@aztec/p2p 0.0.1-commit.7cf39cb55 → 0.0.1-commit.808bf7f90

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/dest/client/factory.d.ts +3 -2
  2. package/dest/client/factory.d.ts.map +1 -1
  3. package/dest/client/factory.js +5 -3
  4. package/dest/client/interface.d.ts +7 -9
  5. package/dest/client/interface.d.ts.map +1 -1
  6. package/dest/client/p2p_client.d.ts +4 -7
  7. package/dest/client/p2p_client.d.ts.map +1 -1
  8. package/dest/client/p2p_client.js +38 -14
  9. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +5 -5
  10. package/dest/config.d.ts +4 -6
  11. package/dest/config.d.ts.map +1 -1
  12. package/dest/config.js +0 -5
  13. package/dest/errors/tx-pool.error.d.ts +8 -0
  14. package/dest/errors/tx-pool.error.d.ts.map +1 -0
  15. package/dest/errors/tx-pool.error.js +9 -0
  16. package/dest/mem_pools/attestation_pool/mocks.d.ts +2 -2
  17. package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
  18. package/dest/mem_pools/attestation_pool/mocks.js +2 -2
  19. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +3 -3
  20. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +3 -1
  21. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -1
  22. package/dest/mem_pools/tx_pool_v2/deleted_pool.js +9 -0
  23. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +3 -3
  24. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -1
  25. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +18 -9
  26. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +3 -3
  27. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +3 -3
  28. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -1
  29. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +10 -4
  30. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +2 -2
  31. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -1
  32. package/dest/mem_pools/tx_pool_v2/eviction/index.js +1 -1
  33. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +48 -5
  34. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -1
  35. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +8 -0
  36. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +4 -4
  37. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +5 -5
  38. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +2 -2
  39. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -1
  40. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +12 -6
  41. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +4 -4
  42. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -1
  43. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +14 -4
  44. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +3 -3
  45. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -1
  46. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +2 -2
  47. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +15 -0
  48. package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
  49. package/dest/mem_pools/tx_pool_v2/instrumentation.js +43 -0
  50. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +12 -2
  51. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
  52. package/dest/mem_pools/tx_pool_v2/interfaces.js +3 -1
  53. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +7 -5
  54. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
  55. package/dest/mem_pools/tx_pool_v2/tx_metadata.js +29 -5
  56. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +5 -2
  57. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -1
  58. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +12 -2
  59. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +5 -2
  60. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
  61. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +6 -5
  62. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +10 -4
  63. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
  64. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +240 -124
  65. package/dest/msg_validators/tx_validator/gas_validator.d.ts +1 -1
  66. package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
  67. package/dest/msg_validators/tx_validator/gas_validator.js +3 -3
  68. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +2 -2
  69. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
  70. package/dest/msg_validators/tx_validator/timestamp_validator.js +6 -6
  71. package/dest/services/dummy_service.d.ts +3 -2
  72. package/dest/services/dummy_service.d.ts.map +1 -1
  73. package/dest/services/dummy_service.js +3 -0
  74. package/dest/services/encoding.d.ts +1 -1
  75. package/dest/services/encoding.d.ts.map +1 -1
  76. package/dest/services/encoding.js +2 -1
  77. package/dest/services/gossipsub/topic_score_params.d.ts +18 -6
  78. package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
  79. package/dest/services/gossipsub/topic_score_params.js +32 -10
  80. package/dest/services/libp2p/libp2p_service.d.ts +2 -1
  81. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  82. package/dest/services/libp2p/libp2p_service.js +7 -3
  83. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +4 -3
  84. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
  85. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +5 -9
  86. package/dest/services/reqresp/batch-tx-requester/interface.d.ts +2 -6
  87. package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
  88. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +10 -13
  89. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
  90. package/dest/services/reqresp/batch-tx-requester/missing_txs.js +25 -46
  91. package/dest/services/service.d.ts +4 -2
  92. package/dest/services/service.d.ts.map +1 -1
  93. package/dest/services/tx_collection/fast_tx_collection.d.ts +1 -1
  94. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
  95. package/dest/services/tx_collection/fast_tx_collection.js +39 -33
  96. package/dest/services/tx_collection/file_store_tx_collection.d.ts +1 -1
  97. package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -1
  98. package/dest/services/tx_collection/file_store_tx_collection.js +4 -2
  99. package/dest/services/tx_collection/file_store_tx_source.d.ts +15 -6
  100. package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -1
  101. package/dest/services/tx_collection/file_store_tx_source.js +47 -16
  102. package/dest/services/tx_collection/instrumentation.d.ts +1 -1
  103. package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
  104. package/dest/services/tx_collection/instrumentation.js +2 -1
  105. package/dest/services/tx_collection/missing_txs_tracker.d.ts +32 -0
  106. package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +1 -0
  107. package/dest/services/tx_collection/missing_txs_tracker.js +27 -0
  108. package/dest/services/tx_collection/proposal_tx_collector.d.ts +7 -6
  109. package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
  110. package/dest/services/tx_collection/proposal_tx_collector.js +5 -4
  111. package/dest/services/tx_collection/slow_tx_collection.d.ts +2 -2
  112. package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
  113. package/dest/services/tx_collection/slow_tx_collection.js +10 -8
  114. package/dest/services/tx_collection/tx_collection.d.ts +5 -4
  115. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
  116. package/dest/services/tx_collection/tx_collection_sink.d.ts +6 -5
  117. package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
  118. package/dest/services/tx_collection/tx_collection_sink.js +13 -22
  119. package/dest/services/tx_collection/tx_source.d.ts +8 -3
  120. package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
  121. package/dest/services/tx_collection/tx_source.js +19 -2
  122. package/dest/services/tx_file_store/tx_file_store.js +1 -1
  123. package/dest/test-helpers/mock-pubsub.d.ts +3 -2
  124. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
  125. package/dest/test-helpers/mock-pubsub.js +6 -0
  126. package/dest/test-helpers/testbench-utils.d.ts +5 -2
  127. package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
  128. package/dest/test-helpers/testbench-utils.js +1 -1
  129. package/dest/testbench/p2p_client_testbench_worker.d.ts +2 -2
  130. package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
  131. package/dest/testbench/p2p_client_testbench_worker.js +8 -8
  132. package/dest/util.d.ts +2 -2
  133. package/dest/util.d.ts.map +1 -1
  134. package/package.json +14 -14
  135. package/src/client/factory.ts +6 -2
  136. package/src/client/interface.ts +14 -9
  137. package/src/client/p2p_client.ts +44 -17
  138. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +18 -8
  139. package/src/config.ts +2 -10
  140. package/src/errors/tx-pool.error.ts +12 -0
  141. package/src/mem_pools/attestation_pool/mocks.ts +2 -1
  142. package/src/mem_pools/tx_pool/README.md +1 -1
  143. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +3 -3
  144. package/src/mem_pools/tx_pool_v2/README.md +1 -1
  145. package/src/mem_pools/tx_pool_v2/deleted_pool.ts +11 -0
  146. package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +21 -8
  147. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +3 -3
  148. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +15 -4
  149. package/src/mem_pools/tx_pool_v2/eviction/index.ts +4 -0
  150. package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +49 -4
  151. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +4 -4
  152. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +5 -5
  153. package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +12 -9
  154. package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +24 -6
  155. package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +3 -3
  156. package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
  157. package/src/mem_pools/tx_pool_v2/interfaces.ts +11 -2
  158. package/src/mem_pools/tx_pool_v2/tx_metadata.ts +40 -9
  159. package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +14 -3
  160. package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +11 -6
  161. package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +262 -117
  162. package/src/msg_validators/tx_validator/gas_validator.ts +11 -3
  163. package/src/msg_validators/tx_validator/timestamp_validator.ts +7 -7
  164. package/src/services/dummy_service.ts +5 -1
  165. package/src/services/encoding.ts +2 -1
  166. package/src/services/gossipsub/README.md +29 -14
  167. package/src/services/gossipsub/topic_score_params.ts +49 -13
  168. package/src/services/libp2p/libp2p_service.ts +7 -2
  169. package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +6 -6
  170. package/src/services/reqresp/batch-tx-requester/interface.ts +1 -5
  171. package/src/services/reqresp/batch-tx-requester/missing_txs.ts +23 -71
  172. package/src/services/service.ts +10 -1
  173. package/src/services/tx_collection/fast_tx_collection.ts +51 -30
  174. package/src/services/tx_collection/file_store_tx_collection.ts +7 -3
  175. package/src/services/tx_collection/file_store_tx_source.ts +61 -17
  176. package/src/services/tx_collection/instrumentation.ts +7 -1
  177. package/src/services/tx_collection/missing_txs_tracker.ts +52 -0
  178. package/src/services/tx_collection/proposal_tx_collector.ts +8 -7
  179. package/src/services/tx_collection/slow_tx_collection.ts +8 -9
  180. package/src/services/tx_collection/tx_collection.ts +4 -3
  181. package/src/services/tx_collection/tx_collection_sink.ts +15 -29
  182. package/src/services/tx_collection/tx_source.ts +22 -3
  183. package/src/services/tx_file_store/tx_file_store.ts +1 -1
  184. package/src/test-helpers/mock-pubsub.ts +10 -0
  185. package/src/test-helpers/testbench-utils.ts +2 -2
  186. package/src/testbench/p2p_client_testbench_worker.ts +20 -13
  187. package/src/util.ts +7 -1
@@ -16,14 +16,12 @@ import type { PeerId } from '@libp2p/interface';
16
16
  import { peerIdFromString } from '@libp2p/peer-id';
17
17
 
18
18
  import type { P2PConfig } from '../../../config.js';
19
+ import { BatchTxRequesterCollector, SendBatchRequestCollector } from '../../../services/index.js';
19
20
  import type { IBatchRequestTxValidator } from '../../../services/reqresp/batch-tx-requester/tx_validator.js';
20
21
  import { RateLimitStatus } from '../../../services/reqresp/rate-limiter/rate_limiter.js';
22
+ import { MissingTxsTracker } from '../../../services/tx_collection/missing_txs_tracker.js';
21
23
  import {
22
- BatchTxRequesterCollector,
23
- SendBatchRequestCollector,
24
- } from '../../../services/tx_collection/proposal_tx_collector.js';
25
- import { AlwaysTrueCircuitVerifier } from '../../../test-helpers/reqresp-nodes.js';
26
- import {
24
+ AlwaysTrueCircuitVerifier,
27
25
  BENCHMARK_CONSTANTS,
28
26
  InMemoryAttestationPool,
29
27
  InMemoryTxPool,
@@ -31,7 +29,7 @@ import {
31
29
  calculateInternalTimeout,
32
30
  createMockEpochCache,
33
31
  createMockWorldStateSynchronizer,
34
- } from '../../../test-helpers/testbench-utils.js';
32
+ } from '../../../test-helpers/index.js';
35
33
  import { createP2PClient } from '../../index.js';
36
34
  import type { P2PClient } from '../../p2p_client.js';
37
35
  import {
@@ -214,7 +212,13 @@ async function runCollector(cmd: Extract<WorkerCommand, { type: 'RUN_COLLECTOR'
214
212
  if (collectorType === 'batch-requester') {
215
213
  const collector = new BatchTxRequesterCollector(p2pService, logger, new DateProvider(), noopTxValidator);
216
214
  const fetched = await executeTimeout(
217
- (_signal: AbortSignal) => collector.collectTxs(parsedTxHashes, parsedProposal, pinnedPeer, internalTimeoutMs),
215
+ (_signal: AbortSignal) =>
216
+ collector.collectTxs(
217
+ MissingTxsTracker.fromArray(parsedTxHashes),
218
+ parsedProposal,
219
+ pinnedPeer,
220
+ internalTimeoutMs,
221
+ ),
218
222
  timeoutMs,
219
223
  () => new Error(`Collector timed out after ${timeoutMs}ms`),
220
224
  );
@@ -226,7 +230,13 @@ async function runCollector(cmd: Extract<WorkerCommand, { type: 'RUN_COLLECTOR'
226
230
  BENCHMARK_CONSTANTS.FIXED_MAX_RETRY_ATTEMPTS,
227
231
  );
228
232
  const fetched = await executeTimeout(
229
- (_signal: AbortSignal) => collector.collectTxs(parsedTxHashes, parsedProposal, pinnedPeer, internalTimeoutMs),
233
+ (_signal: AbortSignal) =>
234
+ collector.collectTxs(
235
+ MissingTxsTracker.fromArray(parsedTxHashes),
236
+ parsedProposal,
237
+ pinnedPeer,
238
+ internalTimeoutMs,
239
+ ),
230
240
  timeoutMs,
231
241
  () => new Error(`Collector timed out after ${timeoutMs}ms`),
232
242
  );
package/src/config.ts CHANGED
@@ -38,7 +38,7 @@ export interface P2PConfig
38
38
  ChainConfig,
39
39
  TxCollectionConfig,
40
40
  TxFileStoreConfig,
41
- Pick<SequencerConfig, 'blockDurationMs'> {
41
+ Pick<SequencerConfig, 'blockDurationMs' | 'expectedBlockProposalsPerSlot'> {
42
42
  /** A flag dictating whether the P2P subsystem should be enabled. */
43
43
  p2pEnabled: boolean;
44
44
 
@@ -173,10 +173,7 @@ export interface P2PConfig
173
173
  /** Whether transactions are disabled for this node. This means transactions will be rejected at the RPC and P2P layers. */
174
174
  disableTransactions: boolean;
175
175
 
176
- /** True to simulate discarding transactions. - For testing purposes only*/
177
- dropTransactions: boolean;
178
-
179
- /** The probability that a transaction is discarded. - For testing purposes only */
176
+ /** The probability that a transaction is discarded (0 = disabled). - For testing purposes only */
180
177
  dropTransactionsProbability: number;
181
178
 
182
179
  /** Whether to delete transactions from the pool after a reorg instead of moving them back to pending. */
@@ -430,11 +427,6 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
430
427
  description: 'Number of auth attempts to allow before peer is banned. Number is inclusive',
431
428
  ...numberConfigHelper(3),
432
429
  },
433
- dropTransactions: {
434
- env: 'P2P_DROP_TX',
435
- description: 'True to simulate discarding transactions. - For testing purposes only',
436
- ...booleanConfigHelper(false),
437
- },
438
430
  dropTransactionsProbability: {
439
431
  env: 'P2P_DROP_TX_CHANCE',
440
432
  description: 'The probability that a transaction is discarded (0 - 1). - For testing purposes only',
@@ -0,0 +1,12 @@
1
+ import type { TxPoolRejectionError } from '../mem_pools/tx_pool_v2/eviction/interfaces.js';
2
+
3
+ /** Error thrown when a transaction is not added to the mempool. */
4
+ export class TxPoolError extends Error {
5
+ public readonly data: TxPoolRejectionError;
6
+
7
+ constructor(public readonly reason: TxPoolRejectionError) {
8
+ super(reason.message);
9
+ this.name = 'TxPoolError';
10
+ this.data = reason;
11
+ }
12
+ }
@@ -34,9 +34,10 @@ export const mockCheckpointAttestation = (
34
34
  slot: number = 0,
35
35
  archive: Fr = Fr.random(),
36
36
  header?: CheckpointHeader,
37
+ feeAssetPriceModifier: bigint = 0n,
37
38
  ): CheckpointAttestation => {
38
39
  header = header ?? CheckpointHeader.random({ slotNumber: SlotNumber(slot) });
39
- const payload = new ConsensusPayload(header, archive);
40
+ const payload = new ConsensusPayload(header, archive, feeAssetPriceModifier);
40
41
 
41
42
  const attestationHash = getHashedSignaturePayloadEthSignedMessage(
42
43
  payload,
@@ -213,7 +213,7 @@ The [`EvictionManager`](eviction/eviction_manager.ts) coordinates eviction by:
213
213
  Evicts transactions that become invalid after a block is mined:
214
214
 
215
215
  - Duplicate nullifiers: Txs with nullifiers already included in the mined block
216
- - Expired transactions: Txs with `includeByTimestamp` ≤ mined block timestamp
216
+ - Expired transactions: Txs with `expirationTimestamp` ≤ mined block timestamp
217
217
 
218
218
  #### 2. `InvalidTxsAfterReorgRule`
219
219
 
@@ -68,10 +68,10 @@ export class InvalidTxsAfterMiningRule implements EvictionRule {
68
68
  }
69
69
 
70
70
  // Evict pending txs with an expiration timestamp less than or equal to the mined block timestamp
71
- const includeByTimestamp = tx.data.includeByTimestamp;
72
- if (includeByTimestamp <= timestamp) {
71
+ const expirationTimestamp = tx.data.expirationTimestamp;
72
+ if (expirationTimestamp <= timestamp) {
73
73
  this.log.verbose(
74
- `Evicting tx ${txHash} from pool due to the tx being expired (includeByTimestamp: ${includeByTimestamp}, mined block timestamp: ${timestamp})`,
74
+ `Evicting tx ${txHash} from pool due to the tx being expired (expirationTimestamp: ${expirationTimestamp}, mined block timestamp: ${timestamp})`,
75
75
  );
76
76
  txsToEvict.push(txHash);
77
77
  continue;
@@ -79,7 +79,7 @@ Lightweight metadata stored alongside each transaction:
79
79
  - `claimAmount`: Fee payer's claim from bridging
80
80
  - `feeLimit`: Maximum fee the tx can pay
81
81
  - `nullifiers`: For conflict detection
82
- - `includeByTimestamp`: Expiration timestamp
82
+ - `expirationTimestamp`: Expiration timestamp
83
83
  - `minedL2BlockId`: Set when mined (undefined otherwise)
84
84
 
85
85
  State is derived by TxPoolIndices:
@@ -301,6 +301,17 @@ export class DeletedPool {
301
301
  return this.#state.size;
302
302
  }
303
303
 
304
+ /** Gets the count of soft-deleted transactions (both prune-based and slot-based). */
305
+ getSoftDeletedCount(): number {
306
+ let count = this.#slotDeletedTxs.size;
307
+ for (const state of this.#state.values()) {
308
+ if (state.softDeleted) {
309
+ count++;
310
+ }
311
+ }
312
+ return count;
313
+ }
314
+
304
315
  /**
305
316
  * Gets all transaction hashes from pruned blocks.
306
317
  */
@@ -9,9 +9,12 @@ import {
9
9
  EvictionEvent,
10
10
  type EvictionRule,
11
11
  type PoolOperations,
12
+ type PreAddContext,
12
13
  type PreAddPoolAccess,
13
14
  type PreAddResult,
14
15
  type PreAddRule,
16
+ type TaggedEviction,
17
+ TxPoolRejectionCode,
15
18
  } from './interfaces.js';
16
19
 
17
20
  /**
@@ -47,21 +50,27 @@ export class EvictionManager {
47
50
  * Runs all pre-add rules for an incoming transaction.
48
51
  * Returns combined result of all rules.
49
52
  */
50
- async runPreAddRules(incomingMeta: TxMetaData, poolAccess: PreAddPoolAccess): Promise<PreAddResult> {
51
- const allTxHashesToEvict: string[] = [];
53
+ async runPreAddRules(
54
+ incomingMeta: TxMetaData,
55
+ poolAccess: PreAddPoolAccess,
56
+ context?: PreAddContext,
57
+ ): Promise<PreAddResult> {
58
+ const evictions: TaggedEviction[] = [];
59
+ const seen = new Set<string>();
52
60
 
53
61
  for (const rule of this.preAddRules) {
54
62
  try {
55
- const result = await rule.check(incomingMeta, poolAccess);
63
+ const result = await rule.check(incomingMeta, poolAccess, context);
56
64
 
57
65
  if (result.shouldIgnore) {
58
66
  return result;
59
67
  }
60
68
 
61
- // Collect txs to evict from all rules
69
+ // Collect txs to evict from all rules, tagged with the rule name
62
70
  for (const txHash of result.txHashesToEvict) {
63
- if (!allTxHashesToEvict.includes(txHash)) {
64
- allTxHashesToEvict.push(txHash);
71
+ if (!seen.has(txHash)) {
72
+ seen.add(txHash);
73
+ evictions.push({ txHash, reason: rule.name });
65
74
  }
66
75
  }
67
76
  } catch (err) {
@@ -70,14 +79,18 @@ export class EvictionManager {
70
79
  return {
71
80
  shouldIgnore: true,
72
81
  txHashesToEvict: [],
73
- reason: `pre-add rule ${rule.name} error: ${err}`,
82
+ reason: {
83
+ code: TxPoolRejectionCode.INTERNAL_ERROR,
84
+ message: `Pre-add rule ${rule.name} error: ${err}`,
85
+ },
74
86
  };
75
87
  }
76
88
  }
77
89
 
78
90
  return {
79
91
  shouldIgnore: false,
80
- txHashesToEvict: allTxHashesToEvict,
92
+ txHashesToEvict: evictions.map(e => e.txHash),
93
+ evictions,
81
94
  };
82
95
  }
83
96
 
@@ -34,7 +34,7 @@ export class FeePayerBalanceEvictionRule implements EvictionRule {
34
34
  }
35
35
 
36
36
  if (context.event === EvictionEvent.CHAIN_PRUNED) {
37
- await this.worldState.syncImmediate(context.blockNumber);
37
+ await this.worldState.syncImmediate();
38
38
  const feePayers = pool.getPendingFeePayers();
39
39
  return await this.evictForFeePayers(feePayers, this.worldState.getSnapshot(context.blockNumber), pool);
40
40
  }
@@ -67,8 +67,8 @@ export class FeePayerBalanceEvictionRule implements EvictionRule {
67
67
  ).flat();
68
68
 
69
69
  if (txsToEvict.length > 0) {
70
- await pool.deleteTxs(txsToEvict);
71
- this.log.verbose(`Evicted ${txsToEvict.length} txs due to insufficient fee payer balance`, {
70
+ await pool.deleteTxs(txsToEvict, this.name);
71
+ this.log.debug(`Evicted ${txsToEvict.length} txs due to insufficient fee payer balance`, {
72
72
  txHashes: txsToEvict,
73
73
  });
74
74
  }
@@ -1,7 +1,13 @@
1
1
  import { createLogger } from '@aztec/foundation/log';
2
2
 
3
3
  import { type TxMetaData, comparePriority } from '../tx_metadata.js';
4
- import type { PreAddPoolAccess, PreAddResult, PreAddRule } from './interfaces.js';
4
+ import {
5
+ type PreAddContext,
6
+ type PreAddPoolAccess,
7
+ type PreAddResult,
8
+ type PreAddRule,
9
+ TxPoolRejectionCode,
10
+ } from './interfaces.js';
5
11
 
6
12
  /**
7
13
  * Pre-add rule that checks if a fee payer has sufficient balance to cover the incoming transaction.
@@ -19,7 +25,7 @@ export class FeePayerBalancePreAddRule implements PreAddRule {
19
25
 
20
26
  private log = createLogger('p2p:tx_pool_v2:fee_payer_balance_pre_add_rule');
21
27
 
22
- async check(incomingMeta: TxMetaData, poolAccess: PreAddPoolAccess): Promise<PreAddResult> {
28
+ async check(incomingMeta: TxMetaData, poolAccess: PreAddPoolAccess, _context?: PreAddContext): Promise<PreAddResult> {
23
29
  // Get fee payer's on-chain balance
24
30
  const initialBalance = await poolAccess.getFeePayerBalance(incomingMeta.feePayer);
25
31
 
@@ -78,7 +84,13 @@ export class FeePayerBalancePreAddRule implements PreAddRule {
78
84
  return {
79
85
  shouldIgnore: true,
80
86
  txHashesToEvict: [],
81
- reason: `fee payer ${incomingMeta.feePayer} has insufficient balance`,
87
+ reason: {
88
+ code: TxPoolRejectionCode.INSUFFICIENT_FEE_PAYER_BALANCE,
89
+ message: `Fee payer ${incomingMeta.feePayer} has insufficient balance. Balance at transaction: ${available}, required: ${incomingMeta.feeLimit}`,
90
+ currentBalance: initialBalance,
91
+ availableBalance: available,
92
+ feeLimit: incomingMeta.feeLimit,
93
+ },
82
94
  };
83
95
  } else {
84
96
  // Existing tx cannot be covered after adding incoming - mark for eviction
@@ -93,7 +105,6 @@ export class FeePayerBalancePreAddRule implements PreAddRule {
93
105
  return {
94
106
  shouldIgnore: true,
95
107
  txHashesToEvict: [],
96
- reason: 'internal error: tx coverage not determined',
97
108
  };
98
109
  }
99
110
 
@@ -6,9 +6,13 @@ export {
6
6
  type EvictionResult,
7
7
  type EvictionRule,
8
8
  type PoolOperations,
9
+ type PreAddContext,
9
10
  type PreAddPoolAccess,
10
11
  type PreAddResult,
11
12
  type PreAddRule,
13
+ type TaggedEviction,
14
+ TxPoolRejectionCode,
15
+ type TxPoolRejectionError,
12
16
  } from './interfaces.js';
13
17
 
14
18
  // Pre-add rules
@@ -67,6 +67,42 @@ export interface PreAddPoolAccess {
67
67
  getLowestPriorityPendingTx(): TxMetaData | undefined;
68
68
  }
69
69
 
70
+ /** A single eviction tagged with the rule that caused it. */
71
+ export interface TaggedEviction {
72
+ readonly txHash: string;
73
+ readonly reason: string;
74
+ }
75
+
76
+ /**
77
+ * Machine-readable rejection codes for pre-add rule rejections.
78
+ */
79
+ export const TxPoolRejectionCode = {
80
+ LOW_PRIORITY_FEE: 'LOW_PRIORITY_FEE',
81
+ INSUFFICIENT_FEE_PAYER_BALANCE: 'INSUFFICIENT_FEE_PAYER_BALANCE',
82
+ NULLIFIER_CONFLICT: 'NULLIFIER_CONFLICT',
83
+ INTERNAL_ERROR: 'INTERNAL_ERROR',
84
+ } as const;
85
+
86
+ export type TxPoolRejectionCode = (typeof TxPoolRejectionCode)[keyof typeof TxPoolRejectionCode];
87
+
88
+ /** Structured rejection reason returned by pre-add rules. */
89
+ export type TxPoolRejectionError =
90
+ | {
91
+ code: typeof TxPoolRejectionCode.LOW_PRIORITY_FEE;
92
+ message: string;
93
+ minimumPriorityFee: bigint;
94
+ txPriorityFee: bigint;
95
+ }
96
+ | {
97
+ code: typeof TxPoolRejectionCode.INSUFFICIENT_FEE_PAYER_BALANCE;
98
+ message: string;
99
+ currentBalance: bigint;
100
+ availableBalance: bigint;
101
+ feeLimit: bigint;
102
+ }
103
+ | { code: typeof TxPoolRejectionCode.NULLIFIER_CONFLICT; message: string; conflictingTxHash: string }
104
+ | { code: typeof TxPoolRejectionCode.INTERNAL_ERROR; message: string };
105
+
70
106
  /**
71
107
  * Result of a pre-add check for a single transaction.
72
108
  */
@@ -75,8 +111,16 @@ export interface PreAddResult {
75
111
  readonly shouldIgnore: boolean;
76
112
  /** Tx hashes (as strings) that should be evicted if this tx is added */
77
113
  readonly txHashesToEvict: string[];
114
+ /** Evictions tagged with the rule name that produced them. Populated by EvictionManager. */
115
+ readonly evictions?: TaggedEviction[];
78
116
  /** Optional reason for ignoring */
79
- readonly reason?: string;
117
+ readonly reason?: TxPoolRejectionError;
118
+ }
119
+
120
+ /** Context passed to pre-add rules from addPendingTxs. */
121
+ export interface PreAddContext {
122
+ /** If true, compare priority fee only (no tx hash tiebreaker). Used for RPC submissions. */
123
+ feeComparisonOnly?: boolean;
80
124
  }
81
125
 
82
126
  /**
@@ -90,9 +134,10 @@ export interface PreAddRule {
90
134
  * Check if incoming tx should be added and which existing txs to evict.
91
135
  * @param incomingMeta - Metadata for the incoming transaction
92
136
  * @param poolAccess - Read-only access to current pool state
137
+ * @param context - Optional context from addPendingTxs caller
93
138
  * @returns Result indicating whether to ignore and what to evict
94
139
  */
95
- check(incomingMeta: TxMetaData, poolAccess: PreAddPoolAccess): Promise<PreAddResult>;
140
+ check(incomingMeta: TxMetaData, poolAccess: PreAddPoolAccess, context?: PreAddContext): Promise<PreAddResult>;
96
141
 
97
142
  /**
98
143
  * Updates the configuration for this rule.
@@ -120,8 +165,8 @@ export interface PoolOperations {
120
165
  /** Get the N lowest priority pending tx hashes */
121
166
  getLowestPriorityPending(limit: number): string[];
122
167
 
123
- /** Delete transactions by hash */
124
- deleteTxs(txHashes: string[]): Promise<void>;
168
+ /** Delete transactions by hash, with an optional reason for metrics */
169
+ deleteTxs(txHashes: string[], reason?: string): Promise<void>;
125
170
  }
126
171
 
127
172
  /**
@@ -35,15 +35,14 @@ export class InvalidTxsAfterMiningRule implements EvictionRule {
35
35
  for (const meta of pendingTxs) {
36
36
  // Evict pending txs that share nullifiers with mined txs
37
37
  if (meta.nullifiers.some(nullifier => minedNullifiers.has(nullifier))) {
38
- this.log.verbose(`Evicting tx ${meta.txHash} from pool due to a duplicate nullifier with a mined tx`);
39
38
  txsToEvict.push(meta.txHash);
40
39
  continue;
41
40
  }
42
41
 
43
42
  // Evict pending txs with an expiration timestamp less than or equal to the mined block timestamp
44
- if (meta.includeByTimestamp <= timestamp) {
43
+ if (meta.expirationTimestamp <= timestamp) {
45
44
  this.log.verbose(
46
- `Evicting tx ${meta.txHash} from pool due to the tx being expired (includeByTimestamp: ${meta.includeByTimestamp}, mined block timestamp: ${timestamp})`,
45
+ `Evicting tx ${meta.txHash} from pool due to the tx being expired (expirationTimestamp: ${meta.expirationTimestamp}, mined block timestamp: ${timestamp})`,
47
46
  );
48
47
  txsToEvict.push(meta.txHash);
49
48
  continue;
@@ -51,7 +50,8 @@ export class InvalidTxsAfterMiningRule implements EvictionRule {
51
50
  }
52
51
 
53
52
  if (txsToEvict.length > 0) {
54
- await pool.deleteTxs(txsToEvict);
53
+ this.log.info(`Evicted ${txsToEvict.length} invalid txs after block mined`);
54
+ await pool.deleteTxs(txsToEvict, this.name);
55
55
  }
56
56
 
57
57
  this.log.debug(`Evicted ${txsToEvict.length} invalid txs after block mined`, { txHashes: txsToEvict });
@@ -45,8 +45,8 @@ export class InvalidTxsAfterReorgRule implements EvictionRule {
45
45
  txsByBlockHash.get(blockHashStr)!.push(meta.txHash);
46
46
  }
47
47
 
48
- // Ensure world state is synced to this block before accessing the snapshot
49
- await this.worldState.syncImmediate(context.blockNumber);
48
+ // Sync without a block number to ensure the world state processes the prune event.
49
+ await this.worldState.syncImmediate();
50
50
  const db = this.worldState.getSnapshot(context.blockNumber);
51
51
 
52
52
  // Check which blocks exist in the archive
@@ -72,8 +72,8 @@ export class InvalidTxsAfterReorgRule implements EvictionRule {
72
72
  }
73
73
 
74
74
  if (txsToEvict.length > 0) {
75
- this.log.verbose(`Evicting ${txsToEvict.length} txs from pool due to referencing pruned blocks`);
76
- await pool.deleteTxs(txsToEvict);
75
+ this.log.info(`Evicting ${txsToEvict.length} txs from pool due to referencing pruned blocks`);
76
+ await pool.deleteTxs(txsToEvict, this.name);
77
77
  }
78
78
 
79
79
  const keptCount = pendingTxs.length - txsToEvict.length;
@@ -81,7 +81,7 @@ export class InvalidTxsAfterReorgRule implements EvictionRule {
81
81
  this.log.verbose(`Kept ${keptCount} txs that did not reference pruned blocks`);
82
82
  }
83
83
 
84
- this.log.info(`Evicted ${txsToEvict.length} invalid txs after reorg`, { txHashes: txsToEvict });
84
+ this.log.debug(`Evicted ${txsToEvict.length} invalid txs after reorg`, { txHashes: txsToEvict });
85
85
 
86
86
  return {
87
87
  reason: 'reorg_invalid_txs',
@@ -5,7 +5,7 @@ import { EvictionEvent } from './interfaces.js';
5
5
 
6
6
  /**
7
7
  * Eviction rule that removes low-priority transactions when the pool exceeds configured limits.
8
- * Only triggers on TXS_ADDED events.
8
+ * Triggers on TXS_ADDED and CHAIN_PRUNED events.
9
9
  */
10
10
  export class LowPriorityEvictionRule implements EvictionRule {
11
11
  public readonly name = 'LowPriorityEviction';
@@ -18,7 +18,7 @@ export class LowPriorityEvictionRule implements EvictionRule {
18
18
  }
19
19
 
20
20
  async evict(context: EvictionContext, pool: PoolOperations): Promise<EvictionResult> {
21
- if (context.event !== EvictionEvent.TXS_ADDED) {
21
+ if (context.event !== EvictionEvent.TXS_ADDED && context.event !== EvictionEvent.CHAIN_PRUNED) {
22
22
  return {
23
23
  reason: 'low_priority',
24
24
  success: true,
@@ -48,19 +48,22 @@ export class LowPriorityEvictionRule implements EvictionRule {
48
48
  };
49
49
  }
50
50
 
51
- this.log.verbose(
52
- `Evicting low priority txs. Pending tx count above limit: ${currentTxCount} > ${this.maxPoolSize}`,
53
- );
51
+ this.log.info(`Evicting low priority txs. Pending tx count above limit: ${currentTxCount} > ${this.maxPoolSize}`);
54
52
  const numberToEvict = currentTxCount - this.maxPoolSize;
55
53
  const txsToEvict = pool.getLowestPriorityPending(numberToEvict);
56
54
 
57
55
  if (txsToEvict.length > 0) {
58
- await pool.deleteTxs(txsToEvict);
56
+ if (context.event === EvictionEvent.TXS_ADDED) {
57
+ const toEvictSet = new Set(txsToEvict);
58
+ const numNewTxsEvicted = context.newTxHashes.filter(newTxHash => toEvictSet.has(newTxHash)).length;
59
+ this.log.info(`Evicted ${txsToEvict.length} low priority txs, including ${numNewTxsEvicted} newly added txs`);
60
+ } else {
61
+ this.log.info(`Evicted ${txsToEvict.length} low priority txs after chain prune`);
62
+ }
63
+ await pool.deleteTxs(txsToEvict, this.name);
59
64
  }
60
65
 
61
- const numNewTxsEvicted = context.newTxHashes.filter(newTxHash => txsToEvict.includes(newTxHash)).length;
62
-
63
- this.log.verbose(`Evicted ${txsToEvict.length} low priority txs, including ${numNewTxsEvicted} newly added txs`, {
66
+ this.log.debug(`Evicted ${txsToEvict.length} low priority txs`, {
64
67
  txHashes: txsToEvict,
65
68
  });
66
69
 
@@ -1,7 +1,14 @@
1
1
  import { createLogger } from '@aztec/foundation/log';
2
2
 
3
- import type { TxMetaData } from '../tx_metadata.js';
4
- import type { EvictionConfig, PreAddPoolAccess, PreAddResult, PreAddRule } from './interfaces.js';
3
+ import { type TxMetaData, comparePriority } from '../tx_metadata.js';
4
+ import {
5
+ type EvictionConfig,
6
+ type PreAddContext,
7
+ type PreAddPoolAccess,
8
+ type PreAddResult,
9
+ type PreAddRule,
10
+ TxPoolRejectionCode,
11
+ } from './interfaces.js';
5
12
 
6
13
  /**
7
14
  * Pre-add rule that checks if the pool is at capacity and handles low-priority eviction.
@@ -20,7 +27,7 @@ export class LowPriorityPreAddRule implements PreAddRule {
20
27
  this.maxPoolSize = config.maxPoolSize;
21
28
  }
22
29
 
23
- check(incomingMeta: TxMetaData, poolAccess: PreAddPoolAccess): Promise<PreAddResult> {
30
+ check(incomingMeta: TxMetaData, poolAccess: PreAddPoolAccess, context?: PreAddContext): Promise<PreAddResult> {
24
31
  // Skip if max pool size is disabled (0 = unlimited)
25
32
  if (this.maxPoolSize === 0) {
26
33
  return Promise.resolve({ shouldIgnore: false, txHashesToEvict: [] });
@@ -40,8 +47,14 @@ export class LowPriorityPreAddRule implements PreAddRule {
40
47
  return Promise.resolve({ shouldIgnore: false, txHashesToEvict: [] });
41
48
  }
42
49
 
43
- // If incoming tx has strictly higher priority, evict the lowest priority tx
44
- if (incomingMeta.priorityFee > lowestPriorityMeta.priorityFee) {
50
+ // Compare incoming tx against lowest priority tx.
51
+ // feeOnly mode (RPC): use strict fee comparison only — avoids churn from hash ordering
52
+ // Default (gossip): use full comparePriority (fee + tx hash tiebreaker) for determinism
53
+ const isHigherPriority = context?.feeComparisonOnly
54
+ ? incomingMeta.priorityFee > lowestPriorityMeta.priorityFee
55
+ : comparePriority(incomingMeta, lowestPriorityMeta) > 0;
56
+
57
+ if (isHigherPriority) {
45
58
  this.log.debug(
46
59
  `Pool at capacity (${currentCount}/${this.maxPoolSize}), evicting ${lowestPriorityMeta.txHash} ` +
47
60
  `(priority ${lowestPriorityMeta.priorityFee}) for ${incomingMeta.txHash} (priority ${incomingMeta.priorityFee})`,
@@ -60,7 +73,12 @@ export class LowPriorityPreAddRule implements PreAddRule {
60
73
  return Promise.resolve({
61
74
  shouldIgnore: true,
62
75
  txHashesToEvict: [],
63
- reason: `pool at capacity and tx has lower priority than existing transactions`,
76
+ reason: {
77
+ code: TxPoolRejectionCode.LOW_PRIORITY_FEE,
78
+ message: `Tx does not meet minimum priority fee. Required: ${lowestPriorityMeta.priorityFee + 1n}, got: ${incomingMeta.priorityFee}`,
79
+ minimumPriorityFee: lowestPriorityMeta.priorityFee + 1n,
80
+ txPriorityFee: incomingMeta.priorityFee,
81
+ },
64
82
  });
65
83
  }
66
84
 
@@ -1,7 +1,7 @@
1
1
  import { createLogger } from '@aztec/foundation/log';
2
2
 
3
3
  import { type TxMetaData, checkNullifierConflict } from '../tx_metadata.js';
4
- import type { PreAddPoolAccess, PreAddResult, PreAddRule } from './interfaces.js';
4
+ import type { PreAddContext, PreAddPoolAccess, PreAddResult, PreAddRule } from './interfaces.js';
5
5
 
6
6
  /**
7
7
  * Pre-add rule that checks for nullifier conflicts between incoming and existing transactions.
@@ -15,7 +15,7 @@ export class NullifierConflictRule implements PreAddRule {
15
15
 
16
16
  private log = createLogger('p2p:tx_pool_v2:nullifier_conflict_rule');
17
17
 
18
- check(incomingMeta: TxMetaData, poolAccess: PreAddPoolAccess): Promise<PreAddResult> {
18
+ check(incomingMeta: TxMetaData, poolAccess: PreAddPoolAccess, _context?: PreAddContext): Promise<PreAddResult> {
19
19
  const result = checkNullifierConflict(
20
20
  incomingMeta,
21
21
  nullifier => poolAccess.getTxHashByNullifier(nullifier),
@@ -23,7 +23,7 @@ export class NullifierConflictRule implements PreAddRule {
23
23
  );
24
24
 
25
25
  if (result.shouldIgnore) {
26
- this.log.debug(`Ignoring tx ${incomingMeta.txHash}: ${result.reason}`);
26
+ this.log.debug(`Ignoring tx ${incomingMeta.txHash}: ${result.reason?.message}`);
27
27
  }
28
28
 
29
29
  return Promise.resolve(result);
@@ -0,0 +1,69 @@
1
+ import {
2
+ Attributes,
3
+ type Meter,
4
+ Metrics,
5
+ type ObservableGauge,
6
+ type ObservableResult,
7
+ type TelemetryClient,
8
+ type UpDownCounter,
9
+ createUpDownCounterWithDefault,
10
+ } from '@aztec/telemetry-client';
11
+
12
+ /** Callback that returns the current estimated metadata memory in bytes. */
13
+ export type MetadataMemoryCallback = () => number;
14
+
15
+ /** Instrumentation for TxPoolV2Impl internal operations. */
16
+ export class TxPoolV2Instrumentation {
17
+ #evictedCounter: UpDownCounter;
18
+ #ignoredCounter: UpDownCounter;
19
+ #rejectedCounter: UpDownCounter;
20
+ #softDeletedHitsCounter: UpDownCounter;
21
+ #missingOnProtectCounter: UpDownCounter;
22
+ #missingPreviouslyEvictedCounter: UpDownCounter;
23
+ #metadataMemoryGauge: ObservableGauge;
24
+
25
+ constructor(telemetry: TelemetryClient, metadataMemoryCallback: MetadataMemoryCallback) {
26
+ const meter: Meter = telemetry.getMeter('TxPoolV2Impl');
27
+
28
+ this.#evictedCounter = createUpDownCounterWithDefault(meter, Metrics.MEMPOOL_TX_POOL_V2_EVICTED_COUNT);
29
+ this.#ignoredCounter = createUpDownCounterWithDefault(meter, Metrics.MEMPOOL_TX_POOL_V2_IGNORED_COUNT);
30
+ this.#rejectedCounter = createUpDownCounterWithDefault(meter, Metrics.MEMPOOL_TX_POOL_V2_REJECTED_COUNT);
31
+ this.#softDeletedHitsCounter = createUpDownCounterWithDefault(meter, Metrics.MEMPOOL_TX_POOL_V2_SOFT_DELETED_HITS);
32
+ this.#missingOnProtectCounter = createUpDownCounterWithDefault(
33
+ meter,
34
+ Metrics.MEMPOOL_TX_POOL_V2_MISSING_ON_PROTECT,
35
+ );
36
+ this.#missingPreviouslyEvictedCounter = createUpDownCounterWithDefault(
37
+ meter,
38
+ Metrics.MEMPOOL_TX_POOL_V2_MISSING_PREVIOUSLY_EVICTED,
39
+ );
40
+ this.#metadataMemoryGauge = meter.createObservableGauge(Metrics.MEMPOOL_TX_POOL_V2_METADATA_MEMORY);
41
+ this.#metadataMemoryGauge.addCallback((result: ObservableResult) => {
42
+ result.observe(metadataMemoryCallback());
43
+ });
44
+ }
45
+
46
+ recordEvictions(count: number, reason: string) {
47
+ this.#evictedCounter.add(count, { [Attributes.TX_POOL_EVICTION_REASON]: reason });
48
+ }
49
+
50
+ recordIgnored(count: number) {
51
+ this.#ignoredCounter.add(count);
52
+ }
53
+
54
+ recordRejected(count: number) {
55
+ this.#rejectedCounter.add(count);
56
+ }
57
+
58
+ recordSoftDeletedHits(count: number) {
59
+ this.#softDeletedHitsCounter.add(count);
60
+ }
61
+
62
+ recordMissingOnProtect(count: number) {
63
+ this.#missingOnProtectCounter.add(count);
64
+ }
65
+
66
+ recordMissingPreviouslyEvicted(count: number) {
67
+ this.#missingPreviouslyEvictedCounter.add(count);
68
+ }
69
+ }