mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-03-18 00:50:39 +00:00
## Summary **Bug fix.** In Verkle mode, all state objects share a single unified trie (`OpenStorageTrie` returns `self`). During `stateDB.commit()`, the main account trie is committed via `s.trie.Commit(true)`, which calls `CollectNodes` to traverse and serialize the entire tree. However, each dirty account's `obj.commit()` also calls `s.trie.Commit(false)` on the **same trie object**, redundantly traversing and serializing the full tree once per dirty account. With N dirty accounts per block, this causes **N+1 full-tree traversals** instead of 1. On a write-heavy workload (2250 SSTOREs), this produces ~131 GB of allocations per block from duplicate NodeSet creation and serialization. It also causes a latent data race from N+1 goroutines concurrently calling `CollectNodes` on shared `InternalNode` objects. This commit adds an `IsVerkle()` early return in `stateObject.commit()` to skip the redundant `trie.Commit()` call. ## Benchmark (AMD EPYC 48-core, 500K entries, `--benchtime=10s --count=3`) | Metric | Baseline | Fixed | Delta | |--------|----------|-------|-------| | Approve (Mgas/s) | 4.16 ± 0.37 | **220.2 ± 10.1** | **+5190%** | | BalanceOf (Mgas/s) | 966.2 ± 8.1 | 971.0 ± 3.0 | +0.5% | | Allocs/op (approve) | 136.4M | 792K | **-99.4%** | Resolves the TODO in statedb.go about the account trie commit being "very heavy" and "something's wonky". --------- Co-authored-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| 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 | ||