@lodestar/beacon-node 1.39.1 → 1.40.0-dev.1020f27ca9
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 +15 -25
- 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 +16 -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/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 +5 -3
- 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 +2 -0
- package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
- package/lib/chain/blocks/blockInput/blockInput.js +6 -0
- 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 +14 -9
- 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 +1 -0
- 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 +20 -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 +24 -6
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +201 -25
- 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 +5 -3
- 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/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/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 +4 -13
- 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 +5 -9
- 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.js +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/blockStateCacheImpl.d.ts +1 -2
- package/lib/chain/stateCache/blockStateCacheImpl.d.ts.map +1 -1
- package/lib/chain/stateCache/blockStateCacheImpl.js +2 -2
- package/lib/chain/stateCache/blockStateCacheImpl.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/inMemoryCheckpointsCache.d.ts +4 -5
- package/lib/chain/stateCache/inMemoryCheckpointsCache.d.ts.map +1 -1
- package/lib/chain/stateCache/inMemoryCheckpointsCache.js +9 -10
- package/lib/chain/stateCache/inMemoryCheckpointsCache.js.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +5 -6
- package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.js +17 -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 +3 -3
- 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 +7 -4
- 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 +3 -3
- 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/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/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +34 -3
- 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.js +2 -2
- 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/util/sszBytes.js +1 -1
- package/lib/util/sszBytes.js.map +1 -1
- package/package.json +15 -15
- package/src/api/impl/beacon/blocks/index.ts +17 -25
- 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 +19 -4
- package/src/api/impl/proof/index.ts +1 -2
- package/src/api/impl/validator/index.ts +13 -14
- package/src/chain/ColumnReconstructionTracker.ts +8 -4
- package/src/chain/archiveStore/historicalState/getHistoricalState.ts +5 -3
- package/src/chain/archiveStore/utils/archiveBlocks.ts +25 -14
- package/src/chain/blocks/blockInput/blockInput.ts +8 -0
- package/src/chain/blocks/importBlock.ts +15 -9
- 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 +1 -0
- package/src/chain/blocks/writeBlockInputToDb.ts +24 -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 +230 -36
- 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 +5 -3
- package/src/chain/interface.ts +34 -3
- 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/prepareNextSlot.ts +8 -12
- package/src/chain/produceBlock/produceBlockBody.ts +13 -6
- package/src/chain/regen/interface.ts +3 -17
- package/src/chain/regen/queued.ts +17 -56
- 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 +1 -1
- package/src/chain/shufflingCache.ts +67 -50
- package/src/chain/stateCache/blockStateCacheImpl.ts +2 -3
- package/src/chain/stateCache/fifoBlockStateCache.ts +4 -5
- package/src/chain/stateCache/inMemoryCheckpointsCache.ts +9 -15
- package/src/chain/stateCache/persistentCheckpointsCache.ts +17 -25
- 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 +2 -7
- package/src/chain/validation/block.ts +8 -4
- package/src/chain/validation/blsToExecutionChange.ts +9 -7
- package/src/chain/validation/dataColumnSidecar.ts +2 -7
- 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/gossip/interface.ts +17 -0
- package/src/network/gossip/scoringParameters.ts +44 -2
- package/src/network/gossip/topic.ts +21 -0
- package/src/network/processor/gossipHandlers.ts +48 -3
- 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 +2 -2
- 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/util/sszBytes.ts +1 -1
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
|
+
}
|
|
@@ -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
|
|
@@ -3,7 +3,6 @@ import {CachedBeaconStateAllForks} from "@lodestar/state-transition";
|
|
|
3
3
|
import {Epoch, RootHex} from "@lodestar/types";
|
|
4
4
|
import {toRootHex} from "@lodestar/utils";
|
|
5
5
|
import {Metrics} from "../../metrics/index.js";
|
|
6
|
-
import {StateRegenerationOpts} from "../regen/interface.js";
|
|
7
6
|
import {MapTracker} from "./mapMetrics.js";
|
|
8
7
|
import {BlockStateCache} from "./types.js";
|
|
9
8
|
|
|
@@ -39,7 +38,7 @@ export class BlockStateCacheImpl implements BlockStateCache {
|
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
|
|
42
|
-
get(rootHex: RootHex
|
|
41
|
+
get(rootHex: RootHex): CachedBeaconStateAllForks | null {
|
|
43
42
|
this.metrics?.lookups.inc();
|
|
44
43
|
const item = this.head?.stateRoot === rootHex ? this.head.state : this.cache.get(rootHex);
|
|
45
44
|
if (!item) {
|
|
@@ -49,7 +48,7 @@ export class BlockStateCacheImpl implements BlockStateCache {
|
|
|
49
48
|
this.metrics?.hits.inc();
|
|
50
49
|
this.metrics?.stateClonedCount.observe(item.clonedCount);
|
|
51
50
|
|
|
52
|
-
return item
|
|
51
|
+
return item;
|
|
53
52
|
}
|
|
54
53
|
|
|
55
54
|
add(item: CachedBeaconStateAllForks): void {
|
|
@@ -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
|
/**
|
|
@@ -3,7 +3,6 @@ import {CachedBeaconStateAllForks} from "@lodestar/state-transition";
|
|
|
3
3
|
import {Epoch, RootHex, phase0} from "@lodestar/types";
|
|
4
4
|
import {MapDef, toRootHex} from "@lodestar/utils";
|
|
5
5
|
import {Metrics} from "../../metrics/index.js";
|
|
6
|
-
import {StateRegenerationOpts} from "../regen/interface.js";
|
|
7
6
|
import {MapTracker} from "./mapMetrics.js";
|
|
8
7
|
import {CacheItemType, CheckpointStateCache} from "./types.js";
|
|
9
8
|
|
|
@@ -42,21 +41,16 @@ export class InMemoryCheckpointStateCache implements CheckpointStateCache {
|
|
|
42
41
|
this.maxEpochs = maxEpochs;
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
async getOrReload(cp: CheckpointHex
|
|
46
|
-
return this.get(cp
|
|
44
|
+
async getOrReload(cp: CheckpointHex): Promise<CachedBeaconStateAllForks | null> {
|
|
45
|
+
return this.get(cp);
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
async getStateOrBytes(cp: CheckpointHex): Promise<Uint8Array | CachedBeaconStateAllForks | null> {
|
|
50
|
-
|
|
51
|
-
return this.get(cp, {dontTransferCache: true});
|
|
49
|
+
return this.get(cp);
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
async getOrReloadLatest(
|
|
55
|
-
rootHex
|
|
56
|
-
maxEpoch: number,
|
|
57
|
-
opts?: StateRegenerationOpts
|
|
58
|
-
): Promise<CachedBeaconStateAllForks | null> {
|
|
59
|
-
return this.getLatest(rootHex, maxEpoch, opts);
|
|
52
|
+
async getOrReloadLatest(rootHex: string, maxEpoch: number): Promise<CachedBeaconStateAllForks | null> {
|
|
53
|
+
return this.getLatest(rootHex, maxEpoch);
|
|
60
54
|
}
|
|
61
55
|
|
|
62
56
|
async processState(): Promise<number> {
|
|
@@ -64,7 +58,7 @@ export class InMemoryCheckpointStateCache implements CheckpointStateCache {
|
|
|
64
58
|
return 0;
|
|
65
59
|
}
|
|
66
60
|
|
|
67
|
-
get(cp: CheckpointHex
|
|
61
|
+
get(cp: CheckpointHex): CachedBeaconStateAllForks | null {
|
|
68
62
|
this.metrics?.lookups.inc();
|
|
69
63
|
const cpKey = toCheckpointKey(cp);
|
|
70
64
|
const item = this.cache.get(cpKey);
|
|
@@ -81,7 +75,7 @@ export class InMemoryCheckpointStateCache implements CheckpointStateCache {
|
|
|
81
75
|
|
|
82
76
|
this.metrics?.stateClonedCount.observe(item.clonedCount);
|
|
83
77
|
|
|
84
|
-
return item
|
|
78
|
+
return item;
|
|
85
79
|
}
|
|
86
80
|
|
|
87
81
|
add(cp: phase0.Checkpoint, item: CachedBeaconStateAllForks): void {
|
|
@@ -98,14 +92,14 @@ export class InMemoryCheckpointStateCache implements CheckpointStateCache {
|
|
|
98
92
|
/**
|
|
99
93
|
* Searches for the latest cached state with a `root`, starting with `epoch` and descending
|
|
100
94
|
*/
|
|
101
|
-
getLatest(rootHex: RootHex, maxEpoch: Epoch
|
|
95
|
+
getLatest(rootHex: RootHex, maxEpoch: Epoch): CachedBeaconStateAllForks | null {
|
|
102
96
|
// sort epochs in descending order, only consider epochs lte `epoch`
|
|
103
97
|
const epochs = Array.from(this.epochIndex.keys())
|
|
104
98
|
.sort((a, b) => b - a)
|
|
105
99
|
.filter((e) => e <= maxEpoch);
|
|
106
100
|
for (const epoch of epochs) {
|
|
107
101
|
if (this.epochIndex.get(epoch)?.has(rootHex)) {
|
|
108
|
-
return this.get({rootHex, epoch}
|
|
102
|
+
return this.get({rootHex, epoch});
|
|
109
103
|
}
|
|
110
104
|
}
|
|
111
105
|
return null;
|