From 075119c205639958ca9c173c720973a5cc5da12d Mon Sep 17 00:00:00 2001 From: Jonathan Gimeno Date: Tue, 16 Jun 2020 19:29:58 +0200 Subject: [PATCH 1/2] move ParamKeyTable() and DefaultParamSpace from keeper to types in Staking --- simapp/app.go | 2 +- x/staking/keeper/keeper.go | 2 +- x/staking/keeper/params.go | 11 ----------- x/staking/types/params.go | 8 ++++++++ 4 files changed, 10 insertions(+), 13 deletions(-) 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{ From 8d771f5b385998dcb3066fc0f57f81caa057c5ce Mon Sep 17 00:00:00 2001 From: Jonathan Gimeno Date: Tue, 16 Jun 2020 19:34:44 +0200 Subject: [PATCH 2/2] add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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.