mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 01:05:47 +00:00
Add CLI flags
This commit is contained in:
@@ -75,6 +75,7 @@ pub struct Config {
|
|||||||
pub chain: beacon_chain::ChainConfig,
|
pub chain: beacon_chain::ChainConfig,
|
||||||
pub eth1: eth1::Config,
|
pub eth1: eth1::Config,
|
||||||
pub execution_endpoints: Option<Vec<SensitiveUrl>>,
|
pub execution_endpoints: Option<Vec<SensitiveUrl>>,
|
||||||
|
pub total_terminal_difficulty_override: Option<u64>,
|
||||||
pub http_api: http_api::Config,
|
pub http_api: http_api::Config,
|
||||||
pub http_metrics: http_metrics::Config,
|
pub http_metrics: http_metrics::Config,
|
||||||
pub monitoring_api: Option<monitoring_api::Config>,
|
pub monitoring_api: Option<monitoring_api::Config>,
|
||||||
@@ -96,6 +97,7 @@ impl Default for Config {
|
|||||||
sync_eth1_chain: false,
|
sync_eth1_chain: false,
|
||||||
eth1: <_>::default(),
|
eth1: <_>::default(),
|
||||||
execution_endpoints: None,
|
execution_endpoints: None,
|
||||||
|
total_terminal_difficulty_override: None,
|
||||||
disabled_forks: Vec::new(),
|
disabled_forks: Vec::new(),
|
||||||
graffiti: Graffiti::default(),
|
graffiti: Graffiti::default(),
|
||||||
http_api: <_>::default(),
|
http_api: <_>::default(),
|
||||||
|
|||||||
@@ -348,6 +348,38 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
|||||||
.help("Specifies how many blocks the database should cache in memory [default: 5]")
|
.help("Specifies how many blocks the database should cache in memory [default: 5]")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
)
|
)
|
||||||
|
/*
|
||||||
|
* Execution Layer Integration
|
||||||
|
*/
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("merge")
|
||||||
|
.long("merge")
|
||||||
|
.help("Enable the features necessary to run merge testnets. This feature \
|
||||||
|
is unstable and is for developers only.")
|
||||||
|
.takes_value(false),
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("execution-endpoints")
|
||||||
|
.long("execution-endpoints")
|
||||||
|
.value_name("EXECUTION-ENDPOINTS")
|
||||||
|
.help("One or more comma-delimited server endpoints for HTTP JSON-RPC connection. \
|
||||||
|
If multiple endpoints are given the endpoints are used as fallback in the \
|
||||||
|
given order. Also enables the --merge flag. \
|
||||||
|
If this flag is omitted and the --eth1-endpoints is supplied, those values \
|
||||||
|
will be used. Defaults to http://127.0.0.1:8545.")
|
||||||
|
.takes_value(true)
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("terminal-total-difficulty-override")
|
||||||
|
.long("terminal-total-difficulty-override")
|
||||||
|
.value_name("TERMINAL_TOTAL_DIFFICULTY")
|
||||||
|
.help("Used to coordinate manual overrides to the TERMINAL_TOTAL_DIFFICULTY parameter. \
|
||||||
|
This flag should only be used if the user has a clear understanding that \
|
||||||
|
the broad Ethereum community has elected to override the terminal difficulty. \
|
||||||
|
Failure to do so will cause your node to experience a consensus failure. \
|
||||||
|
Be extremely careful with the use of this flag.")
|
||||||
|
.takes_value(true)
|
||||||
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Database purging and compaction.
|
* Database purging and compaction.
|
||||||
|
|||||||
@@ -212,6 +212,31 @@ pub fn get_config<E: EthSpec>(
|
|||||||
client_config.eth1.purge_cache = true;
|
client_config.eth1.purge_cache = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(endpoints) = cli_args.value_of("execution-endpoints") {
|
||||||
|
client_config.sync_eth1_chain = true;
|
||||||
|
client_config.execution_endpoints = endpoints
|
||||||
|
.split(',')
|
||||||
|
.map(|s| SensitiveUrl::parse(s))
|
||||||
|
.collect::<Result<_, _>>()
|
||||||
|
.map(Some)
|
||||||
|
.map_err(|e| format!("execution-endpoints contains an invalid URL {:?}", e))?;
|
||||||
|
} else if cli_args.is_present("merge") {
|
||||||
|
client_config.execution_endpoints = Some(client_config.eth1.endpoints.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(total_terminal_difficulty) =
|
||||||
|
clap_utils::parse_optional(cli_args, "total-terminal-difficulty-override")?
|
||||||
|
{
|
||||||
|
if client_config.execution_endpoints.is_none() {
|
||||||
|
return Err(
|
||||||
|
"The --merge flag must be provided when using --total-terminal-difficulty-override"
|
||||||
|
.into(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
client_config.total_terminal_difficulty_override = Some(total_terminal_difficulty);
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(freezer_dir) = cli_args.value_of("freezer-dir") {
|
if let Some(freezer_dir) = cli_args.value_of("freezer-dir") {
|
||||||
client_config.freezer_db_path = Some(PathBuf::from(freezer_dir));
|
client_config.freezer_db_path = Some(PathBuf::from(freezer_dir));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user