@lodestar/beacon-node 1.42.0-dev.d73eccfa56 → 1.42.0-dev.ed2323ce4f
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/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
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import {routes} from "@lodestar/api";
|
|
2
2
|
import {BeaconConfig} from "@lodestar/config";
|
|
3
3
|
import {CheckpointWithPayloadStatus} from "@lodestar/fork-choice";
|
|
4
|
-
import {
|
|
5
|
-
CachedBeaconStateAllForks,
|
|
6
|
-
computeStartSlotAtEpoch,
|
|
7
|
-
getBlockRootAtSlot,
|
|
8
|
-
loadCachedBeaconState,
|
|
9
|
-
} from "@lodestar/state-transition";
|
|
4
|
+
import {IBeaconStateView, computeStartSlotAtEpoch} from "@lodestar/state-transition";
|
|
10
5
|
import {Epoch, RootHex, phase0} from "@lodestar/types";
|
|
11
6
|
import {Logger, MapDef, fromHex, sleep, toHex, toRootHex} from "@lodestar/utils";
|
|
12
7
|
import {Metrics} from "../../metrics/index.js";
|
|
@@ -40,7 +35,7 @@ type CacheKey = string;
|
|
|
40
35
|
|
|
41
36
|
type InMemoryCacheItem = {
|
|
42
37
|
type: CacheItemType.inMemory;
|
|
43
|
-
state:
|
|
38
|
+
state: IBeaconStateView;
|
|
44
39
|
// if a cp state is reloaded from disk, it'll keep track of persistedKey to allow us to remove it from disk later
|
|
45
40
|
// it also helps not to persist it again
|
|
46
41
|
persistedKey?: DatastoreKey;
|
|
@@ -220,9 +215,9 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
220
215
|
* - Get block for processing
|
|
221
216
|
* - Regen head state
|
|
222
217
|
*/
|
|
223
|
-
async getOrReload(cp: CheckpointHexPayload): Promise<
|
|
218
|
+
async getOrReload(cp: CheckpointHexPayload): Promise<IBeaconStateView | null> {
|
|
224
219
|
const stateOrStateBytesData = await this.getStateOrLoadDb(cp);
|
|
225
|
-
if (stateOrStateBytesData === null ||
|
|
220
|
+
if (stateOrStateBytesData === null || isBeaconStateView(stateOrStateBytesData)) {
|
|
226
221
|
return stateOrStateBytesData ?? null;
|
|
227
222
|
}
|
|
228
223
|
const {persistedKey, stateBytes} = stateOrStateBytesData;
|
|
@@ -237,7 +232,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
237
232
|
this.clock?.secFromSlot(this.clock?.currentSlot ?? 0) ?? 0
|
|
238
233
|
);
|
|
239
234
|
const seedState = this.findSeedStateToReload(cp);
|
|
240
|
-
this.metrics?.cpStateCache.stateReloadEpochDiff.observe(Math.abs(seedState.
|
|
235
|
+
this.metrics?.cpStateCache.stateReloadEpochDiff.observe(Math.abs(seedState.epoch - cp.epoch));
|
|
241
236
|
this.logger.debug("Reload: found seed state", {...logMeta, seedSlot: seedState.slot});
|
|
242
237
|
|
|
243
238
|
try {
|
|
@@ -249,19 +244,16 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
249
244
|
if (validatorsBytes == null) {
|
|
250
245
|
// fallback logic in case we can't use the buffer pool
|
|
251
246
|
this.metrics?.cpStateCache.stateReloadValidatorsSerializeAllocCount.inc();
|
|
252
|
-
validatorsBytes = seedState.
|
|
247
|
+
validatorsBytes = seedState.serializeValidators();
|
|
253
248
|
}
|
|
254
249
|
sszTimer?.();
|
|
255
250
|
const timer = this.metrics?.cpStateCache.stateReloadDuration.startTimer();
|
|
256
|
-
const newCachedState =
|
|
251
|
+
const newCachedState = seedState.loadOtherState(stateBytes, validatorsBytes);
|
|
257
252
|
// hashTreeRoot() calls the commit() inside
|
|
258
253
|
// there is no modification inside the state, it's just that we want to compute and cache all roots
|
|
259
254
|
const stateRoot = toRootHex(newCachedState.hashTreeRoot());
|
|
260
255
|
timer?.();
|
|
261
256
|
|
|
262
|
-
// load all cache in order for consumers (usually regen.getState()) to process blocks faster
|
|
263
|
-
newCachedState.validators.getAllReadonlyValues();
|
|
264
|
-
newCachedState.balances.getAll();
|
|
265
257
|
this.logger.debug("Reload: cached state load successful", {
|
|
266
258
|
...logMeta,
|
|
267
259
|
stateSlot: newCachedState.slot,
|
|
@@ -284,9 +276,9 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
284
276
|
/**
|
|
285
277
|
* Return either state or state bytes loaded from db.
|
|
286
278
|
*/
|
|
287
|
-
async getStateOrBytes(cp: CheckpointHexPayload): Promise<
|
|
279
|
+
async getStateOrBytes(cp: CheckpointHexPayload): Promise<IBeaconStateView | Uint8Array | null> {
|
|
288
280
|
const stateOrLoadedState = await this.getStateOrLoadDb(cp);
|
|
289
|
-
if (stateOrLoadedState === null ||
|
|
281
|
+
if (stateOrLoadedState === null || isBeaconStateView(stateOrLoadedState)) {
|
|
290
282
|
return stateOrLoadedState;
|
|
291
283
|
}
|
|
292
284
|
return stateOrLoadedState.stateBytes;
|
|
@@ -295,7 +287,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
295
287
|
/**
|
|
296
288
|
* Return either state or state bytes with persisted key loaded from db.
|
|
297
289
|
*/
|
|
298
|
-
async getStateOrLoadDb(cp: CheckpointHexPayload): Promise<
|
|
290
|
+
async getStateOrLoadDb(cp: CheckpointHexPayload): Promise<IBeaconStateView | LoadedStateBytesData | null> {
|
|
299
291
|
const cpKey = toCacheKey(cp);
|
|
300
292
|
const inMemoryState = this.get(cpKey);
|
|
301
293
|
if (inMemoryState) {
|
|
@@ -326,7 +318,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
326
318
|
/**
|
|
327
319
|
* Similar to get() api without reloading from disk
|
|
328
320
|
*/
|
|
329
|
-
get(cpOrKey: CheckpointHexPayload | CacheKey):
|
|
321
|
+
get(cpOrKey: CheckpointHexPayload | CacheKey): IBeaconStateView | null {
|
|
330
322
|
this.metrics?.cpStateCache.lookups.inc();
|
|
331
323
|
const cpKey = typeof cpOrKey === "string" ? cpOrKey : toCacheKey(cpOrKey);
|
|
332
324
|
const cacheItem = this.cache.get(cpKey);
|
|
@@ -355,7 +347,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
355
347
|
* @param payloadPresent - For Gloas: true if this is payload state, false if block state.
|
|
356
348
|
* Always true for pre-Gloas.
|
|
357
349
|
*/
|
|
358
|
-
add(cp: phase0.Checkpoint, state:
|
|
350
|
+
add(cp: phase0.Checkpoint, state: IBeaconStateView, payloadPresent: boolean): void {
|
|
359
351
|
const cpHex = toCheckpointHexPayload(cp, payloadPresent);
|
|
360
352
|
const key = toCacheKey(cpHex);
|
|
361
353
|
const cacheItem = this.cache.get(key);
|
|
@@ -385,7 +377,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
385
377
|
/**
|
|
386
378
|
* Searches in-memory state for the latest cached state with a `root` without reload, starting with `epoch` and descending
|
|
387
379
|
*/
|
|
388
|
-
getLatest(rootHex: RootHex, maxEpoch: Epoch, payloadPresent: boolean):
|
|
380
|
+
getLatest(rootHex: RootHex, maxEpoch: Epoch, payloadPresent: boolean): IBeaconStateView | null {
|
|
389
381
|
// sort epochs in descending order, only consider epochs lte `epoch`
|
|
390
382
|
const epochs = Array.from(this.epochIndex.keys())
|
|
391
383
|
.sort((a, b) => b - a)
|
|
@@ -412,7 +404,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
412
404
|
rootHex: RootHex,
|
|
413
405
|
maxEpoch: Epoch,
|
|
414
406
|
payloadPresent: boolean
|
|
415
|
-
): Promise<
|
|
407
|
+
): Promise<IBeaconStateView | null> {
|
|
416
408
|
// sort epochs in descending order, only consider epochs lte `epoch`
|
|
417
409
|
const epochs = Array.from(this.epochIndex.keys())
|
|
418
410
|
.sort((a, b) => b - a)
|
|
@@ -518,7 +510,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
518
510
|
* For Gloas: Processes both block state and payload state variants together. The decision of which roots to persist/prune
|
|
519
511
|
* is based on root canonicality (from state's view), not payload presence. Both variants are managed as a unit.
|
|
520
512
|
*/
|
|
521
|
-
async processState(blockRootHex: RootHex, state:
|
|
513
|
+
async processState(blockRootHex: RootHex, state: IBeaconStateView): Promise<number> {
|
|
522
514
|
let persistCount = 0;
|
|
523
515
|
// it's important to sort the epochs in ascending order, in case of big reorg we always want to keep the most recent checkpoint states
|
|
524
516
|
const sortedEpochs = Array.from(this.epochIndex.keys()).sort((a, b) => a - b);
|
|
@@ -587,10 +579,10 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
587
579
|
*
|
|
588
580
|
* Use seed state from the block cache if cannot find any seed states within this cache.
|
|
589
581
|
*/
|
|
590
|
-
findSeedStateToReload(reloadedCp: CheckpointHexPayload):
|
|
582
|
+
findSeedStateToReload(reloadedCp: CheckpointHexPayload): IBeaconStateView {
|
|
591
583
|
const maxEpoch = Math.max(...Array.from(this.epochIndex.keys()));
|
|
592
584
|
const reloadedCpSlot = computeStartSlotAtEpoch(reloadedCp.epoch);
|
|
593
|
-
let firstState:
|
|
585
|
+
let firstState: IBeaconStateView | null = null;
|
|
594
586
|
const logCtx = {reloadedCpEpoch: reloadedCp.epoch, reloadedCpRoot: reloadedCp.rootHex};
|
|
595
587
|
|
|
596
588
|
// no need to check epochs before `maxEpoch - this.maxEpochsInMemory + 1` before they are all persisted
|
|
@@ -620,7 +612,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
620
612
|
// amongst states of the same epoch, choose the one with the same view of reloadedCp
|
|
621
613
|
if (
|
|
622
614
|
reloadedCpSlot < state.slot &&
|
|
623
|
-
toRootHex(getBlockRootAtSlot(
|
|
615
|
+
toRootHex(state.getBlockRootAtSlot(reloadedCpSlot)) === reloadedCp.rootHex
|
|
624
616
|
) {
|
|
625
617
|
this.logger.verbose("Reload: use checkpoint state as seed state", {...cpLog, ...logCtx});
|
|
626
618
|
return state;
|
|
@@ -685,7 +677,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
685
677
|
});
|
|
686
678
|
}
|
|
687
679
|
|
|
688
|
-
getStates(): IterableIterator<
|
|
680
|
+
getStates(): IterableIterator<IBeaconStateView> {
|
|
689
681
|
const items = Array.from(this.cache.values())
|
|
690
682
|
.filter(isInMemoryCacheItem)
|
|
691
683
|
.map((item) => item.state);
|
|
@@ -735,17 +727,13 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
735
727
|
* - In normal condition, we persist 1 checkpoint state per epoch.
|
|
736
728
|
* - In reorged condition, we may persist multiple (most likely 2) checkpoint states per epoch.
|
|
737
729
|
*/
|
|
738
|
-
private async processPastEpoch(
|
|
739
|
-
blockRootHex: RootHex,
|
|
740
|
-
state: CachedBeaconStateAllForks,
|
|
741
|
-
epoch: Epoch
|
|
742
|
-
): Promise<number> {
|
|
730
|
+
private async processPastEpoch(blockRootHex: RootHex, state: IBeaconStateView, epoch: Epoch): Promise<number> {
|
|
743
731
|
let persistCount = 0;
|
|
744
732
|
const epochBoundarySlot = computeStartSlotAtEpoch(epoch);
|
|
745
733
|
const epochBoundaryRoot =
|
|
746
|
-
epochBoundarySlot === state.slot ? fromHex(blockRootHex) : getBlockRootAtSlot(
|
|
734
|
+
epochBoundarySlot === state.slot ? fromHex(blockRootHex) : state.getBlockRootAtSlot(epochBoundarySlot);
|
|
747
735
|
const epochBoundaryHex = toRootHex(epochBoundaryRoot);
|
|
748
|
-
const prevEpochRoot = toRootHex(getBlockRootAtSlot(
|
|
736
|
+
const prevEpochRoot = toRootHex(state.getBlockRootAtSlot(epochBoundarySlot - 1));
|
|
749
737
|
|
|
750
738
|
// for each epoch, usually there are 2 rootHexes respective to the 2 checkpoint states: Previous Root Checkpoint State and Current Root Checkpoint State
|
|
751
739
|
const cpRootHexMap = this.epochIndex.get(epoch) ?? new Map<RootHex, number>();
|
|
@@ -912,15 +900,14 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
912
900
|
* - Also `serializeState.test.ts` perf test shows a lot of differences allocating validators bytes once vs every time,
|
|
913
901
|
* This is 2x - 3x faster than allocating memory every time.
|
|
914
902
|
*/
|
|
915
|
-
private serializeStateValidators(state:
|
|
916
|
-
const
|
|
917
|
-
const size = type.tree_serializedSize(state.validators.node);
|
|
903
|
+
private serializeStateValidators(state: IBeaconStateView): BufferWithKey | null {
|
|
904
|
+
const size = state.serializedValidatorsSize();
|
|
918
905
|
if (this.bufferPool) {
|
|
919
906
|
const bufferWithKey = this.bufferPool.alloc(size, AllocSource.PERSISTENT_CHECKPOINTS_CACHE_VALIDATORS);
|
|
920
907
|
if (bufferWithKey) {
|
|
921
908
|
const validatorsBytes = bufferWithKey.buffer;
|
|
922
909
|
const dataView = new DataView(validatorsBytes.buffer, validatorsBytes.byteOffset, validatorsBytes.byteLength);
|
|
923
|
-
state.
|
|
910
|
+
state.serializeValidatorsToBytes({uint8Array: validatorsBytes, dataView}, 0);
|
|
924
911
|
return bufferWithKey;
|
|
925
912
|
}
|
|
926
913
|
}
|
|
@@ -983,10 +970,8 @@ function fromCacheKey(key: CacheKey): CheckpointHexPayload {
|
|
|
983
970
|
};
|
|
984
971
|
}
|
|
985
972
|
|
|
986
|
-
function
|
|
987
|
-
stateOrBytes
|
|
988
|
-
): stateOrBytes is CachedBeaconStateAllForks {
|
|
989
|
-
return (stateOrBytes as CachedBeaconStateAllForks).slot !== undefined;
|
|
973
|
+
function isBeaconStateView(stateOrBytes: IBeaconStateView | LoadedStateBytesData): stateOrBytes is IBeaconStateView {
|
|
974
|
+
return (stateOrBytes as IBeaconStateView).slot !== undefined;
|
|
990
975
|
}
|
|
991
976
|
|
|
992
977
|
function isInMemoryCacheItem(cacheItem: CacheItem): cacheItem is InMemoryCacheItem {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {routes} from "@lodestar/api";
|
|
2
|
-
import {
|
|
2
|
+
import {IBeaconStateView} from "@lodestar/state-transition";
|
|
3
3
|
import {Epoch, RootHex, phase0} from "@lodestar/types";
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -24,13 +24,13 @@ export type CheckpointHexPayload = {epoch: Epoch; rootHex: RootHex; payloadPrese
|
|
|
24
24
|
* The cache key is state root
|
|
25
25
|
*/
|
|
26
26
|
export interface BlockStateCache {
|
|
27
|
-
get(rootHex: RootHex):
|
|
28
|
-
add(item:
|
|
29
|
-
setHeadState(item:
|
|
27
|
+
get(rootHex: RootHex): IBeaconStateView | null;
|
|
28
|
+
add(item: IBeaconStateView): void;
|
|
29
|
+
setHeadState(item: IBeaconStateView | null): void;
|
|
30
30
|
/**
|
|
31
31
|
* Get a seed state for state reload.
|
|
32
32
|
*/
|
|
33
|
-
getSeedState():
|
|
33
|
+
getSeedState(): IBeaconStateView;
|
|
34
34
|
clear(): void;
|
|
35
35
|
size: number;
|
|
36
36
|
prune(headStateRootHex: RootHex): void;
|
|
@@ -39,7 +39,7 @@ export interface BlockStateCache {
|
|
|
39
39
|
upgradeToGloas(): void;
|
|
40
40
|
dumpSummary(): routes.lodestar.StateCacheItem[];
|
|
41
41
|
/** Expose beacon states stored in cache. Use with caution */
|
|
42
|
-
getStates(): IterableIterator<
|
|
42
|
+
getStates(): IterableIterator<IBeaconStateView>;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
@@ -65,24 +65,20 @@ export interface BlockStateCache {
|
|
|
65
65
|
*/
|
|
66
66
|
export interface CheckpointStateCache {
|
|
67
67
|
init?: () => Promise<void>;
|
|
68
|
-
getOrReload(cp: CheckpointHexPayload): Promise<
|
|
69
|
-
getStateOrBytes(cp: CheckpointHexPayload): Promise<
|
|
70
|
-
get(cpOrKey: CheckpointHexPayload | string):
|
|
71
|
-
add(cp: phase0.Checkpoint, state:
|
|
72
|
-
getLatest(rootHex: RootHex, maxEpoch: Epoch, payloadPresent: boolean):
|
|
73
|
-
getOrReloadLatest(
|
|
74
|
-
rootHex: RootHex,
|
|
75
|
-
maxEpoch: Epoch,
|
|
76
|
-
payloadPresent: boolean
|
|
77
|
-
): Promise<CachedBeaconStateAllForks | null>;
|
|
68
|
+
getOrReload(cp: CheckpointHexPayload): Promise<IBeaconStateView | null>;
|
|
69
|
+
getStateOrBytes(cp: CheckpointHexPayload): Promise<IBeaconStateView | Uint8Array | null>;
|
|
70
|
+
get(cpOrKey: CheckpointHexPayload | string): IBeaconStateView | null;
|
|
71
|
+
add(cp: phase0.Checkpoint, state: IBeaconStateView, payloadPresent: boolean): void;
|
|
72
|
+
getLatest(rootHex: RootHex, maxEpoch: Epoch, payloadPresent: boolean): IBeaconStateView | null;
|
|
73
|
+
getOrReloadLatest(rootHex: RootHex, maxEpoch: Epoch, payloadPresent: boolean): Promise<IBeaconStateView | null>;
|
|
78
74
|
updatePreComputedCheckpoint(rootHex: RootHex, epoch: Epoch, payloadPresent: boolean): number | null;
|
|
79
75
|
prune(finalizedEpoch: Epoch, justifiedEpoch: Epoch): void;
|
|
80
76
|
pruneFinalized(finalizedEpoch: Epoch): void;
|
|
81
|
-
processState(blockRootHex: RootHex, state:
|
|
77
|
+
processState(blockRootHex: RootHex, state: IBeaconStateView): Promise<number>;
|
|
82
78
|
clear(): void;
|
|
83
79
|
dumpSummary(): routes.lodestar.StateCacheItem[];
|
|
84
80
|
/** Expose beacon states stored in cache. Use with caution */
|
|
85
|
-
getStates(): IterableIterator<
|
|
81
|
+
getStates(): IterableIterator<IBeaconStateView>;
|
|
86
82
|
}
|
|
87
83
|
|
|
88
84
|
export enum CacheItemType {
|
|
@@ -48,7 +48,7 @@ export async function validateAttesterSlashing(
|
|
|
48
48
|
chain.config,
|
|
49
49
|
chain.pubkeyCache,
|
|
50
50
|
state.slot,
|
|
51
|
-
state.
|
|
51
|
+
state.validatorCount,
|
|
52
52
|
attesterSlashing,
|
|
53
53
|
false
|
|
54
54
|
);
|
|
@@ -59,8 +59,8 @@ export async function validateAttesterSlashing(
|
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
const currentEpoch = state.
|
|
63
|
-
if (!intersectingIndices.some((index) => isSlashableValidator(state.
|
|
62
|
+
const currentEpoch = state.epoch;
|
|
63
|
+
if (!intersectingIndices.some((index) => isSlashableValidator(state.getValidator(index), currentEpoch))) {
|
|
64
64
|
throw new AttesterSlashingError(GossipAction.REJECT, {
|
|
65
65
|
code: AttesterSlashingErrorCode.INVALID,
|
|
66
66
|
error: Error("AttesterSlashing has no slashable validators"),
|
|
@@ -176,7 +176,7 @@ export async function validateGossipBlobSidecar(
|
|
|
176
176
|
// MAY be queued for later processing while proposers for the block's branch are calculated -- in such
|
|
177
177
|
// a case _do not_ `REJECT`, instead `IGNORE` this message.
|
|
178
178
|
const proposerIndex = blobSidecar.signedBlockHeader.message.proposerIndex;
|
|
179
|
-
if (blockState.
|
|
179
|
+
if (blockState.getBeaconProposer(blobSlot) !== proposerIndex) {
|
|
180
180
|
throw new BlobSidecarGossipError(GossipAction.REJECT, {
|
|
181
181
|
code: BlobSidecarErrorCode.INCORRECT_PROPOSER,
|
|
182
182
|
proposerIndex,
|
|
@@ -6,8 +6,6 @@ import {
|
|
|
6
6
|
computeTimeAtSlot,
|
|
7
7
|
getBlockProposerSignatureSet,
|
|
8
8
|
isExecutionBlockBodyType,
|
|
9
|
-
isExecutionEnabled,
|
|
10
|
-
isExecutionStateType,
|
|
11
9
|
} from "@lodestar/state-transition";
|
|
12
10
|
import {SignedBeaconBlock, deneb, gloas, isGloasBeaconBlock} from "@lodestar/types";
|
|
13
11
|
import {byteArrayEquals, sleep, toRootHex} from "@lodestar/utils";
|
|
@@ -176,7 +174,7 @@ export async function validateGossipBlock(
|
|
|
176
174
|
if (isForkPostBellatrix(fork) && !isForkPostGloas(fork)) {
|
|
177
175
|
if (!isExecutionBlockBodyType(block.body)) throw Error("Not execution block body type");
|
|
178
176
|
const executionPayload = block.body.executionPayload;
|
|
179
|
-
if (isExecutionStateType
|
|
177
|
+
if (blockState.isExecutionStateType && blockState.isExecutionEnabled(block)) {
|
|
180
178
|
const expectedTimestamp = computeTimeAtSlot(config, blockSlot, chain.genesisTime);
|
|
181
179
|
if (executionPayload.timestamp !== computeTimeAtSlot(config, blockSlot, chain.genesisTime)) {
|
|
182
180
|
throw new BlockGossipError(GossipAction.REJECT, {
|
|
@@ -206,7 +204,7 @@ export async function validateGossipBlock(
|
|
|
206
204
|
// shuffling (defined by parent_root/slot). If the proposer_index cannot immediately be verified against the expected
|
|
207
205
|
// shuffling, the block MAY be queued for later processing while proposers for the block's branch are calculated --
|
|
208
206
|
// in such a case do not REJECT, instead IGNORE this message.
|
|
209
|
-
if (blockState.
|
|
207
|
+
if (blockState.getBeaconProposer(blockSlot) !== proposerIndex) {
|
|
210
208
|
throw new BlockGossipError(GossipAction.REJECT, {code: BlockErrorCode.INCORRECT_PROPOSER, proposerIndex});
|
|
211
209
|
}
|
|
212
210
|
|
|
@@ -39,12 +39,12 @@ async function validateBlsToExecutionChange(
|
|
|
39
39
|
const state = chain.getHeadState();
|
|
40
40
|
const {config} = chain;
|
|
41
41
|
const addressChange = blsToExecutionChange.message;
|
|
42
|
-
if (addressChange.validatorIndex >= state.
|
|
42
|
+
if (addressChange.validatorIndex >= state.validatorCount) {
|
|
43
43
|
throw new BlsToExecutionChangeError(GossipAction.REJECT, {
|
|
44
44
|
code: BlsToExecutionChangeErrorCode.INVALID,
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
const validator = state.
|
|
47
|
+
const validator = state.getValidator(addressChange.validatorIndex);
|
|
48
48
|
// [REJECT] All of the conditions within process_bls_to_execution_change pass validation.
|
|
49
49
|
// verifySignature = false, verified in batch below
|
|
50
50
|
const {valid} = isValidBlsToExecutionChange(config, validator, blsToExecutionChange, false);
|
|
@@ -122,7 +122,7 @@ export async function validateGossipDataColumnSidecar(
|
|
|
122
122
|
// while proposers for the block's branch are calculated -- in such a case do not REJECT, instead IGNORE
|
|
123
123
|
// this message.
|
|
124
124
|
const proposerIndex = blockHeader.proposerIndex;
|
|
125
|
-
const expectedProposerIndex = blockState.
|
|
125
|
+
const expectedProposerIndex = blockState.getBeaconProposer(blockHeader.slot);
|
|
126
126
|
|
|
127
127
|
if (proposerIndex !== expectedProposerIndex) {
|
|
128
128
|
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import {PublicKey} from "@chainsafe/blst";
|
|
2
2
|
import {
|
|
3
|
-
CachedBeaconStateGloas,
|
|
4
|
-
canBuilderCoverBid,
|
|
5
3
|
createSingleSignatureSetFromComponents,
|
|
6
4
|
getExecutionPayloadBidSigningRoot,
|
|
7
5
|
isActiveBuilder,
|
|
@@ -33,9 +31,7 @@ async function validateExecutionPayloadBid(
|
|
|
33
31
|
const bid = signedExecutionPayloadBid.message;
|
|
34
32
|
const parentBlockRootHex = toRootHex(bid.parentBlockRoot);
|
|
35
33
|
const parentBlockHashHex = toRootHex(bid.parentBlockHash);
|
|
36
|
-
const state =
|
|
37
|
-
RegenCaller.validateGossipExecutionPayloadBid
|
|
38
|
-
)) as CachedBeaconStateGloas;
|
|
34
|
+
const state = await chain.getHeadStateAtCurrentEpoch(RegenCaller.validateGossipExecutionPayloadBid);
|
|
39
35
|
|
|
40
36
|
// [IGNORE] `bid.slot` is the current slot or the next slot.
|
|
41
37
|
const currentSlot = chain.clock.currentSlot;
|
|
@@ -53,7 +49,7 @@ async function validateExecutionPayloadBid(
|
|
|
53
49
|
|
|
54
50
|
// [REJECT] `bid.builder_index` is a valid/active builder index -- i.e.
|
|
55
51
|
// `is_active_builder(state, bid.builder_index)` returns `True`.
|
|
56
|
-
const builder = state.
|
|
52
|
+
const builder = state.getBuilder(bid.builderIndex);
|
|
57
53
|
if (!isActiveBuilder(builder, state.finalizedCheckpoint.epoch)) {
|
|
58
54
|
throw new ExecutionPayloadBidError(GossipAction.REJECT, {
|
|
59
55
|
code: ExecutionPayloadBidErrorCode.BUILDER_NOT_ELIGIBLE,
|
|
@@ -99,7 +95,7 @@ async function validateExecutionPayloadBid(
|
|
|
99
95
|
}
|
|
100
96
|
// [IGNORE] `bid.value` is less or equal than the builder's excess balance --
|
|
101
97
|
// i.e. `can_builder_cover_bid(state, builder_index, amount)` returns `True`.
|
|
102
|
-
if (!canBuilderCoverBid(
|
|
98
|
+
if (!state.canBuilderCoverBid(bid.builderIndex, bid.value)) {
|
|
103
99
|
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
104
100
|
code: ExecutionPayloadBidErrorCode.BID_TOO_HIGH,
|
|
105
101
|
bidValue: bid.value,
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import {PayloadStatus} from "@lodestar/fork-choice";
|
|
2
|
-
import {
|
|
3
|
-
BeaconStateView,
|
|
4
|
-
CachedBeaconStateGloas,
|
|
5
|
-
computeStartSlotAtEpoch,
|
|
6
|
-
getExecutionPayloadEnvelopeSignatureSet,
|
|
7
|
-
} from "@lodestar/state-transition";
|
|
2
|
+
import {computeStartSlotAtEpoch, getExecutionPayloadEnvelopeSignatureSet} from "@lodestar/state-transition";
|
|
8
3
|
import {gloas} from "@lodestar/types";
|
|
9
4
|
import {toRootHex} from "@lodestar/utils";
|
|
10
5
|
import {ExecutionPayloadEnvelopeError, ExecutionPayloadEnvelopeErrorCode, GossipAction} from "../errors/index.js";
|
|
@@ -119,11 +114,10 @@ async function validateExecutionPayloadEnvelope(
|
|
|
119
114
|
});
|
|
120
115
|
});
|
|
121
116
|
|
|
122
|
-
const state = blockState as CachedBeaconStateGloas;
|
|
123
117
|
const signatureSet = getExecutionPayloadEnvelopeSignatureSet(
|
|
124
118
|
chain.config,
|
|
125
119
|
chain.pubkeyCache,
|
|
126
|
-
|
|
120
|
+
blockState,
|
|
127
121
|
executionPayloadEnvelope,
|
|
128
122
|
payloadInput.proposerIndex
|
|
129
123
|
);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
CachedBeaconStateGloas,
|
|
3
2
|
computeEpochAtSlot,
|
|
4
3
|
createSingleSignatureSetFromComponents,
|
|
5
4
|
getPayloadAttestationDataSigningRoot,
|
|
@@ -66,7 +65,7 @@ async function validatePayloadAttestationMessage(
|
|
|
66
65
|
});
|
|
67
66
|
}
|
|
68
67
|
|
|
69
|
-
const state = chain.getHeadState()
|
|
68
|
+
const state = chain.getHeadState();
|
|
70
69
|
|
|
71
70
|
// [REJECT] The message's block `data.beacon_block_root` passes validation.
|
|
72
71
|
// TODO GLOAS: implement this. Technically if we cannot get proto block from fork choice,
|
|
@@ -75,8 +74,7 @@ async function validatePayloadAttestationMessage(
|
|
|
75
74
|
// [REJECT] The message's validator index is within the payload committee in
|
|
76
75
|
// `get_ptc(state, data.slot)`. The `state` is the head state corresponding to
|
|
77
76
|
// processing the block up to the current slot as determined by the fork choice.
|
|
78
|
-
const
|
|
79
|
-
const validatorCommitteeIndex = ptc.indexOf(validatorIndex);
|
|
77
|
+
const validatorCommitteeIndex = state.getIndexInPayloadTimelinessCommittee(validatorIndex, data.slot);
|
|
80
78
|
|
|
81
79
|
if (validatorCommitteeIndex === -1) {
|
|
82
80
|
throw new PayloadAttestationError(GossipAction.REJECT, {
|
|
@@ -35,7 +35,7 @@ async function validateProposerSlashing(
|
|
|
35
35
|
|
|
36
36
|
// [REJECT] All of the conditions within process_proposer_slashing pass validation.
|
|
37
37
|
try {
|
|
38
|
-
const proposer = state.
|
|
38
|
+
const proposer = state.getValidator(proposerSlashing.signedHeader1.message.proposerIndex);
|
|
39
39
|
// verifySignature = false, verified in batch below
|
|
40
40
|
assertValidProposerSlashing(chain.config, chain.pubkeyCache, state.slot, proposerSlashing, proposer, false);
|
|
41
41
|
} catch (e) {
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import {BeaconConfig} from "@lodestar/config";
|
|
2
2
|
import {DOMAIN_CONTRIBUTION_AND_PROOF} from "@lodestar/params";
|
|
3
|
-
import {
|
|
4
|
-
CachedBeaconStateAllForks,
|
|
5
|
-
ISignatureSet,
|
|
6
|
-
SignatureSetType,
|
|
7
|
-
computeSigningRoot,
|
|
8
|
-
} from "@lodestar/state-transition";
|
|
3
|
+
import {IBeaconStateView, ISignatureSet, SignatureSetType, computeSigningRoot} from "@lodestar/state-transition";
|
|
9
4
|
import {altair, ssz} from "@lodestar/types";
|
|
10
5
|
|
|
11
6
|
export function getContributionAndProofSignatureSet(
|
|
12
7
|
config: BeaconConfig,
|
|
13
|
-
state:
|
|
8
|
+
state: IBeaconStateView,
|
|
14
9
|
signedContributionAndProof: altair.SignedContributionAndProof
|
|
15
10
|
): ISignatureSet {
|
|
16
11
|
const domain = config.getDomain(
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import {BeaconConfig} from "@lodestar/config";
|
|
2
2
|
import {DOMAIN_SYNC_COMMITTEE} from "@lodestar/params";
|
|
3
|
-
import {
|
|
4
|
-
CachedBeaconStateAllForks,
|
|
5
|
-
ISignatureSet,
|
|
6
|
-
SignatureSetType,
|
|
7
|
-
computeSigningRoot,
|
|
8
|
-
} from "@lodestar/state-transition";
|
|
3
|
+
import {IBeaconStateView, ISignatureSet, SignatureSetType, computeSigningRoot} from "@lodestar/state-transition";
|
|
9
4
|
import {altair, ssz} from "@lodestar/types";
|
|
10
5
|
|
|
11
6
|
export function getSyncCommitteeSignatureSet(
|
|
12
7
|
config: BeaconConfig,
|
|
13
|
-
state:
|
|
8
|
+
state: IBeaconStateView,
|
|
14
9
|
syncCommittee: altair.SyncCommitteeMessage
|
|
15
10
|
): ISignatureSet {
|
|
16
11
|
const domain = config.getDomain(state.slot, DOMAIN_SYNC_COMMITTEE, syncCommittee.slot);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {BeaconConfig} from "@lodestar/config";
|
|
2
2
|
import {DOMAIN_SYNC_COMMITTEE} from "@lodestar/params";
|
|
3
|
-
import {
|
|
3
|
+
import {IBeaconStateView, ISignatureSet, SignatureSetType, computeSigningRoot} from "@lodestar/state-transition";
|
|
4
4
|
import {altair, ssz} from "@lodestar/types";
|
|
5
5
|
|
|
6
6
|
export function getSyncCommitteeContributionSignatureSet(
|
|
7
7
|
config: BeaconConfig,
|
|
8
|
-
state:
|
|
8
|
+
state: IBeaconStateView,
|
|
9
9
|
contribution: altair.SyncCommitteeContribution,
|
|
10
10
|
participantIndices: number[]
|
|
11
11
|
): ISignatureSet {
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import {BeaconConfig} from "@lodestar/config";
|
|
2
2
|
import {DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF} from "@lodestar/params";
|
|
3
|
-
import {
|
|
4
|
-
CachedBeaconStateAllForks,
|
|
5
|
-
ISignatureSet,
|
|
6
|
-
SignatureSetType,
|
|
7
|
-
computeSigningRoot,
|
|
8
|
-
} from "@lodestar/state-transition";
|
|
3
|
+
import {IBeaconStateView, ISignatureSet, SignatureSetType, computeSigningRoot} from "@lodestar/state-transition";
|
|
9
4
|
import {altair, ssz} from "@lodestar/types";
|
|
10
5
|
|
|
11
6
|
export function getSyncCommitteeSelectionProofSignatureSet(
|
|
12
7
|
config: BeaconConfig,
|
|
13
|
-
state:
|
|
8
|
+
state: IBeaconStateView,
|
|
14
9
|
contributionAndProof: altair.ContributionAndProof
|
|
15
10
|
): ISignatureSet {
|
|
16
11
|
const slot = contributionAndProof.contribution.slot;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {SYNC_COMMITTEE_SUBNET_COUNT, SYNC_COMMITTEE_SUBNET_SIZE} from "@lodestar/params";
|
|
2
|
-
import {
|
|
2
|
+
import {IBeaconStateView} from "@lodestar/state-transition";
|
|
3
3
|
import {SubnetID, altair} from "@lodestar/types";
|
|
4
4
|
import {toRootHex} from "@lodestar/utils";
|
|
5
5
|
import {GossipAction, SyncCommitteeError, SyncCommitteeErrorCode} from "../errors/index.js";
|
|
@@ -15,12 +15,12 @@ export async function validateGossipSyncCommittee(
|
|
|
15
15
|
chain: IBeaconChain,
|
|
16
16
|
syncCommittee: altair.SyncCommitteeMessage,
|
|
17
17
|
subnet: SubnetID
|
|
18
|
-
): Promise<{
|
|
18
|
+
): Promise<{indicesInSubcommittee: IndexInSubcommittee[]}> {
|
|
19
19
|
const {slot, validatorIndex, beaconBlockRoot} = syncCommittee;
|
|
20
20
|
const messageRoot = toRootHex(beaconBlockRoot);
|
|
21
21
|
|
|
22
22
|
const headState = chain.getHeadState();
|
|
23
|
-
const
|
|
23
|
+
const indicesInSubcommittee = validateGossipSyncCommitteeExceptSig(chain, headState, subnet, syncCommittee);
|
|
24
24
|
|
|
25
25
|
// [IGNORE] The signature's slot is for the current slot, i.e. sync_committee_signature.slot == current_slot.
|
|
26
26
|
// > Checked in validateGossipSyncCommitteeExceptSig()
|
|
@@ -68,12 +68,12 @@ export async function validateGossipSyncCommittee(
|
|
|
68
68
|
// Register this valid item as seen
|
|
69
69
|
chain.seenSyncCommitteeMessages.add(slot, subnet, validatorIndex, messageRoot);
|
|
70
70
|
|
|
71
|
-
return {
|
|
71
|
+
return {indicesInSubcommittee};
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
export async function validateApiSyncCommittee(
|
|
75
75
|
chain: IBeaconChain,
|
|
76
|
-
headState:
|
|
76
|
+
headState: IBeaconStateView,
|
|
77
77
|
syncCommittee: altair.SyncCommitteeMessage
|
|
78
78
|
): Promise<void> {
|
|
79
79
|
const prioritizeBls = true;
|
|
@@ -85,7 +85,7 @@ export async function validateApiSyncCommittee(
|
|
|
85
85
|
*/
|
|
86
86
|
async function validateSyncCommitteeSigOnly(
|
|
87
87
|
chain: IBeaconChain,
|
|
88
|
-
headState:
|
|
88
|
+
headState: IBeaconStateView,
|
|
89
89
|
syncCommittee: altair.SyncCommitteeMessage,
|
|
90
90
|
prioritizeBls = false
|
|
91
91
|
): Promise<void> {
|
|
@@ -102,10 +102,10 @@ async function validateSyncCommitteeSigOnly(
|
|
|
102
102
|
*/
|
|
103
103
|
export function validateGossipSyncCommitteeExceptSig(
|
|
104
104
|
chain: IBeaconChain,
|
|
105
|
-
headState:
|
|
105
|
+
headState: IBeaconStateView,
|
|
106
106
|
subnet: SubnetID,
|
|
107
107
|
data: Pick<altair.SyncCommitteeMessage, "slot" | "validatorIndex">
|
|
108
|
-
): IndexInSubcommittee {
|
|
108
|
+
): IndexInSubcommittee[] {
|
|
109
109
|
const {slot, validatorIndex} = data;
|
|
110
110
|
// [IGNORE] The signature's slot is for the current slot, i.e. sync_committee_signature.slot == current_slot.
|
|
111
111
|
// (with a MAXIMUM_GOSSIP_CLOCK_DISPARITY allowance)
|
|
@@ -127,39 +127,40 @@ export function validateGossipSyncCommitteeExceptSig(
|
|
|
127
127
|
|
|
128
128
|
// [REJECT] The subnet_id is valid for the given validator, i.e. subnet_id in compute_subnets_for_sync_committee(state, sync_committee_signature.validator_index).
|
|
129
129
|
// Note this validation implies the validator is part of the broader current sync committee along with the correct subcommittee.
|
|
130
|
-
const
|
|
131
|
-
if (
|
|
130
|
+
const indicesInSubcommittee = getIndicesInSubcommittee(headState, subnet, data);
|
|
131
|
+
if (indicesInSubcommittee === null) {
|
|
132
132
|
throw new SyncCommitteeError(GossipAction.REJECT, {
|
|
133
133
|
code: SyncCommitteeErrorCode.VALIDATOR_NOT_IN_SYNC_COMMITTEE,
|
|
134
134
|
validatorIndex,
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
return
|
|
138
|
+
return indicesInSubcommittee;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
/**
|
|
142
|
-
* Returns
|
|
143
|
-
* Returns `null` if not part of the sync committee or not part of the given `subnet
|
|
142
|
+
* Returns all IndexInSubcommittee positions of the given `subnet`.
|
|
143
|
+
* Returns `null` if not part of the sync committee or not part of the given `subnet`.
|
|
144
|
+
* A validator may appear multiple times in the same subcommittee.
|
|
144
145
|
*/
|
|
145
|
-
function
|
|
146
|
-
headState:
|
|
146
|
+
function getIndicesInSubcommittee(
|
|
147
|
+
headState: IBeaconStateView,
|
|
147
148
|
subnet: SubnetID,
|
|
148
149
|
data: Pick<altair.SyncCommitteeMessage, "slot" | "validatorIndex">
|
|
149
|
-
): IndexInSubcommittee | null {
|
|
150
|
-
const syncCommittee = headState.
|
|
150
|
+
): IndexInSubcommittee[] | null {
|
|
151
|
+
const syncCommittee = headState.getIndexedSyncCommittee(data.slot);
|
|
151
152
|
const indexesInCommittee = syncCommittee.validatorIndexMap.get(data.validatorIndex);
|
|
152
153
|
if (indexesInCommittee === undefined) {
|
|
153
154
|
// Not part of the sync committee
|
|
154
155
|
return null;
|
|
155
156
|
}
|
|
156
157
|
|
|
158
|
+
const indices: IndexInSubcommittee[] = [];
|
|
157
159
|
for (const indexInCommittee of indexesInCommittee) {
|
|
158
160
|
if (Math.floor(indexInCommittee / SYNC_COMMITTEE_SUBNET_SIZE) === subnet) {
|
|
159
|
-
|
|
161
|
+
indices.push(indexInCommittee % SYNC_COMMITTEE_SUBNET_SIZE);
|
|
160
162
|
}
|
|
161
163
|
}
|
|
162
164
|
|
|
163
|
-
|
|
164
|
-
return null;
|
|
165
|
+
return indices.length > 0 ? indices : null;
|
|
165
166
|
}
|