Cosmos-sdk: Account Query Failure

Created on 11 Aug 2020  Â·  14Comments  Â·  Source: cosmos/cosmos-sdk

Summary of Bug

  1. Query for a valid existing account results in the following:
$ simd q account cosmos1khl0wrnwhg4kjx8fe5h8euxff8ke2emy2yk04l --chain-id=$CHAIN_ID
goroutine 1 [running]:
runtime/debug.Stack(0xc0004af3d0, 0x60, 0x60)
        runtime/debug/stack.go:24 +0x9d
runtime/debug.PrintStack()
        runtime/debug/stack.go:16 +0x22
github.com/cosmos/cosmos-sdk/codec/types.anyCompatError(0x53982a0, 0xc, 0x52e1c80, 0xc0000abbc0, 0x535d040, 0x400bf39)
        github.com/cosmos/cosmos-sdk/codec/types/compat.go:24 +0xde
github.com/cosmos/cosmos-sdk/codec/types.Any.MarshalJSON(...)
        github.com/cosmos/cosmos-sdk/codec/types/compat.go:56
github.com/tendermint/go-amino.invokeMarshalJSON(0x5838740, 0xc0005dd680, 0x535d040, 0xc0000ab9e0, 0x16, 0x16, 0x1)
        github.com/tendermint/[email protected]/json-encode.go:412 +0x80
github.com/tendermint/go-amino.(*Codec).encodeReflectJSON(0xc000e953b0, 0x5838740, 0xc0005dd680, 0xc000d904b0, 0x535d040, 0xc0000ab9e0, 0x16, 0x0, 0x0, 0x0, ...)
        github.com/tendermint/[email protected]/json-encode.go:54 +0xa95
github.com/tendermint/go-amino.(*Codec).MarshalJSON(0xc000e953b0, 0x535d040, 0xc0000ab9e0, 0x0, 0x0, 0x5390c04, 0x5, 0x0)
        github.com/tendermint/[email protected]/amino.go:384 +0x1e2
github.com/cosmos/cosmos-sdk/codec.(*LegacyAmino).MarshalJSON(0xc0002acf38, 0x535d040, 0xc0000ab9e0, 0x0, 0x0, 0x0, 0x0, 0x0)
        github.com/cosmos/cosmos-sdk/codec/amino.go:148 +0xa2
github.com/cosmos/cosmos-sdk/codec.(*HybridCodec).MarshalJSON(0xc000e92200, 0x535d040, 0xc0000ab9e0, 0x22, 0x52f12a0, 0xc000ff7760, 0x52f13e0, 0xc0002adcc8)
        github.com/cosmos/cosmos-sdk/codec/hybrid_codec.go:52 +0x48
github.com/cosmos/cosmos-sdk/client.Context.printOutput(0x0, 0x0, 0x0, 0x589c000, 0xc000f6c3f0, 0x7ffeefbff8ae, 0xc, 0x6f99e30, 0xc000e92200, 0x585aba0, ...)
        github.com/cosmos/cosmos-sdk/client/context.go:226 +0x55
github.com/cosmos/cosmos-sdk/client.Context.PrintOutput(...)
        github.com/cosmos/cosmos-sdk/client/context.go:215
github.com/cosmos/cosmos-sdk/x/auth/client/cli.GetAccountCmd.func1(0xc000ed0dc0, 0xc000edd240, 0x1, 0x2, 0x0, 0x0)
        github.com/cosmos/cosmos-sdk/x/auth/client/cli/query.go:101 +0x336
github.com/spf13/cobra.(*Command).execute(0xc000ed0dc0, 0xc000edd220, 0x2, 0x2, 0xc000ed0dc0, 0xc000edd220)
        github.com/spf13/[email protected]/command.go:842 +0x453
github.com/spf13/cobra.(*Command).ExecuteC(0x6490160, 0x0, 0x0, 0xc000e81d60)
        github.com/spf13/[email protected]/command.go:950 +0x349
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/[email protected]/command.go:887
github.com/spf13/cobra.(*Command).ExecuteContext(...)
        github.com/spf13/[email protected]/command.go:880
github.com/cosmos/cosmos-sdk/simapp/simd/cmd.Execute(0x7d000, 0xc0000b4058)
        github.com/cosmos/cosmos-sdk/simapp/simd/cmd/root.go:73 +0x157
main.main()
        github.com/cosmos/cosmos-sdk/simapp/simd/main.go:10 +0x22
Error: JSON marshal marshaling error for {TypeUrl:/cosmos.auth.v1beta1.BaseAccount Value:[10 20 181 254 247 14 110 186 43 105 24 233 205 46 124 240 201 73 237 149 103 100 18 38 235 90 233 135 33 3 117 178 188 254 86 238 225 186 10 56 10 144 86 204 34 167 123 195 56 131 78 231 122 215 207 136 70 180 52 46 85 204 32 1] XXX_NoUnkeyedLiteral:{} XXX_unrecognized:[] XXX_sizecache:0 cachedValue:<nil> compat:<nil>}, this is likely because amino is being used directly (instead of codec.LegacyAmino which is preferred) or UnpackInterfacesMessage is not defined for some type which contains a protobuf Any either directly or via one of its members. To see a stacktrace of where the error is coming from, set the var Debug = true in codec/types/compat.go
  1. Query for a valid non-existing account results in the super vague error:
$ simd q account cosmos1xg5ahw8r8vwgzjh6uwamszkzx06ndkpk2fnvk5 --chain-id=$CHAIN_ID 
Error: internal

Version

master as of 1744194e7

Steps to Reproduce

  1. Start a local network
  2. Query for accounts both existing and non-existing

For Admin Use

  • [ ] Not duplicate issue
  • [ ] Appropriate labels applied
  • [ ] Appropriate contributors tagged
  • [ ] Contributor assigned/self-assigned
bug auth

Most helpful comment

A fix for 2 and 3 is in #6973

All 14 comments

Maybe (1) is expected because we haven't finished some sort of client migration or something...idk? But (2) should be addressed for sure.

Hmm... I imagine this is because we are in the middle of enabling proto JSON and disabling amino JSON. Integration tests now use proto but the binaries still use amino. That switch will be flipped after #6859 is merged. I split it into 3 PRs to make review easy. Sorry for the janky transition.

Will close this after those PR(s) are merged then.

We need to check and see if that fixed it. There could be something else. @sahith-narahari ?

Now I can't even start a network...

$ make clean localnetwork-start
panic: cannot protobuf JSON encode unsupported type: types.GenesisState

goroutine 1 [running]:
github.com/cosmos/cosmos-sdk/codec.(*ProtoCodec).MustMarshalJSON(0xc000dff820, 0x16fbce0, 0xc00016e9c0, 0xc00016e9c0, 0x4, 0x4)
        github.com/cosmos/cosmos-sdk/codec/proto_codec.go:110 +0x8a
github.com/cosmos/cosmos-sdk/simapp/simd/cmd.initGenFiles(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7ff704afeb30, 0xc000dff820, 0x1c2c6c0, ...)
        github.com/cosmos/cosmos-sdk/simapp/simd/cmd/testnet.go:291 +0x22c
github.com/cosmos/cosmos-sdk/simapp/simd/cmd.InitTestnet(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7ff704afeb30, 0xc000dff820, 0x1c2c6c0, ...)
        github.com/cosmos/cosmos-sdk/simapp/simd/cmd/testnet.go:257 +0x2398
github.com/cosmos/cosmos-sdk/simapp/simd/cmd.testnetCmd.func1(0xc000e62840, 0xc0005ffa70, 0x0, 0x9, 0x0, 0x0)
        github.com/cosmos/cosmos-sdk/simapp/simd/cmd/testnet.go:77 +0x50d
github.com/spf13/cobra.(*Command).execute(0xc000e62840, 0xc0005ff9e0, 0x9, 0x9, 0xc000e62840, 0xc0005ff9e0)
        github.com/spf13/[email protected]/command.go:842 +0x47c
github.com/spf13/cobra.(*Command).ExecuteC(0x26364e0, 0x0, 0x0, 0xc000de1730)
        github.com/spf13/[email protected]/command.go:950 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/[email protected]/command.go:887
github.com/spf13/cobra.(*Command).ExecuteContext(...)
        github.com/spf13/[email protected]/command.go:880
github.com/cosmos/cosmos-sdk/simapp/simd/cmd.Execute(0x15d6680, 0xc00008c058)
        github.com/cosmos/cosmos-sdk/simapp/simd/cmd/root.go:75 +0x159
main.main()
        github.com/cosmos/cosmos-sdk/simapp/simd/main.go:10 +0x25
make: *** [localnet-start] Error 2

(mental note to self: Sigh...I think we need to bring back the localnet bash script)

Looks like the query account is still failing, I added a test here for the same #6973

I would first look into making sure we can actually start a network...

How hard do you think it would be to bring back some of the out of process integration tests for critical commands? We don't need all the module tests out of process - maybe just tx send and core stuff like init and start.

I was thinking just brining back the liveness.sh bash script back and that's it. We don't necessarily need to test individual commands like that, we need to test can we actually start a network.

IMHO: the issue here is the missing interface implementation. The address in the response is of type Any but there is no UnpackInterfaces implementation. To verify, please do:

var _ codectypes.UnpackInterfacesMessage = &QueryAccountResponse{}

and a fix is likely:

+func (m *QueryAccountResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
+       var account AccountI
+       return unpacker.UnpackAny(m.Account, &account)
+}

Which issue @alpe? There are three currently:

  1. Can't even start a network
  2. Can't query an existing account
  3. Unhelpful error message when querying a non-existent account
  1. Can't query an existing account

Sorry for the confusion, I came from #7034. I have not looked into the other problems.

That's exactly the fix thanks @alpe !

I am working on addressing all 3.

A fix for 2 and 3 is in #6973

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rigelrozanski picture rigelrozanski  Â·  3Comments

rigelrozanski picture rigelrozanski  Â·  3Comments

ValarDragon picture ValarDragon  Â·  3Comments

fedekunze picture fedekunze  Â·  3Comments

rigelrozanski picture rigelrozanski  Â·  3Comments