@lodestar/beacon-node 1.51.0-dev.44a2c43710 → 1.51.0-dev.4671dbfa39

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 (70) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +17 -27
  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 +5 -2
  6. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  7. package/lib/chain/GetBlobsTracker.d.ts.map +1 -1
  8. package/lib/chain/GetBlobsTracker.js +4 -2
  9. package/lib/chain/GetBlobsTracker.js.map +1 -1
  10. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  11. package/lib/chain/archiveStore/archiveStore.js +1 -0
  12. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  13. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  14. package/lib/chain/blocks/importExecutionPayload.js +5 -1
  15. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  16. package/lib/chain/blocks/payloadEnvelopeProcessor.js +2 -2
  17. package/lib/chain/blocks/payloadEnvelopeProcessor.js.map +1 -1
  18. package/lib/chain/bls/multithread/index.js +5 -5
  19. package/lib/chain/bls/multithread/index.js.map +1 -1
  20. package/lib/chain/interface.d.ts +1 -2
  21. package/lib/chain/interface.d.ts.map +1 -1
  22. package/lib/chain/interface.js.map +1 -1
  23. package/lib/chain/options.d.ts +0 -1
  24. package/lib/chain/options.d.ts.map +1 -1
  25. package/lib/chain/options.js +0 -1
  26. package/lib/chain/options.js.map +1 -1
  27. package/lib/execution/engine/index.d.ts +1 -1
  28. package/lib/execution/engine/index.d.ts.map +1 -1
  29. package/lib/execution/engine/index.js +1 -1
  30. package/lib/execution/engine/index.js.map +1 -1
  31. package/lib/execution/engine/interface.d.ts +1 -1
  32. package/lib/execution/engine/interface.d.ts.map +1 -1
  33. package/lib/execution/engine/interface.js.map +1 -1
  34. package/lib/monitoring/service.js +1 -1
  35. package/lib/monitoring/service.js.map +1 -1
  36. package/lib/network/network.d.ts.map +1 -1
  37. package/lib/network/network.js +3 -1
  38. package/lib/network/network.js.map +1 -1
  39. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  40. package/lib/network/processor/gossipHandlers.js +0 -2
  41. package/lib/network/processor/gossipHandlers.js.map +1 -1
  42. package/lib/node/options.d.ts +1 -1
  43. package/lib/node/options.d.ts.map +1 -1
  44. package/lib/node/options.js +1 -1
  45. package/lib/node/options.js.map +1 -1
  46. package/lib/sync/interface.d.ts.map +1 -1
  47. package/lib/sync/interface.js.map +1 -1
  48. package/lib/util/queue/itemQueue.js +1 -1
  49. package/lib/util/queue/itemQueue.js.map +1 -1
  50. package/lib/util/sszBytes.js +2 -2
  51. package/lib/util/sszBytes.js.map +1 -1
  52. package/package.json +15 -15
  53. package/src/api/impl/beacon/blocks/index.ts +35 -45
  54. package/src/api/impl/beacon/pool/index.ts +5 -1
  55. package/src/chain/GetBlobsTracker.ts +4 -2
  56. package/src/chain/archiveStore/archiveStore.ts +1 -0
  57. package/src/chain/blocks/importExecutionPayload.ts +7 -1
  58. package/src/chain/blocks/payloadEnvelopeProcessor.ts +2 -2
  59. package/src/chain/bls/multithread/index.ts +5 -5
  60. package/src/chain/interface.ts +1 -2
  61. package/src/chain/options.ts +0 -2
  62. package/src/execution/engine/index.ts +1 -1
  63. package/src/execution/engine/interface.ts +1 -1
  64. package/src/monitoring/service.ts +1 -1
  65. package/src/network/network.ts +3 -1
  66. package/src/network/processor/gossipHandlers.ts +0 -2
  67. package/src/node/options.ts +4 -5
  68. package/src/sync/interface.ts +1 -0
  69. package/src/util/queue/itemQueue.ts +1 -1
  70. package/src/util/sszBytes.ts +2 -2
@@ -316,18 +316,8 @@ export function getBeaconBlockApi(
316
316
  break;
317
317
  }
318
318
 
319
- case routes.beacon.BroadcastValidation.none: {
320
- chain.logger.debug("Skipping broadcast validation", valLogMeta);
321
- break;
322
- }
323
-
324
319
  default: {
325
- // error or log warning we do not support this validation
326
- const message = `Broadcast validation of ${broadcastValidation} type not implemented yet`;
327
- if (chain.opts.broadcastValidationStrictness === "error") {
328
- throw Error(message);
329
- }
330
- chain.logger.warn(message, valLogMeta);
320
+ throw new ApiError(400, `Invalid broadcast validation level ${broadcastValidation}`);
331
321
  }
332
322
  }
333
323
 
@@ -397,26 +387,24 @@ export function getBeaconBlockApi(
397
387
  ...blobSidecars.map((blobSidecar) => () => network.publishBlobSidecar(blobSidecar)),
398
388
  () =>
399
389
  // there is no rush to persist block since we published it to gossip anyway
400
- chain
401
- .processBlock(blockForImport, opts)
402
- .catch((e) => {
403
- if (e instanceof BlockError) {
404
- switch (e.type.code) {
405
- case BlockErrorCode.ALREADY_KNOWN:
406
- // Block was imported while publishing, e.g. received via gossip
407
- chain.logger.debug("Ignoring already-known block during publishing", valLogMeta);
408
- return;
409
- case BlockErrorCode.PARENT_BLOCK_UNKNOWN:
410
- case BlockErrorCode.PARENT_PAYLOAD_UNKNOWN:
411
- chain.emitter.emit(ChainEvent.blockUnknownParent, {
412
- blockInput: blockForImport,
413
- peer: IDENTITY_PEER_ID,
414
- source: BlockInputSource.api,
415
- });
416
- }
390
+ chain.processBlock(blockForImport, opts).catch((e) => {
391
+ if (e instanceof BlockError) {
392
+ switch (e.type.code) {
393
+ case BlockErrorCode.ALREADY_KNOWN:
394
+ // Block was imported while publishing, e.g. received via gossip
395
+ chain.logger.debug("Ignoring already-known block during publishing", valLogMeta);
396
+ return;
397
+ case BlockErrorCode.PARENT_BLOCK_UNKNOWN:
398
+ case BlockErrorCode.PARENT_PAYLOAD_UNKNOWN:
399
+ chain.emitter.emit(ChainEvent.blockUnknownParent, {
400
+ blockInput: blockForImport,
401
+ peer: IDENTITY_PEER_ID,
402
+ source: BlockInputSource.api,
403
+ });
417
404
  }
418
- throw e;
419
- }),
405
+ }
406
+ throw e;
407
+ }),
420
408
  ];
421
409
  const sentPeersArr = await promiseAllMaybeAsync<{sentPeers: number; alreadyPublished: boolean} | number | void>(
422
410
  publishPromises
@@ -804,11 +792,6 @@ export function getBeaconBlockApi(
804
792
  };
805
793
  try {
806
794
  switch (broadcastValidation) {
807
- case routes.beacon.BroadcastValidation.none: {
808
- chain.logger.debug("Skipping broadcast validation of execution payload envelope", valLogMeta);
809
- break;
810
- }
811
-
812
795
  case routes.beacon.BroadcastValidation.gossip: {
813
796
  await validateApiExecutionPayloadEnvelope(chain, signedExecutionPayloadEnvelope);
814
797
  break;
@@ -847,11 +830,7 @@ export function getBeaconBlockApi(
847
830
  }
848
831
 
849
832
  default: {
850
- const message = `Broadcast validation of ${broadcastValidation} type not implemented yet`;
851
- if (chain.opts.broadcastValidationStrictness === "error") {
852
- throw Error(message);
853
- }
854
- chain.logger.warn(message, valLogMeta);
833
+ throw new ApiError(400, `Invalid broadcast validation level ${broadcastValidation}`);
855
834
  }
856
835
  }
857
836
  } catch (error) {
@@ -1003,9 +982,13 @@ export function getBeaconBlockApi(
1003
982
  () => network.publishSignedExecutionPayloadEnvelope(signedExecutionPayloadEnvelope),
1004
983
  // Publish all data column sidecars
1005
984
  ...dataColumnSidecars.map((dataColumnSidecar) => () => network.publishDataColumnSidecar(dataColumnSidecar)),
1006
- // Import execution payload. Signature is verified during broadcast validation, an already
1007
- // known envelope was verified by its original source and `none` deliberately skips validation
1008
- () => chain.processExecutionPayload(payloadInput, {validSignature: true}),
985
+ // Import execution payload
986
+ () =>
987
+ chain.processExecutionPayload(payloadInput, {
988
+ // Signature is verified during broadcast validation only for the submitted envelope,
989
+ // an envelope cached by another source is verified at import
990
+ validSignature: payloadInput.getPayloadEnvelope() === signedExecutionPayloadEnvelope,
991
+ }),
1009
992
  ];
1010
993
 
1011
994
  const publishPromise = promiseAllMaybeAsync<{sentPeers: number; alreadyPublished: boolean} | number | void>(
@@ -1109,7 +1092,7 @@ export function getBeaconBlockApi(
1109
1092
  },
1110
1093
 
1111
1094
  async getSignedExecutionPayloadEnvelope({blockId}, context) {
1112
- const {block, executionOptimistic, finalized} = await getBlockResponse(chain, blockId);
1095
+ const {block, finalized} = await getBlockResponse(chain, blockId);
1113
1096
  const slot = block.message.slot;
1114
1097
  const fork = config.getForkName(slot);
1115
1098
 
@@ -1123,6 +1106,13 @@ export function getBeaconBlockApi(
1123
1106
  const blockRoot = config.getForkTypes(slot).BeaconBlock.hashTreeRoot(block.message);
1124
1107
  const blockRootHex = toRootHex(blockRoot);
1125
1108
 
1109
+ // The block's own flag is the status of the payload it builds on, the envelope's is that of its
1110
+ // FULL variant. An unfinalized block without one has not imported its envelope yet.
1111
+ const payload = finalized ? null : chain.forkChoice.getBlockHex(blockRootHex, PayloadStatus.FULL);
1112
+ if (!finalized && payload === null) {
1113
+ throw new ApiError(404, `Execution payload envelope not found for slot=${slot}, blockRoot=${blockRootHex}`);
1114
+ }
1115
+
1126
1116
  let data: Uint8Array | gloas.SignedExecutionPayloadEnvelope | null;
1127
1117
  try {
1128
1118
  data = context?.returnBytes
@@ -1147,7 +1137,7 @@ export function getBeaconBlockApi(
1147
1137
 
1148
1138
  return {
1149
1139
  data,
1150
- meta: {executionOptimistic, finalized, version: fork},
1140
+ meta: {executionOptimistic: payload !== null && isOptimisticBlock(payload), finalized, version: fork},
1151
1141
  };
1152
1142
  },
1153
1143
 
@@ -17,6 +17,7 @@ import {
17
17
  PayloadAttestationError,
18
18
  PayloadAttestationErrorCode,
19
19
  SyncCommitteeError,
20
+ SyncCommitteeErrorCode,
20
21
  } from "../../../../chain/errors/index.js";
21
22
  import {validateApiAttesterSlashing} from "../../../../chain/validation/attesterSlashing.js";
22
23
  import {validateApiBlsToExecutionChange} from "../../../../chain/validation/blsToExecutionChange.js";
@@ -340,7 +341,10 @@ export function getBeaconPoolApi({
340
341
  const synCommittee = state.getIndexedSyncCommittee(signature.slot);
341
342
  const indexesInCommittee = synCommittee.validatorIndexMap.get(signature.validatorIndex);
342
343
  if (indexesInCommittee === undefined || indexesInCommittee.length === 0) {
343
- return; // Not a sync committee member
344
+ throw new SyncCommitteeError(GossipAction.REJECT, {
345
+ code: SyncCommitteeErrorCode.VALIDATOR_NOT_IN_SYNC_COMMITTEE,
346
+ validatorIndex: signature.validatorIndex,
347
+ });
344
348
  }
345
349
 
346
350
  // Verify signature only, all other data is very likely to be correct, since the `signature` object is created by this node.
@@ -158,8 +158,10 @@ export class GetBlobsTracker {
158
158
 
159
159
  private retryPendingTrigger(input: IBlockInput | PayloadEnvelopeInput, requestFailed: boolean): void {
160
160
  // Triggers dropped while the request was in flight re-enter once it failed, the attempt that was just
161
- // recorded makes this arm the trailing retry instead of sending another request right away
162
- if (this.pendingTriggers.delete(input.blockRootHex) && requestFailed) {
161
+ // recorded makes this arm the trailing retry instead of sending another request right away.
162
+ // Post-gloas only the bid triggers a request, so every failed attempt re-enters to arm its own retry
163
+ const hadPendingTrigger = this.pendingTriggers.delete(input.blockRootHex);
164
+ if (requestFailed && (hadPendingTrigger || input instanceof PayloadEnvelopeInput)) {
163
165
  this.triggerGetBlobs(input);
164
166
  }
165
167
  }
@@ -197,6 +197,7 @@ export class ArchiveStore {
197
197
  //
198
198
  // `jobQueue.push()` can throw synchronously (queue aborted / full) or reject asynchronously;
199
199
  // awaiting it inside the deferred callback funnels both failure modes into the one catch.
200
+ // biome-ignore lint/nursery/noMisusedPromises: the callback catches all errors itself
200
201
  callInNextEventLoop(async () => {
201
202
  try {
202
203
  await this.jobQueue.push(finalized);
@@ -333,7 +333,13 @@ export async function importExecutionPayload(
333
333
 
334
334
  // 7. Queue notifyForkchoiceUpdate to engine api
335
335
  const head = this.forkChoice.getHead();
336
- if (!this.opts.disableImportExecutionFcU && blockRootHex === head.blockRoot) {
336
+ if (
337
+ !this.opts.disableImportExecutionFcU &&
338
+ blockRootHex === head.blockRoot &&
339
+ // Skip a payload that does not satisfy the inclusion list constraints, fork choice keeps the EMPTY
340
+ // variant as head and the next prepare fcU keeps the engine on the parent payload
341
+ this.forkChoice.isPayloadInclusionListSatisfied(blockRootHex)
342
+ ) {
337
343
  const safeBlockHash = getSafeExecutionBlockHash(this.forkChoice, this.logger);
338
344
  const finalizedBlockHash = getFinalizedExecutionBlockHash(this.forkChoice);
339
345
  this.executionEngine.notifyForkchoiceUpdate(fork, blockHashHex, safeBlockHash, finalizedBlockHash).catch((e) => {
@@ -35,7 +35,7 @@ export class PayloadEnvelopeProcessor {
35
35
 
36
36
  async processPayloadEnvelopeJob(payloadInput: PayloadEnvelopeInput, opts: ImportPayloadOpts = {}): Promise<void> {
37
37
  const existing = this.imports.get(payloadInput);
38
- if (existing) {
38
+ if (existing !== undefined) {
39
39
  return existing;
40
40
  }
41
41
 
@@ -43,7 +43,7 @@ export class PayloadEnvelopeProcessor {
43
43
 
44
44
  // Re-check after await, as another call may have queued this payload.
45
45
  const queued = this.imports.get(payloadInput);
46
- if (queued) {
46
+ if (queued !== undefined) {
47
47
  return queued;
48
48
  }
49
49
 
@@ -342,7 +342,7 @@ export class BlsMultiThreadWorkerPool implements IBlsVerifier {
342
342
  } else {
343
343
  this.jobs.push(job);
344
344
  }
345
- callInNextEventLoop(this.runJob);
345
+ callInNextEventLoop(() => void this.runJob());
346
346
  }
347
347
  }
348
348
 
@@ -377,7 +377,7 @@ export class BlsMultiThreadWorkerPool implements IBlsVerifier {
377
377
  let completedJobsCount = 0;
378
378
 
379
379
  if (this.jobs.length > 0) {
380
- callInNextEventLoop(this.runJob);
380
+ callInNextEventLoop(() => void this.runJob());
381
381
  }
382
382
 
383
383
  try {
@@ -423,7 +423,7 @@ export class BlsMultiThreadWorkerPool implements IBlsVerifier {
423
423
  if (workReqs.length === 0) {
424
424
  worker.status = {code: WorkerStatusCode.idle, workerApi};
425
425
  this.workersBusy--;
426
- callInNextEventLoop(this.runJob);
426
+ callInNextEventLoop(() => void this.runJob());
427
427
  return;
428
428
  }
429
429
 
@@ -499,7 +499,7 @@ export class BlsMultiThreadWorkerPool implements IBlsVerifier {
499
499
  this.workersBusy--;
500
500
 
501
501
  // Potentially run a new job
502
- callInNextEventLoop(this.runJob);
502
+ callInNextEventLoop(() => void this.runJob());
503
503
  };
504
504
 
505
505
  /**
@@ -542,7 +542,7 @@ export class BlsMultiThreadWorkerPool implements IBlsVerifier {
542
542
  this.jobs.unshift(job);
543
543
  }
544
544
  this.bufferedJobs = null;
545
- callInNextEventLoop(this.runJob);
545
+ callInNextEventLoop(() => void this.runJob());
546
546
  }
547
547
  };
548
548
 
@@ -77,8 +77,7 @@ import {PayloadEnvelopeInput, SeenPayloadEnvelopeInput} from "./seenCache/seenPa
77
77
  import {ShufflingCache} from "./shufflingCache.js";
78
78
  import {ValidatorMonitor} from "./validatorMonitor.js";
79
79
 
80
- export {BlockType, type AssembledBlockType};
81
- export {type ProposerPreparationData};
80
+ export {type AssembledBlockType, BlockType, type ProposerPreparationData};
82
81
  export type BlockHash = RootHex;
83
82
 
84
83
  export type StateGetOpts = {
@@ -48,7 +48,6 @@ export type IChainOptions = BlockProcessOpts &
48
48
  /** Max number of produced block roots (blinded or full) cached for broadcast validations */
49
49
  maxCachedProducedRoots?: number;
50
50
  initialCustodyGroupCount?: number;
51
- broadcastValidationStrictness?: string;
52
51
  minSameMessageSignatureSetsToBatch: number;
53
52
  archiveDateEpochs?: number;
54
53
  nHistoricalStatesFileDataStore?: boolean;
@@ -121,7 +120,6 @@ export const defaultChainOptions: IChainOptions = {
121
120
  // for attestation validation, having this value ensures we don't have to regen states most of the time
122
121
  maxSkipSlots: 32,
123
122
  disableProposerSlashings: false,
124
- broadcastValidationStrictness: "warn",
125
123
  // should be less than or equal to MIN_SIGNATURE_SETS_TO_BATCH_VERIFY
126
124
  // batching too much may block the I/O thread so if useWorker=false, suggest this value to be 32
127
125
  // since this batch attestation work is designed to work with useWorker=true, make this the lowest value
@@ -17,8 +17,8 @@ import {EngineRestHttpClient} from "./restHttpClient.js";
17
17
  import {RestEngineTransport, formatClientVersionHeader} from "./restTransport.js";
18
18
  import {ExecutionEngineMockJsonRpcClient, JsonRpcBackend} from "./utils.js";
19
19
 
20
- export {ExecutionEngineHttp, ExecutionEngineDisabled, defaultExecutionEngineHttpOpts, engineApiModes};
21
20
  export type {EngineApiMode};
21
+ export {ExecutionEngineDisabled, ExecutionEngineHttp, defaultExecutionEngineHttpOpts, engineApiModes};
22
22
 
23
23
  export type ExecutionEngineOpts =
24
24
  | ({mode?: "http"} & ExecutionEngineHttpOpts)
@@ -25,7 +25,7 @@ import {PayloadId, PayloadIdCache, WithdrawalV1} from "./payloadIdCache.js";
25
25
  import {ExecutionPayloadBodyV2} from "./types.js";
26
26
  import {DATA} from "./utils.js";
27
27
 
28
- export {PayloadIdCache, type PayloadId, type WithdrawalV1};
28
+ export {type PayloadId, PayloadIdCache, type WithdrawalV1};
29
29
  export type ClientVersion = routes.node.ClientVersion;
30
30
  export const ClientCode = routes.node.ClientCode;
31
31
 
@@ -101,7 +101,7 @@ export class MonitoringService {
101
101
  if (this.monitoringInterval) {
102
102
  clearTimeout(this.monitoringInterval);
103
103
  }
104
- if (this.pendingRequest) {
104
+ if (this.pendingRequest !== undefined) {
105
105
  this.fetchAbortController?.abort(FetchAbortReason.Close);
106
106
  await this.pendingRequest;
107
107
  }
@@ -855,7 +855,9 @@ export class Network implements INetwork {
855
855
  };
856
856
 
857
857
  private onTargetGroupCountUpdated = (count: number): void => {
858
- this.core.setTargetGroupCount(count);
858
+ this.core.setTargetGroupCount(count).catch((e) => {
859
+ this.logger.debug("Error setting target custody group count", {count}, e as Error);
860
+ });
859
861
  };
860
862
 
861
863
  private onPublishDataColumns = async (sidecars: DataColumnSidecar[]): Promise<void> => {
@@ -705,8 +705,6 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
705
705
 
706
706
  // Immediately attempt fetch of data columns from execution engine as the bid contains kzg commitments
707
707
  // which is all the information we need so there is no reason to delay until execution payload arrives
708
- // TODO GLOAS: If we want EL retries after this initial attempt, add an explicit retry policy here
709
- // (for example later in the slot). Do not couple retries to incoming gossip columns.
710
708
  // Columns fetched here feed payloadInput.addColumn, which resolves waitForAllData for any
711
709
  // in-flight importExecutionPayload. No processExecutionPayload trigger needed from this path.
712
710
  chain.getBlobsTracker.triggerGetBlobs(payloadInput);
@@ -19,16 +19,15 @@ import {SyncOptions, defaultSyncOptions} from "../sync/options.js";
19
19
 
20
20
  // Re-export so the CLI doesn't need to depend on lodestar-api
21
21
  export {allNamespaces} from "../api/rest/index.js";
22
-
22
+ export type {EngineApiMode};
23
23
  // Re-export to use as default values in CLI args
24
24
  export {
25
- defaultExecutionEngineHttpOpts,
26
- defaultExecutionBuilderHttpOpts,
27
- engineApiModes,
28
25
  ArchiveMode,
29
26
  DEFAULT_ARCHIVE_MODE,
27
+ defaultExecutionBuilderHttpOpts,
28
+ defaultExecutionEngineHttpOpts,
29
+ engineApiModes,
30
30
  };
31
- export type {EngineApiMode};
32
31
 
33
32
  export interface IBeaconNodeOptions {
34
33
  api: ApiOptions;
@@ -7,6 +7,7 @@ import {IBeaconDb} from "../db/index.js";
7
7
  import {Metrics} from "../metrics/index.js";
8
8
  import {INetwork} from "../network/index.js";
9
9
  import {SyncChainDebugState} from "./range/chain.js";
10
+
10
11
  export type {SyncChainDebugState};
11
12
 
12
13
  export type SyncingStatus = routes.node.SyncingStatus;
@@ -69,7 +69,7 @@ export class JobItemQueue<Args extends any[], R> {
69
69
  if (this.jobs.length === 1 && this.opts.noYieldIfOneItem) {
70
70
  void this.runJob();
71
71
  } else if (this.runningJobs < this.opts.maxConcurrency) {
72
- callInNextEventLoop(this.runJob);
72
+ callInNextEventLoop(() => void this.runJob());
73
73
  }
74
74
  });
75
75
  }
@@ -854,7 +854,7 @@ export function getBlobKzgCommitmentsCountFromSignedBeaconBlockSerialized(
854
854
 
855
855
  const start = bidMsgStart + commitmentsRange.start;
856
856
  const end = bidMsgStart + commitmentsRange.end;
857
- return Math.round(((end > blockBytes.byteLength ? blockBytes.byteLength : end) - start) / commitmentSize);
857
+ return Math.round((Math.min(end, blockBytes.byteLength) - start) / commitmentSize);
858
858
  }
859
859
 
860
860
  const {SignedBeaconBlock, BeaconBlock, BeaconBlockBody, KZGCommitment} = ssz[forkName as ForkPostDeneb];
@@ -880,5 +880,5 @@ export function getBlobKzgCommitmentsCountFromSignedBeaconBlockSerialized(
880
880
  const end = messageRange.end + bodyRange.end + kzgCommitmentsRange.end;
881
881
  const start = messageRange.start + bodyRange.start + kzgCommitmentsRange.start;
882
882
 
883
- return Math.round(((end > blockBytes.byteLength ? blockBytes.byteLength : end) - start) / commitmentSize);
883
+ return Math.round((Math.min(end, blockBytes.byteLength) - start) / commitmentSize);
884
884
  }