From 88eb0beeb2332deceee48cd3bd73a742b03c9e12 Mon Sep 17 00:00:00 2001 From: theo <80177219+theochap@users.noreply.github.com> Date: Wed, 28 Jan 2026 09:53:17 -0500 Subject: [PATCH] chore(op-reth): remove op-reth dependencies from core reth library crates (#21492) --- Cargo.lock | 5 +-- crates/engine/local/Cargo.toml | 3 -- crates/engine/local/src/payload.rs | 13 +++++-- crates/optimism/chainspec/src/constants.rs | 12 ------ crates/optimism/rpc/src/eth/transaction.rs | 23 +++++++++-- crates/rpc/rpc-convert/Cargo.toml | 4 -- crates/rpc/rpc-convert/src/lib.rs | 3 -- crates/rpc/rpc-convert/src/receipt.rs | 2 +- crates/rpc/rpc-convert/src/transaction.rs | 44 +++------------------- crates/storage/db-api/Cargo.toml | 6 +-- crates/storage/db-api/src/models/mod.rs | 4 +- 11 files changed, 41 insertions(+), 78 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 12b9904257..f523fa4b81 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8041,6 +8041,7 @@ dependencies = [ "derive_more", "metrics", "modular-bitfield", + "op-alloy-consensus", "parity-scale-codec", "proptest", "proptest-arbitrary-interop", @@ -8048,7 +8049,6 @@ dependencies = [ "reth-codecs", "reth-db-models", "reth-ethereum-primitives", - "reth-optimism-primitives", "reth-primitives-traits", "reth-prune-types", "reth-stages-types", @@ -8319,7 +8319,6 @@ dependencies = [ "reth-chainspec", "reth-engine-primitives", "reth-ethereum-engine-primitives", - "reth-optimism-chainspec", "reth-payload-builder", "reth-payload-primitives", "reth-primitives-traits", @@ -10526,9 +10525,7 @@ dependencies = [ "op-alloy-rpc-types", "reth-ethereum-primitives", "reth-evm", - "reth-optimism-primitives", "reth-primitives-traits", - "reth-storage-api", "serde_json", "thiserror 2.0.18", ] diff --git a/crates/engine/local/Cargo.toml b/crates/engine/local/Cargo.toml index 8bf9e28bcb..b115ad5626 100644 --- a/crates/engine/local/Cargo.toml +++ b/crates/engine/local/Cargo.toml @@ -32,9 +32,7 @@ futures-util.workspace = true # misc eyre.workspace = true tracing.workspace = true - op-alloy-rpc-types-engine = { workspace = true, optional = true } -reth-optimism-chainspec = { workspace = true, optional = true } [lints] workspace = true @@ -42,7 +40,6 @@ workspace = true [features] op = [ "dep:op-alloy-rpc-types-engine", - "dep:reth-optimism-chainspec", "reth-payload-primitives/op", "reth-primitives-traits/op", ] diff --git a/crates/engine/local/src/payload.rs b/crates/engine/local/src/payload.rs index dc3be02f17..5555143096 100644 --- a/crates/engine/local/src/payload.rs +++ b/crates/engine/local/src/payload.rs @@ -72,13 +72,18 @@ where &self, parent: &SealedHeader, ) -> op_alloy_rpc_types_engine::OpPayloadAttributes { + /// Dummy system transaction for dev mode. + /// OP Mainnet transaction at index 0 in block 124665056. + /// + /// + const TX_SET_L1_BLOCK_OP_MAINNET_BLOCK_124665056: [u8; 251] = alloy_primitives::hex!( + "7ef8f8a0683079df94aa5b9cf86687d739a60a9b4f0835e520ec4d664e2e415dca17a6df94deaddeaddeaddeaddeaddeaddeaddeaddead00019442000000000000000000000000000000000000158080830f424080b8a4440a5e200000146b000f79c500000000000000040000000066d052e700000000013ad8a3000000000000000000000000000000000000000000000000000000003ef1278700000000000000000000000000000000000000000000000000000000000000012fdf87b89884a61e74b322bbcf60386f543bfae7827725efaaf0ab1de2294a590000000000000000000000006887246668a3b87f54deb3b94ba47a6f63f32985" + ); + op_alloy_rpc_types_engine::OpPayloadAttributes { payload_attributes: self.build(parent), // Add dummy system transaction - transactions: Some(vec![ - reth_optimism_chainspec::constants::TX_SET_L1_BLOCK_OP_MAINNET_BLOCK_124665056 - .into(), - ]), + transactions: Some(vec![TX_SET_L1_BLOCK_OP_MAINNET_BLOCK_124665056.into()]), no_tx_pool: None, gas_limit: None, eip_1559_params: None, diff --git a/crates/optimism/chainspec/src/constants.rs b/crates/optimism/chainspec/src/constants.rs index ba69adfe1e..439c2fed83 100644 --- a/crates/optimism/chainspec/src/constants.rs +++ b/crates/optimism/chainspec/src/constants.rs @@ -1,7 +1,5 @@ //! OP stack variation of chain spec constants. -use alloy_primitives::hex; - //------------------------------- BASE MAINNET -------------------------------// /// Max gas limit on Base: @@ -11,13 +9,3 @@ pub const BASE_MAINNET_MAX_GAS_LIMIT: u64 = 105_000_000; /// Max gas limit on Base Sepolia: pub const BASE_SEPOLIA_MAX_GAS_LIMIT: u64 = 45_000_000; - -//----------------------------------- DEV ------------------------------------// - -/// Dummy system transaction for dev mode -/// OP Mainnet transaction at index 0 in block 124665056. -/// -/// -pub const TX_SET_L1_BLOCK_OP_MAINNET_BLOCK_124665056: [u8; 251] = hex!( - "7ef8f8a0683079df94aa5b9cf86687d739a60a9b4f0835e520ec4d664e2e415dca17a6df94deaddeaddeaddeaddeaddeaddeaddeaddead00019442000000000000000000000000000000000000158080830f424080b8a4440a5e200000146b000f79c500000000000000040000000066d052e700000000013ad8a3000000000000000000000000000000000000000000000000000000003ef1278700000000000000000000000000000000000000000000000000000000000000012fdf87b89884a61e74b322bbcf60386f543bfae7827725efaaf0ab1de2294a590000000000000000000000006887246668a3b87f54deb3b94ba47a6f63f32985" -); diff --git a/crates/optimism/rpc/src/eth/transaction.rs b/crates/optimism/rpc/src/eth/transaction.rs index f9e7e83375..af842e71c6 100644 --- a/crates/optimism/rpc/src/eth/transaction.rs +++ b/crates/optimism/rpc/src/eth/transaction.rs @@ -4,14 +4,17 @@ use crate::{OpEthApi, OpEthApiError, SequencerClient}; use alloy_primitives::{Bytes, B256}; use alloy_rpc_types_eth::TransactionInfo; use futures::StreamExt; -use op_alloy_consensus::{transaction::OpTransactionInfo, OpTransaction}; +use op_alloy_consensus::{ + transaction::{OpDepositInfo, OpTransactionInfo}, + OpTransaction, +}; use reth_chain_state::CanonStateSubscriptions; use reth_optimism_primitives::DepositReceipt; use reth_primitives_traits::{Recovered, SignedTransaction, SignerRecoverable, WithEncoded}; use reth_rpc_eth_api::{ helpers::{spec::SignersForRpc, EthTransactions, LoadReceipt, LoadTransaction, SpawnBlocking}, - try_into_op_tx_info, EthApiTypes as _, FromEthApiError, FromEvmError, RpcConvert, RpcNodeCore, - RpcReceipt, TxInfoMapper, + EthApiTypes as _, FromEthApiError, FromEvmError, RpcConvert, RpcNodeCore, RpcReceipt, + TxInfoMapper, }; use reth_rpc_eth_types::{block::convert_transaction_receipt, EthApiError, TransactionSource}; use reth_storage_api::{errors::ProviderError, ProviderTx, ReceiptProvider, TransactionsProvider}; @@ -282,6 +285,18 @@ where type Err = ProviderError; fn try_map(&self, tx: &T, tx_info: TransactionInfo) -> Result { - try_into_op_tx_info(&self.provider, tx, tx_info) + let deposit_meta = if tx.is_deposit() { + self.provider.receipt_by_hash(*tx.tx_hash())?.and_then(|receipt| { + receipt.as_deposit_receipt().map(|receipt| OpDepositInfo { + deposit_receipt_version: receipt.deposit_receipt_version, + deposit_nonce: receipt.deposit_nonce, + }) + }) + } else { + None + } + .unwrap_or_default(); + + Ok(OpTransactionInfo::new(tx_info, deposit_meta)) } } diff --git a/crates/rpc/rpc-convert/Cargo.toml b/crates/rpc/rpc-convert/Cargo.toml index 53b8d0541e..0f66d081bf 100644 --- a/crates/rpc/rpc-convert/Cargo.toml +++ b/crates/rpc/rpc-convert/Cargo.toml @@ -14,7 +14,6 @@ workspace = true [dependencies] # reth reth-primitives-traits.workspace = true -reth-storage-api = { workspace = true, optional = true } reth-evm.workspace = true reth-ethereum-primitives.workspace = true @@ -31,7 +30,6 @@ alloy-evm = { workspace = true, features = ["rpc"] } op-alloy-consensus = { workspace = true, optional = true } op-alloy-rpc-types = { workspace = true, optional = true } op-alloy-network = { workspace = true, optional = true } -reth-optimism-primitives = { workspace = true, optional = true } # io jsonrpsee-types.workspace = true @@ -51,8 +49,6 @@ op = [ "dep:op-alloy-consensus", "dep:op-alloy-rpc-types", "dep:op-alloy-network", - "dep:reth-optimism-primitives", - "dep:reth-storage-api", "reth-evm/op", "reth-primitives-traits/op", "alloy-evm/op", diff --git a/crates/rpc/rpc-convert/src/lib.rs b/crates/rpc/rpc-convert/src/lib.rs index 0d33251ce0..1c9ab80432 100644 --- a/crates/rpc/rpc-convert/src/lib.rs +++ b/crates/rpc/rpc-convert/src/lib.rs @@ -24,6 +24,3 @@ pub use transaction::{ }; pub use alloy_evm::rpc::{CallFees, CallFeesError, EthTxEnvError, TryIntoTxEnv}; - -#[cfg(feature = "op")] -pub use transaction::op::*; diff --git a/crates/rpc/rpc-convert/src/receipt.rs b/crates/rpc/rpc-convert/src/receipt.rs index 2da79a9b53..c297414595 100644 --- a/crates/rpc/rpc-convert/src/receipt.rs +++ b/crates/rpc/rpc-convert/src/receipt.rs @@ -29,7 +29,7 @@ impl TryFromReceiptResponse for reth_ethereum_primitive } #[cfg(feature = "op")] -impl TryFromReceiptResponse for reth_optimism_primitives::OpReceipt { +impl TryFromReceiptResponse for op_alloy_consensus::OpReceipt { type Error = Infallible; fn from_receipt_response( diff --git a/crates/rpc/rpc-convert/src/transaction.rs b/crates/rpc/rpc-convert/src/transaction.rs index 1036e15199..9e60f823c6 100644 --- a/crates/rpc/rpc-convert/src/transaction.rs +++ b/crates/rpc/rpc-convert/src/transaction.rs @@ -872,40 +872,8 @@ pub mod op { use super::*; use alloy_consensus::SignableTransaction; use alloy_signer::Signature; - use op_alloy_consensus::{ - transaction::{OpDepositInfo, OpTransactionInfo}, - OpTxEnvelope, - }; + use op_alloy_consensus::{transaction::OpTransactionInfo, OpTxEnvelope}; use op_alloy_rpc_types::OpTransactionRequest; - use reth_optimism_primitives::DepositReceipt; - use reth_primitives_traits::SignedTransaction; - use reth_storage_api::{errors::ProviderError, ReceiptProvider}; - - /// Creates [`OpTransactionInfo`] by adding [`OpDepositInfo`] to [`TransactionInfo`] if `tx` is - /// a deposit. - pub fn try_into_op_tx_info( - provider: &T, - tx: &Tx, - tx_info: TransactionInfo, - ) -> Result - where - Tx: op_alloy_consensus::OpTransaction + SignedTransaction, - T: ReceiptProvider, - { - let deposit_meta = if tx.is_deposit() { - provider.receipt_by_hash(*tx.tx_hash())?.and_then(|receipt| { - receipt.as_deposit_receipt().map(|receipt| OpDepositInfo { - deposit_receipt_version: receipt.deposit_receipt_version, - deposit_nonce: receipt.deposit_nonce, - }) - }) - } else { - None - } - .unwrap_or_default(); - - Ok(OpTransactionInfo::new(tx_info, deposit_meta)) - } impl FromConsensusTx for op_alloy_rpc_types::Transaction @@ -964,9 +932,7 @@ impl TryFromTransactionResponse } #[cfg(feature = "op")] -impl TryFromTransactionResponse - for reth_optimism_primitives::OpTransactionSigned -{ +impl TryFromTransactionResponse for op_alloy_consensus::OpTxEnvelope { type Error = Infallible; fn from_transaction_response( @@ -1015,7 +981,6 @@ mod transaction_response_tests { fn test_optimism_transaction_conversion() { use op_alloy_consensus::OpTxEnvelope; use op_alloy_network::Optimism; - use reth_optimism_primitives::OpTransactionSigned; let signed_tx = Signed::new_unchecked( TxLegacy::default(), @@ -1038,7 +1003,10 @@ mod transaction_response_tests { deposit_receipt_version: None, }; - let result = >::from_transaction_response(tx_response); + let result = + >::from_transaction_response( + tx_response, + ); assert!(result.is_ok()); } diff --git a/crates/storage/db-api/Cargo.toml b/crates/storage/db-api/Cargo.toml index 9faf7cb0ab..b5026043a7 100644 --- a/crates/storage/db-api/Cargo.toml +++ b/crates/storage/db-api/Cargo.toml @@ -28,7 +28,7 @@ alloy-genesis.workspace = true alloy-consensus.workspace = true # optimism -reth-optimism-primitives = { workspace = true, optional = true, features = ["serde", "reth-codec"] } +op-alloy-consensus = { workspace = true, optional = true } # codecs modular-bitfield.workspace = true @@ -85,11 +85,11 @@ arbitrary = [ "reth-prune-types/arbitrary", "reth-stages-types/arbitrary", "alloy-consensus/arbitrary", - "reth-optimism-primitives?/arbitrary", + "op-alloy-consensus?/arbitrary", "reth-ethereum-primitives/arbitrary", ] op = [ - "dep:reth-optimism-primitives", + "dep:op-alloy-consensus", "reth-codecs/op", "reth-primitives-traits/op", ] diff --git a/crates/storage/db-api/src/models/mod.rs b/crates/storage/db-api/src/models/mod.rs index 0b6a12f011..523c17ef43 100644 --- a/crates/storage/db-api/src/models/mod.rs +++ b/crates/storage/db-api/src/models/mod.rs @@ -240,9 +240,9 @@ impl_compression_for_compact!( #[cfg(feature = "op")] mod op { use super::*; - use reth_optimism_primitives::{OpReceipt, OpTransactionSigned}; + use op_alloy_consensus::{OpReceipt, OpTxEnvelope}; - impl_compression_for_compact!(OpTransactionSigned, OpReceipt); + impl_compression_for_compact!(OpTxEnvelope, OpReceipt); } macro_rules! impl_compression_fixed_compact {