@@ -62,9 +62,12 @@ fn proposer() {
6262 ) ) ;
6363
6464 // Receive two prevotes from other validators to reach prevote quorum.
65- let _ = shc. handle_vote ( & leader_fn, prevote ( Some ( BLOCK . id . 0 ) , 0 , 0 , * VALIDATOR_ID_1 ) ) . unwrap ( ) ;
66- let ret =
67- shc. handle_vote ( & leader_fn, prevote ( Some ( BLOCK . id . 0 ) , 0 , 0 , * VALIDATOR_ID_2 ) ) . unwrap ( ) ;
65+ let _ = shc
66+ . handle_vote ( & leader_fn, prevote ( Some ( BLOCK . id . 0 ) , BlockNumber ( 0 ) , 0 , * VALIDATOR_ID_1 ) )
67+ . unwrap ( ) ;
68+ let ret = shc
69+ . handle_vote ( & leader_fn, prevote ( Some ( BLOCK . id . 0 ) , BlockNumber ( 0 ) , 0 , * VALIDATOR_ID_2 ) )
70+ . unwrap ( ) ;
6871 // Expect a precommit broadcast request present.
6972 let mut reqs = match ret {
7073 ShcReturn :: Requests ( r) => r,
@@ -77,10 +80,12 @@ fn proposer() {
7780 ) ) ;
7881
7982 // Now provide precommit votes to reach decision.
80- let _ =
81- shc. handle_vote ( & leader_fn, precommit ( Some ( BLOCK . id . 0 ) , 0 , 0 , * VALIDATOR_ID_1 ) ) . unwrap ( ) ;
82- let decision =
83- shc. handle_vote ( & leader_fn, precommit ( Some ( BLOCK . id . 0 ) , 0 , 0 , * VALIDATOR_ID_2 ) ) . unwrap ( ) ;
83+ let _ = shc
84+ . handle_vote ( & leader_fn, precommit ( Some ( BLOCK . id . 0 ) , BlockNumber ( 0 ) , 0 , * VALIDATOR_ID_1 ) )
85+ . unwrap ( ) ;
86+ let decision = shc
87+ . handle_vote ( & leader_fn, precommit ( Some ( BLOCK . id . 0 ) , BlockNumber ( 0 ) , 0 , * VALIDATOR_ID_2 ) )
88+ . unwrap ( ) ;
8489 match decision {
8590 ShcReturn :: Decision ( d) => assert_eq ! ( d. block, BLOCK . id) ,
8691 _ => panic ! ( "expected decision" ) ,
@@ -135,9 +140,12 @@ fn validator(repeat_proposal: bool) {
135140 }
136141
137142 // Reach prevote quorum with two other validators.
138- let _ = shc. handle_vote ( & leader_fn, prevote ( Some ( BLOCK . id . 0 ) , 0 , 0 , * VALIDATOR_ID_2 ) ) . unwrap ( ) ;
139- let ret =
140- shc. handle_vote ( & leader_fn, prevote ( Some ( BLOCK . id . 0 ) , 0 , 0 , * VALIDATOR_ID_3 ) ) . unwrap ( ) ;
143+ let _ = shc
144+ . handle_vote ( & leader_fn, prevote ( Some ( BLOCK . id . 0 ) , BlockNumber ( 0 ) , 0 , * VALIDATOR_ID_2 ) )
145+ . unwrap ( ) ;
146+ let ret = shc
147+ . handle_vote ( & leader_fn, prevote ( Some ( BLOCK . id . 0 ) , BlockNumber ( 0 ) , 0 , * VALIDATOR_ID_3 ) )
148+ . unwrap ( ) ;
141149 // Expect a precommit broadcast request present.
142150 let mut reqs = match ret {
143151 ShcReturn :: Requests ( r) => r,
@@ -149,9 +157,12 @@ fn validator(repeat_proposal: bool) {
149157 ) ;
150158
151159 // Now provide precommit votes to reach decision.
152- let _ = shc. handle_vote ( & leader_fn, precommit ( Some ( BLOCK . id . 0 ) , 0 , 0 , * PROPOSER_ID ) ) . unwrap ( ) ;
153- let decision =
154- shc. handle_vote ( & leader_fn, precommit ( Some ( BLOCK . id . 0 ) , 0 , 0 , * VALIDATOR_ID_2 ) ) . unwrap ( ) ;
160+ let _ = shc
161+ . handle_vote ( & leader_fn, precommit ( Some ( BLOCK . id . 0 ) , BlockNumber ( 0 ) , 0 , * PROPOSER_ID ) )
162+ . unwrap ( ) ;
163+ let decision = shc
164+ . handle_vote ( & leader_fn, precommit ( Some ( BLOCK . id . 0 ) , BlockNumber ( 0 ) , 0 , * VALIDATOR_ID_2 ) )
165+ . unwrap ( ) ;
155166 match decision {
156167 ShcReturn :: Decision ( d) => assert_eq ! ( d. block, BLOCK . id) ,
157168 _ => panic ! ( "expected decision" ) ,
@@ -182,10 +193,9 @@ fn vote_twice(same_vote: bool) {
182193
183194 // Duplicate prevote should be ignored.
184195 let _ =
185- shc. handle_vote ( & leader_fn, prevote ( Some ( BLOCK . id . 0 ) , HEIGHT . 0 , 0 , * PROPOSER_ID ) ) . unwrap ( ) ;
186- let res = shc
187- . handle_vote ( & leader_fn, prevote ( Some ( BLOCK . id . 0 ) , HEIGHT . 0 , 0 , * VALIDATOR_ID_2 ) )
188- . unwrap ( ) ;
196+ shc. handle_vote ( & leader_fn, prevote ( Some ( BLOCK . id . 0 ) , HEIGHT , 0 , * PROPOSER_ID ) ) . unwrap ( ) ;
197+ let res =
198+ shc. handle_vote ( & leader_fn, prevote ( Some ( BLOCK . id . 0 ) , HEIGHT , 0 , * VALIDATOR_ID_2 ) ) . unwrap ( ) ;
189199 // On quorum of prevotes, expect a precommit broadcast request.
190200 let mut reqs = match res {
191201 ShcReturn :: Requests ( r) => r,
@@ -198,16 +208,16 @@ fn vote_twice(same_vote: bool) {
198208 ) ) ;
199209
200210 // Precommit handling towards decision.
201- let first_vote = precommit ( Some ( BLOCK . id . 0 ) , HEIGHT . 0 , 0 , * PROPOSER_ID ) ;
211+ let first_vote = precommit ( Some ( BLOCK . id . 0 ) , HEIGHT , 0 , * PROPOSER_ID ) ;
202212 let _ = shc. handle_vote ( & leader_fn, first_vote. clone ( ) ) . unwrap ( ) ;
203213 let second_vote = if same_vote {
204214 first_vote. clone ( )
205215 } else {
206- precommit ( Some ( Felt :: TWO ) , HEIGHT . 0 , 0 , * PROPOSER_ID )
216+ precommit ( Some ( Felt :: TWO ) , HEIGHT , 0 , * PROPOSER_ID )
207217 } ;
208218 let _ = shc. handle_vote ( & leader_fn, second_vote. clone ( ) ) . unwrap ( ) ;
209219 let decision =
210- shc. handle_vote ( & leader_fn, precommit ( Some ( BLOCK . id . 0 ) , HEIGHT . 0 , 0 , * VALIDATOR_ID_3 ) ) ;
220+ shc. handle_vote ( & leader_fn, precommit ( Some ( BLOCK . id . 0 ) , HEIGHT , 0 , * VALIDATOR_ID_3 ) ) ;
211221 match decision {
212222 Ok ( ShcReturn :: Decision ( d) ) => assert_eq ! ( d. block, BLOCK . id) ,
213223 _ => panic ! ( "Expected decision" ) ,
@@ -241,9 +251,12 @@ fn rebroadcast_votes() {
241251 ) ) ;
242252
243253 // Receive two prevotes from other validators to reach prevote quorum at round 0.
244- let _ = shc. handle_vote ( & leader_fn, prevote ( Some ( BLOCK . id . 0 ) , 0 , 0 , * VALIDATOR_ID_1 ) ) . unwrap ( ) ;
245- let ret =
246- shc. handle_vote ( & leader_fn, prevote ( Some ( BLOCK . id . 0 ) , 0 , 0 , * VALIDATOR_ID_2 ) ) . unwrap ( ) ;
254+ let _ = shc
255+ . handle_vote ( & leader_fn, prevote ( Some ( BLOCK . id . 0 ) , BlockNumber ( 0 ) , 0 , * VALIDATOR_ID_1 ) )
256+ . unwrap ( ) ;
257+ let ret = shc
258+ . handle_vote ( & leader_fn, prevote ( Some ( BLOCK . id . 0 ) , BlockNumber ( 0 ) , 0 , * VALIDATOR_ID_2 ) )
259+ . unwrap ( ) ;
247260 // Expect a precommit broadcast at round 0.
248261 let reqs = match ret {
249262 ShcReturn :: Requests ( r) => r,
@@ -256,8 +269,10 @@ fn rebroadcast_votes() {
256269
257270 // Advance with NIL precommits from peers (no decision) -> expect scheduling of precommit
258271 // timeout.
259- let _ = shc. handle_vote ( & leader_fn, precommit ( None , 0 , 0 , * VALIDATOR_ID_1 ) ) . unwrap ( ) ;
260- let _ = shc. handle_vote ( & leader_fn, precommit ( None , 0 , 0 , * VALIDATOR_ID_2 ) ) . unwrap ( ) ;
272+ let _ =
273+ shc. handle_vote ( & leader_fn, precommit ( None , BlockNumber ( 0 ) , 0 , * VALIDATOR_ID_1 ) ) . unwrap ( ) ;
274+ let _ =
275+ shc. handle_vote ( & leader_fn, precommit ( None , BlockNumber ( 0 ) , 0 , * VALIDATOR_ID_2 ) ) . unwrap ( ) ;
261276
262277 // Timeout at precommit(0) -> expect a prevote broadcast for round 1.
263278 let ret = shc. handle_event ( & leader_fn, StateMachineEvent :: TimeoutPrecommit ( 0 ) ) . unwrap ( ) ;
@@ -271,9 +286,12 @@ fn rebroadcast_votes() {
271286 ) ) ) ;
272287
273288 // Reach prevote quorum at round 1 with two other validators.
274- let _ = shc. handle_vote ( & leader_fn, prevote ( Some ( BLOCK . id . 0 ) , 0 , 1 , * VALIDATOR_ID_2 ) ) . unwrap ( ) ;
275- let ret =
276- shc. handle_vote ( & leader_fn, prevote ( Some ( BLOCK . id . 0 ) , 0 , 1 , * VALIDATOR_ID_3 ) ) . unwrap ( ) ;
289+ let _ = shc
290+ . handle_vote ( & leader_fn, prevote ( Some ( BLOCK . id . 0 ) , BlockNumber ( 0 ) , 1 , * VALIDATOR_ID_2 ) )
291+ . unwrap ( ) ;
292+ let ret = shc
293+ . handle_vote ( & leader_fn, prevote ( Some ( BLOCK . id . 0 ) , BlockNumber ( 0 ) , 1 , * VALIDATOR_ID_3 ) )
294+ . unwrap ( ) ;
277295 let reqs = match ret {
278296 ShcReturn :: Requests ( r) => r,
279297 _ => panic ! ( "expected requests" ) ,
@@ -286,15 +304,20 @@ fn rebroadcast_votes() {
286304 // Rebroadcast with older vote (round 0) - should be ignored (no broadcast, no task).
287305 let ret = shc. handle_event (
288306 & leader_fn,
289- StateMachineEvent :: VoteBroadcasted ( precommit ( Some ( BLOCK . id . 0 ) , 0 , 0 , * PROPOSER_ID ) ) ,
307+ StateMachineEvent :: VoteBroadcasted ( precommit (
308+ Some ( BLOCK . id . 0 ) ,
309+ BlockNumber ( 0 ) ,
310+ 0 ,
311+ * PROPOSER_ID ,
312+ ) ) ,
290313 ) ;
291314 match ret. unwrap ( ) {
292315 ShcReturn :: Requests ( r) => assert ! ( r. is_empty( ) ) ,
293316 _ => panic ! ( "expected requests" ) ,
294317 }
295318
296319 // Rebroadcast with current round (round 1) - should broadcast.
297- let rebroadcast_vote = precommit ( Some ( BLOCK . id . 0 ) , 0 , 1 , * PROPOSER_ID ) ;
320+ let rebroadcast_vote = precommit ( Some ( BLOCK . id . 0 ) , BlockNumber ( 0 ) , 1 , * PROPOSER_ID ) ;
298321 let ret = shc
299322 . handle_event ( & leader_fn, StateMachineEvent :: VoteBroadcasted ( rebroadcast_vote. clone ( ) ) )
300323 . unwrap ( ) ;
@@ -336,17 +359,19 @@ fn repropose() {
336359 _ => panic ! ( "expected requests" ) ,
337360 }
338361 // A single prevote from another validator does not yet cause quorum.
339- let ret =
340- shc. handle_vote ( & leader_fn, prevote ( Some ( BLOCK . id . 0 ) , 0 , 0 , * VALIDATOR_ID_1 ) ) . unwrap ( ) ;
362+ let ret = shc
363+ . handle_vote ( & leader_fn, prevote ( Some ( BLOCK . id . 0 ) , BlockNumber ( 0 ) , 0 , * VALIDATOR_ID_1 ) )
364+ . unwrap ( ) ;
341365 // No new requests are expected at this point.
342366 match ret {
343367 ShcReturn :: Requests ( reqs) => assert ! ( reqs. is_empty( ) ) ,
344368 _ => panic ! ( "expected requests" ) ,
345369 }
346370 // Reaching prevote quorum with a second external prevote; proposer will broadcast a precommit
347371 // and schedule a prevote timeout for round 0.
348- let ret =
349- shc. handle_vote ( & leader_fn, prevote ( Some ( BLOCK . id . 0 ) , 0 , 0 , * VALIDATOR_ID_2 ) ) . unwrap ( ) ;
372+ let ret = shc
373+ . handle_vote ( & leader_fn, prevote ( Some ( BLOCK . id . 0 ) , BlockNumber ( 0 ) , 0 , * VALIDATOR_ID_2 ) )
374+ . unwrap ( ) ;
350375 // Expect ScheduleTimeoutPrevote{round:0} and BroadcastVote(Precommit).
351376 match ret {
352377 ShcReturn :: Requests ( reqs) => {
@@ -362,8 +387,10 @@ fn repropose() {
362387 }
363388 // receiving Nil precommit requests and then decision on new round; just assert no panic and
364389 // decisions arrive after quorum.
365- let _ = shc. handle_vote ( & leader_fn, precommit ( None , 0 , 0 , * VALIDATOR_ID_1 ) ) . unwrap ( ) ;
366- let ret = shc. handle_vote ( & leader_fn, precommit ( None , 0 , 0 , * VALIDATOR_ID_2 ) ) . unwrap ( ) ;
390+ let _ =
391+ shc. handle_vote ( & leader_fn, precommit ( None , BlockNumber ( 0 ) , 0 , * VALIDATOR_ID_1 ) ) . unwrap ( ) ;
392+ let ret =
393+ shc. handle_vote ( & leader_fn, precommit ( None , BlockNumber ( 0 ) , 0 , * VALIDATOR_ID_2 ) ) . unwrap ( ) ;
367394 // assert that ret is ScheduleTimeoutPrecommit
368395 match ret {
369396 ShcReturn :: Requests ( reqs) => {
0 commit comments