mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 19:51:47 +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:
@@ -1,42 +1,62 @@
|
||||
use lazy_static::lazy_static;
|
||||
pub use lighthouse_metrics::*;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
lazy_static! {
|
||||
/*
|
||||
* Participation Metrics
|
||||
*/
|
||||
pub static ref PARTICIPATION_PREV_EPOCH_HEAD_ATTESTING_GWEI_TOTAL: Result<IntGauge> = try_create_int_gauge(
|
||||
/*
|
||||
* Participation Metrics
|
||||
*/
|
||||
pub static PARTICIPATION_PREV_EPOCH_HEAD_ATTESTING_GWEI_TOTAL: LazyLock<Result<IntGauge>> =
|
||||
LazyLock::new(|| {
|
||||
try_create_int_gauge(
|
||||
"beacon_participation_prev_epoch_head_attesting_gwei_total",
|
||||
"Total effective balance (gwei) of validators who attested to the head in the previous epoch"
|
||||
);
|
||||
pub static ref PARTICIPATION_PREV_EPOCH_TARGET_ATTESTING_GWEI_TOTAL: Result<IntGauge> = try_create_int_gauge(
|
||||
)
|
||||
});
|
||||
pub static PARTICIPATION_PREV_EPOCH_TARGET_ATTESTING_GWEI_TOTAL: LazyLock<Result<IntGauge>> =
|
||||
LazyLock::new(|| {
|
||||
try_create_int_gauge(
|
||||
"beacon_participation_prev_epoch_target_attesting_gwei_total",
|
||||
"Total effective balance (gwei) of validators who attested to the target in the previous epoch"
|
||||
);
|
||||
pub static ref PARTICIPATION_PREV_EPOCH_SOURCE_ATTESTING_GWEI_TOTAL: Result<IntGauge> = try_create_int_gauge(
|
||||
)
|
||||
});
|
||||
pub static PARTICIPATION_PREV_EPOCH_SOURCE_ATTESTING_GWEI_TOTAL: LazyLock<Result<IntGauge>> =
|
||||
LazyLock::new(|| {
|
||||
try_create_int_gauge(
|
||||
"beacon_participation_prev_epoch_source_attesting_gwei_total",
|
||||
"Total effective balance (gwei) of validators who attested to the source in the previous epoch"
|
||||
);
|
||||
pub static ref PARTICIPATION_CURRENT_EPOCH_TOTAL_ACTIVE_GWEI_TOTAL: Result<IntGauge> = try_create_int_gauge(
|
||||
"beacon_participation_current_epoch_active_gwei_total",
|
||||
"Total effective balance (gwei) of validators who are active in the current epoch"
|
||||
);
|
||||
/*
|
||||
* Processing metrics
|
||||
*/
|
||||
pub static ref PROCESS_EPOCH_TIME: Result<Histogram> = try_create_histogram(
|
||||
)
|
||||
});
|
||||
pub static PARTICIPATION_CURRENT_EPOCH_TOTAL_ACTIVE_GWEI_TOTAL: LazyLock<Result<IntGauge>> =
|
||||
LazyLock::new(|| {
|
||||
try_create_int_gauge(
|
||||
"beacon_participation_current_epoch_active_gwei_total",
|
||||
"Total effective balance (gwei) of validators who are active in the current epoch",
|
||||
)
|
||||
});
|
||||
/*
|
||||
* Processing metrics
|
||||
*/
|
||||
pub static PROCESS_EPOCH_TIME: LazyLock<Result<Histogram>> = LazyLock::new(|| {
|
||||
try_create_histogram(
|
||||
"beacon_state_processing_process_epoch",
|
||||
"Time required for process_epoch",
|
||||
);
|
||||
/*
|
||||
* Participation Metrics (progressive balances)
|
||||
*/
|
||||
pub static ref PARTICIPATION_PREV_EPOCH_TARGET_ATTESTING_GWEI_PROGRESSIVE_TOTAL: Result<IntGauge> = try_create_int_gauge(
|
||||
)
|
||||
});
|
||||
/*
|
||||
* Participation Metrics (progressive balances)
|
||||
*/
|
||||
pub static PARTICIPATION_PREV_EPOCH_TARGET_ATTESTING_GWEI_PROGRESSIVE_TOTAL: LazyLock<
|
||||
Result<IntGauge>,
|
||||
> = LazyLock::new(|| {
|
||||
try_create_int_gauge(
|
||||
"beacon_participation_prev_epoch_target_attesting_gwei_progressive_total",
|
||||
"Progressive total effective balance (gwei) of validators who attested to the target in the previous epoch"
|
||||
);
|
||||
pub static ref PARTICIPATION_CURR_EPOCH_TARGET_ATTESTING_GWEI_PROGRESSIVE_TOTAL: Result<IntGauge> = try_create_int_gauge(
|
||||
)
|
||||
});
|
||||
pub static PARTICIPATION_CURR_EPOCH_TARGET_ATTESTING_GWEI_PROGRESSIVE_TOTAL: LazyLock<
|
||||
Result<IntGauge>,
|
||||
> = LazyLock::new(|| {
|
||||
try_create_int_gauge(
|
||||
"beacon_participation_curr_epoch_target_attesting_gwei_progressive_total",
|
||||
"Progressive total effective balance (gwei) of validators who attested to the target in the current epoch"
|
||||
);
|
||||
}
|
||||
)
|
||||
});
|
||||
|
||||
@@ -11,8 +11,8 @@ use crate::{
|
||||
BlockSignatureStrategy, ConsensusContext, VerifyBlockRoot, VerifySignatures,
|
||||
};
|
||||
use beacon_chain::test_utils::{BeaconChainHarness, EphemeralHarnessType};
|
||||
use lazy_static::lazy_static;
|
||||
use ssz_types::Bitfield;
|
||||
use std::sync::LazyLock;
|
||||
use test_utils::generate_deterministic_keypairs;
|
||||
use types::*;
|
||||
|
||||
@@ -22,10 +22,9 @@ pub const VALIDATOR_COUNT: usize = 64;
|
||||
pub const EPOCH_OFFSET: u64 = 4;
|
||||
pub const NUM_ATTESTATIONS: u64 = 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>(
|
||||
epoch_offset: u64,
|
||||
|
||||
Reference in New Issue
Block a user