@lodestar/beacon-node 1.41.0 → 1.42.0-dev.04e52d162f
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 +1 -9
- package/lib/chain/archiveStore/archiveStore.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts +3 -7
- package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
- package/lib/chain/archiveStore/historicalState/getHistoricalState.js +8 -26
- package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/historicalStateRegen.d.ts +2 -2
- package/lib/chain/archiveStore/historicalState/historicalStateRegen.d.ts.map +1 -1
- package/lib/chain/archiveStore/historicalState/historicalStateRegen.js +1 -0
- package/lib/chain/archiveStore/historicalState/historicalStateRegen.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/types.d.ts +2 -0
- package/lib/chain/archiveStore/historicalState/types.d.ts.map +1 -1
- package/lib/chain/archiveStore/historicalState/types.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/worker.js +1 -3
- package/lib/chain/archiveStore/historicalState/worker.js.map +1 -1
- package/lib/chain/archiveStore/interface.d.ts +5 -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 +48 -28
- 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 +167 -0
- package/lib/chain/blocks/importExecutionPayload.js.map +1 -0
- package/lib/chain/blocks/index.d.ts.map +1 -1
- package/lib/chain/blocks/index.js +3 -2
- 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 +28 -15
- 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 +5 -5
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +4 -4
- 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/options.d.ts +1 -0
- package/lib/chain/options.d.ts.map +1 -1
- package/lib/chain/options.js +1 -0
- package/lib/chain/options.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/libp2p/index.d.ts.map +1 -1
- package/lib/network/libp2p/index.js +5 -0
- package/lib/network/libp2p/index.js.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 +16 -16
- 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 +1 -10
- package/src/chain/archiveStore/historicalState/getHistoricalState.ts +10 -39
- package/src/chain/archiveStore/historicalState/historicalStateRegen.ts +2 -1
- package/src/chain/archiveStore/historicalState/types.ts +2 -0
- package/src/chain/archiveStore/historicalState/worker.ts +1 -4
- package/src/chain/archiveStore/interface.ts +5 -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 +69 -32
- package/src/chain/blocks/importExecutionPayload.ts +247 -0
- package/src/chain/blocks/index.ts +3 -2
- 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 +34 -15
- package/src/chain/blocks/utils/checkpoint.ts +2 -2
- package/src/chain/blocks/verifyBlock.ts +5 -10
- package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +9 -14
- 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/options.ts +2 -0
- 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/libp2p/index.ts +5 -0
- 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
|
@@ -50,12 +50,25 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
|
|
|
50
50
|
var e = new Error(message);
|
|
51
51
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
52
|
});
|
|
53
|
-
import { computeStartSlotAtEpoch
|
|
53
|
+
import { computeStartSlotAtEpoch } from "@lodestar/state-transition";
|
|
54
54
|
import { MapDef, fromHex, sleep, toHex, toRootHex } from "@lodestar/utils";
|
|
55
55
|
import { AllocSource } from "../../util/bufferPool.js";
|
|
56
56
|
import { serializeState } from "../serializeState.js";
|
|
57
57
|
import { MapTracker } from "./mapMetrics.js";
|
|
58
58
|
import { CacheItemType } from "./types.js";
|
|
59
|
+
/** Bitmask for tracking which payload variants exist per root in the epochIndex */
|
|
60
|
+
var PayloadAvailability;
|
|
61
|
+
(function (PayloadAvailability) {
|
|
62
|
+
PayloadAvailability[PayloadAvailability["NOT_PRESENT"] = 1] = "NOT_PRESENT";
|
|
63
|
+
PayloadAvailability[PayloadAvailability["PRESENT"] = 2] = "PRESENT";
|
|
64
|
+
})(PayloadAvailability || (PayloadAvailability = {}));
|
|
65
|
+
const PAYLOAD_AVAILABILITY_ALL = [PayloadAvailability.NOT_PRESENT, PayloadAvailability.PRESENT];
|
|
66
|
+
function toPayloadAvailability(payloadPresent) {
|
|
67
|
+
return payloadPresent ? PayloadAvailability.PRESENT : PayloadAvailability.NOT_PRESENT;
|
|
68
|
+
}
|
|
69
|
+
function fromPayloadAvailability(flag) {
|
|
70
|
+
return flag === PayloadAvailability.PRESENT;
|
|
71
|
+
}
|
|
59
72
|
/**
|
|
60
73
|
* Before n-historical states, lodestar keeps all checkpoint states since finalized
|
|
61
74
|
* Since Sep 2024, lodestar stores 3 most recent checkpoint states in memory and the rest on disk. The finalized state
|
|
@@ -105,8 +118,8 @@ const PROCESS_CHECKPOINT_STATES_BPS = 6667;
|
|
|
105
118
|
*/
|
|
106
119
|
export class PersistentCheckpointStateCache {
|
|
107
120
|
cache;
|
|
108
|
-
/** Epoch ->
|
|
109
|
-
epochIndex = new MapDef(() => new
|
|
121
|
+
/** Epoch -> Map<blockRoot, PayloadAvailability bitmask> */
|
|
122
|
+
epochIndex = new MapDef(() => new Map());
|
|
110
123
|
config;
|
|
111
124
|
metrics;
|
|
112
125
|
logger;
|
|
@@ -188,15 +201,20 @@ export class PersistentCheckpointStateCache {
|
|
|
188
201
|
*/
|
|
189
202
|
async getOrReload(cp) {
|
|
190
203
|
const stateOrStateBytesData = await this.getStateOrLoadDb(cp);
|
|
191
|
-
if (stateOrStateBytesData === null ||
|
|
204
|
+
if (stateOrStateBytesData === null || isBeaconStateView(stateOrStateBytesData)) {
|
|
192
205
|
return stateOrStateBytesData ?? null;
|
|
193
206
|
}
|
|
194
207
|
const { persistedKey, stateBytes } = stateOrStateBytesData;
|
|
195
|
-
const logMeta = {
|
|
208
|
+
const logMeta = {
|
|
209
|
+
epoch: cp.epoch,
|
|
210
|
+
rootHex: cp.rootHex,
|
|
211
|
+
payloadPresent: cp.payloadPresent,
|
|
212
|
+
persistedKey: toHex(persistedKey),
|
|
213
|
+
};
|
|
196
214
|
this.logger.debug("Reload: read state successful", logMeta);
|
|
197
215
|
this.metrics?.cpStateCache.stateReloadSecFromSlot.observe(this.clock?.secFromSlot(this.clock?.currentSlot ?? 0) ?? 0);
|
|
198
216
|
const seedState = this.findSeedStateToReload(cp);
|
|
199
|
-
this.metrics?.cpStateCache.stateReloadEpochDiff.observe(Math.abs(seedState.
|
|
217
|
+
this.metrics?.cpStateCache.stateReloadEpochDiff.observe(Math.abs(seedState.epoch - cp.epoch));
|
|
200
218
|
this.logger.debug("Reload: found seed state", { ...logMeta, seedSlot: seedState.slot });
|
|
201
219
|
try {
|
|
202
220
|
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
@@ -209,18 +227,15 @@ export class PersistentCheckpointStateCache {
|
|
|
209
227
|
if (validatorsBytes == null) {
|
|
210
228
|
// fallback logic in case we can't use the buffer pool
|
|
211
229
|
this.metrics?.cpStateCache.stateReloadValidatorsSerializeAllocCount.inc();
|
|
212
|
-
validatorsBytes = seedState.
|
|
230
|
+
validatorsBytes = seedState.serializeValidators();
|
|
213
231
|
}
|
|
214
232
|
sszTimer?.();
|
|
215
233
|
const timer = this.metrics?.cpStateCache.stateReloadDuration.startTimer();
|
|
216
|
-
const newCachedState =
|
|
234
|
+
const newCachedState = seedState.loadOtherState(stateBytes, validatorsBytes);
|
|
217
235
|
// hashTreeRoot() calls the commit() inside
|
|
218
236
|
// there is no modification inside the state, it's just that we want to compute and cache all roots
|
|
219
237
|
const stateRoot = toRootHex(newCachedState.hashTreeRoot());
|
|
220
238
|
timer?.();
|
|
221
|
-
// load all cache in order for consumers (usually regen.getState()) to process blocks faster
|
|
222
|
-
newCachedState.validators.getAllReadonlyValues();
|
|
223
|
-
newCachedState.balances.getAll();
|
|
224
239
|
this.logger.debug("Reload: cached state load successful", {
|
|
225
240
|
...logMeta,
|
|
226
241
|
stateSlot: newCachedState.slot,
|
|
@@ -230,7 +245,7 @@ export class PersistentCheckpointStateCache {
|
|
|
230
245
|
// only remove persisted state once we reload successfully
|
|
231
246
|
const cpKey = toCacheKey(cp);
|
|
232
247
|
this.cache.set(cpKey, { type: CacheItemType.inMemory, state: newCachedState, persistedKey });
|
|
233
|
-
this.
|
|
248
|
+
this.addToEpochIndex(cp.epoch, cp.rootHex, cp.payloadPresent);
|
|
234
249
|
// don't prune from memory here, call it at the last 1/3 of slot 0 of an epoch
|
|
235
250
|
return newCachedState;
|
|
236
251
|
}
|
|
@@ -252,7 +267,7 @@ export class PersistentCheckpointStateCache {
|
|
|
252
267
|
*/
|
|
253
268
|
async getStateOrBytes(cp) {
|
|
254
269
|
const stateOrLoadedState = await this.getStateOrLoadDb(cp);
|
|
255
|
-
if (stateOrLoadedState === null ||
|
|
270
|
+
if (stateOrLoadedState === null || isBeaconStateView(stateOrLoadedState)) {
|
|
256
271
|
return stateOrLoadedState;
|
|
257
272
|
}
|
|
258
273
|
return stateOrLoadedState.stateBytes;
|
|
@@ -306,9 +321,11 @@ export class PersistentCheckpointStateCache {
|
|
|
306
321
|
}
|
|
307
322
|
/**
|
|
308
323
|
* Add a state of a checkpoint to this cache, prune from memory if necessary.
|
|
324
|
+
* @param payloadPresent - For Gloas: true if this is payload state, false if block state.
|
|
325
|
+
* Always true for pre-Gloas.
|
|
309
326
|
*/
|
|
310
|
-
add(cp, state) {
|
|
311
|
-
const cpHex =
|
|
327
|
+
add(cp, state, payloadPresent) {
|
|
328
|
+
const cpHex = toCheckpointHexPayload(cp, payloadPresent);
|
|
312
329
|
const key = toCacheKey(cpHex);
|
|
313
330
|
const cacheItem = this.cache.get(key);
|
|
314
331
|
this.metrics?.cpStateCache.adds.inc();
|
|
@@ -319,27 +336,32 @@ export class PersistentCheckpointStateCache {
|
|
|
319
336
|
this.logger.verbose("Added checkpoint state to memory but a persisted key existed", {
|
|
320
337
|
epoch: cp.epoch,
|
|
321
338
|
rootHex: cpHex.rootHex,
|
|
339
|
+
payloadPresent,
|
|
322
340
|
persistedKey: toHex(persistedKey),
|
|
323
341
|
});
|
|
324
342
|
}
|
|
325
343
|
else {
|
|
326
344
|
this.cache.set(key, { type: CacheItemType.inMemory, state });
|
|
327
|
-
this.logger.verbose("Added checkpoint state to memory", {
|
|
345
|
+
this.logger.verbose("Added checkpoint state to memory", {
|
|
346
|
+
epoch: cp.epoch,
|
|
347
|
+
rootHex: cpHex.rootHex,
|
|
348
|
+
payloadPresent,
|
|
349
|
+
});
|
|
328
350
|
}
|
|
329
|
-
this.
|
|
351
|
+
this.addToEpochIndex(cp.epoch, cpHex.rootHex, cpHex.payloadPresent);
|
|
330
352
|
this.prunePersistedStates();
|
|
331
353
|
}
|
|
332
354
|
/**
|
|
333
355
|
* Searches in-memory state for the latest cached state with a `root` without reload, starting with `epoch` and descending
|
|
334
356
|
*/
|
|
335
|
-
getLatest(rootHex, maxEpoch) {
|
|
357
|
+
getLatest(rootHex, maxEpoch, payloadPresent) {
|
|
336
358
|
// sort epochs in descending order, only consider epochs lte `epoch`
|
|
337
359
|
const epochs = Array.from(this.epochIndex.keys())
|
|
338
360
|
.sort((a, b) => b - a)
|
|
339
361
|
.filter((e) => e <= maxEpoch);
|
|
340
362
|
for (const epoch of epochs) {
|
|
341
|
-
if (this.
|
|
342
|
-
const inMemoryClonedState = this.get({ rootHex, epoch });
|
|
363
|
+
if (this.hasPayloadVariant(epoch, rootHex, payloadPresent)) {
|
|
364
|
+
const inMemoryClonedState = this.get({ rootHex, epoch, payloadPresent });
|
|
343
365
|
if (inMemoryClonedState) {
|
|
344
366
|
return inMemoryClonedState;
|
|
345
367
|
}
|
|
@@ -354,33 +376,35 @@ export class PersistentCheckpointStateCache {
|
|
|
354
376
|
* - Get block for processing
|
|
355
377
|
* - Regen head state
|
|
356
378
|
*/
|
|
357
|
-
async getOrReloadLatest(rootHex, maxEpoch) {
|
|
379
|
+
async getOrReloadLatest(rootHex, maxEpoch, payloadPresent) {
|
|
358
380
|
// sort epochs in descending order, only consider epochs lte `epoch`
|
|
359
381
|
const epochs = Array.from(this.epochIndex.keys())
|
|
360
382
|
.sort((a, b) => b - a)
|
|
361
383
|
.filter((e) => e <= maxEpoch);
|
|
362
384
|
for (const epoch of epochs) {
|
|
363
|
-
if (this.
|
|
385
|
+
if (this.hasPayloadVariant(epoch, rootHex, payloadPresent)) {
|
|
364
386
|
try {
|
|
365
|
-
const state = await this.getOrReload({ rootHex, epoch });
|
|
387
|
+
const state = await this.getOrReload({ rootHex, epoch, payloadPresent });
|
|
366
388
|
if (state) {
|
|
367
389
|
return state;
|
|
368
390
|
}
|
|
369
391
|
}
|
|
370
392
|
catch (e) {
|
|
371
|
-
this.logger.debug("Error get or reload state", { epoch, rootHex }, e);
|
|
393
|
+
this.logger.debug("Error get or reload state", { epoch, rootHex, payloadPresent }, e);
|
|
372
394
|
}
|
|
373
395
|
}
|
|
374
396
|
}
|
|
375
397
|
return null;
|
|
376
398
|
}
|
|
377
399
|
/**
|
|
378
|
-
* Update the precomputed checkpoint and return the number of
|
|
400
|
+
* Update the precomputed checkpoint and return the number of hits for the
|
|
379
401
|
* previous one (if any).
|
|
402
|
+
* @param payloadPresent - For Gloas: true if head block has FULL payload, false if EMPTY.
|
|
403
|
+
* Always true for pre-Gloas.
|
|
380
404
|
*/
|
|
381
|
-
updatePreComputedCheckpoint(rootHex, epoch) {
|
|
405
|
+
updatePreComputedCheckpoint(rootHex, epoch, payloadPresent) {
|
|
382
406
|
const previousHits = this.preComputedCheckpointHits;
|
|
383
|
-
this.preComputedCheckpoint = toCacheKey({ rootHex, epoch });
|
|
407
|
+
this.preComputedCheckpoint = toCacheKey({ rootHex, epoch, payloadPresent });
|
|
384
408
|
this.preComputedCheckpointHits = 0;
|
|
385
409
|
return previousHits;
|
|
386
410
|
}
|
|
@@ -449,6 +473,9 @@ export class PersistentCheckpointStateCache {
|
|
|
449
473
|
* - 2 then we'll persist {root: b2, epoch n-2} checkpoint state to disk, there are also 2 checkpoint states in memory at epoch n, same to the above (maxEpochsInMemory=1)
|
|
450
474
|
*
|
|
451
475
|
* As of Mar 2024, it takes <=350ms to persist a holesky state on fast server
|
|
476
|
+
*
|
|
477
|
+
* For Gloas: Processes both block state and payload state variants together. The decision of which roots to persist/prune
|
|
478
|
+
* is based on root canonicality (from state's view), not payload presence. Both variants are managed as a unit.
|
|
452
479
|
*/
|
|
453
480
|
async processState(blockRootHex, state) {
|
|
454
481
|
let persistCount = 0;
|
|
@@ -523,30 +550,34 @@ export class PersistentCheckpointStateCache {
|
|
|
523
550
|
if (firstState !== null) {
|
|
524
551
|
return firstState;
|
|
525
552
|
}
|
|
526
|
-
for (const rootHex of this.epochIndex.get(epoch) || []) {
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
if (firstState === null) {
|
|
536
|
-
firstState = state;
|
|
553
|
+
for (const [rootHex, bitmask] of this.epochIndex.get(epoch) || []) {
|
|
554
|
+
for (const flag of PAYLOAD_AVAILABILITY_ALL) {
|
|
555
|
+
if (!(bitmask & flag))
|
|
556
|
+
continue;
|
|
557
|
+
const payloadPresent = fromPayloadAvailability(flag);
|
|
558
|
+
const cpKey = toCacheKey({ rootHex, epoch, payloadPresent });
|
|
559
|
+
const cacheItem = this.cache.get(cpKey);
|
|
560
|
+
if (cacheItem === undefined) {
|
|
561
|
+
continue;
|
|
537
562
|
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
563
|
+
if (isInMemoryCacheItem(cacheItem)) {
|
|
564
|
+
const { state } = cacheItem;
|
|
565
|
+
if (firstState === null) {
|
|
566
|
+
firstState = state;
|
|
567
|
+
}
|
|
568
|
+
const cpLog = { cpEpoch: epoch, cpRoot: rootHex, payloadPresent };
|
|
569
|
+
try {
|
|
570
|
+
// amongst states of the same epoch, choose the one with the same view of reloadedCp
|
|
571
|
+
if (reloadedCpSlot < state.slot &&
|
|
572
|
+
toRootHex(state.getBlockRootAtSlot(reloadedCpSlot)) === reloadedCp.rootHex) {
|
|
573
|
+
this.logger.verbose("Reload: use checkpoint state as seed state", { ...cpLog, ...logCtx });
|
|
574
|
+
return state;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
catch (e) {
|
|
578
|
+
// getBlockRootAtSlot may throw error
|
|
579
|
+
this.logger.debug("Error finding checkpoint state to reload", { ...cpLog, ...logCtx }, e);
|
|
545
580
|
}
|
|
546
|
-
}
|
|
547
|
-
catch (e) {
|
|
548
|
-
// getBlockRootAtSlot may throw error
|
|
549
|
-
this.logger.debug("Error finding checkpoint state to reload", { ...cpLog, ...logCtx }, e);
|
|
550
581
|
}
|
|
551
582
|
}
|
|
552
583
|
}
|
|
@@ -560,6 +591,31 @@ export class PersistentCheckpointStateCache {
|
|
|
560
591
|
this.cache.clear();
|
|
561
592
|
this.epochIndex.clear();
|
|
562
593
|
}
|
|
594
|
+
addToEpochIndex(epoch, rootHex, payloadPresent) {
|
|
595
|
+
const rootMap = this.epochIndex.getOrDefault(epoch);
|
|
596
|
+
rootMap.set(rootHex, (rootMap.get(rootHex) ?? 0) | toPayloadAvailability(payloadPresent));
|
|
597
|
+
}
|
|
598
|
+
removeFromEpochIndex(epoch, rootHex, payloadPresent) {
|
|
599
|
+
const rootMap = this.epochIndex.get(epoch);
|
|
600
|
+
if (rootMap === undefined)
|
|
601
|
+
return;
|
|
602
|
+
const existing = rootMap.get(rootHex);
|
|
603
|
+
if (existing === undefined)
|
|
604
|
+
return;
|
|
605
|
+
const updated = existing & ~toPayloadAvailability(payloadPresent);
|
|
606
|
+
if (updated === 0) {
|
|
607
|
+
rootMap.delete(rootHex);
|
|
608
|
+
if (rootMap.size === 0) {
|
|
609
|
+
this.epochIndex.delete(epoch);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
else {
|
|
613
|
+
rootMap.set(rootHex, updated);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
hasPayloadVariant(epoch, rootHex, payloadPresent) {
|
|
617
|
+
return Boolean((this.epochIndex.get(epoch)?.get(rootHex) ?? 0) & toPayloadAvailability(payloadPresent));
|
|
618
|
+
}
|
|
563
619
|
/** ONLY FOR DEBUGGING PURPOSES. For lodestar debug API */
|
|
564
620
|
dumpSummary() {
|
|
565
621
|
return Array.from(this.cache.keys()).map((key) => {
|
|
@@ -624,79 +680,85 @@ export class PersistentCheckpointStateCache {
|
|
|
624
680
|
async processPastEpoch(blockRootHex, state, epoch) {
|
|
625
681
|
let persistCount = 0;
|
|
626
682
|
const epochBoundarySlot = computeStartSlotAtEpoch(epoch);
|
|
627
|
-
const epochBoundaryRoot = epochBoundarySlot === state.slot ? fromHex(blockRootHex) : getBlockRootAtSlot(
|
|
683
|
+
const epochBoundaryRoot = epochBoundarySlot === state.slot ? fromHex(blockRootHex) : state.getBlockRootAtSlot(epochBoundarySlot);
|
|
628
684
|
const epochBoundaryHex = toRootHex(epochBoundaryRoot);
|
|
629
|
-
const prevEpochRoot = toRootHex(getBlockRootAtSlot(
|
|
685
|
+
const prevEpochRoot = toRootHex(state.getBlockRootAtSlot(epochBoundarySlot - 1));
|
|
630
686
|
// for each epoch, usually there are 2 rootHexes respective to the 2 checkpoint states: Previous Root Checkpoint State and Current Root Checkpoint State
|
|
631
|
-
const
|
|
687
|
+
const cpRootHexMap = this.epochIndex.get(epoch) ?? new Map();
|
|
632
688
|
const persistedRootHexes = new Set();
|
|
633
689
|
// 1) if there is no CRCS, persist PRCS (block 0 of epoch is skipped). In this case prevEpochRoot === epochBoundaryHex
|
|
634
690
|
// 2) if there are PRCS and CRCS, persist CRCS => persist CRCS
|
|
635
691
|
// => this is simplified to always persist epochBoundaryHex
|
|
636
692
|
persistedRootHexes.add(epochBoundaryHex);
|
|
637
693
|
// 3) persist any states with unknown roots to this state
|
|
638
|
-
for (const rootHex of
|
|
694
|
+
for (const rootHex of cpRootHexMap.keys()) {
|
|
639
695
|
if (rootHex !== epochBoundaryHex && rootHex !== prevEpochRoot) {
|
|
640
696
|
persistedRootHexes.add(rootHex);
|
|
641
697
|
}
|
|
642
698
|
}
|
|
643
|
-
for (const rootHex of
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
const {
|
|
649
|
-
const
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
//
|
|
689
|
-
// this also means the state is deleted from memory
|
|
699
|
+
for (const [rootHex, bitmask] of cpRootHexMap) {
|
|
700
|
+
for (const flag of PAYLOAD_AVAILABILITY_ALL) {
|
|
701
|
+
if (!(bitmask & flag))
|
|
702
|
+
continue;
|
|
703
|
+
const payloadPresent = fromPayloadAvailability(flag);
|
|
704
|
+
const cpKey = toCacheKey({ epoch: epoch, rootHex, payloadPresent });
|
|
705
|
+
const cacheItem = this.cache.get(cpKey);
|
|
706
|
+
if (cacheItem !== undefined && isInMemoryCacheItem(cacheItem)) {
|
|
707
|
+
let { persistedKey } = cacheItem;
|
|
708
|
+
const { state } = cacheItem;
|
|
709
|
+
const logMeta = {
|
|
710
|
+
stateSlot: state.slot,
|
|
711
|
+
rootHex,
|
|
712
|
+
payloadPresent,
|
|
713
|
+
epochBoundaryHex,
|
|
714
|
+
persistedKey: persistedKey ? toHex(persistedKey) : "",
|
|
715
|
+
};
|
|
716
|
+
if (persistedRootHexes.has(rootHex)) {
|
|
717
|
+
if (persistedKey) {
|
|
718
|
+
// we don't care if the checkpoint state is already persisted
|
|
719
|
+
this.logger.verbose("Pruned checkpoint state from memory but no need to persist", logMeta);
|
|
720
|
+
}
|
|
721
|
+
else {
|
|
722
|
+
// persist and do not update epochIndex
|
|
723
|
+
this.metrics?.cpStateCache.statePersistSecFromSlot.observe(this.clock?.secFromSlot(this.clock?.currentSlot ?? 0) ?? 0);
|
|
724
|
+
const cpPersist = { epoch: epoch, root: fromHex(rootHex) };
|
|
725
|
+
// It's not sustainable to allocate ~240MB for each state every epoch, so we use buffer pool to reuse the memory.
|
|
726
|
+
// As monitored on holesky as of Jan 2024:
|
|
727
|
+
// - This does not increase heap allocation while gc time is the same
|
|
728
|
+
// - It helps stabilize persist time and save ~300ms in average (1.5s vs 1.2s)
|
|
729
|
+
// - It also helps the state reload to save ~500ms in average (4.3s vs 3.8s)
|
|
730
|
+
// - Also `serializeState.test.ts` perf test shows a lot of differences allocating ~240MB once vs per state serialization
|
|
731
|
+
const timer = this.metrics?.stateSerializeDuration.startTimer({
|
|
732
|
+
source: AllocSource.PERSISTENT_CHECKPOINTS_CACHE_STATE,
|
|
733
|
+
});
|
|
734
|
+
persistedKey = await serializeState(state, AllocSource.PERSISTENT_CHECKPOINTS_CACHE_STATE, (stateBytes) => {
|
|
735
|
+
timer?.();
|
|
736
|
+
return this.datastore.write(cpPersist, stateBytes, payloadPresent);
|
|
737
|
+
}, this.bufferPool);
|
|
738
|
+
persistCount++;
|
|
739
|
+
this.logger.verbose("Pruned checkpoint state from memory and persisted to disk", {
|
|
740
|
+
...logMeta,
|
|
741
|
+
persistedKey: toHex(persistedKey),
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
// overwrite cpKey, this means the state is deleted from memory
|
|
690
745
|
this.cache.set(cpKey, { type: CacheItemType.persisted, value: persistedKey });
|
|
691
|
-
// do not update epochIndex
|
|
692
746
|
}
|
|
693
747
|
else {
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
748
|
+
if (persistedKey) {
|
|
749
|
+
// persisted file will be eventually deleted by the archive task
|
|
750
|
+
// this also means the state is deleted from memory
|
|
751
|
+
this.cache.set(cpKey, { type: CacheItemType.persisted, value: persistedKey });
|
|
752
|
+
// do not update epochIndex
|
|
753
|
+
}
|
|
754
|
+
else {
|
|
755
|
+
// delete the state from memory
|
|
756
|
+
this.cache.delete(cpKey);
|
|
757
|
+
this.removeFromEpochIndex(epoch, rootHex, payloadPresent);
|
|
758
|
+
}
|
|
759
|
+
this.metrics?.cpStateCache.statePruneFromMemoryCount.inc();
|
|
760
|
+
this.logger.verbose("Pruned checkpoint state from memory", logMeta);
|
|
697
761
|
}
|
|
698
|
-
this.metrics?.cpStateCache.statePruneFromMemoryCount.inc();
|
|
699
|
-
this.logger.verbose("Pruned checkpoint state from memory", logMeta);
|
|
700
762
|
}
|
|
701
763
|
}
|
|
702
764
|
}
|
|
@@ -707,25 +769,38 @@ export class PersistentCheckpointStateCache {
|
|
|
707
769
|
*/
|
|
708
770
|
async deleteAllEpochItems(epoch) {
|
|
709
771
|
let persistCount = 0;
|
|
710
|
-
const
|
|
711
|
-
for (const rootHex of
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
const
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
772
|
+
const rootHexMap = this.epochIndex.get(epoch) || new Map();
|
|
773
|
+
for (const [rootHex, bitmask] of rootHexMap) {
|
|
774
|
+
for (const flag of PAYLOAD_AVAILABILITY_ALL) {
|
|
775
|
+
if (!(bitmask & flag))
|
|
776
|
+
continue;
|
|
777
|
+
const payloadPresent = fromPayloadAvailability(flag);
|
|
778
|
+
const key = toCacheKey({ rootHex, epoch, payloadPresent });
|
|
779
|
+
const cacheItem = this.cache.get(key);
|
|
780
|
+
if (cacheItem) {
|
|
781
|
+
const persistedKey = isPersistedCacheItem(cacheItem) ? cacheItem.value : cacheItem.persistedKey;
|
|
782
|
+
if (persistedKey) {
|
|
783
|
+
await this.datastore.remove(persistedKey);
|
|
784
|
+
persistCount++;
|
|
785
|
+
this.metrics?.cpStateCache.persistedStateRemoveCount.inc();
|
|
786
|
+
}
|
|
720
787
|
}
|
|
788
|
+
this.cache.delete(key);
|
|
789
|
+
this.logger.verbose("Pruned checkpoint state", {
|
|
790
|
+
epoch,
|
|
791
|
+
rootHex,
|
|
792
|
+
payloadPresent,
|
|
793
|
+
type: cacheItem ? (isPersistedCacheItem(cacheItem) ? "persisted" : "in-memory") : "missing",
|
|
794
|
+
});
|
|
721
795
|
}
|
|
722
|
-
this.cache.delete(key);
|
|
723
796
|
}
|
|
724
797
|
this.epochIndex.delete(epoch);
|
|
725
|
-
this.logger.verbose("Pruned checkpoint states for epoch", {
|
|
798
|
+
this.logger.verbose("Pruned all checkpoint states for epoch", {
|
|
726
799
|
epoch,
|
|
727
800
|
persistCount,
|
|
728
|
-
|
|
801
|
+
items: Array.from(rootHexMap.entries())
|
|
802
|
+
.flatMap(([rootHex, bitmask]) => PAYLOAD_AVAILABILITY_ALL.filter((f) => bitmask & f).map((f) => `${rootHex}:${fromPayloadAvailability(f)}`))
|
|
803
|
+
.join(","),
|
|
729
804
|
});
|
|
730
805
|
}
|
|
731
806
|
/**
|
|
@@ -752,43 +827,65 @@ export class PersistentCheckpointStateCache {
|
|
|
752
827
|
* This is 2x - 3x faster than allocating memory every time.
|
|
753
828
|
*/
|
|
754
829
|
serializeStateValidators(state) {
|
|
755
|
-
const
|
|
756
|
-
const size = type.tree_serializedSize(state.validators.node);
|
|
830
|
+
const size = state.serializedValidatorsSize();
|
|
757
831
|
if (this.bufferPool) {
|
|
758
832
|
const bufferWithKey = this.bufferPool.alloc(size, AllocSource.PERSISTENT_CHECKPOINTS_CACHE_VALIDATORS);
|
|
759
833
|
if (bufferWithKey) {
|
|
760
834
|
const validatorsBytes = bufferWithKey.buffer;
|
|
761
835
|
const dataView = new DataView(validatorsBytes.buffer, validatorsBytes.byteOffset, validatorsBytes.byteLength);
|
|
762
|
-
state.
|
|
836
|
+
state.serializeValidatorsToBytes({ uint8Array: validatorsBytes, dataView }, 0);
|
|
763
837
|
return bufferWithKey;
|
|
764
838
|
}
|
|
765
839
|
}
|
|
766
840
|
return null;
|
|
767
841
|
}
|
|
768
842
|
}
|
|
769
|
-
export function
|
|
843
|
+
export function toCheckpointHexPayload(checkpoint, payloadPresent) {
|
|
770
844
|
return {
|
|
771
845
|
epoch: checkpoint.epoch,
|
|
772
846
|
rootHex: toRootHex(checkpoint.root),
|
|
847
|
+
payloadPresent,
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
/**
|
|
851
|
+
* Convert fork-choice CheckpointWithPayloadStatus to beacon-node CheckpointHexPayload.
|
|
852
|
+
* Maps PayloadStatus enum to boolean payloadPresent.
|
|
853
|
+
* @throws Error if checkpoint has PENDING payload status (ambiguous which variant to use)
|
|
854
|
+
*/
|
|
855
|
+
export function fcCheckpointToHexPayload(checkpoint) {
|
|
856
|
+
const PayloadStatus = { PENDING: 0, EMPTY: 1, FULL: 2 };
|
|
857
|
+
if (checkpoint.payloadStatus === PayloadStatus.PENDING) {
|
|
858
|
+
throw Error(`Cannot convert checkpoint with PENDING payload status at epoch ${checkpoint.epoch} root ${checkpoint.rootHex}`);
|
|
859
|
+
}
|
|
860
|
+
return {
|
|
861
|
+
epoch: checkpoint.epoch,
|
|
862
|
+
rootHex: checkpoint.rootHex,
|
|
863
|
+
payloadPresent: checkpoint.payloadStatus === PayloadStatus.FULL,
|
|
773
864
|
};
|
|
774
865
|
}
|
|
775
866
|
export function toCheckpointKey(cp) {
|
|
776
|
-
return `${cp.rootHex}:${cp.epoch}`;
|
|
867
|
+
return `${cp.rootHex}:${cp.epoch}:${cp.payloadPresent}`;
|
|
777
868
|
}
|
|
869
|
+
/**
|
|
870
|
+
* Convert checkpoint to cache key string.
|
|
871
|
+
* Format: `{rootHex}_{epoch}_{payloadPresent}`
|
|
872
|
+
*/
|
|
778
873
|
function toCacheKey(cp) {
|
|
779
|
-
|
|
780
|
-
return `${cp.rootHex}_${cp.epoch}`;
|
|
781
|
-
}
|
|
782
|
-
return `${toRootHex(cp.root)}_${cp.epoch}`;
|
|
874
|
+
return `${cp.rootHex}_${cp.epoch}_${cp.payloadPresent}`;
|
|
783
875
|
}
|
|
784
876
|
function fromCacheKey(key) {
|
|
785
|
-
const
|
|
877
|
+
const parts = key.split("_");
|
|
878
|
+
const rootHex = parts[0];
|
|
879
|
+
const epoch = Number(parts[1]);
|
|
880
|
+
// For backward compatibility with old format (rootHex_epoch), default to true
|
|
881
|
+
const payloadPresent = parts.length > 2 ? parts[2] === "true" : true;
|
|
786
882
|
return {
|
|
787
883
|
rootHex,
|
|
788
|
-
epoch
|
|
884
|
+
epoch,
|
|
885
|
+
payloadPresent,
|
|
789
886
|
};
|
|
790
887
|
}
|
|
791
|
-
function
|
|
888
|
+
function isBeaconStateView(stateOrBytes) {
|
|
792
889
|
return stateOrBytes.slot !== undefined;
|
|
793
890
|
}
|
|
794
891
|
function isInMemoryCacheItem(cacheItem) {
|
|
@@ -797,7 +894,4 @@ function isInMemoryCacheItem(cacheItem) {
|
|
|
797
894
|
function isPersistedCacheItem(cacheItem) {
|
|
798
895
|
return cacheItem.type === CacheItemType.persisted;
|
|
799
896
|
}
|
|
800
|
-
function isCheckpointHex(cp) {
|
|
801
|
-
return cp.rootHex !== undefined;
|
|
802
|
-
}
|
|
803
897
|
//# sourceMappingURL=persistentCheckpointsCache.js.map
|