diff --git a/CHANGELOG.md b/CHANGELOG.md index 2843951c10db..c6446bc9cd7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/bank) [#11981](https://github.com/cosmos/cosmos-sdk/pull/11981) Create the `SetSendEnabled` endpoint for managing the bank's SendEnabled settings. * (x/auth) [#13210](https://github.com/cosmos/cosmos-sdk/pull/13210) Add `Query/AccountInfo` endpoint for simplified access to basic account info. * (cli) [#13147](https://github.com/cosmos/cosmos-sdk/pull/13147) Add the `--append` flag to the `sign-batch` CLI cmd to combine the messages and sign those txs which are created with `--generate-only`. +* (x/consensus) [#12905](https://github.com/cosmos/cosmos-sdk/pull/12905) Create a new `x/consensus` module that is now responsible for maintaining Tendermint consensus parameters instead of `x/param`. Legacy types remain in order to facilitate parameter migration from the deprecated `x/params`. App developers should ensure that they execute `baseapp.MigrateParams` during their chain upgrade. These legacy types will be removed in a future release. ### Improvements diff --git a/UPGRADING.md b/UPGRADING.md index 8821f85e1972..2aa309e6cd4b 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -52,8 +52,10 @@ Please use the `ghcr.io/cosmos/proto-builder` image (version >= `0.11.0`) for ge #### Broadcast Mode -Broadcast mode `block` was deprecated and has been removed. Please use `sync` mode instead. -When upgrading your tests from `block` to `sync` and checking for a transaction code, you need to query the transaction first (with its hash) to get the correct code. +Broadcast mode `block` was deprecated and has been removed. Please use `sync` mode +instead. When upgrading your tests from `block` to `sync` and checking for a +transaction code, you need to query the transaction first (with its hash) to get +the correct code. ### Modules @@ -69,6 +71,53 @@ By default, the new `MinInitialDepositRatio` parameter is set to zero during mig feature is disabled. If chains wish to utilize the minimum proposal deposits at time of submission, the migration logic needs to be modified to set the new parameter to the desired value. +#### `x/consensus` + +Introducing a new `x/consensus` module to handle managing Tendermint consensus +parameters. For migration it is required to call a specific migration to migrate +existing parameters from the deprecated `x/params` to `x/consensus` module. App +developers should ensure to call `baseapp.MigrateParams` in their upgrade handler. + +Example: + +```go +func (app SimApp) RegisterUpgradeHandlers() { + ----> baseAppLegacySS := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()) <---- + + app.UpgradeKeeper.SetUpgradeHandler( + UpgradeName, + func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + // Migrate Tendermint consensus parameters from x/params module to a + // dedicated x/consensus module. + ----> baseapp.MigrateParams(ctx, baseAppLegacySS, &app.ConsensusParamsKeeper) <---- + + // ... + + return app.ModuleManager.RunMigrations(ctx, app.Configurator(), fromVM) + }, + ) + + // ... +} +``` + +The old params module is required to still be imported in your app.go in order to handle this migration. + +##### App.go Changes + +Previous: + +```go +bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())) +``` + +After: + +```go +app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[upgradetypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String()) +bApp.SetParamStore(&app.ConsensusParamsKeeper) +``` + ### Ledger Ledger support has been generalized to enable use of different apps and keytypes that use `secp256k1`. The Ledger interface remains the same, but it can now be provided through the Keyring `Options`, allowing higher-level chains to connect to different Ledger apps or use custom implementations. In addition, higher-level chains can provide custom key implementations around the Ledger public key, to enable greater flexibility with address generation and signing. diff --git a/baseapp/abci_test.go b/baseapp/abci_test.go index 7ff313c41a07..20b308cdfed8 100644 --- a/baseapp/abci_test.go +++ b/baseapp/abci_test.go @@ -2,6 +2,7 @@ package baseapp import ( "encoding/json" + "errors" "os" "testing" @@ -177,17 +178,19 @@ type paramStore struct { db *dbm.MemDB } -func (ps *paramStore) Set(_ sdk.Context, key []byte, value interface{}) { +var ParamstoreKey = []byte("paramstore") + +func (ps *paramStore) Set(_ sdk.Context, value *tmproto.ConsensusParams) { bz, err := json.Marshal(value) if err != nil { panic(err) } - ps.db.Set(key, bz) + ps.db.Set(ParamstoreKey, bz) } -func (ps *paramStore) Has(_ sdk.Context, key []byte) bool { - ok, err := ps.db.Has(key) +func (ps *paramStore) Has(_ sdk.Context) bool { + ok, err := ps.db.Has(ParamstoreKey) if err != nil { panic(err) } @@ -195,17 +198,21 @@ func (ps *paramStore) Has(_ sdk.Context, key []byte) bool { return ok } -func (ps *paramStore) Get(_ sdk.Context, key []byte, ptr interface{}) { - bz, err := ps.db.Get(key) +func (ps paramStore) Get(_ sdk.Context) (*tmproto.ConsensusParams, error) { + bz, err := ps.db.Get(ParamstoreKey) if err != nil { - panic(err) + return nil, err } if len(bz) == 0 { - return + return nil, errors.New("no consensus params") } - if err := json.Unmarshal(bz, ptr); err != nil { + var params tmproto.ConsensusParams + + if err := json.Unmarshal(bz, ¶ms); err != nil { panic(err) } + + return ¶ms, nil } diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 247099390985..b9618ca989b2 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -5,6 +5,7 @@ import ( "sort" "strings" + "github.com/cosmos/gogoproto/proto" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto/tmhash" "github.com/tendermint/tendermint/libs/log" @@ -12,8 +13,6 @@ import ( dbm "github.com/tendermint/tm-db" "golang.org/x/exp/maps" - "github.com/cosmos/gogoproto/proto" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/snapshots" "github.com/cosmos/cosmos-sdk/store" @@ -407,39 +406,14 @@ func (app *BaseApp) GetConsensusParams(ctx sdk.Context) *tmproto.ConsensusParams return nil } - cp := new(tmproto.ConsensusParams) - - if app.paramStore.Has(ctx, ParamStoreKeyBlockParams) { - var bp tmproto.BlockParams - - app.paramStore.Get(ctx, ParamStoreKeyBlockParams, &bp) - cp.Block = &bp - } - - if app.paramStore.Has(ctx, ParamStoreKeyEvidenceParams) { - var ep tmproto.EvidenceParams - - app.paramStore.Get(ctx, ParamStoreKeyEvidenceParams, &ep) - cp.Evidence = &ep - } - - if app.paramStore.Has(ctx, ParamStoreKeyValidatorParams) { - var vp tmproto.ValidatorParams - - app.paramStore.Get(ctx, ParamStoreKeyValidatorParams, &vp) - cp.Validator = &vp + cp, err := app.paramStore.Get(ctx) + if err != nil { + panic(err) } return cp } -// AddRunTxRecoveryHandler adds custom app.runTx method panic handlers. -func (app *BaseApp) AddRunTxRecoveryHandler(handlers ...RecoveryHandler) { - for _, h := range handlers { - app.runTxRecoveryMiddleware = newRecoveryMiddleware(h, app.runTxRecoveryMiddleware) - } -} - // StoreConsensusParams sets the consensus parameters to the baseapp's param store. func (app *BaseApp) StoreConsensusParams(ctx sdk.Context, cp *tmproto.ConsensusParams) { if app.paramStore == nil { @@ -450,13 +424,18 @@ func (app *BaseApp) StoreConsensusParams(ctx sdk.Context, cp *tmproto.ConsensusP return } - app.paramStore.Set(ctx, ParamStoreKeyBlockParams, cp.Block) - app.paramStore.Set(ctx, ParamStoreKeyEvidenceParams, cp.Evidence) - app.paramStore.Set(ctx, ParamStoreKeyValidatorParams, cp.Validator) + app.paramStore.Set(ctx, cp) // We're explicitly not storing the Tendermint app_version in the param store. It's // stored instead in the x/upgrade store, with its own bump logic. } +// AddRunTxRecoveryHandler adds custom app.runTx method panic handlers. +func (app *BaseApp) AddRunTxRecoveryHandler(handlers ...RecoveryHandler) { + for _, h := range handlers { + app.runTxRecoveryMiddleware = newRecoveryMiddleware(h, app.runTxRecoveryMiddleware) + } +} + // getMaximumBlockGas gets the maximum gas from the consensus params. It panics // if maximum block gas is less than negative one and returns zero if negative // one. diff --git a/baseapp/block_gas_test.go b/baseapp/block_gas_test.go index 280b3bd4f2dc..47f2fbd351ce 100644 --- a/baseapp/block_gas_test.go +++ b/baseapp/block_gas_test.go @@ -32,8 +32,6 @@ import ( bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" - stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" ) var blockMaxGas = uint64(simtestutil.DefaultConsensusParams.Block.MaxGas) @@ -73,8 +71,6 @@ func TestBaseApp_BlockGas(t *testing.T) { var ( bankKeeper bankkeeper.Keeper accountKeeper authkeeper.AccountKeeper - paramsKeeper paramskeeper.Keeper - stakingKeeper *stakingkeeper.Keeper appBuilder *runtime.AppBuilder txConfig client.TxConfig cdc codec.Codec @@ -88,8 +84,6 @@ func TestBaseApp_BlockGas(t *testing.T) { err = depinject.Inject(appConfig, &bankKeeper, &accountKeeper, - ¶msKeeper, - &stakingKeeper, &interfaceRegistry, &txConfig, &cdc, diff --git a/baseapp/deliver_tx_test.go b/baseapp/deliver_tx_test.go index 453ddab35c48..b7daf0505bfc 100644 --- a/baseapp/deliver_tx_test.go +++ b/baseapp/deliver_tx_test.go @@ -5,6 +5,7 @@ import ( "context" "encoding/binary" "encoding/json" + "errors" "fmt" "math/rand" "net/url" @@ -17,6 +18,14 @@ import ( "unsafe" "cosmossdk.io/depinject" + "github.com/cosmos/gogoproto/jsonpb" + "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" + dbm "github.com/tendermint/tm-db" + "github.com/cosmos/cosmos-sdk/baseapp" baseapptestutil "github.com/cosmos/cosmos-sdk/baseapp/testutil" "github.com/cosmos/cosmos-sdk/client" @@ -34,13 +43,6 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/signing" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" - "github.com/cosmos/gogoproto/jsonpb" - "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" - dbm "github.com/tendermint/tm-db" ) var ( @@ -102,10 +104,13 @@ func setupBaseAppWithSnapshots(t *testing.T, config *setupConfig) (*baseapp.Base // patch in TxConfig instead of using an output from x/auth/tx txConfig := authtx.NewTxConfig(cdc, authtx.DefaultSignModes) + // set the TxDecoder in the BaseApp for minimal tx simulations app.SetTxDecoder(txConfig.TxDecoder()) - app.InitChain(abci.RequestInitChain{}) + app.InitChain(abci.RequestInitChain{ + ConsensusParams: &tmproto.ConsensusParams{}, + }) r := rand.New(rand.NewSource(3920758213583)) keyCounter := 0 @@ -571,9 +576,13 @@ func TestGRPCQuery(t *testing.T) { app := setupBaseApp(t, grpcQueryOpt) app.GRPCQueryRouter().SetInterfaceRegistry(codectypes.NewInterfaceRegistry()) - app.InitChain(abci.RequestInitChain{}) + app.InitChain(abci.RequestInitChain{ + ConsensusParams: &tmproto.ConsensusParams{}, + }) + header := tmproto.Header{Height: app.LastBlockHeight() + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) + app.Commit() req := testdata.SayHelloRequest{Name: "foo"} @@ -1886,7 +1895,9 @@ func TestQuery(t *testing.T) { app.SetTxDecoder(txConfig.TxDecoder()) app.SetParamStore(¶mStore{db: dbm.NewMemDB()}) - app.InitChain(abci.RequestInitChain{}) + app.InitChain(abci.RequestInitChain{ + ConsensusParams: &tmproto.ConsensusParams{}, + }) // NOTE: "/store/key1" tells us KVStore // and the final "/key" says to use the data as the @@ -2152,17 +2163,19 @@ type paramStore struct { db *dbm.MemDB } -func (ps *paramStore) Set(_ sdk.Context, key []byte, value interface{}) { +var ParamstoreKey = []byte("paramstore") + +func (ps *paramStore) Set(_ sdk.Context, value *tmproto.ConsensusParams) { bz, err := json.Marshal(value) if err != nil { panic(err) } - ps.db.Set(key, bz) + ps.db.Set(ParamstoreKey, bz) } -func (ps *paramStore) Has(_ sdk.Context, key []byte) bool { - ok, err := ps.db.Has(key) +func (ps *paramStore) Has(_ sdk.Context) bool { + ok, err := ps.db.Has(ParamstoreKey) if err != nil { panic(err) } @@ -2170,17 +2183,21 @@ func (ps *paramStore) Has(_ sdk.Context, key []byte) bool { return ok } -func (ps *paramStore) Get(_ sdk.Context, key []byte, ptr interface{}) { - bz, err := ps.db.Get(key) +func (ps paramStore) Get(ctx sdk.Context) (*tmproto.ConsensusParams, error) { + bz, err := ps.db.Get(ParamstoreKey) if err != nil { panic(err) } if len(bz) == 0 { - return + return nil, errors.New("params not found") } - if err := json.Unmarshal(bz, ptr); err != nil { + var params tmproto.ConsensusParams + + if err := json.Unmarshal(bz, ¶ms); err != nil { panic(err) } + + return ¶ms, nil } diff --git a/baseapp/grpcrouter.go b/baseapp/grpcrouter.go index a92529a97ff3..d311f085c0e4 100644 --- a/baseapp/grpcrouter.go +++ b/baseapp/grpcrouter.go @@ -114,8 +114,5 @@ func (qrt *GRPCQueryRouter) SetInterfaceRegistry(interfaceRegistry codectypes.In qrt.cdc = codec.NewProtoCodec(interfaceRegistry).GRPCCodec() // Once we have an interface registry, we can register the interface // registry reflection gRPC service. - reflection.RegisterReflectionServiceServer( - qrt, - reflection.NewReflectionServiceServer(interfaceRegistry), - ) + reflection.RegisterReflectionServiceServer(qrt, reflection.NewReflectionServiceServer(interfaceRegistry)) } diff --git a/baseapp/params.go b/baseapp/params.go index 5cf31125b027..dec49a22e0dd 100644 --- a/baseapp/params.go +++ b/baseapp/params.go @@ -1,85 +1,15 @@ package baseapp import ( - "errors" - "fmt" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" sdk "github.com/cosmos/cosmos-sdk/types" ) -// Paramspace defines the parameter subspace to be used for the paramstore. -const Paramspace = "baseapp" - -// Parameter store keys for all the consensus parameter types. -var ( - ParamStoreKeyBlockParams = []byte("BlockParams") - ParamStoreKeyEvidenceParams = []byte("EvidenceParams") - ParamStoreKeyValidatorParams = []byte("ValidatorParams") -) - // ParamStore defines the interface the parameter store used by the BaseApp must // fulfill. type ParamStore interface { - Get(ctx sdk.Context, key []byte, ptr interface{}) - Has(ctx sdk.Context, key []byte) bool - Set(ctx sdk.Context, key []byte, param interface{}) -} - -// ValidateBlockParams defines a stateless validation on BlockParams. This function -// is called whenever the parameters are updated or stored. -func ValidateBlockParams(i interface{}) error { - v, ok := i.(tmproto.BlockParams) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - if v.MaxBytes <= 0 { - return fmt.Errorf("block maximum bytes must be positive: %d", v.MaxBytes) - } - - if v.MaxGas < -1 { - return fmt.Errorf("block maximum gas must be greater than or equal to -1: %d", v.MaxGas) - } - - return nil -} - -// 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.(tmproto.EvidenceParams) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - if v.MaxAgeNumBlocks <= 0 { - return fmt.Errorf("evidence maximum age in blocks must be positive: %d", v.MaxAgeNumBlocks) - } - - if v.MaxAgeDuration <= 0 { - return fmt.Errorf("evidence maximum age time duration must be positive: %v", v.MaxAgeDuration) - } - - if v.MaxBytes < 0 { - return fmt.Errorf("maximum evidence bytes must be non-negative: %v", v.MaxBytes) - } - - return nil -} - -// 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.(tmproto.ValidatorParams) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - if len(v.PubKeyTypes) == 0 { - return errors.New("validator allowed pubkey types must not be empty") - } - - return nil + Get(ctx sdk.Context) (*tmproto.ConsensusParams, error) + Has(ctx sdk.Context) bool + Set(ctx sdk.Context, cp *tmproto.ConsensusParams) } diff --git a/baseapp/params_legacy.go b/baseapp/params_legacy.go new file mode 100644 index 000000000000..8fed7253df0d --- /dev/null +++ b/baseapp/params_legacy.go @@ -0,0 +1,147 @@ +/* +Deprecated. + +Legacy types are defined below to aid in the migration of Tendermint consensus +parameters from use of the now deprecated x/params modules to a new dedicated +x/consensus module. + +Application developers should ensure that they implement their upgrade handler +correctly such that app.ConsensusParamsKeeper.Set() is called with the values +returned by GetConsensusParams(). + +Example: + + baseAppLegacySS := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()) + + app.UpgradeKeeper.SetUpgradeHandler( + UpgradeName, + func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + if cp := baseapp.GetConsensusParams(ctx, baseAppLegacySS); cp != nil { + app.ConsensusParamsKeeper.Set(ctx, cp) + } else { + ctx.Logger().Info("warning: consensus parameters are undefined; skipping migration", "upgrade", UpgradeName) + } + + return app.ModuleManager.RunMigrations(ctx, app.Configurator(), fromVM) + }, + ) + +Developers can also bypass the use of the legacy Params subspace and set the +values to app.ConsensusParamsKeeper.Set() explicitly. + +Note, for new chains this is not necessary as Tendermint's consensus parameters +will automatically be set for you in InitChain. +*/ +package baseapp + +import ( + "errors" + "fmt" + + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const Paramspace = "baseapp" + +var ( + ParamStoreKeyBlockParams = []byte("BlockParams") + ParamStoreKeyEvidenceParams = []byte("EvidenceParams") + ParamStoreKeyValidatorParams = []byte("ValidatorParams") +) + +type LegacyParamStore interface { + Get(ctx sdk.Context, key []byte, ptr interface{}) + Has(ctx sdk.Context, key []byte) bool +} + +func ValidateBlockParams(i interface{}) error { + v, ok := i.(tmproto.BlockParams) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v.MaxBytes <= 0 { + return fmt.Errorf("block maximum bytes must be positive: %d", v.MaxBytes) + } + + if v.MaxGas < -1 { + return fmt.Errorf("block maximum gas must be greater than or equal to -1: %d", v.MaxGas) + } + + return nil +} + +func ValidateEvidenceParams(i interface{}) error { + v, ok := i.(tmproto.EvidenceParams) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v.MaxAgeNumBlocks <= 0 { + return fmt.Errorf("evidence maximum age in blocks must be positive: %d", v.MaxAgeNumBlocks) + } + + if v.MaxAgeDuration <= 0 { + return fmt.Errorf("evidence maximum age time duration must be positive: %v", v.MaxAgeDuration) + } + + if v.MaxBytes < 0 { + return fmt.Errorf("maximum evidence bytes must be non-negative: %v", v.MaxBytes) + } + + return nil +} + +func ValidateValidatorParams(i interface{}) error { + v, ok := i.(tmproto.ValidatorParams) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if len(v.PubKeyTypes) == 0 { + return errors.New("validator allowed pubkey types must not be empty") + } + + return nil +} + +func GetConsensusParams(ctx sdk.Context, paramStore LegacyParamStore) *tmproto.ConsensusParams { + if paramStore == nil { + return nil + } + + cp := new(tmproto.ConsensusParams) + + if paramStore.Has(ctx, ParamStoreKeyBlockParams) { + var bp tmproto.BlockParams + + paramStore.Get(ctx, ParamStoreKeyBlockParams, &bp) + cp.Block = &bp + } + + if paramStore.Has(ctx, ParamStoreKeyEvidenceParams) { + var ep tmproto.EvidenceParams + + paramStore.Get(ctx, ParamStoreKeyEvidenceParams, &ep) + cp.Evidence = &ep + } + + if paramStore.Has(ctx, ParamStoreKeyValidatorParams) { + var vp tmproto.ValidatorParams + + paramStore.Get(ctx, ParamStoreKeyValidatorParams, &vp) + cp.Validator = &vp + } + + return cp +} + +func MigrateParams(ctx sdk.Context, lps LegacyParamStore, ps ParamStore) { + if cp := GetConsensusParams(ctx, lps); cp != nil { + ps.Set(ctx, cp) + } else { + ctx.Logger().Info("warning: consensus parameters are undefined; skipping migration") + } +} diff --git a/baseapp/params_test.go b/baseapp/params_test.go deleted file mode 100644 index 3f9d26a56f2f..000000000000 --- a/baseapp/params_test.go +++ /dev/null @@ -1,65 +0,0 @@ -package baseapp_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - - "github.com/cosmos/cosmos-sdk/baseapp" -) - -func TestValidateBlockParams(t *testing.T) { - testCases := []struct { - arg interface{} - expectErr bool - }{ - {nil, true}, - {&tmproto.BlockParams{}, true}, - {tmproto.BlockParams{}, true}, - {tmproto.BlockParams{MaxBytes: -1, MaxGas: -1}, true}, - {tmproto.BlockParams{MaxBytes: 2000000, MaxGas: -5}, true}, - {tmproto.BlockParams{MaxBytes: 2000000, MaxGas: 300000}, false}, - } - - for _, tc := range testCases { - require.Equal(t, tc.expectErr, baseapp.ValidateBlockParams(tc.arg) != nil) - } -} - -func TestValidateEvidenceParams(t *testing.T) { - testCases := []struct { - arg interface{} - expectErr bool - }{ - {nil, true}, - {&tmproto.EvidenceParams{}, true}, - {tmproto.EvidenceParams{}, true}, - {tmproto.EvidenceParams{MaxAgeNumBlocks: -1, MaxAgeDuration: 18004000, MaxBytes: 5000000}, true}, - {tmproto.EvidenceParams{MaxAgeNumBlocks: 360000, MaxAgeDuration: -1, MaxBytes: 5000000}, true}, - {tmproto.EvidenceParams{MaxAgeNumBlocks: 360000, MaxAgeDuration: 18004000, MaxBytes: -1}, true}, - {tmproto.EvidenceParams{MaxAgeNumBlocks: 360000, MaxAgeDuration: 18004000, MaxBytes: 5000000}, false}, - {tmproto.EvidenceParams{MaxAgeNumBlocks: 360000, MaxAgeDuration: 18004000, MaxBytes: 0}, false}, - } - - for _, tc := range testCases { - require.Equal(t, tc.expectErr, baseapp.ValidateEvidenceParams(tc.arg) != nil) - } -} - -func TestValidateValidatorParams(t *testing.T) { - testCases := []struct { - arg interface{} - expectErr bool - }{ - {nil, true}, - {&tmproto.ValidatorParams{}, true}, - {tmproto.ValidatorParams{}, true}, - {tmproto.ValidatorParams{PubKeyTypes: []string{}}, true}, - {tmproto.ValidatorParams{PubKeyTypes: []string{"secp256k1"}}, false}, - } - - for _, tc := range testCases { - require.Equal(t, tc.expectErr, baseapp.ValidateValidatorParams(tc.arg) != nil) - } -} diff --git a/baseapp/util_test.go b/baseapp/util_test.go index 55d6137212c2..8acd70d52884 100644 --- a/baseapp/util_test.go +++ b/baseapp/util_test.go @@ -11,6 +11,7 @@ import ( appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" + consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1" mintmodulev1 "cosmossdk.io/api/cosmos/mint/module/v1" paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1" stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1" @@ -28,6 +29,7 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" _ "github.com/cosmos/cosmos-sdk/x/bank" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + _ "github.com/cosmos/cosmos-sdk/x/consensus" _ "github.com/cosmos/cosmos-sdk/x/mint" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" _ "github.com/cosmos/cosmos-sdk/x/params" @@ -79,6 +81,7 @@ func makeTestConfig() depinject.Config { "auth", "bank", "params", + "consensus", }, EndBlockers: []string{ "staking", @@ -86,6 +89,7 @@ func makeTestConfig() depinject.Config { "bank", "mint", "params", + "consensus", }, OverrideStoreKeys: []*runtimev1alpha1.StoreKeyConfig{ { @@ -99,6 +103,7 @@ func makeTestConfig() depinject.Config { "staking", "mint", "params", + "consensus", }, }), }, @@ -130,6 +135,10 @@ func makeTestConfig() depinject.Config { Name: "mint", Config: appconfig.WrapAny(&mintmodulev1.Module{}), }, + { + Name: "consensus", + Config: appconfig.WrapAny(&consensusmodulev1.Module{}), + }, { Name: "tx", Config: appconfig.WrapAny(&txmodulev1.Module{}), diff --git a/contrib/rosetta/configuration/data.sh b/contrib/rosetta/configuration/data.sh index 51806fcea631..22bdcbacb0b3 100644 --- a/contrib/rosetta/configuration/data.sh +++ b/contrib/rosetta/configuration/data.sh @@ -45,7 +45,7 @@ sleep 10 # send transaction to deterministic address echo sending transaction with addr $addr -simd tx bank send "$addr" cosmos19g9cm8ymzchq2qkcdv3zgqtwayj9asv3hjv5u5 100stake --yes --keyring-backend=test --broadcast-mode=block --chain-id=testing +simd tx bank send "$addr" cosmos19g9cm8ymzchq2qkcdv3zgqtwayj9asv3hjv5u5 100stake --yes --keyring-backend=test --chain-id=testing sleep 10 diff --git a/contrib/rosetta/rosetta-ci/data.tar.gz b/contrib/rosetta/rosetta-ci/data.tar.gz index 7290a7bc1a81..2f2dc13dc5a5 100644 Binary files a/contrib/rosetta/rosetta-ci/data.tar.gz and b/contrib/rosetta/rosetta-ci/data.tar.gz differ diff --git a/simapp/app.go b/simapp/app.go index 2784de096a2d..44a2f5e6e110 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -45,6 +45,9 @@ import ( "github.com/cosmos/cosmos-sdk/x/capability" capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + consensus "github.com/cosmos/cosmos-sdk/x/consensus" + consensuskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" + consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" "github.com/cosmos/cosmos-sdk/x/crisis" crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper" crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" @@ -120,6 +123,7 @@ var ( groupmodule.AppModuleBasic{}, vesting.AppModuleBasic{}, nftmodule.AppModuleBasic{}, + consensus.AppModuleBasic{}, ) ) @@ -142,22 +146,23 @@ type SimApp struct { keys map[string]*storetypes.KVStoreKey // keepers - AccountKeeper authkeeper.AccountKeeper - BankKeeper bankkeeper.Keeper - CapabilityKeeper *capabilitykeeper.Keeper - StakingKeeper *stakingkeeper.Keeper - SlashingKeeper slashingkeeper.Keeper - MintKeeper mintkeeper.Keeper - DistrKeeper distrkeeper.Keeper - GovKeeper *govkeeper.Keeper - CrisisKeeper *crisiskeeper.Keeper - UpgradeKeeper upgradekeeper.Keeper - ParamsKeeper paramskeeper.Keeper - AuthzKeeper authzkeeper.Keeper - EvidenceKeeper evidencekeeper.Keeper - FeeGrantKeeper feegrantkeeper.Keeper - GroupKeeper groupkeeper.Keeper - NFTKeeper nftkeeper.Keeper + AccountKeeper authkeeper.AccountKeeper + BankKeeper bankkeeper.Keeper + CapabilityKeeper *capabilitykeeper.Keeper + StakingKeeper *stakingkeeper.Keeper + SlashingKeeper slashingkeeper.Keeper + MintKeeper mintkeeper.Keeper + DistrKeeper distrkeeper.Keeper + GovKeeper *govkeeper.Keeper + CrisisKeeper *crisiskeeper.Keeper + UpgradeKeeper upgradekeeper.Keeper + ParamsKeeper paramskeeper.Keeper + AuthzKeeper authzkeeper.Keeper + EvidenceKeeper evidencekeeper.Keeper + FeeGrantKeeper feegrantkeeper.Keeper + GroupKeeper groupkeeper.Keeper + NFTKeeper nftkeeper.Keeper + ConsensusParamsKeeper consensuskeeper.Keeper // simulation manager sm *module.SimulationManager @@ -192,10 +197,13 @@ func NewSimApp( // supply the application options appOpts, - // for providing a custom inflaction function for x/mint - // add here your custom function that implements the minttypes.InflationCalculationFn interface. + // For providing a custom inflation function for x/mint add here your + // custom function that implements the minttypes.InflationCalculationFn + // interface. - // for providing a custom authority to a module simply add it below. By default the governance module is the default authority. + // For providing a custom authority to a module simply add it below. By + // default the governance module is the default authority. + // // map[string]sdk.AccAddress{ // minttypes.ModuleName: authtypes.NewModuleAddress(authtypes.ModuleName), // }, @@ -225,6 +233,7 @@ func NewSimApp( &app.FeeGrantKeeper, &app.GroupKeeper, &app.NFTKeeper, + &app.ConsensusParamsKeeper, ); err != nil { panic(err) } @@ -254,7 +263,7 @@ func NewSimApp( distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName, feegrant.ModuleName, nft.ModuleName, group.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, - vestingtypes.ModuleName, + vestingtypes.ModuleName, consensustypes.ModuleName, } app.ModuleManager.SetOrderInitGenesis(genesisModuleOrder...) app.ModuleManager.SetOrderExportGenesis(genesisModuleOrder...) diff --git a/simapp/app_config.go b/simapp/app_config.go index b2c140018dde..4bd7a1548905 100644 --- a/simapp/app_config.go +++ b/simapp/app_config.go @@ -9,6 +9,7 @@ import ( authzmodulev1 "cosmossdk.io/api/cosmos/authz/module/v1" bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" capabilitymodulev1 "cosmossdk.io/api/cosmos/capability/module/v1" + consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1" crisismodulev1 "cosmossdk.io/api/cosmos/crisis/module/v1" distrmodulev1 "cosmossdk.io/api/cosmos/distribution/module/v1" evidencemodulev1 "cosmossdk.io/api/cosmos/evidence/module/v1" @@ -32,6 +33,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/authz" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" @@ -102,6 +104,7 @@ var ( group.ModuleName, paramstypes.ModuleName, vestingtypes.ModuleName, + consensustypes.ModuleName, }, EndBlockers: []string{ crisistypes.ModuleName, @@ -120,6 +123,7 @@ var ( nft.ModuleName, group.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName, }, @@ -217,6 +221,10 @@ var ( Name: crisistypes.ModuleName, Config: appconfig.WrapAny(&crisismodulev1.Module{}), }, + { + Name: consensustypes.ModuleName, + Config: appconfig.WrapAny(&consensusmodulev1.Module{}), + }, }, }) ) diff --git a/simapp/app_legacy.go b/simapp/app_legacy.go index 4fa8ca9ce863..f3b8c85f3dd7 100644 --- a/simapp/app_legacy.go +++ b/simapp/app_legacy.go @@ -51,6 +51,8 @@ import ( "github.com/cosmos/cosmos-sdk/x/capability" capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" + consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" "github.com/cosmos/cosmos-sdk/x/crisis" crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper" crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" @@ -166,22 +168,23 @@ type SimApp struct { memKeys map[string]*storetypes.MemoryStoreKey // keepers - AccountKeeper authkeeper.AccountKeeper - BankKeeper bankkeeper.Keeper - CapabilityKeeper *capabilitykeeper.Keeper - StakingKeeper *stakingkeeper.Keeper - SlashingKeeper slashingkeeper.Keeper - MintKeeper mintkeeper.Keeper - DistrKeeper distrkeeper.Keeper - GovKeeper govkeeper.Keeper - CrisisKeeper *crisiskeeper.Keeper - UpgradeKeeper upgradekeeper.Keeper - ParamsKeeper paramskeeper.Keeper - AuthzKeeper authzkeeper.Keeper - EvidenceKeeper evidencekeeper.Keeper - FeeGrantKeeper feegrantkeeper.Keeper - GroupKeeper groupkeeper.Keeper - NFTKeeper nftkeeper.Keeper + AccountKeeper authkeeper.AccountKeeper + BankKeeper bankkeeper.Keeper + CapabilityKeeper *capabilitykeeper.Keeper + StakingKeeper *stakingkeeper.Keeper + SlashingKeeper slashingkeeper.Keeper + MintKeeper mintkeeper.Keeper + DistrKeeper distrkeeper.Keeper + GovKeeper govkeeper.Keeper + CrisisKeeper *crisiskeeper.Keeper + UpgradeKeeper upgradekeeper.Keeper + ParamsKeeper paramskeeper.Keeper + AuthzKeeper authzkeeper.Keeper + EvidenceKeeper evidencekeeper.Keeper + FeeGrantKeeper feegrantkeeper.Keeper + GroupKeeper groupkeeper.Keeper + NFTKeeper nftkeeper.Keeper + ConsensusParamsKeeper consensusparamkeeper.Keeper // the module manager ModuleManager *module.Manager @@ -226,7 +229,7 @@ func NewSimApp( keys := sdk.NewKVStoreKeys( authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, crisistypes.StoreKey, minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, - govtypes.StoreKey, paramstypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, + govtypes.StoreKey, paramstypes.StoreKey, consensusparamtypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, evidencetypes.StoreKey, capabilitytypes.StoreKey, authzkeeper.StoreKey, nftkeeper.StoreKey, group.StoreKey, ) @@ -257,7 +260,8 @@ func NewSimApp( app.ParamsKeeper = initParamsKeeper(appCodec, legacyAmino, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey]) // set the BaseApp's parameter store - bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())) + app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[upgradetypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String()) + bApp.SetParamStore(&app.ConsensusParamsKeeper) app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey]) // Applications that wish to enforce statically created ScopedKeepers should call `Seal` after creating @@ -339,7 +343,7 @@ func NewSimApp( ), ) - // RegisterUpgradeHandlers is used for registering any on-chain upgrades + // RegisterUpgradeHandlers is used for registering any on-chain upgrades. app.RegisterUpgradeHandlers() app.NFTKeeper = nftkeeper.NewKeeper(keys[nftkeeper.StoreKey], appCodec, app.AccountKeeper, app.BankKeeper) diff --git a/simapp/upgrades.go b/simapp/upgrades.go index 4caab418ac7a..1324d9d98e8e 100644 --- a/simapp/upgrades.go +++ b/simapp/upgrades.go @@ -1,25 +1,35 @@ package simapp import ( + "github.com/cosmos/cosmos-sdk/baseapp" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - "github.com/cosmos/cosmos-sdk/x/group" - "github.com/cosmos/cosmos-sdk/x/nft" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" ) -// UpgradeName defines the on-chain upgrade name for the sample simap upgrade from v045 to v046. +// UpgradeName defines the on-chain upgrade name for the sample SimApp upgrade +// from v046 to v047. // -// NOTE: This upgrade defines a reference implementation of what an upgrade could look like -// when an application is migrating from Cosmos SDK version v0.45.x to v0.46.x. -const UpgradeName = "v045-to-v046" +// NOTE: This upgrade defines a reference implementation of what an upgrade +// could look like when an application is migrating from Cosmos SDK version +// v0.46.x to v0.47.x. +const UpgradeName = "v046-to-v047" func (app SimApp) RegisterUpgradeHandlers() { - app.UpgradeKeeper.SetUpgradeHandler(UpgradeName, - func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + baseAppLegacySS := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()) + + app.UpgradeKeeper.SetUpgradeHandler( + UpgradeName, + func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + // Migrate Tendermint consensus parameters from x/params module to a + // dedicated x/consensus module. + baseapp.MigrateParams(ctx, baseAppLegacySS, &app.ConsensusParamsKeeper) + return app.ModuleManager.RunMigrations(ctx, app.Configurator(), fromVM) - }) + }, + ) upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() if err != nil { @@ -27,12 +37,7 @@ func (app SimApp) RegisterUpgradeHandlers() { } if upgradeInfo.Name == UpgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { - storeUpgrades := storetypes.StoreUpgrades{ - Added: []string{ - group.ModuleName, - nft.ModuleName, - }, - } + storeUpgrades := storetypes.StoreUpgrades{} // configure store loader that checks if version == upgradeHeight and applies store upgrades app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) diff --git a/tests/e2e/client/grpc/tmservice/service_test.go b/tests/e2e/client/grpc/tmservice/service_test.go index a0cba3edb417..7f036e91e455 100644 --- a/tests/e2e/client/grpc/tmservice/service_test.go +++ b/tests/e2e/client/grpc/tmservice/service_test.go @@ -44,6 +44,7 @@ func (s *IntegrationTestSuite) SetupSuite() { configurator.GenutilModule(), configurator.StakingModule(), configurator.GovModule(), + configurator.ConsensusModule(), configurator.TxModule()) cfg, err := network.DefaultConfigWithAppConfig(appConfig) diff --git a/tests/integration/bank/keeper/keeper_test.go b/tests/integration/bank/keeper/keeper_test.go index d201da41e6e5..a1e1d741017f 100644 --- a/tests/integration/bank/keeper/keeper_test.go +++ b/tests/integration/bank/keeper/keeper_test.go @@ -130,6 +130,7 @@ func (suite *IntegrationTestSuite) SetupTest() { configurator.BankModule(), configurator.StakingModule(), configurator.ParamsModule(), + configurator.ConsensusModule(), configurator.VestingModule()), &suite.accountKeeper, &suite.bankKeeper, &suite.stakingKeeper, &interfaceRegistry, &suite.appCodec, &suite.authConfig) diff --git a/tests/integration/genutil/gentx_test.go b/tests/integration/genutil/gentx_test.go index f2b384c72586..4f9346673073 100644 --- a/tests/integration/genutil/gentx_test.go +++ b/tests/integration/genutil/gentx_test.go @@ -26,6 +26,7 @@ import ( _ "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/bank/testutil" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + _ "github.com/cosmos/cosmos-sdk/x/consensus" "github.com/cosmos/cosmos-sdk/x/genutil" "github.com/cosmos/cosmos-sdk/x/genutil/types" _ "github.com/cosmos/cosmos-sdk/x/params" @@ -67,6 +68,7 @@ func (suite *GenTxTestSuite) SetupTest() { configurator.TxModule(), configurator.StakingModule(), configurator.ParamsModule(), + configurator.ConsensusModule(), configurator.AuthModule()), simtestutil.DefaultStartUpConfig(), &encCfg.InterfaceRegistry, &encCfg.Codec, &encCfg.TxConfig, &encCfg.Amino, diff --git a/tests/integration/gov/genesis_test.go b/tests/integration/gov/genesis_test.go index ef8ecf93f423..4fb466a70e0b 100644 --- a/tests/integration/gov/genesis_test.go +++ b/tests/integration/gov/genesis_test.go @@ -19,6 +19,7 @@ import ( _ "github.com/cosmos/cosmos-sdk/x/bank" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + _ "github.com/cosmos/cosmos-sdk/x/consensus" _ "github.com/cosmos/cosmos-sdk/x/distribution" distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" @@ -51,6 +52,7 @@ var appConfig = configurator.NewAppConfig( configurator.GovModule(), configurator.DistributionModule(), configurator.MintModule(), + configurator.ConsensusModule(), ) func TestImportExportQueues(t *testing.T) { diff --git a/testutil/configurator/configurator.go b/testutil/configurator/configurator.go index 4c0c950ba48e..f62cd27efab6 100644 --- a/testutil/configurator/configurator.go +++ b/testutil/configurator/configurator.go @@ -5,6 +5,7 @@ import ( appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" + consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1" distrmodulev1 "cosmossdk.io/api/cosmos/distribution/module/v1" feegrantmodulev1 "cosmossdk.io/api/cosmos/feegrant/module/v1" genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1" @@ -37,6 +38,7 @@ var beginBlockOrder = []string{ "nft", "group", "params", + "consensus", "vesting", } @@ -57,6 +59,7 @@ var endBlockersOrder = []string{ "nft", "group", "params", + "consensus", "upgrade", "vesting", } @@ -78,6 +81,7 @@ var initGenesisOrder = []string{ "nft", "group", "params", + "consensus", "upgrade", "vesting", } @@ -198,6 +202,15 @@ func GovModule() ModuleOption { } } +func ConsensusModule() ModuleOption { + return func(config *appConfig) { + config.moduleConfigs["consensus"] = &appv1alpha1.ModuleConfig{ + Name: "consensus", + Config: appconfig.WrapAny(&consensusmodulev1.Module{}), + } + } +} + func MintModule() ModuleOption { return func(config *appConfig) { config.moduleConfigs["mint"] = &appv1alpha1.ModuleConfig{ diff --git a/testutil/network/network.go b/testutil/network/network.go index 5bfd8dd5d300..960c5eb95818 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -50,6 +50,7 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" _ "github.com/cosmos/cosmos-sdk/x/bank" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + _ "github.com/cosmos/cosmos-sdk/x/consensus" "github.com/cosmos/cosmos-sdk/x/genutil" _ "github.com/cosmos/cosmos-sdk/x/params" _ "github.com/cosmos/cosmos-sdk/x/staking" @@ -140,6 +141,7 @@ func MinimumAppConfig() depinject.Config { configurator.BankModule(), configurator.GenutilModule(), configurator.StakingModule(), + configurator.ConsensusModule(), configurator.TxModule()) } diff --git a/types/query/pagination_test.go b/types/query/pagination_test.go index 512db35a180c..53597c1be812 100644 --- a/types/query/pagination_test.go +++ b/types/query/pagination_test.go @@ -26,6 +26,7 @@ import ( bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" "github.com/cosmos/cosmos-sdk/x/bank/testutil" "github.com/cosmos/cosmos-sdk/x/bank/types" + _ "github.com/cosmos/cosmos-sdk/x/consensus" _ "github.com/cosmos/cosmos-sdk/x/params" ) @@ -67,6 +68,7 @@ func (s *paginationTestSuite) SetupTest() { configurator.AuthModule(), configurator.BankModule(), configurator.ParamsModule(), + configurator.ConsensusModule(), configurator.OmitInitGenesis(), ), &bankKeeper, &accountKeeper, ®, &cdc) diff --git a/x/auth/testutil/app_config.go b/x/auth/testutil/app_config.go index 9717d6c8d14e..3581e689ce98 100644 --- a/x/auth/testutil/app_config.go +++ b/x/auth/testutil/app_config.go @@ -5,6 +5,7 @@ import ( _ "github.com/cosmos/cosmos-sdk/x/auth/tx/module" _ "github.com/cosmos/cosmos-sdk/x/auth/vesting" _ "github.com/cosmos/cosmos-sdk/x/bank" + _ "github.com/cosmos/cosmos-sdk/x/consensus" _ "github.com/cosmos/cosmos-sdk/x/feegrant/module" _ "github.com/cosmos/cosmos-sdk/x/genutil" _ "github.com/cosmos/cosmos-sdk/x/params" @@ -14,6 +15,7 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" "github.com/cosmos/cosmos-sdk/x/feegrant" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" @@ -24,6 +26,7 @@ import ( appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" + consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1" feegrantmodulev1 "cosmossdk.io/api/cosmos/feegrant/module/v1" genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1" paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1" @@ -45,6 +48,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ genutiltypes.ModuleName, feegrant.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, vestingtypes.ModuleName, }, EndBlockers: []string{ @@ -54,6 +58,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ genutiltypes.ModuleName, feegrant.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, vestingtypes.ModuleName, }, InitGenesis: []string{ @@ -63,6 +68,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ genutiltypes.ModuleName, feegrant.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, vestingtypes.ModuleName, }, }), @@ -97,6 +103,10 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ Name: paramstypes.ModuleName, Config: appconfig.WrapAny(¶msmodulev1.Module{}), }, + { + Name: consensustypes.ModuleName, + Config: appconfig.WrapAny(&consensusmodulev1.Module{}), + }, { Name: "tx", Config: appconfig.WrapAny(&txmodulev1.Module{}), diff --git a/x/authz/testutil/app_config.go b/x/authz/testutil/app_config.go index 0a19fd6eb72e..d96539edc813 100644 --- a/x/authz/testutil/app_config.go +++ b/x/authz/testutil/app_config.go @@ -5,6 +5,7 @@ import ( _ "github.com/cosmos/cosmos-sdk/x/auth/tx/module" _ "github.com/cosmos/cosmos-sdk/x/authz/module" _ "github.com/cosmos/cosmos-sdk/x/bank" + _ "github.com/cosmos/cosmos-sdk/x/consensus" _ "github.com/cosmos/cosmos-sdk/x/genutil" _ "github.com/cosmos/cosmos-sdk/x/gov" _ "github.com/cosmos/cosmos-sdk/x/mint" @@ -15,6 +16,7 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/authz" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" @@ -26,6 +28,7 @@ import ( authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" authzmodulev1 "cosmossdk.io/api/cosmos/authz/module/v1" bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" + consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1" genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1" mintmodulev1 "cosmossdk.io/api/cosmos/mint/module/v1" paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1" @@ -47,6 +50,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ genutiltypes.ModuleName, authz.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, EndBlockers: []string{ minttypes.ModuleName, @@ -56,6 +60,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ genutiltypes.ModuleName, authz.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, InitGenesis: []string{ authtypes.ModuleName, @@ -65,6 +70,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ genutiltypes.ModuleName, authz.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, }), }, @@ -101,6 +107,10 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ Name: genutiltypes.ModuleName, Config: appconfig.WrapAny(&genutilmodulev1.Module{}), }, + { + Name: consensustypes.ModuleName, + Config: appconfig.WrapAny(&consensusmodulev1.Module{}), + }, { Name: authz.ModuleName, Config: appconfig.WrapAny(&authzmodulev1.Module{}), diff --git a/x/bank/app_test.go b/x/bank/app_test.go index 40d21304051c..fc4a3a6d6740 100644 --- a/x/bank/app_test.go +++ b/x/bank/app_test.go @@ -21,6 +21,7 @@ import ( bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" "github.com/cosmos/cosmos-sdk/x/bank/testutil" "github.com/cosmos/cosmos-sdk/x/bank/types" + _ "github.com/cosmos/cosmos-sdk/x/consensus" _ "github.com/cosmos/cosmos-sdk/x/gov" govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" _ "github.com/cosmos/cosmos-sdk/x/params" @@ -109,6 +110,7 @@ func createTestSuite(t *testing.T, genesisAccounts []authtypes.GenesisAccount) s configurator.AuthModule(), configurator.StakingModule(), configurator.TxModule(), + configurator.ConsensusModule(), configurator.BankModule(), configurator.GovModule(), ), diff --git a/x/bank/simulation/operations_test.go b/x/bank/simulation/operations_test.go index 6f4b5057cdd9..69381df19892 100644 --- a/x/bank/simulation/operations_test.go +++ b/x/bank/simulation/operations_test.go @@ -21,6 +21,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/bank/simulation" "github.com/cosmos/cosmos-sdk/x/bank/testutil" "github.com/cosmos/cosmos-sdk/x/bank/types" + _ "github.com/cosmos/cosmos-sdk/x/consensus" _ "github.com/cosmos/cosmos-sdk/x/params" _ "github.com/cosmos/cosmos-sdk/x/staking" ) @@ -45,6 +46,7 @@ func (suite *SimTestSuite) SetupTest() { configurator.ParamsModule(), configurator.BankModule(), configurator.StakingModule(), + configurator.ConsensusModule(), configurator.TxModule(), ), &suite.accountKeeper, &suite.bankKeeper, &suite.cdc, &appBuilder) diff --git a/x/capability/testutil/app_config.go b/x/capability/testutil/app_config.go index bdc3954b95ba..5c6171e225b7 100644 --- a/x/capability/testutil/app_config.go +++ b/x/capability/testutil/app_config.go @@ -5,6 +5,7 @@ import ( _ "github.com/cosmos/cosmos-sdk/x/auth/tx/module" _ "github.com/cosmos/cosmos-sdk/x/bank" _ "github.com/cosmos/cosmos-sdk/x/capability" + _ "github.com/cosmos/cosmos-sdk/x/consensus" _ "github.com/cosmos/cosmos-sdk/x/genutil" _ "github.com/cosmos/cosmos-sdk/x/params" _ "github.com/cosmos/cosmos-sdk/x/staking" @@ -13,6 +14,7 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -22,6 +24,7 @@ import ( authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" capabilitymodulev1 "cosmossdk.io/api/cosmos/capability/module/v1" + consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1" genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1" paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1" stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1" @@ -41,6 +44,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ banktypes.ModuleName, genutiltypes.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, EndBlockers: []string{ stakingtypes.ModuleName, @@ -49,6 +53,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ banktypes.ModuleName, genutiltypes.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, InitGenesis: []string{ capabilitytypes.ModuleName, @@ -57,6 +62,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ stakingtypes.ModuleName, genutiltypes.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, }), }, @@ -91,6 +97,10 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ Name: genutiltypes.ModuleName, Config: appconfig.WrapAny(&genutilmodulev1.Module{}), }, + { + Name: consensustypes.ModuleName, + Config: appconfig.WrapAny(&consensusmodulev1.Module{}), + }, { Name: capabilitytypes.ModuleName, Config: appconfig.WrapAny(&capabilitymodulev1.Module{ diff --git a/x/consensus/keeper/grpc_query_test.go b/x/consensus/keeper/grpc_query_test.go index f54a32a389ff..cfd139afef2b 100644 --- a/x/consensus/keeper/grpc_query_test.go +++ b/x/consensus/keeper/grpc_query_test.go @@ -1,10 +1,11 @@ package keeper_test import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/consensus/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/consensus/types" ) func (s *KeeperTestSuite) TestGRPCQueryConsensusParams() { diff --git a/x/consensus/keeper/keeper_test.go b/x/consensus/keeper/keeper_test.go index 4fe39755199a..1cb94f24fa8e 100644 --- a/x/consensus/keeper/keeper_test.go +++ b/x/consensus/keeper/keeper_test.go @@ -3,6 +3,9 @@ package keeper_test import ( "testing" + "github.com/stretchr/testify/suite" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" @@ -11,9 +14,6 @@ import ( consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - - "github.com/stretchr/testify/suite" ) type KeeperTestSuite struct { diff --git a/x/consensus/keeper/msg_server.go b/x/consensus/keeper/msg_server.go index 5e430c1dfe36..a3e7b5c857d2 100644 --- a/x/consensus/keeper/msg_server.go +++ b/x/consensus/keeper/msg_server.go @@ -34,6 +34,7 @@ func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParam if err := types.Validate(tmtypes.ConsensusParamsFromProto(consensusParams)); err != nil { return nil, err } + k.Set(ctx, &consensusParams) ctx.EventManager().EmitEvent( diff --git a/x/consensus/module.go b/x/consensus/module.go index 9f57e9fa2074..5c09fe156877 100644 --- a/x/consensus/module.go +++ b/x/consensus/module.go @@ -4,14 +4,14 @@ import ( "context" "encoding/json" + modulev1 "cosmossdk.io/api/cosmos/consensus/module/v1" "cosmossdk.io/core/appmodule" "cosmossdk.io/depinject" - gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" - modulev1 "cosmossdk.io/api/cosmos/consensus/module/v1" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -20,7 +20,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/consensus/exported" "github.com/cosmos/cosmos-sdk/x/consensus/keeper" "github.com/cosmos/cosmos-sdk/x/consensus/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" @@ -84,9 +83,6 @@ type AppModule struct { AppModuleBasic keeper keeper.Keeper - - // legacySubspace is used solely for migration of x/params managed parameters - legacySubspace exported.ParamStore } // RegisterServices registers module services. @@ -96,11 +92,10 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { } // NewAppModule creates a new AppModule object -func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ss exported.ParamStore) AppModule { +func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{cdc: cdc}, keeper: keeper, - legacySubspace: ss, } } @@ -143,9 +138,6 @@ type consensusParamInputs struct { Key *store.KVStoreKey ModuleKey depinject.OwnModuleKey Authority map[string]sdk.AccAddress `optional:"true"` - - // LegacySubspace is used solely for migration of x/params managed parameters - LegacySubspace exported.ParamStore } type consensusParamOutputs struct { @@ -164,14 +156,14 @@ func provideModule(in consensusParamInputs) consensusParamOutputs { } k := keeper.NewKeeper(in.Cdc, in.Key, authority.String()) - m := NewAppModule(in.Cdc, k, in.LegacySubspace) - // baseappOpt := func(app *baseapp.BaseApp) { - // app.SetParamStore(&k) - // } + m := NewAppModule(in.Cdc, k) + baseappOpt := func(app *baseapp.BaseApp) { + app.SetParamStore(&k) + } return consensusParamOutputs{ - Keeper: k, - Module: runtime.WrapAppModule(m), - // BaseAppOption: baseappOpt, + Keeper: k, + Module: runtime.WrapAppModule(m), + BaseAppOption: baseappOpt, } } diff --git a/x/consensus/types/keys.go b/x/consensus/types/keys.go index 8dd17af7dc13..5ce0fc2cbe4a 100644 --- a/x/consensus/types/keys.go +++ b/x/consensus/types/keys.go @@ -1,8 +1,10 @@ package types const ( + // ModuleName defines the name of the x/consensus module. ModuleName = "consensus" + // StoreKey defines the module's store key. StoreKey = ModuleName ) diff --git a/x/consensus/types/msgs.go b/x/consensus/types/msgs.go index eaa00b0c7bb4..3f5cbfe4c4b3 100644 --- a/x/consensus/types/msgs.go +++ b/x/consensus/types/msgs.go @@ -1,9 +1,10 @@ package types import ( - sdk "github.com/cosmos/cosmos-sdk/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" + + sdk "github.com/cosmos/cosmos-sdk/types" ) // bank message types diff --git a/x/consensus/types/params.go b/x/consensus/types/params.go index b707f8ffb688..5ecf68d9c9fa 100644 --- a/x/consensus/types/params.go +++ b/x/consensus/types/params.go @@ -4,7 +4,8 @@ import ( tmtypes "github.com/tendermint/tendermint/types" ) -// Validate all module parameters +// Validate performs basic validation of ConsensusParams returning an error upon +// failure. func Validate(p tmtypes.ConsensusParams) error { return p.ValidateBasic() } diff --git a/x/consensus/types/util.go b/x/consensus/types/util.go index c08c6b7e9d28..8bbba8278187 100644 --- a/x/consensus/types/util.go +++ b/x/consensus/types/util.go @@ -4,7 +4,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -// x/consensus_param module sentinel errors +// Sentinel errors for the x/consensus module. var ( ErrUnauthorized = sdkerrors.Register(ModuleName, 2, "unauthorized action") ) diff --git a/x/distribution/simulation/operations_test.go b/x/distribution/simulation/operations_test.go index 58a1180c817d..7392d1c5d76a 100644 --- a/x/distribution/simulation/operations_test.go +++ b/x/distribution/simulation/operations_test.go @@ -245,6 +245,7 @@ func (suite *SimTestSuite) SetupTest() { configurator.BankModule(), configurator.StakingModule(), configurator.TxModule(), + configurator.ConsensusModule(), configurator.DistributionModule(), ), &suite.accountKeeper, &suite.bankKeeper, diff --git a/x/distribution/testutil/app_config.go b/x/distribution/testutil/app_config.go index 67aff35b9b28..d1cb0dd29984 100644 --- a/x/distribution/testutil/app_config.go +++ b/x/distribution/testutil/app_config.go @@ -4,6 +4,7 @@ import ( _ "github.com/cosmos/cosmos-sdk/x/auth" _ "github.com/cosmos/cosmos-sdk/x/auth/tx/module" _ "github.com/cosmos/cosmos-sdk/x/bank" + _ "github.com/cosmos/cosmos-sdk/x/consensus" _ "github.com/cosmos/cosmos-sdk/x/distribution" _ "github.com/cosmos/cosmos-sdk/x/genutil" _ "github.com/cosmos/cosmos-sdk/x/mint" @@ -13,6 +14,7 @@ import ( "cosmossdk.io/core/appconfig" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" @@ -23,6 +25,7 @@ import ( appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" + consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1" distrmodulev1 "cosmossdk.io/api/cosmos/distribution/module/v1" genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1" mintmodulev1 "cosmossdk.io/api/cosmos/mint/module/v1" @@ -45,6 +48,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ banktypes.ModuleName, genutiltypes.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, EndBlockers: []string{ stakingtypes.ModuleName, @@ -54,6 +58,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ minttypes.ModuleName, genutiltypes.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, InitGenesis: []string{ authtypes.ModuleName, @@ -63,6 +68,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ minttypes.ModuleName, genutiltypes.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, }), }, @@ -91,6 +97,10 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ Name: paramstypes.ModuleName, Config: appconfig.WrapAny(¶msmodulev1.Module{}), }, + { + Name: consensustypes.ModuleName, + Config: appconfig.WrapAny(&consensusmodulev1.Module{}), + }, { Name: "tx", Config: appconfig.WrapAny(&txmodulev1.Module{}), diff --git a/x/evidence/testutil/app_config.go b/x/evidence/testutil/app_config.go index 5c14e66a197f..1f40dccbc5bf 100644 --- a/x/evidence/testutil/app_config.go +++ b/x/evidence/testutil/app_config.go @@ -4,6 +4,7 @@ import ( _ "github.com/cosmos/cosmos-sdk/x/auth" _ "github.com/cosmos/cosmos-sdk/x/auth/tx/module" _ "github.com/cosmos/cosmos-sdk/x/bank" + _ "github.com/cosmos/cosmos-sdk/x/consensus" _ "github.com/cosmos/cosmos-sdk/x/evidence" _ "github.com/cosmos/cosmos-sdk/x/genutil" _ "github.com/cosmos/cosmos-sdk/x/params" @@ -13,6 +14,7 @@ import ( "cosmossdk.io/core/appconfig" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" @@ -24,6 +26,7 @@ import ( appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" + consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1" evidencemodulev1 "cosmossdk.io/api/cosmos/evidence/module/v1" genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1" paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1" @@ -46,6 +49,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ banktypes.ModuleName, genutiltypes.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, EndBlockers: []string{ stakingtypes.ModuleName, @@ -55,6 +59,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ genutiltypes.ModuleName, evidencetypes.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, InitGenesis: []string{ authtypes.ModuleName, @@ -64,6 +69,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ genutiltypes.ModuleName, evidencetypes.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, }), }, @@ -95,6 +101,10 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ Name: paramstypes.ModuleName, Config: appconfig.WrapAny(¶msmodulev1.Module{}), }, + { + Name: consensustypes.ModuleName, + Config: appconfig.WrapAny(&consensusmodulev1.Module{}), + }, { Name: "tx", Config: appconfig.WrapAny(&txmodulev1.Module{}), diff --git a/x/feegrant/testutil/app_config.go b/x/feegrant/testutil/app_config.go index e1e2f021118a..3745e6bbc00a 100644 --- a/x/feegrant/testutil/app_config.go +++ b/x/feegrant/testutil/app_config.go @@ -5,6 +5,7 @@ import ( _ "github.com/cosmos/cosmos-sdk/x/auth/tx/module" _ "github.com/cosmos/cosmos-sdk/x/auth/vesting" _ "github.com/cosmos/cosmos-sdk/x/bank" + _ "github.com/cosmos/cosmos-sdk/x/consensus" _ "github.com/cosmos/cosmos-sdk/x/feegrant/module" _ "github.com/cosmos/cosmos-sdk/x/genutil" _ "github.com/cosmos/cosmos-sdk/x/mint" @@ -15,6 +16,7 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" "github.com/cosmos/cosmos-sdk/x/feegrant" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" @@ -25,6 +27,7 @@ import ( appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" + consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1" feegrantmodulev1 "cosmossdk.io/api/cosmos/feegrant/module/v1" genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1" paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1" @@ -47,6 +50,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ feegrant.ModuleName, paramstypes.ModuleName, vestingtypes.ModuleName, + consensustypes.ModuleName, }, EndBlockers: []string{ stakingtypes.ModuleName, @@ -56,6 +60,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ feegrant.ModuleName, paramstypes.ModuleName, vestingtypes.ModuleName, + consensustypes.ModuleName, }, InitGenesis: []string{ authtypes.ModuleName, @@ -65,6 +70,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ feegrant.ModuleName, paramstypes.ModuleName, vestingtypes.ModuleName, + consensustypes.ModuleName, }, }), }, @@ -96,6 +102,10 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ Name: paramstypes.ModuleName, Config: appconfig.WrapAny(¶msmodulev1.Module{}), }, + { + Name: consensustypes.ModuleName, + Config: appconfig.WrapAny(&consensusmodulev1.Module{}), + }, { Name: "tx", Config: appconfig.WrapAny(&txmodulev1.Module{}), diff --git a/x/gov/common_test.go b/x/gov/common_test.go index 2c9212eaaa63..ca3512f4b255 100644 --- a/x/gov/common_test.go +++ b/x/gov/common_test.go @@ -18,6 +18,7 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" _ "github.com/cosmos/cosmos-sdk/x/bank" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + _ "github.com/cosmos/cosmos-sdk/x/consensus" "github.com/cosmos/cosmos-sdk/x/gov/keeper" "github.com/cosmos/cosmos-sdk/x/gov/types" v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" @@ -116,6 +117,7 @@ func createTestSuite(t *testing.T) suite { configurator.StakingModule(), configurator.BankModule(), configurator.GovModule(), + configurator.ConsensusModule(), ), simtestutil.DefaultStartUpConfig(), &res.AccountKeeper, &res.BankKeeper, &res.GovKeeper, &res.StakingKeeper, diff --git a/x/gov/simulation/operations_test.go b/x/gov/simulation/operations_test.go index 5caf94f50a20..39f3e7636b15 100644 --- a/x/gov/simulation/operations_test.go +++ b/x/gov/simulation/operations_test.go @@ -22,6 +22,7 @@ import ( _ "github.com/cosmos/cosmos-sdk/x/bank" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" "github.com/cosmos/cosmos-sdk/x/bank/testutil" + _ "github.com/cosmos/cosmos-sdk/x/consensus" govcodec "github.com/cosmos/cosmos-sdk/x/gov/codec" "github.com/cosmos/cosmos-sdk/x/gov/keeper" "github.com/cosmos/cosmos-sdk/x/gov/simulation" @@ -297,6 +298,7 @@ func createTestSuite(t *testing.T, isCheckTx bool) (suite, sdk.Context) { configurator.ParamsModule(), configurator.BankModule(), configurator.StakingModule(), + configurator.ConsensusModule(), configurator.GovModule(), ), &res.AccountKeeper, &res.BankKeeper, &res.GovKeeper, &res.StakingKeeper, &res.cdc) require.NoError(t, err) diff --git a/x/group/testutil/app_config.go b/x/group/testutil/app_config.go index ffba8ac1c66a..b34ee163f465 100644 --- a/x/group/testutil/app_config.go +++ b/x/group/testutil/app_config.go @@ -9,6 +9,7 @@ import ( _ "github.com/cosmos/cosmos-sdk/x/auth/tx/module" _ "github.com/cosmos/cosmos-sdk/x/authz" _ "github.com/cosmos/cosmos-sdk/x/bank" + _ "github.com/cosmos/cosmos-sdk/x/consensus" _ "github.com/cosmos/cosmos-sdk/x/genutil" _ "github.com/cosmos/cosmos-sdk/x/group/module" _ "github.com/cosmos/cosmos-sdk/x/mint" @@ -18,6 +19,7 @@ import ( "cosmossdk.io/core/appconfig" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" "github.com/cosmos/cosmos-sdk/x/group" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" @@ -28,6 +30,7 @@ import ( appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" + consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1" genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1" groupmodulev1 "cosmossdk.io/api/cosmos/group/module/v1" paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1" @@ -49,6 +52,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ genutiltypes.ModuleName, group.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, EndBlockers: []string{ stakingtypes.ModuleName, @@ -58,6 +62,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ genutiltypes.ModuleName, group.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, InitGenesis: []string{ authtypes.ModuleName, @@ -67,6 +72,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ genutiltypes.ModuleName, group.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, }), }, @@ -94,6 +100,10 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ Name: paramstypes.ModuleName, Config: appconfig.WrapAny(¶msmodulev1.Module{}), }, + { + Name: consensustypes.ModuleName, + Config: appconfig.WrapAny(&consensusmodulev1.Module{}), + }, { Name: "tx", Config: appconfig.WrapAny(&txmodulev1.Module{}), diff --git a/x/mint/testutil/app_config.go b/x/mint/testutil/app_config.go index 47e4ed4de7fd..2bf57b360a53 100644 --- a/x/mint/testutil/app_config.go +++ b/x/mint/testutil/app_config.go @@ -5,6 +5,7 @@ import ( _ "github.com/cosmos/cosmos-sdk/x/auth" _ "github.com/cosmos/cosmos-sdk/x/auth/tx/module" _ "github.com/cosmos/cosmos-sdk/x/bank" + _ "github.com/cosmos/cosmos-sdk/x/consensus" _ "github.com/cosmos/cosmos-sdk/x/genutil" _ "github.com/cosmos/cosmos-sdk/x/mint" _ "github.com/cosmos/cosmos-sdk/x/params" @@ -12,6 +13,7 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" @@ -21,6 +23,7 @@ import ( appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" + consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1" genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1" mintmodulev1 "cosmossdk.io/api/cosmos/mint/module/v1" paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1" @@ -41,6 +44,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ banktypes.ModuleName, genutiltypes.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, EndBlockers: []string{ stakingtypes.ModuleName, @@ -49,6 +53,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ minttypes.ModuleName, genutiltypes.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, InitGenesis: []string{ authtypes.ModuleName, @@ -57,6 +62,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ minttypes.ModuleName, genutiltypes.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, }), }, @@ -84,6 +90,10 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ Name: paramstypes.ModuleName, Config: appconfig.WrapAny(¶msmodulev1.Module{}), }, + { + Name: consensustypes.ModuleName, + Config: appconfig.WrapAny(&consensusmodulev1.Module{}), + }, { Name: "tx", Config: appconfig.WrapAny(&txmodulev1.Module{}), diff --git a/x/nft/testutil/app_config.go b/x/nft/testutil/app_config.go index 467313f8d3d9..062faa7c6cd3 100644 --- a/x/nft/testutil/app_config.go +++ b/x/nft/testutil/app_config.go @@ -5,6 +5,7 @@ import ( _ "github.com/cosmos/cosmos-sdk/x/auth" _ "github.com/cosmos/cosmos-sdk/x/auth/tx/module" _ "github.com/cosmos/cosmos-sdk/x/bank" + _ "github.com/cosmos/cosmos-sdk/x/consensus" _ "github.com/cosmos/cosmos-sdk/x/genutil" _ "github.com/cosmos/cosmos-sdk/x/mint" _ "github.com/cosmos/cosmos-sdk/x/nft/module" @@ -13,6 +14,7 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" "github.com/cosmos/cosmos-sdk/x/nft" @@ -23,6 +25,7 @@ import ( appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" + consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1" genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1" mintmodulev1 "cosmossdk.io/api/cosmos/mint/module/v1" nftmodulev1 "cosmossdk.io/api/cosmos/nft/module/v1" @@ -45,6 +48,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ genutiltypes.ModuleName, nft.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, EndBlockers: []string{ stakingtypes.ModuleName, @@ -54,6 +58,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ genutiltypes.ModuleName, nft.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, InitGenesis: []string{ authtypes.ModuleName, @@ -63,6 +68,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ genutiltypes.ModuleName, nft.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, }), }, @@ -91,6 +97,10 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ Name: paramstypes.ModuleName, Config: appconfig.WrapAny(¶msmodulev1.Module{}), }, + { + Name: consensustypes.ModuleName, + Config: appconfig.WrapAny(&consensusmodulev1.Module{}), + }, { Name: "tx", Config: appconfig.WrapAny(&txmodulev1.Module{}), diff --git a/x/params/module.go b/x/params/module.go index fb32960ab404..5db9addd596d 100644 --- a/x/params/module.go +++ b/x/params/module.go @@ -15,7 +15,6 @@ import ( "cosmossdk.io/depinject" "github.com/cosmos/cosmos-sdk/runtime" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -158,21 +157,18 @@ type paramsInputs struct { type paramsOutputs struct { depinject.Out - ParamsKeeper keeper.Keeper - BaseAppOption runtime.BaseAppOption - Module runtime.AppModuleWrapper - GovHandler govv1beta1.HandlerRoute + ParamsKeeper keeper.Keeper + Module runtime.AppModuleWrapper + GovHandler govv1beta1.HandlerRoute } func provideModule(in paramsInputs) paramsOutputs { k := keeper.NewKeeper(in.Cdc, in.LegacyAmino, in.KvStoreKey, in.TransientStoreKey) - baseappOpt := func(app *baseapp.BaseApp) { - app.SetParamStore(k.Subspace(baseapp.Paramspace).WithKeyTable(types.ConsensusParamsKeyTable())) - } + m := runtime.WrapAppModule(NewAppModule(k)) govHandler := govv1beta1.HandlerRoute{RouteKey: proposal.RouterKey, Handler: NewParamChangeProposalHandler(k)} - return paramsOutputs{ParamsKeeper: k, BaseAppOption: baseappOpt, Module: m, GovHandler: govHandler} + return paramsOutputs{ParamsKeeper: k, Module: m, GovHandler: govHandler} } type subspaceInputs struct { diff --git a/x/params/testutil/app_config.go b/x/params/testutil/app_config.go index 133872dc0a60..363369458b89 100644 --- a/x/params/testutil/app_config.go +++ b/x/params/testutil/app_config.go @@ -4,6 +4,7 @@ import ( _ "github.com/cosmos/cosmos-sdk/x/auth" _ "github.com/cosmos/cosmos-sdk/x/auth/tx/module" _ "github.com/cosmos/cosmos-sdk/x/bank" + _ "github.com/cosmos/cosmos-sdk/x/consensus" _ "github.com/cosmos/cosmos-sdk/x/genutil" _ "github.com/cosmos/cosmos-sdk/x/params" _ "github.com/cosmos/cosmos-sdk/x/staking" @@ -11,6 +12,7 @@ import ( "cosmossdk.io/core/appconfig" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -19,6 +21,7 @@ import ( appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" + consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1" genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1" paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1" stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1" @@ -37,6 +40,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ banktypes.ModuleName, genutiltypes.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, EndBlockers: []string{ stakingtypes.ModuleName, @@ -44,6 +48,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ banktypes.ModuleName, genutiltypes.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, InitGenesis: []string{ authtypes.ModuleName, @@ -51,6 +56,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ stakingtypes.ModuleName, genutiltypes.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, }), }, @@ -77,6 +83,10 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ Name: paramstypes.ModuleName, Config: appconfig.WrapAny(¶msmodulev1.Module{}), }, + { + Name: consensustypes.ModuleName, + Config: appconfig.WrapAny(&consensusmodulev1.Module{}), + }, { Name: "tx", Config: appconfig.WrapAny(&txmodulev1.Module{}), diff --git a/x/params/types/consensus_params.go b/x/params/types/consensus_params_legacy.go similarity index 63% rename from x/params/types/consensus_params.go rename to x/params/types/consensus_params_legacy.go index 4c7edb562090..a102aa9a47bc 100644 --- a/x/params/types/consensus_params.go +++ b/x/params/types/consensus_params_legacy.go @@ -6,11 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" ) -// ConsensusParamsKeyTable returns an x/params module keyTable to be used in -// the BaseApp's ParamStore. The KeyTable registers the types along with the -// standard validation functions. Applications can choose to adopt this KeyTable -// or provider their own when the existing validation functions do not suite their -// needs. +// Deprecated. func ConsensusParamsKeyTable() KeyTable { return NewKeyTable( NewParamSetPair( diff --git a/x/slashing/app_test.go b/x/slashing/app_test.go index 94fadd0ad9e5..ce3f5df9ee9a 100644 --- a/x/slashing/app_test.go +++ b/x/slashing/app_test.go @@ -57,6 +57,7 @@ func TestSlashingMsgs(t *testing.T) { configurator.StakingModule(), configurator.SlashingModule(), configurator.TxModule(), + configurator.ConsensusModule(), configurator.BankModule()), startupCfg, &stakingKeeper, &bankKeeper, &slashingKeeper) diff --git a/x/slashing/testutil/app_config.go b/x/slashing/testutil/app_config.go index 9b88072054f6..9944561cf7e9 100644 --- a/x/slashing/testutil/app_config.go +++ b/x/slashing/testutil/app_config.go @@ -4,6 +4,7 @@ import ( _ "github.com/cosmos/cosmos-sdk/x/auth" _ "github.com/cosmos/cosmos-sdk/x/auth/tx/module" _ "github.com/cosmos/cosmos-sdk/x/bank" + _ "github.com/cosmos/cosmos-sdk/x/consensus" _ "github.com/cosmos/cosmos-sdk/x/distribution" _ "github.com/cosmos/cosmos-sdk/x/genutil" _ "github.com/cosmos/cosmos-sdk/x/mint" @@ -14,6 +15,7 @@ import ( "cosmossdk.io/core/appconfig" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" @@ -25,6 +27,7 @@ import ( appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" + consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1" distrmodulev1 "cosmossdk.io/api/cosmos/distribution/module/v1" genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1" mintmodulev1 "cosmossdk.io/api/cosmos/mint/module/v1" @@ -49,6 +52,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ genutiltypes.ModuleName, slashingtypes.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, EndBlockers: []string{ stakingtypes.ModuleName, @@ -59,6 +63,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ minttypes.ModuleName, slashingtypes.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, InitGenesis: []string{ authtypes.ModuleName, @@ -69,6 +74,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ slashingtypes.ModuleName, genutiltypes.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, }), }, @@ -102,6 +108,10 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ Name: paramstypes.ModuleName, Config: appconfig.WrapAny(¶msmodulev1.Module{}), }, + { + Name: consensustypes.ModuleName, + Config: appconfig.WrapAny(&consensusmodulev1.Module{}), + }, { Name: "tx", Config: appconfig.WrapAny(&txmodulev1.Module{}), diff --git a/x/staking/testutil/app_config.go b/x/staking/testutil/app_config.go index 32507cd4e8a3..6663235d0dbd 100644 --- a/x/staking/testutil/app_config.go +++ b/x/staking/testutil/app_config.go @@ -4,6 +4,7 @@ import ( _ "github.com/cosmos/cosmos-sdk/x/auth" _ "github.com/cosmos/cosmos-sdk/x/auth/tx/module" _ "github.com/cosmos/cosmos-sdk/x/bank" + _ "github.com/cosmos/cosmos-sdk/x/consensus" _ "github.com/cosmos/cosmos-sdk/x/distribution" _ "github.com/cosmos/cosmos-sdk/x/genutil" _ "github.com/cosmos/cosmos-sdk/x/mint" @@ -14,6 +15,7 @@ import ( "cosmossdk.io/core/appconfig" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" @@ -25,6 +27,7 @@ import ( appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" + consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1" distrmodulev1 "cosmossdk.io/api/cosmos/distribution/module/v1" genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1" mintmodulev1 "cosmossdk.io/api/cosmos/mint/module/v1" @@ -49,6 +52,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ genutiltypes.ModuleName, slashingtypes.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, EndBlockers: []string{ stakingtypes.ModuleName, @@ -59,6 +63,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ minttypes.ModuleName, slashingtypes.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, InitGenesis: []string{ authtypes.ModuleName, @@ -69,6 +74,7 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ slashingtypes.ModuleName, genutiltypes.ModuleName, paramstypes.ModuleName, + consensustypes.ModuleName, }, }), }, @@ -102,6 +108,10 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ Name: paramstypes.ModuleName, Config: appconfig.WrapAny(¶msmodulev1.Module{}), }, + { + Name: consensustypes.ModuleName, + Config: appconfig.WrapAny(&consensusmodulev1.Module{}), + }, { Name: "tx", Config: appconfig.WrapAny(&txmodulev1.Module{}), diff --git a/x/staking/types/params_legacy.go b/x/staking/types/params_legacy.go index 499dc7c2f768..df474c02ffa1 100644 --- a/x/staking/types/params_legacy.go +++ b/x/staking/types/params_legacy.go @@ -14,7 +14,7 @@ var ( var _ paramtypes.ParamSet = (*Params)(nil) // ParamTable for staking module -// Deprecated: now params can be accesed on key `0x51` on the staking store. +// Deprecated: now params can be accessed on key `0x51` on the staking store. func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) } diff --git a/x/upgrade/keeper/keeper.go b/x/upgrade/keeper/keeper.go index 9d8eeea467bc..18729f55afc6 100644 --- a/x/upgrade/keeper/keeper.go +++ b/x/upgrade/keeper/keeper.go @@ -11,10 +11,9 @@ import ( "github.com/tendermint/tendermint/libs/log" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store/prefix" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/kv"