@lodestar/beacon-node 1.42.0-dev.d73eccfa56 → 1.42.0-dev.eec18d0609
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/blocks/index.js +14 -2
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/beacon/pool/index.js +1 -1
- package/lib/api/impl/beacon/pool/index.js.map +1 -1
- package/lib/api/impl/beacon/state/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/state/index.js +27 -32
- package/lib/api/impl/beacon/state/index.js.map +1 -1
- package/lib/api/impl/beacon/state/utils.d.ts +4 -4
- package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
- package/lib/api/impl/beacon/state/utils.js +7 -10
- package/lib/api/impl/beacon/state/utils.js.map +1 -1
- package/lib/api/impl/lodestar/index.d.ts.map +1 -1
- package/lib/api/impl/lodestar/index.js +4 -6
- package/lib/api/impl/lodestar/index.js.map +1 -1
- package/lib/api/impl/proof/index.d.ts.map +1 -1
- package/lib/api/impl/proof/index.js +2 -6
- package/lib/api/impl/proof/index.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +27 -27
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/api/impl/validator/utils.d.ts +2 -2
- package/lib/api/impl/validator/utils.d.ts.map +1 -1
- package/lib/api/impl/validator/utils.js +3 -3
- package/lib/api/impl/validator/utils.js.map +1 -1
- package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
- package/lib/chain/archiveStore/archiveStore.js +1 -0
- package/lib/chain/archiveStore/archiveStore.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts +3 -7
- package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
- package/lib/chain/archiveStore/historicalState/getHistoricalState.js +8 -26
- package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/historicalStateRegen.d.ts +2 -2
- package/lib/chain/archiveStore/historicalState/historicalStateRegen.d.ts.map +1 -1
- package/lib/chain/archiveStore/historicalState/historicalStateRegen.js +1 -0
- package/lib/chain/archiveStore/historicalState/historicalStateRegen.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/types.d.ts +2 -0
- package/lib/chain/archiveStore/historicalState/types.d.ts.map +1 -1
- package/lib/chain/archiveStore/historicalState/types.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/worker.js +1 -3
- package/lib/chain/archiveStore/historicalState/worker.js.map +1 -1
- package/lib/chain/archiveStore/interface.d.ts +1 -0
- package/lib/chain/archiveStore/interface.d.ts.map +1 -1
- package/lib/chain/balancesCache.d.ts +2 -2
- package/lib/chain/balancesCache.d.ts.map +1 -1
- package/lib/chain/balancesCache.js +4 -4
- package/lib/chain/balancesCache.js.map +1 -1
- package/lib/chain/blocks/blockInput/types.d.ts +1 -0
- package/lib/chain/blocks/blockInput/types.d.ts.map +1 -1
- package/lib/chain/blocks/blockInput/types.js +1 -0
- package/lib/chain/blocks/blockInput/types.js.map +1 -1
- package/lib/chain/blocks/importBlock.d.ts +3 -3
- package/lib/chain/blocks/importBlock.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.js +21 -21
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts +10 -8
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +78 -51
- package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
- package/lib/chain/blocks/index.d.ts.map +1 -1
- package/lib/chain/blocks/index.js +3 -2
- package/lib/chain/blocks/index.js.map +1 -1
- package/lib/chain/blocks/types.d.ts +21 -15
- package/lib/chain/blocks/types.d.ts.map +1 -1
- package/lib/chain/blocks/types.js.map +1 -1
- package/lib/chain/blocks/utils/checkpoint.d.ts +2 -2
- package/lib/chain/blocks/utils/checkpoint.d.ts.map +1 -1
- package/lib/chain/blocks/utils/checkpoint.js.map +1 -1
- package/lib/chain/blocks/verifyBlock.d.ts +2 -2
- package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlock.js +4 -4
- package/lib/chain/blocks/verifyBlock.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts +5 -5
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +4 -4
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksSignatures.d.ts +2 -2
- package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksSignatures.js +1 -1
- package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts +3 -3
- package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js +3 -3
- package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js.map +1 -1
- package/lib/chain/chain.d.ts +12 -12
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +47 -39
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/emitter.d.ts +2 -2
- package/lib/chain/emitter.d.ts.map +1 -1
- package/lib/chain/errors/blockError.d.ts +4 -4
- package/lib/chain/errors/blockError.d.ts.map +1 -1
- package/lib/chain/forkChoice/index.d.ts +4 -4
- package/lib/chain/forkChoice/index.d.ts.map +1 -1
- package/lib/chain/forkChoice/index.js +27 -23
- package/lib/chain/forkChoice/index.js.map +1 -1
- package/lib/chain/initState.d.ts +2 -2
- package/lib/chain/initState.d.ts.map +1 -1
- package/lib/chain/initState.js +1 -1
- package/lib/chain/initState.js.map +1 -1
- package/lib/chain/interface.d.ts +11 -12
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/lightClient/index.d.ts +2 -2
- package/lib/chain/lightClient/index.d.ts.map +1 -1
- package/lib/chain/lightClient/index.js +4 -4
- package/lib/chain/lightClient/index.js.map +1 -1
- package/lib/chain/opPools/aggregatedAttestationPool.d.ts +6 -6
- package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
- package/lib/chain/opPools/aggregatedAttestationPool.js +10 -13
- package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
- package/lib/chain/opPools/opPool.d.ts +3 -3
- package/lib/chain/opPools/opPool.d.ts.map +1 -1
- package/lib/chain/opPools/opPool.js +7 -7
- package/lib/chain/opPools/opPool.js.map +1 -1
- package/lib/chain/opPools/utils.d.ts +2 -2
- package/lib/chain/opPools/utils.d.ts.map +1 -1
- package/lib/chain/opPools/utils.js +1 -1
- package/lib/chain/opPools/utils.js.map +1 -1
- package/lib/chain/options.d.ts +1 -0
- package/lib/chain/options.d.ts.map +1 -1
- package/lib/chain/options.js +1 -0
- package/lib/chain/options.js.map +1 -1
- package/lib/chain/prepareNextSlot.d.ts +2 -2
- package/lib/chain/prepareNextSlot.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +3 -3
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/computeNewStateRoot.d.ts +4 -4
- package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
- package/lib/chain/produceBlock/computeNewStateRoot.js +3 -4
- package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +5 -5
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +12 -16
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/regen/interface.d.ts +13 -13
- package/lib/chain/regen/interface.d.ts.map +1 -1
- package/lib/chain/regen/queued.d.ts +14 -14
- package/lib/chain/regen/queued.d.ts.map +1 -1
- package/lib/chain/regen/queued.js.map +1 -1
- package/lib/chain/regen/regen.d.ts +6 -5
- package/lib/chain/regen/regen.d.ts.map +1 -1
- package/lib/chain/regen/regen.js +6 -6
- package/lib/chain/regen/regen.js.map +1 -1
- package/lib/chain/serializeState.d.ts +2 -2
- package/lib/chain/serializeState.d.ts.map +1 -1
- package/lib/chain/serializeState.js +1 -1
- package/lib/chain/serializeState.js.map +1 -1
- package/lib/chain/shufflingCache.d.ts +2 -2
- package/lib/chain/shufflingCache.d.ts.map +1 -1
- package/lib/chain/shufflingCache.js +3 -4
- package/lib/chain/shufflingCache.js.map +1 -1
- package/lib/chain/stateCache/fifoBlockStateCache.d.ts +6 -6
- package/lib/chain/stateCache/fifoBlockStateCache.d.ts.map +1 -1
- package/lib/chain/stateCache/fifoBlockStateCache.js.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +11 -11
- package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.js +12 -16
- package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
- package/lib/chain/stateCache/types.d.ts +14 -14
- package/lib/chain/stateCache/types.d.ts.map +1 -1
- package/lib/chain/stateCache/types.js.map +1 -1
- package/lib/chain/validation/attesterSlashing.js +3 -3
- package/lib/chain/validation/attesterSlashing.js.map +1 -1
- package/lib/chain/validation/blobSidecar.js +1 -1
- 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.js +2 -2
- package/lib/chain/validation/blsToExecutionChange.js.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.js +1 -1
- package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
- package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/validation/executionPayloadBid.js +4 -4
- package/lib/chain/validation/executionPayloadBid.js.map +1 -1
- package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/validation/executionPayloadEnvelope.js +2 -3
- package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
- package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
- package/lib/chain/validation/payloadAttestationMessage.js +1 -2
- package/lib/chain/validation/payloadAttestationMessage.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/contributionAndProof.d.ts +2 -2
- package/lib/chain/validation/signatureSets/contributionAndProof.d.ts.map +1 -1
- package/lib/chain/validation/signatureSets/contributionAndProof.js +1 -1
- package/lib/chain/validation/signatureSets/contributionAndProof.js.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommittee.d.ts +2 -2
- package/lib/chain/validation/signatureSets/syncCommittee.d.ts.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommittee.js +1 -1
- package/lib/chain/validation/signatureSets/syncCommittee.js.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts +2 -2
- package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommitteeContribution.js.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts +2 -2
- package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js +1 -1
- package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js.map +1 -1
- package/lib/chain/validation/syncCommittee.d.ts +4 -4
- package/lib/chain/validation/syncCommittee.d.ts.map +1 -1
- package/lib/chain/validation/syncCommittee.js +13 -12
- 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 +1 -1
- package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
- package/lib/chain/validation/voluntaryExit.d.ts.map +1 -1
- package/lib/chain/validation/voluntaryExit.js +3 -3
- package/lib/chain/validation/voluntaryExit.js.map +1 -1
- package/lib/chain/validatorMonitor.d.ts +3 -3
- package/lib/chain/validatorMonitor.d.ts.map +1 -1
- package/lib/chain/validatorMonitor.js +9 -7
- package/lib/chain/validatorMonitor.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +12 -4
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +19 -15
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/gossip/encoding.d.ts.map +1 -1
- package/lib/network/gossip/encoding.js +15 -0
- package/lib/network/gossip/encoding.js.map +1 -1
- package/lib/network/gossip/topic.d.ts +2 -729
- package/lib/network/gossip/topic.d.ts.map +1 -1
- package/lib/network/interface.d.ts +4 -2
- package/lib/network/interface.d.ts.map +1 -1
- package/lib/network/libp2p/index.d.ts.map +1 -1
- package/lib/network/libp2p/index.js +22 -11
- package/lib/network/libp2p/index.js.map +1 -1
- package/lib/network/network.d.ts +4 -2
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js +9 -3
- package/lib/network/network.js.map +1 -1
- package/lib/network/options.d.ts.map +1 -1
- package/lib/network/options.js +7 -2
- package/lib/network/options.js.map +1 -1
- package/lib/network/processor/extractSlotRootFns.d.ts +1 -1
- package/lib/network/processor/extractSlotRootFns.js +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +24 -15
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/index.d.ts +12 -7
- package/lib/network/processor/index.d.ts.map +1 -1
- package/lib/network/processor/index.js +99 -78
- package/lib/network/processor/index.js.map +1 -1
- package/lib/network/reqresp/ReqRespBeaconNode.d.ts.map +1 -1
- package/lib/network/reqresp/ReqRespBeaconNode.js +9 -0
- package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts +8 -0
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -0
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +69 -0
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -0
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.d.ts +6 -0
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.d.ts.map +1 -0
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js +28 -0
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js.map +1 -0
- package/lib/network/reqresp/handlers/index.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/index.js +11 -1
- package/lib/network/reqresp/handlers/index.js.map +1 -1
- package/lib/network/reqresp/protocols.d.ts +2 -0
- package/lib/network/reqresp/protocols.d.ts.map +1 -1
- package/lib/network/reqresp/protocols.js +10 -0
- package/lib/network/reqresp/protocols.js.map +1 -1
- package/lib/network/reqresp/rateLimit.d.ts.map +1 -1
- package/lib/network/reqresp/rateLimit.js +8 -0
- package/lib/network/reqresp/rateLimit.js.map +1 -1
- package/lib/network/reqresp/score.d.ts.map +1 -1
- package/lib/network/reqresp/score.js +2 -0
- package/lib/network/reqresp/score.js.map +1 -1
- package/lib/network/reqresp/types.d.ts +8 -2
- package/lib/network/reqresp/types.d.ts.map +1 -1
- package/lib/network/reqresp/types.js +7 -1
- package/lib/network/reqresp/types.js.map +1 -1
- package/lib/node/nodejs.d.ts +2 -2
- package/lib/node/nodejs.d.ts.map +1 -1
- package/lib/node/nodejs.js +1 -4
- package/lib/node/nodejs.js.map +1 -1
- package/lib/node/notifier.d.ts.map +1 -1
- package/lib/node/notifier.js +3 -3
- package/lib/node/notifier.js.map +1 -1
- package/lib/sync/backfill/backfill.d.ts +2 -2
- 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/unknownBlock.d.ts +3 -9
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +8 -41
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/util/types.d.ts +2 -0
- package/lib/util/types.d.ts.map +1 -1
- package/lib/util/types.js +1 -0
- package/lib/util/types.js.map +1 -1
- package/package.json +16 -16
- package/src/api/impl/beacon/blocks/index.ts +16 -2
- package/src/api/impl/beacon/pool/index.ts +1 -1
- package/src/api/impl/beacon/state/index.ts +29 -41
- package/src/api/impl/beacon/state/utils.ts +11 -25
- package/src/api/impl/lodestar/index.ts +4 -8
- package/src/api/impl/proof/index.ts +2 -9
- package/src/api/impl/validator/index.ts +29 -41
- package/src/api/impl/validator/utils.ts +4 -7
- package/src/chain/archiveStore/archiveStore.ts +1 -0
- package/src/chain/archiveStore/historicalState/getHistoricalState.ts +10 -39
- package/src/chain/archiveStore/historicalState/historicalStateRegen.ts +2 -1
- package/src/chain/archiveStore/historicalState/types.ts +2 -0
- package/src/chain/archiveStore/historicalState/worker.ts +1 -4
- package/src/chain/archiveStore/interface.ts +1 -0
- package/src/chain/balancesCache.ts +5 -11
- package/src/chain/blocks/blockInput/types.ts +1 -0
- package/src/chain/blocks/importBlock.ts +23 -25
- package/src/chain/blocks/importExecutionPayload.ts +89 -63
- package/src/chain/blocks/index.ts +3 -2
- package/src/chain/blocks/types.ts +26 -15
- package/src/chain/blocks/utils/checkpoint.ts +2 -2
- package/src/chain/blocks/verifyBlock.ts +5 -10
- package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +9 -14
- package/src/chain/blocks/verifyBlocksSignatures.ts +3 -3
- package/src/chain/blocks/verifyBlocksStateTransitionOnly.ts +6 -8
- package/src/chain/chain.ts +75 -67
- package/src/chain/emitter.ts +2 -2
- package/src/chain/errors/blockError.ts +4 -4
- package/src/chain/forkChoice/index.ts +33 -42
- package/src/chain/initState.ts +7 -2
- package/src/chain/interface.ts +12 -13
- package/src/chain/lightClient/index.ts +9 -22
- package/src/chain/opPools/aggregatedAttestationPool.ts +15 -21
- package/src/chain/opPools/opPool.ts +13 -14
- package/src/chain/opPools/utils.ts +3 -3
- package/src/chain/options.ts +2 -0
- package/src/chain/prepareNextSlot.ts +6 -8
- package/src/chain/produceBlock/computeNewStateRoot.ts +6 -10
- package/src/chain/produceBlock/produceBlockBody.ts +22 -49
- package/src/chain/regen/interface.ts +13 -17
- package/src/chain/regen/queued.ts +16 -20
- package/src/chain/regen/regen.ts +16 -17
- package/src/chain/serializeState.ts +3 -3
- package/src/chain/shufflingCache.ts +5 -7
- package/src/chain/stateCache/fifoBlockStateCache.ts +7 -7
- package/src/chain/stateCache/persistentCheckpointsCache.ts +27 -42
- package/src/chain/stateCache/types.ts +14 -18
- package/src/chain/validation/attesterSlashing.ts +3 -3
- package/src/chain/validation/blobSidecar.ts +1 -1
- package/src/chain/validation/block.ts +2 -4
- package/src/chain/validation/blsToExecutionChange.ts +2 -2
- package/src/chain/validation/dataColumnSidecar.ts +1 -1
- package/src/chain/validation/executionPayloadBid.ts +3 -7
- package/src/chain/validation/executionPayloadEnvelope.ts +2 -8
- package/src/chain/validation/payloadAttestationMessage.ts +2 -4
- package/src/chain/validation/proposerSlashing.ts +1 -1
- package/src/chain/validation/signatureSets/contributionAndProof.ts +2 -7
- package/src/chain/validation/signatureSets/syncCommittee.ts +2 -7
- package/src/chain/validation/signatureSets/syncCommitteeContribution.ts +2 -2
- package/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts +2 -7
- package/src/chain/validation/syncCommittee.ts +21 -20
- package/src/chain/validation/syncCommitteeContributionAndProof.ts +5 -10
- package/src/chain/validation/voluntaryExit.ts +3 -8
- package/src/chain/validatorMonitor.ts +12 -11
- package/src/metrics/metrics/lodestar.ts +23 -19
- package/src/network/gossip/encoding.ts +16 -0
- package/src/network/interface.ts +15 -2
- package/src/network/libp2p/index.ts +24 -13
- package/src/network/network.ts +32 -4
- package/src/network/options.ts +7 -2
- package/src/network/processor/extractSlotRootFns.ts +1 -1
- package/src/network/processor/gossipHandlers.ts +25 -16
- package/src/network/processor/index.ts +110 -89
- package/src/network/reqresp/ReqRespBeaconNode.ts +13 -0
- package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +94 -0
- package/src/network/reqresp/handlers/executionPayloadEnvelopesByRoot.ts +43 -0
- package/src/network/reqresp/handlers/index.ts +12 -0
- package/src/network/reqresp/protocols.ts +12 -0
- package/src/network/reqresp/rateLimit.ts +18 -0
- package/src/network/reqresp/score.ts +2 -0
- package/src/network/reqresp/types.ts +13 -0
- package/src/node/nodejs.ts +3 -5
- package/src/node/notifier.ts +4 -10
- package/src/sync/backfill/backfill.ts +3 -3
- package/src/sync/unknownBlock.ts +10 -50
- package/src/util/types.ts +6 -0
package/src/chain/chain.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import {PrivateKey} from "@libp2p/interface";
|
|
3
|
-
import {
|
|
3
|
+
import {Type} from "@chainsafe/ssz";
|
|
4
4
|
import {BeaconConfig} from "@lodestar/config";
|
|
5
5
|
import {
|
|
6
6
|
CheckpointWithPayloadStatus,
|
|
@@ -14,30 +14,21 @@ import {LoggerNode} from "@lodestar/logger/node";
|
|
|
14
14
|
import {
|
|
15
15
|
BUILDER_INDEX_SELF_BUILD,
|
|
16
16
|
EFFECTIVE_BALANCE_INCREMENT,
|
|
17
|
-
ForkPostFulu,
|
|
17
|
+
type ForkPostFulu,
|
|
18
18
|
GENESIS_SLOT,
|
|
19
19
|
SLOTS_PER_EPOCH,
|
|
20
20
|
isForkPostElectra,
|
|
21
21
|
isForkPostGloas,
|
|
22
22
|
} from "@lodestar/params";
|
|
23
23
|
import {
|
|
24
|
-
BeaconStateAllForks,
|
|
25
|
-
BeaconStateElectra,
|
|
26
|
-
CachedBeaconStateAllForks,
|
|
27
|
-
CachedBeaconStateGloas,
|
|
28
24
|
EffectiveBalanceIncrements,
|
|
29
25
|
EpochShuffling,
|
|
26
|
+
IBeaconStateView,
|
|
30
27
|
PubkeyCache,
|
|
31
|
-
computeAnchorCheckpoint,
|
|
32
|
-
computeAttestationsRewards,
|
|
33
|
-
computeBlockRewards,
|
|
34
28
|
computeEndSlotAtEpoch,
|
|
35
29
|
computeEpochAtSlot,
|
|
36
30
|
computeStartSlotAtEpoch,
|
|
37
|
-
computeSyncCommitteeRewards,
|
|
38
|
-
getEffectiveBalanceIncrementsZeroInactive,
|
|
39
31
|
getEffectiveBalancesFromStateBytes,
|
|
40
|
-
processSlots,
|
|
41
32
|
} from "@lodestar/state-transition";
|
|
42
33
|
import {
|
|
43
34
|
BeaconBlock,
|
|
@@ -283,7 +274,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
283
274
|
clock?: IClock;
|
|
284
275
|
metrics: Metrics | null;
|
|
285
276
|
validatorMonitor: ValidatorMonitor | null;
|
|
286
|
-
anchorState:
|
|
277
|
+
anchorState: IBeaconStateView;
|
|
287
278
|
isAnchorStateFinalized: boolean;
|
|
288
279
|
executionEngine: IExecutionEngine;
|
|
289
280
|
executionBuilder?: IExecutionBuilder;
|
|
@@ -359,16 +350,16 @@ export class BeaconChain implements IBeaconChain {
|
|
|
359
350
|
|
|
360
351
|
this.shufflingCache = new ShufflingCache(metrics, logger, this.opts, [
|
|
361
352
|
{
|
|
362
|
-
shuffling: anchorState.
|
|
363
|
-
decisionRoot: anchorState.
|
|
353
|
+
shuffling: anchorState.getPreviousShuffling(),
|
|
354
|
+
decisionRoot: anchorState.previousDecisionRoot,
|
|
364
355
|
},
|
|
365
356
|
{
|
|
366
|
-
shuffling: anchorState.
|
|
367
|
-
decisionRoot: anchorState.
|
|
357
|
+
shuffling: anchorState.getCurrentShuffling(),
|
|
358
|
+
decisionRoot: anchorState.currentDecisionRoot,
|
|
368
359
|
},
|
|
369
360
|
{
|
|
370
|
-
shuffling: anchorState.
|
|
371
|
-
decisionRoot: anchorState.
|
|
361
|
+
shuffling: anchorState.getNextShuffling(),
|
|
362
|
+
decisionRoot: anchorState.nextDecisionRoot,
|
|
372
363
|
},
|
|
373
364
|
]);
|
|
374
365
|
|
|
@@ -377,7 +368,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
377
368
|
|
|
378
369
|
const fileDataStore = opts.nHistoricalStatesFileDataStore ?? true;
|
|
379
370
|
const blockStateCache = new FIFOBlockStateCache(this.opts, {metrics});
|
|
380
|
-
this.bufferPool = new BufferPool(anchorState.
|
|
371
|
+
this.bufferPool = new BufferPool(anchorState.serializedSize(), metrics);
|
|
381
372
|
|
|
382
373
|
this.cpStateDatastore = fileDataStore ? new FileCPStateDatastore(dataDir) : new DbCPStateDatastore(this.db);
|
|
383
374
|
const checkpointStateCache: CheckpointStateCache = new PersistentCheckpointStateCache(
|
|
@@ -393,10 +384,10 @@ export class BeaconChain implements IBeaconChain {
|
|
|
393
384
|
this.opts
|
|
394
385
|
);
|
|
395
386
|
|
|
396
|
-
const {checkpoint} = computeAnchorCheckpoint(
|
|
387
|
+
const {checkpoint} = anchorState.computeAnchorCheckpoint();
|
|
397
388
|
blockStateCache.add(anchorState);
|
|
398
389
|
blockStateCache.setHeadState(anchorState);
|
|
399
|
-
const payloadPresent = getCheckpointPayloadStatus(anchorState, checkpoint.epoch) === PayloadStatus.FULL;
|
|
390
|
+
const payloadPresent = getCheckpointPayloadStatus(config, anchorState, checkpoint.epoch) === PayloadStatus.FULL;
|
|
400
391
|
checkpointStateCache.add(checkpoint, anchorState, payloadPresent);
|
|
401
392
|
|
|
402
393
|
const forkChoice = initializeForkChoice(
|
|
@@ -557,7 +548,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
557
548
|
await this.opPool.toPersisted(this.db);
|
|
558
549
|
}
|
|
559
550
|
|
|
560
|
-
getHeadState():
|
|
551
|
+
getHeadState(): IBeaconStateView {
|
|
561
552
|
// head state should always exist
|
|
562
553
|
const head = this.forkChoice.getHead();
|
|
563
554
|
const headState = this.regen.getClosestHeadState(head);
|
|
@@ -567,11 +558,11 @@ export class BeaconChain implements IBeaconChain {
|
|
|
567
558
|
return headState;
|
|
568
559
|
}
|
|
569
560
|
|
|
570
|
-
async getHeadStateAtCurrentEpoch(regenCaller: RegenCaller): Promise<
|
|
561
|
+
async getHeadStateAtCurrentEpoch(regenCaller: RegenCaller): Promise<IBeaconStateView> {
|
|
571
562
|
return this.getHeadStateAtEpoch(this.clock.currentEpoch, regenCaller);
|
|
572
563
|
}
|
|
573
564
|
|
|
574
|
-
async getHeadStateAtEpoch(epoch: Epoch, regenCaller: RegenCaller): Promise<
|
|
565
|
+
async getHeadStateAtEpoch(epoch: Epoch, regenCaller: RegenCaller): Promise<IBeaconStateView> {
|
|
575
566
|
// using getHeadState() means we'll use checkpointStateCache if it's available
|
|
576
567
|
const headState = this.getHeadState();
|
|
577
568
|
// head state is in the same epoch, or we pulled up head state already from past epoch
|
|
@@ -588,7 +579,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
588
579
|
async getStateBySlot(
|
|
589
580
|
slot: Slot,
|
|
590
581
|
opts?: StateGetOpts
|
|
591
|
-
): Promise<{state:
|
|
582
|
+
): Promise<{state: IBeaconStateView; executionOptimistic: boolean; finalized: boolean} | null> {
|
|
592
583
|
const finalizedBlock = this.forkChoice.getFinalizedBlock();
|
|
593
584
|
|
|
594
585
|
if (slot < finalizedBlock.slot) {
|
|
@@ -638,15 +629,17 @@ export class BeaconChain implements IBeaconChain {
|
|
|
638
629
|
async getStateByStateRoot(
|
|
639
630
|
stateRoot: RootHex,
|
|
640
631
|
opts?: StateGetOpts
|
|
641
|
-
): Promise<{state:
|
|
632
|
+
): Promise<{state: IBeaconStateView | Uint8Array; executionOptimistic: boolean; finalized: boolean} | null> {
|
|
642
633
|
if (opts?.allowRegen) {
|
|
643
634
|
const state = await this.regen.getState(stateRoot, RegenCaller.restApi);
|
|
644
|
-
const block = this.forkChoice.getBlockDefaultStatus(
|
|
635
|
+
const block = this.forkChoice.getBlockDefaultStatus(
|
|
636
|
+
ssz.phase0.BeaconBlockHeader.hashTreeRoot(state.latestBlockHeader)
|
|
637
|
+
);
|
|
645
638
|
const finalizedEpoch = this.forkChoice.getFinalizedCheckpoint().epoch;
|
|
646
639
|
return {
|
|
647
640
|
state,
|
|
648
641
|
executionOptimistic: block != null && isOptimisticBlock(block),
|
|
649
|
-
finalized: state.
|
|
642
|
+
finalized: state.epoch <= finalizedEpoch && finalizedEpoch !== GENESIS_EPOCH,
|
|
650
643
|
};
|
|
651
644
|
}
|
|
652
645
|
|
|
@@ -657,12 +650,14 @@ export class BeaconChain implements IBeaconChain {
|
|
|
657
650
|
// TODO: This is very inneficient for debug requests of serialized content, since it deserializes to serialize again
|
|
658
651
|
const cachedStateCtx = this.regen.getStateSync(stateRoot);
|
|
659
652
|
if (cachedStateCtx) {
|
|
660
|
-
const block = this.forkChoice.getBlockDefaultStatus(
|
|
653
|
+
const block = this.forkChoice.getBlockDefaultStatus(
|
|
654
|
+
ssz.phase0.BeaconBlockHeader.hashTreeRoot(cachedStateCtx.latestBlockHeader)
|
|
655
|
+
);
|
|
661
656
|
const finalizedEpoch = this.forkChoice.getFinalizedCheckpoint().epoch;
|
|
662
657
|
return {
|
|
663
658
|
state: cachedStateCtx,
|
|
664
659
|
executionOptimistic: block != null && isOptimisticBlock(block),
|
|
665
|
-
finalized: cachedStateCtx.
|
|
660
|
+
finalized: cachedStateCtx.epoch <= finalizedEpoch && finalizedEpoch !== GENESIS_EPOCH,
|
|
666
661
|
};
|
|
667
662
|
}
|
|
668
663
|
|
|
@@ -689,17 +684,19 @@ export class BeaconChain implements IBeaconChain {
|
|
|
689
684
|
|
|
690
685
|
getStateByCheckpoint(
|
|
691
686
|
checkpoint: CheckpointWithPayloadStatus
|
|
692
|
-
): {state:
|
|
687
|
+
): {state: IBeaconStateView; executionOptimistic: boolean; finalized: boolean} | null {
|
|
693
688
|
// finalized or justified checkpoint states maynot be available with PersistentCheckpointStateCache, use getCheckpointStateOrBytes() api to get Uint8Array
|
|
694
689
|
const checkpointHexPayload = fcCheckpointToHexPayload(checkpoint);
|
|
695
690
|
const cachedStateCtx = this.regen.getCheckpointStateSync(checkpointHexPayload);
|
|
696
691
|
if (cachedStateCtx) {
|
|
697
|
-
const block = this.forkChoice.getBlockDefaultStatus(
|
|
692
|
+
const block = this.forkChoice.getBlockDefaultStatus(
|
|
693
|
+
ssz.phase0.BeaconBlockHeader.hashTreeRoot(cachedStateCtx.latestBlockHeader)
|
|
694
|
+
);
|
|
698
695
|
const finalizedEpoch = this.forkChoice.getFinalizedCheckpoint().epoch;
|
|
699
696
|
return {
|
|
700
697
|
state: cachedStateCtx,
|
|
701
698
|
executionOptimistic: block != null && isOptimisticBlock(block),
|
|
702
|
-
finalized: cachedStateCtx.
|
|
699
|
+
finalized: cachedStateCtx.epoch <= finalizedEpoch && finalizedEpoch !== GENESIS_EPOCH,
|
|
703
700
|
};
|
|
704
701
|
}
|
|
705
702
|
|
|
@@ -708,7 +705,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
708
705
|
|
|
709
706
|
async getStateOrBytesByCheckpoint(
|
|
710
707
|
checkpoint: CheckpointWithPayloadStatus
|
|
711
|
-
): Promise<{state:
|
|
708
|
+
): Promise<{state: IBeaconStateView | Uint8Array; executionOptimistic: boolean; finalized: boolean} | null> {
|
|
712
709
|
const checkpointHexPayload = fcCheckpointToHexPayload(checkpoint);
|
|
713
710
|
const cachedStateCtx = await this.regen.getCheckpointStateOrBytes(checkpointHexPayload);
|
|
714
711
|
if (cachedStateCtx) {
|
|
@@ -858,6 +855,24 @@ export class BeaconChain implements IBeaconChain {
|
|
|
858
855
|
return null;
|
|
859
856
|
}
|
|
860
857
|
|
|
858
|
+
async getSerializedExecutionPayloadEnvelope(blockSlot: Slot, blockRootHex: string): Promise<Uint8Array | null> {
|
|
859
|
+
const payloadInput = this.seenPayloadEnvelopeInputCache.get(blockRootHex);
|
|
860
|
+
if (payloadInput?.hasPayloadEnvelope()) {
|
|
861
|
+
const envelope = payloadInput.getPayloadEnvelope();
|
|
862
|
+
const serialized = this.serializedCache.get(envelope);
|
|
863
|
+
if (serialized) {
|
|
864
|
+
return serialized;
|
|
865
|
+
}
|
|
866
|
+
return ssz.gloas.SignedExecutionPayloadEnvelope.serialize(envelope);
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
return (
|
|
870
|
+
(await this.db.executionPayloadEnvelope.getBinary(fromHex(blockRootHex))) ??
|
|
871
|
+
(await this.db.executionPayloadEnvelopeArchive.getBinary(blockSlot)) ??
|
|
872
|
+
null
|
|
873
|
+
);
|
|
874
|
+
}
|
|
875
|
+
|
|
861
876
|
async getDataColumnSidecars(blockSlot: Slot, blockRootHex: string): Promise<DataColumnSidecars> {
|
|
862
877
|
const blockInput = this.seenBlockInputCache.get(blockRootHex);
|
|
863
878
|
if (blockInput) {
|
|
@@ -952,14 +967,13 @@ export class BeaconChain implements IBeaconChain {
|
|
|
952
967
|
consensusBlockValue: Wei;
|
|
953
968
|
shouldOverrideBuilder?: boolean;
|
|
954
969
|
}> {
|
|
955
|
-
const fork = this.config.getForkName(slot);
|
|
956
970
|
const state = await this.regen.getBlockSlotState(
|
|
957
971
|
parentBlock,
|
|
958
972
|
slot,
|
|
959
973
|
{dontTransferCache: true},
|
|
960
974
|
RegenCaller.produceBlock
|
|
961
975
|
);
|
|
962
|
-
const proposerIndex = state.
|
|
976
|
+
const proposerIndex = state.getBeaconProposer(slot);
|
|
963
977
|
const proposerPubKey = this.pubkeyCache.getOrThrow(proposerIndex).toBytes();
|
|
964
978
|
|
|
965
979
|
const {body, produceResult, executionPayloadValue, shouldOverrideBuilder} = await produceBlockBody.call(
|
|
@@ -981,7 +995,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
981
995
|
// The hashtree root computed here for debug log will get cached and hence won't introduce additional delays
|
|
982
996
|
const bodyRoot =
|
|
983
997
|
produceResult.type === BlockType.Full
|
|
984
|
-
?
|
|
998
|
+
? this.config.getForkTypes(slot).BeaconBlockBody.hashTreeRoot(body)
|
|
985
999
|
: this.config
|
|
986
1000
|
.getPostBellatrixForkTypes(slot)
|
|
987
1001
|
.BlindedBeaconBlockBody.hashTreeRoot(body as BlindedBeaconBlockBody);
|
|
@@ -1003,10 +1017,11 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1003
1017
|
block.stateRoot = newStateRoot;
|
|
1004
1018
|
const blockRoot =
|
|
1005
1019
|
produceResult.type === BlockType.Full
|
|
1006
|
-
?
|
|
1020
|
+
? this.config.getForkTypes(slot).BeaconBlock.hashTreeRoot(block)
|
|
1007
1021
|
: this.config.getPostBellatrixForkTypes(slot).BlindedBeaconBlock.hashTreeRoot(block as BlindedBeaconBlock);
|
|
1008
1022
|
const blockRootHex = toRootHex(blockRoot);
|
|
1009
1023
|
|
|
1024
|
+
const fork = this.config.getForkName(slot);
|
|
1010
1025
|
if (isForkPostGloas(fork)) {
|
|
1011
1026
|
// TODO GLOAS: we should retire BlockType post-gloas, may need a new enum for self vs non-self built
|
|
1012
1027
|
if (produceResult.type !== BlockType.Full) {
|
|
@@ -1022,7 +1037,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1022
1037
|
slot,
|
|
1023
1038
|
stateRoot: ZERO_HASH,
|
|
1024
1039
|
};
|
|
1025
|
-
const envelopeStateRoot = computeEnvelopeStateRoot(this.metrics, postState
|
|
1040
|
+
const envelopeStateRoot = computeEnvelopeStateRoot(this.metrics, postState, envelope);
|
|
1026
1041
|
gloasResult.envelopeStateRoot = envelopeStateRoot;
|
|
1027
1042
|
}
|
|
1028
1043
|
|
|
@@ -1143,8 +1158,8 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1143
1158
|
* persist preState, postState and block for further investigation.
|
|
1144
1159
|
*/
|
|
1145
1160
|
async persistInvalidStateRoot(
|
|
1146
|
-
preState:
|
|
1147
|
-
postState:
|
|
1161
|
+
preState: IBeaconStateView,
|
|
1162
|
+
postState: IBeaconStateView,
|
|
1148
1163
|
block: SignedBeaconBlock
|
|
1149
1164
|
): Promise<void> {
|
|
1150
1165
|
const blockSlot = block.message.slot;
|
|
@@ -1159,13 +1174,13 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1159
1174
|
`${logStr}_block`
|
|
1160
1175
|
),
|
|
1161
1176
|
this.persistSszObject(
|
|
1162
|
-
`preState_slot_${preState.slot}
|
|
1177
|
+
`preState_slot_${preState.slot}_BeaconState`,
|
|
1163
1178
|
preState.serialize(),
|
|
1164
1179
|
preState.hashTreeRoot(),
|
|
1165
1180
|
`${logStr}_pre_state`
|
|
1166
1181
|
),
|
|
1167
1182
|
this.persistSszObject(
|
|
1168
|
-
`postState_slot_${postState.slot}
|
|
1183
|
+
`postState_slot_${postState.slot}_BeaconState`,
|
|
1169
1184
|
postState.serialize(),
|
|
1170
1185
|
postState.hashTreeRoot(),
|
|
1171
1186
|
`${logStr}_post_state`
|
|
@@ -1185,12 +1200,6 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1185
1200
|
}
|
|
1186
1201
|
}
|
|
1187
1202
|
|
|
1188
|
-
persistInvalidSszView(view: TreeView<CompositeTypeAny>, suffix?: string): void {
|
|
1189
|
-
if (this.opts.persistInvalidSszObjects) {
|
|
1190
|
-
void this.persistSszObject(view.type.typeName, view.serialize(), view.hashTreeRoot(), suffix);
|
|
1191
|
-
}
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
1203
|
/**
|
|
1195
1204
|
* Regenerate state for attestation verification, this does not happen with default chain option of maxSkipSlots = 32 .
|
|
1196
1205
|
* However, need to handle just in case. Lodestar doesn't support multiple regen state requests for attestation verification
|
|
@@ -1208,7 +1217,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1208
1217
|
this.shufflingCache.insertPromise(attEpoch, shufflingDependentRoot);
|
|
1209
1218
|
const blockEpoch = computeEpochAtSlot(attHeadBlock.slot);
|
|
1210
1219
|
|
|
1211
|
-
let state:
|
|
1220
|
+
let state: IBeaconStateView;
|
|
1212
1221
|
if (blockEpoch < attEpoch - 1) {
|
|
1213
1222
|
// thanks to one epoch look ahead, we don't need to dial up to attEpoch
|
|
1214
1223
|
const targetSlot = computeStartSlotAtEpoch(attEpoch - 1);
|
|
@@ -1226,7 +1235,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1226
1235
|
}
|
|
1227
1236
|
// resolve the promise to unblock other calls of the same epoch and dependent root
|
|
1228
1237
|
this.shufflingCache.processState(state);
|
|
1229
|
-
return state.
|
|
1238
|
+
return state.getShufflingAtEpoch(attEpoch);
|
|
1230
1239
|
}
|
|
1231
1240
|
|
|
1232
1241
|
/**
|
|
@@ -1236,7 +1245,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1236
1245
|
*/
|
|
1237
1246
|
private justifiedBalancesGetter(
|
|
1238
1247
|
checkpoint: CheckpointWithPayloadStatus,
|
|
1239
|
-
blockState:
|
|
1248
|
+
blockState: IBeaconStateView
|
|
1240
1249
|
): EffectiveBalanceIncrements {
|
|
1241
1250
|
this.metrics?.balancesCache.requests.inc();
|
|
1242
1251
|
|
|
@@ -1263,7 +1272,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1263
1272
|
});
|
|
1264
1273
|
}
|
|
1265
1274
|
|
|
1266
|
-
return getEffectiveBalanceIncrementsZeroInactive(
|
|
1275
|
+
return state.getEffectiveBalanceIncrementsZeroInactive();
|
|
1267
1276
|
}
|
|
1268
1277
|
|
|
1269
1278
|
/**
|
|
@@ -1275,8 +1284,8 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1275
1284
|
*/
|
|
1276
1285
|
private closestJustifiedBalancesStateToCheckpoint(
|
|
1277
1286
|
checkpoint: CheckpointWithPayloadStatus,
|
|
1278
|
-
blockState:
|
|
1279
|
-
): {state:
|
|
1287
|
+
blockState: IBeaconStateView
|
|
1288
|
+
): {state: IBeaconStateView; stateId: string; shouldWarn: boolean} {
|
|
1280
1289
|
const checkpointHexPayload = fcCheckpointToHexPayload(checkpoint);
|
|
1281
1290
|
const state = this.regen.getCheckpointStateSync(checkpointHexPayload);
|
|
1282
1291
|
if (state) {
|
|
@@ -1359,10 +1368,9 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1359
1368
|
const fork = this.config.getForkName(headState.slot);
|
|
1360
1369
|
|
|
1361
1370
|
if (isForkPostElectra(fork)) {
|
|
1362
|
-
|
|
1363
|
-
metrics.
|
|
1364
|
-
metrics.
|
|
1365
|
-
metrics.pendingConsolidations.set(headStateElectra.pendingConsolidations.length);
|
|
1371
|
+
metrics.pendingDeposits.set(headState.pendingDepositsCount);
|
|
1372
|
+
metrics.pendingPartialWithdrawals.set(headState.pendingPartialWithdrawalsCount);
|
|
1373
|
+
metrics.pendingConsolidations.set(headState.pendingConsolidationsCount);
|
|
1366
1374
|
}
|
|
1367
1375
|
}
|
|
1368
1376
|
|
|
@@ -1426,7 +1434,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1426
1434
|
this.logger.verbose("Fork choice justified", {epoch: cp.epoch, root: cp.rootHex});
|
|
1427
1435
|
}
|
|
1428
1436
|
|
|
1429
|
-
private onCheckpoint(this: BeaconChain, _checkpoint: phase0.Checkpoint, state:
|
|
1437
|
+
private onCheckpoint(this: BeaconChain, _checkpoint: phase0.Checkpoint, state: IBeaconStateView): void {
|
|
1430
1438
|
// Defer to not block other checkpoint event handlers, which can cause lightclient update delays
|
|
1431
1439
|
callInNextEventLoop(() => {
|
|
1432
1440
|
this.shufflingCache.processState(state);
|
|
@@ -1512,7 +1520,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1512
1520
|
if (stateOrBytes instanceof Uint8Array) {
|
|
1513
1521
|
effectiveBalances = getEffectiveBalancesFromStateBytes(this.config, stateOrBytes, validatorIndices);
|
|
1514
1522
|
} else {
|
|
1515
|
-
effectiveBalances = validatorIndices.map((index) => stateOrBytes.
|
|
1523
|
+
effectiveBalances = validatorIndices.map((index) => stateOrBytes.getValidator(index).effectiveBalance ?? 0);
|
|
1516
1524
|
}
|
|
1517
1525
|
}
|
|
1518
1526
|
|
|
@@ -1562,11 +1570,11 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1562
1570
|
throw Error(`Pre-state is unavailable given block's parent root ${toRootHex(block.parentRoot)}`);
|
|
1563
1571
|
}
|
|
1564
1572
|
|
|
1565
|
-
preState = processSlots(
|
|
1573
|
+
preState = preState.processSlots(block.slot); // Dial preState's slot to block.slot
|
|
1566
1574
|
|
|
1567
1575
|
const proposerRewards = this.regen.getStateSync(toRootHex(block.stateRoot))?.proposerRewards ?? undefined;
|
|
1568
1576
|
|
|
1569
|
-
return computeBlockRewards(
|
|
1577
|
+
return preState.computeBlockRewards(block, proposerRewards);
|
|
1570
1578
|
}
|
|
1571
1579
|
|
|
1572
1580
|
async getAttestationsRewards(
|
|
@@ -1590,7 +1598,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1590
1598
|
throw Error(`State is not in cache for slot ${slot}`);
|
|
1591
1599
|
}
|
|
1592
1600
|
|
|
1593
|
-
const rewards = await computeAttestationsRewards(
|
|
1601
|
+
const rewards = await cachedState.computeAttestationsRewards(validatorIds);
|
|
1594
1602
|
|
|
1595
1603
|
return {rewards, executionOptimistic, finalized};
|
|
1596
1604
|
}
|
|
@@ -1605,8 +1613,8 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1605
1613
|
throw Error(`Pre-state is unavailable given block's parent root ${toRootHex(block.parentRoot)}`);
|
|
1606
1614
|
}
|
|
1607
1615
|
|
|
1608
|
-
preState = processSlots(
|
|
1616
|
+
preState = preState.processSlots(block.slot); // Dial preState's slot to block.slot
|
|
1609
1617
|
|
|
1610
|
-
return computeSyncCommitteeRewards(
|
|
1618
|
+
return preState.computeSyncCommitteeRewards(block, validatorIds ?? []);
|
|
1611
1619
|
}
|
|
1612
1620
|
}
|
package/src/chain/emitter.ts
CHANGED
|
@@ -2,7 +2,7 @@ import {EventEmitter} from "node:events";
|
|
|
2
2
|
import {StrictEventEmitter} from "strict-event-emitter-types";
|
|
3
3
|
import {routes} from "@lodestar/api";
|
|
4
4
|
import {CheckpointWithPayloadStatus} from "@lodestar/fork-choice";
|
|
5
|
-
import {
|
|
5
|
+
import {IBeaconStateView} from "@lodestar/state-transition";
|
|
6
6
|
import {DataColumnSidecars, RootHex, deneb, phase0} from "@lodestar/types";
|
|
7
7
|
import {PeerIdStr} from "../util/peerId.js";
|
|
8
8
|
import {BlockInputSource, IBlockInput} from "./blocks/blockInput/types.js";
|
|
@@ -81,7 +81,7 @@ export type ChainEventData = {
|
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
export type IChainEvents = ApiEvents & {
|
|
84
|
-
[ChainEvent.checkpoint]: (checkpoint: phase0.Checkpoint, state:
|
|
84
|
+
[ChainEvent.checkpoint]: (checkpoint: phase0.Checkpoint, state: IBeaconStateView) => void;
|
|
85
85
|
|
|
86
86
|
[ChainEvent.forkChoiceJustified]: (checkpoint: CheckpointWithPayloadStatus) => void;
|
|
87
87
|
[ChainEvent.forkChoiceFinalized]: (checkpoint: CheckpointWithPayloadStatus) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {IBeaconStateView} from "@lodestar/state-transition";
|
|
2
2
|
import {RootHex, SignedBeaconBlock, Slot, ValidatorIndex} from "@lodestar/types";
|
|
3
3
|
import {LodestarError, toRootHex} from "@lodestar/utils";
|
|
4
4
|
import {ExecutionPayloadStatus} from "../../execution/engine/interface.js";
|
|
@@ -91,13 +91,13 @@ export type BlockErrorType =
|
|
|
91
91
|
| {code: BlockErrorCode.INCORRECT_PROPOSER; proposerIndex: ValidatorIndex}
|
|
92
92
|
| {code: BlockErrorCode.PROPOSAL_SIGNATURE_INVALID; blockSlot: Slot}
|
|
93
93
|
| {code: BlockErrorCode.UNKNOWN_PROPOSER; proposerIndex: ValidatorIndex}
|
|
94
|
-
| {code: BlockErrorCode.INVALID_SIGNATURE; state:
|
|
94
|
+
| {code: BlockErrorCode.INVALID_SIGNATURE; state: IBeaconStateView}
|
|
95
95
|
| {
|
|
96
96
|
code: BlockErrorCode.INVALID_STATE_ROOT;
|
|
97
97
|
root: Uint8Array;
|
|
98
98
|
expectedRoot: Uint8Array;
|
|
99
|
-
preState:
|
|
100
|
-
postState:
|
|
99
|
+
preState: IBeaconStateView;
|
|
100
|
+
postState: IBeaconStateView;
|
|
101
101
|
}
|
|
102
102
|
| {code: BlockErrorCode.NOT_FINALIZED_DESCENDANT; parentRoot: RootHex}
|
|
103
103
|
| {code: BlockErrorCode.NOT_LATER_THAN_PARENT; parentSlot: Slot; slot: Slot}
|
|
@@ -10,18 +10,12 @@ import {
|
|
|
10
10
|
ForkChoiceOpts as RawForkChoiceOpts,
|
|
11
11
|
getCheckpointPayloadStatus,
|
|
12
12
|
} from "@lodestar/fork-choice";
|
|
13
|
-
import {ZERO_HASH_HEX} from "@lodestar/params";
|
|
13
|
+
import {ForkSeq, ZERO_HASH_HEX} from "@lodestar/params";
|
|
14
14
|
import {
|
|
15
|
-
CachedBeaconStateAllForks,
|
|
16
|
-
CachedBeaconStateGloas,
|
|
17
15
|
DataAvailabilityStatus,
|
|
18
|
-
|
|
16
|
+
IBeaconStateView,
|
|
19
17
|
computeEpochAtSlot,
|
|
20
18
|
computeStartSlotAtEpoch,
|
|
21
|
-
getBlockRootAtSlot,
|
|
22
|
-
getEffectiveBalanceIncrementsZeroInactive,
|
|
23
|
-
isExecutionStateType,
|
|
24
|
-
isMergeTransitionComplete,
|
|
25
19
|
} from "@lodestar/state-transition";
|
|
26
20
|
import {Slot, ssz} from "@lodestar/types";
|
|
27
21
|
import {Logger, toRootHex} from "@lodestar/utils";
|
|
@@ -46,7 +40,7 @@ export function initializeForkChoice(
|
|
|
46
40
|
config: ChainForkConfig,
|
|
47
41
|
emitter: ChainEventEmitter,
|
|
48
42
|
currentSlot: Slot,
|
|
49
|
-
state:
|
|
43
|
+
state: IBeaconStateView,
|
|
50
44
|
isFinalizedState: boolean,
|
|
51
45
|
opts: ForkChoiceOpts,
|
|
52
46
|
justifiedBalancesGetter: JustifiedBalancesGetter,
|
|
@@ -83,13 +77,13 @@ export function initializeForkChoiceFromFinalizedState(
|
|
|
83
77
|
config: ChainForkConfig,
|
|
84
78
|
emitter: ChainEventEmitter,
|
|
85
79
|
currentSlot: Slot,
|
|
86
|
-
state:
|
|
80
|
+
state: IBeaconStateView,
|
|
87
81
|
opts: ForkChoiceOpts,
|
|
88
82
|
justifiedBalancesGetter: JustifiedBalancesGetter,
|
|
89
83
|
metrics: Metrics | null,
|
|
90
84
|
logger?: Logger
|
|
91
85
|
): ForkChoice {
|
|
92
|
-
const {blockHeader, checkpoint} = computeAnchorCheckpoint(
|
|
86
|
+
const {blockHeader, checkpoint} = state.computeAnchorCheckpoint();
|
|
93
87
|
const finalizedCheckpoint = {...checkpoint};
|
|
94
88
|
const justifiedCheckpoint = {
|
|
95
89
|
...checkpoint,
|
|
@@ -100,19 +94,19 @@ export function initializeForkChoiceFromFinalizedState(
|
|
|
100
94
|
epoch: checkpoint.epoch === 0 ? checkpoint.epoch : checkpoint.epoch + 1,
|
|
101
95
|
};
|
|
102
96
|
|
|
103
|
-
const justifiedBalances = getEffectiveBalanceIncrementsZeroInactive(
|
|
97
|
+
const justifiedBalances = state.getEffectiveBalanceIncrementsZeroInactive();
|
|
104
98
|
|
|
105
99
|
// forkchoiceConstructor is only used for some test cases
|
|
106
100
|
// production code use ForkChoice constructor directly
|
|
107
101
|
const forkchoiceConstructor = opts.forkchoiceConstructor ?? ForkChoice;
|
|
108
102
|
|
|
109
|
-
const isForkPostGloas = (state
|
|
103
|
+
const isForkPostGloas = computeEpochAtSlot(state.slot) >= config.GLOAS_FORK_EPOCH;
|
|
110
104
|
|
|
111
105
|
// Determine justified checkpoint payload status
|
|
112
|
-
const justifiedPayloadStatus = getCheckpointPayloadStatus(state, justifiedCheckpoint.epoch);
|
|
106
|
+
const justifiedPayloadStatus = getCheckpointPayloadStatus(config, state, justifiedCheckpoint.epoch);
|
|
113
107
|
|
|
114
108
|
// Determine finalized checkpoint payload status
|
|
115
|
-
const finalizedPayloadStatus = getCheckpointPayloadStatus(state, finalizedCheckpoint.epoch);
|
|
109
|
+
const finalizedPayloadStatus = getCheckpointPayloadStatus(config, state, finalizedCheckpoint.epoch);
|
|
116
110
|
|
|
117
111
|
return new forkchoiceConstructor(
|
|
118
112
|
config,
|
|
@@ -148,21 +142,23 @@ export function initializeForkChoiceFromFinalizedState(
|
|
|
148
142
|
unrealizedFinalizedEpoch: finalizedCheckpoint.epoch,
|
|
149
143
|
unrealizedFinalizedRoot: toRootHex(finalizedCheckpoint.root),
|
|
150
144
|
|
|
151
|
-
...(isExecutionStateType
|
|
145
|
+
...(state.isExecutionStateType && state.isMergeTransitionComplete
|
|
152
146
|
? {
|
|
153
|
-
executionPayloadBlockHash: toRootHex(state.
|
|
154
|
-
|
|
147
|
+
executionPayloadBlockHash: toRootHex(state.latestBlockHash),
|
|
148
|
+
// TODO GLOAS: executionPayloadNumber is not tracked in BeaconState post-gloas (EIP-7732 removed
|
|
149
|
+
// latestExecutionPayloadHeader). Using 0 as unavailable fallback until a solution is found.
|
|
150
|
+
executionPayloadNumber: config.getForkSeq(state.slot) >= ForkSeq.gloas ? 0 : state.payloadBlockNumber,
|
|
155
151
|
executionStatus: blockHeader.slot === GENESIS_SLOT ? ExecutionStatus.Valid : ExecutionStatus.Syncing,
|
|
156
152
|
}
|
|
157
153
|
: {executionPayloadBlockHash: null, executionStatus: ExecutionStatus.PreMerge}),
|
|
158
154
|
|
|
159
155
|
dataAvailabilityStatus: DataAvailabilityStatus.PreData,
|
|
160
156
|
payloadStatus: isForkPostGloas ? PayloadStatus.PENDING : PayloadStatus.FULL, // TODO GLOAS: Post-gloas how do we know if the checkpoint payload is FULL or EMPTY?
|
|
161
|
-
parentBlockHash: isForkPostGloas ? toRootHex(
|
|
157
|
+
parentBlockHash: isForkPostGloas ? toRootHex(state.latestBlockHash) : null,
|
|
162
158
|
},
|
|
163
159
|
currentSlot
|
|
164
160
|
),
|
|
165
|
-
state.
|
|
161
|
+
state.validatorCount,
|
|
166
162
|
metrics,
|
|
167
163
|
opts,
|
|
168
164
|
logger
|
|
@@ -176,15 +172,15 @@ export function initializeForkChoiceFromUnfinalizedState(
|
|
|
176
172
|
config: ChainForkConfig,
|
|
177
173
|
emitter: ChainEventEmitter,
|
|
178
174
|
currentSlot: Slot,
|
|
179
|
-
unfinalizedState:
|
|
175
|
+
unfinalizedState: IBeaconStateView,
|
|
180
176
|
opts: ForkChoiceOpts,
|
|
181
177
|
justifiedBalancesGetter: JustifiedBalancesGetter,
|
|
182
178
|
metrics: Metrics | null,
|
|
183
179
|
logger?: Logger
|
|
184
180
|
): ForkChoice {
|
|
185
|
-
const {blockHeader} = computeAnchorCheckpoint(
|
|
186
|
-
const finalizedCheckpoint = unfinalizedState.finalizedCheckpoint
|
|
187
|
-
const justifiedCheckpoint = unfinalizedState.currentJustifiedCheckpoint
|
|
181
|
+
const {blockHeader} = unfinalizedState.computeAnchorCheckpoint();
|
|
182
|
+
const finalizedCheckpoint = unfinalizedState.finalizedCheckpoint;
|
|
183
|
+
const justifiedCheckpoint = unfinalizedState.currentJustifiedCheckpoint;
|
|
188
184
|
const headRoot = toRootHex(ssz.phase0.BeaconBlockHeader.hashTreeRoot(blockHeader));
|
|
189
185
|
|
|
190
186
|
const logCtx = {
|
|
@@ -200,14 +196,14 @@ export function initializeForkChoiceFromUnfinalizedState(
|
|
|
200
196
|
logger?.warn("Initializing fork choice from unfinalized state", logCtx);
|
|
201
197
|
|
|
202
198
|
// this is not the justified state, but there is no other ways to get justified balances
|
|
203
|
-
const justifiedBalances = getEffectiveBalanceIncrementsZeroInactive(
|
|
199
|
+
const justifiedBalances = unfinalizedState.getEffectiveBalanceIncrementsZeroInactive();
|
|
204
200
|
|
|
205
|
-
const isForkPostGloas = (unfinalizedState
|
|
201
|
+
const isForkPostGloas = computeEpochAtSlot(unfinalizedState.slot) >= config.GLOAS_FORK_EPOCH;
|
|
206
202
|
|
|
207
203
|
// For unfinalized state, use getCheckpointPayloadStatus to determine the correct status.
|
|
208
204
|
// It checks state.execution_payload_availability to determine EMPTY vs FULL.
|
|
209
|
-
const justifiedPayloadStatus = getCheckpointPayloadStatus(unfinalizedState, justifiedCheckpoint.epoch);
|
|
210
|
-
const finalizedPayloadStatus = getCheckpointPayloadStatus(unfinalizedState, finalizedCheckpoint.epoch);
|
|
205
|
+
const justifiedPayloadStatus = getCheckpointPayloadStatus(config, unfinalizedState, justifiedCheckpoint.epoch);
|
|
206
|
+
const finalizedPayloadStatus = getCheckpointPayloadStatus(config, unfinalizedState, finalizedCheckpoint.epoch);
|
|
211
207
|
|
|
212
208
|
const store = new ForkChoiceStore(
|
|
213
209
|
currentSlot,
|
|
@@ -241,17 +237,20 @@ export function initializeForkChoiceFromUnfinalizedState(
|
|
|
241
237
|
unrealizedFinalizedEpoch: finalizedCheckpoint.epoch,
|
|
242
238
|
unrealizedFinalizedRoot: toRootHex(finalizedCheckpoint.root),
|
|
243
239
|
|
|
244
|
-
...(isExecutionStateType
|
|
240
|
+
...(unfinalizedState.isExecutionStateType && unfinalizedState.isMergeTransitionComplete
|
|
245
241
|
? {
|
|
246
|
-
executionPayloadBlockHash: toRootHex(unfinalizedState.
|
|
247
|
-
|
|
242
|
+
executionPayloadBlockHash: toRootHex(unfinalizedState.latestBlockHash),
|
|
243
|
+
// TODO GLOAS: executionPayloadNumber is not tracked in BeaconState post-gloas (EIP-7732 removed
|
|
244
|
+
// latestExecutionPayloadHeader). Using 0 as unavailable fallback until a solution is found.
|
|
245
|
+
executionPayloadNumber:
|
|
246
|
+
config.getForkSeq(unfinalizedState.slot) >= ForkSeq.gloas ? 0 : unfinalizedState.payloadBlockNumber,
|
|
248
247
|
executionStatus: blockHeader.slot === GENESIS_SLOT ? ExecutionStatus.Valid : ExecutionStatus.Syncing,
|
|
249
248
|
}
|
|
250
249
|
: {executionPayloadBlockHash: null, executionStatus: ExecutionStatus.PreMerge}),
|
|
251
250
|
|
|
252
251
|
dataAvailabilityStatus: DataAvailabilityStatus.PreData,
|
|
253
252
|
payloadStatus: isForkPostGloas ? PayloadStatus.PENDING : PayloadStatus.FULL, // TODO GLOAS: Post-gloas how do we know if the checkpoint payload is FULL or EMPTY?
|
|
254
|
-
parentBlockHash: isForkPostGloas ? toRootHex(
|
|
253
|
+
parentBlockHash: isForkPostGloas ? toRootHex(unfinalizedState.latestBlockHash) : null,
|
|
255
254
|
};
|
|
256
255
|
|
|
257
256
|
const parentSlot = blockHeader.slot - 1;
|
|
@@ -265,7 +264,7 @@ export function initializeForkChoiceFromUnfinalizedState(
|
|
|
265
264
|
// dummy data, we're not able to regen state before headBlock
|
|
266
265
|
stateRoot: ZERO_HASH_HEX,
|
|
267
266
|
blockRoot: headBlock.parentRoot,
|
|
268
|
-
targetRoot: toRootHex(getBlockRootAtSlot(
|
|
267
|
+
targetRoot: toRootHex(unfinalizedState.getBlockRootAtSlot(computeStartSlotAtEpoch(parentEpoch))),
|
|
269
268
|
};
|
|
270
269
|
|
|
271
270
|
const justifiedBlock: ProtoBlock = {
|
|
@@ -303,13 +302,5 @@ export function initializeForkChoiceFromUnfinalizedState(
|
|
|
303
302
|
// production code use ForkChoice constructor directly
|
|
304
303
|
const forkchoiceConstructor = opts.forkchoiceConstructor ?? ForkChoice;
|
|
305
304
|
|
|
306
|
-
return new forkchoiceConstructor(
|
|
307
|
-
config,
|
|
308
|
-
store,
|
|
309
|
-
protoArray,
|
|
310
|
-
unfinalizedState.validators.length,
|
|
311
|
-
metrics,
|
|
312
|
-
opts,
|
|
313
|
-
logger
|
|
314
|
-
);
|
|
305
|
+
return new forkchoiceConstructor(config, store, protoArray, unfinalizedState.validatorCount, metrics, opts, logger);
|
|
315
306
|
}
|
package/src/chain/initState.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import {ChainForkConfig} from "@lodestar/config";
|
|
2
2
|
import {ZERO_HASH} from "@lodestar/params";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
BeaconStateAllForks,
|
|
5
|
+
IBeaconStateView,
|
|
6
|
+
computeEpochAtSlot,
|
|
7
|
+
computeStartSlotAtEpoch,
|
|
8
|
+
} from "@lodestar/state-transition";
|
|
4
9
|
import {SignedBeaconBlock, ssz} from "@lodestar/types";
|
|
5
10
|
import {Logger, byteArrayEquals, toHex, toRootHex} from "@lodestar/utils";
|
|
6
11
|
import {GENESIS_SLOT} from "../constants/index.js";
|
|
@@ -119,7 +124,7 @@ export async function checkAndPersistAnchorState(
|
|
|
119
124
|
}
|
|
120
125
|
}
|
|
121
126
|
|
|
122
|
-
export function initBeaconMetrics(metrics: Metrics, state:
|
|
127
|
+
export function initBeaconMetrics(metrics: Metrics, state: IBeaconStateView): void {
|
|
123
128
|
metrics.headSlot.set(state.slot);
|
|
124
129
|
metrics.previousJustifiedEpoch.set(state.previousJustifiedCheckpoint.epoch);
|
|
125
130
|
metrics.currentJustifiedEpoch.set(state.currentJustifiedCheckpoint.epoch);
|