@@ -144,14 +144,14 @@ func (bi *BlobIndexer) index() error {
144144 }
145145
146146 // check if node still has last indexed blobs (if its outside the range defined by MAX_REQUEST_BLOCKS_DENEB), otherwise assume that the node has pruned too far and we would miss blobs
147- minBlobSlot := bi . calculateMinBlobSlot (spec , headHeader )
147+ minBlobSlot := calculateMinBlobSlot (spec , headHeader )
148148
149149 // check if node has pruned too far
150150 if err := bi .checkNodePruning (minBlobSlot , status ); err != nil {
151151 return err
152152 }
153153
154- startSlot , denebForkSlot := bi . calculateStartSlot (status , spec )
154+ startSlot , denebForkSlot := calculateStartSlot (status , spec )
155155 if headHeader .Data .Header .Message .Slot <= startSlot {
156156 return fmt .Errorf ("headHeader.Data.Header.Message.Slot <= startSlot: %v < %v (denebForkEpoch: %v, denebForkSlot: %v, slotsPerEpoch: %v)" , headHeader .Data .Header .Message .Slot , startSlot , utils .Config .Chain .ClConfig .DenebForkEpoch , denebForkSlot , utils .Config .Chain .ClConfig .SlotsPerEpoch )
157157 }
@@ -368,19 +368,6 @@ func (bi *BlobIndexer) shouldSkipBlobIndexing(status *BlobIndexerStatus) bool {
368368 status .LastUpdate .After (time .Now ().Add (- waitForOtherBlobIndexerDuration ))
369369}
370370
371- func (bi * BlobIndexer ) calculateMinBlobSlot (spec * constypes.StandardSpecResponse , headHeader * constypes.StandardBeaconHeaderResponse ) uint64 {
372- minBlobSlotRange := * spec .Data .MinEpochsForBlobSidecarsRequests * uint64 (spec .Data .SlotsPerEpoch )
373- minBlobSlot := uint64 (0 )
374- if headHeader .Data .Header .Message .Slot > minBlobSlotRange {
375- minBlobSlot = headHeader .Data .Header .Message .Slot - minBlobSlotRange
376- }
377- pruneMarginSlotRange := utils .Config .BlobIndexer .PruneMarginEpochs * uint64 (spec .Data .SlotsPerEpoch )
378- if minBlobSlot > pruneMarginSlotRange {
379- minBlobSlot = minBlobSlot - pruneMarginSlotRange
380- }
381- return minBlobSlot
382- }
383-
384371func (bi * BlobIndexer ) checkNodePruning (minBlobSlot uint64 , status * BlobIndexerStatus ) error {
385372 if status .LastIndexedFinalizedSlot < minBlobSlot && status .LastIndexedFinalizedBlobSlot > 0 {
386373 bs , err := bi .cl .GetBlobSidecars (status .LastIndexedFinalizedBlobSlot )
@@ -394,15 +381,6 @@ func (bi *BlobIndexer) checkNodePruning(minBlobSlot uint64, status *BlobIndexerS
394381 return nil
395382}
396383
397- func (bi * BlobIndexer ) calculateStartSlot (status * BlobIndexerStatus , spec * constypes.StandardSpecResponse ) (uint64 , uint64 ) {
398- denebForkSlot := * spec .Data .DenebForkEpoch * uint64 (spec .Data .SlotsPerEpoch )
399- startSlot := status .LastIndexedFinalizedSlot + 1
400- if status .LastIndexedFinalizedSlot <= denebForkSlot {
401- startSlot = denebForkSlot
402- }
403- return startSlot , denebForkSlot
404- }
405-
406384func (bi * BlobIndexer ) indexBlobsInBatches (status * BlobIndexerStatus , headHeader , finalizedHeader * constypes.StandardBeaconHeaderResponse , startSlot uint64 ) error {
407385 start := time .Now ()
408386 log .InfoWithFields (log.Fields {
@@ -493,6 +471,28 @@ func (bi *BlobIndexer) indexBlobsInBatches(status *BlobIndexerStatus, headHeader
493471 return nil
494472}
495473
474+ func calculateMinBlobSlot (spec * constypes.StandardSpecResponse , headHeader * constypes.StandardBeaconHeaderResponse ) uint64 {
475+ minBlobSlotRange := * spec .Data .MinEpochsForBlobSidecarsRequests * uint64 (spec .Data .SlotsPerEpoch )
476+ minBlobSlot := uint64 (0 )
477+ if headHeader .Data .Header .Message .Slot > minBlobSlotRange {
478+ minBlobSlot = headHeader .Data .Header .Message .Slot - minBlobSlotRange
479+ }
480+ pruneMarginSlotRange := utils .Config .BlobIndexer .PruneMarginEpochs * uint64 (spec .Data .SlotsPerEpoch )
481+ if minBlobSlot > pruneMarginSlotRange {
482+ minBlobSlot = minBlobSlot - pruneMarginSlotRange
483+ }
484+ return minBlobSlot
485+ }
486+
487+ func calculateStartSlot (status * BlobIndexerStatus , spec * constypes.StandardSpecResponse ) (uint64 , uint64 ) {
488+ denebForkSlot := * spec .Data .DenebForkEpoch * uint64 (spec .Data .SlotsPerEpoch )
489+ startSlot := status .LastIndexedFinalizedSlot + 1
490+ if status .LastIndexedFinalizedSlot <= denebForkSlot {
491+ startSlot = denebForkSlot
492+ }
493+ return startSlot , denebForkSlot
494+ }
495+
496496func reportBlobIndexerStatus () {
497497 if ! utils .Config .BlobIndexer .DisableStatusReports {
498498 services .ReportStatus ("blobindexer" , "Running" , nil )
0 commit comments