Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move legacy keytable init to migration handler code #4730

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
89005eb
move legacy keytable init to migration handler code
charleenfei Sep 20, 2023
92364b7
Merge branch 'main' into charly/issue#4670-move-legacysubspace-key-ta…
charleenfei Sep 20, 2023
a25fb6a
linter
charleenfei Sep 20, 2023
a255752
Merge branch 'charly/issue#4670-move-legacysubspace-key-table-initial…
charleenfei Sep 20, 2023
6e62cff
update test
charleenfei Sep 20, 2023
859de20
Merge branch 'main' into charly/issue#4670-move-legacysubspace-key-ta…
charleenfei Sep 20, 2023
9f18f71
lint & fix test
charleenfei Sep 20, 2023
ec2b813
Merge branch 'charly/issue#4670-move-legacysubspace-key-table-initial…
charleenfei Sep 20, 2023
d91ea13
Merge branch 'main' into charly/issue#4670-move-legacysubspace-key-ta…
charleenfei Sep 20, 2023
f8574a6
rm print statement
charleenfei Sep 20, 2023
5a9981b
Merge branch 'charly/issue#4670-move-legacysubspace-key-table-initial…
charleenfei Sep 20, 2023
725bff4
Merge branch 'main' into charly/issue#4670-move-legacysubspace-key-ta…
charleenfei Sep 20, 2023
5bf4079
Merge branch 'main' into charly/issue#4670-move-legacysubspace-key-ta…
charleenfei Sep 25, 2023
95bd77f
update for code coverage
charleenfei Sep 25, 2023
468c025
Merge branch 'charly/issue#4670-move-legacysubspace-key-table-initial…
charleenfei Sep 25, 2023
18cd60d
linter
charleenfei Sep 25, 2023
d803655
register the key tables in the app.go
charleenfei Sep 25, 2023
b265451
Merge branch 'main' into charly/issue#4670-move-legacysubspace-key-ta…
charleenfei Sep 25, 2023
8c1b360
Merge branch 'main' into charly/issue#4670-move-legacysubspace-key-ta…
charleenfei Sep 25, 2023
342abb3
Merge branch 'main' into charly/issue#4670-move-legacysubspace-key-ta…
colin-axner Sep 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ func NewKeeper(
ics4Wrapper porttypes.ICS4Wrapper, channelKeeper icatypes.ChannelKeeper, portKeeper icatypes.PortKeeper,
scopedKeeper exported.ScopedKeeper, msgRouter icatypes.MessageRouter, authority string,
) Keeper {
// set KeyTable if it has not already been set
if !legacySubspace.HasKeyTable() {
legacySubspace = legacySubspace.WithKeyTable(types.ParamKeyTable())
}

if strings.TrimSpace(authority) == "" {
panic(errors.New("authority must be non-empty"))
}
Expand Down
5 changes: 0 additions & 5 deletions modules/apps/27-interchain-accounts/host/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ func NewKeeper(
panic(errors.New("the Interchain Accounts module account has not been set"))
}

// set KeyTable if it has not already been set
if !legacySubspace.HasKeyTable() {
legacySubspace = legacySubspace.WithKeyTable(types.ParamKeyTable())
}

if strings.TrimSpace(authority) == "" {
panic(errors.New("authority must be non-empty"))
}
Expand Down
4 changes: 0 additions & 4 deletions modules/apps/transfer/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ func NewKeeper(
if addr := authKeeper.GetModuleAddress(types.ModuleName); addr == nil {
panic(errors.New("the IBC transfer module account has not been set"))
}
// set KeyTable if it has not already been set
if !legacySubspace.HasKeyTable() {
legacySubspace = legacySubspace.WithKeyTable(types.ParamKeyTable())
}

if strings.TrimSpace(authority) == "" {
panic(errors.New("authority must be non-empty"))
Expand Down
5 changes: 0 additions & 5 deletions modules/core/02-client/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ type Keeper struct {

// NewKeeper creates a new NewKeeper instance
func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, legacySubspace paramtypes.Subspace, sk types.StakingKeeper, uk types.UpgradeKeeper) Keeper {
// set KeyTable if it has not already been set
if !legacySubspace.HasKeyTable() {
legacySubspace = legacySubspace.WithKeyTable(types.ParamKeyTable())
}

return Keeper{
storeKey: key,
cdc: cdc,
Expand Down
2 changes: 1 addition & 1 deletion modules/core/02-client/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ func (m Migrator) Migrate3to4(ctx sdk.Context) error {
func (m Migrator) MigrateParams(ctx sdk.Context) error {
var params types.Params
m.keeper.legacySubspace.GetParamSet(ctx, &params)

if err := params.Validate(); err != nil {
return err
}

m.keeper.SetParams(ctx, params)
m.keeper.Logger(ctx).Info("successfully migrated client to self-manage params")
return nil
Expand Down
5 changes: 0 additions & 5 deletions modules/core/03-connection/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ type Keeper struct {

// NewKeeper creates a new IBC connection Keeper instance
func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, legacySubspace paramtypes.Subspace, ck types.ClientKeeper) Keeper {
// set KeyTable if it has not already been set
if !legacySubspace.HasKeyTable() {
legacySubspace = legacySubspace.WithKeyTable(types.ParamKeyTable())
}

return Keeper{
storeKey: key,
cdc: cdc,
Expand Down
2 changes: 1 addition & 1 deletion modules/core/03-connection/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ func (m Migrator) Migrate3to4(ctx sdk.Context) error {
func (m Migrator) MigrateParams(ctx sdk.Context) error {
var params types.Params
m.keeper.legacySubspace.GetParamSet(ctx, &params)

if err := params.Validate(); err != nil {
return err
}

m.keeper.SetParams(ctx, params)
m.keeper.Logger(ctx).Info("successfully migrated connection to self-manage params")
return nil
Expand Down
2 changes: 1 addition & 1 deletion modules/core/03-connection/keeper/migrations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (suite *KeeperTestSuite) TestMigrateParams() {
func() {
params := types.DefaultParams()
subspace := suite.chainA.GetSimApp().GetSubspace(ibcexported.ModuleName)
subspace.SetParamSet(suite.chainA.GetContext(), &params) // set params
subspace.SetParamSet(suite.chainA.GetContext(), &params)
},
types.DefaultParams(),
},
Expand Down
9 changes: 0 additions & 9 deletions modules/core/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -45,14 +44,6 @@ func NewKeeper(
stakingKeeper clienttypes.StakingKeeper, upgradeKeeper clienttypes.UpgradeKeeper,
scopedKeeper capabilitykeeper.ScopedKeeper, authority string,
) *Keeper {
// register paramSpace at top level keeper
// set KeyTable if it has not already been set
if !paramSpace.HasKeyTable() {
keyTable := clienttypes.ParamKeyTable()
keyTable.RegisterParamSet(&connectiontypes.Params{})
paramSpace = paramSpace.WithKeyTable(keyTable)
}

// panic if any of the keepers passed in is empty
if isEmpty(stakingKeeper) {
panic(errors.New("cannot initialize IBC keeper: empty staking keeper"))
Expand Down
14 changes: 8 additions & 6 deletions testing/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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{})
damiannolan marked this conversation as resolved.
Show resolved Hide resolved
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
}
Expand Down
Loading