Skip to content

Commit f2aae14

Browse files
committed
flamenco: clean up instr info + trace
1 parent 9332e9e commit f2aae14

22 files changed

+69
-98
lines changed

src/flamenco/runtime/fd_executor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ load_transaction_account( fd_runtime_t * runtime,
472472
constructed by the SVM and modified within each transaction's
473473
instruction execution only, so it incurs a loaded size cost
474474
of 0. */
475-
fd_sysvar_instructions_serialize_account( txn_in, txn_out, (fd_instr_info_t const *)runtime->instr.infos, TXN( txn_in->txn )->instr_cnt, txn_idx );
475+
fd_sysvar_instructions_serialize_account( bank, txn_in, txn_out, txn_idx );
476476
return 0UL;
477477
}
478478

src/flamenco/runtime/info/fd_instr_info.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fd_instr_info_init_from_txn_instr( fd_instr_info_t * instr,
3838
the instr info. */
3939
instr->acct_cnt = fd_ushort_min( txn_instr->acct_cnt, FD_INSTR_ACCT_MAX );
4040
instr->data_sz = txn_instr->data_sz;
41-
instr->data = (uchar *)txn_in->txn->payload + txn_instr->data_off;
41+
memcpy( instr->dogtor, txn_in->txn->payload+txn_instr->data_off, instr->data_sz );
4242

4343
uchar acc_idx_seen[ FD_INSTR_ACCT_MAX ] = {0};
4444

src/flamenco/runtime/info/fd_instr_info.h

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ typedef struct fd_instruction_account fd_instruction_account_t;
3636

3737
struct fd_instr_info {
3838
uchar program_id;
39-
ushort data_sz;
4039
ushort acct_cnt;
4140

42-
uchar * data;
41+
uchar dogtor[ FD_TXN_MTU ];
42+
ushort data_sz;
4343

4444
fd_instruction_account_t accounts[ FD_INSTR_ACCT_MAX ];
4545
uchar is_duplicate[ FD_INSTR_ACCT_MAX ];
@@ -157,20 +157,6 @@ fd_instr_info_sum_account_lamports( fd_instr_info_t const * instr,
157157
ulong * total_lamports_h,
158158
ulong * total_lamports_l );
159159

160-
static inline uchar
161-
fd_instr_get_acc_flags( fd_instr_info_t const * instr,
162-
ushort idx ) {
163-
if( FD_UNLIKELY( idx>=instr->acct_cnt ) ) {
164-
return 0;
165-
}
166-
167-
uchar flags = 0;
168-
if( instr->accounts[idx].is_signer ) flags |= FD_INSTR_ACCT_FLAGS_IS_SIGNER;
169-
if( instr->accounts[idx].is_writable ) flags |= FD_INSTR_ACCT_FLAGS_IS_WRITABLE;
170-
171-
return flags;
172-
}
173-
174160
FD_PROTOTYPES_END
175161

176162
#endif /* HEADER_fd_src_flamenco_runtime_info_fd_instr_info_h */

src/flamenco/runtime/program/fd_address_lookup_table_program.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ fd_address_lookup_table_program_execute( fd_exec_instr_ctx_t * ctx ) {
10701070

10711071
FD_EXEC_CU_UPDATE( ctx, DEFAULT_COMPUTE_UNITS );
10721072

1073-
uchar const * instr_data = ctx->instr->data;
1073+
uchar const * instr_data = ctx->instr->dogtor;
10741074
ulong instr_data_sz = ctx->instr->data_sz;
10751075
if( FD_UNLIKELY( instr_data==NULL ) ) {
10761076
return FD_EXECUTOR_INSTR_ERR_INVALID_INSTR_DATA;

src/flamenco/runtime/program/fd_bpf_loader_program.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -901,13 +901,11 @@ common_extend_program( fd_exec_instr_ctx_t * instr_ctx,
901901
/* https://github.com/anza-xyz/agave/blob/77daab497df191ef485a7ad36ed291c1874596e5/programs/bpf_loader/src/lib.rs#L566-L1444 */
902902
static int
903903
process_loader_upgradeable_instruction( fd_exec_instr_ctx_t * instr_ctx ) {
904-
uchar const * data = instr_ctx->instr->data;
905-
906904
uchar __attribute__((aligned(FD_BPF_UPGRADEABLE_LOADER_PROGRAM_INSTRUCTION_ALIGN))) instruction_mem[ FD_BPF_UPGRADEABLE_LOADER_PROGRAM_INSTRUCTION_FOOTPRINT ] = {0};
907905
fd_bpf_upgradeable_loader_program_instruction_t * instruction = fd_bincode_decode_static_limited_deserialize(
908906
bpf_upgradeable_loader_program_instruction,
909907
instruction_mem,
910-
data,
908+
instr_ctx->instr->dogtor,
911909
instr_ctx->instr->data_sz,
912910
FD_TXN_MTU,
913911
NULL );

src/flamenco/runtime/program/fd_bpf_loader_serialization.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,7 @@ fd_bpf_loader_input_serialize_aligned( fd_exec_instr_ctx_t * ctx,
382382
serialized_params += sizeof(ulong);
383383

384384
/* https://github.com/anza-xyz/agave/blob/v3.0.0/program-runtime/src/serialization.rs#L559 */
385-
uchar * instr_data = ctx->instr->data;
386-
fd_memcpy( serialized_params, instr_data, instr_data_len );
385+
fd_memcpy( serialized_params, ctx->instr->dogtor, instr_data_len );
387386
serialized_params += instr_data_len;
388387

389388
/* https://github.com/anza-xyz/agave/blob/v3.0.0/program-runtime/src/serialization.rs#L560 */
@@ -623,8 +622,7 @@ fd_bpf_loader_input_serialize_unaligned( fd_exec_instr_ctx_t * ctx,
623622
FD_STORE( ulong, serialized_params, instr_data_len );
624623
serialized_params += sizeof(ulong);
625624

626-
uchar * instr_data = (uchar *)ctx->instr->data;
627-
fd_memcpy( serialized_params, instr_data, instr_data_len );
625+
fd_memcpy( serialized_params, ctx->instr->dogtor, instr_data_len );
628626
serialized_params += instr_data_len;
629627

630628
FD_STORE( fd_pubkey_t, serialized_params, txn_accs[ctx->instr->program_id] );

src/flamenco/runtime/program/fd_config_program.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ _process_config_instr( fd_exec_instr_ctx_t * ctx ) {
3030

3131
/* Deserialize the Config Program instruction data, which consists only of the ConfigKeys
3232
https://github.com/solana-labs/solana/blob/v1.17.17/programs/config/src/config_processor.rs#L21 */
33-
if( FD_UNLIKELY( ctx->instr->data==NULL ) ) {
34-
return FD_EXECUTOR_INSTR_ERR_INVALID_INSTR_DATA;
35-
}
3633
if( FD_UNLIKELY( ctx->instr->data_sz>FD_TXN_MTU ) ) {
3734
return FD_EXECUTOR_INSTR_ERR_INVALID_INSTR_DATA;
3835
}
@@ -41,7 +38,7 @@ _process_config_instr( fd_exec_instr_ctx_t * ctx ) {
4138
uchar key_list_mem[ CONFIG_INSTRUCTION_KEYS_FOOTPRINT ] __attribute__((aligned(FD_CONFIG_KEYS_ALIGN)));
4239
fd_config_keys_t * key_list = fd_bincode_decode_static(
4340
config_keys, key_list_mem,
44-
ctx->instr->data,
41+
ctx->instr->dogtor,
4542
ctx->instr->data_sz,
4643
&decode_result );
4744
if( FD_UNLIKELY( decode_result != FD_BINCODE_SUCCESS ) ) {
@@ -233,7 +230,7 @@ _process_config_instr( fd_exec_instr_ctx_t * ctx ) {
233230
}
234231

235232
/* copy_from_slice */
236-
fd_memcpy( data, ctx->instr->data, ctx->instr->data_sz );
233+
fd_memcpy( data, ctx->instr->dogtor, ctx->instr->data_sz );
237234

238235
/* Implicitly dropped */
239236

src/flamenco/runtime/program/fd_loader_v4_program.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ fd_loader_v4_program_execute( fd_exec_instr_ctx_t * instr_ctx ) {
825825
fd_loader_v4_program_instruction_t * instruction = fd_bincode_decode_static_limited_deserialize(
826826
loader_v4_program_instruction,
827827
instruction_mem,
828-
instr_ctx->instr->data,
828+
instr_ctx->instr->dogtor,
829829
instr_ctx->instr->data_sz,
830830
FD_TXN_MTU,
831831
&rc );

src/flamenco/runtime/program/fd_native_cpi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fd_native_cpi_native_invoke( fd_exec_instr_ctx_t * ctx,
4747
acct_meta->is_signer );
4848
}
4949

50-
instr_info->data = instr_data;
50+
fd_memcpy( instr_info->dogtor, instr_data, instr_data_len );
5151
instr_info->data_sz = (ushort)instr_data_len;
5252

5353
/* https://github.com/anza-xyz/agave/blob/v2.2.6/program-runtime/src/invoke_context.rs#L312-L313 */

src/flamenco/runtime/program/fd_precompiles.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ fd_precompile_get_instr_data( fd_exec_instr_ctx_t * ctx,
9292
if( index==USHORT_MAX ) {
9393

9494
/* Use current instruction data */
95-
data = ctx->instr->data;
95+
data = ctx->instr->dogtor;
9696
data_sz = ctx->instr->data_sz;
9797

9898
} else {
@@ -101,7 +101,7 @@ fd_precompile_get_instr_data( fd_exec_instr_ctx_t * ctx,
101101
return FD_EXECUTOR_PRECOMPILE_ERR_DATA_OFFSET;
102102

103103
fd_instr_info_t const * instr = &ctx->runtime->instr.infos[ index ];
104-
data = instr->data;
104+
data = instr->dogtor;
105105
data_sz = instr->data_sz;
106106

107107
}
@@ -120,7 +120,7 @@ fd_precompile_get_instr_data( fd_exec_instr_ctx_t * ctx,
120120
int
121121
fd_precompile_ed25519_verify( fd_exec_instr_ctx_t * ctx ) {
122122

123-
uchar const * data = ctx->instr->data;
123+
uchar const * data = ctx->instr->dogtor;
124124
ulong data_sz = ctx->instr->data_sz;
125125

126126
/* https://github.com/anza-xyz/agave/blob/v1.18.12/sdk/src/ed25519_instruction.rs#L90-L96
@@ -224,7 +224,7 @@ fd_precompile_ed25519_verify( fd_exec_instr_ctx_t * ctx ) {
224224
int
225225
fd_precompile_secp256k1_verify( fd_exec_instr_ctx_t * ctx ) {
226226

227-
uchar const * data = ctx->instr->data;
227+
uchar const * data = ctx->instr->dogtor;
228228
ulong data_sz = ctx->instr->data_sz;
229229

230230
/* https://github.com/anza-xyz/agave/blob/v1.18.12/sdk/src/secp256k1_instruction.rs#L934-L947
@@ -338,7 +338,7 @@ fd_precompile_secp256r1_verify( fd_exec_instr_ctx_t * ctx ) {
338338
return FD_EXECUTOR_INSTR_ERR_UNSUPPORTED_PROGRAM_ID;
339339
}
340340

341-
uchar const * data = ctx->instr->data;
341+
uchar const * data = ctx->instr->dogtor;
342342
ulong data_sz = ctx->instr->data_sz;
343343

344344
/* ... */

0 commit comments

Comments
 (0)