@lodestar/beacon-node 1.45.0-dev.246e0ddef4 → 1.45.0-dev.27da921314

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/beacon/index.d.ts +1 -1
  2. package/lib/api/impl/beacon/index.d.ts.map +1 -1
  3. package/lib/api/impl/beacon/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 +4 -0
  6. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  7. package/lib/api/impl/beacon/state/index.d.ts +1 -1
  8. package/lib/api/impl/beacon/state/index.d.ts.map +1 -1
  9. package/lib/api/impl/beacon/state/index.js +2 -2
  10. package/lib/api/impl/beacon/state/index.js.map +1 -1
  11. package/lib/api/impl/beacon/state/utils.d.ts +2 -1
  12. package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
  13. package/lib/api/impl/beacon/state/utils.js +9 -1
  14. package/lib/api/impl/beacon/state/utils.js.map +1 -1
  15. package/lib/api/impl/debug/index.d.ts +1 -1
  16. package/lib/api/impl/debug/index.d.ts.map +1 -1
  17. package/lib/api/impl/debug/index.js +2 -2
  18. package/lib/api/impl/debug/index.js.map +1 -1
  19. package/lib/api/impl/lodestar/index.js +2 -2
  20. package/lib/api/impl/lodestar/index.js.map +1 -1
  21. package/lib/api/impl/proof/index.d.ts +1 -1
  22. package/lib/api/impl/proof/index.d.ts.map +1 -1
  23. package/lib/api/impl/proof/index.js +2 -2
  24. package/lib/api/impl/proof/index.js.map +1 -1
  25. package/lib/api/impl/utils.d.ts +23 -0
  26. package/lib/api/impl/utils.d.ts.map +1 -1
  27. package/lib/api/impl/utils.js +44 -1
  28. package/lib/api/impl/utils.js.map +1 -1
  29. package/lib/api/impl/validator/index.d.ts +0 -14
  30. package/lib/api/impl/validator/index.d.ts.map +1 -1
  31. package/lib/api/impl/validator/index.js +21 -56
  32. package/lib/api/impl/validator/index.js.map +1 -1
  33. package/lib/api/rest/base.d.ts.map +1 -1
  34. package/lib/api/rest/base.js +8 -0
  35. package/lib/api/rest/base.js.map +1 -1
  36. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  37. package/lib/chain/blocks/importBlock.js +1 -4
  38. package/lib/chain/blocks/importBlock.js.map +1 -1
  39. package/lib/chain/builderCircuitBreaker.d.ts +31 -0
  40. package/lib/chain/builderCircuitBreaker.d.ts.map +1 -0
  41. package/lib/chain/builderCircuitBreaker.js +59 -0
  42. package/lib/chain/builderCircuitBreaker.js.map +1 -0
  43. package/lib/chain/chain.d.ts +2 -0
  44. package/lib/chain/chain.d.ts.map +1 -1
  45. package/lib/chain/chain.js +3 -0
  46. package/lib/chain/chain.js.map +1 -1
  47. package/lib/chain/interface.d.ts +2 -0
  48. package/lib/chain/interface.d.ts.map +1 -1
  49. package/lib/chain/interface.js.map +1 -1
  50. package/lib/chain/options.d.ts +4 -0
  51. package/lib/chain/options.d.ts.map +1 -1
  52. package/lib/chain/options.js.map +1 -1
  53. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  54. package/lib/chain/prepareNextSlot.js +12 -7
  55. package/lib/chain/prepareNextSlot.js.map +1 -1
  56. package/lib/chain/validation/proposerPreferences.d.ts.map +1 -1
  57. package/lib/chain/validation/proposerPreferences.js +3 -2
  58. package/lib/chain/validation/proposerPreferences.js.map +1 -1
  59. package/lib/execution/builder/http.d.ts +18 -0
  60. package/lib/execution/builder/http.d.ts.map +1 -1
  61. package/lib/execution/builder/http.js +20 -11
  62. package/lib/execution/builder/http.js.map +1 -1
  63. package/lib/metrics/metrics/beacon.d.ts +6 -0
  64. package/lib/metrics/metrics/beacon.d.ts.map +1 -1
  65. package/lib/metrics/metrics/beacon.js +18 -0
  66. package/lib/metrics/metrics/beacon.js.map +1 -1
  67. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  68. package/lib/network/processor/gossipHandlers.js +4 -0
  69. package/lib/network/processor/gossipHandlers.js.map +1 -1
  70. package/package.json +19 -19
  71. package/src/api/impl/beacon/index.ts +1 -1
  72. package/src/api/impl/beacon/pool/index.ts +5 -0
  73. package/src/api/impl/beacon/state/index.ts +3 -2
  74. package/src/api/impl/beacon/state/utils.ts +11 -0
  75. package/src/api/impl/debug/index.ts +3 -2
  76. package/src/api/impl/lodestar/index.ts +2 -2
  77. package/src/api/impl/proof/index.ts +2 -2
  78. package/src/api/impl/utils.ts +51 -1
  79. package/src/api/impl/validator/index.ts +21 -62
  80. package/src/api/rest/base.ts +9 -0
  81. package/src/chain/blocks/importBlock.ts +1 -6
  82. package/src/chain/builderCircuitBreaker.ts +84 -0
  83. package/src/chain/chain.ts +7 -0
  84. package/src/chain/interface.ts +2 -0
  85. package/src/chain/options.ts +4 -0
  86. package/src/chain/prepareNextSlot.ts +11 -7
  87. package/src/chain/validation/proposerPreferences.ts +3 -2
  88. package/src/execution/builder/http.ts +30 -17
  89. package/src/metrics/metrics/beacon.ts +19 -0
  90. package/src/network/processor/gossipHandlers.ts +5 -0
@@ -49,6 +49,10 @@ export type IChainOptions = BlockProcessOpts &
49
49
  archiveDateEpochs?: number;
50
50
  nHistoricalStatesFileDataStore?: boolean;
51
51
  nativeStateView?: boolean;
52
+ /** Builder circuit breaker fault inspection window in slots */
53
+ faultInspectionWindow?: number;
54
+ /** Allowed unrevealed payloads within the fault inspection window */
55
+ allowedFaults?: number;
52
56
  };
53
57
 
54
58
  export type BlockProcessOpts = {
@@ -1,7 +1,7 @@
1
1
  import {routes} from "@lodestar/api";
2
2
  import {ChainForkConfig} from "@lodestar/config";
3
3
  import {getSafeExecutionBlockHash} from "@lodestar/fork-choice";
4
- import {ForkPostBellatrix, ForkSeq, SLOTS_PER_EPOCH, isForkPostBellatrix} from "@lodestar/params";
4
+ import {ForkPostBellatrix, ForkSeq, SLOTS_PER_EPOCH, isForkPostBellatrix, isForkPostGloas} from "@lodestar/params";
5
5
  import {
6
6
  IBeaconStateView,
7
7
  IBeaconStateViewBellatrix,
@@ -152,12 +152,16 @@ export class PrepareNextSlotScheduler {
152
152
  updatedHead = proposerHead;
153
153
  }
154
154
 
155
- // Update the builder status, if enabled shoot an api call to check status
156
- this.chain.updateBuilderStatus(clockSlot);
157
- if (this.chain.executionBuilder?.status === BuilderStatus.enabled) {
158
- this.chain.executionBuilder.checkStatus().catch((e) => {
159
- this.logger.error("Builder disabled as the check status api failed", {prepareSlot}, e as Error);
160
- });
155
+ if (isForkPostGloas(fork)) {
156
+ this.chain.builderCircuitBreaker.update(clockSlot);
157
+ } else {
158
+ // Update the builder status, if enabled shoot an api call to check status
159
+ this.chain.updateBuilderStatus(clockSlot);
160
+ if (this.chain.executionBuilder?.status === BuilderStatus.enabled) {
161
+ this.chain.executionBuilder.checkStatus().catch((e) => {
162
+ this.logger.error("Builder disabled as the check status api failed", {prepareSlot}, e as Error);
163
+ });
164
+ }
161
165
  }
162
166
  }
163
167
 
@@ -32,8 +32,9 @@ export async function validateGossipProposerPreferences(
32
32
  });
33
33
  }
34
34
 
35
- // [IGNORE] `preferences.proposal_slot` has not already passed.
36
- const currentSlot = chain.clock.currentSlot;
35
+ // [IGNORE] `preferences.proposal_slot` has not already passed, i.e. `proposal_slot > current_slot`,
36
+ // allowing for `MAXIMUM_GOSSIP_CLOCK_DISPARITY`.
37
+ const currentSlot = chain.clock.currentSlotWithGossipDisparity;
37
38
  if (proposalSlot <= currentSlot) {
38
39
  throw new ProposerPreferencesError(GossipAction.IGNORE, {
39
40
  code: ProposerPreferencesErrorCode.PROPOSAL_SLOT_PASSED,
@@ -70,6 +70,33 @@ export class NoBidReceived extends Error {
70
70
  }
71
71
  }
72
72
 
73
+ /**
74
+ * Beacon clients select randomized values from the following ranges when initializing
75
+ * the circuit breaker (so at boot time and once for each unique boot).
76
+ *
77
+ * ALLOWED_FAULTS: between 1 and SLOTS_PER_EPOCH // 4
78
+ * FAULT_INSPECTION_WINDOW: between SLOTS_PER_EPOCH and 2 * SLOTS_PER_EPOCH
79
+ *
80
+ * The values are randomized per node so builders cannot predict when a given proposer will
81
+ * fall back to local blocks. With fixed thresholds a builder could withhold payloads right up
82
+ * to the limit without ever tripping the breaker.
83
+ */
84
+ export function getFaultInspectionParams(opts: {faultInspectionWindow?: number; allowedFaults?: number}): {
85
+ faultInspectionWindow: number;
86
+ allowedFaults: number;
87
+ } {
88
+ const faultInspectionWindow = Math.max(
89
+ opts.faultInspectionWindow ?? SLOTS_PER_EPOCH + Math.floor(Math.random() * SLOTS_PER_EPOCH),
90
+ SLOTS_PER_EPOCH
91
+ );
92
+ // allowedFaults should be < faultInspectionWindow, limiting them to faultInspectionWindow/4
93
+ const allowedFaults = Math.min(
94
+ opts.allowedFaults ?? Math.floor(faultInspectionWindow / 4),
95
+ Math.floor(faultInspectionWindow / 4)
96
+ );
97
+ return {faultInspectionWindow, allowedFaults};
98
+ }
99
+
73
100
  /**
74
101
  * Additional duration to account for potential event loop lag which causes
75
102
  * builder blocks to be rejected even though the response was sent in time.
@@ -122,23 +149,9 @@ export class ExecutionBuilderHttp implements IExecutionBuilder {
122
149
  this.registrations = new ValidatorRegistrationCache();
123
150
  this.issueLocalFcUWithFeeRecipient = opts.issueLocalFcUWithFeeRecipient;
124
151
 
125
- /**
126
- * Beacon clients select randomized values from the following ranges when initializing
127
- * the circuit breaker (so at boot time and once for each unique boot).
128
- *
129
- * ALLOWED_FAULTS: between 1 and SLOTS_PER_EPOCH // 4
130
- * FAULT_INSPECTION_WINDOW: between SLOTS_PER_EPOCH and 2 * SLOTS_PER_EPOCH
131
- *
132
- */
133
- this.faultInspectionWindow = Math.max(
134
- opts.faultInspectionWindow ?? SLOTS_PER_EPOCH + Math.floor(Math.random() * SLOTS_PER_EPOCH),
135
- SLOTS_PER_EPOCH
136
- );
137
- // allowedFaults should be < faultInspectionWindow, limiting them to faultInspectionWindow/4
138
- this.allowedFaults = Math.min(
139
- opts.allowedFaults ?? Math.floor(this.faultInspectionWindow / 4),
140
- Math.floor(this.faultInspectionWindow / 4)
141
- );
152
+ const {faultInspectionWindow, allowedFaults} = getFaultInspectionParams(opts);
153
+ this.faultInspectionWindow = faultInspectionWindow;
154
+ this.allowedFaults = allowedFaults;
142
155
  }
143
156
 
144
157
  updateStatus(status: BuilderStatus): void {
@@ -138,6 +138,25 @@ export function createBeaconMetrics(register: RegistryMetricCreator) {
138
138
  help: "Count of cached produced results",
139
139
  }),
140
140
 
141
+ builderCircuitBreaker: {
142
+ active: register.gauge({
143
+ name: "beacon_builder_circuit_breaker_active",
144
+ help: "Whether the builder circuit breaker is active (1) causing builder bids to be ignored",
145
+ }),
146
+ faults: register.gauge({
147
+ name: "beacon_builder_circuit_breaker_faults",
148
+ help: "Count of blocks with unrevealed payloads in the fault inspection window",
149
+ }),
150
+ blocksPresent: register.gauge({
151
+ name: "beacon_builder_circuit_breaker_blocks_present",
152
+ help: "Count of blocks present in the fault inspection window",
153
+ }),
154
+ payloadsRevealed: register.gauge({
155
+ name: "beacon_builder_circuit_breaker_payloads_revealed",
156
+ help: "Count of blocks with revealed payloads in the fault inspection window",
157
+ }),
158
+ },
159
+
141
160
  blockPayload: {
142
161
  payloadAdvancePrepTime: register.histogram({
143
162
  name: "beacon_block_payload_prepare_time",
@@ -1241,6 +1241,11 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
1241
1241
  payloadAttestationMessage.data.payloadPresent,
1242
1242
  payloadAttestationMessage.data.blobDataAvailable
1243
1243
  );
1244
+
1245
+ chain.emitter.emit(routes.events.EventType.payloadAttestationMessage, {
1246
+ version: config.getForkName(payloadAttestationMessage.data.slot),
1247
+ data: payloadAttestationMessage,
1248
+ });
1244
1249
  },
1245
1250
  [GossipType.execution_payload_bid]: async ({
1246
1251
  gossipData,