@lodestar/beacon-node 1.42.0 → 1.43.0-dev.07875b3e0c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/blocks/index.js +21 -4
- 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 -0
- package/lib/api/impl/beacon/pool/index.js.map +1 -1
- package/lib/api/impl/beacon/state/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/state/index.js +13 -10
- package/lib/api/impl/beacon/state/index.js.map +1 -1
- package/lib/api/impl/beacon/state/utils.d.ts +2 -2
- package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
- package/lib/api/impl/beacon/state/utils.js.map +1 -1
- package/lib/api/impl/lodestar/attesterSlashing.d.ts +8 -0
- package/lib/api/impl/lodestar/attesterSlashing.d.ts.map +1 -0
- package/lib/api/impl/lodestar/attesterSlashing.js +29 -0
- package/lib/api/impl/lodestar/attesterSlashing.js.map +1 -0
- package/lib/api/impl/lodestar/index.d.ts.map +1 -1
- package/lib/api/impl/lodestar/index.js +39 -0
- package/lib/api/impl/lodestar/index.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +8 -5
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/GetBlobsTracker.d.ts +1 -1
- package/lib/chain/GetBlobsTracker.d.ts.map +1 -1
- package/lib/chain/GetBlobsTracker.js +1 -2
- package/lib/chain/GetBlobsTracker.js.map +1 -1
- package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
- package/lib/chain/archiveStore/archiveStore.js.map +1 -1
- package/lib/chain/archiveStore/interface.d.ts +4 -4
- package/lib/chain/archiveStore/interface.d.ts.map +1 -1
- package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.d.ts +4 -4
- package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.d.ts.map +1 -1
- package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.js +2 -4
- package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.js.map +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.d.ts +2 -2
- package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.js +110 -58
- package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
- package/lib/chain/blocks/importBlock.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.js +29 -35
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts +15 -14
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +69 -82
- package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
- package/lib/chain/blocks/index.d.ts.map +1 -1
- package/lib/chain/blocks/index.js +1 -2
- package/lib/chain/blocks/index.js.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +3 -0
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +20 -0
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts +5 -0
- package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeProcessor.js +6 -4
- package/lib/chain/blocks/payloadEnvelopeProcessor.js.map +1 -1
- package/lib/chain/blocks/types.d.ts +15 -21
- package/lib/chain/blocks/types.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +3 -2
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksSignatures.js +4 -2
- package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
- package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts +24 -0
- package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts.map +1 -0
- package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js +76 -0
- package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js.map +1 -0
- package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts +14 -0
- package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts.map +1 -0
- package/lib/chain/blocks/verifyPayloadsDataAvailability.js +25 -0
- package/lib/chain/blocks/verifyPayloadsDataAvailability.js.map +1 -0
- package/lib/chain/blocks/writePayloadEnvelopeInputToDb.d.ts +1 -1
- package/lib/chain/blocks/writePayloadEnvelopeInputToDb.d.ts.map +1 -1
- package/lib/chain/blocks/writePayloadEnvelopeInputToDb.js +2 -11
- package/lib/chain/blocks/writePayloadEnvelopeInputToDb.js.map +1 -1
- package/lib/chain/chain.d.ts +5 -4
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +32 -38
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/emitter.d.ts +16 -4
- package/lib/chain/emitter.d.ts.map +1 -1
- package/lib/chain/emitter.js +5 -0
- package/lib/chain/emitter.js.map +1 -1
- package/lib/chain/errors/attestationError.d.ts +8 -1
- package/lib/chain/errors/attestationError.d.ts.map +1 -1
- package/lib/chain/errors/attestationError.js +4 -0
- package/lib/chain/errors/attestationError.js.map +1 -1
- package/lib/chain/errors/blockError.d.ts +11 -1
- package/lib/chain/errors/blockError.d.ts.map +1 -1
- package/lib/chain/errors/blockError.js +4 -0
- package/lib/chain/errors/blockError.js.map +1 -1
- package/lib/chain/errors/executionPayloadBid.d.ts +5 -0
- package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadBid.js +1 -0
- package/lib/chain/errors/executionPayloadBid.js.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.d.ts +5 -0
- package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.js +1 -0
- package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
- package/lib/chain/forkChoice/index.d.ts.map +1 -1
- package/lib/chain/forkChoice/index.js +21 -23
- package/lib/chain/forkChoice/index.js.map +1 -1
- package/lib/chain/interface.d.ts +4 -3
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/interface.js.map +1 -1
- package/lib/chain/lightClient/index.d.ts +2 -2
- package/lib/chain/lightClient/index.d.ts.map +1 -1
- package/lib/chain/lightClient/index.js +7 -0
- package/lib/chain/lightClient/index.js.map +1 -1
- package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
- package/lib/chain/opPools/aggregatedAttestationPool.js +5 -2
- package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
- package/lib/chain/opPools/executionPayloadBidPool.d.ts +2 -2
- package/lib/chain/opPools/executionPayloadBidPool.d.ts.map +1 -1
- package/lib/chain/opPools/executionPayloadBidPool.js +2 -2
- package/lib/chain/opPools/executionPayloadBidPool.js.map +1 -1
- package/lib/chain/prepareNextSlot.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +32 -11
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/computeNewStateRoot.d.ts +1 -7
- package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
- package/lib/chain/produceBlock/computeNewStateRoot.js +1 -28
- package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +5 -10
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +49 -19
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/regen/errors.d.ts +1 -11
- package/lib/chain/regen/errors.d.ts.map +1 -1
- package/lib/chain/regen/errors.js +0 -2
- package/lib/chain/regen/errors.js.map +1 -1
- package/lib/chain/regen/interface.d.ts +6 -12
- package/lib/chain/regen/interface.d.ts.map +1 -1
- package/lib/chain/regen/queued.d.ts +6 -11
- package/lib/chain/regen/queued.d.ts.map +1 -1
- package/lib/chain/regen/queued.js +8 -40
- package/lib/chain/regen/queued.js.map +1 -1
- package/lib/chain/regen/regen.d.ts +0 -5
- package/lib/chain/regen/regen.d.ts.map +1 -1
- package/lib/chain/regen/regen.js +7 -34
- package/lib/chain/regen/regen.js.map +1 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +11 -4
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +20 -18
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
- package/lib/chain/stateCache/datastore/db.d.ts +5 -4
- package/lib/chain/stateCache/datastore/db.d.ts.map +1 -1
- package/lib/chain/stateCache/datastore/db.js +10 -32
- package/lib/chain/stateCache/datastore/db.js.map +1 -1
- package/lib/chain/stateCache/datastore/file.d.ts +1 -1
- package/lib/chain/stateCache/datastore/file.d.ts.map +1 -1
- package/lib/chain/stateCache/datastore/file.js +5 -5
- package/lib/chain/stateCache/datastore/file.js.map +1 -1
- package/lib/chain/stateCache/datastore/types.d.ts +1 -1
- package/lib/chain/stateCache/datastore/types.d.ts.map +1 -1
- package/lib/chain/stateCache/fifoBlockStateCache.d.ts +1 -7
- package/lib/chain/stateCache/fifoBlockStateCache.d.ts.map +1 -1
- package/lib/chain/stateCache/fifoBlockStateCache.js +0 -8
- package/lib/chain/stateCache/fifoBlockStateCache.js.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +13 -30
- package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.js +120 -216
- package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
- package/lib/chain/stateCache/types.d.ts +8 -15
- package/lib/chain/stateCache/types.d.ts.map +1 -1
- package/lib/chain/stateCache/types.js.map +1 -1
- package/lib/chain/validation/aggregateAndProof.js +12 -0
- package/lib/chain/validation/aggregateAndProof.js.map +1 -1
- package/lib/chain/validation/attestation.d.ts.map +1 -1
- package/lib/chain/validation/attestation.js +12 -0
- package/lib/chain/validation/attestation.js.map +1 -1
- package/lib/chain/validation/block.d.ts.map +1 -1
- package/lib/chain/validation/block.js +27 -5
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/validation/executionPayloadBid.js +19 -4
- package/lib/chain/validation/executionPayloadBid.js.map +1 -1
- package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/validation/executionPayloadEnvelope.js +27 -12
- package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
- package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
- package/lib/chain/validation/payloadAttestationMessage.js +8 -4
- package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
- package/lib/chain/validation/syncCommittee.d.ts.map +1 -1
- package/lib/chain/validation/syncCommittee.js +4 -0
- package/lib/chain/validation/syncCommittee.js.map +1 -1
- package/lib/chain/validation/syncCommitteeContributionAndProof.js +4 -1
- package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
- package/lib/chain/validatorMonitor.d.ts.map +1 -1
- package/lib/chain/validatorMonitor.js +3 -3
- package/lib/chain/validatorMonitor.js.map +1 -1
- package/lib/db/repositories/executionPayloadEnvelopeArchive.js +1 -1
- package/lib/db/repositories/executionPayloadEnvelopeArchive.js.map +1 -1
- package/lib/execution/engine/http.d.ts.map +1 -1
- package/lib/execution/engine/http.js +21 -14
- package/lib/execution/engine/http.js.map +1 -1
- package/lib/execution/engine/interface.d.ts +1 -0
- package/lib/execution/engine/interface.d.ts.map +1 -1
- package/lib/execution/engine/mock.d.ts.map +1 -1
- package/lib/execution/engine/mock.js +6 -0
- package/lib/execution/engine/mock.js.map +1 -1
- package/lib/execution/engine/types.d.ts +20 -0
- package/lib/execution/engine/types.d.ts.map +1 -1
- package/lib/execution/engine/types.js +18 -0
- package/lib/execution/engine/types.js.map +1 -1
- package/lib/network/gossip/topic.d.ts +3 -729
- package/lib/network/gossip/topic.d.ts.map +1 -1
- package/lib/network/network.js +1 -1
- package/lib/network/network.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +26 -6
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/beaconBlocksByRange.js +2 -1
- package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/beaconBlocksByRoot.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/beaconBlocksByRoot.js +2 -0
- package/lib/network/reqresp/handlers/beaconBlocksByRoot.js.map +1 -1
- package/lib/network/reqresp/handlers/blobSidecarsByRange.d.ts +2 -2
- package/lib/network/reqresp/handlers/blobSidecarsByRange.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/blobSidecarsByRange.js +7 -3
- package/lib/network/reqresp/handlers/blobSidecarsByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/blobSidecarsByRoot.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/blobSidecarsByRoot.js +6 -0
- package/lib/network/reqresp/handlers/blobSidecarsByRoot.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts +2 -2
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +7 -3
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +2 -1
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js +3 -8
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js.map +1 -1
- package/lib/node/nodejs.d.ts.map +1 -1
- package/lib/node/nodejs.js +6 -1
- package/lib/node/nodejs.js.map +1 -1
- package/lib/node/notifier.d.ts.map +1 -1
- package/lib/node/notifier.js +2 -2
- package/lib/node/notifier.js.map +1 -1
- package/lib/util/sszBytes.d.ts.map +1 -1
- package/lib/util/sszBytes.js +16 -3
- package/lib/util/sszBytes.js.map +1 -1
- package/package.json +16 -16
- package/src/api/impl/beacon/blocks/index.ts +30 -4
- package/src/api/impl/beacon/pool/index.ts +4 -0
- package/src/api/impl/beacon/state/index.ts +15 -15
- package/src/api/impl/beacon/state/utils.ts +2 -2
- package/src/api/impl/lodestar/attesterSlashing.ts +43 -0
- package/src/api/impl/lodestar/index.ts +51 -1
- package/src/api/impl/validator/index.ts +10 -6
- package/src/chain/GetBlobsTracker.ts +1 -2
- package/src/chain/archiveStore/archiveStore.ts +5 -5
- package/src/chain/archiveStore/interface.ts +4 -4
- package/src/chain/archiveStore/strategies/frequencyStateArchiveStrategy.ts +6 -8
- package/src/chain/archiveStore/utils/archiveBlocks.ts +153 -94
- package/src/chain/blocks/importBlock.ts +33 -42
- package/src/chain/blocks/importExecutionPayload.ts +83 -99
- package/src/chain/blocks/index.ts +1 -2
- package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +27 -0
- package/src/chain/blocks/payloadEnvelopeProcessor.ts +6 -5
- package/src/chain/blocks/types.ts +15 -26
- package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +2 -1
- package/src/chain/blocks/verifyBlocksSignatures.ts +9 -2
- package/src/chain/blocks/verifyExecutionPayloadEnvelope.ts +129 -0
- package/src/chain/blocks/verifyPayloadsDataAvailability.ts +38 -0
- package/src/chain/blocks/writePayloadEnvelopeInputToDb.ts +9 -18
- package/src/chain/chain.ts +47 -62
- package/src/chain/emitter.ts +15 -3
- package/src/chain/errors/attestationError.ts +6 -1
- package/src/chain/errors/blockError.ts +7 -1
- package/src/chain/errors/executionPayloadBid.ts +6 -0
- package/src/chain/errors/executionPayloadEnvelope.ts +6 -0
- package/src/chain/forkChoice/index.ts +19 -28
- package/src/chain/interface.ts +7 -2
- package/src/chain/lightClient/index.ts +15 -3
- package/src/chain/opPools/aggregatedAttestationPool.ts +6 -1
- package/src/chain/opPools/executionPayloadBidPool.ts +3 -3
- package/src/chain/prepareNextSlot.ts +38 -11
- package/src/chain/produceBlock/computeNewStateRoot.ts +1 -37
- package/src/chain/produceBlock/produceBlockBody.ts +74 -23
- package/src/chain/regen/errors.ts +1 -6
- package/src/chain/regen/interface.ts +6 -12
- package/src/chain/regen/queued.ts +12 -48
- package/src/chain/regen/regen.ts +8 -36
- package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +22 -20
- package/src/chain/stateCache/datastore/db.ts +10 -33
- package/src/chain/stateCache/datastore/file.ts +5 -6
- package/src/chain/stateCache/datastore/types.ts +2 -3
- package/src/chain/stateCache/fifoBlockStateCache.ts +1 -10
- package/src/chain/stateCache/persistentCheckpointsCache.ts +139 -247
- package/src/chain/stateCache/types.ts +8 -14
- package/src/chain/validation/aggregateAndProof.ts +13 -0
- package/src/chain/validation/attestation.ts +13 -0
- package/src/chain/validation/block.ts +30 -7
- package/src/chain/validation/executionPayloadBid.ts +21 -3
- package/src/chain/validation/executionPayloadEnvelope.ts +32 -13
- package/src/chain/validation/payloadAttestationMessage.ts +9 -3
- package/src/chain/validation/syncCommittee.ts +5 -1
- package/src/chain/validation/syncCommitteeContributionAndProof.ts +5 -1
- package/src/chain/validatorMonitor.ts +3 -2
- package/src/db/repositories/executionPayloadEnvelopeArchive.ts +1 -1
- package/src/execution/engine/http.ts +21 -14
- package/src/execution/engine/interface.ts +1 -0
- package/src/execution/engine/mock.ts +8 -1
- package/src/execution/engine/types.ts +41 -0
- package/src/network/network.ts +1 -1
- package/src/network/processor/gossipHandlers.ts +31 -10
- package/src/network/reqresp/handlers/beaconBlocksByRange.ts +3 -1
- package/src/network/reqresp/handlers/beaconBlocksByRoot.ts +3 -0
- package/src/network/reqresp/handlers/blobSidecarsByRange.ts +15 -3
- package/src/network/reqresp/handlers/blobSidecarsByRoot.ts +11 -0
- package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +19 -3
- package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +3 -1
- package/src/network/reqresp/handlers/executionPayloadEnvelopesByRoot.ts +3 -12
- package/src/node/nodejs.ts +7 -2
- package/src/node/notifier.ts +7 -2
- package/src/util/sszBytes.ts +21 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import {ChainForkConfig} from "@lodestar/config";
|
|
3
3
|
import {KeyValue} from "@lodestar/db";
|
|
4
|
-
import {
|
|
4
|
+
import {CheckpointWithHex, IForkChoice, PayloadStatus, ProtoBlock} from "@lodestar/fork-choice";
|
|
5
5
|
import {ForkSeq, SLOTS_PER_EPOCH} from "@lodestar/params";
|
|
6
6
|
import {computeEpochAtSlot, computeStartSlotAtEpoch} from "@lodestar/state-transition";
|
|
7
7
|
import {Epoch, Slot} from "@lodestar/types";
|
|
@@ -52,16 +52,17 @@ export async function archiveBlocks(
|
|
|
52
52
|
forkChoice: IForkChoice,
|
|
53
53
|
lightclientServer: LightClientServer | undefined,
|
|
54
54
|
logger: Logger,
|
|
55
|
-
finalizedCheckpoint:
|
|
55
|
+
finalizedCheckpoint: CheckpointWithHex,
|
|
56
56
|
currentEpoch: Epoch,
|
|
57
57
|
archiveDataEpochs?: number,
|
|
58
58
|
persistOrphanedBlocks?: boolean,
|
|
59
59
|
persistOrphanedBlocksDir?: string
|
|
60
60
|
): Promise<void> {
|
|
61
|
-
// Use fork choice to determine the blocks to archive and delete
|
|
62
|
-
//
|
|
61
|
+
// Use fork choice to determine the blocks to archive and delete.
|
|
62
|
+
// `ancestors` is the canonical walk back from the finalized root, including the previous finalized
|
|
63
|
+
// block as its last element.
|
|
63
64
|
const {ancestors: finalizedCanonicalBlocks, nonAncestors: finalizedNonCanonicalBlocks} =
|
|
64
|
-
forkChoice.
|
|
65
|
+
forkChoice.getAllAncestorAndNonAncestorBlocksDefaultStatus(finalizedCheckpoint.rootHex);
|
|
65
66
|
|
|
66
67
|
// NOTE: The finalized block will be exactly the first block of `epoch` or previous
|
|
67
68
|
const finalizedPostDeneb = finalizedCheckpoint.epoch >= config.DENEB_FORK_EPOCH;
|
|
@@ -76,18 +77,21 @@ export async function archiveBlocks(
|
|
|
76
77
|
const logCtx = {currentEpoch, finalizedEpoch: finalizedCheckpoint.epoch, finalizedRoot: finalizedCheckpoint.rootHex};
|
|
77
78
|
|
|
78
79
|
if (finalizedCanonicalBlockRoots.length > 0) {
|
|
79
|
-
await migrateBlocksFromHotToColdDb(db, finalizedCanonicalBlockRoots);
|
|
80
|
+
const migratedSlots = await migrateBlocksFromHotToColdDb(db, logger, finalizedCanonicalBlockRoots);
|
|
80
81
|
logger.verbose("Migrated blocks from hot DB to cold DB", {
|
|
81
82
|
...logCtx,
|
|
82
83
|
fromSlot: finalizedCanonicalBlockRoots[0].slot,
|
|
83
84
|
toSlot: finalizedCanonicalBlockRoots.at(-1)?.slot,
|
|
84
85
|
size: finalizedCanonicalBlockRoots.length,
|
|
86
|
+
migratedEntries: migratedSlots.length,
|
|
87
|
+
slotRange: prettyPrintIndices(migratedSlots),
|
|
85
88
|
});
|
|
86
89
|
|
|
87
90
|
if (finalizedPostDeneb) {
|
|
88
91
|
const migratedEntries = await migrateBlobSidecarsFromHotToColdDb(
|
|
89
92
|
config,
|
|
90
93
|
db,
|
|
94
|
+
logger,
|
|
91
95
|
finalizedCanonicalBlockRoots,
|
|
92
96
|
currentEpoch
|
|
93
97
|
);
|
|
@@ -95,24 +99,32 @@ export async function archiveBlocks(
|
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
if (finalizedPostFulu) {
|
|
98
|
-
const
|
|
102
|
+
const migratedSlots = await migrateDataColumnSidecarsFromHotToColdDb(
|
|
99
103
|
config,
|
|
100
104
|
db,
|
|
101
105
|
logger,
|
|
102
|
-
|
|
106
|
+
finalizedCanonicalBlocks,
|
|
103
107
|
currentEpoch
|
|
104
108
|
);
|
|
105
|
-
logger.verbose("Migrated dataColumnSidecars from hot DB to cold DB", {
|
|
109
|
+
logger.verbose("Migrated dataColumnSidecars from hot DB to cold DB", {
|
|
110
|
+
...logCtx,
|
|
111
|
+
migratedEntries: migratedSlots.length,
|
|
112
|
+
slotRange: prettyPrintIndices(migratedSlots),
|
|
113
|
+
});
|
|
106
114
|
}
|
|
107
115
|
|
|
108
116
|
if (finalizedPostGloas) {
|
|
109
|
-
const
|
|
117
|
+
const migratedSlots = await migrateExecutionPayloadEnvelopesFromHotToColdDb(
|
|
110
118
|
config,
|
|
111
119
|
db,
|
|
112
120
|
logger,
|
|
113
121
|
finalizedCanonicalBlocks
|
|
114
122
|
);
|
|
115
|
-
logger.verbose("Migrated executionPayloadEnvelopes from hot DB to cold DB", {
|
|
123
|
+
logger.verbose("Migrated executionPayloadEnvelopes from hot DB to cold DB", {
|
|
124
|
+
...logCtx,
|
|
125
|
+
migratedEntries: migratedSlots.length,
|
|
126
|
+
slotRange: prettyPrintIndices(migratedSlots),
|
|
127
|
+
});
|
|
116
128
|
}
|
|
117
129
|
}
|
|
118
130
|
|
|
@@ -140,25 +152,29 @@ export async function archiveBlocks(
|
|
|
140
152
|
);
|
|
141
153
|
}
|
|
142
154
|
|
|
143
|
-
|
|
144
|
-
|
|
155
|
+
const nonCanonicalSlots = finalizedNonCanonicalBlocks.map((summary) => summary.slot).sort((a, b) => a - b);
|
|
156
|
+
const nonCanonicalLogCtx = {
|
|
145
157
|
...logCtx,
|
|
146
|
-
|
|
147
|
-
|
|
158
|
+
count: nonCanonicalBlockRoots.length,
|
|
159
|
+
slotRange: prettyPrintIndices(nonCanonicalSlots),
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
await db.block.batchDelete(nonCanonicalBlockRoots);
|
|
163
|
+
logger.verbose("Deleted non canonical blocks from hot DB", nonCanonicalLogCtx);
|
|
148
164
|
|
|
149
165
|
if (finalizedPostDeneb) {
|
|
150
166
|
await db.blobSidecars.batchDelete(nonCanonicalBlockRoots);
|
|
151
|
-
logger.verbose("Deleted non canonical blobSidecars from hot DB",
|
|
167
|
+
logger.verbose("Deleted non canonical blobSidecars from hot DB", nonCanonicalLogCtx);
|
|
152
168
|
}
|
|
153
169
|
|
|
154
170
|
if (finalizedPostFulu) {
|
|
155
171
|
await db.dataColumnSidecar.deleteMany(nonCanonicalBlockRoots);
|
|
156
|
-
logger.verbose("Deleted non canonical dataColumnSidecars from hot DB",
|
|
172
|
+
logger.verbose("Deleted non canonical dataColumnSidecars from hot DB", nonCanonicalLogCtx);
|
|
157
173
|
}
|
|
158
174
|
|
|
159
175
|
if (finalizedPostGloas) {
|
|
160
176
|
await db.executionPayloadEnvelope.batchDelete(nonCanonicalBlockRoots);
|
|
161
|
-
logger.verbose("Deleted non canonical executionPayloadEnvelopes from hot DB",
|
|
177
|
+
logger.verbose("Deleted non canonical executionPayloadEnvelopes from hot DB", nonCanonicalLogCtx);
|
|
162
178
|
}
|
|
163
179
|
}
|
|
164
180
|
|
|
@@ -239,42 +255,51 @@ export async function archiveBlocks(
|
|
|
239
255
|
});
|
|
240
256
|
}
|
|
241
257
|
|
|
242
|
-
async function migrateBlocksFromHotToColdDb(db: IBeaconDb, blocks: BlockRootSlot[]): Promise<
|
|
243
|
-
//
|
|
244
|
-
//
|
|
245
|
-
// the
|
|
258
|
+
async function migrateBlocksFromHotToColdDb(db: IBeaconDb, logger: Logger, blocks: BlockRootSlot[]): Promise<Slot[]> {
|
|
259
|
+
// The input includes the previous finalized block as the last ancestor; its SignedBeaconBlock
|
|
260
|
+
// was archived on a previous run and is no longer in hot db. `getBinary` returning null for any
|
|
261
|
+
// block in the batch is therefore treated as "already migrated, skip" rather than an error.
|
|
262
|
+
const migratedSlots: Slot[] = [];
|
|
246
263
|
for (let i = 0; i < blocks.length; i += BLOCK_BATCH_SIZE) {
|
|
247
264
|
const toIdx = Math.min(i + BLOCK_BATCH_SIZE, blocks.length);
|
|
248
265
|
const canonicalBlocks = blocks.slice(i, toIdx);
|
|
249
266
|
|
|
250
|
-
|
|
251
|
-
if (canonicalBlocks.length === 0) return;
|
|
267
|
+
if (canonicalBlocks.length === 0) break;
|
|
252
268
|
|
|
253
269
|
// load Buffer instead of SignedBeaconBlock to improve performance
|
|
254
|
-
const canonicalBlockEntries
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
270
|
+
const canonicalBlockEntries = (
|
|
271
|
+
await Promise.all(
|
|
272
|
+
canonicalBlocks.map(async (block): Promise<BlockArchiveBatchPutBinaryItem | null> => {
|
|
273
|
+
const blockBuffer = await db.block.getBinary(block.root);
|
|
274
|
+
if (!blockBuffer) {
|
|
275
|
+
logger.debug("Block in forkchoice but missing in hot db, could be already archived", {
|
|
276
|
+
slot: block.slot,
|
|
277
|
+
root: toRootHex(block.root),
|
|
278
|
+
});
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
return {
|
|
282
|
+
key: block.slot,
|
|
283
|
+
value: blockBuffer,
|
|
284
|
+
slot: block.slot,
|
|
285
|
+
blockRoot: block.root,
|
|
286
|
+
// TODO: Benchmark if faster to slice Buffer or fromHex()
|
|
287
|
+
parentRoot: getParentRootFromSignedBlock(blockBuffer),
|
|
288
|
+
};
|
|
289
|
+
})
|
|
290
|
+
)
|
|
291
|
+
).filter((entry): entry is BlockArchiveBatchPutBinaryItem => entry !== null);
|
|
292
|
+
|
|
293
|
+
if (canonicalBlockEntries.length === 0) continue;
|
|
271
294
|
|
|
272
|
-
// put to blockArchive db and delete block db
|
|
273
295
|
await Promise.all([
|
|
274
296
|
db.blockArchive.batchPutBinary(canonicalBlockEntries),
|
|
275
|
-
db.block.batchDelete(
|
|
297
|
+
db.block.batchDelete(canonicalBlockEntries.map((entry) => entry.blockRoot)),
|
|
276
298
|
]);
|
|
299
|
+
for (const entry of canonicalBlockEntries) migratedSlots.push(entry.slot);
|
|
277
300
|
}
|
|
301
|
+
// Ancestor walk is newest → oldest; sort ascending so `prettyPrintIndices` renders cleanly.
|
|
302
|
+
return migratedSlots.sort((a, b) => a - b);
|
|
278
303
|
}
|
|
279
304
|
|
|
280
305
|
/**
|
|
@@ -284,6 +309,7 @@ async function migrateBlocksFromHotToColdDb(db: IBeaconDb, blocks: BlockRootSlot
|
|
|
284
309
|
async function migrateBlobSidecarsFromHotToColdDb(
|
|
285
310
|
config: ChainForkConfig,
|
|
286
311
|
db: IBeaconDb,
|
|
312
|
+
logger: Logger,
|
|
287
313
|
blocks: BlockRootSlot[],
|
|
288
314
|
currentEpoch: Epoch
|
|
289
315
|
): Promise<number> {
|
|
@@ -296,29 +322,36 @@ async function migrateBlobSidecarsFromHotToColdDb(
|
|
|
296
322
|
if (canonicalBlocks.length === 0) break;
|
|
297
323
|
|
|
298
324
|
// load Buffer instead of ssz deserialized to improve performance
|
|
299
|
-
const canonicalBlobSidecarsEntries: KeyValue<Slot, Uint8Array>[] =
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
325
|
+
const canonicalBlobSidecarsEntries: KeyValue<Slot, Uint8Array>[] = (
|
|
326
|
+
await Promise.all(
|
|
327
|
+
canonicalBlocks
|
|
328
|
+
.filter((block) => {
|
|
329
|
+
const blockSlot = block.slot;
|
|
330
|
+
const blockEpoch = computeEpochAtSlot(blockSlot);
|
|
331
|
+
const forkSeq = config.getForkSeq(blockSlot);
|
|
332
|
+
return (
|
|
333
|
+
forkSeq >= ForkSeq.deneb &&
|
|
334
|
+
forkSeq < ForkSeq.fulu &&
|
|
335
|
+
// if block is out of ${config.MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS}, skip this step
|
|
336
|
+
blockEpoch >= currentEpoch - config.MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS
|
|
337
|
+
);
|
|
338
|
+
})
|
|
339
|
+
.map(async (block): Promise<KeyValue<Slot, Uint8Array> | null> => {
|
|
340
|
+
// The ancestor walk includes the boundary (previous finalized) block; on first
|
|
341
|
+
// finalization that boundary is the anchor which has no blob sidecars in hot db.
|
|
342
|
+
// Treat a null hot-db entry as "nothing to migrate" rather than an error.
|
|
343
|
+
const bytes = await db.blobSidecars.getBinary(block.root);
|
|
344
|
+
if (!bytes) {
|
|
345
|
+
logger.debug("BlobSidecars in forkchoice but missing in hot db, could be already archived", {
|
|
346
|
+
slot: block.slot,
|
|
347
|
+
root: toRootHex(block.root),
|
|
348
|
+
});
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
351
|
+
return {key: block.slot, value: bytes};
|
|
352
|
+
})
|
|
353
|
+
)
|
|
354
|
+
).filter((e): e is KeyValue<Slot, Uint8Array> => e !== null);
|
|
322
355
|
|
|
323
356
|
// put to blockArchive db and delete block db
|
|
324
357
|
await Promise.all([
|
|
@@ -332,24 +365,36 @@ async function migrateBlobSidecarsFromHotToColdDb(
|
|
|
332
365
|
}
|
|
333
366
|
|
|
334
367
|
// TODO: This function can be simplified further by reducing layers of promises in a loop
|
|
368
|
+
/**
|
|
369
|
+
* Post-gloas the data columns of a Gloas block are tied to its execution payload envelope —
|
|
370
|
+
* columns only exist once the FULL variant of the block is in the proto-array. Pre-Gloas (Fulu)
|
|
371
|
+
* blocks only have a FULL variant, so the `payloadStatus === FULL` filter passes them all.
|
|
372
|
+
* Blocks whose canonical variant is PENDING/EMPTY are skipped here — their columns will be picked
|
|
373
|
+
* up on a later run once the FULL variant appears in the ancestor walk.
|
|
374
|
+
*/
|
|
335
375
|
async function migrateDataColumnSidecarsFromHotToColdDb(
|
|
336
376
|
config: ChainForkConfig,
|
|
337
377
|
db: IBeaconDb,
|
|
338
378
|
logger: Logger,
|
|
339
|
-
|
|
379
|
+
canonicalBlocks: ProtoBlock[],
|
|
340
380
|
currentEpoch: Epoch
|
|
341
|
-
): Promise<
|
|
342
|
-
|
|
381
|
+
): Promise<Slot[]> {
|
|
382
|
+
const columnBlocks = canonicalBlocks.filter(
|
|
383
|
+
(block) => config.getForkSeq(block.slot) < ForkSeq.gloas || block.payloadStatus === PayloadStatus.FULL
|
|
384
|
+
);
|
|
385
|
+
if (columnBlocks.length === 0) return [];
|
|
386
|
+
const blocks: BlockRootSlot[] = columnBlocks.map((block) => ({slot: block.slot, root: fromHex(block.blockRoot)}));
|
|
387
|
+
|
|
388
|
+
const migratedSlots: Slot[] = [];
|
|
343
389
|
for (let i = 0; i < blocks.length; i += BLOB_SIDECAR_BATCH_SIZE) {
|
|
344
390
|
const toIdx = Math.min(i + BLOB_SIDECAR_BATCH_SIZE, blocks.length);
|
|
345
|
-
const
|
|
391
|
+
const batch = blocks.slice(i, toIdx);
|
|
392
|
+
if (batch.length === 0) break;
|
|
346
393
|
|
|
347
|
-
|
|
348
|
-
if (canonicalBlocks.length === 0) break;
|
|
349
|
-
const promises = [];
|
|
394
|
+
const promises: Promise<void>[] = [];
|
|
350
395
|
|
|
351
396
|
// load Buffer instead of ssz deserialized to improve performance
|
|
352
|
-
for (const block of
|
|
397
|
+
for (const block of batch) {
|
|
353
398
|
const blockSlot = block.slot;
|
|
354
399
|
const blockEpoch = computeEpochAtSlot(blockSlot);
|
|
355
400
|
|
|
@@ -363,8 +408,16 @@ async function migrateDataColumnSidecarsFromHotToColdDb(
|
|
|
363
408
|
|
|
364
409
|
// Here we assume the data column sidecars are already in the hot db
|
|
365
410
|
const dataColumnSidecarBytes = await fromAsync(db.dataColumnSidecar.valuesStreamBinary(block.root));
|
|
366
|
-
|
|
367
|
-
|
|
411
|
+
if (dataColumnSidecarBytes.length === 0) {
|
|
412
|
+
// Empty stream: either the block has no blobs, or columns were already archived on a
|
|
413
|
+
// previous run (boundary block). Nothing to migrate.
|
|
414
|
+
logger.debug("DataColumnSidecars in forkchoice but missing in hot db, could be already archived", {
|
|
415
|
+
slot: block.slot,
|
|
416
|
+
root: toRootHex(block.root),
|
|
417
|
+
});
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
420
|
+
logger.verbose("Migrated dataColumnSidecars for block", {
|
|
368
421
|
currentEpoch,
|
|
369
422
|
slot: block.slot,
|
|
370
423
|
root: toRootHex(block.root),
|
|
@@ -376,30 +429,32 @@ async function migrateDataColumnSidecarsFromHotToColdDb(
|
|
|
376
429
|
dataColumnSidecarBytes.map((p) => ({key: p.id, value: p.value}))
|
|
377
430
|
)
|
|
378
431
|
);
|
|
379
|
-
|
|
432
|
+
migratedSlots.push(block.slot);
|
|
380
433
|
}
|
|
381
434
|
|
|
382
|
-
promises.push(db.dataColumnSidecar.deleteMany(
|
|
435
|
+
promises.push(db.dataColumnSidecar.deleteMany(batch.map((block) => block.root)));
|
|
383
436
|
|
|
384
|
-
// put to blockArchive db and delete block db
|
|
385
437
|
await Promise.all(promises);
|
|
386
438
|
}
|
|
387
439
|
|
|
388
|
-
|
|
440
|
+
// Ancestor walk is newest → oldest; sort ascending so `prettyPrintIndices` renders cleanly.
|
|
441
|
+
return migratedSlots.sort((a, b) => a - b);
|
|
389
442
|
}
|
|
390
443
|
|
|
444
|
+
/**
|
|
445
|
+
* Post-gloas given a finalized checkpoint at a block root, payload of that block root
|
|
446
|
+
* is not considered finalized, hence they are archived in the next run.
|
|
447
|
+
*/
|
|
391
448
|
async function migrateExecutionPayloadEnvelopesFromHotToColdDb(
|
|
392
449
|
config: ChainForkConfig,
|
|
393
450
|
db: IBeaconDb,
|
|
394
451
|
logger: Logger,
|
|
395
452
|
canonicalBlocks: ProtoBlock[]
|
|
396
|
-
): Promise<
|
|
397
|
-
let migratedEnvelopes = 0;
|
|
398
|
-
|
|
453
|
+
): Promise<Slot[]> {
|
|
399
454
|
const payloadBlocks = canonicalBlocks.filter(
|
|
400
|
-
(block) => config.getForkSeq(block.slot)
|
|
455
|
+
(block) => config.getForkSeq(block.slot) < ForkSeq.gloas || block.payloadStatus === PayloadStatus.FULL
|
|
401
456
|
);
|
|
402
|
-
if (payloadBlocks.length === 0) return
|
|
457
|
+
if (payloadBlocks.length === 0) return [];
|
|
403
458
|
const blocks = payloadBlocks.map((block) => ({slot: block.slot, root: fromHex(block.blockRoot)}));
|
|
404
459
|
|
|
405
460
|
const envelopeEntries: KeyValue<Slot, Uint8Array>[] = [];
|
|
@@ -415,19 +470,23 @@ async function migrateExecutionPayloadEnvelopesFromHotToColdDb(
|
|
|
415
470
|
envelopeEntries.push({key: blocks[i].slot, value: bytes});
|
|
416
471
|
migratedRoots.push(blocks[i].root);
|
|
417
472
|
} else {
|
|
418
|
-
logger.debug("
|
|
473
|
+
logger.debug("ExecutionPayloadEnvelope in forkchoice but missing in hot db, could be already archived", {
|
|
474
|
+
slot: blocks[i].slot,
|
|
475
|
+
root: toRootHex(blocks[i].root),
|
|
476
|
+
});
|
|
419
477
|
}
|
|
420
478
|
}
|
|
421
479
|
|
|
422
|
-
if (envelopeEntries.length
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
}
|
|
480
|
+
if (envelopeEntries.length === 0) return [];
|
|
481
|
+
|
|
482
|
+
await Promise.all([
|
|
483
|
+
db.executionPayloadEnvelopeArchive.batchPutBinary(envelopeEntries),
|
|
484
|
+
db.executionPayloadEnvelope.batchDelete(migratedRoots),
|
|
485
|
+
]);
|
|
429
486
|
|
|
430
|
-
|
|
487
|
+
// Slots are ascending in hot-db key order — sort to guarantee `prettyPrintIndices` output is clean
|
|
488
|
+
// regardless of ancestor-walk order (newest → oldest).
|
|
489
|
+
return envelopeEntries.map((entry) => entry.key).sort((a, b) => a - b);
|
|
431
490
|
}
|
|
432
491
|
|
|
433
492
|
/**
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
ForkChoiceErrorCode,
|
|
9
9
|
NotReorgedReason,
|
|
10
10
|
getSafeExecutionBlockHash,
|
|
11
|
-
isGloasBlock,
|
|
12
11
|
} from "@lodestar/fork-choice";
|
|
13
12
|
import {
|
|
14
13
|
ForkPostAltair,
|
|
@@ -25,6 +24,8 @@ import {
|
|
|
25
24
|
computeStartSlotAtEpoch,
|
|
26
25
|
computeTimeAtSlot,
|
|
27
26
|
isStartSlotOfEpoch,
|
|
27
|
+
isStatePostAltair,
|
|
28
|
+
isStatePostBellatrix,
|
|
28
29
|
} from "@lodestar/state-transition";
|
|
29
30
|
import {
|
|
30
31
|
Attestation,
|
|
@@ -46,7 +47,7 @@ import type {BeaconChain} from "../chain.js";
|
|
|
46
47
|
import {ChainEvent, ReorgEventData} from "../emitter.js";
|
|
47
48
|
import {ForkchoiceCaller} from "../forkChoice/index.js";
|
|
48
49
|
import {REPROCESS_MIN_TIME_TO_NEXT_SLOT_SEC} from "../reprocess.js";
|
|
49
|
-
import {
|
|
50
|
+
import {toCheckpointHex} from "../stateCache/persistentCheckpointsCache.js";
|
|
50
51
|
import {isBlockInputBlobs, isBlockInputColumns} from "./blockInput/blockInput.js";
|
|
51
52
|
import {AttestationImportOpt, FullyVerifiedBlock, ImportBlockOpts} from "./types.js";
|
|
52
53
|
import {getCheckpointFromState} from "./utils/checkpoint.js";
|
|
@@ -85,7 +86,7 @@ export async function importBlock(
|
|
|
85
86
|
fullyVerifiedBlock: FullyVerifiedBlock,
|
|
86
87
|
opts: ImportBlockOpts
|
|
87
88
|
): Promise<void> {
|
|
88
|
-
const {blockInput,
|
|
89
|
+
const {blockInput, postState, parentBlockSlot, executionStatus, dataAvailabilityStatus, indexedAttestations} =
|
|
89
90
|
fullyVerifiedBlock;
|
|
90
91
|
const block = blockInput.getBlock();
|
|
91
92
|
const source = blockInput.getBlockSource();
|
|
@@ -97,7 +98,7 @@ export async function importBlock(
|
|
|
97
98
|
const blockEpoch = computeEpochAtSlot(blockSlot);
|
|
98
99
|
const prevFinalizedEpoch = this.forkChoice.getFinalizedCheckpoint().epoch;
|
|
99
100
|
const blockDelaySec =
|
|
100
|
-
fullyVerifiedBlock.seenTimestampSec - computeTimeAtSlot(this.config, blockSlot,
|
|
101
|
+
fullyVerifiedBlock.seenTimestampSec - computeTimeAtSlot(this.config, blockSlot, postState.genesisTime);
|
|
101
102
|
const recvToValLatency = Date.now() / 1000 - (opts.seenTimestampSec ?? Date.now() / 1000);
|
|
102
103
|
const fork = this.config.getForkSeq(blockSlot);
|
|
103
104
|
|
|
@@ -120,10 +121,10 @@ export async function importBlock(
|
|
|
120
121
|
// 2. Import block to fork choice
|
|
121
122
|
|
|
122
123
|
// Should compute checkpoint balances before forkchoice.onBlock
|
|
123
|
-
this.checkpointBalancesCache.processState(blockRootHex,
|
|
124
|
+
this.checkpointBalancesCache.processState(blockRootHex, postState);
|
|
124
125
|
const blockSummary = this.forkChoice.onBlock(
|
|
125
126
|
block.message,
|
|
126
|
-
|
|
127
|
+
postState,
|
|
127
128
|
blockDelaySec,
|
|
128
129
|
currentSlot,
|
|
129
130
|
fork >= ForkSeq.gloas ? ExecutionStatus.PayloadSeparated : executionStatus,
|
|
@@ -132,11 +133,7 @@ export async function importBlock(
|
|
|
132
133
|
|
|
133
134
|
// This adds the state necessary to process the next block
|
|
134
135
|
// Some block event handlers require state being in state cache so need to do this before emitting EventType.block
|
|
135
|
-
|
|
136
|
-
// Post-Gloas: blockSummary.payloadStatus is always PENDING, so payloadPresent = false (block state only, no payload processing yet)
|
|
137
|
-
const payloadPresent = !isGloasBlock(blockSummary);
|
|
138
|
-
// processState manages both block state and payload state variants together for memory/disk management
|
|
139
|
-
this.regen.processBlockState(blockRootHex, postBlockState);
|
|
136
|
+
this.regen.processState(blockRootHex, postState);
|
|
140
137
|
|
|
141
138
|
// For Gloas blocks, create PayloadEnvelopeInput so it's available for later payload import
|
|
142
139
|
if (fork >= ForkSeq.gloas) {
|
|
@@ -159,17 +156,9 @@ export async function importBlock(
|
|
|
159
156
|
// which is all the information we need so there is no reason to delay until execution payload arrives
|
|
160
157
|
// TODO GLOAS: If we want EL retries after this initial attempt, add an explicit retry policy here
|
|
161
158
|
// (for example later in the slot). Do not couple retries to incoming gossip columns.
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
this.processExecutionPayload(payloadInput, {validSignature: true}).catch((e) => {
|
|
166
|
-
this.logger.debug(
|
|
167
|
-
"Error processing execution payload after getBlobs",
|
|
168
|
-
{slot: blockSlot, root: blockRootHex},
|
|
169
|
-
e as Error
|
|
170
|
-
);
|
|
171
|
-
});
|
|
172
|
-
});
|
|
159
|
+
// Columns fetched here feed payloadInput.addColumn, which resolves waitForAllData for any
|
|
160
|
+
// in-flight importExecutionPayload. No processExecutionPayload trigger needed from this path.
|
|
161
|
+
this.getBlobsTracker.triggerGetBlobs(payloadInput);
|
|
173
162
|
}
|
|
174
163
|
|
|
175
164
|
this.metrics?.importBlock.bySource.inc({source: source.source});
|
|
@@ -189,7 +178,7 @@ export async function importBlock(
|
|
|
189
178
|
(opts.importAttestations !== AttestationImportOpt.Skip && blockEpoch >= currentEpoch - FORK_CHOICE_ATT_EPOCH_LIMIT)
|
|
190
179
|
) {
|
|
191
180
|
const attestations = block.message.body.attestations;
|
|
192
|
-
const rootCache = new RootCache(
|
|
181
|
+
const rootCache = new RootCache(postState);
|
|
193
182
|
const invalidAttestationErrorsByCode = new Map<string, {error: Error; count: number}>();
|
|
194
183
|
|
|
195
184
|
const addAttestation = fork >= ForkSeq.electra ? addAttestationPostElectra : addAttestationPreElectra;
|
|
@@ -203,7 +192,7 @@ export async function importBlock(
|
|
|
203
192
|
const attDataRoot = toRootHex(ssz.phase0.AttestationData.hashTreeRoot(indexedAttestation.data));
|
|
204
193
|
addAttestation.call(
|
|
205
194
|
this,
|
|
206
|
-
|
|
195
|
+
postState,
|
|
207
196
|
target,
|
|
208
197
|
attDataRoot,
|
|
209
198
|
attestation as Attestation<ForkPostElectra>,
|
|
@@ -318,7 +307,7 @@ export async function importBlock(
|
|
|
318
307
|
|
|
319
308
|
if (newHead.blockRoot !== oldHead.blockRoot) {
|
|
320
309
|
// Set head state as strong reference
|
|
321
|
-
this.regen.updateHeadState(newHead,
|
|
310
|
+
this.regen.updateHeadState(newHead, postState);
|
|
322
311
|
|
|
323
312
|
try {
|
|
324
313
|
this.emitter.emit(routes.events.EventType.head, {
|
|
@@ -388,11 +377,13 @@ export async function importBlock(
|
|
|
388
377
|
// we want to import block asap so do this in the next event loop
|
|
389
378
|
callInNextEventLoop(() => {
|
|
390
379
|
try {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
380
|
+
if (isStatePostAltair(postState)) {
|
|
381
|
+
this.lightClientServer?.onImportBlockHead(
|
|
382
|
+
block.message as BeaconBlock<ForkPostAltair>,
|
|
383
|
+
postState,
|
|
384
|
+
parentBlockSlot
|
|
385
|
+
);
|
|
386
|
+
}
|
|
396
387
|
} catch (e) {
|
|
397
388
|
this.logger.verbose("Error lightClientServer.onImportBlock", {slot: blockSlot}, e as Error);
|
|
398
389
|
}
|
|
@@ -411,11 +402,11 @@ export async function importBlock(
|
|
|
411
402
|
// and the block is weak and can potentially be reorged out.
|
|
412
403
|
let shouldOverrideFcu = false;
|
|
413
404
|
|
|
414
|
-
if (blockSlot >= currentSlot &&
|
|
405
|
+
if (blockSlot >= currentSlot && isStatePostBellatrix(postState) && postState.isExecutionStateType) {
|
|
415
406
|
let notOverrideFcuReason = NotReorgedReason.Unknown;
|
|
416
407
|
const proposalSlot = blockSlot + 1;
|
|
417
408
|
try {
|
|
418
|
-
const proposerIndex =
|
|
409
|
+
const proposerIndex = postState.getBeaconProposer(proposalSlot);
|
|
419
410
|
const feeRecipient = this.beaconProposerCache.get(proposerIndex);
|
|
420
411
|
|
|
421
412
|
if (feeRecipient) {
|
|
@@ -495,27 +486,27 @@ export async function importBlock(
|
|
|
495
486
|
}
|
|
496
487
|
}
|
|
497
488
|
|
|
498
|
-
if (!
|
|
499
|
-
this.logger.verbose("After importBlock caching postState without SSZ cache", {slot:
|
|
489
|
+
if (!postState.isStateValidatorsNodesPopulated()) {
|
|
490
|
+
this.logger.verbose("After importBlock caching postState without SSZ cache", {slot: postState.slot});
|
|
500
491
|
}
|
|
501
492
|
|
|
502
493
|
// Cache shufflings when crossing an epoch boundary
|
|
503
494
|
const parentEpoch = computeEpochAtSlot(parentBlockSlot);
|
|
504
495
|
if (parentEpoch < blockEpoch) {
|
|
505
|
-
this.shufflingCache.processState(
|
|
496
|
+
this.shufflingCache.processState(postState);
|
|
506
497
|
this.logger.verbose("Processed shuffling for next epoch", {parentEpoch, blockEpoch, slot: blockSlot});
|
|
507
498
|
}
|
|
508
499
|
|
|
509
500
|
if (blockSlot % SLOTS_PER_EPOCH === 0) {
|
|
510
501
|
// Cache state to preserve epoch transition work
|
|
511
|
-
const checkpointState =
|
|
502
|
+
const checkpointState = postState;
|
|
512
503
|
const cp = getCheckpointFromState(checkpointState);
|
|
513
|
-
this.regen.addCheckpointState(cp, checkpointState
|
|
504
|
+
this.regen.addCheckpointState(cp, checkpointState);
|
|
514
505
|
// consumers should not mutate state ever
|
|
515
506
|
this.emitter.emit(ChainEvent.checkpoint, cp, checkpointState);
|
|
516
507
|
|
|
517
508
|
// Note: in-lined code from previos handler of ChainEvent.checkpoint
|
|
518
|
-
this.logger.verbose("Checkpoint processed",
|
|
509
|
+
this.logger.verbose("Checkpoint processed", toCheckpointHex(cp));
|
|
519
510
|
|
|
520
511
|
const activeValidatorsCount = checkpointState.activeValidatorCount;
|
|
521
512
|
this.metrics?.currentActiveValidators.set(activeValidatorsCount);
|
|
@@ -533,7 +524,7 @@ export async function importBlock(
|
|
|
533
524
|
const justifiedEpoch = justifiedCheckpoint.epoch;
|
|
534
525
|
const preJustifiedEpoch = parentBlockSummary.justifiedEpoch;
|
|
535
526
|
if (justifiedEpoch > preJustifiedEpoch) {
|
|
536
|
-
this.logger.verbose("Checkpoint justified",
|
|
527
|
+
this.logger.verbose("Checkpoint justified", toCheckpointHex(justifiedCheckpoint));
|
|
537
528
|
this.metrics?.previousJustifiedEpoch.set(checkpointState.previousJustifiedCheckpoint.epoch);
|
|
538
529
|
this.metrics?.currentJustifiedEpoch.set(justifiedCheckpoint.epoch);
|
|
539
530
|
}
|
|
@@ -547,7 +538,7 @@ export async function importBlock(
|
|
|
547
538
|
state: toRootHex(checkpointState.hashTreeRoot()),
|
|
548
539
|
executionOptimistic: false,
|
|
549
540
|
});
|
|
550
|
-
this.logger.verbose("Checkpoint finalized",
|
|
541
|
+
this.logger.verbose("Checkpoint finalized", toCheckpointHex(finalizedCheckpoint));
|
|
551
542
|
this.metrics?.finalizedEpoch.set(finalizedCheckpoint.epoch);
|
|
552
543
|
}
|
|
553
544
|
}
|
|
@@ -598,11 +589,11 @@ export async function importBlock(
|
|
|
598
589
|
this.metrics?.parentBlockDistance.observe(blockSlot - parentBlockSlot);
|
|
599
590
|
this.metrics?.proposerBalanceDeltaAny.observe(fullyVerifiedBlock.proposerBalanceDelta);
|
|
600
591
|
this.validatorMonitor?.registerImportedBlock(block.message, fullyVerifiedBlock);
|
|
601
|
-
if (
|
|
592
|
+
if (isStatePostAltair(fullyVerifiedBlock.postState)) {
|
|
602
593
|
this.validatorMonitor?.registerSyncAggregateInBlock(
|
|
603
594
|
blockEpoch,
|
|
604
595
|
(block as altair.SignedBeaconBlock).message.body.syncAggregate,
|
|
605
|
-
fullyVerifiedBlock.
|
|
596
|
+
fullyVerifiedBlock.postState.currentSyncCommitteeIndexed.validatorIndices
|
|
606
597
|
);
|
|
607
598
|
}
|
|
608
599
|
|