Skip to content

prefetcher: grow stream channel buffer from 512 to 4096

8ed2ee9
Select commit
Loading
Failed to load commit list.
Open

prefetcher: builder-phase prefetch + streaming worker pool #2192

prefetcher: grow stream channel buffer from 512 to 4096
8ed2ee9
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Apr 20, 2026 in 16m 53s

Code review found 1 important issue

Found 5 candidates, confirmed 4. See review comments for details.

Details

Severity Count
🔴 Important 1
🟡 Nit 2
🟣 Pre-existing 0
Severity File:Line Issue
🔴 Important miner/worker.go:2306-2317 onSuccess race: idle-phase txs miscounted as builder-phase prefetches
🟡 Nit miner/worker.go:1903-1916 scanOverflow and collectPlanBatch: missing nil guard for prefetchedHashes
🟡 Nit miner/worker.go:1863-1892 buildTxPlan: gas budget decremented before ltx.Resolve() nil check

Annotations

Check failure on line 2317 in miner/worker.go

See this annotation in the file changed.

@claude claude / Claude Code Review

onSuccess race: idle-phase txs miscounted as builder-phase prefetches

The `onSuccess` callback in `runPrefetcher` incorrectly attributes idle-phase prefetch completions to the builder phase during the ≤10ms window between `builderStarted.Store(true)` and the subsequent `evmAbort.Store(true)`. The misleading code comment (lines 2310–2313) explicitly claims the handoff guarantees this cannot happen — but `evmAbort` only fires *after* `runIdleTxProvider` exits, which can lag `builderStarted` by up to 10ms. This inflates `worker/prefetch/builder_added_percent`, making

Check warning on line 1916 in miner/worker.go

See this annotation in the file changed.

@claude claude / Claude Code Review

scanOverflow and collectPlanBatch: missing nil guard for prefetchedHashes

Both `scanOverflow` (~line 1913) and `collectPlanBatch` (~line 2574) call `prefetchedHashes.Load()` without a nil guard, while the sibling function `buildTxPlan` explicitly checks `if prefetchedHashes != nil` before calling `.Load()`. Since `buildTxPlan`'s nil guard signals that `nil` is a valid contract for this parameter type (`*sync.Map`), any future caller or unit test that passes `nil` to either function will panic. Production is currently safe because `commitWork` unconditionally initializ

Check warning on line 1892 in miner/worker.go

See this annotation in the file changed.

@claude claude / Claude Code Review

buildTxPlan: gas budget decremented before ltx.Resolve() nil check

In buildTxPlan, remaining -= ltx.Gas executes before tx := ltx.Resolve() is called, so if Resolve() returns nil (tx evicted from pool between listing and resolution), the gas is permanently deducted from remaining but no tx is added to the plan. This causes buildTxPlan to underestimate the remaining gas budget, potentially excluding subsequent transactions that would have fit — reducing plan-ahead prefetch coverage. The fix is to move remaining -= ltx.Gas to after the Resolve() nil check, mirror