@lodestar/beacon-node 1.49.0-dev.c9d60c8080 → 1.49.0-dev.ca7e252e95
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/pool/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/pool/index.js +4 -2
- package/lib/api/impl/beacon/pool/index.js.map +1 -1
- package/lib/chain/archiveStore/archiveStore.d.ts +1 -2
- package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
- package/lib/chain/archiveStore/archiveStore.js +0 -5
- package/lib/chain/archiveStore/archiveStore.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/metrics.d.ts.map +1 -1
- package/lib/chain/archiveStore/historicalState/metrics.js +0 -6
- package/lib/chain/archiveStore/historicalState/metrics.js.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +13 -0
- package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
- package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
- package/lib/chain/produceBlock/computeNewStateRoot.js +4 -2
- package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
- package/lib/db/beacon.d.ts +1 -2
- package/lib/db/beacon.d.ts.map +1 -1
- package/lib/db/beacon.js +1 -3
- package/lib/db/beacon.js.map +1 -1
- package/lib/db/buckets.d.ts +0 -1
- package/lib/db/buckets.d.ts.map +1 -1
- package/lib/db/buckets.js +1 -1
- package/lib/db/buckets.js.map +1 -1
- package/lib/db/interface.d.ts +1 -2
- package/lib/db/interface.d.ts.map +1 -1
- package/lib/db/repositories/blockArchiveIndex.d.ts +2 -2
- package/lib/db/repositories/blockArchiveIndex.d.ts.map +1 -1
- package/lib/db/repositories/index.d.ts +0 -1
- package/lib/db/repositories/index.d.ts.map +1 -1
- package/lib/db/repositories/index.js +0 -1
- package/lib/db/repositories/index.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +7 -10
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +15 -23
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/node/nodejs.d.ts +2 -7
- package/lib/node/nodejs.d.ts.map +1 -1
- package/lib/node/nodejs.js +2 -22
- package/lib/node/nodejs.js.map +1 -1
- package/lib/sync/interface.d.ts +1 -2
- package/lib/sync/interface.d.ts.map +1 -1
- package/lib/sync/options.d.ts +0 -6
- package/lib/sync/options.d.ts.map +1 -1
- package/lib/sync/options.js +0 -2
- package/lib/sync/options.js.map +1 -1
- package/lib/sync/types.d.ts +0 -2
- package/lib/sync/types.d.ts.map +1 -1
- package/lib/sync/types.js +0 -2
- package/lib/sync/types.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +41 -13
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/util/shuffle.d.ts +0 -4
- package/lib/util/shuffle.d.ts.map +1 -1
- package/lib/util/shuffle.js +0 -8
- package/lib/util/shuffle.js.map +1 -1
- package/package.json +15 -16
- package/src/api/impl/beacon/pool/index.ts +6 -2
- package/src/chain/archiveStore/archiveStore.ts +0 -6
- package/src/chain/archiveStore/historicalState/metrics.ts +0 -7
- package/src/chain/blocks/importExecutionPayload.ts +14 -0
- package/src/chain/produceBlock/computeNewStateRoot.ts +9 -2
- package/src/db/beacon.ts +0 -5
- package/src/db/buckets.ts +1 -1
- package/src/db/interface.ts +0 -3
- package/src/db/repositories/index.ts +0 -1
- package/src/metrics/metrics/lodestar.ts +17 -25
- package/src/node/nodejs.ts +0 -27
- package/src/sync/interface.ts +1 -2
- package/src/sync/options.ts +0 -8
- package/src/sync/types.ts +0 -2
- package/src/sync/unknownBlock.ts +41 -13
- package/src/util/shuffle.ts +0 -9
- package/lib/chain/archiveStore/utils/updateBackfillRange.d.ts +0 -20
- package/lib/chain/archiveStore/utils/updateBackfillRange.d.ts.map +0 -1
- package/lib/chain/archiveStore/utils/updateBackfillRange.js +0 -40
- package/lib/chain/archiveStore/utils/updateBackfillRange.js.map +0 -1
- package/lib/db/repositories/backfilledRanges.d.ts +0 -18
- package/lib/db/repositories/backfilledRanges.d.ts.map +0 -1
- package/lib/db/repositories/backfilledRanges.js +0 -26
- package/lib/db/repositories/backfilledRanges.js.map +0 -1
- package/lib/sync/backfill/backfill.d.ts +0 -169
- package/lib/sync/backfill/backfill.d.ts.map +0 -1
- package/lib/sync/backfill/backfill.js +0 -686
- package/lib/sync/backfill/backfill.js.map +0 -1
- package/lib/sync/backfill/errors.d.ts +0 -30
- package/lib/sync/backfill/errors.d.ts.map +0 -1
- package/lib/sync/backfill/errors.js +0 -15
- package/lib/sync/backfill/errors.js.map +0 -1
- package/lib/sync/backfill/index.d.ts +0 -2
- package/lib/sync/backfill/index.d.ts.map +0 -1
- package/lib/sync/backfill/index.js +0 -2
- package/lib/sync/backfill/index.js.map +0 -1
- package/lib/sync/backfill/verify.d.ts +0 -18
- package/lib/sync/backfill/verify.d.ts.map +0 -1
- package/lib/sync/backfill/verify.js +0 -36
- package/lib/sync/backfill/verify.js.map +0 -1
- package/src/chain/archiveStore/utils/updateBackfillRange.ts +0 -50
- package/src/db/repositories/backfilledRanges.ts +0 -29
- package/src/sync/backfill/backfill.ts +0 -916
- package/src/sync/backfill/errors.ts +0 -23
- package/src/sync/backfill/index.ts +0 -1
- package/src/sync/backfill/verify.ts +0 -58
package/lib/util/shuffle.d.ts
CHANGED
|
@@ -3,8 +3,4 @@
|
|
|
3
3
|
* Note: Uses Math.random() as entropy source, use for non-critical stuff
|
|
4
4
|
*/
|
|
5
5
|
export declare function shuffle<T>(arr: T[]): T[];
|
|
6
|
-
/**
|
|
7
|
-
* Return one random item from array
|
|
8
|
-
*/
|
|
9
|
-
export declare function shuffleOne<T>(arr: T[]): T | undefined;
|
|
10
6
|
//# sourceMappingURL=shuffle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shuffle.d.ts","sourceRoot":"","sources":["../../src/util/shuffle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAOxC
|
|
1
|
+
{"version":3,"file":"shuffle.d.ts","sourceRoot":"","sources":["../../src/util/shuffle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAOxC"}
|
package/lib/util/shuffle.js
CHANGED
|
@@ -10,12 +10,4 @@ export function shuffle(arr) {
|
|
|
10
10
|
}
|
|
11
11
|
return _arr;
|
|
12
12
|
}
|
|
13
|
-
/**
|
|
14
|
-
* Return one random item from array
|
|
15
|
-
*/
|
|
16
|
-
export function shuffleOne(arr) {
|
|
17
|
-
if (arr.length === 0)
|
|
18
|
-
return undefined;
|
|
19
|
-
return arr[Math.floor(Math.random() * arr.length)];
|
|
20
|
-
}
|
|
21
13
|
//# sourceMappingURL=shuffle.js.map
|
package/lib/util/shuffle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shuffle.js","sourceRoot":"","sources":["../../src/util/shuffle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAI,GAAQ;IACjC,MAAM,IAAI,GAAQ,CAAC,GAAG,GAAG,CAAC,CAAC;IAC3B,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC9C,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC
|
|
1
|
+
{"version":3,"file":"shuffle.js","sourceRoot":"","sources":["../../src/util/shuffle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAI,GAAQ;IACjC,MAAM,IAAI,GAAQ,CAAC,GAAG,GAAG,CAAC,CAAC;IAC3B,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC9C,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,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.49.0-dev.
|
|
14
|
+
"version": "1.49.0-dev.ca7e252e95",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"@fastify/swagger-ui": "^5.0.1",
|
|
119
119
|
"@libp2p/bootstrap": "^12.0.30",
|
|
120
120
|
"@libp2p/crypto": "^5.1.23",
|
|
121
|
-
"@libp2p/gossipsub": "^17.1.
|
|
121
|
+
"@libp2p/gossipsub": "^17.1.2",
|
|
122
122
|
"@libp2p/identify": "^4.1.13",
|
|
123
123
|
"@libp2p/interface": "^3.3.0",
|
|
124
124
|
"@libp2p/mdns": "^12.0.30",
|
|
@@ -127,17 +127,17 @@
|
|
|
127
127
|
"@libp2p/prometheus-metrics": "^5.0.28",
|
|
128
128
|
"@libp2p/tcp": "^11.0.27",
|
|
129
129
|
"@libp2p/utils": "^7.4.0",
|
|
130
|
-
"@lodestar/api": "^1.49.0-dev.
|
|
131
|
-
"@lodestar/config": "^1.49.0-dev.
|
|
132
|
-
"@lodestar/db": "^1.49.0-dev.
|
|
133
|
-
"@lodestar/fork-choice": "^1.49.0-dev.
|
|
134
|
-
"@lodestar/logger": "^1.49.0-dev.
|
|
135
|
-
"@lodestar/params": "^1.49.0-dev.
|
|
136
|
-
"@lodestar/reqresp": "^1.49.0-dev.
|
|
137
|
-
"@lodestar/state-transition": "^1.49.0-dev.
|
|
138
|
-
"@lodestar/types": "^1.49.0-dev.
|
|
139
|
-
"@lodestar/utils": "^1.49.0-dev.
|
|
140
|
-
"@lodestar/validator": "^1.49.0-dev.
|
|
130
|
+
"@lodestar/api": "^1.49.0-dev.ca7e252e95",
|
|
131
|
+
"@lodestar/config": "^1.49.0-dev.ca7e252e95",
|
|
132
|
+
"@lodestar/db": "^1.49.0-dev.ca7e252e95",
|
|
133
|
+
"@lodestar/fork-choice": "^1.49.0-dev.ca7e252e95",
|
|
134
|
+
"@lodestar/logger": "^1.49.0-dev.ca7e252e95",
|
|
135
|
+
"@lodestar/params": "^1.49.0-dev.ca7e252e95",
|
|
136
|
+
"@lodestar/reqresp": "^1.49.0-dev.ca7e252e95",
|
|
137
|
+
"@lodestar/state-transition": "^1.49.0-dev.ca7e252e95",
|
|
138
|
+
"@lodestar/types": "^1.49.0-dev.ca7e252e95",
|
|
139
|
+
"@lodestar/utils": "^1.49.0-dev.ca7e252e95",
|
|
140
|
+
"@lodestar/validator": "^1.49.0-dev.ca7e252e95",
|
|
141
141
|
"@multiformats/multiaddr": "^13.0.1",
|
|
142
142
|
"datastore-core": "^12.0.1",
|
|
143
143
|
"datastore-level": "^13.0.1",
|
|
@@ -156,10 +156,9 @@
|
|
|
156
156
|
"xxhash-wasm": "1.0.2"
|
|
157
157
|
},
|
|
158
158
|
"devDependencies": {
|
|
159
|
-
"@chainsafe/swap-or-not-shuffle": "^1.2.1",
|
|
160
159
|
"@libp2p/interface-internal": "^3.1.12",
|
|
161
160
|
"@libp2p/logger": "^6.2.13",
|
|
162
|
-
"@lodestar/spec-test-util": "^1.49.0-dev.
|
|
161
|
+
"@lodestar/spec-test-util": "^1.49.0-dev.ca7e252e95",
|
|
163
162
|
"@types/js-yaml": "^4.0.5",
|
|
164
163
|
"@types/qs": "^6.9.7",
|
|
165
164
|
"@types/tmp": "^0.2.3",
|
|
@@ -174,5 +173,5 @@
|
|
|
174
173
|
"beacon",
|
|
175
174
|
"blockchain"
|
|
176
175
|
],
|
|
177
|
-
"gitHead": "
|
|
176
|
+
"gitHead": "10f249ab17c86e49e05bdac0f2541c43ed70c0d7"
|
|
178
177
|
}
|
|
@@ -39,7 +39,7 @@ export function getBeaconPoolApi({
|
|
|
39
39
|
return {
|
|
40
40
|
async getPoolAttestationsV2({slot, committeeIndex}) {
|
|
41
41
|
// Already filtered by slot
|
|
42
|
-
let attestations = chain.aggregatedAttestationPool.getAll(slot);
|
|
42
|
+
let attestations = [...chain.aggregatedAttestationPool.getAll(slot), ...chain.attestationPool.getAll(slot)];
|
|
43
43
|
const fork = chain.config.getForkName(slot ?? attestations[0]?.data.slot ?? chain.clock.currentSlot);
|
|
44
44
|
const isPostElectra = isForkPostElectra(fork);
|
|
45
45
|
|
|
@@ -48,7 +48,11 @@ export function getBeaconPoolApi({
|
|
|
48
48
|
);
|
|
49
49
|
|
|
50
50
|
if (committeeIndex !== undefined) {
|
|
51
|
-
attestations = attestations.filter((attestation) =>
|
|
51
|
+
attestations = attestations.filter((attestation) =>
|
|
52
|
+
isElectraAttestation(attestation)
|
|
53
|
+
? attestation.committeeBits.get(committeeIndex)
|
|
54
|
+
: committeeIndex === attestation.data.index
|
|
55
|
+
);
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
return {data: attestations, meta: {version: fork}};
|
|
@@ -16,7 +16,6 @@ import {ArchiveMode, ArchiveStoreOpts, StateArchiveStrategy} from "./interface.j
|
|
|
16
16
|
import {FrequencyStateArchiveStrategy} from "./strategies/frequencyStateArchiveStrategy.js";
|
|
17
17
|
import {archiveBlocks} from "./utils/archiveBlocks.js";
|
|
18
18
|
import {pruneHistory} from "./utils/pruneHistory.js";
|
|
19
|
-
import {updateBackfillRange} from "./utils/updateBackfillRange.js";
|
|
20
19
|
|
|
21
20
|
type ArchiveStoreModules = {
|
|
22
21
|
chain: IBeaconChain;
|
|
@@ -37,7 +36,6 @@ export enum ArchiveStoreTask {
|
|
|
37
36
|
OnFinalizedCheckpoint = "on_finalized_checkpoint",
|
|
38
37
|
MaybeArchiveState = "maybe_archive_state",
|
|
39
38
|
ForkchoicePrune = "forkchoice_prune",
|
|
40
|
-
UpdateBackfillRange = "update_backfill_range",
|
|
41
39
|
}
|
|
42
40
|
|
|
43
41
|
/**
|
|
@@ -261,10 +259,6 @@ export class ArchiveStore {
|
|
|
261
259
|
const prunedBlocks = this.chain.forkChoice.prune(finalized.rootHex);
|
|
262
260
|
timer?.({source: ArchiveStoreTask.ForkchoicePrune});
|
|
263
261
|
|
|
264
|
-
timer = this.metrics?.processFinalizedCheckpoint.durationByTask.startTimer();
|
|
265
|
-
await updateBackfillRange({chain: this.chain, db: this.db, logger: this.logger}, finalized);
|
|
266
|
-
timer?.({source: ArchiveStoreTask.UpdateBackfillRange});
|
|
267
|
-
|
|
268
262
|
this.logger.verbose("Finish processing finalized checkpoint", {
|
|
269
263
|
epoch: finalizedEpoch,
|
|
270
264
|
rootHex: finalized.rootHex,
|
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
ProcessOperationsStep,
|
|
7
7
|
ProposerRewardType,
|
|
8
8
|
StateCloneSource,
|
|
9
|
-
StateHashTreeRootSource,
|
|
10
9
|
} from "@lodestar/state-transition";
|
|
11
10
|
import {Gauge, Histogram} from "@lodestar/utils";
|
|
12
11
|
import {RegistryMetricCreator} from "../../../metrics/index.js";
|
|
@@ -92,12 +91,6 @@ export function createHistoricalStateTransitionMetrics(
|
|
|
92
91
|
help: "Time to call commit after process a single block in seconds",
|
|
93
92
|
buckets: [0.005, 0.01, 0.02, 0.05, 0.1, 1],
|
|
94
93
|
}),
|
|
95
|
-
stateHashTreeRootTime: metricsRegister.histogram<{source: StateHashTreeRootSource}>({
|
|
96
|
-
name: "lodestar_historical_state_stfn_hash_tree_root_seconds",
|
|
97
|
-
help: "Time to compute the hash tree root of a post state in seconds",
|
|
98
|
-
buckets: [0.05, 0.1, 0.2, 0.5, 1, 1.5],
|
|
99
|
-
labelNames: ["source"],
|
|
100
|
-
}),
|
|
101
94
|
numEffectiveBalanceUpdates: metricsRegister.gauge({
|
|
102
95
|
name: "lodestar_historical_state_stfn_num_effective_balance_updates_count",
|
|
103
96
|
help: "Count of effective balance updates in epoch transition",
|
|
@@ -12,6 +12,7 @@ import {isQueueErrorAborted} from "../../util/queue/index.js";
|
|
|
12
12
|
import {BeaconChain} from "../chain.js";
|
|
13
13
|
import {RegenCaller} from "../regen/interface.js";
|
|
14
14
|
import {PayloadEnvelopeInput} from "../seenCache/seenPayloadEnvelopeInput.js";
|
|
15
|
+
import {PayloadEnvelopeInputSource} from "./payloadEnvelopeInput/index.js";
|
|
15
16
|
import {ImportPayloadOpts} from "./types.js";
|
|
16
17
|
import {
|
|
17
18
|
verifyExecutionPayloadEnvelope,
|
|
@@ -172,6 +173,9 @@ export async function importExecutionPayload(
|
|
|
172
173
|
}
|
|
173
174
|
|
|
174
175
|
// 4a. Run EL and signature verification in parallel
|
|
176
|
+
const logCtx = {slot, root: blockRootHex, executionBlock: envelope.payload.blockNumber};
|
|
177
|
+
this.logger.debug("Call engine api newPayload", logCtx);
|
|
178
|
+
const verifyStartSec = Date.now() / 1000;
|
|
175
179
|
const [execResult, signatureValid] = await Promise.all([
|
|
176
180
|
this.executionEngine.notifyNewPayload(
|
|
177
181
|
fork,
|
|
@@ -191,6 +195,8 @@ export async function importExecutionPayload(
|
|
|
191
195
|
this.bls
|
|
192
196
|
),
|
|
193
197
|
]);
|
|
198
|
+
this.logger.debug("Receive engine api newPayload result", {...logCtx, status: execResult.status});
|
|
199
|
+
this.metrics?.engineNotifyNewPayloadResult.inc({result: execResult.status});
|
|
194
200
|
|
|
195
201
|
// 4b. Check signature verification result
|
|
196
202
|
if (!signatureValid) {
|
|
@@ -223,6 +229,14 @@ export async function importExecutionPayload(
|
|
|
223
229
|
});
|
|
224
230
|
}
|
|
225
231
|
|
|
232
|
+
const {source, seenTimestampSec} = payloadInput.getPayloadEnvelopeSource();
|
|
233
|
+
if (execResult.status === ExecutionPayloadStatus.VALID && source === PayloadEnvelopeInputSource.gossip) {
|
|
234
|
+
const nowSec = Date.now() / 1000;
|
|
235
|
+
this.metrics?.gossipExecutionPayloadEnvelope.executionPayload.recvToValidation.observe(nowSec - seenTimestampSec);
|
|
236
|
+
// same metric as pre-gloas, it tracks EL verification time regardless of fork
|
|
237
|
+
this.metrics?.gossipBlock.executionPayload.validationTime.observe(nowSec - verifyStartSec);
|
|
238
|
+
}
|
|
239
|
+
|
|
226
240
|
// 5. Persist payload envelope to hot DB. Wait for write-queue space here to apply backpressure
|
|
227
241
|
// on the import pipeline during sync, then perform the write asynchronously to avoid blocking.
|
|
228
242
|
await this.unfinalizedPayloadEnvelopeWrites.waitForSpace();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {EMPTY_SIGNATURE, IBeaconStateView} from "@lodestar/state-transition";
|
|
1
|
+
import {EMPTY_SIGNATURE, IBeaconStateView, StateHashTreeRootSource} from "@lodestar/state-transition";
|
|
2
2
|
import {BeaconBlock, BlindedBeaconBlock, Gwei, Root} from "@lodestar/types";
|
|
3
3
|
import {Metrics} from "../../metrics/index.js";
|
|
4
4
|
|
|
@@ -14,5 +14,12 @@ export function computeNewStateRoot(
|
|
|
14
14
|
): {newStateRoot: Root; proposerReward: Gwei; postState: IBeaconStateView} {
|
|
15
15
|
// Set signature to zero to re-use stateTransition() function which requires the SignedBeaconBlock type
|
|
16
16
|
const signedBlock = {message: block, signature: EMPTY_SIGNATURE};
|
|
17
|
-
|
|
17
|
+
const {newStateRoot, proposerReward, postState, hashTreeRootTime} = state.computeNewStateRoot(
|
|
18
|
+
{block: signedBlock},
|
|
19
|
+
{metrics}
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
metrics?.stateHashTreeRootTime.observe({source: StateHashTreeRootSource.computeNewStateRoot}, hashTreeRootTime);
|
|
23
|
+
|
|
24
|
+
return {newStateRoot, proposerReward, postState};
|
|
18
25
|
}
|
package/src/db/beacon.ts
CHANGED
|
@@ -11,7 +11,6 @@ import {CheckpointStateRepository} from "./repositories/checkpointState.js";
|
|
|
11
11
|
import {
|
|
12
12
|
AttesterSlashingRepository,
|
|
13
13
|
BLSToExecutionChangeRepository,
|
|
14
|
-
BackfilledRanges,
|
|
15
14
|
BestLightClientUpdateRepository,
|
|
16
15
|
BlobSidecarsArchiveRepository,
|
|
17
16
|
BlobSidecarsRepository,
|
|
@@ -61,8 +60,6 @@ export class BeaconDb implements IBeaconDb {
|
|
|
61
60
|
syncCommittee: SyncCommitteeRepository;
|
|
62
61
|
syncCommitteeWitness: SyncCommitteeWitnessRepository;
|
|
63
62
|
|
|
64
|
-
backfilledRanges: BackfilledRanges;
|
|
65
|
-
|
|
66
63
|
readonly dataColumns: IDataColumnStore;
|
|
67
64
|
lastLegacyArchiveSlot: Slot | null = null;
|
|
68
65
|
private readonly flatFileStore: FlatFileStore;
|
|
@@ -97,8 +94,6 @@ export class BeaconDb implements IBeaconDb {
|
|
|
97
94
|
this.syncCommittee = new SyncCommitteeRepository(config, db);
|
|
98
95
|
this.syncCommitteeWitness = new SyncCommitteeWitnessRepository(config, db);
|
|
99
96
|
|
|
100
|
-
this.backfilledRanges = new BackfilledRanges(config, db);
|
|
101
|
-
|
|
102
97
|
this.flatFileStore = new FlatFileStore(opts.dataColumnDir, config, opts.logger, opts.metrics);
|
|
103
98
|
this.dataColumns = new LegacyDataColumnStore(
|
|
104
99
|
this.flatFileStore,
|
package/src/db/buckets.ts
CHANGED
|
@@ -56,7 +56,7 @@ export enum Bucket {
|
|
|
56
56
|
// altair_lightClientSyncCommitteeProof = 35, // DEPRECATED on v0.32.0
|
|
57
57
|
// index_lightClientInitProof = 36, // DEPRECATED on v0.32.0
|
|
58
58
|
|
|
59
|
-
backfilled_ranges = 42, //
|
|
59
|
+
// backfilled_ranges = 42, // DEPRECATED on v1.48.0
|
|
60
60
|
|
|
61
61
|
// Buckets to support LightClient server v2
|
|
62
62
|
lightClient_syncCommitteeWitness = 51, // BlockRoot -> SyncCommitteeWitness
|
package/src/db/interface.ts
CHANGED
|
@@ -6,7 +6,6 @@ import {CheckpointStateRepository} from "./repositories/checkpointState.js";
|
|
|
6
6
|
import {
|
|
7
7
|
AttesterSlashingRepository,
|
|
8
8
|
BLSToExecutionChangeRepository,
|
|
9
|
-
BackfilledRanges,
|
|
10
9
|
BestLightClientUpdateRepository,
|
|
11
10
|
BlobSidecarsArchiveRepository,
|
|
12
11
|
BlobSidecarsRepository,
|
|
@@ -60,8 +59,6 @@ export interface IBeaconDb {
|
|
|
60
59
|
syncCommittee: SyncCommitteeRepository;
|
|
61
60
|
syncCommitteeWitness: SyncCommitteeWitnessRepository;
|
|
62
61
|
|
|
63
|
-
backfilledRanges: BackfilledRanges;
|
|
64
|
-
|
|
65
62
|
dataColumns: IDataColumnStore;
|
|
66
63
|
/** Highest legacy column slot at startup; later archival writes the block-root index first. */
|
|
67
64
|
readonly lastLegacyArchiveSlot: Slot | null;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export {AttesterSlashingRepository} from "./attesterSlashing.js";
|
|
2
|
-
export {BackfilledRanges} from "./backfilledRanges.js";
|
|
3
2
|
export {BlobSidecarsRepository} from "./blobSidecars.js";
|
|
4
3
|
export {BlobSidecarsArchiveRepository} from "./blobSidecarsArchive.js";
|
|
5
4
|
export {BlockRepository} from "./block.js";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** biome-ignore-all lint/suspicious/noTemplateCurlyInString: The metric templates requires to have `${}` in a normal string */
|
|
2
2
|
import {NotReorgedReason} from "@lodestar/fork-choice";
|
|
3
|
+
import {StateHashTreeRootSource} from "@lodestar/state-transition";
|
|
3
4
|
import {ArchiveStoreTask} from "../../chain/archiveStore/archiveStore.js";
|
|
4
5
|
import {FrequencyStateArchiveStep} from "../../chain/archiveStore/strategies/frequencyStateArchiveStrategy.js";
|
|
5
6
|
import type {LateCanonicalBlockReason} from "../../chain/archiveStore/utils/archiveBlocks.js";
|
|
@@ -25,7 +26,6 @@ import type {FlatFileStoreOperation} from "../../db/flatFileStore/metrics.js";
|
|
|
25
26
|
import {ExecutionPayloadStatus} from "../../execution/index.js";
|
|
26
27
|
import {GossipType} from "../../network/index.js";
|
|
27
28
|
import {CannotAcceptWorkReason, ReprocessRejectReason} from "../../network/processor/index.js";
|
|
28
|
-
import {BackfillSyncMethod} from "../../sync/backfill/backfill.js";
|
|
29
29
|
import {
|
|
30
30
|
DeferredPayloadResult,
|
|
31
31
|
DownloadResult,
|
|
@@ -409,6 +409,15 @@ export function createLodestarMetrics(
|
|
|
409
409
|
labelNames: ["caller"],
|
|
410
410
|
}),
|
|
411
411
|
|
|
412
|
+
// this metrics stay here instead of @lodestar/state-transition in order to prepare
|
|
413
|
+
// for the native zig state-transition in the future
|
|
414
|
+
stateHashTreeRootTime: register.histogram<{source: StateHashTreeRootSource}>({
|
|
415
|
+
name: "lodestar_stfn_hash_tree_root_seconds",
|
|
416
|
+
help: "Time to compute the hash tree root of a post state in seconds",
|
|
417
|
+
buckets: [0.01, 0.05, 0.1, 0.2, 0.3, 0.5],
|
|
418
|
+
labelNames: ["source"],
|
|
419
|
+
}),
|
|
420
|
+
|
|
412
421
|
// BLS verifier thread pool and queue
|
|
413
422
|
|
|
414
423
|
bls: {
|
|
@@ -1002,6 +1011,13 @@ export function createLodestarMetrics(
|
|
|
1002
1011
|
help: "Count of errors, by error type, while processing execution payload envelopes",
|
|
1003
1012
|
labelNames: ["error"],
|
|
1004
1013
|
}),
|
|
1014
|
+
executionPayload: {
|
|
1015
|
+
recvToValidation: register.histogram({
|
|
1016
|
+
name: "lodestar_gossip_execution_payload_envelope_received_to_execution_payload_verification_seconds",
|
|
1017
|
+
help: "Time elapsed between execution payload envelope received and execution payload verification",
|
|
1018
|
+
buckets: [0.05, 0.1, 0.25, 0.5, 1, 2, 3, 4, 6, 8],
|
|
1019
|
+
}),
|
|
1020
|
+
},
|
|
1005
1021
|
},
|
|
1006
1022
|
gossipExecutionPayloadBid: {
|
|
1007
1023
|
elapsedTimeTillReceived: register.histogram<{source: OpSource}>({
|
|
@@ -1136,30 +1152,6 @@ export function createLodestarMetrics(
|
|
|
1136
1152
|
help: "The total result of calling notifyForkchoiceUpdate execution engine api",
|
|
1137
1153
|
labelNames: ["result"],
|
|
1138
1154
|
}),
|
|
1139
|
-
backfillSync: {
|
|
1140
|
-
backfilledTillSlot: register.gauge({
|
|
1141
|
-
name: "lodestar_backfill_till_slot",
|
|
1142
|
-
help: "Current lowest backfilled slot",
|
|
1143
|
-
}),
|
|
1144
|
-
prevFinOrWsSlot: register.gauge({
|
|
1145
|
-
name: "lodestar_backfill_prev_fin_or_ws_slot",
|
|
1146
|
-
help: "Slot of previous finalized or wsCheckpoint block to be validated",
|
|
1147
|
-
}),
|
|
1148
|
-
totalBlocks: register.gauge<{method: BackfillSyncMethod}>({
|
|
1149
|
-
name: "lodestar_backfill_sync_blocks_total",
|
|
1150
|
-
help: "Total amount of backfilled blocks",
|
|
1151
|
-
labelNames: ["method"],
|
|
1152
|
-
}),
|
|
1153
|
-
errors: register.gauge({
|
|
1154
|
-
name: "lodestar_backfill_sync_errors_total",
|
|
1155
|
-
help: "Total number of errors while backfilling",
|
|
1156
|
-
}),
|
|
1157
|
-
status: register.gauge({
|
|
1158
|
-
name: "lodestar_backfill_sync_status",
|
|
1159
|
-
help: "Current backfill syncing status: [Aborted, Pending, Syncing, Completed]",
|
|
1160
|
-
}),
|
|
1161
|
-
},
|
|
1162
|
-
|
|
1163
1155
|
opPool: {
|
|
1164
1156
|
aggregatedAttestationPool: {
|
|
1165
1157
|
size: register.gauge({
|
package/src/node/nodejs.ts
CHANGED
|
@@ -8,7 +8,6 @@ import {BeaconConfig} from "@lodestar/config";
|
|
|
8
8
|
import type {LoggerNode} from "@lodestar/logger/node";
|
|
9
9
|
import {ZERO_HASH_HEX} from "@lodestar/params";
|
|
10
10
|
import {IBeaconStateView, isStatePostBellatrix, isStatePostGloas} from "@lodestar/state-transition";
|
|
11
|
-
import {phase0} from "@lodestar/types";
|
|
12
11
|
import {sleep, toRootHex} from "@lodestar/utils";
|
|
13
12
|
import {ProcessShutdownCallback} from "@lodestar/validator";
|
|
14
13
|
import {BeaconRestApiServer, getApi} from "../api/index.js";
|
|
@@ -19,7 +18,6 @@ import {initializeExecutionBuilder, initializeExecutionEngine} from "../executio
|
|
|
19
18
|
import {HttpMetricsServer, Metrics, createMetrics, getHttpMetricsServer} from "../metrics/index.js";
|
|
20
19
|
import {MonitoringService} from "../monitoring/index.js";
|
|
21
20
|
import {Network, getReqRespHandlers} from "../network/index.js";
|
|
22
|
-
import {BackfillSync} from "../sync/backfill/index.js";
|
|
23
21
|
import {BeaconSync, IBeaconSync} from "../sync/index.js";
|
|
24
22
|
import {Clock} from "../util/clock.js";
|
|
25
23
|
import {startDeferredVoluntaryExitPublisher} from "./deferredVoluntaryExitPublisher.js";
|
|
@@ -38,7 +36,6 @@ export type BeaconNodeModules = {
|
|
|
38
36
|
chain: IBeaconChain;
|
|
39
37
|
api: BeaconApiMethods;
|
|
40
38
|
sync: IBeaconSync;
|
|
41
|
-
backfillSync: BackfillSync | null;
|
|
42
39
|
metricsServer: HttpMetricsServer | null;
|
|
43
40
|
monitoring: MonitoringService | null;
|
|
44
41
|
restApi?: BeaconRestApiServer;
|
|
@@ -58,7 +55,6 @@ export type BeaconNodeInitModules = {
|
|
|
58
55
|
peerStoreDir?: string;
|
|
59
56
|
anchorState: IBeaconStateView;
|
|
60
57
|
isAnchorStateFinalized: boolean;
|
|
61
|
-
wsCheckpoint?: phase0.Checkpoint;
|
|
62
58
|
metricsRegistries?: Registry[];
|
|
63
59
|
};
|
|
64
60
|
|
|
@@ -70,7 +66,6 @@ export enum BeaconNodeStatus {
|
|
|
70
66
|
|
|
71
67
|
enum LoggerModule {
|
|
72
68
|
api = "api",
|
|
73
|
-
backfill = "backfill",
|
|
74
69
|
chain = "chain",
|
|
75
70
|
execution = "execution",
|
|
76
71
|
metrics = "metrics",
|
|
@@ -105,7 +100,6 @@ export class BeaconNode {
|
|
|
105
100
|
api: BeaconApiMethods;
|
|
106
101
|
restApi?: BeaconRestApiServer;
|
|
107
102
|
sync: IBeaconSync;
|
|
108
|
-
backfillSync: BackfillSync | null;
|
|
109
103
|
|
|
110
104
|
status: BeaconNodeStatus;
|
|
111
105
|
private controller?: AbortController;
|
|
@@ -123,7 +117,6 @@ export class BeaconNode {
|
|
|
123
117
|
api,
|
|
124
118
|
restApi,
|
|
125
119
|
sync,
|
|
126
|
-
backfillSync,
|
|
127
120
|
controller,
|
|
128
121
|
}: BeaconNodeModules) {
|
|
129
122
|
this.opts = opts;
|
|
@@ -138,7 +131,6 @@ export class BeaconNode {
|
|
|
138
131
|
this.restApi = restApi;
|
|
139
132
|
this.network = network;
|
|
140
133
|
this.sync = sync;
|
|
141
|
-
this.backfillSync = backfillSync;
|
|
142
134
|
this.controller = controller;
|
|
143
135
|
|
|
144
136
|
this.status = BeaconNodeStatus.started;
|
|
@@ -161,7 +153,6 @@ export class BeaconNode {
|
|
|
161
153
|
peerStoreDir,
|
|
162
154
|
anchorState,
|
|
163
155
|
isAnchorStateFinalized,
|
|
164
|
-
wsCheckpoint,
|
|
165
156
|
metricsRegistries = [],
|
|
166
157
|
}: BeaconNodeInitModules): Promise<T> {
|
|
167
158
|
if (hasher.name !== "hashtree") {
|
|
@@ -295,25 +286,9 @@ export class BeaconNode {
|
|
|
295
286
|
chain,
|
|
296
287
|
metrics,
|
|
297
288
|
network,
|
|
298
|
-
wsCheckpoint,
|
|
299
289
|
logger: logger.child({module: LoggerModule.sync}),
|
|
300
290
|
});
|
|
301
291
|
|
|
302
|
-
const backfillSync =
|
|
303
|
-
opts.sync.backfillBatchSize > 0
|
|
304
|
-
? await BackfillSync.init(opts.sync, {
|
|
305
|
-
config,
|
|
306
|
-
db,
|
|
307
|
-
chain,
|
|
308
|
-
metrics,
|
|
309
|
-
network,
|
|
310
|
-
wsCheckpoint,
|
|
311
|
-
anchorState,
|
|
312
|
-
logger: logger.child({module: LoggerModule.backfill}),
|
|
313
|
-
signal,
|
|
314
|
-
})
|
|
315
|
-
: null;
|
|
316
|
-
|
|
317
292
|
const api = getApi(opts.api, {
|
|
318
293
|
config,
|
|
319
294
|
logger: logger.child({module: LoggerModule.api}),
|
|
@@ -361,7 +336,6 @@ export class BeaconNode {
|
|
|
361
336
|
api,
|
|
362
337
|
restApi,
|
|
363
338
|
sync,
|
|
364
|
-
backfillSync,
|
|
365
339
|
controller,
|
|
366
340
|
}) as T;
|
|
367
341
|
}
|
|
@@ -373,7 +347,6 @@ export class BeaconNode {
|
|
|
373
347
|
if (this.status === BeaconNodeStatus.started) {
|
|
374
348
|
this.status = BeaconNodeStatus.closing;
|
|
375
349
|
this.sync.close();
|
|
376
|
-
this.backfillSync?.close();
|
|
377
350
|
if (this.restApi) await this.restApi.close();
|
|
378
351
|
await this.network.close();
|
|
379
352
|
if (this.metricsServer) await this.metricsServer.close();
|
package/src/sync/interface.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {routes} from "@lodestar/api";
|
|
2
2
|
import {BeaconConfig} from "@lodestar/config";
|
|
3
|
-
import {Slot
|
|
3
|
+
import {Slot} from "@lodestar/types";
|
|
4
4
|
import {Logger} from "@lodestar/utils";
|
|
5
5
|
import {IBeaconChain} from "../chain/index.js";
|
|
6
6
|
import {IBeaconDb} from "../db/index.js";
|
|
@@ -51,5 +51,4 @@ export interface SyncModules {
|
|
|
51
51
|
metrics: Metrics | null;
|
|
52
52
|
logger: Logger;
|
|
53
53
|
chain: IBeaconChain;
|
|
54
|
-
wsCheckpoint?: phase0.Checkpoint;
|
|
55
54
|
}
|
package/src/sync/options.ts
CHANGED
|
@@ -16,12 +16,6 @@ export type SyncOptions = {
|
|
|
16
16
|
disableRangeSync?: boolean;
|
|
17
17
|
/** USE FOR TESTING ONLY. Disable unknown block sync completely */
|
|
18
18
|
disableBlockInputSync?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* The batch size of slots for backfill sync can attempt to sync/process before yielding
|
|
21
|
-
* to sync loop. This number can be increased or decreased to make a suitable resource
|
|
22
|
-
* allocation to backfill sync. The default of 0 would mean backfill sync will be skipped
|
|
23
|
-
*/
|
|
24
|
-
backfillBatchSize: number;
|
|
25
19
|
/** For testing only, MAX_PENDING_BLOCKS by default */
|
|
26
20
|
maxPendingBlocks?: number;
|
|
27
21
|
|
|
@@ -39,7 +33,5 @@ export type SyncOptions = {
|
|
|
39
33
|
export const defaultSyncOptions: SyncOptions = {
|
|
40
34
|
isSingleNode: false,
|
|
41
35
|
disableProcessAsChainSegment: false,
|
|
42
|
-
/** By default skip the backfill sync */
|
|
43
|
-
backfillBatchSize: 0,
|
|
44
36
|
slotImportTolerance: SLOTS_PER_EPOCH,
|
|
45
37
|
};
|
package/src/sync/types.ts
CHANGED
|
@@ -105,8 +105,6 @@ export enum DroppedItemReason {
|
|
|
105
105
|
invalidEnvelope = "invalid_envelope",
|
|
106
106
|
/** a payload had an invalid signature (INVALID_SIGNATURE) */
|
|
107
107
|
invalidSignature = "invalid_signature",
|
|
108
|
-
/** a block root was given up on after exhausting download attempts (data could not be fetched) */
|
|
109
|
-
unavailable = "unavailable",
|
|
110
108
|
/** an unexpected / unhandled error code led to removal */
|
|
111
109
|
unknown = "unknown",
|
|
112
110
|
}
|
package/src/sync/unknownBlock.ts
CHANGED
|
@@ -227,8 +227,11 @@ export class BlockInputSync {
|
|
|
227
227
|
private onUnknownBlockRoot = (data: ChainEventData[ChainEvent.unknownBlockRoot]): void => {
|
|
228
228
|
try {
|
|
229
229
|
const isNewRoot = this.addByRootHex(data.rootHex, data.peer);
|
|
230
|
-
|
|
230
|
+
// A retained entry (an earlier download failed, #10018) is not new but still needs a retry pass.
|
|
231
|
+
if (this.pendingBlocks.get(data.rootHex)?.status === PendingBlockInputStatus.pending) {
|
|
231
232
|
this.triggerUnknownBlockSearch();
|
|
233
|
+
}
|
|
234
|
+
if (isNewRoot) {
|
|
232
235
|
this.metrics?.blockInputSync.requests.inc({type: PendingBlockType.UNKNOWN_BLOCK_ROOT});
|
|
233
236
|
this.metrics?.blockInputSync.source.inc({source: data.source});
|
|
234
237
|
}
|
|
@@ -393,12 +396,21 @@ export class BlockInputSync {
|
|
|
393
396
|
}
|
|
394
397
|
}
|
|
395
398
|
|
|
396
|
-
let
|
|
399
|
+
let belowFinalizedBlocks = 0;
|
|
400
|
+
let agedOutBlocks = 0;
|
|
397
401
|
for (const [rootHex, block] of this.pendingBlocks) {
|
|
398
402
|
const slot = getBlockInputSyncCacheItemSlot(block);
|
|
399
|
-
if (typeof slot
|
|
403
|
+
if (typeof slot !== "number") {
|
|
404
|
+
// we may not be able to download a root, hence there is no slot for it
|
|
405
|
+
if (nowSec - block.timeAddedSec > maxSecInCache) {
|
|
406
|
+
this.pendingBlocks.delete(rootHex);
|
|
407
|
+
agedOutBlocks++;
|
|
408
|
+
}
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
if (slot < finalizedSlot) {
|
|
400
412
|
this.pendingBlocks.delete(rootHex);
|
|
401
|
-
|
|
413
|
+
belowFinalizedBlocks++;
|
|
402
414
|
}
|
|
403
415
|
}
|
|
404
416
|
|
|
@@ -411,16 +423,20 @@ export class BlockInputSync {
|
|
|
411
423
|
if (agedOutPayloads > 0) {
|
|
412
424
|
this.metrics?.blockInputSync.removedPayloads.inc({reason: DroppedItemReason.agedOut}, agedOutPayloads);
|
|
413
425
|
}
|
|
414
|
-
if (
|
|
415
|
-
this.metrics?.blockInputSync.removedBlocks.inc({reason: DroppedItemReason.belowFinalized},
|
|
426
|
+
if (belowFinalizedBlocks > 0) {
|
|
427
|
+
this.metrics?.blockInputSync.removedBlocks.inc({reason: DroppedItemReason.belowFinalized}, belowFinalizedBlocks);
|
|
428
|
+
}
|
|
429
|
+
if (agedOutBlocks > 0) {
|
|
430
|
+
this.metrics?.blockInputSync.removedBlocks.inc({reason: DroppedItemReason.agedOut}, agedOutBlocks);
|
|
416
431
|
}
|
|
417
432
|
|
|
418
|
-
this.logger.debug("BlockInputSync.pruneFinalized dropped
|
|
433
|
+
this.logger.debug("BlockInputSync.pruneFinalized dropped stale pending items", {
|
|
419
434
|
finalizedSlot,
|
|
420
435
|
finalizedRoot: checkpoint.rootHex,
|
|
421
436
|
belowFinalizedPayloads,
|
|
422
437
|
agedOutPayloads,
|
|
423
|
-
|
|
438
|
+
belowFinalizedBlocks,
|
|
439
|
+
agedOutBlocks,
|
|
424
440
|
unresolvedSlotPayloads,
|
|
425
441
|
});
|
|
426
442
|
};
|
|
@@ -973,7 +989,12 @@ export class BlockInputSync {
|
|
|
973
989
|
if (!res.err) {
|
|
974
990
|
this.metrics?.blockInputSync.downloadedBlocksSuccess.inc();
|
|
975
991
|
const pending = res.result;
|
|
976
|
-
this
|
|
992
|
+
// pruning may have deleted this entry while we were awaiting the network, do not resurrect it via the set below
|
|
993
|
+
if (!this.pendingBlocks.has(rootHex)) {
|
|
994
|
+
this.logger.verbose("Dropping downloaded block, entry pruned during fetch", logCtx);
|
|
995
|
+
return;
|
|
996
|
+
}
|
|
997
|
+
this.pendingBlocks.set(rootHex, pending);
|
|
977
998
|
const blockSlot = pending.blockInput.slot;
|
|
978
999
|
const finalizedSlot = this.chain.forkChoice.getFinalizedBlock().slot;
|
|
979
1000
|
const delaySec = Date.now() / 1000 - computeTimeAtSlot(this.config, blockSlot, this.chain.genesisTime);
|
|
@@ -1035,8 +1056,11 @@ export class BlockInputSync {
|
|
|
1035
1056
|
}
|
|
1036
1057
|
|
|
1037
1058
|
this.metrics?.blockInputSync.downloadedBlocksError.inc();
|
|
1038
|
-
this.logger.debug("
|
|
1039
|
-
this.
|
|
1059
|
+
this.logger.debug("Failed to download unknown block root, retained for retry", logCtx, res.err);
|
|
1060
|
+
const pendingBlock = this.pendingBlocks.get(rootHex);
|
|
1061
|
+
if (pendingBlock && pendingBlock.status === PendingBlockInputStatus.fetching) {
|
|
1062
|
+
pendingBlock.status = PendingBlockInputStatus.pending;
|
|
1063
|
+
}
|
|
1040
1064
|
}
|
|
1041
1065
|
}
|
|
1042
1066
|
|
|
@@ -1303,7 +1327,7 @@ export class BlockInputSync {
|
|
|
1303
1327
|
}
|
|
1304
1328
|
|
|
1305
1329
|
this.metrics?.blockInputSync.downloadedPayloadsResult.inc({result: DownloadResult.Failed});
|
|
1306
|
-
this.logger.debug("
|
|
1330
|
+
this.logger.debug("Failed to download unknown payload root, retained for retry", logCtx, res.err);
|
|
1307
1331
|
if (!isPendingPayloadEnvelope(payload)) {
|
|
1308
1332
|
payload.status = PendingPayloadInputStatus.pending;
|
|
1309
1333
|
}
|
|
@@ -1763,7 +1787,11 @@ export class BlockInputSync {
|
|
|
1763
1787
|
this.peerBalancer.onRequestCompleted(peerId);
|
|
1764
1788
|
}
|
|
1765
1789
|
|
|
1766
|
-
|
|
1790
|
+
const cacheItemRootHex = getBlockInputSyncCacheItemRootHex(cacheItem);
|
|
1791
|
+
// pruning may have dropped it mid-fetch
|
|
1792
|
+
if (this.pendingBlocks.has(cacheItemRootHex)) {
|
|
1793
|
+
this.pendingBlocks.set(cacheItemRootHex, cacheItem);
|
|
1794
|
+
}
|
|
1767
1795
|
|
|
1768
1796
|
if (cacheItem.status === PendingBlockInputStatus.downloaded) {
|
|
1769
1797
|
// download was successful, no need to go with another peer, return
|
package/src/util/shuffle.ts
CHANGED
|
@@ -10,12 +10,3 @@ export function shuffle<T>(arr: T[]): T[] {
|
|
|
10
10
|
}
|
|
11
11
|
return _arr;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Return one random item from array
|
|
16
|
-
*/
|
|
17
|
-
export function shuffleOne<T>(arr: T[]): T | undefined {
|
|
18
|
-
if (arr.length === 0) return undefined;
|
|
19
|
-
|
|
20
|
-
return arr[Math.floor(Math.random() * arr.length)];
|
|
21
|
-
}
|