Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transaction-pool: replace reth-primitive imports #10766

Merged
merged 3 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 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/transaction-pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ revm.workspace = true

# ethereum
alloy-rlp.workspace = true
alloy-primitives.workspace = true

# async/futures
futures-util.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/transaction-pool/benches/truncate.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![allow(missing_docs)]
use alloy_primitives::{hex_literal::hex, Address};
use criterion::{
criterion_group, criterion_main, measurement::WallTime, BenchmarkGroup, Criterion,
};
Expand All @@ -8,7 +9,6 @@ use proptest::{
strategy::ValueTree,
test_runner::{RngAlgorithm, TestRng, TestRunner},
};
use reth_primitives::{hex_literal::hex, Address};
use reth_transaction_pool::{
pool::{BasefeeOrd, ParkedPool, PendingPool, QueuedOrd},
test_utils::{MockOrdering, MockTransaction, MockTransactionFactory},
Expand Down
3 changes: 2 additions & 1 deletion crates/transaction-pool/src/blobstore/disk.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
//! A simple diskstore for blobs

use crate::blobstore::{BlobStore, BlobStoreCleanupStat, BlobStoreError, BlobStoreSize};
use alloy_primitives::{TxHash, B256};
use alloy_rlp::{Decodable, Encodable};
use parking_lot::{Mutex, RwLock};
use reth_primitives::{BlobTransactionSidecar, TxHash, B256};
use reth_primitives::BlobTransactionSidecar;
use schnellru::{ByLength, LruMap};
use std::{collections::HashSet, fmt, fs, io, path::PathBuf, sync::Arc};
use tracing::{debug, trace};
Expand Down
2 changes: 1 addition & 1 deletion crates/transaction-pool/src/blobstore/mem.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::blobstore::{
BlobStore, BlobStoreCleanupStat, BlobStoreError, BlobStoreSize, BlobTransactionSidecar,
};
use alloy_primitives::B256;
use parking_lot::RwLock;
use reth_primitives::B256;
use std::{collections::HashMap, sync::Arc};

/// An in-memory blob store.
Expand Down
3 changes: 2 additions & 1 deletion crates/transaction-pool/src/blobstore/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
//! Storage for blob data of EIP4844 transactions.

use alloy_primitives::B256;
pub use disk::{DiskFileBlobStore, DiskFileBlobStoreConfig, OpenDiskFileBlobStore};
pub use mem::InMemoryBlobStore;
pub use noop::NoopBlobStore;
use reth_primitives::{BlobTransactionSidecar, B256};
use reth_primitives::BlobTransactionSidecar;
use std::{
fmt,
sync::atomic::{AtomicUsize, Ordering},
Expand Down
2 changes: 1 addition & 1 deletion crates/transaction-pool/src/blobstore/noop.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::blobstore::{BlobStore, BlobStoreCleanupStat, BlobStoreError, BlobTransactionSidecar};
use reth_primitives::B256;
use alloy_primitives::B256;

/// A blobstore implementation that does nothing
#[derive(Clone, Copy, Debug, PartialOrd, PartialEq, Eq, Default)]
Expand Down
2 changes: 1 addition & 1 deletion crates/transaction-pool/src/blobstore/tracker.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Support for maintaining the blob pool.

use alloy_primitives::{BlockNumber, B256};
use reth_execution_types::ChainBlocks;
use reth_primitives::{BlockNumber, B256};
use std::collections::BTreeMap;

/// The type that is used to track canonical blob transactions.
Expand Down
3 changes: 2 additions & 1 deletion crates/transaction-pool/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use crate::{
pool::{NEW_TX_LISTENER_BUFFER_SIZE, PENDING_TX_LISTENER_BUFFER_SIZE},
PoolSize, TransactionOrigin,
};
use reth_primitives::{Address, EIP4844_TX_TYPE_ID};
use alloy_primitives::Address;
use reth_primitives::EIP4844_TX_TYPE_ID;
use std::collections::HashSet;
/// Guarantees max transactions for one sender, compatible with geth/erigon
pub const TXPOOL_MAX_ACCOUNT_SLOTS_PER_SENDER: usize = 16;
Expand Down
5 changes: 3 additions & 2 deletions crates/transaction-pool/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Transaction pool errors

use reth_primitives::{Address, BlobTransactionValidationError, InvalidTransactionError, TxHash};
use alloy_primitives::{Address, TxHash};
use reth_primitives::{BlobTransactionValidationError, InvalidTransactionError};

/// Transaction pool result type.
pub type PoolResult<T> = Result<T, PoolError>;
Expand Down Expand Up @@ -104,7 +105,7 @@ impl PoolError {
}
PoolErrorKind::FeeCapBelowMinimumProtocolFeeCap(_) => {
// fee cap of the tx below the technical minimum determined by the protocol, see
// [MINIMUM_PROTOCOL_FEE_CAP](reth_primitives::constants::MIN_PROTOCOL_BASE_FEE)
// [MINIMUM_PROTOCOL_FEE_CAP](alloy_primitives::constants::MIN_PROTOCOL_BASE_FEE)
// although this transaction will always be invalid, we do not want to penalize the
// sender because this check simply could not be implemented by the client
false
Expand Down
2 changes: 1 addition & 1 deletion crates/transaction-pool/src/identifier.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Identifier types for transactions and senders.
use reth_primitives::Address;
use alloy_primitives::Address;
use rustc_hash::FxHashMap;
use std::collections::HashMap;

Expand Down
3 changes: 2 additions & 1 deletion crates/transaction-pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,11 @@
#![cfg_attr(not(test), warn(unused_crate_dependencies))]

use crate::{identifier::TransactionId, pool::PoolInner};
use alloy_primitives::{Address, TxHash, U256};
use aquamarine as _;
use reth_eth_wire_types::HandleMempoolData;
use reth_execution_types::ChangedAccount;
use reth_primitives::{Address, BlobTransactionSidecar, PooledTransactionsElement, TxHash, U256};
use reth_primitives::{BlobTransactionSidecar, PooledTransactionsElement};
use reth_storage_api::StateProviderFactory;
use std::{collections::HashSet, sync::Arc};
use tokio::sync::mpsc::Receiver;
Expand Down
8 changes: 5 additions & 3 deletions crates/transaction-pool/src/maintain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::{
traits::{CanonicalStateUpdate, TransactionPool, TransactionPoolExt},
BlockInfo, PoolTransaction,
};
use alloy_primitives::{Address, BlockHash, BlockNumber};
use futures_util::{
future::{BoxFuture, Fuse, FusedFuture},
FutureExt, Stream, StreamExt,
Expand All @@ -16,8 +17,8 @@ use reth_chainspec::{ChainSpec, ChainSpecProvider};
use reth_execution_types::ChangedAccount;
use reth_fs_util::FsPathError;
use reth_primitives::{
Address, BlockHash, BlockNumber, BlockNumberOrTag, IntoRecoveredTransaction,
PooledTransactionsElementEcRecovered, TransactionSigned,
BlockNumberOrTag, IntoRecoveredTransaction, PooledTransactionsElementEcRecovered,
TransactionSigned,
};
use reth_storage_api::{errors::provider::ProviderError, BlockReaderIdExt, StateProviderFactory};
use reth_tasks::TaskSpawner;
Expand Down Expand Up @@ -678,9 +679,10 @@ mod tests {
blobstore::InMemoryBlobStore, validate::EthTransactionValidatorBuilder,
CoinbaseTipOrdering, EthPooledTransaction, Pool, TransactionOrigin,
};
use alloy_primitives::{hex, U256};
use reth_chainspec::MAINNET;
use reth_fs_util as fs;
use reth_primitives::{hex, PooledTransactionsElement, U256};
use reth_primitives::PooledTransactionsElement;
use reth_provider::test_utils::{ExtendedAccount, MockEthProvider};
use reth_tasks::TaskManager;

Expand Down
3 changes: 2 additions & 1 deletion crates/transaction-pool/src/noop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ use crate::{
PooledTransactionsElement, PropagatedTransactions, TransactionEvents, TransactionOrigin,
TransactionPool, TransactionValidationOutcome, TransactionValidator, ValidPoolTransaction,
};
use alloy_primitives::{Address, TxHash, U256};
use reth_eth_wire_types::HandleMempoolData;
use reth_primitives::{Address, BlobTransactionSidecar, TxHash, U256};
use reth_primitives::BlobTransactionSidecar;
use std::{collections::HashSet, marker::PhantomData, sync::Arc};
use tokio::sync::{mpsc, mpsc::Receiver};

Expand Down
3 changes: 2 additions & 1 deletion crates/transaction-pool/src/ordering.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::traits::PoolTransaction;
use reth_primitives::{PooledTransactionsElementEcRecovered, TransactionSignedEcRecovered, U256};
use alloy_primitives::U256;
use reth_primitives::{PooledTransactionsElementEcRecovered, TransactionSignedEcRecovered};
use std::{fmt, marker::PhantomData};

/// Priority of the transaction that can be missing.
Expand Down
4 changes: 2 additions & 2 deletions crates/transaction-pool/src/pool/best.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use crate::{
identifier::TransactionId, pool::pending::PendingTransaction, PoolTransaction,
TransactionOrdering, ValidPoolTransaction,
};
use alloy_primitives::B256 as TxHash;
use core::fmt;
use reth_primitives::B256 as TxHash;
use std::{
collections::{BTreeMap, BTreeSet, HashSet},
sync::Arc,
Expand Down Expand Up @@ -268,7 +268,7 @@ mod tests {
test_utils::{MockOrdering, MockTransaction, MockTransactionFactory},
Priority,
};
use reth_primitives::U256;
use alloy_primitives::U256;

#[test]
fn test_best_iter() {
Expand Down
2 changes: 1 addition & 1 deletion crates/transaction-pool/src/pool/events.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{traits::PropagateKind, PoolTransaction, ValidPoolTransaction};
use reth_primitives::{TxHash, B256};
use alloy_primitives::{TxHash, B256};
use std::sync::Arc;

#[cfg(feature = "serde")]
Expand Down
2 changes: 1 addition & 1 deletion crates/transaction-pool/src/pool/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use crate::{
traits::PropagateKind,
PoolTransaction, ValidPoolTransaction,
};
use alloy_primitives::{TxHash, B256};
use futures_util::Stream;
use reth_primitives::{TxHash, B256};
use std::{
collections::{hash_map::Entry, HashMap},
pin::Pin,
Expand Down
6 changes: 4 additions & 2 deletions crates/transaction-pool/src/pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,15 @@ use crate::{
validate::{TransactionValidationOutcome, ValidPoolTransaction},
CanonicalStateUpdate, PoolConfig, TransactionOrdering, TransactionValidator,
};
use alloy_primitives::{Address, TxHash, B256};
use best::BestTransactions;
use parking_lot::{Mutex, RwLock, RwLockReadGuard};
use reth_eth_wire_types::HandleMempoolData;
use reth_execution_types::ChangedAccount;

use reth_primitives::{
Address, BlobTransaction, BlobTransactionSidecar, IntoRecoveredTransaction,
PooledTransactionsElement, TransactionSigned, TxHash, B256,
BlobTransaction, BlobTransactionSidecar, IntoRecoveredTransaction, PooledTransactionsElement,
TransactionSigned,
};
use std::{
collections::{HashMap, HashSet},
Expand Down
3 changes: 2 additions & 1 deletion crates/transaction-pool/src/pool/parked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,8 @@ impl<T: PoolTransaction> Ord for QueuedOrd<T> {
mod tests {
use super::*;
use crate::test_utils::{MockTransaction, MockTransactionFactory, MockTransactionSet};
use reth_primitives::{address, TxType};
use alloy_primitives::address;
use reth_primitives::TxType;
use std::collections::HashSet;

#[test]
Expand Down
3 changes: 2 additions & 1 deletion crates/transaction-pool/src/pool/pending.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,8 @@ mod tests {
test_utils::{MockOrdering, MockTransaction, MockTransactionFactory, MockTransactionSet},
PoolTransaction,
};
use reth_primitives::{address, TxType};
use alloy_primitives::address;
use reth_primitives::TxType;
use std::collections::HashSet;

#[test]
Expand Down
11 changes: 5 additions & 6 deletions crates/transaction-pool/src/pool/txpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ use crate::{
PoolConfig, PoolResult, PoolTransaction, PriceBumpConfig, TransactionOrdering,
ValidPoolTransaction, U256,
};
use reth_primitives::{
constants::{
eip4844::BLOB_TX_MIN_BLOB_GASPRICE, ETHEREUM_BLOCK_GAS_LIMIT, MIN_PROTOCOL_BASE_FEE,
},
Address, TxHash, B256,
use alloy_primitives::{Address, TxHash, B256};
use reth_primitives::constants::{
eip4844::BLOB_TX_MIN_BLOB_GASPRICE, ETHEREUM_BLOCK_GAS_LIMIT, MIN_PROTOCOL_BASE_FEE,
};
use rustc_hash::FxHashMap;
use smallvec::SmallVec;
Expand Down Expand Up @@ -1848,7 +1846,8 @@ impl SenderInfo {

#[cfg(test)]
mod tests {
use reth_primitives::{address, TxType};
use alloy_primitives::address;
use reth_primitives::TxType;

use super::*;
use crate::{
Expand Down
2 changes: 1 addition & 1 deletion crates/transaction-pool/src/pool/update.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Support types for updating the pool.

use crate::{identifier::TransactionId, pool::state::SubPool};
use reth_primitives::TxHash;
use alloy_primitives::TxHash;

/// A change of the transaction's location
///
Expand Down
5 changes: 3 additions & 2 deletions crates/transaction-pool/src/test_utils/gen.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use crate::EthPooledTransaction;
use alloy_primitives::{Address, B256, U256};
use rand::Rng;
use reth_chainspec::MAINNET;
use reth_primitives::{
constants::MIN_PROTOCOL_BASE_FEE, sign_message, AccessList, Address, Bytes, Transaction,
TransactionSigned, TxEip1559, TxEip4844, TxKind, TxLegacy, B256, U256,
constants::MIN_PROTOCOL_BASE_FEE, sign_message, AccessList, Bytes, Transaction,
TransactionSigned, TxEip1559, TxEip4844, TxKind, TxLegacy,
};

/// A generator for transactions for testing purposes.
Expand Down
9 changes: 5 additions & 4 deletions crates/transaction-pool/src/test_utils/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::{
CoinbaseTipOrdering, EthBlobTransactionSidecar, EthPoolTransaction, PoolTransaction,
ValidPoolTransaction,
};
use alloy_primitives::{Address, Bytes, ChainId, TxHash, TxKind, B256, U256};
use paste::paste;
use rand::{
distributions::{Uniform, WeightedIndex},
Expand All @@ -15,12 +16,12 @@ use rand::{
use reth_primitives::{
constants::{eip4844::DATA_GAS_PER_BLOB, MIN_PROTOCOL_BASE_FEE},
transaction::TryFromRecoveredTransactionError,
AccessList, Address, BlobTransactionSidecar, BlobTransactionValidationError, Bytes, ChainId,
AccessList, BlobTransactionSidecar, BlobTransactionValidationError,
PooledTransactionsElementEcRecovered, Signature, Transaction, TransactionSigned,
TransactionSignedEcRecovered, TxEip1559, TxEip2930, TxEip4844, TxHash, TxKind, TxLegacy,
TxType, B256, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID, LEGACY_TX_TYPE_ID,
U256,
TransactionSignedEcRecovered, TxEip1559, TxEip2930, TxEip4844, TxLegacy, 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};

/// A transaction pool implementation using [`MockOrdering`] for transaction ordering.
Expand Down
2 changes: 1 addition & 1 deletion crates/transaction-pool/src/test_utils/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use crate::{
test_utils::{MockOrdering, MockTransactionDistribution, MockTransactionFactory},
TransactionOrdering,
};
use alloy_primitives::{Address, U256};
use rand::Rng;
use reth_primitives::{Address, U256};
use serde::{Deserialize, Serialize};
use std::{
collections::HashMap,
Expand Down
7 changes: 4 additions & 3 deletions crates/transaction-pool/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ use crate::{
validate::ValidPoolTransaction,
AllTransactionsEvents,
};
use alloy_primitives::{Address, TxHash, TxKind, B256, U256};
use futures_util::{ready, Stream};
use reth_eth_wire_types::HandleMempoolData;
use reth_execution_types::ChangedAccount;
use reth_primitives::{
kzg::KzgSettings, transaction::TryFromRecoveredTransactionError, AccessList, Address,
kzg::KzgSettings, transaction::TryFromRecoveredTransactionError, AccessList,
BlobTransactionSidecar, BlobTransactionValidationError, PooledTransactionsElement,
PooledTransactionsElementEcRecovered, SealedBlock, Transaction, TransactionSignedEcRecovered,
TxHash, TxKind, B256, EIP1559_TX_TYPE_ID, EIP4844_TX_TYPE_ID, EIP7702_TX_TYPE_ID, U256,
EIP1559_TX_TYPE_ID, EIP4844_TX_TYPE_ID, EIP7702_TX_TYPE_ID,
};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
Expand All @@ -29,7 +30,7 @@ use std::{
use tokio::sync::mpsc::Receiver;

/// The `PeerId` type.
pub type PeerId = reth_primitives::B512;
pub type PeerId = alloy_primitives::B512;

/// General purpose abstraction of a transaction-pool.
///
Expand Down
3 changes: 2 additions & 1 deletion crates/transaction-pool/src/validate/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -833,8 +833,9 @@ mod tests {
blobstore::InMemoryBlobStore, error::PoolErrorKind, CoinbaseTipOrdering,
EthPooledTransaction, Pool, TransactionPool,
};
use alloy_primitives::{hex, U256};
use reth_chainspec::MAINNET;
use reth_primitives::{hex, PooledTransactionsElement, U256};
use reth_primitives::PooledTransactionsElement;
use reth_provider::test_utils::{ExtendedAccount, MockEthProvider};

fn get_transaction() -> EthPooledTransaction {
Expand Down
8 changes: 4 additions & 4 deletions crates/transaction-pool/src/validate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use crate::{
identifier::{SenderId, TransactionId},
traits::{PoolTransaction, TransactionOrigin},
};
use alloy_primitives::{Address, TxHash, B256, U256};
use futures_util::future::Either;
use reth_primitives::{
Address, BlobTransactionSidecar, IntoRecoveredTransaction,
PooledTransactionsElementEcRecovered, SealedBlock, TransactionSignedEcRecovered, TxHash, B256,
U256,
BlobTransactionSidecar, IntoRecoveredTransaction, PooledTransactionsElementEcRecovered,
SealedBlock, TransactionSignedEcRecovered,
};
use std::{fmt, future::Future, time::Instant};

Expand Down Expand Up @@ -174,7 +174,7 @@ pub trait TransactionValidator: Send + Sync {
/// * nonce >= next nonce of the sender
/// * ...
///
/// See [`InvalidTransactionError`](reth_primitives::InvalidTransactionError) for common errors
/// See [`InvalidTransactionError`](alloy_primitives::InvalidTransactionError) for common errors
/// variants.
///
/// The transaction pool makes no additional assumptions about the validity of the transaction
Expand Down
Loading
Loading