Skip to content

Commit

Permalink
small fixes for v2 to v3 migration (#1016)
Browse files Browse the repository at this point in the history
* small fixes for v2 to v3 migration

* review comment

* Update v2-to-v3.md

* add store upgrade documentation

Co-authored-by: Carlos Rodriguez <crodveg@gmail.com>
  • Loading branch information
crodriguezvega and Carlos Rodriguez authored Mar 4, 2022
1 parent f71a505 commit a55ca88
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions docs/migrations/v2-to-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ app.UpgradeKeeper.SetUpgradeHandler("v3",
func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// set the ICS27 consensus version so InitGenesis is not run
fromVM[icatypes.ModuleName] = icamodule.ConsensusVersion()


// create ICS27 Controller submodule params
controllerParams := icacontrollertypes.Params{
Expand All @@ -46,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
Expand All @@ -62,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.
Expand All @@ -79,7 +94,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)
Expand Down

0 comments on commit a55ca88

Please sign in to comment.