@lodestar/beacon-node 1.45.0-dev.fadf0fbb1f → 1.45.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 +4 -0
- 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 +2 -2
- package/lib/api/impl/beacon/state/index.js.map +1 -1
- package/lib/api/impl/beacon/state/utils.d.ts +2 -1
- package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
- package/lib/api/impl/beacon/state/utils.js +9 -1
- 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 +21 -56
- 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 +1 -4
- 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 +2 -0
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +3 -0
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/interface.d.ts +2 -0
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/interface.js.map +1 -1
- package/lib/chain/options.d.ts +4 -0
- package/lib/chain/options.d.ts.map +1 -1
- 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/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 +3 -2
- 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 +6 -1
- 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 +4 -0
- package/lib/network/processor/gossipHandlers.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 -0
- package/src/api/impl/beacon/state/index.ts +3 -2
- package/src/api/impl/beacon/state/utils.ts +11 -0
- 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 +21 -62
- package/src/api/rest/base.ts +9 -0
- package/src/chain/blocks/importBlock.ts +1 -6
- package/src/chain/builderCircuitBreaker.ts +84 -0
- package/src/chain/chain.ts +7 -0
- package/src/chain/interface.ts +2 -0
- package/src/chain/options.ts +4 -0
- package/src/chain/prepareNextSlot.ts +11 -7
- package/src/chain/validation/executionPayloadBid.ts +14 -9
- package/src/chain/validation/proposerPreferences.ts +3 -2
- 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 +5 -0
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/ChainSafe/lodestar/issues"
|
|
13
13
|
},
|
|
14
|
-
"version": "1.45.0
|
|
14
|
+
"version": "1.45.0",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -108,16 +108,16 @@
|
|
|
108
108
|
"check-readme": "pnpm exec ts-node ../../scripts/check_readme.ts"
|
|
109
109
|
},
|
|
110
110
|
"dependencies": {
|
|
111
|
-
"@chainsafe/as-sha256": "^1.2.
|
|
111
|
+
"@chainsafe/as-sha256": "^1.2.4",
|
|
112
112
|
"@chainsafe/blst": "^2.2.0",
|
|
113
113
|
"@chainsafe/discv5": "^12.0.1",
|
|
114
114
|
"@chainsafe/enr": "^6.0.1",
|
|
115
115
|
"@chainsafe/libp2p-noise": "^17.0.0",
|
|
116
|
-
"@chainsafe/libp2p-quic": "^2.
|
|
117
|
-
"@chainsafe/persistent-merkle-tree": "^1.
|
|
116
|
+
"@chainsafe/libp2p-quic": "^2.1.1",
|
|
117
|
+
"@chainsafe/persistent-merkle-tree": "^1.3.0",
|
|
118
118
|
"@chainsafe/prometheus-gc-stats": "^1.0.0",
|
|
119
119
|
"@chainsafe/snappy-wasm": "^0.5.0",
|
|
120
|
-
"@chainsafe/ssz": "^1.
|
|
120
|
+
"@chainsafe/ssz": "^1.6.2",
|
|
121
121
|
"@chainsafe/threads": "^1.11.3",
|
|
122
122
|
"@crate-crypto/node-eth-kzg": "0.9.1",
|
|
123
123
|
"@fastify/bearer-auth": "^10.0.1",
|
|
@@ -134,17 +134,17 @@
|
|
|
134
134
|
"@libp2p/peer-id": "^6.0.4",
|
|
135
135
|
"@libp2p/prometheus-metrics": "^5.0.14",
|
|
136
136
|
"@libp2p/tcp": "^11.0.13",
|
|
137
|
-
"@lodestar/api": "^1.45.0
|
|
138
|
-
"@lodestar/config": "^1.45.0
|
|
139
|
-
"@lodestar/db": "^1.45.0
|
|
140
|
-
"@lodestar/fork-choice": "^1.45.0
|
|
141
|
-
"@lodestar/logger": "^1.45.0
|
|
142
|
-
"@lodestar/params": "^1.45.0
|
|
143
|
-
"@lodestar/reqresp": "^1.45.0
|
|
144
|
-
"@lodestar/state-transition": "^1.45.0
|
|
145
|
-
"@lodestar/types": "^1.45.0
|
|
146
|
-
"@lodestar/utils": "^1.45.0
|
|
147
|
-
"@lodestar/validator": "^1.45.0
|
|
137
|
+
"@lodestar/api": "^1.45.0",
|
|
138
|
+
"@lodestar/config": "^1.45.0",
|
|
139
|
+
"@lodestar/db": "^1.45.0",
|
|
140
|
+
"@lodestar/fork-choice": "^1.45.0",
|
|
141
|
+
"@lodestar/logger": "^1.45.0",
|
|
142
|
+
"@lodestar/params": "^1.45.0",
|
|
143
|
+
"@lodestar/reqresp": "^1.45.0",
|
|
144
|
+
"@lodestar/state-transition": "^1.45.0",
|
|
145
|
+
"@lodestar/types": "^1.45.0",
|
|
146
|
+
"@lodestar/utils": "^1.45.0",
|
|
147
|
+
"@lodestar/validator": "^1.45.0",
|
|
148
148
|
"@multiformats/multiaddr": "^13.0.1",
|
|
149
149
|
"datastore-core": "^11.0.2",
|
|
150
150
|
"datastore-fs": "^11.0.2",
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
"libp2p": "3.1.6",
|
|
157
157
|
"multiformats": "^13.4.2",
|
|
158
158
|
"prom-client": "^15.1.0",
|
|
159
|
-
"qs": "^6.
|
|
159
|
+
"qs": "^6.14.2",
|
|
160
160
|
"strict-event-emitter-types": "^2.0.0",
|
|
161
161
|
"systeminformation": "^5.22.9",
|
|
162
162
|
"uint8arraylist": "^2.4.7",
|
|
@@ -167,7 +167,7 @@
|
|
|
167
167
|
"@libp2p/interface-internal": "^3.0.13",
|
|
168
168
|
"@libp2p/logger": "^6.2.2",
|
|
169
169
|
"@libp2p/utils": "^7.0.13",
|
|
170
|
-
"@lodestar/spec-test-util": "^1.45.0
|
|
170
|
+
"@lodestar/spec-test-util": "^1.45.0",
|
|
171
171
|
"@types/js-yaml": "^4.0.5",
|
|
172
172
|
"@types/qs": "^6.9.7",
|
|
173
173
|
"@types/tmp": "^0.2.3",
|
|
@@ -184,5 +184,5 @@
|
|
|
184
184
|
"beacon",
|
|
185
185
|
"blockchain"
|
|
186
186
|
],
|
|
187
|
-
"gitHead": "
|
|
187
|
+
"gitHead": "6051fa3335c3dadf3f99292a8fe345ccd69121f7"
|
|
188
188
|
}
|
|
@@ -7,7 +7,7 @@ import {getBeaconRewardsApi} from "./rewards/index.js";
|
|
|
7
7
|
import {getBeaconStateApi} from "./state/index.js";
|
|
8
8
|
|
|
9
9
|
export function getBeaconApi(
|
|
10
|
-
modules: Pick<ApiModules, "chain" | "config" | "logger" | "metrics" | "network" | "db">
|
|
10
|
+
modules: Pick<ApiModules, "chain" | "config" | "logger" | "metrics" | "network" | "db" | "sync">
|
|
11
11
|
): ApplicationMethods<routes.beacon.Endpoints> {
|
|
12
12
|
const block = getBeaconBlockApi(modules);
|
|
13
13
|
const pool = getBeaconPoolApi(modules);
|
|
@@ -241,6 +241,11 @@ export function getBeaconPoolApi({
|
|
|
241
241
|
payloadAttestationMessage.data.blobDataAvailable
|
|
242
242
|
);
|
|
243
243
|
|
|
244
|
+
chain.emitter.emit(routes.events.EventType.payloadAttestationMessage, {
|
|
245
|
+
version: chain.config.getForkName(slot),
|
|
246
|
+
data: payloadAttestationMessage,
|
|
247
|
+
});
|
|
248
|
+
|
|
244
249
|
await network.publishPayloadAttestationMessage(payloadAttestationMessage);
|
|
245
250
|
} catch (e) {
|
|
246
251
|
const logCtx = {
|
|
@@ -26,11 +26,12 @@ import {
|
|
|
26
26
|
export function getBeaconStateApi({
|
|
27
27
|
chain,
|
|
28
28
|
config,
|
|
29
|
-
|
|
29
|
+
sync,
|
|
30
|
+
}: Pick<ApiModules, "chain" | "config" | "sync">): ApplicationMethods<routes.beacon.state.Endpoints> {
|
|
30
31
|
async function getState(
|
|
31
32
|
stateId: routes.beacon.StateId
|
|
32
33
|
): Promise<{state: IBeaconStateView; executionOptimistic: boolean; finalized: boolean}> {
|
|
33
|
-
const {state, executionOptimistic, finalized} = await getStateResponseWithRegen(chain, stateId);
|
|
34
|
+
const {state, executionOptimistic, finalized} = await getStateResponseWithRegen(chain, sync, stateId);
|
|
34
35
|
|
|
35
36
|
return {
|
|
36
37
|
state: state instanceof Uint8Array ? chain.getHeadState().loadOtherState(state) : state,
|
|
@@ -14,7 +14,9 @@ import {
|
|
|
14
14
|
} from "@lodestar/types";
|
|
15
15
|
import {byteArrayEquals, fromHex} from "@lodestar/utils";
|
|
16
16
|
import {IBeaconChain} from "../../../../chain/index.js";
|
|
17
|
+
import {IBeaconSync} from "../../../../sync/index.js";
|
|
17
18
|
import {ApiError, ValidationError} from "../../errors.js";
|
|
19
|
+
import {notWhileSyncing} from "../../utils.js";
|
|
18
20
|
|
|
19
21
|
export function resolveStateId(
|
|
20
22
|
forkChoice: IForkChoice,
|
|
@@ -51,8 +53,17 @@ export function resolveStateId(
|
|
|
51
53
|
|
|
52
54
|
export async function getStateResponseWithRegen(
|
|
53
55
|
chain: IBeaconChain,
|
|
56
|
+
sync: IBeaconSync,
|
|
54
57
|
inStateId: routes.beacon.StateId
|
|
55
58
|
): Promise<{state: IBeaconStateView | Uint8Array; executionOptimistic: boolean; finalized: boolean}> {
|
|
59
|
+
// "head", "finalized" and "justified" resolve to already-available cached states, and "genesis" to a
|
|
60
|
+
// historical DB read - none trigger the forward regen that can walk back past the block-root window
|
|
61
|
+
// (SLOTS_PER_HISTORICAL_ROOT) and wedge a far-behind node. Keep serving those (node observability,
|
|
62
|
+
// dashboards, validator client checks) even while syncing; guard only the regen-capable lookups.
|
|
63
|
+
if (inStateId !== "head" && inStateId !== "finalized" && inStateId !== "justified" && inStateId !== "genesis") {
|
|
64
|
+
notWhileSyncing(chain, sync.state);
|
|
65
|
+
}
|
|
66
|
+
|
|
56
67
|
const stateId = resolveStateId(chain.forkChoice, inStateId);
|
|
57
68
|
|
|
58
69
|
const res =
|
|
@@ -39,7 +39,8 @@ function toPayloadStatusName(status: PayloadStatus): "pending" | "empty" | "full
|
|
|
39
39
|
export function getDebugApi({
|
|
40
40
|
chain,
|
|
41
41
|
config,
|
|
42
|
-
|
|
42
|
+
sync,
|
|
43
|
+
}: Pick<ApiModules, "chain" | "config" | "db" | "sync">): ApplicationMethods<routes.debug.Endpoints> {
|
|
43
44
|
return {
|
|
44
45
|
async getDebugChainHeadsV2() {
|
|
45
46
|
const heads = chain.forkChoice.getHeads();
|
|
@@ -132,7 +133,7 @@ export function getDebugApi({
|
|
|
132
133
|
},
|
|
133
134
|
|
|
134
135
|
async getStateV2({stateId}, context) {
|
|
135
|
-
const {state, executionOptimistic, finalized} = await getStateResponseWithRegen(chain, stateId);
|
|
136
|
+
const {state, executionOptimistic, finalized} = await getStateResponseWithRegen(chain, sync, stateId);
|
|
136
137
|
let slot: number, data: Uint8Array | BeaconState;
|
|
137
138
|
if (state instanceof Uint8Array) {
|
|
138
139
|
slot = getStateSlotFromBytes(state);
|
|
@@ -217,7 +217,7 @@ export function getLodestarApi({
|
|
|
217
217
|
},
|
|
218
218
|
|
|
219
219
|
async getHistoricalSummaries({stateId}) {
|
|
220
|
-
const {state, executionOptimistic, finalized} = await getStateResponseWithRegen(chain, stateId);
|
|
220
|
+
const {state, executionOptimistic, finalized} = await getStateResponseWithRegen(chain, sync, stateId);
|
|
221
221
|
|
|
222
222
|
const stateView = state instanceof Uint8Array ? chain.getHeadState().loadOtherState(state) : state;
|
|
223
223
|
|
|
@@ -332,7 +332,7 @@ export function getLodestarApi({
|
|
|
332
332
|
|
|
333
333
|
for (const [epoch, attestationsPerEpoch] of attestations) {
|
|
334
334
|
const slot = computeStartSlotAtEpoch(epoch);
|
|
335
|
-
const {state} = await getStateResponseWithRegen(chain, slot);
|
|
335
|
+
const {state} = await getStateResponseWithRegen(chain, sync, slot);
|
|
336
336
|
const stateView = state instanceof Uint8Array ? chain.getHeadState().loadOtherState(state) : state;
|
|
337
337
|
const shuffling = stateView.getShufflingAtEpoch(epoch);
|
|
338
338
|
for (const attestation of attestationsPerEpoch) {
|
|
@@ -8,7 +8,7 @@ import {ApiModules} from "../types.js";
|
|
|
8
8
|
|
|
9
9
|
export function getProofApi(
|
|
10
10
|
opts: ApiOptions,
|
|
11
|
-
{chain, config}: Pick<ApiModules, "chain" | "config" | "db">
|
|
11
|
+
{chain, config, sync}: Pick<ApiModules, "chain" | "config" | "db" | "sync">
|
|
12
12
|
): ApplicationMethods<routes.proof.Endpoints> {
|
|
13
13
|
// It's currently possible to request gigantic proofs (eg: a proof of the entire beacon state)
|
|
14
14
|
// We want some some sort of resistance against this DoS vector.
|
|
@@ -21,7 +21,7 @@ export function getProofApi(
|
|
|
21
21
|
throw new Error("Requested proof is too large.");
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
const res = await getStateResponseWithRegen(chain, stateId);
|
|
24
|
+
const res = await getStateResponseWithRegen(chain, sync, stateId);
|
|
25
25
|
|
|
26
26
|
const state = res.state instanceof Uint8Array ? chain.getHeadState().loadOtherState(res.state) : res.state;
|
|
27
27
|
|
package/src/api/impl/utils.ts
CHANGED
|
@@ -1,4 +1,54 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {SLOTS_PER_EPOCH} from "@lodestar/params";
|
|
2
|
+
import type {IBeaconChain} from "../../chain/index.js";
|
|
3
|
+
import {SyncState} from "../../sync/index.js";
|
|
4
|
+
import {ApiError, NodeIsSyncing} from "./errors.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* If the node is within this many epochs from the head, we declare it to be synced regardless of
|
|
8
|
+
* the network sync state.
|
|
9
|
+
*
|
|
10
|
+
* This helps prevent attacks where nodes can convince us that we're syncing some non-existent
|
|
11
|
+
* finalized head.
|
|
12
|
+
*
|
|
13
|
+
* TODO: Lighthouse uses 8 for the attack described above. However, 8 kills Lodestar since validators
|
|
14
|
+
* can trigger regen to fast-forward head state 8 epochs to be immediately invalidated as sync sets
|
|
15
|
+
* a new head. Then the checkpoint state cache grows unbounded with very different states (because
|
|
16
|
+
* they are 8 epochs apart) and causes an OOM. Research a proper solution once regen and the state
|
|
17
|
+
* caches are better.
|
|
18
|
+
*/
|
|
19
|
+
export const SYNC_TOLERANCE_EPOCHS = 1;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Reject any request while the node is syncing. Used by endpoints that must not serve while the
|
|
23
|
+
* node is behind — validator duties, and beacon state lookups whose regen could otherwise walk
|
|
24
|
+
* back past the block-root window (`SLOTS_PER_HISTORICAL_ROOT`) and wedge the node. Throws
|
|
25
|
+
* {@link NodeIsSyncing} (503).
|
|
26
|
+
*/
|
|
27
|
+
export function notWhileSyncing(chain: IBeaconChain, syncState: SyncState): void {
|
|
28
|
+
// Consider node synced before or close to genesis
|
|
29
|
+
if (chain.clock.currentSlot < SLOTS_PER_EPOCH) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
switch (syncState) {
|
|
34
|
+
case SyncState.SyncingFinalized:
|
|
35
|
+
case SyncState.SyncingHead: {
|
|
36
|
+
const currentSlot = chain.clock.currentSlot;
|
|
37
|
+
const headSlot = chain.forkChoice.getHead().slot;
|
|
38
|
+
if (currentSlot - headSlot > SYNC_TOLERANCE_EPOCHS * SLOTS_PER_EPOCH) {
|
|
39
|
+
throw new NodeIsSyncing(`headSlot ${headSlot} currentSlot ${currentSlot}`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
case SyncState.Synced:
|
|
46
|
+
return;
|
|
47
|
+
|
|
48
|
+
case SyncState.Stalled:
|
|
49
|
+
throw new NodeIsSyncing("waiting for peers");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
2
52
|
|
|
3
53
|
/**
|
|
4
54
|
* Ensures that the array contains unique values, and throws an ApiError
|
|
@@ -82,7 +82,6 @@ import {ZERO_HASH} from "../../../constants/index.js";
|
|
|
82
82
|
import {BuilderStatus, NoBidReceived} from "../../../execution/builder/http.js";
|
|
83
83
|
import {validateGossipFnRetryUnknownRoot} from "../../../network/processor/gossipHandlers.js";
|
|
84
84
|
import {CommitteeSubscription} from "../../../network/subnets/index.js";
|
|
85
|
-
import {SyncState} from "../../../sync/index.js";
|
|
86
85
|
import {callInNextEventLoop} from "../../../util/eventLoop.js";
|
|
87
86
|
import {isOptimisticBlock} from "../../../util/forkChoice.js";
|
|
88
87
|
import {getBlockGraffiti, toGraffitiBytes} from "../../../util/graffiti.js";
|
|
@@ -91,23 +90,9 @@ import {ApiOptions} from "../../options.js";
|
|
|
91
90
|
import {getStateResponseWithRegen} from "../beacon/state/utils.js";
|
|
92
91
|
import {ApiError, FailureList, IndexedError, NodeIsSyncing, OnlySupportedByDVT} from "../errors.js";
|
|
93
92
|
import {ApiModules} from "../types.js";
|
|
93
|
+
import {notWhileSyncing} from "../utils.js";
|
|
94
94
|
import {computeSubnetForCommitteesAtSlot, getPubkeysForIndices, selectBlockProductionSource} from "./utils.js";
|
|
95
95
|
|
|
96
|
-
/**
|
|
97
|
-
* If the node is within this many epochs from the head, we declare it to be synced regardless of
|
|
98
|
-
* the network sync state.
|
|
99
|
-
*
|
|
100
|
-
* This helps prevent attacks where nodes can convince us that we're syncing some non-existent
|
|
101
|
-
* finalized head.
|
|
102
|
-
*
|
|
103
|
-
* TODO: Lighthouse uses 8 for the attack described above. However, 8 kills Lodestar since validators
|
|
104
|
-
* can trigger regen to fast-forward head state 8 epochs to be immediately invalidated as sync sets
|
|
105
|
-
* a new head. Then the checkpoint state cache grows unbounded with very different states (because
|
|
106
|
-
* they are 8 epochs apart) and causes an OOM. Research a proper solution once regen and the state
|
|
107
|
-
* caches are better.
|
|
108
|
-
*/
|
|
109
|
-
export const SYNC_TOLERANCE_EPOCHS = 1;
|
|
110
|
-
|
|
111
96
|
/**
|
|
112
97
|
* Cutoff time to wait from start of the slot for execution and builder block production apis to resolve.
|
|
113
98
|
* Post this time, race execution and builder to pick whatever resolves first.
|
|
@@ -341,36 +326,6 @@ export function getValidatorApi(
|
|
|
341
326
|
return null;
|
|
342
327
|
}
|
|
343
328
|
|
|
344
|
-
/**
|
|
345
|
-
* Reject any request while the node is syncing
|
|
346
|
-
*/
|
|
347
|
-
function notWhileSyncing(): void {
|
|
348
|
-
// Consider node synced before or close to genesis
|
|
349
|
-
if (chain.clock.currentSlot < SLOTS_PER_EPOCH) {
|
|
350
|
-
return;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
const syncState = sync.state;
|
|
354
|
-
switch (syncState) {
|
|
355
|
-
case SyncState.SyncingFinalized:
|
|
356
|
-
case SyncState.SyncingHead: {
|
|
357
|
-
const currentSlot = chain.clock.currentSlot;
|
|
358
|
-
const headSlot = chain.forkChoice.getHead().slot;
|
|
359
|
-
if (currentSlot - headSlot > SYNC_TOLERANCE_EPOCHS * SLOTS_PER_EPOCH) {
|
|
360
|
-
throw new NodeIsSyncing(`headSlot ${headSlot} currentSlot ${currentSlot}`);
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
return;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
case SyncState.Synced:
|
|
367
|
-
return;
|
|
368
|
-
|
|
369
|
-
case SyncState.Stalled:
|
|
370
|
-
throw new NodeIsSyncing("waiting for peers");
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
|
|
374
329
|
/**
|
|
375
330
|
* Post merge, the CL and EL could be out of step in the sync, and could result in
|
|
376
331
|
* Syncing status of the chain head. To be precise:
|
|
@@ -573,7 +528,7 @@ export function getValidatorApi(
|
|
|
573
528
|
builderBoostFactor?: bigint,
|
|
574
529
|
{feeRecipient, builderSelection, strictFeeRecipientCheck}: routes.validator.ExtraProduceBlockOpts = {}
|
|
575
530
|
): Promise<ProduceBlindedBlockOrBlockContentsRes> {
|
|
576
|
-
notWhileSyncing();
|
|
531
|
+
notWhileSyncing(chain, sync.state);
|
|
577
532
|
await waitForSlot(slot); // Must never request for a future slot > currentSlot
|
|
578
533
|
|
|
579
534
|
const parentBlock = chain.getProposerHead(slot);
|
|
@@ -917,7 +872,7 @@ export function getValidatorApi(
|
|
|
917
872
|
throw new ApiError(400, `produceBlockV4 not supported for pre-gloas fork=${fork}`);
|
|
918
873
|
}
|
|
919
874
|
|
|
920
|
-
notWhileSyncing();
|
|
875
|
+
notWhileSyncing(chain, sync.state);
|
|
921
876
|
await waitForSlot(slot);
|
|
922
877
|
|
|
923
878
|
const parentBlock = chain.getProposerHead(slot);
|
|
@@ -938,7 +893,10 @@ export function getValidatorApi(
|
|
|
938
893
|
// support when it is implemented.
|
|
939
894
|
const isBuildingOnFull = chain.forkChoice.shouldBuildOnFull(parentBlock, slot);
|
|
940
895
|
const bidParentBlockHash = isBuildingOnFull ? parentBlock.executionPayloadBlockHash : parentBlock.parentBlockHash;
|
|
941
|
-
const
|
|
896
|
+
const circuitBreakerActive = chain.builderCircuitBreaker.isActive(slot);
|
|
897
|
+
const builderBid = circuitBreakerActive
|
|
898
|
+
? null
|
|
899
|
+
: chain.executionPayloadBidPool.getBestBid(slot, bidParentBlockHash, parentBlockRootHex);
|
|
942
900
|
|
|
943
901
|
const logCtx = {
|
|
944
902
|
slot,
|
|
@@ -946,6 +904,7 @@ export function getValidatorApi(
|
|
|
946
904
|
parentBlockRoot: parentBlockRootHex,
|
|
947
905
|
parentBlockHash: parentBlock.executionPayloadBlockHash,
|
|
948
906
|
fork,
|
|
907
|
+
circuitBreakerActive,
|
|
949
908
|
...(builderBid !== null
|
|
950
909
|
? {
|
|
951
910
|
bidValue: builderBid.message.value,
|
|
@@ -1035,7 +994,7 @@ export function getValidatorApi(
|
|
|
1035
994
|
},
|
|
1036
995
|
|
|
1037
996
|
async produceAttestationData({committeeIndex, slot}) {
|
|
1038
|
-
notWhileSyncing();
|
|
997
|
+
notWhileSyncing(chain, sync.state);
|
|
1039
998
|
|
|
1040
999
|
await waitForSlot(slot); // Must never request for a future slot > currentSlot
|
|
1041
1000
|
|
|
@@ -1116,7 +1075,7 @@ export function getValidatorApi(
|
|
|
1116
1075
|
throw new ApiError(400, `producePayloadAttestationData is not supported before Gloas fork=${fork}`);
|
|
1117
1076
|
}
|
|
1118
1077
|
|
|
1119
|
-
notWhileSyncing();
|
|
1078
|
+
notWhileSyncing(chain, sync.state);
|
|
1120
1079
|
await waitForSlot(slot);
|
|
1121
1080
|
|
|
1122
1081
|
const block = chain.forkChoice.getCanonicalBlockAtSlot(slot);
|
|
@@ -1201,7 +1160,7 @@ export function getValidatorApi(
|
|
|
1201
1160
|
},
|
|
1202
1161
|
|
|
1203
1162
|
async getProposerDuties({epoch}, _context, opts?: {v2?: boolean}) {
|
|
1204
|
-
notWhileSyncing();
|
|
1163
|
+
notWhileSyncing(chain, sync.state);
|
|
1205
1164
|
|
|
1206
1165
|
const currentEpoch = currentEpochWithDisparity();
|
|
1207
1166
|
const nextEpoch = currentEpoch + 1;
|
|
@@ -1248,7 +1207,7 @@ export function getValidatorApi(
|
|
|
1248
1207
|
// requested epoch is within that range, we can use the head state at current epoch
|
|
1249
1208
|
state = await chain.getHeadStateAtCurrentEpoch(RegenCaller.getDuties);
|
|
1250
1209
|
} else {
|
|
1251
|
-
const res = await getStateResponseWithRegen(chain, startSlot);
|
|
1210
|
+
const res = await getStateResponseWithRegen(chain, sync, startSlot);
|
|
1252
1211
|
|
|
1253
1212
|
state = res.state instanceof Uint8Array ? chain.getHeadState().loadOtherState(res.state) : res.state;
|
|
1254
1213
|
|
|
@@ -1342,7 +1301,7 @@ export function getValidatorApi(
|
|
|
1342
1301
|
},
|
|
1343
1302
|
|
|
1344
1303
|
async getAttesterDuties({epoch, indices}) {
|
|
1345
|
-
notWhileSyncing();
|
|
1304
|
+
notWhileSyncing(chain, sync.state);
|
|
1346
1305
|
|
|
1347
1306
|
if (indices.length === 0) {
|
|
1348
1307
|
throw new ApiError(400, "No validator to get attester duties");
|
|
@@ -1402,7 +1361,7 @@ export function getValidatorApi(
|
|
|
1402
1361
|
},
|
|
1403
1362
|
|
|
1404
1363
|
async getPtcDuties({epoch, indices}) {
|
|
1405
|
-
notWhileSyncing();
|
|
1364
|
+
notWhileSyncing(chain, sync.state);
|
|
1406
1365
|
|
|
1407
1366
|
if (indices.length === 0) {
|
|
1408
1367
|
throw new ApiError(400, "No validator to get PTC duties");
|
|
@@ -1464,7 +1423,7 @@ export function getValidatorApi(
|
|
|
1464
1423
|
* @param validatorIndices an array of the validator indices for which to obtain the duties.
|
|
1465
1424
|
*/
|
|
1466
1425
|
async getSyncCommitteeDuties({epoch, indices}) {
|
|
1467
|
-
notWhileSyncing();
|
|
1426
|
+
notWhileSyncing(chain, sync.state);
|
|
1468
1427
|
|
|
1469
1428
|
if (indices.length === 0) {
|
|
1470
1429
|
throw new ApiError(400, "No validator to get attester duties");
|
|
@@ -1511,7 +1470,7 @@ export function getValidatorApi(
|
|
|
1511
1470
|
},
|
|
1512
1471
|
|
|
1513
1472
|
async getAggregatedAttestationV2({attestationDataRoot, slot, committeeIndex}) {
|
|
1514
|
-
notWhileSyncing();
|
|
1473
|
+
notWhileSyncing(chain, sync.state);
|
|
1515
1474
|
|
|
1516
1475
|
await waitForSlot(slot); // Must never request for a future slot > currentSlot
|
|
1517
1476
|
|
|
@@ -1534,7 +1493,7 @@ export function getValidatorApi(
|
|
|
1534
1493
|
},
|
|
1535
1494
|
|
|
1536
1495
|
async publishAggregateAndProofsV2({signedAggregateAndProofs}) {
|
|
1537
|
-
notWhileSyncing();
|
|
1496
|
+
notWhileSyncing(chain, sync.state);
|
|
1538
1497
|
|
|
1539
1498
|
const seenTimestampSec = Date.now() / 1000;
|
|
1540
1499
|
const failures: FailureList = [];
|
|
@@ -1595,7 +1554,7 @@ export function getValidatorApi(
|
|
|
1595
1554
|
* https://github.com/ethereum/beacon-APIs/pull/137
|
|
1596
1555
|
*/
|
|
1597
1556
|
async publishContributionAndProofs({contributionAndProofs}) {
|
|
1598
|
-
notWhileSyncing();
|
|
1557
|
+
notWhileSyncing(chain, sync.state);
|
|
1599
1558
|
|
|
1600
1559
|
const failures: FailureList = [];
|
|
1601
1560
|
|
|
@@ -1644,7 +1603,7 @@ export function getValidatorApi(
|
|
|
1644
1603
|
},
|
|
1645
1604
|
|
|
1646
1605
|
async prepareBeaconCommitteeSubnet({subscriptions}) {
|
|
1647
|
-
notWhileSyncing();
|
|
1606
|
+
notWhileSyncing(chain, sync.state);
|
|
1648
1607
|
|
|
1649
1608
|
await network.prepareBeaconCommitteeSubnets(
|
|
1650
1609
|
subscriptions.map(({validatorIndex, slot, isAggregator, committeesAtSlot, committeeIndex}) => ({
|
|
@@ -1677,7 +1636,7 @@ export function getValidatorApi(
|
|
|
1677
1636
|
* https://github.com/ethereum/beacon-APIs/pull/136
|
|
1678
1637
|
*/
|
|
1679
1638
|
async prepareSyncCommitteeSubnets({subscriptions}) {
|
|
1680
|
-
notWhileSyncing();
|
|
1639
|
+
notWhileSyncing(chain, sync.state);
|
|
1681
1640
|
|
|
1682
1641
|
// A `validatorIndex` can be in multiple subnets, so compute the CommitteeSubscription with double for loop
|
|
1683
1642
|
const subs: CommitteeSubscription[] = [];
|
|
@@ -1821,7 +1780,7 @@ export function getValidatorApi(
|
|
|
1821
1780
|
throw new ApiError(400, `getExecutionPayloadEnvelope not supported for pre-gloas fork=${fork}`);
|
|
1822
1781
|
}
|
|
1823
1782
|
|
|
1824
|
-
notWhileSyncing();
|
|
1783
|
+
notWhileSyncing(chain, sync.state);
|
|
1825
1784
|
await waitForSlot(slot);
|
|
1826
1785
|
|
|
1827
1786
|
const blockRootHex = toRootHex(beaconBlockRoot);
|
package/src/api/rest/base.ts
CHANGED
|
@@ -3,6 +3,7 @@ import {fastifyCors} from "@fastify/cors";
|
|
|
3
3
|
import {FastifyError, FastifyInstance, FastifyRequest, errorCodes, fastify} from "fastify";
|
|
4
4
|
import {parse as parseQueryString} from "qs";
|
|
5
5
|
import {addSszContentTypeParser} from "@lodestar/api/server";
|
|
6
|
+
import {NUMBER_OF_COLUMNS} from "@lodestar/params";
|
|
6
7
|
import {ErrorAborted, Gauge, Histogram, Logger} from "@lodestar/utils";
|
|
7
8
|
import {isLocalhostIP} from "../../util/ip.js";
|
|
8
9
|
import {ApiError, FailureList, IndexedError, NodeIsSyncing} from "../impl/errors.js";
|
|
@@ -55,6 +56,13 @@ const INVALID_MEDIA_TYPE_CODE = errorCodes.FST_ERR_CTP_INVALID_MEDIA_TYPE().code
|
|
|
55
56
|
*/
|
|
56
57
|
const SCHEMA_VALIDATION_ERROR_CODE = errorCodes.FST_ERR_VALIDATION().code;
|
|
57
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Cap for array query params, set to the largest array any beacon-API query can carry:
|
|
61
|
+
* a full data-column custody set (`getDebugDataColumnSidecars` `indices`). `qs` turns
|
|
62
|
+
* longer arrays into an object, which then fails schema validation.
|
|
63
|
+
*/
|
|
64
|
+
const QUERY_STRING_ARRAY_LIMIT = NUMBER_OF_COLUMNS;
|
|
65
|
+
|
|
58
66
|
/**
|
|
59
67
|
* REST API powered by `fastify` server.
|
|
60
68
|
*/
|
|
@@ -82,6 +90,7 @@ export class RestApiServer {
|
|
|
82
90
|
// be OpenAPI spec compliant and results are inconsistent, see https://github.com/ljharb/qs/issues/331.
|
|
83
91
|
// The schema validation will catch this and throw an error as parsed query string results in an object.
|
|
84
92
|
parseArrays: false,
|
|
93
|
+
arrayLimit: QUERY_STRING_ARRAY_LIMIT,
|
|
85
94
|
}),
|
|
86
95
|
},
|
|
87
96
|
bodyLimit: opts.bodyLimit,
|
|
@@ -124,18 +124,13 @@ export async function importBlock(
|
|
|
124
124
|
executionStatus = parentBlock.executionStatus;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
// getBeaconProposerOrNull will return null if head state is more than one epoch away
|
|
128
|
-
// from block slot. We skip proposer boost canonical check as we cannot determine the canonical proposer
|
|
129
|
-
const expectedProposerIndex: number | null = this.getHeadState().getBeaconProposerOrNull(blockSlot);
|
|
130
|
-
|
|
131
127
|
const blockSummary = this.forkChoice.onBlock(
|
|
132
128
|
block.message,
|
|
133
129
|
postState,
|
|
134
130
|
blockDelaySec,
|
|
135
131
|
currentSlot,
|
|
136
132
|
executionStatus,
|
|
137
|
-
dataAvailabilityStatus
|
|
138
|
-
expectedProposerIndex
|
|
133
|
+
dataAvailabilityStatus
|
|
139
134
|
);
|
|
140
135
|
|
|
141
136
|
// This adds the state necessary to process the next block
|
|
@@ -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";
|
|
@@ -151,6 +152,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
151
152
|
readonly genesisValidatorsRoot: Root;
|
|
152
153
|
readonly executionEngine: IExecutionEngine;
|
|
153
154
|
readonly executionBuilder?: IExecutionBuilder;
|
|
155
|
+
readonly builderCircuitBreaker: BuilderCircuitBreaker;
|
|
154
156
|
// Expose config for convenience in modularized functions
|
|
155
157
|
readonly config: BeaconConfig;
|
|
156
158
|
readonly custodyConfig: CustodyConfig;
|
|
@@ -425,6 +427,11 @@ export class BeaconChain implements IBeaconChain {
|
|
|
425
427
|
|
|
426
428
|
this.forkChoice = forkChoice;
|
|
427
429
|
|
|
430
|
+
this.builderCircuitBreaker = new BuilderCircuitBreaker(
|
|
431
|
+
{faultInspectionWindow: opts.faultInspectionWindow, allowedFaults: opts.allowedFaults},
|
|
432
|
+
{forkChoice, logger, metrics}
|
|
433
|
+
);
|
|
434
|
+
|
|
428
435
|
this.seenPayloadEnvelopeInputCache = new SeenPayloadEnvelopeInput({
|
|
429
436
|
config,
|
|
430
437
|
clock,
|
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";
|
|
@@ -95,6 +96,7 @@ export interface IBeaconChain {
|
|
|
95
96
|
readonly earliestAvailableSlot: Slot;
|
|
96
97
|
readonly executionEngine: IExecutionEngine;
|
|
97
98
|
readonly executionBuilder?: IExecutionBuilder;
|
|
99
|
+
readonly builderCircuitBreaker: BuilderCircuitBreaker;
|
|
98
100
|
// Expose config for convenience in modularized functions
|
|
99
101
|
readonly config: BeaconConfig;
|
|
100
102
|
readonly custodyConfig: CustodyConfig;
|