Skip to content

Commit

Permalink
rpcdaemon: add NoRefunds flag in some debug API (#2616)
Browse files Browse the repository at this point in the history
  • Loading branch information
lupin012 authored Dec 23, 2024
1 parent 62b69b0 commit b0ce84b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 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.27.0 https://github.com/erigontech/rpc-tests ${{runner.workspace}}/rpc-tests
git -c advice.detachedHead=false clone --depth 1 --branch v1.28.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
1 change: 1 addition & 0 deletions .github/workflows/run_integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ debug_traceBlockByNumber/test_09,\
debug_traceBlockByNumber/test_10,\
debug_traceBlockByNumber/test_11,\
debug_traceBlockByNumber/test_12,\
debug_traceBlockByNumber/test_21,\
debug_traceCallMany/test_07,\
debug_traceCallMany/test_09,\
debug_traceTransaction/test_25.json,\
Expand Down
15 changes: 12 additions & 3 deletions silkworm/rpc/core/evm_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,17 @@ void from_json(const nlohmann::json& json, DebugConfig& tc) {
json.at("disableStorage").get_to(tc.disable_storage);
json.at("disableMemory").get_to(tc.disable_memory);
json.at("disableStack").get_to(tc.disable_stack);

if (json.count("NoRefunds") != 0) {
json.at("NoRefunds").get_to(tc.no_refunds);
}
}

std::ostream& operator<<(std::ostream& out, const DebugConfig& tc) {
out << "disableStorage: " << std::boolalpha << tc.disable_storage;
out << " disableMemory: " << std::boolalpha << tc.disable_memory;
out << " disableStack: " << std::boolalpha << tc.disable_stack;
out << " NoRefunds: " << std::boolalpha << tc.no_refunds;

return out;
}
Expand Down Expand Up @@ -443,6 +448,8 @@ Task<void> DebugExecutor::execute(json::Stream& stream, const ChainStorage& stor
auto state = state_factory.create_state(current_executor, storage, txn_id);
EVMExecutor executor{block, chain_config, workers_, state};

bool refunds = !config_.no_refunds;

for (std::uint64_t idx = 0; idx < transactions.size(); ++idx) {
rpc::Transaction txn{block.transactions[idx]};
SILK_DEBUG << "processing transaction: idx: " << idx << " txn: " << txn;
Expand All @@ -456,7 +463,7 @@ Task<void> DebugExecutor::execute(json::Stream& stream, const ChainStorage& stor
stream.open_array();

Tracers tracers{debug_tracer};
const auto execution_result = executor.call(block, txn, tracers, /* refund */ false, /* gasBailout */ false);
const auto execution_result = executor.call(block, txn, tracers, refunds, /* gasBailout */ false);

debug_tracer->flush_logs();
stream.close_array();
Expand Down Expand Up @@ -517,8 +524,9 @@ Task<void> DebugExecutor::execute(
stream.write_field("structLogs");
stream.open_array();

bool refunds = !config_.no_refunds;
Tracers tracers{debug_tracer};
const auto execution_result = executor.call(block, transaction, tracers);
const auto execution_result = executor.call(block, transaction, tracers, refunds);

debug_tracer->flush_logs();
stream.close_array();
Expand Down Expand Up @@ -587,6 +595,7 @@ Task<void> DebugExecutor::execute(
}

stream.open_array();
bool refunds = !config_.no_refunds;

for (const auto& call : bundle.transactions) {
silkworm::Transaction txn{call.to_transaction()};
Expand All @@ -598,7 +607,7 @@ Task<void> DebugExecutor::execute(
auto debug_tracer = std::make_shared<debug::DebugTracer>(stream, config_);
Tracers tracers{debug_tracer};

const auto execution_result = executor.call(block_context.block_with_hash->block, txn, tracers, /* refund */ false, /* gasBailout */ false);
const auto execution_result = executor.call(block_context.block_with_hash->block, txn, tracers, refunds, /* gasBailout */ false);

debug_tracer->flush_logs();
stream.close_array();
Expand Down
1 change: 1 addition & 0 deletions silkworm/rpc/core/evm_debug.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct DebugConfig {
bool disable_storage{false};
bool disable_memory{false};
bool disable_stack{false};
bool no_refunds{false};
};

std::string uint256_to_hex(const evmone::uint256& x);
Expand Down
2 changes: 1 addition & 1 deletion silkworm/rpc/core/evm_debug_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ TEST_CASE_METHOD(DebugExecutorTest, "DebugConfig") {

std::ostringstream os;
os << config;
CHECK(os.str() == "disableStorage: true disableMemory: false disableStack: true");
CHECK(os.str() == "disableStorage: true disableMemory: false disableStack: true NoRefunds: false");
}
}

Expand Down

0 comments on commit b0ce84b

Please sign in to comment.