Skip to content

Commit

Permalink
fix fastforward logic for non-crossing-hello case, and add comments e…
Browse files Browse the repository at this point in the history
…xplaining
  • Loading branch information
AdityaSripal committed Dec 14, 2023
1 parent 3b6193e commit ffe75ca
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions spec/core/ics-004-channel-and-packet-semantics/UPGRADES.md
Original file line number Diff line number Diff line change
Expand Up @@ -517,16 +517,32 @@ function chanUpgradeTry(
)
)

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

// NON CROSSING HELLO CASE:
// if the counterparty sequence is less than the current sequence,
// 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
// so that the counterparty can abort their attempt and resync with our sequence.
// When the next upgrade attempt is initiated, both sides will move to a fresh
// never-before-seen sequence number
// CROSSING HELLO CASE:
// if the counterparty sequence is less than the current sequence,
// 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 {
if counterpartyUpgradeSequence < channel.upgradeSequence {
var errorUpgradeSequence: uint64
if existingUpgrade == null {
errorUpgradeSequence = channel.upgradeSequence
} else {
errorUpgraeSequence = channel.upgradeSequence - 1
}
errorReceipt = ErrorReceipt{
channel.upgradeSequence - 1,
errorUpgradeSequence,
"sequence out of sync", // constant string changeable by implementation
}
provableStore.set(channelUpgradeErrorPath(portIdentifier, channelIdentifier), errorReceipt)
Expand All @@ -541,7 +557,6 @@ function chanUpgradeTry(
version: counterpartyUpgrade.fields.version,
}

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

// current upgrade either doesn't exist (non-crossing hello case),
// we initialize the upgrade with constructed upgradeFields
Expand Down

0 comments on commit ffe75ca

Please sign in to comment.