Skip to content

Commit 0cbba17

Browse files
removing last fd_types complicated field
1 parent 6e4d6df commit 0cbba17

File tree

17 files changed

+49
-380
lines changed

17 files changed

+49
-380
lines changed

src/discof/replay/fd_replay_tile.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -359,30 +359,29 @@ publish_stake_weights( fd_replay_tile_ctx_t * ctx,
359359
fd_exec_slot_ctx_t * slot_ctx ) {
360360
fd_epoch_schedule_t const * epoch_schedule = fd_bank_epoch_schedule_query( slot_ctx->bank );
361361

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 );
371-
372-
373-
fd_vote_accounts_global_t const * next_epoch_stakes = fd_bank_next_epoch_stakes_locking_query( slot_ctx->bank );
374-
fd_vote_accounts_pair_global_t_mapnode_t * next_epoch_stakes_root = fd_vote_accounts_vote_accounts_root_join( next_epoch_stakes );
362+
do {
363+
fd_vote_states_t const * vote_states_prev_prev = fd_bank_vote_states_prev_prev_locking_query( slot_ctx->bank );
364+
ulong * stake_weights_msg = fd_chunk_to_laddr( ctx->stake_out->mem, ctx->stake_out->chunk );
365+
ulong epoch = fd_slot_to_leader_schedule_epoch( epoch_schedule, fd_bank_slot_get( slot_ctx->bank ) );
366+
ulong stake_weights_sz = generate_stake_weight_msg_2( slot_ctx, epoch - 1, vote_states_prev_prev, stake_weights_msg );
367+
ulong stake_weights_sig = 4UL;
368+
fd_stem_publish( stem, 0UL, stake_weights_sig, ctx->stake_out->chunk, stake_weights_sz, 0UL, 0UL, fd_frag_meta_ts_comp( fd_tickcount() ) );
369+
ctx->stake_out->chunk = fd_dcache_compact_next( ctx->stake_out->chunk, stake_weights_sz, ctx->stake_out->chunk0, ctx->stake_out->wmark );
370+
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]));
371+
fd_bank_vote_states_prev_prev_end_locking_query( slot_ctx->bank );
372+
} while( 0 );
375373

376-
if( next_epoch_stakes_root!=NULL ) {
374+
do {
375+
fd_vote_states_t const * vote_states_prev = fd_bank_vote_states_prev_locking_query( slot_ctx->bank );
377376
ulong * stake_weights_msg = fd_chunk_to_laddr( ctx->stake_out->mem, ctx->stake_out->chunk );
378377
ulong epoch = fd_slot_to_leader_schedule_epoch( epoch_schedule, fd_bank_slot_get( slot_ctx->bank ) ); /* epoch */
379-
ulong stake_weights_sz = generate_stake_weight_msg( slot_ctx, epoch, next_epoch_stakes, stake_weights_msg );
378+
ulong stake_weights_sz = generate_stake_weight_msg_2( slot_ctx, epoch, vote_states_prev, stake_weights_msg );
380379
ulong stake_weights_sig = 4UL;
381380
fd_stem_publish( stem, 0UL, stake_weights_sig, ctx->stake_out->chunk, stake_weights_sz, 0UL, 0UL, fd_frag_meta_ts_comp( fd_tickcount() ) );
382381
ctx->stake_out->chunk = fd_dcache_compact_next( ctx->stake_out->chunk, stake_weights_sz, ctx->stake_out->chunk0, ctx->stake_out->wmark );
383382
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]));
384-
}
385-
fd_bank_next_epoch_stakes_end_locking_query( slot_ctx->bank );
383+
fd_bank_vote_states_end_locking_query( slot_ctx->bank );
384+
} while( 0 );
386385
}
387386

388387
static void

src/flamenco/rewards/fd_rewards.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,12 +1205,10 @@ fd_rewards_recalculate_partitioned_rewards( fd_exec_slot_ctx_t * slot_ctx,
12051205

12061206
fd_bank_stake_delegations_end_locking_modify( slot_ctx->bank );
12071207

1208-
fd_refresh_vote_accounts( slot_ctx,
1209-
stake_history,
1210-
new_warmup_cooldown_rate_epoch );
1211-
// fd_populate_vote_accounts( slot_ctx,
1212-
// stake_history,
1213-
// new_warmup_cooldown_rate_epoch );
1208+
fd_populate_vote_accounts(
1209+
slot_ctx,
1210+
stake_history,
1211+
new_warmup_cooldown_rate_epoch );
12141212
/* In future, the calculation will be cached in the snapshot, but for now we just re-calculate it
12151213
(as Agave does). */
12161214
fd_calculate_stake_vote_rewards_result_t calculate_stake_vote_rewards_result[1];

src/flamenco/runtime/context/fd_exec_slot_ctx.c

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -167,53 +167,6 @@ fd_exec_slot_ctx_recover( fd_exec_slot_ctx_t * slot_ctx,
167167
return 0;
168168
}
169169

170-
/* Move next EpochStakes */
171-
172-
fd_vote_accounts_global_t * next_epoch_stakes = fd_bank_next_epoch_stakes_locking_modify( slot_ctx->bank );
173-
uchar * next_epoch_stakes_pool_mem = (uchar *)fd_ulong_align_up( (ulong)next_epoch_stakes + sizeof(fd_vote_accounts_global_t), fd_vote_accounts_pair_global_t_map_align() );
174-
fd_vote_accounts_pair_global_t_mapnode_t * next_epoch_stakes_pool = fd_vote_accounts_pair_global_t_map_join( fd_vote_accounts_pair_global_t_map_new( next_epoch_stakes_pool_mem, 50000UL ) );
175-
fd_vote_accounts_pair_global_t_mapnode_t * next_epoch_stakes_root = NULL;
176-
177-
fd_vote_accounts_pair_global_t_mapnode_t * pool = vote_accounts_next_stakes_pool;
178-
fd_vote_accounts_pair_global_t_mapnode_t * root = vote_accounts_next_stakes_root;
179-
180-
uchar * acc_region_curr = (uchar *)fd_ulong_align_up( (ulong)next_epoch_stakes_pool + fd_vote_accounts_pair_global_t_map_footprint( 50000UL ), 8UL );
181-
182-
for( fd_vote_accounts_pair_global_t_mapnode_t * n = fd_vote_accounts_pair_global_t_map_minimum( pool, root );
183-
n;
184-
n = fd_vote_accounts_pair_global_t_map_successor( pool, n ) ) {
185-
186-
fd_vote_accounts_pair_global_t_mapnode_t * elem = fd_vote_accounts_pair_global_t_map_acquire( next_epoch_stakes_pool );
187-
FD_TEST( elem );
188-
189-
elem->elem.stake = n->elem.stake;
190-
elem->elem.key = n->elem.key;
191-
192-
elem->elem.value.lamports = n->elem.value.lamports;
193-
elem->elem.value.data_len = 0UL;
194-
elem->elem.value.data_offset = 0UL;
195-
elem->elem.value.owner = n->elem.value.owner;
196-
elem->elem.value.executable = n->elem.value.executable;
197-
elem->elem.value.rent_epoch = n->elem.value.rent_epoch;
198-
199-
elem->elem.value.data_offset = (ulong)(acc_region_curr - (uchar *)&elem->elem.value);;
200-
elem->elem.value.data_len = n->elem.value.data_len;
201-
202-
uchar * manifest_data = fd_solana_account_data_join( &n->elem.value );
203-
memcpy( acc_region_curr, manifest_data, n->elem.value.data_len );
204-
acc_region_curr += n->elem.value.data_len;
205-
206-
fd_vote_accounts_pair_global_t_map_insert(
207-
next_epoch_stakes_pool,
208-
&next_epoch_stakes_root,
209-
elem );
210-
211-
}
212-
fd_vote_accounts_vote_accounts_pool_update( next_epoch_stakes, next_epoch_stakes_pool );
213-
fd_vote_accounts_vote_accounts_root_update( next_epoch_stakes, next_epoch_stakes_root );
214-
fd_bank_next_epoch_stakes_end_locking_modify( slot_ctx->bank );
215-
216-
217170
/* Copy the vote states for the previous epoch E-2 */
218171

219172
fd_vote_states_t * vote_states_prev_prev = fd_vote_states_join( fd_vote_states_new( fd_bank_vote_states_prev_prev_locking_modify( slot_ctx->bank ), FD_RUNTIME_MAX_VOTE_ACCOUNTS ) );
@@ -230,9 +183,9 @@ fd_exec_slot_ctx_recover( fd_exec_slot_ctx_t * slot_ctx,
230183
/* Copy the vote states for the previous epoch E-1 */
231184

232185
fd_vote_states_t * vote_states_prev = fd_vote_states_join( fd_vote_states_new( fd_bank_vote_states_prev_locking_modify( slot_ctx->bank ), FD_RUNTIME_MAX_VOTE_ACCOUNTS ) );
233-
for( fd_vote_accounts_pair_global_t_mapnode_t * n = fd_vote_accounts_pair_global_t_map_minimum( pool, root );
186+
for( fd_vote_accounts_pair_global_t_mapnode_t * n = fd_vote_accounts_pair_global_t_map_minimum( vote_accounts_next_stakes_pool, vote_accounts_next_stakes_root );
234187
n;
235-
n = fd_vote_accounts_pair_global_t_map_successor( pool, n ) ) {
188+
n = fd_vote_accounts_pair_global_t_map_successor( vote_accounts_next_stakes_pool, n ) ) {
236189
uchar * account_data = fd_solana_account_data_join( &n->elem.value );
237190
ulong account_data_len = n->elem.value.data_len;
238191
fd_vote_states_update_from_account(

src/flamenco/runtime/fd_bank.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,6 @@ FD_PROTOTYPES_BEGIN
179179
X(fd_rent_t, rent, sizeof(fd_rent_t), alignof(fd_rent_t), 0, 0, 0 ) /* Rent */ \
180180
X(fd_slot_lthash_t, lthash, sizeof(fd_slot_lthash_t), alignof(fd_slot_lthash_t), 0, 0, 1 ) /* LTHash */ \
181181
X(fd_sysvar_cache_t, sysvar_cache, sizeof(fd_sysvar_cache_t), alignof(fd_sysvar_cache_t), 0, 0, 0 ) /* Sysvar cache */ \
182-
X(fd_vote_accounts_global_t, next_epoch_stakes, 200000000UL, 128UL, 1, 0, 1 ) /* Next epoch stakes, ~4K per account * 50k vote accounts */ \
183-
/* These are the stakes that determine the leader */ \
184-
/* schedule for the upcoming epoch. If we are executing */ \
185-
/* in epoch E, these are the stakes at the end of epoch */ \
186-
/* E-1 and they determined the leader schedule for epoch */ \
187-
/* E+1. */ \
188182
X(fd_epoch_rewards_t, epoch_rewards, FD_EPOCH_REWARDS_FOOTPRINT, FD_EPOCH_REWARDS_ALIGN, 1, 1, 1 ) /* Epoch rewards */ \
189183
X(fd_epoch_leaders_t, epoch_leaders, FD_RUNTIME_MAX_EPOCH_LEADERS, FD_EPOCH_LEADERS_ALIGN, 1, 1, 1 ) /* Epoch leaders. If our system supports 100k vote accs, */ \
190184
/* then there can be 100k unique leaders in the worst */ \
@@ -241,10 +235,6 @@ FD_PROTOTYPES_BEGIN
241235
#undef HAS_COW_0
242236
#undef HAS_COW_1
243237

244-
#define POOL_NAME fd_bank_next_epoch_stakes_pool
245-
#define POOL_T fd_bank_next_epoch_stakes_t
246-
#include "../../util/tmpl/fd_pool.c"
247-
248238
#define POOL_NAME fd_bank_epoch_leaders_pool
249239
#define POOL_T fd_bank_epoch_leaders_t
250240
#include "../../util/tmpl/fd_pool.c"

src/flamenco/runtime/fd_runtime.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,9 +1966,6 @@ fd_runtime_process_new_epoch( fd_exec_slot_ctx_t * slot_ctx,
19661966
new_rate_activation_epoch = NULL;
19671967
}
19681968

1969-
fd_epoch_info_t temp_info = {0};
1970-
fd_epoch_info_new( &temp_info );
1971-
19721969
/* If appropiate, use the stakes at T-1 to generate the leader schedule instead of T-2.
19731970
This is due to a subtlety in how Agave's stake caches interact when loading from snapshots.
19741971
See the comment in fd_exec_slot_ctx_recover_. */

src/flamenco/runtime/program/fd_vote_program.c

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,22 +1913,11 @@ do_process_vote_state_update( fd_vote_state_t * vote_state,
19131913
ctx );
19141914
}
19151915

1916-
// ??
19171916
ulong
1918-
fd_query_pubkey_stake( fd_pubkey_t const * pubkey, fd_vote_accounts_global_t const * vote_accounts ) {
1919-
fd_vote_accounts_pair_global_t_mapnode_t key = { 0 };
1920-
key.elem.key = *pubkey;
1917+
fd_query_pubkey_stake( fd_pubkey_t const * pubkey, fd_vote_states_t const * vote_states ) {
19211918

1922-
fd_vote_accounts_pair_global_t_mapnode_t * vote_accounts_pool = fd_vote_accounts_vote_accounts_pool_join( vote_accounts );
1923-
fd_vote_accounts_pair_global_t_mapnode_t * vote_accounts_root = fd_vote_accounts_vote_accounts_root_join( vote_accounts );
1924-
1925-
if( !vote_accounts_pool && !vote_accounts_root ) {
1926-
return 0;
1927-
}
1928-
1929-
fd_vote_accounts_pair_global_t_mapnode_t * vote_node = fd_vote_accounts_pair_global_t_map_find(
1930-
vote_accounts_pool, vote_accounts_root, &key );
1931-
return vote_node ? vote_node->elem.stake : 0;
1919+
fd_vote_state_ele_t * vote_state_ele = fd_vote_states_query( vote_states, pubkey );
1920+
return vote_state_ele ? vote_state_ele->stake : 0;
19321921
}
19331922

19341923
static int

src/flamenco/runtime/program/fd_vote_program.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fd_vote_state_versions_is_correct_and_initialized( fd_txn_account_t * vote_accou
5454
/* Queries the delegated stake amount for the given vote account pubkey,
5555
given the vote accounts map. Returns 0 if nonexistent. */
5656
ulong
57-
fd_query_pubkey_stake( fd_pubkey_t const * pubkey, fd_vote_accounts_global_t const * vote_accounts );
57+
fd_query_pubkey_stake( fd_pubkey_t const * pubkey, fd_vote_states_t const * vote_accounts );
5858

5959
/* An implementation of solana_sdk::transaction_context::BorrowedAccount::get_state
6060
for setting the vote state.

src/flamenco/runtime/tests/fd_dump_pb.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -403,13 +403,9 @@ create_block_context_protobuf_from_block( fd_exec_test_block_context_t * block_c
403403
ulong vote_account_t_cnt = fd_vote_states_cnt( vote_states );
404404
fd_bank_vote_states_end_locking_query( slot_ctx->bank );
405405

406-
407-
fd_vote_accounts_global_t const * next_epoch_stakes = fd_bank_next_epoch_stakes_locking_query( slot_ctx->bank );
408-
fd_vote_accounts_pair_global_t_mapnode_t * next_epoch_stakes_pool = fd_vote_accounts_vote_accounts_pool_join( next_epoch_stakes );
409-
fd_vote_accounts_pair_global_t_mapnode_t * next_epoch_stakes_root = fd_vote_accounts_vote_accounts_root_join( next_epoch_stakes );
410-
ulong vote_account_t_1_cnt = fd_vote_accounts_pair_global_t_map_size( next_epoch_stakes_pool,
411-
next_epoch_stakes_root );
412-
fd_bank_next_epoch_stakes_end_locking_query( slot_ctx->bank );
406+
fd_vote_states_t const * vote_states_prev = fd_bank_vote_states_prev_locking_query( slot_ctx->bank );
407+
ulong vote_account_t_1_cnt = fd_vote_states_cnt( vote_states_prev );
408+
fd_bank_vote_states_prev_end_locking_query( slot_ctx->bank );
413409

414410
fd_vote_states_t const * vote_states_prev_prev = fd_bank_vote_states_prev_prev_locking_query( slot_ctx->bank );
415411
ulong vote_account_t_2_cnt = fd_vote_states_cnt( vote_states_prev_prev );
@@ -507,7 +503,7 @@ create_block_context_protobuf_from_block( fd_exec_test_block_context_t * block_c
507503
fd_bank_vote_states_end_locking_query( slot_ctx->bank );
508504

509505
// BlockContext -> EpochContext -> vote_accounts_t_1 (vote accounts at epoch T-1)
510-
fd_vote_states_t const * vote_states_prev = fd_bank_vote_states_prev_locking_query( slot_ctx->bank );
506+
vote_states_prev = fd_bank_vote_states_prev_locking_query( slot_ctx->bank );
511507
dump_vote_accounts( slot_ctx,
512508
vote_states_prev,
513509
spad,

0 commit comments

Comments
 (0)