@lodestar/beacon-node 1.49.0-dev.c9061c6942 → 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/blocks/index.js +2 -2
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/beacon/pool/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/pool/index.js +4 -2
- package/lib/api/impl/beacon/pool/index.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +9 -7
- package/lib/api/impl/validator/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 +4 -6
- package/lib/chain/archiveStore/historicalState/metrics.js.map +1 -1
- package/lib/chain/archiveStore/utils/pruneHistory.d.ts.map +1 -1
- package/lib/chain/archiveStore/utils/pruneHistory.js +14 -3
- package/lib/chain/archiveStore/utils/pruneHistory.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/blocks/index.js +2 -2
- package/lib/chain/blocks/index.js.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -1
- package/lib/chain/emitter.d.ts +10 -0
- package/lib/chain/emitter.d.ts.map +1 -1
- package/lib/chain/emitter.js +4 -0
- package/lib/chain/emitter.js.map +1 -1
- package/lib/chain/errors/attesterSlashingError.d.ts +4 -1
- package/lib/chain/errors/attesterSlashingError.d.ts.map +1 -1
- package/lib/chain/errors/attesterSlashingError.js +1 -0
- package/lib/chain/errors/attesterSlashingError.js.map +1 -1
- package/lib/chain/errors/payloadAttestation.d.ts +4 -0
- package/lib/chain/errors/payloadAttestation.d.ts.map +1 -1
- package/lib/chain/errors/payloadAttestation.js +1 -0
- package/lib/chain/errors/payloadAttestation.js.map +1 -1
- package/lib/chain/errors/proposerSlashingError.d.ts +4 -1
- package/lib/chain/errors/proposerSlashingError.d.ts.map +1 -1
- package/lib/chain/errors/proposerSlashingError.js +1 -0
- package/lib/chain/errors/proposerSlashingError.js.map +1 -1
- package/lib/chain/options.d.ts +0 -4
- package/lib/chain/options.d.ts.map +1 -1
- package/lib/chain/options.js +0 -1
- package/lib/chain/options.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/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +6 -6
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +2 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +3 -2
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
- package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
- package/lib/chain/validation/attesterSlashing.js +1 -2
- package/lib/chain/validation/attesterSlashing.js.map +1 -1
- package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
- package/lib/chain/validation/payloadAttestationMessage.js +8 -1
- package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
- package/lib/chain/validation/proposerSlashing.js +1 -2
- package/lib/chain/validation/proposerSlashing.js.map +1 -1
- package/lib/chain/validatorMonitor.d.ts.map +1 -1
- package/lib/chain/validatorMonitor.js +2 -2
- package/lib/chain/validatorMonitor.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/blockArchive.d.ts +5 -0
- package/lib/db/repositories/blockArchive.d.ts.map +1 -1
- package/lib/db/repositories/blockArchive.js +36 -1
- package/lib/db/repositories/blockArchive.js.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 +12 -11
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +25 -23
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/gossip/encoding.d.ts +1 -2
- package/lib/network/gossip/encoding.d.ts.map +1 -1
- package/lib/network/gossip/encoding.js +5 -10
- 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 +16 -1
- package/lib/network/gossip/gossipsub.js.map +1 -1
- package/lib/network/gossip/topic.d.ts +9 -6
- package/lib/network/gossip/topic.d.ts.map +1 -1
- package/lib/network/gossip/topic.js +23 -8
- package/lib/network/gossip/topic.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +16 -5
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/gossipValidatorFn.d.ts +2 -0
- package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
- package/lib/network/processor/gossipValidatorFn.js +88 -7
- package/lib/network/processor/gossipValidatorFn.js.map +1 -1
- package/lib/network/processor/index.d.ts +6 -2
- package/lib/network/processor/index.d.ts.map +1 -1
- package/lib/network/processor/index.js +62 -24
- package/lib/network/processor/index.js.map +1 -1
- package/lib/network/reqresp/protocols.d.ts.map +1 -1
- package/lib/network/reqresp/protocols.js +19 -5
- package/lib/network/reqresp/protocols.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 +21 -2
- package/lib/sync/types.d.ts.map +1 -1
- package/lib/sync/types.js +22 -2
- package/lib/sync/types.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts +20 -0
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +199 -15
- 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/lib/util/sszBytes.d.ts +5 -0
- package/lib/util/sszBytes.d.ts.map +1 -1
- package/lib/util/sszBytes.js +13 -1
- package/lib/util/sszBytes.js.map +1 -1
- package/package.json +15 -16
- package/src/api/impl/beacon/blocks/index.ts +2 -2
- package/src/api/impl/beacon/pool/index.ts +6 -2
- package/src/api/impl/validator/index.ts +9 -7
- package/src/chain/archiveStore/archiveStore.ts +0 -6
- package/src/chain/archiveStore/historicalState/metrics.ts +4 -7
- package/src/chain/archiveStore/utils/pruneHistory.ts +14 -4
- package/src/chain/blocks/importExecutionPayload.ts +14 -0
- package/src/chain/blocks/index.ts +2 -2
- package/src/chain/blocks/payloadEnvelopeInput/types.ts +1 -1
- package/src/chain/emitter.ts +7 -2
- package/src/chain/errors/attesterSlashingError.ts +3 -1
- package/src/chain/errors/payloadAttestation.ts +2 -0
- package/src/chain/errors/proposerSlashingError.ts +3 -1
- package/src/chain/options.ts +0 -5
- package/src/chain/produceBlock/computeNewStateRoot.ts +9 -2
- package/src/chain/produceBlock/produceBlockBody.ts +17 -6
- package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +3 -2
- package/src/chain/validation/attesterSlashing.ts +1 -2
- package/src/chain/validation/payloadAttestationMessage.ts +9 -0
- package/src/chain/validation/proposerSlashing.ts +1 -2
- package/src/chain/validatorMonitor.ts +12 -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/blockArchive.ts +38 -1
- package/src/db/repositories/index.ts +0 -1
- package/src/metrics/metrics/lodestar.ts +34 -26
- package/src/network/gossip/encoding.ts +5 -8
- package/src/network/gossip/gossipsub.ts +19 -2
- package/src/network/gossip/topic.ts +25 -7
- package/src/network/processor/gossipHandlers.ts +18 -5
- package/src/network/processor/gossipValidatorFn.ts +111 -7
- package/src/network/processor/index.ts +81 -24
- package/src/network/reqresp/protocols.ts +31 -6
- 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 +24 -5
- package/src/sync/unknownBlock.ts +207 -14
- package/src/util/shuffle.ts +0 -9
- package/src/util/sszBytes.ts +18 -0
- 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
|
@@ -481,8 +481,8 @@ export function getValidatorApi(
|
|
|
481
481
|
metrics?.blockProductionExecutionPayloadValue.observe({source}, Number(formatWeiToEth(executionPayloadValue)));
|
|
482
482
|
logger.verbose("Produced blinded block", {
|
|
483
483
|
slot,
|
|
484
|
-
executionPayloadValue,
|
|
485
|
-
consensusBlockValue,
|
|
484
|
+
executionPayloadValue: prettyWeiToEth(executionPayloadValue),
|
|
485
|
+
consensusBlockValue: prettyWeiToEth(consensusBlockValue),
|
|
486
486
|
root: toRootHex(config.getPostBellatrixForkTypes(slot).BlindedBeaconBlock.hashTreeRoot(block)),
|
|
487
487
|
});
|
|
488
488
|
|
|
@@ -540,8 +540,8 @@ export function getValidatorApi(
|
|
|
540
540
|
const blockRoot = toRootHex(config.getForkTypes(slot).BeaconBlock.hashTreeRoot(block));
|
|
541
541
|
logger.verbose("Produced execution block", {
|
|
542
542
|
slot,
|
|
543
|
-
executionPayloadValue,
|
|
544
|
-
consensusBlockValue,
|
|
543
|
+
executionPayloadValue: prettyWeiToEth(executionPayloadValue),
|
|
544
|
+
consensusBlockValue: prettyWeiToEth(consensusBlockValue),
|
|
545
545
|
root: blockRoot,
|
|
546
546
|
});
|
|
547
547
|
if (chain.opts.persistProducedBlocks) {
|
|
@@ -1057,6 +1057,8 @@ export function getValidatorApi(
|
|
|
1057
1057
|
rank: index + 1,
|
|
1058
1058
|
source: candidate.url !== undefined ? toPrintableUrl(candidate.url) : "p2p",
|
|
1059
1059
|
builder: candidate.signedBid.message.builderIndex,
|
|
1060
|
+
value: prettyGweiToEth(candidate.signedBid.message.value),
|
|
1061
|
+
executionPayment: prettyGweiToEth(candidate.signedBid.message.executionPayment),
|
|
1060
1062
|
total: prettyGweiToEth(candidate.totalGwei),
|
|
1061
1063
|
boost: candidate.boostFactor,
|
|
1062
1064
|
boosted: prettyGweiToEth(getBoostedTotalScaled(candidate) / 100n),
|
|
@@ -1247,8 +1249,8 @@ export function getValidatorApi(
|
|
|
1247
1249
|
const blockRoot = toRootHex(config.getForkTypes(slot).BeaconBlock.hashTreeRoot(block));
|
|
1248
1250
|
logger.verbose("Produced block", {
|
|
1249
1251
|
...logCtx,
|
|
1250
|
-
executionPayloadValue,
|
|
1251
|
-
consensusBlockValue,
|
|
1252
|
+
executionPayloadValue: prettyWeiToEth(executionPayloadValue),
|
|
1253
|
+
consensusBlockValue: prettyWeiToEth(consensusBlockValue),
|
|
1252
1254
|
root: blockRoot,
|
|
1253
1255
|
});
|
|
1254
1256
|
if (chain.opts.persistProducedBlocks) {
|
|
@@ -2104,7 +2106,7 @@ export function getValidatorApi(
|
|
|
2104
2106
|
auth: entry.auth,
|
|
2105
2107
|
});
|
|
2106
2108
|
} catch (e) {
|
|
2107
|
-
failures.push({index: i, message: (e as Error).message});
|
|
2109
|
+
failures.push({index: i, message: `${builder}: ${(e as Error).message}`});
|
|
2108
2110
|
logger.verbose(
|
|
2109
2111
|
`Error on submitBuilderPreferences [${i}]`,
|
|
2110
2112
|
{slot: entry.auth.message.slot, builder},
|
|
@@ -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",
|
|
@@ -163,6 +156,10 @@ export function createHistoricalStateTransitionMetrics(
|
|
|
163
156
|
name: "lodestar_historical_state_stfn_attestations_per_block_total",
|
|
164
157
|
help: "Count of attestations per block",
|
|
165
158
|
}),
|
|
159
|
+
progressiveBalancesMismatches: metricsRegister.counter({
|
|
160
|
+
name: "lodestar_historical_state_stfn_progressive_balances_mismatches_total",
|
|
161
|
+
help: "Total count of progressive balance cache mismatches",
|
|
162
|
+
}),
|
|
166
163
|
proposerRewards: metricsRegister.gauge<{type: ProposerRewardType}>({
|
|
167
164
|
name: "lodestar_historical_state_stfn_proposer_rewards_total",
|
|
168
165
|
help: "Proposer reward by type per block",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {ChainConfig} from "@lodestar/config";
|
|
2
2
|
import {computeStartSlotAtEpoch} from "@lodestar/state-transition";
|
|
3
3
|
import {Epoch} from "@lodestar/types";
|
|
4
|
-
import {Logger} from "@lodestar/utils";
|
|
4
|
+
import {Logger, prettyPrintIndices} from "@lodestar/utils";
|
|
5
5
|
import {IBeaconDb} from "../../../db/interface.js";
|
|
6
6
|
import {Metrics} from "../../../metrics/index.js";
|
|
7
7
|
|
|
@@ -20,30 +20,40 @@ export async function pruneHistory(
|
|
|
20
20
|
finalizedEpoch
|
|
21
21
|
);
|
|
22
22
|
const blockCutoffSlot = computeStartSlotAtEpoch(blockCutoffEpoch);
|
|
23
|
+
// The latest archived state is the anchor on restart and can trail finalization by a few epochs
|
|
24
|
+
const lastArchivedStateSlot = (await db.stateArchive.lastKey()) ?? 0;
|
|
25
|
+
const stateCutoffSlot = Math.min(computeStartSlotAtEpoch(finalizedEpoch), lastArchivedStateSlot);
|
|
23
26
|
|
|
24
27
|
logger.debug("Preparing to prune history", {
|
|
25
28
|
currentEpoch,
|
|
26
29
|
finalizedEpoch,
|
|
27
30
|
blockCutoffEpoch,
|
|
31
|
+
stateCutoffSlot,
|
|
28
32
|
});
|
|
29
33
|
|
|
30
34
|
const step0 = metrics?.pruneHistory.fetchKeys.startTimer();
|
|
31
|
-
const [blocks, states] = await Promise.all([
|
|
35
|
+
const [blocks, envelopes, states] = await Promise.all([
|
|
32
36
|
db.blockArchive.keys({gte: 0, lt: blockCutoffSlot}),
|
|
33
|
-
db.
|
|
37
|
+
db.executionPayloadEnvelopeArchive.keys({gte: 0, lt: blockCutoffSlot}),
|
|
38
|
+
db.stateArchive.keys({gte: 0, lt: stateCutoffSlot}),
|
|
34
39
|
]);
|
|
35
40
|
step0?.();
|
|
36
41
|
|
|
37
42
|
logger.debug("Pruning history", {
|
|
38
43
|
currentEpoch,
|
|
39
44
|
blocksToPrune: blocks.length,
|
|
45
|
+
envelopesToPrune: envelopes.length,
|
|
40
46
|
statesToPrune: states.length,
|
|
47
|
+
blockSlots: prettyPrintIndices(blocks),
|
|
48
|
+
envelopeSlots: prettyPrintIndices(envelopes),
|
|
49
|
+
stateSlots: prettyPrintIndices(states),
|
|
41
50
|
});
|
|
42
51
|
|
|
43
52
|
const step1 = metrics?.pruneHistory.pruneKeys.startTimer();
|
|
44
53
|
await Promise.all([
|
|
45
54
|
// ->
|
|
46
|
-
db.blockArchive.
|
|
55
|
+
db.blockArchive.batchDeleteRange(blocks),
|
|
56
|
+
db.executionPayloadEnvelopeArchive.batchDelete(envelopes),
|
|
47
57
|
db.stateArchive.batchDelete(states),
|
|
48
58
|
]);
|
|
49
59
|
step1?.();
|
|
@@ -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();
|
|
@@ -104,7 +104,7 @@ export async function processBlocks(
|
|
|
104
104
|
payloadEnvelopesToImport.delete(orphaned.slot);
|
|
105
105
|
// never validated, drop it from the shared cache so it is not served to peers, by-root sync reloads the
|
|
106
106
|
// entry from db if the payload is ever needed
|
|
107
|
-
this.seenPayloadEnvelopeInputCache.
|
|
107
|
+
this.seenPayloadEnvelopeInputCache.remove(orphaned.payloadEnvelopeInput.blockRootHex);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
|
@@ -278,7 +278,7 @@ async function importPayloadEnvelopesOfKnownBlocks(
|
|
|
278
278
|
this.forkChoice.isDescendant(blockRootHex, PayloadStatus.EMPTY, head.blockRoot, head.payloadStatus)
|
|
279
279
|
) {
|
|
280
280
|
// never validated, see processBlocks()
|
|
281
|
-
this.seenPayloadEnvelopeInputCache.
|
|
281
|
+
this.seenPayloadEnvelopeInputCache.remove(blockRootHex);
|
|
282
282
|
orphaned.push({slot, payloadEnvelopeInput: payloadInput});
|
|
283
283
|
continue;
|
|
284
284
|
}
|
|
@@ -23,7 +23,7 @@ export enum PayloadEnvelopeInputSource {
|
|
|
23
23
|
* - prune: explicit prune by root
|
|
24
24
|
* - cap: insertion-order backstop cap (MAX_PAYLOAD_ENVELOPE_INPUT_CACHE_SIZE)
|
|
25
25
|
*/
|
|
26
|
-
export type PayloadEnvelopeInputPruneReason = "belowParent" | "finalized" | "
|
|
26
|
+
export type PayloadEnvelopeInputPruneReason = "belowParent" | "finalized" | "remove" | "cap";
|
|
27
27
|
|
|
28
28
|
export type SourceMeta = {
|
|
29
29
|
source: PayloadEnvelopeInputSource;
|
package/src/chain/emitter.ts
CHANGED
|
@@ -72,6 +72,10 @@ export enum ChainEvent {
|
|
|
72
72
|
* Trigger BlockInputSync to find a SignedExecutionPayloadEnvelope with specified block root.
|
|
73
73
|
*/
|
|
74
74
|
unknownEnvelopeBlockRoot = "unknownEnvelopeBlockRoot",
|
|
75
|
+
/**
|
|
76
|
+
* Same as unknownEnvelopeBlockRoot, but with slot
|
|
77
|
+
*/
|
|
78
|
+
unknownEnvelopeBlockRootSlot = "unknownEnvelopeBlockRootSlot",
|
|
75
79
|
/**
|
|
76
80
|
* Trigger BlockInputSync for blocks that are partially received via gossip but are not complete by time the
|
|
77
81
|
* cut-off window passes for waiting on gossip
|
|
@@ -99,8 +103,8 @@ export type ChainEventData = {
|
|
|
99
103
|
peer: PeerIdStr;
|
|
100
104
|
source: BlockInputSource;
|
|
101
105
|
};
|
|
102
|
-
|
|
103
|
-
[ChainEvent.
|
|
106
|
+
[ChainEvent.unknownEnvelopeBlockRoot]: {rootHex: RootHex; peer?: PeerIdStr; source: BlockInputSource};
|
|
107
|
+
[ChainEvent.unknownEnvelopeBlockRootSlot]: {rootHex: RootHex; slot: Slot; peer?: PeerIdStr; source: BlockInputSource};
|
|
104
108
|
};
|
|
105
109
|
|
|
106
110
|
export type IChainEvents = ApiEvents & {
|
|
@@ -126,6 +130,7 @@ export type IChainEvents = ApiEvents & {
|
|
|
126
130
|
[ChainEvent.incompleteBlockInput]: (data: ChainEventData[ChainEvent.incompleteBlockInput]) => void;
|
|
127
131
|
[ChainEvent.incompletePayloadEnvelope]: (data: ChainEventData[ChainEvent.incompletePayloadEnvelope]) => void;
|
|
128
132
|
[ChainEvent.unknownEnvelopeBlockRoot]: (data: ChainEventData[ChainEvent.unknownEnvelopeBlockRoot]) => void;
|
|
133
|
+
[ChainEvent.unknownEnvelopeBlockRootSlot]: (data: ChainEventData[ChainEvent.unknownEnvelopeBlockRootSlot]) => void;
|
|
129
134
|
};
|
|
130
135
|
|
|
131
136
|
/**
|
|
@@ -3,9 +3,11 @@ import {GossipActionError} from "./gossipValidation.js";
|
|
|
3
3
|
export enum AttesterSlashingErrorCode {
|
|
4
4
|
ALREADY_EXISTS = "ATTESTATION_SLASHING_ERROR_ALREADY_EXISTS",
|
|
5
5
|
INVALID = "ATTESTATION_SLASHING_ERROR_INVALID",
|
|
6
|
+
INVALID_SIGNATURE = "ATTESTATION_SLASHING_ERROR_INVALID_SIGNATURE",
|
|
6
7
|
}
|
|
7
8
|
export type AttesterSlashingErrorType =
|
|
8
9
|
| {code: AttesterSlashingErrorCode.ALREADY_EXISTS}
|
|
9
|
-
| {code: AttesterSlashingErrorCode.INVALID; error: Error}
|
|
10
|
+
| {code: AttesterSlashingErrorCode.INVALID; error: Error}
|
|
11
|
+
| {code: AttesterSlashingErrorCode.INVALID_SIGNATURE};
|
|
10
12
|
|
|
11
13
|
export class AttesterSlashingError extends GossipActionError<AttesterSlashingErrorType> {}
|
|
@@ -6,6 +6,7 @@ export enum PayloadAttestationErrorCode {
|
|
|
6
6
|
PAYLOAD_ATTESTATION_ALREADY_KNOWN = "PAYLOAD_ATTESTATION_ERROR_PAYLOAD_ATTESTATION_ALREADY_KNOWN",
|
|
7
7
|
UNKNOWN_BLOCK_ROOT = "PAYLOAD_ATTESTATION_ERROR_UNKNOWN_BLOCK_ROOT",
|
|
8
8
|
INVALID_BLOCK_SLOT = "PAYLOAD_ATTESTATION_ERROR_INVALID_BLOCK_SLOT",
|
|
9
|
+
PRE_GLOAS_SLOT = "PAYLOAD_ATTESTATION_ERROR_PRE_GLOAS_SLOT",
|
|
9
10
|
INVALID_BLOCK = "PAYLOAD_ATTESTATION_ERROR_INVALID_BLOCK",
|
|
10
11
|
INVALID_ATTESTER = "PAYLOAD_ATTESTATION_ERROR_INVALID_ATTESTER",
|
|
11
12
|
INVALID_SIGNATURE = "PAYLOAD_ATTESTATION_ERROR_INVALID_SIGNATURE",
|
|
@@ -20,6 +21,7 @@ export type PayloadAttestationErrorType =
|
|
|
20
21
|
}
|
|
21
22
|
| {code: PayloadAttestationErrorCode.UNKNOWN_BLOCK_ROOT; blockRoot: RootHex}
|
|
22
23
|
| {code: PayloadAttestationErrorCode.INVALID_BLOCK_SLOT; blockRoot: RootHex; blockSlot: Slot; slot: Slot}
|
|
24
|
+
| {code: PayloadAttestationErrorCode.PRE_GLOAS_SLOT; slot: Slot}
|
|
23
25
|
| {code: PayloadAttestationErrorCode.INVALID_BLOCK; blockRoot: RootHex}
|
|
24
26
|
| {code: PayloadAttestationErrorCode.INVALID_ATTESTER; attesterIndex: ValidatorIndex}
|
|
25
27
|
| {code: PayloadAttestationErrorCode.INVALID_SIGNATURE};
|
|
@@ -3,9 +3,11 @@ import {GossipActionError} from "./gossipValidation.js";
|
|
|
3
3
|
export enum ProposerSlashingErrorCode {
|
|
4
4
|
ALREADY_EXISTS = "PROPOSER_SLASHING_ERROR_ALREADY_EXISTS",
|
|
5
5
|
INVALID = "PROPOSER_SLASHING_ERROR_INVALID",
|
|
6
|
+
INVALID_SIGNATURE = "PROPOSER_SLASHING_ERROR_INVALID_SIGNATURE",
|
|
6
7
|
}
|
|
7
8
|
export type ProposerSlashingErrorType =
|
|
8
9
|
| {code: ProposerSlashingErrorCode.ALREADY_EXISTS}
|
|
9
|
-
| {code: ProposerSlashingErrorCode.INVALID; error: Error}
|
|
10
|
+
| {code: ProposerSlashingErrorCode.INVALID; error: Error}
|
|
11
|
+
| {code: ProposerSlashingErrorCode.INVALID_SIGNATURE};
|
|
10
12
|
|
|
11
13
|
export class ProposerSlashingError extends GossipActionError<ProposerSlashingErrorType> {}
|
package/src/chain/options.ts
CHANGED
|
@@ -63,10 +63,6 @@ export type BlockProcessOpts = {
|
|
|
63
63
|
* Will double processing times. Use only for debugging purposes.
|
|
64
64
|
*/
|
|
65
65
|
disableBlsBatchVerify?: boolean;
|
|
66
|
-
/**
|
|
67
|
-
* Assert progressive balances the same to EpochTransitionCache
|
|
68
|
-
*/
|
|
69
|
-
assertCorrectProgressiveBalances?: boolean;
|
|
70
66
|
/** Used for fork_choice spec tests */
|
|
71
67
|
disableOnBlockError?: boolean;
|
|
72
68
|
/** Used for fork_choice spec tests */
|
|
@@ -114,7 +110,6 @@ export const defaultChainOptions: IChainOptions = {
|
|
|
114
110
|
suggestedFeeRecipient: defaultValidatorOptions.suggestedFeeRecipient,
|
|
115
111
|
graffitiAppend: true,
|
|
116
112
|
serveHistoricalState: false,
|
|
117
|
-
assertCorrectProgressiveBalances: false,
|
|
118
113
|
archiveStateEpochFrequency: 1024,
|
|
119
114
|
archiveMode: DEFAULT_ARCHIVE_MODE,
|
|
120
115
|
pruneHistory: false,
|
|
@@ -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
|
}
|
|
@@ -59,7 +59,18 @@ import {
|
|
|
59
59
|
heze,
|
|
60
60
|
ssz,
|
|
61
61
|
} from "@lodestar/types";
|
|
62
|
-
import {
|
|
62
|
+
import {
|
|
63
|
+
GWEI_TO_WEI,
|
|
64
|
+
Logger,
|
|
65
|
+
byteArrayEquals,
|
|
66
|
+
fromHex,
|
|
67
|
+
prettyGweiToEth,
|
|
68
|
+
prettyWeiToEth,
|
|
69
|
+
sleep,
|
|
70
|
+
toHex,
|
|
71
|
+
toPubkeyHex,
|
|
72
|
+
toRootHex,
|
|
73
|
+
} from "@lodestar/utils";
|
|
63
74
|
import {ZERO_HASH_HEX} from "../../constants/index.js";
|
|
64
75
|
import {numToQuantity} from "../../execution/engine/utils.js";
|
|
65
76
|
import {IExecutionBuilder, IExecutionEngine, PayloadAttributes, PayloadId} from "../../execution/index.js";
|
|
@@ -259,7 +270,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
259
270
|
this.logger.verbose("Produced block with builder bid", {
|
|
260
271
|
slot: blockSlot,
|
|
261
272
|
builderIndex: builderBid.message.builderIndex,
|
|
262
|
-
bidValue: builderBid.message.value,
|
|
273
|
+
bidValue: prettyGweiToEth(builderBid.message.value),
|
|
263
274
|
parentBlockHash: toRootHex(builderBid.message.parentBlockHash),
|
|
264
275
|
parentBlockRoot: toRootHex(builderBid.message.parentBlockRoot),
|
|
265
276
|
blockHash: toRootHex(builderBid.message.blockHash),
|
|
@@ -410,7 +421,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
410
421
|
this.metrics?.blockPayload.payloadFetchedTime.observe({prepType}, fetchedTime);
|
|
411
422
|
this.logger.verbose("Produced block with self-build bid", {
|
|
412
423
|
slot: blockSlot,
|
|
413
|
-
executionPayloadValue,
|
|
424
|
+
executionPayloadValue: prettyWeiToEth(executionPayloadValue),
|
|
414
425
|
prepType,
|
|
415
426
|
payloadId,
|
|
416
427
|
fetchedTime,
|
|
@@ -490,7 +501,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
490
501
|
this.metrics?.blockPayload.payloadFetchedTime.observe({prepType}, fetchedTime);
|
|
491
502
|
this.logger.verbose("Fetched execution payload header from builder", {
|
|
492
503
|
slot: blockSlot,
|
|
493
|
-
executionPayloadValue,
|
|
504
|
+
executionPayloadValue: prettyWeiToEth(executionPayloadValue),
|
|
494
505
|
prepType,
|
|
495
506
|
fetchedTime,
|
|
496
507
|
});
|
|
@@ -607,7 +618,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
607
618
|
this.metrics?.blockPayload.payloadFetchedTime.observe({prepType}, fetchedTime);
|
|
608
619
|
this.logger.verbose("Fetched execution payload from engine", {
|
|
609
620
|
slot: blockSlot,
|
|
610
|
-
executionPayloadValue,
|
|
621
|
+
executionPayloadValue: prettyWeiToEth(executionPayloadValue),
|
|
611
622
|
prepType,
|
|
612
623
|
payloadId,
|
|
613
624
|
fetchedTime,
|
|
@@ -708,7 +719,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
708
719
|
}
|
|
709
720
|
}
|
|
710
721
|
|
|
711
|
-
Object.assign(logMeta, {executionPayloadValue});
|
|
722
|
+
Object.assign(logMeta, {executionPayloadValue: prettyWeiToEth(executionPayloadValue)});
|
|
712
723
|
this.logger.verbose("Produced beacon block body", logMeta);
|
|
713
724
|
|
|
714
725
|
return {body: blockBody as AssembledBodyType<T>, produceResult, executionPayloadValue, shouldOverrideBuilder};
|
|
@@ -256,10 +256,11 @@ export class SeenPayloadEnvelopeInput {
|
|
|
256
256
|
return this.payloadInputs.size;
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
-
|
|
259
|
+
/** Removes the single PayloadEnvelopeInput from the cache */
|
|
260
|
+
remove(blockRootHex: RootHex): void {
|
|
260
261
|
const input = this.payloadInputs.get(blockRootHex);
|
|
261
262
|
if (input) {
|
|
262
|
-
this.evictPayloadInput(input, "
|
|
263
|
+
this.evictPayloadInput(input, "remove");
|
|
263
264
|
}
|
|
264
265
|
}
|
|
265
266
|
|
|
@@ -63,8 +63,7 @@ export async function validateAttesterSlashing(
|
|
|
63
63
|
const signatureSets = getAttesterSlashingSignatureSets(chain.config, state.slot, attesterSlashing);
|
|
64
64
|
if (!(await chain.bls.verifySignatureSets(signatureSets, {batchable: true, priority: prioritizeBls}))) {
|
|
65
65
|
throw new AttesterSlashingError(GossipAction.REJECT, {
|
|
66
|
-
code: AttesterSlashingErrorCode.
|
|
67
|
-
error: Error("Invalid signature"),
|
|
66
|
+
code: AttesterSlashingErrorCode.INVALID_SIGNATURE,
|
|
68
67
|
});
|
|
69
68
|
}
|
|
70
69
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
computeEpochAtSlot,
|
|
2
3
|
createIndexedSignatureSetFromComponents,
|
|
3
4
|
getPayloadAttestationDataSigningRoot,
|
|
4
5
|
isStatePostGloas,
|
|
@@ -35,6 +36,14 @@ async function validatePayloadAttestationMessage(
|
|
|
35
36
|
): Promise<PayloadAttestationValidationResult> {
|
|
36
37
|
const {data, validatorIndex} = payloadAttestationMessage;
|
|
37
38
|
|
|
39
|
+
// [REJECT] The payload attestation slot is at or after the Gloas fork.
|
|
40
|
+
if (computeEpochAtSlot(data.slot) < chain.config.GLOAS_FORK_EPOCH) {
|
|
41
|
+
throw new PayloadAttestationError(GossipAction.REJECT, {
|
|
42
|
+
code: PayloadAttestationErrorCode.PRE_GLOAS_SLOT,
|
|
43
|
+
slot: data.slot,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
38
47
|
// [IGNORE] The message's slot is for the current slot (with a `MAXIMUM_GOSSIP_CLOCK_DISPARITY` allowance), i.e. `data.slot == current_slot`.
|
|
39
48
|
if (!chain.clock.isCurrentSlotGivenGossipDisparity(data.slot)) {
|
|
40
49
|
throw new PayloadAttestationError(GossipAction.IGNORE, {
|
|
@@ -48,8 +48,7 @@ async function validateProposerSlashing(
|
|
|
48
48
|
const signatureSets = getProposerSlashingSignatureSets(chain.config, state.slot, proposerSlashing);
|
|
49
49
|
if (!(await chain.bls.verifySignatureSets(signatureSets, {batchable: true, priority: prioritizeBls}))) {
|
|
50
50
|
throw new ProposerSlashingError(GossipAction.REJECT, {
|
|
51
|
-
code: ProposerSlashingErrorCode.
|
|
52
|
-
error: Error("Invalid signature"),
|
|
51
|
+
code: ProposerSlashingErrorCode.INVALID_SIGNATURE,
|
|
53
52
|
});
|
|
54
53
|
}
|
|
55
54
|
}
|
|
@@ -24,7 +24,17 @@ import {
|
|
|
24
24
|
deneb,
|
|
25
25
|
gloas,
|
|
26
26
|
} from "@lodestar/types";
|
|
27
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
LogData,
|
|
29
|
+
LogHandler,
|
|
30
|
+
LogLevel,
|
|
31
|
+
Logger,
|
|
32
|
+
MapDef,
|
|
33
|
+
MapDefMax,
|
|
34
|
+
prettyGweiToEth,
|
|
35
|
+
prettyPrintIndices,
|
|
36
|
+
toRootHex,
|
|
37
|
+
} from "@lodestar/utils";
|
|
28
38
|
import {GENESIS_SLOT} from "../constants/constants.js";
|
|
29
39
|
import {RegistryMetricCreator} from "../metrics/index.js";
|
|
30
40
|
|
|
@@ -470,7 +480,7 @@ export function createValidatorMonitor(
|
|
|
470
480
|
src,
|
|
471
481
|
builderIndex: bid.builderIndex,
|
|
472
482
|
gasLimit: Number(bid.gasLimit),
|
|
473
|
-
value: bid.value
|
|
483
|
+
value: prettyGweiToEth(bid.value),
|
|
474
484
|
parentBlockRoot: toRootHex(bid.parentBlockRoot),
|
|
475
485
|
parentBlockHash: toRootHex(bid.parentBlockHash),
|
|
476
486
|
blockHash: toRootHex(bid.blockHash),
|
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,8 +1,9 @@
|
|
|
1
1
|
import {ChainForkConfig} from "@lodestar/config";
|
|
2
2
|
import {Db, DbBatch, FilterOptions, KeyValue, Repository} from "@lodestar/db";
|
|
3
3
|
import {Root, SignedBeaconBlock, Slot, ssz} from "@lodestar/types";
|
|
4
|
-
import {bytesToInt, intToBytes} from "@lodestar/utils";
|
|
4
|
+
import {bytesToInt, fromHex, intToBytes} from "@lodestar/utils";
|
|
5
5
|
import {getSignedBlockTypeFromBytes} from "../../util/multifork.js";
|
|
6
|
+
import {getParentRootFromSignedBeaconBlockSerialized} from "../../util/sszBytes.js";
|
|
6
7
|
import {Bucket, getBucketNameByValue} from "../buckets.js";
|
|
7
8
|
import {
|
|
8
9
|
deleteParentRootIndex,
|
|
@@ -24,6 +25,10 @@ export type BlockArchiveBatchPutBinaryItem = KeyValue<Slot, Uint8Array> & {
|
|
|
24
25
|
parentRoot: Root;
|
|
25
26
|
};
|
|
26
27
|
|
|
28
|
+
// The initial prune can span millions of slots. This bounds the slot index reads in flight and keeps each
|
|
29
|
+
// delete batch at a few thousand keys, both tiny next to the block value batches in archiveBlocks
|
|
30
|
+
const DELETE_RANGE_CHUNK_SIZE = 1000;
|
|
31
|
+
|
|
27
32
|
/**
|
|
28
33
|
* Stores finalized blocks. Block slot is identifier.
|
|
29
34
|
*/
|
|
@@ -103,6 +108,38 @@ export class BlockArchiveRepository extends Repository<Slot, SignedBeaconBlock>
|
|
|
103
108
|
);
|
|
104
109
|
}
|
|
105
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Delete a contiguous range of archived blocks together with their index entries.
|
|
113
|
+
* `slots` must be every archived slot in the range, so the parent of each block is the entry before it.
|
|
114
|
+
*/
|
|
115
|
+
async batchDeleteRange(slots: Slot[]): Promise<void> {
|
|
116
|
+
const sorted = [...slots].sort((a, b) => a - b);
|
|
117
|
+
let prevRoot: Root | null = null;
|
|
118
|
+
|
|
119
|
+
for (let i = 0; i < sorted.length; i += DELETE_RANGE_CHUNK_SIZE) {
|
|
120
|
+
const chunk = sorted.slice(i, i + DELETE_RANGE_CHUNK_SIZE);
|
|
121
|
+
const roots = await Promise.all(chunk.map((slot) => this.getRootBySlot(slot)));
|
|
122
|
+
|
|
123
|
+
const keys: Uint8Array[] = [];
|
|
124
|
+
for (let j = 0; j < chunk.length; j++) {
|
|
125
|
+
keys.push(this.encodeKey(chunk[j]), getSlotIndexKey(chunk[j]));
|
|
126
|
+
const root = roots[j];
|
|
127
|
+
if (root) keys.push(getRootIndexKey(root));
|
|
128
|
+
// The parent index entry pointing at this block is keyed by its parent root, which is the
|
|
129
|
+
// previous block's root unless that block is unindexed, then it is read from the block itself
|
|
130
|
+
let parentRoot = prevRoot;
|
|
131
|
+
if (parentRoot === null) {
|
|
132
|
+
const block = await this.getBinary(chunk[j]);
|
|
133
|
+
const parentRootHex = block ? getParentRootFromSignedBeaconBlockSerialized(block) : null;
|
|
134
|
+
parentRoot = parentRootHex ? fromHex(parentRootHex) : null;
|
|
135
|
+
}
|
|
136
|
+
if (parentRoot) keys.push(getParentRootIndexKey(parentRoot));
|
|
137
|
+
prevRoot = root;
|
|
138
|
+
}
|
|
139
|
+
await this.db.batchDelete(keys, this.dbReqOpts);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
106
143
|
async batch(operations: DbBatch<Slot, SignedBeaconBlock>): Promise<void> {
|
|
107
144
|
await this.batchBinary(
|
|
108
145
|
operations.map((operation) =>
|
|
@@ -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";
|