Skip to content
Closed
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
60 changes: 44 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ k256 = "0.13"
mesc = "0.3"
num-format = "0.4"
parking_lot = "0.12"
proptest = "1"
rand = "0.8"
proptest = { git = "https://github.com/getong/proptest", branch = "update-rand-0.9" }
rand = "0.9"
rayon = "1"
regex = { version = "1", default-features = false }
reqwest = { version = "0.12", default-features = false, features = [
Expand Down
4 changes: 2 additions & 2 deletions crates/anvil/core/src/eth/subscription.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Subscription types
use alloy_primitives::hex;
use rand::{distributions::Alphanumeric, thread_rng, Rng};
use rand::{distributions::Alphanumeric, rng, Rng};
use std::fmt;

/// Unique subscription id
Expand Down Expand Up @@ -49,7 +49,7 @@ impl HexIdProvider {
/// Generates a random hex encoded Id
pub fn gen(&self) -> String {
let id: String =
(&mut thread_rng()).sample_iter(Alphanumeric).map(char::from).take(self.len).collect();
(&mut rng()).sample_iter(Alphanumeric).map(char::from).take(self.len).collect();
let out = hex::encode(id);
format!("0x{out}")
}
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ impl NodeArgs {
if let Some(ref mnemonic) = self.mnemonic {
gen = gen.phrase(mnemonic);
} else if let Some(count) = self.mnemonic_random {
let mut rng = rand::thread_rng();
let mut rng = rand::rng();
let mnemonic = match Mnemonic::<English>::new_with_count(&mut rng, count) {
Ok(mnemonic) => mnemonic.to_phrase(),
Err(_) => DEFAULT_MNEMONIC.to_string(),
Expand Down
4 changes: 2 additions & 2 deletions crates/anvil/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use foundry_evm::{
};
use itertools::Itertools;
use parking_lot::RwLock;
use rand::thread_rng;
use rand::rng;
use revm::primitives::BlobExcessGasAndPrice;
use serde_json::{json, Value};
use std::{
Expand Down Expand Up @@ -1444,7 +1444,7 @@ impl AccountGenerator {
Self {
chain_id: CHAIN_ID,
amount,
phrase: Mnemonic::<English>::new(&mut thread_rng()).to_phrase(),
phrase: Mnemonic::<English>::new(&mut rng()).to_phrase(),
derivation_path: None,
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/cast/bin/cmd/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use foundry_cli::{opts::RpcOpts, utils, utils::LoadConfig};
use foundry_common::{fs, sh_println, shell};
use foundry_config::Config;
use foundry_wallets::{RawWalletOpts, WalletOpts, WalletSigner};
use rand::thread_rng;
use rand::rng;
use serde_json::json;
use std::path::Path;
use yansi::Paint;
Expand Down Expand Up @@ -232,7 +232,7 @@ impl WalletSubcommands {
pub async fn run(self) -> Result<()> {
match self {
Self::New { path, account_name, unsafe_password, number, .. } => {
let mut rng = thread_rng();
let mut rng = rng();

let mut json_values = if shell::is_json() { Some(vec![]) } else { None };
if let Some(path) = path {
Expand Down Expand Up @@ -316,7 +316,7 @@ impl WalletSubcommands {
let entropy = Entropy::from_slice(hex::decode(entropy)?)?;
Mnemonic::<English>::new_from_entropy(entropy).to_phrase()
} else {
let mut rng = thread_rng();
let mut rng = rng();
Mnemonic::<English>::new_with_count(&mut rng, words)?.to_phrase()
};

Expand Down Expand Up @@ -465,7 +465,7 @@ flag to set your key via:
rpassword::prompt_password("Enter password: ")?
};

let mut rng = thread_rng();
let mut rng = rng();
let (wallet, _) = PrivateKeySigner::encrypt_keystore(
dir,
&mut rng,
Expand Down
2 changes: 1 addition & 1 deletion crates/cast/bin/cmd/wallet/vanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ pub fn wallet_generator() -> iter::Map<iter::Repeat<()>, impl Fn(()) -> Generate

/// Generates a random K-256 signing key and derives its Ethereum address.
pub fn generate_wallet() -> GeneratedWallet {
let key = SigningKey::random(&mut rand::thread_rng());
let key = SigningKey::random(&mut rand::rng());
let address = secret_key_to_address(&key);
(key, address)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/evm/fuzz/src/strategies/invariants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub fn override_call_strat(
// Choose a random contract if target selected by lazy strategy is not in fuzz run
// identified contracts. This can happen when contract is created in `setUp` call
// but is not included in targetContracts.
contracts.values().choose(&mut rand::thread_rng()).unwrap()
contracts.values().choose(&mut rand::rng()).unwrap()
});
let fuzzed_functions: Vec<_> = contract.abi_fuzzed_functions().cloned().collect();
any::<prop::sample::Index>().prop_map(move |index| index.get(&fuzzed_functions).clone())
Expand Down
12 changes: 6 additions & 6 deletions crates/test-utils/src/rpc.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! RPC API keys utilities.

use foundry_config::{NamedChain, NamedChain::Optimism};
use rand::seq::SliceRandom;
use rand::seq::{IndexedRandom, SliceRandom};
use std::{
env,
sync::{
Expand All @@ -26,7 +26,7 @@ static INFURA_KEYS: LazyLock<Vec<&'static str>> = LazyLock::new(|| {
// "5c812e02193c4ba793f8c214317582bd",
];

keys.shuffle(&mut rand::thread_rng());
keys.shuffle(&mut rand::rng());

keys
});
Expand Down Expand Up @@ -62,7 +62,7 @@ static ALCHEMY_KEYS: LazyLock<Vec<&'static str>> = LazyLock::new(|| {
// "UVatYU2Ax0rX6bDiqddeTRDdcCxzdpoE",
"bVjX9v-FpmUhf5R_oHIgwJx2kXvYPRbx",
];
keys.shuffle(&mut rand::thread_rng());
keys.shuffle(&mut rand::rng());
keys
});

Expand All @@ -82,7 +82,7 @@ static ETHERSCAN_MAINNET_KEYS: LazyLock<Vec<&'static str>> = LazyLock::new(|| {
// Optimism
// "JQNGFHINKS1W7Y5FRXU4SPBYF43J3NYK46",
];
keys.shuffle(&mut rand::thread_rng());
keys.shuffle(&mut rand::rng());
keys
});

Expand Down Expand Up @@ -143,7 +143,7 @@ fn next_archive_url(is_ws: bool) -> String {
let url = if env_archive_urls(is_ws).is_empty() {
next(urls)
} else {
urls.choose_weighted(&mut rand::thread_rng(), |url| {
urls.choose_weighted(&mut rand::rng(), |url| {
if url.contains("reth") {
2usize
} else {
Expand All @@ -164,7 +164,7 @@ fn archive_urls(is_ws: bool) -> &'static [String] {
let env_urls = env_archive_urls(is_ws);
if !env_urls.is_empty() {
let mut urls = env_urls.to_vec();
urls.shuffle(&mut rand::thread_rng());
urls.shuffle(&mut rand::rng());
return urls;
}

Expand Down
Loading