Skip to content

Commit 22bea13

Browse files
small fixes for v2 to v3 migration (#1016) (#1074)
* small fixes for v2 to v3 migration * review comment * Update v2-to-v3.md * add store upgrade documentation Co-authored-by: Carlos Rodriguez <[email protected]> (cherry picked from commit a55ca88) Co-authored-by: Carlos Rodriguez <[email protected]>
1 parent 2160689 commit 22bea13

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

docs/migrations/v2-to-v3.md

+18-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ app.UpgradeKeeper.SetUpgradeHandler("v3",
4242
func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
4343
// set the ICS27 consensus version so InitGenesis is not run
4444
fromVM[icatypes.ModuleName] = icamodule.ConsensusVersion()
45-
4645

4746
// create ICS27 Controller submodule params
4847
controllerParams := icacontrollertypes.Params{
@@ -52,7 +51,7 @@ app.UpgradeKeeper.SetUpgradeHandler("v3",
5251
// create ICS27 Host submodule params
5352
hostParams := icahosttypes.Params{
5453
HostEnabled: true,
55-
AllowMessages: []string{"/cosmos.bank.v1beta1.MsgSend", ...],
54+
AllowMessages: []string{"/cosmos.bank.v1beta1.MsgSend", ...},
5655
}
5756

5857
// initialize ICS27 module
@@ -68,6 +67,22 @@ app.UpgradeKeeper.SetUpgradeHandler("v3",
6867
The host and controller submodule params only need to be set if you integrate those submodules.
6968
For example, if a chain chooses not to integrate a controller submodule, it does not need to set the controller params.
7069

70+
#### Add `StoreUpgrades` for ICS27 module
71+
72+
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`:
73+
74+
```go
75+
if upgradeInfo.Name == "v3" && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
76+
storeUpgrades := store.StoreUpgrades{
77+
Added: []string{icatypes.ModuleName},
78+
}
79+
80+
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
81+
}
82+
```
83+
84+
This ensures that the new module's stores are added to the multistore before the migrations begin.
85+
7186
### Genesis migrations
7287

7388
If the chain will adopt ICS27 and chooses to upgrade via a genesis export, then the ICS27 parameters must be set during genesis migration.
@@ -85,7 +100,7 @@ The migration code required may look like:
85100
// overwrite parameters as desired
86101
hostGenesisState.Params = icahosttypes.Params{
87102
HostEnabled: true,
88-
AllowMessages: []string{"/cosmos.bank.v1beta1.MsgSend", ...],
103+
AllowMessages: []string{"/cosmos.bank.v1beta1.MsgSend", ...},
89104
}
90105

91106
icaGenesisState := icatypes.NewGenesisState(controllerGenesisState, hostGenesisState)

0 commit comments

Comments
 (0)