Skip to content

Commit ae5066a

Browse files
apollo_mempool,apollo_dashboard: add Grafana panels for nonce-gap metrics (#13919)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2c148b7 commit ae5066a

3 files changed

Lines changed: 52 additions & 1 deletion

File tree

crates/apollo_dashboard/resources/dev_grafana.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,28 @@
12191219
],
12201220
"extra_params": {}
12211221
},
1222+
{
1223+
"title": "Accounts With Nonce Gap",
1224+
"description": "Number of accounts whose lowest pool nonce exceeds the account nonce, making them unable to provide any transaction for batching",
1225+
"type": "timeseries",
1226+
"exprs": [
1227+
"mempool_accounts_with_gap{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\"}"
1228+
],
1229+
"extra_params": {
1230+
"log_query": "\"has a nonce gap\""
1231+
}
1232+
},
1233+
{
1234+
"title": "Stuck Transactions (Nonce Gap)",
1235+
"description": "Number of transactions in the pool belonging to accounts whose lowest pool nonce exceeds the account nonce",
1236+
"type": "timeseries",
1237+
"exprs": [
1238+
"mempool_stuck_txs{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\"}"
1239+
],
1240+
"extra_params": {
1241+
"log_query": "\"has a nonce gap\""
1242+
}
1243+
},
12221244
{
12231245
"title": "Transaction Time Spent In Mempool Until Batched",
12241246
"description": "The time a transaction spends in the mempool until it is batched (5m window)",

crates/apollo_dashboard/src/panels/mempool.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
use apollo_mempool::metrics::{
22
LABEL_NAME_DROP_REASON,
3+
MEMPOOL_ACCOUNTS_WITH_GAP,
34
MEMPOOL_DELAYED_DECLARES_SIZE,
45
MEMPOOL_PENDING_QUEUE_SIZE,
56
MEMPOOL_POOL_SIZE,
67
MEMPOOL_PRIORITY_QUEUE_SIZE,
8+
MEMPOOL_STUCK_TXS,
79
MEMPOOL_TOTAL_SIZE_BYTES,
810
MEMPOOL_TRANSACTIONS_COMMITTED,
911
MEMPOOL_TRANSACTIONS_DROPPED,
@@ -97,6 +99,26 @@ fn get_panel_mempool_delayed_declares_size() -> Panel {
9799
PanelType::TimeSeries,
98100
)
99101
}
102+
fn get_panel_mempool_accounts_with_gap() -> Panel {
103+
Panel::new(
104+
"Accounts With Nonce Gap",
105+
"Number of accounts whose lowest pool nonce exceeds the account nonce, making them unable \
106+
to provide any transaction for batching",
107+
MEMPOOL_ACCOUNTS_WITH_GAP.get_name_with_filter().to_string(),
108+
PanelType::TimeSeries,
109+
)
110+
.with_log_query("has a nonce gap")
111+
}
112+
fn get_panel_mempool_stuck_txs() -> Panel {
113+
Panel::new(
114+
"Stuck Transactions (Nonce Gap)",
115+
"Number of transactions in the pool belonging to accounts whose lowest pool nonce exceeds \
116+
the account nonce",
117+
MEMPOOL_STUCK_TXS.get_name_with_filter().to_string(),
118+
PanelType::TimeSeries,
119+
)
120+
.with_log_query("has a nonce gap")
121+
}
100122
fn get_panel_mempool_transaction_time_spent_until_batched() -> Panel {
101123
Panel::from_hist(
102124
&TRANSACTION_TIME_SPENT_UNTIL_BATCHED,
@@ -126,6 +148,8 @@ pub(crate) fn get_mempool_row() -> Row {
126148
get_panel_mempool_priority_queue_size(),
127149
get_panel_mempool_pending_queue_size(),
128150
get_panel_mempool_delayed_declares_size(),
151+
get_panel_mempool_accounts_with_gap(),
152+
get_panel_mempool_stuck_txs(),
129153
get_panel_mempool_transaction_time_spent_until_batched(),
130154
get_panel_mempool_transaction_time_spent_until_committed(),
131155
],

crates/apollo_mempool/src/mempool.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,12 @@ impl Mempool {
942942
if gap_exists {
943943
if self.accounts_with_gap.insert(address) {
944944
// Newly entered gap: all current pool txs for this account are now stuck.
945-
self.n_stuck_txs += self.tx_pool.n_txs_for_address(address);
945+
let n_stuck = self.tx_pool.n_txs_for_address(address);
946+
self.n_stuck_txs += n_stuck;
947+
warn!(
948+
"Account {address} has a nonce gap; {n_stuck} transaction(s) are now \
949+
stuck."
950+
);
946951
}
947952
// Stayed in gap: per-tx deltas were already applied at add/remove sites.
948953
} else {

0 commit comments

Comments
 (0)