@@ -16,9 +16,10 @@ use std::collections::HashSet;
1616use std:: num:: NonZeroUsize ;
1717use std:: sync:: Arc ;
1818use types:: blob_sidecar:: BlobIdentifier ;
19+ use types:: runtime_var_list:: RuntimeFixedList ;
1920use types:: {
2021 BlobSidecar , ChainSpec , ColumnIndex , DataColumnIdentifier , DataColumnSidecar ,
21- DataColumnSidecarList , Epoch , EthSpec , Hash256 , SignedBeaconBlock ,
22+ DataColumnSidecarList , Epoch , EthSpec , Hash256 , RuntimeVariableList , SignedBeaconBlock ,
2223} ;
2324
2425pub type DataColumnsToPublish < E > = Option < DataColumnSidecarList < E > > ;
@@ -32,7 +33,7 @@ pub type DataColumnsToPublish<E> = Option<DataColumnSidecarList<E>>;
3233#[ derive( Clone ) ]
3334pub struct PendingComponents < E : EthSpec > {
3435 pub block_root : Hash256 ,
35- pub verified_blobs : FixedVector < Option < KzgVerifiedBlob < E > > , E :: MaxBlobsPerBlock > ,
36+ pub verified_blobs : RuntimeFixedList < Option < KzgVerifiedBlob < E > > > ,
3637 pub verified_data_columns : Vec < KzgVerifiedCustodyDataColumn < E > > ,
3738 pub executed_block : Option < DietAvailabilityPendingExecutedBlock < E > > ,
3839 pub reconstruction_started : bool ,
@@ -50,9 +51,7 @@ impl<E: EthSpec> PendingComponents<E> {
5051 }
5152
5253 /// Returns an immutable reference to the fixed vector of cached blobs.
53- pub fn get_cached_blobs (
54- & self ,
55- ) -> & FixedVector < Option < KzgVerifiedBlob < E > > , E :: MaxBlobsPerBlock > {
54+ pub fn get_cached_blobs ( & self ) -> & RuntimeFixedList < Option < KzgVerifiedBlob < E > > > {
5655 & self . verified_blobs
5756 }
5857
@@ -73,9 +72,7 @@ impl<E: EthSpec> PendingComponents<E> {
7372 }
7473
7574 /// Returns a mutable reference to the fixed vector of cached blobs.
76- pub fn get_cached_blobs_mut (
77- & mut self ,
78- ) -> & mut FixedVector < Option < KzgVerifiedBlob < E > > , E :: MaxBlobsPerBlock > {
75+ pub fn get_cached_blobs_mut ( & mut self ) -> & mut RuntimeFixedList < Option < KzgVerifiedBlob < E > > > {
7976 & mut self . verified_blobs
8077 }
8178
@@ -147,10 +144,7 @@ impl<E: EthSpec> PendingComponents<E> {
147144 /// Blobs are only inserted if:
148145 /// 1. The blob entry at the index is empty and no block exists.
149146 /// 2. The block exists and its commitment matches the blob's commitment.
150- pub fn merge_blobs (
151- & mut self ,
152- blobs : FixedVector < Option < KzgVerifiedBlob < E > > , E :: MaxBlobsPerBlock > ,
153- ) {
147+ pub fn merge_blobs ( & mut self , blobs : RuntimeFixedList < Option < KzgVerifiedBlob < E > > > ) {
154148 for ( index, blob) in blobs. iter ( ) . cloned ( ) . enumerate ( ) {
155149 let Some ( blob) = blob else { continue } ;
156150 self . merge_single_blob ( index, blob) ;
@@ -194,7 +188,7 @@ impl<E: EthSpec> PendingComponents<E> {
194188 /// Blobs that don't match the new block's commitments are evicted.
195189 pub fn merge_block ( & mut self , block : DietAvailabilityPendingExecutedBlock < E > ) {
196190 self . insert_block ( block) ;
197- let reinsert = std :: mem :: take ( self . get_cached_blobs_mut ( ) ) ;
191+ let reinsert = self . get_cached_blobs_mut ( ) . take ( ) ;
198192 self . merge_blobs ( reinsert) ;
199193 }
200194
@@ -223,10 +217,11 @@ impl<E: EthSpec> PendingComponents<E> {
223217 }
224218
225219 /// Returns an empty `PendingComponents` object with the given block root.
226- pub fn empty ( block_root : Hash256 ) -> Self {
220+ pub fn empty ( block_root : Hash256 , max_len : usize ) -> Self {
227221 Self {
228222 block_root,
229- verified_blobs : FixedVector :: default ( ) ,
223+ // TODO(pawan): just make this a vec potentially
224+ verified_blobs : RuntimeFixedList :: new ( vec ! [ None ; max_len] ) ,
230225 verified_data_columns : vec ! [ ] ,
231226 executed_block : None ,
232227 reconstruction_started : false ,
@@ -280,7 +275,12 @@ impl<E: EthSpec> PendingComponents<E> {
280275 else {
281276 return Err ( AvailabilityCheckError :: Unexpected ) ;
282277 } ;
283- ( Some ( VariableList :: new ( verified_blobs) ?) , None )
278+ let max_len =
279+ spec. max_blobs_per_block ( diet_executed_block. as_block ( ) . epoch ( ) ) as usize ;
280+ (
281+ Some ( RuntimeVariableList :: new ( verified_blobs, max_len) ?) ,
282+ None ,
283+ )
284284 }
285285 BlockImportRequirement :: CustodyColumns ( _) => {
286286 let verified_data_columns = verified_data_columns
@@ -477,7 +477,8 @@ impl<T: BeaconChainTypes> DataAvailabilityCheckerInner<T> {
477477 epoch : Epoch ,
478478 kzg_verified_blobs : I ,
479479 ) -> Result < Availability < T :: EthSpec > , AvailabilityCheckError > {
480- let mut fixed_blobs = FixedVector :: default ( ) ;
480+ let mut fixed_blobs =
481+ RuntimeFixedList :: new ( vec ! [ None ; self . spec. max_blobs_per_block( epoch) as usize ] ) ;
481482
482483 for blob in kzg_verified_blobs {
483484 if let Some ( blob_opt) = fixed_blobs. get_mut ( blob. blob_index ( ) as usize ) {
@@ -491,7 +492,9 @@ impl<T: BeaconChainTypes> DataAvailabilityCheckerInner<T> {
491492 let mut pending_components = write_lock
492493 . pop_entry ( & block_root)
493494 . map ( |( _, v) | v)
494- . unwrap_or_else ( || PendingComponents :: empty ( block_root) ) ;
495+ . unwrap_or_else ( || {
496+ PendingComponents :: empty ( block_root, self . spec . max_blobs_per_block ( epoch) as usize )
497+ } ) ;
495498
496499 // Merge in the blobs.
497500 pending_components. merge_blobs ( fixed_blobs) ;
@@ -527,7 +530,9 @@ impl<T: BeaconChainTypes> DataAvailabilityCheckerInner<T> {
527530 let mut pending_components = write_lock
528531 . pop_entry ( & block_root)
529532 . map ( |( _, v) | v)
530- . unwrap_or_else ( || PendingComponents :: empty ( block_root) ) ;
533+ . unwrap_or_else ( || {
534+ PendingComponents :: empty ( block_root, self . spec . max_blobs_per_block ( epoch) as usize )
535+ } ) ;
531536
532537 // Merge in the data columns.
533538 pending_components. merge_data_columns ( kzg_verified_data_columns) ?;
@@ -614,7 +619,9 @@ impl<T: BeaconChainTypes> DataAvailabilityCheckerInner<T> {
614619 let mut pending_components = write_lock
615620 . pop_entry ( & block_root)
616621 . map ( |( _, v) | v)
617- . unwrap_or_else ( || PendingComponents :: empty ( block_root) ) ;
622+ . unwrap_or_else ( || {
623+ PendingComponents :: empty ( block_root, self . spec . max_blobs_per_block ( epoch) as usize )
624+ } ) ;
618625
619626 // Merge in the block.
620627 pending_components. merge_block ( diet_executed_block) ;
0 commit comments