@@ -3,7 +3,7 @@ use std::future::Future;
3
3
4
4
use beacon_chain:: blob_verification:: { GossipBlobError , GossipVerifiedBlob } ;
5
5
use beacon_chain:: block_verification_types:: { AsBlock , RpcBlock } ;
6
- use beacon_chain:: data_column_verification:: { GossipDataColumnError , GossipVerifiedDataColumn } ;
6
+ use beacon_chain:: data_column_verification:: GossipVerifiedDataColumn ;
7
7
use beacon_chain:: validator_monitor:: { get_block_delay_ms, timestamp_now} ;
8
8
use beacon_chain:: {
9
9
AvailabilityProcessingStatus , BeaconChain , BeaconChainError , BeaconChainTypes , BlockError ,
@@ -216,7 +216,7 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlock<T>>(
216
216
}
217
217
}
218
218
219
- if gossip_verified_columns. iter ( ) . map ( Option :: is_some ) . count ( ) > 0 {
219
+ if ! gossip_verified_columns. is_empty ( ) {
220
220
if let Some ( data_column_publishing_delay) = data_column_publishing_delay_for_testing {
221
221
// Subtract block publishing delay if it is also used.
222
222
// Note: if `data_column_publishing_delay` is less than `block_publishing_delay`, it
@@ -240,7 +240,6 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlock<T>>(
240
240
let sampling_columns_indices = chain. sampling_columns_for_epoch ( epoch) ;
241
241
let sampling_columns = gossip_verified_columns
242
242
. into_iter ( )
243
- . flatten ( )
244
243
. filter ( |data_column| sampling_columns_indices. contains ( & data_column. index ( ) ) )
245
244
. collect :: < Vec < _ > > ( ) ;
246
245
@@ -348,7 +347,7 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlock<T>>(
348
347
type BuildDataSidecarTaskResult < T > = Result <
349
348
(
350
349
Vec < Option < GossipVerifiedBlob < T > > > ,
351
- Vec < Option < GossipVerifiedDataColumn < T > > > ,
350
+ Vec < GossipVerifiedDataColumn < T > > ,
352
351
) ,
353
352
Rejection ,
354
353
> ;
@@ -382,7 +381,7 @@ fn spawn_build_data_sidecar_task<T: BeaconChainTypes>(
382
381
} else {
383
382
// Post PeerDAS: construct data columns.
384
383
let gossip_verified_data_columns =
385
- build_gossip_verified_data_columns ( & chain, & block, blobs, kzg_proofs) ?;
384
+ build_data_columns ( & chain, & block, blobs, kzg_proofs) ?;
386
385
Ok ( ( vec ! [ ] , gossip_verified_data_columns) )
387
386
}
388
387
} ,
@@ -397,12 +396,16 @@ fn spawn_build_data_sidecar_task<T: BeaconChainTypes>(
397
396
} )
398
397
}
399
398
400
- fn build_gossip_verified_data_columns < T : BeaconChainTypes > (
399
+ /// Build data columns as wrapped `GossipVerifiedDataColumn`s.
400
+ /// There is no need to actually perform gossip verification on columns that a block producer
401
+ /// is publishing. In the locally constructed case, cell proof verification happens in the EL.
402
+ /// In the externally constructed case, there wont be any columns here.
403
+ fn build_data_columns < T : BeaconChainTypes > (
401
404
chain : & BeaconChain < T > ,
402
405
block : & SignedBeaconBlock < T :: EthSpec , FullPayload < T :: EthSpec > > ,
403
406
blobs : BlobsList < T :: EthSpec > ,
404
407
kzg_cell_proofs : KzgProofs < T :: EthSpec > ,
405
- ) -> Result < Vec < Option < GossipVerifiedDataColumn < T > > > , Rejection > {
408
+ ) -> Result < Vec < GossipVerifiedDataColumn < T > > , Rejection > {
406
409
let slot = block. slot ( ) ;
407
410
let data_column_sidecars =
408
411
build_blob_data_column_sidecars ( chain, block, blobs, kzg_cell_proofs) . map_err ( |e| {
@@ -414,49 +417,12 @@ fn build_gossip_verified_data_columns<T: BeaconChainTypes>(
414
417
warp_utils:: reject:: custom_bad_request ( format ! ( "{e:?}" ) )
415
418
} ) ?;
416
419
417
- let slot = block. slot ( ) ;
418
420
let gossip_verified_data_columns = data_column_sidecars
419
421
. into_iter ( )
420
- . map ( |data_column_sidecar| {
421
- let column_index = data_column_sidecar. index ;
422
- let subnet = DataColumnSubnetId :: from_column_index ( column_index, & chain. spec ) ;
423
- let gossip_verified_column =
424
- GossipVerifiedDataColumn :: new ( data_column_sidecar, subnet, chain) ;
425
-
426
- match gossip_verified_column {
427
- Ok ( blob) => Ok ( Some ( blob) ) ,
428
- Err ( GossipDataColumnError :: PriorKnown { proposer, .. } ) => {
429
- // Log the error but do not abort publication, we may need to publish the block
430
- // or some of the other data columns if the block & data columns are only
431
- // partially published by the other publisher.
432
- debug ! (
433
- column_index,
434
- %slot,
435
- proposer,
436
- "Data column for publication already known"
437
- ) ;
438
- Ok ( None )
439
- }
440
- Err ( GossipDataColumnError :: PriorKnownUnpublished ) => {
441
- debug ! (
442
- column_index,
443
- %slot,
444
- "Data column for publication already known via the EL"
445
- ) ;
446
- Ok ( None )
447
- }
448
- Err ( e) => {
449
- error ! (
450
- column_index,
451
- %slot,
452
- error = ?e,
453
- "Data column for publication is gossip-invalid"
454
- ) ;
455
- Err ( warp_utils:: reject:: custom_bad_request ( format ! ( "{e:?}" ) ) )
456
- }
457
- }
422
+ . filter_map ( |data_column_sidecar| {
423
+ GossipVerifiedDataColumn :: new_for_block_publishing ( data_column_sidecar, chain) . ok ( )
458
424
} )
459
- . collect :: < Result < Vec < _ > , Rejection > > ( ) ? ;
425
+ . collect :: < Vec < _ > > ( ) ;
460
426
461
427
Ok ( gossip_verified_data_columns)
462
428
}
@@ -533,13 +499,12 @@ fn publish_blob_sidecars<T: BeaconChainTypes>(
533
499
534
500
fn publish_column_sidecars < T : BeaconChainTypes > (
535
501
sender_clone : & UnboundedSender < NetworkMessage < T :: EthSpec > > ,
536
- data_column_sidecars : & [ Option < GossipVerifiedDataColumn < T > > ] ,
502
+ data_column_sidecars : & [ GossipVerifiedDataColumn < T > ] ,
537
503
chain : & BeaconChain < T > ,
538
504
) -> Result < ( ) , BlockError > {
539
505
let malicious_withhold_count = chain. config . malicious_withhold_count ;
540
506
let mut data_column_sidecars = data_column_sidecars
541
507
. iter ( )
542
- . flatten ( )
543
508
. map ( |d| d. clone_data_column ( ) )
544
509
. collect :: < Vec < _ > > ( ) ;
545
510
if malicious_withhold_count > 0 {
0 commit comments