Skip to content

Commit 452582a

Browse files
committed
chore: move build_bundle_body to SimResult
1 parent ac8b10d commit 452582a

2 files changed

Lines changed: 18 additions & 26 deletions

File tree

src/tasks/block/sim.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{
55
config::{BuilderConfig, HostProvider, RuProvider},
66
tasks::env::SimEnv,
77
};
8-
use alloy::consensus::Header;
8+
use alloy::{consensus::Header, eips::Encodable2718, primitives::Bytes};
99
use init4_bin_base::{
1010
deps::metrics::{counter, histogram},
1111
utils::calc::SlotCalculator,
@@ -62,6 +62,21 @@ impl SimResult {
6262
pub fn clone_span(&self) -> Span {
6363
self.sim_env.clone_span()
6464
}
65+
66+
/// Constructs the MEV bundle body from host transactions and the submission transaction.
67+
///
68+
/// Combines all host transactions from the rollup block with the prepared rollup block
69+
/// submission transaction, wrapping each as a non-revertible bundle item.
70+
///
71+
/// The rollup block transaction is always included and placed last in the bundle.
72+
pub fn build_bundle_body(&self, block_tx_bytes: Bytes) -> Vec<Bytes> {
73+
self.block
74+
.host_transactions()
75+
.iter()
76+
.map(|tx| tx.encoded_2718().into())
77+
.chain(std::iter::once(block_tx_bytes))
78+
.collect()
79+
}
6580
}
6681

6782
/// A task that builds blocks based on incoming [`SimEnv`]s and a simulation

src/tasks/submit/flashbots.rs

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ use crate::{
66
tasks::{block::sim::SimResult, submit::SubmitPrep},
77
};
88
use alloy::{
9-
consensus::TxEnvelope,
10-
eips::Encodable2718,
11-
primitives::{Bytes, TxHash},
12-
providers::ext::MevApi,
9+
consensus::TxEnvelope, eips::Encodable2718, primitives::TxHash, providers::ext::MevApi,
1310
rpc::types::mev::EthSendBundle,
1411
};
1512
use init4_bin_base::{deps::metrics::counter, utils::signer::LocalOrAws};
@@ -84,7 +81,7 @@ impl FlashbotsTask {
8481
let tx_bytes = block_tx.encoded_2718().into();
8582

8683
// Build the bundle body with the block_tx bytes as the last transaction in the bundle.
87-
let txs = self.build_bundle_body(sim_result, tx_bytes);
84+
let txs = sim_result.build_bundle_body(tx_bytes);
8885

8986
// Create the MEV bundle (valid only in the specific host block)
9087
Ok(EthSendBundle {
@@ -132,26 +129,6 @@ impl FlashbotsTask {
132129
}
133130
}
134131

135-
/// Constructs the MEV bundle body from host transactions and the submission transaction.
136-
///
137-
/// Combines all host transactions from the rollup block with the prepared rollup block
138-
/// submission transaction, wrapping each as a non-revertible bundle item.
139-
///
140-
/// The rollup block transaction is placed last in the bundle.
141-
fn build_bundle_body(
142-
&self,
143-
sim_result: &SimResult,
144-
tx_bytes: alloy::primitives::Bytes,
145-
) -> Vec<Bytes> {
146-
sim_result
147-
.block
148-
.host_transactions()
149-
.iter()
150-
.map(|tx| tx.encoded_2718().into())
151-
.chain(std::iter::once(tx_bytes))
152-
.collect()
153-
}
154-
155132
/// Main task loop that processes simulation results and submits bundles to Flashbots.
156133
///
157134
/// Receives `SimResult`s from the inbound channel, prepares MEV bundles, and submits

0 commit comments

Comments
 (0)