@aztec/p2p 0.0.1-commit.f295ac2 → 0.0.1-commit.f8ca9b2f3

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 (443) 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 +5 -5
  5. package/dest/client/factory.d.ts.map +1 -1
  6. package/dest/client/factory.js +47 -13
  7. package/dest/client/interface.d.ts +33 -15
  8. package/dest/client/interface.d.ts.map +1 -1
  9. package/dest/client/p2p_client.d.ts +35 -36
  10. package/dest/client/p2p_client.d.ts.map +1 -1
  11. package/dest/client/p2p_client.js +115 -139
  12. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts +2 -0
  13. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts.map +1 -0
  14. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +305 -0
  15. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts +73 -0
  16. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts.map +1 -0
  17. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.js +8 -0
  18. package/dest/config.d.ts +24 -3
  19. package/dest/config.d.ts.map +1 -1
  20. package/dest/config.js +16 -2
  21. package/dest/index.d.ts +2 -1
  22. package/dest/index.d.ts.map +1 -1
  23. package/dest/index.js +1 -0
  24. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +102 -88
  25. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  26. package/dest/mem_pools/attestation_pool/attestation_pool.js +436 -3
  27. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +2 -2
  28. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
  29. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +353 -87
  30. package/dest/mem_pools/attestation_pool/index.d.ts +2 -3
  31. package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
  32. package/dest/mem_pools/attestation_pool/index.js +1 -2
  33. package/dest/mem_pools/index.d.ts +3 -2
  34. package/dest/mem_pools/index.d.ts.map +1 -1
  35. package/dest/mem_pools/index.js +1 -1
  36. package/dest/mem_pools/instrumentation.d.ts +1 -1
  37. package/dest/mem_pools/instrumentation.d.ts.map +1 -1
  38. package/dest/mem_pools/instrumentation.js +2 -2
  39. package/dest/mem_pools/interface.d.ts +5 -5
  40. package/dest/mem_pools/interface.d.ts.map +1 -1
  41. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +3 -3
  42. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
  43. package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +3 -2
  44. package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +1 -1
  45. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +3 -2
  46. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +1 -1
  47. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +3 -3
  48. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
  49. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +8 -1
  50. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +3 -3
  51. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -1
  52. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +2 -0
  53. package/dest/mem_pools/tx_pool_v2/archive/index.d.ts +2 -0
  54. package/dest/mem_pools/tx_pool_v2/archive/index.d.ts.map +1 -0
  55. package/dest/mem_pools/tx_pool_v2/archive/index.js +1 -0
  56. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +43 -0
  57. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -0
  58. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +103 -0
  59. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +87 -0
  60. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -0
  61. package/dest/mem_pools/tx_pool_v2/deleted_pool.js +180 -0
  62. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +47 -0
  63. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -0
  64. package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +119 -0
  65. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +17 -0
  66. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
  67. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +90 -0
  68. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +19 -0
  69. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -0
  70. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +89 -0
  71. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +10 -0
  72. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -0
  73. package/dest/mem_pools/tx_pool_v2/eviction/index.js +11 -0
  74. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +131 -0
  75. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -0
  76. package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +17 -0
  77. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +15 -0
  78. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
  79. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +63 -0
  80. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +17 -0
  81. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
  82. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +91 -0
  83. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +16 -0
  84. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -0
  85. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +70 -0
  86. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +20 -0
  87. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -0
  88. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +63 -0
  89. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +15 -0
  90. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -0
  91. package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +19 -0
  92. package/dest/mem_pools/tx_pool_v2/index.d.ts +6 -0
  93. package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -0
  94. package/dest/mem_pools/tx_pool_v2/index.js +5 -0
  95. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +197 -0
  96. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
  97. package/dest/mem_pools/tx_pool_v2/interfaces.js +6 -0
  98. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +93 -0
  99. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -0
  100. package/dest/mem_pools/tx_pool_v2/tx_metadata.js +127 -0
  101. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts +26 -0
  102. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts.map +1 -0
  103. package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.js +70 -0
  104. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +99 -0
  105. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -0
  106. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +332 -0
  107. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +55 -0
  108. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -0
  109. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +156 -0
  110. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +69 -0
  111. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -0
  112. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +751 -0
  113. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +3 -3
  114. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
  115. package/dest/msg_validators/attestation_validator/attestation_validator.js +41 -10
  116. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +5 -5
  117. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
  118. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +18 -6
  119. package/dest/msg_validators/clock_tolerance.d.ts +21 -0
  120. package/dest/msg_validators/clock_tolerance.d.ts.map +1 -0
  121. package/dest/msg_validators/clock_tolerance.js +37 -0
  122. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +3 -3
  123. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
  124. package/dest/msg_validators/proposal_validator/proposal_validator.js +55 -31
  125. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +3 -3
  126. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +1 -1
  127. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +93 -64
  128. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +3 -3
  129. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
  130. package/dest/msg_validators/tx_validator/archive_cache.d.ts +3 -3
  131. package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -1
  132. package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
  133. package/dest/msg_validators/tx_validator/block_header_validator.d.ts +20 -6
  134. package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
  135. package/dest/msg_validators/tx_validator/block_header_validator.js +4 -3
  136. package/dest/msg_validators/tx_validator/data_validator.d.ts +3 -1
  137. package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
  138. package/dest/msg_validators/tx_validator/data_validator.js +4 -1
  139. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +15 -4
  140. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
  141. package/dest/msg_validators/tx_validator/double_spend_validator.js +7 -6
  142. package/dest/msg_validators/tx_validator/factory.d.ts +8 -3
  143. package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
  144. package/dest/msg_validators/tx_validator/factory.js +21 -11
  145. package/dest/msg_validators/tx_validator/gas_validator.d.ts +3 -2
  146. package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
  147. package/dest/msg_validators/tx_validator/gas_validator.js +3 -2
  148. package/dest/msg_validators/tx_validator/index.d.ts +2 -1
  149. package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
  150. package/dest/msg_validators/tx_validator/index.js +1 -0
  151. package/dest/msg_validators/tx_validator/metadata_validator.d.ts +3 -2
  152. package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
  153. package/dest/msg_validators/tx_validator/metadata_validator.js +2 -2
  154. package/dest/msg_validators/tx_validator/phases_validator.d.ts +3 -2
  155. package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
  156. package/dest/msg_validators/tx_validator/phases_validator.js +3 -3
  157. package/dest/msg_validators/tx_validator/size_validator.d.ts +8 -0
  158. package/dest/msg_validators/tx_validator/size_validator.d.ts.map +1 -0
  159. package/dest/msg_validators/tx_validator/size_validator.js +23 -0
  160. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +22 -5
  161. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
  162. package/dest/msg_validators/tx_validator/timestamp_validator.js +4 -4
  163. package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts +3 -2
  164. package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -1
  165. package/dest/msg_validators/tx_validator/tx_permitted_validator.js +2 -2
  166. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +3 -2
  167. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
  168. package/dest/msg_validators/tx_validator/tx_proof_validator.js +2 -2
  169. package/dest/services/data_store.d.ts +1 -1
  170. package/dest/services/data_store.d.ts.map +1 -1
  171. package/dest/services/data_store.js +10 -6
  172. package/dest/services/discv5/discV5_service.js +1 -1
  173. package/dest/services/dummy_service.d.ts +22 -2
  174. package/dest/services/dummy_service.d.ts.map +1 -1
  175. package/dest/services/dummy_service.js +45 -0
  176. package/dest/services/encoding.d.ts +2 -2
  177. package/dest/services/encoding.d.ts.map +1 -1
  178. package/dest/services/encoding.js +4 -5
  179. package/dest/services/gossipsub/index.d.ts +3 -0
  180. package/dest/services/gossipsub/index.d.ts.map +1 -0
  181. package/dest/services/gossipsub/index.js +2 -0
  182. package/dest/services/gossipsub/scoring.d.ts +21 -3
  183. package/dest/services/gossipsub/scoring.d.ts.map +1 -1
  184. package/dest/services/gossipsub/scoring.js +24 -7
  185. package/dest/services/gossipsub/topic_score_params.d.ts +161 -0
  186. package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -0
  187. package/dest/services/gossipsub/topic_score_params.js +324 -0
  188. package/dest/services/index.d.ts +2 -1
  189. package/dest/services/index.d.ts.map +1 -1
  190. package/dest/services/index.js +1 -0
  191. package/dest/services/libp2p/instrumentation.d.ts +1 -1
  192. package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
  193. package/dest/services/libp2p/instrumentation.js +14 -3
  194. package/dest/services/libp2p/libp2p_service.d.ts +91 -36
  195. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  196. package/dest/services/libp2p/libp2p_service.js +407 -303
  197. package/dest/services/peer-manager/metrics.d.ts +2 -2
  198. package/dest/services/peer-manager/metrics.d.ts.map +1 -1
  199. package/dest/services/peer-manager/metrics.js +20 -5
  200. package/dest/services/peer-manager/peer_scoring.d.ts +1 -1
  201. package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
  202. package/dest/services/peer-manager/peer_scoring.js +33 -4
  203. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +47 -0
  204. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -0
  205. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +566 -0
  206. package/dest/services/reqresp/batch-tx-requester/config.d.ts +17 -0
  207. package/dest/services/reqresp/batch-tx-requester/config.d.ts.map +1 -0
  208. package/dest/services/reqresp/batch-tx-requester/config.js +27 -0
  209. package/dest/services/reqresp/batch-tx-requester/interface.d.ts +50 -0
  210. package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -0
  211. package/dest/services/reqresp/batch-tx-requester/interface.js +1 -0
  212. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +37 -0
  213. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -0
  214. package/dest/services/reqresp/batch-tx-requester/missing_txs.js +151 -0
  215. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +54 -0
  216. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -0
  217. package/dest/services/reqresp/batch-tx-requester/peer_collection.js +139 -0
  218. package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts +20 -0
  219. package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts.map +1 -0
  220. package/dest/services/reqresp/batch-tx-requester/tx_validator.js +21 -0
  221. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +22 -3
  222. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
  223. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +63 -4
  224. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +2 -1
  225. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
  226. package/dest/services/reqresp/connection-sampler/connection_sampler.js +12 -0
  227. package/dest/services/reqresp/interface.d.ts +14 -3
  228. package/dest/services/reqresp/interface.d.ts.map +1 -1
  229. package/dest/services/reqresp/interface.js +17 -3
  230. package/dest/services/reqresp/metrics.d.ts +6 -5
  231. package/dest/services/reqresp/metrics.d.ts.map +1 -1
  232. package/dest/services/reqresp/metrics.js +17 -5
  233. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +5 -1
  234. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
  235. package/dest/services/reqresp/protocols/block_txs/bitvector.js +5 -0
  236. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +7 -5
  237. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
  238. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +27 -9
  239. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +29 -6
  240. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
  241. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +59 -13
  242. package/dest/services/reqresp/protocols/tx.d.ts +7 -1
  243. package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
  244. package/dest/services/reqresp/protocols/tx.js +20 -0
  245. package/dest/services/reqresp/reqresp.d.ts +6 -1
  246. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  247. package/dest/services/reqresp/reqresp.js +69 -26
  248. package/dest/services/service.d.ts +38 -1
  249. package/dest/services/service.d.ts.map +1 -1
  250. package/dest/services/tx_collection/config.d.ts +10 -1
  251. package/dest/services/tx_collection/config.d.ts.map +1 -1
  252. package/dest/services/tx_collection/config.js +25 -1
  253. package/dest/services/tx_collection/fast_tx_collection.d.ts +7 -4
  254. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
  255. package/dest/services/tx_collection/fast_tx_collection.js +34 -13
  256. package/dest/services/tx_collection/file_store_tx_collection.d.ts +44 -0
  257. package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -0
  258. package/dest/services/tx_collection/file_store_tx_collection.js +118 -0
  259. package/dest/services/tx_collection/file_store_tx_source.d.ts +27 -0
  260. package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -0
  261. package/dest/services/tx_collection/file_store_tx_source.js +57 -0
  262. package/dest/services/tx_collection/index.d.ts +3 -1
  263. package/dest/services/tx_collection/index.d.ts.map +1 -1
  264. package/dest/services/tx_collection/index.js +2 -0
  265. package/dest/services/tx_collection/instrumentation.d.ts +1 -1
  266. package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
  267. package/dest/services/tx_collection/instrumentation.js +9 -2
  268. package/dest/services/tx_collection/proposal_tx_collector.d.ts +48 -0
  269. package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -0
  270. package/dest/services/tx_collection/proposal_tx_collector.js +49 -0
  271. package/dest/services/tx_collection/slow_tx_collection.d.ts +5 -3
  272. package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
  273. package/dest/services/tx_collection/slow_tx_collection.js +48 -19
  274. package/dest/services/tx_collection/tx_collection.d.ts +23 -13
  275. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
  276. package/dest/services/tx_collection/tx_collection.js +62 -6
  277. package/dest/services/tx_collection/tx_collection_sink.d.ts +15 -6
  278. package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
  279. package/dest/services/tx_collection/tx_collection_sink.js +13 -7
  280. package/dest/services/tx_file_store/config.d.ts +16 -0
  281. package/dest/services/tx_file_store/config.d.ts.map +1 -0
  282. package/dest/services/tx_file_store/config.js +22 -0
  283. package/dest/services/tx_file_store/index.d.ts +4 -0
  284. package/dest/services/tx_file_store/index.d.ts.map +1 -0
  285. package/dest/services/tx_file_store/index.js +3 -0
  286. package/dest/services/tx_file_store/instrumentation.d.ts +15 -0
  287. package/dest/services/tx_file_store/instrumentation.d.ts.map +1 -0
  288. package/dest/services/tx_file_store/instrumentation.js +29 -0
  289. package/dest/services/tx_file_store/tx_file_store.d.ts +47 -0
  290. package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -0
  291. package/dest/services/tx_file_store/tx_file_store.js +149 -0
  292. package/dest/services/tx_provider.d.ts +5 -5
  293. package/dest/services/tx_provider.d.ts.map +1 -1
  294. package/dest/services/tx_provider.js +5 -4
  295. package/dest/services/tx_provider_instrumentation.d.ts +1 -1
  296. package/dest/services/tx_provider_instrumentation.d.ts.map +1 -1
  297. package/dest/services/tx_provider_instrumentation.js +5 -5
  298. package/dest/test-helpers/index.d.ts +3 -1
  299. package/dest/test-helpers/index.d.ts.map +1 -1
  300. package/dest/test-helpers/index.js +2 -0
  301. package/dest/test-helpers/make-test-p2p-clients.d.ts +3 -3
  302. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  303. package/dest/test-helpers/mock-pubsub.d.ts +27 -1
  304. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
  305. package/dest/test-helpers/mock-pubsub.js +97 -2
  306. package/dest/test-helpers/reqresp-nodes.d.ts +1 -1
  307. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  308. package/dest/test-helpers/reqresp-nodes.js +2 -1
  309. package/dest/test-helpers/test_tx_provider.d.ts +40 -0
  310. package/dest/test-helpers/test_tx_provider.d.ts.map +1 -0
  311. package/dest/test-helpers/test_tx_provider.js +41 -0
  312. package/dest/test-helpers/testbench-utils.d.ts +158 -0
  313. package/dest/test-helpers/testbench-utils.d.ts.map +1 -0
  314. package/dest/test-helpers/testbench-utils.js +360 -0
  315. package/dest/testbench/p2p_client_testbench_worker.d.ts +28 -2
  316. package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
  317. package/dest/testbench/p2p_client_testbench_worker.js +213 -134
  318. package/dest/testbench/worker_client_manager.d.ts +51 -6
  319. package/dest/testbench/worker_client_manager.d.ts.map +1 -1
  320. package/dest/testbench/worker_client_manager.js +226 -44
  321. package/package.json +14 -14
  322. package/src/bootstrap/bootstrap.ts +7 -4
  323. package/src/client/factory.ts +78 -22
  324. package/src/client/interface.ts +39 -14
  325. package/src/client/p2p_client.ts +155 -166
  326. package/src/client/test/tx_proposal_collector/README.md +227 -0
  327. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +336 -0
  328. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +43 -0
  329. package/src/config.ts +38 -2
  330. package/src/index.ts +1 -0
  331. package/src/mem_pools/attestation_pool/attestation_pool.ts +488 -91
  332. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +442 -102
  333. package/src/mem_pools/attestation_pool/index.ts +9 -2
  334. package/src/mem_pools/index.ts +4 -1
  335. package/src/mem_pools/instrumentation.ts +2 -1
  336. package/src/mem_pools/interface.ts +4 -4
  337. package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +2 -2
  338. package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +2 -1
  339. package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +2 -1
  340. package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +10 -7
  341. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +4 -2
  342. package/src/mem_pools/tx_pool_v2/README.md +259 -0
  343. package/src/mem_pools/tx_pool_v2/archive/index.ts +1 -0
  344. package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +120 -0
  345. package/src/mem_pools/tx_pool_v2/deleted_pool.ts +234 -0
  346. package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +147 -0
  347. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +118 -0
  348. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +111 -0
  349. package/src/mem_pools/tx_pool_v2/eviction/index.ts +23 -0
  350. package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +164 -0
  351. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +74 -0
  352. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +101 -0
  353. package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +86 -0
  354. package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +72 -0
  355. package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +31 -0
  356. package/src/mem_pools/tx_pool_v2/index.ts +12 -0
  357. package/src/mem_pools/tx_pool_v2/interfaces.ts +227 -0
  358. package/src/mem_pools/tx_pool_v2/tx_metadata.ts +207 -0
  359. package/src/mem_pools/tx_pool_v2/tx_pool_bench_metrics.ts +77 -0
  360. package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +417 -0
  361. package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +212 -0
  362. package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +895 -0
  363. package/src/msg_validators/attestation_validator/attestation_validator.ts +26 -14
  364. package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +16 -10
  365. package/src/msg_validators/clock_tolerance.ts +51 -0
  366. package/src/msg_validators/proposal_validator/proposal_validator.ts +31 -31
  367. package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +91 -67
  368. package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +2 -2
  369. package/src/msg_validators/tx_validator/archive_cache.ts +3 -3
  370. package/src/msg_validators/tx_validator/block_header_validator.ts +21 -8
  371. package/src/msg_validators/tx_validator/data_validator.ts +6 -2
  372. package/src/msg_validators/tx_validator/double_spend_validator.ts +15 -9
  373. package/src/msg_validators/tx_validator/factory.ts +64 -23
  374. package/src/msg_validators/tx_validator/gas_validator.ts +9 -3
  375. package/src/msg_validators/tx_validator/index.ts +1 -0
  376. package/src/msg_validators/tx_validator/metadata_validator.ts +6 -3
  377. package/src/msg_validators/tx_validator/phases_validator.ts +5 -3
  378. package/src/msg_validators/tx_validator/size_validator.ts +22 -0
  379. package/src/msg_validators/tx_validator/timestamp_validator.ts +25 -17
  380. package/src/msg_validators/tx_validator/tx_permitted_validator.ts +8 -3
  381. package/src/msg_validators/tx_validator/tx_proof_validator.ts +8 -3
  382. package/src/services/data_store.ts +10 -7
  383. package/src/services/discv5/discV5_service.ts +1 -1
  384. package/src/services/dummy_service.ts +57 -0
  385. package/src/services/encoding.ts +4 -5
  386. package/src/services/gossipsub/README.md +626 -0
  387. package/src/services/gossipsub/index.ts +2 -0
  388. package/src/services/gossipsub/scoring.ts +29 -5
  389. package/src/services/gossipsub/topic_score_params.ts +451 -0
  390. package/src/services/index.ts +1 -0
  391. package/src/services/libp2p/instrumentation.ts +15 -2
  392. package/src/services/libp2p/libp2p_service.ts +437 -316
  393. package/src/services/peer-manager/metrics.ts +21 -4
  394. package/src/services/peer-manager/peer_scoring.ts +29 -1
  395. package/src/services/reqresp/batch-tx-requester/README.md +305 -0
  396. package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +706 -0
  397. package/src/services/reqresp/batch-tx-requester/config.ts +40 -0
  398. package/src/services/reqresp/batch-tx-requester/interface.ts +57 -0
  399. package/src/services/reqresp/batch-tx-requester/missing_txs.ts +209 -0
  400. package/src/services/reqresp/batch-tx-requester/peer_collection.ts +205 -0
  401. package/src/services/reqresp/batch-tx-requester/tx_validator.ts +37 -0
  402. package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +65 -4
  403. package/src/services/reqresp/connection-sampler/connection_sampler.ts +16 -0
  404. package/src/services/reqresp/interface.ts +31 -3
  405. package/src/services/reqresp/metrics.ts +34 -9
  406. package/src/services/reqresp/protocols/block_txs/bitvector.ts +7 -0
  407. package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +35 -12
  408. package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +74 -9
  409. package/src/services/reqresp/protocols/tx.ts +22 -0
  410. package/src/services/reqresp/reqresp.ts +79 -22
  411. package/src/services/service.ts +44 -0
  412. package/src/services/tx_collection/config.ts +41 -1
  413. package/src/services/tx_collection/fast_tx_collection.ts +44 -19
  414. package/src/services/tx_collection/file_store_tx_collection.ts +152 -0
  415. package/src/services/tx_collection/file_store_tx_source.ts +70 -0
  416. package/src/services/tx_collection/index.ts +6 -0
  417. package/src/services/tx_collection/instrumentation.ts +11 -2
  418. package/src/services/tx_collection/proposal_tx_collector.ts +112 -0
  419. package/src/services/tx_collection/slow_tx_collection.ts +57 -28
  420. package/src/services/tx_collection/tx_collection.ts +86 -20
  421. package/src/services/tx_collection/tx_collection_sink.ts +17 -7
  422. package/src/services/tx_file_store/config.ts +37 -0
  423. package/src/services/tx_file_store/index.ts +3 -0
  424. package/src/services/tx_file_store/instrumentation.ts +36 -0
  425. package/src/services/tx_file_store/tx_file_store.ts +173 -0
  426. package/src/services/tx_provider.ts +10 -9
  427. package/src/services/tx_provider_instrumentation.ts +11 -5
  428. package/src/test-helpers/index.ts +2 -0
  429. package/src/test-helpers/make-test-p2p-clients.ts +3 -3
  430. package/src/test-helpers/mock-pubsub.ts +133 -3
  431. package/src/test-helpers/reqresp-nodes.ts +2 -1
  432. package/src/test-helpers/test_tx_provider.ts +64 -0
  433. package/src/test-helpers/testbench-utils.ts +422 -0
  434. package/src/testbench/p2p_client_testbench_worker.ts +322 -127
  435. package/src/testbench/worker_client_manager.ts +304 -47
  436. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +0 -40
  437. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +0 -1
  438. package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +0 -218
  439. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -31
  440. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +0 -1
  441. package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +0 -180
  442. package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -320
  443. package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -264
@@ -0,0 +1,626 @@
1
+ # Gossipsub Peer Scoring
2
+
3
+ This module configures gossipsub peer scoring parameters for the Aztec P2P network. Peer scoring helps maintain network health by rewarding well-behaving peers and penalizing misbehaving ones.
4
+
5
+ ## Overview
6
+
7
+ Gossipsub v1.1 introduces peer scoring to defend against various attacks and improve message propagation. Each peer accumulates a score based on their behavior, and peers with low scores may be pruned from the mesh or even disconnected.
8
+
9
+ For the full specification, see: https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md#peer-scoring
10
+
11
+ ## Scoring Parameters
12
+
13
+ The peer score is computed as a weighted sum of topic-specific and application-specific scores:
14
+
15
+ ```
16
+ Score = TopicScore + AppSpecificScore + IPColocationPenalty + BehaviorPenalty
17
+ ```
18
+
19
+ ### Topic-Specific Parameters (P1-P4)
20
+
21
+ Each topic has its own scoring parameters:
22
+
23
+ | Parameter | Type | Description |
24
+ |-----------|------|-------------|
25
+ | **P1: timeInMesh** | Positive | Rewards peers for time spent in the mesh |
26
+ | **P2: firstMessageDeliveries** | Positive | Rewards peers who deliver messages first |
27
+ | **P3: meshMessageDeliveries** | Negative | Penalizes peers who under-deliver messages |
28
+ | **P3b: meshFailurePenalty** | Negative | Sticky penalty applied when pruned from mesh |
29
+ | **P4: invalidMessageDeliveries** | Negative | Penalizes peers who deliver invalid messages |
30
+
31
+ ### Our Configuration
32
+
33
+ We configure all parameters (P1-P4) with values calculated dynamically from network configuration:
34
+
35
+ | Parameter | Max Score | Configuration |
36
+ |-----------|-----------|---------------|
37
+ | P1: timeInMesh | +8 per topic | Slot-based, caps at 1 hour |
38
+ | P2: firstMessageDeliveries | +25 per topic | Convergence-based, fast decay |
39
+ | P3: meshMessageDeliveries | -34 per topic | Must exceed P1+P2 for pruning |
40
+ | P3b: meshFailurePenalty | -34 per topic | Sticky penalty after pruning |
41
+ | P4: invalidMessageDeliveries | -20 per message | Attack detection |
42
+
43
+ **Important:** P1 and P2 are only enabled on topics with P3 enabled (block_proposal, checkpoint_proposal, checkpoint_attestation). The tx topic has all scoring disabled except P4, to prevent free positive score accumulation that would offset penalties from other topics.
44
+
45
+ ## Exponential Decay
46
+
47
+ All counters in gossipsub use exponential decay. Each heartbeat (default: 700ms), counters are multiplied by a decay factor:
48
+
49
+ ```
50
+ counter = counter * decay
51
+ ```
52
+
53
+ ### Multi-Slot Decay Windows
54
+
55
+ For low-frequency topics (like 1 message per 72-second slot), naive decay would cause counters to drop to near-zero before the next message arrives. Instead, we use **multi-slot decay windows**:
56
+
57
+ | Frequency | Decay Window |
58
+ |-----------|--------------|
59
+ | <= 1 msg/slot | 5 slots |
60
+ | 2-10 msg/slot | 3 slots |
61
+ | > 10 msg/slot | 2 slots |
62
+
63
+ ### Decay Factor Calculation
64
+
65
+ To decay to 1% of the original value over the decay window:
66
+
67
+ ```typescript
68
+ heartbeatsPerSlot = slotDurationMs / heartbeatIntervalMs
69
+ heartbeatsInWindow = heartbeatsPerSlot * decayWindowSlots
70
+ decay = 0.01 ^ (1 / heartbeatsInWindow)
71
+ ```
72
+
73
+ **Example** (72s slot, 700ms heartbeat, 5-slot decay window):
74
+ ```
75
+ heartbeatsPerSlot = 72000 / 700 ≈ 103
76
+ heartbeatsInWindow = 103 * 5 = 515
77
+ decay = 0.01^(1/515) ≈ 0.991
78
+ ```
79
+
80
+ ## Convergence and Thresholds
81
+
82
+ ### Convergence (Steady-State Value)
83
+
84
+ If messages arrive at a constant rate, the decaying counter converges to:
85
+
86
+ ```typescript
87
+ messagesPerHeartbeat = expectedPerSlot * (heartbeatMs / slotDurationMs)
88
+ convergence = messagesPerHeartbeat / (1 - decay)
89
+ ```
90
+
91
+ ### Threshold Calculation
92
+
93
+ The P3 threshold determines when penalties apply. We use a conservative threshold at 30% of convergence to avoid penalizing honest peers experiencing normal variance:
94
+
95
+ ```typescript
96
+ threshold = convergence * 0.3
97
+ ```
98
+
99
+ ## meshMessageDeliveriesWindow
100
+
101
+ This parameter determines how long after validating a message other peers can still receive credit for delivering it.
102
+
103
+ **How it works:**
104
+ 1. Peer A delivers a message first
105
+ 2. We validate the message
106
+ 3. Timer starts for `meshMessageDeliveriesWindow` duration (5 seconds)
107
+ 4. Any mesh peer delivering within this window gets credit
108
+
109
+ **Why 5 seconds?**
110
+
111
+ The [gossipsub v1.1 spec](https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md) recommends this window be "small (in the order of milliseconds)" to prevent peers from gaming P3 scores by simply replaying messages back. A peer can echo a message within ~100ms, so a large window allows score inflation.
112
+
113
+ However, real-world implementations use significantly larger values due to practical constraints:
114
+ - **Prysm** (Go): 2 seconds - the go-libp2p default for low-latency Go runtime
115
+ - **Lodestar** (TypeScript): 12 seconds - accounts for JavaScript I/O lag
116
+ - **Ethereum spec proposal**: 400ms was proposed but rejected as "too tight"
117
+
118
+ We use **5 seconds** as a balanced middle ground because:
119
+ 1. **Runtime considerations**: Our implementation is TypeScript (like Lodestar), not Go (like Prysm). JavaScript has higher I/O latency due to single-threaded event loop and garbage collection pauses.
120
+ 2. **Network variance**: Even on healthy networks, message propagation can vary due to:
121
+ - Concurrent validation of multiple messages
122
+ - CPU-intensive proof verification
123
+ - Network congestion during high transaction volume
124
+ - Geographic distribution of validators
125
+ 3. **Conservative but not excessive**: 5s is 2.5× the Go default (allowing for JS overhead) but still well below Lodestar's 12s, maintaining reasonable protection against replay attacks.
126
+ 4. **Attack mitigation**: A 5s window still prevents score gaming - peers would need to consistently echo messages within 5s to maintain positive P3 scores, which requires them to stay connected and somewhat functional.
127
+
128
+ ## meshMessageDeliveriesActivation
129
+
130
+ This is the grace period before P3 penalties can be applied to a peer. During this time, the message delivery counter accumulates without any penalty.
131
+
132
+ **Why activation is 5× the decay window:**
133
+
134
+ We set activation time to **5× the decay window** (10-25 slots depending on topic frequency) because:
135
+
136
+ 1. **Timer starts at mesh join, not first message**: The activation countdown begins when a peer joins the mesh, not when they receive their first message. During network bootstrap, peers may join before any messages are flowing.
137
+
138
+ 2. **Bootstrap grace period**: When the network is starting up, message flow may be delayed. Peers need time for the network to stabilize and messages to start propagating.
139
+
140
+ 3. **Counter convergence**: The threshold is set at 30% of the *converged* counter value. If activation is too short, the counter hasn't approached convergence yet, and honest peers could be penalized unfairly.
141
+
142
+ 4. **Join timing variance**: Peers may join at any point during a slot. With longer activation time, even peers joining at an unlucky time will have accumulated enough messages before penalties start.
143
+
144
+ 5. **Ethereum precedent**: Ethereum's Lodestar implementation uses very long activation times (1-2 epochs ≈ 16-32 slots) for similar reasons.
145
+
146
+ | Topic | Decay Window | Activation Time (5×) |
147
+ |-------|--------------|----------------------|
148
+ | checkpoint_proposal | 5 slots (360s) | 25 slots (1800s / 30min) |
149
+ | block_proposal | 3 slots (216s) | 15 slots (1080s / 18min) |
150
+ | checkpoint_attestation | 2 slots (144s) | 10 slots (720s / 12min) |
151
+
152
+ ## P1: Time in Mesh (Positive Score)
153
+
154
+ P1 rewards peers for time spent in the mesh. We use Lodestar-style slot-based normalization:
155
+
156
+ ```typescript
157
+ timeInMeshQuantum = slotDurationMs // Score increases by ~1 per slot
158
+ timeInMeshCap = 3600 / slotDurationSeconds // Cap at 1 hour (50 slots for 72s slots)
159
+ timeInMeshWeight = MAX_P1_SCORE / cap // Normalized so max P1 = 8
160
+ ```
161
+
162
+ **Key properties:**
163
+ - Score increases gradually: ~1 per slot of mesh membership
164
+ - Caps at 1 hour: prevents runaway positive scores
165
+ - Resets on mesh leave: no credit carried after pruning
166
+
167
+ **Example (72s slots):**
168
+ - After 10 minutes in mesh: P1 ≈ 1.3
169
+ - After 30 minutes in mesh: P1 ≈ 4
170
+ - After 1 hour in mesh: P1 = 8 (max)
171
+
172
+ ## P2: First Message Deliveries (Positive Score)
173
+
174
+ P2 rewards peers who deliver messages first to us. We use convergence-based normalization:
175
+
176
+ ```typescript
177
+ firstMessageDeliveriesDecay = computeDecay(2 slots) // Fast decay
178
+ firstMessageDeliveriesCap = convergence(1 msg/heartbeat)
179
+ firstMessageDeliveriesWeight = MAX_P2_SCORE / cap // Normalized so max P2 = 25
180
+ ```
181
+
182
+ **Key properties:**
183
+ - Fast decay (2 slots): rewards recent behavior, not historical
184
+ - Caps at convergence: prevents score inflation from bursts
185
+ - Resets quickly after mesh leave: decays to near-zero over ~2 slots (e.g., ~144s with 72s slots)
186
+
187
+ ## P3 Weight Formula
188
+
189
+ The P3 weight is calculated to ensure the max penalty equals `MAX_P3_PENALTY_PER_TOPIC` (-34):
190
+
191
+ ```typescript
192
+ // Weight formula: max_penalty / threshold²
193
+ meshMessageDeliveriesWeight = MAX_P3_PENALTY_PER_TOPIC / (threshold * threshold)
194
+
195
+ // When peer delivers nothing (deficit = threshold):
196
+ // penalty = deficit² × weight = threshold² × (-34 / threshold²) = -34
197
+ ```
198
+
199
+ This ensures P3 max penalty (-34) exceeds P1 + P2 max (+33), causing mesh pruning.
200
+
201
+ ## Per-Topic Configuration
202
+
203
+ ### Topic Types and Expected Rates
204
+
205
+ | Topic | Expected/Slot | Decay Window | Notes |
206
+ |-------|--------------|--------------|-------|
207
+ | `tx` | Unpredictable | N/A | P3/P3b disabled |
208
+ | `block_proposal` | N-1 | 3 slots | N = blocks per slot (MBPS mode) |
209
+ | `checkpoint_proposal` | 1 | 5 slots | One per slot |
210
+ | `checkpoint_attestation` | C (~48) | 2 slots | C = committee size |
211
+
212
+ ### Transactions (tx)
213
+
214
+ Transactions are submitted unpredictably by users, so we cannot set meaningful delivery thresholds. **All scoring (P1, P2, P3, P3b) is disabled** for this topic except P4 (invalid message detection).
215
+
216
+ **Rationale:** If P1/P2 were enabled without P3, the tx topic would contribute free positive scores that could offset penalties from other topics, preventing proper mesh pruning of non-contributing peers.
217
+
218
+ ### Block Proposals (block_proposal)
219
+
220
+ In Multi-Block-Per-Slot (MBPS) mode, N-1 block proposals are gossiped per slot (the last block is bundled with the checkpoint). In single-block mode, this is 0.
221
+
222
+ ### Checkpoint Proposals (checkpoint_proposal)
223
+
224
+ Exactly one checkpoint proposal per slot, containing the final block and proof commitments.
225
+
226
+ ### Checkpoint Attestations (checkpoint_attestation)
227
+
228
+ Each committee member sends one attestation per slot. With a target committee size of 48, we expect ~48 attestations per slot.
229
+
230
+ ### Topic Weights
231
+
232
+ All topics use equal weight (1). Block proposals contain transaction hashes, so transactions must propagate for block proposals to validate - making all message types equally important for network health.
233
+
234
+ ## Configuration Dependencies
235
+
236
+ The scoring parameters depend on:
237
+
238
+ | Parameter | Source | Default |
239
+ |-----------|--------|---------|
240
+ | `slotDuration` | L1RollupConstants | 72s |
241
+ | `targetCommitteeSize` | L1RollupConstants | 48 |
242
+ | `heartbeatInterval` | P2PConfig.gossipsubInterval | 700ms |
243
+ | `blockDurationMs` | P2PConfig.blockDurationMs | undefined (single block) |
244
+
245
+ ## Invalid Message Handling (P4)
246
+
247
+ P4 penalizes peers who deliver invalid messages. All topics have this enabled with:
248
+ - Weight: -20
249
+ - Decay: Over 4 slots
250
+
251
+ Invalid messages include malformed data, invalid signatures, or messages failing validation.
252
+
253
+ ## Tuning Guidelines
254
+
255
+ ### Signs of Too-Strict Scoring
256
+
257
+ - Honest peers frequently pruned from mesh
258
+ - High peer churn
259
+ - Slow message propagation despite good network
260
+
261
+ **Solution:** Increase thresholds, use longer decay windows
262
+
263
+ ### Signs of Too-Lenient Scoring
264
+
265
+ - Slow or stalled message propagation
266
+ - Bad peers remaining in mesh too long
267
+ - Network vulnerable to eclipse attacks
268
+
269
+ **Solution:** Decrease thresholds, use shorter decay windows
270
+
271
+ ### Monitoring
272
+
273
+ Key metrics to monitor:
274
+ - Peer scores distribution
275
+ - P3 penalty frequency per topic
276
+ - Invalid message rate per peer
277
+ - Mesh membership stability
278
+
279
+ ## Code Structure
280
+
281
+ - `scoring.ts` - Global peer score thresholds
282
+ - `topic_score_params.ts` - Per-topic parameter calculation
283
+ - `index.ts` - Module exports
284
+
285
+ ## Global Score Thresholds
286
+
287
+ Gossipsub uses global thresholds to determine peer behavior based on total score:
288
+
289
+ | Threshold | Value | Effect |
290
+ |-----------|-------|--------|
291
+ | gossipThreshold | -500 | Below this, peer doesn't receive gossip |
292
+ | publishThreshold | -1000 | Below this, peer's messages aren't relayed |
293
+ | graylistThreshold | -2000 | Below this, all RPCs from peer are ignored |
294
+
295
+ ### Alignment with Application-Level Scoring
296
+
297
+ The thresholds are designed to align with Aztec's application-level peer scoring:
298
+
299
+ ```
300
+ Total Gossipsub Score = TopicScore + (AppScore × AppSpecificWeight)
301
+ ```
302
+
303
+ With `appSpecificWeight = 10` (topic score assumed ~0):
304
+
305
+ | App Score State | App Score | Gossipsub Contribution | Threshold Triggered |
306
+ |-----------------|-----------|------------------------|---------------------|
307
+ | Healthy | 0 to -49 | 0 to -490 | None |
308
+ | Disconnect | -50 | -500 | gossipThreshold |
309
+ | Ban | -100 | -1000 | publishThreshold |
310
+
311
+ This means (best-effort alignment):
312
+ - When a peer reaches **Disconnect** state, they generally stop receiving gossip
313
+ - When a peer reaches **Ban** state, their messages are generally not relayed
314
+ - **Graylist** requires ban-level score PLUS significant topic penalties (attacks)
315
+
316
+ **Important:** Positive topic scores (P1/P2) can temporarily offset app penalties, so alignment is not strict.
317
+ Conversely, if topic scores are low, a peer slightly above the disconnect threshold may still dip below `gossipThreshold`. This is acceptable and tends to recover quickly as topic scores accumulate.
318
+
319
+ ### Topic Score Contribution
320
+
321
+ Topic scores provide **burst response** to attacks, while app score provides **stable baseline**:
322
+
323
+ - P1 (time in mesh): Max +8 per topic (+24 across 3 topics)
324
+ - P2 (first deliveries): Max +25 per topic (+75 across 3 topics, but decays fast)
325
+ - P3 (under-delivery): Max -34 per topic (-102 across 3 topics in MBPS; -68 in single-block mode)
326
+ - P4 (invalid messages): -20 per invalid message, can spike to -2000+ during attacks
327
+
328
+ Example attack scenario:
329
+ - App score: -100 (banned) → -1000 gossipsub
330
+ - P4 burst (10 invalid messages): -2000 per topic
331
+ - **Total: -3000+** → Triggers graylistThreshold
332
+
333
+ The P4 penalty decays to 1% over 4 slots (~5 minutes), allowing recovery if the attack stops.
334
+
335
+ ## Non-Contributing Peers
336
+
337
+ ### How P3 Handles Under-Delivery
338
+
339
+ The P3 (meshMessageDeliveries) penalty applies when a peer's message delivery counter falls below the threshold. The penalty formula is:
340
+
341
+ ```
342
+ deficit = max(0, threshold - counter)
343
+ penalty = deficit² × weight
344
+ ```
345
+
346
+ Where `weight = MAX_P3_PENALTY_PER_TOPIC / (threshold × threshold)`. This design ensures:
347
+
348
+ ```
349
+ If counter = 0 (delivers nothing):
350
+ deficit = threshold
351
+ penalty = threshold² × (-34/threshold²) = -34 per topic
352
+ ```
353
+
354
+ ### Score Balance for Mesh Pruning
355
+
356
+ For a peer to be pruned from the mesh, their **topic score** must be negative. We balance P1/P2/P3 so that non-contributors get pruned:
357
+
358
+ | Scenario | P1 | P2 | P3 | Topic Score | Result |
359
+ |----------|----|----|-----|-------------|--------|
360
+ | Healthy peer (delivering) | +8 | +25 | 0 | +33 | In mesh |
361
+ | New peer (just joined) | +1 | +5 | 0 | +6 | In mesh |
362
+ | Non-contributor (1 hour in mesh) | +8 | 0 | -34 | **-26** | **Pruned** |
363
+ | Non-contributor (new) | +1 | 0 | -34 | **-33** | **Pruned** |
364
+
365
+ The key insight: **P3 max (-34) exceeds P1 + P2 max (+33)**, so even a peer that has been in the mesh for 1 hour will still be pruned if they stop delivering messages.
366
+
367
+ ### What Happens After Pruning
368
+
369
+ When a peer is pruned from the mesh:
370
+
371
+ 1. **P1 resets to 0**: The timeInMesh counter is cleared
372
+ 2. **P2 decays to 0**: Fast decay (2-slot window) makes it negligible over minutes
373
+ 3. **P3b captures the penalty**: The P3 deficit at prune time becomes P3b, which decays slowly
374
+
375
+ After pruning, the peer's score consists mainly of P3b:
376
+ - **Total P3b across 3 topics: -102** (max)
377
+ - **Recovery time**: P3b decays to ~1% over one decay window (2-5 slots = 2-6 minutes)
378
+ - **Grafting eligibility**: Peer can be grafted when score ≥ 0, but asymptotic decay means recovery is slow
379
+
380
+ ### Why Non-Contributors Aren't Disconnected
381
+
382
+ With P3b capped at -102 total after pruning (MBPS mode). In single-block mode, the cap is -68:
383
+
384
+ | Threshold | Value | P3b Score | Triggered? |
385
+ |-----------|-------|-----------|------------|
386
+ | gossipThreshold | -500 | -102 (MBPS) / -68 (single) | No |
387
+ | publishThreshold | -1000 | -102 (MBPS) / -68 (single) | No |
388
+ | graylistThreshold | -2000 | -102 (MBPS) / -68 (single) | No |
389
+
390
+ **A score of -102 (MBPS) or -68 (single-block) is well above -500**, so non-contributing peers:
391
+ - Are pruned from mesh (good - stops them slowing propagation)
392
+ - Still receive gossip (can recover by reconnecting/restarting)
393
+ - Are NOT disconnected unless they also have application-level penalties
394
+
395
+ ### Design Philosophy
396
+
397
+ The system distinguishes between:
398
+
399
+ | Peer Type | Score Range | Effect |
400
+ |-----------|-------------|--------|
401
+ | **Productive** | ≥ 0 | Full mesh participation |
402
+ | **Unproductive** | -1 to -499 | Pruned from mesh, still receives gossip |
403
+ | **Misbehaving** | -500 to -999 | Stops receiving gossip (app: Disconnect) |
404
+ | **Malicious** | -1000 to -1999 | Cannot publish (app: Banned) |
405
+ | **Attacking** | ≤ -2000 | Graylisted, all RPCs ignored |
406
+
407
+ Note: These ranges are approximate; positive topic scores can shift a peer upward temporarily.
408
+
409
+ This is similar to Ethereum's approach: non-contributing peers are removed from the mesh (preventing them from slowing propagation) but not disconnected, as they might be starting up or experiencing temporary connectivity issues.
410
+
411
+ ### When Non-Contributors ARE Penalized
412
+
413
+ Non-contributors will trigger thresholds if they also:
414
+ 1. **Send invalid messages**: P4 penalty of -20 per invalid message accumulates quickly
415
+ 2. **Fail protocol validation**: Application penalties for deserialization errors, manipulation attempts
416
+ 3. **Violate rate limits**: Repeated per-peer limit hits accumulate application penalties
417
+
418
+ ## Application-Level Penalties
419
+
420
+ Beyond gossipsub's topic scoring, Aztec has application-level penalties for protocol violations:
421
+
422
+ ### Penalty Severities
423
+
424
+ | Severity | Points | Errors to Disconnect | Errors to Ban |
425
+ |----------|--------|----------------------|---------------|
426
+ | **HighToleranceError** | 2 | 25 | 50 |
427
+ | **MidToleranceError** | 10 | 5 | 10 |
428
+ | **LowToleranceError** | 50 | 1 | 2 |
429
+
430
+ ### What Triggers Each Severity
431
+
432
+ **HighToleranceError (2 points)** - Transient issues:
433
+ - Rate limit exceeded
434
+ - Failed responses (FAILURE/UNKNOWN status)
435
+ - Recent double spend attempts (within penalty window)
436
+
437
+ **MidToleranceError (10 points)** - Protocol violations:
438
+ - Block/checkpoint exceeds per-slot cap
439
+ - Response hash mismatches
440
+ - Duplicate transactions in response
441
+ - Unrequested transactions in response
442
+
443
+ **LowToleranceError (50 points)** - Serious violations:
444
+ - Message deserialization errors
445
+ - Invalid message manipulation attempts
446
+ - Block number/order mismatches
447
+ - Invalid transactions
448
+ - Badly formed requests
449
+ - Confirmed double spends
450
+
451
+ ### Score Decay
452
+
453
+ Application scores decay by 10% per minute (`decayFactor = 0.9`):
454
+ - Score -100 → -90 after 1 minute
455
+ - Score -100 → -35 after 10 minutes
456
+ - Score -100 → -12 after 20 minutes
457
+
458
+ This allows honest peers to recover from temporary issues.
459
+
460
+ ## Score Calculation Examples
461
+
462
+ ### Example 1: Honest Peer
463
+
464
+ ```
465
+ App score: 0
466
+ Topic P3: 0 (delivering messages)
467
+ Topic P4: 0 (no invalid messages)
468
+ ─────────────────────────────────
469
+ Total: 0 → Full participation ✓
470
+ ```
471
+
472
+ ### Example 2: Peer with Rate Limit Issues
473
+
474
+ ```
475
+ App score: -20 (10 HighToleranceErrors)
476
+ → Gossipsub contribution: -200
477
+ Topic P3: -1 (slightly under-delivering)
478
+ Topic P4: 0
479
+ ─────────────────────────────────
480
+ Total: -201 → Still receives gossip ✓
481
+ ```
482
+
483
+ ### Example 3: Validation Failure
484
+
485
+ ```
486
+ App score: -50 (1 LowToleranceError for invalid message)
487
+ → Gossipsub contribution: -500
488
+ Topic P3: 0
489
+ Topic P4: -20 (the invalid message)
490
+ ─────────────────────────────────
491
+ Total: -520 → Stops receiving gossip (gossipThreshold = -500)
492
+ → Application disconnects peer
493
+ ```
494
+
495
+ ### Example 4: Banned Peer
496
+
497
+ ```
498
+ App score: -100 (2 LowToleranceErrors)
499
+ → Gossipsub contribution: -1000
500
+ Topic P3: -2
501
+ Topic P4: -40 (2 invalid messages)
502
+ ─────────────────────────────────
503
+ Total: -1042 → Cannot publish (publishThreshold = -1000)
504
+ → Application bans peer
505
+ ```
506
+
507
+ ### Example 5: Active Attack (Burst of Invalid Messages)
508
+
509
+ ```
510
+ App score: -100 (banned)
511
+ → Gossipsub contribution: -1000
512
+ Topic P3: -3
513
+ Topic P4: -200 (10 invalid messages: 10 × -20)
514
+ ─────────────────────────────────
515
+ Total: -1203 → Cannot publish (publishThreshold = -1000)
516
+
517
+ If the attacker sends 100 invalid messages quickly:
518
+
519
+ Topic P4: -2000 (100 invalid messages: 100 × -20)
520
+ ─────────────────────────────────
521
+ Total: -3003 → Graylisted (graylistThreshold = -2000)
522
+ → All RPCs ignored
523
+ ```
524
+
525
+ ### Example 6: Recovery After Attack
526
+
527
+ ```
528
+ Initial state: Total score -3003
529
+
530
+ After 4 slots (~5 min):
531
+ P4 decays to 1%: -2000 → -20
532
+ App score unchanged: -1000
533
+ Total: -1023 → Still banned, but no longer graylisted
534
+
535
+ After 10 min:
536
+ App score decays: -100 → -35 → -350 contribution
537
+ P4 further decayed: ~-5
538
+ Total: -358 → Above gossipThreshold, starting to recover
539
+ ```
540
+
541
+ ## Network Outage Analysis
542
+
543
+ What happens when a peer experiences a network outage and stops delivering messages?
544
+
545
+ ### During the Outage
546
+
547
+ While the peer is disconnected:
548
+
549
+ 1. **P3 penalty accumulates**: The message delivery counter decays toward 0, causing increasing P3 penalty
550
+ 2. **Max P3 penalty reached**: Once counter drops below threshold, penalty hits -34 per topic (-102 total in MBPS; -68 single-block)
551
+ 3. **Mesh pruning**: Topic score goes negative → peer is pruned from mesh
552
+ 4. **P3b captures penalty**: The P3 deficit at prune time becomes P3b (sticky penalty)
553
+
554
+ ### Outage Timeline
555
+
556
+ | Time | Event | Score Impact |
557
+ |------|-------|--------------|
558
+ | 0s | Outage begins | P3 = 0 |
559
+ | ~1 decay window (2-5 slots) | Counter decays below threshold | P3 starts decreasing |
560
+ | ~1-2 decay windows | Counter approaches 0 | P3 ≈ -34 per topic |
561
+ | ~1-2 decay windows | Peer pruned from mesh | P3b ≈ -34 per topic |
562
+ | Thereafter | P3b decays slowly | Recovery begins |
563
+
564
+ Note: If the peer just joined the mesh, P3 penalties only start after
565
+ `meshMessageDeliveriesActivation` (10-25 slots depending on topic frequency).
566
+
567
+ ### Key Insight: No Application Penalties
568
+
569
+ During a network outage, the peer:
570
+ - **Does NOT send invalid messages** → No P4 penalty
571
+ - **Does NOT violate protocols** → No application-level penalty
572
+ - **Only accumulates topic-level penalties** → Max -102 (P3b, MBPS) or -68 (single-block)
573
+
574
+ This is the crucial difference from malicious behavior:
575
+
576
+ | Scenario | App Score | Topic Score | Total | Threshold Hit |
577
+ |----------|-----------|-------------|-------|---------------|
578
+ | Network outage | 0 | -102 (MBPS) / -68 (single) | -102 / -68 | None |
579
+ | Validation failure | -50 | -20 | -520 | gossipThreshold |
580
+ | Malicious peer | -100 | -2000+ | -2100+ | graylistThreshold |
581
+
582
+ ### Recovery After Outage
583
+
584
+ When the peer reconnects:
585
+
586
+ 1. **Peer re-joins mesh**: Can request graft (topic score must be > 0 for acceptance)
587
+ 2. **P3b decays**: To ~1% over decay window (2-5 slots depending on topic)
588
+ 3. **P1 restarts from 0**: timeInMesh counter begins accumulating
589
+ 4. **P2 restarts from 0**: firstMessageDeliveries counter begins accumulating
590
+
591
+ **Recovery timeline:**
592
+ - Immediate: Peer can attempt to re-graft
593
+ - ~3-5 minutes: P3b decays to near-zero
594
+ - ~10+ minutes: P1 builds up again (if staying in mesh)
595
+
596
+ ### Why This Design Works
597
+
598
+ The system correctly distinguishes between:
599
+
600
+ | Behavior | Treatment |
601
+ |----------|-----------|
602
+ | **Network issues** | Pruned from mesh (stops slowing propagation), can recover quickly |
603
+ | **Protocol violations** | Disconnected (gossipThreshold), must wait for app score decay |
604
+ | **Malicious activity** | Banned/graylisted, requires both app and topic score decay |
605
+
606
+ A peer experiencing network problems will:
607
+ - Be temporarily removed from mesh propagation (good for network health)
608
+ - NOT be disconnected or banned (they haven't misbehaved)
609
+ - Recover automatically when connectivity returns
610
+ - Retain their connections for recovery
611
+
612
+ This matches Ethereum's approach: **honest peers with temporary issues are inconvenienced but not punished**.
613
+
614
+ ### Rate Limiting During Outages
615
+
616
+ Note: Simply not sending messages does NOT trigger rate limit penalties. Rate limits apply to:
617
+ - **Per-peer rate limit exceeded** → HighToleranceError (2 points)
618
+ - **Other protocol violations** → MidToleranceError or LowToleranceError depending on severity
619
+
620
+ A peer that sends nothing receives no rate limit penalties. The only penalty for not delivering messages is P3, which is explicitly designed to be recoverable.
621
+
622
+ ## References
623
+
624
+ - [Gossipsub v1.1 Specification](https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md)
625
+ - [Lighthouse Scoring Implementation](https://github.com/sigp/lighthouse/blob/stable/beacon_node/lighthouse_network/src/peer_manager/score.rs)
626
+ - [Lodestar Scoring Implementation](https://github.com/ChainSafe/lodestar/tree/unstable/packages/beacon-node/src/network/gossip)
@@ -0,0 +1,2 @@
1
+ export * from './scoring.js';
2
+ export * from './topic_score_params.js';
@@ -1,13 +1,37 @@
1
1
  import type { PeerScoreThresholds } from '@chainsafe/libp2p-gossipsub/score';
2
2
 
3
3
  /**
4
- * The following params is implemented by Lighthouse at
5
- * https://github.com/sigp/lighthouse/blob/b0ac3464ca5fb1e9d75060b56c83bfaf990a3d25/beacon_node/eth2_libp2p/src/behaviour/gossipsub_scoring_parameters.rs#L83
4
+ * Weight applied to application-level peer scores before contributing to gossipsub score.
5
+ *
6
+ * Note: positive topic scores can partially offset app penalties, so alignment with
7
+ * app-level thresholds is best-effort rather than strict.
8
+ */
9
+ export const APP_SPECIFIC_WEIGHT = 10;
10
+
11
+ /**
12
+ * Gossipsub peer score thresholds aligned with application-level scoring.
13
+ *
14
+ * These thresholds work with appSpecificWeight=10 to align gossipsub behavior
15
+ * with application-level peer states (Healthy → Disconnect → Banned).
16
+ *
17
+ * Alignment:
18
+ * - gossipThreshold (-500): Matches Disconnect state (app score -50 × weight 10)
19
+ * - publishThreshold (-1000): Matches Ban state (app score -100 × weight 10)
20
+ * - graylistThreshold (-2000): For severe attacks (ban + topic penalties)
21
+ *
22
+ * The 1:2:4 ratio follows Lodestar's approach and gossipsub spec recommendations.
23
+ *
24
+ * @see https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md#peer-scoring
6
25
  */
7
26
  export const gossipScoreThresholds: PeerScoreThresholds = {
8
- gossipThreshold: -4000,
9
- publishThreshold: -8000,
10
- graylistThreshold: -16000,
27
+ /** Below this, peer is not gossiped to (matches Disconnect state) */
28
+ gossipThreshold: -500,
29
+ /** Below this, self-published messages are not propagated to peer (matches Ban state) */
30
+ publishThreshold: -1000,
31
+ /** Below this, all RPCs from peer are ignored (severe attack scenario) */
32
+ graylistThreshold: -2000,
33
+ /** Above this, peer can offer peer exchange (PX) */
11
34
  acceptPXThreshold: 100,
35
+ /** Above this, peer can be grafted to mesh opportunistically */
12
36
  opportunisticGraftThreshold: 5,
13
37
  };