From 7e9fd7d5571453d7c11c8c6418c03d95cd39d28a Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Mon, 27 Nov 2023 11:35:59 +0100 Subject: [PATCH] fix: set upgrade timeout after `startFlushUpgradeHandshake` in `chanUpgradeAck` (#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 <45793271+sangier@users.noreply.github.com> --------- Co-authored-by: sangier <45793271+sangier@users.noreply.github.com> --- .../UPGRADES.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/spec/core/ics-004-channel-and-packet-semantics/UPGRADES.md b/spec/core/ics-004-channel-and-packet-semantics/UPGRADES.md index 1eb8bad1a..fecb87dbb 100644 --- a/spec/core/ics-004-channel-and-packet-semantics/UPGRADES.md +++ b/spec/core/ics-004-channel-and-packet-semantics/UPGRADES.md @@ -647,16 +647,16 @@ 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 } @@ -664,8 +664,12 @@ function chanUpgradeAck( 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 @@ -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) } ```