From 200f8658e5f4fba6361bd803c2ee55a8997e75da Mon Sep 17 00:00:00 2001 From: John Letey Date: Wed, 23 Nov 2022 10:32:35 +0100 Subject: [PATCH 1/2] fix: remove duplicate ante events --- baseapp/baseapp.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 31f61e7199d1..b657e06b548a 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -739,7 +739,12 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte) (gInfo sdk.GasInfo, re // // Note: If the postHandler fails, we also revert the runMsgs state. if app.postHandler != nil { - newCtx, err := app.postHandler(runMsgCtx, tx, mode == runTxModeSimulate) + // The runMsgCtx context currently contains events emitted by the ante handler. + // We clear this to correctly order events without duplicates. + // Note that the state is still preserved. + postCtx := runMsgCtx.WithEventManager(sdk.NewEventManager()) + + newCtx, err := app.postHandler(postCtx, tx, mode == runTxModeSimulate) if err != nil { return gInfo, nil, nil, priority, err } From 97db3f014ffc4e369288287f06081ebc75c1c5a5 Mon Sep 17 00:00:00 2001 From: John Letey Date: Wed, 23 Nov 2022 11:30:20 +0100 Subject: [PATCH 2/2] chore: update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08663e4a36c4..096cc7b28437 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -202,6 +202,7 @@ extension interfaces. `module.Manager.Modules` is now of type `map[string]interf * (server) [#13778](https://github.com/cosmos/cosmos-sdk/pull/13778) Set Cosmos SDK default endpoints to localhost to avoid unknown exposure of endpoints. * (x/auth) [#13877](https://github.com/cosmos/cosmos-sdk/pull/13877) Handle missing account numbers during `InitGenesis`. * (x/gov) [#13918](https://github.com/cosmos/cosmos-sdk/pull/13918) Fix propagation of message errors when executing a proposal. +* (baseapp) [#13983](https://github.com/cosmos/cosmos-sdk/pull/13983) Don't emit duplicate ante-handler events when a post-handler is defined. ### Deprecated