From b7a526570e71edb15eeaf378bf1eeec1a41f343e Mon Sep 17 00:00:00 2001 From: Facundo Medica <14063057+facundomedica@users.noreply.github.com> Date: Thu, 29 Aug 2024 10:59:20 +0200 Subject: [PATCH 1/2] fix(baseapp): preblock events are not emmitted correctly (#21444) (cherry picked from commit 58bbcd9d758cd5120f16ac38df4eb23e94088e6d) # Conflicts: # baseapp/baseapp.go # types/module/module.go --- baseapp/baseapp.go | 5 +++++ types/module/module.go | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index a89620485087..0c10a274e0b0 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -707,9 +707,14 @@ 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 { +<<<<<<< HEAD ctx := app.finalizeBlockState.Context() rsp, err := app.preBlocker(ctx, req) if err != nil { +======= + ctx := app.finalizeBlockState.Context().WithEventManager(sdk.NewEventManager()) + if err := app.preBlocker(ctx, req); err != nil { +>>>>>>> 58bbcd9d7 (fix(baseapp): preblock events are not emmitted correctly (#21444)) return nil, err } // rsp.ConsensusParamsChanged is true from preBlocker means ConsensusParams in store get changed diff --git a/types/module/module.go b/types/module/module.go index 432d51b5fde9..f1285adeb6dd 100644 --- a/types/module/module.go +++ b/types/module/module.go @@ -750,9 +750,13 @@ func (m Manager) RunMigrations(ctx context.Context, cfg Configurator, fromVM Ver // PreBlock 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. +<<<<<<< HEAD func (m *Manager) PreBlock(ctx sdk.Context) (*sdk.ResponsePreBlock, error) { ctx = ctx.WithEventManager(sdk.NewEventManager()) paramsChanged := false +======= +func (m *Manager) PreBlock(ctx sdk.Context) error { +>>>>>>> 58bbcd9d7 (fix(baseapp): preblock events are not emmitted correctly (#21444)) for _, moduleName := range m.OrderPreBlockers { if module, ok := m.Modules[moduleName].(appmodule.HasPreBlocker); ok { rsp, err := module.PreBlock(ctx) From d57f6fcc9e28129b54f593e7f5f49fdbc34df0c8 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Fri, 30 Aug 2024 21:41:59 +0200 Subject: [PATCH 2/2] fix conflicts --- CHANGELOG.md | 1 + baseapp/baseapp.go | 7 +------ types/module/module.go | 5 ----- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd73d04d79d2..efe3aa3faba5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,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 0c10a274e0b0..5fb0b0fca479 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -707,14 +707,9 @@ 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 { -<<<<<<< HEAD - ctx := app.finalizeBlockState.Context() + ctx := app.finalizeBlockState.Context().WithEventManager(sdk.NewEventManager()) rsp, err := app.preBlocker(ctx, req) if err != nil { -======= - ctx := app.finalizeBlockState.Context().WithEventManager(sdk.NewEventManager()) - if err := app.preBlocker(ctx, req); err != nil { ->>>>>>> 58bbcd9d7 (fix(baseapp): preblock events are not emmitted correctly (#21444)) return nil, err } // rsp.ConsensusParamsChanged is true from preBlocker means ConsensusParams in store get changed diff --git a/types/module/module.go b/types/module/module.go index f1285adeb6dd..7eacde76d097 100644 --- a/types/module/module.go +++ b/types/module/module.go @@ -750,13 +750,8 @@ func (m Manager) RunMigrations(ctx context.Context, cfg Configurator, fromVM Ver // PreBlock 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. -<<<<<<< HEAD func (m *Manager) PreBlock(ctx sdk.Context) (*sdk.ResponsePreBlock, error) { - ctx = ctx.WithEventManager(sdk.NewEventManager()) paramsChanged := false -======= -func (m *Manager) PreBlock(ctx sdk.Context) error { ->>>>>>> 58bbcd9d7 (fix(baseapp): preblock events are not emmitted correctly (#21444)) for _, moduleName := range m.OrderPreBlockers { if module, ok := m.Modules[moduleName].(appmodule.HasPreBlocker); ok { rsp, err := module.PreBlock(ctx)