Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

instantiate verifier when --trust-node is off #5986

Merged
merged 3 commits into from
Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
3 changes: 3 additions & 0 deletions types/rest/rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions x/distribution/client/common/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down