@lodestar/beacon-node 1.47.0-dev.931ecbec99 → 1.47.0-dev.9ba9a5ce85
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 +44 -12
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/beacon/pool/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/pool/index.js +21 -2
- package/lib/api/impl/beacon/pool/index.js.map +1 -1
- package/lib/api/impl/events/index.d.ts.map +1 -1
- package/lib/api/impl/events/index.js +2 -0
- package/lib/api/impl/events/index.js.map +1 -1
- package/lib/api/impl/lodestar/index.js +1 -1
- package/lib/api/impl/lodestar/index.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +237 -49
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/api/impl/validator/utils.js +1 -1
- package/lib/api/impl/validator/utils.js.map +1 -1
- package/lib/api/rest/base.d.ts.map +1 -1
- package/lib/api/rest/base.js +7 -0
- package/lib/api/rest/base.js.map +1 -1
- package/lib/chain/archiveStore/archiveStore.js +1 -1
- package/lib/chain/archiveStore/archiveStore.js.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts +3 -2
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +10 -8
- 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 +21 -13
- package/lib/chain/blocks/index.js.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +2 -1
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +6 -2
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +14 -5
- package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/types.js +5 -0
- package/lib/chain/blocks/payloadEnvelopeInput/types.js.map +1 -1
- package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlock.js +5 -2
- package/lib/chain/blocks/verifyBlock.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js +22 -12
- package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js.map +1 -1
- package/lib/chain/chain.d.ts +7 -3
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +16 -4
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/errors/blockError.d.ts +1 -0
- package/lib/chain/errors/blockError.d.ts.map +1 -1
- package/lib/chain/errors/blockError.js +6 -1
- package/lib/chain/errors/blockError.js.map +1 -1
- package/lib/chain/errors/executionPayloadBid.d.ts +5 -0
- package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadBid.js +1 -0
- package/lib/chain/errors/executionPayloadBid.js.map +1 -1
- package/lib/chain/forkChoice/index.d.ts.map +1 -1
- package/lib/chain/forkChoice/index.js +4 -0
- package/lib/chain/forkChoice/index.js.map +1 -1
- package/lib/chain/interface.d.ts +6 -3
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/interface.js.map +1 -1
- package/lib/chain/opPools/deferredVoluntaryExitPool.d.ts +16 -0
- package/lib/chain/opPools/deferredVoluntaryExitPool.d.ts.map +1 -0
- package/lib/chain/opPools/deferredVoluntaryExitPool.js +57 -0
- package/lib/chain/opPools/deferredVoluntaryExitPool.js.map +1 -0
- package/lib/chain/opPools/executionPayloadBidPool.d.ts +7 -2
- package/lib/chain/opPools/executionPayloadBidPool.d.ts.map +1 -1
- package/lib/chain/opPools/executionPayloadBidPool.js +4 -4
- package/lib/chain/opPools/executionPayloadBidPool.js.map +1 -1
- package/lib/chain/opPools/index.d.ts +2 -1
- package/lib/chain/opPools/index.d.ts.map +1 -1
- package/lib/chain/opPools/index.js +1 -0
- package/lib/chain/opPools/index.js.map +1 -1
- package/lib/chain/prepareNextSlot.d.ts +5 -0
- package/lib/chain/prepareNextSlot.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +47 -6
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
- package/lib/chain/produceBlock/computeNewStateRoot.js +3 -25
- package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/regen/interface.d.ts +5 -2
- package/lib/chain/regen/interface.d.ts.map +1 -1
- package/lib/chain/regen/interface.js +3 -0
- package/lib/chain/regen/interface.js.map +1 -1
- package/lib/chain/regen/queued.d.ts +2 -2
- package/lib/chain/regen/queued.d.ts.map +1 -1
- package/lib/chain/regen/queued.js +5 -5
- package/lib/chain/regen/queued.js.map +1 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +28 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +121 -13
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
- package/lib/chain/stateCache/fifoBlockStateCache.d.ts +5 -1
- package/lib/chain/stateCache/fifoBlockStateCache.d.ts.map +1 -1
- package/lib/chain/stateCache/fifoBlockStateCache.js +6 -0
- package/lib/chain/stateCache/fifoBlockStateCache.js.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +47 -5
- package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.js +117 -7
- package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
- package/lib/chain/stateCache/types.d.ts +3 -3
- package/lib/chain/stateCache/types.d.ts.map +1 -1
- package/lib/chain/validation/block.d.ts.map +1 -1
- package/lib/chain/validation/block.js +40 -10
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/chain/validation/executionPayloadBid.d.ts +15 -3
- package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/validation/executionPayloadBid.js +165 -10
- package/lib/chain/validation/executionPayloadBid.js.map +1 -1
- package/lib/chain/validation/voluntaryExit.d.ts +9 -1
- package/lib/chain/validation/voluntaryExit.d.ts.map +1 -1
- package/lib/chain/validation/voluntaryExit.js +46 -1
- package/lib/chain/validation/voluntaryExit.js.map +1 -1
- package/lib/execution/builder/apiClient.d.ts +70 -0
- package/lib/execution/builder/apiClient.d.ts.map +1 -0
- package/lib/execution/builder/apiClient.js +202 -0
- package/lib/execution/builder/apiClient.js.map +1 -0
- package/lib/execution/builder/validateBid.d.ts +23 -0
- package/lib/execution/builder/validateBid.d.ts.map +1 -0
- package/lib/execution/builder/validateBid.js +119 -0
- package/lib/execution/builder/validateBid.js.map +1 -0
- package/lib/metrics/metrics/lodestar.d.ts +46 -5
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +81 -5
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/gossip/topic.d.ts +13 -0
- package/lib/network/gossip/topic.d.ts.map +1 -1
- package/lib/network/gossip/topic.js +37 -0
- package/lib/network/gossip/topic.js.map +1 -1
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js +23 -43
- package/lib/network/network.js.map +1 -1
- package/lib/network/processor/constants.d.ts +7 -0
- package/lib/network/processor/constants.d.ts.map +1 -0
- package/lib/network/processor/constants.js +7 -0
- package/lib/network/processor/constants.js.map +1 -0
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +6 -2
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/gossipQueues/indexed.d.ts.map +1 -1
- package/lib/network/processor/gossipQueues/indexed.js +0 -1
- package/lib/network/processor/gossipQueues/indexed.js.map +1 -1
- package/lib/network/processor/index.d.ts +3 -0
- package/lib/network/processor/index.d.ts.map +1 -1
- package/lib/network/processor/index.js +52 -23
- package/lib/network/processor/index.js.map +1 -1
- package/lib/network/util.d.ts +0 -1
- package/lib/network/util.d.ts.map +1 -1
- package/lib/network/util.js +0 -4
- package/lib/network/util.js.map +1 -1
- package/lib/node/deferredVoluntaryExitPublisher.d.ts +15 -0
- package/lib/node/deferredVoluntaryExitPublisher.d.ts.map +1 -0
- package/lib/node/deferredVoluntaryExitPublisher.js +38 -0
- package/lib/node/deferredVoluntaryExitPublisher.js.map +1 -0
- package/lib/node/nodejs.d.ts.map +1 -1
- package/lib/node/nodejs.js +7 -0
- package/lib/node/nodejs.js.map +1 -1
- package/lib/sync/range/batch.d.ts +23 -5
- package/lib/sync/range/batch.d.ts.map +1 -1
- package/lib/sync/range/batch.js +61 -22
- package/lib/sync/range/batch.js.map +1 -1
- package/lib/sync/range/chain.d.ts +2 -1
- package/lib/sync/range/chain.d.ts.map +1 -1
- package/lib/sync/range/chain.js +32 -12
- package/lib/sync/range/chain.js.map +1 -1
- package/lib/sync/range/range.js +1 -1
- package/lib/sync/range/range.js.map +1 -1
- package/lib/sync/types.d.ts +32 -0
- package/lib/sync/types.d.ts.map +1 -1
- package/lib/sync/types.js +33 -0
- package/lib/sync/types.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts +6 -2
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +143 -68
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRange.js +16 -11
- package/lib/sync/utils/downloadByRange.js.map +1 -1
- package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRoot.js +3 -1
- package/lib/sync/utils/downloadByRoot.js.map +1 -1
- package/package.json +34 -34
- package/src/api/impl/beacon/blocks/index.ts +51 -15
- package/src/api/impl/beacon/pool/index.ts +22 -2
- package/src/api/impl/events/index.ts +3 -1
- package/src/api/impl/lodestar/index.ts +1 -1
- package/src/api/impl/validator/index.ts +290 -49
- package/src/api/impl/validator/utils.ts +1 -1
- package/src/api/rest/base.ts +7 -0
- package/src/chain/archiveStore/archiveStore.ts +1 -1
- package/src/chain/blocks/importExecutionPayload.ts +12 -10
- package/src/chain/blocks/index.ts +25 -13
- package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +8 -2
- package/src/chain/blocks/payloadEnvelopeInput/types.ts +17 -4
- package/src/chain/blocks/verifyBlock.ts +5 -2
- package/src/chain/blocks/verifyBlocksStateTransitionOnly.ts +25 -16
- package/src/chain/chain.ts +18 -2
- package/src/chain/errors/blockError.ts +8 -2
- package/src/chain/errors/executionPayloadBid.ts +6 -0
- package/src/chain/forkChoice/index.ts +4 -0
- package/src/chain/interface.ts +6 -2
- package/src/chain/opPools/deferredVoluntaryExitPool.ts +65 -0
- package/src/chain/opPools/executionPayloadBidPool.ts +13 -7
- package/src/chain/opPools/index.ts +2 -1
- package/src/chain/prepareNextSlot.ts +49 -6
- package/src/chain/produceBlock/computeNewStateRoot.ts +3 -38
- package/src/chain/produceBlock/produceBlockBody.ts +1 -1
- package/src/chain/regen/interface.ts +5 -2
- package/src/chain/regen/queued.ts +5 -5
- package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +143 -14
- package/src/chain/stateCache/fifoBlockStateCache.ts +8 -1
- package/src/chain/stateCache/persistentCheckpointsCache.ts +133 -8
- package/src/chain/stateCache/types.ts +3 -3
- package/src/chain/validation/block.ts +43 -10
- package/src/chain/validation/executionPayloadBid.ts +192 -12
- package/src/chain/validation/voluntaryExit.ts +59 -2
- package/src/execution/builder/apiClient.ts +264 -0
- package/src/execution/builder/validateBid.ts +181 -0
- package/src/metrics/metrics/lodestar.ts +91 -10
- package/src/network/gossip/topic.ts +38 -0
- package/src/network/network.ts +29 -54
- package/src/network/processor/constants.ts +6 -0
- package/src/network/processor/gossipHandlers.ts +6 -2
- package/src/network/processor/gossipQueues/indexed.ts +0 -1
- package/src/network/processor/index.ts +67 -30
- package/src/network/util.ts +0 -5
- package/src/node/deferredVoluntaryExitPublisher.ts +54 -0
- package/src/node/nodejs.ts +8 -0
- package/src/sync/range/batch.ts +83 -28
- package/src/sync/range/chain.ts +35 -13
- package/src/sync/range/range.ts +1 -1
- package/src/sync/types.ts +33 -0
- package/src/sync/unknownBlock.ts +167 -73
- package/src/sync/utils/downloadByRange.ts +21 -12
- package/src/sync/utils/downloadByRoot.ts +3 -1
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import {routes} from "@lodestar/api";
|
|
2
|
+
import {ApiClient as BuilderApi, getClient} from "@lodestar/api/builder";
|
|
3
|
+
import {ChainForkConfig} from "@lodestar/config";
|
|
4
|
+
import {Logger} from "@lodestar/logger";
|
|
5
|
+
import {DOMAIN_BUILDER_REQUEST_AUTH, ForkPostGloas} from "@lodestar/params";
|
|
6
|
+
import {
|
|
7
|
+
ZERO_HASH,
|
|
8
|
+
computeDomain,
|
|
9
|
+
computeSigningRoot,
|
|
10
|
+
createSingleSignatureSetFromComponents,
|
|
11
|
+
} from "@lodestar/state-transition";
|
|
12
|
+
import {BLSPubkey, Root, SignedBeaconBlock, Slot, WithOptionalBytes, gloas, ssz} from "@lodestar/types";
|
|
13
|
+
import {isValidAsciiHttpUrl, toHex, toPrintableUrl} from "@lodestar/utils";
|
|
14
|
+
import type {IBlsVerifier} from "../../chain/bls/index.js";
|
|
15
|
+
import {Metrics} from "../../metrics/metrics.js";
|
|
16
|
+
import {IClock} from "../../util/clock.js";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Additional duration to account for potential event loop lag which causes
|
|
20
|
+
* builder bids to be rejected even though the response was sent in time.
|
|
21
|
+
*/
|
|
22
|
+
const EVENT_LOOP_LAG_BUFFER = 250;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Duration given to a builder to provide a `SignedExecutionPayloadBid` before the deadline
|
|
26
|
+
* is reached, advertised on each bid request via the `X-Timeout-Ms` header. The p2p bid is
|
|
27
|
+
* selected after the same duration, only considering bids received up to that point.
|
|
28
|
+
*/
|
|
29
|
+
export const BUILDER_BID_DEADLINE_MS = 500;
|
|
30
|
+
|
|
31
|
+
/** Local timeout for bid requests, event loop lag must not discard bids that arrived in time */
|
|
32
|
+
export const BUILDER_BID_REQUEST_TIMEOUT_MS = BUILDER_BID_DEADLINE_MS + EVENT_LOOP_LAG_BUFFER;
|
|
33
|
+
|
|
34
|
+
export type BuilderApiClientOpts = {
|
|
35
|
+
/** Timeout for builder api requests, bid requests always use `BUILDER_BID_REQUEST_TIMEOUT_MS` */
|
|
36
|
+
timeout?: number;
|
|
37
|
+
// Add User-Agent header to all requests
|
|
38
|
+
userAgent?: string;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
type BuilderUrl = string;
|
|
42
|
+
|
|
43
|
+
/** Decode the SSZ URL bytes without allowing replacement characters or unsafe header values. */
|
|
44
|
+
export function decodeBuilderUrl(value: Uint8Array): BuilderUrl {
|
|
45
|
+
let url: string;
|
|
46
|
+
try {
|
|
47
|
+
url = new TextDecoder("utf8", {fatal: true}).decode(value);
|
|
48
|
+
} catch {
|
|
49
|
+
throw Error("Builder url must be valid UTF-8");
|
|
50
|
+
}
|
|
51
|
+
if (!isValidAsciiHttpUrl(url)) {
|
|
52
|
+
throw Error("Invalid builder url");
|
|
53
|
+
}
|
|
54
|
+
return url;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export type BuilderApiBid = {
|
|
58
|
+
url: BuilderUrl;
|
|
59
|
+
entry: routes.validator.BuilderEntry;
|
|
60
|
+
signedBid: gloas.SignedExecutionPayloadBid;
|
|
61
|
+
/** Time in milliseconds from the slot start when the bid was received */
|
|
62
|
+
receivedMs: number;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* External builder integration post-gloas
|
|
67
|
+
*
|
|
68
|
+
* The builder set is driven by the resolved `BuilderConfig` the validator client supplies on
|
|
69
|
+
* each block production request, clients are dialed on demand based on the entry `url`.
|
|
70
|
+
*/
|
|
71
|
+
export class BuilderApiClient {
|
|
72
|
+
private readonly clients = new Map<BuilderUrl, BuilderApi>();
|
|
73
|
+
|
|
74
|
+
constructor(
|
|
75
|
+
private readonly opts: BuilderApiClientOpts,
|
|
76
|
+
private readonly config: ChainForkConfig,
|
|
77
|
+
private readonly clock: IClock,
|
|
78
|
+
private readonly bls: IBlsVerifier,
|
|
79
|
+
private readonly metrics: Metrics | null = null,
|
|
80
|
+
private readonly logger?: Logger
|
|
81
|
+
) {}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Fan out bid requests to the builders named by the entries, one request per unique
|
|
85
|
+
* `(url, auth.message.data)` pair. Errors and empty responses (204) are logged and filtered
|
|
86
|
+
* out so a single unresponsive builder never fails block production.
|
|
87
|
+
*/
|
|
88
|
+
async getExecutionPayloadBids(
|
|
89
|
+
entries: routes.validator.BuilderEntry[],
|
|
90
|
+
slot: Slot,
|
|
91
|
+
parentHash: Root,
|
|
92
|
+
parentRoot: Root,
|
|
93
|
+
proposerPubkey: BLSPubkey
|
|
94
|
+
): Promise<BuilderApiBid[]> {
|
|
95
|
+
const seenRequests = new Set<string>();
|
|
96
|
+
const requests: {url: BuilderUrl; entry: routes.validator.BuilderEntry}[] = [];
|
|
97
|
+
|
|
98
|
+
for (const entry of entries) {
|
|
99
|
+
const urlForLog = Buffer.from(entry.url).toString("utf8");
|
|
100
|
+
let url: BuilderUrl;
|
|
101
|
+
try {
|
|
102
|
+
url = decodeBuilderUrl(entry.url);
|
|
103
|
+
} catch {
|
|
104
|
+
this.logger?.warn("Ignoring builder entry with invalid url", {slot, url: urlForLog});
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const requestKey = `${url}-${toHex(entry.auth.message.data)}`;
|
|
109
|
+
if (seenRequests.has(requestKey)) {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
seenRequests.add(requestKey);
|
|
113
|
+
|
|
114
|
+
// The builder rejects a mismatch, an entry naming a different slot is not used for a bid request
|
|
115
|
+
if (entry.auth.message.slot !== slot) {
|
|
116
|
+
this.logger?.warn("Ignoring builder entry with auth for different slot", {
|
|
117
|
+
slot,
|
|
118
|
+
authSlot: entry.auth.message.slot,
|
|
119
|
+
builder: toPrintableUrl(url),
|
|
120
|
+
});
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
requests.push({url, entry});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Collected in arrival order so an earlier received bid wins ties during candidate ranking
|
|
128
|
+
const bids: BuilderApiBid[] = [];
|
|
129
|
+
await Promise.all(
|
|
130
|
+
requests.map(async ({url, entry}) => {
|
|
131
|
+
this.metrics?.builderApi.bidRequests.inc();
|
|
132
|
+
try {
|
|
133
|
+
const client = await this.getOrCreateClient(url, proposerPubkey, entry.auth);
|
|
134
|
+
const res = await client.getExecutionPayloadBid(
|
|
135
|
+
{
|
|
136
|
+
slot,
|
|
137
|
+
parentHash,
|
|
138
|
+
parentRoot,
|
|
139
|
+
proposerPubkey,
|
|
140
|
+
requestAuth: entry.auth,
|
|
141
|
+
dateMilliseconds: Date.now(),
|
|
142
|
+
timeoutMs: BUILDER_BID_DEADLINE_MS,
|
|
143
|
+
},
|
|
144
|
+
{timeoutMs: BUILDER_BID_REQUEST_TIMEOUT_MS}
|
|
145
|
+
);
|
|
146
|
+
const signedBid = res.value();
|
|
147
|
+
if (signedBid === undefined) {
|
|
148
|
+
this.logger?.debug("No bid received from builder", {slot, builder: toPrintableUrl(url)});
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
this.metrics?.builderApi.bidsReceived.inc();
|
|
152
|
+
bids.push({url, entry, signedBid, receivedMs: this.clock.msFromSlot(slot)});
|
|
153
|
+
} catch (e) {
|
|
154
|
+
this.metrics?.builderApi.bidRequestErrors.inc();
|
|
155
|
+
this.logger?.warn("Failed to get bid from builder", {slot, builder: toPrintableUrl(url)}, e as Error);
|
|
156
|
+
}
|
|
157
|
+
})
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
return bids;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** Forward a proposer's builder preferences to the builder at the given url */
|
|
164
|
+
async submitBuilderPreferences(
|
|
165
|
+
url: BuilderUrl,
|
|
166
|
+
proposerPubkey: BLSPubkey,
|
|
167
|
+
request: gloas.BuilderPreferencesRequest
|
|
168
|
+
): Promise<void> {
|
|
169
|
+
try {
|
|
170
|
+
const client = await this.getOrCreateClient(url, proposerPubkey, request.auth);
|
|
171
|
+
(await client.submitBuilderPreferences({proposerPubkey, request})).assertOk();
|
|
172
|
+
this.metrics?.builderApi.preferencesForwarded.inc({status: "success"});
|
|
173
|
+
} catch (e) {
|
|
174
|
+
this.metrics?.builderApi.preferencesForwarded.inc({status: "error"});
|
|
175
|
+
throw e;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Submit the signed beacon block to the builder whose bid was included. The builder is
|
|
181
|
+
* then responsible for constructing and broadcasting the corresponding
|
|
182
|
+
* `SignedExecutionPayloadEnvelope`, no further action is required by the proposer.
|
|
183
|
+
*/
|
|
184
|
+
async submitSignedBeaconBlock(
|
|
185
|
+
url: BuilderUrl,
|
|
186
|
+
signedBlock: WithOptionalBytes<SignedBeaconBlock<ForkPostGloas>>
|
|
187
|
+
): Promise<void> {
|
|
188
|
+
const client = this.clients.get(url);
|
|
189
|
+
if (client === undefined) {
|
|
190
|
+
this.metrics?.builderApi.blockSubmissions.inc({status: "error"});
|
|
191
|
+
this.logger?.warn("Ignoring signed block submission to unauthenticated builder", {url});
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
try {
|
|
196
|
+
(await client.submitSignedBeaconBlock({signedBlock}, {redirect: "manual"})).assertOk();
|
|
197
|
+
this.metrics?.builderApi.blockSubmissions.inc({status: "success"});
|
|
198
|
+
} catch (e) {
|
|
199
|
+
this.metrics?.builderApi.blockSubmissions.inc({status: "error"});
|
|
200
|
+
throw e;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Establish the connection to every known builder outside the bid deadline, a cold TCP/TLS handshake
|
|
206
|
+
* to a distant builder can exhaust `BUILDER_BID_DEADLINE_MS` on its own, and a long idle connection
|
|
207
|
+
* may be half-open and only fail once written to.
|
|
208
|
+
*/
|
|
209
|
+
async checkStatus(): Promise<void> {
|
|
210
|
+
await Promise.all(
|
|
211
|
+
Array.from(this.clients.entries()).map(async ([url, client]) => {
|
|
212
|
+
try {
|
|
213
|
+
(await client.status()).assertOk();
|
|
214
|
+
this.metrics?.builderApi.statusChecks.inc({status: "success"});
|
|
215
|
+
this.logger?.debug("Builder is ready", {builder: toPrintableUrl(url)});
|
|
216
|
+
} catch (e) {
|
|
217
|
+
this.metrics?.builderApi.statusChecks.inc({status: "error"});
|
|
218
|
+
this.logger?.warn("Builder status check failed", {builder: toPrintableUrl(url)}, e as Error);
|
|
219
|
+
}
|
|
220
|
+
})
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
private async getOrCreateClient(
|
|
225
|
+
url: BuilderUrl,
|
|
226
|
+
proposerPubkey: BLSPubkey,
|
|
227
|
+
auth: gloas.SignedBuilderRequestAuth
|
|
228
|
+
): Promise<BuilderApi> {
|
|
229
|
+
if (auth.message.data.length === 0) {
|
|
230
|
+
throw Error("Builder request auth data must not be empty");
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
let client = this.clients.get(url);
|
|
234
|
+
if (client === undefined) {
|
|
235
|
+
const domain = computeDomain(DOMAIN_BUILDER_REQUEST_AUTH, this.config.GENESIS_FORK_VERSION, ZERO_HASH);
|
|
236
|
+
const signingRoot = computeSigningRoot(ssz.gloas.BuilderRequestAuth, auth.message, domain);
|
|
237
|
+
const signatureSet = createSingleSignatureSetFromComponents(proposerPubkey, signingRoot, auth.signature);
|
|
238
|
+
|
|
239
|
+
let isValid = false;
|
|
240
|
+
try {
|
|
241
|
+
isValid = await this.bls.verifySignatureSets([signatureSet]);
|
|
242
|
+
} catch {
|
|
243
|
+
// Malformed signatures are invalid request authentication.
|
|
244
|
+
}
|
|
245
|
+
if (!isValid) {
|
|
246
|
+
throw Error("Invalid builder request auth");
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
client = getClient(
|
|
250
|
+
{
|
|
251
|
+
baseUrl: url,
|
|
252
|
+
globalInit: {
|
|
253
|
+
timeoutMs: this.opts.timeout,
|
|
254
|
+
headers: this.opts.userAgent ? {"User-Agent": this.opts.userAgent} : undefined,
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
{config: this.config, metrics: this.metrics?.builderHttpClient, logger: this.logger}
|
|
258
|
+
);
|
|
259
|
+
this.clients.set(url, client);
|
|
260
|
+
this.logger?.debug("External builder registered", {url: toPrintableUrl(url)});
|
|
261
|
+
}
|
|
262
|
+
return client;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import {routes} from "@lodestar/api";
|
|
2
|
+
import {ProtoBlock} from "@lodestar/fork-choice";
|
|
3
|
+
import {MAX_EXECUTION_PAYMENT, PAYLOAD_BUILDER_VERSION} from "@lodestar/params";
|
|
4
|
+
import {
|
|
5
|
+
computeEpochAtSlot,
|
|
6
|
+
createSingleSignatureSetFromComponents,
|
|
7
|
+
getExecutionPayloadBidSigningRoot,
|
|
8
|
+
isActiveBuilder,
|
|
9
|
+
isGasLimitTargetCompatible,
|
|
10
|
+
isStatePostGloas,
|
|
11
|
+
} from "@lodestar/state-transition";
|
|
12
|
+
import {RootHex, Slot, gloas} from "@lodestar/types";
|
|
13
|
+
import {bigIntMin, byteArrayEquals, prettyGweiToEth, toHex, toRootHex} from "@lodestar/utils";
|
|
14
|
+
import {IBeaconChain} from "../../chain/index.js";
|
|
15
|
+
import {RegenCaller} from "../../chain/regen/index.js";
|
|
16
|
+
import {getShufflingDependentRoot} from "../../util/dependentRoot.js";
|
|
17
|
+
|
|
18
|
+
/** Return the counted bid payment in Gwei, saturated at uint64 max. */
|
|
19
|
+
export function getBuilderBidTotalGwei(bid: gloas.ExecutionPayloadBid, maxExecutionPayment: bigint): bigint {
|
|
20
|
+
return bigIntMin(MAX_EXECUTION_PAYMENT, BigInt(bid.value) + bigIntMin(bid.executionPayment, maxExecutionPayment));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Validate a bid received from a builder over the builder API in response to a bid request
|
|
25
|
+
* made during block production. Unlike gossip validation, the bid must match the requested
|
|
26
|
+
* slot and parent exactly, may carry a non-zero `executionPayment` which is counted at most at
|
|
27
|
+
* the entry's `maxExecutionPayment`, and is not subject to gossip anti-spam rules.
|
|
28
|
+
*
|
|
29
|
+
* Throws with a description of the failure, the caller drops the bid.
|
|
30
|
+
*/
|
|
31
|
+
export async function validateBuilderApiExecutionPayloadBid(
|
|
32
|
+
chain: IBeaconChain,
|
|
33
|
+
signedExecutionPayloadBid: gloas.SignedExecutionPayloadBid,
|
|
34
|
+
request: {
|
|
35
|
+
slot: Slot;
|
|
36
|
+
parentBlock: ProtoBlock;
|
|
37
|
+
parentBlockHash: RootHex;
|
|
38
|
+
parentBlockRoot: RootHex;
|
|
39
|
+
entry: routes.validator.BuilderEntry;
|
|
40
|
+
getParentExecutionRequests: () => Promise<gloas.ExecutionRequests>;
|
|
41
|
+
}
|
|
42
|
+
): Promise<void> {
|
|
43
|
+
const bid = signedExecutionPayloadBid.message;
|
|
44
|
+
const {slot, parentBlock, parentBlockHash, parentBlockRoot, entry, getParentExecutionRequests} = request;
|
|
45
|
+
|
|
46
|
+
if (bid.slot !== slot) {
|
|
47
|
+
throw Error(`Bid slot=${bid.slot} does not match requested slot=${slot}`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const bidParentBlockHash = toRootHex(bid.parentBlockHash);
|
|
51
|
+
const bidParentBlockRoot = toRootHex(bid.parentBlockRoot);
|
|
52
|
+
if (bidParentBlockHash !== parentBlockHash || bidParentBlockRoot !== parentBlockRoot) {
|
|
53
|
+
throw Error(
|
|
54
|
+
`Bid parent parentBlockHash=${bidParentBlockHash} parentBlockRoot=${bidParentBlockRoot} does not match ` +
|
|
55
|
+
`requested parentBlockHash=${parentBlockHash} parentBlockRoot=${parentBlockRoot}`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const totalPayment = getBuilderBidTotalGwei(bid, entry.maxExecutionPayment);
|
|
60
|
+
if (totalPayment < entry.minBid) {
|
|
61
|
+
throw Error(
|
|
62
|
+
`Bid total payment=${prettyGweiToEth(totalPayment)} ` +
|
|
63
|
+
`(value=${prettyGweiToEth(bid.value)} ` +
|
|
64
|
+
`executionPayment=${prettyGweiToEth(bid.executionPayment)}) ` +
|
|
65
|
+
`is below minBid=${prettyGweiToEth(entry.minBid)}`
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const state = await chain.regen
|
|
70
|
+
.getBlockSlotState(parentBlock, slot, {dontTransferCache: true}, RegenCaller.validateGossipExecutionPayloadBid)
|
|
71
|
+
.catch((e: Error) => {
|
|
72
|
+
throw Error(`Unable to regenerate state to validate bid: ${e.message}`);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
if (!isStatePostGloas(state)) {
|
|
76
|
+
throw Error(`Expected gloas+ state for execution payload bid validation, got fork=${state.forkName}`);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (bid.builderIndex >= state.getBuildersLength()) {
|
|
80
|
+
throw Error(`Bid builderIndex=${bid.builderIndex} is out of bounds`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const builder = state.getBuilder(bid.builderIndex);
|
|
84
|
+
if (!isActiveBuilder(builder, state.finalizedCheckpoint.epoch)) {
|
|
85
|
+
throw Error(`Bid builderIndex=${bid.builderIndex} is not an active builder`);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (builder.version !== PAYLOAD_BUILDER_VERSION) {
|
|
89
|
+
throw Error(`Invalid builder version=${builder.version} expected=${PAYLOAD_BUILDER_VERSION}`);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// A bid not signed by one of the builder pubkeys the entry accepts bids from must not be accepted
|
|
93
|
+
if (
|
|
94
|
+
entry.builderPubkeys.length > 0 &&
|
|
95
|
+
!entry.builderPubkeys.some((pubkey) => byteArrayEquals(pubkey, builder.pubkey))
|
|
96
|
+
) {
|
|
97
|
+
throw Error(
|
|
98
|
+
`Bid builder pubkey=${toHex(builder.pubkey)} is not in the entry's ` +
|
|
99
|
+
`builderPubkeys=${entry.builderPubkeys.map(toHex).join(",")}`
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const blobKzgCommitmentsLen = bid.blobKzgCommitments.length;
|
|
104
|
+
const maxBlobsPerBlock = chain.config.getMaxBlobsPerBlock(computeEpochAtSlot(bid.slot));
|
|
105
|
+
if (blobKzgCommitmentsLen > maxBlobsPerBlock) {
|
|
106
|
+
throw Error(`Bid has too many KZG commitments len=${blobKzgCommitmentsLen} limit=${maxBlobsPerBlock}`);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// The coverage check only applies to the staked collateral payment, a pure execution
|
|
110
|
+
// layer payment bid has nothing to cover on-chain
|
|
111
|
+
if (bid.value > 0 && !state.canBuilderCoverBid(bid.builderIndex, bid.value)) {
|
|
112
|
+
throw Error(
|
|
113
|
+
`Builder cannot cover bid value=${prettyGweiToEth(bid.value)} ` + `balance=${prettyGweiToEth(builder.balance)}`
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const randaoMix = state.getRandaoMix(computeEpochAtSlot(state.slot));
|
|
118
|
+
if (!byteArrayEquals(bid.prevRandao, randaoMix)) {
|
|
119
|
+
throw Error(`Invalid bid prevRandao=${toHex(bid.prevRandao)} expected=${toHex(randaoMix)}`);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// The parent's payload does not try to exit the builder
|
|
123
|
+
if (byteArrayEquals(bid.parentBlockHash, state.latestExecutionPayloadBid.blockHash)) {
|
|
124
|
+
const requests = await getParentExecutionRequests();
|
|
125
|
+
if (
|
|
126
|
+
requests.builderExits.some(
|
|
127
|
+
(request) =>
|
|
128
|
+
byteArrayEquals(request.pubkey, builder.pubkey) &&
|
|
129
|
+
byteArrayEquals(request.sourceAddress, builder.executionAddress)
|
|
130
|
+
)
|
|
131
|
+
) {
|
|
132
|
+
throw Error(`Bid builderIndex=${bid.builderIndex} may exit in the parent payload`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// The builder must honor the proposer preferences it learned over gossip
|
|
137
|
+
const bidEpoch = computeEpochAtSlot(bid.slot);
|
|
138
|
+
const dependentRootHex = (() => {
|
|
139
|
+
try {
|
|
140
|
+
return getShufflingDependentRoot(chain.forkChoice, bidEpoch, computeEpochAtSlot(parentBlock.slot), parentBlock);
|
|
141
|
+
} catch {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
})();
|
|
145
|
+
if (dependentRootHex === null) {
|
|
146
|
+
throw Error(`Unable to resolve proposer preferences dependent root for bid slot=${bid.slot}`);
|
|
147
|
+
}
|
|
148
|
+
const proposerPreferences = chain.proposerPreferencesPool.get(bid.slot, dependentRootHex);
|
|
149
|
+
if (proposerPreferences === null) {
|
|
150
|
+
throw Error(`No proposer preferences found for bid slot=${bid.slot} dependentRoot=${dependentRootHex}`);
|
|
151
|
+
}
|
|
152
|
+
if (!byteArrayEquals(bid.feeRecipient, proposerPreferences.message.feeRecipient)) {
|
|
153
|
+
throw Error(
|
|
154
|
+
`Bid feeRecipient=${toHex(bid.feeRecipient)} does not match ` +
|
|
155
|
+
`proposer preferences feeRecipient=${toHex(proposerPreferences.message.feeRecipient)}`
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const parentPayloadVariant = chain.forkChoice.getBlockHexAndBlockHash(bidParentBlockRoot, bidParentBlockHash);
|
|
160
|
+
if (parentPayloadVariant === null || parentPayloadVariant.executionPayloadBlockHash === null) {
|
|
161
|
+
throw Error(`Unable to resolve parent payload gas limit for bid parentBlockHash=${bidParentBlockHash}`);
|
|
162
|
+
}
|
|
163
|
+
const parentGasLimit = BigInt(parentPayloadVariant.executionPayloadGasLimit);
|
|
164
|
+
const targetGasLimit = proposerPreferences.message.targetGasLimit;
|
|
165
|
+
if (!isGasLimitTargetCompatible(parentGasLimit, bid.gasLimit, targetGasLimit)) {
|
|
166
|
+
throw Error(
|
|
167
|
+
`Bid gasLimit=${bid.gasLimit} is not compatible with ` +
|
|
168
|
+
`parentGasLimit=${parentGasLimit} targetGasLimit=${targetGasLimit}`
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const signatureSet = createSingleSignatureSetFromComponents(
|
|
173
|
+
builder.pubkey,
|
|
174
|
+
getExecutionPayloadBidSigningRoot(chain.config, bid),
|
|
175
|
+
signedExecutionPayloadBid.signature
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
if (!(await chain.bls.verifySignatureSets([signatureSet]))) {
|
|
179
|
+
throw Error(`Invalid bid signature builderIndex=${bid.builderIndex}`);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
@@ -4,7 +4,10 @@ import {ArchiveStoreTask} from "../../chain/archiveStore/archiveStore.js";
|
|
|
4
4
|
import {FrequencyStateArchiveStep} from "../../chain/archiveStore/strategies/frequencyStateArchiveStrategy.js";
|
|
5
5
|
import {BlockInputSource} from "../../chain/blocks/blockInput/index.js";
|
|
6
6
|
import {PayloadErrorCode} from "../../chain/blocks/importExecutionPayload.js";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
PayloadEnvelopeInputPruneReason,
|
|
9
|
+
PayloadEnvelopeInputSource,
|
|
10
|
+
} from "../../chain/blocks/payloadEnvelopeInput/index.js";
|
|
8
11
|
import {JobQueueItemType} from "../../chain/bls/index.js";
|
|
9
12
|
import {AttestationErrorCode, BlockErrorCode} from "../../chain/errors/index.js";
|
|
10
13
|
import {
|
|
@@ -21,7 +24,7 @@ import {ExecutionPayloadStatus} from "../../execution/index.js";
|
|
|
21
24
|
import {GossipType} from "../../network/index.js";
|
|
22
25
|
import {CannotAcceptWorkReason, ReprocessRejectReason} from "../../network/processor/index.js";
|
|
23
26
|
import {BackfillSyncMethod} from "../../sync/backfill/backfill.js";
|
|
24
|
-
import {PendingBlockType} from "../../sync/types.js";
|
|
27
|
+
import {DroppedItemReason, PendingBlockType} from "../../sync/types.js";
|
|
25
28
|
import {PeerSyncType, RangeSyncType} from "../../sync/utils/remoteSyncType.js";
|
|
26
29
|
import {AllocSource} from "../../util/bufferPool.js";
|
|
27
30
|
import {DataColumnReconstructionCode} from "../../util/dataColumns.js";
|
|
@@ -80,15 +83,15 @@ export function createLodestarMetrics(
|
|
|
80
83
|
}),
|
|
81
84
|
jobTime: register.histogram<{topic: GossipType}>({
|
|
82
85
|
name: "lodestar_gossip_validation_queue_job_time_seconds",
|
|
83
|
-
help: "Time to process gossip validation queue job in seconds",
|
|
86
|
+
help: "Time to process gossip validation queue job in seconds (accepted messages only)",
|
|
84
87
|
labelNames: ["topic"],
|
|
85
|
-
buckets: [0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2
|
|
88
|
+
buckets: [0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2],
|
|
86
89
|
}),
|
|
87
90
|
jobWaitTime: register.histogram<{topic: GossipType}>({
|
|
88
91
|
name: "lodestar_gossip_validation_queue_job_wait_time_seconds",
|
|
89
92
|
help: "Time from job added to the queue to starting the job in seconds",
|
|
90
93
|
labelNames: ["topic"],
|
|
91
|
-
buckets: [0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2
|
|
94
|
+
buckets: [0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2],
|
|
92
95
|
}),
|
|
93
96
|
concurrency: register.gauge<{topic: GossipType}>({
|
|
94
97
|
name: "lodestar_gossip_validation_queue_concurrency",
|
|
@@ -101,9 +104,10 @@ export function createLodestarMetrics(
|
|
|
101
104
|
help: "Age of the first item of each key in the indexed queues in seconds",
|
|
102
105
|
buckets: [0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 5],
|
|
103
106
|
}),
|
|
104
|
-
queueTime: register.histogram({
|
|
107
|
+
queueTime: register.histogram<{topic: GossipType}>({
|
|
105
108
|
name: "lodestar_gossip_validation_queue_time_seconds",
|
|
106
109
|
help: "Total time an item stays in queue until it is processed in seconds",
|
|
110
|
+
labelNames: ["topic"],
|
|
107
111
|
buckets: [0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 5],
|
|
108
112
|
}),
|
|
109
113
|
},
|
|
@@ -677,9 +681,15 @@ export function createLodestarMetrics(
|
|
|
677
681
|
name: "lodestar_sync_unknown_block_downloaded_blocks_error_total",
|
|
678
682
|
help: "Total number of downloaded blocks errors in UnknownBlockSync",
|
|
679
683
|
}),
|
|
680
|
-
removedBlocks: register.gauge({
|
|
684
|
+
removedBlocks: register.gauge<{reason: DroppedItemReason}>({
|
|
681
685
|
name: "lodestar_sync_unknown_block_removed_blocks_total",
|
|
682
|
-
help: "Total
|
|
686
|
+
help: "Total pending blocks dropped from BlockInputSync without completing, by reason",
|
|
687
|
+
labelNames: ["reason"],
|
|
688
|
+
}),
|
|
689
|
+
removedPayloads: register.gauge<{reason: DroppedItemReason}>({
|
|
690
|
+
name: "lodestar_sync_unknown_block_removed_payloads_total",
|
|
691
|
+
help: "Total pending payloads dropped from BlockInputSync without completing, by reason",
|
|
692
|
+
labelNames: ["reason"],
|
|
683
693
|
}),
|
|
684
694
|
elapsedTimeTillReceived: register.histogram({
|
|
685
695
|
name: "lodestar_sync_unknown_block_elapsed_time_till_received",
|
|
@@ -911,6 +921,12 @@ export function createLodestarMetrics(
|
|
|
911
921
|
help: "Count of errors, by error type, while processing blocks",
|
|
912
922
|
labelNames: ["error"],
|
|
913
923
|
}),
|
|
924
|
+
|
|
925
|
+
preStateSource: register.counter<{source: "parentState" | "fallbackPreState" | "preState"}>({
|
|
926
|
+
name: "lodestar_gossip_block_validation_pre_state_source_total",
|
|
927
|
+
help: "Source of the pre-state used for gossip block validation",
|
|
928
|
+
labelNames: ["source"],
|
|
929
|
+
}),
|
|
914
930
|
},
|
|
915
931
|
gossipBlob: {
|
|
916
932
|
recvToValidation: register.histogram({
|
|
@@ -1225,6 +1241,12 @@ export function createLodestarMetrics(
|
|
|
1225
1241
|
name: "lodestar_oppool_attester_slashing_pool_size",
|
|
1226
1242
|
help: "Current size of the AttesterSlashingPool",
|
|
1227
1243
|
}),
|
|
1244
|
+
deferredVoluntaryExitPool: {
|
|
1245
|
+
size: register.gauge({
|
|
1246
|
+
name: "lodestar_oppool_deferred_voluntary_exit_pool_size",
|
|
1247
|
+
help: "Current size of the DeferredVoluntaryExitPool",
|
|
1248
|
+
}),
|
|
1249
|
+
},
|
|
1228
1250
|
proposerSlashingPoolSize: register.gauge({
|
|
1229
1251
|
name: "lodestar_oppool_proposer_slashing_pool_size",
|
|
1230
1252
|
help: "Current size of the ProposerSlashingPool",
|
|
@@ -1335,6 +1357,11 @@ export function createLodestarMetrics(
|
|
|
1335
1357
|
help: "Total number of InsertOutcome as a result of adding an execution payload bid from api to the pool",
|
|
1336
1358
|
labelNames: ["insertOutcome"],
|
|
1337
1359
|
}),
|
|
1360
|
+
apiValidationTime: register.histogram({
|
|
1361
|
+
name: "lodestar_api_execution_payload_bid_validation_time_seconds",
|
|
1362
|
+
help: "Time elapsed for signed execution payload bid validation - api path",
|
|
1363
|
+
buckets: [0.005, 0.01, 0.025, 0.05, 0.1, 0.5],
|
|
1364
|
+
}),
|
|
1338
1365
|
},
|
|
1339
1366
|
},
|
|
1340
1367
|
|
|
@@ -1429,6 +1456,16 @@ export function createLodestarMetrics(
|
|
|
1429
1456
|
help: "Checkpoint state cache size",
|
|
1430
1457
|
labelNames: ["type"],
|
|
1431
1458
|
}),
|
|
1459
|
+
persistentTierEpochs: register.gauge<{tier: number}>({
|
|
1460
|
+
name: "lodestar_cp_state_cache_persistent_tier_epochs",
|
|
1461
|
+
help: "Number of epoch keys retained in each on-disk checkpoint state retention tier",
|
|
1462
|
+
labelNames: ["tier"],
|
|
1463
|
+
}),
|
|
1464
|
+
persistentTierStates: register.gauge<{tier: number}>({
|
|
1465
|
+
name: "lodestar_cp_state_cache_persistent_tier_states",
|
|
1466
|
+
help: "Number of persisted checkpoint states retained in each on-disk retention tier",
|
|
1467
|
+
labelNames: ["tier"],
|
|
1468
|
+
}),
|
|
1432
1469
|
reads: register.avgMinMax({
|
|
1433
1470
|
name: "lodestar_cp_state_epoch_reads",
|
|
1434
1471
|
help: "Avg min max of all state cache items total read count",
|
|
@@ -1643,9 +1680,15 @@ export function createLodestarMetrics(
|
|
|
1643
1680
|
name: "lodestar_seen_payload_envelope_input_cache_serialized_object_refs",
|
|
1644
1681
|
help: "Number of serialized-cache object refs retained by cached PayloadEnvelopeInputs",
|
|
1645
1682
|
}),
|
|
1646
|
-
created: register.counter({
|
|
1683
|
+
created: register.counter<{source: PayloadEnvelopeInputSource}>({
|
|
1647
1684
|
name: "lodestar_seen_payload_envelope_input_cache_items_created_total",
|
|
1648
|
-
help: "Number of PayloadEnvelopeInputs created",
|
|
1685
|
+
help: "Number of PayloadEnvelopeInputs created by source",
|
|
1686
|
+
labelNames: ["source"],
|
|
1687
|
+
}),
|
|
1688
|
+
pruned: register.counter<{reason: PayloadEnvelopeInputPruneReason}>({
|
|
1689
|
+
name: "lodestar_seen_payload_envelope_input_cache_items_pruned_total",
|
|
1690
|
+
help: "Number of PayloadEnvelopeInputs evicted by reason",
|
|
1691
|
+
labelNames: ["reason"],
|
|
1649
1692
|
}),
|
|
1650
1693
|
},
|
|
1651
1694
|
},
|
|
@@ -1755,6 +1798,10 @@ export function createLodestarMetrics(
|
|
|
1755
1798
|
name: "lodestar_precompute_next_epoch_transition_waste_total",
|
|
1756
1799
|
help: "Total number of precomputing next epoch transition wasted",
|
|
1757
1800
|
}),
|
|
1801
|
+
predictedReorg: register.counter({
|
|
1802
|
+
name: "lodestar_precompute_next_epoch_transition_predicted_reorg_total",
|
|
1803
|
+
help: "Predicted epoch-boundary reorgs where the strong parent was dialed instead of the weak head",
|
|
1804
|
+
}),
|
|
1758
1805
|
duration: register.histogram({
|
|
1759
1806
|
name: "lodestar_precompute_next_epoch_transition_duration_seconds",
|
|
1760
1807
|
help: "Duration of precomputeNextEpochTransition, including epoch transition and hashTreeRoot",
|
|
@@ -1994,6 +2041,40 @@ export function createLodestarMetrics(
|
|
|
1994
2041
|
}),
|
|
1995
2042
|
},
|
|
1996
2043
|
|
|
2044
|
+
builderApi: {
|
|
2045
|
+
statusChecks: register.counter<{status: "success" | "error"}>({
|
|
2046
|
+
name: "lodestar_builder_api_status_checks_total",
|
|
2047
|
+
help: "Total count of status checks sent to external builders ahead of a proposal",
|
|
2048
|
+
labelNames: ["status"],
|
|
2049
|
+
}),
|
|
2050
|
+
bidRequests: register.counter({
|
|
2051
|
+
name: "lodestar_builder_api_bid_requests_total",
|
|
2052
|
+
help: "Total count of execution payload bid requests sent to external builders",
|
|
2053
|
+
}),
|
|
2054
|
+
bidRequestErrors: register.counter({
|
|
2055
|
+
name: "lodestar_builder_api_bid_request_errors_total",
|
|
2056
|
+
help: "Total count of failed execution payload bid requests to external builders",
|
|
2057
|
+
}),
|
|
2058
|
+
bidsReceived: register.counter({
|
|
2059
|
+
name: "lodestar_builder_api_bids_received_total",
|
|
2060
|
+
help: "Total count of execution payload bids received from external builders",
|
|
2061
|
+
}),
|
|
2062
|
+
bidsDiscarded: register.counter({
|
|
2063
|
+
name: "lodestar_builder_api_bids_discarded_total",
|
|
2064
|
+
help: "Total count of execution payload bids from external builders discarded due to failed validation",
|
|
2065
|
+
}),
|
|
2066
|
+
blockSubmissions: register.counter<{status: "success" | "error"}>({
|
|
2067
|
+
name: "lodestar_builder_api_block_submissions_total",
|
|
2068
|
+
help: "Total count of signed beacon blocks submitted to external builders",
|
|
2069
|
+
labelNames: ["status"],
|
|
2070
|
+
}),
|
|
2071
|
+
preferencesForwarded: register.counter<{status: "success" | "error"}>({
|
|
2072
|
+
name: "lodestar_builder_api_preferences_forwarded_total",
|
|
2073
|
+
help: "Total count of builder preferences forwarded to external builders",
|
|
2074
|
+
labelNames: ["status"],
|
|
2075
|
+
}),
|
|
2076
|
+
},
|
|
2077
|
+
|
|
1997
2078
|
db: {
|
|
1998
2079
|
dbReadReq: register.gauge<{bucket: string}>({
|
|
1999
2080
|
name: "lodestar_db_read_req_total",
|
|
@@ -414,3 +414,41 @@ export const gossipTopicIgnoreDuplicatePublishError: Record<GossipType, boolean>
|
|
|
414
414
|
[GossipType.execution_payload_bid]: true,
|
|
415
415
|
[GossipType.proposer_preferences]: true,
|
|
416
416
|
};
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Whether a publish that reached zero subscribed peers is an acceptable outcome for a topic.
|
|
420
|
+
*
|
|
421
|
+
* Publishing to a topic with no subscribed peers throws `PublishError.NoPeersSubscribedToTopic`, which
|
|
422
|
+
* propagates to the caller and, for messages submitted through the beacon API, is surfaced to the
|
|
423
|
+
* validator client. That is the right default: a message that reached nobody is a failed broadcast, and a
|
|
424
|
+
* VC configured with several beacon nodes can fall back to another one.
|
|
425
|
+
*
|
|
426
|
+
* Only topics that have a concrete reason to tolerate it opt out here, ie. are set to `true`, and the
|
|
427
|
+
* reason is named on the entry. Everything else is `false` and keeps raising. Note this is applied per
|
|
428
|
+
* publish, a topic set to `false` still honors the global `--network.allowPublishToZeroPeers` flag.
|
|
429
|
+
*/
|
|
430
|
+
export const gossipTopicAllowPublishToZeroPeers: Record<GossipType, boolean> = {
|
|
431
|
+
[GossipType.beacon_block]: false,
|
|
432
|
+
[GossipType.blob_sidecar]: false,
|
|
433
|
+
// data_column_sidecar: we ensure having all topic peers via prioritizePeers(). Even with 0 peers on the
|
|
434
|
+
// topic the overall publish can still succeed, because a supernode rebuilds and publishes the missing
|
|
435
|
+
// columns for us, so track sent peers as 0 instead of raising
|
|
436
|
+
[GossipType.data_column_sidecar]: true,
|
|
437
|
+
[GossipType.beacon_aggregate_and_proof]: false,
|
|
438
|
+
[GossipType.beacon_attestation]: false,
|
|
439
|
+
[GossipType.voluntary_exit]: false,
|
|
440
|
+
[GossipType.proposer_slashing]: false,
|
|
441
|
+
[GossipType.attester_slashing]: false,
|
|
442
|
+
[GossipType.sync_committee_contribution_and_proof]: false,
|
|
443
|
+
[GossipType.sync_committee]: false,
|
|
444
|
+
// light_client_finality_update and light_client_optimistic_update: non-mandatory route on most of the
|
|
445
|
+
// network as of Oct 2022, there may be no peer subscribed to the topic at all. Reason carried over from
|
|
446
|
+
// the handlers in network.ts, which used to swallow the error instead
|
|
447
|
+
[GossipType.light_client_finality_update]: true,
|
|
448
|
+
[GossipType.light_client_optimistic_update]: true,
|
|
449
|
+
[GossipType.bls_to_execution_change]: false,
|
|
450
|
+
[GossipType.execution_payload]: false,
|
|
451
|
+
[GossipType.payload_attestation_message]: false,
|
|
452
|
+
[GossipType.execution_payload_bid]: false,
|
|
453
|
+
[GossipType.proposer_preferences]: false,
|
|
454
|
+
};
|