From df983a83e1ccf1fe288b5464569b59b5ac35e38c Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Tue, 28 May 2024 07:46:39 +0200 Subject: [PATCH] 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 --- Cargo.lock | 136 ++- Cargo.toml | 4 +- account_manager/src/lib.rs | 30 +- account_manager/src/validator/create.rs | 73 +- account_manager/src/validator/exit.rs | 50 +- account_manager/src/validator/import.rs | 47 +- account_manager/src/validator/list.rs | 6 +- account_manager/src/validator/mod.rs | 40 +- account_manager/src/validator/modify.rs | 47 +- account_manager/src/validator/recover.rs | 54 +- .../src/validator/slashing_protection.rs | 40 +- account_manager/src/wallet/create.rs | 69 +- account_manager/src/wallet/list.rs | 6 +- account_manager/src/wallet/mod.rs | 32 +- account_manager/src/wallet/recover.rs | 41 +- beacon_node/src/cli.rs | 861 ++++++++----- beacon_node/src/config.rs | 282 ++--- beacon_node/src/lib.rs | 3 +- book/src/help_bn.md | 1085 +++++++++-------- book/src/help_general.md | 230 ++-- book/src/help_vc.md | 490 ++++---- book/src/help_vm.md | 205 ++-- book/src/help_vm_create.md | 290 +++-- book/src/help_vm_import.md | 211 ++-- book/src/help_vm_move.md | 247 ++-- boot_node/src/cli.rs | 77 +- boot_node/src/config.rs | 9 +- boot_node/src/lib.rs | 8 +- boot_node/src/server.rs | 6 +- common/clap_utils/src/lib.rs | 26 +- common/directory/src/lib.rs | 4 +- database_manager/src/lib.rs | 189 +-- lcli/src/change_genesis_time.rs | 4 +- lcli/src/create_payload_header.rs | 4 +- lcli/src/deploy_deposit_contract.rs | 2 +- lcli/src/eth1_genesis.rs | 10 +- lcli/src/interop_genesis.rs | 4 +- lcli/src/main.rs | 819 +++++++------ lcli/src/new_testnet.rs | 6 +- lcli/src/parse_ssz.rs | 10 +- lcli/src/replace_state_pubkeys.rs | 4 +- lcli/src/skip_slots.rs | 2 +- lcli/src/transition_blocks.rs | 6 +- lighthouse/src/main.rs | 284 +++-- lighthouse/tests/beacon_node.rs | 7 +- lighthouse/tests/validator_client.rs | 17 +- lighthouse/tests/validator_manager.rs | 7 +- scripts/cli.sh | 3 - testing/simulator/src/basic_sim.rs | 37 +- testing/simulator/src/cli.rs | 82 +- testing/simulator/src/fallback_sim.rs | 39 +- testing/simulator/src/main.rs | 5 +- validator_client/src/cli.rs | 258 ++-- validator_client/src/config.rs | 66 +- validator_client/src/lib.rs | 2 +- validator_manager/src/create_validators.rs | 128 +- validator_manager/src/import_validators.rs | 46 +- validator_manager/src/lib.rs | 33 +- validator_manager/src/move_validators.rs | 97 +- watch/Cargo.toml | 1 + watch/src/cli.rs | 27 +- 61 files changed, 4038 insertions(+), 2870 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d2c8756cb89..22ed5178715 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,7 +18,7 @@ version = "0.3.5" dependencies = [ "account_utils", "bls", - "clap", + "clap 4.5.4", "clap_utils", "directory", "environment", @@ -281,12 +281,51 @@ dependencies = [ ] [[package]] -name = "ansi_term" -version = "0.12.1" +name = "anstream" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +checksum = "96b09b5178381e0874812a9b157f7fe84982617e48f71f4e3235482775e5b540" dependencies = [ - "winapi", + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" + +[[package]] +name = "anstyle-parse" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", ] [[package]] @@ -812,7 +851,7 @@ name = "beacon_node" version = "5.1.3" dependencies = [ "beacon_chain", - "clap", + "clap 4.5.4", "clap_utils", "client", "directory", @@ -1018,7 +1057,7 @@ name = "boot_node" version = "5.1.3" dependencies = [ "beacon_node", - "clap", + "clap 4.5.4", "clap_utils", "eth2_network_config", "ethereum_ssz", @@ -1280,20 +1319,44 @@ version = "2.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ - "ansi_term", - "atty", "bitflags 1.3.2", - "strsim 0.8.0", "textwrap", "unicode-width", - "vec_map", ] +[[package]] +name = "clap" +version = "4.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" +dependencies = [ + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim 0.11.0", + "terminal_size", +] + +[[package]] +name = "clap_lex" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" + [[package]] name = "clap_utils" version = "0.1.0" dependencies = [ - "clap", + "clap 4.5.4", "dirs", "eth2_network_config", "ethereum-types 0.14.1", @@ -1355,6 +1418,12 @@ dependencies = [ "cc", ] +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "compare_fields" version = "0.2.0" @@ -1462,7 +1531,7 @@ checksum = "b01d6de93b2b6c65e17c634a26653a29d107b3c98c607c765bf38d041531cd8f" dependencies = [ "atty", "cast", - "clap", + "clap 2.34.0", "criterion-plot", "csv", "itertools", @@ -1764,7 +1833,7 @@ version = "0.1.0" dependencies = [ "beacon_chain", "beacon_node", - "clap", + "clap 4.5.4", "clap_utils", "environment", "hex", @@ -1954,7 +2023,7 @@ dependencies = [ name = "directory" version = "0.1.0" dependencies = [ - "clap", + "clap 4.5.4", "clap_utils", "eth2_network_config", ] @@ -4253,7 +4322,7 @@ dependencies = [ "account_utils", "beacon_chain", "bls", - "clap", + "clap 4.5.4", "clap_utils", "deposit_contract", "env_logger 0.9.3", @@ -4830,7 +4899,7 @@ dependencies = [ "beacon_processor", "bls", "boot_node", - "clap", + "clap 4.5.4", "clap_utils", "database_manager", "directory", @@ -7533,7 +7602,7 @@ dependencies = [ name = "simulator" version = "0.2.0" dependencies = [ - "clap", + "clap 4.5.4", "env_logger 0.9.3", "eth2_network_config", "execution_layer", @@ -7927,15 +7996,15 @@ dependencies = [ [[package]] name = "strsim" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" [[package]] name = "strum" @@ -8152,6 +8221,16 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "terminal_size" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" +dependencies = [ + "rustix 0.38.34", + "windows-sys 0.48.0", +] + [[package]] name = "test-test_logger" version = "0.1.0" @@ -8916,6 +8995,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "uuid" version = "0.8.2" @@ -8933,7 +9018,7 @@ dependencies = [ "account_utils", "bincode", "bls", - "clap", + "clap 4.5.4", "clap_utils", "deposit_contract", "directory", @@ -9005,7 +9090,7 @@ name = "validator_manager" version = "0.1.0" dependencies = [ "account_utils", - "clap", + "clap 4.5.4", "clap_utils", "environment", "eth2", @@ -9244,7 +9329,8 @@ dependencies = [ "beacon_chain", "beacon_node", "bls", - "clap", + "clap 4.5.4", + "clap_utils", "diesel", "diesel_migrations", "env_logger 0.9.3", diff --git a/Cargo.toml b/Cargo.toml index c70d9459124..84a51f55657 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -102,10 +102,10 @@ bincode = "1" bitvec = "1" byteorder = "1" bytes = "1" +clap = { version = "4.5.4", features = ["cargo", "wrap_help"] } # Turn off c-kzg's default features which include `blst/portable`. We can turn on blst's portable # feature ourselves when desired. -c-kzg = { version = "1", default-features = false } -clap = "2" +c-kzg = { version = "1", default-features = false } compare_fields_derive = { path = "common/compare_fields_derive" } criterion = "0.3" delay_map = "0.3" diff --git a/account_manager/src/lib.rs b/account_manager/src/lib.rs index ce7e8a42c24..f1160fff9c5 100644 --- a/account_manager/src/lib.rs +++ b/account_manager/src/lib.rs @@ -2,8 +2,11 @@ mod common; pub mod validator; pub mod wallet; -use clap::App; +use clap::Arg; +use clap::ArgAction; use clap::ArgMatches; +use clap::Command; +use clap_utils::FLAG_HEADER; use environment::Environment; use types::EthSpec; @@ -13,25 +16,36 @@ pub const VALIDATOR_DIR_FLAG: &str = "validator-dir"; pub const VALIDATOR_DIR_FLAG_ALIAS: &str = "validators-dir"; pub const WALLETS_DIR_FLAG: &str = "wallets-dir"; -pub fn cli_app<'a, 'b>() -> App<'a, 'b> { - App::new(CMD) - .visible_aliases(&["a", "am", "account", CMD]) +pub fn cli_app() -> Command { + Command::new(CMD) + .visible_aliases(["a", "am", "account", CMD]) .about("Utilities for generating and managing Ethereum 2.0 accounts.") + .display_order(0) + .arg( + Arg::new("help") + .long("help") + .short('h') + .help("Prints help information") + .action(ArgAction::HelpLong) + .display_order(0) + .help_heading(FLAG_HEADER), + ) .subcommand(wallet::cli_app()) .subcommand(validator::cli_app()) } /// Run the account manager, returning an error if the operation did not succeed. -pub fn run(matches: &ArgMatches<'_>, env: Environment) -> Result<(), String> { +pub fn run(matches: &ArgMatches, env: Environment) -> Result<(), String> { match matches.subcommand() { - (wallet::CMD, Some(matches)) => wallet::cli_run(matches)?, - (validator::CMD, Some(matches)) => validator::cli_run(matches, env)?, - (unknown, _) => { + Some((wallet::CMD, matches)) => wallet::cli_run(matches)?, + Some((validator::CMD, matches)) => validator::cli_run(matches, env)?, + Some((unknown, _)) => { return Err(format!( "{} is not a valid {} command. See --help.", unknown, CMD )); } + _ => return Err("No subcommand provided, see --help for options".to_string()), } Ok(()) diff --git a/account_manager/src/validator/create.rs b/account_manager/src/validator/create.rs index 93b041c61c4..cfe4d8e94ad 100644 --- a/account_manager/src/validator/create.rs +++ b/account_manager/src/validator/create.rs @@ -4,7 +4,8 @@ use crate::{SECRETS_DIR_FLAG, WALLETS_DIR_FLAG}; use account_utils::{ random_password, read_password_from_user, strip_off_newlines, validator_definitions, PlainText, }; -use clap::{App, Arg, ArgMatches}; +use clap::{Arg, ArgAction, ArgMatches, Command}; +use clap_utils::FLAG_HEADER; use directory::{ ensure_dir_exists, parse_path_or_default_with_flag, DEFAULT_SECRET_DIR, DEFAULT_WALLET_DIR, }; @@ -26,73 +27,83 @@ pub const COUNT_FLAG: &str = "count"; pub const AT_MOST_FLAG: &str = "at-most"; pub const WALLET_PASSWORD_PROMPT: &str = "Enter your wallet's password:"; -pub fn cli_app<'a, 'b>() -> App<'a, 'b> { - App::new(CMD) +pub fn cli_app() -> Command { + Command::new(CMD) .about( "Creates new validators from an existing EIP-2386 wallet using the EIP-2333 HD key \ derivation scheme.", ) .arg( - Arg::with_name(WALLET_NAME_FLAG) + Arg::new(WALLET_NAME_FLAG) .long(WALLET_NAME_FLAG) .value_name("WALLET_NAME") .help("Use the wallet identified by this name") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name(WALLET_PASSWORD_FLAG) + Arg::new(WALLET_PASSWORD_FLAG) .long(WALLET_PASSWORD_FLAG) .value_name("WALLET_PASSWORD_PATH") .help("A path to a file containing the password which will unlock the wallet.") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name(WALLETS_DIR_FLAG) + Arg::new(WALLETS_DIR_FLAG) .long(WALLETS_DIR_FLAG) .value_name(WALLETS_DIR_FLAG) .help("A path containing Eth2 EIP-2386 wallets. Defaults to ~/.lighthouse/{network}/wallets") - .takes_value(true) - .conflicts_with("datadir"), + .action(ArgAction::Set) + .conflicts_with("datadir") + .display_order(0) ) .arg( - Arg::with_name(SECRETS_DIR_FLAG) + Arg::new(SECRETS_DIR_FLAG) .long(SECRETS_DIR_FLAG) .value_name("SECRETS_DIR") .help( "The path where the validator keystore passwords will be stored. \ Defaults to ~/.lighthouse/{network}/secrets", ) - .takes_value(true), + .conflicts_with("datadir") + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name(DEPOSIT_GWEI_FLAG) + Arg::new(DEPOSIT_GWEI_FLAG) .long(DEPOSIT_GWEI_FLAG) .value_name("DEPOSIT_GWEI") .help( "The GWEI value of the deposit amount. Defaults to the minimum amount \ required for an active validator (MAX_EFFECTIVE_BALANCE)", ) - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name(STORE_WITHDRAW_FLAG) + Arg::new(STORE_WITHDRAW_FLAG) .long(STORE_WITHDRAW_FLAG) .help( "If present, the withdrawal keystore will be stored alongside the voting \ keypair. It is generally recommended to *not* store the withdrawal key and \ instead generate them from the wallet seed when required.", - ), + ) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name(COUNT_FLAG) + Arg::new(COUNT_FLAG) .long(COUNT_FLAG) .value_name("VALIDATOR_COUNT") .help("The number of validators to create, regardless of how many already exist") .conflicts_with("at-most") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name(AT_MOST_FLAG) + Arg::new(AT_MOST_FLAG) .long(AT_MOST_FLAG) .value_name("AT_MOST_VALIDATORS") .help( @@ -100,14 +111,18 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { reach the given count. Never deletes an existing validator.", ) .conflicts_with("count") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name(STDIN_INPUTS_FLAG) - .takes_value(false) - .hidden(cfg!(windows)) + Arg::new(STDIN_INPUTS_FLAG) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .hide(cfg!(windows)) .long(STDIN_INPUTS_FLAG) - .help("If present, read all user inputs from stdin instead of tty."), + .help("If present, read all user inputs from stdin instead of tty.") + .display_order(0) + .action(ArgAction::SetTrue) ) } @@ -119,15 +134,15 @@ pub fn cli_run( let spec = env.core_context().eth2_config.spec; let name: Option = clap_utils::parse_optional(matches, WALLET_NAME_FLAG)?; - let stdin_inputs = cfg!(windows) || matches.is_present(STDIN_INPUTS_FLAG); + let stdin_inputs = cfg!(windows) || matches.get_flag(STDIN_INPUTS_FLAG); - let wallet_base_dir = if matches.value_of("datadir").is_some() { + let wallet_base_dir = if matches.get_one::("datadir").is_some() { let path: PathBuf = clap_utils::parse_required(matches, "datadir")?; path.join(DEFAULT_WALLET_DIR) } else { parse_path_or_default_with_flag(matches, WALLETS_DIR_FLAG, DEFAULT_WALLET_DIR)? }; - let secrets_dir = if matches.value_of("datadir").is_some() { + let secrets_dir = if matches.get_one::("datadir").is_some() { let path: PathBuf = clap_utils::parse_required(matches, "datadir")?; path.join(DEFAULT_SECRET_DIR) } else { @@ -144,7 +159,7 @@ pub fn cli_run( return Err(format!( "No wallet directory at {:?}. Use the `lighthouse --network {} {} {} {}` command to create a wallet", wallet_base_dir, - matches.value_of("network").unwrap_or(""), + matches.get_one::("network").unwrap_or(&String::from("")), crate::CMD, crate::wallet::CMD, crate::wallet::create::CMD @@ -245,7 +260,7 @@ pub fn cli_run( .voting_keystore(keystores.voting, voting_password.as_bytes()) .withdrawal_keystore(keystores.withdrawal, withdrawal_password.as_bytes()) .create_eth1_tx_data(deposit_gwei, &spec) - .store_withdrawal_keystore(matches.is_present(STORE_WITHDRAW_FLAG)) + .store_withdrawal_keystore(matches.get_flag(STORE_WITHDRAW_FLAG)) .build() .map_err(|e| format!("Unable to build validator directory: {:?}", e))?; diff --git a/account_manager/src/validator/exit.rs b/account_manager/src/validator/exit.rs index bc9e0ee1dd6..277d2ae8eca 100644 --- a/account_manager/src/validator/exit.rs +++ b/account_manager/src/validator/exit.rs @@ -1,6 +1,7 @@ use crate::wallet::create::STDIN_INPUTS_FLAG; use bls::{Keypair, PublicKey}; -use clap::{App, Arg, ArgMatches}; +use clap::{Arg, ArgAction, ArgMatches, Command}; +use clap_utils::FLAG_HEADER; use environment::Environment; use eth2::{ types::{GenesisData, StateId, ValidatorData, ValidatorId, ValidatorStatus}, @@ -28,48 +29,59 @@ pub const DEFAULT_BEACON_NODE: &str = "http://localhost:5052/"; pub const CONFIRMATION_PHRASE: &str = "Exit my validator"; pub const WEBSITE_URL: &str = "https://lighthouse-book.sigmaprime.io/voluntary-exit.html"; -pub fn cli_app<'a, 'b>() -> App<'a, 'b> { - App::new("exit") +pub fn cli_app() -> Command { + Command::new("exit") .about("Submits a VoluntaryExit to the beacon chain for a given validator keystore.") .arg( - Arg::with_name(KEYSTORE_FLAG) + Arg::new(KEYSTORE_FLAG) .long(KEYSTORE_FLAG) .value_name("KEYSTORE_PATH") .help("The path to the EIP-2335 voting keystore for the validator") - .takes_value(true) - .required(true), + .action(ArgAction::Set) + .required(true) + .display_order(0) ) .arg( - Arg::with_name(PASSWORD_FILE_FLAG) + Arg::new(PASSWORD_FILE_FLAG) .long(PASSWORD_FILE_FLAG) .value_name("PASSWORD_FILE_PATH") .help("The path to the password file which unlocks the validator voting keystore") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name(BEACON_SERVER_FLAG) + Arg::new(BEACON_SERVER_FLAG) .long(BEACON_SERVER_FLAG) .value_name("NETWORK_ADDRESS") .help("Address to a beacon node HTTP API") .default_value(DEFAULT_BEACON_NODE) - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name(NO_WAIT) + Arg::new(NO_WAIT) .long(NO_WAIT) .help("Exits after publishing the voluntary exit without waiting for confirmation that the exit was included in the beacon chain") + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name(NO_CONFIRMATION) + Arg::new(NO_CONFIRMATION) .long(NO_CONFIRMATION) .help("Exits without prompting for confirmation that you understand the implications of a voluntary exit. This should be used with caution") + .display_order(0) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) ) .arg( - Arg::with_name(STDIN_INPUTS_FLAG) - .takes_value(false) - .hidden(cfg!(windows)) + Arg::new(STDIN_INPUTS_FLAG) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .hide(cfg!(windows)) .long(STDIN_INPUTS_FLAG) - .help("If present, read all user inputs from stdin instead of tty."), + .help("If present, read all user inputs from stdin instead of tty.") + .display_order(0) ) } @@ -78,9 +90,9 @@ pub fn cli_run(matches: &ArgMatches, env: Environment) -> Result< let password_file_path: Option = clap_utils::parse_optional(matches, PASSWORD_FILE_FLAG)?; - let stdin_inputs = cfg!(windows) || matches.is_present(STDIN_INPUTS_FLAG); - let no_wait = matches.is_present(NO_WAIT); - let no_confirmation = matches.is_present(NO_CONFIRMATION); + let stdin_inputs = cfg!(windows) || matches.get_flag(STDIN_INPUTS_FLAG); + let no_wait = matches.get_flag(NO_WAIT); + let no_confirmation = matches.get_flag(NO_CONFIRMATION); let spec = env.eth2_config().spec.clone(); let server_url: String = clap_utils::parse_required(matches, BEACON_SERVER_FLAG)?; diff --git a/account_manager/src/validator/import.rs b/account_manager/src/validator/import.rs index bf000385f3a..a7c72679f74 100644 --- a/account_manager/src/validator/import.rs +++ b/account_manager/src/validator/import.rs @@ -9,7 +9,8 @@ use account_utils::{ }, ZeroizeString, }; -use clap::{App, Arg, ArgMatches}; +use clap::{Arg, ArgAction, ArgMatches, Command}; +use clap_utils::FLAG_HEADER; use slashing_protection::{SlashingDatabase, SLASHING_PROTECTION_FILENAME}; use std::fs; use std::path::PathBuf; @@ -25,8 +26,8 @@ pub const PASSWORD_PROMPT: &str = "Enter the keystore password, or press enter t pub const KEYSTORE_REUSE_WARNING: &str = "DO NOT USE THE ORIGINAL KEYSTORES TO VALIDATE WITH \ ANOTHER CLIENT, OR YOU WILL GET SLASHED."; -pub fn cli_app<'a, 'b>() -> App<'a, 'b> { - App::new(CMD) +pub fn cli_app() -> Command { + Command::new(CMD) .about( "Imports one or more EIP-2335 passwords into a Lighthouse VC directory, \ requesting passwords interactively. The directory flag provides a convenient \ @@ -34,16 +35,17 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { Python utility.", ) .arg( - Arg::with_name(KEYSTORE_FLAG) + Arg::new(KEYSTORE_FLAG) .long(KEYSTORE_FLAG) .value_name("KEYSTORE_PATH") .help("Path to a single keystore to be imported.") .conflicts_with(DIR_FLAG) - .required_unless(DIR_FLAG) - .takes_value(true), + .required_unless_present(DIR_FLAG) + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(DIR_FLAG) + Arg::new(DIR_FLAG) .long(DIR_FLAG) .value_name("KEYSTORES_DIRECTORY") .help( @@ -53,23 +55,29 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { has the '.json' extension will be attempted to be imported.", ) .conflicts_with(KEYSTORE_FLAG) - .required_unless(KEYSTORE_FLAG) - .takes_value(true), + .required_unless_present(KEYSTORE_FLAG) + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(STDIN_INPUTS_FLAG) - .takes_value(false) - .hidden(cfg!(windows)) + Arg::new(STDIN_INPUTS_FLAG) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .hide(cfg!(windows)) .long(STDIN_INPUTS_FLAG) - .help("If present, read all user inputs from stdin instead of tty."), + .help("If present, read all user inputs from stdin instead of tty.") + .display_order(0), ) .arg( - Arg::with_name(REUSE_PASSWORD_FLAG) + Arg::new(REUSE_PASSWORD_FLAG) .long(REUSE_PASSWORD_FLAG) - .help("If present, the same password will be used for all imported keystores."), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .help("If present, the same password will be used for all imported keystores.") + .display_order(0), ) .arg( - Arg::with_name(PASSWORD_FLAG) + Arg::new(PASSWORD_FLAG) .long(PASSWORD_FLAG) .value_name("KEYSTORE_PASSWORD_PATH") .requires(REUSE_PASSWORD_FLAG) @@ -79,15 +87,16 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { The password will be copied to the `validator_definitions.yml` file, so after \ import we strongly recommend you delete the file at KEYSTORE_PASSWORD_PATH.", ) - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) } pub fn cli_run(matches: &ArgMatches, validator_dir: PathBuf) -> Result<(), String> { let keystore: Option = clap_utils::parse_optional(matches, KEYSTORE_FLAG)?; let keystores_dir: Option = clap_utils::parse_optional(matches, DIR_FLAG)?; - let stdin_inputs = cfg!(windows) || matches.is_present(STDIN_INPUTS_FLAG); - let reuse_password = matches.is_present(REUSE_PASSWORD_FLAG); + let stdin_inputs = cfg!(windows) || matches.get_flag(STDIN_INPUTS_FLAG); + let reuse_password = matches.get_flag(REUSE_PASSWORD_FLAG); let keystore_password_path: Option = clap_utils::parse_optional(matches, PASSWORD_FLAG)?; diff --git a/account_manager/src/validator/list.rs b/account_manager/src/validator/list.rs index 33857283695..d082a49590b 100644 --- a/account_manager/src/validator/list.rs +++ b/account_manager/src/validator/list.rs @@ -1,11 +1,11 @@ use account_utils::validator_definitions::ValidatorDefinitions; -use clap::App; +use clap::Command; use std::path::PathBuf; pub const CMD: &str = "list"; -pub fn cli_app<'a, 'b>() -> App<'a, 'b> { - App::new(CMD).about("Lists the public keys of all validators.") +pub fn cli_app() -> Command { + Command::new(CMD).about("Lists the public keys of all validators.") } pub fn cli_run(validator_dir: PathBuf) -> Result<(), String> { diff --git a/account_manager/src/validator/mod.rs b/account_manager/src/validator/mod.rs index af977dcf034..6616bb0c45c 100644 --- a/account_manager/src/validator/mod.rs +++ b/account_manager/src/validator/mod.rs @@ -7,7 +7,8 @@ pub mod recover; pub mod slashing_protection; use crate::{VALIDATOR_DIR_FLAG, VALIDATOR_DIR_FLAG_ALIAS}; -use clap::{App, Arg, ArgMatches}; +use clap::{Arg, ArgAction, ArgMatches, Command}; +use clap_utils::FLAG_HEADER; use directory::{parse_path_or_default_with_flag, DEFAULT_VALIDATOR_DIR}; use environment::Environment; use std::path::PathBuf; @@ -15,11 +16,21 @@ use types::EthSpec; pub const CMD: &str = "validator"; -pub fn cli_app<'a, 'b>() -> App<'a, 'b> { - App::new(CMD) +pub fn cli_app() -> Command { + Command::new(CMD) + .display_order(0) .about("Provides commands for managing Eth2 validators.") .arg( - Arg::with_name(VALIDATOR_DIR_FLAG) + Arg::new("help") + .long("help") + .short('h') + .help("Prints help information") + .action(ArgAction::HelpLong) + .display_order(0) + .help_heading(FLAG_HEADER), + ) + .arg( + Arg::new(VALIDATOR_DIR_FLAG) .long(VALIDATOR_DIR_FLAG) .alias(VALIDATOR_DIR_FLAG_ALIAS) .value_name("VALIDATOR_DIRECTORY") @@ -27,7 +38,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { "The path to search for validator directories. \ Defaults to ~/.lighthouse/{network}/validators", ) - .takes_value(true) + .action(ArgAction::Set) .conflicts_with("datadir"), ) .subcommand(create::cli_app()) @@ -40,7 +51,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { } pub fn cli_run(matches: &ArgMatches, env: Environment) -> Result<(), String> { - let validator_base_dir = if matches.value_of("datadir").is_some() { + let validator_base_dir = if matches.get_one::("datadir").is_some() { let path: PathBuf = clap_utils::parse_required(matches, "datadir")?; path.join(DEFAULT_VALIDATOR_DIR) } else { @@ -49,18 +60,19 @@ pub fn cli_run(matches: &ArgMatches, env: Environment) -> Result< eprintln!("validator-dir path: {:?}", validator_base_dir); match matches.subcommand() { - (create::CMD, Some(matches)) => create::cli_run::(matches, env, validator_base_dir), - (modify::CMD, Some(matches)) => modify::cli_run(matches, validator_base_dir), - (import::CMD, Some(matches)) => import::cli_run(matches, validator_base_dir), - (list::CMD, Some(_)) => list::cli_run(validator_base_dir), - (recover::CMD, Some(matches)) => recover::cli_run(matches, validator_base_dir), - (slashing_protection::CMD, Some(matches)) => { + Some((create::CMD, matches)) => create::cli_run::(matches, env, validator_base_dir), + Some((modify::CMD, matches)) => modify::cli_run(matches, validator_base_dir), + Some((import::CMD, matches)) => import::cli_run(matches, validator_base_dir), + Some((list::CMD, _)) => list::cli_run(validator_base_dir), + Some((recover::CMD, matches)) => recover::cli_run(matches, validator_base_dir), + Some((slashing_protection::CMD, matches)) => { slashing_protection::cli_run(matches, env, validator_base_dir) } - (exit::CMD, Some(matches)) => exit::cli_run(matches, env), - (unknown, _) => Err(format!( + Some((exit::CMD, matches)) => exit::cli_run(matches, env), + Some((unknown, _)) => Err(format!( "{} does not have a {} command. See --help", CMD, unknown )), + _ => Err(format!("No command provided for {}. See --help", CMD)), } } diff --git a/account_manager/src/validator/modify.rs b/account_manager/src/validator/modify.rs index bd4ae4d8f49..571cd28bf5e 100644 --- a/account_manager/src/validator/modify.rs +++ b/account_manager/src/validator/modify.rs @@ -1,6 +1,7 @@ use account_utils::validator_definitions::ValidatorDefinitions; use bls::PublicKey; -use clap::{App, Arg, ArgMatches}; +use clap::{Arg, ArgAction, ArgMatches, Command}; +use clap_utils::FLAG_HEADER; use std::{collections::HashSet, path::PathBuf}; pub const CMD: &str = "modify"; @@ -10,43 +11,50 @@ pub const DISABLE: &str = "disable"; pub const PUBKEY_FLAG: &str = "pubkey"; pub const ALL: &str = "all"; -pub fn cli_app<'a, 'b>() -> App<'a, 'b> { - App::new(CMD) +pub fn cli_app() -> Command { + Command::new(CMD) .about("Modify validator status in validator_definitions.yml.") + .display_order(0) .subcommand( - App::new(ENABLE) + Command::new(ENABLE) .about("Enable validator(s) in validator_definitions.yml.") .arg( - Arg::with_name(PUBKEY_FLAG) + Arg::new(PUBKEY_FLAG) .long(PUBKEY_FLAG) .value_name("PUBKEY") .help("Validator pubkey to enable") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(ALL) + Arg::new(ALL) .long(ALL) .help("Enable all validators in the validator directory") - .takes_value(false) - .conflicts_with(PUBKEY_FLAG), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .conflicts_with(PUBKEY_FLAG) + .display_order(0), ), ) .subcommand( - App::new(DISABLE) + Command::new(DISABLE) .about("Disable validator(s) in validator_definitions.yml.") .arg( - Arg::with_name(PUBKEY_FLAG) + Arg::new(PUBKEY_FLAG) .long(PUBKEY_FLAG) .value_name("PUBKEY") .help("Validator pubkey to disable") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(ALL) + Arg::new(ALL) .long(ALL) .help("Disable all validators in the validator directory") - .takes_value(false) - .conflicts_with(PUBKEY_FLAG), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .conflicts_with(PUBKEY_FLAG) + .display_order(0), ), ) } @@ -55,14 +63,15 @@ pub fn cli_run(matches: &ArgMatches, validator_dir: PathBuf) -> Result<(), Strin // `true` implies we are setting `validator_definition.enabled = true` and // vice versa. let (enabled, sub_matches) = match matches.subcommand() { - (ENABLE, Some(sub_matches)) => (true, sub_matches), - (DISABLE, Some(sub_matches)) => (false, sub_matches), - (unknown, _) => { + Some((ENABLE, sub_matches)) => (true, sub_matches), + Some((DISABLE, sub_matches)) => (false, sub_matches), + Some((unknown, _)) => { return Err(format!( "{} does not have a {} command. See --help", CMD, unknown )) } + _ => return Err(format!("No command provided for {}. See --help", CMD)), }; let mut defs = ValidatorDefinitions::open(&validator_dir).map_err(|e| { format!( @@ -70,7 +79,7 @@ pub fn cli_run(matches: &ArgMatches, validator_dir: PathBuf) -> Result<(), Strin validator_dir, e ) })?; - let pubkeys_to_modify = if sub_matches.is_present(ALL) { + let pubkeys_to_modify = if sub_matches.get_flag(ALL) { defs.as_slice() .iter() .map(|def| def.voting_public_key.clone()) diff --git a/account_manager/src/validator/recover.rs b/account_manager/src/validator/recover.rs index 33d3b189266..4677db18df3 100644 --- a/account_manager/src/validator/recover.rs +++ b/account_manager/src/validator/recover.rs @@ -4,7 +4,8 @@ use crate::wallet::create::STDIN_INPUTS_FLAG; use crate::SECRETS_DIR_FLAG; use account_utils::eth2_keystore::{keypair_from_secret, Keystore, KeystoreBuilder}; use account_utils::{random_password, read_mnemonic_from_cli}; -use clap::{App, Arg, ArgMatches}; +use clap::{Arg, ArgAction, ArgMatches, Command}; +use clap_utils::FLAG_HEADER; use directory::ensure_dir_exists; use directory::{parse_path_or_default_with_flag, DEFAULT_SECRET_DIR}; use eth2_wallet::bip39::Seed; @@ -15,70 +16,79 @@ pub const CMD: &str = "recover"; pub const FIRST_INDEX_FLAG: &str = "first-index"; pub const MNEMONIC_FLAG: &str = "mnemonic-path"; -pub fn cli_app<'a, 'b>() -> App<'a, 'b> { - App::new(CMD) +pub fn cli_app() -> Command { + Command::new(CMD) .about( "Recovers validator private keys given a BIP-39 mnemonic phrase. \ If you did not specify a `--first-index` or count `--count`, by default this will \ only recover the keys associated with the validator at index 0 for an HD wallet \ in accordance with the EIP-2333 spec.") .arg( - Arg::with_name(FIRST_INDEX_FLAG) + Arg::new(FIRST_INDEX_FLAG) .long(FIRST_INDEX_FLAG) .value_name("FIRST_INDEX") .help("The first of consecutive key indexes you wish to recover.") - .takes_value(true) + .action(ArgAction::Set) .required(false) - .default_value("0"), + .default_value("0") + .display_order(0) ) .arg( - Arg::with_name(COUNT_FLAG) + Arg::new(COUNT_FLAG) .long(COUNT_FLAG) .value_name("COUNT") .help("The number of validator keys you wish to recover. Counted consecutively from the provided `--first_index`.") - .takes_value(true) + .action(ArgAction::Set) .required(false) - .default_value("1"), + .default_value("1") + .display_order(0) ) .arg( - Arg::with_name(MNEMONIC_FLAG) + Arg::new(MNEMONIC_FLAG) .long(MNEMONIC_FLAG) .value_name("MNEMONIC_PATH") .help( "If present, the mnemonic will be read in from this file.", ) - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name(SECRETS_DIR_FLAG) + Arg::new(SECRETS_DIR_FLAG) .long(SECRETS_DIR_FLAG) .value_name("SECRETS_DIR") .help( "The path where the validator keystore passwords will be stored. \ Defaults to ~/.lighthouse/{network}/secrets", ) - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name(STORE_WITHDRAW_FLAG) + Arg::new(STORE_WITHDRAW_FLAG) .long(STORE_WITHDRAW_FLAG) .help( "If present, the withdrawal keystore will be stored alongside the voting \ keypair. It is generally recommended to *not* store the withdrawal key and \ instead generate them from the wallet seed when required.", - ), + ) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name(STDIN_INPUTS_FLAG) - .takes_value(false) - .hidden(cfg!(windows)) + Arg::new(STDIN_INPUTS_FLAG) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .hide(cfg!(windows)) .long(STDIN_INPUTS_FLAG) - .help("If present, read all user inputs from stdin instead of tty."), + .help("If present, read all user inputs from stdin instead of tty.") + .display_order(0) ) } pub fn cli_run(matches: &ArgMatches, validator_dir: PathBuf) -> Result<(), String> { - let secrets_dir = if matches.value_of("datadir").is_some() { + let secrets_dir = if matches.get_one::("datadir").is_some() { let path: PathBuf = clap_utils::parse_required(matches, "datadir")?; path.join(DEFAULT_SECRET_DIR) } else { @@ -87,7 +97,7 @@ pub fn cli_run(matches: &ArgMatches, validator_dir: PathBuf) -> Result<(), Strin let first_index: u32 = clap_utils::parse_required(matches, FIRST_INDEX_FLAG)?; let count: u32 = clap_utils::parse_required(matches, COUNT_FLAG)?; let mnemonic_path: Option = clap_utils::parse_optional(matches, MNEMONIC_FLAG)?; - let stdin_inputs = cfg!(windows) || matches.is_present(STDIN_INPUTS_FLAG); + let stdin_inputs = cfg!(windows) || matches.get_flag(STDIN_INPUTS_FLAG); eprintln!("secrets-dir path: {:?}", secrets_dir); @@ -131,7 +141,7 @@ pub fn cli_run(matches: &ArgMatches, validator_dir: PathBuf) -> Result<(), Strin .password_dir(secrets_dir.clone()) .voting_keystore(keystores.voting, voting_password.as_bytes()) .withdrawal_keystore(keystores.withdrawal, withdrawal_password.as_bytes()) - .store_withdrawal_keystore(matches.is_present(STORE_WITHDRAW_FLAG)) + .store_withdrawal_keystore(matches.get_flag(STORE_WITHDRAW_FLAG)) .build() .map_err(|e| format!("Unable to build validator directory: {:?}", e))?; diff --git a/account_manager/src/validator/slashing_protection.rs b/account_manager/src/validator/slashing_protection.rs index ff2eeb9cbfe..bcd860a4847 100644 --- a/account_manager/src/validator/slashing_protection.rs +++ b/account_manager/src/validator/slashing_protection.rs @@ -1,4 +1,4 @@ -use clap::{App, Arg, ArgMatches}; +use clap::{Arg, ArgAction, ArgMatches, Command}; use environment::Environment; use slashing_protection::{ interchange::Interchange, InterchangeError, InterchangeImportOutcome, SlashingDatabase, @@ -18,43 +18,47 @@ pub const EXPORT_FILE_ARG: &str = "EXPORT-FILE"; pub const PUBKEYS_FLAG: &str = "pubkeys"; -pub fn cli_app<'a, 'b>() -> App<'a, 'b> { - App::new(CMD) +pub fn cli_app() -> Command { + Command::new(CMD) .about("Import or export slashing protection data to or from another client") + .display_order(0) .subcommand( - App::new(IMPORT_CMD) + Command::new(IMPORT_CMD) .about("Import an interchange file") .arg( - Arg::with_name(IMPORT_FILE_ARG) - .takes_value(true) + Arg::new(IMPORT_FILE_ARG) + .action(ArgAction::Set) .value_name("FILE") + .display_order(0) .help("The slashing protection interchange file to import (.json)"), ) ) .subcommand( - App::new(EXPORT_CMD) + Command::new(EXPORT_CMD) .about("Export an interchange file") .arg( - Arg::with_name(EXPORT_FILE_ARG) - .takes_value(true) + Arg::new(EXPORT_FILE_ARG) + .action(ArgAction::Set) .value_name("FILE") - .help("The filename to export the interchange file to"), + .help("The filename to export the interchange file to") + .display_order(0) ) .arg( - Arg::with_name(PUBKEYS_FLAG) + Arg::new(PUBKEYS_FLAG) .long(PUBKEYS_FLAG) - .takes_value(true) + .action(ArgAction::Set) .value_name("PUBKEYS") .help( "List of public keys to export history for. Keys should be 0x-prefixed, \ comma-separated. All known keys will be exported if omitted", - ), + ) + .display_order(0) ) ) } pub fn cli_run( - matches: &ArgMatches<'_>, + matches: &ArgMatches, env: Environment, validator_base_dir: PathBuf, ) -> Result<(), String> { @@ -68,7 +72,7 @@ pub fn cli_run( .ok_or_else(|| "Unable to get genesis state, has genesis occurred?".to_string())?; match matches.subcommand() { - (IMPORT_CMD, Some(matches)) => { + Some((IMPORT_CMD, matches)) => { let import_filename: PathBuf = clap_utils::parse_required(matches, IMPORT_FILE_ARG)?; let import_file = File::open(&import_filename).map_err(|e| { format!( @@ -168,7 +172,7 @@ pub fn cli_run( Ok(()) } - (EXPORT_CMD, Some(matches)) => { + Some((EXPORT_CMD, matches)) => { let export_filename: PathBuf = clap_utils::parse_required(matches, EXPORT_FILE_ARG)?; let selected_pubkeys = if let Some(pubkeys) = @@ -215,7 +219,7 @@ pub fn cli_run( Ok(()) } - ("", _) => Err("No subcommand provided, see --help for options".to_string()), - (command, _) => Err(format!("No such subcommand `{}`", command)), + Some((command, _)) => Err(format!("No such subcommand `{}`", command)), + _ => Err("No subcommand provided, see --help for options".to_string()), } } diff --git a/account_manager/src/wallet/create.rs b/account_manager/src/wallet/create.rs index accee11b5a2..12aa5d3801a 100644 --- a/account_manager/src/wallet/create.rs +++ b/account_manager/src/wallet/create.rs @@ -3,7 +3,7 @@ use crate::WALLETS_DIR_FLAG; use account_utils::{ is_password_sufficiently_complex, random_password, read_password_from_user, strip_off_newlines, }; -use clap::{App, Arg, ArgMatches}; +use clap::{Arg, ArgAction, ArgMatches, Command}; use eth2_wallet::{ bip39::{Language, Mnemonic, MnemonicType}, PlainText, @@ -33,21 +33,22 @@ pub const NEW_WALLET_PASSWORD_PROMPT: &str = "Enter a password for your new wallet that is at least 12 characters long:"; pub const RETYPE_PASSWORD_PROMPT: &str = "Please re-enter your wallet's new password:"; -pub fn cli_app<'a, 'b>() -> App<'a, 'b> { - App::new(CMD) +pub fn cli_app() -> Command { + Command::new(CMD) .about("Creates a new HD (hierarchical-deterministic) EIP-2386 wallet.") .arg( - Arg::with_name(NAME_FLAG) + Arg::new(NAME_FLAG) .long(NAME_FLAG) .value_name("WALLET_NAME") .help( "The wallet will be created with this name. It is not allowed to \ create two wallets with the same name for the same --base-dir.", ) - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name(PASSWORD_FLAG) + Arg::new(PASSWORD_FLAG) .long(PASSWORD_FLAG) .value_name("WALLET_PASSWORD_PATH") .help( @@ -56,49 +57,65 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { saved at that path. To avoid confusion, if the file does not already \ exist it must include a '.pass' suffix.", ) - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name(TYPE_FLAG) + Arg::new(TYPE_FLAG) .long(TYPE_FLAG) .value_name("WALLET_TYPE") .help( "The type of wallet to create. Only HD (hierarchical-deterministic) \ wallets are supported presently..", ) - .takes_value(true) - .possible_values(&[HD_TYPE]) - .default_value(HD_TYPE), + .action(ArgAction::Set) + .value_parser([HD_TYPE]) + .default_value(HD_TYPE) + .display_order(0) ) .arg( - Arg::with_name(MNEMONIC_FLAG) + Arg::new(MNEMONIC_FLAG) .long(MNEMONIC_FLAG) .value_name("MNEMONIC_PATH") .help( "If present, the mnemonic will be saved to this file. DO NOT SHARE THE MNEMONIC.", ) - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name(STDIN_INPUTS_FLAG) - .takes_value(false) - .hidden(cfg!(windows)) + Arg::new(STDIN_INPUTS_FLAG) + .action(ArgAction::SetTrue) + .hide(cfg!(windows)) .long(STDIN_INPUTS_FLAG) - .help("If present, read all user inputs from stdin instead of tty."), + .help("If present, read all user inputs from stdin instead of tty.") + .display_order(0) ) .arg( - Arg::with_name(MNEMONIC_LENGTH_FLAG) + Arg::new(MNEMONIC_LENGTH_FLAG) .long(MNEMONIC_LENGTH_FLAG) .value_name("MNEMONIC_LENGTH") .help("The number of words to use for the mnemonic phrase.") - .takes_value(true) - .validator(|len| { - match len.parse::().ok().and_then(|words| MnemonicType::for_word_count(words).ok()) { - Some(_) => Ok(()), - None => Err(format!("Mnemonic length must be one of {}", MNEMONIC_TYPES.iter().map(|t| t.word_count().to_string()).collect::>().join(", "))), - } + .action(ArgAction::Set) + .value_parser(|len: &str| { + match len + .parse::() + .ok() + .and_then(|words| MnemonicType::for_word_count(words).ok()) + { + Some(_) => Ok(len.to_string()), + None => Err(format!( + "Mnemonic length must be one of {}", + MNEMONIC_TYPES + .iter() + .map(|t| t.word_count().to_string()) + .collect::>() + .join(", ") + )), + } }) - .default_value("24"), + .default_value("24") + .display_order(0) ) } @@ -153,7 +170,7 @@ pub fn create_wallet_from_mnemonic( let name: Option = clap_utils::parse_optional(matches, NAME_FLAG)?; let wallet_password_path: Option = clap_utils::parse_optional(matches, PASSWORD_FLAG)?; let type_field: String = clap_utils::parse_required(matches, TYPE_FLAG)?; - let stdin_inputs = cfg!(windows) || matches.is_present(STDIN_INPUTS_FLAG); + let stdin_inputs = cfg!(windows) || matches.get_flag(STDIN_INPUTS_FLAG); let wallet_type = match type_field.as_ref() { HD_TYPE => WalletType::Hd, unknown => return Err(format!("--{} {} is not supported", TYPE_FLAG, unknown)), diff --git a/account_manager/src/wallet/list.rs b/account_manager/src/wallet/list.rs index 9190de3915d..a551ffae128 100644 --- a/account_manager/src/wallet/list.rs +++ b/account_manager/src/wallet/list.rs @@ -1,12 +1,12 @@ use crate::WALLETS_DIR_FLAG; -use clap::App; +use clap::Command; use eth2_wallet_manager::WalletManager; use std::path::PathBuf; pub const CMD: &str = "list"; -pub fn cli_app<'a, 'b>() -> App<'a, 'b> { - App::new(CMD).about("Lists the names of all wallets.") +pub fn cli_app() -> Command { + Command::new(CMD).about("Lists the names of all wallets.") } pub fn cli_run(wallet_base_dir: PathBuf) -> Result<(), String> { diff --git a/account_manager/src/wallet/mod.rs b/account_manager/src/wallet/mod.rs index dfadebf57f3..59f5f362529 100644 --- a/account_manager/src/wallet/mod.rs +++ b/account_manager/src/wallet/mod.rs @@ -3,21 +3,32 @@ pub mod list; pub mod recover; use crate::WALLETS_DIR_FLAG; -use clap::{App, Arg, ArgMatches}; +use clap::{Arg, ArgAction, ArgMatches, Command}; +use clap_utils::FLAG_HEADER; use directory::{ensure_dir_exists, parse_path_or_default_with_flag, DEFAULT_WALLET_DIR}; use std::path::PathBuf; pub const CMD: &str = "wallet"; -pub fn cli_app<'a, 'b>() -> App<'a, 'b> { - App::new(CMD) +pub fn cli_app() -> Command { + Command::new(CMD) .about("Manage wallets, from which validator keys can be derived.") + .display_order(0) .arg( - Arg::with_name(WALLETS_DIR_FLAG) + Arg::new("help") + .long("help") + .short('h') + .help("Prints help information") + .action(ArgAction::HelpLong) + .display_order(0) + .help_heading(FLAG_HEADER) + ) + .arg( + Arg::new(WALLETS_DIR_FLAG) .long(WALLETS_DIR_FLAG) .value_name("WALLETS_DIRECTORY") .help("A path containing Eth2 EIP-2386 wallets. Defaults to ~/.lighthouse/{network}/wallets") - .takes_value(true) + .action(ArgAction::Set) .conflicts_with("datadir"), ) .subcommand(create::cli_app()) @@ -26,7 +37,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { } pub fn cli_run(matches: &ArgMatches) -> Result<(), String> { - let wallet_base_dir = if matches.value_of("datadir").is_some() { + let wallet_base_dir = if matches.get_one::("datadir").is_some() { let path: PathBuf = clap_utils::parse_required(matches, "datadir")?; path.join(DEFAULT_WALLET_DIR) } else { @@ -37,12 +48,13 @@ pub fn cli_run(matches: &ArgMatches) -> Result<(), String> { eprintln!("wallet-dir path: {:?}", wallet_base_dir); match matches.subcommand() { - (create::CMD, Some(matches)) => create::cli_run(matches, wallet_base_dir), - (list::CMD, Some(_)) => list::cli_run(wallet_base_dir), - (recover::CMD, Some(matches)) => recover::cli_run(matches, wallet_base_dir), - (unknown, _) => Err(format!( + Some((create::CMD, matches)) => create::cli_run(matches, wallet_base_dir), + Some((list::CMD, _)) => list::cli_run(wallet_base_dir), + Some((recover::CMD, matches)) => recover::cli_run(matches, wallet_base_dir), + Some((unknown, _)) => Err(format!( "{} does not have a {} command. See --help", CMD, unknown )), + _ => Err("No subcommand provided, see --help for options".to_string()), } } diff --git a/account_manager/src/wallet/recover.rs b/account_manager/src/wallet/recover.rs index 6e047aca8d2..b9641f11521 100644 --- a/account_manager/src/wallet/recover.rs +++ b/account_manager/src/wallet/recover.rs @@ -1,27 +1,28 @@ use crate::wallet::create::{create_wallet_from_mnemonic, STDIN_INPUTS_FLAG}; use crate::wallet::create::{HD_TYPE, NAME_FLAG, PASSWORD_FLAG, TYPE_FLAG}; use account_utils::read_mnemonic_from_cli; -use clap::{App, Arg, ArgMatches}; +use clap::{Arg, ArgAction, ArgMatches, Command}; use std::path::PathBuf; pub const CMD: &str = "recover"; pub const MNEMONIC_FLAG: &str = "mnemonic-path"; -pub fn cli_app<'a, 'b>() -> App<'a, 'b> { - App::new(CMD) +pub fn cli_app() -> Command { + Command::new(CMD) .about("Recovers an EIP-2386 wallet from a given a BIP-39 mnemonic phrase.") .arg( - Arg::with_name(NAME_FLAG) + Arg::new(NAME_FLAG) .long(NAME_FLAG) .value_name("WALLET_NAME") .help( "The wallet will be created with this name. It is not allowed to \ create two wallets with the same name for the same --base-dir.", ) - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(PASSWORD_FLAG) + Arg::new(PASSWORD_FLAG) .long(PASSWORD_FLAG) .value_name("PASSWORD_FILE_PATH") .help( @@ -31,39 +32,43 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { saved at that path. To avoid confusion, if the file does not already \ exist it must include a '.pass' suffix.", ) - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(MNEMONIC_FLAG) + Arg::new(MNEMONIC_FLAG) .long(MNEMONIC_FLAG) .value_name("MNEMONIC_PATH") .help("If present, the mnemonic will be read in from this file.") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(TYPE_FLAG) + Arg::new(TYPE_FLAG) .long(TYPE_FLAG) .value_name("WALLET_TYPE") .help( "The type of wallet to create. Only HD (hierarchical-deterministic) \ wallets are supported presently..", ) - .takes_value(true) - .possible_values(&[HD_TYPE]) - .default_value(HD_TYPE), + .action(ArgAction::Set) + .value_parser([HD_TYPE]) + .default_value(HD_TYPE) + .display_order(0), ) .arg( - Arg::with_name(STDIN_INPUTS_FLAG) - .takes_value(false) - .hidden(cfg!(windows)) + Arg::new(STDIN_INPUTS_FLAG) + .action(ArgAction::SetTrue) + .hide(cfg!(windows)) .long(STDIN_INPUTS_FLAG) - .help("If present, read all user inputs from stdin instead of tty."), + .help("If present, read all user inputs from stdin instead of tty.") + .display_order(0), ) } pub fn cli_run(matches: &ArgMatches, wallet_base_dir: PathBuf) -> Result<(), String> { let mnemonic_path: Option = clap_utils::parse_optional(matches, MNEMONIC_FLAG)?; - let stdin_inputs = cfg!(windows) || matches.is_present(STDIN_INPUTS_FLAG); + let stdin_inputs = cfg!(windows) || matches.get_flag(STDIN_INPUTS_FLAG); eprintln!(); eprintln!("WARNING: KEY RECOVERY CAN LEAD TO DUPLICATING VALIDATORS KEYS, WHICH CAN LEAD TO SLASHING."); diff --git a/beacon_node/src/cli.rs b/beacon_node/src/cli.rs index 81c2196b754..bb7b7535334 100644 --- a/beacon_node/src/cli.rs +++ b/beacon_node/src/cli.rs @@ -1,12 +1,14 @@ -use clap::{App, Arg, ArgGroup}; +use clap::{builder::ArgPredicate, crate_version, Arg, ArgAction, ArgGroup, Command}; +use clap_utils::{get_color_style, FLAG_HEADER}; use strum::VariantNames; -pub fn cli_app<'a, 'b>() -> App<'a, 'b> { - App::new("beacon_node") - .visible_aliases(&["b", "bn", "beacon"]) +pub fn cli_app() -> Command { + Command::new("beacon_node") + .display_order(0) + .visible_aliases(["b", "bn", "beacon"]) .version(crate_version!()) .author("Sigma Prime ") - .setting(clap::AppSettings::ColoredHelp) + .styles(get_color_style()) .about("The primary component which connects to the Ethereum 2.0 P2P network and \ downloads, verifies and stores blocks. Provides a HTTP API for querying \ the beacon chain and publishing messages to the network.") @@ -14,68 +16,91 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { * Configuration directory locations. */ .arg( - Arg::with_name("network-dir") + Arg::new("help") + .long("help") + .short('h') + .help("Prints help information") + .action(ArgAction::HelpLong) + .display_order(0) + .help_heading(FLAG_HEADER) + ) + .arg( + Arg::new("network-dir") .long("network-dir") .value_name("DIR") .help("Data directory for network keys. Defaults to network/ inside the beacon node \ dir.") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("freezer-dir") + Arg::new("freezer-dir") .long("freezer-dir") .value_name("DIR") .help("Data directory for the freezer database.") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("blobs-dir") + Arg::new("blobs-dir") .long("blobs-dir") .value_name("DIR") .help("Data directory for the blobs database.") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) /* * Network parameters. */ .arg( - Arg::with_name("subscribe-all-subnets") + Arg::new("subscribe-all-subnets") .long("subscribe-all-subnets") + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .help("Subscribe to all subnets regardless of validator count. \ This will also advertise the beacon node as being long-lived subscribed to all subnets.") - .takes_value(false), + .display_order(0) ) .arg( - Arg::with_name("import-all-attestations") + Arg::new("import-all-attestations") .long("import-all-attestations") .help("Import and aggregate all attestations, regardless of validator subscriptions. \ This will only import attestations from already-subscribed subnets, use with \ --subscribe-all-subnets to ensure all attestations are received for import.") - .takes_value(false), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .global(true) + .display_order(0) ) .arg( - Arg::with_name("disable-packet-filter") + Arg::new("disable-packet-filter") .long("disable-packet-filter") .help("Disables the discovery packet filter. Useful for testing in smaller networks") - .takes_value(false), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("shutdown-after-sync") + Arg::new("shutdown-after-sync") .long("shutdown-after-sync") .help("Shutdown beacon node as soon as sync is completed. Backfill sync will \ not be performed before shutdown.") - .takes_value(false), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("zero-ports") + Arg::new("zero-ports") .long("zero-ports") - .short("z") + .short('z') .help("Sets all listening TCP/UDP ports to 0, allowing the OS to choose some \ arbitrary free ports.") - .takes_value(false), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("listen-address") + Arg::new("listen-address") .long("listen-address") .value_name("ADDRESS") .help("The address lighthouse will listen for UDP and TCP connections. To listen \ @@ -86,13 +111,13 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { - --listen-address '0.0.0.0' --listen-address '::' will listen over both \ IPv4 and IPv6. The order of the given addresses is not relevant. However, \ multiple IPv4, or multiple IPv6 addresses will not be accepted.") - .multiple(true) - .max_values(2) + .action(ArgAction::Append) + .num_args(0..=2) .default_value("0.0.0.0") - .takes_value(true) + .display_order(0) ) .arg( - Arg::with_name("port") + Arg::new("port") .long("port") .value_name("PORT") .help("The TCP/UDP ports to listen on. There are two UDP ports. \ @@ -100,134 +125,153 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { --discovery-port flag and the quic port can be modified by the --quic-port flag. If listening over both IPv4 and IPv6 the --port flag \ will apply to the IPv4 address and --port6 to the IPv6 address.") .default_value("9000") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("port6") + Arg::new("port6") .long("port6") .value_name("PORT") .help("The TCP/UDP ports to listen on over IPv6 when listening over both IPv4 and \ IPv6. Defaults to 9090 when required. The Quic UDP port will be set to this value + 1.") .default_value("9090") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("discovery-port") + Arg::new("discovery-port") .long("discovery-port") .value_name("PORT") .help("The UDP port that discovery will listen on. Defaults to `port`") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("quic-port") + Arg::new("quic-port") .long("quic-port") .value_name("PORT") .help("The UDP port that quic will listen on. Defaults to `port` + 1") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("discovery-port6") + Arg::new("discovery-port6") .long("discovery-port6") .value_name("PORT") .help("The UDP port that discovery will listen on over IPv6 if listening over \ both IPv4 and IPv6. Defaults to `port6`") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("quic-port6") + Arg::new("quic-port6") .long("quic-port6") .value_name("PORT") .help("The UDP port that quic will listen on over IPv6 if listening over \ both IPv4 and IPv6. Defaults to `port6` + 1") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("target-peers") + Arg::new("target-peers") .long("target-peers") .help("The target number of peers.") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("boot-nodes") + Arg::new("boot-nodes") .long("boot-nodes") .allow_hyphen_values(true) .value_name("ENR/MULTIADDR LIST") .help("One or more comma-delimited base64-encoded ENR's to bootstrap the p2p network. Multiaddr is also supported.") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("network-load") + Arg::new("network-load") .long("network-load") .value_name("INTEGER") .help("Lighthouse's network can be tuned for bandwidth/performance. Setting this to a high value, will increase the bandwidth lighthouse uses, increasing the likelihood of redundant information in exchange for faster communication. This can increase profit of validators marginally by receiving messages faster on the network. Lower values decrease bandwidth usage, but makes communication slower which can lead to validator performance reduction. Values are in the range [1,5].") .default_value("3") - .set(clap::ArgSettings::Hidden) - .takes_value(true), + .hide(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("disable-upnp") + Arg::new("disable-upnp") .long("disable-upnp") .help("Disables UPnP support. Setting this will prevent Lighthouse from attempting to automatically establish external port mappings.") - .takes_value(false), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("private") + Arg::new("private") .long("private") .help("Prevents sending various client identification information.") - .takes_value(false), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("enr-udp-port") + Arg::new("enr-udp-port") .long("enr-udp-port") .value_name("PORT") .help("The UDP4 port of the local ENR. Set this only if you are sure other nodes \ can connect to your local node on this port over IPv4.") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("enr-quic-port") + Arg::new("enr-quic-port") .long("enr-quic-port") .value_name("PORT") .help("The quic UDP4 port that will be set on the local ENR. Set this only if you are sure other nodes \ can connect to your local node on this port over IPv4.") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("enr-udp6-port") + Arg::new("enr-udp6-port") .long("enr-udp6-port") .value_name("PORT") .help("The UDP6 port of the local ENR. Set this only if you are sure other nodes \ can connect to your local node on this port over IPv6.") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("enr-quic6-port") + Arg::new("enr-quic6-port") .long("enr-quic6-port") .value_name("PORT") .help("The quic UDP6 port that will be set on the local ENR. Set this only if you are sure other nodes \ can connect to your local node on this port over IPv6.") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("enr-tcp-port") + Arg::new("enr-tcp-port") .long("enr-tcp-port") .value_name("PORT") .help("The TCP4 port of the local ENR. Set this only if you are sure other nodes \ can connect to your local node on this port over IPv4. The --port flag is \ used if this is not set.") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("enr-tcp6-port") + Arg::new("enr-tcp6-port") .long("enr-tcp6-port") .value_name("PORT") .help("The TCP6 port of the local ENR. Set this only if you are sure other nodes \ can connect to your local node on this port over IPv6. The --port6 flag is \ used if this is not set.") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("enr-address") + Arg::new("enr-address") .long("enr-address") .value_name("ADDRESS") .help("The IP address/ DNS address to broadcast to other peers on how to reach \ @@ -236,76 +280,110 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { discovery. Set this only if you are sure other nodes can connect to your \ local node on this address. This will update the `ip4` or `ip6` ENR fields \ accordingly. To update both, set this flag twice with the different values.") - .multiple(true) - .max_values(2) - .takes_value(true), + .action(ArgAction::Append) + .num_args(1..=2) + .display_order(0) ) .arg( - Arg::with_name("enr-match") - .short("e") + Arg::new("enr-match") + .short('e') .long("enr-match") + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .help("Sets the local ENR IP address and port to match those set for lighthouse. \ Specifically, the IP address will be the value of --listen-address and the \ UDP port will be --discovery-port.") + .display_order(0) ) .arg( - Arg::with_name("disable-enr-auto-update") - .short("x") + Arg::new("disable-enr-auto-update") + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .long("disable-enr-auto-update") .help("Discovery automatically updates the nodes local ENR with an external IP address and port as seen by other peers on the network. \ - This disables this feature, fixing the ENR's IP/PORT to those specified on boot."), + This disables this feature, fixing the ENR's IP/PORT to those specified on boot.") + .display_order(0) ) .arg( - Arg::with_name("libp2p-addresses") + Arg::new("libp2p-addresses") .long("libp2p-addresses") .value_name("MULTIADDR") .help("One or more comma-delimited multiaddrs to manually connect to a libp2p peer \ without an ENR.") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) - // NOTE: This is hidden because it is primarily a developer feature for testnets and + // NOTE: This is hide because it is primarily a developer feature for testnets and // debugging. We remove it from the list to avoid clutter. .arg( - Arg::with_name("disable-discovery") + Arg::new("disable-discovery") .long("disable-discovery") + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .help("Disables the discv5 discovery protocol. The node will not search for new peers or participate in the discovery protocol.") - .hidden(true) + .hide(true) + .display_order(0) ) .arg( - Arg::with_name("disable-quic") + Arg::new("disable-quic") .long("disable-quic") + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .help("Disables the quic transport. The node will rely solely on the TCP transport for libp2p connections.") + .display_order(0) ) .arg( - Arg::with_name("disable-peer-scoring") + Arg::new("disable-peer-scoring") .long("disable-peer-scoring") .help("Disables peer scoring in lighthouse. WARNING: This is a dev only flag is only meant to be used in local testing scenarios \ Using this flag on a real network may cause your node to become eclipsed and see a different view of the network") - .takes_value(false) - .hidden(true), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .hide(true) + .display_order(0) ) .arg( - Arg::with_name("trusted-peers") + Arg::new("trusted-peers") .long("trusted-peers") .value_name("TRUSTED_PEERS") .help("One or more comma-delimited trusted peer ids which always have the highest score according to the peer scoring system.") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) + .display_order(0) ) .arg( - Arg::with_name("genesis-backfill") + Arg::new("genesis-backfill") .long("genesis-backfill") .help("Attempts to download blocks all the way back to genesis when checkpoint syncing.") - .takes_value(false), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("enable-private-discovery") + Arg::new("enable-private-discovery") .long("enable-private-discovery") .help("Lighthouse by default does not discover private IP addresses. Set this flag to enable connection attempts to local addresses.") - .takes_value(false), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("self-limiter") + Arg::new("self-limiter") .long("self-limiter") + .help( + "Enables the outbound rate limiter (requests made by this node). \ + Use the self-limiter-protocol flag to set per protocol configurations. \ + If the self rate limiter is enabled and a protocol is not \ + present in the configuration, the quotas used for the inbound rate limiter will be \ + used." + ) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) + ) + .arg( + Arg::new("self-limiter-protocols") + .long("self-limiter-protocols") .help( "Enables the outbound rate limiter (requests made by this node).\ \ @@ -315,69 +393,89 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { present in the configuration, the quotas used for the inbound rate limiter will be \ used." ) - .min_values(0) - .hidden(true) + .action(ArgAction::Append) + .value_delimiter(';') + .requires("self-limiter") + .display_order(0) ) .arg( - Arg::with_name("proposer-only") + Arg::new("proposer-only") .long("proposer-only") .help("Sets this beacon node at be a block proposer only node. \ This will run the beacon node in a minimal configuration that is sufficient for block publishing only. This flag should be used \ for a beacon node being referenced by validator client using the --proposer-node flag. This configuration is for enabling more secure setups.") - .takes_value(false), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) + ) + .arg( + Arg::new("disable-inbound-rate-limiter") + .long("disable-inbound-rate-limiter") + .help( + "Disables the inbound rate limiter (requests received by this node)." + ) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("inbound-rate-limiter") - .long("inbound-rate-limiter") + Arg::new("inbound-rate-limiter-protocols") + .long("inbound-rate-limiter-protocols") .help( "Configures the inbound rate limiter (requests received by this node).\ \ Rate limit quotas per protocol can be set in the form of \ :/. To set quotas for multiple protocols, \ - separate them by ';'. If the inbound rate limiter is enabled and a protocol is not \ - present in the configuration, the default quotas will be used. \ + separate them by ';'. \ \ - This is enabled by default, using default quotas. To disable rate limiting pass \ - `disabled` to this option instead." + This is enabled by default, using default quotas. To disable rate limiting use \ + the disable-inbound-rate-limiter flag instead." ) - .takes_value(true) - .hidden(true) + .action(ArgAction::Set) + .conflicts_with("disable-inbound-rate-limiter") + .display_order(0) ) .arg( - Arg::with_name("disable-backfill-rate-limiting") + Arg::new("disable-backfill-rate-limiting") .long("disable-backfill-rate-limiting") .help("Disable the backfill sync rate-limiting. This allow users to just sync the entire chain as fast \ as possible, however it can result in resource contention which degrades staking performance. Stakers \ should generally choose to avoid this flag since backfill sync is not required for staking.") - .takes_value(false), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) /* REST API related arguments */ .arg( - Arg::with_name("http") + Arg::new("http") .long("http") .help("Enable the RESTful HTTP API server. Disabled by default.") - .takes_value(false), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("http-address") + Arg::new("http-address") .long("http-address") .requires("enable_http") .value_name("ADDRESS") .help("Set the listen address for the RESTful HTTP API server.") - .default_value_if("enable_http", None, "127.0.0.1") - .takes_value(true), + .default_value_if("enable_http", ArgPredicate::IsPresent, "127.0.0.1") + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("http-port") + Arg::new("http-port") .long("http-port") .requires("enable_http") .value_name("PORT") .help("Set the listen TCP port for the RESTful HTTP API server.") - .default_value_if("enable_http", None, "5052") - .takes_value(true), + .default_value_if("enable_http", ArgPredicate::IsPresent, "5052") + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("http-allow-origin") + Arg::new("http-allow-origin") .long("http-allow-origin") .requires("enable_http") .value_name("ORIGIN") @@ -385,71 +483,82 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { Use * to allow any origin (not recommended in production). \ If no value is supplied, the CORS allowed origin is set to the listen \ address of this server (e.g., http://localhost:5052).") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("http-spec-fork") + Arg::new("http-spec-fork") .long("http-spec-fork") .requires("enable_http") .value_name("FORK") .help("This flag is deprecated and has no effect.") - .takes_value(true) - .hidden(true) + .hide(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("http-enable-tls") + Arg::new("http-enable-tls") .long("http-enable-tls") .help("Serves the RESTful HTTP API server over TLS. This feature is currently \ experimental.") - .takes_value(false) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .requires("http-tls-cert") .requires("http-tls-key") + .display_order(0) ) .arg( - Arg::with_name("http-tls-cert") + Arg::new("http-tls-cert") .long("http-tls-cert") .requires("enable_http") .help("The path of the certificate to be used when serving the HTTP API server \ over TLS.") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("http-tls-key") + Arg::new("http-tls-key") .long("http-tls-key") .requires("enable_http") .help("The path of the private key to be used when serving the HTTP API server \ over TLS. Must not be password-protected.") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("http-allow-sync-stalled") + Arg::new("http-allow-sync-stalled") .long("http-allow-sync-stalled") + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .requires("enable_http") .help("This flag is deprecated and has no effect.") - .hidden(true) + .hide(true) + .display_order(0) ) .arg( - Arg::with_name("http-sse-capacity-multiplier") + Arg::new("http-sse-capacity-multiplier") .long("http-sse-capacity-multiplier") .requires("enable_http") - .takes_value(true) - .default_value_if("enable_http", None, "1") + .action(ArgAction::Set) + .default_value_if("enable_http", ArgPredicate::IsPresent, "1") .value_name("N") .help("Multiplier to apply to the length of HTTP server-sent-event (SSE) channels. \ Increasing this value can prevent messages from being dropped.") + .display_order(0) ) .arg( - Arg::with_name("http-duplicate-block-status") + Arg::new("http-duplicate-block-status") .long("http-duplicate-block-status") .requires("enable_http") - .takes_value(true) - .default_value_if("enable_http", None, "202") + .action(ArgAction::Set) + .default_value_if("enable_http", ArgPredicate::IsPresent, "202") .value_name("STATUS_CODE") .help("Status code to send when a block that is already known is POSTed to the \ HTTP API.") + .display_order(0) ) .arg( - Arg::with_name("http-enable-beacon-processor") + Arg::new("http-enable-beacon-processor") .long("http-enable-beacon-processor") .requires("enable_http") .value_name("BOOLEAN") @@ -457,36 +566,41 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { DoS protection. When set to \"true\", HTTP API requests will be queued and scheduled \ alongside other tasks. When set to \"false\", HTTP API responses will be executed \ immediately.") - .takes_value(true) - .default_value_if("enable_http", None, "true") + .action(ArgAction::Set) + .display_order(0) + .default_value_if("enable_http", ArgPredicate::IsPresent, "true") ) /* Prometheus metrics HTTP server related arguments */ .arg( - Arg::with_name("metrics") + Arg::new("metrics") .long("metrics") .help("Enable the Prometheus metrics HTTP server. Disabled by default.") - .takes_value(false), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("metrics-address") + Arg::new("metrics-address") .long("metrics-address") .value_name("ADDRESS") .requires("metrics") .help("Set the listen address for the Prometheus metrics HTTP server.") - .default_value_if("metrics", None, "127.0.0.1") - .takes_value(true), + .default_value_if("metrics", ArgPredicate::IsPresent, "127.0.0.1") + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("metrics-port") + Arg::new("metrics-port") .long("metrics-port") .requires("metrics") .value_name("PORT") .help("Set the listen TCP port for the Prometheus metrics HTTP server.") - .default_value_if("metrics", None, "5054") - .takes_value(true), + .default_value_if("metrics", ArgPredicate::IsPresent, "5054") + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("metrics-allow-origin") + Arg::new("metrics-allow-origin") .long("metrics-allow-origin") .value_name("ORIGIN") .requires("metrics") @@ -494,15 +608,17 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { Use * to allow any origin (not recommended in production). \ If no value is supplied, the CORS allowed origin is set to the listen \ address of this server (e.g., http://localhost:5054).") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("shuffling-cache-size") + Arg::new("shuffling-cache-size") .long("shuffling-cache-size") .help("Some HTTP API requests can be optimised by caching the shufflings at each epoch. \ This flag allows the user to set the shuffling cache size in epochs. \ Shufflings are dependent on validator count and setting this value to a large number can consume a large amount of memory.") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) /* @@ -510,7 +626,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { */ .arg( - Arg::with_name("monitoring-endpoint") + Arg::new("monitoring-endpoint") .long("monitoring-endpoint") .value_name("ADDRESS") .help("Enables the monitoring service for sending system metrics to a remote endpoint. \ @@ -519,16 +635,18 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { Note: This will send information to a remote sever which may identify and associate your \ validators, IP address and other personal information. Always use a HTTPS connection \ and never provide an untrusted URL.") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("monitoring-endpoint-period") + Arg::new("monitoring-endpoint-period") .long("monitoring-endpoint-period") .value_name("SECONDS") .help("Defines how many seconds to wait between each message sent to \ the monitoring-endpoint. Default: 60s") .requires("monitoring-endpoint") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) /* @@ -536,122 +654,143 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { */ .arg( - Arg::with_name("staking") + Arg::new("staking") .long("staking") .help("Standard option for a staking beacon node. This will enable the HTTP server \ on localhost:5052 and import deposit logs from the execution node. This is \ equivalent to `--http` on merge-ready networks, or `--http --eth1` pre-merge") - .takes_value(false) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) /* * Eth1 Integration */ .arg( - Arg::with_name("eth1") + Arg::new("eth1") .long("eth1") .help("If present the node will connect to an eth1 node. This is required for \ block production, you must use this flag if you wish to serve a validator.") - .takes_value(false), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("dummy-eth1") + Arg::new("dummy-eth1") .long("dummy-eth1") + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .conflicts_with("eth1") .help("If present, uses an eth1 backend that generates static dummy data.\ Identical to the method used at the 2019 Canada interop.") + .display_order(0) ) .arg( - Arg::with_name("eth1-purge-cache") + Arg::new("eth1-purge-cache") .long("eth1-purge-cache") .value_name("PURGE-CACHE") .help("Purges the eth1 block and deposit caches") - .takes_value(false) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("eth1-blocks-per-log-query") + Arg::new("eth1-blocks-per-log-query") .long("eth1-blocks-per-log-query") .value_name("BLOCKS") .help("Specifies the number of blocks that a deposit log query should span. \ This will reduce the size of responses from the Eth1 endpoint.") .default_value("1000") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("eth1-cache-follow-distance") + Arg::new("eth1-cache-follow-distance") .long("eth1-cache-follow-distance") .value_name("BLOCKS") .help("Specifies the distance between the Eth1 chain head and the last block which \ should be imported into the cache. Setting this value lower can help \ compensate for irregular Proof-of-Work block times, but setting it too low \ can make the node vulnerable to re-orgs.") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("slots-per-restore-point") + Arg::new("slots-per-restore-point") .long("slots-per-restore-point") .value_name("SLOT_COUNT") .help("Specifies how often a freezer DB restore point should be stored. \ Cannot be changed after initialization. \ [default: 8192 (mainnet) or 64 (minimal)]") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("epochs-per-migration") + Arg::new("epochs-per-migration") .long("epochs-per-migration") .value_name("N") .help("The number of epochs to wait between running the migration of data from the \ hot DB to the cold DB. Less frequent runs can be useful for minimizing disk \ writes") .default_value("1") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("block-cache-size") + Arg::new("block-cache-size") .long("block-cache-size") .value_name("SIZE") - .help("Specifies how many blocks the database should cache in memory [default: 5]") - .takes_value(true) + .help("Specifies how many blocks the database should cache in memory") + .default_value("5") + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("historic-state-cache-size") + Arg::new("historic-state-cache-size") .long("historic-state-cache-size") .value_name("SIZE") - .help("Specifies how many states from the freezer database should cache in memory [default: 1]") - .takes_value(true) + .help("Specifies how many states from the freezer database should cache in memory") + .default_value("1") + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("state-cache-size") + Arg::new("state-cache-size") .long("state-cache-size") .value_name("STATE_CACHE_SIZE") - .help("Specifies the size of the state cache [default: 128]") - .takes_value(true) + .help("Specifies the size of the state cache") + .default_value("128") + .action(ArgAction::Set) + .display_order(0) ) /* * Execution Layer Integration */ .arg( - Arg::with_name("execution-endpoint") + Arg::new("execution-endpoint") .long("execution-endpoint") .value_name("EXECUTION-ENDPOINT") .alias("execution-endpoints") .help("Server endpoint for an execution layer JWT-authenticated HTTP \ JSON-RPC connection. Uses the same endpoint to populate the \ deposit cache.") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("execution-jwt") + Arg::new("execution-jwt") .long("execution-jwt") .value_name("EXECUTION-JWT") .alias("jwt-secrets") .help("File path which contains the hex-encoded JWT secret for the \ execution endpoint provided in the --execution-endpoint flag.") .requires("execution-endpoint") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("execution-jwt-secret-key") + Arg::new("execution-jwt-secret-key") .long("execution-jwt-secret-key") .value_name("EXECUTION-JWT-SECRET-KEY") .alias("jwt-secret-key") @@ -659,10 +798,11 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { execution endpoint provided in the --execution-endpoint flag.") .requires("execution-endpoint") .conflicts_with("execution-jwt") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("execution-jwt-id") + Arg::new("execution-jwt-id") .long("execution-jwt-id") .value_name("EXECUTION-JWT-ID") .alias("jwt-id") @@ -670,10 +810,11 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { during JWT authentication. It corresponds to the 'id' field in the JWT claims object.\ Set to empty by default") .requires("execution-jwt") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("execution-jwt-version") + Arg::new("execution-jwt-version") .long("execution-jwt-version") .value_name("EXECUTION-JWT-VERSION") .alias("jwt-version") @@ -681,119 +822,136 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { during JWT authentication. It corresponds to the 'clv' field in the JWT claims object.\ Set to empty by default") .requires("execution-jwt") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("suggested-fee-recipient") + Arg::new("suggested-fee-recipient") .long("suggested-fee-recipient") .value_name("SUGGESTED-FEE-RECIPIENT") .help("Emergency fallback fee recipient for use in case the validator client does \ not have one configured. You should set this flag on the validator \ client instead of (or in addition to) setting it here.") .requires("execution-endpoint") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("builder") + Arg::new("builder") .long("builder") .alias("payload-builder") .alias("payload-builders") .help("The URL of a service compatible with the MEV-boost API.") .requires("execution-endpoint") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("execution-timeout-multiplier") + Arg::new("execution-timeout-multiplier") .long("execution-timeout-multiplier") .value_name("NUM") .help("Unsigned integer to multiply the default execution timeouts by.") .default_value("1") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) /* Deneb settings */ .arg( - Arg::with_name("trusted-setup-file-override") + Arg::new("trusted-setup-file-override") .long("trusted-setup-file-override") .value_name("FILE") .help("Path to a json file containing the trusted setup params. \ NOTE: This will override the trusted setup that is generated \ from the mainnet kzg ceremony. Use with caution") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) /* * Database purging and compaction. */ .arg( - Arg::with_name("purge-db") + Arg::new("purge-db") .long("purge-db") + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .help("If present, the chain database will be deleted. Use with caution.") + .display_order(0) ) .arg( - Arg::with_name("compact-db") + Arg::new("compact-db") .long("compact-db") + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .help("If present, apply compaction to the database on start-up. Use with caution. \ It is generally not recommended unless auto-compaction is disabled.") + .display_order(0) ) .arg( - Arg::with_name("auto-compact-db") + Arg::new("auto-compact-db") .long("auto-compact-db") .help("Enable or disable automatic compaction of the database on finalization.") - .takes_value(true) + .action(ArgAction::Set) .default_value("true") + .display_order(0) ) .arg( - Arg::with_name("prune-payloads") + Arg::new("prune-payloads") .long("prune-payloads") .help("Prune execution payloads from Lighthouse's database. This saves space but \ imposes load on the execution client, as payloads need to be \ reconstructed and sent to syncing peers.") - .takes_value(true) + .action(ArgAction::Set) .default_value("true") + .display_order(0) ) .arg( - Arg::with_name("prune-blobs") + Arg::new("prune-blobs") .long("prune-blobs") .value_name("BOOLEAN") .help("Prune blobs from Lighthouse's database when they are older than the data \ data availability boundary relative to the current epoch.") - .takes_value(true) + .action(ArgAction::Set) .default_value("true") + .display_order(0) ) .arg( - Arg::with_name("epochs-per-blob-prune") + Arg::new("epochs-per-blob-prune") .long("epochs-per-blob-prune") .value_name("EPOCHS") .help("The epoch interval with which to prune blobs from Lighthouse's \ database when they are older than the data availability boundary \ relative to the current epoch.") - .takes_value(true) + .action(ArgAction::Set) .default_value("1") + .display_order(0) ) .arg( - Arg::with_name("blob-prune-margin-epochs") + Arg::new("blob-prune-margin-epochs") .long("blob-prune-margin-epochs") .value_name("EPOCHS") .help("The margin for blob pruning in epochs. The oldest blobs are pruned \ up until data_availability_boundary - blob_prune_margin_epochs.") - .takes_value(true) + .action(ArgAction::Set) .default_value("0") + .display_order(0) ) /* * Misc. */ .arg( - Arg::with_name("graffiti") + Arg::new("graffiti") .long("graffiti") .help( "Specify your custom graffiti to be included in blocks. \ Defaults to the current version and commit, truncated to fit in 32 bytes. " ) .value_name("GRAFFITI") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("max-skip-slots") + Arg::new("max-skip-slots") .long("max-skip-slots") .help( "Refuse to skip more than this many slots when processing an attestation. \ @@ -801,43 +959,48 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { but could also cause unnecessary consensus failures, so is disabled by default." ) .value_name("NUM_SLOTS") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) /* * Slasher. */ .arg( - Arg::with_name("slasher") + Arg::new("slasher") .long("slasher") .help( "Run a slasher alongside the beacon node. It is currently only recommended for \ expert users because of the immaturity of the slasher UX and the extra \ resources required." ) - .takes_value(false) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("slasher-dir") + Arg::new("slasher-dir") .long("slasher-dir") .help( "Set the slasher's database directory." ) .value_name("PATH") - .takes_value(true) + .action(ArgAction::Set) .requires("slasher") + .display_order(0) ) .arg( - Arg::with_name("slasher-update-period") + Arg::new("slasher-update-period") .long("slasher-update-period") .help( "Configure how often the slasher runs batch processing." ) .value_name("SECONDS") .requires("slasher") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("slasher-slot-offset") + Arg::new("slasher-slot-offset") .long("slasher-slot-offset") .help( "Set the delay from the start of the slot at which the slasher should ingest \ @@ -846,10 +1009,11 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { ) .value_name("SECONDS") .requires("slasher") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("slasher-history-length") + Arg::new("slasher-history-length") .long("slasher-history-length") .help( "Configure how many epochs of history the slasher keeps. Immutable after \ @@ -857,65 +1021,72 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { ) .value_name("EPOCHS") .requires("slasher") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("slasher-max-db-size") + Arg::new("slasher-max-db-size") .long("slasher-max-db-size") .help( "Maximum size of the MDBX database used by the slasher." ) .value_name("GIGABYTES") .requires("slasher") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("slasher-att-cache-size") + Arg::new("slasher-att-cache-size") .long("slasher-att-cache-size") .help("Set the maximum number of attestation roots for the slasher to cache") .value_name("COUNT") .requires("slasher") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("slasher-chunk-size") + Arg::new("slasher-chunk-size") .long("slasher-chunk-size") .help( "Number of epochs per validator per chunk stored on disk." ) .value_name("EPOCHS") .requires("slasher") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("slasher-validator-chunk-size") + Arg::new("slasher-validator-chunk-size") .long("slasher-validator-chunk-size") .help( "Number of validators per chunk stored on disk." ) .value_name("NUM_VALIDATORS") .requires("slasher") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("slasher-broadcast") + Arg::new("slasher-broadcast") .long("slasher-broadcast") .help("Broadcast slashings found by the slasher to the rest of the network \ [Enabled by default].") - .takes_value(true) + .action(ArgAction::Set) .default_value("true") + .display_order(0) ) .arg( - Arg::with_name("slasher-backend") + Arg::new("slasher-backend") .long("slasher-backend") .value_name("DATABASE") .help("Set the database backend to be used by the slasher.") - .takes_value(true) - .possible_values(slasher::DatabaseBackend::VARIANTS) + .action(ArgAction::Set) + .value_parser(slasher::DatabaseBackend::VARIANTS.to_vec()) .requires("slasher") + .display_order(0) ) .arg( - Arg::with_name("wss-checkpoint") + Arg::new("wss-checkpoint") .long("wss-checkpoint") .help( "Specify a weak subjectivity checkpoint in `block_root:epoch` format to verify \ @@ -924,94 +1095,109 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { state use --checkpoint-sync-url." ) .value_name("WSS_CHECKPOINT") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("checkpoint-state") + Arg::new("checkpoint-state") .long("checkpoint-state") .help("Set a checkpoint state to start syncing from. Must be aligned and match \ --checkpoint-block. Using --checkpoint-sync-url instead is recommended.") .value_name("STATE_SSZ") - .takes_value(true) + .action(ArgAction::Set) .requires("checkpoint-block") + .display_order(0) ) .arg( - Arg::with_name("checkpoint-block") + Arg::new("checkpoint-block") .long("checkpoint-block") .help("Set a checkpoint block to start syncing from. Must be aligned and match \ --checkpoint-state. Using --checkpoint-sync-url instead is recommended.") .value_name("BLOCK_SSZ") - .takes_value(true) + .action(ArgAction::Set) .requires("checkpoint-state") + .display_order(0) ) .arg( - Arg::with_name("checkpoint-blobs") + Arg::new("checkpoint-blobs") .long("checkpoint-blobs") .help("Set the checkpoint blobs to start syncing from. Must be aligned and match \ --checkpoint-block. Using --checkpoint-sync-url instead is recommended.") .value_name("BLOBS_SSZ") - .takes_value(true) + .action(ArgAction::Set) .requires("checkpoint-block") + .display_order(0) ) .arg( - Arg::with_name("checkpoint-sync-url") + Arg::new("checkpoint-sync-url") .long("checkpoint-sync-url") .help("Set the remote beacon node HTTP endpoint to use for checkpoint sync.") .value_name("BEACON_NODE") - .takes_value(true) + .action(ArgAction::Set) .conflicts_with("checkpoint-state") + .display_order(0) ) .arg( - Arg::with_name("checkpoint-sync-url-timeout") + Arg::new("checkpoint-sync-url-timeout") .long("checkpoint-sync-url-timeout") .help("Set the timeout for checkpoint sync calls to remote beacon node HTTP endpoint.") .value_name("SECONDS") - .takes_value(true) + .action(ArgAction::Set) .default_value("180") + .display_order(0) ) .arg( - Arg::with_name("allow-insecure-genesis-sync") + Arg::new("allow-insecure-genesis-sync") .long("allow-insecure-genesis-sync") .help("Enable syncing from genesis, which is generally insecure and incompatible with data availability checks. \ Checkpoint syncing is the preferred method for syncing a node. \ Only use this flag when testing. DO NOT use on mainnet!") .conflicts_with("checkpoint-sync-url") .conflicts_with("checkpoint-state") - .takes_value(false) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("reconstruct-historic-states") + Arg::new("reconstruct-historic-states") .long("reconstruct-historic-states") .help("After a checkpoint sync, reconstruct historic states in the database. This requires syncing all the way back to genesis.") - .takes_value(false) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("validator-monitor-auto") + Arg::new("validator-monitor-auto") .long("validator-monitor-auto") + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .help("Enables the automatic detection and monitoring of validators connected to the \ HTTP API and using the subnet subscription endpoint. This generally has the \ effect of providing additional logging and metrics for locally controlled \ validators.") + .display_order(0) ) .arg( - Arg::with_name("validator-monitor-pubkeys") + Arg::new("validator-monitor-pubkeys") .long("validator-monitor-pubkeys") .help("A comma-separated list of 0x-prefixed validator public keys. \ These validators will receive special monitoring and additional \ logging.") .value_name("PUBKEYS") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("validator-monitor-file") + Arg::new("validator-monitor-file") .long("validator-monitor-file") .help("As per --validator-monitor-pubkeys, but the comma-separated list is \ contained within a file at the given path.") .value_name("PATH") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("validator-monitor-individual-tracking-threshold") + Arg::new("validator-monitor-individual-tracking-threshold") .long("validator-monitor-individual-tracking-threshold") .help("Once the validator monitor reaches this number of local validators \ it will stop collecting per-validator Prometheus metrics and issuing \ @@ -1019,59 +1205,73 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { This avoids infeasibly high cardinality in the Prometheus database and \ high log volume when using many validators. Defaults to 64.") .value_name("INTEGER") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("disable-lock-timeouts") + Arg::new("disable-lock-timeouts") .long("disable-lock-timeouts") .help("Disable the timeouts applied to some internal locks by default. This can \ lead to less spurious failures on slow hardware but is considered \ experimental as it may obscure performance issues.") - .takes_value(false) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("disable-proposer-reorgs") + Arg::new("disable-proposer-reorgs") .long("disable-proposer-reorgs") .help("Do not attempt to reorg late blocks from other validators when proposing.") - .takes_value(false) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("proposer-reorg-threshold") + Arg::new("proposer-reorg-threshold") .long("proposer-reorg-threshold") + .action(ArgAction::Set) .value_name("PERCENT") .help("Percentage of head vote weight below which to attempt a proposer reorg. \ Default: 20%") .conflicts_with("disable-proposer-reorgs") + .display_order(0) ) .arg( - Arg::with_name("proposer-reorg-parent-threshold") + Arg::new("proposer-reorg-parent-threshold") .long("proposer-reorg-parent-threshold") .value_name("PERCENT") .help("Percentage of parent vote weight above which to attempt a proposer reorg. \ Default: 160%") .conflicts_with("disable-proposer-reorgs") + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("proposer-reorg-epochs-since-finalization") + Arg::new("proposer-reorg-epochs-since-finalization") .long("proposer-reorg-epochs-since-finalization") + .action(ArgAction::Set) .value_name("EPOCHS") .help("Maximum number of epochs since finalization at which proposer reorgs are \ allowed. Default: 2") .conflicts_with("disable-proposer-reorgs") + .display_order(0) ) .arg( - Arg::with_name("proposer-reorg-cutoff") + Arg::new("proposer-reorg-cutoff") .long("proposer-reorg-cutoff") .value_name("MILLISECONDS") + .action(ArgAction::Set) .help("Maximum delay after the start of the slot at which to propose a reorging \ block. Lower values can prevent failed reorgs by ensuring the block has \ ample time to propagate and be processed by the network. The default is \ 1/12th of a slot (1 second on mainnet)") .conflicts_with("disable-proposer-reorgs") + .display_order(0) ) .arg( - Arg::with_name("proposer-reorg-disallowed-offsets") + Arg::new("proposer-reorg-disallowed-offsets") .long("proposer-reorg-disallowed-offsets") + .action(ArgAction::Set) .value_name("N1,N2,...") .help("Comma-separated list of integer offsets which can be used to avoid \ proposing reorging blocks at certain slots. An offset of N means that \ @@ -1080,66 +1280,75 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { avoided. Any offsets supplied with this flag will impose additional \ restrictions.") .conflicts_with("disable-proposer-reorgs") + .display_order(0) ) .arg( - Arg::with_name("prepare-payload-lookahead") + Arg::new("prepare-payload-lookahead") .long("prepare-payload-lookahead") .value_name("MILLISECONDS") .help("The time before the start of a proposal slot at which payload attributes \ should be sent. Low values are useful for execution nodes which don't \ improve their payload after the first call, and high values are useful \ for ensuring the EL is given ample notice. Default: 1/3 of a slot.") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("always-prepare-payload") + Arg::new("always-prepare-payload") .long("always-prepare-payload") .help("Send payload attributes with every fork choice update. This is intended for \ use by block builders, relays and developers. You should set a fee \ recipient on this BN and also consider adjusting the \ --prepare-payload-lookahead flag.") - .takes_value(false) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("fork-choice-before-proposal-timeout") + Arg::new("fork-choice-before-proposal-timeout") .long("fork-choice-before-proposal-timeout") .help("Set the maximum number of milliseconds to wait for fork choice before \ proposing a block. You can prevent waiting at all by setting the timeout \ to 0, however you risk proposing atop the wrong parent block.") .default_value("250") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("paranoid-block-proposal") + Arg::new("paranoid-block-proposal") .long("paranoid-block-proposal") .help("Paranoid enough to be reading the source? Nice. This flag reverts some \ block proposal optimisations and forces the node to check every attestation \ it includes super thoroughly. This may be useful in an emergency, but not \ otherwise.") - .hidden(true) - .takes_value(false) + .hide(true) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("builder-fallback-skips") + Arg::new("builder-fallback-skips") .long("builder-fallback-skips") .help("If this node is proposing a block and has seen this number of skip slots \ on the canonical chain in a row, it will NOT query any connected builders, \ and will use the local execution engine for payload construction.") .default_value("3") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("builder-fallback-skips-per-epoch") + Arg::new("builder-fallback-skips-per-epoch") .long("builder-fallback-skips-per-epoch") .help("If this node is proposing a block and has seen this number of skip slots \ on the canonical chain in the past `SLOTS_PER_EPOCH`, it will NOT query \ any connected builders, and will use the local execution engine for \ payload construction.") .default_value("8") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("builder-fallback-epochs-since-finalization") + Arg::new("builder-fallback-epochs-since-finalization") .long("builder-fallback-epochs-since-finalization") .help("If this node is proposing a block and the chain has not finalized within \ this number of epochs, it will NOT query any connected builders, \ @@ -1149,152 +1358,180 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { if there are skips slots at the start of an epoch, right before this node \ is set to propose.") .default_value("3") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("builder-fallback-disable-checks") + Arg::new("builder-fallback-disable-checks") .long("builder-fallback-disable-checks") .help("This flag disables all checks related to chain health. This means the builder \ API will always be used for payload construction, regardless of recent chain \ conditions.") - .takes_value(false) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("builder-profit-threshold") + Arg::new("builder-profit-threshold") .long("builder-profit-threshold") .value_name("WEI_VALUE") .help("This flag is deprecated and has no effect.") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("builder-user-agent") + Arg::new("builder-user-agent") .long("builder-user-agent") .value_name("STRING") .help("The HTTP user agent to send alongside requests to the builder URL. The \ default is Lighthouse's version string.") .requires("builder") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("reset-payload-statuses") + Arg::new("reset-payload-statuses") .long("reset-payload-statuses") .help("When present, Lighthouse will forget the payload statuses of any \ already-imported blocks. This can assist in the recovery from a consensus \ failure caused by the execution layer.") - .takes_value(false) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("disable-deposit-contract-sync") + Arg::new("disable-deposit-contract-sync") .long("disable-deposit-contract-sync") .help("Explicitly disables syncing of deposit logs from the execution node. \ This overrides any previous option that depends on it. \ Useful if you intend to run a non-validating beacon node.") - .takes_value(false) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("disable-optimistic-finalized-sync") + Arg::new("disable-optimistic-finalized-sync") .long("disable-optimistic-finalized-sync") + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .help("Force Lighthouse to verify every execution block hash with the execution \ client during finalized sync. By default block hashes will be checked in \ Lighthouse and only passed to the EL if initial verification fails.") + .display_order(0) ) .arg( - Arg::with_name("light-client-server") + Arg::new("light-client-server") .long("light-client-server") .help("Act as a full node supporting light clients on the p2p network \ [experimental]") - .takes_value(false) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("gui") + Arg::new("gui") .long("gui") .help("Enable the graphical user interface and all its requirements. \ This enables --http and --validator-monitor-auto and enables SSE logging.") - .takes_value(false) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("always-prefer-builder-payload") + Arg::new("always-prefer-builder-payload") + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .long("always-prefer-builder-payload") .help("This flag is deprecated and has no effect.") + .display_order(0) ) .arg( - Arg::with_name("invalid-gossip-verified-blocks-path") + Arg::new("invalid-gossip-verified-blocks-path") + .action(ArgAction::Set) .long("invalid-gossip-verified-blocks-path") .value_name("PATH") .help("If a block succeeds gossip validation whilst failing full validation, store \ the block SSZ as a file at this path. This feature is only recommended for \ developers. This directory is not pruned, users should be careful to avoid \ filling up their disks.") + .display_order(0) ) .arg( - Arg::with_name("progressive-balances") + Arg::new("progressive-balances") .long("progressive-balances") .value_name("MODE") .help("Deprecated. This optimisation is now the default and cannot be disabled.") - .takes_value(true) - .possible_values(&["fast", "disabled", "checked", "strict"]) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("beacon-processor-max-workers") + Arg::new("beacon-processor-max-workers") .long("beacon-processor-max-workers") .value_name("INTEGER") .help("Specifies the maximum concurrent tasks for the task scheduler. Increasing \ this value may increase resource consumption. Reducing the value \ may result in decreased resource usage and diminished performance. The \ default value is the number of logical CPU cores on the host.") - .hidden(true) - .takes_value(true) + .hide(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("beacon-processor-work-queue-len") + Arg::new("beacon-processor-work-queue-len") .long("beacon-processor-work-queue-len") .value_name("INTEGER") .help("Specifies the length of the inbound event queue. \ Higher values may prevent messages from being dropped while lower values \ may help protect the node from becoming overwhelmed.") .default_value("16384") - .hidden(true) - .takes_value(true) + .hide(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("beacon-processor-reprocess-queue-len") + Arg::new("beacon-processor-reprocess-queue-len") .long("beacon-processor-reprocess-queue-len") .value_name("INTEGER") .help("Specifies the length of the queue for messages requiring delayed processing. \ Higher values may prevent messages from being dropped while lower values \ may help protect the node from becoming overwhelmed.") - .hidden(true) + .hide(true) .default_value("12288") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("beacon-processor-attestation-batch-size") + Arg::new("beacon-processor-attestation-batch-size") .long("beacon-processor-attestation-batch-size") .value_name("INTEGER") .help("Specifies the number of gossip attestations in a signature verification batch. \ Higher values may reduce CPU usage in a healthy network whilst lower values may \ increase CPU usage in an unhealthy or hostile network.") - .hidden(true) + .hide(true) .default_value("64") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("beacon-processor-aggregate-batch-size") + Arg::new("beacon-processor-aggregate-batch-size") .long("beacon-processor-aggregate-batch-size") .value_name("INTEGER") .help("Specifies the number of gossip aggregate attestations in a signature \ verification batch. \ Higher values may reduce CPU usage in a healthy network while lower values may \ increase CPU usage in an unhealthy or hostile network.") - .hidden(true) + .hide(true) .default_value("64") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("disable-duplicate-warn-logs") + Arg::new("disable-duplicate-warn-logs") .long("disable-duplicate-warn-logs") .help("This flag is deprecated and has no effect.") - .takes_value(false) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) - .group(ArgGroup::with_name("enable_http").args(&["http", "gui", "staking"]).multiple(true)) + .group(ArgGroup::new("enable_http").args(["http", "gui", "staking"]).multiple(true)) } diff --git a/beacon_node/src/config.rs b/beacon_node/src/config.rs index 9a1d7df124c..e3d304a99ac 100644 --- a/beacon_node/src/config.rs +++ b/beacon_node/src/config.rs @@ -5,9 +5,9 @@ use beacon_chain::chain_config::{ }; use beacon_chain::graffiti_calculator::GraffitiOrigin; use beacon_chain::TrustedSetup; -use clap::ArgMatches; +use clap::{parser::ValueSource, ArgMatches, Id}; use clap_utils::flags::DISABLE_MALLOC_TUNING_FLAG; -use clap_utils::parse_required; +use clap_utils::{parse_flag, parse_required}; use client::{ClientConfig, ClientGenesis}; use directory::{DEFAULT_BEACON_NODE_DIR, DEFAULT_NETWORK_DIR, DEFAULT_ROOT_DIR}; use environment::RuntimeContext; @@ -50,7 +50,7 @@ pub fn get_config( client_config.set_data_dir(get_data_dir(cli_args)); // If necessary, remove any existing database and configuration - if client_config.data_dir().exists() && cli_args.is_present("purge-db") { + if client_config.data_dir().exists() && cli_args.get_flag("purge-db") { // Remove the chain_db. let chain_db = client_config.get_db_path(); if chain_db.exists() { @@ -96,7 +96,7 @@ pub fn get_config( * Note: the config values set here can be overwritten by other more specific cli params */ - if cli_args.is_present("staking") { + if cli_args.get_flag("staking") { client_config.http_api.enabled = true; client_config.sync_eth1_chain = true; } @@ -105,22 +105,22 @@ pub fn get_config( * Http API server */ - if cli_args.is_present("enable_http") { + if cli_args.get_one::("enable_http").is_some() { client_config.http_api.enabled = true; - if let Some(address) = cli_args.value_of("http-address") { + if let Some(address) = cli_args.get_one::("http-address") { client_config.http_api.listen_addr = address .parse::() .map_err(|_| "http-address is not a valid IP address.")?; } - if let Some(port) = cli_args.value_of("http-port") { + if let Some(port) = cli_args.get_one::("http-port") { client_config.http_api.listen_port = port .parse::() .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::("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) @@ -129,7 +129,7 @@ pub fn get_config( client_config.http_api.allow_origin = Some(allow_origin.to_string()); } - if cli_args.is_present("http-spec-fork") { + if cli_args.get_one::("http-spec-fork").is_some() { warn!( log, "Ignoring --http-spec-fork"; @@ -137,22 +137,22 @@ pub fn get_config( ); } - if cli_args.is_present("http-enable-tls") { + if cli_args.get_flag("http-enable-tls") { client_config.http_api.tls_config = Some(TlsConfig { cert: cli_args - .value_of("http-tls-cert") + .get_one::("http-tls-cert") .ok_or("--http-tls-cert was not provided.")? .parse::() .map_err(|_| "http-tls-cert is not a valid path name.")?, key: cli_args - .value_of("http-tls-key") + .get_one::("http-tls-key") .ok_or("--http-tls-key was not provided.")? .parse::() .map_err(|_| "http-tls-key is not a valid path name.")?, }); } - if cli_args.is_present("http-allow-sync-stalled") { + if cli_args.get_flag("http-allow-sync-stalled") { warn!( log, "Ignoring --http-allow-sync-stalled"; @@ -170,10 +170,10 @@ pub fn get_config( parse_required(cli_args, "http-duplicate-block-status")?; client_config.http_api.enable_light_client_server = - cli_args.is_present("light-client-server"); + cli_args.get_flag("light-client-server"); } - if cli_args.is_present("light-client-server") { + if cli_args.get_flag("light-client-server") { client_config.chain.enable_light_client_server = true; } @@ -185,23 +185,23 @@ pub fn get_config( * Prometheus metrics HTTP server */ - if cli_args.is_present("metrics") { + if cli_args.get_flag("metrics") { client_config.http_metrics.enabled = true; } - if let Some(address) = cli_args.value_of("metrics-address") { + if let Some(address) = cli_args.get_one::("metrics-address") { client_config.http_metrics.listen_addr = address .parse::() .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::("metrics-port") { client_config.http_metrics.listen_port = port .parse::() .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::("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) @@ -213,7 +213,7 @@ pub fn get_config( /* * Explorer metrics */ - if let Some(monitoring_endpoint) = cli_args.value_of("monitoring-endpoint") { + if let Some(monitoring_endpoint) = cli_args.get_one::("monitoring-endpoint") { let update_period_secs = clap_utils::parse_optional(cli_args, "monitoring-endpoint-period")?; @@ -227,7 +227,7 @@ pub fn get_config( // Log a warning indicating an open HTTP server if it wasn't specified explicitly // (e.g. using the --staking flag). - if cli_args.is_present("staking") { + if cli_args.get_flag("staking") { warn!( log, "Running HTTP server on port {}", client_config.http_api.listen_port @@ -235,7 +235,7 @@ pub fn get_config( } // Do not scrape for malloc metrics if we've disabled tuning malloc as it may cause panics. - if cli_args.is_present(DISABLE_MALLOC_TUNING_FLAG) { + if cli_args.get_flag(DISABLE_MALLOC_TUNING_FLAG) { client_config.http_metrics.allocator_metrics_enabled = false; } @@ -246,24 +246,24 @@ pub fn get_config( // When present, use an eth1 backend that generates deterministic junk. // // Useful for running testnets without the overhead of a deposit contract. - if cli_args.is_present("dummy-eth1") { + if cli_args.get_flag("dummy-eth1") { client_config.dummy_eth1_backend = true; } // When present, attempt to sync to an eth1 node. // // Required for block production. - if cli_args.is_present("eth1") { + if cli_args.get_flag("eth1") { client_config.sync_eth1_chain = true; } - if let Some(val) = cli_args.value_of("eth1-blocks-per-log-query") { + if let Some(val) = cli_args.get_one::("eth1-blocks-per-log-query") { client_config.eth1.blocks_per_log_query = val .parse() .map_err(|_| "eth1-blocks-per-log-query is not a valid integer".to_string())?; } - if cli_args.is_present("eth1-purge-cache") { + if cli_args.get_flag("eth1-purge-cache") { client_config.eth1.purge_cache = true; } @@ -273,7 +273,7 @@ pub fn get_config( client_config.eth1.cache_follow_distance = Some(follow_distance); } - if let Some(endpoints) = cli_args.value_of("execution-endpoint") { + if let Some(endpoints) = cli_args.get_one::("execution-endpoint") { let mut el_config = execution_layer::Config::default(); // Always follow the deposit contract when there is an execution endpoint. @@ -296,13 +296,14 @@ pub fn get_config( let secret_file: PathBuf; // Parse a single JWT secret from a given file_path, logging warnings if multiple are supplied. - if let Some(secret_files) = cli_args.value_of("execution-jwt") { + if let Some(secret_files) = cli_args.get_one::("execution-jwt") { secret_file = parse_only_one_value(secret_files, PathBuf::from_str, "--execution-jwt", log)?; // Check if the JWT secret key is passed directly via cli flag and persist it to the default // file location. - } else if let Some(jwt_secret_key) = cli_args.value_of("execution-jwt-secret-key") { + } else if let Some(jwt_secret_key) = cli_args.get_one::("execution-jwt-secret-key") + { use std::fs::File; use std::io::Write; secret_file = client_config.data_dir().join(DEFAULT_JWT_FILE); @@ -321,7 +322,7 @@ pub fn get_config( } // Parse and set the payload builder, if any. - if let Some(endpoint) = cli_args.value_of("builder") { + if let Some(endpoint) = cli_args.get_one::("builder") { let payload_builder = parse_only_one_value(endpoint, SensitiveUrl::parse, "--builder", log)?; el_config.builder_url = Some(payload_builder); @@ -330,14 +331,14 @@ pub fn get_config( clap_utils::parse_optional(cli_args, "builder-user-agent")?; } - if cli_args.is_present("builder-profit-threshold") { + if parse_flag(cli_args, "builder-profit-threshold") { warn!( log, "Ignoring --builder-profit-threshold"; "info" => "this flag is deprecated and will be removed" ); } - if cli_args.is_present("always-prefer-builder-payload") { + if cli_args.get_flag("always-prefer-builder-payload") { warn!( log, "Ignoring --always-prefer-builder-payload"; @@ -380,7 +381,8 @@ pub fn get_config( .map_err(|e| format!("Unable to read trusted setup file: {}", e))?; // Override default trusted setup file if required - if let Some(trusted_setup_file_path) = cli_args.value_of("trusted-setup-file-override") { + if let Some(trusted_setup_file_path) = cli_args.get_one::("trusted-setup-file-override") + { let file = std::fs::File::open(trusted_setup_file_path) .map_err(|e| format!("Failed to open trusted setup file: {}", e))?; let trusted_setup: TrustedSetup = serde_json::from_reader(file) @@ -388,11 +390,11 @@ pub fn get_config( client_config.trusted_setup = Some(trusted_setup); } - if let Some(freezer_dir) = cli_args.value_of("freezer-dir") { + if let Some(freezer_dir) = cli_args.get_one::("freezer-dir") { client_config.freezer_db_path = Some(PathBuf::from(freezer_dir)); } - if let Some(blobs_db_dir) = cli_args.value_of("blobs-dir") { + if let Some(blobs_db_dir) = cli_args.get_one::("blobs-dir") { client_config.blobs_db_path = Some(PathBuf::from(blobs_db_dir)); } @@ -400,24 +402,27 @@ pub fn get_config( client_config.store.slots_per_restore_point = sprp; client_config.store.slots_per_restore_point_set_explicitly = sprp_explicit; - if let Some(block_cache_size) = cli_args.value_of("block-cache-size") { + if let Some(block_cache_size) = cli_args.get_one::("block-cache-size") { client_config.store.block_cache_size = block_cache_size .parse() .map_err(|_| "block-cache-size is not a valid integer".to_string())?; } - if let Some(cache_size) = clap_utils::parse_optional(cli_args, "state-cache-size")? { - client_config.store.state_cache_size = cache_size; + if let Some(cache_size) = cli_args.get_one::("state-cache-size") { + client_config.store.state_cache_size = cache_size + .parse() + .map_err(|_| "state-cache-size is not a valid integer".to_string())?; } - if let Some(historic_state_cache_size) = cli_args.value_of("historic-state-cache-size") { + if let Some(historic_state_cache_size) = cli_args.get_one::("historic-state-cache-size") + { client_config.store.historic_state_cache_size = historic_state_cache_size .parse() .map_err(|_| "historic-state-cache-size is not a valid integer".to_string())?; } - client_config.store.compact_on_init = cli_args.is_present("compact-db"); - if let Some(compact_on_prune) = cli_args.value_of("auto-compact-db") { + client_config.store.compact_on_init = cli_args.get_flag("compact-db"); + if let Some(compact_on_prune) = cli_args.get_one::("auto-compact-db") { client_config.store.compact_on_prune = compact_on_prune .parse() .map_err(|_| "auto-compact-db takes a boolean".to_string())?; @@ -458,7 +463,7 @@ pub fn get_config( * from lighthouse. * Discovery address is set to localhost by default. */ - if cli_args.is_present("zero-ports") { + if cli_args.get_flag("zero-ports") { client_config.http_api.listen_port = 0; client_config.http_metrics.listen_port = 0; } @@ -524,14 +529,14 @@ pub fn get_config( None }; - client_config.allow_insecure_genesis_sync = cli_args.is_present("allow-insecure-genesis-sync"); + client_config.allow_insecure_genesis_sync = cli_args.get_flag("allow-insecure-genesis-sync"); client_config.genesis = if eth2_network_config.genesis_state_is_known() { // Set up weak subjectivity sync, or start from the hardcoded genesis state. if let (Some(initial_state_path), Some(initial_block_path), opt_initial_blobs_path) = ( - cli_args.value_of("checkpoint-state"), - cli_args.value_of("checkpoint-block"), - cli_args.value_of("checkpoint-blobs"), + cli_args.get_one::("checkpoint-state"), + cli_args.get_one::("checkpoint-block"), + cli_args.get_one::("checkpoint-blobs"), ) { let read = |path: &str| { use std::fs::File; @@ -547,14 +552,14 @@ pub fn get_config( let anchor_state_bytes = read(initial_state_path)?; let anchor_block_bytes = read(initial_block_path)?; - let anchor_blobs_bytes = opt_initial_blobs_path.map(read).transpose()?; + let anchor_blobs_bytes = opt_initial_blobs_path.map(|s| read(s)).transpose()?; ClientGenesis::WeakSubjSszBytes { anchor_state_bytes, anchor_block_bytes, anchor_blobs_bytes, } - } else if let Some(remote_bn_url) = cli_args.value_of("checkpoint-sync-url") { + } else if let Some(remote_bn_url) = cli_args.get_one::("checkpoint-sync-url") { let url = SensitiveUrl::parse(remote_bn_url) .map_err(|e| format!("Invalid checkpoint sync URL: {:?}", e))?; @@ -563,7 +568,7 @@ pub fn get_config( ClientGenesis::GenesisState } } else { - if cli_args.is_present("checkpoint-state") || cli_args.is_present("checkpoint-sync-url") { + if parse_flag(cli_args, "checkpoint-state") || parse_flag(cli_args, "checkpoint-sync-url") { return Err( "Checkpoint sync is not available for this network as no genesis state is known" .to_string(), @@ -572,14 +577,14 @@ pub fn get_config( ClientGenesis::DepositContract }; - if cli_args.is_present("reconstruct-historic-states") { + if cli_args.get_flag("reconstruct-historic-states") { client_config.chain.reconstruct_historic_states = true; client_config.chain.genesis_backfill = true; } - let beacon_graffiti = if let Some(graffiti) = cli_args.value_of("graffiti") { + let beacon_graffiti = if let Some(graffiti) = cli_args.get_one::("graffiti") { GraffitiOrigin::UserSpecified(GraffitiString::from_str(graffiti)?.into()) - } else if cli_args.is_present("private") { + } else if cli_args.get_flag("private") { // When 'private' flag is present, use a zero-initialized bytes array. GraffitiOrigin::UserSpecified(GraffitiString::empty().into()) } else { @@ -588,7 +593,7 @@ pub fn get_config( }; client_config.beacon_graffiti = beacon_graffiti; - if let Some(wss_checkpoint) = cli_args.value_of("wss-checkpoint") { + if let Some(wss_checkpoint) = cli_args.get_one::("wss-checkpoint") { let mut split = wss_checkpoint.split(':'); let root_str = split .next() @@ -623,8 +628,8 @@ pub fn get_config( client_config.chain.weak_subjectivity_checkpoint = Some(Checkpoint { epoch, root }) } - if let Some(max_skip_slots) = cli_args.value_of("max-skip-slots") { - client_config.chain.import_max_skip_slots = match max_skip_slots { + if let Some(max_skip_slots) = cli_args.get_one::("max-skip-slots") { + client_config.chain.import_max_skip_slots = match max_skip_slots.as_str() { "none" => None, n => Some( n.parse() @@ -638,8 +643,8 @@ pub fn get_config( spec.gossip_max_size as usize, ); - if cli_args.is_present("slasher") { - let slasher_dir = if let Some(slasher_dir) = cli_args.value_of("slasher-dir") { + if cli_args.get_flag("slasher") { + let slasher_dir = if let Some(slasher_dir) = cli_args.get_one::("slasher-dir") { PathBuf::from(slasher_dir) } else { client_config.data_dir().join("slasher_db") @@ -704,11 +709,11 @@ pub fn get_config( client_config.slasher = Some(slasher_config); } - if cli_args.is_present("validator-monitor-auto") { + if cli_args.get_flag("validator-monitor-auto") { client_config.validator_monitor.auto_register = true; } - if let Some(pubkeys) = cli_args.value_of("validator-monitor-pubkeys") { + if let Some(pubkeys) = cli_args.get_one::("validator-monitor-pubkeys") { let pubkeys = pubkeys .split(',') .map(PublicKeyBytes::from_str) @@ -720,7 +725,7 @@ pub fn get_config( .extend_from_slice(&pubkeys); } - if let Some(path) = cli_args.value_of("validator-monitor-file") { + if let Some(path) = cli_args.get_one::("validator-monitor-file") { let string = fs::read(path) .map_err(|e| format!("Unable to read --validator-monitor-file: {}", e)) .and_then(|bytes| { @@ -747,11 +752,11 @@ pub fn get_config( .individual_tracking_threshold = count; } - if cli_args.is_present("disable-lock-timeouts") { + if cli_args.get_flag("disable-lock-timeouts") { client_config.chain.enable_lock_timeouts = false; } - if cli_args.is_present("disable-proposer-reorgs") { + if cli_args.get_flag("disable-proposer-reorgs") { client_config.chain.re_org_head_threshold = None; client_config.chain.re_org_parent_threshold = None; } else { @@ -789,7 +794,7 @@ pub fn get_config( } // Note: This overrides any previous flags that enable this option. - if cli_args.is_present("disable-deposit-contract-sync") { + if cli_args.get_flag("disable-deposit-contract-sync") { client_config.sync_eth1_chain = false; } @@ -801,7 +806,7 @@ pub fn get_config( / DEFAULT_PREPARE_PAYLOAD_LOOKAHEAD_FACTOR }); - client_config.chain.always_prepare_payload = cli_args.is_present("always-prepare-payload"); + client_config.chain.always_prepare_payload = cli_args.get_flag("always-prepare-payload"); if let Some(timeout) = clap_utils::parse_optional(cli_args, "fork-choice-before-proposal-timeout")? @@ -809,10 +814,9 @@ pub fn get_config( client_config.chain.fork_choice_before_proposal_timeout_ms = timeout; } - client_config.chain.always_reset_payload_statuses = - cli_args.is_present("reset-payload-statuses"); + client_config.chain.always_reset_payload_statuses = cli_args.get_flag("reset-payload-statuses"); - client_config.chain.paranoid_block_proposal = cli_args.is_present("paranoid-block-proposal"); + client_config.chain.paranoid_block_proposal = cli_args.get_flag("paranoid-block-proposal"); /* * Builder fallback configs. @@ -826,32 +830,32 @@ pub fn get_config( .builder_fallback_epochs_since_finalization = clap_utils::parse_required(cli_args, "builder-fallback-epochs-since-finalization")?; client_config.chain.builder_fallback_disable_checks = - cli_args.is_present("builder-fallback-disable-checks"); + cli_args.get_flag("builder-fallback-disable-checks"); // Graphical user interface config. - if cli_args.is_present("gui") { + if cli_args.get_flag("gui") { client_config.http_api.enabled = true; client_config.validator_monitor.auto_register = true; } // Optimistic finalized sync. client_config.chain.optimistic_finalized_sync = - !cli_args.is_present("disable-optimistic-finalized-sync"); + !cli_args.get_flag("disable-optimistic-finalized-sync"); - if cli_args.is_present("genesis-backfill") { + if cli_args.get_flag("genesis-backfill") { client_config.chain.genesis_backfill = true; } // Backfill sync rate-limiting client_config.beacon_processor.enable_backfill_rate_limiting = - !cli_args.is_present("disable-backfill-rate-limiting"); + !cli_args.get_flag("disable-backfill-rate-limiting"); if let Some(path) = clap_utils::parse_optional(cli_args, "invalid-gossip-verified-blocks-path")? { client_config.network.invalid_block_storage = Some(path); } - if cli_args.is_present("progressive-balances") { + if cli_args.get_one::("progressive-balances").is_some() { warn!( log, "Progressive balances mode is deprecated"; @@ -890,10 +894,9 @@ pub fn parse_listening_addresses( log: &Logger, ) -> Result { let listen_addresses_str = cli_args - .values_of("listen-address") + .get_many::("listen-address") .expect("--listen_addresses has a default value"); - - let use_zero_ports = cli_args.is_present("zero-ports"); + let use_zero_ports = parse_flag(cli_args, "zero-ports"); // parse the possible ips let mut maybe_ipv4 = None; @@ -927,28 +930,28 @@ pub fn parse_listening_addresses( // parse the possible tcp ports let port = cli_args - .value_of("port") + .get_one::("port") .expect("--port has a default value") .parse::() .map_err(|parse_error| format!("Failed to parse --port as an integer: {parse_error}"))?; let port6 = cli_args - .value_of("port6") - .map(str::parse::) + .get_one::("port6") + .map(|s| str::parse::(s)) .transpose() .map_err(|parse_error| format!("Failed to parse --port6 as an integer: {parse_error}"))? .unwrap_or(9090); // parse the possible discovery ports. let maybe_disc_port = cli_args - .value_of("discovery-port") - .map(str::parse::) + .get_one::("discovery-port") + .map(|s| str::parse::(s)) .transpose() .map_err(|parse_error| { format!("Failed to parse --discovery-port as an integer: {parse_error}") })?; let maybe_disc6_port = cli_args - .value_of("discovery-port6") - .map(str::parse::) + .get_one::("discovery-port6") + .map(|s| str::parse::(s)) .transpose() .map_err(|parse_error| { format!("Failed to parse --discovery-port6 as an integer: {parse_error}") @@ -956,8 +959,8 @@ pub fn parse_listening_addresses( // parse the possible quic port. let maybe_quic_port = cli_args - .value_of("quic-port") - .map(str::parse::) + .get_one::("quic-port") + .map(|s| str::parse::(s)) .transpose() .map_err(|parse_error| { format!("Failed to parse --quic-port as an integer: {parse_error}") @@ -965,8 +968,8 @@ pub fn parse_listening_addresses( // parse the possible quic port. let maybe_quic6_port = cli_args - .value_of("quic-port6") - .map(str::parse::) + .get_one::("quic-port6") + .map(|s| str::parse::(s)) .transpose() .map_err(|parse_error| { format!("Failed to parse --quic6-port as an integer: {parse_error}") @@ -980,10 +983,10 @@ pub fn parse_listening_addresses( } (None, Some(ipv6)) => { // A single ipv6 address was provided. Set the ports - - if cli_args.is_present("port6") { - warn!(log, "When listening only over IPv6, use the --port flag. The value of --port6 will be ignored.") + if cli_args.value_source("port6") == Some(ValueSource::CommandLine) { + warn!(log, "When listening only over IPv6, use the --port flag. The value of --port6 will be ignored."); } + // use zero ports if required. If not, use the given port. let tcp_port = use_zero_ports .then(unused_port::unused_tcp6_port) @@ -1117,41 +1120,41 @@ pub fn set_network_config( log: &Logger, ) -> Result<(), String> { // If a network dir has been specified, override the `datadir` definition. - if let Some(dir) = cli_args.value_of("network-dir") { + if let Some(dir) = cli_args.get_one::("network-dir") { config.network_dir = PathBuf::from(dir); } else { config.network_dir = data_dir.join(DEFAULT_NETWORK_DIR); }; - if cli_args.is_present("subscribe-all-subnets") { + if parse_flag(cli_args, "subscribe-all-subnets") { config.subscribe_all_subnets = true; } - if cli_args.is_present("import-all-attestations") { + if parse_flag(cli_args, "import-all-attestations") { config.import_all_attestations = true; } - if cli_args.is_present("shutdown-after-sync") { + if parse_flag(cli_args, "shutdown-after-sync") { config.shutdown_after_sync = true; } config.set_listening_addr(parse_listening_addresses(cli_args, log)?); // A custom target-peers command will overwrite the --proposer-only default. - if let Some(target_peers_str) = cli_args.value_of("target-peers") { + if let Some(target_peers_str) = cli_args.get_one::("target-peers") { config.target_peers = target_peers_str .parse::() .map_err(|_| format!("Invalid number of target peers: {}", target_peers_str))?; } - if let Some(value) = cli_args.value_of("network-load") { + if let Some(value) = cli_args.get_one::("network-load") { let network_load = value .parse::() .map_err(|_| format!("Invalid integer: {}", value))?; config.network_load = network_load; } - if let Some(boot_enr_str) = cli_args.value_of("boot-nodes") { + if let Some(boot_enr_str) = cli_args.get_one::("boot-nodes") { let mut enrs: Vec = vec![]; let mut multiaddrs: Vec = vec![]; for addr in boot_enr_str.split(',') { @@ -1176,7 +1179,7 @@ pub fn set_network_config( config.boot_nodes_multiaddr = multiaddrs; } - if let Some(libp2p_addresses_str) = cli_args.value_of("libp2p-addresses") { + if let Some(libp2p_addresses_str) = cli_args.get_one::("libp2p-addresses") { config.libp2p_nodes = libp2p_addresses_str .split(',') .map(|multiaddr| { @@ -1187,11 +1190,11 @@ pub fn set_network_config( .collect::, _>>()?; } - if cli_args.is_present("disable-peer-scoring") { + if parse_flag(cli_args, "disable-peer-scoring") { config.disable_peer_scoring = true; } - if let Some(trusted_peers_str) = cli_args.value_of("trusted-peers") { + if let Some(trusted_peers_str) = cli_args.get_one::("trusted-peers") { config.trusted_peers = trusted_peers_str .split(',') .map(|peer_id| { @@ -1205,7 +1208,7 @@ pub fn set_network_config( } } - if let Some(enr_udp_port_str) = cli_args.value_of("enr-udp-port") { + if let Some(enr_udp_port_str) = cli_args.get_one::("enr-udp-port") { config.enr_udp4_port = Some( enr_udp_port_str .parse::() @@ -1213,7 +1216,7 @@ pub fn set_network_config( ); } - if let Some(enr_quic_port_str) = cli_args.value_of("enr-quic-port") { + if let Some(enr_quic_port_str) = cli_args.get_one::("enr-quic-port") { config.enr_quic4_port = Some( enr_quic_port_str .parse::() @@ -1221,7 +1224,7 @@ pub fn set_network_config( ); } - if let Some(enr_tcp_port_str) = cli_args.value_of("enr-tcp-port") { + if let Some(enr_tcp_port_str) = cli_args.get_one::("enr-tcp-port") { config.enr_tcp4_port = Some( enr_tcp_port_str .parse::() @@ -1229,7 +1232,7 @@ pub fn set_network_config( ); } - if let Some(enr_udp_port_str) = cli_args.value_of("enr-udp6-port") { + if let Some(enr_udp_port_str) = cli_args.get_one::("enr-udp6-port") { config.enr_udp6_port = Some( enr_udp_port_str .parse::() @@ -1237,7 +1240,7 @@ pub fn set_network_config( ); } - if let Some(enr_quic_port_str) = cli_args.value_of("enr-quic6-port") { + if let Some(enr_quic_port_str) = cli_args.get_one::("enr-quic6-port") { config.enr_quic6_port = Some( enr_quic_port_str .parse::() @@ -1245,7 +1248,7 @@ pub fn set_network_config( ); } - if let Some(enr_tcp_port_str) = cli_args.value_of("enr-tcp6-port") { + if let Some(enr_tcp_port_str) = cli_args.get_one::("enr-tcp6-port") { config.enr_tcp6_port = Some( enr_tcp_port_str .parse::() @@ -1253,7 +1256,7 @@ pub fn set_network_config( ); } - if cli_args.is_present("enr-match") { + if parse_flag(cli_args, "enr-match") { // Match the IP and UDP port in the ENR. if let Some(ipv4_addr) = config.listen_addrs().v4().cloned() { @@ -1291,7 +1294,7 @@ pub fn set_network_config( } } - if let Some(enr_addresses) = cli_args.values_of("enr-address") { + if let Some(enr_addresses) = cli_args.get_many::("enr-address") { let mut enr_ip4 = None; let mut enr_ip6 = None; let mut resolved_enr_ip4 = None; @@ -1369,79 +1372,78 @@ pub fn set_network_config( } } - if cli_args.is_present("disable-enr-auto-update") { + if parse_flag(cli_args, "disable-enr-auto-update") { config.discv5_config.enr_update = false; } - if cli_args.is_present("disable-packet-filter") { + if parse_flag(cli_args, "disable-packet-filter") { warn!(log, "Discv5 packet filter is disabled"); config.discv5_config.enable_packet_filter = false; } - if cli_args.is_present("disable-discovery") { + if parse_flag(cli_args, "disable-discovery") { config.disable_discovery = true; warn!(log, "Discovery is disabled. New peers will not be found"); } - if cli_args.is_present("disable-quic") { + if parse_flag(cli_args, "disable-quic") { config.disable_quic_support = true; } - if cli_args.is_present("disable-upnp") { + if parse_flag(cli_args, "disable-upnp") { config.upnp_enabled = false; } - if cli_args.is_present("private") { + if parse_flag(cli_args, "private") { config.private = true; } - if cli_args.is_present("metrics") { + if parse_flag(cli_args, "metrics") { config.metrics_enabled = true; } - if cli_args.is_present("enable-private-discovery") { + if parse_flag(cli_args, "enable-private-discovery") { config.discv5_config.table_filter = |_| true; } // Light client server config. - config.enable_light_client_server = cli_args.is_present("light-client-server"); - - // The self limiter is disabled by default. - // This flag can be used both with or without a value. Try to parse it first with a value, if - // no value is defined but the flag is present, use the default params. - config.outbound_rate_limiter_config = clap_utils::parse_optional(cli_args, "self-limiter")?; - if cli_args.is_present("self-limiter") && config.outbound_rate_limiter_config.is_none() { - config.outbound_rate_limiter_config = Some(Default::default()); + config.enable_light_client_server = parse_flag(cli_args, "light-client-server"); + + // The self limiter is disabled by default. If the `self-limiter` flag is provided + // without the `self-limiter-protocols` flag, the default params will be used. + if parse_flag(cli_args, "self-limiter") { + config.outbound_rate_limiter_config = + if let Some(protocols) = cli_args.get_one::("self-limiter-protocols") { + Some(protocols.parse()?) + } else { + Some(Default::default()) + }; } // Proposer-only mode overrides a number of previous configuration parameters. // Specifically, we avoid subscribing to long-lived subnets and wish to maintain a minimal set // of peers. - if cli_args.is_present("proposer-only") { + if parse_flag(cli_args, "proposer-only") { config.subscribe_all_subnets = false; - if cli_args.value_of("target-peers").is_none() { + if cli_args.get_one::("target-peers").is_none() { // If a custom value is not set, change the default to 15 config.target_peers = 15; } config.proposer_only = true; warn!(log, "Proposer-only mode enabled"; "info"=> "Do not connect a validator client to this node unless via the --proposer-nodes flag"); } - // The inbound rate limiter is enabled by default unless `disabled` is passed to the - // `inbound-rate-limiter` flag. Any other value should be parsed as a configuration string. - config.inbound_rate_limiter_config = match cli_args.value_of("inbound-rate-limiter") { - None => { - // Enabled by default, with default values + // The inbound rate limiter is enabled by default unless `disabled` via the + // `disable-inbound-rate-limiter` flag. + config.inbound_rate_limiter_config = if parse_flag(cli_args, "disable-inbound-rate-limiter") { + None + } else { + // Use the default unless values are provided via the `inbound-rate-limiter-protocols` + if let Some(protocols) = cli_args.get_one::("inbound-rate-limiter-protocols") { + Some(protocols.parse()?) + } else { Some(Default::default()) } - Some("disabled") => { - // Explicitly disabled - None - } - Some(config_str) => { - // Enabled with a custom configuration - Some(config_str.parse()?) - } }; Ok(()) } @@ -1454,7 +1456,7 @@ pub fn get_data_dir(cli_args: &ArgMatches) -> PathBuf { // directory and the testnet name onto it. cli_args - .value_of("datadir") + .get_one::("datadir") .map(|path| PathBuf::from(path).join(DEFAULT_BEACON_NODE_DIR)) .or_else(|| { dirs::home_dir().map(|home| { diff --git a/beacon_node/src/lib.rs b/beacon_node/src/lib.rs index ee782c650e2..4ca084c3165 100644 --- a/beacon_node/src/lib.rs +++ b/beacon_node/src/lib.rs @@ -1,4 +1,3 @@ -#[macro_use] extern crate clap; mod cli; @@ -44,7 +43,7 @@ impl ProductionBeaconNode { /// configurations hosted remotely. pub async fn new_from_cli( context: RuntimeContext, - matches: ArgMatches<'static>, + matches: ArgMatches, ) -> Result { let client_config = get_config::(&matches, &context)?; Self::new(context, client_config).await diff --git a/book/src/help_bn.md b/book/src/help_bn.md index f47360eab0e..63374027e60 100644 --- a/book/src/help_bn.md +++ b/book/src/help_bn.md @@ -1,490 +1,607 @@ # Beacon Node ``` -Sigma Prime -The primary component which connects to the Ethereum 2.0 P2P network and downloads, verifies and stores blocks. Provides -a HTTP API for querying the beacon chain and publishing messages to the network. - -USAGE: - lighthouse beacon_node [FLAGS] [OPTIONS] - -FLAGS: - --allow-insecure-genesis-sync Enable syncing from genesis, which is generally insecure and incompatible - with data availability checks. Checkpoint syncing is the preferred method - for syncing a node. Only use this flag when testing. DO NOT use on - mainnet! - --always-prefer-builder-payload This flag is deprecated and has no effect. - --always-prepare-payload Send payload attributes with every fork choice update. This is intended - for use by block builders, relays and developers. You should set a fee - recipient on this BN and also consider adjusting the --prepare-payload- - lookahead flag. - --builder-fallback-disable-checks This flag disables all checks related to chain health. This means the - builder API will always be used for payload construction, regardless of - recent chain conditions. - --compact-db If present, apply compaction to the database on start-up. Use with - caution. It is generally not recommended unless auto-compaction is - disabled. - --disable-backfill-rate-limiting Disable the backfill sync rate-limiting. This allow users to just sync - the entire chain as fast as possible, however it can result in resource - contention which degrades staking performance. Stakers should generally - choose to avoid this flag since backfill sync is not required for - staking. - --disable-deposit-contract-sync Explicitly disables syncing of deposit logs from the execution node. This - overrides any previous option that depends on it. Useful if you intend to - run a non-validating beacon node. - --disable-duplicate-warn-logs This flag is deprecated and has no effect. - -x, --disable-enr-auto-update Discovery automatically updates the nodes local ENR with an external IP - address and port as seen by other peers on the network. This disables - this feature, fixing the ENR's IP/PORT to those specified on boot. - --disable-lock-timeouts Disable the timeouts applied to some internal locks by default. This can - lead to less spurious failures on slow hardware but is considered - experimental as it may obscure performance issues. - --disable-log-timestamp If present, do not include timestamps in logging output. - --disable-malloc-tuning If present, do not configure the system allocator. Providing this flag - will generally increase memory usage, it should only be provided when - debugging specific memory allocation issues. - --disable-optimistic-finalized-sync Force Lighthouse to verify every execution block hash with the execution - client during finalized sync. By default block hashes will be checked in - Lighthouse and only passed to the EL if initial verification fails. - --disable-packet-filter Disables the discovery packet filter. Useful for testing in smaller - networks - --disable-proposer-reorgs Do not attempt to reorg late blocks from other validators when proposing. - --disable-quic Disables the quic transport. The node will rely solely on the TCP - transport for libp2p connections. - --disable-upnp Disables UPnP support. Setting this will prevent Lighthouse from - attempting to automatically establish external port mappings. - --dummy-eth1 If present, uses an eth1 backend that generates static dummy - data.Identical to the method used at the 2019 Canada interop. - --enable-private-discovery Lighthouse by default does not discover private IP addresses. Set this - flag to enable connection attempts to local addresses. - -e, --enr-match Sets the local ENR IP address and port to match those set for lighthouse. - Specifically, the IP address will be the value of --listen-address and - the UDP port will be --discovery-port. - --eth1 If present the node will connect to an eth1 node. This is required for - block production, you must use this flag if you wish to serve a - validator. - --eth1-purge-cache Purges the eth1 block and deposit caches - --genesis-backfill Attempts to download blocks all the way back to genesis when checkpoint - syncing. - --gui Enable the graphical user interface and all its requirements. This - enables --http and --validator-monitor-auto and enables SSE logging. - -h, --help Prints help information - --http Enable the RESTful HTTP API server. Disabled by default. - --http-enable-tls Serves the RESTful HTTP API server over TLS. This feature is currently - experimental. - --import-all-attestations Import and aggregate all attestations, regardless of validator - subscriptions. This will only import attestations from already-subscribed - subnets, use with --subscribe-all-subnets to ensure all attestations are - received for import. - --light-client-server Act as a full node supporting light clients on the p2p network - [experimental] - --log-color Force outputting colors when emitting logs to the terminal. - --logfile-compress If present, compress old log files. This can help reduce the space needed - to store old logs. - --logfile-no-restricted-perms If present, log files will be generated as world-readable meaning they - can be read by any user on the machine. Note that logs can often contain - sensitive information about your validator and so this flag should be - used with caution. For Windows users, the log file permissions will be - inherited from the parent folder. - --metrics Enable the Prometheus metrics HTTP server. Disabled by default. - --private Prevents sending various client identification information. - --proposer-only Sets this beacon node at be a block proposer only node. This will run the - beacon node in a minimal configuration that is sufficient for block - publishing only. This flag should be used for a beacon node being - referenced by validator client using the --proposer-node flag. This - configuration is for enabling more secure setups. - --purge-db If present, the chain database will be deleted. Use with caution. - --reconstruct-historic-states After a checkpoint sync, reconstruct historic states in the database. - This requires syncing all the way back to genesis. - --reset-payload-statuses When present, Lighthouse will forget the payload statuses of any already- - imported blocks. This can assist in the recovery from a consensus - failure caused by the execution layer. - --shutdown-after-sync Shutdown beacon node as soon as sync is completed. Backfill sync will not - be performed before shutdown. - --slasher Run a slasher alongside the beacon node. It is currently only recommended - for expert users because of the immaturity of the slasher UX and the - extra resources required. - --staking Standard option for a staking beacon node. This will enable the HTTP - server on localhost:5052 and import deposit logs from the execution node. - This is equivalent to `--http` on merge-ready networks, or `--http - --eth1` pre-merge - --subscribe-all-subnets Subscribe to all subnets regardless of validator count. This will also - advertise the beacon node as being long-lived subscribed to all subnets. - --validator-monitor-auto Enables the automatic detection and monitoring of validators connected to - the HTTP API and using the subnet subscription endpoint. This generally - has the effect of providing additional logging and metrics for locally - controlled validators. - -V, --version Prints version information - -z, --zero-ports Sets all listening TCP/UDP ports to 0, allowing the OS to choose some - arbitrary free ports. - -OPTIONS: - --auto-compact-db - Enable or disable automatic compaction of the database on finalization. [default: true] - - --blob-prune-margin-epochs - The margin for blob pruning in epochs. The oldest blobs are pruned up until data_availability_boundary - - blob_prune_margin_epochs. [default: 0] - --blobs-dir - Data directory for the blobs database. - - --block-cache-size - Specifies how many blocks the database should cache in memory [default: 5] - - --boot-nodes - One or more comma-delimited base64-encoded ENR's to bootstrap the p2p network. Multiaddr is also supported. - - --builder - The URL of a service compatible with the MEV-boost API. - - --builder-fallback-epochs-since-finalization - If this node is proposing a block and the chain has not finalized within this number of epochs, it will NOT - query any connected builders, and will use the local execution engine for payload construction. Setting this - value to anything less than 2 will cause the node to NEVER query connected builders. Setting it to 2 will - cause this condition to be hit if there are skips slots at the start of an epoch, right before this node is - set to propose. [default: 3] - --builder-fallback-skips - If this node is proposing a block and has seen this number of skip slots on the canonical chain in a row, it - will NOT query any connected builders, and will use the local execution engine for payload construction. - [default: 3] - --builder-fallback-skips-per-epoch - If this node is proposing a block and has seen this number of skip slots on the canonical chain in the past - `SLOTS_PER_EPOCH`, it will NOT query any connected builders, and will use the local execution engine for - payload construction. [default: 8] - --builder-profit-threshold - This flag is deprecated and has no effect. - - --builder-user-agent - The HTTP user agent to send alongside requests to the builder URL. The default is Lighthouse's version - string. - --checkpoint-blobs - Set the checkpoint blobs to start syncing from. Must be aligned and match --checkpoint-block. Using - --checkpoint-sync-url instead is recommended. - --checkpoint-block - Set a checkpoint block to start syncing from. Must be aligned and match --checkpoint-state. Using - --checkpoint-sync-url instead is recommended. - --checkpoint-state - Set a checkpoint state to start syncing from. Must be aligned and match --checkpoint-block. Using - --checkpoint-sync-url instead is recommended. - --checkpoint-sync-url - Set the remote beacon node HTTP endpoint to use for checkpoint sync. - - --checkpoint-sync-url-timeout - Set the timeout for checkpoint sync calls to remote beacon node HTTP endpoint. [default: 180] - - -d, --datadir - Used to specify a custom root data directory for lighthouse keys and databases. Defaults to - $HOME/.lighthouse/{network} where network is the value of the `network` flag Note: Users should specify - separate custom datadirs for different networks. - --debug-level - Specifies the verbosity level used when emitting logs to the terminal. [default: info] [possible values: - info, debug, trace, warn, error, crit] - --discovery-port - The UDP port that discovery will listen on. Defaults to `port` - - --discovery-port6 - The UDP port that discovery will listen on over IPv6 if listening over both IPv4 and IPv6. Defaults to - `port6` - --enr-address
... - The IP address/ DNS address to broadcast to other peers on how to reach this node. If a DNS address is - provided, the enr-address is set to the IP address it resolves to and does not auto-update based on PONG - responses in discovery. Set this only if you are sure other nodes can connect to your local node on this - address. This will update the `ip4` or `ip6` ENR fields accordingly. To update both, set this flag twice - with the different values. - --enr-quic-port - The quic UDP4 port that will be set on the local ENR. Set this only if you are sure other nodes can connect - to your local node on this port over IPv4. - --enr-quic6-port - The quic UDP6 port that will be set on the local ENR. Set this only if you are sure other nodes can connect - to your local node on this port over IPv6. - --enr-tcp-port - The TCP4 port of the local ENR. Set this only if you are sure other nodes can connect to your local node on - this port over IPv4. The --port flag is used if this is not set. - --enr-tcp6-port - The TCP6 port of the local ENR. Set this only if you are sure other nodes can connect to your local node on - this port over IPv6. The --port6 flag is used if this is not set. - --enr-udp-port - The UDP4 port of the local ENR. Set this only if you are sure other nodes can connect to your local node on - this port over IPv4. - --enr-udp6-port - The UDP6 port of the local ENR. Set this only if you are sure other nodes can connect to your local node on - this port over IPv6. - --epochs-per-blob-prune - The epoch interval with which to prune blobs from Lighthouse's database when they are older than the data - availability boundary relative to the current epoch. [default: 1] - --epochs-per-migration - The number of epochs to wait between running the migration of data from the hot DB to the cold DB. Less - frequent runs can be useful for minimizing disk writes [default: 1] - --eth1-blocks-per-log-query - Specifies the number of blocks that a deposit log query should span. This will reduce the size of responses - from the Eth1 endpoint. [default: 1000] - --eth1-cache-follow-distance - Specifies the distance between the Eth1 chain head and the last block which should be imported into the - cache. Setting this value lower can help compensate for irregular Proof-of-Work block times, but setting it - too low can make the node vulnerable to re-orgs. - --execution-endpoint - Server endpoint for an execution layer JWT-authenticated HTTP JSON-RPC connection. Uses the same endpoint to - populate the deposit cache. - --execution-jwt - File path which contains the hex-encoded JWT secret for the execution endpoint provided in the --execution- - endpoint flag. - --execution-jwt-id - Used by the beacon node to communicate a unique identifier to execution nodes during JWT authentication. It - corresponds to the 'id' field in the JWT claims object.Set to empty by default - --execution-jwt-secret-key - Hex-encoded JWT secret for the execution endpoint provided in the --execution-endpoint flag. - - --execution-jwt-version - Used by the beacon node to communicate a client version to execution nodes during JWT authentication. It - corresponds to the 'clv' field in the JWT claims object.Set to empty by default - --execution-timeout-multiplier - Unsigned integer to multiply the default execution timeouts by. [default: 1] - - --fork-choice-before-proposal-timeout - Set the maximum number of milliseconds to wait for fork choice before proposing a block. You can prevent - waiting at all by setting the timeout to 0, however you risk proposing atop the wrong parent block. - [default: 250] - --freezer-dir - Data directory for the freezer database. - - --genesis-state-url - A URL of a beacon-API compatible server from which to download the genesis state. Checkpoint sync server - URLs can generally be used with this flag. If not supplied, a default URL or the --checkpoint-sync-url may - be used. If the genesis state is already included in this binary then this value will be ignored. - --genesis-state-url-timeout - The timeout in seconds for the request to --genesis-state-url. [default: 180] - - --graffiti - Specify your custom graffiti to be included in blocks. Defaults to the current version and commit, truncated - to fit in 32 bytes. - --historic-state-cache-size - Specifies how many states from the freezer database should cache in memory [default: 1] - - --http-address
- Set the listen address for the RESTful HTTP API server. - - --http-allow-origin - Set the value of the Access-Control-Allow-Origin response HTTP header. Use * to allow any origin (not - recommended in production). If no value is supplied, the CORS allowed origin is set to the listen address of - this server (e.g., http://localhost:5052). - --http-duplicate-block-status - Status code to send when a block that is already known is POSTed to the HTTP API. - - --http-enable-beacon-processor - The beacon processor is a scheduler which provides quality-of-service and DoS protection. When set to - "true", HTTP API requests will be queued and scheduled alongside other tasks. When set to "false", HTTP API - responses will be executed immediately. - --http-port - Set the listen TCP port for the RESTful HTTP API server. - - --http-sse-capacity-multiplier - Multiplier to apply to the length of HTTP server-sent-event (SSE) channels. Increasing this value can - prevent messages from being dropped. - --http-tls-cert - The path of the certificate to be used when serving the HTTP API server over TLS. - - --http-tls-key - The path of the private key to be used when serving the HTTP API server over TLS. Must not be password- - protected. - --invalid-gossip-verified-blocks-path - If a block succeeds gossip validation whilst failing full validation, store the block SSZ as a file at this - path. This feature is only recommended for developers. This directory is not pruned, users should be careful - to avoid filling up their disks. - --libp2p-addresses - One or more comma-delimited multiaddrs to manually connect to a libp2p peer without an ENR. - - --listen-address
... - The address lighthouse will listen for UDP and TCP connections. To listen over IpV4 and IpV6 set this flag - twice with the different values. - Examples: - - --listen-address '0.0.0.0' will listen over IPv4. - - --listen-address '::' will listen over IPv6. - - --listen-address '0.0.0.0' --listen-address '::' will listen over both IPv4 and IPv6. The order of the - given addresses is not relevant. However, multiple IPv4, or multiple IPv6 addresses will not be accepted. - [default: 0.0.0.0] - --log-format - Specifies the log format used when emitting logs to the terminal. [possible values: JSON] - - --logfile - File path where the log file will be stored. Once it grows to the value specified in `--logfile-max-size` a - new log file is generated where future logs are stored. Once the number of log files exceeds the value - specified in `--logfile-max-number` the oldest log file will be overwritten. - --logfile-debug-level - The verbosity level used when emitting logs to the log file. [default: debug] [possible values: info, - debug, trace, warn, error, crit] - --logfile-format - Specifies the log format used when emitting logs to the logfile. [possible values: DEFAULT, JSON] - - --logfile-max-number - The maximum number of log files that will be stored. If set to 0, background file logging is disabled. - [default: 5] - --logfile-max-size - The maximum size (in MB) each log file can grow to before rotating. If set to 0, background file logging is - disabled. [default: 200] - --max-skip-slots - Refuse to skip more than this many slots when processing an attestation. This prevents nodes on minority - forks from wasting our time and disk space, but could also cause unnecessary consensus failures, so is - disabled by default. - --metrics-address
- Set the listen address for the Prometheus metrics HTTP server. - - --metrics-allow-origin - Set the value of the Access-Control-Allow-Origin response HTTP header. Use * to allow any origin (not - recommended in production). If no value is supplied, the CORS allowed origin is set to the listen address of - this server (e.g., http://localhost:5054). - --metrics-port - Set the listen TCP port for the Prometheus metrics HTTP server. - - --monitoring-endpoint
- Enables the monitoring service for sending system metrics to a remote endpoint. This can be used to monitor - your setup on certain services (e.g. beaconcha.in). This flag sets the endpoint where the beacon node - metrics will be sent. Note: This will send information to a remote sever which may identify and associate - your validators, IP address and other personal information. Always use a HTTPS connection and never provide - an untrusted URL. - --monitoring-endpoint-period - Defines how many seconds to wait between each message sent to the monitoring-endpoint. Default: 60s - - --network - Name of the Eth2 chain Lighthouse will sync and follow. [possible values: mainnet, gnosis, chiado, sepolia, - holesky] - --network-dir - Data directory for network keys. Defaults to network/ inside the beacon node dir. - - --port - The TCP/UDP ports to listen on. There are two UDP ports. The discovery UDP port will be set to this value - and the Quic UDP port will be set to this value + 1. The discovery port can be modified by the --discovery- - port flag and the quic port can be modified by the --quic-port flag. If listening over both IPv4 - and IPv6 the --port flag will apply to the IPv4 address and --port6 to the IPv6 address. [default: 9000] - --port6 - The TCP/UDP ports to listen on over IPv6 when listening over both IPv4 and IPv6. Defaults to 9090 when - required. The Quic UDP port will be set to this value + 1. [default: 9090] - --prepare-payload-lookahead - The time before the start of a proposal slot at which payload attributes should be sent. Low values are - useful for execution nodes which don't improve their payload after the first call, and high values are - useful for ensuring the EL is given ample notice. Default: 1/3 of a slot. - --progressive-balances - Deprecated. This optimisation is now the default and cannot be disabled. [possible values: fast, disabled, - checked, strict] - --proposer-reorg-cutoff - Maximum delay after the start of the slot at which to propose a reorging block. Lower values can prevent - failed reorgs by ensuring the block has ample time to propagate and be processed by the network. The default - is 1/12th of a slot (1 second on mainnet) - --proposer-reorg-disallowed-offsets - Comma-separated list of integer offsets which can be used to avoid proposing reorging blocks at certain - slots. An offset of N means that reorging proposals will not be attempted at any slot such that `slot % - SLOTS_PER_EPOCH == N`. By default only re-orgs at offset 0 will be avoided. Any offsets supplied with this - flag will impose additional restrictions. - --proposer-reorg-epochs-since-finalization - Maximum number of epochs since finalization at which proposer reorgs are allowed. Default: 2 - - --proposer-reorg-parent-threshold - Percentage of parent vote weight above which to attempt a proposer reorg. Default: 160% - - --proposer-reorg-threshold - Percentage of head vote weight below which to attempt a proposer reorg. Default: 20% - - --prune-blobs - Prune blobs from Lighthouse's database when they are older than the data data availability boundary relative - to the current epoch. [default: true] - --prune-payloads - Prune execution payloads from Lighthouse's database. This saves space but imposes load on the execution - client, as payloads need to be reconstructed and sent to syncing peers. [default: true] - --quic-port - The UDP port that quic will listen on. Defaults to `port` + 1 - - --quic-port6 - The UDP port that quic will listen on over IPv6 if listening over both IPv4 and IPv6. Defaults to `port6` + - 1 - --safe-slots-to-import-optimistically - Used to coordinate manual overrides of the SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY parameter. This flag should - only be used if the user has a clear understanding that the broad Ethereum community has elected to override - this parameter in the event of an attack at the PoS transition block. Incorrect use of this flag can cause - your node to possibly accept an invalid chain or sync more slowly. Be extremely careful with this flag. - --shuffling-cache-size - Some HTTP API requests can be optimised by caching the shufflings at each epoch. This flag allows the user - to set the shuffling cache size in epochs. Shufflings are dependent on validator count and setting this - value to a large number can consume a large amount of memory. - --slasher-att-cache-size - Set the maximum number of attestation roots for the slasher to cache - - --slasher-backend - Set the database backend to be used by the slasher. [possible values: lmdb, disabled] - - --slasher-broadcast - Broadcast slashings found by the slasher to the rest of the network [Enabled by default]. [default: true] - - --slasher-chunk-size - Number of epochs per validator per chunk stored on disk. - - --slasher-dir - Set the slasher's database directory. - - --slasher-history-length - Configure how many epochs of history the slasher keeps. Immutable after initialization. - - --slasher-max-db-size - Maximum size of the MDBX database used by the slasher. - - --slasher-slot-offset - Set the delay from the start of the slot at which the slasher should ingest attestations. Only effective if - the slasher-update-period is a multiple of the slot duration. - --slasher-update-period - Configure how often the slasher runs batch processing. - - --slasher-validator-chunk-size - Number of validators per chunk stored on disk. - - --slots-per-restore-point - Specifies how often a freezer DB restore point should be stored. Cannot be changed after initialization. - [default: 8192 (mainnet) or 64 (minimal)] - --state-cache-size - Specifies the size of the state cache [default: 128] - - --suggested-fee-recipient - Emergency fallback fee recipient for use in case the validator client does not have one configured. You - should set this flag on the validator client instead of (or in addition to) setting it here. - --target-peers - The target number of peers. - - --terminal-block-hash-epoch-override - Used to coordinate manual overrides to the TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH 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 PoW block. Incorrect use of this flag will cause your node to experience a consensus failure. - Be extremely careful with this flag. - --terminal-block-hash-override - Used to coordinate manual overrides to the TERMINAL_BLOCK_HASH 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 - PoW block. Incorrect use of this flag will cause your node to experience a consensus failure. Be extremely - careful with this flag. - --terminal-total-difficulty-override - Used to coordinate manual overrides to the TERMINAL_TOTAL_DIFFICULTY parameter. Accepts a 256-bit decimal - integer (not a hex value). 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. Incorrect use of this flag will - cause your node to experience a consensus failure. Be extremely careful with this flag. - -t, --testnet-dir - Path to directory containing eth2_testnet specs. Defaults to a hard-coded Lighthouse testnet. Only effective - if there is no existing database. - --trusted-peers - One or more comma-delimited trusted peer ids which always have the highest score according to the peer - scoring system. - --trusted-setup-file-override - Path to a json file containing the trusted setup params. NOTE: This will override the trusted setup that is - generated from the mainnet kzg ceremony. Use with caution - --validator-monitor-file - As per --validator-monitor-pubkeys, but the comma-separated list is contained within a file at the given - path. - --validator-monitor-individual-tracking-threshold - Once the validator monitor reaches this number of local validators it will stop collecting per-validator - Prometheus metrics and issuing per-validator logs. Instead, it will provide aggregate metrics and logs. This - avoids infeasibly high cardinality in the Prometheus database and high log volume when using many - validators. Defaults to 64. - --validator-monitor-pubkeys - A comma-separated list of 0x-prefixed validator public keys. These validators will receive special - monitoring and additional logging. - --wss-checkpoint - Specify a weak subjectivity checkpoint in `block_root:epoch` format to verify the node's sync against. The - block root should be 0x-prefixed. Note that this flag is for verification only, to perform a checkpoint sync - from a recent state use --checkpoint-sync-url. +The primary component which connects to the Ethereum 2.0 P2P network and +downloads, verifies and stores blocks. Provides a HTTP API for querying the +beacon chain and publishing messages to the network. + +Usage: lighthouse beacon_node [OPTIONS] + +Options: + --auto-compact-db + Enable or disable automatic compaction of the database on + finalization. [default: true] + --blob-prune-margin-epochs + The margin for blob pruning in epochs. The oldest blobs are pruned up + until data_availability_boundary - blob_prune_margin_epochs. [default: + 0] + --blobs-dir + Data directory for the blobs database. + --block-cache-size + Specifies how many blocks the database should cache in memory + [default: 5] + --boot-nodes + One or more comma-delimited base64-encoded ENR's to bootstrap the p2p + network. Multiaddr is also supported. + --builder + The URL of a service compatible with the MEV-boost API. + --builder-fallback-epochs-since-finalization + If this node is proposing a block and the chain has not finalized + within this number of epochs, it will NOT query any connected + builders, and will use the local execution engine for payload + construction. Setting this value to anything less than 2 will cause + the node to NEVER query connected builders. Setting it to 2 will cause + this condition to be hit if there are skips slots at the start of an + epoch, right before this node is set to propose. [default: 3] + --builder-fallback-skips + If this node is proposing a block and has seen this number of skip + slots on the canonical chain in a row, it will NOT query any connected + builders, and will use the local execution engine for payload + construction. [default: 3] + --builder-fallback-skips-per-epoch + If this node is proposing a block and has seen this number of skip + slots on the canonical chain in the past `SLOTS_PER_EPOCH`, it will + NOT query any connected builders, and will use the local execution + engine for payload construction. [default: 8] + --builder-profit-threshold + This flag is deprecated and has no effect. + --builder-user-agent + The HTTP user agent to send alongside requests to the builder URL. The + default is Lighthouse's version string. + --checkpoint-blobs + Set the checkpoint blobs to start syncing from. Must be aligned and + match --checkpoint-block. Using --checkpoint-sync-url instead is + recommended. + --checkpoint-block + Set a checkpoint block to start syncing from. Must be aligned and + match --checkpoint-state. Using --checkpoint-sync-url instead is + recommended. + --checkpoint-state + Set a checkpoint state to start syncing from. Must be aligned and + match --checkpoint-block. Using --checkpoint-sync-url instead is + recommended. + --checkpoint-sync-url + Set the remote beacon node HTTP endpoint to use for checkpoint sync. + --checkpoint-sync-url-timeout + Set the timeout for checkpoint sync calls to remote beacon node HTTP + endpoint. [default: 180] + -d, --datadir + Used to specify a custom root data directory for lighthouse keys and + databases. Defaults to $HOME/.lighthouse/{network} where network is + the value of the `network` flag Note: Users should specify separate + custom datadirs for different networks. + --debug-level + Specifies the verbosity level used when emitting logs to the terminal. + [default: info] [possible values: info, debug, trace, warn, error, + crit] + --discovery-port + The UDP port that discovery will listen on. Defaults to `port` + --discovery-port6 + The UDP port that discovery will listen on over IPv6 if listening over + both IPv4 and IPv6. Defaults to `port6` + --enr-address
... + The IP address/ DNS address to broadcast to other peers on how to + reach this node. If a DNS address is provided, the enr-address is set + to the IP address it resolves to and does not auto-update based on + PONG responses in discovery. Set this only if you are sure other nodes + can connect to your local node on this address. This will update the + `ip4` or `ip6` ENR fields accordingly. To update both, set this flag + twice with the different values. + --enr-quic-port + The quic UDP4 port that will be set on the local ENR. Set this only if + you are sure other nodes can connect to your local node on this port + over IPv4. + --enr-quic6-port + The quic UDP6 port that will be set on the local ENR. Set this only if + you are sure other nodes can connect to your local node on this port + over IPv6. + --enr-tcp-port + The TCP4 port of the local ENR. Set this only if you are sure other + nodes can connect to your local node on this port over IPv4. The + --port flag is used if this is not set. + --enr-tcp6-port + The TCP6 port of the local ENR. Set this only if you are sure other + nodes can connect to your local node on this port over IPv6. The + --port6 flag is used if this is not set. + --enr-udp-port + The UDP4 port of the local ENR. Set this only if you are sure other + nodes can connect to your local node on this port over IPv4. + --enr-udp6-port + The UDP6 port of the local ENR. Set this only if you are sure other + nodes can connect to your local node on this port over IPv6. + --epochs-per-blob-prune + The epoch interval with which to prune blobs from Lighthouse's + database when they are older than the data availability boundary + relative to the current epoch. [default: 1] + --epochs-per-migration + The number of epochs to wait between running the migration of data + from the hot DB to the cold DB. Less frequent runs can be useful for + minimizing disk writes [default: 1] + --eth1-blocks-per-log-query + Specifies the number of blocks that a deposit log query should span. + This will reduce the size of responses from the Eth1 endpoint. + [default: 1000] + --eth1-cache-follow-distance + Specifies the distance between the Eth1 chain head and the last block + which should be imported into the cache. Setting this value lower can + help compensate for irregular Proof-of-Work block times, but setting + it too low can make the node vulnerable to re-orgs. + --execution-endpoint + Server endpoint for an execution layer JWT-authenticated HTTP JSON-RPC + connection. Uses the same endpoint to populate the deposit cache. + --execution-jwt + File path which contains the hex-encoded JWT secret for the execution + endpoint provided in the --execution-endpoint flag. + --execution-jwt-id + Used by the beacon node to communicate a unique identifier to + execution nodes during JWT authentication. It corresponds to the 'id' + field in the JWT claims object.Set to empty by default + --execution-jwt-secret-key + Hex-encoded JWT secret for the execution endpoint provided in the + --execution-endpoint flag. + --execution-jwt-version + Used by the beacon node to communicate a client version to execution + nodes during JWT authentication. It corresponds to the 'clv' field in + the JWT claims object.Set to empty by default + --execution-timeout-multiplier + Unsigned integer to multiply the default execution timeouts by. + [default: 1] + --fork-choice-before-proposal-timeout + Set the maximum number of milliseconds to wait for fork choice before + proposing a block. You can prevent waiting at all by setting the + timeout to 0, however you risk proposing atop the wrong parent block. + [default: 250] + --freezer-dir + Data directory for the freezer database. + --genesis-state-url + A URL of a beacon-API compatible server from which to download the + genesis state. Checkpoint sync server URLs can generally be used with + this flag. If not supplied, a default URL or the --checkpoint-sync-url + may be used. If the genesis state is already included in this binary + then this value will be ignored. + --genesis-state-url-timeout + The timeout in seconds for the request to --genesis-state-url. + [default: 180] + --graffiti + Specify your custom graffiti to be included in blocks. Defaults to the + current version and commit, truncated to fit in 32 bytes. + --historic-state-cache-size + Specifies how many states from the freezer database should cache in + memory [default: 1] + --http-address
+ Set the listen address for the RESTful HTTP API server. + --http-allow-origin + Set the value of the Access-Control-Allow-Origin response HTTP header. + Use * to allow any origin (not recommended in production). If no value + is supplied, the CORS allowed origin is set to the listen address of + this server (e.g., http://localhost:5052). + --http-duplicate-block-status + Status code to send when a block that is already known is POSTed to + the HTTP API. + --http-enable-beacon-processor + The beacon processor is a scheduler which provides quality-of-service + and DoS protection. When set to "true", HTTP API requests will be + queued and scheduled alongside other tasks. When set to "false", HTTP + API responses will be executed immediately. + --http-port + Set the listen TCP port for the RESTful HTTP API server. + --http-sse-capacity-multiplier + Multiplier to apply to the length of HTTP server-sent-event (SSE) + channels. Increasing this value can prevent messages from being + dropped. + --http-tls-cert + The path of the certificate to be used when serving the HTTP API + server over TLS. + --http-tls-key + The path of the private key to be used when serving the HTTP API + server over TLS. Must not be password-protected. + --inbound-rate-limiter-protocols + Configures the inbound rate limiter (requests received by this + node).Rate limit quotas per protocol can be set in the form of + :/. To set quotas for multiple + protocols, separate them by ';'. This is enabled by default, using + default quotas. To disable rate limiting use the + disable-inbound-rate-limiter flag instead. + --invalid-gossip-verified-blocks-path + If a block succeeds gossip validation whilst failing full validation, + store the block SSZ as a file at this path. This feature is only + recommended for developers. This directory is not pruned, users should + be careful to avoid filling up their disks. + --libp2p-addresses + One or more comma-delimited multiaddrs to manually connect to a libp2p + peer without an ENR. + --listen-address [
...] + The address lighthouse will listen for UDP and TCP connections. To + listen over IpV4 and IpV6 set this flag twice with the different + values. + Examples: + - --listen-address '0.0.0.0' will listen over IPv4. + - --listen-address '::' will listen over IPv6. + - --listen-address '0.0.0.0' --listen-address '::' will listen over + both IPv4 and IPv6. The order of the given addresses is not relevant. + However, multiple IPv4, or multiple IPv6 addresses will not be + accepted. [default: 0.0.0.0] + --log-format + Specifies the log format used when emitting logs to the terminal. + [possible values: JSON] + --logfile + File path where the log file will be stored. Once it grows to the + value specified in `--logfile-max-size` a new log file is generated + where future logs are stored. Once the number of log files exceeds the + value specified in `--logfile-max-number` the oldest log file will be + overwritten. + --logfile-debug-level + The verbosity level used when emitting logs to the log file. [default: + debug] [possible values: info, debug, trace, warn, error, crit] + --logfile-format + Specifies the log format used when emitting logs to the logfile. + [possible values: DEFAULT, JSON] + --logfile-max-number + The maximum number of log files that will be stored. If set to 0, + background file logging is disabled. [default: 5] + --logfile-max-size + The maximum size (in MB) each log file can grow to before rotating. If + set to 0, background file logging is disabled. [default: 200] + --max-skip-slots + Refuse to skip more than this many slots when processing an + attestation. This prevents nodes on minority forks from wasting our + time and disk space, but could also cause unnecessary consensus + failures, so is disabled by default. + --metrics-address
+ Set the listen address for the Prometheus metrics HTTP server. + --metrics-allow-origin + Set the value of the Access-Control-Allow-Origin response HTTP header. + Use * to allow any origin (not recommended in production). If no value + is supplied, the CORS allowed origin is set to the listen address of + this server (e.g., http://localhost:5054). + --metrics-port + Set the listen TCP port for the Prometheus metrics HTTP server. + --monitoring-endpoint
+ Enables the monitoring service for sending system metrics to a remote + endpoint. This can be used to monitor your setup on certain services + (e.g. beaconcha.in). This flag sets the endpoint where the beacon node + metrics will be sent. Note: This will send information to a remote + sever which may identify and associate your validators, IP address and + other personal information. Always use a HTTPS connection and never + provide an untrusted URL. + --monitoring-endpoint-period + Defines how many seconds to wait between each message sent to the + monitoring-endpoint. Default: 60s + --network + Name of the Eth2 chain Lighthouse will sync and follow. [possible + values: mainnet, gnosis, chiado, sepolia, holesky] + --network-dir + Data directory for network keys. Defaults to network/ inside the + beacon node dir. + --port + The TCP/UDP ports to listen on. There are two UDP ports. The discovery + UDP port will be set to this value and the Quic UDP port will be set + to this value + 1. The discovery port can be modified by the + --discovery-port flag and the quic port can be modified by the + --quic-port flag. If listening over both IPv4 and IPv6 the --port flag + will apply to the IPv4 address and --port6 to the IPv6 address. + [default: 9000] + --port6 + The TCP/UDP ports to listen on over IPv6 when listening over both IPv4 + and IPv6. Defaults to 9090 when required. The Quic UDP port will be + set to this value + 1. [default: 9090] + --prepare-payload-lookahead + The time before the start of a proposal slot at which payload + attributes should be sent. Low values are useful for execution nodes + which don't improve their payload after the first call, and high + values are useful for ensuring the EL is given ample notice. Default: + 1/3 of a slot. + --progressive-balances + Deprecated. This optimisation is now the default and cannot be + disabled. + --proposer-reorg-cutoff + Maximum delay after the start of the slot at which to propose a + reorging block. Lower values can prevent failed reorgs by ensuring the + block has ample time to propagate and be processed by the network. The + default is 1/12th of a slot (1 second on mainnet) + --proposer-reorg-disallowed-offsets + Comma-separated list of integer offsets which can be used to avoid + proposing reorging blocks at certain slots. An offset of N means that + reorging proposals will not be attempted at any slot such that `slot % + SLOTS_PER_EPOCH == N`. By default only re-orgs at offset 0 will be + avoided. Any offsets supplied with this flag will impose additional + restrictions. + --proposer-reorg-epochs-since-finalization + Maximum number of epochs since finalization at which proposer reorgs + are allowed. Default: 2 + --proposer-reorg-parent-threshold + Percentage of parent vote weight above which to attempt a proposer + reorg. Default: 160% + --proposer-reorg-threshold + Percentage of head vote weight below which to attempt a proposer + reorg. Default: 20% + --prune-blobs + Prune blobs from Lighthouse's database when they are older than the + data data availability boundary relative to the current epoch. + [default: true] + --prune-payloads + Prune execution payloads from Lighthouse's database. This saves space + but imposes load on the execution client, as payloads need to be + reconstructed and sent to syncing peers. [default: true] + --quic-port + The UDP port that quic will listen on. Defaults to `port` + 1 + --quic-port6 + The UDP port that quic will listen on over IPv6 if listening over both + IPv4 and IPv6. Defaults to `port6` + 1 + --safe-slots-to-import-optimistically + Used to coordinate manual overrides of the + SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY parameter. This flag should only + be used if the user has a clear understanding that the broad Ethereum + community has elected to override this parameter in the event of an + attack at the PoS transition block. Incorrect use of this flag can + cause your node to possibly accept an invalid chain or sync more + slowly. Be extremely careful with this flag. + --self-limiter-protocols + Enables the outbound rate limiter (requests made by this node).Rate + limit quotas per protocol can be set in the form of + :/. To set quotas for multiple + protocols, separate them by ';'. If the self rate limiter is enabled + and a protocol is not present in the configuration, the quotas used + for the inbound rate limiter will be used. + --shuffling-cache-size + Some HTTP API requests can be optimised by caching the shufflings at + each epoch. This flag allows the user to set the shuffling cache size + in epochs. Shufflings are dependent on validator count and setting + this value to a large number can consume a large amount of memory. + --slasher-att-cache-size + Set the maximum number of attestation roots for the slasher to cache + --slasher-backend + Set the database backend to be used by the slasher. [possible values: + lmdb, disabled] + --slasher-broadcast + Broadcast slashings found by the slasher to the rest of the network + [Enabled by default]. [default: true] + --slasher-chunk-size + Number of epochs per validator per chunk stored on disk. + --slasher-dir + Set the slasher's database directory. + --slasher-history-length + Configure how many epochs of history the slasher keeps. Immutable + after initialization. + --slasher-max-db-size + Maximum size of the MDBX database used by the slasher. + --slasher-slot-offset + Set the delay from the start of the slot at which the slasher should + ingest attestations. Only effective if the slasher-update-period is a + multiple of the slot duration. + --slasher-update-period + Configure how often the slasher runs batch processing. + --slasher-validator-chunk-size + Number of validators per chunk stored on disk. + --slots-per-restore-point + Specifies how often a freezer DB restore point should be stored. + Cannot be changed after initialization. [default: 8192 (mainnet) or 64 + (minimal)] + --state-cache-size + Specifies the size of the state cache [default: 128] + --suggested-fee-recipient + Emergency fallback fee recipient for use in case the validator client + does not have one configured. You should set this flag on the + validator client instead of (or in addition to) setting it here. + -t, --testnet-dir + Path to directory containing eth2_testnet specs. Defaults to a + hard-coded Lighthouse testnet. Only effective if there is no existing + database. + --target-peers + The target number of peers. + --terminal-block-hash-epoch-override + Used to coordinate manual overrides to the + TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH 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 PoW block. Incorrect + use of this flag will cause your node to experience a consensus + failure. Be extremely careful with this flag. + --terminal-block-hash-override + Used to coordinate manual overrides to the TERMINAL_BLOCK_HASH + 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 PoW block. Incorrect use of this flag will cause + your node to experience a consensus failure. Be extremely careful with + this flag. + --terminal-total-difficulty-override + Used to coordinate manual overrides to the TERMINAL_TOTAL_DIFFICULTY + parameter. Accepts a 256-bit decimal integer (not a hex value). 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. Incorrect use of this flag will cause your node to + experience a consensus failure. Be extremely careful with this flag. + --trusted-peers + One or more comma-delimited trusted peer ids which always have the + highest score according to the peer scoring system. + --trusted-setup-file-override + Path to a json file containing the trusted setup params. NOTE: This + will override the trusted setup that is generated from the mainnet kzg + ceremony. Use with caution + --validator-monitor-file + As per --validator-monitor-pubkeys, but the comma-separated list is + contained within a file at the given path. + --validator-monitor-individual-tracking-threshold + Once the validator monitor reaches this number of local validators it + will stop collecting per-validator Prometheus metrics and issuing + per-validator logs. Instead, it will provide aggregate metrics and + logs. This avoids infeasibly high cardinality in the Prometheus + database and high log volume when using many validators. Defaults to + 64. + --validator-monitor-pubkeys + A comma-separated list of 0x-prefixed validator public keys. These + validators will receive special monitoring and additional logging. + --wss-checkpoint + Specify a weak subjectivity checkpoint in `block_root:epoch` format to + verify the node's sync against. The block root should be 0x-prefixed. + Note that this flag is for verification only, to perform a checkpoint + sync from a recent state use --checkpoint-sync-url. + -V, --version + Print version + +Flags: + --allow-insecure-genesis-sync + Enable syncing from genesis, which is generally insecure and + incompatible with data availability checks. Checkpoint syncing is the + preferred method for syncing a node. Only use this flag when testing. + DO NOT use on mainnet! + --always-prefer-builder-payload + This flag is deprecated and has no effect. + --always-prepare-payload + Send payload attributes with every fork choice update. This is + intended for use by block builders, relays and developers. You should + set a fee recipient on this BN and also consider adjusting the + --prepare-payload-lookahead flag. + --builder-fallback-disable-checks + This flag disables all checks related to chain health. This means the + builder API will always be used for payload construction, regardless + of recent chain conditions. + --compact-db + If present, apply compaction to the database on start-up. Use with + caution. It is generally not recommended unless auto-compaction is + disabled. + --disable-backfill-rate-limiting + Disable the backfill sync rate-limiting. This allow users to just sync + the entire chain as fast as possible, however it can result in + resource contention which degrades staking performance. Stakers should + generally choose to avoid this flag since backfill sync is not + required for staking. + --disable-deposit-contract-sync + Explicitly disables syncing of deposit logs from the execution node. + This overrides any previous option that depends on it. Useful if you + intend to run a non-validating beacon node. + --disable-duplicate-warn-logs + This flag is deprecated and has no effect. + --disable-enr-auto-update + Discovery automatically updates the nodes local ENR with an external + IP address and port as seen by other peers on the network. This + disables this feature, fixing the ENR's IP/PORT to those specified on + boot. + --disable-inbound-rate-limiter + Disables the inbound rate limiter (requests received by this node). + --disable-lock-timeouts + Disable the timeouts applied to some internal locks by default. This + can lead to less spurious failures on slow hardware but is considered + experimental as it may obscure performance issues. + --disable-log-timestamp + If present, do not include timestamps in logging output. + --disable-malloc-tuning + If present, do not configure the system allocator. Providing this flag + will generally increase memory usage, it should only be provided when + debugging specific memory allocation issues. + --disable-optimistic-finalized-sync + Force Lighthouse to verify every execution block hash with the + execution client during finalized sync. By default block hashes will + be checked in Lighthouse and only passed to the EL if initial + verification fails. + --disable-packet-filter + Disables the discovery packet filter. Useful for testing in smaller + networks + --disable-proposer-reorgs + Do not attempt to reorg late blocks from other validators when + proposing. + --disable-quic + Disables the quic transport. The node will rely solely on the TCP + transport for libp2p connections. + --disable-upnp + Disables UPnP support. Setting this will prevent Lighthouse from + attempting to automatically establish external port mappings. + --dummy-eth1 + If present, uses an eth1 backend that generates static dummy + data.Identical to the method used at the 2019 Canada interop. + -e, --enr-match + Sets the local ENR IP address and port to match those set for + lighthouse. Specifically, the IP address will be the value of + --listen-address and the UDP port will be --discovery-port. + --enable-private-discovery + Lighthouse by default does not discover private IP addresses. Set this + flag to enable connection attempts to local addresses. + --eth1 + If present the node will connect to an eth1 node. This is required for + block production, you must use this flag if you wish to serve a + validator. + --eth1-purge-cache + Purges the eth1 block and deposit caches + --genesis-backfill + Attempts to download blocks all the way back to genesis when + checkpoint syncing. + --gui + Enable the graphical user interface and all its requirements. This + enables --http and --validator-monitor-auto and enables SSE logging. + -h, --help + Prints help information + --http + Enable the RESTful HTTP API server. Disabled by default. + --http-enable-tls + Serves the RESTful HTTP API server over TLS. This feature is currently + experimental. + --import-all-attestations + Import and aggregate all attestations, regardless of validator + subscriptions. This will only import attestations from + already-subscribed subnets, use with --subscribe-all-subnets to ensure + all attestations are received for import. + --light-client-server + Act as a full node supporting light clients on the p2p network + [experimental] + --log-color + Force outputting colors when emitting logs to the terminal. + --logfile-compress + If present, compress old log files. This can help reduce the space + needed to store old logs. + --logfile-no-restricted-perms + If present, log files will be generated as world-readable meaning they + can be read by any user on the machine. Note that logs can often + contain sensitive information about your validator and so this flag + should be used with caution. For Windows users, the log file + permissions will be inherited from the parent folder. + --metrics + Enable the Prometheus metrics HTTP server. Disabled by default. + --private + Prevents sending various client identification information. + --proposer-only + Sets this beacon node at be a block proposer only node. This will run + the beacon node in a minimal configuration that is sufficient for + block publishing only. This flag should be used for a beacon node + being referenced by validator client using the --proposer-node flag. + This configuration is for enabling more secure setups. + --purge-db + If present, the chain database will be deleted. Use with caution. + --reconstruct-historic-states + After a checkpoint sync, reconstruct historic states in the database. + This requires syncing all the way back to genesis. + --reset-payload-statuses + When present, Lighthouse will forget the payload statuses of any + already-imported blocks. This can assist in the recovery from a + consensus failure caused by the execution layer. + --self-limiter + Enables the outbound rate limiter (requests made by this node). Use + the self-limiter-protocol flag to set per protocol configurations. If + the self rate limiter is enabled and a protocol is not present in the + configuration, the quotas used for the inbound rate limiter will be + used. + --shutdown-after-sync + Shutdown beacon node as soon as sync is completed. Backfill sync will + not be performed before shutdown. + --slasher + Run a slasher alongside the beacon node. It is currently only + recommended for expert users because of the immaturity of the slasher + UX and the extra resources required. + --staking + Standard option for a staking beacon node. This will enable the HTTP + server on localhost:5052 and import deposit logs from the execution + node. This is equivalent to `--http` on merge-ready networks, or + `--http --eth1` pre-merge + --subscribe-all-subnets + Subscribe to all subnets regardless of validator count. This will also + advertise the beacon node as being long-lived subscribed to all + subnets. + --validator-monitor-auto + Enables the automatic detection and monitoring of validators connected + to the HTTP API and using the subnet subscription endpoint. This + generally has the effect of providing additional logging and metrics + for locally controlled validators. + -z, --zero-ports + Sets all listening TCP/UDP ports to 0, allowing the OS to choose some + arbitrary free ports. ``` diff --git a/book/src/help_general.md b/book/src/help_general.md index 90d950aa2db..42bff04d1af 100644 --- a/book/src/help_general.md +++ b/book/src/help_general.md @@ -1,109 +1,141 @@ # Lighthouse General Commands ``` -Sigma Prime -Ethereum 2.0 client by Sigma Prime. Provides a full-featured beacon node, a validator client and utilities for managing -validator accounts. +Ethereum 2.0 client by Sigma Prime. Provides a full-featured beacon node, a +validator client and utilities for managing validator accounts. -USAGE: - lighthouse [FLAGS] [OPTIONS] [SUBCOMMAND] +Usage: lighthouse [OPTIONS] [COMMAND] -FLAGS: - --disable-log-timestamp If present, do not include timestamps in logging output. - --disable-malloc-tuning If present, do not configure the system allocator. Providing this flag will - generally increase memory usage, it should only be provided when debugging - specific memory allocation issues. - -l DEPRECATED Enables environment logging giving access to sub-protocol logs such - as discv5 and libp2p - -h, --help Prints help information - --log-color Force outputting colors when emitting logs to the terminal. - --logfile-compress If present, compress old log files. This can help reduce the space needed to - store old logs. - --logfile-no-restricted-perms If present, log files will be generated as world-readable meaning they can be - read by any user on the machine. Note that logs can often contain sensitive - information about your validator and so this flag should be used with caution. - For Windows users, the log file permissions will be inherited from the parent - folder. - -V, --version Prints version information +Commands: + account_manager + Utilities for generating and managing Ethereum 2.0 accounts. [aliases: + a, am, account, account_manager] + beacon_node + The primary component which connects to the Ethereum 2.0 P2P network + and downloads, verifies and stores blocks. Provides a HTTP API for + querying the beacon chain and publishing messages to the network. + [aliases: b, bn, beacon] + boot_node + Start a special Lighthouse process that only serves as a discv5 + boot-node. This process will *not* import blocks or perform most + typical beacon node functions. Instead, it will simply run the discv5 + service and assist nodes on the network to discover each other. This + is the recommended way to provide a network boot-node since it has a + reduced attack surface compared to a full beacon node. + database_manager + Manage a beacon node database [aliases: db] + validator_client + When connected to a beacon node, performs the duties of a staked + validator (e.g., proposing blocks and attestations). [aliases: v, vc, + validator] + validator_manager + Utilities for managing a Lighthouse validator client via the HTTP API. + [aliases: vm, validator-manager, validator_manager] + help + Print this message or the help of the given subcommand(s) -OPTIONS: - -d, --datadir - Used to specify a custom root data directory for lighthouse keys and databases. Defaults to - $HOME/.lighthouse/{network} where network is the value of the `network` flag Note: Users should specify - separate custom datadirs for different networks. - --debug-level - Specifies the verbosity level used when emitting logs to the terminal. [default: info] [possible values: - info, debug, trace, warn, error, crit] - --genesis-state-url - A URL of a beacon-API compatible server from which to download the genesis state. Checkpoint sync server - URLs can generally be used with this flag. If not supplied, a default URL or the --checkpoint-sync-url may - be used. If the genesis state is already included in this binary then this value will be ignored. - --genesis-state-url-timeout - The timeout in seconds for the request to --genesis-state-url. [default: 180] +Options: + -d, --datadir + Used to specify a custom root data directory for lighthouse keys and + databases. Defaults to $HOME/.lighthouse/{network} where network is + the value of the `network` flag Note: Users should specify separate + custom datadirs for different networks. + --debug-level + Specifies the verbosity level used when emitting logs to the terminal. + [default: info] [possible values: info, debug, trace, warn, error, + crit] + --genesis-state-url + A URL of a beacon-API compatible server from which to download the + genesis state. Checkpoint sync server URLs can generally be used with + this flag. If not supplied, a default URL or the --checkpoint-sync-url + may be used. If the genesis state is already included in this binary + then this value will be ignored. + --genesis-state-url-timeout + The timeout in seconds for the request to --genesis-state-url. + [default: 180] + --log-format + Specifies the log format used when emitting logs to the terminal. + [possible values: JSON] + --logfile + File path where the log file will be stored. Once it grows to the + value specified in `--logfile-max-size` a new log file is generated + where future logs are stored. Once the number of log files exceeds the + value specified in `--logfile-max-number` the oldest log file will be + overwritten. + --logfile-debug-level + The verbosity level used when emitting logs to the log file. [default: + debug] [possible values: info, debug, trace, warn, error, crit] + --logfile-format + Specifies the log format used when emitting logs to the logfile. + [possible values: DEFAULT, JSON] + --logfile-max-number + The maximum number of log files that will be stored. If set to 0, + background file logging is disabled. [default: 5] + --logfile-max-size + The maximum size (in MB) each log file can grow to before rotating. If + set to 0, background file logging is disabled. [default: 200] + --network + Name of the Eth2 chain Lighthouse will sync and follow. [possible + values: mainnet, gnosis, chiado, sepolia, holesky] + --safe-slots-to-import-optimistically + Used to coordinate manual overrides of the + SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY parameter. This flag should only + be used if the user has a clear understanding that the broad Ethereum + community has elected to override this parameter in the event of an + attack at the PoS transition block. Incorrect use of this flag can + cause your node to possibly accept an invalid chain or sync more + slowly. Be extremely careful with this flag. + -t, --testnet-dir + Path to directory containing eth2_testnet specs. Defaults to a + hard-coded Lighthouse testnet. Only effective if there is no existing + database. + --terminal-block-hash-epoch-override + Used to coordinate manual overrides to the + TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH 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 PoW block. Incorrect + use of this flag will cause your node to experience a consensus + failure. Be extremely careful with this flag. + --terminal-block-hash-override + Used to coordinate manual overrides to the TERMINAL_BLOCK_HASH + 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 PoW block. Incorrect use of this flag will cause + your node to experience a consensus failure. Be extremely careful with + this flag. + --terminal-total-difficulty-override + Used to coordinate manual overrides to the TERMINAL_TOTAL_DIFFICULTY + parameter. Accepts a 256-bit decimal integer (not a hex value). 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. Incorrect use of this flag will cause your node to + experience a consensus failure. Be extremely careful with this flag. + -V, --version + Print version - --log-format - Specifies the log format used when emitting logs to the terminal. [possible values: JSON] - - --logfile - File path where the log file will be stored. Once it grows to the value specified in `--logfile-max-size` a - new log file is generated where future logs are stored. Once the number of log files exceeds the value - specified in `--logfile-max-number` the oldest log file will be overwritten. - --logfile-debug-level - The verbosity level used when emitting logs to the log file. [default: debug] [possible values: info, - debug, trace, warn, error, crit] - --logfile-format - Specifies the log format used when emitting logs to the logfile. [possible values: DEFAULT, JSON] - - --logfile-max-number - The maximum number of log files that will be stored. If set to 0, background file logging is disabled. - [default: 5] - --logfile-max-size - The maximum size (in MB) each log file can grow to before rotating. If set to 0, background file logging is - disabled. [default: 200] - --network - Name of the Eth2 chain Lighthouse will sync and follow. [possible values: mainnet, gnosis, chiado, sepolia, - holesky] - --safe-slots-to-import-optimistically - Used to coordinate manual overrides of the SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY parameter. This flag should - only be used if the user has a clear understanding that the broad Ethereum community has elected to override - this parameter in the event of an attack at the PoS transition block. Incorrect use of this flag can cause - your node to possibly accept an invalid chain or sync more slowly. Be extremely careful with this flag. - --terminal-block-hash-epoch-override - Used to coordinate manual overrides to the TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH 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 PoW block. Incorrect use of this flag will cause your node to experience a consensus failure. - Be extremely careful with this flag. - --terminal-block-hash-override - Used to coordinate manual overrides to the TERMINAL_BLOCK_HASH 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 - PoW block. Incorrect use of this flag will cause your node to experience a consensus failure. Be extremely - careful with this flag. - --terminal-total-difficulty-override - Used to coordinate manual overrides to the TERMINAL_TOTAL_DIFFICULTY parameter. Accepts a 256-bit decimal - integer (not a hex value). 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. Incorrect use of this flag will - cause your node to experience a consensus failure. Be extremely careful with this flag. - -t, --testnet-dir - Path to directory containing eth2_testnet specs. Defaults to a hard-coded Lighthouse testnet. Only effective - if there is no existing database. - -SUBCOMMANDS: - account_manager Utilities for generating and managing Ethereum 2.0 accounts. [aliases: a, am, account, - account_manager] - beacon_node The primary component which connects to the Ethereum 2.0 P2P network and downloads, - verifies and stores blocks. Provides a HTTP API for querying the beacon chain and - publishing messages to the network. [aliases: b, bn, beacon] - boot_node Start a special Lighthouse process that only serves as a discv5 boot-node. This process - will *not* import blocks or perform most typical beacon node functions. Instead, it will - simply run the discv5 service and assist nodes on the network to discover each other. This - is the recommended way to provide a network boot-node since it has a reduced attack surface - compared to a full beacon node. - database_manager Manage a beacon node database [aliases: db] - help Prints this message or the help of the given subcommand(s) - validator_client When connected to a beacon node, performs the duties of a staked validator (e.g., proposing - blocks and attestations). [aliases: v, vc, validator] - validator_manager Utilities for managing a Lighthouse validator client via the HTTP API. [aliases: vm, - validator-manager, validator_manager] +Flags: + --disable-log-timestamp + If present, do not include timestamps in logging output. + --disable-malloc-tuning + If present, do not configure the system allocator. Providing this flag + will generally increase memory usage, it should only be provided when + debugging specific memory allocation issues. + -h, --help + Prints help information + -l + DEPRECATED Enables environment logging giving access to sub-protocol + logs such as discv5 and libp2p + --log-color + Force outputting colors when emitting logs to the terminal. + --logfile-compress + If present, compress old log files. This can help reduce the space + needed to store old logs. + --logfile-no-restricted-perms + If present, log files will be generated as world-readable meaning they + can be read by any user on the machine. Note that logs can often + contain sensitive information about your validator and so this flag + should be used with caution. For Windows users, the log file + permissions will be inherited from the parent folder. ``` diff --git a/book/src/help_vc.md b/book/src/help_vc.md index f10d837f624..1dba75e5214 100644 --- a/book/src/help_vc.md +++ b/book/src/help_vc.md @@ -1,227 +1,281 @@ # Validator Client ``` -When connected to a beacon node, performs the duties of a staked validator (e.g., proposing blocks and attestations). +When connected to a beacon node, performs the duties of a staked validator +(e.g., proposing blocks and attestations). -USAGE: - lighthouse validator_client [FLAGS] [OPTIONS] +Usage: lighthouse validator_client [OPTIONS] -FLAGS: - --builder-proposals - If this flag is set, Lighthouse will query the Beacon Node for only block headers during proposals and will - sign over headers. Useful for outsourcing execution payload construction during proposals. - --disable-auto-discover - If present, do not attempt to discover new validators in the validators-dir. Validators will need to be - manually added to the validator_definitions.yml file. - --disable-log-timestamp If present, do not include timestamps in logging output. - --disable-malloc-tuning - If present, do not configure the system allocator. Providing this flag will generally increase memory usage, - it should only be provided when debugging specific memory allocation issues. - --disable-run-on-all - DEPRECATED. Use --broadcast. By default, Lighthouse publishes attestation, sync committee subscriptions and - proposer preparation messages to all beacon nodes provided in the `--beacon-nodes flag`. This option changes - that behaviour such that these api calls only go out to the first available and synced beacon node - --disable-slashing-protection-web3signer - Disable Lighthouse's slashing protection for all web3signer keys. This can reduce the I/O burden on the VC - but is only safe if slashing protection is enabled on the remote signer and is implemented correctly. DO NOT - ENABLE THIS FLAG UNLESS YOU ARE CERTAIN THAT SLASHING PROTECTION IS ENABLED ON THE REMOTE SIGNER. YOU WILL - GET SLASHED IF YOU USE THIS FLAG WITHOUT ENABLING WEB3SIGNER'S SLASHING PROTECTION. - --distributed - Enables functionality required for running the validator in a distributed validator cluster. +Options: + --beacon-nodes + Comma-separated addresses to one or more beacon node HTTP APIs. + Default is http://localhost:5052. + --beacon-nodes-tls-certs + Comma-separated paths to custom TLS certificates to use when + connecting to a beacon node (and/or proposer node). These certificates + must be in PEM format and are used in addition to the OS trust store. + Commas must only be used as a delimiter, and must not be part of the + certificate path. + --broadcast + Comma-separated list of beacon API topics to broadcast to all beacon + nodes. Possible values are: none, attestations, blocks, subscriptions, + sync-committee. Default (when flag is omitted) is to broadcast + subscriptions only. + --builder-boost-factor + Defines the boost factor, a percentage multiplier to apply to the + builder's payload value when choosing between a builder payload header + and payload from the local execution node. + --builder-registration-timestamp-override + This flag takes a unix timestamp value that will be used to override + the timestamp used in the builder api registration + -d, --datadir + Used to specify a custom root data directory for lighthouse keys and + databases. Defaults to $HOME/.lighthouse/{network} where network is + the value of the `network` flag Note: Users should specify separate + custom datadirs for different networks. + --debug-level + Specifies the verbosity level used when emitting logs to the terminal. + [default: info] [possible values: info, debug, trace, warn, error, + crit] + --gas-limit + The gas limit to be used in all builder proposals for all validators + managed by this validator client. Note this will not necessarily be + used if the gas limit set here moves too far from the previous block's + gas limit. [default: 30,000,000] + --genesis-state-url + A URL of a beacon-API compatible server from which to download the + genesis state. Checkpoint sync server URLs can generally be used with + this flag. If not supplied, a default URL or the --checkpoint-sync-url + may be used. If the genesis state is already included in this binary + then this value will be ignored. + --genesis-state-url-timeout + The timeout in seconds for the request to --genesis-state-url. + [default: 180] + --graffiti + Specify your custom graffiti to be included in blocks. + --graffiti-file + Specify a graffiti file to load validator graffitis from. + --http-address
+ Set the address for the HTTP address. The HTTP server is not encrypted + and therefore it is unsafe to publish on a public network. When this + flag is used, it additionally requires the explicit use of the + `--unencrypted-http-transport` flag to ensure the user is aware of the + risks involved. For access via the Internet, users should apply + transport-layer security like a HTTPS reverse-proxy or SSH tunnelling. + --http-allow-origin + Set the value of the Access-Control-Allow-Origin response HTTP header. + Use * to allow any origin (not recommended in production). If no value + is supplied, the CORS allowed origin is set to the listen address of + this server (e.g., http://localhost:5062). + --http-port + Set the listen TCP port for the RESTful HTTP API server. + --log-format + Specifies the log format used when emitting logs to the terminal. + [possible values: JSON] + --logfile + File path where the log file will be stored. Once it grows to the + value specified in `--logfile-max-size` a new log file is generated + where future logs are stored. Once the number of log files exceeds the + value specified in `--logfile-max-number` the oldest log file will be + overwritten. + --logfile-debug-level + The verbosity level used when emitting logs to the log file. [default: + debug] [possible values: info, debug, trace, warn, error, crit] + --logfile-format + Specifies the log format used when emitting logs to the logfile. + [possible values: DEFAULT, JSON] + --logfile-max-number + The maximum number of log files that will be stored. If set to 0, + background file logging is disabled. [default: 5] + --logfile-max-size + The maximum size (in MB) each log file can grow to before rotating. If + set to 0, background file logging is disabled. [default: 200] + --metrics-address
+ Set the listen address for the Prometheus metrics HTTP server. + --metrics-allow-origin + Set the value of the Access-Control-Allow-Origin response HTTP header. + Use * to allow any origin (not recommended in production). If no value + is supplied, the CORS allowed origin is set to the listen address of + this server (e.g., http://localhost:5064). + --metrics-port + Set the listen TCP port for the Prometheus metrics HTTP server. + --monitoring-endpoint
+ Enables the monitoring service for sending system metrics to a remote + endpoint. This can be used to monitor your setup on certain services + (e.g. beaconcha.in). This flag sets the endpoint where the beacon node + metrics will be sent. Note: This will send information to a remote + sever which may identify and associate your validators, IP address and + other personal information. Always use a HTTPS connection and never + provide an untrusted URL. + --monitoring-endpoint-period + Defines how many seconds to wait between each message sent to the + monitoring-endpoint. Default: 60s + --network + Name of the Eth2 chain Lighthouse will sync and follow. [possible + values: mainnet, gnosis, chiado, sepolia, holesky] + --proposer-nodes + Comma-separated addresses to one or more beacon node HTTP APIs. These + specify nodes that are used to send beacon block proposals. A failure + will revert back to the standard beacon nodes specified in + --beacon-nodes. + --safe-slots-to-import-optimistically + Used to coordinate manual overrides of the + SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY parameter. This flag should only + be used if the user has a clear understanding that the broad Ethereum + community has elected to override this parameter in the event of an + attack at the PoS transition block. Incorrect use of this flag can + cause your node to possibly accept an invalid chain or sync more + slowly. Be extremely careful with this flag. + --secrets-dir + The directory which contains the password to unlock the validator + voting keypairs. Each password should be contained in a file where the + name is the 0x-prefixed hex representation of the validators voting + public key. Defaults to ~/.lighthouse/{network}/secrets. + --suggested-fee-recipient + Once the merge has happened, this address will receive transaction + fees from blocks proposed by this validator client. If a fee recipient + is configured in the validator definitions it takes priority over this + value. + -t, --testnet-dir + Path to directory containing eth2_testnet specs. Defaults to a + hard-coded Lighthouse testnet. Only effective if there is no existing + database. + --terminal-block-hash-epoch-override + Used to coordinate manual overrides to the + TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH 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 PoW block. Incorrect + use of this flag will cause your node to experience a consensus + failure. Be extremely careful with this flag. + --terminal-block-hash-override + Used to coordinate manual overrides to the TERMINAL_BLOCK_HASH + 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 PoW block. Incorrect use of this flag will cause + your node to experience a consensus failure. Be extremely careful with + this flag. + --terminal-total-difficulty-override + Used to coordinate manual overrides to the TERMINAL_TOTAL_DIFFICULTY + parameter. Accepts a 256-bit decimal integer (not a hex value). 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. Incorrect use of this flag will cause your node to + experience a consensus failure. Be extremely careful with this flag. + --validator-registration-batch-size + Defines the number of validators per validator/register_validator + request sent to the BN. This value can be reduced to avoid timeouts + from builders. [default: 500] + --validators-dir + The directory which contains the validator keystores, deposit data for + each validator along with the common slashing protection database and + the validator_definitions.yml + --web3-signer-keep-alive-timeout + Keep-alive timeout for each web3signer connection. Set to 'null' to + never timeout [default: 20000] + --web3-signer-max-idle-connections + Maximum number of idle connections to maintain per web3signer host. + Default is unlimited. - --enable-doppelganger-protection - If this flag is set, Lighthouse will delay startup for three epochs and monitor for messages on the network - by any of the validators managed by this client. This will result in three (possibly four) epochs worth of - missed attestations. If an attestation is detected during this period, it means it is very likely that you - are running a second validator client with the same keys. This validator client will immediately shutdown if - this is detected in order to avoid potentially committing a slashable offense. Use this flag in order to - ENABLE this functionality, without this flag Lighthouse will begin attesting immediately. - --enable-high-validator-count-metrics - Enable per validator metrics for > 64 validators. Note: This flag is automatically enabled for <= 64 - validators. Enabling this metric for higher validator counts will lead to higher volume of prometheus - metrics being collected. - -h, --help Prints help information - --http Enable the RESTful HTTP API server. Disabled by default. - --http-allow-keystore-export - If present, allow access to the DELETE /lighthouse/keystores HTTP API method, which allows exporting - keystores and passwords to HTTP API consumers who have access to the API token. This method is useful for - exporting validators, however it should be used with caution since it exposes private key data to authorized - users. - --http-store-passwords-in-secrets-dir - If present, any validators created via the HTTP will have keystore passwords stored in the secrets-dir - rather than the validator definitions file. - --init-slashing-protection - If present, do not require the slashing protection database to exist before running. You SHOULD NOT use this - flag unless you're certain that a new slashing protection database is required. Usually, your database will - have been initialized when you imported your validator keys. If you misplace your database and then run with - this flag you risk being slashed. - --log-color Force outputting colors when emitting logs to the terminal. - --logfile-compress - If present, compress old log files. This can help reduce the space needed to store old logs. - - --logfile-no-restricted-perms - If present, log files will be generated as world-readable meaning they can be read by any user on the - machine. Note that logs can often contain sensitive information about your validator and so this flag should - be used with caution. For Windows users, the log file permissions will be inherited from the parent folder. - --metrics Enable the Prometheus metrics HTTP server. Disabled by default. - --prefer-builder-proposals - If this flag is set, Lighthouse will always prefer blocks constructed by builders, regardless of payload - value. - --produce-block-v3 - Enable block production via the block v3 endpoint for this validator client. This should only be enabled - when paired with a beacon node that has this endpoint implemented. This flag will be enabled by default in - future. - --unencrypted-http-transport - This is a safety flag to ensure that the user is aware that the http transport is unencrypted and using a - custom HTTP address is unsafe. - --use-long-timeouts - If present, the validator client will use longer timeouts for requests made to the beacon node. This flag is - generally not recommended, longer timeouts can cause missed duties when fallbacks are used. - -V, --version Prints version information - -OPTIONS: - --beacon-nodes - Comma-separated addresses to one or more beacon node HTTP APIs. Default is http://localhost:5052. - - --beacon-nodes-tls-certs - Comma-separated paths to custom TLS certificates to use when connecting to a beacon node (and/or proposer - node). These certificates must be in PEM format and are used in addition to the OS trust store. Commas must - only be used as a delimiter, and must not be part of the certificate path. - --broadcast - Comma-separated list of beacon API topics to broadcast to all beacon nodes. Possible values are: none, - attestations, blocks, subscriptions, sync-committee. Default (when flag is omitted) is to broadcast - subscriptions only. - --builder-boost-factor - Defines the boost factor, a percentage multiplier to apply to the builder's payload value when choosing - between a builder payload header and payload from the local execution node. - --builder-registration-timestamp-override - This flag takes a unix timestamp value that will be used to override the timestamp used in the builder api - registration - -d, --datadir - Used to specify a custom root data directory for lighthouse keys and databases. Defaults to - $HOME/.lighthouse/{network} where network is the value of the `network` flag Note: Users should specify - separate custom datadirs for different networks. - --debug-level - Specifies the verbosity level used when emitting logs to the terminal. [default: info] [possible values: - info, debug, trace, warn, error, crit] - --gas-limit - The gas limit to be used in all builder proposals for all validators managed by this validator client. Note - this will not necessarily be used if the gas limit set here moves too far from the previous block's gas - limit. [default: 30,000,000] - --genesis-state-url - A URL of a beacon-API compatible server from which to download the genesis state. Checkpoint sync server - URLs can generally be used with this flag. If not supplied, a default URL or the --checkpoint-sync-url may - be used. If the genesis state is already included in this binary then this value will be ignored. - --genesis-state-url-timeout - The timeout in seconds for the request to --genesis-state-url. [default: 180] - - --graffiti - Specify your custom graffiti to be included in blocks. - - --graffiti-file - Specify a graffiti file to load validator graffitis from. - - --http-address
- Set the address for the HTTP address. The HTTP server is not encrypted and therefore it is unsafe to publish - on a public network. When this flag is used, it additionally requires the explicit use of the - `--unencrypted-http-transport` flag to ensure the user is aware of the risks involved. For access via the - Internet, users should apply transport-layer security like a HTTPS reverse-proxy or SSH tunnelling. - --http-allow-origin - Set the value of the Access-Control-Allow-Origin response HTTP header. Use * to allow any origin (not - recommended in production). If no value is supplied, the CORS allowed origin is set to the listen address of - this server (e.g., http://localhost:5062). - --http-port - Set the listen TCP port for the RESTful HTTP API server. - - --latency-measurement-service - Set to 'true' to enable a service that periodically attempts to measure latency to BNs. Set to 'false' to - disable. [default: true] - --log-format - Specifies the log format used when emitting logs to the terminal. [possible values: JSON] - - --logfile - File path where the log file will be stored. Once it grows to the value specified in `--logfile-max-size` a - new log file is generated where future logs are stored. Once the number of log files exceeds the value - specified in `--logfile-max-number` the oldest log file will be overwritten. - --logfile-debug-level - The verbosity level used when emitting logs to the log file. [default: debug] [possible values: info, - debug, trace, warn, error, crit] - --logfile-format - Specifies the log format used when emitting logs to the logfile. [possible values: DEFAULT, JSON] - - --logfile-max-number - The maximum number of log files that will be stored. If set to 0, background file logging is disabled. - [default: 5] - --logfile-max-size - The maximum size (in MB) each log file can grow to before rotating. If set to 0, background file logging is - disabled. [default: 200] - --metrics-address
- Set the listen address for the Prometheus metrics HTTP server. - - --metrics-allow-origin - Set the value of the Access-Control-Allow-Origin response HTTP header. Use * to allow any origin (not - recommended in production). If no value is supplied, the CORS allowed origin is set to the listen address of - this server (e.g., http://localhost:5064). - --metrics-port - Set the listen TCP port for the Prometheus metrics HTTP server. - - --monitoring-endpoint
- Enables the monitoring service for sending system metrics to a remote endpoint. This can be used to monitor - your setup on certain services (e.g. beaconcha.in). This flag sets the endpoint where the beacon node - metrics will be sent. Note: This will send information to a remote sever which may identify and associate - your validators, IP address and other personal information. Always use a HTTPS connection and never provide - an untrusted URL. - --monitoring-endpoint-period - Defines how many seconds to wait between each message sent to the monitoring-endpoint. Default: 60s - - --network - Name of the Eth2 chain Lighthouse will sync and follow. [possible values: mainnet, gnosis, chiado, sepolia, - holesky] - --proposer-nodes - Comma-separated addresses to one or more beacon node HTTP APIs. These specify nodes that are used to send - beacon block proposals. A failure will revert back to the standard beacon nodes specified in --beacon-nodes. - --safe-slots-to-import-optimistically - Used to coordinate manual overrides of the SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY parameter. This flag should - only be used if the user has a clear understanding that the broad Ethereum community has elected to override - this parameter in the event of an attack at the PoS transition block. Incorrect use of this flag can cause - your node to possibly accept an invalid chain or sync more slowly. Be extremely careful with this flag. - --secrets-dir - The directory which contains the password to unlock the validator voting keypairs. Each password should be - contained in a file where the name is the 0x-prefixed hex representation of the validators voting public - key. Defaults to ~/.lighthouse/{network}/secrets. - --suggested-fee-recipient - Once the merge has happened, this address will receive transaction fees from blocks proposed by this - validator client. If a fee recipient is configured in the validator definitions it takes priority over this - value. - --terminal-block-hash-epoch-override - Used to coordinate manual overrides to the TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH 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 PoW block. Incorrect use of this flag will cause your node to experience a consensus failure. - Be extremely careful with this flag. - --terminal-block-hash-override - Used to coordinate manual overrides to the TERMINAL_BLOCK_HASH 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 - PoW block. Incorrect use of this flag will cause your node to experience a consensus failure. Be extremely - careful with this flag. - --terminal-total-difficulty-override - Used to coordinate manual overrides to the TERMINAL_TOTAL_DIFFICULTY parameter. Accepts a 256-bit decimal - integer (not a hex value). 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. Incorrect use of this flag will - cause your node to experience a consensus failure. Be extremely careful with this flag. - -t, --testnet-dir - Path to directory containing eth2_testnet specs. Defaults to a hard-coded Lighthouse testnet. Only effective - if there is no existing database. - --validator-registration-batch-size - Defines the number of validators per validator/register_validator request sent to the BN. This value can be - reduced to avoid timeouts from builders. [default: 500] - --validators-dir - The directory which contains the validator keystores, deposit data for each validator along with the common - slashing protection database and the validator_definitions.yml - --web3-signer-keep-alive-timeout - Keep-alive timeout for each web3signer connection. Set to 'null' to never timeout [default: 20000] - - --web3-signer-max-idle-connections - Maximum number of idle connections to maintain per web3signer host. Default is unlimited. +Flags: + --builder-proposals + If this flag is set, Lighthouse will query the Beacon Node for only + block headers during proposals and will sign over headers. Useful for + outsourcing execution payload construction during proposals. + --disable-auto-discover + If present, do not attempt to discover new validators in the + validators-dir. Validators will need to be manually added to the + validator_definitions.yml file. + --disable-latency-measurement-service + Disables the service that periodically attempts to measure latency to + BNs. + --disable-log-timestamp + If present, do not include timestamps in logging output. + --disable-malloc-tuning + If present, do not configure the system allocator. Providing this flag + will generally increase memory usage, it should only be provided when + debugging specific memory allocation issues. + --disable-run-on-all + DEPRECATED. Use --broadcast. By default, Lighthouse publishes + attestation, sync committee subscriptions and proposer preparation + messages to all beacon nodes provided in the `--beacon-nodes flag`. + This option changes that behaviour such that these api calls only go + out to the first available and synced beacon node + --disable-slashing-protection-web3signer + Disable Lighthouse's slashing protection for all web3signer keys. This + can reduce the I/O burden on the VC but is only safe if slashing + protection is enabled on the remote signer and is implemented + correctly. DO NOT ENABLE THIS FLAG UNLESS YOU ARE CERTAIN THAT + SLASHING PROTECTION IS ENABLED ON THE REMOTE SIGNER. YOU WILL GET + SLASHED IF YOU USE THIS FLAG WITHOUT ENABLING WEB3SIGNER'S SLASHING + PROTECTION. + --distributed + Enables functionality required for running the validator in a + distributed validator cluster. + --enable-doppelganger-protection + If this flag is set, Lighthouse will delay startup for three epochs + and monitor for messages on the network by any of the validators + managed by this client. This will result in three (possibly four) + epochs worth of missed attestations. If an attestation is detected + during this period, it means it is very likely that you are running a + second validator client with the same keys. This validator client will + immediately shutdown if this is detected in order to avoid potentially + committing a slashable offense. Use this flag in order to ENABLE this + functionality, without this flag Lighthouse will begin attesting + immediately. + --enable-high-validator-count-metrics + Enable per validator metrics for > 64 validators. Note: This flag is + automatically enabled for <= 64 validators. Enabling this metric for + higher validator counts will lead to higher volume of prometheus + metrics being collected. + -h, --help + Prints help information + --http + Enable the RESTful HTTP API server. Disabled by default. + --http-allow-keystore-export + If present, allow access to the DELETE /lighthouse/keystores HTTP API + method, which allows exporting keystores and passwords to HTTP API + consumers who have access to the API token. This method is useful for + exporting validators, however it should be used with caution since it + exposes private key data to authorized users. + --http-store-passwords-in-secrets-dir + If present, any validators created via the HTTP will have keystore + passwords stored in the secrets-dir rather than the validator + definitions file. + --init-slashing-protection + If present, do not require the slashing protection database to exist + before running. You SHOULD NOT use this flag unless you're certain + that a new slashing protection database is required. Usually, your + database will have been initialized when you imported your validator + keys. If you misplace your database and then run with this flag you + risk being slashed. + --log-color + Force outputting colors when emitting logs to the terminal. + --logfile-compress + If present, compress old log files. This can help reduce the space + needed to store old logs. + --logfile-no-restricted-perms + If present, log files will be generated as world-readable meaning they + can be read by any user on the machine. Note that logs can often + contain sensitive information about your validator and so this flag + should be used with caution. For Windows users, the log file + permissions will be inherited from the parent folder. + --metrics + Enable the Prometheus metrics HTTP server. Disabled by default. + --prefer-builder-proposals + If this flag is set, Lighthouse will always prefer blocks constructed + by builders, regardless of payload value. + --produce-block-v3 + Enable block production via the block v3 endpoint for this validator + client. This should only be enabled when paired with a beacon node + that has this endpoint implemented. This flag will be enabled by + default in future. + --unencrypted-http-transport + This is a safety flag to ensure that the user is aware that the http + transport is unencrypted and using a custom HTTP address is unsafe. + --use-long-timeouts + If present, the validator client will use longer timeouts for requests + made to the beacon node. This flag is generally not recommended, + longer timeouts can cause missed duties when fallbacks are used. ``` diff --git a/book/src/help_vm.md b/book/src/help_vm.md index c3d505df40d..6f9cc405e76 100644 --- a/book/src/help_vm.md +++ b/book/src/help_vm.md @@ -3,97 +3,126 @@ ``` Utilities for managing a Lighthouse validator client via the HTTP API. -USAGE: - lighthouse validator_manager [FLAGS] [OPTIONS] [SUBCOMMAND] +Usage: lighthouse validator_manager [OPTIONS] [COMMAND] -FLAGS: - --disable-log-timestamp If present, do not include timestamps in logging output. - --disable-malloc-tuning If present, do not configure the system allocator. Providing this flag will - generally increase memory usage, it should only be provided when debugging - specific memory allocation issues. - -h, --help Prints help information - --log-color Force outputting colors when emitting logs to the terminal. - --logfile-compress If present, compress old log files. This can help reduce the space needed to - store old logs. - --logfile-no-restricted-perms If present, log files will be generated as world-readable meaning they can be - read by any user on the machine. Note that logs can often contain sensitive - information about your validator and so this flag should be used with caution. - For Windows users, the log file permissions will be inherited from the parent - folder. - -V, --version Prints version information +Commands: + create + Creates new validators from BIP-39 mnemonic. A JSON file will be + created which contains all the validator keystores and other validator + data. This file can then be imported to a validator client using the + "import-validators" command. Another, optional JSON file is created + which contains a list of validator deposits in the same format as the + "ethereum/staking-deposit-cli" tool. + import + Uploads validators to a validator client using the HTTP API. The + validators are defined in a JSON file which can be generated using the + "create-validators" command. + move + Uploads validators to a validator client using the HTTP API. The + validators are defined in a JSON file which can be generated using the + "create-validators" command. This command only supports validators + signing via a keystore on the local file system (i.e., not Web3Signer + validators). + help + Print this message or the help of the given subcommand(s) -OPTIONS: - -d, --datadir - Used to specify a custom root data directory for lighthouse keys and databases. Defaults to - $HOME/.lighthouse/{network} where network is the value of the `network` flag Note: Users should specify - separate custom datadirs for different networks. - --debug-level - Specifies the verbosity level used when emitting logs to the terminal. [default: info] [possible values: - info, debug, trace, warn, error, crit] - --genesis-state-url - A URL of a beacon-API compatible server from which to download the genesis state. Checkpoint sync server - URLs can generally be used with this flag. If not supplied, a default URL or the --checkpoint-sync-url may - be used. If the genesis state is already included in this binary then this value will be ignored. - --genesis-state-url-timeout - The timeout in seconds for the request to --genesis-state-url. [default: 180] +Options: + -d, --datadir + Used to specify a custom root data directory for lighthouse keys and + databases. Defaults to $HOME/.lighthouse/{network} where network is + the value of the `network` flag Note: Users should specify separate + custom datadirs for different networks. + --debug-level + Specifies the verbosity level used when emitting logs to the terminal. + [default: info] [possible values: info, debug, trace, warn, error, + crit] + --genesis-state-url + A URL of a beacon-API compatible server from which to download the + genesis state. Checkpoint sync server URLs can generally be used with + this flag. If not supplied, a default URL or the --checkpoint-sync-url + may be used. If the genesis state is already included in this binary + then this value will be ignored. + --genesis-state-url-timeout + The timeout in seconds for the request to --genesis-state-url. + [default: 180] + --log-format + Specifies the log format used when emitting logs to the terminal. + [possible values: JSON] + --logfile + File path where the log file will be stored. Once it grows to the + value specified in `--logfile-max-size` a new log file is generated + where future logs are stored. Once the number of log files exceeds the + value specified in `--logfile-max-number` the oldest log file will be + overwritten. + --logfile-debug-level + The verbosity level used when emitting logs to the log file. [default: + debug] [possible values: info, debug, trace, warn, error, crit] + --logfile-format + Specifies the log format used when emitting logs to the logfile. + [possible values: DEFAULT, JSON] + --logfile-max-number + The maximum number of log files that will be stored. If set to 0, + background file logging is disabled. [default: 5] + --logfile-max-size + The maximum size (in MB) each log file can grow to before rotating. If + set to 0, background file logging is disabled. [default: 200] + --network + Name of the Eth2 chain Lighthouse will sync and follow. [possible + values: mainnet, gnosis, chiado, sepolia, holesky] + --safe-slots-to-import-optimistically + Used to coordinate manual overrides of the + SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY parameter. This flag should only + be used if the user has a clear understanding that the broad Ethereum + community has elected to override this parameter in the event of an + attack at the PoS transition block. Incorrect use of this flag can + cause your node to possibly accept an invalid chain or sync more + slowly. Be extremely careful with this flag. + -t, --testnet-dir + Path to directory containing eth2_testnet specs. Defaults to a + hard-coded Lighthouse testnet. Only effective if there is no existing + database. + --terminal-block-hash-epoch-override + Used to coordinate manual overrides to the + TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH 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 PoW block. Incorrect + use of this flag will cause your node to experience a consensus + failure. Be extremely careful with this flag. + --terminal-block-hash-override + Used to coordinate manual overrides to the TERMINAL_BLOCK_HASH + 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 PoW block. Incorrect use of this flag will cause + your node to experience a consensus failure. Be extremely careful with + this flag. + --terminal-total-difficulty-override + Used to coordinate manual overrides to the TERMINAL_TOTAL_DIFFICULTY + parameter. Accepts a 256-bit decimal integer (not a hex value). 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. Incorrect use of this flag will cause your node to + experience a consensus failure. Be extremely careful with this flag. - --log-format - Specifies the log format used when emitting logs to the terminal. [possible values: JSON] - - --logfile - File path where the log file will be stored. Once it grows to the value specified in `--logfile-max-size` a - new log file is generated where future logs are stored. Once the number of log files exceeds the value - specified in `--logfile-max-number` the oldest log file will be overwritten. - --logfile-debug-level - The verbosity level used when emitting logs to the log file. [default: debug] [possible values: info, - debug, trace, warn, error, crit] - --logfile-format - Specifies the log format used when emitting logs to the logfile. [possible values: DEFAULT, JSON] - - --logfile-max-number - The maximum number of log files that will be stored. If set to 0, background file logging is disabled. - [default: 5] - --logfile-max-size - The maximum size (in MB) each log file can grow to before rotating. If set to 0, background file logging is - disabled. [default: 200] - --network - Name of the Eth2 chain Lighthouse will sync and follow. [possible values: mainnet, gnosis, chiado, sepolia, - holesky] - --safe-slots-to-import-optimistically - Used to coordinate manual overrides of the SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY parameter. This flag should - only be used if the user has a clear understanding that the broad Ethereum community has elected to override - this parameter in the event of an attack at the PoS transition block. Incorrect use of this flag can cause - your node to possibly accept an invalid chain or sync more slowly. Be extremely careful with this flag. - --terminal-block-hash-epoch-override - Used to coordinate manual overrides to the TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH 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 PoW block. Incorrect use of this flag will cause your node to experience a consensus failure. - Be extremely careful with this flag. - --terminal-block-hash-override - Used to coordinate manual overrides to the TERMINAL_BLOCK_HASH 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 - PoW block. Incorrect use of this flag will cause your node to experience a consensus failure. Be extremely - careful with this flag. - --terminal-total-difficulty-override - Used to coordinate manual overrides to the TERMINAL_TOTAL_DIFFICULTY parameter. Accepts a 256-bit decimal - integer (not a hex value). 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. Incorrect use of this flag will - cause your node to experience a consensus failure. Be extremely careful with this flag. - -t, --testnet-dir - Path to directory containing eth2_testnet specs. Defaults to a hard-coded Lighthouse testnet. Only effective - if there is no existing database. - -SUBCOMMANDS: - create Creates new validators from BIP-39 mnemonic. A JSON file will be created which contains all the - validator keystores and other validator data. This file can then be imported to a validator client - using the "import-validators" command. Another, optional JSON file is created which contains a list of - validator deposits in the same format as the "ethereum/staking-deposit-cli" tool. - help Prints this message or the help of the given subcommand(s) - import Uploads validators to a validator client using the HTTP API. The validators are defined in a JSON file - which can be generated using the "create-validators" command. - move Uploads validators to a validator client using the HTTP API. The validators are defined in a JSON file - which can be generated using the "create-validators" command. This command only supports validators - signing via a keystore on the local file system (i.e., not Web3Signer validators). +Flags: + --disable-log-timestamp + If present, do not include timestamps in logging output. + --disable-malloc-tuning + If present, do not configure the system allocator. Providing this flag + will generally increase memory usage, it should only be provided when + debugging specific memory allocation issues. + -h, --help + Prints help information + --log-color + Force outputting colors when emitting logs to the terminal. + --logfile-compress + If present, compress old log files. This can help reduce the space + needed to store old logs. + --logfile-no-restricted-perms + If present, log files will be generated as world-readable meaning they + can be read by any user on the machine. Note that logs can often + contain sensitive information about your validator and so this flag + should be used with caution. For Windows users, the log file + permissions will be inherited from the parent folder. ``` diff --git a/book/src/help_vm_create.md b/book/src/help_vm_create.md index af4a491e764..4ddb360e483 100644 --- a/book/src/help_vm_create.md +++ b/book/src/help_vm_create.md @@ -1,139 +1,169 @@ # Validator Manager Create ``` -Creates new validators from BIP-39 mnemonic. A JSON file will be created which contains all the validator keystores and -other validator data. This file can then be imported to a validator client using the "import-validators" command. -Another, optional JSON file is created which contains a list of validator deposits in the same format as the -"ethereum/staking-deposit-cli" tool. +Creates new validators from BIP-39 mnemonic. A JSON file will be created which +contains all the validator keystores and other validator data. This file can +then be imported to a validator client using the "import-validators" command. +Another, optional JSON file is created which contains a list of validator +deposits in the same format as the "ethereum/staking-deposit-cli" tool. -USAGE: - lighthouse validator_manager create [FLAGS] [OPTIONS] --output-path +Usage: lighthouse validator_manager create [OPTIONS] --output-path -FLAGS: - --disable-deposits When provided don't generate the deposits JSON file that is commonly used - for submitting validator deposits via a web UI. Using this flag will save - several seconds per validator if the user has an alternate strategy for - submitting deposits. - --disable-log-timestamp If present, do not include timestamps in logging output. - --disable-malloc-tuning If present, do not configure the system allocator. Providing this flag - will generally increase memory usage, it should only be provided when - debugging specific memory allocation issues. - --force-bls-withdrawal-credentials If present, allows BLS withdrawal credentials rather than an execution - address. This is not recommended. - -h, --help Prints help information - --log-color Force outputting colors when emitting logs to the terminal. - --logfile-compress If present, compress old log files. This can help reduce the space needed - to store old logs. - --logfile-no-restricted-perms If present, log files will be generated as world-readable meaning they can - be read by any user on the machine. Note that logs can often contain - sensitive information about your validator and so this flag should be used - with caution. For Windows users, the log file permissions will be - inherited from the parent folder. - --specify-voting-keystore-password If present, the user will be prompted to enter the voting keystore - password that will be used to encrypt the voting keystores. If this flag - is not provided, a random password will be used. It is not necessary to - keep backups of voting keystore passwords if the mnemonic is safely backed - up. - --stdin-inputs If present, read all user inputs from stdin instead of tty. - -V, --version Prints version information +Options: + --beacon-node + A HTTP(S) address of a beacon node using the beacon-API. If this value + is provided, an error will be raised if any validator key here is + already known as a validator by that beacon node. This helps prevent + the same validator being created twice and therefore slashable + conditions. + --builder-boost-factor + Defines the boost factor, a percentage multiplier to apply to the + builder's payload value when choosing between a builder payload header + and payload from the local execution node. + --builder-proposals + When provided, all created validators will attempt to create blocks + via builder rather than the local EL. [possible values: true, false] + --count + The number of validators to create, regardless of how many already + exist + -d, --datadir + Used to specify a custom root data directory for lighthouse keys and + databases. Defaults to $HOME/.lighthouse/{network} where network is + the value of the `network` flag Note: Users should specify separate + custom datadirs for different networks. + --debug-level + Specifies the verbosity level used when emitting logs to the terminal. + [default: info] [possible values: info, debug, trace, warn, error, + crit] + --deposit-gwei + The GWEI value of the deposit amount. Defaults to the minimum amount + required for an active validator (MAX_EFFECTIVE_BALANCE) + --eth1-withdrawal-address + If this field is set, the given eth1 address will be used to create + the withdrawal credentials. Otherwise, it will generate withdrawal + credentials with the mnemonic-derived withdrawal public key in + EIP-2334 format. + --first-index + The first of consecutive key indexes you wish to create. [default: 0] + --gas-limit + All created validators will use this gas limit. It is recommended to + leave this as the default value by not specifying this flag. + --genesis-state-url + A URL of a beacon-API compatible server from which to download the + genesis state. Checkpoint sync server URLs can generally be used with + this flag. If not supplied, a default URL or the --checkpoint-sync-url + may be used. If the genesis state is already included in this binary + then this value will be ignored. + --genesis-state-url-timeout + The timeout in seconds for the request to --genesis-state-url. + [default: 180] + --log-format + Specifies the log format used when emitting logs to the terminal. + [possible values: JSON] + --logfile + File path where the log file will be stored. Once it grows to the + value specified in `--logfile-max-size` a new log file is generated + where future logs are stored. Once the number of log files exceeds the + value specified in `--logfile-max-number` the oldest log file will be + overwritten. + --logfile-debug-level + The verbosity level used when emitting logs to the log file. [default: + debug] [possible values: info, debug, trace, warn, error, crit] + --logfile-format + Specifies the log format used when emitting logs to the logfile. + [possible values: DEFAULT, JSON] + --logfile-max-number + The maximum number of log files that will be stored. If set to 0, + background file logging is disabled. [default: 5] + --logfile-max-size + The maximum size (in MB) each log file can grow to before rotating. If + set to 0, background file logging is disabled. [default: 200] + --mnemonic-path + If present, the mnemonic will be read in from this file. + --network + Name of the Eth2 chain Lighthouse will sync and follow. [possible + values: mainnet, gnosis, chiado, sepolia, holesky] + --output-path + The path to a directory where the validator and (optionally) deposits + files will be created. The directory will be created if it does not + exist. + --prefer-builder-proposals + If this flag is set, Lighthouse will always prefer blocks constructed + by builders, regardless of payload value. [possible values: true, + false] + --safe-slots-to-import-optimistically + Used to coordinate manual overrides of the + SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY parameter. This flag should only + be used if the user has a clear understanding that the broad Ethereum + community has elected to override this parameter in the event of an + attack at the PoS transition block. Incorrect use of this flag can + cause your node to possibly accept an invalid chain or sync more + slowly. Be extremely careful with this flag. + --suggested-fee-recipient + All created validators will use this value for the suggested fee + recipient. Omit this flag to use the default value from the VC. + -t, --testnet-dir + Path to directory containing eth2_testnet specs. Defaults to a + hard-coded Lighthouse testnet. Only effective if there is no existing + database. + --terminal-block-hash-epoch-override + Used to coordinate manual overrides to the + TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH 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 PoW block. Incorrect + use of this flag will cause your node to experience a consensus + failure. Be extremely careful with this flag. + --terminal-block-hash-override + Used to coordinate manual overrides to the TERMINAL_BLOCK_HASH + 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 PoW block. Incorrect use of this flag will cause + your node to experience a consensus failure. Be extremely careful with + this flag. + --terminal-total-difficulty-override + Used to coordinate manual overrides to the TERMINAL_TOTAL_DIFFICULTY + parameter. Accepts a 256-bit decimal integer (not a hex value). 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. Incorrect use of this flag will cause your node to + experience a consensus failure. Be extremely careful with this flag. -OPTIONS: - --beacon-node - A HTTP(S) address of a beacon node using the beacon-API. If this value is provided, an error will be raised - if any validator key here is already known as a validator by that beacon node. This helps prevent the same - validator being created twice and therefore slashable conditions. - --builder-boost-factor - Defines the boost factor, a percentage multiplier to apply to the builder's payload value when choosing - between a builder payload header and payload from the local execution node. - --builder-proposals - When provided, all created validators will attempt to create blocks via builder rather than the local EL. - [possible values: true, false] - --count - The number of validators to create, regardless of how many already exist - - -d, --datadir - Used to specify a custom root data directory for lighthouse keys and databases. Defaults to - $HOME/.lighthouse/{network} where network is the value of the `network` flag Note: Users should specify - separate custom datadirs for different networks. - --debug-level - Specifies the verbosity level used when emitting logs to the terminal. [default: info] [possible values: - info, debug, trace, warn, error, crit] - --deposit-gwei - The GWEI value of the deposit amount. Defaults to the minimum amount required for an active validator - (MAX_EFFECTIVE_BALANCE) - --eth1-withdrawal-address - If this field is set, the given eth1 address will be used to create the withdrawal credentials. Otherwise, - it will generate withdrawal credentials with the mnemonic-derived withdrawal public key in EIP-2334 format. - --first-index - The first of consecutive key indexes you wish to create. [default: 0] - - --gas-limit - All created validators will use this gas limit. It is recommended to leave this as the default value by not - specifying this flag. - --genesis-state-url - A URL of a beacon-API compatible server from which to download the genesis state. Checkpoint sync server - URLs can generally be used with this flag. If not supplied, a default URL or the --checkpoint-sync-url may - be used. If the genesis state is already included in this binary then this value will be ignored. - --genesis-state-url-timeout - The timeout in seconds for the request to --genesis-state-url. [default: 180] - - --log-format - Specifies the log format used when emitting logs to the terminal. [possible values: JSON] - - --logfile - File path where the log file will be stored. Once it grows to the value specified in `--logfile-max-size` a - new log file is generated where future logs are stored. Once the number of log files exceeds the value - specified in `--logfile-max-number` the oldest log file will be overwritten. - --logfile-debug-level - The verbosity level used when emitting logs to the log file. [default: debug] [possible values: info, - debug, trace, warn, error, crit] - --logfile-format - Specifies the log format used when emitting logs to the logfile. [possible values: DEFAULT, JSON] - - --logfile-max-number - The maximum number of log files that will be stored. If set to 0, background file logging is disabled. - [default: 5] - --logfile-max-size - The maximum size (in MB) each log file can grow to before rotating. If set to 0, background file logging is - disabled. [default: 200] - --mnemonic-path - If present, the mnemonic will be read in from this file. - - --network - Name of the Eth2 chain Lighthouse will sync and follow. [possible values: mainnet, gnosis, chiado, sepolia, - holesky] - --output-path - The path to a directory where the validator and (optionally) deposits files will be created. The directory - will be created if it does not exist. - --prefer-builder-proposals - If this flag is set, Lighthouse will always prefer blocks constructed by builders, regardless of payload - value. [possible values: true, false] - --safe-slots-to-import-optimistically - Used to coordinate manual overrides of the SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY parameter. This flag should - only be used if the user has a clear understanding that the broad Ethereum community has elected to override - this parameter in the event of an attack at the PoS transition block. Incorrect use of this flag can cause - your node to possibly accept an invalid chain or sync more slowly. Be extremely careful with this flag. - --suggested-fee-recipient - All created validators will use this value for the suggested fee recipient. Omit this flag to use the - default value from the VC. - --terminal-block-hash-epoch-override - Used to coordinate manual overrides to the TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH 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 PoW block. Incorrect use of this flag will cause your node to experience a consensus failure. - Be extremely careful with this flag. - --terminal-block-hash-override - Used to coordinate manual overrides to the TERMINAL_BLOCK_HASH 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 - PoW block. Incorrect use of this flag will cause your node to experience a consensus failure. Be extremely - careful with this flag. - --terminal-total-difficulty-override - Used to coordinate manual overrides to the TERMINAL_TOTAL_DIFFICULTY parameter. Accepts a 256-bit decimal - integer (not a hex value). 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. Incorrect use of this flag will - cause your node to experience a consensus failure. Be extremely careful with this flag. - -t, --testnet-dir - Path to directory containing eth2_testnet specs. Defaults to a hard-coded Lighthouse testnet. Only effective - if there is no existing database. +Flags: + --disable-deposits + When provided don't generate the deposits JSON file that is commonly + used for submitting validator deposits via a web UI. Using this flag + will save several seconds per validator if the user has an alternate + strategy for submitting deposits. + --disable-log-timestamp + If present, do not include timestamps in logging output. + --disable-malloc-tuning + If present, do not configure the system allocator. Providing this flag + will generally increase memory usage, it should only be provided when + debugging specific memory allocation issues. + --force-bls-withdrawal-credentials + If present, allows BLS withdrawal credentials rather than an execution + address. This is not recommended. + -h, --help + Prints help information + --log-color + Force outputting colors when emitting logs to the terminal. + --logfile-compress + If present, compress old log files. This can help reduce the space + needed to store old logs. + --logfile-no-restricted-perms + If present, log files will be generated as world-readable meaning they + can be read by any user on the machine. Note that logs can often + contain sensitive information about your validator and so this flag + should be used with caution. For Windows users, the log file + permissions will be inherited from the parent folder. + --specify-voting-keystore-password + If present, the user will be prompted to enter the voting keystore + password that will be used to encrypt the voting keystores. If this + flag is not provided, a random password will be used. It is not + necessary to keep backups of voting keystore passwords if the mnemonic + is safely backed up. + --stdin-inputs + If present, read all user inputs from stdin instead of tty. ``` diff --git a/book/src/help_vm_import.md b/book/src/help_vm_import.md index bee94a0835d..799a1db82b5 100644 --- a/book/src/help_vm_import.md +++ b/book/src/help_vm_import.md @@ -1,103 +1,126 @@ # Validator Manager Import ``` -Uploads validators to a validator client using the HTTP API. The validators are defined in a JSON file which can be -generated using the "create-validators" command. +Uploads validators to a validator client using the HTTP API. The validators are +defined in a JSON file which can be generated using the "create-validators" +command. -USAGE: - lighthouse validator_manager import [FLAGS] [OPTIONS] --validators-file +Usage: lighthouse validator_manager import [OPTIONS] --validators-file -FLAGS: - --disable-log-timestamp If present, do not include timestamps in logging output. - --disable-malloc-tuning If present, do not configure the system allocator. Providing this flag will - generally increase memory usage, it should only be provided when debugging - specific memory allocation issues. - -h, --help Prints help information - --ignore-duplicates If present, ignore any validators which already exist on the VC. Without this - flag, the process will terminate without making any changes. This flag should - be used with caution, whilst it does not directly cause slashable conditions, - it might be an indicator that something is amiss. Users should also be careful - to avoid submitting duplicate deposits for validators that already exist on the - VC. - --log-color Force outputting colors when emitting logs to the terminal. - --logfile-compress If present, compress old log files. This can help reduce the space needed to - store old logs. - --logfile-no-restricted-perms If present, log files will be generated as world-readable meaning they can be - read by any user on the machine. Note that logs can often contain sensitive - information about your validator and so this flag should be used with caution. - For Windows users, the log file permissions will be inherited from the parent - folder. - -V, --version Prints version information +Options: + -d, --datadir + Used to specify a custom root data directory for lighthouse keys and + databases. Defaults to $HOME/.lighthouse/{network} where network is + the value of the `network` flag Note: Users should specify separate + custom datadirs for different networks. + --debug-level + Specifies the verbosity level used when emitting logs to the terminal. + [default: info] [possible values: info, debug, trace, warn, error, + crit] + --genesis-state-url + A URL of a beacon-API compatible server from which to download the + genesis state. Checkpoint sync server URLs can generally be used with + this flag. If not supplied, a default URL or the --checkpoint-sync-url + may be used. If the genesis state is already included in this binary + then this value will be ignored. + --genesis-state-url-timeout + The timeout in seconds for the request to --genesis-state-url. + [default: 180] + --log-format + Specifies the log format used when emitting logs to the terminal. + [possible values: JSON] + --logfile + File path where the log file will be stored. Once it grows to the + value specified in `--logfile-max-size` a new log file is generated + where future logs are stored. Once the number of log files exceeds the + value specified in `--logfile-max-number` the oldest log file will be + overwritten. + --logfile-debug-level + The verbosity level used when emitting logs to the log file. [default: + debug] [possible values: info, debug, trace, warn, error, crit] + --logfile-format + Specifies the log format used when emitting logs to the logfile. + [possible values: DEFAULT, JSON] + --logfile-max-number + The maximum number of log files that will be stored. If set to 0, + background file logging is disabled. [default: 5] + --logfile-max-size + The maximum size (in MB) each log file can grow to before rotating. If + set to 0, background file logging is disabled. [default: 200] + --network + Name of the Eth2 chain Lighthouse will sync and follow. [possible + values: mainnet, gnosis, chiado, sepolia, holesky] + --safe-slots-to-import-optimistically + Used to coordinate manual overrides of the + SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY parameter. This flag should only + be used if the user has a clear understanding that the broad Ethereum + community has elected to override this parameter in the event of an + attack at the PoS transition block. Incorrect use of this flag can + cause your node to possibly accept an invalid chain or sync more + slowly. Be extremely careful with this flag. + -t, --testnet-dir + Path to directory containing eth2_testnet specs. Defaults to a + hard-coded Lighthouse testnet. Only effective if there is no existing + database. + --terminal-block-hash-epoch-override + Used to coordinate manual overrides to the + TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH 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 PoW block. Incorrect + use of this flag will cause your node to experience a consensus + failure. Be extremely careful with this flag. + --terminal-block-hash-override + Used to coordinate manual overrides to the TERMINAL_BLOCK_HASH + 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 PoW block. Incorrect use of this flag will cause + your node to experience a consensus failure. Be extremely careful with + this flag. + --terminal-total-difficulty-override + Used to coordinate manual overrides to the TERMINAL_TOTAL_DIFFICULTY + parameter. Accepts a 256-bit decimal integer (not a hex value). 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. Incorrect use of this flag will cause your node to + experience a consensus failure. Be extremely careful with this flag. + --validators-file + The path to a JSON file containing a list of validators to be imported + to the validator client. This file is usually named "validators.json". + --vc-token + The file containing a token required by the validator client. + --vc-url + A HTTP(S) address of a validator client using the keymanager-API. If + this value is not supplied then a 'dry run' will be conducted where no + changes are made to the validator client. [default: + http://localhost:5062] -OPTIONS: - -d, --datadir - Used to specify a custom root data directory for lighthouse keys and databases. Defaults to - $HOME/.lighthouse/{network} where network is the value of the `network` flag Note: Users should specify - separate custom datadirs for different networks. - --debug-level - Specifies the verbosity level used when emitting logs to the terminal. [default: info] [possible values: - info, debug, trace, warn, error, crit] - --genesis-state-url - A URL of a beacon-API compatible server from which to download the genesis state. Checkpoint sync server - URLs can generally be used with this flag. If not supplied, a default URL or the --checkpoint-sync-url may - be used. If the genesis state is already included in this binary then this value will be ignored. - --genesis-state-url-timeout - The timeout in seconds for the request to --genesis-state-url. [default: 180] - - --log-format - Specifies the log format used when emitting logs to the terminal. [possible values: JSON] - - --logfile - File path where the log file will be stored. Once it grows to the value specified in `--logfile-max-size` a - new log file is generated where future logs are stored. Once the number of log files exceeds the value - specified in `--logfile-max-number` the oldest log file will be overwritten. - --logfile-debug-level - The verbosity level used when emitting logs to the log file. [default: debug] [possible values: info, - debug, trace, warn, error, crit] - --logfile-format - Specifies the log format used when emitting logs to the logfile. [possible values: DEFAULT, JSON] - - --logfile-max-number - The maximum number of log files that will be stored. If set to 0, background file logging is disabled. - [default: 5] - --logfile-max-size - The maximum size (in MB) each log file can grow to before rotating. If set to 0, background file logging is - disabled. [default: 200] - --network - Name of the Eth2 chain Lighthouse will sync and follow. [possible values: mainnet, gnosis, chiado, sepolia, - holesky] - --safe-slots-to-import-optimistically - Used to coordinate manual overrides of the SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY parameter. This flag should - only be used if the user has a clear understanding that the broad Ethereum community has elected to override - this parameter in the event of an attack at the PoS transition block. Incorrect use of this flag can cause - your node to possibly accept an invalid chain or sync more slowly. Be extremely careful with this flag. - --terminal-block-hash-epoch-override - Used to coordinate manual overrides to the TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH 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 PoW block. Incorrect use of this flag will cause your node to experience a consensus failure. - Be extremely careful with this flag. - --terminal-block-hash-override - Used to coordinate manual overrides to the TERMINAL_BLOCK_HASH 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 - PoW block. Incorrect use of this flag will cause your node to experience a consensus failure. Be extremely - careful with this flag. - --terminal-total-difficulty-override - Used to coordinate manual overrides to the TERMINAL_TOTAL_DIFFICULTY parameter. Accepts a 256-bit decimal - integer (not a hex value). 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. Incorrect use of this flag will - cause your node to experience a consensus failure. Be extremely careful with this flag. - -t, --testnet-dir - Path to directory containing eth2_testnet specs. Defaults to a hard-coded Lighthouse testnet. Only effective - if there is no existing database. - --validators-file - The path to a JSON file containing a list of validators to be imported to the validator client. This file is - usually named "validators.json". - --vc-token - The file containing a token required by the validator client. - - --vc-url - A HTTP(S) address of a validator client using the keymanager-API. If this value is not supplied then a 'dry - run' will be conducted where no changes are made to the validator client. [default: http://localhost:5062] +Flags: + --disable-log-timestamp + If present, do not include timestamps in logging output. + --disable-malloc-tuning + If present, do not configure the system allocator. Providing this flag + will generally increase memory usage, it should only be provided when + debugging specific memory allocation issues. + -h, --help + Prints help information + --ignore-duplicates + If present, ignore any validators which already exist on the VC. + Without this flag, the process will terminate without making any + changes. This flag should be used with caution, whilst it does not + directly cause slashable conditions, it might be an indicator that + something is amiss. Users should also be careful to avoid submitting + duplicate deposits for validators that already exist on the VC. + --log-color + Force outputting colors when emitting logs to the terminal. + --logfile-compress + If present, compress old log files. This can help reduce the space + needed to store old logs. + --logfile-no-restricted-perms + If present, log files will be generated as world-readable meaning they + can be read by any user on the machine. Note that logs can often + contain sensitive information about your validator and so this flag + should be used with caution. For Windows users, the log file + permissions will be inherited from the parent folder. ``` diff --git a/book/src/help_vm_move.md b/book/src/help_vm_move.md index d23f2c2de91..9b92e21bc26 100644 --- a/book/src/help_vm_move.md +++ b/book/src/help_vm_move.md @@ -1,120 +1,147 @@ # Validator Manager Move ``` -Uploads validators to a validator client using the HTTP API. The validators are defined in a JSON file which can be -generated using the "create-validators" command. This command only supports validators signing via a keystore on the +Uploads validators to a validator client using the HTTP API. The validators are +defined in a JSON file which can be generated using the "create-validators" +command. This command only supports validators signing via a keystore on the local file system (i.e., not Web3Signer validators). -USAGE: - lighthouse validator_manager move [FLAGS] [OPTIONS] --dest-vc-token --dest-vc-url --src-vc-token --src-vc-url +Usage: lighthouse validator_manager move [OPTIONS] --src-vc-token --src-vc-url --dest-vc-token --dest-vc-url -FLAGS: - --disable-log-timestamp If present, do not include timestamps in logging output. - --disable-malloc-tuning If present, do not configure the system allocator. Providing this flag will - generally increase memory usage, it should only be provided when debugging - specific memory allocation issues. - -h, --help Prints help information - --log-color Force outputting colors when emitting logs to the terminal. - --logfile-compress If present, compress old log files. This can help reduce the space needed to - store old logs. - --logfile-no-restricted-perms If present, log files will be generated as world-readable meaning they can be - read by any user on the machine. Note that logs can often contain sensitive - information about your validator and so this flag should be used with caution. - For Windows users, the log file permissions will be inherited from the parent - folder. - --stdin-inputs If present, read all user inputs from stdin instead of tty. - -V, --version Prints version information +Options: + --builder-boost-factor + Defines the boost factor, a percentage multiplier to apply to the + builder's payload value when choosing between a builder payload header + and payload from the local execution node. + --builder-proposals + When provided, all created validators will attempt to create blocks + via builder rather than the local EL. [possible values: true, false] + --count + The number of validators to move. + -d, --datadir + Used to specify a custom root data directory for lighthouse keys and + databases. Defaults to $HOME/.lighthouse/{network} where network is + the value of the `network` flag Note: Users should specify separate + custom datadirs for different networks. + --debug-level + Specifies the verbosity level used when emitting logs to the terminal. + [default: info] [possible values: info, debug, trace, warn, error, + crit] + --dest-vc-token + The file containing a token required by the destination validator + client. + --dest-vc-url + A HTTP(S) address of a validator client using the keymanager-API. This + validator client is the "destination" and will have new validators + added as they are removed from the "source" validator client. + --gas-limit + All created validators will use this gas limit. It is recommended to + leave this as the default value by not specifying this flag. + --genesis-state-url + A URL of a beacon-API compatible server from which to download the + genesis state. Checkpoint sync server URLs can generally be used with + this flag. If not supplied, a default URL or the --checkpoint-sync-url + may be used. If the genesis state is already included in this binary + then this value will be ignored. + --genesis-state-url-timeout + The timeout in seconds for the request to --genesis-state-url. + [default: 180] + --log-format + Specifies the log format used when emitting logs to the terminal. + [possible values: JSON] + --logfile + File path where the log file will be stored. Once it grows to the + value specified in `--logfile-max-size` a new log file is generated + where future logs are stored. Once the number of log files exceeds the + value specified in `--logfile-max-number` the oldest log file will be + overwritten. + --logfile-debug-level + The verbosity level used when emitting logs to the log file. [default: + debug] [possible values: info, debug, trace, warn, error, crit] + --logfile-format + Specifies the log format used when emitting logs to the logfile. + [possible values: DEFAULT, JSON] + --logfile-max-number + The maximum number of log files that will be stored. If set to 0, + background file logging is disabled. [default: 5] + --logfile-max-size + The maximum size (in MB) each log file can grow to before rotating. If + set to 0, background file logging is disabled. [default: 200] + --network + Name of the Eth2 chain Lighthouse will sync and follow. [possible + values: mainnet, gnosis, chiado, sepolia, holesky] + --prefer-builder-proposals + If this flag is set, Lighthouse will always prefer blocks constructed + by builders, regardless of payload value. [possible values: true, + false] + --safe-slots-to-import-optimistically + Used to coordinate manual overrides of the + SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY parameter. This flag should only + be used if the user has a clear understanding that the broad Ethereum + community has elected to override this parameter in the event of an + attack at the PoS transition block. Incorrect use of this flag can + cause your node to possibly accept an invalid chain or sync more + slowly. Be extremely careful with this flag. + --src-vc-token + The file containing a token required by the source validator client. + --src-vc-url + A HTTP(S) address of a validator client using the keymanager-API. This + validator client is the "source" and contains the validators that are + to be moved. + --stdin-inputs + If present, read all user inputs from stdin instead of tty. + --suggested-fee-recipient + All created validators will use this value for the suggested fee + recipient. Omit this flag to use the default value from the VC. + -t, --testnet-dir + Path to directory containing eth2_testnet specs. Defaults to a + hard-coded Lighthouse testnet. Only effective if there is no existing + database. + --terminal-block-hash-epoch-override + Used to coordinate manual overrides to the + TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH 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 PoW block. Incorrect + use of this flag will cause your node to experience a consensus + failure. Be extremely careful with this flag. + --terminal-block-hash-override + Used to coordinate manual overrides to the TERMINAL_BLOCK_HASH + 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 PoW block. Incorrect use of this flag will cause + your node to experience a consensus failure. Be extremely careful with + this flag. + --terminal-total-difficulty-override + Used to coordinate manual overrides to the TERMINAL_TOTAL_DIFFICULTY + parameter. Accepts a 256-bit decimal integer (not a hex value). 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. Incorrect use of this flag will cause your node to + experience a consensus failure. Be extremely careful with this flag. + --validators + The validators to be moved. Either a list of 0x-prefixed validator + pubkeys or the keyword "all". -OPTIONS: - --builder-boost-factor - Defines the boost factor, a percentage multiplier to apply to the builder's payload value when choosing - between a builder payload header and payload from the local execution node. - --builder-proposals - When provided, all created validators will attempt to create blocks via builder rather than the local EL. - [possible values: true, false] - --count The number of validators to move. - -d, --datadir - Used to specify a custom root data directory for lighthouse keys and databases. Defaults to - $HOME/.lighthouse/{network} where network is the value of the `network` flag Note: Users should specify - separate custom datadirs for different networks. - --debug-level - Specifies the verbosity level used when emitting logs to the terminal. [default: info] [possible values: - info, debug, trace, warn, error, crit] - --dest-vc-token - The file containing a token required by the destination validator client. - - --dest-vc-url - A HTTP(S) address of a validator client using the keymanager-API. This validator client is the "destination" - and will have new validators added as they are removed from the "source" validator client. - --gas-limit - All created validators will use this gas limit. It is recommended to leave this as the default value by not - specifying this flag. - --genesis-state-url - A URL of a beacon-API compatible server from which to download the genesis state. Checkpoint sync server - URLs can generally be used with this flag. If not supplied, a default URL or the --checkpoint-sync-url may - be used. If the genesis state is already included in this binary then this value will be ignored. - --genesis-state-url-timeout - The timeout in seconds for the request to --genesis-state-url. [default: 180] - - --log-format - Specifies the log format used when emitting logs to the terminal. [possible values: JSON] - - --logfile - File path where the log file will be stored. Once it grows to the value specified in `--logfile-max-size` a - new log file is generated where future logs are stored. Once the number of log files exceeds the value - specified in `--logfile-max-number` the oldest log file will be overwritten. - --logfile-debug-level - The verbosity level used when emitting logs to the log file. [default: debug] [possible values: info, - debug, trace, warn, error, crit] - --logfile-format - Specifies the log format used when emitting logs to the logfile. [possible values: DEFAULT, JSON] - - --logfile-max-number - The maximum number of log files that will be stored. If set to 0, background file logging is disabled. - [default: 5] - --logfile-max-size - The maximum size (in MB) each log file can grow to before rotating. If set to 0, background file logging is - disabled. [default: 200] - --network - Name of the Eth2 chain Lighthouse will sync and follow. [possible values: mainnet, gnosis, chiado, sepolia, - holesky] - --prefer-builder-proposals - If this flag is set, Lighthouse will always prefer blocks constructed by builders, regardless of payload - value. [possible values: true, false] - --safe-slots-to-import-optimistically - Used to coordinate manual overrides of the SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY parameter. This flag should - only be used if the user has a clear understanding that the broad Ethereum community has elected to override - this parameter in the event of an attack at the PoS transition block. Incorrect use of this flag can cause - your node to possibly accept an invalid chain or sync more slowly. Be extremely careful with this flag. - --src-vc-token - The file containing a token required by the source validator client. - - --src-vc-url - A HTTP(S) address of a validator client using the keymanager-API. This validator client is the "source" and - contains the validators that are to be moved. - --suggested-fee-recipient - All created validators will use this value for the suggested fee recipient. Omit this flag to use the - default value from the VC. - --terminal-block-hash-epoch-override - Used to coordinate manual overrides to the TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH 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 PoW block. Incorrect use of this flag will cause your node to experience a consensus failure. - Be extremely careful with this flag. - --terminal-block-hash-override - Used to coordinate manual overrides to the TERMINAL_BLOCK_HASH 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 - PoW block. Incorrect use of this flag will cause your node to experience a consensus failure. Be extremely - careful with this flag. - --terminal-total-difficulty-override - Used to coordinate manual overrides to the TERMINAL_TOTAL_DIFFICULTY parameter. Accepts a 256-bit decimal - integer (not a hex value). 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. Incorrect use of this flag will - cause your node to experience a consensus failure. Be extremely careful with this flag. - -t, --testnet-dir - Path to directory containing eth2_testnet specs. Defaults to a hard-coded Lighthouse testnet. Only effective - if there is no existing database. - --validators - The validators to be moved. Either a list of 0x-prefixed validator pubkeys or the keyword "all". +Flags: + --disable-log-timestamp + If present, do not include timestamps in logging output. + --disable-malloc-tuning + If present, do not configure the system allocator. Providing this flag + will generally increase memory usage, it should only be provided when + debugging specific memory allocation issues. + -h, --help + Prints help information + --log-color + Force outputting colors when emitting logs to the terminal. + --logfile-compress + If present, compress old log files. This can help reduce the space + needed to store old logs. + --logfile-no-restricted-perms + If present, log files will be generated as world-readable meaning they + can be read by any user on the machine. Note that logs can often + contain sensitive information about your validator and so this flag + should be used with caution. For Windows users, the log file + permissions will be inherited from the parent folder. ``` diff --git a/boot_node/src/cli.rs b/boot_node/src/cli.rs index d7ea5ab0b35..440a9d27e2d 100644 --- a/boot_node/src/cli.rs +++ b/boot_node/src/cli.rs @@ -1,18 +1,29 @@ //! Simple logic for spawning a Lighthouse BootNode. -use clap::{App, Arg}; +use clap::{Arg, ArgAction, Command}; +use clap_utils::{get_color_style, FLAG_HEADER}; // TODO: Add DOS prevention CLI params -pub fn cli_app<'a, 'b>() -> App<'a, 'b> { - App::new("boot_node") +pub fn cli_app() -> Command { + Command::new("boot_node") .about("Start a special Lighthouse process that only serves as a discv5 boot-node. This \ process will *not* import blocks or perform most typical beacon node functions. Instead, it \ will simply run the discv5 service and assist nodes on the network to discover each other. \ This is the recommended way to provide a network boot-node since it has a reduced attack \ surface compared to a full beacon node.") - .settings(&[clap::AppSettings::ColoredHelp]) + .styles(get_color_style()) + .display_order(0) .arg( - Arg::with_name("enr-address") + Arg::new("help") + .long("help") + .short('h') + .help("Prints help information") + .action(ArgAction::HelpLong) + .display_order(0) + .help_heading(FLAG_HEADER) + ) + .arg( + Arg::new("enr-address") .long("enr-address") .value_name("ADDRESS") .help("The IP address/ DNS address to broadcast to other peers on how to reach \ @@ -21,31 +32,33 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { discovery. Set this only if you are sure other nodes can connect to your \ local node on this address. This will update the `ip4` or `ip6` ENR fields \ accordingly. To update both, set this flag twice with the different values.") - .multiple(true) - .max_values(2) + .action(ArgAction::Append) + .num_args(1..=2) .required(true) .conflicts_with("network-dir") - .takes_value(true), + .display_order(0) ) .arg( - Arg::with_name("port") + Arg::new("port") .long("port") .value_name("PORT") .help("The UDP port to listen on.") .default_value("9000") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("port6") + Arg::new("port6") .long("port6") .value_name("PORT") .help("The UDP port to listen on over IpV6 when listening over both Ipv4 and \ Ipv6. Defaults to 9090 when required.") .default_value("9090") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("listen-address") + Arg::new("listen-address") .long("listen-address") .value_name("ADDRESS") .help("The address the bootnode will listen for UDP communications. To listen \ @@ -56,53 +69,63 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { - --listen-address '0.0.0.0' --listen-address '::' will listen over both \ Ipv4 and Ipv6. The order of the given addresses is not relevant. However, \ multiple Ipv4, or multiple Ipv6 addresses will not be accepted.") - .multiple(true) - .max_values(2) + .num_args(1..=2) .default_value("0.0.0.0") - .takes_value(true) + .action(ArgAction::Append) + .display_order(0) ) .arg( - Arg::with_name("boot-nodes") + Arg::new("boot-nodes") .long("boot-nodes") .allow_hyphen_values(true) .value_name("ENR-LIST/Multiaddr") .help("One or more comma-delimited base64-encoded ENR's or multiaddr strings of peers to initially add to the local routing table") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("enr-udp-port") + Arg::new("enr-udp-port") .long("enr-port") .value_name("PORT") .help("The UDP port of the boot node's ENR. This is the port that external peers will dial to reach this boot node. Set this only if the external port differs from the listening port.") - .takes_value(true) + .action(ArgAction::Set) .conflicts_with("network-dir") + .display_order(0) ) .arg( - Arg::with_name("enr-udp6-port") + Arg::new("enr-udp6-port") .long("enr-udp6-port") .value_name("PORT") .help("The UDP6 port of the local ENR. Set this only if you are sure other nodes \ can connect to your local node on this port over IpV6.") .conflicts_with("network-dir") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("enable-enr-auto-update") - .short("x") + Arg::new("enable-enr-auto-update") + .short('x') + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .long("enable-enr-auto-update") .help("Discovery can automatically update the node's local ENR with an external IP address and port as seen by other peers on the network. \ This enables this feature.") + .display_order(0) ) .arg( - Arg::with_name("disable-packet-filter") + Arg::new("disable-packet-filter") + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .long("disable-packet-filter") .help("Disables discv5 packet filter. Useful for testing in smaller networks") + .display_order(0) ) .arg( - Arg::with_name("network-dir") + Arg::new("network-dir") .value_name("NETWORK_DIR") .long("network-dir") .help("The directory which contains the enr and it's associated private key") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) } diff --git a/boot_node/src/config.rs b/boot_node/src/config.rs index a9c89505322..a8b0f7aa563 100644 --- a/boot_node/src/config.rs +++ b/boot_node/src/config.rs @@ -25,11 +25,10 @@ pub struct BootNodeConfig { impl BootNodeConfig { pub async fn new( - matches: &ArgMatches<'_>, + matches: &ArgMatches, eth2_network_config: &Eth2NetworkConfig, ) -> Result { let data_dir = get_data_dir(matches); - // Try and obtain bootnodes let boot_nodes = { @@ -39,7 +38,7 @@ impl BootNodeConfig { boot_nodes.extend_from_slice(enr); } - if let Some(nodes) = matches.value_of("boot-nodes") { + if let Some(nodes) = matches.get_one::("boot-nodes") { boot_nodes.extend_from_slice( &nodes .split(',') @@ -81,14 +80,14 @@ impl BootNodeConfig { }; // By default this is enabled. If it is not set, revert to false. - if !matches.is_present("enable-enr-auto-update") { + if !matches.get_flag("enable-enr-auto-update") { network_config.discv5_config.enr_update = false; } let private_key = load_private_key(&network_config, &logger); let local_key = CombinedKey::from_libp2p(private_key)?; - let local_enr = if let Some(dir) = matches.value_of("network-dir") { + let local_enr = if let Some(dir) = matches.get_one::("network-dir") { let network_dir: PathBuf = dir.into(); load_enr_from_disk(&network_dir)? } else { diff --git a/boot_node/src/lib.rs b/boot_node/src/lib.rs index e707dc14f76..669b126bd37 100644 --- a/boot_node/src/lib.rs +++ b/boot_node/src/lib.rs @@ -14,8 +14,8 @@ const LOG_CHANNEL_SIZE: usize = 2048; /// Run the bootnode given the CLI configuration. pub fn run( - lh_matches: &ArgMatches<'_>, - bn_matches: &ArgMatches<'_>, + lh_matches: &ArgMatches, + bn_matches: &ArgMatches, eth_spec_id: EthSpecId, eth2_network_config: &Eth2NetworkConfig, debug_level: String, @@ -67,8 +67,8 @@ pub fn run( } fn main( - lh_matches: &ArgMatches<'_>, - bn_matches: &ArgMatches<'_>, + lh_matches: &ArgMatches, + bn_matches: &ArgMatches, eth2_network_config: &Eth2NetworkConfig, log: slog::Logger, ) -> Result<(), String> { diff --git a/boot_node/src/server.rs b/boot_node/src/server.rs index b6bdd148f4b..286fa9e0f0f 100644 --- a/boot_node/src/server.rs +++ b/boot_node/src/server.rs @@ -12,8 +12,8 @@ use slog::info; use types::EthSpec; pub async fn run( - lh_matches: &ArgMatches<'_>, - bn_matches: &ArgMatches<'_>, + lh_matches: &ArgMatches, + bn_matches: &ArgMatches, eth2_network_config: &Eth2NetworkConfig, log: slog::Logger, ) -> Result<(), String> { @@ -28,7 +28,7 @@ pub async fn run( ð2_network_config.chain_spec::()?, )?; - if lh_matches.is_present("immediate-shutdown") { + if lh_matches.get_flag("immediate-shutdown") { return Ok(()); } diff --git a/common/clap_utils/src/lib.rs b/common/clap_utils/src/lib.rs index 1ebd2b1740f..ea56e7e672a 100644 --- a/common/clap_utils/src/lib.rs +++ b/common/clap_utils/src/lib.rs @@ -1,5 +1,6 @@ //! A helper library for parsing values from `clap::ArgMatches`. +use clap::builder::styling::*; use clap::ArgMatches; use eth2_network_config::{Eth2NetworkConfig, DEFAULT_HARDCODED_NETWORK}; use ethereum_types::U256 as Uint256; @@ -15,12 +16,14 @@ pub const BAD_TESTNET_DIR_MESSAGE: &str = "The hard-coded testnet directory was or when there is no default public network to connect to. \ During these times you must specify a --testnet-dir."; +pub const FLAG_HEADER: &str = "Flags"; + /// Try to parse the eth2 network config from the `network`, `testnet-dir` flags in that order. /// Returns the default hardcoded testnet if neither flags are set. pub fn get_eth2_network_config(cli_args: &ArgMatches) -> Result { - let optional_network_config = if cli_args.is_present("network") { + let optional_network_config = if cli_args.contains_id("network") { parse_hardcoded_network(cli_args, "network")? - } else if cli_args.is_present("testnet-dir") { + } else if cli_args.contains_id("testnet-dir") { parse_testnet_dir(cli_args, "testnet-dir")? } else { // if neither is present, assume the default network @@ -92,7 +95,7 @@ pub fn parse_path_with_default_in_home_dir( default: PathBuf, ) -> Result { matches - .value_of(name) + .get_one::(name) .map(|dir| { dir.parse::() .map_err(|e| format!("Unable to parse {}: {}", name, e)) @@ -122,7 +125,8 @@ where ::Err: std::fmt::Display, { matches - .value_of(name) + .try_get_one::(name) + .map_err(|e| format!("Unable to parse {}: {}", name, e))? .map(|val| { val.parse() .map_err(|e| format!("Unable to parse {}: {}", name, e)) @@ -150,7 +154,7 @@ pub fn parse_ssz_optional( name: &'static str, ) -> Result, String> { matches - .value_of(name) + .get_one::(name) .map(|val| { if let Some(stripped) = val.strip_prefix("0x") { let vec = hex::decode(stripped) @@ -190,3 +194,15 @@ where } Ok(()) } + +pub fn get_color_style() -> Styles { + Styles::styled() + .header(AnsiColor::Yellow.on_default()) + .usage(AnsiColor::Green.on_default()) + .literal(AnsiColor::Green.on_default()) + .placeholder(AnsiColor::Green.on_default()) +} + +pub fn parse_flag(matches: &ArgMatches, name: &str) -> bool { + *matches.get_one::(name).unwrap_or(&false) +} diff --git a/common/directory/src/lib.rs b/common/directory/src/lib.rs index e8585c504a0..df03b4f9a4e 100644 --- a/common/directory/src/lib.rs +++ b/common/directory/src/lib.rs @@ -21,9 +21,9 @@ pub const CUSTOM_TESTNET_DIR: &str = "custom"; /// if not present, then checks the "testnet-dir" flag and returns a custom name /// If neither flags are present, returns the default hardcoded network name. pub fn get_network_dir(matches: &ArgMatches) -> String { - if let Some(network_name) = matches.value_of("network") { + if let Some(network_name) = matches.get_one::("network") { network_name.to_string() - } else if matches.value_of("testnet-dir").is_some() { + } else if matches.get_one::("testnet-dir").is_some() { CUSTOM_TESTNET_DIR.to_string() } else { eth2_network_config::DEFAULT_HARDCODED_NETWORK.to_string() diff --git a/database_manager/src/lib.rs b/database_manager/src/lib.rs index 617192abfef..fafff0f0f9d 100644 --- a/database_manager/src/lib.rs +++ b/database_manager/src/lib.rs @@ -3,7 +3,8 @@ use beacon_chain::{ slot_clock::SystemTimeSlotClock, }; use beacon_node::{get_data_dir, get_slots_per_restore_point, ClientConfig}; -use clap::{App, Arg, ArgMatches}; +use clap::{Arg, ArgAction, ArgMatches, Command}; +use clap_utils::{get_color_style, FLAG_HEADER}; use environment::{Environment, RuntimeContext}; use slog::{info, warn, Logger}; use std::fs; @@ -20,147 +21,173 @@ use types::{BeaconState, EthSpec, Slot}; pub const CMD: &str = "database_manager"; -pub fn version_cli_app<'a, 'b>() -> App<'a, 'b> { - App::new("version") - .visible_aliases(&["v"]) - .setting(clap::AppSettings::ColoredHelp) +pub fn version_cli_app() -> Command { + Command::new("version") + .visible_aliases(["v"]) + .styles(get_color_style()) .about("Display database schema version") } -pub fn migrate_cli_app<'a, 'b>() -> App<'a, 'b> { - App::new("migrate") - .setting(clap::AppSettings::ColoredHelp) +pub fn migrate_cli_app() -> Command { + Command::new("migrate") + .styles(get_color_style()) .about("Migrate the database to a specific schema version") .arg( - Arg::with_name("to") + Arg::new("to") .long("to") .value_name("VERSION") .help("Schema version to migrate to") - .takes_value(true) + .action(ArgAction::Set) .required(true), ) } -pub fn inspect_cli_app<'a, 'b>() -> App<'a, 'b> { - App::new("inspect") - .setting(clap::AppSettings::ColoredHelp) +pub fn inspect_cli_app() -> Command { + Command::new("inspect") + .styles(get_color_style()) .about("Inspect raw database values") .arg( - Arg::with_name("column") + Arg::new("column") .long("column") .value_name("TAG") .help("3-byte column ID (see `DBColumn`)") - .takes_value(true) - .required(true), + .action(ArgAction::Set) + .required(true) + .display_order(0), ) .arg( - Arg::with_name("output") + Arg::new("output") .long("output") .value_name("TARGET") .help("Select the type of output to show") .default_value("sizes") - .possible_values(InspectTarget::VARIANTS), + .value_parser(InspectTarget::VARIANTS.to_vec()) + .display_order(0), ) .arg( - Arg::with_name("skip") + Arg::new("skip") .long("skip") .value_name("N") - .help("Skip over the first N keys"), + .help("Skip over the first N keys") + .display_order(0), ) .arg( - Arg::with_name("limit") + Arg::new("limit") .long("limit") .value_name("N") - .help("Output at most N keys"), + .help("Output at most N keys") + .display_order(0), ) .arg( - Arg::with_name("freezer") + Arg::new("freezer") .long("freezer") .help("Inspect the freezer DB rather than the hot DB") - .takes_value(false) - .conflicts_with("blobs-db"), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .conflicts_with("blobs-db") + .display_order(0), ) .arg( - Arg::with_name("blobs-db") + Arg::new("blobs-db") .long("blobs-db") .help("Inspect the blobs DB rather than the hot DB") - .takes_value(false) - .conflicts_with("freezer"), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .conflicts_with("freezer") + .display_order(0), ) .arg( - Arg::with_name("output-dir") + Arg::new("output-dir") .long("output-dir") .value_name("DIR") .help("Base directory for the output files. Defaults to the current directory") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) } -pub fn compact_cli_app<'a, 'b>() -> App<'a, 'b> { - App::new("compact") - .setting(clap::AppSettings::ColoredHelp) +pub fn compact_cli_app() -> Command { + Command::new("compact") + .styles(get_color_style()) .about("Compact database manually") .arg( - Arg::with_name("column") + Arg::new("column") .long("column") .value_name("TAG") .help("3-byte column ID (see `DBColumn`)") - .takes_value(true) - .required(true), + .action(ArgAction::Set) + .required(true) + .display_order(0), ) .arg( - Arg::with_name("freezer") + Arg::new("freezer") .long("freezer") .help("Inspect the freezer DB rather than the hot DB") - .takes_value(false) - .conflicts_with("blobs-db"), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .conflicts_with("blobs-db") + .display_order(0), ) .arg( - Arg::with_name("blobs-db") + Arg::new("blobs-db") .long("blobs-db") .help("Inspect the blobs DB rather than the hot DB") - .takes_value(false) - .conflicts_with("freezer"), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .conflicts_with("freezer") + .display_order(0), ) } -pub fn prune_payloads_app<'a, 'b>() -> App<'a, 'b> { - App::new("prune-payloads") +pub fn prune_payloads_app() -> Command { + Command::new("prune-payloads") .alias("prune_payloads") - .setting(clap::AppSettings::ColoredHelp) + .styles(get_color_style()) .about("Prune finalized execution payloads") } -pub fn prune_blobs_app<'a, 'b>() -> App<'a, 'b> { - App::new("prune-blobs") +pub fn prune_blobs_app() -> Command { + Command::new("prune-blobs") .alias("prune_blobs") - .setting(clap::AppSettings::ColoredHelp) + .styles(get_color_style()) .about("Prune blobs older than data availability boundary") } -pub fn prune_states_app<'a, 'b>() -> App<'a, 'b> { - App::new("prune-states") +pub fn prune_states_app() -> Command { + Command::new("prune-states") .alias("prune_states") .arg( - Arg::with_name("confirm") + Arg::new("confirm") .long("confirm") .help( "Commit to pruning states irreversably. Without this flag the command will \ just check that the database is capable of being pruned.", ) - .takes_value(false), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0), ) - .setting(clap::AppSettings::ColoredHelp) + .styles(get_color_style()) .about("Prune all beacon states from the freezer database") } -pub fn cli_app<'a, 'b>() -> App<'a, 'b> { - App::new(CMD) - .visible_aliases(&["db"]) - .setting(clap::AppSettings::ColoredHelp) +pub fn cli_app() -> Command { + Command::new(CMD) + .display_order(0) + .visible_aliases(["db"]) + .styles(get_color_style()) .about("Manage a beacon node database") .arg( - Arg::with_name("slots-per-restore-point") + Arg::new("help") + .long("help") + .short('h') + .help("Prints help information") + .action(ArgAction::HelpLong) + .display_order(0) + .help_heading(FLAG_HEADER), + ) + .arg( + Arg::new("slots-per-restore-point") .long("slots-per-restore-point") .value_name("SLOT_COUNT") .help( @@ -168,32 +195,36 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { Cannot be changed after initialization. \ [default: 2048 (mainnet) or 64 (minimal)]", ) - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name("freezer-dir") + Arg::new("freezer-dir") .long("freezer-dir") .value_name("DIR") .help("Data directory for the freezer database.") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name("blob-prune-margin-epochs") + Arg::new("blob-prune-margin-epochs") .long("blob-prune-margin-epochs") .value_name("EPOCHS") .help( "The margin for blob pruning in epochs. The oldest blobs are pruned \ up until data_availability_boundary - blob_prune_margin_epochs.", ) - .takes_value(true) - .default_value("0"), + .action(ArgAction::Set) + .default_value("0") + .display_order(0), ) .arg( - Arg::with_name("blobs-dir") + Arg::new("blobs-dir") .long("blobs-dir") .value_name("DIR") .help("Data directory for the blobs database.") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) .subcommand(migrate_cli_app()) .subcommand(version_cli_app()) @@ -298,8 +329,8 @@ fn parse_inspect_config(cli_args: &ArgMatches) -> Result let target = clap_utils::parse_required(cli_args, "output")?; let skip = clap_utils::parse_optional(cli_args, "skip")?; let limit = clap_utils::parse_optional(cli_args, "limit")?; - let freezer = cli_args.is_present("freezer"); - let blobs_db = cli_args.is_present("blobs-db"); + let freezer = cli_args.get_flag("freezer"); + let blobs_db = cli_args.get_flag("blobs-db"); let output_dir: PathBuf = clap_utils::parse_optional(cli_args, "output-dir")?.unwrap_or_else(PathBuf::new); @@ -421,8 +452,8 @@ pub struct CompactConfig { fn parse_compact_config(cli_args: &ArgMatches) -> Result { let column = clap_utils::parse_required(cli_args, "column")?; - let freezer = cli_args.is_present("freezer"); - let blobs_db = cli_args.is_present("blobs-db"); + let freezer = cli_args.get_flag("freezer"); + let blobs_db = cli_args.get_flag("blobs-db"); Ok(CompactConfig { column, freezer, @@ -566,7 +597,7 @@ pub struct PruneStatesConfig { } fn parse_prune_states_config(cli_args: &ArgMatches) -> Result { - let confirm = cli_args.is_present("confirm"); + let confirm = cli_args.get_flag("confirm"); Ok(PruneStatesConfig { confirm }) } @@ -645,33 +676,33 @@ pub fn prune_states( } /// Run the database manager, returning an error string if the operation did not succeed. -pub fn run(cli_args: &ArgMatches<'_>, env: Environment) -> Result<(), String> { +pub fn run(cli_args: &ArgMatches, env: Environment) -> Result<(), String> { let client_config = parse_client_config(cli_args, &env)?; let context = env.core_context(); let log = context.log().clone(); let format_err = |e| format!("Fatal error: {:?}", e); match cli_args.subcommand() { - ("version", Some(_)) => { + Some(("version", _)) => { display_db_version(client_config, &context, log).map_err(format_err) } - ("migrate", Some(cli_args)) => { + Some(("migrate", cli_args)) => { let migrate_config = parse_migrate_config(cli_args)?; migrate_db(migrate_config, client_config, &context, log).map_err(format_err) } - ("inspect", Some(cli_args)) => { + Some(("inspect", cli_args)) => { let inspect_config = parse_inspect_config(cli_args)?; inspect_db::(inspect_config, client_config) } - ("compact", Some(cli_args)) => { + Some(("compact", cli_args)) => { let compact_config = parse_compact_config(cli_args)?; compact_db::(compact_config, client_config, log).map_err(format_err) } - ("prune-payloads", Some(_)) => { + Some(("prune-payloads", _)) => { prune_payloads(client_config, &context, log).map_err(format_err) } - ("prune-blobs", Some(_)) => prune_blobs(client_config, &context, log).map_err(format_err), - ("prune-states", Some(cli_args)) => { + Some(("prune-blobs", _)) => prune_blobs(client_config, &context, log).map_err(format_err), + Some(("prune-states", cli_args)) => { let executor = env.core_context().executor; let network_config = context .eth2_network_config diff --git a/lcli/src/change_genesis_time.rs b/lcli/src/change_genesis_time.rs index f75652c768f..1b100d4644c 100644 --- a/lcli/src/change_genesis_time.rs +++ b/lcli/src/change_genesis_time.rs @@ -8,13 +8,13 @@ use types::{BeaconState, EthSpec}; pub fn run(testnet_dir: PathBuf, matches: &ArgMatches) -> Result<(), String> { let path = matches - .value_of("ssz-state") + .get_one::("ssz-state") .ok_or("ssz-state not specified")? .parse::() .map_err(|e| format!("Unable to parse ssz-state: {}", e))?; let genesis_time = matches - .value_of("genesis-time") + .get_one::("genesis-time") .ok_or("genesis-time not specified")? .parse::() .map_err(|e| format!("Unable to parse genesis-time: {}", e))?; diff --git a/lcli/src/create_payload_header.rs b/lcli/src/create_payload_header.rs index 974a34591f0..65ee40a5e72 100644 --- a/lcli/src/create_payload_header.rs +++ b/lcli/src/create_payload_header.rs @@ -20,7 +20,9 @@ pub fn run(matches: &ArgMatches) -> Result<(), String> { ); let base_fee_per_gas = parse_required(matches, "base-fee-per-gas")?; let gas_limit = parse_required(matches, "gas-limit")?; - let file_name = matches.value_of("file").ok_or("No file supplied")?; + let file_name = matches + .get_one::("file") + .ok_or("No file supplied")?; let fork_name: ForkName = parse_optional(matches, "fork")?.unwrap_or(ForkName::Bellatrix); let execution_payload_header: ExecutionPayloadHeader = match fork_name { diff --git a/lcli/src/deploy_deposit_contract.rs b/lcli/src/deploy_deposit_contract.rs index b920486c846..0674028bee9 100644 --- a/lcli/src/deploy_deposit_contract.rs +++ b/lcli/src/deploy_deposit_contract.rs @@ -4,7 +4,7 @@ use types::EthSpec; use eth1_test_rig::{Http, Provider}; -pub fn run(env: Environment, matches: &ArgMatches<'_>) -> Result<(), String> { +pub fn run(env: Environment, matches: &ArgMatches) -> Result<(), String> { let eth1_http: String = clap_utils::parse_required(matches, "eth1-http")?; let confirmations: usize = clap_utils::parse_required(matches, "confirmations")?; let validator_count: Option = clap_utils::parse_optional(matches, "validator-count")?; diff --git a/lcli/src/eth1_genesis.rs b/lcli/src/eth1_genesis.rs index 635a36ef709..1879851841b 100644 --- a/lcli/src/eth1_genesis.rs +++ b/lcli/src/eth1_genesis.rs @@ -15,15 +15,19 @@ pub const ETH1_GENESIS_UPDATE_INTERVAL: Duration = Duration::from_millis(7_000); pub fn run( env: Environment, testnet_dir: PathBuf, - matches: &ArgMatches<'_>, + matches: &ArgMatches, ) -> Result<(), String> { let endpoints = matches - .value_of("eth1-endpoint") + .get_one::("eth1-endpoint") .map(|e| { warn!("The --eth1-endpoint flag is deprecated. Please use --eth1-endpoints instead"); String::from(e) }) - .or_else(|| matches.value_of("eth1-endpoints").map(String::from)); + .or_else(|| { + matches + .get_one::("eth1-endpoints") + .map(String::from) + }); let mut eth2_network_config = Eth2NetworkConfig::load(testnet_dir.clone())?; diff --git a/lcli/src/interop_genesis.rs b/lcli/src/interop_genesis.rs index f44edffd468..4987a844763 100644 --- a/lcli/src/interop_genesis.rs +++ b/lcli/src/interop_genesis.rs @@ -9,12 +9,12 @@ use types::{test_utils::generate_deterministic_keypairs, EthSpec, Hash256}; pub fn run(testnet_dir: PathBuf, matches: &ArgMatches) -> Result<(), String> { let validator_count = matches - .value_of("validator-count") + .get_one::("validator-count") .ok_or("validator-count not specified")? .parse::() .map_err(|e| format!("Unable to parse validator-count: {}", e))?; - let genesis_time = if let Some(genesis_time) = matches.value_of("genesis-time") { + let genesis_time = if let Some(genesis_time) = matches.get_one::("genesis-time") { genesis_time .parse::() .map_err(|e| format!("Unable to parse genesis-time: {}", e))? diff --git a/lcli/src/main.rs b/lcli/src/main.rs index 7b5c1598c9e..e0e3b9b461e 100644 --- a/lcli/src/main.rs +++ b/lcli/src/main.rs @@ -19,8 +19,8 @@ mod skip_slots; mod state_root; mod transition_blocks; -use clap::{App, Arg, ArgMatches, SubCommand}; -use clap_utils::parse_optional; +use clap::{Arg, ArgAction, ArgMatches, Command}; +use clap_utils::{parse_optional, FLAG_HEADER}; use environment::{EnvironmentBuilder, LoggerConfig}; use eth2_network_config::Eth2NetworkConfig; use parse_ssz::run_parse_ssz; @@ -32,327 +32,367 @@ use types::{EthSpec, EthSpecId}; fn main() { env_logger::init(); - let matches = App::new("Lighthouse CLI Tool") + let matches = Command::new("Lighthouse CLI Tool") .version(lighthouse_version::VERSION) + .display_order(0) .about("Performs various testing-related tasks, including defining testnets.") .arg( - Arg::with_name("spec") - .short("s") + Arg::new("spec") + .short('s') .long("spec") .value_name("STRING") - .takes_value(true) - .possible_values(&["minimal", "mainnet", "gnosis"]) + .action(ArgAction::Set) + .value_parser(["minimal", "mainnet", "gnosis"]) .default_value("mainnet") - .global(true), + .global(true) + .display_order(0) ) .arg( - Arg::with_name("testnet-dir") - .short("d") + Arg::new("testnet-dir") + .short('d') .long("testnet-dir") .value_name("PATH") - .takes_value(true) + .action(ArgAction::Set) .global(true) - .help("The testnet dir."), + .help("The testnet dir.") + .display_order(0) ) .arg( - Arg::with_name("network") + Arg::new("network") .long("network") .value_name("NAME") - .takes_value(true) + .action(ArgAction::Set) .global(true) .help("The network to use. Defaults to mainnet.") .conflicts_with("testnet-dir") + .display_order(0) ) .subcommand( - SubCommand::with_name("skip-slots") + Command::new("skip-slots") .about( "Performs a state transition from some state across some number of skip slots", ) .arg( - Arg::with_name("output-path") + Arg::new("output-path") .long("output-path") .value_name("PATH") - .takes_value(true) - .help("Path to output a SSZ file."), + .action(ArgAction::Set) + .help("Path to output a SSZ file.") + .display_order(0) ) .arg( - Arg::with_name("pre-state-path") + Arg::new("pre-state-path") .long("pre-state-path") .value_name("PATH") - .takes_value(true) + .action(ArgAction::Set) .conflicts_with("beacon-url") - .help("Path to a SSZ file of the pre-state."), + .help("Path to a SSZ file of the pre-state.") + .display_order(0) ) .arg( - Arg::with_name("beacon-url") + Arg::new("beacon-url") .long("beacon-url") .value_name("URL") - .takes_value(true) - .help("URL to a beacon-API provider."), + .action(ArgAction::Set) + .help("URL to a beacon-API provider.") + .display_order(0) ) .arg( - Arg::with_name("state-id") + Arg::new("state-id") .long("state-id") .value_name("STATE_ID") - .takes_value(true) + .action(ArgAction::Set) .requires("beacon-url") - .help("Identifier for a state as per beacon-API standards (slot, root, etc.)"), + .help("Identifier for a state as per beacon-API standards (slot, root, etc.)") + .display_order(0) ) .arg( - Arg::with_name("runs") + Arg::new("runs") .long("runs") .value_name("INTEGER") - .takes_value(true) + .action(ArgAction::Set) .default_value("1") - .help("Number of repeat runs, useful for benchmarking."), + .help("Number of repeat runs, useful for benchmarking.") + .display_order(0) ) .arg( - Arg::with_name("state-root") + Arg::new("state-root") .long("state-root") .value_name("HASH256") - .takes_value(true) - .help("Tree hash root of the provided state, to avoid computing it."), + .action(ArgAction::Set) + .help("Tree hash root of the provided state, to avoid computing it.") + .display_order(0) ) .arg( - Arg::with_name("slots") + Arg::new("slots") .long("slots") .value_name("INTEGER") - .takes_value(true) - .help("Number of slots to skip forward."), + .action(ArgAction::Set) + .help("Number of slots to skip forward.") + .display_order(0) ) .arg( - Arg::with_name("partial-state-advance") + Arg::new("partial-state-advance") .long("partial-state-advance") - .takes_value(false) - .help("If present, don't compute state roots when skipping forward."), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .help("If present, don't compute state roots when skipping forward.") + .display_order(0) ) ) .subcommand( - SubCommand::with_name("transition-blocks") + Command::new("transition-blocks") .about("Performs a state transition given a pre-state and block") .arg( - Arg::with_name("pre-state-path") + Arg::new("pre-state-path") .long("pre-state-path") .value_name("PATH") - .takes_value(true) + .action(ArgAction::Set) .conflicts_with("beacon-url") .requires("block-path") - .help("Path to load a BeaconState from as SSZ."), + .help("Path to load a BeaconState from as SSZ.") + .display_order(0) ) .arg( - Arg::with_name("block-path") + Arg::new("block-path") .long("block-path") .value_name("PATH") - .takes_value(true) + .action(ArgAction::Set) .conflicts_with("beacon-url") .requires("pre-state-path") - .help("Path to load a SignedBeaconBlock from as SSZ."), + .help("Path to load a SignedBeaconBlock from as SSZ.") + .display_order(0) ) .arg( - Arg::with_name("post-state-output-path") + Arg::new("post-state-output-path") .long("post-state-output-path") .value_name("PATH") - .takes_value(true) - .help("Path to output the post-state."), + .action(ArgAction::Set) + .help("Path to output the post-state.") + .display_order(0) ) .arg( - Arg::with_name("pre-state-output-path") + Arg::new("pre-state-output-path") .long("pre-state-output-path") .value_name("PATH") - .takes_value(true) - .help("Path to output the pre-state, useful when used with --beacon-url."), + .action(ArgAction::Set) + .help("Path to output the pre-state, useful when used with --beacon-url.") + .display_order(0) ) .arg( - Arg::with_name("block-output-path") + Arg::new("block-output-path") .long("block-output-path") .value_name("PATH") - .takes_value(true) - .help("Path to output the block, useful when used with --beacon-url."), + .action(ArgAction::Set) + .help("Path to output the block, useful when used with --beacon-url.") + .display_order(0) ) .arg( - Arg::with_name("beacon-url") + Arg::new("beacon-url") .long("beacon-url") .value_name("URL") - .takes_value(true) - .help("URL to a beacon-API provider."), + .action(ArgAction::Set) + .help("URL to a beacon-API provider.") + .display_order(0) ) .arg( - Arg::with_name("block-id") + Arg::new("block-id") .long("block-id") .value_name("BLOCK_ID") - .takes_value(true) + .action(ArgAction::Set) .requires("beacon-url") - .help("Identifier for a block as per beacon-API standards (slot, root, etc.)"), + .help("Identifier for a block as per beacon-API standards (slot, root, etc.)") + .display_order(0) ) .arg( - Arg::with_name("runs") + Arg::new("runs") .long("runs") .value_name("INTEGER") - .takes_value(true) + .action(ArgAction::Set) .default_value("1") - .help("Number of repeat runs, useful for benchmarking."), + .help("Number of repeat runs, useful for benchmarking.") + .display_order(0) ) .arg( - Arg::with_name("no-signature-verification") + Arg::new("no-signature-verification") .long("no-signature-verification") - .takes_value(false) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .help("Disable signature verification.") + .display_order(0) ) .arg( - Arg::with_name("exclude-cache-builds") + Arg::new("exclude-cache-builds") .long("exclude-cache-builds") - .takes_value(false) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .help("If present, pre-build the committee and tree-hash caches without \ - including them in the timings."), + including them in the timings.") + .display_order(0) ) .arg( - Arg::with_name("exclude-post-block-thc") + Arg::new("exclude-post-block-thc") .long("exclude-post-block-thc") - .takes_value(false) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .help("If present, don't rebuild the tree-hash-cache after applying \ - the block."), + the block.") + .display_order(0) ) ) .subcommand( - SubCommand::with_name("pretty-ssz") + Command::new("pretty-ssz") .about("Parses SSZ-encoded data from a file") .arg( - Arg::with_name("format") - .short("f") + Arg::new("format") + .short('f') .long("format") .value_name("FORMAT") - .takes_value(true) - .required(true) + .action(ArgAction::Set) + .required(false) .default_value("json") - .possible_values(&["json", "yaml"]) + .value_parser(["json", "yaml"]) .help("Output format to use") + .display_order(0) ) .arg( - Arg::with_name("type") + Arg::new("type") .value_name("TYPE") - .takes_value(true) + .action(ArgAction::Set) .required(true) - .help("Type to decode"), + .help("Type to decode") + .display_order(0) ) .arg( - Arg::with_name("ssz-file") + Arg::new("ssz-file") .value_name("FILE") - .takes_value(true) + .action(ArgAction::Set) .required(true) - .help("Path to SSZ bytes"), + .help("Path to SSZ bytes") + .display_order(0) ) ) .subcommand( - SubCommand::with_name("deploy-deposit-contract") + Command::new("deploy-deposit-contract") .about( "Deploy a testing eth1 deposit contract.", ) .arg( - Arg::with_name("eth1-http") + Arg::new("eth1-http") .long("eth1-http") - .short("e") + .short('e') .value_name("ETH1_HTTP_PATH") .help("Path to an Eth1 JSON-RPC IPC endpoint") - .takes_value(true) + .action(ArgAction::Set) .required(true) + .display_order(0) ) .arg( - Arg::with_name("confirmations") + Arg::new("confirmations") .value_name("INTEGER") .long("confirmations") - .takes_value(true) + .action(ArgAction::Set) .default_value("3") - .help("The number of block confirmations before declaring the contract deployed."), + .help("The number of block confirmations before declaring the contract deployed.") + .display_order(0) ) .arg( - Arg::with_name("validator-count") + Arg::new("validator-count") .value_name("VALIDATOR_COUNT") .long("validator-count") - .takes_value(true) + .action(ArgAction::Set) .help("If present, makes `validator_count` number of INSECURE deterministic deposits after \ deploying the deposit contract." - ), + ) + .display_order(0) ) ) .subcommand( - SubCommand::with_name("eth1-genesis") + Command::new("eth1-genesis") .about("Listens to the eth1 chain and finds the genesis beacon state") .arg( - Arg::with_name("eth1-endpoint") - .short("e") + Arg::new("eth1-endpoint") + .short('e') .long("eth1-endpoint") .value_name("HTTP_SERVER") - .takes_value(true) - .help("Deprecated. Use --eth1-endpoints."), + .action(ArgAction::Set) + .help("Deprecated. Use --eth1-endpoints.") + .display_order(0) ) .arg( - Arg::with_name("eth1-endpoints") + Arg::new("eth1-endpoints") .long("eth1-endpoints") .value_name("HTTP_SERVER_LIST") - .takes_value(true) + .action(ArgAction::Set) .conflicts_with("eth1-endpoint") .help( "One or more comma-delimited URLs to eth1 JSON-RPC http APIs. \ If multiple endpoints are given the endpoints are used as \ fallback in the given order.", - ), + ) + .display_order(0) ), ) .subcommand( - SubCommand::with_name("interop-genesis") + Command::new("interop-genesis") .about("Produces an interop-compatible genesis state using deterministic keypairs") .arg( - Arg::with_name("validator-count") + Arg::new("validator-count") .long("validator-count") .index(1) .value_name("INTEGER") - .takes_value(true) + .action(ArgAction::Set) .default_value("1024") - .help("The number of validators in the genesis state."), + .help("The number of validators in the genesis state.") + .display_order(0) ) .arg( - Arg::with_name("genesis-time") + Arg::new("genesis-time") .long("genesis-time") - .short("t") + .short('t') .value_name("UNIX_EPOCH") - .takes_value(true) - .help("The value for state.genesis_time. Defaults to now."), + .action(ArgAction::Set) + .help("The value for state.genesis_time. Defaults to now.") + .display_order(0) ) .arg( - Arg::with_name("genesis-fork-version") + Arg::new("genesis-fork-version") .long("genesis-fork-version") .value_name("HEX") - .takes_value(true) + .action(ArgAction::Set) .help( "Used to avoid reply attacks between testnets. Recommended to set to non-default.", - ), + ) + .display_order(0) ), ) .subcommand( - SubCommand::with_name("change-genesis-time") + Command::new("change-genesis-time") .about( "Loads a file with an SSZ-encoded BeaconState and modifies the genesis time.", ) .arg( - Arg::with_name("ssz-state") + Arg::new("ssz-state") .index(1) .value_name("PATH") - .takes_value(true) + .action(ArgAction::Set) .required(true) - .help("The path to the SSZ file"), + .help("The path to the SSZ file") + .display_order(0) ) .arg( - Arg::with_name("genesis-time") + Arg::new("genesis-time") .index(2) .value_name("UNIX_EPOCH") - .takes_value(true) + .action(ArgAction::Set) .required(true) - .help("The value for state.genesis_time."), + .help("The value for state.genesis_time.") + .display_order(0) ), ) .subcommand( - SubCommand::with_name("replace-state-pubkeys") + Command::new("replace-state-pubkeys") .about( "Loads a file with an SSZ-encoded BeaconState and replaces \ all the validator pubkeys with ones derived from the mnemonic \ @@ -360,616 +400,687 @@ fn main() { derivation paths.", ) .arg( - Arg::with_name("ssz-state") + Arg::new("ssz-state") .index(1) .value_name("PATH") - .takes_value(true) + .action(ArgAction::Set) .required(true) - .help("The path to the SSZ file"), + .help("The path to the SSZ file") + .display_order(0) ) .arg( - Arg::with_name("mnemonic") + Arg::new("mnemonic") .index(2) .value_name("BIP39_MNENMONIC") - .takes_value(true) + .action(ArgAction::Set) .default_value( "replace nephew blur decorate waste convince soup column \ orient excite play baby", ) - .help("The mnemonic for key derivation."), + .help("The mnemonic for key derivation.") + .display_order(0) ), ) .subcommand( - SubCommand::with_name("create-payload-header") + Command::new("create-payload-header") .about("Generates an SSZ file containing bytes for an `ExecutionPayloadHeader`. \ Useful as input for `lcli new-testnet --execution-payload-header FILE`. If `--fork` \ is not provided, a payload header for the `Bellatrix` fork will be created.") .arg( - Arg::with_name("execution-block-hash") + Arg::new("execution-block-hash") .long("execution-block-hash") .value_name("BLOCK_HASH") - .takes_value(true) + .action(ArgAction::Set) .help("The block hash used when generating an execution payload. This \ value is used for `execution_payload_header.block_hash` as well as \ `execution_payload_header.random`") .default_value( "0x0000000000000000000000000000000000000000000000000000000000000000", - ), + ) + .display_order(0) ) .arg( - Arg::with_name("genesis-time") + Arg::new("genesis-time") .long("genesis-time") .value_name("INTEGER") - .takes_value(true) + .action(ArgAction::Set) .help("The genesis time when generating an execution payload.") + .display_order(0) ) .arg( - Arg::with_name("base-fee-per-gas") + Arg::new("base-fee-per-gas") .long("base-fee-per-gas") .value_name("INTEGER") - .takes_value(true) + .action(ArgAction::Set) .help("The base fee per gas field in the execution payload generated.") - .default_value("1000000000"), + .default_value("1000000000") + .display_order(0) ) .arg( - Arg::with_name("gas-limit") + Arg::new("gas-limit") .long("gas-limit") .value_name("INTEGER") - .takes_value(true) + .action(ArgAction::Set) .help("The gas limit field in the execution payload generated.") - .default_value("30000000"), + .default_value("30000000") + .display_order(0) ) .arg( - Arg::with_name("file") + Arg::new("file") .long("file") .value_name("FILE") - .takes_value(true) + .action(ArgAction::Set) .required(true) - .help("Output file"), + .help("Output file") + .display_order(0) ).arg( - Arg::with_name("fork") + Arg::new("fork") .long("fork") .value_name("FORK") - .takes_value(true) + .action(ArgAction::Set) .default_value("bellatrix") .help("The fork for which the execution payload header should be created.") - .possible_values(&["bellatrix", "capella", "deneb", "electra"]) + .value_parser(["bellatrix", "capella", "deneb", "electra"]) + .display_order(0) ) ) .subcommand( - SubCommand::with_name("new-testnet") + Command::new("new-testnet") .about( "Produce a new testnet directory. If any of the optional flags are not supplied the values will remain the default for the --spec flag", ) .arg( - Arg::with_name("force") + Arg::new("force") .long("force") - .short("f") - .takes_value(false) - .help("Overwrites any previous testnet configurations"), + .short('f') + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .help("Overwrites any previous testnet configurations") + .display_order(0) ) .arg( - Arg::with_name("interop-genesis-state") + Arg::new("interop-genesis-state") .long("interop-genesis-state") - .takes_value(false) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .help( "If present, a interop-style genesis.ssz file will be generated.", - ), + ) + .display_order(0) ) .arg( - Arg::with_name("derived-genesis-state") + Arg::new("derived-genesis-state") .long("derived-genesis-state") - .takes_value(false) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .help( "If present, a genesis.ssz file will be generated with keys generated from a given mnemonic.", - ), + ) + .display_order(0) ) .arg( - Arg::with_name("mnemonic-phrase") + Arg::new("mnemonic-phrase") .long("mnemonic-phrase") .value_name("MNEMONIC_PHRASE") - .takes_value(true) + .action(ArgAction::Set) .requires("derived-genesis-state") - .help("The mnemonic with which we generate the validator keys for a derived genesis state"), + .help("The mnemonic with which we generate the validator keys for a derived genesis state") + .display_order(0) ) .arg( - Arg::with_name("min-genesis-time") + Arg::new("min-genesis-time") .long("min-genesis-time") .value_name("UNIX_SECONDS") - .takes_value(true) + .action(ArgAction::Set) .help( "The minimum permitted genesis time. For non-eth1 testnets will be the genesis time. Defaults to now.", - ), + ) + .display_order(0) ) .arg( - Arg::with_name("min-genesis-active-validator-count") + Arg::new("min-genesis-active-validator-count") .long("min-genesis-active-validator-count") .value_name("INTEGER") - .takes_value(true) - .help("The number of validators required to trigger eth2 genesis."), + .action(ArgAction::Set) + .help("The number of validators required to trigger eth2 genesis.") + .display_order(0) ) .arg( - Arg::with_name("genesis-delay") + Arg::new("genesis-delay") .long("genesis-delay") .value_name("SECONDS") - .takes_value(true) - .help("The delay between sufficient eth1 deposits and eth2 genesis."), + .action(ArgAction::Set) + .help("The delay between sufficient eth1 deposits and eth2 genesis.") + .display_order(0) ) .arg( - Arg::with_name("min-deposit-amount") + Arg::new("min-deposit-amount") .long("min-deposit-amount") .value_name("GWEI") - .takes_value(true) - .help("The minimum permitted deposit amount."), + .action(ArgAction::Set) + .help("The minimum permitted deposit amount.") + .display_order(0) ) .arg( - Arg::with_name("max-effective-balance") + Arg::new("max-effective-balance") .long("max-effective-balance") .value_name("GWEI") - .takes_value(true) - .help("The amount required to become a validator."), + .action(ArgAction::Set) + .help("The amount required to become a validator.") + .display_order(0) ) .arg( - Arg::with_name("effective-balance-increment") + Arg::new("effective-balance-increment") .long("effective-balance-increment") .value_name("GWEI") - .takes_value(true) - .help("The steps in effective balance calculation."), + .action(ArgAction::Set) + .help("The steps in effective balance calculation.") + .display_order(0) ) .arg( - Arg::with_name("ejection-balance") + Arg::new("ejection-balance") .long("ejection-balance") .value_name("GWEI") - .takes_value(true) - .help("The balance at which a validator gets ejected."), + .action(ArgAction::Set) + .help("The balance at which a validator gets ejected.") + .display_order(0) ) .arg( - Arg::with_name("eth1-follow-distance") + Arg::new("eth1-follow-distance") .long("eth1-follow-distance") .value_name("ETH1_BLOCKS") - .takes_value(true) - .help("The distance to follow behind the eth1 chain head."), + .action(ArgAction::Set) + .help("The distance to follow behind the eth1 chain head.") + .display_order(0) ) .arg( - Arg::with_name("genesis-fork-version") + Arg::new("genesis-fork-version") .long("genesis-fork-version") .value_name("HEX") - .takes_value(true) + .action(ArgAction::Set) .help( "Used to avoid reply attacks between testnets. Recommended to set to non-default.", - ), + ) + .display_order(0) ) .arg( - Arg::with_name("seconds-per-slot") + Arg::new("seconds-per-slot") .long("seconds-per-slot") .value_name("SECONDS") - .takes_value(true) - .help("Eth2 slot time"), + .action(ArgAction::Set) + .help("Eth2 slot time") + .display_order(0) ) .arg( - Arg::with_name("seconds-per-eth1-block") + Arg::new("seconds-per-eth1-block") .long("seconds-per-eth1-block") .value_name("SECONDS") - .takes_value(true) - .help("Eth1 block time"), + .action(ArgAction::Set) + .help("Eth1 block time") + .display_order(0) ) .arg( - Arg::with_name("eth1-id") + Arg::new("eth1-id") .long("eth1-id") .value_name("ETH1_ID") - .takes_value(true) - .help("The chain id and network id for the eth1 testnet."), + .action(ArgAction::Set) + .help("The chain id and network id for the eth1 testnet.") + .display_order(0) ) .arg( - Arg::with_name("deposit-contract-address") + Arg::new("deposit-contract-address") .long("deposit-contract-address") .value_name("ETH1_ADDRESS") - .takes_value(true) + .action(ArgAction::Set) .required(true) - .help("The address of the deposit contract."), + .help("The address of the deposit contract.") + .display_order(0) ) .arg( - Arg::with_name("deposit-contract-deploy-block") + Arg::new("deposit-contract-deploy-block") .long("deposit-contract-deploy-block") .value_name("ETH1_BLOCK_NUMBER") - .takes_value(true) + .action(ArgAction::Set) .default_value("0") .help( "The block the deposit contract was deployed. Setting this is a huge optimization for nodes, please do it.", - ), + ) + .display_order(0) ) .arg( - Arg::with_name("altair-fork-epoch") + Arg::new("altair-fork-epoch") .long("altair-fork-epoch") .value_name("EPOCH") - .takes_value(true) + .action(ArgAction::Set) .help( "The epoch at which to enable the Altair hard fork", - ), + ) + .display_order(0) ) .arg( - Arg::with_name("bellatrix-fork-epoch") + Arg::new("bellatrix-fork-epoch") .long("bellatrix-fork-epoch") .value_name("EPOCH") - .takes_value(true) + .action(ArgAction::Set) .help( "The epoch at which to enable the Bellatrix hard fork", - ), + ) + .display_order(0) ) .arg( - Arg::with_name("capella-fork-epoch") + Arg::new("capella-fork-epoch") .long("capella-fork-epoch") .value_name("EPOCH") - .takes_value(true) + .action(ArgAction::Set) .help( "The epoch at which to enable the Capella hard fork", - ), + ) + .display_order(0) ) .arg( - Arg::with_name("deneb-fork-epoch") + Arg::new("deneb-fork-epoch") .long("deneb-fork-epoch") .value_name("EPOCH") - .takes_value(true) + .action(ArgAction::Set) .help( "The epoch at which to enable the Deneb hard fork", - ), + ) + .display_order(0) ) .arg( - Arg::with_name("electra-fork-epoch") + Arg::new("electra-fork-epoch") .long("electra-fork-epoch") .value_name("EPOCH") - .takes_value(true) + .action(ArgAction::Set) .help( "The epoch at which to enable the Electra hard fork", - ), + ) + .display_order(0) ) .arg( - Arg::with_name("ttd") + Arg::new("ttd") .long("ttd") .value_name("TTD") - .takes_value(true) + .action(ArgAction::Set) .help( "The terminal total difficulty", - ), + ) + .display_order(0) ) .arg( - Arg::with_name("eth1-block-hash") + Arg::new("eth1-block-hash") .long("eth1-block-hash") .value_name("BLOCK_HASH") - .takes_value(true) - .help("The eth1 block hash used when generating a genesis state."), + .action(ArgAction::Set) + .help("The eth1 block hash used when generating a genesis state.") + .display_order(0) ) .arg( - Arg::with_name("execution-payload-header") + Arg::new("execution-payload-header") .long("execution-payload-header") .value_name("FILE") - .takes_value(true) + .action(ArgAction::Set) .required(false) .help("Path to file containing `ExecutionPayloadHeader` SSZ bytes to be \ - used in the genesis state."), + used in the genesis state.") + .display_order(0) ) .arg( - Arg::with_name("validator-count") + Arg::new("validator-count") .long("validator-count") .value_name("INTEGER") - .takes_value(true) - .help("The number of validators when generating a genesis state."), + .action(ArgAction::Set) + .help("The number of validators when generating a genesis state.") + .display_order(0) ) .arg( - Arg::with_name("genesis-time") + Arg::new("genesis-time") .long("genesis-time") .value_name("INTEGER") - .takes_value(true) - .help("The genesis time when generating a genesis state."), + .action(ArgAction::Set) + .help("The genesis time when generating a genesis state.") + .display_order(0) ) .arg( - Arg::with_name("proposer-score-boost") + Arg::new("proposer-score-boost") .long("proposer-score-boost") .value_name("INTEGER") - .takes_value(true) - .help("The proposer score boost to apply as a percentage, e.g. 70 = 70%"), + .action(ArgAction::Set) + .help("The proposer score boost to apply as a percentage, e.g. 70 = 70%") + .display_order(0) ) ) .subcommand( - SubCommand::with_name("check-deposit-data") + Command::new("check-deposit-data") .about("Checks the integrity of some deposit data.") .arg( - Arg::with_name("deposit-amount") + Arg::new("deposit-amount") .index(1) .value_name("GWEI") - .takes_value(true) + .action(ArgAction::Set) .required(true) - .help("The amount (in Gwei) that was deposited"), + .help("The amount (in Gwei) that was deposited") + .display_order(0) ) .arg( - Arg::with_name("deposit-data") + Arg::new("deposit-data") .index(2) .value_name("HEX") - .takes_value(true) + .action(ArgAction::Set) .required(true) .help( "A 0x-prefixed hex string of the deposit data. Should include the function signature.", - ), + ) + .display_order(0) ), ) .subcommand( - SubCommand::with_name("generate-bootnode-enr") + Command::new("generate-bootnode-enr") .about("Generates an ENR address to be used as a pre-genesis boot node.") .arg( - Arg::with_name("ip") + Arg::new("ip") .long("ip") .value_name("IP_ADDRESS") - .takes_value(true) + .action(ArgAction::Set) .required(true) - .help("The IP address to be included in the ENR and used for discovery"), + .help("The IP address to be included in the ENR and used for discovery") + .display_order(0) ) .arg( - Arg::with_name("udp-port") + Arg::new("udp-port") .long("udp-port") .value_name("UDP_PORT") - .takes_value(true) + .action(ArgAction::Set) .required(true) - .help("The UDP port to be included in the ENR and used for discovery"), + .help("The UDP port to be included in the ENR and used for discovery") + .display_order(0) ) .arg( - Arg::with_name("tcp-port") + Arg::new("tcp-port") .long("tcp-port") .value_name("TCP_PORT") - .takes_value(true) + .action(ArgAction::Set) .required(true) .help( "The TCP port to be included in the ENR and used for application comms", - ), + ) + .display_order(0) ) .arg( - Arg::with_name("output-dir") + Arg::new("output-dir") .long("output-dir") .value_name("OUTPUT_DIRECTORY") - .takes_value(true) + .action(ArgAction::Set) .required(true) - .help("The directory in which to create the network dir"), + .help("The directory in which to create the network dir") + .display_order(0) ) .arg( - Arg::with_name("genesis-fork-version") + Arg::new("genesis-fork-version") .long("genesis-fork-version") .value_name("HEX") - .takes_value(true) + .action(ArgAction::Set) .required(true) .help( "Used to avoid reply attacks between testnets. Recommended to set to non-default.", - ), + ) + .display_order(0) ), ) .subcommand( - SubCommand::with_name("insecure-validators") + Command::new("insecure-validators") .about("Produces validator directories with INSECURE, deterministic keypairs.") .arg( - Arg::with_name("count") + Arg::new("count") .long("count") .value_name("COUNT") - .takes_value(true) + .action(ArgAction::Set) .required(true) - .help("Produces validators in the range of 0..count."), + .help("Produces validators in the range of 0..count.") + .display_order(0) ) .arg( - Arg::with_name("base-dir") + Arg::new("base-dir") .long("base-dir") .value_name("BASE_DIR") - .takes_value(true) + .action(ArgAction::Set) .required(true) - .help("The base directory where validator keypairs and secrets are stored"), + .help("The base directory where validator keypairs and secrets are stored") + .display_order(0) ) .arg( - Arg::with_name("node-count") + Arg::new("node-count") .long("node-count") .value_name("NODE_COUNT") - .takes_value(true) - .help("The number of nodes to divide the validator keys to"), + .action(ArgAction::Set) + .help("The number of nodes to divide the validator keys to") + .display_order(0) ) ) .subcommand( - SubCommand::with_name("mnemonic-validators") + Command::new("mnemonic-validators") .about("Produces validator directories by deriving the keys from \ a mnemonic. For testing purposes only, DO NOT USE IN \ PRODUCTION!") .arg( - Arg::with_name("count") + Arg::new("count") .long("count") .value_name("COUNT") - .takes_value(true) + .action(ArgAction::Set) .required(true) - .help("Produces validators in the range of 0..count."), + .help("Produces validators in the range of 0..count.") + .display_order(0) ) .arg( - Arg::with_name("base-dir") + Arg::new("base-dir") .long("base-dir") .value_name("BASE_DIR") - .takes_value(true) + .action(ArgAction::Set) .required(true) - .help("The base directory where validator keypairs and secrets are stored"), + .help("The base directory where validator keypairs and secrets are stored") + .display_order(0) ) .arg( - Arg::with_name("node-count") + Arg::new("node-count") .long("node-count") .value_name("NODE_COUNT") - .takes_value(true) - .help("The number of nodes to divide the validator keys to"), + .action(ArgAction::Set) + .help("The number of nodes to divide the validator keys to") + .display_order(0) ) .arg( - Arg::with_name("mnemonic-phrase") + Arg::new("mnemonic-phrase") .long("mnemonic-phrase") .value_name("MNEMONIC_PHRASE") - .takes_value(true) + .action(ArgAction::Set) .required(true) - .help("The mnemonic with which we generate the validator keys"), + .help("The mnemonic with which we generate the validator keys") + .display_order(0) ) ) .subcommand( - SubCommand::with_name("indexed-attestations") + Command::new("indexed-attestations") .about("Convert attestations to indexed form, using the committees from a state.") .arg( - Arg::with_name("state") + Arg::new("state") .long("state") .value_name("SSZ_STATE") - .takes_value(true) + .action(ArgAction::Set) .required(true) - .help("BeaconState to generate committees from (SSZ)"), + .help("BeaconState to generate committees from (SSZ)") + .display_order(0) ) .arg( - Arg::with_name("attestations") + Arg::new("attestations") .long("attestations") .value_name("JSON_ATTESTATIONS") - .takes_value(true) + .action(ArgAction::Set) .required(true) - .help("List of Attestations to convert to indexed form (JSON)"), + .help("List of Attestations to convert to indexed form (JSON)") + .display_order(0) ) ) .subcommand( - SubCommand::with_name("block-root") + Command::new("block-root") .about("Computes the block root of some block.") .arg( - Arg::with_name("block-path") + Arg::new("block-path") .long("block-path") .value_name("PATH") - .takes_value(true) + .action(ArgAction::Set) .conflicts_with("beacon-url") - .help("Path to load a SignedBeaconBlock from as SSZ."), + .help("Path to load a SignedBeaconBlock from as SSZ.") + .display_order(0) ) .arg( - Arg::with_name("beacon-url") + Arg::new("beacon-url") .long("beacon-url") .value_name("URL") - .takes_value(true) - .help("URL to a beacon-API provider."), + .action(ArgAction::Set) + .help("URL to a beacon-API provider.") + .display_order(0) ) .arg( - Arg::with_name("block-id") + Arg::new("block-id") .long("block-id") .value_name("BLOCK_ID") - .takes_value(true) + .action(ArgAction::Set) .requires("beacon-url") - .help("Identifier for a block as per beacon-API standards (slot, root, etc.)"), + .help("Identifier for a block as per beacon-API standards (slot, root, etc.)") + .display_order(0) ) .arg( - Arg::with_name("runs") + Arg::new("runs") .long("runs") .value_name("INTEGER") - .takes_value(true) + .action(ArgAction::Set) .default_value("1") - .help("Number of repeat runs, useful for benchmarking."), + .help("Number of repeat runs, useful for benchmarking.") + .display_order(0) ) ) .subcommand( - SubCommand::with_name("state-root") + Command::new("state-root") .about("Computes the state root of some state.") .arg( - Arg::with_name("state-path") + Arg::new("state-path") .long("state-path") .value_name("PATH") - .takes_value(true) + .action(ArgAction::Set) .conflicts_with("beacon-url") - .help("Path to load a BeaconState from as SSZ."), + .help("Path to load a BeaconState from as SSZ.") + .display_order(0) ) .arg( - Arg::with_name("beacon-url") + Arg::new("beacon-url") .long("beacon-url") .value_name("URL") - .takes_value(true) - .help("URL to a beacon-API provider."), + .action(ArgAction::Set) + .help("URL to a beacon-API provider.") + .display_order(0) ) .arg( - Arg::with_name("state-id") + Arg::new("state-id") .long("state-id") .value_name("BLOCK_ID") - .takes_value(true) + .action(ArgAction::Set) .requires("beacon-url") - .help("Identifier for a state as per beacon-API standards (slot, root, etc.)"), + .help("Identifier for a state as per beacon-API standards (slot, root, etc.)") + .display_order(0) ) .arg( - Arg::with_name("runs") + Arg::new("runs") .long("runs") .value_name("INTEGER") - .takes_value(true) + .action(ArgAction::Set) .default_value("1") - .help("Number of repeat runs, useful for benchmarking."), + .help("Number of repeat runs, useful for benchmarking.") + .display_order(0) ) ) .subcommand( - SubCommand::with_name("mock-el") + Command::new("mock-el") .about("Creates a mock execution layer server. This is NOT SAFE and should only \ be used for testing and development on testnets. Do not use in production. Do not \ use on mainnet. It cannot perform validator duties.") .arg( - Arg::with_name("jwt-output-path") + Arg::new("jwt-output-path") .long("jwt-output-path") .value_name("PATH") - .takes_value(true) + .action(ArgAction::Set) .required(true) - .help("Path to write the JWT secret."), + .help("Path to write the JWT secret.") + .display_order(0) ) .arg( - Arg::with_name("listen-address") + Arg::new("listen-address") .long("listen-address") .value_name("IP_ADDRESS") - .takes_value(true) + .action(ArgAction::Set) .help("The server will listen on this address.") .default_value("127.0.0.1") + .display_order(0) ) .arg( - Arg::with_name("listen-port") + Arg::new("listen-port") .long("listen-port") .value_name("PORT") - .takes_value(true) + .action(ArgAction::Set) .help("The server will listen on this port.") .default_value("8551") + .display_order(0) ) .arg( - Arg::with_name("all-payloads-valid") + Arg::new("all-payloads-valid") .long("all-payloads-valid") - .takes_value(true) + .action(ArgAction::Set) .help("Controls the response to newPayload and forkchoiceUpdated. \ Set to 'true' to return VALID. Set to 'false' to return SYNCING.") .default_value("false") - .hidden(true) + .hide(true) + .display_order(0) ) .arg( - Arg::with_name("shanghai-time") + Arg::new("shanghai-time") .long("shanghai-time") .value_name("UNIX_TIMESTAMP") - .takes_value(true) + .action(ArgAction::Set) .help("The payload timestamp that enables Shanghai. Defaults to the mainnet value.") .default_value("1681338479") + .display_order(0) ) .arg( - Arg::with_name("cancun-time") + Arg::new("cancun-time") .long("cancun-time") .value_name("UNIX_TIMESTAMP") - .takes_value(true) + .action(ArgAction::Set) .help("The payload timestamp that enables Cancun. No default is provided \ until Cancun is triggered on mainnet.") + .display_order(0) ) .arg( - Arg::with_name("prague-time") + Arg::new("prague-time") .long("prague-time") .value_name("UNIX_TIMESTAMP") - .takes_value(true) + .action(ArgAction::Set) .help("The payload timestamp that enables Prague. No default is provided \ until Prague is triggered on mainnet.") + .display_order(0) ) ) .get_matches(); let result = matches - .value_of("spec") + .get_one::("spec") .ok_or_else(|| "Missing --spec flag".to_string()) - .and_then(FromStr::from_str) + .and_then(|s| FromStr::from_str(s)) .and_then(|eth_spec_id| match eth_spec_id { EthSpecId::Minimal => run(EnvironmentBuilder::minimal(), &matches), EthSpecId::Mainnet => run(EnvironmentBuilder::mainnet(), &matches), @@ -985,10 +1096,7 @@ fn main() { } } -fn run( - env_builder: EnvironmentBuilder, - matches: &ArgMatches<'_>, -) -> Result<(), String> { +fn run(env_builder: EnvironmentBuilder, matches: &ArgMatches) -> Result<(), String> { let env = env_builder .multi_threaded_tokio_runtime() .map_err(|e| format!("should start tokio runtime: {:?}", e))? @@ -1039,74 +1147,75 @@ fn run( }; match matches.subcommand() { - ("transition-blocks", Some(matches)) => { + Some(("transition-blocks", matches)) => { let network_config = get_network_config()?; transition_blocks::run::(env, network_config, matches) .map_err(|e| format!("Failed to transition blocks: {}", e)) } - ("skip-slots", Some(matches)) => { + Some(("skip-slots", matches)) => { let network_config = get_network_config()?; skip_slots::run::(env, network_config, matches) .map_err(|e| format!("Failed to skip slots: {}", e)) } - ("pretty-ssz", Some(matches)) => { + Some(("pretty-ssz", matches)) => { let network_config = get_network_config()?; run_parse_ssz::(network_config, matches) .map_err(|e| format!("Failed to pretty print hex: {}", e)) } - ("deploy-deposit-contract", Some(matches)) => { + Some(("deploy-deposit-contract", matches)) => { deploy_deposit_contract::run::(env, matches) .map_err(|e| format!("Failed to run deploy-deposit-contract command: {}", e)) } - ("eth1-genesis", Some(matches)) => { + Some(("eth1-genesis", matches)) => { let testnet_dir = get_testnet_dir()?; eth1_genesis::run::(env, testnet_dir, matches) .map_err(|e| format!("Failed to run eth1-genesis command: {}", e)) } - ("interop-genesis", Some(matches)) => { + Some(("interop-genesis", matches)) => { let testnet_dir = get_testnet_dir()?; interop_genesis::run::(testnet_dir, matches) .map_err(|e| format!("Failed to run interop-genesis command: {}", e)) } - ("change-genesis-time", Some(matches)) => { + Some(("change-genesis-time", matches)) => { let testnet_dir = get_testnet_dir()?; change_genesis_time::run::(testnet_dir, matches) .map_err(|e| format!("Failed to run change-genesis-time command: {}", e)) } - ("create-payload-header", Some(matches)) => create_payload_header::run::(matches) + Some(("create-payload-header", matches)) => create_payload_header::run::(matches) .map_err(|e| format!("Failed to run create-payload-header command: {}", e)), - ("replace-state-pubkeys", Some(matches)) => { + Some(("replace-state-pubkeys", matches)) => { let testnet_dir = get_testnet_dir()?; replace_state_pubkeys::run::(testnet_dir, matches) .map_err(|e| format!("Failed to run replace-state-pubkeys command: {}", e)) } - ("new-testnet", Some(matches)) => { + Some(("new-testnet", matches)) => { let testnet_dir = get_testnet_dir()?; new_testnet::run::(testnet_dir, matches) .map_err(|e| format!("Failed to run new_testnet command: {}", e)) } - ("check-deposit-data", Some(matches)) => check_deposit_data::run(matches) + Some(("check-deposit-data", matches)) => check_deposit_data::run(matches) .map_err(|e| format!("Failed to run check-deposit-data command: {}", e)), - ("generate-bootnode-enr", Some(matches)) => generate_bootnode_enr::run::(matches) + Some(("generate-bootnode-enr", matches)) => generate_bootnode_enr::run::(matches) .map_err(|e| format!("Failed to run generate-bootnode-enr command: {}", e)), - ("insecure-validators", Some(matches)) => insecure_validators::run(matches) + Some(("insecure-validators", matches)) => insecure_validators::run(matches) .map_err(|e| format!("Failed to run insecure-validators command: {}", e)), - ("mnemonic-validators", Some(matches)) => mnemonic_validators::run(matches) + Some(("mnemonic-validators", matches)) => mnemonic_validators::run(matches) .map_err(|e| format!("Failed to run mnemonic-validators command: {}", e)), - ("indexed-attestations", Some(matches)) => indexed_attestations::run::(matches) + Some(("indexed-attestations", matches)) => indexed_attestations::run::(matches) .map_err(|e| format!("Failed to run indexed-attestations command: {}", e)), - ("block-root", Some(matches)) => { + Some(("block-root", matches)) => { let network_config = get_network_config()?; block_root::run::(env, network_config, matches) .map_err(|e| format!("Failed to run block-root command: {}", e)) } - ("state-root", Some(matches)) => { + Some(("state-root", matches)) => { let network_config = get_network_config()?; state_root::run::(env, network_config, matches) .map_err(|e| format!("Failed to run state-root command: {}", e)) } - ("mock-el", Some(matches)) => mock_el::run::(env, matches) + Some(("mock-el", matches)) => mock_el::run::(env, matches) .map_err(|e| format!("Failed to run mock-el command: {}", e)), - (other, _) => Err(format!("Unknown subcommand {}. See --help.", other)), + Some((other, _)) => Err(format!("Unknown subcommand {}. See --help.", other)), + _ => Err("No subcommand provided. See --help.".to_string()), } } diff --git a/lcli/src/new_testnet.rs b/lcli/src/new_testnet.rs index f6bfb2ac013..57b11999174 100644 --- a/lcli/src/new_testnet.rs +++ b/lcli/src/new_testnet.rs @@ -30,7 +30,7 @@ pub fn run(testnet_dir_path: PathBuf, matches: &ArgMatches) -> Resul let deposit_contract_address: Address = parse_required(matches, "deposit-contract-address")?; let deposit_contract_deploy_block = parse_required(matches, "deposit-contract-deploy-block")?; - let overwrite_files = matches.is_present("force"); + let overwrite_files = matches.get_flag("force"); if testnet_dir_path.exists() && !overwrite_files { return Err(format!( @@ -154,7 +154,7 @@ pub fn run(testnet_dir_path: PathBuf, matches: &ArgMatches) -> Resul (eth1_block_hash, genesis_time) }; - let genesis_state_bytes = if matches.is_present("interop-genesis-state") { + let genesis_state_bytes = if matches.get_flag("interop-genesis-state") { let keypairs = generate_deterministic_keypairs(validator_count); let keypairs: Vec<_> = keypairs.into_iter().map(|kp| (kp.clone(), kp)).collect(); @@ -167,7 +167,7 @@ pub fn run(testnet_dir_path: PathBuf, matches: &ArgMatches) -> Resul )?; Some(genesis_state.as_ssz_bytes()) - } else if matches.is_present("derived-genesis-state") { + } else if matches.get_flag("derived-genesis-state") { let mnemonic_phrase: String = clap_utils::parse_required(matches, "mnemonic-phrase")?; let mnemonic = Mnemonic::from_phrase(&mnemonic_phrase, Language::English).map_err(|e| { format!( diff --git a/lcli/src/parse_ssz.rs b/lcli/src/parse_ssz.rs index e86ffb73dc2..3aa77e57003 100644 --- a/lcli/src/parse_ssz.rs +++ b/lcli/src/parse_ssz.rs @@ -31,8 +31,12 @@ pub fn run_parse_ssz( network_config: Eth2NetworkConfig, matches: &ArgMatches, ) -> Result<(), String> { - let type_str = matches.value_of("type").ok_or("No type supplied")?; - let filename = matches.value_of("ssz-file").ok_or("No file supplied")?; + let type_str = matches + .get_one::("type") + .ok_or("No type supplied")?; + let filename = matches + .get_one::("ssz-file") + .ok_or("No file supplied")?; let format = parse_required(matches, "format")?; let bytes = if filename.ends_with("ssz_snappy") { @@ -58,7 +62,7 @@ pub fn run_parse_ssz( // More fork-specific decoders may need to be added in future, but shouldn't be 100% necessary, // as the fork-generic decoder will always be available (requires correct --network flag). - match type_str { + match type_str.as_str() { "SignedBeaconBlock" => decode_and_print::>( &bytes, |bytes| SignedBeaconBlock::from_ssz_bytes(bytes, spec), diff --git a/lcli/src/replace_state_pubkeys.rs b/lcli/src/replace_state_pubkeys.rs index e8d012b16ec..4b8d6c8253d 100644 --- a/lcli/src/replace_state_pubkeys.rs +++ b/lcli/src/replace_state_pubkeys.rs @@ -13,13 +13,13 @@ use types::{BeaconState, DepositData, EthSpec, Hash256, SignatureBytes, DEPOSIT_ pub fn run(testnet_dir: PathBuf, matches: &ArgMatches) -> Result<(), String> { let path = matches - .value_of("ssz-state") + .get_one::("ssz-state") .ok_or("ssz-state not specified")? .parse::() .map_err(|e| format!("Unable to parse ssz-state: {}", e))?; let mnemonic_phrase = matches - .value_of("mnemonic") + .get_one::("mnemonic") .ok_or("mnemonic not specified")?; let eth2_network_config = Eth2NetworkConfig::load(testnet_dir)?; diff --git a/lcli/src/skip_slots.rs b/lcli/src/skip_slots.rs index d421c077d83..a2173f10df0 100644 --- a/lcli/src/skip_slots.rs +++ b/lcli/src/skip_slots.rs @@ -75,7 +75,7 @@ pub fn run( let runs: usize = parse_required(matches, "runs")?; let slots: u64 = parse_required(matches, "slots")?; let cli_state_root: Option = parse_optional(matches, "state-root")?; - let partial: bool = matches.is_present("partial-state-advance"); + let partial: bool = matches.get_flag("partial-state-advance"); info!("Using {} spec", E::spec_name()); info!("Advancing {} slots", slots); diff --git a/lcli/src/transition_blocks.rs b/lcli/src/transition_blocks.rs index 77fd352829f..ba0c2efa512 100644 --- a/lcli/src/transition_blocks.rs +++ b/lcli/src/transition_blocks.rs @@ -117,9 +117,9 @@ pub fn run( let beacon_url: Option = parse_optional(matches, "beacon-url")?; let runs: usize = parse_required(matches, "runs")?; let config = Config { - no_signature_verification: matches.is_present("no-signature-verification"), - exclude_cache_builds: matches.is_present("exclude-cache-builds"), - exclude_post_block_thc: matches.is_present("exclude-post-block-thc"), + no_signature_verification: matches.get_flag("no-signature-verification"), + exclude_cache_builds: matches.get_flag("exclude-cache-builds"), + exclude_post_block_thc: matches.get_flag("exclude-post-block-thc"), }; info!("Using {} spec", E::spec_name()); diff --git a/lighthouse/src/main.rs b/lighthouse/src/main.rs index 932b125dc69..5743bedfd70 100644 --- a/lighthouse/src/main.rs +++ b/lighthouse/src/main.rs @@ -1,13 +1,16 @@ mod metrics; use beacon_node::ProductionBeaconNode; -use clap::{App, Arg, ArgMatches}; -use clap_utils::{flags::DISABLE_MALLOC_TUNING_FLAG, get_eth2_network_config}; +use clap::{Arg, ArgAction, ArgMatches, Command}; +use clap_utils::{ + flags::DISABLE_MALLOC_TUNING_FLAG, get_color_style, get_eth2_network_config, FLAG_HEADER, +}; use directory::{parse_path_or_default, DEFAULT_BEACON_NODE_DIR, DEFAULT_VALIDATOR_DIR}; use environment::{EnvironmentBuilder, LoggerConfig}; use eth2_network_config::{Eth2NetworkConfig, DEFAULT_HARDCODED_NETWORK, HARDCODED_NET_NAMES}; use ethereum_hashing::have_sha_extensions; use futures::TryFutureExt; +use lazy_static::lazy_static; use lighthouse_version::VERSION; use malloc_utils::configure_memory_allocator; use slog::{crit, info}; @@ -18,6 +21,25 @@ use task_executor::ShutdownReason; use types::{EthSpec, EthSpecId}; use validator_client::ProductionValidatorClient; +lazy_static! { + pub static ref SHORT_VERSION: String = VERSION.replace("Lighthouse/", ""); + pub static ref LONG_VERSION: String = format!( + "{}\n\ + BLS library: {}\n\ + SHA256 hardware acceleration: {}\n\ + Allocator: {}\n\ + Profile: {}\n\ + Specs: mainnet (true), minimal ({}), gnosis ({})", + SHORT_VERSION.as_str(), + bls_library_name(), + have_sha_extensions(), + allocator_name(), + build_profile_name(), + cfg!(feature = "spec-minimal"), + cfg!(feature = "gnosis"), + ); +} + fn bls_library_name() -> &'static str { if cfg!(feature = "portable") { "blst-portable" @@ -54,41 +76,31 @@ fn main() { } // Parse the CLI parameters. - let matches = App::new("Lighthouse") - .version(VERSION.replace("Lighthouse/", "").as_str()) + let matches = Command::new("Lighthouse") + .version(SHORT_VERSION.as_str()) .author("Sigma Prime ") - .setting(clap::AppSettings::ColoredHelp) + .styles(get_color_style()) + .next_line_help(true) + .term_width(80) + .disable_help_flag(true) .about( "Ethereum 2.0 client by Sigma Prime. Provides a full-featured beacon \ node, a validator client and utilities for managing validator accounts.", ) - .long_version( - format!( - "{}\n\ - BLS library: {}\n\ - SHA256 hardware acceleration: {}\n\ - Allocator: {}\n\ - Profile: {}\n\ - Specs: mainnet (true), minimal ({}), gnosis ({})", - VERSION.replace("Lighthouse/", ""), - bls_library_name(), - have_sha_extensions(), - allocator_name(), - build_profile_name(), - cfg!(feature = "spec-minimal"), - cfg!(feature = "gnosis"), - ).as_str() - ) + .long_version(LONG_VERSION.as_str()) + .display_order(0) .arg( - Arg::with_name("env_log") - .short("l") + Arg::new("env_log") + .short('l') .help( "DEPRECATED Enables environment logging giving access to sub-protocol logs such as discv5 and libp2p", ) - .takes_value(false), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("logfile") + Arg::new("logfile") .long("logfile") .value_name("FILE") .help( @@ -97,115 +109,135 @@ fn main() { future logs are stored. \ Once the number of log files exceeds the value specified in \ `--logfile-max-number` the oldest log file will be overwritten.") - .takes_value(true) - .global(true), + .action(ArgAction::Set) + .global(true) + .display_order(0) ) .arg( - Arg::with_name("logfile-debug-level") + Arg::new("logfile-debug-level") .long("logfile-debug-level") .value_name("LEVEL") .help("The verbosity level used when emitting logs to the log file.") - .takes_value(true) - .possible_values(&["info", "debug", "trace", "warn", "error", "crit"]) + .action(ArgAction::Set) + .value_parser(["info", "debug", "trace", "warn", "error", "crit"]) .default_value("debug") - .global(true), + .global(true) + .display_order(0) ) .arg( - Arg::with_name("logfile-format") + Arg::new("logfile-format") .long("logfile-format") .value_name("FORMAT") .help("Specifies the log format used when emitting logs to the logfile.") - .possible_values(&["DEFAULT", "JSON"]) - .takes_value(true) + .value_parser(["DEFAULT", "JSON"]) + .action(ArgAction::Set) .global(true) + .display_order(0) ) .arg( - Arg::with_name("logfile-max-size") + Arg::new("logfile-max-size") .long("logfile-max-size") .value_name("SIZE") .help( "The maximum size (in MB) each log file can grow to before rotating. If set \ to 0, background file logging is disabled.") - .takes_value(true) + .action(ArgAction::Set) .default_value("200") - .global(true), + .global(true) + .display_order(0) ) .arg( - Arg::with_name("logfile-max-number") + Arg::new("logfile-max-number") .long("logfile-max-number") .value_name("COUNT") .help( "The maximum number of log files that will be stored. If set to 0, \ background file logging is disabled.") - .takes_value(true) + .action(ArgAction::Set) .default_value("5") - .global(true), + .global(true) + .display_order(0) ) .arg( - Arg::with_name("logfile-compress") + Arg::new("logfile-compress") .long("logfile-compress") + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .help( "If present, compress old log files. This can help reduce the space needed \ to store old logs.") - .global(true), + .global(true) + .display_order(0) ) .arg( - Arg::with_name("logfile-no-restricted-perms") + Arg::new("logfile-no-restricted-perms") .long("logfile-no-restricted-perms") + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .help( "If present, log files will be generated as world-readable meaning they can be read by \ any user on the machine. Note that logs can often contain sensitive information \ about your validator and so this flag should be used with caution. For Windows users, \ the log file permissions will be inherited from the parent folder.") - .global(true), + .global(true) + .display_order(0) ) .arg( - Arg::with_name("log-format") + Arg::new("log-format") .long("log-format") .value_name("FORMAT") .help("Specifies the log format used when emitting logs to the terminal.") - .possible_values(&["JSON"]) - .takes_value(true) - .global(true), + .value_parser(["JSON"]) + .action(ArgAction::Set) + .global(true) + .display_order(0) ) .arg( - Arg::with_name("log-color") + Arg::new("log-color") .long("log-color") .alias("log-colour") .help("Force outputting colors when emitting logs to the terminal.") - .global(true), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .global(true) + .display_order(0) ) .arg( - Arg::with_name("disable-log-timestamp") + Arg::new("disable-log-timestamp") .long("disable-log-timestamp") + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .help("If present, do not include timestamps in logging output.") - .global(true), + .global(true) + .display_order(0) ) .arg( - Arg::with_name("debug-level") + Arg::new("debug-level") .long("debug-level") .value_name("LEVEL") .help("Specifies the verbosity level used when emitting logs to the terminal.") - .takes_value(true) - .possible_values(&["info", "debug", "trace", "warn", "error", "crit"]) + .action(ArgAction::Set) + .value_parser(["info", "debug", "trace", "warn", "error", "crit"]) .global(true) - .default_value("info"), + .default_value("info") + .display_order(0) ) .arg( - Arg::with_name("datadir") + Arg::new("datadir") .long("datadir") - .short("d") + .short('d') .value_name("DIR") .global(true) .help( "Used to specify a custom root data directory for lighthouse keys and databases. \ Defaults to $HOME/.lighthouse/{network} where network is the value of the `network` flag \ Note: Users should specify separate custom datadirs for different networks.") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("testnet-dir") - .short("t") + Arg::new("testnet-dir") + .short('t') .long("testnet-dir") .value_name("DIR") .help( @@ -213,57 +245,66 @@ fn main() { a hard-coded Lighthouse testnet. Only effective if there is no \ existing database.", ) - .takes_value(true) - .global(true), + .action(ArgAction::Set) + .global(true) + .display_order(0) ) .arg( - Arg::with_name("network") + Arg::new("network") .long("network") .value_name("network") .help("Name of the Eth2 chain Lighthouse will sync and follow.") - .possible_values(HARDCODED_NET_NAMES) + .value_parser(HARDCODED_NET_NAMES.to_vec()) .conflicts_with("testnet-dir") - .takes_value(true) + .action(ArgAction::Set) .global(true) - + .display_order(0) ) .arg( - Arg::with_name("dump-config") + Arg::new("dump-config") .long("dump-config") - .hidden(true) + .hide(true) .help("Dumps the config to a desired location. Used for testing only.") - .takes_value(true) + .action(ArgAction::Set) .global(true) + .display_order(0) ) .arg( - Arg::with_name("dump-chain-config") + Arg::new("dump-chain-config") .long("dump-chain-config") - .hidden(true) + .hide(true) .help("Dumps the chain config to a desired location. Used for testing only.") - .takes_value(true) + .action(ArgAction::Set) .global(true) + .display_order(0) ) .arg( - Arg::with_name("immediate-shutdown") + Arg::new("immediate-shutdown") .long("immediate-shutdown") - .hidden(true) + .hide(true) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .help( "Shuts down immediately after the Beacon Node or Validator has successfully launched. \ Used for testing only, DO NOT USE IN PRODUCTION.") .global(true) + .display_order(0) ) .arg( - Arg::with_name(DISABLE_MALLOC_TUNING_FLAG) + Arg::new(DISABLE_MALLOC_TUNING_FLAG) .long(DISABLE_MALLOC_TUNING_FLAG) .help( "If present, do not configure the system allocator. Providing this flag will \ generally increase memory usage, it should only be provided when debugging \ specific memory allocation issues." ) - .global(true), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .global(true) + .display_order(0) ) .arg( - Arg::with_name("terminal-total-difficulty-override") + Arg::new("terminal-total-difficulty-override") .long("terminal-total-difficulty-override") .value_name("INTEGER") .help("Used to coordinate manual overrides to the TERMINAL_TOTAL_DIFFICULTY parameter. \ @@ -272,11 +313,12 @@ fn main() { the broad Ethereum community has elected to override the terminal difficulty. \ Incorrect use of this flag will cause your node to experience a consensus \ failure. Be extremely careful with this flag.") - .takes_value(true) + .action(ArgAction::Set) .global(true) + .display_order(0) ) .arg( - Arg::with_name("terminal-block-hash-override") + Arg::new("terminal-block-hash-override") .long("terminal-block-hash-override") .value_name("TERMINAL_BLOCK_HASH") .help("Used to coordinate manual overrides to the TERMINAL_BLOCK_HASH parameter. \ @@ -285,11 +327,12 @@ fn main() { Incorrect use of this flag will cause your node to experience a consensus \ failure. Be extremely careful with this flag.") .requires("terminal-block-hash-epoch-override") - .takes_value(true) + .action(ArgAction::Set) .global(true) + .display_order(0) ) .arg( - Arg::with_name("terminal-block-hash-epoch-override") + Arg::new("terminal-block-hash-epoch-override") .long("terminal-block-hash-epoch-override") .value_name("EPOCH") .help("Used to coordinate manual overrides to the TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH \ @@ -298,11 +341,12 @@ fn main() { Incorrect use of this flag will cause your node to experience a consensus \ failure. Be extremely careful with this flag.") .requires("terminal-block-hash-override") - .takes_value(true) + .action(ArgAction::Set) .global(true) + .display_order(0) ) .arg( - Arg::with_name("safe-slots-to-import-optimistically") + Arg::new("safe-slots-to-import-optimistically") .long("safe-slots-to-import-optimistically") .value_name("INTEGER") .help("Used to coordinate manual overrides of the SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY \ @@ -311,11 +355,12 @@ fn main() { of an attack at the PoS transition block. Incorrect use of this flag can cause your \ node to possibly accept an invalid chain or sync more slowly. Be extremely careful with \ this flag.") - .takes_value(true) + .action(ArgAction::Set) .global(true) + .display_order(0) ) .arg( - Arg::with_name("genesis-state-url") + Arg::new("genesis-state-url") .long("genesis-state-url") .value_name("URL") .help( @@ -324,19 +369,30 @@ fn main() { If not supplied, a default URL or the --checkpoint-sync-url may be used. \ If the genesis state is already included in this binary then this value will be ignored.", ) - .takes_value(true) - .global(true), + .action(ArgAction::Set) + .global(true) + .display_order(0) ) .arg( - Arg::with_name("genesis-state-url-timeout") + Arg::new("genesis-state-url-timeout") .long("genesis-state-url-timeout") .value_name("SECONDS") .help( "The timeout in seconds for the request to --genesis-state-url.", ) - .takes_value(true) + .action(ArgAction::Set) .default_value("180") - .global(true), + .global(true) + .display_order(0) + ) + .arg( + Arg::new("help") + .long("help") + .short('h') + .help("Prints help information") + .action(ArgAction::HelpLong) + .display_order(0) + .help_heading(FLAG_HEADER) ) .subcommand(beacon_node::cli_app()) .subcommand(boot_node::cli_app()) @@ -352,7 +408,7 @@ fn main() { // Only apply this optimization for the beacon node. It's the only process with a substantial // memory footprint. let is_beacon_node = matches.subcommand_name() == Some("beacon_node"); - if is_beacon_node && !matches.is_present(DISABLE_MALLOC_TUNING_FLAG) { + if is_beacon_node && !matches.get_flag(DISABLE_MALLOC_TUNING_FLAG) { if let Err(e) = configure_memory_allocator() { eprintln!( "Unable to configure the memory allocator: {} \n\ @@ -370,7 +426,7 @@ fn main() { if let Some(bootnode_matches) = matches.subcommand_matches("boot_node") { // The bootnode uses the main debug-level flag let debug_info = matches - .value_of("debug-level") + .get_one::("debug-level") .expect("Debug-level must be present") .into(); @@ -430,53 +486,53 @@ fn run( } let debug_level = matches - .value_of("debug-level") + .get_one::("debug-level") .ok_or("Expected --debug-level flag")?; - let log_format = matches.value_of("log-format"); + let log_format = matches.get_one::("log-format"); - let log_color = matches.is_present("log-color"); + let log_color = matches.get_flag("log-color"); - let disable_log_timestamp = matches.is_present("disable-log-timestamp"); + let disable_log_timestamp = matches.get_flag("disable-log-timestamp"); let logfile_debug_level = matches - .value_of("logfile-debug-level") + .get_one::("logfile-debug-level") .ok_or("Expected --logfile-debug-level flag")?; let logfile_format = matches - .value_of("logfile-format") + .get_one::("logfile-format") // Ensure that `logfile-format` defaults to the value of `log-format`. - .or_else(|| matches.value_of("log-format")); + .or_else(|| matches.get_one::("log-format")); let logfile_max_size: u64 = matches - .value_of("logfile-max-size") + .get_one::("logfile-max-size") .ok_or("Expected --logfile-max-size flag")? .parse() .map_err(|e| format!("Failed to parse `logfile-max-size`: {:?}", e))?; let logfile_max_number: usize = matches - .value_of("logfile-max-number") + .get_one::("logfile-max-number") .ok_or("Expected --logfile-max-number flag")? .parse() .map_err(|e| format!("Failed to parse `logfile-max-number`: {:?}", e))?; - let logfile_compress = matches.is_present("logfile-compress"); + let logfile_compress = matches.get_flag("logfile-compress"); - let logfile_restricted = !matches.is_present("logfile-no-restricted-perms"); + let logfile_restricted = !matches.get_flag("logfile-no-restricted-perms"); // Construct the path to the log file. let mut log_path: Option = clap_utils::parse_optional(matches, "logfile")?; if log_path.is_none() { log_path = match matches.subcommand() { - ("beacon_node", _) => Some( + Some(("beacon_node", _)) => Some( parse_path_or_default(matches, "datadir")? .join(DEFAULT_BEACON_NODE_DIR) .join("logs") .join("beacon") .with_extension("log"), ), - ("validator_client", Some(vc_matches)) => { - let base_path = if vc_matches.is_present("validators-dir") { + Some(("validator_client", vc_matches)) => { + let base_path = if vc_matches.contains_id("validators-dir") { parse_path_or_default(vc_matches, "validators-dir")? } else { parse_path_or_default(matches, "datadir")?.join(DEFAULT_VALIDATOR_DIR) @@ -495,9 +551,9 @@ fn run( let sse_logging = { if let Some(bn_matches) = matches.subcommand_matches("beacon_node") { - bn_matches.is_present("gui") + bn_matches.get_flag("gui") } else if let Some(vc_matches) = matches.subcommand_matches("validator_client") { - vc_matches.is_present("http") + vc_matches.get_flag("http") } else { false } @@ -626,13 +682,13 @@ fn run( ); match matches.subcommand() { - ("beacon_node", Some(matches)) => { + Some(("beacon_node", matches)) => { let context = environment.core_context(); let log = context.log().clone(); let executor = context.executor.clone(); let mut config = beacon_node::get_config::(matches, &context)?; config.logger_config = logger_config; - let shutdown_flag = matches.is_present("immediate-shutdown"); + let shutdown_flag = matches.get_flag("immediate-shutdown"); // Dump configs if `dump-config` or `dump-chain-config` flags are set clap_utils::check_dump_configs::<_, E>(matches, &config, &context.eth2_config.spec)?; executor.clone().spawn( @@ -653,13 +709,13 @@ fn run( "beacon_node", ); } - ("validator_client", Some(matches)) => { + Some(("validator_client", matches)) => { let context = environment.core_context(); let log = context.log().clone(); let executor = context.executor.clone(); let config = validator_client::Config::from_cli(matches, context.log()) .map_err(|e| format!("Unable to initialize validator config: {}", e))?; - let shutdown_flag = matches.is_present("immediate-shutdown"); + let shutdown_flag = matches.get_flag("immediate-shutdown"); // Dump configs if `dump-config` or `dump-chain-config` flags are set clap_utils::check_dump_configs::<_, E>(matches, &config, &context.eth2_config.spec)?; if !shutdown_flag { diff --git a/lighthouse/tests/beacon_node.rs b/lighthouse/tests/beacon_node.rs index 62bb067273e..245588b4d2b 100644 --- a/lighthouse/tests/beacon_node.rs +++ b/lighthouse/tests/beacon_node.rs @@ -1578,7 +1578,7 @@ fn empty_inbound_rate_limiter_flag() { #[test] fn disable_inbound_rate_limiter_flag() { CommandLineTest::new() - .flag("inbound-rate-limiter", Some("disabled")) + .flag("disable-inbound-rate-limiter", None) .run_with_zero_port() .with_config(|config| assert_eq!(config.network.inbound_rate_limiter_config, None)); } @@ -2134,7 +2134,6 @@ fn slasher_broadcast_flag_no_args() { CommandLineTest::new() .flag("slasher", None) .flag("slasher-max-db-size", Some("1")) - .flag("slasher-broadcast", None) .run_with_zero_port() .with_config(|config| { let slasher_config = config @@ -2313,7 +2312,7 @@ fn proposer_re_org_disallowed_offsets_default() { #[test] fn proposer_re_org_disallowed_offsets_override() { CommandLineTest::new() - .flag("--proposer-reorg-disallowed-offsets", Some("1,2,3")) + .flag("proposer-reorg-disallowed-offsets", Some("1,2,3")) .run_with_zero_port() .with_config(|config| { assert_eq!( @@ -2327,7 +2326,7 @@ fn proposer_re_org_disallowed_offsets_override() { #[should_panic] fn proposer_re_org_disallowed_offsets_invalid() { CommandLineTest::new() - .flag("--proposer-reorg-disallowed-offsets", Some("32,33,34")) + .flag("proposer-reorg-disallowed-offsets", Some("32,33,34")) .run_with_zero_port(); } diff --git a/lighthouse/tests/validator_client.rs b/lighthouse/tests/validator_client.rs index cdf8fa15aaa..9ca6ab43332 100644 --- a/lighthouse/tests/validator_client.rs +++ b/lighthouse/tests/validator_client.rs @@ -594,23 +594,8 @@ fn wrong_broadcast_flag() { #[test] fn latency_measurement_service() { - CommandLineTest::new().run().with_config(|config| { - assert!(config.enable_latency_measurement_service); - }); - CommandLineTest::new() - .flag("latency-measurement-service", None) - .run() - .with_config(|config| { - assert!(config.enable_latency_measurement_service); - }); - CommandLineTest::new() - .flag("latency-measurement-service", Some("true")) - .run() - .with_config(|config| { - assert!(config.enable_latency_measurement_service); - }); CommandLineTest::new() - .flag("latency-measurement-service", Some("false")) + .flag("disable-latency-measurement-service", None) .run() .with_config(|config| { assert!(!config.enable_latency_measurement_service); diff --git a/lighthouse/tests/validator_manager.rs b/lighthouse/tests/validator_manager.rs index fab1cfebf4b..bca6a18ab56 100644 --- a/lighthouse/tests/validator_manager.rs +++ b/lighthouse/tests/validator_manager.rs @@ -55,7 +55,12 @@ impl CommandLineTest { } fn run(mut cmd: Command, should_succeed: bool) { - let output = cmd.output().expect("process should complete"); + let output = cmd + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .output() + .expect("process should complete"); if output.status.success() != should_succeed { let stdout = String::from_utf8(output.stdout).unwrap(); let stderr = String::from_utf8(output.stderr).unwrap(); diff --git a/scripts/cli.sh b/scripts/cli.sh index 148b23966c0..6ca019b39e9 100755 --- a/scripts/cli.sh +++ b/scripts/cli.sh @@ -12,9 +12,6 @@ write_to_file() { local file="$2" local program="$3" - # Remove first line of cmd to get rid of commit specific numbers. - cmd=${cmd#*$'\n'} - # We need to add the header and the backticks to create the code block. printf "# %s\n\n\`\`\`\n%s\n\`\`\`" "$program" "$cmd" > "$file" diff --git a/testing/simulator/src/basic_sim.rs b/testing/simulator/src/basic_sim.rs index 755bb71b430..f69d107e344 100644 --- a/testing/simulator/src/basic_sim.rs +++ b/testing/simulator/src/basic_sim.rs @@ -27,15 +27,32 @@ const SUGGESTED_FEE_RECIPIENT: [u8; 20] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]; pub fn run_basic_sim(matches: &ArgMatches) -> Result<(), String> { - let node_count = value_t!(matches, "nodes", usize).expect("Missing nodes default"); - let proposer_nodes = - value_t!(matches, "proposer-nodes", usize).expect("Missing proposer-nodes default"); - let validators_per_node = value_t!(matches, "validators-per-node", usize) - .expect("Missing validators-per-node default"); - let speed_up_factor = - value_t!(matches, "speed-up-factor", u64).expect("Missing speed-up-factor default"); - let log_level = value_t!(matches, "debug-level", String).expect("Missing default log-level"); - let continue_after_checks = matches.is_present("continue-after-checks"); + let node_count = matches + .get_one::("nodes") + .expect("missing nodes default") + .parse::() + .expect("missing nodes default"); + let proposer_nodes = matches + .get_one::("proposer-nodes") + .unwrap_or(&String::from("0")) + .parse::() + .unwrap_or(0); + println!("PROPOSER-NODES: {}", proposer_nodes); + let validators_per_node = matches + .get_one::("validators-per-node") + .expect("missing validators-per-node default") + .parse::() + .expect("missing validators-per-node default"); + let speed_up_factor = matches + .get_one::("speed-up-factor") + .expect("missing speed-up-factor default") + .parse::() + .expect("missing speed-up-factor default"); + let log_level = matches + .get_one::("debug-level") + .expect("missing debug-level"); + + let continue_after_checks = matches.get_flag("continue-after-checks"); println!("Basic Simulator:"); println!(" nodes: {}", node_count); @@ -64,7 +81,7 @@ pub fn run_basic_sim(matches: &ArgMatches) -> Result<(), String> { .initialize_logger(LoggerConfig { path: None, debug_level: log_level.clone(), - logfile_debug_level: log_level, + logfile_debug_level: log_level.clone(), log_format: None, logfile_format: None, log_color: false, diff --git a/testing/simulator/src/cli.rs b/testing/simulator/src/cli.rs index 00af7e560ce..a82c8b85775 100644 --- a/testing/simulator/src/cli.rs +++ b/testing/simulator/src/cli.rs @@ -1,12 +1,12 @@ -use clap::{App, Arg, SubCommand}; +use clap::{crate_version, Arg, ArgAction, Command}; -pub fn cli_app<'a, 'b>() -> App<'a, 'b> { - App::new("simulator") +pub fn cli_app() -> Command { + Command::new("simulator") .version(crate_version!()) .author("Sigma Prime ") .about("Options for interacting with simulator") .subcommand( - SubCommand::with_name("basic-sim") + Command::new("basic-sim") .about( "Runs a Beacon Chain simulation with `n` beacon node and validator clients, \ each with `v` validators. \ @@ -16,55 +16,55 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { exit immediately.", ) .arg( - Arg::with_name("nodes") - .short("n") + Arg::new("nodes") + .short('n') .long("nodes") - .takes_value(true) + .action(ArgAction::Set) .default_value("3") .help("Number of beacon nodes"), ) .arg( - Arg::with_name("proposer-nodes") - .short("p") + Arg::new("proposer-nodes") + .short('p') .long("proposer-nodes") - .takes_value(true) + .action(ArgAction::Set) .default_value("3") .help("Number of proposer-only beacon nodes"), ) .arg( - Arg::with_name("validators-per-node") - .short("v") + Arg::new("validators-per-node") + .short('v') .long("validators-per-node") - .takes_value(true) + .action(ArgAction::Set) .default_value("20") .help("Number of validators"), ) .arg( - Arg::with_name("speed-up-factor") - .short("s") + Arg::new("speed-up-factor") + .short('s') .long("speed-up-factor") - .takes_value(true) + .action(ArgAction::Set) .default_value("3") .help("Speed up factor. Please use a divisor of 12."), ) .arg( - Arg::with_name("debug-level") - .short("d") + Arg::new("debug-level") + .short('d') .long("debug-level") - .takes_value(true) + .action(ArgAction::Set) .default_value("debug") .help("Set the severity level of the logs."), ) .arg( - Arg::with_name("continue-after-checks") - .short("c") + Arg::new("continue-after-checks") + .short('c') .long("continue_after_checks") - .takes_value(false) + .action(ArgAction::SetTrue) .help("Continue after checks (default false)"), ), ) .subcommand( - SubCommand::with_name("fallback-sim") + Command::new("fallback-sim") .about( "Runs a Beacon Chain simulation with `c` validator clients where each VC is \ connected to `b` beacon nodes with `v` validators. \ @@ -76,50 +76,50 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { Otherwise, the simulation will exit and an error will be reported.", ) .arg( - Arg::with_name("vc-count") - .short("c") + Arg::new("vc-count") + .short('c') .long("vc-count") - .takes_value(true) + .action(ArgAction::Set) .default_value("3") .help("Number of validator clients."), ) .arg( - Arg::with_name("bns-per-vc") - .short("b") + Arg::new("bns-per-vc") + .short('b') .long("bns-per-vc") - .takes_value(true) + .action(ArgAction::Set) .default_value("2") .help("Number of beacon nodes per validator client."), ) .arg( - Arg::with_name("validators-per-vc") - .short("v") + Arg::new("validators-per-vc") + .short('v') .long("validators-per-vc") - .takes_value(true) + .action(ArgAction::Set) .default_value("20") .help("Number of validators per client."), ) .arg( - Arg::with_name("speed-up-factor") - .short("s") + Arg::new("speed-up-factor") + .short('s') .long("speed-up-factor") - .takes_value(true) + .action(ArgAction::Set) .default_value("3") .help("Speed up factor. Please use a divisor of 12."), ) .arg( - Arg::with_name("debug-level") - .short("d") + Arg::new("debug-level") + .short('d') .long("debug-level") - .takes_value(true) + .action(ArgAction::Set) .default_value("debug") .help("Set the severity level of the logs."), ) .arg( - Arg::with_name("continue-after-checks") - .short("c") + Arg::new("continue-after-checks") + .short('c') .long("continue_after_checks") - .takes_value(false) + .action(ArgAction::SetTrue) .help("Continue after checks (default false)"), ), ) diff --git a/testing/simulator/src/fallback_sim.rs b/testing/simulator/src/fallback_sim.rs index c9deeba04d9..33f497f37ff 100644 --- a/testing/simulator/src/fallback_sim.rs +++ b/testing/simulator/src/fallback_sim.rs @@ -34,15 +34,36 @@ const SUGGESTED_FEE_RECIPIENT: [u8; 20] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]; pub fn run_fallback_sim(matches: &ArgMatches) -> Result<(), String> { - let vc_count = value_t!(matches, "vc-count", usize).expect("Missing validator-count default"); - let validators_per_vc = - value_t!(matches, "validators-per-vc", usize).expect("Missing validators-per-vc default"); - let bns_per_vc = value_t!(matches, "bns-per-vc", usize).expect("Missing bns-per-vc default"); + let vc_count = matches + .get_one::("vc-count") + .expect("missing vc-count default") + .parse::() + .expect("missing vc-count default"); + + let validators_per_vc = matches + .get_one::("validators-per-vc") + .expect("missing validators-per-vc default") + .parse::() + .expect("missing validators-per-vc default"); + + let bns_per_vc = matches + .get_one::("bns-per-vc") + .expect("missing bns-per-vc default") + .parse::() + .expect("missing bns-per-vc default"); + assert!(bns_per_vc > 1); - let speed_up_factor = - value_t!(matches, "speed-up-factor", u64).expect("Missing speed-up-factor default"); - let log_level = value_t!(matches, "debug-level", String).expect("Missing default log-level"); - let continue_after_checks = matches.is_present("continue-after-checks"); + let speed_up_factor = matches + .get_one::("speed-up-factor") + .expect("missing speed-up-factor default") + .parse::() + .expect("missing speed-up-factor default"); + + let log_level = matches + .get_one::("debug-level") + .expect("missing debug-level default"); + + let continue_after_checks = matches.get_flag("continue-after-checks"); println!("Fallback Simulator:"); println!(" vc-count: {}", vc_count); @@ -70,7 +91,7 @@ pub fn run_fallback_sim(matches: &ArgMatches) -> Result<(), String> { .initialize_logger(LoggerConfig { path: None, debug_level: log_level.clone(), - logfile_debug_level: log_level, + logfile_debug_level: log_level.clone(), log_format: None, logfile_format: None, log_color: false, diff --git a/testing/simulator/src/main.rs b/testing/simulator/src/main.rs index d1a2d0dc672..03ee902c770 100644 --- a/testing/simulator/src/main.rs +++ b/testing/simulator/src/main.rs @@ -11,7 +11,6 @@ //! easy-to-find files and stdout only contained info from the simulation. //! -#[macro_use] extern crate clap; mod basic_sim; @@ -34,14 +33,14 @@ fn main() { let matches = cli_app().get_matches(); match matches.subcommand() { - ("basic-sim", Some(matches)) => match basic_sim::run_basic_sim(matches) { + Some(("basic-sim", matches)) => match basic_sim::run_basic_sim(matches) { Ok(()) => println!("Simulation exited successfully"), Err(e) => { eprintln!("Simulation exited with error: {}", e); std::process::exit(1) } }, - ("fallback-sim", Some(matches)) => match fallback_sim::run_fallback_sim(matches) { + Some(("fallback-sim", matches)) => match fallback_sim::run_fallback_sim(matches) { Ok(()) => println!("Simulation exited successfully"), Err(e) => { eprintln!("Simulation exited with error: {}", e); diff --git a/validator_client/src/cli.rs b/validator_client/src/cli.rs index 991b621f27d..66b467c1e22 100644 --- a/validator_client/src/cli.rs +++ b/validator_client/src/cli.rs @@ -1,34 +1,47 @@ -use clap::{App, Arg}; +use clap::{builder::ArgPredicate, Arg, ArgAction, Command}; +use clap_utils::{get_color_style, FLAG_HEADER}; -pub fn cli_app<'a, 'b>() -> App<'a, 'b> { - App::new("validator_client") - .visible_aliases(&["v", "vc", "validator"]) - .setting(clap::AppSettings::ColoredHelp) +pub fn cli_app() -> Command { + Command::new("validator_client") + .visible_aliases(["v", "vc", "validator"]) + .styles(get_color_style()) + .display_order(0) .about( "When connected to a beacon node, performs the duties of a staked \ validator (e.g., proposing blocks and attestations).", ) .arg( - Arg::with_name("beacon-nodes") + Arg::new("help") + .long("help") + .short('h') + .help("Prints help information") + .action(ArgAction::HelpLong) + .display_order(0) + .help_heading(FLAG_HEADER) + ) + .arg( + Arg::new("beacon-nodes") .long("beacon-nodes") .value_name("NETWORK_ADDRESSES") .help("Comma-separated addresses to one or more beacon node HTTP APIs. \ Default is http://localhost:5052." ) - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("proposer-nodes") + Arg::new("proposer-nodes") .long("proposer-nodes") .value_name("NETWORK_ADDRESSES") .help("Comma-separated addresses to one or more beacon node HTTP APIs. \ These specify nodes that are used to send beacon block proposals. A failure will revert back to the standard beacon nodes specified in --beacon-nodes." ) - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) // TODO remove this flag in a future release .arg( - Arg::with_name("disable-run-on-all") + Arg::new("disable-run-on-all") .long("disable-run-on-all") .value_name("DISABLE_RUN_ON_ALL") .help("DEPRECATED. Use --broadcast. \ @@ -36,10 +49,12 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { and proposer preparation messages to all beacon nodes provided in the \ `--beacon-nodes flag`. This option changes that behaviour such that these \ api calls only go out to the first available and synced beacon node") - .takes_value(false), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("broadcast") + Arg::new("broadcast") .long("broadcast") .value_name("API_TOPICS") .help("Comma-separated list of beacon API topics to broadcast to all beacon nodes. \ @@ -47,10 +62,11 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { sync-committee. Default (when flag is omitted) is to broadcast \ subscriptions only." ) - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("validators-dir") + Arg::new("validators-dir") .long("validators-dir") .alias("validator-dir") .value_name("VALIDATORS_DIR") @@ -59,11 +75,12 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { each validator along with the common slashing protection database \ and the validator_definitions.yml" ) - .takes_value(true) + .action(ArgAction::Set) .conflicts_with("datadir") + .display_order(0) ) .arg( - Arg::with_name("secrets-dir") + Arg::new("secrets-dir") .long("secrets-dir") .value_name("SECRETS_DIRECTORY") .help( @@ -72,11 +89,15 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { name is the 0x-prefixed hex representation of the validators voting public \ key. Defaults to ~/.lighthouse/{network}/secrets.", ) - .takes_value(true) + .action(ArgAction::Set) + .conflicts_with("datadir") + .display_order(0) ) .arg( - Arg::with_name("init-slashing-protection") + Arg::new("init-slashing-protection") .long("init-slashing-protection") + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .help( "If present, do not require the slashing protection database to exist before \ running. You SHOULD NOT use this flag unless you're certain that a new \ @@ -84,78 +105,95 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { will have been initialized when you imported your validator keys. If you \ misplace your database and then run with this flag you risk being slashed." ) + .display_order(0) ) .arg( - Arg::with_name("disable-auto-discover") + Arg::new("disable-auto-discover") .long("disable-auto-discover") + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .help( "If present, do not attempt to discover new validators in the validators-dir. Validators \ will need to be manually added to the validator_definitions.yml file." ) + .display_order(0) ) .arg( - Arg::with_name("use-long-timeouts") + Arg::new("use-long-timeouts") .long("use-long-timeouts") + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .help("If present, the validator client will use longer timeouts for requests \ made to the beacon node. This flag is generally not recommended, \ longer timeouts can cause missed duties when fallbacks are used.") + .display_order(0) ) .arg( - Arg::with_name("beacon-nodes-tls-certs") + Arg::new("beacon-nodes-tls-certs") .long("beacon-nodes-tls-certs") .value_name("CERTIFICATE-FILES") - .takes_value(true) + .action(ArgAction::Set) .help("Comma-separated paths to custom TLS certificates to use when connecting \ to a beacon node (and/or proposer node). These certificates must be in PEM format and are used \ in addition to the OS trust store. Commas must only be used as a \ delimiter, and must not be part of the certificate path.") + .display_order(0) ) // This overwrites the graffiti configured in the beacon node. .arg( - Arg::with_name("graffiti") + Arg::new("graffiti") .long("graffiti") .help("Specify your custom graffiti to be included in blocks.") .value_name("GRAFFITI") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("graffiti-file") + Arg::new("graffiti-file") .long("graffiti-file") .help("Specify a graffiti file to load validator graffitis from.") .value_name("GRAFFITI-FILE") - .takes_value(true) + .action(ArgAction::Set) .conflicts_with("graffiti") + .display_order(0) ) .arg( - Arg::with_name("suggested-fee-recipient") + Arg::new("suggested-fee-recipient") .long("suggested-fee-recipient") .help("Once the merge has happened, this address will receive transaction fees \ from blocks proposed by this validator client. If a fee recipient is \ configured in the validator definitions it takes priority over this value.") .value_name("FEE-RECIPIENT") - .takes_value(true) + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("produce-block-v3") + Arg::new("produce-block-v3") .long("produce-block-v3") .help("Enable block production via the block v3 endpoint for this validator client. \ This should only be enabled when paired with a beacon node \ that has this endpoint implemented. This flag will be enabled by default in \ future.") - .takes_value(false) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("distributed") + Arg::new("distributed") .long("distributed") .help("Enables functionality required for running the validator in a distributed validator cluster.") - .takes_value(false) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) /* REST API related arguments */ .arg( - Arg::with_name("http") + Arg::new("http") .long("http") .help("Enable the RESTful HTTP API server. Disabled by default.") - .takes_value(false), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) /* * Note: The HTTP server is **not** encrypted (i.e., not HTTPS) and therefore it is @@ -165,7 +203,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { * must also be used in order to make it clear to the user that this is unsafe. */ .arg( - Arg::with_name("http-address") + Arg::new("http-address") .long("http-address") .requires("http") .value_name("ADDRESS") @@ -175,26 +213,31 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { `--unencrypted-http-transport` flag to ensure the user is aware of the \ risks involved. For access via the Internet, users should apply \ transport-layer security like a HTTPS reverse-proxy or SSH tunnelling.") - .requires("unencrypted-http-transport"), + .requires("unencrypted-http-transport") + .display_order(0) ) .arg( - Arg::with_name("unencrypted-http-transport") - .long("unencrypted-http-transport") - .help("This is a safety flag to ensure that the user is aware that the http \ - transport is unencrypted and using a custom HTTP address is unsafe.") - .requires("http-address"), + Arg::new("unencrypted-http-transport") + .long("unencrypted-http-transport") + .help("This is a safety flag to ensure that the user is aware that the http \ + transport is unencrypted and using a custom HTTP address is unsafe.") + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .requires("http-address") + .display_order(0) ) .arg( - Arg::with_name("http-port") + Arg::new("http-port") .long("http-port") .requires("http") .value_name("PORT") .help("Set the listen TCP port for the RESTful HTTP API server.") - .default_value_if("http", None, "5062") - .takes_value(true), + .default_value_if("http", ArgPredicate::IsPresent, "5062") + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("http-allow-origin") + Arg::new("http-allow-origin") .long("http-allow-origin") .requires("http") .value_name("ORIGIN") @@ -202,10 +245,11 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { Use * to allow any origin (not recommended in production). \ If no value is supplied, the CORS allowed origin is set to the listen \ address of this server (e.g., http://localhost:5062).") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("http-allow-keystore-export") + Arg::new("http-allow-keystore-export") .long("http-allow-keystore-export") .requires("http") .help("If present, allow access to the DELETE /lighthouse/keystores HTTP \ @@ -213,44 +257,52 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { consumers who have access to the API token. This method is useful for \ exporting validators, however it should be used with caution since it \ exposes private key data to authorized users.") - .takes_value(false), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("http-store-passwords-in-secrets-dir") + Arg::new("http-store-passwords-in-secrets-dir") .long("http-store-passwords-in-secrets-dir") .requires("http") .help("If present, any validators created via the HTTP will have keystore \ passwords stored in the secrets-dir rather than the validator \ definitions file.") - .takes_value(false), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) /* Prometheus metrics HTTP server related arguments */ .arg( - Arg::with_name("metrics") + Arg::new("metrics") .long("metrics") .help("Enable the Prometheus metrics HTTP server. Disabled by default.") - .takes_value(false), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("metrics-address") + Arg::new("metrics-address") .long("metrics-address") .requires("metrics") .value_name("ADDRESS") .help("Set the listen address for the Prometheus metrics HTTP server.") - .default_value_if("metrics", None, "127.0.0.1") - .takes_value(true), + .default_value_if("metrics", ArgPredicate::IsPresent, "127.0.0.1") + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("metrics-port") + Arg::new("metrics-port") .long("metrics-port") .requires("metrics") .value_name("PORT") .help("Set the listen TCP port for the Prometheus metrics HTTP server.") - .default_value_if("metrics", None, "5064") - .takes_value(true), + .default_value_if("metrics", ArgPredicate::IsPresent, "5064") + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("metrics-allow-origin") + Arg::new("metrics-allow-origin") .long("metrics-allow-origin") .requires("metrics") .value_name("ORIGIN") @@ -258,22 +310,25 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { Use * to allow any origin (not recommended in production). \ If no value is supplied, the CORS allowed origin is set to the listen \ address of this server (e.g., http://localhost:5064).") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("enable-high-validator-count-metrics") + Arg::new("enable-high-validator-count-metrics") .long("enable-high-validator-count-metrics") .help("Enable per validator metrics for > 64 validators. \ Note: This flag is automatically enabled for <= 64 validators. \ Enabling this metric for higher validator counts will lead to higher volume \ of prometheus metrics being collected.") - .takes_value(false), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) /* * Explorer metrics */ .arg( - Arg::with_name("monitoring-endpoint") + Arg::new("monitoring-endpoint") .long("monitoring-endpoint") .value_name("ADDRESS") .help("Enables the monitoring service for sending system metrics to a remote endpoint. \ @@ -282,19 +337,21 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { Note: This will send information to a remote sever which may identify and associate your \ validators, IP address and other personal information. Always use a HTTPS connection \ and never provide an untrusted URL.") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("monitoring-endpoint-period") + Arg::new("monitoring-endpoint-period") .long("monitoring-endpoint-period") .value_name("SECONDS") .help("Defines how many seconds to wait between each message sent to \ the monitoring-endpoint. Default: 60s") .requires("monitoring-endpoint") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("enable-doppelganger-protection") + Arg::new("enable-doppelganger-protection") .long("enable-doppelganger-protection") .value_name("ENABLE_DOPPELGANGER_PROTECTION") .help("If this flag is set, Lighthouse will delay startup for three epochs and \ @@ -306,56 +363,62 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { to avoid potentially committing a slashable offense. Use this flag in order to \ ENABLE this functionality, without this flag Lighthouse will begin attesting \ immediately.") - .takes_value(false), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("builder-proposals") + Arg::new("builder-proposals") .long("builder-proposals") .alias("private-tx-proposals") .help("If this flag is set, Lighthouse will query the Beacon Node for only block \ headers during proposals and will sign over headers. Useful for outsourcing \ execution payload construction during proposals.") - .takes_value(false), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("builder-registration-timestamp-override") + Arg::new("builder-registration-timestamp-override") .long("builder-registration-timestamp-override") .alias("builder-registration-timestamp-override") .help("This flag takes a unix timestamp value that will be used to override the \ timestamp used in the builder api registration") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("gas-limit") + Arg::new("gas-limit") .long("gas-limit") .value_name("INTEGER") - .takes_value(true) + .action(ArgAction::Set) .help("The gas limit to be used in all builder proposals for all validators managed \ by this validator client. Note this will not necessarily be used if the gas limit \ set here moves too far from the previous block's gas limit. [default: 30,000,000]") - .requires("builder-proposals"), + .requires("builder-proposals") + .display_order(0) ) .arg( - Arg::with_name("latency-measurement-service") - .long("latency-measurement-service") - .value_name("BOOLEAN") - .help("Set to 'true' to enable a service that periodically attempts to measure latency to BNs. \ - Set to 'false' to disable.") - .default_value("true") - .takes_value(true), + Arg::new("disable-latency-measurement-service") + .long("disable-latency-measurement-service") + .help("Disables the service that periodically attempts to measure latency to BNs.") + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("validator-registration-batch-size") + Arg::new("validator-registration-batch-size") .long("validator-registration-batch-size") .value_name("INTEGER") .help("Defines the number of validators per \ validator/register_validator request sent to the BN. This value \ can be reduced to avoid timeouts from builders.") .default_value("500") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("builder-boost-factor") + Arg::new("builder-boost-factor") .long("builder-boost-factor") .value_name("UINT64") .help("Defines the boost factor, \ @@ -363,17 +426,20 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { when choosing between a builder payload header and payload from \ the local execution node.") .conflicts_with("prefer-builder-proposals") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("prefer-builder-proposals") + Arg::new("prefer-builder-proposals") .long("prefer-builder-proposals") .help("If this flag is set, Lighthouse will always prefer blocks \ constructed by builders, regardless of payload value.") - .takes_value(false), + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) .arg( - Arg::with_name("disable-slashing-protection-web3signer") + Arg::new("disable-slashing-protection-web3signer") .long("disable-slashing-protection-web3signer") .help("Disable Lighthouse's slashing protection for all web3signer keys. This can \ reduce the I/O burden on the VC but is only safe if slashing protection \ @@ -381,26 +447,30 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { THIS FLAG UNLESS YOU ARE CERTAIN THAT SLASHING PROTECTION IS ENABLED ON \ THE REMOTE SIGNER. YOU WILL GET SLASHED IF YOU USE THIS FLAG WITHOUT \ ENABLING WEB3SIGNER'S SLASHING PROTECTION.") - .takes_value(false) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0) ) /* * Experimental/development options. */ .arg( - Arg::with_name("web3-signer-keep-alive-timeout") + Arg::new("web3-signer-keep-alive-timeout") .long("web3-signer-keep-alive-timeout") .value_name("MILLIS") .default_value("20000") .help("Keep-alive timeout for each web3signer connection. Set to 'null' to never \ timeout") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) .arg( - Arg::with_name("web3-signer-max-idle-connections") + Arg::new("web3-signer-max-idle-connections") .long("web3-signer-max-idle-connections") .value_name("COUNT") .help("Maximum number of idle connections to maintain per web3signer host. Default \ is unlimited.") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0) ) } diff --git a/validator_client/src/config.rs b/validator_client/src/config.rs index 5bd32fced2a..eb47fcf31a0 100644 --- a/validator_client/src/config.rs +++ b/validator_client/src/config.rs @@ -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::("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::("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::("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::("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::("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::("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::("http-address") { + if cli_args.get_flag("unencrypted-http-transport") { config.http_api.listen_addr = address .parse::() .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::("http-port") { config.http_api.listen_port = port .parse::() .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::("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::("metrics-address") { config.http_metrics.listen_addr = address .parse::() .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::("metrics-port") { config.http_metrics.listen_port = port .parse::() .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::("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::("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::("gas-limit") .map(|gas_limit| { gas_limit .parse::() @@ -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::("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"; diff --git a/validator_client/src/lib.rs b/validator_client/src/lib.rs index 381269129ec..729ff62ee30 100644 --- a/validator_client/src/lib.rs +++ b/validator_client/src/lib.rs @@ -109,7 +109,7 @@ impl ProductionValidatorClient { /// and attestation production. pub async fn new_from_cli( context: RuntimeContext, - cli_args: &ArgMatches<'_>, + cli_args: &ArgMatches, ) -> Result { let config = Config::from_cli(cli_args, context.log()) .map_err(|e| format!("Unable to initialize config: {}", e))?; diff --git a/validator_manager/src/create_validators.rs b/validator_manager/src/create_validators.rs index 00adb906365..d53e92deb30 100644 --- a/validator_manager/src/create_validators.rs +++ b/validator_manager/src/create_validators.rs @@ -1,7 +1,8 @@ use super::common::*; use crate::DumpConfig; use account_utils::{random_password_string, read_mnemonic_from_cli, read_password_from_user}; -use clap::{App, Arg, ArgMatches}; +use clap::{Arg, ArgAction, ArgMatches, Command}; +use clap_utils::FLAG_HEADER; use eth2::{ lighthouse_vc::std_types::KeystoreJsonStr, types::{StateId, ValidatorId}, @@ -35,8 +36,8 @@ pub const DEPOSITS_FILENAME: &str = "deposits.json"; const BEACON_NODE_HTTP_TIMEOUT: Duration = Duration::from_secs(2); -pub fn cli_app<'a, 'b>() -> App<'a, 'b> { - App::new(CMD) +pub fn cli_app() -> Command { + Command::new(CMD) .about( "Creates new validators from BIP-39 mnemonic. A JSON file will be created which \ contains all the validator keystores and other validator data. This file can then \ @@ -45,7 +46,16 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { deposits in the same format as the \"ethereum/staking-deposit-cli\" tool.", ) .arg( - Arg::with_name(OUTPUT_PATH_FLAG) + Arg::new("help") + .long("help") + .short('h') + .help("Prints help information") + .action(ArgAction::HelpLong) + .display_order(0) + .help_heading(FLAG_HEADER), + ) + .arg( + Arg::new(OUTPUT_PATH_FLAG) .long(OUTPUT_PATH_FLAG) .value_name("DIRECTORY") .help( @@ -53,10 +63,11 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { files will be created. The directory will be created if it does not exist.", ) .required(true) - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(DEPOSIT_GWEI_FLAG) + Arg::new(DEPOSIT_GWEI_FLAG) .long(DEPOSIT_GWEI_FLAG) .value_name("DEPOSIT_GWEI") .help( @@ -64,51 +75,60 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { required for an active validator (MAX_EFFECTIVE_BALANCE)", ) .conflicts_with(DISABLE_DEPOSITS_FLAG) - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(FIRST_INDEX_FLAG) + Arg::new(FIRST_INDEX_FLAG) .long(FIRST_INDEX_FLAG) .value_name("FIRST_INDEX") .help("The first of consecutive key indexes you wish to create.") - .takes_value(true) + .action(ArgAction::Set) .required(false) - .default_value("0"), + .default_value("0") + .display_order(0), ) .arg( - Arg::with_name(COUNT_FLAG) + Arg::new(COUNT_FLAG) .long(COUNT_FLAG) .value_name("VALIDATOR_COUNT") .help("The number of validators to create, regardless of how many already exist") .conflicts_with("at-most") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(MNEMONIC_FLAG) + Arg::new(MNEMONIC_FLAG) .long(MNEMONIC_FLAG) .value_name("MNEMONIC_PATH") .help("If present, the mnemonic will be read in from this file.") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(STDIN_INPUTS_FLAG) - .takes_value(false) - .hidden(cfg!(windows)) + Arg::new(STDIN_INPUTS_FLAG) + .action(ArgAction::SetTrue) + .hide(cfg!(windows)) .long(STDIN_INPUTS_FLAG) - .help("If present, read all user inputs from stdin instead of tty."), + .help("If present, read all user inputs from stdin instead of tty.") + .display_order(0) + .help_heading(FLAG_HEADER), ) .arg( - Arg::with_name(DISABLE_DEPOSITS_FLAG) + Arg::new(DISABLE_DEPOSITS_FLAG) .long(DISABLE_DEPOSITS_FLAG) .help( "When provided don't generate the deposits JSON file that is \ commonly used for submitting validator deposits via a web UI. \ Using this flag will save several seconds per validator if the \ user has an alternate strategy for submitting deposits.", - ), + ) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0), ) .arg( - Arg::with_name(SPECIFY_VOTING_KEYSTORE_PASSWORD_FLAG) + Arg::new(SPECIFY_VOTING_KEYSTORE_PASSWORD_FLAG) .long(SPECIFY_VOTING_KEYSTORE_PASSWORD_FLAG) .help( "If present, the user will be prompted to enter the voting keystore \ @@ -116,10 +136,13 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { flag is not provided, a random password will be used. It is not \ necessary to keep backups of voting keystore passwords if the \ mnemonic is safely backed up.", - ), + ) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) + .display_order(0), ) .arg( - Arg::with_name(ETH1_WITHDRAWAL_ADDRESS_FLAG) + Arg::new(ETH1_WITHDRAWAL_ADDRESS_FLAG) .long(ETH1_WITHDRAWAL_ADDRESS_FLAG) .value_name("ETH1_ADDRESS") .help( @@ -128,10 +151,11 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { with the mnemonic-derived withdrawal public key in EIP-2334 format.", ) .conflicts_with(DISABLE_DEPOSITS_FLAG) - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(GAS_LIMIT_FLAG) + Arg::new(GAS_LIMIT_FLAG) .long(GAS_LIMIT_FLAG) .value_name("UINT64") .help( @@ -139,10 +163,11 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { to leave this as the default value by not specifying this flag.", ) .required(false) - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(FEE_RECIPIENT_FLAG) + Arg::new(FEE_RECIPIENT_FLAG) .long(FEE_RECIPIENT_FLAG) .value_name("ETH1_ADDRESS") .help( @@ -150,21 +175,23 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { fee recipient. Omit this flag to use the default value from the VC.", ) .required(false) - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(BUILDER_PROPOSALS_FLAG) + Arg::new(BUILDER_PROPOSALS_FLAG) .long(BUILDER_PROPOSALS_FLAG) .help( "When provided, all created validators will attempt to create \ blocks via builder rather than the local EL.", ) .required(false) - .possible_values(&["true", "false"]) - .takes_value(true), + .value_parser(["true", "false"]) + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(BEACON_NODE_FLAG) + Arg::new(BEACON_NODE_FLAG) .long(BEACON_NODE_FLAG) .value_name("HTTP_ADDRESS") .help( @@ -174,21 +201,24 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { prevent the same validator being created twice and therefore slashable \ conditions.", ) - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(FORCE_BLS_WITHDRAWAL_CREDENTIALS) - .takes_value(false) + Arg::new(FORCE_BLS_WITHDRAWAL_CREDENTIALS) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .long(FORCE_BLS_WITHDRAWAL_CREDENTIALS) .help( "If present, allows BLS withdrawal credentials rather than an execution \ address. This is not recommended.", - ), + ) + .display_order(0), ) .arg( - Arg::with_name(BUILDER_BOOST_FACTOR_FLAG) + Arg::new(BUILDER_BOOST_FACTOR_FLAG) .long(BUILDER_BOOST_FACTOR_FLAG) - .takes_value(true) + .action(ArgAction::Set) .value_name("UINT64") .required(false) .help( @@ -196,18 +226,20 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { a percentage multiplier to apply to the builder's payload value \ when choosing between a builder payload header and payload from \ the local execution node.", - ), + ) + .display_order(0), ) .arg( - Arg::with_name(PREFER_BUILDER_PROPOSALS_FLAG) + Arg::new(PREFER_BUILDER_PROPOSALS_FLAG) .long(PREFER_BUILDER_PROPOSALS_FLAG) .help( "If this flag is set, Lighthouse will always prefer blocks \ constructed by builders, regardless of payload value.", ) .required(false) - .possible_values(&["true", "false"]) - .takes_value(true), + .value_parser(["true", "false"]) + .action(ArgAction::Set) + .display_order(0), ) } @@ -242,10 +274,10 @@ impl CreateConfig { first_index: clap_utils::parse_required(matches, FIRST_INDEX_FLAG)?, count: clap_utils::parse_required(matches, COUNT_FLAG)?, mnemonic_path: clap_utils::parse_optional(matches, MNEMONIC_FLAG)?, - stdin_inputs: cfg!(windows) || matches.is_present(STDIN_INPUTS_FLAG), - disable_deposits: matches.is_present(DISABLE_DEPOSITS_FLAG), + stdin_inputs: cfg!(windows) || matches.get_flag(STDIN_INPUTS_FLAG), + disable_deposits: matches.get_flag(DISABLE_DEPOSITS_FLAG), specify_voting_keystore_password: matches - .is_present(SPECIFY_VOTING_KEYSTORE_PASSWORD_FLAG), + .get_flag(SPECIFY_VOTING_KEYSTORE_PASSWORD_FLAG), eth1_withdrawal_address: clap_utils::parse_optional( matches, ETH1_WITHDRAWAL_ADDRESS_FLAG, @@ -259,7 +291,7 @@ impl CreateConfig { fee_recipient: clap_utils::parse_optional(matches, FEE_RECIPIENT_FLAG)?, gas_limit: clap_utils::parse_optional(matches, GAS_LIMIT_FLAG)?, bn_url: clap_utils::parse_optional(matches, BEACON_NODE_FLAG)?, - force_bls_withdrawal_credentials: matches.is_present(FORCE_BLS_WITHDRAWAL_CREDENTIALS), + force_bls_withdrawal_credentials: matches.get_flag(FORCE_BLS_WITHDRAWAL_CREDENTIALS), }) } } @@ -516,8 +548,8 @@ impl ValidatorsAndDeposits { } } -pub async fn cli_run<'a, E: EthSpec>( - matches: &'a ArgMatches<'a>, +pub async fn cli_run( + matches: &ArgMatches, spec: &ChainSpec, dump_config: DumpConfig, ) -> Result<(), String> { diff --git a/validator_manager/src/import_validators.rs b/validator_manager/src/import_validators.rs index 4b924189f20..f193e8d0fbd 100644 --- a/validator_manager/src/import_validators.rs +++ b/validator_manager/src/import_validators.rs @@ -1,6 +1,7 @@ use super::common::*; use crate::DumpConfig; -use clap::{App, Arg, ArgMatches}; +use clap::{Arg, ArgAction, ArgMatches, Command}; +use clap_utils::FLAG_HEADER; use eth2::{lighthouse_vc::std_types::ImportKeystoreStatus, SensitiveUrl}; use serde::{Deserialize, Serialize}; use std::fs; @@ -13,15 +14,24 @@ pub const VC_TOKEN_FLAG: &str = "vc-token"; pub const DETECTED_DUPLICATE_MESSAGE: &str = "Duplicate validator detected!"; -pub fn cli_app<'a, 'b>() -> App<'a, 'b> { - App::new(CMD) +pub fn cli_app() -> Command { + Command::new(CMD) .about( "Uploads validators to a validator client using the HTTP API. The validators \ are defined in a JSON file which can be generated using the \"create-validators\" \ command.", ) .arg( - Arg::with_name(VALIDATORS_FILE_FLAG) + Arg::new("help") + .long("help") + .short('h') + .help("Prints help information") + .action(ArgAction::HelpLong) + .display_order(0) + .help_heading(FLAG_HEADER), + ) + .arg( + Arg::new(VALIDATORS_FILE_FLAG) .long(VALIDATORS_FILE_FLAG) .value_name("PATH_TO_JSON_FILE") .help( @@ -30,10 +40,11 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { \"validators.json\".", ) .required(true) - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(VC_URL_FLAG) + Arg::new(VC_URL_FLAG) .long(VC_URL_FLAG) .value_name("HTTP_ADDRESS") .help( @@ -43,18 +54,21 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { ) .default_value("http://localhost:5062") .requires(VC_TOKEN_FLAG) - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(VC_TOKEN_FLAG) + Arg::new(VC_TOKEN_FLAG) .long(VC_TOKEN_FLAG) .value_name("PATH") .help("The file containing a token required by the validator client.") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(IGNORE_DUPLICATES_FLAG) - .takes_value(false) + Arg::new(IGNORE_DUPLICATES_FLAG) + .action(ArgAction::SetTrue) + .help_heading(FLAG_HEADER) .long(IGNORE_DUPLICATES_FLAG) .help( "If present, ignore any validators which already exist on the VC. \ @@ -63,7 +77,8 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { slashable conditions, it might be an indicator that something is amiss. \ Users should also be careful to avoid submitting duplicate deposits for \ validators that already exist on the VC.", - ), + ) + .display_order(0), ) } @@ -81,15 +96,12 @@ impl ImportConfig { validators_file_path: clap_utils::parse_required(matches, VALIDATORS_FILE_FLAG)?, vc_url: clap_utils::parse_required(matches, VC_URL_FLAG)?, vc_token_path: clap_utils::parse_required(matches, VC_TOKEN_FLAG)?, - ignore_duplicates: matches.is_present(IGNORE_DUPLICATES_FLAG), + ignore_duplicates: matches.get_flag(IGNORE_DUPLICATES_FLAG), }) } } -pub async fn cli_run<'a>( - matches: &'a ArgMatches<'a>, - dump_config: DumpConfig, -) -> Result<(), String> { +pub async fn cli_run(matches: &ArgMatches, dump_config: DumpConfig) -> Result<(), String> { let config = ImportConfig::from_cli(matches)?; if dump_config.should_exit_early(&config)? { Ok(()) diff --git a/validator_manager/src/lib.rs b/validator_manager/src/lib.rs index a9991d3272c..101d6d21360 100644 --- a/validator_manager/src/lib.rs +++ b/validator_manager/src/lib.rs @@ -1,5 +1,5 @@ -use clap::App; -use clap::ArgMatches; +use clap::{Arg, ArgAction, ArgMatches, Command}; +use clap_utils::{get_color_style, FLAG_HEADER}; use common::write_to_json_file; use environment::Environment; use serde::Serialize; @@ -38,17 +38,28 @@ impl DumpConfig { } } -pub fn cli_app<'a, 'b>() -> App<'a, 'b> { - App::new(CMD) - .visible_aliases(&["vm", "validator-manager", CMD]) +pub fn cli_app() -> Command { + Command::new(CMD) + .visible_aliases(["vm", "validator-manager", CMD]) + .display_order(0) + .styles(get_color_style()) .about("Utilities for managing a Lighthouse validator client via the HTTP API.") + .arg( + Arg::new("help") + .long("help") + .short('h') + .help("Prints help information") + .action(ArgAction::HelpLong) + .display_order(0) + .help_heading(FLAG_HEADER), + ) .subcommand(create_validators::cli_app()) .subcommand(import_validators::cli_app()) .subcommand(move_validators::cli_app()) } /// Run the account manager, returning an error if the operation did not succeed. -pub fn run<'a, E: EthSpec>(matches: &'a ArgMatches<'a>, env: Environment) -> Result<(), String> { +pub fn run(matches: &ArgMatches, env: Environment) -> Result<(), String> { let context = env.core_context(); let spec = context.eth2_config.spec; let dump_config = clap_utils::parse_optional(matches, DUMP_CONFIGS_FLAG)? @@ -63,20 +74,20 @@ pub fn run<'a, E: EthSpec>(matches: &'a ArgMatches<'a>, env: Environment) -> .block_on_dangerous( async { match matches.subcommand() { - (create_validators::CMD, Some(matches)) => { + Some((create_validators::CMD, matches)) => { create_validators::cli_run::(matches, &spec, dump_config).await } - (import_validators::CMD, Some(matches)) => { + Some((import_validators::CMD, matches)) => { import_validators::cli_run(matches, dump_config).await } - (move_validators::CMD, Some(matches)) => { + Some((move_validators::CMD, matches)) => { move_validators::cli_run(matches, dump_config).await } - ("", _) => Err("No command supplied. See --help.".to_string()), - (unknown, _) => Err(format!( + Some((unknown, _)) => Err(format!( "{} is not a valid {} command. See --help.", unknown, CMD )), + _ => Err("No command supplied. See --help.".to_string()), } }, "validator_manager", diff --git a/validator_manager/src/move_validators.rs b/validator_manager/src/move_validators.rs index 5826f2756be..d2149d742c1 100644 --- a/validator_manager/src/move_validators.rs +++ b/validator_manager/src/move_validators.rs @@ -1,7 +1,8 @@ use super::common::*; use crate::DumpConfig; use account_utils::{read_password_from_user, ZeroizeString}; -use clap::{App, Arg, ArgMatches}; +use clap::{Arg, ArgAction, ArgMatches, Command}; +use clap_utils::FLAG_HEADER; use eth2::{ lighthouse_vc::{ std_types::{ @@ -66,8 +67,8 @@ impl PasswordSource { } } -pub fn cli_app<'a, 'b>() -> App<'a, 'b> { - App::new(CMD) +pub fn cli_app() -> Command { + Command::new(CMD) .about( "Uploads validators to a validator client using the HTTP API. The validators \ are defined in a JSON file which can be generated using the \"create-validators\" \ @@ -75,7 +76,16 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { file system (i.e., not Web3Signer validators).", ) .arg( - Arg::with_name(SRC_VC_URL_FLAG) + Arg::new("help") + .long("help") + .short('h') + .help("Prints help information") + .action(ArgAction::HelpLong) + .display_order(0) + .help_heading(FLAG_HEADER), + ) + .arg( + Arg::new(SRC_VC_URL_FLAG) .long(SRC_VC_URL_FLAG) .value_name("HTTP_ADDRESS") .help( @@ -85,17 +95,19 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { ) .required(true) .requires(SRC_VC_TOKEN_FLAG) - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(SRC_VC_TOKEN_FLAG) + Arg::new(SRC_VC_TOKEN_FLAG) .long(SRC_VC_TOKEN_FLAG) .value_name("PATH") .help("The file containing a token required by the source validator client.") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(DEST_VC_URL_FLAG) + Arg::new(DEST_VC_URL_FLAG) .long(DEST_VC_URL_FLAG) .value_name("HTTP_ADDRESS") .help( @@ -105,35 +117,39 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { ) .required(true) .requires(DEST_VC_TOKEN_FLAG) - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(DEST_VC_TOKEN_FLAG) + Arg::new(DEST_VC_TOKEN_FLAG) .long(DEST_VC_TOKEN_FLAG) .value_name("PATH") .help("The file containing a token required by the destination validator client.") - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(VALIDATORS_FLAG) + Arg::new(VALIDATORS_FLAG) .long(VALIDATORS_FLAG) .value_name("STRING") .help( "The validators to be moved. Either a list of 0x-prefixed \ validator pubkeys or the keyword \"all\".", ) - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(COUNT_FLAG) + Arg::new(COUNT_FLAG) .long(COUNT_FLAG) .value_name("VALIDATOR_COUNT") .help("The number of validators to move.") .conflicts_with(VALIDATORS_FLAG) - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(GAS_LIMIT_FLAG) + Arg::new(GAS_LIMIT_FLAG) .long(GAS_LIMIT_FLAG) .value_name("UINT64") .help( @@ -141,10 +157,11 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { to leave this as the default value by not specifying this flag.", ) .required(false) - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(FEE_RECIPIENT_FLAG) + Arg::new(FEE_RECIPIENT_FLAG) .long(FEE_RECIPIENT_FLAG) .value_name("ETH1_ADDRESS") .help( @@ -152,30 +169,33 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { fee recipient. Omit this flag to use the default value from the VC.", ) .required(false) - .takes_value(true), + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(BUILDER_PROPOSALS_FLAG) + Arg::new(BUILDER_PROPOSALS_FLAG) .long(BUILDER_PROPOSALS_FLAG) .help( "When provided, all created validators will attempt to create \ blocks via builder rather than the local EL.", ) .required(false) - .possible_values(&["true", "false"]) - .takes_value(true), + .value_parser(["true", "false"]) + .action(ArgAction::Set) + .display_order(0), ) .arg( - Arg::with_name(STDIN_INPUTS_FLAG) - .takes_value(false) - .hidden(cfg!(windows)) + Arg::new(STDIN_INPUTS_FLAG) + .action(ArgAction::SetTrue) + .hide(cfg!(windows)) .long(STDIN_INPUTS_FLAG) - .help("If present, read all user inputs from stdin instead of tty."), + .help("If present, read all user inputs from stdin instead of tty.") + .display_order(0), ) .arg( - Arg::with_name(BUILDER_BOOST_FACTOR_FLAG) + Arg::new(BUILDER_BOOST_FACTOR_FLAG) .long(BUILDER_BOOST_FACTOR_FLAG) - .takes_value(true) + .action(ArgAction::Set) .value_name("UINT64") .required(false) .help( @@ -183,18 +203,20 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { a percentage multiplier to apply to the builder's payload value \ when choosing between a builder payload header and payload from \ the local execution node.", - ), + ) + .display_order(0), ) .arg( - Arg::with_name(PREFER_BUILDER_PROPOSALS_FLAG) + Arg::new(PREFER_BUILDER_PROPOSALS_FLAG) .long(PREFER_BUILDER_PROPOSALS_FLAG) .help( "If this flag is set, Lighthouse will always prefer blocks \ constructed by builders, regardless of payload value.", ) .required(false) - .possible_values(&["true", "false"]) - .takes_value(true), + .value_parser(["true", "false"]) + .action(ArgAction::Set) + .display_order(0), ) } @@ -223,10 +245,10 @@ pub struct MoveConfig { impl MoveConfig { fn from_cli(matches: &ArgMatches) -> Result { let count_flag = clap_utils::parse_optional(matches, COUNT_FLAG)?; - let validators_flag = matches.value_of(VALIDATORS_FLAG); + let validators_flag = matches.get_one::(VALIDATORS_FLAG); let validators = match (count_flag, validators_flag) { (Some(count), None) => Validators::Count(count), - (None, Some(string)) => match string { + (None, Some(string)) => match string.as_str() { "all" => Validators::All, pubkeys => pubkeys .split(',') @@ -257,16 +279,13 @@ impl MoveConfig { fee_recipient: clap_utils::parse_optional(matches, FEE_RECIPIENT_FLAG)?, gas_limit: clap_utils::parse_optional(matches, GAS_LIMIT_FLAG)?, password_source: PasswordSource::Interactive { - stdin_inputs: cfg!(windows) || matches.is_present(STDIN_INPUTS_FLAG), + stdin_inputs: cfg!(windows) || matches.get_flag(STDIN_INPUTS_FLAG), }, }) } } -pub async fn cli_run<'a>( - matches: &'a ArgMatches<'a>, - dump_config: DumpConfig, -) -> Result<(), String> { +pub async fn cli_run(matches: &ArgMatches, dump_config: DumpConfig) -> Result<(), String> { let config = MoveConfig::from_cli(matches)?; if dump_config.should_exit_early(&config)? { Ok(()) diff --git a/watch/Cargo.toml b/watch/Cargo.toml index 3c1634a5b99..9e8da3b293b 100644 --- a/watch/Cargo.toml +++ b/watch/Cargo.toml @@ -15,6 +15,7 @@ path = "src/main.rs" [dependencies] clap = { workspace = true } +clap_utils = { workspace = true } log = { workspace = true } env_logger = { workspace = true } types = { workspace = true } diff --git a/watch/src/cli.rs b/watch/src/cli.rs index 97dc2172933..b7179efe5d4 100644 --- a/watch/src/cli.rs +++ b/watch/src/cli.rs @@ -1,28 +1,29 @@ use crate::{config::Config, logger, server, updater}; -use clap::{App, Arg}; +use clap::{Arg, ArgAction, Command}; +use clap_utils::get_color_style; pub const SERVE: &str = "serve"; pub const RUN_UPDATER: &str = "run-updater"; pub const CONFIG: &str = "config"; -fn run_updater<'a, 'b>() -> App<'a, 'b> { - App::new(RUN_UPDATER).setting(clap::AppSettings::ColoredHelp) +fn run_updater() -> Command { + Command::new(RUN_UPDATER).styles(get_color_style()) } -fn serve<'a, 'b>() -> App<'a, 'b> { - App::new(SERVE).setting(clap::AppSettings::ColoredHelp) +fn serve() -> Command { + Command::new(SERVE).styles(get_color_style()) } -pub fn app<'a, 'b>() -> App<'a, 'b> { - App::new("beacon_watch_daemon") +pub fn app() -> Command { + Command::new("beacon_watch_daemon") .author("Sigma Prime ") - .setting(clap::AppSettings::ColoredHelp) + .styles(get_color_style()) .arg( - Arg::with_name(CONFIG) + Arg::new(CONFIG) .long(CONFIG) .value_name("PATH_TO_CONFIG") .help("Path to configuration file") - .takes_value(true) + .action(ArgAction::Set) .global(true), ) .subcommand(run_updater()) @@ -32,7 +33,7 @@ pub fn app<'a, 'b>() -> App<'a, 'b> { pub async fn run() -> Result<(), String> { let matches = app().get_matches(); - let config = match matches.value_of(CONFIG) { + let config = match matches.get_one::(CONFIG) { Some(path) => Config::load_from_file(path.to_string())?, None => Config::default(), }; @@ -40,10 +41,10 @@ pub async fn run() -> Result<(), String> { logger::init_logger(&config.log_level); match matches.subcommand() { - (RUN_UPDATER, Some(_)) => updater::run_updater(config) + Some((RUN_UPDATER, _)) => updater::run_updater(config) .await .map_err(|e| format!("Failure: {:?}", e)), - (SERVE, Some(_)) => server::serve(config) + Some((SERVE, _)) => server::serve(config) .await .map_err(|e| format!("Failure: {:?}", e)), _ => Err("Unsupported subcommand. See --help".into()),