From e4ae994c710404ce41a52aa977442a754f5f9bf5 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 3 Nov 2022 17:31:55 -0400 Subject: [PATCH] fix: propagate msg events correctly in x/gov (backport #13728) (#13748) --- CHANGELOG.md | 4 ++++ x/gov/abci.go | 12 +++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1e425615a3a..e803b9515539 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +### Bug Fixes + +* (x/gov) [#13728](https://github.com/cosmos/cosmos-sdk/pull/13728) Fix propagation of message events to the current context in `EndBlocker`. + ## [v0.46.4](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.4) - 2022-11-01 ### Features diff --git a/x/gov/abci.go b/x/gov/abci.go index cde12c34a80c..21aca44ed08a 100644 --- a/x/gov/abci.go +++ b/x/gov/abci.go @@ -57,8 +57,9 @@ func EndBlocker(ctx sdk.Context, keeper keeper.Keeper) { if passes { var ( - idx int - msg sdk.Msg + idx int + events sdk.Events + msg sdk.Msg ) // attempt to execute all messages within the passed proposal @@ -70,10 +71,12 @@ func EndBlocker(ctx sdk.Context, keeper keeper.Keeper) { if err == nil { for idx, msg = range messages { handler := keeper.Router().Handler(msg) - _, err = handler(cacheCtx, msg) + res, err := handler(cacheCtx, msg) if err != nil { break } + + events = append(events, res.GetEvents()...) } } @@ -86,6 +89,9 @@ func EndBlocker(ctx sdk.Context, keeper keeper.Keeper) { // write state to the underlying multi-store writeCache() + + // propagate the msg events to the current context + ctx.EventManager().EmitEvents(events) } else { proposal.Status = v1.StatusFailed tagValue = types.AttributeValueProposalFailed