From 0e9efcb3713e589d03155440116c2bf4df910073 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 21 Oct 2025 10:39:43 -0400 Subject: [PATCH 1/4] feat: add metrics --- src/tasks/block/sim.rs | 10 +++++----- src/tasks/submit/flashbots.rs | 26 +++++++++++++------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/tasks/block/sim.rs b/src/tasks/block/sim.rs index 7894194..5eb909a 100644 --- a/src/tasks/block/sim.rs +++ b/src/tasks/block/sim.rs @@ -6,7 +6,7 @@ use crate::{ tasks::env::SimEnv, }; use alloy::{eips::BlockId, network::Ethereum}; -use init4_bin_base::utils::calc::SlotCalculator; +use init4_bin_base::{deps::metrics::counter, utils::calc::SlotCalculator}; use signet_sim::{BlockBuild, BuiltBlock, SimCache}; use signet_types::constants::SignetSystemConstants; use std::time::{Duration, Instant}; @@ -17,7 +17,7 @@ use tokio::{ }, task::JoinHandle, }; -use tracing::{Instrument, Span, instrument}; +use tracing::{Instrument, Span, debug, instrument}; use trevm::revm::{ context::BlockEnv, database::{AlloyDB, WrapDatabaseAsync}, @@ -140,11 +140,12 @@ impl Simulator { ); let built_block = block_build.build().in_current_span().await; - tracing::debug!( + debug!( tx_count = built_block.tx_count(), block_number = built_block.block_number(), "block simulation completed", ); + counter!("signet.builder.simulated_blocks").increment(1); Ok(built_block) } @@ -167,7 +168,7 @@ impl Simulator { cache: SimCache, submit_sender: mpsc::UnboundedSender, ) -> JoinHandle<()> { - tracing::debug!("starting simulator task"); + debug!("starting simulator task"); tokio::spawn(async move { self.run_simulator(constants, cache, submit_sender).await }) } @@ -220,7 +221,6 @@ impl Simulator { continue; }; - let _guard = span.clone().entered(); span_debug!(span, tx_count = block.transactions().len(), "built simulated block"); let _ = submit_sender.send(SimResult { block, sim_env }); } diff --git a/src/tasks/submit/flashbots.rs b/src/tasks/submit/flashbots.rs index cb9d0b7..dbc931d 100644 --- a/src/tasks/submit/flashbots.rs +++ b/src/tasks/submit/flashbots.rs @@ -13,10 +13,10 @@ use alloy::{ }; use eyre::OptionExt; use init4_bin_base::{ - deps::tracing::{Instrument, debug}, - utils::signer::LocalOrAws, + deps::metrics::counter, deps::tracing::Instrument, utils::signer::LocalOrAws, }; use tokio::{sync::mpsc, task::JoinHandle}; +use tracing::debug; /// Handles construction, simulation, and submission of rollup blocks to the /// Flashbots network. @@ -127,12 +127,13 @@ impl FlashbotsTask { ); // Prepare a MEV bundle with the configured call type from the sim result - let bundle = match self.prepare(&sim_result).instrument(span.clone()).await { - Ok(b) => b, - Err(e) => { - span_error!(span, %e, "failed to prepare MEV bundle"); - continue; - } + let Ok(bundle) = + self.prepare(&sim_result).instrument(span.clone()).await.inspect_err(|error| { + counter!("signet.builder.flashbots.bundle_prep_failures").increment(1); + span_debug!(span, %error, "bundle preparation failed"); + }) + else { + continue; }; // Send the bundle to Flashbots @@ -143,17 +144,16 @@ impl FlashbotsTask { .await; match response { - Ok(Some(hash)) => { + Ok(resp) => { + counter!("signet.builder.flashbots.bundles_submitted").increment(1); span_debug!( span, - hash = hash.bundle_hash.to_string(), + hash = resp.map(|r| r.bundle_hash.to_string()), "received bundle hash after submitted to flashbots" ); } - Ok(None) => { - span_debug!(span, "received no bundle hash after submitted to flashbots"); - } Err(err) => { + counter!("signet.builder.flashbots.submission_failures").increment(1); span_error!(span, %err, "MEV bundle submission failed - error returned"); } } From f47f603c094df2f4ffc19d1e556ded103fa4814a Mon Sep 17 00:00:00 2001 From: James Date: Tue, 21 Oct 2025 10:42:40 -0400 Subject: [PATCH 2/4] chore: cleanup --- src/tasks/block/sim.rs | 8 ++++++-- src/tasks/submit/flashbots.rs | 6 +----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/tasks/block/sim.rs b/src/tasks/block/sim.rs index 5eb909a..ee8a1b5 100644 --- a/src/tasks/block/sim.rs +++ b/src/tasks/block/sim.rs @@ -6,7 +6,10 @@ use crate::{ tasks::env::SimEnv, }; use alloy::{eips::BlockId, network::Ethereum}; -use init4_bin_base::{deps::metrics::counter, utils::calc::SlotCalculator}; +use init4_bin_base::{ + deps::metrics::{counter, histogram}, + utils::calc::SlotCalculator, +}; use signet_sim::{BlockBuild, BuiltBlock, SimCache}; use signet_types::constants::SignetSystemConstants; use std::time::{Duration, Instant}; @@ -145,7 +148,8 @@ impl Simulator { block_number = built_block.block_number(), "block simulation completed", ); - counter!("signet.builder.simulated_blocks").increment(1); + counter!("signet.builder.built_blocks").increment(1); + histogram!("signet.builder.built_blocks.tx_count").record(built_block.tx_count() as f64); Ok(built_block) } diff --git a/src/tasks/submit/flashbots.rs b/src/tasks/submit/flashbots.rs index dbc931d..25b423c 100644 --- a/src/tasks/submit/flashbots.rs +++ b/src/tasks/submit/flashbots.rs @@ -120,11 +120,7 @@ impl FlashbotsTask { break; }; let span = sim_result.span(); - span_debug!( - span, - host_block_number = sim_result.host_block_number(), - "received sim result" - ); + span_debug!(span, "received sim result"); // Prepare a MEV bundle with the configured call type from the sim result let Ok(bundle) = From 9b582ce313f282a2718cf8174b9eeb537ab00d9f Mon Sep 17 00:00:00 2001 From: James Date: Tue, 21 Oct 2025 10:43:56 -0400 Subject: [PATCH 3/4] fix: import --- src/tasks/submit/flashbots.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/tasks/submit/flashbots.rs b/src/tasks/submit/flashbots.rs index 25b423c..a5a2d1a 100644 --- a/src/tasks/submit/flashbots.rs +++ b/src/tasks/submit/flashbots.rs @@ -12,11 +12,9 @@ use alloy::{ rpc::types::mev::{BundleItem, MevSendBundle, ProtocolVersion}, }; use eyre::OptionExt; -use init4_bin_base::{ - deps::metrics::counter, deps::tracing::Instrument, utils::signer::LocalOrAws, -}; +use init4_bin_base::{deps::metrics::counter, utils::signer::LocalOrAws}; use tokio::{sync::mpsc, task::JoinHandle}; -use tracing::debug; +use tracing::{Instrument, debug}; /// Handles construction, simulation, and submission of rollup blocks to the /// Flashbots network. From 886d6b1d43ba58084e76b333a41704829f9e1a47 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 21 Oct 2025 12:07:49 -0400 Subject: [PATCH 4/4] feat: 1 more metric --- src/tasks/submit/prep.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/tasks/submit/prep.rs b/src/tasks/submit/prep.rs index e965a7d..36850fc 100644 --- a/src/tasks/submit/prep.rs +++ b/src/tasks/submit/prep.rs @@ -11,6 +11,7 @@ use alloy::{ rpc::types::TransactionRequest, sol_types::SolCall, }; +use init4_bin_base::deps::metrics::counter; use signet_sim::BuiltBlock; use signet_types::{SignRequest, SignResponse}; use signet_zenith::BundleHelper; @@ -75,7 +76,13 @@ impl<'a> SubmitPrep<'a> { self.quincey_resp .get_or_try_init(|| async { let sig_request = self.sig_request(); - self.quincey.get_signature(sig_request).await + self.quincey + .get_signature(sig_request) + .await + .inspect(|_| counter!("signet.builder.quincey_signatures").increment(1)) + .inspect_err(|_| { + counter!("signet.builder.quincey_signature_failures").increment(1) + }) }) .await }