From df7cc3ee672b1516702cc2ee61a91b32b6123a71 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Sun, 13 Aug 2023 21:09:51 +0800 Subject: [PATCH] docs: update upgrade doc and changelog for MigrationModuleManager (#17373) Co-authored-by: Julien Robert --- CHANGELOG.md | 4 ++-- UPGRADING.md | 9 +++++++++ docs/docs/building-apps/03-app-upgrade.md | 12 ++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5ee39f97e..f493c1a28a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,8 +61,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/group) [#17146](https://github.com/cosmos/cosmos-sdk/pull/17146) Rename x/group legacy ORM package's error codespace from "orm" to "legacy_orm", preventing collisions with ORM's error codespace "orm". * (x/bank) [#17170](https://github.com/cosmos/cosmos-sdk/pull/17170) Avoid empty spendable error message on send coins. * (x/distribution) [#17236](https://github.com/cosmos/cosmos-sdk/pull/17236) Using "validateCommunityTax" in "Params.ValidateBasic", preventing panic when field "CommunityTax" is nil. -* (x/upgrade) [#16583](https://github.com/cosmos/cosmos-sdk/pull/16583) Add `MigrationModuleManager` to handle migration of upgrade module before other modules, ensuring access to the updated context with consensus parameters within the same block that executes the migration. -* (x/upgrade) [#17372](https://github.com/cosmos/cosmos-sdk/pull/17372) Stop state machine when `RunMigrationBeginBlock` has error. +* (types) [#16583](https://github.com/cosmos/cosmos-sdk/pull/16583) Add `MigrationModuleManager` to handle migration of upgrade module before other modules, ensuring access to the updated context with consensus parameters within the same block that executes the migration. +* (baseapp) [#17372](https://github.com/cosmos/cosmos-sdk/pull/17372) Stop state-machine when `RunMigrationBeginBlock` has error. ### API Breaking Changes diff --git a/UPGRADING.md b/UPGRADING.md index 64e0ff0aa8..7fbb5c88f5 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -74,6 +74,15 @@ allows an application to define handlers for these methods via `ExtendVoteHandle and `VerifyVoteExtensionHandler` respectively. Please see [here](https://docs.cosmos.network/v0.50/building-apps/vote-extensions) for more info. + +#### Upgrade + +**Users using `depinject` / app v2 do not need any changes, this is abstracted for them.** +```diff ++ app.BaseApp.SetMigrationModuleManager(app.ModuleManager) +``` +BaseApp added `SetMigrationModuleManager` for apps to set their ModuleManager which implements `RunMigrationBeginBlock`. This is essential for BaseApp to run `BeginBlock` of upgrade module and inject `ConsensusParams` to context for `beginBlocker` during `beginBlock`. + #### Events The log section of `abci.TxResult` is not populated in the case of successful diff --git a/docs/docs/building-apps/03-app-upgrade.md b/docs/docs/building-apps/03-app-upgrade.md index 25f989e454..11430f8a34 100644 --- a/docs/docs/building-apps/03-app-upgrade.md +++ b/docs/docs/building-apps/03-app-upgrade.md @@ -50,6 +50,18 @@ the rest of the block as normal. Once 2/3 of the voting power has upgraded, the resume the consensus mechanism. If the majority of operators add a custom `do-upgrade` script, this should be a matter of minutes and not even require them to be awake at that time. +## Set Migration Module Manager + +:::tip +Users using `depinject` / app v2 do not need any changes, this is abstracted for them. +::: + +After app initiation, call `SetMigrationModuleManager` with ModuleManager to give BaseApp access to `RunMigrationBeginBlock`: + +```go +app.BaseApp.SetMigrationModuleManager(app.ModuleManager) +``` + ## Integrating With An App Setup an upgrade Keeper for the app and then define a `BeginBlocker` that calls the upgrade