@lodestar/beacon-node 1.41.0-dev.a35cbde8b3 → 1.41.0-dev.afd446235e

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 (248) hide show
  1. package/lib/api/impl/beacon/state/index.js +8 -8
  2. package/lib/api/impl/beacon/state/index.js.map +1 -1
  3. package/lib/api/impl/beacon/state/utils.d.ts +3 -4
  4. package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
  5. package/lib/api/impl/beacon/state/utils.js +5 -24
  6. package/lib/api/impl/beacon/state/utils.js.map +1 -1
  7. package/lib/api/impl/debug/index.d.ts.map +1 -1
  8. package/lib/api/impl/debug/index.js +5 -2
  9. package/lib/api/impl/debug/index.js.map +1 -1
  10. package/lib/api/impl/node/utils.d.ts +1 -1
  11. package/lib/api/impl/node/utils.d.ts.map +1 -1
  12. package/lib/api/impl/node/utils.js.map +1 -1
  13. package/lib/api/impl/validator/index.d.ts.map +1 -1
  14. package/lib/api/impl/validator/index.js +3 -5
  15. package/lib/api/impl/validator/index.js.map +1 -1
  16. package/lib/chain/archiveStore/archiveStore.d.ts +1 -0
  17. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  18. package/lib/chain/archiveStore/archiveStore.js +9 -0
  19. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  20. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts +5 -6
  21. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
  22. package/lib/chain/archiveStore/historicalState/getHistoricalState.js +9 -10
  23. package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
  24. package/lib/chain/archiveStore/historicalState/worker.js +3 -3
  25. package/lib/chain/archiveStore/historicalState/worker.js.map +1 -1
  26. package/lib/chain/archiveStore/utils/archivePayloads.d.ts +7 -0
  27. package/lib/chain/archiveStore/utils/archivePayloads.d.ts.map +1 -0
  28. package/lib/chain/archiveStore/utils/archivePayloads.js +10 -0
  29. package/lib/chain/archiveStore/utils/archivePayloads.js.map +1 -0
  30. package/lib/chain/bls/multithread/index.d.ts +3 -3
  31. package/lib/chain/bls/multithread/index.d.ts.map +1 -1
  32. package/lib/chain/bls/multithread/index.js +5 -5
  33. package/lib/chain/bls/multithread/index.js.map +1 -1
  34. package/lib/chain/bls/multithread/jobItem.d.ts +2 -2
  35. package/lib/chain/bls/multithread/jobItem.d.ts.map +1 -1
  36. package/lib/chain/bls/multithread/jobItem.js +2 -2
  37. package/lib/chain/bls/multithread/jobItem.js.map +1 -1
  38. package/lib/chain/bls/singleThread.d.ts +4 -4
  39. package/lib/chain/bls/singleThread.d.ts.map +1 -1
  40. package/lib/chain/bls/singleThread.js +4 -4
  41. package/lib/chain/bls/singleThread.js.map +1 -1
  42. package/lib/chain/bls/utils.d.ts +2 -2
  43. package/lib/chain/bls/utils.d.ts.map +1 -1
  44. package/lib/chain/bls/utils.js +7 -4
  45. package/lib/chain/bls/utils.js.map +1 -1
  46. package/lib/chain/chain.d.ts +6 -9
  47. package/lib/chain/chain.d.ts.map +1 -1
  48. package/lib/chain/chain.js +9 -11
  49. package/lib/chain/chain.js.map +1 -1
  50. package/lib/chain/emitter.d.ts +2 -2
  51. package/lib/chain/emitter.d.ts.map +1 -1
  52. package/lib/chain/interface.d.ts +4 -6
  53. package/lib/chain/interface.d.ts.map +1 -1
  54. package/lib/chain/interface.js.map +1 -1
  55. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  56. package/lib/chain/produceBlock/produceBlockBody.js +8 -1
  57. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  58. package/lib/chain/validation/attestation.d.ts.map +1 -1
  59. package/lib/chain/validation/attestation.js +4 -1
  60. package/lib/chain/validation/attestation.js.map +1 -1
  61. package/lib/chain/validation/attesterSlashing.js +1 -1
  62. package/lib/chain/validation/attesterSlashing.js.map +1 -1
  63. package/lib/chain/validation/payloadAttestationMessage.js +8 -1
  64. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  65. package/lib/chain/validation/proposerSlashing.js +1 -1
  66. package/lib/chain/validation/proposerSlashing.js.map +1 -1
  67. package/lib/chain/validation/syncCommitteeContributionAndProof.js +1 -1
  68. package/lib/constants/network.d.ts +2 -1
  69. package/lib/constants/network.d.ts.map +1 -1
  70. package/lib/constants/network.js +1 -0
  71. package/lib/constants/network.js.map +1 -1
  72. package/lib/db/beacon.d.ts +3 -1
  73. package/lib/db/beacon.d.ts.map +1 -1
  74. package/lib/db/beacon.js +5 -1
  75. package/lib/db/beacon.js.map +1 -1
  76. package/lib/db/buckets.d.ts +3 -1
  77. package/lib/db/buckets.d.ts.map +1 -1
  78. package/lib/db/buckets.js +2 -0
  79. package/lib/db/buckets.js.map +1 -1
  80. package/lib/db/interface.d.ts +3 -1
  81. package/lib/db/interface.d.ts.map +1 -1
  82. package/lib/db/repositories/blockArchive.d.ts.map +1 -1
  83. package/lib/db/repositories/blockArchive.js +1 -2
  84. package/lib/db/repositories/blockArchive.js.map +1 -1
  85. package/lib/db/repositories/blockArchiveIndex.d.ts +2 -2
  86. package/lib/db/repositories/blockArchiveIndex.d.ts.map +1 -1
  87. package/lib/db/repositories/dataColumnSidecar.d.ts +5 -3
  88. package/lib/db/repositories/dataColumnSidecar.d.ts.map +1 -1
  89. package/lib/db/repositories/dataColumnSidecar.js +14 -1
  90. package/lib/db/repositories/dataColumnSidecar.js.map +1 -1
  91. package/lib/db/repositories/dataColumnSidecarArchive.d.ts +5 -3
  92. package/lib/db/repositories/dataColumnSidecarArchive.d.ts.map +1 -1
  93. package/lib/db/repositories/dataColumnSidecarArchive.js +14 -1
  94. package/lib/db/repositories/dataColumnSidecarArchive.js.map +1 -1
  95. package/lib/db/repositories/executionPayloadEnvelope.d.ts +19 -0
  96. package/lib/db/repositories/executionPayloadEnvelope.d.ts.map +1 -0
  97. package/lib/db/repositories/executionPayloadEnvelope.js +22 -0
  98. package/lib/db/repositories/executionPayloadEnvelope.js.map +1 -0
  99. package/lib/db/repositories/executionPayloadEnvelopeArchive.d.ts +18 -0
  100. package/lib/db/repositories/executionPayloadEnvelopeArchive.d.ts.map +1 -0
  101. package/lib/db/repositories/executionPayloadEnvelopeArchive.js +28 -0
  102. package/lib/db/repositories/executionPayloadEnvelopeArchive.js.map +1 -0
  103. package/lib/db/repositories/index.d.ts +2 -0
  104. package/lib/db/repositories/index.d.ts.map +1 -1
  105. package/lib/db/repositories/index.js +2 -0
  106. package/lib/db/repositories/index.js.map +1 -1
  107. package/lib/execution/engine/http.d.ts +1 -0
  108. package/lib/execution/engine/http.d.ts.map +1 -1
  109. package/lib/execution/engine/http.js +3 -0
  110. package/lib/execution/engine/http.js.map +1 -1
  111. package/lib/metrics/metrics/lodestar.d.ts +3 -0
  112. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  113. package/lib/metrics/metrics/lodestar.js +5 -0
  114. package/lib/metrics/metrics/lodestar.js.map +1 -1
  115. package/lib/monitoring/service.d.ts +2 -2
  116. package/lib/monitoring/service.d.ts.map +1 -1
  117. package/lib/monitoring/service.js +3 -2
  118. package/lib/monitoring/service.js.map +1 -1
  119. package/lib/network/core/networkCore.d.ts +3 -3
  120. package/lib/network/core/networkCore.d.ts.map +1 -1
  121. package/lib/network/core/networkCore.js.map +1 -1
  122. package/lib/network/core/networkCoreWorkerHandler.d.ts +3 -3
  123. package/lib/network/core/networkCoreWorkerHandler.d.ts.map +1 -1
  124. package/lib/network/core/types.d.ts +2 -2
  125. package/lib/network/core/types.d.ts.map +1 -1
  126. package/lib/network/events.d.ts +2 -1
  127. package/lib/network/events.d.ts.map +1 -1
  128. package/lib/network/events.js.map +1 -1
  129. package/lib/network/gossip/encoding.d.ts +3 -3
  130. package/lib/network/gossip/encoding.d.ts.map +1 -1
  131. package/lib/network/gossip/encoding.js.map +1 -1
  132. package/lib/network/gossip/gossipsub.d.ts +13 -4
  133. package/lib/network/gossip/gossipsub.d.ts.map +1 -1
  134. package/lib/network/gossip/gossipsub.js +47 -20
  135. package/lib/network/gossip/gossipsub.js.map +1 -1
  136. package/lib/network/gossip/interface.d.ts +3 -3
  137. package/lib/network/gossip/interface.d.ts.map +1 -1
  138. package/lib/network/gossip/scoringParameters.d.ts +1 -1
  139. package/lib/network/gossip/scoringParameters.d.ts.map +1 -1
  140. package/lib/network/gossip/scoringParameters.js +1 -1
  141. package/lib/network/gossip/scoringParameters.js.map +1 -1
  142. package/lib/network/gossip/topic.d.ts +51 -51
  143. package/lib/network/interface.d.ts +3 -3
  144. package/lib/network/interface.d.ts.map +1 -1
  145. package/lib/network/libp2p/index.d.ts +1 -1
  146. package/lib/network/libp2p/index.d.ts.map +1 -1
  147. package/lib/network/libp2p/index.js +7 -2
  148. package/lib/network/libp2p/index.js.map +1 -1
  149. package/lib/network/network.d.ts +2 -2
  150. package/lib/network/network.d.ts.map +1 -1
  151. package/lib/network/network.js +1 -1
  152. package/lib/network/network.js.map +1 -1
  153. package/lib/network/options.d.ts.map +1 -1
  154. package/lib/network/options.js +3 -0
  155. package/lib/network/options.js.map +1 -1
  156. package/lib/network/peers/datastore.d.ts +7 -5
  157. package/lib/network/peers/datastore.d.ts.map +1 -1
  158. package/lib/network/peers/datastore.js +10 -10
  159. package/lib/network/peers/datastore.js.map +1 -1
  160. package/lib/network/peers/peerManager.d.ts +11 -0
  161. package/lib/network/peers/peerManager.d.ts.map +1 -1
  162. package/lib/network/peers/peerManager.js +148 -53
  163. package/lib/network/peers/peerManager.js.map +1 -1
  164. package/lib/network/peers/utils/prioritizePeers.d.ts +3 -3
  165. package/lib/network/peers/utils/prioritizePeers.d.ts.map +1 -1
  166. package/lib/network/processor/gossipValidatorFn.js +1 -1
  167. package/lib/network/processor/types.d.ts +1 -1
  168. package/lib/network/processor/types.d.ts.map +1 -1
  169. package/lib/network/reqresp/score.d.ts.map +1 -1
  170. package/lib/network/reqresp/score.js +0 -1
  171. package/lib/network/reqresp/score.js.map +1 -1
  172. package/lib/network/util.js +2 -2
  173. package/lib/network/util.js.map +1 -1
  174. package/lib/node/nodejs.d.ts +3 -5
  175. package/lib/node/nodejs.d.ts.map +1 -1
  176. package/lib/node/nodejs.js +6 -4
  177. package/lib/node/nodejs.js.map +1 -1
  178. package/lib/util/blobs.d.ts +2 -2
  179. package/lib/util/blobs.d.ts.map +1 -1
  180. package/lib/util/blobs.js.map +1 -1
  181. package/lib/util/dataColumns.d.ts +3 -5
  182. package/lib/util/dataColumns.d.ts.map +1 -1
  183. package/lib/util/dataColumns.js +0 -4
  184. package/lib/util/dataColumns.js.map +1 -1
  185. package/lib/util/multifork.d.ts +8 -0
  186. package/lib/util/multifork.d.ts.map +1 -1
  187. package/lib/util/multifork.js +37 -0
  188. package/lib/util/multifork.js.map +1 -1
  189. package/package.json +38 -41
  190. package/src/api/impl/beacon/state/index.ts +8 -8
  191. package/src/api/impl/beacon/state/utils.ts +15 -29
  192. package/src/api/impl/debug/index.ts +8 -5
  193. package/src/api/impl/node/utils.ts +3 -3
  194. package/src/api/impl/validator/index.ts +3 -4
  195. package/src/chain/archiveStore/archiveStore.ts +10 -0
  196. package/src/chain/archiveStore/historicalState/getHistoricalState.ts +10 -11
  197. package/src/chain/archiveStore/historicalState/worker.ts +3 -3
  198. package/src/chain/archiveStore/utils/archivePayloads.ts +15 -0
  199. package/src/chain/bls/multithread/index.ts +7 -7
  200. package/src/chain/bls/multithread/jobItem.ts +3 -3
  201. package/src/chain/bls/singleThread.ts +5 -5
  202. package/src/chain/bls/utils.ts +8 -5
  203. package/src/chain/chain.ts +16 -20
  204. package/src/chain/emitter.ts +2 -2
  205. package/src/chain/interface.ts +4 -11
  206. package/src/chain/produceBlock/produceBlockBody.ts +9 -2
  207. package/src/chain/validation/attestation.ts +4 -1
  208. package/src/chain/validation/attesterSlashing.ts +1 -1
  209. package/src/chain/validation/payloadAttestationMessage.ts +9 -1
  210. package/src/chain/validation/proposerSlashing.ts +1 -1
  211. package/src/chain/validation/syncCommitteeContributionAndProof.ts +1 -1
  212. package/src/constants/network.ts +1 -0
  213. package/src/db/beacon.ts +8 -0
  214. package/src/db/buckets.ts +3 -0
  215. package/src/db/interface.ts +5 -0
  216. package/src/db/repositories/blockArchive.ts +1 -2
  217. package/src/db/repositories/dataColumnSidecar.ts +18 -3
  218. package/src/db/repositories/dataColumnSidecarArchive.ts +18 -3
  219. package/src/db/repositories/executionPayloadEnvelope.ts +26 -0
  220. package/src/db/repositories/executionPayloadEnvelopeArchive.ts +32 -0
  221. package/src/db/repositories/index.ts +2 -0
  222. package/src/execution/engine/http.ts +3 -0
  223. package/src/metrics/metrics/lodestar.ts +5 -0
  224. package/src/monitoring/service.ts +3 -2
  225. package/src/network/core/networkCore.ts +3 -3
  226. package/src/network/core/networkCoreWorkerHandler.ts +3 -3
  227. package/src/network/core/types.ts +2 -2
  228. package/src/network/events.ts +2 -1
  229. package/src/network/gossip/encoding.ts +3 -3
  230. package/src/network/gossip/gossipsub.ts +86 -25
  231. package/src/network/gossip/interface.ts +3 -3
  232. package/src/network/gossip/scoringParameters.ts +4 -4
  233. package/src/network/interface.ts +3 -3
  234. package/src/network/libp2p/index.ts +8 -3
  235. package/src/network/network.ts +7 -5
  236. package/src/network/options.ts +3 -0
  237. package/src/network/peers/datastore.ts +13 -10
  238. package/src/network/peers/peerManager.ts +175 -54
  239. package/src/network/peers/utils/prioritizePeers.ts +3 -3
  240. package/src/network/processor/gossipValidatorFn.ts +1 -1
  241. package/src/network/processor/types.ts +1 -1
  242. package/src/network/reqresp/score.ts +0 -1
  243. package/src/network/util.ts +2 -2
  244. package/src/node/nodejs.ts +8 -9
  245. package/src/util/blobs.ts +3 -3
  246. package/src/util/dataColumns.ts +2 -7
  247. package/src/util/multifork.ts +45 -0
  248. package/src/util/workerEvents.ts +1 -1
@@ -1,4 +1,3 @@
1
- import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map";
2
1
  import {routes} from "@lodestar/api";
3
2
  import {ApplicationMethods} from "@lodestar/api/server";
4
3
  import {ExecutionStatus, ProtoBlock} from "@lodestar/fork-choice";
@@ -27,6 +26,7 @@ import {
27
26
  computeStartSlotAtEpoch,
28
27
  computeTimeAtSlot,
29
28
  createCachedBeaconState,
29
+ createPubkeyCache,
30
30
  getBlockRootAtSlot,
31
31
  getCurrentSlot,
32
32
  loadState,
@@ -1123,8 +1123,7 @@ export function getValidatorApi(
1123
1123
  {
1124
1124
  config: chain.config,
1125
1125
  // Not required to compute proposers
1126
- pubkey2index: new PubkeyIndexMap(),
1127
- index2pubkey: [],
1126
+ pubkeyCache: createPubkeyCache(),
1128
1127
  },
1129
1128
  {skipSyncPubkeys: true, skipSyncCommitteeCache: true}
1130
1129
  );
@@ -1585,7 +1584,7 @@ export function getValidatorApi(
1585
1584
 
1586
1585
  const filteredRegistrations = registrations.filter((registration) => {
1587
1586
  const {pubkey} = registration.message;
1588
- const validatorIndex = chain.pubkey2index.get(pubkey);
1587
+ const validatorIndex = chain.pubkeyCache.getIndex(pubkey);
1589
1588
  if (validatorIndex === null) return false;
1590
1589
 
1591
1590
  const validator = headState.validators.getReadonly(validatorIndex);
@@ -1,5 +1,6 @@
1
1
  import {CheckpointWithHex} from "@lodestar/fork-choice";
2
2
  import {LoggerNode} from "@lodestar/logger/node";
3
+ import {ForkSeq} from "@lodestar/params";
3
4
  import {Checkpoint} from "@lodestar/types/phase0";
4
5
  import {callFnWhenAwait} from "@lodestar/utils";
5
6
  import {IBeaconDb} from "../../db/index.js";
@@ -13,6 +14,7 @@ import {HistoricalStateRegen} from "./historicalState/historicalStateRegen.js";
13
14
  import {ArchiveMode, ArchiveStoreOpts, StateArchiveStrategy} from "./interface.js";
14
15
  import {FrequencyStateArchiveStrategy} from "./strategies/frequencyStateArchiveStrategy.js";
15
16
  import {archiveBlocks} from "./utils/archiveBlocks.js";
17
+ import {archiveExecutionPayloadEnvelopes} from "./utils/archivePayloads.js";
16
18
  import {pruneHistory} from "./utils/pruneHistory.js";
17
19
  import {updateBackfillRange} from "./utils/updateBackfillRange.js";
18
20
 
@@ -27,6 +29,7 @@ type ArchiveStoreInitOpts = ArchiveStoreOpts & {dbName: string; anchorState: {fi
27
29
 
28
30
  export enum ArchiveStoreTask {
29
31
  ArchiveBlocks = "archive_blocks",
32
+ ArchivePayloads = "archive_payloads",
30
33
  PruneHistory = "prune_history",
31
34
  OnFinalizedCheckpoint = "on_finalized_checkpoint",
32
35
  MaybeArchiveState = "maybe_archive_state",
@@ -189,6 +192,7 @@ export class ArchiveStore {
189
192
  private processFinalizedCheckpoint = async (finalized: CheckpointWithHex): Promise<void> => {
190
193
  try {
191
194
  const finalizedEpoch = finalized.epoch;
195
+ const finalizedFork = this.chain.config.getForkSeqAtEpoch(finalizedEpoch);
192
196
  this.logger.verbose("Start processing finalized checkpoint", {epoch: finalizedEpoch, rootHex: finalized.rootHex});
193
197
 
194
198
  let timer = this.metrics?.processFinalizedCheckpoint.durationByTask.startTimer();
@@ -206,6 +210,12 @@ export class ArchiveStore {
206
210
  );
207
211
  timer?.({source: ArchiveStoreTask.ArchiveBlocks});
208
212
 
213
+ if (finalizedFork >= ForkSeq.gloas) {
214
+ timer = this.metrics?.processFinalizedCheckpoint.durationByTask.startTimer();
215
+ await archiveExecutionPayloadEnvelopes(this.chain, finalized);
216
+ timer?.({source: ArchiveStoreTask.ArchivePayloads});
217
+ }
218
+
209
219
  if (this.opts.pruneHistory) {
210
220
  timer = this.metrics?.processFinalizedCheckpoint.durationByTask.startTimer();
211
221
  await pruneHistory(
@@ -1,10 +1,10 @@
1
- import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map";
2
1
  import {BeaconConfig} from "@lodestar/config";
3
2
  import {
4
3
  BeaconStateAllForks,
5
4
  CachedBeaconStateAllForks,
6
5
  DataAvailabilityStatus,
7
6
  ExecutionPayloadStatus,
7
+ PubkeyCache,
8
8
  createCachedBeaconState,
9
9
  stateTransition,
10
10
  } from "@lodestar/state-transition";
@@ -15,16 +15,16 @@ import {HistoricalStateRegenMetrics} from "./metrics.js";
15
15
  import {RegenErrorType} from "./types.js";
16
16
 
17
17
  /**
18
- * Populate a PubkeyIndexMap with any new entries based on a BeaconState
18
+ * Populate a PubkeyCache with any new entries based on a BeaconState
19
19
  */
20
- export function syncPubkeyCache(state: BeaconStateAllForks, pubkey2index: PubkeyIndexMap): void {
20
+ export function syncPubkeyCache(state: BeaconStateAllForks, pubkeyCache: PubkeyCache): void {
21
21
  // Get the validators sub tree once for all the loop
22
22
  const validators = state.validators;
23
23
 
24
24
  const newCount = state.validators.length;
25
- for (let i = pubkey2index.size; i < newCount; i++) {
25
+ for (let i = pubkeyCache.size; i < newCount; i++) {
26
26
  const pubkey = validators.getReadonly(i).pubkey;
27
- pubkey2index.set(pubkey, i);
27
+ pubkeyCache.set(i, pubkey);
28
28
  }
29
29
  }
30
30
 
@@ -35,7 +35,7 @@ export async function getNearestState(
35
35
  slot: number,
36
36
  config: BeaconConfig,
37
37
  db: IBeaconDb,
38
- pubkey2index: PubkeyIndexMap
38
+ pubkeyCache: PubkeyCache
39
39
  ): Promise<CachedBeaconStateAllForks> {
40
40
  const stateBytesArr = await db.stateArchive.binaries({limit: 1, lte: slot, reverse: true});
41
41
  if (!stateBytesArr.length) {
@@ -44,14 +44,13 @@ export async function getNearestState(
44
44
 
45
45
  const stateBytes = stateBytesArr[0];
46
46
  const state = getStateTypeFromBytes(config, stateBytes).deserializeToViewDU(stateBytes);
47
- syncPubkeyCache(state, pubkey2index);
47
+ syncPubkeyCache(state, pubkeyCache);
48
48
 
49
49
  return createCachedBeaconState(
50
50
  state,
51
51
  {
52
52
  config,
53
- pubkey2index,
54
- index2pubkey: [],
53
+ pubkeyCache,
55
54
  },
56
55
  {
57
56
  skipSyncPubkeys: true,
@@ -66,13 +65,13 @@ export async function getHistoricalState(
66
65
  slot: number,
67
66
  config: BeaconConfig,
68
67
  db: IBeaconDb,
69
- pubkey2index: PubkeyIndexMap,
68
+ pubkeyCache: PubkeyCache,
70
69
  metrics?: HistoricalStateRegenMetrics
71
70
  ): Promise<Uint8Array> {
72
71
  const regenTimer = metrics?.regenTime.startTimer();
73
72
 
74
73
  const loadStateTimer = metrics?.loadStateTime.startTimer();
75
- let state = await getNearestState(slot, config, db, pubkey2index).catch((e) => {
74
+ let state = await getNearestState(slot, config, db, pubkeyCache).catch((e) => {
76
75
  metrics?.regenErrorCount.inc({reason: RegenErrorType.loadState});
77
76
  throw e;
78
77
  });
@@ -1,9 +1,9 @@
1
1
  import worker from "node:worker_threads";
2
- import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map";
3
2
  import {Transfer, expose} from "@chainsafe/threads/worker";
4
3
  import {chainConfigFromJson, createBeaconConfig} from "@lodestar/config";
5
4
  import {LevelDbController} from "@lodestar/db/controller/level";
6
5
  import {getNodeLogger} from "@lodestar/logger/node";
6
+ import {createPubkeyCache} from "@lodestar/state-transition";
7
7
  import {BeaconDb} from "../../../db/index.js";
8
8
  import {RegistryMetricCreator, collectNodeJSMetrics} from "../../../metrics/index.js";
9
9
  import {JobFnQueue} from "../../../util/queue/fnQueue.js";
@@ -52,7 +52,7 @@ const queue = new JobFnQueue(
52
52
  queueMetrics
53
53
  );
54
54
 
55
- const pubkey2index = new PubkeyIndexMap();
55
+ const pubkeyCache = createPubkeyCache();
56
56
 
57
57
  const api: HistoricalStateWorkerApi = {
58
58
  async close() {
@@ -65,7 +65,7 @@ const api: HistoricalStateWorkerApi = {
65
65
  historicalStateRegenMetrics?.regenRequestCount.inc();
66
66
 
67
67
  const stateBytes = await queue.push<Uint8Array>(() =>
68
- getHistoricalState(slot, config, db, pubkey2index, historicalStateRegenMetrics)
68
+ getHistoricalState(slot, config, db, pubkeyCache, historicalStateRegenMetrics)
69
69
  );
70
70
  const result = Transfer(stateBytes, [stateBytes.buffer]) as unknown as Uint8Array;
71
71
 
@@ -0,0 +1,15 @@
1
+ import {CheckpointWithHex} from "@lodestar/fork-choice";
2
+ import {IBeaconChain} from "../../interface.js";
3
+
4
+ /**
5
+ * Archives execution payload envelopes from hot DB to archive DB after finalization.
6
+ */
7
+ export async function archiveExecutionPayloadEnvelopes(
8
+ chain: IBeaconChain,
9
+ _finalized: CheckpointWithHex
10
+ ): Promise<void> {
11
+ const finalizedBlock = chain.forkChoice.getFinalizedBlock();
12
+ if (!finalizedBlock) return;
13
+
14
+ // TODO GLOAS: Implement payload envelope archival after epbs fork choice changes are merged
15
+ }
@@ -7,7 +7,7 @@ import {Worker, spawn} from "@chainsafe/threads";
7
7
  self = undefined;
8
8
 
9
9
  import {PublicKey} from "@chainsafe/blst";
10
- import {ISignatureSet, Index2PubkeyCache} from "@lodestar/state-transition";
10
+ import {ISignatureSet, PubkeyCache} from "@lodestar/state-transition";
11
11
  import {Logger} from "@lodestar/utils";
12
12
  import {Metrics} from "../../../metrics/index.js";
13
13
  import {LinkedList} from "../../../util/array.js";
@@ -34,7 +34,7 @@ const workerDir = process.env.NODE_ENV === "test" ? "../../../../lib/chain/bls/m
34
34
  export type BlsMultiThreadWorkerPoolModules = {
35
35
  logger: Logger;
36
36
  metrics: Metrics | null;
37
- index2pubkey: Index2PubkeyCache;
37
+ pubkeyCache: PubkeyCache;
38
38
  };
39
39
 
40
40
  export type BlsMultiThreadWorkerPoolOptions = {
@@ -114,7 +114,7 @@ type WorkerDescriptor = {
114
114
  export class BlsMultiThreadWorkerPool implements IBlsVerifier {
115
115
  private readonly logger: Logger;
116
116
  private readonly metrics: Metrics | null;
117
- private readonly index2pubkey: Index2PubkeyCache;
117
+ private readonly pubkeyCache: PubkeyCache;
118
118
 
119
119
  private readonly workers: WorkerDescriptor[];
120
120
  private readonly jobs = new LinkedList<JobQueueItem>();
@@ -130,10 +130,10 @@ export class BlsMultiThreadWorkerPool implements IBlsVerifier {
130
130
  private workersBusy = 0;
131
131
 
132
132
  constructor(options: BlsMultiThreadWorkerPoolOptions, modules: BlsMultiThreadWorkerPoolModules) {
133
- const {logger, metrics, index2pubkey} = modules;
133
+ const {logger, metrics, pubkeyCache} = modules;
134
134
  this.logger = logger;
135
135
  this.metrics = metrics;
136
- this.index2pubkey = index2pubkey;
136
+ this.pubkeyCache = pubkeyCache;
137
137
  this.blsVerifyAllMultiThread = options.blsVerifyAllMultiThread ?? false;
138
138
 
139
139
  // Use compressed for herumi for now.
@@ -173,7 +173,7 @@ export class BlsMultiThreadWorkerPool implements IBlsVerifier {
173
173
  try {
174
174
  return verifySignatureSetsMaybeBatch(
175
175
  sets.map((set) => ({
176
- publicKey: getAggregatedPubkey(set, this.index2pubkey),
176
+ publicKey: getAggregatedPubkey(set, this.pubkeyCache),
177
177
  message: set.signingRoot.valueOf(),
178
178
  signature: set.signature,
179
179
  }))
@@ -398,7 +398,7 @@ export class BlsMultiThreadWorkerPool implements IBlsVerifier {
398
398
  try {
399
399
  // Note: This can throw, must be handled per-job.
400
400
  // Pubkey and signature aggregation is defered here
401
- workReq = await jobItemWorkReq(job, this.index2pubkey, this.metrics);
401
+ workReq = await jobItemWorkReq(job, this.pubkeyCache, this.metrics);
402
402
  } catch (e) {
403
403
  this.metrics?.blsThreadPool.errorAggregateSignatureSetsCount.inc({type: job.type});
404
404
 
@@ -1,5 +1,5 @@
1
1
  import {PublicKey, asyncAggregateWithRandomness} from "@chainsafe/blst";
2
- import {ISignatureSet, Index2PubkeyCache, SignatureSetType} from "@lodestar/state-transition";
2
+ import {ISignatureSet, PubkeyCache, SignatureSetType} from "@lodestar/state-transition";
3
3
  import {Metrics} from "../../../metrics/metrics.js";
4
4
  import {LinkedList} from "../../../util/array.js";
5
5
  import {VerifySignatureOpts} from "../interface.js";
@@ -50,7 +50,7 @@ export function jobItemSigSets(job: JobQueueItem): number {
50
50
  */
51
51
  export async function jobItemWorkReq(
52
52
  job: JobQueueItem,
53
- index2pubkey: Index2PubkeyCache,
53
+ pubkeyCache: PubkeyCache,
54
54
  metrics: Metrics | null
55
55
  ): Promise<BlsWorkReq> {
56
56
  switch (job.type) {
@@ -59,7 +59,7 @@ export async function jobItemWorkReq(
59
59
  opts: job.opts,
60
60
  sets: job.sets.map((set) => ({
61
61
  // this can throw, handled in the consumer code
62
- publicKey: getAggregatedPubkey(set, index2pubkey, metrics).toBytes(),
62
+ publicKey: getAggregatedPubkey(set, pubkeyCache, metrics).toBytes(),
63
63
  signature: set.signature,
64
64
  message: set.signingRoot,
65
65
  })),
@@ -1,5 +1,5 @@
1
1
  import {PublicKey, Signature, aggregatePublicKeys, aggregateSignatures, verify} from "@chainsafe/blst";
2
- import {ISignatureSet, Index2PubkeyCache} from "@lodestar/state-transition";
2
+ import {ISignatureSet, PubkeyCache} from "@lodestar/state-transition";
3
3
  import {Metrics} from "../../metrics/index.js";
4
4
  import {IBlsVerifier} from "./interface.js";
5
5
  import {verifySignatureSetsMaybeBatch} from "./maybeBatch.js";
@@ -7,18 +7,18 @@ import {getAggregatedPubkey, getAggregatedPubkeysCount} from "./utils.js";
7
7
 
8
8
  export class BlsSingleThreadVerifier implements IBlsVerifier {
9
9
  private readonly metrics: Metrics | null;
10
- private readonly index2pubkey: Index2PubkeyCache;
10
+ private readonly pubkeyCache: PubkeyCache;
11
11
 
12
- constructor({metrics = null, index2pubkey}: {metrics: Metrics | null; index2pubkey: Index2PubkeyCache}) {
12
+ constructor({metrics = null, pubkeyCache}: {metrics: Metrics | null; pubkeyCache: PubkeyCache}) {
13
13
  this.metrics = metrics;
14
- this.index2pubkey = index2pubkey;
14
+ this.pubkeyCache = pubkeyCache;
15
15
  }
16
16
 
17
17
  async verifySignatureSets(sets: ISignatureSet[]): Promise<boolean> {
18
18
  this.metrics?.bls.aggregatedPubkeys.inc(getAggregatedPubkeysCount(sets));
19
19
 
20
20
  const setsAggregated = sets.map((set) => ({
21
- publicKey: getAggregatedPubkey(set, this.index2pubkey, this.metrics),
21
+ publicKey: getAggregatedPubkey(set, this.pubkeyCache, this.metrics),
22
22
  message: set.signingRoot,
23
23
  signature: set.signature,
24
24
  }));
@@ -1,22 +1,25 @@
1
1
  import {PublicKey, aggregatePublicKeys} from "@chainsafe/blst";
2
- import {ISignatureSet, Index2PubkeyCache, SignatureSetType} from "@lodestar/state-transition";
2
+ import {ISignatureSet, PubkeyCache, SignatureSetType} from "@lodestar/state-transition";
3
3
  import {Metrics} from "../../metrics/metrics.js";
4
4
 
5
5
  export function getAggregatedPubkey(
6
6
  signatureSet: ISignatureSet,
7
- index2pubkey: Index2PubkeyCache,
7
+ pubkeyCache: PubkeyCache,
8
8
  metrics: Metrics | null = null
9
9
  ): PublicKey {
10
10
  switch (signatureSet.type) {
11
11
  case SignatureSetType.single:
12
12
  return signatureSet.pubkey;
13
13
 
14
- case SignatureSetType.indexed:
15
- return index2pubkey[signatureSet.index];
14
+ case SignatureSetType.indexed: {
15
+ return pubkeyCache.getOrThrow(signatureSet.index);
16
+ }
16
17
 
17
18
  case SignatureSetType.aggregate: {
18
19
  const timer = metrics?.blsThreadPool.pubkeysAggregationMainThreadDuration.startTimer();
19
- const pubkeys = signatureSet.indices.map((i) => index2pubkey[i]);
20
+ const pubkeys = signatureSet.indices.map((i) => {
21
+ return pubkeyCache.getOrThrow(i);
22
+ });
20
23
  const aggregated = aggregatePublicKeys(pubkeys);
21
24
  timer?.();
22
25
  return aggregated;
@@ -1,6 +1,5 @@
1
1
  import path from "node:path";
2
2
  import {PrivateKey} from "@libp2p/interface";
3
- import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map";
4
3
  import {CompositeTypeAny, TreeView, Type} from "@chainsafe/ssz";
5
4
  import {BeaconConfig} from "@lodestar/config";
6
5
  import {CheckpointWithHex, IForkChoice, ProtoBlock, UpdateHeadOpt} from "@lodestar/fork-choice";
@@ -8,6 +7,7 @@ import {LoggerNode} from "@lodestar/logger/node";
8
7
  import {
9
8
  BUILDER_INDEX_SELF_BUILD,
10
9
  EFFECTIVE_BALANCE_INCREMENT,
10
+ ForkPostFulu,
11
11
  GENESIS_SLOT,
12
12
  SLOTS_PER_EPOCH,
13
13
  isForkPostElectra,
@@ -20,7 +20,7 @@ import {
20
20
  CachedBeaconStateGloas,
21
21
  EffectiveBalanceIncrements,
22
22
  EpochShuffling,
23
- Index2PubkeyCache,
23
+ PubkeyCache,
24
24
  computeAnchorCheckpoint,
25
25
  computeAttestationsRewards,
26
26
  computeBlockRewards,
@@ -36,6 +36,7 @@ import {
36
36
  BeaconBlock,
37
37
  BlindedBeaconBlock,
38
38
  BlindedBeaconBlockBody,
39
+ DataColumnSidecars,
39
40
  Epoch,
40
41
  Root,
41
42
  RootHex,
@@ -46,7 +47,6 @@ import {
46
47
  ValidatorIndex,
47
48
  Wei,
48
49
  deneb,
49
- fulu,
50
50
  gloas,
51
51
  isBlindedBeaconBlock,
52
52
  phase0,
@@ -191,8 +191,7 @@ export class BeaconChain implements IBeaconChain {
191
191
  readonly seenBlockAttesters = new SeenBlockAttesters();
192
192
 
193
193
  // Global state caches
194
- readonly pubkey2index: PubkeyIndexMap;
195
- readonly index2pubkey: Index2PubkeyCache;
194
+ readonly pubkeyCache: PubkeyCache;
196
195
 
197
196
  readonly beaconProposerCache: BeaconProposerCache;
198
197
  readonly checkpointBalancesCache: CheckpointBalancesCache;
@@ -238,8 +237,7 @@ export class BeaconChain implements IBeaconChain {
238
237
  {
239
238
  privateKey,
240
239
  config,
241
- pubkey2index,
242
- index2pubkey,
240
+ pubkeyCache,
243
241
  db,
244
242
  dbName,
245
243
  dataDir,
@@ -255,8 +253,7 @@ export class BeaconChain implements IBeaconChain {
255
253
  }: {
256
254
  privateKey: PrivateKey;
257
255
  config: BeaconConfig;
258
- pubkey2index: PubkeyIndexMap;
259
- index2pubkey: Index2PubkeyCache;
256
+ pubkeyCache: PubkeyCache;
260
257
  db: IBeaconDb;
261
258
  dbName: string;
262
259
  dataDir: string;
@@ -288,8 +285,8 @@ export class BeaconChain implements IBeaconChain {
288
285
  const emitter = new ChainEventEmitter();
289
286
  // by default, verify signatures on both main threads and worker threads
290
287
  const bls = opts.blsVerifyAllMainThread
291
- ? new BlsSingleThreadVerifier({metrics, index2pubkey})
292
- : new BlsMultiThreadWorkerPool(opts, {logger, metrics, index2pubkey});
288
+ ? new BlsSingleThreadVerifier({metrics, pubkeyCache})
289
+ : new BlsMultiThreadWorkerPool(opts, {logger, metrics, pubkeyCache});
293
290
 
294
291
  if (!clock) clock = new Clock({config, genesisTime: this.genesisTime, signal});
295
292
 
@@ -345,8 +342,7 @@ export class BeaconChain implements IBeaconChain {
345
342
  ]);
346
343
 
347
344
  // Global cache of validators pubkey/index mapping
348
- this.pubkey2index = pubkey2index;
349
- this.index2pubkey = index2pubkey;
345
+ this.pubkeyCache = pubkeyCache;
350
346
 
351
347
  const fileDataStore = opts.nHistoricalStatesFileDataStore ?? true;
352
348
  const blockStateCache = new FIFOBlockStateCache(this.opts, {metrics});
@@ -817,7 +813,7 @@ export class BeaconChain implements IBeaconChain {
817
813
  return null;
818
814
  }
819
815
 
820
- async getDataColumnSidecars(blockSlot: Slot, blockRootHex: string): Promise<fulu.DataColumnSidecars> {
816
+ async getDataColumnSidecars(blockSlot: Slot, blockRootHex: string): Promise<DataColumnSidecars> {
821
817
  const blockInput = this.seenBlockInputCache.get(blockRootHex);
822
818
  if (blockInput) {
823
819
  if (!isBlockInputColumns(blockInput)) {
@@ -827,10 +823,10 @@ export class BeaconChain implements IBeaconChain {
827
823
  }
828
824
  const sidecarsUnfinalized = await this.db.dataColumnSidecar.values(fromHex(blockRootHex));
829
825
  if (sidecarsUnfinalized.length > 0) {
830
- return sidecarsUnfinalized;
826
+ return sidecarsUnfinalized as DataColumnSidecars;
831
827
  }
832
828
  const sidecarsFinalized = await this.db.dataColumnSidecarArchive.values(blockSlot);
833
- return sidecarsFinalized;
829
+ return sidecarsFinalized as DataColumnSidecars;
834
830
  }
835
831
 
836
832
  async getSerializedDataColumnSidecars(
@@ -852,7 +848,7 @@ export class BeaconChain implements IBeaconChain {
852
848
  if (serialized) {
853
849
  return serialized;
854
850
  }
855
- return ssz.fulu.DataColumnSidecar.serialize(sidecar);
851
+ return sszTypesFor(blockInput.forkName as ForkPostFulu).DataColumnSidecar.serialize(sidecar);
856
852
  });
857
853
  }
858
854
  const sidecarsUnfinalized = await this.db.dataColumnSidecar.getManyBinary(fromHex(blockRootHex), indices);
@@ -919,7 +915,7 @@ export class BeaconChain implements IBeaconChain {
919
915
  RegenCaller.produceBlock
920
916
  );
921
917
  const proposerIndex = state.epochCtx.getBeaconProposer(slot);
922
- const proposerPubKey = this.index2pubkey[proposerIndex].toBytes();
918
+ const proposerPubKey = this.pubkeyCache.getOrThrow(proposerIndex).toBytes();
923
919
 
924
920
  const {body, produceResult, executionPayloadValue, shouldOverrideBuilder} = await produceBlockBody.call(
925
921
  this,
@@ -1535,7 +1531,7 @@ export class BeaconChain implements IBeaconChain {
1535
1531
  throw Error(`State is not in cache for slot ${slot}`);
1536
1532
  }
1537
1533
 
1538
- const rewards = await computeAttestationsRewards(this.config, this.pubkey2index, cachedState, validatorIds);
1534
+ const rewards = await computeAttestationsRewards(this.config, this.pubkeyCache, cachedState, validatorIds);
1539
1535
 
1540
1536
  return {rewards, executionOptimistic, finalized};
1541
1537
  }
@@ -1552,6 +1548,6 @@ export class BeaconChain implements IBeaconChain {
1552
1548
 
1553
1549
  preState = processSlots(preState, block.slot); // Dial preState's slot to block.slot
1554
1550
 
1555
- return computeSyncCommitteeRewards(this.config, this.index2pubkey, block, preState, validatorIds);
1551
+ return computeSyncCommitteeRewards(this.config, this.pubkeyCache, block, preState, validatorIds);
1556
1552
  }
1557
1553
  }
@@ -3,7 +3,7 @@ import {StrictEventEmitter} from "strict-event-emitter-types";
3
3
  import {routes} from "@lodestar/api";
4
4
  import {CheckpointWithHex} from "@lodestar/fork-choice";
5
5
  import {CachedBeaconStateAllForks} from "@lodestar/state-transition";
6
- import {DataColumnSidecar, RootHex, deneb, phase0} from "@lodestar/types";
6
+ import {DataColumnSidecars, RootHex, deneb, phase0} from "@lodestar/types";
7
7
  import {PeerIdStr} from "../util/peerId.js";
8
8
  import {BlockInputSource, IBlockInput} from "./blocks/blockInput/types.js";
9
9
 
@@ -88,7 +88,7 @@ export type IChainEvents = ApiEvents & {
88
88
 
89
89
  [ChainEvent.updateTargetCustodyGroupCount]: (targetGroupCount: number) => void;
90
90
 
91
- [ChainEvent.publishDataColumns]: (sidecars: DataColumnSidecar[]) => void;
91
+ [ChainEvent.publishDataColumns]: (sidecars: DataColumnSidecars) => void;
92
92
 
93
93
  [ChainEvent.publishBlobSidecars]: (sidecars: deneb.BlobSidecar[]) => void;
94
94
 
@@ -1,16 +1,11 @@
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,
8
+ DataColumnSidecars,
14
9
  Epoch,
15
10
  Root,
16
11
  RootHex,
@@ -23,7 +18,6 @@ import {
23
18
  altair,
24
19
  capella,
25
20
  deneb,
26
- fulu,
27
21
  phase0,
28
22
  rewards,
29
23
  } from "@lodestar/types";
@@ -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
@@ -224,7 +217,7 @@ export interface IBeaconChain {
224
217
  ): Promise<{block: SignedBeaconBlock; executionOptimistic: boolean; finalized: boolean} | null>;
225
218
  getBlobSidecars(blockSlot: Slot, blockRootHex: string): Promise<deneb.BlobSidecars | null>;
226
219
  getSerializedBlobSidecars(blockSlot: Slot, blockRootHex: string): Promise<Uint8Array | null>;
227
- getDataColumnSidecars(blockSlot: Slot, blockRootHex: string): Promise<fulu.DataColumnSidecars>;
220
+ getDataColumnSidecars(blockSlot: Slot, blockRootHex: string): Promise<DataColumnSidecars>;
228
221
  getSerializedDataColumnSidecars(
229
222
  blockSlot: Slot,
230
223
  blockRootHex: string,
@@ -4,6 +4,7 @@ import {
4
4
  BUILDER_INDEX_SELF_BUILD,
5
5
  ForkName,
6
6
  ForkPostBellatrix,
7
+ ForkPostCapella,
7
8
  ForkPostDeneb,
8
9
  ForkPostFulu,
9
10
  ForkPostGloas,
@@ -567,8 +568,14 @@ export async function produceBlockBody<T extends BlockType>(
567
568
  });
568
569
  }
569
570
 
570
- if (ForkSeq[fork] >= ForkSeq.capella) {
571
- const {blsToExecutionChanges, executionPayload} = blockBody as capella.BeaconBlockBody;
571
+ if (ForkSeq[fork] >= ForkSeq.gloas) {
572
+ const {blsToExecutionChanges, payloadAttestations} = blockBody as BeaconBlockBody<ForkPostGloas>;
573
+ Object.assign(logMeta, {
574
+ blsToExecutionChanges: blsToExecutionChanges.length,
575
+ payloadAttestations: payloadAttestations.length,
576
+ });
577
+ } else if (ForkSeq[fork] >= ForkSeq.capella) {
578
+ const {blsToExecutionChanges, executionPayload} = blockBody as BeaconBlockBody<ForkPostCapella & ForkPreGloas>;
572
579
  Object.assign(logMeta, {
573
580
  blsToExecutionChanges: blsToExecutionChanges.length,
574
581
  });
@@ -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 {
@@ -45,7 +45,7 @@ export async function validateAttesterSlashing(
45
45
  // verifySignature = false, verified in batch below
46
46
  assertValidAttesterSlashing(
47
47
  chain.config,
48
- chain.index2pubkey,
48
+ chain.pubkeyCache,
49
49
  state.slot,
50
50
  state.validators.length,
51
51
  attesterSlashing,
@@ -87,8 +87,16 @@ async function validatePayloadAttestationMessage(
87
87
  }
88
88
 
89
89
  // [REJECT] `payload_attestation_message.signature` is valid with respect to the validator's public key.
90
+ const validatorPubkey = chain.pubkeyCache.get(validatorIndex);
91
+ if (!validatorPubkey) {
92
+ throw new PayloadAttestationError(GossipAction.REJECT, {
93
+ code: PayloadAttestationErrorCode.INVALID_ATTESTER,
94
+ attesterIndex: validatorIndex,
95
+ });
96
+ }
97
+
90
98
  const signatureSet = createSingleSignatureSetFromComponents(
91
- chain.index2pubkey[validatorIndex],
99
+ validatorPubkey,
92
100
  getPayloadAttestationDataSigningRoot(chain.config, data),
93
101
  payloadAttestationMessage.signature
94
102
  );
@@ -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,
@@ -30,4 +30,5 @@ export const GOODBYE_KNOWN_CODES: Record<string, string> = {
30
30
  export enum Libp2pEvent {
31
31
  connectionOpen = "connection:open",
32
32
  connectionClose = "connection:close",
33
+ peerIdentify = "peer:identify",
33
34
  }