@@ -282,14 +282,11 @@ where
282282 ctx. metrics . sequencer_tx_gauge . set ( sequencer_tx_time) ;
283283
284284 // If we have payload with txpool we add first builder tx right after deposits
285- self . builder_tx
286- . add_builder_txs ( & state_provider, & mut info, & ctx, & mut db) ?;
285+ let builder_txs =
286+ self . builder_tx
287+ . add_builder_txs ( & state_provider, & mut info, & ctx, & mut db) ?;
287288
288289 // We subtract gas limit and da limit for builder transaction from the whole limit
289- let builder_txs = self
290- . builder_tx
291- . simulate_builder_txs ( & state_provider, & mut info, & ctx, & mut db)
292- . map_err ( |err| PayloadBuilderError :: Other ( Box :: new ( err) ) ) ?;
293290 let builder_tx_gas = builder_txs. iter ( ) . fold ( 0 , |acc, tx| acc + tx. gas_used ) ;
294291 let builder_tx_da_size: u64 = builder_txs. iter ( ) . fold ( 0 , |acc, tx| acc + tx. da_size ) ;
295292
@@ -430,19 +427,28 @@ where
430427 ) ;
431428 let flashblock_build_start_time = Instant :: now ( ) ;
432429 let state = StateProviderDatabase :: new ( & state_provider) ;
430+ let mut db = State :: builder ( )
431+ . with_database ( state)
432+ . with_bundle_update ( )
433+ . with_bundle_prestate ( bundle_state. clone ( ) )
434+ . build ( ) ;
435+
436+ let builder_txs = self . builder_tx . simulate_builder_txs (
437+ & state_provider,
438+ & mut info,
439+ & ctx,
440+ & mut db,
441+ ) ?;
442+ let builder_tx_gas = builder_txs. iter ( ) . fold ( 0 , |acc, tx| acc + tx. gas_used ) ;
443+ let builder_tx_da_size: u64 =
444+ builder_txs. iter ( ) . fold ( 0 , |acc, tx| acc + tx. da_size ) ;
433445
434446 total_gas_per_batch = total_gas_per_batch. saturating_sub ( builder_tx_gas) ;
435447 // saturating sub just in case, we will log an error if da_limit too small for builder_tx_da_size
436448 if let Some ( da_limit) = total_da_per_batch. as_mut ( ) {
437449 * da_limit = da_limit. saturating_sub ( builder_tx_da_size) ;
438450 }
439451
440- let mut db = State :: builder ( )
441- . with_database ( state)
442- . with_bundle_update ( )
443- . with_bundle_prestate ( bundle_state. clone ( ) )
444- . build ( ) ;
445-
446452 let best_txs_start_time = Instant :: now ( ) ;
447453 let best_txs = BestPayloadTransactions :: new (
448454 // We are not using without_updates in here, so arriving transaction could target the current block
0 commit comments