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_ledger:: leader_schedule_utils:: {
1617 first_of_consecutive_leader_slots, last_of_consecutive_leader_slots, leader_slot_index,
1718 } ,
2324 collections:: { BTreeMap , BTreeSet } ,
2425 sync:: {
2526 atomic:: { AtomicBool , Ordering } ,
26- Arc , Condvar , Mutex , RwLock ,
27+ Arc , Condvar , Mutex ,
2728 } ,
2829 thread:: { self , Builder , JoinHandle } ,
2930 time:: Duration ,
@@ -41,7 +42,7 @@ pub(crate) struct EventHandlerContext {
4142 pub ( crate ) start : Arc < ( Mutex < bool > , Condvar ) > ,
4243
4344 pub ( crate ) event_receiver : VotorEventReceiver ,
44- pub ( crate ) skip_timer : Arc < RwLock < SkipTimerManager > > ,
45+ pub ( crate ) timer_manager : Arc < RwLock < TimerManager > > ,
4546
4647 // Contexts
4748 pub ( crate ) shared_context : SharedContext ,
@@ -92,14 +93,15 @@ impl EventHandler {
9293 exit,
9394 start,
9495 event_receiver,
95- skip_timer ,
96+ timer_manager ,
9697 shared_context : ctx,
9798 voting_context : mut vctx,
9899 root_context : rctx,
99100 } = context;
100101 let mut my_pubkey = vctx. identity_keypair . pubkey ( ) ;
101102 let mut pending_blocks = PendingBlocks :: default ( ) ;
102103 let mut finalized_blocks = BTreeSet :: default ( ) ;
104+ let mut received_shred = BTreeSet :: default ( ) ;
103105
104106 // Wait until migration has completed
105107 info ! ( "{my_pubkey}: Event loop initialized" ) ;
@@ -137,12 +139,13 @@ impl EventHandler {
137139 let votes = Self :: handle_event (
138140 & mut my_pubkey,
139141 event,
140- & skip_timer ,
142+ & timer_manager ,
141143 & ctx,
142144 & mut vctx,
143145 & rctx,
144146 & mut pending_blocks,
145147 & mut finalized_blocks,
148+ & mut received_shred,
146149 ) ?;
147150
148151 // TODO: properly bubble up error handling here and in call graph
@@ -157,12 +160,13 @@ impl EventHandler {
157160 fn handle_event (
158161 my_pubkey : & mut Pubkey ,
159162 event : VotorEvent ,
160- skip_timer : & RwLock < SkipTimerManager > ,
163+ timer_manager : & RwLock < TimerManager > ,
161164 ctx : & SharedContext ,
162165 vctx : & mut VotingContext ,
163166 rctx : & RootContext ,
164167 pending_blocks : & mut PendingBlocks ,
165168 finalized_blocks : & mut BTreeSet < Block > ,
169+ received_shred : & mut BTreeSet < Slot > ,
166170 ) -> Result < Vec < Result < BLSOp , VoteError > > , EventLoopError > {
167171 let mut votes = vec ! [ ] ;
168172 match event {
@@ -193,6 +197,7 @@ impl EventHandler {
193197 rctx,
194198 pending_blocks,
195199 finalized_blocks,
200+ received_shred,
196201 ) ?;
197202 }
198203
@@ -203,16 +208,29 @@ impl EventHandler {
203208 Self :: try_final ( my_pubkey, block, vctx, & mut votes) ;
204209 }
205210
211+ VotorEvent :: FirstShred ( slot) => {
212+ info ! ( "{my_pubkey}: First shred {slot}" ) ;
213+ received_shred. insert ( slot) ;
214+ }
215+
206216 // Received a parent ready notification for `slot`
207217 VotorEvent :: ParentReady { slot, parent_block } => {
208218 info ! ( "{my_pubkey}: Parent ready {slot} {parent_block:?}" ) ;
209219 let should_set_timeouts = vctx. vote_history . add_parent_ready ( slot, parent_block) ;
210220 Self :: check_pending_blocks ( my_pubkey, pending_blocks, vctx, & mut votes) ;
211221 if should_set_timeouts {
212- skip_timer . write ( ) . unwrap ( ) . set_timeouts ( slot) ;
222+ timer_manager . write ( ) . set_timeouts ( slot) ;
213223 }
214224 }
215225
226+ VotorEvent :: TimeoutCrashedLeader ( slot) => {
227+ info ! ( "{my_pubkey}: TimeoutCrashedLeader {slot}" ) ;
228+ if vctx. vote_history . voted ( slot) || received_shred. contains ( & slot) {
229+ return Ok ( votes) ;
230+ }
231+ Self :: try_skip_window ( my_pubkey, slot, vctx, & mut votes) ;
232+ }
233+
216234 // Skip timer for the slot has fired
217235 VotorEvent :: Timeout ( slot) => {
218236 info ! ( "{my_pubkey}: Timeout {slot}" ) ;
@@ -287,6 +305,7 @@ impl EventHandler {
287305 rctx,
288306 pending_blocks,
289307 finalized_blocks,
308+ received_shred,
290309 ) ?;
291310 }
292311
@@ -536,6 +555,7 @@ impl EventHandler {
536555 rctx : & RootContext ,
537556 pending_blocks : & mut PendingBlocks ,
538557 finalized_blocks : & mut BTreeSet < Block > ,
558+ received_shred : & mut BTreeSet < Slot > ,
539559 ) -> Result < ( ) , SetRootError > {
540560 let bank_forks_r = ctx. bank_forks . read ( ) . unwrap ( ) ;
541561 let old_root = bank_forks_r. root ( ) ;
@@ -563,6 +583,7 @@ impl EventHandler {
563583 rctx,
564584 pending_blocks,
565585 finalized_blocks,
586+ received_shred,
566587 )
567588 }
568589
0 commit comments