Update context.Verify
This commit is contained in:
parent
e931195831
commit
1013703115
|
@ -14,10 +14,10 @@ import (
|
||||||
"github.com/cosmos/cosmos-sdk/store"
|
"github.com/cosmos/cosmos-sdk/store"
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
cmn "github.com/tendermint/tendermint/libs/common"
|
cmn "github.com/tendermint/tendermint/libs/common"
|
||||||
"github.com/tendermint/tendermint/lite"
|
|
||||||
tmliteErr "github.com/tendermint/tendermint/lite/errors"
|
tmliteErr "github.com/tendermint/tendermint/lite/errors"
|
||||||
tmliteProxy "github.com/tendermint/tendermint/lite/proxy"
|
tmliteProxy "github.com/tendermint/tendermint/lite/proxy"
|
||||||
rpcclient "github.com/tendermint/tendermint/rpc/client"
|
rpcclient "github.com/tendermint/tendermint/rpc/client"
|
||||||
|
tmtypes "github.com/tendermint/tendermint/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetNode returns an RPC client. If the context's client is not defined, an
|
// GetNode returns an RPC client. If the context's client is not defined, an
|
||||||
|
@ -185,13 +185,13 @@ func (ctx CLIContext) query(path string, key cmn.HexBytes) (res []byte, err erro
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify verifies the consensus proof at given height.
|
// Verify verifies the consensus proof at given height.
|
||||||
func (ctx CLIContext) Verify(height int64) (lite.Commit, error) {
|
func (ctx CLIContext) Verify(height int64) (tmtypes.SignedHeader, error) {
|
||||||
check, err := tmliteProxy.GetCertifiedCommit(height, ctx.Client, ctx.Verifier)
|
check, err := tmliteProxy.GetCertifiedCommit(height, ctx.Client, ctx.Verifier)
|
||||||
switch {
|
switch {
|
||||||
case tmliteErr.IsCommitNotFoundErr(err):
|
case tmliteErr.IsErrCommitNotFound(err):
|
||||||
return lite.Commit{}, ErrVerifyCommit(height)
|
return tmtypes.SignedHeader{}, ErrVerifyCommit(height)
|
||||||
case err != nil:
|
case err != nil:
|
||||||
return lite.Commit{}, err
|
return tmtypes.SignedHeader{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return check, nil
|
return check, nil
|
||||||
|
|
|
@ -46,7 +46,7 @@ func getBlock(cliCtx context.CLIContext, height *int64) ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !cliCtx.TrustNode {
|
if !cliCtx.TrustNode {
|
||||||
check, err := cliCtx.Certify(res.Block.Height)
|
check, err := cliCtx.Verify(res.Block.Height)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@ import (
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"github.com/cosmos/cosmos-sdk/client/context"
|
"github.com/cosmos/cosmos-sdk/client/context"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
tmtypes "github.com/tendermint/tendermint/types"
|
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
tmtypes "github.com/tendermint/tendermint/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO these next two functions feel kinda hacky based on their placement
|
// TODO these next two functions feel kinda hacky based on their placement
|
||||||
|
@ -76,12 +76,12 @@ func getValidators(cliCtx context.CLIContext, height *int64) ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !cliCtx.TrustNode {
|
if !cliCtx.TrustNode {
|
||||||
check, err := cliCtx.Certify(validatorsRes.BlockHeight)
|
check, err := cliCtx.Verify(validatorsRes.BlockHeight)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !bytes.Equal(check.ValidatorsHash(), tmtypes.NewValidatorSet(validatorsRes.Validators).Hash()) {
|
if !bytes.Equal(check.ValidatorsHash, tmtypes.NewValidatorSet(validatorsRes.Validators).Hash()) {
|
||||||
return nil, fmt.Errorf("got invalid validatorset")
|
return nil, fmt.Errorf("got invalid validatorset")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,8 @@ package tx
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
|
||||||
"github.com/tendermint/tendermint/libs/common"
|
"github.com/tendermint/tendermint/libs/common"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -83,7 +83,7 @@ func queryTx(cdc *codec.Codec, cliCtx context.CLIContext, hashHexStr string) ([]
|
||||||
|
|
||||||
// ValidateTxResult performs transaction verification
|
// ValidateTxResult performs transaction verification
|
||||||
func ValidateTxResult(cliCtx context.CLIContext, res *ctypes.ResultTx) error {
|
func ValidateTxResult(cliCtx context.CLIContext, res *ctypes.ResultTx) error {
|
||||||
check, err := cliCtx.Certify(res.Height)
|
check, err := cliCtx.Verify(res.Height)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue