mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Update Rust Edition to 2024 (#7766)
* #7749 Thanks @dknopik and @michaelsproul for your help!
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use filesystem::create_with_600_perms;
|
||||
use rand::distributions::Alphanumeric;
|
||||
use rand::{thread_rng, Rng};
|
||||
use rand::distr::Alphanumeric;
|
||||
use rand::{Rng, rng};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use warp::Filter;
|
||||
@@ -58,7 +58,7 @@ impl ApiSecret {
|
||||
}
|
||||
|
||||
let length = PK_LEN;
|
||||
let pk: String = thread_rng()
|
||||
let pk: String = rng()
|
||||
.sample_iter(&Alphanumeric)
|
||||
.take(length)
|
||||
.map(char::from)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use account_utils::validator_definitions::{PasswordStorage, ValidatorDefinition};
|
||||
use account_utils::{
|
||||
eth2_keystore::Keystore,
|
||||
eth2_wallet::{bip39::Mnemonic, WalletBuilder},
|
||||
eth2_wallet::{WalletBuilder, bip39::Mnemonic},
|
||||
random_mnemonic, random_password,
|
||||
};
|
||||
use eth2::lighthouse_vc::types::{self as api_types};
|
||||
@@ -9,7 +9,7 @@ use lighthouse_validator_store::LighthouseValidatorStore;
|
||||
use slot_clock::SlotClock;
|
||||
use std::path::{Path, PathBuf};
|
||||
use types::{ChainSpec, EthSpec};
|
||||
use validator_dir::{keystore_password_path, Builder as ValidatorDirBuilder};
|
||||
use validator_dir::{Builder as ValidatorDirBuilder, keystore_password_path};
|
||||
use zeroize::Zeroizing;
|
||||
|
||||
/// Create some validator EIP-2335 keystores and store them on disk. Then, enroll the validators in
|
||||
|
||||
@@ -2,7 +2,7 @@ use bls::PublicKey;
|
||||
use lighthouse_validator_store::LighthouseValidatorStore;
|
||||
use slot_clock::SlotClock;
|
||||
use std::sync::Arc;
|
||||
use types::{graffiti::GraffitiString, EthSpec, Graffiti};
|
||||
use types::{EthSpec, Graffiti, graffiti::GraffitiString};
|
||||
|
||||
pub fn get_graffiti<T: 'static + SlotClock + Clone, E: EthSpec>(
|
||||
validator_pubkey: PublicKey,
|
||||
|
||||
@@ -19,7 +19,7 @@ use task_executor::TaskExecutor;
|
||||
use tokio::runtime::Handle;
|
||||
use tracing::{info, warn};
|
||||
use types::{EthSpec, PublicKeyBytes};
|
||||
use validator_dir::{keystore_password_path, Builder as ValidatorDirBuilder};
|
||||
use validator_dir::{Builder as ValidatorDirBuilder, keystore_password_path};
|
||||
use warp::Rejection;
|
||||
use warp_utils::reject::{custom_bad_request, custom_server_error};
|
||||
use zeroize::Zeroizing;
|
||||
@@ -79,7 +79,7 @@ pub fn import<T: SlotClock + 'static, E: EthSpec>(
|
||||
let slashing_protection_status =
|
||||
if let Some(InterchangeJsonStr(slashing_protection)) = request.slashing_protection {
|
||||
// Warn for missing slashing protection.
|
||||
for KeystoreJsonStr(ref keystore) in &request.keystores {
|
||||
for KeystoreJsonStr(keystore) in &request.keystores {
|
||||
if let Some(public_key) = keystore.public_key() {
|
||||
let pubkey_bytes = public_key.compress();
|
||||
if !slashing_protection
|
||||
|
||||
@@ -12,7 +12,7 @@ pub use api_secret::PK_FILENAME;
|
||||
use graffiti::{delete_graffiti, get_graffiti, set_graffiti};
|
||||
|
||||
use create_signed_voluntary_exit::create_signed_voluntary_exit;
|
||||
use graffiti_file::{determine_graffiti, GraffitiFile};
|
||||
use graffiti_file::{GraffitiFile, determine_graffiti};
|
||||
use lighthouse_validator_store::LighthouseValidatorStore;
|
||||
use validator_store::ValidatorStore;
|
||||
|
||||
@@ -36,8 +36,8 @@ use eth2::lighthouse_vc::{
|
||||
};
|
||||
use health_metrics::observe::Observe;
|
||||
use lighthouse_version::version_with_platform;
|
||||
use logging::crit;
|
||||
use logging::SSELoggingComponents;
|
||||
use logging::crit;
|
||||
use parking_lot::RwLock;
|
||||
use sensitive_url::SensitiveUrl;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -50,12 +50,12 @@ use std::sync::Arc;
|
||||
use sysinfo::{System, SystemExt};
|
||||
use system_health::observe_system_health_vc;
|
||||
use task_executor::TaskExecutor;
|
||||
use tokio_stream::{wrappers::BroadcastStream, StreamExt};
|
||||
use tokio_stream::{StreamExt, wrappers::BroadcastStream};
|
||||
use tracing::{info, warn};
|
||||
use types::{ChainSpec, ConfigAndPreset, EthSpec};
|
||||
use validator_dir::Builder as ValidatorDirBuilder;
|
||||
use validator_services::block_service::BlockService;
|
||||
use warp::{reply::Response, sse::Event, Filter};
|
||||
use warp::{Filter, reply::Response, sse::Event};
|
||||
use warp_utils::reject::convert_rejection;
|
||||
use warp_utils::task::blocking_json_task;
|
||||
|
||||
@@ -883,7 +883,7 @@ pub fn serve<T: 'static + SlotClock + Clone, E: EthSpec>(
|
||||
return convert_rejection::<Infallible>(Err(
|
||||
warp_utils::reject::custom_bad_request(e.to_string()),
|
||||
))
|
||||
.await
|
||||
.await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,24 +7,24 @@ use account_utils::{
|
||||
use deposit_contract::decode_eth1_tx_data;
|
||||
use doppelganger_service::DoppelgangerService;
|
||||
use eth2::{
|
||||
Error as ApiError,
|
||||
lighthouse_vc::{http_client::ValidatorClientHttpClient, types::*},
|
||||
types::ErrorMessage as ApiErrorMessage,
|
||||
Error as ApiError,
|
||||
};
|
||||
use eth2_keystore::KeystoreBuilder;
|
||||
use initialized_validators::key_cache::{KeyCache, CACHE_FILENAME};
|
||||
use initialized_validators::key_cache::{CACHE_FILENAME, KeyCache};
|
||||
use initialized_validators::{InitializedValidators, OnDecryptFailure};
|
||||
use lighthouse_validator_store::{Config as ValidatorStoreConfig, LighthouseValidatorStore};
|
||||
use parking_lot::RwLock;
|
||||
use sensitive_url::SensitiveUrl;
|
||||
use slashing_protection::{SlashingDatabase, SLASHING_PROTECTION_FILENAME};
|
||||
use slashing_protection::{SLASHING_PROTECTION_FILENAME, SlashingDatabase};
|
||||
use slot_clock::{SlotClock, TestingSlotClock};
|
||||
use std::future::Future;
|
||||
use std::net::{IpAddr, Ipv4Addr};
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use task_executor::test_utils::TestRuntime;
|
||||
use tempfile::{tempdir, TempDir};
|
||||
use tempfile::{TempDir, tempdir};
|
||||
use tokio::sync::oneshot;
|
||||
use types::ChainSpec;
|
||||
use validator_services::block_service::BlockService;
|
||||
@@ -370,9 +370,11 @@ impl ApiTester {
|
||||
|
||||
// Ensure the server lists all of these newly created validators.
|
||||
for validator in &response {
|
||||
assert!(server_vals
|
||||
.iter()
|
||||
.any(|server_val| server_val.voting_pubkey == validator.voting_pubkey));
|
||||
assert!(
|
||||
server_vals
|
||||
.iter()
|
||||
.any(|server_val| server_val.voting_pubkey == validator.voting_pubkey)
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -569,16 +571,17 @@ impl ApiTester {
|
||||
enabled
|
||||
);
|
||||
|
||||
assert!(self
|
||||
.client
|
||||
.get_lighthouse_validators()
|
||||
.await
|
||||
.unwrap()
|
||||
.data
|
||||
.into_iter()
|
||||
.find(|v| v.voting_pubkey == validator.voting_pubkey)
|
||||
.map(|v| v.enabled == enabled)
|
||||
.unwrap());
|
||||
assert!(
|
||||
self.client
|
||||
.get_lighthouse_validators()
|
||||
.await
|
||||
.unwrap()
|
||||
.data
|
||||
.into_iter()
|
||||
.find(|v| v.voting_pubkey == validator.voting_pubkey)
|
||||
.map(|v| v.enabled == enabled)
|
||||
.unwrap()
|
||||
);
|
||||
|
||||
// Check the server via an individual request.
|
||||
assert_eq!(
|
||||
|
||||
@@ -13,15 +13,15 @@ use account_utils::{
|
||||
};
|
||||
use deposit_contract::decode_eth1_tx_data;
|
||||
use eth2::{
|
||||
Error as ApiError,
|
||||
lighthouse_vc::{http_client::ValidatorClientHttpClient, types::*},
|
||||
types::ErrorMessage as ApiErrorMessage,
|
||||
Error as ApiError,
|
||||
};
|
||||
use eth2_keystore::KeystoreBuilder;
|
||||
use lighthouse_validator_store::{Config as ValidatorStoreConfig, LighthouseValidatorStore};
|
||||
use parking_lot::RwLock;
|
||||
use sensitive_url::SensitiveUrl;
|
||||
use slashing_protection::{SlashingDatabase, SLASHING_PROTECTION_FILENAME};
|
||||
use slashing_protection::{SLASHING_PROTECTION_FILENAME, SlashingDatabase};
|
||||
use slot_clock::{SlotClock, TestingSlotClock};
|
||||
use std::future::Future;
|
||||
use std::net::{IpAddr, Ipv4Addr};
|
||||
@@ -29,7 +29,7 @@ use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use task_executor::test_utils::TestRuntime;
|
||||
use tempfile::{tempdir, TempDir};
|
||||
use tempfile::{TempDir, tempdir};
|
||||
use types::graffiti::GraffitiString;
|
||||
use validator_store::ValidatorStore;
|
||||
use zeroize::Zeroizing;
|
||||
@@ -330,9 +330,11 @@ impl ApiTester {
|
||||
|
||||
// Ensure the server lists all of these newly created validators.
|
||||
for validator in &response {
|
||||
assert!(server_vals
|
||||
.iter()
|
||||
.any(|server_val| server_val.voting_pubkey == validator.voting_pubkey));
|
||||
assert!(
|
||||
server_vals
|
||||
.iter()
|
||||
.any(|server_val| server_val.voting_pubkey == validator.voting_pubkey)
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -556,16 +558,17 @@ impl ApiTester {
|
||||
enabled
|
||||
);
|
||||
|
||||
assert!(self
|
||||
.client
|
||||
.get_lighthouse_validators()
|
||||
.await
|
||||
.unwrap()
|
||||
.data
|
||||
.into_iter()
|
||||
.find(|v| v.voting_pubkey == validator.voting_pubkey)
|
||||
.map(|v| v.enabled == enabled)
|
||||
.unwrap());
|
||||
assert!(
|
||||
self.client
|
||||
.get_lighthouse_validators()
|
||||
.await
|
||||
.unwrap()
|
||||
.data
|
||||
.into_iter()
|
||||
.find(|v| v.voting_pubkey == validator.voting_pubkey)
|
||||
.map(|v| v.enabled == enabled)
|
||||
.unwrap()
|
||||
);
|
||||
|
||||
// Check the server via an individual request.
|
||||
assert_eq!(
|
||||
|
||||
@@ -9,11 +9,12 @@ use eth2::lighthouse_vc::{
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use lighthouse_validator_store::DEFAULT_GAS_LIMIT;
|
||||
use rand::{rngs::SmallRng, Rng, SeedableRng};
|
||||
use rand::rngs::StdRng;
|
||||
use rand::{Rng, SeedableRng};
|
||||
use slashing_protection::interchange::{Interchange, InterchangeMetadata};
|
||||
use std::{collections::HashMap, path::Path};
|
||||
use tokio::runtime::Handle;
|
||||
use types::{attestation::AttestationBase, Address};
|
||||
use types::{Address, attestation::AttestationBase};
|
||||
use validator_store::ValidatorStore;
|
||||
use zeroize::Zeroizing;
|
||||
|
||||
@@ -1124,11 +1125,14 @@ async fn generic_migration_test(
|
||||
delete_indices.len()
|
||||
);
|
||||
for &i in &delete_indices {
|
||||
assert!(delete_res
|
||||
.slashing_protection
|
||||
.data
|
||||
.iter()
|
||||
.any(|interchange_data| interchange_data.pubkey == keystore_pubkey(&keystores[i])));
|
||||
assert!(
|
||||
delete_res
|
||||
.slashing_protection
|
||||
.data
|
||||
.iter()
|
||||
.any(|interchange_data| interchange_data.pubkey
|
||||
== keystore_pubkey(&keystores[i]))
|
||||
);
|
||||
}
|
||||
|
||||
// Filter slashing protection according to `slashing_protection_indices`.
|
||||
@@ -1324,13 +1328,13 @@ async fn delete_concurrent_with_signing() {
|
||||
let all_pubkeys = all_pubkeys.clone();
|
||||
|
||||
let handle = handle.spawn(async move {
|
||||
let mut rng = SmallRng::from_entropy();
|
||||
let mut rng: StdRng = SeedableRng::from_os_rng();
|
||||
|
||||
let mut slashing_protection = vec![];
|
||||
for _ in 0..num_delete_attempts {
|
||||
let to_delete = all_pubkeys
|
||||
.iter()
|
||||
.filter(|_| rng.gen_bool(delete_prob))
|
||||
.filter(|_| rng.random_bool(delete_prob))
|
||||
.copied()
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user