Skip to content

Commit

Permalink
Unify MaxCrashQuorum and MaxByzQuorum into MaxQuorum.
Browse files Browse the repository at this point in the history
Signed-off-by: Markus Alexander Kuppe <[email protected]>
  • Loading branch information
lemmy committed Dec 2, 2024
1 parent 2c9bf47 commit af74e7f
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions pirateship.tla
Original file line number Diff line number Diff line change
Expand Up @@ -184,19 +184,11 @@ HighestQCOverQC(l) ==
Max2(a,b) == IF a > b THEN a ELSE b
Min2(a,b) == IF a < b THEN a ELSE b

MaxCrashQuorum(l, m, default) ==
MaxQuorum(Q, l, m, default) ==
LET RECURSIVE RMaxQuorum(_)
RMaxQuorum(i) ==
IF i = default THEN default
ELSE IF \E q \in CQ: \A n \in q: m[n] >= i
THEN i ELSE RMaxQuorum(i-1)
IN RMaxQuorum(Len(l))

MaxByzQuorum(l, m, default) ==
LET RECURSIVE RMaxQuorum(_)
RMaxQuorum(i) ==
IF i = default THEN default
ELSE IF \E q \in BQ: \A n \in q: m[n] >= i
ELSE IF \E q \in Q: \A n \in q: m[n] >= i
THEN i ELSE RMaxQuorum(i-1)
IN RMaxQuorum(Len(l))

Expand Down Expand Up @@ -308,7 +300,7 @@ ReceiveVote(p, r) ==
/\ network' = [network EXCEPT ![p][r] = Tail(network[p][r])]
/\ crashCommitIndex' =
[crashCommitIndex EXCEPT ![p] =
MaxCrashQuorum(log[p], prepareQC'[p], @)]
MaxQuorum(CQ, log[p], prepareQC'[p], @)]
/\ UNCHANGED <<view, log, primary, byzCommitIndex, byzActions>>

MaxCrashQC(l,p) ==
Expand All @@ -317,8 +309,8 @@ MaxCrashQC(l,p) ==
ELSE {}

MaxByzQC(l, m) ==
IF MaxByzQuorum(l, m, 0) > HighestByzQC(l)
THEN {MaxByzQuorum(l, m, 0)}
IF MaxQuorum(BQ, l, m, 0) > HighestByzQC(l)
THEN {MaxQuorum(BQ, l, m, 0)}
ELSE {}

\* Primary p sends AppendEntries to all replicas
Expand Down

0 comments on commit af74e7f

Please sign in to comment.