Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add MigrationModuleManager to handle migration of upgrade module before other modules #16583

Merged
merged 35 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1e55c09
add WithConsensusParamsGetter for manager
mmsqe Jun 15, 2023
5d513a3
test WithConsensusParamsGetter
mmsqe Jun 16, 2023
3fcd4d6
test continuously call BeginBlock
mmsqe Jun 16, 2023
34d47d1
add doc
mmsqe Jun 16, 2023
c21cff7
rm module name check
mmsqe Jun 16, 2023
ea9e96a
add change log
mmsqe Jun 16, 2023
721fb8b
Update CHANGELOG.md
mmsqe Jun 16, 2023
3158f6a
fix interface
mmsqe Jun 16, 2023
e54fc1a
fix lint
mmsqe Jun 16, 2023
81038ec
Apply suggestions from code review
mmsqe Jun 20, 2023
36a3944
Merge remote-tracking branch 'origin/main' into fix_cp
mmsqe Jun 20, 2023
5e43e65
cleanup doc
mmsqe Jun 16, 2023
9c3a25b
fix resolve
mmsqe Jun 20, 2023
5bca160
Merge remote-tracking branch 'origin/main' into fix_cp
mmsqe Jun 26, 2023
9f6994d
fix lint
mmsqe Jun 26, 2023
591d7cf
add ck
mmsqe Jun 27, 2023
e3f80d6
Revert "add ck"
mmsqe Jun 27, 2023
26e9624
add ConsensusParamsGetter interface
mmsqe Jun 27, 2023
6e50d86
Merge remote-tracking branch 'origin/main' into fix_cp
mmsqe Jul 17, 2023
42fc450
fix doc
mmsqe Jul 18, 2023
59f4bef
Merge remote-tracking branch 'origin/main' into fix_cp
mmsqe Aug 9, 2023
120cdae
handle upgrade 1st
mmsqe Aug 9, 2023
74746c9
Update x/upgrade/module.go
mmsqe Aug 10, 2023
7c812be
Merge remote-tracking branch 'origin/main' into fix_cp
mmsqe Aug 10, 2023
bbf4eef
fix doc
mmsqe Aug 10, 2023
ca99e59
replace WithConsensusParamsGetter with MigrationModuleManager
mmsqe Aug 10, 2023
86bc9c0
fix test
mmsqe Aug 10, 2023
1a1b3ce
Apply suggestions from code review
mmsqe Aug 10, 2023
5400774
check nil
mmsqe Aug 11, 2023
2b56da6
update doc
mmsqe Aug 11, 2023
95c6ed9
add test
mmsqe Aug 11, 2023
08a9279
Merge remote-tracking branch 'origin/main' into fix_cp
mmsqe Aug 11, 2023
6ceebbf
update doc
mmsqe Aug 11, 2023
71ea378
Apply suggestions from code review
mmsqe Aug 11, 2023
ff7f08d
Merge branch 'main' into fix_cp
julienrbrt Aug 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update doc
  • Loading branch information
mmsqe committed Aug 11, 2023
commit 2b56da68a52a4d37766d6b37c7c51d95a5cc36ca
2 changes: 2 additions & 0 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,8 @@ func (app *BaseApp) beginBlock(req *abci.RequestFinalizeBlock) (sdk.BeginBlock,
ctx := app.finalizeBlockState.ctx
if app.migrationModuleManager != nil && app.migrationModuleManager.RunMigrationBeginBlock(ctx) {
cp := ctx.ConsensusParams()
// Manager skips this step if Block is non-nil since upgrade module is expected to set this params
// and consensus parameters should not be overwritten.
if cp.Block == nil {
if cp = app.GetConsensusParams(ctx); cp.Block != nil {
ctx = ctx.WithConsensusParams(cp)
Expand Down
7 changes: 5 additions & 2 deletions types/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,9 @@ func (m Manager) RunMigrations(ctx context.Context, cfg Configurator, fromVM Ver
return updatedVM, nil
}

// RunMigrationBeginBlock performs begin block functionality for upgrade module.
// It takes the current context as a parameter and returns a boolean value
// indicating whether the migration was successfully executed or not.
func (m *Manager) RunMigrationBeginBlock(ctx sdk.Context) bool {
for _, moduleName := range m.OrderBeginBlockers {
if mod, ok := m.Modules[moduleName].(appmodule.HasBeginBlocker); ok {
Expand All @@ -710,8 +713,8 @@ func (m *Manager) RunMigrationBeginBlock(ctx sdk.Context) bool {
return false
}

// BeginBlock performs begin block functionality for all modules. It creates a
// child context with an event manager to aggregate events emitted from all
// BeginBlock performs begin block functionality for non-upgrade modules. It creates a
// child context with an event manager to aggregate events emitted from non-upgrade
// modules.
func (m *Manager) BeginBlock(ctx sdk.Context) (sdk.BeginBlock, error) {
ctx = ctx.WithEventManager(sdk.NewEventManager())
Expand Down