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