Skip to content

Commit

Permalink
Add gasUsed field for block. Required by exe-spec-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rodiazet committed Mar 29, 2023
1 parent 293edab commit 3864564
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion test/t8n/t8n.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ int main(int argc, const char* argv[])
j_result["currentDifficulty"] = "0x20000";
j_result["currentBaseFee"] = hex0x(block.base_fee);

int64_t cumulativeGasUsed = 0;
std::vector<state::Transaction> transactions;
std::vector<state::TransactionReceipt> receipts;

Expand Down Expand Up @@ -137,7 +138,8 @@ int main(int argc, const char* argv[])

j_receipt["transactionHash"] = hex0x(computed_tx_hash);
j_receipt["gasUsed"] = hex0x(static_cast<uint64_t>(receipt.gas_used));
j_receipt["cumulativeGasUsed"] = j_receipt["gasUsed"];
cumulativeGasUsed += receipt.gas_used;
j_receipt["cumulativeGasUsed"] = hex0x(cumulativeGasUsed);

j_receipt["blockHash"] = hex0x(bytes32{});
j_receipt["contractAddress"] = hex0x(address{});
Expand All @@ -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(cumulativeGasUsed);

std::ofstream{output_dir / output_result_file} << std::setw(2) << j_result;

Expand Down

0 comments on commit 3864564

Please sign in to comment.