Placeholder
To be refined better by @ethanfrey
Background
In IBC-go:
OnRecvPacket returns an Ack object that can either indicate success or failure of the operation. State is only persisted for the success case.
Returning nil would persist state but not store the Acknowledgment.
The forth case is panic which would not persist state nor store an Ack.
cacheCtx, writeFn = ctx.CacheContext()
ack := cbs.OnRecvPacket(cacheCtx, msg.Packet, relayer)
if ack == nil || ack.Success() {
// write application state changes for asynchronous and successful acknowledgements
writeFn()
} else {
// NOTE: The context returned by CacheContext() refers to a new EventManager, so it needs to explicitly set events to the original context.
// Events should still be emitted from failed acks and asynchronous acks
ctx.EventManager().EmitEvents(cacheCtx.EventManager().Events())
}
// Set packet acknowledgement only if the acknowledgement is not nil.
// NOTE: IBC applications modules may call the WriteAcknowledgement asynchronously if the
// acknowledgement is nil.
if ack != nil {
if err := k.ChannelKeeper.WriteAcknowledgement(ctx, cap, msg.Packet, ack); err != nil {
return nil, err
}
}
in modules/core/keeper/msg_server.go
Placeholder
To be refined better by @ethanfrey
Background
In IBC-go:
OnRecvPacketreturns an Ack object that can either indicate success or failure of the operation. State is only persisted for the success case.Returning
nilwould persist state but not store the Acknowledgment.The forth case is
panicwhich would not persist state nor store an Ack.in
modules/core/keeper/msg_server.go