Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust doppelganger tests #2960

Closed
wants to merge 72 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
993c6af
initial commit
realbigsean Oct 21, 2021
8b03b14
update clap
realbigsean Oct 26, 2021
42039b2
clap 3.0 updates
realbigsean Nov 12, 2021
7bf3c64
Tons of fixes
realbigsean Nov 12, 2021
299277c
Merge branch 'unstable' of https://github.com/sigp/lighthouse into co…
realbigsean Nov 12, 2021
810142b
merge fixes
realbigsean Nov 12, 2021
4d5e86f
Add TOML parsing
realbigsean Nov 15, 2021
d620e05
update clap version
realbigsean Jan 4, 2022
78eae84
about -> help
realbigsean Jan 4, 2022
771aa8d
Merge branch 'unstable' of https://github.com/sigp/lighthouse into co…
realbigsean Jan 4, 2022
9ddb786
refactors and add new App wrapper class
realbigsean Jan 5, 2022
44c06d3
lints and refactors
realbigsean Jan 5, 2022
2dcd2a1
override_help -> about
realbigsean Jan 5, 2022
eaf2306
add some file flag validation, fix some tests, add some docs
realbigsean Jan 6, 2022
417a667
self review
realbigsean Jan 6, 2022
36923b2
fix validation
realbigsean Jan 6, 2022
6e6e789
fix enr tests
realbigsean Jan 6, 2022
88221af
Make lcli a lib
realbigsean Jan 7, 2022
0f66b34
improve file parsing
realbigsean Jan 7, 2022
25ab81f
Merge branch 'unstable' of https://github.com/sigp/lighthouse into co…
realbigsean Jan 7, 2022
2d4053f
Merge branch 'config-file' of https://github.com/realbigsean/lighthou…
realbigsean Jan 7, 2022
870302e
Allow using lcli as a library. Flesh our integration test framework
realbigsean Jan 12, 2022
32a0d4a
refactor lcli flags
realbigsean Jan 13, 2022
6ae306d
Merge branch 'unstable' of https://github.com/sigp/lighthouse into co…
realbigsean Jan 13, 2022
37b7ac2
use constants for requires and conflicts_with
realbigsean Jan 13, 2022
82f5899
Merge branch 'config-file' of https://github.com/realbigsean/lighthou…
realbigsean Jan 13, 2022
42f45b5
get sim testnet working
realbigsean Jan 13, 2022
f9125c1
use constants in lcli command
realbigsean Jan 13, 2022
38546e6
fix comment
realbigsean Jan 13, 2022
e050ac6
add doppelganger test
realbigsean Jan 14, 2022
8c35582
Merge branch 'unstable' of https://github.com/sigp/lighthouse into co…
realbigsean Jan 19, 2022
3268c5e
network load flag
realbigsean Jan 19, 2022
9e09f1b
correct command in docs
realbigsean Jan 19, 2022
a23f042
Update account_manager/src/lib.rs
realbigsean Jan 20, 2022
2640105
Update account_manager/src/validator/mod.rs
realbigsean Jan 20, 2022
fc3499c
Update account_manager/src/validator/modify.rs
realbigsean Jan 20, 2022
f87a456
Update account_manager/src/validator/slashing_protection.rs
realbigsean Jan 20, 2022
982964a
Update account_manager/src/wallet/mod.rs
realbigsean Jan 20, 2022
c3ec601
Update common/clap_utils/src/flags.rs
realbigsean Jan 20, 2022
00bf133
Update lighthouse/src/main.rs
realbigsean Jan 20, 2022
bbbe1c0
Update lcli/src/main.rs
realbigsean Jan 20, 2022
4b8e264
Update lighthouse/src/main.rs
realbigsean Jan 20, 2022
3085a78
Update lighthouse/src/main.rs
realbigsean Jan 20, 2022
3d057a4
Update serde_yaml and remove macro use
realbigsean Jan 20, 2022
9930a27
fix formatting in beacon node config file
realbigsean Jan 20, 2022
0ae7ae5
Merge branch 'unstable' of https://github.com/sigp/lighthouse into co…
realbigsean Jan 20, 2022
1412c89
add file-config link to SUMMARY.md
realbigsean Jan 20, 2022
2ac4fbd
doc fixes and updates
realbigsean Jan 20, 2022
19e58bd
fix docs
realbigsean Jan 20, 2022
13f2524
cargo fmt fix
realbigsean Jan 20, 2022
80a54e5
cargo fmt fix
realbigsean Jan 20, 2022
efeaab9
add back advanced-pre-releases.md with the correct link
realbigsean Jan 20, 2022
c14d255
test commit signing
realbigsean Jan 21, 2022
ee8e623
Revert "test commit signing"
realbigsean Jan 21, 2022
fb733cd
move to new crate
realbigsean Jan 24, 2022
ef8848c
some cleanup
realbigsean Jan 24, 2022
ee5f7c8
lints
realbigsean Jan 25, 2022
9926f36
merge unstable
realbigsean Jan 25, 2022
a292bdc
Merge branch 'config-file' of https://github.com/realbigsean/lighthou…
realbigsean Jan 25, 2022
8773ba4
error handling
realbigsean Jan 25, 2022
b5ea48f
error handling
realbigsean Jan 25, 2022
b94c363
add some check methods
realbigsean Jan 25, 2022
4ac38eb
Merge branch 'unstable' of https://github.com/sigp/lighthouse into co…
realbigsean Jan 28, 2022
cfee1a8
Merge branch 'config-file' of https://github.com/realbigsean/lighthou…
realbigsean Jan 28, 2022
d4eadc5
bugfixes
realbigsean Jan 28, 2022
48c003f
initial commit
realbigsean Jan 31, 2022
c6c743d
fix conflict
realbigsean Jan 31, 2022
00e954e
Merge branch 'clap-derive' of https://github.com/realbigsean/lighthou…
realbigsean Jan 31, 2022
ba6729e
pub fields and start am
realbigsean Jan 31, 2022
33fef02
type global config
realbigsean Feb 1, 2022
b4da8a4
doppelganger tests
realbigsean Feb 2, 2022
69e45c6
account manager
realbigsean Feb 3, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
352 changes: 229 additions & 123 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ members = [
"testing/eth1_test_rig",
"testing/node_test_rig",
"testing/simulator",
"testing/local_testnet",
"testing/test-test_logger",
"testing/state_transition_vectors",
"testing/web3signer_tests",
Expand Down
2 changes: 1 addition & 1 deletion account_manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"

[dependencies]
bls = { path = "../crypto/bls" }
clap = "2.33.3"
clap = "3.0.4"
types = { path = "../consensus/types" }
environment = { path = "../lighthouse/environment" }
eth2_network_config = { path = "../common/eth2_network_config" }
Expand Down
11 changes: 6 additions & 5 deletions account_manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub const SECRETS_DIR_FLAG: &str = "secrets-dir";
pub const VALIDATOR_DIR_FLAG: &str = "validator-dir";
pub const WALLETS_DIR_FLAG: &str = "wallets-dir";

pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
pub fn cli_app<'a>() -> App<'a> {
App::new(CMD)
.visible_aliases(&["a", "am", "account", CMD])
.about("Utilities for generating and managing Ethereum 2.0 accounts.")
Expand All @@ -21,16 +21,17 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
}

/// Run the account manager, returning an error if the operation did not succeed.
pub fn run<T: EthSpec>(matches: &ArgMatches<'_>, env: Environment<T>) -> Result<(), String> {
pub fn run<T: EthSpec>(matches: &ArgMatches, env: Environment<T>) -> 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
));
}
None => return Err(format!("{} requires a command. See --help", CMD)),
}

Ok(())
Expand Down
22 changes: 11 additions & 11 deletions account_manager/src/validator/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,36 @@ 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> {
pub fn cli_app<'a>() -> App<'a> {
App::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),
)
.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),
)
.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"),
)
.arg(
Arg::with_name(SECRETS_DIR_FLAG)
Arg::new(SECRETS_DIR_FLAG)
.long(SECRETS_DIR_FLAG)
.value_name("SECRETS_DIR")
.help(
Expand All @@ -66,7 +66,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
.takes_value(true),
)
.arg(
Arg::with_name(DEPOSIT_GWEI_FLAG)
Arg::new(DEPOSIT_GWEI_FLAG)
.long(DEPOSIT_GWEI_FLAG)
.value_name("DEPOSIT_GWEI")
.help(
Expand All @@ -76,7 +76,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
.takes_value(true),
)
.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 \
Expand All @@ -85,15 +85,15 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
),
)
.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),
)
.arg(
Arg::with_name(AT_MOST_FLAG)
Arg::new(AT_MOST_FLAG)
.long(AT_MOST_FLAG)
.value_name("AT_MOST_VALIDATORS")
.help(
Expand All @@ -104,9 +104,9 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
.takes_value(true),
)
.arg(
Arg::with_name(STDIN_INPUTS_FLAG)
Arg::new(STDIN_INPUTS_FLAG)
.takes_value(false)
.hidden(cfg!(windows))
.hide(cfg!(windows))
.long(STDIN_INPUTS_FLAG)
.help("If present, read all user inputs from stdin instead of tty."),
)
Expand Down
16 changes: 8 additions & 8 deletions account_manager/src/validator/exit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,46 +29,46 @@ pub const CONFIRMATION_PHRASE: &str = "Exit my validator";
pub const WEBSITE_URL: &str = "https://lighthouse-book.sigmaprime.io/voluntary-exit.html";
pub const PROMPT: &str = "WARNING: WITHDRAWING STAKED ETH IS NOT CURRENTLY POSSIBLE";

pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
pub fn cli_app<'a>() -> App<'a> {
App::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),
)
.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),
)
.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),
)
.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")
)
.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")
)
.arg(
Arg::with_name(STDIN_INPUTS_FLAG)
Arg::new(STDIN_INPUTS_FLAG)
.takes_value(false)
.hidden(cfg!(windows))
.hide(cfg!(windows))
.long(STDIN_INPUTS_FLAG)
.help("If present, read all user inputs from stdin instead of tty."),
)
Expand Down
18 changes: 9 additions & 9 deletions account_manager/src/validator/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ 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> {
pub fn cli_app<'a>() -> App<'a> {
App::new(CMD)
.about(
"Imports one or more EIP-2335 passwords into a Lighthouse VC directory, \
Expand All @@ -34,16 +34,16 @@ 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)
.required_unless_present(DIR_FLAG)
.takes_value(true),
)
.arg(
Arg::with_name(DIR_FLAG)
Arg::new(DIR_FLAG)
.long(DIR_FLAG)
.value_name("KEYSTORES_DIRECTORY")
.help(
Expand All @@ -53,23 +53,23 @@ 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)
.required_unless_present(KEYSTORE_FLAG)
.takes_value(true),
)
.arg(
Arg::with_name(STDIN_INPUTS_FLAG)
Arg::new(STDIN_INPUTS_FLAG)
.takes_value(false)
.hidden(cfg!(windows))
.hide(cfg!(windows))
.long(STDIN_INPUTS_FLAG)
.help("If present, read all user inputs from stdin instead of tty."),
)
.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."),
)
.arg(
Arg::with_name(PASSWORD_FLAG)
Arg::new(PASSWORD_FLAG)
.long(PASSWORD_FLAG)
.value_name("KEYSTORE_PASSWORD_PATH")
.requires(REUSE_PASSWORD_FLAG)
Expand Down
2 changes: 1 addition & 1 deletion account_manager/src/validator/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::path::PathBuf;

pub const CMD: &str = "list";

pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
pub fn cli_app<'a>() -> App<'a> {
App::new(CMD).about("Lists the public keys of all validators.")
}

Expand Down
21 changes: 11 additions & 10 deletions account_manager/src/validator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ use types::EthSpec;

pub const CMD: &str = "validator";

pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
pub fn cli_app<'a>() -> App<'a> {
App::new(CMD)
.about("Provides commands for managing Eth2 validators.")
.arg(
Arg::with_name(VALIDATOR_DIR_FLAG)
Arg::new(VALIDATOR_DIR_FLAG)
.long(VALIDATOR_DIR_FLAG)
.value_name("VALIDATOR_DIRECTORY")
.help(
Expand Down Expand Up @@ -48,18 +48,19 @@ pub fn cli_run<T: EthSpec>(matches: &ArgMatches, env: Environment<T>) -> Result<
eprintln!("validator-dir path: {:?}", validator_base_dir);

match matches.subcommand() {
(create::CMD, Some(matches)) => create::cli_run::<T>(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::<T>(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
)),
None => return Err(format!("{} requires a command. See --help", CMD)),
}
}
17 changes: 9 additions & 8 deletions account_manager/src/validator/modify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ 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> {
pub fn cli_app<'a>() -> App<'a> {
App::new(CMD)
.about("Modify validator status in validator_definitions.yml.")
.subcommand(
App::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),
)
.arg(
Arg::with_name(ALL)
Arg::new(ALL)
.long(ALL)
.help("Enable all validators in the validator directory")
.takes_value(false)
Expand All @@ -35,14 +35,14 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
App::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),
)
.arg(
Arg::with_name(ALL)
Arg::new(ALL)
.long(ALL)
.help("Disable all validators in the validator directory")
.takes_value(false)
Expand All @@ -55,14 +55,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
))
}
None => return Err(format!("{} requires a command. See --help", CMD)),
};
let mut defs = ValidatorDefinitions::open(&validator_dir).map_err(|e| {
format!(
Expand Down
Loading