From f698b91d774a1ce5ea801152a05db1713cd309c5 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Sat, 25 Sep 2021 16:17:49 +1000 Subject: [PATCH] Add CLI flags --- beacon_node/client/src/config.rs | 2 ++ beacon_node/src/cli.rs | 32 ++++++++++++++++++++++++++++++++ beacon_node/src/config.rs | 25 +++++++++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/beacon_node/client/src/config.rs b/beacon_node/client/src/config.rs index 28af34da2c..a3791c8a9c 100644 --- a/beacon_node/client/src/config.rs +++ b/beacon_node/client/src/config.rs @@ -75,6 +75,7 @@ pub struct Config { pub chain: beacon_chain::ChainConfig, pub eth1: eth1::Config, pub execution_endpoints: Option>, + pub total_terminal_difficulty_override: Option, pub http_api: http_api::Config, pub http_metrics: http_metrics::Config, pub monitoring_api: Option, @@ -96,6 +97,7 @@ impl Default for Config { sync_eth1_chain: false, eth1: <_>::default(), execution_endpoints: None, + total_terminal_difficulty_override: None, disabled_forks: Vec::new(), graffiti: Graffiti::default(), http_api: <_>::default(), diff --git a/beacon_node/src/cli.rs b/beacon_node/src/cli.rs index f27d430b74..2188a463ed 100644 --- a/beacon_node/src/cli.rs +++ b/beacon_node/src/cli.rs @@ -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]") .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. diff --git a/beacon_node/src/config.rs b/beacon_node/src/config.rs index b0fd687f48..6d29d613db 100644 --- a/beacon_node/src/config.rs +++ b/beacon_node/src/config.rs @@ -212,6 +212,31 @@ pub fn get_config( 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::>() + .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") { client_config.freezer_db_path = Some(PathBuf::from(freezer_dir)); }