docs: Add docs for setting store loader (#9526)

## 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)
This commit is contained in:
likhita-809 2021-06-17 20:34:33 +05:30 committed by GitHub
parent 17ba2eb7ca
commit 0e64fa77d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

View File

@ -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

View File

@ -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.