@@ -4262,7 +4262,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
42624262 head_slot : Slot ,
42634263 canonical_head : Hash256 ,
42644264 ) -> Option < BlockProductionPreState < T :: EthSpec > > {
4265- let re_org_threshold = self . config . re_org_threshold ?;
4265+ let re_org_head_threshold = self . config . re_org_head_threshold ?;
4266+ let re_org_parent_threshold = self . config . re_org_parent_threshold ?;
42664267
42674268 if self . spec . proposer_score_boost . is_none ( ) {
42684269 warn ! (
@@ -4319,7 +4320,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
43194320 . get_proposer_head (
43204321 slot,
43214322 canonical_head,
4322- re_org_threshold,
4323+ re_org_head_threshold,
4324+ re_org_parent_threshold,
43234325 & self . config . re_org_disallowed_offsets ,
43244326 self . config . re_org_max_epochs_since_finalization ,
43254327 )
@@ -4373,7 +4375,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
43734375 "weak_head" => ?canonical_head,
43744376 "parent" => ?re_org_parent_block,
43754377 "head_weight" => proposer_head. head_node. weight,
4376- "threshold_weight" => proposer_head. re_org_weight_threshold
4378+ "threshold_weight" => proposer_head. re_org_head_weight_threshold
43774379 ) ;
43784380
43794381 Some ( pre_state)
@@ -4593,9 +4595,14 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
45934595 let _timer = metrics:: start_timer ( & metrics:: FORK_CHOICE_OVERRIDE_FCU_TIMES ) ;
45944596
45954597 // Never override if proposer re-orgs are disabled.
4596- let re_org_threshold = self
4598+ let re_org_head_threshold = self
45974599 . config
4598- . re_org_threshold
4600+ . re_org_head_threshold
4601+ . ok_or ( DoNotReOrg :: ReOrgsDisabled ) ?;
4602+
4603+ let re_org_parent_threshold = self
4604+ . config
4605+ . re_org_parent_threshold
45994606 . ok_or ( DoNotReOrg :: ReOrgsDisabled ) ?;
46004607
46014608 let head_block_root = canonical_forkchoice_params. head_root ;
@@ -4606,7 +4613,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
46064613 . fork_choice_read_lock ( )
46074614 . get_preliminary_proposer_head (
46084615 head_block_root,
4609- re_org_threshold,
4616+ re_org_head_threshold,
4617+ re_org_parent_threshold,
46104618 & self . config . re_org_disallowed_offsets ,
46114619 self . config . re_org_max_epochs_since_finalization ,
46124620 )
@@ -4674,16 +4682,27 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
46744682 }
46754683
46764684 // If the current slot is already equal to the proposal slot (or we are in the tail end of
4677- // the prior slot), then check the actual weight of the head against the re-org threshold.
4678- let head_weak = if fork_choice_slot == re_org_block_slot {
4679- info. head_node . weight < info. re_org_weight_threshold
4685+ // the prior slot), then check the actual weight of the head against the head re-org threshold
4686+ // and the actual weight of the parent against the parent re-org threshold.
4687+ let ( head_weak, parent_strong) = if fork_choice_slot == re_org_block_slot {
4688+ (
4689+ info. head_node . weight < info. re_org_head_weight_threshold ,
4690+ info. parent_node . weight > info. re_org_parent_weight_threshold ,
4691+ )
46804692 } else {
4681- true
4693+ ( true , true )
46824694 } ;
46834695 if !head_weak {
46844696 return Err ( DoNotReOrg :: HeadNotWeak {
46854697 head_weight : info. head_node . weight ,
4686- re_org_weight_threshold : info. re_org_weight_threshold ,
4698+ re_org_head_weight_threshold : info. re_org_head_weight_threshold ,
4699+ }
4700+ . into ( ) ) ;
4701+ }
4702+ if !parent_strong {
4703+ return Err ( DoNotReOrg :: ParentNotStrong {
4704+ parent_weight : info. parent_node . weight ,
4705+ re_org_parent_weight_threshold : info. re_org_parent_weight_threshold ,
46874706 }
46884707 . into ( ) ) ;
46894708 }
0 commit comments