@lodestar/beacon-node 1.39.0-dev.3bf4734ba9 → 1.39.0-dev.4263377242
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/README.md +1 -1
- package/lib/api/impl/beacon/blocks/utils.js +1 -1
- package/lib/api/impl/beacon/blocks/utils.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/lodestar/index.js +1 -1
- 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 +1 -3
- package/lib/api/impl/validator/index.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/blocks/importBlock.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.js +12 -3
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlock.js +9 -2
- package/lib/chain/blocks/verifyBlock.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +4 -2
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksSignatures.d.ts +2 -1
- package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksSignatures.js +3 -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/chain.d.ts +11 -14
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +36 -50
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/forkChoice/index.d.ts.map +1 -1
- package/lib/chain/forkChoice/index.js +3 -3
- package/lib/chain/forkChoice/index.js.map +1 -1
- package/lib/chain/initState.d.ts +2 -15
- package/lib/chain/initState.d.ts.map +1 -1
- package/lib/chain/initState.js +6 -65
- package/lib/chain/initState.js.map +1 -1
- package/lib/chain/interface.d.ts +6 -11
- 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 +8 -12
- package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
- package/lib/chain/opPools/aggregatedAttestationPool.js +13 -142
- package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
- package/lib/chain/opPools/opPool.d.ts +3 -0
- package/lib/chain/opPools/opPool.d.ts.map +1 -1
- package/lib/chain/opPools/opPool.js +14 -16
- package/lib/chain/opPools/opPool.js.map +1 -1
- package/lib/chain/prepareNextSlot.d.ts +0 -4
- package/lib/chain/prepareNextSlot.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +5 -28
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +0 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +10 -13
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/regen/interface.d.ts +1 -5
- package/lib/chain/regen/interface.d.ts.map +1 -1
- package/lib/chain/regen/queued.d.ts +4 -7
- package/lib/chain/regen/queued.d.ts.map +1 -1
- package/lib/chain/regen/queued.js +15 -25
- package/lib/chain/regen/queued.js.map +1 -1
- package/lib/chain/regen/regen.d.ts +1 -1
- package/lib/chain/regen/regen.d.ts.map +1 -1
- package/lib/chain/regen/regen.js +13 -17
- package/lib/chain/regen/regen.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/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 +9 -7
- package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.js +21 -19
- 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 +9 -0
- package/lib/chain/validation/aggregateAndProof.js.map +1 -1
- package/lib/chain/validation/attestation.d.ts.map +1 -1
- package/lib/chain/validation/attestation.js +2 -2
- 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 +2 -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 +5 -3
- 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 +10 -3
- 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 +2 -3
- package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
- package/lib/chain/validation/proposerSlashing.js +3 -2
- package/lib/chain/validation/proposerSlashing.js.map +1 -1
- package/lib/chain/validation/signatureSets/aggregateAndProof.js +1 -1
- package/lib/chain/validation/signatureSets/aggregateAndProof.js.map +1 -1
- package/lib/chain/validation/signatureSets/contributionAndProof.d.ts +2 -1
- package/lib/chain/validation/signatureSets/contributionAndProof.d.ts.map +1 -1
- package/lib/chain/validation/signatureSets/contributionAndProof.js +2 -2
- package/lib/chain/validation/signatureSets/contributionAndProof.js.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommittee.d.ts +2 -1
- package/lib/chain/validation/signatureSets/syncCommittee.d.ts.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommittee.js +2 -2
- package/lib/chain/validation/signatureSets/syncCommittee.js.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts +2 -1
- 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 -1
- package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js +1 -2
- 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 -3
- 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/db/beacon.d.ts +3 -7
- package/lib/db/beacon.d.ts.map +1 -1
- package/lib/db/beacon.js +33 -12
- package/lib/db/beacon.js.map +1 -1
- package/lib/db/buckets.d.ts +12 -6
- package/lib/db/buckets.d.ts.map +1 -1
- package/lib/db/buckets.js +6 -1
- package/lib/db/buckets.js.map +1 -1
- package/lib/db/interface.d.ts +2 -7
- package/lib/db/interface.d.ts.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 -15
- package/lib/db/repositories/checkpointState.js.map +1 -1
- package/lib/db/repositories/index.d.ts +0 -3
- package/lib/db/repositories/index.d.ts.map +1 -1
- package/lib/db/repositories/index.js +0 -3
- package/lib/db/repositories/index.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/http.d.ts +1 -1
- package/lib/execution/engine/http.d.ts.map +1 -1
- package/lib/execution/engine/http.js +2 -3
- package/lib/execution/engine/http.js.map +1 -1
- package/lib/execution/engine/index.d.ts.map +1 -1
- package/lib/execution/engine/index.js +1 -1
- package/lib/execution/engine/index.js.map +1 -1
- package/lib/execution/engine/interface.d.ts +1 -1
- package/lib/execution/engine/interface.d.ts.map +1 -1
- package/lib/execution/engine/interface.js.map +1 -1
- package/lib/{eth1/provider → execution/engine}/jsonRpcHttpClient.d.ts +1 -1
- package/lib/execution/engine/jsonRpcHttpClient.d.ts.map +1 -0
- package/lib/execution/engine/jsonRpcHttpClient.js.map +1 -0
- package/lib/execution/engine/jwt.d.ts.map +1 -0
- package/lib/execution/engine/jwt.js.map +1 -0
- 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 +35 -8
- package/lib/execution/engine/mock.js.map +1 -1
- package/lib/execution/engine/payloadIdCache.d.ts +1 -1
- package/lib/execution/engine/payloadIdCache.d.ts.map +1 -1
- package/lib/execution/engine/types.d.ts +1 -1
- package/lib/execution/engine/types.d.ts.map +1 -1
- package/lib/execution/engine/types.js +1 -1
- package/lib/execution/engine/types.js.map +1 -1
- package/lib/execution/engine/utils.d.ts +64 -2
- package/lib/execution/engine/utils.d.ts.map +1 -1
- package/lib/execution/engine/utils.js +91 -2
- package/lib/execution/engine/utils.js.map +1 -1
- package/lib/index.d.ts +1 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -2
- package/lib/index.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +1 -41
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +3 -107
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/core/events.d.ts +1 -1
- package/lib/network/core/events.d.ts.map +1 -1
- package/lib/network/core/events.js +1 -1
- package/lib/network/core/events.js.map +1 -1
- package/lib/network/events.d.ts +6 -1
- package/lib/network/events.d.ts.map +1 -1
- package/lib/network/events.js +7 -1
- package/lib/network/events.js.map +1 -1
- package/lib/network/peers/discover.d.ts.map +1 -1
- package/lib/network/peers/discover.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 +6 -3
- package/lib/node/nodejs.d.ts.map +1 -1
- package/lib/node/nodejs.js +30 -12
- package/lib/node/nodejs.js.map +1 -1
- package/lib/node/notifier.d.ts.map +1 -1
- package/lib/node/notifier.js +9 -6
- package/lib/node/notifier.js.map +1 -1
- package/lib/node/options.d.ts +0 -2
- package/lib/node/options.d.ts.map +1 -1
- package/lib/node/options.js +0 -2
- package/lib/node/options.js.map +1 -1
- package/lib/node/utils/interop/deposits.d.ts +2 -1
- package/lib/node/utils/interop/deposits.d.ts.map +1 -1
- package/lib/node/utils/interop/deposits.js.map +1 -1
- package/lib/node/utils/interop/state.d.ts +1 -1
- package/lib/node/utils/interop/state.d.ts.map +1 -1
- package/lib/node/utils/state.d.ts +1 -7
- package/lib/node/utils/state.d.ts.map +1 -1
- package/lib/node/utils/state.js +1 -14
- package/lib/node/utils/state.js.map +1 -1
- package/lib/sync/backfill/backfill.d.ts.map +1 -1
- package/lib/sync/backfill/backfill.js +2 -4
- package/lib/sync/backfill/backfill.js.map +1 -1
- package/lib/sync/backfill/verify.d.ts +2 -2
- package/lib/sync/backfill/verify.d.ts.map +1 -1
- package/lib/sync/backfill/verify.js +3 -3
- package/lib/sync/backfill/verify.js.map +1 -1
- package/lib/util/sszBytes.js +1 -1
- package/lib/util/sszBytes.js.map +1 -1
- package/lib/util/workerEvents.d.ts +1 -6
- package/lib/util/workerEvents.d.ts.map +1 -1
- package/lib/util/workerEvents.js +8 -8
- package/lib/util/workerEvents.js.map +1 -1
- package/package.json +28 -26
- package/src/api/impl/beacon/blocks/utils.ts +1 -1
- package/src/api/impl/beacon/state/utils.ts +2 -22
- package/src/api/impl/lodestar/index.ts +1 -1
- package/src/api/impl/proof/index.ts +1 -2
- package/src/api/impl/validator/index.ts +1 -3
- package/src/chain/archiveStore/historicalState/getHistoricalState.ts +5 -3
- package/src/chain/blocks/importBlock.ts +13 -3
- package/src/chain/blocks/verifyBlock.ts +10 -3
- package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +9 -2
- package/src/chain/blocks/verifyBlocksSignatures.ts +13 -3
- package/src/chain/blocks/verifyBlocksStateTransitionOnly.ts +1 -0
- package/src/chain/chain.ts +50 -62
- package/src/chain/forkChoice/index.ts +3 -2
- package/src/chain/initState.ts +6 -100
- package/src/chain/interface.ts +6 -10
- package/src/chain/lightClient/proofs.ts +0 -2
- package/src/chain/opPools/aggregatedAttestationPool.ts +23 -195
- package/src/chain/opPools/opPool.ts +13 -15
- package/src/chain/prepareNextSlot.ts +3 -34
- package/src/chain/produceBlock/produceBlockBody.ts +15 -14
- package/src/chain/regen/interface.ts +1 -5
- package/src/chain/regen/queued.ts +15 -34
- package/src/chain/regen/regen.ts +12 -18
- 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 +32 -27
- package/src/chain/stateCache/types.ts +5 -10
- package/src/chain/validation/aggregateAndProof.ts +12 -0
- package/src/chain/validation/attestation.ts +3 -3
- package/src/chain/validation/attesterSlashing.ts +14 -2
- package/src/chain/validation/blobSidecar.ts +3 -3
- package/src/chain/validation/block.ts +6 -2
- package/src/chain/validation/blsToExecutionChange.ts +10 -8
- package/src/chain/validation/dataColumnSidecar.ts +3 -3
- package/src/chain/validation/proposerSlashing.ts +8 -2
- package/src/chain/validation/signatureSets/aggregateAndProof.ts +1 -1
- package/src/chain/validation/signatureSets/contributionAndProof.ts +3 -1
- package/src/chain/validation/signatureSets/syncCommittee.ts +3 -1
- package/src/chain/validation/signatureSets/syncCommitteeContribution.ts +3 -1
- package/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts +2 -1
- package/src/chain/validation/syncCommittee.ts +1 -1
- package/src/chain/validation/syncCommitteeContributionAndProof.ts +8 -3
- package/src/chain/validation/voluntaryExit.ts +1 -1
- package/src/db/beacon.ts +38 -16
- package/src/db/buckets.ts +12 -7
- package/src/db/interface.ts +2 -13
- package/src/db/repositories/checkpointState.ts +3 -19
- package/src/db/repositories/index.ts +0 -3
- package/src/db/repositories/stateArchive.ts +13 -27
- package/src/execution/engine/http.ts +8 -9
- package/src/execution/engine/index.ts +1 -1
- package/src/execution/engine/interface.ts +1 -1
- package/src/{eth1/provider → execution/engine}/jsonRpcHttpClient.ts +1 -1
- package/src/execution/engine/mock.ts +41 -15
- package/src/execution/engine/payloadIdCache.ts +1 -1
- package/src/execution/engine/types.ts +9 -9
- package/src/execution/engine/utils.ts +111 -5
- package/src/index.ts +1 -2
- package/src/metrics/metrics/lodestar.ts +3 -109
- package/src/network/core/events.ts +1 -1
- package/src/network/events.ts +7 -1
- package/src/network/peers/discover.ts +3 -3
- package/src/network/reqresp/utils/dataColumnResponseValidation.ts +1 -1
- package/src/node/nodejs.ts +37 -13
- package/src/node/notifier.ts +13 -7
- package/src/node/options.ts +0 -3
- package/src/node/utils/interop/deposits.ts +3 -1
- package/src/node/utils/interop/state.ts +1 -1
- package/src/node/utils/state.ts +3 -18
- package/src/sync/backfill/backfill.ts +2 -9
- package/src/sync/backfill/verify.ts +3 -8
- package/src/util/sszBytes.ts +1 -1
- package/src/util/workerEvents.ts +9 -8
- package/lib/chain/genesis/genesis.d.ts +0 -51
- package/lib/chain/genesis/genesis.d.ts.map +0 -1
- package/lib/chain/genesis/genesis.js +0 -123
- package/lib/chain/genesis/genesis.js.map +0 -1
- package/lib/chain/genesis/interface.d.ts +0 -13
- package/lib/chain/genesis/interface.d.ts.map +0 -1
- package/lib/chain/genesis/interface.js +0 -2
- package/lib/chain/genesis/interface.js.map +0 -1
- package/lib/chain/rewards/attestationsRewards.d.ts +0 -7
- package/lib/chain/rewards/attestationsRewards.d.ts.map +0 -1
- package/lib/chain/rewards/attestationsRewards.js +0 -112
- package/lib/chain/rewards/attestationsRewards.js.map +0 -1
- package/lib/chain/rewards/blockRewards.d.ts +0 -14
- package/lib/chain/rewards/blockRewards.d.ts.map +0 -1
- package/lib/chain/rewards/blockRewards.js +0 -94
- package/lib/chain/rewards/blockRewards.js.map +0 -1
- package/lib/chain/rewards/syncCommitteeRewards.d.ts +0 -6
- package/lib/chain/rewards/syncCommitteeRewards.d.ts.map +0 -1
- package/lib/chain/rewards/syncCommitteeRewards.js +0 -36
- package/lib/chain/rewards/syncCommitteeRewards.js.map +0 -1
- package/lib/db/repositories/depositDataRoot.d.ts +0 -22
- package/lib/db/repositories/depositDataRoot.d.ts.map +0 -1
- package/lib/db/repositories/depositDataRoot.js +0 -62
- package/lib/db/repositories/depositDataRoot.js.map +0 -1
- package/lib/db/repositories/depositEvent.d.ts +0 -13
- package/lib/db/repositories/depositEvent.d.ts.map +0 -1
- package/lib/db/repositories/depositEvent.js +0 -27
- package/lib/db/repositories/depositEvent.js.map +0 -1
- package/lib/db/repositories/eth1Data.d.ts +0 -13
- package/lib/db/repositories/eth1Data.d.ts.map +0 -1
- package/lib/db/repositories/eth1Data.js +0 -26
- package/lib/db/repositories/eth1Data.js.map +0 -1
- package/lib/db/single/index.d.ts +0 -3
- package/lib/db/single/index.d.ts.map +0 -1
- package/lib/db/single/index.js +0 -3
- package/lib/db/single/index.js.map +0 -1
- package/lib/db/single/preGenesisState.d.ts +0 -16
- package/lib/db/single/preGenesisState.d.ts.map +0 -1
- package/lib/db/single/preGenesisState.js +0 -29
- package/lib/db/single/preGenesisState.js.map +0 -1
- package/lib/db/single/preGenesisStateLastProcessedBlock.d.ts +0 -14
- package/lib/db/single/preGenesisStateLastProcessedBlock.d.ts.map +0 -1
- package/lib/db/single/preGenesisStateLastProcessedBlock.js +0 -27
- package/lib/db/single/preGenesisStateLastProcessedBlock.js.map +0 -1
- package/lib/eth1/errors.d.ts +0 -66
- package/lib/eth1/errors.d.ts.map +0 -1
- package/lib/eth1/errors.js +0 -27
- package/lib/eth1/errors.js.map +0 -1
- package/lib/eth1/eth1DataCache.d.ts +0 -19
- package/lib/eth1/eth1DataCache.d.ts.map +0 -1
- package/lib/eth1/eth1DataCache.js +0 -19
- package/lib/eth1/eth1DataCache.js.map +0 -1
- package/lib/eth1/eth1DepositDataTracker.d.ts +0 -80
- package/lib/eth1/eth1DepositDataTracker.d.ts.map +0 -1
- package/lib/eth1/eth1DepositDataTracker.js +0 -317
- package/lib/eth1/eth1DepositDataTracker.js.map +0 -1
- package/lib/eth1/eth1DepositsCache.d.ts +0 -42
- package/lib/eth1/eth1DepositsCache.d.ts.map +0 -1
- package/lib/eth1/eth1DepositsCache.js +0 -119
- package/lib/eth1/eth1DepositsCache.js.map +0 -1
- package/lib/eth1/index.d.ts +0 -31
- package/lib/eth1/index.d.ts.map +0 -1
- package/lib/eth1/index.js +0 -71
- package/lib/eth1/index.js.map +0 -1
- package/lib/eth1/interface.d.ts +0 -74
- package/lib/eth1/interface.d.ts.map +0 -1
- package/lib/eth1/interface.js +0 -8
- package/lib/eth1/interface.js.map +0 -1
- package/lib/eth1/options.d.ts +0 -22
- package/lib/eth1/options.d.ts.map +0 -1
- package/lib/eth1/options.js +0 -8
- package/lib/eth1/options.js.map +0 -1
- package/lib/eth1/provider/eth1Provider.d.ts +0 -39
- package/lib/eth1/provider/eth1Provider.d.ts.map +0 -1
- package/lib/eth1/provider/eth1Provider.js +0 -147
- package/lib/eth1/provider/eth1Provider.js.map +0 -1
- package/lib/eth1/provider/jsonRpcHttpClient.d.ts.map +0 -1
- package/lib/eth1/provider/jsonRpcHttpClient.js.map +0 -1
- package/lib/eth1/provider/jwt.d.ts.map +0 -1
- package/lib/eth1/provider/jwt.js.map +0 -1
- package/lib/eth1/provider/utils.d.ts +0 -65
- package/lib/eth1/provider/utils.d.ts.map +0 -1
- package/lib/eth1/provider/utils.js +0 -120
- package/lib/eth1/provider/utils.js.map +0 -1
- package/lib/eth1/stream.d.ts +0 -15
- package/lib/eth1/stream.d.ts.map +0 -1
- package/lib/eth1/stream.js +0 -54
- package/lib/eth1/stream.js.map +0 -1
- package/lib/eth1/utils/depositContract.d.ts +0 -14
- package/lib/eth1/utils/depositContract.d.ts.map +0 -1
- package/lib/eth1/utils/depositContract.js +0 -33
- package/lib/eth1/utils/depositContract.js.map +0 -1
- package/lib/eth1/utils/deposits.d.ts +0 -8
- package/lib/eth1/utils/deposits.d.ts.map +0 -1
- package/lib/eth1/utils/deposits.js +0 -47
- package/lib/eth1/utils/deposits.js.map +0 -1
- package/lib/eth1/utils/eth1Data.d.ts +0 -22
- package/lib/eth1/utils/eth1Data.d.ts.map +0 -1
- package/lib/eth1/utils/eth1Data.js +0 -77
- package/lib/eth1/utils/eth1Data.js.map +0 -1
- package/lib/eth1/utils/eth1DepositEvent.d.ts +0 -7
- package/lib/eth1/utils/eth1DepositEvent.d.ts.map +0 -1
- package/lib/eth1/utils/eth1DepositEvent.js +0 -13
- package/lib/eth1/utils/eth1DepositEvent.js.map +0 -1
- package/lib/eth1/utils/eth1Vote.d.ts +0 -17
- package/lib/eth1/utils/eth1Vote.d.ts.map +0 -1
- package/lib/eth1/utils/eth1Vote.js +0 -111
- package/lib/eth1/utils/eth1Vote.js.map +0 -1
- package/lib/eth1/utils/groupDepositEventsByBlock.d.ts +0 -9
- package/lib/eth1/utils/groupDepositEventsByBlock.d.ts.map +0 -1
- package/lib/eth1/utils/groupDepositEventsByBlock.js +0 -17
- package/lib/eth1/utils/groupDepositEventsByBlock.js.map +0 -1
- package/lib/eth1/utils/optimizeNextBlockDiffForGenesis.d.ts +0 -10
- package/lib/eth1/utils/optimizeNextBlockDiffForGenesis.d.ts.map +0 -1
- package/lib/eth1/utils/optimizeNextBlockDiffForGenesis.js +0 -14
- package/lib/eth1/utils/optimizeNextBlockDiffForGenesis.js.map +0 -1
- package/src/chain/genesis/genesis.ts +0 -190
- package/src/chain/genesis/interface.ts +0 -14
- package/src/chain/rewards/attestationsRewards.ts +0 -197
- package/src/chain/rewards/blockRewards.ts +0 -150
- package/src/chain/rewards/syncCommitteeRewards.ts +0 -58
- package/src/db/repositories/depositDataRoot.ts +0 -80
- package/src/db/repositories/depositEvent.ts +0 -32
- package/src/db/repositories/eth1Data.ts +0 -33
- package/src/db/single/index.ts +0 -2
- package/src/db/single/preGenesisState.ts +0 -37
- package/src/db/single/preGenesisStateLastProcessedBlock.ts +0 -34
- package/src/eth1/errors.ts +0 -40
- package/src/eth1/eth1DataCache.ts +0 -26
- package/src/eth1/eth1DepositDataTracker.ts +0 -410
- package/src/eth1/eth1DepositsCache.ts +0 -141
- package/src/eth1/index.ts +0 -94
- package/src/eth1/interface.ts +0 -87
- package/src/eth1/options.ts +0 -28
- package/src/eth1/provider/eth1Provider.ts +0 -229
- package/src/eth1/provider/utils.ts +0 -136
- package/src/eth1/stream.ts +0 -75
- package/src/eth1/utils/depositContract.ts +0 -37
- package/src/eth1/utils/deposits.ts +0 -70
- package/src/eth1/utils/eth1Data.ts +0 -100
- package/src/eth1/utils/eth1DepositEvent.ts +0 -12
- package/src/eth1/utils/eth1Vote.ts +0 -142
- package/src/eth1/utils/groupDepositEventsByBlock.ts +0 -19
- package/src/eth1/utils/optimizeNextBlockDiffForGenesis.ts +0 -18
- /package/lib/{eth1/provider → execution/engine}/jsonRpcHttpClient.js +0 -0
- /package/lib/{eth1/provider → execution/engine}/jwt.d.ts +0 -0
- /package/lib/{eth1/provider → execution/engine}/jwt.js +0 -0
- /package/src/{eth1/provider → execution/engine}/jwt.ts +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {routes} from "@lodestar/api";
|
|
2
|
+
import {BeaconConfig} from "@lodestar/config";
|
|
2
3
|
import {
|
|
3
4
|
CachedBeaconStateAllForks,
|
|
4
5
|
computeStartSlotAtEpoch,
|
|
@@ -10,7 +11,6 @@ import {Logger, MapDef, fromHex, sleep, toHex, toRootHex} from "@lodestar/utils"
|
|
|
10
11
|
import {Metrics} from "../../metrics/index.js";
|
|
11
12
|
import {AllocSource, BufferPool, BufferWithKey} from "../../util/bufferPool.js";
|
|
12
13
|
import {IClock} from "../../util/clock.js";
|
|
13
|
-
import {StateRegenerationOpts} from "../regen/interface.js";
|
|
14
14
|
import {serializeState} from "../serializeState.js";
|
|
15
15
|
import {CPStateDatastore, DatastoreKey} from "./datastore/index.js";
|
|
16
16
|
import {MapTracker} from "./mapMetrics.js";
|
|
@@ -24,6 +24,7 @@ export type PersistentCheckpointStateCacheOpts = {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
type PersistentCheckpointStateCacheModules = {
|
|
27
|
+
config: BeaconConfig;
|
|
27
28
|
metrics?: Metrics | null;
|
|
28
29
|
logger: Logger;
|
|
29
30
|
clock?: IClock | null;
|
|
@@ -107,6 +108,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
107
108
|
private readonly cache: MapTracker<CacheKey, CacheItem>;
|
|
108
109
|
/** Epoch -> Set<blockRoot> */
|
|
109
110
|
private readonly epochIndex = new MapDef<Epoch, Set<RootHex>>(() => new Set<string>());
|
|
111
|
+
private readonly config: BeaconConfig;
|
|
110
112
|
private readonly metrics: Metrics | null | undefined;
|
|
111
113
|
private readonly logger: Logger;
|
|
112
114
|
private readonly clock: IClock | null | undefined;
|
|
@@ -120,10 +122,20 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
120
122
|
private readonly bufferPool?: BufferPool | null;
|
|
121
123
|
|
|
122
124
|
constructor(
|
|
123
|
-
{
|
|
125
|
+
{
|
|
126
|
+
config,
|
|
127
|
+
metrics,
|
|
128
|
+
logger,
|
|
129
|
+
clock,
|
|
130
|
+
signal,
|
|
131
|
+
datastore,
|
|
132
|
+
blockStateCache,
|
|
133
|
+
bufferPool,
|
|
134
|
+
}: PersistentCheckpointStateCacheModules,
|
|
124
135
|
opts: PersistentCheckpointStateCacheOpts
|
|
125
136
|
) {
|
|
126
137
|
this.cache = new MapTracker(metrics?.cpStateCache);
|
|
138
|
+
this.config = config;
|
|
127
139
|
if (metrics) {
|
|
128
140
|
this.metrics = metrics;
|
|
129
141
|
metrics.cpStateCache.size.addCollect(() => {
|
|
@@ -191,10 +203,10 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
191
203
|
* - Get block for processing
|
|
192
204
|
* - Regen head state
|
|
193
205
|
*/
|
|
194
|
-
async getOrReload(cp: CheckpointHex
|
|
195
|
-
const stateOrStateBytesData = await this.getStateOrLoadDb(cp
|
|
206
|
+
async getOrReload(cp: CheckpointHex): Promise<CachedBeaconStateAllForks | null> {
|
|
207
|
+
const stateOrStateBytesData = await this.getStateOrLoadDb(cp);
|
|
196
208
|
if (stateOrStateBytesData === null || isCachedBeaconState(stateOrStateBytesData)) {
|
|
197
|
-
return stateOrStateBytesData
|
|
209
|
+
return stateOrStateBytesData ?? null;
|
|
198
210
|
}
|
|
199
211
|
const {persistedKey, stateBytes} = stateOrStateBytesData;
|
|
200
212
|
const logMeta = {persistedKey: toHex(persistedKey)};
|
|
@@ -220,7 +232,8 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
220
232
|
sszTimer?.();
|
|
221
233
|
const timer = this.metrics?.cpStateCache.stateReloadDuration.startTimer();
|
|
222
234
|
const newCachedState = loadCachedBeaconState(seedState, stateBytes, {}, validatorsBytes);
|
|
223
|
-
|
|
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
|
|
224
237
|
const stateRoot = toRootHex(newCachedState.hashTreeRoot());
|
|
225
238
|
timer?.();
|
|
226
239
|
|
|
@@ -239,7 +252,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
239
252
|
this.cache.set(cpKey, {type: CacheItemType.inMemory, state: newCachedState, persistedKey});
|
|
240
253
|
this.epochIndex.getOrDefault(cp.epoch).add(cp.rootHex);
|
|
241
254
|
// don't prune from memory here, call it at the last 1/3 of slot 0 of an epoch
|
|
242
|
-
return newCachedState
|
|
255
|
+
return newCachedState;
|
|
243
256
|
} catch (e) {
|
|
244
257
|
this.logger.debug("Reload: error loading cached state", logMeta, e as Error);
|
|
245
258
|
return null;
|
|
@@ -250,8 +263,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
250
263
|
* Return either state or state bytes loaded from db.
|
|
251
264
|
*/
|
|
252
265
|
async getStateOrBytes(cp: CheckpointHex): Promise<CachedBeaconStateAllForks | Uint8Array | null> {
|
|
253
|
-
|
|
254
|
-
const stateOrLoadedState = await this.getStateOrLoadDb(cp, {dontTransferCache: true});
|
|
266
|
+
const stateOrLoadedState = await this.getStateOrLoadDb(cp);
|
|
255
267
|
if (stateOrLoadedState === null || isCachedBeaconState(stateOrLoadedState)) {
|
|
256
268
|
return stateOrLoadedState;
|
|
257
269
|
}
|
|
@@ -261,12 +273,9 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
261
273
|
/**
|
|
262
274
|
* Return either state or state bytes with persisted key loaded from db.
|
|
263
275
|
*/
|
|
264
|
-
async getStateOrLoadDb(
|
|
265
|
-
cp: CheckpointHex,
|
|
266
|
-
opts?: StateRegenerationOpts
|
|
267
|
-
): Promise<CachedBeaconStateAllForks | LoadedStateBytesData | null> {
|
|
276
|
+
async getStateOrLoadDb(cp: CheckpointHex): Promise<CachedBeaconStateAllForks | LoadedStateBytesData | null> {
|
|
268
277
|
const cpKey = toCacheKey(cp);
|
|
269
|
-
const inMemoryState = this.get(cpKey
|
|
278
|
+
const inMemoryState = this.get(cpKey);
|
|
270
279
|
if (inMemoryState) {
|
|
271
280
|
return inMemoryState;
|
|
272
281
|
}
|
|
@@ -295,7 +304,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
295
304
|
/**
|
|
296
305
|
* Similar to get() api without reloading from disk
|
|
297
306
|
*/
|
|
298
|
-
get(cpOrKey: CheckpointHex | string
|
|
307
|
+
get(cpOrKey: CheckpointHex | string): CachedBeaconStateAllForks | null {
|
|
299
308
|
this.metrics?.cpStateCache.lookups.inc();
|
|
300
309
|
const cpKey = typeof cpOrKey === "string" ? cpOrKey : toCacheKey(cpOrKey);
|
|
301
310
|
const cacheItem = this.cache.get(cpKey);
|
|
@@ -313,7 +322,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
313
322
|
if (isInMemoryCacheItem(cacheItem)) {
|
|
314
323
|
const {state} = cacheItem;
|
|
315
324
|
this.metrics?.cpStateCache.stateClonedCount.observe(state.clonedCount);
|
|
316
|
-
return state
|
|
325
|
+
return state;
|
|
317
326
|
}
|
|
318
327
|
|
|
319
328
|
return null;
|
|
@@ -347,14 +356,14 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
347
356
|
/**
|
|
348
357
|
* Searches in-memory state for the latest cached state with a `root` without reload, starting with `epoch` and descending
|
|
349
358
|
*/
|
|
350
|
-
getLatest(rootHex: RootHex, maxEpoch: Epoch
|
|
359
|
+
getLatest(rootHex: RootHex, maxEpoch: Epoch): CachedBeaconStateAllForks | null {
|
|
351
360
|
// sort epochs in descending order, only consider epochs lte `epoch`
|
|
352
361
|
const epochs = Array.from(this.epochIndex.keys())
|
|
353
362
|
.sort((a, b) => b - a)
|
|
354
363
|
.filter((e) => e <= maxEpoch);
|
|
355
364
|
for (const epoch of epochs) {
|
|
356
365
|
if (this.epochIndex.get(epoch)?.has(rootHex)) {
|
|
357
|
-
const inMemoryClonedState = this.get({rootHex, epoch}
|
|
366
|
+
const inMemoryClonedState = this.get({rootHex, epoch});
|
|
358
367
|
if (inMemoryClonedState) {
|
|
359
368
|
return inMemoryClonedState;
|
|
360
369
|
}
|
|
@@ -370,11 +379,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
370
379
|
* - Get block for processing
|
|
371
380
|
* - Regen head state
|
|
372
381
|
*/
|
|
373
|
-
async getOrReloadLatest(
|
|
374
|
-
rootHex: RootHex,
|
|
375
|
-
maxEpoch: Epoch,
|
|
376
|
-
opts?: StateRegenerationOpts
|
|
377
|
-
): Promise<CachedBeaconStateAllForks | null> {
|
|
382
|
+
async getOrReloadLatest(rootHex: RootHex, maxEpoch: Epoch): Promise<CachedBeaconStateAllForks | null> {
|
|
378
383
|
// sort epochs in descending order, only consider epochs lte `epoch`
|
|
379
384
|
const epochs = Array.from(this.epochIndex.keys())
|
|
380
385
|
.sort((a, b) => b - a)
|
|
@@ -382,9 +387,9 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
382
387
|
for (const epoch of epochs) {
|
|
383
388
|
if (this.epochIndex.get(epoch)?.has(rootHex)) {
|
|
384
389
|
try {
|
|
385
|
-
const
|
|
386
|
-
if (
|
|
387
|
-
return
|
|
390
|
+
const state = await this.getOrReload({rootHex, epoch});
|
|
391
|
+
if (state) {
|
|
392
|
+
return state;
|
|
388
393
|
}
|
|
389
394
|
} catch (e) {
|
|
390
395
|
this.logger.debug("Error get or reload state", {epoch, rootHex}, e as Error);
|
|
@@ -484,7 +489,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
484
489
|
}
|
|
485
490
|
|
|
486
491
|
const blockSlot = state.slot;
|
|
487
|
-
const processCPStatesTimeMs =
|
|
492
|
+
const processCPStatesTimeMs = this.config.getSlotComponentDurationMs(PROCESS_CHECKPOINT_STATES_BPS);
|
|
488
493
|
// we always have clock in production, fallback value is only for test
|
|
489
494
|
const msFromSlot = this.clock?.msFromSlot(blockSlot) ?? processCPStatesTimeMs;
|
|
490
495
|
const msToProcessCPStates = processCPStatesTimeMs - msFromSlot;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {routes} from "@lodestar/api";
|
|
2
2
|
import {CachedBeaconStateAllForks} from "@lodestar/state-transition";
|
|
3
3
|
import {Epoch, RootHex, phase0} from "@lodestar/types";
|
|
4
|
-
import {StateRegenerationOpts} from "../regen/interface.js";
|
|
5
4
|
|
|
6
5
|
export type CheckpointHex = {epoch: Epoch; rootHex: RootHex};
|
|
7
6
|
|
|
@@ -21,7 +20,7 @@ export type CheckpointHex = {epoch: Epoch; rootHex: RootHex};
|
|
|
21
20
|
* The cache key is state root
|
|
22
21
|
*/
|
|
23
22
|
export interface BlockStateCache {
|
|
24
|
-
get(rootHex: RootHex
|
|
23
|
+
get(rootHex: RootHex): CachedBeaconStateAllForks | null;
|
|
25
24
|
add(item: CachedBeaconStateAllForks): void;
|
|
26
25
|
setHeadState(item: CachedBeaconStateAllForks | null): void;
|
|
27
26
|
/**
|
|
@@ -60,16 +59,12 @@ export interface BlockStateCache {
|
|
|
60
59
|
*/
|
|
61
60
|
export interface CheckpointStateCache {
|
|
62
61
|
init?: () => Promise<void>;
|
|
63
|
-
getOrReload(cp: CheckpointHex
|
|
62
|
+
getOrReload(cp: CheckpointHex): Promise<CachedBeaconStateAllForks | null>;
|
|
64
63
|
getStateOrBytes(cp: CheckpointHex): Promise<CachedBeaconStateAllForks | Uint8Array | null>;
|
|
65
|
-
get(cpOrKey: CheckpointHex | string
|
|
64
|
+
get(cpOrKey: CheckpointHex | string): CachedBeaconStateAllForks | null;
|
|
66
65
|
add(cp: phase0.Checkpoint, state: CachedBeaconStateAllForks): void;
|
|
67
|
-
getLatest(rootHex: RootHex, maxEpoch: Epoch
|
|
68
|
-
getOrReloadLatest(
|
|
69
|
-
rootHex: RootHex,
|
|
70
|
-
maxEpoch: Epoch,
|
|
71
|
-
opts?: StateRegenerationOpts
|
|
72
|
-
): Promise<CachedBeaconStateAllForks | null>;
|
|
66
|
+
getLatest(rootHex: RootHex, maxEpoch: Epoch): CachedBeaconStateAllForks | null;
|
|
67
|
+
getOrReloadLatest(rootHex: RootHex, maxEpoch: Epoch): Promise<CachedBeaconStateAllForks | null>;
|
|
73
68
|
updatePreComputedCheckpoint(rootHex: RootHex, epoch: Epoch): number | null;
|
|
74
69
|
prune(finalizedEpoch: Epoch, justifiedEpoch: Epoch): void;
|
|
75
70
|
pruneFinalized(finalizedEpoch: Epoch): void;
|
|
@@ -245,6 +245,18 @@ async function validateAggregateAndProof(
|
|
|
245
245
|
});
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
+
// Same race-condition check as above for seen aggregators
|
|
249
|
+
if (
|
|
250
|
+
!skipValidationKnownAttesters &&
|
|
251
|
+
chain.seenAggregatedAttestations.isKnown(targetEpoch, attIndex, attDataRootHex, aggregationBits)
|
|
252
|
+
) {
|
|
253
|
+
throw new AttestationError(GossipAction.IGNORE, {
|
|
254
|
+
code: AttestationErrorCode.ATTESTERS_ALREADY_KNOWN,
|
|
255
|
+
targetEpoch,
|
|
256
|
+
aggregateRoot: attDataRootHex,
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
|
|
248
260
|
chain.seenAggregators.add(targetEpoch, aggregatorIndex);
|
|
249
261
|
chain.seenAggregatedAttestations.add(
|
|
250
262
|
targetEpoch,
|
|
@@ -12,9 +12,9 @@ import {
|
|
|
12
12
|
isForkPostElectra,
|
|
13
13
|
} from "@lodestar/params";
|
|
14
14
|
import {
|
|
15
|
-
EpochCacheError,
|
|
16
|
-
EpochCacheErrorCode,
|
|
17
15
|
EpochShuffling,
|
|
16
|
+
ShufflingError,
|
|
17
|
+
ShufflingErrorCode,
|
|
18
18
|
SingleSignatureSet,
|
|
19
19
|
computeEpochAtSlot,
|
|
20
20
|
computeSigningRoot,
|
|
@@ -224,7 +224,7 @@ export async function validateApiAttestation(
|
|
|
224
224
|
code: AttestationErrorCode.INVALID_SIGNATURE,
|
|
225
225
|
});
|
|
226
226
|
} catch (err) {
|
|
227
|
-
if (err instanceof
|
|
227
|
+
if (err instanceof ShufflingError && err.type.code === ShufflingErrorCode.COMMITTEE_INDEX_OUT_OF_RANGE) {
|
|
228
228
|
throw new AttestationError(GossipAction.IGNORE, {
|
|
229
229
|
code: AttestationErrorCode.BAD_TARGET_EPOCH,
|
|
230
230
|
});
|
|
@@ -43,7 +43,14 @@ export async function validateAttesterSlashing(
|
|
|
43
43
|
// [REJECT] All of the conditions within process_attester_slashing pass validation.
|
|
44
44
|
try {
|
|
45
45
|
// verifySignature = false, verified in batch below
|
|
46
|
-
assertValidAttesterSlashing(
|
|
46
|
+
assertValidAttesterSlashing(
|
|
47
|
+
chain.config,
|
|
48
|
+
chain.index2pubkey,
|
|
49
|
+
state.slot,
|
|
50
|
+
state.validators.length,
|
|
51
|
+
attesterSlashing,
|
|
52
|
+
false
|
|
53
|
+
);
|
|
47
54
|
} catch (e) {
|
|
48
55
|
throw new AttesterSlashingError(GossipAction.REJECT, {
|
|
49
56
|
code: AttesterSlashingErrorCode.INVALID,
|
|
@@ -51,7 +58,12 @@ export async function validateAttesterSlashing(
|
|
|
51
58
|
});
|
|
52
59
|
}
|
|
53
60
|
|
|
54
|
-
const signatureSets = getAttesterSlashingSignatureSets(
|
|
61
|
+
const signatureSets = getAttesterSlashingSignatureSets(
|
|
62
|
+
chain.config,
|
|
63
|
+
chain.index2pubkey,
|
|
64
|
+
state.slot,
|
|
65
|
+
attesterSlashing
|
|
66
|
+
);
|
|
55
67
|
if (!(await chain.bls.verifySignatureSets(signatureSets, {batchable: true, priority: prioritizeBls}))) {
|
|
56
68
|
throw new AttesterSlashingError(GossipAction.REJECT, {
|
|
57
69
|
code: AttesterSlashingErrorCode.INVALID,
|
|
@@ -138,8 +138,9 @@ export async function validateGossipBlobSidecar(
|
|
|
138
138
|
const signature = blobSidecar.signedBlockHeader.signature;
|
|
139
139
|
if (!chain.seenBlockInputCache.isVerifiedProposerSignature(blobSlot, blockHex, signature)) {
|
|
140
140
|
const signatureSet = getBlockHeaderProposerSignatureSetByParentStateSlot(
|
|
141
|
+
chain.config,
|
|
141
142
|
chain.index2pubkey,
|
|
142
|
-
blockState,
|
|
143
|
+
blockState.slot,
|
|
143
144
|
blobSidecar.signedBlockHeader
|
|
144
145
|
);
|
|
145
146
|
// Don't batch so verification is not delayed
|
|
@@ -243,10 +244,9 @@ export async function validateBlockBlobSidecars(
|
|
|
243
244
|
const blockRootHex = toRootHex(blockRoot);
|
|
244
245
|
const signature = firstSidecarSignedBlockHeader.signature;
|
|
245
246
|
if (!chain.seenBlockInputCache.isVerifiedProposerSignature(blockSlot, blockRootHex, signature)) {
|
|
246
|
-
const headState = await chain.getHeadState();
|
|
247
247
|
const signatureSet = getBlockHeaderProposerSignatureSetByHeaderSlot(
|
|
248
|
+
chain.config,
|
|
248
249
|
chain.index2pubkey,
|
|
249
|
-
headState,
|
|
250
250
|
firstSidecarSignedBlockHeader
|
|
251
251
|
);
|
|
252
252
|
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
computeTimeAtSlot,
|
|
7
7
|
getBlockProposerSignatureSet,
|
|
8
8
|
isExecutionBlockBodyType,
|
|
9
|
+
isExecutionEnabled,
|
|
9
10
|
isExecutionStateType,
|
|
10
11
|
} from "@lodestar/state-transition";
|
|
11
12
|
import {SignedBeaconBlock, deneb} from "@lodestar/types";
|
|
@@ -133,13 +134,16 @@ export async function validateGossipBlock(
|
|
|
133
134
|
throw new BlockGossipError(GossipAction.IGNORE, {code: BlockErrorCode.PARENT_UNKNOWN, parentRoot});
|
|
134
135
|
});
|
|
135
136
|
|
|
137
|
+
// in forky condition, make sure to populate ShufflingCache with regened state
|
|
138
|
+
chain.shufflingCache.processState(blockState);
|
|
139
|
+
|
|
136
140
|
// Extra conditions for merge fork blocks
|
|
137
141
|
// [REJECT] The block's execution payload timestamp is correct with respect to the slot
|
|
138
142
|
// -- i.e. execution_payload.timestamp == compute_timestamp_at_slot(state, block.slot).
|
|
139
143
|
if (fork === ForkName.bellatrix) {
|
|
140
144
|
if (!isExecutionBlockBodyType(block.body)) throw Error("Not merge block type");
|
|
141
145
|
const executionPayload = block.body.executionPayload;
|
|
142
|
-
if (isExecutionStateType(blockState)) {
|
|
146
|
+
if (isExecutionStateType(blockState) && isExecutionEnabled(blockState, block)) {
|
|
143
147
|
const expectedTimestamp = computeTimeAtSlot(config, blockSlot, chain.genesisTime);
|
|
144
148
|
if (executionPayload.timestamp !== computeTimeAtSlot(config, blockSlot, chain.genesisTime)) {
|
|
145
149
|
throw new BlockGossipError(GossipAction.REJECT, {
|
|
@@ -153,7 +157,7 @@ export async function validateGossipBlock(
|
|
|
153
157
|
|
|
154
158
|
// [REJECT] The proposer signature, signed_beacon_block.signature, is valid with respect to the proposer_index pubkey.
|
|
155
159
|
if (!chain.seenBlockInputCache.isVerifiedProposerSignature(blockSlot, blockRoot, signedBlock.signature)) {
|
|
156
|
-
const signatureSet = getBlockProposerSignatureSet(chain.
|
|
160
|
+
const signatureSet = getBlockProposerSignatureSet(chain.config, chain.index2pubkey, signedBlock);
|
|
157
161
|
// Don't batch so verification is not delayed
|
|
158
162
|
if (!(await chain.bls.verifySignatureSets([signatureSet], {verifyOnMainThread: true}))) {
|
|
159
163
|
throw new BlockGossipError(GossipAction.REJECT, {
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CachedBeaconStateCapella,
|
|
3
|
-
getBlsToExecutionChangeSignatureSet,
|
|
4
|
-
isValidBlsToExecutionChange,
|
|
5
|
-
} from "@lodestar/state-transition";
|
|
1
|
+
import {getBlsToExecutionChangeSignatureSet, isValidBlsToExecutionChange} from "@lodestar/state-transition";
|
|
6
2
|
import {capella} from "@lodestar/types";
|
|
7
3
|
import {BlsToExecutionChangeError, BlsToExecutionChangeErrorCode, GossipAction} from "../errors/index.js";
|
|
8
4
|
import {IBeaconChain} from "../index.js";
|
|
@@ -41,11 +37,17 @@ async function validateBlsToExecutionChange(
|
|
|
41
37
|
// NOTE: No need to advance head state since the signature's fork is handled with `broadcastedOnFork`,
|
|
42
38
|
// and chanes relevant to `isValidBlsToExecutionChange()` happen only on processBlock(), not processEpoch()
|
|
43
39
|
const state = chain.getHeadState();
|
|
44
|
-
const {config} =
|
|
45
|
-
|
|
40
|
+
const {config} = chain;
|
|
41
|
+
const addressChange = blsToExecutionChange.message;
|
|
42
|
+
if (addressChange.validatorIndex >= state.validators.length) {
|
|
43
|
+
throw new BlsToExecutionChangeError(GossipAction.REJECT, {
|
|
44
|
+
code: BlsToExecutionChangeErrorCode.INVALID,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
const validator = state.validators.getReadonly(addressChange.validatorIndex);
|
|
46
48
|
// [REJECT] All of the conditions within process_bls_to_execution_change pass validation.
|
|
47
49
|
// verifySignature = false, verified in batch below
|
|
48
|
-
const {valid} = isValidBlsToExecutionChange(
|
|
50
|
+
const {valid} = isValidBlsToExecutionChange(config, validator, blsToExecutionChange, false);
|
|
49
51
|
if (!valid) {
|
|
50
52
|
throw new BlsToExecutionChangeError(GossipAction.REJECT, {
|
|
51
53
|
code: BlsToExecutionChangeErrorCode.INVALID,
|
|
@@ -135,8 +135,9 @@ export async function validateGossipDataColumnSidecar(
|
|
|
135
135
|
const signature = dataColumnSidecar.signedBlockHeader.signature;
|
|
136
136
|
if (!chain.seenBlockInputCache.isVerifiedProposerSignature(blockHeader.slot, blockRootHex, signature)) {
|
|
137
137
|
const signatureSet = getBlockHeaderProposerSignatureSetByParentStateSlot(
|
|
138
|
+
chain.config,
|
|
138
139
|
chain.index2pubkey,
|
|
139
|
-
blockState,
|
|
140
|
+
blockState.slot,
|
|
140
141
|
dataColumnSidecar.signedBlockHeader
|
|
141
142
|
);
|
|
142
143
|
|
|
@@ -336,10 +337,9 @@ export async function validateBlockDataColumnSidecars(
|
|
|
336
337
|
const slot = firstSidecarSignedBlockHeader.message.slot;
|
|
337
338
|
const signature = firstSidecarSignedBlockHeader.signature;
|
|
338
339
|
if (!chain.seenBlockInputCache.isVerifiedProposerSignature(slot, rootHex, signature)) {
|
|
339
|
-
const headState = await chain.getHeadState();
|
|
340
340
|
const signatureSet = getBlockHeaderProposerSignatureSetByHeaderSlot(
|
|
341
|
+
chain.config,
|
|
341
342
|
chain.index2pubkey,
|
|
342
|
-
headState,
|
|
343
343
|
firstSidecarSignedBlockHeader
|
|
344
344
|
);
|
|
345
345
|
|
|
@@ -35,8 +35,9 @@ async function validateProposerSlashing(
|
|
|
35
35
|
|
|
36
36
|
// [REJECT] All of the conditions within process_proposer_slashing pass validation.
|
|
37
37
|
try {
|
|
38
|
+
const proposer = state.validators.getReadonly(proposerSlashing.signedHeader1.message.proposerIndex);
|
|
38
39
|
// verifySignature = false, verified in batch below
|
|
39
|
-
assertValidProposerSlashing(state, proposerSlashing, false);
|
|
40
|
+
assertValidProposerSlashing(chain.config, chain.index2pubkey, state.slot, proposerSlashing, proposer, false);
|
|
40
41
|
} catch (e) {
|
|
41
42
|
throw new ProposerSlashingError(GossipAction.REJECT, {
|
|
42
43
|
code: ProposerSlashingErrorCode.INVALID,
|
|
@@ -44,7 +45,12 @@ async function validateProposerSlashing(
|
|
|
44
45
|
});
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
const signatureSets = getProposerSlashingSignatureSets(
|
|
48
|
+
const signatureSets = getProposerSlashingSignatureSets(
|
|
49
|
+
chain.config,
|
|
50
|
+
chain.index2pubkey,
|
|
51
|
+
state.slot,
|
|
52
|
+
proposerSlashing
|
|
53
|
+
);
|
|
48
54
|
if (!(await chain.bls.verifySignatureSets(signatureSets, {batchable: true, priority: prioritizeBls}))) {
|
|
49
55
|
throw new ProposerSlashingError(GossipAction.REJECT, {
|
|
50
56
|
code: ProposerSlashingErrorCode.INVALID,
|
|
@@ -14,7 +14,7 @@ export function getAggregateAndProofSigningRoot(
|
|
|
14
14
|
epoch: Epoch,
|
|
15
15
|
aggregateAndProof: SignedAggregateAndProof
|
|
16
16
|
): Uint8Array {
|
|
17
|
-
// previously, we call `const aggregatorDomain =
|
|
17
|
+
// previously, we call `const aggregatorDomain = config.getDomain(state.slot, DOMAIN_AGGREGATE_AND_PROOF, slot);`
|
|
18
18
|
// at fork boundary, it's required to dial to target epoch https://github.com/ChainSafe/lodestar/blob/v1.11.3/packages/beacon-node/src/chain/validation/attestation.ts#L573
|
|
19
19
|
// instead of that, just use the fork of slot in the attestation data
|
|
20
20
|
const slot = computeStartSlotAtEpoch(epoch);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {BeaconConfig} from "@lodestar/config";
|
|
1
2
|
import {DOMAIN_CONTRIBUTION_AND_PROOF} from "@lodestar/params";
|
|
2
3
|
import {
|
|
3
4
|
CachedBeaconStateAllForks,
|
|
@@ -9,11 +10,12 @@ import {
|
|
|
9
10
|
import {altair, ssz} from "@lodestar/types";
|
|
10
11
|
|
|
11
12
|
export function getContributionAndProofSignatureSet(
|
|
13
|
+
config: BeaconConfig,
|
|
12
14
|
index2pubkey: Index2PubkeyCache,
|
|
13
15
|
state: CachedBeaconStateAllForks,
|
|
14
16
|
signedContributionAndProof: altair.SignedContributionAndProof
|
|
15
17
|
): ISignatureSet {
|
|
16
|
-
const domain =
|
|
18
|
+
const domain = config.getDomain(
|
|
17
19
|
state.slot,
|
|
18
20
|
DOMAIN_CONTRIBUTION_AND_PROOF,
|
|
19
21
|
signedContributionAndProof.message.contribution.slot
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {BeaconConfig} from "@lodestar/config";
|
|
1
2
|
import {DOMAIN_SYNC_COMMITTEE} from "@lodestar/params";
|
|
2
3
|
import {
|
|
3
4
|
CachedBeaconStateAllForks,
|
|
@@ -9,11 +10,12 @@ import {
|
|
|
9
10
|
import {altair, ssz} from "@lodestar/types";
|
|
10
11
|
|
|
11
12
|
export function getSyncCommitteeSignatureSet(
|
|
13
|
+
config: BeaconConfig,
|
|
12
14
|
index2pubkey: Index2PubkeyCache,
|
|
13
15
|
state: CachedBeaconStateAllForks,
|
|
14
16
|
syncCommittee: altair.SyncCommitteeMessage
|
|
15
17
|
): ISignatureSet {
|
|
16
|
-
const domain =
|
|
18
|
+
const domain = config.getDomain(state.slot, DOMAIN_SYNC_COMMITTEE, syncCommittee.slot);
|
|
17
19
|
|
|
18
20
|
return {
|
|
19
21
|
type: SignatureSetType.single,
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import {PublicKey} from "@chainsafe/blst";
|
|
2
|
+
import {BeaconConfig} from "@lodestar/config";
|
|
2
3
|
import {DOMAIN_SYNC_COMMITTEE} from "@lodestar/params";
|
|
3
4
|
import {CachedBeaconStateAltair, ISignatureSet, SignatureSetType, computeSigningRoot} from "@lodestar/state-transition";
|
|
4
5
|
import {altair, ssz} from "@lodestar/types";
|
|
5
6
|
|
|
6
7
|
export function getSyncCommitteeContributionSignatureSet(
|
|
8
|
+
config: BeaconConfig,
|
|
7
9
|
state: CachedBeaconStateAltair,
|
|
8
10
|
contribution: altair.SyncCommitteeContribution,
|
|
9
11
|
pubkeys: PublicKey[]
|
|
10
12
|
): ISignatureSet {
|
|
11
|
-
const domain =
|
|
13
|
+
const domain = config.getDomain(state.slot, DOMAIN_SYNC_COMMITTEE, contribution.slot);
|
|
12
14
|
return {
|
|
13
15
|
type: SignatureSetType.aggregate,
|
|
14
16
|
pubkeys,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {BeaconConfig} from "@lodestar/config";
|
|
1
2
|
import {DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF} from "@lodestar/params";
|
|
2
3
|
import {
|
|
3
4
|
CachedBeaconStateAllForks,
|
|
@@ -9,11 +10,11 @@ import {
|
|
|
9
10
|
import {altair, ssz} from "@lodestar/types";
|
|
10
11
|
|
|
11
12
|
export function getSyncCommitteeSelectionProofSignatureSet(
|
|
13
|
+
config: BeaconConfig,
|
|
12
14
|
index2pubkey: Index2PubkeyCache,
|
|
13
15
|
state: CachedBeaconStateAllForks,
|
|
14
16
|
contributionAndProof: altair.ContributionAndProof
|
|
15
17
|
): ISignatureSet {
|
|
16
|
-
const {config} = state;
|
|
17
18
|
const slot = contributionAndProof.contribution.slot;
|
|
18
19
|
const domain = config.getDomain(state.slot, DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF, slot);
|
|
19
20
|
const signingData: altair.SyncAggregatorSelectionData = {
|
|
@@ -89,7 +89,7 @@ async function validateSyncCommitteeSigOnly(
|
|
|
89
89
|
syncCommittee: altair.SyncCommitteeMessage,
|
|
90
90
|
prioritizeBls = false
|
|
91
91
|
): Promise<void> {
|
|
92
|
-
const signatureSet = getSyncCommitteeSignatureSet(chain.index2pubkey, headState, syncCommittee);
|
|
92
|
+
const signatureSet = getSyncCommitteeSignatureSet(chain.config, chain.index2pubkey, headState, syncCommittee);
|
|
93
93
|
if (!(await chain.bls.verifySignatureSets([signatureSet], {batchable: true, priority: prioritizeBls}))) {
|
|
94
94
|
throw new SyncCommitteeError(GossipAction.REJECT, {
|
|
95
95
|
code: SyncCommitteeErrorCode.INVALID_SIGNATURE,
|
|
@@ -78,14 +78,19 @@ export async function validateSyncCommitteeGossipContributionAndProof(
|
|
|
78
78
|
const signatureSets = [
|
|
79
79
|
// [REJECT] The contribution_and_proof.selection_proof is a valid signature of the SyncAggregatorSelectionData
|
|
80
80
|
// derived from the contribution by the validator with index contribution_and_proof.aggregator_index.
|
|
81
|
-
getSyncCommitteeSelectionProofSignatureSet(index2pubkey, headState, contributionAndProof),
|
|
81
|
+
getSyncCommitteeSelectionProofSignatureSet(chain.config, index2pubkey, headState, contributionAndProof),
|
|
82
82
|
|
|
83
83
|
// [REJECT] The aggregator signature, signed_contribution_and_proof.signature, is valid.
|
|
84
|
-
getContributionAndProofSignatureSet(index2pubkey, headState, signedContributionAndProof),
|
|
84
|
+
getContributionAndProofSignatureSet(chain.config, index2pubkey, headState, signedContributionAndProof),
|
|
85
85
|
|
|
86
86
|
// [REJECT] The aggregate signature is valid for the message beacon_block_root and aggregate pubkey derived from
|
|
87
87
|
// the participation info in aggregation_bits for the subcommittee specified by the contribution.subcommittee_index.
|
|
88
|
-
getSyncCommitteeContributionSignatureSet(
|
|
88
|
+
getSyncCommitteeContributionSignatureSet(
|
|
89
|
+
chain.config,
|
|
90
|
+
headState as CachedBeaconStateAltair,
|
|
91
|
+
contribution,
|
|
92
|
+
participantPubkeys
|
|
93
|
+
),
|
|
89
94
|
];
|
|
90
95
|
|
|
91
96
|
if (!(await chain.bls.verifySignatureSets(signatureSets, {batchable: true}))) {
|
|
@@ -59,7 +59,7 @@ async function validateVoluntaryExit(
|
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
const signatureSet = getVoluntaryExitSignatureSet(chain.index2pubkey, state, voluntaryExit);
|
|
62
|
+
const signatureSet = getVoluntaryExitSignatureSet(chain.config, chain.index2pubkey, state.slot, voluntaryExit);
|
|
63
63
|
if (!(await chain.bls.verifySignatureSets([signatureSet], {batchable: true, priority: prioritizeBls}))) {
|
|
64
64
|
throw new VoluntaryExitError(GossipAction.REJECT, {
|
|
65
65
|
code: VoluntaryExitErrorCode.INVALID_SIGNATURE,
|
package/src/db/beacon.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {ChainForkConfig} from "@lodestar/config";
|
|
2
|
-
import {Db, LevelDbControllerMetrics} from "@lodestar/db";
|
|
2
|
+
import {Db, LevelDbControllerMetrics, encodeKey} from "@lodestar/db";
|
|
3
|
+
import {Bucket} from "./buckets.js";
|
|
3
4
|
import {IBeaconDb} from "./interface.js";
|
|
4
5
|
import {CheckpointStateRepository} from "./repositories/checkpointState.js";
|
|
5
6
|
import {
|
|
@@ -14,16 +15,12 @@ import {
|
|
|
14
15
|
CheckpointHeaderRepository,
|
|
15
16
|
DataColumnSidecarArchiveRepository,
|
|
16
17
|
DataColumnSidecarRepository,
|
|
17
|
-
DepositDataRootRepository,
|
|
18
|
-
DepositEventRepository,
|
|
19
|
-
Eth1DataRepository,
|
|
20
18
|
ProposerSlashingRepository,
|
|
21
19
|
StateArchiveRepository,
|
|
22
20
|
SyncCommitteeRepository,
|
|
23
21
|
SyncCommitteeWitnessRepository,
|
|
24
22
|
VoluntaryExitRepository,
|
|
25
23
|
} from "./repositories/index.js";
|
|
26
|
-
import {PreGenesisState, PreGenesisStateLastProcessedBlock} from "./single/index.js";
|
|
27
24
|
|
|
28
25
|
export type BeaconDbModules = {
|
|
29
26
|
config: ChainForkConfig;
|
|
@@ -45,14 +42,8 @@ export class BeaconDb implements IBeaconDb {
|
|
|
45
42
|
voluntaryExit: VoluntaryExitRepository;
|
|
46
43
|
proposerSlashing: ProposerSlashingRepository;
|
|
47
44
|
attesterSlashing: AttesterSlashingRepository;
|
|
48
|
-
depositEvent: DepositEventRepository;
|
|
49
45
|
blsToExecutionChange: BLSToExecutionChangeRepository;
|
|
50
46
|
|
|
51
|
-
depositDataRoot: DepositDataRootRepository;
|
|
52
|
-
eth1Data: Eth1DataRepository;
|
|
53
|
-
preGenesisState: PreGenesisState;
|
|
54
|
-
preGenesisStateLastProcessedBlock: PreGenesisStateLastProcessedBlock;
|
|
55
|
-
|
|
56
47
|
// lightclient
|
|
57
48
|
bestLightClientUpdate: BestLightClientUpdateRepository;
|
|
58
49
|
checkpointHeader: CheckpointHeaderRepository;
|
|
@@ -80,11 +71,6 @@ export class BeaconDb implements IBeaconDb {
|
|
|
80
71
|
this.blsToExecutionChange = new BLSToExecutionChangeRepository(config, db);
|
|
81
72
|
this.proposerSlashing = new ProposerSlashingRepository(config, db);
|
|
82
73
|
this.attesterSlashing = new AttesterSlashingRepository(config, db);
|
|
83
|
-
this.depositEvent = new DepositEventRepository(config, db);
|
|
84
|
-
this.depositDataRoot = new DepositDataRootRepository(config, db);
|
|
85
|
-
this.eth1Data = new Eth1DataRepository(config, db);
|
|
86
|
-
this.preGenesisState = new PreGenesisState(config, db);
|
|
87
|
-
this.preGenesisStateLastProcessedBlock = new PreGenesisStateLastProcessedBlock(config, db);
|
|
88
74
|
|
|
89
75
|
// lightclient
|
|
90
76
|
this.bestLightClientUpdate = new BestLightClientUpdateRepository(config, db);
|
|
@@ -110,4 +96,40 @@ export class BeaconDb implements IBeaconDb {
|
|
|
110
96
|
// TODO: Enable once it's deemed safe
|
|
111
97
|
// await this.block.batchDelete(await this.block.keys());
|
|
112
98
|
}
|
|
99
|
+
|
|
100
|
+
async deleteDeprecatedEth1Data(): Promise<void> {
|
|
101
|
+
const deprecatedBuckets = [
|
|
102
|
+
Bucket.phase0_eth1Data,
|
|
103
|
+
Bucket.index_depositDataRoot,
|
|
104
|
+
Bucket.phase0_depositData,
|
|
105
|
+
Bucket.phase0_depositEvent,
|
|
106
|
+
Bucket.phase0_preGenesisState,
|
|
107
|
+
Bucket.phase0_preGenesisStateLastProcessedBlock,
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
for (const bucket of deprecatedBuckets) {
|
|
111
|
+
await this.deleteBucketData(bucket);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
private async deleteBucketData(bucket: Bucket): Promise<void> {
|
|
116
|
+
const minKey = encodeKey(bucket, Buffer.alloc(0));
|
|
117
|
+
const maxKey = encodeKey(bucket + 1, Buffer.alloc(0));
|
|
118
|
+
|
|
119
|
+
// Batch delete to avoid loading all keys into memory at once
|
|
120
|
+
const BATCH_DELETE_SIZE = 1000;
|
|
121
|
+
let keysBatch: Uint8Array[] = [];
|
|
122
|
+
|
|
123
|
+
for await (const key of this.db.keysStream({gte: minKey, lt: maxKey})) {
|
|
124
|
+
keysBatch.push(key);
|
|
125
|
+
if (keysBatch.length >= BATCH_DELETE_SIZE) {
|
|
126
|
+
await this.db.batchDelete(keysBatch);
|
|
127
|
+
keysBatch = [];
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (keysBatch.length > 0) {
|
|
132
|
+
await this.db.batchDelete(keysBatch);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
113
135
|
}
|