From 23736be800c3e42c378e2e9dbf2ca259f2aeea16 Mon Sep 17 00:00:00 2001 From: CPerezz Date: Thu, 9 Apr 2026 12:25:12 +0200 Subject: [PATCH] =?UTF-8?q?core/state,triedb/pathdb:=20doc=20accuracy=20sw?= =?UTF-8?q?eep=20=E2=80=94=20remove=20stale=20temporal=20markers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses review suggestion S2/S7/S22. Remove "NOT wired in yet", "in a later commit", and "Commit N" references that were accurate at the time of their original commit but became stale after subsequent commits landed on the same branch. Update cross-references to name the actual functions and files rather than commit numbers. Specific fixes: * flat_codec_bintrie.go:50-57: "NOT wired" → "wired when isVerkle" * flat_codec_bintrie.go:360: "in a later commit" → "generate_bintrie.go" * database_hasher_binary.go:132: "in a later commit" → "StateDB.commit()" * journal.go:53-56: v4 comment updated from "reserved for" → actual description --- core/state/database_hasher_binary.go | 9 +++++---- triedb/pathdb/flat_codec_bintrie.go | 21 ++++++++++----------- triedb/pathdb/journal.go | 8 ++++---- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/core/state/database_hasher_binary.go b/core/state/database_hasher_binary.go index 355f56b25d..0e843d31ff 100644 --- a/core/state/database_hasher_binary.go +++ b/core/state/database_hasher_binary.go @@ -129,10 +129,11 @@ func (tr *warpBinTrie) copy() *warpBinTrie { // // binaryHasher also implements LeafProducer: alongside every trie mutation // it records the corresponding (stem, offset, value) write into an -// internal buffer. The caller (StateDB.Commit in a later commit) drains -// this buffer once per block and hands the writes to the pathdb flat-state -// layer via the stateUpdate, keeping the bintrie trie and its flat-state -// mirror consistent without recomputing the bintrie key derivation twice. +// internal buffer. StateDB.commit() drains this buffer once per block +// via LeafProducer.DrainStemWrites and hands the writes to the pathdb +// flat-state layer via stateUpdate.encodeBinary, keeping the bintrie +// trie and its flat-state mirror consistent without recomputing the +// bintrie key derivation twice. type binaryHasher struct { db *triedb.Database root common.Hash diff --git a/triedb/pathdb/flat_codec_bintrie.go b/triedb/pathdb/flat_codec_bintrie.go index 28ea2ba253..a55d87b2b1 100644 --- a/triedb/pathdb/flat_codec_bintrie.go +++ b/triedb/pathdb/flat_codec_bintrie.go @@ -47,15 +47,13 @@ import ( // reads the stem from the store (not from the in-flight batch), so a // second write at the same stem would re-read the pre-flush state and // clobber the first write. The codec's public surface area is designed -// around this assumption; Commit 8 of the bintrie flat-state plan -// restructures writeStates to pre-aggregate per-stem writes so callers -// do not have to handle this manually. +// around this assumption; the Flush method pre-aggregates per-stem +// writes so callers do not have to handle this manually. // -// This codec is NOT wired into pathdb.Database.New yet — that happens in a -// later commit once the leaf-production hook in binaryHasher and the -// stateUpdate wiring are in place. Until then, all call sites still -// dispatch through merkleFlatCodec and bintrie mode continues to use the -// (soon to be replaced) keccak-shaped flat-state layout. +// This codec is wired into pathdb.Database.New when isVerkle is true +// (see database.go). The leaf-production hook in binaryHasher emits +// per-offset writes via DrainStemWrites, which encodeBinary routes +// into the per-offset accountData map consumed by Flush. type bintrieFlatCodec struct { // db is the underlying key-value store used by applyWrites to read // the current stem blob before merging in new (offset, value) pairs. @@ -357,9 +355,10 @@ func (c *bintrieFlatCodec) AccountPrefix() []byte { // StoragePrefix returns the same prefix as AccountPrefix because bintrie // flat-state entries are stored in a single namespace (stems contain -// both account and storage data). The generator in a later commit uses -// a single iterator over this prefix rather than the two-tier -// account-then-storage walk used by the merkle generator. +// both account and storage data). The bintrie generator +// (generate_bintrie.go) uses a single iterator over this prefix +// rather than the two-tier account-then-storage walk used by the +// merkle generator. func (c *bintrieFlatCodec) StoragePrefix() []byte { return rawdb.BinTrieStemPrefix } diff --git a/triedb/pathdb/journal.go b/triedb/pathdb/journal.go index 7a91419669..d586553d5b 100644 --- a/triedb/pathdb/journal.go +++ b/triedb/pathdb/journal.go @@ -50,10 +50,10 @@ var ( // - Version 1: storage.Incomplete field is removed // - Version 2: add post-modification state values // - Version 3: a flag has been added to indicate whether the storage slot key is the raw key or a hash -// - Version 4: reserved for bintrie flat-state (per-stem layout). Bumping now -// discards any v3 journals belonging to a bintrie database so -// that the new layout can be introduced cleanly in follow-up -// commits without a migration path. +// - Version 4: bintrie flat-state per-stem layout. The journalGenerator +// struct gains an IsBintrie flag (rlp:"optional", defaults to +// false) so the loader can discard journals from a mismatched +// scheme and trigger a full flat-state regeneration. const journalVersion uint64 = 4 // loadJournal tries to parse the layer journal from the disk.