Move OptimismHardfork to new crate reth_optimism_forks (#10963)

This commit is contained in:
Emilia Hane
2024-09-20 18:51:45 +02:00
committed by GitHub
parent 63f2d59068
commit 66089682d7
42 changed files with 302 additions and 120 deletions

29
Cargo.lock generated
View File

@ -730,9 +730,9 @@ dependencies = [
[[package]] [[package]]
name = "alloy-trie" name = "alloy-trie"
version = "0.5.3" version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a46c9c4fdccda7982e7928904bd85fe235a0404ee3d7e197fff13d61eac8b4f" checksum = "398a977d774db13446b8cead8cfa9517aebf9e03fc8a1512892dc1e03e70bb04"
dependencies = [ dependencies = [
"alloy-primitives", "alloy-primitives",
"alloy-rlp", "alloy-rlp",
@ -4410,7 +4410,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"windows-targets 0.48.5", "windows-targets 0.52.6",
] ]
[[package]] [[package]]
@ -6463,6 +6463,7 @@ dependencies = [
"op-alloy-rpc-types", "op-alloy-rpc-types",
"reth-ethereum-forks", "reth-ethereum-forks",
"reth-network-peers", "reth-network-peers",
"reth-optimism-forks",
"reth-primitives-traits", "reth-primitives-traits",
"reth-trie-common", "reth-trie-common",
"serde", "serde",
@ -7170,9 +7171,11 @@ name = "reth-ethereum-cli"
version = "1.0.7" version = "1.0.7"
dependencies = [ dependencies = [
"alloy-genesis", "alloy-genesis",
"clap",
"eyre", "eyre",
"reth-chainspec", "reth-chainspec",
"reth-cli", "reth-cli",
"reth-cli-commands",
"serde_json", "serde_json",
"shellexpand", "shellexpand",
] ]
@ -7308,6 +7311,7 @@ dependencies = [
"reth-execution-types", "reth-execution-types",
"reth-optimism-chainspec", "reth-optimism-chainspec",
"reth-optimism-consensus", "reth-optimism-consensus",
"reth-optimism-forks",
"reth-primitives", "reth-primitives",
"reth-prune-types", "reth-prune-types",
"reth-revm", "reth-revm",
@ -7942,6 +7946,7 @@ dependencies = [
"reth-node-builder", "reth-node-builder",
"reth-optimism-chainspec", "reth-optimism-chainspec",
"reth-optimism-consensus", "reth-optimism-consensus",
"reth-optimism-forks",
"reth-optimism-payload-builder", "reth-optimism-payload-builder",
"reth-optimism-rpc", "reth-optimism-rpc",
"reth-payload-builder", "reth-payload-builder",
@ -7983,6 +7988,7 @@ dependencies = [
"op-alloy-rpc-types", "op-alloy-rpc-types",
"reth-chainspec", "reth-chainspec",
"reth-ethereum-forks", "reth-ethereum-forks",
"reth-optimism-forks",
"reth-primitives-traits", "reth-primitives-traits",
"serde_json", "serde_json",
] ]
@ -8039,11 +8045,23 @@ dependencies = [
"reth-consensus", "reth-consensus",
"reth-consensus-common", "reth-consensus-common",
"reth-optimism-chainspec", "reth-optimism-chainspec",
"reth-optimism-forks",
"reth-primitives", "reth-primitives",
"reth-trie-common", "reth-trie-common",
"tracing", "tracing",
] ]
[[package]]
name = "reth-optimism-forks"
version = "1.0.7"
dependencies = [
"alloy-chains",
"alloy-primitives",
"once_cell",
"reth-ethereum-forks",
"serde",
]
[[package]] [[package]]
name = "reth-optimism-payload-builder" name = "reth-optimism-payload-builder"
version = "1.0.7" version = "1.0.7"
@ -8056,6 +8074,7 @@ dependencies = [
"reth-evm", "reth-evm",
"reth-evm-optimism", "reth-evm-optimism",
"reth-execution-types", "reth-execution-types",
"reth-optimism-forks",
"reth-payload-builder", "reth-payload-builder",
"reth-payload-primitives", "reth-payload-primitives",
"reth-primitives", "reth-primitives",
@ -8099,6 +8118,7 @@ dependencies = [
"reth-node-api", "reth-node-api",
"reth-node-builder", "reth-node-builder",
"reth-optimism-chainspec", "reth-optimism-chainspec",
"reth-optimism-forks",
"reth-primitives", "reth-primitives",
"reth-provider", "reth-provider",
"reth-rpc", "reth-rpc",
@ -8197,6 +8217,7 @@ dependencies = [
"reth-codecs", "reth-codecs",
"reth-ethereum-forks", "reth-ethereum-forks",
"reth-optimism-chainspec", "reth-optimism-chainspec",
"reth-optimism-forks",
"reth-primitives-traits", "reth-primitives-traits",
"reth-static-file-types", "reth-static-file-types",
"reth-trie-common", "reth-trie-common",
@ -11175,7 +11196,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [ dependencies = [
"windows-sys 0.48.0", "windows-sys 0.59.0",
] ]
[[package]] [[package]]

View File

@ -74,6 +74,7 @@ members = [
"crates/optimism/cli", "crates/optimism/cli",
"crates/optimism/consensus", "crates/optimism/consensus",
"crates/optimism/evm/", "crates/optimism/evm/",
"crates/optimism/hardforks/",
"crates/optimism/node/", "crates/optimism/node/",
"crates/optimism/payload/", "crates/optimism/payload/",
"crates/optimism/primitives/", "crates/optimism/primitives/",
@ -363,6 +364,7 @@ reth-node-types = { path = "crates/node/types" }
reth-optimism-chainspec = { path = "crates/optimism/chainspec" } reth-optimism-chainspec = { path = "crates/optimism/chainspec" }
reth-optimism-cli = { path = "crates/optimism/cli" } reth-optimism-cli = { path = "crates/optimism/cli" }
reth-optimism-consensus = { path = "crates/optimism/consensus" } reth-optimism-consensus = { path = "crates/optimism/consensus" }
reth-optimism-forks = { path = "crates/optimism/hardforks" }
reth-optimism-payload-builder = { path = "crates/optimism/payload" } reth-optimism-payload-builder = { path = "crates/optimism/payload" }
reth-optimism-primitives = { path = "crates/optimism/primitives" } reth-optimism-primitives = { path = "crates/optimism/primitives" }
reth-optimism-rpc = { path = "crates/optimism/rpc" } reth-optimism-rpc = { path = "crates/optimism/rpc" }

View File

@ -17,6 +17,9 @@ reth-network-peers.workspace = true
reth-trie-common.workspace = true reth-trie-common.workspace = true
reth-primitives-traits.workspace = true reth-primitives-traits.workspace = true
# op-reth
reth-optimism-forks = { workspace = true, optional = true }
# ethereum # ethereum
alloy-chains = { workspace = true, features = ["serde", "rlp"] } alloy-chains = { workspace = true, features = ["serde", "rlp"] }
alloy-eips = { workspace = true, features = ["serde"] } alloy-eips = { workspace = true, features = ["serde"] }
@ -47,9 +50,9 @@ op-alloy-rpc-types.workspace = true
[features] [features]
default = ["std"] default = ["std"]
optimism = [ optimism = [
"reth-ethereum-forks/optimism",
"serde", "serde",
"dep:op-alloy-rpc-types", "dep:op-alloy-rpc-types",
"reth-optimism-forks",
] ]
std = [] std = []
arbitrary = [ arbitrary = [

View File

@ -1,4 +1,5 @@
use crate::{constants::MAINNET_DEPOSIT_CONTRACT, once_cell_set, EthChainSpec}; pub use alloy_eips::eip1559::BaseFeeParams;
use alloc::{boxed::Box, sync::Arc, vec::Vec}; use alloc::{boxed::Box, sync::Arc, vec::Vec};
use alloy_chains::{Chain, NamedChain}; use alloy_chains::{Chain, NamedChain};
use alloy_genesis::Genesis; use alloy_genesis::Genesis;
@ -8,8 +9,7 @@ use derive_more::From;
use once_cell::sync::{Lazy, OnceCell}; use once_cell::sync::{Lazy, OnceCell};
use reth_ethereum_forks::{ use reth_ethereum_forks::{
ChainHardforks, DisplayHardforks, EthereumHardfork, EthereumHardforks, ForkCondition, ChainHardforks, DisplayHardforks, EthereumHardfork, EthereumHardforks, ForkCondition,
ForkFilter, ForkFilterKey, ForkHash, ForkId, Hardfork, Hardforks, Head, OptimismHardforks, ForkFilter, ForkFilterKey, ForkHash, ForkId, Hardfork, Hardforks, Head, DEV_HARDFORKS,
DEV_HARDFORKS,
}; };
use reth_network_peers::{ use reth_network_peers::{
base_nodes, base_testnet_nodes, holesky_nodes, mainnet_nodes, op_nodes, op_testnet_nodes, base_nodes, base_testnet_nodes, holesky_nodes, mainnet_nodes, op_nodes, op_testnet_nodes,
@ -24,7 +24,7 @@ use reth_primitives_traits::{
}; };
use reth_trie_common::root::state_root_ref_unhashed; use reth_trie_common::root::state_root_ref_unhashed;
pub use alloy_eips::eip1559::BaseFeeParams; use crate::{constants::MAINNET_DEPOSIT_CONTRACT, once_cell_set, EthChainSpec};
/// The Ethereum mainnet spec /// The Ethereum mainnet spec
pub static MAINNET: Lazy<Arc<ChainSpec>> = Lazy::new(|| { pub static MAINNET: Lazy<Arc<ChainSpec>> = Lazy::new(|| {
@ -244,7 +244,7 @@ impl ChainSpec {
#[cfg(feature = "optimism")] #[cfg(feature = "optimism")]
pub fn is_optimism(&self) -> bool { pub fn is_optimism(&self) -> bool {
self.chain.is_optimism() || self.chain.is_optimism() ||
self.hardforks.get(reth_ethereum_forks::OptimismHardfork::Bedrock).is_some() self.hardforks.get(reth_optimism_forks::OptimismHardfork::Bedrock).is_some()
} }
/// Returns `true` if this chain contains Optimism configuration. /// Returns `true` if this chain contains Optimism configuration.
@ -621,7 +621,8 @@ impl EthereumHardforks for ChainSpec {
} }
} }
impl OptimismHardforks for ChainSpec {} #[cfg(feature = "optimism")]
impl reth_optimism_forks::OptimismHardforks for ChainSpec {}
/// Convert the given [`Genesis`] into an Ethereum [`ChainSpec`]. /// Convert the given [`Genesis`] into an Ethereum [`ChainSpec`].
#[cfg(not(feature = "optimism"))] #[cfg(not(feature = "optimism"))]
@ -715,7 +716,7 @@ fn into_ethereum_chain_spec(genesis: Genesis) -> ChainSpec {
#[cfg(feature = "optimism")] #[cfg(feature = "optimism")]
/// Convert the given [`Genesis`] into an Optimism [`ChainSpec`]. /// Convert the given [`Genesis`] into an Optimism [`ChainSpec`].
fn into_optimism_chain_spec(genesis: Genesis) -> ChainSpec { fn into_optimism_chain_spec(genesis: Genesis) -> ChainSpec {
use reth_ethereum_forks::OptimismHardfork; use reth_optimism_forks::OptimismHardfork;
let optimism_genesis_info = OptimismGenesisInfo::extract_from(&genesis); let optimism_genesis_info = OptimismGenesisInfo::extract_from(&genesis);
let genesis_info = optimism_genesis_info.optimism_chain_info.genesis_info.unwrap_or_default(); let genesis_info = optimism_genesis_info.optimism_chain_info.genesis_info.unwrap_or_default();
@ -979,7 +980,8 @@ impl ChainSpecBuilder {
#[cfg(feature = "optimism")] #[cfg(feature = "optimism")]
pub fn bedrock_activated(mut self) -> Self { pub fn bedrock_activated(mut self) -> Self {
self = self.paris_activated(); self = self.paris_activated();
self.hardforks.insert(crate::OptimismHardfork::Bedrock, ForkCondition::Block(0)); self.hardforks
.insert(reth_optimism_forks::OptimismHardfork::Bedrock, ForkCondition::Block(0));
self self
} }
@ -987,7 +989,8 @@ impl ChainSpecBuilder {
#[cfg(feature = "optimism")] #[cfg(feature = "optimism")]
pub fn regolith_activated(mut self) -> Self { pub fn regolith_activated(mut self) -> Self {
self = self.bedrock_activated(); self = self.bedrock_activated();
self.hardforks.insert(crate::OptimismHardfork::Regolith, ForkCondition::Timestamp(0)); self.hardforks
.insert(reth_optimism_forks::OptimismHardfork::Regolith, ForkCondition::Timestamp(0));
self self
} }
@ -997,7 +1000,8 @@ impl ChainSpecBuilder {
self = self.regolith_activated(); self = self.regolith_activated();
// Canyon also activates changes from L1's Shanghai hardfork // Canyon also activates changes from L1's Shanghai hardfork
self.hardforks.insert(EthereumHardfork::Shanghai, ForkCondition::Timestamp(0)); self.hardforks.insert(EthereumHardfork::Shanghai, ForkCondition::Timestamp(0));
self.hardforks.insert(crate::OptimismHardfork::Canyon, ForkCondition::Timestamp(0)); self.hardforks
.insert(reth_optimism_forks::OptimismHardfork::Canyon, ForkCondition::Timestamp(0));
self self
} }
@ -1006,7 +1010,8 @@ impl ChainSpecBuilder {
pub fn ecotone_activated(mut self) -> Self { pub fn ecotone_activated(mut self) -> Self {
self = self.canyon_activated(); self = self.canyon_activated();
self.hardforks.insert(EthereumHardfork::Cancun, ForkCondition::Timestamp(0)); self.hardforks.insert(EthereumHardfork::Cancun, ForkCondition::Timestamp(0));
self.hardforks.insert(crate::OptimismHardfork::Ecotone, ForkCondition::Timestamp(0)); self.hardforks
.insert(reth_optimism_forks::OptimismHardfork::Ecotone, ForkCondition::Timestamp(0));
self self
} }
@ -1014,7 +1019,8 @@ impl ChainSpecBuilder {
#[cfg(feature = "optimism")] #[cfg(feature = "optimism")]
pub fn fjord_activated(mut self) -> Self { pub fn fjord_activated(mut self) -> Self {
self = self.ecotone_activated(); self = self.ecotone_activated();
self.hardforks.insert(crate::OptimismHardfork::Fjord, ForkCondition::Timestamp(0)); self.hardforks
.insert(reth_optimism_forks::OptimismHardfork::Fjord, ForkCondition::Timestamp(0));
self self
} }
@ -1022,7 +1028,8 @@ impl ChainSpecBuilder {
#[cfg(feature = "optimism")] #[cfg(feature = "optimism")]
pub fn granite_activated(mut self) -> Self { pub fn granite_activated(mut self) -> Self {
self = self.fjord_activated(); self = self.fjord_activated();
self.hardforks.insert(crate::OptimismHardfork::Granite, ForkCondition::Timestamp(0)); self.hardforks
.insert(reth_optimism_forks::OptimismHardfork::Granite, ForkCondition::Timestamp(0));
self self
} }
@ -1117,7 +1124,7 @@ impl OptimismGenesisInfo {
BaseFeeParams::new(denominator as u128, elasticity as u128), BaseFeeParams::new(denominator as u128, elasticity as u128),
), ),
( (
reth_ethereum_forks::OptimismHardfork::Canyon.boxed(), reth_optimism_forks::OptimismHardfork::Canyon.boxed(),
BaseFeeParams::new(canyon_denominator as u128, elasticity as u128), BaseFeeParams::new(canyon_denominator as u128, elasticity as u128),
), ),
] ]
@ -2518,7 +2525,7 @@ Post-merge hard forks (timestamp based):
#[test] #[test]
#[cfg(feature = "optimism")] #[cfg(feature = "optimism")]
fn test_fork_order_optimism_mainnet() { fn test_fork_order_optimism_mainnet() {
use crate::OptimismHardfork; use reth_optimism_forks::OptimismHardfork;
let genesis = Genesis { let genesis = Genesis {
config: ChainConfig { config: ChainConfig {

View File

@ -22,3 +22,5 @@ pub mod recover;
pub mod stage; pub mod stage;
#[cfg(feature = "dev")] #[cfg(feature = "dev")]
pub mod test_vectors; pub mod test_vectors;
pub use node::NodeCommand;

View File

@ -314,24 +314,6 @@ mod tests {
assert_eq!(db_path, Path::new("my/custom/path/db")); assert_eq!(db_path, Path::new("my/custom/path/db"));
} }
#[test]
fn parse_dev() {
let cmd: NodeCommand = NodeCommand::parse_from(["reth", "--dev"]);
let chain = reth_chainspec::DEV.clone();
assert_eq!(cmd.chain.chain, chain.chain);
assert_eq!(cmd.chain.genesis_hash, chain.genesis_hash);
assert_eq!(
cmd.chain.paris_block_and_final_difficulty,
chain.paris_block_and_final_difficulty
);
assert_eq!(cmd.chain.hardforks, chain.hardforks);
assert!(cmd.rpc.http);
assert!(cmd.network.discovery.disable_discovery);
assert!(cmd.dev.dev);
}
#[test] #[test]
fn parse_instance() { fn parse_instance() {
let mut cmd: NodeCommand = NodeCommand::parse_from(["reth"]); let mut cmd: NodeCommand = NodeCommand::parse_from(["reth"]);

View File

@ -50,5 +50,4 @@ tracing.workspace = true
[features] [features]
optimism = [ optimism = [
"reth-beacon-consensus/optimism", "reth-beacon-consensus/optimism",
"reth-ethereum-forks/optimism"
] ]

View File

@ -40,7 +40,6 @@ proptest.workspace = true
[features] [features]
default = ["std", "serde", "rustc-hash"] default = ["std", "serde", "rustc-hash"]
arbitrary = ["dep:arbitrary", "dep:proptest", "dep:proptest-derive"] arbitrary = ["dep:arbitrary", "dep:proptest", "dep:proptest-derive"]
optimism = []
serde = ["dep:serde"] serde = ["dep:serde"]
std = ["thiserror-no-std/std", "rustc-hash/std"] std = ["thiserror-no-std/std", "rustc-hash/std"]
rustc-hash = ["dep:rustc-hash"] rustc-hash = ["dep:rustc-hash"]

View File

@ -1,8 +1,10 @@
use crate::{ChainHardforks, EthereumHardfork, ForkCondition};
use alloc::vec; use alloc::vec;
use alloy_primitives::U256; use alloy_primitives::U256;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use crate::{ChainHardforks, EthereumHardfork, ForkCondition};
/// Dev hardforks /// Dev hardforks
pub static DEV_HARDFORKS: Lazy<ChainHardforks> = Lazy::new(|| { pub static DEV_HARDFORKS: Lazy<ChainHardforks> = Lazy::new(|| {
ChainHardforks::new(vec![ ChainHardforks::new(vec![
@ -23,13 +25,5 @@ pub static DEV_HARDFORKS: Lazy<ChainHardforks> = Lazy::new(|| {
), ),
(EthereumHardfork::Shanghai.boxed(), ForkCondition::Timestamp(0)), (EthereumHardfork::Shanghai.boxed(), ForkCondition::Timestamp(0)),
(EthereumHardfork::Cancun.boxed(), ForkCondition::Timestamp(0)), (EthereumHardfork::Cancun.boxed(), ForkCondition::Timestamp(0)),
#[cfg(feature = "optimism")]
(crate::OptimismHardfork::Regolith.boxed(), ForkCondition::Timestamp(0)),
#[cfg(feature = "optimism")]
(crate::OptimismHardfork::Bedrock.boxed(), ForkCondition::Block(0)),
#[cfg(feature = "optimism")]
(crate::OptimismHardfork::Ecotone.boxed(), ForkCondition::Timestamp(0)),
#[cfg(feature = "optimism")]
(crate::OptimismHardfork::Canyon.boxed(), ForkCondition::Timestamp(0)),
]) ])
}); });

View File

@ -3,9 +3,6 @@ mod macros;
mod ethereum; mod ethereum;
pub use ethereum::EthereumHardfork; pub use ethereum::EthereumHardfork;
mod optimism;
pub use optimism::OptimismHardfork;
mod dev; mod dev;
pub use dev::DEV_HARDFORKS; pub use dev::DEV_HARDFORKS;
@ -47,7 +44,6 @@ impl Hash for dyn Hardfork + 'static {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::hardfork::optimism::OptimismHardfork;
use std::str::FromStr; use std::str::FromStr;
#[test] #[test]
@ -99,24 +95,6 @@ mod tests {
assert_eq!(hardforks, expected_hardforks); assert_eq!(hardforks, expected_hardforks);
} }
#[test]
fn check_op_hardfork_from_str() {
let hardfork_str = ["beDrOck", "rEgOlITH", "cAnYoN", "eCoToNe", "FJorD", "GRaNiTe"];
let expected_hardforks = [
OptimismHardfork::Bedrock,
OptimismHardfork::Regolith,
OptimismHardfork::Canyon,
OptimismHardfork::Ecotone,
OptimismHardfork::Fjord,
OptimismHardfork::Granite,
];
let hardforks: Vec<OptimismHardfork> =
hardfork_str.iter().map(|h| OptimismHardfork::from_str(h).unwrap()).collect();
assert_eq!(hardforks, expected_hardforks);
}
#[test] #[test]
fn check_nonexistent_hardfork_from_str() { fn check_nonexistent_hardfork_from_str() {
assert!(EthereumHardfork::from_str("not a hardfork").is_err()); assert!(EthereumHardfork::from_str("not a hardfork").is_err());

View File

@ -2,10 +2,6 @@
mod ethereum; mod ethereum;
pub use ethereum::EthereumHardforks; pub use ethereum::EthereumHardforks;
/// Optimism helper methods
mod optimism;
pub use optimism::OptimismHardforks;
use crate::{ForkCondition, Hardfork}; use crate::{ForkCondition, Hardfork};
#[cfg(feature = "std")] #[cfg(feature = "std")]
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;

View File

@ -27,7 +27,7 @@ mod head;
pub use forkid::{ pub use forkid::{
EnrForkIdEntry, ForkFilter, ForkFilterKey, ForkHash, ForkId, ForkTransition, ValidationError, EnrForkIdEntry, ForkFilter, ForkFilterKey, ForkHash, ForkId, ForkTransition, ValidationError,
}; };
pub use hardfork::{EthereumHardfork, Hardfork, OptimismHardfork, DEV_HARDFORKS}; pub use hardfork::{EthereumHardfork, Hardfork, DEV_HARDFORKS};
pub use head::Head; pub use head::Head;
pub use display::DisplayHardforks; pub use display::DisplayHardforks;

View File

@ -11,12 +11,20 @@ repository.workspace = true
workspace = true workspace = true
[dependencies] [dependencies]
# reth
reth-cli.workspace = true reth-cli.workspace = true
reth-chainspec.workspace = true reth-chainspec.workspace = true
# ethereum
alloy-genesis.workspace = true alloy-genesis.workspace = true
# io
shellexpand.workspace = true
serde_json.workspace = true
# misc
eyre.workspace = true eyre.workspace = true
shellexpand.workspace = true [dev-dependencies]
serde_json.workspace = true clap.workspace = true
reth-cli-commands.workspace = true

View File

@ -10,3 +10,29 @@
/// Chain specification parser. /// Chain specification parser.
pub mod chainspec; pub mod chainspec;
#[cfg(test)]
mod test {
use clap::Parser;
use reth_chainspec::DEV;
use reth_cli_commands::NodeCommand;
#[test]
#[ignore = "reth cmd will print op-reth output if optimism feature enabled"]
fn parse_dev() {
let cmd: NodeCommand = NodeCommand::parse_from(["reth", "--dev"]);
let chain = DEV.clone();
assert_eq!(cmd.chain.chain, chain.chain);
assert_eq!(cmd.chain.genesis_hash, chain.genesis_hash);
assert_eq!(
cmd.chain.paris_block_and_final_difficulty,
chain.paris_block_and_final_difficulty
);
assert_eq!(cmd.chain.hardforks, chain.hardforks);
assert!(cmd.rpc.http);
assert!(cmd.network.discovery.disable_discovery);
assert!(cmd.dev.dev);
}
}

View File

@ -14,9 +14,12 @@ workspace = true
[dependencies] [dependencies]
# reth # reth
reth-chainspec = { workspace = true, features = ["optimism"] } reth-chainspec = { workspace = true, features = ["optimism"] }
reth-ethereum-forks = { workspace = true, features = ["optimism"] } reth-ethereum-forks.workspace = true
reth-primitives-traits.workspace = true reth-primitives-traits.workspace = true
# op-reth
reth-optimism-forks.workspace = true
# ethereum # ethereum
alloy-chains.workspace = true alloy-chains.workspace = true
alloy-primitives.workspace = true alloy-primitives.workspace = true

View File

@ -6,7 +6,8 @@ use alloy_chains::Chain;
use alloy_primitives::{b256, U256}; use alloy_primitives::{b256, U256};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use reth_chainspec::{once_cell_set, BaseFeeParams, BaseFeeParamsKind, ChainSpec}; use reth_chainspec::{once_cell_set, BaseFeeParams, BaseFeeParamsKind, ChainSpec};
use reth_ethereum_forks::{EthereumHardfork, OptimismHardfork}; use reth_ethereum_forks::EthereumHardfork;
use reth_optimism_forks::OptimismHardfork;
use crate::OpChainSpec; use crate::OpChainSpec;

View File

@ -6,7 +6,8 @@ use alloy_chains::Chain;
use alloy_primitives::{b256, U256}; use alloy_primitives::{b256, U256};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use reth_chainspec::{once_cell_set, BaseFeeParams, BaseFeeParamsKind, ChainSpec}; use reth_chainspec::{once_cell_set, BaseFeeParams, BaseFeeParamsKind, ChainSpec};
use reth_ethereum_forks::{EthereumHardfork, OptimismHardfork}; use reth_ethereum_forks::EthereumHardfork;
use reth_optimism_forks::OptimismHardfork;
use crate::OpChainSpec; use crate::OpChainSpec;

View File

@ -6,7 +6,7 @@ use alloy_chains::Chain;
use alloy_primitives::U256; use alloy_primitives::U256;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use reth_chainspec::{once_cell_set, BaseFeeParams, BaseFeeParamsKind, ChainSpec}; use reth_chainspec::{once_cell_set, BaseFeeParams, BaseFeeParamsKind, ChainSpec};
use reth_ethereum_forks::DEV_HARDFORKS; use reth_optimism_forks::DEV_HARDFORKS;
use reth_primitives_traits::constants::DEV_GENESIS_HASH; use reth_primitives_traits::constants::DEV_GENESIS_HASH;
use crate::OpChainSpec; use crate::OpChainSpec;

View File

@ -9,10 +9,9 @@
extern crate alloc; extern crate alloc;
pub mod constants;
mod base; mod base;
mod base_sepolia; mod base_sepolia;
pub mod constants;
mod dev; mod dev;
mod op; mod op;
mod op_sepolia; mod op_sepolia;
@ -38,10 +37,8 @@ mod tests {
use alloy_genesis::Genesis; use alloy_genesis::Genesis;
use alloy_primitives::b256; use alloy_primitives::b256;
use reth_chainspec::{test_fork_ids, BaseFeeParams, BaseFeeParamsKind, ChainSpec}; use reth_chainspec::{test_fork_ids, BaseFeeParams, BaseFeeParamsKind, ChainSpec};
use reth_ethereum_forks::{ use reth_ethereum_forks::{EthereumHardfork, ForkCondition, ForkHash, ForkId, Head};
EthereumHardfork, ForkCondition, ForkHash, ForkId, Head, OptimismHardfork, use reth_optimism_forks::{OptimismHardfork, OptimismHardforks};
OptimismHardforks,
};
use crate::*; use crate::*;

View File

@ -6,7 +6,8 @@ use alloy_chains::Chain;
use alloy_primitives::{b256, U256}; use alloy_primitives::{b256, U256};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use reth_chainspec::{once_cell_set, BaseFeeParams, BaseFeeParamsKind, ChainSpec}; use reth_chainspec::{once_cell_set, BaseFeeParams, BaseFeeParamsKind, ChainSpec};
use reth_ethereum_forks::{EthereumHardfork, OptimismHardfork}; use reth_ethereum_forks::EthereumHardfork;
use reth_optimism_forks::OptimismHardfork;
use reth_primitives_traits::constants::ETHEREUM_BLOCK_GAS_LIMIT; use reth_primitives_traits::constants::ETHEREUM_BLOCK_GAS_LIMIT;
use crate::OpChainSpec; use crate::OpChainSpec;

View File

@ -6,7 +6,8 @@ use alloy_chains::{Chain, NamedChain};
use alloy_primitives::{b256, U256}; use alloy_primitives::{b256, U256};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use reth_chainspec::{once_cell_set, BaseFeeParams, BaseFeeParamsKind, ChainSpec}; use reth_chainspec::{once_cell_set, BaseFeeParams, BaseFeeParamsKind, ChainSpec};
use reth_ethereum_forks::{EthereumHardfork, OptimismHardfork}; use reth_ethereum_forks::EthereumHardfork;
use reth_optimism_forks::OptimismHardfork;
use reth_primitives_traits::constants::ETHEREUM_BLOCK_GAS_LIMIT; use reth_primitives_traits::constants::ETHEREUM_BLOCK_GAS_LIMIT;
use crate::OpChainSpec; use crate::OpChainSpec;

View File

@ -66,6 +66,7 @@ eyre.workspace = true
tempfile.workspace = true tempfile.workspace = true
reth-stages = { workspace = true, features = ["test-utils"] } reth-stages = { workspace = true, features = ["test-utils"] }
reth-db-common.workspace = true reth-db-common.workspace = true
reth-cli-commands.workspace = true
[features] [features]
optimism = [ optimism = [

View File

@ -175,3 +175,28 @@ where
Ok(guard) Ok(guard)
} }
} }
#[cfg(test)]
mod test {
use clap::Parser;
use reth_cli_commands::NodeCommand;
use reth_optimism_chainspec::OP_DEV;
#[test]
fn parse_dev() {
let cmd: NodeCommand = NodeCommand::parse_from(["op-reth", "--dev"]);
let chain = OP_DEV.clone();
assert_eq!(cmd.chain.chain, chain.chain);
assert_eq!(cmd.chain.genesis_hash, chain.genesis_hash);
assert_eq!(
cmd.chain.paris_block_and_final_difficulty,
chain.paris_block_and_final_difficulty
);
assert_eq!(cmd.chain.hardforks, chain.hardforks);
assert!(cmd.rpc.http);
assert!(cmd.network.discovery.disable_discovery);
assert!(cmd.dev.dev);
}
}

View File

@ -19,6 +19,9 @@ reth-consensus.workspace = true
reth-primitives.workspace = true reth-primitives.workspace = true
reth-trie-common.workspace = true reth-trie-common.workspace = true
# op-reth
reth-optimism-forks.workspace = true
# ethereum # ethereum
alloy-primitives.workspace = true alloy-primitives.workspace = true

View File

@ -10,7 +10,7 @@
#![cfg(feature = "optimism")] #![cfg(feature = "optimism")]
use alloy_primitives::U256; use alloy_primitives::U256;
use reth_chainspec::{ChainSpec, EthereumHardforks, OptimismHardforks}; use reth_chainspec::{ChainSpec, EthereumHardforks};
use reth_consensus::{Consensus, ConsensusError, PostExecutionInput}; use reth_consensus::{Consensus, ConsensusError, PostExecutionInput};
use reth_consensus_common::validation::{ use reth_consensus_common::validation::{
validate_against_parent_4844, validate_against_parent_eip1559_base_fee, validate_against_parent_4844, validate_against_parent_eip1559_base_fee,
@ -18,6 +18,7 @@ use reth_consensus_common::validation::{
validate_header_base_fee, validate_header_extradata, validate_header_gas, validate_header_base_fee, validate_header_extradata, validate_header_gas,
validate_shanghai_withdrawals, validate_shanghai_withdrawals,
}; };
use reth_optimism_forks::OptimismHardforks;
use reth_primitives::{ use reth_primitives::{
BlockWithSenders, GotExpected, Header, SealedBlock, SealedHeader, EMPTY_OMMER_ROOT_HASH, BlockWithSenders, GotExpected, Header, SealedBlock, SealedHeader, EMPTY_OMMER_ROOT_HASH,
}; };

View File

@ -1,7 +1,8 @@
//! Helper function for Receipt root calculation for Optimism hardforks. //! Helper function for Receipt root calculation for Optimism hardforks.
use alloy_primitives::B256; use alloy_primitives::B256;
use reth_chainspec::{ChainSpec, OptimismHardfork}; use reth_chainspec::ChainSpec;
use reth_optimism_forks::OptimismHardfork;
use reth_primitives::ReceiptWithBloom; use reth_primitives::ReceiptWithBloom;
use reth_trie_common::root::ordered_trie_root_with_encoder; use reth_trie_common::root::ordered_trie_root_with_encoder;

View File

@ -27,6 +27,7 @@ alloy-primitives.workspace = true
# Optimism # Optimism
reth-optimism-consensus.workspace = true reth-optimism-consensus.workspace = true
reth-optimism-chainspec.workspace = true reth-optimism-chainspec.workspace = true
reth-optimism-forks.workspace = true
# revm # revm
revm.workspace = true revm.workspace = true

View File

@ -1,5 +1,6 @@
use reth_chainspec::{ChainSpec, OptimismHardfork}; use reth_chainspec::ChainSpec;
use reth_ethereum_forks::{EthereumHardfork, Head}; use reth_ethereum_forks::{EthereumHardfork, Head};
use reth_optimism_forks::OptimismHardfork;
/// Returns the revm [`SpecId`](revm_primitives::SpecId) at the given timestamp. /// Returns the revm [`SpecId`](revm_primitives::SpecId) at the given timestamp.
/// ///

View File

@ -4,7 +4,7 @@ use crate::{
l1::ensure_create2_deployer, OpChainSpec, OptimismBlockExecutionError, OptimismEvmConfig, l1::ensure_create2_deployer, OpChainSpec, OptimismBlockExecutionError, OptimismEvmConfig,
}; };
use alloy_primitives::{BlockNumber, U256}; use alloy_primitives::{BlockNumber, U256};
use reth_chainspec::{ChainSpec, EthereumHardforks, OptimismHardfork}; use reth_chainspec::{ChainSpec, EthereumHardforks};
use reth_evm::{ use reth_evm::{
execute::{ execute::{
BatchExecutor, BlockExecutionError, BlockExecutionInput, BlockExecutionOutput, BatchExecutor, BlockExecutionError, BlockExecutionInput, BlockExecutionOutput,
@ -15,6 +15,7 @@ use reth_evm::{
}; };
use reth_execution_types::ExecutionOutcome; use reth_execution_types::ExecutionOutcome;
use reth_optimism_consensus::validate_block_post_execution; use reth_optimism_consensus::validate_block_post_execution;
use reth_optimism_forks::OptimismHardfork;
use reth_primitives::{BlockWithSenders, Header, Receipt, Receipts, TxType}; use reth_primitives::{BlockWithSenders, Header, Receipt, Receipts, TxType};
use reth_prune_types::PruneModes; use reth_prune_types::PruneModes;
use reth_revm::{ use reth_revm::{

View File

@ -2,8 +2,9 @@
use crate::OptimismBlockExecutionError; use crate::OptimismBlockExecutionError;
use alloy_primitives::{address, b256, hex, Address, Bytes, B256, U256}; use alloy_primitives::{address, b256, hex, Address, Bytes, B256, U256};
use reth_chainspec::{ChainSpec, OptimismHardfork}; use reth_chainspec::ChainSpec;
use reth_execution_errors::BlockExecutionError; use reth_execution_errors::BlockExecutionError;
use reth_optimism_forks::OptimismHardfork;
use reth_primitives::Block; use reth_primitives::Block;
use revm::{ use revm::{
primitives::{Bytecode, HashMap, SpecId}, primitives::{Bytecode, HashMap, SpecId},
@ -296,8 +297,8 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use reth_chainspec::OptimismHardforks;
use reth_optimism_chainspec::OP_MAINNET; use reth_optimism_chainspec::OP_MAINNET;
use reth_optimism_forks::OptimismHardforks;
use reth_primitives::TransactionSigned; use reth_primitives::TransactionSigned;
use super::*; use super::*;

View File

@ -0,0 +1,31 @@
[package]
name = "reth-optimism-forks"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true
description = "Optimism hardforks used in op-reth"
[lints]
workspace = true
[dependencies]
# reth
reth-ethereum-forks.workspace = true
# ethereum
alloy-chains.workspace = true
alloy-primitives.workspace = true
# io
serde = { workspace = true, optional = true }
# misc
once_cell.workspace = true
[features]
default = ["std"]
std = []
serde = ["dep:serde"]

View File

@ -0,0 +1,32 @@
use alloy_primitives::U256;
use once_cell::sync::Lazy;
use reth_ethereum_forks::{ChainHardforks, EthereumHardfork, ForkCondition};
/// Dev hardforks
pub static DEV_HARDFORKS: Lazy<ChainHardforks> = Lazy::new(|| {
ChainHardforks::new(vec![
(EthereumHardfork::Frontier.boxed(), ForkCondition::Block(0)),
(EthereumHardfork::Homestead.boxed(), ForkCondition::Block(0)),
(EthereumHardfork::Dao.boxed(), ForkCondition::Block(0)),
(EthereumHardfork::Tangerine.boxed(), ForkCondition::Block(0)),
(EthereumHardfork::SpuriousDragon.boxed(), ForkCondition::Block(0)),
(EthereumHardfork::Byzantium.boxed(), ForkCondition::Block(0)),
(EthereumHardfork::Constantinople.boxed(), ForkCondition::Block(0)),
(EthereumHardfork::Petersburg.boxed(), ForkCondition::Block(0)),
(EthereumHardfork::Istanbul.boxed(), ForkCondition::Block(0)),
(EthereumHardfork::Berlin.boxed(), ForkCondition::Block(0)),
(EthereumHardfork::London.boxed(), ForkCondition::Block(0)),
(
EthereumHardfork::Paris.boxed(),
ForkCondition::TTD { fork_block: None, total_difficulty: U256::ZERO },
),
(crate::OptimismHardfork::Bedrock.boxed(), ForkCondition::Block(0)),
(crate::OptimismHardfork::Regolith.boxed(), ForkCondition::Timestamp(0)),
(EthereumHardfork::Shanghai.boxed(), ForkCondition::Timestamp(0)),
(crate::OptimismHardfork::Canyon.boxed(), ForkCondition::Timestamp(0)),
(EthereumHardfork::Cancun.boxed(), ForkCondition::Timestamp(0)),
(crate::OptimismHardfork::Ecotone.boxed(), ForkCondition::Timestamp(0)),
(crate::OptimismHardfork::Fjord.boxed(), ForkCondition::Timestamp(0)),
(crate::OptimismHardfork::Granite.boxed(), ForkCondition::Timestamp(0)),
])
});

View File

@ -1,3 +1,5 @@
//! Hard forks of optimism protocol.
use alloc::{boxed::Box, format, string::String, vec}; use alloc::{boxed::Box, format, string::String, vec};
use core::{ use core::{
any::Any, any::Any,
@ -7,11 +9,10 @@ use core::{
use alloy_chains::Chain; use alloy_chains::Chain;
use alloy_primitives::U256; use alloy_primitives::U256;
use reth_ethereum_forks::{hardfork, ChainHardforks, EthereumHardfork, ForkCondition, Hardfork};
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::{hardfork, ChainHardforks, EthereumHardfork, ForkCondition, Hardfork};
hardfork!( hardfork!(
/// The name of an optimism hardfork. /// The name of an optimism hardfork.
/// ///
@ -334,6 +335,8 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::str::FromStr;
use super::*; use super::*;
#[test] #[test]
@ -347,4 +350,27 @@ mod tests {
Some(9101527) Some(9101527)
); );
} }
#[test]
fn check_op_hardfork_from_str() {
let hardfork_str = ["beDrOck", "rEgOlITH", "cAnYoN", "eCoToNe", "FJorD", "GRaNiTe"];
let expected_hardforks = [
OptimismHardfork::Bedrock,
OptimismHardfork::Regolith,
OptimismHardfork::Canyon,
OptimismHardfork::Ecotone,
OptimismHardfork::Fjord,
OptimismHardfork::Granite,
];
let hardforks: Vec<OptimismHardfork> =
hardfork_str.iter().map(|h| OptimismHardfork::from_str(h).unwrap()).collect();
assert_eq!(hardforks, expected_hardforks);
}
#[test]
fn check_nonexistent_hardfork_from_str() {
assert!(OptimismHardfork::from_str("not a hardfork").is_err());
}
} }

View File

@ -1,8 +1,25 @@
use super::Hardforks; //! OP-Reth hard forks.
use crate::OptimismHardfork;
/// Extends [`crate::EthereumHardforks`] with optimism helper methods. #![doc(
pub trait OptimismHardforks: Hardforks { html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
extern crate alloc;
pub mod hardfork;
mod dev;
pub use dev::DEV_HARDFORKS;
pub use hardfork::OptimismHardfork;
use reth_ethereum_forks::EthereumHardforks;
/// Extends [`EthereumHardforks`] with optimism helper methods.
pub trait OptimismHardforks: EthereumHardforks {
/// Convenience method to check if [`OptimismHardfork::Bedrock`] is active at a given block /// Convenience method to check if [`OptimismHardfork::Bedrock`] is active at a given block
/// number. /// number.
fn is_bedrock_active_at_block(&self, block_number: u64) -> bool { fn is_bedrock_active_at_block(&self, block_number: u64) -> bool {

View File

@ -18,7 +18,6 @@ reth-payload-builder.workspace = true
reth-auto-seal-consensus.workspace = true reth-auto-seal-consensus.workspace = true
reth-basic-payload-builder.workspace = true reth-basic-payload-builder.workspace = true
reth-consensus.workspace = true reth-consensus.workspace = true
reth-optimism-payload-builder.workspace = true
reth-rpc-types.workspace = true reth-rpc-types.workspace = true
reth-rpc-types-compat.workspace = true reth-rpc-types-compat.workspace = true
reth-node-api.workspace = true reth-node-api.workspace = true
@ -29,15 +28,19 @@ reth-transaction-pool.workspace = true
reth-network.workspace = true reth-network.workspace = true
reth-evm.workspace = true reth-evm.workspace = true
reth-revm.workspace = true reth-revm.workspace = true
reth-evm-optimism.workspace = true
reth-beacon-consensus.workspace = true reth-beacon-consensus.workspace = true
reth-optimism-consensus.workspace = true
reth-discv5.workspace = true reth-discv5.workspace = true
reth-rpc-eth-types.workspace = true reth-rpc-eth-types.workspace = true
reth-rpc-eth-api.workspace = true reth-rpc-eth-api.workspace = true
reth-optimism-rpc.workspace = true
reth-rpc.workspace = true reth-rpc.workspace = true
# op-reth
reth-optimism-payload-builder.workspace = true
reth-evm-optimism.workspace = true
reth-optimism-rpc.workspace = true
reth-optimism-chainspec.workspace = true reth-optimism-chainspec.workspace = true
reth-optimism-consensus.workspace = true
reth-optimism-forks.workspace = true
# ethereum # ethereum
alloy-primitives.workspace = true alloy-primitives.workspace = true

View File

@ -1,4 +1,4 @@
use reth_chainspec::{ChainSpec, OptimismHardfork}; use reth_chainspec::ChainSpec;
use reth_node_api::{ use reth_node_api::{
payload::{ payload::{
validate_parent_beacon_block_root_presence, EngineApiMessageVersion, validate_parent_beacon_block_root_presence, EngineApiMessageVersion,
@ -7,6 +7,7 @@ use reth_node_api::{
}, },
EngineTypes, EngineTypes,
}; };
use reth_optimism_forks::OptimismHardfork;
use reth_optimism_payload_builder::{OptimismBuiltPayload, OptimismPayloadBuilderAttributes}; use reth_optimism_payload_builder::{OptimismBuiltPayload, OptimismPayloadBuilderAttributes};
use reth_rpc_types::{ use reth_rpc_types::{
engine::ExecutionPayloadEnvelopeV2, engine::ExecutionPayloadEnvelopeV2,

View File

@ -21,7 +21,6 @@ reth-provider.workspace = true
reth-rpc-types.workspace = true reth-rpc-types.workspace = true
reth-rpc-types-compat.workspace = true reth-rpc-types-compat.workspace = true
reth-evm.workspace = true reth-evm.workspace = true
reth-evm-optimism.workspace = true
reth-execution-types.workspace = true reth-execution-types.workspace = true
reth-payload-builder.workspace = true reth-payload-builder.workspace = true
reth-payload-primitives.workspace = true reth-payload-primitives.workspace = true
@ -29,6 +28,10 @@ reth-basic-payload-builder.workspace = true
reth-trie.workspace = true reth-trie.workspace = true
reth-chain-state.workspace = true reth-chain-state.workspace = true
# op-reth
reth-evm-optimism.workspace = true
reth-optimism-forks.workspace = true
# ethereum # ethereum
revm.workspace = true revm.workspace = true
alloy-primitives.workspace = true alloy-primitives.workspace = true

View File

@ -1,18 +1,17 @@
//! Optimism payload builder implementation. //! Optimism payload builder implementation.
use crate::{ use std::sync::Arc;
error::OptimismPayloadBuilderError,
payload::{OptimismBuiltPayload, OptimismPayloadBuilderAttributes},
};
use alloy_primitives::U256; use alloy_primitives::U256;
use reth_basic_payload_builder::*; use reth_basic_payload_builder::*;
use reth_chain_state::ExecutedBlock; use reth_chain_state::ExecutedBlock;
use reth_chainspec::{EthereumHardforks, OptimismHardfork}; use reth_chainspec::EthereumHardforks;
use reth_evm::{ use reth_evm::{
system_calls::pre_block_beacon_root_contract_call, ConfigureEvm, ConfigureEvmEnv, system_calls::pre_block_beacon_root_contract_call, ConfigureEvm, ConfigureEvmEnv,
NextBlockEnvAttributes, NextBlockEnvAttributes,
}; };
use reth_execution_types::ExecutionOutcome; use reth_execution_types::ExecutionOutcome;
use reth_optimism_forks::OptimismHardfork;
use reth_payload_primitives::{PayloadBuilderAttributes, PayloadBuilderError}; use reth_payload_primitives::{PayloadBuilderAttributes, PayloadBuilderError};
use reth_primitives::{ use reth_primitives::{
constants::BEACON_NONCE, constants::BEACON_NONCE,
@ -32,9 +31,13 @@ use revm::{
primitives::{EVMError, EnvWithHandlerCfg, InvalidTransaction, ResultAndState}, primitives::{EVMError, EnvWithHandlerCfg, InvalidTransaction, ResultAndState},
DatabaseCommit, State, DatabaseCommit, State,
}; };
use std::sync::Arc;
use tracing::{debug, trace, warn}; use tracing::{debug, trace, warn};
use crate::{
error::OptimismPayloadBuilderError,
payload::{OptimismBuiltPayload, OptimismPayloadBuilderAttributes},
};
/// Optimism's payload builder /// Optimism's payload builder
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct OptimismPayloadBuilder<EvmConfig> { pub struct OptimismPayloadBuilder<EvmConfig> {

View File

@ -13,7 +13,6 @@ workspace = true
[dependencies] [dependencies]
# reth # reth
reth-evm-optimism.workspace = true
reth-evm.workspace = true reth-evm.workspace = true
reth-primitives.workspace = true reth-primitives.workspace = true
reth-provider.workspace = true reth-provider.workspace = true
@ -29,6 +28,10 @@ reth-network-api.workspace = true
reth-node-builder.workspace = true reth-node-builder.workspace = true
reth-chainspec.workspace = true reth-chainspec.workspace = true
# op-reth
reth-evm-optimism.workspace = true
reth-optimism-forks.workspace = true
# ethereum # ethereum
alloy-primitives.workspace = true alloy-primitives.workspace = true
op-alloy-network.workspace = true op-alloy-network.workspace = true

View File

@ -4,9 +4,10 @@ use op_alloy_consensus::{OpDepositReceipt, OpDepositReceiptWithBloom, OpReceiptE
use op_alloy_rpc_types::{ use op_alloy_rpc_types::{
receipt::L1BlockInfo, OpTransactionReceipt, OptimismTransactionReceiptFields, receipt::L1BlockInfo, OpTransactionReceipt, OptimismTransactionReceiptFields,
}; };
use reth_chainspec::{ChainSpec, OptimismHardforks}; use reth_chainspec::ChainSpec;
use reth_evm_optimism::RethL1BlockInfo; use reth_evm_optimism::RethL1BlockInfo;
use reth_node_api::{FullNodeComponents, NodeTypes}; use reth_node_api::{FullNodeComponents, NodeTypes};
use reth_optimism_forks::OptimismHardforks;
use reth_primitives::{Receipt, TransactionMeta, TransactionSigned, TxType}; use reth_primitives::{Receipt, TransactionMeta, TransactionSigned, TxType};
use reth_provider::ChainSpecProvider; use reth_provider::ChainSpecProvider;
use reth_rpc_eth_api::{helpers::LoadReceipt, FromEthApiError, RpcReceipt}; use reth_rpc_eth_api::{helpers::LoadReceipt, FromEthApiError, RpcReceipt};

View File

@ -20,7 +20,10 @@ reth-trie-common.workspace = true
revm-primitives = { workspace = true, features = ["serde"] } revm-primitives = { workspace = true, features = ["serde"] }
reth-chainspec = { workspace = true, optional = true } reth-chainspec = { workspace = true, optional = true }
reth-codecs = { workspace = true, optional = true } reth-codecs = { workspace = true, optional = true }
# op-reth
reth-optimism-chainspec = { workspace = true, optional = true } reth-optimism-chainspec = { workspace = true, optional = true }
reth-optimism-forks = { workspace = true, optional = true }
# ethereum # ethereum
alloy-consensus.workspace = true alloy-consensus.workspace = true
@ -109,11 +112,11 @@ c-kzg = [
] ]
optimism = [ optimism = [
"reth-chainspec/optimism", "reth-chainspec/optimism",
"reth-ethereum-forks/optimism",
"revm-primitives/optimism", "revm-primitives/optimism",
"reth-codecs?/optimism", "reth-codecs?/optimism",
"dep:reth-optimism-chainspec", "dep:reth-optimism-chainspec",
"dep:op-alloy-consensus", "dep:op-alloy-consensus",
"reth-optimism-forks",
] ]
alloy-compat = [ alloy-compat = [
"reth-primitives-traits/alloy-compat", "reth-primitives-traits/alloy-compat",

View File

@ -63,9 +63,12 @@ pub fn calculate_receipt_root_no_memo_optimism(
// encoding. In the Regolith Hardfork, we must strip the deposit nonce from the // encoding. In the Regolith Hardfork, we must strip the deposit nonce from the
// receipts before calculating the receipt root. This was corrected in the Canyon // receipts before calculating the receipt root. This was corrected in the Canyon
// hardfork. // hardfork.
if chain_spec.is_fork_active_at_timestamp(reth_chainspec::OptimismHardfork::Regolith, timestamp) && if chain_spec
!chain_spec .is_fork_active_at_timestamp(reth_optimism_forks::OptimismHardfork::Regolith, timestamp) &&
.is_fork_active_at_timestamp(reth_chainspec::OptimismHardfork::Canyon, timestamp) !chain_spec.is_fork_active_at_timestamp(
reth_optimism_forks::OptimismHardfork::Canyon,
timestamp,
)
{ {
let receipts = receipts let receipts = receipts
.iter() .iter()