diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e2c3d552c89..b5e36a46cb17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,7 @@ older clients. ### API Breaking Changes +* (x/staking) [\#6451](https://github.com/cosmos/cosmos-sdk/pull/6451) `DefaultParamspace` and `ParamKeyTable` in staking module are moved from keeper to types to enforce consistency. * [\#6409](https://github.com/cosmos/cosmos-sdk/pull/6409) Rename all IsEmpty methods to Empty across the codebase and enforce consistency. * [\#6231](https://github.com/cosmos/cosmos-sdk/pull/6231) Simplify `AppModule` interface, `Route` and `NewHandler` methods become only `Route` and returns a new `Route` type. diff --git a/simapp/app.go b/simapp/app.go index da8a19b075eb..f3213d7f45c0 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -204,7 +204,7 @@ func NewSimApp( app.ParamsKeeper = paramskeeper.NewKeeper(appCodec, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey]) app.subspaces[auth.ModuleName] = app.ParamsKeeper.Subspace(auth.DefaultParamspace) app.subspaces[banktypes.ModuleName] = app.ParamsKeeper.Subspace(banktypes.DefaultParamspace) - app.subspaces[stakingtypes.ModuleName] = app.ParamsKeeper.Subspace(stakingkeeper.DefaultParamspace) + app.subspaces[stakingtypes.ModuleName] = app.ParamsKeeper.Subspace(stakingtypes.DefaultParamspace) app.subspaces[minttypes.ModuleName] = app.ParamsKeeper.Subspace(minttypes.DefaultParamspace) app.subspaces[distrtypes.ModuleName] = app.ParamsKeeper.Subspace(distrtypes.DefaultParamspace) app.subspaces[slashingtypes.ModuleName] = app.ParamsKeeper.Subspace(slashingtypes.DefaultParamspace) diff --git a/x/staking/keeper/keeper.go b/x/staking/keeper/keeper.go index 86d22b9ef69f..bc5e1d5c322e 100644 --- a/x/staking/keeper/keeper.go +++ b/x/staking/keeper/keeper.go @@ -39,7 +39,7 @@ func NewKeeper( ) Keeper { // set KeyTable if it has not already been set if !ps.HasKeyTable() { - ps = ps.WithKeyTable(ParamKeyTable()) + ps = ps.WithKeyTable(types.ParamKeyTable()) } // ensure bonded and not bonded module accounts are set diff --git a/x/staking/keeper/params.go b/x/staking/keeper/params.go index 25ef7cf4bb87..7fe0a8d098eb 100644 --- a/x/staking/keeper/params.go +++ b/x/staking/keeper/params.go @@ -4,20 +4,9 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/cosmos/cosmos-sdk/x/staking/types" ) -// Default parameter namespace -const ( - DefaultParamspace = types.ModuleName -) - -// ParamTable for staking module -func ParamKeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable().RegisterParamSet(&types.Params{}) -} - // UnbondingTime func (k Keeper) UnbondingTime(ctx sdk.Context) (res time.Duration) { k.paramstore.Get(ctx, types.KeyUnbondingTime, &res) diff --git a/x/staking/types/params.go b/x/staking/types/params.go index 4b1e98ee7d1e..3e2c02ac0527 100644 --- a/x/staking/types/params.go +++ b/x/staking/types/params.go @@ -15,6 +15,9 @@ import ( // Staking params default values const ( + // Default parameter namespace + DefaultParamspace = ModuleName + // DefaultUnbondingTime reflects three weeks in seconds as the default // unbonding time. // TODO: Justify our choice of default here. @@ -42,6 +45,11 @@ var ( var _ paramtypes.ParamSet = (*Params)(nil) +// ParamTable for staking module +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + // NewParams creates a new Params instance func NewParams(unbondingTime time.Duration, maxValidators, maxEntries, historicalEntries uint32, bondDenom string) Params { return Params{