-
Notifications
You must be signed in to change notification settings - Fork 132
core/scheduler: fetch attestation data on sse block event #4095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4095 +/- ##
==========================================
+ Coverage 56.37% 56.43% +0.06%
==========================================
Files 245 245
Lines 31169 31238 +69
==========================================
+ Hits 17571 17629 +58
- Misses 11284 11296 +12
+ Partials 2314 2313 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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 implements early attestation data fetching triggered by SSE block events from the beacon node, with a fallback to the traditional 1/3 slot + 300ms timeout if no block event is received. This aims to reduce attestation delays and improve validator performance.
Key changes:
- Added
HandleBlockEventmethod to scheduler that triggers attestation duties immediately upon receiving block events - Introduced
waitForBlockEventOrTimeoutfunction that implements the fallback timeout logic - Refactored duty triggering logic into a shared
triggerDutymethod - Added SSE block event subscription and notification infrastructure
- Fixed data race in featureset test helper functions
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| core/scheduler/scheduler.go | Core implementation of block event handling, early attestation triggering, and fallback timeout logic |
| core/scheduler/scheduler_test.go | Test coverage for block event triggered attestation duties |
| app/sse/listener.go | Added block event subscription mechanism and notification to subscribers |
| app/sse/listener_internal_test.go | Test coverage for block event handling and notification |
| app/featureset/featureset.go | Added FetchAttOnBlock feature flag definition |
| app/featureset/config.go | Fixed data race by adding mutex protection in test cleanup functions |
| app/app.go | Wired block event subscription from SSE listener to scheduler |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2bade22 to
136ac08
Compare
| dutyCtx := log.WithCtx(ctx, z.Any("duty", duty)) | ||
| if duty.Type == core.DutyProposer { | ||
| var span trace.Span | ||
| dutyCtx, span = core.StartDutyTrace(dutyCtx, duty, "core/scheduler.scheduleSlot") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure the trace name is right .scheduleSlot..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't modify this name, it was already like that in scheduleSlot
charon/core/scheduler/scheduler.go
Line 290 in 99bc194
| dutyCtx, span = core.StartDutyTrace(dutyCtx, duty, "core/scheduler.scheduleSlot") |
HandleBlockEventAre you suggesting changing to
.triggerDuty ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No suggestion, whatever you think will be useful when browsing trace data in Grafana.
pinebit
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple minor comments and it's good
|
|
Let's rework this one after Christmas as we've discussed in the past week - separate the logic into 2 flags:
If both are or only the second is enabled, delay will be used. If only the first is enabled, no delay will be added. To be fair, the first one does not make a huge amount of sense. We can achieve only triggering early fetching, which will save us some time, but submitting will still be in 1/3 > x > 2/3 of slot time. There are 2 blockers for the attestation to be actually submitted early:
|



Fetch attestation data on receiving SSE block event or after
1/3 + 300msas a fallback, possibly fetching a stale head.Includes a small fix to
featureset/config.gowhich had a data race on clean up after a test.category: feature
ticket: #4027
feature_flag: fetch_att_on_block