diff --git a/crates/rbuilder/src/building/builders/block_building_helper.rs b/crates/rbuilder/src/building/builders/block_building_helper.rs index 5f5fbbb7..7342fdd1 100644 --- a/crates/rbuilder/src/building/builders/block_building_helper.rs +++ b/crates/rbuilder/src/building/builders/block_building_helper.rs @@ -76,6 +76,10 @@ pub trait BlockBuildingHelper: Send + Sync { /// Updates the cached reads for the block state. fn update_cached_reads(&mut self, cached_reads: CachedReads); + + /// Name of the builder that pregenerated this block. + /// BE CAREFUL: Might be ambiguous if several building parts were involved... + fn builder_name(&self) -> &str; } /// Implementation of BlockBuildingHelper based on a generic Provider @@ -422,4 +426,8 @@ where fn update_cached_reads(&mut self, cached_reads: CachedReads) { self.block_state = self.block_state.clone().with_cached_reads(cached_reads); } + + fn builder_name(&self) -> &str { + &self.builder_name + } } diff --git a/crates/rbuilder/src/building/builders/mock_block_building_helper.rs b/crates/rbuilder/src/building/builders/mock_block_building_helper.rs index f55f1889..26d38112 100644 --- a/crates/rbuilder/src/building/builders/mock_block_building_helper.rs +++ b/crates/rbuilder/src/building/builders/mock_block_building_helper.rs @@ -105,4 +105,8 @@ impl BlockBuildingHelper for MockBlockBuildingHelper { fn update_cached_reads(&mut self, _cached_reads: CachedReads) { unimplemented!() } + + fn builder_name(&self) -> &str { + "Mock" + } } diff --git a/crates/rbuilder/src/live_builder/block_output/bidding/parallel_sealer_bid_maker.rs b/crates/rbuilder/src/live_builder/block_output/bidding/parallel_sealer_bid_maker.rs index 4f3d4eeb..2863e718 100644 --- a/crates/rbuilder/src/live_builder/block_output/bidding/parallel_sealer_bid_maker.rs +++ b/crates/rbuilder/src/live_builder/block_output/bidding/parallel_sealer_bid_maker.rs @@ -121,6 +121,7 @@ impl ParallelSealerBidMakerProcess { let payout_tx_val = bid.payout_tx_value(); let block = bid.block(); let block_number = block.building_context().block(); + let builder_name = block.builder_name().to_string(); // Take sealing "slot" *self.seal_control.seals_in_progress.lock() += 1; let seal_control = self.seal_control.clone(); @@ -129,6 +130,7 @@ impl ParallelSealerBidMakerProcess { match block.finalize_block(payout_tx_val) { Ok(res) => sink.new_block(res.block), Err(error) => error!( + builder_name, block_number, ?error, "Error on finalize_block on ParallelSealerBidMaker" diff --git a/crates/rbuilder/src/live_builder/block_output/bidding/sequential_sealer_bid_maker.rs b/crates/rbuilder/src/live_builder/block_output/bidding/sequential_sealer_bid_maker.rs index 708a2be3..c41d3b4b 100644 --- a/crates/rbuilder/src/live_builder/block_output/bidding/sequential_sealer_bid_maker.rs +++ b/crates/rbuilder/src/live_builder/block_output/bidding/sequential_sealer_bid_maker.rs @@ -90,12 +90,14 @@ impl SequentialSealerBidMakerProcess { let payout_tx_val = bid.payout_tx_value(); let block = bid.block(); let block_number = block.building_context().block(); + let builder_name = block.builder_name().to_string(); match tokio::task::spawn_blocking(move || block.finalize_block(payout_tx_val)).await { Ok(finalize_res) => match finalize_res { Ok(res) => self.sink.new_block(res.block), Err(error) => { if error.is_critical() { error!( + builder_name, block_number, ?error, "Error on finalize_block on SequentialSealerBidMaker" diff --git a/crates/rbuilder/src/live_builder/mod.rs b/crates/rbuilder/src/live_builder/mod.rs index abdbd973..d4110fe8 100644 --- a/crates/rbuilder/src/live_builder/mod.rs +++ b/crates/rbuilder/src/live_builder/mod.rs @@ -131,6 +131,8 @@ where } pub async fn run(self) -> eyre::Result<()> { + // We keep the last block to avoid going back in time since we are now very robust about reorgs or this kind of behavior. + let mut last_processed_block: Option = None; info!("Builder block list size: {}", self.blocklist.len(),); info!( "Builder coinbase address: {:?}", @@ -195,8 +197,13 @@ where ); continue; } + // Allow only increasing blocks + if last_processed_block.map_or(false, |last_processed_block| { + payload.block() <= last_processed_block + }) { + continue; + } // see if we can get parent header in a reasonable time - let time_to_slot = payload.timestamp() - OffsetDateTime::now_utc(); debug!( slot = payload.slot(), @@ -235,6 +242,7 @@ where ); inc_active_slots(); + last_processed_block = Some(payload.block()); if let Some(block_ctx) = BlockBuildingContext::from_attributes( payload.payload_attributes_event.clone(),