diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index 40c00d9a2d49..7aa51692e608 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -36,7 +36,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] -* [#17421](https://github.com/cosmos/cosmos-sdk/pull/17421) Remove `appmodule.UpgradeModule` and add `appmodule.HasPreBlocker` interface. +* [#17421](https://github.com/cosmos/cosmos-sdk/pull/17421) Add `appmodule.HasPreBlocker` interface. ## [v0.10.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.10.0) diff --git a/core/appmodule/module.go b/core/appmodule/module.go index 2cbf6e249535..fa94e52bc181 100644 --- a/core/appmodule/module.go +++ b/core/appmodule/module.go @@ -80,3 +80,10 @@ type HasEndBlocker interface { // a block. EndBlock(context.Context) error } + +// UpgradeModule is the extension interface that upgrade module should implement to differentiate +// it from other modules, migration handler need ensure the upgrade module's migration is executed +// before the rest of the modules. +type UpgradeModule interface { + IsUpgradeModule() +} diff --git a/docs/docs/building-modules/01-module-manager.md b/docs/docs/building-modules/01-module-manager.md index cdefe1bd4e42..e8f810d53a7b 100644 --- a/docs/docs/building-modules/01-module-manager.md +++ b/docs/docs/building-modules/01-module-manager.md @@ -42,6 +42,7 @@ The above interfaces are mostly embedding smaller interfaces (extension interfac * [`appmodule.HasEndBlocker`](#hasendblocker): The extension interface that contains information about the `AppModule` and `EndBlock`. * [`appmodule.HasPrecommit`](#hasprecommit): The extension interface that contains information about the `AppModule` and `Precommit`. * [`appmodule.HasPrepareCheckState`](#haspreparecheckstate): The extension interface that contains information about the `AppModule` and `PrepareCheckState`. +* [`appmodule.UpgradeModule`]: The extension interface that signify if the `AppModule` if the module is an upgrade module. * [`appmodule.HasService` / `module.HasServices`](#hasservices): The extension interface for modules to register services. * [`module.HasABCIEndblock`](#hasabciendblock): The extension interface that contains information about the `AppModule`, `EndBlock` and returns an updated validator set. * (legacy) [`module.HasInvariants`](#hasinvariants): The extension interface for registering invariants. diff --git a/types/module/mock_appmodule_test.go b/types/module/mock_appmodule_test.go index 232400d0578f..9c109badd6b5 100644 --- a/types/module/mock_appmodule_test.go +++ b/types/module/mock_appmodule_test.go @@ -28,3 +28,8 @@ type CoreAppModule interface { appmodule.HasPrecommit appmodule.HasPrepareCheckState } + +type CoreUpgradeAppModule interface { + CoreAppModule + appmodule.UpgradeModule +} diff --git a/x/upgrade/module.go b/x/upgrade/module.go index 36c51a3c26cd..37dfe8cae2d2 100644 --- a/x/upgrade/module.go +++ b/x/upgrade/module.go @@ -170,6 +170,9 @@ func (am AppModule) BeginBlock(ctx context.Context) error { return nil } +// IsUpgradeModule implements the module.UpgradeModule interface. +func (am AppModuleBasic) IsUpgradeModule() {} + // // App Wiring Setup //