Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
186 commits
Select commit Hold shift + click to select a range
ddc6df7
commitment: extract canonical DecodeBranchInto from unfoldBranchNode
May 4, 2026
31fdf57
commitment: add BranchCache with pinned root + bounded LRU tail
May 5, 2026
1593f0e
commitment: document BranchCache concurrency contract
May 5, 2026
8a2c565
commitment: wire BranchCache into trie read + encoder write paths
May 5, 2026
2849165
commitment, db/state: lift BranchCache lifetime to aggregator scope
May 5, 2026
f87937e
commitment: BranchCache divergence detector + per-block fingerprint log
May 6, 2026
b61655c
commitment: disable deferred-encoding mode (use inline CollectUpdate)
May 6, 2026
7e21628
commitment: add DISABLE_BRANCH_CACHE_READS env kill-switch
May 6, 2026
8d6d19a
commitment: multi-layer state probe at BranchCache divergence site
May 7, 2026
87f12be
commitment: tag BranchCache writes with origin + write-seq + timestamp
May 7, 2026
6989427
commitment, db/state/execctx: move BranchCache behind sd.mem chain
May 7, 2026
99823bb
commitment/branch_cache: document responsibility split + post-WarmupC…
May 8, 2026
4410704
commitment/branch_cache: add pinned tier (PinEntry / PinnedCount)
May 8, 2026
9b7c02a
commitment/preload: PreloadContractTrunk recursive enumeration
May 8, 2026
a60b052
state/execctx, commitment: PIN_CONTRACT_TRUNKS env hook
May 8, 2026
71d8480
state/execctx: trunk-preload sync (was async, hit cgo-pointer panic)
May 8, 2026
f85308d
commitment, state/execctx: trunk-preload progress logs + max-branches…
May 8, 2026
a289adc
state/execctx: run trunk-preload AFTER SeekCommitment
May 8, 2026
29ebc42
state/execctx: trunk-preload async with own tx, triggered from Enable…
May 8, 2026
db656cc
execution/commitment: PIN_TRUNK_MAX_DEPTH env + raise maxBranches cap
May 8, 2026
ce8cce4
stagedsync/exec3_parallel: re-enable trie warmup on parallel path
May 4, 2026
e97c95f
commitment: WarmupCache hit/miss/evict observability counters
May 4, 2026
af2ef68
commitment: extract unfoldKeyPath as per-key traversal primitive
May 4, 2026
4074bcc
commitment: WarmupCache dirty-flag + PutBranchIfClean invariants
May 5, 2026
4be9c86
commitment: WarmupCache GetBranchDecoded — lazy-decode read path
May 5, 2026
733dad5
execmodule: chain ValidateChain SD to currentContext for head-extendi…
May 6, 2026
a823097
db/state: H0 baseline benchmark for snapshot-vs-MDBX read cost
May 7, 2026
118298a
db/state: H0 real-datadir bootstrap; first production numbers
May 7, 2026
005790f
db/state, commitment: H_GetAsOf bench + per-block calculator timing
May 7, 2026
4276219
commitment: surface per-block telemetry on cache-fp log
May 8, 2026
1e8c25c
stagedsync/calc_state: skip wasted ensureStorage in StoragePath Apply…
May 8, 2026
a263695
commitment: split disk-load counter from EVM-write plumbing
May 8, 2026
fd593ca
state, commitment: scaffold to quantify EIP-684 HasPrefix cost on sna…
May 8, 2026
d2ac8ef
commitment, dbg: warmer scales 1:1 with cores; document pooling strategy
May 8, 2026
20b020d
existence, state, commitment: add measurement counters for assumption…
May 8, 2026
fefec01
commitment/warmuper: stop walking past leaf cells
May 8, 2026
c57420b
commitment: drop BranchEncoder's WarmupCache fast path
May 8, 2026
63e1124
commitment/hph: drop hph.cache (WarmupCache read-through layer)
May 8, 2026
39b758e
commitment, db/state, stagedsync: delete WarmupCache type and toggle …
May 8, 2026
b99c192
commitment: mark BranchCache dirty in CollectDeferredUpdate too
May 8, 2026
80ea439
commitment/warmuper: scope warmer to branches only — drop account/sto…
May 8, 2026
614fb7b
state, commitment: add unique-prefix file-read counter
May 8, 2026
4b95d45
state, commitment: add unique-prefix length histogram
May 8, 2026
d566e9b
state, commitment: refine length histogram inside storage subtree
May 8, 2026
65fbd14
state/changeset: trunk-probe log to identify hot contracts
May 8, 2026
c07a688
commitment: surface pinned-tier counters on cache-fp log
May 8, 2026
a62cbaf
db/state, db/kv: add TemporalMemBatch.FlushWithCallback
May 10, 2026
8bad508
commitment, state/execctx: BFS / budget-driven trunk preload
May 10, 2026
b29f3cf
state/execctx: raise PIN_TRUNK_RAM_BUDGET_MB default 32 → 64
May 10, 2026
d494eec
state/execctx: clamp PIN_TRUNK_RAM_BUDGET_MB at 64 MiB per contract
May 10, 2026
6ea7ff8
commitment/branch_cache: pin-aware Invalidate, GetWithOrigin, Clear
May 10, 2026
9ef3b9c
state/execctx: invalidate stale BranchCache entries on SD.Unwind
May 10, 2026
878f04a
commitment/preload: split BFS into resumable ContractTrunkPreload
May 10, 2026
a2b6ab5
commitment/branch_cache: add miss-callback hook for adaptive controller
May 10, 2026
be2616e
commitment: AdaptivePinController for promotion / extension / demotion
May 10, 2026
b082c93
state/execctx: wire AdaptivePinController into SharedDomains
May 10, 2026
2c6ee4e
commitment: Prometheus metrics for trunk-pin layer
May 10, 2026
f48c411
commitment: tests for trunk-pin layer + delete orphaned warmup test
May 10, 2026
e69e9bf
commitment, db/state: drop bench-only env knobs and cache-fp log
May 10, 2026
e0b0189
lint: gofmt fixes + drop snapshot_vs_mdbx bench test
May 10, 2026
fa4d7f7
perf(r3): bulk storage-trunk preload via two-parity range scan (core …
May 11, 2026
b4591a2
perf(r3): wire triggerTrunkPreload to the bulk range-scan path
May 11, 2026
ae86359
perf(r3): adaptive controller uses LoadBulk (range scan) when available
May 11, 2026
4ca9284
perf(preload): retire the broken R3 range-scan preload
May 12, 2026
3e0154f
perf(preload): parallel file-only wave-BFS preload (cut-down)
May 12, 2026
4c9968a
perf(preload): cap per-wave fetch by remaining budget
May 12, 2026
eb0c0c5
perf(preload): phase 1 — MDBX-resident branch prefetch (operational c…
May 12, 2026
a3374fe
db/state: test for the phase-1 dbPrefetch cursor walk
May 13, 2026
9db0d59
commitment, db/state: resumable parallel preload + adaptive parallel-…
May 13, 2026
ae9b3f3
execution/commitment: keep the trie checkpoint key out of BranchCache
May 21, 2026
3065d89
execution: parent fork-validation SD into the canonical generation
May 21, 2026
ae711df
execution/commitment: prealloc rest slice in preload_parallel
May 22, 2026
b2a9d64
db/state/execctx, execution/execmodule: clear BranchCache on SetHead …
May 16, 2026
9f5086b
Merge remote-tracking branch 'origin/main' into mh/perf-caches-pr
May 23, 2026
f151829
execution/stagedsync/rawdbreset: clear branchCache on ResetExec (#21138)
May 23, 2026
9898f3c
common/dbg, node/ethconfig: default ExecWorkerCount = NumCPU-1
May 23, 2026
6454b7b
Revert "common/dbg, node/ethconfig: default ExecWorkerCount = NumCPU-1"
May 23, 2026
e8ba812
cmd/evm, execution/tests: per-subtest ephemeral SharedDomains for sta…
mh0lt May 24, 2026
54a9029
execution/tests: read pre-state via sd.AsGetter so tx execution sees …
mh0lt May 24, 2026
57dd0d6
execution/engineapi/engineapitester: reset aggregator branchCache bet…
mh0lt May 24, 2026
5a415cf
execution/cache, db/state/execctx: SD-transparent ethHash bypass for …
May 14, 2026
4499ad5
execution/cache, db/state, execution/state: codeSizeCache for EXTCODE…
May 14, 2026
ad565fe
execution/exec, execution/execmodule: BlockReadAheader populates cach…
May 15, 2026
2d82956
execution/state, execution/cache: stateObject.code populate + addrToH…
May 15, 2026
987f741
execution/cache, db/state/execctx: addr → codeHash LRU above SD
May 15, 2026
934082b
execution/exec: cachePopulatingGetter caches negative results
May 15, 2026
e96df71
execution/cache: surface fill-and-freeze cliff via inserts/dropped co…
May 15, 2026
7b5a71c
execution/cache: replace GenericCache map with sharded LRU + Mode
May 15, 2026
3fec476
execution/cache: STATE_CACHE_MODE env override at NewStateCache time
May 15, 2026
1a56794
execution/cache: correct the LFU rationale in Mode docstring
May 15, 2026
4a512ce
execution/cache: reduce default cache caps to 100 MB each (bench knob)
May 17, 2026
da4b091
Parallel-exec correctness fixes (PR #3 of the perf stack) (#21387)
mh0lt May 25, 2026
3b11e0e
Merge remote-tracking branch 'origin/main' into mh/perf-caches-pr
mh0lt May 25, 2026
b7d89ad
Merge remote-tracking branch 'origin/mh/perf-caches-pr' into mh/perf-…
mh0lt May 25, 2026
9b15362
execution/state: drop tautological nil checks in code-loading paths (…
mh0lt May 25, 2026
6b582fd
execution/execmodule: clear BranchCache between unwindToCommonCanonic…
mh0lt May 26, 2026
25eb151
Revert "execution/execmodule: clear BranchCache between unwindToCommo…
mh0lt May 26, 2026
0021402
execution/commitment, common/maphash: txN-tagged BranchCache entries …
mh0lt May 26, 2026
f972499
db/state, db/state/execctx: plumb real txN to BranchCache writes
mh0lt May 26, 2026
b93969a
db/state/execctx, execution/commitment: wire BranchCache.UnwindTo int…
mh0lt May 26, 2026
c9a3deb
execution/commitment, db/state, execmodule: trim comments per project…
mh0lt May 26, 2026
4618add
execution/engineapi, db/state/execctx, execution/commitment: remove o…
mh0lt May 27, 2026
0dc7b1b
execution/commitment, db/state/execctx, cmd/evm: fix 4 Copilot review…
mh0lt May 27, 2026
fd74979
db/state/execctx: decode AccountsDomain codeHash with DeserialiseV3
mh0lt Jun 4, 2026
ba6c67a
db/state, db/kv: unify FlushWithCallback — flush-only refresh for bra…
May 20, 2026
a5f973b
execution/execmodule: FCU semaphore decouple + foreground-priority bg…
May 20, 2026
f54eb60
execution/execmodule: gate-2 overlay-continuity wiring (FCU/ValidateC…
May 20, 2026
980898d
execution/execmodule: commitWorker lifecycle — drain + exit before DB…
May 20, 2026
a1dbe0b
execution, rpc, txpool: route latest-state reads through the in-fligh…
May 20, 2026
c2ee3fc
execution: published-leaf SD reads for the outer layer under async co…
May 20, 2026
2a41192
execution/cache, state, stagedsync: txNum/epoch cache invalidation; r…
mh0lt Jun 5, 2026
42a2aaf
execution: wire state cache into SetHead unwind (fixes BadBlock on re…
mh0lt Jun 5, 2026
2683865
commitment: LatestStateReader.Clone keeps its source tx, not the comp…
mh0lt Jun 5, 2026
44355fd
db/state, commitment: lock-free per-worker read metrics (+ tx-aware B…
mh0lt Jun 6, 2026
a027002
db/state: drop process-wide metrics accumulator (metrics-on safety)
mh0lt Jun 6, 2026
943968d
commitment: meter the main-fold reads per-ComputeCommitment
mh0lt Jun 6, 2026
f375aa8
db/state, commitment: collapse metrics to per-worker DomainMetrics in…
mh0lt Jun 6, 2026
cd1fb81
exec: meter parallel-exec worker reads (per-worker DomainMetrics, per…
mh0lt Jun 6, 2026
bd6097e
execution/cache: fix off-by-one in state-cache unwind floor
mh0lt Jun 7, 2026
67d0f33
execution: address #21380 review feedback
mh0lt Jun 7, 2026
6f9f737
Merge origin/main into mh/perf-caches-pr (#21380)
mh0lt Jun 7, 2026
5d16a64
Merge mh/perf-caches-pr into mh/perf-statecache-lru-pr (#21386)
mh0lt Jun 8, 2026
2542895
Merge mh/perf-statecache-lru-pr into mh/perf-semaphore-pr-v2 (#21414)
mh0lt Jun 8, 2026
14604c0
Merge remote-tracking branch 'origin/main' into mh/perf-semaphore-pr-v2
mh0lt Jul 8, 2026
24a9000
execution/execmodule, node: default fcuBackgroundCommit + fix bg-prun…
mh0lt Jul 13, 2026
c8fa249
Merge remote-tracking branch 'origin/main' into mh/perf-semaphore-pr-v2
mh0lt Jul 13, 2026
12e9a88
execmodule, cl/beacon: route bg-commit reads via published SD (WIP)
mh0lt Jul 13, 2026
d1350b7
execution, rpc, cmd/rpcdaemon: route bg-commit test reads via publish…
mh0lt Jul 13, 2026
dbea3a2
db/state, execmodule: SharedDomains range-as-of merging in-mem histor…
mh0lt Jul 13, 2026
aaac43f
db/state, execmodule: SharedDomains.HistoryRange merging in-mem + com…
mh0lt Jul 13, 2026
2de5052
db/state, execmodule: SharedDomains.IndexRange over in-mem history
mh0lt Jul 13, 2026
ce06873
rpc/jsonrpc: route test state cache + block reads via published SD (b…
mh0lt Jul 13, 2026
aa69f55
rpc/jsonrpc: route remaining test-body block/state reads via publishe…
mh0lt Jul 13, 2026
f239ba6
execmodule/execmoduletester: retry InsertChain FCU on ExecutionStatus…
mh0lt Jul 13, 2026
04ab253
rpc/jsonrpc: head-pointer tests read raw DB, not published-SD overlay
mh0lt Jul 13, 2026
25b379b
db/state, execmodule: SharedDomains.HistorySeek over in-mem history
mh0lt Jul 13, 2026
3081f38
rpc/jsonrpc: route ListStorageKeys parity tests via published SD
mh0lt Jul 13, 2026
7514590
rpc/jsonrpc: resolve head-pointer test blocks via overlay before raw …
mh0lt Jul 13, 2026
25ede7e
rpc/jsonrpc: eth_getProof builds tip proof against in-flight commitment
mh0lt Jul 13, 2026
2f205c3
execution/execmodule: clear published overlay after SetHead unwind
mh0lt Jul 13, 2026
957e42e
execution/execmodule: reset gen chain + context on SetHead unwind
mh0lt Jul 13, 2026
dd04431
db/state: keep standalone inverted-index writes in a local collection
mh0lt Jul 13, 2026
c83386a
execution/execmodule: roll back generation read-tx in closeAllGens
mh0lt Jul 13, 2026
2472857
execution/execmodule: route unwind-gap test blockgen via published SD
mh0lt Jul 13, 2026
511b8ec
execution: fix bg-commit test flake and route readers via published SD
mh0lt Jul 14, 2026
4670f5c
execution/types, execution/engineapi, execution/stagedsync: carry the…
mh0lt Jul 14, 2026
be79ad7
Merge remote-tracking branch 'origin/main' into mh/perf-semaphore-pr-v2
mh0lt Jul 14, 2026
3b0a19c
cmd/utils/app, db/snapshotsync: make the import tool bg-commit-durable
mh0lt Jul 14, 2026
b7f352b
execution/builder, db/state/execctx: isolate the block builder from t…
mh0lt Jul 14, 2026
8f8d941
execution/builder, execution/execmodule: pin block builder to a scope…
mh0lt Jul 14, 2026
56c0f3c
execution/execmodule: bind scoped read view roTx to the background co…
mh0lt Jul 14, 2026
1a7ecd2
execution/stagedsync: don't save a genesis changeset in serial exec
mh0lt Jul 14, 2026
582b08d
execution/stagedsync: treat empty apply-loop close as clean, not more…
mh0lt Jul 14, 2026
ffacdd0
db/state, execution: one coordinated generation-chain lookup path for…
mh0lt Jul 15, 2026
1fad509
Merge remote-tracking branch 'origin/main' into mh/perf-semaphore-pr-v2
mh0lt Jul 15, 2026
4605dcc
execution/builder, execution/execmodule: coordinate the builder's sco…
mh0lt Jul 15, 2026
beec531
execution/execmodule: harden bg-commit generation lifecycle + builder…
mh0lt Jul 15, 2026
f592b6d
rpc/jsonrpc: guard nil header in getProof
mh0lt Jul 15, 2026
6f0d543
rpc/jsonrpc: wrap latest-block tip reads with the block overlay
mh0lt Jul 15, 2026
2fe4547
execution/execmodule, db/kv: dedup overlay-base, drop dead code, add …
mh0lt Jul 15, 2026
604e974
Merge remote-tracking branch 'origin/main' into mh/perf-semaphore-pr-v2
mh0lt Jul 15, 2026
f7caf29
execution/execmodule: remove unused waitForegroundIdle
mh0lt Jul 15, 2026
2fe5177
execution/exec, execution/execmodule: route read-ahead prefetch throu…
mh0lt Jul 16, 2026
c6d6c06
execution/execmodule: drain commits in insertValidateAndUfc1By1 test …
mh0lt Jul 16, 2026
5c7a67f
execution/exec: read-ahead prefetch uses a plain RO snapshot, not a c…
mh0lt Jul 16, 2026
8e1b25f
Merge remote-tracking branch 'origin/main' into mh/perf-semaphore-pr-v2
mh0lt Jul 16, 2026
5bf8294
Merge remote-tracking branch 'origin/main' into mh/perf-semaphore-pr-v2
mh0lt Jul 17, 2026
758a6d7
execution/stagedsync, execution/execmodule: commitment calculator own…
mh0lt Jul 17, 2026
2e1c28a
execution/stagedsync: remove dead exec-side changeset accumulator mac…
mh0lt Jul 17, 2026
046b3ec
execution/stagedsync: trim stale/oversized changeset comments (review)
mh0lt Jul 17, 2026
b57e1ed
execution/execmodule: assert tip newPayload carries a BAL in fold-ahe…
mh0lt Jul 17, 2026
c323df0
execution/stagedsync: post-block-consistent fold reader (fix wrong ro…
mh0lt Jul 18, 2026
32370ba
Merge remote-tracking branch 'origin/main' into mh/perf-semaphore-pr-v2
mh0lt Jul 20, 2026
0e89d5a
Merge remote-tracking branch 'origin/main' into mh/perf-semaphore-pr-v2
mh0lt Jul 22, 2026
dcc35f1
execution/execmodule: scope payload-bodies BAL getter tests to a sync…
mh0lt Jul 22, 2026
6710bcb
execution, db: address yperbasis review round 5 (P1/P2 blockers)
mh0lt Jul 28, 2026
1e9bae9
Merge origin/main into mh/perf-semaphore-pr-v2
mh0lt Jul 28, 2026
7647816
db/state/execctx: revert HasPrefix parent-chain walk (false CREATE-co…
mh0lt Jul 28, 2026
751e7ee
execution/execmodule, db/state: fix bg-prune FCU race + clear-aware H…
mh0lt Jul 28, 2026
ad2f1f2
execution/execmodule: read e.currentContext under lock in FCU cleanup
mh0lt Jul 28, 2026
7ea6f80
execution, db, rpc: address FCU bg-commit review (P1/P2 blockers)
mh0lt Jul 28, 2026
c747cfe
db/state, execution, rpc: rename BlockOverlayTemporalTx -> OverlayTem…
mh0lt Jul 28, 2026
868efdc
execution/execmodule: drop redundant ParentOverlayTemporalTx
mh0lt Jul 28, 2026
928dbef
execution, db: address FCU bg-commit review round 7 (P1/P2/P3)
mh0lt Jul 29, 2026
da3d119
Merge remote-tracking branch 'origin/main' into mh/perf-semaphore-pr-v2
mh0lt Jul 29, 2026
607ca28
Merge remote-tracking branch 'origin/main' into mh/perf-semaphore-pr-v2
mh0lt Aug 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cl/beacon/handler/block_production_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ func TestCaplinBlockProductionWithWithdrawalRequest(t *testing.T) {
)
require.NoError(t, err)
gen.AddTx(tx)
})
}, m.PublishedSD())
require.NoError(t, err)
err = m.InsertChain(chainPack)
require.NoError(t, err)
Expand Down Expand Up @@ -649,7 +649,7 @@ func TestCaplinBlockProductionGlamsterdamSlotNumber(t *testing.T) {
)
require.NoError(t, err)
gen.AddTx(tx)
})
}, m.PublishedSD())
require.NoError(t, err)
err = m.InsertChain(chainPack)
require.NoError(t, err)
Expand Down
12 changes: 7 additions & 5 deletions cmd/rpcdaemon/rpcdaemontest/test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/erigontech/erigon/common/log/v3"
"github.com/erigontech/erigon/common/u256"
"github.com/erigontech/erigon/db/kv"
"github.com/erigontech/erigon/db/state/execctx"
"github.com/erigontech/erigon/execution/abi/bind"
"github.com/erigontech/erigon/execution/abi/bind/backends"
"github.com/erigontech/erigon/execution/builder"
Expand Down Expand Up @@ -113,11 +114,11 @@ func genTestChainOnce(t *testing.T) {
defer contractBackend.Close()

var err error
testOrphanedChain, err = blockgen.GenerateChain(m.ChainConfig, m.Genesis, m.Engine, m.DB, 5, func(i int, block *blockgen.BlockGen) {})
testOrphanedChain, err = blockgen.GenerateChain(m.ChainConfig, m.Genesis, m.Engine, m.DB, 5, func(i int, block *blockgen.BlockGen) {}, m.PublishedSD())
if err != nil {
t.Fatalf("rpcdaemontest: failed to generate orphaned chain: %v", err)
}
testChain, err = generateChain(&addresses, m.ChainConfig, m.Genesis, m.Engine, m.DB, contractBackend)
testChain, err = generateChain(&addresses, m.ChainConfig, m.Genesis, m.Engine, m.DB, contractBackend, m.PublishedSD())
if err != nil {
t.Fatalf("rpcdaemontest: failed to generate chain: %v", err)
}
Expand Down Expand Up @@ -166,6 +167,7 @@ func generateChain(
engine rules.Engine,
db kv.TemporalRwDB,
contractBackend *backends.SimulatedBackend,
readSD ...*execctx.SharedDomains,
) (*blockgen.ChainPack, error) {
var (
key = addresses.key
Expand Down Expand Up @@ -349,7 +351,7 @@ func generateChain(
block.AddTx(txn)
}
contractBackend.Commit()
})
}, readSD...)
}

func computeMappingStorageKey(addr common.Address, slot uint64) common.Hash {
Expand Down Expand Up @@ -569,7 +571,7 @@ func CreateTestExecModuleForTraces(t *testing.T) *execmoduletester.ExecModuleTes
tx, _ := types.SignTx(types.NewTransaction(0, a2,
&u256.Num0, 50000, &u256.Num1, []byte{0x01, 0x00, 0x01, 0x00}), *types.LatestSignerForChainID(nil), key)
b.AddTx(tx)
})
}, m.PublishedSD())
if err != nil {
t.Fatalf("generate blocks: %v", err)
}
Expand Down Expand Up @@ -678,7 +680,7 @@ func CreateTestExecModuleForTracesCollision(t *testing.T) *execmoduletester.Exec
tx, _ = types.SignTx(types.NewTransaction(2, bb,
&u256.Num0, 100000, &u256.Num1, nil), *types.LatestSignerForChainID(nil), key)
b.AddTx(tx)
})
}, m.PublishedSD())
if err != nil {
t.Fatalf("generate blocks: %v", err)
}
Expand Down
11 changes: 9 additions & 2 deletions cmd/utils/app/import_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,10 @@ func missingBlocks(chainDB kv.RwDB, blocks []*types.Block, blockReader dbservice
})

for i, block := range blocks {
// If we're behind the chain head, only check block, state is available at head
if headBlock.NumberU64() > block.NumberU64() {
// No durable head yet (e.g. only genesis, or the head's commit is still
// in flight under background commit): nothing is behind us, so fall
// through to the per-block presence check.
if headBlock != nil && headBlock.NumberU64() > block.NumberU64() {
if !ChainHasBlock(chainDB, block) {
return blocks[i:]
}
Expand Down Expand Up @@ -445,6 +447,11 @@ func InsertChain(ethereum *eth.Ethereum, chain *blockgen.ChainPack, setHead bool
}
}

// UpdateForkChoice commits in the background; drain it so this file's
// header/TD/canonical state is durable in the raw DB before the next file's
// side-chain TD/head reads (and the final head write) observe it.
ethereum.ExecutionModule().WaitCommitsDrained()

return ethereum.ChainDB().Update(ethereum.SentryCtx(), func(tx kv.RwTx) error {
rawdb.WriteHeadBlockHash(tx, lvh)
return nil
Expand Down
5 changes: 4 additions & 1 deletion db/kv/kv_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,10 @@ type TemporalMemBatch interface {
ClearRam()
IndexAdd(table InvertedIdx, key []byte, txNum uint64) (err error)
IteratePrefix(domain Domain, prefix []byte, roTx Tx, it func(k []byte, v []byte) (cont bool, err error)) error
RangeAsOf(ctx context.Context, domain Domain, fromKey, toKey []byte, ts uint64, asc order.By, limit int, roTx Tx) (stream.KV, error)
HistoryRange(ctx context.Context, domain Domain, fromTs, toTs int, asc order.By, limit int, roTx Tx) (stream.KV, error)
IndexRange(name InvertedIdx, k []byte, fromTs, toTs int, asc order.By, limit int, roTx Tx) (stream.U64, error)
HistorySeek(domain Domain, key []byte, ts uint64) (v []byte, ok bool, err error)
HasPrefix(domain Domain, prefix []byte, roTx Tx) ([]byte, []byte, bool, error)
HasPrefixInRAM(domain Domain, prefix []byte) bool
SizeEstimate() uint64
Expand All @@ -595,7 +599,6 @@ type TemporalMemBatch interface {
DiscardWrites(domain Domain)
Unwind(txNumUnwindTo uint64, changeset *[DomainLen][]DomainEntryDiff)
GetAsOf(domain Domain, key []byte, ts uint64) (v []byte, ok bool, err error)
HistorySeek(domain Domain, key []byte, ts uint64) (v []byte, ok bool, err error)
SetInMemHistoryReads(v bool)
InMemHistoryReads() bool
}
Expand Down
21 changes: 20 additions & 1 deletion db/kv/membatchwithdb/memory_mutation.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ type DomainReader interface {
HistorySeek(name kv.Domain, k []byte, ts uint64) ([]byte, bool, error)
}

// domainLatestReader is the subset of SharedDomains needed for GetLatest/HasPrefix
// reads from an OverlayTemporalReadView. Implemented by SharedDomains.
type domainLatestReader interface {
GetLatest(domain kv.Domain, tx kv.TemporalTx, k []byte) ([]byte, kv.Step, error)
HasPrefix(domain kv.Domain, prefix []byte, roTx kv.Tx) ([]byte, []byte, bool, error)
}

type MemoryMutation struct {
// mu protects concurrent access to the mutation's maps and backing tx.
// Read methods (GetOne, Has) acquire RLock; write methods (Put, Delete,
Expand Down Expand Up @@ -1141,13 +1148,25 @@ func (v *OverlayTemporalReadView) Apply(_ context.Context, f func(tx kv.Tx) erro
return f(v)
}

// Temporal methods — delegate to the independent temporal tx.
// Temporal methods — check the installed SD chain before the committed tx.

func (v *OverlayTemporalReadView) GetLatest(name kv.Domain, k []byte) ([]byte, kv.Step, error) {
// The installed reader walks the whole generation chain and falls through to
// v.temporalTx itself, so its value and error are authoritative — a nil here
// is a genuine tombstone, not a cue to re-read the committed tx.
if dr, ok := v.MemoryMutation.DomainReader.(domainLatestReader); ok {
return dr.GetLatest(name, v.temporalTx, k)
}
return v.temporalTx.GetLatest(name, k)
}
Comment thread
Copilot marked this conversation as resolved.

func (v *OverlayTemporalReadView) HasPrefix(name kv.Domain, prefix []byte) ([]byte, []byte, bool, error) {
// Authoritative for the same reason as GetLatest: the reader already honours
// parent-generation tombstones and the committed tx, so a false result must
// not be overridden by re-checking committed storage the overlay cleared.
if dr, ok := v.MemoryMutation.DomainReader.(domainLatestReader); ok {
return dr.HasPrefix(name, prefix, v.temporalTx)
}
return v.temporalTx.HasPrefix(name, prefix)
}

Expand Down
3 changes: 3 additions & 0 deletions db/snapshotsync/freezeblocks/block_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,9 @@ func (r *BlockReader) CurrentBlock(db kv.Tx) (*types.Block, error) {
if err != nil {
return nil, fmt.Errorf("failed HeaderNumber: %w", err)
}
if headNumber == nil {
return nil, nil
}
block, _, err := r.blockWithSenders(context.Background(), db, headHash, *headNumber, true)
return block, err
}
Expand Down
2 changes: 1 addition & 1 deletion db/snapshotsync/freezeblocks/dump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func createDumpTestKV(t *testing.T, chainConfig *chain.Config, chainSize int) *e
t.Fatalf("failed to create tx: %v", txErr)
}
b.AddTx(tx)
})
}, m.PublishedSD())
if err != nil {
t.Fatal(err)
}
Expand Down
Loading
Loading