From 38720dffc262dc6b508c4c6816f2b032fba9bb26 Mon Sep 17 00:00:00 2001 From: John Letey Date: Fri, 2 Dec 2022 22:58:02 +0000 Subject: [PATCH 1/2] fix: remove duplicate ante events (#13983) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description After enabling the post-handler on our chain, we realised something odd with our transaction events. The ordering was `[ANTE, MSGS, ANTE, POST]`. After doing some digging, we realised that the context used inside the post-handler still contains the events from the ante-handler. This should be backported to v0.46.x and v0.47.x 😄 Happy to make it compatible with #13940 when that gets merged! cc @mbreithecker --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable) (cherry picked from commit 25449b5812c42e8528daee054120f2deddb3e717) # Conflicts: # CHANGELOG.md --- CHANGELOG.md | 14 ++++++++++++++ baseapp/baseapp.go | 7 ++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d18969fc1ac..d6e5fb848cfb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,20 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes * (x/gov) [#13918](https://github.com/cosmos/cosmos-sdk/pull/13918) Fix propagation of message errors when executing a proposal. +<<<<<<< HEAD +======= +* (baseapp)[#14049](https://github.com/cosmos/cosmos-sdk/pull/14049) Fix state sync when interval is zero. +* (store) [#13516](https://github.com/cosmos/cosmos-sdk/pull/13516) Fix state listener that was observing writes at wrong time. +* (baseapp) [#13983](https://github.com/cosmos/cosmos-sdk/pull/13983) Don't emit duplicate ante-handler events when a post-handler is defined. + +### Deprecated + +* (x/evidence) [#13740](https://github.com/cosmos/cosmos-sdk/pull/13740) The `evidence_hash` field of `QueryEvidenceRequest` has been deprecated and now contains a new field `hash` with type `string`. +* (x/bank) [#11859](https://github.com/cosmos/cosmos-sdk/pull/11859) The Params.SendEnabled field is deprecated and unusable. + The information can now be accessed using the BankKeeper. + Setting can be done using MsgSetSendEnabled as a governance proposal. + A SendEnabled query has been added to both GRPC and CLI. +>>>>>>> 25449b581 (fix: remove duplicate ante events (#13983)) ## [v0.46.5](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.5) - 2022-11-17 diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 448ef792fd05..5506aa534954 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -721,7 +721,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 1de3a0712d05f252f7f4e0f20cf035055f5c9fd3 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Sat, 3 Dec 2022 00:03:19 +0100 Subject: [PATCH 2/2] fix changelog --- CHANGELOG.md | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6e5fb848cfb..f30ed9fcf25b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes +* (baseapp) [#13983](https://github.com/cosmos/cosmos-sdk/pull/13983) Don't emit duplicate ante-handler events when a post-handler is defined. * (baseapp) [#14049](https://github.com/cosmos/cosmos-sdk/pull/14049) Fix state sync when interval is zero. ## [v0.46.6](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.6) - 2022-11-18 @@ -59,20 +60,6 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes * (x/gov) [#13918](https://github.com/cosmos/cosmos-sdk/pull/13918) Fix propagation of message errors when executing a proposal. -<<<<<<< HEAD -======= -* (baseapp)[#14049](https://github.com/cosmos/cosmos-sdk/pull/14049) Fix state sync when interval is zero. -* (store) [#13516](https://github.com/cosmos/cosmos-sdk/pull/13516) Fix state listener that was observing writes at wrong time. -* (baseapp) [#13983](https://github.com/cosmos/cosmos-sdk/pull/13983) Don't emit duplicate ante-handler events when a post-handler is defined. - -### Deprecated - -* (x/evidence) [#13740](https://github.com/cosmos/cosmos-sdk/pull/13740) The `evidence_hash` field of `QueryEvidenceRequest` has been deprecated and now contains a new field `hash` with type `string`. -* (x/bank) [#11859](https://github.com/cosmos/cosmos-sdk/pull/11859) The Params.SendEnabled field is deprecated and unusable. - The information can now be accessed using the BankKeeper. - Setting can be done using MsgSetSendEnabled as a governance proposal. - A SendEnabled query has been added to both GRPC and CLI. ->>>>>>> 25449b581 (fix: remove duplicate ante events (#13983)) ## [v0.46.5](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.5) - 2022-11-17