diff --git a/CHANGELOG.md b/CHANGELOG.md index 7479cf5ca409..0af39459aec0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,12 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +## [v0.37.10] - 2020-04-13 + +### Bug Fixes + +* (client/context) [\#5964](https://github.com/cosmos/cosmos-sdk/issues/5964) Fix incorrect instantiation of tmlite verifier when --trust-node is off. + ## [v0.37.9] - 2020-04-09 ### Improvements diff --git a/client/context/context.go b/client/context/context.go index 18f50240d4b6..1e8e2d6416d2 100644 --- a/client/context/context.go +++ b/client/context/context.go @@ -74,8 +74,9 @@ func NewCLIContextWithFrom(from string) CLIContext { } } + trustNode := viper.GetBool(flags.FlagTrustNode) // We need to use a single verifier for all contexts - if verifier == nil || verifierHome != viper.GetString(flags.FlagHome) { + if !trustNode && (verifier == nil || verifierHome != viper.GetString(flags.FlagHome)) { verifier = createVerifier() verifierHome = viper.GetString(flags.FlagHome) } @@ -87,7 +88,7 @@ func NewCLIContextWithFrom(from string) CLIContext { From: viper.GetString(flags.FlagFrom), OutputFormat: viper.GetString(cli.OutputFlag), Height: viper.GetInt64(flags.FlagHeight), - TrustNode: viper.GetBool(flags.FlagTrustNode), + TrustNode: trustNode, UseLedger: viper.GetBool(flags.FlagUseLedger), BroadcastMode: viper.GetString(flags.FlagBroadcastMode), Verifier: verifier, @@ -105,16 +106,6 @@ func NewCLIContextWithFrom(from string) CLIContext { func NewCLIContext() CLIContext { return NewCLIContextWithFrom(viper.GetString(flags.FlagFrom)) } func createVerifier() tmlite.Verifier { - trustNodeDefined := viper.IsSet(flags.FlagTrustNode) - if !trustNodeDefined { - return nil - } - - trustNode := viper.GetBool(flags.FlagTrustNode) - if trustNode { - return nil - } - chainID := viper.GetString(flags.FlagChainID) home := viper.GetString(flags.FlagHome) nodeURI := viper.GetString(flags.FlagNode) diff --git a/types/rest/rest_test.go b/types/rest/rest_test.go index 29d24af27dac..eb6c69fa73ed 100644 --- a/types/rest/rest_test.go +++ b/types/rest/rest_test.go @@ -10,11 +10,13 @@ import ( "sort" "testing" + "github.com/spf13/viper" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/secp256k1" "github.com/cosmos/cosmos-sdk/client/context" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" ) @@ -162,6 +164,7 @@ func TestProcessPostResponse(t *testing.T) { Sequence uint64 `json:"sequence"` } + viper.Set(flags.FlagTrustNode, true) // setup ctx := context.NewCLIContext() height := int64(194423) diff --git a/x/distribution/client/common/common_test.go b/x/distribution/client/common/common_test.go index d10ff87c88dc..cd3706983494 100644 --- a/x/distribution/client/common/common_test.go +++ b/x/distribution/client/common/common_test.go @@ -3,15 +3,17 @@ package common import ( "testing" + "github.com/spf13/viper" "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/client/context" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" ) func TestQueryDelegationRewardsAddrValidation(t *testing.T) { - cdc := codec.New() - ctx := context.NewCLIContext().WithCodec(cdc) + viper.Set(flags.FlagTrustNode, true) + ctx := context.NewCLIContext().WithCodec(codec.New()) type args struct { delAddr string valAddr string