-
Notifications
You must be signed in to change notification settings - Fork 104
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
explicitly propagate events from cached contexts to original context in delaymsg endblocker #393
Conversation
…in delaymsg endblocker
}); err != nil { | ||
k.Logger(ctx).Error("failed to execute delayed message with id %v: %v", id, err) | ||
} | ||
} | ||
|
||
// Propagate events emitted in cached contexts to current context. | ||
ctx.EventManager().EmitEvents(events) |
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.
We should wrap this event emitting logic in RunCached
util, if possible. Does the axelar example util work?
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.
Can you double-check that such a change doesn't cause events to be emitted twice? I think the writeCache
method does emit events, so I'm wondering if the returned events for this transfer did not get added to the cachedCtx event manager, and that's why they were missing. In that case, handling this from RunCached may not be the solution.
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.
There were a lot of issues due to sdk message handler creating new EventManager. The emitted events could be picked up from the result like in: cosmos/cosmos-sdk#13389
or just propagate events like axelar did and @teddyding is suggesting.I believe Axelar as well had issues with losing events with their initial RunCached
implementation: axelarnetwork/axelar-core#1439.
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.
When I emit events in RunCached
like axelar example, they don't show up any more. The reason is that message handlers create a new event manager and thus the events aren't present in ctx.EventManager()
in this line (The cosmos issue that @dalmirel linked also mentioned the same issue)
I think for x/delaymsg
's use case, we have to emit events that are part of handler response
added a test case in second commit that fails without the fix! |
As a separate ticket, I think we should also add this line to our |
Context:
Couldn't find bank transfer events when a bridge is completed.
x/gov
explicitly propagates events from cached contexts (see here)Testing:
Ran localnet
end_block_events
in/block_results
responseend_block_events
in/block_results
responseexample: