Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ics20 same ack handling as ibctransfer #653

Merged
merged 4 commits into from
Feb 9, 2022

Conversation

ethanfrey
Copy link
Member

Use the same handling as ibctransfer, where we update local balancer counter when sending, rather than wait for a success ack.

This works for the cases where relayer are slow to relay success acks (or never do it). It also allows a much more reliable and quicker round trip of send, return without waiting for the acks to be relayed even in the normal case.

Same behavior as ibctransfer, I don't need to be more conservative than that.

Copy link
Contributor

@maurolacy maurolacy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving on your behalf, as I don't know enough about IBC yet for doing a proper review here.

Left a couple of comments with my main concerns. My take is that, if there's no mechanism for retries / messages confirmation, there can be problems.

@@ -338,6 +336,9 @@ fn on_packet_failure(
) -> Result<IbcBasicResponse, ContractError> {
let msg: Ics20Packet = from_binary(&packet.data)?;

// undo the balance update
reduce_channel_balance(deps.storage, &packet.src.channel_id, &msg.denom, msg.amount)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My concern would be: What if, for whatever reason, the packet failure message never arrives?

Not sure if this can be abused, as the successful deposit on the other side is the one crediting the funds. But still, if the packet failure never arrives, the balance would be left in an inconsistent state, resulting in lost funds.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should eventually arrive. If nothing out via "timeout".

If this never gets relayed, the senders tokens remained locked in the contract. Once the timeout arrives, they are paid back.

contracts/cw20-ics20/src/ibc.rs Show resolved Hide resolved
@ethanfrey ethanfrey force-pushed the ics20-same-ack-handling-as-ibctransfer branch from 74ee47c to 2ea606b Compare February 9, 2022 11:38
@ethanfrey ethanfrey merged commit e299f59 into main Feb 9, 2022
@ethanfrey ethanfrey deleted the ics20-same-ack-handling-as-ibctransfer branch February 9, 2022 11:49
@@ -32,15 +32,20 @@ pub struct Ics20Packet {
pub receiver: String,
/// the sender address
pub sender: String,
/// used only by us to control ack handling
pub v: Option<u32>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created an issue about this #662

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I found this and had to revert it.
Turns out ibctransfer packet uses a super-strict JSON parser that fails on any unknown fields.
It seems to me that this is undesired behavior, but that is another discussion.

I need a different format and migration step to do a new release of this, very correct. I was out for a while.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants