From ae3aa2b0cc587e0109d72bb2f0267c5bae2b53e0 Mon Sep 17 00:00:00 2001 From: rodiazet Date: Wed, 29 Mar 2023 17:00:17 +0200 Subject: [PATCH 1/2] 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 d0b4490c4a..3431e3348f 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; From 3c96e41bae1604b070b25e59dcc3381b60ab1b66 Mon Sep 17 00:00:00 2001 From: rodiazet Date: Wed, 29 Mar 2023 16:46:21 +0200 Subject: [PATCH 2/2] t8n: Output `txs.rlp` file with all transactions Returning for exec-spec-tests. --- test/t8n/t8n.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/t8n/t8n.cpp b/test/t8n/t8n.cpp index 3431e3348f..5c62ab5f31 100644 --- a/test/t8n/t8n.cpp +++ b/test/t8n/t8n.cpp @@ -27,6 +27,7 @@ int main(int argc, const char* argv[]) fs::path output_dir; fs::path output_result_file; fs::path output_alloc_file; + fs::path output_body_file; std::optional block_reward; uint64_t chain_id = 0; @@ -59,6 +60,8 @@ int main(int argc, const char* argv[]) block_reward = intx::from_string(argv[i]); else if (arg == "--state.chainid" && ++i < argc) chain_id = intx::from_string(argv[i]); + else if (arg == "--output.body" && ++i < argc) + output_body_file = argv[i]; } state::BlockInfo block; @@ -182,6 +185,9 @@ int main(int argc, const char* argv[]) } std::ofstream{output_dir / output_alloc_file} << std::setw(2) << j_alloc; + + if (!output_body_file.empty()) + std::ofstream{output_dir / output_body_file} << hex0x(rlp::encode(transactions)); } catch (const std::exception& e) {