-
Notifications
You must be signed in to change notification settings - Fork 411
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
Ensure proper events sent in reply #587
Comments
Good finding. The events on reply are indeed not as defined in the spec. The current flow is:
I agree to combining both types to make it easier. |
I agree. I had that thought as well, but no interface :( So, we could combine I'd be happy to write some tests here and implement it. (especially if you want to pick up confio/tgrade#85) |
I had started some work yesterday already to combine the events. Let me bring this to a stable state and I would be happy if you could add a reflect test to confirm it's done as defined in the spec |
In EVENTS.md we define not only the events emitted by the chain but the events that are passed into reply blocks.
Note: you can use the
reflect
contract to test this, it will just store what it gets in thereply
block into it's local storage to be queried later.This is follow up from #586 (comment)
In #586, we filter out all
message
type events after dispatching all submessages However, I would argue that we must filter them before returning the events to thereply
block, which is what is in the spec.Looking into the internals (and assuming the default implementation... all the interfaces make flow analysis a bit tricky), we wee how we already make a temporary event manager before dispatching the message.
When then only re-emit them if the event succeeds, which avoids errors from poluting the event stack. Interestingly, there seem to be two sources of events and I am unclear what goes where:
Which events are in
events
and which inem.Events()
. Can we dropem.Events()
?Later on we see that only the
events
are passed into the reply block on success.We should clear this up. I would propose the following:
events
andem.Events()
)message
type events to producefilteredEvents
.ctx.EventManager().EmitEvents(filteredEvents)
instead of these two callsfilteredEvents
to the reply callThis will ensure no messages make it to reply. There are never dups (between the two event sources) and it removes the need to filter later in Handle
The text was updated successfully, but these errors were encountered: