diff --git a/simlib/mixnet-sims/src/main.rs b/simlib/mixnet-sims/src/main.rs index 5ecb59b..1e9eb91 100644 --- a/simlib/mixnet-sims/src/main.rs +++ b/simlib/mixnet-sims/src/main.rs @@ -22,9 +22,9 @@ use nomos_mix::message_blend::{ }; use parking_lot::Mutex; use rand::prelude::IteratorRandom; -use rand::rngs::SmallRng; use rand::seq::SliceRandom; use rand::{RngCore, SeedableRng}; +use rand_chacha::ChaCha12Rng; use serde::de::DeserializeOwned; use serde::Serialize; // internal @@ -73,7 +73,7 @@ impl SimulationApp { .expect("Time went backwards") .as_secs() }); - let mut rng = SmallRng::seed_from_u64(seed); + let mut rng = ChaCha12Rng::seed_from_u64(seed); let mut node_ids: Vec = (0..settings.simulation_settings.node_count) .map(NodeId::from_index) .collect(); diff --git a/simlib/netrunner/Cargo.toml b/simlib/netrunner/Cargo.toml index 6d8b2fd..cb1838e 100644 --- a/simlib/netrunner/Cargo.toml +++ b/simlib/netrunner/Cargo.toml @@ -28,6 +28,7 @@ serde_with = "2.3" serde_json = "1.0" thiserror = "1" tracing = { version = "0.1", default-features = false, features = ["log", "attributes"] } +rand_chacha = "0.3" [target.'cfg(target_arch = "wasm32")'.dependencies] getrandom = { version = "0.2", features = ["js"] } diff --git a/simlib/netrunner/src/network/mod.rs b/simlib/netrunner/src/network/mod.rs index 925bd55..39fcb16 100644 --- a/simlib/netrunner/src/network/mod.rs +++ b/simlib/netrunner/src/network/mod.rs @@ -12,7 +12,8 @@ use std::{ // crates use crossbeam::channel::{self, Receiver, Sender}; use parking_lot::Mutex; -use rand::{rngs::SmallRng, Rng, SeedableRng}; +use rand::{Rng, SeedableRng}; +use rand_chacha::ChaCha12Rng; use rayon::prelude::*; use serde::{Deserialize, Serialize}; // internal @@ -284,7 +285,7 @@ where .messages .par_iter() .filter(|(network_time, message)| { - let mut rng = SmallRng::seed_from_u64(self.seed); + let mut rng = ChaCha12Rng::seed_from_u64(self.seed); self.send_or_drop_message(&mut rng, network_time, message) }) .cloned() diff --git a/simlib/netrunner/src/runner/mod.rs b/simlib/netrunner/src/runner/mod.rs index f3c6470..016cd24 100644 --- a/simlib/netrunner/src/runner/mod.rs +++ b/simlib/netrunner/src/runner/mod.rs @@ -13,8 +13,8 @@ use crate::streaming::{ }; use crossbeam::channel::Sender; use parking_lot::RwLock; -use rand::rngs::SmallRng; use rand::{RngCore, SeedableRng}; +use rand_chacha::ChaCha12Rng; use rayon::prelude::*; use serde::Serialize; @@ -72,7 +72,7 @@ where { network: Network, wards: Vec, - rng: SmallRng, + rng: ChaCha12Rng, } impl SimulationRunnerInner @@ -136,7 +136,7 @@ where // Store the settings to the producer so that we can collect them later producer.send(R::from(settings.clone()))?; - let rng = SmallRng::seed_from_u64(seed); + let rng = ChaCha12Rng::seed_from_u64(seed); let nodes = Arc::new(RwLock::new(nodes)); let SimulationSettings { wards,