mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-03-21 18:38:07 +00:00
## Summary In binary trie mode, `IntermediateRoot` calls `updateTrie()` once per dirty account. But with the binary trie there is only one unified trie (`OpenStorageTrie` returns `self`), so each call redundantly does per-account trie setup: `getPrefetchedTrie`, `getTrie`, slice allocations for deletions/used, and `prefetcher.used` — all for the same trie pointer. This PR replaces the per-account `updateTrie()` calls with a single flat loop that applies all storage updates directly to `s.trie`. The MPT path is unchanged. The prefetcher trie replacement is guarded to avoid overwriting the binary trie that received updates. This is the phase-1 counterpart to #34021 (H01). H01 fixes the commit phase (`trie.Commit()` called N+1 times). This PR fixes the update phase (`updateTrie()` called N times with redundant setup). Same root cause — unified binary trie operated on per-account — different phases. ## Benchmark (Apple M4 Pro, 500K entries, `--benchtime=10s --count=3`, on top of #34021) | Metric | H01 baseline | H01 + this PR | Delta | |--------|:------------:|:-------------:|:-----:| | Approve (Mgas/s) | 368 | **414** | **+12.5%** | | BalanceOf (Mgas/s) | 870 | 875 | +0.6% | Should be rebased after #34021 is merged. |
||
|---|---|---|
| .. | ||
| pruner | ||
| snapshot | ||
| access_events.go | ||
| access_events_test.go | ||
| access_list.go | ||
| database.go | ||
| database_code.go | ||
| database_history.go | ||
| dump.go | ||
| iterator.go | ||
| iterator_test.go | ||
| journal.go | ||
| metrics.go | ||
| reader.go | ||
| reader_stater.go | ||
| state_object.go | ||
| state_object_test.go | ||
| state_sizer.go | ||
| state_sizer_test.go | ||
| state_test.go | ||
| statedb.go | ||
| statedb_fuzz_test.go | ||
| statedb_hooked.go | ||
| statedb_hooked_test.go | ||
| statedb_test.go | ||
| stateupdate.go | ||
| sync.go | ||
| sync_test.go | ||
| transient_storage.go | ||
| trie_prefetcher.go | ||
| trie_prefetcher_test.go | ||