Skip to content

Commit c312d99

Browse files
fix(baseapp): return events from preblocker in FinalizeBlockResponse (#21159)
1 parent 04bedcd commit c312d99

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

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
@@ -2298,13 +2298,16 @@ func TestBaseApp_PreBlocker(t *testing.T) {
22982298
wasHookCalled := false
22992299
app.SetPreBlocker(func(ctx sdk.Context, req *abci.FinalizeBlockRequest) error {
23002300
wasHookCalled = true
2301+
ctx.EventManager().EmitEvent(sdk.NewEvent("preblockertest", sdk.NewAttribute("height", fmt.Sprintf("%d", req.Height))))
23012302
return nil
23022303
})
23032304
app.Seal()
23042305

2305-
_, err = app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1})
2306+
res, err := app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1})
23062307
require.NoError(t, err)
23072308
require.Equal(t, true, wasHookCalled)
2309+
require.Len(t, res.Events, 1)
2310+
require.Equal(t, "preblockertest", res.Events[0].Type)
23082311

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

0 commit comments

Comments
 (0)