-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: propagate msg events correctly in x/gov #13728
Changes from all commits
35574f7
2864918
61d4437
bc53828
01aac4f
cb612e5
e108e62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A defensive What if I tried to exec an osmosis
|
||
_, err = handler(cacheCtx, msg) | ||
res, err := handler(cacheCtx, msg) | ||
if err != nil { | ||
break | ||
} | ||
|
||
events = append(events, res.GetEvents()...) | ||
} | ||
} | ||
|
||
|
@@ -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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to declare
idx
andmsg
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like all they're used for is building a log msg below in the case of failure:
logMsg = fmt.Sprintf("passed, but msg %d (%s) failed on execution: %s", idx, sdk.MsgTypeURL(msg), err)
If they weren't declared they would only be available inside the scope of the
for
.