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: add missing fields in ots_getBlockTransactions #1999

Merged
merged 3 commits into from
May 7, 2024
Merged
Changes from 1 commit
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
Next Next commit
add withdrawals info serialization and baseFeePerGas
lupin012 committed May 5, 2024
commit 23c786f2f3a2240e1158459765301cc5d6f1dc7e
5 changes: 3 additions & 2 deletions silkworm/rpc/commands/ots_api.cpp
Original file line number Diff line number Diff line change
@@ -226,8 +226,9 @@ Task<void> OtsRpcApi::handle_ots_get_block_transactions(const nlohmann::json& re
auto block_size = extended_block.get_block_size();
auto transaction_count = block_with_hash->block.transactions.size();

BlockTransactionsResponse block_transactions{block_size, block_with_hash->hash, block_with_hash->block.header, *total_difficulty,
transaction_count, block_with_hash->block.ommers};
BlockTransactionsResponse block_transactions{block_size, block_with_hash->hash, block_with_hash->block.header, *total_difficulty, transaction_count, block_with_hash->block.ommers, {}, // receipt
{}, // transactions
block_with_hash->block.withdrawals};

auto page_end = block_with_hash->block.transactions.size() - (page_size * page_number);

10 changes: 10 additions & 0 deletions silkworm/rpc/json/types.cpp
Original file line number Diff line number Diff line change
@@ -362,6 +362,16 @@ void to_json(nlohmann::json& json, const BlockTransactionsResponse& b) {
json["fullblock"]["timestamp"] = to_quantity(b.header.timestamp);
json["fullblock"]["totalDifficulty"] = to_quantity(silkworm::endian::to_big_compact(b.total_difficulty));
json["fullblock"]["transactionCount"] = b.transaction_count;
if (b.header.base_fee_per_gas) {
json["fullblock"]["baseFeePerGas"] = rpc::to_quantity(b.header.base_fee_per_gas.value_or(0));
}
if (b.header.withdrawals_root) {
json["fullblock"]["withdrawalsRoot"] = *b.header.withdrawals_root;
}

if (b.withdrawals) {
json["fullblock"]["withdrawals"] = *(b.withdrawals);
}

json["fullblock"]["transactions"] = b.transactions;
for (std::size_t i{0}; i < json["fullblock"]["transactions"].size(); i++) {