@@ -2733,7 +2733,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
27332733 pub fn filter_chain_segment (
27342734 self : & Arc < Self > ,
27352735 chain_segment : Vec < RpcBlock < T :: EthSpec > > ,
2736- ) -> Result < Vec < HashBlockTuple < T :: EthSpec > > , ChainSegmentResult > {
2736+ ) -> Result < Vec < HashBlockTuple < T :: EthSpec > > , Box < ChainSegmentResult > > {
27372737 // This function will never import any blocks.
27382738 let imported_blocks = vec ! [ ] ;
27392739 let mut filtered_chain_segment = Vec :: with_capacity ( chain_segment. len ( ) ) ;
@@ -2750,10 +2750,10 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
27502750 for ( i, block) in chain_segment. into_iter ( ) . enumerate ( ) {
27512751 // Ensure the block is the correct structure for the fork at `block.slot()`.
27522752 if let Err ( e) = block. as_block ( ) . fork_name ( & self . spec ) {
2753- return Err ( ChainSegmentResult :: Failed {
2753+ return Err ( Box :: new ( ChainSegmentResult :: Failed {
27542754 imported_blocks,
27552755 error : BlockError :: InconsistentFork ( e) ,
2756- } ) ;
2756+ } ) ) ;
27572757 }
27582758
27592759 let block_root = block. block_root ( ) ;
@@ -2765,18 +2765,18 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
27652765 // Without this check it would be possible to have a block verified using the
27662766 // incorrect shuffling. That would be bad, mmkay.
27672767 if block_root != * child_parent_root {
2768- return Err ( ChainSegmentResult :: Failed {
2768+ return Err ( Box :: new ( ChainSegmentResult :: Failed {
27692769 imported_blocks,
27702770 error : BlockError :: NonLinearParentRoots ,
2771- } ) ;
2771+ } ) ) ;
27722772 }
27732773
27742774 // Ensure that the slots are strictly increasing throughout the chain segment.
27752775 if * child_slot <= block. slot ( ) {
2776- return Err ( ChainSegmentResult :: Failed {
2776+ return Err ( Box :: new ( ChainSegmentResult :: Failed {
27772777 imported_blocks,
27782778 error : BlockError :: NonLinearSlots ,
2779- } ) ;
2779+ } ) ) ;
27802780 }
27812781 }
27822782
@@ -2807,18 +2807,18 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
28072807 // The block has a known parent that does not descend from the finalized block.
28082808 // There is no need to process this block or any children.
28092809 Err ( BlockError :: NotFinalizedDescendant { block_parent_root } ) => {
2810- return Err ( ChainSegmentResult :: Failed {
2810+ return Err ( Box :: new ( ChainSegmentResult :: Failed {
28112811 imported_blocks,
28122812 error : BlockError :: NotFinalizedDescendant { block_parent_root } ,
2813- } ) ;
2813+ } ) ) ;
28142814 }
28152815 // If there was an error whilst determining if the block was invalid, return that
28162816 // error.
28172817 Err ( BlockError :: BeaconChainError ( e) ) => {
2818- return Err ( ChainSegmentResult :: Failed {
2818+ return Err ( Box :: new ( ChainSegmentResult :: Failed {
28192819 imported_blocks,
28202820 error : BlockError :: BeaconChainError ( e) ,
2821- } ) ;
2821+ } ) ) ;
28222822 }
28232823 // If the block was decided to be irrelevant for any other reason, don't include
28242824 // this block or any of it's children in the filtered chain segment.
@@ -2863,11 +2863,11 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
28632863 ) ;
28642864 let mut filtered_chain_segment = match filtered_chain_segment_future. await {
28652865 Ok ( Ok ( filtered_segment) ) => filtered_segment,
2866- Ok ( Err ( segment_result) ) => return segment_result,
2866+ Ok ( Err ( segment_result) ) => return * segment_result,
28672867 Err ( error) => {
28682868 return ChainSegmentResult :: Failed {
28692869 imported_blocks,
2870- error : BlockError :: BeaconChainError ( error) ,
2870+ error : BlockError :: BeaconChainError ( error. into ( ) ) ,
28712871 }
28722872 }
28732873 } ;
@@ -2906,7 +2906,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
29062906 Err ( error) => {
29072907 return ChainSegmentResult :: Failed {
29082908 imported_blocks,
2909- error : BlockError :: BeaconChainError ( error) ,
2909+ error : BlockError :: BeaconChainError ( error. into ( ) ) ,
29102910 } ;
29112911 }
29122912 } ;
@@ -3444,20 +3444,23 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
34443444
34453445 Ok ( status)
34463446 }
3447- Err ( e @ BlockError :: BeaconChainError ( BeaconChainError :: TokioJoin ( _) ) ) => {
3448- debug ! (
3449- error = ?e,
3450- "Beacon block processing cancelled"
3451- ) ;
3452- Err ( e)
3453- }
3454- // There was an error whilst attempting to verify and import the block. The block might
3455- // be partially verified or partially imported.
34563447 Err ( BlockError :: BeaconChainError ( e) ) => {
3457- crit ! (
3458- error = ?e,
3459- "Beacon block processing error"
3460- ) ;
3448+ match e. as_ref ( ) {
3449+ BeaconChainError :: TokioJoin ( e) => {
3450+ debug ! (
3451+ error = ?e,
3452+ "Beacon block processing cancelled"
3453+ ) ;
3454+ }
3455+ _ => {
3456+ // There was an error whilst attempting to verify and import the block. The block might
3457+ // be partially verified or partially imported.
3458+ crit ! (
3459+ error = ?e,
3460+ "Beacon block processing error"
3461+ ) ;
3462+ }
3463+ } ;
34613464 Err ( BlockError :: BeaconChainError ( e) )
34623465 }
34633466 // The block failed verification.
@@ -3589,7 +3592,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
35893592 header. message . proposer_index ,
35903593 block_root,
35913594 )
3592- . map_err ( |e| BlockError :: BeaconChainError ( e. into ( ) ) ) ?;
3595+ . map_err ( |e| BlockError :: BeaconChainError ( Box :: new ( e. into ( ) ) ) ) ?;
35933596 if let Some ( slasher) = self . slasher . as_ref ( ) {
35943597 slasher. accept_block_header ( header) ;
35953598 }
@@ -3674,7 +3677,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
36743677 header. message . proposer_index ,
36753678 block_root,
36763679 )
3677- . map_err ( |e| BlockError :: BeaconChainError ( e. into ( ) ) ) ?;
3680+ . map_err ( |e| BlockError :: BeaconChainError ( Box :: new ( e. into ( ) ) ) ) ?;
36783681 if let Some ( slasher) = self . slasher . as_ref ( ) {
36793682 slasher. accept_block_header ( header. clone ( ) ) ;
36803683 }
@@ -3857,7 +3860,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
38573860 payload_verification_status,
38583861 & self . spec ,
38593862 )
3860- . map_err ( |e| BlockError :: BeaconChainError ( e. into ( ) ) ) ?;
3863+ . map_err ( |e| BlockError :: BeaconChainError ( Box :: new ( e. into ( ) ) ) ) ?;
38613864 }
38623865
38633866 // If the block is recent enough and it was not optimistically imported, check to see if it
@@ -4070,7 +4073,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
40704073 warning = "The database is likely corrupt now, consider --purge-db" ,
40714074 "No stored fork choice found to restore from"
40724075 ) ;
4073- Err ( BlockError :: BeaconChainError ( e ) )
4076+ Err ( BlockError :: BeaconChainError ( Box :: new ( e ) ) )
40744077 } else {
40754078 Ok ( ( ) )
40764079 }
@@ -4125,9 +4128,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
41254128 Provided block root is not a checkpoint.",
41264129 ) )
41274130 . map_err ( |err| {
4128- BlockError :: BeaconChainError (
4131+ BlockError :: BeaconChainError ( Box :: new (
41294132 BeaconChainError :: WeakSubjectivtyShutdownError ( err) ,
4130- )
4133+ ) )
41314134 } ) ?;
41324135 return Err ( BlockError :: WeakSubjectivityConflict ) ;
41334136 }
@@ -4901,7 +4904,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
49014904 canonical_forkchoice_params : ForkchoiceUpdateParameters ,
49024905 ) -> Result < ForkchoiceUpdateParameters , Error > {
49034906 self . overridden_forkchoice_update_params_or_failure_reason ( & canonical_forkchoice_params)
4904- . or_else ( |e| match e {
4907+ . or_else ( |e| match * e {
49054908 ProposerHeadError :: DoNotReOrg ( reason) => {
49064909 trace ! (
49074910 %reason,
@@ -4916,19 +4919,19 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
49164919 pub fn overridden_forkchoice_update_params_or_failure_reason (
49174920 & self ,
49184921 canonical_forkchoice_params : & ForkchoiceUpdateParameters ,
4919- ) -> Result < ForkchoiceUpdateParameters , ProposerHeadError < Error > > {
4922+ ) -> Result < ForkchoiceUpdateParameters , Box < ProposerHeadError < Error > > > {
49204923 let _timer = metrics:: start_timer ( & metrics:: FORK_CHOICE_OVERRIDE_FCU_TIMES ) ;
49214924
49224925 // Never override if proposer re-orgs are disabled.
49234926 let re_org_head_threshold = self
49244927 . config
49254928 . re_org_head_threshold
4926- . ok_or ( DoNotReOrg :: ReOrgsDisabled ) ?;
4929+ . ok_or ( Box :: new ( DoNotReOrg :: ReOrgsDisabled . into ( ) ) ) ?;
49274930
49284931 let re_org_parent_threshold = self
49294932 . config
49304933 . re_org_parent_threshold
4931- . ok_or ( DoNotReOrg :: ReOrgsDisabled ) ?;
4934+ . ok_or ( Box :: new ( DoNotReOrg :: ReOrgsDisabled . into ( ) ) ) ?;
49324935
49334936 let head_block_root = canonical_forkchoice_params. head_root ;
49344937
@@ -4969,7 +4972,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
49694972 false
49704973 } ;
49714974 if !current_slot_ok {
4972- return Err ( DoNotReOrg :: HeadDistance . into ( ) ) ;
4975+ return Err ( Box :: new ( DoNotReOrg :: HeadDistance . into ( ) ) ) ;
49734976 }
49744977
49754978 // Only attempt a re-org if we have a proposer registered for the re-org slot.
@@ -4992,7 +4995,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
49924995 decision_root = ?shuffling_decision_root,
49934996 "Fork choice override proposer shuffling miss"
49944997 ) ;
4995- DoNotReOrg :: NotProposing
4998+ Box :: new ( DoNotReOrg :: NotProposing . into ( ) )
49964999 } ) ?
49975000 . index as u64 ;
49985001
@@ -5002,7 +5005,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
50025005 . has_proposer_preparation_data_blocking ( proposer_index)
50035006 } ;
50045007 if !proposing_at_re_org_slot {
5005- return Err ( DoNotReOrg :: NotProposing . into ( ) ) ;
5008+ return Err ( Box :: new ( DoNotReOrg :: NotProposing . into ( ) ) ) ;
50065009 }
50075010
50085011 // If the current slot is already equal to the proposal slot (or we are in the tail end of
@@ -5017,18 +5020,22 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
50175020 ( true , true )
50185021 } ;
50195022 if !head_weak {
5020- return Err ( DoNotReOrg :: HeadNotWeak {
5021- head_weight : info. head_node . weight ,
5022- re_org_head_weight_threshold : info. re_org_head_weight_threshold ,
5023- }
5024- . into ( ) ) ;
5023+ return Err ( Box :: new (
5024+ DoNotReOrg :: HeadNotWeak {
5025+ head_weight : info. head_node . weight ,
5026+ re_org_head_weight_threshold : info. re_org_head_weight_threshold ,
5027+ }
5028+ . into ( ) ,
5029+ ) ) ;
50255030 }
50265031 if !parent_strong {
5027- return Err ( DoNotReOrg :: ParentNotStrong {
5028- parent_weight : info. parent_node . weight ,
5029- re_org_parent_weight_threshold : info. re_org_parent_weight_threshold ,
5030- }
5031- . into ( ) ) ;
5032+ return Err ( Box :: new (
5033+ DoNotReOrg :: ParentNotStrong {
5034+ parent_weight : info. parent_node . weight ,
5035+ re_org_parent_weight_threshold : info. re_org_parent_weight_threshold ,
5036+ }
5037+ . into ( ) ,
5038+ ) ) ;
50325039 }
50335040
50345041 // Check that the head block arrived late and is vulnerable to a re-org. This check is only
@@ -5039,7 +5046,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
50395046 let head_block_late =
50405047 self . block_observed_after_attestation_deadline ( head_block_root, head_slot) ;
50415048 if !head_block_late {
5042- return Err ( DoNotReOrg :: HeadNotLate . into ( ) ) ;
5049+ return Err ( Box :: new ( DoNotReOrg :: HeadNotLate . into ( ) ) ) ;
50435050 }
50445051
50455052 let parent_head_hash = info. parent_node . execution_status . block_hash ( ) ;
@@ -5253,16 +5260,16 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
52535260 . validators ( )
52545261 . get ( proposer_index as usize )
52555262 . map ( |v| v. pubkey )
5256- . ok_or ( BlockProductionError :: BeaconChain (
5263+ . ok_or ( BlockProductionError :: BeaconChain ( Box :: new (
52575264 BeaconChainError :: ValidatorIndexUnknown ( proposer_index as usize ) ,
5258- ) ) ?;
5265+ ) ) ) ?;
52595266
52605267 let builder_params = BuilderParams {
52615268 pubkey,
52625269 slot : state. slot ( ) ,
52635270 chain_health : self
52645271 . is_healthy ( & parent_root)
5265- . map_err ( BlockProductionError :: BeaconChain ) ?,
5272+ . map_err ( |e| BlockProductionError :: BeaconChain ( Box :: new ( e ) ) ) ?,
52665273 } ;
52675274
52685275 // If required, start the process of loading an execution payload from the EL early. This
0 commit comments