diff --git a/Cargo.lock b/Cargo.lock index cd34b08f5..35301d322 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6173,6 +6173,7 @@ dependencies = [ name = "reth" version = "1.0.7" dependencies = [ + "alloy-consensus", "alloy-rlp", "alloy-rpc-types", "aquamarine", @@ -6379,6 +6380,7 @@ dependencies = [ name = "reth-blockchain-tree" version = "1.0.7" dependencies = [ + "alloy-consensus", "alloy-genesis", "alloy-primitives", "aquamarine", @@ -6427,6 +6429,7 @@ dependencies = [ name = "reth-chain-state" version = "1.0.7" dependencies = [ + "alloy-consensus", "alloy-eips", "alloy-primitives", "alloy-signer", @@ -6632,6 +6635,7 @@ dependencies = [ name = "reth-consensus-common" version = "1.0.7" dependencies = [ + "alloy-consensus", "alloy-primitives", "mockall", "rand 0.8.5", @@ -7157,6 +7161,7 @@ name = "reth-eth-wire-types" version = "1.0.7" dependencies = [ "alloy-chains", + "alloy-consensus", "alloy-eips", "alloy-genesis", "alloy-primitives", @@ -7297,6 +7302,7 @@ dependencies = [ name = "reth-evm-ethereum" version = "1.0.7" dependencies = [ + "alloy-consensus", "alloy-eips", "alloy-genesis", "alloy-primitives", @@ -7319,6 +7325,7 @@ dependencies = [ name = "reth-evm-optimism" version = "1.0.7" dependencies = [ + "alloy-consensus", "alloy-genesis", "alloy-primitives", "reth-chainspec", @@ -7371,6 +7378,7 @@ dependencies = [ name = "reth-exex" version = "1.0.7" dependencies = [ + "alloy-consensus", "alloy-genesis", "alloy-primitives", "eyre", @@ -7580,6 +7588,7 @@ dependencies = [ name = "reth-network" version = "1.0.7" dependencies = [ + "alloy-consensus", "alloy-eips", "alloy-node-bindings", "alloy-primitives", @@ -8291,6 +8300,7 @@ dependencies = [ name = "reth-provider" version = "1.0.7" dependencies = [ + "alloy-consensus", "alloy-eips", "alloy-primitives", "alloy-rpc-types-engine", @@ -8918,6 +8928,7 @@ dependencies = [ name = "reth-testing-utils" version = "1.0.7" dependencies = [ + "alloy-consensus", "alloy-eips", "alloy-genesis", "alloy-primitives", @@ -8953,6 +8964,7 @@ dependencies = [ name = "reth-transaction-pool" version = "1.0.7" dependencies = [ + "alloy-consensus", "alloy-eips", "alloy-primitives", "alloy-rlp", diff --git a/bin/reth/Cargo.toml b/bin/reth/Cargo.toml index a78f0f958..19d7d18f1 100644 --- a/bin/reth/Cargo.toml +++ b/bin/reth/Cargo.toml @@ -68,6 +68,7 @@ reth-prune.workspace = true # crypto alloy-rlp.workspace = true alloy-rpc-types = { workspace = true, features = ["engine"] } +alloy-consensus.workspace = true # tracing tracing.workspace = true diff --git a/bin/reth/src/commands/debug_cmd/build_block.rs b/bin/reth/src/commands/debug_cmd/build_block.rs index ab613dad6..a8589a74e 100644 --- a/bin/reth/src/commands/debug_cmd/build_block.rs +++ b/bin/reth/src/commands/debug_cmd/build_block.rs @@ -1,4 +1,5 @@ //! Command for debugging block building. +use alloy_consensus::TxEip4844; use alloy_rlp::Decodable; use alloy_rpc_types::engine::{BlobsBundleV1, PayloadAttributes}; use clap::Parser; @@ -25,7 +26,7 @@ use reth_payload_builder::database::CachedReads; use reth_primitives::{ revm_primitives::KzgSettings, Address, BlobTransaction, BlobTransactionSidecar, Bytes, PooledTransactionsElement, SealedBlock, SealedBlockWithSenders, Transaction, TransactionSigned, - TxEip4844, B256, U256, + B256, U256, }; use reth_provider::{ providers::BlockchainProvider, BlockHashReader, BlockReader, BlockWriter, ChainSpecProvider, diff --git a/crates/blockchain-tree/Cargo.toml b/crates/blockchain-tree/Cargo.toml index 6cf22f1c8..bc7b340ba 100644 --- a/crates/blockchain-tree/Cargo.toml +++ b/crates/blockchain-tree/Cargo.toml @@ -59,6 +59,7 @@ reth-evm-ethereum.workspace = true parking_lot.workspace = true assert_matches.workspace = true alloy-genesis.workspace = true +alloy-consensus.workspace = true [features] test-utils = [] diff --git a/crates/blockchain-tree/src/blockchain_tree.rs b/crates/blockchain-tree/src/blockchain_tree.rs index ed702bff1..4efbc740d 100644 --- a/crates/blockchain-tree/src/blockchain_tree.rs +++ b/crates/blockchain-tree/src/blockchain_tree.rs @@ -1375,6 +1375,7 @@ where #[cfg(test)] mod tests { use super::*; + use alloy_consensus::TxEip1559; use alloy_genesis::{Genesis, GenesisAccount}; use alloy_primitives::{keccak256, Address, Sealable, B256}; use assert_matches::assert_matches; @@ -1390,7 +1391,7 @@ mod tests { proofs::{calculate_receipt_root, calculate_transaction_root}, revm_primitives::AccountInfo, Account, BlockBody, Header, Signature, Transaction, TransactionSigned, - TransactionSignedEcRecovered, TxEip1559, Withdrawals, + TransactionSignedEcRecovered, Withdrawals, }; use reth_provider::{ test_utils::{ diff --git a/crates/chain-state/Cargo.toml b/crates/chain-state/Cargo.toml index 91f68b761..63016918c 100644 --- a/crates/chain-state/Cargo.toml +++ b/crates/chain-state/Cargo.toml @@ -42,12 +42,14 @@ pin-project.workspace = true # optional deps for test-utils alloy-signer = { workspace = true, optional = true } alloy-signer-local = { workspace = true, optional = true } +alloy-consensus = { workspace = true, optional = true } rand = { workspace = true, optional = true } revm = { workspace = true, optional = true } [dev-dependencies] alloy-signer.workspace = true alloy-signer-local.workspace = true +alloy-consensus.workspace = true rand.workspace = true revm.workspace = true @@ -55,6 +57,7 @@ revm.workspace = true test-utils = [ "alloy-signer", "alloy-signer-local", + "alloy-consensus", "rand", "revm" ] diff --git a/crates/chain-state/src/test_utils.rs b/crates/chain-state/src/test_utils.rs index 6fa072f82..f2446eb15 100644 --- a/crates/chain-state/src/test_utils.rs +++ b/crates/chain-state/src/test_utils.rs @@ -2,6 +2,7 @@ use crate::{ in_memory::ExecutedBlock, CanonStateNotification, CanonStateNotifications, CanonStateSubscriptions, }; +use alloy_consensus::TxEip1559; use alloy_primitives::{Address, BlockNumber, B256, U256}; use alloy_signer::SignerSync; use alloy_signer_local::PrivateKeySigner; @@ -13,7 +14,7 @@ use reth_primitives::{ constants::{EIP1559_INITIAL_BASE_FEE, EMPTY_ROOT_HASH}, proofs::{calculate_receipt_root, calculate_transaction_root, calculate_withdrawals_root}, BlockBody, Header, Receipt, Receipts, Requests, SealedBlock, SealedBlockWithSenders, - SealedHeader, Transaction, TransactionSigned, TransactionSignedEcRecovered, TxEip1559, + SealedHeader, Transaction, TransactionSigned, TransactionSignedEcRecovered, }; use reth_trie::{root::state_root_unhashed, updates::TrieUpdates, HashedPostState}; use revm::{db::BundleState, primitives::AccountInfo}; diff --git a/crates/consensus/common/Cargo.toml b/crates/consensus/common/Cargo.toml index c9fea9789..df037fa32 100644 --- a/crates/consensus/common/Cargo.toml +++ b/crates/consensus/common/Cargo.toml @@ -24,3 +24,5 @@ revm-primitives.workspace = true reth-storage-api.workspace = true rand.workspace = true mockall = "0.12" + +alloy-consensus.workspace = true diff --git a/crates/consensus/common/src/validation.rs b/crates/consensus/common/src/validation.rs index 66a953a50..da2fe9406 100644 --- a/crates/consensus/common/src/validation.rs +++ b/crates/consensus/common/src/validation.rs @@ -302,6 +302,7 @@ pub fn validate_against_parent_4844( #[cfg(test)] mod tests { use super::*; + use alloy_consensus::TxEip4844; use alloy_primitives::{ hex_literal::hex, Address, BlockHash, BlockNumber, Bytes, Parity, Sealable, U256, }; @@ -310,7 +311,7 @@ mod tests { use reth_chainspec::ChainSpecBuilder; use reth_primitives::{ proofs, Account, BlockBody, BlockHashOrNumber, Signature, Transaction, TransactionSigned, - TxEip4844, Withdrawal, Withdrawals, + Withdrawal, Withdrawals, }; use reth_storage_api::{ errors::provider::ProviderResult, AccountReader, HeaderProvider, WithdrawalsProvider, diff --git a/crates/ethereum/evm/Cargo.toml b/crates/ethereum/evm/Cargo.toml index 8a8e23a4c..61ce0a23b 100644 --- a/crates/ethereum/evm/Cargo.toml +++ b/crates/ethereum/evm/Cargo.toml @@ -36,6 +36,7 @@ reth-primitives = { workspace = true, features = ["secp256k1"] } secp256k1.workspace = true serde_json.workspace = true alloy-genesis.workspace = true +alloy-consensus.workspace = true [features] default = ["std"] diff --git a/crates/ethereum/evm/src/execute.rs b/crates/ethereum/evm/src/execute.rs index 3e574147f..7af3f2e1d 100644 --- a/crates/ethereum/evm/src/execute.rs +++ b/crates/ethereum/evm/src/execute.rs @@ -472,6 +472,7 @@ where #[cfg(test)] mod tests { use super::*; + use alloy_consensus::TxLegacy; use alloy_eips::{ eip2935::{HISTORY_STORAGE_ADDRESS, HISTORY_STORAGE_CODE}, eip4788::{BEACON_ROOTS_ADDRESS, BEACON_ROOTS_CODE, SYSTEM_ADDRESS}, @@ -481,7 +482,7 @@ mod tests { use reth_chainspec::{ChainSpecBuilder, ForkCondition}; use reth_primitives::{ constants::{EMPTY_ROOT_HASH, ETH_TO_WEI}, - public_key_to_address, Account, Block, BlockBody, Transaction, TxLegacy, + public_key_to_address, Account, Block, BlockBody, Transaction, }; use reth_revm::{ database::StateProviderDatabase, test_utils::StateProviderTest, TransitionState, diff --git a/crates/exex/exex/Cargo.toml b/crates/exex/exex/Cargo.toml index 74f62904a..cbb221419 100644 --- a/crates/exex/exex/Cargo.toml +++ b/crates/exex/exex/Cargo.toml @@ -57,6 +57,7 @@ reth-provider = { workspace = true, features = ["test-utils"] } reth-testing-utils.workspace = true alloy-genesis.workspace = true +alloy-consensus.workspace = true secp256k1.workspace = true tempfile.workspace = true diff --git a/crates/exex/exex/src/backfill/test_utils.rs b/crates/exex/exex/src/backfill/test_utils.rs index 8fd6071e8..5969261a4 100644 --- a/crates/exex/exex/src/backfill/test_utils.rs +++ b/crates/exex/exex/src/backfill/test_utils.rs @@ -1,5 +1,6 @@ use std::sync::Arc; +use alloy_consensus::TxEip2930; use alloy_genesis::{Genesis, GenesisAccount}; use alloy_primitives::{b256, Address, TxKind, U256}; use eyre::OptionExt; @@ -10,7 +11,7 @@ use reth_evm::execute::{ use reth_evm_ethereum::execute::EthExecutorProvider; use reth_primitives::{ constants::ETH_TO_WEI, Block, BlockBody, BlockWithSenders, Header, Receipt, Requests, - SealedBlockWithSenders, Transaction, TxEip2930, + SealedBlockWithSenders, Transaction, }; use reth_provider::{ providers::ProviderNodeTypes, BlockWriter as _, ExecutionOutcome, LatestStateProviderRef, diff --git a/crates/net/eth-wire-types/Cargo.toml b/crates/net/eth-wire-types/Cargo.toml index 1452a683b..6ce51786f 100644 --- a/crates/net/eth-wire-types/Cargo.toml +++ b/crates/net/eth-wire-types/Cargo.toml @@ -41,6 +41,7 @@ arbitrary = { workspace = true, features = ["derive"] } proptest.workspace = true proptest-arbitrary-interop.workspace = true rand.workspace = true +alloy-consensus.workspace = true [features] arbitrary = [ diff --git a/crates/net/eth-wire-types/src/blocks.rs b/crates/net/eth-wire-types/src/blocks.rs index 2eb338522..7cea39a27 100644 --- a/crates/net/eth-wire-types/src/blocks.rs +++ b/crates/net/eth-wire-types/src/blocks.rs @@ -112,11 +112,12 @@ mod tests { message::RequestPair, BlockBodies, BlockHeaders, GetBlockBodies, GetBlockHeaders, HeadersDirection, }; + use alloy_consensus::TxLegacy; use alloy_primitives::{hex, TxKind, U256}; use alloy_rlp::{Decodable, Encodable}; use reth_primitives::{ alloy_primitives::Parity, BlockHashOrNumber, Header, Signature, Transaction, - TransactionSigned, TxLegacy, + TransactionSigned, }; use std::str::FromStr; diff --git a/crates/net/eth-wire-types/src/transactions.rs b/crates/net/eth-wire-types/src/transactions.rs index d750931ce..ae3975d1b 100644 --- a/crates/net/eth-wire-types/src/transactions.rs +++ b/crates/net/eth-wire-types/src/transactions.rs @@ -77,12 +77,13 @@ impl FromIterator for PooledTransactions { #[cfg(test)] mod tests { use crate::{message::RequestPair, GetPooledTransactions, PooledTransactions}; + use alloy_consensus::{TxEip1559, TxLegacy}; use alloy_primitives::{hex, TxKind, U256}; use alloy_rlp::{Decodable, Encodable}; use reth_chainspec::MIN_TRANSACTION_GAS; use reth_primitives::{ alloy_primitives::Parity, PooledTransactionsElement, Signature, Transaction, - TransactionSigned, TxEip1559, TxLegacy, + TransactionSigned, }; use std::str::FromStr; diff --git a/crates/net/network/Cargo.toml b/crates/net/network/Cargo.toml index 23407678d..1d3af517a 100644 --- a/crates/net/network/Cargo.toml +++ b/crates/net/network/Cargo.toml @@ -87,6 +87,7 @@ reth-transaction-pool = { workspace = true, features = ["test-utils"] } # alloy deps for testing against nodes alloy-node-bindings.workspace = true alloy-provider= { workspace = true, features = ["admin-api"] } +alloy-consensus.workspace = true # misc serial_test.workspace = true diff --git a/crates/net/network/tests/it/requests.rs b/crates/net/network/tests/it/requests.rs index 5c32ce46f..42802046d 100644 --- a/crates/net/network/tests/it/requests.rs +++ b/crates/net/network/tests/it/requests.rs @@ -3,6 +3,7 @@ use std::sync::Arc; +use alloy_consensus::TxEip2930; use alloy_primitives::{Bytes, TxKind, U256}; use rand::Rng; use reth_eth_wire::HeadersDirection; @@ -16,7 +17,7 @@ use reth_network_p2p::{ headers::client::{HeadersClient, HeadersRequest}, }; use reth_primitives::{ - alloy_primitives::Parity, Block, Header, Signature, Transaction, TransactionSigned, TxEip2930, + alloy_primitives::Parity, Block, Header, Signature, Transaction, TransactionSigned, }; use reth_provider::test_utils::MockEthProvider; diff --git a/crates/net/network/tests/it/txgossip.rs b/crates/net/network/tests/it/txgossip.rs index 56b71e45a..70ac67bb5 100644 --- a/crates/net/network/tests/it/txgossip.rs +++ b/crates/net/network/tests/it/txgossip.rs @@ -2,12 +2,13 @@ use std::sync::Arc; +use alloy_consensus::TxLegacy; use alloy_primitives::U256; use futures::StreamExt; use rand::thread_rng; use reth_network::{test_utils::Testnet, NetworkEvent, NetworkEventListenerProvider}; use reth_network_api::PeersInfo; -use reth_primitives::{Signature, TransactionSigned, TxLegacy}; +use reth_primitives::{Signature, TransactionSigned}; use reth_provider::test_utils::{ExtendedAccount, MockEthProvider}; use reth_transaction_pool::{test_utils::TransactionGenerator, PoolTransaction, TransactionPool}; diff --git a/crates/optimism/evm/Cargo.toml b/crates/optimism/evm/Cargo.toml index 567e8c002..b0b66cd42 100644 --- a/crates/optimism/evm/Cargo.toml +++ b/crates/optimism/evm/Cargo.toml @@ -41,6 +41,7 @@ tracing.workspace = true reth-revm = { workspace = true, features = ["test-utils"] } reth-optimism-chainspec.workspace = true alloy-genesis.workspace = true +alloy-consensus.workspace = true [features] optimism = [ diff --git a/crates/optimism/evm/src/execute.rs b/crates/optimism/evm/src/execute.rs index ceae0314f..d502abe6a 100644 --- a/crates/optimism/evm/src/execute.rs +++ b/crates/optimism/evm/src/execute.rs @@ -464,12 +464,12 @@ where mod tests { use super::*; use crate::OpChainSpec; + 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, TxEip1559, - BASE_MAINNET, + Account, Block, BlockBody, Signature, Transaction, TransactionSigned, BASE_MAINNET, }; use reth_revm::{ database::StateProviderDatabase, test_utils::StateProviderTest, L1_BLOCK_CONTRACT, diff --git a/crates/primitives/benches/validate_blob_tx.rs b/crates/primitives/benches/validate_blob_tx.rs index 622168bb3..61fe161f2 100644 --- a/crates/primitives/benches/validate_blob_tx.rs +++ b/crates/primitives/benches/validate_blob_tx.rs @@ -1,5 +1,6 @@ #![allow(missing_docs)] +use alloy_consensus::TxEip4844; use alloy_eips::eip4844::env_settings::EnvKzgSettings; use alloy_primitives::hex; use criterion::{ @@ -11,7 +12,7 @@ use proptest::{ test_runner::{RngAlgorithm, TestRng, TestRunner}, }; use proptest_arbitrary_interop::arb; -use reth_primitives::{BlobTransactionSidecar, TxEip4844}; +use reth_primitives::BlobTransactionSidecar; use revm_primitives::MAX_BLOB_NUMBER_PER_BLOCK; // constant seed to use for the rng diff --git a/crates/primitives/src/alloy_compat.rs b/crates/primitives/src/alloy_compat.rs index 8f8ec1b39..867aceece 100644 --- a/crates/primitives/src/alloy_compat.rs +++ b/crates/primitives/src/alloy_compat.rs @@ -2,10 +2,10 @@ use crate::{ constants::EMPTY_TRANSACTIONS, transaction::extract_chain_id, Block, BlockBody, Signature, - Transaction, TransactionSigned, TransactionSignedEcRecovered, TransactionSignedNoHash, - TxEip1559, TxEip2930, TxEip4844, TxLegacy, TxType, + Transaction, TransactionSigned, TransactionSignedEcRecovered, TransactionSignedNoHash, TxType, }; use alloc::{string::ToString, vec::Vec}; +use alloy_consensus::{TxEip1559, TxEip2930, TxEip4844, TxLegacy}; use alloy_primitives::{Parity, TxKind}; use alloy_rlp::Error as RlpError; use alloy_serde::WithOtherFields; diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index 6aadae208..cdcf642c0 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -63,9 +63,9 @@ pub use transaction::BlobTransactionValidationError; pub use transaction::{ util::secp256k1::{public_key_to_address, recover_signer_unchecked, sign_message}, IntoRecoveredTransaction, InvalidTransactionError, Signature, Transaction, TransactionMeta, - TransactionSigned, TransactionSignedEcRecovered, TransactionSignedNoHash, TxEip1559, TxEip2930, - TxEip4844, TxEip7702, TxHashOrNumber, TxLegacy, TxType, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, - EIP4844_TX_TYPE_ID, EIP7702_TX_TYPE_ID, LEGACY_TX_TYPE_ID, + TransactionSigned, TransactionSignedEcRecovered, TransactionSignedNoHash, TxHashOrNumber, + TxType, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID, EIP7702_TX_TYPE_ID, + LEGACY_TX_TYPE_ID, }; // Re-exports diff --git a/crates/primitives/src/transaction/mod.rs b/crates/primitives/src/transaction/mod.rs index 01c290a0f..f1dae00fe 100644 --- a/crates/primitives/src/transaction/mod.rs +++ b/crates/primitives/src/transaction/mod.rs @@ -4,7 +4,7 @@ use crate::{keccak256, Address, BlockHashOrNumber, Bytes, TxHash, B256, U256}; use alloy_eips::eip7702::SignedAuthorization; use alloy_primitives::TxKind; -use alloy_consensus::SignableTransaction; +use alloy_consensus::{SignableTransaction, TxEip1559, TxEip2930, TxEip4844, TxEip7702, TxLegacy}; use alloy_eips::eip2930::AccessList; use alloy_primitives::Parity; use alloy_rlp::{ @@ -18,8 +18,6 @@ use rayon::prelude::{IntoParallelIterator, ParallelIterator}; use serde::{Deserialize, Serialize}; use signature::{decode_with_eip155_chain_id, with_eip155_parity}; -pub use alloy_consensus::{TxEip1559, TxEip2930, TxEip4844, TxEip7702, TxLegacy}; - pub use error::{ InvalidTransactionError, TransactionConversionError, TryFromRecoveredTransactionError, }; diff --git a/crates/primitives/src/transaction/pooled.rs b/crates/primitives/src/transaction/pooled.rs index 0a068d8c4..78ad75692 100644 --- a/crates/primitives/src/transaction/pooled.rs +++ b/crates/primitives/src/transaction/pooled.rs @@ -8,11 +8,13 @@ use super::{ }; use crate::{ Address, BlobTransaction, BlobTransactionSidecar, Bytes, Signature, Transaction, - TransactionSigned, TransactionSignedEcRecovered, TxEip1559, TxEip2930, TxEip4844, TxHash, - TxLegacy, B256, EIP4844_TX_TYPE_ID, + TransactionSigned, TransactionSignedEcRecovered, TxHash, B256, EIP4844_TX_TYPE_ID, }; use alloc::vec::Vec; -use alloy_consensus::{SignableTransaction, TxEip4844WithSidecar}; +use alloy_consensus::{ + transaction::{TxEip1559, TxEip2930, TxEip4844, TxLegacy}, + SignableTransaction, TxEip4844WithSidecar, +}; use alloy_rlp::{Decodable, Encodable, Error as RlpError, Header, EMPTY_LIST_CODE}; use bytes::Buf; use derive_more::{AsRef, Deref}; diff --git a/crates/primitives/src/transaction/sidecar.rs b/crates/primitives/src/transaction/sidecar.rs index c0242acf9..e486fa670 100644 --- a/crates/primitives/src/transaction/sidecar.rs +++ b/crates/primitives/src/transaction/sidecar.rs @@ -1,9 +1,7 @@ #![cfg_attr(docsrs, doc(cfg(feature = "c-kzg")))] -use crate::{ - keccak256, Signature, Transaction, TransactionSigned, TxEip4844, TxHash, EIP4844_TX_TYPE_ID, -}; -use alloy_consensus::TxEip4844WithSidecar; +use crate::{keccak256, Signature, Transaction, TransactionSigned, TxHash, EIP4844_TX_TYPE_ID}; +use alloy_consensus::{transaction::TxEip4844, TxEip4844WithSidecar}; use alloy_rlp::{Decodable, Error as RlpError, Header}; use serde::{Deserialize, Serialize}; diff --git a/crates/primitives/src/transaction/tx_type.rs b/crates/primitives/src/transaction/tx_type.rs index c4ddbb41c..7331ba1ed 100644 --- a/crates/primitives/src/transaction/tx_type.rs +++ b/crates/primitives/src/transaction/tx_type.rs @@ -23,23 +23,23 @@ pub(crate) const COMPACT_IDENTIFIER_EIP1559: usize = 2; #[cfg(any(test, feature = "reth-codec"))] pub(crate) const COMPACT_EXTENDED_IDENTIFIER_FLAG: usize = 3; -/// Identifier for legacy transaction, however [`TxLegacy`](crate::TxLegacy) this is technically not -/// typed. +/// Identifier for legacy transaction, however [`TxLegacy`](alloy_consensus::TxLegacy) this is +/// technically not typed. pub const LEGACY_TX_TYPE_ID: u8 = 0; -/// Identifier for [`TxEip2930`](crate::TxEip2930) transaction. +/// Identifier for [`TxEip2930`](alloy_consensus::TxEip2930) transaction. pub const EIP2930_TX_TYPE_ID: u8 = 1; -/// Identifier for [`TxEip1559`](crate::TxEip1559) transaction. +/// Identifier for [`TxEip1559`](alloy_consensus::TxEip1559) transaction. pub const EIP1559_TX_TYPE_ID: u8 = 2; -/// Identifier for [`TxEip4844`](crate::TxEip4844) transaction. +/// Identifier for [`TxEip4844`](alloy_consensus::TxEip4844) transaction. pub const EIP4844_TX_TYPE_ID: u8 = 3; -/// Identifier for [`TxEip7702`](crate::TxEip7702) transaction. +/// Identifier for [`TxEip7702`](alloy_consensus::TxEip7702) transaction. pub const EIP7702_TX_TYPE_ID: u8 = 4; -/// Identifier for [`TxDeposit`](crate::TxDeposit) transaction. +/// Identifier for [`TxDeposit`](op_alloy_consensus::TxDeposit) transaction. #[cfg(feature = "optimism")] pub const DEPOSIT_TX_TYPE_ID: u8 = 126; diff --git a/crates/rpc/rpc/Cargo.toml b/crates/rpc/rpc/Cargo.toml index 49a1e512e..9593efd4b 100644 --- a/crates/rpc/rpc/Cargo.toml +++ b/crates/rpc/rpc/Cargo.toml @@ -90,6 +90,8 @@ reth-testing-utils.workspace = true reth-transaction-pool = { workspace = true, features = ["test-utils"] } reth-provider = { workspace = true, features = ["test-utils"] } +alloy-consensus.workspace = true + jsonrpsee-types.workspace = true jsonrpsee = { workspace = true, features = ["client"] } diff --git a/crates/rpc/rpc/src/eth/core.rs b/crates/rpc/rpc/src/eth/core.rs index 6b258cac4..47d58c7b0 100644 --- a/crates/rpc/rpc/src/eth/core.rs +++ b/crates/rpc/rpc/src/eth/core.rs @@ -471,7 +471,7 @@ mod tests { if let Some(base_fee_per_gas) = header.base_fee_per_gas { let transaction = TransactionSigned { transaction: reth_primitives::Transaction::Eip1559( - reth_primitives::TxEip1559 { + alloy_consensus::TxEip1559 { max_priority_fee_per_gas: random_fee, max_fee_per_gas: random_fee + base_fee_per_gas, ..Default::default() diff --git a/crates/storage/codecs/src/alloy/transaction/eip1559.rs b/crates/storage/codecs/src/alloy/transaction/eip1559.rs index a08894925..d2113a736 100644 --- a/crates/storage/codecs/src/alloy/transaction/eip1559.rs +++ b/crates/storage/codecs/src/alloy/transaction/eip1559.rs @@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize}; /// By deriving `Compact` here, any future changes or enhancements to the `Compact` derive /// will automatically apply to this type. /// -/// Notice: Make sure this struct is 1:1 with [`alloy_consensus::transaction::TxEip1559`] +/// Notice: Make sure this struct is 1:1 with [`alloy_consensus::TxEip1559`] #[derive(Debug, Clone, PartialEq, Eq, Hash, Compact, Default, Serialize, Deserialize)] #[cfg_attr(test, derive(arbitrary::Arbitrary))] #[cfg_attr(test, crate::add_arbitrary_tests(compact))] diff --git a/crates/storage/codecs/src/alloy/transaction/eip2930.rs b/crates/storage/codecs/src/alloy/transaction/eip2930.rs index 33b58dfff..b8f24db74 100644 --- a/crates/storage/codecs/src/alloy/transaction/eip2930.rs +++ b/crates/storage/codecs/src/alloy/transaction/eip2930.rs @@ -1,5 +1,5 @@ use crate::Compact; -use alloy_consensus::transaction::TxEip2930 as AlloyTxEip2930; +use alloy_consensus::TxEip2930 as AlloyTxEip2930; use alloy_eips::eip2930::AccessList; use alloy_primitives::{Bytes, ChainId, TxKind, U256}; use reth_codecs_derive::add_arbitrary_tests; @@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize}; /// By deriving `Compact` here, any future changes or enhancements to the `Compact` derive /// will automatically apply to this type. /// -/// Notice: Make sure this struct is 1:1 with [`alloy_consensus::transaction::TxEip2930`] +/// Notice: Make sure this struct is 1:1 with [`alloy_consensus::TxEip2930`] #[derive(Debug, Clone, PartialEq, Eq, Hash, Default, Serialize, Deserialize, Compact)] #[cfg_attr(test, derive(arbitrary::Arbitrary))] #[add_arbitrary_tests(compact)] diff --git a/crates/storage/codecs/src/alloy/transaction/eip4844.rs b/crates/storage/codecs/src/alloy/transaction/eip4844.rs index 15a5f443c..e82b9afff 100644 --- a/crates/storage/codecs/src/alloy/transaction/eip4844.rs +++ b/crates/storage/codecs/src/alloy/transaction/eip4844.rs @@ -1,6 +1,6 @@ use crate::{Compact, CompactPlaceholder}; use alloc::vec::Vec; -use alloy_consensus::transaction::TxEip4844 as AlloyTxEip4844; +use alloy_consensus::TxEip4844 as AlloyTxEip4844; use alloy_eips::eip2930::AccessList; use alloy_primitives::{Address, Bytes, ChainId, B256, U256}; use reth_codecs_derive::add_arbitrary_tests; @@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize}; /// By deriving `Compact` here, any future changes or enhancements to the `Compact` derive /// will automatically apply to this type. /// -/// Notice: Make sure this struct is 1:1 with [`alloy_consensus::transaction::TxEip4844`] +/// Notice: Make sure this struct is 1:1 with [`alloy_consensus::TxEip4844`] #[derive(Debug, Clone, PartialEq, Eq, Hash, Default, Serialize, Deserialize, Compact)] #[cfg_attr(test, derive(arbitrary::Arbitrary))] #[add_arbitrary_tests(compact)] diff --git a/crates/storage/codecs/src/alloy/transaction/eip7702.rs b/crates/storage/codecs/src/alloy/transaction/eip7702.rs index a44e97ee1..5f34ac1c2 100644 --- a/crates/storage/codecs/src/alloy/transaction/eip7702.rs +++ b/crates/storage/codecs/src/alloy/transaction/eip7702.rs @@ -1,6 +1,6 @@ use crate::Compact; use alloc::vec::Vec; -use alloy_consensus::transaction::TxEip7702 as AlloyTxEip7702; +use alloy_consensus::TxEip7702 as AlloyTxEip7702; use alloy_eips::{eip2930::AccessList, eip7702::SignedAuthorization}; use alloy_primitives::{Address, Bytes, ChainId, U256}; use reth_codecs_derive::add_arbitrary_tests; @@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize}; /// By deriving `Compact` here, any future changes or enhancements to the `Compact` derive /// will automatically apply to this type. /// -/// Notice: Make sure this struct is 1:1 with [`alloy_consensus::transaction::TxEip7702`] +/// Notice: Make sure this struct is 1:1 with [`alloy_consensus::TxEip7702`] #[derive(Debug, Clone, PartialEq, Eq, Hash, Default, Serialize, Deserialize, Compact)] #[cfg_attr(test, derive(arbitrary::Arbitrary))] #[add_arbitrary_tests(compact)] diff --git a/crates/storage/provider/Cargo.toml b/crates/storage/provider/Cargo.toml index 7524fde6a..048353452 100644 --- a/crates/storage/provider/Cargo.toml +++ b/crates/storage/provider/Cargo.toml @@ -64,6 +64,7 @@ strum.workspace = true # test-utils once_cell = { workspace = true, optional = true } reth-ethereum-engine-primitives = { workspace = true, optional = true } +alloy-consensus = { workspace = true, optional = true } # parallel utils rayon.workspace = true @@ -81,6 +82,8 @@ rand.workspace = true once_cell.workspace = true eyre.workspace = true +alloy-consensus.workspace = true + [features] optimism = ["reth-primitives/optimism", "reth-execution-types/optimism", "reth-optimism-primitives"] serde = ["reth-execution-types/serde"] @@ -91,4 +94,5 @@ test-utils = [ "reth-chain-state/test-utils", "once_cell", "reth-ethereum-engine-primitives", + "alloy-consensus", ] diff --git a/crates/storage/provider/src/test_utils/blocks.rs b/crates/storage/provider/src/test_utils/blocks.rs index 237fc8e34..352f5314a 100644 --- a/crates/storage/provider/src/test_utils/blocks.rs +++ b/crates/storage/provider/src/test_utils/blocks.rs @@ -1,5 +1,6 @@ //! Dummy blocks and data for tests use crate::{DatabaseProviderRW, ExecutionOutcome}; +use alloy_consensus::TxLegacy; use alloy_primitives::{Log, Parity, Sealable, TxKind}; use once_cell::sync::Lazy; use reth_db::tables; @@ -7,7 +8,7 @@ use reth_db_api::{database::Database, models::StoredBlockBodyIndices}; use reth_primitives::{ alloy_primitives, b256, hex_literal::hex, Account, Address, BlockBody, BlockNumber, Bytes, Header, Receipt, SealedBlock, SealedBlockWithSenders, SealedHeader, Signature, Transaction, - TransactionSigned, TxLegacy, TxType, Withdrawal, Withdrawals, B256, U256, + TransactionSigned, TxType, Withdrawal, Withdrawals, B256, U256, }; use reth_trie::root::{state_root_unhashed, storage_root_unhashed}; use revm::{ diff --git a/crates/transaction-pool/Cargo.toml b/crates/transaction-pool/Cargo.toml index a0720c037..41abbb4b6 100644 --- a/crates/transaction-pool/Cargo.toml +++ b/crates/transaction-pool/Cargo.toml @@ -54,6 +54,7 @@ rand = { workspace = true, optional = true } paste = { workspace = true, optional = true } proptest = { workspace = true, optional = true } proptest-arbitrary-interop = { workspace = true, optional = true } +alloy-consensus = { workspace = true, optional = true } [dev-dependencies] reth-primitives = { workspace = true, features = ["arbitrary"] } @@ -68,11 +69,12 @@ pprof = { workspace = true, features = ["criterion", "flamegraph"] } assert_matches.workspace = true tempfile.workspace = true serde_json.workspace = true +alloy-consensus.workspace = true [features] default = ["serde"] serde = ["dep:serde"] -test-utils = ["rand", "paste", "serde"] +test-utils = ["rand", "paste", "serde", "alloy-consensus"] arbitrary = ["proptest", "reth-primitives/arbitrary", "proptest-arbitrary-interop"] [[bench]] diff --git a/crates/transaction-pool/src/test_utils/gen.rs b/crates/transaction-pool/src/test_utils/gen.rs index f87083f16..e5fceb915 100644 --- a/crates/transaction-pool/src/test_utils/gen.rs +++ b/crates/transaction-pool/src/test_utils/gen.rs @@ -1,11 +1,11 @@ use crate::EthPooledTransaction; +use alloy_consensus::{TxEip1559, TxEip4844, TxLegacy}; use alloy_eips::eip2930::AccessList; use alloy_primitives::{Address, TxKind, B256, U256}; use rand::Rng; use reth_chainspec::MAINNET; use reth_primitives::{ constants::MIN_PROTOCOL_BASE_FEE, sign_message, Bytes, Transaction, TransactionSigned, - TxEip1559, TxEip4844, TxLegacy, }; /// A generator for transactions for testing purposes. diff --git a/crates/transaction-pool/src/test_utils/mock.rs b/crates/transaction-pool/src/test_utils/mock.rs index 604f4ffef..eb05a5272 100644 --- a/crates/transaction-pool/src/test_utils/mock.rs +++ b/crates/transaction-pool/src/test_utils/mock.rs @@ -7,6 +7,7 @@ use crate::{ CoinbaseTipOrdering, EthBlobTransactionSidecar, EthPoolTransaction, PoolTransaction, ValidPoolTransaction, }; +use alloy_consensus::{TxEip1559, TxEip2930, TxEip4844, TxLegacy}; use alloy_eips::eip2930::AccessList; use alloy_primitives::{Address, Bytes, ChainId, TxHash, TxKind, B256, U256}; use paste::paste; @@ -18,9 +19,8 @@ use reth_primitives::{ constants::{eip4844::DATA_GAS_PER_BLOB, MIN_PROTOCOL_BASE_FEE}, transaction::TryFromRecoveredTransactionError, BlobTransactionSidecar, BlobTransactionValidationError, PooledTransactionsElementEcRecovered, - Signature, Transaction, TransactionSigned, TransactionSignedEcRecovered, TxEip1559, TxEip2930, - TxEip4844, TxLegacy, TxType, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID, - LEGACY_TX_TYPE_ID, + Signature, Transaction, TransactionSigned, TransactionSignedEcRecovered, TxType, + EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID, LEGACY_TX_TYPE_ID, }; use std::{ops::Range, sync::Arc, time::Instant, vec::IntoIter}; diff --git a/crates/transaction-pool/src/traits.rs b/crates/transaction-pool/src/traits.rs index cef776aab..05bc6140b 100644 --- a/crates/transaction-pool/src/traits.rs +++ b/crates/transaction-pool/src/traits.rs @@ -1392,10 +1392,8 @@ impl Stream for NewSubpoolTransactionStream { #[cfg(test)] mod tests { use super::*; - use reth_primitives::{ - constants::eip4844::DATA_GAS_PER_BLOB, Signature, TransactionSigned, TxEip1559, TxEip2930, - TxEip4844, TxEip7702, TxLegacy, - }; + use alloy_consensus::{TxEip1559, TxEip2930, TxEip4844, TxEip7702, TxLegacy}; + use reth_primitives::{constants::eip4844::DATA_GAS_PER_BLOB, Signature, TransactionSigned}; #[test] fn test_pool_size_invariants() { diff --git a/testing/testing-utils/Cargo.toml b/testing/testing-utils/Cargo.toml index af592e294..49a59ecf6 100644 --- a/testing/testing-utils/Cargo.toml +++ b/testing/testing-utils/Cargo.toml @@ -17,6 +17,7 @@ reth-primitives = { workspace = true, features = ["secp256k1"] } alloy-eips.workspace = true alloy-genesis.workspace = true alloy-primitives.workspace = true +alloy-consensus.workspace = true rand.workspace = true secp256k1 = { workspace = true, features = ["rand"] } diff --git a/testing/testing-utils/src/generators.rs b/testing/testing-utils/src/generators.rs index 46930a5dd..c1c23c998 100644 --- a/testing/testing-utils/src/generators.rs +++ b/testing/testing-utils/src/generators.rs @@ -1,5 +1,6 @@ //! Generators for different data structures like block headers, block bodies and ranges of those. +use alloy_consensus::TxLegacy; use alloy_eips::{ eip6110::DepositRequest, eip7002::WithdrawalRequest, eip7251::ConsolidationRequest, }; @@ -10,7 +11,7 @@ use rand::{ }; use reth_primitives::{ proofs, sign_message, Account, BlockBody, Header, Log, Receipt, Request, Requests, SealedBlock, - SealedHeader, StorageEntry, Transaction, TransactionSigned, TxLegacy, Withdrawal, Withdrawals, + SealedHeader, StorageEntry, Transaction, TransactionSigned, Withdrawal, Withdrawals, }; use secp256k1::{Keypair, Secp256k1}; use std::{ @@ -497,9 +498,10 @@ pub fn random_request(rng: &mut R) -> Request { #[cfg(test)] mod tests { use super::*; + use alloy_consensus::TxEip1559; use alloy_eips::eip2930::AccessList; use alloy_primitives::Parity; - use reth_primitives::{hex, public_key_to_address, Signature, TxEip1559}; + use reth_primitives::{hex, public_key_to_address, Signature}; use std::str::FromStr; #[test]