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