primitives: remove optimism re-export in reth-primitives (#11438)

This commit is contained in:
Thomas Coratger
2024-10-03 12:38:18 +02:00
committed by GitHub
parent 575669b744
commit 7fbe19a9bf
11 changed files with 19 additions and 28 deletions

2
Cargo.lock generated
View File

@ -8070,6 +8070,7 @@ dependencies = [
"alloy-eips", "alloy-eips",
"alloy-genesis", "alloy-genesis",
"alloy-primitives", "alloy-primitives",
"op-alloy-consensus",
"reth-chainspec", "reth-chainspec",
"reth-ethereum-forks", "reth-ethereum-forks",
"reth-evm", "reth-evm",
@ -8111,6 +8112,7 @@ dependencies = [
"eyre", "eyre",
"jsonrpsee", "jsonrpsee",
"jsonrpsee-types", "jsonrpsee-types",
"op-alloy-consensus",
"op-alloy-rpc-types-engine", "op-alloy-rpc-types-engine",
"parking_lot 0.12.3", "parking_lot 0.12.3",
"reqwest", "reqwest",

View File

@ -23,6 +23,7 @@ reth-prune-types.workspace = true
# ethereum # ethereum
alloy-primitives.workspace = true alloy-primitives.workspace = true
op-alloy-consensus.workspace = true
# Optimism # Optimism
reth-optimism-consensus.workspace = true reth-optimism-consensus.workspace = true

View File

@ -468,10 +468,8 @@ mod tests {
use alloy_consensus::TxEip1559; use alloy_consensus::TxEip1559;
use alloy_primitives::{b256, Address, StorageKey, StorageValue}; use alloy_primitives::{b256, Address, StorageKey, StorageValue};
use reth_chainspec::{ChainSpecBuilder, MIN_TRANSACTION_GAS}; use reth_chainspec::{ChainSpecBuilder, MIN_TRANSACTION_GAS};
use reth_optimism_chainspec::optimism_deposit_tx_signature; use reth_optimism_chainspec::{optimism_deposit_tx_signature, BASE_MAINNET};
use reth_primitives::{ use reth_primitives::{Account, Block, BlockBody, Signature, Transaction, TransactionSigned};
Account, Block, BlockBody, Signature, Transaction, TransactionSigned, BASE_MAINNET,
};
use reth_revm::{ use reth_revm::{
database::StateProviderDatabase, test_utils::StateProviderTest, L1_BLOCK_CONTRACT, database::StateProviderDatabase, test_utils::StateProviderTest, L1_BLOCK_CONTRACT,
}; };
@ -546,7 +544,7 @@ mod tests {
); );
let tx_deposit = TransactionSigned::from_transaction_and_signature( let tx_deposit = TransactionSigned::from_transaction_and_signature(
Transaction::Deposit(reth_primitives::TxDeposit { Transaction::Deposit(op_alloy_consensus::TxDeposit {
from: addr, from: addr,
to: addr.into(), to: addr.into(),
gas_limit: MIN_TRANSACTION_GAS, gas_limit: MIN_TRANSACTION_GAS,
@ -630,7 +628,7 @@ mod tests {
); );
let tx_deposit = TransactionSigned::from_transaction_and_signature( let tx_deposit = TransactionSigned::from_transaction_and_signature(
Transaction::Deposit(reth_primitives::TxDeposit { Transaction::Deposit(op_alloy_consensus::TxDeposit {
from: addr, from: addr,
to: addr.into(), to: addr.into(),
gas_limit: MIN_TRANSACTION_GAS, gas_limit: MIN_TRANSACTION_GAS,

View File

@ -213,9 +213,10 @@ mod tests {
use alloy_primitives::{B256, U256}; use alloy_primitives::{B256, U256};
use reth_chainspec::{Chain, ChainSpec}; use reth_chainspec::{Chain, ChainSpec};
use reth_evm::execute::ProviderError; use reth_evm::execute::ProviderError;
use reth_optimism_chainspec::BASE_MAINNET;
use reth_primitives::{ use reth_primitives::{
revm_primitives::{BlockEnv, CfgEnv, SpecId}, revm_primitives::{BlockEnv, CfgEnv, SpecId},
Header, BASE_MAINNET, KECCAK_EMPTY, Header, KECCAK_EMPTY,
}; };
use reth_revm::{ use reth_revm::{
db::{CacheDB, EmptyDBTyped}, db::{CacheDB, EmptyDBTyped},

View File

@ -74,6 +74,7 @@ reth-revm = { workspace = true, features = ["test-utils"] }
tokio.workspace = true tokio.workspace = true
alloy-primitives.workspace = true alloy-primitives.workspace = true
alloy-genesis.workspace = true alloy-genesis.workspace = true
op-alloy-consensus.workspace = true
[features] [features]
optimism = [ optimism = [
@ -86,7 +87,7 @@ optimism = [
"reth-beacon-consensus/optimism", "reth-beacon-consensus/optimism",
"reth-revm/optimism", "reth-revm/optimism",
"reth-auto-seal-consensus/optimism", "reth-auto-seal-consensus/optimism",
"reth-optimism-rpc/optimism" "reth-optimism-rpc/optimism",
] ]
asm-keccak = ["reth-primitives/asm-keccak"] asm-keccak = ["reth-primitives/asm-keccak"]
test-utils = ["reth-node-builder/test-utils"] test-utils = ["reth-node-builder/test-utils"]

View File

@ -232,17 +232,15 @@ mod tests {
use crate::txpool::OpTransactionValidator; use crate::txpool::OpTransactionValidator;
use alloy_eips::eip2718::Encodable2718; use alloy_eips::eip2718::Encodable2718;
use alloy_primitives::{TxKind, U256}; use alloy_primitives::{TxKind, U256};
use op_alloy_consensus::TxDeposit;
use reth::primitives::Signature; use reth::primitives::Signature;
use reth_chainspec::MAINNET; use reth_chainspec::MAINNET;
use reth_primitives::{ use reth_primitives::{Transaction, TransactionSigned, TransactionSignedEcRecovered};
Transaction, TransactionSigned, TransactionSignedEcRecovered, TxDeposit,
};
use reth_provider::test_utils::MockEthProvider; use reth_provider::test_utils::MockEthProvider;
use reth_transaction_pool::{ use reth_transaction_pool::{
blobstore::InMemoryBlobStore, validate::EthTransactionValidatorBuilder, blobstore::InMemoryBlobStore, validate::EthTransactionValidatorBuilder,
EthPooledTransaction, TransactionOrigin, TransactionValidationOutcome, EthPooledTransaction, TransactionOrigin, TransactionValidationOutcome,
}; };
#[test] #[test]
fn validate_optimism_transaction() { fn validate_optimism_transaction() {
let client = MockEthProvider::default(); let client = MockEthProvider::default();

View File

@ -3,8 +3,8 @@
use reth_db::test_utils::create_test_rw_db; use reth_db::test_utils::create_test_rw_db;
use reth_node_api::FullNodeComponents; use reth_node_api::FullNodeComponents;
use reth_node_builder::{NodeBuilder, NodeConfig}; use reth_node_builder::{NodeBuilder, NodeConfig};
use reth_optimism_chainspec::BASE_MAINNET;
use reth_optimism_node::{node::OptimismAddOns, OptimismNode}; use reth_optimism_node::{node::OptimismAddOns, OptimismNode};
use reth_primitives::BASE_MAINNET;
#[test] #[test]
fn test_basic_setup() { fn test_basic_setup() {

View File

@ -196,7 +196,7 @@ impl TryFrom<WithOtherFields<alloy_rpc_types::Transaction>> for Transaction {
let fields = other let fields = other
.deserialize_into::<op_alloy_rpc_types::OptimismTransactionFields>() .deserialize_into::<op_alloy_rpc_types::OptimismTransactionFields>()
.map_err(|e| ConversionError::Custom(e.to_string()))?; .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: fields
.source_hash .source_hash
.ok_or_else(|| ConversionError::Custom("MissingSourceHash".to_string()))?, .ok_or_else(|| ConversionError::Custom("MissingSourceHash".to_string()))?,

View File

@ -78,16 +78,6 @@ pub use arbitrary;
#[cfg(feature = "c-kzg")] #[cfg(feature = "c-kzg")]
pub use c_kzg as 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-compatible serde implementations for commonly used types in Reth.
/// ///
/// `bincode` crate doesn't work with optionally serializable serde fields, but some of the /// `bincode` crate doesn't work with optionally serializable serde fields, but some of the

View File

@ -332,7 +332,7 @@ impl Decodable for ReceiptWithBloom {
Self::decode_receipt(buf, TxType::Eip7702) Self::decode_receipt(buf, TxType::Eip7702)
} }
#[cfg(feature = "optimism")] #[cfg(feature = "optimism")]
crate::DEPOSIT_TX_TYPE_ID => { crate::transaction::DEPOSIT_TX_TYPE_ID => {
buf.advance(1); buf.advance(1);
Self::decode_receipt(buf, TxType::Deposit) Self::decode_receipt(buf, TxType::Deposit)
} }
@ -468,7 +468,7 @@ impl<'a> ReceiptWithBloomEncoder<'a> {
} }
#[cfg(feature = "optimism")] #[cfg(feature = "optimism")]
TxType::Deposit => { 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()); out.put_slice(payload.as_ref());

View File

@ -51,9 +51,9 @@ pub(crate) mod util;
mod variant; mod variant;
#[cfg(feature = "optimism")] #[cfg(feature = "optimism")]
pub use op_alloy_consensus::TxDeposit; use op_alloy_consensus::TxDeposit;
#[cfg(feature = "optimism")] #[cfg(feature = "optimism")]
pub use reth_optimism_chainspec::optimism_deposit_tx_signature; use reth_optimism_chainspec::optimism_deposit_tx_signature;
#[cfg(feature = "optimism")] #[cfg(feature = "optimism")]
pub use tx_type::DEPOSIT_TX_TYPE_ID; pub use tx_type::DEPOSIT_TX_TYPE_ID;
#[cfg(any(test, feature = "reth-codec"))] #[cfg(any(test, feature = "reth-codec"))]