Skip to content

Commit 1433ee4

Browse files
committed
Add timeout timestamps to packets
1 parent 3286e09 commit 1433ee4

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

tests/difference/core/quint_model/ccv.qnt

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,21 @@ module ccv_types {
1717
id: VscId,
1818
// the new validator set. in the implementation, this would be a list of validator updates
1919
validatorSet: ValidatorSet,
20-
// the time at which the packet was sent. used to check whether packets have timed out.
21-
sendingTime: Time
20+
// the time at which the packet was sent.
21+
sendingTime: Time,
22+
// the time (on the receiver) at which the packet will time out
23+
timeoutTime: Time
24+
2225
}
2326

2427
type VscMaturedPacket =
2528
{
2629
// the id of the VscPacket that matured
2730
id: VscId,
28-
// the time at which the packet was sent. used to check whether packets have timed out.
29-
sendingTime: Time
31+
// the time at which the packet was sent.
32+
sendingTime: Time,
33+
// the time (on the receiver) at which the packet will time out
34+
timeoutTime: Time
3035
}
3136

3237

@@ -276,7 +281,7 @@ module ccv {
276281
(Err("No outstanding packets to deliver"), false)
277282
} else {
278283
val packet = currentState.consumerStates.get(sender).outstandingPacketsToProvider.head()
279-
if(packet.sendingTime + CcvTimeout.get(sender) < currentState.providerState.chainState.runningTimestamp) {
284+
if(packet.timeoutTime <= currentState.providerState.chainState.runningTimestamp) {
280285
// drop consumer
281286
val result = stopConsumers(
282287
currentState.providerState.consumerStatus,
@@ -325,7 +330,7 @@ module ccv {
325330
} else {
326331
val packet = currentState.providerState.outstandingPacketsToConsumer.get(receiver).head()
327332
// check if the consumer timed out
328-
if (packet.sendingTime + CcvTimeout.get(PROVIDER_CHAIN) < currentState.consumerStates.get(receiver).chainState.runningTimestamp) {
333+
if (packet.timeoutTime <= currentState.consumerStates.get(receiver).chainState.runningTimestamp) {
329334
// drop consumer
330335
val result = stopConsumers(
331336
currentState.providerState.consumerStatus,
@@ -492,7 +497,8 @@ module ccv {
492497
maturedPackets.transform(
493498
packet => {
494499
id: packet.id,
495-
sendingTime: newChainState.runningTimestamp
500+
sendingTime: newChainState.runningTimestamp,
501+
timeoutTime: newChainState.runningTimestamp + CcvTimeout.get(chain)
496502
}
497503
)
498504
)
@@ -632,7 +638,8 @@ module ccv {
632638
List({
633639
id: providerState.runningVscId,
634640
validatorSet: providerState.chainState.currentValidatorSet,
635-
sendingTime: providerState.chainState.runningTimestamp
641+
sendingTime: providerState.chainState.runningTimestamp,
642+
timeoutTime: providerState.chainState.runningTimestamp + CcvTimeout.get(PROVIDER_CHAIN)
636643
})
637644
} else {
638645
List()

tests/difference/core/quint_model/ccv_model.qnt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ module ccv_model {
230230
id: 0,
231231
validatorSet: Map(),
232232
sendingTime: 9999999999999 * Second,
233+
timeoutTime: 9999999999999 * Second,
233234
}
234235
packets.fold(
235236
latestPossiblePacket,
@@ -241,6 +242,7 @@ module ccv_model {
241242
id: 0,
242243
validatorSet: Map(),
243244
sendingTime: -9999999999 * Second,
245+
timeoutTime: -9999999999 * Second,
244246
}
245247
packets.fold(
246248
earliestPossiblePacket,
@@ -257,18 +259,21 @@ module ccv_model {
257259
id: 1,
258260
validatorSet: Map(),
259261
sendingTime: 1 * Second,
262+
timeoutTime: 1 * Second,
260263
}
261264

262265
val packet2 = {
263266
id: 2,
264267
validatorSet: Map(),
265268
sendingTime: 2 * Second,
269+
timeoutTime: 2 * Second,
266270
}
267271

268272
val packet3 = {
269273
id: 3,
270274
validatorSet: Map(),
271275
sendingTime: 3 * Second,
276+
timeoutTime: 3 * Second,
272277
}
273278
all {
274279
assert(earliest(Set(packet1, packet2, packet3)) == packet1),

0 commit comments

Comments
 (0)