@lodestar/beacon-node 1.39.0-dev.3bf4734ba9 → 1.39.0-dev.46c9c672fd
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/chain/blocks/verifyBlock.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlock.js +1 -1
- 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/chain.d.ts +8 -12
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +23 -47
- 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 +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 +4 -9
- 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/prepareNextSlot.d.ts +0 -4
- package/lib/chain/prepareNextSlot.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +1 -21
- 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 +9 -12
- package/lib/chain/produceBlock/produceBlockBody.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/aggregateAndProof.js +9 -0
- package/lib/chain/validation/aggregateAndProof.js.map +1 -1
- package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
- package/lib/chain/validation/attesterSlashing.js +1 -1
- 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 +3 -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 +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 +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/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 +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.map +1 -1
- package/lib/execution/engine/mock.js +1 -1
- 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 -35
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +0 -90
- 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/node/nodejs.d.ts +6 -3
- package/lib/node/nodejs.d.ts.map +1 -1
- package/lib/node/nodejs.js +13 -10
- 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/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/chain/blocks/verifyBlock.ts +1 -0
- package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +9 -2
- package/src/chain/blocks/verifyBlocksSignatures.ts +13 -3
- package/src/chain/chain.ts +33 -56
- package/src/chain/forkChoice/index.ts +3 -2
- package/src/chain/initState.ts +1 -97
- package/src/chain/interface.ts +4 -8
- package/src/chain/opPools/aggregatedAttestationPool.ts +7 -7
- package/src/chain/opPools/opPool.ts +8 -8
- package/src/chain/prepareNextSlot.ts +1 -28
- package/src/chain/produceBlock/produceBlockBody.ts +9 -13
- package/src/chain/stateCache/persistentCheckpointsCache.ts +15 -2
- package/src/chain/validation/aggregateAndProof.ts +12 -0
- package/src/chain/validation/attesterSlashing.ts +6 -1
- package/src/chain/validation/blobSidecar.ts +3 -3
- package/src/chain/validation/block.ts +3 -2
- package/src/chain/validation/blsToExecutionChange.ts +10 -8
- package/src/chain/validation/dataColumnSidecar.ts +3 -3
- package/src/chain/validation/proposerSlashing.ts +6 -1
- 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/index.ts +0 -3
- 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 +1 -2
- 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 -92
- 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/node/nodejs.ts +20 -11
- 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/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,150 +0,0 @@
|
|
|
1
|
-
import {routes} from "@lodestar/api";
|
|
2
|
-
import {
|
|
3
|
-
ForkName,
|
|
4
|
-
WHISTLEBLOWER_REWARD_QUOTIENT,
|
|
5
|
-
WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA,
|
|
6
|
-
isForkPostElectra,
|
|
7
|
-
} from "@lodestar/params";
|
|
8
|
-
import {
|
|
9
|
-
CachedBeaconStateAllForks,
|
|
10
|
-
CachedBeaconStateAltair,
|
|
11
|
-
CachedBeaconStatePhase0,
|
|
12
|
-
getAttesterSlashableIndices,
|
|
13
|
-
processAttestationsAltair,
|
|
14
|
-
} from "@lodestar/state-transition";
|
|
15
|
-
import {BeaconBlock, altair, phase0} from "@lodestar/types";
|
|
16
|
-
|
|
17
|
-
export type BlockRewards = routes.beacon.BlockRewards;
|
|
18
|
-
type SubRewardValue = number; // All reward values should be integer
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Calculate total proposer block rewards given block and the beacon state of the same slot before the block is applied (preState)
|
|
22
|
-
* postState can be passed in to read reward cache if available
|
|
23
|
-
* Standard (Non MEV) rewards for proposing a block consists of:
|
|
24
|
-
* 1) Including attestations from (beacon) committee
|
|
25
|
-
* 2) Including attestations from sync committee
|
|
26
|
-
* 3) Reporting slashable behaviours from proposer and attester
|
|
27
|
-
*/
|
|
28
|
-
export async function computeBlockRewards(
|
|
29
|
-
block: BeaconBlock,
|
|
30
|
-
preState: CachedBeaconStateAllForks,
|
|
31
|
-
postState?: CachedBeaconStateAllForks
|
|
32
|
-
): Promise<BlockRewards> {
|
|
33
|
-
const fork = preState.config.getForkName(block.slot);
|
|
34
|
-
const {attestations: cachedAttestationsReward = 0, syncAggregate: cachedSyncAggregateReward = 0} =
|
|
35
|
-
postState?.proposerRewards ?? {};
|
|
36
|
-
let blockAttestationReward = cachedAttestationsReward;
|
|
37
|
-
let syncAggregateReward = cachedSyncAggregateReward;
|
|
38
|
-
|
|
39
|
-
if (blockAttestationReward === 0) {
|
|
40
|
-
blockAttestationReward =
|
|
41
|
-
fork === ForkName.phase0
|
|
42
|
-
? computeBlockAttestationRewardPhase0(block as phase0.BeaconBlock, preState as CachedBeaconStatePhase0)
|
|
43
|
-
: computeBlockAttestationRewardAltair(block as altair.BeaconBlock, preState as CachedBeaconStateAltair);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (syncAggregateReward === 0) {
|
|
47
|
-
syncAggregateReward = computeSyncAggregateReward(block as altair.BeaconBlock, preState as CachedBeaconStateAltair);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const blockProposerSlashingReward = computeBlockProposerSlashingReward(fork, block, preState);
|
|
51
|
-
const blockAttesterSlashingReward = computeBlockAttesterSlashingReward(fork, block, preState);
|
|
52
|
-
|
|
53
|
-
const total =
|
|
54
|
-
blockAttestationReward + syncAggregateReward + blockProposerSlashingReward + blockAttesterSlashingReward;
|
|
55
|
-
|
|
56
|
-
return {
|
|
57
|
-
proposerIndex: block.proposerIndex,
|
|
58
|
-
total,
|
|
59
|
-
attestations: blockAttestationReward,
|
|
60
|
-
syncAggregate: syncAggregateReward,
|
|
61
|
-
proposerSlashings: blockProposerSlashingReward,
|
|
62
|
-
attesterSlashings: blockAttesterSlashingReward,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* TODO: Calculate rewards received by block proposer for including attestations.
|
|
68
|
-
*/
|
|
69
|
-
function computeBlockAttestationRewardPhase0(
|
|
70
|
-
_block: phase0.BeaconBlock,
|
|
71
|
-
_preState: CachedBeaconStatePhase0
|
|
72
|
-
): SubRewardValue {
|
|
73
|
-
throw new Error("Unsupported fork! Block attestation reward calculation is not available in phase0");
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Calculate rewards received by block proposer for including attestations since Altair.
|
|
78
|
-
* Reuses `processAttestationsAltair()`. Has dependency on RewardCache
|
|
79
|
-
*/
|
|
80
|
-
function computeBlockAttestationRewardAltair(
|
|
81
|
-
block: altair.BeaconBlock,
|
|
82
|
-
preState: CachedBeaconStateAltair
|
|
83
|
-
): SubRewardValue {
|
|
84
|
-
const fork = preState.config.getForkSeq(block.slot);
|
|
85
|
-
const {attestations} = block.body;
|
|
86
|
-
|
|
87
|
-
processAttestationsAltair(fork, preState, attestations, false);
|
|
88
|
-
|
|
89
|
-
return preState.proposerRewards.attestations;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function computeSyncAggregateReward(block: altair.BeaconBlock, preState: CachedBeaconStateAltair): SubRewardValue {
|
|
93
|
-
if (block.body.syncAggregate !== undefined) {
|
|
94
|
-
const {syncCommitteeBits} = block.body.syncAggregate;
|
|
95
|
-
const {syncProposerReward} = preState.epochCtx;
|
|
96
|
-
|
|
97
|
-
return syncCommitteeBits.getTrueBitIndexes().length * Math.floor(syncProposerReward); // syncProposerReward should already be integer
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return 0; // phase0 block does not have syncAggregate
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Calculate rewards received by block proposer for including proposer slashings.
|
|
105
|
-
* All proposer slashing rewards go to block proposer and none to whistleblower as of Deneb
|
|
106
|
-
*/
|
|
107
|
-
function computeBlockProposerSlashingReward(
|
|
108
|
-
fork: ForkName,
|
|
109
|
-
block: BeaconBlock,
|
|
110
|
-
state: CachedBeaconStateAllForks
|
|
111
|
-
): SubRewardValue {
|
|
112
|
-
let proposerSlashingReward = 0;
|
|
113
|
-
|
|
114
|
-
for (const proposerSlashing of block.body.proposerSlashings) {
|
|
115
|
-
const offendingProposerIndex = proposerSlashing.signedHeader1.message.proposerIndex;
|
|
116
|
-
const offendingProposerBalance = state.validators.getReadonly(offendingProposerIndex).effectiveBalance;
|
|
117
|
-
const whistleblowerRewardQuotient = isForkPostElectra(fork)
|
|
118
|
-
? WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA
|
|
119
|
-
: WHISTLEBLOWER_REWARD_QUOTIENT;
|
|
120
|
-
|
|
121
|
-
proposerSlashingReward += Math.floor(offendingProposerBalance / whistleblowerRewardQuotient);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return proposerSlashingReward;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Calculate rewards received by block proposer for including attester slashings.
|
|
129
|
-
* All attester slashing rewards go to block proposer and none to whistleblower as of Deneb
|
|
130
|
-
*/
|
|
131
|
-
function computeBlockAttesterSlashingReward(
|
|
132
|
-
fork: ForkName,
|
|
133
|
-
block: BeaconBlock,
|
|
134
|
-
preState: CachedBeaconStateAllForks
|
|
135
|
-
): SubRewardValue {
|
|
136
|
-
let attesterSlashingReward = 0;
|
|
137
|
-
|
|
138
|
-
for (const attesterSlashing of block.body.attesterSlashings) {
|
|
139
|
-
for (const offendingAttesterIndex of getAttesterSlashableIndices(attesterSlashing)) {
|
|
140
|
-
const offendingAttesterBalance = preState.validators.getReadonly(offendingAttesterIndex).effectiveBalance;
|
|
141
|
-
const whistleblowerRewardQuotient = isForkPostElectra(fork)
|
|
142
|
-
? WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA
|
|
143
|
-
: WHISTLEBLOWER_REWARD_QUOTIENT;
|
|
144
|
-
|
|
145
|
-
attesterSlashingReward += Math.floor(offendingAttesterBalance / whistleblowerRewardQuotient);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return attesterSlashingReward;
|
|
150
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import {routes} from "@lodestar/api";
|
|
2
|
-
import {ForkName, SYNC_COMMITTEE_SIZE} from "@lodestar/params";
|
|
3
|
-
import {CachedBeaconStateAllForks, CachedBeaconStateAltair, Index2PubkeyCache} from "@lodestar/state-transition";
|
|
4
|
-
import {BeaconBlock, ValidatorIndex, altair} from "@lodestar/types";
|
|
5
|
-
|
|
6
|
-
export type SyncCommitteeRewards = routes.beacon.SyncCommitteeRewards;
|
|
7
|
-
type BalanceRecord = {val: number}; // Use val for convenient way to increment/decrement balance
|
|
8
|
-
|
|
9
|
-
export async function computeSyncCommitteeRewards(
|
|
10
|
-
index2pubkey: Index2PubkeyCache,
|
|
11
|
-
block: BeaconBlock,
|
|
12
|
-
preState: CachedBeaconStateAllForks,
|
|
13
|
-
validatorIds: (ValidatorIndex | string)[] = []
|
|
14
|
-
): Promise<SyncCommitteeRewards> {
|
|
15
|
-
const fork = preState.config.getForkName(block.slot);
|
|
16
|
-
if (fork === ForkName.phase0) {
|
|
17
|
-
throw Error("Cannot get sync rewards as phase0 block does not have sync committee");
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const altairBlock = block as altair.BeaconBlock;
|
|
21
|
-
const preStateAltair = preState as CachedBeaconStateAltair;
|
|
22
|
-
|
|
23
|
-
// Bound syncCommitteeValidatorIndices in case it goes beyond SYNC_COMMITTEE_SIZE just to be safe
|
|
24
|
-
const syncCommitteeValidatorIndices = preStateAltair.epochCtx.currentSyncCommitteeIndexed.validatorIndices.slice(
|
|
25
|
-
0,
|
|
26
|
-
SYNC_COMMITTEE_SIZE
|
|
27
|
-
);
|
|
28
|
-
const {syncParticipantReward} = preStateAltair.epochCtx;
|
|
29
|
-
const {syncCommitteeBits} = altairBlock.body.syncAggregate;
|
|
30
|
-
|
|
31
|
-
// Use balance of each committee as starting point such that we cap the penalty to avoid balance dropping below 0
|
|
32
|
-
const balances: Map<ValidatorIndex, BalanceRecord> = new Map();
|
|
33
|
-
for (const i of syncCommitteeValidatorIndices) {
|
|
34
|
-
balances.set(i, {val: preStateAltair.balances.get(i)});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
for (const i of syncCommitteeValidatorIndices) {
|
|
38
|
-
const balanceRecord = balances.get(i) as BalanceRecord;
|
|
39
|
-
if (syncCommitteeBits.get(i)) {
|
|
40
|
-
// Positive rewards for participants
|
|
41
|
-
balanceRecord.val += syncParticipantReward;
|
|
42
|
-
} else {
|
|
43
|
-
// Negative rewards for non participants
|
|
44
|
-
balanceRecord.val = Math.max(0, balanceRecord.val - syncParticipantReward);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const rewards = Array.from(balances, ([validatorIndex, v]) => ({validatorIndex, reward: v.val}));
|
|
49
|
-
|
|
50
|
-
if (validatorIds.length) {
|
|
51
|
-
const filtersSet = new Set(validatorIds);
|
|
52
|
-
return rewards.filter(
|
|
53
|
-
(reward) => filtersSet.has(reward.validatorIndex) || filtersSet.has(index2pubkey[reward.validatorIndex].toHex())
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return rewards;
|
|
58
|
-
}
|
|
@@ -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
|
-
}
|