@lodestar/beacon-node 1.48.0-dev.e1303d42b0 → 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 (90) 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/archiveStore/historicalState/metrics.d.ts.map +1 -1
  5. package/lib/chain/archiveStore/historicalState/metrics.js +12 -1
  6. package/lib/chain/archiveStore/historicalState/metrics.js.map +1 -1
  7. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  8. package/lib/chain/blocks/importBlock.js +0 -13
  9. package/lib/chain/blocks/importBlock.js.map +1 -1
  10. package/lib/chain/blocks/utils/chainSegment.d.ts +1 -1
  11. package/lib/chain/blocks/utils/chainSegment.d.ts.map +1 -1
  12. package/lib/chain/blocks/utils/chainSegment.js +10 -1
  13. package/lib/chain/blocks/utils/chainSegment.js.map +1 -1
  14. package/lib/chain/chain.d.ts +5 -0
  15. package/lib/chain/chain.d.ts.map +1 -1
  16. package/lib/chain/chain.js +67 -38
  17. package/lib/chain/chain.js.map +1 -1
  18. package/lib/chain/emitter.d.ts +1 -1
  19. package/lib/chain/emitter.js +1 -1
  20. package/lib/chain/errors/blockError.d.ts +3 -5
  21. package/lib/chain/errors/blockError.d.ts.map +1 -1
  22. package/lib/chain/errors/blockError.js +2 -2
  23. package/lib/chain/errors/blockError.js.map +1 -1
  24. package/lib/chain/errors/executionPayloadEnvelope.d.ts +0 -11
  25. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  26. package/lib/chain/errors/executionPayloadEnvelope.js +0 -2
  27. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  28. package/lib/chain/errors/gossipValidation.d.ts +2 -1
  29. package/lib/chain/errors/gossipValidation.d.ts.map +1 -1
  30. package/lib/chain/errors/gossipValidation.js +1 -0
  31. package/lib/chain/errors/gossipValidation.js.map +1 -1
  32. package/lib/chain/prepareNextSlot.js +13 -13
  33. package/lib/chain/prepareNextSlot.js.map +1 -1
  34. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  35. package/lib/chain/produceBlock/produceBlockBody.js +46 -64
  36. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  37. package/lib/chain/validation/block.d.ts.map +1 -1
  38. package/lib/chain/validation/block.js +9 -50
  39. package/lib/chain/validation/block.js.map +1 -1
  40. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  41. package/lib/chain/validation/executionPayloadEnvelope.js +0 -29
  42. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  43. package/lib/chain/validatorMonitor.d.ts +7 -1
  44. package/lib/chain/validatorMonitor.d.ts.map +1 -1
  45. package/lib/chain/validatorMonitor.js +22 -5
  46. package/lib/chain/validatorMonitor.js.map +1 -1
  47. package/lib/execution/engine/mock.d.ts.map +1 -1
  48. package/lib/execution/engine/mock.js +4 -1
  49. package/lib/execution/engine/mock.js.map +1 -1
  50. package/lib/network/gossip/encoding.d.ts.map +1 -1
  51. package/lib/network/gossip/encoding.js +0 -6
  52. package/lib/network/gossip/encoding.js.map +1 -1
  53. package/lib/network/gossip/topic.d.ts +2 -1
  54. package/lib/network/gossip/topic.d.ts.map +1 -1
  55. package/lib/network/gossip/topic.js +4 -20
  56. package/lib/network/gossip/topic.js.map +1 -1
  57. package/lib/network/processor/index.d.ts +49 -3
  58. package/lib/network/processor/index.d.ts.map +1 -1
  59. package/lib/network/processor/index.js +243 -98
  60. package/lib/network/processor/index.js.map +1 -1
  61. package/lib/network/reqresp/protocols.d.ts.map +1 -1
  62. package/lib/network/reqresp/protocols.js +6 -22
  63. package/lib/network/reqresp/protocols.js.map +1 -1
  64. package/lib/network/reqresp/rateLimit.js +2 -1
  65. package/lib/network/reqresp/rateLimit.js.map +1 -1
  66. package/lib/sync/range/range.d.ts.map +1 -1
  67. package/lib/sync/range/range.js +3 -1
  68. package/lib/sync/range/range.js.map +1 -1
  69. package/package.json +15 -15
  70. package/src/api/impl/validator/index.ts +44 -43
  71. package/src/chain/archiveStore/historicalState/metrics.ts +14 -1
  72. package/src/chain/blocks/importBlock.ts +0 -13
  73. package/src/chain/blocks/utils/chainSegment.ts +10 -1
  74. package/src/chain/chain.ts +74 -46
  75. package/src/chain/emitter.ts +1 -1
  76. package/src/chain/errors/blockError.ts +3 -3
  77. package/src/chain/errors/executionPayloadEnvelope.ts +0 -9
  78. package/src/chain/errors/gossipValidation.ts +1 -0
  79. package/src/chain/prepareNextSlot.ts +16 -16
  80. package/src/chain/produceBlock/produceBlockBody.ts +50 -71
  81. package/src/chain/validation/block.ts +9 -66
  82. package/src/chain/validation/executionPayloadEnvelope.ts +0 -37
  83. package/src/chain/validatorMonitor.ts +24 -7
  84. package/src/execution/engine/mock.ts +4 -1
  85. package/src/network/gossip/encoding.ts +0 -6
  86. package/src/network/gossip/topic.ts +3 -25
  87. package/src/network/processor/index.ts +276 -148
  88. package/src/network/reqresp/protocols.ts +7 -24
  89. package/src/network/reqresp/rateLimit.ts +2 -1
  90. package/src/sync/range/range.ts +3 -1
@@ -1,5 +1,5 @@
1
1
  import {BeaconConfig} from "@lodestar/config";
2
- import {ForkName, MAX_DATA_COLUMN_SIDECAR_SIZE, isForkPostGloas} from "@lodestar/params";
2
+ import {ForkName} from "@lodestar/params";
3
3
  import {ContextBytesFactory, ContextBytesType, Encoding, TypeSizes} from "@lodestar/reqresp";
4
4
  import {rateLimitQuotas} from "./rateLimit.js";
5
5
  import {ProtocolNoHandler, ReqRespMethod, Version, requestSszTypeByMethod, responseSszTypeByMethod} from "./types.js";
@@ -151,35 +151,18 @@ function toProtocol(protocol: ProtocolSummary) {
151
151
  encoding: Encoding.SSZ_SNAPPY,
152
152
  contextBytes: toContextBytes(protocol.contextBytesType, config),
153
153
  inboundRateLimits: rateLimitQuotas(fork, config)[protocol.method],
154
- requestSizes: requestType === null ? null : clampTypeSizes(requestType, protocol.method, fork, config),
155
- responseSizes: (fork) =>
156
- clampTypeSizes(responseSszTypeByMethod[protocol.method](fork, protocol.version), protocol.method, fork, config),
154
+ requestSizes: requestType === null ? null : clampTypeSizes(requestType, config),
155
+ responseSizes: (fork) => clampTypeSizes(responseSszTypeByMethod[protocol.method](fork, protocol.version), config),
157
156
  };
158
157
  };
159
158
  }
160
159
 
161
160
  /**
162
- * Bound the sizes accepted from the ssz-snappy length-prefix. Gloas progressive containers have broad
163
- * theoretical SSZ max sizes so the preset p2p bounds must be used instead.
164
- *
165
- * The length-prefix must be within the size bounds derived from the payload SSZ type or `MAX_PAYLOAD_SIZE`,
166
- * whichever is smaller, see
167
- * https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.12/specs/phase0/p2p-interface.md#encoding-strategies.
168
- * Type-specific SSZ bounds supersede the bounds derived from the SSZ type, see
169
- * https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.12/specs/gloas/p2p-interface.md#type-specific-ssz-bounds.
161
+ * Length-prefix must be within the SSZ type bounds or MAX_PAYLOAD_SIZE, whichever is smaller
162
+ * https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.12/specs/phase0/p2p-interface.md#encoding-strategies
170
163
  */
171
- function clampTypeSizes(type: TypeSizes, method: ReqRespMethod, fork: ForkName, config: BeaconConfig): TypeSizes {
172
- let typeSpecificBound = config.MAX_PAYLOAD_SIZE;
173
- if (isForkPostGloas(fork)) {
174
- switch (method) {
175
- case ReqRespMethod.DataColumnSidecarsByRange:
176
- case ReqRespMethod.DataColumnSidecarsByRoot:
177
- typeSpecificBound = MAX_DATA_COLUMN_SIDECAR_SIZE;
178
- break;
179
- }
180
- }
181
-
182
- return {minSize: type.minSize, maxSize: Math.min(type.maxSize, typeSpecificBound)};
164
+ function clampTypeSizes(type: TypeSizes, config: BeaconConfig): TypeSizes {
165
+ return {minSize: type.minSize, maxSize: Math.min(type.maxSize, config.MAX_PAYLOAD_SIZE)};
183
166
  }
184
167
 
185
168
  function toContextBytes(type: ContextBytesType, config: BeaconConfig): ContextBytesFactory {
@@ -126,7 +126,8 @@ function getRequestCountFn<T extends ReqRespMethod>(
126
126
  const type = requestSszTypeByMethod(fork, config)[method];
127
127
  return (reqData: Uint8Array) => {
128
128
  try {
129
- return (type && fn(type.deserialize(reqData))) ?? 1;
129
+ // A schema-valid request can cost 0 tokens; floor to 1 so it stays charged and bannable, not free.
130
+ return Math.max(1, (type && fn(type.deserialize(reqData))) ?? 1);
130
131
  } catch (_e) {
131
132
  return 1;
132
133
  }
@@ -220,8 +220,9 @@ export class RangeSync extends (EventEmitter as {new (): RangeSyncEmitter}) {
220
220
  const {orphaned, skipped} = await this.chain.processChainSegment(blocks, payloadEnvelopes, flags);
221
221
  // We log orphaned payloads to work with different clients
222
222
  // in the future, consider applying penalties in certain conditions
223
+ // make sure the payload source was from range sync in that case
223
224
  for (const {slot, payloadEnvelopeInput} of orphaned) {
224
- const peerIdStr = payloadEnvelopeInput.getPayloadEnvelopeSource().peerIdStr;
225
+ const {peerIdStr, source} = payloadEnvelopeInput.getPayloadEnvelopeSource();
225
226
  let client = "unknown";
226
227
  if (peerIdStr !== undefined) {
227
228
  try {
@@ -234,6 +235,7 @@ export class RangeSync extends (EventEmitter as {new (): RangeSyncEmitter}) {
234
235
  slot,
235
236
  root: payloadEnvelopeInput.blockRootHex,
236
237
  peer: peerIdStr ?? "unknown",
238
+ source,
237
239
  client,
238
240
  skipped,
239
241
  });