Deprecate some reorg-related CLI flags and read from spec (#9177)

- #9123


  


Co-Authored-By: Tan Chee Keong <tanck@sigmaprime.io>

Co-Authored-By: chonghe <44791194+chong-he@users.noreply.github.com>
This commit is contained in:
chonghe
2026-05-25 10:11:27 +08:00
committed by GitHub
parent b5d44bff36
commit 9b961960c4
16 changed files with 141 additions and 253 deletions

View File

@@ -701,11 +701,9 @@ impl ProtoArray {
justified_balances: &JustifiedBalances,
spec: &ChainSpec,
) -> bool {
let reorg_threshold = calculate_committee_fraction::<E>(
justified_balances,
spec.reorg_head_weight_threshold.unwrap_or(20),
)
.unwrap_or(0);
let reorg_threshold =
calculate_committee_fraction::<E>(justified_balances, spec.reorg_head_weight_threshold)
.unwrap_or(0);
let head_weight = head_node
.attestation_score(PayloadStatus::Pending)

View File

@@ -152,9 +152,9 @@ pub struct ChainSpec {
* Fork choice
*/
pub proposer_score_boost: Option<u64>,
pub reorg_head_weight_threshold: Option<u64>,
pub reorg_parent_weight_threshold: Option<u64>,
pub reorg_max_epochs_since_finalization: Option<u64>,
pub reorg_head_weight_threshold: u64,
pub reorg_parent_weight_threshold: u64,
pub reorg_max_epochs_since_finalization: u64,
/*
* Eth1
@@ -925,7 +925,7 @@ impl ChainSpec {
}
/// Calculate the duration into a slot for a given slot component
fn compute_slot_component_duration(
pub fn compute_slot_component_duration(
&self,
component_basis_points: u64,
) -> Result<Duration, ArithError> {
@@ -1163,9 +1163,9 @@ impl ChainSpec {
* Fork choice
*/
proposer_score_boost: Some(40),
reorg_head_weight_threshold: Some(20),
reorg_parent_weight_threshold: Some(160),
reorg_max_epochs_since_finalization: Some(2),
reorg_head_weight_threshold: 20,
reorg_parent_weight_threshold: 160,
reorg_max_epochs_since_finalization: 2,
/*
* Eth1
@@ -1588,9 +1588,9 @@ impl ChainSpec {
* Fork choice
*/
proposer_score_boost: Some(40),
reorg_head_weight_threshold: Some(20),
reorg_parent_weight_threshold: Some(160),
reorg_max_epochs_since_finalization: Some(2),
reorg_head_weight_threshold: 20,
reorg_parent_weight_threshold: 160,
reorg_max_epochs_since_finalization: 2,
/*
* Eth1
@@ -2028,12 +2028,15 @@ pub struct Config {
#[serde(skip_serializing_if = "Option::is_none")]
proposer_score_boost: Option<MaybeQuoted<u64>>,
#[serde(skip_serializing_if = "Option::is_none")]
reorg_head_weight_threshold: Option<MaybeQuoted<u64>>,
#[serde(skip_serializing_if = "Option::is_none")]
reorg_parent_weight_threshold: Option<MaybeQuoted<u64>>,
#[serde(skip_serializing_if = "Option::is_none")]
reorg_max_epochs_since_finalization: Option<MaybeQuoted<u64>>,
#[serde(default = "default_reorg_head_weight_threshold")]
#[serde(with = "serde_utils::quoted_u64")]
reorg_head_weight_threshold: u64,
#[serde(default = "default_reorg_parent_weight_threshold")]
#[serde(with = "serde_utils::quoted_u64")]
reorg_parent_weight_threshold: u64,
#[serde(default = "default_reorg_max_epochs_since_finalization")]
#[serde(with = "serde_utils::quoted_u64")]
reorg_max_epochs_since_finalization: u64,
#[serde(with = "serde_utils::quoted_u64")]
deposit_chain_id: u64,
@@ -2433,6 +2436,18 @@ const fn default_max_per_epoch_activation_churn_limit_gloas() -> u64 {
256_000_000_000
}
const fn default_reorg_head_weight_threshold() -> u64 {
20
}
const fn default_reorg_parent_weight_threshold() -> u64 {
160
}
const fn default_reorg_max_epochs_since_finalization() -> u64 {
2
}
fn max_blocks_by_root_request_common(max_request_blocks: u64) -> usize {
let max_request_blocks = max_request_blocks as usize;
RuntimeVariableList::<Hash256>::new(
@@ -2626,15 +2641,9 @@ impl Config {
max_per_epoch_activation_churn_limit: spec.max_per_epoch_activation_churn_limit,
proposer_score_boost: spec.proposer_score_boost.map(|value| MaybeQuoted { value }),
reorg_head_weight_threshold: spec
.reorg_head_weight_threshold
.map(|value| MaybeQuoted { value }),
reorg_parent_weight_threshold: spec
.reorg_parent_weight_threshold
.map(|value| MaybeQuoted { value }),
reorg_max_epochs_since_finalization: spec
.reorg_max_epochs_since_finalization
.map(|value| MaybeQuoted { value }),
reorg_head_weight_threshold: spec.reorg_head_weight_threshold,
reorg_parent_weight_threshold: spec.reorg_parent_weight_threshold,
reorg_max_epochs_since_finalization: spec.reorg_max_epochs_since_finalization,
deposit_chain_id: spec.deposit_chain_id,
deposit_network_id: spec.deposit_network_id,
@@ -2846,10 +2855,9 @@ impl Config {
max_per_epoch_activation_churn_limit,
churn_limit_quotient,
proposer_score_boost: proposer_score_boost.map(|q| q.value),
reorg_head_weight_threshold: reorg_head_weight_threshold.map(|q| q.value),
reorg_parent_weight_threshold: reorg_parent_weight_threshold.map(|q| q.value),
reorg_max_epochs_since_finalization: reorg_max_epochs_since_finalization
.map(|q| q.value),
reorg_head_weight_threshold,
reorg_parent_weight_threshold,
reorg_max_epochs_since_finalization,
deposit_chain_id,
deposit_network_id,
deposit_contract_address,