go-ethereum/core/state
Daniel Liu e02bc0723a
refactor(core): semantic journalling #28880 (#2081)
This is a follow-up to #29520, and a preparatory PR to a more thorough
change in the journalling system.

This PR hides the journal-implementation details away, so that the
statedb invokes methods like `JournalCreate`, instead of explicitly
appending journal-events in a list. This means that it's up to the
journal whether to implement it as a sequence of events or
aggregate/merge events.

This PR also makes it so that management of valid snapshots is moved
inside the journal, exposed via the methods `Snapshot() int` and
`RevertToSnapshot(revid int, s *StateDB)`.

JournalSetCode journals the setting of code: it is implicit that the
previous values were "no code" and emptyCodeHash. Therefore, we can
simplify the setCode journal.

The self-destruct journalling is a bit strange: we allow the
selfdestruct operation to be journalled several times. This makes it so
that we also are forced to store whether the account was already
destructed.

What we can do instead, is to only journal the first destruction, and
after that only journal balance-changes, but not journal the
selfdestruct itself.

This simplifies the journalling, so that internals about state
management does not leak into the journal-API.

Preimages were, for some reason, integrated into the journal management,
despite not being a consensus-critical data structure. This PR undoes
that.

---------

Co-authored-by: Martin HS <martin@swende.se>
Co-authored-by: Gary Rong <garyrong0905@gmail.com>
2026-03-07 17:42:10 +05:30
..
access_list.go core/state: reduce one alloc #33024 (#1784) 2025-11-24 11:00:15 +05:30
database.go refactor(core): make signature of ContractCode hash-independent #27209 (#1169) 2026-02-13 09:11:43 +05:30
dump.go refactor(all): track state changes in state db #27349 (#1947) 2026-02-24 10:27:31 +05:30
iterator.go refactor(core): make signature of ContractCode hash-independent #27209 (#1169) 2026-02-13 09:11:43 +05:30
iterator_test.go all: port boring changes from pbss #27176 (#1158) 2026-01-26 11:21:46 +05:30
journal.go refactor(core): semantic journalling #28880 (#2081) 2026-03-07 17:42:10 +05:30
metrics.go refactor(all): track state changes in state db #27349 (#1947) 2026-02-24 10:27:31 +05:30
state_object.go refactor(core): semantic journalling #28880 (#2081) 2026-03-07 17:42:10 +05:30
state_object_test.go all: using testing.B.Loop (#1554) 2025-09-24 07:59:48 +08:00
state_reader.go new EVM Upgrade 2021-09-21 16:53:46 +05:30
state_test.go core/state: remove account reset operation v2 #29520 (#1934) 2026-02-24 14:17:27 +05:30
statedb.go refactor(core): semantic journalling #28880 (#2081) 2026-03-07 17:42:10 +05:30
statedb_fuzz_test.go refactor(core): semantic journalling #28880 (#2081) 2026-03-07 17:42:10 +05:30
statedb_hooked.go core/state: ensure deterministic hook emission order in Finalise #33644 (#1981) 2026-01-29 11:23:33 +05:30
statedb_hooked_test.go all: expose block number information to statedb #27753 (#1936) 2026-01-16 15:55:04 +05:30
statedb_test.go refactor(core): semantic journalling #28880 (#2081) 2026-03-07 17:42:10 +05:30
statedb_utils.go record total minted API v2 (#1769) 2025-12-09 19:43:19 +08:00
sync.go core, trie: prepare for path-based trie storage #26603 (#1126) 2025-11-18 11:20:00 +05:30
sync_test.go refactor(core): make signature of ContractCode hash-independent #27209 (#1169) 2026-02-13 09:11:43 +05:30
transient_storage.go all: implement EIP-1153 transient storage (#26003) 2024-11-15 19:39:18 +08:00
trc21_reader.go all: rework trc21 (#1777) 2025-11-18 11:24:56 +05:30