Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: rm optimism feature from chainspec #11722

Merged
merged 4 commits into from
Oct 15, 2024
Merged
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
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions crates/chainspec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ reth-network-peers.workspace = true
reth-trie-common.workspace = true
reth-primitives-traits.workspace = true

# op-reth
reth-optimism-forks = { workspace = true, optional = true }

# ethereum
alloy-chains = { workspace = true, features = ["serde", "rlp"] }
alloy-eips = { workspace = true, features = ["serde"] }
Expand All @@ -42,7 +39,6 @@ alloy-genesis.workspace = true

[features]
default = ["std"]
optimism = ["reth-optimism-forks"]
std = [
"alloy-chains/std",
"alloy-eips/std",
Expand Down
2 changes: 1 addition & 1 deletion crates/chainspec/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,6 @@ impl EthChainSpec for ChainSpec {
}

fn is_optimism(&self) -> bool {
Self::is_optimism(self)
self.chain.is_optimism()
}
}
2 changes: 1 addition & 1 deletion crates/chainspec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub use reth_ethereum_forks::*;

pub use api::EthChainSpec;
pub use info::ChainInfo;
#[cfg(feature = "test-utils")]
#[cfg(any(test, feature = "test-utils"))]
pub use spec::test_fork_ids;
pub use spec::{
BaseFeeParams, BaseFeeParamsKind, ChainSpec, ChainSpecBuilder, ChainSpecProvider,
Expand Down
18 changes: 0 additions & 18 deletions crates/chainspec/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,21 +239,6 @@ impl ChainSpec {
self.chain.is_ethereum()
}

/// Returns `true` if this chain contains Optimism configuration.
#[inline]
#[cfg(feature = "optimism")]
pub fn is_optimism(&self) -> bool {
self.chain.is_optimism() ||
self.hardforks.get(reth_optimism_forks::OptimismHardfork::Bedrock).is_some()
}

/// Returns `true` if this chain contains Optimism configuration.
#[inline]
#[cfg(not(feature = "optimism"))]
pub const fn is_optimism(&self) -> bool {
self.chain.is_optimism()
}

/// Returns `true` if this chain is Optimism mainnet.
#[inline]
pub fn is_optimism_mainnet(&self) -> bool {
Expand Down Expand Up @@ -706,9 +691,6 @@ impl EthereumHardforks for ChainSpec {
}
}

#[cfg(feature = "optimism")]
impl reth_optimism_forks::OptimismHardforks for ChainSpec {}

/// A trait for reading the current chainspec.
#[auto_impl::auto_impl(&, Arc)]
pub trait ChainSpecProvider: Send + Sync {
Expand Down
5 changes: 2 additions & 3 deletions crates/consensus/beacon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ reth-tokio-util.workspace = true
reth-engine-primitives.workspace = true
reth-network-p2p.workspace = true
reth-node-types.workspace = true
reth-chainspec = { workspace = true, optional = true }

# ethereum
alloy-primitives.workspace = true
Expand All @@ -48,8 +49,6 @@ thiserror.workspace = true
schnellru.workspace = true
itertools.workspace = true

reth-chainspec = { workspace = true, optional = true }

[dev-dependencies]
# reth
reth-payload-builder = { workspace = true, features = ["test-utils"] }
Expand Down Expand Up @@ -78,8 +77,8 @@ assert_matches.workspace = true

[features]
optimism = [
"reth-chainspec",
"reth-primitives/optimism",
"reth-provider/optimism",
"reth-blockchain-tree/optimism",
"reth-chainspec"
]
3 changes: 1 addition & 2 deletions crates/consensus/beacon/src/engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,7 @@ where
) -> bool {
// On Optimism, the proposers are allowed to reorg their own chain at will.
#[cfg(feature = "optimism")]
if reth_chainspec::EthChainSpec::chain(self.blockchain.chain_spec().as_ref()).is_optimism()
{
if reth_chainspec::EthChainSpec::is_optimism(&self.blockchain.chain_spec()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should open an issue to move away from this type of behaviour, since it requires every rollup to add a new is_my_rollup trait method to EthChainSpec, and instead solve it at sdk level for engine

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this crate will be deprecated soon, so no need to change anything here

debug!(
target: "consensus::engine",
fcu_head_num=?header.number,
Expand Down
2 changes: 1 addition & 1 deletion crates/optimism/chainspec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ workspace = true

[dependencies]
# reth
reth-chainspec = { workspace = true, features = ["optimism"] }
reth-chainspec.workspace = true
reth-ethereum-forks.workspace = true
reth-primitives-traits.workspace = true
reth-network-peers.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions crates/optimism/chainspec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use reth_chainspec::{
};
use reth_ethereum_forks::{ChainHardforks, EthereumHardfork, ForkCondition, Hardfork};
use reth_network_peers::NodeRecord;
use reth_optimism_forks::OptimismHardforks;
use reth_primitives_traits::Header;
use std::fmt::Display;

Expand Down Expand Up @@ -262,6 +263,8 @@ impl EthereumHardforks for OpChainSpec {
}
}

impl OptimismHardforks for OpChainSpec {}

impl From<Genesis> for OpChainSpec {
fn from(genesis: Genesis) -> Self {
use reth_optimism_forks::OptimismHardfork;
Expand Down
2 changes: 1 addition & 1 deletion crates/optimism/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl ConfigureEvmEnv for OptimismEvmConfig {
cfg_env.perf_analyse_created_bytecodes = AnalysisKind::Analyse;

cfg_env.handler_cfg.spec_id = spec_id;
cfg_env.handler_cfg.is_optimism = self.chain_spec.is_optimism();
cfg_env.handler_cfg.is_optimism = true;
}

fn next_cfg_and_block_env(
Expand Down
1 change: 0 additions & 1 deletion crates/optimism/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ op-alloy-consensus.workspace = true

[features]
optimism = [
"reth-chainspec/optimism",
"reth-primitives/optimism",
"reth-provider/optimism",
"reth-optimism-evm/optimism",
Expand Down
1 change: 0 additions & 1 deletion crates/optimism/payload/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ sha2.workspace = true

[features]
optimism = [
"reth-chainspec/optimism",
"reth-primitives/optimism",
"reth-provider/optimism",
"reth-optimism-evm/optimism",
Expand Down
22 changes: 1 addition & 21 deletions crates/optimism/rpc/src/eth/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use alloy_eips::eip2718::Encodable2718;
use alloy_rpc_types::{AnyReceiptEnvelope, Log, TransactionReceipt};
use op_alloy_consensus::{OpDepositReceipt, OpDepositReceiptWithBloom, OpReceiptEnvelope};
use op_alloy_rpc_types::{receipt::L1BlockInfo, OpTransactionReceipt, OpTransactionReceiptFields};
use reth_chainspec::ChainSpec;
use reth_node_api::{FullNodeComponents, NodeTypes};
use reth_optimism_chainspec::OpChainSpec;
use reth_optimism_evm::RethL1BlockInfo;
Expand Down Expand Up @@ -55,25 +54,6 @@ where
}
}

impl<N> OpEthApi<N>
where
N: FullNodeComponents<Types: NodeTypes<ChainSpec = ChainSpec>>,
{
/// Builds a receipt w.r.t. chain spec.
pub fn build_op_receipt_meta(
&self,
tx: &TransactionSigned,
l1_block_info: revm::L1BlockInfo,
receipt: &Receipt,
) -> Result<OpTransactionReceiptFields, OpEthApiError> {
Ok(OpReceiptFieldsBuilder::default()
.l1_block_info(&self.inner.provider().chain_spec(), tx, l1_block_info)?
.deposit_nonce(receipt.deposit_nonce)
.deposit_version(receipt.deposit_receipt_version)
.build())
}
}

Comment on lines -58 to -76
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of scope to remove unused code, but ok

/// L1 fee and data gas for a non-deposit transaction, or deposit nonce and receipt version for a
/// deposit transaction.
#[derive(Debug, Default, Clone)]
Expand Down Expand Up @@ -113,7 +93,7 @@ impl OpReceiptFieldsBuilder {
/// Applies [`L1BlockInfo`](revm::L1BlockInfo).
pub fn l1_block_info(
mut self,
chain_spec: &ChainSpec,
chain_spec: &OpChainSpec,
tx: &TransactionSigned,
l1_block_info: revm::L1BlockInfo,
) -> Result<Self, OpEthApiError> {
Expand Down
Loading