@@ -116,9 +116,7 @@ fd_runtime_update_slots_per_epoch( fd_bank_t * bank,
116116
117117void
118118fd_runtime_update_leaders ( fd_bank_t * bank ,
119- fd_spad_t * runtime_spad ) {
120-
121- FD_SPAD_FRAME_BEGIN ( runtime_spad ) {
119+ uchar * epoch_weights_mem ) {
122120
123121 fd_epoch_schedule_t const * epoch_schedule = fd_bank_epoch_schedule_query ( bank );
124122
@@ -127,8 +125,7 @@ fd_runtime_update_leaders( fd_bank_t * bank,
127125 ulong slot_cnt = fd_epoch_slot_cnt ( epoch_schedule , epoch );
128126
129127 fd_vote_states_t const * vote_states_prev_prev = fd_bank_vote_states_prev_prev_locking_query ( bank );
130- ulong vote_acc_cnt = fd_vote_states_cnt ( vote_states_prev_prev ) ;
131- fd_vote_stake_weight_t * epoch_weights = fd_spad_alloc_check ( runtime_spad , alignof(fd_vote_stake_weight_t ), vote_acc_cnt * sizeof (fd_vote_stake_weight_t ) );
128+ fd_vote_stake_weight_t * epoch_weights = fd_type_pun ( epoch_weights_mem );
132129 ulong stake_weight_cnt = fd_stake_weights_by_node ( vote_states_prev_prev , epoch_weights );
133130 fd_bank_vote_states_prev_prev_end_locking_query ( bank );
134131
@@ -146,9 +143,8 @@ fd_runtime_update_leaders( fd_bank_t * bank,
146143 }
147144
148145 ulong vote_keyed_lsched = (ulong )fd_runtime_should_use_vote_keyed_leader_schedule ( bank );
149- void * epoch_leaders_mem = fd_bank_epoch_leaders_locking_modify ( bank );
150146 fd_epoch_leaders_t * leaders = fd_epoch_leaders_join ( fd_epoch_leaders_new (
151- epoch_leaders_mem ,
147+ fd_bank_epoch_leaders_locking_modify ( bank ) ,
152148 epoch ,
153149 slot0 ,
154150 slot_cnt ,
@@ -161,7 +157,6 @@ fd_runtime_update_leaders( fd_bank_t * bank,
161157 }
162158 fd_bank_epoch_leaders_end_locking_modify ( bank );
163159 }
164- } FD_SPAD_FRAME_END ;
165160}
166161
167162/******************************************************************************/
@@ -1488,7 +1483,8 @@ fd_runtime_process_new_epoch( fd_banks_t * banks,
14881483 fd_funk_txn_xid_t const * xid ,
14891484 fd_capture_ctx_t * capture_ctx ,
14901485 ulong parent_epoch ,
1491- fd_spad_t * runtime_spad ) {
1486+ fd_spad_t * runtime_spad ,
1487+ fd_runtime_mem_t * runtime_mem ) {
14921488 FD_LOG_NOTICE (( "fd_process_new_epoch start, epoch: %lu, slot: %lu" , fd_bank_epoch_get ( bank ), fd_bank_slot_get ( bank ) ));
14931489
14941490 FD_SPAD_FRAME_BEGIN ( runtime_spad ) {
@@ -1574,7 +1570,7 @@ fd_runtime_process_new_epoch( fd_banks_t * banks,
15741570
15751571 /* Update current leaders using epoch_stakes (new T-2 stakes) */
15761572
1577- fd_runtime_update_leaders ( bank , runtime_spad );
1573+ fd_runtime_update_leaders ( bank , runtime_mem -> epoch_weights_mem );
15781574
15791575 FD_LOG_NOTICE (( "fd_process_new_epoch end" ));
15801576
@@ -1878,7 +1874,8 @@ fd_runtime_process_genesis_block( fd_bank_t * bank,
18781874 fd_funk_t * funk ,
18791875 fd_funk_txn_xid_t const * xid ,
18801876 fd_capture_ctx_t * capture_ctx ,
1881- fd_spad_t * runtime_spad ) {
1877+ fd_spad_t * runtime_spad ,
1878+ fd_runtime_mem_t * runtime_mem ) {
18821879
18831880 fd_hash_t * poh = fd_bank_poh_modify ( bank );
18841881 ulong hashcnt_per_slot = fd_bank_hashes_per_tick_get ( bank ) * fd_bank_ticks_per_slot_get ( bank );
@@ -1904,7 +1901,7 @@ fd_runtime_process_genesis_block( fd_bank_t * bank,
19041901
19051902 fd_sysvar_slot_history_update ( bank , funk , xid , capture_ctx );
19061903
1907- fd_runtime_update_leaders ( bank , runtime_spad );
1904+ fd_runtime_update_leaders ( bank , runtime_mem -> epoch_weights_mem );
19081905
19091906 fd_runtime_freeze ( bank , funk , xid , capture_ctx );
19101907
@@ -1934,7 +1931,8 @@ fd_runtime_read_genesis( fd_banks_t * banks,
19341931 fd_hash_t const * genesis_hash ,
19351932 fd_lthash_value_t const * genesis_lthash ,
19361933 fd_genesis_solana_global_t const * genesis_block ,
1937- fd_spad_t * runtime_spad ) {
1934+ fd_spad_t * runtime_spad ,
1935+ fd_runtime_mem_t * runtime_mem ) {
19381936 FD_SPAD_FRAME_BEGIN ( runtime_spad ) {
19391937
19401938 fd_lthash_value_t * lthash = fd_bank_lthash_locking_modify ( bank );
@@ -1966,7 +1964,7 @@ fd_runtime_read_genesis( fd_banks_t * banks,
19661964 block. In practice, this updates some bank fields (notably the
19671965 poh and bank hash). */
19681966
1969- int err = fd_runtime_process_genesis_block ( bank , funk , xid , capture_ctx , runtime_spad );
1967+ int err = fd_runtime_process_genesis_block ( bank , funk , xid , capture_ctx , runtime_spad , runtime_mem );
19701968 if ( FD_UNLIKELY ( err ) ) FD_LOG_CRIT (( "genesis slot 0 execute failed with error %d" , err ));
19711969
19721970 } FD_SPAD_FRAME_END ;
@@ -1987,6 +1985,7 @@ fd_runtime_block_pre_execute_process_new_epoch( fd_banks_t * banks,
19871985 fd_funk_txn_xid_t const * xid ,
19881986 fd_capture_ctx_t * capture_ctx ,
19891987 fd_spad_t * runtime_spad ,
1988+ fd_runtime_mem_t * runtime_mem ,
19901989 int * is_epoch_boundary ) {
19911990
19921991 ulong const slot = fd_bank_slot_get ( bank );
@@ -2003,7 +2002,7 @@ fd_runtime_block_pre_execute_process_new_epoch( fd_banks_t * banks,
20032002
20042003 if ( FD_UNLIKELY ( prev_epoch < new_epoch || !slot_idx ) ) {
20052004 FD_LOG_DEBUG (( "Epoch boundary starting" ));
2006- fd_runtime_process_new_epoch ( banks , bank , funk , xid , capture_ctx , prev_epoch , runtime_spad );
2005+ fd_runtime_process_new_epoch ( banks , bank , funk , xid , capture_ctx , prev_epoch , runtime_spad , runtime_mem );
20072006 * is_epoch_boundary = 1 ;
20082007 }
20092008 } else {
0 commit comments