@@ -117,7 +117,8 @@ use std::sync::Arc;
117117use std:: time:: Duration ;
118118use store:: iter:: { BlockRootsIterator , ParentRootBlockIterator , StateRootsIterator } ;
119119use store:: {
120- DatabaseBlock , Error as DBError , HotColdDB , KeyValueStore , KeyValueStoreOp , StoreItem , StoreOp ,
120+ BlobSidecarListFromRoot , DatabaseBlock , Error as DBError , HotColdDB , KeyValueStore ,
121+ KeyValueStoreOp , StoreItem , StoreOp ,
121122} ;
122123use task_executor:: { ShutdownReason , TaskExecutor } ;
123124use tokio:: sync:: mpsc:: Receiver ;
@@ -573,7 +574,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
573574 . start_slot ( T :: EthSpec :: slots_per_epoch ( ) ) ;
574575 let is_canonical = self
575576 . block_root_at_slot ( block_slot, WhenSlotSkipped :: None ) ?
576- . map_or ( false , |canonical_root| block_root == & canonical_root) ;
577+ . is_some_and ( |canonical_root| block_root == & canonical_root) ;
577578 Ok ( block_slot <= finalized_slot && is_canonical)
578579 }
579580
@@ -604,7 +605,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
604605 let slot_is_finalized = state_slot <= finalized_slot;
605606 let canonical = self
606607 . state_root_at_slot ( state_slot) ?
607- . map_or ( false , |canonical_root| state_root == & canonical_root) ;
608+ . is_some_and ( |canonical_root| state_root == & canonical_root) ;
608609 Ok ( FinalizationAndCanonicity {
609610 slot_is_finalized,
610611 canonical,
@@ -1147,9 +1148,10 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
11471148 pub fn get_blobs_checking_early_attester_cache (
11481149 & self ,
11491150 block_root : & Hash256 ,
1150- ) -> Result < BlobSidecarList < T :: EthSpec > , Error > {
1151+ ) -> Result < BlobSidecarListFromRoot < T :: EthSpec > , Error > {
11511152 self . early_attester_cache
11521153 . get_blobs ( * block_root)
1154+ . map ( Into :: into)
11531155 . map_or_else ( || self . get_blobs ( block_root) , Ok )
11541156 }
11551157
@@ -1240,11 +1242,11 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
12401242 ///
12411243 /// ## Errors
12421244 /// May return a database error.
1243- pub fn get_blobs ( & self , block_root : & Hash256 ) -> Result < BlobSidecarList < T :: EthSpec > , Error > {
1244- match self . store . get_blobs ( block_root ) ? {
1245- Some ( blobs ) => Ok ( blobs ) ,
1246- None => Ok ( BlobSidecarList :: default ( ) ) ,
1247- }
1245+ pub fn get_blobs (
1246+ & self ,
1247+ block_root : & Hash256 ,
1248+ ) -> Result < BlobSidecarListFromRoot < T :: EthSpec > , Error > {
1249+ self . store . get_blobs ( block_root ) . map_err ( Error :: from )
12481250 }
12491251
12501252 /// Returns the data columns at the given root, if any.
@@ -5118,9 +5120,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
51185120 . start_of ( slot)
51195121 . unwrap_or_else ( || Duration :: from_secs ( 0 ) ) ,
51205122 ) ;
5121- block_delays. observed . map_or ( false , |delay| {
5122- delay >= self . slot_clock . unagg_attestation_production_delay ( )
5123- } )
5123+ block_delays
5124+ . observed
5125+ . is_some_and ( |delay| delay >= self . slot_clock . unagg_attestation_production_delay ( ) )
51245126 }
51255127
51265128 /// Produce a block for some `slot` upon the given `state`.
@@ -5317,23 +5319,19 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
53175319
53185320 // If required, start the process of loading an execution payload from the EL early. This
53195321 // allows it to run concurrently with things like attestation packing.
5320- let prepare_payload_handle = match & state {
5321- BeaconState :: Base ( _) | BeaconState :: Altair ( _) => None ,
5322- BeaconState :: Bellatrix ( _)
5323- | BeaconState :: Capella ( _)
5324- | BeaconState :: Deneb ( _)
5325- | BeaconState :: Electra ( _) => {
5326- let prepare_payload_handle = get_execution_payload (
5327- self . clone ( ) ,
5328- & state,
5329- parent_root,
5330- proposer_index,
5331- builder_params,
5332- builder_boost_factor,
5333- block_production_version,
5334- ) ?;
5335- Some ( prepare_payload_handle)
5336- }
5322+ let prepare_payload_handle = if state. fork_name_unchecked ( ) . bellatrix_enabled ( ) {
5323+ let prepare_payload_handle = get_execution_payload (
5324+ self . clone ( ) ,
5325+ & state,
5326+ parent_root,
5327+ proposer_index,
5328+ builder_params,
5329+ builder_boost_factor,
5330+ block_production_version,
5331+ ) ?;
5332+ Some ( prepare_payload_handle)
5333+ } else {
5334+ None
53375335 } ;
53385336
53395337 let ( mut proposer_slashings, mut attester_slashings, mut voluntary_exits) =
@@ -5751,6 +5749,48 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
57515749 execution_payload_value,
57525750 )
57535751 }
5752+ BeaconState :: Fulu ( _) => {
5753+ let (
5754+ payload,
5755+ kzg_commitments,
5756+ maybe_blobs_and_proofs,
5757+ maybe_requests,
5758+ execution_payload_value,
5759+ ) = block_contents
5760+ . ok_or ( BlockProductionError :: MissingExecutionPayload ) ?
5761+ . deconstruct ( ) ;
5762+
5763+ (
5764+ BeaconBlock :: Fulu ( BeaconBlockFulu {
5765+ slot,
5766+ proposer_index,
5767+ parent_root,
5768+ state_root : Hash256 :: zero ( ) ,
5769+ body : BeaconBlockBodyFulu {
5770+ randao_reveal,
5771+ eth1_data,
5772+ graffiti,
5773+ proposer_slashings : proposer_slashings. into ( ) ,
5774+ attester_slashings : attester_slashings_electra. into ( ) ,
5775+ attestations : attestations_electra. into ( ) ,
5776+ deposits : deposits. into ( ) ,
5777+ voluntary_exits : voluntary_exits. into ( ) ,
5778+ sync_aggregate : sync_aggregate
5779+ . ok_or ( BlockProductionError :: MissingSyncAggregate ) ?,
5780+ execution_payload : payload
5781+ . try_into ( )
5782+ . map_err ( |_| BlockProductionError :: InvalidPayloadFork ) ?,
5783+ bls_to_execution_changes : bls_to_execution_changes. into ( ) ,
5784+ blob_kzg_commitments : kzg_commitments
5785+ . ok_or ( BlockProductionError :: InvalidPayloadFork ) ?,
5786+ execution_requests : maybe_requests
5787+ . ok_or ( BlockProductionError :: MissingExecutionRequests ) ?,
5788+ } ,
5789+ } ) ,
5790+ maybe_blobs_and_proofs,
5791+ execution_payload_value,
5792+ )
5793+ }
57545794 } ;
57555795
57565796 let block = SignedBeaconBlock :: from_block (
0 commit comments