From 333751735e6aa4947f071adf769ef087ca65e19f Mon Sep 17 00:00:00 2001 From: rodiazet Date: Wed, 8 Feb 2023 23:01:04 +0100 Subject: [PATCH] Add state.reward processing --- test/t8n/t8n.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/t8n/t8n.cpp b/test/t8n/t8n.cpp index 4c1a0bfe17..b2e2f5079a 100644 --- a/test/t8n/t8n.cpp +++ b/test/t8n/t8n.cpp @@ -30,6 +30,7 @@ int main(int argc, const char* argv[]) fs::path output_dir; fs::path output_result_file; fs::path output_alloc_file; + intx::uint256 state_reward; for (int i = 0; i < argc; ++i) { @@ -54,6 +55,13 @@ int main(int argc, const char* argv[]) output_result_file = argv[i]; else if (arg == "--output.alloc" && ++i < argc) output_alloc_file = argv[i]; + else if (arg == "--state.reward" && ++i < argc) + { + if (std::string(argv[i]) == "-1") + state_reward = std::numeric_limits::max(); + else + state_reward = intx::from_string(argv[i]); + } } state::BlockInfo block; @@ -128,6 +136,16 @@ int main(int argc, const char* argv[]) } } + if (state_reward != 0 && state_reward != std::numeric_limits::max()) + state.get_or_insert(block.coinbase).balance += state_reward; + else if (state_reward == 0) + state.touch(block.coinbase); + else if (state_reward == std::numeric_limits::max()) + { + if (state.get_or_insert(block.coinbase).is_empty()) + state.get_accounts().erase(block.coinbase); + } + j_result["logsHash"] = hex0x(logs_hash(txs_logs)); j_result["stateRoot"] = hex0x(state::mpt_hash(state.get_accounts())); }