Skip to content

Commit acd0306

Browse files
fatxpool: metrics for unfiltered timings of inblock events (#10312)
This PR adds a new experimental metric `substrate_sub_txpool_timing_event_in_block2` for the reliability dashboard. Unlike the existing `in_block` metric which records timing only for the first `InBlock` event per transaction, the new `in_block2` metric records every InBlock event without filtering. This allows tracking transactions that appear in multiple blocks during chain reorganizations, providing better visibility into fork-related transaction behavior. The implementation adds the new histogram to `EventsHistograms` and updates `handle_status()` to record unfiltered InBlock events before applying deduplication logic. This approach should allow for experimenting with new _inblock confidence_ metric, without affecting the data currently shown on the Reliability Dashboard. --------- Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 7ef1751 commit acd0306

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

prdoc/pr_10312.prdoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
title: 'fatxpool: metrics for unfiltered timings of inblock events'
2+
doc:
3+
- audience: Node Dev
4+
description: |-
5+
This PR adds a new experimental metric `substrate_sub_txpool_timing_event_in_block2` for the reliability dashboard. Unlike the existing `in_block` metric which records timing only for the first `InBlock` event per transaction, the new `in_block2` metric records every InBlock event without filtering. This allows tracking transactions that appear in multiple blocks during chain reorganizations, providing better visibility into fork-related transaction behavior. The implementation adds the new histogram to `EventsHistograms` and updates `handle_status()` to record unfiltered InBlock events before applying deduplication logic.
6+
7+
This approach should allow for experimenting with new _inblock confidence_ metric, without affecting the data currently shown on the Reliability Dashboard.
8+
crates:
9+
- name: sc-transaction-pool
10+
bump: minor

substrate/client/transaction-pool/src/fork_aware_txpool/metrics.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ pub struct EventsHistograms {
9797
pub broadcast: Histogram,
9898
/// Histogram of timings for reporting `TransactionStatus::InBlock` event
9999
pub in_block: Histogram,
100+
/// Histogram of timings for reporting `TransactionStatus::InBlock` event (unfiltered).
101+
///
102+
/// This is an experimental feature for reliability dashboard.
103+
/// Unlike `in_block`, this metric records every InBlock event, including duplicates
104+
/// when the same transaction appears in multiple blocks (e.g., during chain reorgs).
105+
pub in_block_forks: Histogram,
100106
/// Histogram of timings for reporting `TransactionStatus::Retracted` event
101107
pub retracted: Histogram,
102108
/// Histogram of timings for reporting `TransactionStatus::FinalityTimeout` event
@@ -155,6 +161,23 @@ impl EventsHistograms {
155161
)?,
156162
registry,
157163
)?,
164+
in_block_forks: register(
165+
Histogram::with_opts(
166+
histogram_opts!(
167+
"substrate_sub_txpool_timing_event_in_block_forks",
168+
"Histogram of timings for reporting unfiltered InBlock event (experimental feature for reliability dashboard)",
169+
)
170+
.buckets(
171+
[
172+
linear_buckets(0.0, 3.0, 20).unwrap(),
173+
// requested in #9158
174+
vec![60.0, 75.0, 90.0, 120.0, 180.0],
175+
]
176+
.concat(),
177+
),
178+
)?,
179+
registry,
180+
)?,
158181
retracted: register(
159182
Histogram::with_opts(histogram_opts!(
160183
"substrate_sub_txpool_timing_event_retracted",
@@ -557,6 +580,15 @@ where
557580
) {
558581
let Entry::Occupied(mut entry) = submitted_timestamp_map.entry(hash) else { return };
559582
let remove = status.is_final();
583+
584+
// Record unfiltered in_block_forks metric for EVERY InBlock event
585+
if matches!(status, TransactionStatus::InBlock(..)) {
586+
let duration = timestamp.duration_since(entry.get().submit_timestamp);
587+
metrics.report(|metrics| {
588+
metrics.events_histograms.in_block_forks.observe(duration.as_secs_f64())
589+
});
590+
}
591+
560592
if let Some(submit_timestamp) = entry.get_mut().update(&status) {
561593
metrics.report(|metrics| {
562594
metrics

0 commit comments

Comments
 (0)