@lodestar/beacon-node 1.46.0-dev.e6f04acd82 → 1.46.0-dev.f0f5d069e2
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 +21 -1
- package/lib/chain/blocks/verifyBlock.js.map +1 -1
- package/lib/chain/chain.d.ts +5 -0
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +50 -0
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/emitter.d.ts +6 -0
- package/lib/chain/emitter.d.ts.map +1 -1
- package/lib/chain/emitter.js +5 -0
- package/lib/chain/emitter.js.map +1 -1
- package/lib/chain/interface.d.ts +2 -0
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/options.d.ts +2 -0
- package/lib/chain/options.d.ts.map +1 -1
- package/lib/chain/options.js +1 -0
- package/lib/chain/options.js.map +1 -1
- package/lib/chain/prepareNextSlot.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +107 -29
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +6 -6
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/seenCache/seenBlockProposers.d.ts +20 -4
- package/lib/chain/seenCache/seenBlockProposers.d.ts.map +1 -1
- package/lib/chain/seenCache/seenBlockProposers.js +49 -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 +32 -18
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.js +21 -16
- package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +14 -0
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +38 -0
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/network.d.ts +1 -0
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js +11 -1
- package/lib/network/network.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +8 -0
- package/lib/network/processor/gossipHandlers.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 +65 -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 +28 -2
- package/src/chain/chain.ts +56 -0
- package/src/chain/emitter.ts +7 -0
- package/src/chain/interface.ts +3 -0
- package/src/chain/options.ts +3 -0
- package/src/chain/prepareNextSlot.ts +140 -39
- package/src/chain/produceBlock/produceBlockBody.ts +11 -6
- package/src/chain/seenCache/seenBlockProposers.ts +72 -5
- package/src/chain/validation/block.ts +41 -19
- package/src/chain/validation/dataColumnSidecar.ts +27 -17
- package/src/metrics/metrics/lodestar.ts +39 -0
- package/src/network/network.ts +16 -1
- package/src/network/processor/gossipHandlers.ts +7 -0
- package/src/network/reqresp/score.ts +22 -3
- package/src/util/clock.ts +2 -7
|
@@ -1,21 +1,83 @@
|
|
|
1
1
|
import {computeStartSlotAtEpoch} from "@lodestar/state-transition";
|
|
2
|
-
import {Epoch, Slot, ValidatorIndex} from "@lodestar/types";
|
|
2
|
+
import {Epoch, RootHex, Slot, ValidatorIndex, phase0} from "@lodestar/types";
|
|
3
3
|
import {MapDef} from "@lodestar/utils";
|
|
4
4
|
|
|
5
|
+
/** Two distinct block roots signed by the same proposer for the same slot are sufficient to establish an equivocation */
|
|
6
|
+
const MAX_BLOCK_ROOTS_PER_PROPOSAL = 2;
|
|
7
|
+
|
|
5
8
|
/**
|
|
6
9
|
* Keeps a cache to filter block proposals from the same validator in the same slot.
|
|
7
10
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
11
|
+
* Block roots with a signature verified against the block's proposer index are tracked separately from proposals
|
|
12
|
+
* accepted by gossip validation or block import. A root from a block signed by its declared proposer is potential
|
|
13
|
+
* equivocation evidence, but the block may still fail other validation. Such a block must not mark the proposal as
|
|
14
|
+
* known, since that would cause a later valid block for the same slot and proposer to be ignored as a repeat proposal.
|
|
15
|
+
*
|
|
16
|
+
* The signed block header of each observed root is kept so a proposer slashing can be produced from the two
|
|
17
|
+
* conflicting headers once an equivocation is established.
|
|
18
|
+
*
|
|
19
|
+
* The cache is pruned on finalization and bounds the number of roots stored per proposer and slot
|
|
10
20
|
*/
|
|
11
21
|
export class SeenBlockProposers {
|
|
12
22
|
private readonly proposerIndexesBySlot = new MapDef<Slot, Set<ValidatorIndex>>(() => new Set<ValidatorIndex>());
|
|
13
|
-
private
|
|
23
|
+
private readonly signedBlockHeadersBySlot = new MapDef<
|
|
24
|
+
Slot,
|
|
25
|
+
MapDef<ValidatorIndex, Map<RootHex, phase0.SignedBeaconBlockHeader>>
|
|
26
|
+
>(() => new MapDef<ValidatorIndex, Map<RootHex, phase0.SignedBeaconBlockHeader>>(() => new Map()));
|
|
27
|
+
private finalizedSlot: Slot = 0;
|
|
14
28
|
|
|
15
29
|
isKnown(blockSlot: Slot, proposerIndex: ValidatorIndex): boolean {
|
|
16
30
|
return this.proposerIndexesBySlot.get(blockSlot)?.has(proposerIndex) === true;
|
|
17
31
|
}
|
|
18
32
|
|
|
33
|
+
hasBlockRoot(blockSlot: Slot, proposerIndex: ValidatorIndex, blockRoot: RootHex): boolean {
|
|
34
|
+
return this.signedBlockHeadersBySlot.get(blockSlot)?.get(proposerIndex)?.has(blockRoot) === true;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
isEquivocating(blockSlot: Slot, proposerIndex: ValidatorIndex): boolean {
|
|
38
|
+
return (
|
|
39
|
+
(this.signedBlockHeadersBySlot.get(blockSlot)?.get(proposerIndex)?.size ?? 0) >= MAX_BLOCK_ROOTS_PER_PROPOSAL
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
getConflictingBlockRoots(blockSlot: Slot, proposerIndex: ValidatorIndex, blockRoot: RootHex): RootHex[] {
|
|
44
|
+
const signedBlockHeaderByRoot = this.signedBlockHeadersBySlot.get(blockSlot)?.get(proposerIndex);
|
|
45
|
+
return signedBlockHeaderByRoot === undefined
|
|
46
|
+
? []
|
|
47
|
+
: Array.from(signedBlockHeaderByRoot.keys()).filter((root) => root !== blockRoot);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Return the two signed block headers that establish an equivocation, or null if there is none */
|
|
51
|
+
getEquivocationHeaders(
|
|
52
|
+
blockSlot: Slot,
|
|
53
|
+
proposerIndex: ValidatorIndex
|
|
54
|
+
): [phase0.SignedBeaconBlockHeader, phase0.SignedBeaconBlockHeader] | null {
|
|
55
|
+
const signedBlockHeaderByRoot = this.signedBlockHeadersBySlot.get(blockSlot)?.get(proposerIndex);
|
|
56
|
+
if (signedBlockHeaderByRoot === undefined || signedBlockHeaderByRoot.size < MAX_BLOCK_ROOTS_PER_PROPOSAL) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const [signedHeader1, signedHeader2] = signedBlockHeaderByRoot.values();
|
|
60
|
+
return [signedHeader1, signedHeader2];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Record a block only after its proposer signature has been verified */
|
|
64
|
+
observeBlockRoot(
|
|
65
|
+
blockSlot: Slot,
|
|
66
|
+
proposerIndex: ValidatorIndex,
|
|
67
|
+
blockRoot: RootHex,
|
|
68
|
+
signedBlockHeader: phase0.SignedBeaconBlockHeader
|
|
69
|
+
): void {
|
|
70
|
+
if (blockSlot < this.finalizedSlot) {
|
|
71
|
+
throw Error(`blockSlot ${blockSlot} < finalizedSlot ${this.finalizedSlot}`);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const signedBlockHeaderByRoot = this.signedBlockHeadersBySlot.getOrDefault(blockSlot).getOrDefault(proposerIndex);
|
|
75
|
+
if (signedBlockHeaderByRoot.size < MAX_BLOCK_ROOTS_PER_PROPOSAL && !signedBlockHeaderByRoot.has(blockRoot)) {
|
|
76
|
+
signedBlockHeaderByRoot.set(blockRoot, signedBlockHeader);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Mark a block as known from gossip or another block import path */
|
|
19
81
|
add(blockSlot: Slot, proposerIndex: ValidatorIndex): void {
|
|
20
82
|
if (blockSlot < this.finalizedSlot) {
|
|
21
83
|
throw Error(`blockSlot ${blockSlot} < finalizedSlot ${this.finalizedSlot}`);
|
|
@@ -31,9 +93,14 @@ export class SeenBlockProposers {
|
|
|
31
93
|
this.proposerIndexesBySlot.delete(slot);
|
|
32
94
|
}
|
|
33
95
|
}
|
|
96
|
+
for (const slot of this.signedBlockHeadersBySlot.keys()) {
|
|
97
|
+
if (slot < finalizedSlot) {
|
|
98
|
+
this.signedBlockHeadersBySlot.delete(slot);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
34
101
|
}
|
|
35
102
|
|
|
36
|
-
seenAtEpoch(epoch:
|
|
103
|
+
seenAtEpoch(epoch: Epoch, index: ValidatorIndex): boolean {
|
|
37
104
|
const fromSlot = computeStartSlotAtEpoch(epoch);
|
|
38
105
|
const toSlot = computeStartSlotAtEpoch(epoch + 1);
|
|
39
106
|
|
|
@@ -23,8 +23,9 @@ import {
|
|
|
23
23
|
getBlockProposerSignatureSet,
|
|
24
24
|
isExecutionBlockBodyType,
|
|
25
25
|
isStatePostBellatrix,
|
|
26
|
+
signedBlockToSignedHeader,
|
|
26
27
|
} from "@lodestar/state-transition";
|
|
27
|
-
import {SignedBeaconBlock, deneb, gloas, isGloasBeaconBlock} from "@lodestar/types";
|
|
28
|
+
import {RootHex, SignedBeaconBlock, deneb, gloas, isGloasBeaconBlock, ssz} from "@lodestar/types";
|
|
28
29
|
import {byteArrayEquals, sleep, toRootHex} from "@lodestar/utils";
|
|
29
30
|
import {BlockErrorCode, BlockGossipError, GossipAction} from "../errors/index.js";
|
|
30
31
|
import {IBeaconChain} from "../interface.js";
|
|
@@ -75,7 +76,10 @@ export async function validateGossipBlock(
|
|
|
75
76
|
// reboot if the `observed_block_producers` cache is empty. In that case, without this
|
|
76
77
|
// check, we will load the parent and state from disk only to find out later that we
|
|
77
78
|
// already know this block.
|
|
78
|
-
|
|
79
|
+
// A block's hash tree root is identical to its header's, so the root is derived from the header
|
|
80
|
+
// which is also used as potential equivocation evidence
|
|
81
|
+
const signedBlockHeader = signedBlockToSignedHeader(config, signedBlock);
|
|
82
|
+
const blockRoot = toRootHex(ssz.phase0.BeaconBlockHeader.hashTreeRoot(signedBlockHeader.message));
|
|
79
83
|
if (chain.forkChoice.getBlockHexDefaultStatus(blockRoot) !== null) {
|
|
80
84
|
throw new BlockGossipError(GossipAction.IGNORE, {code: BlockErrorCode.ALREADY_KNOWN, root: blockRoot});
|
|
81
85
|
}
|
|
@@ -85,7 +89,12 @@ export async function validateGossipBlock(
|
|
|
85
89
|
|
|
86
90
|
// [IGNORE] The block is the first block with valid signature received for the proposer for the slot, signed_beacon_block.message.slot.
|
|
87
91
|
const proposerIndex = block.proposerIndex;
|
|
92
|
+
const hasBlockRoot = chain.seenBlockProposers.hasBlockRoot(blockSlot, proposerIndex, blockRoot);
|
|
88
93
|
if (chain.seenBlockProposers.isKnown(blockSlot, proposerIndex)) {
|
|
94
|
+
if (!hasBlockRoot && !chain.seenBlockProposers.isEquivocating(blockSlot, proposerIndex)) {
|
|
95
|
+
await verifyBlockProposerSignature(chain, signedBlock, blockRoot, {verifyOnMainThread: false});
|
|
96
|
+
chain.seenBlockProposers.observeBlockRoot(blockSlot, proposerIndex, blockRoot, signedBlockHeader);
|
|
97
|
+
}
|
|
89
98
|
throw new BlockGossipError(GossipAction.IGNORE, {code: BlockErrorCode.REPEAT_PROPOSAL, proposerIndex});
|
|
90
99
|
}
|
|
91
100
|
|
|
@@ -270,18 +279,8 @@ export async function validateGossipBlock(
|
|
|
270
279
|
}
|
|
271
280
|
|
|
272
281
|
// [REJECT] The proposer signature, signed_beacon_block.signature, is valid with respect to the proposer_index pubkey.
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
// Don't batch so verification is not delayed
|
|
276
|
-
if (!(await chain.bls.verifySignatureSets([signatureSet], {verifyOnMainThread: true}))) {
|
|
277
|
-
throw new BlockGossipError(GossipAction.REJECT, {
|
|
278
|
-
code: BlockErrorCode.PROPOSAL_SIGNATURE_INVALID,
|
|
279
|
-
blockSlot,
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
chain.seenBlockInputCache.markVerifiedProposerSignature(blockSlot, blockRoot, signedBlock.signature);
|
|
284
|
-
}
|
|
282
|
+
await verifyBlockProposerSignature(chain, signedBlock, blockRoot);
|
|
283
|
+
chain.seenBlockProposers.observeBlockRoot(blockSlot, proposerIndex, blockRoot, signedBlockHeader);
|
|
285
284
|
|
|
286
285
|
// [REJECT] The block is proposed by the expected proposer_index for the block's slot in the context of the current
|
|
287
286
|
// shuffling (defined by parent_root/slot). If the proposer_index cannot immediately be verified against the expected
|
|
@@ -291,11 +290,6 @@ export async function validateGossipBlock(
|
|
|
291
290
|
throw new BlockGossipError(GossipAction.REJECT, {code: BlockErrorCode.INCORRECT_PROPOSER, proposerIndex});
|
|
292
291
|
}
|
|
293
292
|
|
|
294
|
-
// Check again in case there two blocks are processed concurrently
|
|
295
|
-
if (chain.seenBlockProposers.isKnown(blockSlot, proposerIndex)) {
|
|
296
|
-
throw new BlockGossipError(GossipAction.IGNORE, {code: BlockErrorCode.REPEAT_PROPOSAL, proposerIndex});
|
|
297
|
-
}
|
|
298
|
-
|
|
299
293
|
// Simple implementation of a pending block queue. Keeping the block here recycles the queue logic, and keeps the
|
|
300
294
|
// gossip validation promise without any extra infrastructure.
|
|
301
295
|
// Do the sleep at the end, since regen and signature validation can already take longer than `msToBlockSlot`.
|
|
@@ -305,7 +299,35 @@ export async function validateGossipBlock(
|
|
|
305
299
|
await sleep(msToBlockSlot);
|
|
306
300
|
}
|
|
307
301
|
|
|
302
|
+
// Check again after all async validation and the early-block delay so concurrent proposals cannot both pass
|
|
303
|
+
if (chain.seenBlockProposers.isKnown(blockSlot, proposerIndex)) {
|
|
304
|
+
throw new BlockGossipError(GossipAction.IGNORE, {code: BlockErrorCode.REPEAT_PROPOSAL, proposerIndex});
|
|
305
|
+
}
|
|
306
|
+
|
|
308
307
|
chain.seenBlockProposers.add(blockSlot, proposerIndex);
|
|
309
308
|
|
|
310
309
|
return {skippedSlots};
|
|
311
310
|
}
|
|
311
|
+
|
|
312
|
+
export async function verifyBlockProposerSignature(
|
|
313
|
+
chain: IBeaconChain,
|
|
314
|
+
signedBlock: SignedBeaconBlock,
|
|
315
|
+
blockRoot: RootHex,
|
|
316
|
+
opts: {verifyOnMainThread?: boolean} = {}
|
|
317
|
+
): Promise<void> {
|
|
318
|
+
const blockSlot = signedBlock.message.slot;
|
|
319
|
+
if (chain.seenBlockInputCache.isVerifiedProposerSignature(blockSlot, blockRoot, signedBlock.signature)) {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const signatureSet = getBlockProposerSignatureSet(chain.config, signedBlock);
|
|
324
|
+
// Don't batch so verification is not delayed
|
|
325
|
+
if (!(await chain.bls.verifySignatureSets([signatureSet], {verifyOnMainThread: opts.verifyOnMainThread ?? true}))) {
|
|
326
|
+
throw new BlockGossipError(GossipAction.REJECT, {
|
|
327
|
+
code: BlockErrorCode.PROPOSAL_SIGNATURE_INVALID,
|
|
328
|
+
blockSlot,
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
chain.seenBlockInputCache.markVerifiedProposerSignature(blockSlot, blockRoot, signedBlock.signature);
|
|
333
|
+
}
|
|
@@ -2,15 +2,16 @@ import {ChainConfig, ChainForkConfig} from "@lodestar/config";
|
|
|
2
2
|
import {
|
|
3
3
|
KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH,
|
|
4
4
|
KZG_COMMITMENTS_SUBTREE_INDEX,
|
|
5
|
+
MIN_SEED_LOOKAHEAD,
|
|
5
6
|
NUMBER_OF_COLUMNS,
|
|
7
|
+
isForkPostFulu,
|
|
6
8
|
} from "@lodestar/params";
|
|
7
9
|
import {
|
|
8
10
|
computeEpochAtSlot,
|
|
9
11
|
computeStartSlotAtEpoch,
|
|
10
12
|
getBlockHeaderProposerSignatureSetByHeaderSlot,
|
|
11
|
-
getBlockHeaderProposerSignatureSetByParentStateSlot,
|
|
12
13
|
} from "@lodestar/state-transition";
|
|
13
|
-
import {DataColumnSidecar, Root, Slot, SubnetID, fulu, gloas, ssz} from "@lodestar/types";
|
|
14
|
+
import {DataColumnSidecar, Root, Slot, SubnetID, ValidatorIndex, fulu, gloas, ssz} from "@lodestar/types";
|
|
14
15
|
import {byteArrayEquals, toRootHex, verifyMerkleBranch} from "@lodestar/utils";
|
|
15
16
|
import {BeaconMetrics} from "../../metrics/metrics/beacon.js";
|
|
16
17
|
import {Metrics} from "../../metrics/metrics.js";
|
|
@@ -104,19 +105,23 @@ export async function validateGossipFuluDataColumnSidecar(
|
|
|
104
105
|
});
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
// getBlockSlotState also checks for whether the current finalized checkpoint is an ancestor of the block.
|
|
108
|
-
// As a result, we throw an IGNORE (whereas the spec says we should REJECT for this scenario).
|
|
109
|
-
// this is something we should change this in the future to make the code airtight to the spec.
|
|
110
108
|
// 7) [REJECT] The sidecar's block's parent passes validation.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
109
|
+
// Post-fulu, we can use parent state to get expected proposer index thanks to proposer lookahead
|
|
110
|
+
const parentEpoch = computeEpochAtSlot(parentBlock.slot);
|
|
111
|
+
const blockEpoch = computeEpochAtSlot(blockHeader.slot);
|
|
112
|
+
const getProposerIndex = async (): Promise<ValidatorIndex> => {
|
|
113
|
+
if (isForkPostFulu(chain.config.getForkName(parentBlock.slot)) && blockEpoch - parentEpoch <= MIN_SEED_LOOKAHEAD) {
|
|
114
|
+
const parentState = await chain.regen.getState(parentBlock.stateRoot, RegenCaller.validateGossipDataColumn);
|
|
115
|
+
return parentState.getBeaconProposer(blockHeader.slot);
|
|
116
|
+
}
|
|
117
|
+
const blockState = await chain.regen.getBlockSlotState(
|
|
118
|
+
parentBlock,
|
|
119
|
+
blockHeader.slot,
|
|
120
|
+
{dontTransferCache: true},
|
|
121
|
+
RegenCaller.validateGossipDataColumn
|
|
122
|
+
);
|
|
123
|
+
return blockState.getBeaconProposer(blockHeader.slot);
|
|
124
|
+
};
|
|
120
125
|
|
|
121
126
|
// 13) [REJECT] The sidecar is proposed by the expected proposer_index for the block's slot in the context of the current
|
|
122
127
|
// shuffling (defined by block_header.parent_root/block_header.slot). If the proposer_index cannot
|
|
@@ -124,7 +129,13 @@ export async function validateGossipFuluDataColumnSidecar(
|
|
|
124
129
|
// while proposers for the block's branch are calculated -- in such a case do not REJECT, instead IGNORE
|
|
125
130
|
// this message.
|
|
126
131
|
const proposerIndex = blockHeader.proposerIndex;
|
|
127
|
-
const expectedProposerIndex =
|
|
132
|
+
const expectedProposerIndex = await getProposerIndex().catch(() => {
|
|
133
|
+
throw new DataColumnSidecarGossipError(GossipAction.IGNORE, {
|
|
134
|
+
code: DataColumnSidecarErrorCode.PARENT_UNKNOWN,
|
|
135
|
+
parentRoot,
|
|
136
|
+
slot: blockHeader.slot,
|
|
137
|
+
});
|
|
138
|
+
});
|
|
128
139
|
|
|
129
140
|
if (proposerIndex !== expectedProposerIndex) {
|
|
130
141
|
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
@@ -137,9 +148,8 @@ export async function validateGossipFuluDataColumnSidecar(
|
|
|
137
148
|
// 5) [REJECT] The proposer signature of sidecar.signed_block_header, is valid with respect to the block_header.proposer_index pubkey.
|
|
138
149
|
const signature = dataColumnSidecar.signedBlockHeader.signature;
|
|
139
150
|
if (!chain.seenBlockInputCache.isVerifiedProposerSignature(blockHeader.slot, blockRootHex, signature)) {
|
|
140
|
-
const signatureSet =
|
|
151
|
+
const signatureSet = getBlockHeaderProposerSignatureSetByHeaderSlot(
|
|
141
152
|
chain.config,
|
|
142
|
-
blockState.slot,
|
|
143
153
|
dataColumnSidecar.signedBlockHeader
|
|
144
154
|
);
|
|
145
155
|
|
|
@@ -1179,6 +1179,10 @@ export function createLodestarMetrics(
|
|
|
1179
1179
|
name: "lodestar_oppool_proposer_slashing_pool_size",
|
|
1180
1180
|
help: "Current size of the ProposerSlashingPool",
|
|
1181
1181
|
}),
|
|
1182
|
+
proposerSlashingsProduced: register.counter({
|
|
1183
|
+
name: "lodestar_oppool_proposer_slashings_produced_total",
|
|
1184
|
+
help: "Total number of proposer slashings produced from observed equivocations",
|
|
1185
|
+
}),
|
|
1182
1186
|
voluntaryExitPoolSize: register.gauge({
|
|
1183
1187
|
name: "lodestar_oppool_voluntary_exit_pool_size",
|
|
1184
1188
|
help: "Current size of the VoluntaryExitPool",
|
|
@@ -1708,6 +1712,41 @@ export function createLodestarMetrics(
|
|
|
1708
1712
|
}),
|
|
1709
1713
|
},
|
|
1710
1714
|
|
|
1715
|
+
// Pre-verify builder-deposit signatures in the epochs before the Gloas fork (prepareNextSlot).
|
|
1716
|
+
builderDepositPreVerify: {
|
|
1717
|
+
duration: register.histogram({
|
|
1718
|
+
name: "lodestar_builder_deposit_preverify_duration_seconds",
|
|
1719
|
+
help: "Duration of one preVerifyBuilderDepositsPreGloas call (BLS batch verify + scan)",
|
|
1720
|
+
buckets: [1, 2, 3, 4],
|
|
1721
|
+
}),
|
|
1722
|
+
pendingDeposits: register.gauge({
|
|
1723
|
+
name: "lodestar_builder_deposit_preverify_pending_deposits",
|
|
1724
|
+
help: "Current state.pendingDeposits length (backlog to drain before the fork)",
|
|
1725
|
+
}),
|
|
1726
|
+
cachedDeposits: register.gauge({
|
|
1727
|
+
name: "lodestar_builder_deposit_preverify_cached_deposits",
|
|
1728
|
+
help: "Deposit signatures verified & cached so far this pre-fork window (valid + invalid)",
|
|
1729
|
+
}),
|
|
1730
|
+
scannedDeposits: register.gauge({
|
|
1731
|
+
name: "lodestar_builder_deposit_preverify_scanned_deposits",
|
|
1732
|
+
help: "Pending deposits examined by the last pre-verify call (< pending_deposits ⇒ cap hit)",
|
|
1733
|
+
}),
|
|
1734
|
+
builderPubkeys: register.gauge({
|
|
1735
|
+
name: "lodestar_builder_deposit_preverify_builder_pubkeys",
|
|
1736
|
+
help: "Distinct builder pubkeys tracked this window (validator deposits for these are pre-verified)",
|
|
1737
|
+
}),
|
|
1738
|
+
validSignatures: register.counter<{type: "builder" | "validator"}>({
|
|
1739
|
+
name: "lodestar_builder_deposit_preverify_valid_signatures_total",
|
|
1740
|
+
help: "Cumulative deposit signatures whose BLS verification passed (VALID), by credential type",
|
|
1741
|
+
labelNames: ["type"],
|
|
1742
|
+
}),
|
|
1743
|
+
invalidSignatures: register.counter<{type: "builder" | "validator"}>({
|
|
1744
|
+
name: "lodestar_builder_deposit_preverify_invalid_signatures_total",
|
|
1745
|
+
help: "Cumulative deposit signatures whose BLS verification failed (INVALID), by credential type",
|
|
1746
|
+
labelNames: ["type"],
|
|
1747
|
+
}),
|
|
1748
|
+
},
|
|
1749
|
+
|
|
1711
1750
|
// reprocess attestations
|
|
1712
1751
|
reprocessApiAttestations: {
|
|
1713
1752
|
total: register.gauge({
|
package/src/network/network.ts
CHANGED
|
@@ -147,6 +147,7 @@ export class Network implements INetwork {
|
|
|
147
147
|
this.chain.emitter.on(ChainEvent.updateTargetCustodyGroupCount, this.onTargetGroupCountUpdated);
|
|
148
148
|
this.chain.emitter.on(ChainEvent.publishDataColumns, this.onPublishDataColumns);
|
|
149
149
|
this.chain.emitter.on(ChainEvent.publishBlobSidecars, this.onPublishBlobSidecars);
|
|
150
|
+
this.chain.emitter.on(ChainEvent.publishProposerSlashing, this.onPublishProposerSlashing);
|
|
150
151
|
this.chain.emitter.on(ChainEvent.updateStatus, this.onUpdateStatus);
|
|
151
152
|
}
|
|
152
153
|
|
|
@@ -244,6 +245,7 @@ export class Network implements INetwork {
|
|
|
244
245
|
this.chain.emitter.off(ChainEvent.updateTargetCustodyGroupCount, this.onTargetGroupCountUpdated);
|
|
245
246
|
this.chain.emitter.off(ChainEvent.publishDataColumns, this.onPublishDataColumns);
|
|
246
247
|
this.chain.emitter.off(ChainEvent.publishBlobSidecars, this.onPublishBlobSidecars);
|
|
248
|
+
this.chain.emitter.off(ChainEvent.publishProposerSlashing, this.onPublishProposerSlashing);
|
|
247
249
|
this.chain.emitter.off(ChainEvent.updateStatus, this.onUpdateStatus);
|
|
248
250
|
await this.core.close();
|
|
249
251
|
|
|
@@ -455,7 +457,8 @@ export class Network implements INetwork {
|
|
|
455
457
|
|
|
456
458
|
return this.publishGossip<GossipType.proposer_slashing>(
|
|
457
459
|
{type: GossipType.proposer_slashing, boundary},
|
|
458
|
-
proposerSlashing
|
|
460
|
+
proposerSlashing,
|
|
461
|
+
{ignoreDuplicatePublishError: true}
|
|
459
462
|
);
|
|
460
463
|
}
|
|
461
464
|
|
|
@@ -877,6 +880,18 @@ export class Network implements INetwork {
|
|
|
877
880
|
return promiseAllMaybeAsync(sidecars.map((sidecar) => () => this.publishBlobSidecar(sidecar)));
|
|
878
881
|
};
|
|
879
882
|
|
|
883
|
+
private onPublishProposerSlashing = async (proposerSlashing: phase0.ProposerSlashing): Promise<void> => {
|
|
884
|
+
try {
|
|
885
|
+
await this.publishProposerSlashing(proposerSlashing);
|
|
886
|
+
} catch (e) {
|
|
887
|
+
this.logger.debug(
|
|
888
|
+
"Error publishing proposer slashing",
|
|
889
|
+
{proposerIndex: proposerSlashing.signedHeader1.message.proposerIndex},
|
|
890
|
+
e as Error
|
|
891
|
+
);
|
|
892
|
+
}
|
|
893
|
+
};
|
|
894
|
+
|
|
880
895
|
private onUpdateStatus = async (): Promise<void> => {
|
|
881
896
|
await this.core.updateStatus(this.chain.getStatus());
|
|
882
897
|
};
|
|
@@ -257,6 +257,13 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
257
257
|
chain.seenPayloadEnvelopeInputCache.prune(blockRootHex);
|
|
258
258
|
}
|
|
259
259
|
throw e;
|
|
260
|
+
} finally {
|
|
261
|
+
// The block received from the network may have established an equivocation, either by conflicting
|
|
262
|
+
// with a previously observed block root (REPEAT_PROPOSAL) or with a root observed during validation
|
|
263
|
+
const proposerIndex = signedBlock.message.proposerIndex;
|
|
264
|
+
if (chain.seenBlockProposers.isEquivocating(slot, proposerIndex)) {
|
|
265
|
+
chain.processProposerEquivocation(slot, proposerIndex);
|
|
266
|
+
}
|
|
260
267
|
}
|
|
261
268
|
}
|
|
262
269
|
|
|
@@ -33,9 +33,28 @@ export function onOutgoingReqRespError(e: RequestError, method: ReqRespMethod):
|
|
|
33
33
|
|
|
34
34
|
case RequestErrorCode.DIAL_TIMEOUT:
|
|
35
35
|
case RequestErrorCode.DIAL_ERROR:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
// `RequestError` renders `e.message` as just the error code (see `renderErrorMessage`), so the
|
|
37
|
+
// multistream "protocol selection failed" text is only on the wrapped inner error, which is
|
|
38
|
+
// available on `DIAL_ERROR` via `e.type.error` (`DIAL_TIMEOUT` carries no inner error).
|
|
39
|
+
if (
|
|
40
|
+
e.type.code === RequestErrorCode.DIAL_ERROR &&
|
|
41
|
+
e.type.error.message.includes(multiStreamSelectErrorCodes.protocolSelectionFailed)
|
|
42
|
+
) {
|
|
43
|
+
// Peer does not support the protocol, a real incompatibility rather than a transient
|
|
44
|
+
// failure, so keep the stronger penalty (Fatal for Ping, as before).
|
|
45
|
+
return method === ReqRespMethod.Ping ? PeerAction.Fatal : PeerAction.LowToleranceError;
|
|
46
|
+
}
|
|
47
|
+
switch (method) {
|
|
48
|
+
// Ping and Status are liveness probes; their dial timeouts are dominated by transient
|
|
49
|
+
// network congestion rather than peer misbehavior, so penalize leniently to avoid
|
|
50
|
+
// self-inflicted peer starvation (https://github.com/ChainSafe/lodestar/issues/9562),
|
|
51
|
+
// while still applying some penalty so genuinely dead peers eventually free the slot.
|
|
52
|
+
case ReqRespMethod.Ping:
|
|
53
|
+
case ReqRespMethod.Status:
|
|
54
|
+
return PeerAction.HighToleranceError;
|
|
55
|
+
default:
|
|
56
|
+
return PeerAction.LowToleranceError;
|
|
57
|
+
}
|
|
39
58
|
// TODO: Detect SSZDecodeError and return PeerAction.Fatal
|
|
40
59
|
|
|
41
60
|
case RequestErrorCode.RESP_TIMEOUT:
|
package/src/util/clock.ts
CHANGED
|
@@ -94,10 +94,7 @@ export class Clock extends EventEmitter implements IClock {
|
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
96
96
|
* If it's too close to next slot given MAXIMUM_GOSSIP_CLOCK_DISPARITY, return currentSlot + 1.
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* Spec: phase0/p2p-interface.md - gossip validation uses `current_time + MAXIMUM_GOSSIP_CLOCK_DISPARITY < message_time`
|
|
100
|
-
* to reject future messages (strict `<`), so the boundary (exactly equal) is accepted, hence `<=` here.
|
|
97
|
+
* Spec: phase0/p2p-interface.md rejects future messages with strict `<`, hence `<=` here.
|
|
101
98
|
*/
|
|
102
99
|
get currentSlotWithGossipDisparity(): Slot {
|
|
103
100
|
const currentSlot = this.currentSlot;
|
|
@@ -123,9 +120,7 @@ export class Clock extends EventEmitter implements IClock {
|
|
|
123
120
|
|
|
124
121
|
/**
|
|
125
122
|
* Check if a slot is current slot given MAXIMUM_GOSSIP_CLOCK_DISPARITY.
|
|
126
|
-
*
|
|
127
|
-
* Uses `<=` for disparity checks because the spec rejects with strict `<`
|
|
128
|
-
* (phase0/p2p-interface.md), meaning the boundary (exactly equal) is accepted.
|
|
123
|
+
* Spec: phase0/p2p-interface.md rejects future messages with strict `<`, hence `<=`.
|
|
129
124
|
*/
|
|
130
125
|
isCurrentSlotGivenGossipDisparity(slot: Slot): boolean {
|
|
131
126
|
const currentSlot = this.currentSlot;
|