@lodestar/beacon-node 1.41.0 → 1.42.0-dev.2fd27cd2f6
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 +36 -17
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/beacon/pool/index.js +1 -1
- 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 +27 -32
- package/lib/api/impl/beacon/state/index.js.map +1 -1
- package/lib/api/impl/beacon/state/utils.d.ts +6 -6
- package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
- package/lib/api/impl/beacon/state/utils.js +7 -10
- package/lib/api/impl/beacon/state/utils.js.map +1 -1
- package/lib/api/impl/lodestar/index.d.ts.map +1 -1
- package/lib/api/impl/lodestar/index.js +4 -6
- package/lib/api/impl/lodestar/index.js.map +1 -1
- package/lib/api/impl/proof/index.d.ts.map +1 -1
- package/lib/api/impl/proof/index.js +2 -6
- package/lib/api/impl/proof/index.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +32 -28
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/api/impl/validator/utils.d.ts +2 -2
- package/lib/api/impl/validator/utils.d.ts.map +1 -1
- package/lib/api/impl/validator/utils.js +3 -3
- package/lib/api/impl/validator/utils.js.map +1 -1
- package/lib/chain/archiveStore/archiveStore.d.ts +0 -1
- package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
- package/lib/chain/archiveStore/archiveStore.js +0 -9
- package/lib/chain/archiveStore/archiveStore.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts +2 -6
- package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
- package/lib/chain/archiveStore/historicalState/getHistoricalState.js +3 -23
- package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/worker.js +1 -0
- package/lib/chain/archiveStore/historicalState/worker.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 +4 -1
- package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.js.map +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.js +38 -0
- package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
- package/lib/chain/balancesCache.d.ts +2 -2
- package/lib/chain/balancesCache.d.ts.map +1 -1
- package/lib/chain/balancesCache.js +4 -4
- package/lib/chain/balancesCache.js.map +1 -1
- package/lib/chain/blocks/blockInput/types.d.ts +4 -3
- package/lib/chain/blocks/blockInput/types.d.ts.map +1 -1
- package/lib/chain/blocks/blockInput/types.js +1 -0
- package/lib/chain/blocks/blockInput/types.js.map +1 -1
- package/lib/chain/blocks/importBlock.d.ts +3 -3
- package/lib/chain/blocks/importBlock.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.js +38 -18
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts +48 -0
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -0
- package/lib/chain/blocks/importExecutionPayload.js +158 -0
- package/lib/chain/blocks/importExecutionPayload.js.map +1 -0
- package/lib/chain/blocks/index.js +1 -1
- package/lib/chain/blocks/index.js.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/index.d.ts +3 -0
- package/lib/chain/blocks/payloadEnvelopeInput/index.d.ts.map +1 -0
- package/lib/chain/blocks/payloadEnvelopeInput/index.js +3 -0
- package/lib/chain/blocks/payloadEnvelopeInput/index.js.map +1 -0
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +80 -0
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -0
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +248 -0
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -0
- package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +29 -0
- package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -0
- package/lib/chain/blocks/payloadEnvelopeInput/types.js +11 -0
- package/lib/chain/blocks/payloadEnvelopeInput/types.js.map +1 -0
- package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts +15 -0
- package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts.map +1 -0
- package/lib/chain/blocks/payloadEnvelopeProcessor.js +46 -0
- package/lib/chain/blocks/payloadEnvelopeProcessor.js.map +1 -0
- package/lib/chain/blocks/types.d.ts +9 -2
- package/lib/chain/blocks/types.d.ts.map +1 -1
- package/lib/chain/blocks/types.js.map +1 -1
- package/lib/chain/blocks/utils/checkpoint.d.ts +2 -2
- package/lib/chain/blocks/utils/checkpoint.d.ts.map +1 -1
- package/lib/chain/blocks/utils/checkpoint.js.map +1 -1
- package/lib/chain/blocks/verifyBlock.d.ts +2 -2
- package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlock.js +4 -4
- package/lib/chain/blocks/verifyBlock.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts +3 -3
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +3 -3
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksSignatures.d.ts +2 -2
- package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksSignatures.js +2 -2
- package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts +3 -3
- package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js +3 -3
- package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js.map +1 -1
- package/lib/chain/blocks/writePayloadEnvelopeInputToDb.d.ts +12 -0
- package/lib/chain/blocks/writePayloadEnvelopeInputToDb.d.ts.map +1 -0
- package/lib/chain/blocks/writePayloadEnvelopeInputToDb.js +40 -0
- package/lib/chain/blocks/writePayloadEnvelopeInputToDb.js.map +1 -0
- package/lib/chain/chain.d.ts +22 -17
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +90 -48
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/emitter.d.ts +2 -2
- package/lib/chain/emitter.d.ts.map +1 -1
- package/lib/chain/errors/blockError.d.ts +4 -4
- package/lib/chain/errors/blockError.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.d.ts +12 -2
- package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.js +3 -1
- package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
- package/lib/chain/forkChoice/index.d.ts +4 -4
- package/lib/chain/forkChoice/index.d.ts.map +1 -1
- package/lib/chain/forkChoice/index.js +27 -33
- package/lib/chain/forkChoice/index.js.map +1 -1
- package/lib/chain/initState.d.ts +2 -2
- package/lib/chain/initState.d.ts.map +1 -1
- package/lib/chain/initState.js +1 -1
- package/lib/chain/initState.js.map +1 -1
- package/lib/chain/interface.d.ts +19 -17
- package/lib/chain/interface.d.ts.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 +4 -4
- package/lib/chain/lightClient/index.js.map +1 -1
- package/lib/chain/opPools/aggregatedAttestationPool.d.ts +6 -6
- package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
- package/lib/chain/opPools/aggregatedAttestationPool.js +10 -13
- package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
- package/lib/chain/opPools/opPool.d.ts +3 -3
- package/lib/chain/opPools/opPool.d.ts.map +1 -1
- package/lib/chain/opPools/opPool.js +7 -7
- package/lib/chain/opPools/opPool.js.map +1 -1
- package/lib/chain/opPools/utils.d.ts +2 -2
- package/lib/chain/opPools/utils.d.ts.map +1 -1
- package/lib/chain/opPools/utils.js +2 -2
- package/lib/chain/opPools/utils.js.map +1 -1
- package/lib/chain/prepareNextSlot.d.ts +2 -2
- package/lib/chain/prepareNextSlot.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +9 -5
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/computeNewStateRoot.d.ts +4 -4
- package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
- package/lib/chain/produceBlock/computeNewStateRoot.js +8 -4
- package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +5 -5
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +13 -17
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/regen/errors.d.ts +11 -1
- package/lib/chain/regen/errors.d.ts.map +1 -1
- package/lib/chain/regen/errors.js +2 -0
- package/lib/chain/regen/errors.js.map +1 -1
- package/lib/chain/regen/interface.d.ts +22 -14
- package/lib/chain/regen/interface.d.ts.map +1 -1
- package/lib/chain/regen/interface.js +2 -0
- package/lib/chain/regen/interface.js.map +1 -1
- package/lib/chain/regen/queued.d.ts +20 -15
- package/lib/chain/regen/queued.d.ts.map +1 -1
- package/lib/chain/regen/queued.js +40 -8
- package/lib/chain/regen/queued.js.map +1 -1
- package/lib/chain/regen/regen.d.ts +11 -5
- package/lib/chain/regen/regen.d.ts.map +1 -1
- package/lib/chain/regen/regen.js +38 -11
- package/lib/chain/regen/regen.js.map +1 -1
- package/lib/chain/seenCache/index.d.ts +1 -1
- package/lib/chain/seenCache/index.d.ts.map +1 -1
- package/lib/chain/seenCache/index.js +1 -1
- package/lib/chain/seenCache/index.js.map +1 -1
- package/lib/chain/seenCache/seenGossipBlockInput.js +2 -2
- package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +38 -0
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -0
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +76 -0
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -0
- package/lib/chain/serializeState.d.ts +2 -2
- package/lib/chain/serializeState.d.ts.map +1 -1
- package/lib/chain/serializeState.js +1 -1
- package/lib/chain/serializeState.js.map +1 -1
- package/lib/chain/shufflingCache.d.ts +2 -2
- package/lib/chain/shufflingCache.d.ts.map +1 -1
- package/lib/chain/shufflingCache.js +3 -4
- package/lib/chain/shufflingCache.js.map +1 -1
- package/lib/chain/stateCache/datastore/db.d.ts +4 -5
- package/lib/chain/stateCache/datastore/db.d.ts.map +1 -1
- package/lib/chain/stateCache/datastore/db.js +32 -10
- 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 +13 -10
- package/lib/chain/stateCache/fifoBlockStateCache.d.ts.map +1 -1
- package/lib/chain/stateCache/fifoBlockStateCache.js +8 -3
- package/lib/chain/stateCache/fifoBlockStateCache.js.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +36 -17
- package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.js +228 -134
- package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
- package/lib/chain/stateCache/types.d.ts +23 -16
- package/lib/chain/stateCache/types.d.ts.map +1 -1
- package/lib/chain/stateCache/types.js.map +1 -1
- package/lib/chain/validation/attesterSlashing.js +3 -3
- package/lib/chain/validation/attesterSlashing.js.map +1 -1
- package/lib/chain/validation/blobSidecar.js +1 -1
- package/lib/chain/validation/blobSidecar.js.map +1 -1
- package/lib/chain/validation/block.d.ts.map +1 -1
- package/lib/chain/validation/block.js +3 -3
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/chain/validation/blsToExecutionChange.js +2 -2
- package/lib/chain/validation/blsToExecutionChange.js.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.js +1 -1
- package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
- package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/validation/executionPayloadBid.js +4 -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 +29 -19
- package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
- package/lib/chain/validation/lightClientFinalityUpdate.js +1 -1
- package/lib/chain/validation/lightClientFinalityUpdate.js.map +1 -1
- package/lib/chain/validation/lightClientOptimisticUpdate.js +1 -1
- package/lib/chain/validation/lightClientOptimisticUpdate.js.map +1 -1
- package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
- package/lib/chain/validation/payloadAttestationMessage.js +1 -2
- package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
- package/lib/chain/validation/proposerSlashing.js +1 -1
- package/lib/chain/validation/proposerSlashing.js.map +1 -1
- package/lib/chain/validation/signatureSets/contributionAndProof.d.ts +2 -2
- package/lib/chain/validation/signatureSets/contributionAndProof.d.ts.map +1 -1
- package/lib/chain/validation/signatureSets/contributionAndProof.js +1 -1
- package/lib/chain/validation/signatureSets/contributionAndProof.js.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommittee.d.ts +2 -2
- package/lib/chain/validation/signatureSets/syncCommittee.d.ts.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommittee.js +1 -1
- package/lib/chain/validation/signatureSets/syncCommittee.js.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts +2 -2
- package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommitteeContribution.js.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts +2 -2
- package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js +1 -1
- package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js.map +1 -1
- package/lib/chain/validation/syncCommittee.d.ts +4 -4
- package/lib/chain/validation/syncCommittee.d.ts.map +1 -1
- package/lib/chain/validation/syncCommittee.js +13 -12
- package/lib/chain/validation/syncCommittee.js.map +1 -1
- package/lib/chain/validation/syncCommitteeContributionAndProof.d.ts.map +1 -1
- package/lib/chain/validation/syncCommitteeContributionAndProof.js +1 -1
- package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
- package/lib/chain/validation/voluntaryExit.d.ts.map +1 -1
- package/lib/chain/validation/voluntaryExit.js +3 -3
- package/lib/chain/validation/voluntaryExit.js.map +1 -1
- package/lib/chain/validatorMonitor.d.ts +5 -4
- package/lib/chain/validatorMonitor.d.ts.map +1 -1
- package/lib/chain/validatorMonitor.js +13 -8
- package/lib/chain/validatorMonitor.js.map +1 -1
- package/lib/execution/engine/interface.d.ts +2 -2
- package/lib/metrics/metrics/lodestar.d.ts +40 -4
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +93 -15
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/gossip/encoding.d.ts.map +1 -1
- package/lib/network/gossip/encoding.js +15 -0
- package/lib/network/gossip/encoding.js.map +1 -1
- package/lib/network/interface.d.ts +4 -2
- package/lib/network/interface.d.ts.map +1 -1
- package/lib/network/network.d.ts +4 -2
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js +11 -5
- package/lib/network/network.js.map +1 -1
- package/lib/network/processor/extractSlotRootFns.d.ts +1 -1
- package/lib/network/processor/extractSlotRootFns.d.ts.map +1 -1
- package/lib/network/processor/extractSlotRootFns.js +15 -5
- package/lib/network/processor/extractSlotRootFns.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +39 -9
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/index.d.ts +12 -7
- package/lib/network/processor/index.d.ts.map +1 -1
- package/lib/network/processor/index.js +99 -78
- package/lib/network/processor/index.js.map +1 -1
- package/lib/network/reqresp/ReqRespBeaconNode.d.ts +1 -1
- package/lib/network/reqresp/ReqRespBeaconNode.d.ts.map +1 -1
- package/lib/network/reqresp/ReqRespBeaconNode.js +10 -1
- package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts +8 -0
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -0
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +69 -0
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -0
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.d.ts +6 -0
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.d.ts.map +1 -0
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js +28 -0
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js.map +1 -0
- package/lib/network/reqresp/handlers/index.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/index.js +11 -1
- package/lib/network/reqresp/handlers/index.js.map +1 -1
- package/lib/network/reqresp/protocols.d.ts +2 -0
- package/lib/network/reqresp/protocols.d.ts.map +1 -1
- package/lib/network/reqresp/protocols.js +10 -0
- package/lib/network/reqresp/protocols.js.map +1 -1
- package/lib/network/reqresp/rateLimit.d.ts.map +1 -1
- package/lib/network/reqresp/rateLimit.js +8 -0
- package/lib/network/reqresp/rateLimit.js.map +1 -1
- package/lib/network/reqresp/score.d.ts.map +1 -1
- package/lib/network/reqresp/score.js +2 -0
- package/lib/network/reqresp/score.js.map +1 -1
- package/lib/network/reqresp/types.d.ts +8 -2
- package/lib/network/reqresp/types.d.ts.map +1 -1
- package/lib/network/reqresp/types.js +7 -1
- package/lib/network/reqresp/types.js.map +1 -1
- package/lib/node/nodejs.d.ts +2 -2
- package/lib/node/nodejs.d.ts.map +1 -1
- package/lib/node/nodejs.js +1 -4
- package/lib/node/nodejs.js.map +1 -1
- package/lib/node/notifier.d.ts.map +1 -1
- package/lib/node/notifier.js +3 -3
- package/lib/node/notifier.js.map +1 -1
- package/lib/sync/backfill/backfill.d.ts +3 -3
- package/lib/sync/backfill/backfill.d.ts.map +1 -1
- package/lib/sync/backfill/backfill.js +3 -3
- package/lib/sync/backfill/backfill.js.map +1 -1
- package/lib/sync/constants.d.ts +1 -1
- package/lib/sync/constants.js +1 -1
- package/lib/sync/unknownBlock.d.ts +3 -9
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +8 -41
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/util/sszBytes.d.ts +4 -1
- package/lib/util/sszBytes.d.ts.map +1 -1
- package/lib/util/sszBytes.js +69 -12
- package/lib/util/sszBytes.js.map +1 -1
- package/lib/util/types.d.ts +2 -0
- package/lib/util/types.d.ts.map +1 -1
- package/lib/util/types.js +1 -0
- package/lib/util/types.js.map +1 -1
- package/package.json +15 -15
- package/src/api/impl/beacon/blocks/index.ts +37 -18
- package/src/api/impl/beacon/pool/index.ts +1 -1
- package/src/api/impl/beacon/state/index.ts +29 -41
- package/src/api/impl/beacon/state/utils.ts +13 -27
- package/src/api/impl/lodestar/index.ts +4 -8
- package/src/api/impl/proof/index.ts +2 -9
- package/src/api/impl/validator/index.ts +35 -43
- package/src/api/impl/validator/utils.ts +4 -7
- package/src/chain/archiveStore/archiveStore.ts +0 -10
- package/src/chain/archiveStore/historicalState/getHistoricalState.ts +6 -36
- package/src/chain/archiveStore/historicalState/worker.ts +1 -0
- package/src/chain/archiveStore/interface.ts +4 -4
- package/src/chain/archiveStore/strategies/frequencyStateArchiveStrategy.ts +8 -5
- package/src/chain/archiveStore/utils/archiveBlocks.ts +59 -1
- package/src/chain/balancesCache.ts +5 -11
- package/src/chain/blocks/blockInput/types.ts +4 -3
- package/src/chain/blocks/importBlock.ts +58 -22
- package/src/chain/blocks/importExecutionPayload.ts +236 -0
- package/src/chain/blocks/index.ts +1 -1
- package/src/chain/blocks/payloadEnvelopeInput/index.ts +2 -0
- package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +336 -0
- package/src/chain/blocks/payloadEnvelopeInput/types.ts +33 -0
- package/src/chain/blocks/payloadEnvelopeProcessor.ts +61 -0
- package/src/chain/blocks/types.ts +10 -2
- package/src/chain/blocks/utils/checkpoint.ts +2 -2
- package/src/chain/blocks/verifyBlock.ts +5 -10
- package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +5 -10
- package/src/chain/blocks/verifyBlocksSignatures.ts +4 -4
- package/src/chain/blocks/verifyBlocksStateTransitionOnly.ts +6 -8
- package/src/chain/blocks/writePayloadEnvelopeInputToDb.ts +55 -0
- package/src/chain/chain.ts +134 -81
- package/src/chain/emitter.ts +2 -2
- package/src/chain/errors/blockError.ts +4 -4
- package/src/chain/errors/executionPayloadEnvelope.ts +6 -2
- package/src/chain/forkChoice/index.ts +33 -52
- package/src/chain/initState.ts +7 -2
- package/src/chain/interface.ts +20 -18
- package/src/chain/lightClient/index.ts +9 -22
- package/src/chain/opPools/aggregatedAttestationPool.ts +15 -21
- package/src/chain/opPools/opPool.ts +13 -14
- package/src/chain/opPools/utils.ts +4 -4
- package/src/chain/prepareNextSlot.ts +12 -10
- package/src/chain/produceBlock/computeNewStateRoot.ts +11 -10
- package/src/chain/produceBlock/produceBlockBody.ts +23 -50
- package/src/chain/regen/errors.ts +6 -1
- package/src/chain/regen/interface.ts +22 -18
- package/src/chain/regen/queued.ts +59 -27
- package/src/chain/regen/regen.ts +52 -23
- package/src/chain/seenCache/index.ts +1 -1
- package/src/chain/seenCache/seenGossipBlockInput.ts +2 -2
- package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +106 -0
- package/src/chain/serializeState.ts +3 -3
- package/src/chain/shufflingCache.ts +5 -7
- package/src/chain/stateCache/datastore/db.ts +33 -10
- package/src/chain/stateCache/datastore/file.ts +6 -5
- package/src/chain/stateCache/datastore/types.ts +3 -2
- package/src/chain/stateCache/fifoBlockStateCache.ts +17 -11
- package/src/chain/stateCache/persistentCheckpointsCache.ts +266 -172
- package/src/chain/stateCache/types.ts +22 -16
- package/src/chain/validation/attesterSlashing.ts +3 -3
- package/src/chain/validation/blobSidecar.ts +1 -1
- package/src/chain/validation/block.ts +2 -4
- package/src/chain/validation/blsToExecutionChange.ts +2 -2
- package/src/chain/validation/dataColumnSidecar.ts +1 -1
- package/src/chain/validation/executionPayloadBid.ts +3 -7
- package/src/chain/validation/executionPayloadEnvelope.ts +36 -29
- package/src/chain/validation/lightClientFinalityUpdate.ts +1 -1
- package/src/chain/validation/lightClientOptimisticUpdate.ts +1 -1
- package/src/chain/validation/payloadAttestationMessage.ts +2 -4
- package/src/chain/validation/proposerSlashing.ts +1 -1
- package/src/chain/validation/signatureSets/contributionAndProof.ts +2 -7
- package/src/chain/validation/signatureSets/syncCommittee.ts +2 -7
- package/src/chain/validation/signatureSets/syncCommitteeContribution.ts +2 -2
- package/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts +2 -7
- package/src/chain/validation/syncCommittee.ts +21 -20
- package/src/chain/validation/syncCommitteeContributionAndProof.ts +5 -10
- package/src/chain/validation/voluntaryExit.ts +3 -7
- package/src/chain/validatorMonitor.ts +23 -12
- package/src/execution/engine/interface.ts +2 -2
- package/src/metrics/metrics/lodestar.ts +100 -19
- package/src/network/gossip/encoding.ts +16 -0
- package/src/network/interface.ts +15 -2
- package/src/network/network.ts +34 -6
- package/src/network/processor/extractSlotRootFns.ts +19 -6
- package/src/network/processor/gossipHandlers.ts +45 -8
- package/src/network/processor/index.ts +110 -89
- package/src/network/reqresp/ReqRespBeaconNode.ts +14 -1
- package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +94 -0
- package/src/network/reqresp/handlers/executionPayloadEnvelopesByRoot.ts +43 -0
- package/src/network/reqresp/handlers/index.ts +12 -0
- package/src/network/reqresp/protocols.ts +12 -0
- package/src/network/reqresp/rateLimit.ts +18 -0
- package/src/network/reqresp/score.ts +2 -0
- package/src/network/reqresp/types.ts +13 -0
- package/src/node/nodejs.ts +3 -5
- package/src/node/notifier.ts +4 -10
- package/src/sync/backfill/backfill.ts +4 -4
- package/src/sync/constants.ts +1 -1
- package/src/sync/unknownBlock.ts +10 -50
- package/src/util/sszBytes.ts +90 -10
- package/src/util/types.ts +6 -0
- package/lib/chain/archiveStore/utils/archivePayloads.d.ts +0 -7
- package/lib/chain/archiveStore/utils/archivePayloads.d.ts.map +0 -1
- package/lib/chain/archiveStore/utils/archivePayloads.js +0 -10
- package/lib/chain/archiveStore/utils/archivePayloads.js.map +0 -1
- package/lib/chain/seenCache/seenExecutionPayloadEnvelope.d.ts +0 -15
- package/lib/chain/seenCache/seenExecutionPayloadEnvelope.d.ts.map +0 -1
- package/lib/chain/seenCache/seenExecutionPayloadEnvelope.js +0 -28
- package/lib/chain/seenCache/seenExecutionPayloadEnvelope.js.map +0 -1
- package/src/chain/archiveStore/utils/archivePayloads.ts +0 -15
- package/src/chain/seenCache/seenExecutionPayloadEnvelope.ts +0 -34
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {routes} from "@lodestar/api";
|
|
2
|
-
import {IForkChoice, ProtoBlock} from "@lodestar/fork-choice";
|
|
3
|
-
import {
|
|
2
|
+
import {IForkChoice, PayloadStatus, ProtoBlock} from "@lodestar/fork-choice";
|
|
3
|
+
import {IBeaconStateView, computeEpochAtSlot} from "@lodestar/state-transition";
|
|
4
4
|
import {BeaconBlock, Epoch, RootHex, Slot, isGloasBeaconBlock, phase0} from "@lodestar/types";
|
|
5
|
-
import {Logger, toRootHex} from "@lodestar/utils";
|
|
5
|
+
import {Logger, fromHex, toRootHex} from "@lodestar/utils";
|
|
6
6
|
import {Metrics} from "../../metrics/index.js";
|
|
7
7
|
import {JobItemQueue} from "../../util/queue/index.js";
|
|
8
|
-
import {BlockStateCache,
|
|
8
|
+
import {BlockStateCache, CheckpointHexPayload, CheckpointStateCache} from "../stateCache/types.js";
|
|
9
9
|
import {RegenError, RegenErrorCode} from "./errors.js";
|
|
10
10
|
import {
|
|
11
11
|
IStateRegenerator,
|
|
@@ -34,7 +34,7 @@ export type RegenRequest = RegenRequestByKey[RegenRequestKey];
|
|
|
34
34
|
* All requests are queued so that only a single state at a time may be regenerated at a time
|
|
35
35
|
*/
|
|
36
36
|
export class QueuedStateRegenerator implements IStateRegenerator {
|
|
37
|
-
readonly jobQueue: JobItemQueue<[RegenRequest],
|
|
37
|
+
readonly jobQueue: JobItemQueue<[RegenRequest], IBeaconStateView>;
|
|
38
38
|
private readonly regen: StateRegenerator;
|
|
39
39
|
|
|
40
40
|
private readonly forkChoice: IForkChoice;
|
|
@@ -45,7 +45,7 @@ export class QueuedStateRegenerator implements IStateRegenerator {
|
|
|
45
45
|
|
|
46
46
|
constructor(modules: QueuedStateRegeneratorModules) {
|
|
47
47
|
this.regen = new StateRegenerator(modules);
|
|
48
|
-
this.jobQueue = new JobItemQueue<[RegenRequest],
|
|
48
|
+
this.jobQueue = new JobItemQueue<[RegenRequest], IBeaconStateView>(
|
|
49
49
|
this.jobQueueProcessor,
|
|
50
50
|
{maxLength: REGEN_QUEUE_MAX_LEN, signal: modules.signal},
|
|
51
51
|
modules.metrics ? modules.metrics.regenQueue : undefined
|
|
@@ -79,14 +79,14 @@ export class QueuedStateRegenerator implements IStateRegenerator {
|
|
|
79
79
|
/**
|
|
80
80
|
* Get a state from block state cache.
|
|
81
81
|
*/
|
|
82
|
-
getStateSync(stateRoot: RootHex):
|
|
82
|
+
getStateSync(stateRoot: RootHex): IBeaconStateView | null {
|
|
83
83
|
return this.blockStateCache.get(stateRoot);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
87
|
* Get state for block processing.
|
|
88
88
|
*/
|
|
89
|
-
getPreStateSync(block: BeaconBlock):
|
|
89
|
+
getPreStateSync(block: BeaconBlock): IBeaconStateView | null {
|
|
90
90
|
const parentRoot = toRootHex(block.parentRoot);
|
|
91
91
|
const parentBlock = isGloasBeaconBlock(block)
|
|
92
92
|
? this.forkChoice.getBlockHexAndBlockHash(
|
|
@@ -104,9 +104,19 @@ export class QueuedStateRegenerator implements IStateRegenerator {
|
|
|
104
104
|
const parentEpoch = computeEpochAtSlot(parentBlock.slot);
|
|
105
105
|
const blockEpoch = computeEpochAtSlot(block.slot);
|
|
106
106
|
|
|
107
|
+
// Convert PayloadStatus to payloadPresent boolean
|
|
108
|
+
if (parentBlock.payloadStatus === PayloadStatus.PENDING) {
|
|
109
|
+
throw new RegenError({
|
|
110
|
+
code: RegenErrorCode.UNEXPECTED_PAYLOAD_STATUS,
|
|
111
|
+
blockRoot: block.parentRoot,
|
|
112
|
+
payloadStatus: parentBlock.payloadStatus,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
const payloadPresent = parentBlock.payloadStatus === PayloadStatus.FULL;
|
|
116
|
+
|
|
107
117
|
// Check the checkpoint cache (if the pre-state is a checkpoint state)
|
|
108
118
|
if (parentEpoch < blockEpoch) {
|
|
109
|
-
const checkpointState = this.checkpointStateCache.getLatest(parentRoot, blockEpoch);
|
|
119
|
+
const checkpointState = this.checkpointStateCache.getLatest(parentRoot, blockEpoch, payloadPresent);
|
|
110
120
|
if (checkpointState && computeEpochAtSlot(checkpointState.slot) === blockEpoch) {
|
|
111
121
|
return checkpointState;
|
|
112
122
|
}
|
|
@@ -125,22 +135,34 @@ export class QueuedStateRegenerator implements IStateRegenerator {
|
|
|
125
135
|
return null;
|
|
126
136
|
}
|
|
127
137
|
|
|
128
|
-
async getCheckpointStateOrBytes(cp:
|
|
138
|
+
async getCheckpointStateOrBytes(cp: CheckpointHexPayload): Promise<IBeaconStateView | Uint8Array | null> {
|
|
129
139
|
return this.checkpointStateCache.getStateOrBytes(cp);
|
|
130
140
|
}
|
|
131
141
|
|
|
132
142
|
/**
|
|
133
143
|
* Get checkpoint state from cache
|
|
134
144
|
*/
|
|
135
|
-
getCheckpointStateSync(cp:
|
|
145
|
+
getCheckpointStateSync(cp: CheckpointHexPayload): IBeaconStateView | null {
|
|
136
146
|
return this.checkpointStateCache.get(cp);
|
|
137
147
|
}
|
|
138
148
|
|
|
139
149
|
/**
|
|
140
150
|
* Get state closest to head
|
|
141
151
|
*/
|
|
142
|
-
getClosestHeadState(head: ProtoBlock):
|
|
143
|
-
|
|
152
|
+
getClosestHeadState(head: ProtoBlock): IBeaconStateView | null {
|
|
153
|
+
// Convert PayloadStatus to payloadPresent boolean
|
|
154
|
+
if (head.payloadStatus === PayloadStatus.PENDING) {
|
|
155
|
+
throw new RegenError({
|
|
156
|
+
code: RegenErrorCode.UNEXPECTED_PAYLOAD_STATUS,
|
|
157
|
+
blockRoot: fromHex(head.blockRoot),
|
|
158
|
+
payloadStatus: head.payloadStatus,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
const payloadPresent = head.payloadStatus === PayloadStatus.FULL;
|
|
162
|
+
return (
|
|
163
|
+
this.checkpointStateCache.getLatest(head.blockRoot, Infinity, payloadPresent) ||
|
|
164
|
+
this.blockStateCache.get(head.stateRoot)
|
|
165
|
+
);
|
|
144
166
|
}
|
|
145
167
|
|
|
146
168
|
pruneOnCheckpoint(finalizedEpoch: Epoch, justifiedEpoch: Epoch, headStateRoot: RootHex): void {
|
|
@@ -153,18 +175,27 @@ export class QueuedStateRegenerator implements IStateRegenerator {
|
|
|
153
175
|
this.blockStateCache.deleteAllBeforeEpoch(finalizedEpoch);
|
|
154
176
|
}
|
|
155
177
|
|
|
156
|
-
|
|
178
|
+
processBlockState(blockRootHex: RootHex, postState: IBeaconStateView): void {
|
|
157
179
|
this.blockStateCache.add(postState);
|
|
158
180
|
this.checkpointStateCache.processState(blockRootHex, postState).catch((e) => {
|
|
159
181
|
this.logger.debug("Error processing block state", {blockRootHex, slot: postState.slot}, e);
|
|
160
182
|
});
|
|
161
183
|
}
|
|
162
184
|
|
|
163
|
-
|
|
164
|
-
|
|
185
|
+
/**
|
|
186
|
+
* Process payload state for caching after importing execution payload.
|
|
187
|
+
*/
|
|
188
|
+
processPayloadState(payloadState: IBeaconStateView): void {
|
|
189
|
+
// Add payload state to block state cache (keyed by payload state root)
|
|
190
|
+
this.blockStateCache.add(payloadState);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// TODO GLOAS: This should also be called when importing execution payload after we implement it
|
|
194
|
+
addCheckpointState(cp: phase0.Checkpoint, item: IBeaconStateView, payloadPresent: boolean): void {
|
|
195
|
+
this.checkpointStateCache.add(cp, item, payloadPresent);
|
|
165
196
|
}
|
|
166
197
|
|
|
167
|
-
updateHeadState(newHead: ProtoBlock, maybeHeadState:
|
|
198
|
+
updateHeadState(newHead: ProtoBlock, maybeHeadState: IBeaconStateView): void {
|
|
168
199
|
const {stateRoot: newHeadStateRoot, blockRoot: newHeadBlockRoot, slot: newHeadSlot} = newHead;
|
|
169
200
|
const maybeHeadStateRoot = toRootHex(maybeHeadState.hashTreeRoot());
|
|
170
201
|
const logCtx = {
|
|
@@ -197,19 +228,20 @@ export class QueuedStateRegenerator implements IStateRegenerator {
|
|
|
197
228
|
}
|
|
198
229
|
}
|
|
199
230
|
|
|
200
|
-
updatePreComputedCheckpoint(rootHex: RootHex, epoch: Epoch): number | null {
|
|
201
|
-
return this.checkpointStateCache.updatePreComputedCheckpoint(rootHex, epoch);
|
|
231
|
+
updatePreComputedCheckpoint(rootHex: RootHex, epoch: Epoch, payloadPresent: boolean): number | null {
|
|
232
|
+
return this.checkpointStateCache.updatePreComputedCheckpoint(rootHex, epoch, payloadPresent);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
upgradeForGloas(epoch: Epoch): void {
|
|
236
|
+
this.logger.verbose("Upgrading block state cache for Gloas fork", {epoch});
|
|
237
|
+
this.blockStateCache.upgradeToGloas();
|
|
202
238
|
}
|
|
203
239
|
|
|
204
240
|
/**
|
|
205
241
|
* Get the state to run with `block`.
|
|
206
242
|
* - State after `block.parentRoot` dialed forward to block.slot
|
|
207
243
|
*/
|
|
208
|
-
async getPreState(
|
|
209
|
-
block: BeaconBlock,
|
|
210
|
-
opts: StateRegenerationOpts,
|
|
211
|
-
rCaller: RegenCaller
|
|
212
|
-
): Promise<CachedBeaconStateAllForks> {
|
|
244
|
+
async getPreState(block: BeaconBlock, opts: StateRegenerationOpts, rCaller: RegenCaller): Promise<IBeaconStateView> {
|
|
213
245
|
this.metrics?.regenFnCallTotal.inc({caller: rCaller, entrypoint: RegenFnName.getPreState});
|
|
214
246
|
|
|
215
247
|
// First attempt to fetch the state from caches before queueing
|
|
@@ -235,14 +267,14 @@ export class QueuedStateRegenerator implements IStateRegenerator {
|
|
|
235
267
|
slot: Slot,
|
|
236
268
|
opts: StateRegenerationOpts,
|
|
237
269
|
rCaller: RegenCaller
|
|
238
|
-
): Promise<
|
|
270
|
+
): Promise<IBeaconStateView> {
|
|
239
271
|
this.metrics?.regenFnCallTotal.inc({caller: rCaller, entrypoint: RegenFnName.getBlockSlotState});
|
|
240
272
|
|
|
241
273
|
// The state is not immediately available in the caches, enqueue the job
|
|
242
274
|
return this.jobQueue.push({key: "getBlockSlotState", args: [block, slot, opts, rCaller]});
|
|
243
275
|
}
|
|
244
276
|
|
|
245
|
-
async getState(stateRoot: RootHex, rCaller: RegenCaller): Promise<
|
|
277
|
+
async getState(stateRoot: RootHex, rCaller: RegenCaller): Promise<IBeaconStateView> {
|
|
246
278
|
this.metrics?.regenFnCallTotal.inc({caller: rCaller, entrypoint: RegenFnName.getState});
|
|
247
279
|
|
|
248
280
|
// First attempt to fetch the state from cache before queueing
|
|
@@ -256,7 +288,7 @@ export class QueuedStateRegenerator implements IStateRegenerator {
|
|
|
256
288
|
return this.jobQueue.push({key: "getState", args: [stateRoot, rCaller]});
|
|
257
289
|
}
|
|
258
290
|
|
|
259
|
-
private jobQueueProcessor = async (regenRequest: RegenRequest): Promise<
|
|
291
|
+
private jobQueueProcessor = async (regenRequest: RegenRequest): Promise<IBeaconStateView> => {
|
|
260
292
|
const metricsLabels = {
|
|
261
293
|
caller: regenRequest.args.at(-1) as RegenCaller,
|
|
262
294
|
entrypoint: regenRequest.key as RegenFnName,
|
package/src/chain/regen/regen.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import {ChainForkConfig} from "@lodestar/config";
|
|
2
|
-
import {IForkChoice, ProtoBlock} from "@lodestar/fork-choice";
|
|
3
|
-
import {SLOTS_PER_EPOCH} from "@lodestar/params";
|
|
2
|
+
import {IForkChoice, PayloadStatus, ProtoBlock} from "@lodestar/fork-choice";
|
|
3
|
+
import {ForkSeq, SLOTS_PER_EPOCH} from "@lodestar/params";
|
|
4
4
|
import {
|
|
5
|
-
CachedBeaconStateAllForks,
|
|
6
5
|
DataAvailabilityStatus,
|
|
7
6
|
ExecutionPayloadStatus,
|
|
7
|
+
IBeaconStateView,
|
|
8
8
|
StateHashTreeRootSource,
|
|
9
9
|
computeEpochAtSlot,
|
|
10
10
|
computeStartSlotAtEpoch,
|
|
11
|
-
processSlots,
|
|
12
|
-
stateTransition,
|
|
13
11
|
} from "@lodestar/state-transition";
|
|
14
12
|
import {BeaconBlock, RootHex, SignedBeaconBlock, Slot, isGloasBeaconBlock} from "@lodestar/types";
|
|
15
13
|
import {Logger, fromHex, toRootHex} from "@lodestar/utils";
|
|
@@ -57,7 +55,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
|
|
|
57
55
|
block: BeaconBlock,
|
|
58
56
|
opts: StateRegenerationOpts,
|
|
59
57
|
regenCaller: RegenCaller
|
|
60
|
-
): Promise<
|
|
58
|
+
): Promise<IBeaconStateView> {
|
|
61
59
|
const parentRoot = toRootHex(block.parentRoot);
|
|
62
60
|
const parentBlock = isGloasBeaconBlock(block)
|
|
63
61
|
? this.modules.forkChoice.getBlockHexAndBlockHash(
|
|
@@ -99,7 +97,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
|
|
|
99
97
|
opts: StateRegenerationOpts,
|
|
100
98
|
regenCaller: RegenCaller,
|
|
101
99
|
allowDiskReload = false
|
|
102
|
-
): Promise<
|
|
100
|
+
): Promise<IBeaconStateView> {
|
|
103
101
|
if (slot < block.slot) {
|
|
104
102
|
throw new RegenError({
|
|
105
103
|
code: RegenErrorCode.SLOT_BEFORE_BLOCK_SLOT,
|
|
@@ -111,9 +109,20 @@ export class StateRegenerator implements IStateRegeneratorInternal {
|
|
|
111
109
|
const {blockRoot} = block;
|
|
112
110
|
const {checkpointStateCache} = this.modules;
|
|
113
111
|
const epoch = computeEpochAtSlot(slot);
|
|
112
|
+
|
|
113
|
+
// Convert PayloadStatus to payloadPresent boolean
|
|
114
|
+
if (block.payloadStatus === PayloadStatus.PENDING) {
|
|
115
|
+
throw new RegenError({
|
|
116
|
+
code: RegenErrorCode.UNEXPECTED_PAYLOAD_STATUS,
|
|
117
|
+
blockRoot: fromHex(blockRoot),
|
|
118
|
+
payloadStatus: block.payloadStatus,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
const payloadPresent = block.payloadStatus === PayloadStatus.FULL;
|
|
122
|
+
|
|
114
123
|
const latestCheckpointStateCtx = allowDiskReload
|
|
115
|
-
? await checkpointStateCache.getOrReloadLatest(blockRoot, epoch)
|
|
116
|
-
: checkpointStateCache.getLatest(blockRoot, epoch);
|
|
124
|
+
? await checkpointStateCache.getOrReloadLatest(blockRoot, epoch, payloadPresent)
|
|
125
|
+
: checkpointStateCache.getLatest(blockRoot, epoch, payloadPresent);
|
|
117
126
|
|
|
118
127
|
// If a checkpoint state exists with the given checkpoint root, it either is in requested epoch
|
|
119
128
|
// or needs to have empty slots processed until the requested epoch
|
|
@@ -138,7 +147,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
|
|
|
138
147
|
caller: RegenCaller,
|
|
139
148
|
// internal option, don't want to expose to external caller
|
|
140
149
|
allowDiskReload = false
|
|
141
|
-
): Promise<
|
|
150
|
+
): Promise<IBeaconStateView> {
|
|
142
151
|
// Trivial case, state at stateRoot is already cached
|
|
143
152
|
const cachedStateCtx = this.modules.blockStateCache.get(stateRoot);
|
|
144
153
|
if (cachedStateCtx) {
|
|
@@ -153,7 +162,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
|
|
|
153
162
|
// blocks to replay, ordered highest to lowest
|
|
154
163
|
// gets reversed when replayed
|
|
155
164
|
const blocksToReplay = [block];
|
|
156
|
-
let state:
|
|
165
|
+
let state: IBeaconStateView | null = null;
|
|
157
166
|
const {checkpointStateCache} = this.modules;
|
|
158
167
|
|
|
159
168
|
const getSeedStateTimer = this.modules.metrics?.regenGetState.getSeedState.startTimer({caller});
|
|
@@ -166,9 +175,19 @@ export class StateRegenerator implements IStateRegeneratorInternal {
|
|
|
166
175
|
const lastBlockToReplay = blocksToReplay.at(-1);
|
|
167
176
|
if (!lastBlockToReplay) continue;
|
|
168
177
|
const epoch = computeEpochAtSlot(lastBlockToReplay.slot - 1);
|
|
178
|
+
|
|
179
|
+
// Convert PayloadStatus to payloadPresent boolean
|
|
180
|
+
if (b.payloadStatus === PayloadStatus.PENDING) {
|
|
181
|
+
throw new RegenError({
|
|
182
|
+
code: RegenErrorCode.INTERNAL_ERROR,
|
|
183
|
+
message: `Unexpected PENDING payloadStatus for ancestor block ${b.blockRoot} at slot ${b.slot}`,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
const payloadPresent = b.payloadStatus === PayloadStatus.FULL;
|
|
187
|
+
|
|
169
188
|
state = allowDiskReload
|
|
170
|
-
? await checkpointStateCache.getOrReloadLatest(b.blockRoot, epoch)
|
|
171
|
-
: checkpointStateCache.getLatest(b.blockRoot, epoch);
|
|
189
|
+
? await checkpointStateCache.getOrReloadLatest(b.blockRoot, epoch, payloadPresent)
|
|
190
|
+
: checkpointStateCache.getLatest(b.blockRoot, epoch, payloadPresent);
|
|
172
191
|
if (state) {
|
|
173
192
|
break;
|
|
174
193
|
}
|
|
@@ -239,8 +258,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
|
|
|
239
258
|
// Only advances state trusting block's signture and hashes.
|
|
240
259
|
// We are only running the state transition to get a specific state's data.
|
|
241
260
|
// stateTransition() does the clone() inside, transfer cache to make the regen faster
|
|
242
|
-
state = stateTransition(
|
|
243
|
-
state,
|
|
261
|
+
state = state.stateTransition(
|
|
244
262
|
block,
|
|
245
263
|
{
|
|
246
264
|
// Replay previously imported blocks, assume valid and available
|
|
@@ -312,16 +330,17 @@ async function processSlotsByCheckpoint(
|
|
|
312
330
|
metrics: Metrics | null;
|
|
313
331
|
validatorMonitor: ValidatorMonitor | null;
|
|
314
332
|
emitter: ChainEventEmitter;
|
|
333
|
+
config: ChainForkConfig;
|
|
315
334
|
logger: Logger;
|
|
316
335
|
},
|
|
317
|
-
preState:
|
|
336
|
+
preState: IBeaconStateView,
|
|
318
337
|
slot: Slot,
|
|
319
338
|
regenCaller: RegenCaller,
|
|
320
339
|
opts: StateRegenerationOpts
|
|
321
|
-
): Promise<
|
|
340
|
+
): Promise<IBeaconStateView> {
|
|
322
341
|
let postState = await processSlotsToNearestCheckpoint(modules, preState, slot, regenCaller, opts);
|
|
323
342
|
if (postState.slot < slot) {
|
|
324
|
-
postState = processSlots(
|
|
343
|
+
postState = postState.processSlots(slot, opts, modules);
|
|
325
344
|
}
|
|
326
345
|
return postState;
|
|
327
346
|
}
|
|
@@ -332,6 +351,11 @@ async function processSlotsByCheckpoint(
|
|
|
332
351
|
* emitting "checkpoint" events after every epoch processed.
|
|
333
352
|
*
|
|
334
353
|
* Stops processing after no more full epochs can be processed.
|
|
354
|
+
*
|
|
355
|
+
* Output state variant:
|
|
356
|
+
* - Post-Gloas: If slots are processed, returns block state (payloadPresent=false).
|
|
357
|
+
* If no slots processed, returns preState as-is (preserves variant).
|
|
358
|
+
* - Pre-Gloas: Always payloadPresent=true (no block/payload distinction).
|
|
335
359
|
*/
|
|
336
360
|
export async function processSlotsToNearestCheckpoint(
|
|
337
361
|
modules: {
|
|
@@ -339,18 +363,19 @@ export async function processSlotsToNearestCheckpoint(
|
|
|
339
363
|
metrics: Metrics | null;
|
|
340
364
|
validatorMonitor: ValidatorMonitor | null;
|
|
341
365
|
emitter: ChainEventEmitter | null;
|
|
366
|
+
config: ChainForkConfig;
|
|
342
367
|
logger: Logger | null;
|
|
343
368
|
},
|
|
344
|
-
preState:
|
|
369
|
+
preState: IBeaconStateView,
|
|
345
370
|
slot: Slot,
|
|
346
371
|
regenCaller: RegenCaller,
|
|
347
372
|
opts: StateRegenerationOpts
|
|
348
|
-
): Promise<
|
|
373
|
+
): Promise<IBeaconStateView> {
|
|
349
374
|
const preSlot = preState.slot;
|
|
350
375
|
const postSlot = slot;
|
|
351
376
|
const preEpoch = computeEpochAtSlot(preSlot);
|
|
352
377
|
let postState = preState;
|
|
353
|
-
const {checkpointStateCache, emitter, metrics, logger} = modules;
|
|
378
|
+
const {config, checkpointStateCache, emitter, metrics, logger} = modules;
|
|
354
379
|
let count = 0;
|
|
355
380
|
|
|
356
381
|
for (
|
|
@@ -365,7 +390,7 @@ export async function processSlotsToNearestCheckpoint(
|
|
|
365
390
|
caller: regenCaller,
|
|
366
391
|
});
|
|
367
392
|
// processSlots calls .clone() before mutating
|
|
368
|
-
postState = processSlots(
|
|
393
|
+
postState = postState.processSlots(nextEpochSlot, opts, modules);
|
|
369
394
|
metrics?.epochTransitionByCaller.inc({caller: regenCaller});
|
|
370
395
|
|
|
371
396
|
// this is usually added when we prepare for next slot or validate gossip block
|
|
@@ -374,7 +399,11 @@ export async function processSlotsToNearestCheckpoint(
|
|
|
374
399
|
// This may becomes the "official" checkpoint state if the 1st block of epoch is skipped
|
|
375
400
|
const checkpointState = postState;
|
|
376
401
|
const cp = getCheckpointFromState(checkpointState);
|
|
377
|
-
|
|
402
|
+
// processSlots() only does epoch transitions, never processes payloads
|
|
403
|
+
// Pre-Gloas: payloadPresent is always true (execution payload embedded in block)
|
|
404
|
+
// Post-Gloas: result is a block state (payloadPresent=false)
|
|
405
|
+
const isPayloadPresent = config.getForkSeq(checkpointState.slot) < ForkSeq.gloas;
|
|
406
|
+
checkpointStateCache.add(cp, checkpointState, isPayloadPresent);
|
|
378
407
|
// consumers should not mutate state ever
|
|
379
408
|
emitter?.emit(ChainEvent.checkpoint, cp, checkpointState);
|
|
380
409
|
|
|
@@ -3,5 +3,5 @@ export {SeenBlockProposers} from "./seenBlockProposers.js";
|
|
|
3
3
|
export {SeenSyncCommitteeMessages} from "./seenCommittee.js";
|
|
4
4
|
export {SeenContributionAndProof} from "./seenCommitteeContribution.js";
|
|
5
5
|
export {SeenExecutionPayloadBids} from "./seenExecutionPayloadBids.js";
|
|
6
|
-
export {SeenExecutionPayloadEnvelopes} from "./seenExecutionPayloadEnvelope.js";
|
|
7
6
|
export {SeenBlockInput} from "./seenGossipBlockInput.js";
|
|
7
|
+
export {PayloadEnvelopeInput, SeenPayloadEnvelopeInput} from "./seenPayloadEnvelopeInput.js";
|
|
@@ -180,7 +180,7 @@ export class SeenBlockInput {
|
|
|
180
180
|
blockInput = this.blockInputs.get(parentRootHex ?? "");
|
|
181
181
|
parentRootHex = blockInput?.parentRootHex;
|
|
182
182
|
}
|
|
183
|
-
this.logger?.debug(
|
|
183
|
+
this.logger?.debug("BlockInputCache.prune deleted cached BlockInputs", {deletedCount});
|
|
184
184
|
this.pruneToMaxSize();
|
|
185
185
|
}
|
|
186
186
|
|
|
@@ -193,7 +193,7 @@ export class SeenBlockInput {
|
|
|
193
193
|
this.evictBlockInput(blockInput);
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
this.logger?.debug(
|
|
196
|
+
this.logger?.debug("BlockInputCache.onFinalized deleted cached BlockInputs", {deletedCount});
|
|
197
197
|
this.pruneToMaxSize();
|
|
198
198
|
};
|
|
199
199
|
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import {CheckpointWithHex} from "@lodestar/fork-choice";
|
|
2
|
+
import {computeStartSlotAtEpoch} from "@lodestar/state-transition";
|
|
3
|
+
import {RootHex} from "@lodestar/types";
|
|
4
|
+
import {Logger} from "@lodestar/utils";
|
|
5
|
+
import {Metrics} from "../../metrics/metrics.js";
|
|
6
|
+
import {SerializedCache} from "../../util/serializedCache.js";
|
|
7
|
+
import {CreateFromBlockProps, PayloadEnvelopeInput} from "../blocks/payloadEnvelopeInput/index.js";
|
|
8
|
+
import {ChainEvent, ChainEventEmitter} from "../emitter.js";
|
|
9
|
+
|
|
10
|
+
export type {PayloadEnvelopeInputState} from "../blocks/payloadEnvelopeInput/index.js";
|
|
11
|
+
export {PayloadEnvelopeInput} from "../blocks/payloadEnvelopeInput/index.js";
|
|
12
|
+
|
|
13
|
+
export type SeenPayloadEnvelopeInputModules = {
|
|
14
|
+
chainEvents: ChainEventEmitter;
|
|
15
|
+
signal: AbortSignal;
|
|
16
|
+
serializedCache: SerializedCache;
|
|
17
|
+
metrics: Metrics | null;
|
|
18
|
+
logger?: Logger;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Cache for tracking PayloadEnvelopeInput instances, keyed by beacon block root.
|
|
23
|
+
*
|
|
24
|
+
* Created during block import when a block is processed.
|
|
25
|
+
* Pruned on finalization and after payload is written to DB.
|
|
26
|
+
*/
|
|
27
|
+
export class SeenPayloadEnvelopeInput {
|
|
28
|
+
private readonly chainEvents: ChainEventEmitter;
|
|
29
|
+
private readonly signal: AbortSignal;
|
|
30
|
+
private readonly serializedCache: SerializedCache;
|
|
31
|
+
private readonly metrics: Metrics | null;
|
|
32
|
+
private readonly logger?: Logger;
|
|
33
|
+
private payloadInputs = new Map<RootHex, PayloadEnvelopeInput>();
|
|
34
|
+
|
|
35
|
+
constructor({chainEvents, signal, serializedCache, metrics, logger}: SeenPayloadEnvelopeInputModules) {
|
|
36
|
+
this.chainEvents = chainEvents;
|
|
37
|
+
this.signal = signal;
|
|
38
|
+
this.serializedCache = serializedCache;
|
|
39
|
+
this.metrics = metrics;
|
|
40
|
+
this.logger = logger;
|
|
41
|
+
|
|
42
|
+
if (metrics) {
|
|
43
|
+
metrics.seenCache.payloadEnvelopeInput.count.addCollect(() => {
|
|
44
|
+
metrics.seenCache.payloadEnvelopeInput.count.set(this.payloadInputs.size);
|
|
45
|
+
metrics.seenCache.payloadEnvelopeInput.serializedObjectRefs.set(
|
|
46
|
+
Array.from(this.payloadInputs.values()).reduce(
|
|
47
|
+
(count, payloadInput) => count + payloadInput.getSerializedCacheKeys().length,
|
|
48
|
+
0
|
|
49
|
+
)
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
this.chainEvents.on(ChainEvent.forkChoiceFinalized, this.onFinalized);
|
|
55
|
+
this.signal.addEventListener("abort", () => {
|
|
56
|
+
this.chainEvents.off(ChainEvent.forkChoiceFinalized, this.onFinalized);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private onFinalized = (checkpoint: CheckpointWithHex): void => {
|
|
61
|
+
// Prune all entries with slot < finalized slot
|
|
62
|
+
const finalizedSlot = computeStartSlotAtEpoch(checkpoint.epoch);
|
|
63
|
+
let deletedCount = 0;
|
|
64
|
+
for (const [, input] of this.payloadInputs) {
|
|
65
|
+
if (input.slot < finalizedSlot) {
|
|
66
|
+
this.evictPayloadInput(input);
|
|
67
|
+
deletedCount++;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
this.logger?.debug("SeenPayloadEnvelopeInput.onFinalized deleted cached entries", {deletedCount});
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
add(props: CreateFromBlockProps): PayloadEnvelopeInput {
|
|
74
|
+
if (this.payloadInputs.has(props.blockRootHex)) {
|
|
75
|
+
throw new Error(`PayloadEnvelopeInput already exists for block ${props.blockRootHex}`);
|
|
76
|
+
}
|
|
77
|
+
const input = PayloadEnvelopeInput.createFromBlock(props);
|
|
78
|
+
this.payloadInputs.set(props.blockRootHex, input);
|
|
79
|
+
this.metrics?.seenCache.payloadEnvelopeInput.created.inc();
|
|
80
|
+
return input;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
get(blockRootHex: RootHex): PayloadEnvelopeInput | undefined {
|
|
84
|
+
return this.payloadInputs.get(blockRootHex);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
has(blockRootHex: RootHex): boolean {
|
|
88
|
+
return this.payloadInputs.has(blockRootHex);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
prune(blockRootHex: RootHex): void {
|
|
92
|
+
const payloadInput = this.payloadInputs.get(blockRootHex);
|
|
93
|
+
if (payloadInput) {
|
|
94
|
+
this.evictPayloadInput(payloadInput);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
size(): number {
|
|
99
|
+
return this.payloadInputs.size;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
private evictPayloadInput(payloadInput: PayloadEnvelopeInput): void {
|
|
103
|
+
this.serializedCache.delete(payloadInput.getSerializedCacheKeys());
|
|
104
|
+
this.payloadInputs.delete(payloadInput.blockRootHex);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {IBeaconStateView} from "@lodestar/state-transition";
|
|
2
2
|
import {AllocSource, BufferPool} from "../util/bufferPool.js";
|
|
3
3
|
|
|
4
4
|
type ProcessStateBytesFn<T> = (stateBytes: Uint8Array) => Promise<T>;
|
|
@@ -7,12 +7,12 @@ type ProcessStateBytesFn<T> = (stateBytes: Uint8Array) => Promise<T>;
|
|
|
7
7
|
* Serialize state using the BufferPool if provided.
|
|
8
8
|
*/
|
|
9
9
|
export async function serializeState<T>(
|
|
10
|
-
state:
|
|
10
|
+
state: IBeaconStateView,
|
|
11
11
|
source: AllocSource,
|
|
12
12
|
processFn: ProcessStateBytesFn<T>,
|
|
13
13
|
bufferPool?: BufferPool | null
|
|
14
14
|
): Promise<T> {
|
|
15
|
-
const size = state.
|
|
15
|
+
const size = state.serializedSize();
|
|
16
16
|
let stateBytes: Uint8Array | null = null;
|
|
17
17
|
if (bufferPool) {
|
|
18
18
|
using bufferWithKey = bufferPool.alloc(size, source);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {ForkSeq} from "@lodestar/params";
|
|
2
2
|
import {
|
|
3
|
-
CachedBeaconStateAllForks,
|
|
4
3
|
EpochShuffling,
|
|
4
|
+
IBeaconStateView,
|
|
5
5
|
getAttestingIndices,
|
|
6
6
|
getBeaconCommittees,
|
|
7
7
|
getIndexedAttestation,
|
|
@@ -159,17 +159,15 @@ export class ShufflingCache {
|
|
|
159
159
|
* Process a state to extract and cache all shufflings (previous, current, next).
|
|
160
160
|
* Uses the stored decision roots from epochCtx.
|
|
161
161
|
*/
|
|
162
|
-
processState(state:
|
|
163
|
-
const {epochCtx} = state;
|
|
164
|
-
|
|
162
|
+
processState(state: IBeaconStateView): void {
|
|
165
163
|
// Cache previous shuffling
|
|
166
|
-
this.set(
|
|
164
|
+
this.set(state.getPreviousShuffling(), state.previousDecisionRoot);
|
|
167
165
|
|
|
168
166
|
// Cache current shuffling
|
|
169
|
-
this.set(
|
|
167
|
+
this.set(state.getCurrentShuffling(), state.currentDecisionRoot);
|
|
170
168
|
|
|
171
169
|
// Cache next shuffling
|
|
172
|
-
this.set(
|
|
170
|
+
this.set(state.getNextShuffling(), state.nextDecisionRoot);
|
|
173
171
|
}
|
|
174
172
|
|
|
175
173
|
getIndexedAttestation(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {SLOTS_PER_EPOCH} from "@lodestar/params";
|
|
2
2
|
import {Epoch, phase0, ssz} from "@lodestar/types";
|
|
3
|
-
import {MapDef} from "@lodestar/utils";
|
|
3
|
+
import {MapDef, byteArrayEquals} from "@lodestar/utils";
|
|
4
4
|
import {IBeaconDb} from "../../../db/interface.js";
|
|
5
5
|
import {
|
|
6
6
|
getLastProcessedSlotFromBeaconStateSerialized,
|
|
@@ -14,8 +14,8 @@ import {CPStateDatastore, DatastoreKey} from "./types.js";
|
|
|
14
14
|
export class DbCPStateDatastore implements CPStateDatastore {
|
|
15
15
|
constructor(private readonly db: IBeaconDb) {}
|
|
16
16
|
|
|
17
|
-
async write(cpKey: phase0.Checkpoint, stateBytes: Uint8Array): Promise<DatastoreKey> {
|
|
18
|
-
const serializedCheckpoint = checkpointToDatastoreKey(cpKey);
|
|
17
|
+
async write(cpKey: phase0.Checkpoint, stateBytes: Uint8Array, payloadPresent: boolean): Promise<DatastoreKey> {
|
|
18
|
+
const serializedCheckpoint = checkpointToDatastoreKey(cpKey, payloadPresent);
|
|
19
19
|
await this.db.checkpointState.putBinary(serializedCheckpoint, stateBytes);
|
|
20
20
|
return serializedCheckpoint;
|
|
21
21
|
}
|
|
@@ -40,18 +40,30 @@ export class DbCPStateDatastore implements CPStateDatastore {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
function extractCheckpointBytes(key: DatastoreKey): Uint8Array {
|
|
44
|
+
const fixedSize = ssz.phase0.Checkpoint.minSize;
|
|
45
|
+
return key.subarray(0, fixedSize);
|
|
46
|
+
}
|
|
47
|
+
|
|
43
48
|
export function datastoreKeyToCheckpoint(key: DatastoreKey): phase0.Checkpoint {
|
|
44
|
-
return ssz.phase0.Checkpoint.deserialize(key);
|
|
49
|
+
return ssz.phase0.Checkpoint.deserialize(extractCheckpointBytes(key));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function checkpointToDatastoreKey(cp: phase0.Checkpoint, payloadPresent: boolean): DatastoreKey {
|
|
53
|
+
const cpBytes = ssz.phase0.Checkpoint.serialize(cp);
|
|
54
|
+
const key = new Uint8Array(cpBytes.length + 1);
|
|
55
|
+
key.set(cpBytes);
|
|
56
|
+
key[cpBytes.length] = payloadPresent ? 1 : 0;
|
|
57
|
+
return key;
|
|
45
58
|
}
|
|
46
59
|
|
|
47
|
-
|
|
48
|
-
return
|
|
60
|
+
function isPayloadCheckpointState(key: DatastoreKey): boolean {
|
|
61
|
+
return key.at(-1) === 1;
|
|
49
62
|
}
|
|
50
63
|
|
|
51
64
|
/**
|
|
52
|
-
* Get the latest safe checkpoint state the node can use to boot from
|
|
53
|
-
* -
|
|
54
|
-
* - its last processed block slot should be at epoch boundary or last slot of previous epoch
|
|
65
|
+
* Get the latest "safe" checkpoint state the node can use to boot from
|
|
66
|
+
* - its last processed block slot should be at epoch boundary (CRCS) or last slot of previous epoch (PRCS)
|
|
55
67
|
* - state slot should be at epoch boundary
|
|
56
68
|
* - state slot should be equal to epoch * SLOTS_PER_EPOCH
|
|
57
69
|
*
|
|
@@ -70,9 +82,20 @@ export async function getLatestSafeDatastoreKey(
|
|
|
70
82
|
|
|
71
83
|
const dataStoreKeyByEpoch: Map<Epoch, DatastoreKey> = new Map();
|
|
72
84
|
for (const [epoch, keys] of checkpointsByEpoch.entries()) {
|
|
73
|
-
// only consider epochs with a single checkpoint to avoid ambiguity from forks
|
|
74
85
|
if (keys.length === 1) {
|
|
86
|
+
// PRCS (skipped slot) or CRCS and no payloadPresent
|
|
87
|
+
// Pre-gloas always fall into this case
|
|
75
88
|
dataStoreKeyByEpoch.set(epoch, keys[0]);
|
|
89
|
+
} else if (keys.length === 2) {
|
|
90
|
+
// CRCS without payload and CRCS with payload
|
|
91
|
+
// ie Two keys for the same checkpoint with different payloadPresent suffix (FULL/EMPTY)
|
|
92
|
+
// TODO GLOAS: Here we pick FULL key, there is a chance that payload is orphaned hence we not be able to sync
|
|
93
|
+
const cp0 = extractCheckpointBytes(keys[0]);
|
|
94
|
+
const cp1 = extractCheckpointBytes(keys[1]);
|
|
95
|
+
if (byteArrayEquals(cp0, cp1)) {
|
|
96
|
+
const fullKey = isPayloadCheckpointState(keys[0]) ? keys[0] : keys[1];
|
|
97
|
+
dataStoreKeyByEpoch.set(epoch, fullKey);
|
|
98
|
+
}
|
|
76
99
|
}
|
|
77
100
|
}
|
|
78
101
|
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import {phase0
|
|
2
|
+
import {phase0} from "@lodestar/types";
|
|
3
3
|
import {fromHex, toHex} from "@lodestar/utils";
|
|
4
4
|
import {ensureDir, readFile, readFileNames, removeFile, writeIfNotExist} from "../../../util/file.js";
|
|
5
|
-
import {getLatestSafeDatastoreKey} from "./db.js";
|
|
5
|
+
import {checkpointToDatastoreKey, getLatestSafeDatastoreKey} from "./db.js";
|
|
6
6
|
import {CPStateDatastore, DatastoreKey} from "./types.js";
|
|
7
7
|
|
|
8
8
|
const CHECKPOINT_STATES_FOLDER = "checkpoint_states";
|
|
9
|
-
|
|
9
|
+
/** 41 bytes (40 checkpoint + 1 payloadPresent) = 82 hex chars + "0x" prefix = 84 */
|
|
10
|
+
const CHECKPOINT_FILE_NAME_LENGTH = 84;
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Implementation of CPStateDatastore using file system, this is beneficial for debugging.
|
|
@@ -28,8 +29,8 @@ export class FileCPStateDatastore implements CPStateDatastore {
|
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
async write(cpKey: phase0.Checkpoint, stateBytes: Uint8Array): Promise<DatastoreKey> {
|
|
32
|
-
const serializedCheckpoint =
|
|
32
|
+
async write(cpKey: phase0.Checkpoint, stateBytes: Uint8Array, payloadPresent: boolean): Promise<DatastoreKey> {
|
|
33
|
+
const serializedCheckpoint = checkpointToDatastoreKey(cpKey, payloadPresent);
|
|
33
34
|
const filePath = path.join(this.folderPath, toHex(serializedCheckpoint));
|
|
34
35
|
await writeIfNotExist(filePath, stateBytes);
|
|
35
36
|
return serializedCheckpoint;
|