Add CLI flags

This commit is contained in:
Paul Hauner
2021-09-25 16:17:49 +10:00
parent 81a62e33d7
commit f698b91d77
3 changed files with 59 additions and 0 deletions

View File

@@ -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.

View File

@@ -212,6 +212,31 @@ pub fn get_config<E: EthSpec>(
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") {
client_config.freezer_db_path = Some(PathBuf::from(freezer_dir));
}