Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 8 additions & 3 deletions crates/op-rbuilder/src/builders/flashblocks/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,13 @@ where
let (payload, fb_payload) = build_block(&mut state, &ctx, &mut info)?;

best_payload.set(payload.clone());
self.ws_pub
let flashblock_byte_size = self
.ws_pub
.publish(&fb_payload)
.map_err(PayloadBuilderError::other)?;
ctx.metrics
.flashblock_byte_size_histogram
.record(flashblock_byte_size as f64);

info!(
target: "payload_builder",
Expand Down Expand Up @@ -520,7 +524,8 @@ where
);
return Ok(());
}
self.ws_pub
let flashblock_byte_size = self
.ws_pub
.publish(&fb_payload)
.map_err(PayloadBuilderError::other)?;

Expand All @@ -530,7 +535,7 @@ where
.record(flashblock_build_start_time.elapsed());
ctx.metrics
.flashblock_byte_size_histogram
.record(new_payload.block().size() as f64);
.record(flashblock_byte_size as f64);
ctx.metrics
.flashblock_num_tx_histogram
.record(info.executed_transactions.len() as f64);
Expand Down
6 changes: 3 additions & 3 deletions crates/op-rbuilder/src/builders/flashblocks/wspub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl WebSocketPublisher {
})
}

pub fn publish(&self, payload: &FlashblocksPayloadV1) -> io::Result<()> {
pub fn publish(&self, payload: &FlashblocksPayloadV1) -> io::Result<usize> {
// Serialize the payload to a UTF-8 string
// serialize only once, then just copy around only a pointer
// to the serialized data for each subscription.
Expand All @@ -76,12 +76,12 @@ impl WebSocketPublisher {

let serialized = serde_json::to_string(payload)?;
let utf8_bytes = Utf8Bytes::from(serialized);

let size = utf8_bytes.len();
// Send the serialized payload to all subscribers
self.pipe
.send(utf8_bytes)
.map_err(|e| io::Error::new(io::ErrorKind::ConnectionAborted, e))?;
Ok(())
Ok(size)
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/op-rbuilder/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub struct OpRBuilderMetrics {
pub total_block_built_gauge: Gauge,
/// Histogram of the time taken to build a Flashblock
pub flashblock_build_duration: Histogram,
/// Flashblock byte size histogram
/// Flashblock UTF8 payload byte size histogram
pub flashblock_byte_size_histogram: Histogram,
/// Histogram of transactions in a Flashblock
pub flashblock_num_tx_histogram: Histogram,
Expand Down
Loading