From 5cc1816f5f871a6ed619ec8da3b86f5ce269eacb Mon Sep 17 00:00:00 2001 From: Jun Kimura Date: Tue, 6 Jul 2021 21:57:15 +0900 Subject: [PATCH] Fix missing events in OnRecvPacket (#233) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix to set events to the original context * Update modules/core/keeper/msg_server.go Co-authored-by: Aditya Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> --- modules/core/keeper/msg_server.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 3aeeffdb457..4fbbe18f581 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -500,6 +500,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()