Skip to content

Commit

Permalink
router fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sangier committed Oct 4, 2024
1 parent c0f261a commit d679315
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions spec/core/v2/ics-004-packet-semantics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ The protocol introduces standardized packet receipts that will serve as sentinel
```typescript
enum PacketReceipt {
SUCCESSFUL_RECEIPT = []byte{0x01},
TIMEOUT_RECEIPT = []byte{0x02},
SUCCESSFUL_RECEIPT = byte{0x01},
TIMEOUT_RECEIPT = byte{0x02},
}
```

Expand All @@ -141,7 +141,7 @@ E.g. If a packet within 3 payloads intended for 3 different application is sent
```typescript
type IBCRouter struct {
callbacks: portId -> [Callback]
clients: channelId -> Client // Needed? Maybe not anymore
// clients: channelId -> Client // Needed? Maybe not anymore
}
```

Expand Down Expand Up @@ -264,10 +264,14 @@ sequenceDiagram
Chain A ->> Relayer : clientId= X , channelId = Y
Relayer ->> Chain B : createClient(A chain) + createChannel
Chain B ->> Relayer : clientId= Z , channelId = W
Relayer ->> Chain A : registerChannel(channelId = W)
Relayer ->> Chain B : registerChannel(channelId = Y)
Relayer ->> Chain A : registerChannel(channelId = Y, counterpartyChannelId = W)
Relayer ->> Chain B : registerChannel(channelId = W, counterpartyChannelId = Y)
```

Once the set up is executed the system should be in a similar state:

![Setup Final State](setup_final_state.png)

While the application callbacks registration MUST be handled by the application module during initialization, and client creation is governed by [ICS-2](.ics-002-client-semantics/README.md), the channel creation and registration procedures are defined by ICS-04 and are detailed below.

##### Channel creation
Expand Down Expand Up @@ -314,6 +318,7 @@ Thus, IBC version 2 introduces a new message `registerChannel` that will store t

```typescript
function registerChannel(
channelId: bytes, // local chain channel identifier
counterpartyChannelId: bytes, // the counterparty's channel identifier
authentication: data, // implementation-specific authentication data
) {
Expand All @@ -324,7 +329,6 @@ function registerChannel(
assert(verify(authentication))

// Channel Checks
channelId=generateIdentifier()
abortTransactionUnless(validatedIdentifier(channelId))
channel=getChannel(channelId)
abortTransactionUnless(channel !== null)
Expand All @@ -336,10 +340,10 @@ function registerChannel(
channel.counterpartyChannelId=counterpartyChannelId

// Client registration on the router
router.clients[sourceChannelId]=channel.clientId
//router.clients[sourceChannelId]=channel.clientId // clients on router removed

// Local Store
privateStore.set(channelPath(counterpartyChannelId), channel)
privateStore.set(channelPath(channelId), channel)

}
```
Expand Down Expand Up @@ -485,11 +489,11 @@ function sendPacket(

// Setup checks - channel and client
channel = getChannel(sourceChannelId)
client = router.clients[sourceChannelId]
client = channel.clientId // removed client on router --> client = router.clients[sourceChannelId] // can it be client = channel.clientId
assert(client !== null)

// Evaluate usefulness of this check
assert(client.id === channel.clientId)
// assert(client.id === channel.clientId)

// timeoutTimestamp checks
// disallow packets with a zero timeoutTimestamp
Expand Down Expand Up @@ -600,10 +604,10 @@ function recvPacket(
relayer: string) {

// Channel and Client Checks
channel = getChannel(packet.destId)
client = router.clients[packet.destId]
channel = getChannel(packet.destId) // if I use packet.dest which is a channelId
client = channel.clientId // removed client on router --> client = router.clients[packet.destId] // client = channel.clientId
assert(client !== null)
assert(client.id === channel.clientId)
//assert(client.id === channel.clientId) // useful?

//assert(packet.sourceId == channel.counterpartyChannelId) Unnecessary?

Expand Down Expand Up @@ -765,10 +769,10 @@ function acknowledgePacket(

// Channel and Client Checks
channel = getChannel(packet.sourceId)
client = router.clients[packet.sourceId]
client = channel.clientId //client = router.clients[packet.sourceId]

assert(client !== null)
assert(client.id === channel.clientId)
//assert(client.id === channel.clientId)

//assert(packet.destId == channel.counterpartyChannelId)

Expand Down Expand Up @@ -879,10 +883,10 @@ function timeoutPacket(
) {
// Channel and Client Checks
channel = getChannel(packet.sourceId)
client = router.clients[packet.sourceId]
client = channel.clientId //client = router.clients[packet.sourceId]

assert(client !== null)
assert(client.id === channel.clientId)
// assert(client.id === channel.clientId)

//assert(packet.destId == channel.counterpartyChannelId)

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d679315

Please sign in to comment.