@aztec/p2p 0.0.1-commit.29c6b1a3 → 0.0.1-commit.2eb6648a

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 (276) hide show
  1. package/dest/bootstrap/bootstrap.d.ts +4 -3
  2. package/dest/bootstrap/bootstrap.d.ts.map +1 -1
  3. package/dest/bootstrap/bootstrap.js +4 -4
  4. package/dest/client/factory.d.ts +3 -3
  5. package/dest/client/factory.d.ts.map +1 -1
  6. package/dest/client/factory.js +10 -7
  7. package/dest/client/interface.d.ts +9 -2
  8. package/dest/client/interface.d.ts.map +1 -1
  9. package/dest/client/p2p_client.d.ts +7 -4
  10. package/dest/client/p2p_client.d.ts.map +1 -1
  11. package/dest/client/p2p_client.js +24 -7
  12. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +2 -2
  13. package/dest/config.d.ts +9 -3
  14. package/dest/config.d.ts.map +1 -1
  15. package/dest/config.js +3 -1
  16. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +94 -87
  17. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  18. package/dest/mem_pools/attestation_pool/attestation_pool.js +411 -3
  19. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +2 -2
  20. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
  21. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +351 -85
  22. package/dest/mem_pools/attestation_pool/index.d.ts +2 -3
  23. package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
  24. package/dest/mem_pools/attestation_pool/index.js +1 -2
  25. package/dest/mem_pools/index.d.ts +2 -2
  26. package/dest/mem_pools/index.d.ts.map +1 -1
  27. package/dest/mem_pools/index.js +1 -1
  28. package/dest/mem_pools/instrumentation.d.ts +1 -1
  29. package/dest/mem_pools/instrumentation.d.ts.map +1 -1
  30. package/dest/mem_pools/instrumentation.js +2 -2
  31. package/dest/mem_pools/interface.d.ts +3 -3
  32. package/dest/mem_pools/interface.d.ts.map +1 -1
  33. package/dest/mem_pools/tx_pool_v2/archive/index.d.ts +2 -0
  34. package/dest/mem_pools/tx_pool_v2/archive/index.d.ts.map +1 -0
  35. package/dest/mem_pools/tx_pool_v2/archive/index.js +1 -0
  36. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +43 -0
  37. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -0
  38. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +103 -0
  39. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +47 -0
  40. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -0
  41. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +119 -0
  42. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +17 -0
  43. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
  44. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +90 -0
  45. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +19 -0
  46. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -0
  47. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +89 -0
  48. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +10 -0
  49. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -0
  50. package/dest/mem_pools/tx_pool_v2/eviction/index.js +11 -0
  51. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +131 -0
  52. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -0
  53. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +17 -0
  54. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +15 -0
  55. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
  56. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +63 -0
  57. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +17 -0
  58. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
  59. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +91 -0
  60. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +16 -0
  61. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -0
  62. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +70 -0
  63. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +20 -0
  64. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -0
  65. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +63 -0
  66. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +15 -0
  67. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -0
  68. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +19 -0
  69. package/dest/mem_pools/tx_pool_v2/index.d.ts +5 -0
  70. package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -0
  71. package/dest/mem_pools/tx_pool_v2/index.js +4 -0
  72. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +197 -0
  73. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
  74. package/dest/mem_pools/tx_pool_v2/interfaces.js +6 -0
  75. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +71 -0
  76. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -0
  77. package/dest/mem_pools/tx_pool_v2/tx_metadata.js +95 -0
  78. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts +26 -0
  79. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts.map +1 -0
  80. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.js +70 -0
  81. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +99 -0
  82. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -0
  83. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +332 -0
  84. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +55 -0
  85. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -0
  86. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +156 -0
  87. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +69 -0
  88. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -0
  89. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +748 -0
  90. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +3 -3
  91. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
  92. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +7 -2
  93. package/dest/msg_validators/tx_validator/archive_cache.d.ts +3 -3
  94. package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -1
  95. package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
  96. package/dest/msg_validators/tx_validator/block_header_validator.d.ts +5 -4
  97. package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
  98. package/dest/msg_validators/tx_validator/block_header_validator.js +4 -3
  99. package/dest/msg_validators/tx_validator/data_validator.d.ts +3 -1
  100. package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
  101. package/dest/msg_validators/tx_validator/data_validator.js +4 -1
  102. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +3 -2
  103. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
  104. package/dest/msg_validators/tx_validator/double_spend_validator.js +3 -2
  105. package/dest/msg_validators/tx_validator/factory.d.ts +4 -3
  106. package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
  107. package/dest/msg_validators/tx_validator/factory.js +12 -12
  108. package/dest/msg_validators/tx_validator/gas_validator.d.ts +3 -2
  109. package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
  110. package/dest/msg_validators/tx_validator/gas_validator.js +3 -2
  111. package/dest/msg_validators/tx_validator/metadata_validator.d.ts +3 -2
  112. package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
  113. package/dest/msg_validators/tx_validator/metadata_validator.js +2 -2
  114. package/dest/msg_validators/tx_validator/phases_validator.d.ts +3 -2
  115. package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
  116. package/dest/msg_validators/tx_validator/phases_validator.js +3 -3
  117. package/dest/msg_validators/tx_validator/size_validator.d.ts +3 -1
  118. package/dest/msg_validators/tx_validator/size_validator.d.ts.map +1 -1
  119. package/dest/msg_validators/tx_validator/size_validator.js +4 -1
  120. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +3 -2
  121. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
  122. package/dest/msg_validators/tx_validator/timestamp_validator.js +2 -2
  123. package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts +3 -2
  124. package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -1
  125. package/dest/msg_validators/tx_validator/tx_permitted_validator.js +2 -2
  126. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +3 -2
  127. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
  128. package/dest/msg_validators/tx_validator/tx_proof_validator.js +2 -2
  129. package/dest/services/data_store.d.ts +1 -1
  130. package/dest/services/data_store.d.ts.map +1 -1
  131. package/dest/services/data_store.js +10 -6
  132. package/dest/services/discv5/discV5_service.js +1 -1
  133. package/dest/services/dummy_service.d.ts +6 -2
  134. package/dest/services/dummy_service.d.ts.map +1 -1
  135. package/dest/services/dummy_service.js +3 -0
  136. package/dest/services/index.d.ts +2 -1
  137. package/dest/services/index.d.ts.map +1 -1
  138. package/dest/services/index.js +1 -0
  139. package/dest/services/libp2p/instrumentation.d.ts +1 -1
  140. package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
  141. package/dest/services/libp2p/instrumentation.js +14 -3
  142. package/dest/services/libp2p/libp2p_service.d.ts +74 -33
  143. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  144. package/dest/services/libp2p/libp2p_service.js +309 -238
  145. package/dest/services/peer-manager/metrics.d.ts +2 -2
  146. package/dest/services/peer-manager/metrics.d.ts.map +1 -1
  147. package/dest/services/peer-manager/metrics.js +20 -5
  148. package/dest/services/peer-manager/peer_scoring.d.ts +1 -1
  149. package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
  150. package/dest/services/peer-manager/peer_scoring.js +8 -2
  151. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +4 -4
  152. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
  153. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +9 -9
  154. package/dest/services/reqresp/metrics.d.ts +6 -5
  155. package/dest/services/reqresp/metrics.d.ts.map +1 -1
  156. package/dest/services/reqresp/metrics.js +17 -5
  157. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +6 -4
  158. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
  159. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +17 -12
  160. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +19 -14
  161. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
  162. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +25 -24
  163. package/dest/services/service.d.ts +18 -1
  164. package/dest/services/service.d.ts.map +1 -1
  165. package/dest/services/tx_collection/config.d.ts +3 -3
  166. package/dest/services/tx_collection/config.js +3 -3
  167. package/dest/services/tx_collection/fast_tx_collection.d.ts +4 -5
  168. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
  169. package/dest/services/tx_collection/fast_tx_collection.js +10 -14
  170. package/dest/services/tx_collection/index.d.ts +1 -1
  171. package/dest/services/tx_collection/instrumentation.d.ts +1 -1
  172. package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
  173. package/dest/services/tx_collection/instrumentation.js +9 -2
  174. package/dest/services/tx_collection/proposal_tx_collector.d.ts +12 -12
  175. package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
  176. package/dest/services/tx_collection/proposal_tx_collector.js +4 -5
  177. package/dest/services/tx_file_store/config.d.ts +18 -0
  178. package/dest/services/tx_file_store/config.d.ts.map +1 -0
  179. package/dest/services/tx_file_store/config.js +26 -0
  180. package/dest/services/tx_file_store/index.d.ts +4 -0
  181. package/dest/services/tx_file_store/index.d.ts.map +1 -0
  182. package/dest/services/tx_file_store/index.js +3 -0
  183. package/dest/services/tx_file_store/instrumentation.d.ts +15 -0
  184. package/dest/services/tx_file_store/instrumentation.d.ts.map +1 -0
  185. package/dest/services/tx_file_store/instrumentation.js +29 -0
  186. package/dest/services/tx_file_store/tx_file_store.d.ts +47 -0
  187. package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -0
  188. package/dest/services/tx_file_store/tx_file_store.js +149 -0
  189. package/dest/services/tx_provider_instrumentation.d.ts +1 -1
  190. package/dest/services/tx_provider_instrumentation.d.ts.map +1 -1
  191. package/dest/services/tx_provider_instrumentation.js +5 -5
  192. package/dest/test-helpers/testbench-utils.d.ts +12 -16
  193. package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
  194. package/dest/test-helpers/testbench-utils.js +34 -31
  195. package/dest/testbench/p2p_client_testbench_worker.js +2 -2
  196. package/package.json +14 -14
  197. package/src/bootstrap/bootstrap.ts +7 -4
  198. package/src/client/factory.ts +12 -13
  199. package/src/client/interface.ts +13 -1
  200. package/src/client/p2p_client.ts +32 -8
  201. package/src/client/test/tx_proposal_collector/README.md +4 -4
  202. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +2 -2
  203. package/src/config.ts +8 -1
  204. package/src/mem_pools/attestation_pool/attestation_pool.ts +444 -90
  205. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +436 -100
  206. package/src/mem_pools/attestation_pool/index.ts +9 -2
  207. package/src/mem_pools/index.ts +1 -1
  208. package/src/mem_pools/instrumentation.ts +2 -1
  209. package/src/mem_pools/interface.ts +2 -2
  210. package/src/mem_pools/tx_pool_v2/README.md +209 -0
  211. package/src/mem_pools/tx_pool_v2/archive/index.ts +1 -0
  212. package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +120 -0
  213. package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +147 -0
  214. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +118 -0
  215. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +111 -0
  216. package/src/mem_pools/tx_pool_v2/eviction/index.ts +23 -0
  217. package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +164 -0
  218. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +74 -0
  219. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +101 -0
  220. package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +86 -0
  221. package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +72 -0
  222. package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +31 -0
  223. package/src/mem_pools/tx_pool_v2/index.ts +11 -0
  224. package/src/mem_pools/tx_pool_v2/interfaces.ts +227 -0
  225. package/src/mem_pools/tx_pool_v2/tx_metadata.ts +161 -0
  226. package/src/mem_pools/tx_pool_v2/tx_pool_bench_metrics.ts +77 -0
  227. package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +417 -0
  228. package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +212 -0
  229. package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +882 -0
  230. package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +10 -4
  231. package/src/msg_validators/tx_validator/archive_cache.ts +3 -3
  232. package/src/msg_validators/tx_validator/block_header_validator.ts +7 -8
  233. package/src/msg_validators/tx_validator/data_validator.ts +6 -2
  234. package/src/msg_validators/tx_validator/double_spend_validator.ts +4 -3
  235. package/src/msg_validators/tx_validator/factory.ts +46 -30
  236. package/src/msg_validators/tx_validator/gas_validator.ts +9 -3
  237. package/src/msg_validators/tx_validator/metadata_validator.ts +6 -3
  238. package/src/msg_validators/tx_validator/phases_validator.ts +5 -3
  239. package/src/msg_validators/tx_validator/size_validator.ts +6 -2
  240. package/src/msg_validators/tx_validator/timestamp_validator.ts +6 -3
  241. package/src/msg_validators/tx_validator/tx_permitted_validator.ts +8 -3
  242. package/src/msg_validators/tx_validator/tx_proof_validator.ts +8 -3
  243. package/src/services/data_store.ts +10 -7
  244. package/src/services/discv5/discV5_service.ts +1 -1
  245. package/src/services/dummy_service.ts +6 -0
  246. package/src/services/index.ts +1 -0
  247. package/src/services/libp2p/instrumentation.ts +15 -2
  248. package/src/services/libp2p/libp2p_service.ts +324 -246
  249. package/src/services/peer-manager/metrics.ts +21 -4
  250. package/src/services/peer-manager/peer_scoring.ts +4 -1
  251. package/src/services/reqresp/batch-tx-requester/README.md +14 -14
  252. package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +12 -12
  253. package/src/services/reqresp/metrics.ts +34 -9
  254. package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +23 -14
  255. package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +30 -24
  256. package/src/services/service.ts +20 -0
  257. package/src/services/tx_collection/config.ts +6 -6
  258. package/src/services/tx_collection/fast_tx_collection.ts +14 -24
  259. package/src/services/tx_collection/index.ts +1 -1
  260. package/src/services/tx_collection/instrumentation.ts +11 -2
  261. package/src/services/tx_collection/proposal_tx_collector.ts +12 -14
  262. package/src/services/tx_file_store/config.ts +43 -0
  263. package/src/services/tx_file_store/index.ts +3 -0
  264. package/src/services/tx_file_store/instrumentation.ts +36 -0
  265. package/src/services/tx_file_store/tx_file_store.ts +173 -0
  266. package/src/services/tx_provider_instrumentation.ts +11 -5
  267. package/src/test-helpers/testbench-utils.ts +20 -39
  268. package/src/testbench/p2p_client_testbench_worker.ts +2 -2
  269. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +0 -40
  270. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +0 -1
  271. package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +0 -218
  272. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -31
  273. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +0 -1
  274. package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +0 -180
  275. package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -320
  276. package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -264
@@ -6,12 +6,13 @@ import {
6
6
  type TelemetryClient,
7
7
  type Tracer,
8
8
  type UpDownCounter,
9
+ createUpDownCounterWithDefault,
9
10
  getTelemetryClient,
10
11
  } from '@aztec/telemetry-client';
11
12
 
12
13
  import type { PeerId } from '@libp2p/interface';
13
14
 
14
- import { type GoodByeReason, prettyGoodbyeReason } from '../reqresp/protocols/index.js';
15
+ import { GoodByeReason, prettyGoodbyeReason } from '../reqresp/protocols/index.js';
15
16
 
16
17
  export class PeerManagerMetrics {
17
18
  private sentGoodbyes: UpDownCounter;
@@ -31,10 +32,26 @@ export class PeerManagerMetrics {
31
32
  this.tracer = telemetryClient.getTracer(name);
32
33
 
33
34
  const meter = telemetryClient.getMeter(name);
34
- this.sentGoodbyes = meter.createUpDownCounter(Metrics.PEER_MANAGER_GOODBYES_SENT);
35
- this.receivedGoodbyes = meter.createUpDownCounter(Metrics.PEER_MANAGER_GOODBYES_RECEIVED);
35
+ const goodbyeReasonAttrs = {
36
+ [Attributes.P2P_GOODBYE_REASON]: [
37
+ prettyGoodbyeReason(GoodByeReason.SHUTDOWN),
38
+ prettyGoodbyeReason(GoodByeReason.MAX_PEERS),
39
+ prettyGoodbyeReason(GoodByeReason.LOW_SCORE),
40
+ prettyGoodbyeReason(GoodByeReason.BANNED),
41
+ prettyGoodbyeReason(GoodByeReason.WRONG_NETWORK),
42
+ prettyGoodbyeReason(GoodByeReason.UNKNOWN),
43
+ ],
44
+ };
45
+ this.sentGoodbyes = createUpDownCounterWithDefault(meter, Metrics.PEER_MANAGER_GOODBYES_SENT, goodbyeReasonAttrs);
46
+ this.receivedGoodbyes = createUpDownCounterWithDefault(
47
+ meter,
48
+ Metrics.PEER_MANAGER_GOODBYES_RECEIVED,
49
+ goodbyeReasonAttrs,
50
+ );
36
51
  this.peerCount = meter.createGauge(Metrics.PEER_MANAGER_PEER_COUNT);
37
- this.lowScoreDisconnects = meter.createUpDownCounter(Metrics.PEER_MANAGER_LOW_SCORE_DISCONNECTS);
52
+ this.lowScoreDisconnects = createUpDownCounterWithDefault(meter, Metrics.PEER_MANAGER_LOW_SCORE_DISCONNECTS, {
53
+ [Attributes.P2P_PEER_SCORE_STATE]: ['Banned', 'Disconnect'],
54
+ });
38
55
  this.peerConnectionDuration = meter.createHistogram(Metrics.PEER_MANAGER_PEER_CONNECTION_DURATION);
39
56
  }
40
57
 
@@ -6,6 +6,7 @@ import {
6
6
  Metrics,
7
7
  type TelemetryClient,
8
8
  type UpDownCounter,
9
+ createUpDownCounterWithDefault,
9
10
  getTelemetryClient,
10
11
  } from '@aztec/telemetry-client';
11
12
 
@@ -52,7 +53,9 @@ export class PeerScoring {
52
53
 
53
54
  const meter = telemetry.getMeter('PeerScoring');
54
55
 
55
- this.peerStateCounter = meter.createUpDownCounter(Metrics.P2P_PEER_STATE_COUNT);
56
+ this.peerStateCounter = createUpDownCounterWithDefault(meter, Metrics.P2P_PEER_STATE_COUNT, {
57
+ [Attributes.P2P_PEER_SCORE_STATE]: ['Healthy', 'Disconnect', 'Banned'],
58
+ });
56
59
  }
57
60
 
58
61
  public penalizePeer(peerId: PeerId, penalty: PeerErrorSeverity) {
@@ -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
 
@@ -71,7 +71,7 @@ The requester classifies peers into three categories to optimize fetching:
71
71
  ### Blind Phase → Smart Phase Transition
72
72
 
73
73
  Peers transition from "dumb" to "smart" when they respond with a valid `BlockTxsResponse` containing:
74
- 1. A matching `blockHash`
74
+ 1. A matching `archiveRoot`
75
75
  2. A non-empty `txIndices` BitVector indicating which transactions they have
76
76
  3. At least one transaction we're still missing
77
77
 
@@ -81,10 +81,10 @@ Peers transition from "dumb" to "smart" when they respond with a valid `BlockTxs
81
81
  │ ┌────────────────────────────────────────────────────────────────────────┐ │
82
82
  │ │ Initial State: All peers are "dumb" (except pinned peer) │ │
83
83
  │ │ │ │
84
- │ │ Request: [blockHash, txHashes (full list), txIndices (BitVector)] │ │
84
+ │ │ Request: [archiveRoot, txHashes (full list), txIndices (BitVector)] │ │
85
85
  │ │ └─ Include full hashes because peer may not have proposal │ │
86
86
  │ │ │ │
87
- │ │ Response: [blockHash, txs[], txIndices (what peer has)] │ │
87
+ │ │ Response: [archiveRoot, txs[], txIndices (what peer has)] │ │
88
88
  │ │ └─ Tells us exactly which txs this peer can provide │ │
89
89
  │ └────────────────────────────────────────────────────────────────────────┘ │
90
90
  └──────────────────────────────────────────────────────────────────────────────┘
@@ -97,10 +97,10 @@ Peers transition from "dumb" to "smart" when they respond with a valid `BlockTxs
97
97
  │ ┌────────────────────────────────────────────────────────────────────────┐ │
98
98
  │ │ Peer promoted to "smart" - we know exactly what they have │ │
99
99
  │ │ │ │
100
- │ │ Request: [blockHash, txIndices (BitVector only)] │ │
100
+ │ │ Request: [archiveRoot, txIndices (BitVector only)] │ │
101
101
  │ │ └─ No need for full hashes, peer has the proposal │ │
102
102
  │ │ │ │
103
- │ │ Response: [blockHash, txs[], txIndices (updated availability)] │ │
103
+ │ │ Response: [archiveRoot, txs[], txIndices (updated availability)] │ │
104
104
  │ │ └─ May have received more txs since last response │ │
105
105
  │ └────────────────────────────────────────────────────────────────────────┘ │
106
106
  └──────────────────────────────────────────────────────────────────────────────┘
@@ -152,7 +152,7 @@ The `BatchTxRequester` runs three types of workers concurrently:
152
152
 
153
153
  ```typescript
154
154
  class BlockTxsRequest {
155
- blockHash: Fr; // 32-byte hash of the proposed block header
155
+ archiveRoot: Fr; // Archive root after the proposed block is applied
156
156
  txHashes: TxHashArray; // Full tx hashes (for dumb peers without proposal)
157
157
  txIndices: BitVector; // Which txs from proposal we're requesting (1 = want)
158
158
  }
@@ -162,7 +162,7 @@ class BlockTxsRequest {
162
162
 
163
163
  ```typescript
164
164
  class BlockTxsResponse {
165
- blockHash: Fr; // Echo back the block hash
165
+ archiveRoot: Fr; // Echo back the proposal archive root
166
166
  txs: TxArray; // Actual transaction data
167
167
  txIndices: BitVector; // Which txs the peer has available (1 = have)
168
168
  }
@@ -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,9 +605,9 @@ export class BatchTxRequester {
605
605
  }
606
606
 
607
607
  private isBlockResponseValid(response: BlockTxsResponse): boolean {
608
- const blockIdsMatch = this.blockProposal.archive.toString() === response.blockHash.toString();
608
+ const archiveRootsMatch = this.blockTxsSource.archive.toString() === response.archiveRoot.toString();
609
609
  const peerHasSomeTxsFromProposal = !response.txIndices.isEmpty();
610
- return blockIdsMatch && peerHasSomeTxsFromProposal;
610
+ return archiveRootsMatch && peerHasSomeTxsFromProposal;
611
611
  }
612
612
 
613
613
  private peerHasSomeTxsWeAreMissing(_peerId: PeerId, response: BlockTxsResponse): boolean {
@@ -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,7 +1,9 @@
1
1
  // Request response metrics
2
- import { Attributes, Metrics } from '@aztec/telemetry-client';
2
+ import { Attributes, Metrics, createUpDownCounterWithDefault } from '@aztec/telemetry-client';
3
3
  import type { TelemetryClient, Tracer, UpDownCounter } from '@aztec/telemetry-client';
4
4
 
5
+ import { ReqRespSubProtocol } from './interface.js';
6
+
5
7
  export class ReqRespMetrics {
6
8
  public readonly tracer: Tracer;
7
9
 
@@ -18,27 +20,50 @@ export class ReqRespMetrics {
18
20
  this.tracer = telemetryClient.getTracer(name);
19
21
 
20
22
  const meter = telemetryClient.getMeter(name);
21
- this.sentRequests = meter.createUpDownCounter(Metrics.P2P_REQ_RESP_SENT_REQUESTS);
22
- this.receivedRequests = meter.createUpDownCounter(Metrics.P2P_REQ_RESP_RECEIVED_REQUESTS);
23
+ const protocolAttrs = {
24
+ [Attributes.P2P_REQ_RESP_PROTOCOL]: [
25
+ ReqRespSubProtocol.PING,
26
+ ReqRespSubProtocol.STATUS,
27
+ ReqRespSubProtocol.GOODBYE,
28
+ ReqRespSubProtocol.TX,
29
+ ReqRespSubProtocol.BLOCK,
30
+ ReqRespSubProtocol.AUTH,
31
+ ReqRespSubProtocol.BLOCK_TXS,
32
+ ],
33
+ };
34
+ this.sentRequests = createUpDownCounterWithDefault(meter, Metrics.P2P_REQ_RESP_SENT_REQUESTS, protocolAttrs);
35
+ this.receivedRequests = createUpDownCounterWithDefault(
36
+ meter,
37
+ Metrics.P2P_REQ_RESP_RECEIVED_REQUESTS,
38
+ protocolAttrs,
39
+ );
23
40
 
24
- this.failedOutboundRequests = meter.createUpDownCounter(Metrics.P2P_REQ_RESP_FAILED_OUTBOUND_REQUESTS);
41
+ this.failedOutboundRequests = createUpDownCounterWithDefault(
42
+ meter,
43
+ Metrics.P2P_REQ_RESP_FAILED_OUTBOUND_REQUESTS,
44
+ protocolAttrs,
45
+ );
25
46
 
26
- this.failedInboundRequests = meter.createUpDownCounter(Metrics.P2P_REQ_RESP_FAILED_INBOUND_REQUESTS);
47
+ this.failedInboundRequests = createUpDownCounterWithDefault(
48
+ meter,
49
+ Metrics.P2P_REQ_RESP_FAILED_INBOUND_REQUESTS,
50
+ protocolAttrs,
51
+ );
27
52
  }
28
53
 
29
- public recordRequestSent(protocol: string) {
54
+ public recordRequestSent(protocol: ReqRespSubProtocol) {
30
55
  this.sentRequests.add(1, { [Attributes.P2P_REQ_RESP_PROTOCOL]: protocol });
31
56
  }
32
57
 
33
- public recordRequestReceived(protocol: string) {
58
+ public recordRequestReceived(protocol: ReqRespSubProtocol) {
34
59
  this.receivedRequests.add(1, { [Attributes.P2P_REQ_RESP_PROTOCOL]: protocol });
35
60
  }
36
61
 
37
- public recordRequestError(protocol: string) {
62
+ public recordRequestError(protocol: ReqRespSubProtocol) {
38
63
  this.failedOutboundRequests.add(1, { [Attributes.P2P_REQ_RESP_PROTOCOL]: protocol });
39
64
  }
40
65
 
41
- public recordResponseError(protocol: string) {
66
+ public recordResponseError(protocol: ReqRespSubProtocol) {
42
67
  this.failedInboundRequests.add(1, { [Attributes.P2P_REQ_RESP_PROTOCOL]: protocol });
43
68
  }
44
69
  }
@@ -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,37 +36,40 @@ 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.blockHash.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
- const response = new BlockTxsResponse(request.blockHash, new TxArray(...responseTxs), responseBitVector);
72
+ const response = new BlockTxsResponse(request.archiveRoot, new TxArray(...responseTxs), responseBitVector);
64
73
 
65
74
  return response.toBuffer();
66
75
  };
@@ -1,17 +1,22 @@
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
  */
11
16
  export class BlockTxsRequest {
12
17
  constructor(
13
- // 32 byte hash of the proposed block header
14
- readonly blockHash: Fr,
18
+ // Archive root after the proposed block is applied (proposal identifier)
19
+ readonly archiveRoot: Fr,
15
20
  // Hashes of txs we are requesting
16
21
  readonly txHashes: TxHashArray,
17
22
  // BitVector indicating which txs from the proposal we are requesting
@@ -22,16 +27,17 @@ export class BlockTxsRequest {
22
27
  ) {}
23
28
 
24
29
  /**
25
- * Crates 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
  /**
@@ -63,11 +69,11 @@ export class BlockTxsRequest {
63
69
  */
64
70
  static fromBuffer(buffer: Buffer | BufferReader): BlockTxsRequest {
65
71
  const reader = BufferReader.asReader(buffer);
66
- const blockHash = Fr.fromBuffer(reader);
72
+ const archiveRoot = Fr.fromBuffer(reader);
67
73
  const txHashes = TxHashArray.fromBuffer(reader);
68
74
  const txIndices = BitVector.fromBuffer(reader);
69
75
 
70
- return new BlockTxsRequest(blockHash, txHashes, txIndices);
76
+ return new BlockTxsRequest(archiveRoot, txHashes, txIndices);
71
77
  }
72
78
 
73
79
  /**
@@ -75,7 +81,7 @@ export class BlockTxsRequest {
75
81
  * @returns Buffer representation of the BlockTxRequest object
76
82
  */
77
83
  toBuffer(): Buffer {
78
- return serializeToBuffer([this.blockHash, this.txHashes.toBuffer(), this.txIndices.toBuffer()]);
84
+ return serializeToBuffer([this.archiveRoot, this.txHashes.toBuffer(), this.txIndices.toBuffer()]);
79
85
  }
80
86
  }
81
87
 
@@ -84,7 +90,7 @@ export class BlockTxsRequest {
84
90
  */
85
91
  export class BlockTxsResponse {
86
92
  constructor(
87
- readonly blockHash: Fr,
93
+ readonly archiveRoot: Fr,
88
94
  readonly txs: TxArray, // List of transactions we requested and peer has
89
95
  // BitVector indicating which txs from the proposal are available at the peer
90
96
  // 1 means the tx is available, 0 means it is not
@@ -98,11 +104,11 @@ export class BlockTxsResponse {
98
104
  */
99
105
  static fromBuffer(buffer: Buffer | BufferReader): BlockTxsResponse {
100
106
  const reader = BufferReader.asReader(buffer);
101
- const blockHash = Fr.fromBuffer(reader);
107
+ const archiveRoot = Fr.fromBuffer(reader);
102
108
  const txs = TxArray.fromBuffer(reader);
103
109
  const txIndices = BitVector.fromBuffer(reader);
104
110
 
105
- return new BlockTxsResponse(blockHash, txs, txIndices);
111
+ return new BlockTxsResponse(archiveRoot, txs, txIndices);
106
112
  }
107
113
 
108
114
  /**
@@ -112,7 +118,7 @@ export class BlockTxsResponse {
112
118
  * @returns Buffer representation of the BlockTxResponse object
113
119
  */
114
120
  toBuffer(): Buffer {
115
- return serializeToBuffer([this.blockHash, this.txs.toBuffer(), this.txIndices.toBuffer()]);
121
+ return serializeToBuffer([this.archiveRoot, this.txs.toBuffer(), this.txIndices.toBuffer()]);
116
122
  }
117
123
 
118
124
  static empty(): BlockTxsResponse {
@@ -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
  };