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
14 changes: 9 additions & 5 deletions src/tasks/block/sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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},
Expand Down Expand Up @@ -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)
}
Expand All @@ -167,7 +172,7 @@ impl Simulator {
cache: SimCache,
submit_sender: mpsc::UnboundedSender<SimResult>,
) -> JoinHandle<()> {
tracing::debug!("starting simulator task");
debug!("starting simulator task");

tokio::spawn(async move { self.run_simulator(constants, cache, submit_sender).await })
}
Expand Down Expand Up @@ -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 });
}
Expand Down
34 changes: 14 additions & 20 deletions src/tasks/submit/flashbots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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");
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/tasks/submit/prep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
}
Expand Down