@lodestar/beacon-node 1.48.0-dev.df6a2aa429 → 1.48.0-dev.e17b11435f

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 (48) hide show
  1. package/lib/chain/archiveStore/historicalState/metrics.d.ts.map +1 -1
  2. package/lib/chain/archiveStore/historicalState/metrics.js +12 -1
  3. package/lib/chain/archiveStore/historicalState/metrics.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/lib/network/gossip/encoding.d.ts.map +1 -1
  24. package/lib/network/gossip/encoding.js +0 -6
  25. package/lib/network/gossip/encoding.js.map +1 -1
  26. package/lib/network/gossip/topic.d.ts +2 -1
  27. package/lib/network/gossip/topic.d.ts.map +1 -1
  28. package/lib/network/gossip/topic.js +4 -20
  29. package/lib/network/gossip/topic.js.map +1 -1
  30. package/lib/network/processor/index.d.ts +49 -3
  31. package/lib/network/processor/index.d.ts.map +1 -1
  32. package/lib/network/processor/index.js +232 -98
  33. package/lib/network/processor/index.js.map +1 -1
  34. package/lib/network/reqresp/protocols.d.ts.map +1 -1
  35. package/lib/network/reqresp/protocols.js +6 -22
  36. package/lib/network/reqresp/protocols.js.map +1 -1
  37. package/package.json +15 -15
  38. package/src/chain/archiveStore/historicalState/metrics.ts +14 -1
  39. package/src/chain/errors/blockError.ts +3 -3
  40. package/src/chain/errors/executionPayloadEnvelope.ts +0 -9
  41. package/src/chain/prepareNextSlot.ts +16 -16
  42. package/src/chain/produceBlock/produceBlockBody.ts +50 -71
  43. package/src/chain/validation/block.ts +9 -66
  44. package/src/chain/validation/executionPayloadEnvelope.ts +0 -37
  45. package/src/network/gossip/encoding.ts +0 -6
  46. package/src/network/gossip/topic.ts +3 -25
  47. package/src/network/processor/index.ts +263 -148
  48. package/src/network/reqresp/protocols.ts +7 -24
@@ -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)
@@ -123,9 +123,6 @@ export class DataTransformSnappy implements DataTransform {
123
123
  if (uncompressedDataLength > maxSize) {
124
124
  throw Error(`ssz_snappy decoded data length ${uncompressedDataLength} > ${maxSize}`);
125
125
  }
126
- if (uncompressedDataLength > sszType.maxSize) {
127
- throw Error(`ssz_snappy decoded data length ${uncompressedDataLength} > ${sszType.maxSize}`);
128
- }
129
126
 
130
127
  // Only after sanity length checks, we can decompress the data
131
128
  // Using Buffer.alloc() instead of Buffer.allocUnsafe() to mitigate high GC pressure observed in some environments
@@ -146,9 +143,6 @@ export class DataTransformSnappy implements DataTransform {
146
143
  if (data.length > maxSize) {
147
144
  throw Error(`ssz_snappy encoded data length ${data.length} > ${maxSize}`);
148
145
  }
149
- if (data.length > sszType.maxSize) {
150
- throw Error(`ssz_snappy encoded data length ${data.length} > ${sszType.maxSize}`);
151
- }
152
146
 
153
147
  // Using Buffer.alloc() instead of Buffer.allocUnsafe() to mitigate high GC pressure observed in some environments
154
148
  const compressedData = Buffer.alloc(snappyWasm.max_compress_len(data.length));
@@ -4,17 +4,11 @@ import {
4
4
  ATTESTATION_SUBNET_COUNT,
5
5
  ForkName,
6
6
  ForkSeq,
7
- MAX_ATTESTER_SLASHING_SIZE,
8
- MAX_DATA_COLUMN_SIDECAR_SIZE,
9
- MAX_SIGNED_AGGREGATE_AND_PROOF_SIZE,
10
- MAX_SIGNED_EXECUTION_PAYLOAD_BID_SIZE,
11
- MAX_SIGNED_EXECUTION_PAYLOAD_BID_SIZE_HEZE,
12
7
  SYNC_COMMITTEE_SUBNET_COUNT,
13
8
  isForkPostAltair,
14
9
  isForkPostElectra,
15
10
  isForkPostFulu,
16
11
  isForkPostGloas,
17
- isForkPostHeze,
18
12
  } from "@lodestar/params";
19
13
  import {Attestation, SingleAttestation, ssz, sszTypesFor} from "@lodestar/types";
20
14
  import {GossipAction, GossipActionError, GossipErrorCode} from "../../chain/errors/gossipValidation.js";
@@ -139,27 +133,11 @@ export function getGossipSSZType(topic: GossipTopic) {
139
133
  }
140
134
 
141
135
  /**
142
- * Return the maximum uncompressed SSZ byte length accepted for a gossip object.
136
+ * Return the maximum uncompressed SSZ byte length accepted for a gossip object, the SSZ type max size
137
+ * or MAX_PAYLOAD_SIZE, whichever is smaller.
143
138
  */
144
139
  export function getGossipSSZMaxSize(topic: GossipTopic, maxPayloadSize: number, sszType?: CompositeTypeAny): number {
145
- const {fork} = topic.boundary;
146
- // Gloas progressive containers have broad theoretical SSZ max sizes; use the preset p2p bounds instead.
147
- switch (topic.type) {
148
- case GossipType.beacon_block:
149
- return maxPayloadSize;
150
- case GossipType.beacon_aggregate_and_proof:
151
- return isForkPostGloas(fork) ? MAX_SIGNED_AGGREGATE_AND_PROOF_SIZE : (sszType ?? getGossipSSZType(topic)).maxSize;
152
- case GossipType.attester_slashing:
153
- return isForkPostGloas(fork) ? MAX_ATTESTER_SLASHING_SIZE : (sszType ?? getGossipSSZType(topic)).maxSize;
154
- case GossipType.data_column_sidecar:
155
- return isForkPostGloas(fork) ? MAX_DATA_COLUMN_SIDECAR_SIZE : (sszType ?? getGossipSSZType(topic)).maxSize;
156
- case GossipType.execution_payload:
157
- return maxPayloadSize;
158
- case GossipType.execution_payload_bid:
159
- return isForkPostHeze(fork) ? MAX_SIGNED_EXECUTION_PAYLOAD_BID_SIZE_HEZE : MAX_SIGNED_EXECUTION_PAYLOAD_BID_SIZE;
160
- default:
161
- return (sszType ?? getGossipSSZType(topic)).maxSize;
162
- }
140
+ return Math.min((sszType ?? getGossipSSZType(topic)).maxSize, maxPayloadSize);
163
141
  }
164
142
 
165
143
  /**