Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
7 changes: 6 additions & 1 deletion crates/op-rbuilder/src/builders/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use std::{sync::Arc, time::Instant};
use tips_bundle_pool::pool::{Action, ProcessedBundle};
use tips_core::{BundleExtensions, BundleTxs};
use tokio_util::sync::CancellationToken;
use tracing::{debug, info, trace};
use tracing::{debug, info, trace, warn};

use crate::{
gas_limiter::AddressGasLimiter,
Expand Down Expand Up @@ -445,6 +445,11 @@ impl<ExtraCtx: Debug + Default> OpPayloadBuilderCtx<ExtraCtx> {
// append sender and transaction to the respective lists
info.executed_senders.push(txn.signer());
info.executed_transactions.push(txn.clone().into_inner());

if let Some(backrun_bundle) = best_bundles.get_backrun_bundle(&txn.tx_hash()) {
warn!(target: "payload_builder", tx_hash = ?txn.tx_hash(), "Executing backrun bundle");
// TODO: execute backrun bundle
}
}

// TODO: confirm this is safe to do
Expand Down
8 changes: 8 additions & 0 deletions crates/op-rbuilder/src/builders/flashblocks/best_bundles.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::traits::BundleBounds;
use alloy_primitives::TxHash;
use alloy_primitives::map::HashMap;
use reth_transaction_pool::TransactionPool;
use rollup_boost::FlashblocksPayloadV1;
use std::collections::HashSet;
Expand All @@ -16,6 +17,7 @@ pub(super) struct BestFlashblocksBundles<Pool: TransactionPool> {

// Mut stuff
bundles: Vec<AcceptedBundle>,
backrun_bundles: HashMap<TxHash, AcceptedBundle>,
curr_bundles_idx: usize,
current_block_num: u64,
}
Expand All @@ -29,6 +31,7 @@ impl<Pool: TransactionPool> BestFlashblocksBundles<Pool> {
current_block_num: 0,
commited_transactions: Default::default(),
bundles: vec![],
backrun_bundles: Default::default(),
curr_bundles_idx: 0,
}
}
Expand All @@ -44,6 +47,7 @@ impl<Pool: TransactionPool> BestFlashblocksBundles<Pool> {
self.current_block_num = current_block_num;

self.bundles = self.bundle_pool.get_bundles();
self.backrun_bundles = self.bundle_pool.get_backrun_bundles();
self.curr_bundles_idx = 0;
}

Expand Down Expand Up @@ -98,6 +102,10 @@ impl<Pool: TransactionPool> BundleBounds for BestFlashblocksBundles<Pool> {
}
}

fn get_backrun_bundle(&mut self, tx_hash: &TxHash) -> Option<&AcceptedBundle> {
self.backrun_bundles.get(tx_hash)
}

// TODO
/// Proxy to inner iterator
fn mark_invalid(&mut self, _bundle: &AcceptedBundle) {
Expand Down
2 changes: 2 additions & 0 deletions crates/op-rbuilder/src/traits.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use alloy_consensus::Header;
use alloy_primitives::TxHash;
use reth_node_api::{FullNodeComponents, FullNodeTypes, NodeTypes};
use reth_optimism_chainspec::OpChainSpec;
use reth_optimism_node::OpEngineTypes;
Expand Down Expand Up @@ -80,6 +81,7 @@ impl<T> ClientBounds for T where

pub trait BundleBounds {
fn next(&mut self, ctx: ()) -> Option<&AcceptedBundle>;
fn get_backrun_bundle(&mut self, tx_hash: &TxHash) -> Option<&AcceptedBundle>;

fn mark_invalid(&mut self, bundle: &AcceptedBundle);
}
Expand Down
Loading