diff --git a/Makefile b/Makefile index 29a7526175e8..b37aec3fd123 100644 --- a/Makefile +++ b/Makefile @@ -335,13 +335,18 @@ proto-check-breaking-docker: @$(DOCKER_BUF) check breaking --against-input $(HTTPS_GIT)#branch=master .PHONY: proto-check-breaking-ci -TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.33.1 +TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/master + GOGO_PROTO_URL = https://raw.githubusercontent.com/regen-network/protobuf/cosmos COSMOS_PROTO_URL = https://raw.githubusercontent.com/regen-network/cosmos-proto/master -TM_KV_TYPES = third_party/proto/tendermint/libs/kv -TM_MERKLE_TYPES = third_party/proto/tendermint/crypto/merkle -TM_ABCI_TYPES = third_party/proto/tendermint/abci/types +TM_MERKLE_TYPES = third_party/proto/tendermint/crypto +TM_KEY_TYPES = third_party/proto/tendermint/crypto +TM_ABCI_TYPES = third_party/proto/tendermint/abci +TM_TYPES = third_party/proto/tendermint/types +TM_VERSION = third_party/proto/tendermint/version +TM_LIBS = third_party/proto/tendermint/libs/bits + GOGO_PROTO_TYPES = third_party/proto/gogoproto COSMOS_PROTO_TYPES = third_party/proto/cosmos_proto @@ -357,19 +362,25 @@ proto-update-deps: ## (which is the standard Buf.build FILE_LAYOUT) ## Issue link: https://github.com/tendermint/tendermint/issues/5021 @mkdir -p $(TM_ABCI_TYPES) - @curl -sSL $(TM_URL)/abci/types/types.proto > $(TM_ABCI_TYPES)/types.proto - @sed -i '' '7 s|third_party/proto/||g' $(TM_ABCI_TYPES)/types.proto - @sed -i '' '8 s|crypto/merkle/merkle.proto|tendermint/crypto/merkle/merkle.proto|g' $(TM_ABCI_TYPES)/types.proto - @sed -i '' '9 s|libs/kv/types.proto|tendermint/libs/kv/types.proto|g' $(TM_ABCI_TYPES)/types.proto + @curl -sSL $(TM_URL)/proto/tendermint/abci/types.proto > $(TM_ABCI_TYPES)/types.proto + + @mkdir -p $(TM_VERSION) + @curl -sSL $(TM_URL)/proto/tendermint/version/types.proto > $(TM_VERSION)/types.proto - @mkdir -p $(TM_KV_TYPES) - @curl -sSL $(TM_URL)/libs/kv/types.proto > $(TM_KV_TYPES)/types.proto - @sed -i '' '5 s|third_party/proto/||g' $(TM_KV_TYPES)/types.proto + + @mkdir -p $(TM_TYPES) + @curl -sSL $(TM_URL)/proto/tendermint/types/types.proto > $(TM_TYPES)/types.proto + @curl -sSL $(TM_URL)/proto/tendermint/types/evidence.proto > $(TM_TYPES)/evidence.proto + @curl -sSL $(TM_URL)/proto/tendermint/types/params.proto > $(TM_TYPES)/params.proto @mkdir -p $(TM_MERKLE_TYPES) - @curl -sSL $(TM_URL)/crypto/merkle/merkle.proto > $(TM_MERKLE_TYPES)/merkle.proto - @sed -i '' '7 s|third_party/proto/||g' $(TM_MERKLE_TYPES)/merkle.proto + @curl -sSL $(TM_URL)/proto/tendermint/crypto/proof.proto > $(TM_MERKLE_TYPES)/proof.proto + + @mkdir -p $(TM_KEY_TYPES) + @curl -sSL $(TM_URL)/proto/tendermint/crypto/keys.proto > $(TM_KEY_TYPES)/keys.proto + @mkdir -p $(TM_LIBS) + @curl -sSL $(TM_URL)/proto/tendermint/libs/bits/types.proto > $(TM_LIBS)/types.proto .PHONY: proto-all proto-gen proto-lint proto-check-breaking proto-update-deps diff --git a/SECURITY.md b/SECURITY.md index ce82a957f9bb..4adb59c22e27 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -13,7 +13,7 @@ this [blog post](https://blog.cosmos.network/bug-bounty-program-for-tendermint-c The following is a list of examples of the kinds of bugs we're most interested in for the Cosmos SDK. See [here](https://github.com/tendermint/tendermint/blob/master/SECURITY.md) for vulnerabilities we are interested -in for Tendermint and other lower-level libraries (eg. [IAVL](https://github.com/tendermint/iavl)). +in for Tendermint and other lower-level libraries (eg. [IAVL](https://github.com/cosmos/iavl)). ### Core packages diff --git a/baseapp/abci.go b/baseapp/abci.go index e5784479e7be..b81d7255dab6 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -8,7 +8,9 @@ import ( "syscall" "time" + "github.com/gogo/protobuf/proto" abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/telemetry" @@ -19,7 +21,7 @@ import ( // InitChain implements the ABCI interface. It runs the initialization logic // directly on the CommitMultiStore. func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitChain) { - initHeader := abci.Header{ChainID: req.ChainId, Time: req.Time} + initHeader := tmproto.Header{ChainID: req.ChainId, Time: req.Time} // initialize the deliver state and check state with a correct header app.setDeliverState(initHeader) @@ -56,7 +58,7 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC sort.Sort(abci.ValidatorUpdates(res.Validators)) for i, val := range res.Validators { - if !val.Equal(req.Validators[i]) { + if !proto.Equal(&val, &req.Validators[i]) { panic(fmt.Errorf("genesisValidators[%d] != req.Validators[%d] ", i, i)) } } @@ -552,3 +554,19 @@ func splitPath(requestPath string) (path []string) { return path } + +func (app *BaseApp) ListSnapshots(abci.RequestListSnapshots) abci.ResponseListSnapshots { + return abci.ResponseListSnapshots{} +} + +func (app *BaseApp) OfferSnapshot(abci.RequestOfferSnapshot) abci.ResponseOfferSnapshot { + return abci.ResponseOfferSnapshot{} +} + +func (app *BaseApp) LoadSnapshotChunk(abci.RequestLoadSnapshotChunk) abci.ResponseLoadSnapshotChunk { + return abci.ResponseLoadSnapshotChunk{} +} + +func (app *BaseApp) ApplySnapshotChunk(abci.RequestApplySnapshotChunk) abci.ResponseApplySnapshotChunk { + return abci.ResponseApplySnapshotChunk{} +} diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 281c869e72b0..92d8df2a54c8 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -10,6 +10,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto/tmhash" "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/store" @@ -257,7 +258,7 @@ func (app *BaseApp) init() error { } // needed for the export command which inits from store but never calls initchain - app.setCheckState(abci.Header{}) + app.setCheckState(tmproto.Header{}) app.Seal() return nil @@ -310,7 +311,7 @@ func (app *BaseApp) IsSealed() bool { return app.sealed } // (i.e. a CacheMultiStore) and a new Context with the cache-wrapped multi-store, // provided header, and minimum gas prices set. It is set on InitChain and reset // on Commit. -func (app *BaseApp) setCheckState(header abci.Header) { +func (app *BaseApp) setCheckState(header tmproto.Header) { ms := app.cms.CacheMultiStore() app.checkState = &state{ ms: ms, @@ -322,7 +323,7 @@ func (app *BaseApp) setCheckState(header abci.Header) { // (i.e. a CacheMultiStore) and a new Context with the cache-wrapped multi-store, // and provided header. It is set on InitChain and BeginBlock and set to nil on // Commit. -func (app *BaseApp) setDeliverState(header abci.Header) { +func (app *BaseApp) setDeliverState(header tmproto.Header) { ms := app.cms.CacheMultiStore() app.deliverState = &state{ ms: ms, @@ -347,14 +348,14 @@ func (app *BaseApp) GetConsensusParams(ctx sdk.Context) *abci.ConsensusParams { } if app.paramStore.Has(ctx, ParamStoreKeyEvidenceParams) { - var ep abci.EvidenceParams + var ep tmproto.EvidenceParams app.paramStore.Get(ctx, ParamStoreKeyEvidenceParams, &ep) cp.Evidence = &ep } if app.paramStore.Has(ctx, ParamStoreKeyValidatorParams) { - var vp abci.ValidatorParams + var vp tmproto.ValidatorParams app.paramStore.Get(ctx, ParamStoreKeyValidatorParams, &vp) cp.Validator = &vp diff --git a/baseapp/baseapp_test.go b/baseapp/baseapp_test.go index 3dcef1600b15..7b4537c099a9 100644 --- a/baseapp/baseapp_test.go +++ b/baseapp/baseapp_test.go @@ -17,6 +17,7 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/codec" @@ -137,13 +138,13 @@ func TestLoadVersion(t *testing.T) { require.Equal(t, emptyCommitID, lastID) // execute a block, collect commit ID - header := abci.Header{Height: 1} + header := tmproto.Header{Height: 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) res := app.Commit() commitID1 := sdk.CommitID{Version: 1, Hash: res.Data} // execute a block, collect commit ID - header = abci.Header{Height: 2} + header = tmproto.Header{Height: 2} app.BeginBlock(abci.RequestBeginBlock{Header: header}) res = app.Commit() commitID2 := sdk.CommitID{Version: 2, Hash: res.Data} @@ -242,7 +243,7 @@ func TestSetLoader(t *testing.T) { require.Nil(t, err) // "execute" one block - app.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: 2}}) + app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: 2}}) res := app.Commit() require.NotNil(t, res.Data) @@ -287,7 +288,7 @@ func TestLoadVersionInvalid(t *testing.T) { err = app.LoadVersion(-1) require.Error(t, err) - header := abci.Header{Height: 1} + header := tmproto.Header{Height: 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) res := app.Commit() commitID1 := sdk.CommitID{Version: 1, Hash: res.Data} @@ -337,7 +338,7 @@ func TestLoadVersionPruning(t *testing.T) { // Commit seven blocks, of which 7 (latest) is kept in addition to 6, 5 // (keep recent) and 3 (keep every). for i := int64(1); i <= 7; i++ { - app.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: i}}) + app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: i}}) res := app.Commit() lastCommitID = sdk.CommitID{Version: i, Hash: res.Data} } @@ -527,7 +528,7 @@ func TestInitChainer(t *testing.T) { require.Equal(t, value, res.Value) // commit and ensure we can still query - header := abci.Header{Height: app.LastBlockHeight() + 1} + header := tmproto.Header{Height: app.LastBlockHeight() + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) app.Commit() @@ -783,7 +784,7 @@ func TestCheckTx(t *testing.T) { require.Equal(t, nTxs, storedCounter) // If a block is committed, CheckTx state should be reset. - header := abci.Header{Height: 1} + header := tmproto.Header{Height: 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) app.EndBlock(abci.RequestEndBlock{}) app.Commit() @@ -818,7 +819,7 @@ func TestDeliverTx(t *testing.T) { txPerHeight := 5 for blockN := 0; blockN < nBlocks; blockN++ { - header := abci.Header{Height: int64(blockN) + 1} + header := tmproto.Header{Height: int64(blockN) + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) for i := 0; i < txPerHeight; i++ { @@ -872,7 +873,7 @@ func TestMultiMsgDeliverTx(t *testing.T) { // run a multi-msg tx // with all msgs the same route - header := abci.Header{Height: 1} + header := tmproto.Header{Height: 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) tx := newTxCounter(0, 0, 1, 2) txBytes, err := codec.MarshalBinaryBare(tx) @@ -953,7 +954,7 @@ func TestSimulateTx(t *testing.T) { nBlocks := 3 for blockN := 0; blockN < nBlocks; blockN++ { count := int64(blockN + 1) - header := abci.Header{Height: count} + header := tmproto.Header{Height: count} app.BeginBlock(abci.RequestBeginBlock{Header: header}) tx := newTxCounter(count, count) @@ -1008,7 +1009,7 @@ func TestRunInvalidTransaction(t *testing.T) { app := setupBaseApp(t, anteOpt, routerOpt) - header := abci.Header{Height: 1} + header := tmproto.Header{Height: 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) // transaction with no messages @@ -1136,7 +1137,7 @@ func TestTxGasLimits(t *testing.T) { app := setupBaseApp(t, anteOpt, routerOpt) - header := abci.Header{Height: 1} + header := tmproto.Header{Height: 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) testCases := []struct { @@ -1250,7 +1251,7 @@ func TestMaxBlockGasLimits(t *testing.T) { tx := tc.tx // reset the block gas - header := abci.Header{Height: app.LastBlockHeight() + 1} + header := tmproto.Header{Height: app.LastBlockHeight() + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) // execute the transaction multiple times @@ -1304,7 +1305,7 @@ func TestCustomRunTxPanicHandler(t *testing.T) { app := setupBaseApp(t, anteOpt, routerOpt) - header := abci.Header{Height: 1} + header := tmproto.Header{Height: 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) app.AddRunTxRecoveryHandler(func(recoveryObj interface{}) error { @@ -1346,7 +1347,7 @@ func TestBaseAppAnteHandler(t *testing.T) { app.InitChain(abci.RequestInitChain{}) registerTestCodec(cdc) - header := abci.Header{Height: app.LastBlockHeight() + 1} + header := tmproto.Header{Height: app.LastBlockHeight() + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) // execute a tx that will fail ante handler execution @@ -1454,7 +1455,7 @@ func TestGasConsumptionBadTx(t *testing.T) { app.InitChain(abci.RequestInitChain{}) - header := abci.Header{Height: app.LastBlockHeight() + 1} + header := tmproto.Header{Height: app.LastBlockHeight() + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) tx := newTxCounter(5, 0) @@ -1519,7 +1520,7 @@ func TestQuery(t *testing.T) { require.Equal(t, 0, len(res.Value)) // query is still empty after a DeliverTx before we commit - header := abci.Header{Height: app.LastBlockHeight() + 1} + header := tmproto.Header{Height: app.LastBlockHeight() + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) _, resTx, err = app.Deliver(tx) @@ -1545,7 +1546,7 @@ func TestGRPCQuery(t *testing.T) { app := setupBaseApp(t, grpcQueryOpt) app.InitChain(abci.RequestInitChain{}) - header := abci.Header{Height: app.LastBlockHeight() + 1} + header := tmproto.Header{Height: app.LastBlockHeight() + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) app.Commit() @@ -1602,7 +1603,7 @@ func TestP2PQuery(t *testing.T) { func TestGetMaximumBlockGas(t *testing.T) { app := setupBaseApp(t) app.InitChain(abci.RequestInitChain{}) - ctx := app.NewContext(true, abci.Header{}) + ctx := app.NewContext(true, tmproto.Header{}) app.StoreConsensusParams(ctx, &abci.ConsensusParams{Block: &abci.BlockParams{MaxGas: 0}}) require.Equal(t, uint64(0), app.getMaximumBlockGas(ctx)) @@ -1660,7 +1661,7 @@ func TestWithRouter(t *testing.T) { txPerHeight := 5 for blockN := 0; blockN < nBlocks; blockN++ { - header := abci.Header{Height: int64(blockN) + 1} + header := tmproto.Header{Height: int64(blockN) + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) for i := 0; i < txPerHeight; i++ { diff --git a/baseapp/helpers.go b/baseapp/helpers.go index c69a8ba82925..2fb7cc041a56 100644 --- a/baseapp/helpers.go +++ b/baseapp/helpers.go @@ -1,7 +1,7 @@ package baseapp import ( - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -19,7 +19,7 @@ func (app *BaseApp) Deliver(tx sdk.Tx) (sdk.GasInfo, *sdk.Result, error) { } // Context with current {check, deliver}State of the app used by tests. -func (app *BaseApp) NewContext(isCheckTx bool, header abci.Header) sdk.Context { +func (app *BaseApp) NewContext(isCheckTx bool, header tmproto.Header) sdk.Context { if isCheckTx { return sdk.NewContext(app.checkState.ms, header, true, app.logger). WithMinGasPrices(app.minGasPrices) @@ -28,6 +28,6 @@ func (app *BaseApp) NewContext(isCheckTx bool, header abci.Header) sdk.Context { return sdk.NewContext(app.deliverState.ms, header, false, app.logger) } -func (app *BaseApp) NewUncachedContext(isCheckTx bool, header abci.Header) sdk.Context { +func (app *BaseApp) NewUncachedContext(isCheckTx bool, header tmproto.Header) sdk.Context { return sdk.NewContext(app.cms, header, isCheckTx, app.logger) } diff --git a/baseapp/params.go b/baseapp/params.go index 832397fb81e9..a49145fb1418 100644 --- a/baseapp/params.go +++ b/baseapp/params.go @@ -5,6 +5,7 @@ import ( "fmt" abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -49,7 +50,7 @@ func ValidateBlockParams(i interface{}) error { // ValidateEvidenceParams defines a stateless validation on EvidenceParams. This // function is called whenever the parameters are updated or stored. func ValidateEvidenceParams(i interface{}) error { - v, ok := i.(abci.EvidenceParams) + v, ok := i.(tmproto.EvidenceParams) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } @@ -68,7 +69,7 @@ func ValidateEvidenceParams(i interface{}) error { // ValidateValidatorParams defines a stateless validation on ValidatorParams. This // function is called whenever the parameters are updated or stored. func ValidateValidatorParams(i interface{}) error { - v, ok := i.(abci.ValidatorParams) + v, ok := i.(tmproto.ValidatorParams) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } diff --git a/baseapp/params_test.go b/baseapp/params_test.go index 46eb08005f25..a3265a86bcb9 100644 --- a/baseapp/params_test.go +++ b/baseapp/params_test.go @@ -5,6 +5,7 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/baseapp" ) @@ -33,11 +34,11 @@ func TestValidateEvidenceParams(t *testing.T) { expectErr bool }{ {nil, true}, - {&abci.EvidenceParams{}, true}, - {abci.EvidenceParams{}, true}, - {abci.EvidenceParams{MaxAgeNumBlocks: -1, MaxAgeDuration: 18004000}, true}, - {abci.EvidenceParams{MaxAgeNumBlocks: 360000, MaxAgeDuration: -1}, true}, - {abci.EvidenceParams{MaxAgeNumBlocks: 360000, MaxAgeDuration: 18004000}, false}, + {&tmproto.EvidenceParams{}, true}, + {tmproto.EvidenceParams{}, true}, + {tmproto.EvidenceParams{MaxAgeNumBlocks: -1, MaxAgeDuration: 18004000}, true}, + {tmproto.EvidenceParams{MaxAgeNumBlocks: 360000, MaxAgeDuration: -1}, true}, + {tmproto.EvidenceParams{MaxAgeNumBlocks: 360000, MaxAgeDuration: 18004000}, false}, } for _, tc := range testCases { @@ -51,10 +52,10 @@ func TestValidateValidatorParams(t *testing.T) { expectErr bool }{ {nil, true}, - {&abci.ValidatorParams{}, true}, - {abci.ValidatorParams{}, true}, - {abci.ValidatorParams{PubKeyTypes: []string{}}, true}, - {abci.ValidatorParams{PubKeyTypes: []string{"secp256k1"}}, false}, + {&tmproto.ValidatorParams{}, true}, + {tmproto.ValidatorParams{}, true}, + {tmproto.ValidatorParams{PubKeyTypes: []string{}}, true}, + {tmproto.ValidatorParams{PubKeyTypes: []string{"secp256k1"}}, false}, } for _, tc := range testCases { diff --git a/client/debug/main.go b/client/debug/main.go index eb2a3ecb2f5f..e2584f761652 100644 --- a/client/debug/main.go +++ b/client/debug/main.go @@ -34,17 +34,17 @@ func Cmd() *cobra.Command { // to decode the pubkey string from hex, base64, and finally bech32. If all // encodings fail, an error is returned. func getPubKeyFromString(pkstr string) (crypto.PubKey, error) { - var pubKey ed25519.PubKeyEd25519 + pubKey := make(ed25519.PubKey, ed25519.PubKeySize) bz, err := hex.DecodeString(pkstr) if err == nil { - copy(pubKey[:], bz) + copy(pubKey, bz) return pubKey, nil } bz, err = base64.StdEncoding.DecodeString(pkstr) if err == nil { - copy(pubKey[:], bz) + copy(pubKey, bz) return pubKey, nil } @@ -85,7 +85,7 @@ $ %s debug pubkey cosmos1e0jnq2sun3dzjh8p2xq95kk0expwmd7shwjpfg return err } - edPK, ok := pk.(ed25519.PubKeyEd25519) + edPK, ok := pk.(ed25519.PubKey) if !ok { return fmt.Errorf("invalid pubkey type; expected ED25519") } diff --git a/client/rpc/validators.go b/client/rpc/validators.go index 8038ff923f6e..96b9ff6a8984 100644 --- a/client/rpc/validators.go +++ b/client/rpc/validators.go @@ -119,7 +119,7 @@ func GetValidators(clientCtx client.Context, height *int64, page, limit int) (Re return ResultValidatorsOutput{}, err } - validatorsRes, err := node.Validators(height, page, limit) + validatorsRes, err := node.Validators(height, &page, &limit) if err != nil { return ResultValidatorsOutput{}, err } diff --git a/codec/amino.go b/codec/amino.go index a7348ee4b8e0..00dd07e2b8ce 100644 --- a/codec/amino.go +++ b/codec/amino.go @@ -8,7 +8,6 @@ import ( "io" amino "github.com/tendermint/go-amino" - tmtypes "github.com/tendermint/tendermint/types" "github.com/cosmos/cosmos-sdk/codec/types" ) @@ -29,12 +28,6 @@ func New() *Codec { return &Codec{amino.NewCodec()} } -// RegisterEvidences registers Tendermint evidence types with the provided Amino -// codec. -func RegisterEvidences(cdc *Codec) { - tmtypes.RegisterEvidences(cdc.Amino) -} - // MarshalJSONIndent provides a utility for indented JSON encoding of an object // via an Amino codec. It returns an error if it cannot serialize or indent as // JSON. diff --git a/codec/legacy/codec.go b/codec/legacy/codec.go index f4e0e5be3fdc..59f22b1213be 100644 --- a/codec/legacy/codec.go +++ b/codec/legacy/codec.go @@ -14,6 +14,5 @@ var Cdc *codec.Codec func init() { Cdc = codec.New() cryptocodec.RegisterCrypto(Cdc) - codec.RegisterEvidences(Cdc) Cdc.Seal() } diff --git a/crypto/armor.go b/crypto/armor.go index 933f2eafc0bc..d0637c709d13 100644 --- a/crypto/armor.go +++ b/crypto/armor.go @@ -9,6 +9,7 @@ import ( "github.com/tendermint/tendermint/crypto/armor" "github.com/tendermint/tendermint/crypto/xsalsa20symmetric" + "github.com/cosmos/cosmos-sdk/codec/legacy" cryptoAmino "github.com/cosmos/cosmos-sdk/crypto/codec" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -151,7 +152,7 @@ func encryptPrivKey(privKey crypto.PrivKey, passphrase string) (saltBytes []byte } key = crypto.Sha256(key) // get 32 bytes - privKeyBytes := privKey.Bytes() + privKeyBytes := legacy.Cdc.Amino.MustMarshalBinaryBare(privKey) return saltBytes, xsalsa20symmetric.EncryptSymmetric(privKeyBytes, key) } diff --git a/crypto/armor_test.go b/crypto/armor_test.go index 52d2922b54cd..bae55639bf35 100644 --- a/crypto/armor_test.go +++ b/crypto/armor_test.go @@ -39,7 +39,7 @@ func TestArmorUnarmorPrivKey(t *testing.T) { require.Empty(t, algo) // wrong key type - armored = crypto.ArmorPubKeyBytes(priv.PubKey().Bytes(), "") + armored = crypto.ArmorPubKeyBytes(keyring.CryptoCdc.Amino.MustMarshalBinaryBare(priv.PubKey), "") _, _, err = crypto.UnarmorDecryptPrivKey(armored, "passphrase") require.Error(t, err) require.Contains(t, err.Error(), "unrecognized armor type") @@ -50,7 +50,7 @@ func TestArmorUnarmorPrivKey(t *testing.T) { key, err := bcrypt.GenerateFromPassword(saltBytes, []byte(passphrase), crypto.BcryptSecurityParameter) require.NoError(t, err) key = tmcrypto.Sha256(key) // get 32 bytes - privKeyBytes := privKey.Bytes() + privKeyBytes := keyring.CryptoCdc.Amino.MustMarshalBinaryBare(privKey) return saltBytes, xsalsa20symmetric.EncryptSymmetric(privKeyBytes, key) } saltBytes, encBytes := encryptPrivKeyFn(priv, "passphrase") @@ -74,7 +74,7 @@ func TestArmorUnarmorPubKey(t *testing.T) { // Add keys and see they return in alphabetical order info, _, err := cstore.NewMnemonic("Bob", keyring.English, types.FullFundraiserPath, hd.Secp256k1) require.NoError(t, err) - armored := crypto.ArmorPubKeyBytes(info.GetPubKey().Bytes(), "") + armored := crypto.ArmorPubKeyBytes(keyring.CryptoCdc.Amino.MustMarshalBinaryBare(info.GetPubKey()), "") pubBytes, algo, err := crypto.UnarmorPubKeyBytes(armored) require.NoError(t, err) pub, err := cryptoAmino.PubKeyFromBytes(pubBytes) @@ -82,7 +82,7 @@ func TestArmorUnarmorPubKey(t *testing.T) { require.Equal(t, string(hd.Secp256k1Type), algo) require.True(t, pub.Equals(info.GetPubKey())) - armored = crypto.ArmorPubKeyBytes(info.GetPubKey().Bytes(), "unknown") + armored = crypto.ArmorPubKeyBytes(keyring.CryptoCdc.Amino.MustMarshalBinaryBare(info.GetPubKey()), "unknown") pubBytes, algo, err = crypto.UnarmorPubKeyBytes(armored) require.NoError(t, err) pub, err = cryptoAmino.PubKeyFromBytes(pubBytes) diff --git a/crypto/codec/amino.go b/crypto/codec/amino.go index 9ef14fe93d8d..13a311361e88 100644 --- a/crypto/codec/amino.go +++ b/crypto/codec/amino.go @@ -21,22 +21,22 @@ func init() { // codec. func RegisterCrypto(cdc *codec.Codec) { cdc.RegisterInterface((*crypto.PubKey)(nil), nil) - cdc.RegisterConcrete(ed25519.PubKeyEd25519{}, - ed25519.PubKeyAminoName, nil) - cdc.RegisterConcrete(sr25519.PubKeySr25519{}, - sr25519.PubKeyAminoName, nil) - cdc.RegisterConcrete(secp256k1.PubKeySecp256k1{}, - secp256k1.PubKeyAminoName, nil) + cdc.RegisterConcrete(ed25519.PubKey{}, + ed25519.PubKeyName, nil) + cdc.RegisterConcrete(sr25519.PubKey{}, + sr25519.PubKeyName, nil) + cdc.RegisterConcrete(secp256k1.PubKey{}, + secp256k1.PubKeyName, nil) cdc.RegisterConcrete(multisig.PubKeyMultisigThreshold{}, multisig.PubKeyAminoRoute, nil) cdc.RegisterInterface((*crypto.PrivKey)(nil), nil) - cdc.RegisterConcrete(ed25519.PrivKeyEd25519{}, - ed25519.PrivKeyAminoName, nil) - cdc.RegisterConcrete(sr25519.PrivKeySr25519{}, - sr25519.PrivKeyAminoName, nil) - cdc.RegisterConcrete(secp256k1.PrivKeySecp256k1{}, - secp256k1.PrivKeyAminoName, nil) + cdc.RegisterConcrete(ed25519.PrivKey{}, + ed25519.PrivKeyName, nil) + cdc.RegisterConcrete(sr25519.PrivKey{}, + sr25519.PrivKeyName, nil) + cdc.RegisterConcrete(secp256k1.PrivKey{}, + secp256k1.PrivKeyName, nil) } // PrivKeyFromBytes unmarshals private key bytes and returns a PrivKey diff --git a/crypto/hd/algo.go b/crypto/hd/algo.go index 264f0ae8dfe6..5bf1d1ea71a7 100644 --- a/crypto/hd/algo.go +++ b/crypto/hd/algo.go @@ -61,8 +61,8 @@ func (s secp256k1Algo) Derive() DeriveFn { // Generate generates a secp256k1 private key from the given bytes. func (s secp256k1Algo) Generate() GenerateFn { return func(bz []byte) crypto.PrivKey { - var bzArr [32]byte - copy(bzArr[:], bz) - return secp256k1.PrivKeySecp256k1(bzArr) + var bzArr = make([]byte, secp256k1.PrivKeySize) + copy(bzArr, bz) + return secp256k1.PrivKey(bzArr) } } diff --git a/crypto/hd/fundraiser_test.go b/crypto/hd/fundraiser_test.go index 0f6a539d4fd5..f3c01a04772f 100644 --- a/crypto/hd/fundraiser_test.go +++ b/crypto/hd/fundraiser_test.go @@ -65,7 +65,7 @@ func TestFundraiserCompatibility(t *testing.T) { master, ch := hd.ComputeMastersFromSeed(seed) priv, err := hd.DerivePrivateKeyForPath(master, ch, "44'/118'/0'/0/0") require.NoError(t, err) - pub := secp256k1.PrivKeySecp256k1(priv).PubKey() + pub := secp256k1.PrivKey(priv[:]).PubKey() t.Log("\tNODEJS GOLANG\n") t.Logf("SEED \t%X %X\n", seedB, seed) @@ -76,9 +76,9 @@ func TestFundraiserCompatibility(t *testing.T) { require.Equal(t, seedB, seed) require.Equal(t, master[:], masterB, fmt.Sprintf("Expected masters to match for %d", i)) require.Equal(t, priv[:], privB, "Expected priv keys to match") - var pubBFixed [33]byte + var pubBFixed [secp256k1.PubKeySize]byte copy(pubBFixed[:], pubB) - require.Equal(t, pub, secp256k1.PubKeySecp256k1(pubBFixed), fmt.Sprintf("Expected pub keys to match for %d", i)) + require.Equal(t, pub, secp256k1.PubKey(pubBFixed[:]), fmt.Sprintf("Expected pub keys to match for %d", i)) addr := pub.Address() t.Logf("ADDR \t%X %X\n", addrB, addr) diff --git a/crypto/keyring/keyring.go b/crypto/keyring/keyring.go index 05598d061390..8ce245077307 100644 --- a/crypto/keyring/keyring.go +++ b/crypto/keyring/keyring.go @@ -16,10 +16,10 @@ import ( "github.com/pkg/errors" "github.com/tendermint/crypto/bcrypt" tmcrypto "github.com/tendermint/tendermint/crypto" - cryptoamino "github.com/tendermint/tendermint/crypto/encoding/amino" "github.com/cosmos/cosmos-sdk/client/input" "github.com/cosmos/cosmos-sdk/crypto" + cryptocdc "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/ledger" sdk "github.com/cosmos/cosmos-sdk/types" @@ -197,7 +197,7 @@ func (ks keystore) ExportPubKeyArmor(uid string) (string, error) { return "", fmt.Errorf("no key to export with name: %s", uid) } - return crypto.ArmorPubKeyBytes(bz.GetPubKey().Bytes(), string(bz.GetAlgo())), nil + return crypto.ArmorPubKeyBytes(CryptoCdc.Amino.MustMarshalBinaryBare(bz.GetPubKey()), string(bz.GetAlgo())), nil } func (ks keystore) ExportPubKeyArmorByAddress(address sdk.Address) (string, error) { @@ -239,7 +239,7 @@ func (ks keystore) ExportPrivateKeyObject(uid string) (tmcrypto.PrivKey, error) return nil, err } - priv, err = cryptoamino.PrivKeyFromBytes([]byte(linfo.PrivKeyArmor)) + priv, err = cryptocdc.PrivKeyFromBytes([]byte(linfo.PrivKeyArmor)) if err != nil { return nil, err } @@ -288,7 +288,7 @@ func (ks keystore) ImportPubKey(uid string, armor string) error { return err } - pubKey, err := cryptoamino.PubKeyFromBytes(pubBytes) + pubKey, err := cryptocdc.PubKeyFromBytes(pubBytes) if err != nil { return err } @@ -315,7 +315,7 @@ func (ks keystore) Sign(uid string, msg []byte) ([]byte, tmcrypto.PubKey, error) return nil, nil, fmt.Errorf("private key not available") } - priv, err = cryptoamino.PrivKeyFromBytes([]byte(i.PrivKeyArmor)) + priv, err = cryptocdc.PrivKeyFromBytes([]byte(i.PrivKeyArmor)) if err != nil { return nil, nil, err } @@ -686,8 +686,7 @@ func newRealPrompt(dir string, buf io.Reader) func(string) (string, error) { func (ks keystore) writeLocalKey(name string, priv tmcrypto.PrivKey, algo hd.PubKeyType) (Info, error) { // encrypt private key using keyring pub := priv.PubKey() - - info := newLocalInfo(name, pub, string(priv.Bytes()), algo) + info := newLocalInfo(name, pub, string(CryptoCdc.Amino.MustMarshalBinaryBare(priv)), algo) if err := ks.writeInfo(info); err != nil { return nil, err } diff --git a/crypto/keyring/keyring_test.go b/crypto/keyring/keyring_test.go index 1daf0164f4a8..cf199eb3d429 100644 --- a/crypto/keyring/keyring_test.go +++ b/crypto/keyring/keyring_test.go @@ -153,19 +153,19 @@ func TestSignVerifyKeyRing(t *testing.T) { // try signing both data with both .. s11, pub1, err := kb.Sign(n1, d1) - require.Nil(t, err) + require.NoError(t, err) require.Equal(t, i1.GetPubKey(), pub1) s12, pub1, err := kb.Sign(n1, d2) - require.Nil(t, err) + require.NoError(t, err) require.Equal(t, i1.GetPubKey(), pub1) s21, pub2, err := kb.Sign(n2, d1) - require.Nil(t, err) + require.NoError(t, err) require.Equal(t, i2.GetPubKey(), pub2) s22, pub2, err := kb.Sign(n2, d2) - require.Nil(t, err) + require.NoError(t, err) require.Equal(t, i2.GetPubKey(), pub2) // let's try to validate and make sure it only works when everything is proper diff --git a/crypto/keyring/legacy.go b/crypto/keyring/legacy.go index 2332266d4563..4984936b95f4 100644 --- a/crypto/keyring/legacy.go +++ b/crypto/keyring/legacy.go @@ -159,7 +159,7 @@ func (kb dbKeybase) ExportPubKey(name string) (armor string, err error) { return } - return crypto.ArmorPubKeyBytes(info.GetPubKey().Bytes(), string(info.GetAlgo())), nil + return crypto.ArmorPubKeyBytes(CryptoCdc.Amino.MustMarshalBinaryBare(info.GetPubKey()), string(info.GetAlgo())), nil } // ExportPrivKey returns a private key in ASCII armored format. diff --git a/crypto/keyring/types_test.go b/crypto/keyring/types_test.go index cf935d906c85..50981d177bed 100644 --- a/crypto/keyring/types_test.go +++ b/crypto/keyring/types_test.go @@ -12,7 +12,7 @@ import ( ) func Test_writeReadLedgerInfo(t *testing.T) { - var tmpKey secp256k1.PubKeySecp256k1 + tmpKey := make(secp256k1.PubKey, secp256k1.PubKeySize) bz, _ := hex.DecodeString("035AD6810A47F073553FF30D2FCC7E0D3B1C0B74B61A1AAA2582344037151E143A") copy(tmpKey[:], bz) diff --git a/crypto/ledger/ledger_mock.go b/crypto/ledger/ledger_mock.go index 9af22bb7fb82..85ae9da97bb3 100644 --- a/crypto/ledger/ledger_mock.go +++ b/crypto/ledger/ledger_mock.go @@ -72,13 +72,13 @@ func (mock LedgerSECP256K1Mock) GetAddressPubKeySECP256K1(derivationPath []uint3 } // re-serialize in the 33-byte compressed format - cmp, err := btcec.ParsePubKey(pk[:], btcec.S256()) + cmp, err := btcec.ParsePubKey(pk, btcec.S256()) if err != nil { return nil, "", fmt.Errorf("error parsing public key: %v", err) } - var compressedPublicKey tmsecp256k1.PubKeySecp256k1 - copy(compressedPublicKey[:], cmp.SerializeCompressed()) + compressedPublicKey := make(tmsecp256k1.PubKey, tmsecp256k1.PubKeySize) + copy(compressedPublicKey, cmp.SerializeCompressed()) // Generate the bech32 addr using existing tmcrypto/etc. addr := sdk.AccAddress(compressedPublicKey.Address()).String() diff --git a/crypto/ledger/ledger_secp256k1.go b/crypto/ledger/ledger_secp256k1.go index f25cdff3b830..5ca311d66d3c 100644 --- a/crypto/ledger/ledger_secp256k1.go +++ b/crypto/ledger/ledger_secp256k1.go @@ -115,7 +115,7 @@ func ShowAddress(path hd.BIP44Params, expectedPubKey tmcrypto.PubKey, return err } - if pubKey != expectedPubKey { + if !pubKey.Equals(expectedPubKey) { return fmt.Errorf("the key's pubkey does not match with the one retrieved from Ledger. Check that the HD path and device are the correct ones") } @@ -124,7 +124,7 @@ func ShowAddress(path hd.BIP44Params, expectedPubKey tmcrypto.PubKey, return err } - if pubKey2 != expectedPubKey { + if !pubKey2.Equals(expectedPubKey) { return fmt.Errorf("the key's pubkey does not match with the one retrieved from Ledger. Check that the HD path and device are the correct ones") } @@ -152,6 +152,8 @@ func (pkl PrivKeyLedgerSecp256k1) Bytes() []byte { return cdc.MustMarshalBinaryBare(pkl) } +func (pkl PrivKeyLedgerSecp256k1) Type() string { return "PrivKeyLedgerSecp256k1" } + // Equals implements the PrivKey interface. It makes sure two private keys // refer to the same public key. func (pkl PrivKeyLedgerSecp256k1) Equals(other tmcrypto.PrivKey) bool { @@ -244,8 +246,8 @@ func getPubKeyUnsafe(device SECP256K1, path hd.BIP44Params) (tmcrypto.PubKey, er return nil, fmt.Errorf("error parsing public key: %v", err) } - var compressedPublicKey tmsecp256k1.PubKeySecp256k1 - copy(compressedPublicKey[:], cmp.SerializeCompressed()) + compressedPublicKey := make(tmsecp256k1.PubKey, tmsecp256k1.PubKeySize) + copy(compressedPublicKey, cmp.SerializeCompressed()) return compressedPublicKey, nil } @@ -268,8 +270,8 @@ func getPubKeyAddrSafe(device SECP256K1, path hd.BIP44Params, hrp string) (tmcry return nil, "", fmt.Errorf("error parsing public key: %v", err) } - var compressedPublicKey tmsecp256k1.PubKeySecp256k1 - copy(compressedPublicKey[:], cmp.SerializeCompressed()) + compressedPublicKey := make(tmsecp256k1.PubKey, tmsecp256k1.PubKeySize) + copy(compressedPublicKey, cmp.SerializeCompressed()) return compressedPublicKey, addr, nil } diff --git a/crypto/ledger/ledger_test.go b/crypto/ledger/ledger_test.go index 3de8ff5a386b..e34e1978c51f 100644 --- a/crypto/ledger/ledger_test.go +++ b/crypto/ledger/ledger_test.go @@ -29,7 +29,7 @@ func TestPublicKeyUnsafe(t *testing.T) { require.NotNil(t, priv) require.Equal(t, "eb5ae98721034fef9cd7c4c63588d3b03feb5281b9d232cba34d6f3d71aee59211ffbfe1fe87", - fmt.Sprintf("%x", priv.PubKey().Bytes()), + fmt.Sprintf("%x", cdc.Amino.MustMarshalBinaryBare(priv.PubKey())), "Is your device using test mnemonic: %s ?", testutil.TestMnemonic) pubKeyAddr, err := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeAccPub, priv.PubKey()) @@ -81,7 +81,8 @@ func TestPublicKeyUnsafeHDPath(t *testing.T) { "Is your device using test mnemonic: %s ?", testutil.TestMnemonic) // Store and restore - serializedPk := priv.Bytes() + + serializedPk := cdc.Amino.MustMarshalBinaryBare(priv) require.NotNil(t, serializedPk) require.True(t, len(serializedPk) >= 50) @@ -107,7 +108,7 @@ func TestPublicKeySafe(t *testing.T) { require.Nil(t, ShowAddress(path, priv.PubKey(), sdk.GetConfig().GetBech32AccountAddrPrefix())) require.Equal(t, "eb5ae98721034fef9cd7c4c63588d3b03feb5281b9d232cba34d6f3d71aee59211ffbfe1fe87", - fmt.Sprintf("%x", priv.PubKey().Bytes()), + fmt.Sprintf("%x", cdc.Amino.MustMarshalBinaryBare(priv.PubKey())), "Is your device using test mnemonic: %s ?", testutil.TestMnemonic) pubKeyAddr, err := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeAccPub, priv.PubKey()) @@ -181,7 +182,7 @@ func TestPublicKeyHDPath(t *testing.T) { "Is your device using test mnemonic: %s ?", testutil.TestMnemonic) // Store and restore - serializedPk := priv.Bytes() + serializedPk := cdc.Amino.MustMarshalBinaryBare(priv) require.NotNil(t, serializedPk) require.True(t, len(serializedPk) >= 50) @@ -238,7 +239,7 @@ func TestRealDeviceSecp256k1(t *testing.T) { require.True(t, valid) // now, let's serialize the public key and make sure it still works - bs := priv.PubKey().Bytes() + bs := cdc.Amino.MustMarshalBinaryBare(priv.PubKey()) pub2, err := cryptoAmino.PubKeyFromBytes(bs) require.Nil(t, err, "%+v", err) @@ -252,7 +253,7 @@ func TestRealDeviceSecp256k1(t *testing.T) { require.True(t, valid) // make sure pubkeys serialize properly as well - bs = pub.Bytes() + bs = cdc.Amino.MustMarshalBinaryBare(pub) bpub, err := cryptoAmino.PubKeyFromBytes(bs) require.NoError(t, err) require.Equal(t, pub, bpub) diff --git a/crypto/types/multisig/codec.go b/crypto/types/multisig/codec.go index 052b4f855666..63ba8b2a0ab4 100644 --- a/crypto/types/multisig/codec.go +++ b/crypto/types/multisig/codec.go @@ -21,10 +21,10 @@ func init() { Cdc.RegisterInterface((*crypto.PubKey)(nil), nil) Cdc.RegisterConcrete(PubKeyMultisigThreshold{}, PubKeyAminoRoute, nil) - Cdc.RegisterConcrete(ed25519.PubKeyEd25519{}, - ed25519.PubKeyAminoName, nil) - Cdc.RegisterConcrete(sr25519.PubKeySr25519{}, - sr25519.PubKeyAminoName, nil) - Cdc.RegisterConcrete(secp256k1.PubKeySecp256k1{}, - secp256k1.PubKeyAminoName, nil) + Cdc.RegisterConcrete(ed25519.PubKey{}, + ed25519.PubKeyName, nil) + Cdc.RegisterConcrete(sr25519.PubKey{}, + sr25519.PubKeyName, nil) + Cdc.RegisterConcrete(secp256k1.PubKey{}, + secp256k1.PubKeyName, nil) } diff --git a/crypto/types/multisig/threshold_pubkey.go b/crypto/types/multisig/threshold_pubkey.go index 911843e35cc1..d8d1c516257d 100644 --- a/crypto/types/multisig/threshold_pubkey.go +++ b/crypto/types/multisig/threshold_pubkey.go @@ -134,7 +134,7 @@ func (pk PubKeyMultisigThreshold) Bytes() []byte { // Address returns tmhash(PubKeyMultisigThreshold.Bytes()) func (pk PubKeyMultisigThreshold) Address() crypto.Address { - return crypto.AddressHash(pk.Bytes()) + return crypto.AddressHash(Cdc.MustMarshalBinaryBare(pk)) } // Equals returns true iff pk and other both have the same number of keys, and @@ -154,3 +154,5 @@ func (pk PubKeyMultisigThreshold) Equals(other crypto.PubKey) bool { } return true } + +func (pk PubKeyMultisigThreshold) Type() string { return " PubKeyMultisigThreshold" } diff --git a/crypto/types/multisig/threshold_pubkey_test.go b/crypto/types/multisig/threshold_pubkey_test.go index 4eaf52ffa11f..35a35a0ac794 100644 --- a/crypto/types/multisig/threshold_pubkey_test.go +++ b/crypto/types/multisig/threshold_pubkey_test.go @@ -6,16 +6,17 @@ import ( "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/ed25519" + "github.com/tendermint/tendermint/crypto/secp256k1" + "github.com/tendermint/tendermint/crypto/sr25519" + "github.com/cosmos/cosmos-sdk/codec" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" "github.com/cosmos/cosmos-sdk/types/tx/signing" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - - "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/tendermint/tendermint/crypto/secp256k1" - "github.com/tendermint/tendermint/crypto/sr25519" ) // This tests multisig functionality, but it expects the first k signatures to be valid @@ -189,11 +190,11 @@ func TestMultiSigMigration(t *testing.T) { signBytesFn := func(mode signing.SignMode) ([]byte, error) { return msg, nil } cdc := codec.New() - + cryptocodec.RegisterCrypto(cdc) err := multisig.AddSignatureFromPubKey(multisignature, sigs[0], pkSet[0], pkSet) // create a StdSignature for msg, and convert it to sigV2 - sig := authtypes.StdSignature{PubKey: pkSet[1].Bytes(), Signature: msg} + sig := authtypes.StdSignature{PubKey: cdc.Amino.MustMarshalBinaryBare(pkSet[1]), Signature: msg} sigV2, err := authtypes.StdSignatureToSignatureV2(cdc, sig) require.NoError(t, multisig.AddSignatureV2(multisignature, sigV2, pkSet)) diff --git a/docs/core/store.md b/docs/core/store.md index 1be9c505eeb6..314eafd07f11 100644 --- a/docs/core/store.md +++ b/docs/core/store.md @@ -145,13 +145,13 @@ The default implementation of `KVStore` and `CommitKVStore` used in `baseapp` is +++ https://github.com/cosmos/cosmos-sdk/blob/7d7821b9af132b0f6131640195326aa02b6751db/store/iavl/store.go#L32-L47 - `iavl` stores are based around an [IAVL Tree](https://github.com/tendermint/iavl), a self-balancing binary tree which guarantees that: + `iavl` stores are based around an [IAVL Tree](https://github.com/cosmos/iavl), a self-balancing binary tree which guarantees that: - `Get` and `Set` operations are O(log n), where n is the number of elements in the tree. - Iteration efficiently returns the sorted elements within the range. -- Each tree version is immutable and can be retrieved even after a commit (depending on the pruning settings). +- Each tree version is immutable and can be retrieved even after a commit (depending on the pruning settings). -The documentation on the IAVL Tree is located [here](https://github.com/tendermint/iavl/blob/f9d4b446a226948ed19286354f0d433a887cc4a3/docs/overview.md). +The documentation on the IAVL Tree is located [here](https://github.com/cosmos/iavl/blob/f9d4b446a226948ed19286354f0d433a887cc4a3/docs/overview.md). ### `DbAdapter` Store diff --git a/go.mod b/go.mod index c04f1bfcaa3c..87072b60c564 100644 --- a/go.mod +++ b/go.mod @@ -7,9 +7,9 @@ require ( github.com/armon/go-metrics v0.3.3 github.com/bgentry/speakeasy v0.1.0 github.com/btcsuite/btcd v0.20.1-beta - github.com/confio/ics23-iavl v0.6.0 - github.com/confio/ics23/go v0.0.0-20200604202538-6e2c36a74465 + github.com/confio/ics23/go v0.0.0-20200610201322-18c7bd6b2dd3 github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d + github.com/cosmos/iavl v0.13.4-0.20200714154344-89524cdc51be github.com/cosmos/ledger-cosmos-go v0.11.1 github.com/enigmampc/btcutil v1.0.3-0.20200723161021-e2fb6adb2a25 github.com/gibson042/canonicaljson-go v1.0.3 @@ -30,18 +30,19 @@ require ( github.com/spf13/afero v1.2.2 // indirect github.com/spf13/cast v1.3.1 github.com/spf13/cobra v1.0.0 - github.com/spf13/jwalterweatherman v1.1.0 // indirect + github.com/spf13/jwalterweatherman v1.1.0 // indirect; indirects github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.7.0 github.com/stretchr/testify v1.6.1 github.com/tendermint/btcd v0.1.1 github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 github.com/tendermint/go-amino v0.15.1 - github.com/tendermint/iavl v0.14.0 - github.com/tendermint/tendermint v0.33.6 - github.com/tendermint/tm-db v0.5.1 + github.com/tendermint/tendermint v0.34.0-dev1.0.20200714110441-6ccccb0933d4 + github.com/tendermint/tm-db v0.6.0 google.golang.org/grpc v1.30.0 gopkg.in/yaml.v2 v2.3.0 ) replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.2-alpha.regen.4 + +replace github.com/tendermint/tendermint => ../tendermint diff --git a/go.sum b/go.sum index 1e3a99bd5081..e1a403512389 100644 --- a/go.sum +++ b/go.sum @@ -16,8 +16,6 @@ github.com/99designs/keyring v1.1.5/go.mod h1:7hsVvt2qXgtadGevGJ4ujg+u8m6SpJ5TpH github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/ChainSafe/go-schnorrkel v0.0.0-20200102211924-4bcbc698314f h1:4O1om+UVU+Hfcihr1timk8YNXHxzZWgCo7ofnrZRApw= -github.com/ChainSafe/go-schnorrkel v0.0.0-20200102211924-4bcbc698314f/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= @@ -83,11 +81,8 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/confio/ics23-iavl v0.6.0 h1:vVRCuVaP38FCw1kTeEdFuGuiY+2vAGTBQoH7Zxkq/ws= -github.com/confio/ics23-iavl v0.6.0/go.mod h1:mmXAxD1vWoO0VP8YHu6mM1QHGv71NQqa1iSVm4HeKcY= -github.com/confio/ics23/go v0.0.0-20200323120010-7d9a00f0a2fa/go.mod h1:W1I3XC8d9N8OTu/ct5VJ84ylcOunZwMXsWkd27nvVts= -github.com/confio/ics23/go v0.0.0-20200604202538-6e2c36a74465 h1:tyK54ttJ14HaHaKjB6sQqkZaUSe/LUXKHjfgJNtcj20= -github.com/confio/ics23/go v0.0.0-20200604202538-6e2c36a74465/go.mod h1:W1I3XC8d9N8OTu/ct5VJ84ylcOunZwMXsWkd27nvVts= +github.com/confio/ics23/go v0.0.0-20200610201322-18c7bd6b2dd3 h1:h/HM69qj1llEyq9N8+2sm6HfWsE7P9SFyl4CM2hyK98= +github.com/confio/ics23/go v0.0.0-20200610201322-18c7bd6b2dd3/go.mod h1:W1I3XC8d9N8OTu/ct5VJ84ylcOunZwMXsWkd27nvVts= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= @@ -99,6 +94,8 @@ github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfc github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d h1:49RLWk1j44Xu4fjHb6JFYmeUnDORVwHNkDxaQ0ctCVU= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= +github.com/cosmos/iavl v0.13.4-0.20200714154344-89524cdc51be h1:gPXabvAPawITO5ryB5nCNKmo48951tVD2NTTcV/wNR8= +github.com/cosmos/iavl v0.13.4-0.20200714154344-89524cdc51be/go.mod h1:A9QZVVJuZUBVkvuJQ60QXjRGyxBmHvsXC7ExnwB8wWs= github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4= github.com/cosmos/ledger-cosmos-go v0.11.1/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY= github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI= @@ -128,8 +125,6 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/etcd-io/bbolt v1.3.3 h1:gSJmxrs37LgTqR/oyJBWok6k6SvXEUerFTbltIhXkBM= -github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 h1:0JZ+dUmQeA8IIVUMzysrX4/AKuQwWhV2dYQuPZdvdSQ= github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A= @@ -175,7 +170,6 @@ github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= @@ -183,6 +177,7 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0 h1:oOuy+ugB+P/kBdUnG5QaMXSIyJ1q38wWSojYCb3z5VQ= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= @@ -217,8 +212,6 @@ github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc= github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= -github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= @@ -343,6 +336,8 @@ github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzE github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= @@ -379,6 +374,8 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9 github.com/pelletier/go-toml v1.8.0 h1:Keo9qb7iRJs2voHvunFtuuYFsbWeOBh8/P9v/kVMFtw= github.com/pelletier/go-toml v1.8.0/go.mod h1:D6yutnOGMveHEPV7VQOuvI/gXY61bv+9bAOTRnLElKs= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= +github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ= +github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -395,10 +392,6 @@ github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDf github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= -github.com/prometheus/client_golang v1.5.0 h1:Ctq0iGpCmr3jeP77kbF2UxgvRwzWWz+4Bh9/vJTyg1A= -github.com/prometheus/client_golang v1.5.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= -github.com/prometheus/client_golang v1.5.1 h1:bdHYieyGlH+6OLEk2YQha8THib30KP0/yD0YH9m6xcA= -github.com/prometheus/client_golang v1.5.1/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1 h1:NTGy1Ja9pByO+xAeH/qiWnLrKtr3hJPNjaVUwnjpdpA= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= @@ -413,7 +406,6 @@ github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8 github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= -github.com/prometheus/common v0.9.1 h1:KOMtN28tlbam3/7ZKEYKHhKoJZYYj3gMH4uc62x7X7U= github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0 h1:RyRA7RzGXQZiW+tGMr7sxa85G1z0yOpM1qq5c8lNawc= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= @@ -421,14 +413,12 @@ github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.8 h1:+fpWZdT24pJBiqJdAwYBjPSk+5YmQzYNPYzQsdzLkt8= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ= github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc= -github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a h1:9ZKAASQSHhDYGoxY8uLVpewe1GDZ2vu2Tr/vTdVAkFQ= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 h1:MkV+77GLUNo5oJ0jf870itWm3D0Sjh7+Za9gazKc5LQ= github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= @@ -443,6 +433,8 @@ github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= +github.com/sasha-s/go-deadlock v0.2.0 h1:lMqc+fUb7RrFS3gQLtoQsJ7/6TV/pAIFvBsqX73DK8Y= +github.com/sasha-s/go-deadlock v0.2.0/go.mod h1:StQn567HiB1fF2yJ44N9au7wOhrPS3iZqiDbRupzT10= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= @@ -463,8 +455,6 @@ github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/cobra v0.0.6 h1:breEStsVwemnKh2/s6gMvSdMEkwW0sK8vGStnlVBMCs= -github.com/spf13/cobra v0.0.6/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/cobra v1.0.0 h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8= github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= @@ -475,8 +465,6 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= -github.com/spf13/viper v1.6.2/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k= -github.com/spf13/viper v1.6.3/go.mod h1:jUMtyi0/lB5yZH/FjyGAoH7IMNrIhlBf6pXZmbMDvzw= github.com/spf13/viper v1.7.0 h1:xVKxvI7ouOI5I+U9s2eeiUfMaWBVoXA3AWskkrqK0VM= github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= @@ -489,8 +477,6 @@ github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoH github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= @@ -503,22 +489,10 @@ github.com/tendermint/btcd v0.1.1 h1:0VcxPfflS2zZ3RiOAHkBiFUcPvbtRj5O7zHmcJWHV7s github.com/tendermint/btcd v0.1.1/go.mod h1:DC6/m53jtQzr/NFmMNEu0rxf18/ktVoVtMrnDD5pN+U= github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RMWx1aInLzndwxKalgi5rTqgfXxOxbEI= github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= -github.com/tendermint/go-amino v0.14.1/go.mod h1:i/UKE5Uocn+argJJBb12qTZsCDBcAYMbR92AaJVmKso= github.com/tendermint/go-amino v0.15.1 h1:D2uk35eT4iTsvJd9jWIetzthE5C0/k2QmMFkCN+4JgQ= github.com/tendermint/go-amino v0.15.1/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= -github.com/tendermint/iavl v0.13.2/go.mod h1:vE1u0XAGXYjHykd4BLp8p/yivrw2PF1TuoljBcsQoGA= -github.com/tendermint/iavl v0.14.0 h1:Jkff+IFrXxRWtH9Jn/ga/2cxNnzMTv58xEKgCJsKUBg= -github.com/tendermint/iavl v0.14.0/go.mod h1:QmfViflFiXzxKLQE4tAUuWQHq+RSuQFxablW5oJZ6sE= -github.com/tendermint/tendermint v0.33.2 h1:NzvRMTuXJxqSsFed2J7uHmMU5N1CVzSpfi3nCc882KY= -github.com/tendermint/tendermint v0.33.2/go.mod h1:25DqB7YvV1tN3tHsjWoc2vFtlwICfrub9XO6UBO+4xk= -github.com/tendermint/tendermint v0.33.5 h1:jYgRd9ImkzA9iOyhpmgreYsqSB6tpDa6/rXYPb8HKE8= -github.com/tendermint/tendermint v0.33.5/go.mod h1:0yUs9eIuuDq07nQql9BmI30FtYGcEC60Tu5JzB5IezM= -github.com/tendermint/tendermint v0.33.6 h1:W4UOsXY4ROJZ3TLLGVVv71VXD4WK2gJRb3gzeced+mg= -github.com/tendermint/tendermint v0.33.6/go.mod h1:0yUs9eIuuDq07nQql9BmI30FtYGcEC60Tu5JzB5IezM= -github.com/tendermint/tm-db v0.4.1/go.mod h1:JsJ6qzYkCGiGwm5GHl/H5GLI9XLb6qZX7PRe425dHAY= -github.com/tendermint/tm-db v0.5.0/go.mod h1:lSq7q5WRR/njf1LnhiZ/lIJHk2S8Y1Zyq5oP/3o9C2U= -github.com/tendermint/tm-db v0.5.1 h1:H9HDq8UEA7Eeg13kdYckkgwwkQLBnJGgX4PgLJRhieY= -github.com/tendermint/tm-db v0.5.1/go.mod h1:g92zWjHpCYlEvQXvy9M168Su8V1IBEeawpXVVBaK4f4= +github.com/tendermint/tm-db v0.6.0 h1:Us30k7H1UDcdqoSPhmP8ztAW/SWV6c6OfsfeCiboTC4= +github.com/tendermint/tm-db v0.6.0/go.mod h1:xj3AWJ08kBDlCHKijnhJ7mTcDMOikT1r8Poxy2pJn7Q= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= @@ -532,6 +506,8 @@ github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWp go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0= +go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= @@ -554,13 +530,11 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413 h1:ULYEB3JvPRE/IfO+9uO7vKV/xzVTO7XPAwm8xbf4w2g= golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200406173513-056763e48d71 h1:DOmugCavvUtnUD114C1Wh+UgTgQZ4pMLzXxi1pSt+/Y= golang.org/x/crypto v0.0.0-20200406173513-056763e48d71/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79 h1:IaQbIIB2X/Mp/DKctl6ROxz1KyMlKp4uyvL6+kQ7C88= -golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899 h1:DZhuSZLsGlFL4CmhA8BcRA0mnthyA/nZ00AqCUo7vHg= golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -600,7 +574,6 @@ golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= @@ -637,9 +610,8 @@ golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200122134326-e047566fdf82 h1:ywK/j/KkyTHcdyYSZNXGjMwgmDSfjglYZ3vStQ/gSCU= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1 h1:ogLJMz+qpzav7lGMh10LMvAkM/fAoGlaiiHYiFYdm80= golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -674,7 +646,6 @@ golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200110213125-a7a6caa82ab2 h1:V9r/14uGBqLgNlHRYWdVqjMdWkcOHnE2KG8DwVqQSEc= golang.org/x/tools v0.0.0-20200110213125-a7a6caa82ab2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -702,8 +673,9 @@ google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98 google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200324203455-a04cca1dde73 h1:+yTMTeazSO5iBqU9NR53hgriivQQbYa5Uuaj8r3qKII= google.golang.org/genproto v0.0.0-20200324203455-a04cca1dde73/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= @@ -716,26 +688,26 @@ google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyac google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.28.0 h1:bO/TA4OxCOummhSf10siHuG7vJOiwh7SpRpFZDkOgl4= google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= -google.golang.org/grpc v1.28.1 h1:C1QC6KzgSiLyBabDi87BbjaGreoRgGUF5nOyvfrAZ1k= -google.golang.org/grpc v1.28.1/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= google.golang.org/grpc v1.30.0 h1:M5a8xTlYTxwMn5ZFkwhRabsygDY5G8TYLyQDBxJNAxE= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0 h1:qdOKuR/EIArgaWNjetjgTzgVTAZ+S/WXVrq9HW9zimw= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.24.0 h1:UhZDfRO8JRQru4/+LlLE0BRKGF8L+PICnvYZmx/fEGA= +google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= diff --git a/proto/cosmos/cosmos.proto b/proto/cosmos/cosmos.proto index 595d23c5f2bb..0b02a559d172 100644 --- a/proto/cosmos/cosmos.proto +++ b/proto/cosmos/cosmos.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package cosmos; import "gogoproto/gogo.proto"; -import "tendermint/abci/types/types.proto"; +import "tendermint/abci/types.proto"; import "google/protobuf/any.proto"; option go_package = "github.com/cosmos/cosmos-sdk/types"; @@ -70,7 +70,7 @@ message Result { // Events contains a slice of Event objects that were emitted during message or // handler execution. - repeated tendermint.abci.types.Event events = 3 [(gogoproto.nullable) = false]; + repeated tendermint.abci.Event events = 3 [(gogoproto.nullable) = false]; } // SimulationResponse defines the response generated when a transaction is @@ -101,18 +101,18 @@ message TxData { message TxResponse { option (gogoproto.goproto_getters) = false; - int64 height = 1; - string txhash = 2 [(gogoproto.customname) = "TxHash"]; - string codespace = 3; - uint32 code = 4; - string data = 5; - string raw_log = 6; - repeated ABCIMessageLog logs = 7 [(gogoproto.castrepeated) = "ABCIMessageLogs", (gogoproto.nullable) = false]; - string info = 8; - int64 gas_wanted = 9; - int64 gas_used = 10; - google.protobuf.Any tx = 11; - string timestamp = 12; + int64 height = 1; + string txhash = 2 [(gogoproto.customname) = "TxHash"]; + string codespace = 3; + uint32 code = 4; + string data = 5; + string raw_log = 6; + repeated ABCIMessageLog logs = 7 [(gogoproto.castrepeated) = "ABCIMessageLogs", (gogoproto.nullable) = false]; + string info = 8; + int64 gas_wanted = 9; + int64 gas_used = 10; + google.protobuf.Any tx = 11; + string timestamp = 12; } // ABCIMessageLog defines a structure containing an indexed tx ABCI message log. @@ -120,7 +120,7 @@ message ABCIMessageLog { option (gogoproto.stringer) = true; uint32 msg_index = 1; - string log = 2; + string log = 2; // Events contains a slice of Event objects that were emitted during some // execution. @@ -132,13 +132,13 @@ message ABCIMessageLog { message StringEvent { option (gogoproto.stringer) = true; - string type = 1; + string type = 1; repeated Attribute attributes = 2 [(gogoproto.nullable) = false]; } // Attribute defines an attribute wrapper where the key and value are // strings instead of raw bytes. message Attribute { - string key = 1; + string key = 1; string value = 2; -} \ No newline at end of file +} diff --git a/proto/cosmos/kv/kv.proto b/proto/cosmos/kv/kv.proto new file mode 100644 index 000000000000..f16b05dd6947 --- /dev/null +++ b/proto/cosmos/kv/kv.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; +package cosmos.kv; + +option go_package = "github.com/cosmos/cosmos-sdk/types/kv"; + +// Key-Value Pair +message Pair { + bytes key = 1; + bytes value = 2; +} diff --git a/proto/cosmos/staking/staking.proto b/proto/cosmos/staking/staking.proto index d375ff8f21d5..a89acae96e13 100644 --- a/proto/cosmos/staking/staking.proto +++ b/proto/cosmos/staking/staking.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package cosmos.staking; import "gogoproto/gogo.proto"; -import "tendermint/abci/types/types.proto"; +import "tendermint/types/types.proto"; import "google/protobuf/timestamp.proto"; import "google/protobuf/duration.proto"; import "cosmos/cosmos.proto"; @@ -28,7 +28,7 @@ message MsgCreateValidator { (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress", (gogoproto.moretags) = "yaml:\"validator_address\"" ]; - string pubkey = 6; + string pubkey = 6; cosmos.Coin value = 7 [(gogoproto.nullable) = false]; } @@ -112,10 +112,8 @@ message MsgUndelegate { // HistoricalInfo contains the historical information that gets stored at // each height. message HistoricalInfo { - option (gogoproto.equal) = true; - - tendermint.abci.types.Header header = 1 [(gogoproto.nullable) = false]; - repeated Validator valset = 2 [(gogoproto.nullable) = false]; + tendermint.types.Header header = 1 [(gogoproto.nullable) = false]; + repeated Validator valset = 2 [(gogoproto.nullable) = false]; } // CommissionRates defines the initial commission rates to be used for creating @@ -145,8 +143,8 @@ message Commission { option (gogoproto.equal) = true; option (gogoproto.goproto_stringer) = false; - CommissionRates commission_rates = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - google.protobuf.Timestamp update_time = 2 [ + CommissionRates commission_rates = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; + google.protobuf.Timestamp update_time = 2 [ (gogoproto.nullable) = false, (gogoproto.stdtime) = true, (gogoproto.moretags) = "yaml:\"update_time\"" @@ -183,8 +181,8 @@ message Validator { ]; string consensus_pubkey = 2 [(gogoproto.moretags) = "yaml:\"consensus_pubkey\""]; bool jailed = 3; - int32 status = 4 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.BondStatus"]; - string tokens = 5 [ + int32 status = 4 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.BondStatus"]; + string tokens = 5 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; @@ -193,9 +191,9 @@ message Validator { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; - Description description = 7 [(gogoproto.nullable) = false]; - int64 unbonding_height = 8 [(gogoproto.moretags) = "yaml:\"unbonding_height\""]; - google.protobuf.Timestamp unbonding_time = 9 [ + Description description = 7 [(gogoproto.nullable) = false]; + int64 unbonding_height = 8 [(gogoproto.moretags) = "yaml:\"unbonding_height\""]; + google.protobuf.Timestamp unbonding_time = 9 [ (gogoproto.nullable) = false, (gogoproto.stdtime) = true, (gogoproto.moretags) = "yaml:\"unbonding_time\"" diff --git a/proto/ibc/commitment/commitment.proto b/proto/ibc/commitment/commitment.proto index 99062d4f1c02..9fd11fe52ce3 100644 --- a/proto/ibc/commitment/commitment.proto +++ b/proto/ibc/commitment/commitment.proto @@ -4,7 +4,7 @@ package ibc.commitment; option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"; import "gogoproto/gogo.proto"; -import "tendermint/crypto/merkle/merkle.proto"; +import "tendermint/crypto/proof.proto"; // MerkleRoot defines a merkle root hash. // In the Cosmos SDK, the AppHash of a block header becomes the root. @@ -36,9 +36,7 @@ message MerklePath { // verifiable in conjunction with a known commitment root. Proofs should be // succinct. message MerkleProof { - option (gogoproto.equal) = true; - - tendermint.crypto.merkle.Proof proof = 1; + tendermint.crypto.ProofOps proof = 1; } // KeyPath defines a slice of keys diff --git a/server/export.go b/server/export.go index 0fc94a06a5bd..b2991a2f7891 100644 --- a/server/export.go +++ b/server/export.go @@ -8,6 +8,7 @@ import ( "os" "github.com/spf13/cobra" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" "github.com/cosmos/cosmos-sdk/client" @@ -78,17 +79,18 @@ func ExportCmd(appExporter AppExporter, defaultNodeHome string) *cobra.Command { doc.AppState = appState doc.Validators = validators - doc.ConsensusParams = &tmtypes.ConsensusParams{ - Block: tmtypes.BlockParams{ + doc.ConsensusParams = &tmproto.ConsensusParams{ + Block: tmproto.BlockParams{ MaxBytes: cp.Block.MaxBytes, MaxGas: cp.Block.MaxGas, TimeIotaMs: doc.ConsensusParams.Block.TimeIotaMs, }, - Evidence: tmtypes.EvidenceParams{ + Evidence: tmproto.EvidenceParams{ MaxAgeNumBlocks: cp.Evidence.MaxAgeNumBlocks, MaxAgeDuration: cp.Evidence.MaxAgeDuration, + // TODO: expand to house other params }, - Validator: tmtypes.ValidatorParams{ + Validator: tmproto.ValidatorParams{ PubKeyTypes: cp.Validator.PubKeyTypes, }, } diff --git a/server/mock/app_test.go b/server/mock/app_test.go index 3dd451970ccd..2741925df026 100644 --- a/server/mock/app_test.go +++ b/server/mock/app_test.go @@ -3,11 +3,10 @@ package mock import ( "testing" - "github.com/tendermint/tendermint/types" - "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/tendermint/tendermint/types" ) // TestInitApp makes sure we can initialize this thing without an error @@ -57,7 +56,7 @@ func TestDeliverTx(t *testing.T) { tx := NewTx(key, value) txBytes := tx.GetSignBytes() - header := abci.Header{ + header := tmproto.Header{ AppHash: []byte("apphash"), Height: 1, } diff --git a/server/tm_cmds.go b/server/tm_cmds.go index 7a906380084c..6bcba09aa83a 100644 --- a/server/tm_cmds.go +++ b/server/tm_cmds.go @@ -116,8 +116,8 @@ against which this app has been compiled. }{ Tendermint: tversion.Version, ABCI: tversion.ABCIVersion, - BlockProtocol: tversion.BlockProtocol.Uint64(), - P2PProtocol: tversion.P2PProtocol.Uint64(), + BlockProtocol: tversion.BlockProtocol, + P2PProtocol: tversion.P2PProtocol, }) if err != nil { return err diff --git a/server/util.go b/server/util.go index 7b329e49c09c..55599ec33d19 100644 --- a/server/util.go +++ b/server/util.go @@ -128,7 +128,6 @@ func interceptConfigs(ctx *Context, rootViper *viper.Viper) (*tmcfg.Config, erro conf.ProfListenAddress = "localhost:6060" conf.P2P.RecvRate = 5120000 conf.P2P.SendRate = 5120000 - conf.TxIndex.IndexAllKeys = true conf.Consensus.TimeoutCommit = 5 * time.Second tmcfg.WriteConfigFile(configFile, conf) } else { diff --git a/simapp/app.go b/simapp/app.go index a5cfa4079df0..c99ed67abbdf 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -9,6 +9,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" tmos "github.com/tendermint/tendermint/libs/os" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/baseapp" @@ -385,7 +386,7 @@ func NewSimApp( // sub-keepers. // This must be done during creation of baseapp rather than in InitChain so // that in-memory capabilities get regenerated on app restart - ctx := app.BaseApp.NewUncachedContext(true, abci.Header{}) + ctx := app.BaseApp.NewUncachedContext(true, tmproto.Header{}) app.CapabilityKeeper.InitializeAndSeal(ctx) app.ScopedIBCKeeper = scopedIBCKeeper diff --git a/simapp/export.go b/simapp/export.go index 363bc13954a5..ce5ea4b269a9 100644 --- a/simapp/export.go +++ b/simapp/export.go @@ -5,6 +5,7 @@ import ( "log" abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" @@ -22,7 +23,7 @@ func (app *SimApp) ExportAppStateAndValidators( ) (appState json.RawMessage, validators []tmtypes.GenesisValidator, cp *abci.ConsensusParams, err error) { // as if they could withdraw from the start of the next block - ctx := app.NewContext(true, abci.Header{Height: app.LastBlockHeight()}) + ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()}) if forZeroHeight { app.prepForZeroHeightGenesis(ctx, jailWhiteList) diff --git a/simapp/sim_bench_test.go b/simapp/sim_bench_test.go index 6d8ee05dbf77..b50e7627c563 100644 --- a/simapp/sim_bench_test.go +++ b/simapp/sim_bench_test.go @@ -5,7 +5,7 @@ import ( "os" "testing" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/x/simulation" ) @@ -87,7 +87,7 @@ func BenchmarkInvariants(b *testing.B) { PrintStats(db) } - ctx := app.NewContext(true, abci.Header{Height: app.LastBlockHeight() + 1}) + ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight() + 1}) // 3. Benchmark each invariant separately // diff --git a/simapp/sim_test.go b/simapp/sim_test.go index 83acd4a24f06..ffe6f5aeb1e8 100644 --- a/simapp/sim_test.go +++ b/simapp/sim_test.go @@ -11,6 +11,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/baseapp" @@ -140,8 +141,8 @@ func TestAppImportExport(t *testing.T) { err = app.Codec().UnmarshalJSON(appState, &genesisState) require.NoError(t, err) - ctxA := app.NewContext(true, abci.Header{Height: app.LastBlockHeight()}) - ctxB := newApp.NewContext(true, abci.Header{Height: app.LastBlockHeight()}) + ctxA := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()}) + ctxB := newApp.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()}) newApp.mm.InitGenesis(ctxB, app.Codec(), genesisState) newApp.StoreConsensusParams(ctxB, consensusParams) diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index 4be41810d763..d23c883a299f 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -13,6 +13,7 @@ import ( "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/ed25519" "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" dbm "github.com/tendermint/tm-db" @@ -33,14 +34,13 @@ var DefaultConsensusParams = &abci.ConsensusParams{ MaxBytes: 200000, MaxGas: 2000000, }, - Evidence: &abci.EvidenceParams{ + Evidence: &tmproto.EvidenceParams{ MaxAgeNumBlocks: 302400, MaxAgeDuration: 1814400, }, - Validator: &abci.ValidatorParams{ + Validator: &tmproto.ValidatorParams{ PubKeyTypes: []string{ tmtypes.ABCIPubKeyTypeEd25519, - tmtypes.ABCIPubKeyTypeSecp256k1, }, }, } @@ -136,7 +136,7 @@ func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs // commit genesis changes app.Commit() - app.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash}}) + app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash}}) return app } @@ -175,7 +175,7 @@ func SetupWithGenesisAccounts(genAccs []authtypes.GenesisAccount, balances ...ba ) app.Commit() - app.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: app.LastBlockHeight() + 1}}) + app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1}}) return app } @@ -304,7 +304,7 @@ func TestAddr(addr string, bech string) (sdk.AccAddress, error) { // CheckBalance checks the balance of an account. func CheckBalance(t *testing.T, app *SimApp, addr sdk.AccAddress, balances sdk.Coins) { - ctxCheck := app.BaseApp.NewContext(true, abci.Header{}) + ctxCheck := app.BaseApp.NewContext(true, tmproto.Header{}) require.True(t, balances.IsEqual(app.BankKeeper.GetAllBalances(ctxCheck, addr))) } @@ -313,7 +313,7 @@ func CheckBalance(t *testing.T, app *SimApp, addr sdk.AccAddress, balances sdk.C // the parameter 'expPass' against the result. A corresponding result is // returned. func SignCheckDeliver( - t *testing.T, txGen client.TxConfig, app *bam.BaseApp, header abci.Header, msgs []sdk.Msg, + t *testing.T, txGen client.TxConfig, app *bam.BaseApp, header tmproto.Header, msgs []sdk.Msg, accNums, seq []uint64, expSimPass, expPass bool, priv ...crypto.PrivKey, ) (sdk.GasInfo, *sdk.Result, error) { @@ -415,7 +415,7 @@ func NewPubKeyFromHex(pk string) (res crypto.PubKey) { if err != nil { panic(err) } - var pkEd ed25519.PubKeyEd25519 - copy(pkEd[:], pkBytes) + pkEd := make(ed25519.PubKey, ed25519.PubKeySize) + copy(pkEd, pkBytes) return pkEd } diff --git a/simapp/utils.go b/simapp/utils.go index 6ac89055dc8e..df240c55ebbe 100644 --- a/simapp/utils.go +++ b/simapp/utils.go @@ -5,7 +5,7 @@ import ( "fmt" "io/ioutil" - tmkv "github.com/tendermint/tendermint/libs/kv" + "github.com/cosmos/cosmos-sdk/types/kv" "github.com/tendermint/tendermint/libs/log" dbm "github.com/tendermint/tm-db" @@ -109,7 +109,7 @@ func PrintStats(db dbm.DB) { // GetSimulationLog unmarshals the KVPair's Value to the corresponding type based on the // each's module store key and the prefix bytes of the KVPair's key. -func GetSimulationLog(storeName string, sdr sdk.StoreDecoderRegistry, kvAs, kvBs []tmkv.Pair) (log string) { +func GetSimulationLog(storeName string, sdr sdk.StoreDecoderRegistry, kvAs, kvBs []kv.Pair) (log string) { for i := 0; i < len(kvAs); i++ { if len(kvAs[i].Value) == 0 && len(kvBs[i].Value) == 0 { // skip if the value doesn't have any bytes diff --git a/simapp/utils_test.go b/simapp/utils_test.go index 2218e296f7f8..dec409cdaf6a 100644 --- a/simapp/utils_test.go +++ b/simapp/utils_test.go @@ -6,8 +6,8 @@ import ( "github.com/cosmos/cosmos-sdk/std" + "github.com/cosmos/cosmos-sdk/types/kv" "github.com/stretchr/testify/require" - tmkv "github.com/tendermint/tendermint/libs/kv" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -17,26 +17,26 @@ func TestGetSimulationLog(t *testing.T) { cdc := std.MakeCodec(ModuleBasics) decoders := make(sdk.StoreDecoderRegistry) - decoders[authtypes.StoreKey] = func(kvAs, kvBs tmkv.Pair) string { return "10" } + decoders[authtypes.StoreKey] = func(kvAs, kvBs kv.Pair) string { return "10" } tests := []struct { store string - kvPairs []tmkv.Pair + kvPairs []kv.Pair expectedLog string }{ { "Empty", - []tmkv.Pair{{}}, + []kv.Pair{{}}, "", }, { authtypes.StoreKey, - []tmkv.Pair{{Key: authtypes.GlobalAccountNumberKey, Value: cdc.MustMarshalBinaryBare(uint64(10))}}, + []kv.Pair{{Key: authtypes.GlobalAccountNumberKey, Value: cdc.MustMarshalBinaryBare(uint64(10))}}, "10", }, { "OtherStore", - []tmkv.Pair{{Key: []byte("key"), Value: []byte("value")}}, + []kv.Pair{{Key: []byte("key"), Value: []byte("value")}}, fmt.Sprintf("store A %X => %X\nstore B %X => %X\n", []byte("key"), []byte("value"), []byte("key"), []byte("value")), }, } diff --git a/std/consensus_params.go b/std/consensus_params.go index e92cc1514b47..019010c30750 100644 --- a/std/consensus_params.go +++ b/std/consensus_params.go @@ -2,6 +2,7 @@ package std import ( abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/baseapp" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" @@ -18,10 +19,10 @@ func ConsensusParamsKeyTable() paramstypes.KeyTable { baseapp.ParamStoreKeyBlockParams, abci.BlockParams{}, baseapp.ValidateBlockParams, ), paramstypes.NewParamSetPair( - baseapp.ParamStoreKeyEvidenceParams, abci.EvidenceParams{}, baseapp.ValidateEvidenceParams, + baseapp.ParamStoreKeyEvidenceParams, tmproto.EvidenceParams{}, baseapp.ValidateEvidenceParams, ), paramstypes.NewParamSetPair( - baseapp.ParamStoreKeyValidatorParams, abci.ValidatorParams{}, baseapp.ValidateValidatorParams, + baseapp.ParamStoreKeyValidatorParams, tmproto.ValidatorParams{}, baseapp.ValidateValidatorParams, ), ) } diff --git a/std/pubkey.go b/std/pubkey.go index 35d72bbc731e..ffc7d6437e06 100644 --- a/std/pubkey.go +++ b/std/pubkey.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/types/multisig" "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/ed25519" ed255192 "github.com/tendermint/tendermint/crypto/ed25519" "github.com/tendermint/tendermint/crypto/secp256k1" "github.com/tendermint/tendermint/crypto/sr25519" @@ -23,27 +24,32 @@ func (cdc DefaultPublicKeyCodec) Decode(key *types.PublicKey) (crypto.PubKey, er switch key := key.Sum.(type) { case *types.PublicKey_Secp256K1: n := len(key.Secp256K1) - if n != secp256k1.PubKeySecp256k1Size { + if n != secp256k1.PubKeySize { return nil, fmt.Errorf("wrong length %d for secp256k1 public key", n) } - var res secp256k1.PubKeySecp256k1 - copy(res[:], key.Secp256K1) + + res := make(secp256k1.PubKey, secp256k1.PubKeySize) + copy(res, key.Secp256K1) + return res, nil case *types.PublicKey_Ed25519: n := len(key.Ed25519) - if n != ed255192.PubKeyEd25519Size { + if n != ed255192.PubKeySize { return nil, fmt.Errorf("wrong length %d for ed25519 public key", n) } - var res ed255192.PubKeyEd25519 - copy(res[:], key.Ed25519) + + res := make(ed25519.PubKey, ed25519.PubKeySize) + copy(res, key.Ed25519) + return res, nil case *types.PublicKey_Sr25519: n := len(key.Sr25519) - if n != sr25519.PubKeySr25519Size { + if n != sr25519.PubKeySize { return nil, fmt.Errorf("wrong length %d for sr25519 public key", n) } - var res sr25519.PubKeySr25519 - copy(res[:], key.Sr25519) + + res := make(sr25519.PubKey, sr25519.PubKeySize) + copy(res, key.Sr25519) return res, nil case *types.PublicKey_Multisig: @@ -66,11 +72,11 @@ func (cdc DefaultPublicKeyCodec) Decode(key *types.PublicKey) (crypto.PubKey, er // Encode implements the PublicKeyCodec.Encode method func (cdc DefaultPublicKeyCodec) Encode(key crypto.PubKey) (*types.PublicKey, error) { switch key := key.(type) { - case secp256k1.PubKeySecp256k1: + case secp256k1.PubKey: return &types.PublicKey{Sum: &types.PublicKey_Secp256K1{Secp256K1: key[:]}}, nil - case ed255192.PubKeyEd25519: + case ed255192.PubKey: return &types.PublicKey{Sum: &types.PublicKey_Ed25519{Ed25519: key[:]}}, nil - case sr25519.PubKeySr25519: + case sr25519.PubKey: return &types.PublicKey{Sum: &types.PublicKey_Sr25519{Sr25519: key[:]}}, nil case multisig.PubKeyMultisigThreshold: pubKeys := key.PubKeys diff --git a/store/README.md b/store/README.md index 54994374bcd6..585b1ab52d9e 100644 --- a/store/README.md +++ b/store/README.md @@ -2,7 +2,7 @@ ## CacheKV -`cachekv.Store` is a wrapper `KVStore` which provides buffered writing / cached reading functionalities over the underlying `KVStore`. +`cachekv.Store` is a wrapper `KVStore` which provides buffered writing / cached reading functionalities over the underlying `KVStore`. ```go type Store struct { @@ -50,13 +50,13 @@ type Store struct { ## IAVL -`iavl.Store` is a base-layer self-balancing merkle tree. It is guaranteed that +`iavl.Store` is a base-layer self-balancing merkle tree. It is guaranteed that 1. Get & set operations are `O(log n)`, where `n` is the number of elements in the tree 2. Iteration efficiently returns the sorted elements within the range 3. Each tree version is immutable and can be retrieved even after a commit(depending on the pruning settings) -Specification and implementation of IAVL tree can be found in [https://github.com/tendermint/iavl]. +Specification and implementation of IAVL tree can be found in [https://github.com/cosmos/iavl]. ## GasKV @@ -72,7 +72,6 @@ type Store struct { When each `KVStore` methods are called, `gaskv.Store` automatically consumes appropriate amount of gas depending on the `Store.gasConfig`. - ## Prefix `prefix.Store` is a wrapper `KVStore` which provides automatic key-prefixing functionalities over the underlying `KVStore`. @@ -112,7 +111,7 @@ type traceOperation struct { Key string Value string Metadata map[string]interface{} -} +} ``` `traceOperation.Metadata` is filled with `Store.context` when it is not nil. `TraceContext` is a `map[string]interface{}`. diff --git a/store/cache/cache_test.go b/store/cache/cache_test.go index 93ece75083ed..a90683640048 100644 --- a/store/cache/cache_test.go +++ b/store/cache/cache_test.go @@ -8,8 +8,8 @@ import ( iavlstore "github.com/cosmos/cosmos-sdk/store/iavl" "github.com/cosmos/cosmos-sdk/store/types" + "github.com/cosmos/iavl" "github.com/stretchr/testify/require" - "github.com/tendermint/iavl" dbm "github.com/tendermint/tm-db" ) diff --git a/store/cachekv/memiterator.go b/store/cachekv/memiterator.go index 60ec36868193..c5a00ab8dfcd 100644 --- a/store/cachekv/memiterator.go +++ b/store/cachekv/memiterator.go @@ -4,8 +4,9 @@ import ( "container/list" "errors" - tmkv "github.com/tendermint/tendermint/libs/kv" dbm "github.com/tendermint/tm-db" + + "github.com/cosmos/cosmos-sdk/types/kv" ) // Iterates over iterKVCache items. @@ -13,17 +14,17 @@ import ( // Implements Iterator. type memIterator struct { start, end []byte - items []*tmkv.Pair + items []*kv.Pair ascending bool } func newMemIterator(start, end []byte, items *list.List, ascending bool) *memIterator { - itemsInDomain := make([]*tmkv.Pair, 0) + itemsInDomain := make([]*kv.Pair, 0) var entered bool for e := items.Front(); e != nil; e = e.Next() { - item := e.Value.(*tmkv.Pair) + item := e.Value.(*kv.Pair) if !dbm.IsKeyInDomain(item.Key, start, end) { if entered { break @@ -88,10 +89,12 @@ func (mi *memIterator) Value() []byte { return mi.items[len(mi.items)-1].Value } -func (mi *memIterator) Close() { +func (mi *memIterator) Close() error { mi.start = nil mi.end = nil mi.items = nil + + return nil } // Error returns an error if the memIterator is invalid defined by the Valid diff --git a/store/cachekv/mergeiterator.go b/store/cachekv/mergeiterator.go index 7fe31e5b8b3d..4e7731141ce9 100644 --- a/store/cachekv/mergeiterator.go +++ b/store/cachekv/mergeiterator.go @@ -151,9 +151,11 @@ func (iter *cacheMergeIterator) Value() []byte { } // Close implements Iterator -func (iter *cacheMergeIterator) Close() { +func (iter *cacheMergeIterator) Close() error { iter.parent.Close() iter.cache.Close() + + return nil } // Error returns an error if the cacheMergeIterator is invalid defined by the diff --git a/store/cachekv/store.go b/store/cachekv/store.go index 4b519b7a70b9..dd8f95215b54 100644 --- a/store/cachekv/store.go +++ b/store/cachekv/store.go @@ -8,12 +8,12 @@ import ( "sync" "time" - tmkv "github.com/tendermint/tendermint/libs/kv" dbm "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/store/tracekv" "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/cosmos-sdk/telemetry" + "github.com/cosmos/cosmos-sdk/types/kv" ) // If value is nil but deleted is false, it means the parent doesn't have the @@ -181,13 +181,13 @@ func (store *Store) iterator(start, end []byte, ascending bool) types.Iterator { // Constructs a slice of dirty items, to use w/ memIterator. func (store *Store) dirtyItems(start, end []byte) { - unsorted := make([]*tmkv.Pair, 0) + unsorted := make([]*kv.Pair, 0) for key := range store.unsortedCache { cacheValue := store.cache[key] if dbm.IsKeyInDomain([]byte(key), start, end) { - unsorted = append(unsorted, &tmkv.Pair{Key: []byte(key), Value: cacheValue.value}) + unsorted = append(unsorted, &kv.Pair{Key: []byte(key), Value: cacheValue.value}) delete(store.unsortedCache, key) } @@ -199,7 +199,7 @@ func (store *Store) dirtyItems(start, end []byte) { for e := store.sortedCache.Front(); e != nil && len(unsorted) != 0; { uitem := unsorted[0] - sitem := e.Value.(*tmkv.Pair) + sitem := e.Value.(*kv.Pair) comp := bytes.Compare(uitem.Key, sitem.Key) switch comp { diff --git a/store/firstlast.go b/store/firstlast.go index 0aab0a53ab9c..126861014ced 100644 --- a/store/firstlast.go +++ b/store/firstlast.go @@ -3,30 +3,29 @@ package store import ( "bytes" - tmkv "github.com/tendermint/tendermint/libs/kv" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/kv" ) // Gets the first item. -func First(st KVStore, start, end []byte) (kv tmkv.Pair, ok bool) { +func First(st KVStore, start, end []byte) (kv.Pair, bool) { iter := st.Iterator(start, end) if !iter.Valid() { - return kv, false + return kv.Pair{}, false } defer iter.Close() - return tmkv.Pair{Key: iter.Key(), Value: iter.Value()}, true + return kv.Pair{Key: iter.Key(), Value: iter.Value()}, true } // Gets the last item. `end` is exclusive. -func Last(st KVStore, start, end []byte) (kv tmkv.Pair, ok bool) { +func Last(st KVStore, start, end []byte) (kv.Pair, bool) { iter := st.ReverseIterator(end, start) if !iter.Valid() { if v := st.Get(start); v != nil { - return tmkv.Pair{Key: sdk.CopyBytes(start), Value: sdk.CopyBytes(v)}, true + return kv.Pair{Key: sdk.CopyBytes(start), Value: sdk.CopyBytes(v)}, true } - return kv, false + return kv.Pair{}, false } defer iter.Close() @@ -34,9 +33,9 @@ func Last(st KVStore, start, end []byte) (kv tmkv.Pair, ok bool) { // Skip this one, end is exclusive. iter.Next() if !iter.Valid() { - return kv, false + return kv.Pair{}, false } } - return tmkv.Pair{Key: iter.Key(), Value: iter.Value()}, true + return kv.Pair{Key: iter.Key(), Value: iter.Value()}, true } diff --git a/store/gaskv/store.go b/store/gaskv/store.go index b2b4b792a53b..7cd59dee1f93 100644 --- a/store/gaskv/store.go +++ b/store/gaskv/store.go @@ -165,8 +165,10 @@ func (gi *gasIterator) Value() (value []byte) { } // Implements Iterator. -func (gi *gasIterator) Close() { +func (gi *gasIterator) Close() error { gi.parent.Close() + + return nil } // Error delegates the Error call to the parent iterator. diff --git a/store/gaskv/store_test.go b/store/gaskv/store_test.go index 55378666c02b..cf1c1af4fd14 100644 --- a/store/gaskv/store_test.go +++ b/store/gaskv/store_test.go @@ -55,7 +55,12 @@ func TestGasKVStoreIterator(t *testing.T) { require.Nil(t, end) require.NoError(t, iterator.Error()) - t.Cleanup(iterator.Close) + t.Cleanup(func() { + if err := iterator.Close; err != nil { + t.Logf("error cleaning up iterator: %v", err()) + } + }) + ka := iterator.Key() require.Equal(t, ka, keyFmt(1)) va := iterator.Value() @@ -71,7 +76,11 @@ func TestGasKVStoreIterator(t *testing.T) { require.NoError(t, iterator.Error()) reverseIterator := st.ReverseIterator(nil, nil) - t.Cleanup(reverseIterator.Close) + t.Cleanup(func() { + if err := reverseIterator.Close; err != nil { + t.Logf("error cleaning up iterator: %v", err()) + } + }) require.Equal(t, reverseIterator.Key(), keyFmt(2)) reverseIterator.Next() require.Equal(t, reverseIterator.Key(), keyFmt(1)) diff --git a/store/iavl/store.go b/store/iavl/store.go index cf3ecb681192..149b30b53a98 100644 --- a/store/iavl/store.go +++ b/store/iavl/store.go @@ -6,12 +6,10 @@ import ( "sync" "time" - ics23iavl "github.com/confio/ics23-iavl" ics23 "github.com/confio/ics23/go" - "github.com/tendermint/iavl" + "github.com/cosmos/iavl" abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/crypto/merkle" - tmkv "github.com/tendermint/tendermint/libs/kv" + tmmerkle "github.com/tendermint/tendermint/proto/tendermint/crypto" dbm "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/store/cachekv" @@ -20,6 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/kv" ) const ( @@ -267,7 +266,7 @@ func (st *Store) Query(req abci.RequestQuery) (res abci.ResponseQuery) { } // get proof from tree and convert to merkle.Proof before adding to result - res.Proof = getProofFromTree(mtree, req.Data, res.Value != nil) + res.ProofOps = getProofFromTree(mtree, req.Data, res.Value != nil) case "/subspace": var KVs []types.KVPair @@ -293,7 +292,7 @@ func (st *Store) Query(req abci.RequestQuery) (res abci.ResponseQuery) { // Takes a MutableTree, a key, and a flag for creating existence or absence proof and returns the // appropriate merkle.Proof. Since this must be called after querying for the value, this function should never error // Thus, it will panic on error rather than returning it -func getProofFromTree(tree *iavl.MutableTree, key []byte, exists bool) *merkle.Proof { +func getProofFromTree(tree *iavl.MutableTree, key []byte, exists bool) *tmmerkle.ProofOps { var ( commitmentProof *ics23.CommitmentProof err error @@ -301,14 +300,14 @@ func getProofFromTree(tree *iavl.MutableTree, key []byte, exists bool) *merkle.P if exists { // value was found - commitmentProof, err = ics23iavl.CreateMembershipProof(tree, key) + commitmentProof, err = tree.ImmutableTree.GetMembershipProof(key) if err != nil { // sanity check: If value was found, membership proof must be creatable panic(fmt.Sprintf("unexpected value for empty proof: %s", err.Error())) } } else { // value wasn't found - commitmentProof, err = ics23iavl.CreateNonMembershipProof(tree, key) + commitmentProof, err = tree.ImmutableTree.GetNonMembershipProof(key) if err != nil { // sanity check: If value wasn't found, nonmembership proof must be creatable panic(fmt.Sprintf("unexpected error for nonexistence proof: %s", err.Error())) @@ -316,7 +315,7 @@ func getProofFromTree(tree *iavl.MutableTree, key []byte, exists bool) *merkle.P } op := types.NewIavlCommitmentOp(key, commitmentProof) - return &merkle.Proof{Ops: []merkle.ProofOp{op.ProofOp()}} + return &tmmerkle.ProofOps{Ops: []tmmerkle.ProofOp{op.ProofOp()}} } //---------------------------------------- @@ -333,7 +332,7 @@ type iavlIterator struct { tree *iavl.ImmutableTree // Channel to push iteration values. - iterCh chan tmkv.Pair + iterCh chan kv.Pair // Close this to release goroutine. quitCh chan struct{} @@ -359,7 +358,7 @@ func newIAVLIterator(tree *iavl.ImmutableTree, start, end []byte, ascending bool start: sdk.CopyBytes(start), end: sdk.CopyBytes(end), ascending: ascending, - iterCh: make(chan tmkv.Pair), // Set capacity > 0? + iterCh: make(chan kv.Pair), // Set capacity > 0? quitCh: make(chan struct{}), initCh: make(chan struct{}), } @@ -376,7 +375,7 @@ func (iter *iavlIterator) iterateRoutine() { select { case <-iter.quitCh: return true // done with iteration. - case iter.iterCh <- tmkv.Pair{Key: key, Value: value}: + case iter.iterCh <- kv.Pair{Key: key, Value: value}: return false // yay. } }, @@ -439,11 +438,13 @@ func (iter *iavlIterator) Value() []byte { // Close closes the IAVL iterator by closing the quit channel and waiting for // the iterCh to finish/close. -func (iter *iavlIterator) Close() { +func (iter *iavlIterator) Close() error { close(iter.quitCh) // wait iterCh to close for range iter.iterCh { } + + return nil } // Error performs a no-op. diff --git a/store/iavl/store_test.go b/store/iavl/store_test.go index 27ebc4dbdd5d..6ac09059ab21 100644 --- a/store/iavl/store_test.go +++ b/store/iavl/store_test.go @@ -5,8 +5,8 @@ import ( "fmt" "testing" + "github.com/cosmos/iavl" "github.com/stretchr/testify/require" - "github.com/tendermint/iavl" abci "github.com/tendermint/tendermint/abci/types" dbm "github.com/tendermint/tm-db" @@ -72,7 +72,7 @@ func TestGetImmutable(t *testing.T) { res := newStore.Query(abci.RequestQuery{Data: []byte("hello"), Height: cID.Version, Path: "/key", Prove: true}) require.Equal(t, res.Value, []byte("adios")) - require.NotNil(t, res.Proof) + require.NotNil(t, res.ProofOps) require.Panics(t, func() { newStore.Set(nil, nil) }) require.Panics(t, func() { newStore.Delete(nil) }) diff --git a/store/iavl/tree.go b/store/iavl/tree.go index 9873034fa550..66e209bcdd50 100644 --- a/store/iavl/tree.go +++ b/store/iavl/tree.go @@ -3,7 +3,7 @@ package iavl import ( "fmt" - "github.com/tendermint/iavl" + "github.com/cosmos/iavl" ) var ( diff --git a/store/iavl/tree_test.go b/store/iavl/tree_test.go index bf67088300d4..24332b42e06a 100644 --- a/store/iavl/tree_test.go +++ b/store/iavl/tree_test.go @@ -3,8 +3,8 @@ package iavl import ( "testing" + "github.com/cosmos/iavl" "github.com/stretchr/testify/require" - "github.com/tendermint/iavl" dbm "github.com/tendermint/tm-db" ) diff --git a/store/prefix/store.go b/store/prefix/store.go index 5ac27b84daa8..0aee26016a39 100644 --- a/store/prefix/store.go +++ b/store/prefix/store.go @@ -178,8 +178,10 @@ func (pi *prefixIterator) Value() []byte { } // Implements Iterator -func (pi *prefixIterator) Close() { +func (pi *prefixIterator) Close() error { pi.iter.Close() + + return nil } // Error returns an error if the prefixIterator is invalid defined by the Valid diff --git a/store/prefix/store_test.go b/store/prefix/store_test.go index c46aec6f1a71..f335f06a7203 100644 --- a/store/prefix/store_test.go +++ b/store/prefix/store_test.go @@ -12,7 +12,7 @@ import ( "github.com/stretchr/testify/require" - tiavl "github.com/tendermint/iavl" + tiavl "github.com/cosmos/iavl" dbm "github.com/tendermint/tm-db" ) diff --git a/store/rootmulti/internal/maps/maps.go b/store/rootmulti/internal/maps/maps.go index feb52bafb9fb..ee57bd39c2e7 100644 --- a/store/rootmulti/internal/maps/maps.go +++ b/store/rootmulti/internal/maps/maps.go @@ -5,8 +5,8 @@ import ( "github.com/tendermint/tendermint/crypto/merkle" "github.com/tendermint/tendermint/crypto/tmhash" - "github.com/tendermint/tendermint/libs/kv" + "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/store/types" ) @@ -66,7 +66,7 @@ func hashKVPairs(kvs kv.Pairs) []byte { kvsH[i] = KVPair(kvp).Bytes() } - return merkle.SimpleHashFromByteSlices(kvsH) + return merkle.HashFromByteSlices(kvsH) } // --------------------------------------------- @@ -180,7 +180,7 @@ func SimpleHashFromMap(m map[string][]byte) []byte { // SimpleProofsFromMap generates proofs from a map. The keys/values of the map will be used as the keys/values // in the underlying key-value pairs. // The keys are sorted before the proofs are computed. -func SimpleProofsFromMap(m map[string][]byte) ([]byte, map[string]*merkle.SimpleProof, []string) { +func SimpleProofsFromMap(m map[string][]byte) ([]byte, map[string]*merkle.Proof, []string) { sm := newSimpleMap() for k, v := range m { sm.Set(k, v) @@ -193,8 +193,8 @@ func SimpleProofsFromMap(m map[string][]byte) ([]byte, map[string]*merkle.Simple kvsBytes[i] = KVPair(kvp).Bytes() } - rootHash, proofList := merkle.SimpleProofsFromByteSlices(kvsBytes) - proofs := make(map[string]*merkle.SimpleProof) + rootHash, proofList := merkle.ProofsFromByteSlices(kvsBytes) + proofs := make(map[string]*merkle.Proof) keys := make([]string, len(proofList)) for i, kvp := range kvs { proofs[string(kvp.Key)] = proofList[i] diff --git a/store/rootmulti/internal/proofs/convert.go b/store/rootmulti/internal/proofs/convert.go index 46e65983e646..e3501532c0d3 100644 --- a/store/rootmulti/internal/proofs/convert.go +++ b/store/rootmulti/internal/proofs/convert.go @@ -13,7 +13,7 @@ import ( // // This is the simplest case of the range proof and we will focus on // demoing compatibility here -func ConvertExistenceProof(p *merkle.SimpleProof, key, value []byte) (*ics23.ExistenceProof, error) { +func ConvertExistenceProof(p *merkle.Proof, key, value []byte) (*ics23.ExistenceProof, error) { path, err := convertInnerOps(p) if err != nil { return nil, err @@ -42,7 +42,7 @@ func convertLeafOp() *ics23.LeafOp { } } -func convertInnerOps(p *merkle.SimpleProof) ([]*ics23.InnerOp, error) { +func convertInnerOps(p *merkle.Proof) ([]*ics23.InnerOp, error) { inners := make([]*ics23.InnerOp, 0, len(p.Aunts)) path := buildPath(p.Index, p.Total) @@ -69,7 +69,7 @@ func convertInnerOps(p *merkle.SimpleProof) ([]*ics23.InnerOp, error) { // buildPath returns a list of steps from leaf to root // in each step, true means index is left side, false index is right side // code adapted from merkle/simple_proof.go:computeHashFromAunts -func buildPath(idx int, total int) []bool { +func buildPath(idx int64, total int64) []bool { if total < 2 { return nil } @@ -84,13 +84,13 @@ func buildPath(idx int, total int) []bool { return append(buildPath(idx-numLeft, total-numLeft), goLeft) } -func getSplitPoint(length int) int { +func getSplitPoint(length int64) int64 { if length < 1 { panic("Trying to split a tree with size < 1") } uLength := uint(length) bitlen := bits.Len(uLength) - k := 1 << uint(bitlen-1) + k := int64(1 << uint(bitlen-1)) if k == length { k >>= 1 } diff --git a/store/rootmulti/internal/proofs/convert_test.go b/store/rootmulti/internal/proofs/convert_test.go index f6245b571826..19c5a6761507 100644 --- a/store/rootmulti/internal/proofs/convert_test.go +++ b/store/rootmulti/internal/proofs/convert_test.go @@ -31,8 +31,8 @@ func TestLeafOp(t *testing.T) { func TestBuildPath(t *testing.T) { cases := map[string]struct { - idx int - total int + idx int64 + total int64 expected []bool }{ "pair left": { diff --git a/store/rootmulti/internal/proofs/helpers.go b/store/rootmulti/internal/proofs/helpers.go index 5f70e599bc39..b7c3d88be423 100644 --- a/store/rootmulti/internal/proofs/helpers.go +++ b/store/rootmulti/internal/proofs/helpers.go @@ -3,6 +3,7 @@ package proofs import ( "sort" + "github.com/cosmos/cosmos-sdk/store/rootmulti/internal/maps" "github.com/tendermint/tendermint/crypto/merkle" "github.com/tendermint/tendermint/libs/rand" ) @@ -11,7 +12,7 @@ import ( type SimpleResult struct { Key []byte Value []byte - Proof *merkle.SimpleProof + Proof *merkle.Proof RootHash []byte } @@ -20,7 +21,7 @@ type SimpleResult struct { // returns a range proof and the root hash of the tree func GenerateRangeProof(size int, loc Where) *SimpleResult { data := BuildMap(size) - root, proofs, allkeys := merkle.SimpleProofsFromMap(data) + root, proofs, allkeys := maps.SimpleProofsFromMap(data) key := GetKey(allkeys, loc) proof := proofs[key] @@ -55,7 +56,7 @@ func SortedKeys(data map[string][]byte) []string { } func CalcRoot(data map[string][]byte) []byte { - root, _, _ := merkle.SimpleProofsFromMap(data) + root, _, _ := maps.SimpleProofsFromMap(data) return root } diff --git a/store/rootmulti/proof_test.go b/store/rootmulti/proof_test.go index bac54aada52e..f0bd29063ad1 100644 --- a/store/rootmulti/proof_test.go +++ b/store/rootmulti/proof_test.go @@ -26,31 +26,31 @@ func TestVerifyIAVLStoreQueryProof(t *testing.T) { Data: []byte("MYKEY"), Prove: true, }) - require.NotNil(t, res.Proof) + require.NotNil(t, res.ProofOps) // Verify proof. prt := DefaultProofRuntime() - err = prt.VerifyValue(res.Proof, cid.Hash, "/MYKEY", []byte("MYVALUE")) + err = prt.VerifyValue(res.ProofOps, cid.Hash, "/MYKEY", []byte("MYVALUE")) require.Nil(t, err) // Verify (bad) proof. - err = prt.VerifyValue(res.Proof, cid.Hash, "/MYKEY_NOT", []byte("MYVALUE")) + err = prt.VerifyValue(res.ProofOps, cid.Hash, "/MYKEY_NOT", []byte("MYVALUE")) require.NotNil(t, err) // Verify (bad) proof. - err = prt.VerifyValue(res.Proof, cid.Hash, "/MYKEY/MYKEY", []byte("MYVALUE")) + err = prt.VerifyValue(res.ProofOps, cid.Hash, "/MYKEY/MYKEY", []byte("MYVALUE")) require.NotNil(t, err) // Verify (bad) proof. - err = prt.VerifyValue(res.Proof, cid.Hash, "MYKEY", []byte("MYVALUE")) + err = prt.VerifyValue(res.ProofOps, cid.Hash, "MYKEY", []byte("MYVALUE")) require.NotNil(t, err) // Verify (bad) proof. - err = prt.VerifyValue(res.Proof, cid.Hash, "/MYKEY", []byte("MYVALUE_NOT")) + err = prt.VerifyValue(res.ProofOps, cid.Hash, "/MYKEY", []byte("MYVALUE_NOT")) require.NotNil(t, err) // Verify (bad) proof. - err = prt.VerifyValue(res.Proof, cid.Hash, "/MYKEY", []byte(nil)) + err = prt.VerifyValue(res.ProofOps, cid.Hash, "/MYKEY", []byte(nil)) require.NotNil(t, err) } @@ -73,39 +73,39 @@ func TestVerifyMultiStoreQueryProof(t *testing.T) { Data: []byte("MYKEY"), Prove: true, }) - require.NotNil(t, res.Proof) + require.NotNil(t, res.ProofOps) // Verify proof. prt := DefaultProofRuntime() - err := prt.VerifyValue(res.Proof, cid.Hash, "/iavlStoreKey/MYKEY", []byte("MYVALUE")) + err := prt.VerifyValue(res.ProofOps, cid.Hash, "/iavlStoreKey/MYKEY", []byte("MYVALUE")) require.Nil(t, err) // Verify proof. - err = prt.VerifyValue(res.Proof, cid.Hash, "/iavlStoreKey/MYKEY", []byte("MYVALUE")) + err = prt.VerifyValue(res.ProofOps, cid.Hash, "/iavlStoreKey/MYKEY", []byte("MYVALUE")) require.Nil(t, err) // Verify (bad) proof. - err = prt.VerifyValue(res.Proof, cid.Hash, "/iavlStoreKey/MYKEY_NOT", []byte("MYVALUE")) + err = prt.VerifyValue(res.ProofOps, cid.Hash, "/iavlStoreKey/MYKEY_NOT", []byte("MYVALUE")) require.NotNil(t, err) // Verify (bad) proof. - err = prt.VerifyValue(res.Proof, cid.Hash, "/iavlStoreKey/MYKEY/MYKEY", []byte("MYVALUE")) + err = prt.VerifyValue(res.ProofOps, cid.Hash, "/iavlStoreKey/MYKEY/MYKEY", []byte("MYVALUE")) require.NotNil(t, err) // Verify (bad) proof. - err = prt.VerifyValue(res.Proof, cid.Hash, "iavlStoreKey/MYKEY", []byte("MYVALUE")) + err = prt.VerifyValue(res.ProofOps, cid.Hash, "iavlStoreKey/MYKEY", []byte("MYVALUE")) require.NotNil(t, err) // Verify (bad) proof. - err = prt.VerifyValue(res.Proof, cid.Hash, "/MYKEY", []byte("MYVALUE")) + err = prt.VerifyValue(res.ProofOps, cid.Hash, "/MYKEY", []byte("MYVALUE")) require.NotNil(t, err) // Verify (bad) proof. - err = prt.VerifyValue(res.Proof, cid.Hash, "/iavlStoreKey/MYKEY", []byte("MYVALUE_NOT")) + err = prt.VerifyValue(res.ProofOps, cid.Hash, "/iavlStoreKey/MYKEY", []byte("MYVALUE_NOT")) require.NotNil(t, err) // Verify (bad) proof. - err = prt.VerifyValue(res.Proof, cid.Hash, "/iavlStoreKey/MYKEY", []byte(nil)) + err = prt.VerifyValue(res.ProofOps, cid.Hash, "/iavlStoreKey/MYKEY", []byte(nil)) require.NotNil(t, err) } @@ -129,20 +129,20 @@ func TestVerifyMultiStoreQueryProofAbsence(t *testing.T) { Data: []byte("MYABSENTKEY"), Prove: true, }) - require.NotNil(t, res.Proof) + require.NotNil(t, res.ProofOps) // Verify proof. prt := DefaultProofRuntime() - err = prt.VerifyAbsence(res.Proof, cid.Hash, "/iavlStoreKey/MYABSENTKEY") + err = prt.VerifyAbsence(res.ProofOps, cid.Hash, "/iavlStoreKey/MYABSENTKEY") require.Nil(t, err) // Verify (bad) proof. prt = DefaultProofRuntime() - err = prt.VerifyAbsence(res.Proof, cid.Hash, "/MYABSENTKEY") + err = prt.VerifyAbsence(res.ProofOps, cid.Hash, "/MYABSENTKEY") require.NotNil(t, err) // Verify (bad) proof. prt = DefaultProofRuntime() - err = prt.VerifyValue(res.Proof, cid.Hash, "/iavlStoreKey/MYABSENTKEY", []byte("")) + err = prt.VerifyValue(res.ProofOps, cid.Hash, "/iavlStoreKey/MYABSENTKEY", []byte("")) require.NotNil(t, err) } diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index 2db747a28da3..a6807777b722 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -6,10 +6,10 @@ import ( "strings" ics23 "github.com/confio/ics23/go" + iavltree "github.com/cosmos/iavl" "github.com/pkg/errors" - iavltree "github.com/tendermint/iavl" abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/crypto/merkle" + tmmerkle "github.com/tendermint/tendermint/proto/tendermint/crypto" dbm "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/codec" @@ -484,7 +484,7 @@ func (rs *Store) Query(req abci.RequestQuery) abci.ResponseQuery { return res } - if res.Proof == nil || len(res.Proof.Ops) == 0 { + if res.ProofOps == nil || len(res.ProofOps.Ops) == 0 { return sdkerrors.QueryResult(sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "proof is unexpectedly empty; ensure height has not been pruned")) } @@ -503,7 +503,7 @@ func (rs *Store) Query(req abci.RequestQuery) abci.ResponseQuery { } // Restore origin path and append proof op. - res.Proof.Ops = append(res.Proof.Ops, commitInfo.ProofOp(storeName)) + res.ProofOps.Ops = append(res.ProofOps.Ops, commitInfo.ProofOp(storeName)) return res } @@ -618,7 +618,7 @@ func (ci commitInfo) Hash() []byte { return rootHash } -func (ci commitInfo) ProofOp(storeName string) merkle.ProofOp { +func (ci commitInfo) ProofOp(storeName string) tmmerkle.ProofOp { cmap := ci.toMap() _, proofs, _ := sdkmaps.SimpleProofsFromMap(cmap) proof := proofs[storeName] diff --git a/store/tracekv/store.go b/store/tracekv/store.go index ba0bd8bf316b..f7618dc9aba9 100644 --- a/store/tracekv/store.go +++ b/store/tracekv/store.go @@ -54,6 +54,7 @@ func (tkv *Store) Get(key []byte) []byte { value := tkv.parent.Get(key) writeOperation(tkv.writer, readOp, tkv.context, key, value) + return value } @@ -146,8 +147,10 @@ func (ti *traceIterator) Value() []byte { } // Close implements the Iterator interface. -func (ti *traceIterator) Close() { +func (ti *traceIterator) Close() error { ti.parent.Close() + + return nil } // Error delegates the Error call to the parent iterator. diff --git a/store/tracekv/store_test.go b/store/tracekv/store_test.go index ec2e95567038..72a646e31615 100644 --- a/store/tracekv/store_test.go +++ b/store/tracekv/store_test.go @@ -50,11 +50,12 @@ func TestTraceKVStoreGet(t *testing.T) { expectedValue []byte expectedOut string }{ - { - key: []byte{}, - expectedValue: nil, - expectedOut: "{\"operation\":\"read\",\"key\":\"\",\"value\":\"\",\"metadata\":{\"blockHeight\":64}}\n", - }, + // TODO: key types can not me empty + // { + // key: []byte{}, + // expectedValue: nil, + // expectedOut: "{\"operation\":\"read\",\"key\":\"\",\"value\":\"\",\"metadata\":{\"blockHeight\":64}}\n", + // }, { key: kvPairs[0].Key, expectedValue: kvPairs[0].Value, @@ -124,10 +125,6 @@ func TestTraceKVStoreDelete(t *testing.T) { key []byte expectedOut string }{ - { - key: []byte{}, - expectedOut: "{\"operation\":\"delete\",\"key\":\"\",\"value\":\"\",\"metadata\":{\"blockHeight\":64}}\n", - }, { key: kvPairs[0].Key, expectedOut: "{\"operation\":\"delete\",\"key\":\"a2V5MDAwMDAwMDE=\",\"value\":\"\",\"metadata\":{\"blockHeight\":64}}\n", @@ -150,10 +147,6 @@ func TestTraceKVStoreHas(t *testing.T) { key []byte expected bool }{ - { - key: []byte{}, - expected: false, - }, { key: kvPairs[0].Key, expected: true, @@ -224,7 +217,7 @@ func TestTestTraceKVStoreIterator(t *testing.T) { require.False(t, iterator.Valid()) require.Panics(t, iterator.Next) - require.NotPanics(t, iterator.Close) + require.NoError(t, iterator.Close()) } func TestTestTraceKVStoreReverseIterator(t *testing.T) { @@ -280,7 +273,7 @@ func TestTestTraceKVStoreReverseIterator(t *testing.T) { require.False(t, iterator.Valid()) require.Panics(t, iterator.Next) - require.NotPanics(t, iterator.Close) + require.NoError(t, iterator.Close()) } func TestTraceKVStorePrefix(t *testing.T) { diff --git a/store/types/proof.go b/store/types/proof.go index f8a8125174bb..db8f673f46cd 100644 --- a/store/types/proof.go +++ b/store/types/proof.go @@ -3,6 +3,7 @@ package types import ( ics23 "github.com/confio/ics23/go" "github.com/tendermint/tendermint/crypto/merkle" + tmmerkle "github.com/tendermint/tendermint/proto/tendermint/crypto" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -48,7 +49,7 @@ func NewSimpleMerkleCommitmentOp(key []byte, proof *ics23.CommitmentProof) Commi // CommitmentOpDecoder takes a merkle.ProofOp and attempts to decode it into a CommitmentOp ProofOperator // The proofOp.Data is just a marshalled CommitmentProof. The Key of the CommitmentOp is extracted // from the unmarshalled proof. -func CommitmentOpDecoder(pop merkle.ProofOp) (merkle.ProofOperator, error) { +func CommitmentOpDecoder(pop tmmerkle.ProofOp) (merkle.ProofOperator, error) { var spec *ics23.ProofSpec switch pop.Type { case ProofOpIAVLCommitment: @@ -117,12 +118,12 @@ func (op CommitmentOp) Run(args [][]byte) ([][]byte, error) { // ProofOp implements ProofOperator interface and converts a CommitmentOp // into a merkle.ProofOp format that can later be decoded by CommitmentOpDecoder // back into a CommitmentOp for proof verification -func (op CommitmentOp) ProofOp() merkle.ProofOp { +func (op CommitmentOp) ProofOp() tmmerkle.ProofOp { bz, err := op.Proof.Marshal() if err != nil { panic(err.Error()) } - return merkle.ProofOp{ + return tmmerkle.ProofOp{ Type: op.Type, Key: op.Key, Data: bz, diff --git a/store/types/store.go b/store/types/store.go index fd4e33596e8d..25a30591909b 100644 --- a/store/types/store.go +++ b/store/types/store.go @@ -5,8 +5,9 @@ import ( "io" abci "github.com/tendermint/tendermint/abci/types" - tmkv "github.com/tendermint/tendermint/libs/kv" dbm "github.com/tendermint/tm-db" + + "github.com/cosmos/cosmos-sdk/types/kv" ) type Store interface { @@ -381,7 +382,7 @@ func (key *MemoryStoreKey) String() string { //---------------------------------------- // key-value result for iterator queries -type KVPair tmkv.Pair +type KVPair kv.Pair //---------------------------------------- diff --git a/store/types/utils.go b/store/types/utils.go index 1c836281ea88..22c8ca0761f9 100644 --- a/store/types/utils.go +++ b/store/types/utils.go @@ -3,7 +3,7 @@ package types import ( "bytes" - tmkv "github.com/tendermint/tendermint/libs/kv" + "github.com/cosmos/cosmos-sdk/types/kv" ) // Iterator over all the keys with a certain prefix in ascending order @@ -18,7 +18,7 @@ func KVStoreReversePrefixIterator(kvs KVStore, prefix []byte) Iterator { // DiffKVStores compares two KVstores and returns all the key/value pairs // that differ from one another. It also skips value comparison for a set of provided prefixes. -func DiffKVStores(a KVStore, b KVStore, prefixesToSkip [][]byte) (kvAs, kvBs []tmkv.Pair) { +func DiffKVStores(a KVStore, b KVStore, prefixesToSkip [][]byte) (kvAs, kvBs []kv.Pair) { iterA := a.Iterator(nil, nil) defer iterA.Close() @@ -32,15 +32,15 @@ func DiffKVStores(a KVStore, b KVStore, prefixesToSkip [][]byte) (kvAs, kvBs []t return kvAs, kvBs } - var kvA, kvB tmkv.Pair + var kvA, kvB kv.Pair if iterA.Valid() { - kvA = tmkv.Pair{Key: iterA.Key(), Value: iterA.Value()} + kvA = kv.Pair{Key: iterA.Key(), Value: iterA.Value()} iterA.Next() } if iterB.Valid() { - kvB = tmkv.Pair{Key: iterB.Key(), Value: iterB.Value()} + kvB = kv.Pair{Key: iterB.Key(), Value: iterB.Value()} iterB.Next() } diff --git a/testutil/network/util.go b/testutil/network/util.go index 86bed50eb34e..ecfa3d7c6a6c 100644 --- a/testutil/network/util.go +++ b/testutil/network/util.go @@ -1,6 +1,7 @@ package network import ( + "fmt" "path/filepath" "time" @@ -32,8 +33,8 @@ func startInProcess(cfg Config, val *Validator) error { } app := cfg.AppConstructor(*val) - genDocProvider := node.DefaultGenesisDocProviderFunc(tmCfg) + tmNode, err := node.NewNode( tmCfg, pvm.LoadOrGenFilePV(tmCfg.PrivValidatorKeyFile(), tmCfg.PrivValidatorStateFile()), @@ -45,10 +46,12 @@ func startInProcess(cfg Config, val *Validator) error { logger.With("module", val.Moniker), ) if err != nil { + fmt.Println(err) return err } if err := tmNode.Start(); err != nil { + fmt.Println(err) return err } diff --git a/third_party/proto/tendermint/abci/types.proto b/third_party/proto/tendermint/abci/types.proto new file mode 100644 index 000000000000..cf637fe75a7f --- /dev/null +++ b/third_party/proto/tendermint/abci/types.proto @@ -0,0 +1,396 @@ +syntax = "proto3"; +package tendermint.abci; + +option go_package = "github.com/tendermint/tendermint/abci/types"; + +// For more information on gogo.proto, see: +// https://github.com/gogo/protobuf/blob/master/extensions.md +import "tendermint/crypto/proof.proto"; +import "tendermint/types/types.proto"; +import "tendermint/crypto/keys.proto"; +import "tendermint/types/params.proto"; +import "google/protobuf/timestamp.proto"; +import "gogoproto/gogo.proto"; + +// This file is copied from http://github.com/tendermint/abci +// NOTE: When using custom types, mind the warnings. +// https://github.com/gogo/protobuf/blob/master/custom_types.md#warnings-and-issues + +//---------------------------------------- +// Request types + +message Request { + oneof value { + RequestEcho echo = 1; + RequestFlush flush = 2; + RequestInfo info = 3; + RequestSetOption set_option = 4; + RequestInitChain init_chain = 5; + RequestQuery query = 6; + RequestBeginBlock begin_block = 7; + RequestCheckTx check_tx = 8; + RequestDeliverTx deliver_tx = 9; + RequestEndBlock end_block = 10; + RequestCommit commit = 11; + RequestListSnapshots list_snapshots = 12; + RequestOfferSnapshot offer_snapshot = 13; + RequestLoadSnapshotChunk load_snapshot_chunk = 14; + RequestApplySnapshotChunk apply_snapshot_chunk = 15; + } +} + +message RequestEcho { + string message = 1; +} + +message RequestFlush {} + +message RequestInfo { + string version = 1; + uint64 block_version = 2; + uint64 p2p_version = 3; +} + +// nondeterministic +message RequestSetOption { + string key = 1; + string value = 2; +} + +message RequestInitChain { + google.protobuf.Timestamp time = 1 + [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; + string chain_id = 2; + ConsensusParams consensus_params = 3; + repeated ValidatorUpdate validators = 4 [(gogoproto.nullable) = false]; + bytes app_state_bytes = 5; +} + +message RequestQuery { + bytes data = 1; + string path = 2; + int64 height = 3; + bool prove = 4; +} + +message RequestBeginBlock { + bytes hash = 1; + tendermint.types.Header header = 2 [(gogoproto.nullable) = false]; + LastCommitInfo last_commit_info = 3 [(gogoproto.nullable) = false]; + repeated Evidence byzantine_validators = 4 [(gogoproto.nullable) = false]; +} + +enum CheckTxType { + NEW = 0 [(gogoproto.enumvalue_customname) = "New"]; + RECHECK = 1 [(gogoproto.enumvalue_customname) = "Recheck"]; +} + +message RequestCheckTx { + bytes tx = 1; + CheckTxType type = 2; +} + +message RequestDeliverTx { + bytes tx = 1; +} + +message RequestEndBlock { + int64 height = 1; +} + +message RequestCommit {} + +// lists available snapshots +message RequestListSnapshots { +} + +// offers a snapshot to the application +message RequestOfferSnapshot { + Snapshot snapshot = 1; // snapshot offered by peers + bytes app_hash = 2; // light client-verified app hash for snapshot height +} + +// loads a snapshot chunk +message RequestLoadSnapshotChunk { + uint64 height = 1; + uint32 format = 2; + uint32 chunk = 3; +} + +// Applies a snapshot chunk +message RequestApplySnapshotChunk { + uint32 index = 1; + bytes chunk = 2; + string sender = 3; +} + +//---------------------------------------- +// Response types + +message Response { + oneof value { + ResponseException exception = 1; + ResponseEcho echo = 2; + ResponseFlush flush = 3; + ResponseInfo info = 4; + ResponseSetOption set_option = 5; + ResponseInitChain init_chain = 6; + ResponseQuery query = 7; + ResponseBeginBlock begin_block = 8; + ResponseCheckTx check_tx = 9; + ResponseDeliverTx deliver_tx = 10; + ResponseEndBlock end_block = 11; + ResponseCommit commit = 12; + ResponseListSnapshots list_snapshots = 13; + ResponseOfferSnapshot offer_snapshot = 14; + ResponseLoadSnapshotChunk load_snapshot_chunk = 15; + ResponseApplySnapshotChunk apply_snapshot_chunk = 16; + } +} + +// nondeterministic +message ResponseException { + string error = 1; +} + +message ResponseEcho { + string message = 1; +} + +message ResponseFlush {} + +message ResponseInfo { + string data = 1; + + string version = 2; + uint64 app_version = 3; + + int64 last_block_height = 4; + bytes last_block_app_hash = 5; +} + +// nondeterministic +message ResponseSetOption { + uint32 code = 1; + // bytes data = 2; + string log = 3; + string info = 4; +} + +message ResponseInitChain { + ConsensusParams consensus_params = 1; + repeated ValidatorUpdate validators = 2 [(gogoproto.nullable) = false]; +} + +message ResponseQuery { + uint32 code = 1; + // bytes data = 2; // use "value" instead. + string log = 3; // nondeterministic + string info = 4; // nondeterministic + int64 index = 5; + bytes key = 6; + bytes value = 7; + tendermint.crypto.ProofOps proof_ops = 8; + int64 height = 9; + string codespace = 10; +} + +message ResponseBeginBlock { + repeated Event events = 1 + [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; +} + +message ResponseCheckTx { + uint32 code = 1; + bytes data = 2; + string log = 3; // nondeterministic + string info = 4; // nondeterministic + int64 gas_wanted = 5 [json_name = "gas_wanted"]; + int64 gas_used = 6 [json_name = "gas_used"]; + repeated Event events = 7 + [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; + string codespace = 8; +} + +message ResponseDeliverTx { + uint32 code = 1; + bytes data = 2; + string log = 3; // nondeterministic + string info = 4; // nondeterministic + int64 gas_wanted = 5 [json_name = "gas_wanted"]; + int64 gas_used = 6 [json_name = "gas_used"]; + repeated Event events = 7 + [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; + string codespace = 8; +} + +message ResponseEndBlock { + repeated ValidatorUpdate validator_updates = 1 + [(gogoproto.nullable) = false]; + ConsensusParams consensus_param_updates = 2; + repeated Event events = 3 + [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; +} + +message ResponseCommit { + // reserve 1 + bytes data = 2; + int64 retain_height = 3; +} + +message ResponseListSnapshots { + repeated Snapshot snapshots = 1; +} + +message ResponseOfferSnapshot { + Result result = 1; + + enum Result { + UNKNOWN = 0; // Unknown result, abort all snapshot restoration + ACCEPT = 1; // Snapshot accepted, apply chunks + ABORT = 2; // Abort all snapshot restoration + REJECT = 3; // Reject this specific snapshot, try others + REJECT_FORMAT = 4; // Reject all snapshots of this format, try others + REJECT_SENDER = 5; // Reject all snapshots from the sender(s), try others + } +} + +message ResponseLoadSnapshotChunk { + bytes chunk = 1; +} + +message ResponseApplySnapshotChunk { + Result result = 1; + repeated uint32 refetch_chunks = 2; // Chunks to refetch and reapply + repeated string reject_senders = 3; // Chunk senders to reject and ban + + enum Result { + UNKNOWN = 0; // Unknown result, abort all snapshot restoration + ACCEPT = 1; // Chunk successfully accepted + ABORT = 2; // Abort all snapshot restoration + RETRY = 3; // Retry chunk (combine with refetch and reject) + RETRY_SNAPSHOT = 4; // Retry snapshot (combine with refetch and reject) + REJECT_SNAPSHOT = 5; // Reject this snapshot, try others + } +} + +//---------------------------------------- +// Misc. + +// ConsensusParams contains all consensus-relevant parameters +// that can be adjusted by the abci app +message ConsensusParams { + BlockParams block = 1; + tendermint.types.EvidenceParams evidence = 2; + tendermint.types.ValidatorParams validator = 3; + tendermint.types.VersionParams version = 4; +} + +// BlockParams contains limits on the block size. +message BlockParams { + // Note: must be greater than 0 + int64 max_bytes = 1; + // Note: must be greater or equal to -1 + int64 max_gas = 2; +} + +message LastCommitInfo { + int32 round = 1; + repeated VoteInfo votes = 2 [(gogoproto.nullable) = false]; +} + +// Event allows application developers to attach additional information to +// ResponseBeginBlock, ResponseEndBlock, ResponseCheckTx and ResponseDeliverTx. +// Later, transactions may be queried using these events. +message Event { + string type = 1; + repeated EventAttribute attributes = 2 [ + (gogoproto.nullable) = false, + (gogoproto.jsontag) = "attributes,omitempty" + ]; +} + +// EventAttribute is a single key-value pair, associated with an event. +message EventAttribute { + bytes key = 1; + bytes value = 2; + bool index = 3; // nondeterministic +} + +// TxResult contains results of executing the transaction. +// +// One usage is indexing transaction results. +message TxResult { + int64 height = 1; + uint32 index = 2; + bytes tx = 3; + ResponseDeliverTx result = 4 [(gogoproto.nullable) = false]; +} + +//---------------------------------------- +// Blockchain Types + +// Validator +message Validator { + bytes address = 1; + // PubKey pub_key = 2 [(gogoproto.nullable)=false]; + int64 power = 3; +} + +// ValidatorUpdate +message ValidatorUpdate { + tendermint.crypto.PublicKey pub_key = 1 [(gogoproto.nullable) = false]; + int64 power = 2; +} + +// VoteInfo +message VoteInfo { + Validator validator = 1 [(gogoproto.nullable) = false]; + bool signed_last_block = 2; +} + +message Evidence { + string type = 1; + Validator validator = 2 [(gogoproto.nullable) = false]; + int64 height = 3; + google.protobuf.Timestamp time = 4 [ + (gogoproto.nullable) = false, + (gogoproto.stdtime) = true + ]; + // Total voting power of the validator set in case the ABCI application does + // not store historical validators. + // https://github.com/tendermint/tendermint/issues/4581 + int64 total_voting_power = 5; +} + +//---------------------------------------- +// State Sync Types + +message Snapshot { + uint64 height = 1; // The height at which the snapshot was taken + uint32 format = 2; // The application-specific snapshot format + uint32 chunks = 3; // Number of chunks in the snapshot + bytes hash = 4; // Arbitrary snapshot hash, equal only if identical + bytes metadata = 5; // Arbitrary application metadata +} + +//---------------------------------------- +// Service Definition + +service ABCIApplication { + rpc Echo(RequestEcho) returns (ResponseEcho); + rpc Flush(RequestFlush) returns (ResponseFlush); + rpc Info(RequestInfo) returns (ResponseInfo); + rpc SetOption(RequestSetOption) returns (ResponseSetOption); + rpc DeliverTx(RequestDeliverTx) returns (ResponseDeliverTx); + rpc CheckTx(RequestCheckTx) returns (ResponseCheckTx); + rpc Query(RequestQuery) returns (ResponseQuery); + rpc Commit(RequestCommit) returns (ResponseCommit); + rpc InitChain(RequestInitChain) returns (ResponseInitChain); + rpc BeginBlock(RequestBeginBlock) returns (ResponseBeginBlock); + rpc EndBlock(RequestEndBlock) returns (ResponseEndBlock); + rpc ListSnapshots(RequestListSnapshots) returns (ResponseListSnapshots); + rpc OfferSnapshot(RequestOfferSnapshot) returns (ResponseOfferSnapshot); + rpc LoadSnapshotChunk(RequestLoadSnapshotChunk) returns (ResponseLoadSnapshotChunk); + rpc ApplySnapshotChunk(RequestApplySnapshotChunk) returns (ResponseApplySnapshotChunk); +} diff --git a/third_party/proto/tendermint/abci/types/types.proto b/third_party/proto/tendermint/abci/types/types.proto deleted file mode 100644 index 317a6cd4b68e..000000000000 --- a/third_party/proto/tendermint/abci/types/types.proto +++ /dev/null @@ -1,346 +0,0 @@ -syntax = "proto3"; -package tendermint.abci.types; -option go_package = "github.com/tendermint/tendermint/abci/types"; - -// For more information on gogo.proto, see: -// https://github.com/gogo/protobuf/blob/master/extensions.md -import "gogoproto/gogo.proto"; -import "tendermint/crypto/merkle/merkle.proto"; -import "tendermint/libs/kv/types.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/duration.proto"; - -// This file is copied from http://github.com/tendermint/abci -// NOTE: When using custom types, mind the warnings. -// https://github.com/gogo/protobuf/blob/master/custom_types.md#warnings-and-issues - -option (gogoproto.marshaler_all) = true; -option (gogoproto.unmarshaler_all) = true; -option (gogoproto.sizer_all) = true; -option (gogoproto.goproto_registration) = true; -// Generate tests -option (gogoproto.populate_all) = true; -option (gogoproto.equal_all) = true; -option (gogoproto.testgen_all) = true; - -//---------------------------------------- -// Request types - -message Request { - oneof value { - RequestEcho echo = 2; - RequestFlush flush = 3; - RequestInfo info = 4; - RequestSetOption set_option = 5; - RequestInitChain init_chain = 6; - RequestQuery query = 7; - RequestBeginBlock begin_block = 8; - RequestCheckTx check_tx = 9; - RequestDeliverTx deliver_tx = 19; - RequestEndBlock end_block = 11; - RequestCommit commit = 12; - } -} - -message RequestEcho { - string message = 1; -} - -message RequestFlush {} - -message RequestInfo { - string version = 1; - uint64 block_version = 2; - uint64 p2p_version = 3; -} - -// nondeterministic -message RequestSetOption { - string key = 1; - string value = 2; -} - -message RequestInitChain { - google.protobuf.Timestamp time = 1 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; - string chain_id = 2; - ConsensusParams consensus_params = 3; - repeated ValidatorUpdate validators = 4 [(gogoproto.nullable) = false]; - bytes app_state_bytes = 5; -} - -message RequestQuery { - bytes data = 1; - string path = 2; - int64 height = 3; - bool prove = 4; -} - -message RequestBeginBlock { - bytes hash = 1; - Header header = 2 [(gogoproto.nullable) = false]; - LastCommitInfo last_commit_info = 3 [(gogoproto.nullable) = false]; - repeated Evidence byzantine_validators = 4 [(gogoproto.nullable) = false]; -} - -enum CheckTxType { - New = 0; - Recheck = 1; -} - -message RequestCheckTx { - bytes tx = 1; - CheckTxType type = 2; -} - -message RequestDeliverTx { - bytes tx = 1; -} - -message RequestEndBlock { - int64 height = 1; -} - -message RequestCommit {} - -//---------------------------------------- -// Response types - -message Response { - oneof value { - ResponseException exception = 1; - ResponseEcho echo = 2; - ResponseFlush flush = 3; - ResponseInfo info = 4; - ResponseSetOption set_option = 5; - ResponseInitChain init_chain = 6; - ResponseQuery query = 7; - ResponseBeginBlock begin_block = 8; - ResponseCheckTx check_tx = 9; - ResponseDeliverTx deliver_tx = 10; - ResponseEndBlock end_block = 11; - ResponseCommit commit = 12; - } -} - -// nondeterministic -message ResponseException { - string error = 1; -} - -message ResponseEcho { - string message = 1; -} - -message ResponseFlush {} - -message ResponseInfo { - string data = 1; - - string version = 2; - uint64 app_version = 3; - - int64 last_block_height = 4; - bytes last_block_app_hash = 5; -} - -// nondeterministic -message ResponseSetOption { - uint32 code = 1; - // bytes data = 2; - string log = 3; - string info = 4; -} - -message ResponseInitChain { - ConsensusParams consensus_params = 1; - repeated ValidatorUpdate validators = 2 [(gogoproto.nullable) = false]; -} - -message ResponseQuery { - uint32 code = 1; - // bytes data = 2; // use "value" instead. - string log = 3; // nondeterministic - string info = 4; // nondeterministic - int64 index = 5; - bytes key = 6; - bytes value = 7; - tendermint.crypto.merkle.Proof proof = 8; - int64 height = 9; - string codespace = 10; -} - -message ResponseBeginBlock { - repeated Event events = 1 - [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; -} - -message ResponseCheckTx { - uint32 code = 1; - bytes data = 2; - string log = 3; // nondeterministic - string info = 4; // nondeterministic - int64 gas_wanted = 5; - int64 gas_used = 6; - repeated Event events = 7 - [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; - string codespace = 8; -} - -message ResponseDeliverTx { - uint32 code = 1; - bytes data = 2; - string log = 3; // nondeterministic - string info = 4; // nondeterministic - int64 gas_wanted = 5; - int64 gas_used = 6; - repeated Event events = 7 - [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; - string codespace = 8; -} - -message ResponseEndBlock { - repeated ValidatorUpdate validator_updates = 1 [(gogoproto.nullable) = false]; - ConsensusParams consensus_param_updates = 2; - repeated Event events = 3 - [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; -} - -message ResponseCommit { - // reserve 1 - bytes data = 2; -} - -//---------------------------------------- -// Misc. - -// ConsensusParams contains all consensus-relevant parameters -// that can be adjusted by the abci app -message ConsensusParams { - BlockParams block = 1; - EvidenceParams evidence = 2; - ValidatorParams validator = 3; -} - -// BlockParams contains limits on the block size. -message BlockParams { - // Note: must be greater than 0 - int64 max_bytes = 1; - // Note: must be greater or equal to -1 - int64 max_gas = 2; -} - -message EvidenceParams { - // Note: must be greater than 0 - int64 max_age_num_blocks = 1; - google.protobuf.Duration max_age_duration = 2 - [(gogoproto.nullable) = false, (gogoproto.stdduration) = true]; -} - -// ValidatorParams contains limits on validators. -message ValidatorParams { - repeated string pub_key_types = 1; -} - -message LastCommitInfo { - int32 round = 1; - repeated VoteInfo votes = 2 [(gogoproto.nullable) = false]; -} - -message Event { - string type = 1; - repeated tendermint.libs.kv.Pair attributes = 2 - [(gogoproto.nullable) = false, (gogoproto.jsontag) = "attributes,omitempty"]; -} - -//---------------------------------------- -// Blockchain Types - -message Header { - // basic block info - Version version = 1 [(gogoproto.nullable) = false]; - string chain_id = 2 [(gogoproto.customname) = "ChainID"]; - int64 height = 3; - google.protobuf.Timestamp time = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; - - // prev block info - BlockID last_block_id = 5 [(gogoproto.nullable) = false]; - - // hashes of block data - bytes last_commit_hash = 6; // commit from validators from the last block - bytes data_hash = 7; // transactions - - // hashes from the app output from the prev block - bytes validators_hash = 8; // validators for the current block - bytes next_validators_hash = 9; // validators for the next block - bytes consensus_hash = 10; // consensus params for current block - bytes app_hash = 11; // state after txs from the previous block - bytes last_results_hash = 12; // root hash of all results from the txs from the previous block - - // consensus info - bytes evidence_hash = 13; // evidence included in the block - bytes proposer_address = 14; // original proposer of the block -} - -message Version { - uint64 Block = 1; - uint64 App = 2; -} - -message BlockID { - bytes hash = 1; - PartSetHeader parts_header = 2 [(gogoproto.nullable) = false]; -} - -message PartSetHeader { - int32 total = 1; - bytes hash = 2; -} - -// Validator -message Validator { - bytes address = 1; - // PubKey pub_key = 2 [(gogoproto.nullable)=false]; - int64 power = 3; -} - -// ValidatorUpdate -message ValidatorUpdate { - PubKey pub_key = 1 [(gogoproto.nullable) = false]; - int64 power = 2; -} - -// VoteInfo -message VoteInfo { - Validator validator = 1 [(gogoproto.nullable) = false]; - bool signed_last_block = 2; -} - -message PubKey { - string type = 1; - bytes data = 2; -} - -message Evidence { - string type = 1; - Validator validator = 2 [(gogoproto.nullable) = false]; - int64 height = 3; - google.protobuf.Timestamp time = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; - int64 total_voting_power = 5; -} - -//---------------------------------------- -// Service Definition - -service ABCIApplication { - rpc Echo(RequestEcho) returns (ResponseEcho); - rpc Flush(RequestFlush) returns (ResponseFlush); - rpc Info(RequestInfo) returns (ResponseInfo); - rpc SetOption(RequestSetOption) returns (ResponseSetOption); - rpc DeliverTx(RequestDeliverTx) returns (ResponseDeliverTx); - rpc CheckTx(RequestCheckTx) returns (ResponseCheckTx); - rpc Query(RequestQuery) returns (ResponseQuery); - rpc Commit(RequestCommit) returns (ResponseCommit); - rpc InitChain(RequestInitChain) returns (ResponseInitChain); - rpc BeginBlock(RequestBeginBlock) returns (ResponseBeginBlock); - rpc EndBlock(RequestEndBlock) returns (ResponseEndBlock); -} diff --git a/third_party/proto/tendermint/crypto/keys.proto b/third_party/proto/tendermint/crypto/keys.proto new file mode 100644 index 000000000000..e3a8ce93473f --- /dev/null +++ b/third_party/proto/tendermint/crypto/keys.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; +package tendermint.crypto; + +option go_package = "github.com/tendermint/tendermint/proto/tendermint/crypto"; + +import "gogoproto/gogo.proto"; + +// PublicKey defines the keys available for use with Tendermint Validators +message PublicKey { + option (gogoproto.compare) = true; + option (gogoproto.equal) = true; + + oneof sum { + bytes ed25519 = 1; + } +} + +// PrivateKey defines the keys available for use with Tendermint Validators +// WARNING PrivateKey is used for internal purposes only +message PrivateKey { + oneof sum { + bytes ed25519 = 1; + } +} diff --git a/third_party/proto/tendermint/crypto/merkle/merkle.proto b/third_party/proto/tendermint/crypto/merkle/merkle.proto deleted file mode 100644 index d0b657ef04b3..000000000000 --- a/third_party/proto/tendermint/crypto/merkle/merkle.proto +++ /dev/null @@ -1,31 +0,0 @@ -syntax = "proto3"; -package tendermint.crypto.merkle; -option go_package = "github.com/tendermint/tendermint/crypto/merkle"; - -// For more information on gogo.proto, see: -// https://github.com/gogo/protobuf/blob/master/extensions.md -import "gogoproto/gogo.proto"; - -option (gogoproto.marshaler_all) = true; -option (gogoproto.unmarshaler_all) = true; -option (gogoproto.sizer_all) = true; - -option (gogoproto.populate_all) = true; -option (gogoproto.equal_all) = true; - -//---------------------------------------- -// Message types - -// ProofOp defines an operation used for calculating Merkle root -// The data could be arbitrary format, providing nessecary data -// for example neighbouring node hash -message ProofOp { - string type = 1; - bytes key = 2; - bytes data = 3; -} - -// Proof is Merkle proof defined by the list of ProofOps -message Proof { - repeated ProofOp ops = 1 [(gogoproto.nullable) = false]; -} diff --git a/third_party/proto/tendermint/crypto/proof.proto b/third_party/proto/tendermint/crypto/proof.proto new file mode 100644 index 000000000000..975df7685397 --- /dev/null +++ b/third_party/proto/tendermint/crypto/proof.proto @@ -0,0 +1,41 @@ +syntax = "proto3"; +package tendermint.crypto; + +option go_package = "github.com/tendermint/tendermint/proto/tendermint/crypto"; + +import "gogoproto/gogo.proto"; + +message Proof { + int64 total = 1; + int64 index = 2; + bytes leaf_hash = 3; + repeated bytes aunts = 4; +} + +message ValueOp { + // Encoded in ProofOp.Key. + bytes key = 1; + + // To encode in ProofOp.Data + Proof proof = 2; +} + +message DominoOp { + string key = 1; + string input = 2; + string output = 3; +} + +// ProofOp defines an operation used for calculating Merkle root +// The data could be arbitrary format, providing nessecary data +// for example neighbouring node hash +message ProofOp { + string type = 1; + bytes key = 2; + bytes data = 3; +} + +// ProofOps is Merkle proof defined by the list of ProofOps +message ProofOps { + repeated ProofOp ops = 1 [(gogoproto.nullable) = false]; +} diff --git a/third_party/proto/tendermint/libs/bits/types.proto b/third_party/proto/tendermint/libs/bits/types.proto new file mode 100644 index 000000000000..3111d113a5b1 --- /dev/null +++ b/third_party/proto/tendermint/libs/bits/types.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; +package tendermint.libs.bits; + +option go_package = "github.com/tendermint/tendermint/proto/tendermint/libs/bits"; + +message BitArray { + int64 bits = 1; + repeated uint64 elems = 2; +} diff --git a/third_party/proto/tendermint/libs/kv/types.proto b/third_party/proto/tendermint/libs/kv/types.proto deleted file mode 100644 index 334eab5ac30b..000000000000 --- a/third_party/proto/tendermint/libs/kv/types.proto +++ /dev/null @@ -1,29 +0,0 @@ -syntax = "proto3"; -package tendermint.libs.kv; -option go_package = "github.com/tendermint/tendermint/libs/kv"; - -import "gogoproto/gogo.proto"; - -option (gogoproto.marshaler_all) = true; -option (gogoproto.unmarshaler_all) = true; -option (gogoproto.sizer_all) = true; -option (gogoproto.goproto_registration) = true; -// Generate tests -option (gogoproto.populate_all) = true; -option (gogoproto.equal_all) = true; -option (gogoproto.testgen_all) = true; - -//---------------------------------------- -// Abstract types - -// Define these here for compatibility but use tmlibs/kv.Pair. -message Pair { - bytes key = 1; - bytes value = 2; -} - -// Define these here for compatibility but use tmlibs/kv.KI64Pair. -message KI64Pair { - bytes key = 1; - int64 value = 2; -} diff --git a/third_party/proto/tendermint/types/evidence.proto b/third_party/proto/tendermint/types/evidence.proto new file mode 100644 index 000000000000..782f4cdcb823 --- /dev/null +++ b/third_party/proto/tendermint/types/evidence.proto @@ -0,0 +1,65 @@ +syntax = "proto3"; +package tendermint.types; + +option go_package = "github.com/tendermint/tendermint/proto/tendermint/types"; + +import "gogoproto/gogo.proto"; +import "tendermint/types/types.proto"; +import "tendermint/crypto/keys.proto"; + +// DuplicateVoteEvidence contains evidence a validator signed two conflicting +// votes. +message DuplicateVoteEvidence { + Vote vote_a = 1; + Vote vote_b = 2; +} + +message PotentialAmnesiaEvidence { + Vote vote_a = 1; + Vote vote_b = 2; + + int64 height_stamp = 3; +} + +message AmnesiaEvidence { + PotentialAmnesiaEvidence potential_amnesia_evidence = 1; + ProofOfLockChange polc = 2; +} + +message ConflictingHeadersEvidence { + SignedHeader h1 = 1; + SignedHeader h2 = 2; +} + +message LunaticValidatorEvidence { + Header header = 1; + Vote vote = 2; + string invalid_header_field = 3; +} + +message PhantomValidatorEvidence { + Vote vote = 1; + int64 last_height_validator_was_in_set = 2; +} + +message Evidence { + oneof sum { + DuplicateVoteEvidence duplicate_vote_evidence = 1; + ConflictingHeadersEvidence conflicting_headers_evidence = 2; + LunaticValidatorEvidence lunatic_validator_evidence = 3; + PotentialAmnesiaEvidence potential_amnesia_evidence = 4; + AmnesiaEvidence amnesia_evidence = 5; + PhantomValidatorEvidence phantom_validator_evidence = 6; + } +} + +// EvidenceData contains any evidence of malicious wrong-doing by validators +message EvidenceData { + repeated Evidence evidence = 1 [(gogoproto.nullable) = false]; + bytes hash = 2; +} + +message ProofOfLockChange { + repeated Vote votes = 1; + tendermint.crypto.PublicKey pub_key = 2; +} diff --git a/third_party/proto/tendermint/types/params.proto b/third_party/proto/tendermint/types/params.proto new file mode 100644 index 000000000000..4764f83271f9 --- /dev/null +++ b/third_party/proto/tendermint/types/params.proto @@ -0,0 +1,82 @@ +syntax = "proto3"; +package tendermint.types; + +option go_package = "github.com/tendermint/tendermint/proto/tendermint/types"; + +import "gogoproto/gogo.proto"; +import "google/protobuf/duration.proto"; + +option (gogoproto.equal_all) = true; + +// ConsensusParams contains consensus critical parameters that determine the +// validity of blocks. +message ConsensusParams { + BlockParams block = 1 [(gogoproto.nullable) = false]; + EvidenceParams evidence = 2 [(gogoproto.nullable) = false]; + ValidatorParams validator = 3 [(gogoproto.nullable) = false]; + VersionParams version = 4 [(gogoproto.nullable) = false]; +} + +// BlockParams contains limits on the block size. +message BlockParams { + // Note: must be greater than 0 + int64 max_bytes = 1; + // Note: must be greater or equal to -1 + int64 max_gas = 2; + // Minimum time increment between consecutive blocks (in milliseconds) + // Not exposed to the application. + int64 time_iota_ms = 3; +} + +// EvidenceParams determine how we handle evidence of malfeasance. +message EvidenceParams { + // Max age of evidence, in blocks. + // + // The basic formula for calculating this is: MaxAgeDuration / {average block + // time}. + int64 max_age_num_blocks = 1; + + // Max age of evidence, in time. + // + // It should correspond with an app's "unbonding period" or other similar + // mechanism for handling [Nothing-At-Stake + // attacks](https://github.com/ethereum/wiki/wiki/Proof-of-Stake-FAQ#what-is-the-nothing-at-stake-problem-and-how-can-it-be-fixed). + google.protobuf.Duration max_age_duration = 2 + [(gogoproto.nullable) = false, (gogoproto.stdduration) = true]; + + // This sets the maximum number of evidence that can be committed in a single block. + // and should fall comfortably under the max block bytes when we consider the size of + // each evidence (See MaxEvidenceBytes). The maximum number is MaxEvidencePerBlock. + // Default is 50 + uint32 max_num = 3; + + // Proof trial period dictates the time given for nodes accused of amnesia evidence, incorrectly + // voting twice in two different rounds to respond with their respective proofs. + // Default is half the max age in blocks: 50,000 + int64 proof_trial_period = 4; +} + +// ValidatorParams restrict the public key types validators can use. +// NOTE: uses ABCI pubkey naming, not Amino names. +message ValidatorParams { + option (gogoproto.populate) = true; + option (gogoproto.equal) = true; + + repeated string pub_key_types = 1; +} + +// VersionParams contains the ABCI application version. +message VersionParams { + option (gogoproto.populate) = true; + option (gogoproto.equal) = true; + + uint64 app_version = 1; +} + +// HashedParams is a subset of ConsensusParams. +// It is amino encoded and hashed into +// the Header.ConsensusHash. +message HashedParams { + int64 block_max_bytes = 1; + int64 block_max_gas = 2; +} diff --git a/third_party/proto/tendermint/types/types.proto b/third_party/proto/tendermint/types/types.proto new file mode 100644 index 000000000000..7ba7de8bdfd9 --- /dev/null +++ b/third_party/proto/tendermint/types/types.proto @@ -0,0 +1,156 @@ +syntax = "proto3"; +package tendermint.types; + +option go_package = "github.com/tendermint/tendermint/proto/tendermint/types"; + +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; +import "tendermint/libs/bits/types.proto"; +import "tendermint/crypto/proof.proto"; +import "tendermint/version/types.proto"; + +// BlockIdFlag indicates which BlcokID the signature is for +enum BlockIDFlag { + option (gogoproto.goproto_enum_stringer) = true; + option (gogoproto.goproto_enum_prefix) = false; + + BLOCK_ID_FLAG_UNKNOWN = 0 [(gogoproto.enumvalue_customname) = "BlockIDFlagUnknown"]; + BLOCK_ID_FLAG_ABSENT = 1 [(gogoproto.enumvalue_customname) = "BlockIDFlagAbsent"]; + BLOCK_ID_FLAG_COMMIT = 2 [(gogoproto.enumvalue_customname) = "BlockIDFlagCommit"]; + BLOCK_ID_FLAG_NIL = 3 [(gogoproto.enumvalue_customname) = "BlockIDFlagNil"]; +} + +// SignedMsgType is a type of signed message in the consensus. +enum SignedMsgType { + option (gogoproto.goproto_enum_stringer) = true; + option (gogoproto.goproto_enum_prefix) = false; + + SIGNED_MSG_TYPE_UNKNOWN = 0 [(gogoproto.enumvalue_customname) = "UnknownType"]; + // Votes + SIGNED_MSG_TYPE_PREVOTE = 1 [(gogoproto.enumvalue_customname) = "PrevoteType"]; + SIGNED_MSG_TYPE_PRECOMMIT = 2 [(gogoproto.enumvalue_customname) = "PrecommitType"]; + + // Proposals + SIGNED_MSG_TYPE_PROPOSAL = 32 [(gogoproto.enumvalue_customname) = "ProposalType"]; +} + +// PartsetHeader +message PartSetHeader { + uint32 total = 1; + bytes hash = 2; +} + +message Part { + uint32 index = 1; + bytes bytes = 2; + tendermint.crypto.Proof proof = 3 [(gogoproto.nullable) = false]; +} + +// BlockID +message BlockID { + bytes hash = 1; + PartSetHeader part_set_header = 2 [(gogoproto.nullable) = false]; +} + +// -------------------------------- + +// Header defines the structure of a Tendermint block header. +message Header { + // basic block info + tendermint.version.Consensus version = 1 [(gogoproto.nullable) = false]; + string chain_id = 2 [(gogoproto.customname) = "ChainID"]; + int64 height = 3; + google.protobuf.Timestamp time = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; + + // prev block info + BlockID last_block_id = 5 [(gogoproto.nullable) = false]; + + // hashes of block data + bytes last_commit_hash = 6; // commit from validators from the last block + bytes data_hash = 7; // transactions + + // hashes from the app output from the prev block + bytes validators_hash = 8; // validators for the current block + bytes next_validators_hash = 9; // validators for the next block + bytes consensus_hash = 10; // consensus params for current block + bytes app_hash = 11; // state after txs from the previous block + bytes last_results_hash = 12; // root hash of all results from the txs from the previous block + + // consensus info + bytes evidence_hash = 13; // evidence included in the block + bytes proposer_address = 14; // original proposer of the block +} + +// Data contains the set of transactions included in the block +message Data { + // Txs that will be applied by state @ block.Height+1. + // NOTE: not all txs here are valid. We're just agreeing on the order first. + // This means that block.AppHash does not include these txs. + repeated bytes txs = 1; + // Volatile + bytes hash = 2; +} + +// Vote represents a prevote, precommit, or commit vote from validators for +// consensus. +message Vote { + SignedMsgType type = 1; + int64 height = 2; + int32 round = 3; + BlockID block_id = 4 + [(gogoproto.nullable) = false, (gogoproto.customname) = "BlockID"]; // zero if vote is nil. + google.protobuf.Timestamp timestamp = 5 + [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; + bytes validator_address = 6; + int32 validator_index = 7; + bytes signature = 8; +} + +// Commit contains the evidence that a block was committed by a set of validators. +message Commit { + int64 height = 1; + int32 round = 2; + BlockID block_id = 3 [(gogoproto.nullable) = false, (gogoproto.customname) = "BlockID"]; + repeated CommitSig signatures = 4 [(gogoproto.nullable) = false]; + bytes hash = 5; + tendermint.libs.bits.BitArray bit_array = 6; +} + +// CommitSig is a part of the Vote included in a Commit. +message CommitSig { + BlockIDFlag block_id_flag = 1; + bytes validator_address = 2; + google.protobuf.Timestamp timestamp = 3 + [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; + bytes signature = 4; +} + +message Proposal { + SignedMsgType type = 1; + int64 height = 2; + int32 round = 3; + int32 pol_round = 4; + BlockID block_id = 5 [(gogoproto.customname) = "BlockID", (gogoproto.nullable) = false]; + google.protobuf.Timestamp timestamp = 6 + [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; + bytes signature = 7; +} + +message SignedHeader { + Header header = 1; + Commit commit = 2; +} + +message BlockMeta { + BlockID block_id = 1 [(gogoproto.customname) = "BlockID", (gogoproto.nullable) = false]; + int64 block_size = 2; + Header header = 3 [(gogoproto.nullable) = false]; + int64 num_txs = 4; +} + +// TxProof represents a Merkle proof of the presence of a transaction in the Merkle tree. +message TxProof { + bytes root_hash = 1; + bytes data = 2; + tendermint.crypto.Proof proof = 3; +} diff --git a/third_party/proto/tendermint/version/types.proto b/third_party/proto/tendermint/version/types.proto new file mode 100644 index 000000000000..6061868bd439 --- /dev/null +++ b/third_party/proto/tendermint/version/types.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; +package tendermint.version; + +option go_package = "github.com/tendermint/tendermint/proto/tendermint/version"; + +import "gogoproto/gogo.proto"; + +// App includes the protocol and software version for the application. +// This information is included in ResponseInfo. The App.Protocol can be +// updated in ResponseEndBlock. +message App { + uint64 protocol = 1; + string software = 2; +} + +// Consensus captures the consensus rules for processing a block in the blockchain, +// including all blockchain data structures and the rules of the application's +// state transition machine. +message Consensus { + option (gogoproto.equal) = true; + + uint64 block = 1; + uint64 app = 2; +} diff --git a/types/address.go b/types/address.go index d59db6b15055..0fd114eb2809 100644 --- a/types/address.go +++ b/types/address.go @@ -11,6 +11,7 @@ import ( "github.com/tendermint/tendermint/crypto" yaml "gopkg.in/yaml.v2" + "github.com/cosmos/cosmos-sdk/codec/legacy" tmamino "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/types/bech32" ) @@ -601,7 +602,7 @@ func Bech32ifyPubKey(pkt Bech32PubKeyType, pubkey crypto.PubKey) (string, error) } - return bech32.ConvertAndEncode(bech32Prefix, pubkey.Bytes()) + return bech32.ConvertAndEncode(bech32Prefix, legacy.Cdc.Amino.MustMarshalBinaryBare(pubkey)) } // MustBech32ifyPubKey calls Bech32ifyPubKey except it panics on error. diff --git a/types/address_bench_test.go b/types/address_bench_test.go index 1bb0d15f6153..205954280774 100644 --- a/types/address_bench_test.go +++ b/types/address_bench_test.go @@ -13,7 +13,7 @@ import ( ) func BenchmarkBech32ifyPubKey(b *testing.B) { - var pk ed25519.PubKeyEd25519 + var pk ed25519.PubKey rng := rand.New(rand.NewSource(time.Now().Unix())) b.ResetTimer() @@ -29,7 +29,7 @@ func BenchmarkBech32ifyPubKey(b *testing.B) { } func BenchmarkGetPubKeyFromBech32(b *testing.B) { - var pk ed25519.PubKeyEd25519 + var pk ed25519.PubKey rng := rand.New(rand.NewSource(time.Now().Unix())) b.ResetTimer() diff --git a/types/address_test.go b/types/address_test.go index 8a928a43c923..6a36145fc536 100644 --- a/types/address_test.go +++ b/types/address_test.go @@ -58,10 +58,10 @@ func TestEmptyAddresses(t *testing.T) { } func TestRandBech32PubkeyConsistency(t *testing.T) { - var pub ed25519.PubKeyEd25519 + pub := make(ed25519.PubKey, ed25519.PubKeySize) for i := 0; i < 1000; i++ { - rand.Read(pub[:]) + rand.Read(pub) mustBech32AccPub := types.MustBech32ifyPubKey(types.Bech32PubKeyTypeAccPub, pub) bech32AccPub, err := types.Bech32ifyPubKey(types.Bech32PubKeyTypeAccPub, pub) @@ -116,10 +116,10 @@ func TestYAMLMarshalers(t *testing.T) { } func TestRandBech32AccAddrConsistency(t *testing.T) { - var pub ed25519.PubKeyEd25519 + pub := make(ed25519.PubKey, ed25519.PubKeySize) for i := 0; i < 1000; i++ { - rand.Read(pub[:]) + rand.Read(pub) acc := types.AccAddress(pub.Address()) res := types.AccAddress{} @@ -154,7 +154,7 @@ func TestRandBech32AccAddrConsistency(t *testing.T) { } func TestValAddr(t *testing.T) { - var pub ed25519.PubKeyEd25519 + pub := make(ed25519.PubKey, ed25519.PubKeySize) for i := 0; i < 20; i++ { rand.Read(pub[:]) @@ -194,7 +194,7 @@ func TestValAddr(t *testing.T) { } func TestConsAddress(t *testing.T) { - var pub ed25519.PubKeyEd25519 + pub := make(ed25519.PubKey, ed25519.PubKeySize) for i := 0; i < 20; i++ { rand.Read(pub[:]) @@ -243,7 +243,7 @@ func RandString(n int) string { } func TestConfiguredPrefix(t *testing.T) { - var pub ed25519.PubKeyEd25519 + pub := make(ed25519.PubKey, ed25519.PubKeySize) for length := 1; length < 10; length++ { for times := 1; times < 20; times++ { rand.Read(pub[:]) @@ -298,7 +298,7 @@ func TestConfiguredPrefix(t *testing.T) { } func TestAddressInterface(t *testing.T) { - var pub ed25519.PubKeyEd25519 + pub := make(ed25519.PubKey, ed25519.PubKeySize) rand.Read(pub[:]) addrs := []types.Address{ diff --git a/types/context.go b/types/context.go index 0cc01091c1f2..04722be1fa55 100644 --- a/types/context.go +++ b/types/context.go @@ -7,6 +7,7 @@ import ( "github.com/gogo/protobuf/proto" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/store/gaskv" stypes "github.com/cosmos/cosmos-sdk/store/types" @@ -23,7 +24,7 @@ and standard additions here would be better just to add to the Context struct type Context struct { ctx context.Context ms MultiStore - header abci.Header + header tmproto.Header chainID string txBytes []byte logger log.Logger @@ -57,8 +58,8 @@ func (c Context) MinGasPrices() DecCoins { return c.minGasPrice } func (c Context) EventManager() *EventManager { return c.eventManager } // clone the header before returning -func (c Context) BlockHeader() abci.Header { - var msg = proto.Clone(&c.header).(*abci.Header) +func (c Context) BlockHeader() tmproto.Header { + var msg = proto.Clone(&c.header).(*tmproto.Header) return *msg } @@ -67,7 +68,7 @@ func (c Context) ConsensusParams() *abci.ConsensusParams { } // create a new context -func NewContext(ms MultiStore, header abci.Header, isCheckTx bool, logger log.Logger) Context { +func NewContext(ms MultiStore, header tmproto.Header, isCheckTx bool, logger log.Logger) Context { // https://github.com/gogo/protobuf/issues/519 header.Time = header.Time.UTC() return Context{ @@ -96,7 +97,7 @@ func (c Context) WithMultiStore(ms MultiStore) Context { } // WithBlockHeader returns a Context with an updated tendermint block header in UTC time. -func (c Context) WithBlockHeader(header abci.Header) Context { +func (c Context) WithBlockHeader(header tmproto.Header) Context { // https://github.com/gogo/protobuf/issues/519 header.Time = header.Time.UTC() c.header = header diff --git a/types/context_test.go b/types/context_test.go index a33fe65f64e2..810f87a5d84d 100644 --- a/types/context_test.go +++ b/types/context_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" abci "github.com/tendermint/tendermint/abci/types" @@ -51,7 +52,7 @@ func defaultContext(t *testing.T, key types.StoreKey) types.Context { cms.MountStoreWithDB(key, types.StoreTypeIAVL, db) err := cms.LoadLatestVersion() require.NoError(t, err) - ctx := types.NewContext(cms, abci.Header{}, false, log.NewNopLogger()) + ctx := types.NewContext(cms, tmproto.Header{}, false, log.NewNopLogger()) return ctx } @@ -104,7 +105,7 @@ func TestContextWithCustom(t *testing.T) { var ctx types.Context require.True(t, ctx.IsZero()) - header := abci.Header{} + header := tmproto.Header{} height := int64(1) chainid := "chainid" ischeck := true @@ -164,7 +165,7 @@ func TestContextHeader(t *testing.T) { addr := secp256k1.GenPrivKey().PubKey().Address() proposer := types.ConsAddress(addr) - ctx = types.NewContext(nil, abci.Header{}, false, nil) + ctx = types.NewContext(nil, tmproto.Header{}, false, nil) ctx = ctx. WithBlockHeight(height). @@ -178,35 +179,35 @@ func TestContextHeader(t *testing.T) { func TestContextHeaderClone(t *testing.T) { cases := map[string]struct { - h abci.Header + h tmproto.Header }{ "empty": { - h: abci.Header{}, + h: tmproto.Header{}, }, "height": { - h: abci.Header{ + h: tmproto.Header{ Height: 77, }, }, "time": { - h: abci.Header{ + h: tmproto.Header{ Time: time.Unix(12345677, 12345), }, }, "zero time": { - h: abci.Header{ + h: tmproto.Header{ Time: time.Unix(0, 0), }, }, "many items": { - h: abci.Header{ + h: tmproto.Header{ Height: 823, Time: time.Unix(9999999999, 0), ChainID: "silly-demo", }, }, "many items with hash": { - h: abci.Header{ + h: tmproto.Header{ Height: 823, Time: time.Unix(9999999999, 0), ChainID: "silly-demo", @@ -233,7 +234,7 @@ func TestContextHeaderClone(t *testing.T) { } func TestUnwrapSDKContext(t *testing.T) { - sdkCtx := types.NewContext(nil, abci.Header{}, false, nil) + sdkCtx := types.NewContext(nil, tmproto.Header{}, false, nil) ctx := types.WrapSDKContext(sdkCtx) sdkCtx2 := types.UnwrapSDKContext(ctx) require.Equal(t, sdkCtx, sdkCtx2) diff --git a/types/events.go b/types/events.go index 30fe1ee39de2..3f1ae18fd0d0 100644 --- a/types/events.go +++ b/types/events.go @@ -6,7 +6,6 @@ import ( "strings" abci "github.com/tendermint/tendermint/abci/types" - tmkv "github.com/tendermint/tendermint/libs/kv" ) // ---------------------------------------------------------------------------- @@ -79,8 +78,8 @@ func (a Attribute) String() string { } // ToKVPair converts an Attribute object into a Tendermint key/value pair. -func (a Attribute) ToKVPair() tmkv.Pair { - return tmkv.Pair{Key: toBytes(a.Key), Value: toBytes(a.Value)} +func (a Attribute) ToKVPair() abci.EventAttribute { + return abci.EventAttribute{Key: toBytes(a.Key), Value: toBytes(a.Value), Index: true} } // AppendAttributes adds one or more attributes to an Event. diff --git a/types/kv/kv.go b/types/kv/kv.go new file mode 100644 index 000000000000..23cb7ec789f5 --- /dev/null +++ b/types/kv/kv.go @@ -0,0 +1,36 @@ +package kv + +import ( + "bytes" + "sort" +) + +//---------------------------------------- +// KVPair + +/* +Defined in types.proto +type Pair struct { + Key []byte + Value []byte +} +*/ + +type Pairs []Pair + +// Sorting +func (kvs Pairs) Len() int { return len(kvs) } +func (kvs Pairs) Less(i, j int) bool { + switch bytes.Compare(kvs[i].Key, kvs[j].Key) { + case -1: + return true + case 0: + return bytes.Compare(kvs[i].Value, kvs[j].Value) < 0 + case 1: + return false + default: + panic("invalid comparison result") + } +} +func (kvs Pairs) Swap(i, j int) { kvs[i], kvs[j] = kvs[j], kvs[i] } +func (kvs Pairs) Sort() { sort.Sort(kvs) } diff --git a/types/kv/kv.pb.go b/types/kv/kv.pb.go new file mode 100644 index 000000000000..1e15bdc68f85 --- /dev/null +++ b/types/kv/kv.pb.go @@ -0,0 +1,373 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/kv/kv.proto + +package kv + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Key-Value Pair +type Pair struct { + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (m *Pair) Reset() { *m = Pair{} } +func (m *Pair) String() string { return proto.CompactTextString(m) } +func (*Pair) ProtoMessage() {} +func (*Pair) Descriptor() ([]byte, []int) { + return fileDescriptor_23371bd43b515c6e, []int{0} +} +func (m *Pair) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Pair) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Pair.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Pair) XXX_Merge(src proto.Message) { + xxx_messageInfo_Pair.Merge(m, src) +} +func (m *Pair) XXX_Size() int { + return m.Size() +} +func (m *Pair) XXX_DiscardUnknown() { + xxx_messageInfo_Pair.DiscardUnknown(m) +} + +var xxx_messageInfo_Pair proto.InternalMessageInfo + +func (m *Pair) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +func (m *Pair) GetValue() []byte { + if m != nil { + return m.Value + } + return nil +} + +func init() { + proto.RegisterType((*Pair)(nil), "cosmos.kv.Pair") +} + +func init() { proto.RegisterFile("cosmos/kv/kv.proto", fileDescriptor_23371bd43b515c6e) } + +var fileDescriptor_23371bd43b515c6e = []byte{ + // 150 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4a, 0xce, 0x2f, 0xce, + 0xcd, 0x2f, 0xd6, 0xcf, 0x2e, 0xd3, 0xcf, 0x2e, 0xd3, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, + 0x84, 0x88, 0xe9, 0x65, 0x97, 0x29, 0xe9, 0x71, 0xb1, 0x04, 0x24, 0x66, 0x16, 0x09, 0x09, 0x70, + 0x31, 0x67, 0xa7, 0x56, 0x4a, 0x30, 0x2a, 0x30, 0x6a, 0xf0, 0x04, 0x81, 0x98, 0x42, 0x22, 0x5c, + 0xac, 0x65, 0x89, 0x39, 0xa5, 0xa9, 0x12, 0x4c, 0x60, 0x31, 0x08, 0xc7, 0xc9, 0xfe, 0xc4, 0x23, + 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, + 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x54, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, + 0x92, 0xf3, 0x73, 0xf5, 0xa1, 0x76, 0x42, 0x28, 0xdd, 0xe2, 0x94, 0x6c, 0xfd, 0x92, 0xca, 0x82, + 0x54, 0x90, 0x23, 0x92, 0xd8, 0xc0, 0x4e, 0x30, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xae, 0xee, + 0xa2, 0x4c, 0x98, 0x00, 0x00, 0x00, +} + +func (m *Pair) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Pair) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Pair) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarintKv(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0x12 + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintKv(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintKv(dAtA []byte, offset int, v uint64) int { + offset -= sovKv(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Pair) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovKv(uint64(l)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sovKv(uint64(l)) + } + return n +} + +func sovKv(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozKv(x uint64) (n int) { + return sovKv(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Pair) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowKv + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Pair: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Pair: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowKv + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthKv + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthKv + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowKv + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthKv + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthKv + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) + if m.Value == nil { + m.Value = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipKv(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthKv + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthKv + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipKv(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowKv + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowKv + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowKv + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthKv + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupKv + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthKv + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthKv = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowKv = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupKv = fmt.Errorf("proto: unexpected end of group") +) diff --git a/types/query/pagination_test.go b/types/query/pagination_test.go index bd33f5dc0df0..5f710f5cbeb7 100644 --- a/types/query/pagination_test.go +++ b/types/query/pagination_test.go @@ -5,24 +5,21 @@ import ( "fmt" "testing" - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/store/prefix" - authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" - - "github.com/cosmos/cosmos-sdk/baseapp" - - "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/store" + "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + "github.com/cosmos/cosmos-sdk/x/bank/types" ) const ( @@ -187,7 +184,7 @@ func ExamplePaginate() { func setupTest() (*simapp.SimApp, sdk.Context, codec.Marshaler) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{Height: 1}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{Height: 1}) appCodec := app.AppCodec() db := dbm.NewMemDB() diff --git a/types/store.go b/types/store.go index 96494d98e931..4fa1136cf3a5 100644 --- a/types/store.go +++ b/types/store.go @@ -1,9 +1,8 @@ package types import ( - tmkv "github.com/tendermint/tendermint/libs/kv" - "github.com/cosmos/cosmos-sdk/store/types" + "github.com/cosmos/cosmos-sdk/types/kv" ) type ( @@ -25,7 +24,7 @@ type ( // StoreDecoderRegistry defines each of the modules store decoders. Used for ImportExport // simulation. -type StoreDecoderRegistry map[string]func(kvA, kvB tmkv.Pair) string +type StoreDecoderRegistry map[string]func(kvA, kvB kv.Pair) string // Iterator over all the keys with a certain prefix in ascending order func KVStorePrefixIterator(kvs KVStore, prefix []byte) Iterator { @@ -51,7 +50,7 @@ func KVStoreReversePrefixIteratorPaginated(kvs KVStore, prefix []byte, page, lim // DiffKVStores compares two KVstores and returns all the key/value pairs // that differ from one another. It also skips value comparison for a set of provided prefixes -func DiffKVStores(a KVStore, b KVStore, prefixesToSkip [][]byte) (kvAs, kvBs []tmkv.Pair) { +func DiffKVStores(a KVStore, b KVStore, prefixesToSkip [][]byte) (kvAs, kvBs []kv.Pair) { return types.DiffKVStores(a, b, prefixesToSkip) } diff --git a/types/utils.go b/types/utils.go index 03cd18a45b71..b74dbb6641ff 100644 --- a/types/utils.go +++ b/types/utils.go @@ -91,7 +91,12 @@ func NewLevelDB(name, dir string) (db dbm.DB, err error) { err = fmt.Errorf("couldn't create db: %v", r) } }() - return dbm.NewDB(name, backend, dir), err + + if err != nil { + return nil, err + } + + return dbm.NewDB(name, backend, dir) } // copy bytes diff --git a/x/auth/ante/ante_test.go b/x/auth/ante/ante_test.go index a6f565f52048..b2010056b0ac 100644 --- a/x/auth/ante/ante_test.go +++ b/x/auth/ante/ante_test.go @@ -982,7 +982,7 @@ func (suite *AnteTestSuite) TestCustomSignatureVerificationGasConsumer() { // setup an ante handler that only accepts PubKeyEd25519 suite.anteHandler = ante.NewAnteHandler(suite.app.AccountKeeper, suite.app.BankKeeper, func(meter sdk.GasMeter, sig signing.SignatureV2, params types.Params) error { switch pubkey := sig.PubKey.(type) { - case ed25519.PubKeyEd25519: + case ed25519.PubKey: meter.ConsumeGas(params.SigVerifyCostED25519, "ante verify: ed25519") return nil default: diff --git a/x/auth/ante/basic.go b/x/auth/ante/basic.go index 695cb6ebdf9c..1799912cfa63 100644 --- a/x/auth/ante/basic.go +++ b/x/auth/ante/basic.go @@ -123,7 +123,7 @@ func (cgts ConsumeTxSizeGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, sim // use stdsignature to mock the size of a full signature simSig := types.StdSignature{ //nolint:staticcheck // this will be removed when proto is ready Signature: simSecp256k1Sig[:], - PubKey: pubkey.Bytes(), + PubKey: legacy.Cdc.MustMarshalBinaryBare(pubkey), } sigBz := legacy.Cdc.MustMarshalBinaryBare(simSig) diff --git a/x/auth/ante/integration_test.go b/x/auth/ante/integration_test.go index 4c232b2bbea8..9155b47aabb6 100644 --- a/x/auth/ante/integration_test.go +++ b/x/auth/ante/integration_test.go @@ -1,7 +1,7 @@ package ante_test import ( - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -11,7 +11,7 @@ import ( // returns context and app with params set on account keeper func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) { app := simapp.Setup(isCheckTx) - ctx := app.BaseApp.NewContext(isCheckTx, abci.Header{}) + ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams()) return app, ctx diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index a33d5fb0fc83..a11dd6ec885e 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -20,7 +20,7 @@ import ( var ( // simulation signature values used to estimate gas consumption - simSecp256k1Pubkey secp256k1.PubKeySecp256k1 + simSecp256k1Pubkey = make(secp256k1.PubKey, secp256k1.PubKeySize) simSecp256k1Sig [64]byte _ authsigning.SigVerifiableTx = (*types.StdTx)(nil) // assert StdTx implements SigVerifiableTx @@ -29,7 +29,7 @@ var ( func init() { // This decodes a valid hex string into a sepc256k1Pubkey for use in transaction simulation bz, _ := hex.DecodeString("035AD6810A47F073553FF30D2FCC7E0D3B1C0B74B61A1AAA2582344037151E143A") - copy(simSecp256k1Pubkey[:], bz) + copy(simSecp256k1Pubkey, bz) } // SignatureVerificationGasConsumer is the type of function that is used to both @@ -320,11 +320,11 @@ func DefaultSigVerificationGasConsumer( pubkey := sig.PubKey switch pubkey := pubkey.(type) { - case ed25519.PubKeyEd25519: + case ed25519.PubKey: meter.ConsumeGas(params.SigVerifyCostED25519, "ante verify: ed25519") return sdkerrors.Wrap(sdkerrors.ErrInvalidPubKey, "ED25519 public keys are unsupported") - case secp256k1.PubKeySecp256k1: + case secp256k1.PubKey: meter.ConsumeGas(params.SigVerifyCostSecp256k1, "ante verify: secp256k1") return nil diff --git a/x/auth/ante/sigverify_test.go b/x/auth/ante/sigverify_test.go index e128b9e26276..4904196fc544 100644 --- a/x/auth/ante/sigverify_test.go +++ b/x/auth/ante/sigverify_test.go @@ -6,18 +6,15 @@ import ( "github.com/stretchr/testify/suite" - "github.com/cosmos/cosmos-sdk/testutil/testdata" - - "github.com/cosmos/cosmos-sdk/types/tx/signing" - - "github.com/cosmos/cosmos-sdk/simapp" - "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/ed25519" "github.com/tendermint/tendermint/crypto/secp256k1" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" + "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/x/auth/ante" "github.com/cosmos/cosmos-sdk/x/auth/types" ) @@ -76,7 +73,7 @@ func (suite *AnteTestSuite) TestConsumeSignatureVerificationGas() { multisignature1 := multisig.NewMultisig(len(pkSet1)) expectedCost1 := expectedGasCostByKeys(pkSet1) for i := 0; i < len(pkSet1); i++ { - stdSig := types.StdSignature{PubKey: pkSet1[i].Bytes(), Signature: sigSet1[i]} + stdSig := types.StdSignature{PubKey: cdc.Amino.MustMarshalBinaryBare(pkSet1[i]), Signature: sigSet1[i]} sigV2, err := types.StdSignatureToSignatureV2(cdc, stdSig) suite.Require().NoError(err) err = multisig.AddSignatureV2(multisignature1, sigV2, pkSet1) diff --git a/x/auth/client/query.go b/x/auth/client/query.go index ed8ecacd7aa8..603780cdbf91 100644 --- a/x/auth/client/query.go +++ b/x/auth/client/query.go @@ -43,7 +43,7 @@ func QueryTxsByEvents(clientCtx client.Context, events []string, page, limit int // TODO: this may not always need to be proven // https://github.com/cosmos/cosmos-sdk/issues/6807 - resTxs, err := node.TxSearch(query, true, page, limit, orderBy) + resTxs, err := node.TxSearch(query, true, &page, &limit, orderBy) if err != nil { return nil, err } diff --git a/x/auth/keeper/integration_test.go b/x/auth/keeper/integration_test.go index 0b7714453071..d2069d6d3586 100644 --- a/x/auth/keeper/integration_test.go +++ b/x/auth/keeper/integration_test.go @@ -1,7 +1,7 @@ package keeper_test import ( - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -11,7 +11,7 @@ import ( // returns context and app with params set on account keeper func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) { app := simapp.Setup(isCheckTx) - ctx := app.BaseApp.NewContext(isCheckTx, abci.Header{}) + ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams()) return app, ctx diff --git a/x/auth/module_test.go b/x/auth/module_test.go index 849f2d15409d..0bf268ddba5c 100644 --- a/x/auth/module_test.go +++ b/x/auth/module_test.go @@ -5,6 +5,7 @@ import ( "github.com/stretchr/testify/require" abcitypes "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -12,7 +13,7 @@ import ( func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abcitypes.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) app.InitChain( abcitypes.RequestInitChain{ diff --git a/x/auth/signing/verify_test.go b/x/auth/signing/verify_test.go index 30f53013a0c1..632cb769575d 100644 --- a/x/auth/signing/verify_test.go +++ b/x/auth/signing/verify_test.go @@ -3,15 +3,15 @@ package signing_test import ( "testing" - "github.com/cosmos/cosmos-sdk/testutil/testdata" - "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/ante" "github.com/cosmos/cosmos-sdk/x/auth/signing" @@ -33,6 +33,7 @@ func TestVerifySignature(t *testing.T) { cdc := codec.New() sdk.RegisterCodec(cdc) types.RegisterCodec(cdc) + cryptocodec.RegisterCrypto(cdc) cdc.RegisterConcrete(testdata.TestMsg{}, "cosmos-sdk/Test", nil) acc1 := app.AccountKeeper.NewAccountWithAddress(ctx, addr) @@ -55,7 +56,7 @@ func TestVerifySignature(t *testing.T) { signature, err := priv.Sign(signBytes) require.NoError(t, err) - stdSig := types.StdSignature{PubKey: pubKey.Bytes(), Signature: signature} + stdSig := types.StdSignature{PubKey: cdc.MustMarshalBinaryBare(pubKey), Signature: signature} sigV2, err := types.StdSignatureToSignatureV2(cdc, stdSig) require.NoError(t, err) @@ -73,13 +74,13 @@ func TestVerifySignature(t *testing.T) { sig1, err := priv.Sign(multiSignBytes) require.NoError(t, err) - stdSig1 := types.StdSignature{PubKey: pubKey.Bytes(), Signature: sig1} + stdSig1 := types.StdSignature{PubKey: cdc.MustMarshalBinaryBare(pubKey), Signature: sig1} sig1V2, err := types.StdSignatureToSignatureV2(cdc, stdSig1) require.NoError(t, err) sig2, err := priv1.Sign(multiSignBytes) require.NoError(t, err) - stdSig2 := types.StdSignature{PubKey: pubKey.Bytes(), Signature: sig2} + stdSig2 := types.StdSignature{PubKey: cdc.MustMarshalBinaryBare(pubKey), Signature: sig2} sig2V2, err := types.StdSignatureToSignatureV2(cdc, stdSig2) require.NoError(t, err) @@ -95,7 +96,7 @@ func TestVerifySignature(t *testing.T) { // returns context and app with params set on account keeper func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) { app := simapp.Setup(isCheckTx) - ctx := app.BaseApp.NewContext(isCheckTx, abci.Header{}) + ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) app.AccountKeeper.SetParams(ctx, types.DefaultParams()) return app, ctx diff --git a/x/auth/simulation/decoder.go b/x/auth/simulation/decoder.go index cf3ab69e0b95..2fdf752037b3 100644 --- a/x/auth/simulation/decoder.go +++ b/x/auth/simulation/decoder.go @@ -5,9 +5,9 @@ import ( "fmt" gogotypes "github.com/gogo/protobuf/types" - tmkv "github.com/tendermint/tendermint/libs/kv" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/x/auth/types" ) @@ -18,8 +18,8 @@ type AuthUnmarshaler interface { // NewDecodeStore returns a decoder function closure that unmarshals the KVPair's // Value to the corresponding auth type. -func NewDecodeStore(ak AuthUnmarshaler) func(kvA, kvB tmkv.Pair) string { - return func(kvA, kvB tmkv.Pair) string { +func NewDecodeStore(ak AuthUnmarshaler) func(kvA, kvB kv.Pair) string { + return func(kvA, kvB kv.Pair) string { switch { case bytes.Equal(kvA.Key[:1], types.AddressStoreKeyPrefix): accA, err := ak.UnmarshalAccount(kvA.Value) diff --git a/x/auth/simulation/decoder_test.go b/x/auth/simulation/decoder_test.go index 6603d0083cb9..73f14eb44154 100644 --- a/x/auth/simulation/decoder_test.go +++ b/x/auth/simulation/decoder_test.go @@ -7,10 +7,10 @@ import ( gogotypes "github.com/gogo/protobuf/types" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto/ed25519" - tmkv "github.com/tendermint/tendermint/libs/kv" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/x/auth/simulation" "github.com/cosmos/cosmos-sdk/x/auth/types" ) @@ -31,16 +31,16 @@ func TestDecodeStore(t *testing.T) { globalAccNumber := gogotypes.UInt64Value{Value: 10} - kvPairs := tmkv.Pairs{ - tmkv.Pair{ + kvPairs := kv.Pairs{ + kv.Pair{ Key: types.AddressStoreKey(delAddr1), Value: accBz, }, - tmkv.Pair{ + kv.Pair{ Key: types.GlobalAccountNumberKey, Value: cdc.MustMarshalBinaryBare(&globalAccNumber), }, - tmkv.Pair{ + kv.Pair{ Key: []byte{0x99}, Value: []byte{0x99}, }, diff --git a/x/auth/tx/builder_test.go b/x/auth/tx/builder_test.go index c115f474ac83..89f29ca7fdda 100644 --- a/x/auth/tx/builder_test.go +++ b/x/auth/tx/builder_test.go @@ -3,19 +3,17 @@ package tx import ( "testing" - "github.com/cosmos/cosmos-sdk/testutil/testdata" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - - tx2 "github.com/cosmos/cosmos-sdk/types/tx" - - "github.com/cosmos/cosmos-sdk/types/tx/signing" - "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/legacy" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/std" + "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + tx2 "github.com/cosmos/cosmos-sdk/types/tx" + "github.com/cosmos/cosmos-sdk/types/tx/signing" ) func TestTxBuilder(t *testing.T) { @@ -50,7 +48,7 @@ func TestTxBuilder(t *testing.T) { PubKey: pubkey, Data: &signing.SingleSignatureData{ SignMode: signing.SignMode_SIGN_MODE_DIRECT, - Signature: pubkey.Bytes(), + Signature: legacy.Cdc.MustMarshalBinaryBare(pubkey), }, } @@ -132,7 +130,7 @@ func TestBuilderValidateBasic(t *testing.T) { PubKey: pubKey1, Data: &signing.SingleSignatureData{ SignMode: signing.SignMode_SIGN_MODE_DIRECT, - Signature: pubKey1.Bytes(), + Signature: legacy.Cdc.MustMarshalBinaryBare(pubKey1), }, } @@ -140,7 +138,7 @@ func TestBuilderValidateBasic(t *testing.T) { PubKey: pubKey2, Data: &signing.SingleSignatureData{ SignMode: signing.SignMode_SIGN_MODE_DIRECT, - Signature: pubKey2.Bytes(), + Signature: legacy.Cdc.MustMarshalBinaryBare(pubKey2), }, } diff --git a/x/auth/types/account.go b/x/auth/types/account.go index 1e85ac8f2049..180f1053588d 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -75,7 +75,7 @@ func (acc *BaseAccount) SetPubKey(pubKey crypto.PubKey) error { if pubKey == nil { acc.PubKey = nil } else { - acc.PubKey = pubKey.Bytes() + acc.PubKey = amino.MustMarshalBinaryBare(pubKey) } return nil diff --git a/x/auth/types/client_tx.go b/x/auth/types/client_tx.go index b0f8fc613bcd..cebc36f42a22 100644 --- a/x/auth/types/client_tx.go +++ b/x/auth/types/client_tx.go @@ -41,7 +41,7 @@ func (s *StdTxBuilder) SetSignatures(signatures ...signing.SignatureV2) error { pubKey := sig.PubKey if pubKey != nil { - pubKeyBz = pubKey.Bytes() + pubKeyBz = legacy.Cdc.MustMarshalBinaryBare(pubKey) } var ( diff --git a/x/auth/types/stdtx.go b/x/auth/types/stdtx.go index 589e494285c8..64a1f8456111 100644 --- a/x/auth/types/stdtx.go +++ b/x/auth/types/stdtx.go @@ -73,7 +73,7 @@ func (fee StdFee) GasPrices() sdk.DecCoins { func NewStdSignature(pk crypto.PubKey, sig []byte) StdSignature { var pkBz []byte if pk != nil { - pkBz = pk.Bytes() + pkBz = amino.MustMarshalBinaryBare(pk) } return StdSignature{PubKey: pkBz, Signature: sig} @@ -92,6 +92,7 @@ func (ss StdSignature) GetPubKey() (pk crypto.PubKey) { } amino.MustUnmarshalBinaryBare(ss.PubKey, &pk) + return pk } diff --git a/x/auth/types/stdtx_test.go b/x/auth/types/stdtx_test.go index 70d0ff2f746e..62239188a0f3 100644 --- a/x/auth/types/stdtx_test.go +++ b/x/auth/types/stdtx_test.go @@ -4,23 +4,22 @@ import ( "fmt" "testing" - "github.com/cosmos/cosmos-sdk/testutil/testdata" - - "github.com/cosmos/cosmos-sdk/crypto/types" - "github.com/cosmos/cosmos-sdk/crypto/types/multisig" - - "github.com/cosmos/cosmos-sdk/types/tx/signing" - "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/ed25519" "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" yaml "gopkg.in/yaml.v2" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/legacy" + cryptoamino "github.com/cosmos/cosmos-sdk/crypto/codec" + "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/crypto/types/multisig" + "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/tx/signing" ) var ( @@ -46,7 +45,7 @@ func NewTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, accNums panic(err) } - sigs[i] = StdSignature{PubKey: priv.PubKey().Bytes(), Signature: sig} + sigs[i] = StdSignature{PubKey: legacy.Cdc.MustMarshalBinaryBare(priv.PubKey()), Signature: sig} } tx := NewStdTx(msgs, fee, sigs, "") @@ -92,7 +91,7 @@ func TestStdSignBytes(t *testing.T) { } func TestTxValidateBasic(t *testing.T) { - ctx := sdk.NewContext(nil, abci.Header{ChainID: "mychainid"}, false, log.NewNopLogger()) + ctx := sdk.NewContext(nil, tmproto.Header{ChainID: "mychainid"}, false, log.NewNopLogger()) // keys and addresses priv1, _, addr1 := testdata.KeyTestPubAddr() @@ -174,6 +173,9 @@ func TestDefaultTxEncoder(t *testing.T) { func TestStdSignatureMarshalYAML(t *testing.T) { _, pubKey, _ := testdata.KeyTestPubAddr() + cdc := codec.New() + RegisterCodec(cdc) + cryptoamino.RegisterCrypto(cdc) testCases := []struct { sig StdSignature @@ -184,11 +186,11 @@ func TestStdSignatureMarshalYAML(t *testing.T) { "|\n pubkey: \"\"\n signature: \"\"\n", }, { - StdSignature{PubKey: pubKey.Bytes(), Signature: []byte("dummySig")}, + StdSignature{PubKey: cdc.Amino.MustMarshalBinaryBare(pubKey), Signature: []byte("dummySig")}, fmt.Sprintf("|\n pubkey: %s\n signature: 64756D6D79536967\n", sdk.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeAccPub, pubKey)), }, { - StdSignature{PubKey: pubKey.Bytes(), Signature: nil}, + StdSignature{PubKey: cdc.Amino.MustMarshalBinaryBare(pubKey), Signature: nil}, fmt.Sprintf("|\n pubkey: %s\n signature: \"\"\n", sdk.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeAccPub, pubKey)), }, } @@ -205,8 +207,10 @@ func TestSignatureV2Conversions(t *testing.T) { cdc := codec.New() sdk.RegisterCodec(cdc) RegisterCodec(cdc) + cryptoamino.RegisterCrypto(cdc) + dummy := []byte("dummySig") - sig := StdSignature{PubKey: pubKey.Bytes(), Signature: dummy} + sig := StdSignature{PubKey: cdc.Amino.MustMarshalBinaryBare(pubKey), Signature: dummy} sigV2, err := StdSignatureToSignatureV2(cdc, sig) require.NoError(t, err) @@ -262,16 +266,17 @@ func TestGetSignaturesV2(t *testing.T) { cdc := codec.New() sdk.RegisterCodec(cdc) RegisterCodec(cdc) + cryptoamino.RegisterCrypto(cdc) fee := NewStdFee(50000, sdk.Coins{sdk.NewInt64Coin("atom", 150)}) - sig := StdSignature{PubKey: pubKey.Bytes(), Signature: dummy} + sig := StdSignature{PubKey: cdc.Amino.MustMarshalBinaryBare(pubKey), Signature: dummy} stdTx := NewStdTx([]sdk.Msg{testdata.NewTestMsg()}, fee, []StdSignature{sig}, "testsigs") sigs, err := stdTx.GetSignaturesV2() require.Nil(t, err) require.Equal(t, len(sigs), 1) - require.Equal(t, sigs[0].PubKey.Bytes(), sig.GetPubKey().Bytes()) + require.Equal(t, cdc.Amino.MustMarshalBinaryBare(sigs[0].PubKey), cdc.Amino.MustMarshalBinaryBare(sig.GetPubKey())) require.Equal(t, sigs[0].Data, &signing.SingleSignatureData{ SignMode: signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, Signature: sig.GetSignature(), diff --git a/x/auth/types/txbuilder.go b/x/auth/types/txbuilder.go index 8fe98c92defd..58f3ad7a3419 100644 --- a/x/auth/types/txbuilder.go +++ b/x/auth/types/txbuilder.go @@ -12,6 +12,7 @@ import ( "github.com/spf13/viper" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/crypto/keyring" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -300,7 +301,7 @@ func MakeSignature(kr keyring.Keyring, name string, msg StdSignMsg) (sig StdSign } return StdSignature{ - PubKey: pubkey.Bytes(), + PubKey: legacy.Cdc.MustMarshalBinaryBare(pubkey), Signature: sigBytes, }, nil } diff --git a/x/bank/app_test.go b/x/bank/app_test.go index d99539e034b4..f2c2e62a1ca8 100644 --- a/x/bank/app_test.go +++ b/x/bank/app_test.go @@ -7,9 +7,9 @@ import ( distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/secp256k1" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -94,7 +94,7 @@ func TestSendNotEnoughBalance(t *testing.T) { genAccs := []authtypes.GenesisAccount{acc} app := simapp.SetupWithGenesisAccounts(genAccs) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) err := app.BankKeeper.SetBalances(ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 67))) require.NoError(t, err) @@ -109,14 +109,14 @@ func TestSendNotEnoughBalance(t *testing.T) { origSeq := res1.GetSequence() sendMsg := types.NewMsgSend(addr1, addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 100)}) - header := abci.Header{Height: app.LastBlockHeight() + 1} + header := tmproto.Header{Height: app.LastBlockHeight() + 1} txGen := simapp.MakeEncodingConfig().TxConfig _, _, err = simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, []sdk.Msg{sendMsg}, []uint64{origAccNum}, []uint64{origSeq}, false, false, priv1) require.Error(t, err) simapp.CheckBalance(t, app, addr1, sdk.Coins{sdk.NewInt64Coin("foocoin", 67)}) - res2 := app.AccountKeeper.GetAccount(app.NewContext(true, abci.Header{}), addr1) + res2 := app.AccountKeeper.GetAccount(app.NewContext(true, tmproto.Header{}), addr1) require.NotNil(t, res2) require.Equal(t, res2.GetAccountNumber(), origAccNum) @@ -163,7 +163,7 @@ func TestSendToModuleAcc(t *testing.T) { genAccs := []authtypes.GenesisAccount{acc} app := simapp.SetupWithGenesisAccounts(genAccs) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) err := app.BankKeeper.SetBalances(ctx, test.msg.FromAddress, test.fromBalance) require.NoError(t, err) @@ -177,7 +177,7 @@ func TestSendToModuleAcc(t *testing.T) { origAccNum := res1.GetAccountNumber() origSeq := res1.GetSequence() - header := abci.Header{Height: app.LastBlockHeight() + 1} + header := tmproto.Header{Height: app.LastBlockHeight() + 1} txGen := simapp.MakeEncodingConfig().TxConfig _, _, err = simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, []sdk.Msg{test.msg}, []uint64{origAccNum}, []uint64{origSeq}, test.expSimPass, test.expPass, priv1) if test.expPass { @@ -189,7 +189,7 @@ func TestSendToModuleAcc(t *testing.T) { simapp.CheckBalance(t, app, test.msg.FromAddress, test.expFromBalance) simapp.CheckBalance(t, app, test.msg.ToAddress, test.expToBalance) - res2 := app.AccountKeeper.GetAccount(app.NewContext(true, abci.Header{}), addr1) + res2 := app.AccountKeeper.GetAccount(app.NewContext(true, tmproto.Header{}), addr1) require.NotNil(t, res2) require.Equal(t, res2.GetAccountNumber(), origAccNum) @@ -205,7 +205,7 @@ func TestMsgMultiSendWithAccounts(t *testing.T) { genAccs := []authtypes.GenesisAccount{acc} app := simapp.SetupWithGenesisAccounts(genAccs) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) err := app.BankKeeper.SetBalances(ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 67))) require.NoError(t, err) @@ -248,7 +248,7 @@ func TestMsgMultiSendWithAccounts(t *testing.T) { } for _, tc := range testCases { - header := abci.Header{Height: app.LastBlockHeight() + 1} + header := tmproto.Header{Height: app.LastBlockHeight() + 1} txGen := simapp.MakeEncodingConfig().TxConfig _, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) if tc.expPass { @@ -273,7 +273,7 @@ func TestMsgMultiSendMultipleOut(t *testing.T) { genAccs := []authtypes.GenesisAccount{acc1, acc2} app := simapp.SetupWithGenesisAccounts(genAccs) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) err := app.BankKeeper.SetBalances(ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42))) require.NoError(t, err) @@ -300,7 +300,7 @@ func TestMsgMultiSendMultipleOut(t *testing.T) { } for _, tc := range testCases { - header := abci.Header{Height: app.LastBlockHeight() + 1} + header := tmproto.Header{Height: app.LastBlockHeight() + 1} txGen := simapp.MakeEncodingConfig().TxConfig _, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) require.NoError(t, err) @@ -324,7 +324,7 @@ func TestMsgMultiSendMultipleInOut(t *testing.T) { genAccs := []authtypes.GenesisAccount{acc1, acc2, acc4} app := simapp.SetupWithGenesisAccounts(genAccs) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) err := app.BankKeeper.SetBalances(ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42))) require.NoError(t, err) @@ -355,7 +355,7 @@ func TestMsgMultiSendMultipleInOut(t *testing.T) { } for _, tc := range testCases { - header := abci.Header{Height: app.LastBlockHeight() + 1} + header := tmproto.Header{Height: app.LastBlockHeight() + 1} txGen := simapp.MakeEncodingConfig().TxConfig _, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) require.NoError(t, err) @@ -374,7 +374,7 @@ func TestMsgMultiSendDependent(t *testing.T) { genAccs := []authtypes.GenesisAccount{acc1, acc2} app := simapp.SetupWithGenesisAccounts(genAccs) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) err = app.BankKeeper.SetBalances(ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42))) require.NoError(t, err) @@ -408,7 +408,7 @@ func TestMsgMultiSendDependent(t *testing.T) { } for _, tc := range testCases { - header := abci.Header{Height: app.LastBlockHeight() + 1} + header := tmproto.Header{Height: app.LastBlockHeight() + 1} txGen := simapp.MakeEncodingConfig().TxConfig _, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) require.NoError(t, err) diff --git a/x/bank/bench_test.go b/x/bank/bench_test.go index 67750d6b24c3..deb3f6dd1c6e 100644 --- a/x/bank/bench_test.go +++ b/x/bank/bench_test.go @@ -5,6 +5,7 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" @@ -25,7 +26,7 @@ func BenchmarkOneBankSendTxPerBlock(b *testing.B) { // construct genesis state genAccs := []types.GenesisAccount{&acc} benchmarkApp := simapp.SetupWithGenesisAccounts(genAccs) - ctx := benchmarkApp.BaseApp.NewContext(false, abci.Header{}) + ctx := benchmarkApp.BaseApp.NewContext(false, tmproto.Header{}) // some value conceivably higher than the benchmarks would ever go err := benchmarkApp.BankKeeper.SetBalances(ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 100000000000))) @@ -44,7 +45,7 @@ func BenchmarkOneBankSendTxPerBlock(b *testing.B) { // Run this with a profiler, so its easy to distinguish what time comes from // Committing, and what time comes from Check/Deliver Tx. for i := 0; i < b.N; i++ { - benchmarkApp.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: height}}) + benchmarkApp.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: height}}) _, _, err := benchmarkApp.Check(txs[i]) if err != nil { panic("something is broken in checking transaction") @@ -67,7 +68,7 @@ func BenchmarkOneBankMultiSendTxPerBlock(b *testing.B) { // Construct genesis state genAccs := []authtypes.GenesisAccount{&acc} benchmarkApp := simapp.SetupWithGenesisAccounts(genAccs) - ctx := benchmarkApp.BaseApp.NewContext(false, abci.Header{}) + ctx := benchmarkApp.BaseApp.NewContext(false, tmproto.Header{}) // some value conceivably higher than the benchmarks would ever go err := benchmarkApp.BankKeeper.SetBalances(ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 100000000000))) @@ -86,7 +87,7 @@ func BenchmarkOneBankMultiSendTxPerBlock(b *testing.B) { // Run this with a profiler, so its easy to distinguish what time comes from // Committing, and what time comes from Check/Deliver Tx. for i := 0; i < b.N; i++ { - benchmarkApp.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: height}}) + benchmarkApp.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: height}}) _, _, err := benchmarkApp.Check(txs[i]) if err != nil { panic("something is broken in checking transaction") diff --git a/x/bank/handler_test.go b/x/bank/handler_test.go index ef870e4213ec..e16e8590a14e 100644 --- a/x/bank/handler_test.go +++ b/x/bank/handler_test.go @@ -4,11 +4,10 @@ import ( "strings" "testing" - "github.com/cosmos/cosmos-sdk/testutil/testdata" - "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -16,7 +15,7 @@ import ( func TestInvalidMsg(t *testing.T) { h := NewHandler(nil) - res, err := h(sdk.NewContext(nil, abci.Header{}, false, nil), testdata.NewTestMsg()) + res, err := h(sdk.NewContext(nil, tmproto.Header{}, false, nil), testdata.NewTestMsg()) require.Error(t, err) require.Nil(t, res) diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index 2607166e8c81..cb6bdb626bcb 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/suite" abci "github.com/tendermint/tendermint/abci/types" - tmkv "github.com/tendermint/tendermint/libs/kv" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtime "github.com/tendermint/tendermint/types/time" "github.com/cosmos/cosmos-sdk/simapp" @@ -66,7 +66,7 @@ type IntegrationTestSuite struct { func (suite *IntegrationTestSuite) SetupTest() { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams()) app.BankKeeper.SetParams(ctx, types.DefaultParams()) @@ -90,7 +90,7 @@ func (suite *IntegrationTestSuite) TestSupply() { func (suite *IntegrationTestSuite) TestSupply_SendCoins() { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{Height: 1}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{Height: 1}) appCodec := app.AppCodec() // add module accounts to supply keeper @@ -153,7 +153,7 @@ func (suite *IntegrationTestSuite) TestSupply_SendCoins() { func (suite *IntegrationTestSuite) TestSupply_MintCoins() { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{Height: 1}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{Height: 1}) appCodec := app.AppCodec() // add module accounts to supply keeper @@ -207,7 +207,7 @@ func (suite *IntegrationTestSuite) TestSupply_MintCoins() { func (suite *IntegrationTestSuite) TestSupply_BurnCoins() { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{Height: 1}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{Height: 1}) appCodec, _ := simapp.MakeCodecs() // add module accounts to supply keeper @@ -401,7 +401,7 @@ func (suite *IntegrationTestSuite) TestSendCoins() { func (suite *IntegrationTestSuite) TestValidateBalance() { app, ctx := suite.app, suite.ctx now := tmtime.Now() - ctx = ctx.WithBlockHeader(abci.Header{Time: now}) + ctx = ctx.WithBlockHeader(tmproto.Header{Time: now}) endTime := now.Add(24 * time.Hour) addr1 := sdk.AccAddress([]byte("addr1")) @@ -527,27 +527,32 @@ func (suite *IntegrationTestSuite) TestMsgSendEvents() { event1 := sdk.Event{ Type: types.EventTypeTransfer, - Attributes: []tmkv.Pair{}, + Attributes: []abci.EventAttribute{}, } + event1.Attributes = append( event1.Attributes, - tmkv.Pair{Key: []byte(types.AttributeKeyRecipient), Value: []byte(addr2.String())}, + abci.EventAttribute{Key: []byte(types.AttributeKeyRecipient), Value: []byte(addr2.String()), Index: true}, ) + event1.Attributes = append( event1.Attributes, - tmkv.Pair{Key: []byte(types.AttributeKeySender), Value: []byte(addr.String())}, + abci.EventAttribute{Key: []byte(sdk.AttributeKeySender), Value: []byte(addr.String()), Index: true}, ) + event1.Attributes = append( event1.Attributes, - tmkv.Pair{Key: []byte(sdk.AttributeKeyAmount), Value: []byte(newCoins.String())}, + abci.EventAttribute{Key: []byte(sdk.AttributeKeyAmount), Value: []byte(newCoins.String()), Index: true}, ) + event2 := sdk.Event{ Type: sdk.EventTypeMessage, - Attributes: []tmkv.Pair{}, + Attributes: []abci.EventAttribute{}, } + event2.Attributes = append( event2.Attributes, - tmkv.Pair{Key: []byte(types.AttributeKeySender), Value: []byte(addr.String())}, + abci.EventAttribute{Key: []byte(types.AttributeKeySender), Value: []byte(addr.String()), Index: true}, ) suite.Require().Equal(abci.Event(event1), events[0]) @@ -605,11 +610,11 @@ func (suite *IntegrationTestSuite) TestMsgMultiSendEvents() { event1 := sdk.Event{ Type: sdk.EventTypeMessage, - Attributes: []tmkv.Pair{}, + Attributes: []abci.EventAttribute{}, } event1.Attributes = append( event1.Attributes, - tmkv.Pair{Key: []byte(types.AttributeKeySender), Value: []byte(addr.String())}, + abci.EventAttribute{Key: []byte(types.AttributeKeySender), Value: []byte(addr.String()), Index: true}, ) suite.Require().Equal(abci.Event(event1), events[0]) @@ -627,34 +632,34 @@ func (suite *IntegrationTestSuite) TestMsgMultiSendEvents() { event2 := sdk.Event{ Type: sdk.EventTypeMessage, - Attributes: []tmkv.Pair{}, + Attributes: []abci.EventAttribute{}, } event2.Attributes = append( event2.Attributes, - tmkv.Pair{Key: []byte(types.AttributeKeySender), Value: []byte(addr2.String())}, + abci.EventAttribute{Key: []byte(types.AttributeKeySender), Value: []byte(addr2.String()), Index: true}, ) event3 := sdk.Event{ Type: types.EventTypeTransfer, - Attributes: []tmkv.Pair{}, + Attributes: []abci.EventAttribute{}, } event3.Attributes = append( event3.Attributes, - tmkv.Pair{Key: []byte(types.AttributeKeyRecipient), Value: []byte(addr3.String())}, + abci.EventAttribute{Key: []byte(types.AttributeKeyRecipient), Value: []byte(addr3.String()), Index: true}, ) event3.Attributes = append( event3.Attributes, - tmkv.Pair{Key: []byte(sdk.AttributeKeyAmount), Value: []byte(newCoins.String())}) + abci.EventAttribute{Key: []byte(sdk.AttributeKeyAmount), Value: []byte(newCoins.String()), Index: true}) event4 := sdk.Event{ Type: types.EventTypeTransfer, - Attributes: []tmkv.Pair{}, + Attributes: []abci.EventAttribute{}, } event4.Attributes = append( event4.Attributes, - tmkv.Pair{Key: []byte(types.AttributeKeyRecipient), Value: []byte(addr4.String())}, + abci.EventAttribute{Key: []byte(types.AttributeKeyRecipient), Value: []byte(addr4.String()), Index: true}, ) event4.Attributes = append( event4.Attributes, - tmkv.Pair{Key: []byte(sdk.AttributeKeyAmount), Value: []byte(newCoins2.String())}, + abci.EventAttribute{Key: []byte(sdk.AttributeKeyAmount), Value: []byte(newCoins2.String()), Index: true}, ) suite.Require().Equal(abci.Event(event1), events[1]) @@ -666,7 +671,7 @@ func (suite *IntegrationTestSuite) TestMsgMultiSendEvents() { func (suite *IntegrationTestSuite) TestSpendableCoins() { app, ctx := suite.app, suite.ctx now := tmtime.Now() - ctx = ctx.WithBlockHeader(abci.Header{Time: now}) + ctx = ctx.WithBlockHeader(tmproto.Header{Time: now}) endTime := now.Add(24 * time.Hour) origCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 100)) @@ -697,7 +702,7 @@ func (suite *IntegrationTestSuite) TestSpendableCoins() { func (suite *IntegrationTestSuite) TestVestingAccountSend() { app, ctx := suite.app, suite.ctx now := tmtime.Now() - ctx = ctx.WithBlockHeader(abci.Header{Time: now}) + ctx = ctx.WithBlockHeader(tmproto.Header{Time: now}) endTime := now.Add(24 * time.Hour) origCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 100)) @@ -727,7 +732,7 @@ func (suite *IntegrationTestSuite) TestVestingAccountSend() { func (suite *IntegrationTestSuite) TestPeriodicVestingAccountSend() { app, ctx := suite.app, suite.ctx now := tmtime.Now() - ctx = ctx.WithBlockHeader(abci.Header{Time: now}) + ctx = ctx.WithBlockHeader(tmproto.Header{Time: now}) origCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 100)) sendCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 50)) @@ -760,7 +765,7 @@ func (suite *IntegrationTestSuite) TestPeriodicVestingAccountSend() { func (suite *IntegrationTestSuite) TestVestingAccountReceive() { app, ctx := suite.app, suite.ctx now := tmtime.Now() - ctx = ctx.WithBlockHeader(abci.Header{Time: now}) + ctx = ctx.WithBlockHeader(tmproto.Header{Time: now}) endTime := now.Add(24 * time.Hour) origCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 100)) @@ -794,7 +799,7 @@ func (suite *IntegrationTestSuite) TestVestingAccountReceive() { func (suite *IntegrationTestSuite) TestPeriodicVestingAccountReceive() { app, ctx := suite.app, suite.ctx now := tmtime.Now() - ctx = ctx.WithBlockHeader(abci.Header{Time: now}) + ctx = ctx.WithBlockHeader(tmproto.Header{Time: now}) origCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 100)) sendCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 50)) @@ -833,7 +838,7 @@ func (suite *IntegrationTestSuite) TestPeriodicVestingAccountReceive() { func (suite *IntegrationTestSuite) TestDelegateCoins() { app, ctx := suite.app, suite.ctx now := tmtime.Now() - ctx = ctx.WithBlockHeader(abci.Header{Time: now}) + ctx = ctx.WithBlockHeader(tmproto.Header{Time: now}) endTime := now.Add(24 * time.Hour) origCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 100)) @@ -893,7 +898,7 @@ func (suite *IntegrationTestSuite) TestDelegateCoins_Invalid() { func (suite *IntegrationTestSuite) TestUndelegateCoins() { app, ctx := suite.app, suite.ctx now := tmtime.Now() - ctx = ctx.WithBlockHeader(abci.Header{Time: now}) + ctx = ctx.WithBlockHeader(tmproto.Header{Time: now}) endTime := now.Add(24 * time.Hour) origCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 100)) diff --git a/x/bank/simulation/decoder.go b/x/bank/simulation/decoder.go index 9ae45c7a223f..944606961032 100644 --- a/x/bank/simulation/decoder.go +++ b/x/bank/simulation/decoder.go @@ -4,10 +4,8 @@ import ( "bytes" "fmt" + "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/x/bank/exported" - - tmkv "github.com/tendermint/tendermint/libs/kv" - "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -17,8 +15,8 @@ type SupplyUnmarshaller interface { // NewDecodeStore returns a function closure that unmarshals the KVPair's values // to the corresponding types. -func NewDecodeStore(cdc SupplyUnmarshaller) func(kvA, kvB tmkv.Pair) string { - return func(kvA, kvB tmkv.Pair) string { +func NewDecodeStore(cdc SupplyUnmarshaller) func(kvA, kvB kv.Pair) string { + return func(kvA, kvB kv.Pair) string { switch { case bytes.Equal(kvA.Key[:1], types.SupplyKey): supplyA, err := cdc.UnmarshalSupply(kvA.Value) diff --git a/x/bank/simulation/decoder_test.go b/x/bank/simulation/decoder_test.go index 8b3e89c6e519..d68e273bf2a2 100644 --- a/x/bank/simulation/decoder_test.go +++ b/x/bank/simulation/decoder_test.go @@ -5,10 +5,10 @@ import ( "testing" "github.com/stretchr/testify/require" - tmkv "github.com/tendermint/tendermint/libs/kv" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/x/bank/simulation" "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -22,9 +22,9 @@ func TestDecodeStore(t *testing.T) { supplyBz, err := app.BankKeeper.MarshalSupply(totalSupply) require.NoError(t, err) - kvPairs := tmkv.Pairs{ - tmkv.Pair{Key: types.SupplyKey, Value: supplyBz}, - tmkv.Pair{Key: []byte{0x99}, Value: []byte{0x99}}, + kvPairs := kv.Pairs{ + kv.Pair{Key: types.SupplyKey, Value: supplyBz}, + kv.Pair{Key: []byte{0x99}, Value: []byte{0x99}}, } tests := []struct { diff --git a/x/bank/simulation/operations_test.go b/x/bank/simulation/operations_test.go index 2718dde50092..486ea1ca0bf1 100644 --- a/x/bank/simulation/operations_test.go +++ b/x/bank/simulation/operations_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/suite" abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" @@ -26,7 +27,7 @@ func (suite *SimTestSuite) SetupTest() { checkTx := false app := simapp.Setup(checkTx) suite.app = app - suite.ctx = app.BaseApp.NewContext(checkTx, abci.Header{}) + suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{}) } // TestWeightedOperations tests the weights of the operations. @@ -70,7 +71,7 @@ func (suite *SimTestSuite) TestSimulateMsgSend() { accounts := suite.getTestingAccounts(r, 3) // begin a new block - suite.app.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: suite.app.LastBlockHeight() + 1, AppHash: suite.app.LastCommitID().Hash}}) + suite.app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: suite.app.LastBlockHeight() + 1, AppHash: suite.app.LastCommitID().Hash}}) // execute operation op := simulation.SimulateMsgSend(suite.app.AccountKeeper, suite.app.BankKeeper) @@ -98,7 +99,7 @@ func (suite *SimTestSuite) TestSimulateMsgMultiSend() { accounts := suite.getTestingAccounts(r, 3) // begin a new block - suite.app.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: suite.app.LastBlockHeight() + 1, AppHash: suite.app.LastCommitID().Hash}}) + suite.app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: suite.app.LastBlockHeight() + 1, AppHash: suite.app.LastCommitID().Hash}}) // execute operation op := simulation.SimulateMsgMultiSend(suite.app.AccountKeeper, suite.app.BankKeeper) diff --git a/x/capability/keeper/keeper_test.go b/x/capability/keeper/keeper_test.go index a09c704b7f28..fdd795341010 100644 --- a/x/capability/keeper/keeper_test.go +++ b/x/capability/keeper/keeper_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/stretchr/testify/suite" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -32,7 +32,7 @@ func (suite *KeeperTestSuite) SetupTest() { keeper := keeper.NewKeeper(cdc, app.GetKey(types.StoreKey), app.GetMemKey(types.MemStoreKey)) suite.app = app - suite.ctx = app.BaseApp.NewContext(checkTx, abci.Header{Height: 1}) + suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 1}) suite.keeper = keeper } diff --git a/x/capability/simulation/decoder.go b/x/capability/simulation/decoder.go index 8980efd570f9..40fe458f83d5 100644 --- a/x/capability/simulation/decoder.go +++ b/x/capability/simulation/decoder.go @@ -4,17 +4,16 @@ import ( "bytes" "fmt" - tmkv "github.com/tendermint/tendermint/libs/kv" - "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" + kv "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/x/capability/types" ) // NewDecodeStore returns a decoder function closure that unmarshals the KVPair's // Value to the corresponding capaility type. -func NewDecodeStore(cdc codec.Marshaler) func(kvA, kvB tmkv.Pair) string { - return func(kvA, kvB tmkv.Pair) string { +func NewDecodeStore(cdc codec.Marshaler) func(kvA, kvB kv.Pair) string { + return func(kvA, kvB kv.Pair) string { switch { case bytes.Equal(kvA.Key, types.KeyIndex): idxA := sdk.BigEndianToUint64(kvA.Value) diff --git a/x/capability/simulation/decoder_test.go b/x/capability/simulation/decoder_test.go index 8f10e9085421..e7993eb884e6 100644 --- a/x/capability/simulation/decoder_test.go +++ b/x/capability/simulation/decoder_test.go @@ -5,10 +5,10 @@ import ( "testing" "github.com/stretchr/testify/require" - tmkv "github.com/tendermint/tendermint/libs/kv" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/x/capability/simulation" "github.com/cosmos/cosmos-sdk/x/capability/types" ) @@ -21,16 +21,16 @@ func TestDecodeStore(t *testing.T) { Owners: []types.Owner{{Module: "transfer", Name: "ports/transfer"}}, } - kvPairs := tmkv.Pairs{ - tmkv.Pair{ + kvPairs := kv.Pairs{ + kv.Pair{ Key: types.KeyIndex, Value: sdk.Uint64ToBigEndian(10), }, - tmkv.Pair{ + kv.Pair{ Key: types.KeyPrefixIndexCapability, Value: cdc.MustMarshalBinaryBare(&capOwners), }, - tmkv.Pair{ + kv.Pair{ Key: []byte{0x99}, Value: []byte{0x99}, }, diff --git a/x/crisis/handler_test.go b/x/crisis/handler_test.go index bd2752704e02..828ba9063db3 100644 --- a/x/crisis/handler_test.go +++ b/x/crisis/handler_test.go @@ -7,8 +7,8 @@ import ( "github.com/cosmos/cosmos-sdk/testutil/testdata" "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/simapp" @@ -29,7 +29,7 @@ var ( func createTestApp() (*simapp.SimApp, sdk.Context, []sdk.AccAddress) { db := dbm.NewMemDB() app := simapp.NewSimApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, simapp.DefaultNodeHome, 1) - ctx := app.NewContext(true, abci.Header{}) + ctx := app.NewContext(true, tmproto.Header{}) constantFee := sdk.NewInt64Coin(sdk.DefaultBondDenom, 10) app.CrisisKeeper.SetConstantFee(ctx, constantFee) diff --git a/x/crisis/keeper/keeper_test.go b/x/crisis/keeper/keeper_test.go index c3837d2ca600..563c0e4b1096 100644 --- a/x/crisis/keeper/keeper_test.go +++ b/x/crisis/keeper/keeper_test.go @@ -5,6 +5,7 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -13,14 +14,14 @@ import ( func TestLogger(t *testing.T) { app := simapp.Setup(false) - ctx := app.NewContext(true, abci.Header{}) + ctx := app.NewContext(true, tmproto.Header{}) require.Equal(t, ctx.Logger(), app.CrisisKeeper.Logger(ctx)) } func TestInvariants(t *testing.T) { app := simapp.Setup(false) app.Commit() - app.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: app.LastBlockHeight() + 1}}) + app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1}}) require.Equal(t, app.CrisisKeeper.InvCheckPeriod(), uint(5)) @@ -33,9 +34,9 @@ func TestInvariants(t *testing.T) { func TestAssertInvariants(t *testing.T) { app := simapp.Setup(false) app.Commit() - app.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: app.LastBlockHeight() + 1}}) + app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1}}) - ctx := app.NewContext(true, abci.Header{}) + ctx := app.NewContext(true, tmproto.Header{}) app.CrisisKeeper.RegisterRoute("testModule", "testRoute1", func(sdk.Context) (string, bool) { return "", false }) require.NotPanics(t, func() { app.CrisisKeeper.AssertInvariants(ctx) }) diff --git a/x/distribution/keeper/allocation_test.go b/x/distribution/keeper/allocation_test.go index 726498c60c6d..044146732a6f 100644 --- a/x/distribution/keeper/allocation_test.go +++ b/x/distribution/keeper/allocation_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -16,7 +17,7 @@ import ( func TestAllocateTokensToValidatorWithCommission(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs := simapp.AddTestAddrs(app, ctx, 3, sdk.NewInt(1234)) valAddrs := simapp.ConvertAddrsToValAddrs(addrs) @@ -54,7 +55,7 @@ func TestAllocateTokensToValidatorWithCommission(t *testing.T) { func TestAllocateTokensToManyValidators(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) sh := staking.NewHandler(app.StakingKeeper) addrs := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1234)) @@ -134,7 +135,7 @@ func TestAllocateTokensToManyValidators(t *testing.T) { func TestAllocateTokensTruncation(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs := simapp.AddTestAddrs(app, ctx, 3, sdk.NewInt(1234)) valAddrs := simapp.ConvertAddrsToValAddrs(addrs) diff --git a/x/distribution/keeper/delegation_test.go b/x/distribution/keeper/delegation_test.go index 8b66b58bb914..44135ce10ff5 100644 --- a/x/distribution/keeper/delegation_test.go +++ b/x/distribution/keeper/delegation_test.go @@ -3,9 +3,8 @@ package keeper_test import ( "testing" - abci "github.com/tendermint/tendermint/abci/types" - "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -15,7 +14,7 @@ import ( func TestCalculateRewardsBasic(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) sh := staking.NewHandler(app.StakingKeeper) @@ -77,7 +76,7 @@ func TestCalculateRewardsBasic(t *testing.T) { func TestCalculateRewardsAfterSlash(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(100000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) @@ -147,7 +146,7 @@ func TestCalculateRewardsAfterSlash(t *testing.T) { func TestCalculateRewardsAfterManySlashes(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) sh := staking.NewHandler(app.StakingKeeper) addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(100000000)) @@ -228,7 +227,7 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) { func TestCalculateRewardsMultiDelegator(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) sh := staking.NewHandler(app.StakingKeeper) @@ -303,7 +302,7 @@ func TestWithdrawDelegationRewardsBasic(t *testing.T) { balancePower := int64(1000) balanceTokens := sdk.TokensFromConsensusPower(balancePower) app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addr := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(1000000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) @@ -382,7 +381,7 @@ func TestWithdrawDelegationRewardsBasic(t *testing.T) { func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addr := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(1000000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) @@ -457,7 +456,7 @@ func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) { func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) sh := staking.NewHandler(app.StakingKeeper) addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1000000000)) @@ -543,7 +542,7 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) { func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) sh := staking.NewHandler(app.StakingKeeper) diff --git a/x/distribution/keeper/grpc_query_test.go b/x/distribution/keeper/grpc_query_test.go index f5b48c775090..f6d4406f1a8b 100644 --- a/x/distribution/keeper/grpc_query_test.go +++ b/x/distribution/keeper/grpc_query_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/stretchr/testify/suite" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/simapp" @@ -29,7 +29,7 @@ type KeeperTestSuite struct { func (suite *KeeperTestSuite) SetupTest() { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry()) types.RegisterQueryServer(queryHelper, app.DistrKeeper) diff --git a/x/distribution/keeper/keeper_test.go b/x/distribution/keeper/keeper_test.go index 4829bd33be5e..a8205dfdc1db 100644 --- a/x/distribution/keeper/keeper_test.go +++ b/x/distribution/keeper/keeper_test.go @@ -5,8 +5,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -15,7 +14,7 @@ import ( func TestSetWithdrawAddr(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1000000000)) @@ -37,7 +36,7 @@ func TestSetWithdrawAddr(t *testing.T) { func TestWithdrawValidatorCommission(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) valCommission := sdk.DecCoins{ sdk.NewDecCoinFromDec("mytoken", sdk.NewDec(5).Quo(sdk.NewDec(4))), @@ -91,7 +90,7 @@ func TestWithdrawValidatorCommission(t *testing.T) { func TestGetTotalRewards(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) valCommission := sdk.DecCoins{ sdk.NewDecCoinFromDec("mytoken", sdk.NewDec(5).Quo(sdk.NewDec(4))), @@ -112,7 +111,7 @@ func TestGetTotalRewards(t *testing.T) { func TestFundCommunityPool(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1000000000)) diff --git a/x/distribution/keeper/querier_test.go b/x/distribution/keeper/querier_test.go index 5934af6a1b73..ca78d9f03329 100644 --- a/x/distribution/keeper/querier_test.go +++ b/x/distribution/keeper/querier_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/simapp" @@ -116,7 +117,7 @@ func TestQueries(t *testing.T) { legacyQuerierCdc := codec.NewAminoCodec(cdc) app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addr := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(1000000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addr) diff --git a/x/distribution/module_test.go b/x/distribution/module_test.go index f9c1cb2ce415..113622d208e9 100644 --- a/x/distribution/module_test.go +++ b/x/distribution/module_test.go @@ -5,6 +5,7 @@ import ( "github.com/stretchr/testify/require" abcitypes "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -13,7 +14,7 @@ import ( func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abcitypes.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) app.InitChain( abcitypes.RequestInitChain{ diff --git a/x/distribution/proposal_handler_test.go b/x/distribution/proposal_handler_test.go index d8b21928b8c4..34e99fb27bd3 100644 --- a/x/distribution/proposal_handler_test.go +++ b/x/distribution/proposal_handler_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto/ed25519" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -26,7 +26,7 @@ func testProposal(recipient sdk.AccAddress, amount sdk.Coins) *types.CommunityPo func TestProposalHandlerPassed(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) recipient := delAddr1 @@ -56,7 +56,7 @@ func TestProposalHandlerPassed(t *testing.T) { func TestProposalHandlerFailed(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) recipient := delAddr1 diff --git a/x/distribution/simulation/decoder.go b/x/distribution/simulation/decoder.go index 0d5f6dba568e..a2be7dc188bf 100644 --- a/x/distribution/simulation/decoder.go +++ b/x/distribution/simulation/decoder.go @@ -4,17 +4,16 @@ import ( "bytes" "fmt" - tmkv "github.com/tendermint/tendermint/libs/kv" - "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/x/distribution/types" ) // NewDecodeStore returns a decoder function closure that unmarshals the KVPair's // Value to the corresponding distribution type. -func NewDecodeStore(cdc codec.Marshaler) func(kvA, kvB tmkv.Pair) string { - return func(kvA, kvB tmkv.Pair) string { +func NewDecodeStore(cdc codec.Marshaler) func(kvA, kvB kv.Pair) string { + return func(kvA, kvB kv.Pair) string { switch { case bytes.Equal(kvA.Key[:1], types.FeePoolKey): var feePoolA, feePoolB types.FeePool diff --git a/x/distribution/simulation/decoder_test.go b/x/distribution/simulation/decoder_test.go index 7fddb1625c7b..6db0038f83fe 100644 --- a/x/distribution/simulation/decoder_test.go +++ b/x/distribution/simulation/decoder_test.go @@ -6,8 +6,8 @@ import ( "github.com/stretchr/testify/require" + "github.com/cosmos/cosmos-sdk/types/kv" "github.com/tendermint/tendermint/crypto/ed25519" - tmkv "github.com/tendermint/tendermint/libs/kv" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -36,17 +36,17 @@ func TestDecodeDistributionStore(t *testing.T) { currentRewards := types.NewValidatorCurrentRewards(decCoins, 5) slashEvent := types.NewValidatorSlashEvent(10, sdk.OneDec()) - kvPairs := tmkv.Pairs{ - tmkv.Pair{Key: types.FeePoolKey, Value: cdc.MustMarshalBinaryBare(&feePool)}, - tmkv.Pair{Key: types.ProposerKey, Value: consAddr1.Bytes()}, - tmkv.Pair{Key: types.GetValidatorOutstandingRewardsKey(valAddr1), Value: cdc.MustMarshalBinaryBare(&outstanding)}, - tmkv.Pair{Key: types.GetDelegatorWithdrawAddrKey(delAddr1), Value: delAddr1.Bytes()}, - tmkv.Pair{Key: types.GetDelegatorStartingInfoKey(valAddr1, delAddr1), Value: cdc.MustMarshalBinaryBare(&info)}, - tmkv.Pair{Key: types.GetValidatorHistoricalRewardsKey(valAddr1, 100), Value: cdc.MustMarshalBinaryBare(&historicalRewards)}, - tmkv.Pair{Key: types.GetValidatorCurrentRewardsKey(valAddr1), Value: cdc.MustMarshalBinaryBare(¤tRewards)}, - tmkv.Pair{Key: types.GetValidatorAccumulatedCommissionKey(valAddr1), Value: cdc.MustMarshalBinaryBare(&commission)}, - tmkv.Pair{Key: types.GetValidatorSlashEventKeyPrefix(valAddr1, 13), Value: cdc.MustMarshalBinaryBare(&slashEvent)}, - tmkv.Pair{Key: []byte{0x99}, Value: []byte{0x99}}, + kvPairs := kv.Pairs{ + kv.Pair{Key: types.FeePoolKey, Value: cdc.MustMarshalBinaryBare(&feePool)}, + kv.Pair{Key: types.ProposerKey, Value: consAddr1.Bytes()}, + kv.Pair{Key: types.GetValidatorOutstandingRewardsKey(valAddr1), Value: cdc.MustMarshalBinaryBare(&outstanding)}, + kv.Pair{Key: types.GetDelegatorWithdrawAddrKey(delAddr1), Value: delAddr1.Bytes()}, + kv.Pair{Key: types.GetDelegatorStartingInfoKey(valAddr1, delAddr1), Value: cdc.MustMarshalBinaryBare(&info)}, + kv.Pair{Key: types.GetValidatorHistoricalRewardsKey(valAddr1, 100), Value: cdc.MustMarshalBinaryBare(&historicalRewards)}, + kv.Pair{Key: types.GetValidatorCurrentRewardsKey(valAddr1), Value: cdc.MustMarshalBinaryBare(¤tRewards)}, + kv.Pair{Key: types.GetValidatorAccumulatedCommissionKey(valAddr1), Value: cdc.MustMarshalBinaryBare(&commission)}, + kv.Pair{Key: types.GetValidatorSlashEventKeyPrefix(valAddr1, 13), Value: cdc.MustMarshalBinaryBare(&slashEvent)}, + kv.Pair{Key: []byte{0x99}, Value: []byte{0x99}}, } tests := []struct { diff --git a/x/distribution/simulation/operations_test.go b/x/distribution/simulation/operations_test.go index f7aa17019794..d721cb382e4f 100644 --- a/x/distribution/simulation/operations_test.go +++ b/x/distribution/simulation/operations_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/suite" abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" @@ -64,7 +65,7 @@ func (suite *SimTestSuite) TestSimulateMsgSetWithdrawAddress() { accounts := suite.getTestingAccounts(r, 3) // begin a new block - suite.app.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: suite.app.LastBlockHeight() + 1, AppHash: suite.app.LastCommitID().Hash}}) + suite.app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: suite.app.LastBlockHeight() + 1, AppHash: suite.app.LastCommitID().Hash}}) // execute operation op := simulation.SimulateMsgSetWithdrawAddress(suite.app.AccountKeeper, suite.app.BankKeeper, suite.app.DistrKeeper) @@ -105,7 +106,7 @@ func (suite *SimTestSuite) TestSimulateMsgWithdrawDelegatorReward() { suite.setupValidatorRewards(validator0.OperatorAddress) // begin a new block - suite.app.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: suite.app.LastBlockHeight() + 1, AppHash: suite.app.LastCommitID().Hash}}) + suite.app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: suite.app.LastBlockHeight() + 1, AppHash: suite.app.LastCommitID().Hash}}) // execute operation op := simulation.SimulateMsgWithdrawDelegatorReward(suite.app.AccountKeeper, suite.app.BankKeeper, suite.app.DistrKeeper, suite.app.StakingKeeper) @@ -163,7 +164,7 @@ func (suite *SimTestSuite) testSimulateMsgWithdrawValidatorCommission(tokenName suite.app.DistrKeeper.SetValidatorAccumulatedCommission(suite.ctx, validator0.OperatorAddress, types.ValidatorAccumulatedCommission{Commission: valCommission}) // begin a new block - suite.app.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: suite.app.LastBlockHeight() + 1, AppHash: suite.app.LastCommitID().Hash}}) + suite.app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: suite.app.LastBlockHeight() + 1, AppHash: suite.app.LastCommitID().Hash}}) // execute operation op := simulation.SimulateMsgWithdrawValidatorCommission(suite.app.AccountKeeper, suite.app.BankKeeper, suite.app.DistrKeeper, suite.app.StakingKeeper) @@ -189,7 +190,7 @@ func (suite *SimTestSuite) TestSimulateMsgFundCommunityPool() { accounts := suite.getTestingAccounts(r, 3) // begin a new block - suite.app.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: suite.app.LastBlockHeight() + 1, AppHash: suite.app.LastCommitID().Hash}}) + suite.app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: suite.app.LastBlockHeight() + 1, AppHash: suite.app.LastCommitID().Hash}}) // execute operation op := simulation.SimulateMsgFundCommunityPool(suite.app.AccountKeeper, suite.app.BankKeeper, suite.app.DistrKeeper, suite.app.StakingKeeper) @@ -218,7 +219,7 @@ func (suite *SimTestSuite) SetupTest() { checkTx := false app := simapp.Setup(checkTx) suite.app = app - suite.ctx = app.BaseApp.NewContext(checkTx, abci.Header{}) + suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{}) } func (suite *SimTestSuite) getTestingAccounts(r *rand.Rand, n int) []simtypes.Account { diff --git a/x/distribution/simulation/proposals_test.go b/x/distribution/simulation/proposals_test.go index f49293fe8dfc..6d5895ea8dfd 100644 --- a/x/distribution/simulation/proposals_test.go +++ b/x/distribution/simulation/proposals_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" @@ -16,7 +16,7 @@ import ( func TestProposalContents(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) // initialize parameters s := rand.NewSource(1) diff --git a/x/evidence/genesis_test.go b/x/evidence/genesis_test.go index 381321224072..c09bc9d95e7b 100644 --- a/x/evidence/genesis_test.go +++ b/x/evidence/genesis_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/stretchr/testify/suite" - abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto/ed25519" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/tendermint/tendermint/types/time" "github.com/cosmos/cosmos-sdk/simapp" @@ -27,7 +27,7 @@ func (suite *GenesisTestSuite) SetupTest() { checkTx := false app := simapp.Setup(checkTx) - suite.ctx = app.BaseApp.NewContext(checkTx, abci.Header{Height: 1}) + suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 1}) suite.keeper = app.EvidenceKeeper } diff --git a/x/evidence/handler_test.go b/x/evidence/handler_test.go index 1318b8027b01..1d5388b7c88e 100644 --- a/x/evidence/handler_test.go +++ b/x/evidence/handler_test.go @@ -7,8 +7,8 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto/ed25519" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -104,7 +104,7 @@ func (suite *HandlerTestSuite) TestMsgSubmitEvidence() { } for i, tc := range testCases { - ctx := suite.app.BaseApp.NewContext(false, abci.Header{Height: suite.app.LastBlockHeight() + 1}) + ctx := suite.app.BaseApp.NewContext(false, tmproto.Header{Height: suite.app.LastBlockHeight() + 1}) res, err := suite.handler(ctx, tc.msg) if tc.expectErr { diff --git a/x/evidence/keeper/keeper_test.go b/x/evidence/keeper/keeper_test.go index 1aaaca5f38dc..58dcd25c3d25 100644 --- a/x/evidence/keeper/keeper_test.go +++ b/x/evidence/keeper/keeper_test.go @@ -6,9 +6,13 @@ import ( "testing" "time" - "github.com/cosmos/cosmos-sdk/codec" + "github.com/stretchr/testify/suite" + "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/ed25519" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -16,11 +20,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/evidence/exported" "github.com/cosmos/cosmos-sdk/x/evidence/keeper" "github.com/cosmos/cosmos-sdk/x/evidence/types" - - "github.com/stretchr/testify/suite" - abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/ed25519" ) var ( @@ -46,8 +45,8 @@ func newPubKey(pk string) (res crypto.PubKey) { panic(err) } - var pubkey ed25519.PubKeyEd25519 - copy(pubkey[:], pkBytes) + pubkey := make(ed25519.PubKey, ed25519.PubKeySize) + copy(pubkey, pkBytes) return pubkey } @@ -95,7 +94,7 @@ func (suite *KeeperTestSuite) SetupTest() { app.EvidenceKeeper = *evidenceKeeper - suite.ctx = app.BaseApp.NewContext(checkTx, abci.Header{Height: 1}) + suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 1}) suite.querier = keeper.NewQuerier(*evidenceKeeper, legacyQuerierCdc) suite.app = app diff --git a/x/evidence/simulation/decoder.go b/x/evidence/simulation/decoder.go index dd5becbbbdef..d8c185fd0488 100644 --- a/x/evidence/simulation/decoder.go +++ b/x/evidence/simulation/decoder.go @@ -4,10 +4,8 @@ import ( "bytes" "fmt" + "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/x/evidence/exported" - - tmkv "github.com/tendermint/tendermint/libs/kv" - "github.com/cosmos/cosmos-sdk/x/evidence/types" ) @@ -17,8 +15,8 @@ type EvidenceUnmarshaler interface { // NewDecodeStore returns a decoder function closure that unmarshals the KVPair's // Value to the corresponding evidence type. -func NewDecodeStore(cdc EvidenceUnmarshaler) func(kvA, kvB tmkv.Pair) string { - return func(kvA, kvB tmkv.Pair) string { +func NewDecodeStore(cdc EvidenceUnmarshaler) func(kvA, kvB kv.Pair) string { + return func(kvA, kvB kv.Pair) string { switch { case bytes.Equal(kvA.Key[:1], types.KeyPrefixEvidence): evidenceA, err := cdc.UnmarshalEvidence(kvA.Value) diff --git a/x/evidence/simulation/decoder_test.go b/x/evidence/simulation/decoder_test.go index bdfee6246895..ff19278436dd 100644 --- a/x/evidence/simulation/decoder_test.go +++ b/x/evidence/simulation/decoder_test.go @@ -7,10 +7,10 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto/ed25519" - tmkv "github.com/tendermint/tendermint/libs/kv" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/x/evidence/simulation" "github.com/cosmos/cosmos-sdk/x/evidence/types" ) @@ -31,12 +31,12 @@ func TestDecodeStore(t *testing.T) { evBz, err := app.EvidenceKeeper.MarshalEvidence(ev) require.NoError(t, err) - kvPairs := tmkv.Pairs{ - tmkv.Pair{ + kvPairs := kv.Pairs{ + kv.Pair{ Key: types.KeyPrefixEvidence, Value: evBz, }, - tmkv.Pair{ + kv.Pair{ Key: []byte{0x99}, Value: []byte{0x99}, }, diff --git a/x/gov/abci_test.go b/x/gov/abci_test.go index 79655c5a06fe..5b24b58c9055 100644 --- a/x/gov/abci_test.go +++ b/x/gov/abci_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -16,10 +17,10 @@ import ( func TestTickExpiredDepositPeriod(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs := simapp.AddTestAddrs(app, ctx, 10, valTokens) - header := abci.Header{Height: app.LastBlockHeight() + 1} + header := tmproto.Header{Height: app.LastBlockHeight() + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) govHandler := gov.NewHandler(app.GovKeeper) @@ -68,10 +69,10 @@ func TestTickExpiredDepositPeriod(t *testing.T) { func TestTickMultipleExpiredDepositPeriod(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs := simapp.AddTestAddrs(app, ctx, 10, valTokens) - header := abci.Header{Height: app.LastBlockHeight() + 1} + header := tmproto.Header{Height: app.LastBlockHeight() + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) govHandler := gov.NewHandler(app.GovKeeper) @@ -145,10 +146,10 @@ func TestTickMultipleExpiredDepositPeriod(t *testing.T) { func TestTickPassedDepositPeriod(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs := simapp.AddTestAddrs(app, ctx, 10, valTokens) - header := abci.Header{Height: app.LastBlockHeight() + 1} + header := tmproto.Header{Height: app.LastBlockHeight() + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) govHandler := gov.NewHandler(app.GovKeeper) @@ -198,12 +199,12 @@ func TestTickPassedDepositPeriod(t *testing.T) { func TestTickPassedVotingPeriod(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs := simapp.AddTestAddrs(app, ctx, 10, valTokens) SortAddresses(addrs) - header := abci.Header{Height: app.LastBlockHeight() + 1} + header := tmproto.Header{Height: app.LastBlockHeight() + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) govHandler := gov.NewHandler(app.GovKeeper) @@ -262,7 +263,7 @@ func TestTickPassedVotingPeriod(t *testing.T) { func TestProposalPassedEndblocker(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs := simapp.AddTestAddrs(app, ctx, 10, valTokens) SortAddresses(addrs) @@ -270,7 +271,7 @@ func TestProposalPassedEndblocker(t *testing.T) { handler := gov.NewHandler(app.GovKeeper) stakingHandler := staking.NewHandler(app.StakingKeeper) - header := abci.Header{Height: app.LastBlockHeight() + 1} + header := tmproto.Header{Height: app.LastBlockHeight() + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) valAddr := sdk.ValAddress(addrs[0]) @@ -315,7 +316,7 @@ func TestProposalPassedEndblocker(t *testing.T) { func TestEndBlockerProposalHandlerFailed(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs := simapp.AddTestAddrs(app, ctx, 1, valTokens) SortAddresses(addrs) @@ -323,7 +324,7 @@ func TestEndBlockerProposalHandlerFailed(t *testing.T) { handler := gov.NewHandler(app.GovKeeper) stakingHandler := staking.NewHandler(app.StakingKeeper) - header := abci.Header{Height: app.LastBlockHeight() + 1} + header := tmproto.Header{Height: app.LastBlockHeight() + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) valAddr := sdk.ValAddress(addrs[0]) diff --git a/x/gov/client/utils/query_test.go b/x/gov/client/utils/query_test.go index 85f0983fa3db..7cda74061e4a 100644 --- a/x/gov/client/utils/query_test.go +++ b/x/gov/client/utils/query_test.go @@ -20,8 +20,8 @@ type TxSearchMock struct { txs []tmtypes.Tx } -func (mock TxSearchMock) TxSearch(query string, prove bool, page, perPage int, orderBy string) (*ctypes.ResultTxSearch, error) { - start, end := client.Paginate(len(mock.txs), page, perPage, 100) +func (mock TxSearchMock) TxSearch(query string, prove bool, page, perPage *int, orderBy string) (*ctypes.ResultTxSearch, error) { + start, end := client.Paginate(len(mock.txs), *page, *perPage, 100) //todo:?? if start < 0 || end < 0 { // nil result with nil error crashes utils.QueryTxsByEvents return &ctypes.ResultTxSearch{}, nil diff --git a/x/gov/genesis_test.go b/x/gov/genesis_test.go index 0d1a0d5a9a66..ad34cb5b6d2b 100644 --- a/x/gov/genesis_test.go +++ b/x/gov/genesis_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/codec" @@ -19,15 +20,15 @@ import ( func TestImportExportQueues(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs := simapp.AddTestAddrs(app, ctx, 2, valTokens) SortAddresses(addrs) - header := abci.Header{Height: app.LastBlockHeight() + 1} + header := tmproto.Header{Height: app.LastBlockHeight() + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) - ctx = app.BaseApp.NewContext(false, abci.Header{}) + ctx = app.BaseApp.NewContext(false, tmproto.Header{}) // Create two proposals, put the second into the voting period proposal := TestProposal @@ -78,12 +79,12 @@ func TestImportExportQueues(t *testing.T) { ) app2.Commit() - app2.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: app2.LastBlockHeight() + 1}}) + app2.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app2.LastBlockHeight() + 1}}) - header = abci.Header{Height: app2.LastBlockHeight() + 1} + header = tmproto.Header{Height: app2.LastBlockHeight() + 1} app2.BeginBlock(abci.RequestBeginBlock{Header: header}) - ctx2 := app2.BaseApp.NewContext(false, abci.Header{}) + ctx2 := app2.BaseApp.NewContext(false, tmproto.Header{}) // Jump the time forward past the DepositPeriod and VotingPeriod ctx2 = ctx2.WithBlockTime(ctx2.BlockHeader().Time.Add(app2.GovKeeper.GetDepositParams(ctx2).MaxDepositPeriod).Add(app2.GovKeeper.GetVotingParams(ctx2).VotingPeriod)) @@ -112,12 +113,12 @@ func TestImportExportQueues(t *testing.T) { func TestEqualProposals(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs := simapp.AddTestAddrs(app, ctx, 2, valTokens) SortAddresses(addrs) - header := abci.Header{Height: app.LastBlockHeight() + 1} + header := tmproto.Header{Height: app.LastBlockHeight() + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) // Submit two proposals diff --git a/x/gov/handler_test.go b/x/gov/handler_test.go index 57dde01958c3..316a8736dc04 100644 --- a/x/gov/handler_test.go +++ b/x/gov/handler_test.go @@ -4,11 +4,10 @@ import ( "strings" "testing" - "github.com/cosmos/cosmos-sdk/testutil/testdata" - "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/gov/keeper" @@ -18,7 +17,7 @@ func TestInvalidMsg(t *testing.T) { k := keeper.Keeper{} h := gov.NewHandler(k) - res, err := h(sdk.NewContext(nil, abci.Header{}, false, nil), testdata.NewTestMsg()) + res, err := h(sdk.NewContext(nil, tmproto.Header{}, false, nil), testdata.NewTestMsg()) require.Error(t, err) require.Nil(t, res) require.True(t, strings.Contains(err.Error(), "unrecognized gov message type")) diff --git a/x/gov/keeper/deposit_test.go b/x/gov/keeper/deposit_test.go index 1f70e9a736a7..b94d4edc6d83 100644 --- a/x/gov/keeper/deposit_test.go +++ b/x/gov/keeper/deposit_test.go @@ -5,7 +5,7 @@ import ( "time" "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -13,7 +13,7 @@ import ( func TestDeposits(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) TestAddrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(10000000)) diff --git a/x/gov/keeper/keeper_test.go b/x/gov/keeper/keeper_test.go index 3c3d63f82801..9de994e9fa34 100644 --- a/x/gov/keeper/keeper_test.go +++ b/x/gov/keeper/keeper_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/simapp" @@ -24,7 +24,7 @@ type KeeperTestSuite struct { func (suite *KeeperTestSuite) SetupTest() { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry()) types.RegisterQueryServer(queryHelper, app.GovKeeper) @@ -38,7 +38,7 @@ func (suite *KeeperTestSuite) SetupTest() { func TestIncrementProposalNumber(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) tp := TestProposal _, err := app.GovKeeper.SubmitProposal(ctx, tp) @@ -59,7 +59,7 @@ func TestIncrementProposalNumber(t *testing.T) { func TestProposalQueues(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) // create test proposals tp := TestProposal diff --git a/x/gov/keeper/proposal_test.go b/x/gov/keeper/proposal_test.go index 4f29a6748d1f..d569515b9fa4 100644 --- a/x/gov/keeper/proposal_test.go +++ b/x/gov/keeper/proposal_test.go @@ -7,7 +7,7 @@ import ( "time" "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -16,7 +16,7 @@ import ( func TestGetSetProposal(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) tp := TestProposal proposal, err := app.GovKeeper.SubmitProposal(ctx, tp) @@ -31,7 +31,7 @@ func TestGetSetProposal(t *testing.T) { func TestActivateVotingPeriod(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) tp := TestProposal proposal, err := app.GovKeeper.SubmitProposal(ctx, tp) @@ -60,7 +60,7 @@ func (invalidProposalRoute) ProposalRoute() string { return "nonexistingroute" } func TestSubmitProposal(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) testCases := []struct { content types.Content @@ -85,7 +85,7 @@ func TestSubmitProposal(t *testing.T) { func TestGetProposalsFiltered(t *testing.T) { proposalID := uint64(1) app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) status := []types.ProposalStatus{types.StatusDepositPeriod, types.StatusVotingPeriod} diff --git a/x/gov/keeper/querier_test.go b/x/gov/keeper/querier_test.go index db86e896795a..23033d803248 100644 --- a/x/gov/keeper/querier_test.go +++ b/x/gov/keeper/querier_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/simapp" @@ -145,7 +146,7 @@ func getQueriedVotes(t *testing.T, ctx sdk.Context, cdc codec.JSONMarshaler, que func TestQueries(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) appCodec := app.AppCodec() legacyQuerierCdc := codec.NewAminoCodec(app.Codec()) querier := keeper.NewQuerier(app.GovKeeper, legacyQuerierCdc) @@ -293,7 +294,7 @@ func TestQueries(t *testing.T) { func TestPaginatedVotesQuery(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) appCodec := app.AppCodec() proposal := types.Proposal{ diff --git a/x/gov/keeper/tally_test.go b/x/gov/keeper/tally_test.go index 704aa5d0307d..cf8d504b3eb9 100644 --- a/x/gov/keeper/tally_test.go +++ b/x/gov/keeper/tally_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -14,7 +14,7 @@ import ( func TestTallyNoOneVotes(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) createValidators(ctx, app, []int64{5, 5, 5}) @@ -36,7 +36,7 @@ func TestTallyNoOneVotes(t *testing.T) { func TestTallyNoQuorum(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) createValidators(ctx, app, []int64{2, 5, 0}) @@ -61,7 +61,7 @@ func TestTallyNoQuorum(t *testing.T) { func TestTallyOnlyValidatorsAllYes(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs, _ := createValidators(ctx, app, []int64{5, 5, 5}) tp := TestProposal @@ -87,7 +87,7 @@ func TestTallyOnlyValidatorsAllYes(t *testing.T) { func TestTallyOnlyValidators51No(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) valAccAddrs, _ := createValidators(ctx, app, []int64{5, 6, 0}) @@ -111,7 +111,7 @@ func TestTallyOnlyValidators51No(t *testing.T) { func TestTallyOnlyValidators51Yes(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) valAccAddrs, _ := createValidators(ctx, app, []int64{5, 6, 0}) @@ -136,7 +136,7 @@ func TestTallyOnlyValidators51Yes(t *testing.T) { func TestTallyOnlyValidatorsVetoed(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) valAccAddrs, _ := createValidators(ctx, app, []int64{6, 6, 7}) @@ -162,7 +162,7 @@ func TestTallyOnlyValidatorsVetoed(t *testing.T) { func TestTallyOnlyValidatorsAbstainPasses(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) valAccAddrs, _ := createValidators(ctx, app, []int64{6, 6, 7}) @@ -188,7 +188,7 @@ func TestTallyOnlyValidatorsAbstainPasses(t *testing.T) { func TestTallyOnlyValidatorsAbstainFails(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) valAccAddrs, _ := createValidators(ctx, app, []int64{6, 6, 7}) @@ -214,7 +214,7 @@ func TestTallyOnlyValidatorsAbstainFails(t *testing.T) { func TestTallyOnlyValidatorsNonVoter(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) valAccAddrs, _ := createValidators(ctx, app, []int64{5, 6, 7}) valAccAddr1, valAccAddr2 := valAccAddrs[0], valAccAddrs[1] @@ -240,7 +240,7 @@ func TestTallyOnlyValidatorsNonVoter(t *testing.T) { func TestTallyDelgatorOverride(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs, valAddrs := createValidators(ctx, app, []int64{5, 6, 7}) @@ -276,7 +276,7 @@ func TestTallyDelgatorOverride(t *testing.T) { func TestTallyDelgatorInherit(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs, vals := createValidators(ctx, app, []int64{5, 6, 7}) @@ -311,7 +311,7 @@ func TestTallyDelgatorInherit(t *testing.T) { func TestTallyDelgatorMultipleOverride(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs, vals := createValidators(ctx, app, []int64{5, 6, 7}) @@ -351,7 +351,7 @@ func TestTallyDelgatorMultipleOverride(t *testing.T) { func TestTallyDelgatorMultipleInherit(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) createValidators(ctx, app, []int64{25, 6, 7}) @@ -392,7 +392,7 @@ func TestTallyDelgatorMultipleInherit(t *testing.T) { func TestTallyJailedValidator(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs, valAddrs := createValidators(ctx, app, []int64{25, 6, 7}) @@ -433,7 +433,7 @@ func TestTallyJailedValidator(t *testing.T) { func TestTallyValidatorMultipleDelegations(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs, valAddrs := createValidators(ctx, app, []int64{10, 10, 10}) diff --git a/x/gov/keeper/vote_test.go b/x/gov/keeper/vote_test.go index cc2d92a0a697..98d294c2fd84 100644 --- a/x/gov/keeper/vote_test.go +++ b/x/gov/keeper/vote_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -13,7 +13,7 @@ import ( func TestVotes(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs := simapp.AddTestAddrsIncremental(app, ctx, 5, sdk.NewInt(30000000)) diff --git a/x/gov/module_test.go b/x/gov/module_test.go index a4b44922460b..4e54c0b79af3 100644 --- a/x/gov/module_test.go +++ b/x/gov/module_test.go @@ -5,6 +5,7 @@ import ( "github.com/stretchr/testify/require" abcitypes "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -13,7 +14,7 @@ import ( func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abcitypes.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) app.InitChain( abcitypes.RequestInitChain{ diff --git a/x/gov/simulation/decoder.go b/x/gov/simulation/decoder.go index 1433761a111a..75cb4a5fccc8 100644 --- a/x/gov/simulation/decoder.go +++ b/x/gov/simulation/decoder.go @@ -5,16 +5,15 @@ import ( "encoding/binary" "fmt" - tmkv "github.com/tendermint/tendermint/libs/kv" - "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/x/gov/types" ) // NewDecodeStore returns a decoder function closure that unmarshals the KVPair's // Value to the corresponding gov type. -func NewDecodeStore(cdc codec.Marshaler) func(kvA, kvB tmkv.Pair) string { - return func(kvA, kvB tmkv.Pair) string { +func NewDecodeStore(cdc codec.Marshaler) func(kvA, kvB kv.Pair) string { + return func(kvA, kvB kv.Pair) string { switch { case bytes.Equal(kvA.Key[:1], types.ProposalsKeyPrefix): var proposalA types.Proposal diff --git a/x/gov/simulation/decoder_test.go b/x/gov/simulation/decoder_test.go index 20087f4a11ef..22340673923e 100644 --- a/x/gov/simulation/decoder_test.go +++ b/x/gov/simulation/decoder_test.go @@ -9,10 +9,10 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto/ed25519" - tmkv "github.com/tendermint/tendermint/libs/kv" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/x/gov/simulation" "github.com/cosmos/cosmos-sdk/x/gov/types" ) @@ -40,12 +40,12 @@ func TestDecodeStore(t *testing.T) { proposalBz, err := cdc.MarshalBinaryBare(&proposal) require.NoError(t, err) - kvPairs := tmkv.Pairs{ - tmkv.Pair{Key: types.ProposalKey(1), Value: proposalBz}, - tmkv.Pair{Key: types.InactiveProposalQueueKey(1, endTime), Value: proposalIDBz}, - tmkv.Pair{Key: types.DepositKey(1, delAddr1), Value: cdc.MustMarshalBinaryBare(&deposit)}, - tmkv.Pair{Key: types.VoteKey(1, delAddr1), Value: cdc.MustMarshalBinaryBare(&vote)}, - tmkv.Pair{Key: []byte{0x99}, Value: []byte{0x99}}, + kvPairs := kv.Pairs{ + kv.Pair{Key: types.ProposalKey(1), Value: proposalBz}, + kv.Pair{Key: types.InactiveProposalQueueKey(1, endTime), Value: proposalIDBz}, + kv.Pair{Key: types.DepositKey(1, delAddr1), Value: cdc.MustMarshalBinaryBare(&deposit)}, + kv.Pair{Key: types.VoteKey(1, delAddr1), Value: cdc.MustMarshalBinaryBare(&vote)}, + kv.Pair{Key: []byte{0x99}, Value: []byte{0x99}}, } tests := []struct { diff --git a/x/gov/simulation/operations_test.go b/x/gov/simulation/operations_test.go index c412bd46f1e4..468e9cfba7f4 100644 --- a/x/gov/simulation/operations_test.go +++ b/x/gov/simulation/operations_test.go @@ -9,6 +9,7 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" @@ -104,7 +105,7 @@ func TestSimulateMsgSubmitProposal(t *testing.T) { accounts := getTestingAccounts(t, r, app, ctx, 3) // begin a new block - app.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash}}) + app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash}}) // execute operation op := simulation.SimulateMsgSubmitProposal(app.AccountKeeper, app.BankKeeper, app.GovKeeper, MockWeightedProposalContent{3}.ContentSimulatorFn()) @@ -147,7 +148,7 @@ func TestSimulateMsgDeposit(t *testing.T) { app.GovKeeper.SetProposal(ctx, proposal) // begin a new block - app.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash, Time: blockTime}}) + app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash, Time: blockTime}}) // execute operation op := simulation.SimulateMsgDeposit(app.AccountKeeper, app.BankKeeper, app.GovKeeper) @@ -189,7 +190,7 @@ func TestSimulateMsgVote(t *testing.T) { app.GovKeeper.ActivateVotingPeriod(ctx, proposal) // begin a new block - app.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash, Time: blockTime}}) + app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash, Time: blockTime}}) // execute operation op := simulation.SimulateMsgVote(app.AccountKeeper, app.BankKeeper, app.GovKeeper) @@ -212,7 +213,7 @@ func TestSimulateMsgVote(t *testing.T) { func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) { app := simapp.Setup(isCheckTx) - ctx := app.BaseApp.NewContext(isCheckTx, abci.Header{}) + ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) app.MintKeeper.SetParams(ctx, minttypes.DefaultParams()) app.MintKeeper.SetMinter(ctx, minttypes.DefaultInitialMinter()) diff --git a/x/gov/simulation/proposals_test.go b/x/gov/simulation/proposals_test.go index d83edbfb007b..dcd6f3c3f08b 100644 --- a/x/gov/simulation/proposals_test.go +++ b/x/gov/simulation/proposals_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" sdk "github.com/cosmos/cosmos-sdk/types" @@ -18,7 +18,7 @@ func TestProposalContents(t *testing.T) { s := rand.NewSource(1) r := rand.New(s) - ctx := sdk.NewContext(nil, abci.Header{}, true, nil) + ctx := sdk.NewContext(nil, tmproto.Header{}, true, nil) accounts := simtypes.RandomAccounts(r, 3) // execute ProposalContents function diff --git a/x/ibc-transfer/handler_test.go b/x/ibc-transfer/handler_test.go index 97153941f522..4979ed69f7b1 100644 --- a/x/ibc-transfer/handler_test.go +++ b/x/ibc-transfer/handler_test.go @@ -8,7 +8,8 @@ import ( "github.com/stretchr/testify/suite" abci "github.com/tendermint/tendermint/abci/types" - lite "github.com/tendermint/tendermint/lite2" + lite "github.com/tendermint/tendermint/light" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" @@ -159,7 +160,7 @@ func NewTestChain(clientID string) *TestChain { // Creates simple context for testing purposes func (chain *TestChain) GetContext() sdk.Context { - return chain.App.BaseApp.NewContext(false, abci.Header{ChainID: chain.Header.SignedHeader.Header.ChainID, Height: chain.Header.SignedHeader.Header.Height}) + return chain.App.BaseApp.NewContext(false, tmproto.Header{ChainID: chain.Header.SignedHeader.Header.ChainID, Height: chain.Header.SignedHeader.Header.Height}) } // createClient will create a client for clientChain on targetChain @@ -168,7 +169,7 @@ func (chain *TestChain) CreateClient(client *TestChain) error { // Commit and create a new block on appTarget to get a fresh CommitID client.App.Commit() commitID := client.App.LastCommitID() - client.App.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: client.Header.SignedHeader.Header.Height, Time: client.Header.Time}}) + client.App.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: client.Header.SignedHeader.Header.Height, Time: client.Header.Time}}) // Set HistoricalInfo on client chain after Commit ctxClient := client.GetContext() @@ -179,7 +180,7 @@ func (chain *TestChain) CreateClient(client *TestChain) error { validator.Tokens = sdk.NewInt(1000000) // get one voting power validators := []stakingtypes.Validator{validator} histInfo := stakingtypes.HistoricalInfo{ - Header: abci.Header{ + Header: tmproto.Header{ AppHash: commitID.Hash, }, Valset: validators, @@ -230,7 +231,7 @@ func (chain *TestChain) updateClient(client *TestChain) { commitID := client.App.LastCommitID() client.Header = nextHeader(client) - client.App.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: client.Header.SignedHeader.Header.Height, Time: client.Header.Time}}) + client.App.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: client.Header.SignedHeader.Header.Height, Time: client.Header.Time}}) // Set HistoricalInfo on client chain after Commit ctxClient := client.GetContext() @@ -241,7 +242,7 @@ func (chain *TestChain) updateClient(client *TestChain) { validator.Tokens = sdk.NewInt(1000000) validators := []stakingtypes.Validator{validator} histInfo := stakingtypes.HistoricalInfo{ - Header: abci.Header{ + Header: tmproto.Header{ AppHash: commitID.Hash, }, Valset: validators, diff --git a/x/ibc-transfer/keeper/keeper_test.go b/x/ibc-transfer/keeper/keeper_test.go index 3ce58f0a79ac..dcfb34aa5563 100644 --- a/x/ibc-transfer/keeper/keeper_test.go +++ b/x/ibc-transfer/keeper/keeper_test.go @@ -8,7 +8,8 @@ import ( "github.com/stretchr/testify/suite" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto" - lite "github.com/tendermint/tendermint/lite2" + lite "github.com/tendermint/tendermint/light" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" @@ -80,7 +81,7 @@ func (suite *KeeperTestSuite) queryProof(key []byte) (proof commitmenttypes.Merk height = res.Height proof = commitmenttypes.MerkleProof{ - Proof: res.Proof, + Proof: res.ProofOps, } return @@ -134,7 +135,7 @@ func NewTestChain(clientID string) *TestChain { // Creates simple context for testing purposes func (chain *TestChain) GetContext() sdk.Context { - return chain.App.BaseApp.NewContext(false, abci.Header{ChainID: chain.Header.SignedHeader.Header.ChainID, Height: chain.Header.SignedHeader.Header.Height}) + return chain.App.BaseApp.NewContext(false, tmproto.Header{ChainID: chain.Header.SignedHeader.Header.ChainID, Height: chain.Header.SignedHeader.Header.Height}) } // createClient will create a client for clientChain on targetChain @@ -143,7 +144,7 @@ func (chain *TestChain) CreateClient(client *TestChain) error { // Commit and create a new block on appTarget to get a fresh CommitID client.App.Commit() commitID := client.App.LastCommitID() - client.App.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: client.Header.SignedHeader.Header.Height, Time: client.Header.Time}}) + client.App.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: client.Header.SignedHeader.Header.Height, Time: client.Header.Time}}) // Set HistoricalInfo on client chain after Commit ctxClient := client.GetContext() @@ -154,7 +155,7 @@ func (chain *TestChain) CreateClient(client *TestChain) error { validator.Tokens = sdk.NewInt(1000000) // get one voting power validators := []stakingtypes.Validator{validator} histInfo := stakingtypes.HistoricalInfo{ - Header: abci.Header{ + Header: tmproto.Header{ AppHash: commitID.Hash, }, Valset: validators, @@ -205,7 +206,7 @@ func (chain *TestChain) updateClient(client *TestChain) { commitID := client.App.LastCommitID() client.Header = nextHeader(client) - client.App.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: client.Header.SignedHeader.Header.Height, Time: client.Header.Time}}) + client.App.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: client.Header.SignedHeader.Header.Height, Time: client.Header.Time}}) // Set HistoricalInfo on client chain after Commit ctxClient := client.GetContext() @@ -216,7 +217,7 @@ func (chain *TestChain) updateClient(client *TestChain) { validator.Tokens = sdk.NewInt(1000000) validators := []stakingtypes.Validator{validator} histInfo := stakingtypes.HistoricalInfo{ - Header: abci.Header{ + Header: tmproto.Header{ AppHash: commitID.Hash, }, Valset: validators, diff --git a/x/ibc/02-client/abci_test.go b/x/ibc/02-client/abci_test.go index e61cc2f368a2..9bcbe784b7ad 100644 --- a/x/ibc/02-client/abci_test.go +++ b/x/ibc/02-client/abci_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/stretchr/testify/suite" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/simapp" @@ -26,7 +26,7 @@ func (suite *ClientTestSuite) SetupTest() { suite.app = simapp.Setup(isCheckTx) suite.cdc = suite.app.Codec() - suite.ctx = suite.app.BaseApp.NewContext(isCheckTx, abci.Header{Height: 0, ChainID: "localhost_chain"}) + suite.ctx = suite.app.BaseApp.NewContext(isCheckTx, tmproto.Header{Height: 0, ChainID: "localhost_chain"}) } diff --git a/x/ibc/02-client/client/utils/utils.go b/x/ibc/02-client/client/utils/utils.go index 4430d05fee85..f102405a3e6c 100644 --- a/x/ibc/02-client/client/utils/utils.go +++ b/x/ibc/02-client/client/utils/utils.go @@ -58,7 +58,7 @@ func QueryClientState( return types.StateResponse{}, err } - clientStateRes := types.NewClientStateResponse(clientID, clientState, res.Proof, res.Height) + clientStateRes := types.NewClientStateResponse(clientID, clientState, res.ProofOps, res.Height) return clientStateRes, nil } @@ -86,7 +86,7 @@ func QueryConsensusState( return conStateRes, err } - return types.NewConsensusStateResponse(clientID, cs, res.Proof, res.Height), nil + return types.NewConsensusStateResponse(clientID, cs, res.ProofOps, res.Height), nil } // QueryTendermintHeader takes a client context and returns the appropriate @@ -109,7 +109,12 @@ func QueryTendermintHeader(clientCtx client.Context) (ibctmtypes.Header, int64, return ibctmtypes.Header{}, 0, err } - validators, err := node.Validators(&height, 0, 10000) + page := new(int) + *page = 0 + perPage := new(int) + *perPage = 10_000 + + validators, err := node.Validators(&height, page, perPage) if err != nil { return ibctmtypes.Header{}, 0, err } @@ -142,7 +147,12 @@ func QueryNodeConsensusState(clientCtx client.Context) (ibctmtypes.ConsensusStat return ibctmtypes.ConsensusState{}, 0, err } - validators, err := node.Validators(&height, 0, 10000) + page := new(int) + *page = 0 + perPage := new(int) + *perPage = 10_000 + + validators, err := node.Validators(&height, page, perPage) if err != nil { return ibctmtypes.ConsensusState{}, 0, err } diff --git a/x/ibc/02-client/keeper/client_test.go b/x/ibc/02-client/keeper/client_test.go index d343be644607..f4b51edc820a 100644 --- a/x/ibc/02-client/keeper/client_test.go +++ b/x/ibc/02-client/keeper/client_test.go @@ -5,7 +5,7 @@ import ( "fmt" "time" - lite "github.com/tendermint/tendermint/lite2" + lite "github.com/tendermint/tendermint/light" tmtypes "github.com/tendermint/tendermint/types" "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" diff --git a/x/ibc/02-client/keeper/keeper_test.go b/x/ibc/02-client/keeper/keeper_test.go index 2153a255d58f..43a7f21e8dd5 100644 --- a/x/ibc/02-client/keeper/keeper_test.go +++ b/x/ibc/02-client/keeper/keeper_test.go @@ -7,8 +7,8 @@ import ( "github.com/stretchr/testify/suite" - abci "github.com/tendermint/tendermint/abci/types" - lite "github.com/tendermint/tendermint/lite2" + lite "github.com/tendermint/tendermint/light" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" @@ -54,7 +54,7 @@ func (suite *KeeperTestSuite) SetupTest() { app := simapp.Setup(isCheckTx) suite.cdc = app.Codec() - suite.ctx = app.BaseApp.NewContext(isCheckTx, abci.Header{Height: testClientHeight, ChainID: testClientID, Time: now2}) + suite.ctx = app.BaseApp.NewContext(isCheckTx, tmproto.Header{Height: testClientHeight, ChainID: testClientID, Time: now2}) suite.keeper = &app.IBCKeeper.ClientKeeper suite.privVal = tmtypes.NewMockPV() diff --git a/x/ibc/02-client/simulation/decoder.go b/x/ibc/02-client/simulation/decoder.go index c7f566609dec..3c9a0c9486b6 100644 --- a/x/ibc/02-client/simulation/decoder.go +++ b/x/ibc/02-client/simulation/decoder.go @@ -4,16 +4,15 @@ import ( "bytes" "fmt" - tmkv "github.com/tendermint/tendermint/libs/kv" - "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" ) // NewDecodeStore returns a decoder function closure that unmarshals the KVPair's // Value to the corresponding client type. -func NewDecodeStore(cdc *codec.Codec, kvA, kvB tmkv.Pair) (string, bool) { +func NewDecodeStore(cdc *codec.Codec, kvA, kvB kv.Pair) (string, bool) { switch { case bytes.HasPrefix(kvA.Key, host.KeyClientStorePrefix) && bytes.HasSuffix(kvA.Key, host.KeyClientState()): var clientStateA, clientStateB exported.ClientState diff --git a/x/ibc/02-client/simulation/decoder_test.go b/x/ibc/02-client/simulation/decoder_test.go index fed0cc74f8cd..33be5b5ee381 100644 --- a/x/ibc/02-client/simulation/decoder_test.go +++ b/x/ibc/02-client/simulation/decoder_test.go @@ -6,9 +6,9 @@ import ( "time" "github.com/stretchr/testify/require" - tmkv "github.com/tendermint/tendermint/libs/kv" "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" "github.com/cosmos/cosmos-sdk/x/ibc/02-client/simulation" ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" @@ -30,20 +30,20 @@ func TestDecodeStore(t *testing.T) { Timestamp: time.Now().UTC(), } - kvPairs := tmkv.Pairs{ - tmkv.Pair{ + kvPairs := kv.Pairs{ + kv.Pair{ Key: host.FullKeyClientPath(clientID, host.KeyClientState()), Value: cdc.MustMarshalBinaryBare(clientState), }, - tmkv.Pair{ + kv.Pair{ Key: host.FullKeyClientPath(clientID, host.KeyClientType()), Value: []byte(exported.Tendermint.String()), }, - tmkv.Pair{ + kv.Pair{ Key: host.FullKeyClientPath(clientID, host.KeyConsensusState(10)), Value: cdc.MustMarshalBinaryBare(consState), }, - tmkv.Pair{ + kv.Pair{ Key: []byte{0x99}, Value: []byte{0x99}, }, diff --git a/x/ibc/02-client/types/genesis_test.go b/x/ibc/02-client/types/genesis_test.go index 55aca4088095..d59bec897508 100644 --- a/x/ibc/02-client/types/genesis_test.go +++ b/x/ibc/02-client/types/genesis_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" - lite "github.com/tendermint/tendermint/lite2" + lite "github.com/tendermint/tendermint/light" tmtypes "github.com/tendermint/tendermint/types" "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" diff --git a/x/ibc/02-client/types/querier.go b/x/ibc/02-client/types/querier.go index 64c69cbd087e..33c6b132484a 100644 --- a/x/ibc/02-client/types/querier.go +++ b/x/ibc/02-client/types/querier.go @@ -3,7 +3,7 @@ package types import ( "strings" - "github.com/tendermint/tendermint/crypto/merkle" + tmmerkle "github.com/tendermint/tendermint/proto/tendermint/crypto" "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" @@ -41,7 +41,7 @@ type StateResponse struct { // NewClientStateResponse creates a new StateResponse instance. func NewClientStateResponse( - clientID string, clientState exported.ClientState, proof *merkle.Proof, height int64, + clientID string, clientState exported.ClientState, proof *tmmerkle.ProofOps, height int64, ) StateResponse { return StateResponse{ ClientState: clientState, @@ -62,7 +62,7 @@ type ConsensusStateResponse struct { // NewConsensusStateResponse creates a new ConsensusStateResponse instance. func NewConsensusStateResponse( - clientID string, cs exported.ConsensusState, proof *merkle.Proof, height int64, + clientID string, cs exported.ConsensusState, proof *tmmerkle.ProofOps, height int64, ) ConsensusStateResponse { return ConsensusStateResponse{ ConsensusState: cs, diff --git a/x/ibc/03-connection/client/utils/utils.go b/x/ibc/03-connection/client/utils/utils.go index 81fc8e22d430..789d7590e57b 100644 --- a/x/ibc/03-connection/client/utils/utils.go +++ b/x/ibc/03-connection/client/utils/utils.go @@ -51,7 +51,7 @@ func queryConnectionABCI(clientCtx client.Context, connectionID string) (*types. return nil, err } - proofBz, err := clientCtx.Codec.MarshalBinaryBare(res.Proof) + proofBz, err := clientCtx.Codec.MarshalBinaryBare(res.ProofOps) if err != nil { return nil, err } @@ -94,7 +94,7 @@ func queryClientConnectionsABCI(clientCtx client.Context, clientID string) (*typ return nil, err } - proofBz, err := clientCtx.Codec.MarshalBinaryBare(res.Proof) + proofBz, err := clientCtx.Codec.MarshalBinaryBare(res.ProofOps) if err != nil { return nil, err } diff --git a/x/ibc/03-connection/simulation/decoder.go b/x/ibc/03-connection/simulation/decoder.go index c80a987b6fd8..0b5079997e42 100644 --- a/x/ibc/03-connection/simulation/decoder.go +++ b/x/ibc/03-connection/simulation/decoder.go @@ -4,16 +4,15 @@ import ( "bytes" "fmt" - tmkv "github.com/tendermint/tendermint/libs/kv" - "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" ) // NewDecodeStore returns a decoder function closure that unmarshals the KVPair's // Value to the corresponding connection type. -func NewDecodeStore(cdc codec.BinaryMarshaler, kvA, kvB tmkv.Pair) (string, bool) { +func NewDecodeStore(cdc codec.BinaryMarshaler, kvA, kvB kv.Pair) (string, bool) { switch { case bytes.HasPrefix(kvA.Key, host.KeyClientStorePrefix) && bytes.HasSuffix(kvA.Key, host.KeyConnectionPrefix): var clientConnectionsA, clientConnectionsB types.ClientPaths diff --git a/x/ibc/03-connection/simulation/decoder_test.go b/x/ibc/03-connection/simulation/decoder_test.go index dc75f12ab9bb..f610c83ade75 100644 --- a/x/ibc/03-connection/simulation/decoder_test.go +++ b/x/ibc/03-connection/simulation/decoder_test.go @@ -5,9 +5,9 @@ import ( "testing" "github.com/stretchr/testify/require" - tmkv "github.com/tendermint/tendermint/libs/kv" "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/simulation" "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" @@ -28,16 +28,16 @@ func TestDecodeStore(t *testing.T) { Paths: []string{connectionID}, } - kvPairs := tmkv.Pairs{ - tmkv.Pair{ + kvPairs := kv.Pairs{ + kv.Pair{ Key: host.KeyClientConnections(connection.ClientID), Value: cdc.MustMarshalBinaryBare(&paths), }, - tmkv.Pair{ + kv.Pair{ Key: host.KeyConnection(connectionID), Value: cdc.MustMarshalBinaryBare(&connection), }, - tmkv.Pair{ + kv.Pair{ Key: []byte{0x99}, Value: []byte{0x99}, }, diff --git a/x/ibc/03-connection/types/msgs_test.go b/x/ibc/03-connection/types/msgs_test.go index 6ea55060b6ad..6f272960b3b9 100644 --- a/x/ibc/03-connection/types/msgs_test.go +++ b/x/ibc/03-connection/types/msgs_test.go @@ -49,7 +49,7 @@ func (suite *MsgTestSuite) SetupTest() { Prove: true, }) - merkleProof := commitmenttypes.MerkleProof{Proof: res.Proof} + merkleProof := commitmenttypes.MerkleProof{Proof: res.ProofOps} proof, err := app.AppCodec().MarshalBinaryBare(&merkleProof) suite.NoError(err) diff --git a/x/ibc/04-channel/client/utils/utils.go b/x/ibc/04-channel/client/utils/utils.go index b36cc2eb9853..84905e5bac79 100644 --- a/x/ibc/04-channel/client/utils/utils.go +++ b/x/ibc/04-channel/client/utils/utils.go @@ -48,7 +48,7 @@ func queryPacketCommitmentABCI( return nil, err } - proofBz, err := clientCtx.Codec.MarshalBinaryBare(res.Proof) + proofBz, err := clientCtx.Codec.MarshalBinaryBare(res.ProofOps) if err != nil { return nil, err } @@ -93,7 +93,7 @@ func queryChannelABCI(clientCtx client.Context, portID, channelID string) (*type return nil, err } - proofBz, err := clientCtx.Codec.MarshalBinaryBare(res.Proof) + proofBz, err := clientCtx.Codec.MarshalBinaryBare(res.ProofOps) if err != nil { return nil, err } @@ -195,7 +195,7 @@ func queryNextSequenceRecvABCI(clientCtx client.Context, portID, channelID strin return nil, err } - proofBz, err := clientCtx.Codec.MarshalBinaryBare(res.Proof) + proofBz, err := clientCtx.Codec.MarshalBinaryBare(res.ProofOps) if err != nil { return nil, err } diff --git a/x/ibc/04-channel/simulation/decoder.go b/x/ibc/04-channel/simulation/decoder.go index 9d5b88670c4a..dd35319ee872 100644 --- a/x/ibc/04-channel/simulation/decoder.go +++ b/x/ibc/04-channel/simulation/decoder.go @@ -4,7 +4,7 @@ import ( "bytes" "fmt" - tmkv "github.com/tendermint/tendermint/libs/kv" + "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -14,7 +14,7 @@ import ( // NewDecodeStore returns a decoder function closure that unmarshals the KVPair's // Value to the corresponding channel type. -func NewDecodeStore(cdc codec.BinaryMarshaler, kvA, kvB tmkv.Pair) (string, bool) { +func NewDecodeStore(cdc codec.BinaryMarshaler, kvA, kvB kv.Pair) (string, bool) { switch { case bytes.HasPrefix(kvA.Key, []byte(host.KeyChannelPrefix)): var channelA, channelB types.Channel diff --git a/x/ibc/04-channel/simulation/decoder_test.go b/x/ibc/04-channel/simulation/decoder_test.go index af4ba2fc73ab..dfb1ace7d9c9 100644 --- a/x/ibc/04-channel/simulation/decoder_test.go +++ b/x/ibc/04-channel/simulation/decoder_test.go @@ -5,10 +5,10 @@ import ( "testing" "github.com/stretchr/testify/require" - tmkv "github.com/tendermint/tendermint/libs/kv" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/simulation" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" @@ -28,32 +28,32 @@ func TestDecodeStore(t *testing.T) { bz := []byte{0x1, 0x2, 0x3} - kvPairs := tmkv.Pairs{ - tmkv.Pair{ + kvPairs := kv.Pairs{ + kv.Pair{ Key: host.KeyChannel(portID, channelID), Value: cdc.MustMarshalBinaryBare(&channel), }, - tmkv.Pair{ + kv.Pair{ Key: host.KeyNextSequenceSend(portID, channelID), Value: sdk.Uint64ToBigEndian(1), }, - tmkv.Pair{ + kv.Pair{ Key: host.KeyNextSequenceRecv(portID, channelID), Value: sdk.Uint64ToBigEndian(1), }, - tmkv.Pair{ + kv.Pair{ Key: host.KeyNextSequenceAck(portID, channelID), Value: sdk.Uint64ToBigEndian(1), }, - tmkv.Pair{ + kv.Pair{ Key: host.KeyPacketCommitment(portID, channelID, 1), Value: bz, }, - tmkv.Pair{ + kv.Pair{ Key: host.KeyPacketAcknowledgement(portID, channelID, 1), Value: bz, }, - tmkv.Pair{ + kv.Pair{ Key: []byte{0x99}, Value: []byte{0x99}, }, diff --git a/x/ibc/04-channel/types/msgs_test.go b/x/ibc/04-channel/types/msgs_test.go index a615a11b91e6..0c7b59765547 100644 --- a/x/ibc/04-channel/types/msgs_test.go +++ b/x/ibc/04-channel/types/msgs_test.go @@ -92,7 +92,7 @@ func (suite *MsgTestSuite) SetupTest() { Prove: true, }) - merkleProof := commitmenttypes.MerkleProof{Proof: res.Proof} + merkleProof := commitmenttypes.MerkleProof{Proof: res.ProofOps} proof, err := app.AppCodec().MarshalBinaryBare(&merkleProof) suite.NoError(err) diff --git a/x/ibc/05-port/keeper/keeper_test.go b/x/ibc/05-port/keeper/keeper_test.go index 68a06bf55fab..ec753a16671b 100644 --- a/x/ibc/05-port/keeper/keeper_test.go +++ b/x/ibc/05-port/keeper/keeper_test.go @@ -5,8 +5,7 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -29,7 +28,7 @@ func (suite *KeeperTestSuite) SetupTest() { isCheckTx := false app := simapp.Setup(isCheckTx) - suite.ctx = app.BaseApp.NewContext(isCheckTx, abci.Header{}) + suite.ctx = app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) suite.keeper = &app.IBCKeeper.PortKeeper } diff --git a/x/ibc/07-tendermint/client/cli/tx.go b/x/ibc/07-tendermint/client/cli/tx.go index 7395aad26e6b..fa954dc805f0 100644 --- a/x/ibc/07-tendermint/client/cli/tx.go +++ b/x/ibc/07-tendermint/client/cli/tx.go @@ -13,7 +13,7 @@ import ( "github.com/spf13/cobra" tmmath "github.com/tendermint/tendermint/libs/math" - lite "github.com/tendermint/tendermint/lite2" + lite "github.com/tendermint/tendermint/light" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" diff --git a/x/ibc/07-tendermint/misbehaviour.go b/x/ibc/07-tendermint/misbehaviour.go index e41ae444c932..3846e4da609d 100644 --- a/x/ibc/07-tendermint/misbehaviour.go +++ b/x/ibc/07-tendermint/misbehaviour.go @@ -109,15 +109,13 @@ func checkMisbehaviour( // - ValidatorSet must have 2/3 similarity with trusted FromValidatorSet // - ValidatorSets on both headers are valid given the last trusted ValidatorSet if err := consensusState.ValidatorSet.VerifyCommitLightTrusting( - evidence.ChainID, evidence.Header1.Commit.BlockID, evidence.Header1.Height, - evidence.Header1.Commit, clientState.TrustLevel, + evidence.ChainID, evidence.Header1.Commit, clientState.TrustLevel, ); err != nil { return sdkerrors.Wrapf(clienttypes.ErrInvalidEvidence, "validator set in header 1 has too much change from last known validator set: %v", err) } if err := consensusState.ValidatorSet.VerifyCommitLightTrusting( - evidence.ChainID, evidence.Header2.Commit.BlockID, evidence.Header2.Height, - evidence.Header2.Commit, clientState.TrustLevel, + evidence.ChainID, evidence.Header2.Commit, clientState.TrustLevel, ); err != nil { return sdkerrors.Wrapf(clienttypes.ErrInvalidEvidence, "validator set in header 2 has too much change from last known validator set: %v", err) } diff --git a/x/ibc/07-tendermint/misbehaviour_test.go b/x/ibc/07-tendermint/misbehaviour_test.go index 5cd54baa6695..e6a7dd4d76f1 100644 --- a/x/ibc/07-tendermint/misbehaviour_test.go +++ b/x/ibc/07-tendermint/misbehaviour_test.go @@ -6,7 +6,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto/tmhash" - lite "github.com/tendermint/tendermint/lite2" + lite "github.com/tendermint/tendermint/light" tmtypes "github.com/tendermint/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" diff --git a/x/ibc/07-tendermint/types/client_state.go b/x/ibc/07-tendermint/types/client_state.go index a9d0e2721988..33a9781f607c 100644 --- a/x/ibc/07-tendermint/types/client_state.go +++ b/x/ibc/07-tendermint/types/client_state.go @@ -5,7 +5,7 @@ import ( ics23 "github.com/confio/ics23/go" tmmath "github.com/tendermint/tendermint/libs/math" - lite "github.com/tendermint/tendermint/lite2" + lite "github.com/tendermint/tendermint/light" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/ibc/07-tendermint/types/client_state_test.go b/x/ibc/07-tendermint/types/client_state_test.go index e17ef89b7c73..8f1d8f289ca1 100644 --- a/x/ibc/07-tendermint/types/client_state_test.go +++ b/x/ibc/07-tendermint/types/client_state_test.go @@ -3,7 +3,7 @@ package types_test import ( ics23 "github.com/confio/ics23/go" tmmath "github.com/tendermint/tendermint/libs/math" - lite "github.com/tendermint/tendermint/lite2" + lite "github.com/tendermint/tendermint/light" connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" diff --git a/x/ibc/07-tendermint/types/evidence_test.go b/x/ibc/07-tendermint/types/evidence_test.go index 815b583ddc4b..9dcc4998d527 100644 --- a/x/ibc/07-tendermint/types/evidence_test.go +++ b/x/ibc/07-tendermint/types/evidence_test.go @@ -6,6 +6,7 @@ import ( "github.com/tendermint/tendermint/crypto/tmhash" tmbytes "github.com/tendermint/tendermint/libs/bytes" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" @@ -139,7 +140,7 @@ func (suite *TendermintTestSuite) TestEvidenceValidateBasic() { }, func(ev *ibctmtypes.Evidence) error { // voteSet contains only altVal which is less than 2/3 of total power (height/1height) - wrongVoteSet := tmtypes.NewVoteSet(chainID, ev.Header1.Height, 1, tmtypes.PrecommitType, altValSet) + wrongVoteSet := tmtypes.NewVoteSet(chainID, ev.Header1.Height, 1, tmproto.PrecommitType, altValSet) var err error ev.Header1.Commit, err = tmtypes.MakeCommit(ev.Header1.Commit.BlockID, ev.Header2.Height, ev.Header1.Commit.Round, wrongVoteSet, altSigners, suite.now) return err @@ -156,7 +157,7 @@ func (suite *TendermintTestSuite) TestEvidenceValidateBasic() { }, func(ev *ibctmtypes.Evidence) error { // voteSet contains only altVal which is less than 2/3 of total power (height/1height) - wrongVoteSet := tmtypes.NewVoteSet(chainID, ev.Header2.Height, 1, tmtypes.PrecommitType, altValSet) + wrongVoteSet := tmtypes.NewVoteSet(chainID, ev.Header2.Height, 1, tmproto.PrecommitType, altValSet) var err error ev.Header2.Commit, err = tmtypes.MakeCommit(ev.Header2.Commit.BlockID, ev.Header2.Height, ev.Header2.Commit.Round, wrongVoteSet, altSigners, suite.now) return err diff --git a/x/ibc/07-tendermint/types/header.go b/x/ibc/07-tendermint/types/header.go index d82df6c3ce07..61b040f5b20c 100644 --- a/x/ibc/07-tendermint/types/header.go +++ b/x/ibc/07-tendermint/types/header.go @@ -3,7 +3,7 @@ package types import ( "bytes" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -59,6 +59,6 @@ func (h Header) ValidateBasic(chainID string) error { // ToABCIHeader parses the header to an ABCI header type. // NOTE: only for testing use. -func (h Header) ToABCIHeader() abci.Header { +func (h Header) ToABCIHeader() tmproto.Header { return tmtypes.TM2PB.Header(h.SignedHeader.Header) } diff --git a/x/ibc/07-tendermint/types/msgs.go b/x/ibc/07-tendermint/types/msgs.go index 6cc16c234781..e943dc4ff09e 100644 --- a/x/ibc/07-tendermint/types/msgs.go +++ b/x/ibc/07-tendermint/types/msgs.go @@ -5,7 +5,7 @@ import ( ics23 "github.com/confio/ics23/go" tmmath "github.com/tendermint/tendermint/libs/math" - lite "github.com/tendermint/tendermint/lite2" + lite "github.com/tendermint/tendermint/light" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" diff --git a/x/ibc/07-tendermint/types/msgs_test.go b/x/ibc/07-tendermint/types/msgs_test.go index 686dbfc2c5f3..9ad2f4e801f7 100644 --- a/x/ibc/07-tendermint/types/msgs_test.go +++ b/x/ibc/07-tendermint/types/msgs_test.go @@ -4,7 +4,7 @@ import ( ics23 "github.com/confio/ics23/go" "github.com/tendermint/tendermint/crypto/secp256k1" "github.com/tendermint/tendermint/libs/math" - lite "github.com/tendermint/tendermint/lite2" + lite "github.com/tendermint/tendermint/light" tmtypes "github.com/tendermint/tendermint/types" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/ibc/07-tendermint/types/tendermint_test.go b/x/ibc/07-tendermint/types/tendermint_test.go index 395d10d28575..ae15c2757d91 100644 --- a/x/ibc/07-tendermint/types/tendermint_test.go +++ b/x/ibc/07-tendermint/types/tendermint_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/suite" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" @@ -51,7 +51,7 @@ func (suite *TendermintTestSuite) SetupTest() { val := tmtypes.NewValidator(pubKey, 10) suite.valSet = tmtypes.NewValidatorSet([]*tmtypes.Validator{val}) suite.header = ibctmtypes.CreateTestHeader(chainID, height, suite.now, suite.valSet, []tmtypes.PrivValidator{suite.privVal}) - suite.ctx = app.BaseApp.NewContext(checkTx, abci.Header{Height: 1, Time: suite.now}) + suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 1, Time: suite.now}) } func TestTendermintTestSuite(t *testing.T) { diff --git a/x/ibc/07-tendermint/types/test_utils.go b/x/ibc/07-tendermint/types/test_utils.go index 316a44ff7a5e..dd4ecb17fb99 100644 --- a/x/ibc/07-tendermint/types/test_utils.go +++ b/x/ibc/07-tendermint/types/test_utils.go @@ -1,20 +1,20 @@ package types import ( + "math" "time" "github.com/tendermint/tendermint/crypto/tmhash" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + tmversion "github.com/tendermint/tendermint/proto/tendermint/version" tmtypes "github.com/tendermint/tendermint/types" - "github.com/tendermint/tendermint/version" ) -const maxInt = int(^uint(0) >> 1) - // Copied unimported test functions from tmtypes to use them here -func MakeBlockID(hash []byte, partSetSize int, partSetHash []byte) tmtypes.BlockID { +func MakeBlockID(hash []byte, partSetSize uint32, partSetHash []byte) tmtypes.BlockID { return tmtypes.BlockID{ Hash: hash, - PartsHeader: tmtypes.PartSetHeader{ + PartSetHeader: tmtypes.PartSetHeader{ Total: partSetSize, Hash: partSetHash, }, @@ -25,11 +25,11 @@ func MakeBlockID(hash []byte, partSetSize int, partSetHash []byte) tmtypes.Block func CreateTestHeader(chainID string, height int64, timestamp time.Time, valSet *tmtypes.ValidatorSet, signers []tmtypes.PrivValidator) Header { vsetHash := valSet.Hash() tmHeader := tmtypes.Header{ - Version: version.Consensus{Block: 2, App: 2}, + Version: tmversion.Consensus{Block: 2, App: 2}, ChainID: chainID, Height: height, Time: timestamp, - LastBlockID: MakeBlockID(make([]byte, tmhash.Size), maxInt, make([]byte, tmhash.Size)), + LastBlockID: MakeBlockID(make([]byte, tmhash.Size), math.MaxUint32, make([]byte, tmhash.Size)), LastCommitHash: tmhash.Sum([]byte("last_commit_hash")), DataHash: tmhash.Sum([]byte("data_hash")), ValidatorsHash: vsetHash, @@ -42,7 +42,7 @@ func CreateTestHeader(chainID string, height int64, timestamp time.Time, valSet } hhash := tmHeader.Hash() blockID := MakeBlockID(hhash, 3, tmhash.Sum([]byte("part_set"))) - voteSet := tmtypes.NewVoteSet(chainID, height, 1, tmtypes.PrecommitType, valSet) + voteSet := tmtypes.NewVoteSet(chainID, height, 1, tmproto.PrecommitType, valSet) commit, err := tmtypes.MakeCommit(blockID, height, 1, voteSet, signers, timestamp) if err != nil { panic(err) diff --git a/x/ibc/07-tendermint/update.go b/x/ibc/07-tendermint/update.go index 728fe1eaa8fe..c35debdc1df9 100644 --- a/x/ibc/07-tendermint/update.go +++ b/x/ibc/07-tendermint/update.go @@ -3,7 +3,7 @@ package tendermint import ( "time" - lite "github.com/tendermint/tendermint/lite2" + lite "github.com/tendermint/tendermint/light" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" diff --git a/x/ibc/07-tendermint/update_test.go b/x/ibc/07-tendermint/update_test.go index c2c48e135f90..ffc13b9a62a9 100644 --- a/x/ibc/07-tendermint/update_test.go +++ b/x/ibc/07-tendermint/update_test.go @@ -4,7 +4,7 @@ import ( "bytes" "time" - lite "github.com/tendermint/tendermint/lite2" + lite "github.com/tendermint/tendermint/light" tmtypes "github.com/tendermint/tendermint/types" tendermint "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint" diff --git a/x/ibc/09-localhost/types/localhost_test.go b/x/ibc/09-localhost/types/localhost_test.go index 30111397a17b..349c2e8a533b 100644 --- a/x/ibc/09-localhost/types/localhost_test.go +++ b/x/ibc/09-localhost/types/localhost_test.go @@ -4,8 +4,7 @@ import ( "testing" "github.com/stretchr/testify/suite" - - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/simapp" @@ -31,7 +30,7 @@ func (suite *LocalhostTestSuite) SetupTest() { suite.aminoCdc = app.Codec() suite.cdc = app.AppCodec() - ctx := app.BaseApp.NewContext(isCheckTx, abci.Header{Height: 1}) + ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{Height: 1}) suite.store = app.IBCKeeper.ClientKeeper.ClientStore(ctx, clientexported.ClientTypeLocalHost) } diff --git a/x/ibc/23-commitment/types/commitment.pb.go b/x/ibc/23-commitment/types/commitment.pb.go index f5c8784e0e22..a6e96584cc50 100644 --- a/x/ibc/23-commitment/types/commitment.pb.go +++ b/x/ibc/23-commitment/types/commitment.pb.go @@ -7,7 +7,7 @@ import ( fmt "fmt" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" - merkle "github.com/tendermint/tendermint/crypto/merkle" + merkle "github.com/tendermint/tendermint/proto/tendermint/crypto" io "io" math "math" math_bits "math/bits" @@ -183,7 +183,7 @@ func (m *MerklePath) GetKeyPath() KeyPath { // verifiable in conjunction with a known commitment root. Proofs should be // succinct. type MerkleProof struct { - Proof *merkle.Proof `protobuf:"bytes,1,opt,name=proof,proto3" json:"proof,omitempty"` + Proof *merkle.ProofOps `protobuf:"bytes,1,opt,name=proof,proto3" json:"proof,omitempty"` } func (m *MerkleProof) Reset() { *m = MerkleProof{} } @@ -219,7 +219,7 @@ func (m *MerkleProof) XXX_DiscardUnknown() { var xxx_messageInfo_MerkleProof proto.InternalMessageInfo -func (m *MerkleProof) GetProof() *merkle.Proof { +func (m *MerkleProof) GetProof() *merkle.ProofOps { if m != nil { return m.Proof } @@ -316,64 +316,40 @@ func init() { proto.RegisterFile("ibc/commitment/commitment.proto", fileDescript var fileDescriptor_71f36b3839a24c54 = []byte{ // 509 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0x31, 0x6f, 0xd3, 0x40, - 0x14, 0xc7, 0x6d, 0x62, 0x48, 0xb8, 0x54, 0x25, 0x1c, 0xa0, 0x46, 0xa1, 0xd8, 0x91, 0x25, 0x20, - 0x20, 0xd5, 0x96, 0x52, 0xe8, 0x10, 0x31, 0xa5, 0x31, 0x34, 0xa4, 0x84, 0xe8, 0x50, 0xa4, 0xc2, - 0x12, 0x39, 0xce, 0x35, 0xb6, 0x5c, 0xfb, 0x2c, 0xfb, 0x90, 0xea, 0x6f, 0x50, 0x31, 0x31, 0xb2, - 0x20, 0x55, 0x82, 0x81, 0x8f, 0xd2, 0xb1, 0x23, 0x93, 0x85, 0x9c, 0x85, 0xb9, 0x9f, 0xa0, 0xba, - 0x3b, 0x57, 0x49, 0xa5, 0x2e, 0x77, 0xef, 0xf9, 0xfd, 0xfc, 0xde, 0xdf, 0x7f, 0x3f, 0xa0, 0x79, - 0x53, 0xc7, 0x74, 0x48, 0x10, 0x78, 0x34, 0xc0, 0x21, 0x5d, 0x09, 0x8d, 0x28, 0x26, 0x94, 0xc0, - 0x75, 0x6f, 0xea, 0x18, 0xcb, 0xa7, 0x8d, 0x87, 0x73, 0x32, 0x27, 0xbc, 0x64, 0xb2, 0x48, 0x50, - 0x8d, 0xa7, 0x14, 0x87, 0x33, 0x1c, 0x07, 0x1e, 0x6b, 0x11, 0xa7, 0x11, 0x25, 0x66, 0x80, 0x63, - 0xff, 0x08, 0x17, 0x97, 0xc0, 0xf4, 0x67, 0x00, 0x7c, 0xe0, 0x39, 0x22, 0x84, 0x42, 0x08, 0x14, - 0xd7, 0x4e, 0xdc, 0xba, 0xdc, 0x94, 0x5b, 0x6b, 0x88, 0xc7, 0x1d, 0xe5, 0xe4, 0x54, 0x93, 0xf4, - 0x1e, 0x58, 0x13, 0xdc, 0x28, 0xc6, 0x87, 0xde, 0x31, 0x7c, 0x05, 0x80, 0x8f, 0xd3, 0x49, 0xc4, - 0x33, 0xc1, 0x77, 0x1f, 0x5d, 0x64, 0xda, 0xfd, 0xd4, 0x0e, 0x8e, 0x3a, 0xfa, 0xb2, 0xa6, 0xa3, - 0xbb, 0x3e, 0x4e, 0xc5, 0x5b, 0xfa, 0xe4, 0x6a, 0xda, 0xc8, 0xa6, 0x2e, 0x1c, 0x80, 0x0a, 0xe7, - 0x6c, 0x2a, 0x26, 0x56, 0xdb, 0x1b, 0xc6, 0xf5, 0x6f, 0x33, 0x06, 0x38, 0x65, 0x68, 0x77, 0xe3, - 0x2c, 0xd3, 0xa4, 0x8b, 0x4c, 0xbb, 0xb7, 0xd2, 0xde, 0xa6, 0xae, 0x8e, 0xca, 0xbe, 0x20, 0x3a, - 0xca, 0x0f, 0x26, 0xf3, 0x3d, 0xa8, 0x5e, 0xc9, 0x24, 0xe4, 0x10, 0xbe, 0x06, 0xb7, 0x23, 0x16, - 0x14, 0xed, 0x35, 0x63, 0x69, 0x8a, 0x21, 0x4c, 0x31, 0x0a, 0x37, 0x38, 0x8f, 0x04, 0xdd, 0x51, - 0xfe, 0x9f, 0x6a, 0xb2, 0xfe, 0x06, 0x94, 0x8b, 0xf1, 0xf0, 0x39, 0x50, 0x7c, 0x9c, 0x26, 0x75, - 0xb9, 0x59, 0x6a, 0x55, 0xdb, 0x0f, 0x6e, 0x50, 0x89, 0x38, 0xd0, 0xa9, 0x30, 0xb3, 0xb8, 0x12, - 0x1b, 0x94, 0x06, 0x38, 0x85, 0x9b, 0x40, 0x09, 0xed, 0x00, 0x17, 0x0e, 0x55, 0xf2, 0x4c, 0xe3, - 0x39, 0xe2, 0x27, 0xdc, 0x01, 0x25, 0x1c, 0x3a, 0xf5, 0x5b, 0x4d, 0xb9, 0xb5, 0xde, 0x7e, 0x7c, - 0x43, 0x5b, 0x2b, 0x74, 0xc8, 0xcc, 0x0b, 0xe7, 0xdd, 0x72, 0x9e, 0x69, 0x8c, 0x45, 0xec, 0x10, - 0xff, 0xe4, 0xa5, 0x0d, 0xaa, 0x2b, 0x08, 0x7c, 0x01, 0x36, 0x07, 0xd6, 0xe7, 0x89, 0x35, 0xdc, - 0xfd, 0xd8, 0xeb, 0x0f, 0xdf, 0x4d, 0xc6, 0x68, 0x7f, 0x32, 0x1e, 0x7e, 0x1a, 0x59, 0xbb, 0xfd, - 0xb7, 0x7d, 0xab, 0x57, 0x93, 0x1a, 0xe5, 0x6f, 0x3f, 0x9b, 0xa5, 0x31, 0xda, 0x87, 0x4f, 0x40, - 0xed, 0x1a, 0xba, 0x67, 0x1d, 0xd4, 0x64, 0x51, 0xde, 0xb3, 0x0e, 0x1a, 0x95, 0x93, 0x5f, 0xaa, - 0xf4, 0xe7, 0xb7, 0x2a, 0x75, 0x47, 0x67, 0xb9, 0x2a, 0x9f, 0xe7, 0xaa, 0xfc, 0x2f, 0x57, 0xe5, - 0xef, 0x0b, 0x55, 0x3a, 0x5f, 0xa8, 0xd2, 0xdf, 0x85, 0x2a, 0x7d, 0xd9, 0x99, 0x7b, 0xd4, 0xfd, - 0x3a, 0x65, 0x7a, 0x4d, 0x87, 0x24, 0x01, 0x49, 0x8a, 0x6b, 0x2b, 0x99, 0xf9, 0xe6, 0xb1, 0xc9, - 0xb6, 0xb8, 0xbd, 0xbd, 0xb5, 0xb2, 0xc8, 0x34, 0x8d, 0x70, 0x32, 0xbd, 0xc3, 0xf7, 0x6e, 0xfb, - 0x32, 0x00, 0x00, 0xff, 0xff, 0xef, 0xa1, 0xaa, 0x6d, 0xe7, 0x02, 0x00, 0x00, -} - -func (this *MerkleProof) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*MerkleProof) - if !ok { - that2, ok := that.(MerkleProof) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if !this.Proof.Equal(that1.Proof) { - return false - } - return true + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0x41, 0x6f, 0xd3, 0x30, + 0x14, 0xc7, 0x13, 0x1a, 0x68, 0x71, 0xa7, 0x51, 0x0c, 0x68, 0x55, 0x19, 0x49, 0x15, 0x21, 0x28, + 0x48, 0x4b, 0xa4, 0x0e, 0x4d, 0xa8, 0xe2, 0xd4, 0x35, 0x6c, 0x55, 0x47, 0x57, 0x19, 0x55, 0x1a, + 0x5c, 0xa2, 0x34, 0xf5, 0x9a, 0x28, 0x4b, 0x1c, 0x25, 0x46, 0x5a, 0xbe, 0xc1, 0xc4, 0x89, 0x23, + 0x17, 0x24, 0x24, 0x38, 0xf0, 0x51, 0x76, 0xdc, 0x91, 0x53, 0x84, 0xd2, 0x6f, 0xb0, 0x4f, 0x80, + 0x6c, 0x77, 0x6a, 0x27, 0xf5, 0xe2, 0x3c, 0xfb, 0xfd, 0xfc, 0xde, 0x3f, 0x7f, 0x3f, 0xa0, 0xf9, + 0x13, 0xd7, 0x74, 0x49, 0x18, 0xfa, 0x34, 0xc4, 0x11, 0x5d, 0x09, 0x8d, 0x38, 0x21, 0x94, 0xc0, + 0x4d, 0x7f, 0xe2, 0x1a, 0xcb, 0xd3, 0xc6, 0xe3, 0x19, 0x99, 0x11, 0x9e, 0x32, 0x59, 0x24, 0xa8, + 0xc6, 0x73, 0x8a, 0xa3, 0x29, 0x4e, 0x42, 0x9f, 0x95, 0x48, 0xb2, 0x98, 0x12, 0x33, 0xc4, 0x49, + 0x70, 0x86, 0x4d, 0x9a, 0xc5, 0x38, 0x15, 0x94, 0xfe, 0x02, 0x80, 0x0f, 0xfc, 0x14, 0x11, 0x42, + 0x21, 0x04, 0x8a, 0xe7, 0xa4, 0x5e, 0x5d, 0x6e, 0xca, 0xad, 0x0d, 0xc4, 0xe3, 0x8e, 0x72, 0xf1, + 0x53, 0x93, 0xf4, 0x1e, 0xd8, 0x10, 0xdc, 0x28, 0xc1, 0xa7, 0xfe, 0x39, 0x7c, 0x03, 0x40, 0x80, + 0x33, 0x3b, 0xe6, 0x3b, 0xc1, 0x77, 0x9f, 0x5c, 0xe7, 0xda, 0xc3, 0xcc, 0x09, 0xcf, 0x3a, 0xfa, + 0x32, 0xa7, 0xa3, 0xfb, 0x01, 0xce, 0xc4, 0x2d, 0xdd, 0xbe, 0xe9, 0x36, 0x72, 0xa8, 0x07, 0x07, + 0xa0, 0xc2, 0x39, 0x87, 0x8a, 0x8e, 0xd5, 0xf6, 0x96, 0x71, 0xfb, 0xd7, 0x8c, 0x01, 0xce, 0x18, + 0xda, 0xdd, 0xba, 0xcc, 0x35, 0xe9, 0x3a, 0xd7, 0x1e, 0xac, 0x94, 0x77, 0xa8, 0xa7, 0xa3, 0x72, + 0x20, 0x88, 0x8e, 0xf2, 0x9d, 0xc9, 0x3c, 0x00, 0xd5, 0x1b, 0x99, 0x84, 0x9c, 0xc2, 0xb7, 0xe0, + 0x6e, 0xcc, 0x82, 0x45, 0x79, 0xdd, 0x58, 0x7a, 0x62, 0x08, 0x4f, 0x0c, 0xe1, 0x89, 0xc1, 0xf9, + 0xe3, 0x38, 0x45, 0xe2, 0x82, 0xfe, 0x0e, 0x94, 0x17, 0xbd, 0xe1, 0x4b, 0xa0, 0x04, 0x38, 0x4b, + 0xeb, 0x72, 0xb3, 0xd4, 0xaa, 0xb6, 0x1f, 0xad, 0x91, 0x88, 0x38, 0xd0, 0xa9, 0x30, 0xa7, 0xb8, + 0x0c, 0x07, 0x94, 0x06, 0x38, 0x83, 0xdb, 0x40, 0x89, 0x9c, 0x10, 0x2f, 0xec, 0xa9, 0x14, 0xb9, + 0xc6, 0xf7, 0x88, 0xaf, 0x70, 0x0f, 0x94, 0x70, 0xe4, 0xd6, 0xef, 0x34, 0xe5, 0xd6, 0x66, 0xfb, + 0xe9, 0x9a, 0xb2, 0x56, 0xe4, 0x92, 0xa9, 0x1f, 0xcd, 0xba, 0xe5, 0x22, 0xd7, 0x18, 0x8b, 0xd8, + 0x22, 0x1e, 0xe4, 0xb5, 0x03, 0xaa, 0x2b, 0x08, 0x7c, 0x05, 0xb6, 0x07, 0xd6, 0x27, 0xdb, 0x1a, + 0xee, 0x1f, 0xf7, 0xfa, 0xc3, 0x03, 0x7b, 0x8c, 0x8e, 0xec, 0xf1, 0xf0, 0xe3, 0xc8, 0xda, 0xef, + 0xbf, 0xef, 0x5b, 0xbd, 0x9a, 0xd4, 0x28, 0x7f, 0xfd, 0xd1, 0x2c, 0x8d, 0xd1, 0x11, 0x7c, 0x06, + 0x6a, 0xb7, 0xd0, 0x43, 0xeb, 0xa4, 0x26, 0x8b, 0xf4, 0xa1, 0x75, 0xd2, 0xa8, 0x5c, 0xfc, 0x52, + 0xa5, 0x3f, 0xbf, 0x55, 0xa9, 0x3b, 0xba, 0x2c, 0x54, 0xf9, 0xaa, 0x50, 0xe5, 0x7f, 0x85, 0x2a, + 0x7f, 0x9b, 0xab, 0xd2, 0xd5, 0x5c, 0x95, 0xfe, 0xce, 0x55, 0xe9, 0xf3, 0xde, 0xcc, 0xa7, 0xde, + 0x97, 0x09, 0xd3, 0x6b, 0xba, 0x24, 0x0d, 0x49, 0xba, 0xf8, 0xec, 0xa4, 0xd3, 0xc0, 0x3c, 0x37, + 0xd9, 0x04, 0xb7, 0x77, 0x77, 0x56, 0x86, 0x98, 0xcf, 0xdc, 0xe4, 0x1e, 0x1f, 0xba, 0xdd, 0xff, + 0x01, 0x00, 0x00, 0xff, 0xff, 0xab, 0x47, 0xa6, 0xaf, 0xe3, 0x02, 0x00, 0x00, } + func (m *MerkleRoot) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -991,7 +967,7 @@ func (m *MerkleProof) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Proof == nil { - m.Proof = &merkle.Proof{} + m.Proof = &merkle.ProofOps{} } if err := m.Proof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/x/ibc/23-commitment/types/merkle.go b/x/ibc/23-commitment/types/merkle.go index e8c7a44228f6..b30c296dd76b 100644 --- a/x/ibc/23-commitment/types/merkle.go +++ b/x/ibc/23-commitment/types/merkle.go @@ -5,12 +5,12 @@ import ( "net/url" ics23 "github.com/confio/ics23/go" + "github.com/gogo/protobuf/proto" + tmmerkle "github.com/tendermint/tendermint/proto/tendermint/crypto" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/exported" host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" - - "github.com/tendermint/tendermint/crypto/merkle" ) // var representing the proofspecs for a SDK chain @@ -366,7 +366,7 @@ func convertProofs(mproof MerkleProof) ([]*ics23.CommitmentProof, error) { // Empty returns true if the root is empty func (proof MerkleProof) Empty() bool { - return proof.Proof.Equal(nil) || proof.Equal(MerkleProof{}) || proof.Proof.Equal(nil) || proof.Proof.Equal(merkle.Proof{}) + return proto.Equal(proof.Proof, nil) || proto.Equal(&proof, &MerkleProof{}) || proto.Equal(proof.Proof, nil) || proto.Equal(proof.Proof, &tmmerkle.ProofOps{}) } // ValidateBasic checks if the proof is empty. diff --git a/x/ibc/23-commitment/types/merkle_test.go b/x/ibc/23-commitment/types/merkle_test.go index bc5fa341a664..d621a19bdf81 100644 --- a/x/ibc/23-commitment/types/merkle_test.go +++ b/x/ibc/23-commitment/types/merkle_test.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/crypto/merkle" + tmmerkle "github.com/tendermint/tendermint/proto/tendermint/crypto" ) func (suite *MerkleTestSuite) TestVerifyMembership() { @@ -21,10 +21,10 @@ func (suite *MerkleTestSuite) TestVerifyMembership() { Data: []byte("MYKEY"), Prove: true, }) - require.NotNil(suite.T(), res.Proof) + require.NotNil(suite.T(), res.ProofOps) proof := types.MerkleProof{ - Proof: res.Proof, + Proof: res.ProofOps, } suite.Require().NoError(proof.ValidateBasic()) suite.Require().Error(types.MerkleProof{}.ValidateBasic()) @@ -49,8 +49,8 @@ func (suite *MerkleTestSuite) TestVerifyMembership() { {"nil root", []byte(nil), []string{suite.storeKey.Name(), "MYKEY"}, []byte("MYVALUE"), func() {}, false}, // invalid proof with nil root {"proof is wrong length", cid.Hash, []string{suite.storeKey.Name(), "MYKEY"}, []byte("MYVALUE"), func() { proof = types.MerkleProof{ - Proof: &merkle.Proof{ - Ops: res.Proof.Ops[1:], + Proof: &tmmerkle.ProofOps{ + Ops: res.ProofOps.Ops[1:], }, } }, false}, // invalid proof with wrong length @@ -89,10 +89,10 @@ func (suite *MerkleTestSuite) TestVerifyNonMembership() { Data: []byte("MYABSENTKEY"), Prove: true, }) - require.NotNil(suite.T(), res.Proof) + require.NotNil(suite.T(), res.ProofOps) proof := types.MerkleProof{ - Proof: res.Proof, + Proof: res.ProofOps, } suite.Require().NoError(proof.ValidateBasic()) @@ -114,8 +114,8 @@ func (suite *MerkleTestSuite) TestVerifyNonMembership() { {"nil root", []byte(nil), []string{suite.storeKey.Name(), "MYABSENTKEY"}, func() {}, false}, // invalid proof with nil root {"proof is wrong length", cid.Hash, []string{suite.storeKey.Name(), "MYKEY"}, func() { proof = types.MerkleProof{ - Proof: &merkle.Proof{ - Ops: res.Proof.Ops[1:], + Proof: &tmmerkle.ProofOps{ + Ops: res.ProofOps.Ops[1:], }, } }, false}, // invalid proof with wrong length diff --git a/x/ibc/genesis_test.go b/x/ibc/genesis_test.go index 3814884425d6..4341b4e90999 100644 --- a/x/ibc/genesis_test.go +++ b/x/ibc/genesis_test.go @@ -1,7 +1,7 @@ package ibc_test import ( - lite "github.com/tendermint/tendermint/lite2" + lite "github.com/tendermint/tendermint/light" "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" diff --git a/x/ibc/ibc_test.go b/x/ibc/ibc_test.go index 55f96c2d80c9..2ebde9a284ab 100644 --- a/x/ibc/ibc_test.go +++ b/x/ibc/ibc_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/suite" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" @@ -61,7 +61,7 @@ func (suite *IBCTestSuite) SetupTest() { suite.header = ibctmtypes.CreateTestHeader("chainID", 10, now, valSet, []tmtypes.PrivValidator{privVal}) suite.cdc = suite.app.Codec() - suite.ctx = suite.app.BaseApp.NewContext(isCheckTx, abci.Header{}) + suite.ctx = suite.app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) } func TestIBCTestSuite(t *testing.T) { diff --git a/x/ibc/keeper/keeper_test.go b/x/ibc/keeper/keeper_test.go index 941b20eb7845..01a62f639589 100644 --- a/x/ibc/keeper/keeper_test.go +++ b/x/ibc/keeper/keeper_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/suite" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/simapp" @@ -28,7 +28,7 @@ func (suite *KeeperTestSuite) SetupTest() { legacyQuerierCdc := codec.NewAminoCodec(app.Codec()) suite.cdc = app.Codec() - suite.ctx = app.BaseApp.NewContext(isCheckTx, abci.Header{}) + suite.ctx = app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) suite.keeper = app.IBCKeeper suite.querier = keeper.NewQuerier(*app.IBCKeeper, legacyQuerierCdc) } diff --git a/x/ibc/simulation/decoder.go b/x/ibc/simulation/decoder.go index cb8a3d1ee763..29048025ab61 100644 --- a/x/ibc/simulation/decoder.go +++ b/x/ibc/simulation/decoder.go @@ -3,9 +3,8 @@ package simulation import ( "fmt" - tmkv "github.com/tendermint/tendermint/libs/kv" - "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/types/kv" clientsim "github.com/cosmos/cosmos-sdk/x/ibc/02-client/simulation" connectionsim "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/simulation" channelsim "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/simulation" @@ -14,8 +13,8 @@ import ( // NewDecodeStore returns a decoder function closure that unmarshals the KVPair's // Value to the corresponding ibc type. -func NewDecodeStore(cdc codec.BinaryMarshaler, aminoCdc *codec.Codec) func(kvA, kvB tmkv.Pair) string { - return func(kvA, kvB tmkv.Pair) string { +func NewDecodeStore(cdc codec.BinaryMarshaler, aminoCdc *codec.Codec) func(kvA, kvB kv.Pair) string { + return func(kvA, kvB kv.Pair) string { if res, found := clientsim.NewDecodeStore(aminoCdc, kvA, kvB); found { return res } diff --git a/x/ibc/simulation/decoder_test.go b/x/ibc/simulation/decoder_test.go index 0dc926d142f3..0f9360e4cb90 100644 --- a/x/ibc/simulation/decoder_test.go +++ b/x/ibc/simulation/decoder_test.go @@ -5,9 +5,9 @@ import ( "testing" "github.com/stretchr/testify/require" - tmkv "github.com/tendermint/tendermint/libs/kv" "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/types/kv" connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" @@ -40,20 +40,20 @@ func TestDecodeStore(t *testing.T) { Version: "1.0", } - kvPairs := tmkv.Pairs{ - tmkv.Pair{ + kvPairs := kv.Pairs{ + kv.Pair{ Key: host.FullKeyClientPath(clientID, host.KeyClientState()), Value: aminoCdc.MustMarshalBinaryBare(clientState), }, - tmkv.Pair{ + kv.Pair{ Key: host.KeyConnection(connectionID), Value: cdc.MustMarshalBinaryBare(&connection), }, - tmkv.Pair{ + kv.Pair{ Key: host.KeyChannel(portID, channelID), Value: cdc.MustMarshalBinaryBare(&channel), }, - tmkv.Pair{ + kv.Pair{ Key: []byte{0x99}, Value: []byte{0x99}, }, diff --git a/x/ibc/testing/chain.go b/x/ibc/testing/chain.go index fb87c694add8..20ddc32ae3ac 100644 --- a/x/ibc/testing/chain.go +++ b/x/ibc/testing/chain.go @@ -2,6 +2,7 @@ package testing import ( "fmt" + "math" "strconv" "testing" "time" @@ -14,9 +15,10 @@ import ( "github.com/tendermint/tendermint/crypto/secp256k1" "github.com/tendermint/tendermint/crypto/tmhash" tmmath "github.com/tendermint/tendermint/libs/math" - lite "github.com/tendermint/tendermint/lite2" + lite "github.com/tendermint/tendermint/light" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + tmversion "github.com/tendermint/tendermint/proto/tendermint/version" tmtypes "github.com/tendermint/tendermint/types" - "github.com/tendermint/tendermint/version" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/simapp" @@ -46,8 +48,6 @@ const ( InvalidID = "IDisInvalid" ConnectionIDPrefix = "connectionid" - - maxInt = int(^uint(0) >> 1) ) var ( @@ -68,7 +68,7 @@ type TestChain struct { App *simapp.SimApp ChainID string LastHeader ibctmtypes.Header // header for last block height committed - CurrentHeader abci.Header // header for current block height + CurrentHeader tmproto.Header // header for current block height Querier sdk.Querier // TODO: deprecate once clients are migrated to gRPC QueryServer types.QueryServer TxConfig client.TxConfig @@ -115,7 +115,7 @@ func NewTestChain(t *testing.T, chainID string) *TestChain { legacyQuerierCdc := codec.NewAminoCodec(app.Codec()) // create current header and call begin block - header := abci.Header{ + header := tmproto.Header{ Height: 1, Time: globalStartTime, } @@ -160,7 +160,7 @@ func (chain *TestChain) QueryProof(key []byte) ([]byte, uint64) { }) merkleProof := commitmenttypes.MerkleProof{ - Proof: res.Proof, + Proof: res.ProofOps, } proof, err := chain.App.AppCodec().MarshalBinaryBare(&merkleProof) @@ -195,7 +195,7 @@ func (chain *TestChain) NextBlock() { chain.LastHeader = chain.CreateTMClientHeader() // increment the current header - chain.CurrentHeader = abci.Header{ + chain.CurrentHeader = tmproto.Header{ Height: chain.App.LastBlockHeight() + 1, AppHash: chain.App.LastCommitID().Hash, // NOTE: the time is increased by the coordinator to maintain time synchrony amongst @@ -342,11 +342,11 @@ func (chain *TestChain) UpdateTMClient(counterparty *TestChain, clientID string) func (chain *TestChain) CreateTMClientHeader() ibctmtypes.Header { vsetHash := chain.Vals.Hash() tmHeader := tmtypes.Header{ - Version: version.Consensus{Block: 2, App: 2}, + Version: tmversion.Consensus{Block: 2, App: 2}, ChainID: chain.ChainID, Height: chain.CurrentHeader.Height, Time: chain.CurrentHeader.Time, - LastBlockID: MakeBlockID(make([]byte, tmhash.Size), maxInt, make([]byte, tmhash.Size)), + LastBlockID: MakeBlockID(make([]byte, tmhash.Size), math.MaxUint32, make([]byte, tmhash.Size)), LastCommitHash: chain.App.LastCommitID().Hash, DataHash: tmhash.Sum([]byte("data_hash")), ValidatorsHash: vsetHash, @@ -361,7 +361,7 @@ func (chain *TestChain) CreateTMClientHeader() ibctmtypes.Header { blockID := MakeBlockID(hhash, 3, tmhash.Sum([]byte("part_set"))) - voteSet := tmtypes.NewVoteSet(chain.ChainID, chain.CurrentHeader.Height, 1, tmtypes.PrecommitType, chain.Vals) + voteSet := tmtypes.NewVoteSet(chain.ChainID, chain.CurrentHeader.Height, 1, tmproto.PrecommitType, chain.Vals) commit, err := tmtypes.MakeCommit(blockID, chain.CurrentHeader.Height, 1, voteSet, chain.Signers, chain.CurrentHeader.Time) require.NoError(chain.t, err) @@ -378,10 +378,10 @@ func (chain *TestChain) CreateTMClientHeader() ibctmtypes.Header { } // Copied unimported test functions from tmtypes to use them here -func MakeBlockID(hash []byte, partSetSize int, partSetHash []byte) tmtypes.BlockID { +func MakeBlockID(hash []byte, partSetSize uint32, partSetHash []byte) tmtypes.BlockID { return tmtypes.BlockID{ Hash: hash, - PartsHeader: tmtypes.PartSetHeader{ + PartSetHeader: tmtypes.PartSetHeader{ Total: partSetSize, Hash: partSetHash, }, diff --git a/x/mint/keeper/grpc_query_test.go b/x/mint/keeper/grpc_query_test.go index f63b248a288a..11b627669438 100644 --- a/x/mint/keeper/grpc_query_test.go +++ b/x/mint/keeper/grpc_query_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/stretchr/testify/suite" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/simapp" @@ -23,7 +23,7 @@ type MintTestSuite struct { func (suite *MintTestSuite) SetupTest() { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry()) types.RegisterQueryServer(queryHelper, app.MintKeeper) diff --git a/x/mint/keeper/integration_test.go b/x/mint/keeper/integration_test.go index db1efaca3f12..df321c33bd0c 100644 --- a/x/mint/keeper/integration_test.go +++ b/x/mint/keeper/integration_test.go @@ -1,7 +1,7 @@ package keeper_test import ( - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -12,7 +12,7 @@ import ( func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) { app := simapp.Setup(isCheckTx) - ctx := app.BaseApp.NewContext(isCheckTx, abci.Header{}) + ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) app.MintKeeper.SetParams(ctx, types.DefaultParams()) app.MintKeeper.SetMinter(ctx, types.DefaultInitialMinter()) diff --git a/x/mint/module_test.go b/x/mint/module_test.go index 92e22d4986b9..3b2df369e661 100644 --- a/x/mint/module_test.go +++ b/x/mint/module_test.go @@ -5,6 +5,7 @@ import ( "github.com/stretchr/testify/require" abcitypes "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -13,7 +14,7 @@ import ( func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abcitypes.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) app.InitChain( abcitypes.RequestInitChain{ diff --git a/x/mint/simulation/decoder.go b/x/mint/simulation/decoder.go index 49ca7a56fc54..37d9930f7da5 100644 --- a/x/mint/simulation/decoder.go +++ b/x/mint/simulation/decoder.go @@ -4,16 +4,15 @@ import ( "bytes" "fmt" - tmkv "github.com/tendermint/tendermint/libs/kv" - "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/x/mint/types" ) // NewDecodeStore returns a decoder function closure that umarshals the KVPair's // Value to the corresponding mint type. -func NewDecodeStore(cdc codec.Marshaler) func(kvA, kvB tmkv.Pair) string { - return func(kvA, kvB tmkv.Pair) string { +func NewDecodeStore(cdc codec.Marshaler) func(kvA, kvB kv.Pair) string { + return func(kvA, kvB kv.Pair) string { switch { case bytes.Equal(kvA.Key, types.MinterKey): var minterA, minterB types.Minter diff --git a/x/mint/simulation/decoder_test.go b/x/mint/simulation/decoder_test.go index 0d69dc331b03..f67b3bb8ad6d 100644 --- a/x/mint/simulation/decoder_test.go +++ b/x/mint/simulation/decoder_test.go @@ -6,10 +6,9 @@ import ( "github.com/stretchr/testify/require" - tmkv "github.com/tendermint/tendermint/libs/kv" - "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/x/mint/simulation" "github.com/cosmos/cosmos-sdk/x/mint/types" ) @@ -20,9 +19,9 @@ func TestDecodeStore(t *testing.T) { minter := types.NewMinter(sdk.OneDec(), sdk.NewDec(15)) - kvPairs := tmkv.Pairs{ - tmkv.Pair{Key: types.MinterKey, Value: cdc.MustMarshalBinaryBare(&minter)}, - tmkv.Pair{Key: []byte{0x99}, Value: []byte{0x99}}, + kvPairs := kv.Pairs{ + kv.Pair{Key: types.MinterKey, Value: cdc.MustMarshalBinaryBare(&minter)}, + kv.Pair{Key: []byte{0x99}, Value: []byte{0x99}}, } tests := []struct { name string diff --git a/x/params/keeper/common_test.go b/x/params/keeper/common_test.go index c6c151809c37..8193c6fa0ae2 100644 --- a/x/params/keeper/common_test.go +++ b/x/params/keeper/common_test.go @@ -1,8 +1,8 @@ package keeper_test import ( - abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/codec" @@ -45,6 +45,6 @@ func defaultContext(key sdk.StoreKey, tkey sdk.StoreKey) sdk.Context { if err != nil { panic(err) } - ctx := sdk.NewContext(cms, abci.Header{}, false, log.NewNopLogger()) + ctx := sdk.NewContext(cms, tmproto.Header{}, false, log.NewNopLogger()) return ctx } diff --git a/x/params/keeper/keeper_test.go b/x/params/keeper/keeper_test.go index b30783fbd80a..44c8223f2c25 100644 --- a/x/params/keeper/keeper_test.go +++ b/x/params/keeper/keeper_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/simapp" @@ -40,7 +40,7 @@ func TestKeeperTestSuite(t *testing.T) { // returns context and app func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) { app := simapp.Setup(isCheckTx) - ctx := app.BaseApp.NewContext(isCheckTx, abci.Header{}) + ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) return app, ctx } diff --git a/x/params/proposal_handler_test.go b/x/params/proposal_handler_test.go index ddbb81fb7cc4..857f16db0251 100644 --- a/x/params/proposal_handler_test.go +++ b/x/params/proposal_handler_test.go @@ -5,8 +5,8 @@ import ( "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/codec" @@ -76,7 +76,7 @@ func newTestInput(t *testing.T) testInput { require.Nil(t, err) keeper := keeper.NewKeeper(proposal.ModuleCdc, keyParams, tKeyParams) - ctx := sdk.NewContext(cms, abci.Header{}, false, log.NewNopLogger()) + ctx := sdk.NewContext(cms, tmproto.Header{}, false, log.NewNopLogger()) return testInput{ctx, cdc, keeper} } diff --git a/x/params/simulation/operations_test.go b/x/params/simulation/operations_test.go index a7aecfdbda5e..54c90a6c2e3d 100644 --- a/x/params/simulation/operations_test.go +++ b/x/params/simulation/operations_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" @@ -43,7 +43,7 @@ func TestSimulateParamChangeProposalContent(t *testing.T) { s := rand.NewSource(1) r := rand.New(s) - ctx := sdk.NewContext(nil, abci.Header{}, true, nil) + ctx := sdk.NewContext(nil, tmproto.Header{}, true, nil) accounts := simtypes.RandomAccounts(r, 3) paramChangePool := []simtypes.ParamChange{MockParamChange{1}, MockParamChange{2}, MockParamChange{3}} diff --git a/x/params/simulation/proposals_test.go b/x/params/simulation/proposals_test.go index 0b84aa07f99e..e89bb668a489 100644 --- a/x/params/simulation/proposals_test.go +++ b/x/params/simulation/proposals_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" sdk "github.com/cosmos/cosmos-sdk/types" @@ -19,7 +19,7 @@ func TestProposalContents(t *testing.T) { s := rand.NewSource(1) r := rand.New(s) - ctx := sdk.NewContext(nil, abci.Header{}, true, nil) + ctx := sdk.NewContext(nil, tmproto.Header{}, true, nil) accounts := simtypes.RandomAccounts(r, 3) paramChangePool := []simtypes.ParamChange{MockParamChange{1}, MockParamChange{2}, MockParamChange{3}} diff --git a/x/params/types/subspace_test.go b/x/params/types/subspace_test.go index d7c30ba18f65..bd14aa698a26 100644 --- a/x/params/types/subspace_test.go +++ b/x/params/types/subspace_test.go @@ -6,8 +6,8 @@ import ( "time" "github.com/stretchr/testify/suite" - abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/codec" @@ -37,7 +37,7 @@ func (suite *SubspaceTestSuite) SetupTest() { ss := types.NewSubspace(cdc, key, tkey, "testsubspace") suite.cdc = cdc - suite.ctx = sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger()) + suite.ctx = sdk.NewContext(ms, tmproto.Header{}, false, log.NewNopLogger()) suite.ss = ss.WithKeyTable(paramKeyTable()) } diff --git a/x/simulation/mock_tendermint.go b/x/simulation/mock_tendermint.go index 0a16147d24c9..a0d8913fa1e4 100644 --- a/x/simulation/mock_tendermint.go +++ b/x/simulation/mock_tendermint.go @@ -8,7 +8,9 @@ import ( "time" abci "github.com/tendermint/tendermint/abci/types" + cryptoenc "github.com/tendermint/tendermint/crypto/encoding" tmbytes "github.com/tendermint/tendermint/libs/bytes" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" ) @@ -19,8 +21,8 @@ type mockValidator struct { func (mv mockValidator) String() string { return fmt.Sprintf("mockValidator{%s:%X power:%v state:%v}", - mv.val.PubKey.Type, - mv.val.PubKey.Data, + "key:", + mv.val.PubKey, mv.val.Power, mv.livenessState) } @@ -72,7 +74,7 @@ func (vals mockValidators) randomProposer(r *rand.Rand) tmbytes.HexBytes { key := keys[r.Intn(len(keys))] proposer := vals[key].val - pk, err := tmtypes.PB2TM.PubKey(proposer.PubKey) + pk, err := cryptoenc.PubKeyFromProto(proposer.PubKey) if err != nil { //nolint:wsl panic(err) } @@ -119,7 +121,7 @@ func updateValidators(tb testing.TB, r *rand.Rand, params Params, func RandomRequestBeginBlock(r *rand.Rand, params Params, validators mockValidators, pastTimes []time.Time, pastVoteInfos [][]abci.VoteInfo, - event func(route, op, evResult string), header abci.Header) abci.RequestBeginBlock { + event func(route, op, evResult string), header tmproto.Header) abci.RequestBeginBlock { if len(validators) == 0 { return abci.RequestBeginBlock{ Header: header, @@ -149,7 +151,7 @@ func RandomRequestBeginBlock(r *rand.Rand, params Params, event("begin_block", "signing", "missed") } - pubkey, err := tmtypes.PB2TM.PubKey(mVal.val.PubKey) + pubkey, err := cryptoenc.PubKeyFromProto(mVal.val.PubKey) if err != nil { panic(err) } diff --git a/x/simulation/params.go b/x/simulation/params.go index 6363846a09cc..1710ed445814 100644 --- a/x/simulation/params.go +++ b/x/simulation/params.go @@ -5,9 +5,9 @@ import ( "fmt" "math/rand" - "github.com/tendermint/tendermint/types" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/tendermint/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types/simulation" @@ -168,10 +168,10 @@ func RandomConsensusParams(r *rand.Rand, appState json.RawMessage) *abci.Consens MaxBytes: int64(simulation.RandIntBetween(r, 20000000, 30000000)), MaxGas: -1, }, - Validator: &abci.ValidatorParams{ - PubKeyTypes: []string{types.ABCIPubKeyTypeSecp256k1, types.ABCIPubKeyTypeEd25519}, + Validator: &tmproto.ValidatorParams{ + PubKeyTypes: []string{types.ABCIPubKeyTypeEd25519}, }, - Evidence: &abci.EvidenceParams{ + Evidence: &tmproto.EvidenceParams{ MaxAgeNumBlocks: int64(stakingGenesisState.Params.UnbondingTime / AverageBlockTime), MaxAgeDuration: stakingGenesisState.Params.UnbondingTime, }, diff --git a/x/simulation/params_test.go b/x/simulation/params_test.go index 8ba53efd8675..d0b538c26e4d 100644 --- a/x/simulation/params_test.go +++ b/x/simulation/params_test.go @@ -6,8 +6,7 @@ import ( "testing" "github.com/stretchr/testify/require" - - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" @@ -40,7 +39,7 @@ func TestNewWeightedProposalContent(t *testing.T) { require.Equal(t, key, pContent.AppParamsKey()) require.Equal(t, weight, pContent.DefaultWeight()) - ctx := sdk.NewContext(nil, abci.Header{}, true, nil) + ctx := sdk.NewContext(nil, tmproto.Header{}, true, nil) require.Equal(t, content, pContent.ContentSimulatorFn()(nil, ctx, nil)) } diff --git a/x/simulation/simulate.go b/x/simulation/simulate.go index 7e07ade4efdb..636111fc7549 100644 --- a/x/simulation/simulate.go +++ b/x/simulation/simulate.go @@ -11,6 +11,7 @@ import ( "time" abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -86,7 +87,7 @@ func SimulateFromSeed( nextValidators := validators - header := abci.Header{ + header := tmproto.Header{ ChainID: config.ChainID, Height: 1, Time: genesisTimestamp, @@ -240,7 +241,7 @@ func SimulateFromSeed( //______________________________________________________________________________ type blockSimFn func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, - accounts []simulation.Account, header abci.Header) (opCount int) + accounts []simulation.Account, header tmproto.Header) (opCount int) // Returns a function to simulate blocks. Written like this to avoid constant // parameters being passed everytime, to minimize memory overhead. @@ -254,7 +255,7 @@ func createBlockSimulator(testingMode bool, tb testing.TB, w io.Writer, params P selectOp := ops.getSelectOpFn() return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []simulation.Account, header abci.Header, + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []simulation.Account, header tmproto.Header, ) (opCount int) { _, _ = fmt.Fprintf( w, "\rSimulating... block %d/%d, operation %d/%d.", diff --git a/x/slashing/abci_test.go b/x/slashing/abci_test.go index fcff517deba9..0b6026bcde66 100644 --- a/x/slashing/abci_test.go +++ b/x/slashing/abci_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -16,7 +17,7 @@ import ( func TestBeginBlocker(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) pks := simapp.CreateTestPubKeys(1) simapp.AddTestAddrsFromPubKeys(app, ctx, pks, sdk.TokensFromConsensusPower(200)) diff --git a/x/slashing/app_test.go b/x/slashing/app_test.go index bc8f6e03eba0..6282716103aa 100644 --- a/x/slashing/app_test.go +++ b/x/slashing/app_test.go @@ -6,7 +6,8 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/crypto/secp256k1" + "github.com/tendermint/tendermint/crypto/ed25519" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -17,19 +18,19 @@ import ( ) var ( - priv1 = secp256k1.GenPrivKey() + priv1 = ed25519.GenPrivKey() addr1 = sdk.AccAddress(priv1.PubKey().Address()) ) func checkValidator(t *testing.T, app *simapp.SimApp, _ sdk.AccAddress, expFound bool) stakingtypes.Validator { - ctxCheck := app.BaseApp.NewContext(true, abci.Header{}) + ctxCheck := app.BaseApp.NewContext(true, tmproto.Header{}) validator, found := app.StakingKeeper.GetValidator(ctxCheck, sdk.ValAddress(addr1)) require.Equal(t, expFound, found) return validator } func checkValidatorSigningInfo(t *testing.T, app *simapp.SimApp, addr sdk.ConsAddress, expFound bool) types.ValidatorSigningInfo { - ctxCheck := app.BaseApp.NewContext(true, abci.Header{}) + ctxCheck := app.BaseApp.NewContext(true, tmproto.Header{}) signingInfo, found := app.SlashingKeeper.GetValidatorSigningInfo(ctxCheck, addr) require.Equal(t, expFound, found) return signingInfo @@ -62,13 +63,13 @@ func TestSlashingMsgs(t *testing.T) { sdk.ValAddress(addr1), priv1.PubKey(), bondCoin, description, commission, sdk.OneInt(), ) - header := abci.Header{Height: app.LastBlockHeight() + 1} + header := tmproto.Header{Height: app.LastBlockHeight() + 1} txGen := simapp.MakeEncodingConfig().TxConfig _, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, []sdk.Msg{createValidatorMsg}, []uint64{0}, []uint64{0}, true, true, priv1) require.NoError(t, err) simapp.CheckBalance(t, app, addr1, sdk.Coins{genCoin.Sub(bondCoin)}) - header = abci.Header{Height: app.LastBlockHeight() + 1} + header = tmproto.Header{Height: app.LastBlockHeight() + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) validator := checkValidator(t, app, addr1, true) @@ -80,7 +81,7 @@ func TestSlashingMsgs(t *testing.T) { checkValidatorSigningInfo(t, app, sdk.ConsAddress(addr1), true) // unjail should fail with unknown validator - header = abci.Header{Height: app.LastBlockHeight() + 1} + header = tmproto.Header{Height: app.LastBlockHeight() + 1} _, res, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, []sdk.Msg{unjailMsg}, []uint64{0}, []uint64{1}, false, false, priv1) require.Error(t, err) require.Nil(t, res) diff --git a/x/slashing/handler_test.go b/x/slashing/handler_test.go index d2ee849cea15..baa27015d1a0 100644 --- a/x/slashing/handler_test.go +++ b/x/slashing/handler_test.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/testutil/testdata" "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -23,7 +23,7 @@ import ( func TestCannotUnjailUnlessJailed(t *testing.T) { // initial setup app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) pks := simapp.CreateTestPubKeys(1) simapp.AddTestAddrsFromPubKeys(app, ctx, pks, sdk.TokensFromConsensusPower(200)) @@ -55,7 +55,7 @@ func TestCannotUnjailUnlessJailed(t *testing.T) { func TestCannotUnjailUnlessMeetMinSelfDelegation(t *testing.T) { // initial setup app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) pks := simapp.CreateTestPubKeys(1) simapp.AddTestAddrsFromPubKeys(app, ctx, pks, sdk.TokensFromConsensusPower(200)) @@ -94,7 +94,7 @@ func TestCannotUnjailUnlessMeetMinSelfDelegation(t *testing.T) { func TestJailedValidatorDelegations(t *testing.T) { // initial setup app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{Time: time.Unix(0, 0)}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{Time: time.Unix(0, 0)}) pks := simapp.CreateTestPubKeys(3) simapp.AddTestAddrsFromPubKeys(app, ctx, pks, sdk.TokensFromConsensusPower(20)) @@ -164,7 +164,7 @@ func TestInvalidMsg(t *testing.T) { k := keeper.Keeper{} h := slashing.NewHandler(k) - res, err := h(sdk.NewContext(nil, abci.Header{}, false, nil), testdata.NewTestMsg()) + res, err := h(sdk.NewContext(nil, tmproto.Header{}, false, nil), testdata.NewTestMsg()) require.Error(t, err) require.Nil(t, res) require.True(t, strings.Contains(err.Error(), "unrecognized slashing message type")) @@ -175,7 +175,7 @@ func TestInvalidMsg(t *testing.T) { func TestHandleAbsentValidator(t *testing.T) { // initial setup app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{Time: time.Unix(0, 0)}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{Time: time.Unix(0, 0)}) pks := simapp.CreateTestPubKeys(1) simapp.AddTestAddrsFromPubKeys(app, ctx, pks, sdk.TokensFromConsensusPower(200)) @@ -278,7 +278,7 @@ func TestHandleAbsentValidator(t *testing.T) { require.Nil(t, res) // unrevocation should succeed after jail expiration - ctx = ctx.WithBlockHeader(abci.Header{Time: time.Unix(1, 0).Add(app.SlashingKeeper.DowntimeJailDuration(ctx))}) + ctx = ctx.WithBlockHeader(tmproto.Header{Time: time.Unix(1, 0).Add(app.SlashingKeeper.DowntimeJailDuration(ctx))}) res, err = slh(ctx, types.NewMsgUnjail(addr)) require.NoError(t, err) require.NotNil(t, res) diff --git a/x/slashing/keeper/grpc_query_test.go b/x/slashing/keeper/grpc_query_test.go index 5b4667907f4d..ef47b26710c1 100644 --- a/x/slashing/keeper/grpc_query_test.go +++ b/x/slashing/keeper/grpc_query_test.go @@ -6,7 +6,7 @@ import ( "time" "github.com/stretchr/testify/suite" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/simapp" @@ -29,7 +29,7 @@ type SlashingTestSuite struct { func (suite *SlashingTestSuite) SetupTest() { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams()) app.BankKeeper.SetParams(ctx, banktypes.DefaultParams()) diff --git a/x/slashing/keeper/keeper_test.go b/x/slashing/keeper/keeper_test.go index 1a305728e5f8..5231edc79ae1 100644 --- a/x/slashing/keeper/keeper_test.go +++ b/x/slashing/keeper/keeper_test.go @@ -5,7 +5,7 @@ import ( "time" "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -16,7 +16,7 @@ import ( func TestUnJailNotBonded(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) p := app.StakingKeeper.GetParams(ctx) p.MaxValidators = 5 @@ -98,7 +98,7 @@ func TestUnJailNotBonded(t *testing.T) { // and that they are not immediately jailed func TestHandleNewValidator(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(200)) valAddrs := simapp.ConvertAddrsToValAddrs(addrDels) @@ -148,7 +148,7 @@ func TestHandleNewValidator(t *testing.T) { func TestHandleAlreadyJailed(t *testing.T) { // initial setup app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) power := int64(100) amt := sdk.TokensFromConsensusPower(power) @@ -205,7 +205,7 @@ func TestValidatorDippingInAndOut(t *testing.T) { // initial setup // TestParams set the SignedBlocksWindow to 1000 and MaxMissedBlocksPerWindow to 500 app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) app.SlashingKeeper.SetParams(ctx, keeper.TestParams()) params := app.StakingKeeper.GetParams(ctx) diff --git a/x/slashing/keeper/querier_test.go b/x/slashing/keeper/querier_test.go index 1721fe767042..3f784e2c9544 100644 --- a/x/slashing/keeper/querier_test.go +++ b/x/slashing/keeper/querier_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/simapp" @@ -15,7 +15,7 @@ import ( func TestNewQuerier(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) app.SlashingKeeper.SetParams(ctx, keeper.TestParams()) legacyQuerierCdc := codec.NewAminoCodec(app.Codec()) querier := keeper.NewQuerier(app.SlashingKeeper, legacyQuerierCdc) @@ -33,7 +33,7 @@ func TestQueryParams(t *testing.T) { cdc := codec.New() legacyQuerierCdc := codec.NewAminoCodec(cdc) app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) app.SlashingKeeper.SetParams(ctx, keeper.TestParams()) querier := keeper.NewQuerier(app.SlashingKeeper, legacyQuerierCdc) diff --git a/x/slashing/keeper/signing_info_test.go b/x/slashing/keeper/signing_info_test.go index e10df926c605..1b70c83b9712 100644 --- a/x/slashing/keeper/signing_info_test.go +++ b/x/slashing/keeper/signing_info_test.go @@ -5,8 +5,7 @@ import ( "time" "github.com/stretchr/testify/require" - - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -15,7 +14,7 @@ import ( func TestGetSetValidatorSigningInfo(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(200)) info, found := app.SlashingKeeper.GetValidatorSigningInfo(ctx, sdk.ConsAddress(addrDels[0])) @@ -39,7 +38,7 @@ func TestGetSetValidatorSigningInfo(t *testing.T) { func TestGetSetValidatorMissedBlockBitArray(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(200)) missed := app.SlashingKeeper.GetValidatorMissedBlockBitArray(ctx, sdk.ConsAddress(addrDels[0]), 0) @@ -51,7 +50,7 @@ func TestGetSetValidatorMissedBlockBitArray(t *testing.T) { func TestTombstoned(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(200)) require.Panics(t, func() { app.SlashingKeeper.Tombstone(ctx, sdk.ConsAddress(addrDels[0])) }) @@ -75,7 +74,7 @@ func TestTombstoned(t *testing.T) { func TestJailUntil(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(200)) require.Panics(t, func() { app.SlashingKeeper.JailUntil(ctx, sdk.ConsAddress(addrDels[0]), time.Now()) }) diff --git a/x/slashing/simulation/decoder.go b/x/slashing/simulation/decoder.go index af0a15b5ce1c..d42e70c8090d 100644 --- a/x/slashing/simulation/decoder.go +++ b/x/slashing/simulation/decoder.go @@ -4,8 +4,8 @@ import ( "bytes" "fmt" + "github.com/cosmos/cosmos-sdk/types/kv" gogotypes "github.com/gogo/protobuf/types" - tmkv "github.com/tendermint/tendermint/libs/kv" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/x/slashing/types" @@ -13,8 +13,8 @@ import ( // NewDecodeStore returns a decoder function closure that unmarshals the KVPair's // Value to the corresponding slashing type. -func NewDecodeStore(cdc codec.Marshaler) func(kvA, kvB tmkv.Pair) string { - return func(kvA, kvB tmkv.Pair) string { +func NewDecodeStore(cdc codec.Marshaler) func(kvA, kvB kv.Pair) string { + return func(kvA, kvB kv.Pair) string { switch { case bytes.Equal(kvA.Key[:1], types.ValidatorSigningInfoKeyPrefix): var infoA, infoB types.ValidatorSigningInfo diff --git a/x/slashing/simulation/decoder_test.go b/x/slashing/simulation/decoder_test.go index 8fbe78823846..38ed6684cdd3 100644 --- a/x/slashing/simulation/decoder_test.go +++ b/x/slashing/simulation/decoder_test.go @@ -10,10 +10,10 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto/ed25519" - tmkv "github.com/tendermint/tendermint/libs/kv" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/x/slashing/simulation" "github.com/cosmos/cosmos-sdk/x/slashing/types" ) @@ -34,11 +34,11 @@ func TestDecodeStore(t *testing.T) { bechPK := sdk.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, delPk1) missed := gogotypes.BoolValue{Value: true} - kvPairs := tmkv.Pairs{ - tmkv.Pair{Key: types.ValidatorSigningInfoKey(consAddr1), Value: cdc.MustMarshalBinaryBare(&info)}, - tmkv.Pair{Key: types.ValidatorMissedBlockBitArrayKey(consAddr1, 6), Value: cdc.MustMarshalBinaryBare(&missed)}, - tmkv.Pair{Key: types.AddrPubkeyRelationKey(delAddr1), Value: cdc.MustMarshalBinaryBare(&gogotypes.StringValue{Value: bechPK})}, - tmkv.Pair{Key: []byte{0x99}, Value: []byte{0x99}}, + kvPairs := kv.Pairs{ + kv.Pair{Key: types.ValidatorSigningInfoKey(consAddr1), Value: cdc.MustMarshalBinaryBare(&info)}, + kv.Pair{Key: types.ValidatorMissedBlockBitArrayKey(consAddr1, 6), Value: cdc.MustMarshalBinaryBare(&missed)}, + kv.Pair{Key: types.AddrPubkeyRelationKey(delAddr1), Value: cdc.MustMarshalBinaryBare(&gogotypes.StringValue{Value: bechPK})}, + kv.Pair{Key: []byte{0x99}, Value: []byte{0x99}}, } tests := []struct { diff --git a/x/slashing/simulation/operations_test.go b/x/slashing/simulation/operations_test.go index 0987daadb2ed..b5d0ac334d0b 100644 --- a/x/slashing/simulation/operations_test.go +++ b/x/slashing/simulation/operations_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" @@ -83,7 +84,7 @@ func TestSimulateMsgUnjail(t *testing.T) { app.DistrKeeper.SetDelegatorStartingInfo(ctx, validator0.OperatorAddress, val0AccAddress, distrtypes.NewDelegatorStartingInfo(2, sdk.OneDec(), 200)) // begin a new block - app.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash, Time: blockTime}}) + app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash, Time: blockTime}}) // execute operation op := simulation.SimulateMsgUnjail(app.AccountKeeper, app.BankKeeper, app.SlashingKeeper, app.StakingKeeper) @@ -103,7 +104,7 @@ func TestSimulateMsgUnjail(t *testing.T) { func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) { app := simapp.Setup(isCheckTx) - ctx := app.BaseApp.NewContext(isCheckTx, abci.Header{}) + ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) app.MintKeeper.SetParams(ctx, minttypes.DefaultParams()) app.MintKeeper.SetMinter(ctx, minttypes.DefaultInitialMinter()) diff --git a/x/staking/app_test.go b/x/staking/app_test.go index 457003475e14..062413ee978c 100644 --- a/x/staking/app_test.go +++ b/x/staking/app_test.go @@ -5,6 +5,7 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -14,7 +15,7 @@ import ( ) func checkValidator(t *testing.T, app *simapp.SimApp, addr sdk.ValAddress, expFound bool) types.Validator { - ctxCheck := app.BaseApp.NewContext(true, abci.Header{}) + ctxCheck := app.BaseApp.NewContext(true, tmproto.Header{}) validator, found := app.StakingKeeper.GetValidator(ctxCheck, addr) require.Equal(t, expFound, found) @@ -26,7 +27,7 @@ func checkDelegation( validatorAddr sdk.ValAddress, expFound bool, expShares sdk.Dec, ) { - ctxCheck := app.BaseApp.NewContext(true, abci.Header{}) + ctxCheck := app.BaseApp.NewContext(true, tmproto.Header{}) delegation, found := app.StakingKeeper.GetDelegation(ctxCheck, delegatorAddr, validatorAddr) if expFound { require.True(t, found) @@ -68,13 +69,13 @@ func TestStakingMsgs(t *testing.T) { sdk.ValAddress(addr1), priv1.PubKey(), bondCoin, description, commissionRates, sdk.OneInt(), ) - header := abci.Header{Height: app.LastBlockHeight() + 1} + header := tmproto.Header{Height: app.LastBlockHeight() + 1} txGen := simapp.MakeEncodingConfig().TxConfig _, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, []sdk.Msg{createValidatorMsg}, []uint64{0}, []uint64{0}, true, true, priv1) require.NoError(t, err) simapp.CheckBalance(t, app, addr1, sdk.Coins{genCoin.Sub(bondCoin)}) - header = abci.Header{Height: app.LastBlockHeight() + 1} + header = tmproto.Header{Height: app.LastBlockHeight() + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) validator := checkValidator(t, app, sdk.ValAddress(addr1), true) @@ -82,14 +83,14 @@ func TestStakingMsgs(t *testing.T) { require.Equal(t, sdk.Bonded, validator.Status) require.True(sdk.IntEq(t, bondTokens, validator.BondedTokens())) - header = abci.Header{Height: app.LastBlockHeight() + 1} + header = tmproto.Header{Height: app.LastBlockHeight() + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) // edit the validator description = types.NewDescription("bar_moniker", "", "", "", "") editValidatorMsg := types.NewMsgEditValidator(sdk.ValAddress(addr1), description, nil, nil) - header = abci.Header{Height: app.LastBlockHeight() + 1} + header = tmproto.Header{Height: app.LastBlockHeight() + 1} _, _, err = simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, []sdk.Msg{editValidatorMsg}, []uint64{0}, []uint64{1}, true, true, priv1) require.NoError(t, err) @@ -100,7 +101,7 @@ func TestStakingMsgs(t *testing.T) { simapp.CheckBalance(t, app, addr2, sdk.Coins{genCoin}) delegateMsg := types.NewMsgDelegate(addr2, sdk.ValAddress(addr1), bondCoin) - header = abci.Header{Height: app.LastBlockHeight() + 1} + header = tmproto.Header{Height: app.LastBlockHeight() + 1} _, _, err = simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, []sdk.Msg{delegateMsg}, []uint64{1}, []uint64{0}, true, true, priv2) require.NoError(t, err) @@ -109,7 +110,7 @@ func TestStakingMsgs(t *testing.T) { // begin unbonding beginUnbondingMsg := types.NewMsgUndelegate(addr2, sdk.ValAddress(addr1), bondCoin) - header = abci.Header{Height: app.LastBlockHeight() + 1} + header = tmproto.Header{Height: app.LastBlockHeight() + 1} _, _, err = simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, []sdk.Msg{beginUnbondingMsg}, []uint64{1}, []uint64{1}, true, true, priv2) require.NoError(t, err) diff --git a/x/staking/common_test.go b/x/staking/common_test.go index a19969df7eaa..d60b7cf60048 100644 --- a/x/staking/common_test.go +++ b/x/staking/common_test.go @@ -1,9 +1,9 @@ package staking_test import ( - abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/secp256k1" + "github.com/tendermint/tendermint/crypto/ed25519" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/simapp" @@ -14,9 +14,9 @@ import ( // nolint:deadcode,unused,varcheck var ( - priv1 = secp256k1.GenPrivKey() + priv1 = ed25519.GenPrivKey() addr1 = sdk.AccAddress(priv1.PubKey().Address()) - priv2 = secp256k1.GenPrivKey() + priv2 = ed25519.GenPrivKey() addr2 = sdk.AccAddress(priv2.PubKey().Address()) commissionRates = types.NewCommissionRates(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) @@ -39,7 +39,7 @@ func NewTestMsgDelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, amt sdk. // to avoid messing with the hooks. func getBaseSimappWithCustomKeeper() (*codec.Codec, *simapp.SimApp, sdk.Context) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) appCodec := app.AppCodec() diff --git a/x/staking/genesis.go b/x/staking/genesis.go index 4cb8dd95baa0..390dbe0bf921 100644 --- a/x/staking/genesis.go +++ b/x/staking/genesis.go @@ -6,6 +6,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" tmtypes "github.com/tendermint/tendermint/types" + "github.com/cosmos/cosmos-sdk/codec/legacy" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/staking/exported" "github.com/cosmos/cosmos-sdk/x/staking/keeper" @@ -133,7 +134,10 @@ func InitGenesis( panic(fmt.Sprintf("validator %s not found", lv.Address)) } - update := validator.ABCIValidatorUpdate() + update, err := validator.ABCIValidatorUpdate() + if err != nil { + panic(err) //todo see if returning error is possible + } update.Power = lv.Power // keep the next-val-set offset, use the last power for the first block res = append(res, update) } @@ -212,7 +216,7 @@ func validateGenesisStateValidators(validators []types.Validator) (err error) { for i := 0; i < len(validators); i++ { val := validators[i] - strKey := string(val.GetConsPubKey().Bytes()) + strKey := string(legacy.Cdc.MustMarshalBinaryBare(val.GetConsPubKey())) if _, ok := addrMap[strKey]; ok { return fmt.Errorf("duplicate validator in genesis state: moniker %v, address %v", val.Description.Moniker, val.GetConsAddr()) diff --git a/x/staking/genesis_test.go b/x/staking/genesis_test.go index d67f66b9a8cc..aa8111c4f10b 100644 --- a/x/staking/genesis_test.go +++ b/x/staking/genesis_test.go @@ -87,7 +87,9 @@ func TestInitGenesis(t *testing.T) { abcivals := make([]abci.ValidatorUpdate, len(vals)) for i, val := range validators { - abcivals[i] = val.ABCIValidatorUpdate() + var err error + abcivals[i], err = val.ABCIValidatorUpdate() + require.NoError(t, err) } require.Equal(t, abcivals, vals) @@ -122,7 +124,9 @@ func TestInitGenesisLargeValidatorSet(t *testing.T) { abcivals := make([]abci.ValidatorUpdate, 100) for i, val := range validators[:100] { - abcivals[i] = val.ABCIValidatorUpdate() + var err error + abcivals[i], err = val.ABCIValidatorUpdate() + require.NoError(t, err) } require.Equal(t, abcivals, vals) diff --git a/x/staking/handler.go b/x/staking/handler.go index da7c9fa3683f..eef0123e0a2f 100644 --- a/x/staking/handler.go +++ b/x/staking/handler.go @@ -6,7 +6,6 @@ import ( "github.com/armon/go-metrics" gogotypes "github.com/gogo/protobuf/types" tmstrings "github.com/tendermint/tendermint/libs/strings" - tmtypes "github.com/tendermint/tendermint/types" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" @@ -70,12 +69,16 @@ func handleMsgCreateValidator(ctx sdk.Context, msg *types.MsgCreateValidator, k cp := ctx.ConsensusParams() if cp != nil && cp.Validator != nil { - tmPubKey := tmtypes.TM2PB.PubKey(pk) + // tmPubKey, err := cryptoenc.PubKeyToProto(pk) + // if err != nil { + // return nil, err + // } - if !tmstrings.StringInSlice(tmPubKey.Type, cp.Validator.PubKeyTypes) { + // todo check if we need PubkeyName or type + if !tmstrings.StringInSlice(pk.Type(), cp.Validator.PubKeyTypes) { return nil, sdkerrors.Wrapf( types.ErrValidatorPubKeyTypeNotSupported, - "got: %s, expected: %s", tmPubKey.Type, cp.Validator.PubKeyTypes, + "got: %s, expected: %s", pk.Type(), cp.Validator.PubKeyTypes, ) } } diff --git a/x/staking/handler_test.go b/x/staking/handler_test.go index 488fa6b8b5ec..461747dba2c1 100644 --- a/x/staking/handler_test.go +++ b/x/staking/handler_test.go @@ -13,6 +13,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto/secp256k1" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" @@ -196,7 +197,7 @@ func TestInvalidPubKeyTypeMsgCreateValidator(t *testing.T) { app, ctx, _, valAddrs := bootstrapHandlerGenesisTest(t, 1000, 1, 1000) handler := staking.NewHandler(app.StakingKeeper) ctx = ctx.WithConsensusParams(&abci.ConsensusParams{ - Validator: &abci.ValidatorParams{PubKeyTypes: []string{tmtypes.ABCIPubKeyTypeEd25519}}, + Validator: &tmproto.ValidatorParams{PubKeyTypes: []string{tmtypes.ABCIPubKeyTypeEd25519}}, }) addr := valAddrs[0] @@ -209,7 +210,7 @@ func TestInvalidPubKeyTypeMsgCreateValidator(t *testing.T) { require.Nil(t, res) ctx = ctx.WithConsensusParams(&abci.ConsensusParams{ - Validator: &abci.ValidatorParams{PubKeyTypes: []string{tmtypes.ABCIPubKeyTypeSecp256k1}}, + Validator: &tmproto.ValidatorParams{PubKeyTypes: []string{"secp256k1"}}, }) res, err = handler(ctx, msgCreateValidator) @@ -1441,7 +1442,7 @@ func TestInvalidMsg(t *testing.T) { k := keeper.Keeper{} h := staking.NewHandler(k) - res, err := h(sdk.NewContext(nil, abci.Header{}, false, nil), testdata.NewTestMsg()) + res, err := h(sdk.NewContext(nil, tmproto.Header{}, false, nil), testdata.NewTestMsg()) require.Error(t, err) require.Nil(t, res) require.True(t, strings.Contains(err.Error(), "unrecognized staking message type")) diff --git a/x/staking/keeper/common_test.go b/x/staking/keeper/common_test.go index b4c98a011c46..334803520218 100644 --- a/x/staking/keeper/common_test.go +++ b/x/staking/keeper/common_test.go @@ -3,7 +3,7 @@ package keeper_test import ( "testing" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/simapp" @@ -20,7 +20,7 @@ var ( // to avoid messing with the hooks. func createTestInput() (*codec.Codec, *simapp.SimApp, sdk.Context) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) appCodec := app.AppCodec() diff --git a/x/staking/keeper/historical_info_test.go b/x/staking/keeper/historical_info_test.go index 37e3b7237f58..c4aa2415f5fa 100644 --- a/x/staking/keeper/historical_info_test.go +++ b/x/staking/keeper/historical_info_test.go @@ -4,14 +4,12 @@ import ( "sort" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" - + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/staking/types" - - "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" ) func TestHistoricalInfo(t *testing.T) { @@ -55,11 +53,11 @@ func TestTrackHistoricalInfo(t *testing.T) { // set historical info at 5, 4 which should be pruned // and check that it has been stored - h4 := abci.Header{ + h4 := tmproto.Header{ ChainID: "HelloChain", Height: 4, } - h5 := abci.Header{ + h5 := tmproto.Header{ ChainID: "HelloChain", Height: 5, } @@ -89,7 +87,7 @@ func TestTrackHistoricalInfo(t *testing.T) { app.StakingKeeper.SetLastValidatorPower(ctx, val2.OperatorAddress, 8) // Set Header for BeginBlock context - header := abci.Header{ + header := tmproto.Header{ ChainID: "HelloChain", Height: 10, } @@ -126,9 +124,9 @@ func TestGetAllHistoricalInfo(t *testing.T) { types.NewValidator(addrVals[1], PKs[1], types.Description{}), } - header1 := abci.Header{ChainID: "HelloChain", Height: 10} - header2 := abci.Header{ChainID: "HelloChain", Height: 11} - header3 := abci.Header{ChainID: "HelloChain", Height: 12} + header1 := tmproto.Header{ChainID: "HelloChain", Height: 10} + header2 := tmproto.Header{ChainID: "HelloChain", Height: 11} + header3 := tmproto.Header{ChainID: "HelloChain", Height: 12} hist1 := types.HistoricalInfo{Header: header1, Valset: valSet} hist2 := types.HistoricalInfo{Header: header2, Valset: valSet} diff --git a/x/staking/keeper/keeper_test.go b/x/staking/keeper/keeper_test.go index b3764d0776d8..43b91e9ea31d 100644 --- a/x/staking/keeper/keeper_test.go +++ b/x/staking/keeper/keeper_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/simapp" @@ -27,7 +27,7 @@ type KeeperTestSuite struct { func (suite *KeeperTestSuite) SetupTest() { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) querier := keeper.Querier{Keeper: app.StakingKeeper} @@ -36,7 +36,7 @@ func (suite *KeeperTestSuite) SetupTest() { queryClient := types.NewQueryClient(queryHelper) addrs, _, validators := createValidators(ctx, app, []int64{9, 8, 7}) - header := abci.Header{ + header := tmproto.Header{ ChainID: "HelloChain", Height: 5, } @@ -48,7 +48,7 @@ func (suite *KeeperTestSuite) SetupTest() { } func TestParams(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abci.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) expParams := types.DefaultParams() diff --git a/x/staking/keeper/querier_test.go b/x/staking/keeper/querier_test.go index 165589224673..48d5436be1ed 100644 --- a/x/staking/keeper/querier_test.go +++ b/x/staking/keeper/querier_test.go @@ -9,6 +9,7 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -33,7 +34,7 @@ func TestNewQuerier(t *testing.T) { app.StakingKeeper.SetValidatorByPowerIndex(ctx, validators[i]) } - header := abci.Header{ + header := tmproto.Header{ ChainID: "HelloChain", Height: 5, } @@ -721,7 +722,7 @@ func TestQueryHistoricalInfo(t *testing.T) { app.StakingKeeper.SetValidator(ctx, val1) app.StakingKeeper.SetValidator(ctx, val2) - header := abci.Header{ + header := tmproto.Header{ ChainID: "HelloChain", Height: 5, } diff --git a/x/staking/keeper/slash_test.go b/x/staking/keeper/slash_test.go index d6f1e06a7e86..7eb277b41a26 100644 --- a/x/staking/keeper/slash_test.go +++ b/x/staking/keeper/slash_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -92,7 +92,7 @@ func TestSlashUnbondingDelegation(t *testing.T) { require.Equal(t, int64(0), slashAmount.Int64()) // after the expiration time, no longer eligible for slashing - ctx = ctx.WithBlockHeader(abci.Header{Time: time.Unix(10, 0)}) + ctx = ctx.WithBlockHeader(tmproto.Header{Time: time.Unix(10, 0)}) app.StakingKeeper.SetUnbondingDelegation(ctx, ubd) slashAmount = app.StakingKeeper.SlashUnbondingDelegation(ctx, ubd, 0, fraction) require.Equal(t, int64(0), slashAmount.Int64()) @@ -100,7 +100,7 @@ func TestSlashUnbondingDelegation(t *testing.T) { // test valid slash, before expiration timestamp and to which stake contributed notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx) oldUnbondedPoolBalances := app.BankKeeper.GetAllBalances(ctx, notBondedPool.GetAddress()) - ctx = ctx.WithBlockHeader(abci.Header{Time: time.Unix(0, 0)}) + ctx = ctx.WithBlockHeader(tmproto.Header{Time: time.Unix(0, 0)}) app.StakingKeeper.SetUnbondingDelegation(ctx, ubd) slashAmount = app.StakingKeeper.SlashUnbondingDelegation(ctx, ubd, 0, fraction) require.Equal(t, int64(5), slashAmount.Int64()) @@ -149,7 +149,7 @@ func TestSlashRedelegation(t *testing.T) { require.Equal(t, int64(0), slashAmount.Int64()) // after the expiration time, no longer eligible for slashing - ctx = ctx.WithBlockHeader(abci.Header{Time: time.Unix(10, 0)}) + ctx = ctx.WithBlockHeader(tmproto.Header{Time: time.Unix(10, 0)}) app.StakingKeeper.SetRedelegation(ctx, rd) validator, found = app.StakingKeeper.GetValidator(ctx, addrVals[1]) require.True(t, found) @@ -159,7 +159,7 @@ func TestSlashRedelegation(t *testing.T) { balances = app.BankKeeper.GetAllBalances(ctx, bondedPool.GetAddress()) // test valid slash, before expiration timestamp and to which stake contributed - ctx = ctx.WithBlockHeader(abci.Header{Time: time.Unix(0, 0)}) + ctx = ctx.WithBlockHeader(tmproto.Header{Time: time.Unix(0, 0)}) app.StakingKeeper.SetRedelegation(ctx, rd) validator, found = app.StakingKeeper.GetValidator(ctx, addrVals[1]) require.True(t, found) diff --git a/x/staking/keeper/val_state_change.go b/x/staking/keeper/val_state_change.go index 04d74dd91b8c..502d6663f6d0 100644 --- a/x/staking/keeper/val_state_change.go +++ b/x/staking/keeper/val_state_change.go @@ -140,7 +140,11 @@ func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx sdk.Context) (updates []ab // update the validator set if power has changed if !found || !bytes.Equal(oldPowerBytes, newPowerBytes) { - updates = append(updates, validator.ABCIValidatorUpdate()) + valUpdate, err := validator.ABCIValidatorUpdate() + if err != nil { + panic(err) // todo return err + } + updates = append(updates, valUpdate) k.SetLastValidatorPower(ctx, valAddr, newPower) } @@ -157,7 +161,11 @@ func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx sdk.Context) (updates []ab validator = k.bondedToUnbonding(ctx, validator) amtFromBondedToNotBonded = amtFromBondedToNotBonded.Add(validator.GetTokens()) k.DeleteLastValidatorPower(ctx, validator.GetOperator()) - updates = append(updates, validator.ABCIValidatorUpdateZero()) + valZero, err := validator.ABCIValidatorUpdateZero() + if err != nil { + panic(err) //todo return err + } + updates = append(updates, valZero) } // Update the pools based on the recent updates in the validator set: diff --git a/x/staking/keeper/validator_test.go b/x/staking/keeper/validator_test.go index ce34b0d23439..b2b83a19a781 100644 --- a/x/staking/keeper/validator_test.go +++ b/x/staking/keeper/validator_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -55,7 +55,11 @@ func TestSetValidator(t *testing.T) { validator, found := app.StakingKeeper.GetValidator(ctx, valAddr) require.True(t, found) require.Equal(t, 1, len(updates)) - require.Equal(t, validator.ABCIValidatorUpdate(), updates[0]) + + vUpdate, err := validator.ABCIValidatorUpdate() + require.NoError(t, err) + + require.Equal(t, vUpdate, updates[0]) // after the save the validator should be bonded require.Equal(t, sdk.Bonded, validator.Status) @@ -699,8 +703,14 @@ func TestApplyAndReturnValidatorSetUpdatesAllNone(t *testing.T) { assert.Equal(t, 2, len(updates)) validators[0], _ = app.StakingKeeper.GetValidator(ctx, validators[0].OperatorAddress) validators[1], _ = app.StakingKeeper.GetValidator(ctx, validators[1].OperatorAddress) - assert.Equal(t, validators[0].ABCIValidatorUpdate(), updates[1]) - assert.Equal(t, validators[1].ABCIValidatorUpdate(), updates[0]) + + v0Update, err := validators[0].ABCIValidatorUpdate() + require.NoError(t, err) + v1Update, err := validators[1].ABCIValidatorUpdate() + require.NoError(t, err) + + assert.Equal(t, v0Update, updates[1]) + assert.Equal(t, v1Update, updates[0]) } func TestApplyAndReturnValidatorSetUpdatesIdentical(t *testing.T) { @@ -752,7 +762,11 @@ func TestApplyAndReturnValidatorSetUpdatesSingleValueChange(t *testing.T) { updates := app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx) require.Equal(t, 1, len(updates)) - require.Equal(t, validators[0].ABCIValidatorUpdate(), updates[0]) + + v0Update, err := validators[0].ABCIValidatorUpdate() + require.NoError(t, err) + + require.Equal(t, v0Update, updates[0]) } func TestApplyAndReturnValidatorSetUpdatesMultipleValueChange(t *testing.T) { @@ -783,8 +797,14 @@ func TestApplyAndReturnValidatorSetUpdatesMultipleValueChange(t *testing.T) { updates := app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx) require.Equal(t, 2, len(updates)) - require.Equal(t, validators[0].ABCIValidatorUpdate(), updates[0]) - require.Equal(t, validators[1].ABCIValidatorUpdate(), updates[1]) + + v0Update, err := validators[0].ABCIValidatorUpdate() + require.NoError(t, err) + v1Update, err := validators[1].ABCIValidatorUpdate() + require.NoError(t, err) + + require.Equal(t, v0Update, updates[0]) + require.Equal(t, v1Update, updates[1]) } func TestApplyAndReturnValidatorSetUpdatesInserted(t *testing.T) { @@ -812,7 +832,10 @@ func TestApplyAndReturnValidatorSetUpdatesInserted(t *testing.T) { updates := app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx) validators[2], _ = app.StakingKeeper.GetValidator(ctx, validators[2].OperatorAddress) require.Equal(t, 1, len(updates)) - require.Equal(t, validators[2].ABCIValidatorUpdate(), updates[0]) + + v2Update, err := validators[2].ABCIValidatorUpdate() + require.NoError(t, err) + require.Equal(t, v2Update, updates[0]) // test validtor added at the beginning // tendermintUpdate set: {} -> {c0} @@ -821,7 +844,10 @@ func TestApplyAndReturnValidatorSetUpdatesInserted(t *testing.T) { updates = app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx) validators[3], _ = app.StakingKeeper.GetValidator(ctx, validators[3].OperatorAddress) require.Equal(t, 1, len(updates)) - require.Equal(t, validators[3].ABCIValidatorUpdate(), updates[0]) + + v3Update, err := validators[3].ABCIValidatorUpdate() + require.NoError(t, err) + require.Equal(t, v3Update, updates[0]) // test validtor added at the end // tendermintUpdate set: {} -> {c0} @@ -830,7 +856,10 @@ func TestApplyAndReturnValidatorSetUpdatesInserted(t *testing.T) { updates = app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx) validators[4], _ = app.StakingKeeper.GetValidator(ctx, validators[4].OperatorAddress) require.Equal(t, 1, len(updates)) - require.Equal(t, validators[4].ABCIValidatorUpdate(), updates[0]) + + v4Update, err := validators[4].ABCIValidatorUpdate() + require.NoError(t, err) + require.Equal(t, v4Update, updates[0]) } func TestApplyAndReturnValidatorSetUpdatesWithCliffValidator(t *testing.T) { @@ -870,8 +899,14 @@ func TestApplyAndReturnValidatorSetUpdatesWithCliffValidator(t *testing.T) { updates = app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx) validators[2], _ = app.StakingKeeper.GetValidator(ctx, validators[2].OperatorAddress) require.Equal(t, 2, len(updates), "%v", updates) - require.Equal(t, validators[0].ABCIValidatorUpdateZero(), updates[1]) - require.Equal(t, validators[2].ABCIValidatorUpdate(), updates[0]) + + v0Update, err := validators[0].ABCIValidatorUpdateZero() + require.NoError(t, err) + v2Update, err := validators[2].ABCIValidatorUpdate() + require.NoError(t, err) + + require.Equal(t, v0Update, updates[1]) + require.Equal(t, v2Update, updates[0]) } func TestApplyAndReturnValidatorSetUpdatesPowerDecrease(t *testing.T) { @@ -911,8 +946,14 @@ func TestApplyAndReturnValidatorSetUpdatesPowerDecrease(t *testing.T) { // Tendermint updates should reflect power change updates := app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx) require.Equal(t, 2, len(updates)) - require.Equal(t, validators[0].ABCIValidatorUpdate(), updates[0]) - require.Equal(t, validators[1].ABCIValidatorUpdate(), updates[1]) + + v0Update, err := validators[0].ABCIValidatorUpdate() + require.NoError(t, err) + v1Update, err := validators[1].ABCIValidatorUpdate() + require.NoError(t, err) + + require.Equal(t, v0Update, updates[0]) + require.Equal(t, v1Update, updates[1]) } func TestApplyAndReturnValidatorSetUpdatesNewValidator(t *testing.T) { @@ -944,8 +985,14 @@ func TestApplyAndReturnValidatorSetUpdatesNewValidator(t *testing.T) { require.Equal(t, len(validators), len(updates)) validators[0], _ = app.StakingKeeper.GetValidator(ctx, validators[0].OperatorAddress) validators[1], _ = app.StakingKeeper.GetValidator(ctx, validators[1].OperatorAddress) - require.Equal(t, validators[0].ABCIValidatorUpdate(), updates[0]) - require.Equal(t, validators[1].ABCIValidatorUpdate(), updates[1]) + + v0Update, err := validators[0].ABCIValidatorUpdate() + require.NoError(t, err) + v1Update, err := validators[1].ABCIValidatorUpdate() + require.NoError(t, err) + + require.Equal(t, v0Update, updates[0]) + require.Equal(t, v1Update, updates[1]) require.Equal(t, 0, len(app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx))) @@ -991,9 +1038,17 @@ func TestApplyAndReturnValidatorSetUpdatesNewValidator(t *testing.T) { validators[0], _ = app.StakingKeeper.GetValidator(ctx, validators[0].OperatorAddress) validators[1], _ = app.StakingKeeper.GetValidator(ctx, validators[1].OperatorAddress) require.Equal(t, len(validators)+1, len(updates)) - require.Equal(t, validator.ABCIValidatorUpdate(), updates[0]) - require.Equal(t, validators[0].ABCIValidatorUpdate(), updates[1]) - require.Equal(t, validators[1].ABCIValidatorUpdate(), updates[2]) + + vUpdate, err := validator.ABCIValidatorUpdate() + require.NoError(t, err) + v0Update, err = validators[0].ABCIValidatorUpdate() + require.NoError(t, err) + v1Update, err = validators[1].ABCIValidatorUpdate() + require.NoError(t, err) + + require.Equal(t, vUpdate, updates[0]) + require.Equal(t, v0Update, updates[1]) + require.Equal(t, v1Update, updates[2]) } func TestApplyAndReturnValidatorSetUpdatesBondTransition(t *testing.T) { @@ -1024,8 +1079,15 @@ func TestApplyAndReturnValidatorSetUpdatesBondTransition(t *testing.T) { require.Equal(t, 2, len(updates)) validators[2], _ = app.StakingKeeper.GetValidator(ctx, validators[2].OperatorAddress) validators[1], _ = app.StakingKeeper.GetValidator(ctx, validators[1].OperatorAddress) - require.Equal(t, validators[2].ABCIValidatorUpdate(), updates[0]) - require.Equal(t, validators[1].ABCIValidatorUpdate(), updates[1]) + + v2Update, err := validators[2].ABCIValidatorUpdate() + require.NoError(t, err) + + v1Update, err := validators[1].ABCIValidatorUpdate() + require.NoError(t, err) + + require.Equal(t, v2Update, updates[0]) + require.Equal(t, v1Update, updates[1]) require.Equal(t, 0, len(app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx))) @@ -1065,17 +1127,19 @@ func TestApplyAndReturnValidatorSetUpdatesBondTransition(t *testing.T) { app.StakingKeeper.SetValidator(ctx, validators[1]) app.StakingKeeper.SetValidatorByPowerIndex(ctx, validators[1]) + v1Update, err = validators[1].ABCIValidatorUpdate() + require.NoError(t, err) // verify initial Tendermint updates are correct updates = app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx) require.Equal(t, 1, len(updates)) - require.Equal(t, validators[1].ABCIValidatorUpdate(), updates[0]) + require.Equal(t, v1Update, updates[0]) require.Equal(t, 0, len(app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx))) } func TestUpdateValidatorCommission(t *testing.T) { app, ctx, _, addrVals := bootstrapValidatorTest(t, 1000, 20) - ctx = ctx.WithBlockHeader(abci.Header{Time: time.Now().UTC()}) + ctx = ctx.WithBlockHeader(tmproto.Header{Time: time.Now().UTC()}) commission1 := types.NewCommissionWithTime( sdk.NewDecWithPrec(1, 1), sdk.NewDecWithPrec(3, 1), diff --git a/x/staking/module_test.go b/x/staking/module_test.go index fa7cf6a83f63..b1d126d0c38a 100644 --- a/x/staking/module_test.go +++ b/x/staking/module_test.go @@ -5,6 +5,7 @@ import ( "github.com/stretchr/testify/require" abcitypes "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -13,7 +14,7 @@ import ( func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, abcitypes.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) app.InitChain( abcitypes.RequestInitChain{ diff --git a/x/staking/simulation/decoder.go b/x/staking/simulation/decoder.go index 35d2cff23e86..696aee7d2292 100644 --- a/x/staking/simulation/decoder.go +++ b/x/staking/simulation/decoder.go @@ -4,17 +4,16 @@ import ( "bytes" "fmt" - tmkv "github.com/tendermint/tendermint/libs/kv" - "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/x/staking/types" ) // NewDecodeStore returns a decoder function closure that unmarshals the KVPair's // Value to the corresponding staking type. -func NewDecodeStore(cdc codec.Marshaler) func(kvA, kvB tmkv.Pair) string { - return func(kvA, kvB tmkv.Pair) string { +func NewDecodeStore(cdc codec.Marshaler) func(kvA, kvB kv.Pair) string { + return func(kvA, kvB kv.Pair) string { switch { case bytes.Equal(kvA.Key[:1], types.LastTotalPowerKey): var powerA, powerB sdk.IntProto diff --git a/x/staking/simulation/decoder_test.go b/x/staking/simulation/decoder_test.go index 67e26be1e810..ca432e33aca5 100644 --- a/x/staking/simulation/decoder_test.go +++ b/x/staking/simulation/decoder_test.go @@ -7,8 +7,8 @@ import ( "github.com/stretchr/testify/require" + "github.com/cosmos/cosmos-sdk/types/kv" "github.com/tendermint/tendermint/crypto/ed25519" - tmkv "github.com/tendermint/tendermint/libs/kv" "github.com/cosmos/cosmos-sdk/codec" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" @@ -43,14 +43,14 @@ func TestDecodeStore(t *testing.T) { ubd := types.NewUnbondingDelegation(delAddr1, valAddr1, 15, bondTime, sdk.OneInt()) red := types.NewRedelegation(delAddr1, valAddr1, valAddr1, 12, bondTime, sdk.OneInt(), sdk.OneDec()) - kvPairs := tmkv.Pairs{ - tmkv.Pair{Key: types.LastTotalPowerKey, Value: cdc.MustMarshalBinaryBare(&sdk.IntProto{Int: sdk.OneInt()})}, - tmkv.Pair{Key: types.GetValidatorKey(valAddr1), Value: cdc.MustMarshalBinaryBare(&val)}, - tmkv.Pair{Key: types.LastValidatorPowerKey, Value: valAddr1.Bytes()}, - tmkv.Pair{Key: types.GetDelegationKey(delAddr1, valAddr1), Value: cdc.MustMarshalBinaryBare(&del)}, - tmkv.Pair{Key: types.GetUBDKey(delAddr1, valAddr1), Value: cdc.MustMarshalBinaryBare(&ubd)}, - tmkv.Pair{Key: types.GetREDKey(delAddr1, valAddr1, valAddr1), Value: cdc.MustMarshalBinaryBare(&red)}, - tmkv.Pair{Key: []byte{0x99}, Value: []byte{0x99}}, + kvPairs := kv.Pairs{ + kv.Pair{Key: types.LastTotalPowerKey, Value: cdc.MustMarshalBinaryBare(&sdk.IntProto{Int: sdk.OneInt()})}, + kv.Pair{Key: types.GetValidatorKey(valAddr1), Value: cdc.MustMarshalBinaryBare(&val)}, + kv.Pair{Key: types.LastValidatorPowerKey, Value: valAddr1.Bytes()}, + kv.Pair{Key: types.GetDelegationKey(delAddr1, valAddr1), Value: cdc.MustMarshalBinaryBare(&del)}, + kv.Pair{Key: types.GetUBDKey(delAddr1, valAddr1), Value: cdc.MustMarshalBinaryBare(&ubd)}, + kv.Pair{Key: types.GetREDKey(delAddr1, valAddr1, valAddr1), Value: cdc.MustMarshalBinaryBare(&red)}, + kv.Pair{Key: []byte{0x99}, Value: []byte{0x99}}, } tests := []struct { diff --git a/x/staking/simulation/operations_test.go b/x/staking/simulation/operations_test.go index 8d2afdfa59af..ff10d321bb6e 100644 --- a/x/staking/simulation/operations_test.go +++ b/x/staking/simulation/operations_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" @@ -69,7 +70,7 @@ func TestSimulateMsgCreateValidator(t *testing.T) { accounts := getTestingAccounts(t, r, app, ctx, 3) // begin a new block - app.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash}}) + app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash}}) // execute operation op := simulation.SimulateMsgCreateValidator(app.AccountKeeper, app.BankKeeper, app.StakingKeeper) @@ -106,7 +107,7 @@ func TestSimulateMsgEditValidator(t *testing.T) { _ = getTestingValidator0(t, app, ctx, accounts) // begin a new block - app.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash, Time: blockTime}}) + app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash, Time: blockTime}}) // execute operation op := simulation.SimulateMsgEditValidator(app.AccountKeeper, app.BankKeeper, app.StakingKeeper) @@ -144,7 +145,7 @@ func TestSimulateMsgDelegate(t *testing.T) { setupValidatorRewards(app, ctx, validator0.OperatorAddress) // begin a new block - app.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash, Time: blockTime}}) + app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash, Time: blockTime}}) // execute operation op := simulation.SimulateMsgDelegate(app.AccountKeeper, app.BankKeeper, app.StakingKeeper) @@ -189,7 +190,7 @@ func TestSimulateMsgUndelegate(t *testing.T) { setupValidatorRewards(app, ctx, validator0.OperatorAddress) // begin a new block - app.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash, Time: blockTime}}) + app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash, Time: blockTime}}) // execute operation op := simulation.SimulateMsgUndelegate(app.AccountKeeper, app.BankKeeper, app.StakingKeeper) @@ -238,7 +239,7 @@ func TestSimulateMsgBeginRedelegate(t *testing.T) { setupValidatorRewards(app, ctx, validator1.OperatorAddress) // begin a new block - app.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash, Time: blockTime}}) + app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash, Time: blockTime}}) // execute operation op := simulation.SimulateMsgBeginRedelegate(app.AccountKeeper, app.BankKeeper, app.StakingKeeper) @@ -263,7 +264,7 @@ func TestSimulateMsgBeginRedelegate(t *testing.T) { func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) { app := simapp.Setup(isCheckTx) - ctx := app.BaseApp.NewContext(isCheckTx, abci.Header{}) + ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) app.MintKeeper.SetParams(ctx, minttypes.DefaultParams()) app.MintKeeper.SetMinter(ctx, minttypes.DefaultInitialMinter()) diff --git a/x/staking/types/historical_info.go b/x/staking/types/historical_info.go index 7af34d13c5e9..fc4dc2906bae 100644 --- a/x/staking/types/historical_info.go +++ b/x/staking/types/historical_info.go @@ -3,7 +3,7 @@ package types import ( "sort" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -11,7 +11,7 @@ import ( // NewHistoricalInfo will create a historical information struct from header and valset // it will first sort valset before inclusion into historical info -func NewHistoricalInfo(header abci.Header, valSet Validators) HistoricalInfo { +func NewHistoricalInfo(header tmproto.Header, valSet Validators) HistoricalInfo { sort.Sort(valSet) return HistoricalInfo{ diff --git a/x/staking/types/historical_info_test.go b/x/staking/types/historical_info_test.go index 32e149af56a9..e37ca88218b5 100644 --- a/x/staking/types/historical_info_test.go +++ b/x/staking/types/historical_info_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) var ( @@ -15,7 +15,7 @@ var ( NewValidator(valAddr2, pk2, Description{}), NewValidator(valAddr3, pk3, Description{}), } - header = abci.Header{ + header = tmproto.Header{ ChainID: "hello", Height: 5, } diff --git a/x/staking/types/staking.pb.go b/x/staking/types/staking.pb.go index f8a27b46f098..4c154f05b5f1 100644 --- a/x/staking/types/staking.pb.go +++ b/x/staking/types/staking.pb.go @@ -16,7 +16,7 @@ import ( github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" _ "github.com/golang/protobuf/ptypes/duration" _ "github.com/golang/protobuf/ptypes/timestamp" - types1 "github.com/tendermint/tendermint/abci/types" + types1 "github.com/tendermint/tendermint/proto/tendermint/types" io "io" io_ioutil "io/ioutil" math "math" @@ -2353,38 +2353,6 @@ func (this *MsgUndelegate) Equal(that interface{}) bool { } return true } -func (this *HistoricalInfo) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*HistoricalInfo) - if !ok { - that2, ok := that.(HistoricalInfo) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if !this.Header.Equal(&that1.Header) { - return false - } - if len(this.Valset) != len(that1.Valset) { - return false - } - for i := range this.Valset { - if !this.Valset[i].Equal(&that1.Valset[i]) { - return false - } - } - return true -} func (this *CommissionRates) Equal(that interface{}) bool { if that == nil { return this == nil diff --git a/x/staking/types/validator.go b/x/staking/types/validator.go index b18d3eb2ecd9..f4b21a46e359 100644 --- a/x/staking/types/validator.go +++ b/x/staking/types/validator.go @@ -9,6 +9,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto" + cryptoenc "github.com/tendermint/tendermint/crypto/encoding" tmtypes "github.com/tendermint/tendermint/types" yaml "gopkg.in/yaml.v2" @@ -222,20 +223,28 @@ func (d Description) EnsureLength() (Description, error) { // ABCIValidatorUpdate returns an abci.ValidatorUpdate from a staking validator type // with the full validator power -func (v Validator) ABCIValidatorUpdate() abci.ValidatorUpdate { +func (v Validator) ABCIValidatorUpdate() (abci.ValidatorUpdate, error) { + pk, err := cryptoenc.PubKeyToProto(v.GetConsPubKey()) + if err != nil { + return abci.ValidatorUpdate{}, err + } return abci.ValidatorUpdate{ - PubKey: tmtypes.TM2PB.PubKey(v.GetConsPubKey()), + PubKey: pk, Power: v.ConsensusPower(), - } + }, nil } // ABCIValidatorUpdateZero returns an abci.ValidatorUpdate from a staking validator type // with zero power used for validator updates. -func (v Validator) ABCIValidatorUpdateZero() abci.ValidatorUpdate { +func (v Validator) ABCIValidatorUpdateZero() (abci.ValidatorUpdate, error) { + pk, err := cryptoenc.PubKeyToProto(v.GetConsPubKey()) + if err != nil { + return abci.ValidatorUpdate{}, err + } return abci.ValidatorUpdate{ - PubKey: tmtypes.TM2PB.PubKey(v.GetConsPubKey()), + PubKey: pk, Power: 0, - } + }, nil } // ToTmValidator casts an SDK validator to a tendermint type Validator. diff --git a/x/staking/types/validator_test.go b/x/staking/types/validator_test.go index e914a87e8792..145ebe87a35a 100644 --- a/x/staking/types/validator_test.go +++ b/x/staking/types/validator_test.go @@ -9,6 +9,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto/ed25519" + cryptoenc "github.com/tendermint/tendermint/crypto/encoding" tmtypes "github.com/tendermint/tendermint/types" "github.com/cosmos/cosmos-sdk/codec/legacy" @@ -60,16 +61,26 @@ func TestUpdateDescription(t *testing.T) { func TestABCIValidatorUpdate(t *testing.T) { validator := NewValidator(valAddr1, pk1, Description{}) - abciVal := validator.ABCIValidatorUpdate() - require.Equal(t, tmtypes.TM2PB.PubKey(validator.GetConsPubKey()), abciVal.PubKey) + abciVal, err := validator.ABCIValidatorUpdate() + require.NoError(t, err) + + pk, err := cryptoenc.PubKeyToProto(validator.GetConsPubKey()) + require.NoError(t, err) + + require.Equal(t, pk, abciVal.PubKey) require.Equal(t, validator.BondedTokens().Int64(), abciVal.Power) } func TestABCIValidatorUpdateZero(t *testing.T) { validator := NewValidator(valAddr1, pk1, Description{}) - abciVal := validator.ABCIValidatorUpdateZero() - require.Equal(t, tmtypes.TM2PB.PubKey(validator.GetConsPubKey()), abciVal.PubKey) + abciVal, err := validator.ABCIValidatorUpdateZero() + require.NoError(t, err) + + pk, err := cryptoenc.PubKeyToProto(validator.GetConsPubKey()) + require.NoError(t, err) + + require.Equal(t, pk, abciVal.PubKey) require.Equal(t, int64(0), abciVal.Power) } diff --git a/x/upgrade/abci_test.go b/x/upgrade/abci_test.go index 2f7cbdf3a708..af59e0fb04fb 100644 --- a/x/upgrade/abci_test.go +++ b/x/upgrade/abci_test.go @@ -13,6 +13,7 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/codec" @@ -52,7 +53,7 @@ func setupTest(height int64, skip map[int64]bool) TestSuite { ) s.keeper = app.UpgradeKeeper - s.ctx = app.BaseApp.NewContext(false, abci.Header{Height: height, Time: time.Now()}) + s.ctx = app.BaseApp.NewContext(false, tmproto.Header{Height: height, Time: time.Now()}) s.module = upgrade.NewAppModule(s.keeper) s.querier = s.module.LegacyQuerierHandler(codec.NewAminoCodec(app.Codec())) diff --git a/x/upgrade/keeper/grpc_query_test.go b/x/upgrade/keeper/grpc_query_test.go index 1ffb0038f6cd..d307157402de 100644 --- a/x/upgrade/keeper/grpc_query_test.go +++ b/x/upgrade/keeper/grpc_query_test.go @@ -6,8 +6,7 @@ import ( "testing" "github.com/stretchr/testify/suite" - - abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/simapp" @@ -25,7 +24,7 @@ type UpgradeTestSuite struct { func (suite *UpgradeTestSuite) SetupTest() { suite.app = simapp.Setup(false) - suite.ctx = suite.app.BaseApp.NewContext(false, abci.Header{}) + suite.ctx = suite.app.BaseApp.NewContext(false, tmproto.Header{}) queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.app.InterfaceRegistry()) types.RegisterQueryServer(queryHelper, suite.app.UpgradeKeeper) diff --git a/x/upgrade/types/plan_test.go b/x/upgrade/types/plan_test.go index 57e025a0398d..5ad6efde05a9 100644 --- a/x/upgrade/types/plan_test.go +++ b/x/upgrade/types/plan_test.go @@ -7,8 +7,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -179,7 +179,7 @@ func TestShouldExecute(t *testing.T) { for name, tc := range cases { tc := tc // copy to local variable for scopelint t.Run(name, func(t *testing.T) { - ctx := sdk.NewContext(nil, abci.Header{Height: tc.ctxHeight, Time: tc.ctxTime}, false, log.NewNopLogger()) + ctx := sdk.NewContext(nil, tmproto.Header{Height: tc.ctxHeight, Time: tc.ctxTime}, false, log.NewNopLogger()) should := tc.p.ShouldExecute(ctx) assert.Equal(t, tc.expected, should) }) diff --git a/x/upgrade/types/storeloader_test.go b/x/upgrade/types/storeloader_test.go index a77b7593e288..7fd147013e55 100644 --- a/x/upgrade/types/storeloader_test.go +++ b/x/upgrade/types/storeloader_test.go @@ -10,6 +10,7 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/baseapp" @@ -128,7 +129,7 @@ func TestSetLoader(t *testing.T) { require.Nil(t, err) // "execute" one block - app.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: 2}}) + app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: 2}}) res := app.Commit() require.NotNil(t, res.Data)