@@ -4263,7 +4263,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
42634263 head_slot : Slot ,
42644264 canonical_head : Hash256 ,
42654265 ) -> Option < BlockProductionPreState < T :: EthSpec > > {
4266- let re_org_threshold = self . config . re_org_threshold ?;
4266+ let re_org_head_threshold = self . config . re_org_head_threshold ?;
4267+ let re_org_parent_threshold = self . config . re_org_parent_threshold ?;
42674268
42684269 if self . spec . proposer_score_boost . is_none ( ) {
42694270 warn ! (
@@ -4320,7 +4321,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
43204321 . get_proposer_head (
43214322 slot,
43224323 canonical_head,
4323- re_org_threshold,
4324+ re_org_head_threshold,
4325+ re_org_parent_threshold,
43244326 & self . config . re_org_disallowed_offsets ,
43254327 self . config . re_org_max_epochs_since_finalization ,
43264328 )
@@ -4374,7 +4376,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
43744376 "weak_head" => ?canonical_head,
43754377 "parent" => ?re_org_parent_block,
43764378 "head_weight" => proposer_head. head_node. weight,
4377- "threshold_weight" => proposer_head. re_org_weight_threshold
4379+ "threshold_weight" => proposer_head. re_org_head_weight_threshold
43784380 ) ;
43794381
43804382 Some ( pre_state)
@@ -4594,9 +4596,14 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
45944596 let _timer = metrics:: start_timer ( & metrics:: FORK_CHOICE_OVERRIDE_FCU_TIMES ) ;
45954597
45964598 // Never override if proposer re-orgs are disabled.
4597- let re_org_threshold = self
4599+ let re_org_head_threshold = self
45984600 . config
4599- . re_org_threshold
4601+ . re_org_head_threshold
4602+ . ok_or ( DoNotReOrg :: ReOrgsDisabled ) ?;
4603+
4604+ let re_org_parent_threshold = self
4605+ . config
4606+ . re_org_parent_threshold
46004607 . ok_or ( DoNotReOrg :: ReOrgsDisabled ) ?;
46014608
46024609 let head_block_root = canonical_forkchoice_params. head_root ;
@@ -4607,7 +4614,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
46074614 . fork_choice_read_lock ( )
46084615 . get_preliminary_proposer_head (
46094616 head_block_root,
4610- re_org_threshold,
4617+ re_org_head_threshold,
4618+ re_org_parent_threshold,
46114619 & self . config . re_org_disallowed_offsets ,
46124620 self . config . re_org_max_epochs_since_finalization ,
46134621 )
@@ -4675,16 +4683,27 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
46754683 }
46764684
46774685 // If the current slot is already equal to the proposal slot (or we are in the tail end of
4678- // the prior slot), then check the actual weight of the head against the re-org threshold.
4679- let head_weak = if fork_choice_slot == re_org_block_slot {
4680- info. head_node . weight < info. re_org_weight_threshold
4686+ // the prior slot), then check the actual weight of the head against the head re-org threshold
4687+ // and the actual weight of the parent against the parent re-org threshold.
4688+ let ( head_weak, parent_strong) = if fork_choice_slot == re_org_block_slot {
4689+ (
4690+ info. head_node . weight < info. re_org_head_weight_threshold ,
4691+ info. parent_node . weight > info. re_org_parent_weight_threshold ,
4692+ )
46814693 } else {
4682- true
4694+ ( true , true )
46834695 } ;
46844696 if !head_weak {
46854697 return Err ( DoNotReOrg :: HeadNotWeak {
46864698 head_weight : info. head_node . weight ,
4687- re_org_weight_threshold : info. re_org_weight_threshold ,
4699+ re_org_head_weight_threshold : info. re_org_head_weight_threshold ,
4700+ }
4701+ . into ( ) ) ;
4702+ }
4703+ if !parent_strong {
4704+ return Err ( DoNotReOrg :: ParentNotStrong {
4705+ parent_weight : info. parent_node . weight ,
4706+ re_org_parent_weight_threshold : info. re_org_parent_weight_threshold ,
46884707 }
46894708 . into ( ) ) ;
46904709 }
0 commit comments