From 5e77dfe0ecd5de58b561762c85cd12fcd2b3d630 Mon Sep 17 00:00:00 2001 From: Andy Date: Fri, 13 Dec 2024 11:25:43 -0500 Subject: [PATCH] fix: reset metrics when builder re-initialized. (#934) --- crates/builder/src/bundle_sender.rs | 1 + crates/builder/src/transaction_tracker.rs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/crates/builder/src/bundle_sender.rs b/crates/builder/src/bundle_sender.rs index 2e589d14e..28f98b6f6 100644 --- a/crates/builder/src/bundle_sender.rs +++ b/crates/builder/src/bundle_sender.rs @@ -331,6 +331,7 @@ where error!("Bundle send error {error:?}"); self.metrics.bundle_txns_failed.increment(1); state.bundle_error(error); + state.transaction_tracker.reset().await; } } diff --git a/crates/builder/src/transaction_tracker.rs b/crates/builder/src/transaction_tracker.rs index 25377c077..1b5f76de3 100644 --- a/crates/builder/src/transaction_tracker.rs +++ b/crates/builder/src/transaction_tracker.rs @@ -296,6 +296,8 @@ where ); let sent_tx = self.sender.send_transaction(tx, expected_storage).await; + self.update_metrics(); + match sent_tx { Ok(sent_tx) => { info!( @@ -495,6 +497,10 @@ where async fn reset(&mut self) { let nonce = self.get_external_nonce().await.unwrap_or(self.nonce); self.set_nonce_and_clear_state(nonce); + // reset metrics when tracker reset. + self.metrics.num_pending_transactions.set(0); + self.metrics.current_max_fee_per_gas.set(0); + self.metrics.max_priority_fee_per_gas.set(0); } fn abandon(&mut self) {