Skip to content

Commit

Permalink
state: Only mark touch of empty accounts
Browse files Browse the repository at this point in the history
If an account is being touched but is not empty it doesn't make sense
to mark it as touched. Touching only affects deleting empty accounts
but an account cannot become empty later during transaction execution
(except for selfdestruct, but this is tracked separately).

When executing all state tests from https://github.com/ethereum/tests,
this optimization reduces number of registered touch events by 99.2%
(from 1673250 to 13806) and number of reverted touch events by 99.7%
(from 1345463 to 401).

Moreover, considering current Mainnet status and
[EIP-7523: Empty accounts deprecation](https://eips.ethereum.org/EIPS/eip-7523)
empty accounts cannot be encountered after the Paris revision.
Therefore, this change total disables unnecessary touch handling
in current PoS networks.
  • Loading branch information
chfast committed Jan 9, 2024
1 parent 0c3fb24 commit 3a63f52
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/state/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ Account& State::get_or_insert(const address& addr, Account account)

Account& State::touch(const address& addr)
{
auto& acc = get_or_insert(addr);
if (!acc.erasable)
auto& acc = get_or_insert(addr, {.erasable = true});
if (!acc.erasable && acc.is_empty())
{
acc.erasable = true;
m_journal.emplace_back(JournalTouched{addr});
Expand Down

0 comments on commit 3a63f52

Please sign in to comment.