@lodestar/beacon-node 1.52.0-dev.269cf1aa5b → 1.52.0-dev.31011e1c39
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 +47 -26
- 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 +4 -2
- package/lib/api/impl/beacon/pool/index.js.map +1 -1
- package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
- package/lib/api/impl/beacon/state/utils.js +2 -1
- package/lib/api/impl/beacon/state/utils.js.map +1 -1
- package/lib/api/impl/debug/index.d.ts.map +1 -1
- package/lib/api/impl/debug/index.js +6 -2
- package/lib/api/impl/debug/index.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +87 -48
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/ColumnReconstructionTracker.d.ts +4 -0
- package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
- package/lib/chain/ColumnReconstructionTracker.js +4 -0
- package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
- package/lib/chain/archiveStore/historicalState/getHistoricalState.js +7 -0
- package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.js +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
- package/lib/chain/archiveStore/utils/pruneHistory.d.ts.map +1 -1
- package/lib/chain/archiveStore/utils/pruneHistory.js +8 -4
- package/lib/chain/archiveStore/utils/pruneHistory.js.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +9 -3
- package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
- package/lib/chain/blocks/index.d.ts.map +1 -1
- package/lib/chain/blocks/index.js +3 -17
- package/lib/chain/blocks/index.js.map +1 -1
- package/lib/chain/chain.d.ts +7 -6
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +80 -41
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/errors/attestationError.d.ts +15 -1
- package/lib/chain/errors/attestationError.d.ts.map +1 -1
- package/lib/chain/errors/attestationError.js +8 -0
- package/lib/chain/errors/attestationError.js.map +1 -1
- package/lib/chain/errors/executionPayloadBid.d.ts +9 -3
- package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadBid.js +2 -1
- package/lib/chain/errors/executionPayloadBid.js.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.d.ts +55 -0
- package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.js +8 -0
- package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
- package/lib/chain/interface.d.ts +1 -1
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/lightClient/index.d.ts +13 -6
- package/lib/chain/lightClient/index.d.ts.map +1 -1
- package/lib/chain/lightClient/index.js +95 -115
- package/lib/chain/lightClient/index.js.map +1 -1
- package/lib/chain/opPools/opPool.js +6 -6
- package/lib/chain/opPools/opPool.js.map +1 -1
- package/lib/chain/prepareNextSlot.d.ts +45 -0
- package/lib/chain/prepareNextSlot.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +265 -69
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +6 -2
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +54 -64
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/seenCache/seenAttesters.d.ts +1 -0
- package/lib/chain/seenCache/seenAttesters.d.ts.map +1 -1
- package/lib/chain/seenCache/seenAttesters.js +1 -1
- package/lib/chain/seenCache/seenAttesters.js.map +1 -1
- package/lib/chain/seenCache/seenBlockAttesters.d.ts +8 -2
- package/lib/chain/seenCache/seenBlockAttesters.d.ts.map +1 -1
- package/lib/chain/seenCache/seenBlockAttesters.js +43 -6
- package/lib/chain/seenCache/seenBlockAttesters.js.map +1 -1
- package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts +13 -4
- package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts.map +1 -1
- package/lib/chain/seenCache/seenExecutionPayloadBids.js +13 -12
- package/lib/chain/seenCache/seenExecutionPayloadBids.js.map +1 -1
- package/lib/chain/validation/aggregateAndProof.d.ts.map +1 -1
- package/lib/chain/validation/aggregateAndProof.js +24 -7
- package/lib/chain/validation/aggregateAndProof.js.map +1 -1
- package/lib/chain/validation/attestation.d.ts.map +1 -1
- package/lib/chain/validation/attestation.js +32 -16
- 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 +4 -2
- 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 +9 -1
- 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 +47 -42
- package/lib/chain/validation/executionPayloadBid.js.map +1 -1
- package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/validation/executionPayloadEnvelope.js +100 -9
- package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
- package/lib/chain/validation/payloadAttestationMessage.js +9 -0
- package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
- package/lib/chain/validation/proposerSlashing.js +4 -2
- package/lib/chain/validation/proposerSlashing.js.map +1 -1
- package/lib/chain/validation/signatureSets/contributionAndProof.d.ts +2 -2
- package/lib/chain/validation/signatureSets/contributionAndProof.d.ts.map +1 -1
- package/lib/chain/validation/signatureSets/contributionAndProof.js +2 -2
- package/lib/chain/validation/signatureSets/contributionAndProof.js.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommittee.d.ts +2 -2
- package/lib/chain/validation/signatureSets/syncCommittee.d.ts.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommittee.js +2 -2
- package/lib/chain/validation/signatureSets/syncCommittee.js.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts +2 -2
- package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommitteeContribution.js +2 -2
- package/lib/chain/validation/signatureSets/syncCommitteeContribution.js.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts +2 -2
- package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js +2 -2
- package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js.map +1 -1
- package/lib/chain/validation/syncCommittee.d.ts +1 -1
- package/lib/chain/validation/syncCommittee.d.ts.map +1 -1
- package/lib/chain/validation/syncCommittee.js +5 -5
- package/lib/chain/validation/syncCommittee.js.map +1 -1
- package/lib/chain/validation/syncCommitteeContributionAndProof.js +3 -3
- package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
- package/lib/chain/validation/voluntaryExit.d.ts.map +1 -1
- package/lib/chain/validation/voluntaryExit.js +39 -6
- package/lib/chain/validation/voluntaryExit.js.map +1 -1
- package/lib/chain/validatorMonitor.js +43 -43
- package/lib/chain/validatorMonitor.js.map +1 -1
- package/lib/execution/engine/blockHash.d.ts +12 -0
- package/lib/execution/engine/blockHash.d.ts.map +1 -0
- package/lib/execution/engine/blockHash.js +17 -0
- package/lib/execution/engine/blockHash.js.map +1 -0
- package/lib/execution/engine/http.d.ts +2 -2
- package/lib/execution/engine/http.d.ts.map +1 -1
- package/lib/execution/engine/http.js +13 -7
- package/lib/execution/engine/http.js.map +1 -1
- package/lib/execution/engine/interface.d.ts +16 -3
- package/lib/execution/engine/interface.d.ts.map +1 -1
- package/lib/execution/engine/interface.js +11 -0
- package/lib/execution/engine/interface.js.map +1 -1
- package/lib/execution/engine/jsonRpcHttpClient.d.ts +2 -0
- package/lib/execution/engine/jsonRpcHttpClient.d.ts.map +1 -1
- package/lib/execution/engine/jsonRpcHttpClient.js +14 -6
- package/lib/execution/engine/jsonRpcHttpClient.js.map +1 -1
- package/lib/execution/engine/jsonRpcTransport.d.ts +2 -2
- package/lib/execution/engine/jsonRpcTransport.d.ts.map +1 -1
- package/lib/execution/engine/jsonRpcTransport.js +4 -4
- package/lib/execution/engine/jsonRpcTransport.js.map +1 -1
- package/lib/execution/engine/mock.d.ts.map +1 -1
- package/lib/execution/engine/mock.js +6 -6
- package/lib/execution/engine/mock.js.map +1 -1
- package/lib/execution/engine/payloadIdCache.d.ts +6 -1
- package/lib/execution/engine/payloadIdCache.d.ts.map +1 -1
- package/lib/execution/engine/payloadIdCache.js +7 -2
- package/lib/execution/engine/payloadIdCache.js.map +1 -1
- package/lib/execution/engine/restHttpClient.d.ts.map +1 -1
- package/lib/execution/engine/restHttpClient.js +9 -5
- package/lib/execution/engine/restHttpClient.js.map +1 -1
- package/lib/execution/engine/restTransport.d.ts +2 -2
- package/lib/execution/engine/restTransport.d.ts.map +1 -1
- package/lib/execution/engine/restTransport.js +4 -4
- package/lib/execution/engine/restTransport.js.map +1 -1
- package/lib/execution/engine/signal.d.ts +6 -0
- package/lib/execution/engine/signal.d.ts.map +1 -0
- package/lib/execution/engine/signal.js +24 -0
- package/lib/execution/engine/signal.js.map +1 -0
- package/lib/execution/engine/transport.d.ts +2 -2
- package/lib/execution/engine/transport.d.ts.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/metrics/metrics/beacon.d.ts +5 -0
- package/lib/metrics/metrics/beacon.d.ts.map +1 -1
- package/lib/metrics/metrics/beacon.js +5 -0
- package/lib/metrics/metrics/beacon.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +1 -0
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +5 -0
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/core/events.d.ts +6 -2
- package/lib/network/core/events.d.ts.map +1 -1
- package/lib/network/core/events.js +9 -0
- package/lib/network/core/events.js.map +1 -1
- package/lib/network/core/networkCoreWorkerHandler.d.ts.map +1 -1
- package/lib/network/core/networkCoreWorkerHandler.js +3 -2
- package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
- package/lib/network/gossip/gossipsub.d.ts +1 -0
- package/lib/network/gossip/gossipsub.d.ts.map +1 -1
- package/lib/network/gossip/gossipsub.js +5 -2
- package/lib/network/gossip/gossipsub.js.map +1 -1
- package/lib/network/gossip/topic.d.ts +1 -7
- package/lib/network/gossip/topic.d.ts.map +1 -1
- package/lib/network/gossip/topic.js +0 -13
- package/lib/network/gossip/topic.js.map +1 -1
- package/lib/network/network.d.ts +1 -0
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js +26 -12
- package/lib/network/network.js.map +1 -1
- package/lib/network/peers/peerManager.d.ts.map +1 -1
- package/lib/network/peers/peerManager.js +22 -2
- package/lib/network/peers/peerManager.js.map +1 -1
- package/lib/network/peers/utils/prioritizePeers.d.ts +2 -0
- package/lib/network/peers/utils/prioritizePeers.d.ts.map +1 -1
- package/lib/network/peers/utils/prioritizePeers.js +11 -2
- package/lib/network/peers/utils/prioritizePeers.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +19 -6
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
- package/lib/network/processor/gossipValidatorFn.js +4 -1
- package/lib/network/processor/gossipValidatorFn.js.map +1 -1
- package/lib/network/processor/index.d.ts.map +1 -1
- package/lib/network/processor/index.js +4 -2
- package/lib/network/processor/index.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
- package/lib/network/reqresp/utils/collect.d.ts +4 -4
- package/lib/network/reqresp/utils/collect.d.ts.map +1 -1
- package/lib/network/reqresp/utils/collect.js +9 -8
- package/lib/network/reqresp/utils/collect.js.map +1 -1
- package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts +1 -1
- package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts.map +1 -1
- package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js +2 -2
- package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js.map +1 -1
- package/lib/sync/range/batch.d.ts +10 -0
- package/lib/sync/range/batch.d.ts.map +1 -1
- package/lib/sync/range/batch.js +29 -0
- package/lib/sync/range/batch.js.map +1 -1
- package/lib/sync/range/chain.d.ts +17 -2
- package/lib/sync/range/chain.d.ts.map +1 -1
- package/lib/sync/range/chain.js +60 -20
- package/lib/sync/range/chain.js.map +1 -1
- package/lib/sync/range/range.d.ts.map +1 -1
- package/lib/sync/range/range.js +44 -3
- package/lib/sync/range/range.js.map +1 -1
- package/lib/sync/range/utils/batches.d.ts +20 -4
- package/lib/sync/range/utils/batches.d.ts.map +1 -1
- package/lib/sync/range/utils/batches.js +31 -13
- package/lib/sync/range/utils/batches.js.map +1 -1
- package/lib/sync/range/utils/peerBalancer.d.ts +1 -1
- package/lib/sync/range/utils/peerBalancer.d.ts.map +1 -1
- package/lib/sync/range/utils/peerBalancer.js +5 -2
- package/lib/sync/range/utils/peerBalancer.js.map +1 -1
- package/lib/sync/types.d.ts +14 -1
- package/lib/sync/types.d.ts.map +1 -1
- package/lib/sync/types.js +2 -0
- package/lib/sync/types.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts +28 -1
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +340 -27
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/downloadByRange.d.ts +22 -1
- package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRange.js +55 -25
- package/lib/sync/utils/downloadByRange.js.map +1 -1
- package/lib/sync/utils/downloadByRoot.d.ts +24 -2
- package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRoot.js +48 -5
- package/lib/sync/utils/downloadByRoot.js.map +1 -1
- package/lib/util/asyncIterableToEvents.d.ts +20 -3
- package/lib/util/asyncIterableToEvents.d.ts.map +1 -1
- package/lib/util/asyncIterableToEvents.js +76 -20
- package/lib/util/asyncIterableToEvents.js.map +1 -1
- package/lib/util/dataColumns.d.ts +1 -1
- package/lib/util/dataColumns.d.ts.map +1 -1
- package/lib/util/dataColumns.js +4 -1
- package/lib/util/dataColumns.js.map +1 -1
- package/lib/util/eventLoop.d.ts +3 -3
- package/lib/util/eventLoop.d.ts.map +1 -1
- package/lib/util/eventLoop.js +3 -3
- package/lib/util/eventLoop.js.map +1 -1
- package/package.json +27 -27
- package/src/api/impl/beacon/blocks/index.ts +53 -28
- package/src/api/impl/beacon/pool/index.ts +10 -8
- package/src/api/impl/beacon/state/utils.ts +2 -1
- package/src/api/impl/debug/index.ts +6 -2
- package/src/api/impl/validator/index.ts +122 -66
- package/src/chain/ColumnReconstructionTracker.ts +5 -0
- package/src/chain/archiveStore/historicalState/getHistoricalState.ts +9 -0
- package/src/chain/archiveStore/utils/archiveBlocks.ts +1 -1
- package/src/chain/archiveStore/utils/pruneHistory.ts +9 -4
- package/src/chain/blocks/importExecutionPayload.ts +9 -2
- package/src/chain/blocks/index.ts +3 -31
- package/src/chain/chain.ts +112 -78
- package/src/chain/errors/attestationError.ts +11 -1
- package/src/chain/errors/executionPayloadBid.ts +9 -2
- package/src/chain/errors/executionPayloadEnvelope.ts +58 -0
- package/src/chain/interface.ts +1 -1
- package/src/chain/lightClient/index.ts +108 -142
- package/src/chain/opPools/opPool.ts +6 -6
- package/src/chain/prepareNextSlot.ts +347 -89
- package/src/chain/produceBlock/produceBlockBody.ts +69 -80
- package/src/chain/seenCache/seenAttesters.ts +1 -1
- package/src/chain/seenCache/seenBlockAttesters.ts +48 -6
- package/src/chain/seenCache/seenExecutionPayloadBids.ts +35 -15
- package/src/chain/validation/aggregateAndProof.ts +24 -9
- package/src/chain/validation/attestation.ts +31 -20
- package/src/chain/validation/attesterSlashing.ts +4 -2
- package/src/chain/validation/block.ts +9 -1
- package/src/chain/validation/executionPayloadBid.ts +60 -44
- package/src/chain/validation/executionPayloadEnvelope.ts +115 -8
- package/src/chain/validation/payloadAttestationMessage.ts +10 -0
- package/src/chain/validation/proposerSlashing.ts +4 -2
- package/src/chain/validation/signatureSets/contributionAndProof.ts +4 -6
- package/src/chain/validation/signatureSets/syncCommittee.ts +2 -3
- package/src/chain/validation/signatureSets/syncCommitteeContribution.ts +2 -3
- package/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts +2 -3
- package/src/chain/validation/syncCommittee.ts +3 -5
- package/src/chain/validation/syncCommitteeContributionAndProof.ts +3 -3
- package/src/chain/validation/voluntaryExit.ts +44 -6
- package/src/chain/validatorMonitor.ts +43 -43
- package/src/execution/engine/blockHash.ts +27 -0
- package/src/execution/engine/http.ts +18 -10
- package/src/execution/engine/interface.ts +18 -3
- package/src/execution/engine/jsonRpcHttpClient.ts +26 -14
- package/src/execution/engine/jsonRpcTransport.ts +8 -4
- package/src/execution/engine/mock.ts +13 -8
- package/src/execution/engine/payloadIdCache.ts +12 -4
- package/src/execution/engine/restHttpClient.ts +17 -11
- package/src/execution/engine/restTransport.ts +5 -4
- package/src/execution/engine/signal.ts +28 -0
- package/src/execution/engine/transport.ts +3 -2
- package/src/index.ts +6 -1
- package/src/metrics/metrics/beacon.ts +9 -0
- package/src/metrics/metrics/lodestar.ts +5 -0
- package/src/network/core/events.ts +12 -0
- package/src/network/core/networkCoreWorkerHandler.ts +6 -2
- package/src/network/gossip/gossipsub.ts +6 -2
- package/src/network/gossip/topic.ts +1 -14
- package/src/network/network.ts +39 -13
- package/src/network/peers/peerManager.ts +26 -2
- package/src/network/peers/utils/prioritizePeers.ts +14 -1
- package/src/network/processor/gossipHandlers.ts +25 -13
- package/src/network/processor/gossipValidatorFn.ts +4 -0
- package/src/network/processor/index.ts +7 -2
- package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +1 -1
- package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +1 -1
- package/src/network/reqresp/utils/collect.ts +16 -8
- package/src/network/reqresp/utils/collectSequentialBlocksInRange.ts +3 -2
- package/src/sync/range/batch.ts +33 -0
- package/src/sync/range/chain.ts +72 -17
- package/src/sync/range/range.ts +57 -3
- package/src/sync/range/utils/batches.ts +38 -13
- package/src/sync/range/utils/peerBalancer.ts +4 -1
- package/src/sync/types.ts +13 -0
- package/src/sync/unknownBlock.ts +389 -29
- package/src/sync/utils/downloadByRange.ts +89 -29
- package/src/sync/utils/downloadByRoot.ts +75 -7
- package/src/util/asyncIterableToEvents.ts +100 -21
- package/src/util/dataColumns.ts +4 -1
- package/src/util/eventLoop.ts +3 -3
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import {routes} from "@lodestar/api";
|
|
2
2
|
import {ChainForkConfig} from "@lodestar/config";
|
|
3
|
-
import {getFinalizedExecutionBlockHash, getSafeExecutionBlockHash} from "@lodestar/fork-choice";
|
|
4
3
|
import {
|
|
4
|
+
ProtoBlock,
|
|
5
|
+
PtcQuorumEvent,
|
|
6
|
+
getFinalizedExecutionBlockHash,
|
|
7
|
+
getPtcVerdict,
|
|
8
|
+
getSafeExecutionBlockHash,
|
|
9
|
+
} from "@lodestar/fork-choice";
|
|
10
|
+
import {
|
|
11
|
+
ForkName,
|
|
5
12
|
ForkPostBellatrix,
|
|
6
13
|
ForkSeq,
|
|
7
14
|
SLOTS_PER_EPOCH,
|
|
@@ -21,7 +28,7 @@ import {
|
|
|
21
28
|
isStatePostFulu,
|
|
22
29
|
isStatePostGloas,
|
|
23
30
|
} from "@lodestar/state-transition";
|
|
24
|
-
import {Bytes32, Slot, ValidatorIndex} from "@lodestar/types";
|
|
31
|
+
import {Bytes32, RootHex, Slot, ValidatorIndex} from "@lodestar/types";
|
|
25
32
|
import {Logger, fromHex, isErrorAborted, sleep, toHex} from "@lodestar/utils";
|
|
26
33
|
import {GENESIS_SLOT} from "../constants/constants.js";
|
|
27
34
|
import {BuilderStatus} from "../execution/builder/http.js";
|
|
@@ -29,6 +36,7 @@ import {PayloadAttributes} from "../execution/index.js";
|
|
|
29
36
|
import {Metrics} from "../metrics/index.js";
|
|
30
37
|
import {ClockEvent} from "../util/clock.js";
|
|
31
38
|
import {isQueueErrorAborted} from "../util/queue/index.js";
|
|
39
|
+
import {ChainEvent} from "./emitter.js";
|
|
32
40
|
import {ForkchoiceCaller} from "./forkChoice/index.js";
|
|
33
41
|
import {IBeaconChain} from "./interface.js";
|
|
34
42
|
import {
|
|
@@ -38,8 +46,13 @@ import {
|
|
|
38
46
|
} from "./produceBlock/produceBlockBody.js";
|
|
39
47
|
import {RegenCaller} from "./regen/index.js";
|
|
40
48
|
|
|
41
|
-
|
|
42
|
-
|
|
49
|
+
/**
|
|
50
|
+
* With 12s slot times, this scheduler will run 4s before the start of each slot (`12 - 0.6667 * 12 = 4`).
|
|
51
|
+
*
|
|
52
|
+
* Post-Gloas this is after the payload deadline (50% of the slot), so the parent's payload has normally been
|
|
53
|
+
* imported, and before the PTC deadline (75%). The parent choice is revisited when the PTC verdict or a timely
|
|
54
|
+
* payload comes in after the scheduled run, see `reprepare`.
|
|
55
|
+
*/
|
|
43
56
|
export const PREPARE_NEXT_SLOT_BPS = 6667;
|
|
44
57
|
|
|
45
58
|
/* We don't want to do more epoch transition than this */
|
|
@@ -58,6 +71,28 @@ const BUILDER_PREVERIFY_LIMIT_BPS = 2000;
|
|
|
58
71
|
*/
|
|
59
72
|
const BUILDER_STATUS_CHECK_BEFORE_SLOT_BPS = 1667;
|
|
60
73
|
|
|
74
|
+
export enum PreparePayloadReason {
|
|
75
|
+
/** The scheduled run at PREPARE_NEXT_SLOT_BPS of the slot */
|
|
76
|
+
scheduled = "scheduled",
|
|
77
|
+
/** The PTC reached a verdict on the payload of the current slot's block */
|
|
78
|
+
ptcQuorum = "ptc_quorum",
|
|
79
|
+
/** A timely payload of the current slot's block was imported after the scheduled run */
|
|
80
|
+
payloadImported = "payload_imported",
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Inputs the payload for `prepareSlot` was last prepared with, a re-prepare with the same inputs is skipped */
|
|
84
|
+
type PreparedPayload = {
|
|
85
|
+
prepareSlot: Slot;
|
|
86
|
+
proposerIndex: ValidatorIndex;
|
|
87
|
+
headRoot: RootHex;
|
|
88
|
+
/** Whether the payload builds on the parent's full payload or its empty variant, `null` pre-Gloas */
|
|
89
|
+
buildOnFull: boolean | null;
|
|
90
|
+
/** `undefined` if the proposer is not ours, only the payload attributes event was emitted */
|
|
91
|
+
feeRecipient: string | undefined;
|
|
92
|
+
/** The forkchoiceUpdated failed, so a re-prepare retries it even with unchanged inputs */
|
|
93
|
+
failed: boolean;
|
|
94
|
+
};
|
|
95
|
+
|
|
61
96
|
/**
|
|
62
97
|
* At Bellatrix, if we are responsible for proposing in next slot, we want to prepare payload
|
|
63
98
|
* 4s before the start of next slot at PREPARE_NEXT_SLOT_BPS of the current slot.
|
|
@@ -70,6 +105,11 @@ const BUILDER_STATUS_CHECK_BEFORE_SLOT_BPS = 1667;
|
|
|
70
105
|
*
|
|
71
106
|
*/
|
|
72
107
|
export class PrepareNextSlotScheduler {
|
|
108
|
+
private lastPrepared: PreparedPayload | null = null;
|
|
109
|
+
/** Slot a payload preparation is in flight for, a re-prepare requested meanwhile runs after it */
|
|
110
|
+
private preparingSlot: Slot | null = null;
|
|
111
|
+
private queuedReason: PreparePayloadReason | null = null;
|
|
112
|
+
|
|
73
113
|
constructor(
|
|
74
114
|
private readonly chain: IBeaconChain,
|
|
75
115
|
private readonly config: ChainForkConfig,
|
|
@@ -78,10 +118,14 @@ export class PrepareNextSlotScheduler {
|
|
|
78
118
|
private readonly signal: AbortSignal
|
|
79
119
|
) {
|
|
80
120
|
this.chain.clock.on(ClockEvent.slot, this.prepareForNextSlot);
|
|
121
|
+
this.chain.emitter.on(ChainEvent.forkChoicePtcQuorum, this.onPtcQuorum);
|
|
122
|
+
this.chain.emitter.on(routes.events.EventType.executionPayload, this.onExecutionPayloadImported);
|
|
81
123
|
this.signal.addEventListener(
|
|
82
124
|
"abort",
|
|
83
125
|
() => {
|
|
84
126
|
this.chain.clock.off(ClockEvent.slot, this.prepareForNextSlot);
|
|
127
|
+
this.chain.emitter.off(ChainEvent.forkChoicePtcQuorum, this.onPtcQuorum);
|
|
128
|
+
this.chain.emitter.off(routes.events.EventType.executionPayload, this.onExecutionPayloadImported);
|
|
85
129
|
},
|
|
86
130
|
{once: true}
|
|
87
131
|
);
|
|
@@ -109,6 +153,10 @@ export class PrepareNextSlotScheduler {
|
|
|
109
153
|
// or precompute epoch transition
|
|
110
154
|
await sleep(this.config.getSlotComponentDurationMs(currentFork, PREPARE_NEXT_SLOT_BPS), this.signal);
|
|
111
155
|
|
|
156
|
+
// Re-prepare requests from here on are queued until this run is done. Earlier ones are
|
|
157
|
+
// dropped, the head computed below already reflects them.
|
|
158
|
+
this.preparingSlot = prepareSlot;
|
|
159
|
+
|
|
112
160
|
// calling updateHead() here before we produce a block to reduce reorg possibility
|
|
113
161
|
const headBlock = this.chain.recomputeForkChoiceHead(ForkchoiceCaller.prepareNextSlot);
|
|
114
162
|
const {slot: headSlot, blockRoot: headRoot} = headBlock;
|
|
@@ -163,15 +211,7 @@ export class PrepareNextSlotScheduler {
|
|
|
163
211
|
};
|
|
164
212
|
|
|
165
213
|
const proposerIndex = await getProposerIndex();
|
|
166
|
-
|
|
167
|
-
const pooledPreferences = isForkPostGloas(fork)
|
|
168
|
-
? getPooledProposerPreferences(this.chain, prepareSlot, headRoot)
|
|
169
|
-
: null;
|
|
170
|
-
feeRecipient =
|
|
171
|
-
pooledPreferences !== null
|
|
172
|
-
? toHex(pooledPreferences.feeRecipient)
|
|
173
|
-
: this.chain.beaconProposerCache.getOrDefault(proposerIndex);
|
|
174
|
-
}
|
|
214
|
+
feeRecipient = this.getFeeRecipient(fork, prepareSlot, headRoot, proposerIndex);
|
|
175
215
|
|
|
176
216
|
// Predict the proposer head of the next slot when either:
|
|
177
217
|
// - we are proposing the next slot (single-slot proposer-boost-reorg), or
|
|
@@ -231,82 +271,15 @@ export class PrepareNextSlotScheduler {
|
|
|
231
271
|
);
|
|
232
272
|
}
|
|
233
273
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
if (this.chain.forkChoice.shouldBuildOnFull(updatedHead, prepareSlot)) {
|
|
244
|
-
parentBlockHash = preparedState.latestExecutionPayloadBid.blockHash;
|
|
245
|
-
// Skip applying parent payload unless we're proposing the next slot or have to emit payload_attributes events
|
|
246
|
-
if (feeRecipient !== undefined || this.chain.opts.emitPayloadAttributes === true) {
|
|
247
|
-
const parentExecutionRequests = await this.chain.getParentExecutionRequests(
|
|
248
|
-
updatedHead.slot,
|
|
249
|
-
updatedHead.blockRoot
|
|
250
|
-
);
|
|
251
|
-
stateAfterParentPayload = preparedState.withParentPayloadApplied(parentExecutionRequests);
|
|
252
|
-
}
|
|
253
|
-
} else {
|
|
254
|
-
parentBlockHash = preparedState.latestExecutionPayloadBid.parentBlockHash;
|
|
255
|
-
}
|
|
256
|
-
} else {
|
|
257
|
-
parentBlockHash = preparedState.latestExecutionPayloadHeader.blockHash;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
// The payload_attributes event must carry the same hashes we send to the EL
|
|
261
|
-
const safeBlockHash = getSafeExecutionBlockHash(this.chain.forkChoice, this.logger);
|
|
262
|
-
const finalizedBlockHash = getFinalizedExecutionBlockHash(this.chain.forkChoice);
|
|
263
|
-
|
|
264
|
-
let payloadAttributes: PayloadAttributes | undefined;
|
|
265
|
-
// If emitPayloadAttributes is true emit a SSE payloadAttributes event for
|
|
266
|
-
// every slot. Without the flag, only emit the event if we are proposing in the next slot.
|
|
267
|
-
if (
|
|
268
|
-
(feeRecipient || this.chain.opts.emitPayloadAttributes === true) &&
|
|
269
|
-
this.chain.emitter.listenerCount(routes.events.EventType.payloadAttributes)
|
|
270
|
-
) {
|
|
271
|
-
const data = getPayloadAttributesForSSE(fork as ForkPostBellatrix, this.chain, {
|
|
272
|
-
prepareState: stateAfterParentPayload,
|
|
273
|
-
prepareSlot,
|
|
274
|
-
parentBlockRoot: fromHex(updatedHead.blockRoot),
|
|
275
|
-
parentBlockHash,
|
|
276
|
-
safeBlockHash,
|
|
277
|
-
finalizedBlockHash,
|
|
278
|
-
feeRecipient: feeRecipient ?? "0x0000000000000000000000000000000000000000",
|
|
279
|
-
});
|
|
280
|
-
this.chain.emitter.emit(routes.events.EventType.payloadAttributes, {data, version: fork});
|
|
281
|
-
payloadAttributes = data.payloadAttributes;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
if (feeRecipient) {
|
|
285
|
-
const preparationTime =
|
|
286
|
-
computeTimeAtSlot(this.config, prepareSlot, this.chain.genesisTime) - Date.now() / 1000;
|
|
287
|
-
this.metrics?.blockPayload.payloadAdvancePrepTime.observe(preparationTime);
|
|
288
|
-
|
|
289
|
-
// awaiting here instead of throwing an async call because there is no other task
|
|
290
|
-
// left for scheduler and this gives nice semantics to catch and log errors in the
|
|
291
|
-
// try/catch wrapper here.
|
|
292
|
-
await prepareExecutionPayload(
|
|
293
|
-
this.chain,
|
|
294
|
-
this.logger,
|
|
295
|
-
fork as ForkPostBellatrix, // State is of execution type
|
|
296
|
-
fromHex(updatedHead.blockRoot),
|
|
297
|
-
parentBlockHash,
|
|
298
|
-
safeBlockHash,
|
|
299
|
-
finalizedBlockHash,
|
|
300
|
-
stateAfterParentPayload,
|
|
301
|
-
feeRecipient,
|
|
302
|
-
payloadAttributes
|
|
303
|
-
);
|
|
304
|
-
this.logger.verbose("PrepareNextSlotScheduler prepared new payload", {
|
|
305
|
-
prepareSlot,
|
|
306
|
-
proposerIndex,
|
|
307
|
-
feeRecipient,
|
|
308
|
-
});
|
|
309
|
-
}
|
|
274
|
+
await this.preparePayload({
|
|
275
|
+
reason: PreparePayloadReason.scheduled,
|
|
276
|
+
fork: fork as ForkPostBellatrix,
|
|
277
|
+
prepareSlot,
|
|
278
|
+
proposerIndex,
|
|
279
|
+
feeRecipient,
|
|
280
|
+
head: updatedHead,
|
|
281
|
+
state: preparedState,
|
|
282
|
+
});
|
|
310
283
|
|
|
311
284
|
this.computeStateHashTreeRoot(preparedState, isEpochTransition);
|
|
312
285
|
} else {
|
|
@@ -416,9 +389,294 @@ export class PrepareNextSlotScheduler {
|
|
|
416
389
|
this.metrics?.precomputeNextEpochTransition.count.inc({result: "error"}, 1);
|
|
417
390
|
this.logger.error("Failed to run prepareForNextSlot", {nextEpoch, isEpochTransition, prepareSlot}, e as Error);
|
|
418
391
|
}
|
|
392
|
+
} finally {
|
|
393
|
+
this.finishRun(prepareSlot);
|
|
419
394
|
}
|
|
420
395
|
};
|
|
421
396
|
|
|
397
|
+
/**
|
|
398
|
+
* Choose the parent the payload for `prepareSlot` builds on, emit the payload attributes and ask the engine
|
|
399
|
+
* to build the payload. Records the inputs so a later `reprepare` can skip an unchanged result.
|
|
400
|
+
*/
|
|
401
|
+
private async preparePayload({
|
|
402
|
+
reason,
|
|
403
|
+
fork,
|
|
404
|
+
prepareSlot,
|
|
405
|
+
proposerIndex,
|
|
406
|
+
feeRecipient,
|
|
407
|
+
head,
|
|
408
|
+
state,
|
|
409
|
+
}: {
|
|
410
|
+
reason: PreparePayloadReason;
|
|
411
|
+
fork: ForkPostBellatrix;
|
|
412
|
+
prepareSlot: Slot;
|
|
413
|
+
proposerIndex: ValidatorIndex;
|
|
414
|
+
feeRecipient: string | undefined;
|
|
415
|
+
head: ProtoBlock;
|
|
416
|
+
state: IBeaconStateView;
|
|
417
|
+
}): Promise<void> {
|
|
418
|
+
if (!isStatePostBellatrix(state)) {
|
|
419
|
+
throw new Error("Expected Bellatrix state for payload attributes");
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
let parentBlockHash: Bytes32;
|
|
423
|
+
let buildOnFull: boolean | null = null;
|
|
424
|
+
// Apply parent payload once here as it's reused by EL prep and SSE emit below
|
|
425
|
+
let stateAfterParentPayload: IBeaconStateViewBellatrix = state;
|
|
426
|
+
if (isStatePostGloas(state)) {
|
|
427
|
+
// Spec: should_build_on_full(store, head, slot) - see produceBlockBody.ts for context.
|
|
428
|
+
buildOnFull = this.chain.forkChoice.shouldBuildOnFull(head, prepareSlot);
|
|
429
|
+
if (buildOnFull) {
|
|
430
|
+
parentBlockHash = state.latestExecutionPayloadBid.blockHash;
|
|
431
|
+
// Skip applying parent payload unless we're proposing the next slot or have to emit payload_attributes events
|
|
432
|
+
if (feeRecipient !== undefined || this.chain.opts.emitPayloadAttributes === true) {
|
|
433
|
+
const parentExecutionRequests = await this.chain.getParentExecutionRequests(head.slot, head.blockRoot);
|
|
434
|
+
stateAfterParentPayload = state.withParentPayloadApplied(parentExecutionRequests);
|
|
435
|
+
}
|
|
436
|
+
} else {
|
|
437
|
+
parentBlockHash = state.latestExecutionPayloadBid.parentBlockHash;
|
|
438
|
+
}
|
|
439
|
+
} else {
|
|
440
|
+
parentBlockHash = state.latestExecutionPayloadHeader.blockHash;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// Block production owns the engine head once the proposal slot started, a late fcU could move it back
|
|
444
|
+
if (reason !== PreparePayloadReason.scheduled && this.chain.clock.currentSlot >= prepareSlot) {
|
|
445
|
+
this.metrics?.blockPayload.payloadReprepare.inc({reason, result: "dropped"});
|
|
446
|
+
this.logger.debug("Proposal slot started, not re-preparing", {prepareSlot, reason, headRoot: head.blockRoot});
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
// The payload_attributes event must carry the same hashes we send to the EL
|
|
451
|
+
const safeBlockHash = getSafeExecutionBlockHash(this.chain.forkChoice, this.logger);
|
|
452
|
+
const finalizedBlockHash = getFinalizedExecutionBlockHash(this.chain.forkChoice);
|
|
453
|
+
|
|
454
|
+
let payloadAttributes: PayloadAttributes | undefined;
|
|
455
|
+
// If emitPayloadAttributes is true emit a SSE payloadAttributes event for
|
|
456
|
+
// every slot. Without the flag, only emit the event if we are proposing in the next slot.
|
|
457
|
+
if (
|
|
458
|
+
(feeRecipient || this.chain.opts.emitPayloadAttributes === true) &&
|
|
459
|
+
this.chain.emitter.listenerCount(routes.events.EventType.payloadAttributes)
|
|
460
|
+
) {
|
|
461
|
+
const data = getPayloadAttributesForSSE(fork, this.chain, {
|
|
462
|
+
prepareState: stateAfterParentPayload,
|
|
463
|
+
prepareSlot,
|
|
464
|
+
parentBlockRoot: fromHex(head.blockRoot),
|
|
465
|
+
parentBlockHash,
|
|
466
|
+
safeBlockHash,
|
|
467
|
+
finalizedBlockHash,
|
|
468
|
+
feeRecipient: feeRecipient ?? "0x0000000000000000000000000000000000000000",
|
|
469
|
+
});
|
|
470
|
+
this.chain.emitter.emit(routes.events.EventType.payloadAttributes, {data, version: fork});
|
|
471
|
+
payloadAttributes = data.payloadAttributes;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// Builders take the parent from the payload attributes event, so re-prepare whenever it was emitted. Recorded
|
|
475
|
+
// before the engine call, a failed forkchoiceUpdated must not drop the later re-prepares for this slot
|
|
476
|
+
const prepared = feeRecipient !== undefined || payloadAttributes !== undefined;
|
|
477
|
+
const record: PreparedPayload = {
|
|
478
|
+
prepareSlot,
|
|
479
|
+
proposerIndex,
|
|
480
|
+
headRoot: head.blockRoot,
|
|
481
|
+
buildOnFull,
|
|
482
|
+
feeRecipient,
|
|
483
|
+
failed: false,
|
|
484
|
+
};
|
|
485
|
+
if (prepared) {
|
|
486
|
+
this.lastPrepared = record;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
if (feeRecipient) {
|
|
490
|
+
// Only for the scheduled run, a re-prepare later in the slot would add a second, shorter sample
|
|
491
|
+
if (reason === PreparePayloadReason.scheduled) {
|
|
492
|
+
const preparationTime = computeTimeAtSlot(this.config, prepareSlot, this.chain.genesisTime) - Date.now() / 1000;
|
|
493
|
+
this.metrics?.blockPayload.payloadAdvancePrepTime.observe(preparationTime);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
// awaiting here instead of throwing an async call because there is no other task
|
|
497
|
+
// left for scheduler and this gives nice semantics to catch and log errors in the
|
|
498
|
+
// try/catch wrapper here.
|
|
499
|
+
try {
|
|
500
|
+
await prepareExecutionPayload(
|
|
501
|
+
this.chain,
|
|
502
|
+
this.logger,
|
|
503
|
+
fork, // State is of execution type
|
|
504
|
+
fromHex(head.blockRoot),
|
|
505
|
+
parentBlockHash,
|
|
506
|
+
safeBlockHash,
|
|
507
|
+
finalizedBlockHash,
|
|
508
|
+
stateAfterParentPayload,
|
|
509
|
+
feeRecipient,
|
|
510
|
+
payloadAttributes
|
|
511
|
+
);
|
|
512
|
+
} catch (e) {
|
|
513
|
+
record.failed = true;
|
|
514
|
+
throw e;
|
|
515
|
+
}
|
|
516
|
+
this.logger.verbose("PrepareNextSlotScheduler prepared new payload", {
|
|
517
|
+
prepareSlot,
|
|
518
|
+
proposerIndex,
|
|
519
|
+
feeRecipient,
|
|
520
|
+
reason,
|
|
521
|
+
headRoot: head.blockRoot,
|
|
522
|
+
buildOnFull,
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
if (prepared && reason !== PreparePayloadReason.scheduled) {
|
|
527
|
+
this.metrics?.blockPayload.payloadReprepare.inc({reason, result: "changed"});
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/** Fee recipient of our validator proposing `prepareSlot`, `undefined` if the proposer is not ours */
|
|
532
|
+
private getFeeRecipient(
|
|
533
|
+
fork: ForkName,
|
|
534
|
+
prepareSlot: Slot,
|
|
535
|
+
headRoot: RootHex,
|
|
536
|
+
proposerIndex: ValidatorIndex
|
|
537
|
+
): string | undefined {
|
|
538
|
+
if (!this.chain.beaconProposerCache.has(proposerIndex)) {
|
|
539
|
+
return undefined;
|
|
540
|
+
}
|
|
541
|
+
const pooledPreferences = isForkPostGloas(fork)
|
|
542
|
+
? getPooledProposerPreferences(this.chain, prepareSlot, headRoot)
|
|
543
|
+
: null;
|
|
544
|
+
return pooledPreferences !== null
|
|
545
|
+
? toHex(pooledPreferences.feeRecipient)
|
|
546
|
+
: this.chain.beaconProposerCache.getOrDefault(proposerIndex);
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* The PTC verdict on the current slot's block decides whether the next proposal extends its payload.
|
|
551
|
+
* Spec: the proposer SHOULD call `prepare_execution_payload` again once the parent's payload attestations are in.
|
|
552
|
+
*/
|
|
553
|
+
private onPtcQuorum = (data: PtcQuorumEvent): void => {
|
|
554
|
+
if (data.slot === this.chain.clock.currentSlot) {
|
|
555
|
+
this.requestReprepare(PreparePayloadReason.ptcQuorum);
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* A payload of the current slot's block imported after the scheduled run moves the head to its full variant.
|
|
561
|
+
* Only react to a payload the PTC votes present: seen before the payload deadline, or already voted present. The
|
|
562
|
+
* event is only emitted once the payload's data is available. A late one without that verdict will likely be voted
|
|
563
|
+
* absent and the re-prepare undone.
|
|
564
|
+
*/
|
|
565
|
+
private onExecutionPayloadImported = ({slot, blockRoot}: {slot: Slot; blockRoot: RootHex}): void => {
|
|
566
|
+
if (slot !== this.chain.clock.currentSlot) {
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
const payloadInput = this.chain.seenPayloadEnvelopeInputCache.get(blockRoot);
|
|
570
|
+
if (payloadInput === undefined || !payloadInput.hasPayloadEnvelope()) {
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
const seenSec = this.chain.clock.secFromSlot(slot, payloadInput.getPayloadEnvelopeSource().seenTimestampSec);
|
|
574
|
+
const quorum = this.chain.forkChoice.getPtcQuorum(blockRoot);
|
|
575
|
+
if (
|
|
576
|
+
seenSec >= this.config.getPayloadDueMs(this.config.getForkName(slot)) / 1000 &&
|
|
577
|
+
(quorum === null || getPtcVerdict(quorum) !== true)
|
|
578
|
+
) {
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
this.requestReprepare(PreparePayloadReason.payloadImported);
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Re-run the payload preparation for the next slot after its inputs may have changed. Waits for an in-flight
|
|
586
|
+
* preparation, drops the request if neither a payload nor payload attributes were prepared for the next slot.
|
|
587
|
+
*/
|
|
588
|
+
private requestReprepare(reason: PreparePayloadReason): void {
|
|
589
|
+
const prepareSlot = this.chain.clock.currentSlot + 1;
|
|
590
|
+
if (this.preparingSlot !== null) {
|
|
591
|
+
if (this.preparingSlot === prepareSlot) {
|
|
592
|
+
this.queuedReason = reason;
|
|
593
|
+
}
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
if (this.lastPrepared?.prepareSlot !== prepareSlot) {
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
this.preparingSlot = prepareSlot;
|
|
601
|
+
this.reprepare(prepareSlot, reason)
|
|
602
|
+
.catch((e) => {
|
|
603
|
+
if (!isErrorAborted(e) && !isQueueErrorAborted(e)) {
|
|
604
|
+
this.metrics?.blockPayload.payloadReprepare.inc({reason, result: "error"});
|
|
605
|
+
this.logger.error("Failed to re-prepare payload for next slot", {prepareSlot, reason}, e as Error);
|
|
606
|
+
}
|
|
607
|
+
})
|
|
608
|
+
.finally(() => this.finishRun(prepareSlot));
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
private finishRun(prepareSlot: Slot): void {
|
|
612
|
+
if (this.preparingSlot !== prepareSlot) {
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
this.preparingSlot = null;
|
|
616
|
+
const queued = this.queuedReason;
|
|
617
|
+
this.queuedReason = null;
|
|
618
|
+
if (queued !== null) {
|
|
619
|
+
this.requestReprepare(queued);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
private async reprepare(prepareSlot: Slot, reason: PreparePayloadReason): Promise<void> {
|
|
624
|
+
const prepared = this.lastPrepared;
|
|
625
|
+
const fork = this.config.getForkName(prepareSlot);
|
|
626
|
+
if (prepared === null || prepared.prepareSlot !== prepareSlot || !isForkPostBellatrix(fork)) {
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
// Same head resolution as the scheduled run, the head may have changed since
|
|
631
|
+
const headBlock = this.chain.recomputeForkChoiceHead(ForkchoiceCaller.prepareNextSlot);
|
|
632
|
+
const feeRecipient = this.getFeeRecipient(fork, prepareSlot, headBlock.blockRoot, prepared.proposerIndex);
|
|
633
|
+
// Without a local proposer a re-prepare only re-emits the payload attributes, skip it if nobody listens
|
|
634
|
+
if (
|
|
635
|
+
feeRecipient === undefined &&
|
|
636
|
+
(this.chain.opts.emitPayloadAttributes !== true ||
|
|
637
|
+
this.chain.emitter.listenerCount(routes.events.EventType.payloadAttributes) === 0)
|
|
638
|
+
) {
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
const isEpochTransition = computeEpochAtSlot(prepareSlot) > computeEpochAtSlot(prepareSlot - 1);
|
|
642
|
+
const proposerHead = feeRecipient !== undefined || isEpochTransition ? this.chain.predictProposerHead() : headBlock;
|
|
643
|
+
const head = proposerHead.blockRoot !== headBlock.blockRoot ? proposerHead : headBlock;
|
|
644
|
+
|
|
645
|
+
const buildOnFull = isForkPostGloas(fork) ? this.chain.forkChoice.shouldBuildOnFull(head, prepareSlot) : null;
|
|
646
|
+
const logCtx = {prepareSlot, reason, headRoot: head.blockRoot, buildOnFull};
|
|
647
|
+
if (
|
|
648
|
+
!prepared.failed &&
|
|
649
|
+
head.blockRoot === prepared.headRoot &&
|
|
650
|
+
buildOnFull === prepared.buildOnFull &&
|
|
651
|
+
feeRecipient === prepared.feeRecipient
|
|
652
|
+
) {
|
|
653
|
+
this.metrics?.blockPayload.payloadReprepare.inc({reason, result: "unchanged"});
|
|
654
|
+
this.logger.debug("Payload for next slot unchanged, not re-preparing", logCtx);
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
this.logger.verbose("Re-preparing payload for next slot", {
|
|
658
|
+
...logCtx,
|
|
659
|
+
prevHeadRoot: prepared.headRoot,
|
|
660
|
+
prevBuildOnFull: prepared.buildOnFull,
|
|
661
|
+
});
|
|
662
|
+
|
|
663
|
+
const state = await this.chain.regen.getBlockSlotState(
|
|
664
|
+
head,
|
|
665
|
+
prepareSlot,
|
|
666
|
+
{dontTransferCache: !isEpochTransition},
|
|
667
|
+
head === headBlock ? RegenCaller.precomputeEpoch : RegenCaller.predictProposerHead
|
|
668
|
+
);
|
|
669
|
+
await this.preparePayload({
|
|
670
|
+
reason,
|
|
671
|
+
fork,
|
|
672
|
+
prepareSlot,
|
|
673
|
+
proposerIndex: prepared.proposerIndex,
|
|
674
|
+
feeRecipient,
|
|
675
|
+
head,
|
|
676
|
+
state,
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
|
|
422
680
|
/**
|
|
423
681
|
* Pre-establish the builder connections so the handshake lands outside the bid deadline. Scheduled
|
|
424
682
|
* later in the slot, connecting at PREPARE_NEXT_SLOT_BPS would go cold before bids are requested.
|