@lodestar/beacon-node 1.43.0-dev.4358217e12 → 1.43.0-dev.4451fec75a

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 (254) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +10 -0
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/api/impl/beacon/pool/index.d.ts.map +1 -1
  5. package/lib/api/impl/beacon/pool/index.js +45 -2
  6. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  7. package/lib/api/impl/debug/index.d.ts.map +1 -1
  8. package/lib/api/impl/debug/index.js +0 -1
  9. package/lib/api/impl/debug/index.js.map +1 -1
  10. package/lib/api/impl/validator/index.d.ts.map +1 -1
  11. package/lib/api/impl/validator/index.js +68 -2
  12. package/lib/api/impl/validator/index.js.map +1 -1
  13. package/lib/chain/blocks/blockInput/blockInput.d.ts +3 -0
  14. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
  15. package/lib/chain/blocks/blockInput/blockInput.js +4 -1
  16. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  17. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  18. package/lib/chain/blocks/importBlock.js +16 -31
  19. package/lib/chain/blocks/importBlock.js.map +1 -1
  20. package/lib/chain/blocks/importExecutionPayload.d.ts +6 -1
  21. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  22. package/lib/chain/blocks/importExecutionPayload.js +19 -10
  23. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  24. package/lib/chain/blocks/index.d.ts.map +1 -1
  25. package/lib/chain/blocks/index.js +35 -21
  26. package/lib/chain/blocks/index.js.map +1 -1
  27. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +12 -1
  28. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -1
  29. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +28 -2
  30. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -1
  31. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +17 -0
  32. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -1
  33. package/lib/chain/blocks/types.d.ts +2 -1
  34. package/lib/chain/blocks/types.d.ts.map +1 -1
  35. package/lib/chain/blocks/utils/chainSegment.d.ts +1 -3
  36. package/lib/chain/blocks/utils/chainSegment.d.ts.map +1 -1
  37. package/lib/chain/blocks/utils/chainSegment.js +34 -23
  38. package/lib/chain/blocks/utils/chainSegment.js.map +1 -1
  39. package/lib/chain/blocks/verifyBlock.d.ts +2 -1
  40. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  41. package/lib/chain/blocks/verifyBlock.js +30 -12
  42. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  43. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts +0 -4
  44. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
  45. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +5 -2
  46. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  47. package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts +2 -1
  48. package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts.map +1 -1
  49. package/lib/chain/blocks/verifyBlocksSanityChecks.js +16 -7
  50. package/lib/chain/blocks/verifyBlocksSanityChecks.js.map +1 -1
  51. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts +2 -2
  52. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts.map +1 -1
  53. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js +10 -6
  54. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js.map +1 -1
  55. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts.map +1 -1
  56. package/lib/chain/blocks/verifyPayloadsDataAvailability.js +8 -3
  57. package/lib/chain/blocks/verifyPayloadsDataAvailability.js.map +1 -1
  58. package/lib/chain/chain.d.ts.map +1 -1
  59. package/lib/chain/chain.js +25 -8
  60. package/lib/chain/chain.js.map +1 -1
  61. package/lib/chain/emitter.d.ts +0 -11
  62. package/lib/chain/emitter.d.ts.map +1 -1
  63. package/lib/chain/emitter.js +0 -4
  64. package/lib/chain/emitter.js.map +1 -1
  65. package/lib/chain/errors/proposerPreferences.d.ts +8 -1
  66. package/lib/chain/errors/proposerPreferences.d.ts.map +1 -1
  67. package/lib/chain/errors/proposerPreferences.js +1 -0
  68. package/lib/chain/errors/proposerPreferences.js.map +1 -1
  69. package/lib/chain/initState.d.ts.map +1 -1
  70. package/lib/chain/initState.js +6 -1
  71. package/lib/chain/initState.js.map +1 -1
  72. package/lib/chain/lightClient/index.d.ts.map +1 -1
  73. package/lib/chain/lightClient/index.js +1 -1
  74. package/lib/chain/lightClient/index.js.map +1 -1
  75. package/lib/chain/opPools/payloadAttestationPool.d.ts +2 -1
  76. package/lib/chain/opPools/payloadAttestationPool.d.ts.map +1 -1
  77. package/lib/chain/opPools/payloadAttestationPool.js +52 -10
  78. package/lib/chain/opPools/payloadAttestationPool.js.map +1 -1
  79. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  80. package/lib/chain/prepareNextSlot.js +16 -18
  81. package/lib/chain/prepareNextSlot.js.map +1 -1
  82. package/lib/chain/produceBlock/produceBlockBody.d.ts +12 -3
  83. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  84. package/lib/chain/produceBlock/produceBlockBody.js +33 -20
  85. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  86. package/lib/chain/regen/queued.d.ts.map +1 -1
  87. package/lib/chain/regen/queued.js +1 -4
  88. package/lib/chain/regen/queued.js.map +1 -1
  89. package/lib/chain/regen/regen.d.ts.map +1 -1
  90. package/lib/chain/regen/regen.js +1 -4
  91. package/lib/chain/regen/regen.js.map +1 -1
  92. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +21 -11
  93. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
  94. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +70 -20
  95. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
  96. package/lib/chain/seenCache/seenProposerPreferences.d.ts +8 -7
  97. package/lib/chain/seenCache/seenProposerPreferences.d.ts.map +1 -1
  98. package/lib/chain/seenCache/seenProposerPreferences.js +11 -10
  99. package/lib/chain/seenCache/seenProposerPreferences.js.map +1 -1
  100. package/lib/chain/validation/executionPayloadBid.js +11 -8
  101. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  102. package/lib/chain/validation/payloadAttestationMessage.d.ts +1 -1
  103. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
  104. package/lib/chain/validation/payloadAttestationMessage.js +5 -3
  105. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  106. package/lib/chain/validation/proposerPreferences.d.ts.map +1 -1
  107. package/lib/chain/validation/proposerPreferences.js +39 -17
  108. package/lib/chain/validation/proposerPreferences.js.map +1 -1
  109. package/lib/metrics/metrics/lodestar.d.ts +4 -0
  110. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  111. package/lib/metrics/metrics/lodestar.js +5 -0
  112. package/lib/metrics/metrics/lodestar.js.map +1 -1
  113. package/lib/network/gossip/topic.d.ts +751 -2
  114. package/lib/network/gossip/topic.d.ts.map +1 -1
  115. package/lib/network/interface.d.ts +2 -0
  116. package/lib/network/interface.d.ts.map +1 -1
  117. package/lib/network/network.d.ts +2 -0
  118. package/lib/network/network.d.ts.map +1 -1
  119. package/lib/network/network.js +8 -0
  120. package/lib/network/network.js.map +1 -1
  121. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  122. package/lib/network/processor/gossipHandlers.js +61 -13
  123. package/lib/network/processor/gossipHandlers.js.map +1 -1
  124. package/lib/network/processor/index.js +5 -5
  125. package/lib/network/processor/index.js.map +1 -1
  126. package/lib/network/reqresp/ReqRespBeaconNode.d.ts.map +1 -1
  127. package/lib/network/reqresp/ReqRespBeaconNode.js +1 -1
  128. package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
  129. package/lib/network/reqresp/handlers/beaconBlocksByHead.d.ts +9 -0
  130. package/lib/network/reqresp/handlers/beaconBlocksByHead.d.ts.map +1 -0
  131. package/lib/network/reqresp/handlers/beaconBlocksByHead.js +61 -0
  132. package/lib/network/reqresp/handlers/beaconBlocksByHead.js.map +1 -0
  133. package/lib/network/reqresp/handlers/index.d.ts.map +1 -1
  134. package/lib/network/reqresp/handlers/index.js +5 -0
  135. package/lib/network/reqresp/handlers/index.js.map +1 -1
  136. package/lib/network/reqresp/interface.d.ts +1 -1
  137. package/lib/network/reqresp/interface.js +1 -1
  138. package/lib/network/reqresp/protocols.d.ts +1 -0
  139. package/lib/network/reqresp/protocols.d.ts.map +1 -1
  140. package/lib/network/reqresp/protocols.js +5 -0
  141. package/lib/network/reqresp/protocols.js.map +1 -1
  142. package/lib/network/reqresp/rateLimit.d.ts.map +1 -1
  143. package/lib/network/reqresp/rateLimit.js +4 -0
  144. package/lib/network/reqresp/rateLimit.js.map +1 -1
  145. package/lib/network/reqresp/score.d.ts.map +1 -1
  146. package/lib/network/reqresp/score.js +1 -0
  147. package/lib/network/reqresp/score.js.map +1 -1
  148. package/lib/network/reqresp/types.d.ts +3 -0
  149. package/lib/network/reqresp/types.d.ts.map +1 -1
  150. package/lib/network/reqresp/types.js +3 -0
  151. package/lib/network/reqresp/types.js.map +1 -1
  152. package/lib/node/nodejs.js +2 -2
  153. package/lib/node/nodejs.js.map +1 -1
  154. package/lib/node/notifier.js +1 -7
  155. package/lib/node/notifier.js.map +1 -1
  156. package/lib/sync/constants.d.ts +7 -1
  157. package/lib/sync/constants.d.ts.map +1 -1
  158. package/lib/sync/constants.js +7 -4
  159. package/lib/sync/constants.js.map +1 -1
  160. package/lib/sync/range/batch.d.ts +43 -6
  161. package/lib/sync/range/batch.d.ts.map +1 -1
  162. package/lib/sync/range/batch.js +243 -44
  163. package/lib/sync/range/batch.js.map +1 -1
  164. package/lib/sync/range/chain.d.ts +16 -2
  165. package/lib/sync/range/chain.d.ts.map +1 -1
  166. package/lib/sync/range/chain.js +100 -9
  167. package/lib/sync/range/chain.js.map +1 -1
  168. package/lib/sync/range/range.d.ts.map +1 -1
  169. package/lib/sync/range/range.js +54 -5
  170. package/lib/sync/range/range.js.map +1 -1
  171. package/lib/sync/range/utils/peerBalancer.d.ts +2 -1
  172. package/lib/sync/range/utils/peerBalancer.d.ts.map +1 -1
  173. package/lib/sync/range/utils/peerBalancer.js +8 -4
  174. package/lib/sync/range/utils/peerBalancer.js.map +1 -1
  175. package/lib/sync/sync.d.ts.map +1 -1
  176. package/lib/sync/sync.js +13 -0
  177. package/lib/sync/sync.js.map +1 -1
  178. package/lib/sync/unknownBlock.d.ts +7 -2
  179. package/lib/sync/unknownBlock.d.ts.map +1 -1
  180. package/lib/sync/unknownBlock.js +127 -57
  181. package/lib/sync/unknownBlock.js.map +1 -1
  182. package/lib/sync/utils/downloadByRange.d.ts +36 -9
  183. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  184. package/lib/sync/utils/downloadByRange.js +106 -42
  185. package/lib/sync/utils/downloadByRange.js.map +1 -1
  186. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  187. package/lib/sync/utils/downloadByRoot.js +10 -0
  188. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  189. package/lib/sync/utils/rateLimit.d.ts +2 -0
  190. package/lib/sync/utils/rateLimit.d.ts.map +1 -0
  191. package/lib/sync/utils/rateLimit.js +15 -0
  192. package/lib/sync/utils/rateLimit.js.map +1 -0
  193. package/lib/util/sszBytes.d.ts.map +1 -1
  194. package/lib/util/sszBytes.js +8 -6
  195. package/lib/util/sszBytes.js.map +1 -1
  196. package/package.json +15 -16
  197. package/src/api/impl/beacon/blocks/index.ts +13 -0
  198. package/src/api/impl/beacon/pool/index.ts +83 -1
  199. package/src/api/impl/debug/index.ts +0 -1
  200. package/src/api/impl/validator/index.ts +82 -1
  201. package/src/chain/blocks/blockInput/blockInput.ts +4 -1
  202. package/src/chain/blocks/importBlock.ts +16 -50
  203. package/src/chain/blocks/importExecutionPayload.ts +32 -15
  204. package/src/chain/blocks/index.ts +32 -15
  205. package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +37 -3
  206. package/src/chain/blocks/payloadEnvelopeInput/types.ts +18 -0
  207. package/src/chain/blocks/types.ts +2 -1
  208. package/src/chain/blocks/utils/chainSegment.ts +35 -24
  209. package/src/chain/blocks/verifyBlock.ts +45 -13
  210. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +6 -4
  211. package/src/chain/blocks/verifyBlocksSanityChecks.ts +16 -6
  212. package/src/chain/blocks/verifyExecutionPayloadEnvelope.ts +14 -6
  213. package/src/chain/blocks/verifyPayloadsDataAvailability.ts +7 -4
  214. package/src/chain/chain.ts +29 -7
  215. package/src/chain/emitter.ts +0 -11
  216. package/src/chain/errors/proposerPreferences.ts +9 -1
  217. package/src/chain/initState.ts +9 -1
  218. package/src/chain/lightClient/index.ts +6 -6
  219. package/src/chain/opPools/payloadAttestationPool.ts +59 -10
  220. package/src/chain/prepareNextSlot.ts +21 -29
  221. package/src/chain/produceBlock/produceBlockBody.ts +41 -25
  222. package/src/chain/regen/queued.ts +2 -7
  223. package/src/chain/regen/regen.ts +2 -7
  224. package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +90 -24
  225. package/src/chain/seenCache/seenProposerPreferences.ts +14 -11
  226. package/src/chain/validation/executionPayloadBid.ts +11 -8
  227. package/src/chain/validation/payloadAttestationMessage.ts +6 -4
  228. package/src/chain/validation/proposerPreferences.ts +37 -18
  229. package/src/metrics/metrics/lodestar.ts +6 -0
  230. package/src/network/interface.ts +2 -0
  231. package/src/network/network.ts +23 -0
  232. package/src/network/processor/gossipHandlers.ts +75 -14
  233. package/src/network/processor/index.ts +5 -5
  234. package/src/network/reqresp/ReqRespBeaconNode.ts +1 -0
  235. package/src/network/reqresp/handlers/beaconBlocksByHead.ts +91 -0
  236. package/src/network/reqresp/handlers/index.ts +5 -0
  237. package/src/network/reqresp/interface.ts +1 -1
  238. package/src/network/reqresp/protocols.ts +6 -0
  239. package/src/network/reqresp/rateLimit.ts +4 -0
  240. package/src/network/reqresp/score.ts +1 -0
  241. package/src/network/reqresp/types.ts +5 -0
  242. package/src/node/nodejs.ts +2 -2
  243. package/src/node/notifier.ts +1 -8
  244. package/src/sync/constants.ts +8 -4
  245. package/src/sync/range/batch.ts +309 -51
  246. package/src/sync/range/chain.ts +119 -10
  247. package/src/sync/range/range.ts +68 -5
  248. package/src/sync/range/utils/peerBalancer.ts +9 -3
  249. package/src/sync/sync.ts +13 -1
  250. package/src/sync/unknownBlock.ts +157 -60
  251. package/src/sync/utils/downloadByRange.ts +174 -44
  252. package/src/sync/utils/downloadByRoot.ts +12 -0
  253. package/src/sync/utils/rateLimit.ts +16 -0
  254. package/src/util/sszBytes.ts +8 -6
@@ -1,9 +1,10 @@
1
- import {Slot, ValidatorIndex} from "@lodestar/types";
1
+ import {RootHex, Slot, ValidatorIndex} from "@lodestar/types";
2
2
  import {GossipActionError} from "./gossipValidation.js";
3
3
 
4
4
  export enum ProposerPreferencesErrorCode {
5
5
  INVALID_EPOCH = "PROPOSER_PREFERENCES_ERROR_INVALID_EPOCH",
6
6
  PROPOSAL_SLOT_PASSED = "PROPOSER_PREFERENCES_ERROR_PROPOSAL_SLOT_PASSED",
7
+ UNKNOWN_DEPENDENT_ROOT = "PROPOSER_PREFERENCES_ERROR_UNKNOWN_DEPENDENT_ROOT",
7
8
  INVALID_PROPOSER = "PROPOSER_PREFERENCES_ERROR_INVALID_PROPOSER",
8
9
  ALREADY_KNOWN = "PROPOSER_PREFERENCES_ERROR_ALREADY_KNOWN",
9
10
  INVALID_SIGNATURE = "PROPOSER_PREFERENCES_ERROR_INVALID_SIGNATURE",
@@ -20,15 +21,22 @@ export type ProposerPreferencesErrorType =
20
21
  proposalSlot: Slot;
21
22
  currentSlot: Slot;
22
23
  }
24
+ | {
25
+ code: ProposerPreferencesErrorCode.UNKNOWN_DEPENDENT_ROOT;
26
+ proposalSlot: Slot;
27
+ dependentRoot: RootHex;
28
+ }
23
29
  | {
24
30
  code: ProposerPreferencesErrorCode.INVALID_PROPOSER;
25
31
  proposalSlot: Slot;
26
32
  validatorIndex: ValidatorIndex;
33
+ dependentRoot: RootHex;
27
34
  }
28
35
  | {
29
36
  code: ProposerPreferencesErrorCode.ALREADY_KNOWN;
30
37
  proposalSlot: Slot;
31
38
  validatorIndex: ValidatorIndex;
39
+ dependentRoot: RootHex;
32
40
  }
33
41
  | {
34
42
  code: ProposerPreferencesErrorCode.INVALID_SIGNATURE;
@@ -1,7 +1,8 @@
1
1
  import {ChainForkConfig} from "@lodestar/config";
2
- import {ZERO_HASH} from "@lodestar/params";
2
+ import {ForkPostGloas, ForkSeq, ZERO_HASH} from "@lodestar/params";
3
3
  import {
4
4
  BeaconStateAllForks,
5
+ BeaconStateGloas,
5
6
  IBeaconStateView,
6
7
  computeEpochAtSlot,
7
8
  computeStartSlotAtEpoch,
@@ -52,6 +53,13 @@ export function createGenesisBlock(config: ChainForkConfig, genesisState: Beacon
52
53
  const genesisBlock = types.SignedBeaconBlock.defaultValue();
53
54
  const stateRoot = genesisState.hashTreeRoot();
54
55
  genesisBlock.message.stateRoot = stateRoot;
56
+
57
+ if (config.getForkSeq(GENESIS_SLOT) >= ForkSeq.gloas) {
58
+ const gloasBlock = genesisBlock as SignedBeaconBlock<ForkPostGloas>;
59
+ const gloasState = genesisState as BeaconStateGloas;
60
+ gloasBlock.message.body.signedExecutionPayloadBid.message = gloasState.latestExecutionPayloadBid.toValue();
61
+ }
62
+
55
63
  return genesisBlock;
56
64
  }
57
65
 
@@ -1,12 +1,6 @@
1
1
  import {BitArray} from "@chainsafe/ssz";
2
2
  import {routes} from "@lodestar/api";
3
3
  import {ChainForkConfig} from "@lodestar/config";
4
- import {
5
- LightClientUpdateSummary,
6
- isBetterUpdate,
7
- toLightClientUpdateSummary,
8
- upgradeLightClientHeader,
9
- } from "@lodestar/light-client/spec";
10
4
  import {
11
5
  ForkName,
12
6
  ForkPostAltair,
@@ -27,6 +21,12 @@ import {
27
21
  computeSyncPeriodAtSlot,
28
22
  executionPayloadToPayloadHeader,
29
23
  } from "@lodestar/state-transition";
24
+ import {
25
+ LightClientUpdateSummary,
26
+ isBetterUpdate,
27
+ toLightClientUpdateSummary,
28
+ upgradeLightClientHeader,
29
+ } from "@lodestar/state-transition/light-client";
30
30
  import {
31
31
  BeaconBlock,
32
32
  BeaconBlockBody,
@@ -57,7 +57,7 @@ export class PayloadAttestationPool {
57
57
  add(
58
58
  message: gloas.PayloadAttestationMessage,
59
59
  payloadAttDataRootHex: RootHex,
60
- validatorCommitteeIndex: number
60
+ validatorCommitteeIndices: number[]
61
61
  ): InsertOutcome {
62
62
  const slot = message.data.slot;
63
63
  const lowestPermissibleSlot = this.lowestPermissibleSlot;
@@ -85,10 +85,10 @@ export class PayloadAttestationPool {
85
85
  const aggregate = aggregateByDataRoot.get(payloadAttDataRootHex);
86
86
  if (aggregate) {
87
87
  // Aggregate msg into aggregate
88
- return aggregateMessageInto(message, validatorCommitteeIndex, aggregate);
88
+ return aggregateMessageInto(message, validatorCommitteeIndices, aggregate);
89
89
  }
90
90
  // Create a new aggregate with data
91
- aggregateByDataRoot.set(payloadAttDataRootHex, messageToAggregate(message, validatorCommitteeIndex));
91
+ aggregateByDataRoot.set(payloadAttDataRootHex, messageToAggregate(message, validatorCommitteeIndices));
92
92
 
93
93
  return InsertOutcome.NewData;
94
94
  }
@@ -119,31 +119,80 @@ export class PayloadAttestationPool {
119
119
  .map(fastToPayloadAttestation);
120
120
  }
121
121
 
122
+ getAll(slot?: Slot): gloas.PayloadAttestation[] {
123
+ const aggregates: AggregateFast[] = [];
124
+
125
+ const addAggregates = (aggregateByDataRootByBlockRoot: Map<BlockRootHex, Map<DataRootHex, AggregateFast>>) => {
126
+ for (const aggregateByDataRoot of aggregateByDataRootByBlockRoot.values()) {
127
+ aggregates.push(...aggregateByDataRoot.values());
128
+ }
129
+ };
130
+
131
+ if (slot !== undefined) {
132
+ const aggregateByDataRootByBlockRoot = this.aggregateByDataRootByBlockRootBySlot.get(slot);
133
+ if (aggregateByDataRootByBlockRoot) {
134
+ addAggregates(aggregateByDataRootByBlockRoot);
135
+ }
136
+ } else {
137
+ for (const aggregateByDataRootByBlockRoot of this.aggregateByDataRootByBlockRootBySlot.values()) {
138
+ addAggregates(aggregateByDataRootByBlockRoot);
139
+ }
140
+ }
141
+
142
+ return aggregates
143
+ .sort((a, b) => b.aggregationBits.getTrueBitIndexes().length - a.aggregationBits.getTrueBitIndexes().length)
144
+ .map(fastToPayloadAttestation);
145
+ }
146
+
122
147
  prune(clockSlot: Slot): void {
123
148
  pruneBySlot(this.aggregateByDataRootByBlockRootBySlot, clockSlot, SLOTS_RETAINED);
124
149
  this.lowestPermissibleSlot = clockSlot;
125
150
  }
126
151
  }
127
152
 
128
- function messageToAggregate(message: gloas.PayloadAttestationMessage, validatorCommitteeIndex: number): AggregateFast {
153
+ function messageToAggregate(
154
+ message: gloas.PayloadAttestationMessage,
155
+ validatorCommitteeIndices: number[]
156
+ ): AggregateFast {
157
+ const aggregationBits = BitArray.fromBitLen(PTC_SIZE);
158
+ for (const index of validatorCommitteeIndices) {
159
+ aggregationBits.set(index, true);
160
+ }
161
+ const sig = signatureFromBytesNoCheck(message.signature);
162
+ // The validator signed once but occupies `validatorCommitteeIndices.length` PTC positions.
163
+ // Verification aggregates the pubkey once per set bit, so the signature must be aggregated
164
+ // the same number of times for the BLS check to balance — same pattern as sync committee.
165
+ const signature =
166
+ validatorCommitteeIndices.length === 1
167
+ ? sig
168
+ : aggregateSignatures(new Array(validatorCommitteeIndices.length).fill(sig));
129
169
  return {
130
- aggregationBits: BitArray.fromSingleBit(PTC_SIZE, validatorCommitteeIndex),
170
+ aggregationBits,
131
171
  data: message.data,
132
- signature: signatureFromBytesNoCheck(message.signature),
172
+ signature,
133
173
  };
134
174
  }
135
175
 
136
176
  function aggregateMessageInto(
137
177
  message: gloas.PayloadAttestationMessage,
138
- validatorCommitteeIndex: number,
178
+ validatorCommitteeIndices: number[],
139
179
  aggregate: AggregateFast
140
180
  ): InsertOutcome {
141
- if (aggregate.aggregationBits.get(validatorCommitteeIndex) === true) {
181
+ // Gossip dedup via `seenPayloadAttesters` is keyed by (epoch, validatorIndex), so the same
182
+ // validator's message is never processed twice — all of its bits are set together or none.
183
+ // Checking the first index is sufficient.
184
+ if (aggregate.aggregationBits.get(validatorCommitteeIndices[0]) === true) {
142
185
  return InsertOutcome.AlreadyKnown;
143
186
  }
144
187
 
145
- aggregate.aggregationBits.set(validatorCommitteeIndex, true);
146
- aggregate.signature = aggregateSignatures([aggregate.signature, signatureFromBytesNoCheck(message.signature)]);
188
+ for (const index of validatorCommitteeIndices) {
189
+ aggregate.aggregationBits.set(index, true);
190
+ }
191
+ const sig = signatureFromBytesNoCheck(message.signature);
192
+ aggregate.signature = aggregateSignatures([
193
+ aggregate.signature,
194
+ ...new Array(validatorCommitteeIndices.length).fill(sig),
195
+ ]);
147
196
 
148
197
  return InsertOutcome.Aggregated;
149
198
  }
@@ -4,13 +4,14 @@ import {getSafeExecutionBlockHash} from "@lodestar/fork-choice";
4
4
  import {ForkPostBellatrix, ForkSeq, SLOTS_PER_EPOCH, isForkPostBellatrix} from "@lodestar/params";
5
5
  import {
6
6
  IBeaconStateView,
7
+ IBeaconStateViewBellatrix,
7
8
  StateHashTreeRootSource,
8
9
  computeEpochAtSlot,
9
10
  computeTimeAtSlot,
10
11
  isStatePostBellatrix,
11
12
  isStatePostGloas,
12
13
  } from "@lodestar/state-transition";
13
- import {Bytes32, Slot, electra} from "@lodestar/types";
14
+ import {Bytes32, Slot} from "@lodestar/types";
14
15
  import {Logger, fromHex, isErrorAborted, sleep} from "@lodestar/utils";
15
16
  import {GENESIS_SLOT, ZERO_HASH_HEX} from "../constants/constants.js";
16
17
  import {BuilderStatus} from "../execution/builder/http.js";
@@ -165,19 +166,26 @@ export class PrepareNextSlotScheduler {
165
166
  }
166
167
 
167
168
  let parentBlockHash: Bytes32;
168
- let isExtendingPayload = false;
169
+ // Apply parent payload once here as it's reused by EL prep and SSE emit below
170
+ let stateAfterParentPayload: IBeaconStateViewBellatrix = updatedPrepareState;
169
171
  if (isStatePostGloas(updatedPrepareState)) {
170
- isExtendingPayload = this.chain.forkChoice.shouldExtendPayload(updatedHead.blockRoot);
171
- parentBlockHash = isExtendingPayload
172
- ? updatedPrepareState.latestExecutionPayloadBid.blockHash
173
- : updatedPrepareState.latestExecutionPayloadBid.parentBlockHash;
172
+ if (this.chain.forkChoice.shouldExtendPayload(updatedHead.blockRoot)) {
173
+ parentBlockHash = updatedPrepareState.latestExecutionPayloadBid.blockHash;
174
+ // Skip applying parent payload unless we're proposing the next slot or have to emit payload_attributes events
175
+ if (feeRecipient !== undefined || this.chain.opts.emitPayloadAttributes === true) {
176
+ const parentExecutionRequests = await this.chain.getParentExecutionRequests(
177
+ updatedHead.slot,
178
+ updatedHead.blockRoot
179
+ );
180
+ stateAfterParentPayload = updatedPrepareState.withParentPayloadApplied(parentExecutionRequests);
181
+ }
182
+ } else {
183
+ parentBlockHash = updatedPrepareState.latestExecutionPayloadBid.parentBlockHash;
184
+ }
174
185
  } else {
175
186
  parentBlockHash = updatedPrepareState.latestExecutionPayloadHeader.blockHash;
176
187
  }
177
188
 
178
- // Reused by the SSE emit below to avoid a second DB lookup on cache miss
179
- let parentExecutionRequests: electra.ExecutionRequests | undefined;
180
-
181
189
  if (feeRecipient) {
182
190
  const preparationTime =
183
191
  computeTimeAtSlot(this.config, prepareSlot, this.chain.genesisTime) - Date.now() / 1000;
@@ -187,13 +195,6 @@ export class PrepareNextSlotScheduler {
187
195
  const finalizedBlockHash =
188
196
  this.chain.forkChoice.getFinalizedBlock().executionPayloadBlockHash ?? ZERO_HASH_HEX;
189
197
 
190
- if (isExtendingPayload) {
191
- parentExecutionRequests = await this.chain.getParentExecutionRequests(
192
- updatedHead.slot,
193
- updatedHead.blockRoot
194
- );
195
- }
196
-
197
198
  // awaiting here instead of throwing an async call because there is no other task
198
199
  // left for scheduler and this gives nice semantics to catch and log errors in the
199
200
  // try/catch wrapper here.
@@ -205,9 +206,8 @@ export class PrepareNextSlotScheduler {
205
206
  parentBlockHash,
206
207
  safeBlockHash,
207
208
  finalizedBlockHash,
208
- updatedPrepareState,
209
- feeRecipient,
210
- parentExecutionRequests
209
+ stateAfterParentPayload,
210
+ feeRecipient
211
211
  );
212
212
  this.logger.verbose("PrepareNextSlotScheduler prepared new payload", {
213
213
  prepareSlot,
@@ -222,7 +222,7 @@ export class PrepareNextSlotScheduler {
222
222
  // and head.parent (proposer-boost-reorg fallback). Anything older is evicted.
223
223
  const updatedHeadParent = this.chain.forkChoice.getBlockHexDefaultStatus(updatedHead.parentRoot);
224
224
  if (updatedHeadParent) {
225
- this.chain.seenPayloadEnvelopeInputCache.pruneBelow(updatedHeadParent.slot);
225
+ this.chain.seenPayloadEnvelopeInputCache.pruneBelowParent(updatedHeadParent);
226
226
  }
227
227
  }
228
228
 
@@ -234,20 +234,12 @@ export class PrepareNextSlotScheduler {
234
234
  (feeRecipient || this.chain.opts.emitPayloadAttributes === true) &&
235
235
  this.chain.emitter.listenerCount(routes.events.EventType.payloadAttributes)
236
236
  ) {
237
- // if we didn't fetch above (not proposing), SSE still needs it here
238
- if (!parentExecutionRequests && isExtendingPayload) {
239
- parentExecutionRequests = await this.chain.getParentExecutionRequests(
240
- updatedHead.slot,
241
- updatedHead.blockRoot
242
- );
243
- }
244
237
  const data = getPayloadAttributesForSSE(fork as ForkPostBellatrix, this.chain, {
245
- prepareState: updatedPrepareState,
238
+ prepareState: stateAfterParentPayload,
246
239
  prepareSlot,
247
240
  parentBlockRoot: fromHex(updatedHead.blockRoot),
248
241
  parentBlockHash,
249
242
  feeRecipient: feeRecipient ?? "0x0000000000000000000000000000000000000000",
250
- parentExecutionRequests,
251
243
  });
252
244
  this.chain.emitter.emit(routes.events.EventType.payloadAttributes, {data, version: fork});
253
245
  }
@@ -49,7 +49,7 @@ import {
49
49
  ssz,
50
50
  } from "@lodestar/types";
51
51
  import {Logger, byteArrayEquals, fromHex, sleep, toHex, toPubkeyHex, toRootHex} from "@lodestar/utils";
52
- import {ZERO_HASH, ZERO_HASH_HEX} from "../../constants/index.js";
52
+ import {ZERO_HASH_HEX} from "../../constants/index.js";
53
53
  import {numToQuantity} from "../../execution/engine/utils.js";
54
54
  import {
55
55
  IExecutionBuilder,
@@ -111,6 +111,7 @@ export type ProduceFullGloas = {
111
111
  executionRequests: electra.ExecutionRequests;
112
112
  blobsBundle: BlobsBundle<ForkPostGloas>;
113
113
  cells: fulu.Cell[][];
114
+ parentBlockRoot: Root;
114
115
  };
115
116
  export type ProduceFullFulu = {
116
117
  type: BlockType.Full;
@@ -214,19 +215,19 @@ export async function produceBlockBody<T extends BlockType>(
214
215
  });
215
216
 
216
217
  // Get execution payload from EL
218
+ let parentBlockHash: Bytes32;
219
+ let parentExecutionRequests: electra.ExecutionRequests;
220
+ // Apply parent payload once here as it's reused by EL prep and voluntary exit filtering below
221
+ let stateAfterParentPayload: IBeaconStateViewBellatrix = currentState;
217
222
  const isExtendingPayload = this.forkChoice.shouldExtendPayload(toRootHex(parentBlockRoot));
218
- let parentBlockHash = isExtendingPayload
219
- ? currentState.latestExecutionPayloadBid.blockHash
220
- : currentState.latestExecutionPayloadBid.parentBlockHash;
221
- // At gloas genesis the committed bid has no prior EL block to reference
222
- // (`bid.parentBlockHash` is zero). Fall back to `bid.blockHash` (= eth1 genesis hash) so the
223
- // FCU to the EL carries a valid head. Post-genesis bids always reference a non-zero parent.
224
- if (isStatePostGloas(currentState) && byteArrayEquals(parentBlockHash, ZERO_HASH)) {
223
+ if (isExtendingPayload) {
225
224
  parentBlockHash = currentState.latestExecutionPayloadBid.blockHash;
225
+ parentExecutionRequests = await this.getParentExecutionRequests(parentBlock.slot, parentBlock.blockRoot);
226
+ stateAfterParentPayload = currentState.withParentPayloadApplied(parentExecutionRequests);
227
+ } else {
228
+ parentBlockHash = currentState.latestExecutionPayloadBid.parentBlockHash;
229
+ parentExecutionRequests = ssz.electra.ExecutionRequests.defaultValue();
226
230
  }
227
- const parentExecutionRequests = isExtendingPayload
228
- ? await this.getParentExecutionRequests(parentBlock.slot, parentBlock.blockRoot)
229
- : ssz.electra.ExecutionRequests.defaultValue();
230
231
  const prepareRes = await prepareExecutionPayload(
231
232
  this,
232
233
  this.logger,
@@ -235,9 +236,8 @@ export async function produceBlockBody<T extends BlockType>(
235
236
  parentBlockHash,
236
237
  safeBlockHash,
237
238
  finalizedBlockHash ?? ZERO_HASH_HEX,
238
- currentState,
239
- feeRecipient,
240
- parentExecutionRequests
239
+ stateAfterParentPayload,
240
+ feeRecipient
241
241
  );
242
242
 
243
243
  const {prepType, payloadId} = prepareRes;
@@ -296,6 +296,14 @@ export async function produceBlockBody<T extends BlockType>(
296
296
  blockSlot - 1
297
297
  );
298
298
  gloasBody.parentExecutionRequests = parentExecutionRequests;
299
+ // Drop voluntary exits that parent_execution_requests have invalidated (e.g. a withdrawal
300
+ // request initiating an exit on the same validator). Op pool selected against the unapplied
301
+ // state, so re-validate against the post-apply state to avoid producing an invalid block.
302
+ if (isExtendingPayload && commonBlockBody.voluntaryExits.length > 0) {
303
+ gloasBody.voluntaryExits = commonBlockBody.voluntaryExits.filter((signedVoluntaryExit) =>
304
+ stateAfterParentPayload.isValidVoluntaryExit(signedVoluntaryExit, false)
305
+ );
306
+ }
299
307
  blockBody = gloasBody as AssembledBodyType<T>;
300
308
 
301
309
  // Store execution payload data required to construct execution payload envelope later
@@ -304,6 +312,7 @@ export async function produceBlockBody<T extends BlockType>(
304
312
  gloasResult.executionRequests = executionRequests;
305
313
  gloasResult.blobsBundle = blobsBundle;
306
314
  gloasResult.cells = cells;
315
+ gloasResult.parentBlockRoot = fromHex(parentBlock.blockRoot);
307
316
 
308
317
  const fetchedTime = Date.now() / 1000 - computeTimeAtSlot(this.config, blockSlot, this.genesisTime);
309
318
  this.metrics?.blockPayload.payloadFetchedTime.observe({prepType}, fetchedTime);
@@ -631,9 +640,12 @@ export async function prepareExecutionPayload(
631
640
  parentBlockHash: Bytes32,
632
641
  safeBlockHash: RootHex,
633
642
  finalizedBlockHash: RootHex,
643
+ /**
644
+ * Post-gloas, when extending a full parent, callers must apply
645
+ * parent execution payload first (see `withParentPayloadApplied`).
646
+ */
634
647
  state: IBeaconStateViewBellatrix,
635
- suggestedFeeRecipient: string,
636
- parentExecutionRequests?: electra.ExecutionRequests
648
+ suggestedFeeRecipient: string
637
649
  ): Promise<{prepType: PayloadPreparationType; payloadId: PayloadId}> {
638
650
  const timestamp = computeTimeAtSlot(chain.config, state.slot, state.genesisTime);
639
651
  const prevRandao = state.getRandaoMix(state.epoch);
@@ -670,7 +682,6 @@ export async function prepareExecutionPayload(
670
682
  parentBlockRoot,
671
683
  parentBlockHash,
672
684
  feeRecipient: suggestedFeeRecipient,
673
- parentExecutionRequests,
674
685
  });
675
686
 
676
687
  payloadId = await chain.executionEngine.notifyForkchoiceUpdate(
@@ -729,14 +740,16 @@ export function getPayloadAttributesForSSE(
729
740
  parentBlockRoot,
730
741
  parentBlockHash,
731
742
  feeRecipient,
732
- parentExecutionRequests,
733
743
  }: {
744
+ /**
745
+ * Post-gloas, when extending a full parent, callers must apply
746
+ * parent execution payload first (see `withParentPayloadApplied`).
747
+ */
734
748
  prepareState: IBeaconStateViewBellatrix;
735
749
  prepareSlot: Slot;
736
750
  parentBlockRoot: Root;
737
751
  parentBlockHash: Bytes32;
738
752
  feeRecipient: string;
739
- parentExecutionRequests?: electra.ExecutionRequests;
740
753
  }
741
754
  ): SSEPayloadAttributes {
742
755
  const payloadAttributes = preparePayloadAttributes(fork, chain, {
@@ -745,7 +758,6 @@ export function getPayloadAttributesForSSE(
745
758
  parentBlockRoot,
746
759
  parentBlockHash,
747
760
  feeRecipient,
748
- parentExecutionRequests,
749
761
  });
750
762
 
751
763
  let parentBlockNumber: number;
@@ -784,14 +796,16 @@ function preparePayloadAttributes(
784
796
  parentBlockRoot,
785
797
  parentBlockHash,
786
798
  feeRecipient,
787
- parentExecutionRequests,
788
799
  }: {
800
+ /**
801
+ * Post-gloas, when extending a full parent, callers must apply
802
+ * parent execution payload first (see `withParentPayloadApplied`).
803
+ */
789
804
  prepareState: IBeaconStateViewBellatrix;
790
805
  prepareSlot: Slot;
791
806
  parentBlockRoot: Root;
792
807
  parentBlockHash: Bytes32;
793
808
  feeRecipient: string;
794
- parentExecutionRequests?: electra.ExecutionRequests;
795
809
  }
796
810
  ): SSEPayloadAttributes["payloadAttributes"] {
797
811
  const timestamp = computeTimeAtSlot(chain.config, prepareSlot, prepareState.genesisTime);
@@ -810,11 +824,13 @@ function preparePayloadAttributes(
810
824
  if (isStatePostGloas(prepareState)) {
811
825
  const isExtendingPayload = byteArrayEquals(parentBlockHash, prepareState.latestExecutionPayloadBid.blockHash);
812
826
  if (isExtendingPayload) {
813
- if (parentExecutionRequests === undefined) {
814
- throw new Error("parentExecutionRequests required when extending full parent");
827
+ // applyParentExecutionPayload sets latestBlockHash = parentBid.blockHash, so a mismatch
828
+ // here means the caller did not apply parent payload to prepareState
829
+ if (!byteArrayEquals(prepareState.latestBlockHash, prepareState.latestExecutionPayloadBid.blockHash)) {
830
+ throw new Error("Expected state with parent execution payload applied for withdrawals");
815
831
  }
816
832
  (payloadAttributes as capella.SSEPayloadAttributes["payloadAttributes"]).withdrawals =
817
- prepareState.getExpectedWithdrawalsForFullParent(parentExecutionRequests);
833
+ prepareState.getExpectedWithdrawals().expectedWithdrawals;
818
834
  } else {
819
835
  // When the parent block is empty, state.payloadExpectedWithdrawals holds a batch
820
836
  // already deducted from CL balances but never credited on the EL (the envelope
@@ -1,7 +1,7 @@
1
1
  import {routes} from "@lodestar/api";
2
2
  import {IForkChoice, ProtoBlock} from "@lodestar/fork-choice";
3
3
  import {IBeaconStateView, computeEpochAtSlot} from "@lodestar/state-transition";
4
- import {BeaconBlock, Epoch, RootHex, Slot, isGloasBeaconBlock, phase0} from "@lodestar/types";
4
+ import {BeaconBlock, Epoch, RootHex, Slot, 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,12 +88,7 @@ export class QueuedStateRegenerator implements IStateRegenerator {
88
88
  */
89
89
  getPreStateSync(block: BeaconBlock): IBeaconStateView | null {
90
90
  const parentRoot = toRootHex(block.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);
91
+ const parentBlock = this.forkChoice.getBlockHexDefaultStatus(parentRoot);
97
92
  if (!parentBlock) {
98
93
  throw new RegenError({
99
94
  code: RegenErrorCode.BLOCK_NOT_IN_FORKCHOICE,
@@ -9,7 +9,7 @@ import {
9
9
  computeEpochAtSlot,
10
10
  computeStartSlotAtEpoch,
11
11
  } from "@lodestar/state-transition";
12
- import {BeaconBlock, RootHex, SignedBeaconBlock, Slot, isGloasBeaconBlock} from "@lodestar/types";
12
+ import {BeaconBlock, RootHex, SignedBeaconBlock, Slot} from "@lodestar/types";
13
13
  import {Logger, fromHex, toRootHex} from "@lodestar/utils";
14
14
  import {IBeaconDb} from "../../db/index.js";
15
15
  import {Metrics} from "../../metrics/index.js";
@@ -57,12 +57,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
57
57
  regenCaller: RegenCaller
58
58
  ): Promise<IBeaconStateView> {
59
59
  const parentRoot = toRootHex(block.parentRoot);
60
- const parentBlock = isGloasBeaconBlock(block)
61
- ? this.modules.forkChoice.getBlockHexAndBlockHash(
62
- parentRoot,
63
- toRootHex(block.body.signedExecutionPayloadBid.message.parentBlockHash)
64
- )
65
- : this.modules.forkChoice.getBlockHexDefaultStatus(parentRoot);
60
+ const parentBlock = this.modules.forkChoice.getBlockHexDefaultStatus(parentRoot);
66
61
  if (!parentBlock) {
67
62
  throw new RegenError({
68
63
  code: RegenErrorCode.BLOCK_NOT_IN_FORKCHOICE,