From c6963cd422edb059f6c50b119719914fc47d7f5c Mon Sep 17 00:00:00 2001 From: Facundo Date: Fri, 2 Aug 2024 11:59:38 +0200 Subject: [PATCH 1/2] fix: return events from preblocker in FinalizeBlockResponse --- baseapp/abci.go | 1 + baseapp/abci_test.go | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/baseapp/abci.go b/baseapp/abci.go index 513d8667fc76..e7724182e0e4 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -789,6 +789,7 @@ func (app *BaseApp) internalFinalizeBlock(ctx context.Context, req *abci.Finaliz if err := app.preBlock(req); err != nil { return nil, err } + events = append(events, app.finalizeBlockState.ctx.EventManager().ABCIEvents()...) beginBlock, err := app.beginBlock(req) if err != nil { diff --git a/baseapp/abci_test.go b/baseapp/abci_test.go index f455fd5692a0..b7fb67fad216 100644 --- a/baseapp/abci_test.go +++ b/baseapp/abci_test.go @@ -2298,13 +2298,16 @@ func TestBaseApp_PreBlocker(t *testing.T) { wasHookCalled := false app.SetPreBlocker(func(ctx sdk.Context, req *abci.FinalizeBlockRequest) error { wasHookCalled = true + ctx.EventManager().EmitEvent(sdk.NewEvent("preblockertest", sdk.NewAttribute("height", fmt.Sprintf("%d", req.Height)))) return nil }) app.Seal() - _, err = app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1}) + res, err := app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1}) require.NoError(t, err) require.Equal(t, true, wasHookCalled) + require.Len(t, res.Events, 1) + require.Equal(t, "preblockertest", res.Events[0].Type) // Now try erroring app = baseapp.NewBaseApp(name, logger, db, nil) From ae8091927e024a1bbcd679173170aa6f29930a82 Mon Sep 17 00:00:00 2001 From: Facundo Date: Fri, 2 Aug 2024 12:12:56 +0200 Subject: [PATCH 2/2] cl++ --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5489bf2690eb..92305f048128 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -108,6 +108,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i ### Bug Fixes +* (baseapp) [#21159](https://github.com/cosmos/cosmos-sdk/pull/21159) Return PreBlocker events in FinalizeBlockResponse. * (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. * (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. * (client/keys) [#18562](https://github.com/cosmos/cosmos-sdk/pull/18562) `keys delete` won't terminate when a key is not found.