@@ -13,6 +13,8 @@ use parking_lot::RwLock;
13
13
use std:: cmp:: Ordering ;
14
14
use std:: num:: NonZeroUsize ;
15
15
use std:: sync:: Arc ;
16
+ use std:: thread:: sleep;
17
+ use std:: time:: Duration ;
16
18
use tracing:: debug;
17
19
use types:: blob_sidecar:: BlobIdentifier ;
18
20
use types:: {
@@ -560,7 +562,7 @@ impl<T: BeaconChainTypes> DataAvailabilityCheckerInner<T> {
560
562
561
563
// If we're sampling all columns, it means we must be custodying all columns.
562
564
let total_column_count = self . spec . number_of_columns as usize ;
563
- let received_column_count = pending_components. verified_data_columns . len ( ) ;
565
+ let mut received_column_count = pending_components. verified_data_columns . len ( ) ;
564
566
565
567
if pending_components. reconstruction_started {
566
568
return ReconstructColumnsDecision :: No ( "already started" ) ;
@@ -573,7 +575,31 @@ impl<T: BeaconChainTypes> DataAvailabilityCheckerInner<T> {
573
575
}
574
576
575
577
pending_components. reconstruction_started = true ;
576
- ReconstructColumnsDecision :: Yes ( pending_components. verified_data_columns . clone ( ) )
578
+
579
+ // Instead of starting to reconstruct immediately, wait for more columns to arrive
580
+ drop ( write_lock) ;
581
+ loop {
582
+ sleep ( Duration :: from_millis ( 25 ) ) ;
583
+ let mut write_lock = self . critical . write ( ) ;
584
+ let Some ( pending_components) = write_lock. get ( block_root) else {
585
+ // Block may have been imported as it does not exist in availability cache.
586
+ return ReconstructColumnsDecision :: No ( "block already imported" ) ;
587
+ } ;
588
+ let new_received_column_count = pending_components. verified_data_columns . len ( ) ;
589
+
590
+ // Check if there is still a need to reconstruct.
591
+ if new_received_column_count >= total_column_count {
592
+ return ReconstructColumnsDecision :: No ( "all columns received" ) ;
593
+ }
594
+
595
+ // Check if no new column arrived.
596
+ if new_received_column_count == received_column_count {
597
+ return ReconstructColumnsDecision :: Yes ( pending_components. verified_data_columns . clone ( ) ) ;
598
+ }
599
+
600
+ // Update count for next check.
601
+ received_column_count = new_received_column_count;
602
+ }
577
603
}
578
604
579
605
/// This could mean some invalid data columns made it through to the `DataAvailabilityChecker`.
0 commit comments