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: some fixes after porting erigon 2.60 #2287

Merged
merged 6 commits into from
Sep 2, 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 @@ -27,7 +27,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 v0.44.0 https://github.com/erigontech/rpc-tests ${{runner.workspace}}/rpc-tests
git -c advice.detachedHead=false clone --depth 1 --branch v0.45.0 https://github.com/erigontech/rpc-tests ${{runner.workspace}}/rpc-tests
cd ${{runner.workspace}}/rpc-tests
pip3 install -r requirements.txt

Expand Down
3 changes: 1 addition & 2 deletions silkworm/rpc/commands/erigon_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,7 @@ Task<void> ErigonRpcApi::handle_erigon_get_logs_by_hash(const nlohmann::json& re

const auto block_with_hash = co_await core::read_block_by_hash(*block_cache_, *chain_storage, block_hash);
if (!block_with_hash) {
std::vector<Logs> logs{};
reply = make_json_content(request, logs);
reply = make_json_content(request, nullptr);
co_await tx->close(); // RAII not (yet) available with coroutines
co_return;
}
Expand Down
28 changes: 14 additions & 14 deletions silkworm/rpc/commands/eth_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ Task<void> EthereumRpcApi::handle_eth_get_block_transaction_count_by_hash(const
const auto tx_count = block_with_hash->block.transactions.size();
reply = make_json_content(request, to_quantity(tx_count));
} else {
reply = make_json_content(request, 0x0);
reply = make_json_content(request, nullptr);
}
} catch (const std::invalid_argument& iv) {
reply = make_json_content(request, 0x0);
Expand Down Expand Up @@ -315,7 +315,7 @@ Task<void> EthereumRpcApi::handle_eth_get_block_transaction_count_by_number(cons
const auto tx_count = block_with_hash->block.transactions.size();
reply = make_json_content(request, to_quantity(tx_count));
} else {
reply = make_json_content(request, 0x0);
reply = make_json_content(request, nullptr);
}
} catch (const std::invalid_argument& iv) {
reply = make_json_content(request, 0x0);
Expand Down Expand Up @@ -458,11 +458,12 @@ Task<void> EthereumRpcApi::handle_eth_get_uncle_count_by_block_hash(const nlohma
const auto chain_storage = tx->create_storage();

const auto block_with_hash = co_await core::read_block_by_hash(*block_cache_, *chain_storage, block_hash);
uint64_t ommers = 0;
if (block_with_hash) {
ommers = block_with_hash->block.ommers.size();
if (!block_with_hash) {
reply = make_json_content(request, nullptr);
} else {
const auto ommers = block_with_hash->block.ommers.size();
reply = make_json_content(request, to_quantity(ommers));
}
reply = make_json_content(request, to_quantity(ommers));
} catch (const std::exception& e) {
SILK_ERROR << "exception: " << e.what() << " processing request: " << request.dump();
reply = make_json_error(request, kInternalError, e.what());
Expand Down Expand Up @@ -493,12 +494,12 @@ Task<void> EthereumRpcApi::handle_eth_get_uncle_count_by_block_number(const nloh

const auto block_number = co_await core::get_block_number(block_id, *tx);
const auto block_with_hash = co_await core::read_block_by_number(*block_cache_, *chain_storage, block_number);
uint64_t ommers = 0;
if (block_with_hash) {
ommers = block_with_hash->block.ommers.size();
if (!block_with_hash) {
reply = make_json_content(request, nullptr);
} else {
const auto ommers = block_with_hash->block.ommers.size();
reply = make_json_content(request, to_quantity(ommers));
}

reply = make_json_content(request, to_quantity(ommers));
} catch (const std::exception& e) {
SILK_ERROR << "exception: " << e.what() << " processing request: " << request.dump();
reply = make_json_error(request, kInternalError, e.what());
Expand Down Expand Up @@ -1395,9 +1396,8 @@ Task<void> EthereumRpcApi::handle_eth_call_bundle(const nlohmann::json& request,
struct CallBundleTxInfo tx_info {};
const auto tx_with_block = co_await core::read_transaction_by_hash(*block_cache_, *chain_storage, tx_hash_list[i]);
if (!tx_with_block) {
const auto error_msg = "invalid transaction hash";
SILK_ERROR << error_msg;
reply = make_json_error(request, kInvalidParams, error_msg);
reply = make_json_content(request, {});
error = true;
break;
}

Expand Down
4 changes: 4 additions & 0 deletions silkworm/rpc/commands/txpool_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ Task<void> TxPoolRpcApi::handle_txpool_status(const nlohmann::json& request, nlo
Task<void> TxPoolRpcApi::handle_txpool_content(const nlohmann::json& request, nlohmann::json& reply) {
try {
const auto txpool_transactions = co_await tx_pool_->get_transactions();
if (!txpool_transactions.size()) {
reply = make_json_content(request, nullptr);
co_return;
}

TransactionContent transactions_content;
transactions_content["queued"];
Expand Down
Loading