@@ -405,22 +405,6 @@ fd_executor_verify_transaction( fd_bank_t * bank,
405405 return FD_RUNTIME_EXECUTE_SUCCESS ;
406406}
407407
408- static void
409- fd_executor_setup_instr_infos_from_txn_instrs ( fd_runtime_t * runtime ,
410- fd_bank_t * bank ,
411- fd_txn_in_t const * txn_in ,
412- fd_txn_out_t * txn_out ) {
413- ushort instr_cnt = TXN ( txn_in -> txn )-> instr_cnt ;
414-
415- /* Set up the instr infos for the transaction */
416- for ( ushort i = 0 ; i < instr_cnt ; i ++ ) {
417- fd_txn_instr_t const * instr = & TXN ( txn_in -> txn )-> instr [i ];
418- fd_instr_info_init_from_txn_instr ( & runtime -> instr .infos [i ], bank , txn_in , txn_out , instr );
419- }
420-
421- runtime -> instr .info_cnt = instr_cnt ;
422- }
423-
424408/* https://github.com/anza-xyz/agave/blob/v2.0.9/svm/src/account_loader.rs#L410-427 */
425409static int
426410accumulate_and_check_loaded_account_data_size ( ulong acc_size ,
@@ -456,8 +440,7 @@ accumulate_and_check_loaded_account_data_size( ulong acc_size,
456440
457441 https://github.com/anza-xyz/agave/blob/v2.3.1/svm/src/account_loader.rs#L199-L228 */
458442static ulong
459- load_transaction_account ( fd_runtime_t * runtime ,
460- fd_bank_t * bank ,
443+ load_transaction_account ( fd_bank_t * bank ,
461444 fd_txn_in_t const * txn_in ,
462445 fd_txn_out_t * txn_out ,
463446 fd_txn_account_t * acct ,
@@ -472,7 +455,7 @@ load_transaction_account( fd_runtime_t * runtime,
472455 constructed by the SVM and modified within each transaction's
473456 instruction execution only, so it incurs a loaded size cost
474457 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 );
458+ fd_sysvar_instructions_serialize_account ( bank , txn_in , txn_out , txn_idx );
476459 return 0UL ;
477460 }
478461
@@ -549,7 +532,7 @@ fd_executor_load_transaction_accounts_old( fd_runtime_t * runtime,
549532 }
550533
551534 /* https://github.com/anza-xyz/agave/blob/v2.3.1/svm/src/account_loader.rs#L733-L740 */
552- ulong loaded_acc_size = load_transaction_account ( runtime , bank , txn_in , txn_out , acct , is_writable , unknown_acc , i );
535+ ulong loaded_acc_size = load_transaction_account ( bank , txn_in , txn_out , acct , is_writable , unknown_acc , i );
553536 int err = accumulate_and_check_loaded_account_data_size ( loaded_acc_size ,
554537 requested_loaded_accounts_data_size ,
555538 & txn_out -> details .loaded_accounts_data_size );
@@ -816,7 +799,7 @@ fd_executor_load_transaction_accounts_simd_186( fd_runtime_t * runtime,
816799
817800 /* Load and collect any remaining accounts
818801 https://github.com/anza-xyz/agave/blob/v2.3.1/svm/src/account_loader.rs#L652-L659 */
819- ulong loaded_acc_size = load_transaction_account ( runtime , bank , txn_in , txn_out , acct , is_writable , unknown_acc , i );
802+ ulong loaded_acc_size = load_transaction_account ( bank , txn_in , txn_out , acct , is_writable , unknown_acc , i );
820803 int err = fd_collect_loaded_account (
821804 runtime ,
822805 txn_out ,
@@ -1160,11 +1143,13 @@ fd_txn_ctx_push( fd_runtime_t * runtime,
11601143 }
11611144 }
11621145
1163- /* https://github.com/anza-xyz/agave/blob/c4b42ab045860d7b13b3912eafb30e6d2f4e593f/sdk/src/transaction_context.rs#L347-L351 */
1164- if ( FD_UNLIKELY ( runtime -> instr .trace_length >=FD_MAX_INSTRUCTION_TRACE_LENGTH ) ) {
1146+ /* Note that we don't update the trace length here - since the caller
1147+ allocates out of the trace array, they are also responsible for
1148+ incrementing the trace length variable.
1149+ https://github.com/anza-xyz/agave/blob/c4b42ab045860d7b13b3912eafb30e6d2f4e593f/sdk/src/transaction_context.rs#L347-L351 */
1150+ if ( FD_UNLIKELY ( runtime -> instr .trace_length > FD_MAX_INSTRUCTION_TRACE_LENGTH ) ) {
11651151 return FD_EXECUTOR_INSTR_ERR_MAX_INSN_TRACE_LENS_EXCEEDED ;
11661152 }
1167- runtime -> instr .trace_length ++ ;
11681153
11691154 /* https://github.com/anza-xyz/agave/blob/c4b42ab045860d7b13b3912eafb30e6d2f4e593f/sdk/src/transaction_context.rs#L352-L356 */
11701155 if ( FD_UNLIKELY ( runtime -> instr .stack_sz >=FD_MAX_INSTRUCTION_STACK_DEPTH ) ) {
@@ -1342,11 +1327,6 @@ fd_execute_instr( fd_runtime_t * runtime,
13421327 };
13431328 fd_base58_encode_32 ( txn_out -> accounts .accounts [ instr -> program_id ].pubkey -> uc , NULL , ctx -> program_id_base58 );
13441329
1345- runtime -> instr .trace [ runtime -> instr .trace_length - 1 ] = (fd_exec_instr_trace_entry_t ) {
1346- .instr_info = instr ,
1347- .stack_height = runtime -> instr .stack_sz ,
1348- };
1349-
13501330 /* Look up the native program. We check for precompiles within the lookup function as well.
13511331 https://github.com/anza-xyz/agave/blob/v2.1.6/svm/src/message_processor.rs#L88 */
13521332 fd_exec_instr_fn_t native_prog_fn ;
@@ -1588,9 +1568,6 @@ fd_executor_setup_accounts_for_txn( fd_runtime_t * runtime,
15881568
15891569 txn_out -> accounts .nonce_idx_in_txn = ULONG_MAX ;
15901570 runtime -> executable .cnt = executable_idx ;
1591-
1592- /* Set up instr infos from the txn descriptor. No Agave equivalent to this function. */
1593- fd_executor_setup_instr_infos_from_txn_instrs ( runtime , bank , txn_in , txn_out );
15941571}
15951572
15961573int
@@ -1620,19 +1597,34 @@ fd_execute_txn( fd_runtime_t * runtime,
16201597 bool dump_insn = runtime -> log .capture_ctx && fd_bank_slot_get ( bank ) >= runtime -> log .capture_ctx -> dump_proto_start_slot && runtime -> log .capture_ctx -> dump_instr_to_pb ;
16211598 (void )dump_insn ;
16221599
1600+ fd_txn_t const * txn = TXN ( txn_in -> txn );
1601+
16231602 /* Initialize log collection. */
16241603 fd_log_collector_init ( runtime -> log .log_collector , runtime -> log .enable_log_collector );
16251604
16261605 for ( ushort i = 0 ; i < TXN ( txn_in -> txn )-> instr_cnt ; i ++ ) {
1627- runtime -> instr .current_idx = i ;
1606+ /* Set up the instr info for the current instruction */
1607+ fd_instr_info_t * instr_info = & runtime -> instr .trace [runtime -> instr .trace_length ++ ];
1608+ fd_instr_info_init_from_txn_instr (
1609+ instr_info ,
1610+ bank ,
1611+ txn_in ,
1612+ txn_out ,
1613+ & txn -> instr [i ]
1614+ );
1615+
16281616# if FD_HAS_FLATCC
16291617 if ( FD_UNLIKELY ( dump_insn ) ) {
16301618 // Capture the input and convert it into a Protobuf message
1631- fd_dump_instr_to_protobuf ( runtime , bank , txn_in , txn_out , & runtime -> instr . infos [ i ] , i );
1619+ fd_dump_instr_to_protobuf ( runtime , bank , txn_in , txn_out , instr_info , i );
16321620 }
16331621# endif
16341622
1635- int instr_exec_result = fd_execute_instr ( runtime , bank , txn_in , txn_out , & runtime -> instr .infos [i ] );
1623+ /* Update the current executing instruction index */
1624+ runtime -> instr .current_idx = i ;
1625+
1626+ /* Execute the current instruction */
1627+ int instr_exec_result = fd_execute_instr ( runtime , bank , txn_in , txn_out , instr_info );
16361628 if ( FD_UNLIKELY ( instr_exec_result != FD_EXECUTOR_INSTR_SUCCESS ) ) {
16371629 if ( txn_out -> err .exec_err_idx == INT_MAX ) {
16381630 txn_out -> err .exec_err_idx = i ;
0 commit comments