Skip to content

Commit c54cf3e

Browse files
wip
1 parent c1674f2 commit c54cf3e

File tree

11 files changed

+22
-30
lines changed

11 files changed

+22
-30
lines changed

src/flamenco/runtime/context/fd_exec_txn_ctx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ fd_txn_account_has_bpf_loader_upgradeable( const fd_pubkey_t * account_keys,
214214
int
215215
fd_exec_txn_ctx_account_is_writable_idx( fd_exec_txn_ctx_t const * txn_ctx, ushort idx ) {
216216
uint bpf_upgradeable = fd_txn_account_has_bpf_loader_upgradeable( txn_ctx->account_keys, txn_ctx->accounts_cnt );
217-
return fd_exec_txn_account_is_writable_idx_flat( txn_ctx->slot,
217+
return fd_exec_txn_account_is_writable_idx_flat( fd_bank_slot_get( txn_ctx->bank ),
218218
idx,
219219
&txn_ctx->account_keys[idx],
220220
TXN( &txn_ctx->txn ),

src/flamenco/runtime/context/fd_exec_txn_ctx.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ struct fd_exec_txn_ctx {
5454
fd_bank_hash_cmp_t * bank_hash_cmp;
5555
fd_txn_p_t txn;
5656

57-
ulong slot;
58-
5957
/* LOG COLLECTOR ****************************************/
6058

6159
int enable_exec_recording;
@@ -75,9 +73,9 @@ struct fd_exec_txn_ctx {
7573
That is the limit we are going to use here. */
7674
ulong accounts_cnt; /* Number of account pubkeys accessed by this transaction. */
7775
fd_pubkey_t account_keys[ MAX_TX_ACCOUNT_LOCKS ]; /* Array of account pubkeys accessed by this transaction. */
76+
fd_txn_account_t accounts[ MAX_TX_ACCOUNT_LOCKS ]; /* Array of borrowed accounts accessed by this transaction. */
7877
ulong executable_cnt; /* Number of BPF upgradeable loader accounts. */
7978
fd_txn_account_t executable_accounts[ MAX_TX_ACCOUNT_LOCKS ]; /* Array of BPF upgradeable loader program data accounts */
80-
fd_txn_account_t accounts[ MAX_TX_ACCOUNT_LOCKS ]; /* Array of borrowed accounts accessed by this transaction. */
8179

8280
/* When a program is deployed or upgraded, we must queue it to be
8381
updated in the program cache (if it exists already) so that

src/flamenco/runtime/fd_executor.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ fd_executor_setup_txn_alut_account_keys( fd_exec_txn_ctx_t * txn_ctx ) {
10461046
txn_ctx->txn.payload,
10471047
txn_ctx->funk,
10481048
txn_ctx->xid,
1049-
txn_ctx->slot,
1049+
fd_bank_slot_get( txn_ctx->bank ),
10501050
slot_hashes,
10511051
accts_alt );
10521052
fd_sysvar_cache_slot_hashes_leave_const( sysvar_cache, slot_hashes );
@@ -1346,7 +1346,7 @@ fd_execute_instr( fd_exec_txn_ctx_t * txn_ctx,
13461346
void
13471347
fd_executor_reclaim_account( fd_exec_txn_ctx_t * txn_ctx,
13481348
fd_txn_account_t * account ) {
1349-
fd_txn_account_set_slot( account, txn_ctx->slot );
1349+
fd_txn_account_set_slot( account, fd_bank_slot_get( txn_ctx->bank ) );
13501350
if( FD_UNLIKELY( fd_txn_account_get_lamports( account )==0UL ) ) {
13511351
fd_txn_account_set_data_len( account, 0UL );
13521352
fd_txn_account_clear_owner( account );
@@ -1383,8 +1383,6 @@ fd_exec_txn_ctx_setup( fd_bank_t * bank,
13831383
ctx->enable_exec_recording = !!( bank->flags & FD_BANK_FLAGS_EXEC_RECORDING );
13841384

13851385
ctx->bank = bank;
1386-
1387-
ctx->slot = fd_bank_slot_get( bank );
13881386
}
13891387

13901388
fd_txn_account_t *
@@ -1533,7 +1531,7 @@ fd_executor_setup_accounts_for_txn( fd_exec_txn_ctx_t * txn_ctx ) {
15331531

15341532
/* Dumping ELF files to protobuf, if applicable */
15351533
int dump_elf_to_pb = txn_ctx->capture_ctx &&
1536-
txn_ctx->slot >= txn_ctx->capture_ctx->dump_proto_start_slot &&
1534+
fd_bank_slot_get( txn_ctx->bank ) >= txn_ctx->capture_ctx->dump_proto_start_slot &&
15371535
txn_ctx->capture_ctx->dump_elf_to_pb;
15381536
if( FD_UNLIKELY( dump_elf_to_pb ) ) {
15391537
for( ushort i=0; i<txn_ctx->accounts_cnt; i++ ) {
@@ -1569,7 +1567,7 @@ fd_executor_txn_verify( fd_txn_p_t * txn_p,
15691567
int
15701568
fd_execute_txn( fd_exec_txn_ctx_t * txn_ctx ) {
15711569

1572-
bool dump_insn = txn_ctx->capture_ctx && txn_ctx->slot >= txn_ctx->capture_ctx->dump_proto_start_slot && txn_ctx->capture_ctx->dump_instr_to_pb;
1570+
bool dump_insn = txn_ctx->capture_ctx && fd_bank_slot_get( txn_ctx->bank ) >= txn_ctx->capture_ctx->dump_proto_start_slot && txn_ctx->capture_ctx->dump_instr_to_pb;
15731571

15741572
/* Initialize log collection */
15751573
fd_log_collector_init( &txn_ctx->log_collector, txn_ctx->enable_exec_recording );

src/flamenco/runtime/fd_runtime.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ fd_runtime_pre_execute_check( fd_exec_txn_ctx_t * txn_ctx ) {
607607
*/
608608

609609
uchar dump_txn = !!( txn_ctx->capture_ctx &&
610-
txn_ctx->slot >= txn_ctx->capture_ctx->dump_proto_start_slot &&
610+
fd_bank_slot_get( txn_ctx->bank ) >= txn_ctx->capture_ctx->dump_proto_start_slot &&
611611
txn_ctx->capture_ctx->dump_txn_to_pb );
612612
if( FD_UNLIKELY( dump_txn ) ) {
613613
fd_dump_txn_to_protobuf( txn_ctx );
@@ -1042,16 +1042,13 @@ fd_runtime_prepare_and_execute_txn( fd_banks_t * banks,
10421042
FD_LOG_CRIT(( "Could not get bank at pool idx %lu", bank_idx ));
10431043
}
10441044

1045-
ulong slot = fd_bank_slot_get( bank );
1046-
10471045
/* FIXME: The transaction setup code is super messy and needs to be
10481046
refactored. */
10491047

10501048
/* Setup and execute the transaction. */
10511049
txn_ctx->bank = bank;
1052-
txn_ctx->slot = fd_bank_slot_get( bank );
10531050
txn_ctx->enable_exec_recording = !!( bank->flags & FD_BANK_FLAGS_EXEC_RECORDING );
1054-
txn_ctx->xid[0] = (fd_funk_txn_xid_t){ .ul = { slot, bank_idx } };
1051+
txn_ctx->xid[0] = (fd_funk_txn_xid_t){ .ul = { fd_bank_slot_get( bank ), bank_idx } };
10551052
txn_ctx->txn = *txn;
10561053
txn_ctx->exec_stack = exec_stack;
10571054
txn_ctx->exec_accounts = exec_accounts;

src/flamenco/runtime/program/fd_bpf_loader_program.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@ fd_deploy_program( fd_exec_instr_ctx_t * instr_ctx,
139139
}
140140

141141
fd_vm_syscall_register_slot( syscalls,
142-
instr_ctx->txn_ctx->slot,
142+
fd_bank_slot_get( instr_ctx->txn_ctx->bank ),
143143
fd_bank_features_query( instr_ctx->txn_ctx->bank ),
144144
1 );
145145

146146
/* Load executable */
147147
fd_sbpf_elf_info_t elf_info[ 1UL ];
148-
fd_prog_versions_t versions = fd_prog_versions( fd_bank_features_query( instr_ctx->txn_ctx->bank ), instr_ctx->txn_ctx->slot );
148+
fd_prog_versions_t versions = fd_prog_versions( fd_bank_features_query( instr_ctx->txn_ctx->bank ), fd_bank_slot_get( instr_ctx->txn_ctx->bank ) );
149149

150150
fd_sbpf_loader_config_t config = { 0 };
151151
config.elf_deploy_checks = deploy_mode;
@@ -386,7 +386,7 @@ fd_bpf_execute( fd_exec_instr_ctx_t * instr_ctx,
386386

387387
/* TODO do we really need to re-do this on every instruction? */
388388
fd_vm_syscall_register_slot( syscalls,
389-
instr_ctx->txn_ctx->slot,
389+
fd_bank_slot_get( instr_ctx->txn_ctx->bank ),
390390
fd_bank_features_query( instr_ctx->txn_ctx->bank ),
391391
0 );
392392

@@ -429,7 +429,7 @@ fd_bpf_execute( fd_exec_instr_ctx_t * instr_ctx,
429429

430430
/* For dumping syscalls for seed corpora */
431431
int dump_syscall_to_pb = instr_ctx->txn_ctx->capture_ctx &&
432-
instr_ctx->txn_ctx->slot >= instr_ctx->txn_ctx->capture_ctx->dump_proto_start_slot &&
432+
fd_bank_slot_get( instr_ctx->txn_ctx->bank ) >= instr_ctx->txn_ctx->capture_ctx->dump_proto_start_slot &&
433433
instr_ctx->txn_ctx->capture_ctx->dump_syscall_to_pb;
434434

435435
/* TODO: (topointon): correctly set check_size in vm setup */
@@ -2559,7 +2559,7 @@ fd_bpf_loader_program_execute( fd_exec_instr_ctx_t * ctx ) {
25592559
}
25602560

25612561
ulong program_data_slot = program_data_account_state->inner.program_data.slot;
2562-
if( FD_UNLIKELY( program_data_slot>=ctx->txn_ctx->slot ) ) {
2562+
if( FD_UNLIKELY( program_data_slot>=fd_bank_slot_get( ctx->txn_ctx->bank ) ) ) {
25632563
/* The account was likely just deployed or upgraded. Corresponds to
25642564
'LoadedProgramType::DelayVisibility' */
25652565
fd_log_collector_msg_literal( ctx, "Program is not deployed" );

src/flamenco/runtime/program/fd_builtin_programs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ fd_is_migrating_builtin_program( fd_exec_txn_ctx_t const * txn_ctx,
353353
fd_core_bpf_migration_config_t const * config = migrating_builtins[i];
354354
if( !memcmp( pubkey->uc, config->builtin_program_id->key, sizeof(fd_pubkey_t) ) ) {
355355
if( config->enable_feature_offset!=NO_ENABLE_FEATURE_ID &&
356-
FD_FEATURE_ACTIVE_OFFSET( txn_ctx->slot, fd_bank_features_query( txn_ctx->bank ), config->enable_feature_offset ) ) {
356+
FD_FEATURE_ACTIVE_OFFSET( fd_bank_slot_get( txn_ctx->bank ), fd_bank_features_query( txn_ctx->bank ), config->enable_feature_offset ) ) {
357357
/* The program has been migrated to BPF. */
358358
*migrated_yet = 1;
359359
}

src/flamenco/runtime/program/fd_loader_v4_program.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ fd_loader_v4_program_execute( fd_exec_instr_ctx_t * instr_ctx ) {
902902
}
903903

904904
/* Handle `DelayedVisibility` case */
905-
if( FD_UNLIKELY( state->slot>=instr_ctx->txn_ctx->slot ) ) {
905+
if( FD_UNLIKELY( state->slot>=fd_bank_slot_get( instr_ctx->txn_ctx->bank ) ) ) {
906906
fd_log_collector_msg_literal( instr_ctx, "Program is not deployed" );
907907
return FD_EXECUTOR_INSTR_ERR_UNSUPPORTED_PROGRAM_ID;
908908
}

src/flamenco/runtime/program/fd_stake_program.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ get_if_mergeable( fd_exec_instr_ctx_t * invoke_context, // not const to
851851
int is_some = fd_new_warmup_cooldown_rate_epoch(
852852
epoch_schedule,
853853
fd_bank_features_query( invoke_context->txn_ctx->bank ),
854-
invoke_context->txn_ctx->slot,
854+
fd_bank_slot_get( invoke_context->txn_ctx->bank ),
855855
&new_rate_activation_epoch,
856856
&err );
857857
if( FD_UNLIKELY( err ) ) return err;
@@ -1170,7 +1170,7 @@ get_stake_status( fd_exec_instr_ctx_t const * invoke_context,
11701170
int is_some = fd_new_warmup_cooldown_rate_epoch(
11711171
epoch_schedule,
11721172
fd_bank_features_query( invoke_context->txn_ctx->bank ),
1173-
invoke_context->txn_ctx->slot,
1173+
fd_bank_slot_get( invoke_context->txn_ctx->bank ),
11741174
&new_rate_activation_epoch,
11751175
&err );
11761176
if( FD_UNLIKELY( err ) ) return err;
@@ -1216,7 +1216,7 @@ redelegate_stake( fd_exec_instr_ctx_t const * ctx,
12161216
int is_some = fd_new_warmup_cooldown_rate_epoch(
12171217
epoch_schedule,
12181218
fd_bank_features_query( ctx->txn_ctx->bank ),
1219-
ctx->txn_ctx->slot,
1219+
fd_bank_slot_get( ctx->txn_ctx->bank ),
12201220
&new_rate_activation_epoch,
12211221
&err );
12221222
if( FD_UNLIKELY( err ) ) return err;
@@ -2872,7 +2872,7 @@ fd_stake_program_execute( fd_exec_instr_ctx_t * ctx ) {
28722872
int is_some = fd_new_warmup_cooldown_rate_epoch(
28732873
epoch_schedule,
28742874
fd_bank_features_query( ctx->txn_ctx->bank ),
2875-
ctx->txn_ctx->slot,
2875+
fd_bank_slot_get( ctx->txn_ctx->bank ),
28762876
&new_rate_activation_epoch,
28772877
&err );
28782878
if( FD_UNLIKELY( err ) ) return err;

src/flamenco/runtime/tests/fd_dump_pb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ create_txn_context_protobuf_from_txn( fd_exec_test_txn_context_t * txn_context_m
881881

882882
/* Transaction Context -> slot_ctx */
883883
txn_context_msg->has_slot_ctx = true;
884-
txn_context_msg->slot_ctx.slot = txn_ctx->slot;
884+
txn_context_msg->slot_ctx.slot = fd_bank_slot_get( txn_ctx->bank );
885885
}
886886

887887
static void
@@ -1253,7 +1253,7 @@ FD_SPAD_FRAME_BEGIN( spad ) {
12531253
txn_ctx->capture_ctx->dump_proto_output_dir,
12541254
encoded_signature,
12551255
FD_BASE58_ENC_32_ALLOCA( program_acc->pubkey ),
1256-
txn_ctx->slot );
1256+
fd_bank_slot_get( txn_ctx->bank ) );
12571257

12581258
/* The generated filename should be unique for every call. Silently return otherwise. */
12591259
if( FD_UNLIKELY( access( filename, F_OK )!=-1 ) ) {

src/flamenco/runtime/tests/fd_vm_harness.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ do{
211211
/* Setup syscalls. Have them all be no-ops */
212212
fd_sbpf_syscalls_t * syscalls = fd_sbpf_syscalls_new( fd_spad_alloc_check( spad, fd_sbpf_syscalls_align(), fd_sbpf_syscalls_footprint() ) );
213213
fd_vm_syscall_register_slot( syscalls,
214-
instr_ctx->txn_ctx->slot,
214+
fd_bank_slot_get( instr_ctx->txn_ctx->bank ),
215215
fd_bank_features_query( instr_ctx->txn_ctx->bank ),
216216
0 );
217217

0 commit comments

Comments
 (0)