mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-02 16:21:42 +00:00
upgrade clap to v4.5 (#5273)
* upgrade clap to v4.5 * cli fixes * Merge branch 'unstable' of https://github.com/sigp/lighthouse into upgrade-clap-cli * value parser for mnemonic * Merge branch 'unstable' of https://github.com/sigp/lighthouse into upgrade-clap-cli * merge unstable * default --format val * fix eth sim * fix eth sim * merge conflicts * resolve beta compiler issue * add num args, version * add custom flag parser, make rate limiter flags clap friendly * remove unneeded check * fmt * update * alphabetic order * resolve merge conflict * fix test * resolve conflicts * fix test * revert removed if statement * fmt got me again * fix broken flag * make cli * make cli * update * remove -e files * update * cli help updates * Merge branch 'unstable' of https://github.com/sigp/lighthouse into upgrade-clap-cli * cli help updates * md files * merge conflict * merge conflicts * md * help text, text width, and a few flag fixes * fmt * merge * revert * revert * resolve merge conflicts * merge conflicts * revert simulator changes * require at least one arg * fix eth sim cli * resolve merge conflicts * book changes * md changes * cli check * cli check * retry cli check * retry cli check * Merge branch 'unstable' of https://github.com/sigp/lighthouse into upgrade-clap-cli * cli * Merge remote-tracking branch 'origin/unstable' into upgrade-clap-cli * Update CLI docs for Goerli removal * Fix cargo lock
This commit is contained in:
@@ -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<E: EthSpec>(
|
||||
matches: &ArgMatches,
|
||||
spec: &ChainSpec,
|
||||
dump_config: DumpConfig,
|
||||
) -> Result<(), String> {
|
||||
|
||||
@@ -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(())
|
||||
|
||||
@@ -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<E>) -> Result<(), String> {
|
||||
pub fn run<E: EthSpec>(matches: &ArgMatches, env: Environment<E>) -> 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<E>) ->
|
||||
.block_on_dangerous(
|
||||
async {
|
||||
match matches.subcommand() {
|
||||
(create_validators::CMD, Some(matches)) => {
|
||||
Some((create_validators::CMD, matches)) => {
|
||||
create_validators::cli_run::<E>(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",
|
||||
|
||||
@@ -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<Self, String> {
|
||||
let count_flag = clap_utils::parse_optional(matches, COUNT_FLAG)?;
|
||||
let validators_flag = matches.value_of(VALIDATORS_FLAG);
|
||||
let validators_flag = matches.get_one::<String>(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(())
|
||||
|
||||
Reference in New Issue
Block a user