Cosmos-sdk: simd query auth/account panics

Created on 5 Aug 2020  路  9Comments  路  Source: cosmos/cosmos-sdk

Summary of Bug

When using simd query auth account or simd query account, I get _panic: runtime error: invalid memory address or nil pointer dereference_

Version

nightly-2020-08-05 from https://hub.docker.com/r/interchainio/simapp/tags

Steps to Reproduce

  1. Start a simapp blockchain in the docker container called "simapp"
  2. Run docker exec -it simapp simd query account <a valid address from chain here>
  3. See the error
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x1048882]

goroutine 1 [running]:
github.com/cosmos/cosmos-sdk/x/auth/client/cli.GetAccountCmd.func1(0xc000b98dc0, 0xc000c08db0, 0x1, 0x1, 0x0, 0x0)
        github.com/cosmos/cosmos-sdk/x/auth/client/cli/query.go:102 +0x312
github.com/spf13/cobra.(*Command).execute(0xc000b98dc0, 0xc000c08d90, 0x1, 0x1, 0xc000b98dc0, 0xc000c08d90)
        github.com/spf13/[email protected]/command.go:842 +0x453
github.com/spf13/cobra.(*Command).ExecuteC(0x2851ee0, 0x0, 0x0, 0xc000b722d0)
        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(0x0, 0xc00008a058)
        github.com/cosmos/cosmos-sdk/simapp/simd/cmd/root.go:72 +0x157
main.main()
        github.com/cosmos/cosmos-sdk/simapp/simd/main.go:10 +0x22

For Admin Use

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

Most helpful comment

The data here is not JSON, but rather a protobuf-encoded field, thus we cannot UnmarshalJSON.

I queried the raw store directly over tendermint rpc /store/acc/key and parsed the Any object that comes back and it works (in CosmJS). We just need to properly unpack protobuf in the go client

All 9 comments

Looks like res or res.Account is nil somehow.

            var account types.AccountI
            err = clientCtx.InterfaceRegistry.UnpackAny(res.Account, &account)
            if err != nil {
                return err
            }

Why are we doing this @atheeshp? Can we not just use clientCtx.UnmarshalJSON?

@alexanderbez I added a fmt.Printf("Account: %#v\n", res) right before the panic and get this:

Account: &types.QueryAccountResponse{Account:&types.Any{TypeUrl: "/cosmos.auth.BaseAccount",
Value: []byte{0xa, 0x14, 0xd, 0x82, 0xb1, 0xe7, 0xc9, 0x6d, 0xbf, 0xa4, 0x24, 0x62, 0xfe, 0x61, 0x29, 0x32, 0xe6, 0xbf, 0xf1, 0x11, 0xd5, 0x1b, 0x18, 0x1},
}}

which i manually confirmed as a valid protobuf value for the BaseAccount data.

However, fmt.Printf("Interface Registry: %#v\n", clientCtx.InterfaceRegistry) printed the following:

Interface Registry: <nil>

Seems the interface registry is not being set up properly.

Thanks for the debugging -- it really brings up my original question to @atheeshp of why we don't just call and use clientCtx.JSONMarshaler.UnmarshalJSON.

The data here is not JSON, but rather a protobuf-encoded field, thus we cannot UnmarshalJSON.

I queried the raw store directly over tendermint rpc /store/acc/key and parsed the Any object that comes back and it works (in CosmJS). We just need to properly unpack protobuf in the go client

Thanks @ethanfrey for all the debugging. @sahith-narahari fixed the issue. @webmaster128 do you mind testing it from the PR branch i.e., sahith/fix-simd-query and confirm?

Thank you @anilCSE!

@webmaster128 do you mind testing it from the PR branch i.e., sahith/fix-simd-query and confirm?

I have no Go development environment available (and no plans to change that), sorry.

Thanks @ethanfrey, this was an issue with simapp intialization. I tested with a chain locally, and works with the fix. Will do some more testing on other commands and ensure everything's working

I will test tomorrow morning.

Problem fixed in nightly-2020-08-06, thank you!

Was this page helpful?
0 / 5 - 0 ratings