From 9bbfbda47fbd136007fedb16d9d64137352569a0 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Wed, 21 Sep 2022 13:22:43 +0200 Subject: [PATCH 1/4] renaming ica migrations handler pkg version --- .../controller/migrations/{v5 => v6}/migrations.go | 2 +- .../controller/migrations/{v5 => v6}/migrations_test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) rename modules/apps/27-interchain-accounts/controller/migrations/{v5 => v6}/migrations.go (99%) rename modules/apps/27-interchain-accounts/controller/migrations/{v5 => v6}/migrations_test.go (97%) diff --git a/modules/apps/27-interchain-accounts/controller/migrations/v5/migrations.go b/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations.go similarity index 99% rename from modules/apps/27-interchain-accounts/controller/migrations/v5/migrations.go rename to modules/apps/27-interchain-accounts/controller/migrations/v6/migrations.go index 2b91c965885..d9e8124c32d 100644 --- a/modules/apps/27-interchain-accounts/controller/migrations/v5/migrations.go +++ b/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations.go @@ -1,4 +1,4 @@ -package v5 +package v6 import ( "github.com/cosmos/cosmos-sdk/codec" diff --git a/modules/apps/27-interchain-accounts/controller/migrations/v5/migrations_test.go b/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go similarity index 97% rename from modules/apps/27-interchain-accounts/controller/migrations/v5/migrations_test.go rename to modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go index 7818844a554..ba143ef7db3 100644 --- a/modules/apps/27-interchain-accounts/controller/migrations/v5/migrations_test.go +++ b/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go @@ -1,4 +1,4 @@ -package v5_test +package v6_test import ( "testing" @@ -6,7 +6,7 @@ import ( capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" "github.com/stretchr/testify/suite" - v5 "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller/migrations/v5" + v6 "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller/migrations/v6" "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller/types" icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types" channeltypes "github.com/cosmos/ibc-go/v5/modules/core/04-channel/types" @@ -117,7 +117,7 @@ func (suite *MigrationsTestSuite) TestMigrateICS27ChannelCapability() { suite.ResetMemStore() // empty the x/capability in-memory store - err = v5.MigrateICS27ChannelCapability( + err = v6.MigrateICS27ChannelCapability( suite.chainA.GetContext(), suite.chainA.Codec, suite.chainA.GetSimApp().GetKey(capabilitytypes.StoreKey), From 6140890f474b7df4fd75855006330a5c60ec4628 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Wed, 21 Sep 2022 15:18:51 +0200 Subject: [PATCH 2/4] adding v6 upgrade handler to simapp --- testing/simapp/app.go | 6 +++++ testing/simapp/upgrades/v6/upgrades.go | 36 ++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 testing/simapp/upgrades/v6/upgrades.go diff --git a/testing/simapp/app.go b/testing/simapp/app.go index bbc1faa6440..9455d95be4f 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -112,6 +112,7 @@ import ( ibcmock "github.com/cosmos/ibc-go/v5/testing/mock" simappparams "github.com/cosmos/ibc-go/v5/testing/simapp/params" simappupgrades "github.com/cosmos/ibc-go/v5/testing/simapp/upgrades" + v6 "github.com/cosmos/ibc-go/v5/testing/simapp/upgrades/v6" ibctestingtypes "github.com/cosmos/ibc-go/v5/testing/types" ) @@ -870,4 +871,9 @@ func (app *SimApp) setupUpgradeHandlers() { simappupgrades.DefaultUpgradeName, simappupgrades.CreateDefaultUpgradeHandler(app.mm, app.configurator), ) + + app.UpgradeKeeper.SetUpgradeHandler( + v6.UpgradeName, + v6.CreateUpgradeHandler(app.mm, app.configurator, app.appCodec, app.keys[capabilitytypes.ModuleName], app.CapabilityKeeper, ibcmock.ModuleName+icacontrollertypes.SubModuleName), + ) } diff --git a/testing/simapp/upgrades/v6/upgrades.go b/testing/simapp/upgrades/v6/upgrades.go new file mode 100644 index 00000000000..b38f4deac21 --- /dev/null +++ b/testing/simapp/upgrades/v6/upgrades.go @@ -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/v5/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. +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 + } + + return mm.RunMigrations(ctx, configurator, vm) + } +} From 5620b6aab01cf02a7c2b14f41f242ba1a5263553 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Wed, 21 Sep 2022 15:27:56 +0200 Subject: [PATCH 3/4] removing whitespace --- testing/simapp/upgrades/v6/upgrades.go | 1 - 1 file changed, 1 deletion(-) diff --git a/testing/simapp/upgrades/v6/upgrades.go b/testing/simapp/upgrades/v6/upgrades.go index b38f4deac21..64aff619096 100644 --- a/testing/simapp/upgrades/v6/upgrades.go +++ b/testing/simapp/upgrades/v6/upgrades.go @@ -26,7 +26,6 @@ func CreateUpgradeHandler( 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 } From 315759981ca1f3309406a48501e1cf027e716612 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Thu, 29 Sep 2022 10:30:40 +0200 Subject: [PATCH 4/4] adding inline doc comments --- testing/simapp/app.go | 13 ++++++++++++- testing/simapp/upgrades/v6/upgrades.go | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/testing/simapp/app.go b/testing/simapp/app.go index 8898da8b2e1..a612bee1425 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -873,8 +873,19 @@ func (app *SimApp) setupUpgradeHandlers() { 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), + v6.CreateUpgradeHandler( + app.mm, + app.configurator, + app.appCodec, + app.keys[capabilitytypes.ModuleName], + app.CapabilityKeeper, + ibcmock.ModuleName+icacontrollertypes.SubModuleName, + ), ) } diff --git a/testing/simapp/upgrades/v6/upgrades.go b/testing/simapp/upgrades/v6/upgrades.go index 996a7da89ac..9a3b5780562 100644 --- a/testing/simapp/upgrades/v6/upgrades.go +++ b/testing/simapp/upgrades/v6/upgrades.go @@ -17,6 +17,7 @@ const ( ) // 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,