mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-17 12:58:31 +00:00
upgrade clap to v4.5 (#5273)
* upgrade clap to v4.5 * cli fixes * Merge branch 'unstable' of https://github.com/sigp/lighthouse into upgrade-clap-cli * value parser for mnemonic * Merge branch 'unstable' of https://github.com/sigp/lighthouse into upgrade-clap-cli * merge unstable * default --format val * fix eth sim * fix eth sim * merge conflicts * resolve beta compiler issue * add num args, version * add custom flag parser, make rate limiter flags clap friendly * remove unneeded check * fmt * update * alphabetic order * resolve merge conflict * fix test * resolve conflicts * fix test * revert removed if statement * fmt got me again * fix broken flag * make cli * make cli * update * remove -e files * update * cli help updates * Merge branch 'unstable' of https://github.com/sigp/lighthouse into upgrade-clap-cli * cli help updates * md files * merge conflict * merge conflicts * md * help text, text width, and a few flag fixes * fmt * merge * revert * revert * resolve merge conflicts * merge conflicts * revert simulator changes * require at least one arg * fix eth sim cli * resolve merge conflicts * book changes * md changes * cli check * cli check * retry cli check * retry cli check * Merge branch 'unstable' of https://github.com/sigp/lighthouse into upgrade-clap-cli * cli * Merge remote-tracking branch 'origin/unstable' into upgrade-clap-cli * Update CLI docs for Goerli removal * Fix cargo lock
This commit is contained in:
@@ -151,15 +151,15 @@ impl Config {
|
||||
.unwrap_or_else(|| PathBuf::from("."));
|
||||
|
||||
let (mut validator_dir, mut secrets_dir) = (None, None);
|
||||
if cli_args.value_of("datadir").is_some() {
|
||||
if cli_args.get_one::<String>("datadir").is_some() {
|
||||
let base_dir: PathBuf = parse_required(cli_args, "datadir")?;
|
||||
validator_dir = Some(base_dir.join(DEFAULT_VALIDATOR_DIR));
|
||||
secrets_dir = Some(base_dir.join(DEFAULT_SECRET_DIR));
|
||||
}
|
||||
if cli_args.value_of("validators-dir").is_some() {
|
||||
if cli_args.get_one::<String>("validators-dir").is_some() {
|
||||
validator_dir = Some(parse_required(cli_args, "validators-dir")?);
|
||||
}
|
||||
if cli_args.value_of("secrets-dir").is_some() {
|
||||
if cli_args.get_one::<String>("secrets-dir").is_some() {
|
||||
secrets_dir = Some(parse_required(cli_args, "secrets-dir")?);
|
||||
}
|
||||
|
||||
@@ -195,11 +195,11 @@ impl Config {
|
||||
.map_err(|e| format!("Unable to parse proposer node URL: {:?}", e))?;
|
||||
}
|
||||
|
||||
config.disable_auto_discover = cli_args.is_present("disable-auto-discover");
|
||||
config.init_slashing_protection = cli_args.is_present("init-slashing-protection");
|
||||
config.use_long_timeouts = cli_args.is_present("use-long-timeouts");
|
||||
config.disable_auto_discover = cli_args.get_flag("disable-auto-discover");
|
||||
config.init_slashing_protection = cli_args.get_flag("init-slashing-protection");
|
||||
config.use_long_timeouts = cli_args.get_flag("use-long-timeouts");
|
||||
|
||||
if let Some(graffiti_file_path) = cli_args.value_of("graffiti-file") {
|
||||
if let Some(graffiti_file_path) = cli_args.get_one::<String>("graffiti-file") {
|
||||
let mut graffiti_file = GraffitiFile::new(graffiti_file_path.into());
|
||||
graffiti_file
|
||||
.read_graffiti_file()
|
||||
@@ -208,7 +208,7 @@ impl Config {
|
||||
info!(log, "Successfully loaded graffiti file"; "path" => graffiti_file_path);
|
||||
}
|
||||
|
||||
if let Some(input_graffiti) = cli_args.value_of("graffiti") {
|
||||
if let Some(input_graffiti) = cli_args.get_one::<String>("graffiti") {
|
||||
let graffiti_bytes = input_graffiti.as_bytes();
|
||||
if graffiti_bytes.len() > GRAFFITI_BYTES_LEN {
|
||||
return Err(format!(
|
||||
@@ -237,11 +237,11 @@ impl Config {
|
||||
config.beacon_nodes_tls_certs = Some(tls_certs.split(',').map(PathBuf::from).collect());
|
||||
}
|
||||
|
||||
if cli_args.is_present("distributed") {
|
||||
if cli_args.get_flag("distributed") {
|
||||
config.distributed = true;
|
||||
}
|
||||
|
||||
if cli_args.is_present("disable-run-on-all") {
|
||||
if cli_args.get_flag("disable-run-on-all") {
|
||||
warn!(
|
||||
log,
|
||||
"The --disable-run-on-all flag is deprecated";
|
||||
@@ -249,7 +249,7 @@ impl Config {
|
||||
);
|
||||
config.broadcast_topics = vec![];
|
||||
}
|
||||
if let Some(broadcast_topics) = cli_args.value_of("broadcast") {
|
||||
if let Some(broadcast_topics) = cli_args.get_one::<String>("broadcast") {
|
||||
config.broadcast_topics = broadcast_topics
|
||||
.split(',')
|
||||
.filter(|t| *t != "none")
|
||||
@@ -281,12 +281,12 @@ impl Config {
|
||||
* Http API server
|
||||
*/
|
||||
|
||||
if cli_args.is_present("http") {
|
||||
if cli_args.get_flag("http") {
|
||||
config.http_api.enabled = true;
|
||||
}
|
||||
|
||||
if let Some(address) = cli_args.value_of("http-address") {
|
||||
if cli_args.is_present("unencrypted-http-transport") {
|
||||
if let Some(address) = cli_args.get_one::<String>("http-address") {
|
||||
if cli_args.get_flag("unencrypted-http-transport") {
|
||||
config.http_api.listen_addr = address
|
||||
.parse::<IpAddr>()
|
||||
.map_err(|_| "http-address is not a valid IP address.")?;
|
||||
@@ -298,13 +298,13 @@ impl Config {
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(port) = cli_args.value_of("http-port") {
|
||||
if let Some(port) = cli_args.get_one::<String>("http-port") {
|
||||
config.http_api.listen_port = port
|
||||
.parse::<u16>()
|
||||
.map_err(|_| "http-port is not a valid u16.")?;
|
||||
}
|
||||
|
||||
if let Some(allow_origin) = cli_args.value_of("http-allow-origin") {
|
||||
if let Some(allow_origin) = cli_args.get_one::<String>("http-allow-origin") {
|
||||
// Pre-validate the config value to give feedback to the user on node startup, instead of
|
||||
// as late as when the first API response is produced.
|
||||
hyper::header::HeaderValue::from_str(allow_origin)
|
||||
@@ -313,11 +313,11 @@ impl Config {
|
||||
config.http_api.allow_origin = Some(allow_origin.to_string());
|
||||
}
|
||||
|
||||
if cli_args.is_present("http-allow-keystore-export") {
|
||||
if cli_args.get_flag("http-allow-keystore-export") {
|
||||
config.http_api.allow_keystore_export = true;
|
||||
}
|
||||
|
||||
if cli_args.is_present("http-store-passwords-in-secrets-dir") {
|
||||
if cli_args.get_flag("http-store-passwords-in-secrets-dir") {
|
||||
config.http_api.store_passwords_in_secrets_dir = true;
|
||||
}
|
||||
|
||||
@@ -325,27 +325,27 @@ impl Config {
|
||||
* Prometheus metrics HTTP server
|
||||
*/
|
||||
|
||||
if cli_args.is_present("metrics") {
|
||||
if cli_args.get_flag("metrics") {
|
||||
config.http_metrics.enabled = true;
|
||||
}
|
||||
|
||||
if cli_args.is_present("enable-high-validator-count-metrics") {
|
||||
if cli_args.get_flag("enable-high-validator-count-metrics") {
|
||||
config.enable_high_validator_count_metrics = true;
|
||||
}
|
||||
|
||||
if let Some(address) = cli_args.value_of("metrics-address") {
|
||||
if let Some(address) = cli_args.get_one::<String>("metrics-address") {
|
||||
config.http_metrics.listen_addr = address
|
||||
.parse::<IpAddr>()
|
||||
.map_err(|_| "metrics-address is not a valid IP address.")?;
|
||||
}
|
||||
|
||||
if let Some(port) = cli_args.value_of("metrics-port") {
|
||||
if let Some(port) = cli_args.get_one::<String>("metrics-port") {
|
||||
config.http_metrics.listen_port = port
|
||||
.parse::<u16>()
|
||||
.map_err(|_| "metrics-port is not a valid u16.")?;
|
||||
}
|
||||
|
||||
if let Some(allow_origin) = cli_args.value_of("metrics-allow-origin") {
|
||||
if let Some(allow_origin) = cli_args.get_one::<String>("metrics-allow-origin") {
|
||||
// Pre-validate the config value to give feedback to the user on node startup, instead of
|
||||
// as late as when the first API response is produced.
|
||||
hyper::header::HeaderValue::from_str(allow_origin)
|
||||
@@ -354,14 +354,14 @@ impl Config {
|
||||
config.http_metrics.allow_origin = Some(allow_origin.to_string());
|
||||
}
|
||||
|
||||
if cli_args.is_present(DISABLE_MALLOC_TUNING_FLAG) {
|
||||
if cli_args.get_flag(DISABLE_MALLOC_TUNING_FLAG) {
|
||||
config.http_metrics.allocator_metrics_enabled = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Explorer metrics
|
||||
*/
|
||||
if let Some(monitoring_endpoint) = cli_args.value_of("monitoring-endpoint") {
|
||||
if let Some(monitoring_endpoint) = cli_args.get_one::<String>("monitoring-endpoint") {
|
||||
let update_period_secs =
|
||||
clap_utils::parse_optional(cli_args, "monitoring-endpoint-period")?;
|
||||
config.monitoring_api = Some(monitoring_api::Config {
|
||||
@@ -372,24 +372,24 @@ impl Config {
|
||||
});
|
||||
}
|
||||
|
||||
if cli_args.is_present("enable-doppelganger-protection") {
|
||||
if cli_args.get_flag("enable-doppelganger-protection") {
|
||||
config.enable_doppelganger_protection = true;
|
||||
}
|
||||
|
||||
if cli_args.is_present("builder-proposals") {
|
||||
if cli_args.get_flag("builder-proposals") {
|
||||
config.builder_proposals = true;
|
||||
}
|
||||
|
||||
if cli_args.is_present("produce-block-v3") {
|
||||
if cli_args.get_flag("produce-block-v3") {
|
||||
config.produce_block_v3 = true;
|
||||
}
|
||||
|
||||
if cli_args.is_present("prefer-builder-proposals") {
|
||||
if cli_args.get_flag("prefer-builder-proposals") {
|
||||
config.prefer_builder_proposals = true;
|
||||
}
|
||||
|
||||
config.gas_limit = cli_args
|
||||
.value_of("gas-limit")
|
||||
.get_one::<String>("gas-limit")
|
||||
.map(|gas_limit| {
|
||||
gas_limit
|
||||
.parse::<u64>()
|
||||
@@ -398,7 +398,7 @@ impl Config {
|
||||
.transpose()?;
|
||||
|
||||
if let Some(registration_timestamp_override) =
|
||||
cli_args.value_of("builder-registration-timestamp-override")
|
||||
cli_args.get_one::<String>("builder-registration-timestamp-override")
|
||||
{
|
||||
config.builder_registration_timestamp_override = Some(
|
||||
registration_timestamp_override
|
||||
@@ -410,7 +410,7 @@ impl Config {
|
||||
config.builder_boost_factor = parse_optional(cli_args, "builder-boost-factor")?;
|
||||
|
||||
config.enable_latency_measurement_service =
|
||||
parse_optional(cli_args, "latency-measurement-service")?.unwrap_or(true);
|
||||
!cli_args.get_flag("disable-latency-measurement-service");
|
||||
|
||||
config.validator_registration_batch_size =
|
||||
parse_required(cli_args, "validator-registration-batch-size")?;
|
||||
@@ -419,7 +419,7 @@ impl Config {
|
||||
}
|
||||
|
||||
config.enable_web3signer_slashing_protection =
|
||||
if cli_args.is_present("disable-slashing-protection-web3signer") {
|
||||
if cli_args.get_flag("disable-slashing-protection-web3signer") {
|
||||
warn!(
|
||||
log,
|
||||
"Slashing protection for remote keys disabled";
|
||||
|
||||
Reference in New Issue
Block a user