cosmos / ibc-go

Inter-Blockchain Communication Protocol (IBC) implementation in Golang.
https://ibc.cosmos.network/
MIT License
553 stars 597 forks source link

Return result and acknowledgement from RelayPacket #2956

Closed migueldingli1997 closed 1 year ago

migueldingli1997 commented 1 year ago

Summary

Return result and acknowledgement from RelayPacket function for possibility of applying checks or further operations based on these values.

Problem Definition

I have found the RelayPacket function to be very useful for tests where the packet is parsed from events and then relayed. An example from this repository that served as inspiration is the following: https://github.com/cosmos/ibc-go/blob/c86d27fc280cfb342a9e4689b381e5823441b694/modules/apps/transfer/keeper/relay_test.go#L223-L230

As my code has gotten more complex I have found myself wanting to relay packets that were committed on the counterparty chain as a result of a packet relayed on the original chain. For example, an interchain accounts transaction with a MsgTransfer will create a packet on the counterparty chain during the ICA host's OnRecvPacket.

The way I see it, the easiest way to then relay this second packet would be to get a hold of the OnRecvPacket's events and look for the packet there. However the RelayPacket function currently discards the result containing the events.

So what I'm hoping for here is:

Proposal

From:

func (path *Path) RelayPacket(packet channeltypes.Packet) error

To:

func (path *Path) RelayPacket(packet channeltypes.Packet) (res *sdk.Result, ack []byte, err error)

For Admin Use

crodriguezvega commented 1 year ago

Hi @migueldingli1997. Sorry for the late reply...

We have discussed this issue and we have a proposal: we would like to keep RelayPacket as is, but instead add a new function (tentatively called RelayPacketWithResults), with the same functionality as RelayPacket, but that will return what you need (i.e (res *sdk.Result, ack []byte, err error)). That way the existing RelayPacket function doesn't need to change and usages of it can remain the same.

How does this sound? Would it work for you?

migueldingli1997 commented 1 year ago

That would work @crodriguezvega :)