@lodestar/beacon-node 1.47.0-dev.d9c16ea16f → 1.47.0-dev.e91bc3e859
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.
- package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/blocks/index.js +3 -6
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/beacon/pool/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/pool/index.js +4 -0
- package/lib/api/impl/beacon/pool/index.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +12 -22
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/api/impl/validator/utils.d.ts +5 -0
- package/lib/api/impl/validator/utils.d.ts.map +1 -1
- package/lib/api/impl/validator/utils.js +18 -12
- package/lib/api/impl/validator/utils.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/metrics.d.ts.map +1 -1
- package/lib/chain/archiveStore/historicalState/metrics.js +21 -0
- package/lib/chain/archiveStore/historicalState/metrics.js.map +1 -1
- package/lib/chain/blocks/importBlock.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.js +2 -7
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/blocks/index.js +1 -1
- package/lib/chain/blocks/index.js.map +1 -1
- package/lib/chain/builderCircuitBreaker.d.ts +6 -5
- package/lib/chain/builderCircuitBreaker.d.ts.map +1 -1
- package/lib/chain/builderCircuitBreaker.js +28 -15
- package/lib/chain/builderCircuitBreaker.js.map +1 -1
- package/lib/chain/chain.d.ts +1 -1
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +2 -1
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/errors/blockError.d.ts +1 -0
- package/lib/chain/errors/blockError.d.ts.map +1 -1
- package/lib/chain/options.d.ts +1 -1
- package/lib/chain/options.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +1 -1
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +2 -0
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +6 -1
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/seenCache/seenBlockProposers.d.ts +5 -1
- package/lib/chain/seenCache/seenBlockProposers.d.ts.map +1 -1
- package/lib/chain/seenCache/seenBlockProposers.js +10 -3
- package/lib/chain/seenCache/seenBlockProposers.js.map +1 -1
- package/lib/chain/validation/block.d.ts.map +1 -1
- package/lib/chain/validation/block.js +21 -7
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/chain/validation/proposerPreferences.d.ts +1 -1
- package/lib/chain/validation/proposerPreferences.js +1 -1
- package/lib/execution/builder/http.d.ts +10 -7
- package/lib/execution/builder/http.d.ts.map +1 -1
- package/lib/execution/builder/http.js +11 -8
- package/lib/execution/builder/http.js.map +1 -1
- package/lib/metrics/metrics/beacon.d.ts +3 -3
- package/lib/metrics/metrics/beacon.d.ts.map +1 -1
- package/lib/metrics/metrics/beacon.js +9 -9
- package/lib/metrics/metrics/beacon.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +10 -0
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +16 -0
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +32 -5
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +17 -5
- package/lib/sync/unknownBlock.js.map +1 -1
- package/package.json +14 -14
- package/src/api/impl/beacon/blocks/index.ts +4 -6
- package/src/api/impl/beacon/pool/index.ts +5 -0
- package/src/api/impl/validator/index.ts +22 -27
- package/src/api/impl/validator/utils.ts +30 -15
- package/src/chain/archiveStore/historicalState/metrics.ts +22 -0
- package/src/chain/blocks/importBlock.ts +1 -6
- package/src/chain/blocks/index.ts +1 -1
- package/src/chain/builderCircuitBreaker.ts +31 -17
- package/src/chain/chain.ts +2 -0
- package/src/chain/errors/blockError.ts +1 -1
- package/src/chain/options.ts +1 -1
- package/src/chain/prepareNextSlot.ts +1 -1
- package/src/chain/produceBlock/produceBlockBody.ts +13 -0
- package/src/chain/seenCache/seenBlockProposers.ts +13 -3
- package/src/chain/validation/block.ts +21 -7
- package/src/chain/validation/proposerPreferences.ts +1 -1
- package/src/execution/builder/http.ts +11 -11
- package/src/metrics/metrics/beacon.ts +9 -9
- package/src/metrics/metrics/lodestar.ts +16 -0
- package/src/network/processor/gossipHandlers.ts +35 -3
- package/src/sync/unknownBlock.ts +18 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {IForkChoice} from "@lodestar/fork-choice";
|
|
1
|
+
import {IForkChoice, ProtoBlock} from "@lodestar/fork-choice";
|
|
2
2
|
import {Slot} from "@lodestar/types";
|
|
3
3
|
import {Logger} from "@lodestar/utils";
|
|
4
4
|
import {getFaultInspectionParams} from "../execution/builder/http.js";
|
|
@@ -15,11 +15,15 @@ export type BuilderCircuitBreakerModules = {
|
|
|
15
15
|
metrics: Metrics | null;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
+
/** Four observations is the minimum useful recovery sample for the default ~25% fault budget */
|
|
19
|
+
const MIN_BLOCKS_TO_DEACTIVATE = 4;
|
|
20
|
+
|
|
18
21
|
/**
|
|
19
22
|
* Post-gloas circuit breaker for builder bids. The beacon block is produced by the proposer
|
|
20
23
|
* regardless of bid source, so missed blocks are not a useful builder health signal. Instead
|
|
21
|
-
* count blocks
|
|
22
|
-
*
|
|
24
|
+
* count canonical blocks selected as EMPTY. Activate when the proportion of EMPTY blocks exceeds
|
|
25
|
+
* the fault budget, and resume selecting builder bids only when the observed blocks are within
|
|
26
|
+
* budget and meet the minimum recovery sample size.
|
|
23
27
|
*/
|
|
24
28
|
export class BuilderCircuitBreaker {
|
|
25
29
|
readonly faultInspectionWindow: number;
|
|
@@ -35,39 +39,49 @@ export class BuilderCircuitBreaker {
|
|
|
35
39
|
const {faultInspectionWindow, allowedFaults} = getFaultInspectionParams(opts);
|
|
36
40
|
this.faultInspectionWindow = faultInspectionWindow;
|
|
37
41
|
this.allowedFaults = allowedFaults;
|
|
42
|
+
this.modules.logger.info("Builder circuit breaker initialized", {faultInspectionWindow, allowedFaults});
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
/** Whether builder bids must be ignored for a block produced at clockSlot */
|
|
41
|
-
isActive(clockSlot: Slot): boolean {
|
|
42
|
-
this.update(clockSlot);
|
|
46
|
+
isActive(clockSlot: Slot, head: ProtoBlock): boolean {
|
|
47
|
+
this.update(clockSlot, head);
|
|
43
48
|
return this.active;
|
|
44
49
|
}
|
|
45
50
|
|
|
46
|
-
update(clockSlot: Slot): void {
|
|
51
|
+
update(clockSlot: Slot, head: ProtoBlock): void {
|
|
47
52
|
if (clockSlot <= this.lastUpdatedSlot) {
|
|
48
53
|
return;
|
|
49
54
|
}
|
|
50
55
|
this.lastUpdatedSlot = clockSlot;
|
|
51
56
|
|
|
52
|
-
// Exclude clockSlot itself, its payload
|
|
53
|
-
const {
|
|
57
|
+
// Exclude clockSlot itself, its payload status may still be unresolved
|
|
58
|
+
const {full, empty} = this.modules.forkChoice.getCanonicalPayloadCounts(
|
|
54
59
|
Math.max(clockSlot - this.faultInspectionWindow, 0),
|
|
55
|
-
clockSlot - 1
|
|
60
|
+
clockSlot - 1,
|
|
61
|
+
head
|
|
56
62
|
);
|
|
57
|
-
const
|
|
63
|
+
const canonicalBlocks = full + empty;
|
|
58
64
|
|
|
59
65
|
const wasActive = this.active;
|
|
60
|
-
// Scale the fault budget by blocks
|
|
61
|
-
|
|
66
|
+
// Scale the fault budget by canonical blocks so sparse windows still trigger on high EMPTY rates
|
|
67
|
+
const exceedsFaultBudget = empty * this.faultInspectionWindow > this.allowedFaults * canonicalBlocks;
|
|
68
|
+
if (exceedsFaultBudget) {
|
|
69
|
+
this.active = true;
|
|
70
|
+
} else if (canonicalBlocks >= MIN_BLOCKS_TO_DEACTIVATE) {
|
|
71
|
+
// Require a minimum sample within the fault budget before accepting builder bids again
|
|
72
|
+
this.active = false;
|
|
73
|
+
}
|
|
62
74
|
|
|
63
75
|
this.modules.metrics?.builderCircuitBreaker.active.set(this.active ? 1 : 0);
|
|
64
|
-
this.modules.metrics?.builderCircuitBreaker.
|
|
65
|
-
this.modules.metrics?.builderCircuitBreaker.
|
|
66
|
-
this.modules.metrics?.builderCircuitBreaker.
|
|
76
|
+
this.modules.metrics?.builderCircuitBreaker.canonicalBlocks.set(canonicalBlocks);
|
|
77
|
+
this.modules.metrics?.builderCircuitBreaker.fullBlocks.set(full);
|
|
78
|
+
this.modules.metrics?.builderCircuitBreaker.emptyBlocks.set(empty);
|
|
67
79
|
|
|
68
80
|
const logCtx = {
|
|
69
|
-
|
|
70
|
-
|
|
81
|
+
clockSlot,
|
|
82
|
+
canonicalBlocks,
|
|
83
|
+
full,
|
|
84
|
+
empty,
|
|
71
85
|
faultInspectionWindow: this.faultInspectionWindow,
|
|
72
86
|
allowedFaults: this.allowedFaults,
|
|
73
87
|
};
|
package/src/chain/chain.ts
CHANGED
|
@@ -1072,6 +1072,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1072
1072
|
graffiti,
|
|
1073
1073
|
slot,
|
|
1074
1074
|
feeRecipient,
|
|
1075
|
+
strictFeeRecipientCheck,
|
|
1075
1076
|
commonBlockBodyPromise,
|
|
1076
1077
|
parentBlock,
|
|
1077
1078
|
builderBid,
|
|
@@ -1100,6 +1101,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1100
1101
|
graffiti,
|
|
1101
1102
|
slot,
|
|
1102
1103
|
feeRecipient,
|
|
1104
|
+
strictFeeRecipientCheck,
|
|
1103
1105
|
parentBlock,
|
|
1104
1106
|
proposerIndex,
|
|
1105
1107
|
proposerPubKey,
|
|
@@ -118,7 +118,7 @@ export type BlockErrorType =
|
|
|
118
118
|
| {code: BlockErrorCode.GENESIS_BLOCK}
|
|
119
119
|
| {code: BlockErrorCode.WOULD_REVERT_FINALIZED_SLOT; blockSlot: Slot; finalizedSlot: Slot}
|
|
120
120
|
| {code: BlockErrorCode.ALREADY_KNOWN; root: RootHex}
|
|
121
|
-
| {code: BlockErrorCode.REPEAT_PROPOSAL; proposerIndex: ValidatorIndex}
|
|
121
|
+
| {code: BlockErrorCode.REPEAT_PROPOSAL; proposerIndex: ValidatorIndex; root: RootHex}
|
|
122
122
|
| {code: BlockErrorCode.BLOCK_SLOT_LIMIT_REACHED}
|
|
123
123
|
| {code: BlockErrorCode.INCORRECT_PROPOSER; proposerIndex: ValidatorIndex}
|
|
124
124
|
| {code: BlockErrorCode.PROPOSAL_SIGNATURE_INVALID; blockSlot: Slot}
|
package/src/chain/options.ts
CHANGED
|
@@ -53,7 +53,7 @@ export type IChainOptions = BlockProcessOpts &
|
|
|
53
53
|
nativeStateView?: boolean;
|
|
54
54
|
/** Builder circuit breaker fault inspection window in slots */
|
|
55
55
|
faultInspectionWindow?: number;
|
|
56
|
-
/**
|
|
56
|
+
/** Canonical EMPTY blocks allowed per `faultInspectionWindow` observed blocks */
|
|
57
57
|
allowedFaults?: number;
|
|
58
58
|
};
|
|
59
59
|
|
|
@@ -169,7 +169,7 @@ export class PrepareNextSlotScheduler {
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
if (isForkPostGloas(fork)) {
|
|
172
|
-
this.chain.builderCircuitBreaker.update(clockSlot);
|
|
172
|
+
this.chain.builderCircuitBreaker.update(clockSlot, updatedHead);
|
|
173
173
|
} else {
|
|
174
174
|
// Update the builder status, if enabled shoot an api call to check status
|
|
175
175
|
this.chain.updateBuilderStatus(clockSlot);
|
|
@@ -100,6 +100,8 @@ export type BlockAttributes = {
|
|
|
100
100
|
slot: Slot;
|
|
101
101
|
parentBlock: ProtoBlock;
|
|
102
102
|
feeRecipient?: string;
|
|
103
|
+
/** Verify that a locally produced execution payload uses `feeRecipient`. */
|
|
104
|
+
strictFeeRecipientCheck?: boolean;
|
|
103
105
|
/** When provided, build block with this builder bid instead of a self-build bid */
|
|
104
106
|
builderBid?: gloas.SignedExecutionPayloadBid;
|
|
105
107
|
};
|
|
@@ -201,6 +203,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
201
203
|
const {
|
|
202
204
|
slot: blockSlot,
|
|
203
205
|
feeRecipient: requestedFeeRecipient,
|
|
206
|
+
strictFeeRecipientCheck,
|
|
204
207
|
parentBlock,
|
|
205
208
|
proposerIndex,
|
|
206
209
|
proposerPubKey,
|
|
@@ -334,6 +337,16 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
334
337
|
executionPayloadValue = payloadRes.executionPayloadValue;
|
|
335
338
|
shouldOverrideBuilder = payloadRes.shouldOverrideBuilder;
|
|
336
339
|
|
|
340
|
+
if (
|
|
341
|
+
strictFeeRecipientCheck &&
|
|
342
|
+
requestedFeeRecipient &&
|
|
343
|
+
!byteArrayEquals(executionPayload.feeRecipient, fromHex(requestedFeeRecipient))
|
|
344
|
+
) {
|
|
345
|
+
throw Error(
|
|
346
|
+
`Invalid feeRecipient set in engine payload expected=${requestedFeeRecipient} actual=${toHex(executionPayload.feeRecipient)}`
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
|
|
337
350
|
if (blobsBundle === undefined) {
|
|
338
351
|
throw Error(`Missing blobsBundle response from getPayload at fork=${fork}`);
|
|
339
352
|
}
|
|
@@ -19,7 +19,9 @@ const MIN_EQUIVOCATION_BLOCK_ROOTS_PER_PROPOSAL = 2;
|
|
|
19
19
|
* The cache is pruned on finalization and bounds the number of roots stored per proposer and slot
|
|
20
20
|
*/
|
|
21
21
|
export class SeenBlockProposers {
|
|
22
|
-
private readonly proposerIndexesBySlot = new MapDef<Slot,
|
|
22
|
+
private readonly proposerIndexesBySlot = new MapDef<Slot, Map<ValidatorIndex, RootHex>>(
|
|
23
|
+
() => new Map<ValidatorIndex, RootHex>()
|
|
24
|
+
);
|
|
23
25
|
private readonly signedBlockHeadersBySlot = new MapDef<
|
|
24
26
|
Slot,
|
|
25
27
|
MapDef<ValidatorIndex, Map<RootHex, phase0.SignedBeaconBlockHeader>>
|
|
@@ -30,6 +32,14 @@ export class SeenBlockProposers {
|
|
|
30
32
|
return this.proposerIndexesBySlot.get(blockSlot)?.has(proposerIndex) === true;
|
|
31
33
|
}
|
|
32
34
|
|
|
35
|
+
/**
|
|
36
|
+
* The block proposer is known at slot with a different root.
|
|
37
|
+
*/
|
|
38
|
+
isRepeatProposal(blockSlot: Slot, proposerIndex: ValidatorIndex, blockRoot: RootHex): boolean {
|
|
39
|
+
const knownRoot = this.proposerIndexesBySlot.get(blockSlot)?.get(proposerIndex);
|
|
40
|
+
return knownRoot !== undefined && knownRoot !== blockRoot;
|
|
41
|
+
}
|
|
42
|
+
|
|
33
43
|
hasBlockRoot(blockSlot: Slot, proposerIndex: ValidatorIndex, blockRoot: RootHex): boolean {
|
|
34
44
|
return this.signedBlockHeadersBySlot.get(blockSlot)?.get(proposerIndex)?.has(blockRoot) === true;
|
|
35
45
|
}
|
|
@@ -85,12 +95,12 @@ export class SeenBlockProposers {
|
|
|
85
95
|
}
|
|
86
96
|
|
|
87
97
|
/** Mark a block as known from gossip or another block import path */
|
|
88
|
-
add(blockSlot: Slot, proposerIndex: ValidatorIndex): void {
|
|
98
|
+
add(blockSlot: Slot, proposerIndex: ValidatorIndex, blockRoot: RootHex): void {
|
|
89
99
|
if (blockSlot < this.finalizedSlot) {
|
|
90
100
|
throw Error(`blockSlot ${blockSlot} < finalizedSlot ${this.finalizedSlot}`);
|
|
91
101
|
}
|
|
92
102
|
|
|
93
|
-
this.proposerIndexesBySlot.getOrDefault(blockSlot).
|
|
103
|
+
this.proposerIndexesBySlot.getOrDefault(blockSlot).set(proposerIndex, blockRoot);
|
|
94
104
|
}
|
|
95
105
|
|
|
96
106
|
prune(finalizedSlot: Slot): void {
|
|
@@ -89,13 +89,20 @@ export async function validateGossipBlock(
|
|
|
89
89
|
|
|
90
90
|
// [IGNORE] The block is the first block with valid signature received for the proposer for the slot, signed_beacon_block.message.slot.
|
|
91
91
|
const proposerIndex = block.proposerIndex;
|
|
92
|
-
const hasBlockRoot = chain.seenBlockProposers.hasBlockRoot(blockSlot, proposerIndex, blockRoot);
|
|
93
92
|
if (chain.seenBlockProposers.isKnown(blockSlot, proposerIndex)) {
|
|
94
|
-
if (
|
|
95
|
-
|
|
96
|
-
chain.seenBlockProposers.
|
|
93
|
+
if (chain.seenBlockProposers.isRepeatProposal(blockSlot, proposerIndex, blockRoot)) {
|
|
94
|
+
const hasBlockRoot = chain.seenBlockProposers.hasBlockRoot(blockSlot, proposerIndex, blockRoot);
|
|
95
|
+
if (!hasBlockRoot && !chain.seenBlockProposers.isEquivocating(blockSlot, proposerIndex)) {
|
|
96
|
+
await verifyBlockProposerSignature(chain, signedBlock, blockRoot, {verifyOnMainThread: false});
|
|
97
|
+
chain.seenBlockProposers.observeBlockRoot(blockSlot, proposerIndex, blockRoot, signedBlockHeader);
|
|
98
|
+
}
|
|
99
|
+
throw new BlockGossipError(GossipAction.IGNORE, {
|
|
100
|
+
code: BlockErrorCode.REPEAT_PROPOSAL,
|
|
101
|
+
proposerIndex,
|
|
102
|
+
root: blockRoot,
|
|
103
|
+
});
|
|
97
104
|
}
|
|
98
|
-
throw new BlockGossipError(GossipAction.IGNORE, {code: BlockErrorCode.
|
|
105
|
+
throw new BlockGossipError(GossipAction.IGNORE, {code: BlockErrorCode.ALREADY_KNOWN, root: blockRoot});
|
|
99
106
|
}
|
|
100
107
|
|
|
101
108
|
// [REJECT] The current finalized_checkpoint is an ancestor of block -- i.e.
|
|
@@ -301,10 +308,17 @@ export async function validateGossipBlock(
|
|
|
301
308
|
|
|
302
309
|
// Check again after all async validation and the early-block delay so concurrent proposals cannot both pass
|
|
303
310
|
if (chain.seenBlockProposers.isKnown(blockSlot, proposerIndex)) {
|
|
304
|
-
|
|
311
|
+
if (chain.seenBlockProposers.isRepeatProposal(blockSlot, proposerIndex, blockRoot)) {
|
|
312
|
+
throw new BlockGossipError(GossipAction.IGNORE, {
|
|
313
|
+
code: BlockErrorCode.REPEAT_PROPOSAL,
|
|
314
|
+
proposerIndex,
|
|
315
|
+
root: blockRoot,
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
throw new BlockGossipError(GossipAction.IGNORE, {code: BlockErrorCode.ALREADY_KNOWN, root: blockRoot});
|
|
305
319
|
}
|
|
306
320
|
|
|
307
|
-
chain.seenBlockProposers.add(blockSlot, proposerIndex);
|
|
321
|
+
chain.seenBlockProposers.add(blockSlot, proposerIndex, blockRoot);
|
|
308
322
|
|
|
309
323
|
return {skippedSlots};
|
|
310
324
|
}
|
|
@@ -13,7 +13,7 @@ import {IBeaconChain} from "../index.js";
|
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Validates a gossiped `SignedProposerPreferences` per
|
|
16
|
-
* https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.
|
|
16
|
+
* https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.14/specs/gloas/p2p-interface.md#new-proposer_preferences
|
|
17
17
|
*/
|
|
18
18
|
export async function validateGossipProposerPreferences(
|
|
19
19
|
chain: IBeaconChain,
|
|
@@ -71,15 +71,18 @@ export class NoBidReceived extends Error {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
75
|
-
* the circuit breaker (so at boot time and once for each unique boot).
|
|
74
|
+
* Default circuit breaker parameters:
|
|
76
75
|
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
76
|
+
* SLOTS_PER_EPOCH <= FAULT_INSPECTION_WINDOW < 2 * SLOTS_PER_EPOCH (randomized at initialization)
|
|
77
|
+
* ALLOWED_FAULTS: FAULT_INSPECTION_WINDOW // 4
|
|
79
78
|
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
79
|
+
* e.g. on mainnet SLOTS_PER_EPOCH is 32, so FAULT_INSPECTION_WINDOW is between 32 and 63,
|
|
80
|
+
* and a window of 40 results in ALLOWED_FAULTS = 10.
|
|
81
|
+
*
|
|
82
|
+
* The randomized default window keeps the exact slots under inspection unpredictable per node,
|
|
83
|
+
* so a builder cannot tell when past faults age out of a given proposer's window and time
|
|
84
|
+
* withholding around trip or recovery points. Explicitly configured windows are clamped to at
|
|
85
|
+
* least SLOTS_PER_EPOCH, and configured allowedFaults is capped at the default ~25% budget.
|
|
83
86
|
*/
|
|
84
87
|
export function getFaultInspectionParams(opts: {faultInspectionWindow?: number; allowedFaults?: number}): {
|
|
85
88
|
faultInspectionWindow: number;
|
|
@@ -90,10 +93,7 @@ export function getFaultInspectionParams(opts: {faultInspectionWindow?: number;
|
|
|
90
93
|
SLOTS_PER_EPOCH
|
|
91
94
|
);
|
|
92
95
|
// 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
|
-
);
|
|
96
|
+
const allowedFaults = Math.min(opts.allowedFaults ?? Infinity, Math.floor(faultInspectionWindow / 4));
|
|
97
97
|
return {faultInspectionWindow, allowedFaults};
|
|
98
98
|
}
|
|
99
99
|
|
|
@@ -143,17 +143,17 @@ export function createBeaconMetrics(register: RegistryMetricCreator) {
|
|
|
143
143
|
name: "beacon_builder_circuit_breaker_active",
|
|
144
144
|
help: "Whether the builder circuit breaker is active (1) causing builder bids to be ignored",
|
|
145
145
|
}),
|
|
146
|
-
|
|
147
|
-
name: "
|
|
148
|
-
help: "Count of
|
|
146
|
+
canonicalBlocks: register.gauge({
|
|
147
|
+
name: "beacon_builder_circuit_breaker_canonical_blocks",
|
|
148
|
+
help: "Count of canonical FULL and EMPTY blocks in the fault inspection window",
|
|
149
149
|
}),
|
|
150
|
-
|
|
151
|
-
name: "
|
|
152
|
-
help: "Count of blocks
|
|
150
|
+
fullBlocks: register.gauge({
|
|
151
|
+
name: "beacon_builder_circuit_breaker_full_blocks",
|
|
152
|
+
help: "Count of canonical FULL blocks in the fault inspection window",
|
|
153
153
|
}),
|
|
154
|
-
|
|
155
|
-
name: "
|
|
156
|
-
help: "Count of
|
|
154
|
+
emptyBlocks: register.gauge({
|
|
155
|
+
name: "beacon_builder_circuit_breaker_empty_blocks",
|
|
156
|
+
help: "Count of canonical EMPTY blocks in the fault inspection window",
|
|
157
157
|
}),
|
|
158
158
|
},
|
|
159
159
|
|
|
@@ -908,6 +908,22 @@ export function createLodestarMetrics(
|
|
|
908
908
|
labelNames: ["error"],
|
|
909
909
|
}),
|
|
910
910
|
},
|
|
911
|
+
gossipExecutionPayloadBid: {
|
|
912
|
+
elapsedTimeTillReceived: register.histogram<{source: OpSource}>({
|
|
913
|
+
name: "lodestar_gossip_execution_payload_bid_elapsed_time_till_received_seconds",
|
|
914
|
+
help: "Time elapsed between the bid's slot start and the time the execution payload bid was received (negative = received before its slot, broadcast in the previous slot; positive = received during its own slot, late)",
|
|
915
|
+
labelNames: ["source"],
|
|
916
|
+
buckets: [-6, -3, -1, 0, 3],
|
|
917
|
+
}),
|
|
918
|
+
},
|
|
919
|
+
gossipPayloadAttestationMessage: {
|
|
920
|
+
elapsedTimeTillReceived: register.histogram<{source: OpSource}>({
|
|
921
|
+
name: "lodestar_gossip_payload_attestation_message_elapsed_time_till_received_seconds",
|
|
922
|
+
help: "Time elapsed between slot time and the time the payload attestation message was received",
|
|
923
|
+
labelNames: ["source"],
|
|
924
|
+
buckets: [3, 6, 9, 12],
|
|
925
|
+
}),
|
|
926
|
+
},
|
|
911
927
|
// recovery in the case of specific blob rows required
|
|
912
928
|
recoverBlobSidecars: {
|
|
913
929
|
blobsReconstructed: register.counter({
|
|
@@ -713,9 +713,32 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
713
713
|
const {serializedData} = gossipData;
|
|
714
714
|
|
|
715
715
|
const signedBlock = sszDeserialize(topic, serializedData);
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
716
|
+
try {
|
|
717
|
+
const blockInput = await validateBeaconBlock(signedBlock, topic.boundary.fork, peerIdStr, seenTimestampSec);
|
|
718
|
+
chain.serializedCache.set(signedBlock, serializedData);
|
|
719
|
+
handleValidBeaconBlock(blockInput, peerIdStr, seenTimestampSec);
|
|
720
|
+
} catch (e) {
|
|
721
|
+
// Spec: IGNORE the block, ie not to re-publish to peers
|
|
722
|
+
// but we should still import an equivocating (REPEAT_PROPOSAL) block into fork choice because we don't
|
|
723
|
+
// know if this block (or the 1st known block with same slot) will become canonical yet
|
|
724
|
+
if (
|
|
725
|
+
e instanceof BlockGossipError &&
|
|
726
|
+
e.type.code === BlockErrorCode.REPEAT_PROPOSAL &&
|
|
727
|
+
// this is make sure the block's proposer signature was verified, it should be true anyway
|
|
728
|
+
chain.seenBlockProposers.hasBlockRoot(signedBlock.message.slot, e.type.proposerIndex, e.type.root)
|
|
729
|
+
) {
|
|
730
|
+
// blockInput was optimistically seeded in validateBeaconBlock and retained on IGNORE
|
|
731
|
+
const blockInput = chain.seenBlockInputCache.get(e.type.root);
|
|
732
|
+
if (blockInput) {
|
|
733
|
+
chain.serializedCache.set(signedBlock, serializedData);
|
|
734
|
+
// this is technically not a valid gossip block but gossip validation is a cheap subset of checks
|
|
735
|
+
// this runs the full state transition, so importing an equivocating-but-valid block here is safe.
|
|
736
|
+
handleValidBeaconBlock(blockInput, peerIdStr, seenTimestampSec);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
// rethrow so gossipValidatorFn maps IGNORE -> TopicValidatorResult.Ignore (message not forwarded)
|
|
740
|
+
throw e;
|
|
741
|
+
}
|
|
719
742
|
},
|
|
720
743
|
|
|
721
744
|
[GossipType.blob_sidecar]: async ({
|
|
@@ -1232,11 +1255,15 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
1232
1255
|
[GossipType.payload_attestation_message]: async ({
|
|
1233
1256
|
gossipData,
|
|
1234
1257
|
topic,
|
|
1258
|
+
seenTimestampSec,
|
|
1235
1259
|
}: GossipHandlerParamGeneric<GossipType.payload_attestation_message>) => {
|
|
1236
1260
|
const {serializedData} = gossipData;
|
|
1237
1261
|
const payloadAttestationMessage = sszDeserialize(topic, serializedData);
|
|
1238
1262
|
const validationResult = await validateGossipPayloadAttestationMessage(chain, payloadAttestationMessage);
|
|
1239
1263
|
|
|
1264
|
+
const delaySec = chain.clock.secFromSlot(payloadAttestationMessage.data.slot, seenTimestampSec);
|
|
1265
|
+
metrics?.gossipPayloadAttestationMessage.elapsedTimeTillReceived.observe({source: OpSource.gossip}, delaySec);
|
|
1266
|
+
|
|
1240
1267
|
try {
|
|
1241
1268
|
const insertOutcome = chain.payloadAttestationPool.add(
|
|
1242
1269
|
payloadAttestationMessage,
|
|
@@ -1263,11 +1290,16 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
1263
1290
|
[GossipType.execution_payload_bid]: async ({
|
|
1264
1291
|
gossipData,
|
|
1265
1292
|
topic,
|
|
1293
|
+
seenTimestampSec,
|
|
1266
1294
|
}: GossipHandlerParamGeneric<GossipType.execution_payload_bid>) => {
|
|
1267
1295
|
const {serializedData} = gossipData;
|
|
1268
1296
|
const executionPayloadBid = sszDeserialize(topic, serializedData);
|
|
1269
1297
|
const {proposerIndex} = await validateGossipExecutionPayloadBid(chain, executionPayloadBid);
|
|
1270
1298
|
|
|
1299
|
+
// this could be negative, because it's most likely the bid of next slot comes at this clock slot
|
|
1300
|
+
const elapsedSec = chain.clock.secFromSlot(executionPayloadBid.message.slot, seenTimestampSec);
|
|
1301
|
+
metrics?.gossipExecutionPayloadBid.elapsedTimeTillReceived.observe({source: OpSource.gossip}, elapsedSec);
|
|
1302
|
+
|
|
1271
1303
|
// Handle valid payload bid by storing in a bid pool
|
|
1272
1304
|
try {
|
|
1273
1305
|
const insertOutcome = chain.executionPayloadBidPool.add(executionPayloadBid);
|
package/src/sync/unknownBlock.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {routes} from "@lodestar/api";
|
|
2
2
|
import {ChainForkConfig} from "@lodestar/config";
|
|
3
|
-
import {ForkSeq} from "@lodestar/params";
|
|
3
|
+
import {ForkSeq, isForkPostGloas} from "@lodestar/params";
|
|
4
4
|
import {RequestError, RequestErrorCode} from "@lodestar/reqresp";
|
|
5
5
|
import {computeTimeAtSlot} from "@lodestar/state-transition";
|
|
6
6
|
import {RootHex, Slot, gloas} from "@lodestar/types";
|
|
@@ -764,9 +764,10 @@ export class BlockInputSync {
|
|
|
764
764
|
// this prevents unbundling attack
|
|
765
765
|
// see https://lighthouse-blog.sigmaprime.io/mev-unbundling-rpc.html
|
|
766
766
|
const {slot: blockSlot, proposerIndex} = pendingBlock.blockInput.getBlock().message;
|
|
767
|
+
const blockRootHex = pendingBlock.blockInput.blockRootHex;
|
|
767
768
|
const logCtx = {
|
|
768
769
|
slot: blockSlot,
|
|
769
|
-
root:
|
|
770
|
+
root: blockRootHex,
|
|
770
771
|
delaySec: this.chain.clock.secFromSlot(blockSlot),
|
|
771
772
|
};
|
|
772
773
|
this.logger.verbose("Processing downloaded block", logCtx);
|
|
@@ -780,7 +781,7 @@ export class BlockInputSync {
|
|
|
780
781
|
// eligible for proposer boost to prevent unbundling attack
|
|
781
782
|
this.logger.verbose("Avoid proposer boost for this block of known proposer", {
|
|
782
783
|
slot: blockSlot,
|
|
783
|
-
root:
|
|
784
|
+
root: blockRootHex,
|
|
784
785
|
proposerIndex,
|
|
785
786
|
});
|
|
786
787
|
await sleep(proposerBoostWindowMs);
|
|
@@ -807,12 +808,24 @@ export class BlockInputSync {
|
|
|
807
808
|
if (!res.err) {
|
|
808
809
|
this.logger.verbose("Processed block from unknown sync", logCtx);
|
|
809
810
|
// no need to update status to "processed", delete anyway
|
|
810
|
-
this.pendingBlocks.delete(
|
|
811
|
+
this.pendingBlocks.delete(blockRootHex);
|
|
812
|
+
|
|
813
|
+
if (isForkPostGloas(fork)) {
|
|
814
|
+
const payloadInput = this.chain.seenPayloadEnvelopeInputCache.get(blockRootHex);
|
|
815
|
+
if (!payloadInput) {
|
|
816
|
+
this.logger.warn("PayloadEnvelopeInput not seeded during unknown sync processReadyBlock()", logCtx);
|
|
817
|
+
} else {
|
|
818
|
+
// Similar to the gossip path: immediately attempt fetch of data columns from the execution engine.
|
|
819
|
+
// The bid already carries the kzg commitments, so there is no reason to wait for the payload to arrive.
|
|
820
|
+
this.chain.getBlobsTracker.triggerGetBlobs(payloadInput);
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
|
|
811
824
|
// Re-enter the scheduler so descendants blocked on either parent blocks or parent payloads
|
|
812
825
|
// are advanced through the same dependency checks as every other pending item.
|
|
813
826
|
this.triggerUnknownBlockSearch();
|
|
814
827
|
} else {
|
|
815
|
-
const errorData = {slot: pendingBlock.blockInput.slot, root:
|
|
828
|
+
const errorData = {slot: pendingBlock.blockInput.slot, root: blockRootHex};
|
|
816
829
|
if (res.err instanceof BlockError) {
|
|
817
830
|
switch (res.err.type.code) {
|
|
818
831
|
// This cases are already handled with `{ignoreIfKnown: true}`
|