@lodestar/beacon-node 1.52.0-dev.77088eb712 → 1.52.0-dev.7dd7051260

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 (88) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +63 -39
  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 +3 -1
  6. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  7. package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
  8. package/lib/api/impl/beacon/state/utils.js +2 -1
  9. package/lib/api/impl/beacon/state/utils.js.map +1 -1
  10. package/lib/api/impl/debug/index.d.ts.map +1 -1
  11. package/lib/api/impl/debug/index.js +6 -2
  12. package/lib/api/impl/debug/index.js.map +1 -1
  13. package/lib/api/impl/validator/index.d.ts.map +1 -1
  14. package/lib/api/impl/validator/index.js +6 -4
  15. package/lib/api/impl/validator/index.js.map +1 -1
  16. package/lib/chain/blocks/index.d.ts.map +1 -1
  17. package/lib/chain/blocks/index.js +3 -16
  18. package/lib/chain/blocks/index.js.map +1 -1
  19. package/lib/chain/chain.d.ts +3 -3
  20. package/lib/chain/chain.d.ts.map +1 -1
  21. package/lib/chain/chain.js +53 -24
  22. package/lib/chain/chain.js.map +1 -1
  23. package/lib/chain/errors/executionPayloadBid.d.ts +3 -2
  24. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
  25. package/lib/chain/errors/executionPayloadBid.js +1 -1
  26. package/lib/chain/errors/executionPayloadBid.js.map +1 -1
  27. package/lib/chain/interface.d.ts +1 -1
  28. package/lib/chain/interface.d.ts.map +1 -1
  29. package/lib/chain/opPools/opPool.js +6 -6
  30. package/lib/chain/opPools/opPool.js.map +1 -1
  31. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts +13 -4
  32. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts.map +1 -1
  33. package/lib/chain/seenCache/seenExecutionPayloadBids.js +13 -12
  34. package/lib/chain/seenCache/seenExecutionPayloadBids.js.map +1 -1
  35. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  36. package/lib/chain/validation/executionPayloadBid.js +30 -40
  37. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  38. package/lib/chain/validation/payloadAttestationMessage.js +9 -0
  39. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  40. package/lib/chain/validatorMonitor.js +43 -43
  41. package/lib/chain/validatorMonitor.js.map +1 -1
  42. package/lib/network/gossip/topic.d.ts +1 -7
  43. package/lib/network/gossip/topic.d.ts.map +1 -1
  44. package/lib/network/gossip/topic.js +0 -13
  45. package/lib/network/gossip/topic.js.map +1 -1
  46. package/lib/network/network.d.ts +1 -0
  47. package/lib/network/network.d.ts.map +1 -1
  48. package/lib/network/network.js +20 -11
  49. package/lib/network/network.js.map +1 -1
  50. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  51. package/lib/network/processor/gossipHandlers.js +8 -4
  52. package/lib/network/processor/gossipHandlers.js.map +1 -1
  53. package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
  54. package/lib/network/processor/gossipValidatorFn.js +4 -1
  55. package/lib/network/processor/gossipValidatorFn.js.map +1 -1
  56. package/lib/network/reqresp/utils/collect.d.ts +4 -4
  57. package/lib/network/reqresp/utils/collect.d.ts.map +1 -1
  58. package/lib/network/reqresp/utils/collect.js +9 -8
  59. package/lib/network/reqresp/utils/collect.js.map +1 -1
  60. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts +1 -1
  61. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts.map +1 -1
  62. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js +2 -2
  63. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js.map +1 -1
  64. package/lib/sync/unknownBlock.d.ts.map +1 -1
  65. package/lib/sync/unknownBlock.js +2 -1
  66. package/lib/sync/unknownBlock.js.map +1 -1
  67. package/package.json +16 -16
  68. package/src/api/impl/beacon/blocks/index.ts +74 -47
  69. package/src/api/impl/beacon/pool/index.ts +9 -7
  70. package/src/api/impl/beacon/state/utils.ts +2 -1
  71. package/src/api/impl/debug/index.ts +6 -2
  72. package/src/api/impl/validator/index.ts +6 -3
  73. package/src/chain/blocks/index.ts +3 -30
  74. package/src/chain/chain.ts +81 -40
  75. package/src/chain/errors/executionPayloadBid.ts +3 -2
  76. package/src/chain/interface.ts +1 -1
  77. package/src/chain/opPools/opPool.ts +6 -6
  78. package/src/chain/seenCache/seenExecutionPayloadBids.ts +35 -15
  79. package/src/chain/validation/executionPayloadBid.ts +40 -42
  80. package/src/chain/validation/payloadAttestationMessage.ts +10 -0
  81. package/src/chain/validatorMonitor.ts +43 -43
  82. package/src/network/gossip/topic.ts +1 -14
  83. package/src/network/network.ts +33 -11
  84. package/src/network/processor/gossipHandlers.ts +14 -10
  85. package/src/network/processor/gossipValidatorFn.ts +4 -0
  86. package/src/network/reqresp/utils/collect.ts +16 -8
  87. package/src/network/reqresp/utils/collectSequentialBlocksInRange.ts +3 -2
  88. package/src/sync/unknownBlock.ts +2 -1
@@ -1301,13 +1301,16 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
1301
1301
  }
1302
1302
  }
1303
1303
 
1304
- chain.forkChoice.notifyPtcMessages(
1305
- toRootHex(payloadAttestationMessage.data.beaconBlockRoot),
1306
- payloadAttestationMessage.data.slot,
1307
- validationResult.validatorCommitteeIndices,
1308
- payloadAttestationMessage.data.payloadPresent,
1309
- payloadAttestationMessage.data.blobDataAvailable
1310
- );
1304
+ // Gossip accepts adjacent slots within the clock disparity but fork choice only counts the current slot
1305
+ if (payloadAttestationMessage.data.slot === chain.clock.currentSlot) {
1306
+ chain.forkChoice.notifyPtcMessages(
1307
+ toRootHex(payloadAttestationMessage.data.beaconBlockRoot),
1308
+ payloadAttestationMessage.data.slot,
1309
+ validationResult.validatorCommitteeIndices,
1310
+ payloadAttestationMessage.data.payloadPresent,
1311
+ payloadAttestationMessage.data.blobDataAvailable
1312
+ );
1313
+ }
1311
1314
 
1312
1315
  chain.emitter.emit(routes.events.EventType.payloadAttestationMessage, {
1313
1316
  version: config.getForkName(payloadAttestationMessage.data.slot),
@@ -1422,12 +1425,13 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
1422
1425
  try {
1423
1426
  metrics?.inclusionListsValid.inc({source: InclusionListSource.gossip});
1424
1427
  metrics?.inclusionListsValidSize.inc(totalBytes);
1425
- // Timely only if received within its own slot before the deadline, so a list for the next slot that
1426
- // passed validation under clock disparity is untimely. Late lists are still stored, marked untimely
1428
+ // A list received before its slot within clock disparity is timely, the spec delays it until the slot
1429
+ // starts. Bounded on receipt time as validation checks the slot after queueing. Late lists are untimely
1427
1430
  const secFromSlot = chain.clock.secFromSlot(slot, seenTimestampSec);
1428
1431
  metrics?.inclusionListArrivalTime.observe(secFromSlot);
1429
1432
  const isTimely =
1430
- secFromSlot >= 0 && secFromSlot * 1000 < config.getInclusionListDueMs(config.getForkName(slot));
1433
+ secFromSlot * 1000 >= -config.MAXIMUM_GOSSIP_CLOCK_DISPARITY &&
1434
+ secFromSlot * 1000 < config.getInclusionListDueMs(config.getForkName(slot));
1431
1435
 
1432
1436
  const insertOutcome = chain.inclusionListStore.process(signedInclusionList, committeeIndices, isTimely);
1433
1437
  metrics?.inclusionListStore.insertOutcome.inc({insertOutcome});
@@ -12,6 +12,7 @@ import {
12
12
  ExecutionPayloadEnvelopeErrorCode,
13
13
  GossipAction,
14
14
  GossipActionError,
15
+ GossipErrorCode,
15
16
  InclusionListErrorCode,
16
17
  PayloadAttestationErrorCode,
17
18
  ProposerPreferencesErrorCode,
@@ -116,6 +117,9 @@ const gossipRejectPeerAction: Record<GossipType, RejectPeerActionRule> = {
116
117
  };
117
118
 
118
119
  export function rejectPeerAction(type: GossipType, code: string): PeerAction {
120
+ if (code === GossipErrorCode.INVALID_SERIALIZED_BYTES_ERROR_CODE) {
121
+ return PeerAction.LowToleranceError;
122
+ }
119
123
  const rule = gossipRejectPeerAction[type];
120
124
  return rule.byCode?.[code] ?? rule.default;
121
125
  }
@@ -12,11 +12,12 @@ import {ResponseTypeGetter} from "../types.js";
12
12
  */
13
13
  export async function collectExactOneTyped<T>(
14
14
  source: AsyncIterable<ResponseIncoming>,
15
- typeFn: ResponseTypeGetter<T>
15
+ typeFn: ResponseTypeGetter<T>,
16
+ onInvalidResponse?: (chunk: ResponseIncoming) => void
16
17
  ): Promise<T> {
17
18
  for await (const chunk of source) {
18
19
  const type = typeFn(chunk.fork, chunk.protocolVersion);
19
- const response = sszDeserializeResponse(type, chunk.data);
20
+ const response = sszDeserializeResponse(type, chunk, onInvalidResponse);
20
21
  return response;
21
22
  }
22
23
  throw new RequestError({code: RequestErrorCode.EMPTY_RESPONSE});
@@ -33,13 +34,14 @@ export async function collectMaxResponseTyped<T>(
33
34
  source: AsyncIterable<ResponseIncoming>,
34
35
  maxResponses: number,
35
36
  typeFn: ResponseTypeGetter<T>,
36
- serializedCache?: SerializedCache
37
+ serializedCache?: SerializedCache,
38
+ onInvalidResponse?: (chunk: ResponseIncoming) => void
37
39
  ): Promise<T[]> {
38
40
  // else: zero or more responses
39
41
  const responses: T[] = [];
40
42
  for await (const chunk of source) {
41
43
  const type = typeFn(chunk.fork, chunk.protocolVersion);
42
- const response = sszDeserializeResponse(type, chunk.data);
44
+ const response = sszDeserializeResponse(type, chunk, onInvalidResponse);
43
45
  // optionally cache the serialized response if the cache is available
44
46
  serializedCache?.set(response as object, chunk.data);
45
47
  responses.push(response);
@@ -62,13 +64,14 @@ export async function collectMaxResponseTypedWithBytes<T>(
62
64
  source: AsyncIterable<ResponseIncoming>,
63
65
  maxResponses: number,
64
66
  typeFn: ResponseTypeGetter<T>,
65
- serializedCache?: SerializedCache
67
+ serializedCache?: SerializedCache,
68
+ onInvalidResponse?: (chunk: ResponseIncoming) => void
66
69
  ): Promise<T[]> {
67
70
  // else: zero or more responses
68
71
  const responses: T[] = [];
69
72
  for await (const chunk of source) {
70
73
  const type = typeFn(chunk.fork, chunk.protocolVersion);
71
- const data = sszDeserializeResponse(type, chunk.data);
74
+ const data = sszDeserializeResponse(type, chunk, onInvalidResponse);
72
75
  responses.push(data);
73
76
  // optionally cache the serialized response if the cache is available
74
77
  serializedCache?.set(data as object, chunk.data);
@@ -81,10 +84,15 @@ export async function collectMaxResponseTypedWithBytes<T>(
81
84
  }
82
85
 
83
86
  /** Light wrapper on type to wrap deserialize errors */
84
- export function sszDeserializeResponse<T>(type: Type<T>, bytes: Uint8Array): T {
87
+ export function sszDeserializeResponse<T>(
88
+ type: Type<T>,
89
+ chunk: ResponseIncoming,
90
+ onInvalidResponse?: (chunk: ResponseIncoming) => void
91
+ ): T {
85
92
  try {
86
- return type.deserialize(bytes);
93
+ return type.deserialize(chunk.data);
87
94
  } catch (e) {
95
+ onInvalidResponse?.(chunk);
88
96
  throw new RequestError({code: RequestErrorCode.INVALID_RESPONSE_SSZ, errorMessage: (e as Error).message});
89
97
  }
90
98
  }
@@ -12,13 +12,14 @@ import {sszDeserializeResponse} from "./collect.js";
12
12
  export async function collectSequentialBlocksInRange(
13
13
  blockStream: AsyncIterable<ResponseIncoming>,
14
14
  {count, startSlot}: Pick<phase0.BeaconBlocksByRangeRequest, "count" | "startSlot">,
15
- serializedCache?: SerializedCache
15
+ serializedCache?: SerializedCache,
16
+ onInvalidResponse?: (chunk: ResponseIncoming) => void
16
17
  ): Promise<SignedBeaconBlock[]> {
17
18
  const blocks: SignedBeaconBlock[] = [];
18
19
 
19
20
  for await (const chunk of blockStream) {
20
21
  const blockType = responseSszTypeByMethod[ReqRespMethod.BeaconBlocksByRange](chunk.fork, chunk.protocolVersion);
21
- const block = sszDeserializeResponse(blockType, chunk.data);
22
+ const block = sszDeserializeResponse(blockType, chunk, onInvalidResponse);
22
23
 
23
24
  const blockSlot = block.message.slot;
24
25
 
@@ -376,7 +376,8 @@ export class BlockInputSync {
376
376
  // because the payload at the finalized block is not finalized
377
377
  const finalizedSlot = this.chain.forkChoice.getFinalizedBlock().slot;
378
378
  const nowSec = Date.now() / 1000;
379
- const maxSecInCache = (PRUNE_UNRESOLVED_SLOT_EPOCHS * SLOTS_PER_EPOCH * this.config.SLOT_DURATION_MS) / 1000;
379
+ const slotDurationMs = this.config.getSlotDurationMs(this.config.getForkName(this.chain.clock.currentSlot));
380
+ const maxSecInCache = (PRUNE_UNRESOLVED_SLOT_EPOCHS * SLOTS_PER_EPOCH * slotDurationMs) / 1000;
380
381
 
381
382
  let belowFinalizedPayloads = 0;
382
383
  let agedOutPayloads = 0;