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

Add t8n features required by exe-spec-tests #604

Merged
merged 2 commits into from
Mar 29, 2023
Merged
Changes from all commits
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
11 changes: 10 additions & 1 deletion test/t8n/t8n.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<intx::uint256> block_reward;
uint64_t chain_id = 0;

Expand Down Expand Up @@ -59,6 +60,8 @@ int main(int argc, const char* argv[])
block_reward = intx::from_string<intx::uint256>(argv[i]);
else if (arg == "--state.chainid" && ++i < argc)
chain_id = intx::from_string<uint64_t>(argv[i]);
else if (arg == "--output.body" && ++i < argc)
output_body_file = argv[i];
}

state::BlockInfo block;
Expand All @@ -80,6 +83,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<state::Transaction> transactions;
std::vector<state::TransactionReceipt> receipts;

Expand Down Expand Up @@ -137,7 +141,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"];
cumulative_gas_used += receipt.gas_used;
j_receipt["cumulativeGasUsed"] = hex0x(cumulative_gas_used);

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

Expand All @@ -179,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)
{
Expand Down