@@ -358,33 +358,29 @@ publish_stake_weights( fd_replay_tile_ctx_t * ctx,
358
358
fd_exec_slot_ctx_t * slot_ctx ) {
359
359
fd_epoch_schedule_t const * epoch_schedule = fd_bank_epoch_schedule_query ( slot_ctx -> bank );
360
360
361
- fd_vote_accounts_global_t const * epoch_stakes = fd_bank_epoch_stakes_locking_query ( slot_ctx -> bank );
362
- fd_vote_accounts_pair_global_t_mapnode_t * epoch_stakes_root = fd_vote_accounts_vote_accounts_root_join ( epoch_stakes );
363
-
364
- if ( epoch_stakes_root != NULL ) {
361
+ fd_vote_states_t const * vote_states_prev_prev = fd_bank_vote_states_prev_prev_locking_query ( slot_ctx -> bank );
362
+ do {
365
363
ulong * stake_weights_msg = fd_chunk_to_laddr ( ctx -> stake_out -> mem , ctx -> stake_out -> chunk );
366
- ulong epoch = fd_slot_to_leader_schedule_epoch ( epoch_schedule , fd_bank_slot_get ( slot_ctx -> bank ) );
367
- ulong stake_weights_sz = generate_stake_weight_msg ( slot_ctx , epoch - 1 , epoch_stakes , stake_weights_msg );
368
- ulong stake_weights_sig = 4UL ;
364
+ ulong epoch = fd_slot_to_leader_schedule_epoch ( epoch_schedule , fd_bank_slot_get ( slot_ctx -> bank ) );
365
+ ulong stake_weights_sz = generate_stake_weight_msg ( slot_ctx , epoch - 1 , vote_states_prev_prev , stake_weights_msg );
366
+ ulong stake_weights_sig = 4UL ;
369
367
fd_stem_publish ( stem , 0UL , stake_weights_sig , ctx -> stake_out -> chunk , stake_weights_sz , 0UL , 0UL , fd_frag_meta_ts_comp ( fd_tickcount () ) );
370
368
ctx -> stake_out -> chunk = fd_dcache_compact_next ( ctx -> stake_out -> chunk , stake_weights_sz , ctx -> stake_out -> chunk0 , ctx -> stake_out -> wmark );
371
369
FD_LOG_NOTICE (("sending current epoch stake weights - epoch: %lu, stake_weight_cnt: %lu, start_slot: %lu, slot_cnt: %lu" , stake_weights_msg [0 ], stake_weights_msg [1 ], stake_weights_msg [2 ], stake_weights_msg [3 ]));
372
- }
373
-
374
- fd_bank_epoch_stakes_end_locking_query ( slot_ctx -> bank );
375
- fd_vote_accounts_global_t const * next_epoch_stakes = fd_bank_next_epoch_stakes_locking_query ( slot_ctx -> bank );
376
- fd_vote_accounts_pair_global_t_mapnode_t * next_epoch_stakes_root = fd_vote_accounts_vote_accounts_root_join ( next_epoch_stakes );
370
+ } while ( 0 );
371
+ fd_bank_vote_states_prev_prev_end_locking_query ( slot_ctx -> bank );
377
372
378
- if ( next_epoch_stakes_root != NULL ) {
373
+ fd_vote_states_t const * vote_states_prev = fd_bank_vote_states_prev_locking_query ( slot_ctx -> bank );
374
+ do {
379
375
ulong * stake_weights_msg = fd_chunk_to_laddr ( ctx -> stake_out -> mem , ctx -> stake_out -> chunk );
380
376
ulong epoch = fd_slot_to_leader_schedule_epoch ( epoch_schedule , fd_bank_slot_get ( slot_ctx -> bank ) ); /* epoch */
381
- ulong stake_weights_sz = generate_stake_weight_msg ( slot_ctx , epoch , next_epoch_stakes , stake_weights_msg );
382
- ulong stake_weights_sig = 4UL ;
377
+ ulong stake_weights_sz = generate_stake_weight_msg ( slot_ctx , epoch , vote_states_prev , stake_weights_msg );
378
+ ulong stake_weights_sig = 4UL ;
383
379
fd_stem_publish ( stem , 0UL , stake_weights_sig , ctx -> stake_out -> chunk , stake_weights_sz , 0UL , 0UL , fd_frag_meta_ts_comp ( fd_tickcount () ) );
384
380
ctx -> stake_out -> chunk = fd_dcache_compact_next ( ctx -> stake_out -> chunk , stake_weights_sz , ctx -> stake_out -> chunk0 , ctx -> stake_out -> wmark );
385
381
FD_LOG_NOTICE (("sending next epoch stake weights - epoch: %lu, stake_weight_cnt: %lu, start_slot: %lu, slot_cnt: %lu" , stake_weights_msg [0 ], stake_weights_msg [1 ], stake_weights_msg [2 ], stake_weights_msg [3 ]));
386
- }
387
- fd_bank_next_epoch_stakes_end_locking_query ( slot_ctx -> bank );
382
+ } while ( 0 );
383
+ fd_bank_vote_states_prev_end_locking_query ( slot_ctx -> bank );
388
384
}
389
385
390
386
static void
@@ -529,7 +525,6 @@ restore_slot_ctx( fd_replay_tile_ctx_t * ctx,
529
525
530
526
fd_exec_slot_ctx_t * recovered_slot_ctx = fd_exec_slot_ctx_recover ( ctx -> slot_ctx ,
531
527
manifest_global );
532
-
533
528
if ( !recovered_slot_ctx ) {
534
529
FD_LOG_ERR (( "Failed to restore slot context from snapshot manifest!" ));
535
530
}
@@ -692,20 +687,18 @@ init_after_snapshot( fd_replay_tile_ctx_t * ctx ) {
692
687
memset ( block_id , 0 , sizeof (fd_hash_t ) );
693
688
block_id -> key [0 ] = UCHAR_MAX ; /* TODO: would be good to have the actual block id of the snapshot slot */
694
689
695
- fd_vote_accounts_global_t const * vote_accounts = fd_bank_curr_epoch_stakes_locking_query ( ctx -> slot_ctx -> bank );
696
-
697
- fd_vote_accounts_pair_global_t_mapnode_t * vote_accounts_pool = fd_vote_accounts_vote_accounts_pool_join ( vote_accounts );
698
- fd_vote_accounts_pair_global_t_mapnode_t * vote_accounts_root = fd_vote_accounts_vote_accounts_root_join ( vote_accounts );
690
+ fd_vote_states_t const * vote_states = fd_bank_vote_states_locking_query ( ctx -> slot_ctx -> bank );
699
691
700
692
fd_bank_hash_cmp_t * bank_hash_cmp = ctx -> bank_hash_cmp ;
701
- for ( fd_vote_accounts_pair_global_t_mapnode_t * curr = fd_vote_accounts_pair_global_t_map_minimum ( vote_accounts_pool , vote_accounts_root );
702
- curr ;
703
- curr = fd_vote_accounts_pair_global_t_map_successor ( vote_accounts_pool , curr ) ) {
704
- bank_hash_cmp -> total_stake += curr -> elem .stake ;
693
+
694
+ uchar iter_mem [FD_VOTE_STATE_ITER_FOOTPRINT ];
695
+ for ( fd_vote_states_iter_t * iter = fd_vote_states_iter_init ( vote_states , iter_mem ); !fd_vote_states_iter_done ( iter ); fd_vote_states_iter_next ( iter ) ) {
696
+ fd_vote_state_ele_t const * vote_state = fd_vote_states_iter_ele ( iter );
697
+ bank_hash_cmp -> total_stake += vote_state -> stake ;
705
698
}
706
699
bank_hash_cmp -> watermark = snapshot_slot ;
707
700
708
- fd_bank_curr_epoch_stakes_end_locking_query ( ctx -> slot_ctx -> bank );
701
+ fd_bank_vote_states_end_locking_query ( ctx -> slot_ctx -> bank );
709
702
710
703
ulong root = snapshot_slot ;
711
704
if ( FD_LIKELY ( root > fd_fseq_query ( ctx -> published_wmark ) ) ) {
@@ -750,8 +743,8 @@ init_from_snapshot( fd_replay_tile_ctx_t * ctx,
750
743
fd_bank_lthash_end_locking_query ( ctx -> slot_ctx -> bank );
751
744
752
745
fd_runtime_update_leaders ( ctx -> slot_ctx -> bank ,
753
- fd_bank_slot_get ( ctx -> slot_ctx -> bank ),
754
- ctx -> runtime_spad );
746
+ fd_bank_slot_get ( ctx -> slot_ctx -> bank ),
747
+ ctx -> runtime_spad );
755
748
756
749
fd_runtime_read_genesis ( ctx -> slot_ctx ,
757
750
ctx -> genesis ,
@@ -1055,86 +1048,30 @@ publish_votes_to_plugin( fd_replay_tile_ctx_t * ctx,
1055
1048
fd_fork_t * fork = fd_fork_frontier_ele_query ( ctx -> forks -> frontier , & bank_slot , NULL , ctx -> forks -> pool );
1056
1049
if ( FD_UNLIKELY ( !fork ) ) return ;
1057
1050
1058
- fd_vote_accounts_global_t const * epoch_stakes = fd_bank_epoch_stakes_locking_query ( ctx -> slot_ctx -> bank );
1059
- fd_vote_accounts_pair_global_t_mapnode_t * epoch_stakes_pool = fd_vote_accounts_vote_accounts_pool_join ( epoch_stakes );
1060
- fd_vote_accounts_pair_global_t_mapnode_t * epoch_stakes_root = fd_vote_accounts_vote_accounts_root_join ( epoch_stakes );
1061
-
1051
+ fd_vote_states_t const * vote_states = fd_bank_vote_states_locking_query ( ctx -> slot_ctx -> bank );
1062
1052
ulong i = 0 ;
1063
1053
FD_SPAD_FRAME_BEGIN ( ctx -> runtime_spad ) {
1064
- for ( fd_vote_accounts_pair_global_t_mapnode_t const * n = fd_vote_accounts_pair_global_t_map_minimum_const ( epoch_stakes_pool , epoch_stakes_root );
1065
- n && i < FD_CLUSTER_NODE_CNT ;
1066
- n = fd_vote_accounts_pair_global_t_map_successor_const ( epoch_stakes_pool , n ) ) {
1067
- if ( n -> elem .stake == 0 ) continue ;
1068
-
1069
- uchar * data = (uchar * )& n -> elem .value + n -> elem .value .data_offset ;
1070
- ulong data_len = n -> elem .value .data_len ;
1071
-
1072
- int err ;
1073
- fd_vote_state_versioned_t * vsv = fd_bincode_decode_spad (
1074
- vote_state_versioned , ctx -> runtime_spad ,
1075
- data ,
1076
- data_len ,
1077
- & err );
1078
- if ( FD_UNLIKELY ( err ) ) {
1079
- FD_LOG_ERR (( "Unexpected failure in decoding vote state %d" , err ));
1080
- }
1081
-
1082
- fd_pubkey_t node_pubkey ;
1083
- ulong commission ;
1084
- ulong epoch_credits ;
1085
- fd_vote_epoch_credits_t const * _epoch_credits ;
1086
- ulong root_slot ;
1087
-
1088
- switch ( vsv -> discriminant ) {
1089
- case fd_vote_state_versioned_enum_v0_23_5 :
1090
- node_pubkey = vsv -> inner .v0_23_5 .node_pubkey ;
1091
- commission = vsv -> inner .v0_23_5 .commission ;
1092
- _epoch_credits = deq_fd_vote_epoch_credits_t_cnt ( vsv -> inner .v0_23_5 .epoch_credits ) == 0 ? NULL : deq_fd_vote_epoch_credits_t_peek_tail_const ( vsv -> inner .v0_23_5 .epoch_credits );
1093
- epoch_credits = _epoch_credits == NULL ? 0UL : _epoch_credits -> credits - _epoch_credits -> prev_credits ;
1094
- root_slot = vsv -> inner .v0_23_5 .root_slot ;
1095
- break ;
1096
- case fd_vote_state_versioned_enum_v1_14_11 :
1097
- node_pubkey = vsv -> inner .v1_14_11 .node_pubkey ;
1098
- commission = vsv -> inner .v1_14_11 .commission ;
1099
- _epoch_credits = deq_fd_vote_epoch_credits_t_cnt ( vsv -> inner .v1_14_11 .epoch_credits ) == 0 ? NULL : deq_fd_vote_epoch_credits_t_peek_tail_const ( vsv -> inner .v1_14_11 .epoch_credits );
1100
- epoch_credits = _epoch_credits == NULL ? 0UL : _epoch_credits -> credits - _epoch_credits -> prev_credits ;
1101
- root_slot = vsv -> inner .v1_14_11 .root_slot ;
1102
- break ;
1103
- case fd_vote_state_versioned_enum_current :
1104
- node_pubkey = vsv -> inner .current .node_pubkey ;
1105
- commission = vsv -> inner .current .commission ;
1106
- _epoch_credits = deq_fd_vote_epoch_credits_t_cnt ( vsv -> inner .current .epoch_credits ) == 0 ? NULL : deq_fd_vote_epoch_credits_t_peek_tail_const ( vsv -> inner .current .epoch_credits );
1107
- epoch_credits = _epoch_credits == NULL ? 0UL : _epoch_credits -> credits - _epoch_credits -> prev_credits ;
1108
- root_slot = vsv -> inner .v0_23_5 .root_slot ;
1109
- break ;
1110
- default :
1111
- __builtin_unreachable ();
1112
- }
1113
-
1114
- fd_clock_timestamp_vote_t_mapnode_t query ;
1115
- memcpy ( query .elem .pubkey .uc , n -> elem .key .uc , 32UL );
1116
- fd_clock_timestamp_votes_global_t const * clock_timestamp_votes = fd_bank_clock_timestamp_votes_locking_query ( ctx -> slot_ctx -> bank );
1117
- fd_clock_timestamp_vote_t_mapnode_t * timestamp_votes_root = fd_clock_timestamp_votes_votes_root_join ( clock_timestamp_votes );
1118
- fd_clock_timestamp_vote_t_mapnode_t * timestamp_votes_pool = fd_clock_timestamp_votes_votes_pool_join ( clock_timestamp_votes );
1119
-
1120
- fd_clock_timestamp_vote_t_mapnode_t * res = fd_clock_timestamp_vote_t_map_find ( timestamp_votes_pool , timestamp_votes_root , & query );
1054
+ uchar iter_mem [FD_VOTE_STATE_ITER_FOOTPRINT ];
1055
+ for ( fd_vote_states_iter_t * iter = fd_vote_states_iter_init ( vote_states , iter_mem ); !fd_vote_states_iter_done ( iter ); fd_vote_states_iter_next ( iter ) ) {
1056
+ fd_vote_state_ele_t const * vote_state = fd_vote_states_iter_ele ( iter );
1121
1057
1122
1058
fd_vote_update_msg_t * msg = (fd_vote_update_msg_t * )(dst + sizeof (ulong ) + i * 112U );
1123
1059
memset ( msg , 0 , 112U );
1124
- memcpy ( msg -> vote_pubkey , n -> elem . key . uc , sizeof (fd_pubkey_t ) );
1125
- memcpy ( msg -> node_pubkey , node_pubkey . uc , sizeof (fd_pubkey_t ) );
1126
- msg -> activated_stake = n -> elem . stake ;
1127
- msg -> last_vote = res == NULL ? 0UL : res -> elem . slot ;
1128
- msg -> root_slot = root_slot ;
1129
- msg -> epoch_credits = epoch_credits ;
1130
- msg -> commission = (uchar )commission ;
1060
+ memcpy ( msg -> vote_pubkey , & vote_state -> vote_account , sizeof (fd_pubkey_t ) );
1061
+ memcpy ( msg -> node_pubkey , & vote_state -> node_account , sizeof (fd_pubkey_t ) );
1062
+ msg -> activated_stake = vote_state -> stake ;
1063
+ msg -> last_vote = vote_state -> last_vote_slot ;
1064
+ msg -> root_slot = 0UL ; /* TODO: needs to be populated in vote_state */
1065
+ msg -> epoch_credits = 0UL ; /* TODO: needs to be populated in vote_state */
1066
+ msg -> commission = (uchar )vote_state -> commission ;
1131
1067
msg -> is_delinquent = (uchar )fd_int_if (fd_bank_slot_get ( ctx -> slot_ctx -> bank ) >= 128UL , msg -> last_vote <= fd_bank_slot_get ( ctx -> slot_ctx -> bank ) - 128UL , msg -> last_vote == 0 );
1068
+
1069
+
1132
1070
++ i ;
1133
- fd_bank_clock_timestamp_votes_end_locking_query ( ctx -> slot_ctx -> bank );
1134
1071
}
1135
1072
} FD_SPAD_FRAME_END ;
1136
1073
1137
- fd_bank_epoch_stakes_end_locking_query ( ctx -> slot_ctx -> bank );
1074
+ fd_bank_vote_states_end_locking_query ( ctx -> slot_ctx -> bank );
1138
1075
1139
1076
* (ulong * )dst = i ;
1140
1077
0 commit comments