Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 41 additions & 30 deletions crates/op-rbuilder/src/builders/flashblocks/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,15 +456,12 @@ where
// We got block cancelled, we won't need anything from the block at this point
// Caution: this assume that block cancel token only cancelled when new FCU is received
if block_cancel.is_cancelled() {
ctx.metrics.block_built_success.increment(1);
ctx.metrics
.flashblock_count
.record(ctx.flashblock_index() as f64);
debug!(
target: "payload_builder",
message = "Payload building complete, job cancelled during execution"
self.record_flashblocks_metrics(
&ctx,
flashblocks_per_block,
&span,
"Payload building complete, channel closed or job cancelled",
);
span.record("flashblock_count", ctx.flashblock_index());
return Ok(());
}

Expand Down Expand Up @@ -514,15 +511,12 @@ where
// If main token got canceled in here that means we received get_payload and we should drop everything and now update best_payload
// To ensure that we will return same blocks as rollup-boost (to leverage caches)
if block_cancel.is_cancelled() {
ctx.metrics.block_built_success.increment(1);
ctx.metrics
.flashblock_count
.record(ctx.flashblock_index() as f64);
debug!(
target: "payload_builder",
message = "Payload building complete, job cancelled during execution"
self.record_flashblocks_metrics(
&ctx,
flashblocks_per_block,
&span,
"Payload building complete, channel closed or job cancelled",
);
span.record("flashblock_count", ctx.flashblock_index());
return Ok(());
}
self.ws_pub
Expand Down Expand Up @@ -563,27 +557,44 @@ where
}
}
None => {
// Exit loop if channel closed or cancelled
ctx.metrics.block_built_success.increment(1);
ctx.metrics
.flashblock_count
.record(ctx.flashblock_index() as f64);
ctx.metrics
.missing_flashblocks_count
.record(flashblocks_per_block.saturating_sub(ctx.flashblock_index()) as f64);
debug!(
target: "payload_builder",
message = "Payload building complete, channel closed or job cancelled",
missing_falshblocks = flashblocks_per_block.saturating_sub(ctx.flashblock_index()),
reduced_flashblocks = self.config.flashblocks_per_block().saturating_sub(flashblocks_per_block),
self.record_flashblocks_metrics(
&ctx,
flashblocks_per_block,
&span,
"Payload building complete, channel closed or job cancelled",
);
span.record("flashblock_count", ctx.flashblock_index());
return Ok(());
}
}
}
}

/// Do some logging and metric recording when we stop build flashblocks
fn record_flashblocks_metrics(
&self,
ctx: &OpPayloadBuilderCtx<FlashblocksExtraCtx>,
flashblocks_per_block: u64,
span: &tracing::Span,
message: &str,
) {
ctx.metrics.block_built_success.increment(1);
ctx.metrics
.flashblock_count
.record(ctx.flashblock_index() as f64);
ctx.metrics
.missing_flashblocks_count
.record(flashblocks_per_block.saturating_sub(ctx.flashblock_index()) as f64);

debug!(
target: "payload_builder",
message = message,
missing_flashblocks = flashblocks_per_block.saturating_sub(ctx.flashblock_index()),
reduced_flashblocks = self.config.flashblocks_per_block().saturating_sub(flashblocks_per_block),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of the number of missing flashblocks I would have the raw values e.g. flashblocks_per_block, flashblock_index and flashblocks per block as the flashblocks_per_block and ctx.flashblock_index() values can potentially change for every block

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, there are two flashblocks_per_block values though so I named one of them config_flashblocks_per_block. Is there a better name for that?

);

span.record("flashblock_count", ctx.flashblock_index());
}

/// Spawn task that will send new flashblock level cancel token in steady intervals (first interval
/// may vary if --flashblocks.dynamic enabled)
pub fn spawn_timer_task(
Expand Down
Loading