mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-09 11:25:55 +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:
@@ -4,7 +4,7 @@ version = "5.2.1"
|
||||
authors = ["Sigma Prime <contact@sigmaprime.io>"]
|
||||
edition = { workspace = true }
|
||||
autotests = false
|
||||
rust-version = "1.78.0"
|
||||
rust-version = "1.80.0"
|
||||
|
||||
[features]
|
||||
default = ["slasher-lmdb"]
|
||||
@@ -50,7 +50,6 @@ eth2_network_config = { workspace = true }
|
||||
lighthouse_version = { workspace = true }
|
||||
account_utils = { workspace = true }
|
||||
lighthouse_metrics = { workspace = true }
|
||||
lazy_static = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
serde_yaml = { workspace = true }
|
||||
|
||||
@@ -14,20 +14,20 @@ use environment::{EnvironmentBuilder, LoggerConfig};
|
||||
use eth2_network_config::{Eth2NetworkConfig, DEFAULT_HARDCODED_NETWORK, HARDCODED_NET_NAMES};
|
||||
use ethereum_hashing::have_sha_extensions;
|
||||
use futures::TryFutureExt;
|
||||
use lazy_static::lazy_static;
|
||||
use lighthouse_version::VERSION;
|
||||
use malloc_utils::configure_memory_allocator;
|
||||
use slog::{crit, info};
|
||||
use std::backtrace::Backtrace;
|
||||
use std::path::PathBuf;
|
||||
use std::process::exit;
|
||||
use std::sync::LazyLock;
|
||||
use task_executor::ShutdownReason;
|
||||
use types::{EthSpec, EthSpecId};
|
||||
use validator_client::ProductionValidatorClient;
|
||||
|
||||
lazy_static! {
|
||||
pub static ref SHORT_VERSION: String = VERSION.replace("Lighthouse/", "");
|
||||
pub static ref LONG_VERSION: String = format!(
|
||||
pub static SHORT_VERSION: LazyLock<String> = LazyLock::new(|| VERSION.replace("Lighthouse/", ""));
|
||||
pub static LONG_VERSION: LazyLock<String> = LazyLock::new(|| {
|
||||
format!(
|
||||
"{}\n\
|
||||
BLS library: {}\n\
|
||||
BLS hardware acceleration: {}\n\
|
||||
@@ -43,8 +43,8 @@ lazy_static! {
|
||||
build_profile_name(),
|
||||
cfg!(feature = "spec-minimal"),
|
||||
cfg!(feature = "gnosis"),
|
||||
);
|
||||
}
|
||||
)
|
||||
});
|
||||
|
||||
fn bls_library_name() -> &'static str {
|
||||
if cfg!(feature = "portable") {
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
use lazy_static::lazy_static;
|
||||
pub use lighthouse_metrics::*;
|
||||
use lighthouse_version::VERSION;
|
||||
use slog::{error, Logger};
|
||||
use std::sync::LazyLock;
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
lazy_static! {
|
||||
pub static ref PROCESS_START_TIME_SECONDS: Result<IntGauge> = try_create_int_gauge(
|
||||
pub static PROCESS_START_TIME_SECONDS: LazyLock<Result<IntGauge>> = LazyLock::new(|| {
|
||||
try_create_int_gauge(
|
||||
"process_start_time_seconds",
|
||||
"The unix timestamp at which the process was started"
|
||||
);
|
||||
}
|
||||
"The unix timestamp at which the process was started",
|
||||
)
|
||||
});
|
||||
|
||||
lazy_static! {
|
||||
pub static ref LIGHTHOUSE_VERSION: Result<IntGaugeVec> = try_create_int_gauge_vec(
|
||||
pub static LIGHTHOUSE_VERSION: LazyLock<Result<IntGaugeVec>> = LazyLock::new(|| {
|
||||
try_create_int_gauge_vec(
|
||||
"lighthouse_info",
|
||||
"The build of Lighthouse running on the server",
|
||||
&["version"],
|
||||
);
|
||||
}
|
||||
)
|
||||
});
|
||||
|
||||
pub fn expose_process_start_time(log: &Logger) {
|
||||
match SystemTime::now().duration_since(UNIX_EPOCH) {
|
||||
|
||||
Reference in New Issue
Block a user