diff --git a/app/upgrades/v23/upgrades.go b/app/upgrades/v23/upgrades.go index e7ae32159..dcc0963cd 100644 --- a/app/upgrades/v23/upgrades.go +++ b/app/upgrades/v23/upgrades.go @@ -3,18 +3,20 @@ package v23 import ( "fmt" + "github.com/CosmosContracts/juno/v23/app/keepers" + "github.com/CosmosContracts/juno/v23/app/upgrades" + "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - - "github.com/CosmosContracts/juno/v23/app/keepers" - "github.com/CosmosContracts/juno/v23/app/upgrades" + icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v7/types" ) func CreateV23UpgradeHandler( mm *module.Manager, cfg module.Configurator, - _ *keepers.AppKeepers, + keepers *keepers.AppKeepers, ) upgradetypes.UpgradeHandler { return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { logger := ctx.Logger().With("upgrade", UpgradeName) @@ -22,12 +24,34 @@ func CreateV23UpgradeHandler( nativeDenom := upgrades.GetChainsDenomToken(ctx.ChainID()) logger.Info(fmt.Sprintf("With native denom %s", nativeDenom)) + // migrate ICQ params + for _, subspace := range keepers.ParamsKeeper.GetSubspaces() { + subspace := subspace + + var keyTable paramstypes.KeyTable + if subspace.Name() == icqtypes.ModuleName { + keyTable = icqtypes.ParamKeyTable() + } else { + continue + } + + if !subspace.HasKeyTable() { + subspace.WithKeyTable(keyTable) + } + } + + // Migrate Tendermint consensus parameters from x/params module to a deprecated x/consensus module. + // The old params module is required to still be imported in your app.go in order to handle this migration. + baseAppLegacySS := keepers.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()) + baseapp.MigrateParams(ctx, baseAppLegacySS, &keepers.ConsensusParamsKeeper) + // Run migrations logger.Info(fmt.Sprintf("pre migrate version map: %v", vm)) versionMap, err := mm.RunMigrations(ctx, cfg, vm) if err != nil { return nil, err } + logger.Info(fmt.Sprintf("post migrate version map: %v", versionMap)) return versionMap, err