diff --git a/Cargo.lock b/Cargo.lock index d5e4763e0d..21ef2cbf83 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1046,6 +1046,7 @@ dependencies = [ "criterion", "crossbeam-channel", "fxhash", + "getrandom 0.4.2", "hex", "hex-literal", "imbl", diff --git a/Cargo.toml b/Cargo.toml index 0ae64888a1..899c00bd70 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,6 +35,7 @@ fxhash = "0.2.1" crossbeam-channel = "0.5.15" slab = "0.4.9" rand = "0.10.1" +getrandom = { version = "0.4.2", default-features = false } imbl = "3.0.0" lru = "0.18.0" libc = "0.2.155" diff --git a/benchtop/Cargo.lock b/benchtop/Cargo.lock index 27b98a1927..fa31e9bdb0 100644 --- a/benchtop/Cargo.lock +++ b/benchtop/Cargo.lock @@ -2177,6 +2177,7 @@ dependencies = [ "cfg-if", "crossbeam-channel", "fxhash", + "getrandom 0.4.2", "imbl", "io-uring", "libc", @@ -2184,7 +2185,6 @@ dependencies = [ "lru", "nomt-core", "parking_lot", - "rand 0.10.1", "slab", "thread_local", "threadpool", diff --git a/nomt/Cargo.toml b/nomt/Cargo.toml index 437e740b19..75399bd43c 100644 --- a/nomt/Cargo.toml +++ b/nomt/Cargo.toml @@ -20,7 +20,8 @@ twox-hash.workspace = true fxhash.workspace = true crossbeam-channel.workspace = true slab.workspace = true -rand.workspace = true +rand = { workspace = true, optional = true } +getrandom.workspace = true imbl.workspace = true lru.workspace = true libc.workspace = true @@ -36,6 +37,7 @@ io-uring.workspace = true loom.workspace = true [dev-dependencies] +rand.workspace = true rand_pcg.workspace = true hex-literal.workspace = true tempfile.workspace = true @@ -54,7 +56,7 @@ harness = false [features] default = ["blake3-hasher", "sha2-hasher"] -benchmarks = ["dep:criterion"] +benchmarks = ["dep:criterion", "dep:rand"] fuzz = [] borsh = ["dep:borsh", "nomt-core/borsh"] blake3-hasher = ["nomt-core/blake3-hasher"] diff --git a/nomt/src/options.rs b/nomt/src/options.rs index c0f9a1436e..af96bcfd55 100644 --- a/nomt/src/options.rs +++ b/nomt/src/options.rs @@ -36,7 +36,8 @@ pub struct Options { impl Options { /// Create a new `Options` instance with the default values and a random bitbox seed. pub fn new() -> Self { - let bitbox_seed: [u8; 16] = rand::random(); + let mut bitbox_seed = [0; 16]; + getrandom::fill(&mut bitbox_seed).expect("failed to generate bitbox seed"); Self { path: PathBuf::from("nomt_db"),