Skip to content

Commit

Permalink
instantiate verifier when --trust-node is on
Browse files Browse the repository at this point in the history
Closes: #5964
  • Loading branch information
Alessio Treglia committed Apr 13, 2020
1 parent 469463a commit 07b8fe0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [v0.37.9] - 2020-04-09

### 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

* (tendermint) Bump Tendermint version to [v0.32.10](https://github.com/tendermint/tendermint/releases/tag/v0.32.10).
Expand Down
15 changes: 3 additions & 12 deletions client/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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,
Expand All @@ -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)
Expand Down

0 comments on commit 07b8fe0

Please sign in to comment.