From 55a34e95ee5c6f175391843cf759e964625a2a72 Mon Sep 17 00:00:00 2001 From: Aditya Sripal Date: Wed, 29 Nov 2023 13:30:43 +0100 Subject: [PATCH] add explanation and optimization --- spec/core/ics-004-channel-and-packet-semantics/UPGRADES.md | 7 +++++++ 1 file changed, 7 insertions(+) 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 8e6d1776d..9f2dca673 100644 --- a/spec/core/ics-004-channel-and-packet-semantics/UPGRADES.md +++ b/spec/core/ics-004-channel-and-packet-semantics/UPGRADES.md @@ -571,6 +571,9 @@ function chanUpgradeTry( // then either the counterparty chain is out-of-sync or the message // is out-of-sync and we write an error receipt with our sequence - 1 // so that the counterparty can update their sequence as well. + // This will cause the outdated counterparty to upgrade the sequence + // and abort their out-of-sync upgrade without aborting our own since + // the error receipt sequence is lower than ours and higher than the counterparty. if counterpartyUpgradeSequence < channel.upgradeSequence { errorReceipt = ErrorReceipt{ channel.upgradeSequence - 1, @@ -906,6 +909,10 @@ function cancelChannelUpgrade( // If counterparty sequence is less than the current sequence, // abort transaction since this error receipt is from a previous upgrade abortTransactionUnless(errorReceipt.sequence >= channel.upgradeSequence) + // fastforward channel sequence to higher sequence so that we can start + // new handshake on a fresh sequence + channel.upgradeSequence = errorReceipt.sequence + provableStore.set(channelPath(portIdentifier, channelIdentifier), channel) // get underlying connection for proof verification connection = provableStore.get(connectionPath(channel.connectionHops[0]))