Skip to content

Commit 711d4ad

Browse files
authored
docs: update IBC v2 spec (#1210)
* docs: fix incomplete sentence * fix: counterparties use client IDs
1 parent 7a5a748 commit 711d4ad

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

spec/eureka/README.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function updateClient(
5757
header: bytes,
5858
): error
5959

60-
// once a client has been created, relayers can submit misbehaviour that proves the counterparty chain
60+
// once a client has been created, relayers can submit misbehaviour that proves the counterparty chain violated the trust model.
6161
// The light client must verify the misbehaviour using the trust model of the consensus mechanism
6262
// and execute some custom logic such as freezing the client from accepting future updates and proof verification.
6363
function submitMisbehaviour(
@@ -107,25 +107,25 @@ interface Counterparty {
107107
}
108108
109109
function ProvideCounterparty(
110-
channelIdentifier: Identifier, // this will be our own client identifier representing our channel to desired chain
111-
counterpartyChannelIdentifier: Identifier, // this is the counterparty's identifier of our chain
110+
clientIdentifier: Identifier, // this will be our own client identifier representing our channel to desired chain
111+
counterpartyClientIdentifier: Identifier, // this is the counterparty's identifier of our chain
112112
counterpartyKeyPrefix: CommitmentPrefix,
113113
authentication: data, // implementation-specific authentication data
114114
) {
115115
assert(verify(authentication))
116116
117117
counterparty = Counterparty{
118-
channelId: counterpartyChannelIdentifier,
118+
clientId: counterpartyClientIdentifier,
119119
keyPrefix: counterpartyKeyPrefix
120120
}
121121
122122
privateStore.set(counterpartyPath(channelIdentifier), counterparty)
123123
}
124124
125125
// getCounterparty retrieves the stored counterparty identifier
126-
// given the channelIdentifier on our chain once it is provided
127-
function getCounterparty(channelIdentifier: Identifier): Counterparty {
128-
return privateStore.get(counterpartyPath(channelIdentifier))
126+
// given the clientIdentifier on our chain once it is provided
127+
function getCounterparty(clientIdentifier: Identifier): Counterparty {
128+
return privateStore.get(counterpartyPath(clientIdentifier))
129129
}
130130
```
131131

@@ -192,7 +192,7 @@ function sendPacket(
192192
193193
// if the sequence doesn't already exist, this call initializes the sequence to 0
194194
sequence = channelStore.get(nextSequenceSendPath(sourcePort, sourceChannel))
195-
195+
196196
// store commitment to the packet data & packet timeout
197197
channelStore.set(
198198
packetCommitmentPath(sourcePort, sourceChannel, sequence),
@@ -245,7 +245,7 @@ function recvPacket(
245245
assert(packet.timeoutHeight === 0 || getConsensusHeight() < packet.timeoutHeight)
246246
assert(packet.timeoutTimestamp === 0 || currentTimestamp() < packet.timeoutTimestamp)
247247
248-
248+
249249
// we must set the receipt so it can be verified on the other side
250250
// this receipt does not contain any data, since the packet has not yet been processed
251251
// it's the sentinel success receipt: []byte{0x01}
@@ -274,7 +274,7 @@ function recvPacket(
274274
cbs = router.callbacks[packet.destPort]
275275
// IMPORTANT: if the ack is error, then the callback reverts its internal state changes, but the entire tx continues
276276
ack = cbs.OnRecvPacket(packet, relayer)
277-
277+
278278
if ack != nil {
279279
channelStore.set(packetAcknowledgementPath(packet.destPort, packet.destChannel, packet.sequence), ack)
280280
}
@@ -294,7 +294,7 @@ function acknowledgePacket(
294294
// assert dest channel is sourceChannel's counterparty channel identifier
295295
counterparty = getCounterparty(packet.destChannel)
296296
assert(packet.sourceChannel == counterparty.channelId)
297-
297+
298298
// assert dest port is sourcePort's counterparty port identifier
299299
assert(packet.destPort == ports[packet.sourcePort])
300300
@@ -331,7 +331,7 @@ function timeoutPacket(
331331
// assert dest channel is sourceChannel's counterparty channel identifier
332332
counterparty = getCounterparty(packet.destChannel)
333333
assert(packet.sourceChannel == counterparty.channelId)
334-
334+
335335
// assert dest port is sourcePort's counterparty port identifier
336336
assert(packet.destPort == ports[packet.sourcePort])
337337
@@ -381,12 +381,12 @@ Similarly, for packet flow messages sent to the sender (AcknowledgePacket, Timeo
381381

382382
Claim: If the clients are setup correctly, then a chain cannot mistake a packet flow message intended for a different chain as a valid message from a valid counterparty.
383383

384-
We must note that client identifiers are unique to each chain but are not globally unique. Let us first consider a user that correctly specifies the source and destination identifiers in the packet.
384+
We must note that client identifiers are unique to each chain but are not globally unique. Let us first consider a user that correctly specifies the source and destination identifiers in the packet.
385385

386386
We wish to ensure that well-formed packets (i.e. packets with correctly setup client ids) cannot have packet flow messages succeed on third-party chains. Ill-formed packets (i.e. packets with invalid client ids) may in some cases complete in invalid states; however we must ensure that any completed state from these packets cannot mix with the state of other valid packets.
387387

388388
We are guaranteed that the source identifier is unique on the source chain, the destination identifier is unique on the destination chain. Additionally, the destination identifier points to a valid client of the source chain, and the source identifier points to a valid client of the destination chain.
389389

390-
Suppose the RecvPacket is sent to a chain other than the one identified by the sourceClient on the source chain.
390+
Suppose the RecvPacket is sent to a chain other than the one identified by the sourceClient on the source chain.
391391

392392
In the packet flow messages sent to the receiver (RecvPacket), the packet send is verified using the client on the destination chain (retrieved using destination identifier) with the packet commitment path derived by the source identifier. This verification check can only pass if the chain identified by the destination client committed the packet we received under the source channel identifier. This is only possible if the destination client is pointing to the original source chain, or if it is pointing to a different chain that committed the exact same packet. Pointing to the original source chain would mean we sent the packet to the correct . Since the sender only sends packets intended for the destination chain by setting to a unique source identifier, we can be sure the packet was indeed intended for us. Since our client on the receiver is also correctly pointing to the sender chain, we are verifying the proof against a specific consensus algorithm that we assume to be honest. If the packet is committed to the wrong key path, then we will not accept the packet. Similarly, if the packet is committed by the wrong chain then we will not be able to verify correctly.

0 commit comments

Comments
 (0)