Skip to content

Commit

Permalink
ICS-3: Remove Crossing Hellos (#786)
Browse files Browse the repository at this point in the history
* always generate new identifier to remove crossing hellos logic

* update ack

* make sure ACK is in previous state INIT and version from counterparty is in the selected versions of INIT

* Update spec/core/ics-003-connection-semantics/README.md

Co-authored-by: Marius Poke <[email protected]>

Co-authored-by: Marius Poke <[email protected]>
  • Loading branch information
AdityaSripal and mpoke authored Jul 13, 2022
1 parent cfce8bc commit 58737aa
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions spec/core/ics-003-connection-semantics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ function connOpenInit(

```typescript
function connOpenTry(
previousIdentifier: Identifier,
counterpartyConnectionIdentifier: Identifier,
counterpartyPrefix: CommitmentPrefix,
counterpartyClientIdentifier: Identifier,
Expand All @@ -350,33 +349,23 @@ function connOpenTry(
proofConsensus: CommitmentProof,
proofHeight: Height,
consensusHeight: Height) {
if (previousIdentifier !== "") {
previous = provableStore.get(connectionPath(identifier))
abortTransactionUnless(
(previous !== null) &&
(previous.state === INIT &&
previous.counterpartyConnectionIdentifier === "" &&
previous.counterpartyPrefix === counterpartyPrefix &&
previous.clientIdentifier === clientIdentifier &&
previous.counterpartyClientIdentifier === counterpartyClientIdentifier &&
previous.delayPeriodTime === delayPeriodTime
previous.delayPeriodBlocks === delayPeriodBlocks))
identifier = previousIdentifier
} else {
// generate a new identifier if the passed identifier was the sentinel empty-string
identifier = generateIdentifier()
}
// generate a new identifier
identifier = generateIdentifier()

abortTransactionUnless(consensusHeight < getCurrentHeight())
expectedConsensusState = getConsensusState(consensusHeight)
expected = ConnectionEnd{INIT, "", getCommitmentPrefix(), counterpartyClientIdentifier,
clientIdentifier, counterpartyVersions, delayPeriodTime, delayPeriodBlocks}
versionsIntersection = intersection(counterpartyVersions, previous !== null ? previous.version : getCompatibleVersions())

versionsIntersection = intersection(counterpartyVersions, getCompatibleVersions())
version = pickVersion(versionsIntersection) // throws if there is no intersection

connection = ConnectionEnd{TRYOPEN, counterpartyConnectionIdentifier, counterpartyPrefix,
clientIdentifier, counterpartyClientIdentifier, version, delayPeriodTime, delayPeriodBlocks}
abortTransactionUnless(connection.verifyConnectionState(proofHeight, proofInit, counterpartyConnectionIdentifier, expected))
abortTransactionUnless(connection.verifyClientConsensusState(
proofHeight, proofConsensus, counterpartyClientIdentifier, consensusHeight, expectedConsensusState))

provableStore.set(connectionPath(identifier), connection)
addConnectionToClient(clientIdentifier, identifier)
}
Expand All @@ -395,9 +384,7 @@ function connOpenAck(
consensusHeight: Height) {
abortTransactionUnless(consensusHeight < getCurrentHeight())
connection = provableStore.get(connectionPath(identifier))
abortTransactionUnless(
(connection.state === INIT && connection.version.indexOf(version) !== -1)
|| (connection.state === TRYOPEN && connection.version === version))
abortTransactionUnless((connection.state === INIT && connection.version.indexOf(version) !== -1)
expectedConsensusState = getConsensusState(consensusHeight)
expected = ConnectionEnd{TRYOPEN, identifier, getCommitmentPrefix(),
connection.counterpartyClientIdentifier, connection.clientIdentifier,
Expand Down

0 comments on commit 58737aa

Please sign in to comment.