@lodestar/beacon-node 1.46.0 → 1.47.0-dev.02d2dbea03
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 +6 -8
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/beacon/pool/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/pool/index.js +25 -2
- package/lib/api/impl/beacon/pool/index.js.map +1 -1
- package/lib/api/impl/beacon/state/utils.d.ts +2 -1
- package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
- package/lib/api/impl/beacon/state/utils.js.map +1 -1
- package/lib/api/impl/events/index.d.ts +1 -1
- package/lib/api/impl/events/index.d.ts.map +1 -1
- package/lib/api/impl/events/index.js +12 -3
- package/lib/api/impl/events/index.js.map +1 -1
- package/lib/api/impl/lodestar/index.d.ts.map +1 -1
- package/lib/api/impl/lodestar/index.js +12 -13
- package/lib/api/impl/lodestar/index.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +12 -22
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/api/impl/validator/utils.d.ts +5 -0
- package/lib/api/impl/validator/utils.d.ts.map +1 -1
- package/lib/api/impl/validator/utils.js +18 -12
- package/lib/api/impl/validator/utils.js.map +1 -1
- package/lib/api/rest/base.d.ts.map +1 -1
- package/lib/api/rest/base.js +7 -0
- package/lib/api/rest/base.js.map +1 -1
- package/lib/chain/archiveStore/archiveStore.js +1 -1
- package/lib/chain/archiveStore/archiveStore.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/metrics.d.ts.map +1 -1
- package/lib/chain/archiveStore/historicalState/metrics.js +21 -0
- package/lib/chain/archiveStore/historicalState/metrics.js.map +1 -1
- package/lib/chain/blocks/importBlock.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.js +3 -8
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts +3 -2
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +12 -10
- 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 +17 -11
- package/lib/chain/blocks/index.js.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +2 -1
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +6 -2
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +14 -5
- package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/types.js +5 -0
- package/lib/chain/blocks/payloadEnvelopeInput/types.js.map +1 -1
- package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlock.js +11 -16
- package/lib/chain/blocks/verifyBlock.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js +22 -12
- package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js.map +1 -1
- package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts +2 -2
- package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js +2 -2
- package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js.map +1 -1
- package/lib/chain/bls/index.d.ts +1 -1
- package/lib/chain/bls/index.d.ts.map +1 -1
- package/lib/chain/bls/interface.d.ts +5 -5
- package/lib/chain/bls/interface.d.ts.map +1 -1
- package/lib/chain/bls/multithread/index.d.ts +5 -11
- package/lib/chain/bls/multithread/index.d.ts.map +1 -1
- package/lib/chain/bls/multithread/index.js +116 -101
- package/lib/chain/bls/multithread/index.js.map +1 -1
- package/lib/chain/bls/multithread/jobItem.d.ts +5 -19
- package/lib/chain/bls/multithread/jobItem.d.ts.map +1 -1
- package/lib/chain/bls/multithread/jobItem.js +10 -65
- package/lib/chain/bls/multithread/jobItem.js.map +1 -1
- package/lib/chain/bls/multithread/types.d.ts +29 -8
- package/lib/chain/bls/multithread/types.d.ts.map +1 -1
- package/lib/chain/bls/multithread/types.js +12 -0
- package/lib/chain/bls/multithread/types.js.map +1 -1
- package/lib/chain/bls/multithread/utils.d.ts +4 -0
- package/lib/chain/bls/multithread/utils.d.ts.map +1 -1
- package/lib/chain/bls/multithread/utils.js +10 -0
- package/lib/chain/bls/multithread/utils.js.map +1 -1
- package/lib/chain/bls/multithread/worker.js +49 -23
- package/lib/chain/bls/multithread/worker.js.map +1 -1
- package/lib/chain/bls/singleThread.d.ts +4 -10
- package/lib/chain/bls/singleThread.d.ts.map +1 -1
- package/lib/chain/bls/singleThread.js +8 -45
- package/lib/chain/bls/singleThread.js.map +1 -1
- package/lib/chain/bls/utils.d.ts +4 -4
- package/lib/chain/bls/utils.d.ts.map +1 -1
- package/lib/chain/bls/utils.js +18 -19
- package/lib/chain/bls/utils.js.map +1 -1
- package/lib/chain/builderCircuitBreaker.d.ts +6 -5
- package/lib/chain/builderCircuitBreaker.d.ts.map +1 -1
- package/lib/chain/builderCircuitBreaker.js +28 -15
- package/lib/chain/builderCircuitBreaker.js.map +1 -1
- package/lib/chain/chain.d.ts +5 -3
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +24 -8
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/errors/blockError.d.ts +2 -0
- package/lib/chain/errors/blockError.d.ts.map +1 -1
- package/lib/chain/errors/blockError.js +6 -1
- package/lib/chain/errors/blockError.js.map +1 -1
- package/lib/chain/errors/proposerPreferences.d.ts +6 -0
- package/lib/chain/errors/proposerPreferences.d.ts.map +1 -1
- package/lib/chain/errors/proposerPreferences.js +1 -0
- package/lib/chain/errors/proposerPreferences.js.map +1 -1
- package/lib/chain/interface.d.ts +4 -2
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/interface.js.map +1 -1
- package/lib/chain/opPools/aggregatedAttestationPool.js +1 -1
- package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
- package/lib/chain/opPools/attestationPool.d.ts +1 -1
- package/lib/chain/opPools/attestationPool.d.ts.map +1 -1
- package/lib/chain/opPools/attestationPool.js +1 -1
- package/lib/chain/opPools/attestationPool.js.map +1 -1
- package/lib/chain/opPools/deferredVoluntaryExitPool.d.ts +16 -0
- package/lib/chain/opPools/deferredVoluntaryExitPool.d.ts.map +1 -0
- package/lib/chain/opPools/deferredVoluntaryExitPool.js +57 -0
- package/lib/chain/opPools/deferredVoluntaryExitPool.js.map +1 -0
- package/lib/chain/opPools/index.d.ts +1 -0
- package/lib/chain/opPools/index.d.ts.map +1 -1
- package/lib/chain/opPools/index.js +1 -0
- package/lib/chain/opPools/index.js.map +1 -1
- package/lib/chain/opPools/payloadAttestationPool.js +3 -3
- package/lib/chain/opPools/payloadAttestationPool.js.map +1 -1
- package/lib/chain/opPools/syncCommitteeMessagePool.js +1 -1
- package/lib/chain/opPools/syncCommitteeMessagePool.js.map +1 -1
- package/lib/chain/opPools/syncContributionAndProofPool.js +1 -1
- package/lib/chain/opPools/syncContributionAndProofPool.js.map +1 -1
- package/lib/chain/opPools/utils.d.ts +1 -1
- 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 -3
- package/lib/chain/options.d.ts.map +1 -1
- package/lib/chain/options.js.map +1 -1
- package/lib/chain/prepareNextSlot.js +2 -2
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +2 -0
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +8 -3
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/regen/interface.d.ts +4 -2
- package/lib/chain/regen/interface.d.ts.map +1 -1
- package/lib/chain/regen/interface.js +2 -0
- package/lib/chain/regen/interface.js.map +1 -1
- package/lib/chain/regen/queued.d.ts +2 -2
- package/lib/chain/regen/queued.d.ts.map +1 -1
- package/lib/chain/regen/queued.js +5 -5
- package/lib/chain/regen/queued.js.map +1 -1
- package/lib/chain/seenCache/seenAttesters.d.ts +9 -5
- package/lib/chain/seenCache/seenAttesters.d.ts.map +1 -1
- package/lib/chain/seenCache/seenAttesters.js +25 -4
- package/lib/chain/seenCache/seenAttesters.js.map +1 -1
- package/lib/chain/seenCache/seenBlockProposers.d.ts +5 -1
- package/lib/chain/seenCache/seenBlockProposers.d.ts.map +1 -1
- package/lib/chain/seenCache/seenBlockProposers.js +17 -7
- package/lib/chain/seenCache/seenBlockProposers.js.map +1 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +28 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +121 -13
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
- package/lib/chain/stateCache/fifoBlockStateCache.d.ts +5 -1
- package/lib/chain/stateCache/fifoBlockStateCache.d.ts.map +1 -1
- package/lib/chain/stateCache/fifoBlockStateCache.js +6 -0
- package/lib/chain/stateCache/fifoBlockStateCache.js.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +47 -5
- package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.js +117 -7
- package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
- package/lib/chain/stateCache/types.d.ts +3 -3
- package/lib/chain/stateCache/types.d.ts.map +1 -1
- package/lib/chain/validation/attestation.d.ts.map +1 -1
- package/lib/chain/validation/attestation.js +1 -4
- package/lib/chain/validation/attestation.js.map +1 -1
- package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
- package/lib/chain/validation/attesterSlashing.js +1 -1
- package/lib/chain/validation/attesterSlashing.js.map +1 -1
- package/lib/chain/validation/block.d.ts.map +1 -1
- package/lib/chain/validation/block.js +21 -7
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/validation/executionPayloadBid.js +1 -2
- package/lib/chain/validation/executionPayloadBid.js.map +1 -1
- package/lib/chain/validation/executionPayloadEnvelope.js +1 -1
- 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 +5 -14
- package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
- package/lib/chain/validation/proposerPreferences.d.ts +1 -1
- package/lib/chain/validation/proposerPreferences.d.ts.map +1 -1
- package/lib/chain/validation/proposerPreferences.js +13 -4
- package/lib/chain/validation/proposerPreferences.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/voluntaryExit.d.ts +9 -1
- package/lib/chain/validation/voluntaryExit.d.ts.map +1 -1
- package/lib/chain/validation/voluntaryExit.js +46 -1
- package/lib/chain/validation/voluntaryExit.js.map +1 -1
- package/lib/execution/builder/http.d.ts +10 -7
- package/lib/execution/builder/http.d.ts.map +1 -1
- package/lib/execution/builder/http.js +11 -8
- package/lib/execution/builder/http.js.map +1 -1
- package/lib/metrics/metrics/beacon.d.ts +3 -3
- package/lib/metrics/metrics/beacon.d.ts.map +1 -1
- package/lib/metrics/metrics/beacon.js +9 -9
- package/lib/metrics/metrics/beacon.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +71 -22
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +126 -52
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/gossip/topic.d.ts +13 -0
- package/lib/network/gossip/topic.d.ts.map +1 -1
- package/lib/network/gossip/topic.js +37 -0
- package/lib/network/gossip/topic.js.map +1 -1
- package/lib/network/libp2p/index.d.ts.map +1 -1
- package/lib/network/libp2p/index.js +10 -2
- package/lib/network/libp2p/index.js.map +1 -1
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js +22 -43
- package/lib/network/network.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +37 -6
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/reqresp/score.d.ts.map +1 -1
- package/lib/network/reqresp/score.js +5 -11
- package/lib/network/reqresp/score.js.map +1 -1
- package/lib/network/util.d.ts +0 -1
- package/lib/network/util.d.ts.map +1 -1
- package/lib/network/util.js +0 -4
- package/lib/network/util.js.map +1 -1
- package/lib/node/deferredVoluntaryExitPublisher.d.ts +15 -0
- package/lib/node/deferredVoluntaryExitPublisher.d.ts.map +1 -0
- package/lib/node/deferredVoluntaryExitPublisher.js +38 -0
- package/lib/node/deferredVoluntaryExitPublisher.js.map +1 -0
- package/lib/node/nodejs.d.ts +2 -1
- package/lib/node/nodejs.d.ts.map +1 -1
- package/lib/node/nodejs.js +2 -0
- package/lib/node/nodejs.js.map +1 -1
- package/lib/sync/range/batch.d.ts +23 -5
- package/lib/sync/range/batch.d.ts.map +1 -1
- package/lib/sync/range/batch.js +62 -23
- package/lib/sync/range/batch.js.map +1 -1
- package/lib/sync/range/chain.d.ts +2 -1
- package/lib/sync/range/chain.d.ts.map +1 -1
- package/lib/sync/range/chain.js +23 -10
- package/lib/sync/range/chain.js.map +1 -1
- package/lib/sync/range/utils/hashBlocks.d.ts +16 -4
- package/lib/sync/range/utils/hashBlocks.d.ts.map +1 -1
- package/lib/sync/range/utils/hashBlocks.js +49 -18
- package/lib/sync/range/utils/hashBlocks.js.map +1 -1
- package/lib/sync/types.d.ts +32 -0
- package/lib/sync/types.d.ts.map +1 -1
- package/lib/sync/types.js +33 -0
- package/lib/sync/types.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts +9 -0
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +187 -47
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRange.js +16 -11
- package/lib/sync/utils/downloadByRange.js.map +1 -1
- package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRoot.js +3 -1
- package/lib/sync/utils/downloadByRoot.js.map +1 -1
- package/package.json +37 -37
- package/src/api/impl/beacon/blocks/index.ts +7 -8
- package/src/api/impl/beacon/pool/index.ts +27 -2
- package/src/api/impl/beacon/state/utils.ts +2 -1
- package/src/api/impl/events/index.ts +12 -4
- package/src/api/impl/lodestar/index.ts +12 -13
- package/src/api/impl/validator/index.ts +22 -27
- package/src/api/impl/validator/utils.ts +30 -15
- package/src/api/rest/base.ts +7 -0
- package/src/chain/archiveStore/archiveStore.ts +1 -1
- package/src/chain/archiveStore/historicalState/metrics.ts +22 -0
- package/src/chain/blocks/importBlock.ts +2 -7
- package/src/chain/blocks/importExecutionPayload.ts +13 -12
- package/src/chain/blocks/index.ts +21 -11
- package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +8 -2
- package/src/chain/blocks/payloadEnvelopeInput/types.ts +17 -4
- package/src/chain/blocks/verifyBlock.ts +21 -25
- package/src/chain/blocks/verifyBlocksStateTransitionOnly.ts +25 -16
- package/src/chain/blocks/verifyExecutionPayloadEnvelope.ts +1 -9
- package/src/chain/bls/index.ts +1 -1
- package/src/chain/bls/interface.ts +7 -3
- package/src/chain/bls/multithread/index.ts +148 -120
- package/src/chain/bls/multithread/jobItem.ts +12 -82
- package/src/chain/bls/multithread/types.ts +33 -8
- package/src/chain/bls/multithread/utils.ts +11 -0
- package/src/chain/bls/multithread/worker.ts +85 -27
- package/src/chain/bls/singleThread.ts +11 -55
- package/src/chain/bls/utils.ts +23 -24
- package/src/chain/builderCircuitBreaker.ts +31 -17
- package/src/chain/chain.ts +25 -7
- package/src/chain/errors/blockError.ts +9 -3
- package/src/chain/errors/proposerPreferences.ts +7 -0
- package/src/chain/interface.ts +4 -1
- package/src/chain/opPools/aggregatedAttestationPool.ts +1 -1
- package/src/chain/opPools/attestationPool.ts +1 -1
- package/src/chain/opPools/deferredVoluntaryExitPool.ts +65 -0
- package/src/chain/opPools/index.ts +1 -0
- package/src/chain/opPools/payloadAttestationPool.ts +3 -3
- package/src/chain/opPools/syncCommitteeMessagePool.ts +1 -1
- package/src/chain/opPools/syncContributionAndProofPool.ts +1 -1
- package/src/chain/opPools/utils.ts +1 -1
- package/src/chain/options.ts +1 -3
- package/src/chain/prepareNextSlot.ts +2 -2
- package/src/chain/produceBlock/produceBlockBody.ts +15 -2
- package/src/chain/regen/interface.ts +4 -2
- package/src/chain/regen/queued.ts +5 -5
- package/src/chain/seenCache/seenAttesters.ts +31 -5
- package/src/chain/seenCache/seenBlockProposers.ts +24 -7
- package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +143 -14
- package/src/chain/stateCache/fifoBlockStateCache.ts +8 -1
- package/src/chain/stateCache/persistentCheckpointsCache.ts +133 -8
- package/src/chain/stateCache/types.ts +3 -3
- package/src/chain/validation/attestation.ts +1 -7
- package/src/chain/validation/attesterSlashing.ts +1 -8
- package/src/chain/validation/block.ts +21 -7
- package/src/chain/validation/executionPayloadBid.ts +1 -2
- package/src/chain/validation/executionPayloadEnvelope.ts +0 -1
- package/src/chain/validation/payloadAttestationMessage.ts +6 -17
- package/src/chain/validation/proposerPreferences.ts +15 -5
- package/src/chain/validation/proposerSlashing.ts +1 -1
- package/src/chain/validation/voluntaryExit.ts +59 -2
- package/src/execution/builder/http.ts +11 -11
- package/src/metrics/metrics/beacon.ts +9 -9
- package/src/metrics/metrics/lodestar.ts +138 -57
- package/src/network/gossip/topic.ts +38 -0
- package/src/network/libp2p/index.ts +11 -2
- package/src/network/network.ts +27 -55
- package/src/network/processor/gossipHandlers.ts +40 -4
- package/src/network/reqresp/score.ts +5 -11
- package/src/network/util.ts +0 -5
- package/src/node/deferredVoluntaryExitPublisher.ts +54 -0
- package/src/node/nodejs.ts +5 -1
- package/src/sync/range/batch.ts +84 -29
- package/src/sync/range/chain.ts +26 -11
- package/src/sync/range/utils/hashBlocks.ts +56 -21
- package/src/sync/types.ts +36 -1
- package/src/sync/unknownBlock.ts +212 -53
- package/src/sync/utils/downloadByRange.ts +21 -12
- package/src/sync/utils/downloadByRoot.ts +3 -1
- package/lib/chain/bls/maybeBatch.d.ts +0 -12
- package/lib/chain/bls/maybeBatch.d.ts.map +0 -1
- package/lib/chain/bls/maybeBatch.js +0 -35
- package/lib/chain/bls/maybeBatch.js.map +0 -1
- package/src/chain/bls/maybeBatch.ts +0 -45
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {Logger} from "@lodestar/logger";
|
|
2
|
+
import {IBeaconStateView, VoluntaryExitValidity} from "@lodestar/state-transition";
|
|
3
|
+
import {Epoch, ValidatorIndex} from "@lodestar/types";
|
|
4
|
+
import {SignedVoluntaryExit} from "@lodestar/types/phase0";
|
|
5
|
+
import {isTransientExitValidity} from "../validation/voluntaryExit.js";
|
|
6
|
+
|
|
7
|
+
type DeferredEntry = {
|
|
8
|
+
exit: SignedVoluntaryExit;
|
|
9
|
+
validity: VoluntaryExitValidity;
|
|
10
|
+
insertedAtEpoch: Epoch;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export class DeferredVoluntaryExitPool {
|
|
14
|
+
private pool = new Map<ValidatorIndex, DeferredEntry>();
|
|
15
|
+
|
|
16
|
+
constructor(
|
|
17
|
+
private readonly logger: Logger,
|
|
18
|
+
private readonly maxSize = 1024,
|
|
19
|
+
private readonly maxDeferEpochs = 4096
|
|
20
|
+
) {}
|
|
21
|
+
|
|
22
|
+
insert(exit: SignedVoluntaryExit, validity: VoluntaryExitValidity, currentEpoch: Epoch): boolean {
|
|
23
|
+
if (!isTransientExitValidity(validity)) return false;
|
|
24
|
+
if (this.pool.size === this.maxSize) return false;
|
|
25
|
+
if (this.pool.has(exit.message.validatorIndex)) return false;
|
|
26
|
+
|
|
27
|
+
this.pool.set(exit.message.validatorIndex, {exit, validity, insertedAtEpoch: currentEpoch});
|
|
28
|
+
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
drainProcessableExits(state: IBeaconStateView): SignedVoluntaryExit[] {
|
|
33
|
+
const epoch = state.epoch;
|
|
34
|
+
const validExits: SignedVoluntaryExit[] = [];
|
|
35
|
+
for (const [validatorIndex, entry] of this.pool) {
|
|
36
|
+
try {
|
|
37
|
+
if (epoch - entry.insertedAtEpoch > this.maxDeferEpochs) {
|
|
38
|
+
this.pool.delete(validatorIndex);
|
|
39
|
+
this.logger.debug("Deferred voluntary exit expired", {validatorIndex, lastValidity: entry.validity});
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const validity = state.getVoluntaryExitValidity(entry.exit, true);
|
|
43
|
+
if (validity === VoluntaryExitValidity.valid) {
|
|
44
|
+
validExits.push(entry.exit);
|
|
45
|
+
this.pool.delete(validatorIndex);
|
|
46
|
+
} else if (!isTransientExitValidity(validity)) {
|
|
47
|
+
this.logger.debug("Deferred voluntary exit became permanently invalid", {validatorIndex, validity});
|
|
48
|
+
this.pool.delete(validatorIndex);
|
|
49
|
+
}
|
|
50
|
+
// Else if still transient - keep
|
|
51
|
+
} catch (e) {
|
|
52
|
+
this.logger.debug("Processing deferred voluntary exit failed", {validatorIndex}, e as Error);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return validExits;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
has(validatorIndex: ValidatorIndex): boolean {
|
|
59
|
+
return this.pool.has(validatorIndex);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
size(): number {
|
|
63
|
+
return this.pool.size;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export {AggregatedAttestationPool} from "./aggregatedAttestationPool.js";
|
|
2
2
|
export {AttestationPool} from "./attestationPool.js";
|
|
3
|
+
export {DeferredVoluntaryExitPool} from "./deferredVoluntaryExitPool.js";
|
|
3
4
|
export {ExecutionPayloadBidPool} from "./executionPayloadBidPool.js";
|
|
4
5
|
export {OpPool} from "./opPool.js";
|
|
5
6
|
export {PayloadAttestationPool} from "./payloadAttestationPool.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Signature, aggregateSignatures} from "@chainsafe/blst";
|
|
1
|
+
import {Signature, aggregateSignatures} from "@chainsafe/lodestar-z/blst";
|
|
2
2
|
import {BitArray} from "@chainsafe/ssz";
|
|
3
3
|
import {ChainForkConfig} from "@lodestar/config";
|
|
4
4
|
import {MAX_COMMITTEES_PER_SLOT, MAX_PAYLOAD_ATTESTATIONS, PTC_SIZE} from "@lodestar/params";
|
|
@@ -178,8 +178,8 @@ function aggregateMessageInto(
|
|
|
178
178
|
validatorCommitteeIndices: number[],
|
|
179
179
|
aggregate: AggregateFast
|
|
180
180
|
): InsertOutcome {
|
|
181
|
-
// Gossip dedup via `seenPayloadAttesters` is keyed by (
|
|
182
|
-
// validator's message is never processed twice
|
|
181
|
+
// Gossip dedup via `seenPayloadAttesters` is keyed by (slot, validatorIndex), so the same
|
|
182
|
+
// validator's message is never processed twice for this aggregate's slot. All of its bits are set together or none.
|
|
183
183
|
// Checking the first index is sufficient.
|
|
184
184
|
if (aggregate.aggregationBits.get(validatorCommitteeIndices[0]) === true) {
|
|
185
185
|
return InsertOutcome.AlreadyKnown;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Signature, aggregateSignatures} from "@chainsafe/blst";
|
|
1
|
+
import {Signature, aggregateSignatures} from "@chainsafe/lodestar-z/blst";
|
|
2
2
|
import {BitArray} from "@chainsafe/ssz";
|
|
3
3
|
import {ChainForkConfig} from "@lodestar/config";
|
|
4
4
|
import {SYNC_COMMITTEE_SIZE, SYNC_COMMITTEE_SUBNET_COUNT} from "@lodestar/params";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Signature, aggregateSignatures} from "@chainsafe/blst";
|
|
1
|
+
import {Signature, aggregateSignatures} from "@chainsafe/lodestar-z/blst";
|
|
2
2
|
import {BitArray} from "@chainsafe/ssz";
|
|
3
3
|
import {ChainForkConfig} from "@lodestar/config";
|
|
4
4
|
import {SYNC_COMMITTEE_SIZE, SYNC_COMMITTEE_SUBNET_SIZE} from "@lodestar/params";
|
package/src/chain/options.ts
CHANGED
|
@@ -53,7 +53,7 @@ export type IChainOptions = BlockProcessOpts &
|
|
|
53
53
|
nativeStateView?: boolean;
|
|
54
54
|
/** Builder circuit breaker fault inspection window in slots */
|
|
55
55
|
faultInspectionWindow?: number;
|
|
56
|
-
/**
|
|
56
|
+
/** Canonical EMPTY blocks allowed per `faultInspectionWindow` observed blocks */
|
|
57
57
|
allowedFaults?: number;
|
|
58
58
|
};
|
|
59
59
|
|
|
@@ -86,8 +86,6 @@ export type BlockProcessOpts = {
|
|
|
86
86
|
verifyOnly?: boolean;
|
|
87
87
|
/** Used to specify to skip execution payload validation */
|
|
88
88
|
skipVerifyExecutionPayload?: boolean;
|
|
89
|
-
/** Used to specify to skip block signatures validation */
|
|
90
|
-
skipVerifyBlockSignatures?: boolean;
|
|
91
89
|
};
|
|
92
90
|
|
|
93
91
|
export type PoolOpts = {
|
|
@@ -169,7 +169,7 @@ export class PrepareNextSlotScheduler {
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
if (isForkPostGloas(fork)) {
|
|
172
|
-
this.chain.builderCircuitBreaker.update(clockSlot);
|
|
172
|
+
this.chain.builderCircuitBreaker.update(clockSlot, updatedHead);
|
|
173
173
|
} else {
|
|
174
174
|
// Update the builder status, if enabled shoot an api call to check status
|
|
175
175
|
this.chain.updateBuilderStatus(clockSlot);
|
|
@@ -224,7 +224,7 @@ export class PrepareNextSlotScheduler {
|
|
|
224
224
|
this.metrics?.blockPayload.payloadAdvancePrepTime.observe(preparationTime);
|
|
225
225
|
|
|
226
226
|
const safeBlockHash = getSafeExecutionBlockHash(this.chain.forkChoice, this.logger);
|
|
227
|
-
const finalizedBlockHash = getFinalizedExecutionBlockHash(this.chain.forkChoice
|
|
227
|
+
const finalizedBlockHash = getFinalizedExecutionBlockHash(this.chain.forkChoice);
|
|
228
228
|
|
|
229
229
|
// awaiting here instead of throwing an async call because there is no other task
|
|
230
230
|
// left for scheduler and this gives nice semantics to catch and log errors in the
|
|
@@ -100,6 +100,8 @@ export type BlockAttributes = {
|
|
|
100
100
|
slot: Slot;
|
|
101
101
|
parentBlock: ProtoBlock;
|
|
102
102
|
feeRecipient?: string;
|
|
103
|
+
/** Verify that a locally produced execution payload uses `feeRecipient`. */
|
|
104
|
+
strictFeeRecipientCheck?: boolean;
|
|
103
105
|
/** When provided, build block with this builder bid instead of a self-build bid */
|
|
104
106
|
builderBid?: gloas.SignedExecutionPayloadBid;
|
|
105
107
|
};
|
|
@@ -201,6 +203,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
201
203
|
const {
|
|
202
204
|
slot: blockSlot,
|
|
203
205
|
feeRecipient: requestedFeeRecipient,
|
|
206
|
+
strictFeeRecipientCheck,
|
|
204
207
|
parentBlock,
|
|
205
208
|
proposerIndex,
|
|
206
209
|
proposerPubKey,
|
|
@@ -271,7 +274,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
271
274
|
// full and blinded no longer makes sense in gloas, it might be a good idea to move
|
|
272
275
|
// this into a completely separate function and have pre/post gloas more separated
|
|
273
276
|
const safeBlockHash = getSafeExecutionBlockHash(this.forkChoice, this.logger);
|
|
274
|
-
const finalizedBlockHash = getFinalizedExecutionBlockHash(this.forkChoice
|
|
277
|
+
const finalizedBlockHash = getFinalizedExecutionBlockHash(this.forkChoice);
|
|
275
278
|
// TODO GLOAS: post-Gloas, proposer feeRecipient is also carried (signed) in
|
|
276
279
|
// ProposerPreferencesPool. Consider using this unified cache instead
|
|
277
280
|
// see https://github.com/ChainSafe/lodestar/issues/9379
|
|
@@ -334,6 +337,16 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
334
337
|
executionPayloadValue = payloadRes.executionPayloadValue;
|
|
335
338
|
shouldOverrideBuilder = payloadRes.shouldOverrideBuilder;
|
|
336
339
|
|
|
340
|
+
if (
|
|
341
|
+
strictFeeRecipientCheck &&
|
|
342
|
+
requestedFeeRecipient &&
|
|
343
|
+
!byteArrayEquals(executionPayload.feeRecipient, fromHex(requestedFeeRecipient))
|
|
344
|
+
) {
|
|
345
|
+
throw Error(
|
|
346
|
+
`Invalid feeRecipient set in engine payload expected=${requestedFeeRecipient} actual=${toHex(executionPayload.feeRecipient)}`
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
|
|
337
350
|
if (blobsBundle === undefined) {
|
|
338
351
|
throw Error(`Missing blobsBundle response from getPayload at fork=${fork}`);
|
|
339
352
|
}
|
|
@@ -417,7 +430,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
417
430
|
}
|
|
418
431
|
|
|
419
432
|
const safeBlockHash = getSafeExecutionBlockHash(this.forkChoice, this.logger);
|
|
420
|
-
const finalizedBlockHash = getFinalizedExecutionBlockHash(this.forkChoice
|
|
433
|
+
const finalizedBlockHash = getFinalizedExecutionBlockHash(this.forkChoice);
|
|
421
434
|
const feeRecipient = requestedFeeRecipient ?? this.beaconProposerCache.getOrDefault(proposerIndex);
|
|
422
435
|
const feeRecipientType = requestedFeeRecipient
|
|
423
436
|
? "requested"
|
|
@@ -21,6 +21,8 @@ export enum RegenCaller {
|
|
|
21
21
|
validateGossipAggregateAndProof = "validateGossipAggregateAndProof",
|
|
22
22
|
validateGossipAttestation = "validateGossipAttestation",
|
|
23
23
|
validateGossipVoluntaryExit = "validateGossipVoluntaryExit",
|
|
24
|
+
validateApiVoluntaryExit = "validateApiVoluntaryExit",
|
|
25
|
+
publishDeferredVoluntaryExits = "publishDeferredVoluntaryExits",
|
|
24
26
|
validateGossipExecutionPayloadBid = "validateGossipExecutionPayloadBid",
|
|
25
27
|
validateGossipPayloadAttestationMessage = "validateGossipPayloadAttestationMessage",
|
|
26
28
|
validateGossipProposerPreferences = "validateGossipProposerPreferences",
|
|
@@ -39,14 +41,14 @@ export type StateRegenerationOpts = {
|
|
|
39
41
|
};
|
|
40
42
|
|
|
41
43
|
export interface IStateRegenerator extends IStateRegeneratorInternal {
|
|
42
|
-
dropCache(): void
|
|
44
|
+
dropCache(): Promise<void>;
|
|
43
45
|
dumpCacheSummary(): routes.lodestar.StateCacheItem[];
|
|
44
46
|
getStateSync(stateRoot: RootHex): IBeaconStateView | null;
|
|
45
47
|
getPreStateSync(block: BeaconBlock): IBeaconStateView | null;
|
|
46
48
|
getCheckpointStateOrBytes(cp: CheckpointHex): Promise<IBeaconStateView | Uint8Array | null>;
|
|
47
49
|
getCheckpointStateSync(cp: CheckpointHex): IBeaconStateView | null;
|
|
48
50
|
getClosestHeadState(head: ProtoBlock): IBeaconStateView | null;
|
|
49
|
-
|
|
51
|
+
onCheckpoint(finalizedEpoch: Epoch, justifiedEpoch: Epoch, headStateRoot: RootHex): void;
|
|
50
52
|
processState(blockRootHex: RootHex, postState: IBeaconStateView): void;
|
|
51
53
|
addCheckpointState(cp: phase0.Checkpoint, item: IBeaconStateView): void;
|
|
52
54
|
updateHeadState(newHead: ProtoBlock, maybeHeadState: IBeaconStateView): void;
|
|
@@ -67,9 +67,9 @@ export class QueuedStateRegenerator implements IStateRegenerator {
|
|
|
67
67
|
return this.jobQueue.jobLen < REGEN_CAN_ACCEPT_WORK_THRESHOLD;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
dropCache(): void {
|
|
70
|
+
async dropCache(): Promise<void> {
|
|
71
71
|
this.blockStateCache.clear();
|
|
72
|
-
this.checkpointStateCache.clear();
|
|
72
|
+
await this.checkpointStateCache.clear();
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
dumpCacheSummary(): routes.lodestar.StateCacheItem[] {
|
|
@@ -138,9 +138,9 @@ export class QueuedStateRegenerator implements IStateRegenerator {
|
|
|
138
138
|
return this.checkpointStateCache.getLatest(head.blockRoot, Infinity) || this.blockStateCache.get(head.stateRoot);
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
|
|
142
|
-
this.checkpointStateCache.
|
|
143
|
-
this.blockStateCache.
|
|
141
|
+
onCheckpoint(finalizedEpoch: Epoch, justifiedEpoch: Epoch, headStateRoot: RootHex): void {
|
|
142
|
+
this.checkpointStateCache.onCheckpoint(finalizedEpoch, justifiedEpoch);
|
|
143
|
+
this.blockStateCache.onCheckpoint(headStateRoot);
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
processState(blockRootHex: RootHex, postState: IBeaconStateView): void {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {computeEpochAtSlot} from "@lodestar/state-transition";
|
|
2
|
+
import {Epoch, Slot, ValidatorIndex} from "@lodestar/types";
|
|
2
3
|
import {MapDef} from "@lodestar/utils";
|
|
3
4
|
|
|
4
5
|
// How many *non future* epochs we intend to keep for SeenAttesters.
|
|
@@ -57,7 +58,32 @@ export class SeenAttesters {
|
|
|
57
58
|
*/
|
|
58
59
|
export class SeenAggregators extends SeenAttesters {}
|
|
59
60
|
|
|
60
|
-
/**
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
/** Keeps a cache to filter payload attestations from the same validator in the same slot. */
|
|
62
|
+
export class SeenPayloadAttesters {
|
|
63
|
+
private readonly validatorIndexesBySlot = new MapDef<Slot, Set<ValidatorIndex>>(() => new Set<ValidatorIndex>());
|
|
64
|
+
private readonly validatorIndexesByEpoch = new SeenAttesters();
|
|
65
|
+
|
|
66
|
+
isKnown(slot: Slot, validatorIndex: ValidatorIndex): boolean {
|
|
67
|
+
return this.validatorIndexesBySlot.get(slot)?.has(validatorIndex) === true;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
add(slot: Slot, validatorIndex: ValidatorIndex): void {
|
|
71
|
+
const epoch = computeEpochAtSlot(slot);
|
|
72
|
+
this.validatorIndexesByEpoch.add(epoch, validatorIndex);
|
|
73
|
+
this.validatorIndexesBySlot.getOrDefault(slot).add(validatorIndex);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
seenAtEpoch(epoch: Epoch, validatorIndex: ValidatorIndex): boolean {
|
|
77
|
+
return this.validatorIndexesByEpoch.isKnown(epoch, validatorIndex);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
prune(currentEpoch: Epoch): void {
|
|
81
|
+
const lowestPermissibleEpoch = Math.max(currentEpoch - EPOCH_LOOKBACK_LIMIT, 0);
|
|
82
|
+
for (const slot of this.validatorIndexesBySlot.keys()) {
|
|
83
|
+
if (computeEpochAtSlot(slot) < lowestPermissibleEpoch) {
|
|
84
|
+
this.validatorIndexesBySlot.delete(slot);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
this.validatorIndexesByEpoch.prune(currentEpoch);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -3,7 +3,7 @@ import {Epoch, RootHex, Slot, ValidatorIndex, phase0} from "@lodestar/types";
|
|
|
3
3
|
import {MapDef} from "@lodestar/utils";
|
|
4
4
|
|
|
5
5
|
/** Two distinct block roots signed by the same proposer for the same slot are sufficient to establish an equivocation */
|
|
6
|
-
const
|
|
6
|
+
const MIN_EQUIVOCATION_BLOCK_ROOTS_PER_PROPOSAL = 2;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Keeps a cache to filter block proposals from the same validator in the same slot.
|
|
@@ -19,7 +19,9 @@ const MAX_BLOCK_ROOTS_PER_PROPOSAL = 2;
|
|
|
19
19
|
* The cache is pruned on finalization and bounds the number of roots stored per proposer and slot
|
|
20
20
|
*/
|
|
21
21
|
export class SeenBlockProposers {
|
|
22
|
-
private readonly proposerIndexesBySlot = new MapDef<Slot,
|
|
22
|
+
private readonly proposerIndexesBySlot = new MapDef<Slot, Map<ValidatorIndex, RootHex>>(
|
|
23
|
+
() => new Map<ValidatorIndex, RootHex>()
|
|
24
|
+
);
|
|
23
25
|
private readonly signedBlockHeadersBySlot = new MapDef<
|
|
24
26
|
Slot,
|
|
25
27
|
MapDef<ValidatorIndex, Map<RootHex, phase0.SignedBeaconBlockHeader>>
|
|
@@ -30,13 +32,22 @@ export class SeenBlockProposers {
|
|
|
30
32
|
return this.proposerIndexesBySlot.get(blockSlot)?.has(proposerIndex) === true;
|
|
31
33
|
}
|
|
32
34
|
|
|
35
|
+
/**
|
|
36
|
+
* The block proposer is known at slot with a different root.
|
|
37
|
+
*/
|
|
38
|
+
isRepeatProposal(blockSlot: Slot, proposerIndex: ValidatorIndex, blockRoot: RootHex): boolean {
|
|
39
|
+
const knownRoot = this.proposerIndexesBySlot.get(blockSlot)?.get(proposerIndex);
|
|
40
|
+
return knownRoot !== undefined && knownRoot !== blockRoot;
|
|
41
|
+
}
|
|
42
|
+
|
|
33
43
|
hasBlockRoot(blockSlot: Slot, proposerIndex: ValidatorIndex, blockRoot: RootHex): boolean {
|
|
34
44
|
return this.signedBlockHeadersBySlot.get(blockSlot)?.get(proposerIndex)?.has(blockRoot) === true;
|
|
35
45
|
}
|
|
36
46
|
|
|
37
47
|
isEquivocating(blockSlot: Slot, proposerIndex: ValidatorIndex): boolean {
|
|
38
48
|
return (
|
|
39
|
-
(this.signedBlockHeadersBySlot.get(blockSlot)?.get(proposerIndex)?.size ?? 0) >=
|
|
49
|
+
(this.signedBlockHeadersBySlot.get(blockSlot)?.get(proposerIndex)?.size ?? 0) >=
|
|
50
|
+
MIN_EQUIVOCATION_BLOCK_ROOTS_PER_PROPOSAL
|
|
40
51
|
);
|
|
41
52
|
}
|
|
42
53
|
|
|
@@ -53,7 +64,10 @@ export class SeenBlockProposers {
|
|
|
53
64
|
proposerIndex: ValidatorIndex
|
|
54
65
|
): [phase0.SignedBeaconBlockHeader, phase0.SignedBeaconBlockHeader] | null {
|
|
55
66
|
const signedBlockHeaderByRoot = this.signedBlockHeadersBySlot.get(blockSlot)?.get(proposerIndex);
|
|
56
|
-
if (
|
|
67
|
+
if (
|
|
68
|
+
signedBlockHeaderByRoot === undefined ||
|
|
69
|
+
signedBlockHeaderByRoot.size < MIN_EQUIVOCATION_BLOCK_ROOTS_PER_PROPOSAL
|
|
70
|
+
) {
|
|
57
71
|
return null;
|
|
58
72
|
}
|
|
59
73
|
const [signedHeader1, signedHeader2] = signedBlockHeaderByRoot.values();
|
|
@@ -72,18 +86,21 @@ export class SeenBlockProposers {
|
|
|
72
86
|
}
|
|
73
87
|
|
|
74
88
|
const signedBlockHeaderByRoot = this.signedBlockHeadersBySlot.getOrDefault(blockSlot).getOrDefault(proposerIndex);
|
|
75
|
-
if (
|
|
89
|
+
if (
|
|
90
|
+
signedBlockHeaderByRoot.size < MIN_EQUIVOCATION_BLOCK_ROOTS_PER_PROPOSAL &&
|
|
91
|
+
!signedBlockHeaderByRoot.has(blockRoot)
|
|
92
|
+
) {
|
|
76
93
|
signedBlockHeaderByRoot.set(blockRoot, signedBlockHeader);
|
|
77
94
|
}
|
|
78
95
|
}
|
|
79
96
|
|
|
80
97
|
/** Mark a block as known from gossip or another block import path */
|
|
81
|
-
add(blockSlot: Slot, proposerIndex: ValidatorIndex): void {
|
|
98
|
+
add(blockSlot: Slot, proposerIndex: ValidatorIndex, blockRoot: RootHex): void {
|
|
82
99
|
if (blockSlot < this.finalizedSlot) {
|
|
83
100
|
throw Error(`blockSlot ${blockSlot} < finalizedSlot ${this.finalizedSlot}`);
|
|
84
101
|
}
|
|
85
102
|
|
|
86
|
-
this.proposerIndexesBySlot.getOrDefault(blockSlot).
|
|
103
|
+
this.proposerIndexesBySlot.getOrDefault(blockSlot).set(proposerIndex, blockRoot);
|
|
87
104
|
}
|
|
88
105
|
|
|
89
106
|
prune(finalizedSlot: Slot): void {
|
|
@@ -1,18 +1,32 @@
|
|
|
1
1
|
import {ChainForkConfig} from "@lodestar/config";
|
|
2
2
|
import {CheckpointWithHex, IForkChoice, PayloadStatus, ProtoBlock} from "@lodestar/fork-choice";
|
|
3
|
+
import {ForkPostGloas, SLOTS_PER_EPOCH, isForkPostGloas} from "@lodestar/params";
|
|
3
4
|
import {computeStartSlotAtEpoch} from "@lodestar/state-transition";
|
|
4
|
-
import {RootHex} from "@lodestar/types";
|
|
5
|
-
import {Logger} from "@lodestar/utils";
|
|
5
|
+
import {RootHex, SignedBeaconBlock} from "@lodestar/types";
|
|
6
|
+
import {Logger, fromHex} from "@lodestar/utils";
|
|
7
|
+
import {IBeaconDb} from "../../db/index.js";
|
|
6
8
|
import {Metrics} from "../../metrics/metrics.js";
|
|
9
|
+
import {MAX_LOOK_AHEAD_EPOCHS} from "../../sync/constants.js";
|
|
7
10
|
import {IClock} from "../../util/clock.js";
|
|
11
|
+
import {CustodyConfig} from "../../util/dataColumns.js";
|
|
8
12
|
import {SerializedCache} from "../../util/serializedCache.js";
|
|
9
13
|
import {isDaOutOfRange} from "../blocks/blockInput/index.js";
|
|
10
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
CreateFromBidProps,
|
|
16
|
+
CreateFromBlockProps,
|
|
17
|
+
PayloadEnvelopeInput,
|
|
18
|
+
PayloadEnvelopeInputPruneReason,
|
|
19
|
+
PayloadEnvelopeInputSource,
|
|
20
|
+
} from "../blocks/payloadEnvelopeInput/index.js";
|
|
11
21
|
import {ChainEvent, ChainEventEmitter} from "../emitter.js";
|
|
22
|
+
import {SeenBlockInput} from "./seenGossipBlockInput.js";
|
|
12
23
|
|
|
13
24
|
export type {PayloadEnvelopeInputState} from "../blocks/payloadEnvelopeInput/index.js";
|
|
14
25
|
export {PayloadEnvelopeInput} from "../blocks/payloadEnvelopeInput/index.js";
|
|
15
26
|
|
|
27
|
+
// Bound this cache by this max size, this is the same to SeenBlockInput
|
|
28
|
+
const MAX_PAYLOAD_ENVELOPE_INPUT_CACHE_SIZE = (MAX_LOOK_AHEAD_EPOCHS + 1) * SLOTS_PER_EPOCH;
|
|
29
|
+
|
|
16
30
|
export type SeenPayloadEnvelopeInputModules = {
|
|
17
31
|
config: ChainForkConfig;
|
|
18
32
|
clock: IClock;
|
|
@@ -20,6 +34,9 @@ export type SeenPayloadEnvelopeInputModules = {
|
|
|
20
34
|
chainEvents: ChainEventEmitter;
|
|
21
35
|
signal: AbortSignal;
|
|
22
36
|
serializedCache: SerializedCache;
|
|
37
|
+
db: IBeaconDb;
|
|
38
|
+
seenBlockInputCache: SeenBlockInput;
|
|
39
|
+
custodyConfig: CustodyConfig;
|
|
23
40
|
metrics: Metrics | null;
|
|
24
41
|
logger?: Logger;
|
|
25
42
|
};
|
|
@@ -40,9 +57,14 @@ export class SeenPayloadEnvelopeInput {
|
|
|
40
57
|
private readonly chainEvents: ChainEventEmitter;
|
|
41
58
|
private readonly signal: AbortSignal;
|
|
42
59
|
private readonly serializedCache: SerializedCache;
|
|
60
|
+
private readonly db: IBeaconDb;
|
|
61
|
+
private readonly seenBlockInputCache: SeenBlockInput;
|
|
62
|
+
private readonly custodyConfig: CustodyConfig;
|
|
43
63
|
private readonly metrics: Metrics | null;
|
|
44
64
|
private readonly logger?: Logger;
|
|
45
65
|
private payloadInputs = new Map<RootHex, PayloadEnvelopeInput>();
|
|
66
|
+
// Dedup concurrent DB reloads of the same root so callers share one reconstructed object.
|
|
67
|
+
private readonly reloading = new Map<RootHex, Promise<PayloadEnvelopeInput | undefined>>();
|
|
46
68
|
|
|
47
69
|
constructor({
|
|
48
70
|
config,
|
|
@@ -51,6 +73,9 @@ export class SeenPayloadEnvelopeInput {
|
|
|
51
73
|
chainEvents,
|
|
52
74
|
signal,
|
|
53
75
|
serializedCache,
|
|
76
|
+
db,
|
|
77
|
+
seenBlockInputCache,
|
|
78
|
+
custodyConfig,
|
|
54
79
|
metrics,
|
|
55
80
|
logger,
|
|
56
81
|
}: SeenPayloadEnvelopeInputModules) {
|
|
@@ -60,6 +85,9 @@ export class SeenPayloadEnvelopeInput {
|
|
|
60
85
|
this.chainEvents = chainEvents;
|
|
61
86
|
this.signal = signal;
|
|
62
87
|
this.serializedCache = serializedCache;
|
|
88
|
+
this.db = db;
|
|
89
|
+
this.seenBlockInputCache = seenBlockInputCache;
|
|
90
|
+
this.custodyConfig = custodyConfig;
|
|
63
91
|
this.metrics = metrics;
|
|
64
92
|
this.logger = logger;
|
|
65
93
|
|
|
@@ -86,7 +114,7 @@ export class SeenPayloadEnvelopeInput {
|
|
|
86
114
|
let deletedCount = 0;
|
|
87
115
|
for (const [, input] of this.payloadInputs) {
|
|
88
116
|
if (input.slot < finalizedSlot) {
|
|
89
|
-
this.evictPayloadInput(input);
|
|
117
|
+
this.evictPayloadInput(input, "finalized");
|
|
90
118
|
deletedCount++;
|
|
91
119
|
}
|
|
92
120
|
}
|
|
@@ -110,12 +138,13 @@ export class SeenPayloadEnvelopeInput {
|
|
|
110
138
|
const daOutOfRange = isDaOutOfRange(this.config, props.forkName, props.block.message.slot, this.clock.currentEpoch);
|
|
111
139
|
const input = PayloadEnvelopeInput.createFromBlock({...props, daOutOfRange});
|
|
112
140
|
this.payloadInputs.set(props.blockRootHex, input);
|
|
113
|
-
this.metrics?.seenCache.payloadEnvelopeInput.created.inc();
|
|
141
|
+
this.metrics?.seenCache.payloadEnvelopeInput.created.inc({source: props.source});
|
|
114
142
|
this.logger?.verbose("SeenPayloadEnvelopeInput.add created new entry", {
|
|
115
143
|
slot: input.slot,
|
|
116
144
|
root: props.blockRootHex,
|
|
117
145
|
daOutOfRange,
|
|
118
146
|
});
|
|
147
|
+
this.pruneToMaxSize();
|
|
119
148
|
return input;
|
|
120
149
|
}
|
|
121
150
|
|
|
@@ -131,12 +160,13 @@ export class SeenPayloadEnvelopeInput {
|
|
|
131
160
|
const daOutOfRange = isDaOutOfRange(this.config, props.forkName, props.slot, this.clock.currentEpoch);
|
|
132
161
|
const input = PayloadEnvelopeInput.createFromBid({...props, daOutOfRange});
|
|
133
162
|
this.payloadInputs.set(props.blockRootHex, input);
|
|
134
|
-
this.metrics?.seenCache.payloadEnvelopeInput.created.inc();
|
|
163
|
+
this.metrics?.seenCache.payloadEnvelopeInput.created.inc({source: props.source});
|
|
135
164
|
this.logger?.verbose("SeenPayloadEnvelopeInput.addFromBid created new entry", {
|
|
136
165
|
slot: input.slot,
|
|
137
166
|
root: props.blockRootHex,
|
|
138
167
|
daOutOfRange,
|
|
139
168
|
});
|
|
169
|
+
this.pruneToMaxSize();
|
|
140
170
|
return input;
|
|
141
171
|
}
|
|
142
172
|
|
|
@@ -144,6 +174,80 @@ export class SeenPayloadEnvelopeInput {
|
|
|
144
174
|
return this.payloadInputs.get(blockRootHex);
|
|
145
175
|
}
|
|
146
176
|
|
|
177
|
+
/**
|
|
178
|
+
* Like `get()`, but on a cache miss reconstruct the shell (bid + versionedHashes) from the block
|
|
179
|
+
* in `seenBlockInputCache` or the hot DB.
|
|
180
|
+
* This api is meant for BlockInputSync when a late/weird payloads for old blocks
|
|
181
|
+
*
|
|
182
|
+
* NOTE: the reconstructed entry is always EMPTY even when the block is actually FULL (its
|
|
183
|
+
* payload envelope + columns persisted in the DB). The consumer should consult fork choice if it needs to.
|
|
184
|
+
*/
|
|
185
|
+
async getOrReload(blockRootHex: RootHex): Promise<PayloadEnvelopeInput | undefined> {
|
|
186
|
+
const existing = this.payloadInputs.get(blockRootHex);
|
|
187
|
+
if (existing !== undefined) {
|
|
188
|
+
return existing;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Without this dedup, two concurrent misses each db.block.get + createFromBlock a DIFFERENT shell
|
|
192
|
+
// for the same root; processPayloadEnvelopeJob's WeakMap (keyed by object) can't dedup the import.
|
|
193
|
+
const inflight = this.reloading.get(blockRootHex);
|
|
194
|
+
if (inflight !== undefined) {
|
|
195
|
+
return inflight;
|
|
196
|
+
}
|
|
197
|
+
const promise = this.reloadFromDb(blockRootHex);
|
|
198
|
+
this.reloading.set(blockRootHex, promise);
|
|
199
|
+
try {
|
|
200
|
+
return await promise;
|
|
201
|
+
} finally {
|
|
202
|
+
this.reloading.delete(blockRootHex);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
private async reloadFromDb(blockRootHex: RootHex): Promise<PayloadEnvelopeInput | undefined> {
|
|
207
|
+
// Only recover unfinalized, fork-choice-known blocks. Do not read the finalized archive. The gate
|
|
208
|
+
// also filters out un-imported blocks that may sit in seenBlockInputCache before validation.
|
|
209
|
+
if (!this.forkChoice.hasBlockHex(blockRootHex)) {
|
|
210
|
+
return undefined;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// In-memory first: persistBlockInput writes db.block THEN prunes seenBlockInputCache, so a
|
|
214
|
+
// just-imported block whose async write (unfinalizedBlockWrites) has not flushed yet is still here;
|
|
215
|
+
// older blocks (already pruned from the cache) fall through to the hot db.
|
|
216
|
+
const cachedBlockInput = this.seenBlockInputCache.get(blockRootHex);
|
|
217
|
+
const block = cachedBlockInput?.hasBlock()
|
|
218
|
+
? cachedBlockInput.getBlock()
|
|
219
|
+
: await this.db.block.get(fromHex(blockRootHex));
|
|
220
|
+
if (block == null) {
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const forkName = this.config.getForkName(block.message.slot);
|
|
225
|
+
if (!isForkPostGloas(forkName)) {
|
|
226
|
+
return undefined;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const daOutOfRange = isDaOutOfRange(this.config, forkName, block.message.slot, this.clock.currentEpoch);
|
|
230
|
+
const input = PayloadEnvelopeInput.createFromBlock({
|
|
231
|
+
blockRootHex,
|
|
232
|
+
block: block as SignedBeaconBlock<ForkPostGloas>,
|
|
233
|
+
forkName,
|
|
234
|
+
sampledColumns: this.custodyConfig.sampledColumns,
|
|
235
|
+
custodyColumns: this.custodyConfig.custodyColumns,
|
|
236
|
+
seenTimestampSec: Date.now() / 1000,
|
|
237
|
+
source: PayloadEnvelopeInputSource.reload,
|
|
238
|
+
daOutOfRange,
|
|
239
|
+
});
|
|
240
|
+
this.payloadInputs.set(blockRootHex, input);
|
|
241
|
+
this.metrics?.seenCache.payloadEnvelopeInput.created.inc({source: PayloadEnvelopeInputSource.reload});
|
|
242
|
+
this.logger?.verbose("SeenPayloadEnvelopeInput.getOrReload reconstructed entry from db", {
|
|
243
|
+
slot: input.slot,
|
|
244
|
+
root: blockRootHex,
|
|
245
|
+
});
|
|
246
|
+
// Set above (entry is at the back of the insertion order), so the cap never evicts what we just reloaded.
|
|
247
|
+
this.pruneToMaxSize();
|
|
248
|
+
return input;
|
|
249
|
+
}
|
|
250
|
+
|
|
147
251
|
hasPayload(blockRootHex: RootHex): boolean {
|
|
148
252
|
return this.payloadInputs.get(blockRootHex)?.hasPayloadEnvelope() ?? false;
|
|
149
253
|
}
|
|
@@ -155,8 +259,7 @@ export class SeenPayloadEnvelopeInput {
|
|
|
155
259
|
prune(blockRootHex: RootHex): void {
|
|
156
260
|
const input = this.payloadInputs.get(blockRootHex);
|
|
157
261
|
if (input) {
|
|
158
|
-
this.evictPayloadInput(input);
|
|
159
|
-
this.logger?.verbose("SeenPayloadEnvelopeInput.prune deleted", {slot: input.slot, root: blockRootHex});
|
|
262
|
+
this.evictPayloadInput(input, "prune");
|
|
160
263
|
}
|
|
161
264
|
}
|
|
162
265
|
|
|
@@ -170,17 +273,43 @@ export class SeenPayloadEnvelopeInput {
|
|
|
170
273
|
// ...and don't evict while columns are still being gathered: writeDataColumnsToDb awaits the
|
|
171
274
|
// same hasComputedAllData() before persisting. Such entries are pruned by a later call.
|
|
172
275
|
if (input?.hasComputedAllData()) {
|
|
173
|
-
this.evictPayloadInput(input);
|
|
174
|
-
this.logger?.verbose("SeenPayloadEnvelopeInput.pruneBelowParent deleted", {
|
|
175
|
-
slot: block.slot,
|
|
176
|
-
root: block.blockRoot,
|
|
177
|
-
});
|
|
276
|
+
this.evictPayloadInput(input, "belowParent");
|
|
178
277
|
}
|
|
179
278
|
}
|
|
180
279
|
}
|
|
181
280
|
}
|
|
182
281
|
|
|
183
|
-
|
|
282
|
+
/**
|
|
283
|
+
* Bound this cache to have at most MAX_PAYLOAD_ENVELOPE_INPUT_CACHE_SIZE items.
|
|
284
|
+
* Evicts by insertion order so a just-reloaded old-slot entry is not evicted right after.
|
|
285
|
+
* On unstable network, we may need to query an evicted item, UnknownBlockInput will recover
|
|
286
|
+
* it from db via getOrReload() api. Runs after every single insert, so it evicts ~1 per call.
|
|
287
|
+
*/
|
|
288
|
+
private pruneToMaxSize(): void {
|
|
289
|
+
let evicted = 0;
|
|
290
|
+
for (const input of this.payloadInputs.values()) {
|
|
291
|
+
if (this.payloadInputs.size <= MAX_PAYLOAD_ENVELOPE_INPUT_CACHE_SIZE) {
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
this.evictPayloadInput(input, "cap");
|
|
295
|
+
evicted++;
|
|
296
|
+
}
|
|
297
|
+
if (evicted > 0) {
|
|
298
|
+
this.logger?.debug("SeenPayloadEnvelopeInput.pruneToMaxSize evicted", {
|
|
299
|
+
evicted,
|
|
300
|
+
size: this.payloadInputs.size,
|
|
301
|
+
max: MAX_PAYLOAD_ENVELOPE_INPUT_CACHE_SIZE,
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
private evictPayloadInput(payloadInput: PayloadEnvelopeInput, reason: PayloadEnvelopeInputPruneReason): void {
|
|
307
|
+
this.metrics?.seenCache.payloadEnvelopeInput.pruned.inc({reason});
|
|
308
|
+
this.logger?.debug("SeenPayloadEnvelopeInput evicted", {
|
|
309
|
+
slot: payloadInput.slot,
|
|
310
|
+
root: payloadInput.blockRootHex,
|
|
311
|
+
reason,
|
|
312
|
+
});
|
|
184
313
|
this.serializedCache.delete(payloadInput.getSerializedCacheKeys());
|
|
185
314
|
this.payloadInputs.delete(payloadInput.blockRootHex);
|
|
186
315
|
}
|
|
@@ -144,13 +144,20 @@ export class FIFOBlockStateCache implements BlockStateCache {
|
|
|
144
144
|
return this.cache.size;
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
/**
|
|
148
|
+
* On a checkpoint event, prune the cache while keeping the head state.
|
|
149
|
+
*/
|
|
150
|
+
onCheckpoint(headStateRootHex: string): void {
|
|
151
|
+
this.prune(headStateRootHex);
|
|
152
|
+
}
|
|
153
|
+
|
|
147
154
|
/**
|
|
148
155
|
* Prune the cache from tail to keep the most recent n states consistently.
|
|
149
156
|
* The tail of the list is the oldest state, in case regen adds back the same state,
|
|
150
157
|
* it should stay next to head so that it won't be pruned right away.
|
|
151
158
|
* The FIFO cache helps with this.
|
|
152
159
|
*/
|
|
153
|
-
prune(lastAddedKey: string): void {
|
|
160
|
+
private prune(lastAddedKey: string): void {
|
|
154
161
|
while (this.keyOrder.length > this.maxStates) {
|
|
155
162
|
const key = this.keyOrder.last();
|
|
156
163
|
// it does not make sense to prune the last added state
|