@@ -55,32 +55,24 @@ TraceServer == TLCEval(FoldSeq(
5555 ELSE { x . event . nid } ,
5656 { } , TraceLog ) )
5757
58- BootstrapLogIndicesForServer ( i ) ==
59- LET
60- FirstBootstrapLogIndex == SelectInSeq ( TraceLog , LAMBDA x : x . event . nid = i /\ x . event . name \in { "InitState" , "BecomeFollower" , "ApplyConfChange" } )
61- FirstNonBootstrapLogIndex == SelectInSeq ( TraceLog , LAMBDA x : x . event . nid = i /\ x . event . name \notin { "InitState" , "BecomeFollower" , "ApplyConfChange" } )
62- LastBootstrapLogIndexUpperBound == IF FirstNonBootstrapLogIndex = 0 THEN Len ( TraceLog ) ELSE FirstNonBootstrapLogIndex - 1
63- IN
64- { k \in FirstBootstrapLogIndex .. LastBootstrapLogIndexUpperBound : TraceLog [ k ] . event . nid = i }
65-
66- BootstrapLogIndices == UNION { BootstrapLogIndicesForServer ( i ) : i \in Server }
67-
68- LastBootstrapLog == [ i \in Server |-> TraceLog [ Max ( BootstrapLogIndicesForServer ( i ) ) ] ]
69-
70- BootstrappedConfig ( i ) ==
71- IF LastBootstrapLog [ i ] . event . name = "ApplyConfChange" THEN
72- ToSet ( LastBootstrapLog [ i ] . event . prop . cc . newconf )
73- ELSE
74- ToSet ( LastBootstrapLog [ i ] . event . conf [ 1 ] )
75-
76- TraceInitServer == BootstrappedConfig ( TraceLog [ 1 ] . event . nid )
58+ BootstrapIndex == [ i \in Server |-> SelectInSeq ( TraceLog , LAMBDA x : x . event . nid = i /\ x . event . name = "Bootstrap" ) ]
59+ BootstrapEntries ( i ) == FoldSeq (
60+ LAMBDA x , y : Append ( y , [ term |-> 1 ,
61+ type |-> "ConfigEntry" ,
62+ value |-> [ newconf |-> ToSet ( TraceLog [ x ] . event . prop . cc . newconf ) , learners |-> { } ] ] ) ,
63+ << >> ,
64+ SetToSortSeq ( { j \in DOMAIN TraceLog : /\ j < BootstrapIndex [ i ]
65+ /\ TraceLog [ j ] . event . nid = i
66+ /\ TraceLog [ j ] . event . name = "ApplyConfChange" } , < ) )
67+
68+ TraceInitServer == { i \in Server : BootstrapIndex [ i ] > 0 }
7769ASSUME TraceInitServer \subseteq TraceServer
7870
79- TraceInitServerVars == /\ currentTerm = [ i \in Server |-> LastBootstrapLog [ i ] . event . state . term ]
80- /\ state = [ i \in Server |-> LastBootstrapLog [ i ] . event . role ]
81- /\ votedFor = [ i \in Server |-> LastBootstrapLog [ i ] . event . state . vote ]
82- TraceInitLogVars == /\ log = [ i \in Server |-> [ j \in 1 .. LastBootstrapLog [ i ] . event . log |-> [ term |-> 1 , type |-> "ConfigEntry" , value |-> [ newconf |-> BootstrappedConfig ( i ) , learners |-> { } ] ] ] ]
83- /\ commitIndex = [ i \in Server |-> LastBootstrapLog [ i ] . event . state . commit ]
71+ TraceInitServerVars == /\ currentTerm = [ i \in Server |-> IF i \in InitServer THEN 1 ELSE 0 ]
72+ /\ state = [ i \in Server |-> Follower ]
73+ /\ votedFor = [ i \in Server |-> Nil ]
74+ TraceInitLogVars == /\ log = [ i \in Server |-> BootstrapEntries ( i ) ]
75+ /\ commitIndex = [ i \in Server |-> Len ( log [ i ] ) ]
8476TraceInitConfigVars ==
8577 /\ config = [ i \in Server |-> [ jointConfig |-> << BootstrappedConfig ( i ) , { } >> , learners |-> { } ] ]
8678 /\ reconfigCount = 0
@@ -125,6 +117,8 @@ StepToNextTraceIfMessageIsProcessed(msg) ==
125117
126118-------------------------------------------------------------------------------------
127119
120+ LoglineIsBootStrap == l <= BootstrapIndex [ logline . event . nid ]
121+
128122LoglineIsEvent ( e ) ==
129123 /\ l <= Len ( TraceLog )
130124 /\ logline . event . name = e
@@ -436,12 +430,12 @@ TraceNextReceiveActions ==
436430 /\ StepToNextTraceIfMessageIsProcessed ( m )
437431
438432TraceNext ==
439- \/ /\ l \in BootstrapLogIndices
440- /\ UNCHANGED << vars >>
441- /\ StepToNextTrace
442- \/ /\ l \notin BootstrapLogIndices
443- /\ \/ TraceNextNonReceiveActions
444- \/ TraceNextReceiveActions
433+ IF LoglineIsBootStrap THEN
434+ /\ UNCHANGED << vars >>
435+ /\ StepToNextTrace
436+ ELSE
437+ \/ TraceNextNonReceiveActions
438+ \/ TraceNextReceiveActions
445439
446440TraceSpec ==
447441 TraceInit /\ [] [ TraceNext ]_ << l , pl , vars >>
0 commit comments