@lodestar/beacon-node 1.51.0-dev.596284206a → 1.51.0-dev.6484138c50
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/validator/index.d.ts +6 -0
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +38 -25
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/blocks/types.d.ts +4 -1
- package/lib/chain/blocks/types.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlock.js +17 -6
- package/lib/chain/blocks/verifyBlock.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksSignatures.js +7 -5
- package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
- package/lib/chain/bls/interface.d.ts +2 -0
- package/lib/chain/bls/interface.d.ts.map +1 -1
- package/lib/chain/bls/multithread/index.d.ts.map +1 -1
- package/lib/chain/bls/multithread/index.js +8 -6
- package/lib/chain/bls/multithread/index.js.map +1 -1
- package/lib/execution/builder/apiClient.d.ts +14 -8
- package/lib/execution/builder/apiClient.d.ts.map +1 -1
- package/lib/execution/builder/apiClient.js +12 -10
- package/lib/execution/builder/apiClient.js.map +1 -1
- package/lib/execution/builder/http.d.ts +2 -0
- package/lib/execution/builder/http.d.ts.map +1 -1
- package/lib/execution/builder/http.js +2 -0
- package/lib/execution/builder/http.js.map +1 -1
- package/lib/execution/engine/utils.d.ts.map +1 -1
- package/lib/execution/engine/utils.js +3 -2
- package/lib/execution/engine/utils.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +1 -0
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +5 -0
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/metrics/server/http.js +5 -5
- package/lib/metrics/server/http.js.map +1 -1
- package/lib/network/libp2p/index.d.ts.map +1 -1
- package/lib/network/libp2p/index.js +5 -1
- package/lib/network/libp2p/index.js.map +1 -1
- package/lib/network/options.d.ts +2 -0
- package/lib/network/options.d.ts.map +1 -1
- package/lib/network/options.js.map +1 -1
- package/lib/node/nodejs.d.ts +2 -0
- package/lib/node/nodejs.d.ts.map +1 -1
- package/lib/node/nodejs.js +37 -19
- package/lib/node/nodejs.js.map +1 -1
- package/lib/node/options.d.ts +3 -1
- package/lib/node/options.d.ts.map +1 -1
- package/lib/node/options.js +4 -2
- package/lib/node/options.js.map +1 -1
- package/package.json +16 -16
- package/src/api/impl/validator/index.ts +43 -29
- package/src/chain/blocks/types.ts +4 -1
- package/src/chain/blocks/verifyBlock.ts +30 -16
- package/src/chain/blocks/verifyBlocksSignatures.ts +7 -5
- package/src/chain/bls/interface.ts +2 -0
- package/src/chain/bls/multithread/index.ts +9 -5
- package/src/execution/builder/apiClient.ts +16 -13
- package/src/execution/builder/http.ts +4 -0
- package/src/execution/engine/utils.ts +4 -2
- package/src/metrics/metrics/lodestar.ts +5 -0
- package/src/metrics/server/http.ts +5 -5
- package/src/network/libp2p/index.ts +5 -1
- package/src/network/options.ts +2 -0
- package/src/node/nodejs.ts +34 -15
- package/src/node/options.ts +5 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/node/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAoB,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAC,WAAW,EAAE,oBAAoB,EAAE,aAAa,EAAsB,MAAM,qBAAqB,CAAC;AAC1G,OAAO,EAAC,oBAAoB,EAA8B,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAC,eAAe,EAAmB,MAAM,kBAAkB,CAAC;AACnE,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EACnB,+BAA+B,EAE/B,8BAA8B,EAE9B,cAAc,EACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAC,cAAc,EAAwB,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAC,iBAAiB,EAA2B,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAC,cAAc,EAAwB,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAC,WAAW,EAAqB,MAAM,oBAAoB,CAAC;AAGnE,OAAO,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAC;AACnD,YAAY,EAAC,aAAa,EAAC,CAAC;AAE5B,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,+BAA+B,EAC/B,8BAA8B,EAC9B,cAAc,GACf,CAAC;AAEF,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,UAAU,CAAC;IAChB,KAAK,EAAE,aAAa,CAAC;IACrB,EAAE,EAAE,eAAe,CAAC;IACpB,eAAe,EAAE,mBAAmB,CAAC;IACrC,gBAAgB,EAAE,oBAAoB,CAAC;IACvC,OAAO,EAAE,cAAc,CAAC;IACxB,gBAAgB,EAAE,oBAAoB,CAAC;IACvC,UAAU,EAAE,iBAAiB,CAAC;IAC9B,OAAO,EAAE,cAAc,CAAC;IACxB,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,eAAO,MAAM,cAAc,EAAE,kBAW5B,CAAC"}
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/node/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sCAAsC,EAAC,MAAM,gCAAgC,CAAC;AACtF,OAAO,EAAC,UAAU,EAAoB,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAC,WAAW,EAAE,oBAAoB,EAAE,aAAa,EAAsB,MAAM,qBAAqB,CAAC;AAC1G,OAAO,EAAC,oBAAoB,EAA8B,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAC,eAAe,EAAmB,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAC,yBAAyB,EAAC,MAAM,mCAAmC,CAAC;AAC5E,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EACnB,+BAA+B,EAE/B,8BAA8B,EAE9B,cAAc,EACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAC,cAAc,EAAwB,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAC,iBAAiB,EAA2B,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAC,cAAc,EAAwB,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAC,WAAW,EAAqB,MAAM,oBAAoB,CAAC;AAGnE,OAAO,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAC;AACnD,YAAY,EAAC,aAAa,EAAC,CAAC;AAE5B,OAAO,EACL,WAAW,EACX,sCAAsC,EACtC,yBAAyB,EACzB,oBAAoB,EACpB,+BAA+B,EAC/B,8BAA8B,EAC9B,cAAc,GACf,CAAC;AAEF,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,UAAU,CAAC;IAChB,KAAK,EAAE,aAAa,CAAC;IACrB,EAAE,EAAE,eAAe,CAAC;IACpB,eAAe,EAAE,mBAAmB,CAAC;IACrC,gBAAgB,EAAE,oBAAoB,CAAC;IACvC,OAAO,EAAE,cAAc,CAAC;IACxB,gBAAgB,EAAE,oBAAoB,CAAC;IACvC,UAAU,EAAE,iBAAiB,CAAC;IAC9B,OAAO,EAAE,cAAc,CAAC;IACxB,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,eAAO,MAAM,cAAc,EAAE,kBAW5B,CAAC"}
|
package/lib/node/options.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { BLOCK_PRODUCTION_RACE_CUTOFF_GLOAS_BPS } from "../api/impl/validator/index.js";
|
|
1
2
|
import { defaultApiOptions } from "../api/options.js";
|
|
2
3
|
import { ArchiveMode, DEFAULT_ARCHIVE_MODE, defaultChainOptions } from "../chain/options.js";
|
|
3
4
|
import { defaultValidatorMonitorOpts } from "../chain/validatorMonitor.js";
|
|
4
5
|
import { defaultDbOptions } from "../db/options.js";
|
|
6
|
+
import { BUILDER_BID_LAG_BUFFER_MS } from "../execution/builder/apiClient.js";
|
|
5
7
|
import { defaultExecutionBuilderHttpOpts, defaultExecutionBuilderOpts, defaultExecutionEngineHttpOpts, defaultExecutionEngineOpts, engineApiModes, } from "../execution/index.js";
|
|
6
8
|
import { defaultMetricsOptions } from "../metrics/options.js";
|
|
7
9
|
import { defaultMonitoringOptions } from "../monitoring/options.js";
|
|
@@ -9,8 +11,8 @@ import { defaultNetworkOptions } from "../network/options.js";
|
|
|
9
11
|
import { defaultSyncOptions } from "../sync/options.js";
|
|
10
12
|
// Re-export so the CLI doesn't need to depend on lodestar-api
|
|
11
13
|
export { allNamespaces } from "../api/rest/index.js";
|
|
12
|
-
// Re-export to use as default values in CLI args
|
|
13
|
-
export { ArchiveMode, DEFAULT_ARCHIVE_MODE, defaultExecutionBuilderHttpOpts, defaultExecutionEngineHttpOpts, engineApiModes, };
|
|
14
|
+
// Re-export to use as default values and for validation in CLI args
|
|
15
|
+
export { ArchiveMode, BLOCK_PRODUCTION_RACE_CUTOFF_GLOAS_BPS, BUILDER_BID_LAG_BUFFER_MS, DEFAULT_ARCHIVE_MODE, defaultExecutionBuilderHttpOpts, defaultExecutionEngineHttpOpts, engineApiModes, };
|
|
14
16
|
export const defaultOptions = {
|
|
15
17
|
api: defaultApiOptions,
|
|
16
18
|
chain: defaultChainOptions,
|
package/lib/node/options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/node/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,iBAAiB,EAAC,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAC,WAAW,EAAE,oBAAoB,EAAiB,mBAAmB,EAAC,MAAM,qBAAqB,CAAC;AAC1G,OAAO,EAAuB,2BAA2B,EAAC,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAkB,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAIL,+BAA+B,EAC/B,2BAA2B,EAC3B,8BAA8B,EAC9B,0BAA0B,EAC1B,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAiB,qBAAqB,EAAC,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAoB,wBAAwB,EAAC,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAiB,qBAAqB,EAAC,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAc,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AAEnE,8DAA8D;AAC9D,OAAO,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAEnD,
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/node/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sCAAsC,EAAC,MAAM,gCAAgC,CAAC;AACtF,OAAO,EAAa,iBAAiB,EAAC,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAC,WAAW,EAAE,oBAAoB,EAAiB,mBAAmB,EAAC,MAAM,qBAAqB,CAAC;AAC1G,OAAO,EAAuB,2BAA2B,EAAC,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAkB,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAC,yBAAyB,EAAC,MAAM,mCAAmC,CAAC;AAC5E,OAAO,EAIL,+BAA+B,EAC/B,2BAA2B,EAC3B,8BAA8B,EAC9B,0BAA0B,EAC1B,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAiB,qBAAqB,EAAC,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAoB,wBAAwB,EAAC,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAiB,qBAAqB,EAAC,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAc,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AAEnE,8DAA8D;AAC9D,OAAO,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAEnD,oEAAoE;AACpE,OAAO,EACL,WAAW,EACX,sCAAsC,EACtC,yBAAyB,EACzB,oBAAoB,EACpB,+BAA+B,EAC/B,8BAA8B,EAC9B,cAAc,GACf,CAAC;AAeF,MAAM,CAAC,MAAM,cAAc,GAAuB;IAChD,GAAG,EAAE,iBAAiB;IACtB,KAAK,EAAE,mBAAmB;IAC1B,EAAE,EAAE,gBAAgB;IACpB,eAAe,EAAE,0BAA0B;IAC3C,gBAAgB,EAAE,2BAA2B;IAC7C,OAAO,EAAE,qBAAqB;IAC9B,gBAAgB,EAAE,2BAA2B;IAC7C,UAAU,EAAE,wBAAwB;IACpC,OAAO,EAAE,qBAAqB;IAC9B,IAAI,EAAE,kBAAkB;CACzB,CAAC"}
|
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.51.0-dev.
|
|
14
|
+
"version": "1.51.0-dev.6484138c50",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -126,18 +126,18 @@
|
|
|
126
126
|
"@libp2p/prometheus-metrics": "^5.0.31",
|
|
127
127
|
"@libp2p/tcp": "^11.0.30",
|
|
128
128
|
"@libp2p/utils": "^7.4.3",
|
|
129
|
-
"@lodestar/api": "^1.51.0-dev.
|
|
130
|
-
"@lodestar/config": "^1.51.0-dev.
|
|
131
|
-
"@lodestar/db": "^1.51.0-dev.
|
|
132
|
-
"@lodestar/fork-choice": "^1.51.0-dev.
|
|
133
|
-
"@lodestar/logger": "^1.51.0-dev.
|
|
134
|
-
"@lodestar/native": "^1.51.0-dev.
|
|
135
|
-
"@lodestar/params": "^1.51.0-dev.
|
|
136
|
-
"@lodestar/reqresp": "^1.51.0-dev.
|
|
137
|
-
"@lodestar/state-transition": "^1.51.0-dev.
|
|
138
|
-
"@lodestar/types": "^1.51.0-dev.
|
|
139
|
-
"@lodestar/utils": "^1.51.0-dev.
|
|
140
|
-
"@lodestar/validator": "^1.51.0-dev.
|
|
129
|
+
"@lodestar/api": "^1.51.0-dev.6484138c50",
|
|
130
|
+
"@lodestar/config": "^1.51.0-dev.6484138c50",
|
|
131
|
+
"@lodestar/db": "^1.51.0-dev.6484138c50",
|
|
132
|
+
"@lodestar/fork-choice": "^1.51.0-dev.6484138c50",
|
|
133
|
+
"@lodestar/logger": "^1.51.0-dev.6484138c50",
|
|
134
|
+
"@lodestar/native": "^1.51.0-dev.6484138c50",
|
|
135
|
+
"@lodestar/params": "^1.51.0-dev.6484138c50",
|
|
136
|
+
"@lodestar/reqresp": "^1.51.0-dev.6484138c50",
|
|
137
|
+
"@lodestar/state-transition": "^1.51.0-dev.6484138c50",
|
|
138
|
+
"@lodestar/types": "^1.51.0-dev.6484138c50",
|
|
139
|
+
"@lodestar/utils": "^1.51.0-dev.6484138c50",
|
|
140
|
+
"@lodestar/validator": "^1.51.0-dev.6484138c50",
|
|
141
141
|
"@multiformats/multiaddr": "^13.0.1",
|
|
142
142
|
"datastore-core": "^12.0.1",
|
|
143
143
|
"datastore-level": "^13.0.1",
|
|
@@ -159,8 +159,8 @@
|
|
|
159
159
|
"@ethereumjs/rlp": "^4.0.1",
|
|
160
160
|
"@libp2p/interface-internal": "^3.2.0",
|
|
161
161
|
"@libp2p/logger": "^6.2.15",
|
|
162
|
-
"@lodestar/spec-test-util": "^1.51.0-dev.
|
|
163
|
-
"@lodestar/test-utils": "^1.51.0-dev.
|
|
162
|
+
"@lodestar/spec-test-util": "^1.51.0-dev.6484138c50",
|
|
163
|
+
"@lodestar/test-utils": "^1.51.0-dev.6484138c50",
|
|
164
164
|
"@types/js-yaml": "^4.0.5",
|
|
165
165
|
"@types/qs": "^6.9.7",
|
|
166
166
|
"@types/tmp": "^0.2.3",
|
|
@@ -174,5 +174,5 @@
|
|
|
174
174
|
"beacon",
|
|
175
175
|
"blockchain"
|
|
176
176
|
],
|
|
177
|
-
"gitHead": "
|
|
177
|
+
"gitHead": "52d9f70effc2ef20ef5f1beb3a6a453528223d9c"
|
|
178
178
|
}
|
|
@@ -94,7 +94,7 @@ import {
|
|
|
94
94
|
import {validateGossipProposerPreferences} from "../../../chain/validation/proposerPreferences.js";
|
|
95
95
|
import {validateSyncCommitteeGossipContributionAndProof} from "../../../chain/validation/syncCommitteeContributionAndProof.js";
|
|
96
96
|
import {ZERO_HASH} from "../../../constants/index.js";
|
|
97
|
-
import {
|
|
97
|
+
import {BuilderApiBid, decodeBuilderUrl} from "../../../execution/builder/apiClient.js";
|
|
98
98
|
import {BuilderStatus, NoBidReceived} from "../../../execution/builder/http.js";
|
|
99
99
|
import {getBuilderBidTotalGwei, validateBuilderApiExecutionPayloadBid} from "../../../execution/builder/validateBid.js";
|
|
100
100
|
import {validateGossipFnRetryUnknownRoot} from "../../../network/processor/gossipHandlers.js";
|
|
@@ -123,10 +123,14 @@ import {
|
|
|
123
123
|
* A cutoff of 1667 BPS (2 seconds for 12s slots) gives enough time and if there are unexpected delays
|
|
124
124
|
* it ensures we publish in time as proposals after the attestation deadline will likely be orphaned
|
|
125
125
|
* due to proposer boost reorg.
|
|
126
|
-
*
|
|
127
|
-
* TODO GLOAS: re-evaluate cutoff timing due to attestation deadline changes in gloas
|
|
128
126
|
*/
|
|
129
127
|
const BLOCK_PRODUCTION_RACE_CUTOFF_BPS = 1667;
|
|
128
|
+
/**
|
|
129
|
+
* Post-gloas cutoff, kept at 1667 BPS (2 seconds for 12s slots) for now.
|
|
130
|
+
*
|
|
131
|
+
* TODO GLOAS: revisit, the block propagates faster as it only commits to a bid and the attestation deadline changed
|
|
132
|
+
*/
|
|
133
|
+
export const BLOCK_PRODUCTION_RACE_CUTOFF_GLOAS_BPS = 1667;
|
|
130
134
|
/** Rejection message of the bid block branch when there is no viable bid to commit to */
|
|
131
135
|
const NO_BID_AVAILABLE = "No builder bid available";
|
|
132
136
|
|
|
@@ -1005,33 +1009,50 @@ export function getValidatorApi(
|
|
|
1005
1009
|
(!circuitBreakerActive &&
|
|
1006
1010
|
chain.executionPayloadBidPool.getBestBid(slot, bidParentBlockHash, parentBlockRootHex) !== null);
|
|
1007
1011
|
|
|
1008
|
-
//
|
|
1009
|
-
//
|
|
1010
|
-
const
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
});
|
|
1022
|
-
return null;
|
|
1023
|
-
}
|
|
1024
|
-
return p2pBid;
|
|
1025
|
-
});
|
|
1012
|
+
// Calculate cutoff time based on start of the slot, ensures a slow local payload build does
|
|
1013
|
+
// not delay the proposal when a builder bid block is available (and vice versa)
|
|
1014
|
+
const cutoffMs = Math.max(
|
|
1015
|
+
0,
|
|
1016
|
+
config.getSlotComponentDurationMs(fork, BLOCK_PRODUCTION_RACE_CUTOFF_GLOAS_BPS) - chain.clock.msFromSlot(slot)
|
|
1017
|
+
);
|
|
1018
|
+
|
|
1019
|
+
// Give p2p bids the same time to bid up as granted to builder API bid requests via the advertised
|
|
1020
|
+
// deadline, the pool is read once the deadline passed and the bid requests settled. A late request
|
|
1021
|
+
// does not wait past the race cutoff, a pooled bid is still the fastest fallback if the local block fails
|
|
1022
|
+
const bidDeadlinePromise = circuitBreakerActive
|
|
1023
|
+
? Promise.resolve()
|
|
1024
|
+
: sleep(Math.min(chain.builderApiClient.bidDeadline, cutoffMs));
|
|
1026
1025
|
|
|
1027
1026
|
// Candidates are ranked by their boosted counted total payment, the p2p bid is governed
|
|
1028
1027
|
// by the top-level factors and each builder API bid by its own entry. Ties prefer the
|
|
1029
1028
|
// earliest received builder API bid, so the signed block can be routed back to its
|
|
1030
1029
|
// builder directly.
|
|
1031
1030
|
const bestBidPromise: Promise<BidCandidate | null> = (async () => {
|
|
1032
|
-
|
|
1031
|
+
// Past the race cutoff a pooled p2p bid is used right away rather than waiting for pending
|
|
1032
|
+
// builder API requests, the local block is selected at the cutoff anyway if it is ready
|
|
1033
|
+
let [builderApiBids] = await Promise.all([
|
|
1034
|
+
Promise.race([builderApiBidsPromise, sleep(cutoffMs).then(() => null)]),
|
|
1035
|
+
bidDeadlinePromise,
|
|
1036
|
+
]);
|
|
1033
1037
|
let parentExecutionRequestsPromise: Promise<gloas.ExecutionRequests> | null = null;
|
|
1034
1038
|
|
|
1039
|
+
let p2pBid: PooledExecutionPayloadBid | null = circuitBreakerActive
|
|
1040
|
+
? null
|
|
1041
|
+
: chain.executionPayloadBidPool.getBestBid(slot, bidParentBlockHash, parentBlockRootHex);
|
|
1042
|
+
// Discard p2p bids below the proposer's configured floor on the total payment.
|
|
1043
|
+
// A p2p bid's total is just its value since gossip validation enforces executionPayment=0.
|
|
1044
|
+
if (p2pBid !== null && BigInt(p2pBid.signedBid.message.value) < builderConfig.minBid) {
|
|
1045
|
+
logger.info("Best p2p bid below configured minimum", {
|
|
1046
|
+
slot,
|
|
1047
|
+
bidValue: prettyGweiToEth(p2pBid.signedBid.message.value),
|
|
1048
|
+
minBid: prettyGweiToEth(builderConfig.minBid),
|
|
1049
|
+
});
|
|
1050
|
+
p2pBid = null;
|
|
1051
|
+
}
|
|
1052
|
+
if (builderApiBids === null) {
|
|
1053
|
+
builderApiBids = p2pBid !== null ? [] : await builderApiBidsPromise;
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1035
1056
|
const candidates = (
|
|
1036
1057
|
await Promise.all(
|
|
1037
1058
|
builderApiBids.map(async ({url, entry, signedBid, receivedMs}): Promise<BidCandidate | null> => {
|
|
@@ -1118,13 +1139,6 @@ export function getValidatorApi(
|
|
|
1118
1139
|
return fn().finally(() => t?.({source}));
|
|
1119
1140
|
};
|
|
1120
1141
|
|
|
1121
|
-
// Calculate cutoff time based on start of the slot, ensures a slow local payload build does
|
|
1122
|
-
// not delay the proposal when a builder bid block is available (and vice versa)
|
|
1123
|
-
const cutoffMs = Math.max(
|
|
1124
|
-
0,
|
|
1125
|
-
config.getSlotComponentDurationMs(fork, BLOCK_PRODUCTION_RACE_CUTOFF_BPS) - chain.clock.msFromSlot(slot)
|
|
1126
|
-
);
|
|
1127
|
-
|
|
1128
1142
|
// use abort controller to stop waiting for the bid block if the engine block will be selected
|
|
1129
1143
|
const controller = new AbortController();
|
|
1130
1144
|
|
|
@@ -109,7 +109,10 @@ export type FullyVerifiedBlock = {
|
|
|
109
109
|
parentBlockSlot: Slot;
|
|
110
110
|
proposerBalanceDelta: number;
|
|
111
111
|
dataAvailabilityStatus: DataAvailabilityStatus;
|
|
112
|
-
/**
|
|
112
|
+
/**
|
|
113
|
+
* Pre-computed indexed attestations from signature verification to avoid duplicate work.
|
|
114
|
+
* Their `attestingIndices` are in committee order, not sorted, so they are not spec-valid `IndexedAttestation`s.
|
|
115
|
+
*/
|
|
113
116
|
indexedAttestations: IndexedAttestation[];
|
|
114
117
|
/** Seen timestamp seconds */
|
|
115
118
|
seenTimestampSec: number;
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
DataAvailabilityStatus,
|
|
5
5
|
IBeaconStateView,
|
|
6
6
|
computeEpochAtSlot,
|
|
7
|
-
|
|
7
|
+
getAttestingIndices,
|
|
8
8
|
signedBlockToSignedHeader,
|
|
9
9
|
} from "@lodestar/state-transition";
|
|
10
10
|
import {IndexedAttestation, Slot, deneb} from "@lodestar/types";
|
|
@@ -119,7 +119,13 @@ export async function verifyBlocksInEpoch(
|
|
|
119
119
|
const shuffling =
|
|
120
120
|
this.shufflingCache.getSync(attEpoch, preState0.getShufflingDecisionRoot(attEpoch)) ??
|
|
121
121
|
preState0.getShufflingAtEpoch(attEpoch);
|
|
122
|
-
|
|
122
|
+
// Unlike getIndexedAttestation, keep attestingIndices in committee order: sorting them dominates building
|
|
123
|
+
// these on mainnet blocks. See FullyVerifiedBlock.indexedAttestations.
|
|
124
|
+
return {
|
|
125
|
+
attestingIndices: getAttestingIndices(shuffling, fork, attestation),
|
|
126
|
+
data: attestation.data,
|
|
127
|
+
signature: attestation.signature,
|
|
128
|
+
};
|
|
123
129
|
});
|
|
124
130
|
}
|
|
125
131
|
|
|
@@ -175,16 +181,29 @@ export async function verifyBlocksInEpoch(
|
|
|
175
181
|
const [
|
|
176
182
|
segmentExecStatus,
|
|
177
183
|
{blockDAStatuses, payloadDAStatuses, availableTime},
|
|
178
|
-
{postStates, proposerBalanceDeltas, verifyStateTime},
|
|
179
184
|
{verifySignaturesTime},
|
|
185
|
+
{postStates, proposerBalanceDeltas, verifyStateTime},
|
|
180
186
|
] = await Promise.all([
|
|
181
187
|
verifyExecutionPayloadsPromise,
|
|
182
188
|
|
|
183
189
|
// data availability (fork-specific; see daAvailabilityPromise above)
|
|
184
190
|
daAvailabilityPromise,
|
|
185
191
|
|
|
192
|
+
// All signatures at once. Must be called before verifyBlocksStateTransitionOnly()
|
|
193
|
+
// so we hand the BLS job to the worker pool before the main thread
|
|
194
|
+
// is busy with the state transition.
|
|
195
|
+
verifyBlocksSignatures(
|
|
196
|
+
this.config,
|
|
197
|
+
this.bls,
|
|
198
|
+
this.logger,
|
|
199
|
+
this.metrics,
|
|
200
|
+
preState0,
|
|
201
|
+
blocks,
|
|
202
|
+
indexedAttestationsByBlock,
|
|
203
|
+
opts
|
|
204
|
+
),
|
|
205
|
+
|
|
186
206
|
// Run state transition only
|
|
187
|
-
// TODO: Ensure it yields to allow flushing to workers and engine API
|
|
188
207
|
verifyBlocksStateTransitionOnly(
|
|
189
208
|
preState0,
|
|
190
209
|
blockInputs,
|
|
@@ -198,22 +217,17 @@ export async function verifyBlocksInEpoch(
|
|
|
198
217
|
opts
|
|
199
218
|
),
|
|
200
219
|
|
|
201
|
-
// All signatures at once
|
|
202
|
-
verifyBlocksSignatures(
|
|
203
|
-
this.config,
|
|
204
|
-
this.bls,
|
|
205
|
-
this.logger,
|
|
206
|
-
this.metrics,
|
|
207
|
-
preState0,
|
|
208
|
-
blocks,
|
|
209
|
-
indexedAttestationsByBlock,
|
|
210
|
-
opts
|
|
211
|
-
),
|
|
212
|
-
|
|
213
220
|
// TODO GLOAS: can verify payload signatures in batch too
|
|
214
221
|
// maybe chain with the above verifyBlocksSignatures()
|
|
215
222
|
]);
|
|
216
223
|
|
|
224
|
+
if (blockInputs.length === 1 && opts.seenTimestampSec !== undefined) {
|
|
225
|
+
const consensusVerifiedTime = Math.max(verifyStateTime, verifySignaturesTime);
|
|
226
|
+
this.metrics?.gossipBlock.receivedToConsensusVerifiedTime.observe(
|
|
227
|
+
consensusVerifiedTime / 1000 - opts.seenTimestampSec
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
217
231
|
for (const blockInput of blockInputs) {
|
|
218
232
|
const block = blockInput.getBlock();
|
|
219
233
|
const {slot, proposerIndex} = block.message;
|
|
@@ -36,10 +36,9 @@ export async function verifyBlocksSignatures(
|
|
|
36
36
|
? preState0.currentSyncCommitteeIndexed
|
|
37
37
|
: new SyncCommitteeCacheEmpty();
|
|
38
38
|
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
//
|
|
42
|
-
// so the attester and proposer shufflings are correct.
|
|
39
|
+
// Runs concurrently with the state transition. Signature sets are built from preState0, which
|
|
40
|
+
// verifyBlocksInEpoch() guarantees is in the same epoch as every block, so the proposer and attester shufflings
|
|
41
|
+
// and the sync committee are the ones the blocks were signed under.
|
|
43
42
|
for (const [i, block] of blocks.entries()) {
|
|
44
43
|
// Use [i] to make clear that the index has to be correct to blame the right block below on BlockError()
|
|
45
44
|
isValidPromises[i] = opts.validSignatures
|
|
@@ -50,7 +49,10 @@ export async function verifyBlocksSignatures(
|
|
|
50
49
|
bls.verifySignatureSets(
|
|
51
50
|
getBlockSignatureSets(config, currentSyncCommitteeIndexed, preState0, block, indexedAttestationsByBlock[i], {
|
|
52
51
|
skipProposerSignature: opts.validProposerSignature,
|
|
53
|
-
})
|
|
52
|
+
}),
|
|
53
|
+
// Prioritize block verification over attestations, since
|
|
54
|
+
// attestations already buffer up to `MAX_BUFFER_WAIT_MS`
|
|
55
|
+
{priority: true}
|
|
54
56
|
);
|
|
55
57
|
|
|
56
58
|
// getBlockSignatureSets() takes 45ms in benchmarks for 2022Q2 mainnet blocks (100 sigs). When syncing a 32 blocks
|
|
@@ -22,6 +22,8 @@ export type VerifySignatureOpts = {
|
|
|
22
22
|
verifyOnMainThread?: boolean;
|
|
23
23
|
/**
|
|
24
24
|
* Some signature sets are more important than others, and should be verified first.
|
|
25
|
+
* Non-batchable priority jobs are posted to an idle worker before this call returns, so the caller
|
|
26
|
+
* can run synchronous work right after without delaying the verification.
|
|
25
27
|
*/
|
|
26
28
|
priority?: boolean;
|
|
27
29
|
};
|
|
@@ -333,15 +333,19 @@ export class BlsMultiThreadWorkerPool implements IBlsVerifier {
|
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
+
// First hand work to an idle worker before returning to the caller.
|
|
337
|
+
// Deferring the post to the next macrotask would make the worker
|
|
338
|
+
// sit idle while waiting for the next synchronous work
|
|
339
|
+
else if (job.opts.priority) {
|
|
340
|
+
this.jobs.unshift(job);
|
|
341
|
+
void this.runJob();
|
|
342
|
+
}
|
|
343
|
+
|
|
336
344
|
// Push job and schedule to call `runJob` in the next macro event loop cycle.
|
|
337
345
|
// This is useful to allow batching job submitted from a synchronous for loop,
|
|
338
346
|
// and to prevent large stacks since runJob may be called recursively.
|
|
339
347
|
else {
|
|
340
|
-
|
|
341
|
-
this.jobs.unshift(job);
|
|
342
|
-
} else {
|
|
343
|
-
this.jobs.push(job);
|
|
344
|
-
}
|
|
348
|
+
this.jobs.push(job);
|
|
345
349
|
callInNextEventLoop(() => void this.runJob());
|
|
346
350
|
}
|
|
347
351
|
}
|
|
@@ -19,21 +19,20 @@ import {IClock} from "../../util/clock.js";
|
|
|
19
19
|
* Additional duration to account for potential event loop lag which causes
|
|
20
20
|
* builder bids to be rejected even though the response was sent in time.
|
|
21
21
|
*/
|
|
22
|
-
const
|
|
22
|
+
export const BUILDER_BID_LAG_BUFFER_MS = 250;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
26
|
-
* is reached, advertised on each bid request via the `X-Timeout-Ms` header.
|
|
27
|
-
*
|
|
25
|
+
* Default 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. Bids received via
|
|
27
|
+
* p2p are given the same time to bid up.
|
|
28
28
|
*/
|
|
29
|
-
export const
|
|
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;
|
|
29
|
+
export const DEFAULT_BUILDER_BID_DEADLINE_MS = 500;
|
|
33
30
|
|
|
34
31
|
export type BuilderApiClientOpts = {
|
|
35
|
-
/** Timeout for builder api requests, bid requests
|
|
32
|
+
/** Timeout for builder api requests, bid requests are bounded by `bidDeadline` instead */
|
|
36
33
|
timeout?: number;
|
|
34
|
+
/** Time builders are given to provide a bid once block production starts, in milliseconds */
|
|
35
|
+
bidDeadline?: number;
|
|
37
36
|
// Add User-Agent header to all requests
|
|
38
37
|
userAgent?: string;
|
|
39
38
|
};
|
|
@@ -69,6 +68,7 @@ export type BuilderApiBid = {
|
|
|
69
68
|
* each block production request, clients are dialed on demand based on the entry `url`.
|
|
70
69
|
*/
|
|
71
70
|
export class BuilderApiClient {
|
|
71
|
+
readonly bidDeadline: number;
|
|
72
72
|
private readonly clients = new Map<BuilderUrl, BuilderApi>();
|
|
73
73
|
|
|
74
74
|
constructor(
|
|
@@ -78,7 +78,9 @@ export class BuilderApiClient {
|
|
|
78
78
|
private readonly bls: IBlsVerifier,
|
|
79
79
|
private readonly metrics: Metrics | null = null,
|
|
80
80
|
private readonly logger?: Logger
|
|
81
|
-
) {
|
|
81
|
+
) {
|
|
82
|
+
this.bidDeadline = opts.bidDeadline ?? DEFAULT_BUILDER_BID_DEADLINE_MS;
|
|
83
|
+
}
|
|
82
84
|
|
|
83
85
|
/**
|
|
84
86
|
* Fan out bid requests to the builders named by the entries, one request per unique
|
|
@@ -139,9 +141,10 @@ export class BuilderApiClient {
|
|
|
139
141
|
proposerPubkey,
|
|
140
142
|
requestAuth: entry.auth,
|
|
141
143
|
dateMilliseconds: Date.now(),
|
|
142
|
-
timeoutMs:
|
|
144
|
+
timeoutMs: this.bidDeadline,
|
|
143
145
|
},
|
|
144
|
-
|
|
146
|
+
// Event loop lag must not discard bids that arrived in time
|
|
147
|
+
{timeoutMs: this.bidDeadline + BUILDER_BID_LAG_BUFFER_MS}
|
|
145
148
|
);
|
|
146
149
|
const signedBid = res.value();
|
|
147
150
|
if (signedBid === undefined) {
|
|
@@ -203,7 +206,7 @@ export class BuilderApiClient {
|
|
|
203
206
|
|
|
204
207
|
/**
|
|
205
208
|
* Establish the connection to every known builder outside the bid deadline, a cold TCP/TLS handshake
|
|
206
|
-
* to a distant builder can exhaust
|
|
209
|
+
* to a distant builder can exhaust the bid deadline on its own, and a long idle connection
|
|
207
210
|
* may be half-open and only fail once written to.
|
|
208
211
|
*/
|
|
209
212
|
async checkStatus(): Promise<void> {
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
} from "@lodestar/types";
|
|
21
21
|
import {toPrintableUrl} from "@lodestar/utils";
|
|
22
22
|
import {Metrics} from "../../metrics/metrics.js";
|
|
23
|
+
import {DEFAULT_BUILDER_BID_DEADLINE_MS} from "./apiClient.js";
|
|
23
24
|
import {ValidatorRegistration, ValidatorRegistrationCache} from "./cache.js";
|
|
24
25
|
import {IExecutionBuilder} from "./interface.js";
|
|
25
26
|
|
|
@@ -29,6 +30,8 @@ export type ExecutionBuilderHttpOpts = {
|
|
|
29
30
|
timeout?: number;
|
|
30
31
|
faultInspectionWindow?: number;
|
|
31
32
|
allowedFaults?: number;
|
|
33
|
+
/** Post-gloas only, time builders are given to provide a bid once block production starts, in milliseconds */
|
|
34
|
+
bidDeadline?: number;
|
|
32
35
|
|
|
33
36
|
// Only required for merge-mock runs, no need to expose it to cli
|
|
34
37
|
issueLocalFcUWithFeeRecipient?: string;
|
|
@@ -40,6 +43,7 @@ export const defaultExecutionBuilderHttpOpts: ExecutionBuilderHttpOpts = {
|
|
|
40
43
|
enabled: false,
|
|
41
44
|
url: "http://localhost:8661",
|
|
42
45
|
timeout: 12000,
|
|
46
|
+
bidDeadline: DEFAULT_BUILDER_BID_DEADLINE_MS,
|
|
43
47
|
};
|
|
44
48
|
|
|
45
49
|
export enum BuilderStatus {
|
|
@@ -169,14 +169,16 @@ function getExecutionEngineStateForPayloadStatus(payloadStatus: ExecutionPayload
|
|
|
169
169
|
return ExecutionEngineState.SYNCED;
|
|
170
170
|
|
|
171
171
|
case ExecutionPayloadStatus.ELERROR:
|
|
172
|
-
case ExecutionPayloadStatus.INVALID:
|
|
173
172
|
case ExecutionPayloadStatus.SYNCING:
|
|
174
|
-
case ExecutionPayloadStatus.INVALID_BLOCK_HASH:
|
|
175
173
|
return ExecutionEngineState.SYNCING;
|
|
176
174
|
|
|
177
175
|
case ExecutionPayloadStatus.UNAVAILABLE:
|
|
178
176
|
return ExecutionEngineState.OFFLINE;
|
|
179
177
|
|
|
178
|
+
case ExecutionPayloadStatus.INVALID:
|
|
179
|
+
case ExecutionPayloadStatus.INVALID_BLOCK_HASH:
|
|
180
|
+
return ExecutionEngineState.ONLINE;
|
|
181
|
+
|
|
180
182
|
default:
|
|
181
183
|
// In case we can't determine the state, we assume it stays in old state
|
|
182
184
|
// This assumption is better than considering offline, because the offline state may trigger some notifications
|
|
@@ -1013,6 +1013,11 @@ export function createLodestarMetrics(
|
|
|
1013
1013
|
help: "Time elapsed between block received and fully verified state, signatures and payload",
|
|
1014
1014
|
buckets: [0.05, 0.1, 0.3, 0.5, 0.7, 1, 1.3, 1.6, 2, 2.5, 3, 3.5, 4],
|
|
1015
1015
|
}),
|
|
1016
|
+
receivedToConsensusVerifiedTime: register.histogram({
|
|
1017
|
+
name: "lodestar_gossip_block_received_to_consensus_verified_seconds",
|
|
1018
|
+
help: "Time from gossip block arrival until both the state transition and all block signature verifications are complete, excluding execution payload verification",
|
|
1019
|
+
buckets: [0.01, 0.015, 0.02, 0.025, 0.03, 0.04, 0.5, 1],
|
|
1020
|
+
}),
|
|
1016
1021
|
verifiedToBlobsAvailabiltyTime: register.histogram<{numBlobs: number}>({
|
|
1017
1022
|
name: "lodestar_gossip_block_verified_to_blobs_availability_time",
|
|
1018
1023
|
help: "Time elapsed between block verified and blobs became available",
|
|
@@ -44,16 +44,16 @@ export async function getHttpMetricsServer(
|
|
|
44
44
|
): Promise<void> {
|
|
45
45
|
if (req.method === "GET" && req.url && req.url.includes("/metrics")) {
|
|
46
46
|
const timer = scrapeTimeMetric.startTimer();
|
|
47
|
-
const metricsRes = await Promise.all([
|
|
48
|
-
timer({status: metricsRes
|
|
47
|
+
const metricsRes = await wrapError(Promise.all([register.metrics(), getOtherMetrics()]));
|
|
48
|
+
timer({status: metricsRes.err ? RequestStatus.error : RequestStatus.success});
|
|
49
49
|
|
|
50
50
|
// Ensure we only writeHead once
|
|
51
|
-
if (metricsRes
|
|
52
|
-
res.writeHead(500, {"content-type": "text/plain"}).end(metricsRes
|
|
51
|
+
if (metricsRes.err) {
|
|
52
|
+
res.writeHead(500, {"content-type": "text/plain"}).end(metricsRes.err.stack);
|
|
53
53
|
} else {
|
|
54
54
|
// Get scrape time metrics
|
|
55
55
|
const httpServerMetrics = await httpServerRegister.metrics();
|
|
56
|
-
const metrics = [metricsRes[0]
|
|
56
|
+
const metrics = [metricsRes.result[0], httpServerMetrics, ...metricsRes.result[1]];
|
|
57
57
|
const metricsStr = metrics.join("\n\n");
|
|
58
58
|
res.writeHead(200, {"content-type": register.contentType}).end(metricsStr);
|
|
59
59
|
}
|
|
@@ -150,7 +150,11 @@ export async function createNodeJsLibp2p(
|
|
|
150
150
|
nodeInfo: {
|
|
151
151
|
name: "lodestar",
|
|
152
152
|
version: networkOpts.version ?? "unknown",
|
|
153
|
-
userAgent: networkOpts.private
|
|
153
|
+
userAgent: networkOpts.private
|
|
154
|
+
? ""
|
|
155
|
+
: networkOpts.advertiseVersion && networkOpts.version
|
|
156
|
+
? `lodestar/${networkOpts.version}`
|
|
157
|
+
: "lodestar",
|
|
154
158
|
},
|
|
155
159
|
addresses: {
|
|
156
160
|
listen: localMultiaddrs,
|
package/src/network/options.ts
CHANGED
|
@@ -25,6 +25,8 @@ export interface NetworkOptions
|
|
|
25
25
|
mdns?: boolean;
|
|
26
26
|
connectToDiscv5Bootnodes?: boolean;
|
|
27
27
|
version?: string;
|
|
28
|
+
/** Include the version in libp2p Identify. Private mode takes precedence. */
|
|
29
|
+
advertiseVersion?: boolean;
|
|
28
30
|
private?: boolean;
|
|
29
31
|
useWorker?: boolean;
|
|
30
32
|
maxYoungGenerationSizeMb?: number;
|
package/src/node/nodejs.ts
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
isStatePostGloas,
|
|
21
21
|
} from "@lodestar/state-transition";
|
|
22
22
|
import {Slot} from "@lodestar/types";
|
|
23
|
-
import {sleep, toRootHex} from "@lodestar/utils";
|
|
23
|
+
import {defer, sleep, toRootHex} from "@lodestar/utils";
|
|
24
24
|
import {ProcessShutdownCallback} from "@lodestar/validator";
|
|
25
25
|
import {BeaconRestApiServer, getApi} from "../api/index.js";
|
|
26
26
|
import {getDataColumnSidecarsMinEpoch} from "../chain/archiveStore/utils/archiveBlocks.js";
|
|
@@ -117,6 +117,7 @@ export class BeaconNode {
|
|
|
117
117
|
|
|
118
118
|
status: BeaconNodeStatus;
|
|
119
119
|
private controller?: AbortController;
|
|
120
|
+
private closePromise: Promise<void> | undefined;
|
|
120
121
|
|
|
121
122
|
constructor({
|
|
122
123
|
opts,
|
|
@@ -297,6 +298,7 @@ export class BeaconNode {
|
|
|
297
298
|
: undefined,
|
|
298
299
|
builderApiClientOpts: {
|
|
299
300
|
timeout: opts.executionBuilder.timeout,
|
|
301
|
+
bidDeadline: opts.executionBuilder.bidDeadline,
|
|
300
302
|
// Sent with all builder api requests, unless the node runs in private mode
|
|
301
303
|
userAgent: opts.executionBuilder.userAgent,
|
|
302
304
|
},
|
|
@@ -392,23 +394,40 @@ export class BeaconNode {
|
|
|
392
394
|
/**
|
|
393
395
|
* Stop beacon node and its sub-components.
|
|
394
396
|
*/
|
|
395
|
-
|
|
396
|
-
if (this.
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
397
|
+
close(): Promise<void> {
|
|
398
|
+
if (this.closePromise !== undefined) return this.closePromise;
|
|
399
|
+
const completion = defer<void>();
|
|
400
|
+
this.closePromise = completion.promise;
|
|
401
|
+
this.status = BeaconNodeStatus.closing;
|
|
402
|
+
void this.closeInternal().then(completion.resolve, completion.reject);
|
|
403
|
+
return this.closePromise;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
private async closeInternal(): Promise<void> {
|
|
407
|
+
const errors: unknown[] = [];
|
|
408
|
+
for (const cleanup of [
|
|
409
|
+
() => this.sync.close(),
|
|
410
|
+
() => this.restApi?.close(),
|
|
411
|
+
() => this.network.close(),
|
|
412
|
+
() => this.metricsServer?.close(),
|
|
413
|
+
() => this.monitoring?.close(),
|
|
414
|
+
() => this.chain.persistToDisk(),
|
|
415
|
+
() => this.chain.close(),
|
|
405
416
|
// Abort signal last: close() calls above clear intervals/timeouts so no new
|
|
406
417
|
// operations get scheduled. If we aborted first, a still-pending interval could
|
|
407
418
|
// fire and schedule a new operation after abort, leaving it stuck and delaying shutdown.
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
419
|
+
() => this.controller?.abort(),
|
|
420
|
+
() => sleep(DELAY_BEFORE_CLOSING_DB_MS),
|
|
421
|
+
() => this.db.close(),
|
|
422
|
+
]) {
|
|
423
|
+
try {
|
|
424
|
+
await cleanup();
|
|
425
|
+
} catch (error) {
|
|
426
|
+
errors.push(error);
|
|
427
|
+
}
|
|
412
428
|
}
|
|
429
|
+
this.status = BeaconNodeStatus.closed;
|
|
430
|
+
if (errors.length === 1) throw errors[0];
|
|
431
|
+
if (errors.length > 1) throw new AggregateError(errors, "Beacon node cleanup failed");
|
|
413
432
|
}
|
|
414
433
|
}
|