Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/block-processor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ pub(crate) mod metrics;
mod alias;
pub use alias::{AliasOracle, AliasOracleFactory};

mod utils;
pub use utils::revm_spec;

mod v1;
pub use v1::SignetBlockProcessor as SignetBlockProcessorV1;

Expand Down
37 changes: 37 additions & 0 deletions crates/block-processor/src/utils.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use reth::revm::primitives::hardfork::SpecId;
use reth_chainspec::EthereumHardforks;

/// Equivalent to [`reth_evm_ethereum::revm_spec`], however, always starts at
/// [`SpecId::PRAGUE`] and transitions to [`SpecId::OSAKA`].
pub fn revm_spec(chain_spec: &reth::chainspec::ChainSpec, timestamp: u64) -> SpecId {
if chain_spec.is_osaka_active_at_timestamp(timestamp) { SpecId::OSAKA } else { SpecId::PRAGUE }
}

/// This is simply a compile-time assertion to ensure that all SpecIds are
/// covered in the match. When this fails to compile, it indicates that a new
/// hardfork has been added and [`revm_spec`] needs to be updated.
#[allow(dead_code)]
const fn assert_in_range(spec_id: SpecId) {
match spec_id {
SpecId::FRONTIER
| SpecId::FRONTIER_THAWING
| SpecId::HOMESTEAD
| SpecId::DAO_FORK
| SpecId::TANGERINE
| SpecId::SPURIOUS_DRAGON
| SpecId::BYZANTIUM
| SpecId::CONSTANTINOPLE
| SpecId::PETERSBURG
| SpecId::ISTANBUL
| SpecId::MUIR_GLACIER
| SpecId::BERLIN
| SpecId::LONDON
| SpecId::ARROW_GLACIER
| SpecId::GRAY_GLACIER
| SpecId::MERGE
| SpecId::SHANGHAI
| SpecId::CANCUN
| SpecId::PRAGUE
| SpecId::OSAKA => {}
}
}
8 changes: 2 additions & 6 deletions crates/block-processor/src/v1/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use reth::{
},
revm::{database::StateProviderDatabase, db::StateBuilder},
};
use reth_chainspec::{ChainSpec, EthereumHardforks};
use reth_chainspec::ChainSpec;
use reth_node_api::{FullNodeComponents, NodeTypes};
use signet_blobber::{CacheHandle, ExtractableChainShim};
use signet_constants::SignetSystemConstants;
Expand Down Expand Up @@ -80,11 +80,7 @@ where

/// Get the active spec id at the given timestamp.
fn spec_id(&self, timestamp: u64) -> SpecId {
if self.chain_spec.is_prague_active_at_timestamp(timestamp) {
SpecId::PRAGUE
} else {
SpecId::CANCUN
}
crate::revm_spec(&self.chain_spec, timestamp)
}

/// Make a [`StateProviderDatabase`] from the read-write provider, suitable
Expand Down
1 change: 1 addition & 0 deletions crates/node-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ serde.workspace = true
tracing.workspace = true
trevm.workspace = true
signet-genesis.workspace = true
signet-block-processor.workspace = true

[features]
test_utils = ["dep:reth-db", "reth-db/test-utils"]
8 changes: 2 additions & 6 deletions crates/node-config/src/core.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use alloy::genesis::Genesis;
use init4_bin_base::utils::{calc::SlotCalculator, from_env::FromEnv};
use reth::providers::providers::StaticFileProvider;
use reth_chainspec::{ChainSpec, EthereumHardforks};
use reth_chainspec::ChainSpec;
use reth_node_api::NodePrimitives;
use signet_blobber::BlobFetcherConfig;
use signet_genesis::GenesisSpec;
Expand Down Expand Up @@ -215,11 +215,7 @@ impl SignetNodeConfig {

/// Get the current spec id for the Signet Node chain.
pub fn spec_id(&self, timestamp: u64) -> SpecId {
if self.chain_spec().is_prague_active_at_timestamp(timestamp) {
SpecId::PRAGUE
} else {
SpecId::CANCUN
}
signet_block_processor::revm_spec(self.chain_spec(), timestamp)
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ reth.workspace = true
reth-chainspec.workspace = true
reth-db.workspace = true
reth-db-common.workspace = true
reth-evm-ethereum.workspace = true
reth-node-api.workspace = true
reth-rpc-eth-api.workspace = true

Expand All @@ -45,6 +44,7 @@ tracing.workspace = true
serde_json.workspace = true
futures-util = "0.3.31"
itertools.workspace = true
signet-block-processor.workspace = true

[dev-dependencies]
signet-zenith.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/src/ctx/signet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ where

/// Get the EVM spec ID for a given block.
pub fn evm_spec_id(&self, header: &Header) -> SpecId {
reth_evm_ethereum::revm_spec(&self.chain_spec(), header)
signet_block_processor::revm_spec(&self.chain_spec(), header.timestamp())
}

/// Access the subscription manager.
Expand Down
Loading