diff --git a/silkworm/rpc/commands/debug_api.cpp b/silkworm/rpc/commands/debug_api.cpp index a64ab4148d..09a39c5f32 100644 --- a/silkworm/rpc/commands/debug_api.cpp +++ b/silkworm/rpc/commands/debug_api.cpp @@ -259,6 +259,9 @@ Task DebugRpcApi::handle_debug_storage_range_at(const nlohmann::json& requ result["nextKey"] = "0x" + silkworm::to_hex(next_key); } + reply = make_json_content(request, result); + } catch (const std::invalid_argument& e) { + nlohmann::json result = {{"storage", nullptr}, {"nextKey", nullptr}}; reply = make_json_content(request, result); } catch (const std::exception& e) { SILK_ERROR << "exception: " << e.what() << " processing request: " << request.dump(); diff --git a/silkworm/rpc/commands/eth_api.cpp b/silkworm/rpc/commands/eth_api.cpp index c74b36a0d0..2e0ce2b0c4 100644 --- a/silkworm/rpc/commands/eth_api.cpp +++ b/silkworm/rpc/commands/eth_api.cpp @@ -281,7 +281,7 @@ Task EthereumRpcApi::handle_eth_get_block_transaction_count_by_hash(const reply = make_json_content(request, nullptr); } } catch (const std::invalid_argument& iv) { - reply = make_json_content(request, 0x0); + reply = make_json_content(request, nullptr); } catch (const std::exception& e) { SILK_ERROR << "exception: " << e.what() << " processing request: " << request.dump(); reply = make_json_error(request, kInternalError, e.what()); @@ -318,7 +318,7 @@ Task EthereumRpcApi::handle_eth_get_block_transaction_count_by_number(cons reply = make_json_content(request, nullptr); } } catch (const std::invalid_argument& iv) { - reply = make_json_content(request, 0x0); + reply = make_json_content(request, nullptr); } catch (const std::exception& e) { SILK_ERROR << "exception: " << e.what() << " processing request: " << request.dump(); reply = make_json_error(request, kInternalError, e.what()); @@ -921,6 +921,8 @@ Task EthereumRpcApi::handle_eth_estimate_gas(const nlohmann::json& request const auto estimated_gas = co_await estimate_gas_oracle.estimate_gas(call, latest_block, block_number_for_gas_limit); reply = make_json_content(request, to_quantity(estimated_gas)); + } catch (const std::invalid_argument& iv) { + reply = make_json_content(request, to_quantity(0)); } catch (const rpc::EstimateGasException& e) { SILK_ERROR << "EstimateGasException: code: " << e.error_code() << " message: " << e.message() << " processing request: " << request.dump(); if (e.data().empty()) { diff --git a/silkworm/rpc/core/evm_trace.cpp b/silkworm/rpc/core/evm_trace.cpp index 3a48f529f2..6bc5ac2f10 100644 --- a/silkworm/rpc/core/evm_trace.cpp +++ b/silkworm/rpc/core/evm_trace.cpp @@ -1775,7 +1775,12 @@ Task TraceCallExecutor::trace_filter(const TraceFilter& trace_filter, cons filter.count = trace_filter.count; auto block_number = trace_filter.from_block.number(); - auto block_with_hash = co_await core::read_block_by_number_or_hash(block_cache_, storage, tx_, trace_filter.from_block); + std::shared_ptr block_with_hash; + try { + block_with_hash = co_await core::read_block_by_number_or_hash(block_cache_, storage, tx_, trace_filter.from_block); + } catch (const std::invalid_argument& iv) { + block_with_hash = nullptr; + } while (block_number <= trace_filter.to_block.number()) { if (!block_with_hash) { @@ -1798,7 +1803,11 @@ Task TraceCallExecutor::trace_filter(const TraceFilter& trace_filter, cons } block_number++; - block_with_hash = co_await core::read_block_by_number(block_cache_, storage, block_number); + try { + block_with_hash = co_await core::read_block_by_number(block_cache_, storage, block_number); + } catch (const std::invalid_argument& iv) { + block_with_hash = nullptr; + } } stream.close_array();