You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ICS4: Add ORDERED_ALLOW_TIMEOUT channel type (#636)
* add ORDERED_ALLOW_TIMEOUT channel type
* increment next sequence recv on timeout on ordered allow timeout channel
* fix issue with incrementing next sequence recv
* fix switch statements
* fix conditional bug
* return on receiving timed out packet
* address most of reviews
* final fixes
* address small issues
Copy file name to clipboardexpand all lines: spec/core/ics-004-channel-and-packet-semantics/README.md
+130-54
Original file line number
Diff line number
Diff line change
@@ -44,14 +44,17 @@ A *bidirectional* channel is a channel where packets can flow in both directions
44
44
45
45
A *unidirectional* channel is a channel where packets can only flow in one direction: from `A` to `B` (or from `B` to `A`, the order of naming is arbitrary).
46
46
47
-
An *ordered* channel is a channel where packets are delivered exactly in the order which they were sent.
47
+
An *ordered* channel is a channel where packets are delivered exactly in the order which they were sent. This channel type offers a very strict guarantee of ordering. Either, the packets are received in the order they were sent, or if a packet in the sequence times out; then all future packets are also not receivable and the channel closes.
48
+
49
+
An *ordered_allow_timeout* channel is a less strict version of the *ordered* channel. Here, the channel logic will take a *best effort* approach to delivering the packets in order. In a stream of packets, the channel will relay all packets in order and if a packet in the stream times out, the timeout logic for that packet will execute and the rest of the later packets will continue processing in order. Thus, we **do not close** the channel on a timeout with this channel type.
48
50
49
51
An *unordered* channel is a channel where packets can be delivered in any order, which may differ from the order in which they were sent.
50
52
51
53
```typescript
52
54
enumChannelOrder {
53
55
ORDERED,
54
56
UNORDERED,
57
+
ORDERED_ALLOW_TIMEOUT,
55
58
}
56
59
```
57
60
@@ -75,7 +78,7 @@ interface ChannelEnd {
75
78
```
76
79
77
80
- The `state` is the current state of the channel end.
78
-
- The `ordering` field indicates whether the channel is ordered or unordered.
81
+
- The `ordering` field indicates whether the channel is `unordered`, `ordered`, or `ordered_allow_timeout`.
79
82
- The `counterpartyPortIdentifier` identifies the port on the counterparty chain which owns the other end of the channel.
80
83
- The `counterpartyChannelIdentifier` identifies the channel end on the counterparty chain.
81
84
- The `nextSequenceSend`, stored separately, tracks the sequence number for the next packet to be sent.
@@ -132,6 +135,15 @@ An `OpaquePacket` is a packet, but cloaked in an obscuring data type by the host
132
135
typeOpaquePacket=object
133
136
```
134
137
138
+
In order to enable new channel types (e.g. ORDERED_ALLOW_TIMEOUT), the protocol introduces standardized packet receipts that will serve as sentinel values for the receiving chain to expliclity write to its store the outcome of a `recvPacket`.
139
+
140
+
```typescript
141
+
enumPacketReceipt {
142
+
SUCCESSFUL_RECEIPT,
143
+
TIMEOUT_RECEIPT,
144
+
}
145
+
```
146
+
135
147
### Desired Properties
136
148
137
149
#### Efficiency
@@ -147,8 +159,9 @@ type OpaquePacket = object
147
159
148
160
#### Ordering
149
161
150
-
- On ordered channels, packets should be sent and received in the same order: if packet *x* is sent before packet *y* by a channel end on chain `A`, packet *x* must be received before packet *y* by the corresponding channel end on chain `B`.
151
-
- On unordered channels, packets may be sent and received in any order. Unordered packets, like ordered packets, have individual timeouts specified in terms of the destination chain's height.
162
+
- On *ordered* channels, packets should be sent and received in the same order: if packet *x* is sent before packet *y* by a channel end on chain `A`, packet *x* must be received before packet *y* by the corresponding channel end on chain `B`. If packet *x* is sent before packet *y* by a channel and packet *x* is timed out; then packet *y* and any packet sent after *x* cannot be received.
163
+
- On *ordered_allow_timeout* channels, packets should be sent and received in the same order: if packet *x* is sent before packet *y* by a channel end on chain `A`, packet *x* must be received **or** timed out before packet *y* by the corresponding channel end on chain `B`.
164
+
- On *unordered* channels, packets may be sent and received in any order. Unordered packets, like ordered packets, have individual timeouts specified in terms of the destination chain's height.
152
165
153
166
#### Permissioning
154
167
@@ -209,7 +222,8 @@ function packetCommitmentPath(portIdentifier: Identifier, channelIdentifier: Ide
209
222
210
223
Absence of the path in the store is equivalent to a zero-bit.
211
224
212
-
Packet receipt data are stored under the `packetReceiptPath`
225
+
Packet receipt data are stored under the `packetReceiptPath`. In the case of a successful receive, the destination chain writes a sentinel success value of `SUCCESSFUL_RECEIPT`.
226
+
Some channel types MAY write a sentinel timeout value `TIMEOUT_RECEIPT` if the packet is received after the specified timeout.
213
227
214
228
```typescript
215
229
function packetReceiptPath(portIdentifier:Identifier, channelIdentifier:Identifier, sequence:uint64):Path {
@@ -577,11 +591,11 @@ The IBC handler performs the following steps in order:
577
591
- Checks that the channel & connection are open to receive packets
578
592
- Checks that the calling module owns the receiving port
579
593
- Checks that the packet metadata matches the channel & connection information
580
-
- Checks that the packet sequence is the next sequence the channel end expects to receive (for ordered channels)
581
-
- Checks that the timeout height has not yet passed
594
+
- Checks that the packet sequence is the next sequence the channel end expects to receive (for ordered and ordered_allow_timeout channels)
595
+
- Checks that the timeout height and timestamp have not yet passed
582
596
- Checks the inclusion proof of packet data commitment in the outgoing chain's state
583
597
- Sets a store path to indicate that the packet has been received (unordered channels only)
584
-
- Increments the packet receive sequence associated with the channel end (ordered channels only)
598
+
- Increments the packet receive sequence associated with the channel end (ordered and ordered_allow_timeout channels only)
585
599
586
600
We pass the address of the `relayer` that signed and submitted the packet to enable a module to optionally provide some rewards. This provides a foundation for fee payment, but can be used for other techniques as well (like calculating a leaderboard).
0 commit comments