mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
refactor: replace once_cell Lazy with LazyLock (#9844)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de> Co-authored-by: Oliver <onbjerg@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
a206eb3690
commit
106a0c7cf7
4
.github/workflows/lint.yml
vendored
4
.github/workflows/lint.yml
vendored
@ -87,7 +87,7 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: "1.79" # MSRV
|
||||
toolchain: "1.80" # MSRV
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
cache-on-failure: true
|
||||
@ -130,7 +130,7 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: "1.79" # MSRV
|
||||
toolchain: "1.80" # MSRV
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
cache-on-failure: true
|
||||
|
||||
5
Cargo.lock
generated
5
Cargo.lock
generated
@ -2914,7 +2914,6 @@ version = "0.0.0"
|
||||
dependencies = [
|
||||
"eyre",
|
||||
"futures",
|
||||
"once_cell",
|
||||
"reth-chainspec",
|
||||
"reth-discv4",
|
||||
"reth-ecies",
|
||||
@ -7474,7 +7473,6 @@ name = "reth-metrics-derive"
|
||||
version = "1.0.4"
|
||||
dependencies = [
|
||||
"metrics",
|
||||
"once_cell",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex",
|
||||
@ -7847,7 +7845,6 @@ dependencies = [
|
||||
"metrics-exporter-prometheus",
|
||||
"metrics-process",
|
||||
"metrics-util",
|
||||
"once_cell",
|
||||
"procfs",
|
||||
"reqwest",
|
||||
"reth-chainspec",
|
||||
@ -8798,7 +8795,6 @@ dependencies = [
|
||||
"derive_more",
|
||||
"itertools 0.13.0",
|
||||
"metrics",
|
||||
"once_cell",
|
||||
"proptest",
|
||||
"proptest-arbitrary-interop",
|
||||
"rayon",
|
||||
@ -8856,7 +8852,6 @@ dependencies = [
|
||||
"derive_more",
|
||||
"itertools 0.13.0",
|
||||
"metrics",
|
||||
"once_cell",
|
||||
"proptest",
|
||||
"proptest-arbitrary-interop",
|
||||
"rayon",
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
[workspace.package]
|
||||
version = "1.0.4"
|
||||
edition = "2021"
|
||||
rust-version = "1.79"
|
||||
rust-version = "1.80"
|
||||
license = "MIT OR Apache-2.0"
|
||||
homepage = "https://paradigmxyz.github.io/reth"
|
||||
repository = "https://github.com/paradigmxyz/reth"
|
||||
@ -448,7 +448,7 @@ itertools = "0.13"
|
||||
linked_hash_set = "0.1"
|
||||
modular-bitfield = "0.11.2"
|
||||
nybbles = "0.2.1"
|
||||
once_cell = "1.17"
|
||||
once_cell = "1.19"
|
||||
parking_lot = "0.12"
|
||||
paste = "1.0"
|
||||
rand = "0.8.5"
|
||||
|
||||
@ -87,7 +87,7 @@ When updating this, also update:
|
||||
- .github/workflows/lint.yml
|
||||
-->
|
||||
|
||||
The Minimum Supported Rust Version (MSRV) of this project is [1.79.0](https://blog.rust-lang.org/2024/06/13/Rust-1.79.0.html).
|
||||
The Minimum Supported Rust Version (MSRV) of this project is [1.80.0](https://blog.rust-lang.org/2024/07/25/Rust-1.80.0.html).
|
||||
|
||||
See the book for detailed instructions on how to [build from source](https://paradigmxyz.github.io/reth/installation/source.html).
|
||||
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
msrv = "1.79"
|
||||
msrv = "1.80"
|
||||
too-large-for-stack = 128
|
||||
|
||||
@ -16,6 +16,7 @@ workspace = true
|
||||
alloy-chains.workspace = true
|
||||
alloy-primitives = { workspace = true, features = ["serde", "rand", "rlp"] }
|
||||
alloy-rlp = { workspace = true, features = ["arrayvec", "derive"] }
|
||||
once_cell.workspace = true
|
||||
|
||||
# used for forkid
|
||||
crc = "3"
|
||||
@ -23,7 +24,6 @@ crc = "3"
|
||||
# misc
|
||||
serde = { workspace = true, features = ["derive"], optional = true }
|
||||
thiserror-no-std = { workspace = true, default-features = false }
|
||||
once_cell.workspace = true
|
||||
dyn-clone.workspace = true
|
||||
rustc-hash = { workspace = true, optional = true }
|
||||
|
||||
|
||||
@ -18,7 +18,6 @@ proc-macro2.workspace = true
|
||||
syn = { workspace = true, features = ["extra-traits"] }
|
||||
quote.workspace = true
|
||||
regex = "1.6.0"
|
||||
once_cell.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
metrics.workspace = true
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use once_cell::sync::Lazy;
|
||||
use quote::{quote, ToTokens};
|
||||
use regex::Regex;
|
||||
use std::sync::LazyLock;
|
||||
use syn::{
|
||||
punctuated::Punctuated, Attribute, Data, DeriveInput, Error, Expr, Field, Lit, LitBool, LitStr,
|
||||
Meta, MetaNameValue, Result, Token,
|
||||
@ -11,8 +11,8 @@ use crate::{metric::Metric, with_attrs::WithAttrs};
|
||||
/// Metric name regex according to Prometheus data model
|
||||
///
|
||||
/// See <https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels>
|
||||
static METRIC_NAME_RE: Lazy<Regex> =
|
||||
Lazy::new(|| Regex::new(r"^[a-zA-Z_:.][a-zA-Z0-9_:.]*$").unwrap());
|
||||
static METRIC_NAME_RE: LazyLock<Regex> =
|
||||
LazyLock::new(|| Regex::new(r"^[a-zA-Z_:.][a-zA-Z0-9_:.]*$").unwrap());
|
||||
|
||||
/// Supported metrics separators
|
||||
const SUPPORTED_SEPARATORS: &[&str] = &[".", "_", ":"];
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
use metrics::{
|
||||
Counter, Gauge, Histogram, Key, KeyName, Label, Metadata, Recorder, SharedString, Unit,
|
||||
};
|
||||
use once_cell::sync::Lazy;
|
||||
use reth_metrics_derive::Metrics;
|
||||
use serial_test::serial;
|
||||
use std::{collections::HashMap, sync::Mutex};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
sync::{LazyLock, Mutex},
|
||||
};
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Metrics)]
|
||||
@ -58,7 +60,7 @@ struct DynamicScopeMetrics {
|
||||
skipped_field_e: u128,
|
||||
}
|
||||
|
||||
static RECORDER: Lazy<TestRecorder> = Lazy::new(TestRecorder::new);
|
||||
static RECORDER: LazyLock<TestRecorder> = LazyLock::new(TestRecorder::new);
|
||||
|
||||
fn test_describe(scope: &str) {
|
||||
assert_eq!(RECORDER.metrics_len(), 4);
|
||||
|
||||
@ -20,8 +20,6 @@ metrics-util.workspace = true
|
||||
|
||||
tokio.workspace = true
|
||||
|
||||
once_cell.workspace = true
|
||||
|
||||
jsonrpsee = { workspace = true, features = ["server"] }
|
||||
http.workspace = true
|
||||
tower.workspace = true
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
use eyre::WrapErr;
|
||||
use metrics_exporter_prometheus::{PrometheusBuilder, PrometheusHandle};
|
||||
use metrics_util::layers::{PrefixLayer, Stack};
|
||||
use once_cell::sync::Lazy;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
/// Installs the Prometheus recorder as the global recorder.
|
||||
pub fn install_prometheus_recorder() -> &'static PrometheusHandle {
|
||||
@ -12,8 +12,8 @@ pub fn install_prometheus_recorder() -> &'static PrometheusHandle {
|
||||
|
||||
/// The default Prometheus recorder handle. We use a global static to ensure that it is only
|
||||
/// installed once.
|
||||
static PROMETHEUS_RECORDER_HANDLE: Lazy<PrometheusHandle> =
|
||||
Lazy::new(|| PrometheusRecorder::install().unwrap());
|
||||
static PROMETHEUS_RECORDER_HANDLE: LazyLock<PrometheusHandle> =
|
||||
LazyLock::new(|| PrometheusRecorder::install().unwrap());
|
||||
|
||||
/// Prometheus recorder installer
|
||||
#[derive(Debug)]
|
||||
|
||||
@ -42,9 +42,9 @@ c-kzg = { workspace = true, features = ["serde"], optional = true }
|
||||
bytes.workspace = true
|
||||
derive_more.workspace = true
|
||||
modular-bitfield = { workspace = true, optional = true }
|
||||
once_cell.workspace = true
|
||||
rayon.workspace = true
|
||||
serde.workspace = true
|
||||
once_cell.workspace = true
|
||||
tempfile = { workspace = true, optional = true }
|
||||
thiserror = { workspace = true, optional = true }
|
||||
zstd = { workspace = true, features = ["experimental"], optional = true }
|
||||
|
||||
@ -68,7 +68,6 @@ tokio = { workspace = true, default-features = false, features = [
|
||||
"macros",
|
||||
] }
|
||||
tokio-stream.workspace = true
|
||||
once_cell.workspace = true
|
||||
serde_json.workspace = true
|
||||
similar-asserts.workspace = true
|
||||
criterion.workspace = true
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
use once_cell::sync::Lazy;
|
||||
use reth_chainspec::{Chain, ChainSpec, HOLESKY, MAINNET};
|
||||
use reth_db_api::database::Database;
|
||||
use reth_primitives::{
|
||||
@ -11,7 +10,10 @@ use reth_storage_errors::provider::ProviderResult;
|
||||
use reth_trie::{proof::Proof, Nibbles, StateRoot};
|
||||
use reth_trie_common::{AccountProof, StorageProof};
|
||||
use reth_trie_db::{DatabaseProof, DatabaseStateRoot};
|
||||
use std::{str::FromStr, sync::Arc};
|
||||
use std::{
|
||||
str::FromStr,
|
||||
sync::{Arc, LazyLock},
|
||||
};
|
||||
|
||||
/*
|
||||
World State (sampled from <https://ethereum.stackexchange.com/questions/268/ethereum-block-architecture/6413#6413>)
|
||||
@ -24,7 +26,7 @@ use std::{str::FromStr, sync::Arc};
|
||||
|
||||
All expected testspec results were obtained from querying proof RPC on the running geth instance `geth init crates/trie/testdata/proof-genesis.json && geth --http`.
|
||||
*/
|
||||
static TEST_SPEC: Lazy<Arc<ChainSpec>> = Lazy::new(|| {
|
||||
static TEST_SPEC: LazyLock<Arc<ChainSpec>> = LazyLock::new(|| {
|
||||
ChainSpec {
|
||||
chain: Chain::from_id(12345),
|
||||
genesis: serde_json::from_str(include_str!("../../trie/testdata/proof-genesis.json"))
|
||||
|
||||
@ -62,7 +62,6 @@ tokio = { workspace = true, default-features = false, features = [
|
||||
"macros",
|
||||
] }
|
||||
tokio-stream.workspace = true
|
||||
once_cell.workspace = true
|
||||
serde_json.workspace = true
|
||||
similar-asserts.workspace = true
|
||||
criterion.workspace = true
|
||||
|
||||
@ -20,4 +20,3 @@ futures.workspace = true
|
||||
tokio.workspace = true
|
||||
|
||||
eyre.workspace = true
|
||||
once_cell.workspace = true
|
||||
|
||||
@ -9,7 +9,6 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use futures::StreamExt;
|
||||
use once_cell::sync::Lazy;
|
||||
use reth_chainspec::{Chain, MAINNET};
|
||||
use reth_discv4::{DiscoveryUpdate, Discv4, Discv4ConfigBuilder, DEFAULT_DISCOVERY_ADDRESS};
|
||||
use reth_ecies::stream::ECIESStream;
|
||||
@ -20,12 +19,13 @@ use reth_network::config::rng_secret_key;
|
||||
use reth_network_peers::{mainnet_nodes, pk2id, NodeRecord};
|
||||
use reth_primitives::{EthereumHardfork, Head, MAINNET_GENESIS_HASH};
|
||||
use secp256k1::{SecretKey, SECP256K1};
|
||||
use std::sync::LazyLock;
|
||||
use tokio::net::TcpStream;
|
||||
|
||||
type AuthedP2PStream = P2PStream<ECIESStream<TcpStream>>;
|
||||
type AuthedEthStream = EthStream<P2PStream<ECIESStream<TcpStream>>>;
|
||||
|
||||
pub static MAINNET_BOOT_NODES: Lazy<Vec<NodeRecord>> = Lazy::new(mainnet_nodes);
|
||||
pub static MAINNET_BOOT_NODES: LazyLock<Vec<NodeRecord>> = LazyLock::new(mainnet_nodes);
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> eyre::Result<()> {
|
||||
|
||||
Reference in New Issue
Block a user