Skip to content

Commit

Permalink
docs: Add docs for setting store loader (#9526)
Browse files Browse the repository at this point in the history
## Description

Closes: #9503 

<!-- Add a description of the changes that this PR introduces and the files that
are the most critical to review. -->

Add documentation for setting StoreLoader as part of in-place store migration.

---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [x] included the correct `docs:` prefix in the PR title
- [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting))
- [x] provided a link to the relevant issue or specification
- [ ] followed the [documentation writing guidelines](https://github.com/cosmos/cosmos-sdk/blob/master/docs/DOC_WRITING_GUIDELINES.md)
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [x] confirmed the correct `docs:` prefix in the PR title
- [ ] confirmed all author checklist items have been addressed 
- [x] confirmed that this PR only changes documentation
- [x] reviewed content for consistency
- [x] reviewed content for thoroughness
- [x] reviewed content for spelling and grammar
- [ ] tested instructions (if applicable)
  • Loading branch information
likhita-809 authored Jun 17, 2021
1 parent 17ba2eb commit 0e64fa7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/building-modules/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ In-place store migrations allow your modules to upgrade to new versions that inc

## Prerequisite Readings

- [In-Place Store Migration](../core-concepts/upgrade.md) {prereq}
- [In-Place Store Migration](../core/upgrade.md) {prereq}

## Consensus Version

Expand Down
23 changes: 23 additions & 0 deletions docs/core/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,29 @@ To learn more about configuring migration scripts for your modules, see the [Mig

You can introduce entirely new modules to the application during an upgrade. New modules are recognized because they have not yet been registered in `x/upgrade`'s `VersionMap` store. In this case, `RunMigrations` calls the `InitGenesis` function from the corresponding module to set up its initial state.

### Add StoreUpgrades for New Modules

All chains preparing to run in-place store migrations will need to manually add store upgrades for new modules and then configure the store loader to apply those upgrades. This ensures that the new module's stores are added to the multistore before the migrations begin.

```golang
upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(err)
}

if upgradeInfo.Name == "my-plan" && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{
// add store upgrades for new modules
// Example:
// Added: []string{"foo", "bar"},
// ...
}

// configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}
```

## Overwriting Genesis Functions

The Cosmos SDK offers modules that the application developer can import in their app. These modules often have an `InitGenesis` function already defined.
Expand Down

0 comments on commit 0e64fa7

Please sign in to comment.