Skip to content

Commit

Permalink
fix: set upgrade timeout after startFlushUpgradeHandshake in `chanU…
Browse files Browse the repository at this point in the history
…pgradeAck` (#1040)

* fix: set upgrade timeout after start flush upgrade handshake in chan upgrade ack

* Update spec/core/ics-004-channel-and-packet-semantics/UPGRADES.md

Co-authored-by: sangier <[email protected]>

---------

Co-authored-by: sangier <[email protected]>
  • Loading branch information
crodriguezvega and sangier authored Nov 27, 2023
1 parent 2efdd82 commit 7e9fd7d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions spec/core/ics-004-channel-and-packet-semantics/UPGRADES.md
Original file line number Diff line number Diff line change
Expand Up @@ -647,25 +647,29 @@ function chanUpgradeAck(
)
)

upgrade = provableStore.get(channelUpgradePath(portIdentifier, channelIdentifier))
existingUpgrade = provableStore.get(channelUpgradePath(portIdentifier, channelIdentifier))

// optimistically accept version that TRY chain proposes and pass this to callback for confirmation.
// in the crossing hello case, we do not modify version that our TRY call returned and instead
// enforce that both TRY calls returned the same version
if (channel.state == OPEN) {
upgrade.fields.version == counterpartyUpgrade.fields.version
existingUpgrade.fields.version == counterpartyUpgrade.fields.version
}
// if upgrades are not compatible by ACK step, then we restore the channel
if (!isCompatibleUpgradeFields(upgrade.fields, counterpartyUpgrade.fields)) {
if (!isCompatibleUpgradeFields(existingUpgrade.fields, counterpartyUpgrade.fields)) {
restoreChannel(portIdentifier, channelIdentifier)
return
}

if (channel.state == OPEN) {
// prove counterparty and move our own state to flushing
// if we are already at flushing, then no state changes occur
// upgrade is blocked on this channelEnd from progressing until flush completes on both ends
// upgrade is blocked on this channelEnd from progressing until flush completes on its end
startFlushUpgradeHandshake(portIdentifier, channelIdentifier)
// startFlushUpgradeHandshake sets the timeout for the upgrade
// so retrieve upgrade again here and use that timeout value
upgrade = provableStore.get(channelUpgradePath(portIdentifier, channelIdentifier))
existingUpgrade.timeout = upgrade.timeout
}

timeout = counterpartyUpgrade.timeout
Expand Down Expand Up @@ -705,7 +709,7 @@ function chanUpgradeAck(
}

// if no error, agree on final version
provableStore.set(channelUpgradePath(portIdentifier, channelIdentifier), upgrade)
provableStore.set(channelUpgradePath(portIdentifier, channelIdentifier), existingUpgrade)
}
```

Expand Down

0 comments on commit 7e9fd7d

Please sign in to comment.