From b72f87a0270cf6b234f5e4d15855c032cf5a1d6e Mon Sep 17 00:00:00 2001 From: Jeremiah Andrews Date: Fri, 3 Aug 2018 16:24:03 -0700 Subject: [PATCH 1/7] Update IAVL dependency for v0.10.0 --- Gopkg.lock | 8 ++++---- Gopkg.toml | 2 +- store/iavlstore.go | 16 ++++++++-------- store/iavlstore_test.go | 12 ++++++------ store/prefixstore_test.go | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 5e40c17e6cc2..5edc19816d15 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -415,12 +415,12 @@ version = "v0.12.0-rc0" [[projects]] - digest = "1:d4a15d404afbf591e8be16fcda7f5ac87948d5c7531f9d909fd84cc730ab16e2" + digest = "1:e99ef92d64f2391efbbfb15310df635f96247532bbac2676ea43e466d706401d" name = "github.com/tendermint/iavl" packages = ["."] pruneopts = "UT" - revision = "35f66e53d9b01e83b30de68b931f54b2477a94c9" - version = "v0.9.2" + revision = "e5726c0066ccdd299a2ec9262f93c7896cdfcd87" + version = "v0.10.0" [[projects]] digest = "1:4f15e95fe3888cc75dd34f407d6394cbc7fd3ff24920851b92b295f6a8b556e6" @@ -579,7 +579,7 @@ [[projects]] branch = "master" - digest = "1:077c1c599507b3b3e9156d17d36e1e61928ee9b53a5b420f10f28ebd4a0b275c" + digest = "1:601e63e7d4577f907118bec825902505291918859d223bce015539e79f1160e3" name = "google.golang.org/genproto" packages = ["googleapis/rpc/status"] pruneopts = "UT" diff --git a/Gopkg.toml b/Gopkg.toml index 4368699b6be9..f8194ccd015d 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -53,7 +53,7 @@ [[override]] name = "github.com/tendermint/iavl" - version = "=v0.9.2" + version = "=v0.10.0" [[override]] name = "github.com/tendermint/tendermint" diff --git a/store/iavlstore.go b/store/iavlstore.go index daffa7dd5553..57c10323842e 100644 --- a/store/iavlstore.go +++ b/store/iavlstore.go @@ -20,7 +20,7 @@ const ( // load the iavl store func LoadIAVLStore(db dbm.DB, id CommitID, pruning sdk.PruningStrategy) (CommitStore, error) { - tree := iavl.NewVersionedTree(db, defaultIAVLCacheSize) + tree := iavl.NewMutableTree(db, defaultIAVLCacheSize) _, err := tree.LoadVersion(id.Version) if err != nil { return nil, err @@ -40,7 +40,7 @@ var _ Queryable = (*iavlStore)(nil) type iavlStore struct { // The underlying tree. - tree *iavl.VersionedTree + tree *iavl.MutableTree // How many old versions we hold onto. // A value of 0 means keep no recent states. @@ -56,7 +56,7 @@ type iavlStore struct { } // CONTRACT: tree should be fully loaded. -func newIAVLStore(tree *iavl.VersionedTree, numRecent int64, storeEvery int64) *iavlStore { +func newIAVLStore(tree *iavl.MutableTree, numRecent int64, storeEvery int64) *iavlStore { st := &iavlStore{ tree: tree, numRecent: numRecent, @@ -167,16 +167,16 @@ func (st *iavlStore) Gas(meter GasMeter, config GasConfig) KVStore { // Implements KVStore. func (st *iavlStore) Iterator(start, end []byte) Iterator { - return newIAVLIterator(st.tree.Tree(), start, end, true) + return newIAVLIterator(st.tree.ImmutableTree, start, end, true) } // Implements KVStore. func (st *iavlStore) ReverseIterator(start, end []byte) Iterator { - return newIAVLIterator(st.tree.Tree(), start, end, false) + return newIAVLIterator(st.tree.ImmutableTree, start, end, false) } // Handle gatest the latest height, if height is 0 -func getHeight(tree *iavl.VersionedTree, req abci.RequestQuery) int64 { +func getHeight(tree *iavl.MutableTree, req abci.RequestQuery) int64 { height := req.Height if height == 0 { latest := tree.Version64() @@ -255,7 +255,7 @@ func (st *iavlStore) Query(req abci.RequestQuery) (res abci.ResponseQuery) { // Implements Iterator. type iavlIterator struct { // Underlying store - tree *iavl.Tree + tree *iavl.ImmutableTree // Domain start, end []byte @@ -286,7 +286,7 @@ var _ Iterator = (*iavlIterator)(nil) // newIAVLIterator will create a new iavlIterator. // CONTRACT: Caller must release the iavlIterator, as each one creates a new // goroutine. -func newIAVLIterator(tree *iavl.Tree, start, end []byte, ascending bool) *iavlIterator { +func newIAVLIterator(tree *iavl.ImmutableTree, start, end []byte, ascending bool) *iavlIterator { iter := &iavlIterator{ tree: tree, start: cp(start), diff --git a/store/iavlstore_test.go b/store/iavlstore_test.go index 793089a26e86..c200a63d4a2f 100644 --- a/store/iavlstore_test.go +++ b/store/iavlstore_test.go @@ -29,8 +29,8 @@ var ( ) // make a tree and save it -func newTree(t *testing.T, db dbm.DB) (*iavl.VersionedTree, CommitID) { - tree := iavl.NewVersionedTree(db, cacheSize) +func newTree(t *testing.T, db dbm.DB) (*iavl.MutableTree, CommitID) { + tree := iavl.NewMutableTree(db, cacheSize) for k, v := range treeData { tree.Set([]byte(k), []byte(v)) } @@ -325,7 +325,7 @@ type pruneState struct { func testPruning(t *testing.T, numRecent int64, storeEvery int64, states []pruneState) { db := dbm.NewMemDB() - tree := iavl.NewVersionedTree(db, cacheSize) + tree := iavl.NewMutableTree(db, cacheSize) iavlStore := newIAVLStore(tree, numRecent, storeEvery) for step, state := range states { for _, ver := range state.stored { @@ -344,7 +344,7 @@ func testPruning(t *testing.T, numRecent int64, storeEvery int64, states []prune func TestIAVLNoPrune(t *testing.T) { db := dbm.NewMemDB() - tree := iavl.NewVersionedTree(db, cacheSize) + tree := iavl.NewMutableTree(db, cacheSize) iavlStore := newIAVLStore(tree, numRecent, int64(1)) nextVersion(iavlStore) for i := 1; i < 100; i++ { @@ -359,7 +359,7 @@ func TestIAVLNoPrune(t *testing.T) { func TestIAVLPruneEverything(t *testing.T) { db := dbm.NewMemDB() - tree := iavl.NewVersionedTree(db, cacheSize) + tree := iavl.NewMutableTree(db, cacheSize) iavlStore := newIAVLStore(tree, int64(0), int64(0)) nextVersion(iavlStore) for i := 1; i < 100; i++ { @@ -377,7 +377,7 @@ func TestIAVLPruneEverything(t *testing.T) { func TestIAVLStoreQuery(t *testing.T) { db := dbm.NewMemDB() - tree := iavl.NewVersionedTree(db, cacheSize) + tree := iavl.NewMutableTree(db, cacheSize) iavlStore := newIAVLStore(tree, numRecent, storeEvery) k1, v1 := []byte("key1"), []byte("val1") diff --git a/store/prefixstore_test.go b/store/prefixstore_test.go index ff37b27d4719..49bc68037a72 100644 --- a/store/prefixstore_test.go +++ b/store/prefixstore_test.go @@ -66,7 +66,7 @@ func testPrefixStore(t *testing.T, baseStore KVStore, prefix []byte) { func TestIAVLStorePrefix(t *testing.T) { db := dbm.NewMemDB() - tree := iavl.NewVersionedTree(db, cacheSize) + tree := iavl.NewMutableTree(db, cacheSize) iavlStore := newIAVLStore(tree, numRecent, storeEvery) testPrefixStore(t, iavlStore, []byte("test")) From b83e6e8b1aa21422a27533da949bed6b587809e9 Mon Sep 17 00:00:00 2001 From: Jeremiah Andrews Date: Mon, 20 Aug 2018 22:15:58 -0700 Subject: [PATCH 2/7] Add to pending changelog --- PENDING.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/PENDING.md b/PENDING.md index 17616ced1a4d..00e609039f77 100644 --- a/PENDING.md +++ b/PENDING.md @@ -1,4 +1,17 @@ -## PENDING +## v0.24.1 PENDING + +BREAKING CHANGES + +FEATURES + +IMPROVEMENTS + +* [store] \#1952 Update IAVL dependency to v0.10.0 + +BUG FIXES + +## v0.24.0 PENDING +^--- PENDING wasn't purged on sdk v0.23.0 release. BREAKING CHANGES From bd227ec6dbca3623a72f382ffe9053b80ab325cb Mon Sep 17 00:00:00 2001 From: Christopher Goes Date: Tue, 21 Aug 2018 15:53:44 +0200 Subject: [PATCH 3/7] dep ensure -v -update --- Gopkg.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 5edc19816d15..2245223419a4 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -552,7 +552,7 @@ "unix", ] pruneopts = "UT" - revision = "11551d06cbcc94edc80a0facaccbda56473c19c1" + revision = "4ea2f632f6e912459fe60b26b1749377f0d889d5" [[projects]] digest = "1:a2ab62866c75542dd18d2b069fec854577a20211d7c0ea6ae746072a1dccdd18" @@ -579,7 +579,7 @@ [[projects]] branch = "master" - digest = "1:601e63e7d4577f907118bec825902505291918859d223bce015539e79f1160e3" + digest = "1:077c1c599507b3b3e9156d17d36e1e61928ee9b53a5b420f10f28ebd4a0b275c" name = "google.golang.org/genproto" packages = ["googleapis/rpc/status"] pruneopts = "UT" From 3ac55b589dfd7b5b22135451c41b2fa84017f016 Mon Sep 17 00:00:00 2001 From: Christopher Goes Date: Wed, 29 Aug 2018 15:08:04 +0200 Subject: [PATCH 4/7] Update testcase from merge --- store/iavlstore_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/store/iavlstore_test.go b/store/iavlstore_test.go index c200a63d4a2f..49793d376620 100644 --- a/store/iavlstore_test.go +++ b/store/iavlstore_test.go @@ -468,7 +468,7 @@ func TestIAVLStoreQuery(t *testing.T) { func BenchmarkIAVLIteratorNext(b *testing.B) { db := dbm.NewMemDB() treeSize := 1000 - tree := iavl.NewVersionedTree(db, cacheSize) + tree := iavl.NewMutableTree(db, cacheSize) for i := 0; i < treeSize; i++ { key := cmn.RandBytes(4) value := cmn.RandBytes(50) From 2378e3431c050d4763a7d362a71f07b98ce1d532 Mon Sep 17 00:00:00 2001 From: Jeremiah Andrews Date: Fri, 31 Aug 2018 15:22:37 -0700 Subject: [PATCH 5/7] Fix linter errors --- baseapp/baseapp.go | 1 + baseapp/baseapp_test.go | 4 ++-- client/context/query.go | 4 +++- cmd/cosmos-sdk-cli/cmd/init.go | 3 +++ examples/democoin/x/assoc/validator_set.go | 3 +++ server/init.go | 1 + server/start.go | 1 + store/iavlstore.go | 1 + store/multistoreproof_test.go | 8 +++++--- store/tracekvstore.go | 1 + store/tracekvstore_test.go | 8 ++++---- tests/gobash.go | 1 + types/account.go | 3 +++ types/context.go | 1 + types/errors.go | 1 + x/auth/client/cli/account.go | 1 + x/gov/depositsvotes.go | 1 + x/gov/keeper.go | 6 ++++++ x/gov/proposals.go | 2 ++ x/gov/queryable.go | 7 +++++++ x/gov/simulation/msgs.go | 1 + x/ibc/client/cli/relay.go | 1 + x/mock/app.go | 2 ++ x/mock/simulation/random_simulate_blocks.go | 1 + x/params/keeper.go | 1 + x/params/msg_status.go | 1 + x/slashing/client/rest/query.go | 1 + x/slashing/keeper_test.go | 10 +++++----- x/stake/client/rest/utils.go | 1 + x/stake/handler_test.go | 2 +- x/stake/keeper/key.go | 1 + x/stake/keeper/slash.go | 1 + x/stake/keeper/validator.go | 2 ++ x/stake/simulation/invariants.go | 1 + x/stake/simulation/msgs.go | 1 + x/stake/types/delegation_test.go | 4 ++-- 36 files changed, 71 insertions(+), 18 deletions(-) diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 60c694ff766e..5552ff78473e 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -345,6 +345,7 @@ func handleQueryStore(app *BaseApp, path []string, req abci.RequestQuery) (res a return queryable.Query(req) } +// nolint: unparam func handleQueryP2P(app *BaseApp, path []string, req abci.RequestQuery) (res abci.ResponseQuery) { // "/p2p" prefix for p2p queries if len(path) >= 4 { diff --git a/baseapp/baseapp_test.go b/baseapp/baseapp_test.go index 04e47214dd2f..b8716278621b 100644 --- a/baseapp/baseapp_test.go +++ b/baseapp/baseapp_test.go @@ -626,12 +626,12 @@ func TestSimulateTx(t *testing.T) { // simulate a message, check gas reported result := app.Simulate(tx) require.True(t, result.IsOK(), result.Log) - require.Equal(t, int64(gasConsumed), result.GasUsed) + require.Equal(t, gasConsumed, result.GasUsed) // simulate again, same result result = app.Simulate(tx) require.True(t, result.IsOK(), result.Log) - require.Equal(t, int64(gasConsumed), result.GasUsed) + require.Equal(t, gasConsumed, result.GasUsed) // simulate by calling Query with encoded tx txBytes, err := codec.MarshalBinary(tx) diff --git a/client/context/query.go b/client/context/query.go index 4c1cad877785..33610bc15bfe 100644 --- a/client/context/query.go +++ b/client/context/query.go @@ -10,6 +10,8 @@ import ( "github.com/pkg/errors" + "strings" + "github.com/cosmos/cosmos-sdk/store" "github.com/cosmos/cosmos-sdk/wire" abci "github.com/tendermint/tendermint/abci/types" @@ -17,7 +19,6 @@ import ( tmliteProxy "github.com/tendermint/tendermint/lite/proxy" rpcclient "github.com/tendermint/tendermint/rpc/client" ctypes "github.com/tendermint/tendermint/rpc/core/types" - "strings" ) // GetNode returns an RPC client. If the context's client is not defined, an @@ -323,6 +324,7 @@ func (ctx CLIContext) query(path string, key cmn.HexBytes) (res []byte, err erro } // verifyProof perform response proof verification +// nolint: unparam func (ctx CLIContext) verifyProof(path string, resp abci.ResponseQuery) error { if ctx.Certifier == nil { diff --git a/cmd/cosmos-sdk-cli/cmd/init.go b/cmd/cosmos-sdk-cli/cmd/init.go index 8cebc48f29a1..e9e9cd8a9287 100644 --- a/cmd/cosmos-sdk-cli/cmd/init.go +++ b/cmd/cosmos-sdk-cli/cmd/init.go @@ -60,6 +60,7 @@ func resolveProjectPath(remoteProjectPath string) string { return gopath + string(os.PathSeparator) + "src" + string(os.PathSeparator) + remoteProjectPath } +// nolint: unparam, errcheck func copyBasecoinTemplate(projectName string, projectPath string, remoteProjectPath string) { basecoinProjectPath := resolveProjectPath(remoteBasecoinPath) filepath.Walk(basecoinProjectPath, func(path string, f os.FileInfo, err error) error { @@ -88,6 +89,7 @@ func copyBasecoinTemplate(projectName string, projectPath string, remoteProjectP }) } +// nolint: errcheck func createGopkg(projectPath string) { // Create gopkg.toml file dependencies := map[string]string{ @@ -111,6 +113,7 @@ func createGopkg(projectPath string) { ioutil.WriteFile(projectPath+"/Gopkg.toml", []byte(contents), os.ModePerm) } +// nolint: errcheck func createMakefile(projectPath string) { // Create makefile // TODO: Should we use tools/ directory as in Cosmos-SDK to get tools for linting etc. diff --git a/examples/democoin/x/assoc/validator_set.go b/examples/democoin/x/assoc/validator_set.go index 8a954c72037c..7515e1ad6022 100644 --- a/examples/democoin/x/assoc/validator_set.go +++ b/examples/democoin/x/assoc/validator_set.go @@ -62,6 +62,7 @@ func GetAssocKey(base sdk.ValAddress, assoc sdk.ValAddress) []byte { } // Associate associates new address with validator address +// nolint: unparam func (valset ValidatorSet) Associate(ctx sdk.Context, base sdk.ValAddress, assoc sdk.ValAddress) bool { if len(base) != valset.addrLen || len(assoc) != valset.addrLen { return false @@ -76,6 +77,7 @@ func (valset ValidatorSet) Associate(ctx sdk.Context, base sdk.ValAddress, assoc } // Dissociate removes association between addresses +// nolint: unparam func (valset ValidatorSet) Dissociate(ctx sdk.Context, base sdk.ValAddress, assoc sdk.ValAddress) bool { if len(base) != valset.addrLen || len(assoc) != valset.addrLen { return false @@ -90,6 +92,7 @@ func (valset ValidatorSet) Dissociate(ctx sdk.Context, base sdk.ValAddress, asso } // Associations returns all associated addresses with a validator +// nolint: unparam func (valset ValidatorSet) Associations(ctx sdk.Context, base sdk.ValAddress) (res []sdk.ValAddress) { res = make([]sdk.ValAddress, valset.maxAssoc) iter := sdk.KVStorePrefixIterator(valset.store, GetAssocPrefix(base)) diff --git a/server/init.go b/server/init.go index 105325e0d5bd..ffe2b6eddc76 100644 --- a/server/init.go +++ b/server/init.go @@ -344,6 +344,7 @@ func readOrCreatePrivValidator(tmConfig *cfg.Config) crypto.PubKey { // writeGenesisFile creates and writes the genesis configuration to disk. An // error is returned if building or writing the configuration to file fails. +// nolint: unparam func writeGenesisFile(cdc *wire.Codec, genesisFile, chainID string, validators []tmtypes.GenesisValidator, appState json.RawMessage) error { genDoc := tmtypes.GenesisDoc{ ChainID: chainID, diff --git a/server/start.go b/server/start.go index 8f369d517fbf..829e3936393a 100644 --- a/server/start.go +++ b/server/start.go @@ -84,6 +84,7 @@ func startStandAlone(ctx *Context, appCreator AppCreator) error { return nil } +// nolint: unparam func startInProcess(ctx *Context, appCreator AppCreator) (*node.Node, error) { cfg := ctx.Config home := cfg.RootDir diff --git a/store/iavlstore.go b/store/iavlstore.go index 57c10323842e..61bdc5630796 100644 --- a/store/iavlstore.go +++ b/store/iavlstore.go @@ -56,6 +56,7 @@ type iavlStore struct { } // CONTRACT: tree should be fully loaded. +// nolint: unparam func newIAVLStore(tree *iavl.MutableTree, numRecent int64, storeEvery int64) *iavlStore { st := &iavlStore{ tree: tree, diff --git a/store/multistoreproof_test.go b/store/multistoreproof_test.go index b4e8a84b1664..790588fb2929 100644 --- a/store/multistoreproof_test.go +++ b/store/multistoreproof_test.go @@ -2,10 +2,12 @@ package store import ( "encoding/hex" + "testing" + "github.com/stretchr/testify/assert" "github.com/tendermint/iavl" cmn "github.com/tendermint/tendermint/libs/common" - "testing" + "github.com/tendermint/tendermint/libs/db" ) func TestVerifyMultiStoreCommitInfo(t *testing.T) { @@ -91,7 +93,7 @@ func TestVerifyMultiStoreCommitInfo(t *testing.T) { } func TestVerifyRangeProof(t *testing.T) { - tree := iavl.NewTree(nil, 0) + tree := iavl.NewMutableTree(db.NewMemDB(), 0) rand := cmn.NewRand() rand.Seed(0) // for determinism @@ -100,7 +102,7 @@ func TestVerifyRangeProof(t *testing.T) { tree.Set(key, []byte(rand.Str(8))) } - root := tree.Hash() + root := tree.WorkingHash() key := []byte{0x32} val, proof, err := tree.GetWithProof(key) diff --git a/store/tracekvstore.go b/store/tracekvstore.go index 0224e8c123db..d8c34c354542 100644 --- a/store/tracekvstore.go +++ b/store/tracekvstore.go @@ -179,6 +179,7 @@ func (tkv *TraceKVStore) CacheWrapWithTrace(_ io.Writer, _ TraceContext) CacheWr // writeOperation writes a KVStore operation to the underlying io.Writer as // JSON-encoded data where the key/value pair is base64 encoded. +// nolint: errcheck func writeOperation(w io.Writer, op operation, tc TraceContext, key, value []byte) { traceOp := traceOperation{ Operation: op, diff --git a/store/tracekvstore_test.go b/store/tracekvstore_test.go index 2182c5288634..887fcf96e5c9 100644 --- a/store/tracekvstore_test.go +++ b/store/tracekvstore_test.go @@ -156,8 +156,8 @@ func TestTestTraceKVStoreIterator(t *testing.T) { iterator := store.Iterator(nil, nil) s, e := iterator.Domain() - require.Equal(t, []uint8([]byte(nil)), s) - require.Equal(t, []uint8([]byte(nil)), e) + require.Equal(t, []byte(nil), s) + require.Equal(t, []byte(nil), e) testCases := []struct { expectedKey []byte @@ -212,8 +212,8 @@ func TestTestTraceKVStoreReverseIterator(t *testing.T) { iterator := store.ReverseIterator(nil, nil) s, e := iterator.Domain() - require.Equal(t, []uint8([]byte(nil)), s) - require.Equal(t, []uint8([]byte(nil)), e) + require.Equal(t, []byte(nil), s) + require.Equal(t, []byte(nil), e) testCases := []struct { expectedKey []byte diff --git a/tests/gobash.go b/tests/gobash.go index 11f4407f2332..6282f2fda4c4 100644 --- a/tests/gobash.go +++ b/tests/gobash.go @@ -13,6 +13,7 @@ import ( // ExecuteT executes the command, pipes any input to STDIN and return STDOUT, // logging STDOUT/STDERR to t. +// nolint: errcheck func ExecuteT(t *testing.T, cmd, input string) (out string) { t.Log("Running", cmn.Cyan(cmd)) diff --git a/types/account.go b/types/account.go index 429cbf2857dc..943867d79b88 100644 --- a/types/account.go +++ b/types/account.go @@ -133,6 +133,7 @@ func (aa AccAddress) String() string { } // Format implements the fmt.Formatter interface. +// nolint: errcheck func (aa AccAddress) Format(s fmt.State, verb rune) { switch verb { case 's': @@ -247,6 +248,7 @@ func (va ValAddress) String() string { } // Format implements the fmt.Formatter interface. +// nolint: errcheck func (va ValAddress) Format(s fmt.State, verb rune) { switch verb { case 's': @@ -361,6 +363,7 @@ func (ca ConsAddress) String() string { } // Format implements the fmt.Formatter interface. +// nolint: errcheck func (ca ConsAddress) Format(s fmt.State, verb rune) { switch verb { case 's': diff --git a/types/context.go b/types/context.go index 44b0474e8b6b..85fb16a7ff17 100644 --- a/types/context.go +++ b/types/context.go @@ -30,6 +30,7 @@ type Context struct { } // create a new context +// nolint: unparam func NewContext(ms MultiStore, header abci.Header, isCheckTx bool, logger log.Logger) Context { c := Context{ Context: context.Background(), diff --git a/types/errors.go b/types/errors.go index 45ef79f56a6e..c72933d6056d 100644 --- a/types/errors.go +++ b/types/errors.go @@ -219,6 +219,7 @@ func (err *sdkError) WithDefaultCodespace(cs CodespaceType) Error { } // Implements ABCIError. +// nolint: errcheck func (err *sdkError) TraceSDK(format string, args ...interface{}) Error { err.Trace(1, format, args...) return err diff --git a/x/auth/client/cli/account.go b/x/auth/client/cli/account.go index 3b93798a0dc1..6f6359288238 100644 --- a/x/auth/client/cli/account.go +++ b/x/auth/client/cli/account.go @@ -30,6 +30,7 @@ func GetAccountDecoder(cdc *wire.Codec) auth.AccountDecoder { // GetAccountCmd returns a query account that will display the state of the // account at a given address. +// nolint: unparam func GetAccountCmd(storeName string, cdc *wire.Codec, decoder auth.AccountDecoder) *cobra.Command { return &cobra.Command{ Use: "account [address]", diff --git a/x/gov/depositsvotes.go b/x/gov/depositsvotes.go index b5c65931fc7e..d1179023fa4b 100644 --- a/x/gov/depositsvotes.go +++ b/x/gov/depositsvotes.go @@ -132,6 +132,7 @@ func (vo VoteOption) String() string { } // For Printf / Sprintf, returns bech32 when using %s +// nolint: errcheck func (vo VoteOption) Format(s fmt.State, verb rune) { switch verb { case 's': diff --git a/x/gov/keeper.go b/x/gov/keeper.go index e8dbbc4a7f09..576d2cc22f14 100644 --- a/x/gov/keeper.go +++ b/x/gov/keeper.go @@ -210,6 +210,7 @@ func (keeper Keeper) activateVotingPeriod(ctx sdk.Context, proposal Proposal) { // Procedures // Returns the current Deposit Procedure from the global param store +// nolint: errcheck func (keeper Keeper) GetDepositProcedure(ctx sdk.Context) DepositProcedure { var depositProcedure DepositProcedure keeper.ps.Get(ctx, ParamStoreKeyDepositProcedure, &depositProcedure) @@ -217,6 +218,7 @@ func (keeper Keeper) GetDepositProcedure(ctx sdk.Context) DepositProcedure { } // Returns the current Voting Procedure from the global param store +// nolint: errcheck func (keeper Keeper) GetVotingProcedure(ctx sdk.Context) VotingProcedure { var votingProcedure VotingProcedure keeper.ps.Get(ctx, ParamStoreKeyVotingProcedure, &votingProcedure) @@ -224,20 +226,24 @@ func (keeper Keeper) GetVotingProcedure(ctx sdk.Context) VotingProcedure { } // Returns the current Tallying Procedure from the global param store +// nolint: errcheck func (keeper Keeper) GetTallyingProcedure(ctx sdk.Context) TallyingProcedure { var tallyingProcedure TallyingProcedure keeper.ps.Get(ctx, ParamStoreKeyTallyingProcedure, &tallyingProcedure) return tallyingProcedure } +// nolint: errcheck func (keeper Keeper) setDepositProcedure(ctx sdk.Context, depositProcedure DepositProcedure) { keeper.ps.Set(ctx, ParamStoreKeyDepositProcedure, &depositProcedure) } +// nolint: errcheck func (keeper Keeper) setVotingProcedure(ctx sdk.Context, votingProcedure VotingProcedure) { keeper.ps.Set(ctx, ParamStoreKeyVotingProcedure, &votingProcedure) } +// nolint: errcheck func (keeper Keeper) setTallyingProcedure(ctx sdk.Context, tallyingProcedure TallyingProcedure) { keeper.ps.Set(ctx, ParamStoreKeyTallyingProcedure, &tallyingProcedure) } diff --git a/x/gov/proposals.go b/x/gov/proposals.go index c52ab1e8759d..b4c6783673a2 100644 --- a/x/gov/proposals.go +++ b/x/gov/proposals.go @@ -187,6 +187,7 @@ func (pt ProposalKind) String() string { } // For Printf / Sprintf, returns bech32 when using %s +// nolint: errcheck func (pt ProposalKind) Format(s fmt.State, verb rune) { switch verb { case 's': @@ -289,6 +290,7 @@ func (status ProposalStatus) String() string { } // For Printf / Sprintf, returns bech32 when using %s +// nolint: errcheck func (status ProposalStatus) Format(s fmt.State, verb rune) { switch verb { case 's': diff --git a/x/gov/queryable.go b/x/gov/queryable.go index e64d506d1e87..090b9a91455a 100644 --- a/x/gov/queryable.go +++ b/x/gov/queryable.go @@ -36,6 +36,7 @@ type QueryProposalParams struct { ProposalID int64 } +// nolint: unparam func queryProposal(ctx sdk.Context, path []string, req abci.RequestQuery, keeper Keeper) (res []byte, err sdk.Error) { var params QueryProposalParams err2 := keeper.cdc.UnmarshalJSON(req.Data, ¶ms) @@ -61,6 +62,7 @@ type QueryDepositParams struct { Depositer sdk.AccAddress } +// nolint: unparam func queryDeposit(ctx sdk.Context, path []string, req abci.RequestQuery, keeper Keeper) (res []byte, err sdk.Error) { var params QueryDepositParams err2 := keeper.cdc.UnmarshalJSON(req.Data, ¶ms) @@ -82,6 +84,7 @@ type QueryVoteParams struct { Voter sdk.AccAddress } +// nolint: unparam func queryVote(ctx sdk.Context, path []string, req abci.RequestQuery, keeper Keeper) (res []byte, err sdk.Error) { var params QueryVoteParams err2 := keeper.cdc.UnmarshalJSON(req.Data, ¶ms) @@ -102,6 +105,7 @@ type QueryDepositsParams struct { ProposalID int64 } +// nolint: unparam func queryDeposits(ctx sdk.Context, path []string, req abci.RequestQuery, keeper Keeper) (res []byte, err sdk.Error) { var params QueryDepositParams err2 := keeper.cdc.UnmarshalJSON(req.Data, ¶ms) @@ -129,6 +133,7 @@ type QueryVotesParams struct { ProposalID int64 } +// nolint: unparam func queryVotes(ctx sdk.Context, path []string, req abci.RequestQuery, keeper Keeper) (res []byte, err sdk.Error) { var params QueryVotesParams err2 := keeper.cdc.UnmarshalJSON(req.Data, ¶ms) @@ -160,6 +165,7 @@ type QueryProposalsParams struct { NumLatestProposals int64 } +// nolint: unparam func queryProposals(ctx sdk.Context, path []string, req abci.RequestQuery, keeper Keeper) (res []byte, err sdk.Error) { var params QueryProposalsParams err2 := keeper.cdc.UnmarshalJSON(req.Data, ¶ms) @@ -181,6 +187,7 @@ type QueryTallyParams struct { ProposalID int64 } +// nolint: unparam func queryTally(ctx sdk.Context, path []string, req abci.RequestQuery, keeper Keeper) (res []byte, err sdk.Error) { // TODO: Dependant on #1914 diff --git a/x/gov/simulation/msgs.go b/x/gov/simulation/msgs.go index eca8accae05b..13e537efad25 100644 --- a/x/gov/simulation/msgs.go +++ b/x/gov/simulation/msgs.go @@ -86,6 +86,7 @@ func SimulateMsgDeposit(k gov.Keeper, sk stake.Keeper) simulation.Operation { } // SimulateMsgVote +// nolint: unparam func SimulateMsgVote(k gov.Keeper, sk stake.Keeper) simulation.Operation { return func(tb testing.TB, r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, keys []crypto.PrivKey, log string, event func(string)) (action string, fOp []simulation.FutureOperation, err sdk.Error) { key := simulation.RandomKey(r, keys) diff --git a/x/ibc/client/cli/relay.go b/x/ibc/client/cli/relay.go index 92b03a66fcbb..37479980c502 100644 --- a/x/ibc/client/cli/relay.go +++ b/x/ibc/client/cli/relay.go @@ -163,6 +163,7 @@ func query(node string, key []byte, storeName string) (res []byte, err error) { return context.NewCLIContext().WithNodeURI(node).QueryStore(key, storeName) } +// nolint: unparam func (c relayCommander) broadcastTx(seq int64, node string, tx []byte) error { _, err := context.NewCLIContext().WithNodeURI(node).BroadcastTx(tx) return err diff --git a/x/mock/app.go b/x/mock/app.go index f472c5531cca..97068a3a511d 100644 --- a/x/mock/app.go +++ b/x/mock/app.go @@ -86,6 +86,7 @@ func (app *App) CompleteSetup(newKeys []*sdk.KVStoreKey) error { } // InitChainer performs custom logic for initialization. +// nolint: errcheck func (app *App) InitChainer(ctx sdk.Context, _ abci.RequestInitChain) abci.ResponseInitChain { // Load the genesis accounts for _, genacc := range app.GenesisAccounts { @@ -207,6 +208,7 @@ func GeneratePrivKeyAddressPairsFromRand(rand *rand.Rand, n int) (keys []crypto. // RandomSetGenesis set genesis accounts with random coin values using the // provided addresses and coin denominations. +// nolint: errcheck func RandomSetGenesis(r *rand.Rand, app *App, addrs []sdk.AccAddress, denoms []string) { accts := make([]auth.Account, len(addrs), len(addrs)) randCoinIntervals := []BigInterval{ diff --git a/x/mock/simulation/random_simulate_blocks.go b/x/mock/simulation/random_simulate_blocks.go index fc7543280a74..11c3dbd6a300 100644 --- a/x/mock/simulation/random_simulate_blocks.go +++ b/x/mock/simulation/random_simulate_blocks.go @@ -243,6 +243,7 @@ func getKeys(validators map[string]mockValidator) []string { } // RandomRequestBeginBlock generates a list of signing validators according to the provided list of validators, signing fraction, and evidence fraction +// nolint: unparam func RandomRequestBeginBlock(r *rand.Rand, validators map[string]mockValidator, livenessTransitions TransitionMatrix, evidenceFraction float64, pastTimes []time.Time, pastSigningValidators [][]abci.SigningValidator, event func(string), header abci.Header, log string) abci.RequestBeginBlock { if len(validators) == 0 { diff --git a/x/params/keeper.go b/x/params/keeper.go index 69bcc05ea8aa..7fd9bb3c9ccb 100644 --- a/x/params/keeper.go +++ b/x/params/keeper.go @@ -23,6 +23,7 @@ func NewKeeper(cdc *wire.Codec, key sdk.StoreKey) Keeper { } // InitKeeper constructs a new Keeper with initial parameters +// nolint: errcheck func InitKeeper(ctx sdk.Context, cdc *wire.Codec, key sdk.StoreKey, params ...interface{}) Keeper { if len(params)%2 != 0 { panic("Odd params list length for InitKeeper") diff --git a/x/params/msg_status.go b/x/params/msg_status.go index 7f9197c5c189..a8516a85b7ad 100644 --- a/x/params/msg_status.go +++ b/x/params/msg_status.go @@ -15,6 +15,7 @@ func ActivatedParamKey(ty string) string { } // InitGenesis stores activated type to param store +// nolint: errcheck func InitGenesis(ctx sdk.Context, k Keeper, data GenesisState) { for _, ty := range data.ActivatedTypes { k.set(ctx, ActivatedParamKey(ty), true) diff --git a/x/slashing/client/rest/query.go b/x/slashing/client/rest/query.go index 78c4a2d2f859..0ebe13250f50 100644 --- a/x/slashing/client/rest/query.go +++ b/x/slashing/client/rest/query.go @@ -19,6 +19,7 @@ func registerQueryRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *wire.Cod } // http request handler to query signing info +// nolint: unparam func signingInfoHandlerFn(cliCtx context.CLIContext, storeName string, cdc *wire.Codec) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) diff --git a/x/slashing/keeper_test.go b/x/slashing/keeper_test.go index c0932acf427c..0eb67bfb6b3d 100644 --- a/x/slashing/keeper_test.go +++ b/x/slashing/keeper_test.go @@ -165,7 +165,7 @@ func TestHandleAbsentValidator(t *testing.T) { validator, _ := sk.GetValidatorByPubKey(ctx, val) require.Equal(t, sdk.Bonded, validator.GetStatus()) pool := sk.GetPool(ctx) - require.Equal(t, int64(amtInt), pool.BondedTokens.RoundInt64()) + require.Equal(t, amtInt, pool.BondedTokens.RoundInt64()) // 501st block missed ctx = ctx.WithBlockHeight(height) @@ -195,7 +195,7 @@ func TestHandleAbsentValidator(t *testing.T) { // validator should have been slashed pool = sk.GetPool(ctx) slashAmt := sdk.NewDec(amtInt).Mul(keeper.SlashFractionDowntime(ctx)).RoundInt64() - require.Equal(t, int64(amtInt)-slashAmt, pool.BondedTokens.RoundInt64()) + require.Equal(t, amtInt-slashAmt, pool.BondedTokens.RoundInt64()) // validator start height should have been changed info, found = keeper.getValidatorSigningInfo(ctx, sdk.ConsAddress(val.Address())) @@ -252,7 +252,7 @@ func TestHandleNewValidator(t *testing.T) { info, found := keeper.getValidatorSigningInfo(ctx, sdk.ConsAddress(val.Address())) require.True(t, found) - require.Equal(t, int64(keeper.SignedBlocksWindow(ctx)+1), info.StartHeight) + require.Equal(t, keeper.SignedBlocksWindow(ctx)+1, info.StartHeight) require.Equal(t, int64(2), info.IndexOffset) require.Equal(t, int64(1), info.SignedBlocksCounter) require.Equal(t, time.Unix(0, 0).UTC(), info.JailedUntil) @@ -296,7 +296,7 @@ func TestHandleAlreadyJailed(t *testing.T) { require.Equal(t, sdk.Unbonding, validator.GetStatus()) // validator should have been slashed - require.Equal(t, int64(amtInt-1), validator.GetTokens().RoundInt64()) + require.Equal(t, amtInt-1, validator.GetTokens().RoundInt64()) // another block missed ctx = ctx.WithBlockHeight(height) @@ -304,6 +304,6 @@ func TestHandleAlreadyJailed(t *testing.T) { // validator should not have been slashed twice validator, _ = sk.GetValidatorByPubKey(ctx, val) - require.Equal(t, int64(amtInt-1), validator.GetTokens().RoundInt64()) + require.Equal(t, amtInt-1, validator.GetTokens().RoundInt64()) } diff --git a/x/stake/client/rest/utils.go b/x/stake/client/rest/utils.go index 171ded2b35f1..d8ad5fec557b 100644 --- a/x/stake/client/rest/utils.go +++ b/x/stake/client/rest/utils.go @@ -163,6 +163,7 @@ func getValidators(validatorKVs []sdk.KVPair, cdc *wire.Codec) ([]types.BechVali } // gets all Bech32 validators from a key +// nolint: unparam func getBech32Validators(storeName string, cliCtx context.CLIContext, cdc *wire.Codec) ( validators []types.BechValidator, httpStatusCode int, errMsg string, err error) { diff --git a/x/stake/handler_test.go b/x/stake/handler_test.go index 68c342fd8793..a733b7f1568f 100644 --- a/x/stake/handler_test.go +++ b/x/stake/handler_test.go @@ -430,7 +430,7 @@ func TestIncrementsMsgUnbond(t *testing.T) { initBond, } for _, c := range errorCases { - unbondShares := sdk.NewDec(int64(c)) + unbondShares := sdk.NewDec(c) msgBeginUnbonding := NewMsgBeginUnbonding(delegatorAddr, validatorAddr, unbondShares) got = handleMsgBeginUnbonding(ctx, msgBeginUnbonding, keeper) require.False(t, got.IsOK(), "expected unbond msg to fail") diff --git a/x/stake/keeper/key.go b/x/stake/keeper/key.go index d539c35d05b5..f3e2967c81fc 100644 --- a/x/stake/keeper/key.go +++ b/x/stake/keeper/key.go @@ -68,6 +68,7 @@ func GetValidatorsByPowerIndexKey(validator types.Validator, pool types.Pool) [] // get the power ranking of a validator // NOTE the larger values are of higher value +// nolint: unparam func getValidatorPowerRank(validator types.Validator, pool types.Pool) []byte { potentialPower := validator.Tokens diff --git a/x/stake/keeper/slash.go b/x/stake/keeper/slash.go index be26d1a23210..e077accb7113 100644 --- a/x/stake/keeper/slash.go +++ b/x/stake/keeper/slash.go @@ -203,6 +203,7 @@ func (k Keeper) slashUnbondingDelegation(ctx sdk.Context, unbondingDelegation ty // the unbonding delegation had enough stake to slash // (the amount actually slashed may be less if there's // insufficient stake remaining) +// nolint: unparam func (k Keeper) slashRedelegation(ctx sdk.Context, validator types.Validator, redelegation types.Redelegation, infractionHeight int64, slashFactor sdk.Dec) (slashAmount sdk.Dec) { diff --git a/x/stake/keeper/validator.go b/x/stake/keeper/validator.go index 47a5d5f66fa0..96719d8607d2 100644 --- a/x/stake/keeper/validator.go +++ b/x/stake/keeper/validator.go @@ -372,6 +372,7 @@ func (k Keeper) updateForJailing(ctx sdk.Context, oldFound bool, oldValidator, n return newValidator } +// nolint: unparam func (k Keeper) getPowerIncreasing(ctx sdk.Context, oldFound bool, oldValidator, newValidator types.Validator) bool { if oldFound && oldValidator.BondedTokens().LT(newValidator.BondedTokens()) { return true @@ -380,6 +381,7 @@ func (k Keeper) getPowerIncreasing(ctx sdk.Context, oldFound bool, oldValidator, } // get the bond height and incremented intra-tx counter +// nolint: unparam func (k Keeper) bondIncrement(ctx sdk.Context, oldFound bool, oldValidator, newValidator types.Validator) (height int64, intraTxCounter int16) { diff --git a/x/stake/simulation/invariants.go b/x/stake/simulation/invariants.go index 859bb05915be..8f218f45be04 100644 --- a/x/stake/simulation/invariants.go +++ b/x/stake/simulation/invariants.go @@ -25,6 +25,7 @@ func AllInvariants(ck bank.Keeper, k stake.Keeper, am auth.AccountMapper) simula } // SupplyInvariants checks that the total supply reflects all held loose tokens, bonded tokens, and unbonding delegations +// nolint: unparam func SupplyInvariants(ck bank.Keeper, k stake.Keeper, am auth.AccountMapper) simulation.Invariant { return func(t *testing.T, app *baseapp.BaseApp, log string) { ctx := app.NewContext(false, abci.Header{}) diff --git a/x/stake/simulation/msgs.go b/x/stake/simulation/msgs.go index af42dba49040..26446013240e 100644 --- a/x/stake/simulation/msgs.go +++ b/x/stake/simulation/msgs.go @@ -258,6 +258,7 @@ func SimulateMsgCompleteRedelegate(k stake.Keeper) simulation.Operation { } // Setup +// nolint: errcheck func Setup(mapp *mock.App, k stake.Keeper) simulation.RandSetup { return func(r *rand.Rand, privKeys []crypto.PrivKey) { ctx := mapp.NewContext(false, abci.Header{}) diff --git a/x/stake/types/delegation_test.go b/x/stake/types/delegation_test.go index 8e0dda7e247b..e7521225719a 100644 --- a/x/stake/types/delegation_test.go +++ b/x/stake/types/delegation_test.go @@ -23,7 +23,7 @@ func TestDelegationEqual(t *testing.T) { ok := d1.Equal(d2) require.True(t, ok) - d2.ValidatorAddr = sdk.ValAddress(addr3) + d2.ValidatorAddr = addr3 d2.Shares = sdk.NewDec(200) ok = d1.Equal(d2) @@ -57,7 +57,7 @@ func TestUnbondingDelegationEqual(t *testing.T) { ok := ud1.Equal(ud2) require.True(t, ok) - ud2.ValidatorAddr = sdk.ValAddress(addr3) + ud2.ValidatorAddr = addr3 ud2.MinTime = time.Unix(20*20*2, 0) ok = ud1.Equal(ud2) From 01da56a020dd091c9af8599e52777120989c468b Mon Sep 17 00:00:00 2001 From: Jeremiah Andrews Date: Mon, 3 Sep 2018 08:00:41 -0700 Subject: [PATCH 6/7] Fix pending changelog --- PENDING.md | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/PENDING.md b/PENDING.md index 00e609039f77..5e253df3007c 100644 --- a/PENDING.md +++ b/PENDING.md @@ -1,17 +1,4 @@ -## v0.24.1 PENDING - -BREAKING CHANGES - -FEATURES - -IMPROVEMENTS - -* [store] \#1952 Update IAVL dependency to v0.10.0 - -BUG FIXES - -## v0.24.0 PENDING -^--- PENDING wasn't purged on sdk v0.23.0 release. +## PENDING BREAKING CHANGES @@ -98,6 +85,7 @@ IMPROVEMENTS * [tools] Make get_vendor_deps deletes `.vendor-new` directories, in case scratch files are present. * [cli] \#1632 Add integration tests to ensure `basecoind init && basecoind` start sequences run successfully for both `democoin` and `basecoin` examples. * [store] Speedup IAVL iteration, and consequently everything that requires IAVL iteration. [#2143](https://github.com/cosmos/cosmos-sdk/issues/2143) + * [store] \#1952 Update IAVL dependency to v0.10.0 * [simulation] Make timestamps randomized [#2153](https://github.com/cosmos/cosmos-sdk/pull/2153) * Tendermint From 20f5325f479ca513538dec1ec240379b6f89fbe3 Mon Sep 17 00:00:00 2001 From: Jeremiah Andrews Date: Mon, 3 Sep 2018 09:47:24 -0700 Subject: [PATCH 7/7] Fix more linter errors --- x/mock/simulation/random_simulate_blocks.go | 2 ++ x/slashing/handler_test.go | 8 +++---- x/slashing/keeper_test.go | 24 ++++++++++----------- x/slashing/tick_test.go | 4 ++-- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/x/mock/simulation/random_simulate_blocks.go b/x/mock/simulation/random_simulate_blocks.go index 11c3dbd6a300..00b7a7365fa6 100644 --- a/x/mock/simulation/random_simulate_blocks.go +++ b/x/mock/simulation/random_simulate_blocks.go @@ -209,6 +209,7 @@ func queueOperations(queuedOperations map[int][]Operation, futureOperations []Fu } } +// nolint: errcheck func runQueuedOperations(queueOperations map[int][]Operation, height int, tb testing.TB, r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, privKeys []crypto.PrivKey, log string, event func(string)) (updatedLog string, numOpsRan int) { updatedLog = log @@ -321,6 +322,7 @@ func AssertAllInvariants(t *testing.T, app *baseapp.BaseApp, tests []Invariant, } // updateValidators mimicks Tendermint's update logic +// nolint: unparam func updateValidators(tb testing.TB, r *rand.Rand, current map[string]mockValidator, updates []abci.Validator, event func(string)) map[string]mockValidator { for _, update := range updates { switch { diff --git a/x/slashing/handler_test.go b/x/slashing/handler_test.go index c5afb87389df..9cdcd05334f0 100644 --- a/x/slashing/handler_test.go +++ b/x/slashing/handler_test.go @@ -16,15 +16,15 @@ func TestCannotUnjailUnlessJailed(t *testing.T) { slh := NewHandler(keeper) amtInt := int64(100) addr, val, amt := addrs[0], pks[0], sdk.NewInt(amtInt) - msg := newTestMsgCreateValidator(sdk.ValAddress(addr), val, amt) + msg := newTestMsgCreateValidator(addr, val, amt) got := stake.NewHandler(sk)(ctx, msg) require.True(t, got.IsOK()) stake.EndBlocker(ctx, sk) require.Equal(t, ck.GetCoins(ctx, sdk.AccAddress(addr)), sdk.Coins{{sk.GetParams(ctx).BondDenom, initCoins.Sub(amt)}}) - require.True(t, sdk.NewDecFromInt(amt).Equal(sk.Validator(ctx, sdk.ValAddress(addr)).GetPower())) + require.True(t, sdk.NewDecFromInt(amt).Equal(sk.Validator(ctx, addr).GetPower())) // assert non-jailed validator can't be unjailed - got = slh(ctx, NewMsgUnjail(sdk.ValAddress(addr))) + got = slh(ctx, NewMsgUnjail(addr)) require.False(t, got.IsOK(), "allowed unjail of non-jailed validator") require.Equal(t, sdk.ToABCICode(DefaultCodespace, CodeValidatorNotJailed), got.Code) } @@ -39,7 +39,7 @@ func TestJailedValidatorDelegations(t *testing.T) { // create a validator amount := int64(10) valPubKey, bondAmount := pks[0], sdk.NewInt(amount) - valAddr, consAddr := sdk.ValAddress(addrs[1]), sdk.ConsAddress(addrs[0]) + valAddr, consAddr := addrs[1], sdk.ConsAddress(addrs[0]) msgCreateVal := newTestMsgCreateValidator(valAddr, valPubKey, bondAmount) got := stake.NewHandler(stakeKeeper)(ctx, msgCreateVal) diff --git a/x/slashing/keeper_test.go b/x/slashing/keeper_test.go index 0eb67bfb6b3d..ff50a594ea34 100644 --- a/x/slashing/keeper_test.go +++ b/x/slashing/keeper_test.go @@ -27,12 +27,12 @@ func TestHandleDoubleSign(t *testing.T) { sk = sk.WithValidatorHooks(keeper.ValidatorHooks()) amtInt := int64(100) addr, val, amt := addrs[0], pks[0], sdk.NewInt(amtInt) - got := stake.NewHandler(sk)(ctx, newTestMsgCreateValidator(sdk.ValAddress(addr), val, amt)) + got := stake.NewHandler(sk)(ctx, newTestMsgCreateValidator(addr, val, amt)) require.True(t, got.IsOK()) validatorUpdates := stake.EndBlocker(ctx, sk) keeper.AddValidators(ctx, validatorUpdates) require.Equal(t, ck.GetCoins(ctx, sdk.AccAddress(addr)), sdk.Coins{{sk.GetParams(ctx).BondDenom, initCoins.Sub(amt)}}) - require.True(t, sdk.NewDecFromInt(amt).Equal(sk.Validator(ctx, sdk.ValAddress(addr)).GetPower())) + require.True(t, sdk.NewDecFromInt(amt).Equal(sk.Validator(ctx, addr).GetPower())) // handle a signature to set signing info keeper.handleValidatorSignature(ctx, val.Address(), amtInt, true) @@ -41,13 +41,13 @@ func TestHandleDoubleSign(t *testing.T) { keeper.handleDoubleSign(ctx, val.Address(), 0, time.Unix(0, 0), amtInt) // should be jailed - require.True(t, sk.Validator(ctx, sdk.ValAddress(addr)).GetJailed()) + require.True(t, sk.Validator(ctx, addr).GetJailed()) // unjail to measure power sk.Unjail(ctx, val) // power should be reduced require.Equal( t, sdk.NewDecFromInt(amt).Mul(sdk.NewDec(19).Quo(sdk.NewDec(20))), - sk.Validator(ctx, sdk.ValAddress(addr)).GetPower(), + sk.Validator(ctx, addr).GetPower(), ) ctx = ctx.WithBlockHeader(abci.Header{Time: time.Unix(1, 0).Add(keeper.MaxEvidenceAge(ctx))}) @@ -55,7 +55,7 @@ func TestHandleDoubleSign(t *testing.T) { keeper.handleDoubleSign(ctx, val.Address(), 0, time.Unix(0, 0), amtInt) require.Equal( t, sdk.NewDecFromInt(amt).Mul(sdk.NewDec(19).Quo(sdk.NewDec(20))), - sk.Validator(ctx, sdk.ValAddress(addr)).GetPower(), + sk.Validator(ctx, addr).GetPower(), ) } @@ -125,12 +125,12 @@ func TestHandleAbsentValidator(t *testing.T) { addr, val, amt := addrs[0], pks[0], sdk.NewInt(amtInt) sh := stake.NewHandler(sk) slh := NewHandler(keeper) - got := sh(ctx, newTestMsgCreateValidator(sdk.ValAddress(addr), val, amt)) + got := sh(ctx, newTestMsgCreateValidator(addr, val, amt)) require.True(t, got.IsOK()) validatorUpdates := stake.EndBlocker(ctx, sk) keeper.AddValidators(ctx, validatorUpdates) require.Equal(t, ck.GetCoins(ctx, sdk.AccAddress(addr)), sdk.Coins{{sk.GetParams(ctx).BondDenom, initCoins.Sub(amt)}}) - require.True(t, sdk.NewDecFromInt(amt).Equal(sk.Validator(ctx, sdk.ValAddress(addr)).GetPower())) + require.True(t, sdk.NewDecFromInt(amt).Equal(sk.Validator(ctx, addr).GetPower())) info, found := keeper.getValidatorSigningInfo(ctx, sdk.ConsAddress(val.Address())) require.False(t, found) require.Equal(t, int64(0), info.StartHeight) @@ -180,12 +180,12 @@ func TestHandleAbsentValidator(t *testing.T) { require.Equal(t, sdk.Unbonding, validator.GetStatus()) // unrevocation should fail prior to jail expiration - got = slh(ctx, NewMsgUnjail(sdk.ValAddress(addr))) + got = slh(ctx, NewMsgUnjail(addr)) require.False(t, got.IsOK()) // unrevocation should succeed after jail expiration ctx = ctx.WithBlockHeader(abci.Header{Time: time.Unix(1, 0).Add(keeper.DowntimeUnbondDuration(ctx))}) - got = slh(ctx, NewMsgUnjail(sdk.ValAddress(addr))) + got = slh(ctx, NewMsgUnjail(addr)) require.True(t, got.IsOK()) // validator should be rebonded now @@ -235,12 +235,12 @@ func TestHandleNewValidator(t *testing.T) { ctx, ck, sk, _, keeper := createTestInput(t) addr, val, amt := addrs[0], pks[0], int64(100) sh := stake.NewHandler(sk) - got := sh(ctx, newTestMsgCreateValidator(sdk.ValAddress(addr), val, sdk.NewInt(amt))) + got := sh(ctx, newTestMsgCreateValidator(addr, val, sdk.NewInt(amt))) require.True(t, got.IsOK()) validatorUpdates := stake.EndBlocker(ctx, sk) keeper.AddValidators(ctx, validatorUpdates) require.Equal(t, ck.GetCoins(ctx, sdk.AccAddress(addr)), sdk.Coins{{sk.GetParams(ctx).BondDenom, initCoins.SubRaw(amt)}}) - require.Equal(t, sdk.NewDec(amt), sk.Validator(ctx, sdk.ValAddress(addr)).GetPower()) + require.Equal(t, sdk.NewDec(amt), sk.Validator(ctx, addr).GetPower()) // 1000 first blocks not a validator ctx = ctx.WithBlockHeight(keeper.SignedBlocksWindow(ctx) + 1) @@ -273,7 +273,7 @@ func TestHandleAlreadyJailed(t *testing.T) { amtInt := int64(100) addr, val, amt := addrs[0], pks[0], sdk.NewInt(amtInt) sh := stake.NewHandler(sk) - got := sh(ctx, newTestMsgCreateValidator(sdk.ValAddress(addr), val, amt)) + got := sh(ctx, newTestMsgCreateValidator(addr, val, amt)) require.True(t, got.IsOK()) validatorUpdates := stake.EndBlocker(ctx, sk) keeper.AddValidators(ctx, validatorUpdates) diff --git a/x/slashing/tick_test.go b/x/slashing/tick_test.go index 25167578d1c1..81003a968a47 100644 --- a/x/slashing/tick_test.go +++ b/x/slashing/tick_test.go @@ -17,12 +17,12 @@ func TestBeginBlocker(t *testing.T) { addr, pk, amt := addrs[2], pks[2], sdk.NewInt(100) // bond the validator - got := stake.NewHandler(sk)(ctx, newTestMsgCreateValidator(sdk.ValAddress(addr), pk, amt)) + got := stake.NewHandler(sk)(ctx, newTestMsgCreateValidator(addr, pk, amt)) require.True(t, got.IsOK()) validatorUpdates := stake.EndBlocker(ctx, sk) keeper.AddValidators(ctx, validatorUpdates) require.Equal(t, ck.GetCoins(ctx, sdk.AccAddress(addr)), sdk.Coins{{sk.GetParams(ctx).BondDenom, initCoins.Sub(amt)}}) - require.True(t, sdk.NewDecFromInt(amt).Equal(sk.Validator(ctx, sdk.ValAddress(addr)).GetPower())) + require.True(t, sdk.NewDecFromInt(amt).Equal(sk.Validator(ctx, addr).GetPower())) val := abci.Validator{ Address: pk.Address(),