mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-21 22:04:44 +00:00
Split the VC into crates making it more modular (#6453)
* Starting to modularize the VC * Revert changes to eth2 * More progress * More progress * Compiles * Merge latest unstable and make it compile * Fix some lints * Tests compile * Merge latest unstable * Remove unnecessary deps * Merge latest unstable * Correct release tests * Merge latest unstable * Merge remote-tracking branch 'origin/unstable' into modularize-vc * Merge branch 'unstable' into modularize-vc * Revert unnecessary cargo lock changes * Update validator_client/beacon_node_fallback/Cargo.toml * Update validator_client/http_metrics/Cargo.toml * Update validator_client/http_metrics/src/lib.rs * Update validator_client/initialized_validators/Cargo.toml * Update validator_client/signing_method/Cargo.toml * Update validator_client/validator_metrics/Cargo.toml * Update validator_client/validator_services/Cargo.toml * Update validator_client/validator_store/Cargo.toml * Update validator_client/validator_store/src/lib.rs * Merge remote-tracking branch 'origin/unstable' into modularize-vc * Fix format string * Rename doppelganger trait * Don't drop the tempdir * Cargo fmt
This commit is contained in:
@@ -1,8 +1,4 @@
|
||||
use crate::beacon_node_fallback::ApiTopic;
|
||||
use crate::graffiti_file::GraffitiFile;
|
||||
use crate::{
|
||||
beacon_node_fallback, beacon_node_health::BeaconNodeSyncDistanceTiers, http_api, http_metrics,
|
||||
};
|
||||
use beacon_node_fallback::{beacon_node_health::BeaconNodeSyncDistanceTiers, ApiTopic};
|
||||
use clap::ArgMatches;
|
||||
use clap_utils::{flags::DISABLE_MALLOC_TUNING_FLAG, parse_optional, parse_required};
|
||||
use directory::{
|
||||
@@ -10,6 +6,8 @@ use directory::{
|
||||
DEFAULT_VALIDATOR_DIR,
|
||||
};
|
||||
use eth2::types::Graffiti;
|
||||
use graffiti_file::GraffitiFile;
|
||||
use initialized_validators::Config as InitializedValidatorsConfig;
|
||||
use sensitive_url::SensitiveUrl;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use slog::{info, warn, Logger};
|
||||
@@ -19,13 +17,18 @@ use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
use std::time::Duration;
|
||||
use types::{Address, GRAFFITI_BYTES_LEN};
|
||||
use validator_http_api;
|
||||
use validator_http_metrics;
|
||||
use validator_store::Config as ValidatorStoreConfig;
|
||||
|
||||
pub const DEFAULT_BEACON_NODE: &str = "http://localhost:5052/";
|
||||
pub const DEFAULT_WEB3SIGNER_KEEP_ALIVE: Option<Duration> = Some(Duration::from_secs(20));
|
||||
|
||||
/// Stores the core configuration for this validator instance.
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct Config {
|
||||
/// Configuration parameters for the validator store.
|
||||
#[serde(flatten)]
|
||||
pub validator_store: ValidatorStoreConfig,
|
||||
/// The data directory, which stores all validator databases
|
||||
pub validator_dir: PathBuf,
|
||||
/// The directory containing the passwords to unlock validator keystores.
|
||||
@@ -49,12 +52,10 @@ pub struct Config {
|
||||
pub graffiti: Option<Graffiti>,
|
||||
/// Graffiti file to load per validator graffitis.
|
||||
pub graffiti_file: Option<GraffitiFile>,
|
||||
/// Fallback fallback address.
|
||||
pub fee_recipient: Option<Address>,
|
||||
/// Configuration for the HTTP REST API.
|
||||
pub http_api: http_api::Config,
|
||||
pub http_api: validator_http_api::Config,
|
||||
/// Configuration for the HTTP REST API.
|
||||
pub http_metrics: http_metrics::Config,
|
||||
pub http_metrics: validator_http_metrics::Config,
|
||||
/// Configuration for the Beacon Node fallback.
|
||||
pub beacon_node_fallback: beacon_node_fallback::Config,
|
||||
/// Configuration for sending metrics to a remote explorer endpoint.
|
||||
@@ -68,11 +69,7 @@ pub struct Config {
|
||||
/// (<= 64 validators)
|
||||
pub enable_high_validator_count_metrics: bool,
|
||||
/// Enable use of the blinded block endpoints during proposals.
|
||||
pub builder_proposals: bool,
|
||||
/// Overrides the timestamp field in builder api ValidatorRegistrationV1
|
||||
pub builder_registration_timestamp_override: Option<u64>,
|
||||
/// Fallback gas limit.
|
||||
pub gas_limit: Option<u64>,
|
||||
/// A list of custom certificates that the validator client will additionally use when
|
||||
/// connecting to a beacon node over SSL/TLS.
|
||||
pub beacon_nodes_tls_certs: Option<Vec<PathBuf>>,
|
||||
@@ -82,16 +79,11 @@ pub struct Config {
|
||||
pub enable_latency_measurement_service: bool,
|
||||
/// Defines the number of validators per `validator/register_validator` request sent to the BN.
|
||||
pub validator_registration_batch_size: usize,
|
||||
/// Enable slashing protection even while using web3signer keys.
|
||||
pub enable_web3signer_slashing_protection: bool,
|
||||
/// Specifies the boost factor, a percentage multiplier to apply to the builder's payload value.
|
||||
pub builder_boost_factor: Option<u64>,
|
||||
/// If true, Lighthouse will prefer builder proposals, if available.
|
||||
pub prefer_builder_proposals: bool,
|
||||
/// Whether we are running with distributed network support.
|
||||
pub distributed: bool,
|
||||
pub web3_signer_keep_alive_timeout: Option<Duration>,
|
||||
pub web3_signer_max_idle_connections: Option<usize>,
|
||||
/// Configuration for the initialized validators
|
||||
#[serde(flatten)]
|
||||
pub initialized_validators: InitializedValidatorsConfig,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
@@ -109,6 +101,7 @@ impl Default for Config {
|
||||
let beacon_nodes = vec![SensitiveUrl::parse(DEFAULT_BEACON_NODE)
|
||||
.expect("beacon_nodes must always be a valid url.")];
|
||||
Self {
|
||||
validator_store: ValidatorStoreConfig::default(),
|
||||
validator_dir,
|
||||
secrets_dir,
|
||||
beacon_nodes,
|
||||
@@ -119,7 +112,6 @@ impl Default for Config {
|
||||
use_long_timeouts: false,
|
||||
graffiti: None,
|
||||
graffiti_file: None,
|
||||
fee_recipient: None,
|
||||
http_api: <_>::default(),
|
||||
http_metrics: <_>::default(),
|
||||
beacon_node_fallback: <_>::default(),
|
||||
@@ -127,18 +119,12 @@ impl Default for Config {
|
||||
enable_doppelganger_protection: false,
|
||||
enable_high_validator_count_metrics: false,
|
||||
beacon_nodes_tls_certs: None,
|
||||
builder_proposals: false,
|
||||
builder_registration_timestamp_override: None,
|
||||
gas_limit: None,
|
||||
broadcast_topics: vec![ApiTopic::Subscriptions],
|
||||
enable_latency_measurement_service: true,
|
||||
validator_registration_batch_size: 500,
|
||||
enable_web3signer_slashing_protection: true,
|
||||
builder_boost_factor: None,
|
||||
prefer_builder_proposals: false,
|
||||
distributed: false,
|
||||
web3_signer_keep_alive_timeout: DEFAULT_WEB3SIGNER_KEEP_ALIVE,
|
||||
web3_signer_max_idle_connections: None,
|
||||
initialized_validators: <_>::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -233,7 +219,7 @@ impl Config {
|
||||
if let Some(input_fee_recipient) =
|
||||
parse_optional::<Address>(cli_args, "suggested-fee-recipient")?
|
||||
{
|
||||
config.fee_recipient = Some(input_fee_recipient);
|
||||
config.validator_store.fee_recipient = Some(input_fee_recipient);
|
||||
}
|
||||
|
||||
if let Some(tls_certs) = parse_optional::<String>(cli_args, "beacon-nodes-tls-certs")? {
|
||||
@@ -270,7 +256,7 @@ impl Config {
|
||||
* Web3 signer
|
||||
*/
|
||||
if let Some(s) = parse_optional::<String>(cli_args, "web3-signer-keep-alive-timeout")? {
|
||||
config.web3_signer_keep_alive_timeout = if s == "null" {
|
||||
config.initialized_validators.web3_signer_keep_alive_timeout = if s == "null" {
|
||||
None
|
||||
} else {
|
||||
Some(Duration::from_millis(
|
||||
@@ -279,7 +265,9 @@ impl Config {
|
||||
}
|
||||
}
|
||||
if let Some(n) = parse_optional::<usize>(cli_args, "web3-signer-max-idle-connections")? {
|
||||
config.web3_signer_max_idle_connections = Some(n);
|
||||
config
|
||||
.initialized_validators
|
||||
.web3_signer_max_idle_connections = Some(n);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -382,14 +370,14 @@ impl Config {
|
||||
}
|
||||
|
||||
if cli_args.get_flag("builder-proposals") {
|
||||
config.builder_proposals = true;
|
||||
config.validator_store.builder_proposals = true;
|
||||
}
|
||||
|
||||
if cli_args.get_flag("prefer-builder-proposals") {
|
||||
config.prefer_builder_proposals = true;
|
||||
config.validator_store.prefer_builder_proposals = true;
|
||||
}
|
||||
|
||||
config.gas_limit = cli_args
|
||||
config.validator_store.gas_limit = cli_args
|
||||
.get_one::<String>("gas-limit")
|
||||
.map(|gas_limit| {
|
||||
gas_limit
|
||||
@@ -408,7 +396,8 @@ impl Config {
|
||||
);
|
||||
}
|
||||
|
||||
config.builder_boost_factor = parse_optional(cli_args, "builder-boost-factor")?;
|
||||
config.validator_store.builder_boost_factor =
|
||||
parse_optional(cli_args, "builder-boost-factor")?;
|
||||
|
||||
config.enable_latency_measurement_service =
|
||||
!cli_args.get_flag("disable-latency-measurement-service");
|
||||
@@ -419,7 +408,7 @@ impl Config {
|
||||
return Err("validator-registration-batch-size cannot be 0".to_string());
|
||||
}
|
||||
|
||||
config.enable_web3signer_slashing_protection =
|
||||
config.validator_store.enable_web3signer_slashing_protection =
|
||||
if cli_args.get_flag("disable-slashing-protection-web3signer") {
|
||||
warn!(
|
||||
log,
|
||||
|
||||
Reference in New Issue
Block a user