@@ -617,6 +617,28 @@ func fetchMissingSidecars*(
617617 res.add (BlobIdentifier (block_root: blockRoot, index: BlobIndex (bindex)))
618618 res
619619
620+ func getMissingSidecarIndices * (
621+ quarantine: BlobQuarantine ,
622+ blockRoot: Eth2Digest ,
623+ blck: deneb.SignedBeaconBlock | electra.SignedBeaconBlock
624+ ): seq [BlobIndex ] =
625+ # # Function returns sequence of BlobIndex for blobs which are missing for
626+ # # block root ``blockRoot`` and block ``blck``.
627+ var res: seq [BlobIndex ]
628+ let record = quarantine.roots.getOrDefault (blockRoot)
629+
630+ let commitmentsCount = len (blck.message.body.blob_kzg_commitments)
631+ if (commitmentsCount == 0 ) or (record.count == commitmentsCount):
632+ # Fast-path if ``blck`` does not have any blobs or if quarantine's record
633+ # holds enough blobs.
634+ return res
635+
636+ for bindex in 0 ..< commitmentsCount:
637+ let index = quarantine.getIndex (BlobIndex (bindex))
638+ if len (record.sidecars) == 0 or record.sidecars[index].isEmpty ():
639+ res.add (BlobIndex (bindex))
640+ res
641+
620642func fetchMissingSidecars * (
621643 quarantine: ColumnQuarantine ,
622644 blockRoot: Eth2Digest ,
@@ -694,6 +716,40 @@ func fetchMissingSidecars*(
694716 DataColumnsByRootIdentifier (
695717 block_root: blockRoot, indices: DataColumnIndices (res))
696718
719+ func getMissingSidecarIndices * (
720+ quarantine: ColumnQuarantine ,
721+ blockRoot: Eth2Digest ,
722+ blck: fulu.SignedBeaconBlock | gloas.SignedBeaconBlock ,
723+ ): seq [ColumnIndex ] =
724+ var res: seq [ColumnIndex ]
725+ let record = quarantine.roots.getOrDefault (blockRoot)
726+
727+ if len (blck.message.body.blob_kzg_commitments) == 0 :
728+ # Fast-path if block does not have any columns
729+ return res
730+
731+ let supernode = (len (quarantine.custodyColumns) == NUMBER_OF_COLUMNS )
732+ if supernode:
733+ if len (record.sidecars) > NUMBER_OF_COLUMNS div 2 :
734+ return res
735+ if len (record.sidecars) == 0 :
736+ for index in 0 ..< NUMBER_OF_COLUMNS :
737+ res.add (ColumnIndex (index))
738+ else :
739+ for index in 0 ..< NUMBER_OF_COLUMNS :
740+ if record.sidecars[index].isEmpty ():
741+ res.add (ColumnIndex (index))
742+ else :
743+ if len (record.sidecars) == 0 :
744+ for column in quarantine.custodyMap.items ():
745+ res.add (column)
746+ else :
747+ for column in quarantine.custodyMap.items ():
748+ let index = quarantine.getIndex (column)
749+ if (index == - 1 ) or (record.sidecars[index].isEmpty ()):
750+ res.add (column)
751+ res
752+
697753proc pruneAfterFinalization * (
698754 quarantine: var BlobQuarantine ,
699755 epoch: Epoch ,
0 commit comments