@@ -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 ,
@@ -1173,11 +1157,13 @@ fd_txn_ctx_push( fd_runtime_t * runtime,
11731157 }
11741158 }
11751159
1176- /* https://github.com/anza-xyz/agave/blob/c4b42ab045860d7b13b3912eafb30e6d2f4e593f/sdk/src/transaction_context.rs#L347-L351 */
1177- if ( FD_UNLIKELY ( runtime -> instr .trace_length >=FD_MAX_INSTRUCTION_TRACE_LENGTH ) ) {
1160+ /* Note that we don't update the trace length here - since the caller
1161+ allocates out of the trace array, they are also responsible for
1162+ incrementing the trace length variable.
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 ) ) {
11781165 return FD_EXECUTOR_INSTR_ERR_MAX_INSN_TRACE_LENS_EXCEEDED ;
11791166 }
1180- runtime -> instr .trace_length ++ ;
11811167
11821168 /* https://github.com/anza-xyz/agave/blob/c4b42ab045860d7b13b3912eafb30e6d2f4e593f/sdk/src/transaction_context.rs#L352-L356 */
11831169 if ( FD_UNLIKELY ( runtime -> instr .stack_sz >=FD_MAX_INSTRUCTION_STACK_DEPTH ) ) {
@@ -1355,11 +1341,6 @@ fd_execute_instr( fd_runtime_t * runtime,
13551341 };
13561342 fd_base58_encode_32 ( txn_out -> accounts .accounts [ instr -> program_id ].pubkey -> uc , NULL , ctx -> program_id_base58 );
13571343
1358- runtime -> instr .trace [ runtime -> instr .trace_length - 1 ] = (fd_exec_instr_trace_entry_t ) {
1359- .instr_info = instr ,
1360- .stack_height = runtime -> instr .stack_sz ,
1361- };
1362-
13631344 /* Look up the native program. We check for precompiles within the lookup function as well.
13641345 https://github.com/anza-xyz/agave/blob/v2.1.6/svm/src/message_processor.rs#L88 */
13651346 fd_exec_instr_fn_t native_prog_fn ;
@@ -1601,9 +1582,6 @@ fd_executor_setup_accounts_for_txn( fd_runtime_t * runtime,
16011582
16021583 txn_out -> accounts .nonce_idx_in_txn = ULONG_MAX ;
16031584 runtime -> executable .cnt = executable_idx ;
1604-
1605- /* Set up instr infos from the txn descriptor. No Agave equivalent to this function. */
1606- fd_executor_setup_instr_infos_from_txn_instrs ( runtime , bank , txn_in , txn_out );
16071585}
16081586
16091587int
@@ -1633,19 +1611,41 @@ fd_execute_txn( fd_runtime_t * runtime,
16331611 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 ;
16341612 (void )dump_insn ;
16351613
1614+ fd_txn_t const * txn = TXN ( txn_in -> txn );
1615+
16361616 /* Initialize log collection. */
16371617 fd_log_collector_init ( runtime -> log .log_collector , runtime -> log .enable_log_collector );
16381618
16391619 for ( ushort i = 0 ; i < TXN ( txn_in -> txn )-> instr_cnt ; i ++ ) {
1640- runtime -> instr .current_idx = i ;
1620+ /* Set up the instr info for the current instruction */
1621+ fd_instr_info_init_from_txn_instr (
1622+ & runtime -> instr .trace [runtime -> instr .trace_length ],
1623+ bank ,
1624+ txn_in ,
1625+ txn_out ,
1626+ & txn -> instr [i ]
1627+ );
1628+
16411629# if FD_HAS_FLATCC
16421630 if ( FD_UNLIKELY ( dump_insn ) ) {
16431631 // Capture the input and convert it into a Protobuf message
1644- fd_dump_instr_to_protobuf ( runtime , bank , txn_in , txn_out , & runtime -> instr .infos [i ], i );
1632+ fd_dump_instr_to_protobuf (
1633+ runtime ,
1634+ bank ,
1635+ txn_in ,
1636+ txn_out ,
1637+ & runtime -> instr .trace [runtime -> instr .trace_length ],
1638+ i
1639+ );
16451640 }
16461641# endif
16471642
1648- int instr_exec_result = fd_execute_instr ( runtime , bank , txn_in , txn_out , & runtime -> instr .infos [i ] );
1643+ /* Update the current executing instruction index and trace length */
1644+ runtime -> instr .current_idx = i ;
1645+ runtime -> instr .trace_length ++ ;
1646+
1647+ /* Execute the current instruction */
1648+ int instr_exec_result = fd_execute_instr ( runtime , bank , txn_in , txn_out , & runtime -> instr .trace [i ] );
16491649 if ( FD_UNLIKELY ( instr_exec_result != FD_EXECUTOR_INSTR_SUCCESS ) ) {
16501650 if ( txn_out -> err .exec_err_idx == INT_MAX ) {
16511651 txn_out -> err .exec_err_idx = i ;
0 commit comments