From de17e6e6c5b8e882c440356f6a848fced2dd4ff1 Mon Sep 17 00:00:00 2001 From: Vladislav Varadinov Date: Fri, 13 Jan 2023 16:41:00 +0200 Subject: [PATCH] fix: add missing postCtx (#14613) --- baseapp/baseapp.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 22ed0abd881a..8a987156cb79 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -724,8 +724,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 { - // Follow-up Ref: https://github.com/cosmos/cosmos-sdk/pull/13941 - newCtx, err := app.postHandler(runMsgCtx, tx, mode == runTxModeSimulate, err == nil) + // 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, err == nil) if err != nil { return gInfo, nil, anteEvents, priority, err }