diff --git a/Cargo.lock b/Cargo.lock index 27c50c07475220..2f46b23e538d3e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5173,7 +5173,6 @@ dependencies = [ "num-traits", "num_cpus", "num_enum 0.6.1", - "once_cell", "ouroboros", "percentage", "qualifier_attr", @@ -5937,7 +5936,6 @@ dependencies = [ "lazy_static", "log", "memmap2", - "once_cell", "rustc_version 0.4.0", "serde", "serde_bytes", @@ -6854,7 +6852,6 @@ dependencies = [ "num-traits", "num_cpus", "num_enum 0.6.1", - "once_cell", "ouroboros", "percentage", "rand 0.8.5", diff --git a/Cargo.toml b/Cargo.toml index f1ee5fd826412b..1971c42658cfc3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -243,7 +243,6 @@ num_cpus = "1.16.0" num_enum = "0.6.1" num-derive = "0.3" num-traits = "0.2" -once_cell = "1.18.0" openssl = "0.10" ouroboros = "0.15.6" parking_lot = "0.12" diff --git a/accounts-db/Cargo.toml b/accounts-db/Cargo.toml index b53e1d15efe72a..2e2685b901bb5c 100644 --- a/accounts-db/Cargo.toml +++ b/accounts-db/Cargo.toml @@ -36,7 +36,6 @@ num-derive = { workspace = true } num-traits = { workspace = true } num_cpus = { workspace = true } num_enum = { workspace = true } -once_cell = { workspace = true } ouroboros = { workspace = true } percentage = { workspace = true } qualifier_attr = { workspace = true } diff --git a/accounts-db/src/accounts_index.rs b/accounts-db/src/accounts_index.rs index 916a641723f79f..b9038441d12515 100644 --- a/accounts-db/src/accounts_index.rs +++ b/accounts-db/src/accounts_index.rs @@ -13,7 +13,6 @@ use { secondary_index::*, }, log::*, - once_cell::sync::OnceCell, ouroboros::self_referencing, rand::{thread_rng, Rng}, rayon::{ @@ -37,7 +36,7 @@ use { path::PathBuf, sync::{ atomic::{AtomicBool, AtomicU64, AtomicU8, AtomicUsize, Ordering}, - Arc, Mutex, RwLock, RwLockReadGuard, RwLockWriteGuard, + Arc, Mutex, OnceLock, RwLock, RwLockReadGuard, RwLockWriteGuard, }, }, thiserror::Error, @@ -703,7 +702,7 @@ pub struct AccountsIndex + Into> { pub max_distance_to_min_scan_slot: AtomicU64, /// populated at generate_index time - accounts that could possibly be rent paying - pub rent_paying_accounts_by_partition: OnceCell, + pub rent_paying_accounts_by_partition: OnceLock, } impl + Into> AccountsIndex { @@ -737,7 +736,7 @@ impl + Into> AccountsIndex { roots_removed: AtomicUsize::default(), active_scans: AtomicUsize::default(), max_distance_to_min_scan_slot: AtomicU64::default(), - rent_paying_accounts_by_partition: OnceCell::default(), + rent_paying_accounts_by_partition: OnceLock::default(), } } diff --git a/accounts-db/src/tiered_storage.rs b/accounts-db/src/tiered_storage.rs index 5ced4d537b981d..65d3485dccb064 100644 --- a/accounts-db/src/tiered_storage.rs +++ b/accounts-db/src/tiered_storage.rs @@ -19,13 +19,13 @@ use { error::TieredStorageError, footer::{AccountBlockFormat, AccountMetaFormat, OwnersBlockFormat}, index::AccountIndexFormat, - once_cell::sync::OnceCell, readable::TieredStorageReader, solana_sdk::{account::ReadableAccount, hash::Hash}, std::{ borrow::Borrow, fs::OpenOptions, path::{Path, PathBuf}, + sync::OnceLock, }, writer::TieredStorageWriter, }; @@ -45,7 +45,7 @@ pub struct TieredStorageFormat { #[derive(Debug)] pub struct TieredStorage { - reader: OnceCell, + reader: OnceLock, format: Option, path: PathBuf, } @@ -66,7 +66,7 @@ impl TieredStorage { /// is called. pub fn new_writable(path: impl Into, format: TieredStorageFormat) -> Self { Self { - reader: OnceCell::::new(), + reader: OnceLock::::new(), format: Some(format), path: path.into(), } @@ -77,7 +77,7 @@ impl TieredStorage { pub fn new_readonly(path: impl Into) -> TieredStorageResult { let path = path.into(); Ok(Self { - reader: OnceCell::with_value(TieredStorageReader::new_from_path(&path)?), + reader: TieredStorageReader::new_from_path(&path).map(OnceLock::from)?, format: None, path, }) diff --git a/frozen-abi/Cargo.toml b/frozen-abi/Cargo.toml index 3cd9ef73447fd3..3121b6968ebdf5 100644 --- a/frozen-abi/Cargo.toml +++ b/frozen-abi/Cargo.toml @@ -14,7 +14,6 @@ bs58 = { workspace = true } bv = { workspace = true, features = ["serde"] } lazy_static = { workspace = true } log = { workspace = true, features = ["std"] } -once_cell = { workspace = true } serde = { workspace = true, features = ["derive", "rc"] } serde_bytes = { workspace = true } serde_derive = { workspace = true } @@ -32,7 +31,6 @@ either = { workspace = true, features = ["use_std"] } generic-array = { workspace = true, features = ["serde", "more_lengths"] } im = { workspace = true, features = ["rayon", "serde"] } memmap2 = { workspace = true } -once_cell = { workspace = true, features = ["alloc", "race"] } subtle = { workspace = true } [target.'cfg(any(unix, windows))'.dependencies] diff --git a/frozen-abi/src/abi_example.rs b/frozen-abi/src/abi_example.rs index 6ac6804861fd67..c7765c4a573544 100644 --- a/frozen-abi/src/abi_example.rs +++ b/frozen-abi/src/abi_example.rs @@ -555,9 +555,3 @@ impl AbiEnumVisitor for Result { digester.create_child() } } - -impl AbiExample for once_cell::sync::OnceCell { - fn example() -> Self { - Self::with_value(T::example()) - } -} diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index 895200bce4c5e1..bc743d1bf0aa77 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -4496,7 +4496,6 @@ dependencies = [ "num-traits", "num_cpus", "num_enum 0.6.1", - "once_cell", "ouroboros", "percentage", "qualifier_attr", @@ -4942,7 +4941,6 @@ dependencies = [ "lazy_static", "log", "memmap2", - "once_cell", "rustc_version", "serde", "serde_bytes", @@ -5548,7 +5546,6 @@ dependencies = [ "num-traits", "num_cpus", "num_enum 0.6.1", - "once_cell", "ouroboros", "percentage", "rand 0.8.5", diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index cfc8b65496a79a..238d5dfb36653d 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -37,7 +37,6 @@ num-derive = { workspace = true } num-traits = { workspace = true } num_cpus = { workspace = true } num_enum = { workspace = true } -once_cell = { workspace = true } ouroboros = { workspace = true } percentage = { workspace = true } rand = { workspace = true } diff --git a/runtime/src/vote_account.rs b/runtime/src/vote_account.rs index efbddb40ef3b08..93789e3eed87af 100644 --- a/runtime/src/vote_account.rs +++ b/runtime/src/vote_account.rs @@ -1,6 +1,7 @@ +#[cfg(RUSTC_WITH_SPECIALIZATION)] +use solana_frozen_abi::abi_example::AbiExample; use { itertools::Itertools, - once_cell::sync::OnceCell, serde::ser::{Serialize, Serializer}, solana_sdk::{ account::{AccountSharedData, ReadableAccount}, @@ -12,7 +13,7 @@ use { cmp::Ordering, collections::{hash_map::Entry, HashMap}, iter::FromIterator, - sync::Arc, + sync::{Arc, OnceLock}, }, thiserror::Error, }; @@ -29,20 +30,20 @@ pub enum Error { InvalidOwner(/*owner:*/ Pubkey), } -#[derive(Debug, AbiExample)] +#[derive(Debug)] struct VoteAccountInner { account: AccountSharedData, - vote_state: OnceCell>, + vote_state: OnceLock>, } pub type VoteAccountsHashMap = HashMap; -#[derive(Clone, Debug, AbiExample, Deserialize)] +#[derive(Clone, Debug, Deserialize)] #[serde(from = "Arc")] pub struct VoteAccounts { vote_accounts: Arc, // Inner Arc is meant to implement copy-on-write semantics. - staked_nodes: OnceCell< + staked_nodes: OnceLock< Arc< HashMap< Pubkey, // VoteAccount.vote_state.node_pubkey. @@ -243,7 +244,7 @@ impl TryFrom for VoteAccountInner { } Ok(Self { account, - vote_state: OnceCell::new(), + vote_state: OnceLock::new(), }) } } @@ -262,7 +263,7 @@ impl Default for VoteAccounts { fn default() -> Self { Self { vote_accounts: Arc::default(), - staked_nodes: OnceCell::new(), + staked_nodes: OnceLock::new(), } } } @@ -281,7 +282,7 @@ impl From> for VoteAccounts { fn from(vote_accounts: Arc) -> Self { Self { vote_accounts, - staked_nodes: OnceCell::new(), + staked_nodes: OnceLock::new(), } } } @@ -316,6 +317,26 @@ impl Serialize for VoteAccounts { } } +#[cfg(RUSTC_WITH_SPECIALIZATION)] +impl AbiExample for VoteAccountInner { + fn example() -> Self { + Self { + account: AccountSharedData::example(), + vote_state: OnceLock::from(Result::::example()), + } + } +} + +#[cfg(RUSTC_WITH_SPECIALIZATION)] +impl AbiExample for VoteAccounts { + fn example() -> Self { + Self { + vote_accounts: Arc::::example(), + staked_nodes: OnceLock::from(Arc::>::example()), + } + } +} + #[cfg(test)] mod tests { use {