@lodestar/beacon-node 1.52.0-dev.1f4a364fc5 → 1.52.0-dev.20cca3c9f1
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/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +15 -9
- 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/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.js +0 -1
- package/lib/chain/blocks/index.js.map +1 -1
- package/lib/chain/chain.d.ts +3 -2
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +30 -7
- 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 +6 -1
- package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadBid.js +1 -0
- package/lib/chain/errors/executionPayloadBid.js.map +1 -1
- package/lib/chain/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/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/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 +1 -0
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +23 -15
- 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/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/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 +17 -2
- 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/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/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/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/network.d.ts.map +1 -1
- package/lib/network/network.js +6 -1
- 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 +15 -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/sync/range/batch.d.ts +6 -0
- package/lib/sync/range/batch.d.ts.map +1 -1
- package/lib/sync/range/batch.js +17 -0
- package/lib/sync/range/batch.js.map +1 -1
- package/lib/sync/range/chain.d.ts.map +1 -1
- package/lib/sync/range/chain.js +8 -1
- 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 +43 -3
- package/lib/sync/range/range.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 +338 -26
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/downloadByRange.d.ts +14 -1
- package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRange.js +12 -2
- 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/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/validator/index.ts +17 -10
- package/src/chain/ColumnReconstructionTracker.ts +5 -0
- package/src/chain/archiveStore/historicalState/getHistoricalState.ts +9 -0
- package/src/chain/archiveStore/utils/pruneHistory.ts +9 -4
- package/src/chain/blocks/importExecutionPayload.ts +9 -2
- package/src/chain/blocks/index.ts +0 -1
- package/src/chain/chain.ts +35 -8
- package/src/chain/errors/attestationError.ts +11 -1
- package/src/chain/errors/executionPayloadBid.ts +6 -0
- package/src/chain/errors/executionPayloadEnvelope.ts +58 -0
- package/src/chain/lightClient/index.ts +108 -142
- package/src/chain/prepareNextSlot.ts +347 -89
- package/src/chain/produceBlock/produceBlockBody.ts +25 -16
- package/src/chain/seenCache/seenAttesters.ts +1 -1
- package/src/chain/seenCache/seenBlockAttesters.ts +48 -6
- package/src/chain/validation/aggregateAndProof.ts +24 -9
- package/src/chain/validation/attestation.ts +31 -20
- package/src/chain/validation/block.ts +9 -1
- package/src/chain/validation/executionPayloadBid.ts +20 -2
- package/src/chain/validation/executionPayloadEnvelope.ts +115 -8
- package/src/chain/validation/payloadAttestationMessage.ts +10 -0
- package/src/chain/validation/voluntaryExit.ts +44 -6
- 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/gossip/gossipsub.ts +6 -2
- package/src/network/network.ts +6 -2
- package/src/network/peers/peerManager.ts +26 -2
- package/src/network/peers/utils/prioritizePeers.ts +14 -1
- package/src/network/processor/gossipHandlers.ts +15 -7
- package/src/network/processor/index.ts +7 -2
- package/src/sync/range/batch.ts +20 -0
- package/src/sync/range/chain.ts +8 -0
- package/src/sync/range/range.ts +56 -3
- package/src/sync/types.ts +13 -0
- package/src/sync/unknownBlock.ts +387 -28
- package/src/sync/utils/downloadByRange.ts +29 -3
- package/src/sync/utils/downloadByRoot.ts +75 -7
- package/src/util/eventLoop.ts +3 -3
|
@@ -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
|
|
@@ -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.
|
|
@@ -19,8 +19,9 @@ import {RegenCaller} from "../regen/index.js";
|
|
|
19
19
|
/**
|
|
20
20
|
* Check whether a bid builds on one of the paths compatible with the local head branch.
|
|
21
21
|
*
|
|
22
|
-
* Building directly on the parent is allowed for
|
|
23
|
-
*
|
|
22
|
+
* Building directly on the parent is allowed for the slot after the head if the head was late or
|
|
23
|
+
* its proposer equivocated, the conditions under which a proposer may re-org the head. At epoch
|
|
24
|
+
* boundaries the parent must also be the predicted proposer head.
|
|
24
25
|
* Otherwise the bid must build on the local head's full or empty payload variant, as selected for its slot.
|
|
25
26
|
*/
|
|
26
27
|
function isBidCompatibleWithHead(
|
|
@@ -34,6 +35,11 @@ function isBidCompatibleWithHead(
|
|
|
34
35
|
const buildsOnParentPayload = bidParentBlockHash === head.parentBlockHash;
|
|
35
36
|
|
|
36
37
|
if (buildsOnParentBlock && buildsOnParentPayload) {
|
|
38
|
+
const bidSlotOk = head.slot + 1 === bidSlot;
|
|
39
|
+
const headLate = !head.timeliness;
|
|
40
|
+
if (!bidSlotOk || !(headLate || chain.forkChoice.isProposerEquivocation(head))) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
37
43
|
if (!isStartSlotOfEpoch(bidSlot)) {
|
|
38
44
|
return true;
|
|
39
45
|
}
|
|
@@ -114,6 +120,18 @@ async function validateExecutionPayloadBid(
|
|
|
114
120
|
});
|
|
115
121
|
}
|
|
116
122
|
|
|
123
|
+
// [IGNORE] The bid is received after the payload attestation deadline of `bid.slot - 1`
|
|
124
|
+
if (
|
|
125
|
+
chain.clock.msFromSlot(bid.slot - 1) <
|
|
126
|
+
chain.config.getPayloadAttestationDueMs(chain.config.getForkName(bid.slot - 1))
|
|
127
|
+
) {
|
|
128
|
+
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
129
|
+
code: ExecutionPayloadBidErrorCode.BEFORE_PAYLOAD_ATTESTATION_DEADLINE,
|
|
130
|
+
builderIndex: bid.builderIndex,
|
|
131
|
+
slot: bid.slot,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
117
135
|
// [IGNORE] The bid is received after the inclusion list deadline of `bid.slot - 1`
|
|
118
136
|
if (
|
|
119
137
|
isForkPostHeze(chain.config.getForkName(bid.slot)) &&
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {PayloadStatus, ProtoBlock} from "@lodestar/fork-choice";
|
|
2
2
|
import {
|
|
3
3
|
computeStartSlotAtEpoch,
|
|
4
|
+
computeTimeAtSlot,
|
|
4
5
|
getExecutionPayloadEnvelopeSignatureSet,
|
|
5
6
|
isStatePostGloas,
|
|
6
7
|
} from "@lodestar/state-transition";
|
|
7
8
|
import {gloas, ssz} from "@lodestar/types";
|
|
8
9
|
import {byteArrayEquals, toRootHex} from "@lodestar/utils";
|
|
10
|
+
import {computeExecutionBlockHash} from "../../execution/engine/blockHash.js";
|
|
9
11
|
import {
|
|
10
12
|
getBeaconBlockRootFromExecutionPayloadEnvelopeSerialized,
|
|
11
13
|
getSlotFromExecutionPayloadEnvelopeSerialized,
|
|
@@ -54,7 +56,7 @@ export function validateGossipExecutionPayloadEnvelopeSerialized(
|
|
|
54
56
|
|
|
55
57
|
const maxTransactionCount = getMaxTransactionCount(chain, block, payloadInput);
|
|
56
58
|
if (BigInt(transactionCount) > maxTransactionCount) {
|
|
57
|
-
throw new ExecutionPayloadEnvelopeError(GossipAction.
|
|
59
|
+
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
58
60
|
code: ExecutionPayloadEnvelopeErrorCode.TOO_MANY_TRANSACTIONS,
|
|
59
61
|
slot,
|
|
60
62
|
root: blockRootHex,
|
|
@@ -129,6 +131,17 @@ async function validateExecutionPayloadEnvelope(
|
|
|
129
131
|
});
|
|
130
132
|
}
|
|
131
133
|
|
|
134
|
+
// [REJECT] `envelope.parent_beacon_block_root == block.parent_root`
|
|
135
|
+
if (toRootHex(envelope.parentBeaconBlockRoot) !== block.parentRoot) {
|
|
136
|
+
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
137
|
+
code: ExecutionPayloadEnvelopeErrorCode.PARENT_BEACON_BLOCK_ROOT_MISMATCH,
|
|
138
|
+
slot: payload.slotNumber,
|
|
139
|
+
root: blockRootHex,
|
|
140
|
+
envelopeParentBeaconBlockRoot: toRootHex(envelope.parentBeaconBlockRoot),
|
|
141
|
+
blockParentRoot: block.parentRoot,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
132
145
|
// [REJECT] `envelope.builder_index == bid.builder_index`
|
|
133
146
|
if (envelope.builderIndex !== payloadInput.getBuilderIndex()) {
|
|
134
147
|
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
@@ -140,6 +153,30 @@ async function validateExecutionPayloadEnvelope(
|
|
|
140
153
|
});
|
|
141
154
|
}
|
|
142
155
|
|
|
156
|
+
const bid = payloadInput.getBid();
|
|
157
|
+
|
|
158
|
+
// [REJECT] `payload.prev_randao == bid.prev_randao`
|
|
159
|
+
if (!byteArrayEquals(payload.prevRandao, bid.prevRandao)) {
|
|
160
|
+
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
161
|
+
code: ExecutionPayloadEnvelopeErrorCode.PREV_RANDAO_MISMATCH,
|
|
162
|
+
slot: payload.slotNumber,
|
|
163
|
+
root: blockRootHex,
|
|
164
|
+
envelopePrevRandao: toRootHex(payload.prevRandao),
|
|
165
|
+
bidPrevRandao: toRootHex(bid.prevRandao),
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// [REJECT] `payload.gas_limit == bid.gas_limit`
|
|
170
|
+
if (BigInt(payload.gasLimit) !== bid.gasLimit) {
|
|
171
|
+
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
172
|
+
code: ExecutionPayloadEnvelopeErrorCode.GAS_LIMIT_MISMATCH,
|
|
173
|
+
slot: payload.slotNumber,
|
|
174
|
+
root: blockRootHex,
|
|
175
|
+
envelopeGasLimit: payload.gasLimit,
|
|
176
|
+
bidGasLimit: bid.gasLimit,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
143
180
|
// [REJECT] `payload.block_hash == bid.block_hash`
|
|
144
181
|
if (toRootHex(payload.blockHash) !== payloadInput.getBlockHashHex()) {
|
|
145
182
|
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
@@ -153,22 +190,23 @@ async function validateExecutionPayloadEnvelope(
|
|
|
153
190
|
|
|
154
191
|
// [REJECT] `hash_tree_root(envelope.execution_requests) == bid.execution_requests_root`
|
|
155
192
|
const requestsRoot = ssz.gloas.ExecutionRequests.hashTreeRoot(envelope.executionRequests);
|
|
156
|
-
if (!byteArrayEquals(requestsRoot,
|
|
193
|
+
if (!byteArrayEquals(requestsRoot, bid.executionRequestsRoot)) {
|
|
157
194
|
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
158
195
|
code: ExecutionPayloadEnvelopeErrorCode.EXECUTION_REQUESTS_ROOT_MISMATCH,
|
|
159
196
|
slot: payload.slotNumber,
|
|
160
197
|
root: blockRootHex,
|
|
161
198
|
envelopeRequestsRoot: toRootHex(requestsRoot),
|
|
162
|
-
bidRequestsRoot: toRootHex(
|
|
199
|
+
bidRequestsRoot: toRootHex(bid.executionRequestsRoot),
|
|
163
200
|
});
|
|
164
201
|
}
|
|
165
202
|
|
|
166
|
-
//
|
|
167
|
-
|
|
168
|
-
//
|
|
203
|
+
// Execution request and withdrawal count limits are enforced by the SSZ list limits on decode
|
|
204
|
+
|
|
205
|
+
// [REJECT] The number of transactions is within the limit implied by the parent payload's gas limit,
|
|
206
|
+
// also checked before deserialization in validateGossipExecutionPayloadEnvelopeSerialized
|
|
169
207
|
const maxTransactionCount = getMaxTransactionCount(chain, block, payloadInput);
|
|
170
208
|
if (BigInt(payload.transactions.length) > maxTransactionCount) {
|
|
171
|
-
throw new ExecutionPayloadEnvelopeError(GossipAction.
|
|
209
|
+
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
172
210
|
code: ExecutionPayloadEnvelopeErrorCode.TOO_MANY_TRANSACTIONS,
|
|
173
211
|
slot: payload.slotNumber,
|
|
174
212
|
root: blockRootHex,
|
|
@@ -177,7 +215,7 @@ async function validateExecutionPayloadEnvelope(
|
|
|
177
215
|
});
|
|
178
216
|
}
|
|
179
217
|
|
|
180
|
-
// Get the block state to verify the builder's signature.
|
|
218
|
+
// Get the block state to verify the payload against it and the builder's signature.
|
|
181
219
|
const blockState = await chain.regen
|
|
182
220
|
.getState(block.stateRoot, RegenCaller.validateGossipPayloadEnvelope)
|
|
183
221
|
.catch(() => {
|
|
@@ -191,6 +229,75 @@ async function validateExecutionPayloadEnvelope(
|
|
|
191
229
|
throw new Error(`Expected gloas+ state for execution payload envelope validation, got fork=${blockState.forkName}`);
|
|
192
230
|
}
|
|
193
231
|
|
|
232
|
+
// [REJECT] `payload.parent_hash == state.latest_block_hash`
|
|
233
|
+
if (!byteArrayEquals(payload.parentHash, blockState.latestBlockHash)) {
|
|
234
|
+
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
235
|
+
code: ExecutionPayloadEnvelopeErrorCode.PARENT_HASH_MISMATCH,
|
|
236
|
+
slot: payload.slotNumber,
|
|
237
|
+
root: blockRootHex,
|
|
238
|
+
envelopeParentHash: toRootHex(payload.parentHash),
|
|
239
|
+
latestBlockHash: toRootHex(blockState.latestBlockHash),
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// [REJECT] `payload.timestamp == compute_time_at_slot(state.genesis_time, block.slot)`
|
|
244
|
+
const expectedTimestamp = computeTimeAtSlot(chain.config, block.slot, blockState.genesisTime);
|
|
245
|
+
if (payload.timestamp !== expectedTimestamp) {
|
|
246
|
+
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
247
|
+
code: ExecutionPayloadEnvelopeErrorCode.INCORRECT_TIMESTAMP,
|
|
248
|
+
slot: payload.slotNumber,
|
|
249
|
+
root: blockRootHex,
|
|
250
|
+
envelopeTimestamp: payload.timestamp,
|
|
251
|
+
expectedTimestamp,
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// [REJECT] The payload contains no empty transactions
|
|
256
|
+
// An empty transaction is a deletion in the transactions trie, so trailing empty transactions would not change
|
|
257
|
+
// the block hash. The EL rejects such a payload, as `verify_and_notify_new_payload` does before hashing.
|
|
258
|
+
for (let i = 0; i < payload.transactions.length; i++) {
|
|
259
|
+
if (payload.transactions.getSize(i) === 0) {
|
|
260
|
+
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
261
|
+
code: ExecutionPayloadEnvelopeErrorCode.EMPTY_TRANSACTION,
|
|
262
|
+
slot: payload.slotNumber,
|
|
263
|
+
root: blockRootHex,
|
|
264
|
+
transactionIndex: i,
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// [REJECT] `hash_tree_root(payload.withdrawals) == hash_tree_root(state.payload_expected_withdrawals)`
|
|
270
|
+
const withdrawalsRoot = ssz.gloas.Withdrawals.hashTreeRoot(payload.withdrawals);
|
|
271
|
+
const expectedWithdrawalsRoot = ssz.gloas.Withdrawals.hashTreeRoot(blockState.payloadExpectedWithdrawals);
|
|
272
|
+
if (!byteArrayEquals(withdrawalsRoot, expectedWithdrawalsRoot)) {
|
|
273
|
+
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
274
|
+
code: ExecutionPayloadEnvelopeErrorCode.WITHDRAWALS_MISMATCH,
|
|
275
|
+
slot: payload.slotNumber,
|
|
276
|
+
root: blockRootHex,
|
|
277
|
+
envelopeWithdrawalsRoot: toRootHex(withdrawalsRoot),
|
|
278
|
+
expectedWithdrawalsRoot: toRootHex(expectedWithdrawalsRoot),
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// [REJECT] The payload's block hash is computed correctly
|
|
283
|
+
const timer = chain.metrics?.gossipExecutionPayloadEnvelope.blockHashTime.startTimer();
|
|
284
|
+
const computedBlockHash = computeExecutionBlockHash(
|
|
285
|
+
blockState.forkName,
|
|
286
|
+
payload,
|
|
287
|
+
envelope.parentBeaconBlockRoot,
|
|
288
|
+
envelope.executionRequests
|
|
289
|
+
);
|
|
290
|
+
timer?.();
|
|
291
|
+
if (!byteArrayEquals(computedBlockHash, payload.blockHash)) {
|
|
292
|
+
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
293
|
+
code: ExecutionPayloadEnvelopeErrorCode.INVALID_BLOCK_HASH,
|
|
294
|
+
slot: payload.slotNumber,
|
|
295
|
+
root: blockRootHex,
|
|
296
|
+
blockHash: toRootHex(payload.blockHash),
|
|
297
|
+
computedBlockHash: toRootHex(computedBlockHash),
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
|
|
194
301
|
// [REJECT] `signed_execution_payload_envelope.signature` is valid as verified
|
|
195
302
|
// by `verify_execution_payload_envelope_signature`.
|
|
196
303
|
const signatureSet = getExecutionPayloadEnvelopeSignatureSet(
|
|
@@ -131,6 +131,16 @@ async function validatePayloadAttestationMessage(
|
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
// Re-check after the await: concurrent messages from the same validator all pass the check above
|
|
135
|
+
if (chain.seenPayloadAttesters.isKnown(data.slot, validatorIndex)) {
|
|
136
|
+
throw new PayloadAttestationError(GossipAction.IGNORE, {
|
|
137
|
+
code: PayloadAttestationErrorCode.PAYLOAD_ATTESTATION_ALREADY_KNOWN,
|
|
138
|
+
validatorIndex,
|
|
139
|
+
slot: data.slot,
|
|
140
|
+
blockRoot: toRootHex(data.beaconBlockRoot),
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
134
144
|
// Valid
|
|
135
145
|
chain.seenPayloadAttesters.add(data.slot, validatorIndex);
|
|
136
146
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {FAR_FUTURE_EPOCH} from "@lodestar/params";
|
|
2
|
+
import {VoluntaryExitValidity, computeEpochAtSlot, getVoluntaryExitSignatureSet} from "@lodestar/state-transition";
|
|
2
3
|
import {phase0} from "@lodestar/types";
|
|
3
4
|
import {
|
|
4
5
|
GossipAction,
|
|
@@ -99,19 +100,56 @@ async function validateVoluntaryExit(
|
|
|
99
100
|
// The only condition that is time sensitive and may require a non-head state is
|
|
100
101
|
// -> Validator is active && validator has not initiated exit
|
|
101
102
|
// The voluntaryExit.epoch must be in the past but the validator's status may change in recent epochs.
|
|
102
|
-
// We dial the head state to the current epoch
|
|
103
|
-
// relevant on periods of many skipped slots.
|
|
104
|
-
const state = await chain.
|
|
103
|
+
// We dial the head state to the current epoch (with a MAXIMUM_GOSSIP_CLOCK_DISPARITY allowance) to get the
|
|
104
|
+
// current status of the validator. This is relevant on periods of many skipped slots.
|
|
105
|
+
const state = await chain.getHeadStateAtEpoch(
|
|
106
|
+
computeEpochAtSlot(chain.clock.currentSlotWithGossipDisparity),
|
|
107
|
+
RegenCaller.validateGossipVoluntaryExit
|
|
108
|
+
);
|
|
105
109
|
|
|
106
|
-
// [REJECT] All of the conditions within process_voluntary_exit pass validation.
|
|
107
110
|
// verifySignature = false, verified in batch below
|
|
108
111
|
const validity = state.getVoluntaryExitValidity(voluntaryExit, false);
|
|
109
112
|
if (validity !== VoluntaryExitValidity.valid) {
|
|
110
|
-
|
|
113
|
+
let action: GossipAction;
|
|
114
|
+
switch (validity) {
|
|
115
|
+
// [IGNORE] The voluntary exit epoch is not in the future
|
|
116
|
+
case VoluntaryExitValidity.earlyEpoch:
|
|
117
|
+
// [IGNORE] The validator has not already initiated exit
|
|
118
|
+
case VoluntaryExitValidity.alreadyExited:
|
|
119
|
+
// [IGNORE] The validator has no pending partial withdrawals
|
|
120
|
+
case VoluntaryExitValidity.pendingWithdrawals:
|
|
121
|
+
action = GossipAction.IGNORE;
|
|
122
|
+
break;
|
|
123
|
+
// [REJECT] The validator index is valid
|
|
124
|
+
// [REJECT] The validator is active
|
|
125
|
+
// An exit in a future epoch or of a validator past its exit epoch can also be reported as inactive,
|
|
126
|
+
// the spec checks both conditions first and ignores the exit
|
|
127
|
+
case VoluntaryExitValidity.inactive: {
|
|
128
|
+
const {epoch, validatorIndex} = voluntaryExit.message;
|
|
129
|
+
if (epoch > state.epoch) {
|
|
130
|
+
throw new VoluntaryExitError(GossipAction.IGNORE, {code: VoluntaryExitErrorCode.EARLY_EPOCH});
|
|
131
|
+
}
|
|
132
|
+
if (
|
|
133
|
+
validatorIndex < state.validatorCount &&
|
|
134
|
+
state.getValidator(validatorIndex).exitEpoch !== FAR_FUTURE_EPOCH
|
|
135
|
+
) {
|
|
136
|
+
throw new VoluntaryExitError(GossipAction.IGNORE, {code: VoluntaryExitErrorCode.ALREADY_EXITED});
|
|
137
|
+
}
|
|
138
|
+
action = GossipAction.REJECT;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
// [REJECT] The validator has been active long enough
|
|
142
|
+
case VoluntaryExitValidity.shortTimeActive:
|
|
143
|
+
case VoluntaryExitValidity.invalidSignature:
|
|
144
|
+
action = GossipAction.REJECT;
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
throw new VoluntaryExitError(action, {
|
|
111
148
|
code: voluntaryExitValidityToErrorCode(validity),
|
|
112
149
|
});
|
|
113
150
|
}
|
|
114
151
|
|
|
152
|
+
// [REJECT] The signature is valid
|
|
115
153
|
const signatureSet = getVoluntaryExitSignatureSet(chain.config, state, voluntaryExit);
|
|
116
154
|
if (!(await chain.bls.verifySignatureSets([signatureSet], {batchable: true, priority: prioritizeBls}))) {
|
|
117
155
|
throw new VoluntaryExitError(GossipAction.REJECT, {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {computeExecutionBlockHash as computeExecutionBlockHashNative} from "@lodestar/native/execution-block-hash";
|
|
2
|
+
import {ForkPostBellatrix, ForkSeq, isForkPostElectra} from "@lodestar/params";
|
|
3
|
+
import {ExecutionPayload, ExecutionRequests, Root, sszTypesFor} from "@lodestar/types";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Compute the execution block hash of `payload`: keccak256 of the RLP-encoded execution block header,
|
|
7
|
+
* with the header fields laid out as in execution-specs for the execution fork paired with `fork`.
|
|
8
|
+
*
|
|
9
|
+
* `parentBeaconBlockRoot` is required from deneb and `executionRequests` from electra.
|
|
10
|
+
*
|
|
11
|
+
* Throws if a transaction is empty. It would be a deletion in the transactions trie and not change the hash.
|
|
12
|
+
*/
|
|
13
|
+
export function computeExecutionBlockHash(
|
|
14
|
+
fork: ForkPostBellatrix,
|
|
15
|
+
payload: ExecutionPayload,
|
|
16
|
+
parentBeaconBlockRoot: Root | null,
|
|
17
|
+
executionRequests: ExecutionRequests | null
|
|
18
|
+
): Uint8Array {
|
|
19
|
+
return computeExecutionBlockHashNative(
|
|
20
|
+
ForkSeq[fork],
|
|
21
|
+
sszTypesFor(fork).ExecutionPayload.serialize(payload),
|
|
22
|
+
parentBeaconBlockRoot ?? undefined,
|
|
23
|
+
executionRequests !== null && isForkPostElectra(fork)
|
|
24
|
+
? sszTypesFor(fork).ExecutionRequests.serialize(executionRequests)
|
|
25
|
+
: undefined
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -2,7 +2,7 @@ import {Logger} from "@lodestar/logger";
|
|
|
2
2
|
import {ForkName, ForkPostFulu, ForkSeq, SLOTS_PER_EPOCH, isForkPostBellatrix} from "@lodestar/params";
|
|
3
3
|
import {BlobsBundle, ExecutionPayload, ExecutionRequests, Root, RootHex, Wei, bellatrix} from "@lodestar/types";
|
|
4
4
|
import {BlobAndProofV2} from "@lodestar/types/fulu";
|
|
5
|
-
import {isErrorAborted} from "@lodestar/utils";
|
|
5
|
+
import {ErrorAborted, isErrorAborted} from "@lodestar/utils";
|
|
6
6
|
import {Metrics} from "../../metrics/index.js";
|
|
7
7
|
import {EPOCHS_PER_BATCH} from "../../sync/constants.js";
|
|
8
8
|
import {getLodestarClientVersion} from "../../util/metadata.js";
|
|
@@ -11,6 +11,8 @@ import {JobItemQueue} from "../../util/queue/index.js";
|
|
|
11
11
|
import {
|
|
12
12
|
ClientVersion,
|
|
13
13
|
ExecutePayloadResponse,
|
|
14
|
+
ExecutionEngineError,
|
|
15
|
+
ExecutionEngineErrorCode,
|
|
14
16
|
ExecutionEngineState,
|
|
15
17
|
ExecutionPayloadStatus,
|
|
16
18
|
ForkchoiceUpdatedResult,
|
|
@@ -334,13 +336,18 @@ export class ExecutionEngineHttp implements IExecutionEngine {
|
|
|
334
336
|
headBlockHash: RootHex,
|
|
335
337
|
safeBlockHash: RootHex,
|
|
336
338
|
finalizedBlockHash: RootHex,
|
|
337
|
-
payloadAttributes?: PayloadAttributes
|
|
339
|
+
payloadAttributes?: PayloadAttributes,
|
|
340
|
+
signal?: AbortSignal
|
|
338
341
|
): Promise<ForkchoiceUpdatedResult> {
|
|
339
|
-
const result = await this.enqueue(() =>
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
342
|
+
const result = await this.enqueue(() => {
|
|
343
|
+
// Aborted while waiting in the queue, do not select a transport and sign a request that is not sent
|
|
344
|
+
if (signal?.aborted) {
|
|
345
|
+
throw new ErrorAborted("notifyForkchoiceUpdate");
|
|
346
|
+
}
|
|
347
|
+
return this.withTransport(fork, undefined, (transport) =>
|
|
348
|
+
transport.forkchoiceUpdated(fork, headBlockHash, safeBlockHash, finalizedBlockHash, payloadAttributes, signal)
|
|
349
|
+
);
|
|
350
|
+
});
|
|
344
351
|
const {
|
|
345
352
|
payloadStatus: {status},
|
|
346
353
|
payloadId,
|
|
@@ -373,7 +380,7 @@ export class ExecutionEngineHttp implements IExecutionEngine {
|
|
|
373
380
|
case ExecutionPayloadStatus.SYNCING:
|
|
374
381
|
// Throw error on syncing if requested to produce a block, else silently ignore
|
|
375
382
|
if (payloadAttributes) {
|
|
376
|
-
throw
|
|
383
|
+
throw new ExecutionEngineError({code: ExecutionEngineErrorCode.SYNCING}, "Execution Layer Syncing");
|
|
377
384
|
}
|
|
378
385
|
return result;
|
|
379
386
|
|
|
@@ -394,7 +401,8 @@ export class ExecutionEngineHttp implements IExecutionEngine {
|
|
|
394
401
|
*/
|
|
395
402
|
async getPayload(
|
|
396
403
|
fork: ForkName,
|
|
397
|
-
payloadId: PayloadId
|
|
404
|
+
payloadId: PayloadId,
|
|
405
|
+
signal?: AbortSignal
|
|
398
406
|
): Promise<{
|
|
399
407
|
executionPayload: ExecutionPayload;
|
|
400
408
|
executionPayloadValue: Wei;
|
|
@@ -402,7 +410,7 @@ export class ExecutionEngineHttp implements IExecutionEngine {
|
|
|
402
410
|
executionRequests?: ExecutionRequests;
|
|
403
411
|
shouldOverrideBuilder?: boolean;
|
|
404
412
|
}> {
|
|
405
|
-
return this.withTransport(fork, undefined, (transport) => transport.getPayload(fork, payloadId));
|
|
413
|
+
return this.withTransport(fork, undefined, (transport) => transport.getPayload(fork, payloadId, signal));
|
|
406
414
|
}
|
|
407
415
|
|
|
408
416
|
async prunePayloadIdCache(): Promise<void> {
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
capella,
|
|
20
20
|
} from "@lodestar/types";
|
|
21
21
|
import {BlobAndProofV2} from "@lodestar/types/fulu";
|
|
22
|
+
import {LodestarError} from "@lodestar/utils";
|
|
22
23
|
import {PayloadId, PayloadIdCache, WithdrawalV1} from "./payloadIdCache.js";
|
|
23
24
|
import {ExecutionPayloadBodyV2} from "./types.js";
|
|
24
25
|
import {DATA} from "./utils.js";
|
|
@@ -131,6 +132,18 @@ export type PayloadAttributes = {
|
|
|
131
132
|
|
|
132
133
|
export type VersionedHashes = Uint8Array[];
|
|
133
134
|
|
|
135
|
+
export enum ExecutionEngineErrorCode {
|
|
136
|
+
/**
|
|
137
|
+
* `notifyForkchoiceUpdate` requested a payload while the execution client is syncing, the head block is not
|
|
138
|
+
* available to build on yet
|
|
139
|
+
*/
|
|
140
|
+
SYNCING = "EXECUTION_ENGINE_ERROR_SYNCING",
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export type ExecutionEngineErrorType = {code: ExecutionEngineErrorCode.SYNCING};
|
|
144
|
+
|
|
145
|
+
export class ExecutionEngineError extends LodestarError<ExecutionEngineErrorType> {}
|
|
146
|
+
|
|
134
147
|
/**
|
|
135
148
|
* Execution engine represents an abstract protocol to interact with execution clients. Potential transports include:
|
|
136
149
|
* - JSON RPC over network
|
|
@@ -180,14 +193,15 @@ export interface IExecutionEngine {
|
|
|
180
193
|
* Should be called in response to fork-choice head and finalized events.
|
|
181
194
|
*
|
|
182
195
|
* An INVALID verdict is returned, not thrown: the caller feeds it back into fork choice together with the
|
|
183
|
-
* `latestValidHash`. Only SYNCING while building a payload is an error
|
|
196
|
+
* `latestValidHash`. Only SYNCING while building a payload is an error, thrown as `ExecutionEngineError` with code `SYNCING`.
|
|
184
197
|
*/
|
|
185
198
|
notifyForkchoiceUpdate(
|
|
186
199
|
fork: ForkName,
|
|
187
200
|
headBlockHash: RootHex,
|
|
188
201
|
safeBlockHash: RootHex,
|
|
189
202
|
finalizedBlockHash: RootHex,
|
|
190
|
-
payloadAttributes?: PayloadAttributes
|
|
203
|
+
payloadAttributes?: PayloadAttributes,
|
|
204
|
+
signal?: AbortSignal
|
|
191
205
|
): Promise<ForkchoiceUpdatedResult>;
|
|
192
206
|
|
|
193
207
|
/**
|
|
@@ -199,7 +213,8 @@ export interface IExecutionEngine {
|
|
|
199
213
|
*/
|
|
200
214
|
getPayload(
|
|
201
215
|
fork: ForkName,
|
|
202
|
-
payloadId: PayloadId
|
|
216
|
+
payloadId: PayloadId,
|
|
217
|
+
signal?: AbortSignal
|
|
203
218
|
): Promise<{
|
|
204
219
|
executionPayload: ExecutionPayload;
|
|
205
220
|
executionPayloadValue: Wei;
|