66 commitment:: { alpenglow_update_commitment_cache, AlpenglowCommitmentType } ,
77 event:: { CompletedBlock , VotorEvent , VotorEventReceiver } ,
88 root_utils:: { self , RootContext } ,
9- skip_timer :: SkipTimerManager ,
9+ timer_manager :: TimerManager ,
1010 vote_history:: { VoteHistory , VoteHistoryError } ,
1111 voting_utils:: { self , BLSOp , VoteError , VotingContext } ,
1212 votor:: { SharedContext , Votor } ,
1313 } ,
1414 crossbeam_channel:: { select, RecvError , SendError } ,
15+ parking_lot:: RwLock ,
1516 solana_clock:: Slot ,
1617 solana_hash:: Hash ,
1718 solana_ledger:: leader_schedule_utils:: {
2526 collections:: { BTreeMap , BTreeSet } ,
2627 sync:: {
2728 atomic:: { AtomicBool , Ordering } ,
28- Arc , Condvar , Mutex , RwLock ,
29+ Arc , Condvar , Mutex ,
2930 } ,
3031 thread:: { self , Builder , JoinHandle } ,
3132 time:: Duration ,
@@ -43,7 +44,7 @@ pub(crate) struct EventHandlerContext {
4344 pub ( crate ) start : Arc < ( Mutex < bool > , Condvar ) > ,
4445
4546 pub ( crate ) event_receiver : VotorEventReceiver ,
46- pub ( crate ) skip_timer : Arc < RwLock < SkipTimerManager > > ,
47+ pub ( crate ) timer_manager : Arc < RwLock < TimerManager > > ,
4748
4849 // Contexts
4950 pub ( crate ) shared_context : SharedContext ,
@@ -94,14 +95,15 @@ impl EventHandler {
9495 exit,
9596 start,
9697 event_receiver,
97- skip_timer ,
98+ timer_manager ,
9899 shared_context : ctx,
99100 voting_context : mut vctx,
100101 root_context : rctx,
101102 } = context;
102103 let mut my_pubkey = vctx. identity_keypair . pubkey ( ) ;
103104 let mut pending_blocks = PendingBlocks :: default ( ) ;
104105 let mut finalized_blocks = BTreeSet :: default ( ) ;
106+ let mut received_shred = BTreeSet :: default ( ) ;
105107
106108 // Wait until migration has completed
107109 info ! ( "{my_pubkey}: Event loop initialized" ) ;
@@ -139,12 +141,13 @@ impl EventHandler {
139141 let votes = Self :: handle_event (
140142 & mut my_pubkey,
141143 event,
142- & skip_timer ,
144+ & timer_manager ,
143145 & ctx,
144146 & mut vctx,
145147 & rctx,
146148 & mut pending_blocks,
147149 & mut finalized_blocks,
150+ & mut received_shred,
148151 ) ?;
149152
150153 // TODO: properly bubble up error handling here and in call graph
@@ -159,12 +162,13 @@ impl EventHandler {
159162 fn handle_event (
160163 my_pubkey : & mut Pubkey ,
161164 event : VotorEvent ,
162- skip_timer : & RwLock < SkipTimerManager > ,
165+ timer_manager : & RwLock < TimerManager > ,
163166 ctx : & SharedContext ,
164167 vctx : & mut VotingContext ,
165168 rctx : & RootContext ,
166169 pending_blocks : & mut PendingBlocks ,
167170 finalized_blocks : & mut BTreeSet < Block > ,
171+ received_shred : & mut BTreeSet < Slot > ,
168172 ) -> Result < Vec < Result < BLSOp , VoteError > > , EventLoopError > {
169173 let mut votes = vec ! [ ] ;
170174 match event {
@@ -195,6 +199,7 @@ impl EventHandler {
195199 rctx,
196200 pending_blocks,
197201 finalized_blocks,
202+ received_shred,
198203 ) ?;
199204 }
200205
@@ -205,16 +210,29 @@ impl EventHandler {
205210 Self :: try_final ( my_pubkey, block, vctx, & mut votes) ;
206211 }
207212
213+ VotorEvent :: FirstShred ( slot) => {
214+ info ! ( "{my_pubkey}: First shred {slot}" ) ;
215+ received_shred. insert ( slot) ;
216+ }
217+
208218 // Received a parent ready notification for `slot`
209219 VotorEvent :: ParentReady { slot, parent_block } => {
210220 info ! ( "{my_pubkey}: Parent ready {slot} {parent_block:?}" ) ;
211221 let should_set_timeouts = vctx. vote_history . add_parent_ready ( slot, parent_block) ;
212222 Self :: check_pending_blocks ( my_pubkey, pending_blocks, vctx, & mut votes) ;
213223 if should_set_timeouts {
214- skip_timer . write ( ) . unwrap ( ) . set_timeouts ( slot) ;
224+ timer_manager . write ( ) . set_timeouts ( slot) ;
215225 }
216226 }
217227
228+ VotorEvent :: TimeoutCrashedLeader ( slot) => {
229+ info ! ( "{my_pubkey}: TimeoutCrashedLeader {slot}" ) ;
230+ if vctx. vote_history . voted ( slot) || received_shred. contains ( & slot) {
231+ return Ok ( votes) ;
232+ }
233+ Self :: try_skip_window ( my_pubkey, slot, vctx, & mut votes) ;
234+ }
235+
218236 // Skip timer for the slot has fired
219237 VotorEvent :: Timeout ( slot) => {
220238 info ! ( "{my_pubkey}: Timeout {slot}" ) ;
@@ -289,6 +307,7 @@ impl EventHandler {
289307 rctx,
290308 pending_blocks,
291309 finalized_blocks,
310+ received_shred,
292311 ) ?;
293312 }
294313
@@ -538,6 +557,7 @@ impl EventHandler {
538557 rctx : & RootContext ,
539558 pending_blocks : & mut PendingBlocks ,
540559 finalized_blocks : & mut BTreeSet < Block > ,
560+ received_shred : & mut BTreeSet < Slot > ,
541561 ) -> Result < ( ) , SetRootError > {
542562 let bank_forks_r = ctx. bank_forks . read ( ) . unwrap ( ) ;
543563 let old_root = bank_forks_r. root ( ) ;
@@ -565,6 +585,7 @@ impl EventHandler {
565585 rctx,
566586 pending_blocks,
567587 finalized_blocks,
588+ received_shred,
568589 )
569590 }
570591
0 commit comments