@@ -359,20 +359,17 @@ publish_stake_weights( fd_replay_tile_ctx_t * ctx,
359
359
fd_exec_slot_ctx_t * slot_ctx ) {
360
360
fd_epoch_schedule_t const * epoch_schedule = fd_bank_epoch_schedule_query ( slot_ctx -> bank );
361
361
362
- fd_vote_accounts_global_t const * epoch_stakes = fd_bank_epoch_stakes_locking_query ( slot_ctx -> bank );
363
- fd_vote_accounts_pair_global_t_mapnode_t * epoch_stakes_root = fd_vote_accounts_vote_accounts_root_join ( epoch_stakes );
362
+ fd_vote_states_t const * vote_states_prev_prev = fd_bank_vote_states_prev_prev_locking_query ( slot_ctx -> bank );
363
+ ulong * stake_weights_msg = fd_chunk_to_laddr ( ctx -> stake_out -> mem , ctx -> stake_out -> chunk );
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_2 ( slot_ctx , epoch - 1 , vote_states_prev_prev , stake_weights_msg );
366
+ ulong stake_weights_sig = 4UL ;
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 () ) );
368
+ ctx -> stake_out -> chunk = fd_dcache_compact_next ( ctx -> stake_out -> chunk , stake_weights_sz , ctx -> stake_out -> chunk0 , ctx -> stake_out -> wmark );
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 ]));
370
+ fd_bank_vote_states_prev_prev_end_locking_query ( slot_ctx -> bank );
364
371
365
- if ( epoch_stakes_root != NULL ) {
366
- ulong * stake_weights_msg = fd_chunk_to_laddr ( ctx -> stake_out -> mem , ctx -> stake_out -> chunk );
367
- ulong epoch = fd_slot_to_leader_schedule_epoch ( epoch_schedule , fd_bank_slot_get ( slot_ctx -> bank ) );
368
- ulong stake_weights_sz = generate_stake_weight_msg ( slot_ctx , epoch - 1 , epoch_stakes , stake_weights_msg );
369
- ulong stake_weights_sig = 4UL ;
370
- fd_stem_publish ( stem , 0UL , stake_weights_sig , ctx -> stake_out -> chunk , stake_weights_sz , 0UL , 0UL , fd_frag_meta_ts_comp ( fd_tickcount () ) );
371
- ctx -> stake_out -> chunk = fd_dcache_compact_next ( ctx -> stake_out -> chunk , stake_weights_sz , ctx -> stake_out -> chunk0 , ctx -> stake_out -> wmark );
372
- 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 ]));
373
- }
374
372
375
- fd_bank_epoch_stakes_end_locking_query ( slot_ctx -> bank );
376
373
fd_vote_accounts_global_t const * next_epoch_stakes = fd_bank_next_epoch_stakes_locking_query ( slot_ctx -> bank );
377
374
fd_vote_accounts_pair_global_t_mapnode_t * next_epoch_stakes_root = fd_vote_accounts_vote_accounts_root_join ( next_epoch_stakes );
378
375
@@ -1063,86 +1060,35 @@ publish_votes_to_plugin( fd_replay_tile_ctx_t * ctx,
1063
1060
fd_fork_t * fork = fd_fork_frontier_ele_query ( ctx -> forks -> frontier , & bank_slot , NULL , ctx -> forks -> pool );
1064
1061
if ( FD_UNLIKELY ( !fork ) ) return ;
1065
1062
1066
- fd_vote_accounts_global_t const * epoch_stakes = fd_bank_epoch_stakes_locking_query ( ctx -> slot_ctx -> bank );
1067
- fd_vote_accounts_pair_global_t_mapnode_t * epoch_stakes_pool = fd_vote_accounts_vote_accounts_pool_join ( epoch_stakes );
1068
- fd_vote_accounts_pair_global_t_mapnode_t * epoch_stakes_root = fd_vote_accounts_vote_accounts_root_join ( epoch_stakes );
1063
+ fd_vote_states_t const * vote_states = fd_bank_vote_states_locking_query ( ctx -> slot_ctx -> bank );
1064
+
1065
+ fd_vote_state_map_t * vote_state_map = fd_vote_states_get_map ( vote_states );
1066
+ fd_vote_state_ele_t * vote_state_pool = fd_vote_states_get_pool ( vote_states );
1069
1067
1070
1068
ulong i = 0 ;
1071
1069
FD_SPAD_FRAME_BEGIN ( ctx -> runtime_spad ) {
1072
- 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 );
1073
- n && i < FD_CLUSTER_NODE_CNT ;
1074
- n = fd_vote_accounts_pair_global_t_map_successor_const ( epoch_stakes_pool , n ) ) {
1075
- if ( n -> elem .stake == 0 ) continue ;
1076
-
1077
- uchar * data = (uchar * )& n -> elem .value + n -> elem .value .data_offset ;
1078
- ulong data_len = n -> elem .value .data_len ;
1079
-
1080
- int err ;
1081
- fd_vote_state_versioned_t * vsv = fd_bincode_decode_spad (
1082
- vote_state_versioned , ctx -> runtime_spad ,
1083
- data ,
1084
- data_len ,
1085
- & err );
1086
- if ( FD_UNLIKELY ( err ) ) {
1087
- FD_LOG_ERR (( "Unexpected failure in decoding vote state %d" , err ));
1088
- }
1089
-
1090
- fd_pubkey_t node_pubkey ;
1091
- ulong commission ;
1092
- ulong epoch_credits ;
1093
- fd_vote_epoch_credits_t const * _epoch_credits ;
1094
- ulong root_slot ;
1095
-
1096
- switch ( vsv -> discriminant ) {
1097
- case fd_vote_state_versioned_enum_v0_23_5 :
1098
- node_pubkey = vsv -> inner .v0_23_5 .node_pubkey ;
1099
- commission = vsv -> inner .v0_23_5 .commission ;
1100
- _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 );
1101
- epoch_credits = _epoch_credits == NULL ? 0UL : _epoch_credits -> credits - _epoch_credits -> prev_credits ;
1102
- root_slot = vsv -> inner .v0_23_5 .root_slot ;
1103
- break ;
1104
- case fd_vote_state_versioned_enum_v1_14_11 :
1105
- node_pubkey = vsv -> inner .v1_14_11 .node_pubkey ;
1106
- commission = vsv -> inner .v1_14_11 .commission ;
1107
- _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 );
1108
- epoch_credits = _epoch_credits == NULL ? 0UL : _epoch_credits -> credits - _epoch_credits -> prev_credits ;
1109
- root_slot = vsv -> inner .v1_14_11 .root_slot ;
1110
- break ;
1111
- case fd_vote_state_versioned_enum_current :
1112
- node_pubkey = vsv -> inner .current .node_pubkey ;
1113
- commission = vsv -> inner .current .commission ;
1114
- _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 );
1115
- epoch_credits = _epoch_credits == NULL ? 0UL : _epoch_credits -> credits - _epoch_credits -> prev_credits ;
1116
- root_slot = vsv -> inner .v0_23_5 .root_slot ;
1117
- break ;
1118
- default :
1119
- __builtin_unreachable ();
1120
- }
1121
-
1122
- fd_clock_timestamp_vote_t_mapnode_t query ;
1123
- memcpy ( query .elem .pubkey .uc , n -> elem .key .uc , 32UL );
1124
- fd_clock_timestamp_votes_global_t const * clock_timestamp_votes = fd_bank_clock_timestamp_votes_locking_query ( ctx -> slot_ctx -> bank );
1125
- fd_clock_timestamp_vote_t_mapnode_t * timestamp_votes_root = fd_clock_timestamp_votes_votes_root_join ( clock_timestamp_votes );
1126
- fd_clock_timestamp_vote_t_mapnode_t * timestamp_votes_pool = fd_clock_timestamp_votes_votes_pool_join ( clock_timestamp_votes );
1127
-
1128
- fd_clock_timestamp_vote_t_mapnode_t * res = fd_clock_timestamp_vote_t_map_find ( timestamp_votes_pool , timestamp_votes_root , & query );
1070
+ for ( fd_vote_state_map_iter_t iter = fd_vote_state_map_iter_init ( vote_state_map , vote_state_pool );
1071
+ !fd_vote_state_map_iter_done ( iter , vote_state_map , vote_state_pool );
1072
+ iter = fd_vote_state_map_iter_next ( iter , vote_state_map , vote_state_pool ) ) {
1073
+ fd_vote_state_ele_t const * vote_state = fd_vote_state_map_iter_ele_const ( iter , vote_state_map , vote_state_pool );
1129
1074
1130
1075
fd_vote_update_msg_t * msg = (fd_vote_update_msg_t * )(dst + sizeof (ulong ) + i * 112U );
1131
1076
memset ( msg , 0 , 112U );
1132
- memcpy ( msg -> vote_pubkey , n -> elem . key . uc , sizeof (fd_pubkey_t ) );
1133
- memcpy ( msg -> node_pubkey , node_pubkey . uc , sizeof (fd_pubkey_t ) );
1134
- msg -> activated_stake = n -> elem . stake ;
1135
- msg -> last_vote = res == NULL ? 0UL : res -> elem . slot ;
1136
- msg -> root_slot = root_slot ;
1137
- msg -> epoch_credits = epoch_credits ;
1138
- msg -> commission = (uchar )commission ;
1077
+ memcpy ( msg -> vote_pubkey , & vote_state -> vote_account , sizeof (fd_pubkey_t ) );
1078
+ memcpy ( msg -> node_pubkey , & vote_state -> node_account , sizeof (fd_pubkey_t ) );
1079
+ msg -> activated_stake = vote_state -> stake ;
1080
+ msg -> last_vote = vote_state -> last_vote_slot ;
1081
+ msg -> root_slot = 0UL ; /* TODO: needs to be populated in vote_state */
1082
+ msg -> epoch_credits = 0UL ; /* TODO: needs to be populated in vote_state */
1083
+ msg -> commission = (uchar )vote_state -> commission ;
1139
1084
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 );
1085
+
1086
+
1140
1087
++ i ;
1141
- fd_bank_clock_timestamp_votes_end_locking_query ( ctx -> slot_ctx -> bank );
1142
1088
}
1143
1089
} FD_SPAD_FRAME_END ;
1144
1090
1145
- fd_bank_epoch_stakes_end_locking_query ( ctx -> slot_ctx -> bank );
1091
+ fd_bank_vote_states_end_locking_query ( ctx -> slot_ctx -> bank );
1146
1092
1147
1093
* (ulong * )dst = i ;
1148
1094
0 commit comments