mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-01 20:04:41 +00:00
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:
@@ -1,15 +1,10 @@
|
||||
use crate::custody_context::NodeCustodyType;
|
||||
pub use proto_array::{DisallowedReOrgOffsets, ReOrgThreshold};
|
||||
pub use proto_array::DisallowedReOrgOffsets;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::str::FromStr;
|
||||
use std::{collections::HashSet, sync::LazyLock, time::Duration};
|
||||
use types::{Checkpoint, Epoch, Hash256};
|
||||
use types::{Checkpoint, Hash256};
|
||||
|
||||
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;
|
||||
pub const DEFAULT_FORK_CHOICE_BEFORE_PROPOSAL_TIMEOUT: u64 = 250;
|
||||
|
||||
/// Default fraction of a slot lookahead for payload preparation (12/3 = 4 seconds on mainnet).
|
||||
@@ -41,14 +36,6 @@ pub struct ChainConfig {
|
||||
pub archive: bool,
|
||||
/// The max size of a message that can be sent over the network.
|
||||
pub max_network_size: usize,
|
||||
/// Maximum percentage of the head committee weight at which to attempt re-orging the canonical head.
|
||||
pub re_org_head_threshold: Option<ReOrgThreshold>,
|
||||
/// Minimum percentage of the parent committee weight at which to attempt re-orging the canonical head.
|
||||
pub re_org_parent_threshold: Option<ReOrgThreshold>,
|
||||
/// 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.
|
||||
pub re_org_cutoff_millis: Option<u64>,
|
||||
/// Additional epoch offsets at which re-orging block proposals are not permitted.
|
||||
///
|
||||
/// By default this list is empty, but it can be useful for reacting to network conditions, e.g.
|
||||
@@ -125,6 +112,8 @@ pub struct ChainConfig {
|
||||
pub enable_partial_columns: bool,
|
||||
/// The node's custody type, determining how many data columns to custody and sample.
|
||||
pub node_custody_type: NodeCustodyType,
|
||||
/// Disable proposer re-org
|
||||
pub disable_proposer_reorg: bool,
|
||||
}
|
||||
|
||||
impl Default for ChainConfig {
|
||||
@@ -134,10 +123,6 @@ impl Default for ChainConfig {
|
||||
weak_subjectivity_checkpoint: None,
|
||||
archive: false,
|
||||
max_network_size: 10 * 1_048_576, // 10M
|
||||
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(),
|
||||
fork_choice_before_proposal_timeout_ms: DEFAULT_FORK_CHOICE_BEFORE_PROPOSAL_TIMEOUT,
|
||||
// Builder fallback configs that are set in `clap` will override these.
|
||||
@@ -168,15 +153,7 @@ impl Default for ChainConfig {
|
||||
disable_get_blobs: false,
|
||||
enable_partial_columns: false,
|
||||
node_custody_type: NodeCustodyType::Fullnode,
|
||||
disable_proposer_reorg: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ChainConfig {
|
||||
/// The latest delay from the start of the slot at which to attempt a 1-slot re-org.
|
||||
pub fn re_org_cutoff(&self, slot_duration: Duration) -> Duration {
|
||||
self.re_org_cutoff_millis
|
||||
.map(Duration::from_millis)
|
||||
.unwrap_or_else(|| slot_duration / DEFAULT_RE_ORG_CUTOFF_DENOMINATOR)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user