Skip to content

Commit

Permalink
fix: propagate msg events correctly in x/gov (#13728)
Browse files Browse the repository at this point in the history
  • Loading branch information
damiannolan authored Nov 3, 2022
1 parent 61ed5d1 commit 9b8e1a1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/gov) [#13051](https://github.com/cosmos/cosmos-sdk/pull/13051) In SubmitPropsal, when a legacy msg fails it's handler call, wrap the error as ErrInvalidProposalContent (instead of ErrNoProposalHandlerExists).
* (x/gov) [#13045](https://github.com/cosmos/cosmos-sdk/pull/13045) Fix gov migrations for v3(0.46).
* (snapshot) [#13400](https://github.com/cosmos/cosmos-sdk/pull/13400) Fix snapshot checksum issue in golang 1.19.
* (x/gov) [#13728](https://github.com/cosmos/cosmos-sdk/pull/13728) Fix propagation of message events to the current context in `EndBlocker`.

### Deprecated

Expand Down
12 changes: 9 additions & 3 deletions x/gov/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,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 @@ -71,10 +72,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 @@ -87,6 +90,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 9b8e1a1

Please sign in to comment.