@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
@@ -4,9 +4,11 @@ import {
4
4
  ForkChoice,
5
5
  ForkChoiceStore,
6
6
  JustifiedBalancesGetter,
7
+ PayloadStatus,
7
8
  ProtoArray,
8
9
  ProtoBlock,
9
10
  ForkChoiceOpts as RawForkChoiceOpts,
11
+ getCheckpointPayloadStatus,
10
12
  } from "@lodestar/fork-choice";
11
13
  import {ZERO_HASH_HEX} from "@lodestar/params";
12
14
  import {
@@ -104,6 +106,14 @@ export function initializeForkChoiceFromFinalizedState(
104
106
  // production code use ForkChoice constructor directly
105
107
  const forkchoiceConstructor = opts.forkchoiceConstructor ?? ForkChoice;
106
108
 
109
+ const isForkPostGloas = (state as CachedBeaconStateGloas).latestBlockHash !== undefined;
110
+
111
+ // Determine justified checkpoint payload status
112
+ const justifiedPayloadStatus = getCheckpointPayloadStatus(state, justifiedCheckpoint.epoch);
113
+
114
+ // Determine finalized checkpoint payload status
115
+ const finalizedPayloadStatus = getCheckpointPayloadStatus(state, finalizedCheckpoint.epoch);
116
+
107
117
  return new forkchoiceConstructor(
108
118
  config,
109
119
 
@@ -113,6 +123,8 @@ export function initializeForkChoiceFromFinalizedState(
113
123
  finalizedCheckpoint,
114
124
  justifiedBalances,
115
125
  justifiedBalancesGetter,
126
+ justifiedPayloadStatus,
127
+ finalizedPayloadStatus,
116
128
  {
117
129
  onJustified: (cp) => emitter.emit(ChainEvent.forkChoiceJustified, cp),
118
130
  onFinalized: (cp) => emitter.emit(ChainEvent.forkChoiceFinalized, cp),
@@ -145,15 +157,12 @@ export function initializeForkChoiceFromFinalizedState(
145
157
  : {executionPayloadBlockHash: null, executionStatus: ExecutionStatus.PreMerge}),
146
158
 
147
159
  dataAvailabilityStatus: DataAvailabilityStatus.PreData,
148
- ...(computeEpochAtSlot(blockHeader.slot) < state.config.GLOAS_FORK_EPOCH
149
- ? {
150
- builderIndex: undefined,
151
- blockHashHex: undefined,
152
- }
153
- : {
154
- builderIndex: (state as CachedBeaconStateGloas).latestExecutionPayloadBid.builderIndex,
155
- blockHashHex: toRootHex((state as CachedBeaconStateGloas).latestExecutionPayloadBid.blockHash),
156
- }),
160
+ payloadStatus: isForkPostGloas ? PayloadStatus.PENDING : PayloadStatus.FULL, // TODO GLOAS: Post-gloas how do we know if the checkpoint payload is FULL or EMPTY?
161
+ builderIndex: isForkPostGloas ? (state as CachedBeaconStateGloas).latestExecutionPayloadBid.builderIndex : null,
162
+ blockHashFromBid: isForkPostGloas
163
+ ? toRootHex((state as CachedBeaconStateGloas).latestExecutionPayloadBid.blockHash)
164
+ : null,
165
+ parentBlockHash: isForkPostGloas ? toRootHex((state as CachedBeaconStateGloas).latestBlockHash) : null,
157
166
  },
158
167
  currentSlot
159
168
  ),
@@ -196,12 +205,22 @@ export function initializeForkChoiceFromUnfinalizedState(
196
205
 
197
206
  // this is not the justified state, but there is no other ways to get justified balances
198
207
  const justifiedBalances = getEffectiveBalanceIncrementsZeroInactive(unfinalizedState);
208
+
209
+ const isForkPostGloas = (unfinalizedState as CachedBeaconStateGloas).latestBlockHash !== undefined;
210
+
211
+ // For unfinalized state, use getCheckpointPayloadStatus to determine the correct status.
212
+ // It checks state.execution_payload_availability to determine EMPTY vs FULL.
213
+ const justifiedPayloadStatus = getCheckpointPayloadStatus(unfinalizedState, justifiedCheckpoint.epoch);
214
+ const finalizedPayloadStatus = getCheckpointPayloadStatus(unfinalizedState, finalizedCheckpoint.epoch);
215
+
199
216
  const store = new ForkChoiceStore(
200
217
  currentSlot,
201
218
  justifiedCheckpoint,
202
219
  finalizedCheckpoint,
203
220
  justifiedBalances,
204
221
  justifiedBalancesGetter,
222
+ justifiedPayloadStatus,
223
+ finalizedPayloadStatus,
205
224
  {
206
225
  onJustified: (cp) => emitter.emit(ChainEvent.forkChoiceJustified, cp),
207
226
  onFinalized: (cp) => emitter.emit(ChainEvent.forkChoiceFinalized, cp),
@@ -235,15 +254,14 @@ export function initializeForkChoiceFromUnfinalizedState(
235
254
  : {executionPayloadBlockHash: null, executionStatus: ExecutionStatus.PreMerge}),
236
255
 
237
256
  dataAvailabilityStatus: DataAvailabilityStatus.PreData,
238
- ...(computeEpochAtSlot(blockHeader.slot) < unfinalizedState.config.GLOAS_FORK_EPOCH
239
- ? {
240
- builderIndex: undefined,
241
- blockHashHex: undefined,
242
- }
243
- : {
244
- builderIndex: (unfinalizedState as CachedBeaconStateGloas).latestExecutionPayloadBid.builderIndex,
245
- blockHashHex: toRootHex((unfinalizedState as CachedBeaconStateGloas).latestExecutionPayloadBid.blockHash),
246
- }),
257
+ payloadStatus: isForkPostGloas ? PayloadStatus.PENDING : PayloadStatus.FULL, // TODO GLOAS: Post-gloas how do we know if the checkpoint payload is FULL or EMPTY?
258
+ builderIndex: isForkPostGloas
259
+ ? (unfinalizedState as CachedBeaconStateGloas).latestExecutionPayloadBid.builderIndex
260
+ : null,
261
+ blockHashFromBid: isForkPostGloas
262
+ ? toRootHex((unfinalizedState as CachedBeaconStateGloas).latestExecutionPayloadBid.blockHash)
263
+ : null,
264
+ parentBlockHash: isForkPostGloas ? toRootHex((unfinalizedState as CachedBeaconStateGloas).latestBlockHash) : null,
247
265
  };
248
266
 
249
267
  const parentSlot = blockHeader.slot - 1;
@@ -285,9 +303,9 @@ export function initializeForkChoiceFromUnfinalizedState(
285
303
  };
286
304
 
287
305
  const protoArray = ProtoArray.initialize(finalizedBlock, currentSlot);
288
- protoArray.onBlock(justifiedBlock, currentSlot);
289
- protoArray.onBlock(parentBlock, currentSlot);
290
- protoArray.onBlock(headBlock, currentSlot);
306
+ protoArray.onBlock(justifiedBlock, currentSlot, null);
307
+ protoArray.onBlock(parentBlock, currentSlot, null);
308
+ protoArray.onBlock(headBlock, currentSlot, null);
291
309
 
292
310
  logger?.verbose("Initialized protoArray successfully", {...logCtx, length: protoArray.length()});
293
311
 
@@ -1,13 +1,7 @@
1
- import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map";
2
1
  import {CompositeTypeAny, TreeView, Type} from "@chainsafe/ssz";
3
2
  import {BeaconConfig} from "@lodestar/config";
4
3
  import {CheckpointWithHex, IForkChoice, ProtoBlock} from "@lodestar/fork-choice";
5
- import {
6
- BeaconStateAllForks,
7
- CachedBeaconStateAllForks,
8
- EpochShuffling,
9
- Index2PubkeyCache,
10
- } from "@lodestar/state-transition";
4
+ import {BeaconStateAllForks, CachedBeaconStateAllForks, EpochShuffling, PubkeyCache} from "@lodestar/state-transition";
11
5
  import {
12
6
  BeaconBlock,
13
7
  BlindedBeaconBlock,
@@ -117,8 +111,7 @@ export interface IBeaconChain {
117
111
  readonly regen: IStateRegenerator;
118
112
  readonly lightClientServer?: LightClientServer;
119
113
  readonly reprocessController: ReprocessController;
120
- readonly pubkey2index: PubkeyIndexMap;
121
- readonly index2pubkey: Index2PubkeyCache;
114
+ readonly pubkeyCache: PubkeyCache;
122
115
  readonly archiveStore: IArchiveStore;
123
116
 
124
117
  // Ops pool
@@ -864,7 +864,7 @@ function isValidShuffling(
864
864
  // attestation's shuffling is the same as the current state's.
865
865
  // To account for skipped slots, find the first block at *or before* the pivot slot.
866
866
  const beaconBlockRootHex = blockRootHex;
867
- const beaconBlock = forkChoice.getBlockHex(beaconBlockRootHex);
867
+ const beaconBlock = forkChoice.getBlockHexDefaultStatus(beaconBlockRootHex);
868
868
  if (!beaconBlock) {
869
869
  return InvalidAttestationData.BlockNotInForkChoice;
870
870
  }
@@ -723,8 +723,7 @@ export function getPayloadAttributesForSSE(
723
723
 
724
724
  let parentBlockNumber: number;
725
725
  if (isForkPostGloas(fork)) {
726
- // TODO GLOAS: revisit this after fork choice changes are merged
727
- const parentBlock = chain.forkChoice.getBlock(parentBlockRoot);
726
+ const parentBlock = chain.forkChoice.getBlockHexAndBlockHash(toRootHex(parentBlockRoot), toRootHex(parentHash));
728
727
  if (parentBlock?.executionPayloadBlockHash == null) {
729
728
  throw Error(`Parent block not found in fork choice root=${toRootHex(parentBlockRoot)}`);
730
729
  }
@@ -1,7 +1,7 @@
1
1
  import {routes} from "@lodestar/api";
2
2
  import {IForkChoice, ProtoBlock} from "@lodestar/fork-choice";
3
3
  import {CachedBeaconStateAllForks, computeEpochAtSlot} from "@lodestar/state-transition";
4
- import {BeaconBlock, Epoch, RootHex, Slot, phase0} from "@lodestar/types";
4
+ import {BeaconBlock, Epoch, RootHex, Slot, isGloasBeaconBlock, phase0} from "@lodestar/types";
5
5
  import {Logger, toRootHex} from "@lodestar/utils";
6
6
  import {Metrics} from "../../metrics/index.js";
7
7
  import {JobItemQueue} from "../../util/queue/index.js";
@@ -88,7 +88,12 @@ export class QueuedStateRegenerator implements IStateRegenerator {
88
88
  */
89
89
  getPreStateSync(block: BeaconBlock): CachedBeaconStateAllForks | null {
90
90
  const parentRoot = toRootHex(block.parentRoot);
91
- const parentBlock = this.forkChoice.getBlockHex(parentRoot);
91
+ const parentBlock = isGloasBeaconBlock(block)
92
+ ? this.forkChoice.getBlockHexAndBlockHash(
93
+ parentRoot,
94
+ toRootHex(block.body.signedExecutionPayloadBid.message.parentBlockHash)
95
+ )
96
+ : this.forkChoice.getBlockHexDefaultStatus(parentRoot);
92
97
  if (!parentBlock) {
93
98
  throw new RegenError({
94
99
  code: RegenErrorCode.BLOCK_NOT_IN_FORKCHOICE,
@@ -11,7 +11,7 @@ import {
11
11
  processSlots,
12
12
  stateTransition,
13
13
  } from "@lodestar/state-transition";
14
- import {BeaconBlock, RootHex, SignedBeaconBlock, Slot} from "@lodestar/types";
14
+ import {BeaconBlock, RootHex, SignedBeaconBlock, Slot, isGloasBeaconBlock} from "@lodestar/types";
15
15
  import {Logger, fromHex, toRootHex} from "@lodestar/utils";
16
16
  import {IBeaconDb} from "../../db/index.js";
17
17
  import {Metrics} from "../../metrics/index.js";
@@ -58,7 +58,13 @@ export class StateRegenerator implements IStateRegeneratorInternal {
58
58
  opts: StateRegenerationOpts,
59
59
  regenCaller: RegenCaller
60
60
  ): Promise<CachedBeaconStateAllForks> {
61
- const parentBlock = this.modules.forkChoice.getBlock(block.parentRoot);
61
+ const parentRoot = toRootHex(block.parentRoot);
62
+ const parentBlock = isGloasBeaconBlock(block)
63
+ ? this.modules.forkChoice.getBlockHexAndBlockHash(
64
+ parentRoot,
65
+ toRootHex(block.body.signedExecutionPayloadBid.message.parentBlockHash)
66
+ )
67
+ : this.modules.forkChoice.getBlockHexDefaultStatus(parentRoot);
62
68
  if (!parentBlock) {
63
69
  throw new RegenError({
64
70
  code: RegenErrorCode.BLOCK_NOT_IN_FORKCHOICE,
@@ -152,7 +158,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
152
158
 
153
159
  const getSeedStateTimer = this.modules.metrics?.regenGetState.getSeedState.startTimer({caller});
154
160
  // iterateAncestorBlocks only returns ancestor blocks, not the block itself
155
- for (const b of this.modules.forkChoice.iterateAncestorBlocks(block.blockRoot)) {
161
+ for (const b of this.modules.forkChoice.iterateAncestorBlocks(block.blockRoot, block.payloadStatus)) {
156
162
  state = this.modules.blockStateCache.get(b.stateRoot);
157
163
  if (state) {
158
164
  break;
@@ -3,6 +3,7 @@ import {CheckpointWithHex} from "@lodestar/fork-choice";
3
3
  import {
4
4
  ForkName,
5
5
  ForkPostFulu,
6
+ ForkPostGloas,
6
7
  ForkPreGloas,
7
8
  SLOTS_PER_EPOCH,
8
9
  isForkPostDeneb,
@@ -20,6 +21,7 @@ import {
20
21
  BlockInput,
21
22
  BlockInputBlobs,
22
23
  BlockInputColumns,
24
+ BlockInputNoData,
23
25
  BlockInputPreData,
24
26
  BlockWithSource,
25
27
  DAType,
@@ -179,12 +181,19 @@ export class SeenBlockInput {
179
181
  if (!blockInput) {
180
182
  const {forkName, daOutOfRange} = this.buildCommonProps(block.message.slot);
181
183
 
182
- // TODO GLOAS: Implement
183
184
  if (isForkPostGloas(forkName)) {
184
- throw Error("Not implemented");
185
- }
186
- // Pre-deneb
187
- if (!isForkPostDeneb(forkName)) {
185
+ // Post-gloas
186
+ blockInput = BlockInputNoData.createFromBlock({
187
+ block: block as SignedBeaconBlock<ForkPostGloas>,
188
+ blockRootHex,
189
+ daOutOfRange,
190
+ forkName,
191
+ source,
192
+ seenTimestampSec,
193
+ peerIdStr,
194
+ });
195
+ } else if (!isForkPostDeneb(forkName)) {
196
+ // Pre-deneb
188
197
  blockInput = BlockInputPreData.createFromBlock({
189
198
  block,
190
199
  blockRootHex,
@@ -194,8 +203,8 @@ export class SeenBlockInput {
194
203
  seenTimestampSec,
195
204
  peerIdStr,
196
205
  });
197
- // Fulu Only
198
206
  } else if (isForkPostFulu(forkName)) {
207
+ // Fulu Only
199
208
  blockInput = BlockInputColumns.createFromBlock({
200
209
  block: block as SignedBeaconBlock<ForkPostFulu & ForkPreGloas>,
201
210
  blockRootHex,
@@ -207,8 +216,8 @@ export class SeenBlockInput {
207
216
  seenTimestampSec,
208
217
  peerIdStr,
209
218
  });
210
- // Deneb and Electra
211
219
  } else {
220
+ // Deneb and Electra
212
221
  blockInput = BlockInputBlobs.createFromBlock({
213
222
  block: block as SignedBeaconBlock<ForkBlobsDA>,
214
223
  blockRootHex,
@@ -81,7 +81,7 @@ async function validateAggregateAndProof(
81
81
  });
82
82
  }
83
83
  // [REJECT] `aggregate.data.index == 0` if `block.slot == aggregate.data.slot`.
84
- const block = chain.forkChoice.getBlock(attData.beaconBlockRoot);
84
+ const block = chain.forkChoice.getBlockDefaultStatus(attData.beaconBlockRoot);
85
85
 
86
86
  // If block is unknown, we don't handle it here. It will throw error later on at `verifyHeadBlockAndTargetRoot()`
87
87
  if (block !== null && block.slot === attData.slot && attData.index !== 0) {
@@ -143,7 +143,10 @@ export async function validateGossipAttestationsSameAttData(
143
143
  if (batchableBls) {
144
144
  // all signature sets should have same signing root since we filtered in network processor
145
145
  signatureValids = await chain.bls.verifySignatureSetsSameMessage(
146
- signatureSets.map((set) => ({publicKey: chain.index2pubkey[set.index], signature: set.signature})),
146
+ signatureSets.map((set) => {
147
+ const publicKey = chain.pubkeyCache.getOrThrow(set.index);
148
+ return {publicKey, signature: set.signature};
149
+ }),
147
150
  signatureSets[0].signingRoot
148
151
  );
149
152
  } else {
@@ -183,7 +186,7 @@ export async function validateGossipAttestationsSameAttData(
183
186
  chain.seenAttesters.add(targetEpoch, validatorIndex);
184
187
  } else {
185
188
  step0ResultOrErrors[oldIndex] = {
186
- err: new AttestationError(GossipAction.IGNORE, {
189
+ err: new AttestationError(GossipAction.REJECT, {
187
190
  code: AttestationErrorCode.INVALID_SIGNATURE,
188
191
  }),
189
192
  };
@@ -304,7 +307,7 @@ async function validateAttestationNoSignatureCheck(
304
307
  }
305
308
 
306
309
  // [REJECT] `attestation.data.index == 0` if `block.slot == attestation.data.slot`.
307
- const block = chain.forkChoice.getBlock(attData.beaconBlockRoot);
310
+ const block = chain.forkChoice.getBlockDefaultStatus(attData.beaconBlockRoot);
308
311
 
309
312
  // block being null will be handled by `verifyHeadBlockAndTargetRoot`
310
313
  if (block !== null && block.slot === attSlot && attData.index !== 0) {
@@ -753,7 +756,7 @@ export function getAttestationDataSigningRoot(config: BeaconConfig, data: phase0
753
756
  function verifyHeadBlockIsKnown(chain: IBeaconChain, beaconBlockRoot: Root): ProtoBlock {
754
757
  // TODO (LH): Enforce a maximum skip distance for unaggregated attestations.
755
758
 
756
- const headBlock = chain.forkChoice.getBlock(beaconBlockRoot);
759
+ const headBlock = chain.forkChoice.getBlockDefaultStatus(beaconBlockRoot);
757
760
  if (headBlock === null) {
758
761
  throw new AttestationError(GossipAction.IGNORE, {
759
762
  code: AttestationErrorCode.UNKNOWN_OR_PREFINALIZED_BEACON_BLOCK_ROOT,
@@ -2,6 +2,7 @@ import {
2
2
  assertValidAttesterSlashing,
3
3
  getAttesterSlashableIndices,
4
4
  getAttesterSlashingSignatureSets,
5
+ isSlashableValidator,
5
6
  } from "@lodestar/state-transition";
6
7
  import {AttesterSlashing} from "@lodestar/types";
7
8
  import {AttesterSlashingError, AttesterSlashingErrorCode, GossipAction} from "../errors/index.js";
@@ -45,7 +46,7 @@ export async function validateAttesterSlashing(
45
46
  // verifySignature = false, verified in batch below
46
47
  assertValidAttesterSlashing(
47
48
  chain.config,
48
- chain.index2pubkey,
49
+ chain.pubkeyCache,
49
50
  state.slot,
50
51
  state.validators.length,
51
52
  attesterSlashing,
@@ -58,6 +59,14 @@ export async function validateAttesterSlashing(
58
59
  });
59
60
  }
60
61
 
62
+ const currentEpoch = state.epochCtx.epoch;
63
+ if (!intersectingIndices.some((index) => isSlashableValidator(state.validators.getReadonly(index), currentEpoch))) {
64
+ throw new AttesterSlashingError(GossipAction.REJECT, {
65
+ code: AttesterSlashingErrorCode.INVALID,
66
+ error: Error("AttesterSlashing has no slashable validators"),
67
+ });
68
+ }
69
+
61
70
  const signatureSets = getAttesterSlashingSignatureSets(chain.config, state.slot, attesterSlashing);
62
71
  if (!(await chain.bls.verifySignatureSets(signatureSets, {batchable: true, priority: prioritizeBls}))) {
63
72
  throw new AttesterSlashingError(GossipAction.REJECT, {
@@ -78,7 +78,7 @@ export async function validateGossipBlobSidecar(
78
78
  // already know this block.
79
79
  const blockRoot = ssz.phase0.BeaconBlockHeader.hashTreeRoot(blobSidecar.signedBlockHeader.message);
80
80
  const blockHex = toRootHex(blockRoot);
81
- if (chain.forkChoice.getBlockHex(blockHex) !== null) {
81
+ if (chain.forkChoice.getBlockHexDefaultStatus(blockHex) !== null) {
82
82
  throw new BlobSidecarGossipError(GossipAction.IGNORE, {code: BlobSidecarErrorCode.ALREADY_KNOWN, root: blockHex});
83
83
  }
84
84
 
@@ -89,7 +89,7 @@ export async function validateGossipBlobSidecar(
89
89
  // gossip and non-gossip sources) (a client MAY queue blocks for processing once the parent block is
90
90
  // retrieved).
91
91
  const parentRoot = toRootHex(blobSidecar.signedBlockHeader.message.parentRoot);
92
- const parentBlock = chain.forkChoice.getBlockHex(parentRoot);
92
+ const parentBlock = chain.forkChoice.getBlockHexDefaultStatus(parentRoot);
93
93
  if (parentBlock === null) {
94
94
  // If fork choice does *not* consider the parent to be a descendant of the finalized block,
95
95
  // then there are two more cases:
@@ -9,7 +9,7 @@ import {
9
9
  isExecutionEnabled,
10
10
  isExecutionStateType,
11
11
  } from "@lodestar/state-transition";
12
- import {SignedBeaconBlock, deneb, gloas} from "@lodestar/types";
12
+ import {SignedBeaconBlock, deneb, gloas, isGloasBeaconBlock} from "@lodestar/types";
13
13
  import {byteArrayEquals, sleep, toRootHex} from "@lodestar/utils";
14
14
  import {BlockErrorCode, BlockGossipError, GossipAction} from "../errors/index.js";
15
15
  import {IBeaconChain} from "../interface.js";
@@ -56,7 +56,7 @@ export async function validateGossipBlock(
56
56
  // check, we will load the parent and state from disk only to find out later that we
57
57
  // already know this block.
58
58
  const blockRoot = toRootHex(config.getForkTypes(blockSlot).BeaconBlock.hashTreeRoot(block));
59
- if (chain.forkChoice.getBlockHex(blockRoot) !== null) {
59
+ if (chain.forkChoice.getBlockHexDefaultStatus(blockRoot) !== null) {
60
60
  throw new BlockGossipError(GossipAction.IGNORE, {code: BlockErrorCode.ALREADY_KNOWN, root: blockRoot});
61
61
  }
62
62
 
@@ -72,7 +72,12 @@ export async function validateGossipBlock(
72
72
  // [REJECT] The current finalized_checkpoint is an ancestor of block -- i.e.
73
73
  // get_ancestor(store, block.parent_root, compute_start_slot_at_epoch(store.finalized_checkpoint.epoch)) == store.finalized_checkpoint.root
74
74
  const parentRoot = toRootHex(block.parentRoot);
75
- const parentBlock = chain.forkChoice.getBlockHex(parentRoot);
75
+ const parentBlock = isGloasBeaconBlock(block)
76
+ ? chain.forkChoice.getBlockHexAndBlockHash(
77
+ parentRoot,
78
+ toRootHex(block.body.signedExecutionPayloadBid.message.parentBlockHash)
79
+ )
80
+ : chain.forkChoice.getBlockHexDefaultStatus(parentRoot);
76
81
  if (parentBlock === null) {
77
82
  // If fork choice does *not* consider the parent to be a descendant of the finalized block,
78
83
  // then there are two more cases:
@@ -104,7 +109,7 @@ export async function validateGossipBlock(
104
109
 
105
110
  // [REJECT] The block is from a higher slot than its parent.
106
111
  if (parentBlock.slot >= blockSlot) {
107
- throw new BlockGossipError(GossipAction.IGNORE, {
112
+ throw new BlockGossipError(GossipAction.REJECT, {
108
113
  code: BlockErrorCode.NOT_LATER_THAN_PARENT,
109
114
  parentSlot: parentBlock.slot,
110
115
  slot: blockSlot,
@@ -73,7 +73,7 @@ export async function validateGossipDataColumnSidecar(
73
73
  // 6) [IGNORE] The sidecar's block's parent (defined by block_header.parent_root) has been seen (via gossip
74
74
  // or non-gossip sources)
75
75
  const parentRoot = toRootHex(blockHeader.parentRoot);
76
- const parentBlock = chain.forkChoice.getBlockHex(parentRoot);
76
+ const parentBlock = chain.forkChoice.getBlockHexDefaultStatus(parentRoot);
77
77
  if (parentBlock === null) {
78
78
  // If fork choice does *not* consider the parent to be a descendant of the finalized block,
79
79
  // then there are two more cases:
@@ -113,8 +113,7 @@ async function validateExecutionPayloadBid(
113
113
 
114
114
  // [IGNORE] `bid.parent_block_root` is the hash tree root of a known beacon
115
115
  // block in fork choice.
116
- const block = chain.forkChoice.getBlock(bid.parentBlockRoot);
117
- if (block === null) {
116
+ if (!chain.forkChoice.hasBlock(bid.parentBlockRoot)) {
118
117
  throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
119
118
  code: ExecutionPayloadBidErrorCode.UNKNOWN_BLOCK_ROOT,
120
119
  parentBlockRoot: parentBlockRootHex,
@@ -37,7 +37,7 @@ async function validateExecutionPayloadEnvelope(
37
37
  // the block is retrieved).
38
38
  // TODO GLOAS: Need to review this, we should queue the envelope for later
39
39
  // processing if the block is not yet known, otherwise we would ignore it here
40
- const block = chain.forkChoice.getBlock(envelope.beaconBlockRoot);
40
+ const block = chain.forkChoice.getBlockDefaultStatus(envelope.beaconBlockRoot);
41
41
  if (block === null) {
42
42
  throw new ExecutionPayloadEnvelopeError(GossipAction.IGNORE, {
43
43
  code: ExecutionPayloadEnvelopeErrorCode.BLOCK_ROOT_UNKNOWN,
@@ -79,7 +79,7 @@ async function validateExecutionPayloadEnvelope(
79
79
  });
80
80
  }
81
81
 
82
- if (block.builderIndex === undefined || block.blockHashHex === undefined) {
82
+ if (block.builderIndex == null || block.blockHashFromBid == null) {
83
83
  // This indicates this block is a pre-gloas block which is wrong
84
84
  throw new ExecutionPayloadEnvelopeError(GossipAction.IGNORE, {
85
85
  code: ExecutionPayloadEnvelopeErrorCode.CACHE_FAIL,
@@ -97,11 +97,11 @@ async function validateExecutionPayloadEnvelope(
97
97
  }
98
98
 
99
99
  // [REJECT] `payload.block_hash == bid.block_hash`
100
- if (toRootHex(payload.blockHash) !== block.blockHashHex) {
100
+ if (toRootHex(payload.blockHash) !== block.blockHashFromBid) {
101
101
  throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
102
102
  code: ExecutionPayloadEnvelopeErrorCode.BLOCK_HASH_MISMATCH,
103
103
  envelopeBlockHash: toRootHex(payload.blockHash),
104
- bidBlockHash: block.blockHashHex,
104
+ bidBlockHash: block.blockHashFromBid,
105
105
  });
106
106
  }
107
107
 
@@ -59,8 +59,7 @@ async function validatePayloadAttestationMessage(
59
59
  // [IGNORE] The message's block `data.beacon_block_root` has been seen (via
60
60
  // gossip or non-gossip sources) (a client MAY queue attestation for processing
61
61
  // once the block is retrieved. Note a client might want to request payload after).
62
- const block = chain.forkChoice.getBlock(data.beaconBlockRoot);
63
- if (block === null) {
62
+ if (!chain.forkChoice.hasBlock(data.beaconBlockRoot)) {
64
63
  throw new PayloadAttestationError(GossipAction.IGNORE, {
65
64
  code: PayloadAttestationErrorCode.UNKNOWN_BLOCK_ROOT,
66
65
  blockRoot: toRootHex(data.beaconBlockRoot),
@@ -87,8 +86,16 @@ async function validatePayloadAttestationMessage(
87
86
  }
88
87
 
89
88
  // [REJECT] `payload_attestation_message.signature` is valid with respect to the validator's public key.
89
+ const validatorPubkey = chain.pubkeyCache.get(validatorIndex);
90
+ if (!validatorPubkey) {
91
+ throw new PayloadAttestationError(GossipAction.REJECT, {
92
+ code: PayloadAttestationErrorCode.INVALID_ATTESTER,
93
+ attesterIndex: validatorIndex,
94
+ });
95
+ }
96
+
90
97
  const signatureSet = createSingleSignatureSetFromComponents(
91
- chain.index2pubkey[validatorIndex],
98
+ validatorPubkey,
92
99
  getPayloadAttestationDataSigningRoot(chain.config, data),
93
100
  payloadAttestationMessage.signature
94
101
  );
@@ -37,7 +37,7 @@ async function validateProposerSlashing(
37
37
  try {
38
38
  const proposer = state.validators.getReadonly(proposerSlashing.signedHeader1.message.proposerIndex);
39
39
  // verifySignature = false, verified in batch below
40
- assertValidProposerSlashing(chain.config, chain.index2pubkey, state.slot, proposerSlashing, proposer, false);
40
+ assertValidProposerSlashing(chain.config, chain.pubkeyCache, state.slot, proposerSlashing, proposer, false);
41
41
  } catch (e) {
42
42
  throw new ProposerSlashingError(GossipAction.REJECT, {
43
43
  code: ProposerSlashingErrorCode.INVALID,
@@ -106,7 +106,7 @@ export async function validateSyncCommitteeGossipContributionAndProof(
106
106
  /**
107
107
  * Retrieve pubkeys in contribution aggregate using epochCtx:
108
108
  * - currSyncCommitteeIndexes cache
109
- * - index2pubkey cache
109
+ * - pubkeyCache
110
110
  */
111
111
  function getContributionIndices(
112
112
  state: CachedBeaconStateAltair,
@@ -1,4 +1,3 @@
1
- import all from "it-all";
2
1
  import {ChainForkConfig} from "@lodestar/config";
3
2
  import {Db, FilterOptions, KeyValue, Repository} from "@lodestar/db";
4
3
  import {Root, SignedBeaconBlock, Slot, ssz} from "@lodestar/types";
@@ -121,7 +120,7 @@ export class BlockArchiveRepository extends Repository<Slot, SignedBeaconBlock>
121
120
  }
122
121
 
123
122
  async values(opts?: BlockFilterOptions): Promise<SignedBeaconBlock[]> {
124
- return all(this.valuesStream(opts));
123
+ return await Array.fromAsync(this.valuesStream(opts));
125
124
  }
126
125
 
127
126
  // INDEX
@@ -128,6 +128,7 @@ const getClientVersionOpts: ReqOpts = {routeId: "getClientVersion"};
128
128
  */
129
129
  export class ExecutionEngineHttp implements IExecutionEngine {
130
130
  private logger: Logger;
131
+ private metrics: Metrics | null;
131
132
 
132
133
  // The default state is ONLINE, it will be updated to SYNCING once we receive the first payload
133
134
  // This assumption is better than the OFFLINE state, since we can't be sure if the EL is offline and being offline may trigger some notifications
@@ -167,6 +168,7 @@ export class ExecutionEngineHttp implements IExecutionEngine {
167
168
  metrics?.engineHttpProcessorQueue
168
169
  );
169
170
  this.logger = logger;
171
+ this.metrics = metrics ?? null;
170
172
 
171
173
  this.rpc.emitter.on(JsonRpcHttpClientEvent.ERROR, ({error}) => {
172
174
  this.updateEngineState(getExecutionEngineState({payloadError: error, oldState: this.state}));
@@ -369,6 +371,7 @@ export class ExecutionEngineHttp implements IExecutionEngine {
369
371
  } = await request;
370
372
 
371
373
  this.updateEngineState(getExecutionEngineState({payloadStatus: status, oldState: this.state}));
374
+ this.metrics?.engineNotifyForkchoiceUpdateResult.inc({result: status});
372
375
 
373
376
  switch (status) {
374
377
  case ExecutionPayloadStatus.VALID:
@@ -928,6 +928,11 @@ export function createLodestarMetrics(
928
928
  help: "The total result of calling notifyNewPayload execution engine api",
929
929
  labelNames: ["result"],
930
930
  }),
931
+ engineNotifyForkchoiceUpdateResult: register.gauge<{result: ExecutionPayloadStatus}>({
932
+ name: "lodestar_execution_engine_notify_forkchoice_update_result_total",
933
+ help: "The total result of calling notifyForkchoiceUpdate execution engine api",
934
+ labelNames: ["result"],
935
+ }),
931
936
  backfillSync: {
932
937
  backfilledTillSlot: register.gauge({
933
938
  name: "lodestar_backfill_till_slot",
@@ -89,9 +89,9 @@ export class MonitoringService {
89
89
  }
90
90
 
91
91
  /**
92
- * Stop sending client stats
92
+ * Stop sending client stats and wait for any pending request to complete
93
93
  */
94
- close(): void {
94
+ async close(): Promise<void> {
95
95
  if (this.status === Status.Closed) return;
96
96
  this.status = Status.Closed;
97
97
 
@@ -103,6 +103,7 @@ export class MonitoringService {
103
103
  }
104
104
  if (this.pendingRequest) {
105
105
  this.fetchAbortController?.abort(FetchAbortReason.Close);
106
+ await this.pendingRequest;
106
107
  }
107
108
  }
108
109
 
@@ -1,8 +1,8 @@
1
- import {Connection, PrivateKey} from "@libp2p/interface";
1
+ import type {PeerScoreStatsDump} from "@libp2p/gossipsub/score";
2
+ import type {PublishOpts} from "@libp2p/gossipsub/types";
3
+ import type {Connection, PrivateKey} from "@libp2p/interface";
2
4
  import {peerIdFromPrivateKey} from "@libp2p/peer-id";
3
5
  import {multiaddr} from "@multiformats/multiaddr";
4
- import {PeerScoreStatsDump} from "@chainsafe/libp2p-gossipsub/score";
5
- import {PublishOpts} from "@chainsafe/libp2p-gossipsub/types";
6
6
  import {routes} from "@lodestar/api";
7
7
  import {BeaconConfig, ForkBoundary} from "@lodestar/config";
8
8
  import type {LoggerNode} from "@lodestar/logger/node";
@@ -1,9 +1,9 @@
1
1
  import path from "node:path";
2
2
  import workerThreads from "node:worker_threads";
3
3
  import {privateKeyToProtobuf} from "@libp2p/crypto/keys";
4
- import {PrivateKey} from "@libp2p/interface";
5
- import {PeerScoreStatsDump} from "@chainsafe/libp2p-gossipsub/score";
6
- import {PublishOpts} from "@chainsafe/libp2p-gossipsub/types";
4
+ import type {PeerScoreStatsDump} from "@libp2p/gossipsub/score";
5
+ import type {PublishOpts} from "@libp2p/gossipsub/types";
6
+ import type {PrivateKey} from "@libp2p/interface";
7
7
  import {ModuleThread, Thread, Worker, spawn} from "@chainsafe/threads";
8
8
  import {routes} from "@lodestar/api";
9
9
  import {BeaconConfig, chainConfigToJson} from "@lodestar/config";
@@ -1,5 +1,5 @@
1
- import {PeerScoreStatsDump} from "@chainsafe/libp2p-gossipsub/score";
2
- import {PublishOpts} from "@chainsafe/libp2p-gossipsub/types";
1
+ import type {PeerScoreStatsDump} from "@libp2p/gossipsub/score";
2
+ import type {PublishOpts} from "@libp2p/gossipsub/types";
3
3
  import {routes} from "@lodestar/api";
4
4
  import {SpecJson} from "@lodestar/config";
5
5
  import {LoggerNodeOpts} from "@lodestar/logger/node";
@@ -1,5 +1,6 @@
1
1
  import {EventEmitter} from "node:events";
2
- import {PeerId, TopicValidatorResult} from "@libp2p/interface";
2
+ import type {TopicValidatorResult} from "@libp2p/gossipsub";
3
+ import type {PeerId} from "@libp2p/interface";
3
4
  import {CustodyIndex, Status} from "@lodestar/types";
4
5
  import {PeerIdStr} from "../util/peerId.js";
5
6
  import {StrictEventEmitterSingleArg} from "../util/strictEvents.js";