-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMC.tla
87 lines (64 loc) · 1.59 KB
/
MC.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
---- MODULE MC ----
\* @type: Set(SERVER);
Server == {
"sv1_OF_SERVER",
"sv2_OF_SERVER",
"sv3_OF_SERVER"
}
\* @type: Int;
MaxClientRequests == 8
\* @type: Int;
MaxLogLength == 8
\* @type: STATE;
Follower == "Follower_OF_STATE"
\* @type: STATE;
Candidate == "Candidate_OF_STATE"
\* @type: STATE;
Leader == "Leader_OF_STATE"
\* @type: MESSAGE_TYPE;
RequestVoteRequest == "RequestVoteRequest_OF_MESSAGE_TYPE"
\* @type: MESSAGE_TYPE;
RequestVoteResponse == "RequestVoteResponse_OF_MESSAGE_TYPE"
\* @type: MESSAGE_TYPE;
AppendEntriesRequest == "AppendEntriesRequest_OF_MESSAGE_TYPE"
\* @type: MESSAGE_TYPE;
AppendEntriesResponse == "AppendEntriesResponse_OF_MESSAGE_TYPE"
----
VARIABLES
\* @type: MESSAGE -> Int;
messages,
\* @type: Set(ELECTION);
elections
VARIABLES
\* @type: SERVER -> Int;
currentTerm,
\* @type: SERVER -> STATE;
state,
\* @type: SERVER -> Set(SERVER);
votedFor
VARIABLES
\* @type: SERVER -> Seq(LOG_ITEM);
log,
\* @type: SERVER -> Int;
commitIndex,
\* @type: Int;
valueRequestedByClient
VARIABLES
\* @type: SERVER -> Set(SERVER);
votesResponded,
\* @type: SERVER -> Set(SERVER);
votesGranted,
\* @type: SERVER -> SERVER -> Seq(LOG_ITEM);
voterLog
VARIABLES
\* @type: SERVER -> SERVER -> Int;
nextIndex,
\* @type: SERVER -> SERVER -> Int;
matchIndex
----
INSTANCE Raft
\* Invariant: Multiple leaders are not in a term.
\* @type: Bool;
ElectionSafety ==
\A i,j \in Server : i /= j /\ currentTerm[i] = currentTerm[j] => state[i] /= Leader \/ state[j] /= Leader
====