From c49713487b7c67d685631269bfff61f006c22a32 Mon Sep 17 00:00:00 2001 From: Sixtysixter <20945591+Sixtysixter@users.noreply.github.com> Date: Tue, 28 Jan 2025 21:03:11 +0100 Subject: [PATCH] rpcdaemon: fix invalid data access for CREATE2 in trace_filter (#2649) --- .github/workflows/run_integration_tests.sh | 8 ++++---- silkworm/rpc/core/evm_trace.cpp | 7 ++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/run_integration_tests.sh b/.github/workflows/run_integration_tests.sh index f227ab3105..8beb3ce835 100755 --- a/.github/workflows/run_integration_tests.sh +++ b/.github/workflows/run_integration_tests.sh @@ -39,11 +39,11 @@ debug_traceTransaction/test_90,\ debug_traceTransaction/test_91,\ debug_traceTransaction/test_92,\ debug_traceTransaction/test_96,\ +trace_filter/test_24,\ trace_replayBlockTransactions/test_29,\ -engine_,\ -trace_filter/test_24.json,\ -trace_replayTransaction/test_48.tar,\ -trace_transaction/test_37.json +trace_replayTransaction/test_48,\ +trace_transaction/test_37,\ +engine_ failed_test=$? diff --git a/silkworm/rpc/core/evm_trace.cpp b/silkworm/rpc/core/evm_trace.cpp index 4ba28030f6..358b38fb1e 100644 --- a/silkworm/rpc/core/evm_trace.cpp +++ b/silkworm/rpc/core/evm_trace.cpp @@ -805,7 +805,9 @@ void TraceTracer::on_execution_start(evmc_revision rev, const evmc_message& msg, current_depth_ = msg.depth; auto create = (!initial_ibs_.exists(recipient) && created_address_.find(recipient) == created_address_.end() && recipient != code_address); - + if (last_opcode_) { + create = create || last_opcode_.value() == OP_CREATE2 || last_opcode_.value() == OP_CREATE; + } start_gas_.push(msg.gas); size_t index = traces_.size(); @@ -937,6 +939,8 @@ void TraceTracer::on_execution_end(const evmc_result& result, const silkworm::In is_precompile_ = false; return; } + if (index_stack_.empty()) + return; if (index_stack_.empty()) { return; @@ -1042,6 +1046,7 @@ void TraceTracer::on_creation_completed(const evmc_result& result, const silkwor auto start_gas = start_gas_.top(); index_stack_.pop(); start_gas_.pop(); + Trace& trace = traces_[index]; trace.trace_result->gas_used = start_gas - result.gas_left; }