@lodestar/beacon-node 1.48.0-dev.58bd2c7c96 → 1.48.0-dev.59456ca330

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 (30) hide show
  1. package/lib/api/impl/validator/index.d.ts.map +1 -1
  2. package/lib/api/impl/validator/index.js +39 -39
  3. package/lib/api/impl/validator/index.js.map +1 -1
  4. package/lib/chain/errors/blockError.d.ts +3 -5
  5. package/lib/chain/errors/blockError.d.ts.map +1 -1
  6. package/lib/chain/errors/blockError.js +2 -2
  7. package/lib/chain/errors/blockError.js.map +1 -1
  8. package/lib/chain/errors/executionPayloadEnvelope.d.ts +0 -11
  9. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  10. package/lib/chain/errors/executionPayloadEnvelope.js +0 -2
  11. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  12. package/lib/chain/prepareNextSlot.js +13 -13
  13. package/lib/chain/prepareNextSlot.js.map +1 -1
  14. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  15. package/lib/chain/produceBlock/produceBlockBody.js +46 -64
  16. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  17. package/lib/chain/validation/block.d.ts.map +1 -1
  18. package/lib/chain/validation/block.js +9 -50
  19. package/lib/chain/validation/block.js.map +1 -1
  20. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  21. package/lib/chain/validation/executionPayloadEnvelope.js +0 -29
  22. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  23. package/package.json +15 -15
  24. package/src/api/impl/validator/index.ts +44 -43
  25. package/src/chain/errors/blockError.ts +3 -3
  26. package/src/chain/errors/executionPayloadEnvelope.ts +0 -9
  27. package/src/chain/prepareNextSlot.ts +16 -16
  28. package/src/chain/produceBlock/produceBlockBody.ts +50 -71
  29. package/src/chain/validation/block.ts +9 -66
  30. package/src/chain/validation/executionPayloadEnvelope.ts +0 -37
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "bugs": {
12
12
  "url": "https://github.com/ChainSafe/lodestar/issues"
13
13
  },
14
- "version": "1.48.0-dev.58bd2c7c96",
14
+ "version": "1.48.0-dev.59456ca330",
15
15
  "type": "module",
16
16
  "exports": {
17
17
  ".": {
@@ -109,7 +109,7 @@
109
109
  "@chainsafe/persistent-merkle-tree": "^1.3.1",
110
110
  "@chainsafe/prometheus-gc-stats": "^1.0.0",
111
111
  "@chainsafe/snappy-wasm": "^0.5.0",
112
- "@chainsafe/ssz": "^1.6.3",
112
+ "@chainsafe/ssz": "^1.7.0",
113
113
  "@chainsafe/threads": "^1.11.3",
114
114
  "@crate-crypto/node-eth-kzg": "0.9.1",
115
115
  "@fastify/bearer-auth": "^10.0.1",
@@ -126,17 +126,17 @@
126
126
  "@libp2p/peer-id": "^6.0.15",
127
127
  "@libp2p/prometheus-metrics": "^5.0.28",
128
128
  "@libp2p/tcp": "^11.0.27",
129
- "@lodestar/api": "^1.48.0-dev.58bd2c7c96",
130
- "@lodestar/config": "^1.48.0-dev.58bd2c7c96",
131
- "@lodestar/db": "^1.48.0-dev.58bd2c7c96",
132
- "@lodestar/fork-choice": "^1.48.0-dev.58bd2c7c96",
133
- "@lodestar/logger": "^1.48.0-dev.58bd2c7c96",
134
- "@lodestar/params": "^1.48.0-dev.58bd2c7c96",
135
- "@lodestar/reqresp": "^1.48.0-dev.58bd2c7c96",
136
- "@lodestar/state-transition": "^1.48.0-dev.58bd2c7c96",
137
- "@lodestar/types": "^1.48.0-dev.58bd2c7c96",
138
- "@lodestar/utils": "^1.48.0-dev.58bd2c7c96",
139
- "@lodestar/validator": "^1.48.0-dev.58bd2c7c96",
129
+ "@lodestar/api": "^1.48.0-dev.59456ca330",
130
+ "@lodestar/config": "^1.48.0-dev.59456ca330",
131
+ "@lodestar/db": "^1.48.0-dev.59456ca330",
132
+ "@lodestar/fork-choice": "^1.48.0-dev.59456ca330",
133
+ "@lodestar/logger": "^1.48.0-dev.59456ca330",
134
+ "@lodestar/params": "^1.48.0-dev.59456ca330",
135
+ "@lodestar/reqresp": "^1.48.0-dev.59456ca330",
136
+ "@lodestar/state-transition": "^1.48.0-dev.59456ca330",
137
+ "@lodestar/types": "^1.48.0-dev.59456ca330",
138
+ "@lodestar/utils": "^1.48.0-dev.59456ca330",
139
+ "@lodestar/validator": "^1.48.0-dev.59456ca330",
140
140
  "@multiformats/multiaddr": "^13.0.1",
141
141
  "datastore-core": "^12.0.1",
142
142
  "datastore-level": "^13.0.1",
@@ -158,7 +158,7 @@
158
158
  "@libp2p/interface-internal": "^3.1.12",
159
159
  "@libp2p/logger": "^6.2.13",
160
160
  "@libp2p/utils": "^7.4.0",
161
- "@lodestar/spec-test-util": "^1.48.0-dev.58bd2c7c96",
161
+ "@lodestar/spec-test-util": "^1.48.0-dev.59456ca330",
162
162
  "@types/js-yaml": "^4.0.5",
163
163
  "@types/qs": "^6.9.7",
164
164
  "@types/tmp": "^0.2.3",
@@ -175,5 +175,5 @@
175
175
  "beacon",
176
176
  "blockchain"
177
177
  ],
178
- "gitHead": "5c8d15843b51c830b516320bfd00c1c9ee34291f"
178
+ "gitHead": "a0db83f84e4d5ea344e8a204cd14eea587d6ce66"
179
179
  }
@@ -133,40 +133,37 @@ type BidCandidate = {
133
133
  };
134
134
 
135
135
  /**
136
- * Return the best bid by boosted total payment. A candidate with the max boost factor is
137
- * preferred over any other regardless of value, ties prefer a builder api bid over the
138
- * p2p bid, and the earlier received bid between builder api bids.
136
+ * Ranking value of a bid, the boosted total payment scaled by 100 as `boostFactor` is a percentage.
137
+ * Kept scaled so bids that differ by less than a percent are not truncated into a tie.
139
138
  */
140
- function selectBestBid(candidates: BidCandidate[]): BidCandidate | null {
141
- const boostedValue = ({totalGwei, boostFactor}: BidCandidate): bigint => boostFactor * totalGwei;
142
- let best: BidCandidate | null = null;
143
- for (const candidate of candidates) {
144
- if (best === null) {
145
- best = candidate;
146
- continue;
147
- }
148
- // Preserve max boost preference before comparing bid values
149
- const candidateIsMaxBoost = candidate.boostFactor === MAX_BUILDER_BOOST_FACTOR;
150
- const bestIsMaxBoost = best.boostFactor === MAX_BUILDER_BOOST_FACTOR;
151
- if (candidateIsMaxBoost !== bestIsMaxBoost) {
152
- if (candidateIsMaxBoost) {
153
- best = candidate;
154
- }
155
- continue;
156
- }
157
- const candidateValue = boostedValue(candidate);
158
- const bestValue = boostedValue(best);
159
- if (candidateValue > bestValue) {
160
- best = candidate;
161
- } else if (
162
- candidateValue === bestValue &&
163
- // A tie prefers a builder api bid over the p2p bid, and the earlier received bid otherwise
164
- (best.url === undefined || (candidate.url !== undefined && candidate.receivedMs < best.receivedMs))
165
- ) {
166
- best = candidate;
167
- }
139
+ function getBoostedTotalScaled({totalGwei, boostFactor}: BidCandidate): bigint {
140
+ return boostFactor * totalGwei;
141
+ }
142
+
143
+ /** Order bid candidates by preference, best first, used to select a bid and to log the ranking */
144
+ function compareBidCandidates(a: BidCandidate, b: BidCandidate): number {
145
+ // Preserve max boost preference before comparing bid values
146
+ const aIsMaxBoost = a.boostFactor === MAX_BUILDER_BOOST_FACTOR;
147
+ const bIsMaxBoost = b.boostFactor === MAX_BUILDER_BOOST_FACTOR;
148
+ if (aIsMaxBoost !== bIsMaxBoost) {
149
+ return aIsMaxBoost ? -1 : 1;
168
150
  }
169
- return best;
151
+
152
+ const aBoostedTotal = getBoostedTotalScaled(a);
153
+ const bBoostedTotal = getBoostedTotalScaled(b);
154
+ if (aBoostedTotal !== bBoostedTotal) {
155
+ return aBoostedTotal > bBoostedTotal ? -1 : 1;
156
+ }
157
+
158
+ // A tie prefers a builder api bid over the p2p bid
159
+ const aIsBuilderApi = a.url !== undefined;
160
+ const bIsBuilderApi = b.url !== undefined;
161
+ if (aIsBuilderApi !== bIsBuilderApi) {
162
+ return aIsBuilderApi ? -1 : 1;
163
+ }
164
+
165
+ // and the earlier received bid between builder api bids
166
+ return a.receivedMs - b.receivedMs;
170
167
  }
171
168
 
172
169
  type ProduceBlockContentsRes = {executionPayloadValue: Wei; consensusBlockValue: Wei} & {
@@ -1049,20 +1046,24 @@ export function getValidatorApi(
1049
1046
  });
1050
1047
  }
1051
1048
 
1052
- const best = selectBestBid(candidates);
1053
- if (candidates.length > 0) {
1054
- logger.debug("Ranked builder bid candidates", {
1049
+ if (candidates.length === 0) {
1050
+ return null;
1051
+ }
1052
+
1053
+ const rankedCandidates = candidates.toSorted(compareBidCandidates);
1054
+ for (const [index, candidate] of rankedCandidates.entries()) {
1055
+ logger.debug("Builder bid candidate", {
1055
1056
  slot,
1056
- candidates: candidates
1057
- .map(
1058
- (candidate) =>
1059
- `${candidate.url ?? "p2p"}:total=${prettyGweiToEth(candidate.totalGwei)}:boost=${candidate.boostFactor}:received=${candidate.receivedMs}ms`
1060
- )
1061
- .join(","),
1062
- bidSource: best?.url ?? "p2p",
1057
+ rank: index + 1,
1058
+ source: candidate.url !== undefined ? toPrintableUrl(candidate.url) : "p2p",
1059
+ builder: candidate.signedBid.message.builderIndex,
1060
+ total: prettyGweiToEth(candidate.totalGwei),
1061
+ boost: candidate.boostFactor,
1062
+ boosted: prettyGweiToEth(getBoostedTotalScaled(candidate) / 100n),
1063
+ receivedMs: candidate.receivedMs,
1063
1064
  });
1064
1065
  }
1065
- return best;
1066
+ return rankedCandidates[0];
1066
1067
  })();
1067
1068
 
1068
1069
  const commonBlockBodyPromise = chain.produceCommonBlockBody({
@@ -78,8 +78,8 @@ export enum BlockErrorCode {
78
78
  TOO_MANY_KZG_COMMITMENTS = "BLOCK_ERROR_TOO_MANY_KZG_COMMITMENTS",
79
79
  /** Bid parent block root does not match block parent root */
80
80
  BID_PARENT_ROOT_MISMATCH = "BLOCK_ERROR_BID_PARENT_ROOT_MISMATCH",
81
- /** A block body operation or parent execution request list exceeds its per-block limit */
82
- TOO_MANY_BLOCK_OPERATIONS = "BLOCK_ERROR_TOO_MANY_BLOCK_OPERATIONS",
81
+ /** A block contains deposits where none are allowed */
82
+ NON_ZERO_DEPOSITS = "BLOCK_ERROR_NON_ZERO_DEPOSITS",
83
83
  /** The parent block's execution payload has been verified as invalid */
84
84
  PARENT_EXECUTION_INVALID = "BLOCK_ERROR_PARENT_EXECUTION_INVALID",
85
85
  /**
@@ -153,7 +153,7 @@ export type BlockErrorType =
153
153
  | {code: BlockErrorCode.DATA_UNAVAILABLE}
154
154
  | {code: BlockErrorCode.TOO_MANY_KZG_COMMITMENTS; blobKzgCommitmentsLen: number; commitmentLimit: number}
155
155
  | {code: BlockErrorCode.BID_PARENT_ROOT_MISMATCH; bidParentRoot: RootHex; blockParentRoot: RootHex}
156
- | {code: BlockErrorCode.TOO_MANY_BLOCK_OPERATIONS; name: string; count: number; limit: number}
156
+ | {code: BlockErrorCode.NON_ZERO_DEPOSITS; count: number}
157
157
  | {code: BlockErrorCode.PARENT_EXECUTION_INVALID; parentRoot: RootHex}
158
158
  | {code: BlockErrorCode.PARENT_PAYLOAD_UNKNOWN; parentRoot: RootHex; parentBlockHash: RootHex}
159
159
  | {code: BlockErrorCode.NON_LINEAR_PAYLOAD_ROOTS; parentBlockHash: RootHex; expectedBlockHash: RootHex};
@@ -12,8 +12,6 @@ export enum ExecutionPayloadEnvelopeErrorCode {
12
12
  BUILDER_INDEX_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_BUILDER_INDEX_MISMATCH",
13
13
  BLOCK_HASH_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_BLOCK_HASH_MISMATCH",
14
14
  EXECUTION_REQUESTS_ROOT_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_EXECUTION_REQUESTS_ROOT_MISMATCH",
15
- EXECUTION_REQUESTS_COUNT_EXCEEDED = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_EXECUTION_REQUESTS_COUNT_EXCEEDED",
16
- WITHDRAWALS_COUNT_EXCEEDED = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_WITHDRAWALS_COUNT_EXCEEDED",
17
15
  INVALID_SIGNATURE = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_INVALID_SIGNATURE",
18
16
  PAYLOAD_ENVELOPE_INPUT_MISSING = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_PAYLOAD_ENVELOPE_INPUT_MISSING",
19
17
  }
@@ -44,13 +42,6 @@ export type ExecutionPayloadEnvelopeErrorType =
44
42
  envelopeRequestsRoot: RootHex;
45
43
  bidRequestsRoot: RootHex;
46
44
  }
47
- | {
48
- code: ExecutionPayloadEnvelopeErrorCode.EXECUTION_REQUESTS_COUNT_EXCEEDED;
49
- name: string;
50
- count: number;
51
- limit: number;
52
- }
53
- | {code: ExecutionPayloadEnvelopeErrorCode.WITHDRAWALS_COUNT_EXCEEDED; count: number; limit: number}
54
45
  | {code: ExecutionPayloadEnvelopeErrorCode.INVALID_SIGNATURE}
55
46
  | {code: ExecutionPayloadEnvelopeErrorCode.PAYLOAD_ENVELOPE_INPUT_MISSING; blockRoot: RootHex};
56
47
 
@@ -243,6 +243,22 @@ export class PrepareNextSlotScheduler {
243
243
  parentBlockHash = preparedState.latestExecutionPayloadHeader.blockHash;
244
244
  }
245
245
 
246
+ // If emitPayloadAttributes is true emit a SSE payloadAttributes event for
247
+ // every slot. Without the flag, only emit the event if we are proposing in the next slot.
248
+ if (
249
+ (feeRecipient || this.chain.opts.emitPayloadAttributes === true) &&
250
+ this.chain.emitter.listenerCount(routes.events.EventType.payloadAttributes)
251
+ ) {
252
+ const data = getPayloadAttributesForSSE(fork as ForkPostBellatrix, this.chain, {
253
+ prepareState: stateAfterParentPayload,
254
+ prepareSlot,
255
+ parentBlockRoot: fromHex(updatedHead.blockRoot),
256
+ parentBlockHash,
257
+ feeRecipient: feeRecipient ?? "0x0000000000000000000000000000000000000000",
258
+ });
259
+ this.chain.emitter.emit(routes.events.EventType.payloadAttributes, {data, version: fork});
260
+ }
261
+
246
262
  if (feeRecipient) {
247
263
  const preparationTime =
248
264
  computeTimeAtSlot(this.config, prepareSlot, this.chain.genesisTime) - Date.now() / 1000;
@@ -273,22 +289,6 @@ export class PrepareNextSlotScheduler {
273
289
  }
274
290
 
275
291
  this.computeStateHashTreeRoot(preparedState, isEpochTransition);
276
-
277
- // If emitPayloadAttributes is true emit a SSE payloadAttributes event for
278
- // every slot. Without the flag, only emit the event if we are proposing in the next slot.
279
- if (
280
- (feeRecipient || this.chain.opts.emitPayloadAttributes === true) &&
281
- this.chain.emitter.listenerCount(routes.events.EventType.payloadAttributes)
282
- ) {
283
- const data = getPayloadAttributesForSSE(fork as ForkPostBellatrix, this.chain, {
284
- prepareState: stateAfterParentPayload,
285
- prepareSlot,
286
- parentBlockRoot: fromHex(updatedHead.blockRoot),
287
- parentBlockHash,
288
- feeRecipient: feeRecipient ?? "0x0000000000000000000000000000000000000000",
289
- });
290
- this.chain.emitter.emit(routes.events.EventType.payloadAttributes, {data, version: fork});
291
- }
292
292
  } else {
293
293
  // Pre-bellatrix only reaches here at an epoch transition to precompute the next epoch state
294
294
  const preparedState = await this.chain.regen.getBlockSlotState(
@@ -528,23 +528,18 @@ export async function produceBlockBody<T extends BlockType>(
528
528
  }
529
529
  }
530
530
 
531
- if (ForkSeq[fork] >= ForkSeq.deneb) {
532
- const {blobKzgCommitments} = builderRes;
533
- if (blobKzgCommitments === undefined) {
534
- throw Error(`Invalid builder getHeader response for fork=${fork}, missing blobKzgCommitments`);
535
- }
536
-
537
- (blockBody as deneb.BlindedBeaconBlockBody).blobKzgCommitments = blobKzgCommitments;
538
- Object.assign(logMeta, {blobs: blobKzgCommitments.length});
531
+ const {blobKzgCommitments, executionRequests} = builderRes;
532
+ if (blobKzgCommitments === undefined) {
533
+ throw Error(`Invalid builder getHeader response for fork=${fork}, missing blobKzgCommitments`);
539
534
  }
540
535
 
541
- if (ForkSeq[fork] >= ForkSeq.electra) {
542
- const {executionRequests} = builderRes;
543
- if (executionRequests === undefined) {
544
- throw Error(`Invalid builder getHeader response for fork=${fork}, missing executionRequests`);
545
- }
546
- (blockBody as electra.BlindedBeaconBlockBody).executionRequests = executionRequests;
536
+ (blockBody as BlindedBeaconBlockBody<ForkName.fulu>).blobKzgCommitments = blobKzgCommitments;
537
+ Object.assign(logMeta, {blobs: blobKzgCommitments.length});
538
+
539
+ if (executionRequests === undefined) {
540
+ throw Error(`Invalid builder getHeader response for fork=${fork}, missing executionRequests`);
547
541
  }
542
+ (blockBody as BlindedBeaconBlockBody<ForkName.fulu>).executionRequests = executionRequests;
548
543
  }
549
544
 
550
545
  // blockType === BlockType.Full
@@ -899,45 +894,38 @@ function preparePayloadAttributes(
899
894
  ): SSEPayloadAttributes["payloadAttributes"] {
900
895
  const timestamp = computeTimeAtSlot(chain.config, prepareSlot, prepareState.genesisTime);
901
896
  const prevRandao = prepareState.getRandaoMix(prepareState.epoch);
902
- const payloadAttributes = {
903
- timestamp,
904
- prevRandao,
905
- suggestedFeeRecipient: feeRecipient,
906
- };
907
-
908
- if (ForkSeq[fork] >= ForkSeq.capella) {
909
- if (!isStatePostCapella(prepareState)) {
910
- throw new Error("Expected Capella state for withdrawals");
911
- }
897
+ if (!isStatePostCapella(prepareState)) {
898
+ throw new Error("Expected Capella state for withdrawals");
899
+ }
912
900
 
913
- if (isStatePostGloas(prepareState)) {
914
- const isExtendingPayload = byteArrayEquals(parentBlockHash, prepareState.latestExecutionPayloadBid.blockHash);
915
- if (isExtendingPayload) {
916
- // applyParentExecutionPayload sets latestBlockHash = parentBid.blockHash, so a mismatch
917
- // here means the caller did not apply parent payload to prepareState
918
- if (!byteArrayEquals(prepareState.latestBlockHash, prepareState.latestExecutionPayloadBid.blockHash)) {
919
- throw new Error("Expected state with parent execution payload applied for withdrawals");
920
- }
921
- (payloadAttributes as capella.SSEPayloadAttributes["payloadAttributes"]).withdrawals =
922
- prepareState.getExpectedWithdrawals().expectedWithdrawals;
923
- } else {
924
- // When the parent block is empty, state.payloadExpectedWithdrawals holds a batch
925
- // already deducted from CL balances but never credited on the EL (the envelope
926
- // was not delivered). The next payload must carry those same withdrawals to
927
- // restore CL/EL consistency, otherwise validators permanently lose that balance.
928
- (payloadAttributes as capella.SSEPayloadAttributes["payloadAttributes"]).withdrawals =
929
- prepareState.payloadExpectedWithdrawals;
901
+ let withdrawals: capella.Withdrawal[];
902
+ if (isStatePostGloas(prepareState)) {
903
+ const isExtendingPayload = byteArrayEquals(parentBlockHash, prepareState.latestExecutionPayloadBid.blockHash);
904
+ if (isExtendingPayload) {
905
+ // applyParentExecutionPayload sets latestBlockHash = parentBid.blockHash, so a mismatch
906
+ // here means the caller did not apply parent payload to prepareState
907
+ if (!byteArrayEquals(prepareState.latestBlockHash, prepareState.latestExecutionPayloadBid.blockHash)) {
908
+ throw new Error("Expected state with parent execution payload applied for withdrawals");
930
909
  }
910
+ withdrawals = prepareState.getExpectedWithdrawals().expectedWithdrawals;
931
911
  } else {
932
- // withdrawals logic is now fork aware as it changes on electra fork post capella
933
- (payloadAttributes as capella.SSEPayloadAttributes["payloadAttributes"]).withdrawals =
934
- prepareState.getExpectedWithdrawals().expectedWithdrawals;
912
+ // When the parent block is empty, state.payloadExpectedWithdrawals holds a batch
913
+ // already deducted from CL balances but never credited on the EL (the envelope
914
+ // was not delivered). The next payload must carry those same withdrawals to
915
+ // restore CL/EL consistency, otherwise validators permanently lose that balance.
916
+ withdrawals = prepareState.payloadExpectedWithdrawals;
935
917
  }
918
+ } else {
919
+ withdrawals = prepareState.getExpectedWithdrawals().expectedWithdrawals;
936
920
  }
937
921
 
938
- if (ForkSeq[fork] >= ForkSeq.deneb) {
939
- (payloadAttributes as deneb.SSEPayloadAttributes["payloadAttributes"]).parentBeaconBlockRoot = parentBlockRoot;
940
- }
922
+ const payloadAttributes: deneb.SSEPayloadAttributes["payloadAttributes"] = {
923
+ timestamp,
924
+ prevRandao,
925
+ suggestedFeeRecipient: feeRecipient,
926
+ withdrawals,
927
+ parentBeaconBlockRoot: parentBlockRoot,
928
+ };
941
929
 
942
930
  if (ForkSeq[fork] >= ForkSeq.gloas) {
943
931
  if (!isStatePostGloas(prepareState)) {
@@ -1050,37 +1038,28 @@ export async function produceCommonBlockBody<T extends BlockType>(
1050
1038
  step: BlockProductionStep.attestations,
1051
1039
  });
1052
1040
 
1053
- const blockBody: Omit<CommonBlockBody, "blsToExecutionChanges" | "syncAggregate"> = {
1041
+ const endSyncAggregate = stepsMetrics?.startTimer();
1042
+ const parentBlockRoot = fromHex(parentBlock.blockRoot);
1043
+ const previousSlot = slot - 1;
1044
+ const syncAggregate = this.syncContributionAndProofPool.getAggregate(previousSlot, parentBlockRoot);
1045
+ this.metrics?.production.producedSyncAggregateParticipants.observe(
1046
+ syncAggregate.syncCommitteeBits.getTrueBitIndexes().length
1047
+ );
1048
+ endSyncAggregate?.({
1049
+ step: BlockProductionStep.syncAggregate,
1050
+ });
1051
+
1052
+ // Live proposal production is supported from Fulu onward.
1053
+ return {
1054
1054
  randaoReveal,
1055
1055
  graffiti,
1056
- // Eth1 data voting is no longer required since electra
1057
1056
  eth1Data: currentState.eth1Data,
1058
1057
  proposerSlashings: this.opts.disableProposerSlashings === true ? [] : proposerSlashings,
1059
1058
  attesterSlashings,
1060
1059
  attestations,
1061
- // Since electra, deposits are processed by the execution layer,
1062
- // we no longer support handling deposits from earlier forks.
1063
1060
  deposits: [],
1064
1061
  voluntaryExits,
1062
+ blsToExecutionChanges,
1063
+ syncAggregate,
1065
1064
  };
1066
-
1067
- if (ForkSeq[fork] >= ForkSeq.capella) {
1068
- (blockBody as CommonBlockBody).blsToExecutionChanges = blsToExecutionChanges;
1069
- }
1070
-
1071
- const endSyncAggregate = stepsMetrics?.startTimer();
1072
- if (ForkSeq[fork] >= ForkSeq.altair) {
1073
- const parentBlockRoot = fromHex(parentBlock.blockRoot);
1074
- const previousSlot = slot - 1;
1075
- const syncAggregate = this.syncContributionAndProofPool.getAggregate(previousSlot, parentBlockRoot);
1076
- this.metrics?.production.producedSyncAggregateParticipants.observe(
1077
- syncAggregate.syncCommitteeBits.getTrueBitIndexes().length
1078
- );
1079
- (blockBody as CommonBlockBody).syncAggregate = syncAggregate;
1080
- }
1081
- endSyncAggregate?.({
1082
- step: BlockProductionStep.syncAggregate,
1083
- });
1084
-
1085
- return blockBody as CommonBlockBody;
1086
1065
  }
@@ -1,22 +1,6 @@
1
1
  import {ChainForkConfig} from "@lodestar/config";
2
2
  import {ExecutionStatus} from "@lodestar/fork-choice";
3
- import {
4
- ForkName,
5
- MAX_ATTESTATIONS_ELECTRA,
6
- MAX_ATTESTER_SLASHINGS_ELECTRA,
7
- MAX_BLS_TO_EXECUTION_CHANGES,
8
- MAX_BUILDER_DEPOSIT_REQUESTS_PER_PAYLOAD,
9
- MAX_BUILDER_EXIT_REQUESTS_PER_PAYLOAD,
10
- MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD,
11
- MAX_PAYLOAD_ATTESTATIONS,
12
- MAX_PROPOSER_SLASHINGS,
13
- MAX_VOLUNTARY_EXITS,
14
- MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD,
15
- MIN_SEED_LOOKAHEAD,
16
- isForkPostBellatrix,
17
- isForkPostDeneb,
18
- isForkPostGloas,
19
- } from "@lodestar/params";
3
+ import {ForkName, MIN_SEED_LOOKAHEAD, isForkPostBellatrix, isForkPostDeneb, isForkPostGloas} from "@lodestar/params";
20
4
  import {
21
5
  computeEpochAtSlot,
22
6
  computeStartSlotAtEpoch,
@@ -173,7 +157,8 @@ export async function validateGossipBlock(
173
157
  }
174
158
 
175
159
  if (isForkPostGloas(fork)) {
176
- const bid = (block as gloas.BeaconBlock).body.signedExecutionPayloadBid.message;
160
+ const body = (block as gloas.BeaconBlock).body;
161
+ const bid = body.signedExecutionPayloadBid.message;
177
162
 
178
163
  // [REJECT] The length of KZG commitments is less than or equal to the limitation defined in Consensus Layer
179
164
  // -- i.e. validate that len(bid.blob_kzg_commitments) <= max_blobs_per_block
@@ -196,54 +181,12 @@ export async function validateGossipBlock(
196
181
  });
197
182
  }
198
183
 
199
- // [REJECT] The counts of `block.body.parent_execution_requests` are within
200
- // their respective limits -- i.e. validate that
201
- // `len(block.body.parent_execution_requests.withdrawals) <= MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD`,
202
- // `len(block.body.parent_execution_requests.consolidations) <= MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD`,
203
- // `len(block.body.parent_execution_requests.builder_deposits) <= MAX_BUILDER_DEPOSIT_REQUESTS_PER_PAYLOAD`,
204
- // and
205
- // `len(block.body.parent_execution_requests.builder_exits) <= MAX_BUILDER_EXIT_REQUESTS_PER_PAYLOAD`.
206
- // [REJECT] The counts of the block body operations are within their respective
207
- // limits -- i.e. validate that
208
- // `len(block.body.proposer_slashings) <= MAX_PROPOSER_SLASHINGS`,
209
- // `len(block.body.attester_slashings) <= MAX_ATTESTER_SLASHINGS_ELECTRA`,
210
- // `len(block.body.attestations) <= MAX_ATTESTATIONS_ELECTRA`,
211
- // `len(block.body.deposits) == 0`,
212
- // `len(block.body.voluntary_exits) <= MAX_VOLUNTARY_EXITS`,
213
- // `len(block.body.bls_to_execution_changes) <= MAX_BLS_TO_EXECUTION_CHANGES`,
214
- // and `len(block.body.payload_attestations) <= MAX_PAYLOAD_ATTESTATIONS`.
215
- const body = (block as gloas.BeaconBlock).body;
216
- const requests = body.parentExecutionRequests;
217
- const countLimits: [string, number, number][] = [
218
- ["parentExecutionRequests.withdrawals", requests.withdrawals.length, MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD],
219
- [
220
- "parentExecutionRequests.consolidations",
221
- requests.consolidations.length,
222
- MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD,
223
- ],
224
- [
225
- "parentExecutionRequests.builderDeposits",
226
- requests.builderDeposits.length,
227
- MAX_BUILDER_DEPOSIT_REQUESTS_PER_PAYLOAD,
228
- ],
229
- ["parentExecutionRequests.builderExits", requests.builderExits.length, MAX_BUILDER_EXIT_REQUESTS_PER_PAYLOAD],
230
- ["proposerSlashings", body.proposerSlashings.length, MAX_PROPOSER_SLASHINGS],
231
- ["attesterSlashings", body.attesterSlashings.length, MAX_ATTESTER_SLASHINGS_ELECTRA],
232
- ["attestations", body.attestations.length, MAX_ATTESTATIONS_ELECTRA],
233
- ["deposits", body.deposits.length, 0],
234
- ["voluntaryExits", body.voluntaryExits.length, MAX_VOLUNTARY_EXITS],
235
- ["blsToExecutionChanges", body.blsToExecutionChanges.length, MAX_BLS_TO_EXECUTION_CHANGES],
236
- ["payloadAttestations", body.payloadAttestations.length, MAX_PAYLOAD_ATTESTATIONS],
237
- ];
238
- for (const [name, count, limit] of countLimits) {
239
- if (count > limit) {
240
- throw new BlockGossipError(GossipAction.REJECT, {
241
- code: BlockErrorCode.TOO_MANY_BLOCK_OPERATIONS,
242
- name,
243
- count,
244
- limit,
245
- });
246
- }
184
+ // [REJECT] The block contains no deposits.
185
+ if (body.deposits.length !== 0) {
186
+ throw new BlockGossipError(GossipAction.REJECT, {
187
+ code: BlockErrorCode.NON_ZERO_DEPOSITS,
188
+ count: body.deposits.length,
189
+ });
247
190
  }
248
191
 
249
192
  // TODO GLOAS: [REJECT] The block's execution payload parent (defined by bid.parent_block_hash) passes all validation
@@ -1,11 +1,4 @@
1
1
  import {PayloadStatus} from "@lodestar/fork-choice";
2
- import {
3
- MAX_BUILDER_DEPOSIT_REQUESTS_PER_PAYLOAD,
4
- MAX_BUILDER_EXIT_REQUESTS_PER_PAYLOAD,
5
- MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD,
6
- MAX_WITHDRAWALS_PER_PAYLOAD,
7
- MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD,
8
- } from "@lodestar/params";
9
2
  import {
10
3
  computeStartSlotAtEpoch,
11
4
  getExecutionPayloadEnvelopeSignatureSet,
@@ -122,36 +115,6 @@ async function validateExecutionPayloadEnvelope(
122
115
  });
123
116
  }
124
117
 
125
- // [REJECT] The counts of `execution_requests` are within their respective limits.
126
- // New in Gloas:EIP7688 — progressive lists are unbounded at the type level, so bounds
127
- // are enforced here in gossip validation.
128
- const {executionRequests} = envelope;
129
- const requestCountLimits: [string, number, number][] = [
130
- ["withdrawals", executionRequests.withdrawals.length, MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD],
131
- ["consolidations", executionRequests.consolidations.length, MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD],
132
- ["builderDeposits", executionRequests.builderDeposits.length, MAX_BUILDER_DEPOSIT_REQUESTS_PER_PAYLOAD],
133
- ["builderExits", executionRequests.builderExits.length, MAX_BUILDER_EXIT_REQUESTS_PER_PAYLOAD],
134
- ];
135
- for (const [name, count, limit] of requestCountLimits) {
136
- if (count > limit) {
137
- throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
138
- code: ExecutionPayloadEnvelopeErrorCode.EXECUTION_REQUESTS_COUNT_EXCEEDED,
139
- name,
140
- count,
141
- limit,
142
- });
143
- }
144
- }
145
-
146
- // [REJECT] The number of withdrawals is within the limit.
147
- if (payload.withdrawals.length > MAX_WITHDRAWALS_PER_PAYLOAD) {
148
- throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
149
- code: ExecutionPayloadEnvelopeErrorCode.WITHDRAWALS_COUNT_EXCEEDED,
150
- count: payload.withdrawals.length,
151
- limit: MAX_WITHDRAWALS_PER_PAYLOAD,
152
- });
153
- }
154
-
155
118
  // Get the block state to verify the builder's signature.
156
119
  const blockState = await chain.regen
157
120
  .getState(block.stateRoot, RegenCaller.validateGossipPayloadEnvelope)