Skip to content

Commit

Permalink
fix: propagate msg events correctly in x/gov (backport #13728) (#13748)
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Nov 3, 2022
1 parent ba49bff commit e4ae994
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions x/gov/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()...)
}
}

Expand All @@ -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
Expand Down

0 comments on commit e4ae994

Please sign in to comment.