@lodestar/beacon-node 1.38.0 → 1.39.0-dev.100ab480bb
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 +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 +25 -59
- 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 +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/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/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 +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 +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 +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 +15 -4
- package/src/chain/chain.ts +35 -69
- 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/options.ts +0 -6
- package/src/chain/prepareNextSlot.ts +2 -29
- package/src/chain/produceBlock/produceBlockBody.ts +33 -132
- package/src/chain/stateCache/persistentCheckpointsCache.ts +15 -2
- package/src/chain/validation/aggregateAndProof.ts +12 -0
- package/src/chain/validation/attesterSlashing.ts +7 -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 +6 -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 +20 -11
- 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 +9 -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/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 -37
- 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/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/chain/rewards/attestationsRewards.ts +0 -196
- 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/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,328 +0,0 @@
|
|
|
1
|
-
import {ChainConfig} from "@lodestar/config";
|
|
2
|
-
import {RootHex} from "@lodestar/types";
|
|
3
|
-
import {Logger, pruneSetToMax, toRootHex} from "@lodestar/utils";
|
|
4
|
-
import {ZERO_HASH_HEX} from "../constants/index.js";
|
|
5
|
-
import {Metrics} from "../metrics/index.js";
|
|
6
|
-
import {enumToIndexMap} from "../util/enum.js";
|
|
7
|
-
import {EthJsonRpcBlockRaw, IEth1Provider, PowMergeBlock, PowMergeBlockTimestamp, TDProgress} from "./interface.js";
|
|
8
|
-
import {dataToRootHex, quantityToBigint, quantityToNum} from "./provider/utils.js";
|
|
9
|
-
|
|
10
|
-
export enum StatusCode {
|
|
11
|
-
STOPPED = "STOPPED",
|
|
12
|
-
SEARCHING = "SEARCHING",
|
|
13
|
-
FOUND = "FOUND",
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
type Status =
|
|
17
|
-
| {code: StatusCode.STOPPED}
|
|
18
|
-
| {code: StatusCode.SEARCHING}
|
|
19
|
-
| {code: StatusCode.FOUND; mergeBlock: PowMergeBlock};
|
|
20
|
-
|
|
21
|
-
/** For metrics, index order = declaration order of StatusCode */
|
|
22
|
-
const statusCodeIdx = enumToIndexMap(StatusCode);
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Bounds `blocksByHashCache` cache, imposing a max distance between highest and lowest block numbers.
|
|
26
|
-
* In case of extreme forking the cache might grow unbounded.
|
|
27
|
-
*/
|
|
28
|
-
const MAX_CACHE_POW_BLOCKS = 1024;
|
|
29
|
-
|
|
30
|
-
const MAX_TD_RENDER_VALUE = Number.MAX_SAFE_INTEGER;
|
|
31
|
-
|
|
32
|
-
export type Eth1MergeBlockTrackerModules = {
|
|
33
|
-
config: ChainConfig;
|
|
34
|
-
logger: Logger;
|
|
35
|
-
signal: AbortSignal;
|
|
36
|
-
metrics: Metrics | null;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// get_pow_block_at_total_difficulty
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Follows the eth1 chain to find a (or multiple?) merge blocks that cross the threshold of total terminal difficulty
|
|
43
|
-
*
|
|
44
|
-
* Finding the mergeBlock could be done in demand when proposing pre-merge blocks. However, that would slow block
|
|
45
|
-
* production during the weeks between BELLATRIX_EPOCH and TTD.
|
|
46
|
-
*/
|
|
47
|
-
export class Eth1MergeBlockTracker {
|
|
48
|
-
private readonly config: ChainConfig;
|
|
49
|
-
private readonly logger: Logger;
|
|
50
|
-
private readonly metrics: Metrics | null;
|
|
51
|
-
|
|
52
|
-
private readonly blocksByHashCache = new Map<RootHex, PowMergeBlock>();
|
|
53
|
-
private readonly intervals: NodeJS.Timeout[] = [];
|
|
54
|
-
|
|
55
|
-
private status: Status;
|
|
56
|
-
private latestEth1Block: PowMergeBlockTimestamp | null = null;
|
|
57
|
-
private getTerminalPowBlockFromEth1Promise: Promise<PowMergeBlock | null> | null = null;
|
|
58
|
-
private readonly safeTDFactor: bigint;
|
|
59
|
-
|
|
60
|
-
constructor(
|
|
61
|
-
{config, logger, signal, metrics}: Eth1MergeBlockTrackerModules,
|
|
62
|
-
private readonly eth1Provider: IEth1Provider
|
|
63
|
-
) {
|
|
64
|
-
this.config = config;
|
|
65
|
-
this.logger = logger;
|
|
66
|
-
this.metrics = metrics;
|
|
67
|
-
|
|
68
|
-
this.status = {code: StatusCode.STOPPED};
|
|
69
|
-
|
|
70
|
-
signal.addEventListener("abort", () => this.close(), {once: true});
|
|
71
|
-
|
|
72
|
-
this.safeTDFactor = getSafeTDFactor(this.config.TERMINAL_TOTAL_DIFFICULTY);
|
|
73
|
-
const scaledTTD = this.config.TERMINAL_TOTAL_DIFFICULTY / this.safeTDFactor;
|
|
74
|
-
|
|
75
|
-
// Only run metrics if necessary
|
|
76
|
-
if (metrics) {
|
|
77
|
-
// TTD can't be dynamically changed during execution, register metric once
|
|
78
|
-
metrics.eth1.eth1MergeTTD.set(Number(scaledTTD as bigint));
|
|
79
|
-
metrics.eth1.eth1MergeTDFactor.set(Number(this.safeTDFactor as bigint));
|
|
80
|
-
|
|
81
|
-
metrics.eth1.eth1MergeStatus.addCollect(() => {
|
|
82
|
-
// Set merge ttd, merge status and merge block status
|
|
83
|
-
metrics.eth1.eth1MergeStatus.set(statusCodeIdx[this.status.code]);
|
|
84
|
-
|
|
85
|
-
if (this.latestEth1Block !== null) {
|
|
86
|
-
// Set latestBlock stats
|
|
87
|
-
metrics.eth1.eth1LatestBlockNumber.set(this.latestEth1Block.number);
|
|
88
|
-
metrics.eth1.eth1LatestBlockTD.set(Number(this.latestEth1Block.totalDifficulty / this.safeTDFactor));
|
|
89
|
-
metrics.eth1.eth1LatestBlockTimestamp.set(this.latestEth1Block.timestamp);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Returns the most recent POW block that satisfies the merge block condition
|
|
97
|
-
*/
|
|
98
|
-
async getTerminalPowBlock(): Promise<PowMergeBlock | null> {
|
|
99
|
-
switch (this.status.code) {
|
|
100
|
-
case StatusCode.STOPPED:
|
|
101
|
-
// If not module is not polling fetch the mergeBlock explicitly
|
|
102
|
-
return this.getTerminalPowBlockFromEth1();
|
|
103
|
-
|
|
104
|
-
case StatusCode.SEARCHING:
|
|
105
|
-
// Assume that polling would have found the block
|
|
106
|
-
return null;
|
|
107
|
-
|
|
108
|
-
case StatusCode.FOUND:
|
|
109
|
-
return this.status.mergeBlock;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
getTDProgress(): TDProgress | null {
|
|
114
|
-
if (this.latestEth1Block === null) {
|
|
115
|
-
return this.latestEth1Block;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const tdDiff = this.config.TERMINAL_TOTAL_DIFFICULTY - this.latestEth1Block.totalDifficulty;
|
|
119
|
-
|
|
120
|
-
if (tdDiff > BigInt(0)) {
|
|
121
|
-
return {
|
|
122
|
-
ttdHit: false,
|
|
123
|
-
tdFactor: this.safeTDFactor,
|
|
124
|
-
tdDiffScaled: Number((tdDiff / this.safeTDFactor) as bigint),
|
|
125
|
-
ttd: this.config.TERMINAL_TOTAL_DIFFICULTY,
|
|
126
|
-
td: this.latestEth1Block.totalDifficulty,
|
|
127
|
-
timestamp: this.latestEth1Block.timestamp,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
return {
|
|
131
|
-
ttdHit: true,
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Get a POW block by hash checking the local cache first
|
|
137
|
-
*/
|
|
138
|
-
async getPowBlock(powBlockHash: string): Promise<PowMergeBlock | null> {
|
|
139
|
-
// Check cache first
|
|
140
|
-
const cachedBlock = this.blocksByHashCache.get(powBlockHash);
|
|
141
|
-
if (cachedBlock) {
|
|
142
|
-
return cachedBlock;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// Fetch from node
|
|
146
|
-
const blockRaw = await this.eth1Provider.getBlockByHash(powBlockHash);
|
|
147
|
-
if (blockRaw) {
|
|
148
|
-
const block = toPowBlock(blockRaw);
|
|
149
|
-
this.cacheBlock(block);
|
|
150
|
-
return block;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return null;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Should only start polling for mergeBlock if:
|
|
158
|
-
* - after BELLATRIX_FORK_EPOCH
|
|
159
|
-
* - Beacon node synced
|
|
160
|
-
* - head state not isMergeTransitionComplete
|
|
161
|
-
*/
|
|
162
|
-
startPollingMergeBlock(): void {
|
|
163
|
-
if (this.status.code !== StatusCode.STOPPED) {
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
this.status = {code: StatusCode.SEARCHING};
|
|
168
|
-
this.logger.info("Starting search for terminal POW block", {
|
|
169
|
-
TERMINAL_TOTAL_DIFFICULTY: this.config.TERMINAL_TOTAL_DIFFICULTY,
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
const interval = setInterval(() => {
|
|
173
|
-
// Preemptively try to find merge block and cache it if found.
|
|
174
|
-
// Future callers of getTerminalPowBlock() will re-use the cached found mergeBlock.
|
|
175
|
-
this.getTerminalPowBlockFromEth1().catch((e) => {
|
|
176
|
-
this.logger.error("Error on findMergeBlock", {}, e as Error);
|
|
177
|
-
this.metrics?.eth1.eth1PollMergeBlockErrors.inc();
|
|
178
|
-
});
|
|
179
|
-
}, this.config.SECONDS_PER_ETH1_BLOCK * 1000);
|
|
180
|
-
|
|
181
|
-
this.intervals.push(interval);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
private close(): void {
|
|
185
|
-
this.intervals.forEach(clearInterval);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
private async getTerminalPowBlockFromEth1(): Promise<PowMergeBlock | null> {
|
|
189
|
-
if (!this.getTerminalPowBlockFromEth1Promise) {
|
|
190
|
-
this.getTerminalPowBlockFromEth1Promise = this.internalGetTerminalPowBlockFromEth1()
|
|
191
|
-
.then((mergeBlock) => {
|
|
192
|
-
// Persist found merge block here to affect both caller paths:
|
|
193
|
-
// - internal searcher
|
|
194
|
-
// - external caller if STOPPED
|
|
195
|
-
if (mergeBlock && this.status.code !== StatusCode.FOUND) {
|
|
196
|
-
if (this.status.code === StatusCode.SEARCHING) {
|
|
197
|
-
this.close();
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
this.logger.info("Terminal POW block found!", {
|
|
201
|
-
hash: mergeBlock.blockHash,
|
|
202
|
-
number: mergeBlock.number,
|
|
203
|
-
totalDifficulty: mergeBlock.totalDifficulty,
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
this.status = {code: StatusCode.FOUND, mergeBlock};
|
|
207
|
-
this.metrics?.eth1.eth1MergeBlockDetails.set(
|
|
208
|
-
{
|
|
209
|
-
terminalBlockHash: mergeBlock.blockHash,
|
|
210
|
-
// Convert all number/bigints to string labels
|
|
211
|
-
terminalBlockNumber: mergeBlock.number.toString(10),
|
|
212
|
-
terminalBlockTD: mergeBlock.totalDifficulty.toString(10),
|
|
213
|
-
},
|
|
214
|
-
1
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
return mergeBlock;
|
|
219
|
-
})
|
|
220
|
-
.finally(() => {
|
|
221
|
-
this.getTerminalPowBlockFromEth1Promise = null;
|
|
222
|
-
});
|
|
223
|
-
} else {
|
|
224
|
-
// This should no happen, since getTerminalPowBlockFromEth1() should resolve faster than SECONDS_PER_ETH1_BLOCK.
|
|
225
|
-
// else something is wrong: the el-cl comms are two slow, or the backsearch got stuck in a deep search.
|
|
226
|
-
this.metrics?.eth1.getTerminalPowBlockPromiseCacheHit.inc();
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
return this.getTerminalPowBlockFromEth1Promise;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* **internal** + **unsafe** since it can create multiple backward searches that overload the eth1 client.
|
|
234
|
-
* Must be called in a wrapper to ensure that there's only once concurrent call to this fn.
|
|
235
|
-
*/
|
|
236
|
-
private async internalGetTerminalPowBlockFromEth1(): Promise<PowMergeBlock | null> {
|
|
237
|
-
// Search merge block by hash
|
|
238
|
-
// Terminal block hash override takes precedence over terminal total difficulty
|
|
239
|
-
const terminalBlockHash = toRootHex(this.config.TERMINAL_BLOCK_HASH);
|
|
240
|
-
if (terminalBlockHash !== ZERO_HASH_HEX) {
|
|
241
|
-
const block = await this.getPowBlock(terminalBlockHash);
|
|
242
|
-
if (block) {
|
|
243
|
-
return block;
|
|
244
|
-
}
|
|
245
|
-
// if a TERMINAL_BLOCK_HASH other than ZERO_HASH is configured and we can't find it, return NONE
|
|
246
|
-
return null;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// Search merge block by TTD
|
|
250
|
-
const latestBlockRaw = await this.eth1Provider.getBlockByNumber("latest");
|
|
251
|
-
if (!latestBlockRaw) {
|
|
252
|
-
throw Error("getBlockByNumber('latest') returned null");
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
let block = toPowBlock(latestBlockRaw);
|
|
256
|
-
this.latestEth1Block = {...block, timestamp: quantityToNum(latestBlockRaw.timestamp)};
|
|
257
|
-
this.cacheBlock(block);
|
|
258
|
-
|
|
259
|
-
// This code path to look backwards for the merge block is only necessary if:
|
|
260
|
-
// - The network has not yet found the merge block
|
|
261
|
-
// - There are descendants of the merge block in the eth1 chain
|
|
262
|
-
// For the search below to require more than a few hops, multiple block proposers in a row must fail to detect
|
|
263
|
-
// an existing merge block. Such situation is extremely unlikely, so this search is left un-optimized. Since
|
|
264
|
-
// this class can start eagerly looking for the merge block when not necessary, startPollingMergeBlock() should
|
|
265
|
-
// only be called when there is certainty that a mergeBlock search is necessary.
|
|
266
|
-
|
|
267
|
-
while (true) {
|
|
268
|
-
if (block.totalDifficulty < this.config.TERMINAL_TOTAL_DIFFICULTY) {
|
|
269
|
-
// TTD not reached yet
|
|
270
|
-
return null;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// else block.totalDifficulty >= this.config.TERMINAL_TOTAL_DIFFICULTY
|
|
274
|
-
// Potential mergeBlock! Must find the first block that passes TTD
|
|
275
|
-
|
|
276
|
-
// Allow genesis block to reach TTD https://github.com/ethereum/consensus-specs/pull/2719
|
|
277
|
-
if (block.parentHash === ZERO_HASH_HEX) {
|
|
278
|
-
return block;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
const parent = await this.getPowBlock(block.parentHash);
|
|
282
|
-
if (!parent) {
|
|
283
|
-
throw Error(`Unknown parent of block with TD>TTD ${block.parentHash}`);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
this.metrics?.eth1.eth1ParentBlocksFetched.inc();
|
|
287
|
-
|
|
288
|
-
// block.td > TTD && parent.td < TTD => block is mergeBlock
|
|
289
|
-
if (parent.totalDifficulty < this.config.TERMINAL_TOTAL_DIFFICULTY) {
|
|
290
|
-
// Is terminal total difficulty block AND has verified block -> parent relationship
|
|
291
|
-
return block;
|
|
292
|
-
}
|
|
293
|
-
block = parent;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
private cacheBlock(block: PowMergeBlock): void {
|
|
298
|
-
this.blocksByHashCache.set(block.blockHash, block);
|
|
299
|
-
pruneSetToMax(this.blocksByHashCache, MAX_CACHE_POW_BLOCKS);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
export function toPowBlock(block: EthJsonRpcBlockRaw): PowMergeBlock {
|
|
304
|
-
// Validate untrusted data from API
|
|
305
|
-
return {
|
|
306
|
-
number: quantityToNum(block.number),
|
|
307
|
-
blockHash: dataToRootHex(block.hash),
|
|
308
|
-
parentHash: dataToRootHex(block.parentHash),
|
|
309
|
-
totalDifficulty: quantityToBigint(block.totalDifficulty),
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* TTD values can be very large, for xDAI > 1e45. So scale down.
|
|
315
|
-
* To be good, TTD should be rendered as a number < Number.MAX_TD_RENDER_VALUE ~= 9e15
|
|
316
|
-
*/
|
|
317
|
-
export function getSafeTDFactor(ttd: bigint): bigint {
|
|
318
|
-
const safeIntegerMult = ttd / BigInt(MAX_TD_RENDER_VALUE);
|
|
319
|
-
|
|
320
|
-
// TTD < MAX_TD_RENDER_VALUE, no need to scale down
|
|
321
|
-
if (safeIntegerMult === BigInt(0)) {
|
|
322
|
-
return BigInt(1);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
// Return closest power of 10 to ensure TD < max
|
|
326
|
-
const safeIntegerMultDigits = safeIntegerMult.toString(10).length;
|
|
327
|
-
return BigInt(10) ** BigInt(safeIntegerMultDigits);
|
|
328
|
-
}
|
package/src/eth1/index.ts
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import {CachedBeaconStateAllForks} from "@lodestar/state-transition";
|
|
2
|
-
import {Root} from "@lodestar/types";
|
|
3
|
-
import {fromHex} from "@lodestar/utils";
|
|
4
|
-
import {Eth1DepositDataTracker, Eth1DepositDataTrackerModules} from "./eth1DepositDataTracker.js";
|
|
5
|
-
import {Eth1MergeBlockTracker, Eth1MergeBlockTrackerModules} from "./eth1MergeBlockTracker.js";
|
|
6
|
-
import {Eth1DataAndDeposits, IEth1ForBlockProduction, IEth1Provider, PowMergeBlock, TDProgress} from "./interface.js";
|
|
7
|
-
import {Eth1Options} from "./options.js";
|
|
8
|
-
import {Eth1Provider} from "./provider/eth1Provider.js";
|
|
9
|
-
export {Eth1Provider};
|
|
10
|
-
export type {IEth1ForBlockProduction, IEth1Provider};
|
|
11
|
-
|
|
12
|
-
// This module encapsulates all consumer functionality to the execution node (formerly eth1). The execution client
|
|
13
|
-
// has to:
|
|
14
|
-
//
|
|
15
|
-
// - For genesis, the beacon node must follow the eth1 chain: get all deposit events + blocks within that range.
|
|
16
|
-
// Once the genesis conditions are met, start the POS chain with the resulting state. The logic is similar to the
|
|
17
|
-
// two points below, but the implementation is specialized for each scenario.
|
|
18
|
-
//
|
|
19
|
-
// - Follow the eth1 block chain to validate eth1Data votes. It needs all consecutive blocks within a specific range
|
|
20
|
-
// and at a distance from the head.
|
|
21
|
-
// ETH1_FOLLOW_DISTANCE uint64(2**11) (= 2,048) Eth1 blocks ~8 hours
|
|
22
|
-
// EPOCHS_PER_ETH1_VOTING_PERIOD uint64(2**6) (= 64) epochs ~6.8 hours
|
|
23
|
-
//
|
|
24
|
-
// - Fetch ALL deposit events from the deposit contract to build the deposit tree and validate future merkle proofs.
|
|
25
|
-
// Then it must follow deposit events at a distance roughly similar to the `ETH1_FOLLOW_DISTANCE` parameter above.
|
|
26
|
-
//
|
|
27
|
-
// - [New bellatrix]: After BELLATRIX_FORK_EPOCH, it must fetch the block with hash
|
|
28
|
-
// `state.eth1_data.block_hash` to compute `terminal_total_difficulty`. Note this may change with
|
|
29
|
-
// https://github.com/ethereum/consensus-specs/issues/2603.
|
|
30
|
-
//
|
|
31
|
-
// - [New bellatrix]: On block production post BELLATRIX_FORK_EPOCH, pre merge, the beacon node must find the merge block
|
|
32
|
-
// crossing the `terminal_total_difficulty` boundary and include it in the block. After the merge block production
|
|
33
|
-
// will just use `execution_engine.assemble_block` without fetching individual blocks.
|
|
34
|
-
//
|
|
35
|
-
// - [New bellatrix]: Fork-choice must validate the merge block ensuring it crossed the `terminal_total_difficulty`
|
|
36
|
-
// boundary, so it must fetch the POW block referenced in the merge block + its POW parent block.
|
|
37
|
-
//
|
|
38
|
-
// With the merge the beacon node has to follow the eth1 chain at two distances:
|
|
39
|
-
// 1. At `ETH1_FOLLOW_DISTANCE` for eth1Data to be re-org safe
|
|
40
|
-
// 2. At the head to get the first merge block, tolerating possible re-orgs
|
|
41
|
-
//
|
|
42
|
-
// Then both streams of blocks should not be merged since it's harder to guard against re-orgs from (2) to (1).
|
|
43
|
-
|
|
44
|
-
export function initializeEth1ForBlockProduction(
|
|
45
|
-
opts: Eth1Options,
|
|
46
|
-
modules: Pick<Eth1DepositDataTrackerModules, "db" | "config" | "metrics" | "logger" | "signal">
|
|
47
|
-
): IEth1ForBlockProduction {
|
|
48
|
-
if (opts.enabled) {
|
|
49
|
-
return new Eth1ForBlockProduction(opts, {
|
|
50
|
-
config: modules.config,
|
|
51
|
-
db: modules.db,
|
|
52
|
-
metrics: modules.metrics,
|
|
53
|
-
logger: modules.logger,
|
|
54
|
-
signal: modules.signal,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
return new Eth1ForBlockProductionDisabled();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export class Eth1ForBlockProduction implements IEth1ForBlockProduction {
|
|
61
|
-
private readonly eth1DepositDataTracker: Eth1DepositDataTracker | null;
|
|
62
|
-
private readonly eth1MergeBlockTracker: Eth1MergeBlockTracker;
|
|
63
|
-
|
|
64
|
-
constructor(
|
|
65
|
-
opts: Eth1Options,
|
|
66
|
-
modules: Eth1DepositDataTrackerModules & Eth1MergeBlockTrackerModules & {eth1Provider?: IEth1Provider}
|
|
67
|
-
) {
|
|
68
|
-
const eth1Provider =
|
|
69
|
-
modules.eth1Provider ||
|
|
70
|
-
new Eth1Provider(
|
|
71
|
-
modules.config,
|
|
72
|
-
{...opts, logger: modules.logger},
|
|
73
|
-
modules.signal,
|
|
74
|
-
modules.metrics?.eth1HttpClient
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
this.eth1DepositDataTracker = opts.disableEth1DepositDataTracker
|
|
78
|
-
? null
|
|
79
|
-
: new Eth1DepositDataTracker(opts, modules, eth1Provider);
|
|
80
|
-
|
|
81
|
-
this.eth1MergeBlockTracker = new Eth1MergeBlockTracker(modules, eth1Provider);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
async getEth1DataAndDeposits(state: CachedBeaconStateAllForks): Promise<Eth1DataAndDeposits> {
|
|
85
|
-
if (this.eth1DepositDataTracker === null) {
|
|
86
|
-
return {eth1Data: state.eth1Data, deposits: []};
|
|
87
|
-
}
|
|
88
|
-
return this.eth1DepositDataTracker.getEth1DataAndDeposits(state);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
async getTerminalPowBlock(): Promise<Root | null> {
|
|
92
|
-
const block = await this.eth1MergeBlockTracker.getTerminalPowBlock();
|
|
93
|
-
return block && fromHex(block.blockHash);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
getPowBlock(powBlockHash: string): Promise<PowMergeBlock | null> {
|
|
97
|
-
return this.eth1MergeBlockTracker.getPowBlock(powBlockHash);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
getTDProgress(): TDProgress | null {
|
|
101
|
-
return this.eth1MergeBlockTracker.getTDProgress();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
startPollingMergeBlock(): void {
|
|
105
|
-
this.eth1MergeBlockTracker.startPollingMergeBlock();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
isPollingEth1Data(): boolean {
|
|
109
|
-
return this.eth1DepositDataTracker?.isPollingEth1Data() ?? false;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
stopPollingEth1Data(): void {
|
|
113
|
-
this.eth1DepositDataTracker?.stopPollingEth1Data();
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Disabled version of Eth1ForBlockProduction
|
|
119
|
-
* May produce invalid blocks by not adding new deposits and voting for the same eth1Data
|
|
120
|
-
*/
|
|
121
|
-
export class Eth1ForBlockProductionDisabled implements IEth1ForBlockProduction {
|
|
122
|
-
/**
|
|
123
|
-
* Returns same eth1Data as in state and no deposits
|
|
124
|
-
* May produce invalid blocks if deposits have to be added
|
|
125
|
-
*/
|
|
126
|
-
async getEth1DataAndDeposits(state: CachedBeaconStateAllForks): Promise<Eth1DataAndDeposits> {
|
|
127
|
-
return {eth1Data: state.eth1Data, deposits: []};
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Will miss the oportunity to propose the merge block but will still produce valid blocks
|
|
132
|
-
*/
|
|
133
|
-
async getTerminalPowBlock(): Promise<Root | null> {
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/** Will not be able to validate the merge block */
|
|
138
|
-
async getPowBlock(_powBlockHash: string): Promise<PowMergeBlock | null> {
|
|
139
|
-
throw Error("eth1 must be enabled to verify merge block");
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
getTDProgress(): TDProgress | null {
|
|
143
|
-
return null;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
isPollingEth1Data(): boolean {
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
startPollingMergeBlock(): void {
|
|
151
|
-
// Ignore
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
stopPollingEth1Data(): void {
|
|
155
|
-
// Ignore
|
|
156
|
-
}
|
|
157
|
-
}
|
package/src/eth1/interface.ts
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import {BeaconConfig} from "@lodestar/config";
|
|
2
|
-
import {CachedBeaconStateAllForks} from "@lodestar/state-transition";
|
|
3
|
-
import {Root, RootHex, phase0} from "@lodestar/types";
|
|
4
|
-
|
|
5
|
-
export type EthJsonRpcBlockRaw = {
|
|
6
|
-
/** the block number. null when its pending block. `"0x1b4"` */
|
|
7
|
-
number: string;
|
|
8
|
-
/** 32 Bytes - hash of the block. null when its pending block. `"0xdc0818cf78f21a8e70579cb46a43643f78291264dda342ae31049421c82d21ae"` */
|
|
9
|
-
hash: string;
|
|
10
|
-
/** 32 Bytes - hash of the parent block. `"0xe99e022112df268087ea7eafaf4790497fd21dbeeb6bd7a1721df161a6657a54"` */
|
|
11
|
-
parentHash: string;
|
|
12
|
-
/**
|
|
13
|
-
* integer of the total difficulty of the chain until this block. `"0x78ed983323d"`.
|
|
14
|
-
* Current mainnet value is 0x684de10dc5c03f006b6, 75 bits so requires a bigint.
|
|
15
|
-
*/
|
|
16
|
-
totalDifficulty: string;
|
|
17
|
-
/** the unix timestamp for when the block was collated. `"0x55ba467c"` */
|
|
18
|
-
timestamp: string;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export interface IEth1Provider {
|
|
22
|
-
deployBlock: number;
|
|
23
|
-
getBlockNumber(): Promise<number>;
|
|
24
|
-
/** Returns HTTP code 200 + value=null if block is not found */
|
|
25
|
-
getBlockByNumber(blockNumber: number | "latest"): Promise<EthJsonRpcBlockRaw | null>;
|
|
26
|
-
/** Returns HTTP code 200 + value=null if block is not found */
|
|
27
|
-
getBlockByHash(blockHashHex: string): Promise<EthJsonRpcBlockRaw | null>;
|
|
28
|
-
/** null returns are ignored, may return a different number of blocks than expected */
|
|
29
|
-
getBlocksByNumber(fromBlock: number, toBlock: number): Promise<EthJsonRpcBlockRaw[]>;
|
|
30
|
-
getDepositEvents(fromBlock: number, toBlock: number): Promise<phase0.DepositEvent[]>;
|
|
31
|
-
validateContract(): Promise<void>;
|
|
32
|
-
getState(): Eth1ProviderState;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export enum Eth1ProviderState {
|
|
36
|
-
ONLINE = "ONLINE",
|
|
37
|
-
OFFLINE = "OFFLINE",
|
|
38
|
-
ERROR = "ERROR",
|
|
39
|
-
AUTH_FAILED = "AUTH_FAILED",
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export type Eth1DataAndDeposits = {
|
|
43
|
-
eth1Data: phase0.Eth1Data;
|
|
44
|
-
deposits: phase0.Deposit[];
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export interface IEth1ForBlockProduction {
|
|
48
|
-
getEth1DataAndDeposits(state: CachedBeaconStateAllForks): Promise<Eth1DataAndDeposits>;
|
|
49
|
-
|
|
50
|
-
/** Returns the most recent POW block that satisfies the merge block condition */
|
|
51
|
-
getTerminalPowBlock(): Promise<Root | null>;
|
|
52
|
-
/** Get a POW block by hash checking the local cache first */
|
|
53
|
-
getPowBlock(powBlockHash: string): Promise<PowMergeBlock | null>;
|
|
54
|
-
|
|
55
|
-
/** Get current TD progress for log notifier */
|
|
56
|
-
getTDProgress(): TDProgress | null;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Should only start polling for mergeBlock if:
|
|
60
|
-
* - after BELLATRIX_FORK_EPOCH
|
|
61
|
-
* - Beacon node synced
|
|
62
|
-
* - head state not isMergeTransitionComplete
|
|
63
|
-
*/
|
|
64
|
-
startPollingMergeBlock(): void;
|
|
65
|
-
|
|
66
|
-
isPollingEth1Data(): boolean;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Should stop polling eth1Data after a Electra block is finalized AND deposit_requests_start_index is reached
|
|
70
|
-
*/
|
|
71
|
-
stopPollingEth1Data(): void;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/** Different Eth1Block from phase0.Eth1Block with blockHash */
|
|
75
|
-
export type Eth1Block = {
|
|
76
|
-
blockHash: Uint8Array;
|
|
77
|
-
blockNumber: number;
|
|
78
|
-
timestamp: number;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export type PowMergeBlock = {
|
|
82
|
-
number: number;
|
|
83
|
-
blockHash: RootHex;
|
|
84
|
-
parentHash: RootHex;
|
|
85
|
-
totalDifficulty: bigint;
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
export type PowMergeBlockTimestamp = PowMergeBlock & {
|
|
89
|
-
/** in seconds */
|
|
90
|
-
timestamp: number;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export type TDProgress =
|
|
94
|
-
| {
|
|
95
|
-
ttdHit: false;
|
|
96
|
-
/** Power of ten by which tdDiffScaled is scaled down */
|
|
97
|
-
tdFactor: bigint;
|
|
98
|
-
/** (TERMINAL_TOTAL_DIFFICULTY - block.totalDifficulty) / tdFactor */
|
|
99
|
-
tdDiffScaled: number;
|
|
100
|
-
/** TERMINAL_TOTAL_DIFFICULTY */
|
|
101
|
-
ttd: bigint;
|
|
102
|
-
/** totalDifficulty of latest fetched eth1 block */
|
|
103
|
-
td: bigint;
|
|
104
|
-
/** timestamp in sec of latest fetched eth1 block */
|
|
105
|
-
timestamp: number;
|
|
106
|
-
}
|
|
107
|
-
| {ttdHit: true};
|
|
108
|
-
|
|
109
|
-
export type BatchDepositEvents = {
|
|
110
|
-
depositEvents: phase0.DepositEvent[];
|
|
111
|
-
blockNumber: number;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
export type Eth1Streamer = {
|
|
115
|
-
getDepositsStream(fromBlock: number): AsyncGenerator<BatchDepositEvents>;
|
|
116
|
-
getDepositsAndBlockStreamForGenesis(fromBlock: number): AsyncGenerator<[phase0.DepositEvent[], phase0.Eth1Block]>;
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
export type IEth1StreamParams = Pick<
|
|
120
|
-
BeaconConfig,
|
|
121
|
-
"ETH1_FOLLOW_DISTANCE" | "MIN_GENESIS_TIME" | "GENESIS_DELAY" | "SECONDS_PER_ETH1_BLOCK"
|
|
122
|
-
> & {
|
|
123
|
-
maxBlocksPerPoll: number;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
export type IJson = string | number | boolean | undefined | IJson[] | {[key: string]: IJson};
|
|
127
|
-
|
|
128
|
-
export interface RpcPayload<P = IJson[]> {
|
|
129
|
-
method: string;
|
|
130
|
-
params: P;
|
|
131
|
-
}
|
package/src/eth1/options.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export type Eth1Options = {
|
|
2
|
-
enabled?: boolean;
|
|
3
|
-
disableEth1DepositDataTracker?: boolean;
|
|
4
|
-
providerUrls?: string[];
|
|
5
|
-
/**
|
|
6
|
-
* jwtSecretHex is the jwt secret if the eth1 modules should ping the jwt auth
|
|
7
|
-
* protected engine endpoints.
|
|
8
|
-
*/
|
|
9
|
-
jwtSecretHex?: string;
|
|
10
|
-
jwtId?: string;
|
|
11
|
-
jwtVersion?: string;
|
|
12
|
-
depositContractDeployBlock?: number;
|
|
13
|
-
unsafeAllowDepositDataOverwrite?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Vote for a specific eth1_data regardless of validity and existing votes.
|
|
16
|
-
* hex encoded ssz serialized Eth1Data type.
|
|
17
|
-
*/
|
|
18
|
-
forcedEth1DataVote?: string;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const DEFAULT_PROVIDER_URLS = ["http://localhost:8545"];
|
|
22
|
-
|
|
23
|
-
export const defaultEth1Options: Eth1Options = {
|
|
24
|
-
enabled: true,
|
|
25
|
-
providerUrls: DEFAULT_PROVIDER_URLS,
|
|
26
|
-
depositContractDeployBlock: 0,
|
|
27
|
-
unsafeAllowDepositDataOverwrite: false,
|
|
28
|
-
};
|