diff --git a/Cargo.lock b/Cargo.lock index 06d86e1eefb..7829228449b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4192,7 +4192,6 @@ dependencies = [ "log", "mach", "nix 0.26.4", - "once_cell", "region", "sp-wasm-interface", "winapi", @@ -4236,7 +4235,6 @@ dependencies = [ "gear-wasm-gen", "gsdk", "names 0.14.0", - "once_cell", "parking_lot 0.12.1", "primitive-types", "rand 0.8.5", @@ -4401,7 +4399,6 @@ dependencies = [ "environmental", "gear-sandbox-env", "log", - "once_cell", "parity-scale-codec", "sp-allocator", "sp-wasm-interface", diff --git a/lazy-pages/Cargo.toml b/lazy-pages/Cargo.toml index 72e8af962a1..2a29d357a81 100644 --- a/lazy-pages/Cargo.toml +++ b/lazy-pages/Cargo.toml @@ -14,7 +14,6 @@ sp-wasm-interface = { workspace = true, features = ["std"] } cfg-if.workspace = true region.workspace = true derive_more.workspace = true -once_cell.workspace = true gear-sandbox-host.workspace = true gear-core.workspace = true diff --git a/lazy-pages/src/init_flag.rs b/lazy-pages/src/init_flag.rs index 4e1b490ce42..f4d7884ce22 100644 --- a/lazy-pages/src/init_flag.rs +++ b/lazy-pages/src/init_flag.rs @@ -19,13 +19,13 @@ #[cfg(not(test))] mod not_tests { use crate::InitError; - use once_cell::sync::OnceCell; + use std::sync::OnceLock; - pub struct InitializationFlag(OnceCell>); + pub struct InitializationFlag(OnceLock>); impl InitializationFlag { pub const fn new() -> Self { - Self(OnceCell::new()) + Self(OnceLock::new()) } pub fn get_or_init( diff --git a/lazy-pages/src/sys/unix.rs b/lazy-pages/src/sys/unix.rs index 90b08abde5c..df0fe9fcab8 100644 --- a/lazy-pages/src/sys/unix.rs +++ b/lazy-pages/src/sys/unix.rs @@ -27,8 +27,7 @@ use nix::{ libc::{c_void, siginfo_t}, sys::{signal, signal::SigHandler}, }; -use once_cell::sync::OnceCell; -use std::io; +use std::{io, sync::OnceLock}; /// Signal handler which has been set before lazy-pages initialization. /// Currently use to support wasmer signal handler. @@ -37,7 +36,7 @@ use std::io; /// see https://github.com/gear-tech/substrate/blob/gear-stable/client/executor/common/src/sandbox/wasmer_backend.rs /// and https://github.com/wasmerio/wasmer/blob/e6857d116134bdc9ab6a1dabc3544cf8e6aee22b/lib/vm/src/trap/traphandlers.rs#L548 /// So, if we receive signal from unknown memory we should try to use old (wasmer) signal handler. -static mut OLD_SIG_HANDLER: OnceCell = OnceCell::new(); +static OLD_SIG_HANDLER: OnceLock = OnceLock::new(); cfg_if! { if #[cfg(all(target_os = "linux", target_arch = "x86_64"))] { diff --git a/sandbox/host/Cargo.toml b/sandbox/host/Cargo.toml index d2cdb363668..99b8c0770a0 100644 --- a/sandbox/host/Cargo.toml +++ b/sandbox/host/Cargo.toml @@ -24,7 +24,6 @@ sp-allocator = { workspace = true, features = ["std"] } sp-wasm-interface = { workspace = true, features = ["std"] } gear-sandbox-env = { workspace = true, features = ["std"] } wasmer-cache = { workspace = true, optional = true } -once_cell.workspace = true tempfile.workspace = true [features] diff --git a/sandbox/host/src/sandbox/wasmer_backend.rs b/sandbox/host/src/sandbox/wasmer_backend.rs index 15f18e9a693..a0bd58cff3d 100644 --- a/sandbox/host/src/sandbox/wasmer_backend.rs +++ b/sandbox/host/src/sandbox/wasmer_backend.rs @@ -46,15 +46,15 @@ enum CachedModuleErr { #[cfg(feature = "wasmer-cache")] use { - once_cell::sync::OnceCell, sandbox_wasmer::Module, + std::sync::OnceLock, tempfile::TempDir, wasmer_cache::{Cache, FileSystemCache, Hash}, CachedModuleErr::*, }; #[cfg(feature = "wasmer-cache")] -static CACHE_DIR: OnceCell = OnceCell::new(); +static CACHE_DIR: OnceLock = OnceLock::new(); /// Wasmer specific context pub struct Backend { diff --git a/utils/node-loader/Cargo.toml b/utils/node-loader/Cargo.toml index 9eebd6bbcee..fa7795ad9f4 100644 --- a/utils/node-loader/Cargo.toml +++ b/utils/node-loader/Cargo.toml @@ -24,7 +24,6 @@ clap = { workspace = true, features = ["derive"] } futures.workspace = true futures-timer.workspace = true names = "0.14.0" -once_cell.workspace = true parking_lot.workspace = true primitive-types = { workspace = true, features = ["scale-info"] } rand = { workspace = true, features = ["small_rng"] } diff --git a/utils/node-loader/src/batch_pool/api/nonce.rs b/utils/node-loader/src/batch_pool/api/nonce.rs index 44a0e4fdd66..70c622596cd 100644 --- a/utils/node-loader/src/batch_pool/api/nonce.rs +++ b/utils/node-loader/src/batch_pool/api/nonce.rs @@ -1,16 +1,18 @@ use crate::utils; use anyhow::{anyhow, Result}; use gclient::{Error as GClientError, Result as GClientResult}; -use once_cell::sync::OnceCell; use parking_lot::{Mutex, MutexGuard}; use std::{ cmp::Reverse, collections::BinaryHeap, - sync::atomic::{AtomicU64, Ordering}, + sync::{ + atomic::{AtomicU64, Ordering}, + OnceLock, + }, }; -pub static AVAILABLE_NONCE: OnceCell = OnceCell::new(); -pub static MISSED_NONCES: OnceCell> = OnceCell::new(); +pub static AVAILABLE_NONCE: OnceLock = OnceLock::new(); +pub static MISSED_NONCES: OnceLock> = OnceLock::new(); pub type MinHeap = BinaryHeap>; type MissedNoncesGuard<'a> = MutexGuard<'a, MinHeap>; diff --git a/utils/wasm-builder/src/cargo_toolchain.rs b/utils/wasm-builder/src/cargo_toolchain.rs index a0cdad14398..40a985593c7 100644 --- a/utils/wasm-builder/src/cargo_toolchain.rs +++ b/utils/wasm-builder/src/cargo_toolchain.rs @@ -59,6 +59,7 @@ impl Toolchain { .and_then(|s| std::str::from_utf8(s).ok()) .expect("unexpected `rustup` output"); + // TODO #3499: replace it with `std::sync::LazyLock` when it becomes stable static TOOLCHAIN_CHANNEL_RE: Lazy = Lazy::new(|| { // This regex is borrowed from the rustup code and modified (added non-capturing groups) let pattern = format!(