Resolve merge conflicts

This commit is contained in:
Eitan Seri-Levi
2026-01-02 08:52:14 -06:00
918 changed files with 49304 additions and 37273 deletions

View File

@@ -1,7 +1,7 @@
use std::time::Duration;
use clap::{builder::ArgPredicate, crate_version, Arg, ArgAction, ArgGroup, Command};
use clap_utils::{get_color_style, FLAG_HEADER};
use clap::{Arg, ArgAction, ArgGroup, Command, builder::ArgPredicate, crate_version};
use clap_utils::{FLAG_HEADER, get_color_style};
use strum::VariantNames;
#[allow(clippy::large_stack_frames)]
@@ -47,33 +47,47 @@ pub fn cli_app() -> Command {
* Network parameters.
*/
.arg(
Arg::new("subscribe-all-data-column-subnets")
.long("subscribe-all-data-column-subnets")
Arg::new("supernode")
.long("supernode")
.alias("subscribe-all-data-column-subnets")
.action(ArgAction::SetTrue)
.help_heading(FLAG_HEADER)
.help("Subscribe to all data column subnets and participate in data custody for \
all columns. This will also advertise the beacon node as being long-lived \
subscribed to all data column subnets. \
NOTE: this is an experimental flag and may change any time without notice!")
.help("Run as a voluntary supernode. This node will subscribe to all data column \
subnets, custody all data columns, and perform reconstruction and cross-seeding. \
This requires significantly more bandwidth, storage, and computation requirements but \
the node will have direct access to all blobs via the beacon API and it \
helps network resilience by serving all data columns to syncing peers.")
.display_order(0)
)
.arg(
Arg::new("semi-supernode")
.long("semi-supernode")
.action(ArgAction::SetTrue)
.help_heading(FLAG_HEADER)
.conflicts_with("supernode")
.help("Run in minimal reconstruction mode. This node will subscribe to and custody \
half of the data columns (enough for reconstruction), enabling efficient \
data availability with lower bandwidth and storage requirements compared to \
a supernode, while still supporting full blob reconstruction.")
.display_order(0)
.hide(true)
)
.arg(
// TODO(das): remove this before PeerDAS release
Arg::new("malicious-withhold-count")
.long("malicious-withhold-count")
.action(ArgAction::Set)
.help_heading(FLAG_HEADER)
.help("TESTING ONLY do not use this")
.help("TESTING ONLY: Withholds a subset of data columns during publishing. \
Do not use in production. Requires the 'testing' feature to be enabled.")
.hide(true)
.display_order(0)
)
.arg(
Arg::new("enable-sampling")
.long("enable-sampling")
.action(ArgAction::SetTrue)
Arg::new("advertise-false-custody-group-count")
.long("advertise-false-custody-group-count")
.action(ArgAction::Set)
.help_heading(FLAG_HEADER)
.help("Enable peer sampling on data columns. Disabled by default.")
.help("TESTING ONLY: Advertises a false custody group count for testing PeerDAS. \
Do not use in production. Requires the 'testing' feature to be enabled.")
.hide(true)
.display_order(0)
)
@@ -235,7 +249,6 @@ pub fn cli_app() -> Command {
.long("network-load")
.value_name("INTEGER")
.help("Lighthouse's network can be tuned for bandwidth/performance. Setting this to a high value, will increase the bandwidth lighthouse uses, increasing the likelihood of redundant information in exchange for faster communication. This can increase profit of validators marginally by receiving messages faster on the network. Lower values decrease bandwidth usage, but makes communication slower which can lead to validator performance reduction. Values are in the range [1,5].")
.default_value("3")
.hide(true)
.action(ArgAction::Set)
.display_order(0)
@@ -401,6 +414,16 @@ pub fn cli_app() -> Command {
.help_heading(FLAG_HEADER)
.display_order(0)
)
.arg(
Arg::new("complete-blob-backfill")
.long("complete-blob-backfill")
.help("Download all blobs back to the Deneb fork epoch. This will likely result in \
the node banning most of its peers.")
.action(ArgAction::SetTrue)
.help_heading(FLAG_HEADER)
.display_order(0)
.hide(true)
)
.arg(
Arg::new("enable-private-discovery")
.long("enable-private-discovery")
@@ -688,59 +711,6 @@ pub fn cli_app() -> Command {
.help_heading(FLAG_HEADER)
.display_order(0)
)
/*
* Eth1 Integration
*/
.arg(
Arg::new("eth1")
.long("eth1")
.help("DEPRECATED")
.action(ArgAction::SetTrue)
.help_heading(FLAG_HEADER)
.display_order(0)
.hide(true)
)
.arg(
Arg::new("dummy-eth1")
.long("dummy-eth1")
.help("DEPRECATED")
.action(ArgAction::SetTrue)
.help_heading(FLAG_HEADER)
.conflicts_with("eth1")
.display_order(0)
.hide(true)
)
.arg(
Arg::new("eth1-purge-cache")
.long("eth1-purge-cache")
.value_name("PURGE-CACHE")
.help("Purges the eth1 block and deposit caches")
.action(ArgAction::SetTrue)
.help_heading(FLAG_HEADER)
.display_order(0)
)
.arg(
Arg::new("eth1-blocks-per-log-query")
.long("eth1-blocks-per-log-query")
.value_name("BLOCKS")
.help("Specifies the number of blocks that a deposit log query should span. \
This will reduce the size of responses from the Eth1 endpoint.")
.default_value("1000")
.action(ArgAction::Set)
.display_order(0)
)
.arg(
Arg::new("eth1-cache-follow-distance")
.long("eth1-cache-follow-distance")
.value_name("BLOCKS")
.help("Specifies the distance between the Eth1 chain head and the last block which \
should be imported into the cache. Setting this value lower can help \
compensate for irregular Proof-of-Work block times, but setting it too low \
can make the node vulnerable to re-orgs.")
.action(ArgAction::Set)
.display_order(0)
)
.arg(
Arg::new("slots-per-restore-point")
.long("slots-per-restore-point")
@@ -790,7 +760,7 @@ pub fn cli_app() -> Command {
.long("block-cache-size")
.value_name("SIZE")
.help("Specifies how many blocks the database should cache in memory")
.default_value("5")
.default_value("0")
.action(ArgAction::Set)
.display_order(0)
)
@@ -808,20 +778,32 @@ pub fn cli_app() -> Command {
Arg::new("hdiff-buffer-cache-size")
.long("hdiff-buffer-cache-size")
.value_name("SIZE")
.help("Number of hierarchical diff (hdiff) buffers to cache in memory. Each buffer \
is around the size of a BeaconState so you should be cautious about setting \
this value too high. This flag is irrelevant for most nodes, which run with \
state pruning enabled.")
.help("Number of cold hierarchical diff (hdiff) buffers to cache in memory. Each \
buffer is around the size of a BeaconState so you should be cautious about \
setting this value too high. This flag is irrelevant for most nodes, which \
run with state pruning enabled.")
.default_value("16")
.action(ArgAction::Set)
.display_order(0)
)
.arg(
Arg::new("hot-hdiff-buffer-cache-size")
.long("hot-hdiff-buffer-cache-size")
.value_name("SIZE")
.help("Number of hot hierarchical diff (hdiff) buffers to cache in memory. Each \
buffer is around the size of a BeaconState so you should be cautious about \
setting this value too high. Setting this value higher can reduce the time \
taken to store new states on disk at the cost of higher memory usage.")
.default_value("1")
.action(ArgAction::Set)
.display_order(0)
)
.arg(
Arg::new("state-cache-size")
.long("state-cache-size")
.value_name("STATE_CACHE_SIZE")
.help("Specifies the size of the state cache")
.default_value("32")
.default_value("128")
.action(ArgAction::Set)
.display_order(0)
)
@@ -917,6 +899,14 @@ pub fn cli_app() -> Command {
.action(ArgAction::Set)
.display_order(0)
)
.arg(
Arg::new("disable-get-blobs")
.long("disable-get-blobs")
.help("Disables the getBlobs optimisation to fetch blobs from the EL mempool")
.action(ArgAction::SetTrue)
.help_heading(FLAG_HEADER)
.display_order(0)
)
.arg(
Arg::new("builder-header-timeout")
.long("builder-header-timeout")
@@ -1488,17 +1478,6 @@ pub fn cli_app() -> Command {
.help_heading(FLAG_HEADER)
.display_order(0)
)
.arg(
Arg::new("disable-deposit-contract-sync")
.long("disable-deposit-contract-sync")
.help("Explicitly disables syncing of deposit logs from the execution node. \
This overrides any previous option that depends on it. \
Useful if you intend to run a non-validating beacon node.")
.action(ArgAction::SetTrue)
.help_heading(FLAG_HEADER)
.conflicts_with("staking")
.display_order(0)
)
.arg(
Arg::new("disable-optimistic-finalized-sync")
.long("disable-optimistic-finalized-sync")
@@ -1509,15 +1488,6 @@ pub fn cli_app() -> Command {
Lighthouse and only passed to the EL if initial verification fails.")
.display_order(0)
)
.arg(
Arg::new("light-client-server")
.long("light-client-server")
.help("DEPRECATED")
.action(ArgAction::SetTrue)
.help_heading(FLAG_HEADER)
.display_order(0)
)
.arg(
Arg::new("disable-light-client-server")
.long("disable-light-client-server")
@@ -1636,22 +1606,22 @@ pub fn cli_app() -> Command {
.value_name("SECONDS")
.action(ArgAction::Set)
.help_heading(FLAG_HEADER)
.help("TESTING ONLY: Artificially delay block publishing by the specified number of seconds. \
This only works for if `BroadcastValidation::Gossip` is used (default). \
DO NOT USE IN PRODUCTION.")
.help("TESTING ONLY: Artificially delays block publishing by the specified number of seconds. \
This only works if BroadcastValidation::Gossip is used (default). \
Do not use in production. Requires the 'testing' feature to be enabled.")
.hide(true)
.display_order(0)
)
.arg(
Arg::new("delay-data-column-publishing")
.long("delay-data-column-publishing")
.value_name("SECONDS")
.value_name("SECONDS")
.action(ArgAction::Set)
.help_heading(FLAG_HEADER)
.help("TESTING ONLY: Artificially delay data column publishing by the specified number of seconds. \
Limitation: If `delay-block-publishing` is also used, data columns will be delayed for a \
minimum of `delay-block-publishing` seconds.
DO NOT USE IN PRODUCTION.")
.help("TESTING ONLY: Artificially delays data column publishing by the specified number of seconds. \
Limitation: If delay-block-publishing is also used, data columns will be delayed for a \
minimum of delay-block-publishing seconds. \
Do not use in production. Requires the 'testing' feature to be enabled.")
.hide(true)
.display_order(0)
)

View File

@@ -1,24 +1,23 @@
use account_utils::{read_input_from_user, STDIN_INPUTS_FLAG};
use account_utils::{STDIN_INPUTS_FLAG, read_input_from_user};
use beacon_chain::chain_config::{
DisallowedReOrgOffsets, ReOrgThreshold, DEFAULT_PREPARE_PAYLOAD_LOOKAHEAD_FACTOR,
DEFAULT_RE_ORG_HEAD_THRESHOLD, DEFAULT_RE_ORG_MAX_EPOCHS_SINCE_FINALIZATION,
DEFAULT_RE_ORG_PARENT_THRESHOLD, INVALID_HOLESKY_BLOCK_ROOT,
DEFAULT_PREPARE_PAYLOAD_LOOKAHEAD_FACTOR, DEFAULT_RE_ORG_HEAD_THRESHOLD,
DEFAULT_RE_ORG_MAX_EPOCHS_SINCE_FINALIZATION, DEFAULT_RE_ORG_PARENT_THRESHOLD,
DisallowedReOrgOffsets, INVALID_HOLESKY_BLOCK_ROOT, ReOrgThreshold,
};
use beacon_chain::custody_context::NodeCustodyType;
use beacon_chain::graffiti_calculator::GraffitiOrigin;
use beacon_chain::TrustedSetup;
use clap::{parser::ValueSource, ArgMatches, Id};
use bls::PublicKeyBytes;
use clap::{ArgMatches, Id, parser::ValueSource};
use clap_utils::flags::DISABLE_MALLOC_TUNING_FLAG;
use clap_utils::{parse_flag, parse_required};
use client::{ClientConfig, ClientGenesis};
use directory::{DEFAULT_BEACON_NODE_DIR, DEFAULT_NETWORK_DIR, DEFAULT_ROOT_DIR};
use environment::RuntimeContext;
use execution_layer::DEFAULT_JWT_FILE;
use genesis::Eth1Endpoint;
use http_api::TlsConfig;
use lighthouse_network::ListenAddress;
use lighthouse_network::{multiaddr::Protocol, Enr, Multiaddr, NetworkConfig, PeerIdSerialized};
use lighthouse_network::{Enr, Multiaddr, NetworkConfig, PeerIdSerialized, multiaddr::Protocol};
use network_utils::listen_addr::ListenAddress;
use sensitive_url::SensitiveUrl;
use std::cmp::max;
use std::collections::HashSet;
use std::fmt::Debug;
use std::fs;
@@ -31,7 +30,7 @@ use std::str::FromStr;
use std::time::Duration;
use tracing::{error, info, warn};
use types::graffiti::GraffitiString;
use types::{Checkpoint, Epoch, EthSpec, Hash256, PublicKeyBytes};
use types::{Checkpoint, Epoch, EthSpec, Hash256};
const PURGE_DB_CONFIRMATION: &str = "confirm";
@@ -111,6 +110,18 @@ pub fn get_config<E: EthSpec>(
set_network_config(&mut client_config.network, cli_args, &data_dir_ref)?;
// Parse custody mode from CLI flags
let is_supernode = parse_flag(cli_args, "supernode");
let is_semi_supernode = parse_flag(cli_args, "semi-supernode");
client_config.chain.node_custody_type = if is_supernode {
NodeCustodyType::Supernode
} else if is_semi_supernode {
NodeCustodyType::SemiSupernode
} else {
NodeCustodyType::Fullnode
};
/*
* Staking flag
* Note: the config values set here can be overwritten by other more specific cli params
@@ -173,17 +184,14 @@ pub fn get_config<E: EthSpec>(
parse_required(cli_args, "http-duplicate-block-status")?;
}
if cli_args.get_flag("light-client-server") {
warn!(
"The --light-client-server flag is deprecated. The light client server is enabled \
by default"
);
}
if cli_args.get_flag("disable-light-client-server") {
client_config.chain.enable_light_client_server = false;
}
if cli_args.get_flag("disable-get-blobs") {
client_config.chain.disable_get_blobs = true;
}
if let Some(sync_tolerance_epochs) =
clap_utils::parse_optional(cli_args, "sync-tolerance-epochs")?
{
@@ -194,10 +202,6 @@ pub fn get_config<E: EthSpec>(
client_config.chain.shuffling_cache_size = cache_size;
}
if cli_args.get_flag("enable-sampling") {
client_config.chain.enable_sampling = true;
}
if let Some(batches) = clap_utils::parse_optional(cli_args, "blob-publication-batches")? {
client_config.chain.blob_publication_batches = batches;
}
@@ -265,34 +269,6 @@ pub fn get_config<E: EthSpec>(
client_config.http_metrics.allocator_metrics_enabled = false;
}
/*
* Eth1
*/
if cli_args.get_flag("dummy-eth1") {
warn!("The --dummy-eth1 flag is deprecated");
}
if cli_args.get_flag("eth1") {
warn!("The --eth1 flag is deprecated");
}
if let Some(val) = cli_args.get_one::<String>("eth1-blocks-per-log-query") {
client_config.eth1.blocks_per_log_query = val
.parse()
.map_err(|_| "eth1-blocks-per-log-query is not a valid integer".to_string())?;
}
if cli_args.get_flag("eth1-purge-cache") {
client_config.eth1.purge_cache = true;
}
if let Some(follow_distance) =
clap_utils::parse_optional(cli_args, "eth1-cache-follow-distance")?
{
client_config.eth1.cache_follow_distance = Some(follow_distance);
}
// `--execution-endpoint` is required now.
let endpoints: String = clap_utils::parse_required(cli_args, "execution-endpoint")?;
let mut el_config = execution_layer::Config::default();
@@ -358,35 +334,16 @@ pub fn get_config<E: EthSpec>(
clap_utils::parse_required(cli_args, "execution-timeout-multiplier")?;
el_config.execution_timeout_multiplier = Some(execution_timeout_multiplier);
client_config.eth1.endpoint = Eth1Endpoint::Auth {
endpoint: execution_endpoint,
jwt_path: secret_file,
jwt_id: el_config.jwt_id.clone(),
jwt_version: el_config.jwt_version.clone(),
};
// Store the EL config in the client config.
client_config.execution_layer = Some(el_config);
// 4844 params
if let Some(trusted_setup) = context
.eth2_network_config
.as_ref()
.map(|config| serde_json::from_slice(&config.kzg_trusted_setup))
.transpose()
.map_err(|e| format!("Unable to read trusted setup file: {}", e))?
{
client_config.trusted_setup = trusted_setup;
};
// Override default trusted setup file if required
if let Some(trusted_setup_file_path) = cli_args.get_one::<String>("trusted-setup-file-override")
{
let file = std::fs::File::open(trusted_setup_file_path)
.map_err(|e| format!("Failed to open trusted setup file: {}", e))?;
let trusted_setup: TrustedSetup = serde_json::from_reader(file)
.map_err(|e| format!("Unable to read trusted setup file: {}", e))?;
client_config.trusted_setup = trusted_setup;
client_config.trusted_setup = std::fs::read(trusted_setup_file_path)
.map_err(|e| format!("Failed to read trusted setup file: {}", e))?;
} else if let Some(eth2_network_config) = context.eth2_network_config.as_ref() {
client_config.trusted_setup = eth2_network_config.kzg_trusted_setup.clone();
}
if let Some(freezer_dir) = cli_args.get_one::<String>("freezer-dir") {
@@ -418,7 +375,13 @@ pub fn get_config<E: EthSpec>(
if let Some(hdiff_buffer_cache_size) =
clap_utils::parse_optional(cli_args, "hdiff-buffer-cache-size")?
{
client_config.store.hdiff_buffer_cache_size = hdiff_buffer_cache_size;
client_config.store.cold_hdiff_buffer_cache_size = hdiff_buffer_cache_size;
}
if let Some(hdiff_buffer_cache_size) =
clap_utils::parse_optional(cli_args, "hot-hdiff-buffer-cache-size")?
{
client_config.store.hot_hdiff_buffer_cache_size = hdiff_buffer_cache_size;
}
client_config.store.compact_on_init = cli_args.get_flag("compact-db");
@@ -472,6 +435,7 @@ pub fn get_config<E: EthSpec>(
client_config.store.blob_prune_margin_epochs = blob_prune_margin_epochs;
}
#[cfg(feature = "testing")]
if let Some(malicious_withhold_count) =
clap_utils::parse_optional(cli_args, "malicious-withhold-count")?
{
@@ -500,32 +464,22 @@ pub fn get_config<E: EthSpec>(
.as_ref()
.ok_or("Context is missing eth2 network config")?;
client_config.eth1.deposit_contract_address = format!("{:?}", spec.deposit_contract_address);
client_config.eth1.deposit_contract_deploy_block =
eth2_network_config.deposit_contract_deploy_block;
client_config.eth1.lowest_cached_block_number =
client_config.eth1.deposit_contract_deploy_block;
client_config.eth1.follow_distance = spec.eth1_follow_distance;
client_config.eth1.node_far_behind_seconds =
max(5, spec.eth1_follow_distance / 2) * spec.seconds_per_eth1_block;
client_config.eth1.chain_id = spec.deposit_chain_id.into();
client_config.eth1.set_block_cache_truncation::<E>(spec);
info!(
deploy_block = client_config.eth1.deposit_contract_deploy_block,
address = &client_config.eth1.deposit_contract_address,
deploy_block = eth2_network_config.deposit_contract_deploy_block,
address = ?spec.deposit_contract_address,
"Deposit contract"
);
// Only append network config bootnodes if discovery is not disabled
if !client_config.network.disable_discovery {
if let Some(boot_nodes) = &eth2_network_config.boot_enr {
client_config
.network
.boot_nodes_enr
.extend_from_slice(boot_nodes)
}
if !client_config.network.disable_discovery
&& let Some(boot_nodes) = &eth2_network_config.boot_enr
{
client_config
.network
.boot_nodes_enr
.extend_from_slice(boot_nodes)
}
client_config.chain.checkpoint_sync_url_timeout =
clap_utils::parse_required::<u64>(cli_args, "checkpoint-sync-url-timeout")?;
@@ -809,11 +763,6 @@ pub fn get_config<E: EthSpec>(
}
}
// Note: This overrides any previous flags that enable this option.
if cli_args.get_flag("disable-deposit-contract-sync") {
client_config.sync_eth1_chain = false;
}
client_config.chain.prepare_payload_lookahead =
clap_utils::parse_optional(cli_args, "prepare-payload-lookahead")?
.map(Duration::from_millis)
@@ -862,6 +811,14 @@ pub fn get_config<E: EthSpec>(
client_config.chain.genesis_backfill = true;
}
client_config.chain.complete_blob_backfill = cli_args.get_flag("complete-blob-backfill");
// Ensure `prune_blobs` is false whenever complete-blob-backfill is set. This overrides any
// setting of `--prune-blobs true` applied earlier in flag parsing.
if client_config.chain.complete_blob_backfill {
client_config.store.prune_blobs = false;
}
// Backfill sync rate-limiting
client_config.beacon_processor.enable_backfill_rate_limiting =
!cli_args.get_flag("disable-backfill-rate-limiting");
@@ -893,10 +850,12 @@ pub fn get_config<E: EthSpec>(
.max_gossip_aggregate_batch_size =
clap_utils::parse_required(cli_args, "beacon-processor-aggregate-batch-size")?;
#[cfg(feature = "testing")]
if let Some(delay) = clap_utils::parse_optional(cli_args, "delay-block-publishing")? {
client_config.chain.block_publishing_delay = Some(Duration::from_secs_f64(delay));
}
#[cfg(feature = "testing")]
if let Some(delay) = clap_utils::parse_optional(cli_args, "delay-data-column-publishing")? {
client_config.chain.data_column_publishing_delay = Some(Duration::from_secs_f64(delay));
}
@@ -953,18 +912,18 @@ pub fn parse_listening_addresses(cli_args: &ArgMatches) -> Result<ListenAddress,
IpAddr::V4(v4_addr) => match &maybe_ipv4 {
Some(first_ipv4_addr) => {
return Err(format!(
"When setting the --listen-address option twice, use an IPv4 address and an IPv6 address. \
"When setting the --listen-address option twice, use an IPv4 address and an IPv6 address. \
Got two IPv4 addresses {first_ipv4_addr} and {v4_addr}"
));
));
}
None => maybe_ipv4 = Some(v4_addr),
},
IpAddr::V6(v6_addr) => match &maybe_ipv6 {
Some(first_ipv6_addr) => {
return Err(format!(
"When setting the --listen-address option twice, use an IPv4 address and an IPv6 address. \
"When setting the --listen-address option twice, use an IPv4 address and an IPv6 address. \
Got two IPv6 addresses {first_ipv6_addr} and {v6_addr}"
));
));
}
None => maybe_ipv6 = Some(v6_addr),
},
@@ -1037,7 +996,9 @@ pub fn parse_listening_addresses(cli_args: &ArgMatches) -> Result<ListenAddress,
(None, Some(ipv6)) => {
// A single ipv6 address was provided. Set the ports
if cli_args.value_source("port6") == Some(ValueSource::CommandLine) {
warn!("When listening only over IPv6, use the --port flag. The value of --port6 will be ignored.");
warn!(
"When listening only over IPv6, use the --port flag. The value of --port6 will be ignored."
);
}
// If we are only listening on ipv6 and the user has specified --port6, lets just use
@@ -1046,33 +1007,37 @@ pub fn parse_listening_addresses(cli_args: &ArgMatches) -> Result<ListenAddress,
// use zero ports if required. If not, use the given port.
let tcp_port = use_zero_ports
.then(unused_port::unused_tcp6_port)
.then(network_utils::unused_port::unused_tcp6_port)
.transpose()?
.unwrap_or(port);
if maybe_disc6_port.is_some() {
warn!("When listening only over IPv6, use the --discovery-port flag. The value of --discovery-port6 will be ignored.")
warn!(
"When listening only over IPv6, use the --discovery-port flag. The value of --discovery-port6 will be ignored."
)
}
if maybe_quic6_port.is_some() {
warn!("When listening only over IPv6, use the --quic-port flag. The value of --quic-port6 will be ignored.")
warn!(
"When listening only over IPv6, use the --quic-port flag. The value of --quic-port6 will be ignored."
)
}
// use zero ports if required. If not, use the specific udp port. If none given, use
// the tcp port.
let disc_port = use_zero_ports
.then(unused_port::unused_udp6_port)
.then(network_utils::unused_port::unused_udp6_port)
.transpose()?
.or(maybe_disc_port)
.unwrap_or(tcp_port);
let quic_port = use_zero_ports
.then(unused_port::unused_udp6_port)
.then(network_utils::unused_port::unused_udp6_port)
.transpose()?
.or(maybe_quic_port)
.unwrap_or(if tcp_port == 0 { 0 } else { tcp_port + 1 });
ListenAddress::V6(lighthouse_network::ListenAddr {
ListenAddress::V6(network_utils::listen_addr::ListenAddr {
addr: ipv6,
quic_port,
disc_port,
@@ -1084,25 +1049,25 @@ pub fn parse_listening_addresses(cli_args: &ArgMatches) -> Result<ListenAddress,
// use zero ports if required. If not, use the given port.
let tcp_port = use_zero_ports
.then(unused_port::unused_tcp4_port)
.then(network_utils::unused_port::unused_tcp4_port)
.transpose()?
.unwrap_or(port);
// use zero ports if required. If not, use the specific discovery port. If none given, use
// the tcp port.
let disc_port = use_zero_ports
.then(unused_port::unused_udp4_port)
.then(network_utils::unused_port::unused_udp4_port)
.transpose()?
.or(maybe_disc_port)
.unwrap_or(tcp_port);
// use zero ports if required. If not, use the specific quic port. If none given, use
// the tcp port + 1.
let quic_port = use_zero_ports
.then(unused_port::unused_udp4_port)
.then(network_utils::unused_port::unused_udp4_port)
.transpose()?
.or(maybe_quic_port)
.unwrap_or(if tcp_port == 0 { 0 } else { tcp_port + 1 });
ListenAddress::V4(lighthouse_network::ListenAddr {
ListenAddress::V4(network_utils::listen_addr::ListenAddr {
addr: ipv4,
disc_port,
quic_port,
@@ -1114,16 +1079,16 @@ pub fn parse_listening_addresses(cli_args: &ArgMatches) -> Result<ListenAddress,
let port6 = maybe_port6.unwrap_or(port);
let ipv4_tcp_port = use_zero_ports
.then(unused_port::unused_tcp4_port)
.then(network_utils::unused_port::unused_tcp4_port)
.transpose()?
.unwrap_or(port);
let ipv4_disc_port = use_zero_ports
.then(unused_port::unused_udp4_port)
.then(network_utils::unused_port::unused_udp4_port)
.transpose()?
.or(maybe_disc_port)
.unwrap_or(ipv4_tcp_port);
let ipv4_quic_port = use_zero_ports
.then(unused_port::unused_udp4_port)
.then(network_utils::unused_port::unused_udp4_port)
.transpose()?
.or(maybe_quic_port)
.unwrap_or(if ipv4_tcp_port == 0 {
@@ -1134,16 +1099,16 @@ pub fn parse_listening_addresses(cli_args: &ArgMatches) -> Result<ListenAddress,
// Defaults to 9000 when required
let ipv6_tcp_port = use_zero_ports
.then(unused_port::unused_tcp6_port)
.then(network_utils::unused_port::unused_tcp6_port)
.transpose()?
.unwrap_or(port6);
let ipv6_disc_port = use_zero_ports
.then(unused_port::unused_udp6_port)
.then(network_utils::unused_port::unused_udp6_port)
.transpose()?
.or(maybe_disc6_port)
.unwrap_or(ipv6_tcp_port);
let ipv6_quic_port = use_zero_ports
.then(unused_port::unused_udp6_port)
.then(network_utils::unused_port::unused_udp6_port)
.transpose()?
.or(maybe_quic6_port)
.unwrap_or(if ipv6_tcp_port == 0 {
@@ -1153,13 +1118,13 @@ pub fn parse_listening_addresses(cli_args: &ArgMatches) -> Result<ListenAddress,
});
ListenAddress::DualStack(
lighthouse_network::ListenAddr {
network_utils::listen_addr::ListenAddr {
addr: ipv4,
disc_port: ipv4_disc_port,
quic_port: ipv4_quic_port,
tcp_port: ipv4_tcp_port,
},
lighthouse_network::ListenAddr {
network_utils::listen_addr::ListenAddr {
addr: ipv6,
disc_port: ipv6_disc_port,
quic_port: ipv6_quic_port,
@@ -1185,10 +1150,6 @@ pub fn set_network_config(
config.network_dir = data_dir.join(DEFAULT_NETWORK_DIR);
};
if parse_flag(cli_args, "subscribe-all-data-column-subnets") {
config.subscribe_all_data_column_subnets = true;
}
if parse_flag(cli_args, "subscribe-all-subnets") {
config.subscribe_all_subnets = true;
}
@@ -1197,6 +1158,13 @@ pub fn set_network_config(
config.import_all_attestations = true;
}
#[cfg(feature = "testing")]
if let Some(advertise_false_custody_group_count) =
clap_utils::parse_optional(cli_args, "advertise-false-custody-group-count")?
{
config.advertise_false_custody_group_count = Some(advertise_false_custody_group_count);
}
if parse_flag(cli_args, "shutdown-after-sync") {
config.shutdown_after_sync = true;
}
@@ -1267,7 +1235,11 @@ pub fn set_network_config(
})
.collect::<Result<Vec<PeerIdSerialized>, _>>()?;
if config.trusted_peers.len() >= config.target_peers {
warn!( target_peers = config.target_peers, trusted_peers = config.trusted_peers.len(),"More trusted peers than the target peer limit. This will prevent efficient peer selection criteria.");
warn!(
target_peers = config.target_peers,
trusted_peers = config.trusted_peers.len(),
"More trusted peers than the target peer limit. This will prevent efficient peer selection criteria."
);
}
}
@@ -1397,7 +1369,7 @@ pub fn set_network_config(
let addr_str = format!("{addr}:{port}");
match addr_str.to_socket_addrs() {
Err(_e) => {
return Err(format!("Failed to parse or resolve address {addr}."))
return Err(format!("Failed to parse or resolve address {addr}."));
}
Ok(resolved_addresses) => {
for socket_addr in resolved_addresses {
@@ -1488,10 +1460,6 @@ pub fn set_network_config(
if parse_flag(cli_args, "proposer-only") {
config.subscribe_all_subnets = false;
if cli_args.get_one::<String>("target-peers").is_none() {
// If a custom value is not set, change the default to 15
config.target_peers = 15;
}
config.proposer_only = true;
warn!(
info = "Proposer-only mode enabled",

View File

@@ -2,15 +2,15 @@ mod cli;
mod config;
pub use beacon_chain;
use beacon_chain::{
builder::Witness, eth1_chain::CachingEth1Backend, slot_clock::SystemTimeSlotClock,
};
use beacon_chain::{builder::Witness, slot_clock::SystemTimeSlotClock};
use clap::ArgMatches;
pub use cli::cli_app;
pub use client::{Client, ClientBuilder, ClientConfig, ClientGenesis};
pub use config::{get_config, get_data_dir, set_network_config};
use environment::RuntimeContext;
pub use eth2_config::Eth2Config;
use lighthouse_network::load_private_key;
use network_utils::enr_ext::peer_id_to_node_id;
use slasher::{DatabaseBackendOverride, Slasher};
use std::ops::{Deref, DerefMut};
use std::sync::Arc;
@@ -19,15 +19,8 @@ use tracing::{info, warn};
use types::{ChainSpec, Epoch, EthSpec, ForkName};
/// A type-alias to the tighten the definition of a production-intended `Client`.
pub type ProductionClient<E> = Client<
Witness<
SystemTimeSlotClock,
CachingEth1Backend<E>,
E,
BeaconNodeBackend<E>,
BeaconNodeBackend<E>,
>,
>;
pub type ProductionClient<E> =
Client<Witness<SystemTimeSlotClock, E, BeaconNodeBackend<E>, BeaconNodeBackend<E>>>;
/// The beacon node `Client` that will be used in production.
///
@@ -129,25 +122,14 @@ impl<E: EthSpec> ProductionBeaconNode<E> {
builder
};
// Generate or load the node id.
let local_keypair = load_private_key(&client_config.network);
let node_id = peer_id_to_node_id(&local_keypair.public().to_peer_id())?.raw();
let builder = builder
.beacon_chain_builder(client_genesis, client_config.clone())
.beacon_chain_builder(client_genesis, client_config.clone(), node_id)
.await?;
let builder = if client_config.sync_eth1_chain {
info!(
endpoint = ?client_config.eth1.endpoint,
method = "json rpc via http",
"Block production enabled"
);
builder
.caching_eth1_backend(client_config.eth1.clone())
.await?
} else {
info!(
reason = "no eth1 backend configured",
"Block production disabled"
);
builder.no_eth1_backend()?
};
info!("Block production enabled");
let builder = builder.system_time_slot_clock()?;
@@ -157,7 +139,7 @@ impl<E: EthSpec> ProductionBeaconNode<E> {
builder
.build_beacon_chain()?
.network(Arc::new(client_config.network))
.network(Arc::new(client_config.network), local_keypair)
.await?
.notifier()?
.http_metrics_config(client_config.http_metrics.clone())
@@ -230,6 +212,7 @@ mod test {
spec.electra_fork_epoch = None;
spec.eip7805_fork_epoch = None;
spec.fulu_fork_epoch = None;
spec.gloas_fork_epoch = None;
let result = validator_fork_epochs(&spec);
assert_eq!(
result,