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

state: Fix processing withdrawals of 0 #670

Merged
merged 1 commit into from
Jul 8, 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
7 changes: 4 additions & 3 deletions test/state/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,13 @@ evmc_message build_message(const Transaction& tx, int64_t execution_gas_limit) n
void finalize(State& state, evmc_revision rev, const address& coinbase,
std::optional<uint64_t> block_reward, std::span<Withdrawal> withdrawals)
{
// TODO: The block reward can be represented as a withdrawal.
if (block_reward.has_value())
state.touch(coinbase).balance += *block_reward;

for (const auto& withdrawal : withdrawals)
state.touch(withdrawal.recipient).balance += withdrawal.get_amount();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember why we implemented this in different order originally. The use of .touch() indicates we want the account to be cleared.


if (rev >= EVMC_SPURIOUS_DRAGON)
{
std::erase_if(
Expand All @@ -131,9 +135,6 @@ void finalize(State& state, evmc_revision rev, const address& coinbase,
return acc.erasable && acc.is_empty();
});
}

for (const auto& withdrawal : withdrawals)
state.touch(withdrawal.recipient).balance += withdrawal.get_amount();
}

std::variant<TransactionReceipt, std::error_code> transition(
Expand Down