Skip to content

Commit

Permalink
remove param space, fix param query, add changelog, fix migration method
Browse files Browse the repository at this point in the history
  • Loading branch information
nullpointer0x00 committed Apr 15, 2024
1 parent f2d91b2 commit 0b683b6
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 29 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 4 additions & 5 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 0 additions & 11 deletions app/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
}
8 changes: 0 additions & 8 deletions x/attribute/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand Down
5 changes: 1 addition & 4 deletions x/attribute/keeper/query_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, &params)

return &types.QueryParamsResponse{Params: params}, nil
return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil
}

// Attribute queries for a specific attribute
Expand Down
2 changes: 2 additions & 0 deletions x/attribute/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
}
Expand All @@ -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, &params.MaxValueLength, validateMaxValueLength),
Expand Down

0 comments on commit 0b683b6

Please sign in to comment.