Skip to content

Commit ef767a9

Browse files
committed
feat: track flashbots submission duration
1 parent 22ea7e5 commit ef767a9

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/metrics.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ const FLASHBOTS_EMPTY_BLOCKS_HELP: &str = "Number of empty blocks skipped";
5151
const FLASHBOTS_SUBMISSIONS: &str = "signet.builder.flashbots.submissions";
5252
const FLASHBOTS_SUBMISSIONS_HELP: &str = "Number of submission attempts to Flashbots";
5353

54+
const FLASHBOTS_SUBMISSION_DURATION_MS: &str = "signet.builder.flashbots.submission_duration_ms";
55+
const FLASHBOTS_SUBMISSION_DURATION_MS_HELP: &str =
56+
"Duration of Flashbots bundle submission requests in milliseconds";
57+
5458
// -- Block Building --
5559
const BUILT_BLOCKS: &str = "signet.builder.built_blocks";
5660
const BUILT_BLOCKS_HELP: &str = "Number of blocks built by the simulator";
@@ -89,6 +93,7 @@ static DESCRIBE: LazyLock<()> = LazyLock::new(|| {
8993
describe_counter!(FLASHBOTS_BUNDLE_PREP_FAILURES, FLASHBOTS_BUNDLE_PREP_FAILURES_HELP);
9094
describe_counter!(FLASHBOTS_EMPTY_BLOCKS, FLASHBOTS_EMPTY_BLOCKS_HELP);
9195
describe_counter!(FLASHBOTS_SUBMISSIONS, FLASHBOTS_SUBMISSIONS_HELP);
96+
describe_histogram!(FLASHBOTS_SUBMISSION_DURATION_MS, FLASHBOTS_SUBMISSION_DURATION_MS_HELP);
9297

9398
// Block building
9499
describe_counter!(BUILT_BLOCKS, BUILT_BLOCKS_HELP);
@@ -162,6 +167,12 @@ pub fn flashbots_submissions() -> Counter {
162167
counter!(FLASHBOTS_SUBMISSIONS)
163168
}
164169

170+
/// Histogram for Flashbots bundle submission duration in milliseconds.
171+
pub fn flashbots_submission_duration_ms() -> Histogram {
172+
LazyLock::force(&DESCRIBE);
173+
histogram!(FLASHBOTS_SUBMISSION_DURATION_MS)
174+
}
175+
165176
// -- Block Building --
166177

167178
/// Counter for blocks built by the simulator.

src/tasks/submit/flashbots.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use alloy::{
1414
};
1515
use eyre::OptionExt;
1616
use init4_bin_base::utils::signer::LocalOrAws;
17+
use std::time::Instant;
1718
use tokio::{sync::mpsc, task::JoinHandle};
1819
use tracing::{Instrument, debug, debug_span};
1920

@@ -196,13 +197,17 @@ impl FlashbotsTask {
196197
let signer = self.signer.clone();
197198

198199
tokio::spawn(async move {
200+
let start = Instant::now();
199201
let response = flashbots
200202
.send_mev_bundle(bundle.clone())
201203
.with_auth(signer.clone())
202204
.into_future()
203205
.instrument(submit_span.clone())
204206
.await;
205207

208+
metrics::flashbots_submission_duration_ms()
209+
.record(start.elapsed().as_millis() as f64);
210+
206211
match response {
207212
Ok(resp) => {
208213
metrics::flashbots_bundles_submitted().increment(1);

0 commit comments

Comments
 (0)