From 8c9152d9c619189a98aa0ba7b8355839737a9fce Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 30 Aug 2024 19:53:57 +0000 Subject: [PATCH] fix(baseapp): preblock events are not emmitted correctly (backport #21444) (#21458) Co-authored-by: Facundo Medica <14063057+facundomedica@users.noreply.github.com> Co-authored-by: Julien Robert --- CHANGELOG.md | 1 + baseapp/baseapp.go | 2 +- types/module/module.go | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 370c39b819bc..44ee41b033eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes * (baseapp) [#21256](https://github.com/cosmos/cosmos-sdk/pull/21256) Halt height will not commit the block indicated, meaning that if halt-height is set to 10, only blocks until 9 (included) will be committed. This is to go back to the original behavior before a change was introduced in v0.50.0. +* (baseapp) [#21444](https://github.com/cosmos/cosmos-sdk/pull/21444) Follow-up, Return PreBlocker events in FinalizeBlockResponse. ## [v0.50.9](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.9) - 2024-08-07 diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index a89620485087..5fb0b0fca479 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -707,7 +707,7 @@ func (app *BaseApp) cacheTxContext(ctx sdk.Context, txBytes []byte) (sdk.Context func (app *BaseApp) preBlock(req *abci.RequestFinalizeBlock) ([]abci.Event, error) { var events []abci.Event if app.preBlocker != nil { - ctx := app.finalizeBlockState.Context() + ctx := app.finalizeBlockState.Context().WithEventManager(sdk.NewEventManager()) rsp, err := app.preBlocker(ctx, req) if err != nil { return nil, err diff --git a/types/module/module.go b/types/module/module.go index 432d51b5fde9..7eacde76d097 100644 --- a/types/module/module.go +++ b/types/module/module.go @@ -751,7 +751,6 @@ func (m Manager) RunMigrations(ctx context.Context, cfg Configurator, fromVM Ver // 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) PreBlock(ctx sdk.Context) (*sdk.ResponsePreBlock, error) { - ctx = ctx.WithEventManager(sdk.NewEventManager()) paramsChanged := false for _, moduleName := range m.OrderPreBlockers { if module, ok := m.Modules[moduleName].(appmodule.HasPreBlocker); ok {