@lodestar/beacon-node 1.45.0-dev.f535421f29 → 1.45.0-rc.0
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/index.d.ts +1 -1
- package/lib/api/impl/beacon/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/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 +6 -43
- package/lib/api/impl/beacon/pool/index.js.map +1 -1
- package/lib/api/impl/beacon/state/index.d.ts +1 -1
- package/lib/api/impl/beacon/state/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/state/index.js +48 -5
- package/lib/api/impl/beacon/state/index.js.map +1 -1
- package/lib/api/impl/beacon/state/utils.d.ts +13 -3
- package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
- package/lib/api/impl/beacon/state/utils.js +48 -4
- package/lib/api/impl/beacon/state/utils.js.map +1 -1
- package/lib/api/impl/debug/index.d.ts +1 -1
- package/lib/api/impl/debug/index.d.ts.map +1 -1
- package/lib/api/impl/debug/index.js +2 -2
- package/lib/api/impl/debug/index.js.map +1 -1
- package/lib/api/impl/lodestar/index.js +2 -2
- package/lib/api/impl/lodestar/index.js.map +1 -1
- package/lib/api/impl/proof/index.d.ts +1 -1
- package/lib/api/impl/proof/index.d.ts.map +1 -1
- package/lib/api/impl/proof/index.js +2 -2
- package/lib/api/impl/proof/index.js.map +1 -1
- package/lib/api/impl/utils.d.ts +23 -0
- package/lib/api/impl/utils.d.ts.map +1 -1
- package/lib/api/impl/utils.js +44 -1
- package/lib/api/impl/utils.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts +0 -14
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +67 -62
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/api/rest/base.d.ts.map +1 -1
- package/lib/api/rest/base.js +8 -0
- package/lib/api/rest/base.js.map +1 -1
- package/lib/chain/blocks/importBlock.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.js +2 -5
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/builderCircuitBreaker.d.ts +31 -0
- package/lib/chain/builderCircuitBreaker.d.ts.map +1 -0
- package/lib/chain/builderCircuitBreaker.js +59 -0
- package/lib/chain/builderCircuitBreaker.js.map +1 -0
- package/lib/chain/chain.d.ts +3 -2
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +4 -3
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/interface.d.ts +3 -2
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/interface.js.map +1 -1
- package/lib/chain/opPools/proposerPreferencesPool.d.ts +2 -1
- package/lib/chain/opPools/proposerPreferencesPool.d.ts.map +1 -1
- package/lib/chain/opPools/proposerPreferencesPool.js +3 -0
- package/lib/chain/opPools/proposerPreferencesPool.js.map +1 -1
- package/lib/chain/options.d.ts +5 -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 +12 -7
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +4 -12
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/seenCache/index.d.ts +0 -1
- package/lib/chain/seenCache/index.d.ts.map +1 -1
- package/lib/chain/seenCache/index.js +0 -1
- package/lib/chain/seenCache/index.js.map +1 -1
- package/lib/chain/validation/executionPayloadBid.js +11 -10
- package/lib/chain/validation/executionPayloadBid.js.map +1 -1
- package/lib/chain/validation/proposerPreferences.d.ts.map +1 -1
- package/lib/chain/validation/proposerPreferences.js +14 -5
- package/lib/chain/validation/proposerPreferences.js.map +1 -1
- package/lib/execution/builder/http.d.ts +18 -0
- package/lib/execution/builder/http.d.ts.map +1 -1
- package/lib/execution/builder/http.js +20 -11
- package/lib/execution/builder/http.js.map +1 -1
- package/lib/metrics/metrics/beacon.d.ts +6 -0
- package/lib/metrics/metrics/beacon.d.ts.map +1 -1
- package/lib/metrics/metrics/beacon.js +18 -0
- package/lib/metrics/metrics/beacon.js.map +1 -1
- package/lib/network/core/metrics.d.ts +65 -0
- package/lib/network/core/metrics.d.ts.map +1 -1
- package/lib/network/core/metrics.js +94 -0
- package/lib/network/core/metrics.js.map +1 -1
- package/lib/network/discv5/utils.d.ts.map +1 -1
- package/lib/network/discv5/utils.js +12 -3
- package/lib/network/discv5/utils.js.map +1 -1
- package/lib/network/gossip/encoding.d.ts.map +1 -1
- package/lib/network/gossip/encoding.js +7 -0
- package/lib/network/gossip/encoding.js.map +1 -1
- package/lib/network/gossip/gossipsub.d.ts.map +1 -1
- package/lib/network/gossip/gossipsub.js +2 -1
- package/lib/network/gossip/gossipsub.js.map +1 -1
- package/lib/network/gossip/topic.d.ts +765 -3
- package/lib/network/gossip/topic.d.ts.map +1 -1
- package/lib/network/gossip/topic.js +23 -3
- package/lib/network/gossip/topic.js.map +1 -1
- package/lib/network/peers/peerManager.d.ts.map +1 -1
- package/lib/network/peers/peerManager.js +10 -0
- package/lib/network/peers/peerManager.js.map +1 -1
- package/lib/network/peers/score/score.d.ts +3 -1
- package/lib/network/peers/score/score.d.ts.map +1 -1
- package/lib/network/peers/score/score.js +6 -1
- package/lib/network/peers/score/score.js.map +1 -1
- package/lib/network/peers/score/store.d.ts.map +1 -1
- package/lib/network/peers/score/store.js +6 -1
- package/lib/network/peers/score/store.js.map +1 -1
- package/lib/network/peers/utils/prioritizePeers.d.ts.map +1 -1
- package/lib/network/peers/utils/prioritizePeers.js +14 -0
- package/lib/network/peers/utils/prioritizePeers.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +6 -3
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/util/graffiti.d.ts +15 -0
- package/lib/util/graffiti.d.ts.map +1 -1
- package/lib/util/graffiti.js +55 -0
- package/lib/util/graffiti.js.map +1 -1
- package/package.json +19 -19
- package/src/api/impl/beacon/index.ts +1 -1
- package/src/api/impl/beacon/pool/index.ts +5 -53
- package/src/api/impl/beacon/state/index.ts +55 -3
- package/src/api/impl/beacon/state/utils.ts +68 -4
- package/src/api/impl/debug/index.ts +3 -2
- package/src/api/impl/lodestar/index.ts +2 -2
- package/src/api/impl/proof/index.ts +2 -2
- package/src/api/impl/utils.ts +51 -1
- package/src/api/impl/validator/index.ts +75 -67
- package/src/api/rest/base.ts +9 -0
- package/src/chain/blocks/importBlock.ts +2 -7
- package/src/chain/builderCircuitBreaker.ts +84 -0
- package/src/chain/chain.ts +7 -3
- package/src/chain/interface.ts +2 -2
- package/src/chain/opPools/proposerPreferencesPool.ts +5 -1
- package/src/chain/options.ts +6 -0
- package/src/chain/prepareNextSlot.ts +11 -7
- package/src/chain/produceBlock/produceBlockBody.ts +9 -17
- package/src/chain/seenCache/index.ts +0 -1
- package/src/chain/validation/executionPayloadBid.ts +14 -9
- package/src/chain/validation/proposerPreferences.ts +15 -5
- package/src/execution/builder/http.ts +30 -17
- package/src/metrics/metrics/beacon.ts +19 -0
- package/src/network/core/metrics.ts +94 -0
- package/src/network/discv5/utils.ts +11 -3
- package/src/network/gossip/encoding.ts +7 -0
- package/src/network/gossip/gossipsub.ts +2 -1
- package/src/network/gossip/topic.ts +28 -4
- package/src/network/peers/peerManager.ts +11 -0
- package/src/network/peers/score/score.ts +8 -1
- package/src/network/peers/score/store.ts +8 -1
- package/src/network/peers/utils/prioritizePeers.ts +15 -0
- package/src/network/processor/gossipHandlers.ts +6 -2
- package/src/util/graffiti.ts +78 -0
- package/lib/chain/seenCache/seenProposerPreferences.d.ts +0 -16
- package/lib/chain/seenCache/seenProposerPreferences.d.ts.map +0 -1
- package/lib/chain/seenCache/seenProposerPreferences.js +0 -26
- package/lib/chain/seenCache/seenProposerPreferences.js.map +0 -1
- package/src/chain/seenCache/seenProposerPreferences.ts +0 -32
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {IForkChoice} from "@lodestar/fork-choice";
|
|
2
|
+
import {Slot} from "@lodestar/types";
|
|
3
|
+
import {Logger} from "@lodestar/utils";
|
|
4
|
+
import {getFaultInspectionParams} from "../execution/builder/http.js";
|
|
5
|
+
import {Metrics} from "../metrics/index.js";
|
|
6
|
+
|
|
7
|
+
export type BuilderCircuitBreakerOpts = {
|
|
8
|
+
faultInspectionWindow?: number;
|
|
9
|
+
allowedFaults?: number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type BuilderCircuitBreakerModules = {
|
|
13
|
+
forkChoice: IForkChoice;
|
|
14
|
+
logger: Logger;
|
|
15
|
+
metrics: Metrics | null;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Post-gloas circuit breaker for builder bids. The beacon block is produced by the proposer
|
|
20
|
+
* regardless of bid source, so missed blocks are not a useful builder health signal. Instead
|
|
21
|
+
* count blocks whose payload was never revealed and stop selecting builder bids while the
|
|
22
|
+
* non-reveal rate in the fault inspection window is too high.
|
|
23
|
+
*/
|
|
24
|
+
export class BuilderCircuitBreaker {
|
|
25
|
+
readonly faultInspectionWindow: number;
|
|
26
|
+
readonly allowedFaults: number;
|
|
27
|
+
|
|
28
|
+
private active = false;
|
|
29
|
+
private lastUpdatedSlot = -1;
|
|
30
|
+
|
|
31
|
+
constructor(
|
|
32
|
+
opts: BuilderCircuitBreakerOpts,
|
|
33
|
+
private readonly modules: BuilderCircuitBreakerModules
|
|
34
|
+
) {
|
|
35
|
+
const {faultInspectionWindow, allowedFaults} = getFaultInspectionParams(opts);
|
|
36
|
+
this.faultInspectionWindow = faultInspectionWindow;
|
|
37
|
+
this.allowedFaults = allowedFaults;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Whether builder bids must be ignored for a block produced at clockSlot */
|
|
41
|
+
isActive(clockSlot: Slot): boolean {
|
|
42
|
+
this.update(clockSlot);
|
|
43
|
+
return this.active;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
update(clockSlot: Slot): void {
|
|
47
|
+
if (clockSlot <= this.lastUpdatedSlot) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
this.lastUpdatedSlot = clockSlot;
|
|
51
|
+
|
|
52
|
+
// Exclude clockSlot itself, its payload reveal may still be in flight
|
|
53
|
+
const {blocksPresent, payloadsRevealed} = this.modules.forkChoice.getPayloadRevealCounts(
|
|
54
|
+
Math.max(clockSlot - this.faultInspectionWindow, 0),
|
|
55
|
+
clockSlot - 1
|
|
56
|
+
);
|
|
57
|
+
const faults = blocksPresent - payloadsRevealed;
|
|
58
|
+
|
|
59
|
+
const wasActive = this.active;
|
|
60
|
+
// Scale the fault budget by blocks present so sparse windows still trigger on high non-reveal rates
|
|
61
|
+
this.active = faults * this.faultInspectionWindow > this.allowedFaults * blocksPresent;
|
|
62
|
+
|
|
63
|
+
this.modules.metrics?.builderCircuitBreaker.active.set(this.active ? 1 : 0);
|
|
64
|
+
this.modules.metrics?.builderCircuitBreaker.faults.set(faults);
|
|
65
|
+
this.modules.metrics?.builderCircuitBreaker.blocksPresent.set(blocksPresent);
|
|
66
|
+
this.modules.metrics?.builderCircuitBreaker.payloadsRevealed.set(payloadsRevealed);
|
|
67
|
+
|
|
68
|
+
const logCtx = {
|
|
69
|
+
blocksPresent,
|
|
70
|
+
faults,
|
|
71
|
+
faultInspectionWindow: this.faultInspectionWindow,
|
|
72
|
+
allowedFaults: this.allowedFaults,
|
|
73
|
+
};
|
|
74
|
+
if (this.active !== wasActive) {
|
|
75
|
+
if (this.active) {
|
|
76
|
+
this.modules.logger.warn("Builder circuit breaker activated, ignoring builder bids", logCtx);
|
|
77
|
+
} else {
|
|
78
|
+
this.modules.logger.info("Builder circuit breaker deactivated", logCtx);
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
this.modules.logger.verbose("Builder circuit breaker status", {active: this.active, ...logCtx});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
package/src/chain/chain.ts
CHANGED
|
@@ -75,6 +75,7 @@ import {ImportPayloadOpts} from "./blocks/types.js";
|
|
|
75
75
|
import {persistBlockInput} from "./blocks/writeBlockInputToDb.js";
|
|
76
76
|
import {persistPayloadEnvelopeInput} from "./blocks/writePayloadEnvelopeInputToDb.js";
|
|
77
77
|
import {BlsMultiThreadWorkerPool, BlsSingleThreadVerifier, IBlsVerifier} from "./bls/index.js";
|
|
78
|
+
import {BuilderCircuitBreaker} from "./builderCircuitBreaker.js";
|
|
78
79
|
import {ColumnReconstructionTracker} from "./ColumnReconstructionTracker.js";
|
|
79
80
|
import {ChainEvent, ChainEventEmitter} from "./emitter.js";
|
|
80
81
|
import {ForkchoiceCaller, initializeForkChoice} from "./forkChoice/index.js";
|
|
@@ -107,7 +108,6 @@ import {
|
|
|
107
108
|
SeenExecutionPayloadBids,
|
|
108
109
|
SeenPayloadAttesters,
|
|
109
110
|
SeenPayloadEnvelopeInput,
|
|
110
|
-
SeenProposerPreferences,
|
|
111
111
|
SeenSyncCommitteeMessages,
|
|
112
112
|
} from "./seenCache/index.js";
|
|
113
113
|
import {SeenAggregatedAttestations} from "./seenCache/seenAggregateAndProof.js";
|
|
@@ -152,6 +152,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
152
152
|
readonly genesisValidatorsRoot: Root;
|
|
153
153
|
readonly executionEngine: IExecutionEngine;
|
|
154
154
|
readonly executionBuilder?: IExecutionBuilder;
|
|
155
|
+
readonly builderCircuitBreaker: BuilderCircuitBreaker;
|
|
155
156
|
// Expose config for convenience in modularized functions
|
|
156
157
|
readonly config: BeaconConfig;
|
|
157
158
|
readonly custodyConfig: CustodyConfig;
|
|
@@ -189,7 +190,6 @@ export class BeaconChain implements IBeaconChain {
|
|
|
189
190
|
readonly seenPayloadAttesters = new SeenPayloadAttesters();
|
|
190
191
|
readonly seenAggregatedAttestations: SeenAggregatedAttestations;
|
|
191
192
|
readonly seenExecutionPayloadBids = new SeenExecutionPayloadBids();
|
|
192
|
-
readonly seenProposerPreferences = new SeenProposerPreferences();
|
|
193
193
|
readonly seenBlockProposers = new SeenBlockProposers();
|
|
194
194
|
readonly seenSyncCommitteeMessages = new SeenSyncCommitteeMessages();
|
|
195
195
|
readonly seenContributionAndProof: SeenContributionAndProof;
|
|
@@ -427,6 +427,11 @@ export class BeaconChain implements IBeaconChain {
|
|
|
427
427
|
|
|
428
428
|
this.forkChoice = forkChoice;
|
|
429
429
|
|
|
430
|
+
this.builderCircuitBreaker = new BuilderCircuitBreaker(
|
|
431
|
+
{faultInspectionWindow: opts.faultInspectionWindow, allowedFaults: opts.allowedFaults},
|
|
432
|
+
{forkChoice, logger, metrics}
|
|
433
|
+
);
|
|
434
|
+
|
|
430
435
|
this.seenPayloadEnvelopeInputCache = new SeenPayloadEnvelopeInput({
|
|
431
436
|
config,
|
|
432
437
|
clock,
|
|
@@ -1473,7 +1478,6 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1473
1478
|
this.payloadAttestationPool.prune(slot);
|
|
1474
1479
|
this.executionPayloadBidPool.prune(slot);
|
|
1475
1480
|
this.seenExecutionPayloadBids.prune(slot);
|
|
1476
|
-
this.seenProposerPreferences.prune(slot);
|
|
1477
1481
|
this.proposerPreferencesPool.prune(slot);
|
|
1478
1482
|
this.seenAttestationDatas.onSlot(slot);
|
|
1479
1483
|
this.reprocessController.onSlot(slot);
|
package/src/chain/interface.ts
CHANGED
|
@@ -35,6 +35,7 @@ import {BeaconProposerCache, ProposerPreparationData} from "./beaconProposerCach
|
|
|
35
35
|
import {IBlockInput} from "./blocks/blockInput/index.js";
|
|
36
36
|
import {ImportBlockOpts, ImportPayloadOpts} from "./blocks/types.js";
|
|
37
37
|
import {IBlsVerifier} from "./bls/index.js";
|
|
38
|
+
import {BuilderCircuitBreaker} from "./builderCircuitBreaker.js";
|
|
38
39
|
import {ColumnReconstructionTracker} from "./ColumnReconstructionTracker.js";
|
|
39
40
|
import {ChainEventEmitter} from "./emitter.js";
|
|
40
41
|
import {ForkchoiceCaller} from "./forkChoice/index.js";
|
|
@@ -61,7 +62,6 @@ import {
|
|
|
61
62
|
SeenContributionAndProof,
|
|
62
63
|
SeenExecutionPayloadBids,
|
|
63
64
|
SeenPayloadAttesters,
|
|
64
|
-
SeenProposerPreferences,
|
|
65
65
|
SeenSyncCommitteeMessages,
|
|
66
66
|
} from "./seenCache/index.js";
|
|
67
67
|
import {SeenAggregatedAttestations} from "./seenCache/seenAggregateAndProof.js";
|
|
@@ -96,6 +96,7 @@ export interface IBeaconChain {
|
|
|
96
96
|
readonly earliestAvailableSlot: Slot;
|
|
97
97
|
readonly executionEngine: IExecutionEngine;
|
|
98
98
|
readonly executionBuilder?: IExecutionBuilder;
|
|
99
|
+
readonly builderCircuitBreaker: BuilderCircuitBreaker;
|
|
99
100
|
// Expose config for convenience in modularized functions
|
|
100
101
|
readonly config: BeaconConfig;
|
|
101
102
|
readonly custodyConfig: CustodyConfig;
|
|
@@ -133,7 +134,6 @@ export interface IBeaconChain {
|
|
|
133
134
|
readonly seenPayloadAttesters: SeenPayloadAttesters;
|
|
134
135
|
readonly seenAggregatedAttestations: SeenAggregatedAttestations;
|
|
135
136
|
readonly seenExecutionPayloadBids: SeenExecutionPayloadBids;
|
|
136
|
-
readonly seenProposerPreferences: SeenProposerPreferences;
|
|
137
137
|
readonly seenBlockProposers: SeenBlockProposers;
|
|
138
138
|
readonly seenSyncCommitteeMessages: SeenSyncCommitteeMessages;
|
|
139
139
|
readonly seenContributionAndProof: SeenContributionAndProof;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {RootHex, Slot, gloas} from "@lodestar/types";
|
|
1
|
+
import {RootHex, Slot, ValidatorIndex, gloas} from "@lodestar/types";
|
|
2
2
|
import {toRootHex} from "@lodestar/utils";
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -22,6 +22,10 @@ export class ProposerPreferencesPool {
|
|
|
22
22
|
return this.bySlot.get(slot)?.get(dependentRootHex) ?? null;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
isKnown(proposalSlot: Slot, dependentRoot: RootHex, validatorIndex: ValidatorIndex): boolean {
|
|
26
|
+
return this.get(proposalSlot, dependentRoot)?.message.validatorIndex === validatorIndex;
|
|
27
|
+
}
|
|
28
|
+
|
|
25
29
|
add(signed: gloas.SignedProposerPreferences): void {
|
|
26
30
|
const {proposalSlot, dependentRoot} = signed.message;
|
|
27
31
|
const rootHex = toRootHex(dependentRoot);
|
package/src/chain/options.ts
CHANGED
|
@@ -35,6 +35,7 @@ export type IChainOptions = BlockProcessOpts &
|
|
|
35
35
|
persistOrphanedBlocksDir?: string;
|
|
36
36
|
skipCreateStateCacheIfAvailable?: boolean;
|
|
37
37
|
suggestedFeeRecipient: string;
|
|
38
|
+
graffitiAppend?: boolean;
|
|
38
39
|
maxSkipSlots?: number;
|
|
39
40
|
/** Ensure blobs returned by the execution engine are valid */
|
|
40
41
|
sanityCheckExecutionEngineBlobs?: boolean;
|
|
@@ -48,6 +49,10 @@ export type IChainOptions = BlockProcessOpts &
|
|
|
48
49
|
archiveDateEpochs?: number;
|
|
49
50
|
nHistoricalStatesFileDataStore?: boolean;
|
|
50
51
|
nativeStateView?: boolean;
|
|
52
|
+
/** Builder circuit breaker fault inspection window in slots */
|
|
53
|
+
faultInspectionWindow?: number;
|
|
54
|
+
/** Allowed unrevealed payloads within the fault inspection window */
|
|
55
|
+
allowedFaults?: number;
|
|
51
56
|
};
|
|
52
57
|
|
|
53
58
|
export type BlockProcessOpts = {
|
|
@@ -107,6 +112,7 @@ export const defaultChainOptions: IChainOptions = {
|
|
|
107
112
|
computeUnrealized: true,
|
|
108
113
|
fastConfirmation: false,
|
|
109
114
|
suggestedFeeRecipient: defaultValidatorOptions.suggestedFeeRecipient,
|
|
115
|
+
graffitiAppend: true,
|
|
110
116
|
serveHistoricalState: false,
|
|
111
117
|
assertCorrectProgressiveBalances: false,
|
|
112
118
|
archiveStateEpochFrequency: 1024,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {routes} from "@lodestar/api";
|
|
2
2
|
import {ChainForkConfig} from "@lodestar/config";
|
|
3
3
|
import {getSafeExecutionBlockHash} from "@lodestar/fork-choice";
|
|
4
|
-
import {ForkPostBellatrix, ForkSeq, SLOTS_PER_EPOCH, isForkPostBellatrix} from "@lodestar/params";
|
|
4
|
+
import {ForkPostBellatrix, ForkSeq, SLOTS_PER_EPOCH, isForkPostBellatrix, isForkPostGloas} from "@lodestar/params";
|
|
5
5
|
import {
|
|
6
6
|
IBeaconStateView,
|
|
7
7
|
IBeaconStateViewBellatrix,
|
|
@@ -152,12 +152,16 @@ export class PrepareNextSlotScheduler {
|
|
|
152
152
|
updatedHead = proposerHead;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
155
|
+
if (isForkPostGloas(fork)) {
|
|
156
|
+
this.chain.builderCircuitBreaker.update(clockSlot);
|
|
157
|
+
} else {
|
|
158
|
+
// Update the builder status, if enabled shoot an api call to check status
|
|
159
|
+
this.chain.updateBuilderStatus(clockSlot);
|
|
160
|
+
if (this.chain.executionBuilder?.status === BuilderStatus.enabled) {
|
|
161
|
+
this.chain.executionBuilder.checkStatus().catch((e) => {
|
|
162
|
+
this.logger.error("Builder disabled as the check status api failed", {prepareSlot}, e as Error);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
161
165
|
}
|
|
162
166
|
}
|
|
163
167
|
|
|
@@ -43,6 +43,7 @@ import {
|
|
|
43
43
|
ValidatorIndex,
|
|
44
44
|
Wei,
|
|
45
45
|
altair,
|
|
46
|
+
bellatrix,
|
|
46
47
|
capella,
|
|
47
48
|
deneb,
|
|
48
49
|
electra,
|
|
@@ -830,28 +831,19 @@ export function getPayloadAttributesForSSE(
|
|
|
830
831
|
feeRecipient,
|
|
831
832
|
});
|
|
832
833
|
|
|
833
|
-
|
|
834
|
-
if (isForkPostGloas(fork)) {
|
|
835
|
-
const parentBlock = chain.forkChoice.getBlockHexAndBlockHash(
|
|
836
|
-
toRootHex(parentBlockRoot),
|
|
837
|
-
toRootHex(parentBlockHash)
|
|
838
|
-
);
|
|
839
|
-
if (parentBlock?.executionPayloadBlockHash == null) {
|
|
840
|
-
throw Error(`Parent block not found in fork choice root=${toRootHex(parentBlockRoot)}`);
|
|
841
|
-
}
|
|
842
|
-
parentBlockNumber = parentBlock.executionPayloadNumber;
|
|
843
|
-
} else {
|
|
844
|
-
parentBlockNumber = prepareState.payloadBlockNumber;
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
const ssePayloadAttributes: SSEPayloadAttributes = {
|
|
834
|
+
const ssePayloadAttributes = {
|
|
848
835
|
proposerIndex: prepareState.getBeaconProposer(prepareSlot),
|
|
849
836
|
proposalSlot: prepareSlot,
|
|
850
|
-
parentBlockNumber,
|
|
851
837
|
parentBlockRoot,
|
|
852
838
|
parentBlockHash,
|
|
853
839
|
payloadAttributes,
|
|
854
|
-
};
|
|
840
|
+
} as SSEPayloadAttributes;
|
|
841
|
+
|
|
842
|
+
if (!isForkPostGloas(fork)) {
|
|
843
|
+
// Removed in Gloas, builders can get the block number from the EL via the block hash if required
|
|
844
|
+
(ssePayloadAttributes as bellatrix.SSEPayloadAttributes).parentBlockNumber = prepareState.payloadBlockNumber;
|
|
845
|
+
}
|
|
846
|
+
|
|
855
847
|
return ssePayloadAttributes;
|
|
856
848
|
}
|
|
857
849
|
|
|
@@ -5,4 +5,3 @@ export {SeenContributionAndProof} from "./seenCommitteeContribution.js";
|
|
|
5
5
|
export {SeenExecutionPayloadBids} from "./seenExecutionPayloadBids.js";
|
|
6
6
|
export {SeenBlockInput} from "./seenGossipBlockInput.js";
|
|
7
7
|
export {PayloadEnvelopeInput, SeenPayloadEnvelopeInput} from "./seenPayloadEnvelopeInput.js";
|
|
8
|
-
export {SeenProposerPreferences} from "./seenProposerPreferences.js";
|
|
@@ -37,9 +37,11 @@ async function validateExecutionPayloadBid(
|
|
|
37
37
|
const parentBlockRootHex = toRootHex(bid.parentBlockRoot);
|
|
38
38
|
const parentBlockHashHex = toRootHex(bid.parentBlockHash);
|
|
39
39
|
|
|
40
|
-
// [IGNORE] `bid.slot` is the current slot or the next slot.
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
// [IGNORE] `bid.slot` is the current slot, or the next slot (`bid.slot - 1` is current), allowing for `MAXIMUM_GOSSIP_CLOCK_DISPARITY`.
|
|
41
|
+
if (
|
|
42
|
+
!chain.clock.isCurrentSlotGivenGossipDisparity(bid.slot) &&
|
|
43
|
+
!chain.clock.isCurrentSlotGivenGossipDisparity(bid.slot - 1)
|
|
44
|
+
) {
|
|
43
45
|
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
44
46
|
code: ExecutionPayloadBidErrorCode.INVALID_SLOT,
|
|
45
47
|
builderIndex: bid.builderIndex,
|
|
@@ -122,17 +124,20 @@ async function validateExecutionPayloadBid(
|
|
|
122
124
|
throw new Error(`Expected gloas+ state for execution payload bid validation, got fork=${state.forkName}`);
|
|
123
125
|
}
|
|
124
126
|
|
|
125
|
-
// [REJECT] `bid.builder_index` is
|
|
126
|
-
// `
|
|
127
|
-
|
|
128
|
-
try
|
|
129
|
-
|
|
130
|
-
} catch {
|
|
127
|
+
// [REJECT] `bid.builder_index` is within bounds -- i.e. `bid.builder_index < len(state.builders)`.
|
|
128
|
+
// `state.getBuilder` returns a lazy SSZ `getReadonly` view that is not bounds-checked eagerly; an
|
|
129
|
+
// out-of-range index only throws (`LeafNode has no right node`) on deferred field access (e.g. inside
|
|
130
|
+
// `isActiveBuilder`), escaping a try/catch around `getBuilder`. Check the length explicitly instead.
|
|
131
|
+
if (bid.builderIndex >= state.getBuildersLength()) {
|
|
131
132
|
throw new ExecutionPayloadBidError(GossipAction.REJECT, {
|
|
132
133
|
code: ExecutionPayloadBidErrorCode.BUILDER_NOT_ELIGIBLE,
|
|
133
134
|
builderIndex: bid.builderIndex,
|
|
134
135
|
});
|
|
135
136
|
}
|
|
137
|
+
|
|
138
|
+
// [REJECT] `bid.builder_index` is a valid/active builder index -- i.e.
|
|
139
|
+
// `is_active_builder(state, bid.builder_index)` returns `True`.
|
|
140
|
+
const builder = state.getBuilder(bid.builderIndex);
|
|
136
141
|
if (!isActiveBuilder(builder, state.finalizedCheckpoint.epoch)) {
|
|
137
142
|
throw new ExecutionPayloadBidError(GossipAction.REJECT, {
|
|
138
143
|
code: ExecutionPayloadBidErrorCode.BUILDER_NOT_ELIGIBLE,
|
|
@@ -32,8 +32,9 @@ export async function validateGossipProposerPreferences(
|
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
// [IGNORE] `preferences.proposal_slot` has not already passed.
|
|
36
|
-
|
|
35
|
+
// [IGNORE] `preferences.proposal_slot` has not already passed, i.e. `proposal_slot > current_slot`,
|
|
36
|
+
// allowing for `MAXIMUM_GOSSIP_CLOCK_DISPARITY`.
|
|
37
|
+
const currentSlot = chain.clock.currentSlotWithGossipDisparity;
|
|
37
38
|
if (proposalSlot <= currentSlot) {
|
|
38
39
|
throw new ProposerPreferencesError(GossipAction.IGNORE, {
|
|
39
40
|
code: ProposerPreferencesErrorCode.PROPOSAL_SLOT_PASSED,
|
|
@@ -81,7 +82,7 @@ export async function validateGossipProposerPreferences(
|
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
// [IGNORE] First valid message for (dependent_root, proposal_slot, validator_index).
|
|
84
|
-
if (chain.
|
|
85
|
+
if (chain.proposerPreferencesPool.isKnown(proposalSlot, dependentRootHex, validatorIndex)) {
|
|
85
86
|
throw new ProposerPreferencesError(GossipAction.IGNORE, {
|
|
86
87
|
code: ProposerPreferencesErrorCode.ALREADY_KNOWN,
|
|
87
88
|
proposalSlot,
|
|
@@ -105,6 +106,15 @@ export async function validateGossipProposerPreferences(
|
|
|
105
106
|
});
|
|
106
107
|
}
|
|
107
108
|
|
|
108
|
-
//
|
|
109
|
-
chain.
|
|
109
|
+
// Repeated check - deals with race-condition between preferences submissions
|
|
110
|
+
if (chain.proposerPreferencesPool.isKnown(proposalSlot, dependentRootHex, validatorIndex)) {
|
|
111
|
+
throw new ProposerPreferencesError(GossipAction.IGNORE, {
|
|
112
|
+
code: ProposerPreferencesErrorCode.ALREADY_KNOWN,
|
|
113
|
+
proposalSlot,
|
|
114
|
+
validatorIndex,
|
|
115
|
+
dependentRoot: dependentRootHex,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
chain.proposerPreferencesPool.add(signedProposerPreferences);
|
|
110
120
|
}
|
|
@@ -70,6 +70,33 @@ export class NoBidReceived extends Error {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Beacon clients select randomized values from the following ranges when initializing
|
|
75
|
+
* the circuit breaker (so at boot time and once for each unique boot).
|
|
76
|
+
*
|
|
77
|
+
* ALLOWED_FAULTS: between 1 and SLOTS_PER_EPOCH // 4
|
|
78
|
+
* FAULT_INSPECTION_WINDOW: between SLOTS_PER_EPOCH and 2 * SLOTS_PER_EPOCH
|
|
79
|
+
*
|
|
80
|
+
* The values are randomized per node so builders cannot predict when a given proposer will
|
|
81
|
+
* fall back to local blocks. With fixed thresholds a builder could withhold payloads right up
|
|
82
|
+
* to the limit without ever tripping the breaker.
|
|
83
|
+
*/
|
|
84
|
+
export function getFaultInspectionParams(opts: {faultInspectionWindow?: number; allowedFaults?: number}): {
|
|
85
|
+
faultInspectionWindow: number;
|
|
86
|
+
allowedFaults: number;
|
|
87
|
+
} {
|
|
88
|
+
const faultInspectionWindow = Math.max(
|
|
89
|
+
opts.faultInspectionWindow ?? SLOTS_PER_EPOCH + Math.floor(Math.random() * SLOTS_PER_EPOCH),
|
|
90
|
+
SLOTS_PER_EPOCH
|
|
91
|
+
);
|
|
92
|
+
// allowedFaults should be < faultInspectionWindow, limiting them to faultInspectionWindow/4
|
|
93
|
+
const allowedFaults = Math.min(
|
|
94
|
+
opts.allowedFaults ?? Math.floor(faultInspectionWindow / 4),
|
|
95
|
+
Math.floor(faultInspectionWindow / 4)
|
|
96
|
+
);
|
|
97
|
+
return {faultInspectionWindow, allowedFaults};
|
|
98
|
+
}
|
|
99
|
+
|
|
73
100
|
/**
|
|
74
101
|
* Additional duration to account for potential event loop lag which causes
|
|
75
102
|
* builder blocks to be rejected even though the response was sent in time.
|
|
@@ -122,23 +149,9 @@ export class ExecutionBuilderHttp implements IExecutionBuilder {
|
|
|
122
149
|
this.registrations = new ValidatorRegistrationCache();
|
|
123
150
|
this.issueLocalFcUWithFeeRecipient = opts.issueLocalFcUWithFeeRecipient;
|
|
124
151
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
*
|
|
129
|
-
* ALLOWED_FAULTS: between 1 and SLOTS_PER_EPOCH // 4
|
|
130
|
-
* FAULT_INSPECTION_WINDOW: between SLOTS_PER_EPOCH and 2 * SLOTS_PER_EPOCH
|
|
131
|
-
*
|
|
132
|
-
*/
|
|
133
|
-
this.faultInspectionWindow = Math.max(
|
|
134
|
-
opts.faultInspectionWindow ?? SLOTS_PER_EPOCH + Math.floor(Math.random() * SLOTS_PER_EPOCH),
|
|
135
|
-
SLOTS_PER_EPOCH
|
|
136
|
-
);
|
|
137
|
-
// allowedFaults should be < faultInspectionWindow, limiting them to faultInspectionWindow/4
|
|
138
|
-
this.allowedFaults = Math.min(
|
|
139
|
-
opts.allowedFaults ?? Math.floor(this.faultInspectionWindow / 4),
|
|
140
|
-
Math.floor(this.faultInspectionWindow / 4)
|
|
141
|
-
);
|
|
152
|
+
const {faultInspectionWindow, allowedFaults} = getFaultInspectionParams(opts);
|
|
153
|
+
this.faultInspectionWindow = faultInspectionWindow;
|
|
154
|
+
this.allowedFaults = allowedFaults;
|
|
142
155
|
}
|
|
143
156
|
|
|
144
157
|
updateStatus(status: BuilderStatus): void {
|
|
@@ -138,6 +138,25 @@ export function createBeaconMetrics(register: RegistryMetricCreator) {
|
|
|
138
138
|
help: "Count of cached produced results",
|
|
139
139
|
}),
|
|
140
140
|
|
|
141
|
+
builderCircuitBreaker: {
|
|
142
|
+
active: register.gauge({
|
|
143
|
+
name: "beacon_builder_circuit_breaker_active",
|
|
144
|
+
help: "Whether the builder circuit breaker is active (1) causing builder bids to be ignored",
|
|
145
|
+
}),
|
|
146
|
+
faults: register.gauge({
|
|
147
|
+
name: "beacon_builder_circuit_breaker_faults",
|
|
148
|
+
help: "Count of blocks with unrevealed payloads in the fault inspection window",
|
|
149
|
+
}),
|
|
150
|
+
blocksPresent: register.gauge({
|
|
151
|
+
name: "beacon_builder_circuit_breaker_blocks_present",
|
|
152
|
+
help: "Count of blocks present in the fault inspection window",
|
|
153
|
+
}),
|
|
154
|
+
payloadsRevealed: register.gauge({
|
|
155
|
+
name: "beacon_builder_circuit_breaker_payloads_revealed",
|
|
156
|
+
help: "Count of blocks with revealed payloads in the fault inspection window",
|
|
157
|
+
}),
|
|
158
|
+
},
|
|
159
|
+
|
|
141
160
|
blockPayload: {
|
|
142
161
|
payloadAdvancePrepTime: register.histogram({
|
|
143
162
|
name: "beacon_block_payload_prepare_time",
|
|
@@ -127,6 +127,100 @@ export function createNetworkCoreMetrics(register: RegistryMetricCreator) {
|
|
|
127
127
|
name: "lodestar_peer_manager_starved_bool",
|
|
128
128
|
help: "Whether lodestar is starved of data while syncing",
|
|
129
129
|
}),
|
|
130
|
+
/**
|
|
131
|
+
* Core selection/pruning phase of the heartbeat, split out of heartbeatDuration so it
|
|
132
|
+
* can be attributed on its own. Divide by peersEvaluated for time-per-peer.
|
|
133
|
+
*/
|
|
134
|
+
prioritizePeersDuration: register.histogram({
|
|
135
|
+
name: "lodestar_peer_manager_prioritize_peers_seconds",
|
|
136
|
+
help: "prioritizePeers function duration in seconds, the core peer selection/pruning algorithm",
|
|
137
|
+
buckets: [0.0005, 0.001, 0.005, 0.01, 0.05, 0.1],
|
|
138
|
+
}),
|
|
139
|
+
/**
|
|
140
|
+
* Score decay + map prune over every tracked peer, split out of heartbeatDuration.
|
|
141
|
+
* This loop iterates the whole score store, so divide by scoreMapSize (not
|
|
142
|
+
* peersEvaluated) for time-per-peer.
|
|
143
|
+
*/
|
|
144
|
+
scoreUpdateDuration: register.histogram({
|
|
145
|
+
name: "lodestar_peer_score_update_seconds",
|
|
146
|
+
help: "Peer score store update (decay + prune over all peers) duration in seconds",
|
|
147
|
+
buckets: [0.0005, 0.001, 0.005, 0.01, 0.05, 0.1],
|
|
148
|
+
}),
|
|
149
|
+
/**
|
|
150
|
+
* Denominator for prioritizePeersDuration: it scales with the number of connected
|
|
151
|
+
* healthy peers, so time-per-peer (prioritizePeersDuration / this) is the comparable
|
|
152
|
+
* figure. For scoreUpdateDuration use scoreMapSize instead.
|
|
153
|
+
*/
|
|
154
|
+
peersEvaluated: register.histogram({
|
|
155
|
+
name: "lodestar_peer_manager_peers_evaluated_count",
|
|
156
|
+
help: "Number of connected healthy peers evaluated by prioritizePeers per heartbeat, denominator for prioritize_peers_seconds",
|
|
157
|
+
buckets: [0, 25, 50, 75, 100, 150, 200],
|
|
158
|
+
}),
|
|
159
|
+
/**
|
|
160
|
+
* Every peer the manager intends to disconnect. Covers both the top-of-heartbeat
|
|
161
|
+
* bad-score disconnects ("banned"/"score_too_low") and the prioritization reasons;
|
|
162
|
+
* the older peersRequestedToDisconnect gauge only recorded the latter. Counts intent,
|
|
163
|
+
* not completion (goodbye is fire-and-forget).
|
|
164
|
+
*/
|
|
165
|
+
peersPruned: register.counter<{reason: string}>({
|
|
166
|
+
name: "lodestar_peer_manager_peers_pruned_total",
|
|
167
|
+
help: "Total peers the peer manager intends to disconnect, labeled by reason (incl. bad-score and prioritization reasons)",
|
|
168
|
+
labelNames: ["reason"],
|
|
169
|
+
}),
|
|
170
|
+
/**
|
|
171
|
+
* Actual peer count per active subnet, to check the min-peers-per-subnet invariant.
|
|
172
|
+
* Buckets straddle the target (TARGET_SUBNET_PEERS = 6).
|
|
173
|
+
*/
|
|
174
|
+
peersPerActiveSubnet: register.histogram<{type: SubnetType}>({
|
|
175
|
+
name: "lodestar_peer_manager_peers_per_active_subnet",
|
|
176
|
+
help: "Histogram of connected peer count per active subnet, labeled by subnet type",
|
|
177
|
+
labelNames: ["type"],
|
|
178
|
+
buckets: [0, 2, 4, 6, 8, 12],
|
|
179
|
+
}),
|
|
180
|
+
/**
|
|
181
|
+
* Live outbound ratio, to check the OUTBOUND_PEERS_RATIO (10%) invariant (issue #2215).
|
|
182
|
+
* Denominator is connected healthy peers (banned/disconnected already removed).
|
|
183
|
+
*/
|
|
184
|
+
outboundPeersRatio: register.gauge({
|
|
185
|
+
name: "lodestar_peer_manager_outbound_peers_ratio",
|
|
186
|
+
help: "Ratio of outbound peers to total connected healthy peers, verifies the outbound peers invariant",
|
|
187
|
+
}),
|
|
188
|
+
/**
|
|
189
|
+
* Score state crossings (Healthy/Disconnected/Banned). Sensitive to the decay formula,
|
|
190
|
+
* thresholds, and gossip-score weighting.
|
|
191
|
+
*/
|
|
192
|
+
scoreStateTransitions: register.counter<{from: string; to: string}>({
|
|
193
|
+
name: "lodestar_peer_score_state_transitions_total",
|
|
194
|
+
help: "Total peer score state transitions, labeled by from and to state (Healthy/Disconnected/Banned)",
|
|
195
|
+
labelNames: ["from", "to"],
|
|
196
|
+
}),
|
|
197
|
+
/**
|
|
198
|
+
* Entry count of the score store (not bytes). Reflects the prune-to-MAX_ENTRIES /
|
|
199
|
+
* SCORE_THRESHOLD retention logic. Also the denominator for scoreUpdateDuration
|
|
200
|
+
* time-per-peer (that loop iterates the whole store, not just connected peers).
|
|
201
|
+
*/
|
|
202
|
+
scoreMapSize: register.gauge({
|
|
203
|
+
name: "lodestar_peer_manager_score_map_size",
|
|
204
|
+
help: "Current number of entries in the peer score store",
|
|
205
|
+
}),
|
|
206
|
+
/**
|
|
207
|
+
* Entry count of the connectedPeers map (not bytes). Should track libp2p_peers; a
|
|
208
|
+
* persistent gap indicates the connection leak guarded by leakedConnectionsCount.
|
|
209
|
+
*/
|
|
210
|
+
connectedPeersMapSize: register.gauge({
|
|
211
|
+
name: "lodestar_peer_manager_connected_peers_map_size",
|
|
212
|
+
help: "Current number of entries in the peer manager connectedPeers map",
|
|
213
|
+
}),
|
|
214
|
+
/**
|
|
215
|
+
* assertPeerRelevance outcome per Status exchange: "relevant", an irrelevant reason
|
|
216
|
+
* code, or "error". Fires on every status evaluation (inbound requests and our own
|
|
217
|
+
* requestStatus responses both route through onStatus).
|
|
218
|
+
*/
|
|
219
|
+
relevanceCheck: register.counter<{result: string}>({
|
|
220
|
+
name: "lodestar_peer_relevance_check_total",
|
|
221
|
+
help: "Total peer relevance checks on Status, labeled by result (relevant or irrelevant reason code)",
|
|
222
|
+
labelNames: ["result"],
|
|
223
|
+
}),
|
|
130
224
|
},
|
|
131
225
|
leakedConnectionsCount: register.gauge({
|
|
132
226
|
name: "lodestar_peer_manager_leaked_connections_count",
|
|
@@ -13,9 +13,17 @@ export enum ENRRelevance {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export function enrRelevance(enr: ENR, config: BeaconConfig, clock: IClock): ENRRelevance {
|
|
16
|
-
// We are not interested in peers that don't advertise at least one transport (tcp or quic)
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
// We are not interested in peers that don't advertise at least one transport (tcp or quic).
|
|
17
|
+
let multiaddrTCP: ReturnType<ENR["getLocationMultiaddr"]>;
|
|
18
|
+
let multiaddrQUIC: ReturnType<ENR["getLocationMultiaddr"]>;
|
|
19
|
+
// Malformed ENR endpoint fields can make multiaddr conversion throw.
|
|
20
|
+
// Treat endpoints that cannot be converted as unusable.
|
|
21
|
+
try {
|
|
22
|
+
multiaddrTCP = enr.getLocationMultiaddr(ENRKey.tcp);
|
|
23
|
+
multiaddrQUIC = enr.getLocationMultiaddr(ENRKey.quic);
|
|
24
|
+
} catch {
|
|
25
|
+
return ENRRelevance.no_transport;
|
|
26
|
+
}
|
|
19
27
|
if (!multiaddrTCP && !multiaddrQUIC) {
|
|
20
28
|
return ENRRelevance.no_transport;
|
|
21
29
|
}
|
|
@@ -52,6 +52,13 @@ export function fastMsgIdFn(rpcMsg: RPC.Message): string {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
export function msgIdToStrFn(msgId: Uint8Array): string {
|
|
55
|
+
// Spec mandates a 20-byte gossipsub message-id, but control-message IDs from peers
|
|
56
|
+
// can be any length. Reject non-20-byte IDs to avoid a Buffer.set() RangeError on
|
|
57
|
+
// longer IDs and stale shared-buffer bytes on shorter ones.
|
|
58
|
+
// Ref: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.10/specs/phase0/p2p-interface.md?plain=1#L486
|
|
59
|
+
if (msgId.length !== 20) {
|
|
60
|
+
throw Error(`Expect msgId to be 20 bytes, got ${msgId.length}`);
|
|
61
|
+
}
|
|
55
62
|
// this is the same logic to `toHex(msgId)` with better performance
|
|
56
63
|
sharedMsgIdBuf.set(msgId);
|
|
57
64
|
return `0x${sharedMsgIdBuf.toString("hex")}`;
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
computeGossipPeerScoreParams,
|
|
36
36
|
gossipScoreThresholds,
|
|
37
37
|
} from "./scoringParameters.js";
|
|
38
|
-
import {GossipTopicCache, getCoreTopicsAtFork, stringifyGossipTopic} from "./topic.js";
|
|
38
|
+
import {GossipTopicCache, getAllowedTopics, getCoreTopicsAtFork, stringifyGossipTopic} from "./topic.js";
|
|
39
39
|
|
|
40
40
|
/** As specified in https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/p2p-interface.md */
|
|
41
41
|
const GOSSIPSUB_HEARTBEAT_INTERVAL = 0.7 * 1000;
|
|
@@ -140,6 +140,7 @@ export class Eth2Gossipsub {
|
|
|
140
140
|
const gossipsubInstance = gossipsub({
|
|
141
141
|
globalSignaturePolicy: StrictNoSign,
|
|
142
142
|
allowPublishToZeroTopicPeers: allowPublishToZeroPeers,
|
|
143
|
+
allowedTopics: getAllowedTopics(networkConfig),
|
|
143
144
|
D: gossipsubD ?? GOSSIP_D,
|
|
144
145
|
Dlo: gossipsubDLow ?? GOSSIP_D_LOW,
|
|
145
146
|
Dhi: gossipsubDHigh ?? GOSSIP_D_HIGH,
|