@aztec/p2p 0.0.1-commit.993d52e → 0.0.1-commit.9a89641

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 (473) hide show
  1. package/README.md +130 -3
  2. package/dest/bootstrap/bootstrap.d.ts +1 -1
  3. package/dest/bootstrap/bootstrap.d.ts.map +1 -1
  4. package/dest/bootstrap/bootstrap.js +22 -6
  5. package/dest/client/factory.d.ts +5 -4
  6. package/dest/client/factory.d.ts.map +1 -1
  7. package/dest/client/factory.js +39 -16
  8. package/dest/client/interface.d.ts +52 -12
  9. package/dest/client/interface.d.ts.map +1 -1
  10. package/dest/client/p2p_client.d.ts +34 -19
  11. package/dest/client/p2p_client.d.ts.map +1 -1
  12. package/dest/client/p2p_client.js +120 -73
  13. package/dest/config.d.ts +160 -110
  14. package/dest/config.d.ts.map +1 -1
  15. package/dest/config.js +139 -49
  16. package/dest/errors/p2p-service.error.d.ts +9 -0
  17. package/dest/errors/p2p-service.error.d.ts.map +1 -0
  18. package/dest/errors/p2p-service.error.js +10 -0
  19. package/dest/errors/reqresp.error.d.ts +9 -16
  20. package/dest/errors/reqresp.error.d.ts.map +1 -1
  21. package/dest/errors/reqresp.error.js +10 -17
  22. package/dest/index.d.ts +1 -2
  23. package/dest/index.d.ts.map +1 -1
  24. package/dest/index.js +0 -1
  25. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +101 -59
  26. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  27. package/dest/mem_pools/attestation_pool/attestation_pool.js +274 -197
  28. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +1 -1
  29. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
  30. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +224 -65
  31. package/dest/mem_pools/attestation_pool/mocks.d.ts +1 -1
  32. package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
  33. package/dest/mem_pools/attestation_pool/mocks.js +6 -4
  34. package/dest/mem_pools/index.d.ts +1 -2
  35. package/dest/mem_pools/index.d.ts.map +1 -1
  36. package/dest/mem_pools/instrumentation.d.ts +12 -5
  37. package/dest/mem_pools/instrumentation.d.ts.map +1 -1
  38. package/dest/mem_pools/instrumentation.js +38 -17
  39. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +1 -5
  40. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -1
  41. package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +1 -7
  42. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +3 -3
  43. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -1
  44. package/dest/mem_pools/tx_pool_v2/deleted_pool.js +6 -6
  45. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
  46. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
  47. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +5 -4
  48. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +1 -1
  49. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -1
  50. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +3 -1
  51. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +2 -1
  52. package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -1
  53. package/dest/mem_pools/tx_pool_v2/eviction/index.js +1 -0
  54. package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.d.ts +16 -0
  55. package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.d.ts.map +1 -0
  56. package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.js +64 -0
  57. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +1 -1
  58. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -1
  59. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +3 -4
  60. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +1 -1
  61. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -1
  62. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +6 -7
  63. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +1 -1
  64. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -1
  65. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +6 -5
  66. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +41 -9
  67. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
  68. package/dest/mem_pools/tx_pool_v2/interfaces.js +3 -1
  69. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +17 -8
  70. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
  71. package/dest/mem_pools/tx_pool_v2/tx_metadata.js +20 -7
  72. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +15 -1
  73. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -1
  74. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +55 -41
  75. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +12 -4
  76. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
  77. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +23 -6
  78. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +17 -3
  79. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
  80. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +234 -120
  81. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +10 -3
  82. package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
  83. package/dest/msg_validators/attestation_validator/attestation_validator.js +38 -15
  84. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +7 -3
  85. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
  86. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +4 -5
  87. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +11 -5
  88. package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
  89. package/dest/msg_validators/proposal_validator/block_proposal_validator.js +11 -3
  90. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +11 -5
  91. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
  92. package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +23 -3
  93. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +35 -10
  94. package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
  95. package/dest/msg_validators/proposal_validator/proposal_validator.js +128 -56
  96. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +1 -1
  97. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
  98. package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +8 -15
  99. package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +2 -1
  100. package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -1
  101. package/dest/msg_validators/tx_validator/allowed_public_setup.js +25 -21
  102. package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts +17 -0
  103. package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts.map +1 -0
  104. package/dest/msg_validators/tx_validator/allowed_setup_helpers.js +24 -0
  105. package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
  106. package/dest/msg_validators/tx_validator/cached_tx_validator.d.ts +15 -0
  107. package/dest/msg_validators/tx_validator/cached_tx_validator.d.ts.map +1 -0
  108. package/dest/msg_validators/tx_validator/cached_tx_validator.js +19 -0
  109. package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts +9 -0
  110. package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts.map +1 -0
  111. package/dest/msg_validators/tx_validator/contract_instance_validator.js +48 -0
  112. package/dest/msg_validators/tx_validator/data_validator.d.ts +2 -1
  113. package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
  114. package/dest/msg_validators/tx_validator/data_validator.js +36 -2
  115. package/dest/msg_validators/tx_validator/factory.d.ts +25 -7
  116. package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
  117. package/dest/msg_validators/tx_validator/factory.js +55 -16
  118. package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts +1 -1
  119. package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts.map +1 -1
  120. package/dest/msg_validators/tx_validator/fee_payer_balance.js +6 -2
  121. package/dest/msg_validators/tx_validator/gas_validator.d.ts +53 -7
  122. package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
  123. package/dest/msg_validators/tx_validator/gas_validator.js +88 -41
  124. package/dest/msg_validators/tx_validator/index.d.ts +4 -1
  125. package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
  126. package/dest/msg_validators/tx_validator/index.js +3 -0
  127. package/dest/msg_validators/tx_validator/metadata_validator.d.ts +1 -1
  128. package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
  129. package/dest/msg_validators/tx_validator/metadata_validator.js +4 -4
  130. package/dest/msg_validators/tx_validator/phases_validator.d.ts +22 -2
  131. package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
  132. package/dest/msg_validators/tx_validator/phases_validator.js +72 -24
  133. package/dest/msg_validators/tx_validator/timestamp_validator.js +1 -1
  134. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +2 -1
  135. package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
  136. package/dest/msg_validators/tx_validator/tx_proof_validator.js +2 -0
  137. package/dest/msg_validators/tx_validator/tx_validation_cache.d.ts +48 -0
  138. package/dest/msg_validators/tx_validator/tx_validation_cache.d.ts.map +1 -0
  139. package/dest/msg_validators/tx_validator/tx_validation_cache.js +68 -0
  140. package/dest/services/data_store.d.ts +1 -1
  141. package/dest/services/data_store.d.ts.map +1 -1
  142. package/dest/services/data_store.js +5 -5
  143. package/dest/services/discv5/discV5_service.d.ts +13 -2
  144. package/dest/services/discv5/discV5_service.d.ts.map +1 -1
  145. package/dest/services/discv5/discV5_service.js +119 -23
  146. package/dest/services/discv5/persisted_enr_store.d.ts +38 -0
  147. package/dest/services/discv5/persisted_enr_store.d.ts.map +1 -0
  148. package/dest/services/discv5/persisted_enr_store.js +145 -0
  149. package/dest/services/dummy_service.d.ts +15 -15
  150. package/dest/services/dummy_service.d.ts.map +1 -1
  151. package/dest/services/dummy_service.js +15 -16
  152. package/dest/services/encoding.d.ts +23 -6
  153. package/dest/services/encoding.d.ts.map +1 -1
  154. package/dest/services/encoding.js +32 -16
  155. package/dest/services/gossipsub/topic_score_params.d.ts +6 -12
  156. package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
  157. package/dest/services/gossipsub/topic_score_params.js +4 -14
  158. package/dest/services/libp2p/instrumentation.d.ts +3 -1
  159. package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
  160. package/dest/services/libp2p/instrumentation.js +14 -0
  161. package/dest/services/libp2p/libp2p_service.d.ts +46 -47
  162. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  163. package/dest/services/libp2p/libp2p_service.js +460 -320
  164. package/dest/services/peer-manager/metrics.d.ts +3 -1
  165. package/dest/services/peer-manager/metrics.d.ts.map +1 -1
  166. package/dest/services/peer-manager/metrics.js +6 -0
  167. package/dest/services/peer-manager/peer_manager.d.ts +20 -3
  168. package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
  169. package/dest/services/peer-manager/peer_manager.js +83 -26
  170. package/dest/services/peer-manager/peer_scoring.d.ts +34 -2
  171. package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
  172. package/dest/services/peer-manager/peer_scoring.js +102 -13
  173. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +4 -8
  174. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
  175. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +94 -122
  176. package/dest/services/reqresp/batch-tx-requester/interface.d.ts +10 -6
  177. package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
  178. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +5 -4
  179. package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
  180. package/dest/services/reqresp/batch-tx-requester/missing_txs.js +13 -7
  181. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +19 -11
  182. package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
  183. package/dest/services/reqresp/batch-tx-requester/peer_collection.js +52 -15
  184. package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts +5 -14
  185. package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts.map +1 -1
  186. package/dest/services/reqresp/batch-tx-requester/tx_validator.js +6 -20
  187. package/dest/services/reqresp/config.d.ts +15 -3
  188. package/dest/services/reqresp/config.d.ts.map +1 -1
  189. package/dest/services/reqresp/config.js +11 -0
  190. package/dest/services/reqresp/interface.d.ts +16 -18
  191. package/dest/services/reqresp/interface.d.ts.map +1 -1
  192. package/dest/services/reqresp/interface.js +10 -20
  193. package/dest/services/reqresp/metrics.d.ts +1 -1
  194. package/dest/services/reqresp/metrics.d.ts.map +1 -1
  195. package/dest/services/reqresp/metrics.js +0 -1
  196. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +4 -3
  197. package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
  198. package/dest/services/reqresp/protocols/block_txs/bitvector.js +3 -2
  199. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +1 -1
  200. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
  201. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +31 -28
  202. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +12 -7
  203. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
  204. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +42 -24
  205. package/dest/services/reqresp/protocols/index.d.ts +1 -2
  206. package/dest/services/reqresp/protocols/index.d.ts.map +1 -1
  207. package/dest/services/reqresp/protocols/index.js +0 -1
  208. package/dest/services/reqresp/protocols/tx.d.ts +1 -1
  209. package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
  210. package/dest/services/reqresp/protocols/tx.js +1 -3
  211. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +5 -4
  212. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
  213. package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -8
  214. package/dest/services/reqresp/rate-limiter/rate_limits.d.ts +1 -1
  215. package/dest/services/reqresp/rate-limiter/rate_limits.d.ts.map +1 -1
  216. package/dest/services/reqresp/rate-limiter/rate_limits.js +3 -13
  217. package/dest/services/reqresp/reqresp.d.ts +7 -29
  218. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  219. package/dest/services/reqresp/reqresp.js +75 -216
  220. package/dest/services/service.d.ts +29 -12
  221. package/dest/services/service.d.ts.map +1 -1
  222. package/dest/services/tx_collection/config.d.ts +2 -23
  223. package/dest/services/tx_collection/config.d.ts.map +1 -1
  224. package/dest/services/tx_collection/config.js +2 -55
  225. package/dest/services/tx_collection/file_store_tx_collection.d.ts +12 -28
  226. package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -1
  227. package/dest/services/tx_collection/file_store_tx_collection.js +43 -83
  228. package/dest/services/tx_collection/file_store_tx_source.d.ts +5 -4
  229. package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -1
  230. package/dest/services/tx_collection/file_store_tx_source.js +39 -29
  231. package/dest/services/tx_collection/index.d.ts +2 -3
  232. package/dest/services/tx_collection/index.d.ts.map +1 -1
  233. package/dest/services/tx_collection/index.js +0 -1
  234. package/dest/services/tx_collection/instrumentation.d.ts +1 -1
  235. package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
  236. package/dest/services/tx_collection/instrumentation.js +0 -2
  237. package/dest/services/tx_collection/request_tracker.d.ts +53 -0
  238. package/dest/services/tx_collection/request_tracker.d.ts.map +1 -0
  239. package/dest/services/tx_collection/request_tracker.js +84 -0
  240. package/dest/services/tx_collection/tx_collection.d.ts +36 -55
  241. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
  242. package/dest/services/tx_collection/tx_collection.js +275 -119
  243. package/dest/services/tx_collection/tx_collection_sink.d.ts +1 -1
  244. package/dest/services/tx_collection/tx_collection_sink.js +2 -2
  245. package/dest/services/tx_collection/tx_source.d.ts +6 -5
  246. package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
  247. package/dest/services/tx_collection/tx_source.js +13 -8
  248. package/dest/services/tx_file_store/tx_file_store.d.ts +1 -3
  249. package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
  250. package/dest/services/tx_file_store/tx_file_store.js +4 -14
  251. package/dest/services/tx_provider.d.ts +3 -1
  252. package/dest/services/tx_provider.d.ts.map +1 -1
  253. package/dest/services/tx_provider.js +3 -0
  254. package/dest/test-helpers/make-test-p2p-clients.d.ts +1 -1
  255. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  256. package/dest/test-helpers/make-test-p2p-clients.js +5 -2
  257. package/dest/test-helpers/mock-pubsub.d.ts +23 -9
  258. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
  259. package/dest/test-helpers/mock-pubsub.js +44 -44
  260. package/dest/test-helpers/reqresp-nodes.d.ts +4 -5
  261. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  262. package/dest/test-helpers/reqresp-nodes.js +16 -18
  263. package/dest/test-helpers/test_tx_provider.d.ts +3 -1
  264. package/dest/test-helpers/test_tx_provider.d.ts.map +1 -1
  265. package/dest/test-helpers/test_tx_provider.js +3 -0
  266. package/dest/test-helpers/testbench-utils.d.ts +15 -14
  267. package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
  268. package/dest/test-helpers/testbench-utils.js +51 -16
  269. package/dest/testbench/p2p_client_testbench_worker.d.ts +3 -5
  270. package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
  271. package/dest/testbench/p2p_client_testbench_worker.js +104 -41
  272. package/dest/testbench/worker_client_manager.d.ts +12 -6
  273. package/dest/testbench/worker_client_manager.d.ts.map +1 -1
  274. package/dest/testbench/worker_client_manager.js +57 -11
  275. package/dest/util.d.ts +12 -7
  276. package/dest/util.d.ts.map +1 -1
  277. package/dest/util.js +35 -14
  278. package/dest/versioning.d.ts +3 -6
  279. package/dest/versioning.d.ts.map +1 -1
  280. package/dest/versioning.js +3 -24
  281. package/package.json +15 -16
  282. package/src/bootstrap/bootstrap.ts +17 -3
  283. package/src/client/factory.ts +62 -9
  284. package/src/client/interface.ts +48 -18
  285. package/src/client/p2p_client.ts +140 -106
  286. package/src/client/test/{tx_proposal_collector/README.md → p2p_client.batch_tx_requester.bench.README.md} +23 -53
  287. package/src/config.ts +241 -57
  288. package/src/errors/p2p-service.error.ts +11 -0
  289. package/src/errors/reqresp.error.ts +13 -19
  290. package/src/index.ts +0 -1
  291. package/src/mem_pools/attestation_pool/attestation_pool.ts +329 -243
  292. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +244 -69
  293. package/src/mem_pools/attestation_pool/mocks.ts +13 -8
  294. package/src/mem_pools/index.ts +0 -3
  295. package/src/mem_pools/instrumentation.ts +27 -17
  296. package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +1 -9
  297. package/src/mem_pools/tx_pool_v2/deleted_pool.ts +7 -7
  298. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +4 -5
  299. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +3 -2
  300. package/src/mem_pools/tx_pool_v2/eviction/index.ts +1 -0
  301. package/src/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.ts +67 -0
  302. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +1 -3
  303. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +5 -7
  304. package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +5 -6
  305. package/src/mem_pools/tx_pool_v2/interfaces.ts +40 -8
  306. package/src/mem_pools/tx_pool_v2/tx_metadata.ts +35 -13
  307. package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +62 -41
  308. package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +36 -7
  309. package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +260 -124
  310. package/src/msg_validators/attestation_validator/README.md +49 -0
  311. package/src/msg_validators/attestation_validator/attestation_validator.ts +46 -14
  312. package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +15 -7
  313. package/src/msg_validators/proposal_validator/README.md +123 -0
  314. package/src/msg_validators/proposal_validator/block_proposal_validator.ts +26 -4
  315. package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +43 -7
  316. package/src/msg_validators/proposal_validator/proposal_validator.ts +150 -58
  317. package/src/msg_validators/tx_validator/README.md +17 -3
  318. package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +3 -12
  319. package/src/msg_validators/tx_validator/allowed_public_setup.ts +22 -27
  320. package/src/msg_validators/tx_validator/allowed_setup_helpers.ts +31 -0
  321. package/src/msg_validators/tx_validator/archive_cache.ts +1 -1
  322. package/src/msg_validators/tx_validator/cached_tx_validator.ts +31 -0
  323. package/src/msg_validators/tx_validator/contract_instance_validator.ts +56 -0
  324. package/src/msg_validators/tx_validator/data_validator.ts +44 -1
  325. package/src/msg_validators/tx_validator/factory.ts +66 -9
  326. package/src/msg_validators/tx_validator/fee_payer_balance.ts +6 -2
  327. package/src/msg_validators/tx_validator/gas_validator.ts +117 -39
  328. package/src/msg_validators/tx_validator/index.ts +3 -0
  329. package/src/msg_validators/tx_validator/metadata_validator.ts +12 -4
  330. package/src/msg_validators/tx_validator/phases_validator.ts +82 -27
  331. package/src/msg_validators/tx_validator/timestamp_validator.ts +1 -1
  332. package/src/msg_validators/tx_validator/tx_proof_validator.ts +2 -0
  333. package/src/msg_validators/tx_validator/tx_validation_cache.ts +101 -0
  334. package/src/services/data_store.ts +5 -13
  335. package/src/services/discv5/discV5_service.ts +126 -14
  336. package/src/services/discv5/persisted_enr_store.ts +158 -0
  337. package/src/services/dummy_service.ts +20 -39
  338. package/src/services/encoding.ts +35 -19
  339. package/src/services/gossipsub/README.md +33 -11
  340. package/src/services/gossipsub/topic_score_params.ts +9 -18
  341. package/src/services/libp2p/instrumentation.ts +14 -0
  342. package/src/services/libp2p/libp2p_service.ts +508 -358
  343. package/src/services/peer-manager/metrics.ts +7 -0
  344. package/src/services/peer-manager/peer_manager.ts +91 -25
  345. package/src/services/peer-manager/peer_scoring.ts +102 -8
  346. package/src/services/reqresp/README.md +194 -0
  347. package/src/services/reqresp/batch-tx-requester/README.md +46 -7
  348. package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +91 -137
  349. package/src/services/reqresp/batch-tx-requester/interface.ts +13 -5
  350. package/src/services/reqresp/batch-tx-requester/missing_txs.ts +13 -6
  351. package/src/services/reqresp/batch-tx-requester/peer_collection.ts +68 -24
  352. package/src/services/reqresp/batch-tx-requester/tx_validator.ts +12 -25
  353. package/src/services/reqresp/config.ts +19 -2
  354. package/src/services/reqresp/interface.ts +21 -47
  355. package/src/services/reqresp/metrics.ts +0 -1
  356. package/src/services/reqresp/protocols/block_txs/bitvector.ts +3 -2
  357. package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +34 -30
  358. package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +47 -20
  359. package/src/services/reqresp/protocols/index.ts +0 -1
  360. package/src/services/reqresp/protocols/tx.ts +1 -3
  361. package/src/services/reqresp/rate-limiter/rate_limiter.ts +13 -9
  362. package/src/services/reqresp/rate-limiter/rate_limits.ts +3 -13
  363. package/src/services/reqresp/reqresp.ts +87 -260
  364. package/src/services/service.ts +35 -28
  365. package/src/services/tx_collection/config.ts +3 -80
  366. package/src/services/tx_collection/file_store_tx_collection.ts +54 -103
  367. package/src/services/tx_collection/file_store_tx_source.ts +43 -31
  368. package/src/services/tx_collection/index.ts +1 -6
  369. package/src/services/tx_collection/instrumentation.ts +1 -7
  370. package/src/services/tx_collection/request_tracker.ts +127 -0
  371. package/src/services/tx_collection/tx_collection.ts +331 -176
  372. package/src/services/tx_collection/tx_collection_sink.ts +2 -2
  373. package/src/services/tx_collection/tx_source.ts +10 -8
  374. package/src/services/tx_file_store/tx_file_store.ts +5 -17
  375. package/src/services/tx_provider.ts +5 -0
  376. package/src/test-helpers/make-test-p2p-clients.ts +4 -1
  377. package/src/test-helpers/mock-pubsub.ts +46 -60
  378. package/src/test-helpers/reqresp-nodes.ts +13 -23
  379. package/src/test-helpers/test_tx_provider.ts +5 -0
  380. package/src/test-helpers/testbench-utils.ts +64 -28
  381. package/src/testbench/p2p_client_testbench_worker.ts +111 -57
  382. package/src/testbench/worker_client_manager.ts +72 -25
  383. package/src/util.ts +33 -18
  384. package/src/versioning.ts +3 -33
  385. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts +0 -2
  386. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts.map +0 -1
  387. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +0 -304
  388. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts +0 -73
  389. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts.map +0 -1
  390. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.js +0 -8
  391. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +0 -125
  392. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +0 -1
  393. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +0 -596
  394. package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +0 -32
  395. package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +0 -1
  396. package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +0 -112
  397. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +0 -157
  398. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +0 -1
  399. package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +0 -52
  400. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +0 -16
  401. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +0 -1
  402. package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +0 -122
  403. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +0 -17
  404. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +0 -1
  405. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +0 -84
  406. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +0 -19
  407. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +0 -1
  408. package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +0 -78
  409. package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +0 -26
  410. package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +0 -1
  411. package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.js +0 -84
  412. package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts +0 -25
  413. package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts.map +0 -1
  414. package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.js +0 -57
  415. package/dest/mem_pools/tx_pool/index.d.ts +0 -3
  416. package/dest/mem_pools/tx_pool/index.d.ts.map +0 -1
  417. package/dest/mem_pools/tx_pool/index.js +0 -2
  418. package/dest/mem_pools/tx_pool/priority.d.ts +0 -12
  419. package/dest/mem_pools/tx_pool/priority.d.ts.map +0 -1
  420. package/dest/mem_pools/tx_pool/priority.js +0 -15
  421. package/dest/mem_pools/tx_pool/tx_pool.d.ts +0 -127
  422. package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +0 -1
  423. package/dest/mem_pools/tx_pool/tx_pool.js +0 -3
  424. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +0 -7
  425. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +0 -1
  426. package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +0 -400
  427. package/dest/msg_validators/clock_tolerance.d.ts +0 -21
  428. package/dest/msg_validators/clock_tolerance.d.ts.map +0 -1
  429. package/dest/msg_validators/clock_tolerance.js +0 -37
  430. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +0 -24
  431. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +0 -1
  432. package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +0 -378
  433. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +0 -64
  434. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +0 -1
  435. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +0 -151
  436. package/dest/services/reqresp/protocols/block.d.ts +0 -9
  437. package/dest/services/reqresp/protocols/block.d.ts.map +0 -1
  438. package/dest/services/reqresp/protocols/block.js +0 -32
  439. package/dest/services/tx_collection/fast_tx_collection.d.ts +0 -54
  440. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +0 -1
  441. package/dest/services/tx_collection/fast_tx_collection.js +0 -327
  442. package/dest/services/tx_collection/missing_txs_tracker.d.ts +0 -32
  443. package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +0 -1
  444. package/dest/services/tx_collection/missing_txs_tracker.js +0 -27
  445. package/dest/services/tx_collection/proposal_tx_collector.d.ts +0 -49
  446. package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +0 -1
  447. package/dest/services/tx_collection/proposal_tx_collector.js +0 -50
  448. package/dest/services/tx_collection/slow_tx_collection.d.ts +0 -57
  449. package/dest/services/tx_collection/slow_tx_collection.d.ts.map +0 -1
  450. package/dest/services/tx_collection/slow_tx_collection.js +0 -211
  451. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +0 -345
  452. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +0 -43
  453. package/src/mem_pools/tx_pool/README.md +0 -270
  454. package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +0 -746
  455. package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +0 -132
  456. package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +0 -208
  457. package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +0 -162
  458. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +0 -104
  459. package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +0 -93
  460. package/src/mem_pools/tx_pool/eviction/low_priority_eviction_rule.ts +0 -106
  461. package/src/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.ts +0 -75
  462. package/src/mem_pools/tx_pool/index.ts +0 -2
  463. package/src/mem_pools/tx_pool/priority.ts +0 -20
  464. package/src/mem_pools/tx_pool/tx_pool.ts +0 -141
  465. package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +0 -319
  466. package/src/msg_validators/clock_tolerance.ts +0 -51
  467. package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +0 -373
  468. package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +0 -161
  469. package/src/services/reqresp/protocols/block.ts +0 -37
  470. package/src/services/tx_collection/fast_tx_collection.ts +0 -387
  471. package/src/services/tx_collection/missing_txs_tracker.ts +0 -52
  472. package/src/services/tx_collection/proposal_tx_collector.ts +0 -113
  473. package/src/services/tx_collection/slow_tx_collection.ts +0 -266
@@ -370,16 +370,20 @@ function applyDecs2203RFactory() {
370
370
  function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
371
371
  return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
372
372
  }
373
- var _dec, _dec1, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _initProto;
373
+ var _dec, _dec1, _dec2, _dec3, _dec4, _dec5, _initProto;
374
374
  import { BlockNumber } from '@aztec/foundation/branded-types';
375
+ import { compactArray, maxBy, merge } from '@aztec/foundation/collection';
375
376
  import { createLibp2pComponentLogger, createLogger } from '@aztec/foundation/log';
376
377
  import { RunningPromise } from '@aztec/foundation/running-promise';
377
378
  import { Timer } from '@aztec/foundation/timer';
378
379
  import { protocolContractsHash } from '@aztec/protocol-contracts';
379
- import { GasFees } from '@aztec/stdlib/gas';
380
- import { BlockProposal, CheckpointAttestation, CheckpointProposal, P2PMessage, PeerErrorSeverity, TopicType, createTopicString, getTopicsForConfig, metricsTopicStrToLabels } from '@aztec/stdlib/p2p';
380
+ import { DEFAULT_MAX_BLOCKS_PER_CHECKPOINT } from '@aztec/stdlib/config';
381
+ import { getNetworkTxGasLimits } from '@aztec/stdlib/gas';
382
+ import { BlockProposal, CheckpointAttestation, CheckpointProposal, P2PMessage, PeerErrorSeverity, PeerErrorSeverityByHarshness, TopicType, createTopicString, getTopicsForConfig, metricsTopicStrToLabels } from '@aztec/stdlib/p2p';
383
+ import { ConsensusTimetable, getDefaultCheckpointProposalSyncGrace } from '@aztec/stdlib/timetable';
381
384
  import { MerkleTreeId } from '@aztec/stdlib/trees';
382
385
  import { Tx } from '@aztec/stdlib/tx';
386
+ import { InvalidBlockProposalTxsError } from '@aztec/stdlib/validators';
383
387
  import { compressComponentVersions } from '@aztec/stdlib/versioning';
384
388
  import { Attributes, OtelMetricsAdapter, SpanStatusCode, WithTracer, trackSpan } from '@aztec/telemetry-client';
385
389
  import { gossipsub } from '@chainsafe/libp2p-gossipsub';
@@ -392,24 +396,39 @@ import { identify } from '@libp2p/identify';
392
396
  import { TopicValidatorResult } from '@libp2p/interface';
393
397
  import { mplex } from '@libp2p/mplex';
394
398
  import { tcp } from '@libp2p/tcp';
399
+ import { multiaddr } from '@multiformats/multiaddr';
395
400
  import { ENR } from '@nethermindeth/enr';
396
401
  import { createLibp2p } from 'libp2p';
402
+ import { CheckpointProposalReceivedCallbackNotRegisteredError } from '../../errors/p2p-service.error.js';
397
403
  import { BlockProposalValidator, CheckpointAttestationValidator, CheckpointProposalValidator, DoubleSpendTxValidator, FishermanAttestationValidator, getDefaultAllowedSetupFunctions } from '../../msg_validators/index.js';
398
404
  import { MessageSeenValidator } from '../../msg_validators/msg_seen_validator/msg_seen_validator.js';
399
- import { createFirstStageTxValidationsForGossipedTransactions, createSecondStageTxValidationsForGossipedTransactions, createTxValidatorForBlockProposalReceivedTxs, createTxValidatorForReqResponseReceivedTxs } from '../../msg_validators/tx_validator/factory.js';
405
+ import { createFirstStageTxValidationsForGossipedTransactions, createSecondStageTxValidationsForGossipedTransactions, createTxValidatorForBlockProposalReceivedTxs } from '../../msg_validators/tx_validator/factory.js';
400
406
  import { GossipSubEvent } from '../../types/index.js';
401
407
  import { convertToMultiaddr } from '../../util.js';
402
408
  import { getVersions } from '../../versioning.js';
403
409
  import { AztecDatastore } from '../data_store.js';
404
410
  import { DiscV5Service } from '../discv5/discV5_service.js';
405
- import { SnappyTransform, fastMsgIdFn, getMsgIdFn, msgIdToStrFn } from '../encoding.js';
411
+ import { SnappyTransform, getMsgIdFn, msgIdToStrFn } from '../encoding.js';
406
412
  import { APP_SPECIFIC_WEIGHT, gossipScoreThresholds } from '../gossipsub/scoring.js';
407
413
  import { createAllTopicScoreParams } from '../gossipsub/topic_score_params.js';
408
414
  import { PeerManager } from '../peer-manager/peer_manager.js';
409
415
  import { PeerScoring } from '../peer-manager/peer_scoring.js';
410
- import { DEFAULT_SUB_PROTOCOL_VALIDATORS, ReqRespSubProtocol, ValidationError, pingHandler, reqGoodbyeHandler, reqRespBlockHandler, reqRespBlockTxsHandler, reqRespStatusHandler, reqRespTxHandler } from '../reqresp/index.js';
416
+ import { YAMUX_MAX_MESSAGE_SIZE_BYTES } from '../reqresp/config.js';
417
+ import { ReqRespSubProtocol, ValidationError, pingHandler, reqGoodbyeHandler, reqRespBlockTxsHandler, reqRespStatusHandler, reqRespTxHandler } from '../reqresp/index.js';
411
418
  import { ReqResp } from '../reqresp/reqresp.js';
412
419
  import { P2PInstrumentation } from './instrumentation.js';
420
+ /**
421
+ * Builds the {@link ConsensusTimetable} shared by the gossip validators for proposal/attestation receive-window
422
+ * bounds. Derived purely from protocol slot-timing constants plus the block sub-slot duration and the consensus
423
+ * materialization grace, so every node agrees on these bounds without depending on proposer operational budgets.
424
+ */ function buildConsensusTimetable(config, l1Constants) {
425
+ const blockDuration = config.blockDurationMs / 1000;
426
+ return new ConsensusTimetable({
427
+ l1Constants,
428
+ blockDuration,
429
+ checkpointProposalSyncGrace: config.checkpointProposalSyncGraceSeconds ?? getDefaultCheckpointProposalSyncGrace(blockDuration)
430
+ });
431
+ }
413
432
  _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId, attestation)=>({
414
433
  [Attributes.SLOT_NUMBER]: attestation.payload.header.slotNumber.toString()
415
434
  })), _dec1 = trackSpan('Libp2pService.validateAndStoreBlockProposal', (_peerId, block)=>({
@@ -425,16 +444,8 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
425
444
  [Attributes.SLOT_NUMBER]: checkpoint.slotNumber,
426
445
  [Attributes.BLOCK_ARCHIVE]: checkpoint.archive.toString(),
427
446
  [Attributes.P2P_ID]: await checkpoint.p2pMessageLoggingIdentifier().then((i)=>i.toString())
428
- })), _dec5 = trackSpan('Libp2pService.validateRequestedBlockTxs', (request)=>({
447
+ })), _dec5 = trackSpan('Libp2pService.validateRequestedBlockTxsConsistency', (request)=>({
429
448
  [Attributes.BLOCK_ARCHIVE]: request.archiveRoot.toString()
430
- })), _dec6 = trackSpan('Libp2pService.validateRequestedTx', (requestedTxHash, _responseTx)=>({
431
- [Attributes.TX_HASH]: requestedTxHash.toString()
432
- })), _dec7 = trackSpan('Libp2pService.validateRequestedBlock', (requestedBlockNumber, _responseBlock)=>({
433
- [Attributes.BLOCK_NUMBER]: requestedBlockNumber.toString()
434
- })), _dec8 = trackSpan('Libp2pService.validateCheckpointAttestation', async (_, attestation)=>({
435
- [Attributes.SLOT_NUMBER]: attestation.payload.header.slotNumber,
436
- [Attributes.BLOCK_ARCHIVE]: attestation.archive.toString(),
437
- [Attributes.P2P_ID]: await attestation.p2pMessageLoggingIdentifier().then((i)=>i.toString())
438
449
  }));
439
450
  /**
440
451
  * Lib P2P implementation of the P2PService interface.
@@ -449,6 +460,8 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
449
460
  epochCache;
450
461
  proofVerifier;
451
462
  worldStateSynchronizer;
463
+ blockMinFeesProvider;
464
+ txValidationCache;
452
465
  static{
453
466
  ({ e: [_initProto] } = _apply_decs_2203_r(this, [
454
467
  [
@@ -479,22 +492,7 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
479
492
  [
480
493
  _dec5,
481
494
  2,
482
- "validateRequestedBlockTxs"
483
- ],
484
- [
485
- _dec6,
486
- 2,
487
- "validateRequestedTxs"
488
- ],
489
- [
490
- _dec7,
491
- 2,
492
- "validateRequestedBlock"
493
- ],
494
- [
495
- _dec8,
496
- 2,
497
- "validateCheckpointAttestation"
495
+ "validateRequestedBlockTxsConsistency"
498
496
  ]
499
497
  ], []));
500
498
  }
@@ -506,9 +504,10 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
506
504
  checkpointAttestationValidator;
507
505
  protocolVersion;
508
506
  topicStrings;
509
- feesCache;
510
507
  /** Callback invoked when a duplicate proposal is detected (triggers slashing). */ duplicateProposalCallback;
508
+ /** Callback invoked when an oversized block proposal is stored as slashing evidence (triggers slashing). */ oversizedProposalCallback;
511
509
  /** Callback invoked when a duplicate attestation is detected (triggers slashing). */ duplicateAttestationCallback;
510
+ /** Callback invoked when a valid checkpoint attestation is accepted into the pool. */ checkpointAttestationCallback;
512
511
  /**
513
512
  * Callback for when a block is received from a peer.
514
513
  * @param block - The block received from the peer.
@@ -518,13 +517,20 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
518
517
  * Callback for when a checkpoint proposal is received from a peer.
519
518
  * @param checkpoint - The checkpoint proposal received from the peer.
520
519
  * @returns The attestations for the checkpoint, if any.
521
- */ checkpointReceivedCallback;
520
+ */ allNodesCheckpointReceivedCallback;
521
+ /**
522
+ * Callback for when a checkpoint proposal is received - specifically for validators - from a peer.
523
+ * @param checkpoint - The checkpoint proposal received from the peer.
524
+ * @returns The attestations for the checkpoint, if any.
525
+ */ validatorCheckpointReceivedCallback;
522
526
  gossipSubEventHandler;
527
+ ipChangedHandler;
528
+ discoveredP2pIp;
523
529
  instrumentation;
524
530
  telemetry;
525
531
  logger;
526
- constructor(config, node, peerDiscoveryService, reqresp, peerManager, mempools, archiver, epochCache, proofVerifier, worldStateSynchronizer, telemetry, logger = createLogger('p2p:libp2p_service')){
527
- super(telemetry, 'LibP2PService'), this.config = config, this.node = node, this.peerDiscoveryService = peerDiscoveryService, this.reqresp = reqresp, this.peerManager = peerManager, this.mempools = mempools, this.archiver = archiver, this.epochCache = epochCache, this.proofVerifier = proofVerifier, this.worldStateSynchronizer = worldStateSynchronizer, this.msgIdSeenValidators = (_initProto(this), {}), this.protocolVersion = '', this.topicStrings = {};
532
+ constructor(config, node, peerDiscoveryService, reqresp, peerManager, mempools, archiver, epochCache, proofVerifier, worldStateSynchronizer, blockMinFeesProvider, telemetry, logger = createLogger('p2p:libp2p_service'), txValidationCache){
533
+ super(telemetry, 'LibP2PService'), this.config = config, this.node = node, this.peerDiscoveryService = peerDiscoveryService, this.reqresp = reqresp, this.peerManager = peerManager, this.mempools = mempools, this.archiver = archiver, this.epochCache = epochCache, this.proofVerifier = proofVerifier, this.worldStateSynchronizer = worldStateSynchronizer, this.blockMinFeesProvider = blockMinFeesProvider, this.txValidationCache = txValidationCache, this.msgIdSeenValidators = (_initProto(this), {}), this.protocolVersion = '', this.topicStrings = {};
528
534
  this.telemetry = telemetry;
529
535
  // Create child logger with fisherman prefix if in fisherman mode
530
536
  this.logger = config.fishermanMode ? logger.createChild('[FISHERMAN]') : logger;
@@ -540,29 +546,44 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
540
546
  this.topicStrings[TopicType.block_proposal] = createTopicString(TopicType.block_proposal, this.protocolVersion);
541
547
  this.topicStrings[TopicType.checkpoint_proposal] = createTopicString(TopicType.checkpoint_proposal, this.protocolVersion);
542
548
  this.topicStrings[TopicType.checkpoint_attestation] = createTopicString(TopicType.checkpoint_attestation, this.protocolVersion);
543
- this.blockProposalValidator = new BlockProposalValidator(epochCache, {
544
- txsPermitted: !config.disableTransactions,
545
- maxTxsPerBlock: config.maxTxsPerBlock
546
- });
547
- this.checkpointProposalValidator = new CheckpointProposalValidator(epochCache, {
549
+ // Build the consensus timetable once from protocol slot-timing constants and inject it into every
550
+ // validator so they share one set of receive-window bounds, independent of proposer operational budgets.
551
+ const consensusTimetable = buildConsensusTimetable(config, epochCache.getL1Constants());
552
+ const proposalValidatorOpts = {
548
553
  txsPermitted: !config.disableTransactions,
549
- maxTxsPerBlock: config.maxTxsPerBlock
550
- });
551
- this.checkpointAttestationValidator = config.fishermanMode ? new FishermanAttestationValidator(epochCache, mempools.attestationPool, telemetry) : new CheckpointAttestationValidator(epochCache);
554
+ maxTxsPerBlock: config.validateMaxTxsPerBlock ?? config.validateMaxTxsPerCheckpoint,
555
+ maxBlocksPerCheckpoint: config.maxBlocksPerCheckpoint,
556
+ skipSlotValidation: config.skipProposalSlotValidation,
557
+ signatureContext: {
558
+ chainId: config.l1ChainId,
559
+ rollupAddress: config.rollupAddress
560
+ },
561
+ clockDisparityMs: config.maxGossipClockDisparityMs
562
+ };
563
+ this.blockProposalValidator = new BlockProposalValidator(epochCache, consensusTimetable, proposalValidatorOpts);
564
+ this.checkpointProposalValidator = new CheckpointProposalValidator(epochCache, consensusTimetable, proposalValidatorOpts);
565
+ const attestationValidatorOpts = {
566
+ signatureContext: proposalValidatorOpts.signatureContext,
567
+ clockDisparityMs: config.maxGossipClockDisparityMs
568
+ };
569
+ this.checkpointAttestationValidator = config.fishermanMode ? new FishermanAttestationValidator(epochCache, consensusTimetable, mempools.attestationPool, telemetry, attestationValidatorOpts) : new CheckpointAttestationValidator(epochCache, consensusTimetable, attestationValidatorOpts);
552
570
  this.gossipSubEventHandler = this.handleGossipSubEvent.bind(this);
553
571
  this.blockReceivedCallback = async (block)=>{
554
- this.logger.debug(`Handler not yet registered: Block received callback not set. Received block for slot ${block.slotNumber} from peer.`, {
572
+ this.logger.warn(`Handler for block received not yet registered on P2P service. Received block ${block.blockNumber} for slot ${block.slotNumber} from peer.`, {
555
573
  p2pMessageIdentifier: await block.p2pMessageLoggingIdentifier()
556
574
  });
557
- return false;
575
+ return true;
576
+ };
577
+ this.allNodesCheckpointReceivedCallback = (_checkpoint)=>{
578
+ throw new CheckpointProposalReceivedCallbackNotRegisteredError();
558
579
  };
559
- this.checkpointReceivedCallback = (checkpoint)=>{
560
- this.logger.debug(`Handler not yet registered: Checkpoint received callback not set. Received checkpoint for slot ${checkpoint.slotNumber} from peer.`);
580
+ this.validatorCheckpointReceivedCallback = (_checkpoint)=>{
561
581
  return Promise.resolve(undefined);
562
582
  };
563
583
  }
564
584
  updateConfig(config) {
565
585
  this.reqresp.updateConfig(config);
586
+ this.config = merge(this.config, config);
566
587
  }
567
588
  /**
568
589
  * Creates an instance of the LibP2P service.
@@ -570,12 +591,12 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
570
591
  * @param txPool - The transaction pool to be accessed by the service.
571
592
  * @returns The new service.
572
593
  */ static async new(config, peerId, deps) {
573
- const { worldStateSynchronizer, epochCache, l2BlockSource, mempools, proofVerifier, peerStore, telemetry, logger, packageVersion } = deps;
594
+ const { worldStateSynchronizer, epochCache, l2BlockSource, mempools, proofVerifier, peerStore, blockMinFeesProvider, telemetry, logger, packageVersion, txValidationCache } = deps;
574
595
  const { p2pPort, maxPeerCount, listenAddress } = config;
575
596
  const bindAddrTcp = convertToMultiaddr(listenAddress, p2pPort, 'tcp');
576
597
  const datastore = new AztecDatastore(peerStore);
577
598
  const otelMetricsAdapter = new OtelMetricsAdapter(telemetry, logger.getBindings());
578
- const peerDiscoveryService = new DiscV5Service(peerId, config, packageVersion, telemetry, createLogger(`${logger.module}:discv5_service`, logger.getBindings()));
599
+ const peerDiscoveryService = new DiscV5Service(peerId, config, packageVersion, telemetry, createLogger(`${logger.module}:discv5_service`, logger.getBindings()), peerStore);
579
600
  // Seed libp2p's bootstrap discovery with private and trusted peers
580
601
  const bootstrapNodes = [
581
602
  ...config.privatePeers,
@@ -590,31 +611,45 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
590
611
  const versions = getVersions(config);
591
612
  const protocolVersion = compressComponentVersions(versions);
592
613
  const preferredPeersEnrs = config.preferredPeers.map((enr)=>ENR.decodeTxt(enr));
593
- const directPeers = (await Promise.all(preferredPeersEnrs.map(async (enr)=>{
594
- const peerId = await enr.peerId();
595
- const address = enr.getLocationMultiaddr('tcp');
596
- if (address === undefined) {
597
- throw new Error(`Direct peer ${peerId.toString()} has no TCP address, ENR: ${enr.encodeTxt()}`);
614
+ const directPeers = compactArray(await Promise.all(preferredPeersEnrs.map(async (enr)=>{
615
+ try {
616
+ const peerId = await enr.peerId();
617
+ const address = enr.getLocationMultiaddr('tcp');
618
+ if (address === undefined) {
619
+ throw new Error(`Direct peer ${peerId.toString()} has no TCP address, ENR: ${enr.encodeTxt()}`);
620
+ }
621
+ return {
622
+ id: peerId,
623
+ addrs: [
624
+ address
625
+ ]
626
+ };
627
+ } catch (err) {
628
+ // A malformed configured ENR shouldn't abort node setup — skip it and log.
629
+ logger.warn(`Skipping preferred peer with invalid ENR`, {
630
+ err
631
+ });
632
+ return undefined;
598
633
  }
599
- return {
600
- id: peerId,
601
- addrs: [
602
- address
603
- ]
604
- };
605
- }))).filter((peer)=>peer !== undefined);
634
+ })));
606
635
  const announceTcpMultiaddr = config.p2pIp ? [
607
636
  convertToMultiaddr(config.p2pIp, p2pPort, 'tcp')
608
637
  ] : [];
609
- // Create dynamic topic score params based on network configuration
638
+ // Create dynamic topic score params based on network configuration. Scoring uses the network-wide
639
+ // max-blocks-per-checkpoint config value directly to size expected per-slot message rates; these are
640
+ // peer-rate thresholds, not consensus deadlines, so they need no proposer operational budgets.
610
641
  const l1Constants = epochCache.getL1Constants();
611
642
  const topicScoreParams = createAllTopicScoreParams(protocolVersion, {
612
643
  slotDurationMs: l1Constants.slotDuration * 1000,
613
644
  heartbeatIntervalMs: config.gossipsubInterval,
614
645
  targetCommitteeSize: l1Constants.targetCommitteeSize,
615
- blockDurationMs: config.blockDurationMs,
646
+ maxBlocksPerCheckpoint: config.maxBlocksPerCheckpoint ?? DEFAULT_MAX_BLOCKS_PER_CHECKPOINT,
616
647
  expectedBlockProposalsPerSlot: config.expectedBlockProposalsPerSlot
617
648
  });
649
+ // Restrict gossipsub to exactly the topics we subscribe to. Without this, an arbitrary-topic
650
+ // message is transformed, msg-id'd and inserted into the seenCache before the subscription check,
651
+ // so a crafted topic colliding on msg id can suppress a real message as a duplicate.
652
+ const allowedTopics = getTopicsForConfig(config.disableTransactions).map((topic)=>createTopicString(topic, protocolVersion));
618
653
  const node = await createLibp2p({
619
654
  start: false,
620
655
  peerId,
@@ -648,8 +683,11 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
648
683
  ],
649
684
  datastore,
650
685
  peerDiscovery,
686
+ // Pin the yamux frame size: MAX_REQRESP_REQUEST_SIZE_BYTES relies on a reqresp request fitting in one frame.
651
687
  streamMuxers: [
652
- yamux(),
688
+ yamux({
689
+ maxMessageSize: YAMUX_MAX_MESSAGE_SIZE_BYTES
690
+ }),
653
691
  mplex()
654
692
  ],
655
693
  connectionEncryption: [
@@ -667,7 +705,7 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
667
705
  },
668
706
  connectionGater: {
669
707
  denyInboundConnection: (maConn)=>{
670
- const allowed = peerManager.isNodeAllowedToConnect(maConn.remoteAddr.nodeAddress().address);
708
+ const allowed = peerManager.isAddressAllowedToConnect(maConn.remoteAddr.nodeAddress().address);
671
709
  if (allowed) {
672
710
  return false;
673
711
  }
@@ -677,7 +715,7 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
677
715
  denyInboundEncryptedConnection: (peerId, _maConn)=>{
678
716
  //NOTE: it is not necessary to check address here because this was already done by
679
717
  // denyInboundConnection
680
- const allowed = peerManager.isNodeAllowedToConnect(peerId);
718
+ const allowed = peerManager.isPeerAllowedToConnect(peerId);
681
719
  if (allowed) {
682
720
  return false;
683
721
  }
@@ -704,9 +742,13 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
704
742
  mcacheLength: config.gossipsubMcacheLength,
705
743
  mcacheGossip: config.gossipsubMcacheGossip,
706
744
  seenTTL: config.gossipsubSeenTTL,
745
+ allowedTopics,
746
+ // No fastMsgIdFn: the fast-path dedup cache keys on a non-cryptographic 64-bit hash of the
747
+ // raw data only (no topic), so a collision — accidental or engineered via a weak seed — drops
748
+ // a different message with no fallback to the full id. Dedup instead rests solely on the
749
+ // cryptographic, topic-framed msgIdFn below.
707
750
  msgIdFn: getMsgIdFn,
708
751
  msgIdToStrFn: msgIdToStrFn,
709
- fastMsgIdFn: fastMsgIdFn,
710
752
  dataTransform: new SnappyTransform(),
711
753
  metricsRegister: otelMetricsAdapter,
712
754
  metricsTopicStrToLabel: metricsTopicStrToLabels(protocolVersion),
@@ -719,7 +761,8 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
719
761
  })
720
762
  }),
721
763
  components: (components)=>({
722
- connectionManager: components.connectionManager
764
+ connectionManager: components.connectionManager,
765
+ addressManager: components.addressManager
723
766
  })
724
767
  },
725
768
  logger: createLibp2pComponentLogger(logger.module, logger.getBindings())
@@ -727,6 +770,8 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
727
770
  const peerScoring = new PeerScoring(config, telemetry);
728
771
  const reqresp = new ReqResp(config, node, peerScoring, createLogger(`${logger.module}:reqresp`));
729
772
  const peerManager = new PeerManager(node, peerDiscoveryService, config, telemetry, createLogger(`${logger.module}:peer_manager`), peerScoring, reqresp, worldStateSynchronizer, protocolVersion, epochCache);
773
+ // Gate req/resp data protocols for unauthenticated peers when p2pAllowOnlyValidators is enabled
774
+ reqresp.setShouldRejectPeer((peerId)=>peerManager.shouldDisableP2PGossip(peerId));
730
775
  // Configure application-specific scoring for gossipsub.
731
776
  // The weight scales app score to align with gossipsub thresholds:
732
777
  // - Disconnect (-50) × 10 = -500 = gossipThreshold (stops receiving gossip)
@@ -734,7 +779,7 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
734
779
  // Note: positive topic scores can offset penalties, so alignment is best-effort.
735
780
  node.services.pubsub.score.params.appSpecificWeight = APP_SPECIFIC_WEIGHT;
736
781
  node.services.pubsub.score.params.appSpecificScore = (peerId)=>peerManager.shouldDisableP2PGossip(peerId) ? -Infinity : peerManager.getPeerScore(peerId);
737
- return new LibP2PService(config, node, peerDiscoveryService, reqresp, peerManager, mempools, l2BlockSource, epochCache, proofVerifier, worldStateSynchronizer, telemetry, logger);
782
+ return new LibP2PService(config, node, peerDiscoveryService, reqresp, peerManager, mempools, l2BlockSource, epochCache, proofVerifier, worldStateSynchronizer, blockMinFeesProvider, telemetry, logger, txValidationCache);
738
783
  }
739
784
  /**
740
785
  * Starts the LibP2P service.
@@ -744,22 +789,19 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
744
789
  if (this.node.status === 'started') {
745
790
  throw new Error('P2P service already started');
746
791
  }
747
- // Get listen & announce addresses for logging
748
792
  const { p2pIp, p2pPort } = this.config;
749
- if (!p2pIp) {
750
- throw new Error('Announce address not provided.');
793
+ if (!p2pIp && !this.config.queryForIp) {
794
+ throw new Error('Announce address not provided and queryForIp is not enabled.');
751
795
  }
752
- const announceTcpMultiaddr = convertToMultiaddr(p2pIp, p2pPort, 'tcp');
796
+ const announceTcpMultiaddr = p2pIp ? convertToMultiaddr(p2pIp, p2pPort, 'tcp') : undefined;
753
797
  // Create request response protocol handlers
754
798
  const txHandler = reqRespTxHandler(this.mempools);
755
799
  const goodbyeHandler = reqGoodbyeHandler(this.peerManager);
756
- const blockHandler = reqRespBlockHandler(this.archiver);
757
800
  const statusHandler = reqRespStatusHandler(this.protocolVersion, this.worldStateSynchronizer, this.logger);
758
801
  const requestResponseHandlers = {
759
802
  [ReqRespSubProtocol.PING]: pingHandler,
760
803
  [ReqRespSubProtocol.STATUS]: statusHandler.bind(this),
761
- [ReqRespSubProtocol.GOODBYE]: goodbyeHandler.bind(this),
762
- [ReqRespSubProtocol.BLOCK]: blockHandler.bind(this)
804
+ [ReqRespSubProtocol.GOODBYE]: goodbyeHandler.bind(this)
763
805
  };
764
806
  if (!this.config.disableTransactions) {
765
807
  const blockTxsHandler = reqRespBlockTxsHandler(this.mempools.attestationPool, this.archiver, this.mempools.txPool);
@@ -768,15 +810,8 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
768
810
  if (!this.config.disableTransactions) {
769
811
  requestResponseHandlers[ReqRespSubProtocol.TX] = txHandler.bind(this);
770
812
  }
771
- // Define the sub protocol validators - This is done within this start() method to gain a callback to the existing validateTx function
772
- const reqrespSubProtocolValidators = {
773
- ...DEFAULT_SUB_PROTOCOL_VALIDATORS,
774
- [ReqRespSubProtocol.TX]: this.validateRequestedTxs.bind(this),
775
- [ReqRespSubProtocol.BLOCK_TXS]: this.validateRequestedBlockTxs.bind(this),
776
- [ReqRespSubProtocol.BLOCK]: this.validateRequestedBlock.bind(this)
777
- };
778
813
  await this.peerManager.initializePeers();
779
- await this.reqresp.start(requestResponseHandlers, reqrespSubProtocolValidators);
814
+ await this.reqresp.start(requestResponseHandlers);
780
815
  await this.node.start();
781
816
  // Subscribe to standard GossipSub topics by default
782
817
  for (const topic of getTopicsForConfig(this.config.disableTransactions)){
@@ -788,6 +823,34 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
788
823
  if (!this.config.p2pDiscoveryDisabled) {
789
824
  await this.peerDiscoveryService.start();
790
825
  }
826
+ // Bridge discv5 IP changes to libp2p's AddressManager so peers see the updated address
827
+ if (this.config.queryForIp) {
828
+ this.discoveredP2pIp = this.config.p2pIp;
829
+ this.logger.info('IP change tracking enabled, bridging discv5 IP updates to libp2p AddressManager');
830
+ this.ipChangedHandler = (ip)=>{
831
+ const addressManager = this.node.services.components.addressManager;
832
+ const newAddr = multiaddr(convertToMultiaddr(ip, this.config.p2pPort, 'tcp'));
833
+ const previousIp = this.discoveredP2pIp;
834
+ if (previousIp) {
835
+ const oldAddr = multiaddr(convertToMultiaddr(previousIp, this.config.p2pPort, 'tcp'));
836
+ addressManager.removeObservedAddr(oldAddr);
837
+ this.logger.info('Libp2p announce address updated due to IP change', {
838
+ previousIp,
839
+ newIp: ip,
840
+ newMultiaddr: newAddr.toString()
841
+ });
842
+ } else {
843
+ this.logger.info('Libp2p announce address set from initial discv5 IP discovery', {
844
+ ip,
845
+ multiaddr: newAddr.toString()
846
+ });
847
+ }
848
+ addressManager.addObservedAddr(newAddr);
849
+ addressManager.confirmObservedAddr(newAddr);
850
+ this.discoveredP2pIp = ip;
851
+ };
852
+ this.peerDiscoveryService.on('ip:changed', this.ipChangedHandler);
853
+ }
791
854
  this.discoveryRunningPromise = new RunningPromise(async ()=>{
792
855
  await this.peerManager.heartbeat();
793
856
  }, this.logger, this.config.peerCheckIntervalMS);
@@ -805,6 +868,10 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
805
868
  */ async stop() {
806
869
  // Remove gossip sub listener
807
870
  this.node.services.pubsub.removeEventListener(GossipSubEvent.MESSAGE, this.gossipSubEventHandler);
871
+ if (this.ipChangedHandler) {
872
+ this.peerDiscoveryService.removeListener('ip:changed', this.ipChangedHandler);
873
+ this.ipChangedHandler = undefined;
874
+ }
808
875
  // Stop peer manager
809
876
  this.logger.debug('Stopping peer manager...');
810
877
  await this.peerManager.stop();
@@ -818,8 +885,8 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
818
885
  await this.stopLibP2P();
819
886
  this.logger.info('LibP2P service stopped');
820
887
  }
821
- addReqRespSubProtocol(subProtocol, handler, validator) {
822
- return this.reqresp.addSubProtocol(subProtocol, handler, validator);
888
+ addReqRespSubProtocol(subProtocol, handler) {
889
+ return this.reqresp.addSubProtocol(subProtocol, handler);
823
890
  }
824
891
  registerThisValidatorAddresses(address) {
825
892
  this.peerManager.registerThisValidatorAddresses(address);
@@ -841,14 +908,6 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
841
908
  };
842
909
  setImmediate(()=>void safeJob());
843
910
  }
844
- /**
845
- * Send a batch of requests to peers, and return the responses
846
- * @param protocol - The request response protocol to use
847
- * @param requests - The requests to send to the peers
848
- * @returns The responses to the requests
849
- */ sendBatchRequest(protocol, requests, pinnedPeerId) {
850
- return this.reqresp.sendBatchRequest(protocol, requests, pinnedPeerId);
851
- }
852
911
  sendRequestToPeer(peerId, subProtocol, payload, dialTimeout) {
853
912
  return this.reqresp.sendRequestToPeer(peerId, subProtocol, payload, dialTimeout);
854
913
  }
@@ -861,8 +920,11 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
861
920
  registerBlockReceivedCallback(callback) {
862
921
  this.blockReceivedCallback = callback;
863
922
  }
864
- registerCheckpointReceivedCallback(callback) {
865
- this.checkpointReceivedCallback = callback;
923
+ registerValidatorCheckpointReceivedCallback(callback) {
924
+ this.validatorCheckpointReceivedCallback = callback;
925
+ }
926
+ registerAllNodesCheckpointReceivedCallback(callback) {
927
+ this.allNodesCheckpointReceivedCallback = callback;
866
928
  }
867
929
  /**
868
930
  * Registers a callback to be invoked when a duplicate proposal is detected.
@@ -871,12 +933,20 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
871
933
  this.duplicateProposalCallback = callback;
872
934
  }
873
935
  /**
936
+ * Registers a callback to be invoked when an oversized block proposal is stored as slashing evidence.
937
+ */ registerOversizedProposalCallback(callback) {
938
+ this.oversizedProposalCallback = callback;
939
+ }
940
+ /**
874
941
  * Registers a callback to be invoked when a duplicate attestation is detected.
875
942
  * A validator signing attestations for different proposals at the same slot.
876
943
  * This callback is triggered on the first duplicate (when count goes from 1 to 2).
877
944
  */ registerDuplicateAttestationCallback(callback) {
878
945
  this.duplicateAttestationCallback = callback;
879
946
  }
947
+ registerCheckpointAttestationCallback(callback) {
948
+ this.checkpointAttestationCallback = callback;
949
+ }
880
950
  /**
881
951
  * Subscribes to a topic.
882
952
  * @param topic - The topic to subscribe to.
@@ -928,6 +998,12 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
928
998
  if (!validator || !validator.addMessage(msgId)) {
929
999
  this.instrumentation.incMessagePrevalidationStatus(false, topicType);
930
1000
  this.node.services.pubsub.reportMessageValidationResult(msgId, source.toString(), TopicValidatorResult.Ignore);
1001
+ if (topicType === TopicType.tx) {
1002
+ this.logger.verbose(`Ignoring already-seen tx gossip message`, {
1003
+ msgId,
1004
+ source: source.toString()
1005
+ });
1006
+ }
931
1007
  return {
932
1008
  result: false,
933
1009
  topicType
@@ -985,6 +1061,13 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
985
1061
  }
986
1062
  // Process the message, optionally within a linked span for trace propagation
987
1063
  const processMessage = async ()=>{
1064
+ if (this.config.skipIncomingProposals && (msg.topic === this.topicStrings[TopicType.block_proposal] || msg.topic === this.topicStrings[TopicType.checkpoint_proposal])) {
1065
+ this.logger.warn(`Ignoring incoming proposal (skipIncomingProposals is set)`, {
1066
+ topic: msg.topic
1067
+ });
1068
+ this.node.services.pubsub.reportMessageValidationResult(msgId, source.toString(), TopicValidatorResult.Ignore);
1069
+ return;
1070
+ }
988
1071
  if (msg.topic === this.topicStrings[TopicType.tx]) {
989
1072
  await this.handleGossipedTx(p2pMessage.payload, msgId, source);
990
1073
  } else if (msg.topic === this.topicStrings[TopicType.checkpoint_attestation]) {
@@ -1033,29 +1116,79 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1033
1116
  return;
1034
1117
  }
1035
1118
  async validateReceivedMessage(validationFunc, msgId, source, topicType) {
1119
+ // Default to reject result with a penalty if validation function throws an error
1036
1120
  let resultAndObj = {
1037
- result: TopicValidatorResult.Reject
1121
+ result: TopicValidatorResult.Reject,
1122
+ severity: PeerErrorSeverity.MidToleranceError
1038
1123
  };
1039
1124
  const timer = new Timer();
1040
1125
  try {
1041
1126
  resultAndObj = await validationFunc();
1042
1127
  } catch (err) {
1043
- this.peerManager.penalizePeer(source, PeerErrorSeverity.LowToleranceError);
1044
- this.logger.error(`Error deserializing and validating gossipsub message`, err, {
1128
+ this.logger.error(`Error validating gossipsub message`, err, {
1045
1129
  msgId,
1046
1130
  source: source.toString(),
1047
1131
  topicType
1048
1132
  });
1049
1133
  }
1134
+ const validationTimeMs = timer.ms();
1135
+ const mcacheWindowMs = this.config.gossipsubMcacheLength * this.config.gossipsubInterval;
1136
+ if (validationTimeMs > mcacheWindowMs * 0.75) {
1137
+ this.instrumentation.incSlowValidation(topicType);
1138
+ this.logger.warn(`Gossip validation for ${topicType} took ${validationTimeMs}ms, approaching mcache eviction window of ${mcacheWindowMs}ms. ` + `Message forwarding may be skipped if validation exceeds the window.`, {
1139
+ msgId,
1140
+ source: source.toString(),
1141
+ topicType,
1142
+ validationTimeMs,
1143
+ mcacheWindowMs
1144
+ });
1145
+ }
1050
1146
  if (resultAndObj.result === TopicValidatorResult.Accept) {
1147
+ this.logger.debug(`Message ${topicType} accepted by validator`, {
1148
+ msgId,
1149
+ source: source.toString(),
1150
+ topicType
1151
+ });
1051
1152
  this.instrumentation.recordMessageValidation(topicType, timer);
1153
+ } else if (resultAndObj.result === TopicValidatorResult.Reject) {
1154
+ this.logger.warn(`Message ${topicType} rejected by validator with severity ${resultAndObj.severity}`, {
1155
+ msgId,
1156
+ source: source.toString(),
1157
+ topicType,
1158
+ severity: resultAndObj.severity
1159
+ });
1160
+ this.peerManager.penalizePeer(source, resultAndObj.severity);
1161
+ } else {
1162
+ this.logger.trace(`Message ${topicType} ignored by validator`, {
1163
+ msgId,
1164
+ source: source.toString(),
1165
+ topicType
1166
+ });
1052
1167
  }
1053
1168
  this.node.services.pubsub.reportMessageValidationResult(msgId, source.toString(), resultAndObj.result);
1054
1169
  return resultAndObj;
1055
1170
  }
1171
+ tryDeserialize(deserializeFunc, msgId, source) {
1172
+ try {
1173
+ return deserializeFunc();
1174
+ } catch (err) {
1175
+ this.logger.warn(`Failed to deserialize gossipsub message from buffer`, {
1176
+ err,
1177
+ msgId,
1178
+ source: source.toString()
1179
+ });
1180
+ return undefined;
1181
+ }
1182
+ }
1056
1183
  async handleGossipedTx(payloadData, msgId, source) {
1057
1184
  const validationFunc = async ()=>{
1058
- const tx = Tx.fromBuffer(payloadData);
1185
+ const tx = this.tryDeserialize(()=>Tx.fromBuffer(payloadData), msgId, source);
1186
+ if (!tx) {
1187
+ return {
1188
+ result: TopicValidatorResult.Reject,
1189
+ severity: PeerErrorSeverity.LowToleranceError
1190
+ };
1191
+ }
1059
1192
  const currentBlockNumber = await this.archiver.getBlockNumber();
1060
1193
  const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
1061
1194
  // Stage 1: fast validators (metadata, data, timestamps, double-spend, gas, phases, block header)
@@ -1071,14 +1204,22 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1071
1204
  const txBlockNumber = BlockNumber(currentBlockNumber + 1);
1072
1205
  severity = await this.handleDoubleSpendFailure(tx, txBlockNumber);
1073
1206
  }
1074
- this.peerManager.penalizePeer(source, severity);
1207
+ this.logger.verbose(`Rejecting gossiped tx ${tx.getTxHash().toString()}: stage 1 validation failed`, {
1208
+ validator: name,
1209
+ severity,
1210
+ source: source.toString()
1211
+ });
1075
1212
  return {
1076
- result: TopicValidatorResult.Reject
1213
+ result: TopicValidatorResult.Reject,
1214
+ severity
1077
1215
  };
1078
1216
  }
1079
1217
  // Pool pre-check: see if the pool would accept this tx before doing expensive proof verification
1080
1218
  const canAdd = await this.mempools.txPool.canAddPendingTx(tx);
1081
1219
  if (canAdd === 'ignored') {
1220
+ this.logger.verbose(`Ignoring gossiped tx ${tx.getTxHash().toString()}: pool pre-check returned ignored`, {
1221
+ source: source.toString()
1222
+ });
1082
1223
  return {
1083
1224
  result: TopicValidatorResult.Ignore,
1084
1225
  obj: tx
@@ -1088,10 +1229,15 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1088
1229
  const secondStageValidators = this.createSecondStageMessageValidators();
1089
1230
  const secondStageOutcome = await this.runValidations(tx, secondStageValidators);
1090
1231
  if (!secondStageOutcome.allPassed) {
1091
- const { severity } = secondStageOutcome.failure;
1092
- this.peerManager.penalizePeer(source, severity);
1232
+ const { severity, name } = secondStageOutcome.failure;
1233
+ this.logger.verbose(`Rejecting gossiped tx ${tx.getTxHash().toString()}: stage 2 validation failed`, {
1234
+ validator: name,
1235
+ severity,
1236
+ source: source.toString()
1237
+ });
1093
1238
  return {
1094
- result: TopicValidatorResult.Reject
1239
+ result: TopicValidatorResult.Reject,
1240
+ severity
1095
1241
  };
1096
1242
  }
1097
1243
  // Pool add: persist the tx
@@ -1103,7 +1249,7 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1103
1249
  });
1104
1250
  const wasAccepted = addResult.accepted.some((h)=>h.equals(txHash));
1105
1251
  const wasIgnored = addResult.ignored.some((h)=>h.equals(txHash));
1106
- this.logger.trace(`Validate propagated tx`, {
1252
+ this.logger.verbose(`Validate propagated tx ${txHash.toString()}`, {
1107
1253
  wasAccepted,
1108
1254
  wasIgnored,
1109
1255
  [Attributes.P2P_ID]: source.toString()
@@ -1119,8 +1265,13 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1119
1265
  obj: tx
1120
1266
  };
1121
1267
  } else {
1268
+ this.logger.warn(`Gossiped tx ${txHash.toString()} unexpectedly rejected by pool`, {
1269
+ source: source.toString(),
1270
+ txHash: txHash.toString()
1271
+ });
1122
1272
  return {
1123
- result: TopicValidatorResult.Reject
1273
+ result: TopicValidatorResult.Reject,
1274
+ severity: PeerErrorSeverity.HighToleranceError
1124
1275
  };
1125
1276
  }
1126
1277
  };
@@ -1141,7 +1292,16 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1141
1292
  * Process a checkpoint attestation from a peer.
1142
1293
  * Validates the attestation and adds it to the pool.
1143
1294
  */ async processCheckpointAttestationFromPeer(payloadData, msgId, source) {
1144
- const { result, obj: attestation } = await this.validateReceivedMessage(()=>this.validateAndStoreCheckpointAttestation(source, CheckpointAttestation.fromBuffer(payloadData)), msgId, source, TopicType.checkpoint_attestation);
1295
+ const { result, obj: attestation } = await this.validateReceivedMessage(()=>{
1296
+ const attestation = this.tryDeserialize(()=>CheckpointAttestation.fromBuffer(payloadData), msgId, source);
1297
+ if (!attestation) {
1298
+ return Promise.resolve({
1299
+ result: TopicValidatorResult.Reject,
1300
+ severity: PeerErrorSeverity.LowToleranceError
1301
+ });
1302
+ }
1303
+ return this.validateAndStoreCheckpointAttestation(source, attestation);
1304
+ }, msgId, source, TopicType.checkpoint_attestation);
1145
1305
  if (result !== TopicValidatorResult.Accept || !attestation) {
1146
1306
  return;
1147
1307
  }
@@ -1156,9 +1316,9 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1156
1316
  const validationResult = await this.checkpointAttestationValidator.validate(attestation);
1157
1317
  if (validationResult.result === 'reject') {
1158
1318
  this.logger.warn(`Penalizing peer ${peerId} for checkpoint attestation validation failure`);
1159
- this.peerManager.penalizePeer(peerId, validationResult.severity);
1160
1319
  return {
1161
- result: TopicValidatorResult.Reject
1320
+ result: TopicValidatorResult.Reject,
1321
+ severity: validationResult.severity
1162
1322
  };
1163
1323
  }
1164
1324
  if (validationResult.result === 'ignore') {
@@ -1185,9 +1345,9 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1185
1345
  obj: attestation
1186
1346
  };
1187
1347
  }
1188
- // Could not add (cap reached for signer), no need to re-broadcast
1348
+ // Could not add (cap reached for signer), penalize and do not re-broadcast
1189
1349
  if (!added) {
1190
- this.logger.warn(`Dropping checkpoint attestation due to cap`, {
1350
+ this.logger.warn(`Rejecting checkpoint attestation due to cap`, {
1191
1351
  slot: slot.toString(),
1192
1352
  archive: attestation.archive.toString(),
1193
1353
  source: peerId.toString(),
@@ -1195,8 +1355,8 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1195
1355
  count
1196
1356
  });
1197
1357
  return {
1198
- result: TopicValidatorResult.Ignore,
1199
- obj: attestation
1358
+ result: TopicValidatorResult.Reject,
1359
+ severity: PeerErrorSeverity.HighToleranceError
1200
1360
  };
1201
1361
  }
1202
1362
  // Check if this is a duplicate attestation (signer attested to a different proposal at the same slot)
@@ -1217,15 +1377,17 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1217
1377
  }
1218
1378
  }
1219
1379
  // Attestation was added successfully - accept it so other nodes can also detect the equivocation
1380
+ this.checkpointAttestationCallback?.(attestation);
1220
1381
  return {
1221
1382
  result: TopicValidatorResult.Accept,
1222
1383
  obj: attestation
1223
1384
  };
1224
1385
  }
1225
1386
  async processBlockFromPeer(payloadData, msgId, source) {
1226
- const { result, obj: block, metadata: { isEquivocated } = {} } = await this.validateReceivedMessage(()=>this.validateAndStoreBlockProposal(source, BlockProposal.fromBuffer(payloadData)), msgId, source, TopicType.block_proposal);
1227
- // If not accepted or equivocated, return
1228
- if (result !== TopicValidatorResult.Accept || !block || isEquivocated) {
1387
+ const { result, obj: block, metadata: { isEquivocated, isOversized } = {} } = await this.validateReceivedMessage(()=>this.validateAndStoreBlockProposal(source, BlockProposal.fromBuffer(payloadData)), msgId, source, TopicType.block_proposal);
1388
+ // If not accepted, equivocated, or oversized, return. Oversized proposals are re-broadcast as
1389
+ // slashing evidence but never attested or processed.
1390
+ if (result !== TopicValidatorResult.Accept || !block || isEquivocated || isOversized) {
1229
1391
  return;
1230
1392
  }
1231
1393
  await this.processValidBlockProposal(block, source);
@@ -1234,9 +1396,9 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1234
1396
  const validationResult = await this.blockProposalValidator.validate(block);
1235
1397
  if (validationResult.result === 'reject') {
1236
1398
  this.logger.warn(`Penalizing peer ${peerId} for block proposal validation failure`);
1237
- this.peerManager.penalizePeer(peerId, validationResult.severity);
1238
1399
  return {
1239
- result: TopicValidatorResult.Reject
1400
+ result: TopicValidatorResult.Reject,
1401
+ severity: validationResult.severity
1240
1402
  };
1241
1403
  }
1242
1404
  if (validationResult.result === 'ignore') {
@@ -1248,6 +1410,10 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1248
1410
  // Try to add the proposal: this handles existence check, cap check, and adding in one call
1249
1411
  const { added, alreadyExists, count } = await this.mempools.attestationPool.tryAddBlockProposal(block);
1250
1412
  const isEquivocated = count !== undefined && count > 1;
1413
+ // An oversized proposal (index at or beyond the consensus per-checkpoint limit) is structurally valid
1414
+ // proposer misbehavior: it is stored and re-broadcast as slashing evidence but never processed or
1415
+ // attested to. No-ops when maxBlocksPerCheckpoint is unset (local/test).
1416
+ const isOversized = this.config.maxBlocksPerCheckpoint !== undefined && block.indexWithinCheckpoint >= this.config.maxBlocksPerCheckpoint;
1251
1417
  // Duplicate proposal received, no need to re-broadcast
1252
1418
  if (alreadyExists) {
1253
1419
  this.logger.debug(`Ignoring duplicate block proposal received`, {
@@ -1260,13 +1426,13 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1260
1426
  result: TopicValidatorResult.Ignore,
1261
1427
  obj: block,
1262
1428
  metadata: {
1263
- isEquivocated
1429
+ isEquivocated,
1430
+ isOversized
1264
1431
  }
1265
1432
  };
1266
1433
  }
1267
1434
  // Too many blocks received for this slot and index, penalize peer and do not re-broadcast
1268
1435
  if (!added) {
1269
- this.peerManager.penalizePeer(peerId, PeerErrorSeverity.HighToleranceError);
1270
1436
  this.logger.warn(`Penalizing peer for block proposal exceeding per-position cap`, {
1271
1437
  ...block.toBlockInfo(),
1272
1438
  indexWithinCheckpoint: block.indexWithinCheckpoint,
@@ -1277,10 +1443,30 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1277
1443
  return {
1278
1444
  result: TopicValidatorResult.Reject,
1279
1445
  metadata: {
1280
- isEquivocated
1281
- }
1446
+ isEquivocated,
1447
+ isOversized
1448
+ },
1449
+ severity: PeerErrorSeverity.HighToleranceError
1282
1450
  };
1283
1451
  }
1452
+ // The proposal was stored: if oversized, invoke the oversized callback so the proposer can be
1453
+ // slashed. Fired alongside (not instead of) equivocation detection below.
1454
+ if (isOversized) {
1455
+ const proposer = block.getSender();
1456
+ if (proposer) {
1457
+ this.logger.warn(`Detected oversized block proposal at slot ${block.slotNumber}`, {
1458
+ ...block.toBlockInfo(),
1459
+ indexWithinCheckpoint: block.indexWithinCheckpoint,
1460
+ maxBlocksPerCheckpoint: this.config.maxBlocksPerCheckpoint,
1461
+ source: peerId.toString(),
1462
+ proposer: proposer.toString()
1463
+ });
1464
+ this.oversizedProposalCallback?.({
1465
+ slot: block.slotNumber,
1466
+ proposer
1467
+ });
1468
+ }
1469
+ }
1284
1470
  // If this was a duplicate proposal, do not process it, but do invoke the duplicate callback,
1285
1471
  // and do re-broadcast it so other nodes in the network know to slash the proposer
1286
1472
  if (isEquivocated) {
@@ -1302,14 +1488,19 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1302
1488
  result: TopicValidatorResult.Accept,
1303
1489
  obj: block,
1304
1490
  metadata: {
1305
- isEquivocated
1491
+ isEquivocated,
1492
+ isOversized
1306
1493
  }
1307
1494
  };
1308
1495
  }
1309
1496
  // Otherwise, we're good to go!
1310
1497
  return {
1311
1498
  result: TopicValidatorResult.Accept,
1312
- obj: block
1499
+ obj: block,
1500
+ metadata: {
1501
+ isEquivocated: false,
1502
+ isOversized
1503
+ }
1313
1504
  };
1314
1505
  }
1315
1506
  // REFACTOR(palla): This method should be moved to the p2p_client or to a separate component,
@@ -1323,27 +1514,53 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1323
1514
  });
1324
1515
  // Mark the txs in this proposal as protected
1325
1516
  await this.mempools.txPool.protectTxs(block.txHashes, block.blockHeader);
1326
- // Call the block received callback to validate the proposal.
1327
- // Note: Validators do NOT attest to individual blocks, only to checkpoint proposals.
1328
- const isValid = await this.blockReceivedCallback(block, sender);
1329
- if (!isValid) {
1330
- this.logger.warn(`Block proposal validation failed for block ${block.blockNumber}`, block.toBlockInfo());
1517
+ if (!await this.tryBlockReceivedCallback(block, sender)) {
1518
+ // Release the protections this proposal created so its txs return to pending. Only entries still
1519
+ // keyed to this slot are cleared, so a tx referenced by a live proposal at another slot stays protected.
1520
+ await this.mempools.txPool.unprotectTxs(block.txHashes, slot);
1521
+ }
1522
+ }
1523
+ /**
1524
+ * Runs the block received callback to validate a proposal, and returns whether it was accepted.
1525
+ * A callback that throws is reported as a rejection: the proposal is no more usable than one explicitly
1526
+ * rejected, and letting the error escape would leave the proposal's tx protections in place.
1527
+ * Note: Validators do NOT attest to individual blocks, only to checkpoint proposals.
1528
+ */ async tryBlockReceivedCallback(block, sender) {
1529
+ try {
1530
+ const isValid = await this.blockReceivedCallback(block, sender);
1531
+ if (!isValid) {
1532
+ this.logger.info(`Block proposal validation failed for block ${block.blockNumber}`, block.toBlockInfo());
1533
+ }
1534
+ return isValid;
1535
+ } catch (err) {
1536
+ this.logger.error(`Error validating block proposal for block ${block.blockNumber}`, err, block.toBlockInfo());
1537
+ return false;
1331
1538
  }
1332
1539
  }
1333
1540
  /**
1334
1541
  * Handle a gossiped checkpoint proposal.
1335
1542
  * Validates and processes the checkpoint proposal, then triggers the callback for attestation.
1336
1543
  */ async handleGossipedCheckpointProposal(payloadData, msgId, source) {
1337
- const { result, obj: checkpoint, metadata: { isEquivocated, processBlock } = {} } = await this.validateReceivedMessage(()=>this.validateAndStoreCheckpointProposal(source, CheckpointProposal.fromBuffer(payloadData)), msgId, source, TopicType.checkpoint_proposal);
1544
+ const { result, obj: checkpoint, metadata: { isEquivocated, processBlock, isOversized } = {} } = await this.validateReceivedMessage(()=>this.validateAndStoreCheckpointProposal(source, CheckpointProposal.fromBuffer(payloadData)), msgId, source, TopicType.checkpoint_proposal);
1545
+ // An oversized checkpoint is re-broadcast as slashing evidence but never attested or processed.
1546
+ // Process checkpoint proposal if valid and neither equivocated nor oversized.
1547
+ const processCheckpointFn = ()=>result === TopicValidatorResult.Accept && checkpoint && !isEquivocated && !isOversized ? this.processValidCheckpointProposal(checkpoint.toCore(), source) : Promise.resolve();
1338
1548
  // If the checkpoint contained a valid last block, we process it even if the checkpoint itself is to be rejected
1339
1549
  // TODO(palla/mbps): Is this ok? Should we be considering a block from a checkpoint that was equivocated?
1340
- if (processBlock && checkpoint?.getBlockProposal()) {
1341
- await this.processValidBlockProposal(checkpoint.getBlockProposal(), source);
1342
- }
1343
- if (result !== TopicValidatorResult.Accept || !checkpoint || isEquivocated) {
1550
+ const processBlockFn = ()=>processBlock && checkpoint && checkpoint.getBlockProposal() ? this.processValidBlockProposal(checkpoint.getBlockProposal(), source) : Promise.resolve();
1551
+ // A node that skips checkpoint validation attests without re-executing the embedded last block, so run
1552
+ // the checkpoint callback first: this creates and broadcasts the attestation before the block is
1553
+ // processed. Otherwise the block's re-execution — which can stall until the re-execution deadline
1554
+ // waiting for a parent that may never arrive — would delay the attestation past the slot's attestation
1555
+ // window, after which peers reject it as stale.
1556
+ if (this.config.skipCheckpointProposalValidation) {
1557
+ await processCheckpointFn();
1558
+ await processBlockFn();
1344
1559
  return;
1345
1560
  }
1346
- await this.processValidCheckpointProposal(checkpoint.toCore(), source);
1561
+ // Process the block first, since it's required for the checkpoint proposal validation.
1562
+ await processBlockFn();
1563
+ await processCheckpointFn();
1347
1564
  }
1348
1565
  /**
1349
1566
  * Validates a checkpoint proposal. Penalizes peer if validation fails. Adds the checkpoint and
@@ -1352,9 +1569,9 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1352
1569
  const validationResult = await this.checkpointProposalValidator.validate(checkpoint);
1353
1570
  if (validationResult.result === 'reject') {
1354
1571
  this.logger.warn(`Penalizing peer ${peerId} for checkpoint proposal validation failure`);
1355
- this.peerManager.penalizePeer(peerId, validationResult.severity);
1356
1572
  return {
1357
- result: TopicValidatorResult.Reject
1573
+ result: TopicValidatorResult.Reject,
1574
+ severity: validationResult.severity
1358
1575
  };
1359
1576
  }
1360
1577
  if (validationResult.result === 'ignore') {
@@ -1366,23 +1583,28 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1366
1583
  // Extract and try to add the block proposal first if present
1367
1584
  const blockProposal = checkpoint.getBlockProposal();
1368
1585
  let processBlock = false;
1586
+ let isOversized = false;
1369
1587
  if (blockProposal) {
1370
1588
  this.logger.debug(`Validating block proposal from propagated checkpoint`, {
1371
1589
  [Attributes.SLOT_NUMBER]: checkpoint.slotNumber.toString(),
1372
1590
  [Attributes.P2P_ID]: peerId.toString()
1373
1591
  });
1374
- const { result, obj, metadata: { isEquivocated } = {} } = await this.validateAndStoreBlockProposal(peerId, blockProposal);
1375
- if (result === TopicValidatorResult.Reject || !obj || isEquivocated) {
1592
+ const blockProposalResult = await this.validateAndStoreBlockProposal(peerId, blockProposal);
1593
+ const { obj, metadata: { isEquivocated, isOversized: blockIsOversized } = {} } = blockProposalResult;
1594
+ isOversized = blockIsOversized ?? false;
1595
+ if (blockProposalResult.result === TopicValidatorResult.Reject || !obj || isEquivocated) {
1376
1596
  this.logger.debug(`Rejecting checkpoint due to invalid last block proposal`, {
1377
1597
  [Attributes.SLOT_NUMBER]: checkpoint.slotNumber.toString(),
1378
1598
  [Attributes.P2P_ID]: peerId.toString(),
1379
1599
  isEquivocated,
1380
- result
1600
+ result: blockProposalResult.result
1381
1601
  });
1382
1602
  return {
1383
- result: TopicValidatorResult.Reject
1603
+ result: TopicValidatorResult.Reject,
1604
+ severity: 'severity' in blockProposalResult ? blockProposalResult.severity : PeerErrorSeverity.MidToleranceError
1384
1605
  };
1385
- } else if (result === TopicValidatorResult.Accept && obj && !isEquivocated) {
1606
+ } else if (blockProposalResult.result === TopicValidatorResult.Accept && obj && !isEquivocated && !isOversized) {
1607
+ // An oversized terminal block is re-broadcast as slashing evidence but never processed.
1386
1608
  processBlock = true;
1387
1609
  }
1388
1610
  }
@@ -1402,14 +1624,14 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1402
1624
  obj: checkpoint,
1403
1625
  metadata: {
1404
1626
  isEquivocated,
1405
- processBlock
1627
+ processBlock,
1628
+ isOversized
1406
1629
  }
1407
1630
  };
1408
1631
  }
1409
- // Too many checkpoint proposals received for this slot, penalize peer and do not re-broadcast
1632
+ // Too many checkpoint proposals received for this slot, penalize peer and do not re-broadcast.
1410
1633
  // Note: We still return the checkpoint obj so the lastBlock can be processed if valid
1411
1634
  if (!added) {
1412
- this.peerManager.penalizePeer(peerId, PeerErrorSeverity.HighToleranceError);
1413
1635
  this.logger.warn(`Penalizing peer for checkpoint proposal exceeding per-slot cap`, {
1414
1636
  ...checkpoint.toCheckpointInfo(),
1415
1637
  count,
@@ -1420,8 +1642,10 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1420
1642
  obj: checkpoint,
1421
1643
  metadata: {
1422
1644
  isEquivocated,
1423
- processBlock
1424
- }
1645
+ processBlock,
1646
+ isOversized
1647
+ },
1648
+ severity: PeerErrorSeverity.HighToleranceError
1425
1649
  };
1426
1650
  }
1427
1651
  // If this was a duplicate proposal, do not process it, but do invoke the duplicate callback,
@@ -1446,7 +1670,8 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1446
1670
  obj: checkpoint,
1447
1671
  metadata: {
1448
1672
  isEquivocated,
1449
- processBlock
1673
+ processBlock,
1674
+ isOversized
1450
1675
  }
1451
1676
  };
1452
1677
  }
@@ -1456,7 +1681,8 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1456
1681
  obj: checkpoint,
1457
1682
  metadata: {
1458
1683
  processBlock,
1459
- isEquivocated
1684
+ isEquivocated,
1685
+ isOversized
1460
1686
  }
1461
1687
  };
1462
1688
  }
@@ -1471,9 +1697,10 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1471
1697
  archive: checkpoint.archive.toString(),
1472
1698
  source: sender.toString()
1473
1699
  });
1700
+ await this.allNodesCheckpointReceivedCallback(checkpoint, sender);
1474
1701
  // Call the checkpoint received callback with the core version (without lastBlock)
1475
1702
  // to validate and potentially generate attestations
1476
- const attestations = await this.checkpointReceivedCallback(checkpoint, sender);
1703
+ const attestations = await this.validatorCheckpointReceivedCallback(checkpoint, sender);
1477
1704
  if (attestations && attestations.length > 0) {
1478
1705
  // If the callback returned attestations, add them to the pool and propagate them
1479
1706
  await this.mempools.attestationPool.addOwnCheckpointAttestations(attestations);
@@ -1497,62 +1724,66 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1497
1724
  });
1498
1725
  }
1499
1726
  /**
1500
- * Validate the requested block transactions. Allow partial returns.
1727
+ * Validate the requested block transactions request-response consistency.
1728
+ * It does NOT validate the transactions themselves.
1501
1729
  * @param request - The block transactions request.
1502
1730
  * @param response - The block transactions response.
1503
1731
  * @param peerId - The ID of the peer that made the request.
1504
- * @returns True if the requested block transactions are valid, false otherwise.
1505
- */ async validateRequestedBlockTxs(request, response, peerId) {
1506
- const requestedTxValidator = this.createRequestedTxValidator();
1732
+ * @returns True if the request-response is consistent, false otherwise.
1733
+ */ async validateRequestedBlockTxsConsistency(request, response, peerId) {
1507
1734
  try {
1508
- if (!response.archiveRoot.equals(request.archiveRoot)) {
1509
- this.peerManager.penalizePeer(peerId, PeerErrorSeverity.MidToleranceError);
1510
- throw new ValidationError(`Received block txs for unexpected archive root: expected ${request.archiveRoot.toString()}, got ${response.archiveRoot.toString()}`);
1511
- }
1512
- if (response.txIndices.getLength() !== request.txIndices.getLength()) {
1513
- this.peerManager.penalizePeer(peerId, PeerErrorSeverity.MidToleranceError);
1514
- throw new ValidationError(`Received block txs with mismatched bitvector length: expected ${request.txIndices.getLength()}, got ${response.txIndices.getLength()}`);
1515
- }
1516
- // Check no duplicates and not exceeding returnable count
1517
- const requestedIndices = new Set(request.txIndices.getTrueIndices());
1518
- const availableIndices = new Set(response.txIndices.getTrueIndices());
1519
- const maxReturnable = [
1520
- ...requestedIndices
1521
- ].filter((i)=>availableIndices.has(i)).length;
1522
- const returnedHashes = await Promise.all(response.txs.map((tx)=>tx.getTxHash().toString()));
1735
+ // Check for duplicates txs (or hashes) in the response.
1736
+ const returnedHashes = response.txs.map((tx)=>tx.getTxHash().toString());
1523
1737
  const uniqueReturned = new Set(returnedHashes.map((h)=>h.toString()));
1524
1738
  if (uniqueReturned.size !== returnedHashes.length) {
1525
1739
  this.peerManager.penalizePeer(peerId, PeerErrorSeverity.MidToleranceError);
1526
1740
  throw new ValidationError(`Received duplicate txs in block txs response`);
1527
1741
  }
1528
- if (response.txs.length > maxReturnable) {
1742
+ // We get the block tx hashes from the proposal or the archiver.
1743
+ const proposal = await this.mempools.attestationPool.getBlockProposalByArchive(request.archiveRoot.toString());
1744
+ const blockTxHashes = proposal?.txHashes ?? (await this.archiver.getBlock({
1745
+ archive: request.archiveRoot
1746
+ }))?.body.txEffects.map((e)=>e.txHash);
1747
+ // If we don't have the block, we can't verify membership/order of the returned txs.
1748
+ if (!blockTxHashes) {
1749
+ // This shouldn't happen, since we asked for the block (proposal).
1750
+ // Neither a local proposal nor an archived block: we cannot verify membership/order of the
1751
+ // returned txs. This is a local-state gap, not a peer fault, so we do not penalize.
1752
+ this.logger.warn(`Block ${request.archiveRoot.toString()} not found in attestation pool or archiver; cannot validate membership/order of returned txs`);
1753
+ // NOTE: We mark the response as invalid, given the limitations of a true/false return value.
1754
+ return false;
1755
+ }
1756
+ // Verify that the returned tx hashes are a subset of (tx hashes by index) U (explicitly requested tx hashes).
1757
+ const uniqueRequestedHashes = new Set([
1758
+ // tx hashes requested by index.
1759
+ ...request.txIndices.getTrueIndices().map((i)=>blockTxHashes[i].toString()),
1760
+ // explicitly requested tx hashes.
1761
+ ...request.txHashes.map((h)=>h.toString())
1762
+ ]);
1763
+ if (!returnedHashes.every((h)=>uniqueRequestedHashes.has(h))) {
1764
+ this.peerManager.penalizePeer(peerId, PeerErrorSeverity.LowToleranceError);
1765
+ throw new ValidationError('Returned txs should be a subset of (tx hashes by index) U (explicitly requested tx hashes)');
1766
+ }
1767
+ // Tx indices information is optional, but if present, we need to verify a few things.
1768
+ if (!response.peerHasBlock()) {
1769
+ this.logger.debug(`Peer ${peerId.toString()} signalled missing block`);
1770
+ return true;
1771
+ }
1772
+ // If the response has a non-empty bitvector, it needs to be consistent with the number of txs in the block.
1773
+ if (response.txIndices.getLength() !== blockTxHashes.length) {
1529
1774
  this.peerManager.penalizePeer(peerId, PeerErrorSeverity.MidToleranceError);
1530
- throw new ValidationError(`Received more txs (${response.txs.length}) than requested-and-available (${maxReturnable})`);
1775
+ throw new ValidationError(`Received block txs with mismatched bitvector length: expected ${blockTxHashes.length}, got ${response.txIndices.getLength()}`);
1531
1776
  }
1532
- // Given proposal (should have locally), ensure returned txs are valid subset and match request indices
1533
- const proposal = await this.mempools.attestationPool.getBlockProposal(request.archiveRoot.toString());
1534
- if (proposal) {
1535
- // Build intersected indices
1536
- const intersectIdx = request.txIndices.getTrueIndices().filter((i)=>response.txIndices.isSet(i));
1537
- // Enforce subset membership and preserve increasing order by index.
1538
- const hashToIndexInProposal = new Map(proposal.txHashes.map((h, i)=>[
1539
- h.toString(),
1540
- i
1541
- ]));
1542
- const allowedIndexSet = new Set(intersectIdx);
1543
- const indices = returnedHashes.map((h)=>hashToIndexInProposal.get(h));
1544
- const allAllowed = indices.every((idx)=>idx !== undefined && allowedIndexSet.has(idx));
1545
- const strictlyIncreasing = indices.every((idx, i)=>i === 0 ? idx !== undefined : idx > indices[i - 1]);
1546
- if (!allAllowed || !strictlyIncreasing) {
1547
- this.peerManager.penalizePeer(peerId, PeerErrorSeverity.LowToleranceError);
1548
- throw new ValidationError('Returned txs do not match expected subset/order for requested indices');
1549
- }
1550
- } else {
1551
- // No local proposal, cannot check the membership/order of the returned txs
1552
- this.logger.warn(`Block proposal not found for archive root ${request.archiveRoot.toString()}; cannot validate membership/order of returned txs`);
1553
- return false;
1777
+ // For every index we requested that the peer claims to have (per its bitvector), the
1778
+ // corresponding tx must be present in the response. A peer advertising availability but
1779
+ // withholding the tx is inconsistent.
1780
+ const returnedHashSet = new Set(returnedHashes);
1781
+ const expectedIndices = request.txIndices.getTrueIndices().filter((i)=>response.txIndices.isSet(i));
1782
+ const missingExpected = expectedIndices.some((i)=>!returnedHashSet.has(blockTxHashes[i].toString()));
1783
+ if (missingExpected) {
1784
+ this.peerManager.penalizePeer(peerId, PeerErrorSeverity.LowToleranceError);
1785
+ throw new ValidationError('Peer advertised requested txs via indices but did not return them');
1554
1786
  }
1555
- await Promise.all(response.txs.map((tx)=>this.validateRequestedTx(tx, peerId, requestedTxValidator)));
1556
1787
  return true;
1557
1788
  } catch (e) {
1558
1789
  if (e instanceof ValidationError) {
@@ -1563,104 +1794,8 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1563
1794
  return false;
1564
1795
  }
1565
1796
  }
1566
- /**
1567
- * Validate a collection of txs that has been requested from a peer.
1568
- *
1569
- * The core component of this validator is that each tx hash MUST match the requested tx hash,
1570
- * In order to perform this check, the tx proof must be verified.
1571
- *
1572
- * Note: This function is called from within `ReqResp.sendRequest` as part of the
1573
- * ReqRespSubProtocol.TX subprotocol validation.
1574
- *
1575
- * @param requestedTxHash - The collection of the txs that was requested.
1576
- * @param responseTx - The collection of txs that was received as a response to the request.
1577
- * @param peerId - The peer ID of the peer that sent the tx.
1578
- * @returns True if the whole collection of txs is valid, false otherwise.
1579
- */ async validateRequestedTxs(requestedTxHash, responseTx, peerId) {
1580
- const requested = new Set(requestedTxHash.map((h)=>h.toString()));
1581
- const requestedTxValidator = this.createRequestedTxValidator();
1582
- //TODO: (mralj) - this is somewhat naive implementation, if single tx is invalid we consider the whole response invalid.
1583
- // I think we should still extract the valid txs and return them, so that we can still use the response.
1584
- try {
1585
- await Promise.all(responseTx.map((tx)=>this.validateRequestedTx(tx, peerId, requestedTxValidator, requested)));
1586
- return true;
1587
- } catch (e) {
1588
- if (e instanceof ValidationError) {
1589
- this.logger.warn(`Failed to validate requested txs from peer ${peerId.toString()}, reason ${e.message}`);
1590
- } else {
1591
- this.logger.error(`Error during validation of requested txs`, e);
1592
- }
1593
- return false;
1594
- }
1595
- }
1596
- /**
1597
- * Validates a BLOCK response.
1598
- *
1599
- * If a local copy exists, enforces hash equality. If missing, rejects (no penalty) since the hash cannot be verified.
1600
- * Penalizes on block number mismatch or hash mismatch.
1601
- *
1602
- * @param requestedBlockNumber - The requested block number.
1603
- * @param responseBlock - The block returned by the peer.
1604
- * @param peerId - The peer that returned the block.
1605
- * @returns True if the response is valid, false otherwise.
1606
- */ async validateRequestedBlock(requestedBlockNumber, responseBlock, peerId) {
1607
- try {
1608
- const reqNum = Number(requestedBlockNumber.toString());
1609
- if (responseBlock.number !== reqNum) {
1610
- this.peerManager.penalizePeer(peerId, PeerErrorSeverity.LowToleranceError);
1611
- return false;
1612
- }
1613
- const local = await this.archiver.getBlock(BlockNumber(reqNum));
1614
- if (!local) {
1615
- // We are missing the local block; we cannot verify the hash yet. Reject without penalizing.
1616
- // TODO: Consider extending this validator to accept an expected hash or
1617
- // performing quorum-based checks when using P2P syncing prior to L1 sync.
1618
- this.logger.warn(`Local block ${reqNum} not found; rejecting BLOCK response without hash verification`);
1619
- return false;
1620
- }
1621
- const [localHash, respHash] = await Promise.all([
1622
- local.hash(),
1623
- responseBlock.hash()
1624
- ]);
1625
- if (!localHash.equals(respHash)) {
1626
- this.peerManager.penalizePeer(peerId, PeerErrorSeverity.MidToleranceError);
1627
- return false;
1628
- }
1629
- return true;
1630
- } catch (e) {
1631
- this.logger.warn(`Error validating requested block`, e);
1632
- return false;
1633
- }
1634
- }
1635
- async validateRequestedTx(tx, peerId, txValidator, requested) {
1636
- const penalize = (severity)=>this.peerManager.penalizePeer(peerId, severity);
1637
- if (requested && !requested.has(tx.getTxHash().toString())) {
1638
- penalize(PeerErrorSeverity.MidToleranceError);
1639
- throw new ValidationError(`Received tx with hash ${tx.getTxHash().toString()} that was not requested.`);
1640
- }
1641
- const { result } = await txValidator.validateTx(tx);
1642
- if (result === 'invalid') {
1643
- penalize(PeerErrorSeverity.LowToleranceError);
1644
- throw new ValidationError(`Received tx with hash ${tx.getTxHash().toString()} that is invalid.`);
1645
- }
1646
- }
1647
- createRequestedTxValidator() {
1648
- return createTxValidatorForReqResponseReceivedTxs(this.proofVerifier, {
1649
- l1ChainId: this.config.l1ChainId,
1650
- rollupVersion: this.config.rollupVersion
1651
- });
1652
- }
1653
- async getGasFees(blockNumber) {
1654
- if (blockNumber === this.feesCache?.blockNumber) {
1655
- return this.feesCache.gasFees;
1656
- }
1657
- const header = await this.archiver.getBlockHeader(blockNumber);
1658
- const gasFees = header?.globalVariables.gasFees ?? GasFees.empty();
1659
- this.feesCache = {
1660
- blockNumber,
1661
- gasFees
1662
- };
1663
- return gasFees;
1797
+ getGasFees() {
1798
+ return this.blockMinFeesProvider.getCurrentMinFees();
1664
1799
  }
1665
1800
  /**
1666
1801
  * Get the BatchTxRequesterLibP2PService dependencies for creating BatchTxRequester instances
@@ -1671,29 +1806,45 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1671
1806
  txValidatorConfig: {
1672
1807
  l1ChainId: this.config.l1ChainId,
1673
1808
  rollupVersion: this.config.rollupVersion,
1674
- proofVerifier: this.proofVerifier
1809
+ proofVerifier: this.proofVerifier,
1810
+ txValidationCache: this.txValidationCache
1675
1811
  },
1676
- peerScoring: this.peerManager
1812
+ peerScoring: this.peerManager,
1813
+ validateRequestedBlockTxsConsistency: this.validateRequestedBlockTxsConsistency.bind(this)
1677
1814
  };
1678
1815
  }
1679
1816
  async validateTxsReceivedInBlockProposal(txs) {
1680
1817
  const validator = createTxValidatorForBlockProposalReceivedTxs(this.proofVerifier, {
1681
1818
  l1ChainId: this.config.l1ChainId,
1682
1819
  rollupVersion: this.config.rollupVersion
1683
- }, this.logger.getBindings());
1684
- const results = await Promise.all(txs.map(async (tx)=>{
1685
- const result = await validator.validateTx(tx);
1686
- return result.result !== 'invalid';
1687
- }));
1688
- if (results.some((value)=>value === false)) {
1689
- throw new Error('Invalid tx detected');
1820
+ }, this.logger.getBindings(), this.txValidationCache);
1821
+ const results = await Promise.all(txs.map(async (tx)=>({
1822
+ txHash: tx.getTxHash(),
1823
+ result: await validator.validateTx(tx)
1824
+ })));
1825
+ const invalidTxs = results.flatMap(({ txHash, result })=>result.result === 'invalid' ? [
1826
+ {
1827
+ txHash,
1828
+ reasons: result.reason
1829
+ }
1830
+ ] : []);
1831
+ if (invalidTxs.length > 0) {
1832
+ throw new InvalidBlockProposalTxsError(invalidTxs);
1690
1833
  }
1691
1834
  }
1692
1835
  /** Creates the first stage (fast) validators for gossiped transactions. */ async createFirstStageMessageValidators(currentBlockNumber, nextSlotTimestamp) {
1693
- const gasFees = await this.getGasFees(currentBlockNumber);
1694
- const allowedInSetup = this.config.txPublicSetupAllowList ?? await getDefaultAllowedSetupFunctions();
1836
+ const gasFees = await this.getGasFees();
1837
+ const allowedInSetup = [
1838
+ ...await getDefaultAllowedSetupFunctions(),
1839
+ ...this.config.txPublicSetupAllowListExtend ?? []
1840
+ ];
1695
1841
  const blockNumber = BlockNumber(currentBlockNumber + 1);
1696
- return createFirstStageTxValidationsForGossipedTransactions(nextSlotTimestamp, blockNumber, this.worldStateSynchronizer, gasFees, this.config.l1ChainId, this.config.rollupVersion, protocolContractsHash, this.archiver, !this.config.disableTransactions, allowedInSetup, this.logger.getBindings());
1842
+ const l1Constants = await this.archiver.getL1Constants();
1843
+ const networkTxGasLimits = getNetworkTxGasLimits(this.config, l1Constants);
1844
+ return createFirstStageTxValidationsForGossipedTransactions(nextSlotTimestamp, blockNumber, this.worldStateSynchronizer, gasFees, this.config.l1ChainId, this.config.rollupVersion, protocolContractsHash, this.archiver, !this.config.disableTransactions, allowedInSetup, this.logger.getBindings(), {
1845
+ maxTxL2Gas: networkTxGasLimits.l2Gas,
1846
+ maxTxDAGas: networkTxGasLimits.daGas
1847
+ });
1697
1848
  }
1698
1849
  /** Creates the second stage (expensive proof verification) validators for gossiped transactions. */ createSecondStageMessageValidators() {
1699
1850
  return createSecondStageTxValidationsForGossipedTransactions(this.proofVerifier, this.logger.getBindings());
@@ -1714,8 +1865,10 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1714
1865
  });
1715
1866
  // A promise that resolves when all validations have been run
1716
1867
  const allValidations = await Promise.all(validationPromises);
1717
- const failed = allValidations.find((x)=>!x.isValid);
1718
- if (failed) {
1868
+ const failures = allValidations.filter((x)=>!x.isValid);
1869
+ if (failures.length > 0) {
1870
+ // Pick the most severe failure (lowest tolerance = harshest penalty)
1871
+ const failed = maxBy(failures, (f)=>PeerErrorSeverityByHarshness.indexOf(f.severity));
1719
1872
  return {
1720
1873
  allPassed: false,
1721
1874
  failure: {
@@ -1762,19 +1915,6 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
1762
1915
  }
1763
1916
  return PeerErrorSeverity.HighToleranceError;
1764
1917
  }
1765
- /**
1766
- * Validate a checkpoint attestation.
1767
- *
1768
- * @param attestation - The checkpoint attestation to validate.
1769
- * @returns True if the checkpoint attestation is valid, false otherwise.
1770
- */ async validateCheckpointAttestation(peerId, attestation) {
1771
- const result = await this.checkpointAttestationValidator.validate(attestation);
1772
- if (result.result === 'reject') {
1773
- this.logger.warn(`Penalizing peer ${peerId} for checkpoint attestation validation failure`);
1774
- this.peerManager.penalizePeer(peerId, result.severity);
1775
- }
1776
- return result;
1777
- }
1778
1918
  getPeerScore(peerId) {
1779
1919
  return this.node.services.pubsub.score.score(peerId.toString());
1780
1920
  }