@@ -1460,21 +1460,6 @@ Task<std::vector<Trace>> TraceCallExecutor::trace_transaction(const BlockWithHas
14601460 co_return traces;
14611461}
14621462
1463- bool TraceCallExecutor::run_previous_transactions (EVMExecutor& executor, const silkworm::Block& block, uint64_t tx_id) {
1464- if (tx_id == 0 ) {
1465- return true ;
1466- }
1467- for (size_t idx = 0 ; idx < block.transactions .size (); idx++) {
1468- const auto & txn = block.transactions .at (idx);
1469-
1470- if (tx_id == idx) {
1471- return true ;
1472- }
1473- executor.call (block, txn, {}, /* refund=*/ true , /* gas_bailout=*/ false );
1474- }
1475- return false ;
1476- }
1477-
14781463Task<TraceEntriesResult> TraceCallExecutor::trace_transaction_entries (const TransactionWithBlock& transaction_with_block) {
14791464 const auto & block = transaction_with_block.block_with_hash ->block ;
14801465 const auto block_number = block.header .number ;
@@ -1489,10 +1474,7 @@ Task<TraceEntriesResult> TraceCallExecutor::trace_transaction_entries(const Tran
14891474 auto curr_state = tx_.create_state (current_executor, database_reader_, chain_storage_, block_number - 1 );
14901475 EVMExecutor executor{*chain_config_ptr, workers_, curr_state};
14911476
1492- if (!run_previous_transactions (executor, block, transaction_with_block.transaction .transaction_index )) {
1493- SILK_ERROR << " trace_operations: transaction idx: " << transaction_with_block.transaction .transaction_index << " not found" ;
1494- return {};
1495- }
1477+ executor.call_first_n (block, transaction_with_block.transaction .transaction_index );
14961478
14971479 const auto entry_tracer = std::make_shared<trace::EntryTracer>(initial_ibs);
14981480 Tracers tracers{entry_tracer};
@@ -1520,10 +1502,7 @@ Task<std::string> TraceCallExecutor::trace_transaction_error(const TransactionWi
15201502 auto curr_state = tx_.create_state (current_executor, database_reader_, chain_storage_, block_number - 1 );
15211503 EVMExecutor executor{*chain_config_ptr, workers_, curr_state};
15221504
1523- if (!run_previous_transactions (executor, block, transaction_with_block.transaction .transaction_index )) {
1524- SILK_ERROR << " trace_transaction_error: transaction idx: " << transaction_with_block.transaction .transaction_index << " not found" ;
1525- return {};
1526- }
1505+ executor.call_first_n (block, transaction_with_block.transaction .transaction_index );
15271506
15281507 const auto & txn = block.transactions .at (transaction_with_block.transaction .transaction_index );
15291508 auto execution_result = executor.call (block, txn, {}, /* refund=*/ true , /* gas_bailout=*/ false );
@@ -1553,10 +1532,7 @@ Task<TraceOperationsResult> TraceCallExecutor::trace_operations(const Transactio
15531532 auto curr_state = tx_.create_state (current_executor, database_reader_, chain_storage_, block_number - 1 );
15541533 EVMExecutor executor{*chain_config_ptr, workers_, curr_state};
15551534
1556- if (!run_previous_transactions (executor, block, transaction_with_block.transaction .transaction_index )) {
1557- SILK_ERROR << " trace_operations: transaction idx: " << transaction_with_block.transaction .transaction_index << " not found" ;
1558- return {};
1559- }
1535+ executor.call_first_n (block, transaction_with_block.transaction .transaction_index );
15601536
15611537 auto entry_tracer = std::make_shared<trace::OperationTracer>(initial_ibs);
15621538 Tracers tracers{entry_tracer};
@@ -1785,6 +1761,8 @@ void EntryTracer::on_execution_start(evmc_revision rev, const evmc_message& msg,
17851761 const auto str_value = " 0x" + intx::hex (intx::be::load<intx::uint256>(msg.value ));
17861762 auto str_input = " 0x" + silkworm::to_hex (input);
17871763
1764+ current_depth_ = msg.depth ;
1765+
17881766 // Ignore precompiles in the returned trace (maybe we shouldn't?)
17891767 if (precompile::is_precompile (msg.code_address , rev)) {
17901768 // writes special value for index
@@ -1817,7 +1795,6 @@ void EntryTracer::on_execution_start(evmc_revision rev, const evmc_message& msg,
18171795 }
18181796 }
18191797 traces_stack_idx_.emplace (result_.size () - 1 );
1820- current_depth_ = msg.depth ;
18211798
18221799 SILK_DEBUG << " EntryTracer::on_execution_start: gas: " << std::dec << msg.gas
18231800 << " , msg.depth: " << msg.depth
0 commit comments