|
5 | 5 | limits::FlashblockLimits, |
6 | 6 | publish::{PublishFlashblock, WebSocketSink}, |
7 | 7 | rpc::TransactionStatusRpc, |
| 8 | + signer::BuilderSigner, |
8 | 9 | state::FlashblockNumber, |
9 | 10 | stop::BreakAfterMaxFlashblocks, |
10 | 11 | }, |
|
18 | 19 | }, |
19 | 20 | reth_optimism_rpc::OpEthApiBuilder, |
20 | 21 | std::sync::Arc, |
21 | | - tracing::warn, |
22 | 22 | }; |
23 | 23 |
|
24 | 24 | mod args; |
@@ -96,54 +96,50 @@ fn build_pipeline( |
96 | 96 |
|
97 | 97 | let ws = Arc::new(WebSocketSink::new(cli_args.flashblocks_args.ws_address)?); |
98 | 98 |
|
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 | | - }; |
| 99 | + // TODO: Think about a better way to conditionally add steps so we don't |
| 100 | + // have to default to a random signer. |
| 101 | + let builder_signer = cli_args |
| 102 | + .builder_signer |
| 103 | + .clone() |
| 104 | + .unwrap_or(BuilderSigner::random()); |
127 | 105 |
|
128 | 106 | // Multiple steps need to access flashblock number state, so we need to |
129 | 107 | // initialize it outside |
130 | 108 | let flashblock_number = Arc::new(FlashblockNumber::new()); |
131 | 109 |
|
132 | | - let pipeline = Pipeline::<Flashblocks>::named("flashblocks") |
| 110 | + let pipeline = Pipeline::<Flashblocks>::named("top") |
133 | 111 | .with_step(OptimismPrologue) |
134 | | - .with_step(FlashtestationsPrologue::try_new( |
135 | | - cli_args.flashtestations.clone(), |
136 | | - cli_args.builder_signer.clone(), |
137 | | - )?) |
| 112 | + .with_step_if( |
| 113 | + cli_args.flashtestations.flashtestations_enabled |
| 114 | + && cli_args.builder_signer.is_some(), |
| 115 | + FlashtestationsPrologue::try_new( |
| 116 | + cli_args.flashtestations.clone(), |
| 117 | + builder_signer.clone(), |
| 118 | + )?, |
| 119 | + ) |
138 | 120 | .with_pipeline( |
139 | 121 | Loop, |
140 | | - Pipeline::default() |
| 122 | + Pipeline::named("n_flashblocks") |
141 | 123 | .with_pipeline( |
142 | 124 | Once, |
143 | | - Pipeline::default() |
| 125 | + Pipeline::named("single_flashblock") |
144 | 126 | .with_pipeline( |
145 | 127 | Loop, |
146 | | - flashblock_building_pipeline_steps |
| 128 | + Pipeline::named("flashblock_steps") |
| 129 | + .with_step(AppendOrders::from_pool(pool).with_ok_on_limit()) |
| 130 | + .with_step(OrderByPriorityFee::default()) |
| 131 | + .with_step_if( |
| 132 | + cli_args.revert_protection, |
| 133 | + RemoveRevertedTransactions::default(), |
| 134 | + ) |
| 135 | + .with_step(BreakAfterDeadline) |
| 136 | + .with_epilogue_if( |
| 137 | + cli_args.builder_signer.is_some(), |
| 138 | + BuilderEpilogue::with_signer(builder_signer.clone().into()) |
| 139 | + .with_message(|block| { |
| 140 | + format!("Block Number: {}", block.number()) |
| 141 | + }), |
| 142 | + ) |
147 | 143 | .with_epilogue(PublishFlashblock::new( |
148 | 144 | ws.clone(), |
149 | 145 | flashblock_number.clone(), |
|
0 commit comments