go-ethereum/core/state
rjl493456442 eb67d61933
cmd/geth, core/state, tests: rework EIP7610 check (#34718)
This PR simplifies the implementation of EIP-7610 by eliminating the
need to check storage emptiness during contract deployment.

EIP-7610 specifies that contract creation must be rejected if the
destination account has a non-zero nonce, non-empty runtime code, or 
**non-empty storage**.

After EIP-161, all newly deployed contracts are initialized with a nonce
of one. As a result, such accounts are no longer eligible as deployment 
targets unless they are explicitly cleared.

However, prior to EIP-161, contracts were initialized with a nonce of
zero. This made it possible to end up with accounts that have:

- zero nonce
- empty runtime code
- non-empty storage (created during constructor execution)
- non-zero balance

These edge-case accounts complicate the storage emptiness check.

In practice, contract addresses are derived using one of the following
formulas:
- `Keccak256(rlp({sender, nonce}))[12:]`
- `Keccak256([]byte{0xff}, sender, salt[:], initHash)[12:]`

As such, an existing address is not selected as a deployment target
unless a collision occurs, which is extremely unlikely.

---

Previously, verifying storage emptiness relied on GetStorageRoot.
However, with the transition to the block-based access list (BAL), 
the storage root is no longer available, as computing it would require 
reconstructing the full storage trie from all mutations of preceding 
transactions.

To address this, this PR introduces a simplified approach: it hardcodes
the set of known accounts that have zero nonce, empty runtime code, 
but non-empty storage and non-zero balance. During contract deployment, 
if the destination address belongs to this set, the deployment is
rejected.

This check is applied retroactively back to genesis. Since no address
collision events have occurred in Ethereum’s history, this change does
not
alter existing behavior. Instead, it serves as a safeguard for future
state
transitions.
2026-04-14 15:54:36 +02:00
..
pruner all: improve ETA calculation across all progress indicators (#32521) 2025-09-01 13:47:02 +08:00
snapshot crypto/keccak: vendor in golang.org/x/crypto/sha3 (#33323) 2026-02-03 14:55:27 -07:00
access_events.go trie, go.mod: remove all references to go-verkle and go-ipa (#33461) 2025-12-30 20:44:04 +08:00
access_events_test.go trie, go.mod: remove all references to go-verkle and go-ipa (#33461) 2025-12-30 20:44:04 +08:00
access_list.go core/state: improve accessList copy (#33024) 2025-10-26 16:13:59 +08:00
database.go core/state: introduce state iterator interface (#33102) 2026-04-03 10:35:32 +08:00
database_code.go core, miner, tests: introduce codedb and simplify cachingDB (#33816) 2026-03-10 08:29:21 +01:00
database_history.go core/state: introduce state iterator interface (#33102) 2026-04-03 10:35:32 +08:00
database_iterator.go core/state: introduce state iterator interface (#33102) 2026-04-03 10:35:32 +08:00
database_iterator_test.go core/state: introduce state iterator interface (#33102) 2026-04-03 10:35:32 +08:00
dump.go core/state: introduce state iterator interface (#33102) 2026-04-03 10:35:32 +08:00
iterator.go core, miner, tests: introduce codedb and simplify cachingDB (#33816) 2026-03-10 08:29:21 +01:00
iterator_test.go core/state: state reader abstraction (#29761) 2024-09-05 13:10:47 +03:00
journal.go core: miner: reduce allocations in block building (#33375) 2026-02-03 08:19:16 +01:00
metrics.go core/rawdb,state: add preimage miss metric (#31295) 2025-03-07 11:23:19 +01:00
reader.go core/state: avoid Bytes() allocation in flatReader hash computations (#34025) 2026-03-17 11:42:42 +01:00
reader_stater.go core, miner, tests: introduce codedb and simplify cachingDB (#33816) 2026-03-10 08:29:21 +01:00
state_object.go core/state: skip redundant trie Commit for Verkle in stateObject.commit (#34021) 2026-03-17 12:27:29 +01:00
state_object_test.go core/state: using testing.B.Loop (#32658) 2025-09-19 16:57:43 -06:00
state_sizer.go core/state: add bounds check in heap eviction loop (#33712) 2026-01-29 21:08:04 +08:00
state_sizer_test.go core/state: fix incorrect contract code state metrics (#33376) 2025-12-10 11:33:59 +08:00
state_test.go core, consensus/beacon: defer trie resolution (#31725) 2025-06-25 09:42:11 +08:00
statedb.go cmd/geth, core/state, tests: rework EIP7610 check (#34718) 2026-04-14 15:54:36 +02:00
statedb_fuzz_test.go core, miner, tests: introduce codedb and simplify cachingDB (#33816) 2026-03-10 08:29:21 +01:00
statedb_hooked.go cmd/geth, core/state, tests: rework EIP7610 check (#34718) 2026-04-14 15:54:36 +02:00
statedb_hooked_test.go core: invoke selfdestruct tracer hooks during finalisation (#32919) 2026-01-16 15:10:08 -07:00
statedb_test.go cmd/geth, core/state, tests: rework EIP7610 check (#34718) 2026-04-14 15:54:36 +02:00
stateupdate.go core, miner, tests: introduce codedb and simplify cachingDB (#33816) 2026-03-10 08:29:21 +01:00
sync.go core,eth,internal: fix typo (#29024) 2024-02-20 19:42:48 +08:00
sync_test.go core, miner, tests: introduce codedb and simplify cachingDB (#33816) 2026-03-10 08:29:21 +01:00
transient_storage.go core/state: optimize transient storage (#33695) 2026-04-14 15:39:42 +02:00
trie_prefetcher.go trie, core/state: introduce trie Prefetch for optimizing preload (#32134) 2025-08-20 21:45:27 +08:00
trie_prefetcher_test.go cmd/geth, core/state, tests: rework EIP7610 check (#34718) 2026-04-14 15:54:36 +02:00