Skip to content

Commit f35975e

Browse files
committed
fix: use revm spec consistently
1 parent 6985f96 commit f35975e

File tree

8 files changed

+56
-23
lines changed

8 files changed

+56
-23
lines changed

Cargo.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ signet-rpc = { version = "0.12", path = "crates/rpc" }
4646

4747
init4-bin-base = { version = "0.13.1", features = ["alloy"] }
4848

49-
signet-bundle = "0.13"
50-
signet-constants = "0.13"
51-
signet-evm = "0.13"
52-
signet-extract = "0.13"
53-
signet-test-utils = "0.13"
54-
signet-tx-cache = "0.13"
55-
signet-types = "0.13"
56-
signet-zenith = "0.13"
57-
signet-journal = "0.13"
49+
signet-bundle = "0.14"
50+
signet-constants = "0.14"
51+
signet-evm = "0.14"
52+
signet-extract = "0.14"
53+
signet-test-utils = "0.14"
54+
signet-tx-cache = "0.14"
55+
signet-types = "0.14"
56+
signet-zenith = "0.14"
57+
signet-journal = "0.14"
5858

5959
# ajj
6060
ajj = { version = "0.3.4" }

crates/block-processor/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ pub(crate) mod metrics;
1616
mod alias;
1717
pub use alias::{AliasOracle, AliasOracleFactory};
1818

19+
mod utils;
20+
pub use utils::revm_spec;
21+
1922
mod v1;
2023
pub use v1::SignetBlockProcessor as SignetBlockProcessorV1;
2124

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
use reth::revm::primitives::hardfork::SpecId;
2+
use reth_chainspec::EthereumHardforks;
3+
4+
/// Equivalent to [`reth_evm_ethereum::revm_spec`], however, always starts at
5+
/// [`SpecId::PRAGUE`] and transitions to [`SpecId::OSAKA`].
6+
pub fn revm_spec(chain_spec: &reth::chainspec::ChainSpec, timestamp: u64) -> SpecId {
7+
if chain_spec.is_osaka_active_at_timestamp(timestamp) { SpecId::OSAKA } else { SpecId::PRAGUE }
8+
}
9+
10+
/// This is simply a compile-time assertion to ensure that all SpecIds are
11+
/// covered in the match. When this fails to compile, it indicates that a new
12+
/// hardfork has been added and [`revm_spec`] needs to be updated.
13+
#[allow(dead_code)]
14+
const fn assert_in_range(spec_id: SpecId) {
15+
match spec_id {
16+
SpecId::FRONTIER
17+
| SpecId::FRONTIER_THAWING
18+
| SpecId::HOMESTEAD
19+
| SpecId::DAO_FORK
20+
| SpecId::TANGERINE
21+
| SpecId::SPURIOUS_DRAGON
22+
| SpecId::BYZANTIUM
23+
| SpecId::CONSTANTINOPLE
24+
| SpecId::PETERSBURG
25+
| SpecId::ISTANBUL
26+
| SpecId::MUIR_GLACIER
27+
| SpecId::BERLIN
28+
| SpecId::LONDON
29+
| SpecId::ARROW_GLACIER
30+
| SpecId::GRAY_GLACIER
31+
| SpecId::MERGE
32+
| SpecId::SHANGHAI
33+
| SpecId::CANCUN
34+
| SpecId::PRAGUE
35+
| SpecId::OSAKA => {}
36+
}
37+
}

crates/block-processor/src/v1/processor.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use reth::{
1414
},
1515
revm::{database::StateProviderDatabase, db::StateBuilder},
1616
};
17-
use reth_chainspec::{ChainSpec, EthereumHardforks};
17+
use reth_chainspec::ChainSpec;
1818
use reth_node_api::{FullNodeComponents, NodeTypes};
1919
use signet_blobber::{CacheHandle, ExtractableChainShim};
2020
use signet_constants::SignetSystemConstants;
@@ -80,11 +80,7 @@ where
8080

8181
/// Get the active spec id at the given timestamp.
8282
fn spec_id(&self, timestamp: u64) -> SpecId {
83-
if self.chain_spec.is_prague_active_at_timestamp(timestamp) {
84-
SpecId::PRAGUE
85-
} else {
86-
SpecId::CANCUN
87-
}
83+
crate::revm_spec(&self.chain_spec, timestamp)
8884
}
8985

9086
/// Make a [`StateProviderDatabase`] from the read-write provider, suitable

crates/node-config/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ serde.workspace = true
2828
tracing.workspace = true
2929
trevm.workspace = true
3030
signet-genesis.workspace = true
31+
signet-block-processor.workspace = true
3132

3233
[features]
3334
test_utils = ["dep:reth-db", "reth-db/test-utils"]

crates/node-config/src/core.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use alloy::genesis::Genesis;
22
use init4_bin_base::utils::{calc::SlotCalculator, from_env::FromEnv};
33
use reth::providers::providers::StaticFileProvider;
4-
use reth_chainspec::{ChainSpec, EthereumHardforks};
4+
use reth_chainspec::ChainSpec;
55
use reth_node_api::NodePrimitives;
66
use signet_blobber::BlobFetcherConfig;
77
use signet_genesis::GenesisSpec;
@@ -215,11 +215,7 @@ impl SignetNodeConfig {
215215

216216
/// Get the current spec id for the Signet Node chain.
217217
pub fn spec_id(&self, timestamp: u64) -> SpecId {
218-
if self.chain_spec().is_prague_active_at_timestamp(timestamp) {
219-
SpecId::PRAGUE
220-
} else {
221-
SpecId::CANCUN
222-
}
218+
signet_block_processor::revm_spec(self.chain_spec(), timestamp)
223219
}
224220
}
225221

crates/rpc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ reth.workspace = true
2727
reth-chainspec.workspace = true
2828
reth-db.workspace = true
2929
reth-db-common.workspace = true
30-
reth-evm-ethereum.workspace = true
3130
reth-node-api.workspace = true
3231
reth-rpc-eth-api.workspace = true
3332

@@ -45,6 +44,7 @@ tracing.workspace = true
4544
serde_json.workspace = true
4645
futures-util = "0.3.31"
4746
itertools.workspace = true
47+
signet-block-processor.workspace = true
4848

4949
[dev-dependencies]
5050
signet-zenith.workspace = true

crates/rpc/src/ctx/signet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ where
173173

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

179179
/// Access the subscription manager.

0 commit comments

Comments
 (0)