From ae3aa2b0cc587e0109d72bb2f0267c5bae2b53e0 Mon Sep 17 00:00:00 2001 From: rodiazet Date: Wed, 29 Mar 2023 17:00:17 +0200 Subject: [PATCH] t8n: Add `gasUsed` field for block Required by exe-spec-tests. Also fixes "cumulativeGasUsed" for receipts. --- test/t8n/t8n.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/t8n/t8n.cpp b/test/t8n/t8n.cpp index d0b4490c4..3431e3348 100644 --- a/test/t8n/t8n.cpp +++ b/test/t8n/t8n.cpp @@ -80,6 +80,7 @@ int main(int argc, const char* argv[]) j_result["currentDifficulty"] = "0x20000"; j_result["currentBaseFee"] = hex0x(block.base_fee); + int64_t cumulative_gas_used = 0; std::vector transactions; std::vector receipts; @@ -137,7 +138,8 @@ int main(int argc, const char* argv[]) j_receipt["transactionHash"] = hex0x(computed_tx_hash); j_receipt["gasUsed"] = hex0x(static_cast(receipt.gas_used)); - j_receipt["cumulativeGasUsed"] = j_receipt["gasUsed"]; + cumulative_gas_used += receipt.gas_used; + j_receipt["cumulativeGasUsed"] = hex0x(cumulative_gas_used); j_receipt["blockHash"] = hex0x(bytes32{}); j_receipt["contractAddress"] = hex0x(address{}); @@ -162,6 +164,7 @@ int main(int argc, const char* argv[]) j_result["logsBloom"] = hex0x(compute_bloom_filter(receipts)); j_result["receiptsRoot"] = hex0x(state::mpt_hash(receipts)); j_result["txRoot"] = hex0x(state::mpt_hash(transactions)); + j_result["gasUsed"] = hex0x(cumulative_gas_used); std::ofstream{output_dir / output_result_file} << std::setw(2) << j_result;