3737 slot: Slot
3838
3939 BlockRootsList * = List [Eth2Digest , Limit MAX_REQUEST_BLOCKS ]
40- BlobIdentifierList * = List [BlobIdentifier , Limit (MAX_REQUEST_BLOB_SIDECARS )]
41- DataColumnIdentifierList * = List [DataColumnIdentifier , Limit (MAX_REQUEST_DATA_COLUMN_SIDECARS )]
40+ BlobIdentifierList * = List [
41+ BlobIdentifier , Limit MAX_SUPPORTED_REQUEST_BLOB_SIDECARS ]
42+ DataColumnIdentifierList * = List [
43+ DataColumnIdentifier , Limit (MAX_REQUEST_DATA_COLUMN_SIDECARS )]
4244
4345proc readChunkPayload * (
4446 conn: Connection , peer: Peer , MsgType: type (ref ForkedSignedBeaconBlock )):
@@ -108,11 +110,13 @@ proc readChunkPayload*(
108110
109111template getBlobSidecarsByRoot (
110112 versionNumber: static string , peer: Peer , dag: ChainDAGRef , response: auto ,
111- blobIds: BlobIdentifierList ) =
113+ blobIds: BlobIdentifierList , maxReqSidecars: uint64 ) =
112114 trace " got v" & versionNumber & " blobs range request" ,
113115 peer, len = blobIds.len
114116 if blobIds.len == 0 :
115117 raise newException (InvalidInputsError , " No blobs requested" )
118+ if blobIds.lenu64 > maxReqSidecars:
119+ raise newException (InvalidInputsError , " Exceeding blob request limit" )
116120
117121 let count = blobIds.len
118122
@@ -145,8 +149,8 @@ template getBlobSidecarsByRoot(
145149
146150template getBlobSidecarsByRange (
147151 versionNumber: static string , peer: Peer , dag: ChainDAGRef , response: auto ,
148- startSlot: Slot , reqCount: uint64 , blobsPerBlock: static uint64 ,
149- maxReqSidecars: static uint64 ) =
152+ startSlot: Slot , reqCount: uint64 , blobsPerBlock: uint64 ,
153+ maxReqSidecars: uint64 ) =
150154 trace " got v" & versionNumber & " blobs range request" ,
151155 peer, startSlot, count = reqCount
152156 if reqCount == 0 :
@@ -161,9 +165,9 @@ template getBlobSidecarsByRange(
161165 if startSlot.epoch < epochBoundary:
162166 raise newException (ResourceUnavailableError , BlobsOutOfRange )
163167
164- var blockIds: array [int (maxReqSidecars) , BlockId ]
168+ var blockIds: array [MAX_SUPPORTED_REQUEST_BLOB_SIDECARS . int , BlockId ]
165169 let
166- count = int min (reqCount, blockIds.lenu64 )
170+ count = int min (reqCount, maxReqSidecars )
167171 endIndex = count - 1
168172 startIndex =
169173 dag.getBlockRange (startSlot, blockIds.toOpenArray (0 , endIndex))
@@ -334,7 +338,7 @@ p2pProtocol BeaconSync(version = 1,
334338 peer: Peer ,
335339 blobIds: BlobIdentifierList ,
336340 response: MultipleChunksResponse [
337- ref BlobSidecar , Limit (MAX_REQUEST_BLOB_SIDECARS_ELECTRA )])
341+ ref BlobSidecar , Limit (MAX_SUPPORTED_REQUEST_BLOB_SIDECARS )])
338342 {.async , libp2pProtocol (" blob_sidecars_by_root" , 1 ).} =
339343 # TODO Semantically, this request should return a non-ref, but doing so
340344 # runs into extreme inefficiency due to the compiler introducing
@@ -348,15 +352,17 @@ p2pProtocol BeaconSync(version = 1,
348352 # client call that returns `seq[ref BlobSidecar]` will
349353 # will be generated by the libp2p macro - we guarantee that seq items
350354 # are `not-nil` in the implementation
351- getBlobSidecarsByRoot (" 1" , peer, peer.networkState.dag, response, blobIds)
355+ getBlobSidecarsByRoot (
356+ " 1" , peer, peer.networkState.dag, response, blobIds,
357+ peer.networkState.dag.cfg.MAX_REQUEST_BLOB_SIDECARS_ELECTRA )
352358
353359 # https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/deneb/p2p-interface.md#blobsidecarsbyrange-v1
354360 proc blobSidecarsByRange (
355361 peer: Peer ,
356362 startSlot: Slot ,
357363 reqCount: uint64 ,
358364 response: MultipleChunksResponse [
359- ref BlobSidecar , Limit (MAX_REQUEST_BLOB_SIDECARS_ELECTRA )])
365+ ref BlobSidecar , Limit (MAX_SUPPORTED_REQUEST_BLOB_SIDECARS )])
360366 {.async , libp2pProtocol (" blob_sidecars_by_range" , 1 ).} =
361367 # TODO This code is more complicated than it needs to be, since the type
362368 # of the multiple chunks response is not actually used in this server
@@ -368,7 +374,8 @@ p2pProtocol BeaconSync(version = 1,
368374 # are `not-nil` in the implementation
369375 getBlobSidecarsByRange (
370376 " 1" , peer, peer.networkState.dag, response, startSlot, reqCount,
371- MAX_BLOBS_PER_BLOCK_ELECTRA , MAX_REQUEST_BLOB_SIDECARS_ELECTRA )
377+ peer.networkState.dag.cfg.MAX_BLOBS_PER_BLOCK_ELECTRA ,
378+ peer.networkState.dag.cfg.MAX_REQUEST_BLOB_SIDECARS_ELECTRA )
372379
373380 # https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.10/specs/fulu/p2p-interface.md#datacolumnsidecarsbyroot-v1
374381 proc dataColumnSidecarsByRoot (
@@ -420,7 +427,7 @@ p2pProtocol BeaconSync(version = 1,
420427 debug " Data column root request done" ,
421428 peer, roots = colIds.len, count, found
422429
423- # https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.10/specs/fulu/p2p-interface.md#datacolumnsidecarsbyrange-v1
430+ # https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.10/specs/fulu/p2p-interface.md#datacolumnsidecarsbyrange-v1
424431 proc dataColumnSidecarsByRange (
425432 peer: Peer ,
426433 startSlot: Slot ,
0 commit comments