From 0b683b6ff4da0ebe8abf47ebf67e7b534c060a7f Mon Sep 17 00:00:00 2001 From: Carlton N Hanna Date: Mon, 15 Apr 2024 12:10:39 -0600 Subject: [PATCH] remove param space, fix param query, add changelog, fix migration method --- CHANGELOG.md | 2 ++ app/app.go | 9 ++++----- app/upgrades.go | 2 +- app/upgrades_test.go | 11 ----------- x/attribute/keeper/keeper.go | 8 -------- x/attribute/keeper/query_server.go | 5 +---- x/attribute/types/params.go | 2 ++ 7 files changed, 10 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 76b52304f7..4b40036539 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ * Bump the SDK to `v0.50.5-pio-1` (from an earlier ephemeral version) [#1897](https://github.com/provenance-io/provenance/pull/1897). * Removed `rewards` module [#1905](https://github.com/provenance-io/provenance/pull/1905). * Remove unused navs [#1920](https://github.com/provenance-io/provenance/issues/1920). +* Migrate module params from param space to module store. + * Attribute module param migration [#1927](https://github.com/provenance-io/provenance/pull/1927) ### Dependencies diff --git a/app/app.go b/app/app.go index 28b34dbb5e..c6fcc8f724 100644 --- a/app/app.go +++ b/app/app.go @@ -1363,11 +1363,10 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypesv1.ParamKeyTable()) paramsKeeper.Subspace(crisistypes.ModuleName) - paramsKeeper.Subspace(metadatatypes.ModuleName) // TODO[1760]: params: Migrate metadata params. - paramsKeeper.Subspace(markertypes.ModuleName) // TODO[1760]: params: Migrate marker params. - paramsKeeper.Subspace(nametypes.ModuleName) // TODO[1760]: params: Migrate name params. - paramsKeeper.Subspace(attributetypes.ModuleName) // TODO[1760]: params: Migrate attribute params. - paramsKeeper.Subspace(msgfeestypes.ModuleName) // TODO[1760]: params: Migrate msgFees params. + paramsKeeper.Subspace(metadatatypes.ModuleName) // TODO[1760]: params: Migrate metadata params. + paramsKeeper.Subspace(markertypes.ModuleName) // TODO[1760]: params: Migrate marker params. + paramsKeeper.Subspace(nametypes.ModuleName) // TODO[1760]: params: Migrate name params. + paramsKeeper.Subspace(msgfeestypes.ModuleName) // TODO[1760]: params: Migrate msgFees params. paramsKeeper.Subspace(wasmtypes.ModuleName) paramsKeeper.Subspace(triggertypes.ModuleName) // TODO[1760]: params: Migrate trigger params. diff --git a/app/upgrades.go b/app/upgrades.go index f8e885cbdb..c4ded9d190 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -292,7 +292,7 @@ func migrateBaseappParams(ctx sdk.Context, app *App) error { // TODO: Remove with the umber handlers. func migrateAttributeParams(ctx sdk.Context, app *App) { ctx.Logger().Info("Migrating attribute params.") - attributeParamSpace := app.GetSubspace(attributetypes.ModuleName) + attributeParamSpace := app.ParamsKeeper.Subspace(attributetypes.ModuleName).WithKeyTable(attributetypes.ParamKeyTable()) maxValueLength := uint32(attributetypes.DefaultMaxValueLength) // TODO: remove attributetypes.ParamStoreKeyMaxValueLength with the umber handlers. if attributeParamSpace.Has(ctx, attributetypes.ParamStoreKeyMaxValueLength) { diff --git a/app/upgrades_test.go b/app/upgrades_test.go index bffdd04acc..3c7684e4c1 100644 --- a/app/upgrades_test.go +++ b/app/upgrades_test.go @@ -23,7 +23,6 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/provenance-io/provenance/internal/helpers" - attributetypes "github.com/provenance-io/provenance/x/attribute/types" ) type UpgradeTestSuite struct { @@ -629,13 +628,3 @@ func (s *UpgradeTestSuite) TestRemoveInactiveValidatorDelegations() { s.Assert().Len(validators, 3, "GetAllValidators after %s", runnerName) }) } - -func (s *UpgradeTestSuite) TestMigrateAttributeParams() { - expectedValueLength := uint32(512) - s.app.GetSubspace(attributetypes.ModuleName).SetParamSet(s.ctx, &attributetypes.Params{MaxValueLength: expectedValueLength}) - - migrateAttributeParams(s.ctx, s.app) - - params := s.app.AttributeKeeper.GetParams(s.ctx) - s.Require().Equal(expectedValueLength, params.MaxValueLength, "GetParams() MaxValueLength should match the pre-set value") -} diff --git a/x/attribute/keeper/keeper.go b/x/attribute/keeper/keeper.go index 621f5d8946..59cccdc55b 100644 --- a/x/attribute/keeper/keeper.go +++ b/x/attribute/keeper/keeper.go @@ -24,9 +24,6 @@ type Handler func(record types.Attribute) error // Keeper defines the attribute module Keeper type Keeper struct { - // The reference to the Paramstore to get and set attribute specific params - paramSpace paramtypes.Subspace - // Used to ensure accounts exist for addresses. authKeeper types.AccountKeeper // The keeper used for ensuring names resolve to owners. @@ -51,13 +48,8 @@ func NewKeeper( cdc codec.BinaryCodec, key storetypes.StoreKey, paramSpace paramtypes.Subspace, authKeeper types.AccountKeeper, nameKeeper types.NameKeeper, ) Keeper { - if !paramSpace.HasKeyTable() { - paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) - } - keeper := Keeper{ storeKey: key, - paramSpace: paramSpace, authKeeper: authKeeper, nameKeeper: nameKeeper, cdc: cdc, diff --git a/x/attribute/keeper/query_server.go b/x/attribute/keeper/query_server.go index 26e4656a6b..604398d38a 100644 --- a/x/attribute/keeper/query_server.go +++ b/x/attribute/keeper/query_server.go @@ -20,10 +20,7 @@ var _ types.QueryServer = Keeper{} // Params queries params of attribute module func (k Keeper) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { ctx := sdk.UnwrapSDKContext(c) - var params types.Params - k.paramSpace.GetParamSet(ctx, ¶ms) - - return &types.QueryParamsResponse{Params: params}, nil + return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil } // Attribute queries for a specific attribute diff --git a/x/attribute/types/params.go b/x/attribute/types/params.go index ee7f1f7084..e0bed97c12 100644 --- a/x/attribute/types/params.go +++ b/x/attribute/types/params.go @@ -26,6 +26,7 @@ func (params Params) String() string { } // ParamKeyTable for slashing module +// TODO: remove with the umber (v1.19.x) handlers. func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) } @@ -40,6 +41,7 @@ func NewParams( } // ParamSetPairs - Implements params.ParamSet +// TODO: remove with the umber (v1.19.x) handlers. func (params *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(ParamStoreKeyMaxValueLength, ¶ms.MaxValueLength, validateMaxValueLength),