Skip to content

Commit 51d75ab

Browse files
committed
chore: clean up pipeline with conditional steps
1 parent a871ada commit 51d75ab

File tree

3 files changed

+32
-52
lines changed

3 files changed

+32
-52
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jemalloc = ["rblib/jemalloc"]
3434
debug = ["tokio/full", "tokio/tracing", "dep:console-subscriber"]
3535

3636
[dependencies]
37-
rblib = { git = "https://github.com/flashbots/rblib", rev = "b0e1ba3cfba5e190479e6dbcc95889422f0444ad" }
37+
rblib = { git = "https://github.com/flashbots/rblib", rev = "66c5c15a8834a6f677bec0d6b34f54ffc7cdd4ff" }
3838

3939
futures = "0.3"
4040
tokio = "1.46"
@@ -77,7 +77,7 @@ console-subscriber = { version = "0.4", optional = true }
7777
tracing-subscriber = "0.3.20"
7878

7979
[dev-dependencies]
80-
rblib = { git = "https://github.com/flashbots/rblib", rev = "b0e1ba3cfba5e190479e6dbcc95889422f0444ad", features = [
80+
rblib = { git = "https://github.com/flashbots/rblib", rev = "66c5c15a8834a6f677bec0d6b34f54ffc7cdd4ff", features = [
8181
"test-utils",
8282
] }
8383

src/flashtestations/step.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,9 @@ struct State {
3535
impl FlashtestationsPrologue {
3636
pub fn try_new(
3737
args: FlashtestationsArgs,
38-
builder_key: Option<BuilderSigner>,
38+
builder_key: BuilderSigner,
3939
) -> eyre::Result<Self> {
40-
if !args.flashtestations_enabled {
41-
return Ok(Self {
42-
manager: None,
43-
state: Arc::default(),
44-
});
45-
}
46-
47-
let manager = FlashtestationsManager::try_new(
48-
args,
49-
builder_key.context("builder key required for flashtestations")?,
50-
)?;
40+
let manager = FlashtestationsManager::try_new(args, builder_key)?;
5141

5242
Ok(Self {
5343
manager: Some(manager),

src/main.rs

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use {
1818
},
1919
reth_optimism_rpc::OpEthApiBuilder,
2020
std::sync::Arc,
21-
tracing::warn,
2221
};
2322

2423
mod args;
@@ -96,54 +95,45 @@ fn build_pipeline(
9695

9796
let ws = Arc::new(WebSocketSink::new(cli_args.flashblocks_args.ws_address)?);
9897

99-
let flashblock_building_pipeline_steps = if cli_args.revert_protection {
100-
(
101-
AppendOrders::from_pool(pool).with_ok_on_limit(),
102-
OrderByPriorityFee::default(),
103-
RemoveRevertedTransactions::default(),
104-
BreakAfterDeadline,
105-
)
106-
.into_pipeline()
107-
} else {
108-
(
109-
AppendOrders::from_pool(pool).with_ok_on_limit(),
110-
OrderByPriorityFee::default(),
111-
BreakAfterDeadline,
112-
)
113-
.into_pipeline()
114-
};
115-
116-
let flashblock_building_pipeline_steps = if let Some(ref signer) =
117-
cli_args.builder_signer
118-
{
119-
flashblock_building_pipeline_steps.with_epilogue(
120-
BuilderEpilogue::with_signer(signer.clone().into())
121-
.with_message(|block| format!("Block Number: {}", block.number())),
122-
)
123-
} else {
124-
warn!("BUILDER_SECRET_KEY is not specified, skipping builder transactions");
125-
flashblock_building_pipeline_steps
126-
};
127-
12898
// Multiple steps need to access flashblock number state, so we need to
12999
// initialize it outside
130100
let flashblock_number = Arc::new(FlashblockNumber::new());
131101

132-
let pipeline = Pipeline::<Flashblocks>::named("flashblocks")
102+
let pipeline = Pipeline::<Flashblocks>::named("top")
133103
.with_step(OptimismPrologue)
134-
.with_step(FlashtestationsPrologue::try_new(
135-
cli_args.flashtestations.clone(),
136-
cli_args.builder_signer.clone(),
137-
)?)
104+
.with_step_if(
105+
cli_args.flashtestations.flashtestations_enabled
106+
&& cli_args.builder_signer.is_some(),
107+
FlashtestationsPrologue::try_new(
108+
cli_args.flashtestations.clone(),
109+
cli_args.builder_signer.clone().unwrap(),
110+
)?,
111+
)
138112
.with_pipeline(
139113
Loop,
140-
Pipeline::default()
114+
Pipeline::named("n_flashblocks")
141115
.with_pipeline(
142116
Once,
143-
Pipeline::default()
117+
Pipeline::named("single_flashblock")
144118
.with_pipeline(
145119
Loop,
146-
flashblock_building_pipeline_steps
120+
Pipeline::named("flashblock_steps")
121+
.with_step(AppendOrders::from_pool(pool).with_ok_on_limit())
122+
.with_step(OrderByPriorityFee::default())
123+
.with_step_if(
124+
cli_args.revert_protection,
125+
RemoveRevertedTransactions::default(),
126+
)
127+
.with_step(BreakAfterDeadline)
128+
.with_epilogue_if(
129+
cli_args.builder_signer.is_some(),
130+
BuilderEpilogue::with_signer(
131+
cli_args.builder_signer.clone().unwrap().clone().into(),
132+
)
133+
.with_message(|block| {
134+
format!("Block Number: {}", block.number())
135+
}),
136+
)
147137
.with_epilogue(PublishFlashblock::new(
148138
ws.clone(),
149139
flashblock_number.clone(),

0 commit comments

Comments
 (0)