diff --git a/crates/op-rbuilder/src/main.rs b/crates/op-rbuilder/src/main.rs index a248f0e4c..f2931d351 100644 --- a/crates/op-rbuilder/src/main.rs +++ b/crates/op-rbuilder/src/main.rs @@ -28,6 +28,7 @@ mod primitives; mod tester; mod tx_signer; use monitor_tx_pool::monitor_tx_pool; +mod txpool_trait; fn main() { Cli::::parse() diff --git a/crates/op-rbuilder/src/payload_builder_vanilla.rs b/crates/op-rbuilder/src/payload_builder_vanilla.rs index 4113b7629..beb5d4ef6 100644 --- a/crates/op-rbuilder/src/payload_builder_vanilla.rs +++ b/crates/op-rbuilder/src/payload_builder_vanilla.rs @@ -1,3 +1,4 @@ +use crate::txpool_trait::BuilderTransactionPool; use crate::{ generator::{BlockCell, BlockPayloadJobGenerator, BuildArguments, PayloadBuilder}, metrics::OpRBuilderMetrics, @@ -772,14 +773,14 @@ impl OpBuilder<'_, Txs> { pub trait OpPayloadTransactions: Clone + Send + Sync + Unpin + 'static { /// Returns an iterator that yields the transaction in the order they should get included in the /// new payload. - fn best_transactions>( + fn best_transactions>( &self, pool: Pool, attr: BestTransactionsAttributes, ) -> impl PayloadTransactions; /// Removes invalid transactions from the tx pool - fn remove_invalid>( + fn remove_invalid>( &self, pool: Pool, hashes: Vec, @@ -787,7 +788,7 @@ pub trait OpPayloadTransactions: Clone + Send + Sync + Unpin + 'sta } impl OpPayloadTransactions for () { - fn best_transactions>( + fn best_transactions>( &self, pool: Pool, attr: BestTransactionsAttributes, @@ -795,7 +796,7 @@ impl OpPayloadTransactions for () { BestPayloadTransactions::new(pool.best_transactions_with_attributes(attr)) } - fn remove_invalid>( + fn remove_invalid>( &self, pool: Pool, hashes: Vec, diff --git a/crates/op-rbuilder/src/txpool_trait.rs b/crates/op-rbuilder/src/txpool_trait.rs new file mode 100644 index 000000000..93fda5b12 --- /dev/null +++ b/crates/op-rbuilder/src/txpool_trait.rs @@ -0,0 +1,46 @@ +use alloy_primitives::TxHash; +use reth_transaction_pool::TransactionPool; +use reth_transaction_pool::{ + BestTransactions, BestTransactionsAttributes, EthPoolTransaction, ValidPoolTransaction, +}; +use std::sync::Arc; + +pub trait BuilderTransactionPool: Send + Sync + Clone { + /// The transaction type of the pool + type Transaction: EthPoolTransaction; + + /// Returns an iterator that yields transactions that are ready for block production with the + /// given base fee and optional blob fee attributes. + /// + /// Consumer: Block production + fn best_transactions_with_attributes( + &self, + best_transactions_attributes: BestTransactionsAttributes, + ) -> Box>>>; + + /// Removes all transactions corresponding to the given hashes. + /// + /// Consumer: Utility + fn remove_transactions( + &self, + hashes: Vec, + ) -> Vec>>; +} + +impl BuilderTransactionPool for T { + type Transaction = T::Transaction; + + fn best_transactions_with_attributes( + &self, + best_transactions_attributes: BestTransactionsAttributes, + ) -> Box>>> { + TransactionPool::best_transactions_with_attributes(self, best_transactions_attributes) + } + + fn remove_transactions( + &self, + hashes: Vec, + ) -> Vec>> { + TransactionPool::remove_transactions(self, hashes) + } +}