diff --git a/src/tasks/block/sim.rs b/src/tasks/block/sim.rs index 7894194..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::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}; @@ -17,7 +20,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 +143,13 @@ 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.built_blocks").increment(1); + histogram!("signet.builder.built_blocks.tx_count").record(built_block.tx_count() as f64); Ok(built_block) } @@ -167,7 +172,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 +225,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..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::tracing::{Instrument, debug}, - utils::signer::LocalOrAws, -}; +use init4_bin_base::{deps::metrics::counter, utils::signer::LocalOrAws}; use tokio::{sync::mpsc, task::JoinHandle}; +use tracing::{Instrument, debug}; /// Handles construction, simulation, and submission of rollup blocks to the /// Flashbots network. @@ -120,19 +118,16 @@ 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 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 +138,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"); } } 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 }