cosmos / ibc

Interchain Standards (ICS) for the Cosmos network & interchain ecosystem.
Other
908 stars 386 forks source link

ICS20v2 path forwarding: simplify revert in-flight changes #1110

Closed crodriguezvega closed 1 month ago

crodriguezvega commented 1 month ago

Following up on the discussion from the walkthrough, it does seem like we can simplify the logic of revertInflightChanges (I actually had also hinted that to Aditya when I first reviewed the spec...)

To make it easier for everyone to reason about this (although please double check that I haven't made any mistake), the following outlines what happens with the escrow accounts and forwarding account assuming that there is a timeout or error ack and changes on the middle hop need to be reverted. The receivedPacket is the received packet on the middle hop and the sentPacket is the packet sent from the middle hop as a result of forwarding.

Scenario 1 (source when receiving, source when sending)

Scenario 2 (source when receiving, not source when sending)

Scenario 3 (not source when receiving, source when sending)

Scenario 4 (not source when receiving, not source when sending)