@lodestar/beacon-node 1.41.0-dev.aeb5a213ee → 1.41.0-dev.bb273175f2

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 (294) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +3 -2
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/api/impl/beacon/state/index.js +8 -8
  5. package/lib/api/impl/beacon/state/index.js.map +1 -1
  6. package/lib/api/impl/beacon/state/utils.d.ts +3 -4
  7. package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
  8. package/lib/api/impl/beacon/state/utils.js +4 -4
  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 +1 -0
  12. package/lib/api/impl/debug/index.js.map +1 -1
  13. package/lib/api/impl/node/utils.d.ts +1 -1
  14. package/lib/api/impl/node/utils.d.ts.map +1 -1
  15. package/lib/api/impl/node/utils.js.map +1 -1
  16. package/lib/api/impl/validator/index.d.ts.map +1 -1
  17. package/lib/api/impl/validator/index.js +29 -15
  18. package/lib/api/impl/validator/index.js.map +1 -1
  19. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  20. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  21. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts +5 -6
  22. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
  23. package/lib/chain/archiveStore/historicalState/getHistoricalState.js +9 -10
  24. package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
  25. package/lib/chain/archiveStore/historicalState/worker.js +3 -3
  26. package/lib/chain/archiveStore/historicalState/worker.js.map +1 -1
  27. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts +3 -8
  28. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
  29. package/lib/chain/archiveStore/utils/archiveBlocks.js +1 -1
  30. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  31. package/lib/chain/archiveStore/utils/updateBackfillRange.js +1 -1
  32. package/lib/chain/archiveStore/utils/updateBackfillRange.js.map +1 -1
  33. package/lib/chain/blocks/blockInput/blockInput.d.ts +20 -2
  34. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
  35. package/lib/chain/blocks/blockInput/blockInput.js +47 -0
  36. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  37. package/lib/chain/blocks/blockInput/types.d.ts +13 -1
  38. package/lib/chain/blocks/blockInput/types.d.ts.map +1 -1
  39. package/lib/chain/blocks/blockInput/types.js +1 -0
  40. package/lib/chain/blocks/blockInput/types.js.map +1 -1
  41. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  42. package/lib/chain/blocks/importBlock.js +27 -4
  43. package/lib/chain/blocks/importBlock.js.map +1 -1
  44. package/lib/chain/blocks/verifyBlocksDataAvailability.d.ts.map +1 -1
  45. package/lib/chain/blocks/verifyBlocksDataAvailability.js +3 -0
  46. package/lib/chain/blocks/verifyBlocksDataAvailability.js.map +1 -1
  47. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts +4 -0
  48. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
  49. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +5 -1
  50. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  51. package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts.map +1 -1
  52. package/lib/chain/blocks/verifyBlocksSanityChecks.js +4 -1
  53. package/lib/chain/blocks/verifyBlocksSanityChecks.js.map +1 -1
  54. package/lib/chain/blocks/writeBlockInputToDb.d.ts +12 -3
  55. package/lib/chain/blocks/writeBlockInputToDb.d.ts.map +1 -1
  56. package/lib/chain/blocks/writeBlockInputToDb.js +101 -96
  57. package/lib/chain/blocks/writeBlockInputToDb.js.map +1 -1
  58. package/lib/chain/bls/multithread/index.d.ts +3 -3
  59. package/lib/chain/bls/multithread/index.d.ts.map +1 -1
  60. package/lib/chain/bls/multithread/index.js +5 -5
  61. package/lib/chain/bls/multithread/index.js.map +1 -1
  62. package/lib/chain/bls/multithread/jobItem.d.ts +2 -2
  63. package/lib/chain/bls/multithread/jobItem.d.ts.map +1 -1
  64. package/lib/chain/bls/multithread/jobItem.js +2 -2
  65. package/lib/chain/bls/multithread/jobItem.js.map +1 -1
  66. package/lib/chain/bls/singleThread.d.ts +4 -4
  67. package/lib/chain/bls/singleThread.d.ts.map +1 -1
  68. package/lib/chain/bls/singleThread.js +4 -4
  69. package/lib/chain/bls/singleThread.js.map +1 -1
  70. package/lib/chain/bls/utils.d.ts +2 -2
  71. package/lib/chain/bls/utils.d.ts.map +1 -1
  72. package/lib/chain/bls/utils.js +7 -4
  73. package/lib/chain/bls/utils.js.map +1 -1
  74. package/lib/chain/chain.d.ts +5 -8
  75. package/lib/chain/chain.d.ts.map +1 -1
  76. package/lib/chain/chain.js +19 -21
  77. package/lib/chain/chain.js.map +1 -1
  78. package/lib/chain/emitter.d.ts +3 -3
  79. package/lib/chain/emitter.d.ts.map +1 -1
  80. package/lib/chain/errors/executionPayloadEnvelope.d.ts +2 -2
  81. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  82. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  83. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  84. package/lib/chain/forkChoice/index.js +30 -24
  85. package/lib/chain/forkChoice/index.js.map +1 -1
  86. package/lib/chain/interface.d.ts +2 -4
  87. package/lib/chain/interface.d.ts.map +1 -1
  88. package/lib/chain/interface.js.map +1 -1
  89. package/lib/chain/opPools/aggregatedAttestationPool.js +1 -1
  90. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  91. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  92. package/lib/chain/produceBlock/produceBlockBody.js +1 -2
  93. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  94. package/lib/chain/regen/queued.d.ts.map +1 -1
  95. package/lib/chain/regen/queued.js +4 -1
  96. package/lib/chain/regen/queued.js.map +1 -1
  97. package/lib/chain/regen/regen.d.ts.map +1 -1
  98. package/lib/chain/regen/regen.js +6 -2
  99. package/lib/chain/regen/regen.js.map +1 -1
  100. package/lib/chain/seenCache/seenGossipBlockInput.d.ts.map +1 -1
  101. package/lib/chain/seenCache/seenGossipBlockInput.js +15 -7
  102. package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
  103. package/lib/chain/validation/aggregateAndProof.js +1 -1
  104. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  105. package/lib/chain/validation/attestation.d.ts.map +1 -1
  106. package/lib/chain/validation/attestation.js +7 -4
  107. package/lib/chain/validation/attestation.js.map +1 -1
  108. package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
  109. package/lib/chain/validation/attesterSlashing.js +9 -2
  110. package/lib/chain/validation/attesterSlashing.js.map +1 -1
  111. package/lib/chain/validation/blobSidecar.js +2 -2
  112. package/lib/chain/validation/blobSidecar.js.map +1 -1
  113. package/lib/chain/validation/block.d.ts.map +1 -1
  114. package/lib/chain/validation/block.js +6 -3
  115. package/lib/chain/validation/block.js.map +1 -1
  116. package/lib/chain/validation/dataColumnSidecar.js +1 -1
  117. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  118. package/lib/chain/validation/executionPayloadBid.js +1 -2
  119. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  120. package/lib/chain/validation/executionPayloadEnvelope.js +4 -4
  121. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  122. package/lib/chain/validation/payloadAttestationMessage.js +9 -3
  123. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  124. package/lib/chain/validation/proposerSlashing.js +1 -1
  125. package/lib/chain/validation/proposerSlashing.js.map +1 -1
  126. package/lib/chain/validation/syncCommitteeContributionAndProof.js +1 -1
  127. package/lib/db/repositories/blockArchive.d.ts.map +1 -1
  128. package/lib/db/repositories/blockArchive.js +1 -2
  129. package/lib/db/repositories/blockArchive.js.map +1 -1
  130. package/lib/execution/engine/http.d.ts +1 -0
  131. package/lib/execution/engine/http.d.ts.map +1 -1
  132. package/lib/execution/engine/http.js +3 -0
  133. package/lib/execution/engine/http.js.map +1 -1
  134. package/lib/metrics/metrics/lodestar.d.ts +3 -0
  135. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  136. package/lib/metrics/metrics/lodestar.js +5 -0
  137. package/lib/metrics/metrics/lodestar.js.map +1 -1
  138. package/lib/monitoring/service.d.ts +2 -2
  139. package/lib/monitoring/service.d.ts.map +1 -1
  140. package/lib/monitoring/service.js +3 -2
  141. package/lib/monitoring/service.js.map +1 -1
  142. package/lib/network/core/networkCore.d.ts +3 -3
  143. package/lib/network/core/networkCore.d.ts.map +1 -1
  144. package/lib/network/core/networkCore.js.map +1 -1
  145. package/lib/network/core/networkCoreWorkerHandler.d.ts +3 -3
  146. package/lib/network/core/networkCoreWorkerHandler.d.ts.map +1 -1
  147. package/lib/network/core/types.d.ts +2 -2
  148. package/lib/network/core/types.d.ts.map +1 -1
  149. package/lib/network/events.d.ts +2 -1
  150. package/lib/network/events.d.ts.map +1 -1
  151. package/lib/network/events.js.map +1 -1
  152. package/lib/network/gossip/encoding.d.ts +3 -3
  153. package/lib/network/gossip/encoding.d.ts.map +1 -1
  154. package/lib/network/gossip/encoding.js.map +1 -1
  155. package/lib/network/gossip/gossipsub.d.ts +13 -4
  156. package/lib/network/gossip/gossipsub.d.ts.map +1 -1
  157. package/lib/network/gossip/gossipsub.js +47 -20
  158. package/lib/network/gossip/gossipsub.js.map +1 -1
  159. package/lib/network/gossip/interface.d.ts +3 -3
  160. package/lib/network/gossip/interface.d.ts.map +1 -1
  161. package/lib/network/gossip/scoringParameters.d.ts +1 -1
  162. package/lib/network/gossip/scoringParameters.d.ts.map +1 -1
  163. package/lib/network/gossip/scoringParameters.js +1 -1
  164. package/lib/network/gossip/scoringParameters.js.map +1 -1
  165. package/lib/network/interface.d.ts +3 -3
  166. package/lib/network/interface.d.ts.map +1 -1
  167. package/lib/network/libp2p/index.d.ts +1 -1
  168. package/lib/network/libp2p/index.d.ts.map +1 -1
  169. package/lib/network/libp2p/index.js +7 -2
  170. package/lib/network/libp2p/index.js.map +1 -1
  171. package/lib/network/network.d.ts +2 -2
  172. package/lib/network/network.d.ts.map +1 -1
  173. package/lib/network/network.js.map +1 -1
  174. package/lib/network/options.d.ts.map +1 -1
  175. package/lib/network/options.js +3 -0
  176. package/lib/network/options.js.map +1 -1
  177. package/lib/network/peers/datastore.d.ts +7 -5
  178. package/lib/network/peers/datastore.d.ts.map +1 -1
  179. package/lib/network/peers/datastore.js +10 -10
  180. package/lib/network/peers/datastore.js.map +1 -1
  181. package/lib/network/peers/peerManager.d.ts +3 -0
  182. package/lib/network/peers/peerManager.d.ts.map +1 -1
  183. package/lib/network/peers/peerManager.js +103 -53
  184. package/lib/network/peers/peerManager.js.map +1 -1
  185. package/lib/network/peers/utils/prioritizePeers.d.ts +3 -3
  186. package/lib/network/peers/utils/prioritizePeers.d.ts.map +1 -1
  187. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  188. package/lib/network/processor/gossipHandlers.js +4 -1
  189. package/lib/network/processor/gossipHandlers.js.map +1 -1
  190. package/lib/network/processor/gossipValidatorFn.js +1 -1
  191. package/lib/network/processor/types.d.ts +1 -1
  192. package/lib/network/processor/types.d.ts.map +1 -1
  193. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
  194. package/lib/network/reqresp/handlers/beaconBlocksByRange.js +3 -2
  195. package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
  196. package/lib/network/reqresp/handlers/blobSidecarsByRange.d.ts.map +1 -1
  197. package/lib/network/reqresp/handlers/blobSidecarsByRange.js +3 -2
  198. package/lib/network/reqresp/handlers/blobSidecarsByRange.js.map +1 -1
  199. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js +1 -1
  200. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js.map +1 -1
  201. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  202. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +3 -2
  203. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  204. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +1 -1
  205. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
  206. package/lib/network/reqresp/score.d.ts.map +1 -1
  207. package/lib/network/reqresp/score.js +0 -1
  208. package/lib/network/reqresp/score.js.map +1 -1
  209. package/lib/network/util.js +2 -2
  210. package/lib/network/util.js.map +1 -1
  211. package/lib/node/nodejs.d.ts +3 -5
  212. package/lib/node/nodejs.d.ts.map +1 -1
  213. package/lib/node/nodejs.js +6 -4
  214. package/lib/node/nodejs.js.map +1 -1
  215. package/lib/util/clock.d.ts +6 -0
  216. package/lib/util/clock.d.ts.map +1 -1
  217. package/lib/util/clock.js +9 -3
  218. package/lib/util/clock.js.map +1 -1
  219. package/package.json +39 -42
  220. package/src/api/impl/beacon/blocks/index.ts +3 -2
  221. package/src/api/impl/beacon/state/index.ts +8 -8
  222. package/src/api/impl/beacon/state/utils.ts +5 -6
  223. package/src/api/impl/debug/index.ts +1 -0
  224. package/src/api/impl/node/utils.ts +3 -3
  225. package/src/api/impl/validator/index.ts +29 -16
  226. package/src/chain/archiveStore/archiveStore.ts +5 -5
  227. package/src/chain/archiveStore/historicalState/getHistoricalState.ts +10 -11
  228. package/src/chain/archiveStore/historicalState/worker.ts +3 -3
  229. package/src/chain/archiveStore/utils/archiveBlocks.ts +4 -5
  230. package/src/chain/archiveStore/utils/updateBackfillRange.ts +1 -1
  231. package/src/chain/blocks/blockInput/blockInput.ts +68 -3
  232. package/src/chain/blocks/blockInput/types.ts +13 -0
  233. package/src/chain/blocks/importBlock.ts +35 -4
  234. package/src/chain/blocks/verifyBlocksDataAvailability.ts +3 -0
  235. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +9 -2
  236. package/src/chain/blocks/verifyBlocksSanityChecks.ts +7 -2
  237. package/src/chain/blocks/writeBlockInputToDb.ts +119 -101
  238. package/src/chain/bls/multithread/index.ts +7 -7
  239. package/src/chain/bls/multithread/jobItem.ts +3 -3
  240. package/src/chain/bls/singleThread.ts +5 -5
  241. package/src/chain/bls/utils.ts +8 -5
  242. package/src/chain/chain.ts +36 -29
  243. package/src/chain/emitter.ts +3 -3
  244. package/src/chain/errors/executionPayloadEnvelope.ts +6 -2
  245. package/src/chain/forkChoice/index.ts +39 -21
  246. package/src/chain/interface.ts +2 -9
  247. package/src/chain/opPools/aggregatedAttestationPool.ts +1 -1
  248. package/src/chain/produceBlock/produceBlockBody.ts +1 -2
  249. package/src/chain/regen/queued.ts +7 -2
  250. package/src/chain/regen/regen.ts +9 -3
  251. package/src/chain/seenCache/seenGossipBlockInput.ts +16 -7
  252. package/src/chain/validation/aggregateAndProof.ts +1 -1
  253. package/src/chain/validation/attestation.ts +7 -4
  254. package/src/chain/validation/attesterSlashing.ts +10 -1
  255. package/src/chain/validation/blobSidecar.ts +2 -2
  256. package/src/chain/validation/block.ts +9 -4
  257. package/src/chain/validation/dataColumnSidecar.ts +1 -1
  258. package/src/chain/validation/executionPayloadBid.ts +1 -2
  259. package/src/chain/validation/executionPayloadEnvelope.ts +4 -4
  260. package/src/chain/validation/payloadAttestationMessage.ts +10 -3
  261. package/src/chain/validation/proposerSlashing.ts +1 -1
  262. package/src/chain/validation/syncCommitteeContributionAndProof.ts +1 -1
  263. package/src/db/repositories/blockArchive.ts +1 -2
  264. package/src/execution/engine/http.ts +3 -0
  265. package/src/metrics/metrics/lodestar.ts +5 -0
  266. package/src/monitoring/service.ts +3 -2
  267. package/src/network/core/networkCore.ts +3 -3
  268. package/src/network/core/networkCoreWorkerHandler.ts +3 -3
  269. package/src/network/core/types.ts +2 -2
  270. package/src/network/events.ts +2 -1
  271. package/src/network/gossip/encoding.ts +3 -3
  272. package/src/network/gossip/gossipsub.ts +86 -25
  273. package/src/network/gossip/interface.ts +3 -3
  274. package/src/network/gossip/scoringParameters.ts +4 -4
  275. package/src/network/interface.ts +3 -3
  276. package/src/network/libp2p/index.ts +8 -3
  277. package/src/network/network.ts +3 -3
  278. package/src/network/options.ts +3 -0
  279. package/src/network/peers/datastore.ts +13 -10
  280. package/src/network/peers/peerManager.ts +118 -54
  281. package/src/network/peers/utils/prioritizePeers.ts +3 -3
  282. package/src/network/processor/gossipHandlers.ts +12 -3
  283. package/src/network/processor/gossipValidatorFn.ts +1 -1
  284. package/src/network/processor/types.ts +1 -1
  285. package/src/network/reqresp/handlers/beaconBlocksByRange.ts +3 -2
  286. package/src/network/reqresp/handlers/blobSidecarsByRange.ts +3 -2
  287. package/src/network/reqresp/handlers/blobSidecarsByRoot.ts +1 -1
  288. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +3 -2
  289. package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +1 -1
  290. package/src/network/reqresp/score.ts +0 -1
  291. package/src/network/util.ts +2 -2
  292. package/src/node/nodejs.ts +8 -9
  293. package/src/util/clock.ts +9 -4
  294. package/src/util/workerEvents.ts +1 -1
@@ -1,4 +1,4 @@
1
- import {Direction, PeerId} from "@libp2p/interface";
1
+ import type {MessageStreamDirection, PeerId} from "@libp2p/interface";
2
2
  import {BitArray} from "@chainsafe/ssz";
3
3
  import {ChainConfig} from "@lodestar/config";
4
4
  import {ATTESTATION_SUBNET_COUNT, SYNC_COMMITTEE_SUBNET_COUNT} from "@lodestar/params";
@@ -95,7 +95,7 @@ function computeStatusScore(ours: Status, theirs: Status | null, opts: Prioritiz
95
95
 
96
96
  type PeerInfo = {
97
97
  id: PeerId;
98
- direction: Direction | null;
98
+ direction: MessageStreamDirection | null;
99
99
  statusScore: StatusScore;
100
100
  attnets: phase0.AttestationSubnets;
101
101
  syncnets: altair.SyncSubnets;
@@ -137,7 +137,7 @@ export enum ExcessPeerDisconnectReason {
137
137
  export function prioritizePeers(
138
138
  connectedPeersInfo: {
139
139
  id: PeerId;
140
- direction: Direction | null;
140
+ direction: MessageStreamDirection | null;
141
141
  status: Status | null;
142
142
  attnets: phase0.AttestationSubnets | null;
143
143
  syncnets: altair.SyncSubnets | null;
@@ -2,6 +2,7 @@ import {routes} from "@lodestar/api";
2
2
  import {BeaconConfig, ChainForkConfig} from "@lodestar/config";
3
3
  import {
4
4
  ForkName,
5
+ ForkPostDeneb,
5
6
  ForkPostElectra,
6
7
  ForkPreElectra,
7
8
  ForkSeq,
@@ -70,6 +71,7 @@ import {validateGossipPayloadAttestationMessage} from "../../chain/validation/pa
70
71
  import {OpSource} from "../../chain/validatorMonitor.js";
71
72
  import {Metrics} from "../../metrics/index.js";
72
73
  import {kzgCommitmentToVersionedHash} from "../../util/blobs.js";
74
+ import {getBlobKzgCommitments} from "../../util/dataColumns.ts";
73
75
  import {INetworkCore} from "../core/index.js";
74
76
  import {NetworkEventBus} from "../events.js";
75
77
  import {
@@ -417,9 +419,11 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
417
419
  chain.getBlobsTracker.triggerGetBlobs(blockInput);
418
420
  } else {
419
421
  metrics?.blockInputFetchStats.totalDataAvailableBlockInputs.inc();
420
- metrics?.blockInputFetchStats.totalDataAvailableBlockInputBlobs.inc(
421
- (signedBlock.message as deneb.BeaconBlock).body.blobKzgCommitments.length
422
- );
422
+ const blobCount = getBlobKzgCommitments(
423
+ blockInput.forkName,
424
+ signedBlock as SignedBeaconBlock<ForkPostDeneb>
425
+ ).length;
426
+ metrics?.blockInputFetchStats.totalDataAvailableBlockInputBlobs.inc(blobCount);
423
427
  }
424
428
 
425
429
  chain
@@ -852,6 +856,11 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
852
856
  } catch (e) {
853
857
  logger.error("Error adding to payloadAttestation pool", {}, e as Error);
854
858
  }
859
+ chain.forkChoice.notifyPtcMessages(
860
+ toRootHex(payloadAttestationMessage.data.beaconBlockRoot),
861
+ [validationResult.validatorCommitteeIndex],
862
+ payloadAttestationMessage.data.payloadPresent
863
+ );
855
864
  },
856
865
  [GossipType.execution_payload_bid]: async ({
857
866
  gossipData,
@@ -1,4 +1,4 @@
1
- import {TopicValidatorResult} from "@libp2p/interface";
1
+ import {TopicValidatorResult} from "@libp2p/gossipsub";
2
2
  import {ChainForkConfig} from "@lodestar/config";
3
3
  import {Logger} from "@lodestar/utils";
4
4
  import {AttestationError, GossipAction, GossipActionError} from "../../chain/errors/index.js";
@@ -1,4 +1,4 @@
1
- import {Message} from "@libp2p/interface";
1
+ import type {Message} from "@libp2p/gossipsub";
2
2
  import {ForkName} from "@lodestar/params";
3
3
  import {Slot, SlotOptionalRoot} from "@lodestar/types";
4
4
  import {PeerIdStr} from "../../util/peerId.js";
@@ -47,9 +47,10 @@ export async function* onBeaconBlocksByRange(
47
47
 
48
48
  // Non-finalized range of blocks
49
49
  if (endSlot > finalizedSlot) {
50
- const headRoot = chain.forkChoice.getHeadRoot();
50
+ const headBlock = chain.forkChoice.getHead();
51
+ const headRoot = headBlock.blockRoot;
51
52
  // TODO DENEB: forkChoice should mantain an array of canonical blocks, and change only on reorg
52
- const headChain = chain.forkChoice.getAllAncestorBlocks(headRoot);
53
+ const headChain = chain.forkChoice.getAllAncestorBlocks(headRoot, headBlock.payloadStatus);
53
54
  // getAllAncestorBlocks response includes the head node, so it's the full chain.
54
55
 
55
56
  // Iterate head chain with ascending block numbers
@@ -34,9 +34,10 @@ export async function* onBlobSidecarsByRange(
34
34
 
35
35
  // Non-finalized range of blobs
36
36
  if (endSlot > finalizedSlot) {
37
- const headRoot = chain.forkChoice.getHeadRoot();
37
+ const headBlock = chain.forkChoice.getHead();
38
+ const headRoot = headBlock.blockRoot;
38
39
  // TODO DENEB: forkChoice should mantain an array of canonical blocks, and change only on reorg
39
- const headChain = chain.forkChoice.getAllAncestorBlocks(headRoot);
40
+ const headChain = chain.forkChoice.getAllAncestorBlocks(headRoot, headBlock.payloadStatus);
40
41
 
41
42
  // Iterate head chain with ascending block numbers
42
43
  for (let i = headChain.length - 1; i >= 0; i--) {
@@ -20,7 +20,7 @@ export async function* onBlobSidecarsByRoot(
20
20
  for (const blobIdentifier of requestBody) {
21
21
  const {blockRoot, index} = blobIdentifier;
22
22
  const blockRootHex = toRootHex(blockRoot);
23
- const block = chain.forkChoice.getBlockHex(blockRootHex);
23
+ const block = chain.forkChoice.getBlockHexDefaultStatus(blockRootHex);
24
24
 
25
25
  // NOTE: Only support non-finalized blocks.
26
26
  // SPEC: Clients MUST support requesting blocks and sidecars since the latest finalized epoch.
@@ -78,8 +78,9 @@ export async function* onDataColumnSidecarsByRange(
78
78
 
79
79
  // Non-finalized range of columns
80
80
  if (endSlot > finalizedSlot) {
81
- const headRoot = chain.forkChoice.getHeadRoot();
82
- const headChain = chain.forkChoice.getAllAncestorBlocks(headRoot);
81
+ const headBlock = chain.forkChoice.getHead();
82
+ const headRoot = headBlock.blockRoot;
83
+ const headChain = chain.forkChoice.getAllAncestorBlocks(headRoot, headBlock.payloadStatus);
83
84
 
84
85
  // Iterate head chain with ascending block numbers
85
86
  for (let i = headChain.length - 1; i >= 0; i--) {
@@ -34,7 +34,7 @@ export async function* onDataColumnSidecarsByRoot(
34
34
  }
35
35
 
36
36
  const blockRootHex = toRootHex(blockRoot);
37
- const block = chain.forkChoice.getBlockHex(blockRootHex);
37
+ const block = chain.forkChoice.getBlockHexDefaultStatus(blockRootHex);
38
38
  // If the block is not in fork choice, it may be finalized. Attempt to find its slot in block archive
39
39
  const slot = block ? block.slot : await db.blockArchive.getSlotByRoot(blockRoot);
40
40
 
@@ -38,7 +38,6 @@ export function onOutgoingReqRespError(e: RequestError, method: ReqRespMethod):
38
38
  : PeerAction.LowToleranceError;
39
39
  // TODO: Detect SSZDecodeError and return PeerAction.Fatal
40
40
 
41
- case RequestErrorCode.TTFB_TIMEOUT:
42
41
  case RequestErrorCode.RESP_TIMEOUT:
43
42
  switch (method) {
44
43
  case ReqRespMethod.Ping:
@@ -23,7 +23,7 @@ export function getConnection(libp2p: Libp2p, peerIdStr: string): Connection | u
23
23
  return getConnectionsMap(libp2p).get(peerIdStr)?.value[0] ?? undefined;
24
24
  }
25
25
 
26
- // https://github.com/ChainSafe/js-libp2p-gossipsub/blob/3475242ed254f7647798ab7f36b21909f6cb61da/src/index.ts#L2009
26
+ // https://github.com/libp2p/js-libp2p/blob/f87cba928991736d9646b3e054c367f55cab315c/packages/gossipsub/src/gossipsub.ts#L2076
27
27
  export function isPublishToZeroPeersError(e: Error): boolean {
28
- return e.message.includes("PublishError.InsufficientPeers");
28
+ return e.message.includes("PublishError.NoPeersSubscribedToTopic");
29
29
  }
@@ -2,12 +2,11 @@ import {setMaxListeners} from "node:events";
2
2
  import {PrivateKey} from "@libp2p/interface";
3
3
  import {Registry} from "prom-client";
4
4
  import {hasher} from "@chainsafe/persistent-merkle-tree";
5
- import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map";
6
5
  import {BeaconApiMethods} from "@lodestar/api/beacon/server";
7
6
  import {BeaconConfig} from "@lodestar/config";
8
7
  import type {LoggerNode} from "@lodestar/logger/node";
9
8
  import {ZERO_HASH_HEX} from "@lodestar/params";
10
- import {CachedBeaconStateAllForks, Index2PubkeyCache, isExecutionCachedStateType} from "@lodestar/state-transition";
9
+ import {CachedBeaconStateAllForks, PubkeyCache, isExecutionCachedStateType} from "@lodestar/state-transition";
11
10
  import {phase0} from "@lodestar/types";
12
11
  import {sleep, toRootHex} from "@lodestar/utils";
13
12
  import {ProcessShutdownCallback} from "@lodestar/validator";
@@ -47,8 +46,7 @@ export type BeaconNodeModules = {
47
46
  export type BeaconNodeInitModules = {
48
47
  opts: IBeaconNodeOptions;
49
48
  config: BeaconConfig;
50
- pubkey2index: PubkeyIndexMap;
51
- index2pubkey: Index2PubkeyCache;
49
+ pubkeyCache: PubkeyCache;
52
50
  db: IBeaconDb;
53
51
  logger: LoggerNode;
54
52
  processShutdownCallback: ProcessShutdownCallback;
@@ -150,8 +148,7 @@ export class BeaconNode {
150
148
  static async init<T extends BeaconNode = BeaconNode>({
151
149
  opts,
152
150
  config,
153
- pubkey2index,
154
- index2pubkey,
151
+ pubkeyCache,
155
152
  db,
156
153
  logger,
157
154
  processShutdownCallback,
@@ -240,8 +237,7 @@ export class BeaconNode {
240
237
  privateKey,
241
238
  config,
242
239
  clock,
243
- pubkey2index,
244
- index2pubkey,
240
+ pubkeyCache,
245
241
  dataDir,
246
242
  db,
247
243
  dbName: opts.db.name,
@@ -364,9 +360,12 @@ export class BeaconNode {
364
360
  if (this.restApi) await this.restApi.close();
365
361
  await this.network.close();
366
362
  if (this.metricsServer) await this.metricsServer.close();
367
- if (this.monitoring) this.monitoring.close();
363
+ if (this.monitoring) await this.monitoring.close();
368
364
  await this.chain.persistToDisk();
369
365
  await this.chain.close();
366
+ // Abort signal last: close() calls above clear intervals/timeouts so no new
367
+ // operations get scheduled. If we aborted first, a still-pending interval could
368
+ // fire and schedule a new operation after abort, leaving it stuck and delaying shutdown.
370
369
  if (this.controller) this.controller.abort();
371
370
  await sleep(DELAY_BEFORE_CLOSING_DB_MS);
372
371
  await this.db.close();
package/src/util/clock.ts CHANGED
@@ -92,15 +92,17 @@ export class Clock extends EventEmitter implements IClock {
92
92
  }
93
93
  return slot;
94
94
  }
95
-
96
95
  /**
97
96
  * If it's too close to next slot given MAXIMUM_GOSSIP_CLOCK_DISPARITY, return currentSlot + 1.
98
97
  * Otherwise return currentSlot
98
+ *
99
+ * Spec: phase0/p2p-interface.md - gossip validation uses `current_time + MAXIMUM_GOSSIP_CLOCK_DISPARITY < message_time`
100
+ * to reject future messages (strict `<`), so the boundary (exactly equal) is accepted, hence `<=` here.
99
101
  */
100
102
  get currentSlotWithGossipDisparity(): Slot {
101
103
  const currentSlot = this.currentSlot;
102
104
  const nextSlotTime = computeTimeAtSlot(this.config, currentSlot + 1, this.genesisTime) * 1000;
103
- return nextSlotTime - Date.now() < this.config.MAXIMUM_GOSSIP_CLOCK_DISPARITY ? currentSlot + 1 : currentSlot;
105
+ return nextSlotTime - Date.now() <= this.config.MAXIMUM_GOSSIP_CLOCK_DISPARITY ? currentSlot + 1 : currentSlot;
104
106
  }
105
107
 
106
108
  get currentEpoch(): Epoch {
@@ -121,6 +123,9 @@ export class Clock extends EventEmitter implements IClock {
121
123
 
122
124
  /**
123
125
  * Check if a slot is current slot given MAXIMUM_GOSSIP_CLOCK_DISPARITY.
126
+ *
127
+ * Uses `<=` for disparity checks because the spec rejects with strict `<`
128
+ * (phase0/p2p-interface.md), meaning the boundary (exactly equal) is accepted.
124
129
  */
125
130
  isCurrentSlotGivenGossipDisparity(slot: Slot): boolean {
126
131
  const currentSlot = this.currentSlot;
@@ -129,12 +134,12 @@ export class Clock extends EventEmitter implements IClock {
129
134
  }
130
135
  const nextSlotTime = computeTimeAtSlot(this.config, currentSlot + 1, this.genesisTime) * 1000;
131
136
  // we're too close to next slot, accept next slot
132
- if (nextSlotTime - Date.now() < this.config.MAXIMUM_GOSSIP_CLOCK_DISPARITY) {
137
+ if (nextSlotTime - Date.now() <= this.config.MAXIMUM_GOSSIP_CLOCK_DISPARITY) {
133
138
  return slot === currentSlot + 1;
134
139
  }
135
140
  const currentSlotTime = computeTimeAtSlot(this.config, currentSlot, this.genesisTime) * 1000;
136
141
  // we've just passed the current slot, accept previous slot
137
- if (Date.now() - currentSlotTime < this.config.MAXIMUM_GOSSIP_CLOCK_DISPARITY) {
142
+ if (Date.now() - currentSlotTime <= this.config.MAXIMUM_GOSSIP_CLOCK_DISPARITY) {
138
143
  return slot === currentSlot - 1;
139
144
  }
140
145
  return false;
@@ -1,5 +1,5 @@
1
1
  import {MessagePort, Worker} from "node:worker_threads";
2
- import {Message} from "@libp2p/interface";
2
+ import type {Message} from "@libp2p/gossipsub";
3
3
  import {Thread} from "@chainsafe/threads";
4
4
  import {Logger} from "@lodestar/logger";
5
5
  import {sleep} from "@lodestar/utils";