Skip to content

*: early fetch on head#4561

Open
KaloyanTanev wants to merge 4 commits into
mainfrom
kalo/early-fetch-on-head
Open

*: early fetch on head#4561
KaloyanTanev wants to merge 4 commits into
mainfrom
kalo/early-fetch-on-head

Conversation

@KaloyanTanev

Copy link
Copy Markdown
Collaborator
  1. Fetch early not on SSE block, but on SSE head.
  2. Clear the saved early fetched attestations on chain reorg.
  3. Verify the fetched root from attestation data request is the same as the SSE event.
  4. Clear old attestation data.

category: bug
ticket: none

@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 → SSE head, 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.

Comment on lines +98 to 103
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)
}
Comment on lines 431 to 433
case <-s.clock.After(time.Until(fallbackDeadline)):
// Check if block event triggered early fetch
if _, triggered := s.eventTriggeredAttestations.Load(slot.Slot); !triggered {
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.41667% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.12%. Comparing base (576c67b) to head (4a62764).

Files with missing lines Patch % Lines
core/scheduler/scheduler.go 0.00% 8 Missing ⚠️
app/sse/listener.go 68.42% 3 Missing and 3 partials ⚠️
app/app.go 0.00% 3 Missing ⚠️
core/fetcher/fetcher.go 88.88% 1 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants