From d39d47d777a3f078680a84b072dd78c621160c83 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Mon, 28 Feb 2022 09:22:23 +0100 Subject: [PATCH 1/4] small fixes for v2 to v3 migration --- docs/migrations/v2-to-v3.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/migrations/v2-to-v3.md b/docs/migrations/v2-to-v3.md index f2352ce9b05..0b39f8cb673 100644 --- a/docs/migrations/v2-to-v3.md +++ b/docs/migrations/v2-to-v3.md @@ -37,7 +37,7 @@ app.UpgradeKeeper.SetUpgradeHandler("v3", // set ICS27 Host submodule params app.ICAHostKeeper.SetParams(ctx, icahosttypes.Params{ HostEnabled: true, - AllowMessages: []string{"/cosmos.bank.v1beta1.MsgSend", ...], + AllowMessages: []string{"/cosmos.bank.v1beta1.MsgSend", ...}, }) // set ICS27 Controller submodule params @@ -47,7 +47,8 @@ app.UpgradeKeeper.SetUpgradeHandler("v3", ... - return app.mm.RunMigrations(ctx, app.configurator, fromVM) + vm[icatypes.ModuleName] = 1 + return app.mm.RunMigrations(ctx, app.configurator, vm) }) ``` @@ -72,7 +73,7 @@ The migration code required may look like: // overwrite parameters as desired hostGenesisState.Params = icahosttypes.Params{ HostEnabled: true, - AllowMessages: []string{"/cosmos.bank.v1beta1.MsgSend", ...], + AllowMessages: []string{"/cosmos.bank.v1beta1.MsgSend", ...}, } icaGenesisState := icatypes.NewGenesisState(controllerGenesisState, hostGenesisState) From 1c9adf774442e378435f7c301dca767e440dabc3 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Mon, 28 Feb 2022 14:00:13 +0100 Subject: [PATCH 2/4] review comment --- docs/migrations/v2-to-v3.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/migrations/v2-to-v3.md b/docs/migrations/v2-to-v3.md index 0b39f8cb673..c3dc5c3e090 100644 --- a/docs/migrations/v2-to-v3.md +++ b/docs/migrations/v2-to-v3.md @@ -47,7 +47,6 @@ app.UpgradeKeeper.SetUpgradeHandler("v3", ... - vm[icatypes.ModuleName] = 1 return app.mm.RunMigrations(ctx, app.configurator, vm) }) From ae82168d86ea2b8bbb3c4ab6215e68a0723a3a6b Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Tue, 1 Mar 2022 17:31:34 +0100 Subject: [PATCH 3/4] Update v2-to-v3.md --- docs/migrations/v2-to-v3.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/migrations/v2-to-v3.md b/docs/migrations/v2-to-v3.md index ba905f92690..b42c0dd233d 100644 --- a/docs/migrations/v2-to-v3.md +++ b/docs/migrations/v2-to-v3.md @@ -45,7 +45,7 @@ app.UpgradeKeeper.SetUpgradeHandler("v3", // create ICS27 Host submodule params hostParams := icahosttypes.Params{ HostEnabled: true, - AllowMessages: []string{"/cosmos.bank.v1beta1.MsgSend", ...], + AllowMessages: []string{"/cosmos.bank.v1beta1.MsgSend", ...}, } // initialize ICS27 module @@ -53,7 +53,7 @@ app.UpgradeKeeper.SetUpgradeHandler("v3", ... - return app.mm.RunMigrations(ctx, app.configurator, vm) + return app.mm.RunMigrations(ctx, app.configurator, fromVM) }) ``` From bc4ef1d45a502268fc6a11aa90d09708bb1cc3e2 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Thu, 3 Mar 2022 14:47:31 +0100 Subject: [PATCH 4/4] add store upgrade documentation --- docs/migrations/v2-to-v3.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/migrations/v2-to-v3.md b/docs/migrations/v2-to-v3.md index b42c0dd233d..beab128a1fd 100644 --- a/docs/migrations/v2-to-v3.md +++ b/docs/migrations/v2-to-v3.md @@ -61,6 +61,22 @@ app.UpgradeKeeper.SetUpgradeHandler("v3", The host and controller submodule params only need to be set if you integrate those submodules. For example, if a chain chooses not to integrate a controller submodule, it does not need to set the controller params. +#### Add `StoreUpgrades` for ICS27 module + +For ICS27 it is also necessary to [manually add store upgrades](https://docs.cosmos.network/v0.44/core/upgrade.html#add-storeupgrades-for-new-modules) for the new ICS27 module and then configure the store loader to apply those upgrades in `app.go`: + +```go +if upgradeInfo.Name == "v3" && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { + storeUpgrades := store.StoreUpgrades{ + Added: []string{icatypes.ModuleName}, + } + + app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) +} +``` + +This ensures that the new module's stores are added to the multistore before the migrations begin. + ### Genesis migrations If the chain will adopt ICS27 and chooses to upgrade via a genesis export, then the ICS27 parameters must be set during genesis migration.