1//! Transaction pool metrics.
23use reth_metrics::{
4 metrics::{Counter, Gauge, Histogram},
5 Metrics,
6};
78/// Transaction pool metrics
9#[derive(Metrics)]
10#[metrics(scope = "transaction_pool")]
11pub struct TxPoolMetrics {
12/// Number of transactions inserted in the pool
13pub(crate) inserted_transactions: Counter,
14/// Number of invalid transactions
15pub(crate) invalid_transactions: Counter,
16/// Number of removed transactions from the pool
17pub(crate) removed_transactions: Counter,
1819/// Number of transactions in the pending sub-pool
20pub(crate) pending_pool_transactions: Gauge,
21/// Total amount of memory used by the transactions in the pending sub-pool in bytes
22pub(crate) pending_pool_size_bytes: Gauge,
2324/// Number of transactions in the basefee sub-pool
25pub(crate) basefee_pool_transactions: Gauge,
26/// Total amount of memory used by the transactions in the basefee sub-pool in bytes
27pub(crate) basefee_pool_size_bytes: Gauge,
2829/// Number of transactions in the queued sub-pool
30pub(crate) queued_pool_transactions: Gauge,
31/// Total amount of memory used by the transactions in the queued sub-pool in bytes
32pub(crate) queued_pool_size_bytes: Gauge,
3334/// Number of transactions in the blob sub-pool
35pub(crate) blob_pool_transactions: Gauge,
36/// Total amount of memory used by the transactions in the blob sub-pool in bytes
37pub(crate) blob_pool_size_bytes: Gauge,
3839/// Number of all transactions of all sub-pools: pending + basefee + queued + blob
40pub(crate) total_transactions: Gauge,
41/// Number of all legacy transactions in the pool
42pub(crate) total_legacy_transactions: Gauge,
43/// Number of all EIP-2930 transactions in the pool
44pub(crate) total_eip2930_transactions: Gauge,
45/// Number of all EIP-1559 transactions in the pool
46pub(crate) total_eip1559_transactions: Gauge,
47/// Number of all EIP-4844 transactions in the pool
48pub(crate) total_eip4844_transactions: Gauge,
49/// Number of all EIP-7702 transactions in the pool
50pub(crate) total_eip7702_transactions: Gauge,
5152/// How often the pool was updated after the canonical state changed
53pub(crate) performed_state_updates: Counter,
5455/// Counter for the number of pending transactions evicted
56pub(crate) pending_transactions_evicted: Counter,
57/// Counter for the number of basefee transactions evicted
58pub(crate) basefee_transactions_evicted: Counter,
59/// Counter for the number of blob transactions evicted
60pub(crate) blob_transactions_evicted: Counter,
61/// Counter for the number of queued transactions evicted
62pub(crate) queued_transactions_evicted: Counter,
63}
6465/// Transaction pool blobstore metrics
66#[derive(Metrics)]
67#[metrics(scope = "transaction_pool")]
68pub struct BlobStoreMetrics {
69/// Number of failed inserts into the blobstore
70pub(crate) blobstore_failed_inserts: Counter,
71/// Number of failed deletes into the blobstore
72pub(crate) blobstore_failed_deletes: Counter,
73/// The number of bytes the blobs in the blobstore take up
74pub(crate) blobstore_byte_size: Gauge,
75/// How many blobs are currently in the blobstore
76pub(crate) blobstore_entries: Gauge,
77}
7879/// 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.
85pub(crate) dirty_accounts: Gauge,
86/// Counter for the number of times the pool state diverged from the canonical blockchain
87 /// state.
88pub(crate) drift_count: Counter,
89/// Counter for the number of transactions reinserted into the pool following a blockchain
90 /// reorganization (reorg).
91pub(crate) reinserted_transactions: Counter,
92/// Counter for the number of finalized blob transactions that have been removed from tracking.
93pub(crate) deleted_tracked_finalized_blobs: Counter,
94}
9596impl MaintainPoolMetrics {
97#[inline]
98pub(crate) fn set_dirty_accounts_len(&self, count: usize) {
99self.dirty_accounts.set(countas f64);
100 }
101102#[inline]
103pub(crate) fn inc_reinserted_transactions(&self, count: usize) {
104self.reinserted_transactions.increment(countas u64);
105 }
106107#[inline]
108pub(crate) fn inc_deleted_tracked_blobs(&self, count: usize) {
109self.deleted_tracked_finalized_blobs.increment(countas u64);
110 }
111112#[inline]
113pub(crate) fn inc_drift(&self) {
114self.drift_count.increment(1);
115 }
116}
117118/// All Transactions metrics
119#[derive(Metrics)]
120#[metrics(scope = "transaction_pool")]
121pub struct AllTransactionsMetrics {
122/// Number of all transactions by hash in the pool
123pub(crate) all_transactions_by_hash: Gauge,
124/// Number of all transactions by id in the pool
125pub(crate) all_transactions_by_id: Gauge,
126/// Number of all transactions by all senders in the pool
127pub(crate) all_transactions_by_all_senders: Gauge,
128/// Number of blob transactions nonce gaps.
129pub(crate) blob_transactions_nonce_gaps: Counter,
130/// The current blob base fee
131pub(crate) blob_base_fee: Gauge,
132/// The current base fee
133pub(crate) base_fee: Gauge,
134}
135136/// Transaction pool validation metrics
137#[derive(Metrics)]
138#[metrics(scope = "transaction_pool")]
139pub struct TxPoolValidationMetrics {
140/// How long to successfully validate a blob
141pub(crate) blob_validation_duration: Histogram,
142}