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
56/// Transaction pool blobstore metrics
57#[derive(Metrics)]
58#[metrics(scope = "transaction_pool")]
59pub struct BlobStoreMetrics {
60 /// Number of failed inserts into the blobstore
61 pub(crate) blobstore_failed_inserts: Counter,
62 /// Number of failed deletes into the blobstore
63 pub(crate) blobstore_failed_deletes: Counter,
64 /// The number of bytes the blobs in the blobstore take up
65 pub(crate) blobstore_byte_size: Gauge,
66 /// How many blobs are currently in the blobstore
67 pub(crate) blobstore_entries: Gauge,
68}
69
70/// Transaction pool maintenance metrics
71#[derive(Metrics)]
72#[metrics(scope = "transaction_pool")]
73pub struct MaintainPoolMetrics {
74 /// Gauge indicating the number of addresses with pending updates in the pool,
75 /// requiring their account information to be fetched.
76 pub(crate) dirty_accounts: Gauge,
77 /// Counter for the number of times the pool state diverged from the canonical blockchain
78 /// state.
79 pub(crate) drift_count: Counter,
80 /// Counter for the number of transactions reinserted into the pool following a blockchain
81 /// reorganization (reorg).
82 pub(crate) reinserted_transactions: Counter,
83 /// Counter for the number of finalized blob transactions that have been removed from tracking.
84 pub(crate) deleted_tracked_finalized_blobs: Counter,
85}
86
87impl MaintainPoolMetrics {
88 #[inline]
89 pub(crate) fn set_dirty_accounts_len(&self, count: usize) {
90 self.dirty_accounts.set(count as f64);
91 }
92
93 #[inline]
94 pub(crate) fn inc_reinserted_transactions(&self, count: usize) {
95 self.reinserted_transactions.increment(count as u64);
96 }
97
98 #[inline]
99 pub(crate) fn inc_deleted_tracked_blobs(&self, count: usize) {
100 self.deleted_tracked_finalized_blobs.increment(count as u64);
101 }
102
103 #[inline]
104 pub(crate) fn inc_drift(&self) {
105 self.drift_count.increment(1);
106 }
107}
108
109/// All Transactions metrics
110#[derive(Metrics)]
111#[metrics(scope = "transaction_pool")]
112pub struct AllTransactionsMetrics {
113 /// Number of all transactions by hash in the pool
114 pub(crate) all_transactions_by_hash: Gauge,
115 /// Number of all transactions by id in the pool
116 pub(crate) all_transactions_by_id: Gauge,
117 /// Number of all transactions by all senders in the pool
118 pub(crate) all_transactions_by_all_senders: Gauge,
119 /// Number of blob transactions nonce gaps.
120 pub(crate) blob_transactions_nonce_gaps: Counter,
121 /// The current blob base fee
122 pub(crate) blob_base_fee: Gauge,
123 /// The current base fee
124 pub(crate) base_fee: Gauge,
125}