@@ -27,6 +27,7 @@ use solana_ledger::blockstore_processor::{
2727 confirm_slot_entries, create_thread_pool, ConfirmationProgress , ConfirmationTiming ,
2828} ;
2929use solana_ledger:: leader_schedule_cache:: LeaderScheduleCache ;
30+ use solana_ledger:: leader_schedule_utils;
3031use solana_poh_config:: PohConfig ;
3132use solana_pubkey:: Pubkey ;
3233use solana_rent:: Rent ;
@@ -471,24 +472,6 @@ pub fn execute_block(context: BlockContext) -> Option<BlockEffects> {
471472 ) ,
472473 ) ;
473474
474- let stakes_current_accounts = Stakes :: new ( & stakes_t, |pubkey| {
475- context
476- . acct_states
477- . iter ( )
478- . find ( |acct| {
479- Pubkey :: new_from_array ( acct. address . clone ( ) . try_into ( ) . unwrap ( ) ) == * pubkey
480- } )
481- . map ( AccountSharedData :: from)
482- } )
483- . unwrap ( ) ;
484- epoch_stakes. insert (
485- leader_schedule_epoch. saturating_add ( 1 ) ,
486- VersionedEpochStakes :: new (
487- SerdeStakesToStakeFormat :: from ( stakes_current_accounts) ,
488- leader_schedule_epoch. saturating_add ( 1 ) ,
489- ) ,
490- ) ;
491-
492475 let fee_rate_governor = slot_ctx. fee_rate_governor . unwrap ( ) ;
493476
494477 let mut parent_lthash = LtHash :: identity ( ) ;
@@ -579,6 +562,7 @@ pub fn execute_block(context: BlockContext) -> Option<BlockEffects> {
579562 null_tracer ( ) ,
580563 ) ;
581564 }
565+ let l_sched = leader_schedule_utils:: leader_schedule ( current_epoch, & bank) . unwrap ( ) ;
582566
583567 bank. distribute_partitioned_epoch_rewards ( ) ;
584568
@@ -689,48 +673,35 @@ pub fn execute_block(context: BlockContext) -> Option<BlockEffects> {
689673 // - leader_schedule_epoch: The epoch for which the leader schedule applies
690674 // - first_slot: The absolute slot number where this epoch begins
691675 // - slots_in_epoch: Total number of slots in this epoch (can vary by epoch)
692- let first_slot = epoch_schedule_for_effects. get_first_slot_in_epoch ( leader_schedule_epoch ) ;
693- let slots_in_epoch = epoch_schedule_for_effects. get_slots_in_epoch ( leader_schedule_epoch ) ;
676+ let first_slot = epoch_schedule_for_effects. get_first_slot_in_epoch ( current_epoch ) ;
677+ let slots_in_epoch = epoch_schedule_for_effects. get_slots_in_epoch ( current_epoch ) ;
694678
695679 // Attempt to retrieve the leader schedule for this epoch from the cache
696- let leader_schedule_effects =
697- if let Some ( schedule) = leader_schedule. get_epoch_leader_schedule ( leader_schedule_epoch) {
698- // Schedule found, obtain effects and hash
699- // Generate a deterministic 128-bit hash of the entire leader schedule
700- // This hash encodes both WHO the leaders are and WHEN they lead.
701- // We use a fixed seed for reproducibility across implementations.
702- let mut schedule_hash = [ 0u8 ; 16 ] ;
703- let schedule_pubkeys: Vec < Pubkey > = ( 0 ..slots_in_epoch)
704- . map ( |slot_offset| schedule[ slot_offset] )
705- . collect ( ) ;
706-
707- let unique_cnt = hash_epoch_leaders (
708- & schedule_pubkeys,
709- LEADER_SCHEDULE_HASH_SEED ,
710- & mut schedule_hash,
711- ) ;
712-
713- // Package all the schedule metadata for output
714- proto:: LeaderScheduleEffects {
715- leaders_epoch : leader_schedule_epoch, // Which epoch this schedule applies to
716- leaders_slot0 : first_slot, // First absolute slot in this epoch
717- leaders_slot_cnt : slots_in_epoch as u64 , // Total slots in this epoch
718- leader_pub_cnt : unique_cnt as u64 , // Number of unique leader validators
719- leaders_sched_cnt : slots_in_epoch as u64 , // Number of scheduled leader slots (verification field)
720- leader_schedule_hash : schedule_hash. to_vec ( ) , // 128-bit fingerprint of the schedule
721- }
722- } else {
723- // No schedule found for this epoch, return empty/zero values
724- // This can happen during bootstrapping or if the epoch is too far in the future
725- proto:: LeaderScheduleEffects {
726- leaders_epoch : 0 ,
727- leaders_slot0 : 0 ,
728- leaders_slot_cnt : 0 ,
729- leader_pub_cnt : 0 ,
730- leaders_sched_cnt : 0 ,
731- leader_schedule_hash : vec ! [ ] ,
732- }
733- } ;
680+
681+ // Schedule found, obtain effects and hash
682+ // Generate a deterministic 128-bit hash of the entire leader schedule
683+ // This hash encodes both WHO the leaders are and WHEN they lead.
684+ // We use a fixed seed for reproducibility across implementations.
685+ let mut schedule_hash = [ 0u8 ; 16 ] ;
686+ let schedule_pubkeys: Vec < Pubkey > = ( 0 ..slots_in_epoch)
687+ . map ( |slot_offset| l_sched[ slot_offset] )
688+ . collect ( ) ;
689+
690+ let unique_cnt = hash_epoch_leaders (
691+ & schedule_pubkeys,
692+ LEADER_SCHEDULE_HASH_SEED ,
693+ & mut schedule_hash,
694+ ) ;
695+
696+ // Package all the schedule metadata for output
697+ let leader_schedule_effects = proto:: LeaderScheduleEffects {
698+ leaders_epoch : current_epoch, // Which epoch this schedule applies to
699+ leaders_slot0 : first_slot, // First absolute slot in this epoch
700+ leaders_slot_cnt : slots_in_epoch as u64 , // Total slots in this epoch
701+ leader_pub_cnt : unique_cnt as u64 , // Number of unique leader validators
702+ leaders_sched_cnt : slots_in_epoch as u64 , // Number of scheduled leader slots (verification field)
703+ leader_schedule_hash : schedule_hash. to_vec ( ) , // 128-bit fingerprint of the schedule
704+ } ;
734705
735706 // Then include in the output
736707 Some ( BlockEffects {
0 commit comments