diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 69ff5e5a0..aabaf44e6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -454,10 +454,9 @@ jobs: with: stable-toolchain: true cargo-cache-key: cargo-stable-wasm - cargo-cache-fallback-key: cargo-stable - name: Install wasm-pack - uses: taiki-e/cache-cargo-install-action@v2 + uses: taiki-e/install-action@v2 with: tool: wasm-pack diff --git a/Cargo.lock b/Cargo.lock index fac3bf1f8..3ce0cc34b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -207,7 +207,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "246a225cc6131e9ee4f24619af0f19d67761fff15d7ccc22e42b80846e69449a" dependencies = [ "num-traits", - "rand", + "rand 0.8.5", ] [[package]] @@ -384,7 +384,7 @@ dependencies = [ "ff", "group", "pairing", - "rand_core", + "rand_core 0.6.4", "serde", "subtle", ] @@ -754,7 +754,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array", - "rand_core", + "rand_core 0.6.4", "subtle", "zeroize", ] @@ -780,7 +780,7 @@ dependencies = [ "curve25519-dalek-derive", "digest", "fiat-crypto", - "rand_core", + "rand_core 0.6.4", "rustc_version", "subtle", "zeroize", @@ -928,7 +928,7 @@ checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" dependencies = [ "curve25519-dalek", "ed25519", - "rand_core", + "rand_core 0.6.4", "serde", "sha2", "subtle", @@ -978,7 +978,7 @@ dependencies = [ "generic-array", "group", "pkcs8", - "rand_core", + "rand_core 0.6.4", "sec1", "subtle", "zeroize", @@ -1054,7 +1054,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393" dependencies = [ "bitvec", - "rand_core", + "rand_core 0.6.4", "subtle", ] @@ -1229,22 +1229,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", - "js-sys", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", - "wasm-bindgen", + "wasi", ] [[package]] name = "getrandom" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" dependencies = [ "cfg-if", + "js-sys", "libc", "r-efi", - "wasi 0.14.2+wasi-0.2.4", + "wasip2", + "wasm-bindgen", ] [[package]] @@ -1266,8 +1266,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff", - "rand", - "rand_core", + "rand 0.8.5", + "rand_core 0.6.4", "rand_xorshift", "subtle", ] @@ -1573,7 +1573,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0acd33ff0285af998aaf9b57342af478078f53492322fafc47450e09397e0e9" dependencies = [ "bitmaps", - "rand_core", + "rand_core 0.6.4", "rand_xoshiro", "rayon", "serde", @@ -1774,7 +1774,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "windows-sys 0.52.0", ] @@ -2123,8 +2123,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha", - "rand_core", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.3", ] [[package]] @@ -2134,7 +2144,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.3", ] [[package]] @@ -2146,13 +2166,22 @@ dependencies = [ "getrandom 0.2.15", ] +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom 0.3.4", +] + [[package]] name = "rand_xorshift" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" dependencies = [ - "rand_core", + "rand_core 0.6.4", ] [[package]] @@ -2161,7 +2190,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa" dependencies = [ - "rand_core", + "rand_core 0.6.4", ] [[package]] @@ -2574,7 +2603,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ "digest", - "rand_core", + "rand_core 0.6.4", ] [[package]] @@ -2669,7 +2698,7 @@ dependencies = [ "curve25519-dalek", "five8", "five8_const", - "rand", + "rand 0.9.2", "serde", "serde_derive", "solana-account-info", @@ -2765,7 +2794,7 @@ dependencies = [ "ff", "group", "pairing", - "rand", + "rand 0.8.5", "rayon", "serde", "serde_json", @@ -3051,8 +3080,8 @@ dependencies = [ "im", "log", "memmap2", - "rand", - "rand_chacha", + "rand 0.9.2", + "rand_chacha 0.9.0", "serde", "serde_bytes", "serde_derive", @@ -3211,7 +3240,7 @@ dependencies = [ "ed25519-dalek", "ed25519-dalek-bip32", "five8", - "rand", + "rand 0.9.2", "serde_json", "solana-address", "solana-derivation-path", @@ -3538,7 +3567,7 @@ dependencies = [ name = "solana-pubkey" version = "4.0.0" dependencies = [ - "rand", + "rand 0.9.2", "solana-address", ] @@ -3640,7 +3669,7 @@ dependencies = [ "bincode", "console_error_panic_hook", "console_log", - "getrandom 0.2.15", + "getrandom 0.3.4", "js-sys", "log", "solana-address", @@ -3675,7 +3704,7 @@ dependencies = [ "digest", "hex", "k256", - "rand", + "rand 0.8.5", "serde", "serde_derive", "sha3", @@ -3698,7 +3727,7 @@ dependencies = [ "anyhow", "borsh", "k256", - "rand", + "rand 0.8.5", "solana-define-syscall", "solana-frozen-abi", "solana-frozen-abi-macro", @@ -3746,7 +3775,7 @@ name = "solana-serde-varint" version = "3.0.0" dependencies = [ "bincode", - "rand", + "rand 0.9.2", "serde", "serde_derive", "solana-short-vec", @@ -3758,7 +3787,7 @@ version = "3.1.0" dependencies = [ "bincode", "borsh", - "rand", + "rand 0.9.2", "serde", "solana-instruction-error", "solana-pubkey", @@ -3807,7 +3836,7 @@ dependencies = [ "curve25519-dalek", "ed25519-dalek", "five8", - "rand", + "rand 0.9.2", "serde", "serde-big-array", "serde_derive", @@ -3837,7 +3866,7 @@ dependencies = [ "criterion", "num-derive", "num-traits", - "rand", + "rand 0.9.2", "thiserror 2.0.12", ] @@ -4038,7 +4067,7 @@ dependencies = [ "itertools 0.12.1", "num-derive", "num-traits", - "rand", + "rand 0.9.2", "serde", "serde_derive", "serde_with", @@ -4185,7 +4214,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1" dependencies = [ "fastrand", - "getrandom 0.3.3", + "getrandom 0.3.4", "once_cell", "rustix", "windows-sys 0.59.0", @@ -4281,7 +4310,7 @@ checksum = "a30fd743a02bf35236f6faf99adb03089bb77e91c998dac2c2ad76bb424f668c" dependencies = [ "once_cell", "pbkdf2 0.12.2", - "rand", + "rand 0.8.5", "rustc-hash", "sha2", "thiserror 1.0.69", @@ -4539,12 +4568,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "wasi" -version = "0.14.2+wasi-0.2.4" +name = "wasip2" +version = "1.0.1+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" dependencies = [ - "wit-bindgen-rt", + "wit-bindgen", ] [[package]] @@ -4821,13 +4850,10 @@ dependencies = [ ] [[package]] -name = "wit-bindgen-rt" -version = "0.39.0" +name = "wit-bindgen" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" -dependencies = [ - "bitflags 2.8.0", -] +checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" [[package]] name = "write16" diff --git a/Cargo.toml b/Cargo.toml index 250087375..00726695d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -173,7 +173,7 @@ ed25519-dalek-bip32 = "0.3.0" ff = "0.13.1" five8 = "1.0.0" five8_const = "1.0.0" -getrandom = "0.2.10" +getrandom = "0.3.4" group = "0.13.0" hex = "0.4.3" hmac = "0.12.1" @@ -200,7 +200,8 @@ proptest = "1.6" qstring = "0.7.2" qualifier_attr = { version = "0.2.2", default-features = false } quote = "1.0.35" -rand = "0.8.5" +rand = "0.9.2" +rand_chacha = "0.9.0" rayon = "1.10.0" regex = "1.11" reqwest = { version = "0.11.27", default-features = false } diff --git a/address/src/hasher.rs b/address/src/hasher.rs index 922b91ec6..73135ccbd 100644 --- a/address/src/hasher.rs +++ b/address/src/hasher.rs @@ -5,7 +5,7 @@ use { hash::{BuildHasher, Hasher}, mem, }, - rand::{thread_rng, Rng}, + rand::{rng, Rng}, }; /// A faster, but less collision resistant hasher for addresses. @@ -64,8 +64,8 @@ impl Default for AddressHasherBuilder { /// `RandomState` fn default() -> Self { std::thread_local!(static OFFSET: Cell = { - let mut rng = thread_rng(); - Cell::new(rng.gen_range(0..ADDRESS_BYTES - mem::size_of::())) + let mut rng = rng(); + Cell::new(rng.random_range(0..ADDRESS_BYTES - mem::size_of::())) }); let offset = OFFSET.with(|offset| { diff --git a/bls-signatures/Cargo.toml b/bls-signatures/Cargo.toml index f46b2c23d..21ab52795 100644 --- a/bls-signatures/Cargo.toml +++ b/bls-signatures/Cargo.toml @@ -48,7 +48,7 @@ blst = { workspace = true } blstrs = { workspace = true } ff = { workspace = true } group = { workspace = true } -rand = { workspace = true } +rand = "0.8" # blstrs is still on rand_core v0.6, so pin this for now rayon = { workspace = true, optional = true } solana-signature = { workspace = true, optional = true } solana-signer = { workspace = true, optional = true } diff --git a/frozen-abi/Cargo.toml b/frozen-abi/Cargo.toml index 7a5497947..74443fcdd 100644 --- a/frozen-abi/Cargo.toml +++ b/frozen-abi/Cargo.toml @@ -42,8 +42,8 @@ im = { workspace = true, features = ["rayon", "serde"] } memmap2 = { workspace = true } # These dependencies are used only to back `frozen-abi` StableAbi API, # to avoid version skew and keep digest computation stable regardless of consumer dependencies. -rand = "0.8.5" -rand_chacha = "0.3.1" +rand = { workspace = true } +rand_chacha = { workspace = true } [target.'cfg(not(target_os = "solana"))'.dev-dependencies] bitflags = { workspace = true, features = ["serde"] } diff --git a/frozen-abi/src/stable_abi.rs b/frozen-abi/src/stable_abi.rs index 475ae86a3..ddd7c1956 100644 --- a/frozen-abi/src/stable_abi.rs +++ b/frozen-abi/src/stable_abi.rs @@ -1,10 +1,10 @@ -use rand::{distributions::Standard, Rng, RngCore}; +use rand::{distr::StandardUniform, Rng, RngCore}; pub trait StableAbi: Sized { fn random(rng: &mut impl RngCore) -> Self where - Standard: rand::distributions::Distribution, + StandardUniform: rand::distr::Distribution, { - rng.r#gen::() + rng.random::() } } diff --git a/keypair/src/lib.rs b/keypair/src/lib.rs index e0ccb1943..1ef52bad7 100644 --- a/keypair/src/lib.rs +++ b/keypair/src/lib.rs @@ -2,7 +2,6 @@ #![cfg_attr(docsrs, feature(doc_cfg))] use { ed25519_dalek::Signer as DalekSigner, - rand::rngs::OsRng, solana_seed_phrase::generate_seed_from_seed_phrase_and_passphrase, solana_signer::SignerError, std::{ @@ -34,8 +33,8 @@ impl Keypair { /// Constructs a new, random `Keypair` using `OsRng` #[allow(clippy::new_without_default)] pub fn new() -> Self { - let mut rng = OsRng; - Self(ed25519_dalek::SigningKey::generate(&mut rng)) + let secret_bytes = rand::random::<[u8; Self::SECRET_KEY_LENGTH]>(); + Self(ed25519_dalek::SigningKey::from_bytes(&secret_bytes)) } /// Constructs a new `Keypair` using secret key bytes diff --git a/sdk-wasm-js/Cargo.toml b/sdk-wasm-js/Cargo.toml index 8de7e7aff..534bab12f 100644 --- a/sdk-wasm-js/Cargo.toml +++ b/sdk-wasm-js/Cargo.toml @@ -32,7 +32,7 @@ solana-transaction = { workspace = true, features = ["bincode", "verify"] } [target.'cfg(target_arch = "wasm32")'.dependencies] console_error_panic_hook = { workspace = true } console_log = { workspace = true } -getrandom = { workspace = true, features = ["js"] } +getrandom = { workspace = true, features = ["wasm_js"] } js-sys = { workspace = true } log = { workspace = true } wasm-bindgen = { workspace = true } diff --git a/secp256k1-program/Cargo.toml b/secp256k1-program/Cargo.toml index ca0b226f9..79922b873 100644 --- a/secp256k1-program/Cargo.toml +++ b/secp256k1-program/Cargo.toml @@ -38,7 +38,7 @@ solana-signature = { workspace = true, features = ["std"] } [dev-dependencies] anyhow = { workspace = true } hex = { workspace = true } -rand = { workspace = true } +rand = "0.8" # k256 still uses rand_core v0.6 solana-account-info = { workspace = true } solana-example-mocks = { path = "../example-mocks" } solana-instruction = { workspace = true } diff --git a/secp256k1-recover/Cargo.toml b/secp256k1-recover/Cargo.toml index 125cd81bf..b23de5a69 100644 --- a/secp256k1-recover/Cargo.toml +++ b/secp256k1-recover/Cargo.toml @@ -35,7 +35,7 @@ k256 = { workspace = true } [dev-dependencies] anyhow = { workspace = true } borsh = { workspace = true } -rand = { workspace = true } +rand = "0.8" # k256 still uses rand_core v0.6 solana-program = { path = "../program" } [target.'cfg(not(target_os = "solana"))'.dev-dependencies] diff --git a/serde-varint/src/lib.rs b/serde-varint/src/lib.rs index 146e23f91..57b310b84 100644 --- a/serde-varint/src/lib.rs +++ b/serde-varint/src/lib.rs @@ -182,13 +182,13 @@ mod tests { #[test] fn test_serde_varint_rand() { - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); for _ in 0..100_000 { let dummy = Dummy { - a: rng.gen::() >> rng.gen_range(0..u32::BITS), - b: rng.gen::() >> rng.gen_range(0..u64::BITS), - c: rng.gen::() >> rng.gen_range(0..u64::BITS), - d: rng.gen::() >> rng.gen_range(0..u32::BITS), + a: rng.random::() >> rng.random_range(0..u32::BITS), + b: rng.random::() >> rng.random_range(0..u64::BITS), + c: rng.random::() >> rng.random_range(0..u64::BITS), + d: rng.random::() >> rng.random_range(0..u32::BITS), }; let bytes = bincode::serialize(&dummy).unwrap(); let other: Dummy = bincode::deserialize(&bytes).unwrap(); @@ -240,7 +240,7 @@ mod tests { #[test] fn test_serde_varint_fuzz() { - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); let mut buffer = [0u8; 36]; let mut num_errors = 0; for _ in 0..200_000 { @@ -265,7 +265,7 @@ mod tests { fn test_serde_varint_cross_fuzz() { #[derive(Serialize, Deserialize)] struct U16(#[serde(with = "super")] u16); - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); let mut buffer = [0u8; 16]; let mut num_errors = 0; for _ in 0..200_000 { diff --git a/serialize-utils/src/cursor.rs b/serialize-utils/src/cursor.rs index de8f31240..f7e38d609 100644 --- a/serialize-utils/src/cursor.rs +++ b/serialize-utils/src/cursor.rs @@ -133,7 +133,7 @@ mod test { #[test] fn test_read_option_u64() { for _ in 0..100 { - let test_value = rand::random::>(); + let test_value = rand::random_bool(0.5).then(rand::random::); test_read(read_option_u64, test_value); } } @@ -150,7 +150,7 @@ mod test { fn test_read_pubkey() { for _ in 0..100 { let mut buf = [0; 32]; - rand::thread_rng().fill(&mut buf); + rand::rng().fill(&mut buf); let test_value = Pubkey::from(buf); test_read(read_pubkey, test_value); } diff --git a/signer-store/benches/encoding.rs b/signer-store/benches/encoding.rs index 5ec5bbcdf..d0ca65484 100644 --- a/signer-store/benches/encoding.rs +++ b/signer-store/benches/encoding.rs @@ -8,7 +8,9 @@ use { /// Creates a single BitVec with pseudo-random data for Base2 benchmarking. fn create_test_data_base2(rng: &mut ThreadRng, len: usize) -> BitVec { - iter::repeat_with(|| rng.gen_bool(0.5)).take(len).collect() + iter::repeat_with(|| rng.random_bool(0.5)) + .take(len) + .collect() } /// Creates two BitVecs with a uniform distribution of valid Base3 pairs. @@ -54,7 +56,7 @@ fn create_test_data_base3_sparse(len: usize) -> (BitVec, BitVec = (0..raw_data_length).map(|_| rng.gen::()).collect(); + let raw_data_length = rng.random_range(1..serialized_len_x4); + let mut raw_data: Vec = (0..raw_data_length).map(|_| rng.random::()).collect(); // pure random data will ~never have a valid enum tag, so lets help it out - if raw_data_length >= 4 && rng.gen::() { - let tag = rng.gen::() % 4; + if raw_data_length >= 4 && rng.random::() { + let tag = rng.random::() % 4; raw_data[0] = tag; raw_data[1] = 0; raw_data[2] = 0; @@ -695,14 +695,14 @@ mod tests { // variant let serialized_len_x4 = serialized_size(&VoteStateV4::default()).unwrap() * 4; - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); for _ in 0..1000 { - let raw_data_length = rng.gen_range(1..serialized_len_x4); - let mut raw_data: Vec = (0..raw_data_length).map(|_| rng.gen::()).collect(); + let raw_data_length = rng.random_range(1..serialized_len_x4); + let mut raw_data: Vec = (0..raw_data_length).map(|_| rng.random::()).collect(); // pure random data will ~never have a valid enum tag, so lets help it out - if raw_data_length >= 4 && rng.gen::() { - let tag = rng.gen::() % 4; + if raw_data_length >= 4 && rng.random::() { + let tag = rng.random::() % 4; raw_data[0] = tag; raw_data[1] = 0; raw_data[2] = 0; @@ -908,7 +908,7 @@ mod tests { #[test] fn test_serde_compact_vote_state_update() { - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); for _ in 0..5000 { run_serde_compact_vote_state_update(&mut rng); } @@ -916,21 +916,21 @@ mod tests { fn run_serde_compact_vote_state_update(rng: &mut R) { let lockouts: VecDeque<_> = std::iter::repeat_with(|| { - let slot = 149_303_885_u64.saturating_add(rng.gen_range(0..10_000)); - let confirmation_count = rng.gen_range(0..33); + let slot = 149_303_885_u64.saturating_add(rng.random_range(0..10_000)); + let confirmation_count = rng.random_range(0..33); Lockout::new_with_confirmation_count(slot, confirmation_count) }) .take(32) .sorted_by_key(|lockout| lockout.slot()) .collect(); - let root = rng.gen_ratio(1, 2).then(|| { + let root = rng.random_bool(0.5).then(|| { lockouts[0] .slot() - .checked_sub(rng.gen_range(0..1_000)) + .checked_sub(rng.random_range(0..1_000)) .expect("All slots should be greater than 1_000") }); - let timestamp = rng.gen_ratio(1, 2).then(|| rng.gen()); - let hash = Hash::from(rng.gen::<[u8; 32]>()); + let timestamp = rng.random_bool(0.5).then(|| rng.random()); + let hash = Hash::from(rng.random::<[u8; 32]>()); let vote_state_update = VoteStateUpdate { lockouts, root, @@ -949,7 +949,7 @@ mod tests { let vote = VoteInstruction::UpdateVoteState(vote_state_update.clone()); let bytes = bincode::serialize(&vote).unwrap(); assert_eq!(vote, bincode::deserialize(&bytes).unwrap()); - let hash = Hash::from(rng.gen::<[u8; 32]>()); + let hash = Hash::from(rng.random::<[u8; 32]>()); let vote = VoteInstruction::UpdateVoteStateSwitch(vote_state_update, hash); let bytes = bincode::serialize(&vote).unwrap(); assert_eq!(vote, bincode::deserialize(&bytes).unwrap());