@@ -172,7 +172,7 @@ calculate_stake_points_and_credits( fd_stake_history_t const * stake_history
172
172
static int
173
173
calculate_stake_rewards ( fd_stake_history_t const * stake_history ,
174
174
fd_stake_delegation_t const * stake ,
175
- fd_vote_state_versioned_t * vote_state_versioned ,
175
+ uchar commission ,
176
176
fd_vote_state_ele_t const * vote_state ,
177
177
ulong rewarded_epoch ,
178
178
fd_point_value_t * point_value ,
@@ -211,7 +211,7 @@ calculate_stake_rewards( fd_stake_history_t const * stake_history,
211
211
}
212
212
213
213
fd_commission_split_t split_result ;
214
- fd_vote_commission_split ( vote_state_versioned , rewards , & split_result );
214
+ fd_vote_commission_split ( commission , rewards , & split_result );
215
215
if ( split_result .is_split && (split_result .voter_portion == 0 || split_result .staker_portion == 0 ) ) {
216
216
return 1 ;
217
217
}
@@ -226,7 +226,6 @@ calculate_stake_rewards( fd_stake_history_t const * stake_history,
226
226
static int
227
227
redeem_rewards ( fd_stake_history_t const * stake_history ,
228
228
fd_stake_delegation_t const * stake ,
229
- fd_vote_state_versioned_t * vote_state_versioned ,
230
229
fd_vote_state_ele_t const * vote_state ,
231
230
ulong rewarded_epoch ,
232
231
fd_point_value_t * point_value ,
@@ -236,7 +235,7 @@ redeem_rewards( fd_stake_history_t const * stake_history,
236
235
int rc = calculate_stake_rewards (
237
236
stake_history ,
238
237
stake ,
239
- vote_state_versioned ,
238
+ vote_state -> commission ,
240
239
vote_state ,
241
240
rewarded_epoch ,
242
241
point_value ,
@@ -315,34 +314,6 @@ get_minimum_stake_delegation( fd_exec_slot_ctx_t const * slot_ctx ) {
315
314
return 1 ;
316
315
}
317
316
318
- static fd_vote_state_versioned_t *
319
- deserialize_vote_account ( fd_exec_slot_ctx_t const * slot_ctx ,
320
- fd_pubkey_t const * vote_account_pubkey ,
321
- fd_spad_t * runtime_spad ) {
322
-
323
- FD_TXN_ACCOUNT_DECL ( vote_account );
324
- if ( FD_UNLIKELY ( fd_txn_account_init_from_funk_readonly ( vote_account ,
325
- vote_account_pubkey ,
326
- slot_ctx -> funk ,
327
- slot_ctx -> funk_txn ) ) ) {
328
- FD_LOG_DEBUG (( "Vote account not found" ));
329
- return NULL ;
330
- }
331
-
332
- // Deserialize the vote account and ensure its in the correct state
333
- int err ;
334
- fd_vote_state_versioned_t * res = fd_bincode_decode_spad (
335
- vote_state_versioned , runtime_spad ,
336
- fd_txn_account_get_data ( vote_account ),
337
- fd_txn_account_get_data_len ( vote_account ),
338
- & err );
339
- if ( FD_UNLIKELY ( err ) ) {
340
- return NULL ;
341
- }
342
-
343
- return res ;
344
- }
345
-
346
317
static uint128
347
318
calculate_points_all ( fd_exec_slot_ctx_t const * slot_ctx ,
348
319
fd_bank_t * bank ,
@@ -359,6 +330,8 @@ calculate_points_all( fd_exec_slot_ctx_t const * slot_ctx,
359
330
fd_stake_delegation_map_t * stake_delegation_map = fd_stake_delegations_get_map ( stake_delegations );
360
331
fd_stake_delegation_t * stake_delegation_pool = fd_stake_delegations_get_pool ( stake_delegations );
361
332
333
+
334
+ ulong curr_epoch = fd_bank_epoch_get ( bank );
362
335
for ( fd_stake_delegation_map_iter_t iter = fd_stake_delegation_map_iter_init ( stake_delegation_map , stake_delegation_pool );
363
336
!fd_stake_delegation_map_iter_done ( iter , stake_delegation_map , stake_delegation_pool );
364
337
iter = fd_stake_delegation_map_iter_next ( iter , stake_delegation_map , stake_delegation_pool ) ) {
@@ -371,8 +344,10 @@ calculate_points_all( fd_exec_slot_ctx_t const * slot_ctx,
371
344
fd_vote_states_t const * vote_states = fd_bank_vote_states_locking_query ( slot_ctx -> bank );
372
345
fd_vote_state_ele_t * vote_state_ele = fd_vote_states_query ( vote_states , & stake_delegation -> vote_account );
373
346
if ( FD_UNLIKELY ( !vote_state_ele ) ) {
374
- FD_LOG_WARNING (( "failed to query vote state" ));
347
+ FD_LOG_WARNING (( "failed to query vote state %lu %lu %lu %lu" , stake_delegation -> stake , stake_delegation -> activation_epoch , stake_delegation -> deactivation_epoch , curr_epoch ));
375
348
continue ;
349
+ } else {
350
+ FD_LOG_WARNING (( "queried vote state %lu %lu %lu %lu" , stake_delegation -> stake , stake_delegation -> activation_epoch , stake_delegation -> deactivation_epoch , curr_epoch ));
376
351
}
377
352
378
353
uint128 account_points ;
@@ -474,15 +449,9 @@ calculate_stake_vote_rewards_account( fd_exec_slot_ctx_t const *
474
449
}
475
450
}
476
451
477
- fd_pubkey_t const * voter_acc = & stake_delegation -> vote_account ;
478
- fd_vote_state_versioned_t * vote_state = deserialize_vote_account ( slot_ctx , voter_acc , spad );
479
- if ( FD_UNLIKELY ( !vote_state ) ) {
480
- FD_LOG_WARNING (( "failed to deserialize vote account" ));
481
- continue ;
482
- }
483
-
484
- fd_vote_states_t const * vote_states = fd_bank_vote_states_locking_query ( slot_ctx -> bank );
485
- fd_vote_state_ele_t * vote_state_ele = fd_vote_states_query ( vote_states , voter_acc );
452
+ fd_pubkey_t const * voter_acc = & stake_delegation -> vote_account ;
453
+ fd_vote_states_t const * vote_states = fd_bank_vote_states_locking_query ( slot_ctx -> bank );
454
+ fd_vote_state_ele_t * vote_state_ele = fd_vote_states_query ( vote_states , voter_acc );
486
455
if ( FD_UNLIKELY ( !vote_state_ele ) ) {
487
456
FD_LOG_WARNING (( "failed to query vote state" ));
488
457
continue ;
@@ -494,7 +463,6 @@ calculate_stake_vote_rewards_account( fd_exec_slot_ctx_t const *
494
463
int err = redeem_rewards (
495
464
stake_history ,
496
465
stake_delegation ,
497
- vote_state ,
498
466
vote_state_ele ,
499
467
rewarded_epoch ,
500
468
point_value ,
@@ -511,29 +479,12 @@ calculate_stake_vote_rewards_account( fd_exec_slot_ctx_t const *
511
479
fd_solcap_write_stake_reward_event ( capture_ctx -> capture ,
512
480
& stake_delegation -> stake_account ,
513
481
voter_acc ,
514
- fd_vote_account_commission ( vote_state ) ,
482
+ vote_state_ele -> commission ,
515
483
(long )calculated_stake_rewards -> voter_rewards ,
516
484
(long )calculated_stake_rewards -> staker_rewards ,
517
485
(long )calculated_stake_rewards -> new_credits_observed );
518
486
}
519
487
520
- /* Fetch the comission for the vote account */
521
- uchar commission = 0 ;
522
- switch ( vote_state -> discriminant ) {
523
- case fd_vote_state_versioned_enum_current :
524
- commission = vote_state -> inner .current .commission ;
525
- break ;
526
- case fd_vote_state_versioned_enum_v0_23_5 :
527
- commission = vote_state -> inner .v0_23_5 .commission ;
528
- break ;
529
- case fd_vote_state_versioned_enum_v1_14_11 :
530
- commission = vote_state -> inner .v1_14_11 .commission ;
531
- break ;
532
- default :
533
- FD_LOG_DEBUG (( "unsupported vote account" ));
534
- continue ;
535
- }
536
-
537
488
// Find and update the vote reward node in the local map
538
489
fd_vote_reward_t_mapnode_t vote_map_key [1 ];
539
490
vote_map_key -> elem .pubkey = * voter_acc ;
@@ -548,7 +499,7 @@ calculate_stake_vote_rewards_account( fd_exec_slot_ctx_t const *
548
499
if ( vote_reward_node == NULL ) {
549
500
vote_reward_node = fd_vote_reward_t_map_acquire ( vote_reward_map_pool );
550
501
vote_reward_node -> elem .pubkey = * voter_acc ;
551
- vote_reward_node -> elem .commission = commission ;
502
+ vote_reward_node -> elem .commission = vote_state_ele -> commission ;
552
503
vote_reward_node -> elem .vote_rewards = calculated_stake_rewards -> voter_rewards ;
553
504
vote_reward_node -> elem .needs_store = 1 ;
554
505
fd_vote_reward_t_map_insert ( vote_reward_map_pool , & vote_reward_map_root , vote_reward_node );
0 commit comments