From ef5041ef4dc827da91adf946952358e4ef1781e9 Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Thu, 21 May 2026 09:54:32 +0200 Subject: [PATCH] eth/catalyst: engine_hasBlobs (#34859) Co-authored-by: healthykim Co-authored-by: Felix Lange --- core/txpool/blobpool/blobpool.go | 18 +++++++----------- eth/catalyst/api.go | 7 ++++++- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/core/txpool/blobpool/blobpool.go b/core/txpool/blobpool/blobpool.go index d33629365f..da54952674 100644 --- a/core/txpool/blobpool/blobpool.go +++ b/core/txpool/blobpool/blobpool.go @@ -1695,18 +1695,14 @@ func (p *BlobPool) GetBlobs(vhashes []common.Hash, version byte) ([]*kzg4844.Blo return blobs, commitments, proofs, nil } -// AvailableBlobs returns the number of blobs that are available in the subpool. -func (p *BlobPool) AvailableBlobs(vhashes []common.Hash) int { - available := 0 - for _, vhash := range vhashes { - // Retrieve the datastore item (in a short lock) - p.lock.RLock() - _, exists := p.lookup.storeidOfBlob(vhash) - p.lock.RUnlock() - if exists { - available++ - } +// AvailableBlobs returns whether the blobs are available in the subpool. +func (p *BlobPool) AvailableBlobs(vhashes []common.Hash) []bool { + available := make([]bool, len(vhashes)) + p.lock.RLock() + for i, vhash := range vhashes { + _, available[i] = p.lookup.storeidOfBlob(vhash) } + p.lock.RUnlock() return available } diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index b31185a40f..a1f9673de8 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -630,7 +630,7 @@ func (api *ConsensusAPI) getBlobs(hashes []common.Hash, v2 bool) (engine.BlobAnd if len(hashes) > 128 { return nil, engine.TooLargeRequest.With(fmt.Errorf("requested blob count too large: %v", len(hashes))) } - available := api.eth.BlobTxPool().AvailableBlobs(hashes) + available := len(api.eth.BlobTxPool().AvailableBlobs(hashes)) getBlobsRequestedCounter.Inc(int64(len(hashes))) getBlobsAvailableCounter.Inc(int64(available)) @@ -679,6 +679,11 @@ func (api *ConsensusAPI) getBlobs(hashes []common.Hash, v2 bool) (engine.BlobAnd return res, nil } +// HasBlobs reports availability for the requested blob-versioned-hashes. +func (api *ConsensusAPI) HasBlobs(hashes []common.Hash) []bool { + return api.eth.BlobTxPool().AvailableBlobs(hashes) +} + // Helper for NewPayload* methods. var invalidStatus = engine.PayloadStatusV1{Status: engine.INVALID}