Skip to content

Commit

Permalink
Merge branch 'peerdas-network-processor' into peerdas-network-rpc-han…
Browse files Browse the repository at this point in the history
…dler

# Conflicts:
#	beacon_node/beacon_chain/src/data_availability_checker.rs
  • Loading branch information
jimmygchen committed Aug 13, 2024
2 parents 42de037 + f428d17 commit 25c1647
Show file tree
Hide file tree
Showing 71 changed files with 2,751 additions and 625 deletions.
104 changes: 98 additions & 6 deletions Cargo.lock

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

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,14 @@ bytes = "1"
clap = { version = "4.5.4", features = ["derive", "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 }
c-kzg = { version = "1", default-features = false }
compare_fields_derive = { path = "common/compare_fields_derive" }
criterion = "0.5"
delay_map = "0.3"
derivative = "2"
dirs = "3"
either = "1.9"
rust_eth_kzg = "0.3.4"
discv5 = { version = "0.4.1", features = ["libp2p"] }
env_logger = "0.9"
error-chain = "0.12"
Expand Down Expand Up @@ -239,6 +240,9 @@ validator_client = { path = "validator_client" }
validator_dir = { path = "common/validator_dir" }
warp_utils = { path = "common/warp_utils" }

[patch.crates-io]
quick-protobuf = { git = "https://github.com/sigp/quick-protobuf.git", rev = "681f413312404ab6e51f0b46f39b0075c6f4ebfd" }

[profile.maxperf]
inherits = "release"
lto = "fat"
Expand Down
50 changes: 36 additions & 14 deletions account_manager/src/validator/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,13 @@ pub fn cli_run(matches: &ArgMatches, validator_dir: PathBuf) -> Result<(), Strin
let password_opt = loop {
if let Some(password) = previous_password.clone() {
eprintln!("Reuse previous password.");
break Some(password);
if check_password_on_keystore(&keystore, &password)? {
break Some(password);
} else {
eprintln!("Reused password incorrect. Retry!");
previous_password = None;
continue;
}
}
eprintln!();
eprintln!("{}", PASSWORD_PROMPT);
Expand All @@ -201,20 +207,12 @@ pub fn cli_run(matches: &ArgMatches, validator_dir: PathBuf) -> Result<(), Strin
}
};

match keystore.decrypt_keypair(password.as_ref()) {
Ok(_) => {
eprintln!("Password is correct.");
eprintln!();
sleep(Duration::from_secs(1)); // Provides nicer UX.
if reuse_password {
previous_password = Some(password.clone());
}
break Some(password);
}
Err(eth2_keystore::Error::InvalidPassword) => {
eprintln!("Invalid password");
// Check if the password unlocks the keystore
if check_password_on_keystore(&keystore, &password)? {
if reuse_password {
previous_password = Some(password.clone());
}
Err(e) => return Err(format!("Error whilst decrypting keypair: {:?}", e)),
break Some(password);
}
};

Expand Down Expand Up @@ -317,3 +315,27 @@ pub fn cli_run(matches: &ArgMatches, validator_dir: PathBuf) -> Result<(), Strin

Ok(())
}

/// Checks if the given password unlocks the keystore.
///
/// Returns `Ok(true)` if password unlocks the keystore successfully.
/// Returns `Ok(false` if password is incorrect.
/// Otherwise, returns the keystore error.
fn check_password_on_keystore(
keystore: &Keystore,
password: &ZeroizeString,
) -> Result<bool, String> {
match keystore.decrypt_keypair(password.as_ref()) {
Ok(_) => {
eprintln!("Password is correct.");
eprintln!();
sleep(Duration::from_secs(1)); // Provides nicer UX.
Ok(true)
}
Err(eth2_keystore::Error::InvalidPassword) => {
eprintln!("Invalid password");
Ok(false)
}
Err(e) => Err(format!("Error whilst decrypting keypair: {:?}", e)),
}
}
2 changes: 1 addition & 1 deletion beacon_node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "beacon_node"
version = "5.2.1"
version = "5.3.0"
authors = [
"Paul Hauner <paul@paulhauner.com>",
"Age Manning <Age@AgeManning.com",
Expand Down
Loading

0 comments on commit 25c1647

Please sign in to comment.