*: early fetch on head#4561
Conversation
|
There was a problem hiding this comment.
Pull request overview
This PR changes early attestation-data prefetching to trigger on the beacon node’s SSE head event (instead of the SSE block event), adds verification that fetched attestation data matches the head root from the event, and improves cache invalidation/cleanup to avoid stale early-fetched data.
Changes:
- Switch early fetch trigger from SSE
block→ SSEhead, and pass the head block root through the scheduler → fetcher path. - Verify early-fetched attestation data votes for the head root from the SSE head event; skip caching on mismatch.
- Invalidate/evict early-fetch caches on chain reorgs and as slots advance; add/extend unit tests for these behaviors.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| core/scheduler/scheduler.go | Updates scheduler wiring to trigger early fetch on head events and propagate the head block root into FetchOnly. |
| core/interfaces.go | Extends Scheduler/Fetcher interfaces to include the head block root parameter for early-fetch flows. |
| core/fetcher/fetcher.go | Adds root verification for early-fetched attestation data, stale-slot eviction, and cache invalidation on reorg. |
| core/fetcher/fetcher_test.go | Extends tests to cover head-root mismatch behavior, reorg invalidation, and stale-slot eviction. |
| app/sse/listener.go | Emits head events to subscribers with parsed eth2p0.Root block root; stops notifying on block events. |
| app/sse/listener_internal_test.go | Updates SSE listener tests for the new head-event subscription/notification signature. |
| app/featureset/featureset.go | Updates feature flag documentation to reflect head-event triggering and root verification semantics. |
| app/app.go | Wires SSE head events into the scheduler and subscribes reorg events to invalidate the fetcher’s early-fetch cache (when enabled). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| fetcherFetchOnly func(context.Context, core.Duty, core.DutyDefinitionSet, string, eth2p0.Root) error | ||
| builderEnabled bool | ||
| schedSlotFunc schedSlotFunc | ||
| epochResolved map[uint64]chan struct{} // Notification channels for epoch resolution | ||
| eventTriggeredAttestations sync.Map // Track attestation duties triggered via sse block event (map[uint64]bool) | ||
| eventTriggeredAttestations sync.Map // Track attestation duties triggered via sse head event (map[uint64]bool) | ||
| } |
| case <-s.clock.After(time.Until(fallbackDeadline)): | ||
| // Check if block event triggered early fetch | ||
| if _, triggered := s.eventTriggeredAttestations.Load(slot.Slot); !triggered { |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4561 +/- ##
==========================================
+ Coverage 57.08% 57.12% +0.04%
==========================================
Files 245 245
Lines 33218 33249 +31
==========================================
+ Hits 18963 18994 +31
+ Misses 11867 11859 -8
- Partials 2388 2396 +8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|



block, but on SSEhead.category: bug
ticket: none