diff --git a/crates/transaction-pool/src/lib.rs b/crates/transaction-pool/src/lib.rs index 839af93390..c9e46252ce 100644 --- a/crates/transaction-pool/src/lib.rs +++ b/crates/transaction-pool/src/lib.rs @@ -417,6 +417,10 @@ where self.pool.get_pooled_transaction_elements(tx_hashes, limit) } + fn get_pooled_transaction_element(&self, tx_hash: TxHash) -> Option { + self.pool.get_pooled_transaction_element(tx_hash) + } + fn best_transactions( &self, ) -> Box>>> { diff --git a/crates/transaction-pool/src/noop.rs b/crates/transaction-pool/src/noop.rs index c55a8bf058..98395d294f 100644 --- a/crates/transaction-pool/src/noop.rs +++ b/crates/transaction-pool/src/noop.rs @@ -135,6 +135,13 @@ impl TransactionPool for NoopTransactionPool { vec![] } + fn get_pooled_transaction_element( + &self, + _tx_hash: TxHash, + ) -> Option { + None + } + fn best_transactions( &self, ) -> Box>>> { diff --git a/crates/transaction-pool/src/pool/mod.rs b/crates/transaction-pool/src/pool/mod.rs index 580a332e18..da4b524b75 100644 --- a/crates/transaction-pool/src/pool/mod.rs +++ b/crates/transaction-pool/src/pool/mod.rs @@ -341,6 +341,21 @@ where elements } + /// Returns converted [PooledTransactionsElement] for the given transaction hash. + pub(crate) fn get_pooled_transaction_element( + &self, + tx_hash: TxHash, + ) -> Option { + self.get(&tx_hash).and_then(|transaction| { + let tx = transaction.to_recovered_transaction().into_signed(); + if tx.is_eip4844() { + self.get_blob_transaction(tx).map(PooledTransactionsElement::BlobTransaction) + } else { + Some(PooledTransactionsElement::from(tx)) + } + }) + } + /// Updates the entire pool after a new block was executed. pub(crate) fn on_canonical_state_change(&self, update: CanonicalStateUpdate<'_>) { trace!(target: "txpool", ?update, "updating pool on canonical state change"); diff --git a/crates/transaction-pool/src/traits.rs b/crates/transaction-pool/src/traits.rs index 00500f5e2c..fd06c912d6 100644 --- a/crates/transaction-pool/src/traits.rs +++ b/crates/transaction-pool/src/traits.rs @@ -221,6 +221,16 @@ pub trait TransactionPool: Send + Sync + Clone { limit: GetPooledTransactionLimit, ) -> Vec; + /// Returns converted [PooledTransactionsElement] for the given transaction hash. + /// + /// This adheres to the expected behavior of + /// [`GetPooledTransactions`](https://github.com/ethereum/devp2p/blob/master/caps/eth.md#getpooledtransactions-0x09): + /// + /// If the transaction is a blob transaction, the sidecar will be included. + /// + /// Consumer: P2P + fn get_pooled_transaction_element(&self, tx_hash: TxHash) -> Option; + /// Returns an iterator that yields transactions that are ready for block production. /// /// Consumer: Block production