@@ -107,19 +107,10 @@ pub trait BlockBuildingSink: std::fmt::Debug + Send + Sync {
107107pub struct SubmissionConfig {
108108 pub chain_spec : Arc < ChainSpec > ,
109109 pub signer : BLSBlockSigner ,
110-
111- pub optimistic_config : Option < OptimisticConfig > ,
112110 pub optimistic_v3_config : Option < OptimisticV3Config > ,
113111 pub bid_observer : Box < dyn BidObserver + Send + Sync > ,
114112}
115113
116- /// Configuration for optimistic block submission to relays.
117- #[ derive( Debug , Clone ) ]
118- pub struct OptimisticConfig {
119- pub signer : BLSBlockSigner ,
120- pub max_bid_value : U256 ,
121- }
122-
123114/// Configuration for optimistic V3.
124115#[ derive( Debug , Clone ) ]
125116pub struct OptimisticV3Config {
@@ -160,19 +151,6 @@ async fn run_submit_to_relays_job(
160151 . collect :: < Vec < _ > > ( ) ,
161152 ) ;
162153
163- let ( regular_relays, optimistic_relays) = relays
164- . into_iter ( )
165- . partition :: < Vec < _ > , _ > ( |relay| !relay. optimistic ( ) ) ;
166-
167- let regular_relays_ids = regular_relays
168- . iter ( )
169- . map ( |relay| relay. id ( ) )
170- . collect :: < Vec < _ > > ( ) ;
171- let optimistic_relays_ids = optimistic_relays
172- . iter ( )
173- . map ( |relay| relay. id ( ) )
174- . collect :: < Vec < _ > > ( ) ;
175-
176154 let mut last_bid_hash = None ;
177155 ' submit: loop {
178156 tokio:: select! {
@@ -210,18 +188,6 @@ async fn run_submit_to_relays_job(
210188 . filter ( |o| !o. order . is_tx ( ) )
211189 . count ( ) ;
212190
213- // Only enable the optimistic config for this block if the bid value is below the max bid value
214- let optimistic_config = config
215- . optimistic_config
216- . as_ref ( )
217- . and_then ( |optimistic_config| {
218- if block. trace . bid_value < optimistic_config. max_bid_value {
219- Some ( optimistic_config)
220- } else {
221- None
222- }
223- } ) ;
224-
225191 // SAFETY: UNIX timestamp in nanos won't exceed u64::MAX until year 2554
226192 let sequence = OffsetDateTime :: now_utc ( ) . unix_timestamp_nanos ( ) as u64 ;
227193 let executed_orders = block
@@ -254,8 +220,7 @@ async fn run_submit_to_relays_job(
254220 gas = block. sealed_block. gas_used,
255221 block_id = block. trace. build_block_id. 0 ,
256222 builder_name = block. builder_name,
257- regular_relays_ids = ?regular_relays_ids,
258- optimistic_relays_ids = ?optimistic_relays_ids,
223+ ?relay_set
259224 ) ;
260225 info ! (
261226 parent: & submission_span,
@@ -280,99 +245,49 @@ async fn run_submit_to_relays_job(
280245 latency_ms = latency. whole_milliseconds( ) ,
281246 "Submitting bid" ,
282247 ) ;
283- inc_initiated_submissions ( optimistic_config . is_some ( ) ) ;
248+ inc_initiated_submissions ( ) ;
284249
285250 let execution_payload = block_to_execution_payload (
286251 & config. chain_spec ,
287252 & slot_data. payload_attributes_event . data ,
288253 & block. sealed_block ,
289254 ) ;
290- let ( regular_request, optimistic_request) = {
291- let mut regular = None ;
292- if optimistic_config. is_none ( ) || !regular_relays. is_empty ( ) {
293- regular = create_submit_block_request (
294- & config. signer ,
295- & config. chain_spec ,
296- & slot_data,
297- & block,
298- & execution_payload,
299- )
300- . inspect_err ( |error| {
301- error ! ( parent: & submission_span, ?error, "Error creating regular submit block request" ) ;
302- } )
303- . ok ( ) ;
304- }
305-
306- let mut optimistic = None ;
307- if let Some ( optimistic_config) =
308- optimistic_config. filter ( |_| !optimistic_relays. is_empty ( ) )
309- {
310- optimistic = create_submit_block_request (
311- & optimistic_config. signer ,
312- & config. chain_spec ,
313- & slot_data,
314- & block,
315- & execution_payload,
316- ) . inspect_err ( |error| {
317- error ! ( parent: & submission_span, ?error, "Error creating optimistic submit block request" ) ;
318- } )
319- . ok ( ) ;
255+ let request = match create_submit_block_request (
256+ & config. signer ,
257+ & config. chain_spec ,
258+ & slot_data,
259+ & block,
260+ & execution_payload,
261+ ) {
262+ Ok ( request) => request,
263+ Err ( error) => {
264+ error ! ( parent: & submission_span, ?error, "Error creating submit block request" ) ;
265+ continue ' submit;
320266 }
321-
322- ( regular, optimistic)
323267 } ;
324268
325- if regular_request. is_none ( ) && optimistic_request. is_none ( ) {
326- let regular_relays_len = regular_relays. len ( ) ;
327- let optimistic_relays_len = optimistic_relays. len ( ) ;
328- error ! ( parent: & submission_span, regular_relays_len, optimistic_relays_len, "Unable to construct request from the built block" ) ;
329- continue ' submit;
330- }
331-
332269 mark_submission_start_time ( block. trace . orders_sealed_at ) ;
333- if let Some ( request) = & regular_request {
334- submit_block_to_relays (
335- request. clone ( ) ,
336- & bid_metadata,
337- & block. bid_adjustments ,
338- & regular_relays,
339- & slot_data. relay_registrations ,
340- false ,
341- & config. optimistic_v3_config ,
342- & submission_span,
343- & cancel,
344- )
345- }
270+ submit_block_to_relays (
271+ request. clone ( ) ,
272+ & bid_metadata,
273+ & block. bid_adjustments ,
274+ & relays,
275+ & slot_data. relay_registrations ,
276+ & config. optimistic_v3_config ,
277+ & submission_span,
278+ & cancel,
279+ ) ;
346280
347- let optimistic_request = optimistic_request
348- . map ( |req| ( req, true ) )
349- // non-optimistic submission to optimistic relays
350- . or ( regular_request. map ( |req| ( req, false ) ) ) ;
351- if let Some ( ( request, optimistic) ) = optimistic_request {
352- submit_block_to_relays (
353- request. clone ( ) ,
354- & bid_metadata,
355- & block. bid_adjustments ,
356- & optimistic_relays,
357- & slot_data. relay_registrations ,
358- optimistic,
359- & config. optimistic_v3_config ,
360- & submission_span,
361- & cancel,
281+ submission_span. in_scope ( || {
282+ config. bid_observer . block_submitted (
283+ & slot_data,
284+ request,
285+ Arc :: new ( block. trace ) ,
286+ builder_name,
287+ bid_metadata. value . top_competitor_bid . unwrap_or_default ( ) ,
288+ & relay_set,
362289 ) ;
363-
364- submission_span. in_scope ( || {
365- // NOTE: we only notify normal submission here because they have the same contents but different pubkeys
366- config. bid_observer . block_submitted (
367- & slot_data,
368- request,
369- Arc :: new ( block. trace ) ,
370- builder_name,
371- bid_metadata. value . top_competitor_bid . unwrap_or_default ( ) ,
372- & relay_set,
373- ) ;
374- } )
375- }
290+ } ) ;
376291 }
377292}
378293
@@ -473,7 +388,6 @@ fn submit_block_to_relays(
473388 bid_adjustments : & std:: collections:: HashMap < Address , BidAdjustmentData > ,
474389 relays : & Vec < MevBoostRelayBidSubmitter > ,
475390 registrations : & HashMap < MevBoostRelayID , RelaySlotData > ,
476- optimistic : bool ,
477391 optimistic_v3_config : & Option < OptimisticV3Config > ,
478392 submission_span : & Span ,
479393 cancel : & CancellationToken ,
@@ -530,8 +444,7 @@ fn submit_block_to_relays(
530444 metadata : bid_metadata. clone ( ) ,
531445 } ;
532446
533- let span =
534- info_span ! ( parent: submission_span, "relay_submit" , relay = & relay. id( ) , optimistic) ;
447+ let span = info_span ! ( parent: submission_span, "relay_submit" , relay = & relay. id( ) ) ;
535448 let relay = relay. clone ( ) ;
536449 let cancel = cancel. clone ( ) ;
537450 tokio:: spawn (
@@ -541,7 +454,6 @@ fn submit_block_to_relays(
541454 submission,
542455 optimistic_v3,
543456 registration. registration ,
544- optimistic,
545457 cancel,
546458 )
547459 . await ;
@@ -556,7 +468,6 @@ async fn submit_bid_to_the_relay(
556468 submit_block_request : SubmitBlockRequestWithMetadata ,
557469 optimistic_v3_request : Option < ( OptimisticV3Config , SubmitHeaderRequestWithMetadata ) > ,
558470 registration : ValidatorSlotData ,
559- optimistic : bool ,
560471 cancel : CancellationToken ,
561472) {
562473 let submit_start = Instant :: now ( ) ;
@@ -591,7 +502,7 @@ async fn submit_bid_to_the_relay(
591502 Ok ( ( ) ) => {
592503 trace ! ( "Block submitted to the relay successfully" ) ;
593504 add_relay_submit_time ( relay. id ( ) , submit_time) ;
594- inc_relay_accepted_submissions ( relay. id ( ) , optimistic) ;
505+ inc_relay_accepted_submissions ( relay. id ( ) , relay . optimistic ( ) ) ;
595506 }
596507 Err ( SubmitBlockErr :: PayloadDelivered | SubmitBlockErr :: PastSlot ) => {
597508 trace ! ( "Block already delivered by the relay, cancelling" ) ;
0 commit comments