@lodestar/beacon-node 1.52.0-dev.2252a15492 → 1.52.0-dev.263ed9ded6
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 +22 -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 +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 +14 -3
- package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadBid.js +3 -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 +58 -43
- 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 +11 -2
- 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.map +1 -1
- package/lib/network/network.js +12 -7
- 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/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/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 +24 -8
- 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 +15 -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 +75 -50
- package/src/chain/validation/executionPayloadEnvelope.ts +115 -8
- package/src/chain/validation/payloadAttestationMessage.ts +12 -2
- 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 +12 -8
- 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/index.ts +7 -2
- package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +1 -1
- package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +1 -1
- 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
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
G2_POINT_AT_INFINITY,
|
|
25
25
|
IBeaconStateView,
|
|
26
26
|
type IBeaconStateViewBellatrix,
|
|
27
|
+
type IBeaconStateViewGloas,
|
|
27
28
|
computeEpochAtSlot,
|
|
28
29
|
computeTimeAtSlot,
|
|
29
30
|
getExpectedGasLimit,
|
|
@@ -111,6 +112,12 @@ export type BlockAttributes = {
|
|
|
111
112
|
graffiti: Bytes32;
|
|
112
113
|
slot: Slot;
|
|
113
114
|
parentBlock: ProtoBlock;
|
|
115
|
+
// the state of parentBlock processed to slot
|
|
116
|
+
parentState: IBeaconStateView;
|
|
117
|
+
// parentStateWithPayload is the same as parentState for pre-gloas or if building on EMPTY
|
|
118
|
+
parentStateWithPayload: IBeaconStateView;
|
|
119
|
+
// Parent's execution requests, undefined pre-gloas.
|
|
120
|
+
parentExecutionRequests?: gloas.ExecutionRequests;
|
|
114
121
|
feeRecipient?: string;
|
|
115
122
|
/** Verify that a locally produced execution payload uses `feeRecipient`. */
|
|
116
123
|
strictFeeRecipientCheck?: boolean;
|
|
@@ -175,32 +182,9 @@ export type ProduceResult =
|
|
|
175
182
|
| ProduceFullPhase0
|
|
176
183
|
| ProduceBlinded;
|
|
177
184
|
|
|
178
|
-
/**
|
|
179
|
-
* Drop voluntary exits that `parent_execution_requests` have invalidated (e.g. a withdrawal
|
|
180
|
-
* request initiating an exit on the same validator). Op pool selected against the unapplied
|
|
181
|
-
* state, so re-validate against the post-apply state to avoid producing an invalid block.
|
|
182
|
-
*
|
|
183
|
-
* `getStateAfterParentPayload` is a thunk so the post-apply state is only materialized when
|
|
184
|
-
* actually needed (i.e. when extending the parent payload and there are exits to filter).
|
|
185
|
-
*/
|
|
186
|
-
function maybeFilterInvalidatedVoluntaryExits(
|
|
187
|
-
commonBlockBody: CommonBlockBody,
|
|
188
|
-
isExtendingPayload: boolean,
|
|
189
|
-
getStateAfterParentPayload: () => IBeaconStateViewBellatrix
|
|
190
|
-
): CommonBlockBody["voluntaryExits"] {
|
|
191
|
-
if (!isExtendingPayload || commonBlockBody.voluntaryExits.length === 0) {
|
|
192
|
-
return commonBlockBody.voluntaryExits;
|
|
193
|
-
}
|
|
194
|
-
const state = getStateAfterParentPayload();
|
|
195
|
-
return commonBlockBody.voluntaryExits.filter((signedVoluntaryExit) =>
|
|
196
|
-
state.isValidVoluntaryExit(signedVoluntaryExit, false)
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
185
|
export async function produceBlockBody<T extends BlockType>(
|
|
201
186
|
this: BeaconChain,
|
|
202
187
|
blockType: T,
|
|
203
|
-
currentState: IBeaconStateView,
|
|
204
188
|
blockAttr: BlockAttributes & {
|
|
205
189
|
proposerIndex: ValidatorIndex;
|
|
206
190
|
proposerPubKey: BLSPubkey;
|
|
@@ -221,6 +205,9 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
221
205
|
proposerPubKey,
|
|
222
206
|
commonBlockBodyPromise,
|
|
223
207
|
builderBid,
|
|
208
|
+
parentState,
|
|
209
|
+
parentStateWithPayload,
|
|
210
|
+
parentExecutionRequests,
|
|
224
211
|
} = blockAttr;
|
|
225
212
|
let executionPayloadValue: Wei;
|
|
226
213
|
let blockBody: AssembledBodyType<T>;
|
|
@@ -242,17 +229,17 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
242
229
|
this.logger.verbose("Producing beacon block body", logMeta);
|
|
243
230
|
|
|
244
231
|
if (builderBid !== undefined) {
|
|
245
|
-
if (!isStatePostGloas(
|
|
246
|
-
throw new Error(
|
|
232
|
+
if (!isStatePostGloas(parentState)) {
|
|
233
|
+
throw new Error(`Expected Gloas state for builder bid block production slot=${blockSlot}`);
|
|
234
|
+
}
|
|
235
|
+
if (parentExecutionRequests === undefined) {
|
|
236
|
+
throw new Error(`Expected parentExecutionRequests for gloas block production slot=${blockSlot}`);
|
|
247
237
|
}
|
|
248
238
|
|
|
249
239
|
const isExtendingPayload = byteArrayEquals(
|
|
250
240
|
builderBid.message.parentBlockHash,
|
|
251
|
-
|
|
241
|
+
parentState.latestExecutionPayloadBid.blockHash
|
|
252
242
|
);
|
|
253
|
-
const parentExecutionRequests = isExtendingPayload
|
|
254
|
-
? await this.getParentExecutionRequests(parentBlock.slot, parentBlock.blockRoot)
|
|
255
|
-
: ssz.gloas.ExecutionRequests.defaultValue();
|
|
256
243
|
executionPayloadValue = (BigInt(builderBid.message.value) + builderBid.message.executionPayment) * GWEI_TO_WEI;
|
|
257
244
|
|
|
258
245
|
const commonBlockBody = await commonBlockBodyPromise;
|
|
@@ -262,10 +249,9 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
262
249
|
parentBlock.blockRoot,
|
|
263
250
|
blockSlot - 1
|
|
264
251
|
);
|
|
252
|
+
// parentExecutionRequests fetched once by the entrypoint (isExtendingPayload aligns with the
|
|
253
|
+
// build-on-full decision used to select this bid; default value when building on an empty parent)
|
|
265
254
|
gloasBody.parentExecutionRequests = parentExecutionRequests;
|
|
266
|
-
gloasBody.voluntaryExits = maybeFilterInvalidatedVoluntaryExits(commonBlockBody, isExtendingPayload, () =>
|
|
267
|
-
currentState.withParentPayloadApplied(parentExecutionRequests)
|
|
268
|
-
);
|
|
269
255
|
blockBody = gloasBody as AssembledBodyType<T>;
|
|
270
256
|
|
|
271
257
|
this.logger.verbose("Produced block with builder bid", {
|
|
@@ -278,8 +264,11 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
278
264
|
isExtendingPayload,
|
|
279
265
|
});
|
|
280
266
|
} else if (isForkPostGloas(fork)) {
|
|
281
|
-
if (!isStatePostGloas(
|
|
282
|
-
throw new Error(
|
|
267
|
+
if (!isStatePostGloas(parentState)) {
|
|
268
|
+
throw new Error(`Expected Gloas state for Gloas block production slot=${blockSlot}`);
|
|
269
|
+
}
|
|
270
|
+
if (parentExecutionRequests === undefined) {
|
|
271
|
+
throw new Error(`Expected parentExecutionRequests for gloas block production slot=${blockSlot}`);
|
|
283
272
|
}
|
|
284
273
|
|
|
285
274
|
// TODO GLOAS: support non self-building here, the block type differentiation between
|
|
@@ -299,20 +288,16 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
299
288
|
|
|
300
289
|
// Get execution payload from EL
|
|
301
290
|
let parentBlockHash: Bytes32;
|
|
302
|
-
|
|
303
|
-
//
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
const isBuildingOnFull = this.forkChoice.shouldBuildOnFull(parentBlock, blockSlot);
|
|
291
|
+
const stateAfterParentPayload = parentStateWithPayload as IBeaconStateViewGloas;
|
|
292
|
+
// Spec: should_build_on_full(store, head, slot), decided by the caller when applying the parent payload
|
|
293
|
+
const isBuildingOnFull = byteArrayEquals(
|
|
294
|
+
stateAfterParentPayload.latestBlockHash,
|
|
295
|
+
parentState.latestExecutionPayloadBid.blockHash
|
|
296
|
+
);
|
|
309
297
|
if (isBuildingOnFull) {
|
|
310
|
-
parentBlockHash =
|
|
311
|
-
parentExecutionRequests = await this.getParentExecutionRequests(parentBlock.slot, parentBlock.blockRoot);
|
|
312
|
-
stateAfterParentPayload = currentState.withParentPayloadApplied(parentExecutionRequests);
|
|
298
|
+
parentBlockHash = parentState.latestExecutionPayloadBid.blockHash;
|
|
313
299
|
} else {
|
|
314
|
-
parentBlockHash =
|
|
315
|
-
parentExecutionRequests = ssz.gloas.ExecutionRequests.defaultValue();
|
|
300
|
+
parentBlockHash = parentState.latestExecutionPayloadBid.parentBlockHash;
|
|
316
301
|
}
|
|
317
302
|
const prepareRes = await prepareExecutionPayload(
|
|
318
303
|
this,
|
|
@@ -326,7 +311,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
326
311
|
feeRecipient
|
|
327
312
|
);
|
|
328
313
|
|
|
329
|
-
const {prepType, payloadId} = prepareRes;
|
|
314
|
+
const {prepType, payloadId, preparedAtMs} = prepareRes;
|
|
330
315
|
Object.assign(logMeta, {executionPayloadPrepType: prepType});
|
|
331
316
|
|
|
332
317
|
this.logger.verbose("Prepared execution payload from engine", {
|
|
@@ -339,9 +324,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
339
324
|
isBuildingOnFull,
|
|
340
325
|
});
|
|
341
326
|
|
|
342
|
-
|
|
343
|
-
await sleep(PAYLOAD_GENERATION_TIME_MS);
|
|
344
|
-
}
|
|
327
|
+
await waitForPayloadGeneration(preparedAtMs);
|
|
345
328
|
|
|
346
329
|
this.logger.verbose("Fetching execution payload from engine", {slot: blockSlot, payloadId});
|
|
347
330
|
const payloadRes = await this.executionEngine.getPayload(fork, payloadId);
|
|
@@ -379,7 +362,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
379
362
|
parentBlockHash,
|
|
380
363
|
parentBlockRoot,
|
|
381
364
|
blockHash: executionPayload.blockHash,
|
|
382
|
-
prevRandao:
|
|
365
|
+
prevRandao: parentState.getRandaoMix(parentState.epoch),
|
|
383
366
|
feeRecipient: executionPayload.feeRecipient,
|
|
384
367
|
gasLimit: BigInt(executionPayload.gasLimit),
|
|
385
368
|
builderIndex: BUILDER_INDEX_SELF_BUILD,
|
|
@@ -416,12 +399,8 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
416
399
|
parentBlock.blockRoot,
|
|
417
400
|
blockSlot - 1
|
|
418
401
|
);
|
|
402
|
+
// parentExecutionRequests fetched once by the entrypoint (default value when building on an empty parent)
|
|
419
403
|
gloasBody.parentExecutionRequests = parentExecutionRequests;
|
|
420
|
-
gloasBody.voluntaryExits = maybeFilterInvalidatedVoluntaryExits(
|
|
421
|
-
commonBlockBody,
|
|
422
|
-
isBuildingOnFull,
|
|
423
|
-
() => stateAfterParentPayload
|
|
424
|
-
);
|
|
425
404
|
blockBody = gloasBody as AssembledBodyType<T>;
|
|
426
405
|
|
|
427
406
|
// Store execution payload data required to construct execution payload envelope later
|
|
@@ -451,7 +430,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
451
430
|
shouldOverrideBuilder,
|
|
452
431
|
});
|
|
453
432
|
} else if (isForkPostBellatrix(fork)) {
|
|
454
|
-
if (!isStatePostBellatrix(
|
|
433
|
+
if (!isStatePostBellatrix(parentState)) {
|
|
455
434
|
throw new Error("Expected Bellatrix state for execution block production");
|
|
456
435
|
}
|
|
457
436
|
|
|
@@ -480,10 +459,10 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
480
459
|
this.logger,
|
|
481
460
|
fork,
|
|
482
461
|
parentBlockRoot,
|
|
483
|
-
|
|
462
|
+
parentState.latestExecutionPayloadHeader.blockHash,
|
|
484
463
|
safeBlockHash,
|
|
485
464
|
finalizedBlockHash ?? ZERO_HASH_HEX,
|
|
486
|
-
|
|
465
|
+
parentState,
|
|
487
466
|
executionBuilder.issueLocalFcUWithFeeRecipient
|
|
488
467
|
);
|
|
489
468
|
}
|
|
@@ -495,7 +474,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
495
474
|
slot: blockSlot,
|
|
496
475
|
proposerPubKey: toHex(proposerPubKey),
|
|
497
476
|
});
|
|
498
|
-
const headerRes = await prepareExecutionPayloadHeader(this, fork,
|
|
477
|
+
const headerRes = await prepareExecutionPayloadHeader(this, fork, parentState, proposerPubKey);
|
|
499
478
|
|
|
500
479
|
endExecutionPayloadHeader?.({
|
|
501
480
|
step: BlockProductionStep.executionPayload,
|
|
@@ -530,7 +509,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
530
509
|
});
|
|
531
510
|
} else {
|
|
532
511
|
const headerGasLimit = builderRes.header.gasLimit;
|
|
533
|
-
const parentGasLimit =
|
|
512
|
+
const parentGasLimit = parentState.latestExecutionPayloadHeader.gasLimit;
|
|
534
513
|
const expectedGasLimit = getExpectedGasLimit(parentGasLimit, targetGasLimit);
|
|
535
514
|
|
|
536
515
|
const lowerBound = Math.min(parentGasLimit, expectedGasLimit);
|
|
@@ -584,24 +563,17 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
584
563
|
this.logger,
|
|
585
564
|
fork,
|
|
586
565
|
parentBlockRoot,
|
|
587
|
-
|
|
566
|
+
parentState.latestExecutionPayloadHeader.blockHash,
|
|
588
567
|
safeBlockHash,
|
|
589
568
|
finalizedBlockHash ?? ZERO_HASH_HEX,
|
|
590
|
-
|
|
569
|
+
parentState,
|
|
591
570
|
feeRecipient
|
|
592
571
|
);
|
|
593
572
|
|
|
594
|
-
const {prepType, payloadId} = prepareRes;
|
|
573
|
+
const {prepType, payloadId, preparedAtMs} = prepareRes;
|
|
595
574
|
Object.assign(logMeta, {executionPayloadPrepType: prepType});
|
|
596
575
|
|
|
597
|
-
|
|
598
|
-
// Wait for 500ms to allow EL to add some txs to the payload
|
|
599
|
-
// the pitfalls of this have been put forward here, but 500ms delay for block proposal
|
|
600
|
-
// seems marginal even with unhealthy network
|
|
601
|
-
//
|
|
602
|
-
// See: https://discord.com/channels/595666850260713488/892088344438255616/1009882079632314469
|
|
603
|
-
await sleep(PAYLOAD_GENERATION_TIME_MS);
|
|
604
|
-
}
|
|
576
|
+
await waitForPayloadGeneration(preparedAtMs);
|
|
605
577
|
|
|
606
578
|
this.logger.verbose("Fetching execution payload from engine", {slot: blockSlot, payloadId});
|
|
607
579
|
const payloadRes = await this.executionEngine.getPayload(fork, payloadId);
|
|
@@ -763,7 +735,7 @@ export async function prepareExecutionPayload(
|
|
|
763
735
|
suggestedFeeRecipient: string,
|
|
764
736
|
/** Attributes already computed for the same state and fee recipient, e.g. for the SSE event */
|
|
765
737
|
payloadAttributes?: PayloadAttributes
|
|
766
|
-
): Promise<{prepType: PayloadPreparationType; payloadId: PayloadId}> {
|
|
738
|
+
): Promise<{prepType: PayloadPreparationType; payloadId: PayloadId; preparedAtMs: number}> {
|
|
767
739
|
const timestamp = computeTimeAtSlot(chain.config, state.slot, state.genesisTime);
|
|
768
740
|
const prevRandao = state.getRandaoMix(state.epoch);
|
|
769
741
|
|
|
@@ -792,10 +764,11 @@ export async function prepareExecutionPayload(
|
|
|
792
764
|
// the EL returns Syncing on this request to prepare a payload
|
|
793
765
|
// TODO: Handle only this case, DO NOT put a generic try / catch that discards all errors
|
|
794
766
|
let payloadId: PayloadId | null;
|
|
767
|
+
let preparedAtMs: number;
|
|
795
768
|
let prepType: PayloadPreparationType;
|
|
796
769
|
|
|
797
770
|
if (payloadIdCached) {
|
|
798
|
-
payloadId = payloadIdCached;
|
|
771
|
+
({payloadId, preparedAtMs} = payloadIdCached);
|
|
799
772
|
prepType = PayloadPreparationType.Cached;
|
|
800
773
|
} else {
|
|
801
774
|
// If there was a payload assigned to this timestamp, it would imply that there some sort
|
|
@@ -821,6 +794,7 @@ export async function prepareExecutionPayload(
|
|
|
821
794
|
feeRecipient: suggestedFeeRecipient,
|
|
822
795
|
})
|
|
823
796
|
);
|
|
797
|
+
preparedAtMs = performance.now();
|
|
824
798
|
logger.verbose("Prepared payload id from execution engine", {payloadId});
|
|
825
799
|
}
|
|
826
800
|
|
|
@@ -833,7 +807,23 @@ export async function prepareExecutionPayload(
|
|
|
833
807
|
// We are only returning payloadId here because prepareExecutionPayload is also called from
|
|
834
808
|
// prepareNextSlot, which is an advance call to execution engine to start building payload
|
|
835
809
|
// Actual payload isn't produced till getPayload is called.
|
|
836
|
-
return {payloadId, prepType};
|
|
810
|
+
return {payloadId, prepType, preparedAtMs};
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
* Give the engine PAYLOAD_GENERATION_TIME_MS since the payload was requested before fetching it. A payload prepared
|
|
815
|
+
* in advance usually had seconds, one prepared or re-prepared right before the slot gets the same time as a fresh one.
|
|
816
|
+
*
|
|
817
|
+
* The pitfalls of this delay have been put forward here, but 500ms delay for block proposal
|
|
818
|
+
* seems marginal even with unhealthy network
|
|
819
|
+
*
|
|
820
|
+
* See: https://discord.com/channels/595666850260713488/892088344438255616/1009882079632314469
|
|
821
|
+
*/
|
|
822
|
+
async function waitForPayloadGeneration(preparedAtMs: number): Promise<void> {
|
|
823
|
+
const remainingMs = PAYLOAD_GENERATION_TIME_MS - (performance.now() - preparedAtMs);
|
|
824
|
+
if (remainingMs > 0) {
|
|
825
|
+
await sleep(remainingMs);
|
|
826
|
+
}
|
|
837
827
|
}
|
|
838
828
|
|
|
839
829
|
async function prepareExecutionPayloadHeader(
|
|
@@ -1102,8 +1092,7 @@ export function getPooledProposerPreferences(
|
|
|
1102
1092
|
export async function produceCommonBlockBody<T extends BlockType>(
|
|
1103
1093
|
this: BeaconChain,
|
|
1104
1094
|
blockType: T,
|
|
1105
|
-
|
|
1106
|
-
{randaoReveal, graffiti, slot, parentBlock}: BlockAttributes
|
|
1095
|
+
{randaoReveal, graffiti, slot, parentBlock, parentStateWithPayload}: BlockAttributes
|
|
1107
1096
|
): Promise<CommonBlockBody> {
|
|
1108
1097
|
const stepsMetrics =
|
|
1109
1098
|
blockType === BlockType.Full
|
|
@@ -1124,7 +1113,7 @@ export async function produceCommonBlockBody<T extends BlockType>(
|
|
|
1124
1113
|
// }
|
|
1125
1114
|
// }
|
|
1126
1115
|
const [attesterSlashings, proposerSlashings, voluntaryExits, blsToExecutionChanges] =
|
|
1127
|
-
this.opPool.getSlashingsAndExits(
|
|
1116
|
+
this.opPool.getSlashingsAndExits(parentStateWithPayload, blockType, this.metrics);
|
|
1128
1117
|
|
|
1129
1118
|
const endAttestations = stepsMetrics?.startTimer();
|
|
1130
1119
|
// TODO: extract to a separate BeaconChain method to coordinate the 2 op-pools
|
|
@@ -1132,7 +1121,7 @@ export async function produceCommonBlockBody<T extends BlockType>(
|
|
|
1132
1121
|
fork,
|
|
1133
1122
|
this.forkChoice,
|
|
1134
1123
|
this.shufflingCache,
|
|
1135
|
-
|
|
1124
|
+
parentStateWithPayload,
|
|
1136
1125
|
this.singleAttestationPool
|
|
1137
1126
|
);
|
|
1138
1127
|
endAttestations?.({
|
|
@@ -1163,7 +1152,7 @@ export async function produceCommonBlockBody<T extends BlockType>(
|
|
|
1163
1152
|
};
|
|
1164
1153
|
|
|
1165
1154
|
if (!isForkPostHeze(fork)) {
|
|
1166
|
-
commonBlockBody.eth1Data =
|
|
1155
|
+
commonBlockBody.eth1Data = parentStateWithPayload.eth1Data;
|
|
1167
1156
|
commonBlockBody.deposits = [];
|
|
1168
1157
|
}
|
|
1169
1158
|
|
|
@@ -22,7 +22,7 @@ import {MapDef} from "@lodestar/utils";
|
|
|
22
22
|
//
|
|
23
23
|
// Assuming we're at epoch 99 while all other nodes at epoch 100, they all accept attestations at epoch 99, 100.
|
|
24
24
|
// If MAX_RETAINED_EPOCH = 2 then lowestPermissibleEpoch is 97 which is more than enough
|
|
25
|
-
const EPOCH_LOOKBACK_LIMIT = 2;
|
|
25
|
+
export const EPOCH_LOOKBACK_LIMIT = 2;
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Keeps a cache to filter unaggregated attestations from the same validator in the same epoch.
|
|
@@ -1,18 +1,60 @@
|
|
|
1
1
|
import {Epoch, ValidatorIndex} from "@lodestar/types";
|
|
2
|
-
import {
|
|
3
|
-
// TODO abstract out the Seen* caches into an abstract abstract data structure
|
|
4
|
-
// that all the caches can extend since they share similar structure.
|
|
2
|
+
import {EPOCH_LOOKBACK_LIMIT} from "./seenAttesters.js";
|
|
5
3
|
|
|
6
|
-
|
|
4
|
+
/** A bitset per epoch, block import adds tens of thousands of indices per block on the main thread */
|
|
5
|
+
export class SeenBlockAttesters {
|
|
6
|
+
private readonly bitsByEpoch = new Map<Epoch, Uint8Array>();
|
|
7
|
+
private lowestPermissibleEpoch: Epoch = 0;
|
|
8
|
+
private byteLength = 0;
|
|
9
|
+
|
|
10
|
+
isKnown(epoch: Epoch, validatorIndex: ValidatorIndex): boolean {
|
|
11
|
+
const bits = this.bitsByEpoch.get(epoch);
|
|
12
|
+
// The index comes from API requests, the bitwise operators below would truncate it and alias a tracked index
|
|
13
|
+
if (
|
|
14
|
+
bits === undefined ||
|
|
15
|
+
!Number.isInteger(validatorIndex) ||
|
|
16
|
+
validatorIndex < 0 ||
|
|
17
|
+
validatorIndex >= bits.length * 8
|
|
18
|
+
) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
// Validator i is bit (i % 8) of byte floor(i / 8): `>>> 3` picks the byte, `& 7` the bit inside it
|
|
22
|
+
return (bits[validatorIndex >>> 3] & (1 << (validatorIndex & 7))) !== 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** `validatorIndexes` must be indices of the validator registry */
|
|
7
26
|
addIndices(epoch: Epoch, validatorIndexes: ValidatorIndex[]): void {
|
|
8
27
|
if (epoch < this.lowestPermissibleEpoch) {
|
|
9
28
|
throw Error(`EpochTooLow ${epoch} < ${this.lowestPermissibleEpoch}`);
|
|
10
29
|
}
|
|
11
30
|
|
|
12
|
-
|
|
31
|
+
let bits = this.bitsByEpoch.get(epoch);
|
|
32
|
+
if (bits === undefined) {
|
|
33
|
+
bits = new Uint8Array(this.byteLength);
|
|
34
|
+
this.bitsByEpoch.set(epoch, bits);
|
|
35
|
+
}
|
|
13
36
|
|
|
14
37
|
for (const index of validatorIndexes) {
|
|
15
|
-
|
|
38
|
+
// floor(index / 8), the byte that holds this validator's bit
|
|
39
|
+
const byteIndex = index >>> 3;
|
|
40
|
+
if (byteIndex >= bits.length) {
|
|
41
|
+
const grown: Uint8Array = new Uint8Array(Math.max(byteIndex + 1, bits.length * 2));
|
|
42
|
+
grown.set(bits);
|
|
43
|
+
bits = grown;
|
|
44
|
+
this.bitsByEpoch.set(epoch, bits);
|
|
45
|
+
this.byteLength = Math.max(this.byteLength, bits.length);
|
|
46
|
+
}
|
|
47
|
+
// Set bit (index % 8) of that byte
|
|
48
|
+
bits[byteIndex] |= 1 << (index & 7);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
prune(currentEpoch: Epoch): void {
|
|
53
|
+
this.lowestPermissibleEpoch = Math.max(currentEpoch - EPOCH_LOOKBACK_LIMIT, 0);
|
|
54
|
+
for (const epoch of this.bitsByEpoch.keys()) {
|
|
55
|
+
if (epoch < this.lowestPermissibleEpoch) {
|
|
56
|
+
this.bitsByEpoch.delete(epoch);
|
|
57
|
+
}
|
|
16
58
|
}
|
|
17
59
|
}
|
|
18
60
|
}
|
|
@@ -6,38 +6,58 @@ import {MapDef} from "@lodestar/utils";
|
|
|
6
6
|
*/
|
|
7
7
|
const SLOTS_RETAINED = 2;
|
|
8
8
|
|
|
9
|
+
export type SeenBuilderBids = {
|
|
10
|
+
/** Number of valid bids seen */
|
|
11
|
+
count: number;
|
|
12
|
+
/**
|
|
13
|
+
* The builder's bid limit. Bids for the same slot and parent root are validated against the same state,
|
|
14
|
+
* so it is known without the state once a bid was valid
|
|
15
|
+
*/
|
|
16
|
+
limit: number;
|
|
17
|
+
};
|
|
18
|
+
|
|
9
19
|
/**
|
|
10
|
-
*
|
|
20
|
+
* Counts the valid execution payload bids seen per
|
|
11
21
|
* (slot, builder, parent block hash, parent block root).
|
|
12
22
|
*/
|
|
13
23
|
export class SeenExecutionPayloadBids {
|
|
14
|
-
private readonly
|
|
15
|
-
() => new MapDef<BuilderIndex,
|
|
24
|
+
private readonly bidsByBranchByBuilderBySlot = new MapDef<Slot, MapDef<BuilderIndex, Map<string, SeenBuilderBids>>>(
|
|
25
|
+
() => new MapDef<BuilderIndex, Map<string, SeenBuilderBids>>(() => new Map<string, SeenBuilderBids>())
|
|
16
26
|
);
|
|
17
27
|
private lowestPermissibleSlot: Slot = 0;
|
|
18
28
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
get(
|
|
30
|
+
slot: Slot,
|
|
31
|
+
builderIndex: BuilderIndex,
|
|
32
|
+
parentBlockHash: RootHex,
|
|
33
|
+
parentBlockRoot: RootHex
|
|
34
|
+
): SeenBuilderBids | undefined {
|
|
35
|
+
return this.bidsByBranchByBuilderBySlot
|
|
36
|
+
.get(slot)
|
|
37
|
+
?.get(builderIndex)
|
|
38
|
+
?.get(branchKey(parentBlockHash, parentBlockRoot));
|
|
24
39
|
}
|
|
25
40
|
|
|
26
|
-
add(
|
|
41
|
+
add(
|
|
42
|
+
slot: Slot,
|
|
43
|
+
builderIndex: BuilderIndex,
|
|
44
|
+
parentBlockHash: RootHex,
|
|
45
|
+
parentBlockRoot: RootHex,
|
|
46
|
+
bidLimit: number
|
|
47
|
+
): void {
|
|
27
48
|
if (slot < this.lowestPermissibleSlot) {
|
|
28
49
|
throw Error(`slot ${slot} < lowestPermissibleSlot ${this.lowestPermissibleSlot}`);
|
|
29
50
|
}
|
|
30
|
-
this.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
.add(branchKey(parentBlockHash, parentBlockRoot));
|
|
51
|
+
const bidsByBranch = this.bidsByBranchByBuilderBySlot.getOrDefault(slot).getOrDefault(builderIndex);
|
|
52
|
+
const key = branchKey(parentBlockHash, parentBlockRoot);
|
|
53
|
+
bidsByBranch.set(key, {count: (bidsByBranch.get(key)?.count ?? 0) + 1, limit: bidLimit});
|
|
34
54
|
}
|
|
35
55
|
|
|
36
56
|
prune(currentSlot: Slot): void {
|
|
37
57
|
this.lowestPermissibleSlot = Math.max(currentSlot - SLOTS_RETAINED, 0);
|
|
38
|
-
for (const slot of this.
|
|
58
|
+
for (const slot of this.bidsByBranchByBuilderBySlot.keys()) {
|
|
39
59
|
if (slot < this.lowestPermissibleSlot) {
|
|
40
|
-
this.
|
|
60
|
+
this.bidsByBranchByBuilderBySlot.delete(slot);
|
|
41
61
|
}
|
|
42
62
|
}
|
|
43
63
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {ExecutionStatus, PayloadStatus} from "@lodestar/fork-choice";
|
|
1
2
|
import {ForkName, ForkSeq} from "@lodestar/params";
|
|
2
3
|
import {
|
|
3
4
|
ISignatureSet,
|
|
@@ -100,15 +101,29 @@ async function validateAggregateAndProof(
|
|
|
100
101
|
// (a client MAY queue attestations for processing until the payload is imported and SHOULD
|
|
101
102
|
// request the payload envelope via `ExecutionPayloadEnvelopesByRoot` using
|
|
102
103
|
// `aggregate.data.beacon_block_root`).
|
|
103
|
-
if (
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
104
|
+
if (block !== null && attData.index === 1) {
|
|
105
|
+
const beaconBlockRoot = toRootHex(attData.beaconBlockRoot);
|
|
106
|
+
const fullBlock = chain.forkChoice.getBlockHex(beaconBlockRoot, PayloadStatus.FULL);
|
|
107
|
+
if (fullBlock === null) {
|
|
108
|
+
throw new AttestationError(GossipAction.IGNORE, {
|
|
109
|
+
code: AttestationErrorCode.EXECUTION_PAYLOAD_NOT_SEEN,
|
|
110
|
+
beaconBlockRoot,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
// [IGNORE] The attested execution payload is optimistic
|
|
114
|
+
if (fullBlock.executionStatus === ExecutionStatus.Syncing) {
|
|
115
|
+
throw new AttestationError(GossipAction.IGNORE, {
|
|
116
|
+
code: AttestationErrorCode.EXECUTION_PAYLOAD_OPTIMISTIC,
|
|
117
|
+
beaconBlockRoot,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
// [REJECT] The attested execution payload is processed and invalid
|
|
121
|
+
if (fullBlock.executionStatus === ExecutionStatus.Invalid) {
|
|
122
|
+
throw new AttestationError(GossipAction.REJECT, {
|
|
123
|
+
code: AttestationErrorCode.EXECUTION_PAYLOAD_INVALID,
|
|
124
|
+
beaconBlockRoot,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
112
127
|
}
|
|
113
128
|
|
|
114
129
|
// [REJECT] len(committee_indices) == 1, where committee_indices = get_committee_indices(aggregate)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {BitArray} from "@chainsafe/ssz";
|
|
2
2
|
import {BeaconConfig} from "@lodestar/config";
|
|
3
|
-
import {ProtoBlock} from "@lodestar/fork-choice";
|
|
3
|
+
import {ExecutionStatus, PayloadStatus, ProtoBlock} from "@lodestar/fork-choice";
|
|
4
4
|
import {
|
|
5
5
|
ATTESTATION_SUBNET_COUNT,
|
|
6
6
|
DOMAIN_BEACON_ATTESTER,
|
|
@@ -309,25 +309,6 @@ async function validateAttestationNoSignatureCheck(
|
|
|
309
309
|
code: AttestationErrorCode.PREMATURELY_INDICATED_PAYLOAD_PRESENT,
|
|
310
310
|
});
|
|
311
311
|
}
|
|
312
|
-
|
|
313
|
-
// [REJECT] If `attestation.data.index == 1` (payload present for a past block),
|
|
314
|
-
// the execution payload for `block` passes validation.
|
|
315
|
-
// [IGNORE] When `attestation.data.index == 1` (payload present for a past block),
|
|
316
|
-
// the execution payload for `block` has been fully imported, including its data -- i.e.
|
|
317
|
-
// `is_payload_verified(store, attestation.data.beacon_block_root)` returns `True`
|
|
318
|
-
// (a client MAY queue attestations for processing until the payload is imported and
|
|
319
|
-
// SHOULD request the payload envelope via `ExecutionPayloadEnvelopesByRoot` using
|
|
320
|
-
// `attestation.data.beacon_block_root`).
|
|
321
|
-
if (
|
|
322
|
-
block !== null &&
|
|
323
|
-
attData.index === 1 &&
|
|
324
|
-
!chain.forkChoice.hasPayloadHexUnsafe(toRootHex(attData.beaconBlockRoot))
|
|
325
|
-
) {
|
|
326
|
-
throw new AttestationError(GossipAction.IGNORE, {
|
|
327
|
-
code: AttestationErrorCode.EXECUTION_PAYLOAD_NOT_SEEN,
|
|
328
|
-
beaconBlockRoot: toRootHex(attData.beaconBlockRoot),
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
312
|
} else {
|
|
332
313
|
// [REJECT] attestation.data.index == 0
|
|
333
314
|
if (attData.index !== 0) {
|
|
@@ -343,6 +324,36 @@ async function validateAttestationNoSignatureCheck(
|
|
|
343
324
|
committeeIndex = attestationOrCache.cache.committeeIndex;
|
|
344
325
|
}
|
|
345
326
|
|
|
327
|
+
// The payload status can change after the attestation data was cached, so this runs for cached data too
|
|
328
|
+
if (isForkPostGloas(fork) && attData.index === 1) {
|
|
329
|
+
const beaconBlockRoot = toRootHex(attData.beaconBlockRoot);
|
|
330
|
+
const fullBlock = chain.forkChoice.getBlockHex(beaconBlockRoot, PayloadStatus.FULL);
|
|
331
|
+
// [IGNORE] The corresponding execution payload envelope has been seen and verified
|
|
332
|
+
// (a client MAY queue attestations for processing until the payload is imported and
|
|
333
|
+
// SHOULD request the payload envelope via `ExecutionPayloadEnvelopesByRoot`).
|
|
334
|
+
// An unknown block is handled by `verifyHeadBlockAndTargetRoot`
|
|
335
|
+
if (fullBlock === null) {
|
|
336
|
+
if (chain.forkChoice.hasBlockHexUnsafe(beaconBlockRoot)) {
|
|
337
|
+
throw new AttestationError(GossipAction.IGNORE, {
|
|
338
|
+
code: AttestationErrorCode.EXECUTION_PAYLOAD_NOT_SEEN,
|
|
339
|
+
beaconBlockRoot,
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
} else if (fullBlock.executionStatus === ExecutionStatus.Syncing) {
|
|
343
|
+
// [IGNORE] The attested execution payload is optimistic
|
|
344
|
+
throw new AttestationError(GossipAction.IGNORE, {
|
|
345
|
+
code: AttestationErrorCode.EXECUTION_PAYLOAD_OPTIMISTIC,
|
|
346
|
+
beaconBlockRoot,
|
|
347
|
+
});
|
|
348
|
+
} else if (fullBlock.executionStatus === ExecutionStatus.Invalid) {
|
|
349
|
+
// [REJECT] The attested execution payload is processed and invalid
|
|
350
|
+
throw new AttestationError(GossipAction.REJECT, {
|
|
351
|
+
code: AttestationErrorCode.EXECUTION_PAYLOAD_INVALID,
|
|
352
|
+
beaconBlockRoot,
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
346
357
|
chain.metrics?.gossipAttestation.attestationSlotToClockSlot.observe(
|
|
347
358
|
{caller: RegenCaller.validateGossipAttestation},
|
|
348
359
|
chain.clock.currentSlot - attSlot
|
|
@@ -61,8 +61,10 @@ export async function validateAttesterSlashing(
|
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
const
|
|
64
|
+
// Head state may lag behind a fork transition, verify against the fork of the clock slot
|
|
65
|
+
const currentSlot = chain.clock.currentSlot;
|
|
66
|
+
const signatureSets = getAttesterSlashingSignatureSets(chain.config, currentSlot, attesterSlashing);
|
|
67
|
+
const verifiedDomains = getAttesterSlashingSignatureDomains(chain.config, currentSlot, attesterSlashing);
|
|
66
68
|
if (!(await chain.bls.verifySignatureSets(signatureSets, {batchable: true, priority: prioritizeBls}))) {
|
|
67
69
|
throw new AttesterSlashingError(GossipAction.REJECT, {
|
|
68
70
|
code: AttesterSlashingErrorCode.INVALID_SIGNATURE,
|
|
@@ -121,13 +121,21 @@ export async function validateGossipBlock(
|
|
|
121
121
|
// (via gossip or non-gossip sources) (a client MAY queue blocks for processing once the parent payload is retrieved).
|
|
122
122
|
if (isGloasBeaconBlock(block)) {
|
|
123
123
|
const parentBlockHashHex = toRootHex(block.body.signedExecutionPayloadBid.message.parentBlockHash);
|
|
124
|
-
|
|
124
|
+
const parentPayloadBlock = chain.forkChoice.getBlockHexAndBlockHash(parentRoot, parentBlockHashHex);
|
|
125
|
+
if (parentPayloadBlock === null) {
|
|
125
126
|
throw new BlockGossipError(GossipAction.IGNORE, {
|
|
126
127
|
code: BlockErrorCode.PARENT_PAYLOAD_UNKNOWN,
|
|
127
128
|
parentRoot,
|
|
128
129
|
parentBlockHash: parentBlockHashHex,
|
|
129
130
|
});
|
|
130
131
|
}
|
|
132
|
+
// [IGNORE] The block's parent passed validation but the payload it builds on is invalid
|
|
133
|
+
if (parentPayloadBlock.executionStatus === ExecutionStatus.Invalid) {
|
|
134
|
+
throw new BlockGossipError(GossipAction.IGNORE, {
|
|
135
|
+
code: BlockErrorCode.PARENT_EXECUTION_INVALID,
|
|
136
|
+
parentRoot,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
131
139
|
}
|
|
132
140
|
|
|
133
141
|
// [REJECT] The block is from a higher slot than its parent.
|