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: Rename .erasable.erase_if_empty #787

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion test/state/account.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ struct Account
/// The account should be erased if it is empty at the end of a transaction.
/// This flag means the account has been "touched" as defined in EIP-161
/// or it is a newly created temporary account.
bool erasable = false;
///
/// Yellow Paper uses term "delete" but it is a keyword in C++ while
/// the term "erase" is used for deleting objects from C++ collections.
bool erase_if_empty = false;

/// The account has been created in the current transaction.
bool just_created = false;
Expand Down
4 changes: 2 additions & 2 deletions test/state/host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ evmc::Result Host::call(const evmc_message& orig_msg) noexcept
{
static constexpr auto addr_03 = 0x03_address;
auto* const acc_03 = m_state.find(addr_03);
const auto is_03_touched = acc_03 != nullptr && acc_03->erasable;
const auto is_03_touched = acc_03 != nullptr && acc_03->erase_if_empty;

// Revert.
m_state.rollback(state_checkpoint);
Expand Down Expand Up @@ -394,7 +394,7 @@ evmc_access_status Host::access_account(const address& addr) noexcept
if (m_rev < EVMC_BERLIN)
return EVMC_ACCESS_COLD; // Ignore before Berlin.

auto& acc = m_state.get_or_insert(addr, {.erasable = true});
auto& acc = m_state.get_or_insert(addr, {.erase_if_empty = true});

if (acc.access_status == EVMC_ACCESS_WARM || is_precompile(m_rev, addr))
return EVMC_ACCESS_WARM;
Expand Down
4 changes: 2 additions & 2 deletions test/state/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void State::rollback(size_t checkpoint)
}
else if constexpr (std::is_same_v<T, JournalTouched>)
{
get(e.addr).erasable = false;
get(e.addr).erase_if_empty = false;
}
else if constexpr (std::is_same_v<T, JournalDestruct>)
{
Expand Down Expand Up @@ -256,7 +256,7 @@ void delete_empty_accounts(State& state)
{
std::erase_if(state.get_accounts(), [](const std::pair<const address, Account>& p) noexcept {
const auto& acc = p.second;
return acc.erasable && acc.is_empty();
return acc.erase_if_empty && acc.is_empty();
});
}
} // namespace
Expand Down
4 changes: 2 additions & 2 deletions test/state/state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ class State
Account& touch(const address& addr)
{
auto& acc = get_or_insert(addr);
if (!acc.erasable)
if (!acc.erase_if_empty)
{
acc.erasable = true;
acc.erase_if_empty = true;
m_journal.emplace_back(JournalTouched{addr});
}
return acc;
Expand Down