After upgrading, I can't query by tx hash unless I specify the --trust-node flag.
Not specifying the flag results in the following stack trace:
$ ./build/emcli q tx 2B08FC02FA89169C28056867FEB58423F0EA2DB9AC4F43F5BC5098C271E9BF69
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x48e2195]
goroutine 1 [running]:
github.com/tendermint/tendermint/lite/proxy.GetCertifiedCommit(0x9bf8, 0x4f96140, 0xc000b6aae0, 0x0, 0x0, 0xc000f0c160, 0x0, 0x0, 0xc00039c230)
[...]golang/pkg/mod/github.com/tendermint/[email protected]/lite/proxy/query.go:140 +0x105
github.com/cosmos/cosmos-sdk/client/context.CLIContext.Verify(0xc000bab730, 0x4f96140, 0xc000b6aae0, 0x0, 0x0, 0x4f60aa0, 0xc000010010, 0x4c23773, 0x4, 0x0, ...)
[...]golang/pkg/mod/github.com/cosmos/[email protected]/client/context/query.go:116 +0x66
github.com/cosmos/cosmos-sdk/x/auth/client/utils.ValidateTxResult(0xc000bab730, 0x4f96140, 0xc000b6aae0, 0x0, 0x0, 0x4f60aa0, 0xc000010010, 0x4c23773, 0x4, 0x0, ...)
[...]golang/pkg/mod/github.com/cosmos/[email protected]/x/auth/client/utils/query.go:128 +0x8e
github.com/cosmos/cosmos-sdk/x/auth/client/utils.QueryTx(0xc000bab730, 0x4f96140, 0xc000b6aae0, 0x0, 0x0, 0x4f60aa0, 0xc000010010, 0x4c23773, 0x4, 0x0, ...)
[...]golang/pkg/mod/github.com/cosmos/[email protected]/x/auth/client/utils/query.go:93 +0x371
github.com/cosmos/cosmos-sdk/x/auth/client/cli.QueryTxCmd.func1(0xc0000d5180, 0xc000eaf8e0, 0x1, 0x1, 0x0, 0x0)
[...]golang/pkg/mod/github.com/cosmos/[email protected]/x/auth/client/cli/query.go:171 +0x105
github.com/spf13/cobra.(*Command).execute(0xc0000d5180, 0xc000eaf8b0, 0x1, 0x1, 0xc0000d5180, 0xc000eaf8b0)
[...]golang/pkg/mod/github.com/spf13/[email protected]/command.go:826 +0x460
github.com/spf13/cobra.(*Command).ExecuteC(0xc0000d4780, 0x4484560, 0xc0000d4780, 0x4c22784)
[...]golang/pkg/mod/github.com/spf13/[email protected]/command.go:914 +0x2fb
github.com/spf13/cobra.(*Command).Execute(...)
[...]golang/pkg/mod/github.com/spf13/[email protected]/command.go:864
github.com/tendermint/tendermint/libs/cli.Executor.Execute(0xc0000d4780, 0x4e1ae00, 0x2, 0xc000e62ae0)
[...]golang/pkg/mod/github.com/tendermint/[email protected]/libs/cli/setup.go:89 +0x3c
main.main()
[...]em-ledger/cmd/emcli/main.go:76 +0x33d
Cosmos-SDK v0.37.8
Adding the line
viper.SetDefault(flags.FlagTrustNode, "false")
in the main function of the cli seems to fix the issue. Could it be an issue with the updated Viper library?
Checkout our the following em-ledger commit: https://github.com/e-money/em-ledger/commit/d2db6814d4d3138fccf0dcb1aec5cda3c13104cf
make build
./build/emcli q tx 2B08FC02FA89169C28056867FEB58423F0EA2DB9AC4F43F5BC5098C271E9BF69 --node tcp://emoney.validator.network:80
I just made an attempt with the newest version of Gaia, and it seems the problem is also present there.
To reproduce:
The issue can now be demonstrated with the following queries:
./build/gaiacli q tx 136625830D53DE07AE3FDBB35849923908E0C59131EEBECEE6488926B86F63E5 --node tcp://cosmoshub.validator.network:80 --trust-node
Provides expected output with tx details
./build/gaiacli q tx 136625830D53DE07AE3FDBB35849923908E0C59131EEBECEE6488926B86F63E5 --node tcp://cosmoshub.validator.network:80
Crashes with a stacktrace that is very similar to the one in the issue.
@jgimeno do you think you have the bandwidth to tackle this?
Gonna check!
@alexanderbez the problem is that 0.37.x does not include this bugfix.
https://github.com/cosmos/cosmos-sdk/pull/5618
An option can be to upgrade to 0.38 if possible.
Another one is to release a new 0.37 with this included.
I don't think that is a true fix to the issue, but we should certainly cherry-pick that into the next 0.37.x release. This was working before -- which leads me to believe this has something to do with Viper.
More information, from Gaia v2.0.4 stopped working.
It included these changes:
(sdk) Bump SDK version to v0.37.5.
(tendermint) Bump Tendermint version to v0.32.8.
That includes internally too a change from viper 1.4.0 to 1.6.1
Ok I know where is the issue, viper 1.6.0 has this feature
IsSet no longer returns true when an unset key has a flags bound
IsSet no longer returns true when an unset key has a flags bound
Gosh, this breaks quite few things. @jgimeno and I are on the case.
We'll have to change the pruning flags, their parsing heavily relies on IsSet(). We are on it
Would it be an option to downgrade the Viper dependency? Is there something essential in the 1.6 release?
In line of principle, I'm not against downgrading to viper 1.4 - my immediate, natural reaction was to do so. Afterwards, we decided to invest some time in trying to fix the use of viper.IsSet() (in many places it's just plain wrong) whilst keeping cobra/viper in sync with upstream's latest release. If that fails, we fall back to downgrade viper.
Yeah, the problem is that it means that cobra will need to be downgraded too.
Yeah, the problem is that it means that cobra will need to be downgraded too.
Why? Can you not just simply use the replace directive?
Yes, sure we could. We are trying to fix the problem first though.
Experiencing this too when running gaiacli queries on Gaia v2.0.8.
gaiacli q tx 7644CA329A30E58F320B0A1CB8DDB923EB8E2196505A918F06DFC999234C5814
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0xc8d075]
@franono this should solve it https://github.com/cosmos/cosmos-sdk/commit/b75406534d2085a89071ba6b6681513d04ba520e
EDIT: actually I can't reproduce that @franono:
alessio@bangalter:~/work/gaia$ build/gaiacli version --long
name: gaia
server_name: gaiad
client_name: gaiacli
version: 2.0.8
commit: e6f3efff002f74741b05233fe1f05aa893611d53
build_tags: netgo,ledger
go: go version go1.14.2 linux/amd64
alessio@bangalter:~/work/gaia$ build/gaiacli q tx 7644CA329A30E58F320B0A1CB8DDB923EB8E2196505A918F06DFC999234C5814 --trust-node --node tcp://cosmoshub.validator.network:80
height: 1502783
txhash: 7644CA329A30E58F320B0A1CB8DDB923EB8E2196505A918F06DFC999234C5814
code: 0
data: ""
rawlog: '[{"msg_index":0,"success":true,"log":"","events":[{"type":"delegate","attributes":[{"key":"validator","value":"cosmosvaloper1wwspfe7whh3zu4ql5rvpg044lyk6cuu7fpnd9e"},{"key":"amount","value":"407935"}]},{"type":"message","attributes":[{"key":"module","value":"staking"},{"key":"sender","value":"cosmos14fr86wh3dfvpnh88tny4ek257vtp3lr0kkgnx3"},{"key":"action","value":"delegate"}]}]}]'
logs:
- msgindex: 0
success: true
log: ""
events:
- type: delegate
attributes:
- key: validator
value: cosmosvaloper1wwspfe7whh3zu4ql5rvpg044lyk6cuu7fpnd9e
- key: amount
value: "407935"
- type: message
attributes:
- key: module
value: staking
- key: sender
value: cosmos14fr86wh3dfvpnh88tny4ek257vtp3lr0kkgnx3
- key: action
value: delegate
info: ""
gaswanted: 200000
gasused: 107930
codespace: ""
tx:
msg:
- delegator_address: cosmos14fr86wh3dfvpnh88tny4ek257vtp3lr0kkgnx3
validator_address: cosmosvaloper1wwspfe7whh3zu4ql5rvpg044lyk6cuu7fpnd9e
amount:
denom: uatom
amount: "407935"
fee:
amount:
- denom: uatom
amount: "1000"
gas: 200000
signatures:
- |
pubkey: cosmospub1addwnpepqdexmutzj46e29k5q4xjymtautxpy2uhecrmrj7g29z5fndwrm5q24p2sqv
signature: !!binary |
QFe0fKkrt1mwAYnsD3l+yacANlZp8M4miHOW1jEKyDox9RJnyRuuw75a71kH+H8/QycLwp
8EGLmvnYaDqdkQ6w==
memo: Stake via Trust Wallet
timestamp: "2020-04-13T09:16:15Z"
events:
- type: delegate
attributes:
- key: validator
value: cosmosvaloper1wwspfe7whh3zu4ql5rvpg044lyk6cuu7fpnd9e
- key: amount
value: "407935"
- type: message
attributes:
- key: module
value: staking
- key: sender
value: cosmos14fr86wh3dfvpnh88tny4ek257vtp3lr0kkgnx3
- key: action
value: delegate
Nevermind @franono. If I remove the --trust-node flag then I can reproduce it. I'm on it.
This is not solved in the v0.37.x series of cosmos-sdk. Hence reopening.
Fixed in cosmos-sdk v0.37.10. Hence closing.
We need to release this too https://github.com/cosmos/cosmos-sdk/pull/6021. Hence reopening.
This is now fixed in cosmos-sdk v0.37.11. Hence closing.
Most helpful comment
Ok I know where is the issue, viper 1.6.0 has this feature
https://github.com/cosmos/cosmos-sdk/blob/6d5ca0b4f17e1018effd4b56d0c7b9302c651ee4/client/context/context.go#L108