-
Notifications
You must be signed in to change notification settings - Fork 200
/
Finitize_ReplicatedLog.tla
59 lines (42 loc) · 1.26 KB
/
Finitize_ReplicatedLog.tla
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---------------------- MODULE Finitize_ReplicatedLog ------------------------
EXTENDS Naturals, Sequences
CONSTANTS Node, Transaction, Divergence
VARIABLES log, executed, converge
vars == <<log, executed, converge>>
S == INSTANCE ReplicatedLog
TypeOK ==
/\ log \in Seq(Transaction)
/\ Len(log) <= Divergence
/\ executed \in [Node -> 0 .. Divergence]
Liveness == converge ~> S!Convergence
Init ==
/\ S!Init
/\ converge = FALSE
WriteTx(n, tx) ==
/\ ~converge
/\ Len(log) < Divergence
/\ S!WriteTx(n, tx)
/\ UNCHANGED converge
ExecuteTx(n) ==
/\ S!ExecuteTx(n)
/\ UNCHANGED converge
GarbageCollect ==
LET SetMin(s) == CHOOSE e \in s : \A o \in s : e <= o IN
LET MinExecuted == SetMin({executed[o] : o \in Node}) IN
/\ log' = [i \in 1 .. Len(log) - MinExecuted |-> log[i + MinExecuted]]
/\ executed' = [n \in Node |-> executed[n] - MinExecuted]
/\ UNCHANGED converge
Converge ==
/\ converge' = TRUE
/\ UNCHANGED <<log, executed>>
Fairness == \A n \in Node : WF_vars(ExecuteTx(n))
Next ==
\/ \E n \in Node : \E tx \in Transaction : WriteTx(n, tx)
\/ \E n \in Node : ExecuteTx(n)
\/ GarbageCollect
\/ Converge
Spec ==
/\ Init
/\ [][Next]_vars
/\ Fairness
=============================================================================