Skip to content

Commit

Permalink
Builder name on errors (#286)
Browse files Browse the repository at this point in the history
## πŸ“ Summary

Add builder algorithm name to 2 error!

## πŸ’‘ Motivation and Context

Allows to pinpoint problems with new algorithms.

---

## βœ… I have completed the following steps:

* [X] Run `make lint`
* [X] Run `make test`
* [ ] Added tests (if applicable)
  • Loading branch information
ZanCorDX authored Dec 13, 2024
1 parent 67df6cf commit 9835e67
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,8 @@ impl BlockBuildingHelper for MockBlockBuildingHelper {
fn update_cached_reads(&mut self, _cached_reads: CachedReads) {
unimplemented!()
}

fn builder_name(&self) -> &str {
"Mock"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 9 additions & 1 deletion crates/rbuilder/src/live_builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u64> = None;
info!("Builder block list size: {}", self.blocklist.len(),);
info!(
"Builder coinbase address: {:?}",
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit 9835e67

Please sign in to comment.