From 9b2bcb69d753e4fade126481be1f83bd0e6c300c Mon Sep 17 00:00:00 2001 From: Thomas Coratger Date: Wed, 2 Oct 2024 20:20:53 +0200 Subject: [PATCH 1/2] primitives: Remove optimism re-export in reth-primitives --- crates/optimism/evm/src/execute.rs | 10 ++++------ crates/optimism/evm/src/lib.rs | 3 ++- crates/optimism/node/src/txpool.rs | 2 +- crates/optimism/node/tests/it/builder.rs | 2 +- crates/primitives/src/lib.rs | 10 ---------- crates/primitives/src/receipt.rs | 4 ++-- 6 files changed, 10 insertions(+), 21 deletions(-) diff --git a/crates/optimism/evm/src/execute.rs b/crates/optimism/evm/src/execute.rs index 28f8cdf4ed25..f0ad1c2fbce7 100644 --- a/crates/optimism/evm/src/execute.rs +++ b/crates/optimism/evm/src/execute.rs @@ -468,10 +468,8 @@ mod tests { use alloy_consensus::TxEip1559; use alloy_primitives::{b256, Address, StorageKey, StorageValue}; use reth_chainspec::{ChainSpecBuilder, MIN_TRANSACTION_GAS}; - use reth_optimism_chainspec::optimism_deposit_tx_signature; - use reth_primitives::{ - Account, Block, BlockBody, Signature, Transaction, TransactionSigned, BASE_MAINNET, - }; + use reth_optimism_chainspec::{optimism_deposit_tx_signature, BASE_MAINNET}; + use reth_primitives::{Account, Block, BlockBody, Signature, Transaction, TransactionSigned}; use reth_revm::{ database::StateProviderDatabase, test_utils::StateProviderTest, L1_BLOCK_CONTRACT, }; @@ -546,7 +544,7 @@ mod tests { ); let tx_deposit = TransactionSigned::from_transaction_and_signature( - Transaction::Deposit(reth_primitives::TxDeposit { + Transaction::Deposit(reth_primitives::transaction::TxDeposit { from: addr, to: addr.into(), gas_limit: MIN_TRANSACTION_GAS, @@ -630,7 +628,7 @@ mod tests { ); let tx_deposit = TransactionSigned::from_transaction_and_signature( - Transaction::Deposit(reth_primitives::TxDeposit { + Transaction::Deposit(reth_primitives::transaction::TxDeposit { from: addr, to: addr.into(), gas_limit: MIN_TRANSACTION_GAS, diff --git a/crates/optimism/evm/src/lib.rs b/crates/optimism/evm/src/lib.rs index 7d918b6ef5e3..b220b6056de0 100644 --- a/crates/optimism/evm/src/lib.rs +++ b/crates/optimism/evm/src/lib.rs @@ -213,9 +213,10 @@ mod tests { use alloy_primitives::{B256, U256}; use reth_chainspec::{Chain, ChainSpec}; use reth_evm::execute::ProviderError; + use reth_optimism_chainspec::BASE_MAINNET; use reth_primitives::{ revm_primitives::{BlockEnv, CfgEnv, SpecId}, - Header, BASE_MAINNET, KECCAK_EMPTY, + Header, KECCAK_EMPTY, }; use reth_revm::{ db::{CacheDB, EmptyDBTyped}, diff --git a/crates/optimism/node/src/txpool.rs b/crates/optimism/node/src/txpool.rs index 3bd5d6fd38db..69f759ec5d7a 100644 --- a/crates/optimism/node/src/txpool.rs +++ b/crates/optimism/node/src/txpool.rs @@ -235,7 +235,7 @@ mod tests { use reth::primitives::Signature; use reth_chainspec::MAINNET; use reth_primitives::{ - Transaction, TransactionSigned, TransactionSignedEcRecovered, TxDeposit, + transaction::TxDeposit, Transaction, TransactionSigned, TransactionSignedEcRecovered, }; use reth_provider::test_utils::MockEthProvider; use reth_transaction_pool::{ diff --git a/crates/optimism/node/tests/it/builder.rs b/crates/optimism/node/tests/it/builder.rs index df1dd71fb086..20363828e861 100644 --- a/crates/optimism/node/tests/it/builder.rs +++ b/crates/optimism/node/tests/it/builder.rs @@ -3,8 +3,8 @@ use reth_db::test_utils::create_test_rw_db; use reth_node_api::FullNodeComponents; use reth_node_builder::{NodeBuilder, NodeConfig}; +use reth_optimism_chainspec::BASE_MAINNET; use reth_optimism_node::{node::OptimismAddOns, OptimismNode}; -use reth_primitives::BASE_MAINNET; #[test] fn test_basic_setup() { diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index da620e50e82c..ec65cbf20e52 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -78,16 +78,6 @@ pub use arbitrary; #[cfg(feature = "c-kzg")] pub use c_kzg as kzg; -/// Optimism specific re-exports -#[cfg(feature = "optimism")] -mod optimism { - pub use crate::transaction::{optimism_deposit_tx_signature, TxDeposit, DEPOSIT_TX_TYPE_ID}; - pub use reth_optimism_chainspec::{BASE_MAINNET, BASE_SEPOLIA, OP_MAINNET, OP_SEPOLIA}; -} - -#[cfg(feature = "optimism")] -pub use optimism::*; - /// Bincode-compatible serde implementations for commonly used types in Reth. /// /// `bincode` crate doesn't work with optionally serializable serde fields, but some of the diff --git a/crates/primitives/src/receipt.rs b/crates/primitives/src/receipt.rs index 60ea42e94a43..5c794be5061e 100644 --- a/crates/primitives/src/receipt.rs +++ b/crates/primitives/src/receipt.rs @@ -332,7 +332,7 @@ impl Decodable for ReceiptWithBloom { Self::decode_receipt(buf, TxType::Eip7702) } #[cfg(feature = "optimism")] - crate::DEPOSIT_TX_TYPE_ID => { + crate::transaction::DEPOSIT_TX_TYPE_ID => { buf.advance(1); Self::decode_receipt(buf, TxType::Deposit) } @@ -468,7 +468,7 @@ impl<'a> ReceiptWithBloomEncoder<'a> { } #[cfg(feature = "optimism")] TxType::Deposit => { - out.put_u8(crate::DEPOSIT_TX_TYPE_ID); + out.put_u8(crate::transaction::DEPOSIT_TX_TYPE_ID); } } out.put_slice(payload.as_ref()); From a239524810b8fde14ce9d42f6294a1bf479306b9 Mon Sep 17 00:00:00 2001 From: Thomas Coratger Date: Thu, 3 Oct 2024 11:06:17 +0200 Subject: [PATCH 2/2] fix comment --- Cargo.lock | 2 ++ crates/optimism/evm/Cargo.toml | 1 + crates/optimism/evm/src/execute.rs | 4 ++-- crates/optimism/node/Cargo.toml | 3 ++- crates/optimism/node/src/txpool.rs | 6 ++---- crates/primitives/src/alloy_compat.rs | 2 +- crates/primitives/src/transaction/mod.rs | 4 ++-- 7 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d14e97f7a82a..00be3aa269ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8069,6 +8069,7 @@ dependencies = [ "alloy-eips", "alloy-genesis", "alloy-primitives", + "op-alloy-consensus", "reth-chainspec", "reth-ethereum-forks", "reth-evm", @@ -8110,6 +8111,7 @@ dependencies = [ "eyre", "jsonrpsee", "jsonrpsee-types", + "op-alloy-consensus", "op-alloy-rpc-types-engine", "parking_lot 0.12.3", "reqwest", diff --git a/crates/optimism/evm/Cargo.toml b/crates/optimism/evm/Cargo.toml index c0be459167ff..76fa3ce69e4d 100644 --- a/crates/optimism/evm/Cargo.toml +++ b/crates/optimism/evm/Cargo.toml @@ -23,6 +23,7 @@ reth-prune-types.workspace = true # ethereum alloy-primitives.workspace = true +op-alloy-consensus.workspace = true # Optimism reth-optimism-consensus.workspace = true diff --git a/crates/optimism/evm/src/execute.rs b/crates/optimism/evm/src/execute.rs index f0ad1c2fbce7..6ca9cec5260e 100644 --- a/crates/optimism/evm/src/execute.rs +++ b/crates/optimism/evm/src/execute.rs @@ -544,7 +544,7 @@ mod tests { ); let tx_deposit = TransactionSigned::from_transaction_and_signature( - Transaction::Deposit(reth_primitives::transaction::TxDeposit { + Transaction::Deposit(op_alloy_consensus::TxDeposit { from: addr, to: addr.into(), gas_limit: MIN_TRANSACTION_GAS, @@ -628,7 +628,7 @@ mod tests { ); let tx_deposit = TransactionSigned::from_transaction_and_signature( - Transaction::Deposit(reth_primitives::transaction::TxDeposit { + Transaction::Deposit(op_alloy_consensus::TxDeposit { from: addr, to: addr.into(), gas_limit: MIN_TRANSACTION_GAS, diff --git a/crates/optimism/node/Cargo.toml b/crates/optimism/node/Cargo.toml index 90eaa9fc2f4a..cb74bcbc0904 100644 --- a/crates/optimism/node/Cargo.toml +++ b/crates/optimism/node/Cargo.toml @@ -74,6 +74,7 @@ reth-revm = { workspace = true, features = ["test-utils"] } tokio.workspace = true alloy-primitives.workspace = true alloy-genesis.workspace = true +op-alloy-consensus.workspace = true [features] optimism = [ @@ -86,7 +87,7 @@ optimism = [ "reth-beacon-consensus/optimism", "reth-revm/optimism", "reth-auto-seal-consensus/optimism", - "reth-optimism-rpc/optimism" + "reth-optimism-rpc/optimism", ] asm-keccak = ["reth-primitives/asm-keccak"] test-utils = ["reth-node-builder/test-utils"] diff --git a/crates/optimism/node/src/txpool.rs b/crates/optimism/node/src/txpool.rs index 69f759ec5d7a..811c37e91cb5 100644 --- a/crates/optimism/node/src/txpool.rs +++ b/crates/optimism/node/src/txpool.rs @@ -232,17 +232,15 @@ mod tests { use crate::txpool::OpTransactionValidator; use alloy_eips::eip2718::Encodable2718; use alloy_primitives::{TxKind, U256}; + use op_alloy_consensus::TxDeposit; use reth::primitives::Signature; use reth_chainspec::MAINNET; - use reth_primitives::{ - transaction::TxDeposit, Transaction, TransactionSigned, TransactionSignedEcRecovered, - }; + use reth_primitives::{Transaction, TransactionSigned, TransactionSignedEcRecovered}; use reth_provider::test_utils::MockEthProvider; use reth_transaction_pool::{ blobstore::InMemoryBlobStore, validate::EthTransactionValidatorBuilder, EthPooledTransaction, TransactionOrigin, TransactionValidationOutcome, }; - #[test] fn validate_optimism_transaction() { let client = MockEthProvider::default(); diff --git a/crates/primitives/src/alloy_compat.rs b/crates/primitives/src/alloy_compat.rs index 867aceecef0b..bf7f557b799a 100644 --- a/crates/primitives/src/alloy_compat.rs +++ b/crates/primitives/src/alloy_compat.rs @@ -196,7 +196,7 @@ impl TryFrom> for Transaction { let fields = other .deserialize_into::() .map_err(|e| ConversionError::Custom(e.to_string()))?; - Ok(Self::Deposit(crate::transaction::TxDeposit { + Ok(Self::Deposit(op_alloy_consensus::TxDeposit { source_hash: fields .source_hash .ok_or_else(|| ConversionError::Custom("MissingSourceHash".to_string()))?, diff --git a/crates/primitives/src/transaction/mod.rs b/crates/primitives/src/transaction/mod.rs index 95c04094e2a3..b16c2c88ab52 100644 --- a/crates/primitives/src/transaction/mod.rs +++ b/crates/primitives/src/transaction/mod.rs @@ -51,9 +51,9 @@ pub(crate) mod util; mod variant; #[cfg(feature = "optimism")] -pub use op_alloy_consensus::TxDeposit; +use op_alloy_consensus::TxDeposit; #[cfg(feature = "optimism")] -pub use reth_optimism_chainspec::optimism_deposit_tx_signature; +use reth_optimism_chainspec::optimism_deposit_tx_signature; #[cfg(feature = "optimism")] pub use tx_type::DEPOSIT_TX_TYPE_ID; #[cfg(any(test, feature = "reth-codec"))]