Skip to content

Commit 0ef6906

Browse files
committed
Check for pending blobs in GetBlobSidecars Api endpoint
1 parent a6e214f commit 0ef6906

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

node-api/handlers/beacon/blobs.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626

2727
"github.com/berachain/beacon-kit/node-api/handlers"
2828
"github.com/berachain/beacon-kit/node-api/handlers/beacon/types"
29+
handlertypes "github.com/berachain/beacon-kit/node-api/handlers/types"
2930
"github.com/berachain/beacon-kit/node-api/handlers/utils"
3031
"github.com/berachain/beacon-kit/primitives/math"
3132
)
@@ -93,6 +94,18 @@ func (h *Handler) GetBlobSidecars(c handlers.Context) (any, error) {
9394
return nil, err
9495
}
9596

97+
// If no blobs found, check if we expect blobs for this slot. If so, it means that
98+
// we are still waiting for the blobs to be fetched via BlobReactor.
99+
if len(blobSidecars) == 0 {
100+
st, _, stateErr := h.backend.StateAndSlotFromHeight(int64(slot)) //#nosec: G115 // practically safe
101+
if stateErr == nil {
102+
payloadHeader, headerErr := st.GetLatestExecutionPayloadHeader()
103+
if headerErr == nil && payloadHeader.GetBlobGasUsed() > 0 {
104+
return nil, fmt.Errorf("blobs pending: %w", handlertypes.ErrNotFound)
105+
}
106+
}
107+
}
108+
96109
// Create a map of requested indices for O(1) index lookups.
97110
isRequestIndex := make(map[uint64]bool)
98111
for _, idx := range indices {

0 commit comments

Comments
 (0)