Update Rust Edition to 2024 (#7766)

* #7749

Thanks @dknopik and @michaelsproul for your help!
This commit is contained in:
chonghe
2025-08-13 11:04:31 +08:00
committed by GitHub
parent bd6b8b6a65
commit 522bd9e9c6
468 changed files with 3594 additions and 3396 deletions

View File

@@ -1,13 +1,13 @@
use account_utils::strip_off_newlines;
pub use account_utils::STDIN_INPUTS_FLAG;
use account_utils::strip_off_newlines;
use eth2::lighthouse_vc::std_types::{InterchangeJsonStr, KeystoreJsonStr};
use eth2::{
SensitiveUrl,
lighthouse_vc::{
http_client::ValidatorClientHttpClient,
std_types::{ImportKeystoreStatus, ImportKeystoresRequest, SingleKeystoreResponse, Status},
types::UpdateFeeRecipientRequest,
},
SensitiveUrl,
};
use serde::{Deserialize, Serialize};
use std::fs;

View File

@@ -4,9 +4,9 @@ use account_utils::{random_password_string, read_mnemonic_from_cli, read_passwor
use clap::{Arg, ArgAction, ArgMatches, Command};
use clap_utils::FLAG_HEADER;
use eth2::{
BeaconNodeHttpClient, SensitiveUrl, Timeouts,
lighthouse_vc::std_types::KeystoreJsonStr,
types::{StateId, ValidatorId},
BeaconNodeHttpClient, SensitiveUrl, Timeouts,
};
use eth2_wallet::WalletBuilder;
use serde::{Deserialize, Serialize};
@@ -439,17 +439,16 @@ impl ValidatorsAndDeposits {
different validator clients. If you understand the risks and are certain you \
wish to generate this validator again, omit the --{} flag.",
voting_public_key, derivation_index, BEACON_NODE_FLAG
))?
))?;
}
Ok(None) => {
eprintln!("{:?} was not found in the beacon chain", voting_public_key)
}
Ok(None) => eprintln!(
"{:?} was not found in the beacon chain",
voting_public_key
),
Err(e) => {
return Err(format!(
"Error checking if validator exists in beacon chain: {:?}",
e
))
));
}
}
}
@@ -591,7 +590,7 @@ pub mod tests {
use regex::Regex;
use std::path::Path;
use std::str::FromStr;
use tempfile::{tempdir, TempDir};
use tempfile::{TempDir, tempdir};
use tree_hash::TreeHash;
type E = MainnetEthSpec;

View File

@@ -1,13 +1,13 @@
use clap::{Arg, ArgAction, ArgMatches, Command};
use eth2::{
lighthouse_vc::types::{DeleteKeystoreStatus, DeleteKeystoresRequest},
SensitiveUrl,
lighthouse_vc::types::{DeleteKeystoreStatus, DeleteKeystoresRequest},
};
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
use types::PublicKeyBytes;
use crate::{common::vc_http_client, DumpConfig};
use crate::{DumpConfig, common::vc_http_client};
pub const CMD: &str = "delete";
pub const VC_URL_FLAG: &str = "vc-url";
@@ -160,7 +160,7 @@ mod test {
use crate::{
common::ValidatorSpecification, import_validators::tests::TestBuilder as ImportTestBuilder,
};
use validator_http_api::{test_utils::ApiTester, Config as HttpConfig};
use validator_http_api::{Config as HttpConfig, test_utils::ApiTester};
struct TestBuilder {
delete_config: Option<DeleteConfig>,

View File

@@ -1,4 +1,4 @@
use crate::{common::vc_http_client, DumpConfig};
use crate::{DumpConfig, common::vc_http_client};
use clap::{Arg, ArgAction, ArgMatches, Command};
use clap_utils::FLAG_HEADER;
@@ -302,7 +302,7 @@ mod test {
sync::Arc,
};
use types::{ChainSpec, MainnetEthSpec};
use validator_http_api::{test_utils::ApiTester, Config as HttpConfig};
use validator_http_api::{Config as HttpConfig, test_utils::ApiTester};
use zeroize::Zeroizing;
type E = MainnetEthSpec;
@@ -533,13 +533,17 @@ mod test {
let beacon_exit_epoch = current_epoch + 1 + max_seed_lookahead;
let beacon_withdrawable_epoch = beacon_exit_epoch + min_withdrawability_delay;
assert!(validator_exit_epoch
.iter()
.all(|&epoch| epoch == beacon_exit_epoch));
assert!(
validator_exit_epoch
.iter()
.all(|&epoch| epoch == beacon_exit_epoch)
);
assert!(validator_withdrawable_epoch
.iter()
.all(|&epoch| epoch == beacon_withdrawable_epoch));
assert!(
validator_withdrawable_epoch
.iter()
.all(|&epoch| epoch == beacon_withdrawable_epoch)
);
if result.is_ok() {
return TestResult { result: Ok(()) };

View File

@@ -5,7 +5,7 @@ use clap::{Arg, ArgAction, ArgMatches, Command};
use clap_utils::FLAG_HEADER;
use derivative::Derivative;
use eth2::lighthouse_vc::types::KeystoreJsonStr;
use eth2::{lighthouse_vc::std_types::ImportKeystoreStatus, SensitiveUrl};
use eth2::{SensitiveUrl, lighthouse_vc::std_types::ImportKeystoreStatus};
use serde::{Deserialize, Serialize};
use std::fs;
use std::path::PathBuf;
@@ -279,38 +279,38 @@ async fn run(config: ImportConfig) -> Result<(), String> {
for (i, validator) in validators.into_iter().enumerate() {
match validator.upload(&http_client, ignore_duplicates).await {
Ok(status) => {
match status.status {
ImportKeystoreStatus::Imported => {
eprintln!("Uploaded keystore {} of {} to the VC", i + 1, count)
}
ImportKeystoreStatus::Duplicate => {
if ignore_duplicates {
eprintln!("Re-uploaded keystore {} of {} to the VC", i + 1, count)
} else {
eprintln!(
"Keystore {} of {} was uploaded to the VC, but it was a duplicate. \
Exiting now, use --{} to allow duplicates.",
i + 1, count, IGNORE_DUPLICATES_FLAG
);
return Err(DETECTED_DUPLICATE_MESSAGE.to_string());
}
}
ImportKeystoreStatus::Error => {
Ok(status) => match status.status {
ImportKeystoreStatus::Imported => {
eprintln!("Uploaded keystore {} of {} to the VC", i + 1, count)
}
ImportKeystoreStatus::Duplicate => {
if ignore_duplicates {
eprintln!("Re-uploaded keystore {} of {} to the VC", i + 1, count)
} else {
eprintln!(
"Upload of keystore {} of {} failed with message: {:?}. \
"Keystore {} of {} was uploaded to the VC, but it was a duplicate. \
Exiting now, use --{} to allow duplicates.",
i + 1,
count,
IGNORE_DUPLICATES_FLAG
);
return Err(DETECTED_DUPLICATE_MESSAGE.to_string());
}
}
ImportKeystoreStatus::Error => {
eprintln!(
"Upload of keystore {} of {} failed with message: {:?}. \
A potential solution is run this command again \
using the --{} flag, however care should be taken to ensure \
that there are no duplicate deposits submitted.",
i + 1,
count,
status.message,
IGNORE_DUPLICATES_FLAG
);
return Err(format!("Upload failed with {:?}", status.message));
}
i + 1,
count,
status.message,
IGNORE_DUPLICATES_FLAG
);
return Err(format!("Upload failed with {:?}", status.message));
}
}
},
e @ Err(UploadError::InvalidPublicKey) => {
eprintln!("Validator {} has an invalid public key", i);
return Err(format!("{:?}", e));
@@ -384,8 +384,8 @@ pub mod tests {
use super::*;
use crate::create_validators::tests::TestBuilder as CreateTestBuilder;
use std::fs::{self, File};
use tempfile::{tempdir, TempDir};
use validator_http_api::{test_utils::ApiTester, Config as HttpConfig};
use tempfile::{TempDir, tempdir};
use validator_http_api::{Config as HttpConfig, test_utils::ApiTester};
const VC_TOKEN_FILE_NAME: &str = "vc_token.json";

View File

@@ -8,7 +8,7 @@ use std::time::Duration;
use types::{ChainSpec, EthSpec, PublicKeyBytes};
use crate::exit_validators::get_current_epoch;
use crate::{common::vc_http_client, DumpConfig};
use crate::{DumpConfig, common::vc_http_client};
pub const CMD: &str = "list";
pub const VC_URL_FLAG: &str = "vc-url";
@@ -224,7 +224,7 @@ mod test {
common::ValidatorSpecification, import_validators::tests::TestBuilder as ImportTestBuilder,
};
use types::MainnetEthSpec;
use validator_http_api::{test_utils::ApiTester, Config as HttpConfig};
use validator_http_api::{Config as HttpConfig, test_utils::ApiTester};
type E = MainnetEthSpec;
struct TestBuilder {

View File

@@ -3,6 +3,7 @@ use crate::DumpConfig;
use account_utils::read_password_from_user;
use clap::{Arg, ArgAction, ArgMatches, Command};
use eth2::{
SensitiveUrl,
lighthouse_vc::{
std_types::{
DeleteKeystoreStatus, DeleteKeystoresRequest, ImportKeystoreStatus, InterchangeJsonStr,
@@ -10,7 +11,6 @@ use eth2::{
},
types::{ExportKeystoresResponse, SingleExportKeystoresResponse},
},
SensitiveUrl,
};
use serde::{Deserialize, Serialize};
use std::collections::{HashMap, HashSet};
@@ -458,8 +458,7 @@ async fn run(config: MoveConfig) -> Result<(), String> {
Err(e) => {
eprintln!(
"Retrying after error: {:?}. If this error persists the user will need to \
manually recover their keystore for validator {:?} from the mnemonic."
,
manually recover their keystore for validator {:?} from the mnemonic.",
e, pubkey_to_move
);
}
@@ -668,8 +667,8 @@ mod test {
use crate::import_validators::tests::TestBuilder as ImportTestBuilder;
use account_utils::validator_definitions::SigningDefinition;
use std::fs;
use tempfile::{tempdir, TempDir};
use validator_http_api::{test_utils::ApiTester, Config as HttpConfig};
use tempfile::{TempDir, tempdir};
use validator_http_api::{Config as HttpConfig, test_utils::ApiTester};
const SRC_VC_TOKEN_FILE_NAME: &str = "src_vc_token.json";
const DEST_VC_TOKEN_FILE_NAME: &str = "dest_vc_token.json";
@@ -901,13 +900,13 @@ mod test {
);
if self.reuse_password_files.is_some() {
assert!(
src_vc
.secrets_dir
.path()
.join(format!("{:?}", pubkey))
.exists(),
"the source password file was used by another validator and should not be deleted"
)
src_vc
.secrets_dir
.path()
.join(format!("{:?}", pubkey))
.exists(),
"the source password file was used by another validator and should not be deleted"
)
} else {
assert!(
!src_vc