diff --git a/modules/apps/27-interchain-accounts/controller/keeper/migrations.go b/modules/apps/27-interchain-accounts/controller/keeper/migrations.go index 1e0a8bb7090..705d93cb4b4 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/migrations.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/migrations.go @@ -55,11 +55,6 @@ func (m Migrator) AssertChannelCapabilityMigrations(ctx sdk.Context) error { // MigrateParams migrates the controller submodule's parameters from the x/params to self store. func (m Migrator) MigrateParams(ctx sdk.Context) error { if m.keeper != nil { - // set KeyTable if it has not already been set - if !m.keeper.legacySubspace.HasKeyTable() { - m.keeper.legacySubspace = m.keeper.legacySubspace.WithKeyTable(controllertypes.ParamKeyTable()) - } - var params controllertypes.Params m.keeper.legacySubspace.GetParamSet(ctx, ¶ms) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/migrations_test.go b/modules/apps/27-interchain-accounts/controller/keeper/migrations_test.go index 34e727070ba..dbb7dc746a5 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/migrations_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/migrations_test.go @@ -2,12 +2,6 @@ package keeper_test import ( "fmt" - "reflect" - - "cosmossdk.io/store/prefix" - - "github.com/cosmos/cosmos-sdk/codec" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" icacontrollerkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/keeper" icacontrollertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" @@ -93,15 +87,8 @@ func (suite *KeeperTestSuite) TestMigratorMigrateParams() { "success: default params", func() { params := icacontrollertypes.DefaultParams() - sk := suite.chainA.GetSimApp().GetKey(paramtypes.StoreKey) - store := suite.chainA.GetContext().KVStore(sk) - controllerStore := prefix.NewStore(store, append([]byte(icacontrollertypes.SubModuleName), '/')) - enabled := reflect.Indirect(reflect.ValueOf(params.ControllerEnabled)).Interface() - aminoCodec := codec.NewLegacyAmino() - enabledBz, err := aminoCodec.MarshalJSON(enabled) - suite.Require().NoError(err) - - controllerStore.Set(icacontrollertypes.KeyControllerEnabled, enabledBz) + subspace := suite.chainA.GetSimApp().GetSubspace(icacontrollertypes.SubModuleName) // get subspace + subspace.SetParamSet(suite.chainA.GetContext(), ¶ms) // set params }, icacontrollertypes.DefaultParams(), }, diff --git a/modules/apps/27-interchain-accounts/host/keeper/migrations.go b/modules/apps/27-interchain-accounts/host/keeper/migrations.go index 6aa2d0d2d82..894018606c7 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/migrations.go +++ b/modules/apps/27-interchain-accounts/host/keeper/migrations.go @@ -21,10 +21,6 @@ func NewMigrator(k *Keeper) Migrator { // MigrateParams migrates the host submodule's parameters from the x/params to self store. func (m Migrator) MigrateParams(ctx sdk.Context) error { if m.keeper != nil { - if !m.keeper.legacySubspace.HasKeyTable() { - m.keeper.legacySubspace = m.keeper.legacySubspace.WithKeyTable(types.ParamKeyTable()) - } - var params types.Params m.keeper.legacySubspace.GetParamSet(ctx, ¶ms) diff --git a/modules/apps/27-interchain-accounts/host/keeper/migrations_test.go b/modules/apps/27-interchain-accounts/host/keeper/migrations_test.go index b033e314316..e47e40f100f 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/migrations_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/migrations_test.go @@ -2,12 +2,6 @@ package keeper_test import ( "fmt" - "reflect" - - "cosmossdk.io/store/prefix" - - "github.com/cosmos/cosmos-sdk/codec" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" icahostkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/keeper" icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" @@ -23,21 +17,8 @@ func (suite *KeeperTestSuite) TestMigratorMigrateParams() { "success: default params", func() { params := icahosttypes.DefaultParams() - sk := suite.chainA.GetSimApp().GetKey(paramtypes.StoreKey) - store := suite.chainA.GetContext().KVStore(sk) - hostStore := prefix.NewStore(store, append([]byte(icahosttypes.SubModuleName), '/')) - enabled := reflect.Indirect(reflect.ValueOf(params.HostEnabled)).Interface() - aminoCodec := codec.NewLegacyAmino() - enabledBz, err := aminoCodec.MarshalJSON(enabled) - suite.Require().NoError(err) - - hostStore.Set(icahosttypes.KeyHostEnabled, enabledBz) - - allowList := reflect.Indirect(reflect.ValueOf(params.AllowMessages)).Interface() - allowListBz, err := aminoCodec.MarshalJSON(allowList) - suite.Require().NoError(err) - - hostStore.Set(icahosttypes.KeyAllowMessages, allowListBz) + subspace := suite.chainA.GetSimApp().GetSubspace(icahosttypes.SubModuleName) // get subspace + subspace.SetParamSet(suite.chainA.GetContext(), ¶ms) // set params }, icahosttypes.DefaultParams(), }, diff --git a/modules/apps/transfer/keeper/migrations.go b/modules/apps/transfer/keeper/migrations.go index beb7640a466..ae13ab7c80e 100644 --- a/modules/apps/transfer/keeper/migrations.go +++ b/modules/apps/transfer/keeper/migrations.go @@ -22,11 +22,6 @@ func NewMigrator(keeper Keeper) Migrator { // MigrateParams migrates the transfer module's parameters from the x/params to self store. func (m Migrator) MigrateParams(ctx sdk.Context) error { - // set KeyTable if it has not already been set - if !m.keeper.legacySubspace.HasKeyTable() { - m.keeper.legacySubspace = m.keeper.legacySubspace.WithKeyTable(types.ParamKeyTable()) - } - var params types.Params m.keeper.legacySubspace.GetParamSet(ctx, ¶ms) diff --git a/modules/apps/transfer/keeper/migrations_test.go b/modules/apps/transfer/keeper/migrations_test.go index 18846e65114..49b978cef42 100644 --- a/modules/apps/transfer/keeper/migrations_test.go +++ b/modules/apps/transfer/keeper/migrations_test.go @@ -2,16 +2,12 @@ package keeper_test import ( "fmt" - "reflect" sdkmath "cosmossdk.io/math" - "cosmossdk.io/store/prefix" - "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" banktestutil "github.com/cosmos/cosmos-sdk/x/bank/testutil" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" transferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" @@ -28,21 +24,8 @@ func (suite *KeeperTestSuite) TestMigratorMigrateParams() { "success: default params", func() { params := transfertypes.DefaultParams() - sk := suite.chainA.GetSimApp().GetKey(paramtypes.StoreKey) - store := suite.chainA.GetContext().KVStore(sk) - transferStore := prefix.NewStore(store, append([]byte(transfertypes.ModuleName), '/')) - receiveEnabled := reflect.Indirect(reflect.ValueOf(params.ReceiveEnabled)).Interface() - aminoCodec := codec.NewLegacyAmino() - receiveEnabledBz, err := aminoCodec.MarshalJSON(receiveEnabled) - suite.Require().NoError(err) - - transferStore.Set(transfertypes.KeyReceiveEnabled, receiveEnabledBz) - - sendEnabled := reflect.Indirect(reflect.ValueOf(params.SendEnabled)).Interface() - sendEnabledBz, err := aminoCodec.MarshalJSON(sendEnabled) - suite.Require().NoError(err) - - transferStore.Set(transfertypes.KeySendEnabled, sendEnabledBz) + subspace := suite.chainA.GetSimApp().GetSubspace(transfertypes.ModuleName) + subspace.SetParamSet(suite.chainA.GetContext(), ¶ms) // set params }, transfertypes.DefaultParams(), }, diff --git a/modules/core/02-client/keeper/migrations.go b/modules/core/02-client/keeper/migrations.go index cc3c3e79896..54620867928 100644 --- a/modules/core/02-client/keeper/migrations.go +++ b/modules/core/02-client/keeper/migrations.go @@ -37,11 +37,6 @@ func (m Migrator) Migrate3to4(ctx sdk.Context) error { // This migration takes the parameters that are currently stored and managed by x/params // and stores them directly in the ibc module's state. func (m Migrator) MigrateParams(ctx sdk.Context) error { - // set KeyTable if it has not already been set - if !m.keeper.legacySubspace.HasKeyTable() { - m.keeper.legacySubspace = m.keeper.legacySubspace.WithKeyTable(types.ParamKeyTable()) - } - var params types.Params m.keeper.legacySubspace.GetParamSet(ctx, ¶ms) if err := params.Validate(); err != nil { diff --git a/modules/core/02-client/keeper/migrations_test.go b/modules/core/02-client/keeper/migrations_test.go index 8df7faa9e6c..7bdd26b8a12 100644 --- a/modules/core/02-client/keeper/migrations_test.go +++ b/modules/core/02-client/keeper/migrations_test.go @@ -1,13 +1,6 @@ package keeper_test import ( - "reflect" - - "cosmossdk.io/store/prefix" - - "github.com/cosmos/cosmos-sdk/codec" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/cosmos/ibc-go/v8/modules/core/02-client/keeper" "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" @@ -24,15 +17,8 @@ func (suite *KeeperTestSuite) TestMigrateParams() { "success: default params", func() { params := types.DefaultParams() - sk := suite.chainA.GetSimApp().GetKey(paramtypes.StoreKey) - store := suite.chainA.GetContext().KVStore(sk) - clientStore := prefix.NewStore(store, append([]byte(ibcexported.ModuleName), '/')) - v := reflect.Indirect(reflect.ValueOf(params.AllowedClients)).Interface() - aminoCodec := codec.NewLegacyAmino() - bz, err := aminoCodec.MarshalJSON(v) - suite.Require().NoError(err) - - clientStore.Set(types.KeyAllowedClients, bz) + subspace := suite.chainA.GetSimApp().GetSubspace(ibcexported.ModuleName) + subspace.SetParamSet(suite.chainA.GetContext(), ¶ms) }, types.DefaultParams(), }, diff --git a/modules/core/03-connection/keeper/migrations.go b/modules/core/03-connection/keeper/migrations.go index b73a77ef4be..64b84e7885e 100644 --- a/modules/core/03-connection/keeper/migrations.go +++ b/modules/core/03-connection/keeper/migrations.go @@ -28,11 +28,6 @@ func (m Migrator) Migrate3to4(ctx sdk.Context) error { // This migration takes the parameters that are currently stored and managed by x/params // and stores them directly in the ibc module's state. func (m Migrator) MigrateParams(ctx sdk.Context) error { - // set KeyTable if it has not already been set - if !m.keeper.legacySubspace.HasKeyTable() { - m.keeper.legacySubspace = m.keeper.legacySubspace.WithKeyTable(types.ParamKeyTable()) - } - var params types.Params m.keeper.legacySubspace.GetParamSet(ctx, ¶ms) if err := params.Validate(); err != nil { diff --git a/modules/core/03-connection/keeper/migrations_test.go b/modules/core/03-connection/keeper/migrations_test.go index 0d1054ae4bb..36907ff4f96 100644 --- a/modules/core/03-connection/keeper/migrations_test.go +++ b/modules/core/03-connection/keeper/migrations_test.go @@ -1,13 +1,6 @@ package keeper_test import ( - "reflect" - - "cosmossdk.io/store/prefix" - - "github.com/cosmos/cosmos-sdk/codec" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/cosmos/ibc-go/v8/modules/core/03-connection/keeper" "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" @@ -23,17 +16,9 @@ func (suite *KeeperTestSuite) TestMigrateParams() { { "success: default params", func() { - // set old params via direct store manipulation in order to make sure that initializing a keytable works correctly in the migration handler params := types.DefaultParams() - sk := suite.chainA.GetSimApp().GetKey(paramtypes.StoreKey) - store := suite.chainA.GetContext().KVStore(sk) - connectionStore := prefix.NewStore(store, append([]byte(ibcexported.ModuleName), '/')) - v := reflect.Indirect(reflect.ValueOf(params.MaxExpectedTimePerBlock)).Interface() - aminoCodec := codec.NewLegacyAmino() - bz, err := aminoCodec.MarshalJSON(v) - suite.Require().NoError(err) - - connectionStore.Set(types.KeyMaxExpectedTimePerBlock, bz) + subspace := suite.chainA.GetSimApp().GetSubspace(ibcexported.ModuleName) + subspace.SetParamSet(suite.chainA.GetContext(), ¶ms) }, types.DefaultParams(), }, diff --git a/modules/core/keeper/keeper.go b/modules/core/keeper/keeper.go index 5bbdfcd3643..6831be40bda 100644 --- a/modules/core/keeper/keeper.go +++ b/modules/core/keeper/keeper.go @@ -14,7 +14,6 @@ import ( clientkeeper "github.com/cosmos/ibc-go/v8/modules/core/02-client/keeper" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" connectionkeeper "github.com/cosmos/ibc-go/v8/modules/core/03-connection/keeper" - // connectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" channelkeeper "github.com/cosmos/ibc-go/v8/modules/core/04-channel/keeper" portkeeper "github.com/cosmos/ibc-go/v8/modules/core/05-port/keeper" porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" @@ -45,7 +44,6 @@ func NewKeeper( stakingKeeper clienttypes.StakingKeeper, upgradeKeeper clienttypes.UpgradeKeeper, scopedKeeper capabilitykeeper.ScopedKeeper, authority string, ) *Keeper { - // register paramSpace at top level keeper // panic if any of the keepers passed in is empty if isEmpty(stakingKeeper) { panic(errors.New("cannot initialize IBC keeper: empty staking keeper")) diff --git a/testing/simapp/app.go b/testing/simapp/app.go index df0d84e034e..cd275c7d9db 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -123,6 +123,7 @@ import ( ibc "github.com/cosmos/ibc-go/v8/modules/core" ibcclient "github.com/cosmos/ibc-go/v8/modules/core/02-client" ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" @@ -1005,12 +1006,13 @@ func BlockedAddresses() map[string]bool { func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey) paramskeeper.Keeper { paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey) - // TODO: ibc module subspaces can be removed after migration of params - // https://github.com/cosmos/ibc-go/issues/2010 - paramsKeeper.Subspace(ibctransfertypes.ModuleName) - paramsKeeper.Subspace(ibcexported.ModuleName) - paramsKeeper.Subspace(icacontrollertypes.SubModuleName) - paramsKeeper.Subspace(icahosttypes.SubModuleName) + // register the key tables for legacy param subspaces + keyTable := ibcclienttypes.ParamKeyTable() + keyTable.RegisterParamSet(&ibcconnectiontypes.Params{}) + paramsKeeper.Subspace(ibcexported.ModuleName).WithKeyTable(keyTable) + paramsKeeper.Subspace(ibctransfertypes.ModuleName).WithKeyTable(ibctransfertypes.ParamKeyTable()) + paramsKeeper.Subspace(icacontrollertypes.SubModuleName).WithKeyTable(icacontrollertypes.ParamKeyTable()) + paramsKeeper.Subspace(icahosttypes.SubModuleName).WithKeyTable(icahosttypes.ParamKeyTable()) return paramsKeeper }