reth_transaction_pool/
metrics.rs

1//! Transaction pool metrics.
2
3use reth_metrics::{
4    metrics::{Counter, Gauge},
5    Metrics,
6};
7
8/// Transaction pool metrics
9#[derive(Metrics)]
10#[metrics(scope = "transaction_pool")]
11pub struct TxPoolMetrics {
12    /// Number of transactions inserted in the pool
13    pub(crate) inserted_transactions: Counter,
14    /// Number of invalid transactions
15    pub(crate) invalid_transactions: Counter,
16    /// Number of removed transactions from the pool
17    pub(crate) removed_transactions: Counter,
18
19    /// Number of transactions in the pending sub-pool
20    pub(crate) pending_pool_transactions: Gauge,
21    /// Total amount of memory used by the transactions in the pending sub-pool in bytes
22    pub(crate) pending_pool_size_bytes: Gauge,
23
24    /// Number of transactions in the basefee sub-pool
25    pub(crate) basefee_pool_transactions: Gauge,
26    /// Total amount of memory used by the transactions in the basefee sub-pool in bytes
27    pub(crate) basefee_pool_size_bytes: Gauge,
28
29    /// Number of transactions in the queued sub-pool
30    pub(crate) queued_pool_transactions: Gauge,
31    /// Total amount of memory used by the transactions in the queued sub-pool in bytes
32    pub(crate) queued_pool_size_bytes: Gauge,
33
34    /// Number of transactions in the blob sub-pool
35    pub(crate) blob_pool_transactions: Gauge,
36    /// Total amount of memory used by the transactions in the blob sub-pool in bytes
37    pub(crate) blob_pool_size_bytes: Gauge,
38
39    /// Number of all transactions of all sub-pools: pending + basefee + queued + blob
40    pub(crate) total_transactions: Gauge,
41    /// Number of all legacy transactions in the pool
42    pub(crate) total_legacy_transactions: Gauge,
43    /// Number of all EIP-2930 transactions in the pool
44    pub(crate) total_eip2930_transactions: Gauge,
45    /// Number of all EIP-1559 transactions in the pool
46    pub(crate) total_eip1559_transactions: Gauge,
47    /// Number of all EIP-4844 transactions in the pool
48    pub(crate) total_eip4844_transactions: Gauge,
49    /// Number of all EIP-7702 transactions in the pool
50    pub(crate) total_eip7702_transactions: Gauge,
51
52    /// How often the pool was updated after the canonical state changed
53    pub(crate) performed_state_updates: Counter,
54
55    /// Counter for the number of pending transactions evicted
56    pub(crate) pending_transactions_evicted: Counter,
57    /// Counter for the number of basefee transactions evicted
58    pub(crate) basefee_transactions_evicted: Counter,
59    /// Counter for the number of blob transactions evicted
60    pub(crate) blob_transactions_evicted: Counter,
61    /// Counter for the number of queued transactions evicted
62    pub(crate) queued_transactions_evicted: Counter,
63}
64
65/// Transaction pool blobstore metrics
66#[derive(Metrics)]
67#[metrics(scope = "transaction_pool")]
68pub struct BlobStoreMetrics {
69    /// Number of failed inserts into the blobstore
70    pub(crate) blobstore_failed_inserts: Counter,
71    /// Number of failed deletes into the blobstore
72    pub(crate) blobstore_failed_deletes: Counter,
73    /// The number of bytes the blobs in the blobstore take up
74    pub(crate) blobstore_byte_size: Gauge,
75    /// How many blobs are currently in the blobstore
76    pub(crate) blobstore_entries: Gauge,
77}
78
79/// Transaction pool maintenance metrics
80#[derive(Metrics)]
81#[metrics(scope = "transaction_pool")]
82pub struct MaintainPoolMetrics {
83    /// Gauge indicating the number of addresses with pending updates in the pool,
84    /// requiring their account information to be fetched.
85    pub(crate) dirty_accounts: Gauge,
86    /// Counter for the number of times the pool state diverged from the canonical blockchain
87    /// state.
88    pub(crate) drift_count: Counter,
89    /// Counter for the number of transactions reinserted into the pool following a blockchain
90    /// reorganization (reorg).
91    pub(crate) reinserted_transactions: Counter,
92    /// Counter for the number of finalized blob transactions that have been removed from tracking.
93    pub(crate) deleted_tracked_finalized_blobs: Counter,
94}
95
96impl MaintainPoolMetrics {
97    #[inline]
98    pub(crate) fn set_dirty_accounts_len(&self, count: usize) {
99        self.dirty_accounts.set(count as f64);
100    }
101
102    #[inline]
103    pub(crate) fn inc_reinserted_transactions(&self, count: usize) {
104        self.reinserted_transactions.increment(count as u64);
105    }
106
107    #[inline]
108    pub(crate) fn inc_deleted_tracked_blobs(&self, count: usize) {
109        self.deleted_tracked_finalized_blobs.increment(count as u64);
110    }
111
112    #[inline]
113    pub(crate) fn inc_drift(&self) {
114        self.drift_count.increment(1);
115    }
116}
117
118/// All Transactions metrics
119#[derive(Metrics)]
120#[metrics(scope = "transaction_pool")]
121pub struct AllTransactionsMetrics {
122    /// Number of all transactions by hash in the pool
123    pub(crate) all_transactions_by_hash: Gauge,
124    /// Number of all transactions by id in the pool
125    pub(crate) all_transactions_by_id: Gauge,
126    /// Number of all transactions by all senders in the pool
127    pub(crate) all_transactions_by_all_senders: Gauge,
128    /// Number of blob transactions nonce gaps.
129    pub(crate) blob_transactions_nonce_gaps: Counter,
130    /// The current blob base fee
131    pub(crate) blob_base_fee: Gauge,
132    /// The current base fee
133    pub(crate) base_fee: Gauge,
134}