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.
This commit is contained in:
Etan Kissling 2024-03-22 03:27:02 +01:00 committed by GitHub
parent 17ee40b39b
commit 9d5643240b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 1 deletions

View File

@ -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)