diff --git a/beacon-chain/sync/initial-sync/blocks_fetcher.go b/beacon-chain/sync/initial-sync/blocks_fetcher.go index 8e877b9b7f..b03322843e 100644 --- a/beacon-chain/sync/initial-sync/blocks_fetcher.go +++ b/beacon-chain/sync/initial-sync/blocks_fetcher.go @@ -356,18 +356,22 @@ func (f *blocksFetcher) handleRequest(ctx context.Context, start primitives.Slot // It returns the peer ID from which blobs were fetched (if any). func (f *blocksFetcher) fetchSidecars(ctx context.Context, pid peer.ID, peers []peer.ID, bwScs []blocks.BlockWithROSidecars) (peer.ID, error) { samplesPerSlot := params.BeaconConfig().SamplesPerSlot + count := len(bwScs) - if len(bwScs) == 0 { + if count == 0 { return "", nil } - // Find the first block with a slot greater than or equal to the first Fulu slot. - firstFuluIndex := sort.Search(len(bwScs), func(i int) bool { - return bwScs[i].Block.Version() >= version.Fulu - }) + preFuluBlocks, postFuluBlocks := make([]blocks.BlockWithROSidecars, 0, count), make([]blocks.BlockWithROSidecars, 0, count) - preFuluBlocks := bwScs[:firstFuluIndex] - postFuluBlocks := bwScs[firstFuluIndex:] + for _, bwSc := range bwScs { + if bwSc.Block.Version() >= version.Fulu { + postFuluBlocks = append(postFuluBlocks, bwSc) + continue + } + + preFuluBlocks = append(preFuluBlocks, bwSc) + } var ( blobsPid peer.ID