Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
eserilev committed Apr 4, 2024
1 parent 9b40a14 commit e320c99
Show file tree
Hide file tree
Showing 19 changed files with 713 additions and 207 deletions.
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ bincode = "1"
bitvec = "1"
byteorder = "1"
bytes = "1"
clap = { version = "4.5.1", features = ["cargo"] }
clap = { version = "4.5.1", features = ["cargo", "wrap_help"] }
compare_fields_derive = { path = "common/compare_fields_derive" }
criterion = "0.3"
delay_map = "0.3"
Expand Down
28 changes: 20 additions & 8 deletions account_manager/src/validator/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use account_utils::{
random_password, read_password_from_user, strip_off_newlines, validator_definitions, PlainText,
};
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,
};
Expand Down Expand Up @@ -37,22 +38,25 @@ pub fn cli_app() -> Command {
.long(WALLET_NAME_FLAG)
.value_name("WALLET_NAME")
.help("Use the wallet identified by this name")
.action(ArgAction::Set),
.action(ArgAction::Set)
.display_order(0)
)
.arg(
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.")
.action(ArgAction::Set),
.action(ArgAction::Set)
.display_order(0)
)
.arg(
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")
.action(ArgAction::Set)
.conflicts_with("datadir"),
.conflicts_with("datadir")
.display_order(0)
)
.arg(
Arg::new(SECRETS_DIR_FLAG)
Expand All @@ -63,7 +67,8 @@ pub fn cli_app() -> Command {
Defaults to ~/.lighthouse/{network}/secrets",
)
.conflicts_with("datadir")
.action(ArgAction::Set),
.action(ArgAction::Set)
.display_order(0)
)
.arg(
Arg::new(DEPOSIT_GWEI_FLAG)
Expand All @@ -73,7 +78,8 @@ pub fn cli_app() -> Command {
"The GWEI value of the deposit amount. Defaults to the minimum amount \
required for an active validator (MAX_EFFECTIVE_BALANCE)",
)
.action(ArgAction::Set),
.action(ArgAction::Set)
.display_order(0)
)
.arg(
Arg::new(STORE_WITHDRAW_FLAG)
Expand All @@ -84,14 +90,17 @@ pub fn cli_app() -> Command {
instead generate them from the wallet seed when required.",
)
.action(ArgAction::SetTrue)
.help_heading(FLAG_HEADER)
.display_order(0)
)
.arg(
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")
.action(ArgAction::Set),
.action(ArgAction::Set)
.display_order(0)
)
.arg(
Arg::new(AT_MOST_FLAG)
Expand All @@ -102,14 +111,17 @@ pub fn cli_app() -> Command {
reach the given count. Never deletes an existing validator.",
)
.conflicts_with("count")
.action(ArgAction::Set),
.action(ArgAction::Set)
.display_order(0)
)
.arg(
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)
)
}

Expand Down
16 changes: 12 additions & 4 deletions account_manager/src/validator/exit.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::wallet::create::STDIN_INPUTS_FLAG;
use bls::{Keypair, PublicKey};
use clap::{Arg, ArgAction, ArgMatches, Command};
use clap_utils::FLAG_HEADER;
use environment::Environment;
use eth2::{
types::{GenesisData, StateId, ValidatorData, ValidatorId, ValidatorStatus},
Expand Down Expand Up @@ -37,39 +38,46 @@ pub fn cli_app() -> Command {
.value_name("KEYSTORE_PATH")
.help("The path to the EIP-2335 voting keystore for the validator")
.action(ArgAction::Set)
.required(true),
.required(true)
.display_order(0)
)
.arg(
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")
.action(ArgAction::Set),
.action(ArgAction::Set)
.display_order(0)
)
.arg(
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)
.action(ArgAction::Set),
.action(ArgAction::Set)
.display_order(0)
)
.arg(
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")
.display_order(0)
)
.arg(
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)
)
.arg(
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)
)
}

Expand Down
18 changes: 13 additions & 5 deletions account_manager/src/validator/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use account_utils::{
ZeroizeString,
};
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;
Expand Down Expand Up @@ -40,7 +41,8 @@ pub fn cli_app() -> Command {
.help("Path to a single keystore to be imported.")
.conflicts_with(DIR_FLAG)
.required_unless_present(DIR_FLAG)
.action(ArgAction::Set),
.action(ArgAction::Set)
.display_order(0),
)
.arg(
Arg::new(DIR_FLAG)
Expand All @@ -54,20 +56,25 @@ pub fn cli_app() -> Command {
)
.conflicts_with(KEYSTORE_FLAG)
.required_unless_present(KEYSTORE_FLAG)
.action(ArgAction::Set),
.action(ArgAction::Set)
.display_order(0),
)
.arg(
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::new(REUSE_PASSWORD_FLAG)
.long(REUSE_PASSWORD_FLAG)
.action(ArgAction::SetTrue)
.help("If present, the same password will be used for all imported keystores."),
.help_heading(FLAG_HEADER)
.help("If present, the same password will be used for all imported keystores.")
.display_order(0),
)
.arg(
Arg::new(PASSWORD_FLAG)
Expand All @@ -80,7 +87,8 @@ pub fn cli_app() -> Command {
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.",
)
.action(ArgAction::Set),
.action(ArgAction::Set)
.display_order(0),
)
}

Expand Down
1 change: 1 addition & 0 deletions account_manager/src/validator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub const CMD: &str = "validator";

pub fn cli_app() -> Command {
Command::new(CMD)
.display_order(0)
.about("Provides commands for managing Eth2 validators.")
.arg(
Arg::new(VALIDATOR_DIR_FLAG)
Expand Down
16 changes: 12 additions & 4 deletions account_manager/src/validator/modify.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use account_utils::validator_definitions::ValidatorDefinitions;
use bls::PublicKey;
use clap::{Arg, ArgAction, ArgMatches, Command};
use clap_utils::FLAG_HEADER;
use std::{collections::HashSet, path::PathBuf};

pub const CMD: &str = "modify";
Expand All @@ -13,6 +14,7 @@ pub const ALL: &str = "all";
pub fn cli_app() -> Command {
Command::new(CMD)
.about("Modify validator status in validator_definitions.yml.")
.display_order(0)
.subcommand(
Command::new(ENABLE)
.about("Enable validator(s) in validator_definitions.yml.")
Expand All @@ -21,14 +23,17 @@ pub fn cli_app() -> Command {
.long(PUBKEY_FLAG)
.value_name("PUBKEY")
.help("Validator pubkey to enable")
.action(ArgAction::Set),
.action(ArgAction::Set)
.display_order(0),
)
.arg(
Arg::new(ALL)
.long(ALL)
.help("Enable all validators in the validator directory")
.action(ArgAction::SetTrue)
.conflicts_with(PUBKEY_FLAG),
.help_heading(FLAG_HEADER)
.conflicts_with(PUBKEY_FLAG)
.display_order(0),
),
)
.subcommand(
Expand All @@ -39,14 +44,17 @@ pub fn cli_app() -> Command {
.long(PUBKEY_FLAG)
.value_name("PUBKEY")
.help("Validator pubkey to disable")
.action(ArgAction::Set),
.action(ArgAction::Set)
.display_order(0),
)
.arg(
Arg::new(ALL)
.long(ALL)
.help("Disable all validators in the validator directory")
.action(ArgAction::SetTrue)
.conflicts_with(PUBKEY_FLAG),
.help_heading(FLAG_HEADER)
.conflicts_with(PUBKEY_FLAG)
.display_order(0),
),
)
}
Expand Down
17 changes: 13 additions & 4 deletions account_manager/src/validator/recover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ 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::{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;
Expand All @@ -29,7 +30,8 @@ pub fn cli_app() -> Command {
.help("The first of consecutive key indexes you wish to recover.")
.action(ArgAction::Set)
.required(false)
.default_value("0"),
.default_value("0")
.display_order(0)
)
.arg(
Arg::new(COUNT_FLAG)
Expand All @@ -38,7 +40,8 @@ pub fn cli_app() -> Command {
.help("The number of validator keys you wish to recover. Counted consecutively from the provided `--first_index`.")
.action(ArgAction::Set)
.required(false)
.default_value("1"),
.default_value("1")
.display_order(0)
)
.arg(
Arg::new(MNEMONIC_FLAG)
Expand All @@ -48,6 +51,7 @@ pub fn cli_app() -> Command {
"If present, the mnemonic will be read in from this file.",
)
.action(ArgAction::Set)
.display_order(0)
)
.arg(
Arg::new(SECRETS_DIR_FLAG)
Expand All @@ -57,7 +61,8 @@ pub fn cli_app() -> Command {
"The path where the validator keystore passwords will be stored. \
Defaults to ~/.lighthouse/{network}/secrets",
)
.action(ArgAction::Set),
.action(ArgAction::Set)
.display_order(0)
)
.arg(
Arg::new(STORE_WITHDRAW_FLAG)
Expand All @@ -68,13 +73,17 @@ pub fn cli_app() -> Command {
instead generate them from the wallet seed when required.",
)
.action(ArgAction::SetTrue)
.help_heading(FLAG_HEADER)
.display_order(0)
)
.arg(
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)
)
}

Expand Down
Loading

0 comments on commit e320c99

Please sign in to comment.