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

chore: add v6 upgrade handler to simapp #2383

Merged
merged 12 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions testing/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ import (
ibcmock "github.com/cosmos/ibc-go/v6/testing/mock"
simappparams "github.com/cosmos/ibc-go/v6/testing/simapp/params"
simappupgrades "github.com/cosmos/ibc-go/v6/testing/simapp/upgrades"
v6 "github.com/cosmos/ibc-go/v6/testing/simapp/upgrades/v6"
ibctestingtypes "github.com/cosmos/ibc-go/v6/testing/types"
)

Expand Down Expand Up @@ -870,4 +871,20 @@ func (app *SimApp) setupUpgradeHandlers() {
simappupgrades.DefaultUpgradeName,
simappupgrades.CreateDefaultUpgradeHandler(app.mm, app.configurator),
)

// NOTE: The moduleName arg of v6.CreateUpgradeHandler refers to the auth module ScopedKeeper name to which the channel capability should be migrated from.
// This should be the same string value provided upon instantiation of the ScopedKeeper with app.CapabilityKeeper.ScopeToModule()
// TODO: update git tag in link below
// See: https://github.com/cosmos/ibc-go/blob/v5.0.0-rc2/testing/simapp/app.go#L304
app.UpgradeKeeper.SetUpgradeHandler(
v6.UpgradeName,
v6.CreateUpgradeHandler(
app.mm,
app.configurator,
app.appCodec,
app.keys[capabilitytypes.ModuleName],
app.CapabilityKeeper,
ibcmock.ModuleName+icacontrollertypes.SubModuleName,
),
)
}
36 changes: 36 additions & 0 deletions testing/simapp/upgrades/v6/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package v6

import (
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

v6 "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/controller/migrations/v6"
)

const (
// UpgradeName defines the on-chain upgrade name for the SimApp v6 upgrade.
UpgradeName = "v6"
)

// CreateUpgradeHandler creates an upgrade handler for the v6 SimApp upgrade.
// NOTE: The v6.MigrateICS27ChannelCapabiliity function can be omitted if chains do not yet implement an ICS27 controller module
func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
cdc codec.BinaryCodec,
capabilityStoreKey *storetypes.KVStoreKey,
capabilityKeeper *capabilitykeeper.Keeper,
moduleName string,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
if err := v6.MigrateICS27ChannelCapability(ctx, cdc, capabilityStoreKey, capabilityKeeper, moduleName); err != nil {
return nil, err
}
colin-axner marked this conversation as resolved.
Show resolved Hide resolved

return mm.RunMigrations(ctx, configurator, vm)
}
}