Skip to content

Commit

Permalink
Add state.reward processing
Browse files Browse the repository at this point in the history
  • Loading branch information
rodiazet committed Feb 8, 2023
1 parent 886174b commit 390393f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/t8n/t8n.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -54,6 +55,14 @@ 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<intx::uint256>::max();
else
state_reward = intx::from_string<intx::uint256>(argv[i]);
}

}

state::BlockInfo block;
Expand Down Expand Up @@ -128,6 +137,16 @@ int main(int argc, const char* argv[])
}
}

if (state_reward != 0 && state_reward != std::numeric_limits<intx::uint256>::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<intx::uint256>::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()));
}
Expand Down

0 comments on commit 390393f

Please sign in to comment.