@lodestar/beacon-node 1.52.0-dev.6ab73fec0a → 1.52.0-dev.6f38e91359

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 (314) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +63 -39
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/api/impl/beacon/pool/index.d.ts.map +1 -1
  5. package/lib/api/impl/beacon/pool/index.js +3 -1
  6. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  7. package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
  8. package/lib/api/impl/beacon/state/utils.js +2 -1
  9. package/lib/api/impl/beacon/state/utils.js.map +1 -1
  10. package/lib/api/impl/debug/index.d.ts.map +1 -1
  11. package/lib/api/impl/debug/index.js +6 -2
  12. package/lib/api/impl/debug/index.js.map +1 -1
  13. package/lib/api/impl/validator/index.d.ts.map +1 -1
  14. package/lib/api/impl/validator/index.js +19 -11
  15. package/lib/api/impl/validator/index.js.map +1 -1
  16. package/lib/chain/ColumnReconstructionTracker.d.ts +4 -0
  17. package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
  18. package/lib/chain/ColumnReconstructionTracker.js +4 -0
  19. package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
  20. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
  21. package/lib/chain/archiveStore/historicalState/getHistoricalState.js +7 -0
  22. package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
  23. package/lib/chain/archiveStore/utils/pruneHistory.d.ts.map +1 -1
  24. package/lib/chain/archiveStore/utils/pruneHistory.js +8 -4
  25. package/lib/chain/archiveStore/utils/pruneHistory.js.map +1 -1
  26. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
  27. package/lib/chain/blocks/blockInput/blockInput.js +3 -1
  28. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  29. package/lib/chain/blocks/importExecutionPayload.d.ts +1 -1
  30. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  31. package/lib/chain/blocks/importExecutionPayload.js +25 -5
  32. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  33. package/lib/chain/blocks/index.d.ts.map +1 -1
  34. package/lib/chain/blocks/index.js +3 -17
  35. package/lib/chain/blocks/index.js.map +1 -1
  36. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  37. package/lib/chain/blocks/verifyBlock.js +21 -17
  38. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  39. package/lib/chain/blocks/verifyBlocksDataAvailability.d.ts +2 -2
  40. package/lib/chain/blocks/verifyBlocksDataAvailability.d.ts.map +1 -1
  41. package/lib/chain/blocks/verifyBlocksDataAvailability.js +3 -3
  42. package/lib/chain/blocks/verifyBlocksDataAvailability.js.map +1 -1
  43. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
  44. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +7 -5
  45. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  46. package/lib/chain/blocks/verifyBlocksSignatures.d.ts +2 -2
  47. package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
  48. package/lib/chain/blocks/verifyBlocksSignatures.js +2 -1
  49. package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
  50. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts +2 -2
  51. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts.map +1 -1
  52. package/lib/chain/blocks/verifyPayloadsDataAvailability.js +3 -3
  53. package/lib/chain/blocks/verifyPayloadsDataAvailability.js.map +1 -1
  54. package/lib/chain/bls/utils.js +1 -1
  55. package/lib/chain/bls/utils.js.map +1 -1
  56. package/lib/chain/chain.d.ts +6 -5
  57. package/lib/chain/chain.d.ts.map +1 -1
  58. package/lib/chain/chain.js +74 -26
  59. package/lib/chain/chain.js.map +1 -1
  60. package/lib/chain/errors/attestationError.d.ts +15 -1
  61. package/lib/chain/errors/attestationError.d.ts.map +1 -1
  62. package/lib/chain/errors/attestationError.js +8 -0
  63. package/lib/chain/errors/attestationError.js.map +1 -1
  64. package/lib/chain/errors/executionPayloadBid.d.ts +9 -3
  65. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
  66. package/lib/chain/errors/executionPayloadBid.js +2 -1
  67. package/lib/chain/errors/executionPayloadBid.js.map +1 -1
  68. package/lib/chain/errors/executionPayloadEnvelope.d.ts +55 -0
  69. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  70. package/lib/chain/errors/executionPayloadEnvelope.js +8 -0
  71. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  72. package/lib/chain/forkChoice/index.d.ts +1 -4
  73. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  74. package/lib/chain/forkChoice/index.js +1 -4
  75. package/lib/chain/forkChoice/index.js.map +1 -1
  76. package/lib/chain/forkChoiceExecutionEngine.d.ts +5 -3
  77. package/lib/chain/forkChoiceExecutionEngine.d.ts.map +1 -1
  78. package/lib/chain/forkChoiceExecutionEngine.js +34 -11
  79. package/lib/chain/forkChoiceExecutionEngine.js.map +1 -1
  80. package/lib/chain/interface.d.ts +1 -1
  81. package/lib/chain/interface.d.ts.map +1 -1
  82. package/lib/chain/lightClient/index.d.ts +13 -6
  83. package/lib/chain/lightClient/index.d.ts.map +1 -1
  84. package/lib/chain/lightClient/index.js +95 -115
  85. package/lib/chain/lightClient/index.js.map +1 -1
  86. package/lib/chain/opPools/inclusionListStore.d.ts +4 -1
  87. package/lib/chain/opPools/inclusionListStore.d.ts.map +1 -1
  88. package/lib/chain/opPools/inclusionListStore.js +5 -2
  89. package/lib/chain/opPools/inclusionListStore.js.map +1 -1
  90. package/lib/chain/opPools/opPool.js +6 -6
  91. package/lib/chain/opPools/opPool.js.map +1 -1
  92. package/lib/chain/options.js +1 -1
  93. package/lib/chain/options.js.map +1 -1
  94. package/lib/chain/seenCache/seenAttesters.d.ts +1 -0
  95. package/lib/chain/seenCache/seenAttesters.d.ts.map +1 -1
  96. package/lib/chain/seenCache/seenAttesters.js +1 -1
  97. package/lib/chain/seenCache/seenAttesters.js.map +1 -1
  98. package/lib/chain/seenCache/seenBlockAttesters.d.ts +8 -2
  99. package/lib/chain/seenCache/seenBlockAttesters.d.ts.map +1 -1
  100. package/lib/chain/seenCache/seenBlockAttesters.js +43 -6
  101. package/lib/chain/seenCache/seenBlockAttesters.js.map +1 -1
  102. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts +13 -4
  103. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts.map +1 -1
  104. package/lib/chain/seenCache/seenExecutionPayloadBids.js +13 -12
  105. package/lib/chain/seenCache/seenExecutionPayloadBids.js.map +1 -1
  106. package/lib/chain/shufflingCache.d.ts +5 -0
  107. package/lib/chain/shufflingCache.d.ts.map +1 -1
  108. package/lib/chain/shufflingCache.js +39 -1
  109. package/lib/chain/shufflingCache.js.map +1 -1
  110. package/lib/chain/validation/aggregateAndProof.d.ts.map +1 -1
  111. package/lib/chain/validation/aggregateAndProof.js +37 -9
  112. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  113. package/lib/chain/validation/attestation.d.ts.map +1 -1
  114. package/lib/chain/validation/attestation.js +32 -16
  115. package/lib/chain/validation/attestation.js.map +1 -1
  116. package/lib/chain/validation/block.d.ts.map +1 -1
  117. package/lib/chain/validation/block.js +9 -1
  118. package/lib/chain/validation/block.js.map +1 -1
  119. package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
  120. package/lib/chain/validation/dataColumnSidecar.js +8 -1
  121. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  122. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  123. package/lib/chain/validation/executionPayloadBid.js +47 -42
  124. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  125. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  126. package/lib/chain/validation/executionPayloadEnvelope.js +100 -9
  127. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  128. package/lib/chain/validation/payloadAttestationMessage.js +9 -0
  129. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  130. package/lib/execution/engine/blockHash.d.ts +12 -0
  131. package/lib/execution/engine/blockHash.d.ts.map +1 -0
  132. package/lib/execution/engine/blockHash.js +17 -0
  133. package/lib/execution/engine/blockHash.js.map +1 -0
  134. package/lib/execution/engine/http.d.ts +2 -2
  135. package/lib/execution/engine/http.d.ts.map +1 -1
  136. package/lib/execution/engine/http.js +13 -7
  137. package/lib/execution/engine/http.js.map +1 -1
  138. package/lib/execution/engine/interface.d.ts +16 -3
  139. package/lib/execution/engine/interface.d.ts.map +1 -1
  140. package/lib/execution/engine/interface.js +11 -0
  141. package/lib/execution/engine/interface.js.map +1 -1
  142. package/lib/execution/engine/jsonRpcHttpClient.d.ts +2 -0
  143. package/lib/execution/engine/jsonRpcHttpClient.d.ts.map +1 -1
  144. package/lib/execution/engine/jsonRpcHttpClient.js +14 -6
  145. package/lib/execution/engine/jsonRpcHttpClient.js.map +1 -1
  146. package/lib/execution/engine/jsonRpcTransport.d.ts +2 -2
  147. package/lib/execution/engine/jsonRpcTransport.d.ts.map +1 -1
  148. package/lib/execution/engine/jsonRpcTransport.js +4 -4
  149. package/lib/execution/engine/jsonRpcTransport.js.map +1 -1
  150. package/lib/execution/engine/mock.d.ts.map +1 -1
  151. package/lib/execution/engine/mock.js +6 -6
  152. package/lib/execution/engine/mock.js.map +1 -1
  153. package/lib/execution/engine/restHttpClient.d.ts.map +1 -1
  154. package/lib/execution/engine/restHttpClient.js +9 -5
  155. package/lib/execution/engine/restHttpClient.js.map +1 -1
  156. package/lib/execution/engine/restTransport.d.ts +2 -2
  157. package/lib/execution/engine/restTransport.d.ts.map +1 -1
  158. package/lib/execution/engine/restTransport.js +4 -4
  159. package/lib/execution/engine/restTransport.js.map +1 -1
  160. package/lib/execution/engine/signal.d.ts +6 -0
  161. package/lib/execution/engine/signal.d.ts.map +1 -0
  162. package/lib/execution/engine/signal.js +24 -0
  163. package/lib/execution/engine/signal.js.map +1 -0
  164. package/lib/execution/engine/transport.d.ts +2 -2
  165. package/lib/execution/engine/transport.d.ts.map +1 -1
  166. package/lib/index.d.ts +1 -1
  167. package/lib/index.d.ts.map +1 -1
  168. package/lib/index.js +1 -1
  169. package/lib/index.js.map +1 -1
  170. package/lib/metrics/metrics/beacon.d.ts +4 -0
  171. package/lib/metrics/metrics/beacon.d.ts.map +1 -1
  172. package/lib/metrics/metrics/beacon.js +11 -2
  173. package/lib/metrics/metrics/beacon.js.map +1 -1
  174. package/lib/metrics/metrics/lodestar.d.ts +3 -0
  175. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  176. package/lib/metrics/metrics/lodestar.js +42 -28
  177. package/lib/metrics/metrics/lodestar.js.map +1 -1
  178. package/lib/network/gossip/gossipsub.d.ts +1 -0
  179. package/lib/network/gossip/gossipsub.d.ts.map +1 -1
  180. package/lib/network/gossip/gossipsub.js +5 -2
  181. package/lib/network/gossip/gossipsub.js.map +1 -1
  182. package/lib/network/gossip/topic.d.ts +1 -7
  183. package/lib/network/gossip/topic.d.ts.map +1 -1
  184. package/lib/network/gossip/topic.js +0 -13
  185. package/lib/network/gossip/topic.js.map +1 -1
  186. package/lib/network/network.d.ts +1 -0
  187. package/lib/network/network.d.ts.map +1 -1
  188. package/lib/network/network.js +26 -12
  189. package/lib/network/network.js.map +1 -1
  190. package/lib/network/peers/peerManager.d.ts.map +1 -1
  191. package/lib/network/peers/peerManager.js +22 -2
  192. package/lib/network/peers/peerManager.js.map +1 -1
  193. package/lib/network/peers/utils/prioritizePeers.d.ts +2 -0
  194. package/lib/network/peers/utils/prioritizePeers.d.ts.map +1 -1
  195. package/lib/network/peers/utils/prioritizePeers.js +11 -2
  196. package/lib/network/peers/utils/prioritizePeers.js.map +1 -1
  197. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  198. package/lib/network/processor/gossipHandlers.js +19 -6
  199. package/lib/network/processor/gossipHandlers.js.map +1 -1
  200. package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
  201. package/lib/network/processor/gossipValidatorFn.js +4 -1
  202. package/lib/network/processor/gossipValidatorFn.js.map +1 -1
  203. package/lib/network/processor/index.d.ts.map +1 -1
  204. package/lib/network/processor/index.js +4 -2
  205. package/lib/network/processor/index.js.map +1 -1
  206. package/lib/network/reqresp/utils/collect.d.ts +4 -4
  207. package/lib/network/reqresp/utils/collect.d.ts.map +1 -1
  208. package/lib/network/reqresp/utils/collect.js +9 -8
  209. package/lib/network/reqresp/utils/collect.js.map +1 -1
  210. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts +1 -1
  211. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts.map +1 -1
  212. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js +2 -2
  213. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js.map +1 -1
  214. package/lib/sync/range/batch.d.ts +6 -0
  215. package/lib/sync/range/batch.d.ts.map +1 -1
  216. package/lib/sync/range/batch.js +17 -0
  217. package/lib/sync/range/batch.js.map +1 -1
  218. package/lib/sync/range/chain.d.ts.map +1 -1
  219. package/lib/sync/range/chain.js +8 -1
  220. package/lib/sync/range/chain.js.map +1 -1
  221. package/lib/sync/range/range.d.ts.map +1 -1
  222. package/lib/sync/range/range.js +43 -3
  223. package/lib/sync/range/range.js.map +1 -1
  224. package/lib/sync/types.d.ts +14 -1
  225. package/lib/sync/types.d.ts.map +1 -1
  226. package/lib/sync/types.js +2 -0
  227. package/lib/sync/types.js.map +1 -1
  228. package/lib/sync/unknownBlock.d.ts +28 -1
  229. package/lib/sync/unknownBlock.d.ts.map +1 -1
  230. package/lib/sync/unknownBlock.js +340 -27
  231. package/lib/sync/unknownBlock.js.map +1 -1
  232. package/lib/sync/utils/downloadByRange.d.ts +14 -1
  233. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  234. package/lib/sync/utils/downloadByRange.js +12 -2
  235. package/lib/sync/utils/downloadByRange.js.map +1 -1
  236. package/lib/sync/utils/downloadByRoot.d.ts +24 -2
  237. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  238. package/lib/sync/utils/downloadByRoot.js +48 -5
  239. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  240. package/lib/util/eventLoop.d.ts +3 -3
  241. package/lib/util/eventLoop.d.ts.map +1 -1
  242. package/lib/util/eventLoop.js +3 -3
  243. package/lib/util/eventLoop.js.map +1 -1
  244. package/package.json +27 -27
  245. package/src/api/impl/beacon/blocks/index.ts +74 -47
  246. package/src/api/impl/beacon/pool/index.ts +9 -7
  247. package/src/api/impl/beacon/state/utils.ts +2 -1
  248. package/src/api/impl/debug/index.ts +6 -2
  249. package/src/api/impl/validator/index.ts +21 -11
  250. package/src/chain/ColumnReconstructionTracker.ts +5 -0
  251. package/src/chain/archiveStore/historicalState/getHistoricalState.ts +9 -0
  252. package/src/chain/archiveStore/utils/pruneHistory.ts +9 -4
  253. package/src/chain/blocks/blockInput/blockInput.ts +4 -1
  254. package/src/chain/blocks/importExecutionPayload.ts +30 -4
  255. package/src/chain/blocks/index.ts +3 -31
  256. package/src/chain/blocks/verifyBlock.ts +24 -17
  257. package/src/chain/blocks/verifyBlocksDataAvailability.ts +4 -4
  258. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +7 -4
  259. package/src/chain/blocks/verifyBlocksSignatures.ts +3 -0
  260. package/src/chain/blocks/verifyPayloadsDataAvailability.ts +5 -4
  261. package/src/chain/bls/utils.ts +1 -1
  262. package/src/chain/chain.ts +107 -43
  263. package/src/chain/errors/attestationError.ts +11 -1
  264. package/src/chain/errors/executionPayloadBid.ts +9 -2
  265. package/src/chain/errors/executionPayloadEnvelope.ts +58 -0
  266. package/src/chain/forkChoice/index.ts +1 -4
  267. package/src/chain/forkChoiceExecutionEngine.ts +48 -15
  268. package/src/chain/interface.ts +1 -1
  269. package/src/chain/lightClient/index.ts +108 -142
  270. package/src/chain/opPools/inclusionListStore.ts +5 -2
  271. package/src/chain/opPools/opPool.ts +6 -6
  272. package/src/chain/options.ts +1 -1
  273. package/src/chain/seenCache/seenAttesters.ts +1 -1
  274. package/src/chain/seenCache/seenBlockAttesters.ts +48 -6
  275. package/src/chain/seenCache/seenExecutionPayloadBids.ts +35 -15
  276. package/src/chain/shufflingCache.ts +40 -1
  277. package/src/chain/validation/aggregateAndProof.ts +43 -14
  278. package/src/chain/validation/attestation.ts +31 -20
  279. package/src/chain/validation/block.ts +9 -1
  280. package/src/chain/validation/dataColumnSidecar.ts +7 -1
  281. package/src/chain/validation/executionPayloadBid.ts +60 -44
  282. package/src/chain/validation/executionPayloadEnvelope.ts +115 -8
  283. package/src/chain/validation/payloadAttestationMessage.ts +10 -0
  284. package/src/execution/engine/blockHash.ts +27 -0
  285. package/src/execution/engine/http.ts +18 -10
  286. package/src/execution/engine/interface.ts +18 -3
  287. package/src/execution/engine/jsonRpcHttpClient.ts +26 -14
  288. package/src/execution/engine/jsonRpcTransport.ts +8 -4
  289. package/src/execution/engine/mock.ts +13 -8
  290. package/src/execution/engine/restHttpClient.ts +17 -11
  291. package/src/execution/engine/restTransport.ts +5 -4
  292. package/src/execution/engine/signal.ts +28 -0
  293. package/src/execution/engine/transport.ts +3 -2
  294. package/src/index.ts +6 -1
  295. package/src/metrics/metrics/beacon.ts +11 -2
  296. package/src/metrics/metrics/lodestar.ts +42 -28
  297. package/src/network/gossip/gossipsub.ts +6 -2
  298. package/src/network/gossip/topic.ts +1 -14
  299. package/src/network/network.ts +39 -13
  300. package/src/network/peers/peerManager.ts +26 -2
  301. package/src/network/peers/utils/prioritizePeers.ts +14 -1
  302. package/src/network/processor/gossipHandlers.ts +25 -13
  303. package/src/network/processor/gossipValidatorFn.ts +4 -0
  304. package/src/network/processor/index.ts +7 -2
  305. package/src/network/reqresp/utils/collect.ts +16 -8
  306. package/src/network/reqresp/utils/collectSequentialBlocksInRange.ts +3 -2
  307. package/src/sync/range/batch.ts +20 -0
  308. package/src/sync/range/chain.ts +8 -0
  309. package/src/sync/range/range.ts +56 -3
  310. package/src/sync/types.ts +13 -0
  311. package/src/sync/unknownBlock.ts +389 -29
  312. package/src/sync/utils/downloadByRange.ts +29 -3
  313. package/src/sync/utils/downloadByRoot.ts +75 -7
  314. package/src/util/eventLoop.ts +3 -3
@@ -68,7 +68,7 @@ export function createLodestarMetrics(
68
68
  if (genesisTime) {
69
69
  register
70
70
  .gauge({
71
- name: "lodestar_genesis_time",
71
+ name: "lodestar_genesis_time_seconds",
72
72
  help: "Genesis time in seconds",
73
73
  })
74
74
  .set(genesisTime);
@@ -565,13 +565,13 @@ export function createLodestarMetrics(
565
565
  }),
566
566
  // To measure the time cost of main thread <-> worker message passing
567
567
  latencyToWorker: register.histogram({
568
- name: "lodestar_bls_thread_pool_latency_to_worker",
568
+ name: "lodestar_bls_thread_pool_latency_to_worker_seconds",
569
569
  help: "Time from sending the job to the worker and the worker receiving it",
570
570
  // The dashboard treats 20ms as slow; values above 100ms only need severe-stall classification.
571
571
  buckets: [0.00025, 0.001, 0.005, 0.02, 0.1],
572
572
  }),
573
573
  latencyFromWorker: register.histogram({
574
- name: "lodestar_bls_thread_pool_latency_from_worker",
574
+ name: "lodestar_bls_thread_pool_latency_from_worker_seconds",
575
575
  help: "Time from the worker sending the result and the main thread receiving it",
576
576
  buckets: [0.00025, 0.001, 0.005, 0.02, 0.1],
577
577
  }),
@@ -775,7 +775,7 @@ export function createLodestarMetrics(
775
775
  labelNames: ["reason"],
776
776
  }),
777
777
  elapsedTimeTillReceived: register.histogram({
778
- name: "lodestar_sync_unknown_block_elapsed_time_till_received",
778
+ name: "lodestar_sync_unknown_block_elapsed_time_till_received_seconds",
779
779
  help: "Time elapsed between block slot time and the time block received via unknown block sync",
780
780
  buckets: [0.5, 1, 2, 4, 6, 12],
781
781
  }),
@@ -930,86 +930,86 @@ export function createLodestarMetrics(
930
930
  // Gossip block
931
931
  gossipBlock: {
932
932
  elapsedTimeTillReceived: register.histogram<{source: OpSource}>({
933
- name: "lodestar_gossip_block_elapsed_time_till_received",
933
+ name: "lodestar_gossip_block_elapsed_time_till_received_seconds",
934
934
  help: "Time elapsed between block slot time and the time block received via gossip",
935
935
  labelNames: ["source"],
936
936
  buckets: [0.5, 1, 2, 4, 6, 12],
937
937
  }),
938
938
  elapsedTimeTillProcessed: register.histogram({
939
- name: "lodestar_gossip_block_elapsed_time_till_processed",
939
+ name: "lodestar_gossip_block_elapsed_time_till_processed_seconds",
940
940
  help: "Time elapsed between block slot time and the time block processed",
941
941
  buckets: [0.5, 1, 2, 4, 6, 12],
942
942
  }),
943
943
 
944
944
  gossipValidation: {
945
945
  recvToValidation: register.histogram({
946
- name: "lodestar_gossip_block_received_to_gossip_validate",
946
+ name: "lodestar_gossip_block_received_to_gossip_validate_seconds",
947
947
  help: "Time elapsed between block received and block validated",
948
948
  buckets: [0.05, 0.1, 0.3, 0.5, 0.7, 1, 1.3, 1.6, 2, 2.5, 3, 3.5, 4],
949
949
  }),
950
950
  validationTime: register.histogram({
951
- name: "lodestar_gossip_block_gossip_validate_time",
951
+ name: "lodestar_gossip_block_gossip_validate_time_seconds",
952
952
  help: "Time to apply gossip validations",
953
953
  buckets: [0.05, 0.1, 0.3, 0.5, 0.7, 1, 1.3, 1.6, 2, 2.5, 3, 3.5, 4],
954
954
  }),
955
955
  },
956
956
  stateTransition: {
957
957
  recvToValidation: register.histogram({
958
- name: "lodestar_gossip_block_received_to_state_transition",
958
+ name: "lodestar_gossip_block_received_to_state_transition_seconds",
959
959
  help: "Time elapsed between block received and block state transition",
960
960
  buckets: [0.05, 0.1, 0.3, 0.5, 0.7, 1, 1.3, 1.6, 2, 2.5, 3, 3.5, 4],
961
961
  }),
962
962
  validationTime: register.histogram({
963
- name: "lodestar_gossip_block_state_transition_time",
963
+ name: "lodestar_gossip_block_state_transition_time_seconds",
964
964
  help: "Time to validate block state transition",
965
965
  buckets: [0.05, 0.1, 0.3, 0.5, 0.7, 1, 1.3, 1.6, 2, 2.5, 3, 3.5, 4],
966
966
  }),
967
967
  },
968
968
  signatureVerification: {
969
969
  recvToValidation: register.histogram({
970
- name: "lodestar_gossip_block_received_to_signatures_verification",
970
+ name: "lodestar_gossip_block_received_to_signatures_verification_seconds",
971
971
  help: "Time elapsed between block received and block signatures verification",
972
972
  buckets: [0.05, 0.1, 0.3, 0.5, 0.7, 1, 1.3, 1.6, 2, 2.5, 3, 3.5, 4],
973
973
  }),
974
974
  validationTime: register.histogram({
975
- name: "lodestar_gossip_block_signatures_verification_time",
975
+ name: "lodestar_gossip_block_signatures_verification_time_seconds",
976
976
  help: "Time elapsed for block signatures verification",
977
977
  buckets: [0.05, 0.1, 0.3, 0.5, 0.7, 1, 1.3, 1.6, 2, 2.5, 3, 3.5, 4],
978
978
  }),
979
979
  },
980
980
  executionPayload: {
981
981
  recvToValidation: register.histogram({
982
- name: "lodestar_gossip_block_received_to_execution_payload_verification",
982
+ name: "lodestar_gossip_block_received_to_execution_payload_verification_seconds",
983
983
  help: "Time elapsed between block received and execution payload verification",
984
984
  buckets: [0.05, 0.1, 0.3, 0.5, 0.7, 1, 1.3, 1.6, 2, 2.5, 3, 3.5, 4],
985
985
  }),
986
986
  validationTime: register.histogram({
987
- name: "lodestar_gossip_execution_payload_verification_time",
987
+ name: "lodestar_gossip_execution_payload_verification_time_seconds",
988
988
  help: "Time elapsed for execution payload verification",
989
989
  buckets: [0.05, 0.1, 0.3, 0.5, 0.7, 1, 1.3, 1.6, 2, 2.5, 3, 3.5, 4],
990
990
  }),
991
991
  },
992
992
  blockImport: {
993
993
  recvToValidation: register.histogram({
994
- name: "lodestar_gossip_block_received_to_block_import",
994
+ name: "lodestar_gossip_block_received_to_block_import_seconds",
995
995
  help: "Time elapsed between block received and block import",
996
996
  buckets: [0.05, 0.1, 0.3, 0.5, 0.7, 1, 1.3, 1.6, 2, 2.5, 3, 3.5, 4],
997
997
  }),
998
998
  validationTime: register.histogram({
999
- name: "lodestar_gossip_block_block_import_time",
999
+ name: "lodestar_gossip_block_block_import_time_seconds",
1000
1000
  help: "Time elapsed for block import",
1001
1001
  buckets: [0.05, 0.1, 0.3, 0.5, 0.7, 1, 1.3, 1.6, 2, 2.5, 3, 3.5, 4],
1002
1002
  }),
1003
1003
  },
1004
1004
 
1005
1005
  receivedToBlobsAvailabilityTime: register.histogram<{numBlobs: number}>({
1006
- name: "lodestar_gossip_block_received_to_blobs_availability_time",
1006
+ name: "lodestar_gossip_block_received_to_blobs_availability_time_seconds",
1007
1007
  help: "Time elapsed between block received and blobs became available",
1008
1008
  buckets: [0.05, 0.1, 0.3, 0.5, 0.7, 1, 1.3, 1.6, 2, 2.5, 3, 3.5, 4],
1009
1009
  labelNames: ["numBlobs"],
1010
1010
  }),
1011
1011
  receivedToFullyVerifiedTime: register.histogram({
1012
- name: "lodestar_gossip_block_received_to_fully_verified_time",
1012
+ name: "lodestar_gossip_block_received_to_fully_verified_time_seconds",
1013
1013
  help: "Time elapsed between block received and fully verified state, signatures and payload",
1014
1014
  buckets: [0.05, 0.1, 0.3, 0.5, 0.7, 1, 1.3, 1.6, 2, 2.5, 3, 3.5, 4],
1015
1015
  }),
@@ -1019,7 +1019,7 @@ export function createLodestarMetrics(
1019
1019
  buckets: [0.01, 0.015, 0.02, 0.025, 0.03, 0.04, 0.5, 1],
1020
1020
  }),
1021
1021
  verifiedToBlobsAvailabiltyTime: register.histogram<{numBlobs: number}>({
1022
- name: "lodestar_gossip_block_verified_to_blobs_availability_time",
1022
+ name: "lodestar_gossip_block_verified_to_blobs_availability_time_seconds",
1023
1023
  help: "Time elapsed between block verified and blobs became available",
1024
1024
  buckets: [0.05, 0.1, 0.3, 0.5, 0.7, 1, 1.3, 1.6, 2, 2.5, 3, 3.5, 4],
1025
1025
  labelNames: ["numBlobs"],
@@ -1045,12 +1045,12 @@ export function createLodestarMetrics(
1045
1045
  },
1046
1046
  gossipBlob: {
1047
1047
  recvToValidation: register.histogram({
1048
- name: "lodestar_gossip_blob_received_to_gossip_validate",
1048
+ name: "lodestar_gossip_blob_received_to_gossip_validate_seconds",
1049
1049
  help: "Time elapsed between blob received and blob validation",
1050
1050
  buckets: [0.05, 0.1, 0.2, 0.5, 1, 1.5, 2, 4],
1051
1051
  }),
1052
1052
  validationTime: register.histogram({
1053
- name: "lodestar_gossip_blob_gossip_validate_time",
1053
+ name: "lodestar_gossip_blob_gossip_validate_time_seconds",
1054
1054
  help: "Time elapsed for blob validation",
1055
1055
  buckets: [0.05, 0.1, 0.2, 0.5, 1, 1.5, 2, 4],
1056
1056
  }),
@@ -1058,7 +1058,7 @@ export function createLodestarMetrics(
1058
1058
  // Gossip execution payload envelope
1059
1059
  gossipExecutionPayloadEnvelope: {
1060
1060
  elapsedTimeTillReceived: register.histogram<{source: OpSource}>({
1061
- name: "lodestar_gossip_execution_payload_envelope_elapsed_time_till_received",
1061
+ name: "lodestar_gossip_execution_payload_envelope_elapsed_time_till_received_seconds",
1062
1062
  help: "Time elapsed between slot time and the time execution payload envelope received",
1063
1063
  labelNames: ["source"],
1064
1064
  buckets: [0.5, 1, 2, 4, 6, 12],
@@ -1068,6 +1068,11 @@ export function createLodestarMetrics(
1068
1068
  help: "Count of errors, by error type, while processing execution payload envelopes",
1069
1069
  labelNames: ["error"],
1070
1070
  }),
1071
+ blockHashTime: register.histogram({
1072
+ name: "lodestar_gossip_execution_payload_envelope_block_hash_seconds",
1073
+ help: "Time to compute the execution block hash of a gossip execution payload envelope",
1074
+ buckets: [0.001, 0.002, 0.005, 0.01, 0.025, 0.05, 0.1, 0.5, 1],
1075
+ }),
1071
1076
  executionPayload: {
1072
1077
  recvToValidation: register.histogram({
1073
1078
  name: "lodestar_gossip_execution_payload_envelope_received_to_execution_payload_verification_seconds",
@@ -1157,7 +1162,7 @@ export function createLodestarMetrics(
1157
1162
  help: "Count persisting block with serialized data",
1158
1163
  }),
1159
1164
  elapsedTimeTillBecomeHead: register.histogram({
1160
- name: "lodestar_gossip_block_elapsed_time_till_become_head",
1165
+ name: "lodestar_gossip_block_elapsed_time_till_become_head_seconds",
1161
1166
  help: "Time elapsed between block slot time and the time block becomes head",
1162
1167
  buckets: [0.5, 1, 2, 4, 6, 12],
1163
1168
  }),
@@ -1595,7 +1600,7 @@ export function createLodestarMetrics(
1595
1600
  help: "Avg min max of all state cache items total read count",
1596
1601
  }),
1597
1602
  secondsSinceLastRead: register.avgMinMax({
1598
- name: "lodestar_state_cache_seconds_since_last_read",
1603
+ name: "lodestar_state_cache_since_last_read_seconds",
1599
1604
  help: "Avg min max of all state cache items seconds since last reads",
1600
1605
  }),
1601
1606
  stateClonedCount: register.histogram({
@@ -1664,7 +1669,7 @@ export function createLodestarMetrics(
1664
1669
  help: "Avg min max of all state cache items total read count",
1665
1670
  }),
1666
1671
  secondsSinceLastRead: register.avgMinMax({
1667
- name: "lodestar_cp_state_epoch_seconds_since_last_read",
1672
+ name: "lodestar_cp_state_epoch_since_last_read_seconds",
1668
1673
  help: "Avg min max of all state cache items seconds since last reads",
1669
1674
  }),
1670
1675
  stateClonedCount: register.histogram({
@@ -1682,7 +1687,7 @@ export function createLodestarMetrics(
1682
1687
  help: "Total number of states pruned from memory",
1683
1688
  }),
1684
1689
  statePersistSecFromSlot: register.histogram({
1685
- name: "lodestar_cp_state_cache_state_persist_seconds_from_slot",
1690
+ name: "lodestar_cp_state_cache_state_persist_from_slot_seconds",
1686
1691
  help: "Histogram of time to persist state to db since the clock slot",
1687
1692
  buckets: [0, 2, 4, 6, 8, 10, 12],
1688
1693
  }),
@@ -1710,7 +1715,7 @@ export function createLodestarMetrics(
1710
1715
  buckets: [0, 1, 2, 4, 8, 16, 32],
1711
1716
  }),
1712
1717
  stateReloadSecFromSlot: register.histogram({
1713
- name: "lodestar_cp_state_cache_state_reload_seconds_from_slot",
1718
+ name: "lodestar_cp_state_cache_state_reload_from_slot_seconds",
1714
1719
  help: "Histogram of time to load state from db since the clock slot",
1715
1720
  buckets: [0, 2, 4, 6, 8, 10, 12],
1716
1721
  }),
@@ -1784,6 +1789,15 @@ export function createLodestarMetrics(
1784
1789
  help: "Time from promise insertion until promise resolution when shuffling was ready in seconds",
1785
1790
  buckets: [0.5, 1, 1.5, 2],
1786
1791
  }),
1792
+ committeePubkeysComputeTime: register.histogram({
1793
+ name: "lodestar_shuffling_cache_committee_pubkeys_compute_seconds",
1794
+ help: "Time to aggregate the committee pubkeys of a shuffling off the main thread in seconds",
1795
+ buckets: [0.1, 0.25, 0.5, 1, 2, 5],
1796
+ }),
1797
+ committeePubkeysErrors: register.counter({
1798
+ name: "lodestar_shuffling_cache_committee_pubkeys_errors_total",
1799
+ help: "Total number of shufflings whose committee pubkeys could not be computed",
1800
+ }),
1787
1801
  },
1788
1802
 
1789
1803
  seenCache: {
@@ -1916,7 +1930,7 @@ export function createLodestarMetrics(
1916
1930
  labelNames: ["entrypoint", "caller"],
1917
1931
  }),
1918
1932
  regenFnCallDuration: register.histogram<{entrypoint: RegenFnName; caller: RegenCaller}>({
1919
- name: "lodestar_regen_fn_call_duration",
1933
+ name: "lodestar_regen_fn_call_duration_seconds",
1920
1934
  help: "regen function duration",
1921
1935
  labelNames: ["entrypoint", "caller"],
1922
1936
  buckets: [0.1, 1, 10, 100],
@@ -25,7 +25,7 @@ import {getSlotDurations} from "@lodestar/state-transition";
25
25
  import {SubnetID} from "@lodestar/types";
26
26
  import {Logger, Map2d, Map2dArr} from "@lodestar/utils";
27
27
  import {RegistryMetricCreator} from "../../metrics/index.js";
28
- import {callImmediate, callInNextEventLoop} from "../../util/eventLoop.js";
28
+ import {callAfterIO, callInNextEventLoop} from "../../util/eventLoop.js";
29
29
  import {NetworkEvent, NetworkEventBus, NetworkEventData} from "../events.js";
30
30
  import {Libp2p} from "../interface.js";
31
31
  import {NetworkConfig} from "../networkConfig.js";
@@ -433,7 +433,7 @@ export class Eth2Gossipsub {
433
433
  // See https://github.com/ChainSafe/lodestar/issues/5604
434
434
  // A block arrives once per slot and cannot cause that lag, so it skips the 1ms timer delay
435
435
  if (topic.type === GossipType.beacon_block) {
436
- callImmediate(emitPendingMessage);
436
+ callAfterIO(emitPendingMessage);
437
437
  } else {
438
438
  callInNextEventLoop(emitPendingMessage);
439
439
  }
@@ -505,6 +505,10 @@ export class Eth2Gossipsub {
505
505
  getDirectPeers(): string[] {
506
506
  return Array.from(this.gossipsub.direct);
507
507
  }
508
+
509
+ isDirectPeer(peerIdStr: string): boolean {
510
+ return this.gossipsub.direct.has(peerIdStr);
511
+ }
508
512
  }
509
513
 
510
514
  /**
@@ -12,7 +12,7 @@ import {
12
12
  isForkPostGloas,
13
13
  } from "@lodestar/params";
14
14
  import {TypeSizes} from "@lodestar/reqresp";
15
- import {Attestation, SingleAttestation, ssz, sszTypesFor} from "@lodestar/types";
15
+ import {SingleAttestation, ssz, sszTypesFor} from "@lodestar/types";
16
16
  import {GossipAction, GossipActionError, GossipErrorCode} from "../../chain/errors/gossipValidation.js";
17
17
  import {computeMaxGloasDataColumnSidecarSize} from "../../util/sszBytes.js";
18
18
  import {NetworkConfig} from "../networkConfig.js";
@@ -173,19 +173,6 @@ export function sszDeserialize<T extends GossipTopic>(topic: T, serializedData:
173
173
  }
174
174
  }
175
175
 
176
- /**
177
- * @deprecated
178
- * Deserialize a gossip serialized data into an Attestation object.
179
- * No longer used post-electra. Use `sszDeserializeSingleAttestation` instead
180
- */
181
- export function sszDeserializeAttestation(fork: ForkName, serializedData: Uint8Array): Attestation {
182
- try {
183
- return sszTypesFor(fork).Attestation.deserialize(serializedData);
184
- } catch (_e) {
185
- throw new GossipActionError(GossipAction.REJECT, {code: GossipErrorCode.INVALID_SERIALIZED_BYTES_ERROR_CODE});
186
- }
187
- }
188
-
189
176
  /**
190
177
  * Deserialize a gossip seralized data into an SingleAttestation object.
191
178
  */
@@ -431,7 +431,7 @@ export class Network implements INetwork {
431
431
  }
432
432
 
433
433
  async publishBlsToExecutionChange(blsToExecutionChange: capella.SignedBLSToExecutionChange): Promise<number> {
434
- const publishChanges = [];
434
+ const publishChanges: Promise<number>[] = [];
435
435
  for (const boundary of getActiveForkBoundaries(this.config, this.clock.currentEpoch)) {
436
436
  const fork = ForkSeq[boundary.fork];
437
437
 
@@ -447,7 +447,11 @@ export class Network implements INetwork {
447
447
  if (publishChanges.length === 0) {
448
448
  throw Error("No capella+ fork active yet to publish blsToExecutionChange");
449
449
  }
450
- return Promise.any(publishChanges);
450
+ try {
451
+ return await Promise.any(publishChanges);
452
+ } finally {
453
+ await Promise.allSettled(publishChanges);
454
+ }
451
455
  }
452
456
 
453
457
  async publishProposerSlashing(proposerSlashing: phase0.ProposerSlashing): Promise<number> {
@@ -596,7 +600,8 @@ export class Network implements INetwork {
596
600
  request
597
601
  ),
598
602
  request,
599
- this.chain.serializedCache
603
+ this.chain.serializedCache,
604
+ () => this.reportInvalidResponse(peerId)
600
605
  );
601
606
  }
602
607
 
@@ -611,7 +616,8 @@ export class Network implements INetwork {
611
616
  ),
612
617
  request.length,
613
618
  responseSszTypeByMethod[ReqRespMethod.BeaconBlocksByRoot],
614
- this.chain.serializedCache
619
+ this.chain.serializedCache,
620
+ () => this.reportInvalidResponse(peerId)
615
621
  );
616
622
  }
617
623
 
@@ -623,28 +629,32 @@ export class Network implements INetwork {
623
629
  this.sendReqRespRequest(peerId, ReqRespMethod.BeaconBlocksByHead, [Version.V1], request),
624
630
  Math.min(request.count, this.config.MAX_REQUEST_BLOCKS_DENEB),
625
631
  responseSszTypeByMethod[ReqRespMethod.BeaconBlocksByHead],
626
- this.chain.serializedCache
632
+ this.chain.serializedCache,
633
+ () => this.reportInvalidResponse(peerId)
627
634
  );
628
635
  }
629
636
 
630
637
  async sendLightClientBootstrap(peerId: PeerIdStr, request: Root): Promise<LightClientBootstrap> {
631
638
  return collectExactOneTyped(
632
639
  this.sendReqRespRequest(peerId, ReqRespMethod.LightClientBootstrap, [Version.V1], request),
633
- responseSszTypeByMethod[ReqRespMethod.LightClientBootstrap]
640
+ responseSszTypeByMethod[ReqRespMethod.LightClientBootstrap],
641
+ () => this.reportInvalidResponse(peerId)
634
642
  );
635
643
  }
636
644
 
637
645
  async sendLightClientOptimisticUpdate(peerId: PeerIdStr): Promise<LightClientOptimisticUpdate> {
638
646
  return collectExactOneTyped(
639
647
  this.sendReqRespRequest(peerId, ReqRespMethod.LightClientOptimisticUpdate, [Version.V1], null),
640
- responseSszTypeByMethod[ReqRespMethod.LightClientOptimisticUpdate]
648
+ responseSszTypeByMethod[ReqRespMethod.LightClientOptimisticUpdate],
649
+ () => this.reportInvalidResponse(peerId)
641
650
  );
642
651
  }
643
652
 
644
653
  async sendLightClientFinalityUpdate(peerId: PeerIdStr): Promise<LightClientFinalityUpdate> {
645
654
  return collectExactOneTyped(
646
655
  this.sendReqRespRequest(peerId, ReqRespMethod.LightClientFinalityUpdate, [Version.V1], null),
647
- responseSszTypeByMethod[ReqRespMethod.LightClientFinalityUpdate]
656
+ responseSszTypeByMethod[ReqRespMethod.LightClientFinalityUpdate],
657
+ () => this.reportInvalidResponse(peerId)
648
658
  );
649
659
  }
650
660
 
@@ -655,7 +665,9 @@ export class Network implements INetwork {
655
665
  return collectMaxResponseTyped(
656
666
  this.sendReqRespRequest(peerId, ReqRespMethod.LightClientUpdatesByRange, [Version.V1], request),
657
667
  request.count,
658
- responseSszTypeByMethod[ReqRespMethod.LightClientUpdatesByRange]
668
+ responseSszTypeByMethod[ReqRespMethod.LightClientUpdatesByRange],
669
+ undefined,
670
+ () => this.reportInvalidResponse(peerId)
659
671
  );
660
672
  }
661
673
 
@@ -666,7 +678,9 @@ export class Network implements INetwork {
666
678
  return collectMaxResponseTyped(
667
679
  this.sendReqRespRequest(peerId, ReqRespMethod.DataColumnSidecarsByRange, [Version.V1], request),
668
680
  request.count * request.columns.length,
669
- responseSszTypeByMethod[ReqRespMethod.DataColumnSidecarsByRange]
681
+ responseSszTypeByMethod[ReqRespMethod.DataColumnSidecarsByRange],
682
+ undefined,
683
+ () => this.reportInvalidResponse(peerId)
670
684
  );
671
685
  }
672
686
 
@@ -678,7 +692,8 @@ export class Network implements INetwork {
678
692
  this.sendReqRespRequest(peerId, ReqRespMethod.DataColumnSidecarsByRoot, [Version.V1], request),
679
693
  request.reduce((total, {columns}) => total + columns.length, 0),
680
694
  responseSszTypeByMethod[ReqRespMethod.DataColumnSidecarsByRoot],
681
- this.chain.serializedCache
695
+ this.chain.serializedCache,
696
+ () => this.reportInvalidResponse(peerId)
682
697
  );
683
698
  }
684
699
 
@@ -689,7 +704,9 @@ export class Network implements INetwork {
689
704
  return collectMaxResponseTyped(
690
705
  this.sendReqRespRequest(peerId, ReqRespMethod.ExecutionPayloadEnvelopesByRange, [Version.V1], request),
691
706
  request.count,
692
- responseSszTypeByMethod[ReqRespMethod.ExecutionPayloadEnvelopesByRange]
707
+ responseSszTypeByMethod[ReqRespMethod.ExecutionPayloadEnvelopesByRange],
708
+ undefined,
709
+ () => this.reportInvalidResponse(peerId)
693
710
  );
694
711
  }
695
712
 
@@ -701,10 +718,19 @@ export class Network implements INetwork {
701
718
  this.sendReqRespRequest(peerId, ReqRespMethod.ExecutionPayloadEnvelopesByRoot, [Version.V1], request),
702
719
  request.length,
703
720
  responseSszTypeByMethod[ReqRespMethod.ExecutionPayloadEnvelopesByRoot],
704
- this.chain.serializedCache
721
+ this.chain.serializedCache,
722
+ () => this.reportInvalidResponse(peerId)
705
723
  );
706
724
  }
707
725
 
726
+ private async reportInvalidResponse(peerId: PeerIdStr): Promise<void> {
727
+ try {
728
+ await this.core.reportPeer(peerId, PeerAction.LowToleranceError, "InvalidResponseSsz");
729
+ } catch (error) {
730
+ this.logger.debug("Failed to report invalid response", {peerId}, error as Error);
731
+ }
732
+ }
733
+
708
734
  private sendReqRespRequest<Req>(
709
735
  peerId: PeerIdStr,
710
736
  method: ReqRespMethod,
@@ -449,7 +449,8 @@ export class PeerManager {
449
449
  .catch((e) => this.logger.verbose("cannot tag peer", {peerId: peer.toString()}, e as Error));
450
450
  peerData.relevantStatus = RelevantPeerStatus.relevant;
451
451
  }
452
- if (getConnection(this.libp2p, peer.toString())) {
452
+ // A peer rejected on connect is not tracked and may still send a status before its goodbye completes
453
+ if (peerData && getConnection(this.libp2p, peer.toString())) {
453
454
  const nodeId = peerData?.nodeId ?? computeNodeId(peer);
454
455
  // TODO(fulu): Are we sure we've run Metadata before this?
455
456
  const custodyGroupCount = peerData?.metadata?.custodyGroupCount ?? this.config.CUSTODY_REQUIREMENT;
@@ -554,6 +555,11 @@ export class PeerManager {
554
555
  // ban and disconnect peers with bad score, collect rest of healthy peers
555
556
  const connectedHealthyPeers: PeerId[] = [];
556
557
  for (const peer of connectedPeers) {
558
+ // Direct peers are trusted by the operator, a bad score never disconnects them
559
+ if (this.gossipsub.isDirectPeer(peer.toString())) {
560
+ connectedHealthyPeers.push(peer);
561
+ continue;
562
+ }
557
563
  switch (this.peerRpcScores.getScoreState(peer)) {
558
564
  case ScoreState.Banned:
559
565
  this.metrics?.peerManager.peersPruned.inc({reason: "banned"});
@@ -584,9 +590,11 @@ export class PeerManager {
584
590
  const prioritizeTimer = this.metrics?.peerManager.prioritizePeersDuration.startTimer();
585
591
  const {peersToDisconnect, peersToConnect, attnetQueries, syncnetQueries, custodyGroupQueries} = prioritizePeers(
586
592
  connectedHealthyPeers.map((peer) => {
587
- const peerData = this.connectedPeers.get(peer.toString());
593
+ const peerIdStr = peer.toString();
594
+ const peerData = this.connectedPeers.get(peerIdStr);
588
595
  return {
589
596
  id: peer,
597
+ direct: this.gossipsub.isDirectPeer(peerIdStr),
590
598
  direction: peerData?.direction ?? null,
591
599
  status: peerData?.status ?? null,
592
600
  attnets: peerData?.metadata?.attnets ?? null,
@@ -708,6 +716,10 @@ export class PeerManager {
708
716
  private updateGossipsubScores(): void {
709
717
  const gossipsubScores = new Map<string, number>();
710
718
  for (const peerIdStr of this.connectedPeers.keys()) {
719
+ // Direct peers are never disconnected, they must not take the negative score allowance of other peers
720
+ if (this.gossipsub.isDirectPeer(peerIdStr)) {
721
+ continue;
722
+ }
711
723
  gossipsubScores.set(peerIdStr, this.gossipsub.getScore(peerIdStr));
712
724
  }
713
725
 
@@ -786,6 +798,18 @@ export class PeerManager {
786
798
  return false;
787
799
  }
788
800
 
801
+ // The heartbeat only disconnects peers that are already connected, a peer with a bad score
802
+ // could otherwise reconnect right after and stay connected until the next heartbeat
803
+ const scoreState = this.peerRpcScores.getScoreState(remotePeer);
804
+ if (scoreState !== ScoreState.Healthy && !this.gossipsub.isDirectPeer(remotePeerStr)) {
805
+ this.logger.debug("Peer with bad score connected, disconnecting", {peer: remotePeerPrettyStr, scoreState});
806
+ void this.goodbyeAndDisconnect(
807
+ remotePeer,
808
+ scoreState === ScoreState.Banned ? GoodByeReasonCode.BANNED : GoodByeReasonCode.SCORE_TOO_LOW
809
+ );
810
+ return false;
811
+ }
812
+
789
813
  if (!opts.overwriteExisting && this.connectedPeers.has(remotePeerStr)) {
790
814
  return false;
791
815
  }
@@ -98,6 +98,7 @@ function computeStatusScore(ours: Status, theirs: Status | null, opts: Prioritiz
98
98
 
99
99
  type PeerInfo = {
100
100
  id: PeerId;
101
+ direct: boolean;
101
102
  direction: MessageStreamDirection | null;
102
103
  statusScore: StatusScore;
103
104
  attnets: phase0.AttestationSubnets;
@@ -140,6 +141,7 @@ export enum ExcessPeerDisconnectReason {
140
141
  export function prioritizePeers(
141
142
  connectedPeersInfo: {
142
143
  id: PeerId;
144
+ direct?: boolean;
143
145
  direction: MessageStreamDirection | null;
144
146
  status: Status | null;
145
147
  attnets: phase0.AttestationSubnets | null;
@@ -169,6 +171,7 @@ export function prioritizePeers(
169
171
  const connectedPeers = connectedPeersInfo.map(
170
172
  (peer): PeerInfo => ({
171
173
  id: peer.id,
174
+ direct: peer.direct ?? false,
172
175
  direction: peer.direction,
173
176
  statusScore: computeStatusScore(opts.status, peer.status, opts),
174
177
  attnets: peer.attnets ?? attnetsZero,
@@ -365,6 +368,11 @@ function pruneExcessPeers(
365
368
  const peersEligibleForPruning = sortedPeers
366
369
  // Then, iterate from highest score to lowest doing a manual filter for duties and outbound ratio
367
370
  .filter((peer) => {
371
+ // Direct peers are pinned by the operator, they count towards all targets but are never pruned
372
+ if (peer.direct) {
373
+ return false;
374
+ }
375
+
368
376
  // Peers with duties are not eligible for pruning
369
377
  if ((dutiesByPeer.get(peer) ?? 0) > 0) {
370
378
  return false;
@@ -488,11 +496,12 @@ function pruneExcessPeers(
488
496
  // otherwise we'll not able to accept new peer connection to consider better peers
489
497
  // see https://github.com/ChainSafe/lodestar/issues/5198
490
498
  const remainingPeersToDisconnect: PeerId[] = [];
491
- for (const {id} of sortedPeers) {
499
+ for (const {id, direct} of sortedPeers) {
492
500
  if (peersToDisconnectCount >= peersToDisconnectTarget) {
493
501
  break;
494
502
  }
495
503
  if (
504
+ direct ||
496
505
  noLongLivedSubnetPeersToDisconnect.includes(id) ||
497
506
  badScorePeersToDisconnect.includes(id) ||
498
507
  tooGroupedPeersToDisconnect.includes(id)
@@ -568,6 +577,10 @@ function findPeerToRemove(
568
577
  const peersOnSubnet = sortBy(peersOnMostGroupedSubnet, (peer) => peer.attnetsTrueBitIndices.length);
569
578
  let removedPeer: PeerInfo | null = null;
570
579
  for (const candidatePeer of peersOnSubnet) {
580
+ if (candidatePeer.direct) {
581
+ continue;
582
+ }
583
+
571
584
  // new logic of lodestar
572
585
  const attnetIndices = candidatePeer.attnetsTrueBitIndices;
573
586
  if (attnetIndices.length > 0) {
@@ -89,7 +89,7 @@ import {validateGossipProposerPreferences} from "../../chain/validation/proposer
89
89
  import {OpSource} from "../../chain/validatorMonitor.js";
90
90
  import {Metrics} from "../../metrics/index.js";
91
91
  import {getBlobKzgCommitments, getDataColumnSidecarSlot} from "../../util/dataColumns.js";
92
- import {callImmediate, callInNextEventLoop} from "../../util/eventLoop.js";
92
+ import {callAfterIO, callInNextEventLoop} from "../../util/eventLoop.js";
93
93
  import {INetworkCore} from "../core/index.js";
94
94
  import {NetworkEventBus} from "../events.js";
95
95
  import {
@@ -269,6 +269,16 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
269
269
  // The block is retained for unknown parent sync without full validation. Authenticate it first, this
270
270
  // does not need the parent state
271
271
  const proposerIndex = signedBlock.message.proposerIndex;
272
+ // An active proposer missing from the cache comes from a branch that finalized validators this node never
273
+ // processed, range sync recovers that branch from peer status
274
+ if (proposerIndex >= chain.pubkeyCache.size) {
275
+ throw new BlockGossipError(GossipAction.REJECT, {
276
+ code: BlockErrorCode.UNKNOWN_PROPOSER,
277
+ slot,
278
+ root: blockRootHex,
279
+ proposerIndex,
280
+ });
281
+ }
272
282
  await verifyBlockProposerSignature(chain, signedBlock, blockRootHex);
273
283
  chain.seenBlockProposers.observeBlockRoot(
274
284
  slot,
@@ -676,7 +686,7 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
676
686
  try {
677
687
  const blockInput = await validateBeaconBlock(signedBlock, topic.boundary.fork, peerIdStr, seenTimestampSec);
678
688
  // Runs after the validation result is reported, except with `network.useWorker: false`
679
- callImmediate(() => {
689
+ callAfterIO(() => {
680
690
  try {
681
691
  chain.serializedCache.set(signedBlock, serializedData);
682
692
  handleValidBeaconBlock(blockInput, peerIdStr, seenTimestampSec);
@@ -1301,13 +1311,16 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
1301
1311
  }
1302
1312
  }
1303
1313
 
1304
- chain.forkChoice.notifyPtcMessages(
1305
- toRootHex(payloadAttestationMessage.data.beaconBlockRoot),
1306
- payloadAttestationMessage.data.slot,
1307
- validationResult.validatorCommitteeIndices,
1308
- payloadAttestationMessage.data.payloadPresent,
1309
- payloadAttestationMessage.data.blobDataAvailable
1310
- );
1314
+ // Gossip accepts adjacent slots within the clock disparity but fork choice only counts the current slot
1315
+ if (payloadAttestationMessage.data.slot === chain.clock.currentSlot) {
1316
+ chain.forkChoice.notifyPtcMessages(
1317
+ toRootHex(payloadAttestationMessage.data.beaconBlockRoot),
1318
+ payloadAttestationMessage.data.slot,
1319
+ validationResult.validatorCommitteeIndices,
1320
+ payloadAttestationMessage.data.payloadPresent,
1321
+ payloadAttestationMessage.data.blobDataAvailable
1322
+ );
1323
+ }
1311
1324
 
1312
1325
  chain.emitter.emit(routes.events.EventType.payloadAttestationMessage, {
1313
1326
  version: config.getForkName(payloadAttestationMessage.data.slot),
@@ -1422,12 +1435,11 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
1422
1435
  try {
1423
1436
  metrics?.inclusionListsValid.inc({source: InclusionListSource.gossip});
1424
1437
  metrics?.inclusionListsValidSize.inc(totalBytes);
1425
- // Timely only if received within its own slot before the deadline, so a list for the next slot that
1426
- // passed validation under clock disparity is untimely. Late lists are still stored, marked untimely
1438
+ // A list received before its slot is timely, the spec delays it until the slot starts. Only gossip
1439
+ // validation bounds how early a list can be. Late lists are still stored, marked untimely
1427
1440
  const secFromSlot = chain.clock.secFromSlot(slot, seenTimestampSec);
1428
1441
  metrics?.inclusionListArrivalTime.observe(secFromSlot);
1429
- const isTimely =
1430
- secFromSlot >= 0 && secFromSlot * 1000 < config.getInclusionListDueMs(config.getForkName(slot));
1442
+ const isTimely = secFromSlot * 1000 < config.getInclusionListDueMs(config.getForkName(slot));
1431
1443
 
1432
1444
  const insertOutcome = chain.inclusionListStore.process(signedInclusionList, committeeIndices, isTimely);
1433
1445
  metrics?.inclusionListStore.insertOutcome.inc({insertOutcome});
@@ -12,6 +12,7 @@ import {
12
12
  ExecutionPayloadEnvelopeErrorCode,
13
13
  GossipAction,
14
14
  GossipActionError,
15
+ GossipErrorCode,
15
16
  InclusionListErrorCode,
16
17
  PayloadAttestationErrorCode,
17
18
  ProposerPreferencesErrorCode,
@@ -116,6 +117,9 @@ const gossipRejectPeerAction: Record<GossipType, RejectPeerActionRule> = {
116
117
  };
117
118
 
118
119
  export function rejectPeerAction(type: GossipType, code: string): PeerAction {
120
+ if (code === GossipErrorCode.INVALID_SERIALIZED_BYTES_ERROR_CODE) {
121
+ return PeerAction.LowToleranceError;
122
+ }
119
123
  const rule = gossipRejectPeerAction[type];
120
124
  return rule.byCode?.[code] ?? rule.default;
121
125
  }