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_traceBlockByNumber support for block tags #2626

Merged
merged 4 commits into from
Dec 31, 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.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
Loading