From 3a63f52e47b5cf44c5a340859cd3d3270b2a55d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Fri, 22 Dec 2023 16:57:49 +0100 Subject: [PATCH] state: Only mark touch of empty accounts 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. --- test/state/state.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/state/state.cpp b/test/state/state.cpp index aae72028eb..2c5f01fea1 100644 --- a/test/state/state.cpp +++ b/test/state/state.cpp @@ -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});