Skip to content

Commit ebe465d

Browse files
wip txn in
1 parent a955f35 commit ebe465d

File tree

10 files changed

+41
-28
lines changed

10 files changed

+41
-28
lines changed

src/flamenco/runtime/fd_executor.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,7 +1576,7 @@ fd_executor_setup_accounts_for_txn( fd_runtime_t * runtime,
15761576
txn_ctx->log.capture_ctx->dump_elf_to_pb;
15771577
if( FD_UNLIKELY( dump_elf_to_pb ) ) {
15781578
for( ushort i=0; i<txn_out->accounts.accounts_cnt; i++ ) {
1579-
fd_dump_elf_to_protobuf( runtime, txn_ctx, &txn_out->accounts.accounts[i] );
1579+
fd_dump_elf_to_protobuf( runtime, txn_in, txn_ctx, &txn_out->accounts.accounts[i] );
15801580
}
15811581
}
15821582
# endif
@@ -1623,7 +1623,7 @@ fd_execute_txn( fd_runtime_t * runtime,
16231623
# if FD_HAS_FLATCC
16241624
if( FD_UNLIKELY( dump_insn ) ) {
16251625
// Capture the input and convert it into a Protobuf message
1626-
fd_dump_instr_to_protobuf( runtime, txn_out, txn_ctx, &runtime->instr.infos[i], i );
1626+
fd_dump_instr_to_protobuf( runtime, txn_in, txn_out, txn_ctx, &runtime->instr.infos[i], i );
16271627
}
16281628
# endif
16291629

src/flamenco/runtime/fd_runtime.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ fd_runtime_pre_execute_check( fd_runtime_t * runtime,
608608
fd_bank_slot_get( txn_ctx->bank ) >= txn_ctx->log.capture_ctx->dump_proto_start_slot &&
609609
txn_ctx->log.capture_ctx->dump_txn_to_pb );
610610
if( FD_UNLIKELY( dump_txn ) ) {
611-
fd_dump_txn_to_protobuf( runtime, txn_out, txn_ctx );
611+
fd_dump_txn_to_protobuf( runtime, txn_in, txn_out, txn_ctx );
612612
}
613613
# endif
614614

@@ -1030,7 +1030,7 @@ fd_runtime_commit_txn( fd_runtime_t * runtime,
10301030
int
10311031
fd_runtime_prepare_and_execute_txn( fd_runtime_t * runtime,
10321032
fd_bank_t * bank,
1033-
fd_txn_in_t * txn_in,
1033+
fd_txn_in_t const * txn_in,
10341034
fd_exec_txn_ctx_t * txn_ctx,
10351035
fd_txn_out_t * txn_out,
10361036
fd_capture_ctx_t * capture_ctx,

src/flamenco/runtime/fd_runtime.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ fd_runtime_pre_execute_check( fd_runtime_t * runtime,
399399
int
400400
fd_runtime_prepare_and_execute_txn( fd_runtime_t * runtime,
401401
fd_bank_t * bank,
402-
fd_txn_in_t * txn_in,
402+
fd_txn_in_t const * txn_in,
403403
fd_exec_txn_ctx_t * txn_ctx,
404404
fd_txn_out_t * txn_out,
405405
fd_capture_ctx_t * capture_ctx,

src/flamenco/runtime/tests/fd_block_harness.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,9 +487,10 @@ fd_solfuzz_block_ctx_exec( fd_solfuzz_runner_t * runner,
487487

488488
/* Execute the transaction against the runtime */
489489
res = FD_RUNTIME_EXECUTE_SUCCESS;
490+
fd_txn_in_t txn_in = { .txn = *txn };
490491
fd_txn_out_t txn_out;
491492
fd_runtime_t runtime;
492-
fd_exec_txn_ctx_t * txn_ctx = fd_solfuzz_txn_ctx_exec( runner, &runtime, txn, &res, &txn_out );
493+
fd_exec_txn_ctx_t * txn_ctx = fd_solfuzz_txn_ctx_exec( runner, &runtime, &txn_in, &res, &txn_out );
493494
txn_out.err.exec_err = res;
494495

495496
if( FD_UNLIKELY( !txn_out.err.is_committable ) ) {
@@ -500,6 +501,7 @@ fd_solfuzz_block_ctx_exec( fd_solfuzz_runner_t * runner,
500501
fd_runtime_commit_txn(
501502
&runtime,
502503
runner->bank,
504+
&txn_in,
503505
&txn_out,
504506
txn_ctx,
505507
capture_ctx,

src/flamenco/runtime/tests/fd_dump_pb.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -752,11 +752,12 @@ create_block_context_protobuf_from_block( fd_block_dump_ctx_t * dump_ctx,
752752
static void
753753
create_txn_context_protobuf_from_txn( fd_exec_test_txn_context_t * txn_context_msg,
754754
fd_runtime_t * runtime,
755-
fd_txn_out_t * txn_out,
756-
fd_exec_txn_ctx_t * txn_ctx,
755+
fd_bank_t * bank,
756+
fd_txn_in_t const * txn_in,
757+
fd_txn_out_t * txn_out,
757758
fd_spad_t * spad ) {
758-
fd_txn_t const * txn_descriptor = TXN( &txn_ctx->txn );
759-
uchar const * txn_payload = (uchar const *) txn_ctx->txn.payload;
759+
fd_txn_t const * txn_descriptor = TXN( &txn_in->txn );
760+
uchar const * txn_payload = (uchar const *) txn_in->txn.payload;
760761

761762
/* Transaction Context -> account_shared_data
762763
Contains:
@@ -772,7 +773,7 @@ create_txn_context_protobuf_from_txn( fd_exec_test_txn_context_t * txn_context_m
772773
txn_context_msg->account_shared_data = fd_spad_alloc( spad,
773774
alignof(fd_exec_test_acct_state_t),
774775
(256UL*2UL + txn_descriptor->addr_table_lookup_cnt + num_sysvar_entries) * sizeof(fd_exec_test_acct_state_t) );
775-
fd_funk_txn_xid_t xid = { .ul = { fd_bank_slot_get( txn_ctx->bank ), txn_ctx->bank->idx } };
776+
fd_funk_txn_xid_t xid = { .ul = { fd_bank_slot_get( bank ), bank->idx } };
776777
for( ulong i = 0; i < txn_out->accounts.accounts_cnt; ++i ) {
777778
fd_txn_account_t txn_account[1];
778779
int ret = fd_txn_account_init_from_funk_readonly( txn_account, &txn_out->accounts.account_keys[i], runtime->funk, &xid );
@@ -873,17 +874,17 @@ create_txn_context_protobuf_from_txn( fd_exec_test_txn_context_t * txn_context_m
873874
alignof(pb_bytes_array_t *),
874875
PB_BYTES_ARRAY_T_ALLOCSIZE((FD_BLOCKHASHES_MAX) * sizeof(pb_bytes_array_t *)) );
875876
txn_context_msg->blockhash_queue = output_blockhash_queue;
876-
fd_blockhashes_t const * block_hash_queue = fd_bank_block_hash_queue_query( txn_ctx->bank );
877+
fd_blockhashes_t const * block_hash_queue = fd_bank_block_hash_queue_query( bank );
877878
dump_blockhash_queue( block_hash_queue, spad, output_blockhash_queue, &txn_context_msg->blockhash_queue_count );
878879

879880
/* Transaction Context -> epoch_ctx */
880881
txn_context_msg->has_epoch_ctx = true;
881882
txn_context_msg->epoch_ctx.has_features = true;
882-
dump_sorted_features( fd_bank_features_query( txn_ctx->bank ), &txn_context_msg->epoch_ctx.features, spad );
883+
dump_sorted_features( fd_bank_features_query( bank ), &txn_context_msg->epoch_ctx.features, spad );
883884

884885
/* Transaction Context -> slot_ctx */
885886
txn_context_msg->has_slot_ctx = true;
886-
txn_context_msg->slot_ctx.slot = fd_bank_slot_get( txn_ctx->bank );
887+
txn_context_msg->slot_ctx.slot = fd_bank_slot_get( bank );
887888
}
888889

889890
static void
@@ -985,6 +986,7 @@ create_instr_context_protobuf_from_instructions( fd_exec_test_instr_context_t *
985986

986987
void
987988
fd_dump_instr_to_protobuf( fd_runtime_t * runtime,
989+
fd_txn_in_t const * txn_in,
988990
fd_txn_out_t * txn_out,
989991
fd_exec_txn_ctx_t * txn_ctx,
990992
fd_instr_info_t * instr,
@@ -993,7 +995,7 @@ fd_dump_instr_to_protobuf( fd_runtime_t * runtime,
993995

994996
FD_SPAD_FRAME_BEGIN( spad ) {
995997
// Get base58-encoded tx signature
996-
const fd_ed25519_sig_t * signatures = fd_txn_get_signatures( TXN( &txn_ctx->txn ), txn_ctx->txn.payload );
998+
const fd_ed25519_sig_t * signatures = fd_txn_get_signatures( TXN( &txn_in->txn ), txn_in->txn.payload );
997999
fd_ed25519_sig_t signature; fd_memcpy( signature, signatures[0], sizeof(fd_ed25519_sig_t) );
9981000
char encoded_signature[FD_BASE58_ENCODED_64_SZ];
9991001
ulong out_size;
@@ -1029,13 +1031,14 @@ fd_dump_instr_to_protobuf( fd_runtime_t * runtime,
10291031

10301032
void
10311033
fd_dump_txn_to_protobuf( fd_runtime_t * runtime,
1034+
fd_txn_in_t const * txn_in,
10321035
fd_txn_out_t * txn_out,
10331036
fd_exec_txn_ctx_t * txn_ctx ) {
10341037
fd_spad_t * spad = fd_spad_join( fd_spad_new( txn_ctx->log.dumping_mem, 1UL<<28UL ) );
10351038

10361039
FD_SPAD_FRAME_BEGIN( spad ) {
10371040
// Get base58-encoded tx signature
1038-
const fd_ed25519_sig_t * signatures = fd_txn_get_signatures( TXN( &txn_ctx->txn ), txn_ctx->txn.payload );
1041+
const fd_ed25519_sig_t * signatures = fd_txn_get_signatures( TXN( &txn_in->txn ), txn_in->txn.payload );
10391042
fd_ed25519_sig_t signature; fd_memcpy( signature, signatures[0], sizeof(fd_ed25519_sig_t) );
10401043
char encoded_signature[FD_BASE58_ENCODED_64_SZ];
10411044
ulong out_size;
@@ -1049,7 +1052,7 @@ fd_dump_txn_to_protobuf( fd_runtime_t * runtime,
10491052
}
10501053

10511054
fd_exec_test_txn_context_t txn_context_msg = FD_EXEC_TEST_TXN_CONTEXT_INIT_DEFAULT;
1052-
create_txn_context_protobuf_from_txn( &txn_context_msg, runtime, txn_out, txn_ctx, spad );
1055+
create_txn_context_protobuf_from_txn( &txn_context_msg, runtime, txn_ctx->bank, txn_in, txn_out, spad );
10531056

10541057
/* Output to file */
10551058
ulong out_buf_size = 100UL<<20UL; // 100 MB
@@ -1122,7 +1125,7 @@ fd_dump_vm_syscall_to_protobuf( fd_vm_t const * vm,
11221125
FD_SPAD_FRAME_BEGIN( spad ) {
11231126

11241127
fd_ed25519_sig_t signature;
1125-
memcpy( signature, (uchar const *)vm->instr_ctx->txn_ctx->txn.payload + TXN( &vm->instr_ctx->txn_ctx->txn )->signature_off, sizeof(fd_ed25519_sig_t) );
1128+
memcpy( signature, (uchar const *)vm->instr_ctx->txn_in->txn.payload + TXN( &vm->instr_ctx->txn_in->txn )->signature_off, sizeof(fd_ed25519_sig_t) );
11261129
char encoded_signature[FD_BASE58_ENCODED_64_SZ];
11271130
fd_base58_encode_64( signature, NULL, encoded_signature );
11281131

@@ -1239,6 +1242,7 @@ FD_SPAD_FRAME_BEGIN( spad ) {
12391242

12401243
void
12411244
fd_dump_elf_to_protobuf( fd_runtime_t * runtime,
1245+
fd_txn_in_t const * txn_in,
12421246
fd_exec_txn_ctx_t * txn_ctx,
12431247
fd_txn_account_t * program_acc ) {
12441248
fd_spad_t * spad = fd_spad_join( fd_spad_new( txn_ctx->log.dumping_mem, 1UL<<28UL ) );
@@ -1257,7 +1261,7 @@ FD_SPAD_FRAME_BEGIN( spad ) {
12571261

12581262
/* Serialize the ELF to protobuf */
12591263
fd_ed25519_sig_t signature;
1260-
memcpy( signature, (uchar const *)txn_ctx->txn.payload + TXN( &txn_ctx->txn )->signature_off, sizeof(fd_ed25519_sig_t) );
1264+
memcpy( signature, (uchar const *)txn_in->txn.payload + TXN( &txn_in->txn )->signature_off, sizeof(fd_ed25519_sig_t) );
12611265
char encoded_signature[FD_BASE58_ENCODED_64_SZ];
12621266
fd_base58_encode_64( signature, NULL, encoded_signature );
12631267

src/flamenco/runtime/tests/fd_dump_pb.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,15 @@ fd_block_dump_context_reset( fd_block_dump_ctx_t * ctx ) {
156156

157157
void
158158
fd_dump_instr_to_protobuf( fd_runtime_t * runtime,
159+
fd_txn_in_t const * txn_in,
159160
fd_txn_out_t * txn_out,
160161
fd_exec_txn_ctx_t * txn_ctx,
161162
fd_instr_info_t * instr,
162163
ushort instruction_idx );
163164

164165
void
165166
fd_dump_txn_to_protobuf( fd_runtime_t * runtime,
167+
fd_txn_in_t const * txn_in,
166168
fd_txn_out_t * txn_out,
167169
fd_exec_txn_ctx_t * txn_ctx );
168170

@@ -211,6 +213,7 @@ fd_dump_vm_syscall_to_protobuf( fd_vm_t const * vm,
211213

212214
void
213215
fd_dump_elf_to_protobuf( fd_runtime_t * runtime,
216+
fd_txn_in_t const * txn_in,
214217
fd_exec_txn_ctx_t * txn_ctx,
215218
fd_txn_account_t * program_acc );
216219

src/flamenco/runtime/tests/fd_instr_harness.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ fd_solfuzz_pb_instr_ctx_create( fd_solfuzz_runner_t * runner,
4040
uchar * txn_ctx_mem = fd_spad_alloc( runner->spad, FD_EXEC_TXN_CTX_ALIGN, FD_EXEC_TXN_CTX_FOOTPRINT );
4141
fd_exec_txn_ctx_t * txn_ctx = fd_exec_txn_ctx_join( fd_exec_txn_ctx_new( txn_ctx_mem ) );
4242

43+
fd_txn_in_t * txn_in = fd_spad_alloc( runner->spad, alignof(fd_txn_in_t), sizeof(fd_txn_in_t) );
4344
fd_txn_out_t * txn_out = fd_spad_alloc( runner->spad, alignof(fd_txn_out_t), sizeof(fd_txn_out_t) );
4445

4546
fd_runtime_t * runtime = fd_spad_alloc( runner->spad, alignof(fd_runtime_t), sizeof(fd_runtime_t) );
4647
runtime->exec_stack = runner->exec_stack;
4748

4849
ctx->txn_ctx = txn_ctx;
4950
ctx->txn_out = txn_out;
51+
ctx->txn_in = txn_in;
5052

5153
ctx->txn_ctx->exec_accounts = runner->exec_accounts;
5254

@@ -124,7 +126,7 @@ fd_solfuzz_pb_instr_ctx_create( fd_solfuzz_runner_t * runner,
124126
txn_out->err.exec_err_kind = FD_EXECUTOR_ERR_KIND_NONE;
125127
runtime->instr.current_idx = 0;
126128

127-
txn_ctx->txn = *txn;
129+
txn_in->txn = *txn;
128130
txn_out->details.compute_budget.compute_unit_limit = test_ctx->cu_avail;
129131
txn_out->details.compute_budget.compute_meter = test_ctx->cu_avail;
130132
runtime->instr.info_cnt = 1UL;
@@ -396,7 +398,7 @@ fd_solfuzz_pb_instr_run( fd_solfuzz_runner_t * runner,
396398
fd_instr_info_t * instr = (fd_instr_info_t *) ctx->instr;
397399

398400
/* Execute the test */
399-
int exec_result = fd_execute_instr( ctx->runtime, ctx->txn_out, ctx->txn_ctx, instr );
401+
int exec_result = fd_execute_instr( ctx->runtime, ctx->txn_in, ctx->txn_out, ctx->txn_ctx, instr );
400402

401403
/* Allocate space to capture outputs */
402404

src/flamenco/runtime/tests/fd_txn_harness.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ fd_solfuzz_pb_txn_serialize( uchar * txn_ra
333333
fd_exec_txn_ctx_t *
334334
fd_solfuzz_txn_ctx_exec( fd_solfuzz_runner_t * runner,
335335
fd_runtime_t * runtime,
336-
fd_txn_p_t * txn,
336+
fd_txn_in_t const * txn_in,
337337
int * exec_res,
338338
fd_txn_out_t * txn_out ) {
339339

@@ -365,8 +365,8 @@ fd_solfuzz_txn_ctx_exec( fd_solfuzz_runner_t * runner,
365365
*exec_res = fd_runtime_prepare_and_execute_txn(
366366
runtime,
367367
runner->bank,
368+
txn_in,
368369
txn_ctx,
369-
txn,
370370
txn_out,
371371
NULL,
372372
runner->exec_accounts,
@@ -393,8 +393,10 @@ fd_solfuzz_pb_txn_run( fd_solfuzz_runner_t * runner,
393393
/* Execute the transaction against the runtime */
394394
int exec_res = 0;
395395
fd_runtime_t * runtime = fd_spad_alloc( runner->spad, alignof(fd_runtime_t), sizeof(fd_runtime_t) );
396+
fd_txn_in_t * txn_in = fd_spad_alloc( runner->spad, alignof(fd_txn_in_t), sizeof(fd_txn_in_t) );
396397
fd_txn_out_t * txn_out = fd_spad_alloc( runner->spad, alignof(fd_txn_out_t), sizeof(fd_txn_out_t) );
397-
fd_exec_txn_ctx_t * txn_ctx = fd_solfuzz_txn_ctx_exec( runner, runtime, txn, &exec_res, txn_out );
398+
txn_in->txn = *txn;
399+
fd_exec_txn_ctx_t * txn_ctx = fd_solfuzz_txn_ctx_exec( runner, runtime, txn_in, &exec_res, txn_out );
398400

399401
/* Start saving txn exec results */
400402
FD_SCRATCH_ALLOC_INIT( l, output_buf );
@@ -518,7 +520,7 @@ fd_solfuzz_pb_txn_run( fd_solfuzz_runner_t * runner,
518520
for( ulong j=0UL; j<accounts_cnt; j++ ) {
519521
fd_txn_account_t * acc = &accounts_to_save[j];
520522

521-
if( !( fd_exec_txn_ctx_account_is_writable_idx( txn_out, txn_ctx, (ushort)j ) || j==FD_FEE_PAYER_TXN_IDX ) ) continue;
523+
if( !( fd_exec_txn_ctx_account_is_writable_idx( txn_in, txn_out, txn_ctx, (ushort)j ) || j==FD_FEE_PAYER_TXN_IDX ) ) continue;
522524
assert( fd_txn_account_is_mutable( acc ) );
523525

524526
ulong modified_idx = txn_result->resulting_state.acct_states_count;

src/flamenco/runtime/tests/fd_txn_harness.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fd_solfuzz_pb_txn_serialize( uchar * txn_ra
2323
fd_exec_txn_ctx_t *
2424
fd_solfuzz_txn_ctx_exec( fd_solfuzz_runner_t * runner,
2525
fd_runtime_t * runtime,
26-
fd_txn_p_t * txn,
26+
fd_txn_in_t const * txn_in,
2727
int * exec_res,
2828
fd_txn_out_t * txn_out );
2929

src/flamenco/runtime/tests/fd_vm_harness.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ do{
161161
( !memcmp( fd_txn_account_get_owner( program_acc ), fd_solana_bpf_loader_deprecated_program_id.key, sizeof(fd_pubkey_t) ) );
162162

163163
/* Push the instruction onto the stack. This may also modify the sysvar instructions account, if its present. */
164-
int stack_push_err = fd_instr_stack_push( instr_ctx->runtime, instr_ctx->txn_out, instr_ctx->txn_ctx, (fd_instr_info_t *)instr_ctx->instr );
164+
int stack_push_err = fd_instr_stack_push( instr_ctx->runtime, instr_ctx->txn_in, instr_ctx->txn_out, instr_ctx->txn_ctx, (fd_instr_info_t *)instr_ctx->instr );
165165
if( FD_UNLIKELY( stack_push_err ) ) {
166166
FD_LOG_WARNING(( "instr stack push err" ));
167167
fd_solfuzz_pb_instr_ctx_destroy( runner, instr_ctx );
@@ -472,7 +472,7 @@ fd_solfuzz_pb_syscall_run( fd_solfuzz_runner_t * runner,
472472
( !memcmp( fd_txn_account_get_owner( program_acc ), fd_solana_bpf_loader_deprecated_program_id.key, sizeof(fd_pubkey_t) ) );
473473

474474
/* Push the instruction onto the stack. This may also modify the sysvar instructions account, if its present. */
475-
int stack_push_err = fd_instr_stack_push( ctx->runtime, ctx->txn_out, ctx->txn_ctx, (fd_instr_info_t *)ctx->instr );
475+
int stack_push_err = fd_instr_stack_push( ctx->runtime, ctx->txn_in, ctx->txn_out, ctx->txn_ctx, (fd_instr_info_t *)ctx->instr );
476476
if( FD_UNLIKELY( stack_push_err ) ) {
477477
FD_LOG_WARNING(( "instr stack push err" ));
478478
goto error;

0 commit comments

Comments
 (0)