@lodestar/beacon-node 1.52.0-dev.77088eb712 → 1.52.0-dev.8068b97a3f
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 +63 -39
- 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 +3 -1
- 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 +17 -7
- 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.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 +6 -5
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +74 -26
- 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 +3 -2
- package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadBid.js +1 -1
- package/lib/chain/errors/executionPayloadBid.js.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.d.ts +48 -0
- package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.js +7 -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/opPools/opPool.js +6 -6
- package/lib/chain/opPools/opPool.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/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 +30 -40
- 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 +79 -4
- 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/validatorMonitor.js +43 -43
- package/lib/chain/validatorMonitor.js.map +1 -1
- package/lib/network/gossip/gossipsub.js +2 -2
- package/lib/network/gossip/gossipsub.js.map +1 -1
- package/lib/network/gossip/topic.d.ts +1 -7
- package/lib/network/gossip/topic.d.ts.map +1 -1
- package/lib/network/gossip/topic.js +0 -13
- package/lib/network/gossip/topic.js.map +1 -1
- package/lib/network/network.d.ts +1 -0
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js +20 -11
- package/lib/network/network.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +19 -6
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
- package/lib/network/processor/gossipValidatorFn.js +4 -1
- package/lib/network/processor/gossipValidatorFn.js.map +1 -1
- package/lib/network/processor/index.d.ts.map +1 -1
- package/lib/network/processor/index.js +4 -2
- package/lib/network/processor/index.js.map +1 -1
- package/lib/network/reqresp/utils/collect.d.ts +4 -4
- package/lib/network/reqresp/utils/collect.d.ts.map +1 -1
- package/lib/network/reqresp/utils/collect.js +9 -8
- package/lib/network/reqresp/utils/collect.js.map +1 -1
- package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts +1 -1
- package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts.map +1 -1
- package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js +2 -2
- package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js.map +1 -1
- package/lib/sync/range/batch.d.ts +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 +12 -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 +256 -24
- 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 +43 -1
- 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 +18 -18
- package/src/api/impl/beacon/blocks/index.ts +74 -47
- package/src/api/impl/beacon/pool/index.ts +9 -7
- 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 +19 -7
- 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 +3 -31
- package/src/chain/chain.ts +107 -43
- package/src/chain/errors/attestationError.ts +11 -1
- package/src/chain/errors/executionPayloadBid.ts +3 -2
- package/src/chain/errors/executionPayloadEnvelope.ts +50 -0
- package/src/chain/interface.ts +1 -1
- package/src/chain/opPools/opPool.ts +6 -6
- 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/block.ts +9 -1
- package/src/chain/validation/executionPayloadBid.ts +40 -42
- package/src/chain/validation/executionPayloadEnvelope.ts +87 -3
- package/src/chain/validation/payloadAttestationMessage.ts +10 -0
- package/src/chain/validatorMonitor.ts +43 -43
- package/src/network/gossip/gossipsub.ts +2 -2
- package/src/network/gossip/topic.ts +1 -14
- package/src/network/network.ts +33 -11
- package/src/network/processor/gossipHandlers.ts +25 -13
- package/src/network/processor/gossipValidatorFn.ts +4 -0
- package/src/network/processor/index.ts +7 -2
- package/src/network/reqresp/utils/collect.ts +16 -8
- package/src/network/reqresp/utils/collectSequentialBlocksInRange.ts +3 -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 +11 -0
- package/src/sync/unknownBlock.ts +295 -24
- package/src/sync/utils/downloadByRange.ts +29 -3
- package/src/sync/utils/downloadByRoot.ts +68 -2
- package/src/util/eventLoop.ts +3 -3
|
@@ -290,7 +290,7 @@ export class OpPool {
|
|
|
290
290
|
const endAttesterSlashings = stepsMetrics?.startTimer();
|
|
291
291
|
const attesterSlashings: AttesterSlashing[] = [];
|
|
292
292
|
const maxAttesterSlashings = stateFork >= ForkSeq.electra ? MAX_ATTESTER_SLASHINGS_ELECTRA : MAX_ATTESTER_SLASHINGS;
|
|
293
|
-
|
|
293
|
+
for (const [key, attesterSlashing] of this.attesterSlashings) {
|
|
294
294
|
const domains = getAttesterSlashingSignatureDomains(this.config, state.slot, attesterSlashing.attesterSlashing);
|
|
295
295
|
if (!attesterSlashing.verifiedDomains.every((domain, i) => byteArrayEquals(domain, domains[i]))) {
|
|
296
296
|
this.attesterSlashings.delete(key);
|
|
@@ -300,18 +300,15 @@ export class OpPool {
|
|
|
300
300
|
const slashableIndices = new Set<ValidatorIndex>();
|
|
301
301
|
for (let i = 0; i < attesterSlashing.intersectingIndices.length; i++) {
|
|
302
302
|
const index = attesterSlashing.intersectingIndices[i];
|
|
303
|
-
//
|
|
303
|
+
// Covered by an earlier slashing in this block, the remaining indices may still be slashable
|
|
304
304
|
if (toBeSlashedIndices.has(index)) {
|
|
305
|
-
continue
|
|
305
|
+
continue;
|
|
306
306
|
}
|
|
307
307
|
|
|
308
308
|
const validator = state.getValidator(index);
|
|
309
309
|
if (isSlashableAtEpoch(validator, stateEpoch)) {
|
|
310
310
|
slashableIndices.add(index);
|
|
311
311
|
}
|
|
312
|
-
if (attesterSlashings.length >= maxAttesterSlashings) {
|
|
313
|
-
break attesterSlashing;
|
|
314
|
-
}
|
|
315
312
|
}
|
|
316
313
|
|
|
317
314
|
// If there were slashable indices in this slashing
|
|
@@ -321,6 +318,9 @@ export class OpPool {
|
|
|
321
318
|
for (const index of slashableIndices) {
|
|
322
319
|
toBeSlashedIndices.add(index);
|
|
323
320
|
}
|
|
321
|
+
if (attesterSlashings.length >= maxAttesterSlashings) {
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
326
|
endAttesterSlashings?.({
|
|
@@ -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
|
|
@@ -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.
|
|
@@ -16,33 +16,6 @@ import {ExecutionPayloadBidError, ExecutionPayloadBidErrorCode, GossipAction} fr
|
|
|
16
16
|
import {IBeaconChain} from "../index.js";
|
|
17
17
|
import {RegenCaller} from "../regen/index.js";
|
|
18
18
|
|
|
19
|
-
/**
|
|
20
|
-
* Relative increment over the current highest bid required to forward a bid, in basis points.
|
|
21
|
-
* With 3%, laddering from 1 gwei to 1 ETH takes ~256 bids given the floor and cap below, see
|
|
22
|
-
* https://github.com/ethereum/consensus-specs/pull/4792#issuecomment-3714553549.
|
|
23
|
-
*/
|
|
24
|
-
const BID_INCREMENT_BPS = 300;
|
|
25
|
-
/**
|
|
26
|
-
* Minimum absolute increment (0.0001 ETH). Covers low bid values where the relative increment
|
|
27
|
-
* is tiny and provides weak spam protection.
|
|
28
|
-
*/
|
|
29
|
-
const BID_INCREMENT_FLOOR_GWEI = 100_000;
|
|
30
|
-
/**
|
|
31
|
-
* Maximum absolute increment (0.01 ETH). Bounds the barrier for legitimate competition on
|
|
32
|
-
* high value blocks where the relative increment would suppress closely competing bids.
|
|
33
|
-
*/
|
|
34
|
-
const BID_INCREMENT_CAP_GWEI = 10_000_000;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Return the minimum value a new bid must have to be forwarded given the current highest bid.
|
|
38
|
-
* Division before multiplication to stay within safe integer range for max gwei values.
|
|
39
|
-
*/
|
|
40
|
-
function getMinBidValue(currentHighestBid: number): number {
|
|
41
|
-
const relativeIncrement = Math.floor(currentHighestBid / 10_000) * BID_INCREMENT_BPS;
|
|
42
|
-
const increment = Math.min(Math.max(BID_INCREMENT_FLOOR_GWEI, relativeIncrement), BID_INCREMENT_CAP_GWEI);
|
|
43
|
-
return currentHighestBid + increment;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
19
|
/**
|
|
47
20
|
* Check whether a bid builds on one of the paths compatible with the local head branch.
|
|
48
21
|
*
|
|
@@ -165,27 +138,30 @@ async function validateExecutionPayloadBid(
|
|
|
165
138
|
});
|
|
166
139
|
}
|
|
167
140
|
|
|
168
|
-
// [IGNORE]
|
|
169
|
-
// the
|
|
170
|
-
//
|
|
171
|
-
|
|
172
|
-
|
|
141
|
+
// [IGNORE] The builder has not reached its bid limit, checked against the limit of its last valid bid.
|
|
142
|
+
// Bids for the same slot and parent root are validated against the same state, so bids past the
|
|
143
|
+
// limit can be dropped before state regeneration and the other expensive validation steps.
|
|
144
|
+
const seenBids = chain.seenExecutionPayloadBids.get(
|
|
145
|
+
bid.slot,
|
|
146
|
+
bid.builderIndex,
|
|
147
|
+
bidParentBlockHash,
|
|
148
|
+
bidParentBlockRoot
|
|
149
|
+
);
|
|
150
|
+
if (seenBids !== undefined && seenBids.count >= seenBids.limit) {
|
|
173
151
|
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
174
|
-
code: ExecutionPayloadBidErrorCode.
|
|
152
|
+
code: ExecutionPayloadBidErrorCode.BID_LIMIT_REACHED,
|
|
175
153
|
builderIndex: bid.builderIndex,
|
|
176
154
|
slot: bid.slot,
|
|
177
155
|
parentBlockRoot: bidParentBlockRoot,
|
|
178
156
|
parentBlockHash: bidParentBlockHash,
|
|
157
|
+
bidLimit: seenBids.limit,
|
|
179
158
|
});
|
|
180
159
|
}
|
|
181
160
|
|
|
182
161
|
// [IGNORE] this bid is the highest value bid seen for the tuple
|
|
183
162
|
// `(bid.slot, bid.parent_block_hash, bid.parent_block_root)`.
|
|
184
|
-
// As a DoS prevention measure, the bid must also exceed the current highest bid by a minimum
|
|
185
|
-
// increment, see https://github.com/ethereum/consensus-specs/pull/4831. This prevents spam
|
|
186
|
-
// from builders submitting numerous bids with minimal value increments.
|
|
187
163
|
const bestBid = chain.executionPayloadBidPool.getBestBid(bid.slot, bidParentBlockHash, bidParentBlockRoot);
|
|
188
|
-
if (bestBid !== null && bid.value
|
|
164
|
+
if (bestBid !== null && bid.value <= bestBid.signedBid.message.value) {
|
|
189
165
|
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
190
166
|
code: ExecutionPayloadBidErrorCode.BID_TOO_LOW,
|
|
191
167
|
bidValue: bid.value,
|
|
@@ -366,6 +342,24 @@ async function validateExecutionPayloadBid(
|
|
|
366
342
|
});
|
|
367
343
|
}
|
|
368
344
|
|
|
345
|
+
// [IGNORE] The builder has not reached its bid limit for the tuple
|
|
346
|
+
// `(bid.slot, bid.parent_block_hash, bid.parent_block_root)` -- i.e. one bid per ETH of builder balance
|
|
347
|
+
// not owed in pending withdrawals, `get_builder_bid_limit(state, bid.builder_index)`.
|
|
348
|
+
const bidLimit = state.getBuilderBidLimit(bid.builderIndex);
|
|
349
|
+
if (
|
|
350
|
+
(chain.seenExecutionPayloadBids.get(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot)?.count ??
|
|
351
|
+
0) >= bidLimit
|
|
352
|
+
) {
|
|
353
|
+
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
354
|
+
code: ExecutionPayloadBidErrorCode.BID_LIMIT_REACHED,
|
|
355
|
+
builderIndex: bid.builderIndex,
|
|
356
|
+
slot: bid.slot,
|
|
357
|
+
parentBlockRoot: bidParentBlockRoot,
|
|
358
|
+
parentBlockHash: bidParentBlockHash,
|
|
359
|
+
bidLimit,
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
|
|
369
363
|
// [IGNORE] `bid.value` is less or equal than the builder's excess balance --
|
|
370
364
|
// i.e. `can_builder_cover_bid(state, builder_index, amount)` returns `True`.
|
|
371
365
|
if (!state.canBuilderCoverBid(bid.builderIndex, bid.value)) {
|
|
@@ -426,20 +420,24 @@ async function validateExecutionPayloadBid(
|
|
|
426
420
|
});
|
|
427
421
|
}
|
|
428
422
|
|
|
429
|
-
// Repeat the
|
|
430
|
-
// for the same builder and tuple from
|
|
431
|
-
if (
|
|
423
|
+
// Repeat the bid limit check after the awaited signature verification to prevent concurrent bids
|
|
424
|
+
// for the same builder and tuple from all passing validation.
|
|
425
|
+
if (
|
|
426
|
+
(chain.seenExecutionPayloadBids.get(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot)?.count ??
|
|
427
|
+
0) >= bidLimit
|
|
428
|
+
) {
|
|
432
429
|
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
433
|
-
code: ExecutionPayloadBidErrorCode.
|
|
430
|
+
code: ExecutionPayloadBidErrorCode.BID_LIMIT_REACHED,
|
|
434
431
|
builderIndex: bid.builderIndex,
|
|
435
432
|
slot: bid.slot,
|
|
436
433
|
parentBlockRoot: bidParentBlockRoot,
|
|
437
434
|
parentBlockHash: bidParentBlockHash,
|
|
435
|
+
bidLimit,
|
|
438
436
|
});
|
|
439
437
|
}
|
|
440
438
|
|
|
441
439
|
// Valid
|
|
442
|
-
chain.seenExecutionPayloadBids.add(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot);
|
|
440
|
+
chain.seenExecutionPayloadBids.add(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot, bidLimit);
|
|
443
441
|
|
|
444
442
|
return {proposerIndex: proposerPreferences.message.validatorIndex};
|
|
445
443
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
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";
|
|
@@ -129,6 +130,17 @@ async function validateExecutionPayloadEnvelope(
|
|
|
129
130
|
});
|
|
130
131
|
}
|
|
131
132
|
|
|
133
|
+
// [REJECT] `envelope.parent_beacon_block_root == block.parent_root`
|
|
134
|
+
if (toRootHex(envelope.parentBeaconBlockRoot) !== block.parentRoot) {
|
|
135
|
+
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
136
|
+
code: ExecutionPayloadEnvelopeErrorCode.PARENT_BEACON_BLOCK_ROOT_MISMATCH,
|
|
137
|
+
slot: payload.slotNumber,
|
|
138
|
+
root: blockRootHex,
|
|
139
|
+
envelopeParentBeaconBlockRoot: toRootHex(envelope.parentBeaconBlockRoot),
|
|
140
|
+
blockParentRoot: block.parentRoot,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
132
144
|
// [REJECT] `envelope.builder_index == bid.builder_index`
|
|
133
145
|
if (envelope.builderIndex !== payloadInput.getBuilderIndex()) {
|
|
134
146
|
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
@@ -140,6 +152,30 @@ async function validateExecutionPayloadEnvelope(
|
|
|
140
152
|
});
|
|
141
153
|
}
|
|
142
154
|
|
|
155
|
+
const bid = payloadInput.getBid();
|
|
156
|
+
|
|
157
|
+
// [REJECT] `payload.prev_randao == bid.prev_randao`
|
|
158
|
+
if (!byteArrayEquals(payload.prevRandao, bid.prevRandao)) {
|
|
159
|
+
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
160
|
+
code: ExecutionPayloadEnvelopeErrorCode.PREV_RANDAO_MISMATCH,
|
|
161
|
+
slot: payload.slotNumber,
|
|
162
|
+
root: blockRootHex,
|
|
163
|
+
envelopePrevRandao: toRootHex(payload.prevRandao),
|
|
164
|
+
bidPrevRandao: toRootHex(bid.prevRandao),
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// [REJECT] `payload.gas_limit == bid.gas_limit`
|
|
169
|
+
if (BigInt(payload.gasLimit) !== bid.gasLimit) {
|
|
170
|
+
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
171
|
+
code: ExecutionPayloadEnvelopeErrorCode.GAS_LIMIT_MISMATCH,
|
|
172
|
+
slot: payload.slotNumber,
|
|
173
|
+
root: blockRootHex,
|
|
174
|
+
envelopeGasLimit: payload.gasLimit,
|
|
175
|
+
bidGasLimit: bid.gasLimit,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
143
179
|
// [REJECT] `payload.block_hash == bid.block_hash`
|
|
144
180
|
if (toRootHex(payload.blockHash) !== payloadInput.getBlockHashHex()) {
|
|
145
181
|
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
@@ -153,13 +189,13 @@ async function validateExecutionPayloadEnvelope(
|
|
|
153
189
|
|
|
154
190
|
// [REJECT] `hash_tree_root(envelope.execution_requests) == bid.execution_requests_root`
|
|
155
191
|
const requestsRoot = ssz.gloas.ExecutionRequests.hashTreeRoot(envelope.executionRequests);
|
|
156
|
-
if (!byteArrayEquals(requestsRoot,
|
|
192
|
+
if (!byteArrayEquals(requestsRoot, bid.executionRequestsRoot)) {
|
|
157
193
|
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
158
194
|
code: ExecutionPayloadEnvelopeErrorCode.EXECUTION_REQUESTS_ROOT_MISMATCH,
|
|
159
195
|
slot: payload.slotNumber,
|
|
160
196
|
root: blockRootHex,
|
|
161
197
|
envelopeRequestsRoot: toRootHex(requestsRoot),
|
|
162
|
-
bidRequestsRoot: toRootHex(
|
|
198
|
+
bidRequestsRoot: toRootHex(bid.executionRequestsRoot),
|
|
163
199
|
});
|
|
164
200
|
}
|
|
165
201
|
|
|
@@ -177,7 +213,7 @@ async function validateExecutionPayloadEnvelope(
|
|
|
177
213
|
});
|
|
178
214
|
}
|
|
179
215
|
|
|
180
|
-
// Get the block state to verify the builder's signature.
|
|
216
|
+
// Get the block state to verify the payload against it and the builder's signature.
|
|
181
217
|
const blockState = await chain.regen
|
|
182
218
|
.getState(block.stateRoot, RegenCaller.validateGossipPayloadEnvelope)
|
|
183
219
|
.catch(() => {
|
|
@@ -191,6 +227,54 @@ async function validateExecutionPayloadEnvelope(
|
|
|
191
227
|
throw new Error(`Expected gloas+ state for execution payload envelope validation, got fork=${blockState.forkName}`);
|
|
192
228
|
}
|
|
193
229
|
|
|
230
|
+
// [REJECT] `payload.parent_hash == state.latest_block_hash`
|
|
231
|
+
if (!byteArrayEquals(payload.parentHash, blockState.latestBlockHash)) {
|
|
232
|
+
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
233
|
+
code: ExecutionPayloadEnvelopeErrorCode.PARENT_HASH_MISMATCH,
|
|
234
|
+
slot: payload.slotNumber,
|
|
235
|
+
root: blockRootHex,
|
|
236
|
+
envelopeParentHash: toRootHex(payload.parentHash),
|
|
237
|
+
latestBlockHash: toRootHex(blockState.latestBlockHash),
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// [REJECT] `payload.timestamp == compute_time_at_slot(state.genesis_time, block.slot)`
|
|
242
|
+
const expectedTimestamp = computeTimeAtSlot(chain.config, block.slot, blockState.genesisTime);
|
|
243
|
+
if (payload.timestamp !== expectedTimestamp) {
|
|
244
|
+
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
245
|
+
code: ExecutionPayloadEnvelopeErrorCode.INCORRECT_TIMESTAMP,
|
|
246
|
+
slot: payload.slotNumber,
|
|
247
|
+
root: blockRootHex,
|
|
248
|
+
envelopeTimestamp: payload.timestamp,
|
|
249
|
+
expectedTimestamp,
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// [REJECT] The payload contains no empty transactions
|
|
254
|
+
for (let i = 0; i < payload.transactions.length; i++) {
|
|
255
|
+
if (payload.transactions.getSize(i) === 0) {
|
|
256
|
+
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
257
|
+
code: ExecutionPayloadEnvelopeErrorCode.EMPTY_TRANSACTION,
|
|
258
|
+
slot: payload.slotNumber,
|
|
259
|
+
root: blockRootHex,
|
|
260
|
+
transactionIndex: i,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// [REJECT] `hash_tree_root(payload.withdrawals) == hash_tree_root(state.payload_expected_withdrawals)`
|
|
266
|
+
const withdrawalsRoot = ssz.gloas.Withdrawals.hashTreeRoot(payload.withdrawals);
|
|
267
|
+
const expectedWithdrawalsRoot = ssz.gloas.Withdrawals.hashTreeRoot(blockState.payloadExpectedWithdrawals);
|
|
268
|
+
if (!byteArrayEquals(withdrawalsRoot, expectedWithdrawalsRoot)) {
|
|
269
|
+
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
270
|
+
code: ExecutionPayloadEnvelopeErrorCode.WITHDRAWALS_MISMATCH,
|
|
271
|
+
slot: payload.slotNumber,
|
|
272
|
+
root: blockRootHex,
|
|
273
|
+
envelopeWithdrawalsRoot: toRootHex(withdrawalsRoot),
|
|
274
|
+
expectedWithdrawalsRoot: toRootHex(expectedWithdrawalsRoot),
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
|
|
194
278
|
// [REJECT] `signed_execution_payload_envelope.signature` is valid as verified
|
|
195
279
|
// by `verify_execution_payload_envelope_signature`.
|
|
196
280
|
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
|
|