Skip to content

fix(node-api): enforce DA period check in GetBlobSidecars#3129

Open
NikhilSharmaWe wants to merge 2 commits into
berachain:mainfrom
NikhilSharmaWe:fix/blob-sidecars-da-period
Open

fix(node-api): enforce DA period check in GetBlobSidecars#3129
NikhilSharmaWe wants to merge 2 commits into
berachain:mainfrom
NikhilSharmaWe:fix/blob-sidecars-da-period

Conversation

@NikhilSharmaWe

Copy link
Copy Markdown

Fixes #3127

Summary

GetBlobSidecars was calling WithinDAPeriod(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 of slotID (which is -1 for head).

Before: WithinDAPeriod(slot, slot) → always passes
After: WithinDAPeriod(slot, headHeight) → rejects slots outside MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS

Local head is used (not sync target) so /blob_sidecars/head still works while the node is syncing.

Test plan

  • go test -tags=test ./node-api/handlers/beacon/... -run TestGetBlobSidecars
  • go test -tags=test ./node-api/handlers/beacon/...
  • Head request succeeds (head block id)
  • Head request succeeds while syncing (headHeight=1000, syncToHeight=800_000)
  • Explicit in-window slot accepted (999000 with head at 1_000_000)
  • Out-of-window slot rejected (212568 with head at 1_000_000)
  • Store not queried when DA check fails (AssertNotCalled on GetBlobSidecarsAtSlot)

Signed-off-by: Nikhil Sharma <nikhilsharma230303@gmail.com>
@NikhilSharmaWe NikhilSharmaWe requested a review from a team as a code owner June 19, 2026 05:05
Copilot AI review requested due to automatic review settings June 19, 2026 05:05

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

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/head resolution and as the “current” slot in WithinDAPeriod.
  • Update the DA-period error message to print the resolved slot value (not slotID, which is -1 for head).
  • 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 thread node-api/handlers/beacon/blobs.go Outdated
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 thread node-api/handlers/beacon/blob_test.go Outdated
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>
@NikhilSharmaWe

Copy link
Copy Markdown
Author

@fridrik01 PTAL, thanks

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.

GetBlobSidecars DA period check compares slot against itself

2 participants