Skip to content

Commit f4747a3

Browse files
committed
fix api changes
1 parent 46056de commit f4747a3

File tree

11 files changed

+35
-54
lines changed

11 files changed

+35
-54
lines changed

Cargo.lock

Lines changed: 10 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ wasmtime = "15.0.1"
9494
substreams = "=0.6.0"
9595
substreams-entity-change = "2"
9696
substreams-near-core = "=0.10.2"
97+
rand = { version = "0.9.1", features = ["os_rng"] }
9798

9899
# Incremental compilation on Rust 1.58 causes an ICE on build. As soon as graph node builds again, these can be removed.
99100
[profile.test]

chain/ethereum/src/network.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,9 @@ impl EthereumNetworkAdapters {
196196
required_capabilities: &NodeCapabilities,
197197
retest_percent: f64,
198198
) -> Result<Arc<EthereumAdapter>, Error> {
199-
let retest_rng: f64 = (&mut rand::thread_rng()).gen();
199+
let retest_rng: f64 = (&mut rand::rng()).random();
200200

201-
let cheapest = input
202-
.into_iter()
203-
.choose_multiple(&mut rand::thread_rng(), 3);
201+
let cheapest = input.into_iter().choose_multiple(&mut rand::rng(), 3);
204202
let cheapest = cheapest.iter();
205203

206204
// If request falls below the retest threshold, use this request to try and
@@ -231,7 +229,7 @@ impl EthereumNetworkAdapters {
231229
let cheapest = self.all_unverified_cheapest_with(required_capabilities);
232230

233231
Self::cheapest_from(
234-
cheapest.choose_multiple(&mut rand::thread_rng(), 3),
232+
cheapest.choose_multiple(&mut rand::rng(), 3),
235233
required_capabilities,
236234
self.retest_percent,
237235
)
@@ -245,7 +243,7 @@ impl EthereumNetworkAdapters {
245243
let cheapest = self
246244
.all_cheapest_with(required_capabilities)
247245
.await
248-
.choose_multiple(&mut rand::thread_rng(), 3);
246+
.choose_multiple(&mut rand::rng(), 3);
249247

250248
Self::cheapest_from(cheapest, required_capabilities, self.retest_percent)
251249
}

graph/Cargo.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ atomic_refcell = "0.1.13"
1212
# We require this precise version of bigdecimal. Updating to later versions
1313
# has caused PoI differences; if you update this version, you will need to
1414
# make sure that it does not cause PoI changes
15-
old_bigdecimal = { version = "=0.1.2", features = ["serde"], package = "bigdecimal" }
15+
old_bigdecimal = { version = "=0.1.2", features = [
16+
"serde",
17+
], package = "bigdecimal" }
1618
bytes = "1.0.1"
1719
bs58 = { workspace = true }
1820
cid = "0.11.1"
@@ -40,7 +42,7 @@ lazy_static = "1.5.0"
4042
num-bigint = { version = "=0.2.6", features = ["serde"] }
4143
num-integer = { version = "=0.1.46" }
4244
num-traits = "=0.2.19"
43-
rand = "0.9.0"
45+
rand.workspace = true
4446
regex = "1.5.4"
4547
semver = { version = "1.0.23", features = ["serde"] }
4648
serde = { workspace = true }
@@ -93,7 +95,8 @@ defer = "0.2"
9395
# Our fork contains patches to make some fields optional for Celo and Fantom compatibility.
9496
# Without the "arbitrary_precision" feature, we get the error `data did not match any variant of untagged enum Response`.
9597
web3 = { git = "https://github.com/graphprotocol/rust-web3", branch = "graph-patches-onto-0.18", features = [
96-
"arbitrary_precision", "test"
98+
"arbitrary_precision",
99+
"test",
97100
] }
98101
serde_plain = "1.0.2"
99102
csv = "1.3.0"

graph/src/data/graphql/load_manager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Utilities to keep moving statistics about queries
22
33
use prometheus::core::GenericCounter;
4-
use rand::{prelude::Rng, thread_rng};
4+
use rand::{prelude::Rng, rng};
55
use std::collections::{HashMap, HashSet};
66
use std::iter::FromIterator;
77
use std::sync::{Arc, RwLock};
@@ -439,7 +439,7 @@ impl LoadManager {
439439
// that cause at least 20% of the effort
440440
let kill_rate = self.update_kill_rate(shard, kill_rate, last_update, overloaded, wait_ms);
441441
let decline =
442-
thread_rng().gen_bool((kill_rate * query_effort / total_effort).min(1.0).max(0.0));
442+
rng().random_bool((kill_rate * query_effort / total_effort).min(1.0).max(0.0));
443443
if decline {
444444
if ENV_VARS.load_simulate {
445445
debug!(self.logger, "Declining query";

graph/src/data/subgraph/schema.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ use anyhow::{anyhow, bail, Error};
44
use chrono::{DateTime, Utc};
55
use hex;
66
use rand::rngs::OsRng;
7-
use rand::Rng;
7+
use rand::TryRngCore as _;
8+
// use rand::rngs::OsRng;
9+
// use rand::Rng;
810
use std::collections::BTreeSet;
911
use std::str::FromStr;
1012
use std::{fmt, fmt::Display};
@@ -272,11 +274,9 @@ impl_stable_hash!(SubgraphError {
272274
});
273275

274276
pub fn generate_entity_id() -> String {
275-
// Fast crypto RNG from operating system
276-
let mut rng = OsRng::default();
277-
278277
// 128 random bits
279-
let id_bytes: [u8; 16] = rng.gen();
278+
let mut id_bytes = [0u8; 16];
279+
OsRng.try_fill_bytes(&mut id_bytes).unwrap();
280280

281281
// 32 hex chars
282282
// Comparable to uuidv4, but without the hyphens,

graph/src/util/backoff.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl ExponentialBackoff {
5151
if delay > self.ceiling {
5252
delay = self.ceiling;
5353
}
54-
let jitter = rand::Rng::gen_range(&mut rand::thread_rng(), -self.jitter..=self.jitter);
54+
let jitter = rand::Rng::random_range(&mut rand::rng(), -self.jitter..=self.jitter);
5555
delay.mul_f64(1.0 + jitter)
5656
}
5757

runtime/test/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ graph = { path = "../../graph" }
1010
graph-chain-ethereum = { path = "../../chain/ethereum" }
1111
graph-runtime-derive = { path = "../derive" }
1212
graph-runtime-wasm = { path = "../wasm" }
13-
rand = "0.9.0"
13+
rand.workspace = true
1414

1515

1616
[dev-dependencies]

runtime/test/src/test_padding.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ const WASM_FILE_NAME: &str = "test_padding.wasm";
88

99
//for tests, to run in parallel, sub graph name has be unique
1010
fn rnd_sub_graph_name(size: usize) -> String {
11-
use rand::{distributions::Alphanumeric, Rng};
12-
rand::thread_rng()
11+
use rand::{distr::Alphanumeric, Rng};
12+
rand::rng()
1313
.sample_iter(&Alphanumeric)
1414
.take(size)
1515
.map(char::from)

store/postgres/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ maybe-owned = "0.3.4"
2323
postgres = "0.19.1"
2424
openssl = "0.10.72"
2525
postgres-openssl = "0.5.1"
26-
rand = "0.9.0"
26+
rand.workspace = true
2727
serde = { workspace = true }
2828
serde_json = { workspace = true }
2929
stable-hash_legacy = { git = "https://github.com/graphprotocol/stable-hash", branch = "old", package = "stable-hash" }

0 commit comments

Comments
 (0)