mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 09:16:00 +00:00
Update Rust Edition to 2024 (#7766)
* #7749 Thanks @dknopik and @michaelsproul for your help!
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
use bls::PublicKeyBytes;
|
||||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
use criterion::{Criterion, criterion_group, criterion_main};
|
||||
use rand::Rng;
|
||||
use ssz::Decode;
|
||||
use store::{
|
||||
hdiff::{HDiff, HDiffBuffer},
|
||||
StoreConfig,
|
||||
hdiff::{HDiff, HDiffBuffer},
|
||||
};
|
||||
use types::{BeaconState, Epoch, Eth1Data, EthSpec, MainnetEthSpec as E, Validator};
|
||||
|
||||
@@ -12,7 +12,7 @@ pub fn all_benches(c: &mut Criterion) {
|
||||
let spec = E::default_spec();
|
||||
let genesis_time = 0;
|
||||
let eth1_data = Eth1Data::default();
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut rng = rand::rng();
|
||||
let validator_mutations = 1000;
|
||||
let validator_additions = 100;
|
||||
|
||||
@@ -27,11 +27,11 @@ pub fn all_benches(c: &mut Criterion) {
|
||||
// Change all balances
|
||||
for i in 0..n {
|
||||
let balance = target_state.balances_mut().get_mut(i).unwrap();
|
||||
*balance += rng.gen_range(1..=1_000_000);
|
||||
*balance += rng.random_range(1..=1_000_000);
|
||||
}
|
||||
// And some validator records
|
||||
for _ in 0..validator_mutations {
|
||||
let index = rng.gen_range(1..n);
|
||||
let index = rng.random_range(1..n);
|
||||
// TODO: Only change a few things, and not the pubkey
|
||||
*target_state.validators_mut().get_mut(index).unwrap() = rand_validator(&mut rng);
|
||||
}
|
||||
@@ -80,7 +80,7 @@ fn bench_against_states(
|
||||
fn rand_validator(mut rng: impl Rng) -> Validator {
|
||||
let mut pubkey = [0u8; 48];
|
||||
rng.fill_bytes(&mut pubkey);
|
||||
let withdrawal_credentials: [u8; 32] = rng.gen();
|
||||
let withdrawal_credentials: [u8; 32] = rng.random();
|
||||
|
||||
Validator {
|
||||
pubkey: PublicKeyBytes::from_ssz_bytes(&pubkey).unwrap(),
|
||||
@@ -97,7 +97,7 @@ fn rand_validator(mut rng: impl Rng) -> Validator {
|
||||
fn append_validator(state: &mut BeaconState<E>, mut rng: impl Rng) {
|
||||
state
|
||||
.balances_mut()
|
||||
.push(32_000_000_000 + rng.gen_range(1..=1_000_000_000))
|
||||
.push(32_000_000_000 + rng.random_range(1..=1_000_000_000))
|
||||
.unwrap();
|
||||
if let Ok(inactivity_scores) = state.inactivity_scores_mut() {
|
||||
inactivity_scores.push(0).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user