Skip to content

Commit 818857d

Browse files
committed
remove the option for standard building
1 parent d6597c9 commit 818857d

File tree

12 files changed

+88
-121
lines changed

12 files changed

+88
-121
lines changed

src/args.rs

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ pub struct FlashblocksArgs {
8383
name = "WS_ADDRESS",
8484
env = "FLASHBLOCKS_WS_ADDRESS",
8585
num_args = 0..=1,
86-
default_missing_value = "0.0.0.0:10111"
86+
default_value = "0.0.0.0:10111"
8787
)]
88-
enabled: Option<SocketAddr>,
88+
pub ws_address: SocketAddr,
8989

9090
/// Should we calculate the state root for each flashblock
9191
#[arg(
@@ -106,18 +106,6 @@ impl Default for BuilderArgs {
106106
}
107107
}
108108

109-
impl FlashblocksArgs {
110-
/// Returns true if flashblocks are enabled.
111-
pub fn enabled(&self) -> bool {
112-
self.enabled.is_some()
113-
}
114-
115-
/// Returns the WebSocket address for flashblocks publishing socket.
116-
pub fn ws_address(&self) -> Option<SocketAddr> {
117-
self.enabled
118-
}
119-
}
120-
121109
/// This type is used to store the builder's secret key for signing the last
122110
/// transaction in the block.
123111
#[derive(Debug, Clone, Deref, FromStr, Into, From)]
@@ -220,10 +208,12 @@ impl FlashblocksArgs {
220208
Self {
221209
interval: Duration::from_millis(250),
222210
leeway_time: Duration::from_millis(75),
223-
enabled: Some(
224-
SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, Self::get_available_port())
225-
.into(),
226-
),
211+
ws_address: SocketAddrV4::new(
212+
Ipv4Addr::UNSPECIFIED,
213+
Self::get_available_port(),
214+
)
215+
.into(),
216+
227217
calculate_state_root: true,
228218
}
229219
}
@@ -237,10 +227,12 @@ impl FlashblocksArgs {
237227
Self {
238228
interval,
239229
leeway_time,
240-
enabled: Some(
241-
SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, Self::get_available_port())
242-
.into(),
243-
),
230+
ws_address: SocketAddrV4::new(
231+
Ipv4Addr::UNSPECIFIED,
232+
Self::get_available_port(),
233+
)
234+
.into(),
235+
244236
calculate_state_root: true,
245237
}
246238
}

src/main.rs

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -80,54 +80,6 @@ fn build_pipeline(
8080
cli_args: &BuilderArgs,
8181
pool: &OrderPool<Flashblocks>,
8282
) -> eyre::Result<Pipeline<Flashblocks>> {
83-
let pipeline = if cli_args.flashblocks_args.enabled() {
84-
build_flashblocks_pipeline(cli_args, pool)?
85-
} else {
86-
build_classic_pipeline(cli_args, pool)
87-
};
88-
pool.attach_pipeline(&pipeline);
89-
90-
Ok(pipeline)
91-
}
92-
93-
/// Classic block builder
94-
///
95-
/// Block building strategy that builds blocks using the classic approach by
96-
/// producing one block payload per CL payload job.
97-
fn build_classic_pipeline(
98-
cli_args: &BuilderArgs,
99-
pool: &OrderPool<Flashblocks>,
100-
) -> Pipeline<Flashblocks> {
101-
if cli_args.revert_protection {
102-
Pipeline::<Flashblocks>::named("classic")
103-
.with_prologue(OptimismPrologue)
104-
.with_pipeline(
105-
Loop,
106-
(
107-
AppendOrders::from_pool(pool),
108-
OrderByPriorityFee::default(),
109-
RemoveRevertedTransactions::default(),
110-
),
111-
)
112-
} else {
113-
Pipeline::<Flashblocks>::named("classic")
114-
.with_prologue(OptimismPrologue)
115-
.with_pipeline(
116-
Loop,
117-
(AppendOrders::from_pool(pool), OrderByPriorityFee::default()),
118-
)
119-
}
120-
}
121-
122-
fn build_flashblocks_pipeline(
123-
cli_args: &BuilderArgs,
124-
pool: &OrderPool<Flashblocks>,
125-
) -> eyre::Result<Pipeline<Flashblocks>> {
126-
let socket_address = cli_args
127-
.flashblocks_args
128-
.ws_address()
129-
.expect("WebSocket address must be set for Flashblocks");
130-
13183
// how often a flashblock is published
13284
let interval = cli_args.flashblocks_args.interval;
13385

@@ -139,7 +91,7 @@ fn build_flashblocks_pipeline(
13991
// building and the payload job deadline that is given by the CL.
14092
let total_building_time = Minus(leeway_time);
14193

142-
let ws = Arc::new(WebSocketSink::new(socket_address)?);
94+
let ws = Arc::new(WebSocketSink::new(cli_args.flashblocks_args.ws_address)?);
14395

14496
let flashblock_building_pipeline_steps = (
14597
AppendOrders::from_pool(pool).with_ok_on_limit(),
@@ -191,7 +143,9 @@ fn build_flashblocks_pipeline(
191143
.with_step(BreakAfterMaxFlashblocks::new(flashblock_number)),
192144
)
193145
.with_limits(Scaled::default().deadline(total_building_time));
146+
194147
ws.watch_shutdown(&pipeline);
148+
pool.attach_pipeline(&pipeline);
195149

196150
Ok(pipeline)
197151
}

src/tests/args.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fn test_leeway_time_invalid_format() {
5858
}
5959

6060
#[test]
61-
fn test_leeway_time_with_flashblocks_enabled() {
61+
fn test_leeway_time() {
6262
let args = Cli::try_parse_from([
6363
"flashblocks",
6464
"node",
@@ -72,11 +72,7 @@ fn test_leeway_time_with_flashblocks_enabled() {
7272
if let Commands::Node(node_command) = args.command {
7373
let flashblocks_args = &node_command.ext.flashblocks_args;
7474
assert_eq!(flashblocks_args.leeway_time, Duration::from_millis(150));
75-
assert!(flashblocks_args.enabled());
76-
assert_eq!(
77-
flashblocks_args.ws_address().unwrap().to_string(),
78-
"127.0.0.1:8080"
79-
);
75+
assert_eq!(flashblocks_args.ws_address.to_string(), "127.0.0.1:8080");
8076
} else {
8177
panic!("Expected Node command");
8278
}

src/tests/bundle.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use {
1414

1515
#[tokio::test]
1616
async fn one_valid_tx_included() -> eyre::Result<()> {
17-
let node = Flashblocks::test_node().await?;
17+
let (node, _) = Flashblocks::test_node().await?;
1818

1919
let bundle_with_one_tx = random_valid_bundle(1);
2020
let bundle_hash = bundle_with_one_tx.hash();
@@ -40,7 +40,7 @@ async fn one_valid_tx_included() -> eyre::Result<()> {
4040

4141
#[tokio::test]
4242
async fn two_valid_txs_included() -> eyre::Result<()> {
43-
let node = Flashblocks::test_node().await?;
43+
let (node, _) = Flashblocks::test_node().await?;
4444

4545
let bundle_with_two_txs = random_valid_bundle(2);
4646
let bundle_hash = bundle_with_two_txs.hash();
@@ -67,7 +67,7 @@ async fn two_valid_txs_included() -> eyre::Result<()> {
6767

6868
#[tokio::test]
6969
async fn min_block_timestamp_constraint() -> eyre::Result<()> {
70-
let node = Flashblocks::test_node().await?;
70+
let (node, _) = Flashblocks::test_node().await?;
7171

7272
let mut bundle_with_one_tx = random_valid_bundle(1);
7373
bundle_with_one_tx.min_block_number = Some(3);

src/tests/flashblocks.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use {
1010

1111
#[tokio::test]
1212
async fn empty_blocks_smoke() -> eyre::Result<()> {
13-
let (node, ws_addr) = Flashblocks::test_node_with_flashblocks_on().await?;
13+
let (node, ws_addr) = Flashblocks::test_node().await?;
1414
let ws = WebSocketObserver::new(ws_addr).await?;
1515

1616
for i in 1..=5 {
@@ -38,7 +38,7 @@ async fn blocks_with_txs_smoke() -> eyre::Result<()> {
3838
const BLOCKS: usize = 5;
3939
const TXS_PER_BLOCK: usize = 60;
4040

41-
let (node, ws_addr) = Flashblocks::test_node_with_flashblocks_on().await?;
41+
let (node, ws_addr) = Flashblocks::test_node().await?;
4242
let ws = WebSocketObserver::new(ws_addr).await?;
4343

4444
for i in 1..=BLOCKS {
@@ -98,7 +98,7 @@ async fn flashblock_timings_2000ms_block_time_0ms_leeway_time()
9898
const TXS_PER_BLOCK: usize = 60;
9999

100100
let (node, ws_addr) =
101-
Flashblocks::test_node_with_flashblocks_on_and_custom_leeway_time_and_interval(
101+
Flashblocks::test_node_with_custom_leeway_time_and_interval(
102102
Duration::from_millis(0),
103103
Duration::from_millis(250),
104104
)
@@ -149,7 +149,7 @@ async fn flashblock_timings_2000ms_block_time_75ms_leeway_time()
149149
-> eyre::Result<()> {
150150
const TXS_PER_BLOCK: usize = 60;
151151

152-
let (node, ws_addr) = Flashblocks::test_node_with_flashblocks_on().await?;
152+
let (node, ws_addr) = Flashblocks::test_node().await?;
153153
let ws = WebSocketObserver::new(ws_addr).await?;
154154

155155
// Create a block at the top of the timestamp second
@@ -197,7 +197,7 @@ async fn flashblock_timings_2000ms_block_time_500ms_leeway_time()
197197
const TXS_PER_BLOCK: usize = 60;
198198

199199
let (node, ws_addr) =
200-
Flashblocks::test_node_with_flashblocks_on_and_custom_leeway_time_and_interval(
200+
Flashblocks::test_node_with_custom_leeway_time_and_interval(
201201
Duration::from_millis(500),
202202
Duration::from_millis(500),
203203
)

src/tests/limits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ async fn run_test(
3131
const TXS_PER_BLOCK: usize = 60;
3232

3333
let (node, ws_addr) =
34-
Flashblocks::test_node_with_flashblocks_on_and_custom_leeway_time_and_interval(
34+
Flashblocks::test_node_with_custom_leeway_time_and_interval(
3535
leeway_time,
3636
flashblocks_interval,
3737
)

src/tests/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use {
2-
crate::{args::BuilderArgs, bundle::FlashblocksBundle},
2+
crate::bundle::FlashblocksBundle,
33
rand::{Rng, rng},
44
rblib::{
55
alloy::{

src/tests/revert.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use {
1919

2020
#[tokio::test]
2121
async fn critical_reverted_tx_not_included() -> eyre::Result<()> {
22-
let node = Flashblocks::test_node().await?;
22+
let (node, _) = Flashblocks::test_node().await?;
2323

2424
let bundle_without_reverts = random_valid_bundle(1);
2525
let bundle_with_reverts = random_bundle_with_reverts(0, 1);
@@ -54,7 +54,7 @@ async fn critical_reverted_tx_not_included() -> eyre::Result<()> {
5454

5555
#[tokio::test]
5656
async fn faliable_reverted_included() -> eyre::Result<()> {
57-
let node = Flashblocks::test_node().await?;
57+
let (node, _) = Flashblocks::test_node().await?;
5858

5959
// create a bundle with one valid tx
6060
let bundle_without_reverts = random_valid_bundle(1);
@@ -96,7 +96,7 @@ async fn faliable_reverted_included() -> eyre::Result<()> {
9696

9797
#[tokio::test]
9898
async fn faliable_optional_reverted_not_included() -> eyre::Result<()> {
99-
let node = Flashblocks::test_node().await?;
99+
let (node, _) = Flashblocks::test_node().await?;
100100

101101
// create a bundle with one valid and one reverting tx
102102
let mut bundle_with_reverts = random_bundle_with_reverts(1, 1);
@@ -127,11 +127,7 @@ async fn faliable_optional_reverted_not_included() -> eyre::Result<()> {
127127

128128
#[tokio::test]
129129
async fn when_disabled_reverted_txs_are_included() -> eyre::Result<()> {
130-
let node = Flashblocks::test_node_with_cli_args(BuilderArgs {
131-
revert_protection: false,
132-
..Default::default()
133-
})
134-
.await?;
130+
let (node, _) = Flashblocks::test_node_with_revert_protection_off().await?;
135131

136132
// create a bundle with one valid and one reverting tx
137133
let mut bundle_with_reverts = random_bundle_with_reverts(1, 1);

src/tests/rpc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ macro_rules! assert_ineligible {
2929
/// should be rejected by the RPC before making it to the orders pool.
3030
#[tokio::test]
3131
async fn max_block_number_in_past() -> eyre::Result<()> {
32-
let node = Flashblocks::test_node().await?;
32+
let (node, _) = Flashblocks::test_node().await?;
3333

3434
let block = node.next_block().await?;
3535
assert_eq!(block.number(), 1);
@@ -63,7 +63,7 @@ async fn max_block_number_in_past() -> eyre::Result<()> {
6363
#[tokio::test]
6464
async fn max_block_timestamp_in_past() -> eyre::Result<()> {
6565
// node at genesis, block 0
66-
let node = Flashblocks::test_node().await?;
66+
let (node, _) = Flashblocks::test_node().await?;
6767
let genesis_timestamp = node.config().chain.genesis_timestamp();
6868
let mut bundle = random_valid_bundle(1);
6969
bundle.max_timestamp = Some(genesis_timestamp.saturating_sub(1));
@@ -81,7 +81,7 @@ async fn max_block_timestamp_in_past() -> eyre::Result<()> {
8181

8282
#[tokio::test]
8383
async fn empty_bundle_rejected_by_rpc() -> eyre::Result<()> {
84-
let node = Flashblocks::test_node().await?;
84+
let (node, _) = Flashblocks::test_node().await?;
8585

8686
let empty_bundle = FlashblocksBundle::with_transactions(vec![]);
8787
let result = BundlesApiClient::<Flashblocks>::send_bundle(

src/tests/standard.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use {
1818
#[tokio::test]
1919
async fn chain_produces_empty_blocks() -> eyre::Result<()> {
2020
// builders signer is not configured, so won't produce a builder tx
21-
let node = Flashblocks::test_node().await?;
21+
let (node, _) = Flashblocks::test_node().await?;
2222

2323
for i in 1..5 {
2424
let block = node.next_block().await?;
@@ -38,7 +38,7 @@ async fn chain_produces_blocks_with_txs() -> eyre::Result<()> {
3838
const TXS_PER_BLOCK: usize = 5;
3939

4040
// builders signer is not configured, so won't produce a builder tx
41-
let node = Flashblocks::test_node().await?;
41+
let (node, _) = Flashblocks::test_node().await?;
4242

4343
for i in 1..=BLOCKS {
4444
let mut txs = Vec::with_capacity(TXS_PER_BLOCK);
@@ -65,7 +65,7 @@ async fn chain_produces_blocks_with_txs() -> eyre::Result<()> {
6565
/// when the builder signer is provided in the CLI arguments.
6666
#[tokio::test]
6767
async fn blocks_have_builder_tx() -> eyre::Result<()> {
68-
let node = Flashblocks::test_node_with_builder_signer().await?;
68+
let (node, _) = Flashblocks::test_node_with_builder_signer().await?;
6969

7070
let block = node.next_block().await?;
7171
debug!("produced block: {block:#?}");

0 commit comments

Comments
 (0)