Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpcdaemon: debug_traceTransaction error field #2456

Merged
merged 7 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/rpc-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Checkout RPC Tests Repository & Install Requirements
run: |
rm -rf ${{runner.workspace}}/rpc-tests
git -c advice.detachedHead=false clone --depth 1 --branch v1.3.0 https://github.com/erigontech/rpc-tests ${{runner.workspace}}/rpc-tests
git -c advice.detachedHead=false clone --depth 1 --branch v1.4.0 https://github.com/erigontech/rpc-tests ${{runner.workspace}}/rpc-tests
cd ${{runner.workspace}}/rpc-tests
pip3 install -r requirements.txt

Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/run_integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,17 @@ debug_accountRange,\
debug_getModifiedAccounts,\
debug_storageRangeAt,\
debug_traceCall/test_02.json,\
debug_traceTransaction,\
debug_traceTransaction/test_25.json,\
debug_traceTransaction/test_36.json,\
debug_traceTransaction/test_43.json,\
debug_traceTransaction/test_62.json,\
debug_traceTransaction/test_74.tar,\
debug_traceTransaction/test_75.tar,\
debug_traceTransaction/test_77.json,\
debug_traceTransaction/test_90.tar,\
debug_traceTransaction/test_91.tar,\
debug_traceTransaction/test_92.tar,\
debug_traceTransaction/test_96.json,\
engine_,\
erigon_getBalanceChangesInBlock,\
erigon_getLatestLogs,\
Expand Down
21 changes: 12 additions & 9 deletions silkworm/rpc/core/evm_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

#include "evm_debug.hpp"

#include <memory>
#include <string>

#include <evmc/instructions.h>
#include <evmone/execution_state.hpp>
#include <evmone/instructions_traits.hpp>
#include <intx/intx.hpp>

#include <silkworm/core/common/util.hpp>
Expand Down Expand Up @@ -84,18 +84,21 @@ void output_memory(std::vector<std::string>& vect, const evmone::Memory& memory)
const auto data = memory.data();
vect.push_back(silkworm::to_hex({data, memory.size()}));
}

void insert_error(DebugLog& log, evmc_status_code status_code) {
switch (status_code) {
case evmc_status_code::EVMC_FAILURE:
case evmc_status_code::EVMC_OUT_OF_GAS:
log.error = "out of gas";
break;
case evmc_status_code::EVMC_STACK_OVERFLOW:
log.error = {"stack overflow (" + std::to_string(log.stack_height) + " <=> " + std::to_string(evmone::instr::traits[log.op_code].stack_height_required) + ")"};
break;
case evmc_status_code::EVMC_STACK_UNDERFLOW:
log.error = true;
log.error = {"stack underflow (" + std::to_string(log.stack_height) + " <=> " + std::to_string(evmone::instr::traits[log.op_code].stack_height_required) + ")"};
break;
case evmc_status_code::EVMC_UNDEFINED_INSTRUCTION:
case evmc_status_code::EVMC_FAILURE:
default:
log.error = false;
log.error = "";
break;
}
}
Expand Down Expand Up @@ -189,6 +192,7 @@ void DebugTracer::on_instruction_start(uint32_t pc, const intx::uint256* stack_t
log.gas = gas;
log.gas_cost = metrics_[opcode].gas_cost;
log.depth = execution_state.msg->depth + 1;
log.stack_height = stack_height;

if (!config_.disable_stack) {
output_stack(log.stack, stack_top, stack_height);
Expand Down Expand Up @@ -328,10 +332,9 @@ void DebugTracer::write_log(const DebugLog& log) {
}
stream_.close_object();
}
if (log.error) {
stream_.write_field("error");
stream_.open_object();
stream_.close_object();

if (!log.error.empty()) {
stream_.write_field("error", log.error);
}

stream_.close_object();
Expand Down
3 changes: 2 additions & 1 deletion silkworm/rpc/core/evm_debug.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ struct DebugLog {
std::int64_t gas{0};
std::int64_t gas_cost{0};
std::int32_t depth{0};
bool error{false};
std::string error;
int stack_height{0};
std::vector<std::string> memory;
std::vector<std::string> stack;
Storage storage;
Expand Down
Loading