Skip to content

Commit

Permalink
add new fields on block header serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
lupin012 committed Apr 24, 2024
1 parent 1f7b484 commit f687233
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
5 changes: 3 additions & 2 deletions silkworm/rpc/commands/erigon_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ Task<void> ErigonRpcApi::handle_erigon_get_block_by_timestamp(const nlohmann::js
const auto block_with_hash = co_await core::read_block_by_number(*block_cache_, *chain_storage, block_number);
if (!block_with_hash) {
const std::string error_msg = "block not found ";
SILK_ERROR << "erigon_get_block_by_timestamè: core::read_block_by_number: " << error_msg << request.dump();
SILK_ERROR << "erigon_get_block_by_timestamp: core::read_block_by_number: " << error_msg << request.dump();
make_glaze_json_error(request, 100, error_msg, reply);
co_await tx->close(); // RAII not (yet) available with coroutines
co_return;
Expand Down Expand Up @@ -259,7 +259,8 @@ Task<void> ErigonRpcApi::handle_erigon_get_header_by_hash(const nlohmann::json&

const auto header{co_await chain_storage->read_header(block_hash)};
if (!header) {
reply = make_json_error(request, 100, "block not found");
auto error_msg = "block header not found: 0x" + silkworm::to_hex(block_hash);
reply = make_json_error(request, -32000, error_msg);
} else {
reply = make_json_content(request, *header);
}
Expand Down
15 changes: 14 additions & 1 deletion silkworm/rpc/json/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,20 @@ void to_json(nlohmann::json& json, const BlockHeader& header) {
} else {
json["baseFeePerGas"] = nullptr;
}
json["withdrawalsRoot"] = nullptr; // waiting EIP-4895
json["AuRaSeal"] = nullptr;
json["AuRaStep"] = 0;
json["Verkle"] = false;
json["VerkleKeyVals"] = nullptr;
json["VerkleProof"] = nullptr;
json["blobGasUsed"] = nullptr;
json["excessBlobGas"] = nullptr;
json["parentBeaconBlockRoot"] = nullptr;
if (header.withdrawals_root) {
json["withdrawalsRoot"] = *header.withdrawals_root;
}
else {
json["withdrawalsRoot"] = nullptr;
}
}

} // namespace silkworm
Expand Down

0 comments on commit f687233

Please sign in to comment.