From fdd0fb6aa16a0f7fd5713f0d460a3db6e1446e28 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Wed, 16 Aug 2023 23:38:09 +0800 Subject: [PATCH] SetPreBeginBlocker before SetBeginBlocker --- runtime/builder.go | 2 +- simapp/app.go | 7 ++++++- types/module/module.go | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/runtime/builder.go b/runtime/builder.go index ec675d04e80a..bc586ff35b72 100644 --- a/runtime/builder.go +++ b/runtime/builder.go @@ -41,7 +41,7 @@ func (a *AppBuilder) Build( bApp.SetVersion(version.Version) bApp.SetInterfaceRegistry(a.app.interfaceRegistry) bApp.MountStores(a.app.storeKeys...) - bApp.SetPreBeginBlocker(a.app.ModuleManager.PreBeginBlocker) + bApp.SetPreBeginBlocker(a.app.ModuleManager.PreBeginBlock) a.app.BaseApp = bApp a.app.configurator = module.NewConfigurator(a.app.cdc, a.app.MsgServiceRouter(), a.app.GRPCQueryRouter()) diff --git a/simapp/app.go b/simapp/app.go index 06bd476c7068..f1fd6aeb64c2 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -418,7 +418,6 @@ func NewSimApp( nftmodule.NewAppModule(appCodec, app.NFTKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper), ) - bApp.SetPreBeginBlocker(app.ModuleManager) // During begin block slashing happens after distr.BeginBlocker so that // there is nothing left over in the validator fee pool, so as to keep the @@ -497,6 +496,7 @@ func NewSimApp( // initialize BaseApp app.SetInitChainer(app.InitChainer) + app.SetPreBeginBlocker(app.PreBeginBlocker) app.SetBeginBlocker(app.BeginBlocker) app.SetEndBlocker(app.EndBlocker) app.setAnteHandler(encodingConfig.TxConfig) @@ -562,6 +562,11 @@ func (app *SimApp) setPostHandler() { // Name returns the name of the App func (app *SimApp) Name() string { return app.BaseApp.Name() } +// PreBeginBlocker application updates every begin block +func (app *SimApp) PreBeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) (sdk.ResponsePreBeginBlock, error) { + return app.ModuleManager.PreBeginBlock(ctx, req) +} + // BeginBlocker application updates every begin block func (app *SimApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { return app.ModuleManager.BeginBlock(ctx, req) diff --git a/types/module/module.go b/types/module/module.go index 4e4a46426d0f..21a361eae43d 100644 --- a/types/module/module.go +++ b/types/module/module.go @@ -561,10 +561,10 @@ func (m Manager) RunMigrations(ctx sdk.Context, cfg Configurator, fromVM Version return updatedVM, nil } -// PreBeginBlocker performs begin block functionality for upgrade module. +// PreBeginBlock 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) PreBeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) (sdk.ResponsePreBeginBlock, error) { +func (m *Manager) PreBeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) (sdk.ResponsePreBeginBlock, error) { ctx = ctx.WithEventManager(sdk.NewEventManager()) paramsChanged := false for _, moduleName := range m.PreBeginBlockers {