Skip to content

Commit

Permalink
rpcdaemon: returnValue for failed txns in debug_trace* APIs (#2741)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sixtysixter authored Feb 26, 2025
1 parent 8971182 commit f7d57cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
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.45.0 https://github.com/erigontech/rpc-tests ${{runner.workspace}}/rpc-tests
git -c advice.detachedHead=false clone --depth 1 --branch v1.47.0 https://github.com/erigontech/rpc-tests ${{runner.workspace}}/rpc-tests
cd ${{runner.workspace}}/rpc-tests
pip3 install -r requirements.txt --break-system-packages
Expand Down
10 changes: 8 additions & 2 deletions silkworm/rpc/core/evm_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <string>

#include <evmc/evmc.h>
#include <evmc/instructions.h>
#include <evmone/execution_state.hpp>
#include <evmone/instructions_traits.hpp>
Expand Down Expand Up @@ -558,12 +559,17 @@ Task<void> DebugExecutor::execute(
debug_tracer->flush_logs();
stream.close_array();

SILK_DEBUG << "debug return: " << execution_result.error_message();
SILK_DEBUG << "result error_code: " << execution_result.error_code.value_or(0) << ", message: " << execution_result.error_message();

if (!execution_result.pre_check_error) {
stream.write_json_field("failed", !execution_result.success());
stream.write_field("gas", transaction.gas_limit - execution_result.gas_left);
stream.write_field("returnValue", silkworm::to_hex(execution_result.data));
const auto error_code = execution_result.error_code.value_or(evmc_status_code::EVMC_SUCCESS);
if (error_code == evmc_status_code::EVMC_SUCCESS || error_code == evmc_status_code::EVMC_REVERT) {
stream.write_field("returnValue", silkworm::to_hex(execution_result.data));
} else {
stream.write_field("returnValue", "");
}
}
stream.close_object();

Expand Down

0 comments on commit f7d57cb

Please sign in to comment.