Skip to content

Commit c225e3f

Browse files
fix(baseapp): return events from preblocker in FinalizeBlockResponse (backport #21159) (#21161)
Co-authored-by: Facundo Medica <14063057+facundomedica@users.noreply.github.com>
1 parent 580af8b commit c225e3f

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
108108

109109
### Bug Fixes
110110

111+
* (baseapp) [#21159](https://github.com/cosmos/cosmos-sdk/pull/21159) Return PreBlocker events in FinalizeBlockResponse.
111112
* (baseapp) [#18727](https://github.com/cosmos/cosmos-sdk/pull/18727) Ensure that `BaseApp.Init` firstly returns any errors from a nil commit multistore instead of panicking on nil dereferencing and before sealing the app.
112113
* (client) [#18622](https://github.com/cosmos/cosmos-sdk/pull/18622) Fixed a potential under/overflow from `uint64->int64` when computing gas fees as a LegacyDec.
113114
* (client/keys) [#18562](https://github.com/cosmos/cosmos-sdk/pull/18562) `keys delete` won't terminate when a key is not found.

baseapp/abci.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ func (app *BaseApp) internalFinalizeBlock(ctx context.Context, req *abci.Finaliz
789789
if err := app.preBlock(req); err != nil {
790790
return nil, err
791791
}
792+
events = append(events, app.finalizeBlockState.ctx.EventManager().ABCIEvents()...)
792793

793794
beginBlock, err := app.beginBlock(req)
794795
if err != nil {

baseapp/abci_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2062,13 +2062,16 @@ func TestBaseApp_PreBlocker(t *testing.T) {
20622062
wasHookCalled := false
20632063
app.SetPreBlocker(func(ctx sdk.Context, req *abci.FinalizeBlockRequest) error {
20642064
wasHookCalled = true
2065+
ctx.EventManager().EmitEvent(sdk.NewEvent("preblockertest", sdk.NewAttribute("height", fmt.Sprintf("%d", req.Height))))
20652066
return nil
20662067
})
20672068
app.Seal()
20682069

2069-
_, err = app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1})
2070+
res, err := app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1})
20702071
require.NoError(t, err)
20712072
require.Equal(t, true, wasHookCalled)
2073+
require.Len(t, res.Events, 1)
2074+
require.Equal(t, "preblockertest", res.Events[0].Type)
20722075

20732076
// Now try erroring
20742077
app = baseapp.NewBaseApp(name, logger, db, nil)

0 commit comments

Comments
 (0)