@lodestar/beacon-node 1.42.0-dev.7b5ce3932d → 1.42.0-dev.83dedda569
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.js +1 -1
- 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/historicalState/getHistoricalState.d.ts +2 -6
- package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
- package/lib/chain/archiveStore/historicalState/getHistoricalState.js +3 -23
- package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/worker.js +1 -0
- package/lib/chain/archiveStore/historicalState/worker.js.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 +9 -9
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +4 -5
- package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
- package/lib/chain/blocks/index.js +1 -1
- package/lib/chain/blocks/index.js.map +1 -1
- package/lib/chain/blocks/types.d.ts +2 -2
- 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 +3 -3
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +3 -3
- 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/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 +5 -0
- 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/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 +9 -7
- 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 +1 -1
- 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/historicalState/getHistoricalState.ts +6 -36
- package/src/chain/archiveStore/historicalState/worker.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 +11 -14
- package/src/chain/blocks/importExecutionPayload.ts +6 -11
- package/src/chain/blocks/index.ts +1 -1
- package/src/chain/blocks/types.ts +2 -2
- package/src/chain/blocks/utils/checkpoint.ts +2 -2
- package/src/chain/blocks/verifyBlock.ts +5 -10
- package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +5 -10
- 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/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 +5 -0
- package/src/network/network.ts +32 -4
- package/src/network/processor/extractSlotRootFns.ts +1 -1
- package/src/network/processor/gossipHandlers.ts +9 -8
- 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
|
@@ -14,17 +14,7 @@ import {
|
|
|
14
14
|
isForkPostBellatrix,
|
|
15
15
|
isForkPostGloas,
|
|
16
16
|
} from "@lodestar/params";
|
|
17
|
-
import {
|
|
18
|
-
CachedBeaconStateAllForks,
|
|
19
|
-
CachedBeaconStateBellatrix,
|
|
20
|
-
CachedBeaconStateCapella,
|
|
21
|
-
CachedBeaconStateExecutions,
|
|
22
|
-
CachedBeaconStateGloas,
|
|
23
|
-
G2_POINT_AT_INFINITY,
|
|
24
|
-
computeTimeAtSlot,
|
|
25
|
-
getExpectedWithdrawals,
|
|
26
|
-
getRandaoMix,
|
|
27
|
-
} from "@lodestar/state-transition";
|
|
17
|
+
import {G2_POINT_AT_INFINITY, IBeaconStateView, computeTimeAtSlot} from "@lodestar/state-transition";
|
|
28
18
|
import {
|
|
29
19
|
BLSPubkey,
|
|
30
20
|
BLSSignature,
|
|
@@ -161,7 +151,7 @@ export type ProduceResult =
|
|
|
161
151
|
export async function produceBlockBody<T extends BlockType>(
|
|
162
152
|
this: BeaconChain,
|
|
163
153
|
blockType: T,
|
|
164
|
-
currentState:
|
|
154
|
+
currentState: IBeaconStateView,
|
|
165
155
|
blockAttr: BlockAttributes & {
|
|
166
156
|
proposerIndex: ValidatorIndex;
|
|
167
157
|
proposerPubKey: BLSPubkey;
|
|
@@ -204,7 +194,6 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
204
194
|
// TODO GLOAS: support non self-building here, the block type differentiation between
|
|
205
195
|
// full and blinded no longer makes sense in gloas, it might be a good idea to move
|
|
206
196
|
// this into a completely separate function and have pre/post gloas more separated
|
|
207
|
-
const gloasState = currentState as CachedBeaconStateGloas;
|
|
208
197
|
const safeBlockHash = getSafeExecutionBlockHash(this.forkChoice);
|
|
209
198
|
const finalizedBlockHash = this.forkChoice.getFinalizedBlock().executionPayloadBlockHash ?? ZERO_HASH_HEX;
|
|
210
199
|
const feeRecipient = requestedFeeRecipient ?? this.beaconProposerCache.getOrDefault(proposerIndex);
|
|
@@ -225,7 +214,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
225
214
|
parentBlockRoot,
|
|
226
215
|
safeBlockHash,
|
|
227
216
|
finalizedBlockHash ?? ZERO_HASH_HEX,
|
|
228
|
-
|
|
217
|
+
currentState,
|
|
229
218
|
feeRecipient
|
|
230
219
|
);
|
|
231
220
|
|
|
@@ -259,10 +248,10 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
259
248
|
|
|
260
249
|
// Create self-build execution payload bid
|
|
261
250
|
const bid: gloas.ExecutionPayloadBid = {
|
|
262
|
-
parentBlockHash:
|
|
251
|
+
parentBlockHash: currentState.latestBlockHash,
|
|
263
252
|
parentBlockRoot: parentBlockRoot,
|
|
264
253
|
blockHash: executionPayload.blockHash,
|
|
265
|
-
prevRandao: getRandaoMix(
|
|
254
|
+
prevRandao: currentState.getRandaoMix(currentState.epoch),
|
|
266
255
|
feeRecipient: executionPayload.feeRecipient,
|
|
267
256
|
gasLimit: BigInt(executionPayload.gasLimit),
|
|
268
257
|
builderIndex: BUILDER_INDEX_SELF_BUILD,
|
|
@@ -336,7 +325,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
336
325
|
parentBlockRoot,
|
|
337
326
|
safeBlockHash,
|
|
338
327
|
finalizedBlockHash ?? ZERO_HASH_HEX,
|
|
339
|
-
currentState
|
|
328
|
+
currentState,
|
|
340
329
|
executionBuilder.issueLocalFcUWithFeeRecipient
|
|
341
330
|
);
|
|
342
331
|
}
|
|
@@ -348,12 +337,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
348
337
|
slot: blockSlot,
|
|
349
338
|
proposerPubKey: toHex(proposerPubKey),
|
|
350
339
|
});
|
|
351
|
-
const headerRes = await prepareExecutionPayloadHeader(
|
|
352
|
-
this,
|
|
353
|
-
fork,
|
|
354
|
-
currentState as CachedBeaconStateBellatrix,
|
|
355
|
-
proposerPubKey
|
|
356
|
-
);
|
|
340
|
+
const headerRes = await prepareExecutionPayloadHeader(this, fork, currentState, proposerPubKey);
|
|
357
341
|
|
|
358
342
|
endExecutionPayloadHeader?.({
|
|
359
343
|
step: BlockProductionStep.executionPayload,
|
|
@@ -388,7 +372,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
388
372
|
});
|
|
389
373
|
} else {
|
|
390
374
|
const headerGasLimit = builderRes.header.gasLimit;
|
|
391
|
-
const parentGasLimit =
|
|
375
|
+
const parentGasLimit = currentState.latestExecutionPayloadHeader.gasLimit;
|
|
392
376
|
const expectedGasLimit = getExpectedGasLimit(parentGasLimit, targetGasLimit);
|
|
393
377
|
|
|
394
378
|
const lowerBound = Math.min(parentGasLimit, expectedGasLimit);
|
|
@@ -449,7 +433,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
449
433
|
parentBlockRoot,
|
|
450
434
|
safeBlockHash,
|
|
451
435
|
finalizedBlockHash ?? ZERO_HASH_HEX,
|
|
452
|
-
currentState
|
|
436
|
+
currentState,
|
|
453
437
|
feeRecipient
|
|
454
438
|
);
|
|
455
439
|
|
|
@@ -614,14 +598,12 @@ export async function prepareExecutionPayload(
|
|
|
614
598
|
parentBlockRoot: Root,
|
|
615
599
|
safeBlockHash: RootHex,
|
|
616
600
|
finalizedBlockHash: RootHex,
|
|
617
|
-
state:
|
|
601
|
+
state: IBeaconStateView,
|
|
618
602
|
suggestedFeeRecipient: string
|
|
619
603
|
): Promise<{prepType: PayloadPreparationType; payloadId: PayloadId}> {
|
|
620
|
-
const parentHash =
|
|
621
|
-
? (state as CachedBeaconStateGloas).latestBlockHash
|
|
622
|
-
: (state as CachedBeaconStateExecutions).latestExecutionPayloadHeader.blockHash;
|
|
604
|
+
const parentHash = state.latestBlockHash;
|
|
623
605
|
const timestamp = computeTimeAtSlot(chain.config, state.slot, state.genesisTime);
|
|
624
|
-
const prevRandao = getRandaoMix(state
|
|
606
|
+
const prevRandao = state.getRandaoMix(state.epoch);
|
|
625
607
|
|
|
626
608
|
const payloadIdCached = chain.executionEngine.payloadIdCache.get({
|
|
627
609
|
headBlockHash: toRootHex(parentHash),
|
|
@@ -684,7 +666,7 @@ async function prepareExecutionPayloadHeader(
|
|
|
684
666
|
config: ChainForkConfig;
|
|
685
667
|
},
|
|
686
668
|
fork: ForkPostBellatrix,
|
|
687
|
-
state:
|
|
669
|
+
state: IBeaconStateView,
|
|
688
670
|
proposerPubKey: BLSPubkey
|
|
689
671
|
): Promise<{
|
|
690
672
|
header: ExecutionPayloadHeader;
|
|
@@ -711,16 +693,9 @@ export function getPayloadAttributesForSSE(
|
|
|
711
693
|
prepareSlot,
|
|
712
694
|
parentBlockRoot,
|
|
713
695
|
feeRecipient,
|
|
714
|
-
}: {
|
|
715
|
-
prepareState: CachedBeaconStateExecutions | CachedBeaconStateGloas;
|
|
716
|
-
prepareSlot: Slot;
|
|
717
|
-
parentBlockRoot: Root;
|
|
718
|
-
feeRecipient: string;
|
|
719
|
-
}
|
|
696
|
+
}: {prepareState: IBeaconStateView; prepareSlot: Slot; parentBlockRoot: Root; feeRecipient: string}
|
|
720
697
|
): SSEPayloadAttributes {
|
|
721
|
-
const parentHash =
|
|
722
|
-
? (prepareState as CachedBeaconStateGloas).latestBlockHash
|
|
723
|
-
: (prepareState as CachedBeaconStateExecutions).latestExecutionPayloadHeader.blockHash;
|
|
698
|
+
const parentHash = prepareState.latestBlockHash;
|
|
724
699
|
const payloadAttributes = preparePayloadAttributes(fork, chain, {
|
|
725
700
|
prepareState,
|
|
726
701
|
prepareSlot,
|
|
@@ -736,11 +711,11 @@ export function getPayloadAttributesForSSE(
|
|
|
736
711
|
}
|
|
737
712
|
parentBlockNumber = parentBlock.executionPayloadNumber;
|
|
738
713
|
} else {
|
|
739
|
-
parentBlockNumber =
|
|
714
|
+
parentBlockNumber = prepareState.payloadBlockNumber;
|
|
740
715
|
}
|
|
741
716
|
|
|
742
717
|
const ssePayloadAttributes: SSEPayloadAttributes = {
|
|
743
|
-
proposerIndex: prepareState.
|
|
718
|
+
proposerIndex: prepareState.getBeaconProposer(prepareSlot),
|
|
744
719
|
proposalSlot: prepareSlot,
|
|
745
720
|
parentBlockNumber,
|
|
746
721
|
parentBlockRoot,
|
|
@@ -761,14 +736,14 @@ function preparePayloadAttributes(
|
|
|
761
736
|
parentBlockRoot,
|
|
762
737
|
feeRecipient,
|
|
763
738
|
}: {
|
|
764
|
-
prepareState:
|
|
739
|
+
prepareState: IBeaconStateView;
|
|
765
740
|
prepareSlot: Slot;
|
|
766
741
|
parentBlockRoot: Root;
|
|
767
742
|
feeRecipient: string;
|
|
768
743
|
}
|
|
769
744
|
): SSEPayloadAttributes["payloadAttributes"] {
|
|
770
745
|
const timestamp = computeTimeAtSlot(chain.config, prepareSlot, prepareState.genesisTime);
|
|
771
|
-
const prevRandao = getRandaoMix(prepareState
|
|
746
|
+
const prevRandao = prepareState.getRandaoMix(prepareState.epoch);
|
|
772
747
|
const payloadAttributes = {
|
|
773
748
|
timestamp,
|
|
774
749
|
prevRandao,
|
|
@@ -777,10 +752,8 @@ function preparePayloadAttributes(
|
|
|
777
752
|
|
|
778
753
|
if (ForkSeq[fork] >= ForkSeq.capella) {
|
|
779
754
|
// withdrawals logic is now fork aware as it changes on electra fork post capella
|
|
780
|
-
(payloadAttributes as capella.SSEPayloadAttributes["payloadAttributes"]).withdrawals =
|
|
781
|
-
|
|
782
|
-
prepareState as CachedBeaconStateCapella
|
|
783
|
-
).expectedWithdrawals;
|
|
755
|
+
(payloadAttributes as capella.SSEPayloadAttributes["payloadAttributes"]).withdrawals =
|
|
756
|
+
prepareState.getExpectedWithdrawals().expectedWithdrawals;
|
|
784
757
|
}
|
|
785
758
|
|
|
786
759
|
if (ForkSeq[fork] >= ForkSeq.deneb) {
|
|
@@ -793,7 +766,7 @@ function preparePayloadAttributes(
|
|
|
793
766
|
export async function produceCommonBlockBody<T extends BlockType>(
|
|
794
767
|
this: BeaconChain,
|
|
795
768
|
blockType: T,
|
|
796
|
-
currentState:
|
|
769
|
+
currentState: IBeaconStateView,
|
|
797
770
|
{randaoReveal, graffiti, slot, parentBlock}: BlockAttributes
|
|
798
771
|
): Promise<CommonBlockBody> {
|
|
799
772
|
const stepsMetrics =
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {routes} from "@lodestar/api";
|
|
2
2
|
import {ProtoBlock} from "@lodestar/fork-choice";
|
|
3
|
-
import {
|
|
3
|
+
import {IBeaconStateView} from "@lodestar/state-transition";
|
|
4
4
|
import {BeaconBlock, Epoch, RootHex, Slot, phase0} from "@lodestar/types";
|
|
5
5
|
import {CheckpointHexPayload} from "../stateCache/types.js";
|
|
6
6
|
|
|
@@ -38,21 +38,21 @@ export type StateRegenerationOpts = {
|
|
|
38
38
|
export interface IStateRegenerator extends IStateRegeneratorInternal {
|
|
39
39
|
dropCache(): void;
|
|
40
40
|
dumpCacheSummary(): routes.lodestar.StateCacheItem[];
|
|
41
|
-
getStateSync(stateRoot: RootHex):
|
|
42
|
-
getPreStateSync(block: BeaconBlock):
|
|
43
|
-
getCheckpointStateOrBytes(cp: CheckpointHexPayload): Promise<
|
|
44
|
-
getCheckpointStateSync(cp: CheckpointHexPayload):
|
|
45
|
-
getClosestHeadState(head: ProtoBlock):
|
|
41
|
+
getStateSync(stateRoot: RootHex): IBeaconStateView | null;
|
|
42
|
+
getPreStateSync(block: BeaconBlock): IBeaconStateView | null;
|
|
43
|
+
getCheckpointStateOrBytes(cp: CheckpointHexPayload): Promise<IBeaconStateView | Uint8Array | null>;
|
|
44
|
+
getCheckpointStateSync(cp: CheckpointHexPayload): IBeaconStateView | null;
|
|
45
|
+
getClosestHeadState(head: ProtoBlock): IBeaconStateView | null;
|
|
46
46
|
pruneOnCheckpoint(finalizedEpoch: Epoch, justifiedEpoch: Epoch, headStateRoot: RootHex): void;
|
|
47
47
|
pruneOnFinalized(finalizedEpoch: Epoch): void;
|
|
48
|
-
processBlockState(blockRootHex: RootHex, postState:
|
|
49
|
-
processPayloadState(payloadState:
|
|
48
|
+
processBlockState(blockRootHex: RootHex, postState: IBeaconStateView): void;
|
|
49
|
+
processPayloadState(payloadState: IBeaconStateView): void;
|
|
50
50
|
/**
|
|
51
51
|
* payloadPresent is true if this is payload state, false if block state.
|
|
52
52
|
* payloadPresent is always true for pre-gloas.
|
|
53
53
|
*/
|
|
54
|
-
addCheckpointState(cp: phase0.Checkpoint, item:
|
|
55
|
-
updateHeadState(newHead: ProtoBlock, maybeHeadState:
|
|
54
|
+
addCheckpointState(cp: phase0.Checkpoint, item: IBeaconStateView, payloadPresent: boolean): void;
|
|
55
|
+
updateHeadState(newHead: ProtoBlock, maybeHeadState: IBeaconStateView): void;
|
|
56
56
|
updatePreComputedCheckpoint(rootHex: RootHex, epoch: Epoch, payloadPresent: boolean): number | null;
|
|
57
57
|
upgradeForGloas(epoch: Epoch): void;
|
|
58
58
|
}
|
|
@@ -65,11 +65,7 @@ export interface IStateRegeneratorInternal {
|
|
|
65
65
|
* Return a valid pre-state for a beacon block
|
|
66
66
|
* This will always return a state in the latest viable epoch
|
|
67
67
|
*/
|
|
68
|
-
getPreState(
|
|
69
|
-
block: BeaconBlock,
|
|
70
|
-
opts: StateRegenerationOpts,
|
|
71
|
-
rCaller: RegenCaller
|
|
72
|
-
): Promise<CachedBeaconStateAllForks>;
|
|
68
|
+
getPreState(block: BeaconBlock, opts: StateRegenerationOpts, rCaller: RegenCaller): Promise<IBeaconStateView>;
|
|
73
69
|
|
|
74
70
|
/**
|
|
75
71
|
* Return the state of `blockRoot` processed to slot `slot`
|
|
@@ -79,10 +75,10 @@ export interface IStateRegeneratorInternal {
|
|
|
79
75
|
slot: Slot,
|
|
80
76
|
opts: StateRegenerationOpts,
|
|
81
77
|
rCaller: RegenCaller
|
|
82
|
-
): Promise<
|
|
78
|
+
): Promise<IBeaconStateView>;
|
|
83
79
|
|
|
84
80
|
/**
|
|
85
81
|
* Return the exact state with `stateRoot`
|
|
86
82
|
*/
|
|
87
|
-
getState(stateRoot: RootHex, rCaller: RegenCaller): Promise<
|
|
83
|
+
getState(stateRoot: RootHex, rCaller: RegenCaller): Promise<IBeaconStateView>;
|
|
88
84
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {routes} from "@lodestar/api";
|
|
2
2
|
import {IForkChoice, PayloadStatus, ProtoBlock} from "@lodestar/fork-choice";
|
|
3
|
-
import {
|
|
3
|
+
import {IBeaconStateView, computeEpochAtSlot} from "@lodestar/state-transition";
|
|
4
4
|
import {BeaconBlock, Epoch, RootHex, Slot, isGloasBeaconBlock, phase0} from "@lodestar/types";
|
|
5
5
|
import {Logger, fromHex, toRootHex} from "@lodestar/utils";
|
|
6
6
|
import {Metrics} from "../../metrics/index.js";
|
|
@@ -34,7 +34,7 @@ export type RegenRequest = RegenRequestByKey[RegenRequestKey];
|
|
|
34
34
|
* All requests are queued so that only a single state at a time may be regenerated at a time
|
|
35
35
|
*/
|
|
36
36
|
export class QueuedStateRegenerator implements IStateRegenerator {
|
|
37
|
-
readonly jobQueue: JobItemQueue<[RegenRequest],
|
|
37
|
+
readonly jobQueue: JobItemQueue<[RegenRequest], IBeaconStateView>;
|
|
38
38
|
private readonly regen: StateRegenerator;
|
|
39
39
|
|
|
40
40
|
private readonly forkChoice: IForkChoice;
|
|
@@ -45,7 +45,7 @@ export class QueuedStateRegenerator implements IStateRegenerator {
|
|
|
45
45
|
|
|
46
46
|
constructor(modules: QueuedStateRegeneratorModules) {
|
|
47
47
|
this.regen = new StateRegenerator(modules);
|
|
48
|
-
this.jobQueue = new JobItemQueue<[RegenRequest],
|
|
48
|
+
this.jobQueue = new JobItemQueue<[RegenRequest], IBeaconStateView>(
|
|
49
49
|
this.jobQueueProcessor,
|
|
50
50
|
{maxLength: REGEN_QUEUE_MAX_LEN, signal: modules.signal},
|
|
51
51
|
modules.metrics ? modules.metrics.regenQueue : undefined
|
|
@@ -79,14 +79,14 @@ export class QueuedStateRegenerator implements IStateRegenerator {
|
|
|
79
79
|
/**
|
|
80
80
|
* Get a state from block state cache.
|
|
81
81
|
*/
|
|
82
|
-
getStateSync(stateRoot: RootHex):
|
|
82
|
+
getStateSync(stateRoot: RootHex): IBeaconStateView | null {
|
|
83
83
|
return this.blockStateCache.get(stateRoot);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
87
|
* Get state for block processing.
|
|
88
88
|
*/
|
|
89
|
-
getPreStateSync(block: BeaconBlock):
|
|
89
|
+
getPreStateSync(block: BeaconBlock): IBeaconStateView | null {
|
|
90
90
|
const parentRoot = toRootHex(block.parentRoot);
|
|
91
91
|
const parentBlock = isGloasBeaconBlock(block)
|
|
92
92
|
? this.forkChoice.getBlockHexAndBlockHash(
|
|
@@ -135,21 +135,21 @@ export class QueuedStateRegenerator implements IStateRegenerator {
|
|
|
135
135
|
return null;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
async getCheckpointStateOrBytes(cp: CheckpointHexPayload): Promise<
|
|
138
|
+
async getCheckpointStateOrBytes(cp: CheckpointHexPayload): Promise<IBeaconStateView | Uint8Array | null> {
|
|
139
139
|
return this.checkpointStateCache.getStateOrBytes(cp);
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
143
|
* Get checkpoint state from cache
|
|
144
144
|
*/
|
|
145
|
-
getCheckpointStateSync(cp: CheckpointHexPayload):
|
|
145
|
+
getCheckpointStateSync(cp: CheckpointHexPayload): IBeaconStateView | null {
|
|
146
146
|
return this.checkpointStateCache.get(cp);
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
/**
|
|
150
150
|
* Get state closest to head
|
|
151
151
|
*/
|
|
152
|
-
getClosestHeadState(head: ProtoBlock):
|
|
152
|
+
getClosestHeadState(head: ProtoBlock): IBeaconStateView | null {
|
|
153
153
|
// Convert PayloadStatus to payloadPresent boolean
|
|
154
154
|
if (head.payloadStatus === PayloadStatus.PENDING) {
|
|
155
155
|
throw new RegenError({
|
|
@@ -175,7 +175,7 @@ export class QueuedStateRegenerator implements IStateRegenerator {
|
|
|
175
175
|
this.blockStateCache.deleteAllBeforeEpoch(finalizedEpoch);
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
processBlockState(blockRootHex: RootHex, postState:
|
|
178
|
+
processBlockState(blockRootHex: RootHex, postState: IBeaconStateView): void {
|
|
179
179
|
this.blockStateCache.add(postState);
|
|
180
180
|
this.checkpointStateCache.processState(blockRootHex, postState).catch((e) => {
|
|
181
181
|
this.logger.debug("Error processing block state", {blockRootHex, slot: postState.slot}, e);
|
|
@@ -185,17 +185,17 @@ export class QueuedStateRegenerator implements IStateRegenerator {
|
|
|
185
185
|
/**
|
|
186
186
|
* Process payload state for caching after importing execution payload.
|
|
187
187
|
*/
|
|
188
|
-
processPayloadState(payloadState:
|
|
188
|
+
processPayloadState(payloadState: IBeaconStateView): void {
|
|
189
189
|
// Add payload state to block state cache (keyed by payload state root)
|
|
190
190
|
this.blockStateCache.add(payloadState);
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
// TODO GLOAS: This should also be called when importing execution payload after we implement it
|
|
194
|
-
addCheckpointState(cp: phase0.Checkpoint, item:
|
|
194
|
+
addCheckpointState(cp: phase0.Checkpoint, item: IBeaconStateView, payloadPresent: boolean): void {
|
|
195
195
|
this.checkpointStateCache.add(cp, item, payloadPresent);
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
updateHeadState(newHead: ProtoBlock, maybeHeadState:
|
|
198
|
+
updateHeadState(newHead: ProtoBlock, maybeHeadState: IBeaconStateView): void {
|
|
199
199
|
const {stateRoot: newHeadStateRoot, blockRoot: newHeadBlockRoot, slot: newHeadSlot} = newHead;
|
|
200
200
|
const maybeHeadStateRoot = toRootHex(maybeHeadState.hashTreeRoot());
|
|
201
201
|
const logCtx = {
|
|
@@ -241,11 +241,7 @@ export class QueuedStateRegenerator implements IStateRegenerator {
|
|
|
241
241
|
* Get the state to run with `block`.
|
|
242
242
|
* - State after `block.parentRoot` dialed forward to block.slot
|
|
243
243
|
*/
|
|
244
|
-
async getPreState(
|
|
245
|
-
block: BeaconBlock,
|
|
246
|
-
opts: StateRegenerationOpts,
|
|
247
|
-
rCaller: RegenCaller
|
|
248
|
-
): Promise<CachedBeaconStateAllForks> {
|
|
244
|
+
async getPreState(block: BeaconBlock, opts: StateRegenerationOpts, rCaller: RegenCaller): Promise<IBeaconStateView> {
|
|
249
245
|
this.metrics?.regenFnCallTotal.inc({caller: rCaller, entrypoint: RegenFnName.getPreState});
|
|
250
246
|
|
|
251
247
|
// First attempt to fetch the state from caches before queueing
|
|
@@ -271,14 +267,14 @@ export class QueuedStateRegenerator implements IStateRegenerator {
|
|
|
271
267
|
slot: Slot,
|
|
272
268
|
opts: StateRegenerationOpts,
|
|
273
269
|
rCaller: RegenCaller
|
|
274
|
-
): Promise<
|
|
270
|
+
): Promise<IBeaconStateView> {
|
|
275
271
|
this.metrics?.regenFnCallTotal.inc({caller: rCaller, entrypoint: RegenFnName.getBlockSlotState});
|
|
276
272
|
|
|
277
273
|
// The state is not immediately available in the caches, enqueue the job
|
|
278
274
|
return this.jobQueue.push({key: "getBlockSlotState", args: [block, slot, opts, rCaller]});
|
|
279
275
|
}
|
|
280
276
|
|
|
281
|
-
async getState(stateRoot: RootHex, rCaller: RegenCaller): Promise<
|
|
277
|
+
async getState(stateRoot: RootHex, rCaller: RegenCaller): Promise<IBeaconStateView> {
|
|
282
278
|
this.metrics?.regenFnCallTotal.inc({caller: rCaller, entrypoint: RegenFnName.getState});
|
|
283
279
|
|
|
284
280
|
// First attempt to fetch the state from cache before queueing
|
|
@@ -292,7 +288,7 @@ export class QueuedStateRegenerator implements IStateRegenerator {
|
|
|
292
288
|
return this.jobQueue.push({key: "getState", args: [stateRoot, rCaller]});
|
|
293
289
|
}
|
|
294
290
|
|
|
295
|
-
private jobQueueProcessor = async (regenRequest: RegenRequest): Promise<
|
|
291
|
+
private jobQueueProcessor = async (regenRequest: RegenRequest): Promise<IBeaconStateView> => {
|
|
296
292
|
const metricsLabels = {
|
|
297
293
|
caller: regenRequest.args.at(-1) as RegenCaller,
|
|
298
294
|
entrypoint: regenRequest.key as RegenFnName,
|
package/src/chain/regen/regen.ts
CHANGED
|
@@ -2,14 +2,12 @@ import {ChainForkConfig} from "@lodestar/config";
|
|
|
2
2
|
import {IForkChoice, PayloadStatus, ProtoBlock} from "@lodestar/fork-choice";
|
|
3
3
|
import {ForkSeq, SLOTS_PER_EPOCH} from "@lodestar/params";
|
|
4
4
|
import {
|
|
5
|
-
CachedBeaconStateAllForks,
|
|
6
5
|
DataAvailabilityStatus,
|
|
7
6
|
ExecutionPayloadStatus,
|
|
7
|
+
IBeaconStateView,
|
|
8
8
|
StateHashTreeRootSource,
|
|
9
9
|
computeEpochAtSlot,
|
|
10
10
|
computeStartSlotAtEpoch,
|
|
11
|
-
processSlots,
|
|
12
|
-
stateTransition,
|
|
13
11
|
} from "@lodestar/state-transition";
|
|
14
12
|
import {BeaconBlock, RootHex, SignedBeaconBlock, Slot, isGloasBeaconBlock} from "@lodestar/types";
|
|
15
13
|
import {Logger, fromHex, toRootHex} from "@lodestar/utils";
|
|
@@ -57,7 +55,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
|
|
|
57
55
|
block: BeaconBlock,
|
|
58
56
|
opts: StateRegenerationOpts,
|
|
59
57
|
regenCaller: RegenCaller
|
|
60
|
-
): Promise<
|
|
58
|
+
): Promise<IBeaconStateView> {
|
|
61
59
|
const parentRoot = toRootHex(block.parentRoot);
|
|
62
60
|
const parentBlock = isGloasBeaconBlock(block)
|
|
63
61
|
? this.modules.forkChoice.getBlockHexAndBlockHash(
|
|
@@ -99,7 +97,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
|
|
|
99
97
|
opts: StateRegenerationOpts,
|
|
100
98
|
regenCaller: RegenCaller,
|
|
101
99
|
allowDiskReload = false
|
|
102
|
-
): Promise<
|
|
100
|
+
): Promise<IBeaconStateView> {
|
|
103
101
|
if (slot < block.slot) {
|
|
104
102
|
throw new RegenError({
|
|
105
103
|
code: RegenErrorCode.SLOT_BEFORE_BLOCK_SLOT,
|
|
@@ -149,7 +147,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
|
|
|
149
147
|
caller: RegenCaller,
|
|
150
148
|
// internal option, don't want to expose to external caller
|
|
151
149
|
allowDiskReload = false
|
|
152
|
-
): Promise<
|
|
150
|
+
): Promise<IBeaconStateView> {
|
|
153
151
|
// Trivial case, state at stateRoot is already cached
|
|
154
152
|
const cachedStateCtx = this.modules.blockStateCache.get(stateRoot);
|
|
155
153
|
if (cachedStateCtx) {
|
|
@@ -164,7 +162,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
|
|
|
164
162
|
// blocks to replay, ordered highest to lowest
|
|
165
163
|
// gets reversed when replayed
|
|
166
164
|
const blocksToReplay = [block];
|
|
167
|
-
let state:
|
|
165
|
+
let state: IBeaconStateView | null = null;
|
|
168
166
|
const {checkpointStateCache} = this.modules;
|
|
169
167
|
|
|
170
168
|
const getSeedStateTimer = this.modules.metrics?.regenGetState.getSeedState.startTimer({caller});
|
|
@@ -260,8 +258,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
|
|
|
260
258
|
// Only advances state trusting block's signture and hashes.
|
|
261
259
|
// We are only running the state transition to get a specific state's data.
|
|
262
260
|
// stateTransition() does the clone() inside, transfer cache to make the regen faster
|
|
263
|
-
state = stateTransition(
|
|
264
|
-
state,
|
|
261
|
+
state = state.stateTransition(
|
|
265
262
|
block,
|
|
266
263
|
{
|
|
267
264
|
// Replay previously imported blocks, assume valid and available
|
|
@@ -333,16 +330,17 @@ async function processSlotsByCheckpoint(
|
|
|
333
330
|
metrics: Metrics | null;
|
|
334
331
|
validatorMonitor: ValidatorMonitor | null;
|
|
335
332
|
emitter: ChainEventEmitter;
|
|
333
|
+
config: ChainForkConfig;
|
|
336
334
|
logger: Logger;
|
|
337
335
|
},
|
|
338
|
-
preState:
|
|
336
|
+
preState: IBeaconStateView,
|
|
339
337
|
slot: Slot,
|
|
340
338
|
regenCaller: RegenCaller,
|
|
341
339
|
opts: StateRegenerationOpts
|
|
342
|
-
): Promise<
|
|
340
|
+
): Promise<IBeaconStateView> {
|
|
343
341
|
let postState = await processSlotsToNearestCheckpoint(modules, preState, slot, regenCaller, opts);
|
|
344
342
|
if (postState.slot < slot) {
|
|
345
|
-
postState = processSlots(
|
|
343
|
+
postState = postState.processSlots(slot, opts, modules);
|
|
346
344
|
}
|
|
347
345
|
return postState;
|
|
348
346
|
}
|
|
@@ -365,18 +363,19 @@ export async function processSlotsToNearestCheckpoint(
|
|
|
365
363
|
metrics: Metrics | null;
|
|
366
364
|
validatorMonitor: ValidatorMonitor | null;
|
|
367
365
|
emitter: ChainEventEmitter | null;
|
|
366
|
+
config: ChainForkConfig;
|
|
368
367
|
logger: Logger | null;
|
|
369
368
|
},
|
|
370
|
-
preState:
|
|
369
|
+
preState: IBeaconStateView,
|
|
371
370
|
slot: Slot,
|
|
372
371
|
regenCaller: RegenCaller,
|
|
373
372
|
opts: StateRegenerationOpts
|
|
374
|
-
): Promise<
|
|
373
|
+
): Promise<IBeaconStateView> {
|
|
375
374
|
const preSlot = preState.slot;
|
|
376
375
|
const postSlot = slot;
|
|
377
376
|
const preEpoch = computeEpochAtSlot(preSlot);
|
|
378
377
|
let postState = preState;
|
|
379
|
-
const {checkpointStateCache, emitter, metrics, logger} = modules;
|
|
378
|
+
const {config, checkpointStateCache, emitter, metrics, logger} = modules;
|
|
380
379
|
let count = 0;
|
|
381
380
|
|
|
382
381
|
for (
|
|
@@ -391,7 +390,7 @@ export async function processSlotsToNearestCheckpoint(
|
|
|
391
390
|
caller: regenCaller,
|
|
392
391
|
});
|
|
393
392
|
// processSlots calls .clone() before mutating
|
|
394
|
-
postState = processSlots(
|
|
393
|
+
postState = postState.processSlots(nextEpochSlot, opts, modules);
|
|
395
394
|
metrics?.epochTransitionByCaller.inc({caller: regenCaller});
|
|
396
395
|
|
|
397
396
|
// this is usually added when we prepare for next slot or validate gossip block
|
|
@@ -403,7 +402,7 @@ export async function processSlotsToNearestCheckpoint(
|
|
|
403
402
|
// processSlots() only does epoch transitions, never processes payloads
|
|
404
403
|
// Pre-Gloas: payloadPresent is always true (execution payload embedded in block)
|
|
405
404
|
// Post-Gloas: result is a block state (payloadPresent=false)
|
|
406
|
-
const isPayloadPresent =
|
|
405
|
+
const isPayloadPresent = config.getForkSeq(checkpointState.slot) < ForkSeq.gloas;
|
|
407
406
|
checkpointStateCache.add(cp, checkpointState, isPayloadPresent);
|
|
408
407
|
// consumers should not mutate state ever
|
|
409
408
|
emitter?.emit(ChainEvent.checkpoint, cp, checkpointState);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {IBeaconStateView} from "@lodestar/state-transition";
|
|
2
2
|
import {AllocSource, BufferPool} from "../util/bufferPool.js";
|
|
3
3
|
|
|
4
4
|
type ProcessStateBytesFn<T> = (stateBytes: Uint8Array) => Promise<T>;
|
|
@@ -7,12 +7,12 @@ type ProcessStateBytesFn<T> = (stateBytes: Uint8Array) => Promise<T>;
|
|
|
7
7
|
* Serialize state using the BufferPool if provided.
|
|
8
8
|
*/
|
|
9
9
|
export async function serializeState<T>(
|
|
10
|
-
state:
|
|
10
|
+
state: IBeaconStateView,
|
|
11
11
|
source: AllocSource,
|
|
12
12
|
processFn: ProcessStateBytesFn<T>,
|
|
13
13
|
bufferPool?: BufferPool | null
|
|
14
14
|
): Promise<T> {
|
|
15
|
-
const size = state.
|
|
15
|
+
const size = state.serializedSize();
|
|
16
16
|
let stateBytes: Uint8Array | null = null;
|
|
17
17
|
if (bufferPool) {
|
|
18
18
|
using bufferWithKey = bufferPool.alloc(size, source);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {ForkSeq} from "@lodestar/params";
|
|
2
2
|
import {
|
|
3
|
-
CachedBeaconStateAllForks,
|
|
4
3
|
EpochShuffling,
|
|
4
|
+
IBeaconStateView,
|
|
5
5
|
getAttestingIndices,
|
|
6
6
|
getBeaconCommittees,
|
|
7
7
|
getIndexedAttestation,
|
|
@@ -159,17 +159,15 @@ export class ShufflingCache {
|
|
|
159
159
|
* Process a state to extract and cache all shufflings (previous, current, next).
|
|
160
160
|
* Uses the stored decision roots from epochCtx.
|
|
161
161
|
*/
|
|
162
|
-
processState(state:
|
|
163
|
-
const {epochCtx} = state;
|
|
164
|
-
|
|
162
|
+
processState(state: IBeaconStateView): void {
|
|
165
163
|
// Cache previous shuffling
|
|
166
|
-
this.set(
|
|
164
|
+
this.set(state.getPreviousShuffling(), state.previousDecisionRoot);
|
|
167
165
|
|
|
168
166
|
// Cache current shuffling
|
|
169
|
-
this.set(
|
|
167
|
+
this.set(state.getCurrentShuffling(), state.currentDecisionRoot);
|
|
170
168
|
|
|
171
169
|
// Cache next shuffling
|
|
172
|
-
this.set(
|
|
170
|
+
this.set(state.getNextShuffling(), state.nextDecisionRoot);
|
|
173
171
|
}
|
|
174
172
|
|
|
175
173
|
getIndexedAttestation(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {routes} from "@lodestar/api";
|
|
2
|
-
import {
|
|
2
|
+
import {IBeaconStateView} from "@lodestar/state-transition";
|
|
3
3
|
import {RootHex} from "@lodestar/types";
|
|
4
4
|
import {toRootHex} from "@lodestar/utils";
|
|
5
5
|
import {Metrics} from "../../metrics/index.js";
|
|
@@ -48,7 +48,7 @@ export const DEFAULT_MAX_BLOCK_STATES_GLOAS = 128;
|
|
|
48
48
|
export class FIFOBlockStateCache implements BlockStateCache {
|
|
49
49
|
private maxStates: number;
|
|
50
50
|
|
|
51
|
-
private readonly cache: MapTracker<string,
|
|
51
|
+
private readonly cache: MapTracker<string, IBeaconStateView>;
|
|
52
52
|
/**
|
|
53
53
|
* Key order to implement FIFO cache
|
|
54
54
|
*/
|
|
@@ -68,7 +68,7 @@ export class FIFOBlockStateCache implements BlockStateCache {
|
|
|
68
68
|
/**
|
|
69
69
|
* Set a state as head, happens when importing a block and head block is changed.
|
|
70
70
|
*/
|
|
71
|
-
setHeadState(item:
|
|
71
|
+
setHeadState(item: IBeaconStateView | null): void {
|
|
72
72
|
if (item !== null) {
|
|
73
73
|
this.add(item, true);
|
|
74
74
|
}
|
|
@@ -79,7 +79,7 @@ export class FIFOBlockStateCache implements BlockStateCache {
|
|
|
79
79
|
* base merkle tree for all BeaconState objects across application.
|
|
80
80
|
* See packages/state-transition/src/util/loadState/loadState.ts for more detail
|
|
81
81
|
*/
|
|
82
|
-
getSeedState():
|
|
82
|
+
getSeedState(): IBeaconStateView {
|
|
83
83
|
const firstValue = this.cache.values().next();
|
|
84
84
|
if (firstValue.done) {
|
|
85
85
|
// should not happen
|
|
@@ -94,7 +94,7 @@ export class FIFOBlockStateCache implements BlockStateCache {
|
|
|
94
94
|
/**
|
|
95
95
|
* Get a state from this cache given a state root hex.
|
|
96
96
|
*/
|
|
97
|
-
get(rootHex: RootHex):
|
|
97
|
+
get(rootHex: RootHex): IBeaconStateView | null {
|
|
98
98
|
this.metrics?.lookups.inc();
|
|
99
99
|
const item = this.cache.get(rootHex);
|
|
100
100
|
if (!item) {
|
|
@@ -112,7 +112,7 @@ export class FIFOBlockStateCache implements BlockStateCache {
|
|
|
112
112
|
* @param isHead if true, move it to the head of the list. Otherwise add to the 2nd position.
|
|
113
113
|
* In importBlock() steps, normally it'll call add() with isHead = false first. Then call setHeadState() to set the head.
|
|
114
114
|
*/
|
|
115
|
-
add(item:
|
|
115
|
+
add(item: IBeaconStateView, isHead = false): void {
|
|
116
116
|
const key = toRootHex(item.hashTreeRoot());
|
|
117
117
|
if (this.cache.get(key) != null) {
|
|
118
118
|
if (!this.keyOrder.has(key)) {
|
|
@@ -200,7 +200,7 @@ export class FIFOBlockStateCache implements BlockStateCache {
|
|
|
200
200
|
}));
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
getStates(): IterableIterator<
|
|
203
|
+
getStates(): IterableIterator<IBeaconStateView> {
|
|
204
204
|
return this.cache.values();
|
|
205
205
|
}
|
|
206
206
|
|