Skip to content

Commit 92b8f6a

Browse files
authored
Remove flashblocks conditional compilation (#67)
1 parent 6a6215e commit 92b8f6a

File tree

25 files changed

+2649
-2662
lines changed

25 files changed

+2649
-2662
lines changed

.github/workflows/checks.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,6 @@ jobs:
135135
- name: Run integration tests
136136
run: cargo test --package op-rbuilder --lib
137137

138-
- name: Build flashblocks rbuilder
139-
run: cargo build -p op-rbuilder --bin op-rbuilder --features flashblocks
140-
141-
- name: Run flashblocks builder integration tests
142-
run: cargo test --package op-rbuilder --lib --features flashblocks
143-
144138
- name: Aggregate playground logs
145139
# This steps fails if the test fails early and the playground logs dir has not been created
146140
if: ${{ failure() }}

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ lint: ## Run the linters
5151
test: ## Run the tests for rbuilder and op-rbuilder
5252
cargo test --verbose --features "$(FEATURES)"
5353
cargo test -p op-rbuilder --verbose --features "$(FEATURES)"
54-
cargo test -p op-rbuilder --verbose --features "$(FEATURES),flashblocks"
5554

5655
.PHONY: lt
5756
lt: lint test ## Run "lint" and "test"

crates/op-rbuilder/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ min-debug-logs = ["tracing/release_max_level_debug"]
132132
min-trace-logs = ["tracing/release_max_level_trace"]
133133

134134
testing = []
135-
flashblocks = []
136135

137136
[[bin]]
138137
name = "op-rbuilder"

crates/op-rbuilder/src/args/mod.rs

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,81 @@
1+
use crate::builders::BuilderMode;
2+
use clap::Parser;
3+
pub use op::OpRbuilderArgs;
4+
use playground::PlaygroundOptions;
5+
use reth_optimism_cli::{chainspec::OpChainSpecParser, commands::Commands};
6+
17
mod op;
28
mod playground;
39

4-
pub use op::OpRbuilderArgs;
5-
pub use playground::CliExt;
10+
/// This trait is used to extend Reth's CLI with additional functionality that
11+
/// are specific to the OP builder, such as populating default values for CLI arguments
12+
/// when running in the playground mode or checking the builder mode.
13+
///
14+
pub trait CliExt {
15+
/// Populates the default values for the CLI arguments when the user specifies
16+
/// the `--builder.playground` flag.
17+
fn populate_defaults(self) -> Self;
18+
19+
/// Returns the builder mode that the node is started with.
20+
fn builder_mode(&self) -> BuilderMode;
21+
22+
/// Returns the Cli instance with the parsed command line arguments
23+
/// and defaults populated if applicable.
24+
fn parsed() -> Self;
25+
}
26+
27+
pub type Cli = reth_optimism_cli::Cli<OpChainSpecParser, OpRbuilderArgs>;
28+
29+
impl CliExt for Cli {
30+
/// Checks if the node is started with the `--builder.playground` flag,
31+
/// and if so, populates the default values for the CLI arguments from the
32+
/// playground configuration.
33+
///
34+
/// The `--builder.playground` flag is used to populate the CLI arguments with
35+
/// default values for running the builder against the playground environment.
36+
///
37+
/// The values are populated from the default directory of the playground
38+
/// configuration, which is `$HOME/.playground/devnet/` by default.
39+
///
40+
/// Any manually specified CLI arguments by the user will override the defaults.
41+
fn populate_defaults(self) -> Self {
42+
let Commands::Node(ref node_command) = self.command else {
43+
// playground defaults are only relevant if running the node commands.
44+
return self;
45+
};
46+
47+
let Some(ref playground_dir) = node_command.ext.playground else {
48+
// not running in playground mode.
49+
return self;
50+
};
51+
52+
let options = match PlaygroundOptions::new(playground_dir) {
53+
Ok(options) => options,
54+
Err(e) => exit(e),
55+
};
56+
57+
options.apply(self)
58+
}
59+
60+
fn parsed() -> Self {
61+
Cli::parse().populate_defaults()
62+
}
63+
64+
/// Returns the type of builder implementation that the node is started with.
65+
/// Currently supports `Standard` and `Flashblocks` modes.
66+
fn builder_mode(&self) -> BuilderMode {
67+
if let Commands::Node(ref node_command) = self.command {
68+
if node_command.ext.enable_flashblocks {
69+
return BuilderMode::Flashblocks;
70+
}
71+
}
72+
BuilderMode::Standard
73+
}
74+
}
75+
76+
/// Following clap's convention, a failure to parse the command line arguments
77+
/// will result in terminating the program with a non-zero exit code.
78+
fn exit(error: eyre::Report) -> ! {
79+
eprintln!("{error}");
80+
std::process::exit(-1);
81+
}

crates/op-rbuilder/src/args/op.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ pub struct OpRbuilderArgs {
1919
/// Builder secret key for signing last transaction in block
2020
#[arg(long = "rollup.builder-secret-key", env = "BUILDER_SECRET_KEY")]
2121
pub builder_signer: Option<Signer>,
22+
23+
/// When set to true, the builder will build flashblocks
24+
/// and will build standard blocks at the chain block time.
25+
///
26+
/// The default value will change in the future once the flashblocks
27+
/// feature is stable.
28+
#[arg(
29+
long = "rollup.enable-flashblocks",
30+
default_value = "false",
31+
env = "ENABLE_FLASHBLOCKS"
32+
)]
33+
pub enable_flashblocks: bool,
34+
2235
/// Websocket port for flashblock payload builder
2336
#[arg(
2437
long = "rollup.flashblocks-ws-url",

crates/op-rbuilder/src/args/playground.rs

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
//! directory to use. This is useful for testing against different playground
2828
//! configurations.
2929
30-
use super::OpRbuilderArgs;
3130
use alloy_primitives::hex;
3231
use clap::{parser::ValueSource, CommandFactory};
3332
use core::{
@@ -49,47 +48,9 @@ use std::{
4948
};
5049
use url::{Host, Url};
5150

52-
/// This trait is used to extend Reth's CLI with additional functionality that
53-
/// populates the default values for the command line arguments when the user
54-
/// specifies that they want to use the playground.
55-
///
56-
/// The `--builder.playground` flag is used to populate the CLI arguments with
57-
/// default values for running the builder against the playground environment.
58-
///
59-
/// The values are populated from the default directory of the playground
60-
/// configuration, which is `$HOME/.playground/devnet/` by default.
61-
///
62-
/// Any manually specified CLI arguments by the user will override the defaults.
63-
pub trait CliExt {
64-
/// Populates the default values for the CLI arguments when the user specifies
65-
/// the `--builder.playground` flag.
66-
fn populate_defaults(self) -> Self;
67-
}
68-
69-
type Cli = reth_optimism_cli::Cli<OpChainSpecParser, OpRbuilderArgs>;
70-
71-
impl CliExt for Cli {
72-
fn populate_defaults(self) -> Self {
73-
let Commands::Node(ref node_command) = self.command else {
74-
// playground defaults are only relevant if running the node commands.
75-
return self;
76-
};
77-
78-
let Some(ref playground_dir) = node_command.ext.playground else {
79-
// not running in playground mode.
80-
return self;
81-
};
51+
use super::Cli;
8252

83-
let options = match PlaygroundOptions::new(playground_dir) {
84-
Ok(options) => options,
85-
Err(e) => exit(e),
86-
};
87-
88-
options.apply(self)
89-
}
90-
}
91-
92-
struct PlaygroundOptions {
53+
pub struct PlaygroundOptions {
9354
/// Sets node.chain in NodeCommand
9455
pub chain: Arc<OpChainSpec>,
9556

@@ -210,13 +171,6 @@ impl PlaygroundOptions {
210171
}
211172
}
212173

213-
/// Following clap's convention, a failure to parse the command line arguments
214-
/// will result in terminating the program with a non-zero exit code.
215-
fn exit(error: eyre::Report) -> ! {
216-
eprintln!("{error}");
217-
std::process::exit(-1);
218-
}
219-
220174
fn existing_path(base: &Path, relative: &str) -> Result<String> {
221175
let path = base.join(relative);
222176
if path.exists() {

0 commit comments

Comments
 (0)