ibc-rs icon indicating copy to clipboard operation
ibc-rs copied to clipboard

[Transfer App] Refine return type of `process_recv_packet_execute`

Open Farhad-Shabani opened this issue 1 year ago • 5 comments

Problem Statement

The current implementation of the process_recv_packet_execute in the relay module returns a Result<ModuleExtras, (ModuleExtras, TokenTransferError)> type which is not conventional and may cause confusion to future maintainers.

Proposal

It is suggested to update the implementation to return Result<ModuleExtras, TokenTransferError> directly, where TokenTransferError contains all the necessary error information. If ModuleExtras is needed to handle the error case, it can be returned as part of the error variant.

Farhad-Shabani avatar Mar 08 '23 14:03 Farhad-Shabani

The problem with this suggested signature is that all error variants of TokenTransferError would need to have the logs in them, since we always want the logs, no matter the error that occurred. And at the call site, you need to match on every error one way or another to get those logs out.

plafer avatar Mar 08 '23 15:03 plafer

all error variants of TokenTransferError would need to have the logs in them

IIUC, I don't think we need to do so. There is just needed to add one specific variant for this case (say, TokenTransferError::CannotMintCoins { extras }). Did you look into the implementation in #504?

Farhad-Shabani avatar Mar 08 '23 17:03 Farhad-Shabani

But then you're implicitly saying that CannotMintCoins is the only viable variant to return, since all other variants will be throwing logs away.

plafer avatar Mar 08 '23 18:03 plafer

Following our discussion, we have reached the conclusion that this type is the most logical output type considering the existing design and the interactions with our error, event, and logging handling mechanisms. However, with your permission @palfer, I would like to keep this issue open as we refine our designs, perhaps we find a way to address it. I noticed the way we gather events and logs differs from the IBC-go side. Perhaps exploring this disparity may assist us in resolving this issue as well.

Farhad-Shabani avatar Mar 10 '23 19:03 Farhad-Shabani

yes I'm okay with keeping this issue open as the signature of process_recv_packet_execute indeed is not idiomatic.

plafer avatar Mar 10 '23 20:03 plafer