mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-20 05:14:35 +00:00
Clippy 1.49.0 updates and dht persistence test fix (#2156)
## Issue Addressed `test_dht_persistence` failing ## Proposed Changes Bind `NetworkService::start` to an underscore prefixed variable rather than `_`. `_` was causing it to be dropped immediately This was failing 5/100 times before this update, but I haven't been able to get it to fail after updating it Co-authored-by: realbigsean <seananderson33@gmail.com>
This commit is contained in:
@@ -5,17 +5,16 @@ use crate::{
|
||||
},
|
||||
KeyType, ValidatorPath,
|
||||
};
|
||||
pub use bip39::{Mnemonic, Seed as Bip39Seed};
|
||||
pub use eth2_key_derivation::{DerivedKey, DerivedKeyError};
|
||||
use eth2_keystore::{
|
||||
decrypt, default_kdf, encrypt, keypair_from_secret, Keystore, KeystoreBuilder, IV_SIZE,
|
||||
SALT_SIZE,
|
||||
};
|
||||
pub use eth2_keystore::{Error as KeystoreError, PlainText};
|
||||
use rand::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::io::{Read, Write};
|
||||
|
||||
pub use bip39::{Mnemonic, Seed as Bip39Seed};
|
||||
pub use eth2_key_derivation::DerivedKey;
|
||||
pub use eth2_keystore::{Error as KeystoreError, PlainText};
|
||||
pub use uuid::Uuid;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
@@ -24,6 +23,7 @@ pub enum Error {
|
||||
PathExhausted,
|
||||
EmptyPassword,
|
||||
EmptySeed,
|
||||
InvalidNextAccount { old: u32, new: u32 },
|
||||
}
|
||||
|
||||
impl From<KeystoreError> for Error {
|
||||
@@ -32,6 +32,14 @@ impl From<KeystoreError> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DerivedKeyError> for Error {
|
||||
fn from(e: DerivedKeyError) -> Error {
|
||||
match e {
|
||||
DerivedKeyError::EmptySeed => Error::EmptySeed,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Contains the two keystores required for an eth2 validator.
|
||||
pub struct ValidatorKeystores {
|
||||
/// Contains the secret key used for signing every-day consensus messages (blocks,
|
||||
@@ -222,12 +230,15 @@ impl Wallet {
|
||||
///
|
||||
/// Returns `Err(())` if `nextaccount` is less than `self.nextaccount()` without mutating
|
||||
/// `self`. This is to protect against duplicate validator generation.
|
||||
pub fn set_nextaccount(&mut self, nextaccount: u32) -> Result<(), ()> {
|
||||
pub fn set_nextaccount(&mut self, nextaccount: u32) -> Result<(), Error> {
|
||||
if nextaccount >= self.nextaccount() {
|
||||
self.json.nextaccount = nextaccount;
|
||||
Ok(())
|
||||
} else {
|
||||
Err(())
|
||||
Err(Error::InvalidNextAccount {
|
||||
old: self.json.nextaccount,
|
||||
new: nextaccount,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,7 +306,7 @@ pub fn recover_validator_secret(
|
||||
) -> Result<(PlainText, ValidatorPath), Error> {
|
||||
let path = ValidatorPath::new(index, key_type);
|
||||
let secret = wallet.decrypt_seed(wallet_password)?;
|
||||
let master = DerivedKey::from_seed(secret.as_bytes()).map_err(|()| Error::EmptyPassword)?;
|
||||
let master = DerivedKey::from_seed(secret.as_bytes()).map_err(Error::from)?;
|
||||
|
||||
let destination = path.iter_nodes().fold(master, |dk, i| dk.child(*i));
|
||||
|
||||
@@ -311,7 +322,7 @@ pub fn recover_validator_secret_from_mnemonic(
|
||||
key_type: KeyType,
|
||||
) -> Result<(PlainText, ValidatorPath), Error> {
|
||||
let path = ValidatorPath::new(index, key_type);
|
||||
let master = DerivedKey::from_seed(secret).map_err(|()| Error::EmptyPassword)?;
|
||||
let master = DerivedKey::from_seed(secret).map_err(Error::from)?;
|
||||
|
||||
let destination = path.iter_nodes().fold(master, |dk, i| dk.child(*i));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user