mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 00:42:42 +00:00
Update Rust Edition to 2024 (#7766)
* #7749 Thanks @dknopik and @michaelsproul for your help!
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
use crate::common::read_wallet_name_from_cli;
|
||||
use crate::{SECRETS_DIR_FLAG, WALLETS_DIR_FLAG};
|
||||
use account_utils::{
|
||||
random_password, read_password_from_user, strip_off_newlines, validator_definitions, PlainText,
|
||||
STDIN_INPUTS_FLAG,
|
||||
PlainText, STDIN_INPUTS_FLAG, random_password, read_password_from_user, strip_off_newlines,
|
||||
validator_definitions,
|
||||
};
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command};
|
||||
use clap_utils::FLAG_HEADER;
|
||||
use directory::{parse_path_or_default_with_flag, DEFAULT_SECRET_DIR, DEFAULT_WALLET_DIR};
|
||||
use directory::{DEFAULT_SECRET_DIR, DEFAULT_WALLET_DIR, parse_path_or_default_with_flag};
|
||||
use environment::Environment;
|
||||
use eth2_wallet_manager::WalletManager;
|
||||
use slashing_protection::{SlashingDatabase, SLASHING_PROTECTION_FILENAME};
|
||||
use slashing_protection::{SLASHING_PROTECTION_FILENAME, SlashingDatabase};
|
||||
use std::ffi::OsStr;
|
||||
use std::fs;
|
||||
use std::fs::create_dir_all;
|
||||
@@ -148,7 +148,9 @@ pub fn cli_run<E: EthSpec>(
|
||||
return Err(format!(
|
||||
"No wallet directory at {:?}. Use the `lighthouse --network {} {} {} {}` command to create a wallet",
|
||||
wallet_base_dir,
|
||||
matches.get_one::<String>("network").unwrap_or(&String::from("<NETWORK>")),
|
||||
matches
|
||||
.get_one::<String>("network")
|
||||
.unwrap_or(&String::from("<NETWORK>")),
|
||||
crate::CMD,
|
||||
crate::wallet::CMD,
|
||||
crate::wallet::create::CMD
|
||||
|
||||
@@ -4,8 +4,8 @@ use clap::{Arg, ArgAction, ArgMatches, Command};
|
||||
use clap_utils::FLAG_HEADER;
|
||||
use environment::Environment;
|
||||
use eth2::{
|
||||
types::{GenesisData, StateId, ValidatorData, ValidatorId, ValidatorStatus},
|
||||
BeaconNodeHttpClient, Timeouts,
|
||||
types::{GenesisData, StateId, ValidatorData, ValidatorId, ValidatorStatus},
|
||||
};
|
||||
use eth2_keystore::Keystore;
|
||||
use eth2_network_config::Eth2NetworkConfig;
|
||||
@@ -239,9 +239,11 @@ async fn publish_voluntary_exit<E: EthSpec>(
|
||||
let withdrawal_epoch = validator_data.validator.withdrawable_epoch;
|
||||
let current_epoch = get_current_epoch::<E>(genesis_data.genesis_time, spec)
|
||||
.ok_or("Failed to get current epoch. Please check your system time")?;
|
||||
eprintln!("Voluntary exit has been accepted into the beacon chain, but not yet finalized. \
|
||||
eprintln!(
|
||||
"Voluntary exit has been accepted into the beacon chain, but not yet finalized. \
|
||||
Finalization may take several minutes or longer. Before finalization there is a low \
|
||||
probability that the exit may be reverted.");
|
||||
probability that the exit may be reverted."
|
||||
);
|
||||
eprintln!(
|
||||
"Current epoch: {}, Exit epoch: {}, Withdrawable epoch: {}",
|
||||
current_epoch, exit_epoch, withdrawal_epoch
|
||||
@@ -401,7 +403,7 @@ mod tests {
|
||||
use eth2_keystore::KeystoreBuilder;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use tempfile::{tempdir, TempDir};
|
||||
use tempfile::{TempDir, tempdir};
|
||||
|
||||
const PASSWORD: &str = "cats";
|
||||
const KEYSTORE_NAME: &str = "keystore-m_12381_3600_0_0_0-1595406747.json";
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
use crate::wallet::create::PASSWORD_FLAG;
|
||||
use account_utils::validator_definitions::SigningDefinition;
|
||||
use account_utils::{
|
||||
STDIN_INPUTS_FLAG,
|
||||
eth2_keystore::Keystore,
|
||||
read_password_from_user,
|
||||
validator_definitions::{
|
||||
recursively_find_voting_keystores, PasswordStorage, ValidatorDefinition,
|
||||
ValidatorDefinitions, CONFIG_FILENAME,
|
||||
CONFIG_FILENAME, PasswordStorage, ValidatorDefinition, ValidatorDefinitions,
|
||||
recursively_find_voting_keystores,
|
||||
},
|
||||
STDIN_INPUTS_FLAG,
|
||||
};
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command};
|
||||
use clap_utils::FLAG_HEADER;
|
||||
use slashing_protection::{SlashingDatabase, SLASHING_PROTECTION_FILENAME};
|
||||
use slashing_protection::{SLASHING_PROTECTION_FILENAME, SlashingDatabase};
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use std::thread::sleep;
|
||||
@@ -133,7 +133,7 @@ pub fn cli_run(matches: &ArgMatches, validator_dir: PathBuf) -> Result<(), Strin
|
||||
return Err(format!(
|
||||
"Must supply either --{} or --{}",
|
||||
KEYSTORE_FLAG, DIR_FLAG
|
||||
))
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -227,19 +227,20 @@ pub fn cli_run(matches: &ArgMatches, validator_dir: PathBuf) -> Result<(), Strin
|
||||
if let Some(ValidatorDefinition {
|
||||
signing_definition:
|
||||
SigningDefinition::LocalKeystore {
|
||||
voting_keystore_password: ref mut old_passwd,
|
||||
voting_keystore_password: old_passwd,
|
||||
..
|
||||
},
|
||||
..
|
||||
}) = old_validator_def_opt
|
||||
&& old_passwd.is_none()
|
||||
&& password_opt.is_some()
|
||||
{
|
||||
if old_passwd.is_none() && password_opt.is_some() {
|
||||
*old_passwd = password_opt;
|
||||
defs.save(&validator_dir)
|
||||
.map_err(|e| format!("Unable to save {}: {:?}", CONFIG_FILENAME, e))?;
|
||||
eprintln!("Password updated for public key {}", voting_pubkey);
|
||||
}
|
||||
*old_passwd = password_opt;
|
||||
defs.save(&validator_dir)
|
||||
.map_err(|e| format!("Unable to save {}: {:?}", CONFIG_FILENAME, e))?;
|
||||
eprintln!("Password updated for public key {}", voting_pubkey);
|
||||
}
|
||||
|
||||
eprintln!(
|
||||
"Skipping import of keystore for existing public key: {:?}",
|
||||
src_keystore
|
||||
|
||||
@@ -8,7 +8,7 @@ pub mod slashing_protection;
|
||||
|
||||
use crate::{VALIDATOR_DIR_FLAG, VALIDATOR_DIR_FLAG_ALIAS};
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command};
|
||||
use directory::{parse_path_or_default_with_flag, DEFAULT_VALIDATOR_DIR};
|
||||
use directory::{DEFAULT_VALIDATOR_DIR, parse_path_or_default_with_flag};
|
||||
use environment::Environment;
|
||||
use std::path::PathBuf;
|
||||
use types::EthSpec;
|
||||
|
||||
@@ -69,7 +69,7 @@ pub fn cli_run(matches: &ArgMatches, validator_dir: PathBuf) -> Result<(), Strin
|
||||
return Err(format!(
|
||||
"{} does not have a {} command. See --help",
|
||||
CMD, unknown
|
||||
))
|
||||
));
|
||||
}
|
||||
_ => return Err(format!("No command provided for {}. See --help", CMD)),
|
||||
};
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
use super::create::STORE_WITHDRAW_FLAG;
|
||||
use crate::validator::create::COUNT_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, STDIN_INPUTS_FLAG};
|
||||
use crate::validator::create::COUNT_FLAG;
|
||||
use account_utils::eth2_keystore::{Keystore, KeystoreBuilder, keypair_from_secret};
|
||||
use account_utils::{STDIN_INPUTS_FLAG, random_password, read_mnemonic_from_cli};
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command};
|
||||
use clap_utils::FLAG_HEADER;
|
||||
use directory::{parse_path_or_default_with_flag, DEFAULT_SECRET_DIR};
|
||||
use directory::{DEFAULT_SECRET_DIR, parse_path_or_default_with_flag};
|
||||
use eth2_wallet::bip39::Seed;
|
||||
use eth2_wallet::{recover_validator_secret_from_mnemonic, KeyType, ValidatorKeystores};
|
||||
use eth2_wallet::{KeyType, ValidatorKeystores, recover_validator_secret_from_mnemonic};
|
||||
use std::fs::create_dir_all;
|
||||
use std::path::PathBuf;
|
||||
use validator_dir::Builder as ValidatorDirBuilder;
|
||||
@@ -97,7 +97,9 @@ pub fn cli_run(matches: &ArgMatches, validator_dir: PathBuf) -> Result<(), Strin
|
||||
.map_err(|e| format!("Could not create secrets dir at {secrets_dir:?}: {e:?}"))?;
|
||||
|
||||
eprintln!();
|
||||
eprintln!("WARNING: KEY RECOVERY CAN LEAD TO DUPLICATING VALIDATORS KEYS, WHICH CAN LEAD TO SLASHING.");
|
||||
eprintln!(
|
||||
"WARNING: KEY RECOVERY CAN LEAD TO DUPLICATING VALIDATORS KEYS, WHICH CAN LEAD TO SLASHING."
|
||||
);
|
||||
eprintln!();
|
||||
|
||||
let mnemonic = read_mnemonic_from_cli(mnemonic_path, stdin_inputs)?;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command};
|
||||
use environment::Environment;
|
||||
use slashing_protection::{
|
||||
interchange::Interchange, InterchangeError, InterchangeImportOutcome, SlashingDatabase,
|
||||
SLASHING_PROTECTION_FILENAME,
|
||||
InterchangeError, InterchangeImportOutcome, SLASHING_PROTECTION_FILENAME, SlashingDatabase,
|
||||
interchange::Interchange,
|
||||
};
|
||||
use std::fs::File;
|
||||
use std::path::PathBuf;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
use crate::common::read_wallet_name_from_cli;
|
||||
use crate::WALLETS_DIR_FLAG;
|
||||
use crate::common::read_wallet_name_from_cli;
|
||||
use account_utils::{
|
||||
is_password_sufficiently_complex, random_password, read_password_from_user, strip_off_newlines,
|
||||
STDIN_INPUTS_FLAG,
|
||||
STDIN_INPUTS_FLAG, is_password_sufficiently_complex, random_password, read_password_from_user,
|
||||
strip_off_newlines,
|
||||
};
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command};
|
||||
use eth2_wallet::{
|
||||
bip39::{Language, Mnemonic, MnemonicType},
|
||||
PlainText,
|
||||
bip39::{Language, Mnemonic, MnemonicType},
|
||||
};
|
||||
use eth2_wallet_manager::{LockedWallet, WalletManager, WalletType};
|
||||
use filesystem::create_with_600_perms;
|
||||
|
||||
@@ -4,7 +4,7 @@ pub mod recover;
|
||||
|
||||
use crate::WALLETS_DIR_FLAG;
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command};
|
||||
use directory::{parse_path_or_default_with_flag, DEFAULT_WALLET_DIR};
|
||||
use directory::{DEFAULT_WALLET_DIR, parse_path_or_default_with_flag};
|
||||
use std::fs::create_dir_all;
|
||||
use std::path::PathBuf;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::wallet::create::create_wallet_from_mnemonic;
|
||||
use crate::wallet::create::{HD_TYPE, NAME_FLAG, PASSWORD_FLAG, TYPE_FLAG};
|
||||
use account_utils::{read_mnemonic_from_cli, STDIN_INPUTS_FLAG};
|
||||
use account_utils::{STDIN_INPUTS_FLAG, read_mnemonic_from_cli};
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command};
|
||||
use std::path::PathBuf;
|
||||
|
||||
@@ -63,7 +63,9 @@ pub fn cli_run(matches: &ArgMatches, wallet_base_dir: PathBuf) -> Result<(), Str
|
||||
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.");
|
||||
eprintln!(
|
||||
"WARNING: KEY RECOVERY CAN LEAD TO DUPLICATING VALIDATORS KEYS, WHICH CAN LEAD TO SLASHING."
|
||||
);
|
||||
eprintln!();
|
||||
|
||||
let mnemonic = read_mnemonic_from_cli(mnemonic_path, stdin_inputs)?;
|
||||
|
||||
Reference in New Issue
Block a user