diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ce34b40dcd9..c733cc385a6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -193,7 +193,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (deps) Bump IAVL version to [v0.19.4](https://github.com/cosmos/iavl/releases/tag/v0.19.4). -## Bug Fixes +### Bug Fixes * (x/auth/tx) [#12474](https://github.com/cosmos/cosmos-sdk/pull/12474) Remove condition in GetTxsEvent that disallowed multiple equal signs, which would break event queries with base64 strings (i.e. query by signature). * (store) [#13530](https://github.com/cosmos/cosmos-sdk/pull/13530) Fix app-hash mismatch if upgrade migration commit is interrupted. @@ -202,7 +202,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [#13656](https://github.com/cosmos/cosmos-sdk/pull/13659) Rename `server.FlagIAVLFastNode` to `server.FlagDisableIAVLFastNode` for clarity. -## API Breaking Changes +### API Breaking Changes * (context) [#13063](https://github.com/cosmos/cosmos-sdk/pull/13063) Update `Context#CacheContext` to automatically emit all events on the parent context's `EventManager`. diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index 1e93876c286f..af000f4404c8 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -184,9 +184,9 @@ const config = { additionalLanguages: ["protobuf", "go-module"], // https://prismjs.com/#supported-languages }, algolia: { - appId: "BH4D9OD16A", - apiKey: "ac317234e6a42074175369b2f42e9754", - indexName: "cosmos-sdk", + appId: "QLS2QSP47E", + apiKey: "067b84458bfa80c295e1d4f12c461911", + indexName: "cosmos_network", contextualSearch: false, }, }), diff --git a/runtime/app.go b/runtime/app.go index 427b03f6f0c9..4cfa6d52782f 100644 --- a/runtime/app.go +++ b/runtime/app.go @@ -36,8 +36,6 @@ import ( // App can be used to create a hybrid app.go setup where some configuration is // done declaratively with an app config and the rest of it is done the old way. // See simapp/app.go for an example of this setup. -// -//nolint:unused type App struct { *baseapp.BaseApp @@ -49,8 +47,6 @@ type App struct { cdc codec.Codec amino *codec.LegacyAmino basicManager module.BasicManager - beginBlockers []func(sdk.Context, abci.RequestBeginBlock) - endBlockers []func(sdk.Context, abci.RequestEndBlock) []abci.ValidatorUpdate baseAppOptions []BaseAppOption msgServiceRouter *baseapp.MsgServiceRouter appConfig *appv1alpha1.Config diff --git a/store/iavl/store.go b/store/iavl/store.go index b93a3502547b..c6878e4a39b8 100644 --- a/store/iavl/store.go +++ b/store/iavl/store.go @@ -410,28 +410,3 @@ func getProofFromTree(tree *iavl.MutableTree, key []byte, exists bool) *tmcrypto op := types.NewIavlCommitmentOp(key, commitmentProof) return &tmcrypto.ProofOps{Ops: []tmcrypto.ProofOp{op.ProofOp()}} } - -//---------------------------------------- - -// iavlIterator implements types.Iterator. -type iavlIterator struct { - dbm.Iterator -} - -var _ types.Iterator = (*iavlIterator)(nil) - -// newIAVLIterator will create a new iavlIterator. -// CONTRACT: Caller must release the iavlIterator, as each one creates a new -// goroutine. -// -//nolint:deadcode,unused -func newIAVLIterator(tree *iavl.ImmutableTree, start, end []byte, ascending bool) *iavlIterator { - iterator, err := tree.Iterator(start, end, ascending) - if err != nil { - panic(err) - } - iter := &iavlIterator{ - Iterator: iterator, - } - return iter -} diff --git a/store/iavl/store_test.go b/store/iavl/store_test.go index 5c120f290194..ef057e4e0a30 100644 --- a/store/iavl/store_test.go +++ b/store/iavl/store_test.go @@ -121,6 +121,7 @@ func TestGetImmutable(t *testing.T) { store := UnsafeNewStore(tree) updated, err := tree.Set([]byte("hello"), []byte("adios")) + require.NoError(t, err) require.True(t, updated) hash, ver, err := tree.SaveVersion() cID = types.CommitID{Version: ver, Hash: hash} diff --git a/tests/integration/bank/keeper/deterministic_test.go b/tests/integration/bank/keeper/deterministic_test.go index d94c67ddfe06..238740d51fb4 100644 --- a/tests/integration/bank/keeper/deterministic_test.go +++ b/tests/integration/bank/keeper/deterministic_test.go @@ -185,7 +185,6 @@ func (suite *DeterministicTestSuite) TestGRPCQueryTotalSupply() { initialSupply := res.GetSupply() rapid.Check(suite.T(), func(t *rapid.T) { - numCoins := rapid.IntRange(1, 3).Draw(t, "num-count") coins := make(sdk.Coins, 0, numCoins) @@ -233,7 +232,6 @@ func (suite *DeterministicTestSuite) TestGRPCQueryTotalSupplyOf() { req := &banktypes.QuerySupplyOfRequest{Denom: coin.GetDenom()} testdata.DeterministicIterations(suite.ctx, suite.Require(), req, suite.queryClient.SupplyOf, 0, true) - }) coin := sdk.NewCoin("bar", sdk.NewInt(100)) diff --git a/testutil/testdata/grpc_query.go b/testutil/testdata/grpc_query.go index 85c14f7f1a50..1b74e8ae720a 100644 --- a/testutil/testdata/grpc_query.go +++ b/testutil/testdata/grpc_query.go @@ -12,11 +12,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -var ( - // iterCount defines the number of iterations to run on each query to test - // determinism. - iterCount = 1000 -) +// iterCount defines the number of iterations to run on each query to test +// determinism. +var iterCount = 1000 type QueryImpl struct{} diff --git a/tx/textual/valuerenderer/string.go b/tx/textual/valuerenderer/string.go index b84a68f51af9..d79dc46b0dec 100644 --- a/tx/textual/valuerenderer/string.go +++ b/tx/textual/valuerenderer/string.go @@ -7,8 +7,7 @@ import ( "google.golang.org/protobuf/reflect/protoreflect" ) -type stringValueRenderer struct { -} +type stringValueRenderer struct{} // NewStringValueRenderer returns a ValueRenderer for protocol buffer string values. // It renders the string as-is without quotation. diff --git a/types/context_test.go b/types/context_test.go index 78fb9c2762bd..fb16c3db49d0 100644 --- a/types/context_test.go +++ b/types/context_test.go @@ -73,12 +73,6 @@ func (s *contextTestSuite) TestLogContext() { ctx.Logger().Error("error") } -type dummy int64 //nolint:unused - -func (d dummy) Clone() interface{} { - return d -} - // Testing saving/loading sdk type values to/from the context func (s *contextTestSuite) TestContextWithCustom() { var ctx types.Context diff --git a/types/mempool/mempool_test.go b/types/mempool/mempool_test.go index d6f8e8134679..38944a501cf8 100644 --- a/types/mempool/mempool_test.go +++ b/types/mempool/mempool_test.go @@ -55,7 +55,8 @@ func (tx testTx) GetSignaturesV2() (res []txsigning.SignatureV2, err error) { res = append(res, txsigning.SignatureV2{ PubKey: testPubKey{address: tx.address}, Data: nil, - Sequence: tx.nonce}) + Sequence: tx.nonce, + }) return res, nil } diff --git a/x/auth/keeper/deterministic_test.go b/x/auth/keeper/deterministic_test.go index 9d49e040aab1..440de458e7c7 100644 --- a/x/auth/keeper/deterministic_test.go +++ b/x/auth/keeper/deterministic_test.go @@ -33,8 +33,9 @@ type DeterministicTestSuite struct { } var ( - addr = sdk.MustAccAddressFromBech32("cosmos1j364pjm8jkxxmujj0vp2xjg0y7w8tyveuamfm6") - pub, _ = hex.DecodeString("01090C02812F010C25200ED40E004105160196E801F70005070EA21603FF06001E") + addr = sdk.MustAccAddressFromBech32("cosmos1j364pjm8jkxxmujj0vp2xjg0y7w8tyveuamfm6") + pub, _ = hex.DecodeString("01090C02812F010C25200ED40E004105160196E801F70005070EA21603FF06001E") + permissions = []string{"burner", "minter", "staking", "random"} ) func TestDeterministicTestSuite(t *testing.T) { @@ -252,8 +253,6 @@ func (suite *DeterministicTestSuite) setModuleAccounts( } func (suite *DeterministicTestSuite) TestGRPCQueryModuleAccounts() { - permissions := []string{"burner", "minter", "staking", "random"} - rapid.Check(suite.T(), func(t *rapid.T) { maccsCount := rapid.IntRange(1, 10).Draw(t, "accounts") maccs := make([]string, maccsCount) @@ -303,5 +302,51 @@ func (suite *DeterministicTestSuite) TestGRPCQueryModuleAccounts() { queryClient := suite.createAndReturnQueryClient(suite.accountKeeper) req := &types.QueryModuleAccountsRequest{} - testdata.DeterministicIterations(suite.ctx, suite.Require(), req, queryClient.ModuleAccounts, 0x2175, false) + testdata.DeterministicIterations(suite.ctx, suite.Require(), req, queryClient.ModuleAccounts, 8565, false) +} + +func (suite *DeterministicTestSuite) TestGRPCQueryModuleAccountByName() { + rapid.Check(suite.T(), func(t *rapid.T) { + mName := rapid.StringMatching(`[a-z]{5,}`).Draw(t, "module-name") + + maccPerms := make(map[string][]string) + mPerms := make([]string, 0, 4) + for _, permission := range permissions { + if rapid.Bool().Draw(t, "permissions") { + mPerms = append(mPerms, permission) + } + } + + if len(mPerms) == 0 { + num := rapid.IntRange(0, 3).Draw(t, "num") + mPerms = append(mPerms, permissions[num]) + } + + maccPerms[mName] = mPerms + + ak := keeper.NewAccountKeeper( + suite.encCfg.Codec, + suite.key, + types.ProtoBaseAccount, + maccPerms, + "cosmos", + types.NewModuleAddress("gov").String(), + ) + suite.setModuleAccounts(suite.ctx, ak, []string{mName}) + + queryClient := suite.createAndReturnQueryClient(ak) + req := &types.QueryModuleAccountByNameRequest{Name: mName} + testdata.DeterministicIterations(suite.ctx, suite.Require(), req, queryClient.ModuleAccountByName, 0, true) + }) + + maccs := make([]string, 0, len(suite.maccPerms)) + for k := range suite.maccPerms { + maccs = append(maccs, k) + } + + suite.setModuleAccounts(suite.ctx, suite.accountKeeper, maccs) + + queryClient := suite.createAndReturnQueryClient(suite.accountKeeper) + req := &types.QueryModuleAccountByNameRequest{Name: "mint"} + testdata.DeterministicIterations(suite.ctx, suite.Require(), req, queryClient.ModuleAccountByName, 1372, false) } diff --git a/x/bank/types/params.go b/x/bank/types/params.go index 6c03e2fad72b..d7d1a05043db 100644 --- a/x/bank/types/params.go +++ b/x/bank/types/params.go @@ -51,28 +51,6 @@ func (se SendEnabled) Validate() error { return sdk.ValidateDenom(se.Denom) } -// validateSendEnabledParams is used by the x/params module to validate the params for the bank module. -// -//nolint:deadcode,unused -func validateSendEnabledParams(i interface{}) error { - params, ok := i.([]*SendEnabled) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - // ensure each denom is only registered one time. - registered := make(map[string]bool) - for _, p := range params { - if _, exists := registered[p.Denom]; exists { - return fmt.Errorf("duplicate send enabled parameter found: '%s'", p.Denom) - } - if err := validateSendEnabled(*p); err != nil { - return err - } - registered[p.Denom] = true - } - return nil -} - // NewSendEnabled creates a new SendEnabled object // The denom may be left empty to control the global default setting of send_enabled func NewSendEnabled(denom string, sendEnabled bool) *SendEnabled { @@ -87,17 +65,6 @@ func (se SendEnabled) String() string { return fmt.Sprintf("denom: %s\nenabled: %t\n", se.Denom, se.Enabled) } -// validateSendEnabled is used by the x/params module to validate a single SendEnabled entry. -// -//nolint:unused -func validateSendEnabled(i interface{}) error { - param, ok := i.(SendEnabled) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - return param.Validate() -} - // validateIsBool is used by the x/params module to validate that a thing is a bool. func validateIsBool(i interface{}) error { _, ok := i.(bool) diff --git a/x/bank/types/params_test.go b/x/bank/types/params_test.go index 4e48166e70a1..697e9412a360 100644 --- a/x/bank/types/params_test.go +++ b/x/bank/types/params_test.go @@ -3,41 +3,12 @@ package types import ( "testing" - "cosmossdk.io/math" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" ) -func Test_validateSendEnabledParam(t *testing.T) { - type args struct { - i interface{} - } - tests := []struct { - name string - args args - wantErr bool - }{ - {"invalid type", args{sdk.NewCoin(sdk.DefaultBondDenom, math.OneInt())}, true}, - - {"invalid empty denom send enabled", args{*NewSendEnabled("", true)}, true}, - {"invalid empty denom send disabled", args{*NewSendEnabled("", false)}, true}, - - {"valid denom send enabled", args{*NewSendEnabled(sdk.DefaultBondDenom, true)}, false}, - {"valid denom send disabled", args{*NewSendEnabled(sdk.DefaultBondDenom, false)}, false}, - - {"invalid denom send enabled", args{*NewSendEnabled("0FOO", true)}, true}, - {"invalid denom send disabled", args{*NewSendEnabled("0FOO", false)}, true}, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - require.Equal(t, tt.wantErr, validateSendEnabled(tt.args.i) != nil) - }) - } -} - func Test_sendParamEqual(t *testing.T) { paramsA := NewSendEnabled(sdk.DefaultBondDenom, true) paramsB := NewSendEnabled(sdk.DefaultBondDenom, true) @@ -100,47 +71,3 @@ func Test_validateParams(t *testing.T) { assert.NoError(t, NewParams(false).Validate(), "false") assert.Error(t, Params{[]*SendEnabled{{"foocoing", false}}, true}.Validate(), "with SendEnabled entry") } - -func Test_validateSendEnabledParams(t *testing.T) { - tests := []struct { - name string - arg interface{} - exp string - }{ - { - name: "ok", - arg: []*SendEnabled{}, - exp: "", - }, - { - name: "has entry", - arg: []*SendEnabled{{"foocoin", false}}, - exp: "", - }, - { - name: "not a slice", - arg: &SendEnabled{}, - exp: "invalid parameter type: *types.SendEnabled", - }, - { - name: "not a slice of refs", - arg: []SendEnabled{}, - exp: "invalid parameter type: []types.SendEnabled", - }, - { - name: "not a slice of send enabled", - arg: []*Params{}, - exp: "invalid parameter type: []*types.Params", - }, - } - for _, tc := range tests { - t.Run(tc.name, func(tt *testing.T) { - actual := validateSendEnabledParams(tc.arg) - if len(tc.exp) == 0 { - assert.NoError(tt, actual) - } else { - assert.EqualError(tt, actual, tc.exp) - } - }) - } -} diff --git a/x/gov/keeper/keeper.go b/x/gov/keeper/keeper.go index 34e8e975d37e..23868a77e9ad 100644 --- a/x/gov/keeper/keeper.go +++ b/x/gov/keeper/keeper.go @@ -18,9 +18,6 @@ import ( // Keeper defines the governance module Keeper type Keeper struct { - // The reference to the Paramstore to get and set gov specific params - paramSpace types.ParamSubspace //nolint:unused - authKeeper types.AccountKeeper bankKeeper types.BankKeeper diff --git a/x/gov/migrations/v4/store_test.go b/x/gov/migrations/v4/store_test.go index 74fb64bcd1a7..cb6cd9bab48a 100644 --- a/x/gov/migrations/v4/store_test.go +++ b/x/gov/migrations/v4/store_test.go @@ -119,7 +119,6 @@ func TestMigrateStore(t *testing.T) { // Check if proposal 2 is in the new store but not proposal 1 require.Nil(t, store.Get(v4.VotingPeriodProposalKey(proposal1.Id))) require.Equal(t, []byte{0x1}, store.Get(v4.VotingPeriodProposalKey(proposal2.Id))) - } func getTestProposal() []sdk.Msg {