@@ -2729,7 +2729,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
27292729 pub fn filter_chain_segment (
27302730 self : & Arc < Self > ,
27312731 chain_segment : Vec < RpcBlock < T :: EthSpec > > ,
2732- ) -> Result < Vec < HashBlockTuple < T :: EthSpec > > , ChainSegmentResult > {
2732+ ) -> Result < Vec < HashBlockTuple < T :: EthSpec > > , Box < ChainSegmentResult > > {
27332733 // This function will never import any blocks.
27342734 let imported_blocks = vec ! [ ] ;
27352735 let mut filtered_chain_segment = Vec :: with_capacity ( chain_segment. len ( ) ) ;
@@ -2746,10 +2746,10 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
27462746 for ( i, block) in chain_segment. into_iter ( ) . enumerate ( ) {
27472747 // Ensure the block is the correct structure for the fork at `block.slot()`.
27482748 if let Err ( e) = block. as_block ( ) . fork_name ( & self . spec ) {
2749- return Err ( ChainSegmentResult :: Failed {
2749+ return Err ( Box :: new ( ChainSegmentResult :: Failed {
27502750 imported_blocks,
27512751 error : BlockError :: InconsistentFork ( e) ,
2752- } ) ;
2752+ } ) ) ;
27532753 }
27542754
27552755 let block_root = block. block_root ( ) ;
@@ -2761,18 +2761,18 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
27612761 // Without this check it would be possible to have a block verified using the
27622762 // incorrect shuffling. That would be bad, mmkay.
27632763 if block_root != * child_parent_root {
2764- return Err ( ChainSegmentResult :: Failed {
2764+ return Err ( Box :: new ( ChainSegmentResult :: Failed {
27652765 imported_blocks,
27662766 error : BlockError :: NonLinearParentRoots ,
2767- } ) ;
2767+ } ) ) ;
27682768 }
27692769
27702770 // Ensure that the slots are strictly increasing throughout the chain segment.
27712771 if * child_slot <= block. slot ( ) {
2772- return Err ( ChainSegmentResult :: Failed {
2772+ return Err ( Box :: new ( ChainSegmentResult :: Failed {
27732773 imported_blocks,
27742774 error : BlockError :: NonLinearSlots ,
2775- } ) ;
2775+ } ) ) ;
27762776 }
27772777 }
27782778
@@ -2803,18 +2803,18 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
28032803 // The block has a known parent that does not descend from the finalized block.
28042804 // There is no need to process this block or any children.
28052805 Err ( BlockError :: NotFinalizedDescendant { block_parent_root } ) => {
2806- return Err ( ChainSegmentResult :: Failed {
2806+ return Err ( Box :: new ( ChainSegmentResult :: Failed {
28072807 imported_blocks,
28082808 error : BlockError :: NotFinalizedDescendant { block_parent_root } ,
2809- } ) ;
2809+ } ) ) ;
28102810 }
28112811 // If there was an error whilst determining if the block was invalid, return that
28122812 // error.
28132813 Err ( BlockError :: BeaconChainError ( e) ) => {
2814- return Err ( ChainSegmentResult :: Failed {
2814+ return Err ( Box :: new ( ChainSegmentResult :: Failed {
28152815 imported_blocks,
28162816 error : BlockError :: BeaconChainError ( e) ,
2817- } ) ;
2817+ } ) ) ;
28182818 }
28192819 // If the block was decided to be irrelevant for any other reason, don't include
28202820 // this block or any of it's children in the filtered chain segment.
@@ -2859,11 +2859,11 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
28592859 ) ;
28602860 let mut filtered_chain_segment = match filtered_chain_segment_future. await {
28612861 Ok ( Ok ( filtered_segment) ) => filtered_segment,
2862- Ok ( Err ( segment_result) ) => return segment_result,
2862+ Ok ( Err ( segment_result) ) => return * segment_result,
28632863 Err ( error) => {
28642864 return ChainSegmentResult :: Failed {
28652865 imported_blocks,
2866- error : BlockError :: BeaconChainError ( error) ,
2866+ error : BlockError :: BeaconChainError ( error. into ( ) ) ,
28672867 }
28682868 }
28692869 } ;
@@ -2902,7 +2902,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
29022902 Err ( error) => {
29032903 return ChainSegmentResult :: Failed {
29042904 imported_blocks,
2905- error : BlockError :: BeaconChainError ( error) ,
2905+ error : BlockError :: BeaconChainError ( error. into ( ) ) ,
29062906 } ;
29072907 }
29082908 } ;
@@ -3440,20 +3440,23 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
34403440
34413441 Ok ( status)
34423442 }
3443- Err ( e @ BlockError :: BeaconChainError ( BeaconChainError :: TokioJoin ( _) ) ) => {
3444- debug ! (
3445- error = ?e,
3446- "Beacon block processing cancelled"
3447- ) ;
3448- Err ( e)
3449- }
3450- // There was an error whilst attempting to verify and import the block. The block might
3451- // be partially verified or partially imported.
34523443 Err ( BlockError :: BeaconChainError ( e) ) => {
3453- crit ! (
3454- error = ?e,
3455- "Beacon block processing error"
3456- ) ;
3444+ match e. as_ref ( ) {
3445+ BeaconChainError :: TokioJoin ( e) => {
3446+ debug ! (
3447+ error = ?e,
3448+ "Beacon block processing cancelled"
3449+ ) ;
3450+ }
3451+ _ => {
3452+ // There was an error whilst attempting to verify and import the block. The block might
3453+ // be partially verified or partially imported.
3454+ crit ! (
3455+ error = ?e,
3456+ "Beacon block processing error"
3457+ ) ;
3458+ }
3459+ } ;
34573460 Err ( BlockError :: BeaconChainError ( e) )
34583461 }
34593462 // The block failed verification.
@@ -3585,7 +3588,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
35853588 header. message . proposer_index ,
35863589 block_root,
35873590 )
3588- . map_err ( |e| BlockError :: BeaconChainError ( e. into ( ) ) ) ?;
3591+ . map_err ( |e| BlockError :: BeaconChainError ( Box :: new ( e. into ( ) ) ) ) ?;
35893592 if let Some ( slasher) = self . slasher . as_ref ( ) {
35903593 slasher. accept_block_header ( header) ;
35913594 }
@@ -3670,7 +3673,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
36703673 header. message . proposer_index ,
36713674 block_root,
36723675 )
3673- . map_err ( |e| BlockError :: BeaconChainError ( e. into ( ) ) ) ?;
3676+ . map_err ( |e| BlockError :: BeaconChainError ( Box :: new ( e. into ( ) ) ) ) ?;
36743677 if let Some ( slasher) = self . slasher . as_ref ( ) {
36753678 slasher. accept_block_header ( header. clone ( ) ) ;
36763679 }
@@ -3853,7 +3856,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
38533856 payload_verification_status,
38543857 & self . spec ,
38553858 )
3856- . map_err ( |e| BlockError :: BeaconChainError ( e. into ( ) ) ) ?;
3859+ . map_err ( |e| BlockError :: BeaconChainError ( Box :: new ( e. into ( ) ) ) ) ?;
38573860 }
38583861
38593862 // If the block is recent enough and it was not optimistically imported, check to see if it
@@ -4066,7 +4069,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
40664069 warning = "The database is likely corrupt now, consider --purge-db" ,
40674070 "No stored fork choice found to restore from"
40684071 ) ;
4069- Err ( BlockError :: BeaconChainError ( e ) )
4072+ Err ( BlockError :: BeaconChainError ( Box :: new ( e ) ) )
40704073 } else {
40714074 Ok ( ( ) )
40724075 }
@@ -4121,9 +4124,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
41214124 Provided block root is not a checkpoint.",
41224125 ) )
41234126 . map_err ( |err| {
4124- BlockError :: BeaconChainError (
4127+ BlockError :: BeaconChainError ( Box :: new (
41254128 BeaconChainError :: WeakSubjectivtyShutdownError ( err) ,
4126- )
4129+ ) )
41274130 } ) ?;
41284131 return Err ( BlockError :: WeakSubjectivityConflict ) ;
41294132 }
@@ -4897,7 +4900,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
48974900 canonical_forkchoice_params : ForkchoiceUpdateParameters ,
48984901 ) -> Result < ForkchoiceUpdateParameters , Error > {
48994902 self . overridden_forkchoice_update_params_or_failure_reason ( & canonical_forkchoice_params)
4900- . or_else ( |e| match e {
4903+ . or_else ( |e| match * e {
49014904 ProposerHeadError :: DoNotReOrg ( reason) => {
49024905 trace ! (
49034906 %reason,
@@ -4912,19 +4915,19 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
49124915 pub fn overridden_forkchoice_update_params_or_failure_reason (
49134916 & self ,
49144917 canonical_forkchoice_params : & ForkchoiceUpdateParameters ,
4915- ) -> Result < ForkchoiceUpdateParameters , ProposerHeadError < Error > > {
4918+ ) -> Result < ForkchoiceUpdateParameters , Box < ProposerHeadError < Error > > > {
49164919 let _timer = metrics:: start_timer ( & metrics:: FORK_CHOICE_OVERRIDE_FCU_TIMES ) ;
49174920
49184921 // Never override if proposer re-orgs are disabled.
49194922 let re_org_head_threshold = self
49204923 . config
49214924 . re_org_head_threshold
4922- . ok_or ( DoNotReOrg :: ReOrgsDisabled ) ?;
4925+ . ok_or ( Box :: new ( DoNotReOrg :: ReOrgsDisabled . into ( ) ) ) ?;
49234926
49244927 let re_org_parent_threshold = self
49254928 . config
49264929 . re_org_parent_threshold
4927- . ok_or ( DoNotReOrg :: ReOrgsDisabled ) ?;
4930+ . ok_or ( Box :: new ( DoNotReOrg :: ReOrgsDisabled . into ( ) ) ) ?;
49284931
49294932 let head_block_root = canonical_forkchoice_params. head_root ;
49304933
@@ -4965,7 +4968,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
49654968 false
49664969 } ;
49674970 if !current_slot_ok {
4968- return Err ( DoNotReOrg :: HeadDistance . into ( ) ) ;
4971+ return Err ( Box :: new ( DoNotReOrg :: HeadDistance . into ( ) ) ) ;
49694972 }
49704973
49714974 // Only attempt a re-org if we have a proposer registered for the re-org slot.
@@ -4988,7 +4991,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
49884991 decision_root = ?shuffling_decision_root,
49894992 "Fork choice override proposer shuffling miss"
49904993 ) ;
4991- DoNotReOrg :: NotProposing
4994+ Box :: new ( DoNotReOrg :: NotProposing . into ( ) )
49924995 } ) ?
49934996 . index as u64 ;
49944997
@@ -4998,7 +5001,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
49985001 . has_proposer_preparation_data_blocking ( proposer_index)
49995002 } ;
50005003 if !proposing_at_re_org_slot {
5001- return Err ( DoNotReOrg :: NotProposing . into ( ) ) ;
5004+ return Err ( Box :: new ( DoNotReOrg :: NotProposing . into ( ) ) ) ;
50025005 }
50035006
50045007 // If the current slot is already equal to the proposal slot (or we are in the tail end of
@@ -5013,18 +5016,22 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
50135016 ( true , true )
50145017 } ;
50155018 if !head_weak {
5016- return Err ( DoNotReOrg :: HeadNotWeak {
5017- head_weight : info. head_node . weight ,
5018- re_org_head_weight_threshold : info. re_org_head_weight_threshold ,
5019- }
5020- . into ( ) ) ;
5019+ return Err ( Box :: new (
5020+ DoNotReOrg :: HeadNotWeak {
5021+ head_weight : info. head_node . weight ,
5022+ re_org_head_weight_threshold : info. re_org_head_weight_threshold ,
5023+ }
5024+ . into ( ) ,
5025+ ) ) ;
50215026 }
50225027 if !parent_strong {
5023- return Err ( DoNotReOrg :: ParentNotStrong {
5024- parent_weight : info. parent_node . weight ,
5025- re_org_parent_weight_threshold : info. re_org_parent_weight_threshold ,
5026- }
5027- . into ( ) ) ;
5028+ return Err ( Box :: new (
5029+ DoNotReOrg :: ParentNotStrong {
5030+ parent_weight : info. parent_node . weight ,
5031+ re_org_parent_weight_threshold : info. re_org_parent_weight_threshold ,
5032+ }
5033+ . into ( ) ,
5034+ ) ) ;
50285035 }
50295036
50305037 // Check that the head block arrived late and is vulnerable to a re-org. This check is only
@@ -5035,7 +5042,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
50355042 let head_block_late =
50365043 self . block_observed_after_attestation_deadline ( head_block_root, head_slot) ;
50375044 if !head_block_late {
5038- return Err ( DoNotReOrg :: HeadNotLate . into ( ) ) ;
5045+ return Err ( Box :: new ( DoNotReOrg :: HeadNotLate . into ( ) ) ) ;
50395046 }
50405047
50415048 let parent_head_hash = info. parent_node . execution_status . block_hash ( ) ;
@@ -5249,16 +5256,16 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
52495256 . validators ( )
52505257 . get ( proposer_index as usize )
52515258 . map ( |v| v. pubkey )
5252- . ok_or ( BlockProductionError :: BeaconChain (
5259+ . ok_or ( BlockProductionError :: BeaconChain ( Box :: new (
52535260 BeaconChainError :: ValidatorIndexUnknown ( proposer_index as usize ) ,
5254- ) ) ?;
5261+ ) ) ) ?;
52555262
52565263 let builder_params = BuilderParams {
52575264 pubkey,
52585265 slot : state. slot ( ) ,
52595266 chain_health : self
52605267 . is_healthy ( & parent_root)
5261- . map_err ( BlockProductionError :: BeaconChain ) ?,
5268+ . map_err ( |e| BlockProductionError :: BeaconChain ( Box :: new ( e ) ) ) ?,
52625269 } ;
52635270
52645271 // If required, start the process of loading an execution payload from the EL early. This
0 commit comments