fix(node-api): enforce DA period check in GetBlobSidecars#3129
Open
NikhilSharmaWe wants to merge 2 commits into
Open
fix(node-api): enforce DA period check in GetBlobSidecars#3129NikhilSharmaWe wants to merge 2 commits into
NikhilSharmaWe wants to merge 2 commits into
Conversation
Signed-off-by: Nikhil Sharma <nikhilsharma230303@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes the DA retention guard in the Beacon API GetBlobSidecars handler by comparing the requested slot against the node’s local head (from GetSyncData()), ensuring requests outside MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS are rejected before querying the availability store.
Changes:
- Fetch local head once and use it both for
/blob_sidecars/headresolution and as the “current” slot inWithinDAPeriod. - Update the DA-period error message to print the resolved slot value (not
slotID, which is-1forhead). - Expand handler tests to cover syncing head behavior and DA-window accept/reject cases.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| node-api/handlers/beacon/blobs.go | Fixes DA-period enforcement by comparing requested slot vs local head; adjusts slot resolution and error message. |
| node-api/handlers/beacon/blob_test.go | Adds/extends tests for head-while-syncing and DA window rejection, including “store not queried” expectations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+75
to
+77
| // Validate the requested slot is within the Data Availability Period. | ||
| if !h.cs.WithinDAPeriod(slot, slot) { | ||
| // Compare against local head; same retention window as availability pruning. | ||
| if !h.cs.WithinDAPeriod(slot, math.Slot(headHeight)) { |
Comment on lines
+167
to
+171
| require.Error(t, err) | ||
| require.Nil(t, res) | ||
| require.ErrorContains(t, err, "not within Data Availability Period") | ||
| require.ErrorContains(t, err, "212568") | ||
| backend.AssertNotCalled(t, "GetBlobSidecarsAtSlot") |
Signed-off-by: Nikhil Sharma <nikhilsharma230303@gmail.com>
Author
|
@fridrik01 PTAL, thanks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3127
Summary
GetBlobSidecarswas callingWithinDAPeriod(slot, slot), which always evaluates to true, so the DA retention guard never ran.This change compares the requested slot against local head from
GetSyncData(), using the same retention window as availability pruning. The error message now prints the resolved slot instead ofslotID(which is-1forhead).Before:
WithinDAPeriod(slot, slot)→ always passesAfter:
WithinDAPeriod(slot, headHeight)→ rejects slots outsideMIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTSLocal head is used (not sync target) so
/blob_sidecars/headstill works while the node is syncing.Test plan
go test -tags=test ./node-api/handlers/beacon/... -run TestGetBlobSidecarsgo test -tags=test ./node-api/handlers/beacon/...headblock id)headHeight=1000,syncToHeight=800_000)AssertNotCalledonGetBlobSidecarsAtSlot)