mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-24 07:14:46 +00:00
Replace lazy_static! with LazyLock (#6189)
* Replace `lazy_static` with `LazyLock`. * Merge branch 'unstable' into remove-lazy-static # Conflicts: # beacon_node/lighthouse_network/src/peer_manager/mod.rs * Lint fixes. * Merge branch 'unstable' into remove-lazy-static # Conflicts: # beacon_node/beacon_chain/src/metrics.rs * Moar lint fixes. * Update rust version to 1.80.0. * Merge branch 'unstable' into remove-lazy-static
This commit is contained in:
@@ -2,15 +2,14 @@
|
||||
use crate::test_utils::*;
|
||||
use beacon_chain::test_utils::{BeaconChainHarness, EphemeralHarnessType};
|
||||
use beacon_chain::types::*;
|
||||
use lazy_static::lazy_static;
|
||||
use std::sync::LazyLock;
|
||||
use swap_or_not_shuffle::shuffle_list;
|
||||
|
||||
pub const VALIDATOR_COUNT: usize = 16;
|
||||
|
||||
lazy_static! {
|
||||
/// A cached set of keys.
|
||||
static ref KEYPAIRS: Vec<Keypair> = generate_deterministic_keypairs(VALIDATOR_COUNT);
|
||||
}
|
||||
/// A cached set of keys.
|
||||
static KEYPAIRS: LazyLock<Vec<Keypair>> =
|
||||
LazyLock::new(|| generate_deterministic_keypairs(VALIDATOR_COUNT));
|
||||
|
||||
fn get_harness<E: EthSpec>(validator_count: usize) -> BeaconChainHarness<EphemeralHarnessType<E>> {
|
||||
let harness = BeaconChainHarness::builder(E::default())
|
||||
|
||||
@@ -6,18 +6,17 @@ use beacon_chain::types::{
|
||||
ChainSpec, Domain, Epoch, EthSpec, Hash256, Keypair, MainnetEthSpec, MinimalEthSpec,
|
||||
RelativeEpoch, Slot, Vector,
|
||||
};
|
||||
use lazy_static::lazy_static;
|
||||
use ssz::Encode;
|
||||
use std::ops::Mul;
|
||||
use std::sync::LazyLock;
|
||||
use swap_or_not_shuffle::compute_shuffled_index;
|
||||
|
||||
pub const MAX_VALIDATOR_COUNT: usize = 129;
|
||||
pub const SLOT_OFFSET: Slot = Slot::new(1);
|
||||
|
||||
lazy_static! {
|
||||
/// A cached set of keys.
|
||||
static ref KEYPAIRS: Vec<Keypair> = generate_deterministic_keypairs(MAX_VALIDATOR_COUNT);
|
||||
}
|
||||
/// A cached set of keys.
|
||||
static KEYPAIRS: LazyLock<Vec<Keypair>> =
|
||||
LazyLock::new(|| generate_deterministic_keypairs(MAX_VALIDATOR_COUNT));
|
||||
|
||||
async fn get_harness<E: EthSpec>(
|
||||
validator_count: usize,
|
||||
|
||||
@@ -1,23 +1,21 @@
|
||||
//! Identifies each shard by an integer identifier.
|
||||
use crate::{AttestationRef, ChainSpec, CommitteeIndex, Epoch, EthSpec, Slot};
|
||||
use lazy_static::lazy_static;
|
||||
use safe_arith::{ArithError, SafeArith};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::sync::LazyLock;
|
||||
use swap_or_not_shuffle::compute_shuffled_index;
|
||||
|
||||
const MAX_SUBNET_ID: usize = 64;
|
||||
|
||||
lazy_static! {
|
||||
static ref SUBNET_ID_TO_STRING: Vec<String> = {
|
||||
let mut v = Vec::with_capacity(MAX_SUBNET_ID);
|
||||
static SUBNET_ID_TO_STRING: LazyLock<Vec<String>> = LazyLock::new(|| {
|
||||
let mut v = Vec::with_capacity(MAX_SUBNET_ID);
|
||||
|
||||
for i in 0..MAX_SUBNET_ID {
|
||||
v.push(i.to_string());
|
||||
}
|
||||
v
|
||||
};
|
||||
}
|
||||
for i in 0..MAX_SUBNET_ID {
|
||||
v.push(i.to_string());
|
||||
}
|
||||
v
|
||||
});
|
||||
|
||||
#[derive(arbitrary::Arbitrary, Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[serde(transparent)]
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
//! Identifies each sync committee subnet by an integer identifier.
|
||||
use crate::consts::altair::SYNC_COMMITTEE_SUBNET_COUNT;
|
||||
use crate::EthSpec;
|
||||
use lazy_static::lazy_static;
|
||||
use safe_arith::{ArithError, SafeArith};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use ssz_types::typenum::Unsigned;
|
||||
use std::collections::HashSet;
|
||||
use std::fmt::{self, Display};
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::sync::LazyLock;
|
||||
|
||||
lazy_static! {
|
||||
static ref SYNC_SUBNET_ID_TO_STRING: Vec<String> = {
|
||||
let mut v = Vec::with_capacity(SYNC_COMMITTEE_SUBNET_COUNT as usize);
|
||||
static SYNC_SUBNET_ID_TO_STRING: LazyLock<Vec<String>> = LazyLock::new(|| {
|
||||
let mut v = Vec::with_capacity(SYNC_COMMITTEE_SUBNET_COUNT as usize);
|
||||
|
||||
for i in 0..SYNC_COMMITTEE_SUBNET_COUNT {
|
||||
v.push(i.to_string());
|
||||
}
|
||||
v
|
||||
};
|
||||
}
|
||||
for i in 0..SYNC_COMMITTEE_SUBNET_COUNT {
|
||||
v.push(i.to_string());
|
||||
}
|
||||
v
|
||||
});
|
||||
|
||||
#[derive(arbitrary::Arbitrary, Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[serde(transparent)]
|
||||
|
||||
Reference in New Issue
Block a user