@aztec/p2p 0.0.1-commit.e3c1de76 → 0.0.1-commit.e558bd1c

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 (188) hide show
  1. package/dest/client/factory.d.ts +3 -3
  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 +9 -2
  5. package/dest/client/interface.d.ts.map +1 -1
  6. package/dest/client/p2p_client.d.ts +7 -4
  7. package/dest/client/p2p_client.d.ts.map +1 -1
  8. package/dest/client/p2p_client.js +22 -7
  9. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +1 -1
  10. package/dest/config.d.ts +9 -3
  11. package/dest/config.d.ts.map +1 -1
  12. package/dest/config.js +3 -1
  13. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +94 -87
  14. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  15. package/dest/mem_pools/attestation_pool/attestation_pool.js +411 -3
  16. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +2 -2
  17. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
  18. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +351 -85
  19. package/dest/mem_pools/attestation_pool/index.d.ts +2 -3
  20. package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
  21. package/dest/mem_pools/attestation_pool/index.js +1 -2
  22. package/dest/mem_pools/index.d.ts +2 -2
  23. package/dest/mem_pools/index.d.ts.map +1 -1
  24. package/dest/mem_pools/index.js +1 -1
  25. package/dest/mem_pools/interface.d.ts +3 -3
  26. package/dest/mem_pools/interface.d.ts.map +1 -1
  27. package/dest/mem_pools/tx_pool_v2/archive/index.d.ts +2 -0
  28. package/dest/mem_pools/tx_pool_v2/archive/index.d.ts.map +1 -0
  29. package/dest/mem_pools/tx_pool_v2/archive/index.js +1 -0
  30. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +43 -0
  31. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -0
  32. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +103 -0
  33. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +47 -0
  34. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -0
  35. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +119 -0
  36. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +17 -0
  37. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
  38. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +90 -0
  39. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +19 -0
  40. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -0
  41. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +89 -0
  42. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +10 -0
  43. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -0
  44. package/dest/mem_pools/tx_pool_v2/eviction/index.js +11 -0
  45. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +131 -0
  46. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -0
  47. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +17 -0
  48. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +15 -0
  49. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
  50. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +63 -0
  51. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +17 -0
  52. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
  53. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +91 -0
  54. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +16 -0
  55. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -0
  56. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +70 -0
  57. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +20 -0
  58. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -0
  59. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +63 -0
  60. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +15 -0
  61. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -0
  62. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +19 -0
  63. package/dest/mem_pools/tx_pool_v2/index.d.ts +5 -0
  64. package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -0
  65. package/dest/mem_pools/tx_pool_v2/index.js +4 -0
  66. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +197 -0
  67. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
  68. package/dest/mem_pools/tx_pool_v2/interfaces.js +6 -0
  69. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +71 -0
  70. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -0
  71. package/dest/mem_pools/tx_pool_v2/tx_metadata.js +95 -0
  72. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts +26 -0
  73. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts.map +1 -0
  74. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.js +70 -0
  75. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +99 -0
  76. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -0
  77. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +332 -0
  78. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +55 -0
  79. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -0
  80. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +156 -0
  81. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +69 -0
  82. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -0
  83. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +748 -0
  84. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +3 -3
  85. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
  86. package/dest/services/dummy_service.d.ts +6 -2
  87. package/dest/services/dummy_service.d.ts.map +1 -1
  88. package/dest/services/dummy_service.js +3 -0
  89. package/dest/services/index.d.ts +2 -1
  90. package/dest/services/index.d.ts.map +1 -1
  91. package/dest/services/index.js +1 -0
  92. package/dest/services/libp2p/libp2p_service.d.ts +74 -33
  93. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  94. package/dest/services/libp2p/libp2p_service.js +299 -228
  95. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +4 -4
  96. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
  97. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +8 -8
  98. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +6 -4
  99. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
  100. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +16 -11
  101. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +15 -10
  102. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
  103. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +12 -11
  104. package/dest/services/service.d.ts +18 -1
  105. package/dest/services/service.d.ts.map +1 -1
  106. package/dest/services/tx_collection/config.d.ts +3 -3
  107. package/dest/services/tx_collection/config.js +3 -3
  108. package/dest/services/tx_collection/fast_tx_collection.d.ts +4 -5
  109. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
  110. package/dest/services/tx_collection/fast_tx_collection.js +10 -14
  111. package/dest/services/tx_collection/index.d.ts +1 -1
  112. package/dest/services/tx_collection/proposal_tx_collector.d.ts +12 -12
  113. package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
  114. package/dest/services/tx_collection/proposal_tx_collector.js +4 -5
  115. package/dest/services/tx_file_store/config.d.ts +18 -0
  116. package/dest/services/tx_file_store/config.d.ts.map +1 -0
  117. package/dest/services/tx_file_store/config.js +26 -0
  118. package/dest/services/tx_file_store/index.d.ts +4 -0
  119. package/dest/services/tx_file_store/index.d.ts.map +1 -0
  120. package/dest/services/tx_file_store/index.js +3 -0
  121. package/dest/services/tx_file_store/instrumentation.d.ts +15 -0
  122. package/dest/services/tx_file_store/instrumentation.d.ts.map +1 -0
  123. package/dest/services/tx_file_store/instrumentation.js +29 -0
  124. package/dest/services/tx_file_store/tx_file_store.d.ts +47 -0
  125. package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -0
  126. package/dest/services/tx_file_store/tx_file_store.js +149 -0
  127. package/dest/test-helpers/testbench-utils.d.ts +10 -16
  128. package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
  129. package/dest/test-helpers/testbench-utils.js +32 -30
  130. package/dest/testbench/p2p_client_testbench_worker.js +1 -1
  131. package/package.json +14 -14
  132. package/src/client/factory.ts +7 -4
  133. package/src/client/interface.ts +13 -1
  134. package/src/client/p2p_client.ts +30 -8
  135. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +1 -1
  136. package/src/config.ts +8 -1
  137. package/src/mem_pools/attestation_pool/attestation_pool.ts +444 -90
  138. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +436 -100
  139. package/src/mem_pools/attestation_pool/index.ts +9 -2
  140. package/src/mem_pools/index.ts +1 -1
  141. package/src/mem_pools/interface.ts +2 -2
  142. package/src/mem_pools/tx_pool_v2/README.md +209 -0
  143. package/src/mem_pools/tx_pool_v2/archive/index.ts +1 -0
  144. package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +120 -0
  145. package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +147 -0
  146. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +118 -0
  147. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +111 -0
  148. package/src/mem_pools/tx_pool_v2/eviction/index.ts +23 -0
  149. package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +164 -0
  150. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +74 -0
  151. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +101 -0
  152. package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +86 -0
  153. package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +72 -0
  154. package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +31 -0
  155. package/src/mem_pools/tx_pool_v2/index.ts +11 -0
  156. package/src/mem_pools/tx_pool_v2/interfaces.ts +227 -0
  157. package/src/mem_pools/tx_pool_v2/tx_metadata.ts +161 -0
  158. package/src/mem_pools/tx_pool_v2/tx_pool_bench_metrics.ts +77 -0
  159. package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +417 -0
  160. package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +212 -0
  161. package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +882 -0
  162. package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +2 -2
  163. package/src/services/dummy_service.ts +6 -0
  164. package/src/services/index.ts +1 -0
  165. package/src/services/libp2p/libp2p_service.ts +304 -230
  166. package/src/services/reqresp/batch-tx-requester/README.md +7 -7
  167. package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +11 -11
  168. package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +22 -13
  169. package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +21 -15
  170. package/src/services/service.ts +20 -0
  171. package/src/services/tx_collection/config.ts +6 -6
  172. package/src/services/tx_collection/fast_tx_collection.ts +14 -24
  173. package/src/services/tx_collection/index.ts +1 -1
  174. package/src/services/tx_collection/proposal_tx_collector.ts +12 -14
  175. package/src/services/tx_file_store/config.ts +43 -0
  176. package/src/services/tx_file_store/index.ts +3 -0
  177. package/src/services/tx_file_store/instrumentation.ts +36 -0
  178. package/src/services/tx_file_store/tx_file_store.ts +173 -0
  179. package/src/test-helpers/testbench-utils.ts +18 -39
  180. package/src/testbench/p2p_client_testbench_worker.ts +1 -1
  181. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +0 -40
  182. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +0 -1
  183. package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +0 -218
  184. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -31
  185. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +0 -1
  186. package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +0 -180
  187. package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -320
  188. package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -264
@@ -1,14 +1,14 @@
1
1
  # BatchTxRequester
2
2
 
3
- The `BatchTxRequester` is a specialized P2P service that aggressively fetches missing transactions from peers when a node receives a block proposal but lacks some of the referenced transactions. This is critical for validators who need all transactions to attest to a proposal.
3
+ The `BatchTxRequester` is a specialized P2P service that aggressively fetches missing transactions from peers when a node lacks some of the referenced transactions. It serves two pathways: (1) block proposals, where validators need all transactions to attest, and (2) block proving, where provers need all transactions to generate proofs.
4
4
 
5
5
  ## Overview
6
6
 
7
- When a validator receives a block proposal, they must verify all transactions in the block. If some transactions are missing from the local mempool (e.g., due to gossip delays), the `BatchTxRequester` kicks in to fetch them via direct peer-to-peer requests before the attestation deadline.
7
+ When a validator receives a block proposal or a prover needs to prove a block, they must have all transactions. If some transactions are missing from the local mempool (e.g., due to gossip delays), the `BatchTxRequester` kicks in to fetch them via direct peer-to-peer requests before the deadline.
8
8
 
9
9
  ```
10
10
  ┌─────────────────────────────────────────────────────────────────────────────┐
11
- Block Proposal Received
11
+ Block Proposal or Block Received
12
12
  │ (contains hashes of N transactions) │
13
13
  └─────────────────────────────────────────────────────────────────────────────┘
14
14
 
@@ -230,8 +230,8 @@ Request to peer fails
230
230
  ```typescript
231
231
  const requester = new BatchTxRequester(
232
232
  missingTxHashes, // TxHash[] - what we need
233
- blockProposal, // BlockProposal - the proposal we're attesting to
234
- pinnedPeer, // PeerId | undefined - who sent us the proposal
233
+ blockTxsSource, // BlockTxsSource - the proposal or block we need txs for
234
+ pinnedPeer, // PeerId | undefined - peer expected to have the txs
235
235
  timeoutMs, // number - how long to try
236
236
  p2pService, // BatchTxRequesterLibP2PService
237
237
  );
@@ -268,14 +268,14 @@ const txs = await BatchTxRequester.collectAllTxs(requester.run());
268
268
  ┌───────────────────────────────────┐ ┌─────────────────────────────────────┐
269
269
  │ FastTxCollection │ │ SlowTxCollection │
270
270
  │ │ │ │
271
- │ Time-critical: attestations │ │ Background: unproven blocks │
271
+ │ Time-critical: proposals/proving │ │ Background: unproven blocks │
272
272
  │ │ │ │
273
273
  │ 1. Try RPC nodes first (fast) │ │ Periodic polling of RPC nodes │
274
274
  │ 2. Fall back to BatchTxRequester │ │ and peers for missing txs │
275
275
  │ │ │ │
276
276
  └───────────────────┬───────────────┘ └─────────────────────────────────────┘
277
277
 
278
- │ For 'proposal' requests
278
+ │ For 'proposal' and 'block' requests
279
279
 
280
280
  ┌─────────────────────────────────────────────────────────────────────────────┐
281
281
  │ BatchTxRequester │
@@ -4,14 +4,14 @@ import { type Logger, createLogger } from '@aztec/foundation/log';
4
4
  import { FifoMemoryQueue, type ISemaphore, Semaphore } from '@aztec/foundation/queue';
5
5
  import { sleep } from '@aztec/foundation/sleep';
6
6
  import { DateProvider, executeTimeout } from '@aztec/foundation/timer';
7
- import { type BlockProposal, PeerErrorSeverity } from '@aztec/stdlib/p2p';
7
+ import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
8
8
  import { Tx, TxArray, TxHash } from '@aztec/stdlib/tx';
9
9
 
10
10
  import type { PeerId } from '@libp2p/interface';
11
11
  import { peerIdFromString } from '@libp2p/peer-id';
12
12
 
13
13
  import { ReqRespSubProtocol } from '.././interface.js';
14
- import { BlockTxsRequest, BlockTxsResponse } from '.././protocols/index.js';
14
+ import { BlockTxsRequest, BlockTxsResponse, type BlockTxsSource } from '.././protocols/index.js';
15
15
  import { ReqRespStatus } from '.././status.js';
16
16
  import {
17
17
  DEFAULT_BATCH_TX_REQUESTER_BAD_PEER_THRESHOLD,
@@ -42,7 +42,7 @@ import { BatchRequestTxValidator, type IBatchRequestTxValidator } from './tx_val
42
42
  * - Is the peer which was unable to send us successful response N times in a row
43
43
  * */
44
44
  export class BatchTxRequester {
45
- private readonly blockProposal: BlockProposal;
45
+ private readonly blockTxsSource: BlockTxsSource;
46
46
  private readonly pinnedPeer: PeerId | undefined;
47
47
  private readonly timeoutMs: number;
48
48
  private readonly p2pService: BatchTxRequesterLibP2PService;
@@ -61,7 +61,7 @@ export class BatchTxRequester {
61
61
 
62
62
  constructor(
63
63
  missingTxs: TxHash[],
64
- blockProposal: BlockProposal,
64
+ blockTxsSource: BlockTxsSource,
65
65
  pinnedPeer: PeerId | undefined,
66
66
  timeoutMs: number,
67
67
  p2pService: BatchTxRequesterLibP2PService,
@@ -69,7 +69,7 @@ export class BatchTxRequester {
69
69
  dateProvider?: DateProvider,
70
70
  opts?: BatchTxRequesterOptions,
71
71
  ) {
72
- this.blockProposal = blockProposal;
72
+ this.blockTxsSource = blockTxsSource;
73
73
  this.pinnedPeer = pinnedPeer;
74
74
  this.timeoutMs = timeoutMs;
75
75
  this.p2pService = p2pService;
@@ -205,7 +205,7 @@ export class BatchTxRequester {
205
205
  return;
206
206
  }
207
207
 
208
- const request = BlockTxsRequest.fromBlockProposalAndMissingTxs(this.blockProposal, txs);
208
+ const request = BlockTxsRequest.fromTxsSourceAndMissingTxs(this.blockTxsSource, txs);
209
209
  if (!request) {
210
210
  return;
211
211
  }
@@ -249,8 +249,8 @@ export class BatchTxRequester {
249
249
  // If peer is dumb peer, we don't know yet if they received full blockProposal
250
250
  // there is solid chance that peer didn't receive proposal yet, thus we must send full hashes
251
251
  const includeFullHashesInRequestNotJustIndices = true;
252
- const blockRequest = BlockTxsRequest.fromBlockProposalAndMissingTxs(
253
- this.blockProposal,
252
+ const blockRequest = BlockTxsRequest.fromTxsSourceAndMissingTxs(
253
+ this.blockTxsSource,
254
254
  txs,
255
255
  includeFullHashesInRequestNotJustIndices,
256
256
  );
@@ -342,7 +342,7 @@ export class BatchTxRequester {
342
342
 
343
343
  const makeRequest = (pid: PeerId) => {
344
344
  const txs = this.txsMetadata.getTxsToRequestFromThePeer(pid);
345
- const blockRequest = BlockTxsRequest.fromBlockProposalAndMissingTxs(this.blockProposal, txs);
345
+ const blockRequest = BlockTxsRequest.fromTxsSourceAndMissingTxs(this.blockTxsSource, txs);
346
346
  if (!blockRequest) {
347
347
  return undefined;
348
348
  }
@@ -605,7 +605,7 @@ export class BatchTxRequester {
605
605
  }
606
606
 
607
607
  private isBlockResponseValid(response: BlockTxsResponse): boolean {
608
- const archiveRootsMatch = this.blockProposal.archive.toString() === response.archiveRoot.toString();
608
+ const archiveRootsMatch = this.blockTxsSource.archive.toString() === response.archiveRoot.toString();
609
609
  const peerHasSomeTxsFromProposal = !response.txIndices.isEmpty();
610
610
  return archiveRootsMatch && peerHasSomeTxsFromProposal;
611
611
  }
@@ -624,7 +624,7 @@ export class BatchTxRequester {
624
624
  private extractHashesPeerHasFromResponse(response: BlockTxsResponse): Array<TxHash> {
625
625
  const hashes: TxHash[] = [];
626
626
  const indicesOfHashesPeerHas = new Set(response.txIndices.getTrueIndices());
627
- this.blockProposal.txHashes.forEach((hash, idx) => {
627
+ this.blockTxsSource.txHashes.forEach((hash, idx) => {
628
628
  if (indicesOfHashesPeerHas.has(idx)) {
629
629
  hashes.push(hash);
630
630
  }
@@ -1,9 +1,10 @@
1
1
  import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import type { L2BlockSource } from '@aztec/stdlib/block';
2
3
  import { TxArray } from '@aztec/stdlib/tx';
3
4
 
4
5
  import type { PeerId } from '@libp2p/interface';
5
6
 
6
- import type { AttestationPool } from '../../../../mem_pools/attestation_pool/attestation_pool.js';
7
+ import type { AttestationPoolApi } from '../../../../mem_pools/attestation_pool/attestation_pool.js';
7
8
  import type { TxPool } from '../../../../mem_pools/index.js';
8
9
  import type { ReqRespSubProtocolHandler } from '../../interface.js';
9
10
  import { ReqRespStatus, ReqRespStatusError } from '../../status.js';
@@ -13,10 +14,15 @@ import { BlockTxsRequest, BlockTxsResponse } from './block_txs_reqresp.js';
13
14
  /**
14
15
  * Handler for block txs requests
15
16
  * @param attestationPool - the attestation pool to check for block proposals
16
- * @param mempools - the mempools containing the tx pool
17
+ * @param archiver - the archiver to look up blocks by archive root
18
+ * @param txPool - the tx pool to fetch transactions from
17
19
  * @returns the BlockTxs request handler
18
20
  */
19
- export function reqRespBlockTxsHandler(attestationPool: AttestationPool, txPool: TxPool): ReqRespSubProtocolHandler {
21
+ export function reqRespBlockTxsHandler(
22
+ attestationPool: AttestationPoolApi,
23
+ archiver: L2BlockSource,
24
+ txPool: TxPool,
25
+ ): ReqRespSubProtocolHandler {
20
26
  /**
21
27
  * Handler for block txs requests
22
28
  * @param msg - the block txs request message
@@ -30,34 +36,37 @@ export function reqRespBlockTxsHandler(attestationPool: AttestationPool, txPool:
30
36
  } catch (err: any) {
31
37
  throw new ReqRespStatusError(ReqRespStatus.BADLY_FORMED_REQUEST, { cause: err });
32
38
  }
33
-
34
- const blockProposal = await attestationPool.getBlockProposal(request.archiveRoot.toString());
39
+ // First try attestation pool, then fall back to archiver
40
+ let txHashes = (await attestationPool.getBlockProposal(request.archiveRoot.toString()))?.txHashes;
41
+ if (!txHashes) {
42
+ txHashes = (await archiver.getL2BlockByArchive(request.archiveRoot))?.body.txEffects.map(effect => effect.txHash);
43
+ }
35
44
 
36
45
  let requestedTxsHashes;
37
46
  if (request.txHashes.length > 0) {
38
47
  requestedTxsHashes = request.txHashes;
39
48
  }
40
49
 
41
- // This is scenario in which we don't have this block proposal the peer is requesting from us
50
+ // This is scenario in which we don't have this block the peer is requesting from us
42
51
  // But peer has sent requested tx hashes, so we can send them the transactions
43
- if (!blockProposal && requestedTxsHashes !== undefined) {
52
+ if (!txHashes && requestedTxsHashes !== undefined) {
44
53
  const responseTxs = (await txPool.getTxsByHash(requestedTxsHashes)).filter(tx => !!tx);
45
54
  const response = new BlockTxsResponse(Fr.zero(), new TxArray(...responseTxs), BitVector.init(0, []));
46
55
  return response.toBuffer();
47
56
  }
48
57
 
49
- // If don't have this block proposal and peer has not sent requested tx hashes
50
- if (!blockProposal) {
58
+ // If we don't have this block and peer has not sent requested tx hashes
59
+ if (!txHashes) {
51
60
  throw new ReqRespStatusError(ReqRespStatus.NOT_FOUND);
52
61
  }
53
62
 
54
- const txsAvailableInPool = await txPool.hasTxs(blockProposal.txHashes);
55
- //Map txs in the pool to their indices in the block proposal
63
+ const txsAvailableInPool = await txPool.hasTxs(txHashes);
64
+ // Map txs in the pool to their indices in the block
56
65
  const availableIndices = txsAvailableInPool.map((hasTx, idx) => (hasTx ? idx : -1)).filter(idx => idx !== -1);
57
- const responseBitVector = BitVector.init(blockProposal.txHashes.length, availableIndices);
66
+ const responseBitVector = BitVector.init(txHashes.length, availableIndices);
58
67
 
59
68
  const requestedIndices = new Set(request.txIndices.getTrueIndices());
60
- requestedTxsHashes = blockProposal.txHashes.filter((_, idx) => requestedIndices.has(idx));
69
+ requestedTxsHashes = txHashes.filter((_, idx) => requestedIndices.has(idx));
61
70
 
62
71
  const responseTxs = (await txPool.getTxsByHash(requestedTxsHashes)).filter(tx => !!tx);
63
72
  const response = new BlockTxsResponse(request.archiveRoot, new TxArray(...responseTxs), responseBitVector);
@@ -1,10 +1,15 @@
1
1
  import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
3
- import type { BlockProposal } from '@aztec/stdlib/p2p';
4
- import { TxArray, TxHash, TxHashArray } from '@aztec/stdlib/tx';
3
+ import { TxArray, type TxHash, TxHashArray } from '@aztec/stdlib/tx';
5
4
 
6
5
  import { BitVector } from './bitvector.js';
7
6
 
7
+ /** Minimal interface for a block source that provides tx hashes and an archive root. */
8
+ export interface BlockTxsSource {
9
+ txHashes: TxHash[];
10
+ archive: Fr;
11
+ }
12
+
8
13
  /**
9
14
  * Request message for requesting specific transactions from a block
10
15
  */
@@ -22,16 +27,17 @@ export class BlockTxsRequest {
22
27
  ) {}
23
28
 
24
29
  /**
25
- * Creates new BlockTxsRequest given proposal and missing tx hashes
30
+ * Creates new BlockTxsRequest given a block txs source and missing tx hashes.
26
31
  *
27
- * @param: blockProposal - The block proposal for which we are making request
28
- * @param: missingTxHashes - Tx hashes from the proposal we are missing
29
- * @param: includeFullTxHashes - Whether to include full list of missing tx hashes in the request or just Bitvector indices
32
+ * @param blockTxsSource - The block or proposal for which we are making the request
33
+ * @param missingTxHashes - Tx hashes from the source we are missing
34
+ * @param includeFullTxHashes - Whether to include full list of missing tx hashes in the request or just Bitvector indices
30
35
  *
31
- * @returns undefined if there were no missingTxHashes matching BlockProposal hashes, otherwise
32
- * returns new BlockTxsRequest*/
33
- static fromBlockProposalAndMissingTxs(
34
- blockProposal: BlockProposal,
36
+ * @returns undefined if there were no missingTxHashes matching the source hashes, otherwise
37
+ * returns new BlockTxsRequest
38
+ */
39
+ static fromTxsSourceAndMissingTxs(
40
+ blockTxsSource: BlockTxsSource,
35
41
  missingTxHashes: TxHash[],
36
42
  includeFullTxHashes = false,
37
43
  ): BlockTxsRequest | undefined {
@@ -41,19 +47,19 @@ export class BlockTxsRequest {
41
47
 
42
48
  const missingHashesSet = new Set(missingTxHashes.map(t => t.toString()));
43
49
 
44
- // We cannot request txs that are not part of the block proposal
45
- if (!missingHashesSet.isSubsetOf(new Set(blockProposal.txHashes.map(t => t.toString())))) {
50
+ // We cannot request txs that are not part of the block
51
+ if (!missingHashesSet.isSubsetOf(new Set(blockTxsSource.txHashes.map(t => t.toString())))) {
46
52
  return undefined;
47
53
  }
48
54
 
49
- const missingIndices = blockProposal.txHashes
55
+ const missingIndices = blockTxsSource.txHashes
50
56
  .map((hash, idx) => (missingHashesSet.has(hash.toString()) ? idx : -1))
51
57
  .filter(i => i != -1);
52
58
 
53
- const requestBitVector = BitVector.init(blockProposal.txHashes.length, missingIndices);
59
+ const requestBitVector = BitVector.init(blockTxsSource.txHashes.length, missingIndices);
54
60
  const hashes = includeFullTxHashes ? new TxHashArray(...missingTxHashes) : new TxHashArray();
55
61
 
56
- return new BlockTxsRequest(blockProposal.archive, hashes, requestBitVector);
62
+ return new BlockTxsRequest(blockTxsSource.archive, hashes, requestBitVector);
57
63
  }
58
64
 
59
65
  /**
@@ -1,3 +1,4 @@
1
+ import type { SlotNumber } from '@aztec/foundation/branded-types';
1
2
  import type { EthAddress } from '@aztec/foundation/eth-address';
2
3
  import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
3
4
  import type { BlockProposal, CheckpointAttestation, CheckpointProposalCore, Gossipable } from '@aztec/stdlib/p2p';
@@ -43,6 +44,19 @@ export type P2PCheckpointReceivedCallback = (
43
44
 
44
45
  export type AuthReceivedCallback = (peerId: PeerId, authRequest: AuthRequest) => Promise<AuthResponse | undefined>;
45
46
 
47
+ /** Minimal info passed to the duplicate proposal callback. */
48
+ export type DuplicateProposalInfo = {
49
+ slot: SlotNumber;
50
+ proposer: EthAddress;
51
+ type: 'checkpoint' | 'block';
52
+ };
53
+
54
+ /**
55
+ * Callback for when a duplicate proposal is detected (equivocation).
56
+ * Invoked on the first duplicate (when count goes from 1 to 2).
57
+ */
58
+ export type P2PDuplicateProposalCallback = (info: DuplicateProposalInfo) => void;
59
+
46
60
  /**
47
61
  * The interface for a P2P service implementation.
48
62
  */
@@ -86,6 +100,12 @@ export interface P2PService {
86
100
 
87
101
  registerCheckpointReceivedCallback(callback: P2PCheckpointReceivedCallback): void;
88
102
 
103
+ /**
104
+ * Registers a callback invoked when a duplicate proposal is detected (equivocation).
105
+ * The callback is triggered on the first duplicate (when count goes from 1 to 2).
106
+ */
107
+ registerDuplicateProposalCallback(callback: P2PDuplicateProposalCallback): void;
108
+
89
109
  getEnr(): ENR | undefined;
90
110
 
91
111
  getPeers(includePending?: boolean): PeerInfo[];
@@ -6,7 +6,7 @@ import {
6
6
  } from '@aztec/foundation/config';
7
7
  import { MAX_RPC_TXS_LEN } from '@aztec/stdlib/interfaces/api-limit';
8
8
 
9
- export type ProposalTxCollectorType = 'new' | 'old';
9
+ export type MissingTxsCollectorType = 'new' | 'old';
10
10
 
11
11
  export type TxCollectionConfig = {
12
12
  /** How long to wait before starting reqresp for fast collection */
@@ -29,8 +29,8 @@ export type TxCollectionConfig = {
29
29
  txCollectionFastMaxParallelRequestsPerNode: number;
30
30
  /** Maximum number of transactions to request from a node in a single batch */
31
31
  txCollectionNodeRpcMaxBatchSize: number;
32
- /** Which collector implementation to use for proposal tx collection */
33
- txCollectionProposalTxCollectorType: ProposalTxCollectorType;
32
+ /** Which collector implementation to use for missing txs collection */
33
+ txCollectionMissingTxsCollectorType: MissingTxsCollectorType;
34
34
  };
35
35
 
36
36
  export const txCollectionConfigMappings: ConfigMappingsType<TxCollectionConfig> = {
@@ -90,9 +90,9 @@ export const txCollectionConfigMappings: ConfigMappingsType<TxCollectionConfig>
90
90
  description: 'Maximum number of transactions to request from a node in a single batch',
91
91
  ...numberConfigHelper(MAX_RPC_TXS_LEN),
92
92
  },
93
- txCollectionProposalTxCollectorType: {
94
- env: 'TX_COLLECTION_PROPOSAL_TX_COLLECTOR_TYPE',
95
- description: 'Which collector implementation to use for proposal tx collection (new or old)',
93
+ txCollectionMissingTxsCollectorType: {
94
+ env: 'TX_COLLECTION_MISSING_TXS_COLLECTOR_TYPE',
95
+ description: 'Which collector implementation to use for missing txs collection (new or old)',
96
96
  ...enumConfigHelper(['new', 'old'] as const, 'new'),
97
97
  },
98
98
  };
@@ -2,7 +2,6 @@ import { BlockNumber } from '@aztec/foundation/branded-types';
2
2
  import { times } from '@aztec/foundation/collection';
3
3
  import { AbortError, TimeoutError } from '@aztec/foundation/error';
4
4
  import { type Logger, createLogger } from '@aztec/foundation/log';
5
- import { boundInclusive } from '@aztec/foundation/number';
6
5
  import { promiseWithResolvers } from '@aztec/foundation/promise';
7
6
  import { sleep } from '@aztec/foundation/sleep';
8
7
  import { DateProvider, elapsed } from '@aztec/foundation/timer';
@@ -14,12 +13,10 @@ import type { PeerId } from '@libp2p/interface';
14
13
 
15
14
  import type { BatchTxRequesterConfig } from '../reqresp/batch-tx-requester/config.js';
16
15
  import type { BatchTxRequesterLibP2PService } from '../reqresp/batch-tx-requester/interface.js';
17
- import { ReqRespSubProtocol } from '../reqresp/interface.js';
18
- import { chunkTxHashesRequest } from '../reqresp/protocols/tx.js';
19
16
  import type { TxCollectionConfig } from './config.js';
20
17
  import {
21
18
  BatchTxRequesterCollector,
22
- type ProposalTxCollector,
19
+ type MissingTxsCollector,
23
20
  SendBatchRequestCollector,
24
21
  } from './proposal_tx_collector.js';
25
22
  import type { FastCollectionRequest, FastCollectionRequestInput } from './tx_collection.js';
@@ -29,22 +26,22 @@ import type { TxSource } from './tx_source.js';
29
26
  export class FastTxCollection {
30
27
  // eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
31
28
  protected requests: Set<FastCollectionRequest> = new Set();
32
- private proposalTxCollector: ProposalTxCollector;
29
+ private missingTxsCollector: MissingTxsCollector;
33
30
 
34
31
  constructor(
35
- private p2pService: BatchTxRequesterLibP2PService,
32
+ p2pService: BatchTxRequesterLibP2PService,
36
33
  private nodes: TxSource[],
37
34
  private txCollectionSink: TxCollectionSink,
38
35
  private config: TxCollectionConfig,
39
36
  private dateProvider: DateProvider = new DateProvider(),
40
37
  private log: Logger = createLogger('p2p:tx_collection_service'),
41
- proposalTxCollector?: ProposalTxCollector,
38
+ missingTxsCollector?: MissingTxsCollector,
42
39
  ) {
43
40
  const batchTxRequesterConfig = this.config as Partial<BatchTxRequesterConfig>;
44
- const proposalCollectorType = this.config.txCollectionProposalTxCollectorType;
45
- this.proposalTxCollector =
46
- proposalTxCollector ??
47
- (proposalCollectorType === 'old'
41
+ const missingTxsCollectorType = this.config.txCollectionMissingTxsCollectorType;
42
+ this.missingTxsCollector =
43
+ missingTxsCollector ??
44
+ (missingTxsCollectorType === 'old'
48
45
  ? new SendBatchRequestCollector(p2pService)
49
46
  : new BatchTxRequesterCollector(p2pService, log, dateProvider, undefined, batchTxRequesterConfig));
50
47
  }
@@ -258,8 +255,6 @@ export class FastTxCollection {
258
255
  private async collectFastViaReqResp(request: FastCollectionRequest, opts: { pinnedPeer?: PeerId }) {
259
256
  const timeoutMs = +request.deadline - this.dateProvider.now();
260
257
  const pinnedPeer = opts.pinnedPeer;
261
- const maxPeers = boundInclusive(Math.ceil(request.missingTxHashes.size / 2), 8, 32);
262
- const maxRetryAttempts = 5;
263
258
  const blockInfo = request.blockInfo;
264
259
  const slotNumber = blockInfo.slotNumber;
265
260
  if (timeoutMs < 100) {
@@ -279,18 +274,13 @@ export class FastTxCollection {
279
274
  await this.txCollectionSink.collect(
280
275
  async txHashes => {
281
276
  if (request.type === 'proposal') {
282
- return await this.proposalTxCollector.collectTxs(txHashes, request.blockProposal, pinnedPeer, timeoutMs);
277
+ return await this.missingTxsCollector.collectTxs(txHashes, request.blockProposal, pinnedPeer, timeoutMs);
283
278
  } else if (request.type === 'block') {
284
- const txs = await this.p2pService.reqResp.sendBatchRequest<ReqRespSubProtocol.TX>(
285
- ReqRespSubProtocol.TX,
286
- chunkTxHashesRequest(txHashes),
287
- pinnedPeer,
288
- timeoutMs,
289
- maxPeers,
290
- maxRetryAttempts,
291
- );
292
-
293
- return txs.flat();
279
+ const blockTxsSource = {
280
+ txHashes: request.block.body.txEffects.map(e => e.txHash),
281
+ archive: request.block.archive.root,
282
+ };
283
+ return await this.missingTxsCollector.collectTxs(txHashes, blockTxsSource, pinnedPeer, timeoutMs);
294
284
  } else {
295
285
  throw new Error(`Unknown request type: ${(request as any).type}`);
296
286
  }
@@ -1,7 +1,7 @@
1
1
  export { TxCollection, type FastCollectionRequestInput } from './tx_collection.js';
2
2
  export { type TxSource, createNodeRpcTxSources, NodeRpcTxSource } from './tx_source.js';
3
3
  export {
4
- type ProposalTxCollector,
4
+ type MissingTxsCollector,
5
5
  BatchTxRequesterCollector,
6
6
  SendBatchRequestCollector,
7
7
  } from './proposal_tx_collector.js';
@@ -1,6 +1,5 @@
1
1
  import type { Logger } from '@aztec/foundation/log';
2
2
  import type { DateProvider } from '@aztec/foundation/timer';
3
- import type { BlockProposal } from '@aztec/stdlib/p2p';
4
3
  import type { Tx, TxHash } from '@aztec/stdlib/tx';
5
4
 
6
5
  import type { PeerId } from '@libp2p/interface';
@@ -9,25 +8,24 @@ import { BatchTxRequester } from '../reqresp/batch-tx-requester/batch_tx_request
9
8
  import type { BatchTxRequesterConfig } from '../reqresp/batch-tx-requester/config.js';
10
9
  import type { BatchTxRequesterLibP2PService } from '../reqresp/batch-tx-requester/interface.js';
11
10
  import type { IBatchRequestTxValidator } from '../reqresp/batch-tx-requester/tx_validator.js';
12
- import { ReqRespSubProtocol } from '../reqresp/interface.js';
13
- import { chunkTxHashesRequest } from '../reqresp/protocols/tx.js';
11
+ import { type BlockTxsSource, ReqRespSubProtocol, chunkTxHashesRequest } from '../reqresp/index.js';
14
12
 
15
13
  /**
16
- * Strategy interface for collecting transactions for block proposals.
14
+ * Strategy interface for collecting missing transactions for a block or proposal.
17
15
  * Allows swapping between different tx collection implementations for benchmarking.
18
16
  */
19
- export interface ProposalTxCollector {
17
+ export interface MissingTxsCollector {
20
18
  /**
21
- * Collect transactions for a block proposal.
19
+ * Collect missing transactions for a block or proposal.
22
20
  * @param txHashes - The transaction hashes to collect
23
- * @param blockProposal - The block proposal containing the transactions
24
- * @param pinnedPeer - Optional peer that sent the proposal (expected to have all txs)
21
+ * @param blockTxsSource - The block or proposal containing the transactions
22
+ * @param pinnedPeer - Optional peer expected to have the transactions
25
23
  * @param timeoutMs - Timeout in milliseconds
26
24
  * @returns The collected transactions
27
25
  */
28
26
  collectTxs(
29
27
  txHashes: TxHash[],
30
- blockProposal: BlockProposal,
28
+ blockTxsSource: BlockTxsSource,
31
29
  pinnedPeer: PeerId | undefined,
32
30
  timeoutMs: number,
33
31
  ): Promise<Tx[]>;
@@ -37,7 +35,7 @@ export interface ProposalTxCollector {
37
35
  * Collects transactions using the BatchTxRequester implementation.
38
36
  * This uses a smart/dumb peer strategy with parallel workers.
39
37
  */
40
- export class BatchTxRequesterCollector implements ProposalTxCollector {
38
+ export class BatchTxRequesterCollector implements MissingTxsCollector {
41
39
  constructor(
42
40
  private p2pService: BatchTxRequesterLibP2PService,
43
41
  private log: Logger,
@@ -48,7 +46,7 @@ export class BatchTxRequesterCollector implements ProposalTxCollector {
48
46
 
49
47
  async collectTxs(
50
48
  txHashes: TxHash[],
51
- blockProposal: BlockProposal,
49
+ blockTxsSource: BlockTxsSource,
52
50
  pinnedPeer: PeerId | undefined,
53
51
  timeoutMs: number,
54
52
  ): Promise<Tx[]> {
@@ -61,7 +59,7 @@ export class BatchTxRequesterCollector implements ProposalTxCollector {
61
59
 
62
60
  const batchRequester = new BatchTxRequester(
63
61
  txHashes,
64
- blockProposal,
62
+ blockTxsSource,
65
63
  pinnedPeer,
66
64
  timeoutMs,
67
65
  this.p2pService,
@@ -87,7 +85,7 @@ const DEFAULT_MAX_RETRY_ATTEMPTS = 3;
87
85
  * Collects transactions using the sendBatchRequest implementation from ReqResp.
88
86
  * This is the original implementation that balances requests across peers.
89
87
  */
90
- export class SendBatchRequestCollector implements ProposalTxCollector {
88
+ export class SendBatchRequestCollector implements MissingTxsCollector {
91
89
  constructor(
92
90
  private p2pService: BatchTxRequesterLibP2PService,
93
91
  private maxPeers: number = DEFAULT_MAX_PEERS,
@@ -96,7 +94,7 @@ export class SendBatchRequestCollector implements ProposalTxCollector {
96
94
 
97
95
  async collectTxs(
98
96
  txHashes: TxHash[],
99
- _blockProposal: BlockProposal,
97
+ _blockTxsSource: BlockTxsSource,
100
98
  pinnedPeer: PeerId | undefined,
101
99
  timeoutMs: number,
102
100
  ): Promise<Tx[]> {
@@ -0,0 +1,43 @@
1
+ import { type ConfigMappingsType, booleanConfigHelper, numberConfigHelper } from '@aztec/foundation/config';
2
+
3
+ /**
4
+ * Configuration for the TxFileStore service.
5
+ */
6
+ export type TxFileStoreConfig = {
7
+ /** URL for uploading txs to file storage (s3://, gs://, file://) */
8
+ txFileStoreUrl?: string;
9
+ /** URL for downloading txs from file storage */
10
+ txFileStoreDownloadUrl?: string;
11
+ /** Max concurrent uploads */
12
+ txFileStoreUploadConcurrency: number;
13
+ /** Max queue size to prevent unbounded memory growth */
14
+ txFileStoreMaxQueueSize: number;
15
+ /** Enable tx file store upload */
16
+ txFileStoreEnabled: boolean;
17
+ };
18
+
19
+ export const txFileStoreConfigMappings: ConfigMappingsType<TxFileStoreConfig> = {
20
+ txFileStoreUrl: {
21
+ env: 'TX_FILE_STORE_URL',
22
+ description: 'URL for uploading txs to file storage (s3://, gs://, file://)',
23
+ },
24
+ txFileStoreDownloadUrl: {
25
+ env: 'TX_FILE_STORE_DOWNLOAD_URL',
26
+ description: 'URL for downloading txs from file storage',
27
+ },
28
+ txFileStoreUploadConcurrency: {
29
+ env: 'TX_FILE_STORE_UPLOAD_CONCURRENCY',
30
+ description: 'Maximum number of concurrent tx uploads',
31
+ ...numberConfigHelper(10),
32
+ },
33
+ txFileStoreMaxQueueSize: {
34
+ env: 'TX_FILE_STORE_MAX_QUEUE_SIZE',
35
+ description: 'Maximum queue size for pending uploads (oldest dropped when exceeded)',
36
+ ...numberConfigHelper(1000),
37
+ },
38
+ txFileStoreEnabled: {
39
+ env: 'TX_FILE_STORE_ENABLED',
40
+ description: 'Enable uploading transactions to file storage',
41
+ ...booleanConfigHelper(false),
42
+ },
43
+ };
@@ -0,0 +1,3 @@
1
+ export { TxFileStore } from './tx_file_store.js';
2
+ export { TxFileStoreInstrumentation } from './instrumentation.js';
3
+ export { type TxFileStoreConfig, txFileStoreConfigMappings } from './config.js';
@@ -0,0 +1,36 @@
1
+ import { type Gauge, type Histogram, Metrics, type TelemetryClient, type UpDownCounter } from '@aztec/telemetry-client';
2
+
3
+ /** Instrumentation for the TxFileStore service. */
4
+ export class TxFileStoreInstrumentation {
5
+ private uploadsSuccess: UpDownCounter;
6
+ private uploadsFailed: UpDownCounter;
7
+ private uploadsSkipped: UpDownCounter;
8
+ private uploadDuration: Histogram;
9
+ private queueSize: Gauge;
10
+
11
+ constructor(client: TelemetryClient, name: string) {
12
+ const meter = client.getMeter(name);
13
+ this.uploadsSuccess = meter.createUpDownCounter(Metrics.TX_FILE_STORE_UPLOADS_SUCCESS);
14
+ this.uploadsFailed = meter.createUpDownCounter(Metrics.TX_FILE_STORE_UPLOADS_FAILED);
15
+ this.uploadsSkipped = meter.createUpDownCounter(Metrics.TX_FILE_STORE_UPLOADS_SKIPPED);
16
+ this.uploadDuration = meter.createHistogram(Metrics.TX_FILE_STORE_UPLOAD_DURATION);
17
+ this.queueSize = meter.createGauge(Metrics.TX_FILE_STORE_QUEUE_SIZE);
18
+ }
19
+
20
+ recordUploadSuccess(durationMs: number) {
21
+ this.uploadsSuccess.add(1);
22
+ this.uploadDuration.record(durationMs);
23
+ }
24
+
25
+ recordUploadFailed() {
26
+ this.uploadsFailed.add(1);
27
+ }
28
+
29
+ recordUploadSkipped() {
30
+ this.uploadsSkipped.add(1);
31
+ }
32
+
33
+ recordQueueSize(size: number) {
34
+ this.queueSize.record(size);
35
+ }
36
+ }