Skip to content

Commit 74967e7

Browse files
removing slot ctx in more places
1 parent e9c18e2 commit 74967e7

16 files changed

+348
-290
lines changed

src/app/ledger/main.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,10 @@ runtime_replay( fd_ledger_args_t * ledger_args ) {
284284

285285
ulong blk_txn_cnt = 0UL;
286286
FD_LOG_NOTICE(( "Used memory in spad before slot=%lu %lu", slot, ledger_args->runtime_spad->mem_used ));
287-
FD_TEST( fd_runtime_block_eval_tpool( ledger_args->slot_ctx,
288-
slot,
287+
FD_TEST( fd_runtime_block_eval_tpool( ledger_args->slot_ctx->banks,
288+
ledger_args->slot_ctx->bank,
289+
ledger_args->slot_ctx->funk,
290+
ledger_args->slot_ctx->funk_txn,
289291
blk,
290292
ledger_args->capture_ctx,
291293
ledger_args->tpool,
@@ -312,7 +314,7 @@ runtime_replay( fd_ledger_args_t * ledger_args ) {
312314
poh_hash ));
313315

314316
if( ledger_args->checkpt_mismatch ) {
315-
fd_runtime_checkpt( ledger_args->capture_ctx, ledger_args->slot_ctx, ULONG_MAX );
317+
fd_runtime_checkpt( ledger_args->capture_ctx, ledger_args->slot_ctx->funk, ULONG_MAX );
316318
}
317319
if( ledger_args->abort_on_mismatch ) {
318320
ret = 1;
@@ -340,7 +342,7 @@ runtime_replay( fd_ledger_args_t * ledger_args ) {
340342
bank_hash ));
341343

342344
if( ledger_args->checkpt_mismatch ) {
343-
fd_runtime_checkpt( ledger_args->capture_ctx, ledger_args->slot_ctx, ULONG_MAX );
345+
fd_runtime_checkpt( ledger_args->capture_ctx, ledger_args->slot_ctx->funk, ULONG_MAX );
344346
}
345347
if( ledger_args->abort_on_mismatch ) {
346348
ret = 1;

src/discof/replay/fd_replay_tile.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ funk_and_txncache_publish( fd_replay_tile_ctx_t * ctx, ulong wmk, fd_funk_txn_xi
636636
funk_publish( ctx, to_root_txn, wmk );
637637

638638
if( FD_UNLIKELY( ctx->capture_ctx ) ) {
639-
fd_runtime_checkpt( ctx->capture_ctx, ctx->slot_ctx, wmk );
639+
fd_runtime_checkpt( ctx->capture_ctx, ctx->slot_ctx->funk, wmk );
640640
}
641641

642642
}
@@ -906,7 +906,9 @@ prepare_new_block_execution( fd_replay_tile_ctx_t * ctx,
906906
int is_epoch_boundary = 0;
907907
/* TODO: Currently all of the epoch boundary/rewards logic is not
908908
multhreaded at the epoch boundary. */
909-
fd_runtime_block_pre_execute_process_new_epoch( ctx->slot_ctx,
909+
fd_runtime_block_pre_execute_process_new_epoch( ctx->slot_ctx->bank,
910+
ctx->slot_ctx->funk,
911+
ctx->slot_ctx->funk_txn,
910912
NULL,
911913
ctx->exec_spads,
912914
ctx->exec_spad_cnt,
@@ -1077,7 +1079,7 @@ exec_slice( fd_replay_tile_ctx_t * ctx,
10771079
/* Insert or reverify invoked programs for this epoch, if needed
10781080
FIXME: this should be done during txn parsing so that we don't have to loop
10791081
over all accounts a second time. */
1080-
fd_runtime_update_program_cache( ctx->slot_ctx, &txn_p, ctx->runtime_spad );
1082+
fd_runtime_update_program_cache( ctx->slot_ctx->bank, ctx->slot_ctx->funk, ctx->slot_ctx->funk_txn, &txn_p, ctx->runtime_spad );
10811083

10821084
fd_fork_t * fork = fd_fork_frontier_ele_query( ctx->forks->frontier,
10831085
&slot,

src/flamenco/rewards/fd_rewards.c

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -960,21 +960,23 @@ calculate_rewards_and_distribute_vote_rewards( fd_bank_t *
960960

961961
/* Distributes a single partitioned reward to a single stake account */
962962
static int
963-
distribute_epoch_reward_to_stake_acc( fd_exec_slot_ctx_t * slot_ctx,
963+
distribute_epoch_reward_to_stake_acc( fd_bank_t * bank,
964+
fd_funk_t * funk,
965+
fd_funk_txn_t * funk_txn,
964966
fd_pubkey_t * stake_pubkey,
965967
ulong reward_lamports,
966968
ulong new_credits_observed ) {
967969
FD_TXN_ACCOUNT_DECL( stake_acc_rec );
968970
if( FD_UNLIKELY( fd_txn_account_init_from_funk_mutable( stake_acc_rec,
969971
stake_pubkey,
970-
slot_ctx->funk,
971-
slot_ctx->funk_txn,
972+
funk,
973+
funk_txn,
972974
0,
973975
0UL ) != FD_ACC_MGR_SUCCESS ) ) {
974976
FD_LOG_ERR(( "Unable to modify stake account" ));
975977
}
976978

977-
stake_acc_rec->vt->set_slot( stake_acc_rec, slot_ctx->slot );
979+
stake_acc_rec->vt->set_slot( stake_acc_rec, bank->slot );
978980

979981
fd_stake_state_v2_t stake_state[1] = {0};
980982
if( fd_stake_get_state( stake_acc_rec, stake_state ) != 0 ) {
@@ -1000,20 +1002,20 @@ distribute_epoch_reward_to_stake_acc( fd_exec_slot_ctx_t * slot_ctx,
10001002
FD_LOG_ERR(( "write_stake_state failed" ));
10011003
}
10021004

1003-
fd_txn_account_mutable_fini( stake_acc_rec, slot_ctx->funk, slot_ctx->funk_txn );
1005+
fd_txn_account_mutable_fini( stake_acc_rec, funk, funk_txn );
10041006

10051007
return 0;
10061008
}
10071009

10081010
/* Sets the epoch reward status to inactive, and destroys any allocated state associated with the active state. */
10091011
static void
1010-
set_epoch_reward_status_inactive( fd_exec_slot_ctx_t * slot_ctx ) {
1011-
fd_epoch_reward_status_global_t * epoch_reward_status = fd_bank_epoch_reward_status_locking_modify( slot_ctx->bank );
1012+
set_epoch_reward_status_inactive( fd_bank_t * bank ) {
1013+
fd_epoch_reward_status_global_t * epoch_reward_status = fd_bank_epoch_reward_status_locking_modify( bank );
10121014
if( epoch_reward_status->discriminant == fd_epoch_reward_status_enum_Active ) {
10131015
FD_LOG_NOTICE(( "Done partitioning rewards for current epoch" ));
10141016
}
10151017
epoch_reward_status->discriminant = fd_epoch_reward_status_enum_Inactive;
1016-
fd_bank_epoch_reward_status_end_locking_modify( slot_ctx->bank );
1018+
fd_bank_epoch_reward_status_end_locking_modify( bank );
10171019
}
10181020

10191021
/* Sets the epoch reward status to active.
@@ -1061,7 +1063,9 @@ set_epoch_reward_status_active( fd_bank_t * bank,
10611063
static void
10621064
distribute_epoch_rewards_in_partition( fd_partitioned_stake_rewards_dlist_t * partition,
10631065
fd_stake_reward_t * pool,
1064-
fd_exec_slot_ctx_t * slot_ctx,
1066+
fd_bank_t * bank,
1067+
fd_funk_t * funk,
1068+
fd_funk_txn_t * funk_txn,
10651069
fd_spad_t * runtime_spad ) {
10661070

10671071
ulong lamports_distributed = 0UL;
@@ -1072,7 +1076,9 @@ distribute_epoch_rewards_in_partition( fd_partitioned_stake_rewards_dlist_t * pa
10721076
iter = fd_partitioned_stake_rewards_dlist_iter_fwd_next( iter, partition, pool ) ) {
10731077
fd_stake_reward_t * stake_reward = fd_partitioned_stake_rewards_dlist_iter_ele( iter, partition, pool );
10741078

1075-
if( distribute_epoch_reward_to_stake_acc( slot_ctx,
1079+
if( distribute_epoch_reward_to_stake_acc( bank,
1080+
funk,
1081+
funk_txn,
10761082
&stake_reward->stake_pubkey,
10771083
stake_reward->lamports,
10781084
stake_reward->credits_observed ) == 0 ) {
@@ -1083,33 +1089,30 @@ distribute_epoch_rewards_in_partition( fd_partitioned_stake_rewards_dlist_t * pa
10831089
}
10841090

10851091
/* Update the epoch rewards sysvar with the amount distributed and burnt */
1086-
fd_sysvar_epoch_rewards_distribute( slot_ctx,
1092+
fd_sysvar_epoch_rewards_distribute( bank,
1093+
funk,
1094+
funk_txn,
10871095
lamports_distributed + lamports_burned,
10881096
runtime_spad );
10891097

10901098
FD_LOG_DEBUG(( "lamports burned: %lu, lamports distributed: %lu", lamports_burned, lamports_distributed ));
10911099

1092-
fd_bank_capitalization_set( slot_ctx->bank, fd_bank_capitalization_get( slot_ctx->bank ) + lamports_distributed );
1100+
fd_bank_capitalization_set( bank, fd_bank_capitalization_get( bank ) + lamports_distributed );
10931101
}
10941102

10951103
/* Process reward distribution for the block if it is inside reward interval.
10961104
10971105
https://github.com/anza-xyz/agave/blob/cbc8320d35358da14d79ebcada4dfb6756ffac79/runtime/src/bank/partitioned_epoch_rewards/distribution.rs#L42 */
10981106
void
1099-
fd_distribute_partitioned_epoch_rewards( fd_exec_slot_ctx_t * slot_ctx,
1100-
fd_tpool_t * tpool,
1101-
fd_spad_t * * exec_spads,
1102-
ulong exec_spad_cnt,
1103-
fd_spad_t * runtime_spad ) {
1104-
1105-
(void)tpool;
1106-
(void)exec_spads;
1107-
(void)exec_spad_cnt;
1107+
fd_distribute_partitioned_epoch_rewards( fd_bank_t * bank,
1108+
fd_funk_t * funk,
1109+
fd_funk_txn_t * funk_txn,
1110+
fd_spad_t * runtime_spad ) {
11081111

1109-
fd_epoch_reward_status_global_t const * epoch_reward_status = fd_bank_epoch_reward_status_locking_query( slot_ctx->bank );
1112+
fd_epoch_reward_status_global_t const * epoch_reward_status = fd_bank_epoch_reward_status_locking_query( bank );
11101113

11111114
if( epoch_reward_status->discriminant == fd_epoch_reward_status_enum_Inactive ) {
1112-
fd_bank_epoch_reward_status_end_locking_query( slot_ctx->bank );
1115+
fd_bank_epoch_reward_status_end_locking_query( bank );
11131116
return;
11141117
}
11151118

@@ -1123,12 +1126,12 @@ fd_distribute_partitioned_epoch_rewards( fd_exec_slot_ctx_t * slot_ctx,
11231126
FD_LOG_CRIT(( "Failed to join pool" ));
11241127
}
11251128

1126-
ulong height = fd_bank_block_height_get( slot_ctx->bank );
1129+
ulong height = fd_bank_block_height_get( bank );
11271130
ulong distribution_starting_block_height = status->distribution_starting_block_height;
11281131
ulong distribution_end_exclusive = distribution_starting_block_height + status->partitioned_stake_rewards.partitions_len;
11291132

1130-
fd_epoch_schedule_t const * epoch_schedule = fd_bank_epoch_schedule_query( slot_ctx->bank );
1131-
ulong epoch = fd_slot_to_epoch( epoch_schedule, slot_ctx->slot, NULL );
1133+
fd_epoch_schedule_t const * epoch_schedule = fd_bank_epoch_schedule_query( bank );
1134+
ulong epoch = fd_slot_to_epoch( epoch_schedule, bank->slot, NULL );
11321135

11331136
if( FD_UNLIKELY( get_slots_in_epoch( epoch, epoch_schedule ) <= status->partitioned_stake_rewards.partitions_len ) ) {
11341137
FD_LOG_ERR(( "Should not be distributing rewards" ));
@@ -1138,16 +1141,18 @@ fd_distribute_partitioned_epoch_rewards( fd_exec_slot_ctx_t * slot_ctx,
11381141
ulong partition_index = height - distribution_starting_block_height;
11391142
distribute_epoch_rewards_in_partition( &partitions[ partition_index ],
11401143
pool,
1141-
slot_ctx,
1144+
bank,
1145+
funk,
1146+
funk_txn,
11421147
runtime_spad );
11431148
}
11441149

1145-
fd_bank_epoch_reward_status_end_locking_query( slot_ctx->bank );
1150+
fd_bank_epoch_reward_status_end_locking_query( bank );
11461151

11471152
/* If we have finished distributing rewards, set the status to inactive */
11481153
if( fd_ulong_sat_add( height, 1UL ) >= distribution_end_exclusive ) {
1149-
set_epoch_reward_status_inactive( slot_ctx );
1150-
fd_sysvar_epoch_rewards_set_inactive( slot_ctx, runtime_spad );
1154+
set_epoch_reward_status_inactive( bank );
1155+
fd_sysvar_epoch_rewards_set_inactive( bank, funk, funk_txn, runtime_spad );
11511156
}
11521157
}
11531158

@@ -1217,7 +1222,7 @@ fd_rewards_recalculate_partitioned_rewards( fd_exec_slot_ctx_t * slot_ctx,
12171222
fd_sysvar_epoch_rewards_t * epoch_rewards = fd_sysvar_epoch_rewards_read( slot_ctx->funk, slot_ctx->funk_txn, runtime_spad );
12181223
if( FD_UNLIKELY( epoch_rewards == NULL ) ) {
12191224
FD_LOG_NOTICE(( "Failed to read or decode epoch rewards sysvar - may not have been created yet" ));
1220-
set_epoch_reward_status_inactive( slot_ctx );
1225+
set_epoch_reward_status_inactive( slot_ctx->bank );
12211226
return;
12221227
}
12231228

@@ -1338,6 +1343,6 @@ fd_rewards_recalculate_partitioned_rewards( fd_exec_slot_ctx_t * slot_ctx,
13381343
epoch_rewards->distribution_starting_block_height,
13391344
&stake_rewards_by_partition->partitioned_stake_rewards );
13401345
} else {
1341-
set_epoch_reward_status_inactive( slot_ctx );
1346+
set_epoch_reward_status_inactive( slot_ctx->bank );
13421347
}
13431348
}

src/flamenco/rewards/fd_rewards.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,10 @@ fd_rewards_recalculate_partitioned_rewards( fd_exec_slot_ctx_t * slot_ctx,
5454
fd_spad_t * runtime_spad );
5555

5656
void
57-
fd_distribute_partitioned_epoch_rewards( fd_exec_slot_ctx_t * slot_ctx,
58-
fd_tpool_t * tpool,
59-
fd_spad_t * * exec_spads,
60-
ulong exec_spad_cnt,
61-
fd_spad_t * runtime_spad );
57+
fd_distribute_partitioned_epoch_rewards( fd_bank_t * bank,
58+
fd_funk_t * funk,
59+
fd_funk_txn_t * funk_txn,
60+
fd_spad_t * runtime_spad );
6261

6362
FD_PROTOTYPES_END
6463

src/flamenco/runtime/fd_cost_tracker.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,12 @@ add_transaction_cost( fd_cost_tracker_t * self,
318318
/** PUBLIC FUNCTIONS ***/
319319

320320
void
321-
fd_cost_tracker_init( fd_cost_tracker_t * self,
322-
fd_exec_slot_ctx_t const * slot_ctx,
323-
fd_spad_t * spad ) {
321+
fd_cost_tracker_init( fd_cost_tracker_t * self,
322+
fd_bank_t * bank,
323+
fd_spad_t * spad ) {
324324
// Set limits appropriately
325325
self->account_cost_limit = FD_MAX_WRITABLE_ACCOUNT_UNITS;
326-
self->block_cost_limit = FD_FEATURE_ACTIVE_BANK( slot_ctx->bank, raise_block_limits_to_50m ) ? FD_MAX_BLOCK_UNITS_SIMD_0207 : FD_MAX_BLOCK_UNITS;
326+
self->block_cost_limit = FD_FEATURE_ACTIVE_BANK( bank, raise_block_limits_to_50m ) ? FD_MAX_BLOCK_UNITS_SIMD_0207 : FD_MAX_BLOCK_UNITS;
327327
self->vote_cost_limit = FD_MAX_VOTE_UNITS;
328328

329329
/* Init cost tracker map

src/flamenco/runtime/fd_cost_tracker.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ FD_PROTOTYPES_BEGIN
4848

4949
/* Initializes the cost tracker and allocates enough memory for the map */
5050
void
51-
fd_cost_tracker_init( fd_cost_tracker_t * self,
52-
fd_exec_slot_ctx_t const * slot_ctx,
53-
fd_spad_t * spad );
51+
fd_cost_tracker_init( fd_cost_tracker_t * self,
52+
fd_bank_t * bank,
53+
fd_spad_t * spad );
5454

5555
/* Modeled after `CostModel::calculate_cost_for_executed_transaction()`.
5656
Used to compute transaction cost information for executed transactions.

0 commit comments

Comments
 (0)