Skip to content

Commit e6cad69

Browse files
committed
removed lazy_static and use LazyCell/LazyLock
Signed-off-by: lakshya-sky <[email protected]>
1 parent 1be3fe7 commit e6cad69

File tree

21 files changed

+236
-246
lines changed

21 files changed

+236
-246
lines changed

Cargo.lock

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/ethrex/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ rand = "0.8.5"
4646
rayon.workspace = true
4747
local-ip-address = "0.6"
4848
tokio-util.workspace = true
49-
lazy_static.workspace = true
5049
secp256k1.workspace = true
5150
reqwest.workspace = true
5251
thiserror.workspace = true

cmd/ethrex/l2/deployer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::{
44
path::PathBuf,
55
process::{Command, Stdio},
66
str::FromStr,
7+
sync::LazyLock,
78
};
89

910
use bytes::Bytes;
@@ -568,9 +569,8 @@ pub async fn deploy_l1_contracts(
568569
Ok(contract_addresses)
569570
}
570571

571-
lazy_static::lazy_static! {
572-
static ref SALT: std::sync::Mutex<H256> = std::sync::Mutex::new(H256::zero());
573-
}
572+
static SALT: LazyLock<std::sync::Mutex<H256>> =
573+
LazyLock::new(|| std::sync::Mutex::new(H256::zero()));
574574

575575
async fn deploy_contracts(
576576
eth_client: &EthClient,

crates/common/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ libc = "0.2"
2626
crc32fast.workspace = true
2727
bytes.workspace = true
2828
hex.workspace = true
29-
lazy_static.workspace = true
3029
rayon.workspace = true
3130
url.workspace = true
3231
rkyv.workspace = true

crates/common/rlp/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ tinyvec = "1.6.0"
1010
thiserror.workspace = true
1111
bytes.workspace = true
1212
hex.workspace = true
13-
lazy_static.workspace = true
1413
ethereum-types.workspace = true
1514
snap.workspace = true
1615

crates/common/trie/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ serde_json = "1.0.117"
2121
rocksdb = { workspace = true, optional = true }
2222
smallvec = { version = "1.10.0", features = ["const_generics", "union"] }
2323
digest = "0.10.6"
24-
lazy_static.workspace = true
2524
crossbeam.workspace = true
2625
rustc-hash.workspace = true
2726
rkyv.workspace = true

crates/common/trie/trie.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use ethrex_rlp::constants::RLP_NULL;
1717
use ethrex_rlp::encode::RLPEncode;
1818
use rustc_hash::FxHashSet;
1919
use std::collections::BTreeMap;
20-
use std::sync::{Arc, Mutex};
20+
use std::sync::{Arc, LazyLock, Mutex};
2121

2222
pub use self::db::{InMemoryTrieDB, TrieDB};
2323
pub use self::logger::{TrieLogger, TrieWitness};
@@ -32,14 +32,9 @@ pub use self::error::{ExtensionNodeErrorData, InconsistentTreeError, TrieError};
3232
use self::{node::LeafNode, trie_iter::TrieIterator};
3333

3434
use ethrex_rlp::decode::RLPDecode;
35-
use lazy_static::lazy_static;
3635

37-
lazy_static! {
38-
// Hash value for an empty trie, equal to keccak(RLP_NULL)
39-
pub static ref EMPTY_TRIE_HASH: H256 = H256(
40-
keccak_hash([RLP_NULL]),
41-
);
42-
}
36+
// Hash value for an empty trie, equal to keccak(RLP_NULL)
37+
pub static EMPTY_TRIE_HASH: LazyLock<H256> = LazyLock::new(|| H256(keccak_hash([RLP_NULL])));
4338

4439
/// RLP-encoded trie path
4540
pub type PathRLP = Vec<u8>;

crates/common/types/genesis.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use std::{
99
collections::{BTreeMap, HashMap},
1010
io::{BufReader, Error},
1111
path::Path,
12+
sync::LazyLock,
1213
};
1314
use tracing::warn;
1415

@@ -266,18 +267,16 @@ pub struct ChainConfig {
266267
pub enable_verkle_at_genesis: bool,
267268
}
268269

269-
lazy_static::lazy_static! {
270-
pub static ref NETWORK_NAMES: HashMap<u64, &'static str> = {
271-
HashMap::from([
272-
(1, "mainnet"),
273-
(11155111, "sepolia"),
274-
(17000, "holesky"),
275-
(560048, "hoodi"),
276-
(9, "L1 local devnet"),
277-
(65536999, "L2 local devnet"),
278-
])
279-
};
280-
}
270+
pub static NETWORK_NAMES: LazyLock<HashMap<u64, &'static str>> = LazyLock::new(|| {
271+
HashMap::from([
272+
(1, "mainnet"),
273+
(11155111, "sepolia"),
274+
(17000, "holesky"),
275+
(560048, "hoodi"),
276+
(9, "L1 local devnet"),
277+
(65536999, "L2 local devnet"),
278+
])
279+
});
281280

282281
#[repr(u8)]
283282
#[derive(Debug, PartialEq, Eq, PartialOrd, Default, Hash, Clone, Copy, Serialize, Deserialize)]

crates/l2/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ futures.workspace = true
4444
directories = "5.0.1"
4545
bincode = "1.3.3"
4646
serde_with.workspace = true
47-
lazy_static.workspace = true
4847
aligned-sdk.workspace = true
4948
ethers = "2.0"
5049
chrono = "0.4.41"

crates/l2/sdk/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ ethrex-rlp.workspace = true
2525
bytes.workspace = true
2626
reqwest.workspace = true
2727
eyre.workspace = true
28-
lazy_static.workspace = true
2928

3029
[lib]
3130
name = "ethrex_l2_sdk"

0 commit comments

Comments
 (0)