From 9d5643240beb7d4bf95663e384bd92b2873e3778 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Fri, 22 Mar 2024 03:27:02 +0100 Subject: [PATCH] only request blobs if a sync response actually provided blocks (#6121) During sync, we can skip the `blobSidecarsByRange` request when there are no blocks with `kzg_commitments` in the blocks data. Avoids running into throttling from peers during long periods of non-finality. --- beacon_chain/sync/sync_manager.nim | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/beacon_chain/sync/sync_manager.nim b/beacon_chain/sync/sync_manager.nim index cbc826910..1f13549eb 100644 --- a/beacon_chain/sync/sync_manager.nim +++ b/beacon_chain/sync/sync_manager.nim @@ -409,6 +409,19 @@ proc syncStep[A, B](man: SyncManager[A, B], index: int, peer: A) request = req return + let shouldGetBlobs = + if not man.shouldGetBlobs(req.slot.epoch): + false + else: + var hasBlobs = false + for blck in blockData: + withBlck(blck[]): + when consensusFork >= ConsensusFork.Deneb: + if forkyBlck.message.body.blob_kzg_commitments.len > 0: + hasBlobs = true + break + hasBlobs + func combine(acc: seq[Slot], cur: Slot): seq[Slot] = var copy = acc if copy[copy.len-1] != cur: @@ -416,7 +429,7 @@ proc syncStep[A, B](man: SyncManager[A, B], index: int, peer: A) copy let blobData = - if man.shouldGetBlobs(req.slot.epoch): + if shouldGetBlobs: let blobs = await man.getBlobSidecars(peer, req) if blobs.isErr(): peer.updateScore(PeerScoreNoValues)