reth_transaction_pool/lib.rs
1//! Reth's transaction pool implementation.
2//!
3//! This crate provides a generic transaction pool implementation.
4//!
5//! ## Functionality
6//!
7//! The transaction pool is responsible for
8//!
9//! - recording incoming transactions
10//! - providing existing transactions
11//! - ordering and providing the best transactions for block production
12//! - monitoring memory footprint and enforce pool size limits
13//! - storing blob data for transactions in a separate blobstore on insertion
14//!
15//! ## Transaction Flow: From Network/RPC to Pool
16//!
17//! Transactions enter the pool through two main paths:
18//!
19//! ### 1. Network Path (P2P)
20//!
21//! ```text
22//! Network Peer
23//! ↓
24//! Transactions or NewPooledTransactionHashes message
25//! ↓
26//! TransactionsManager (crates/net/network/src/transactions/mod.rs)
27//! │
28//! ├─→ For Transactions message:
29//! │ ├─→ Validates message format
30//! │ ├─→ Checks if transaction already known
31//! │ ├─→ Marks peer as having seen the transaction
32//! │ └─→ Queues for import
33//! │
34//! └─→ For NewPooledTransactionHashes message:
35//! ├─→ Filters out already known transactions
36//! ├─→ Queues unknown hashes for fetching
37//! ├─→ Sends GetPooledTransactions request
38//! ├─→ Receives PooledTransactions response
39//! └─→ Queues fetched transactions for import
40//! ↓
41//! pool.add_external_transactions() [Origin: External]
42//! ↓
43//! Transaction Validation & Pool Addition
44//! ```
45//!
46//! ### 2. RPC Path (Local submission)
47//!
48//! ```text
49//! eth_sendRawTransaction RPC call
50//! ├─→ Decodes raw bytes
51//! └─→ Recovers sender
52//! ↓
53//! pool.add_transaction() [Origin: Local]
54//! ↓
55//! Transaction Validation & Pool Addition
56//! ```
57//!
58//! ### Transaction Origins
59//!
60//! - **Local**: Transactions submitted via RPC (trusted, may have different fee requirements)
61//! - **External**: Transactions from network peers (untrusted, subject to stricter validation)
62//! - **Private**: Local transactions that should not be propagated to the network
63//!
64//! ## Validation Process
65//!
66//! ### Stateless Checks
67//!
68//! Ethereum transactions undergo several stateless checks:
69//!
70//! - **Transaction Type**: Fork-dependent support (Legacy always, EIP-2930/1559/4844/7702 need
71//! activation)
72//! - **Size**: Input data ≤ 128KB (default)
73//! - **Gas**: Limit ≤ block gas limit
74//! - **Fees**: Priority fee ≤ max fee; local tx fee cap; external minimum priority fee
75//! - **Chain ID**: Must match current chain
76//! - **Intrinsic Gas**: Sufficient for data and access lists
77//! - **Blobs** (EIP-4844): Valid count, KZG proofs
78//!
79//! ### Stateful Checks
80//!
81//! 1. **Sender**: No bytecode (unless EIP-7702 delegated in Prague)
82//! 2. **Nonce**: ≥ account nonce
83//! 3. **Balance**: Covers value + (`gas_limit` × `max_fee_per_gas`)
84//!
85//! ### Common Errors
86//!
87//! - [`NonceNotConsistent`](reth_primitives_traits::transaction::error::InvalidTransactionError::NonceNotConsistent): Nonce too low
88//! - [`InsufficientFunds`](reth_primitives_traits::transaction::error::InvalidTransactionError::InsufficientFunds): Insufficient balance
89//! - [`ExceedsGasLimit`](crate::error::InvalidPoolTransactionError::ExceedsGasLimit): Gas limit too
90//! high
91//! - [`SignerAccountHasBytecode`](reth_primitives_traits::transaction::error::InvalidTransactionError::SignerAccountHasBytecode): EOA has code
92//! - [`Underpriced`](crate::error::InvalidPoolTransactionError::Underpriced): Fee too low
93//! - [`ReplacementUnderpriced`](crate::error::PoolErrorKind::ReplacementUnderpriced): Replacement
94//! transaction fee too low
95//! - Blob errors:
96//! - [`MissingEip4844BlobSidecar`](crate::error::Eip4844PoolTransactionError::MissingEip4844BlobSidecar): Missing sidecar
97//! - [`InvalidEip4844Blob`](crate::error::Eip4844PoolTransactionError::InvalidEip4844Blob):
98//! Invalid blob proofs
99//! - [`NoEip4844Blobs`](crate::error::Eip4844PoolTransactionError::NoEip4844Blobs): EIP-4844
100//! transaction without blobs
101//! - [`TooManyEip4844Blobs`](crate::error::Eip4844PoolTransactionError::TooManyEip4844Blobs): Too
102//! many blobs
103//!
104//! ## Subpool Design
105//!
106//! The pool maintains four distinct subpools, each serving a specific purpose
107//!
108//! ### Subpools
109//!
110//! 1. **Pending**: Ready for inclusion (no gaps, sufficient balance/fees)
111//! 2. **Queued**: Future transactions (nonce gaps or insufficient balance)
112//! 3. **`BaseFee`**: Valid but below current base fee
113//! 4. **Blob**: EIP-4844 transactions not pending due to insufficient base fee or blob fee
114//!
115//! ### State Transitions
116//!
117//! Transactions move between subpools based on state changes:
118//!
119//! ```text
120//! Queued ─────────→ BaseFee/Blob ────────→ Pending
121//! ↑ ↑ │
122//! │ │ │
123//! └────────────────────┴─────────────────────┘
124//! (demotions due to state changes)
125//! ```
126//!
127//! **Promotions**: Nonce gaps filled, balance/fee improvements
128//! **Demotions**: Nonce gaps created, balance/fee degradation
129//!
130//! ## Pool Maintenance
131//!
132//! 1. **Block Updates**: Removes mined txs, updates accounts/fees, triggers movements
133//! 2. **Size Enforcement**: Discards worst transactions when limits exceeded
134//! 3. **Propagation**: External (always), Local (configurable), Private (never)
135//!
136//! ## Assumptions
137//!
138//! ### Transaction type
139//!
140//! The pool expects certain ethereum related information from the generic transaction type of the
141//! pool ([`PoolTransaction`]), this includes gas price, base fee (EIP-1559 transactions), nonce
142//! etc. It makes no assumptions about the encoding format, but the transaction type must report its
143//! size so pool size limits (memory) can be enforced.
144//!
145//! ### Transaction ordering
146//!
147//! The pending pool contains transactions that can be mined on the current state.
148//! The order in which they're returned are determined by a `Priority` value returned by the
149//! `TransactionOrdering` type this pool is configured with.
150//!
151//! This is only used in the _pending_ pool to yield the best transactions for block production. The
152//! _base pool_ is ordered by base fee, and the _queued pool_ by current distance.
153//!
154//! ### Validation
155//!
156//! The pool itself does not validate incoming transactions, instead this should be provided by
157//! implementing `TransactionsValidator`. Only transactions that the validator returns as valid are
158//! included in the pool. It is assumed that transaction that are in the pool are either valid on
159//! the current state or could become valid after certain state changes. Transactions that can never
160//! become valid (e.g. nonce lower than current on chain nonce) will never be added to the pool and
161//! instead are discarded right away.
162//!
163//! ### State Changes
164//!
165//! New blocks trigger pool updates via changesets (see Pool Maintenance).
166//!
167//! ## Implementation details
168//!
169//! The `TransactionPool` trait exposes all externally used functionality of the pool, such as
170//! inserting, querying specific transactions by hash or retrieving the best transactions.
171//! In addition, it enables the registration of event listeners that are notified of state changes.
172//! Events are communicated via channels.
173//!
174//! ### Architecture
175//!
176//! The final `TransactionPool` is made up of two layers:
177//!
178//! The lowest layer is the actual pool implementations that manages (validated) transactions:
179//! [`TxPool`](crate::pool::txpool::TxPool). This is contained in a higher level pool type that
180//! guards the low level pool and handles additional listeners or metrics: [`PoolInner`].
181//!
182//! The transaction pool will be used by separate consumers (RPC, P2P), to make sharing easier, the
183//! [`Pool`] type is just an `Arc` wrapper around `PoolInner`. This is the usable type that provides
184//! the `TransactionPool` interface.
185//!
186//!
187//! ## Blob Transactions
188//!
189//! Blob transaction can be quite large hence they are stored in a separate blobstore. The pool is
190//! responsible for inserting blob data for new transactions into the blobstore.
191//! See also [`ValidTransaction`](validate::ValidTransaction)
192//!
193//!
194//! ## Examples
195//!
196//! Listen for new transactions and print them:
197//!
198//! ```
199//! use reth_chainspec::MAINNET;
200//! use reth_storage_api::StateProviderFactory;
201//! use reth_tasks::TokioTaskExecutor;
202//! use reth_chainspec::ChainSpecProvider;
203//! use reth_transaction_pool::{TransactionValidationTaskExecutor, Pool, TransactionPool};
204//! use reth_transaction_pool::blobstore::InMemoryBlobStore;
205//! use reth_chainspec::EthereumHardforks;
206//! async fn t<C>(client: C) where C: ChainSpecProvider<ChainSpec: EthereumHardforks> + StateProviderFactory + Clone + 'static{
207//! let blob_store = InMemoryBlobStore::default();
208//! let pool = Pool::eth_pool(
209//! TransactionValidationTaskExecutor::eth(client, blob_store.clone(), TokioTaskExecutor::default()),
210//! blob_store,
211//! Default::default(),
212//! );
213//! let mut transactions = pool.pending_transactions_listener();
214//! tokio::task::spawn( async move {
215//! while let Some(tx) = transactions.recv().await {
216//! println!("New transaction: {:?}", tx);
217//! }
218//! });
219//!
220//! // do something useful with the pool, like RPC integration
221//!
222//! # }
223//! ```
224//!
225//! Spawn maintenance task to keep the pool updated
226//!
227//! ```
228//! use futures_util::Stream;
229//! use reth_chain_state::CanonStateNotification;
230//! use reth_chainspec::{MAINNET, ChainSpecProvider, ChainSpec};
231//! use reth_storage_api::{BlockReaderIdExt, StateProviderFactory};
232//! use reth_tasks::TokioTaskExecutor;
233//! use reth_tasks::TaskSpawner;
234//! use reth_tasks::TaskManager;
235//! use reth_transaction_pool::{TransactionValidationTaskExecutor, Pool};
236//! use reth_transaction_pool::blobstore::InMemoryBlobStore;
237//! use reth_transaction_pool::maintain::{maintain_transaction_pool_future};
238//! use alloy_consensus::Header;
239//!
240//! async fn t<C, St>(client: C, stream: St)
241//! where C: StateProviderFactory + BlockReaderIdExt<Header = Header> + ChainSpecProvider<ChainSpec = ChainSpec> + Clone + 'static,
242//! St: Stream<Item = CanonStateNotification> + Send + Unpin + 'static,
243//! {
244//! let blob_store = InMemoryBlobStore::default();
245//! let rt = tokio::runtime::Runtime::new().unwrap();
246//! let manager = TaskManager::new(rt.handle().clone());
247//! let executor = manager.executor();
248//! let pool = Pool::eth_pool(
249//! TransactionValidationTaskExecutor::eth(client.clone(), blob_store.clone(), executor.clone()),
250//! blob_store,
251//! Default::default(),
252//! );
253//!
254//! // spawn a task that listens for new blocks and updates the pool's transactions, mined transactions etc..
255//! tokio::task::spawn(maintain_transaction_pool_future(client, pool, stream, executor.clone(), Default::default()));
256//!
257//! # }
258//! ```
259//!
260//! ## Feature Flags
261//!
262//! - `serde` (default): Enable serde support
263//! - `test-utils`: Export utilities for testing
264
265#![doc(
266 html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
267 html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
268 issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
269)]
270#![cfg_attr(docsrs, feature(doc_cfg))]
271#![cfg_attr(not(test), warn(unused_crate_dependencies))]
272
273pub use crate::{
274 batcher::{BatchTxProcessor, BatchTxRequest},
275 blobstore::{BlobStore, BlobStoreError},
276 config::{
277 LocalTransactionConfig, PoolConfig, PriceBumpConfig, SubPoolLimit,
278 DEFAULT_MAX_INFLIGHT_DELEGATED_SLOTS, DEFAULT_PRICE_BUMP,
279 DEFAULT_TXPOOL_ADDITIONAL_VALIDATION_TASKS, MAX_NEW_PENDING_TXS_NOTIFICATIONS,
280 REPLACE_BLOB_PRICE_BUMP, TXPOOL_MAX_ACCOUNT_SLOTS_PER_SENDER,
281 TXPOOL_SUBPOOL_MAX_SIZE_MB_DEFAULT, TXPOOL_SUBPOOL_MAX_TXS_DEFAULT,
282 },
283 error::PoolResult,
284 ordering::{CoinbaseTipOrdering, Priority, TransactionOrdering},
285 pool::{
286 blob_tx_priority, fee_delta, state::SubPool, AddedTransactionOutcome,
287 AllTransactionsEvents, FullTransactionEvent, NewTransactionEvent, TransactionEvent,
288 TransactionEvents, TransactionListenerKind,
289 },
290 traits::*,
291 validate::{
292 EthTransactionValidator, TransactionValidationOutcome, TransactionValidationTaskExecutor,
293 TransactionValidator, ValidPoolTransaction,
294 },
295};
296use crate::{identifier::TransactionId, pool::PoolInner};
297use alloy_eips::{
298 eip4844::{BlobAndProofV1, BlobAndProofV2},
299 eip7594::BlobTransactionSidecarVariant,
300};
301use alloy_primitives::{Address, TxHash, B256, U256};
302use aquamarine as _;
303use reth_chainspec::{ChainSpecProvider, EthereumHardforks};
304use reth_eth_wire_types::HandleMempoolData;
305use reth_execution_types::ChangedAccount;
306use reth_primitives_traits::{Block, Recovered};
307use reth_storage_api::StateProviderFactory;
308use std::{collections::HashSet, sync::Arc};
309use tokio::sync::mpsc::Receiver;
310use tracing::{instrument, trace};
311
312pub mod error;
313pub mod maintain;
314pub mod metrics;
315pub mod noop;
316pub mod pool;
317pub mod validate;
318
319pub mod batcher;
320pub mod blobstore;
321mod config;
322pub mod identifier;
323mod ordering;
324mod traits;
325
326#[cfg(any(test, feature = "test-utils"))]
327/// Common test helpers for mocking a pool
328pub mod test_utils;
329
330/// Type alias for default ethereum transaction pool
331pub type EthTransactionPool<Client, S, T = EthPooledTransaction> = Pool<
332 TransactionValidationTaskExecutor<EthTransactionValidator<Client, T>>,
333 CoinbaseTipOrdering<T>,
334 S,
335>;
336
337/// A shareable, generic, customizable `TransactionPool` implementation.
338#[derive(Debug)]
339pub struct Pool<V, T: TransactionOrdering, S> {
340 /// Arc'ed instance of the pool internals
341 pool: Arc<PoolInner<V, T, S>>,
342}
343
344// === impl Pool ===
345
346impl<V, T, S> Pool<V, T, S>
347where
348 V: TransactionValidator,
349 T: TransactionOrdering<Transaction = <V as TransactionValidator>::Transaction>,
350 S: BlobStore,
351{
352 /// Create a new transaction pool instance.
353 pub fn new(validator: V, ordering: T, blob_store: S, config: PoolConfig) -> Self {
354 Self { pool: Arc::new(PoolInner::new(validator, ordering, blob_store, config)) }
355 }
356
357 /// Returns the wrapped pool internals.
358 pub fn inner(&self) -> &PoolInner<V, T, S> {
359 &self.pool
360 }
361
362 /// Get the config the pool was configured with.
363 pub fn config(&self) -> &PoolConfig {
364 self.inner().config()
365 }
366
367 /// Get the validator reference.
368 pub fn validator(&self) -> &V {
369 self.inner().validator()
370 }
371
372 /// Validates the given transaction
373 async fn validate(
374 &self,
375 origin: TransactionOrigin,
376 transaction: V::Transaction,
377 ) -> TransactionValidationOutcome<V::Transaction> {
378 self.pool.validator().validate_transaction(origin, transaction).await
379 }
380
381 /// Returns future that validates all transactions in the given iterator.
382 ///
383 /// This returns the validated transactions in the iterator's order.
384 async fn validate_all(
385 &self,
386 origin: TransactionOrigin,
387 transactions: impl IntoIterator<Item = V::Transaction> + Send,
388 ) -> Vec<TransactionValidationOutcome<V::Transaction>> {
389 self.pool.validator().validate_transactions_with_origin(origin, transactions).await
390 }
391
392 /// Number of transactions in the entire pool
393 pub fn len(&self) -> usize {
394 self.pool.len()
395 }
396
397 /// Whether the pool is empty
398 pub fn is_empty(&self) -> bool {
399 self.pool.is_empty()
400 }
401
402 /// Returns whether or not the pool is over its configured size and transaction count limits.
403 pub fn is_exceeded(&self) -> bool {
404 self.pool.is_exceeded()
405 }
406
407 /// Returns the configured blob store.
408 pub fn blob_store(&self) -> &S {
409 self.pool.blob_store()
410 }
411}
412
413impl<Client, S> EthTransactionPool<Client, S>
414where
415 Client:
416 ChainSpecProvider<ChainSpec: EthereumHardforks> + StateProviderFactory + Clone + 'static,
417 S: BlobStore,
418{
419 /// Returns a new [`Pool`] that uses the default [`TransactionValidationTaskExecutor`] when
420 /// validating [`EthPooledTransaction`]s and ords via [`CoinbaseTipOrdering`]
421 ///
422 /// # Example
423 ///
424 /// ```
425 /// use reth_chainspec::MAINNET;
426 /// use reth_storage_api::StateProviderFactory;
427 /// use reth_tasks::TokioTaskExecutor;
428 /// use reth_chainspec::ChainSpecProvider;
429 /// use reth_transaction_pool::{
430 /// blobstore::InMemoryBlobStore, Pool, TransactionValidationTaskExecutor,
431 /// };
432 /// use reth_chainspec::EthereumHardforks;
433 /// # fn t<C>(client: C) where C: ChainSpecProvider<ChainSpec: EthereumHardforks> + StateProviderFactory + Clone + 'static {
434 /// let blob_store = InMemoryBlobStore::default();
435 /// let pool = Pool::eth_pool(
436 /// TransactionValidationTaskExecutor::eth(
437 /// client,
438 /// blob_store.clone(),
439 /// TokioTaskExecutor::default(),
440 /// ),
441 /// blob_store,
442 /// Default::default(),
443 /// );
444 /// # }
445 /// ```
446 pub fn eth_pool(
447 validator: TransactionValidationTaskExecutor<
448 EthTransactionValidator<Client, EthPooledTransaction>,
449 >,
450 blob_store: S,
451 config: PoolConfig,
452 ) -> Self {
453 Self::new(validator, CoinbaseTipOrdering::default(), blob_store, config)
454 }
455}
456
457/// implements the `TransactionPool` interface for various transaction pool API consumers.
458impl<V, T, S> TransactionPool for Pool<V, T, S>
459where
460 V: TransactionValidator,
461 <V as TransactionValidator>::Transaction: EthPoolTransaction,
462 T: TransactionOrdering<Transaction = <V as TransactionValidator>::Transaction>,
463 S: BlobStore,
464{
465 type Transaction = T::Transaction;
466
467 fn pool_size(&self) -> PoolSize {
468 self.pool.size()
469 }
470
471 fn block_info(&self) -> BlockInfo {
472 self.pool.block_info()
473 }
474
475 async fn add_transaction_and_subscribe(
476 &self,
477 origin: TransactionOrigin,
478 transaction: Self::Transaction,
479 ) -> PoolResult<TransactionEvents> {
480 let tx = self.validate(origin, transaction).await;
481 self.pool.add_transaction_and_subscribe(origin, tx)
482 }
483
484 async fn add_transaction(
485 &self,
486 origin: TransactionOrigin,
487 transaction: Self::Transaction,
488 ) -> PoolResult<AddedTransactionOutcome> {
489 let tx = self.validate(origin, transaction).await;
490 let mut results = self.pool.add_transactions(origin, std::iter::once(tx));
491 results.pop().expect("result length is the same as the input")
492 }
493
494 async fn add_transactions(
495 &self,
496 origin: TransactionOrigin,
497 transactions: Vec<Self::Transaction>,
498 ) -> Vec<PoolResult<AddedTransactionOutcome>> {
499 if transactions.is_empty() {
500 return Vec::new()
501 }
502 let validated = self.validate_all(origin, transactions).await;
503
504 self.pool.add_transactions(origin, validated.into_iter())
505 }
506
507 fn transaction_event_listener(&self, tx_hash: TxHash) -> Option<TransactionEvents> {
508 self.pool.add_transaction_event_listener(tx_hash)
509 }
510
511 fn all_transactions_event_listener(&self) -> AllTransactionsEvents<Self::Transaction> {
512 self.pool.add_all_transactions_event_listener()
513 }
514
515 fn pending_transactions_listener_for(&self, kind: TransactionListenerKind) -> Receiver<TxHash> {
516 self.pool.add_pending_listener(kind)
517 }
518
519 fn blob_transaction_sidecars_listener(&self) -> Receiver<NewBlobSidecar> {
520 self.pool.add_blob_sidecar_listener()
521 }
522
523 fn new_transactions_listener_for(
524 &self,
525 kind: TransactionListenerKind,
526 ) -> Receiver<NewTransactionEvent<Self::Transaction>> {
527 self.pool.add_new_transaction_listener(kind)
528 }
529
530 fn pooled_transaction_hashes(&self) -> Vec<TxHash> {
531 self.pool.pooled_transactions_hashes()
532 }
533
534 fn pooled_transaction_hashes_max(&self, max: usize) -> Vec<TxHash> {
535 self.pool.pooled_transactions_hashes_max(max)
536 }
537
538 fn pooled_transactions(&self) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>> {
539 self.pool.pooled_transactions()
540 }
541
542 fn pooled_transactions_max(
543 &self,
544 max: usize,
545 ) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>> {
546 self.pool.pooled_transactions_max(max)
547 }
548
549 fn get_pooled_transaction_elements(
550 &self,
551 tx_hashes: Vec<TxHash>,
552 limit: GetPooledTransactionLimit,
553 ) -> Vec<<<V as TransactionValidator>::Transaction as PoolTransaction>::Pooled> {
554 self.pool.get_pooled_transaction_elements(tx_hashes, limit)
555 }
556
557 fn get_pooled_transaction_element(
558 &self,
559 tx_hash: TxHash,
560 ) -> Option<Recovered<<<V as TransactionValidator>::Transaction as PoolTransaction>::Pooled>>
561 {
562 self.pool.get_pooled_transaction_element(tx_hash)
563 }
564
565 fn best_transactions(
566 &self,
567 ) -> Box<dyn BestTransactions<Item = Arc<ValidPoolTransaction<Self::Transaction>>>> {
568 Box::new(self.pool.best_transactions())
569 }
570
571 fn best_transactions_with_attributes(
572 &self,
573 best_transactions_attributes: BestTransactionsAttributes,
574 ) -> Box<dyn BestTransactions<Item = Arc<ValidPoolTransaction<Self::Transaction>>>> {
575 self.pool.best_transactions_with_attributes(best_transactions_attributes)
576 }
577
578 fn pending_transactions(&self) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>> {
579 self.pool.pending_transactions()
580 }
581
582 fn pending_transactions_max(
583 &self,
584 max: usize,
585 ) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>> {
586 self.pool.pending_transactions_max(max)
587 }
588
589 fn queued_transactions(&self) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>> {
590 self.pool.queued_transactions()
591 }
592
593 fn pending_and_queued_txn_count(&self) -> (usize, usize) {
594 let data = self.pool.get_pool_data();
595 let pending = data.pending_transactions_count();
596 let queued = data.queued_transactions_count();
597 (pending, queued)
598 }
599
600 fn all_transactions(&self) -> AllPoolTransactions<Self::Transaction> {
601 self.pool.all_transactions()
602 }
603
604 fn all_transaction_hashes(&self) -> Vec<TxHash> {
605 self.pool.all_transaction_hashes()
606 }
607
608 fn remove_transactions(
609 &self,
610 hashes: Vec<TxHash>,
611 ) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>> {
612 self.pool.remove_transactions(hashes)
613 }
614
615 fn remove_transactions_and_descendants(
616 &self,
617 hashes: Vec<TxHash>,
618 ) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>> {
619 self.pool.remove_transactions_and_descendants(hashes)
620 }
621
622 fn remove_transactions_by_sender(
623 &self,
624 sender: Address,
625 ) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>> {
626 self.pool.remove_transactions_by_sender(sender)
627 }
628
629 fn retain_unknown<A>(&self, announcement: &mut A)
630 where
631 A: HandleMempoolData,
632 {
633 self.pool.retain_unknown(announcement)
634 }
635
636 fn get(&self, tx_hash: &TxHash) -> Option<Arc<ValidPoolTransaction<Self::Transaction>>> {
637 self.inner().get(tx_hash)
638 }
639
640 fn get_all(&self, txs: Vec<TxHash>) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>> {
641 self.inner().get_all(txs)
642 }
643
644 fn on_propagated(&self, txs: PropagatedTransactions) {
645 self.inner().on_propagated(txs)
646 }
647
648 fn get_transactions_by_sender(
649 &self,
650 sender: Address,
651 ) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>> {
652 self.pool.get_transactions_by_sender(sender)
653 }
654
655 fn get_pending_transactions_with_predicate(
656 &self,
657 predicate: impl FnMut(&ValidPoolTransaction<Self::Transaction>) -> bool,
658 ) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>> {
659 self.pool.pending_transactions_with_predicate(predicate)
660 }
661
662 fn get_pending_transactions_by_sender(
663 &self,
664 sender: Address,
665 ) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>> {
666 self.pool.get_pending_transactions_by_sender(sender)
667 }
668
669 fn get_queued_transactions_by_sender(
670 &self,
671 sender: Address,
672 ) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>> {
673 self.pool.get_queued_transactions_by_sender(sender)
674 }
675
676 fn get_highest_transaction_by_sender(
677 &self,
678 sender: Address,
679 ) -> Option<Arc<ValidPoolTransaction<Self::Transaction>>> {
680 self.pool.get_highest_transaction_by_sender(sender)
681 }
682
683 fn get_highest_consecutive_transaction_by_sender(
684 &self,
685 sender: Address,
686 on_chain_nonce: u64,
687 ) -> Option<Arc<ValidPoolTransaction<Self::Transaction>>> {
688 self.pool.get_highest_consecutive_transaction_by_sender(sender, on_chain_nonce)
689 }
690
691 fn get_transaction_by_sender_and_nonce(
692 &self,
693 sender: Address,
694 nonce: u64,
695 ) -> Option<Arc<ValidPoolTransaction<Self::Transaction>>> {
696 let transaction_id = TransactionId::new(self.pool.get_sender_id(sender), nonce);
697
698 self.inner().get_pool_data().all().get(&transaction_id).map(|tx| tx.transaction.clone())
699 }
700
701 fn get_transactions_by_origin(
702 &self,
703 origin: TransactionOrigin,
704 ) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>> {
705 self.pool.get_transactions_by_origin(origin)
706 }
707
708 /// Returns all pending transactions filtered by [`TransactionOrigin`]
709 fn get_pending_transactions_by_origin(
710 &self,
711 origin: TransactionOrigin,
712 ) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>> {
713 self.pool.get_pending_transactions_by_origin(origin)
714 }
715
716 fn unique_senders(&self) -> HashSet<Address> {
717 self.pool.unique_senders()
718 }
719
720 fn get_blob(
721 &self,
722 tx_hash: TxHash,
723 ) -> Result<Option<Arc<BlobTransactionSidecarVariant>>, BlobStoreError> {
724 self.pool.blob_store().get(tx_hash)
725 }
726
727 fn get_all_blobs(
728 &self,
729 tx_hashes: Vec<TxHash>,
730 ) -> Result<Vec<(TxHash, Arc<BlobTransactionSidecarVariant>)>, BlobStoreError> {
731 self.pool.blob_store().get_all(tx_hashes)
732 }
733
734 fn get_all_blobs_exact(
735 &self,
736 tx_hashes: Vec<TxHash>,
737 ) -> Result<Vec<Arc<BlobTransactionSidecarVariant>>, BlobStoreError> {
738 self.pool.blob_store().get_exact(tx_hashes)
739 }
740
741 fn get_blobs_for_versioned_hashes_v1(
742 &self,
743 versioned_hashes: &[B256],
744 ) -> Result<Vec<Option<BlobAndProofV1>>, BlobStoreError> {
745 self.pool.blob_store().get_by_versioned_hashes_v1(versioned_hashes)
746 }
747
748 fn get_blobs_for_versioned_hashes_v2(
749 &self,
750 versioned_hashes: &[B256],
751 ) -> Result<Option<Vec<BlobAndProofV2>>, BlobStoreError> {
752 self.pool.blob_store().get_by_versioned_hashes_v2(versioned_hashes)
753 }
754}
755
756impl<V, T, S> TransactionPoolExt for Pool<V, T, S>
757where
758 V: TransactionValidator,
759 <V as TransactionValidator>::Transaction: EthPoolTransaction,
760 T: TransactionOrdering<Transaction = <V as TransactionValidator>::Transaction>,
761 S: BlobStore,
762{
763 #[instrument(skip(self), target = "txpool")]
764 fn set_block_info(&self, info: BlockInfo) {
765 trace!(target: "txpool", "updating pool block info");
766 self.pool.set_block_info(info)
767 }
768
769 fn on_canonical_state_change<B>(&self, update: CanonicalStateUpdate<'_, B>)
770 where
771 B: Block,
772 {
773 self.pool.on_canonical_state_change(update);
774 }
775
776 fn update_accounts(&self, accounts: Vec<ChangedAccount>) {
777 self.pool.update_accounts(accounts);
778 }
779
780 fn delete_blob(&self, tx: TxHash) {
781 self.pool.delete_blob(tx)
782 }
783
784 fn delete_blobs(&self, txs: Vec<TxHash>) {
785 self.pool.delete_blobs(txs)
786 }
787
788 fn cleanup_blobs(&self) {
789 self.pool.cleanup_blobs()
790 }
791}
792
793impl<V, T: TransactionOrdering, S> Clone for Pool<V, T, S> {
794 fn clone(&self) -> Self {
795 Self { pool: Arc::clone(&self.pool) }
796 }
797}