@lodestar/beacon-node 1.38.0 → 1.39.0-dev.39dac0f03d
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/utils.js +1 -1
- package/lib/api/impl/beacon/blocks/utils.js.map +1 -1
- package/lib/api/impl/beacon/state/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/state/index.js +4 -5
- package/lib/api/impl/beacon/state/index.js.map +1 -1
- package/lib/api/impl/validator/index.js +1 -1
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlock.js +1 -21
- package/lib/chain/blocks/verifyBlock.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts +1 -6
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +9 -128
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksSignatures.d.ts +3 -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/chain.d.ts +1 -4
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +10 -28
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/initState.d.ts +1 -14
- package/lib/chain/initState.d.ts.map +1 -1
- package/lib/chain/initState.js +1 -62
- package/lib/chain/initState.js.map +1 -1
- package/lib/chain/interface.d.ts +0 -2
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/interface.js.map +1 -1
- package/lib/chain/opPools/aggregatedAttestationPool.d.ts +4 -4
- package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
- package/lib/chain/opPools/aggregatedAttestationPool.js +4 -4
- 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 +9 -8
- package/lib/chain/opPools/opPool.js.map +1 -1
- package/lib/chain/options.d.ts +0 -4
- package/lib/chain/options.d.ts.map +1 -1
- package/lib/chain/options.js +0 -2
- package/lib/chain/options.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 +2 -22
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +2 -22
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +32 -98
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/rewards/attestationsRewards.d.ts +3 -2
- package/lib/chain/rewards/attestationsRewards.d.ts.map +1 -1
- package/lib/chain/rewards/attestationsRewards.js +9 -9
- package/lib/chain/rewards/attestationsRewards.js.map +1 -1
- package/lib/chain/rewards/blockRewards.d.ts +2 -1
- package/lib/chain/rewards/blockRewards.d.ts.map +1 -1
- package/lib/chain/rewards/blockRewards.js +5 -5
- package/lib/chain/rewards/blockRewards.js.map +1 -1
- package/lib/chain/rewards/syncCommitteeRewards.d.ts +3 -2
- package/lib/chain/rewards/syncCommitteeRewards.d.ts.map +1 -1
- package/lib/chain/rewards/syncCommitteeRewards.js +2 -3
- package/lib/chain/rewards/syncCommitteeRewards.js.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +4 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.js +4 -2
- package/lib/chain/stateCache/persistentCheckpointsCache.js.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 -2
- package/lib/chain/validation/blobSidecar.js.map +1 -1
- package/lib/chain/validation/block.js +1 -1
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/chain/validation/blsToExecutionChange.js +1 -1
- package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.js +2 -2
- package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
- package/lib/chain/validation/proposerSlashing.js +1 -1
- package/lib/chain/validation/proposerSlashing.js.map +1 -1
- package/lib/chain/validation/signatureSets/aggregateAndProof.js +1 -1
- package/lib/chain/validation/signatureSets/aggregateAndProof.js.map +1 -1
- package/lib/chain/validation/signatureSets/contributionAndProof.d.ts +3 -2
- package/lib/chain/validation/signatureSets/contributionAndProof.d.ts.map +1 -1
- package/lib/chain/validation/signatureSets/contributionAndProof.js +3 -4
- package/lib/chain/validation/signatureSets/contributionAndProof.js.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommittee.d.ts +3 -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 +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 +3 -2
- package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js +2 -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 +5 -4
- 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/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/execution/engine/http.d.ts +5 -13
- package/lib/execution/engine/http.d.ts.map +1 -1
- package/lib/execution/engine/http.js +6 -15
- 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 +2 -6
- package/lib/execution/engine/mock.d.ts.map +1 -1
- package/lib/execution/engine/mock.js +4 -15
- 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 +0 -49
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +0 -134
- 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/node/nodejs.d.ts.map +1 -1
- package/lib/node/nodejs.js +10 -9
- package/lib/node/nodejs.js.map +1 -1
- package/lib/node/notifier.d.ts.map +1 -1
- package/lib/node/notifier.js +0 -13
- 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 -2
- 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/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 +14 -21
- package/src/api/impl/beacon/blocks/utils.ts +1 -1
- package/src/api/impl/beacon/state/index.ts +4 -5
- package/src/api/impl/validator/index.ts +1 -1
- package/src/chain/blocks/verifyBlock.ts +3 -24
- package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +9 -161
- package/src/chain/blocks/verifyBlocksSignatures.ts +5 -2
- package/src/chain/chain.ts +9 -32
- package/src/chain/initState.ts +1 -97
- package/src/chain/interface.ts +0 -2
- package/src/chain/opPools/aggregatedAttestationPool.ts +7 -7
- package/src/chain/opPools/opPool.ts +8 -8
- package/src/chain/options.ts +0 -6
- package/src/chain/prepareNextSlot.ts +2 -29
- package/src/chain/produceBlock/produceBlockBody.ts +33 -132
- package/src/chain/rewards/attestationsRewards.ts +18 -8
- package/src/chain/rewards/blockRewards.ts +6 -3
- package/src/chain/rewards/syncCommitteeRewards.ts +5 -3
- package/src/chain/stateCache/persistentCheckpointsCache.ts +15 -2
- package/src/chain/validation/attesterSlashing.ts +2 -2
- package/src/chain/validation/blobSidecar.ts +10 -2
- package/src/chain/validation/block.ts +1 -1
- package/src/chain/validation/blsToExecutionChange.ts +1 -1
- package/src/chain/validation/dataColumnSidecar.ts +6 -1
- package/src/chain/validation/proposerSlashing.ts +1 -1
- package/src/chain/validation/signatureSets/aggregateAndProof.ts +1 -1
- package/src/chain/validation/signatureSets/contributionAndProof.ts +6 -3
- package/src/chain/validation/signatureSets/syncCommittee.ts +6 -2
- package/src/chain/validation/signatureSets/syncCommitteeContribution.ts +3 -1
- package/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts +5 -2
- package/src/chain/validation/syncCommittee.ts +1 -1
- package/src/chain/validation/syncCommitteeContributionAndProof.ts +10 -6
- 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/index.ts +0 -3
- package/src/execution/engine/http.ts +12 -21
- 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 +4 -17
- 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 +0 -144
- package/src/network/core/events.ts +1 -1
- package/src/network/events.ts +7 -1
- package/src/node/nodejs.ts +11 -9
- package/src/node/notifier.ts +0 -16
- 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 +14 -2
- package/src/sync/backfill/verify.ts +10 -2
- 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/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/eth1MergeBlockTracker.d.ts +0 -65
- package/lib/eth1/eth1MergeBlockTracker.d.ts.map +0 -1
- package/lib/eth1/eth1MergeBlockTracker.js +0 -262
- package/lib/eth1/eth1MergeBlockTracker.js.map +0 -1
- package/lib/eth1/index.d.ts +0 -46
- package/lib/eth1/index.d.ts.map +0 -1
- package/lib/eth1/index.js +0 -121
- package/lib/eth1/index.js.map +0 -1
- package/lib/eth1/interface.d.ts +0 -112
- 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/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/eth1MergeBlockTracker.ts +0 -328
- package/src/eth1/index.ts +0 -157
- package/src/eth1/interface.ts +0 -131
- 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,190 +0,0 @@
|
|
|
1
|
-
import {Tree, toGindex} from "@chainsafe/persistent-merkle-tree";
|
|
2
|
-
import {BeaconConfig, ChainForkConfig} from "@lodestar/config";
|
|
3
|
-
import {GENESIS_EPOCH, GENESIS_SLOT} from "@lodestar/params";
|
|
4
|
-
import {
|
|
5
|
-
BeaconStateAllForks,
|
|
6
|
-
CachedBeaconStateAllForks,
|
|
7
|
-
applyDeposits,
|
|
8
|
-
applyEth1BlockHash,
|
|
9
|
-
applyTimestamp,
|
|
10
|
-
createCachedBeaconState,
|
|
11
|
-
createEmptyEpochCacheImmutableData,
|
|
12
|
-
getActiveValidatorIndices,
|
|
13
|
-
getGenesisBeaconState,
|
|
14
|
-
getTemporaryBlockHeader,
|
|
15
|
-
} from "@lodestar/state-transition";
|
|
16
|
-
import {phase0, ssz} from "@lodestar/types";
|
|
17
|
-
import {Logger} from "@lodestar/utils";
|
|
18
|
-
import {DepositTree} from "../../db/repositories/depositDataRoot.js";
|
|
19
|
-
import {IEth1Provider} from "../../eth1/index.js";
|
|
20
|
-
import {IEth1StreamParams} from "../../eth1/interface.js";
|
|
21
|
-
import {getDepositsAndBlockStreamForGenesis, getDepositsStream} from "../../eth1/stream.js";
|
|
22
|
-
import {GenesisResult, IGenesisBuilder} from "./interface.js";
|
|
23
|
-
|
|
24
|
-
export type GenesisBuilderKwargs = {
|
|
25
|
-
config: ChainForkConfig;
|
|
26
|
-
eth1Provider: IEth1Provider;
|
|
27
|
-
logger: Logger;
|
|
28
|
-
|
|
29
|
-
/** Use to restore pending progress */
|
|
30
|
-
pendingStatus?: {
|
|
31
|
-
state: BeaconStateAllForks;
|
|
32
|
-
depositTree: DepositTree;
|
|
33
|
-
lastProcessedBlockNumber: number;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
signal?: AbortSignal;
|
|
37
|
-
maxBlocksPerPoll?: number;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export class GenesisBuilder implements IGenesisBuilder {
|
|
41
|
-
// Expose state to persist on error
|
|
42
|
-
readonly state: CachedBeaconStateAllForks;
|
|
43
|
-
readonly depositTree: DepositTree;
|
|
44
|
-
/** Is null if no block has been processed yet */
|
|
45
|
-
lastProcessedBlockNumber: number | null = null;
|
|
46
|
-
|
|
47
|
-
private readonly config: BeaconConfig;
|
|
48
|
-
private readonly eth1Provider: IEth1Provider;
|
|
49
|
-
private readonly logger: Logger;
|
|
50
|
-
private readonly signal?: AbortSignal;
|
|
51
|
-
private readonly eth1Params: IEth1StreamParams;
|
|
52
|
-
private readonly depositCache = new Set<number>();
|
|
53
|
-
private readonly fromBlock: number;
|
|
54
|
-
private readonly logEvery = 30 * 1000;
|
|
55
|
-
private lastLog = 0;
|
|
56
|
-
/** Current count of active validators in the state */
|
|
57
|
-
private activatedValidatorCount: number;
|
|
58
|
-
|
|
59
|
-
constructor({config, eth1Provider, logger, signal, pendingStatus, maxBlocksPerPoll}: GenesisBuilderKwargs) {
|
|
60
|
-
// at genesis builder, there is no genesis validator so we don't have a real BeaconConfig
|
|
61
|
-
// but we need BeaconConfig to temporarily create CachedBeaconState, the cast here is safe since we don't use any getDomain here
|
|
62
|
-
// the use of state as CachedBeaconState is just for convenient, GenesisResult returns TreeView anyway
|
|
63
|
-
this.eth1Provider = eth1Provider;
|
|
64
|
-
this.logger = logger;
|
|
65
|
-
this.signal = signal;
|
|
66
|
-
this.eth1Params = {
|
|
67
|
-
...config,
|
|
68
|
-
maxBlocksPerPoll: maxBlocksPerPoll ?? 10000,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
let stateView: BeaconStateAllForks;
|
|
72
|
-
|
|
73
|
-
if (pendingStatus) {
|
|
74
|
-
this.logger.info("Restoring pending genesis state", {block: pendingStatus.lastProcessedBlockNumber});
|
|
75
|
-
stateView = pendingStatus.state;
|
|
76
|
-
this.depositTree = pendingStatus.depositTree;
|
|
77
|
-
this.fromBlock = Math.max(pendingStatus.lastProcessedBlockNumber + 1, this.eth1Provider.deployBlock);
|
|
78
|
-
} else {
|
|
79
|
-
stateView = getGenesisBeaconState(
|
|
80
|
-
config,
|
|
81
|
-
ssz.phase0.Eth1Data.defaultValue(),
|
|
82
|
-
getTemporaryBlockHeader(config, config.getForkTypes(GENESIS_SLOT).BeaconBlock.defaultValue())
|
|
83
|
-
);
|
|
84
|
-
this.depositTree = ssz.phase0.DepositDataRootList.defaultViewDU();
|
|
85
|
-
this.fromBlock = this.eth1Provider.deployBlock;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// TODO - PENDING: Ensure EpochCacheImmutableData is created only once
|
|
89
|
-
this.state = createCachedBeaconState(stateView, createEmptyEpochCacheImmutableData(config, stateView));
|
|
90
|
-
this.config = this.state.config;
|
|
91
|
-
this.activatedValidatorCount = getActiveValidatorIndices(stateView, GENESIS_EPOCH).length;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Get eth1 deposit events and blocks and apply to this.state until we found genesis.
|
|
96
|
-
*/
|
|
97
|
-
async waitForGenesis(): Promise<GenesisResult> {
|
|
98
|
-
await this.eth1Provider.validateContract();
|
|
99
|
-
|
|
100
|
-
// Load data from data from this.db.depositData, this.db.depositDataRoot
|
|
101
|
-
// And start from a more recent fromBlock
|
|
102
|
-
const blockNumberValidatorGenesis = await this.waitForGenesisValidators();
|
|
103
|
-
|
|
104
|
-
const depositsAndBlocksStream = getDepositsAndBlockStreamForGenesis(
|
|
105
|
-
blockNumberValidatorGenesis,
|
|
106
|
-
this.eth1Provider,
|
|
107
|
-
this.eth1Params,
|
|
108
|
-
this.signal
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
for await (const [depositEvents, block] of depositsAndBlocksStream) {
|
|
112
|
-
this.applyDeposits(depositEvents);
|
|
113
|
-
applyTimestamp(this.config, this.state, block.timestamp);
|
|
114
|
-
applyEth1BlockHash(this.state, block.blockHash);
|
|
115
|
-
this.lastProcessedBlockNumber = block.blockNumber;
|
|
116
|
-
|
|
117
|
-
if (
|
|
118
|
-
this.state.genesisTime >= this.config.MIN_GENESIS_TIME &&
|
|
119
|
-
this.activatedValidatorCount >= this.config.MIN_GENESIS_ACTIVE_VALIDATOR_COUNT
|
|
120
|
-
) {
|
|
121
|
-
this.logger.info("Found genesis state", {blockNumber: block.blockNumber});
|
|
122
|
-
return {
|
|
123
|
-
state: this.state,
|
|
124
|
-
depositTree: this.depositTree,
|
|
125
|
-
block,
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
this.throttledLog(`Waiting for min genesis time ${block.timestamp} / ${this.config.MIN_GENESIS_TIME}`);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
throw Error("depositsStream stopped without a valid genesis state");
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* First phase of waiting for genesis.
|
|
137
|
-
* Stream deposits events in batches as big as possible without querying block data
|
|
138
|
-
* @returns Block number at which there are enough active validators is state for genesis
|
|
139
|
-
*/
|
|
140
|
-
private async waitForGenesisValidators(): Promise<number> {
|
|
141
|
-
const depositsStream = getDepositsStream(this.fromBlock, this.eth1Provider, this.eth1Params, this.signal);
|
|
142
|
-
|
|
143
|
-
for await (const {depositEvents, blockNumber} of depositsStream) {
|
|
144
|
-
this.applyDeposits(depositEvents);
|
|
145
|
-
this.lastProcessedBlockNumber = blockNumber;
|
|
146
|
-
|
|
147
|
-
if (this.activatedValidatorCount >= this.config.MIN_GENESIS_ACTIVE_VALIDATOR_COUNT) {
|
|
148
|
-
this.logger.info("Found enough genesis validators", {blockNumber});
|
|
149
|
-
return blockNumber;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
this.throttledLog(
|
|
153
|
-
`Found ${this.state.validators.length} / ${this.config.MIN_GENESIS_ACTIVE_VALIDATOR_COUNT} validators to genesis`
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
throw Error("depositsStream stopped without a valid genesis state");
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
private applyDeposits(depositEvents: phase0.DepositEvent[]): void {
|
|
161
|
-
const newDeposits = depositEvents
|
|
162
|
-
.filter((depositEvent) => !this.depositCache.has(depositEvent.index))
|
|
163
|
-
.map((depositEvent) => {
|
|
164
|
-
this.depositCache.add(depositEvent.index);
|
|
165
|
-
this.depositTree.push(ssz.phase0.DepositData.hashTreeRoot(depositEvent.depositData));
|
|
166
|
-
const gindex = toGindex(this.depositTree.type.depth, BigInt(depositEvent.index));
|
|
167
|
-
|
|
168
|
-
// Apply changes from the push above
|
|
169
|
-
this.depositTree.commit();
|
|
170
|
-
const depositTreeNode = this.depositTree.node;
|
|
171
|
-
return {
|
|
172
|
-
proof: new Tree(depositTreeNode).getSingleProof(gindex),
|
|
173
|
-
data: depositEvent.depositData,
|
|
174
|
-
};
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
const {activatedValidatorCount} = applyDeposits(this.config, this.state, newDeposits, this.depositTree);
|
|
178
|
-
this.activatedValidatorCount += activatedValidatorCount;
|
|
179
|
-
|
|
180
|
-
// TODO: If necessary persist deposits here to this.db.depositData, this.db.depositDataRoot
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/** Throttle genesis generation status log to prevent spamming */
|
|
184
|
-
private throttledLog(message: string): void {
|
|
185
|
-
if (Date.now() - this.lastLog > this.logEvery) {
|
|
186
|
-
this.lastLog = Date.now();
|
|
187
|
-
this.logger.info(message);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {CompositeViewDU, VectorCompositeType} from "@chainsafe/ssz";
|
|
2
|
-
import {CachedBeaconStateAllForks} from "@lodestar/state-transition";
|
|
3
|
-
import {ssz} from "@lodestar/types";
|
|
4
|
-
import {Eth1Block} from "../../eth1/interface.js";
|
|
5
|
-
|
|
6
|
-
export type GenesisResult = {
|
|
7
|
-
state: CachedBeaconStateAllForks;
|
|
8
|
-
depositTree: CompositeViewDU<VectorCompositeType<typeof ssz.Root>>;
|
|
9
|
-
block: Eth1Block;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export interface IGenesisBuilder {
|
|
13
|
-
waitForGenesis: () => Promise<GenesisResult>;
|
|
14
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import {ByteVectorType, CompositeViewDU, ListCompositeType} from "@chainsafe/ssz";
|
|
2
|
-
import {ChainForkConfig} from "@lodestar/config";
|
|
3
|
-
import {Db, KeyValue, Repository} from "@lodestar/db";
|
|
4
|
-
import {Root, ssz} from "@lodestar/types";
|
|
5
|
-
import {bytesToInt} from "@lodestar/utils";
|
|
6
|
-
import {Bucket, getBucketNameByValue} from "../buckets.js";
|
|
7
|
-
|
|
8
|
-
// TODO: Review where is best to put this type
|
|
9
|
-
export type DepositTree = CompositeViewDU<ListCompositeType<ByteVectorType>>;
|
|
10
|
-
|
|
11
|
-
export class DepositDataRootRepository extends Repository<number, Root> {
|
|
12
|
-
private depositRootTree?: DepositTree;
|
|
13
|
-
|
|
14
|
-
constructor(config: ChainForkConfig, db: Db) {
|
|
15
|
-
const bucket = Bucket.index_depositDataRoot;
|
|
16
|
-
super(config, db, bucket, ssz.Root, getBucketNameByValue(bucket));
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
decodeKey(data: Buffer): number {
|
|
20
|
-
return bytesToInt(super.decodeKey(data) as unknown as Uint8Array, "be");
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// depositDataRoots stored by depositData index
|
|
24
|
-
getId(_value: Root): number {
|
|
25
|
-
throw new Error("Unable to create depositIndex from root");
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async put(index: number, value: Root): Promise<void> {
|
|
29
|
-
await super.put(index, value);
|
|
30
|
-
await this.depositRootTreeSet(index, value);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async batchPut(items: KeyValue<number, Root>[]): Promise<void> {
|
|
34
|
-
await super.batchPut(items);
|
|
35
|
-
for (const {key, value} of items) {
|
|
36
|
-
await this.depositRootTreeSet(key, value);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async putList(roots: Root[]): Promise<void> {
|
|
41
|
-
await this.batchPut(roots.map((root, index) => ({key: index, value: root})));
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async batchPutValues(values: {index: number; root: Root}[]): Promise<void> {
|
|
45
|
-
await this.batchPut(
|
|
46
|
-
values.map(({index, root}) => ({
|
|
47
|
-
key: index,
|
|
48
|
-
value: root,
|
|
49
|
-
}))
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async getDepositRootTree(): Promise<DepositTree> {
|
|
54
|
-
if (!this.depositRootTree) {
|
|
55
|
-
const values = await this.values();
|
|
56
|
-
this.depositRootTree = ssz.phase0.DepositDataRootList.toViewDU(values);
|
|
57
|
-
}
|
|
58
|
-
return this.depositRootTree;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async getDepositRootTreeAtIndex(depositIndex: number): Promise<DepositTree> {
|
|
62
|
-
const depositRootTree = await this.getDepositRootTree();
|
|
63
|
-
return depositRootTree.sliceTo(depositIndex);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
private async depositRootTreeSet(index: number, value: Uint8Array): Promise<void> {
|
|
67
|
-
const depositRootTree = await this.getDepositRootTree();
|
|
68
|
-
|
|
69
|
-
// TODO: Review and fix properly
|
|
70
|
-
if (index > depositRootTree.length) {
|
|
71
|
-
throw Error(`Error setting depositRootTree index ${index} > length ${depositRootTree.length}`);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (index === depositRootTree.length) {
|
|
75
|
-
depositRootTree.push(value);
|
|
76
|
-
} else {
|
|
77
|
-
depositRootTree.set(index, value);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import {ChainForkConfig} from "@lodestar/config";
|
|
2
|
-
import {Db, Repository} from "@lodestar/db";
|
|
3
|
-
import {phase0, ssz} from "@lodestar/types";
|
|
4
|
-
import {Bucket, getBucketNameByValue} from "../buckets.js";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* DepositData indexed by deposit index
|
|
8
|
-
* Removed when included on chain or old
|
|
9
|
-
*/
|
|
10
|
-
export class DepositEventRepository extends Repository<number, phase0.DepositEvent> {
|
|
11
|
-
constructor(config: ChainForkConfig, db: Db) {
|
|
12
|
-
const bucket = Bucket.phase0_depositEvent;
|
|
13
|
-
super(config, db, bucket, ssz.phase0.DepositEvent, getBucketNameByValue(bucket));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async deleteOld(depositCount: number): Promise<void> {
|
|
17
|
-
const firstDepositIndex = await this.firstKey();
|
|
18
|
-
if (firstDepositIndex === null) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
await this.batchDelete(Array.from({length: depositCount - firstDepositIndex}, (_, i) => i + firstDepositIndex));
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async batchPutValues(depositEvents: phase0.DepositEvent[]): Promise<void> {
|
|
25
|
-
await this.batchPut(
|
|
26
|
-
depositEvents.map((depositEvent) => ({
|
|
27
|
-
key: depositEvent.index,
|
|
28
|
-
value: depositEvent,
|
|
29
|
-
}))
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import {ChainForkConfig} from "@lodestar/config";
|
|
2
|
-
import {Db, Repository} from "@lodestar/db";
|
|
3
|
-
import {phase0, ssz} from "@lodestar/types";
|
|
4
|
-
import {bytesToInt} from "@lodestar/utils";
|
|
5
|
-
import {Bucket, getBucketNameByValue} from "../buckets.js";
|
|
6
|
-
|
|
7
|
-
export class Eth1DataRepository extends Repository<number, phase0.Eth1DataOrdered> {
|
|
8
|
-
constructor(config: ChainForkConfig, db: Db) {
|
|
9
|
-
const bucket = Bucket.phase0_eth1Data;
|
|
10
|
-
super(config, db, bucket, ssz.phase0.Eth1DataOrdered, getBucketNameByValue(bucket));
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
decodeKey(data: Buffer): number {
|
|
14
|
-
return bytesToInt(super.decodeKey(data) as unknown as Uint8Array, "be");
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
getId(_value: phase0.Eth1Data): number {
|
|
18
|
-
throw new Error("Unable to create timestamp from block hash");
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async batchPutValues(eth1Datas: (phase0.Eth1DataOrdered & {timestamp: number})[]): Promise<void> {
|
|
22
|
-
await this.batchPut(
|
|
23
|
-
eth1Datas.map((eth1Data) => ({
|
|
24
|
-
key: eth1Data.timestamp,
|
|
25
|
-
value: eth1Data,
|
|
26
|
-
}))
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async deleteOld(timestamp: number): Promise<void> {
|
|
31
|
-
await this.batchDelete(await this.keys({lt: timestamp}));
|
|
32
|
-
}
|
|
33
|
-
}
|
package/src/db/single/index.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import {ChainForkConfig} from "@lodestar/config";
|
|
2
|
-
import {Db, DbReqOpts} from "@lodestar/db";
|
|
3
|
-
import {ForkAll, GENESIS_SLOT} from "@lodestar/params";
|
|
4
|
-
import {BeaconStateAllForks} from "@lodestar/state-transition";
|
|
5
|
-
import {SSZTypesFor} from "@lodestar/types";
|
|
6
|
-
import {Bucket, getBucketNameByValue} from "../buckets.js";
|
|
7
|
-
|
|
8
|
-
export class PreGenesisState {
|
|
9
|
-
private readonly config: ChainForkConfig;
|
|
10
|
-
private readonly bucket: Bucket;
|
|
11
|
-
private readonly db: Db;
|
|
12
|
-
private readonly key: Uint8Array;
|
|
13
|
-
private readonly type: SSZTypesFor<ForkAll, "BeaconState">;
|
|
14
|
-
private readonly dbReqOpts: DbReqOpts;
|
|
15
|
-
|
|
16
|
-
constructor(config: ChainForkConfig, db: Db) {
|
|
17
|
-
this.config = config;
|
|
18
|
-
this.db = db;
|
|
19
|
-
this.bucket = Bucket.phase0_preGenesisState;
|
|
20
|
-
this.key = new Uint8Array([this.bucket]);
|
|
21
|
-
this.type = this.config.getForkTypes(GENESIS_SLOT).BeaconState;
|
|
22
|
-
this.dbReqOpts = {bucketId: getBucketNameByValue(this.bucket)};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async put(value: BeaconStateAllForks): Promise<void> {
|
|
26
|
-
await this.db.put(this.key, value.serialize(), this.dbReqOpts);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async get(): Promise<BeaconStateAllForks | null> {
|
|
30
|
-
const value = await this.db.get(this.key, this.dbReqOpts);
|
|
31
|
-
return value ? this.type.deserializeToViewDU(value) : null;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async delete(): Promise<void> {
|
|
35
|
-
await this.db.delete(this.key, this.dbReqOpts);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import {UintNumberType} from "@chainsafe/ssz";
|
|
2
|
-
import {ChainForkConfig} from "@lodestar/config";
|
|
3
|
-
import {Db, DbReqOpts} from "@lodestar/db";
|
|
4
|
-
import {ssz} from "@lodestar/types";
|
|
5
|
-
import {Bucket, getBucketNameByValue} from "../buckets.js";
|
|
6
|
-
|
|
7
|
-
export class PreGenesisStateLastProcessedBlock {
|
|
8
|
-
private readonly bucket: Bucket;
|
|
9
|
-
private readonly type: UintNumberType;
|
|
10
|
-
private readonly db: Db;
|
|
11
|
-
private readonly key: Uint8Array;
|
|
12
|
-
private readonly dbReqOpts: DbReqOpts;
|
|
13
|
-
|
|
14
|
-
constructor(_config: ChainForkConfig, db: Db) {
|
|
15
|
-
this.db = db;
|
|
16
|
-
this.type = ssz.UintNum64;
|
|
17
|
-
this.bucket = Bucket.phase0_preGenesisStateLastProcessedBlock;
|
|
18
|
-
this.key = new Uint8Array([this.bucket]);
|
|
19
|
-
this.dbReqOpts = {bucketId: getBucketNameByValue(this.bucket)};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async put(value: number): Promise<void> {
|
|
23
|
-
await this.db.put(this.key, this.type.serialize(value), this.dbReqOpts);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async get(): Promise<number | null> {
|
|
27
|
-
const value = await this.db.get(this.key, this.dbReqOpts);
|
|
28
|
-
return value ? this.type.deserialize(value) : null;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async delete(): Promise<void> {
|
|
32
|
-
await this.db.delete(this.key, this.dbReqOpts);
|
|
33
|
-
}
|
|
34
|
-
}
|
package/src/eth1/errors.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import {LodestarError} from "@lodestar/utils";
|
|
2
|
-
|
|
3
|
-
export enum Eth1ErrorCode {
|
|
4
|
-
/** Deposit index too high */
|
|
5
|
-
DEPOSIT_INDEX_TOO_HIGH = "ETH1_ERROR_DEPOSIT_INDEX_TOO_HIGH",
|
|
6
|
-
/** Not enough deposits in DB */
|
|
7
|
-
NOT_ENOUGH_DEPOSITS = "ETH1_ERROR_NOT_ENOUGH_DEPOSITS",
|
|
8
|
-
/** Too many deposits returned by DB */
|
|
9
|
-
TOO_MANY_DEPOSITS = "ETH1_ERROR_TOO_MANY_DEPOSITS",
|
|
10
|
-
/** Deposit root tree does not match current eth1Data */
|
|
11
|
-
WRONG_DEPOSIT_ROOT = "ETH1_ERROR_WRONG_DEPOSIT_ROOT",
|
|
12
|
-
|
|
13
|
-
/** No deposits found for block range */
|
|
14
|
-
NO_DEPOSITS_FOR_BLOCK_RANGE = "ETH1_ERROR_NO_DEPOSITS_FOR_BLOCK_RANGE",
|
|
15
|
-
/** No depositRoot for depositCount */
|
|
16
|
-
NO_DEPOSIT_ROOT = "ETH1_ERROR_NO_DEPOSIT_ROOT",
|
|
17
|
-
/** Not enough deposit roots for index */
|
|
18
|
-
NOT_ENOUGH_DEPOSIT_ROOTS = "ETH1_ERROR_NOT_ENOUGH_DEPOSIT_ROOTS",
|
|
19
|
-
|
|
20
|
-
/** Attempted to insert a duplicate log for same index into the Eth1DepositsCache */
|
|
21
|
-
DUPLICATE_DISTINCT_LOG = "ETH1_ERROR_DUPLICATE_DISTINCT_LOG",
|
|
22
|
-
/** Attempted to insert a log with index != prev + 1 into the Eth1DepositsCache */
|
|
23
|
-
NON_CONSECUTIVE_LOGS = "ETH1_ERROR_NON_CONSECUTIVE_LOGS",
|
|
24
|
-
/** Expected a deposit log in the db for the index, missing log implies a corrupted db */
|
|
25
|
-
MISSING_DEPOSIT_LOG = "ETH1_ERROR_MISSING_DEPOSIT_LOG",
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export type Eth1ErrorType =
|
|
29
|
-
| {code: Eth1ErrorCode.DEPOSIT_INDEX_TOO_HIGH; depositIndex: number; depositCount: number}
|
|
30
|
-
| {code: Eth1ErrorCode.NOT_ENOUGH_DEPOSITS; len: number; expectedLen: number}
|
|
31
|
-
| {code: Eth1ErrorCode.TOO_MANY_DEPOSITS; len: number; expectedLen: number}
|
|
32
|
-
| {code: Eth1ErrorCode.WRONG_DEPOSIT_ROOT; root: string; expectedRoot: string}
|
|
33
|
-
| {code: Eth1ErrorCode.NO_DEPOSITS_FOR_BLOCK_RANGE; fromBlock: number; toBlock: number}
|
|
34
|
-
| {code: Eth1ErrorCode.NO_DEPOSIT_ROOT; depositCount: number}
|
|
35
|
-
| {code: Eth1ErrorCode.NOT_ENOUGH_DEPOSIT_ROOTS; index: number; treeLength: number}
|
|
36
|
-
| {code: Eth1ErrorCode.DUPLICATE_DISTINCT_LOG; newIndex: number; lastLogIndex: number}
|
|
37
|
-
| {code: Eth1ErrorCode.NON_CONSECUTIVE_LOGS; newIndex: number; lastLogIndex: number}
|
|
38
|
-
| {code: Eth1ErrorCode.MISSING_DEPOSIT_LOG; newIndex: number; lastLogIndex: number};
|
|
39
|
-
|
|
40
|
-
export class Eth1Error extends LodestarError<Eth1ErrorType> {}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import {ChainForkConfig} from "@lodestar/config";
|
|
2
|
-
import {phase0} from "@lodestar/types";
|
|
3
|
-
import {IBeaconDb} from "../db/index.js";
|
|
4
|
-
|
|
5
|
-
export class Eth1DataCache {
|
|
6
|
-
db: IBeaconDb;
|
|
7
|
-
config: ChainForkConfig;
|
|
8
|
-
|
|
9
|
-
constructor(config: ChainForkConfig, db: IBeaconDb) {
|
|
10
|
-
this.config = config;
|
|
11
|
-
this.db = db;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
async get({timestampRange}: {timestampRange: {gte: number; lte: number}}): Promise<phase0.Eth1DataOrdered[]> {
|
|
15
|
-
return this.db.eth1Data.values(timestampRange);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async add(eth1Datas: (phase0.Eth1DataOrdered & {timestamp: number})[]): Promise<void> {
|
|
19
|
-
await this.db.eth1Data.batchPutValues(eth1Datas);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async getHighestCachedBlockNumber(): Promise<number | null> {
|
|
23
|
-
const highestEth1Data = await this.db.eth1Data.lastValue();
|
|
24
|
-
return highestEth1Data?.blockNumber ?? null;
|
|
25
|
-
}
|
|
26
|
-
}
|