Skip to content

Commit ff9c55b

Browse files
authored
In-process rbuilder orderpool <> reth transaction-pool connection (#339)
Adds a new method to `LiveBuilder` `connect_to_transaction_pool` allowing in-process connection between the reth transaction pool and rbuilder orderpool. This fixes an issue where the orderpool does not receive any transactions that were cached on disk by reth on start up, and finally removes the requirement for an ipc connection when running in-process.
1 parent efa52eb commit ff9c55b

File tree

5 files changed

+31
-21
lines changed

5 files changed

+31
-21
lines changed

op-rbuilder/node/src/node.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use reth_primitives::TransactionSigned;
2727
use reth_provider::{BlockReader, CanonStateSubscriptions, DatabaseProviderFactory};
2828
use reth_tracing::tracing::{debug, info};
2929
use reth_transaction_pool::{
30-
blobstore::DiskFileBlobStore, CoinbaseTipOrdering, EthPooledTransaction,
30+
blobstore::DiskFileBlobStore, CoinbaseTipOrdering, EthPooledTransaction, Pool,
3131
TransactionValidationTaskExecutor,
3232
};
3333
use reth_trie_db::MerklePatriciaTrie;
@@ -194,16 +194,16 @@ where
194194
.require_l1_data_gas_fee(!ctx.config().dev.dev)
195195
});
196196

197-
let bundle_ops = BundlePoolOps::new(ctx.provider().clone(), self.config)
198-
.await
199-
.expect("Failed to instantiate RbuilderBundlePoolOps");
200-
let transaction_pool = OpRbuilderTransactionPool::new(
197+
let tx_pool = Pool::new(
201198
validator,
202199
CoinbaseTipOrdering::default(),
203200
blob_store,
204-
bundle_ops,
205201
ctx.pool_config(),
206202
);
203+
let bundle_ops = BundlePoolOps::new(ctx.provider().clone(), tx_pool.clone(), self.config)
204+
.await
205+
.expect("Failed to instantiate RbuilderBundlePoolOps");
206+
let transaction_pool = OpRbuilderTransactionPool::new(tx_pool, bundle_ops);
207207

208208
info!(target: "reth::cli", "Transaction pool initialized");
209209
let transactions_path = data_dir.txpool_transactions();

op-rbuilder/payload_builder/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,5 @@ optimism = [
4848
"reth-provider/optimism",
4949
"revm/optimism",
5050
"reth-optimism-consensus/optimism",
51+
"reth-optimism-payload-builder/optimism"
5152
]

transaction-pool-bundle-ext/bundle_pool_ops/rbuilder/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ rbuilder = { path = "../../../rbuilder" }
1010
alloy-primitives.workspace = true
1111
alloy-rpc-types-beacon.workspace = true
1212
reth-primitives = { workspace = true }
13-
reth-provider = {workspace = true}
13+
reth-transaction-pool = { workspace = true }
14+
reth-provider = { workspace = true }
15+
1416
derive_more = { workspace = true }
1517
eyre = { workspace = true }
1618
tokio = { workspace = true }

transaction-pool-bundle-ext/bundle_pool_ops/rbuilder/src/lib.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ use rbuilder::{
3030
};
3131
use reth_primitives::TransactionSigned;
3232
use reth_provider::{BlockReader, DatabaseProviderFactory, HeaderProvider};
33+
use reth_transaction_pool::{
34+
BlobStore, EthPooledTransaction, Pool, TransactionOrdering, TransactionValidator,
35+
};
3336
use tokio::{
3437
sync::{
3538
mpsc::{self, error::SendError},
@@ -88,13 +91,20 @@ impl SlotSource for OurSlotSource {
8891
}
8992

9093
impl BundlePoolOps {
91-
pub async fn new<P>(provider: P, config: Config) -> Result<Self, Error>
94+
pub async fn new<P, V, T, S>(
95+
provider: P,
96+
pool: Pool<V, T, S>,
97+
config: Config,
98+
) -> Result<Self, Error>
9299
where
93100
P: DatabaseProviderFactory<Provider: BlockReader>
94101
+ reth_provider::StateProviderFactory
95102
+ HeaderProvider
96103
+ Clone
97104
+ 'static,
105+
V: TransactionValidator<Transaction = EthPooledTransaction> + 'static,
106+
T: TransactionOrdering<Transaction = <V as TransactionValidator>::Transaction>,
107+
S: BlobStore,
98108
{
99109
// Create the payload source to trigger new block building
100110
let cancellation_token = CancellationToken::new();
@@ -108,7 +118,6 @@ impl BundlePoolOps {
108118
block_building_helper_tx,
109119
};
110120

111-
// Spawn the builder!
112121
let builder_strategy = BuilderConfig {
113122
name: "mp-ordering".to_string(),
114123
builder: SpecificBuilderConfig::OrderingBuilder(OrderingBuilderConfig {
@@ -162,6 +171,10 @@ impl BundlePoolOps {
162171
.await
163172
.expect("Failed to start full telemetry server");
164173

174+
builder
175+
.connect_to_transaction_pool(pool)
176+
.await
177+
.expect("Failed to connect to reth pool");
165178
builder.run().await.unwrap();
166179

167180
Ok::<(), ()>

transaction-pool-bundle-ext/src/bundle_supported_pool.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ use reth_primitives::PooledTransactionsElement;
99
use reth_transaction_pool::{
1010
AllPoolTransactions, AllTransactionsEvents, BestTransactions, BestTransactionsAttributes,
1111
BlobStore, BlobStoreError, BlockInfo, CanonicalStateUpdate, EthPoolTransaction,
12-
GetPooledTransactionLimit, NewBlobSidecar, NewTransactionEvent, Pool, PoolConfig, PoolResult,
13-
PoolSize, PropagatedTransactions, TransactionEvents, TransactionListenerKind,
14-
TransactionOrdering, TransactionOrigin, TransactionPool,
15-
TransactionPoolExt as TransactionPoolBlockInfoExt, TransactionValidator, ValidPoolTransaction,
12+
GetPooledTransactionLimit, NewBlobSidecar, NewTransactionEvent, Pool, PoolResult, PoolSize,
13+
PropagatedTransactions, TransactionEvents, TransactionListenerKind, TransactionOrdering,
14+
TransactionOrigin, TransactionPool, TransactionPoolExt as TransactionPoolBlockInfoExt,
15+
TransactionValidator, ValidPoolTransaction,
1616
};
1717
use std::{collections::HashSet, future::Future, sync::Arc};
1818
use tokio::sync::mpsc::Receiver;
@@ -67,15 +67,9 @@ where
6767
S: BlobStore,
6868
B: BundlePoolOperations,
6969
{
70-
pub fn new(
71-
validator: V,
72-
ordering: T,
73-
blob_store: S,
74-
bundle_ops: B,
75-
tx_pool_config: PoolConfig,
76-
) -> Self {
70+
pub fn new(pool: Pool<V, T, S>, bundle_ops: B) -> Self {
7771
Self {
78-
tx_pool: Pool::<V, T, S>::new(validator, ordering, blob_store, tx_pool_config),
72+
tx_pool: pool,
7973
bundle_pool: Arc::new(BundlePool::<B>::new(bundle_ops)),
8074
}
8175
}

0 commit comments

Comments
 (0)