@lodestar/beacon-node 1.46.0-dev.281a8ee194 → 1.46.0-dev.3d8f7cf440
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 +37 -15
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +15 -6
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/blocks/importBlock.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.js +3 -3
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +3 -4
- package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
- package/lib/chain/blocks/index.d.ts.map +1 -1
- package/lib/chain/blocks/index.js +6 -0
- package/lib/chain/blocks/index.js.map +1 -1
- package/lib/chain/blocks/utils/chainSegment.d.ts.map +1 -1
- package/lib/chain/blocks/utils/chainSegment.js +31 -25
- package/lib/chain/blocks/utils/chainSegment.js.map +1 -1
- package/lib/chain/blocks/utils/polarBearBanner.d.ts +2 -0
- package/lib/chain/blocks/utils/polarBearBanner.d.ts.map +1 -0
- package/lib/chain/blocks/utils/polarBearBanner.js +51 -0
- package/lib/chain/blocks/utils/polarBearBanner.js.map +1 -0
- package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlock.js +12 -0
- package/lib/chain/blocks/verifyBlock.js.map +1 -1
- package/lib/chain/prepareNextSlot.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +74 -6
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +5 -5
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/seenCache/seenBlockProposers.d.ts +15 -4
- package/lib/chain/seenCache/seenBlockProposers.d.ts.map +1 -1
- package/lib/chain/seenCache/seenBlockProposers.js +35 -2
- package/lib/chain/seenCache/seenBlockProposers.js.map +1 -1
- package/lib/chain/validation/block.d.ts +4 -1
- package/lib/chain/validation/block.d.ts.map +1 -1
- package/lib/chain/validation/block.js +26 -15
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +13 -0
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +34 -0
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/reqresp/score.d.ts.map +1 -1
- package/lib/network/reqresp/score.js +20 -3
- package/lib/network/reqresp/score.js.map +1 -1
- package/lib/util/clock.d.ts +2 -7
- package/lib/util/clock.d.ts.map +1 -1
- package/lib/util/clock.js +2 -7
- package/lib/util/clock.js.map +1 -1
- package/package.json +15 -15
- package/src/api/impl/beacon/blocks/index.ts +60 -16
- package/src/api/impl/validator/index.ts +19 -6
- package/src/chain/blocks/importBlock.ts +3 -2
- package/src/chain/blocks/importExecutionPayload.ts +8 -4
- package/src/chain/blocks/index.ts +7 -0
- package/src/chain/blocks/utils/chainSegment.ts +35 -28
- package/src/chain/blocks/utils/polarBearBanner.ts +50 -0
- package/src/chain/blocks/verifyBlock.ts +16 -0
- package/src/chain/prepareNextSlot.ts +82 -6
- package/src/chain/produceBlock/produceBlockBody.ts +10 -5
- package/src/chain/seenCache/seenBlockProposers.ts +46 -5
- package/src/chain/validation/block.ts +36 -18
- package/src/metrics/metrics/lodestar.ts +35 -0
- package/src/network/reqresp/score.ts +22 -3
- package/src/util/clock.ts +2 -7
|
@@ -58,7 +58,7 @@ import {
|
|
|
58
58
|
ProduceFullGloas,
|
|
59
59
|
} from "../../../../chain/produceBlock/index.js";
|
|
60
60
|
import {RegenCaller} from "../../../../chain/regen/index.js";
|
|
61
|
-
import {validateGossipBlock} from "../../../../chain/validation/block.js";
|
|
61
|
+
import {validateGossipBlock, verifyBlockProposerSignature} from "../../../../chain/validation/block.js";
|
|
62
62
|
import {validateApiExecutionPayloadBid} from "../../../../chain/validation/executionPayloadBid.js";
|
|
63
63
|
import {validateApiExecutionPayloadEnvelope} from "../../../../chain/validation/executionPayloadEnvelope.js";
|
|
64
64
|
import {OpSource} from "../../../../chain/validatorMonitor.js";
|
|
@@ -268,7 +268,6 @@ export function getBeaconBlockApi({
|
|
|
268
268
|
await verifyBlocksInEpoch.call(chain as BeaconChain, parentBlock, [blockForImport], null, {
|
|
269
269
|
...opts,
|
|
270
270
|
verifyOnly: true,
|
|
271
|
-
skipVerifyBlockSignatures: true,
|
|
272
271
|
skipVerifyExecutionPayload: true,
|
|
273
272
|
seenTimestampSec,
|
|
274
273
|
});
|
|
@@ -285,12 +284,26 @@ export function getBeaconBlockApi({
|
|
|
285
284
|
|
|
286
285
|
chain.logger.debug("Consensus validated while publishing block", valLogMeta);
|
|
287
286
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
287
|
+
// Non-local blocks had their proposer and block-body signatures checked by verifyBlocksInEpoch above
|
|
288
|
+
// Locally produced blocks already passed block production validation, so only their proposer signature is unchecked
|
|
289
|
+
// Verify that signature and observe the block root here
|
|
290
|
+
if (blockLocallyProduced) {
|
|
291
|
+
try {
|
|
292
|
+
await verifyBlockProposerSignature(chain, signedBlock, blockRoot);
|
|
293
|
+
chain.seenBlockProposers.observeBlockRoot(slot, signedBlock.message.proposerIndex, blockRoot);
|
|
294
|
+
} catch (e) {
|
|
295
|
+
chain.logger.error(
|
|
296
|
+
"Proposer signature validation failed while publishing the block",
|
|
297
|
+
valLogMeta,
|
|
298
|
+
e as Error
|
|
299
|
+
);
|
|
300
|
+
chain.persistInvalidSszValue(
|
|
301
|
+
chain.config.getForkTypes(slot).SignedBeaconBlock,
|
|
302
|
+
signedBlock,
|
|
303
|
+
"api_reject_consensus_failure"
|
|
304
|
+
);
|
|
305
|
+
throw e;
|
|
292
306
|
}
|
|
293
|
-
chain.logger.warn(message, valLogMeta);
|
|
294
307
|
}
|
|
295
308
|
break;
|
|
296
309
|
}
|
|
@@ -318,6 +331,25 @@ export function getBeaconBlockApi({
|
|
|
318
331
|
await sleep(msToBlockSlot);
|
|
319
332
|
}
|
|
320
333
|
|
|
334
|
+
if (broadcastValidation === routes.beacon.BroadcastValidation.consensusAndEquivocation) {
|
|
335
|
+
const conflictingRoots = chain.seenBlockProposers.getConflictingBlockRoots(
|
|
336
|
+
slot,
|
|
337
|
+
signedBlock.message.proposerIndex,
|
|
338
|
+
blockRoot
|
|
339
|
+
);
|
|
340
|
+
if (conflictingRoots.length > 0) {
|
|
341
|
+
chain.logger.warn("Not publishing block due to proposer equivocation", {
|
|
342
|
+
...valLogMeta,
|
|
343
|
+
conflictingRoots: conflictingRoots.join(", "),
|
|
344
|
+
});
|
|
345
|
+
throw new ApiError(
|
|
346
|
+
400,
|
|
347
|
+
`Block is a proposer equivocation, conflicting block roots: ${conflictingRoots.join(", ")}`
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
chain.logger.debug("Equivocation validated while publishing the block", valLogMeta);
|
|
351
|
+
}
|
|
352
|
+
|
|
321
353
|
// TODO: Validate block
|
|
322
354
|
const delaySec = seenTimestampSec - computeTimeAtSlot(config, slot, chain.genesisTime);
|
|
323
355
|
metrics?.gossipBlock.elapsedTimeTillReceived.observe({source: OpSource.api}, delaySec);
|
|
@@ -775,15 +807,6 @@ export function getBeaconBlockApi({
|
|
|
775
807
|
throw new ApiError(400, (error as Error).message);
|
|
776
808
|
}
|
|
777
809
|
chain.logger.debug("Consensus validated while publishing execution payload envelope", valLogMeta);
|
|
778
|
-
|
|
779
|
-
// TODO GLOAS: check the block is not a proposer equivocation before publishing the envelope
|
|
780
|
-
if (broadcastValidation === routes.beacon.BroadcastValidation.consensusAndEquivocation) {
|
|
781
|
-
const message = `Equivocation checks not yet implemented for broadcastValidation=${broadcastValidation}`;
|
|
782
|
-
if (chain.opts.broadcastValidationStrictness === "error") {
|
|
783
|
-
throw Error(message);
|
|
784
|
-
}
|
|
785
|
-
chain.logger.warn(message, valLogMeta);
|
|
786
|
-
}
|
|
787
810
|
break;
|
|
788
811
|
}
|
|
789
812
|
|
|
@@ -886,6 +909,27 @@ export function getBeaconBlockApi({
|
|
|
886
909
|
await sleep(msToBlockSlot);
|
|
887
910
|
}
|
|
888
911
|
|
|
912
|
+
// Keep this as the final async validation before publishing. A conflicting block may be observed while the
|
|
913
|
+
// envelope, blob data, or slot timing is being validated above.
|
|
914
|
+
if (broadcastValidation === routes.beacon.BroadcastValidation.consensusAndEquivocation) {
|
|
915
|
+
const conflictingRoots = chain.seenBlockProposers.getConflictingBlockRoots(
|
|
916
|
+
slot,
|
|
917
|
+
payloadInput.proposerIndex,
|
|
918
|
+
blockRootHex
|
|
919
|
+
);
|
|
920
|
+
if (conflictingRoots.length > 0) {
|
|
921
|
+
chain.logger.warn("Not publishing execution payload envelope due to proposer equivocation", {
|
|
922
|
+
...valLogMeta,
|
|
923
|
+
conflictingRoots: conflictingRoots.join(", "),
|
|
924
|
+
});
|
|
925
|
+
throw new ApiError(
|
|
926
|
+
400,
|
|
927
|
+
`Block of execution payload envelope is a proposer equivocation, conflicting block roots: ${conflictingRoots.join(", ")}`
|
|
928
|
+
);
|
|
929
|
+
}
|
|
930
|
+
chain.logger.debug("Equivocation validated while publishing execution payload envelope", valLogMeta);
|
|
931
|
+
}
|
|
932
|
+
|
|
889
933
|
if (payloadInput.hasPayloadEnvelope()) {
|
|
890
934
|
// The envelope may have been added while this request was being validated, e.g. via gossip
|
|
891
935
|
chain.logger.debug("Execution payload envelope already added during publishing", valLogMeta);
|
|
@@ -339,12 +339,13 @@ export function getValidatorApi(
|
|
|
339
339
|
* Following activities should be skipped on an Optimistic head (with Syncing status):
|
|
340
340
|
* 1. Attestation if targetRoot is optimistic
|
|
341
341
|
* 2. SyncCommitteeContribution if if the root for which to produce contribution is Optimistic.
|
|
342
|
-
* 3. ProduceBlock if the parentRoot (chain's current head is optimistic
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
342
|
+
* 3. ProduceBlock if the parentRoot (chain's current head) is optimistic. Must be checked
|
|
343
|
+
* explicitly as only local payload production consults the EL, blinded blocks from an
|
|
344
|
+
* external builder or bid based blocks (gloas) can be produced without a synced EL.
|
|
345
|
+
* 4. SyncCommitteeSignature (base sync committee message) is aborted in the validator client
|
|
346
|
+
* (see SyncCommitteeService) when the head root it would sign is optimistic, since it is
|
|
347
|
+
* produced from the head root without a beacon-node produce endpoint to gate here. Spec:
|
|
348
|
+
* https://github.com/ethereum/consensus-specs/blob/v1.6.1/sync/optimistic.md#participating-in-sync-committees
|
|
348
349
|
*/
|
|
349
350
|
|
|
350
351
|
function notOnOptimisticBlockRoot(beaconBlockRoot: Root): void {
|
|
@@ -545,6 +546,12 @@ export function getValidatorApi(
|
|
|
545
546
|
const parentBlock = chain.getProposerHead(slot);
|
|
546
547
|
const {blockRoot: parentBlockRootHex, slot: parentSlot} = parentBlock;
|
|
547
548
|
const parentBlockRoot = fromHex(parentBlockRootHex);
|
|
549
|
+
// An optimistic validator MUST NOT produce a block
|
|
550
|
+
if (isOptimisticBlock(parentBlock)) {
|
|
551
|
+
throw new NodeIsSyncing(
|
|
552
|
+
`Parent block's execution payload not yet validated, executionPayloadBlockHash=${parentBlock.executionPayloadBlockHash}`
|
|
553
|
+
);
|
|
554
|
+
}
|
|
548
555
|
notOnOutOfRangeData(parentBlockRoot);
|
|
549
556
|
metrics?.blockProductionSlotDelta.set(slot - parentSlot);
|
|
550
557
|
|
|
@@ -870,6 +877,12 @@ export function getValidatorApi(
|
|
|
870
877
|
const parentBlock = chain.getProposerHead(slot);
|
|
871
878
|
const {blockRoot: parentBlockRootHex, slot: parentSlot} = parentBlock;
|
|
872
879
|
const parentBlockRoot = fromHex(parentBlockRootHex);
|
|
880
|
+
// An optimistic validator MUST NOT produce a block
|
|
881
|
+
if (isOptimisticBlock(parentBlock)) {
|
|
882
|
+
throw new NodeIsSyncing(
|
|
883
|
+
`Parent block's execution payload not yet validated, executionPayloadBlockHash=${parentBlock.executionPayloadBlockHash}`
|
|
884
|
+
);
|
|
885
|
+
}
|
|
873
886
|
notOnOutOfRangeData(parentBlockRoot);
|
|
874
887
|
metrics?.blockProductionSlotDelta.set(slot - parentSlot);
|
|
875
888
|
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
ForkChoiceError,
|
|
7
7
|
ForkChoiceErrorCode,
|
|
8
8
|
NotReorgedReason,
|
|
9
|
+
getFinalizedExecutionBlockHash,
|
|
9
10
|
getSafeExecutionBlockHash,
|
|
10
11
|
} from "@lodestar/fork-choice";
|
|
11
12
|
import {
|
|
@@ -443,8 +444,8 @@ export async function importBlock(
|
|
|
443
444
|
* the current finalized block does not contain any execution payload at all (pre MERGE_EPOCH) or if it contains a
|
|
444
445
|
* zero block hash (pre TTD)
|
|
445
446
|
*/
|
|
446
|
-
const safeBlockHash = getSafeExecutionBlockHash(this.forkChoice);
|
|
447
|
-
const finalizedBlockHash = this.forkChoice.
|
|
447
|
+
const safeBlockHash = getSafeExecutionBlockHash(this.forkChoice, this.logger);
|
|
448
|
+
const finalizedBlockHash = getFinalizedExecutionBlockHash(this.forkChoice, this.logger);
|
|
448
449
|
if (headBlockHash !== ZERO_HASH_HEX) {
|
|
449
450
|
this.executionEngine
|
|
450
451
|
.notifyForkchoiceUpdate(
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import {routes} from "@lodestar/api";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ExecutionStatus,
|
|
4
|
+
PayloadExecutionStatus,
|
|
5
|
+
getFinalizedExecutionBlockHash,
|
|
6
|
+
getSafeExecutionBlockHash,
|
|
7
|
+
} from "@lodestar/fork-choice";
|
|
3
8
|
import {DataAvailabilityStatus, isStatePostGloas} from "@lodestar/state-transition";
|
|
4
9
|
import {isErrorAborted} from "@lodestar/utils";
|
|
5
|
-
import {ZERO_HASH_HEX} from "../../constants/index.js";
|
|
6
10
|
import {ExecutionPayloadStatus} from "../../execution/index.js";
|
|
7
11
|
import {isQueueErrorAborted} from "../../util/queue/index.js";
|
|
8
12
|
import {BeaconChain} from "../chain.js";
|
|
@@ -245,8 +249,8 @@ export async function importExecutionPayload(
|
|
|
245
249
|
// 7. Queue notifyForkchoiceUpdate to engine api
|
|
246
250
|
const head = this.forkChoice.getHead();
|
|
247
251
|
if (!this.opts.disableImportExecutionFcU && blockRootHex === head.blockRoot) {
|
|
248
|
-
const safeBlockHash = getSafeExecutionBlockHash(this.forkChoice);
|
|
249
|
-
const finalizedBlockHash = this.forkChoice.
|
|
252
|
+
const safeBlockHash = getSafeExecutionBlockHash(this.forkChoice, this.logger);
|
|
253
|
+
const finalizedBlockHash = getFinalizedExecutionBlockHash(this.forkChoice, this.logger);
|
|
250
254
|
this.executionEngine.notifyForkchoiceUpdate(fork, blockHashHex, safeBlockHash, finalizedBlockHash).catch((e) => {
|
|
251
255
|
if (!isErrorAborted(e) && !isQueueErrorAborted(e)) {
|
|
252
256
|
this.logger.error("Error pushing notifyForkchoiceUpdate()", {blockHashHex, finalizedBlockHash}, e);
|
|
@@ -108,6 +108,13 @@ export async function processBlocks(
|
|
|
108
108
|
throw segmentExecStatus.execAborted.execError;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
if (opts.skipVerifyBlockSignatures !== true) {
|
|
112
|
+
for (const blockInput of relevantBlocks) {
|
|
113
|
+
const block = blockInput.getBlock().message;
|
|
114
|
+
this.seenBlockProposers.add(block.slot, block.proposerIndex);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
111
118
|
const {executionStatuses} = segmentExecStatus;
|
|
112
119
|
const verifiedBlocksBySlot = new Map<Slot, FullyVerifiedBlock>();
|
|
113
120
|
for (let i = 0; i < relevantBlocks.length; i++) {
|
|
@@ -31,23 +31,40 @@ export function assertLinearChainSegment(
|
|
|
31
31
|
payloadEnvelopes: Map<Slot, PayloadEnvelopeInput> | null,
|
|
32
32
|
parentBlock: ProtoBlock | null
|
|
33
33
|
): ChainSegmentResult {
|
|
34
|
+
if (blocks.length === 0) {
|
|
35
|
+
return {warnings: null};
|
|
36
|
+
}
|
|
37
|
+
|
|
34
38
|
const warnings: OrphanedPayloadEnvelope[] = [];
|
|
35
39
|
|
|
36
|
-
|
|
37
|
-
// Starts from the known forkchoice parent's execution hash.
|
|
38
|
-
// - FULL variant (envelope present for slot): advances to envelope.payload.blockHash
|
|
39
|
-
// - EMPTY variant (no envelope for slot): execution hash is unchanged
|
|
40
|
-
let currentExecHash: string | null = parentBlock?.executionPayloadBlockHash ?? null;
|
|
41
|
-
// Checkpoint sync first batch: parent is the anchor PENDING whose executionPayloadBlockHash
|
|
42
|
-
// is the inherited parentBlockHash semantic (= grandparent's payload), not its own payload.
|
|
43
|
-
// If parent's own payload envelope arrives in this batch, advance currentExecHash to that
|
|
44
|
-
// payload's blockHash so the segment validation sees the true EL chain head.
|
|
40
|
+
let parentExecHash: string | null = parentBlock?.executionPayloadBlockHash ?? null;
|
|
45
41
|
if (parentBlock !== null) {
|
|
46
42
|
const parentPayloadInput = payloadEnvelopes?.get(parentBlock.slot);
|
|
47
43
|
if (parentPayloadInput?.hasPayloadEnvelope()) {
|
|
48
|
-
|
|
44
|
+
// Checkpoint-sync first batch: the anchor is stored PENDING with the inherited (grandparent)
|
|
45
|
+
// hash, not its own payload. Its payload envelope is in this batch, so use that blockHash as
|
|
46
|
+
// the real parent EL head.
|
|
47
|
+
parentExecHash = parentPayloadInput.getBlockHashHex();
|
|
49
48
|
}
|
|
50
49
|
}
|
|
50
|
+
|
|
51
|
+
// Track the expected execution payload block hash through the segment, seeded from the FIRST
|
|
52
|
+
// block's own bid
|
|
53
|
+
const firstBlockMessage = blocks[0].getBlock().message;
|
|
54
|
+
let currentExecHash: string | null = isGloasBeaconBlock(firstBlockMessage)
|
|
55
|
+
? toRootHex(firstBlockMessage.body.signedExecutionPayloadBid.message.parentBlockHash)
|
|
56
|
+
: null;
|
|
57
|
+
|
|
58
|
+
// First block must build on the parent's EL head. PARENT_PAYLOAD_UNKNOWN (vs the in-segment
|
|
59
|
+
// NON_LINEAR_PAYLOAD_ROOTS below) tells range sync this is a parent-link problem, not an in-batch one.
|
|
60
|
+
if (parentExecHash !== null && currentExecHash !== null && currentExecHash !== parentExecHash) {
|
|
61
|
+
throw new BlockError(blocks[0].getBlock(), {
|
|
62
|
+
code: BlockErrorCode.PARENT_PAYLOAD_UNKNOWN,
|
|
63
|
+
parentRoot: toRootHex(firstBlockMessage.parentRoot),
|
|
64
|
+
parentBlockHash: currentExecHash,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
51
68
|
// Track the execution hash before the last FULL advancement so we can recover
|
|
52
69
|
// if the next block reveals that envelope was orphaned.
|
|
53
70
|
let prevExecHash: string | null = currentExecHash;
|
|
@@ -76,8 +93,7 @@ export function assertLinearChainSegment(
|
|
|
76
93
|
}
|
|
77
94
|
|
|
78
95
|
if (isGloasBeaconBlock(block.message)) {
|
|
79
|
-
//
|
|
80
|
-
// chain is seeded mid-segment by the first FULL envelope.
|
|
96
|
+
// currentExecHash and prevExecHash are only null for a pre-gloas first block (fork-transition segment); always set post-gloas.
|
|
81
97
|
if (currentExecHash !== null) {
|
|
82
98
|
// Verify the bid's parentBlockHash matches the tracked execution hash.
|
|
83
99
|
// This ensures the block was built on the correct FULL or EMPTY variant of its parent.
|
|
@@ -86,22 +102,13 @@ export function assertLinearChainSegment(
|
|
|
86
102
|
// Maybe the previous slot's FULL envelope was orphaned — try falling back.
|
|
87
103
|
// If even prevExecHash doesn't match, the segment is non-linear.
|
|
88
104
|
if (bidParentHash !== prevExecHash) {
|
|
89
|
-
//
|
|
90
|
-
//
|
|
91
|
-
throw new BlockError(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
parentRoot: toRootHex(block.message.parentRoot),
|
|
97
|
-
parentBlockHash: bidParentHash,
|
|
98
|
-
}
|
|
99
|
-
: {
|
|
100
|
-
code: BlockErrorCode.NON_LINEAR_PAYLOAD_ROOTS,
|
|
101
|
-
parentBlockHash: bidParentHash,
|
|
102
|
-
expectedBlockHash: currentExecHash,
|
|
103
|
-
}
|
|
104
|
-
);
|
|
105
|
+
// Broken link inside the segment: throw NON_LINEAR_PAYLOAD_ROOTS instead of PARENT_PAYLOAD_UNKNOWN
|
|
106
|
+
// this is important for range sync to handle accordingly
|
|
107
|
+
throw new BlockError(block, {
|
|
108
|
+
code: BlockErrorCode.NON_LINEAR_PAYLOAD_ROOTS,
|
|
109
|
+
parentBlockHash: bidParentHash,
|
|
110
|
+
expectedBlockHash: currentExecHash,
|
|
111
|
+
});
|
|
105
112
|
}
|
|
106
113
|
if (lastFullSlot !== null && payloadEnvelopes !== null) {
|
|
107
114
|
const orphanedInput = payloadEnvelopes.get(lastFullSlot);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export const GLOAS_POLAR_BEAR_BANNER = String.raw`
|
|
2
|
+
|
|
3
|
+
__ . .- '%%%░░░░░
|
|
4
|
+
/ '-. , ' '%%%░░░░
|
|
5
|
+
_.--""""--.._; . * .-' '%%%%░░
|
|
6
|
+
\ / _."" .' '-._ ' . '%%%%
|
|
7
|
+
L ."; ; ; '-. . / ' * '""
|
|
8
|
+
Ø / / .' ' ; '. ' ; |
|
|
9
|
+
D / ; e ' ) ( ' ; \ . .' ,:
|
|
10
|
+
E ; : P ( ' ) : '-.\ ' '
|
|
11
|
+
S ; ; B ).( '. '; ' '
|
|
12
|
+
T : : S (/:\) \ :
|
|
13
|
+
A : \ ': / : \ \ '.;
|
|
14
|
+
R \ \ '; \\ // ; ;
|
|
15
|
+
/ \ \ : .' \ \|/ | /
|
|
16
|
+
'>' : ' '.; |
|
|
17
|
+
/ ,' / '. ;/ _\
|
|
18
|
+
;,' ; '. '.; '-.
|
|
19
|
+
;' .' : '. '. / \, \ \ \
|
|
20
|
+
\ :,' : '. '. \ ; ::\_/_/_/::
|
|
21
|
+
~| .-=:.-" -,- "-.,=-.\ ;.; :::; ; ;::
|
|
22
|
+
~|\ |('.' : .')| \: '. :::::::
|
|
23
|
+
~|:\ \\/ : \// ; \ _____
|
|
24
|
+
~~\:\ ■ : .:. : _/ ; \hjw:
|
|
25
|
+
~~~\/ | ; ; ; | \"""
|
|
26
|
+
~~.' ■ : _ _ ; / ; /|~~
|
|
27
|
+
~/ | '. \'; ;'/ .' .' / /:|~~
|
|
28
|
+
| ■ ! : : !_.' / .--::/~~~
|
|
29
|
+
|\___ | '.: :.'/\ ; ____.':|:|/~~~~
|
|
30
|
+
\:::|\ ■ \'_'/ | : : ___/|:::|:'"""~~~~~
|
|
31
|
+
~'""|:\ | ;"^" | ! :__/|::|/""""~~~~~~~~~~
|
|
32
|
+
~~~~\::\_____ .-' | ; |::|/""~~~~~~~~~~~~~~~~
|
|
33
|
+
~~~~~\:|::::|\ / / / / / /"""~~~~~~~~~~~~~~~~~~~~
|
|
34
|
+
~~~~~~\|::::|:'--\_\_\__.'-| ;~~~~~~~~~~~~~~~~~~~~~~~~
|
|
35
|
+
~~~~~~~~""""~\::::::::::::/ .'~~~~~~~~~~~~~<><~~~~~~~~~
|
|
36
|
+
~~~~~~~~~~~~~~""""'"""".-' /~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
37
|
+
~~~~~~~__,------.__.--/ , , , |/--._~~~~~~~~~~~~~~~~~~~~~~~
|
|
38
|
+
~~~~~~/ | . :\| | |v' \__~~~~~~~~~~~~~~~~~~~~
|
|
39
|
+
~~~~~|\ ■ /:\ :::v-;v-':: \_~~~~~~~~~~~~~~~~~~
|
|
40
|
+
~~~~~\:\ / : \ ::::::::: \~~~~~~~~~~~~~~~~~
|
|
41
|
+
~~~~~~\|'-. / : \ /|~~~~~~~~~~~~~~~~
|
|
42
|
+
~~~~~~~~': \ \'. ,'/ ___ ____/:/~~~~~~~~~<><~~~~
|
|
43
|
+
~~~~~~~~~~\|: \ ' / /|:|\ /|:::|/~~~~~~~~~~~~~~~~~
|
|
44
|
+
~~~~~~~~~~~|: \:/ //"""\\ /:/"""~~~~~~~~~~~~~~~~~~~
|
|
45
|
+
~~~><>~~~~~|\ ' //~~~~~\\______/:/~~~~~~~~~~~~~~~~~~~~~~~
|
|
46
|
+
~~~~~~~~~~~'|\____//~~~~~~~\|GLOAS|/~~~~~~~~<><~~~~~~~~~~~~~
|
|
47
|
+
~~~~~~~~~~~~\|:::|/~~~~~~~~~'"""""'~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
48
|
+
~~~~~~~~~~~~~'"""'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
49
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~eth
|
|
50
|
+
`;
|
|
@@ -2,6 +2,7 @@ import {ExecutionStatus, ProtoBlock} from "@lodestar/fork-choice";
|
|
|
2
2
|
import {ForkName, ForkSeq, isForkPostFulu} from "@lodestar/params";
|
|
3
3
|
import {DataAvailabilityStatus, IBeaconStateView, computeEpochAtSlot} from "@lodestar/state-transition";
|
|
4
4
|
import {IndexedAttestation, Slot, deneb} from "@lodestar/types";
|
|
5
|
+
import {toRootHex} from "@lodestar/utils";
|
|
5
6
|
import {getBlobKzgCommitments} from "../../util/dataColumns.js";
|
|
6
7
|
import type {BeaconChain} from "../chain.js";
|
|
7
8
|
import {BlockError, BlockErrorCode} from "../errors/index.js";
|
|
@@ -13,6 +14,7 @@ import {ImportBlockOpts} from "./types.js";
|
|
|
13
14
|
import {DENEB_BLOWFISH_BANNER} from "./utils/blowfishBanner.js";
|
|
14
15
|
import {ELECTRA_GIRAFFE_BANNER} from "./utils/giraffeBanner.js";
|
|
15
16
|
import {CAPELLA_OWL_BANNER} from "./utils/ownBanner.js";
|
|
17
|
+
import {GLOAS_POLAR_BEAR_BANNER} from "./utils/polarBearBanner.js";
|
|
16
18
|
import {FULU_ZEBRA_BANNER} from "./utils/zebraBanner.js";
|
|
17
19
|
import {verifyBlocksDataAvailability} from "./verifyBlocksDataAvailability.js";
|
|
18
20
|
import {SegmentExecStatus, verifyBlocksExecutionPayload} from "./verifyBlocksExecutionPayloads.js";
|
|
@@ -203,6 +205,15 @@ export async function verifyBlocksInEpoch(
|
|
|
203
205
|
// maybe chain with the above verifyBlocksSignatures()
|
|
204
206
|
]);
|
|
205
207
|
|
|
208
|
+
if (opts.skipVerifyBlockSignatures !== true) {
|
|
209
|
+
for (const block of blocks) {
|
|
210
|
+
const blockRoot = toRootHex(
|
|
211
|
+
this.config.getForkTypes(block.message.slot).BeaconBlock.hashTreeRoot(block.message)
|
|
212
|
+
);
|
|
213
|
+
this.seenBlockProposers.observeBlockRoot(block.message.slot, block.message.proposerIndex, blockRoot);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
206
217
|
if (opts.verifyOnly !== true) {
|
|
207
218
|
const fromForkBoundary = this.config.getForkBoundaryAtEpoch(computeEpochAtSlot(parentBlock.slot));
|
|
208
219
|
const toForkBoundary = this.config.getForkBoundaryAtEpoch(computeEpochAtSlot(lastBlock.message.slot));
|
|
@@ -230,6 +241,11 @@ export async function verifyBlocksInEpoch(
|
|
|
230
241
|
this.logger.info("Activating peerDAS", {epoch: this.config.FULU_FORK_EPOCH});
|
|
231
242
|
break;
|
|
232
243
|
|
|
244
|
+
case ForkName.gloas:
|
|
245
|
+
this.logger.info(GLOAS_POLAR_BEAR_BANNER);
|
|
246
|
+
this.logger.info("Activating ePBS", {epoch: this.config.GLOAS_FORK_EPOCH});
|
|
247
|
+
break;
|
|
248
|
+
|
|
233
249
|
default:
|
|
234
250
|
}
|
|
235
251
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {routes} from "@lodestar/api";
|
|
2
2
|
import {ChainForkConfig} from "@lodestar/config";
|
|
3
|
-
import {getSafeExecutionBlockHash} from "@lodestar/fork-choice";
|
|
3
|
+
import {getFinalizedExecutionBlockHash, getSafeExecutionBlockHash} from "@lodestar/fork-choice";
|
|
4
4
|
import {
|
|
5
5
|
ForkPostBellatrix,
|
|
6
6
|
ForkSeq,
|
|
@@ -10,17 +10,20 @@ import {
|
|
|
10
10
|
isForkPostGloas,
|
|
11
11
|
} from "@lodestar/params";
|
|
12
12
|
import {
|
|
13
|
+
GLOAS_PREVERIFY_WINDOW_EPOCHS,
|
|
13
14
|
IBeaconStateView,
|
|
14
15
|
IBeaconStateViewBellatrix,
|
|
16
|
+
MAX_BUILDER_DEPOSITS_PER_SLOT,
|
|
15
17
|
StateHashTreeRootSource,
|
|
16
18
|
computeEpochAtSlot,
|
|
17
19
|
computeTimeAtSlot,
|
|
18
20
|
isStatePostBellatrix,
|
|
21
|
+
isStatePostFulu,
|
|
19
22
|
isStatePostGloas,
|
|
20
23
|
} from "@lodestar/state-transition";
|
|
21
24
|
import {Bytes32, Slot, ValidatorIndex} from "@lodestar/types";
|
|
22
25
|
import {Logger, fromHex, isErrorAborted, sleep} from "@lodestar/utils";
|
|
23
|
-
import {GENESIS_SLOT
|
|
26
|
+
import {GENESIS_SLOT} from "../constants/constants.js";
|
|
24
27
|
import {BuilderStatus} from "../execution/builder/http.js";
|
|
25
28
|
import {Metrics} from "../metrics/index.js";
|
|
26
29
|
import {ClockEvent} from "../util/clock.js";
|
|
@@ -37,6 +40,11 @@ export const PREPARE_NEXT_SLOT_BPS = 6667;
|
|
|
37
40
|
/* We don't want to do more epoch transition than this */
|
|
38
41
|
const PREPARE_EPOCH_LIMIT = 1;
|
|
39
42
|
|
|
43
|
+
/* Fraction of a slot (out of 10_000) the pre-Gloas builder-deposit pre-verify may spend per tick.
|
|
44
|
+
* 2000 = 20% of slot (2.4s on mainnet), within the spare window left after PREPARE_NEXT_SLOT_BPS.
|
|
45
|
+
* Expressed in bps so it scales with slot duration (mainnet vs minimal/devnet). */
|
|
46
|
+
const BUILDER_PREVERIFY_LIMIT_BPS = 2000;
|
|
47
|
+
|
|
40
48
|
/**
|
|
41
49
|
* At Bellatrix, if we are responsible for proposing in next slot, we want to prepare payload
|
|
42
50
|
* 4s before the start of next slot at PREPARE_NEXT_SLOT_BPS of the current slot.
|
|
@@ -117,6 +125,7 @@ export class PrepareNextSlotScheduler {
|
|
|
117
125
|
? this.metrics?.precomputeNextEpochTransition.duration.startTimer()
|
|
118
126
|
: null;
|
|
119
127
|
const start = Date.now();
|
|
128
|
+
let feeRecipient: string | undefined;
|
|
120
129
|
// No need to wait for this or the clock drift
|
|
121
130
|
if (isForkPostBellatrix(fork)) {
|
|
122
131
|
let preparedState: IBeaconStateView | undefined;
|
|
@@ -140,7 +149,7 @@ export class PrepareNextSlotScheduler {
|
|
|
140
149
|
};
|
|
141
150
|
|
|
142
151
|
const proposerIndex = await getProposerIndex();
|
|
143
|
-
|
|
152
|
+
feeRecipient = this.chain.beaconProposerCache.get(proposerIndex);
|
|
144
153
|
|
|
145
154
|
if (feeRecipient) {
|
|
146
155
|
// If we are proposing next slot, we need to predict if we can proposer-boost-reorg or not
|
|
@@ -214,9 +223,8 @@ export class PrepareNextSlotScheduler {
|
|
|
214
223
|
computeTimeAtSlot(this.config, prepareSlot, this.chain.genesisTime) - Date.now() / 1000;
|
|
215
224
|
this.metrics?.blockPayload.payloadAdvancePrepTime.observe(preparationTime);
|
|
216
225
|
|
|
217
|
-
const safeBlockHash = getSafeExecutionBlockHash(this.chain.forkChoice);
|
|
218
|
-
const finalizedBlockHash =
|
|
219
|
-
this.chain.forkChoice.getFinalizedBlock().executionPayloadBlockHash ?? ZERO_HASH_HEX;
|
|
226
|
+
const safeBlockHash = getSafeExecutionBlockHash(this.chain.forkChoice, this.logger);
|
|
227
|
+
const finalizedBlockHash = getFinalizedExecutionBlockHash(this.chain.forkChoice, this.logger);
|
|
220
228
|
|
|
221
229
|
// awaiting here instead of throwing an async call because there is no other task
|
|
222
230
|
// left for scheduler and this gives nice semantics to catch and log errors in the
|
|
@@ -287,6 +295,74 @@ export class PrepareNextSlotScheduler {
|
|
|
287
295
|
});
|
|
288
296
|
|
|
289
297
|
precomputeEpochTransitionTimer?.();
|
|
298
|
+
|
|
299
|
+
// Nothing more to do on an epoch-transition slot: that precompute already ran a full (>1s)
|
|
300
|
+
// epoch transition, so we don't pile the builder-deposit pre-verify (below) on top of it.
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// Pre-verify builder-deposit signatures in the GLOAS_PREVERIFY_WINDOW_EPOCHS epochs leading
|
|
305
|
+
// up to the Gloas fork, off the block-import hot path, so onboardBuildersFromPendingDeposits
|
|
306
|
+
// at the transition is mostly cache hits. Reached only on non-epoch-transition slots (the
|
|
307
|
+
// epoch-transition branch returned above). Runs on the head state — its pendingDeposits are
|
|
308
|
+
// what the fork transition derives from, and its epochCtx holds the shared, app-wide
|
|
309
|
+
// builderDepositSignatureCache.
|
|
310
|
+
const headState = this.chain.getHeadState();
|
|
311
|
+
if (isStatePostFulu(headState)) {
|
|
312
|
+
const gloasEpoch = this.config.GLOAS_FORK_EPOCH;
|
|
313
|
+
const finalizedEpoch = this.chain.forkChoice.getFinalizedCheckpoint().epoch;
|
|
314
|
+
if (finalizedEpoch >= gloasEpoch) {
|
|
315
|
+
// Gloas is finalized — the pre-verify cache has served its purpose; release its memory.
|
|
316
|
+
headState.clearPreGloasBuilderDepositCache();
|
|
317
|
+
} else {
|
|
318
|
+
const clockEpoch = computeEpochAtSlot(clockSlot);
|
|
319
|
+
if (
|
|
320
|
+
ForkSeq[fork] < ForkSeq.gloas && // only before the fork
|
|
321
|
+
clockEpoch >= gloasEpoch - GLOAS_PREVERIFY_WINDOW_EPOCHS && // Infinity when Gloas unscheduled → skip
|
|
322
|
+
clockEpoch < gloasEpoch &&
|
|
323
|
+
// skip when we're the next-slot proposer — don't compete with block-production prep.
|
|
324
|
+
feeRecipient === undefined
|
|
325
|
+
) {
|
|
326
|
+
const maxDurationMs = this.config.getSlotComponentDurationMs(BUILDER_PREVERIFY_LIMIT_BPS);
|
|
327
|
+
const preVerifyTimer = this.metrics?.builderDepositPreVerify.duration.startTimer();
|
|
328
|
+
const result = headState.preVerifyBuilderDepositsPreGloas(MAX_BUILDER_DEPOSITS_PER_SLOT, maxDurationMs);
|
|
329
|
+
preVerifyTimer?.();
|
|
330
|
+
|
|
331
|
+
const preVerifyMetrics = this.metrics?.builderDepositPreVerify;
|
|
332
|
+
if (preVerifyMetrics) {
|
|
333
|
+
preVerifyMetrics.pendingDeposits.set(result.pendingDepositsCount);
|
|
334
|
+
preVerifyMetrics.cachedDeposits.set(result.totalCachedDeposits);
|
|
335
|
+
preVerifyMetrics.scannedDeposits.set(result.scannedPendingDeposits);
|
|
336
|
+
preVerifyMetrics.builderPubkeys.set(result.totalBuilderPubkeys);
|
|
337
|
+
if (result.validBuilderSignaturesCount > 0) {
|
|
338
|
+
preVerifyMetrics.validSignatures.inc({type: "builder"}, result.validBuilderSignaturesCount);
|
|
339
|
+
}
|
|
340
|
+
if (result.validValidatorSignaturesCount > 0) {
|
|
341
|
+
preVerifyMetrics.validSignatures.inc({type: "validator"}, result.validValidatorSignaturesCount);
|
|
342
|
+
}
|
|
343
|
+
if (result.invalidBuilderSignaturesCount > 0) {
|
|
344
|
+
preVerifyMetrics.invalidSignatures.inc({type: "builder"}, result.invalidBuilderSignaturesCount);
|
|
345
|
+
}
|
|
346
|
+
if (result.invalidValidatorSignaturesCount > 0) {
|
|
347
|
+
preVerifyMetrics.invalidSignatures.inc({type: "validator"}, result.invalidValidatorSignaturesCount);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// Always log (once per slot, only within the pre-fork window) so devnets show the
|
|
352
|
+
// pre-verify draining even on all-cache-hit ticks.
|
|
353
|
+
this.logger.verbose("PrepareNextSlotScheduler pre-verified deposit signatures", {
|
|
354
|
+
clockSlot,
|
|
355
|
+
validBuilderSignaturesCount: result.validBuilderSignaturesCount,
|
|
356
|
+
invalidBuilderSignaturesCount: result.invalidBuilderSignaturesCount,
|
|
357
|
+
validValidatorSignaturesCount: result.validValidatorSignaturesCount,
|
|
358
|
+
invalidValidatorSignaturesCount: result.invalidValidatorSignaturesCount,
|
|
359
|
+
scannedPendingDeposits: result.scannedPendingDeposits,
|
|
360
|
+
totalCachedDeposits: result.totalCachedDeposits,
|
|
361
|
+
totalBuilderPubkeys: result.totalBuilderPubkeys,
|
|
362
|
+
pendingDepositsCount: result.pendingDepositsCount,
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
}
|
|
290
366
|
}
|
|
291
367
|
} catch (e) {
|
|
292
368
|
if (!isErrorAborted(e) && !isQueueErrorAborted(e)) {
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import {BitArray} from "@chainsafe/ssz";
|
|
2
2
|
import {ChainForkConfig} from "@lodestar/config";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
IForkChoice,
|
|
5
|
+
ProtoBlock,
|
|
6
|
+
getFinalizedExecutionBlockHash,
|
|
7
|
+
getSafeExecutionBlockHash,
|
|
8
|
+
} from "@lodestar/fork-choice";
|
|
4
9
|
import {
|
|
5
10
|
BUILDER_INDEX_SELF_BUILD,
|
|
6
11
|
ForkName,
|
|
@@ -265,8 +270,8 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
265
270
|
// TODO GLOAS: support non self-building here, the block type differentiation between
|
|
266
271
|
// full and blinded no longer makes sense in gloas, it might be a good idea to move
|
|
267
272
|
// this into a completely separate function and have pre/post gloas more separated
|
|
268
|
-
const safeBlockHash = getSafeExecutionBlockHash(this.forkChoice);
|
|
269
|
-
const finalizedBlockHash = this.forkChoice.
|
|
273
|
+
const safeBlockHash = getSafeExecutionBlockHash(this.forkChoice, this.logger);
|
|
274
|
+
const finalizedBlockHash = getFinalizedExecutionBlockHash(this.forkChoice, this.logger);
|
|
270
275
|
// TODO GLOAS: post-Gloas, proposer feeRecipient is also carried (signed) in
|
|
271
276
|
// ProposerPreferencesPool. Consider using this unified cache instead
|
|
272
277
|
// see https://github.com/ChainSafe/lodestar/issues/9379
|
|
@@ -411,8 +416,8 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
411
416
|
throw new Error("Expected Bellatrix state for execution block production");
|
|
412
417
|
}
|
|
413
418
|
|
|
414
|
-
const safeBlockHash = getSafeExecutionBlockHash(this.forkChoice);
|
|
415
|
-
const finalizedBlockHash = this.forkChoice.
|
|
419
|
+
const safeBlockHash = getSafeExecutionBlockHash(this.forkChoice, this.logger);
|
|
420
|
+
const finalizedBlockHash = getFinalizedExecutionBlockHash(this.forkChoice, this.logger);
|
|
416
421
|
const feeRecipient = requestedFeeRecipient ?? this.beaconProposerCache.getOrDefault(proposerIndex);
|
|
417
422
|
const feeRecipientType = requestedFeeRecipient
|
|
418
423
|
? "requested"
|