Skip to content

Commit

Permalink
Fix missing events in OnRecvPacket (cosmos#233)
Browse files Browse the repository at this point in the history
* fix to set events to the original context

* Update modules/core/keeper/msg_server.go

Co-authored-by: Aditya <[email protected]>
Co-authored-by: colin axnér <[email protected]>
  • Loading branch information
3 people committed Sep 3, 2021
1 parent 6582d8c commit 209e4c3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/core/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,10 @@ func (k Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPacke
// Cache context so that we may discard state changes from callback if the acknowledgement is unsuccessful.
cacheCtx, writeFn := ctx.CacheContext()
ack := cbs.OnRecvPacket(cacheCtx, msg.Packet, relayer)
// This doesn't cause duplicate events to be emitted.
// NOTE: The context returned by CacheContext() refers to a new EventManager, so it needs to explicitly set events to the original context.
// Events from callback are emitted regardless of acknowledgement success
ctx.EventManager().EmitEvents(cacheCtx.EventManager().Events())
if ack == nil || ack.Success() {
// write application state changes for asynchronous and successful acknowledgements
writeFn()
Expand Down

0 comments on commit 209e4c3

Please sign in to comment.