Skip to content

Commit e54fe70

Browse files
committed
chore: memoize spec
1 parent c999571 commit e54fe70

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/tasks/block/cfg.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
//! This file implements the [`trevm::Cfg`] and [`trevm::Block`] traits for Signet and host networks.
22
33
use alloy_chains::NamedChain;
4+
use reth_chainspec::ChainSpec;
45
use signet_block_processor::revm_spec;
56
use signet_constants::pecorino;
7+
use signet_genesis::PECORINO_GENESIS;
8+
use std::sync::LazyLock;
69
use trevm::revm::{context::CfgEnv, primitives::hardfork::SpecId};
710

11+
/// The RU Pecorino [`ChainSpec`].
12+
static PECORINO_SPEC: LazyLock<ChainSpec> =
13+
LazyLock::new(|| ChainSpec::from_genesis(PECORINO_GENESIS.to_owned()));
14+
815
/// [`SignetCfgEnv`] holds network-level configuration values.
916
#[derive(Debug, Clone, Copy)]
1017
pub struct SignetCfgEnv {
@@ -23,12 +30,9 @@ impl SignetCfgEnv {
2330
fn spec_id(&self) -> SpecId {
2431
match self.chain_id {
2532
// Pecorino
26-
pecorino::HOST_CHAIN_ID | pecorino::RU_CHAIN_ID => revm_spec(
27-
&reth_chainspec::ChainSpec::from_genesis(
28-
signet_genesis::PECORINO_GENESIS.to_owned(),
29-
),
30-
self.timestamp,
31-
),
33+
pecorino::HOST_CHAIN_ID | pecorino::RU_CHAIN_ID => {
34+
revm_spec(&PECORINO_SPEC, self.timestamp)
35+
}
3236
// Host Mainnet
3337
id if id == NamedChain::Mainnet as u64 => {
3438
revm_spec(&reth_chainspec::MAINNET, self.timestamp)

0 commit comments

Comments
 (0)