Skip to content

Commit

Permalink
feat(app): update old migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
amimart committed Jan 17, 2024
1 parent 85362d4 commit ab068fc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 21 deletions.
10 changes: 6 additions & 4 deletions app/upgrades/v4/upgrade.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package v4

import (
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"context"

storetypes "cosmossdk.io/store/types"
upgradetypes "cosmossdk.io/x/upgrade/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

const UpgradeName = "v4.0.0"
Expand All @@ -15,8 +17,8 @@ func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
logger := ctx.Logger().With("upgrade", UpgradeName)
return func(ctx context.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
logger := sdk.UnwrapSDKContext(ctx).Logger().With("upgrade", UpgradeName)

logger.Debug("running module migrations...")
return mm.RunMigrations(ctx, configurator, vm)
Expand Down
10 changes: 6 additions & 4 deletions app/upgrades/v41/upgrade.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package v41

import (
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"context"

storetypes "cosmossdk.io/store/types"
upgradetypes "cosmossdk.io/x/upgrade/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

const UpgradeName = "v4.1.0"
Expand All @@ -15,8 +17,8 @@ func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
logger := ctx.Logger().With("upgrade", UpgradeName)
return func(ctx context.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
logger := sdk.UnwrapSDKContext(ctx).Logger().With("upgrade", UpgradeName)

logger.Debug("running module migrations...")
return mm.RunMigrations(ctx, configurator, vm)
Expand Down
24 changes: 15 additions & 9 deletions app/upgrades/v5/upgrade.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package v5

import (
"context"

wasmmigrationtypes "github.com/CosmWasm/wasmd/x/wasm/migrations/v2"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"

storetypes "cosmossdk.io/store/types"
upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/baseapp"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
Expand All @@ -19,11 +23,10 @@ import (
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types"
icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types"
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
icacontrollertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types"
icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types"
ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
)

const UpgradeName = "v5.0.0"
Expand Down Expand Up @@ -83,7 +86,7 @@ func CreateUpgradeHandler(
keyTable = icacontrollertypes.ParamKeyTable()
// wasm
case wasmtypes.ModuleName:
keyTable = wasmtypes.ParamKeyTable() //nolint:staticcheck
keyTable = wasmmigrationtypes.ParamKeyTable() //nolint:staticcheck
default:
continue
}
Expand All @@ -95,11 +98,14 @@ func CreateUpgradeHandler(

baseAppLegacySS := paramsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())

return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
logger := ctx.Logger().With("upgrade", UpgradeName)
return func(ctx context.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
sdkCtx := sdk.UnwrapSDKContext(ctx)
logger := sdkCtx.Logger().With("upgrade", UpgradeName)

logger.Debug("migrate consensus params keeper")
baseapp.MigrateParams(ctx, baseAppLegacySS, consensusParamsKeeper)
if err := baseapp.MigrateParams(sdkCtx, baseAppLegacySS, consensusParamsKeeper.ParamsStore); err != nil {
return nil, err
}

logger.Debug("running module migrations...")
return mm.RunMigrations(ctx, configurator, vm)
Expand Down
10 changes: 6 additions & 4 deletions app/upgrades/v6/upgrade.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package v6

import (
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"context"

storetypes "cosmossdk.io/store/types"
upgradetypes "cosmossdk.io/x/upgrade/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

const UpgradeName = "v6.0.0"
Expand All @@ -21,8 +23,8 @@ func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
logger := ctx.Logger().With("upgrade", UpgradeName)
return func(ctx context.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
logger := sdk.UnwrapSDKContext(ctx).Logger().With("upgrade", UpgradeName)

logger.Debug("running module migrations...")
return mm.RunMigrations(ctx, configurator, vm)
Expand Down

0 comments on commit ab068fc

Please sign in to comment.