diff --git a/Cargo.lock b/Cargo.lock index bb65a4dec..2b9aa0d9e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5361,7 +5361,6 @@ dependencies = [ "chrono", "clap 2.33.3", "rpassword", - "solana-perf", "solana-remote-wallet", "solana-sdk", "tempfile", @@ -5378,7 +5377,6 @@ dependencies = [ "chrono", "clap 3.2.23", "rpassword", - "solana-perf", "solana-remote-wallet", "solana-sdk", "solana-zk-token-sdk", diff --git a/clap-utils/Cargo.toml b/clap-utils/Cargo.toml index 80f7430cb..7457ca689 100644 --- a/clap-utils/Cargo.toml +++ b/clap-utils/Cargo.toml @@ -13,7 +13,6 @@ edition = { workspace = true } chrono = { workspace = true, features = ["default"] } clap = "2.33.0" rpassword = { workspace = true } -solana-perf = { workspace = true } solana-remote-wallet = { workspace = true } solana-sdk = { workspace = true } thiserror = { workspace = true } diff --git a/clap-utils/src/input_validators.rs b/clap-utils/src/input_validators.rs index ff86e1f10..fbe72d987 100644 --- a/clap-utils/src/input_validators.rs +++ b/clap-utils/src/input_validators.rs @@ -393,25 +393,6 @@ where } } -pub fn is_niceness_adjustment_valid(value: T) -> Result<(), String> -where - T: AsRef + Display, -{ - let adjustment = value - .as_ref() - .parse::() - .map_err(|err| format!("error parsing niceness adjustment value '{value}': {err}"))?; - if solana_perf::thread::is_renice_allowed(adjustment) { - Ok(()) - } else { - Err(String::from( - "niceness adjustment supported only on Linux; negative adjustment \ - (priority increase) requires root or CAP_SYS_NICE (see `man 7 capabilities` \ - for details)", - )) - } -} - pub fn validate_maximum_full_snapshot_archives_to_retain(value: T) -> Result<(), String> where T: AsRef + Display, @@ -456,11 +437,4 @@ mod tests { assert!(is_derivation("a/b").is_err()); assert!(is_derivation("0/4294967296").is_err()); } - - #[test] - fn test_is_niceness_adjustment_valid() { - assert_eq!(is_niceness_adjustment_valid("0"), Ok(())); - assert!(is_niceness_adjustment_valid("128").is_err()); - assert!(is_niceness_adjustment_valid("-129").is_err()); - } } diff --git a/clap-v3-utils/Cargo.toml b/clap-v3-utils/Cargo.toml index 71c1734c5..ad406b3cb 100644 --- a/clap-v3-utils/Cargo.toml +++ b/clap-v3-utils/Cargo.toml @@ -13,7 +13,6 @@ edition = { workspace = true } chrono = { workspace = true, features = ["default"] } clap = { version = "3.2.23", features = ["cargo"] } rpassword = { workspace = true } -solana-perf = { workspace = true } solana-remote-wallet = { workspace = true } solana-sdk = { workspace = true } solana-zk-token-sdk = { workspace = true } diff --git a/clap-v3-utils/src/input_validators.rs b/clap-v3-utils/src/input_validators.rs index 33888a914..76c780d3f 100644 --- a/clap-v3-utils/src/input_validators.rs +++ b/clap-v3-utils/src/input_validators.rs @@ -387,25 +387,6 @@ where } } -pub fn is_niceness_adjustment_valid(value: T) -> Result<(), String> -where - T: AsRef + Display, -{ - let adjustment = value - .as_ref() - .parse::() - .map_err(|err| format!("error parsing niceness adjustment value '{value}': {err}"))?; - if solana_perf::thread::is_renice_allowed(adjustment) { - Ok(()) - } else { - Err(String::from( - "niceness adjustment supported only on Linux; negative adjustment \ - (priority increase) requires root or CAP_SYS_NICE (see `man 7 capabilities` \ - for details)", - )) - } -} - #[cfg(test)] mod tests { use super::*; @@ -422,11 +403,4 @@ mod tests { assert!(is_derivation("a/b").is_err()); assert!(is_derivation("0/4294967296").is_err()); } - - #[test] - fn test_is_niceness_adjustment_valid() { - assert_eq!(is_niceness_adjustment_valid("0"), Ok(())); - assert!(is_niceness_adjustment_valid("128").is_err()); - assert!(is_niceness_adjustment_valid("-129").is_err()); - } } diff --git a/perf/src/thread.rs b/perf/src/thread.rs index 6090b8de6..3e9f307ec 100644 --- a/perf/src/thread.rs +++ b/perf/src/thread.rs @@ -1,3 +1,5 @@ +use std::fmt::Display; + /// Wrapper for `nice(3)`. #[cfg(target_os = "linux")] fn nice(adjustment: i8) -> Result { @@ -67,6 +69,25 @@ pub fn is_renice_allowed(adjustment: i8) -> bool { adjustment == 0 } +pub fn is_niceness_adjustment_valid(value: T) -> Result<(), String> +where + T: AsRef + Display, +{ + let adjustment = value + .as_ref() + .parse::() + .map_err(|err| format!("error parsing niceness adjustment value '{value}': {err}"))?; + if is_renice_allowed(adjustment) { + Ok(()) + } else { + Err(String::from( + "niceness adjustment supported only on Linux; negative adjustment \ + (priority increase) requires root or CAP_SYS_NICE (see `man 7 capabilities` \ + for details)", + )) + } +} + #[cfg(test)] mod tests { #[cfg(target_os = "linux")] @@ -101,4 +122,11 @@ mod tests { assert!(result.is_err()); } } + + #[test] + fn test_is_niceness_adjustment_valid() { + assert_eq!(is_niceness_adjustment_valid("0"), Ok(())); + assert!(is_niceness_adjustment_valid("128").is_err()); + assert!(is_niceness_adjustment_valid("-129").is_err()); + } } diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index 06a4e2cf9..c47a5e138 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -4613,7 +4613,6 @@ dependencies = [ "chrono", "clap 2.33.3", "rpassword", - "solana-perf", "solana-remote-wallet", "solana-sdk", "thiserror", diff --git a/validator/src/cli.rs b/validator/src/cli.rs index 6d11ecc79..9ae0f1583 100644 --- a/validator/src/cli.rs +++ b/validator/src/cli.rs @@ -6,9 +6,8 @@ use { solana_clap_utils::{ hidden_unless_forced, input_validators::{ - is_keypair, is_keypair_or_ask_keyword, is_niceness_adjustment_valid, is_parsable, - is_pow2, is_pubkey, is_pubkey_or_keypair, is_slot, is_url_or_moniker, - is_valid_percentage, is_within_range, + is_keypair, is_keypair_or_ask_keyword, is_parsable, is_pow2, is_pubkey, + is_pubkey_or_keypair, is_slot, is_url_or_moniker, is_valid_percentage, is_within_range, validate_maximum_full_snapshot_archives_to_retain, validate_maximum_incremental_snapshot_archives_to_retain, }, @@ -485,7 +484,7 @@ pub fn app<'a>(version: &'a str, default_args: &'a DefaultArgs) -> App<'a, 'a> { .long("snapshot-packager-niceness-adjustment") .value_name("ADJUSTMENT") .takes_value(true) - .validator(is_niceness_adjustment_valid) + .validator(solana_perf::thread::is_niceness_adjustment_valid) .default_value(&default_args.snapshot_packager_niceness_adjustment) .help("Add this value to niceness of snapshot packager thread. Negative value \ increases priority, positive value decreases priority.") @@ -840,7 +839,7 @@ pub fn app<'a>(version: &'a str, default_args: &'a DefaultArgs) -> App<'a, 'a> { .long("rpc-niceness-adjustment") .value_name("ADJUSTMENT") .takes_value(true) - .validator(is_niceness_adjustment_valid) + .validator(solana_perf::thread::is_niceness_adjustment_valid) .default_value(&default_args.rpc_niceness_adjustment) .help("Add this value to niceness of RPC threads. Negative value \ increases priority, positive value decreases priority.")