Skip to content

Commit

Permalink
rpcdaemon: debug_traceBlockByNumber support for block tags (#2626)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sixtysixter authored Dec 31, 2024
1 parent 9974f25 commit d9123c1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 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.32.0 https://github.com/erigontech/rpc-tests ${{runner.workspace}}/rpc-tests
git -c advice.detachedHead=false clone --depth 1 --branch v1.33.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
2 changes: 1 addition & 1 deletion .github/workflows/run_integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ debug_traceBlockByNumber/test_09,\
debug_traceBlockByNumber/test_10,\
debug_traceBlockByNumber/test_11,\
debug_traceBlockByNumber/test_12,\
debug_traceBlockByNumber/test_21,\
debug_traceBlockByNumber/test_29,\
debug_traceTransaction/test_25.json,\
debug_traceTransaction/test_36.json,\
debug_traceTransaction/test_43.json,\
Expand Down
14 changes: 7 additions & 7 deletions silkworm/rpc/commands/debug_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,14 +536,16 @@ Task<void> DebugRpcApi::handle_debug_trace_block_by_number(const nlohmann::json&
stream.write_json(reply);
co_return;
}

auto tx = co_await database_->begin();
BlockNum block_num{0};
if (params[0].is_string()) {
auto chain_storage = tx->create_storage();
BlockReader block_reader{*chain_storage, *tx};

const auto value = params[0].get<std::string>();
if (silkworm::is_valid_hex(value)) {
block_num = static_cast<BlockNum>(std::stol(value, nullptr, 16));
} else if (silkworm::is_valid_dec(value)) {
block_num = static_cast<BlockNum>(std::stol(value, nullptr, 10));
}

block_num = co_await block_reader.get_block_num(value);
} else {
block_num = params[0].get<BlockNum>();
}
Expand All @@ -557,8 +559,6 @@ Task<void> DebugRpcApi::handle_debug_trace_block_by_number(const nlohmann::json&
stream.write_json_field("id", request["id"]);
stream.write_field("jsonrpc", "2.0");

auto tx = co_await database_->begin();

try {
const auto chain_storage = tx->create_storage();

Expand Down

0 comments on commit d9123c1

Please sign in to comment.