4
4
/* Stripped down version of `fd_refresh_vote_accounts()` that simply refreshes the stake delegation amount
5
5
for each of the vote accounts using the stake delegations cache. */
6
6
static void
7
- fd_runtime_fuzz_block_refresh_vote_accounts ( fd_vote_accounts_pair_global_t_mapnode_t * vote_accounts_pool ,
8
- fd_vote_accounts_pair_global_t_mapnode_t * vote_accounts_root ,
9
- fd_vote_states_t * vote_states ,
10
- fd_stake_delegations_t * stake_delegations ) {
7
+ fd_runtime_fuzz_block_refresh_vote_accounts ( fd_vote_states_t * vote_states ,
8
+ fd_stake_delegations_t * stake_delegations ) {
11
9
fd_stake_delegation_map_t * map = fd_stake_delegations_get_map ( stake_delegations );
12
10
fd_stake_delegation_t * pool = fd_stake_delegations_get_pool ( stake_delegations );
13
11
@@ -20,12 +18,6 @@ fd_runtime_fuzz_block_refresh_vote_accounts( fd_vote_accounts_pair_global_t_mapn
20
18
ulong stake = node -> stake ;
21
19
22
20
/* Find the voter in the vote accounts cache and update their delegation amount */
23
- fd_vote_accounts_pair_global_t_mapnode_t vode_node [1 ];
24
- fd_memcpy ( vode_node -> elem .key .uc , voter_pubkey , sizeof (fd_pubkey_t ) );
25
- fd_vote_accounts_pair_global_t_mapnode_t * found_node = fd_vote_accounts_pair_global_t_map_find ( vote_accounts_pool , vote_accounts_root , vode_node );
26
- if ( FD_LIKELY ( found_node ) ) {
27
- found_node -> elem .stake += stake ;
28
- }
29
21
fd_vote_state_ele_t * vote_state = fd_vote_states_query ( vote_states , voter_pubkey );
30
22
ulong vote_stake = vote_state -> stake ;
31
23
fd_vote_states_update_stake ( vote_states , voter_pubkey , vote_stake + stake );
@@ -37,12 +29,10 @@ fd_runtime_fuzz_block_refresh_vote_accounts( fd_vote_accounts_pair_global_t_mapn
37
29
from the current present account state. This function also registers a vote timestamp
38
30
for the vote account */
39
31
static void
40
- fd_runtime_fuzz_block_register_vote_account ( fd_exec_slot_ctx_t * slot_ctx ,
41
- fd_vote_states_t * vote_states ,
42
- fd_vote_accounts_pair_global_t_mapnode_t * pool ,
43
- fd_vote_accounts_pair_global_t_mapnode_t * * root ,
44
- fd_pubkey_t * pubkey ,
45
- fd_spad_t * spad ) {
32
+ fd_runtime_fuzz_block_register_vote_account ( fd_exec_slot_ctx_t * slot_ctx ,
33
+ fd_vote_states_t * vote_states ,
34
+ fd_pubkey_t * pubkey ,
35
+ fd_spad_t * spad ) {
46
36
FD_TXN_ACCOUNT_DECL ( acc );
47
37
if ( FD_UNLIKELY ( fd_txn_account_init_from_funk_readonly ( acc , pubkey , slot_ctx -> funk , slot_ctx -> funk_txn ) ) ) {
48
38
return ;
@@ -70,32 +60,11 @@ fd_runtime_fuzz_block_register_vote_account( fd_exec_slot_ctx_t *
70
60
return ;
71
61
}
72
62
73
- /* Nothing to do if the account already exists in the cache */
74
- fd_vote_accounts_pair_global_t_mapnode_t existing_node [1 ];
75
- fd_memcpy ( existing_node -> elem .key .uc , pubkey , sizeof (fd_pubkey_t ) );
76
- if ( fd_vote_accounts_pair_global_t_map_find ( pool , * root , existing_node ) ) {
77
- return ;
78
- }
79
-
80
- /* At this point, the node is new and needs to be inserted into the cache. */
81
- fd_vote_accounts_pair_global_t_mapnode_t * node_to_insert = fd_vote_accounts_pair_global_t_map_acquire ( pool );
82
- fd_memcpy ( node_to_insert -> elem .key .uc , pubkey , sizeof (fd_pubkey_t ) );
83
-
84
- ulong account_dlen = fd_txn_account_get_data_len ( acc );
85
- node_to_insert -> elem .stake = 0UL ; // This will get set later
86
- node_to_insert -> elem .value .executable = !!fd_txn_account_is_executable ( acc );
87
- node_to_insert -> elem .value .lamports = fd_txn_account_get_lamports ( acc );
88
- node_to_insert -> elem .value .rent_epoch = fd_txn_account_get_rent_epoch ( acc );
89
- node_to_insert -> elem .value .data_len = account_dlen ;
90
-
91
- uchar * data = fd_spad_alloc ( spad , alignof(uchar ), account_dlen );
92
- memcpy ( data , fd_txn_account_get_data ( acc ), account_dlen );
93
- fd_solana_account_data_update ( & node_to_insert -> elem .value , data );
94
-
95
- fd_vote_accounts_pair_global_t_map_insert ( pool , root , node_to_insert );
96
-
97
- fd_vote_states_update_from_account ( vote_states , pubkey , data , account_dlen );
98
- fd_vote_states_update_stake ( vote_states , pubkey , node_to_insert -> elem .stake );
63
+ fd_vote_states_update_from_account (
64
+ vote_states ,
65
+ acc -> pubkey ,
66
+ fd_txn_account_get_data ( acc ),
67
+ fd_txn_account_get_data_len ( acc ) );
99
68
}
100
69
101
70
/* Stores an entry in the stake delegations cache for the given vote account. Deserializes and uses the present
@@ -285,11 +254,6 @@ fd_runtime_fuzz_block_ctx_create( fd_runtime_fuzz_runner_t * runner,
285
254
vote_states_prev_prev = fd_vote_states_join ( fd_vote_states_new ( vote_states_prev_prev , FD_RUNTIME_MAX_VOTE_ACCOUNTS ) );
286
255
fd_bank_vote_states_prev_prev_end_locking_modify ( slot_ctx -> bank );
287
256
288
- fd_vote_accounts_global_t * curr_stakes = fd_bank_curr_epoch_stakes_locking_modify ( slot_ctx -> bank );
289
- uchar * pool_mem = (uchar * )fd_ulong_align_up ( (ulong )curr_stakes + sizeof (fd_vote_accounts_global_t ), fd_vote_accounts_pair_t_map_align () );
290
- fd_vote_accounts_pair_global_t_mapnode_t * vote_accounts_pool = fd_vote_accounts_pair_global_t_map_join ( fd_vote_accounts_pair_global_t_map_new ( pool_mem , vote_acct_max ) );
291
- fd_vote_accounts_pair_global_t_mapnode_t * vote_accounts_root = NULL ;
292
-
293
257
fd_stake_delegations_t * stake_delegations = fd_bank_stake_delegations_locking_modify ( slot_ctx -> bank );
294
258
stake_delegations = fd_stake_delegations_join ( fd_stake_delegations_new ( stake_delegations , FD_RUNTIME_MAX_STAKE_ACCOUNTS ) );
295
259
@@ -302,12 +266,11 @@ fd_runtime_fuzz_block_ctx_create( fd_runtime_fuzz_runner_t * runner,
302
266
/* Update vote accounts cache for epoch T */
303
267
fd_pubkey_t pubkey ;
304
268
memcpy ( & pubkey , test_ctx -> acct_states [i ].address , sizeof (fd_pubkey_t ) );
305
- fd_runtime_fuzz_block_register_vote_account ( slot_ctx ,
306
- vote_states ,
307
- vote_accounts_pool ,
308
- & vote_accounts_root ,
309
- & pubkey ,
310
- runner -> spad );
269
+ fd_runtime_fuzz_block_register_vote_account (
270
+ slot_ctx ,
271
+ vote_states ,
272
+ & pubkey ,
273
+ runner -> spad );
311
274
312
275
/* Update the stake delegations cache for epoch T */
313
276
fd_runtime_fuzz_block_register_stake_delegation ( slot_ctx ,
@@ -316,17 +279,9 @@ fd_runtime_fuzz_block_ctx_create( fd_runtime_fuzz_runner_t * runner,
316
279
}
317
280
318
281
/* Refresh vote accounts to calculate stake delegations */
319
- fd_runtime_fuzz_block_refresh_vote_accounts ( vote_accounts_pool ,
320
- vote_accounts_root ,
321
- vote_states ,
322
- stake_delegations );
282
+ fd_runtime_fuzz_block_refresh_vote_accounts ( vote_states , stake_delegations );
323
283
fd_bank_vote_states_end_locking_modify ( slot_ctx -> bank );
324
284
325
-
326
- fd_vote_accounts_vote_accounts_pool_update ( curr_stakes , vote_accounts_pool );
327
- fd_vote_accounts_vote_accounts_root_update ( curr_stakes , vote_accounts_root );
328
-
329
- fd_bank_curr_epoch_stakes_end_locking_modify ( slot_ctx -> bank );
330
285
fd_bank_stake_delegations_end_locking_modify ( slot_ctx -> bank );
331
286
332
287
/* Finish init epoch bank sysvars */
@@ -344,9 +299,9 @@ fd_runtime_fuzz_block_ctx_create( fd_runtime_fuzz_runner_t * runner,
344
299
fd_runtime_fuzz_refresh_program_cache ( slot_ctx , test_ctx -> acct_states , test_ctx -> acct_states_count , runner -> spad );
345
300
346
301
fd_vote_accounts_global_t * vote_accounts = fd_bank_next_epoch_stakes_locking_modify ( slot_ctx -> bank );
347
- pool_mem = (uchar * )fd_ulong_align_up ( (ulong )vote_accounts + sizeof (fd_vote_accounts_global_t ), fd_vote_accounts_pair_global_t_map_align () );
348
- vote_accounts_pool = fd_vote_accounts_pair_global_t_map_join ( fd_vote_accounts_pair_global_t_map_new ( pool_mem , vote_acct_max ) );
349
- vote_accounts_root = NULL ;
302
+ uchar * pool_mem = (uchar * )fd_ulong_align_up ( (ulong )vote_accounts + sizeof (fd_vote_accounts_global_t ), fd_vote_accounts_pair_global_t_map_align () );
303
+ fd_vote_accounts_pair_global_t_mapnode_t * vote_accounts_pool = fd_vote_accounts_pair_global_t_map_join ( fd_vote_accounts_pair_global_t_map_new ( pool_mem , vote_acct_max ) );
304
+ fd_vote_accounts_pair_global_t_mapnode_t * vote_accounts_root = NULL ;
350
305
351
306
/* Update vote cache for epoch T-1 */
352
307
vote_states_prev = fd_bank_vote_states_prev_locking_modify ( slot_ctx -> bank );
0 commit comments