diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 4f8d3b7123c..421bc12ee43 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -4262,7 +4262,8 @@ impl BeaconChain { head_slot: Slot, canonical_head: Hash256, ) -> Option> { - let re_org_threshold = self.config.re_org_threshold?; + let re_org_head_threshold = self.config.re_org_head_threshold?; + let re_org_parent_threshold = self.config.re_org_parent_threshold?; if self.spec.proposer_score_boost.is_none() { warn!( @@ -4319,7 +4320,8 @@ impl BeaconChain { .get_proposer_head( slot, canonical_head, - re_org_threshold, + re_org_head_threshold, + re_org_parent_threshold, &self.config.re_org_disallowed_offsets, self.config.re_org_max_epochs_since_finalization, ) @@ -4373,7 +4375,7 @@ impl BeaconChain { "weak_head" => ?canonical_head, "parent" => ?re_org_parent_block, "head_weight" => proposer_head.head_node.weight, - "threshold_weight" => proposer_head.re_org_weight_threshold + "threshold_weight" => proposer_head.re_org_head_weight_threshold ); Some(pre_state) @@ -4593,9 +4595,14 @@ impl BeaconChain { let _timer = metrics::start_timer(&metrics::FORK_CHOICE_OVERRIDE_FCU_TIMES); // Never override if proposer re-orgs are disabled. - let re_org_threshold = self + let re_org_head_threshold = self .config - .re_org_threshold + .re_org_head_threshold + .ok_or(DoNotReOrg::ReOrgsDisabled)?; + + let re_org_parent_threshold = self + .config + .re_org_parent_threshold .ok_or(DoNotReOrg::ReOrgsDisabled)?; let head_block_root = canonical_forkchoice_params.head_root; @@ -4606,7 +4613,8 @@ impl BeaconChain { .fork_choice_read_lock() .get_preliminary_proposer_head( head_block_root, - re_org_threshold, + re_org_head_threshold, + re_org_parent_threshold, &self.config.re_org_disallowed_offsets, self.config.re_org_max_epochs_since_finalization, ) @@ -4674,16 +4682,27 @@ impl BeaconChain { } // If the current slot is already equal to the proposal slot (or we are in the tail end of - // the prior slot), then check the actual weight of the head against the re-org threshold. - let head_weak = if fork_choice_slot == re_org_block_slot { - info.head_node.weight < info.re_org_weight_threshold + // the prior slot), then check the actual weight of the head against the head re-org threshold + // and the actual weight of the parent against the parent re-org threshold. + let (head_weak, parent_strong) = if fork_choice_slot == re_org_block_slot { + ( + info.head_node.weight < info.re_org_head_weight_threshold, + info.parent_node.weight > info.re_org_parent_weight_threshold, + ) } else { - true + (true, true) }; if !head_weak { return Err(DoNotReOrg::HeadNotWeak { head_weight: info.head_node.weight, - re_org_weight_threshold: info.re_org_weight_threshold, + re_org_head_weight_threshold: info.re_org_head_weight_threshold, + } + .into()); + } + if !parent_strong { + return Err(DoNotReOrg::ParentNotStrong { + parent_weight: info.parent_node.weight, + re_org_parent_weight_threshold: info.re_org_parent_weight_threshold, } .into()); } diff --git a/beacon_node/beacon_chain/src/builder.rs b/beacon_node/beacon_chain/src/builder.rs index 637734bce33..c1ebeb68bba 100644 --- a/beacon_node/beacon_chain/src/builder.rs +++ b/beacon_node/beacon_chain/src/builder.rs @@ -172,8 +172,8 @@ where } /// Sets the proposer re-org threshold. - pub fn proposer_re_org_threshold(mut self, threshold: Option) -> Self { - self.chain_config.re_org_threshold = threshold; + pub fn proposer_re_org_head_threshold(mut self, threshold: Option) -> Self { + self.chain_config.re_org_head_threshold = threshold; self } diff --git a/beacon_node/beacon_chain/src/chain_config.rs b/beacon_node/beacon_chain/src/chain_config.rs index 12b3d372993..0772aff6710 100644 --- a/beacon_node/beacon_chain/src/chain_config.rs +++ b/beacon_node/beacon_chain/src/chain_config.rs @@ -3,7 +3,8 @@ use serde::{Deserialize, Serialize}; use std::time::Duration; use types::{Checkpoint, Epoch}; -pub const DEFAULT_RE_ORG_THRESHOLD: ReOrgThreshold = ReOrgThreshold(20); +pub const DEFAULT_RE_ORG_HEAD_THRESHOLD: ReOrgThreshold = ReOrgThreshold(20); +pub const DEFAULT_RE_ORG_PARENT_THRESHOLD: ReOrgThreshold = ReOrgThreshold(160); pub const DEFAULT_RE_ORG_MAX_EPOCHS_SINCE_FINALIZATION: Epoch = Epoch::new(2); /// Default to 1/12th of the slot, which is 1 second on mainnet. pub const DEFAULT_RE_ORG_CUTOFF_DENOMINATOR: u32 = 12; @@ -31,8 +32,10 @@ pub struct ChainConfig { pub enable_lock_timeouts: bool, /// The max size of a message that can be sent over the network. pub max_network_size: usize, - /// Maximum percentage of committee weight at which to attempt re-orging the canonical head. - pub re_org_threshold: Option, + /// Maximum percentage of the head committee weight at which to attempt re-orging the canonical head. + pub re_org_head_threshold: Option, + /// Minimum percentage of the parent committee weight at which to attempt re-orging the canonical head. + pub re_org_parent_threshold: Option, /// Maximum number of epochs since finalization for attempting a proposer re-org. pub re_org_max_epochs_since_finalization: Epoch, /// Maximum delay after the start of the slot at which to propose a reorging block. @@ -95,7 +98,8 @@ impl Default for ChainConfig { reconstruct_historic_states: false, enable_lock_timeouts: true, max_network_size: 10 * 1_048_576, // 10M - re_org_threshold: Some(DEFAULT_RE_ORG_THRESHOLD), + re_org_head_threshold: Some(DEFAULT_RE_ORG_HEAD_THRESHOLD), + re_org_parent_threshold: Some(DEFAULT_RE_ORG_PARENT_THRESHOLD), re_org_max_epochs_since_finalization: DEFAULT_RE_ORG_MAX_EPOCHS_SINCE_FINALIZATION, re_org_cutoff_millis: None, re_org_disallowed_offsets: DisallowedReOrgOffsets::default(), diff --git a/beacon_node/http_api/tests/interactive_tests.rs b/beacon_node/http_api/tests/interactive_tests.rs index d63d04fcec5..529dc852e98 100644 --- a/beacon_node/http_api/tests/interactive_tests.rs +++ b/beacon_node/http_api/tests/interactive_tests.rs @@ -419,7 +419,7 @@ pub async fn proposer_boost_re_org_test( None, Some(Box::new(move |builder| { builder - .proposer_re_org_threshold(Some(ReOrgThreshold(re_org_threshold))) + .proposer_re_org_head_threshold(Some(ReOrgThreshold(re_org_threshold))) .proposer_re_org_max_epochs_since_finalization(Epoch::new( max_epochs_since_finalization, )) diff --git a/beacon_node/src/cli.rs b/beacon_node/src/cli.rs index 7fae66d6d2c..d46eb0f403e 100644 --- a/beacon_node/src/cli.rs +++ b/beacon_node/src/cli.rs @@ -1040,10 +1040,18 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { Arg::with_name("proposer-reorg-threshold") .long("proposer-reorg-threshold") .value_name("PERCENT") - .help("Percentage of vote weight below which to attempt a proposer reorg. \ + .help("Percentage of head vote weight below which to attempt a proposer reorg. \ Default: 20%") .conflicts_with("disable-proposer-reorgs") ) + .arg( + Arg::with_name("proposer-reorg-parent-threshold") + .long("proposer-reorg-parent-threshold") + .value_name("PERCENT") + .help("Percentage of parent vote weight above which to attempt a proposer reorg. \ + Default: 160%") + .conflicts_with("disable-proposer-reorgs") + ) .arg( Arg::with_name("proposer-reorg-epochs-since-finalization") .long("proposer-reorg-epochs-since-finalization") diff --git a/beacon_node/src/config.rs b/beacon_node/src/config.rs index 14cb3945a79..9b0032e3068 100644 --- a/beacon_node/src/config.rs +++ b/beacon_node/src/config.rs @@ -1,6 +1,7 @@ use beacon_chain::chain_config::{ DisallowedReOrgOffsets, ReOrgThreshold, DEFAULT_PREPARE_PAYLOAD_LOOKAHEAD_FACTOR, - DEFAULT_RE_ORG_MAX_EPOCHS_SINCE_FINALIZATION, DEFAULT_RE_ORG_THRESHOLD, + DEFAULT_RE_ORG_HEAD_THRESHOLD, DEFAULT_RE_ORG_MAX_EPOCHS_SINCE_FINALIZATION, + DEFAULT_RE_ORG_PARENT_THRESHOLD, }; use beacon_chain::TrustedSetup; use clap::ArgMatches; @@ -749,12 +750,13 @@ pub fn get_config( } if cli_args.is_present("disable-proposer-reorgs") { - client_config.chain.re_org_threshold = None; + client_config.chain.re_org_head_threshold = None; + client_config.chain.re_org_parent_threshold = None; } else { - client_config.chain.re_org_threshold = Some( + client_config.chain.re_org_head_threshold = Some( clap_utils::parse_optional(cli_args, "proposer-reorg-threshold")? .map(ReOrgThreshold) - .unwrap_or(DEFAULT_RE_ORG_THRESHOLD), + .unwrap_or(DEFAULT_RE_ORG_HEAD_THRESHOLD), ); client_config.chain.re_org_max_epochs_since_finalization = clap_utils::parse_optional(cli_args, "proposer-reorg-epochs-since-finalization")? @@ -762,6 +764,12 @@ pub fn get_config( client_config.chain.re_org_cutoff_millis = clap_utils::parse_optional(cli_args, "proposer-reorg-cutoff")?; + client_config.chain.re_org_parent_threshold = Some( + clap_utils::parse_optional(cli_args, "proposer-reorg-parent-threshold")? + .map(ReOrgThreshold) + .unwrap_or(DEFAULT_RE_ORG_PARENT_THRESHOLD), + ); + if let Some(disallowed_offsets_str) = clap_utils::parse_optional::(cli_args, "proposer-reorg-disallowed-offsets")? { diff --git a/book/src/help_bn.md b/book/src/help_bn.md index 92cef3b473b..996642f0fc7 100644 --- a/book/src/help_bn.md +++ b/book/src/help_bn.md @@ -383,8 +383,11 @@ OPTIONS: --proposer-reorg-epochs-since-finalization Maximum number of epochs since finalization at which proposer reorgs are allowed. Default: 2 + --proposer-reorg-parent-threshold + Percentage of parent vote weight above which to attempt a proposer reorg. Default: 160% + --proposer-reorg-threshold - Percentage of vote weight below which to attempt a proposer reorg. Default: 20% + Percentage of head vote weight below which to attempt a proposer reorg. Default: 20% --prune-blobs Prune blobs from Lighthouse's database when they are older than the data data availability boundary relative diff --git a/common/eth2_network_config/built_in_network_configs/gnosis/config.yaml b/common/eth2_network_config/built_in_network_configs/gnosis/config.yaml index 7558b482506..27fb81a5139 100644 --- a/common/eth2_network_config/built_in_network_configs/gnosis/config.yaml +++ b/common/eth2_network_config/built_in_network_configs/gnosis/config.yaml @@ -81,6 +81,12 @@ CHURN_LIMIT_QUOTIENT: 4096 # --------------------------------------------------------------- # 40% PROPOSER_SCORE_BOOST: 40 +# 20% +REORG_HEAD_WEIGHT_THRESHOLD: 20 +# 160% +REORG_PARENT_WEIGHT_THRESHOLD: 160 +# `2` epochs +REORG_MAX_EPOCHS_SINCE_FINALIZATION: 2 # Deposit contract # --------------------------------------------------------------- diff --git a/common/eth2_network_config/built_in_network_configs/holesky/config.yaml b/common/eth2_network_config/built_in_network_configs/holesky/config.yaml index 947924a7d16..bd384cfe497 100644 --- a/common/eth2_network_config/built_in_network_configs/holesky/config.yaml +++ b/common/eth2_network_config/built_in_network_configs/holesky/config.yaml @@ -71,6 +71,12 @@ MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT: 8 # --------------------------------------------------------------- # 40% PROPOSER_SCORE_BOOST: 40 +# 20% +REORG_HEAD_WEIGHT_THRESHOLD: 20 +# 160% +REORG_PARENT_WEIGHT_THRESHOLD: 160 +# `2` epochs +REORG_MAX_EPOCHS_SINCE_FINALIZATION: 2 # Deposit contract # --------------------------------------------------------------- diff --git a/common/eth2_network_config/built_in_network_configs/prater/config.yaml b/common/eth2_network_config/built_in_network_configs/prater/config.yaml index ac94b638666..f474b172c51 100644 --- a/common/eth2_network_config/built_in_network_configs/prater/config.yaml +++ b/common/eth2_network_config/built_in_network_configs/prater/config.yaml @@ -78,6 +78,12 @@ MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT: 8 # --------------------------------------------------------------- # 40% PROPOSER_SCORE_BOOST: 40 +# 20% +REORG_HEAD_WEIGHT_THRESHOLD: 20 +# 160% +REORG_PARENT_WEIGHT_THRESHOLD: 160 +# `2` epochs +REORG_MAX_EPOCHS_SINCE_FINALIZATION: 2 # Deposit contract # --------------------------------------------------------------- diff --git a/common/eth2_network_config/built_in_network_configs/sepolia/config.yaml b/common/eth2_network_config/built_in_network_configs/sepolia/config.yaml index 89b51ba7686..2df40798c11 100644 --- a/common/eth2_network_config/built_in_network_configs/sepolia/config.yaml +++ b/common/eth2_network_config/built_in_network_configs/sepolia/config.yaml @@ -69,6 +69,10 @@ MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT: 8 # --------------------------------------------------------------- # 40% PROPOSER_SCORE_BOOST: 40 +# 20% +REORG_HEAD_WEIGHT_THRESHOLD: 20 +# 160% +REORG_PARENT_WEIGHT_THRESHOLD: 160 # Deposit contract # --------------------------------------------------------------- diff --git a/consensus/fork_choice/src/fork_choice.rs b/consensus/fork_choice/src/fork_choice.rs index 133741111a2..6e3f6717ede 100644 --- a/consensus/fork_choice/src/fork_choice.rs +++ b/consensus/fork_choice/src/fork_choice.rs @@ -517,7 +517,8 @@ where &self, current_slot: Slot, canonical_head: Hash256, - re_org_threshold: ReOrgThreshold, + re_org_head_threshold: ReOrgThreshold, + re_org_parent_threshold: ReOrgThreshold, disallowed_offsets: &DisallowedReOrgOffsets, max_epochs_since_finalization: Epoch, ) -> Result>> { @@ -549,7 +550,8 @@ where current_slot, canonical_head, self.fc_store.justified_balances(), - re_org_threshold, + re_org_head_threshold, + re_org_parent_threshold, disallowed_offsets, max_epochs_since_finalization, ) @@ -559,7 +561,8 @@ where pub fn get_preliminary_proposer_head( &self, canonical_head: Hash256, - re_org_threshold: ReOrgThreshold, + re_org_head_threshold: ReOrgThreshold, + re_org_parent_threshold: ReOrgThreshold, disallowed_offsets: &DisallowedReOrgOffsets, max_epochs_since_finalization: Epoch, ) -> Result>> { @@ -569,7 +572,8 @@ where current_slot, canonical_head, self.fc_store.justified_balances(), - re_org_threshold, + re_org_head_threshold, + re_org_parent_threshold, disallowed_offsets, max_epochs_since_finalization, ) @@ -706,6 +710,7 @@ where // Add proposer score boost if the block is timely. let is_before_attesting_interval = block_delay < Duration::from_secs(spec.seconds_per_slot / INTERVALS_PER_SLOT); + let is_first_block = self.fc_store.proposer_boost_root().is_zero(); if current_slot == block.slot() && is_before_attesting_interval && is_first_block { self.fc_store.set_proposer_boost_root(block_root); diff --git a/consensus/proto_array/src/proto_array_fork_choice.rs b/consensus/proto_array/src/proto_array_fork_choice.rs index cd29b481f10..e1faba369f3 100644 --- a/consensus/proto_array/src/proto_array_fork_choice.rs +++ b/consensus/proto_array/src/proto_array_fork_choice.rs @@ -195,8 +195,10 @@ pub struct ProposerHeadInfo { /// Information about the parent of the current head, which should be selected as the parent /// for a new proposal *if* a re-org is decided on. pub parent_node: ProtoNode, - /// The computed fraction of the active committee balance below which we can re-org. - pub re_org_weight_threshold: u64, + /// The computed fraction of the active head committee balance below which we can re-org. + pub re_org_head_weight_threshold: u64, + /// The computed fraction of the active parent committee balance above which we can re-org. + pub re_org_parent_weight_threshold: u64, /// The current slot from fork choice's point of view, may lead the wall-clock slot by upto /// 500ms. pub current_slot: Slot, @@ -259,7 +261,11 @@ pub enum DoNotReOrg { }, HeadNotWeak { head_weight: u64, - re_org_weight_threshold: u64, + re_org_head_weight_threshold: u64, + }, + ParentNotStrong { + parent_weight: u64, + re_org_parent_weight_threshold: u64, }, HeadNotLate, NotProposing, @@ -288,9 +294,21 @@ impl std::fmt::Display for DoNotReOrg { ), Self::HeadNotWeak { head_weight, - re_org_weight_threshold, + re_org_head_weight_threshold, } => { - write!(f, "head not weak ({head_weight}/{re_org_weight_threshold})") + write!( + f, + "head not weak ({head_weight}/{re_org_head_weight_threshold})" + ) + } + Self::ParentNotStrong { + parent_weight, + re_org_parent_weight_threshold, + } => { + write!( + f, + "parent not strong ({parent_weight}/{re_org_parent_weight_threshold})" + ) } Self::HeadNotLate => { write!(f, "head arrived on time") @@ -486,12 +504,14 @@ impl ProtoArrayForkChoice { /// Get the block to propose on during `current_slot`. /// /// This function returns a *definitive* result which should be acted on. + #[allow(clippy::too_many_arguments)] pub fn get_proposer_head( &self, current_slot: Slot, canonical_head: Hash256, justified_balances: &JustifiedBalances, - re_org_threshold: ReOrgThreshold, + re_org_head_threshold: ReOrgThreshold, + re_org_parent_threshold: ReOrgThreshold, disallowed_offsets: &DisallowedReOrgOffsets, max_epochs_since_finalization: Epoch, ) -> Result> { @@ -499,7 +519,8 @@ impl ProtoArrayForkChoice { current_slot, canonical_head, justified_balances, - re_org_threshold, + re_org_head_threshold, + re_org_parent_threshold, disallowed_offsets, max_epochs_since_finalization, )?; @@ -510,14 +531,26 @@ impl ProtoArrayForkChoice { return Err(DoNotReOrg::HeadDistance.into()); } - // Only re-org if the head's weight is less than the configured committee fraction. + // Only re-org if the head's weight is less than the heads configured committee fraction. let head_weight = info.head_node.weight; - let re_org_weight_threshold = info.re_org_weight_threshold; - let weak_head = head_weight < re_org_weight_threshold; + let re_org_head_weight_threshold = info.re_org_head_weight_threshold; + let weak_head = head_weight < re_org_head_weight_threshold; if !weak_head { return Err(DoNotReOrg::HeadNotWeak { head_weight, - re_org_weight_threshold, + re_org_head_weight_threshold, + } + .into()); + } + + // Only re-org if the parent's weight is greater than the parents configured committee fraction. + let parent_weight = info.parent_node.weight; + let re_org_parent_weight_threshold = info.re_org_parent_weight_threshold; + let parent_strong = parent_weight > re_org_parent_weight_threshold; + if !parent_strong { + return Err(DoNotReOrg::ParentNotStrong { + parent_weight, + re_org_parent_weight_threshold, } .into()); } @@ -529,12 +562,14 @@ impl ProtoArrayForkChoice { /// Get information about the block to propose on during `current_slot`. /// /// This function returns a *partial* result which must be processed further. + #[allow(clippy::too_many_arguments)] pub fn get_proposer_head_info( &self, current_slot: Slot, canonical_head: Hash256, justified_balances: &JustifiedBalances, - re_org_threshold: ReOrgThreshold, + re_org_head_threshold: ReOrgThreshold, + re_org_parent_threshold: ReOrgThreshold, disallowed_offsets: &DisallowedReOrgOffsets, max_epochs_since_finalization: Epoch, ) -> Result> { @@ -595,15 +630,20 @@ impl ProtoArrayForkChoice { return Err(DoNotReOrg::JustificationAndFinalizationNotCompetitive.into()); } - // Compute re-org weight threshold. - let re_org_weight_threshold = - calculate_committee_fraction::(justified_balances, re_org_threshold.0) + // Compute re-org weight thresholds for head and parent. + let re_org_head_weight_threshold = + calculate_committee_fraction::(justified_balances, re_org_head_threshold.0) + .ok_or(Error::ReOrgThresholdOverflow)?; + + let re_org_parent_weight_threshold = + calculate_committee_fraction::(justified_balances, re_org_parent_threshold.0) .ok_or(Error::ReOrgThresholdOverflow)?; Ok(ProposerHeadInfo { head_node, parent_node, - re_org_weight_threshold, + re_org_head_weight_threshold, + re_org_parent_weight_threshold, current_slot, }) } diff --git a/consensus/types/src/chain_spec.rs b/consensus/types/src/chain_spec.rs index c40c793e45a..988bd6755dc 100644 --- a/consensus/types/src/chain_spec.rs +++ b/consensus/types/src/chain_spec.rs @@ -114,6 +114,8 @@ pub struct ChainSpec { */ pub safe_slots_to_update_justified: u64, pub proposer_score_boost: Option, + pub reorg_head_weight_threshold: Option, + pub reorg_parent_weight_threshold: Option, /* * Eth1 @@ -642,6 +644,8 @@ impl ChainSpec { */ safe_slots_to_update_justified: 8, proposer_score_boost: Some(40), + reorg_head_weight_threshold: Some(20), + reorg_parent_weight_threshold: Some(160), /* * Eth1 @@ -912,6 +916,8 @@ impl ChainSpec { */ safe_slots_to_update_justified: 8, proposer_score_boost: Some(40), + reorg_head_weight_threshold: Some(20), + reorg_parent_weight_threshold: Some(160), /* * Eth1 diff --git a/lighthouse/tests/beacon_node.rs b/lighthouse/tests/beacon_node.rs index bd78b1c475e..68d8e46eb02 100644 --- a/lighthouse/tests/beacon_node.rs +++ b/lighthouse/tests/beacon_node.rs @@ -2,8 +2,8 @@ use beacon_node::ClientConfig as Config; use crate::exec::{CommandLineTestExec, CompletedTest}; use beacon_node::beacon_chain::chain_config::{ - DisallowedReOrgOffsets, DEFAULT_RE_ORG_CUTOFF_DENOMINATOR, - DEFAULT_RE_ORG_MAX_EPOCHS_SINCE_FINALIZATION, DEFAULT_RE_ORG_THRESHOLD, + DisallowedReOrgOffsets, DEFAULT_RE_ORG_CUTOFF_DENOMINATOR, DEFAULT_RE_ORG_HEAD_THRESHOLD, + DEFAULT_RE_ORG_MAX_EPOCHS_SINCE_FINALIZATION, }; use beacon_processor::BeaconProcessorConfig; use eth1::Eth1Endpoint; @@ -2200,8 +2200,8 @@ fn enable_proposer_re_orgs_default() { .run_with_zero_port() .with_config(|config| { assert_eq!( - config.chain.re_org_threshold, - Some(DEFAULT_RE_ORG_THRESHOLD) + config.chain.re_org_head_threshold, + Some(DEFAULT_RE_ORG_HEAD_THRESHOLD) ); assert_eq!( config.chain.re_org_max_epochs_since_finalization, @@ -2219,15 +2219,26 @@ fn disable_proposer_re_orgs() { CommandLineTest::new() .flag("disable-proposer-reorgs", None) .run_with_zero_port() - .with_config(|config| assert_eq!(config.chain.re_org_threshold, None)); + .with_config(|config| { + assert_eq!(config.chain.re_org_head_threshold, None); + assert_eq!(config.chain.re_org_parent_threshold, None) + }); +} + +#[test] +fn proposer_re_org_parent_threshold() { + CommandLineTest::new() + .flag("proposer-reorg-parent-threshold", Some("90")) + .run_with_zero_port() + .with_config(|config| assert_eq!(config.chain.re_org_parent_threshold.unwrap().0, 90)); } #[test] -fn proposer_re_org_threshold() { +fn proposer_re_org_head_threshold() { CommandLineTest::new() .flag("proposer-reorg-threshold", Some("90")) .run_with_zero_port() - .with_config(|config| assert_eq!(config.chain.re_org_threshold.unwrap().0, 90)); + .with_config(|config| assert_eq!(config.chain.re_org_head_threshold.unwrap().0, 90)); } #[test] diff --git a/testing/ef_tests/src/cases/fork_choice.rs b/testing/ef_tests/src/cases/fork_choice.rs index 467d71b8591..876d7e59d2f 100644 --- a/testing/ef_tests/src/cases/fork_choice.rs +++ b/testing/ef_tests/src/cases/fork_choice.rs @@ -4,7 +4,8 @@ use ::fork_choice::{PayloadVerificationStatus, ProposerHeadError}; use beacon_chain::beacon_proposer_cache::compute_proposer_duties_from_head; use beacon_chain::blob_verification::GossipBlobError; use beacon_chain::chain_config::{ - DisallowedReOrgOffsets, DEFAULT_RE_ORG_MAX_EPOCHS_SINCE_FINALIZATION, DEFAULT_RE_ORG_THRESHOLD, + DisallowedReOrgOffsets, DEFAULT_RE_ORG_HEAD_THRESHOLD, + DEFAULT_RE_ORG_MAX_EPOCHS_SINCE_FINALIZATION, DEFAULT_RE_ORG_PARENT_THRESHOLD, }; use beacon_chain::slot_clock::SlotClock; use beacon_chain::{ @@ -746,7 +747,8 @@ impl Tester { let proposer_head_result = fc.get_proposer_head( slot, canonical_head, - DEFAULT_RE_ORG_THRESHOLD, + DEFAULT_RE_ORG_HEAD_THRESHOLD, + DEFAULT_RE_ORG_PARENT_THRESHOLD, &DisallowedReOrgOffsets::default(), DEFAULT_RE_ORG_MAX_EPOCHS_SINCE_FINALIZATION, );