@lodestar/beacon-node 1.47.0-dev.f591cb177e → 1.48.0-dev.67344272c0
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 +44 -12
- 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 +21 -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.map +1 -1
- package/lib/api/impl/events/index.js +2 -0
- package/lib/api/impl/events/index.js.map +1 -1
- package/lib/api/impl/lodestar/index.js +1 -1
- 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 +237 -49
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/api/impl/validator/utils.js +1 -1
- 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/blocks/importExecutionPayload.d.ts +3 -2
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +11 -9
- 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 +21 -13
- 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 +5 -2
- 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/chain.d.ts +9 -4
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +22 -8
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/errors/blockError.d.ts +1 -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/executionPayloadBid.d.ts +5 -0
- package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadBid.js +1 -0
- package/lib/chain/errors/executionPayloadBid.js.map +1 -1
- package/lib/chain/forkChoice/index.d.ts.map +1 -1
- package/lib/chain/forkChoice/index.js +4 -0
- package/lib/chain/forkChoice/index.js.map +1 -1
- package/lib/chain/interface.d.ts +8 -4
- 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/executionPayloadBidPool.d.ts +7 -2
- package/lib/chain/opPools/executionPayloadBidPool.d.ts.map +1 -1
- package/lib/chain/opPools/executionPayloadBidPool.js +4 -4
- package/lib/chain/opPools/executionPayloadBidPool.js.map +1 -1
- package/lib/chain/opPools/index.d.ts +2 -1
- 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/prepareNextSlot.d.ts +5 -0
- package/lib/chain/prepareNextSlot.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +47 -6
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
- package/lib/chain/produceBlock/computeNewStateRoot.js +3 -25
- package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/regen/interface.d.ts +5 -2
- package/lib/chain/regen/interface.d.ts.map +1 -1
- package/lib/chain/regen/interface.js +3 -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/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 +40 -10
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/chain/validation/executionPayloadBid.d.ts +15 -3
- package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/validation/executionPayloadBid.js +166 -12
- 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.js +2 -2
- 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/apiClient.d.ts +70 -0
- package/lib/execution/builder/apiClient.d.ts.map +1 -0
- package/lib/execution/builder/apiClient.js +202 -0
- package/lib/execution/builder/apiClient.js.map +1 -0
- package/lib/execution/builder/validateBid.d.ts +23 -0
- package/lib/execution/builder/validateBid.d.ts.map +1 -0
- package/lib/execution/builder/validateBid.js +119 -0
- package/lib/execution/builder/validateBid.js.map +1 -0
- package/lib/metrics/metrics/lodestar.d.ts +84 -23
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +161 -55
- 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/network.d.ts.map +1 -1
- package/lib/network/network.js +23 -43
- package/lib/network/network.js.map +1 -1
- package/lib/network/processor/constants.d.ts +7 -0
- package/lib/network/processor/constants.d.ts.map +1 -0
- package/lib/network/processor/constants.js +7 -0
- package/lib/network/processor/constants.js.map +1 -0
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +6 -2
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/gossipQueues/indexed.d.ts.map +1 -1
- package/lib/network/processor/gossipQueues/indexed.js +0 -1
- package/lib/network/processor/gossipQueues/indexed.js.map +1 -1
- package/lib/network/processor/index.d.ts +3 -0
- package/lib/network/processor/index.d.ts.map +1 -1
- package/lib/network/processor/index.js +52 -23
- package/lib/network/processor/index.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 +7 -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 +61 -22
- 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 +32 -12
- package/lib/sync/range/chain.js.map +1 -1
- package/lib/sync/range/range.js +1 -1
- package/lib/sync/range/range.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 +6 -2
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +143 -68
- 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 +35 -35
- package/src/api/impl/beacon/blocks/index.ts +51 -15
- package/src/api/impl/beacon/pool/index.ts +22 -2
- package/src/api/impl/beacon/state/utils.ts +2 -1
- package/src/api/impl/events/index.ts +3 -1
- package/src/api/impl/lodestar/index.ts +1 -1
- package/src/api/impl/validator/index.ts +290 -49
- package/src/api/impl/validator/utils.ts +1 -1
- package/src/api/rest/base.ts +7 -0
- package/src/chain/archiveStore/archiveStore.ts +1 -1
- package/src/chain/blocks/importExecutionPayload.ts +12 -11
- package/src/chain/blocks/index.ts +25 -13
- package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +8 -2
- package/src/chain/blocks/payloadEnvelopeInput/types.ts +17 -4
- package/src/chain/blocks/verifyBlock.ts +5 -2
- 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/chain.ts +25 -7
- package/src/chain/errors/blockError.ts +8 -2
- package/src/chain/errors/executionPayloadBid.ts +6 -0
- package/src/chain/forkChoice/index.ts +4 -0
- package/src/chain/interface.ts +8 -3
- 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/executionPayloadBidPool.ts +13 -7
- package/src/chain/opPools/index.ts +2 -1
- 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/prepareNextSlot.ts +49 -6
- package/src/chain/produceBlock/computeNewStateRoot.ts +3 -38
- package/src/chain/produceBlock/produceBlockBody.ts +1 -1
- package/src/chain/regen/interface.ts +5 -2
- package/src/chain/regen/queued.ts +5 -5
- package/src/chain/seenCache/seenAttesters.ts +31 -5
- 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 +43 -10
- package/src/chain/validation/executionPayloadBid.ts +193 -14
- package/src/chain/validation/executionPayloadEnvelope.ts +0 -1
- package/src/chain/validation/payloadAttestationMessage.ts +6 -17
- package/src/chain/validation/proposerPreferences.ts +3 -3
- package/src/chain/validation/proposerSlashing.ts +1 -1
- package/src/chain/validation/voluntaryExit.ts +59 -2
- package/src/execution/builder/apiClient.ts +264 -0
- package/src/execution/builder/validateBid.ts +181 -0
- package/src/metrics/metrics/lodestar.ts +176 -61
- package/src/network/gossip/topic.ts +38 -0
- package/src/network/network.ts +29 -54
- package/src/network/processor/constants.ts +6 -0
- package/src/network/processor/gossipHandlers.ts +6 -2
- package/src/network/processor/gossipQueues/indexed.ts +0 -1
- package/src/network/processor/index.ts +67 -30
- 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 +10 -1
- package/src/sync/range/batch.ts +83 -28
- package/src/sync/range/chain.ts +35 -13
- package/src/sync/range/range.ts +1 -1
- package/src/sync/types.ts +33 -0
- package/src/sync/unknownBlock.ts +167 -73
- 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
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {IForkChoice, ProtoBlock} from "@lodestar/fork-choice";
|
|
1
|
+
import {ProtoBlock} from "@lodestar/fork-choice";
|
|
3
2
|
import {PAYLOAD_BUILDER_VERSION} from "@lodestar/params";
|
|
4
3
|
import {
|
|
5
4
|
computeEpochAtSlot,
|
|
@@ -47,11 +46,12 @@ function getMinBidValue(currentHighestBid: number): number {
|
|
|
47
46
|
/**
|
|
48
47
|
* Check whether a bid builds on one of the paths compatible with the local head branch.
|
|
49
48
|
*
|
|
50
|
-
* Building directly on the parent is allowed for proposer-boost reorgs
|
|
49
|
+
* Building directly on the parent is allowed for proposer-boost reorgs, including at epoch
|
|
50
|
+
* boundaries when the head is weak enough that a reorg onto the strong parent is predicted.
|
|
51
51
|
* Otherwise the bid must build on the local head's full or empty payload variant, as selected for its slot.
|
|
52
52
|
*/
|
|
53
53
|
function isBidCompatibleWithHead(
|
|
54
|
-
|
|
54
|
+
chain: IBeaconChain,
|
|
55
55
|
head: ProtoBlock,
|
|
56
56
|
bidSlot: Slot,
|
|
57
57
|
bidParentBlockRoot: RootHex,
|
|
@@ -61,9 +61,13 @@ function isBidCompatibleWithHead(
|
|
|
61
61
|
const buildsOnParentPayload = bidParentBlockHash === head.parentBlockHash;
|
|
62
62
|
|
|
63
63
|
if (buildsOnParentBlock && buildsOnParentPayload) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
if (!isStartSlotOfEpoch(bidSlot)) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
// Epoch-boundary reorgs are allowed, but only propagate the bid if its parent matches the block
|
|
68
|
+
// we predict a proposer would reorg onto — predictProposerHead returns the strong parent only
|
|
69
|
+
// when the head is weak.
|
|
70
|
+
return chain.predictProposerHead().blockRoot === bidParentBlockRoot;
|
|
67
71
|
}
|
|
68
72
|
|
|
69
73
|
if (bidParentBlockRoot !== head.blockRoot) {
|
|
@@ -72,18 +76,170 @@ function isBidCompatibleWithHead(
|
|
|
72
76
|
|
|
73
77
|
const buildsOnHeadPayload = bidParentBlockHash === head.executionPayloadBlockHash;
|
|
74
78
|
|
|
75
|
-
if (forkChoice.shouldBuildOnFull(head, bidSlot)) {
|
|
79
|
+
if (chain.forkChoice.shouldBuildOnFull(head, bidSlot)) {
|
|
76
80
|
return buildsOnHeadPayload;
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
return buildsOnParentPayload;
|
|
80
84
|
}
|
|
81
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Validation for bids submitted via the API by the operator's own builder.
|
|
88
|
+
*
|
|
89
|
+
* Only non-transient checks are applied: slot later than parent, zero execution payment, blob
|
|
90
|
+
* commitment count, builder eligibility, version and balance coverage, prev_randao, and signature.
|
|
91
|
+
* Transient gossip rules (head compatibility, first bid per tuple, value increment, proposer
|
|
92
|
+
* preferences) are not applied, since those only limit forwarding of peers' messages and the
|
|
93
|
+
* builder may legitimately bid on a branch this node does not consider head.
|
|
94
|
+
* The parent-payload builder-exit rule is omitted because this endpoint only accepts bids from
|
|
95
|
+
* the operator's own builder.
|
|
96
|
+
*
|
|
97
|
+
* Throws on any failed check. Also throws if the bid's parent block is unknown or its state is
|
|
98
|
+
* unavailable, since the checks cannot be evaluated against the parent branch.
|
|
99
|
+
*/
|
|
82
100
|
export async function validateApiExecutionPayloadBid(
|
|
83
101
|
chain: IBeaconChain,
|
|
84
102
|
signedExecutionPayloadBid: gloas.SignedExecutionPayloadBid
|
|
85
|
-
): Promise<
|
|
86
|
-
|
|
103
|
+
): Promise<void> {
|
|
104
|
+
const bid = signedExecutionPayloadBid.message;
|
|
105
|
+
const bidParentBlockRoot = toRootHex(bid.parentBlockRoot);
|
|
106
|
+
|
|
107
|
+
// [IGNORE] `bid.slot` is the current slot, or the next slot (`bid.slot - 1` is current), allowing for `MAXIMUM_GOSSIP_CLOCK_DISPARITY`.
|
|
108
|
+
if (
|
|
109
|
+
!chain.clock.isCurrentSlotGivenGossipDisparity(bid.slot) &&
|
|
110
|
+
!chain.clock.isCurrentSlotGivenGossipDisparity(bid.slot - 1)
|
|
111
|
+
) {
|
|
112
|
+
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
113
|
+
code: ExecutionPayloadBidErrorCode.INVALID_SLOT,
|
|
114
|
+
builderIndex: bid.builderIndex,
|
|
115
|
+
slot: bid.slot,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// [IGNORE] `bid.parent_block_root` is the hash tree root of a known beacon block in fork choice.
|
|
120
|
+
// Moved earlier than the spec ordering so we can derive the proposer dependent root for the
|
|
121
|
+
// proposer-preferences lookup below from a known fork-choice block.
|
|
122
|
+
const parentBlock = chain.forkChoice.getBlockHexDefaultStatus(bidParentBlockRoot);
|
|
123
|
+
if (parentBlock === null) {
|
|
124
|
+
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
125
|
+
code: ExecutionPayloadBidErrorCode.UNKNOWN_BLOCK_ROOT,
|
|
126
|
+
parentBlockRoot: bidParentBlockRoot,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// [REJECT] The bid is for a higher slot than its parent block -- i.e.
|
|
131
|
+
// validate that `bid.slot` is greater than the slot of the block with root
|
|
132
|
+
// `bid.parent_block_root`.
|
|
133
|
+
if (bid.slot <= parentBlock.slot) {
|
|
134
|
+
throw new ExecutionPayloadBidError(GossipAction.REJECT, {
|
|
135
|
+
code: ExecutionPayloadBidErrorCode.NOT_LATER_THAN_PARENT,
|
|
136
|
+
parentSlot: parentBlock.slot,
|
|
137
|
+
slot: bid.slot,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// [REJECT] `bid.execution_payment` is zero.
|
|
142
|
+
if (bid.executionPayment !== 0n) {
|
|
143
|
+
throw new ExecutionPayloadBidError(GossipAction.REJECT, {
|
|
144
|
+
code: ExecutionPayloadBidErrorCode.NON_ZERO_EXECUTION_PAYMENT,
|
|
145
|
+
builderIndex: bid.builderIndex,
|
|
146
|
+
executionPayment: bid.executionPayment,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// [REJECT] The length of KZG commitments is less than or equal to the limitation defined in the
|
|
151
|
+
// consensus layer -- i.e. validate that
|
|
152
|
+
// `len(bid.blob_kzg_commitments) <= get_blob_parameters(compute_epoch_at_slot(bid.slot)).max_blobs_per_block`.
|
|
153
|
+
const blobKzgCommitmentsLen = bid.blobKzgCommitments.length;
|
|
154
|
+
const maxBlobsPerBlock = chain.config.getMaxBlobsPerBlock(computeEpochAtSlot(bid.slot));
|
|
155
|
+
if (blobKzgCommitmentsLen > maxBlobsPerBlock) {
|
|
156
|
+
throw new ExecutionPayloadBidError(GossipAction.REJECT, {
|
|
157
|
+
code: ExecutionPayloadBidErrorCode.TOO_MANY_KZG_COMMITMENTS,
|
|
158
|
+
blobKzgCommitmentsLen,
|
|
159
|
+
commitmentLimit: maxBlobsPerBlock,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const state = await chain.regen
|
|
164
|
+
.getBlockSlotState(parentBlock, bid.slot, {dontTransferCache: true}, RegenCaller.validateApiExecutionPayloadBid)
|
|
165
|
+
.catch(() => {
|
|
166
|
+
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
167
|
+
code: ExecutionPayloadBidErrorCode.UNKNOWN_BLOCK_ROOT,
|
|
168
|
+
parentBlockRoot: bidParentBlockRoot,
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
if (!isStatePostGloas(state)) {
|
|
173
|
+
throw new Error(`Expected gloas+ state for execution payload bid validation, got fork=${state.forkName}`);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// [REJECT] `bid.builder_index` is within bounds -- i.e. `bid.builder_index < len(state.builders)`.
|
|
177
|
+
// `state.getBuilder` returns a lazy SSZ `getReadonly` view that is not bounds-checked eagerly; an
|
|
178
|
+
// out-of-range index only throws (`LeafNode has no right node`) on deferred field access (e.g. inside
|
|
179
|
+
// `isActiveBuilder`), escaping a try/catch around `getBuilder`. Check the length explicitly instead.
|
|
180
|
+
if (bid.builderIndex >= state.getBuildersLength()) {
|
|
181
|
+
throw new ExecutionPayloadBidError(GossipAction.REJECT, {
|
|
182
|
+
code: ExecutionPayloadBidErrorCode.BUILDER_NOT_ELIGIBLE,
|
|
183
|
+
builderIndex: bid.builderIndex,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// [REJECT] `bid.builder_index` is a valid/active builder index -- i.e.
|
|
188
|
+
// `is_active_builder(state, bid.builder_index)` returns `True`.
|
|
189
|
+
const builder = state.getBuilder(bid.builderIndex);
|
|
190
|
+
if (!isActiveBuilder(builder, state.finalizedCheckpoint.epoch)) {
|
|
191
|
+
throw new ExecutionPayloadBidError(GossipAction.REJECT, {
|
|
192
|
+
code: ExecutionPayloadBidErrorCode.BUILDER_NOT_ELIGIBLE,
|
|
193
|
+
builderIndex: bid.builderIndex,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// [REJECT] The builder version is `PAYLOAD_BUILDER_VERSION` -- i.e.
|
|
198
|
+
// `state.builders[bid.builder_index].version == PAYLOAD_BUILDER_VERSION`.
|
|
199
|
+
if (builder.version !== PAYLOAD_BUILDER_VERSION) {
|
|
200
|
+
throw new ExecutionPayloadBidError(GossipAction.REJECT, {
|
|
201
|
+
code: ExecutionPayloadBidErrorCode.INVALID_BUILDER_VERSION,
|
|
202
|
+
builderIndex: bid.builderIndex,
|
|
203
|
+
version: builder.version,
|
|
204
|
+
expectedVersion: PAYLOAD_BUILDER_VERSION,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// [IGNORE] `bid.value` is less or equal than the builder's excess balance --
|
|
209
|
+
// i.e. `can_builder_cover_bid(state, builder_index, amount)` returns `True`.
|
|
210
|
+
if (!state.canBuilderCoverBid(bid.builderIndex, bid.value)) {
|
|
211
|
+
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
212
|
+
code: ExecutionPayloadBidErrorCode.BID_TOO_HIGH,
|
|
213
|
+
bidValue: bid.value,
|
|
214
|
+
builderBalance: builder.balance,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// [REJECT] `bid.prev_randao` is the correct RANDAO mix -- i.e. validate that
|
|
219
|
+
// `bid.prev_randao == get_randao_mix(parent_state, get_current_epoch(parent_state))`.
|
|
220
|
+
const randaoMix = state.getRandaoMix(computeEpochAtSlot(state.slot));
|
|
221
|
+
if (!byteArrayEquals(bid.prevRandao, randaoMix)) {
|
|
222
|
+
throw new ExecutionPayloadBidError(GossipAction.REJECT, {
|
|
223
|
+
code: ExecutionPayloadBidErrorCode.INVALID_PREV_RANDAO,
|
|
224
|
+
builderIndex: bid.builderIndex,
|
|
225
|
+
bidPrevRandao: toHex(bid.prevRandao),
|
|
226
|
+
expectedPrevRandao: toHex(randaoMix),
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// [REJECT] `signed_execution_payload_bid.signature` is valid with respect to the `bid.builder_index`.
|
|
231
|
+
const signatureSet = createSingleSignatureSetFromComponents(
|
|
232
|
+
builder.pubkey,
|
|
233
|
+
getExecutionPayloadBidSigningRoot(chain.config, bid),
|
|
234
|
+
signedExecutionPayloadBid.signature
|
|
235
|
+
);
|
|
236
|
+
if (!(await chain.bls.verifySignatureSets([signatureSet]))) {
|
|
237
|
+
throw new ExecutionPayloadBidError(GossipAction.REJECT, {
|
|
238
|
+
code: ExecutionPayloadBidErrorCode.INVALID_SIGNATURE,
|
|
239
|
+
builderIndex: bid.builderIndex,
|
|
240
|
+
slot: bid.slot,
|
|
241
|
+
});
|
|
242
|
+
}
|
|
87
243
|
}
|
|
88
244
|
|
|
89
245
|
export async function validateGossipExecutionPayloadBid(
|
|
@@ -115,7 +271,7 @@ async function validateExecutionPayloadBid(
|
|
|
115
271
|
|
|
116
272
|
// [IGNORE] The bid is compatible with the current head branch.
|
|
117
273
|
const head = chain.forkChoice.getHead();
|
|
118
|
-
if (!isBidCompatibleWithHead(chain
|
|
274
|
+
if (!isBidCompatibleWithHead(chain, head, bid.slot, bidParentBlockRoot, bidParentBlockHash)) {
|
|
119
275
|
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
120
276
|
code: ExecutionPayloadBidErrorCode.INCOMPATIBLE_WITH_HEAD,
|
|
121
277
|
slot: bid.slot,
|
|
@@ -314,11 +470,11 @@ async function validateExecutionPayloadBid(
|
|
|
314
470
|
// increment, see https://github.com/ethereum/consensus-specs/pull/4831. This prevents spam
|
|
315
471
|
// from builders submitting numerous bids with minimal value increments.
|
|
316
472
|
const bestBid = chain.executionPayloadBidPool.getBestBid(bid.slot, bidParentBlockHash, bidParentBlockRoot);
|
|
317
|
-
if (bestBid !== null && bid.value < getMinBidValue(bestBid.message.value)) {
|
|
473
|
+
if (bestBid !== null && bid.value < getMinBidValue(bestBid.signedBid.message.value)) {
|
|
318
474
|
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
319
475
|
code: ExecutionPayloadBidErrorCode.BID_TOO_LOW,
|
|
320
476
|
bidValue: bid.value,
|
|
321
|
-
currentHighestBid: bestBid.message.value,
|
|
477
|
+
currentHighestBid: bestBid.signedBid.message.value,
|
|
322
478
|
});
|
|
323
479
|
}
|
|
324
480
|
// [IGNORE] `bid.value` is less or equal than the builder's excess balance --
|
|
@@ -343,9 +499,32 @@ async function validateExecutionPayloadBid(
|
|
|
343
499
|
});
|
|
344
500
|
}
|
|
345
501
|
|
|
502
|
+
// [IGNORE] The parent's payload does not try to exit the builder
|
|
503
|
+
if (byteArrayEquals(bid.parentBlockHash, state.latestExecutionPayloadBid.blockHash)) {
|
|
504
|
+
const requests = await chain.getParentExecutionRequests(parentBlock.slot, parentBlock.blockRoot).catch(() => {
|
|
505
|
+
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
506
|
+
code: ExecutionPayloadBidErrorCode.UNKNOWN_PARENT_BLOCK_HASH,
|
|
507
|
+
parentBlockHash: bidParentBlockHash,
|
|
508
|
+
});
|
|
509
|
+
});
|
|
510
|
+
if (
|
|
511
|
+
requests.builderExits.some(
|
|
512
|
+
(request) =>
|
|
513
|
+
byteArrayEquals(request.pubkey, builder.pubkey) &&
|
|
514
|
+
byteArrayEquals(request.sourceAddress, builder.executionAddress)
|
|
515
|
+
)
|
|
516
|
+
) {
|
|
517
|
+
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
518
|
+
code: ExecutionPayloadBidErrorCode.BUILDER_MAY_EXIT,
|
|
519
|
+
builderIndex: bid.builderIndex,
|
|
520
|
+
parentBlockRoot: bidParentBlockRoot,
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
|
|
346
525
|
// [REJECT] `signed_execution_payload_bid.signature` is valid with respect to the `bid.builder_index`.
|
|
347
526
|
const signatureSet = createSingleSignatureSetFromComponents(
|
|
348
|
-
|
|
527
|
+
builder.pubkey,
|
|
349
528
|
getExecutionPayloadBidSigningRoot(chain.config, bid),
|
|
350
529
|
signedExecutionPayloadBid.signature
|
|
351
530
|
);
|
|
@@ -170,7 +170,6 @@ async function validateExecutionPayloadEnvelope(
|
|
|
170
170
|
// by `verify_execution_payload_envelope_signature`.
|
|
171
171
|
const signatureSet = getExecutionPayloadEnvelopeSignatureSet(
|
|
172
172
|
chain.config,
|
|
173
|
-
chain.pubkeyCache,
|
|
174
173
|
blockState,
|
|
175
174
|
executionPayloadEnvelope,
|
|
176
175
|
payloadInput.proposerIndex
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
createSingleSignatureSetFromComponents,
|
|
2
|
+
createIndexedSignatureSetFromComponents,
|
|
4
3
|
getPayloadAttestationDataSigningRoot,
|
|
5
4
|
isStatePostGloas,
|
|
6
5
|
} from "@lodestar/state-transition";
|
|
@@ -36,7 +35,6 @@ async function validatePayloadAttestationMessage(
|
|
|
36
35
|
prioritizeBls = false
|
|
37
36
|
): Promise<PayloadAttestationValidationResult> {
|
|
38
37
|
const {data, validatorIndex} = payloadAttestationMessage;
|
|
39
|
-
const epoch = computeEpochAtSlot(data.slot);
|
|
40
38
|
|
|
41
39
|
// [IGNORE] The message's slot is for the current slot (with a `MAXIMUM_GOSSIP_CLOCK_DISPARITY` allowance), i.e. `data.slot == current_slot`.
|
|
42
40
|
if (!chain.clock.isCurrentSlotGivenGossipDisparity(data.slot)) {
|
|
@@ -48,9 +46,8 @@ async function validatePayloadAttestationMessage(
|
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
// [IGNORE] The `payload_attestation_message` is the first valid message received
|
|
51
|
-
// from the validator with index `payload_attestation_message.validator_index`.
|
|
52
|
-
|
|
53
|
-
if (chain.seenPayloadAttesters.isKnown(epoch, validatorIndex)) {
|
|
49
|
+
// for the slot from the validator with index `payload_attestation_message.validator_index`.
|
|
50
|
+
if (chain.seenPayloadAttesters.isKnown(data.slot, validatorIndex)) {
|
|
54
51
|
throw new PayloadAttestationError(GossipAction.IGNORE, {
|
|
55
52
|
code: PayloadAttestationErrorCode.PAYLOAD_ATTESTATION_ALREADY_KNOWN,
|
|
56
53
|
validatorIndex,
|
|
@@ -114,16 +111,8 @@ async function validatePayloadAttestationMessage(
|
|
|
114
111
|
}
|
|
115
112
|
|
|
116
113
|
// [REJECT] `payload_attestation_message.signature` is valid with respect to the validator's public key.
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
throw new PayloadAttestationError(GossipAction.REJECT, {
|
|
120
|
-
code: PayloadAttestationErrorCode.INVALID_ATTESTER,
|
|
121
|
-
attesterIndex: validatorIndex,
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const signatureSet = createSingleSignatureSetFromComponents(
|
|
126
|
-
validatorPubkey,
|
|
114
|
+
const signatureSet = createIndexedSignatureSetFromComponents(
|
|
115
|
+
validatorIndex,
|
|
127
116
|
getPayloadAttestationDataSigningRoot(chain.config, data),
|
|
128
117
|
payloadAttestationMessage.signature
|
|
129
118
|
);
|
|
@@ -135,7 +124,7 @@ async function validatePayloadAttestationMessage(
|
|
|
135
124
|
}
|
|
136
125
|
|
|
137
126
|
// Valid
|
|
138
|
-
chain.seenPayloadAttesters.add(
|
|
127
|
+
chain.seenPayloadAttesters.add(data.slot, validatorIndex);
|
|
139
128
|
|
|
140
129
|
return {
|
|
141
130
|
attDataRootHex: toRootHex(ssz.gloas.PayloadAttestationData.hashTreeRoot(data)),
|
|
@@ -3,7 +3,7 @@ import {GENESIS_EPOCH, GENESIS_SLOT, MIN_SEED_LOOKAHEAD, SLOTS_PER_EPOCH, isFork
|
|
|
3
3
|
import {
|
|
4
4
|
computeEpochAtSlot,
|
|
5
5
|
computeStartSlotAtEpoch,
|
|
6
|
-
|
|
6
|
+
createIndexedSignatureSetFromComponents,
|
|
7
7
|
getProposerPreferencesSigningRoot,
|
|
8
8
|
} from "@lodestar/state-transition";
|
|
9
9
|
import {Epoch, Slot, ValidatorIndex, gloas} from "@lodestar/types";
|
|
@@ -139,8 +139,8 @@ export async function validateGossipProposerPreferences(
|
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
// [REJECT] `signed_proposer_preferences.signature` is valid with respect to the validator's public key.
|
|
142
|
-
const signatureSet =
|
|
143
|
-
|
|
142
|
+
const signatureSet = createIndexedSignatureSetFromComponents(
|
|
143
|
+
validatorIndex,
|
|
144
144
|
getProposerPreferencesSigningRoot(chain.config, preferences),
|
|
145
145
|
signedProposerPreferences.signature
|
|
146
146
|
);
|
|
@@ -37,7 +37,7 @@ async function validateProposerSlashing(
|
|
|
37
37
|
try {
|
|
38
38
|
const proposer = state.getValidator(proposerSlashing.signedHeader1.message.proposerIndex);
|
|
39
39
|
// verifySignature = false, verified in batch below
|
|
40
|
-
assertValidProposerSlashing(chain.config,
|
|
40
|
+
assertValidProposerSlashing(chain.config, state.slot, proposerSlashing, proposer, false);
|
|
41
41
|
} catch (e) {
|
|
42
42
|
throw new ProposerSlashingError(GossipAction.REJECT, {
|
|
43
43
|
code: ProposerSlashingErrorCode.INVALID,
|
|
@@ -9,12 +9,69 @@ import {
|
|
|
9
9
|
import {IBeaconChain} from "../index.js";
|
|
10
10
|
import {RegenCaller} from "../regen/index.js";
|
|
11
11
|
|
|
12
|
+
export type ApiVoluntaryExitResult = {status: "published"} | {status: "deferred"; validity: VoluntaryExitValidity};
|
|
13
|
+
|
|
14
|
+
// Variants that can become valid in a future epoch without user action.
|
|
15
|
+
// - earlyEpoch: exit.message.epoch is in the future; valid once current epoch catches up
|
|
16
|
+
// - shortTimeActive: validator active < SHARD_COMMITTEE_PERIOD; valid once enough time passes
|
|
17
|
+
// - pendingWithdrawals: Electra; valid once pending partial withdrawals drain
|
|
18
|
+
// Note: VoluntaryExitValidity.inactive is intentionally excluded. It conflates
|
|
19
|
+
// "validator does not exist" (permanent) with "validator not yet activated"
|
|
20
|
+
// (transient), and cleanly classifying it requires splitting the enum variant
|
|
21
|
+
// upstream. Left for a future follow-up.
|
|
22
|
+
|
|
23
|
+
export function isTransientExitValidity(v: VoluntaryExitValidity): boolean {
|
|
24
|
+
switch (v) {
|
|
25
|
+
case VoluntaryExitValidity.earlyEpoch:
|
|
26
|
+
case VoluntaryExitValidity.shortTimeActive:
|
|
27
|
+
case VoluntaryExitValidity.pendingWithdrawals:
|
|
28
|
+
return true;
|
|
29
|
+
case VoluntaryExitValidity.valid:
|
|
30
|
+
case VoluntaryExitValidity.inactive:
|
|
31
|
+
case VoluntaryExitValidity.alreadyExited:
|
|
32
|
+
case VoluntaryExitValidity.invalidSignature:
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Comments for each call are present inside `validateVoluntaryExit`.
|
|
12
38
|
export async function validateApiVoluntaryExit(
|
|
13
39
|
chain: IBeaconChain,
|
|
14
40
|
voluntaryExit: phase0.SignedVoluntaryExit
|
|
15
|
-
): Promise<
|
|
41
|
+
): Promise<ApiVoluntaryExitResult> {
|
|
16
42
|
const prioritizeBls = true;
|
|
17
|
-
|
|
43
|
+
|
|
44
|
+
if (
|
|
45
|
+
chain.opPool.hasSeenVoluntaryExit(voluntaryExit.message.validatorIndex) ||
|
|
46
|
+
chain.deferredVoluntaryExitPool.has(voluntaryExit.message.validatorIndex)
|
|
47
|
+
) {
|
|
48
|
+
throw new VoluntaryExitError(GossipAction.IGNORE, {
|
|
49
|
+
code: VoluntaryExitErrorCode.ALREADY_EXISTS,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const state = await chain.getHeadStateAtCurrentEpoch(RegenCaller.validateApiVoluntaryExit);
|
|
54
|
+
const validity = state.getVoluntaryExitValidity(voluntaryExit, false);
|
|
55
|
+
|
|
56
|
+
if (validity !== VoluntaryExitValidity.valid && !isTransientExitValidity(validity)) {
|
|
57
|
+
throw new VoluntaryExitError(GossipAction.REJECT, {
|
|
58
|
+
code: voluntaryExitValidityToErrorCode(validity),
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const signatureSet = getVoluntaryExitSignatureSet(chain.config, state, voluntaryExit);
|
|
63
|
+
if (!(await chain.bls.verifySignatureSets([signatureSet], {batchable: true, priority: prioritizeBls}))) {
|
|
64
|
+
throw new VoluntaryExitError(GossipAction.REJECT, {
|
|
65
|
+
code: VoluntaryExitErrorCode.INVALID_SIGNATURE,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (validity !== VoluntaryExitValidity.valid) {
|
|
70
|
+
// Transient failure — signature is good, defer
|
|
71
|
+
return {status: "deferred", validity};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return {status: "published"};
|
|
18
75
|
}
|
|
19
76
|
|
|
20
77
|
export async function validateGossipVoluntaryExit(
|