Client updates for TM 0.24

This commit is contained in:
Christopher Goes 2018-09-03 18:24:32 +02:00
parent 14d5e686d9
commit 532c9ee95e
3 changed files with 20 additions and 11 deletions

View File

@ -11,6 +11,7 @@ import (
"github.com/spf13/viper"
"github.com/tendermint/tendermint/libs/cli"
"github.com/tendermint/tendermint/libs/log"
tmlite "github.com/tendermint/tendermint/lite"
tmliteProxy "github.com/tendermint/tendermint/lite/proxy"
rpcclient "github.com/tendermint/tendermint/rpc/client"
@ -36,7 +37,7 @@ type CLIContext struct {
Async bool
JSON bool
PrintResponse bool
Certifier tmlite.Certifier
Verifier tmlite.Verifier
DryRun bool
}
@ -63,12 +64,12 @@ func NewCLIContext() CLIContext {
Async: viper.GetBool(client.FlagAsync),
JSON: viper.GetBool(client.FlagJson),
PrintResponse: viper.GetBool(client.FlagPrintResponse),
Certifier: createCertifier(),
Verifier: createVerifier(),
DryRun: viper.GetBool(client.FlagDryRun),
}
}
func createCertifier() tmlite.Certifier {
func createVerifier() tmlite.Verifier {
trustNode := viper.GetBool(client.FlagTrustNode)
if trustNode {
return nil
@ -91,11 +92,13 @@ func createCertifier() tmlite.Certifier {
if errMsg.Len() != 0 {
panic(fmt.Errorf("can't create certifier for distrust mode, empty values from these options: %s", errMsg.String()))
}
certifier, err := tmliteProxy.GetCertifier(chainID, home, nodeURI)
node := rpcclient.NewHTTP(nodeURI, "/websocket")
// TODO Utilize ctx.Logger correctly
verifier, err := tmliteProxy.NewVerifier(chainID, home, node, log.NewNopLogger())
if err != nil {
panic(err)
}
return certifier
return verifier
}
// WithCodec returns a copy of the context with an updated codec.
@ -156,9 +159,9 @@ func (ctx CLIContext) WithUseLedger(useLedger bool) CLIContext {
return ctx
}
// WithCertifier - return a copy of the context with an updated Certifier
func (ctx CLIContext) WithCertifier(certifier tmlite.Certifier) CLIContext {
ctx.Certifier = certifier
// WithVerifier - return a copy of the context with an updated Verifier
func (ctx CLIContext) WithVerifier(verifier tmlite.Verifier) CLIContext {
ctx.Verifier = verifier
return ctx
}

View File

@ -325,8 +325,8 @@ func (ctx CLIContext) query(path string, key cmn.HexBytes) (res []byte, err erro
// verifyProof perform response proof verification
func (ctx CLIContext) verifyProof(path string, resp abci.ResponseQuery) error {
if ctx.Certifier == nil {
return fmt.Errorf("missing valid certifier to verify data from untrusted node")
if ctx.Verifier == nil {
return fmt.Errorf("missing valid verifier to verify data from untrusted node")
}
node, err := ctx.GetNode()
@ -335,7 +335,7 @@ func (ctx CLIContext) verifyProof(path string, resp abci.ResponseQuery) error {
}
// AppHash for height H is in header H+1
commit, err := tmliteProxy.GetCertifiedCommit(resp.Height+1, node, ctx.Certifier)
commit, err := tmliteProxy.GetCertifiedCommit(resp.Height+1, node, ctx.Verifier)
if err != nil {
return err
}

View File

@ -33,6 +33,7 @@ import (
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
nm "github.com/tendermint/tendermint/node"
"github.com/tendermint/tendermint/p2p"
pvm "github.com/tendermint/tendermint/privval"
"github.com/tendermint/tendermint/proxy"
tmrpc "github.com/tendermint/tendermint/rpc/lib/server"
@ -218,9 +219,14 @@ func startTM(
) (*nm.Node, error) {
genDocProvider := func() (*tmtypes.GenesisDoc, error) { return genDoc, nil }
dbProvider := func(*nm.DBContext) (dbm.DB, error) { return dbm.NewMemDB(), nil }
nodeKey, err := p2p.LoadOrGenNodeKey(tmcfg.NodeKeyFile())
if err != nil {
return nil, err
}
node, err := nm.NewNode(
tmcfg,
privVal,
nodeKey,
proxy.NewLocalClientCreator(app),
genDocProvider,
dbProvider,