Skip to content

Commit

Permalink
SetPreBeginBlocker before SetBeginBlocker
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Aug 16, 2023
1 parent 40a9eec commit fdd0fb6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion runtime/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
7 changes: 6 additions & 1 deletion simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions types/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit fdd0fb6

Please sign in to comment.