@lodestar/beacon-node 1.39.1 → 1.40.0-dev.059f489b0f
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 +23 -27
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/beacon/state/utils.d.ts +2 -7
- package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
- package/lib/api/impl/beacon/state/utils.js +0 -12
- package/lib/api/impl/beacon/state/utils.js.map +1 -1
- package/lib/api/impl/config/constants.d.ts +3 -0
- package/lib/api/impl/config/constants.d.ts.map +1 -1
- package/lib/api/impl/config/constants.js +5 -1
- package/lib/api/impl/config/constants.js.map +1 -1
- package/lib/api/impl/debug/index.d.ts +1 -1
- package/lib/api/impl/debug/index.d.ts.map +1 -1
- package/lib/api/impl/debug/index.js +3 -6
- package/lib/api/impl/debug/index.js.map +1 -1
- package/lib/api/impl/lodestar/index.d.ts.map +1 -1
- package/lib/api/impl/lodestar/index.js +30 -3
- 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 +1 -2
- 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 +10 -11
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/api/rest/base.d.ts.map +1 -1
- package/lib/api/rest/base.js +2 -2
- package/lib/api/rest/base.js.map +1 -1
- package/lib/chain/ColumnReconstructionTracker.d.ts +2 -0
- package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
- package/lib/chain/ColumnReconstructionTracker.js +7 -3
- package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
- package/lib/chain/archiveStore/historicalState/getHistoricalState.js +7 -4
- package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.js +23 -14
- package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
- package/lib/chain/blocks/blockInput/blockInput.d.ts +30 -0
- package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
- package/lib/chain/blocks/blockInput/blockInput.js +44 -3
- package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
- package/lib/chain/blocks/importBlock.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.js +15 -10
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/blocks/index.d.ts.map +1 -1
- package/lib/chain/blocks/index.js +0 -14
- package/lib/chain/blocks/index.js.map +1 -1
- package/lib/chain/blocks/types.d.ts +0 -2
- package/lib/chain/blocks/types.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlock.js +9 -9
- package/lib/chain/blocks/verifyBlock.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.map +1 -1
- package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js +2 -2
- package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js.map +1 -1
- package/lib/chain/blocks/writeBlockInputToDb.d.ts +1 -4
- package/lib/chain/blocks/writeBlockInputToDb.d.ts.map +1 -1
- package/lib/chain/blocks/writeBlockInputToDb.js +28 -28
- package/lib/chain/blocks/writeBlockInputToDb.js.map +1 -1
- package/lib/chain/bls/multithread/index.d.ts +3 -1
- package/lib/chain/bls/multithread/index.d.ts.map +1 -1
- package/lib/chain/bls/multithread/index.js +5 -3
- package/lib/chain/bls/multithread/index.js.map +1 -1
- package/lib/chain/bls/multithread/jobItem.d.ts +2 -2
- package/lib/chain/bls/multithread/jobItem.d.ts.map +1 -1
- package/lib/chain/bls/multithread/jobItem.js +2 -2
- package/lib/chain/bls/multithread/jobItem.js.map +1 -1
- package/lib/chain/bls/singleThread.d.ts +4 -2
- package/lib/chain/bls/singleThread.d.ts.map +1 -1
- package/lib/chain/bls/singleThread.js +4 -2
- package/lib/chain/bls/singleThread.js.map +1 -1
- package/lib/chain/bls/utils.d.ts +2 -2
- package/lib/chain/bls/utils.d.ts.map +1 -1
- package/lib/chain/bls/utils.js +9 -6
- package/lib/chain/bls/utils.js.map +1 -1
- package/lib/chain/chain.d.ts +25 -7
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +213 -50
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/errors/attestationError.d.ts +14 -1
- package/lib/chain/errors/attestationError.d.ts.map +1 -1
- package/lib/chain/errors/attestationError.js +8 -0
- package/lib/chain/errors/attestationError.js.map +1 -1
- package/lib/chain/errors/executionPayloadBid.d.ts +48 -0
- package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -0
- package/lib/chain/errors/executionPayloadBid.js +15 -0
- package/lib/chain/errors/executionPayloadBid.js.map +1 -0
- package/lib/chain/errors/executionPayloadEnvelope.d.ts +48 -0
- package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -0
- package/lib/chain/errors/executionPayloadEnvelope.js +16 -0
- package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -0
- package/lib/chain/errors/index.d.ts +3 -0
- package/lib/chain/errors/index.d.ts.map +1 -1
- package/lib/chain/errors/index.js +3 -0
- package/lib/chain/errors/index.js.map +1 -1
- package/lib/chain/errors/payloadAttestation.d.ts +34 -0
- package/lib/chain/errors/payloadAttestation.d.ts.map +1 -0
- package/lib/chain/errors/payloadAttestation.js +13 -0
- package/lib/chain/errors/payloadAttestation.js.map +1 -0
- package/lib/chain/forkChoice/index.d.ts.map +1 -1
- package/lib/chain/forkChoice/index.js +18 -0
- package/lib/chain/forkChoice/index.js.map +1 -1
- package/lib/chain/initState.d.ts +1 -1
- package/lib/chain/initState.d.ts.map +1 -1
- package/lib/chain/initState.js +7 -5
- package/lib/chain/initState.js.map +1 -1
- package/lib/chain/interface.d.ts +23 -5
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/interface.js.map +1 -1
- package/lib/chain/lightClient/index.d.ts.map +1 -1
- package/lib/chain/lightClient/index.js +1 -2
- package/lib/chain/lightClient/index.js.map +1 -1
- package/lib/chain/lightClient/proofs.d.ts.map +1 -1
- package/lib/chain/lightClient/proofs.js +0 -2
- package/lib/chain/lightClient/proofs.js.map +1 -1
- package/lib/chain/opPools/aggregatedAttestationPool.d.ts +5 -9
- package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
- package/lib/chain/opPools/aggregatedAttestationPool.js +12 -141
- package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
- package/lib/chain/opPools/executionPayloadBidPool.d.ts +21 -0
- package/lib/chain/opPools/executionPayloadBidPool.d.ts.map +1 -0
- package/lib/chain/opPools/executionPayloadBidPool.js +57 -0
- package/lib/chain/opPools/executionPayloadBidPool.js.map +1 -0
- package/lib/chain/opPools/index.d.ts +2 -0
- package/lib/chain/opPools/index.d.ts.map +1 -1
- package/lib/chain/opPools/index.js +2 -0
- package/lib/chain/opPools/index.js.map +1 -1
- package/lib/chain/opPools/opPool.js +5 -8
- package/lib/chain/opPools/opPool.js.map +1 -1
- package/lib/chain/opPools/payloadAttestationPool.d.ts +24 -0
- package/lib/chain/opPools/payloadAttestationPool.d.ts.map +1 -0
- package/lib/chain/opPools/payloadAttestationPool.js +109 -0
- package/lib/chain/opPools/payloadAttestationPool.js.map +1 -0
- package/lib/chain/options.d.ts +0 -1
- package/lib/chain/options.d.ts.map +1 -1
- package/lib/chain/options.js +0 -1
- package/lib/chain/options.js.map +1 -1
- package/lib/chain/prepareNextSlot.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +9 -10
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +3 -2
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +6 -4
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/regen/interface.d.ts +5 -14
- package/lib/chain/regen/interface.d.ts.map +1 -1
- package/lib/chain/regen/interface.js +1 -1
- package/lib/chain/regen/interface.js.map +1 -1
- package/lib/chain/regen/queued.d.ts +6 -10
- package/lib/chain/regen/queued.d.ts.map +1 -1
- package/lib/chain/regen/queued.js +16 -40
- package/lib/chain/regen/queued.js.map +1 -1
- package/lib/chain/regen/regen.d.ts +6 -8
- package/lib/chain/regen/regen.d.ts.map +1 -1
- package/lib/chain/regen/regen.js +20 -34
- package/lib/chain/regen/regen.js.map +1 -1
- package/lib/chain/seenCache/index.d.ts +3 -1
- package/lib/chain/seenCache/index.d.ts.map +1 -1
- package/lib/chain/seenCache/index.js +3 -1
- package/lib/chain/seenCache/index.js.map +1 -1
- package/lib/chain/seenCache/seenAttesters.d.ts +5 -0
- package/lib/chain/seenCache/seenAttesters.d.ts.map +1 -1
- package/lib/chain/seenCache/seenAttesters.js +5 -0
- package/lib/chain/seenCache/seenAttesters.js.map +1 -1
- package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts +12 -0
- package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts.map +1 -0
- package/lib/chain/seenCache/seenExecutionPayloadBids.js +30 -0
- package/lib/chain/seenCache/seenExecutionPayloadBids.js.map +1 -0
- package/lib/chain/seenCache/seenExecutionPayloadEnvelope.d.ts +15 -0
- package/lib/chain/seenCache/seenExecutionPayloadEnvelope.d.ts.map +1 -0
- package/lib/chain/seenCache/seenExecutionPayloadEnvelope.js +28 -0
- package/lib/chain/seenCache/seenExecutionPayloadEnvelope.js.map +1 -0
- package/lib/chain/seenCache/seenGossipBlockInput.d.ts.map +1 -1
- package/lib/chain/seenCache/seenGossipBlockInput.js +3 -3
- package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
- package/lib/chain/shufflingCache.d.ts +16 -11
- package/lib/chain/shufflingCache.d.ts.map +1 -1
- package/lib/chain/shufflingCache.js +47 -41
- package/lib/chain/shufflingCache.js.map +1 -1
- package/lib/chain/stateCache/fifoBlockStateCache.d.ts +1 -2
- package/lib/chain/stateCache/fifoBlockStateCache.d.ts.map +1 -1
- package/lib/chain/stateCache/fifoBlockStateCache.js +4 -4
- package/lib/chain/stateCache/fifoBlockStateCache.js.map +1 -1
- package/lib/chain/stateCache/index.d.ts +0 -2
- package/lib/chain/stateCache/index.d.ts.map +1 -1
- package/lib/chain/stateCache/index.js +0 -2
- package/lib/chain/stateCache/index.js.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +7 -7
- package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.js +20 -17
- package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
- package/lib/chain/stateCache/types.d.ts +5 -6
- package/lib/chain/stateCache/types.d.ts.map +1 -1
- package/lib/chain/stateCache/types.js.map +1 -1
- package/lib/chain/validation/aggregateAndProof.js +35 -14
- package/lib/chain/validation/aggregateAndProof.js.map +1 -1
- package/lib/chain/validation/attestation.d.ts +2 -2
- package/lib/chain/validation/attestation.d.ts.map +1 -1
- package/lib/chain/validation/attestation.js +28 -9
- package/lib/chain/validation/attestation.js.map +1 -1
- package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
- package/lib/chain/validation/attesterSlashing.js +2 -2
- package/lib/chain/validation/attesterSlashing.js.map +1 -1
- package/lib/chain/validation/blobSidecar.d.ts.map +1 -1
- package/lib/chain/validation/blobSidecar.js +5 -5
- 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 +8 -6
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/chain/validation/blsToExecutionChange.d.ts.map +1 -1
- package/lib/chain/validation/blsToExecutionChange.js +9 -2
- package/lib/chain/validation/blsToExecutionChange.js.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.js +5 -5
- package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
- package/lib/chain/validation/executionPayloadBid.d.ts +5 -0
- package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -0
- package/lib/chain/validation/executionPayloadBid.js +104 -0
- package/lib/chain/validation/executionPayloadBid.js.map +1 -0
- package/lib/chain/validation/executionPayloadEnvelope.d.ts +5 -0
- package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -0
- package/lib/chain/validation/executionPayloadEnvelope.js +89 -0
- package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -0
- package/lib/chain/validation/payloadAttestationMessage.d.ts +9 -0
- package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -0
- package/lib/chain/validation/payloadAttestationMessage.js +72 -0
- package/lib/chain/validation/payloadAttestationMessage.js.map +1 -0
- package/lib/chain/validation/proposerSlashing.js +3 -2
- package/lib/chain/validation/proposerSlashing.js.map +1 -1
- package/lib/chain/validation/signatureSets/aggregateAndProof.d.ts +2 -3
- package/lib/chain/validation/signatureSets/aggregateAndProof.d.ts.map +1 -1
- package/lib/chain/validation/signatureSets/aggregateAndProof.js +8 -3
- package/lib/chain/validation/signatureSets/aggregateAndProof.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 +3 -3
- package/lib/chain/validation/signatureSets/contributionAndProof.js.map +1 -1
- package/lib/chain/validation/signatureSets/selectionProof.d.ts +2 -3
- package/lib/chain/validation/signatureSets/selectionProof.d.ts.map +1 -1
- package/lib/chain/validation/signatureSets/selectionProof.js +8 -3
- package/lib/chain/validation/signatureSets/selectionProof.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 +3 -3
- package/lib/chain/validation/signatureSets/syncCommittee.js.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts +1 -2
- package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommitteeContribution.js +2 -2
- 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 +3 -3
- package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js.map +1 -1
- package/lib/chain/validation/syncCommittee.js +1 -1
- 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 +3 -5
- package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
- package/lib/chain/validation/voluntaryExit.js +1 -1
- package/lib/chain/validation/voluntaryExit.js.map +1 -1
- package/lib/chain/validatorMonitor.d.ts +2 -0
- package/lib/chain/validatorMonitor.d.ts.map +1 -1
- package/lib/chain/validatorMonitor.js +49 -7
- package/lib/chain/validatorMonitor.js.map +1 -1
- package/lib/db/repositories/checkpointState.d.ts +2 -6
- package/lib/db/repositories/checkpointState.d.ts.map +1 -1
- package/lib/db/repositories/checkpointState.js +3 -16
- package/lib/db/repositories/checkpointState.js.map +1 -1
- package/lib/db/repositories/stateArchive.d.ts +9 -9
- package/lib/db/repositories/stateArchive.d.ts.map +1 -1
- package/lib/db/repositories/stateArchive.js +6 -21
- package/lib/db/repositories/stateArchive.js.map +1 -1
- package/lib/execution/engine/mock.d.ts +9 -6
- package/lib/execution/engine/mock.d.ts.map +1 -1
- package/lib/execution/engine/mock.js +34 -7
- package/lib/execution/engine/mock.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +28 -6
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +67 -17
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/core/networkCore.d.ts +3 -0
- package/lib/network/core/networkCore.d.ts.map +1 -1
- package/lib/network/core/networkCore.js +9 -0
- package/lib/network/core/networkCore.js.map +1 -1
- package/lib/network/core/networkCoreWorker.js +3 -0
- package/lib/network/core/networkCoreWorker.js.map +1 -1
- package/lib/network/core/networkCoreWorkerHandler.d.ts +3 -0
- package/lib/network/core/networkCoreWorkerHandler.d.ts.map +1 -1
- package/lib/network/core/networkCoreWorkerHandler.js +9 -0
- package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
- package/lib/network/core/types.d.ts +3 -0
- package/lib/network/core/types.d.ts.map +1 -1
- package/lib/network/gossip/gossipsub.d.ts +34 -0
- package/lib/network/gossip/gossipsub.d.ts.map +1 -1
- package/lib/network/gossip/gossipsub.js +123 -0
- package/lib/network/gossip/gossipsub.js.map +1 -1
- package/lib/network/gossip/interface.d.ts +20 -2
- package/lib/network/gossip/interface.d.ts.map +1 -1
- package/lib/network/gossip/interface.js +3 -0
- package/lib/network/gossip/interface.js.map +1 -1
- package/lib/network/gossip/scoringParameters.d.ts.map +1 -1
- package/lib/network/gossip/scoringParameters.js +38 -2
- package/lib/network/gossip/scoringParameters.js.map +1 -1
- package/lib/network/gossip/topic.d.ts +77 -1
- package/lib/network/gossip/topic.d.ts.map +1 -1
- package/lib/network/gossip/topic.js +20 -0
- package/lib/network/gossip/topic.js.map +1 -1
- package/lib/network/network.d.ts +3 -0
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js +9 -0
- package/lib/network/network.js.map +1 -1
- package/lib/network/options.d.ts +6 -0
- package/lib/network/options.d.ts.map +1 -1
- package/lib/network/options.js.map +1 -1
- package/lib/network/peers/peerManager.d.ts.map +1 -1
- package/lib/network/peers/peerManager.js +9 -0
- package/lib/network/peers/peerManager.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +35 -4
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/gossipQueues/index.d.ts.map +1 -1
- package/lib/network/processor/gossipQueues/index.js +16 -0
- package/lib/network/processor/gossipQueues/index.js.map +1 -1
- package/lib/network/processor/index.d.ts.map +1 -1
- package/lib/network/processor/index.js +3 -0
- package/lib/network/processor/index.js.map +1 -1
- package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/beaconBlocksByRange.js +2 -4
- package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/beaconBlocksByRoot.d.ts +1 -2
- package/lib/network/reqresp/handlers/beaconBlocksByRoot.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/beaconBlocksByRoot.js +5 -26
- package/lib/network/reqresp/handlers/beaconBlocksByRoot.js.map +1 -1
- package/lib/network/reqresp/handlers/blobSidecarsByRoot.d.ts +1 -2
- package/lib/network/reqresp/handlers/blobSidecarsByRoot.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/blobSidecarsByRoot.js +5 -7
- package/lib/network/reqresp/handlers/blobSidecarsByRoot.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +1 -2
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +1 -5
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
- package/lib/network/reqresp/handlers/index.js +2 -2
- package/lib/network/reqresp/handlers/index.js.map +1 -1
- package/lib/network/reqresp/utils/dataColumnResponseValidation.js +1 -1
- package/lib/network/reqresp/utils/dataColumnResponseValidation.js.map +1 -1
- package/lib/node/nodejs.d.ts.map +1 -1
- package/lib/node/nodejs.js +17 -2
- package/lib/node/nodejs.js.map +1 -1
- package/lib/sync/backfill/backfill.d.ts.map +1 -1
- package/lib/sync/backfill/backfill.js +3 -4
- package/lib/sync/backfill/backfill.js.map +1 -1
- package/lib/sync/backfill/verify.d.ts +1 -2
- package/lib/sync/backfill/verify.d.ts.map +1 -1
- package/lib/sync/backfill/verify.js +2 -2
- package/lib/sync/backfill/verify.js.map +1 -1
- package/lib/sync/range/chain.d.ts.map +1 -1
- package/lib/sync/range/chain.js +0 -1
- package/lib/sync/range/chain.js.map +1 -1
- package/lib/sync/range/range.d.ts.map +1 -1
- package/lib/sync/range/range.js +0 -3
- package/lib/sync/range/range.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +0 -3
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRange.js +2 -2
- package/lib/sync/utils/downloadByRange.js.map +1 -1
- package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRoot.js +1 -2
- package/lib/sync/utils/downloadByRoot.js.map +1 -1
- package/lib/util/sszBytes.js +1 -1
- package/lib/util/sszBytes.js.map +1 -1
- package/package.json +16 -16
- package/src/api/impl/beacon/blocks/index.ts +39 -37
- package/src/api/impl/beacon/state/utils.ts +2 -22
- package/src/api/impl/config/constants.ts +8 -0
- package/src/api/impl/debug/index.ts +2 -6
- package/src/api/impl/lodestar/index.ts +36 -4
- package/src/api/impl/proof/index.ts +1 -2
- package/src/api/impl/validator/index.ts +15 -15
- package/src/api/rest/base.ts +4 -4
- package/src/chain/ColumnReconstructionTracker.ts +8 -4
- package/src/chain/archiveStore/historicalState/getHistoricalState.ts +7 -4
- package/src/chain/archiveStore/utils/archiveBlocks.ts +25 -14
- package/src/chain/blocks/blockInput/blockInput.ts +55 -4
- package/src/chain/blocks/importBlock.ts +16 -10
- package/src/chain/blocks/index.ts +0 -19
- package/src/chain/blocks/types.ts +0 -2
- package/src/chain/blocks/verifyBlock.ts +9 -12
- package/src/chain/blocks/verifyBlocksSignatures.ts +4 -12
- package/src/chain/blocks/verifyBlocksStateTransitionOnly.ts +2 -2
- package/src/chain/blocks/writeBlockInputToDb.ts +33 -30
- package/src/chain/bls/multithread/index.ts +7 -4
- package/src/chain/bls/multithread/jobItem.ts +7 -3
- package/src/chain/bls/singleThread.ts +5 -3
- package/src/chain/bls/utils.ts +15 -7
- package/src/chain/chain.ts +247 -65
- package/src/chain/errors/attestationError.ts +11 -1
- package/src/chain/errors/executionPayloadBid.ts +35 -0
- package/src/chain/errors/executionPayloadEnvelope.ts +34 -0
- package/src/chain/errors/index.ts +3 -0
- package/src/chain/errors/payloadAttestation.ts +25 -0
- package/src/chain/forkChoice/index.ts +19 -0
- package/src/chain/initState.ts +7 -5
- package/src/chain/interface.ts +34 -3
- package/src/chain/lightClient/index.ts +1 -2
- package/src/chain/lightClient/proofs.ts +0 -2
- package/src/chain/opPools/aggregatedAttestationPool.ts +19 -191
- package/src/chain/opPools/executionPayloadBidPool.ts +77 -0
- package/src/chain/opPools/index.ts +2 -0
- package/src/chain/opPools/opPool.ts +5 -7
- package/src/chain/opPools/payloadAttestationPool.ts +157 -0
- package/src/chain/options.ts +0 -2
- package/src/chain/prepareNextSlot.ts +8 -12
- package/src/chain/produceBlock/produceBlockBody.ts +13 -6
- package/src/chain/regen/interface.ts +4 -18
- package/src/chain/regen/queued.ts +17 -57
- package/src/chain/regen/regen.ts +22 -43
- package/src/chain/seenCache/index.ts +3 -1
- package/src/chain/seenCache/seenAttesters.ts +5 -0
- package/src/chain/seenCache/seenExecutionPayloadBids.ts +35 -0
- package/src/chain/seenCache/seenExecutionPayloadEnvelope.ts +34 -0
- package/src/chain/seenCache/seenGossipBlockInput.ts +3 -3
- package/src/chain/shufflingCache.ts +67 -50
- package/src/chain/stateCache/fifoBlockStateCache.ts +4 -5
- package/src/chain/stateCache/index.ts +0 -2
- package/src/chain/stateCache/persistentCheckpointsCache.ts +23 -27
- package/src/chain/stateCache/types.ts +5 -10
- package/src/chain/validation/aggregateAndProof.ts +36 -14
- package/src/chain/validation/attestation.ts +36 -19
- package/src/chain/validation/attesterSlashing.ts +9 -7
- package/src/chain/validation/blobSidecar.ts +4 -9
- package/src/chain/validation/block.ts +9 -6
- package/src/chain/validation/blsToExecutionChange.ts +9 -7
- package/src/chain/validation/dataColumnSidecar.ts +4 -9
- package/src/chain/validation/executionPayloadBid.ts +141 -0
- package/src/chain/validation/executionPayloadEnvelope.ts +122 -0
- package/src/chain/validation/payloadAttestationMessage.ts +109 -0
- package/src/chain/validation/proposerSlashing.ts +3 -7
- package/src/chain/validation/signatureSets/aggregateAndProof.ts +9 -14
- package/src/chain/validation/signatureSets/contributionAndProof.ts +2 -4
- package/src/chain/validation/signatureSets/selectionProof.ts +9 -9
- package/src/chain/validation/signatureSets/syncCommittee.ts +2 -4
- package/src/chain/validation/signatureSets/syncCommitteeContribution.ts +2 -3
- package/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts +2 -4
- package/src/chain/validation/syncCommittee.ts +1 -1
- package/src/chain/validation/syncCommitteeContributionAndProof.ts +3 -5
- package/src/chain/validation/voluntaryExit.ts +1 -1
- package/src/chain/validatorMonitor.ts +62 -8
- package/src/db/repositories/checkpointState.ts +3 -19
- package/src/db/repositories/stateArchive.ts +13 -27
- package/src/execution/engine/mock.ts +40 -13
- package/src/index.ts +1 -1
- package/src/metrics/metrics/lodestar.ts +68 -17
- package/src/network/core/networkCore.ts +12 -0
- package/src/network/core/networkCoreWorker.ts +3 -0
- package/src/network/core/networkCoreWorkerHandler.ts +9 -0
- package/src/network/core/types.ts +6 -0
- package/src/network/gossip/gossipsub.ts +147 -1
- package/src/network/gossip/interface.ts +17 -0
- package/src/network/gossip/scoringParameters.ts +44 -2
- package/src/network/gossip/topic.ts +21 -0
- package/src/network/network.ts +12 -0
- package/src/network/options.ts +6 -0
- package/src/network/peers/peerManager.ts +11 -0
- package/src/network/processor/gossipHandlers.ts +49 -4
- package/src/network/processor/gossipQueues/index.ts +16 -0
- package/src/network/processor/index.ts +3 -0
- package/src/network/reqresp/handlers/beaconBlocksByRange.ts +2 -4
- package/src/network/reqresp/handlers/beaconBlocksByRoot.ts +5 -32
- package/src/network/reqresp/handlers/blobSidecarsByRoot.ts +5 -9
- package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +5 -2
- package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +1 -5
- package/src/network/reqresp/handlers/index.ts +2 -2
- package/src/network/reqresp/utils/dataColumnResponseValidation.ts +1 -1
- package/src/node/nodejs.ts +18 -3
- package/src/sync/backfill/backfill.ts +3 -4
- package/src/sync/backfill/verify.ts +2 -3
- package/src/sync/range/chain.ts +0 -1
- package/src/sync/range/range.ts +0 -3
- package/src/sync/unknownBlock.ts +0 -3
- package/src/sync/utils/downloadByRange.ts +2 -2
- package/src/sync/utils/downloadByRoot.ts +1 -2
- package/src/util/sszBytes.ts +1 -1
- package/lib/chain/stateCache/blockStateCacheImpl.d.ts +0 -55
- package/lib/chain/stateCache/blockStateCacheImpl.d.ts.map +0 -1
- package/lib/chain/stateCache/blockStateCacheImpl.js +0 -130
- package/lib/chain/stateCache/blockStateCacheImpl.js.map +0 -1
- package/lib/chain/stateCache/inMemoryCheckpointsCache.d.ts +0 -61
- package/lib/chain/stateCache/inMemoryCheckpointsCache.d.ts.map +0 -1
- package/lib/chain/stateCache/inMemoryCheckpointsCache.js +0 -157
- package/lib/chain/stateCache/inMemoryCheckpointsCache.js.map +0 -1
- package/lib/util/bytes.d.ts +0 -3
- package/lib/util/bytes.d.ts.map +0 -1
- package/lib/util/bytes.js +0 -11
- package/lib/util/bytes.js.map +0 -1
- package/src/chain/stateCache/blockStateCacheImpl.ts +0 -150
- package/src/chain/stateCache/inMemoryCheckpointsCache.ts +0 -198
- package/src/util/bytes.ts +0 -11
package/src/chain/regen/regen.ts
CHANGED
|
@@ -11,13 +11,14 @@ import {
|
|
|
11
11
|
processSlots,
|
|
12
12
|
stateTransition,
|
|
13
13
|
} from "@lodestar/state-transition";
|
|
14
|
-
import {BeaconBlock, RootHex, SignedBeaconBlock, Slot
|
|
14
|
+
import {BeaconBlock, RootHex, SignedBeaconBlock, Slot} from "@lodestar/types";
|
|
15
15
|
import {Logger, fromHex, toRootHex} from "@lodestar/utils";
|
|
16
16
|
import {IBeaconDb} from "../../db/index.js";
|
|
17
17
|
import {Metrics} from "../../metrics/index.js";
|
|
18
18
|
import {nextEventLoop} from "../../util/eventLoop.js";
|
|
19
19
|
import {getCheckpointFromState} from "../blocks/utils/checkpoint.js";
|
|
20
20
|
import {ChainEvent, ChainEventEmitter} from "../emitter.js";
|
|
21
|
+
import {SeenBlockInput} from "../seenCache/seenGossipBlockInput.js";
|
|
21
22
|
import {BlockStateCache, CheckpointStateCache} from "../stateCache/types.js";
|
|
22
23
|
import {ValidatorMonitor} from "../validatorMonitor.js";
|
|
23
24
|
import {RegenError, RegenErrorCode} from "./errors.js";
|
|
@@ -28,6 +29,7 @@ export type RegenModules = {
|
|
|
28
29
|
forkChoice: IForkChoice;
|
|
29
30
|
blockStateCache: BlockStateCache;
|
|
30
31
|
checkpointStateCache: CheckpointStateCache;
|
|
32
|
+
seenBlockInputCache: SeenBlockInput;
|
|
31
33
|
config: ChainForkConfig;
|
|
32
34
|
emitter: ChainEventEmitter;
|
|
33
35
|
logger: Logger;
|
|
@@ -74,24 +76,11 @@ export class StateRegenerator implements IStateRegeneratorInternal {
|
|
|
74
76
|
// We may have the checkpoint state with parent root inside the checkpoint state cache
|
|
75
77
|
// through gossip validation.
|
|
76
78
|
if (parentEpoch < blockEpoch) {
|
|
77
|
-
return this.
|
|
79
|
+
return this.getBlockSlotState(parentBlock, block.slot, opts, regenCaller, allowDiskReload);
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
// Otherwise, get the state normally.
|
|
81
|
-
return this.getState(parentBlock.stateRoot, regenCaller,
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Get state after block `cp.root` dialed forward to first slot of `cp.epoch`
|
|
86
|
-
*/
|
|
87
|
-
async getCheckpointState(
|
|
88
|
-
cp: phase0.Checkpoint,
|
|
89
|
-
opts: StateRegenerationOpts,
|
|
90
|
-
regenCaller: RegenCaller,
|
|
91
|
-
allowDiskReload = false
|
|
92
|
-
): Promise<CachedBeaconStateAllForks> {
|
|
93
|
-
const checkpointStartSlot = computeStartSlotAtEpoch(cp.epoch);
|
|
94
|
-
return this.getBlockSlotState(toRootHex(cp.root), checkpointStartSlot, opts, regenCaller, allowDiskReload);
|
|
83
|
+
return this.getState(parentBlock.stateRoot, regenCaller, allowDiskReload);
|
|
95
84
|
}
|
|
96
85
|
|
|
97
86
|
/**
|
|
@@ -99,20 +88,12 @@ export class StateRegenerator implements IStateRegeneratorInternal {
|
|
|
99
88
|
* - allowDiskReload should be used with care, as it will cause the state to be reloaded from disk
|
|
100
89
|
*/
|
|
101
90
|
async getBlockSlotState(
|
|
102
|
-
|
|
91
|
+
block: ProtoBlock,
|
|
103
92
|
slot: Slot,
|
|
104
93
|
opts: StateRegenerationOpts,
|
|
105
94
|
regenCaller: RegenCaller,
|
|
106
95
|
allowDiskReload = false
|
|
107
96
|
): Promise<CachedBeaconStateAllForks> {
|
|
108
|
-
const block = this.modules.forkChoice.getBlockHex(blockRoot);
|
|
109
|
-
if (!block) {
|
|
110
|
-
throw new RegenError({
|
|
111
|
-
code: RegenErrorCode.BLOCK_NOT_IN_FORKCHOICE,
|
|
112
|
-
blockRoot,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
97
|
if (slot < block.slot) {
|
|
117
98
|
throw new RegenError({
|
|
118
99
|
code: RegenErrorCode.SLOT_BEFORE_BLOCK_SLOT,
|
|
@@ -121,11 +102,12 @@ export class StateRegenerator implements IStateRegeneratorInternal {
|
|
|
121
102
|
});
|
|
122
103
|
}
|
|
123
104
|
|
|
105
|
+
const {blockRoot} = block;
|
|
124
106
|
const {checkpointStateCache} = this.modules;
|
|
125
107
|
const epoch = computeEpochAtSlot(slot);
|
|
126
108
|
const latestCheckpointStateCtx = allowDiskReload
|
|
127
|
-
? await checkpointStateCache.getOrReloadLatest(blockRoot, epoch
|
|
128
|
-
: checkpointStateCache.getLatest(blockRoot, epoch
|
|
109
|
+
? await checkpointStateCache.getOrReloadLatest(blockRoot, epoch)
|
|
110
|
+
: checkpointStateCache.getLatest(blockRoot, epoch);
|
|
129
111
|
|
|
130
112
|
// If a checkpoint state exists with the given checkpoint root, it either is in requested epoch
|
|
131
113
|
// or needs to have empty slots processed until the requested epoch
|
|
@@ -136,7 +118,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
|
|
|
136
118
|
// Otherwise, use the fork choice to get the stateRoot from block at the checkpoint root
|
|
137
119
|
// regenerate that state,
|
|
138
120
|
// then process empty slots until the requested epoch
|
|
139
|
-
const blockStateCtx = await this.getState(block.stateRoot, regenCaller,
|
|
121
|
+
const blockStateCtx = await this.getState(block.stateRoot, regenCaller, allowDiskReload);
|
|
140
122
|
return processSlotsByCheckpoint(this.modules, blockStateCtx, slot, regenCaller, opts);
|
|
141
123
|
}
|
|
142
124
|
|
|
@@ -148,23 +130,15 @@ export class StateRegenerator implements IStateRegeneratorInternal {
|
|
|
148
130
|
async getState(
|
|
149
131
|
stateRoot: RootHex,
|
|
150
132
|
caller: RegenCaller,
|
|
151
|
-
opts?: StateRegenerationOpts,
|
|
152
133
|
// internal option, don't want to expose to external caller
|
|
153
134
|
allowDiskReload = false
|
|
154
135
|
): Promise<CachedBeaconStateAllForks> {
|
|
155
136
|
// Trivial case, state at stateRoot is already cached
|
|
156
|
-
const cachedStateCtx = this.modules.blockStateCache.get(stateRoot
|
|
137
|
+
const cachedStateCtx = this.modules.blockStateCache.get(stateRoot);
|
|
157
138
|
if (cachedStateCtx) {
|
|
158
139
|
return cachedStateCtx;
|
|
159
140
|
}
|
|
160
141
|
|
|
161
|
-
// in block gossip validation (getPreState() call), dontTransferCache is specified as true because we only want to transfer cache in verifyBlocksStateTransitionOnly()
|
|
162
|
-
// but here we want to process blocks as fast as possible so force to transfer cache in this case
|
|
163
|
-
if (opts && allowDiskReload) {
|
|
164
|
-
// if there is no `opts` specified, it already means "false"
|
|
165
|
-
opts.dontTransferCache = false;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
142
|
// Otherwise we have to use the fork choice to traverse backwards, block by block,
|
|
169
143
|
// searching the state caches
|
|
170
144
|
// then replay blocks forward to the desired stateRoot
|
|
@@ -179,7 +153,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
|
|
|
179
153
|
const getSeedStateTimer = this.modules.metrics?.regenGetState.getSeedState.startTimer({caller});
|
|
180
154
|
// iterateAncestorBlocks only returns ancestor blocks, not the block itself
|
|
181
155
|
for (const b of this.modules.forkChoice.iterateAncestorBlocks(block.blockRoot)) {
|
|
182
|
-
state = this.modules.blockStateCache.get(b.stateRoot
|
|
156
|
+
state = this.modules.blockStateCache.get(b.stateRoot);
|
|
183
157
|
if (state) {
|
|
184
158
|
break;
|
|
185
159
|
}
|
|
@@ -187,8 +161,8 @@ export class StateRegenerator implements IStateRegeneratorInternal {
|
|
|
187
161
|
if (!lastBlockToReplay) continue;
|
|
188
162
|
const epoch = computeEpochAtSlot(lastBlockToReplay.slot - 1);
|
|
189
163
|
state = allowDiskReload
|
|
190
|
-
? await checkpointStateCache.getOrReloadLatest(b.blockRoot, epoch
|
|
191
|
-
: checkpointStateCache.getLatest(b.blockRoot, epoch
|
|
164
|
+
? await checkpointStateCache.getOrReloadLatest(b.blockRoot, epoch)
|
|
165
|
+
: checkpointStateCache.getLatest(b.blockRoot, epoch);
|
|
192
166
|
if (state) {
|
|
193
167
|
break;
|
|
194
168
|
}
|
|
@@ -219,7 +193,10 @@ export class StateRegenerator implements IStateRegeneratorInternal {
|
|
|
219
193
|
const protoBlocksAsc = blocksToReplay.reverse();
|
|
220
194
|
for (const [i, protoBlock] of protoBlocksAsc.entries()) {
|
|
221
195
|
replaySlots[i] = protoBlock.slot;
|
|
222
|
-
|
|
196
|
+
const blockInput = this.modules.seenBlockInputCache.get(protoBlock.blockRoot);
|
|
197
|
+
blockPromises[i] = blockInput?.hasBlock()
|
|
198
|
+
? Promise.resolve(blockInput.getBlock())
|
|
199
|
+
: this.modules.db.block.get(fromHex(protoBlock.blockRoot));
|
|
223
200
|
}
|
|
224
201
|
|
|
225
202
|
const logCtx = {stateRoot, caller, replaySlots: replaySlots.join(",")};
|
|
@@ -255,6 +232,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
|
|
|
255
232
|
try {
|
|
256
233
|
// Only advances state trusting block's signture and hashes.
|
|
257
234
|
// We are only running the state transition to get a specific state's data.
|
|
235
|
+
// stateTransition() does the clone() inside, transfer cache to make the regen faster
|
|
258
236
|
state = stateTransition(
|
|
259
237
|
state,
|
|
260
238
|
block,
|
|
@@ -265,6 +243,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
|
|
|
265
243
|
verifyStateRoot: false,
|
|
266
244
|
verifyProposer: false,
|
|
267
245
|
verifySignatures: false,
|
|
246
|
+
dontTransferCache: false,
|
|
268
247
|
},
|
|
269
248
|
this.modules
|
|
270
249
|
);
|
|
@@ -390,8 +369,8 @@ export async function processSlotsToNearestCheckpoint(
|
|
|
390
369
|
const checkpointState = postState;
|
|
391
370
|
const cp = getCheckpointFromState(checkpointState);
|
|
392
371
|
checkpointStateCache.add(cp, checkpointState);
|
|
393
|
-
// consumers should not mutate
|
|
394
|
-
emitter?.emit(ChainEvent.checkpoint, cp, checkpointState
|
|
372
|
+
// consumers should not mutate state ever
|
|
373
|
+
emitter?.emit(ChainEvent.checkpoint, cp, checkpointState);
|
|
395
374
|
|
|
396
375
|
if (count >= 1) {
|
|
397
376
|
// in normal condition, we only process 1 epoch so never reach this
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export {SeenAggregators, SeenAttesters} from "./seenAttesters.js";
|
|
1
|
+
export {SeenAggregators, SeenAttesters, SeenPayloadAttesters} from "./seenAttesters.js";
|
|
2
2
|
export {SeenBlockProposers} from "./seenBlockProposers.js";
|
|
3
3
|
export {SeenSyncCommitteeMessages} from "./seenCommittee.js";
|
|
4
4
|
export {SeenContributionAndProof} from "./seenCommitteeContribution.js";
|
|
5
|
+
export {SeenExecutionPayloadBids} from "./seenExecutionPayloadBids.js";
|
|
6
|
+
export {SeenExecutionPayloadEnvelopes} from "./seenExecutionPayloadEnvelope.js";
|
|
5
7
|
export {SeenBlockInput} from "./seenGossipBlockInput.js";
|
|
@@ -56,3 +56,8 @@ export class SeenAttesters {
|
|
|
56
56
|
* Keeps a cache to filter aggregated attestations from the same aggregators in the same epoch
|
|
57
57
|
*/
|
|
58
58
|
export class SeenAggregators extends SeenAttesters {}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Keeps a cache to filter payload attestations from the same attesters in the same epoch
|
|
62
|
+
*/
|
|
63
|
+
export class SeenPayloadAttesters extends SeenAttesters {}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {BuilderIndex, Slot} from "@lodestar/types";
|
|
2
|
+
import {MapDef} from "@lodestar/utils";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* TODO GLOAS: Revisit this value and add rational for choosing it
|
|
6
|
+
*/
|
|
7
|
+
const SLOTS_RETAINED = 2;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Tracks execution payload bids we've already seen per (slot, builder).
|
|
11
|
+
*/
|
|
12
|
+
export class SeenExecutionPayloadBids {
|
|
13
|
+
private readonly builderIndexesBySlot = new MapDef<Slot, Set<BuilderIndex>>(() => new Set<BuilderIndex>());
|
|
14
|
+
private lowestPermissibleSlot: Slot = 0;
|
|
15
|
+
|
|
16
|
+
isKnown(slot: Slot, builderIndex: BuilderIndex): boolean {
|
|
17
|
+
return this.builderIndexesBySlot.get(slot)?.has(builderIndex) === true;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
add(slot: Slot, builderIndex: BuilderIndex): void {
|
|
21
|
+
if (slot < this.lowestPermissibleSlot) {
|
|
22
|
+
throw Error(`slot ${slot} < lowestPermissibleSlot ${this.lowestPermissibleSlot}`);
|
|
23
|
+
}
|
|
24
|
+
this.builderIndexesBySlot.getOrDefault(slot).add(builderIndex);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
prune(currentSlot: Slot): void {
|
|
28
|
+
this.lowestPermissibleSlot = Math.max(currentSlot - SLOTS_RETAINED, 0);
|
|
29
|
+
for (const slot of this.builderIndexesBySlot.keys()) {
|
|
30
|
+
if (slot < this.lowestPermissibleSlot) {
|
|
31
|
+
this.builderIndexesBySlot.delete(slot);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {RootHex, Slot} from "@lodestar/types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Cache to prevent processing multiple execution payload envelopes for the same block root.
|
|
5
|
+
* Only one builder qualifies to submit an execution payload for a given slot.
|
|
6
|
+
* We only keep track of envelopes of unfinalized slots.
|
|
7
|
+
* [IGNORE] The node has not seen another valid `SignedExecutionPayloadEnvelope` for this block root.
|
|
8
|
+
*/
|
|
9
|
+
export class SeenExecutionPayloadEnvelopes {
|
|
10
|
+
private readonly slotByBlockRoot = new Map<RootHex, Slot>();
|
|
11
|
+
private finalizedSlot: Slot = 0;
|
|
12
|
+
|
|
13
|
+
isKnown(blockRoot: RootHex): boolean {
|
|
14
|
+
return this.slotByBlockRoot.has(blockRoot);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
add(blockRoot: RootHex, slot: Slot): void {
|
|
18
|
+
if (slot < this.finalizedSlot) {
|
|
19
|
+
throw Error(`slot ${slot} < finalizedSlot ${this.finalizedSlot}`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
this.slotByBlockRoot.set(blockRoot, slot);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
prune(finalizedSlot: Slot): void {
|
|
26
|
+
this.finalizedSlot = finalizedSlot;
|
|
27
|
+
|
|
28
|
+
for (const [blockRoot, slot] of this.slotByBlockRoot.entries()) {
|
|
29
|
+
if (slot < finalizedSlot) {
|
|
30
|
+
this.slotByBlockRoot.delete(blockRoot);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -3,7 +3,7 @@ import {CheckpointWithHex} from "@lodestar/fork-choice";
|
|
|
3
3
|
import {ForkName, ForkPostFulu, ForkPreGloas, isForkPostDeneb, isForkPostFulu, isForkPostGloas} from "@lodestar/params";
|
|
4
4
|
import {computeStartSlotAtEpoch} from "@lodestar/state-transition";
|
|
5
5
|
import {BLSSignature, RootHex, SignedBeaconBlock, Slot, deneb, fulu} from "@lodestar/types";
|
|
6
|
-
import {LodestarError, Logger, pruneSetToMax} from "@lodestar/utils";
|
|
6
|
+
import {LodestarError, Logger, byteArrayEquals, pruneSetToMax} from "@lodestar/utils";
|
|
7
7
|
import {Metrics} from "../../metrics/metrics.js";
|
|
8
8
|
import {IClock} from "../../util/clock.js";
|
|
9
9
|
import {CustodyConfig} from "../../util/dataColumns.js";
|
|
@@ -344,7 +344,7 @@ export class SeenBlockInput {
|
|
|
344
344
|
return false;
|
|
345
345
|
}
|
|
346
346
|
// Only consider verified if the signature matches
|
|
347
|
-
return
|
|
347
|
+
return byteArrayEquals(cachedSignature, signature);
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
/**
|
|
@@ -379,7 +379,7 @@ export class SeenBlockInput {
|
|
|
379
379
|
let itemsToDelete = this.blockInputs.size - MAX_BLOCK_INPUT_CACHE_SIZE;
|
|
380
380
|
|
|
381
381
|
if (itemsToDelete > 0) {
|
|
382
|
-
const sorted = [...this.blockInputs.entries()].sort((a, b) =>
|
|
382
|
+
const sorted = [...this.blockInputs.entries()].sort((a, b) => a[1].slot - b[1].slot);
|
|
383
383
|
for (const [rootHex] of sorted) {
|
|
384
384
|
this.blockInputs.delete(rootHex);
|
|
385
385
|
itemsToDelete--;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import {ForkSeq} from "@lodestar/params";
|
|
1
2
|
import {
|
|
2
|
-
|
|
3
|
+
CachedBeaconStateAllForks,
|
|
3
4
|
EpochShuffling,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
computeEpochShufflingAsync,
|
|
5
|
+
getAttestingIndices,
|
|
6
|
+
getBeaconCommittees,
|
|
7
|
+
getIndexedAttestation,
|
|
8
8
|
} from "@lodestar/state-transition";
|
|
9
|
-
import {Epoch, RootHex} from "@lodestar/types";
|
|
9
|
+
import {Attestation, CommitteeIndex, Epoch, IndexedAttestation, RootHex, Slot} from "@lodestar/types";
|
|
10
10
|
import {LodestarError, Logger, MapDef, pruneSetToMax} from "@lodestar/utils";
|
|
11
11
|
import {Metrics} from "../metrics/metrics.js";
|
|
12
12
|
|
|
@@ -53,7 +53,7 @@ export type ShufflingCacheOpts = {
|
|
|
53
53
|
* - if a shuffling is not available (which does not happen with default chain option of maxSkipSlots = 32), track a promise to make sure we don't compute the same shuffling twice
|
|
54
54
|
* - skip computing shuffling when loading state bytes from disk
|
|
55
55
|
*/
|
|
56
|
-
export class ShufflingCache
|
|
56
|
+
export class ShufflingCache {
|
|
57
57
|
/** LRU cache implemented as a map, pruned every time we add an item */
|
|
58
58
|
private readonly itemsByDecisionRootByEpoch: MapDef<Epoch, Map<RootHex, CacheItem>> = new MapDef(
|
|
59
59
|
() => new Map<RootHex, CacheItem>()
|
|
@@ -136,60 +136,76 @@ export class ShufflingCache implements IShufflingCache {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
/**
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
* NOTE: If a shuffling is already queued and not calculated it will build and resolve
|
|
143
|
-
* the promise but the already queued build will happen at some later time
|
|
139
|
+
* Get a shuffling synchronously, return null if not present.
|
|
140
|
+
* The only time we have a promise cache item is when we regen shuffling for attestation, which never happens
|
|
141
|
+
* with default chain option.
|
|
144
142
|
*/
|
|
145
|
-
getSync
|
|
146
|
-
epoch: Epoch,
|
|
147
|
-
decisionRoot: RootHex,
|
|
148
|
-
buildProps?: T
|
|
149
|
-
): T extends ShufflingBuildProps ? EpochShuffling : EpochShuffling | null {
|
|
143
|
+
getSync(epoch: Epoch, decisionRoot: RootHex): EpochShuffling | null {
|
|
150
144
|
const cacheItem = this.itemsByDecisionRootByEpoch.getOrDefault(epoch).get(decisionRoot);
|
|
151
|
-
if (
|
|
145
|
+
if (cacheItem === undefined) {
|
|
152
146
|
this.metrics?.shufflingCache.miss.inc();
|
|
153
|
-
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (isShufflingCacheItem(cacheItem)) {
|
|
154
151
|
this.metrics?.shufflingCache.hit.inc();
|
|
155
152
|
return cacheItem.shuffling;
|
|
156
|
-
} else if (buildProps) {
|
|
157
|
-
// TODO: (@matthewkeil) This should possible log a warning??
|
|
158
|
-
this.metrics?.shufflingCache.shufflingPromiseNotResolvedAndThrownAway.inc();
|
|
159
|
-
} else {
|
|
160
|
-
this.metrics?.shufflingCache.shufflingPromiseNotResolved.inc();
|
|
161
153
|
}
|
|
162
154
|
|
|
163
|
-
|
|
164
|
-
if (buildProps) {
|
|
165
|
-
const timer = this.metrics?.shufflingCache.shufflingCalculationTime.startTimer({source: "getSync"});
|
|
166
|
-
shuffling = computeEpochShuffling(buildProps.state, buildProps.activeIndices, epoch);
|
|
167
|
-
timer?.();
|
|
168
|
-
this.set(shuffling, decisionRoot);
|
|
169
|
-
}
|
|
170
|
-
return shuffling as T extends ShufflingBuildProps ? EpochShuffling : EpochShuffling | null;
|
|
155
|
+
return null;
|
|
171
156
|
}
|
|
172
157
|
|
|
173
158
|
/**
|
|
174
|
-
*
|
|
159
|
+
* Process a state to extract and cache all shufflings (previous, current, next).
|
|
160
|
+
* Uses the stored decision roots from epochCtx.
|
|
175
161
|
*/
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
162
|
+
processState(state: CachedBeaconStateAllForks): void {
|
|
163
|
+
const {epochCtx} = state;
|
|
164
|
+
|
|
165
|
+
// Cache previous shuffling
|
|
166
|
+
this.set(epochCtx.previousShuffling, epochCtx.previousDecisionRoot);
|
|
167
|
+
|
|
168
|
+
// Cache current shuffling
|
|
169
|
+
this.set(epochCtx.currentShuffling, epochCtx.currentDecisionRoot);
|
|
170
|
+
|
|
171
|
+
// Cache next shuffling
|
|
172
|
+
this.set(epochCtx.nextShuffling, epochCtx.nextDecisionRoot);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
getIndexedAttestation(
|
|
176
|
+
epoch: number,
|
|
177
|
+
decisionRoot: string,
|
|
178
|
+
fork: ForkSeq,
|
|
179
|
+
attestation: Attestation
|
|
180
|
+
): IndexedAttestation {
|
|
181
|
+
const shuffling = this.getShufflingOrThrow(epoch, decisionRoot);
|
|
182
|
+
return getIndexedAttestation(shuffling, fork, attestation);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
getAttestingIndices(epoch: number, decisionRoot: string, fork: ForkSeq, attestation: Attestation): number[] {
|
|
186
|
+
const shuffling = this.getShufflingOrThrow(epoch, decisionRoot);
|
|
187
|
+
return getAttestingIndices(shuffling, fork, attestation);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
getBeaconCommittee(epoch: number, decisionRoot: string, slot: Slot, index: CommitteeIndex): Uint32Array {
|
|
191
|
+
return this.getBeaconCommittees(epoch, decisionRoot, slot, [index])[0];
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
getBeaconCommittees(epoch: number, decisionRoot: string, slot: Slot, indices: CommitteeIndex[]): Uint32Array[] {
|
|
195
|
+
const shuffling = this.getShufflingOrThrow(epoch, decisionRoot);
|
|
196
|
+
return getBeaconCommittees(shuffling, slot, indices);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
private getShufflingOrThrow(epoch: number, decisionRoot: string): EpochShuffling {
|
|
200
|
+
const shuffling = this.getSync(epoch, decisionRoot);
|
|
201
|
+
if (shuffling === null) {
|
|
202
|
+
throw new ShufflingCacheError({
|
|
203
|
+
code: ShufflingCacheErrorCode.NO_SHUFFLING_FOUND,
|
|
204
|
+
epoch,
|
|
205
|
+
decisionRoot,
|
|
192
206
|
});
|
|
207
|
+
}
|
|
208
|
+
return shuffling;
|
|
193
209
|
}
|
|
194
210
|
|
|
195
211
|
/**
|
|
@@ -207,7 +223,8 @@ export class ShufflingCache implements IShufflingCache {
|
|
|
207
223
|
(Date.now() - cacheItem.timeInsertedMs) / 1000
|
|
208
224
|
);
|
|
209
225
|
} else {
|
|
210
|
-
this.metrics?.shufflingCache.
|
|
226
|
+
this.metrics?.shufflingCache.shufflingSetMultipleTimes.inc();
|
|
227
|
+
return;
|
|
211
228
|
}
|
|
212
229
|
}
|
|
213
230
|
// set the shuffling
|
|
@@ -4,7 +4,6 @@ import {RootHex} from "@lodestar/types";
|
|
|
4
4
|
import {toRootHex} from "@lodestar/utils";
|
|
5
5
|
import {Metrics} from "../../metrics/index.js";
|
|
6
6
|
import {LinkedList} from "../../util/array.js";
|
|
7
|
-
import {StateRegenerationOpts} from "../regen/interface.js";
|
|
8
7
|
import {MapTracker} from "./mapMetrics.js";
|
|
9
8
|
import {BlockStateCache} from "./types.js";
|
|
10
9
|
|
|
@@ -86,14 +85,14 @@ export class FIFOBlockStateCache implements BlockStateCache {
|
|
|
86
85
|
}
|
|
87
86
|
|
|
88
87
|
const firstState = firstValue.value;
|
|
89
|
-
//
|
|
90
|
-
return firstState
|
|
88
|
+
// consumers should not mutate the returned state
|
|
89
|
+
return firstState;
|
|
91
90
|
}
|
|
92
91
|
|
|
93
92
|
/**
|
|
94
93
|
* Get a state from this cache given a state root hex.
|
|
95
94
|
*/
|
|
96
|
-
get(rootHex: RootHex
|
|
95
|
+
get(rootHex: RootHex): CachedBeaconStateAllForks | null {
|
|
97
96
|
this.metrics?.lookups.inc();
|
|
98
97
|
const item = this.cache.get(rootHex);
|
|
99
98
|
if (!item) {
|
|
@@ -103,7 +102,7 @@ export class FIFOBlockStateCache implements BlockStateCache {
|
|
|
103
102
|
this.metrics?.hits.inc();
|
|
104
103
|
this.metrics?.stateClonedCount.observe(item.clonedCount);
|
|
105
104
|
|
|
106
|
-
return item
|
|
105
|
+
return item;
|
|
107
106
|
}
|
|
108
107
|
|
|
109
108
|
/**
|
|
@@ -11,7 +11,6 @@ import {Logger, MapDef, fromHex, sleep, toHex, toRootHex} from "@lodestar/utils"
|
|
|
11
11
|
import {Metrics} from "../../metrics/index.js";
|
|
12
12
|
import {AllocSource, BufferPool, BufferWithKey} from "../../util/bufferPool.js";
|
|
13
13
|
import {IClock} from "../../util/clock.js";
|
|
14
|
-
import {StateRegenerationOpts} from "../regen/interface.js";
|
|
15
14
|
import {serializeState} from "../serializeState.js";
|
|
16
15
|
import {CPStateDatastore, DatastoreKey} from "./datastore/index.js";
|
|
17
16
|
import {MapTracker} from "./mapMetrics.js";
|
|
@@ -32,7 +31,7 @@ type PersistentCheckpointStateCacheModules = {
|
|
|
32
31
|
signal?: AbortSignal;
|
|
33
32
|
datastore: CPStateDatastore;
|
|
34
33
|
blockStateCache: BlockStateCache;
|
|
35
|
-
bufferPool?: BufferPool
|
|
34
|
+
bufferPool?: BufferPool;
|
|
36
35
|
};
|
|
37
36
|
|
|
38
37
|
/** checkpoint serialized as a string */
|
|
@@ -120,7 +119,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
120
119
|
private readonly maxEpochsOnDisk: number;
|
|
121
120
|
private readonly datastore: CPStateDatastore;
|
|
122
121
|
private readonly blockStateCache: BlockStateCache;
|
|
123
|
-
private readonly bufferPool?: BufferPool
|
|
122
|
+
private readonly bufferPool?: BufferPool;
|
|
124
123
|
|
|
125
124
|
constructor(
|
|
126
125
|
{
|
|
@@ -204,10 +203,10 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
204
203
|
* - Get block for processing
|
|
205
204
|
* - Regen head state
|
|
206
205
|
*/
|
|
207
|
-
async getOrReload(cp: CheckpointHex
|
|
208
|
-
const stateOrStateBytesData = await this.getStateOrLoadDb(cp
|
|
206
|
+
async getOrReload(cp: CheckpointHex): Promise<CachedBeaconStateAllForks | null> {
|
|
207
|
+
const stateOrStateBytesData = await this.getStateOrLoadDb(cp);
|
|
209
208
|
if (stateOrStateBytesData === null || isCachedBeaconState(stateOrStateBytesData)) {
|
|
210
|
-
return stateOrStateBytesData
|
|
209
|
+
return stateOrStateBytesData ?? null;
|
|
211
210
|
}
|
|
212
211
|
const {persistedKey, stateBytes} = stateOrStateBytesData;
|
|
213
212
|
const logMeta = {persistedKey: toHex(persistedKey)};
|
|
@@ -233,7 +232,8 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
233
232
|
sszTimer?.();
|
|
234
233
|
const timer = this.metrics?.cpStateCache.stateReloadDuration.startTimer();
|
|
235
234
|
const newCachedState = loadCachedBeaconState(seedState, stateBytes, {}, validatorsBytes);
|
|
236
|
-
|
|
235
|
+
// hashTreeRoot() calls the commit() inside
|
|
236
|
+
// there is no modification inside the state, it's just that we want to compute and cache all roots
|
|
237
237
|
const stateRoot = toRootHex(newCachedState.hashTreeRoot());
|
|
238
238
|
timer?.();
|
|
239
239
|
|
|
@@ -252,7 +252,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
252
252
|
this.cache.set(cpKey, {type: CacheItemType.inMemory, state: newCachedState, persistedKey});
|
|
253
253
|
this.epochIndex.getOrDefault(cp.epoch).add(cp.rootHex);
|
|
254
254
|
// don't prune from memory here, call it at the last 1/3 of slot 0 of an epoch
|
|
255
|
-
return newCachedState
|
|
255
|
+
return newCachedState;
|
|
256
256
|
} catch (e) {
|
|
257
257
|
this.logger.debug("Reload: error loading cached state", logMeta, e as Error);
|
|
258
258
|
return null;
|
|
@@ -263,8 +263,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
263
263
|
* Return either state or state bytes loaded from db.
|
|
264
264
|
*/
|
|
265
265
|
async getStateOrBytes(cp: CheckpointHex): Promise<CachedBeaconStateAllForks | Uint8Array | null> {
|
|
266
|
-
|
|
267
|
-
const stateOrLoadedState = await this.getStateOrLoadDb(cp, {dontTransferCache: true});
|
|
266
|
+
const stateOrLoadedState = await this.getStateOrLoadDb(cp);
|
|
268
267
|
if (stateOrLoadedState === null || isCachedBeaconState(stateOrLoadedState)) {
|
|
269
268
|
return stateOrLoadedState;
|
|
270
269
|
}
|
|
@@ -274,12 +273,9 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
274
273
|
/**
|
|
275
274
|
* Return either state or state bytes with persisted key loaded from db.
|
|
276
275
|
*/
|
|
277
|
-
async getStateOrLoadDb(
|
|
278
|
-
cp: CheckpointHex,
|
|
279
|
-
opts?: StateRegenerationOpts
|
|
280
|
-
): Promise<CachedBeaconStateAllForks | LoadedStateBytesData | null> {
|
|
276
|
+
async getStateOrLoadDb(cp: CheckpointHex): Promise<CachedBeaconStateAllForks | LoadedStateBytesData | null> {
|
|
281
277
|
const cpKey = toCacheKey(cp);
|
|
282
|
-
const inMemoryState = this.get(cpKey
|
|
278
|
+
const inMemoryState = this.get(cpKey);
|
|
283
279
|
if (inMemoryState) {
|
|
284
280
|
return inMemoryState;
|
|
285
281
|
}
|
|
@@ -308,7 +304,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
308
304
|
/**
|
|
309
305
|
* Similar to get() api without reloading from disk
|
|
310
306
|
*/
|
|
311
|
-
get(cpOrKey: CheckpointHex | string
|
|
307
|
+
get(cpOrKey: CheckpointHex | string): CachedBeaconStateAllForks | null {
|
|
312
308
|
this.metrics?.cpStateCache.lookups.inc();
|
|
313
309
|
const cpKey = typeof cpOrKey === "string" ? cpOrKey : toCacheKey(cpOrKey);
|
|
314
310
|
const cacheItem = this.cache.get(cpKey);
|
|
@@ -326,7 +322,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
326
322
|
if (isInMemoryCacheItem(cacheItem)) {
|
|
327
323
|
const {state} = cacheItem;
|
|
328
324
|
this.metrics?.cpStateCache.stateClonedCount.observe(state.clonedCount);
|
|
329
|
-
return state
|
|
325
|
+
return state;
|
|
330
326
|
}
|
|
331
327
|
|
|
332
328
|
return null;
|
|
@@ -360,14 +356,14 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
360
356
|
/**
|
|
361
357
|
* Searches in-memory state for the latest cached state with a `root` without reload, starting with `epoch` and descending
|
|
362
358
|
*/
|
|
363
|
-
getLatest(rootHex: RootHex, maxEpoch: Epoch
|
|
359
|
+
getLatest(rootHex: RootHex, maxEpoch: Epoch): CachedBeaconStateAllForks | null {
|
|
364
360
|
// sort epochs in descending order, only consider epochs lte `epoch`
|
|
365
361
|
const epochs = Array.from(this.epochIndex.keys())
|
|
366
362
|
.sort((a, b) => b - a)
|
|
367
363
|
.filter((e) => e <= maxEpoch);
|
|
368
364
|
for (const epoch of epochs) {
|
|
369
365
|
if (this.epochIndex.get(epoch)?.has(rootHex)) {
|
|
370
|
-
const inMemoryClonedState = this.get({rootHex, epoch}
|
|
366
|
+
const inMemoryClonedState = this.get({rootHex, epoch});
|
|
371
367
|
if (inMemoryClonedState) {
|
|
372
368
|
return inMemoryClonedState;
|
|
373
369
|
}
|
|
@@ -383,11 +379,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
383
379
|
* - Get block for processing
|
|
384
380
|
* - Regen head state
|
|
385
381
|
*/
|
|
386
|
-
async getOrReloadLatest(
|
|
387
|
-
rootHex: RootHex,
|
|
388
|
-
maxEpoch: Epoch,
|
|
389
|
-
opts?: StateRegenerationOpts
|
|
390
|
-
): Promise<CachedBeaconStateAllForks | null> {
|
|
382
|
+
async getOrReloadLatest(rootHex: RootHex, maxEpoch: Epoch): Promise<CachedBeaconStateAllForks | null> {
|
|
391
383
|
// sort epochs in descending order, only consider epochs lte `epoch`
|
|
392
384
|
const epochs = Array.from(this.epochIndex.keys())
|
|
393
385
|
.sort((a, b) => b - a)
|
|
@@ -395,9 +387,9 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
395
387
|
for (const epoch of epochs) {
|
|
396
388
|
if (this.epochIndex.get(epoch)?.has(rootHex)) {
|
|
397
389
|
try {
|
|
398
|
-
const
|
|
399
|
-
if (
|
|
400
|
-
return
|
|
390
|
+
const state = await this.getOrReload({rootHex, epoch});
|
|
391
|
+
if (state) {
|
|
392
|
+
return state;
|
|
401
393
|
}
|
|
402
394
|
} catch (e) {
|
|
403
395
|
this.logger.debug("Error get or reload state", {epoch, rootHex}, e as Error);
|
|
@@ -859,6 +851,10 @@ export function toCheckpointHex(checkpoint: phase0.Checkpoint): CheckpointHex {
|
|
|
859
851
|
};
|
|
860
852
|
}
|
|
861
853
|
|
|
854
|
+
export function toCheckpointKey(cp: CheckpointHex): string {
|
|
855
|
+
return `${cp.rootHex}:${cp.epoch}`;
|
|
856
|
+
}
|
|
857
|
+
|
|
862
858
|
function toCacheKey(cp: CheckpointHex | phase0.Checkpoint): CacheKey {
|
|
863
859
|
if (isCheckpointHex(cp)) {
|
|
864
860
|
return `${cp.rootHex}_${cp.epoch}`;
|