Skip to content

Commit

Permalink
primitives: remove optimism re-export in reth-primitives (paradigmx…
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoratger authored Oct 3, 2024
1 parent 575669b commit 7fbe19a
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 28 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/optimism/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 4 additions & 6 deletions crates/optimism/evm/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -546,7 +544,7 @@ mod tests {
);

let tx_deposit = TransactionSigned::from_transaction_and_signature(
Transaction::Deposit(reth_primitives::TxDeposit {
Transaction::Deposit(op_alloy_consensus::TxDeposit {
from: addr,
to: addr.into(),
gas_limit: MIN_TRANSACTION_GAS,
Expand Down Expand Up @@ -630,7 +628,7 @@ mod tests {
);

let tx_deposit = TransactionSigned::from_transaction_and_signature(
Transaction::Deposit(reth_primitives::TxDeposit {
Transaction::Deposit(op_alloy_consensus::TxDeposit {
from: addr,
to: addr.into(),
gas_limit: MIN_TRANSACTION_GAS,
Expand Down
3 changes: 2 additions & 1 deletion crates/optimism/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
3 changes: 2 additions & 1 deletion crates/optimism/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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"]
6 changes: 2 additions & 4 deletions crates/optimism/node/src/txpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, TransactionSigned, TransactionSignedEcRecovered, TxDeposit,
};
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();
Expand Down
2 changes: 1 addition & 1 deletion crates/optimism/node/tests/it/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/src/alloy_compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ impl TryFrom<WithOtherFields<alloy_rpc_types::Transaction>> for Transaction {
let fields = other
.deserialize_into::<op_alloy_rpc_types::OptimismTransactionFields>()
.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()))?,
Expand Down
10 changes: 0 additions & 10 deletions crates/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions crates/primitives/src/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions crates/primitives/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))]
Expand Down

0 comments on commit 7fbe19a

Please sign in to comment.