Skip to content

update rand to 0.9 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
387 changes: 254 additions & 133 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ env_logger = "0.11"
futures = "0.3.30"
futures-bounded = { version = "0.2.4" }
futures-rustls = { version = "0.26.0", default-features = false }
getrandom = "0.2"
getrandom = "0.3"
if-watch = "3.2.1"
hickory-proto = { version = "0.25.0-alpha.4", default-features = false }
hickory-resolver = { version = "0.25.0-alpha.4", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ multistream-select = { workspace = true }
parking_lot = "0.12.3"
pin-project = "1.1.5"
quick-protobuf = "0.8"
rand = "0.8"
rand = "0.9"
rw-stream-sink = { workspace = true }
thiserror = { workspace = true }
tracing = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion examples/autonatv2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ clap = { version = "4.4.18", features = ["derive"] }
tokio = { version = "1.35.1", features = ["macros", "rt-multi-thread"] }
tracing = "0.1.40"
tracing-subscriber = { workspace = true, features = ["env-filter"] }
rand = "0.8.5"
rand = "0.9"
opentelemetry_sdk = { version = "0.21.1", optional = true, features = ["rt-tokio"] }
tracing-opentelemetry = { version = "0.22.0", optional = true }
opentelemetry-jaeger = { version = "0.20.0", optional = true, features = ["rt-tokio"] }
Expand Down
2 changes: 1 addition & 1 deletion examples/browser-webrtc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ crate-type = ["cdylib"]
[dependencies]
anyhow = "1.0.86"
futures = { workspace = true }
rand = "0.8"
rand = "0.9"
tracing = { workspace = true }
tracing-subscriber = { workspace = true, features = ["env-filter"] }

Expand Down
4 changes: 2 additions & 2 deletions examples/browser-webrtc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use libp2p::{
swarm::SwarmEvent,
};
use libp2p_webrtc as webrtc;
use rand::thread_rng;
use rand::rng;
use tokio::net::TcpListener;
use tower_http::cors::{Any, CorsLayer};

Expand All @@ -33,7 +33,7 @@ async fn main() -> anyhow::Result<()> {
.with_other_transport(|id_keys| {
Ok(webrtc::tokio::Transport::new(
id_keys.clone(),
webrtc::tokio::Certificate::generate(&mut thread_rng())?,
webrtc::tokio::Certificate::generate(&mut rng())?,
)
.map(|(peer_id, conn), _| (peer_id, StreamMuxerBox::new(conn))))
})?
Expand Down
2 changes: 1 addition & 1 deletion examples/stream/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ anyhow = "1"
futures = { workspace = true }
libp2p = { path = "../../libp2p", features = [ "tokio", "quic"] }
libp2p-stream = { path = "../../protocols/stream", version = "0.3.0-alpha" }
rand = "0.8"
rand = "0.9"
tokio = { workspace = true, features = ["full"] }
tracing = { workspace = true }
tracing-subscriber = { workspace = true, features = ["env-filter"] }
Expand Down
2 changes: 1 addition & 1 deletion examples/stream/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ async fn send(mut stream: Stream) -> io::Result<()> {
let num_bytes = rand::random::<usize>() % 1000;

let mut bytes = vec![0; num_bytes];
rand::thread_rng().fill_bytes(&mut bytes);
rand::rng().fill_bytes(&mut bytes);

stream.write_all(&bytes).await?;

Expand Down
2 changes: 1 addition & 1 deletion identity/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ tracing = { workspace = true }
multihash = { version = "0.19.1", optional = true }
p256 = { version = "0.13", default-features = false, features = ["ecdsa", "std", "pem"], optional = true }
quick-protobuf = "0.8.1"
rand = { version = "0.8", optional = true }
rand = { version = "0.9", optional = true }
sec1 = { version = "0.7", default-features = false, optional = true }
serde = { version = "1", optional = true, features = ["derive"] }
sha2 = { version = "0.10.8", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion identity/src/ecdsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
/// Generate a new random ECDSA secret key.
#[cfg(feature = "rand")]
pub fn generate() -> SecretKey {
SecretKey(SigningKey::random(&mut rand::thread_rng()))
SecretKey(SigningKey::random(&mut rand::rng()))

Check failure on line 99 in identity/src/ecdsa.rs

View workflow job for this annotation

GitHub Actions / clippy (beta)

the trait bound `rand::prelude::ThreadRng: p256::elliptic_curve::rand_core::CryptoRngCore` is not satisfied

Check failure on line 99 in identity/src/ecdsa.rs

View workflow job for this annotation

GitHub Actions / clippy (beta)

the trait bound `rand::prelude::ThreadRng: p256::elliptic_curve::rand_core::CryptoRngCore` is not satisfied

Check failure on line 99 in identity/src/ecdsa.rs

View workflow job for this annotation

GitHub Actions / Check rustdoc intra-doc links

the trait bound `ThreadRng: CryptoRngCore` is not satisfied

Check failure on line 99 in identity/src/ecdsa.rs

View workflow job for this annotation

GitHub Actions / Check rustdoc intra-doc links

the trait bound `ThreadRng: CryptoRngCore` is not satisfied

Check failure on line 99 in identity/src/ecdsa.rs

View workflow job for this annotation

GitHub Actions / Compile with MSRV

the trait bound `ThreadRng: CryptoRngCore` is not satisfied

Check failure on line 99 in identity/src/ecdsa.rs

View workflow job for this annotation

GitHub Actions / Compile with MSRV

the trait bound `ThreadRng: CryptoRngCore` is not satisfied

Check failure on line 99 in identity/src/ecdsa.rs

View workflow job for this annotation

GitHub Actions / clippy (1.83.0)

the trait bound `rand::prelude::ThreadRng: p256::elliptic_curve::rand_core::CryptoRngCore` is not satisfied

Check failure on line 99 in identity/src/ecdsa.rs

View workflow job for this annotation

GitHub Actions / clippy (1.83.0)

the trait bound `rand::prelude::ThreadRng: p256::elliptic_curve::rand_core::CryptoRngCore` is not satisfied

Check failure on line 99 in identity/src/ecdsa.rs

View workflow job for this annotation

GitHub Actions / Test libp2p

the trait bound `ThreadRng: CryptoRngCore` is not satisfied

Check failure on line 99 in identity/src/ecdsa.rs

View workflow job for this annotation

GitHub Actions / Test libp2p

the trait bound `ThreadRng: CryptoRngCore` is not satisfied

Check failure on line 99 in identity/src/ecdsa.rs

View workflow job for this annotation

GitHub Actions / Test libp2p-identity

the trait bound `ThreadRng: CryptoRngCore` is not satisfied

Check failure on line 99 in identity/src/ecdsa.rs

View workflow job for this annotation

GitHub Actions / Test libp2p-identity

the trait bound `ThreadRng: CryptoRngCore` is not satisfied

Check failure on line 99 in identity/src/ecdsa.rs

View workflow job for this annotation

GitHub Actions / Test libp2p-pnet

the trait bound `ThreadRng: CryptoRngCore` is not satisfied

Check failure on line 99 in identity/src/ecdsa.rs

View workflow job for this annotation

GitHub Actions / Test libp2p-pnet

the trait bound `ThreadRng: CryptoRngCore` is not satisfied

Check failure on line 99 in identity/src/ecdsa.rs

View workflow job for this annotation

GitHub Actions / Test libp2p-tls

the trait bound `ThreadRng: CryptoRngCore` is not satisfied

Check failure on line 99 in identity/src/ecdsa.rs

View workflow job for this annotation

GitHub Actions / Test libp2p-tls

the trait bound `ThreadRng: CryptoRngCore` is not satisfied
}

/// Sign a message with this secret key, producing a DER-encoded ECDSA signature.
Expand Down
2 changes: 1 addition & 1 deletion identity/src/peer_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl PeerId {
/// This is useful for randomly walking on a DHT, or for testing purposes.
#[cfg(feature = "rand")]
pub fn random() -> PeerId {
let peer_id = rand::thread_rng().gen::<[u8; 32]>();
let peer_id = rand::rng().random::<[u8; 32]>();
PeerId {
multihash: Multihash::wrap(0x0, &peer_id).expect("The digest size is never too large"),
}
Expand Down
2 changes: 1 addition & 1 deletion identity/src/secp256k1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
/// Generate a new random Secp256k1 secret key.
#[cfg(feature = "rand")]
pub fn generate() -> SecretKey {
SecretKey(libsecp256k1::SecretKey::random(&mut rand::thread_rng()))
SecretKey(libsecp256k1::SecretKey::random(&mut rand::rng()))

Check failure on line 94 in identity/src/secp256k1.rs

View workflow job for this annotation

GitHub Actions / clippy (beta)

the trait bound `rand::prelude::ThreadRng: rand::rng::Rng` is not satisfied

Check failure on line 94 in identity/src/secp256k1.rs

View workflow job for this annotation

GitHub Actions / Check rustdoc intra-doc links

the trait bound `ThreadRng: rand::rng::Rng` is not satisfied

Check failure on line 94 in identity/src/secp256k1.rs

View workflow job for this annotation

GitHub Actions / Compile with MSRV

the trait bound `ThreadRng: rand::rng::Rng` is not satisfied

Check failure on line 94 in identity/src/secp256k1.rs

View workflow job for this annotation

GitHub Actions / clippy (1.83.0)

the trait bound `rand::prelude::ThreadRng: rand::rng::Rng` is not satisfied

Check failure on line 94 in identity/src/secp256k1.rs

View workflow job for this annotation

GitHub Actions / Test libp2p

the trait bound `ThreadRng: rand::rng::Rng` is not satisfied

Check failure on line 94 in identity/src/secp256k1.rs

View workflow job for this annotation

GitHub Actions / Test libp2p-identity

the trait bound `ThreadRng: rand::rng::Rng` is not satisfied

Check failure on line 94 in identity/src/secp256k1.rs

View workflow job for this annotation

GitHub Actions / Test libp2p-pnet

the trait bound `ThreadRng: rand::rng::Rng` is not satisfied

Check failure on line 94 in identity/src/secp256k1.rs

View workflow job for this annotation

GitHub Actions / Test libp2p-tls

the trait bound `ThreadRng: rand::rng::Rng` is not satisfied
}

/// Create a secret key from a byte slice, zeroing the slice on success.
Expand Down
2 changes: 1 addition & 1 deletion interop-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
anyhow = "1"
futures = { workspace = true }
rand = "0.8.5"
rand = "0.9"
serde = { version = "1", features = ["derive"] }
tracing = { workspace = true }
tracing-subscriber = { workspace = true, features = ["env-filter"] }
Expand Down
2 changes: 1 addition & 1 deletion interop-tests/src/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pub(crate) mod native {
.with_other_transport(|key| {
Ok(webrtc::tokio::Transport::new(
key.clone(),
webrtc::tokio::Certificate::generate(&mut rand::thread_rng())?,
webrtc::tokio::Certificate::generate(&mut rand::rng())?,
))
})?
.with_behaviour(behaviour_constructor)?
Expand Down
2 changes: 1 addition & 1 deletion libp2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ tcp = ["dep:libp2p-tcp"]
tls = ["dep:libp2p-tls"]
tokio = [ "libp2p-swarm/tokio", "libp2p-mdns?/tokio", "libp2p-tcp?/tokio", "libp2p-dns?/tokio", "libp2p-quic?/tokio", "libp2p-upnp?/tokio"]
uds = ["dep:libp2p-uds"]
wasm-bindgen = [ "futures-timer/wasm-bindgen", "getrandom/js", "libp2p-swarm/wasm-bindgen", "libp2p-gossipsub?/wasm-bindgen"]
wasm-bindgen = [ "futures-timer/wasm-bindgen", "libp2p-swarm/wasm-bindgen", "libp2p-gossipsub?/wasm-bindgen"]
webrtc-websys = ['dep:libp2p-webrtc-websys']
websocket-websys = ["dep:libp2p-websocket-websys"]
websocket = ["dep:libp2p-websocket"]
Expand Down
2 changes: 1 addition & 1 deletion misc/connection-limits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ libp2p-ping = { workspace = true }
libp2p-swarm-derive = { path = "../../swarm-derive" }
libp2p-swarm-test = { path = "../../swarm-test" }
quickcheck = { workspace = true }
rand = "0.8.5"
rand = "0.9"

[lints]
workspace = true
2 changes: 1 addition & 1 deletion misc/connection-limits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ mod tests {
fn fill_outgoing() -> (Swarm<Behaviour>, Multiaddr, u32) {
use rand::Rng;

let outgoing_limit = rand::thread_rng().gen_range(1..10);
let outgoing_limit = rand::rng().random_range(1..10);

let mut network = Swarm::new_ephemeral(|_| {
Behaviour::new(
Expand Down
2 changes: 1 addition & 1 deletion misc/webrtc-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ libp2p-identity = { workspace = true }
libp2p-noise = { workspace = true }
quick-protobuf = "0.8"
quick-protobuf-codec = { workspace = true }
rand = "0.8"
rand = "0.9"
serde = { version = "1.0", features = ["derive"] }
sha2 = "0.10.8"
tinytemplate = "1.2"
Expand Down
4 changes: 2 additions & 2 deletions misc/webrtc-utils/src/sdp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// DEALINGS IN THE SOFTWARE.
use std::net::{IpAddr, SocketAddr};

use rand::{distributions::Alphanumeric, thread_rng, Rng};
use rand::{distributions::Alphanumeric, rng, Rng};
use serde::Serialize;
use tinytemplate::TinyTemplate;

Expand Down Expand Up @@ -149,7 +149,7 @@ pub fn render_description(
pub fn random_ufrag() -> String {
format!(
"libp2p+webrtc+v1/{}",
thread_rng()
rng()
.sample_iter(&Alphanumeric)
.take(64)
.map(char::from)
Expand Down
2 changes: 1 addition & 1 deletion muxers/mplex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ libp2p-core = { workspace = true }
libp2p-identity = { workspace = true }
nohash-hasher = "0.2"
parking_lot = "0.12"
rand = "0.8"
rand = "0.9"
smallvec = "1.13.2"
tracing = { workspace = true }
unsigned-varint = { workspace = true, features = ["asynchronous_codec"] }
Expand Down
4 changes: 2 additions & 2 deletions protocols/autonat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ libp2p-swarm = { workspace = true }
quick-protobuf = "0.8"
tracing = { workspace = true }
quick-protobuf-codec = { workspace = true }
rand = "0.8"
rand_core = { version = "0.6", optional = true }
rand = "0.9"
rand_core = { version = "0.9", optional = true }
thiserror = { workspace = true, optional = true }

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions protocols/autonat/src/v1/behaviour/as_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use libp2p_core::Multiaddr;
use libp2p_identity::PeerId;
use libp2p_request_response::{self as request_response, OutboundFailure, OutboundRequestId};
use libp2p_swarm::{ConnectionId, ListenAddresses, ToSwarm};
use rand::{seq::SliceRandom, thread_rng};
use rand::{seq::SliceRandom, rng};
use web_time::Instant;

use super::{
Expand Down Expand Up @@ -265,7 +265,7 @@ impl AsClient<'_> {

servers.retain(|s| !self.throttled_servers.iter().any(|(id, _)| s == &id));

servers.choose(&mut thread_rng()).map(|&&p| p)
servers.choose(&mut rng()).map(|&&p| p)
}

// Send a dial-request to a randomly selected server.
Expand Down
2 changes: 1 addition & 1 deletion protocols/autonat/src/v2/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ impl From<Response> for proto::Message {

impl DialDataRequest {
pub(crate) fn from_rng<R: rand_core::RngCore>(addr_idx: usize, mut rng: R) -> Self {
let num_bytes = rng.gen_range(DATA_LEN_LOWER_BOUND..=DATA_LEN_UPPER_BOUND);
let num_bytes = rng.random_range(DATA_LEN_LOWER_BOUND..=DATA_LEN_UPPER_BOUND);
Self {
addr_idx,
num_bytes,
Expand Down
2 changes: 1 addition & 1 deletion protocols/floodsub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ libp2p-swarm = { workspace = true }
libp2p-identity = { workspace = true }
quick-protobuf = "0.8"
quick-protobuf-codec = { workspace = true }
rand = "0.8"
rand = "0.9"
smallvec = "1.13.2"
thiserror = { workspace = true }
tracing = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions protocols/gossipsub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ keywords = ["peer-to-peer", "libp2p", "networking"]
categories = ["network-programming", "asynchronous"]

[features]
wasm-bindgen = ["getrandom/js", "futures-timer/wasm-bindgen"]
wasm-bindgen = ["futures-timer/wasm-bindgen"]

[dependencies]
async-channel = "2.3.1"
Expand All @@ -32,7 +32,7 @@ libp2p-identity = { workspace = true, features = ["rand"] }
libp2p-swarm = { workspace = true }
quick-protobuf = "0.8"
quick-protobuf-codec = { workspace = true }
rand = "0.8"
rand = "0.9"
regex = "1.10.5"
serde = { version = "1", optional = true, features = ["derive"] }
sha2 = "0.10.8"
Expand Down
12 changes: 6 additions & 6 deletions protocols/gossipsub/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use libp2p_swarm::{
};
use prometheus_client::registry::Registry;
use quick_protobuf::{MessageWrite, Writer};
use rand::{seq::SliceRandom, thread_rng};
use rand::{seq::SliceRandom, rng};
use web_time::{Instant, SystemTime};

use crate::{
Expand Down Expand Up @@ -1291,7 +1291,7 @@ where

// Ask in random order
let mut iwant_ids_vec: Vec<_> = iwant_ids.into_iter().collect();
let mut rng = thread_rng();
let mut rng = rng();
iwant_ids_vec.partial_shuffle(&mut rng, iask);

iwant_ids_vec.truncate(iask);
Expand Down Expand Up @@ -1632,7 +1632,7 @@ where
px.retain(|p| p.peer_id.is_some());
if px.len() > n {
// only use at most prune_peers many random peers
let mut rng = thread_rng();
let mut rng = rng();
px.partial_shuffle(&mut rng, n);
px = px.into_iter().take(n).collect();
}
Expand Down Expand Up @@ -2177,7 +2177,7 @@ where
let excess_peer_no = peers.len() - self.config.mesh_n();

// shuffle the peers and then sort by score ascending beginning with the worst
let mut rng = thread_rng();
let mut rng = rng();
let mut shuffled = peers.iter().copied().collect::<Vec<_>>();
shuffled.shuffle(&mut rng);
shuffled.sort_by(|p1, p2| {
Expand Down Expand Up @@ -2467,7 +2467,7 @@ where
/// Emits gossip - Send IHAVE messages to a random set of gossip peers. This is applied to mesh
/// and fanout peers
fn emit_gossip(&mut self) {
let mut rng = thread_rng();
let mut rng = rng();
let mut messages = Vec::new();
for (topic_hash, peers) in self.mesh.iter().chain(self.fanout.iter()) {
let mut message_ids = self.mcache.get_gossip_message_ids(topic_hash);
Expand Down Expand Up @@ -3491,7 +3491,7 @@ fn get_random_peers_dynamic(
}

// we have more peers than needed, shuffle them and return n of them
let mut rng = thread_rng();
let mut rng = rng();
gossip_peers.partial_shuffle(&mut rng, n);

tracing::debug!("RANDOM PEERS: Got {:?} peers", n);
Expand Down
6 changes: 3 additions & 3 deletions protocols/gossipsub/src/behaviour/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3349,13 +3349,13 @@ fn test_scoring_p1() {
}

fn random_message(seq: &mut u64, topics: &[TopicHash]) -> RawMessage {
let mut rng = rand::thread_rng();
let mut rng = rand::rng();
*seq += 1;
RawMessage {
source: Some(PeerId::random()),
data: (0..rng.gen_range(10..30)).map(|_| rng.gen()).collect(),
data: (0..rng.random_range(10..30)).map(|_| rng.gen()).collect(),
sequence_number: Some(*seq),
topic: topics[rng.gen_range(0..topics.len())].clone(),
topic: topics[rng.random_range(0..topics.len())].clone(),
signature: None,
key: None,
validated: true,
Expand Down
24 changes: 12 additions & 12 deletions protocols/gossipsub/src/rpc_proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,27 @@ mod test {

let new_message1 = super::proto::Message {
from: Some(PeerId::random().to_bytes()),
data: Some(rand::thread_rng().gen::<[u8; 32]>().to_vec()),
seqno: Some(rand::thread_rng().gen::<[u8; 8]>().to_vec()),
data: Some(rand::rng().random::<[u8; 32]>().to_vec()),
seqno: Some(rand::rng().random::<[u8; 8]>().to_vec()),
topic: topic1.clone().into_string(),
signature: Some(rand::thread_rng().gen::<[u8; 32]>().to_vec()),
key: Some(rand::thread_rng().gen::<[u8; 32]>().to_vec()),
signature: Some(rand::rng().random::<[u8; 32]>().to_vec()),
key: Some(rand::rng().random::<[u8; 32]>().to_vec()),
};
let old_message1 = compat::pb::Message {
from: Some(PeerId::random().to_bytes()),
data: Some(rand::thread_rng().gen::<[u8; 32]>().to_vec()),
seqno: Some(rand::thread_rng().gen::<[u8; 8]>().to_vec()),
data: Some(rand::rng().random::<[u8; 32]>().to_vec()),
seqno: Some(rand::rng().random::<[u8; 8]>().to_vec()),
topic_ids: vec![topic1.clone().into_string()],
signature: Some(rand::thread_rng().gen::<[u8; 32]>().to_vec()),
key: Some(rand::thread_rng().gen::<[u8; 32]>().to_vec()),
signature: Some(rand::rng().random::<[u8; 32]>().to_vec()),
key: Some(rand::rng().random::<[u8; 32]>().to_vec()),
};
let old_message2 = compat::pb::Message {
from: Some(PeerId::random().to_bytes()),
data: Some(rand::thread_rng().gen::<[u8; 32]>().to_vec()),
seqno: Some(rand::thread_rng().gen::<[u8; 8]>().to_vec()),
data: Some(rand::rng().random::<[u8; 32]>().to_vec()),
seqno: Some(rand::rng().random::<[u8; 8]>().to_vec()),
topic_ids: vec![topic1.clone().into_string(), topic2.clone().into_string()],
signature: Some(rand::thread_rng().gen::<[u8; 32]>().to_vec()),
key: Some(rand::thread_rng().gen::<[u8; 32]>().to_vec()),
signature: Some(rand::rng().random::<[u8; 32]>().to_vec()),
key: Some(rand::rng().random::<[u8; 32]>().to_vec()),
};

let mut new_message1b = Vec::with_capacity(new_message1.get_size());
Expand Down
2 changes: 1 addition & 1 deletion protocols/kad/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ futures-bounded = { workspace = true }
quick-protobuf = "0.8"
quick-protobuf-codec = { workspace = true }
libp2p-identity = { workspace = true, features = ["rand"] }
rand = "0.8"
rand = "0.9"
sha2 = "0.10.8"
smallvec = "1.13.2"
uint = "0.10"
Expand Down
Loading
Loading