Skip to content

Commit 0e9efcb

Browse files
committed
feat: add metrics
1 parent f753b88 commit 0e9efcb

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/tasks/block/sim.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{
66
tasks::env::SimEnv,
77
};
88
use alloy::{eips::BlockId, network::Ethereum};
9-
use init4_bin_base::utils::calc::SlotCalculator;
9+
use init4_bin_base::{deps::metrics::counter, utils::calc::SlotCalculator};
1010
use signet_sim::{BlockBuild, BuiltBlock, SimCache};
1111
use signet_types::constants::SignetSystemConstants;
1212
use std::time::{Duration, Instant};
@@ -17,7 +17,7 @@ use tokio::{
1717
},
1818
task::JoinHandle,
1919
};
20-
use tracing::{Instrument, Span, instrument};
20+
use tracing::{Instrument, Span, debug, instrument};
2121
use trevm::revm::{
2222
context::BlockEnv,
2323
database::{AlloyDB, WrapDatabaseAsync},
@@ -140,11 +140,12 @@ impl Simulator {
140140
);
141141

142142
let built_block = block_build.build().in_current_span().await;
143-
tracing::debug!(
143+
debug!(
144144
tx_count = built_block.tx_count(),
145145
block_number = built_block.block_number(),
146146
"block simulation completed",
147147
);
148+
counter!("signet.builder.simulated_blocks").increment(1);
148149

149150
Ok(built_block)
150151
}
@@ -167,7 +168,7 @@ impl Simulator {
167168
cache: SimCache,
168169
submit_sender: mpsc::UnboundedSender<SimResult>,
169170
) -> JoinHandle<()> {
170-
tracing::debug!("starting simulator task");
171+
debug!("starting simulator task");
171172

172173
tokio::spawn(async move { self.run_simulator(constants, cache, submit_sender).await })
173174
}
@@ -220,7 +221,6 @@ impl Simulator {
220221
continue;
221222
};
222223

223-
let _guard = span.clone().entered();
224224
span_debug!(span, tx_count = block.transactions().len(), "built simulated block");
225225
let _ = submit_sender.send(SimResult { block, sim_env });
226226
}

src/tasks/submit/flashbots.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ use alloy::{
1313
};
1414
use eyre::OptionExt;
1515
use init4_bin_base::{
16-
deps::tracing::{Instrument, debug},
17-
utils::signer::LocalOrAws,
16+
deps::metrics::counter, deps::tracing::Instrument, utils::signer::LocalOrAws,
1817
};
1918
use tokio::{sync::mpsc, task::JoinHandle};
19+
use tracing::debug;
2020

2121
/// Handles construction, simulation, and submission of rollup blocks to the
2222
/// Flashbots network.
@@ -127,12 +127,13 @@ impl FlashbotsTask {
127127
);
128128

129129
// Prepare a MEV bundle with the configured call type from the sim result
130-
let bundle = match self.prepare(&sim_result).instrument(span.clone()).await {
131-
Ok(b) => b,
132-
Err(e) => {
133-
span_error!(span, %e, "failed to prepare MEV bundle");
134-
continue;
135-
}
130+
let Ok(bundle) =
131+
self.prepare(&sim_result).instrument(span.clone()).await.inspect_err(|error| {
132+
counter!("signet.builder.flashbots.bundle_prep_failures").increment(1);
133+
span_debug!(span, %error, "bundle preparation failed");
134+
})
135+
else {
136+
continue;
136137
};
137138

138139
// Send the bundle to Flashbots
@@ -143,17 +144,16 @@ impl FlashbotsTask {
143144
.await;
144145

145146
match response {
146-
Ok(Some(hash)) => {
147+
Ok(resp) => {
148+
counter!("signet.builder.flashbots.bundles_submitted").increment(1);
147149
span_debug!(
148150
span,
149-
hash = hash.bundle_hash.to_string(),
151+
hash = resp.map(|r| r.bundle_hash.to_string()),
150152
"received bundle hash after submitted to flashbots"
151153
);
152154
}
153-
Ok(None) => {
154-
span_debug!(span, "received no bundle hash after submitted to flashbots");
155-
}
156155
Err(err) => {
156+
counter!("signet.builder.flashbots.submission_failures").increment(1);
157157
span_error!(span, %err, "MEV bundle submission failed - error returned");
158158
}
159159
}

0 commit comments

Comments
 (0)