Merge PR #5527: Bump Tendermint Version to v0.33.0

* Bump Tendermint version to v0.33.0

* Deprecate old cmn package with new packages

* Update update DB APIs

* More DB updates

* Bump IAVL to v0.13.0

* Handle error returned by iavl.NewMutableTree

* Fix some IAVL stuffs

* Update IAVL

* More updates

* Passing tests

* Fix unit tests

Co-authored-by: Jack Zampolin <jack.zampolin@gmail.com>
This commit is contained in:
Alexander Bezobchuk
2020-01-16 13:46:51 -08:00
committed by Jack Zampolin
co-authored by Jack Zampolin
parent c92a7389ff
commit c1991e31bd
88 changed files with 577 additions and 344 deletions
+11 -3
View File
@@ -59,14 +59,18 @@ func NewCLIContextWithInputAndFrom(input io.Reader, from string) CLIContext {
genOnly := viper.GetBool(flags.FlagGenerateOnly)
fromAddress, fromName, err := GetFromFields(input, from, genOnly)
if err != nil {
fmt.Printf("failed to get from fields: %v", err)
fmt.Printf("failed to get from fields: %v\n", err)
os.Exit(1)
}
if !genOnly {
nodeURI = viper.GetString(flags.FlagNode)
if nodeURI != "" {
rpc = rpcclient.NewHTTP(nodeURI, "/websocket")
rpc, err = rpcclient.NewHTTP(nodeURI, "/websocket")
if err != nil {
fmt.Printf("failted to get client: %v\n", err)
os.Exit(1)
}
}
}
@@ -154,7 +158,11 @@ func (ctx CLIContext) WithTrustNode(trustNode bool) CLIContext {
// WithNodeURI returns a copy of the context with an updated node URI.
func (ctx CLIContext) WithNodeURI(nodeURI string) CLIContext {
ctx.NodeURI = nodeURI
ctx.Client = rpcclient.NewHTTP(nodeURI, "/websocket")
client, err := rpcclient.NewHTTP(nodeURI, "/websocket")
if err != nil {
panic(err)
}
ctx.Client = client
return ctx
}
+4 -4
View File
@@ -8,7 +8,7 @@ import (
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto/merkle"
cmn "github.com/tendermint/tendermint/libs/common"
tmbytes "github.com/tendermint/tendermint/libs/bytes"
tmliteErr "github.com/tendermint/tendermint/lite/errors"
tmliteProxy "github.com/tendermint/tendermint/lite/proxy"
rpcclient "github.com/tendermint/tendermint/rpc/client"
@@ -45,7 +45,7 @@ func (ctx CLIContext) QueryWithData(path string, data []byte) ([]byte, int64, er
// QueryStore performs a query to a Tendermint node with the provided key and
// store name. It returns the result and height of the query upon success
// or an error if the query fails.
func (ctx CLIContext) QueryStore(key cmn.HexBytes, storeName string) ([]byte, int64, error) {
func (ctx CLIContext) QueryStore(key tmbytes.HexBytes, storeName string) ([]byte, int64, error) {
return ctx.queryStore(key, storeName, "key")
}
@@ -77,7 +77,7 @@ func (ctx CLIContext) GetFromName() string {
// or an error if the query fails. In addition, it will verify the returned
// proof if TrustNode is disabled. If proof verification fails or the query
// height is invalid, an error will be returned.
func (ctx CLIContext) query(path string, key cmn.HexBytes) (res []byte, height int64, err error) {
func (ctx CLIContext) query(path string, key tmbytes.HexBytes) (res []byte, height int64, err error) {
node, err := ctx.GetNode()
if err != nil {
return res, height, err
@@ -167,7 +167,7 @@ func (ctx CLIContext) verifyProof(queryPath string, resp abci.ResponseQuery) err
// queryStore performs a query to a Tendermint node with the provided a store
// name and path. It returns the result and height of the query upon success
// or an error if the query fails.
func (ctx CLIContext) queryStore(key cmn.HexBytes, storeName, endPath string) ([]byte, int64, error) {
func (ctx CLIContext) queryStore(key tmbytes.HexBytes, storeName, endPath string) ([]byte, int64, error) {
path := fmt.Sprintf("/store/%s/%s", storeName, endPath)
return ctx.query(path, key)
}
+6 -1
View File
@@ -38,10 +38,15 @@ func CreateVerifier(ctx CLIContext, cacheSize int) (tmlite.Verifier, error) {
return nil, errors.New("must provide a valid RPC client or RPC URI to create verifier")
}
var err error
// create an RPC client based off of the RPC URI if no RPC client exists
client := ctx.Client
if client == nil {
client = rpcclient.NewHTTP(ctx.NodeURI, "/websocket")
client, err = rpcclient.NewHTTP(ctx.NodeURI, "/websocket")
if err != nil {
return nil, err
}
}
return tmliteproxy.NewVerifier(
+2 -1
View File
@@ -4,8 +4,9 @@ import (
"io/ioutil"
"testing"
"github.com/cosmos/cosmos-sdk/client/context"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/client/context"
)
func TestCreateVerifier(t *testing.T) {