Skip to content

Commit e7b43b6

Browse files
authored
remove the option for standard building (#38)
1 parent 80264cc commit e7b43b6

File tree

13 files changed

+87
-151
lines changed

13 files changed

+87
-151
lines changed

src/args.rs

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ pub struct FlashblocksArgs {
8686
name = "WS_ADDRESS",
8787
env = "FLASHBLOCKS_WS_ADDRESS",
8888
num_args = 0..=1,
89-
default_missing_value = "0.0.0.0:10111"
89+
default_value = "0.0.0.0:10111"
9090
)]
91-
enabled: Option<SocketAddr>,
91+
pub ws_address: SocketAddr,
9292

9393
/// Should we calculate the state root for each flashblock
9494
#[arg(
@@ -109,18 +109,6 @@ impl Default for BuilderArgs {
109109
}
110110
}
111111

112-
impl FlashblocksArgs {
113-
/// Returns true if flashblocks are enabled.
114-
pub fn enabled(&self) -> bool {
115-
self.enabled.is_some()
116-
}
117-
118-
/// Returns the WebSocket address for flashblocks publishing socket.
119-
pub fn ws_address(&self) -> Option<SocketAddr> {
120-
self.enabled
121-
}
122-
}
123-
124112
/// This trait is used to extend Reth's CLI with additional functionality that
125113
/// are specific to the OP builder, such as populating default values for CLI
126114
/// arguments when running in the playground mode or checking the builder mode.
@@ -209,10 +197,12 @@ impl FlashblocksArgs {
209197
Self {
210198
interval: Duration::from_millis(250),
211199
leeway_time: Duration::from_millis(75),
212-
enabled: Some(
213-
SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, Self::get_available_port())
214-
.into(),
215-
),
200+
ws_address: SocketAddrV4::new(
201+
Ipv4Addr::UNSPECIFIED,
202+
Self::get_available_port(),
203+
)
204+
.into(),
205+
216206
calculate_state_root: true,
217207
}
218208
}
@@ -226,10 +216,12 @@ impl FlashblocksArgs {
226216
Self {
227217
interval,
228218
leeway_time,
229-
enabled: Some(
230-
SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, Self::get_available_port())
231-
.into(),
232-
),
219+
ws_address: SocketAddrV4::new(
220+
Ipv4Addr::UNSPECIFIED,
221+
Self::get_available_port(),
222+
)
223+
.into(),
224+
233225
calculate_state_root: true,
234226
}
235227
}

src/main.rs

Lines changed: 3 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -83,64 +83,6 @@ fn build_pipeline(
8383
cli_args: &BuilderArgs,
8484
pool: &OrderPool<Flashblocks>,
8585
) -> eyre::Result<Pipeline<Flashblocks>> {
86-
let pipeline = if cli_args.flashblocks_args.enabled() {
87-
build_flashblocks_pipeline(cli_args, pool)?
88-
} else {
89-
build_classic_pipeline(cli_args, pool)
90-
};
91-
pool.attach_pipeline(&pipeline);
92-
93-
Ok(pipeline)
94-
}
95-
96-
/// Classic block builder
97-
///
98-
/// Block building strategy that builds blocks using the classic approach by
99-
/// producing one block payload per CL payload job.
100-
fn build_classic_pipeline(
101-
cli_args: &BuilderArgs,
102-
pool: &OrderPool<Flashblocks>,
103-
) -> Pipeline<Flashblocks> {
104-
let pipeline = if cli_args.revert_protection {
105-
Pipeline::<Flashblocks>::named("classic")
106-
.with_prologue(OptimismPrologue)
107-
.with_pipeline(
108-
Loop,
109-
(
110-
AppendOrders::from_pool(pool),
111-
OrderByPriorityFee::default(),
112-
RemoveRevertedTransactions::default(),
113-
),
114-
)
115-
} else {
116-
Pipeline::<Flashblocks>::named("classic")
117-
.with_prologue(OptimismPrologue)
118-
.with_pipeline(
119-
Loop,
120-
(AppendOrders::from_pool(pool), OrderByPriorityFee::default()),
121-
)
122-
};
123-
124-
if let Some(ref signer) = cli_args.builder_signer {
125-
pipeline.with_epilogue(
126-
BuilderEpilogue::with_signer(signer.clone().into())
127-
.with_message(|block| format!("Block Number: {}", block.number())),
128-
)
129-
} else {
130-
warn!("BUILDER_SECRET_KEY is not specified, skipping builder transactions");
131-
pipeline
132-
}
133-
}
134-
135-
fn build_flashblocks_pipeline(
136-
cli_args: &BuilderArgs,
137-
pool: &OrderPool<Flashblocks>,
138-
) -> eyre::Result<Pipeline<Flashblocks>> {
139-
let socket_address = cli_args
140-
.flashblocks_args
141-
.ws_address()
142-
.expect("WebSocket address must be set for Flashblocks");
143-
14486
// how often a flashblock is published
14587
let interval = cli_args.flashblocks_args.interval;
14688

@@ -152,7 +94,7 @@ fn build_flashblocks_pipeline(
15294
// building and the payload job deadline that is given by the CL.
15395
let total_building_time = Minus(leeway_time);
15496

155-
let ws = Arc::new(WebSocketSink::new(socket_address)?);
97+
let ws = Arc::new(WebSocketSink::new(cli_args.flashblocks_args.ws_address)?);
15698

15799
let flashblock_building_pipeline_steps = (
158100
AppendOrders::from_pool(pool).with_ok_on_limit(),
@@ -208,7 +150,9 @@ fn build_flashblocks_pipeline(
208150
.with_step(BreakAfterMaxFlashblocks::new(flashblock_number)),
209151
)
210152
.with_limits(Scaled::default().deadline(total_building_time));
153+
211154
ws.watch_shutdown(&pipeline);
155+
pool.attach_pipeline(&pipeline);
212156

213157
Ok(pipeline)
214158
}

src/tests/args.rs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -56,28 +56,3 @@ fn test_leeway_time_invalid_format() {
5656
);
5757
}
5858
}
59-
60-
#[test]
61-
fn test_leeway_time_with_flashblocks_enabled() {
62-
let args = Cli::try_parse_from([
63-
"flashblocks",
64-
"node",
65-
"--flashblocks.leeway-time",
66-
"150ms",
67-
"--flashblocks",
68-
"127.0.0.1:8080",
69-
])
70-
.expect("Should parse successfully");
71-
72-
if let Commands::Node(node_command) = args.command {
73-
let flashblocks_args = &node_command.ext.flashblocks_args;
74-
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-
);
80-
} else {
81-
panic!("Expected Node command");
82-
}
83-
}

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 {
@@ -41,7 +41,7 @@ async fn blocks_with_txs_smoke() -> eyre::Result<()> {
4141
const BLOCKS: usize = 5;
4242
const TXS_PER_BLOCK: usize = 60;
4343

44-
let (node, ws_addr) = Flashblocks::test_node_with_flashblocks_on().await?;
44+
let (node, ws_addr) = Flashblocks::test_node().await?;
4545
let ws = WebSocketObserver::new(ws_addr).await?;
4646

4747
for i in 1..=BLOCKS {
@@ -103,7 +103,7 @@ async fn flashblock_timings_2000ms_block_time_0ms_leeway_time()
103103
const TXS_PER_BLOCK: usize = 60;
104104

105105
let (node, ws_addr) =
106-
Flashblocks::test_node_with_flashblocks_on_and_custom_leeway_time_and_interval(
106+
Flashblocks::test_node_with_custom_leeway_time_and_interval(
107107
Duration::from_millis(0),
108108
Duration::from_millis(250),
109109
)
@@ -154,7 +154,7 @@ async fn flashblock_timings_2000ms_block_time_75ms_leeway_time()
154154
-> eyre::Result<()> {
155155
const TXS_PER_BLOCK: usize = 60;
156156

157-
let (node, ws_addr) = Flashblocks::test_node_with_flashblocks_on().await?;
157+
let (node, ws_addr) = Flashblocks::test_node().await?;
158158
let ws = WebSocketObserver::new(ws_addr).await?;
159159

160160
// Create a block at the top of the timestamp second
@@ -202,7 +202,7 @@ async fn flashblock_timings_2000ms_block_time_500ms_leeway_time()
202202
const TXS_PER_BLOCK: usize = 60;
203203

204204
let (node, ws_addr) =
205-
Flashblocks::test_node_with_flashblocks_on_and_custom_leeway_time_and_interval(
205+
Flashblocks::test_node_with_custom_leeway_time_and_interval(
206206
Duration::from_millis(500),
207207
Duration::from_millis(500),
208208
)

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/ordering.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use {
1515
/// flashblock, but not the entire block.
1616
#[tokio::test]
1717
async fn txs_ordered_by_priority_fee() -> eyre::Result<()> {
18-
let node = Flashblocks::test_node().await?;
18+
let (node, _) = Flashblocks::test_node().await?;
1919

2020
let tx_tips = vec![100, 300, 200, 500, 400];
2121
let mut sent_txs = Vec::new();

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 fallible_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 fallible_reverted_included() -> eyre::Result<()> {
9696

9797
#[tokio::test]
9898
async fn fallible_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 fallible_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(

0 commit comments

Comments
 (0)