@lodestar/beacon-node 1.43.0-rc.5 → 1.44.0-dev.055b83cb3d
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 +30 -0
- 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 +46 -5
- package/lib/api/impl/beacon/pool/index.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +103 -49
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/blocks/importBlock.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.js +5 -2
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +4 -2
- package/lib/chain/blocks/importExecutionPayload.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 +5 -2
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/errors/executionPayloadBid.d.ts +24 -1
- package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadBid.js +4 -0
- package/lib/chain/errors/executionPayloadBid.js.map +1 -1
- package/lib/chain/forkChoice/index.d.ts.map +1 -1
- package/lib/chain/forkChoice/index.js +14 -4
- package/lib/chain/forkChoice/index.js.map +1 -1
- package/lib/chain/interface.d.ts +2 -1
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/interface.js.map +1 -1
- package/lib/chain/lightClient/index.d.ts.map +1 -1
- package/lib/chain/lightClient/index.js +1 -1
- package/lib/chain/lightClient/index.js.map +1 -1
- package/lib/chain/opPools/executionPayloadBidPool.d.ts +4 -4
- package/lib/chain/opPools/executionPayloadBidPool.d.ts.map +1 -1
- package/lib/chain/opPools/executionPayloadBidPool.js +6 -4
- package/lib/chain/opPools/executionPayloadBidPool.js.map +1 -1
- package/lib/chain/opPools/index.d.ts +1 -0
- package/lib/chain/opPools/index.d.ts.map +1 -1
- package/lib/chain/opPools/index.js +1 -0
- package/lib/chain/opPools/index.js.map +1 -1
- package/lib/chain/opPools/payloadAttestationPool.d.ts +1 -1
- package/lib/chain/opPools/payloadAttestationPool.d.ts.map +1 -1
- package/lib/chain/opPools/payloadAttestationPool.js +30 -10
- package/lib/chain/opPools/payloadAttestationPool.js.map +1 -1
- package/lib/chain/opPools/proposerPreferencesPool.d.ts +29 -0
- package/lib/chain/opPools/proposerPreferencesPool.d.ts.map +1 -0
- package/lib/chain/opPools/proposerPreferencesPool.js +56 -0
- package/lib/chain/opPools/proposerPreferencesPool.js.map +1 -0
- package/lib/chain/prepareNextSlot.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +2 -1
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +7 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +107 -18
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/validation/executionPayloadBid.d.ts +7 -3
- package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/validation/executionPayloadBid.js +87 -23
- package/lib/chain/validation/executionPayloadBid.js.map +1 -1
- package/lib/chain/validation/payloadAttestationMessage.d.ts +1 -1
- package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
- package/lib/chain/validation/payloadAttestationMessage.js +5 -3
- package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
- package/lib/chain/validatorMonitor.d.ts +1 -0
- package/lib/chain/validatorMonitor.d.ts.map +1 -1
- package/lib/chain/validatorMonitor.js +16 -0
- package/lib/chain/validatorMonitor.js.map +1 -1
- package/lib/execution/builder/index.d.ts +1 -2
- package/lib/execution/builder/index.d.ts.map +1 -1
- package/lib/execution/builder/index.js +0 -1
- package/lib/execution/builder/index.js.map +1 -1
- package/lib/execution/engine/interface.d.ts +1 -0
- package/lib/execution/engine/interface.d.ts.map +1 -1
- package/lib/execution/engine/types.d.ts +2 -0
- package/lib/execution/engine/types.d.ts.map +1 -1
- package/lib/execution/engine/types.js +2 -0
- package/lib/execution/engine/types.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +1 -1
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +4 -3
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/gossip/topic.d.ts +1 -1
- package/lib/network/interface.d.ts +2 -0
- package/lib/network/interface.d.ts.map +1 -1
- package/lib/network/network.d.ts +2 -0
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js +10 -0
- 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/util/dependentRoot.d.ts +6 -2
- package/lib/util/dependentRoot.d.ts.map +1 -1
- package/lib/util/dependentRoot.js +20 -16
- package/lib/util/dependentRoot.js.map +1 -1
- package/package.json +14 -15
- package/src/api/impl/beacon/blocks/index.ts +36 -0
- package/src/api/impl/beacon/pool/index.ts +58 -4
- package/src/api/impl/validator/index.ts +118 -50
- package/src/chain/blocks/importBlock.ts +9 -2
- package/src/chain/blocks/importExecutionPayload.ts +7 -1
- package/src/chain/chain.ts +5 -0
- package/src/chain/errors/executionPayloadBid.ts +25 -1
- package/src/chain/forkChoice/index.ts +14 -4
- package/src/chain/interface.ts +2 -0
- package/src/chain/lightClient/index.ts +6 -6
- package/src/chain/opPools/executionPayloadBidPool.ts +10 -9
- package/src/chain/opPools/index.ts +1 -0
- package/src/chain/opPools/payloadAttestationPool.ts +34 -10
- package/src/chain/opPools/proposerPreferencesPool.ts +59 -0
- package/src/chain/prepareNextSlot.ts +2 -1
- package/src/chain/produceBlock/produceBlockBody.ts +158 -25
- package/src/chain/validation/executionPayloadBid.ts +96 -28
- package/src/chain/validation/payloadAttestationMessage.ts +6 -4
- package/src/chain/validatorMonitor.ts +18 -0
- package/src/execution/builder/index.ts +1 -4
- package/src/execution/engine/interface.ts +1 -0
- package/src/execution/engine/types.ts +4 -0
- package/src/metrics/metrics/lodestar.ts +4 -3
- package/src/network/interface.ts +2 -0
- package/src/network/network.ts +22 -0
- package/src/network/processor/gossipHandlers.ts +24 -6
- package/src/util/dependentRoot.ts +22 -18
- package/lib/execution/builder/utils.d.ts +0 -5
- package/lib/execution/builder/utils.d.ts.map +0 -1
- package/lib/execution/builder/utils.js +0 -17
- package/lib/execution/builder/utils.js.map +0 -1
- package/src/execution/builder/utils.ts +0 -19
|
@@ -57,7 +57,7 @@ export class PayloadAttestationPool {
|
|
|
57
57
|
add(
|
|
58
58
|
message: gloas.PayloadAttestationMessage,
|
|
59
59
|
payloadAttDataRootHex: RootHex,
|
|
60
|
-
|
|
60
|
+
validatorCommitteeIndices: number[]
|
|
61
61
|
): InsertOutcome {
|
|
62
62
|
const slot = message.data.slot;
|
|
63
63
|
const lowestPermissibleSlot = this.lowestPermissibleSlot;
|
|
@@ -85,10 +85,10 @@ export class PayloadAttestationPool {
|
|
|
85
85
|
const aggregate = aggregateByDataRoot.get(payloadAttDataRootHex);
|
|
86
86
|
if (aggregate) {
|
|
87
87
|
// Aggregate msg into aggregate
|
|
88
|
-
return aggregateMessageInto(message,
|
|
88
|
+
return aggregateMessageInto(message, validatorCommitteeIndices, aggregate);
|
|
89
89
|
}
|
|
90
90
|
// Create a new aggregate with data
|
|
91
|
-
aggregateByDataRoot.set(payloadAttDataRootHex, messageToAggregate(message,
|
|
91
|
+
aggregateByDataRoot.set(payloadAttDataRootHex, messageToAggregate(message, validatorCommitteeIndices));
|
|
92
92
|
|
|
93
93
|
return InsertOutcome.NewData;
|
|
94
94
|
}
|
|
@@ -150,25 +150,49 @@ export class PayloadAttestationPool {
|
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
function messageToAggregate(
|
|
153
|
+
function messageToAggregate(
|
|
154
|
+
message: gloas.PayloadAttestationMessage,
|
|
155
|
+
validatorCommitteeIndices: number[]
|
|
156
|
+
): AggregateFast {
|
|
157
|
+
const aggregationBits = BitArray.fromBitLen(PTC_SIZE);
|
|
158
|
+
for (const index of validatorCommitteeIndices) {
|
|
159
|
+
aggregationBits.set(index, true);
|
|
160
|
+
}
|
|
161
|
+
const sig = signatureFromBytesNoCheck(message.signature);
|
|
162
|
+
// The validator signed once but occupies `validatorCommitteeIndices.length` PTC positions.
|
|
163
|
+
// Verification aggregates the pubkey once per set bit, so the signature must be aggregated
|
|
164
|
+
// the same number of times for the BLS check to balance — same pattern as sync committee.
|
|
165
|
+
const signature =
|
|
166
|
+
validatorCommitteeIndices.length === 1
|
|
167
|
+
? sig
|
|
168
|
+
: aggregateSignatures(new Array(validatorCommitteeIndices.length).fill(sig));
|
|
154
169
|
return {
|
|
155
|
-
aggregationBits
|
|
170
|
+
aggregationBits,
|
|
156
171
|
data: message.data,
|
|
157
|
-
signature
|
|
172
|
+
signature,
|
|
158
173
|
};
|
|
159
174
|
}
|
|
160
175
|
|
|
161
176
|
function aggregateMessageInto(
|
|
162
177
|
message: gloas.PayloadAttestationMessage,
|
|
163
|
-
|
|
178
|
+
validatorCommitteeIndices: number[],
|
|
164
179
|
aggregate: AggregateFast
|
|
165
180
|
): InsertOutcome {
|
|
166
|
-
|
|
181
|
+
// Gossip dedup via `seenPayloadAttesters` is keyed by (epoch, validatorIndex), so the same
|
|
182
|
+
// validator's message is never processed twice — all of its bits are set together or none.
|
|
183
|
+
// Checking the first index is sufficient.
|
|
184
|
+
if (aggregate.aggregationBits.get(validatorCommitteeIndices[0]) === true) {
|
|
167
185
|
return InsertOutcome.AlreadyKnown;
|
|
168
186
|
}
|
|
169
187
|
|
|
170
|
-
|
|
171
|
-
|
|
188
|
+
for (const index of validatorCommitteeIndices) {
|
|
189
|
+
aggregate.aggregationBits.set(index, true);
|
|
190
|
+
}
|
|
191
|
+
const sig = signatureFromBytesNoCheck(message.signature);
|
|
192
|
+
aggregate.signature = aggregateSignatures([
|
|
193
|
+
aggregate.signature,
|
|
194
|
+
...new Array(validatorCommitteeIndices.length).fill(sig),
|
|
195
|
+
]);
|
|
172
196
|
|
|
173
197
|
return InsertOutcome.Aggregated;
|
|
174
198
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {RootHex, Slot, gloas} from "@lodestar/types";
|
|
2
|
+
import {toRootHex} from "@lodestar/utils";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Pool of validated `SignedProposerPreferences` indexed by `(slot, dependent_root)`.
|
|
6
|
+
*
|
|
7
|
+
* The primary consumer is `validateExecutionPayloadBid`, which looks up the matching
|
|
8
|
+
* preferences via `get(bid.slot, dependent_root)` to enforce the IGNORE-existence and
|
|
9
|
+
* REJECT-equality rules from the gloas spec. The beacon API `/pool/proposer_preferences`
|
|
10
|
+
* GET endpoint reads from the same pool via `getAll`.
|
|
11
|
+
*
|
|
12
|
+
* `validator_index` is intentionally not part of the key: gossip validation enforces
|
|
13
|
+
* `proposers[proposalSlot % SLOTS_PER_EPOCH] === validatorIndex` against the shuffling
|
|
14
|
+
* implied by `dependent_root`, so once a preference has been validated `(slot, dependent_root)`
|
|
15
|
+
* already pins down the validator.
|
|
16
|
+
*/
|
|
17
|
+
export class ProposerPreferencesPool {
|
|
18
|
+
private readonly bySlot = new Map<Slot, Map<RootHex, gloas.SignedProposerPreferences>>();
|
|
19
|
+
|
|
20
|
+
/** Lookup for bid validation: matches `(bid.slot, get_proposer_dependent_root(parent_state, ...))`. */
|
|
21
|
+
get(slot: Slot, dependentRootHex: RootHex): gloas.SignedProposerPreferences | null {
|
|
22
|
+
return this.bySlot.get(slot)?.get(dependentRootHex) ?? null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
add(signed: gloas.SignedProposerPreferences): void {
|
|
26
|
+
const {proposalSlot, dependentRoot} = signed.message;
|
|
27
|
+
const rootHex = toRootHex(dependentRoot);
|
|
28
|
+
let byRoot = this.bySlot.get(proposalSlot);
|
|
29
|
+
if (!byRoot) {
|
|
30
|
+
byRoot = new Map();
|
|
31
|
+
this.bySlot.set(proposalSlot, byRoot);
|
|
32
|
+
}
|
|
33
|
+
byRoot.set(rootHex, signed);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** API read-out: flatten across branches, optionally filtered by slot. */
|
|
37
|
+
getAll(slot?: Slot): gloas.SignedProposerPreferences[] {
|
|
38
|
+
if (slot !== undefined) {
|
|
39
|
+
const byRoot = this.bySlot.get(slot);
|
|
40
|
+
return byRoot ? Array.from(byRoot.values()) : [];
|
|
41
|
+
}
|
|
42
|
+
const out: gloas.SignedProposerPreferences[] = [];
|
|
43
|
+
for (const byRoot of this.bySlot.values()) {
|
|
44
|
+
for (const v of byRoot.values()) out.push(v);
|
|
45
|
+
}
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Entries are only load-bearing while `proposal_slot >= current_slot`. Once the slot has
|
|
51
|
+
* passed the `[IGNORE] proposal_slot > current_slot` gossip rule takes over, so drop them
|
|
52
|
+
* on each slot tick.
|
|
53
|
+
*/
|
|
54
|
+
prune(currentSlot: Slot): void {
|
|
55
|
+
for (const slot of this.bySlot.keys()) {
|
|
56
|
+
if (slot < currentSlot) this.bySlot.delete(slot);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -169,7 +169,8 @@ export class PrepareNextSlotScheduler {
|
|
|
169
169
|
// Apply parent payload once here as it's reused by EL prep and SSE emit below
|
|
170
170
|
let stateAfterParentPayload: IBeaconStateViewBellatrix = updatedPrepareState;
|
|
171
171
|
if (isStatePostGloas(updatedPrepareState)) {
|
|
172
|
-
|
|
172
|
+
// Spec: should_build_on_full(store, head) — see produceBlockBody.ts for context.
|
|
173
|
+
if (this.chain.forkChoice.shouldBuildOnFull(updatedHead)) {
|
|
173
174
|
parentBlockHash = updatedPrepareState.latestExecutionPayloadBid.blockHash;
|
|
174
175
|
// Skip applying parent payload unless we're proposing the next slot or have to emit payload_attributes events
|
|
175
176
|
if (feeRecipient !== undefined || this.chain.opts.emitPayloadAttributes === true) {
|
|
@@ -18,7 +18,9 @@ import {
|
|
|
18
18
|
G2_POINT_AT_INFINITY,
|
|
19
19
|
IBeaconStateView,
|
|
20
20
|
type IBeaconStateViewBellatrix,
|
|
21
|
+
computeEpochAtSlot,
|
|
21
22
|
computeTimeAtSlot,
|
|
23
|
+
getExpectedGasLimit,
|
|
22
24
|
isStatePostBellatrix,
|
|
23
25
|
isStatePostCapella,
|
|
24
26
|
isStatePostGloas,
|
|
@@ -48,20 +50,16 @@ import {
|
|
|
48
50
|
gloas,
|
|
49
51
|
ssz,
|
|
50
52
|
} from "@lodestar/types";
|
|
51
|
-
import {Logger, byteArrayEquals, fromHex, sleep, toHex, toPubkeyHex, toRootHex} from "@lodestar/utils";
|
|
53
|
+
import {GWEI_TO_WEI, Logger, byteArrayEquals, fromHex, sleep, toHex, toPubkeyHex, toRootHex} from "@lodestar/utils";
|
|
52
54
|
import {ZERO_HASH_HEX} from "../../constants/index.js";
|
|
53
55
|
import {numToQuantity} from "../../execution/engine/utils.js";
|
|
54
|
-
import {
|
|
55
|
-
|
|
56
|
-
IExecutionEngine,
|
|
57
|
-
PayloadAttributes,
|
|
58
|
-
PayloadId,
|
|
59
|
-
getExpectedGasLimit,
|
|
60
|
-
} from "../../execution/index.js";
|
|
56
|
+
import {IExecutionBuilder, IExecutionEngine, PayloadAttributes, PayloadId} from "../../execution/index.js";
|
|
57
|
+
import {getShufflingDependentRoot} from "../../util/dependentRoot.js";
|
|
61
58
|
import {fromGraffitiBytes} from "../../util/graffiti.js";
|
|
62
59
|
import {kzg} from "../../util/kzg.js";
|
|
63
60
|
import type {BeaconChain} from "../chain.js";
|
|
64
61
|
import {CommonBlockBody} from "../interface.js";
|
|
62
|
+
import {ProposerPreferencesPool} from "../opPools/index.js";
|
|
65
63
|
import {validateBlobsAndKzgCommitments, validateCellsAndKzgCommitments} from "./validateBlobsAndKzgCommitments.js";
|
|
66
64
|
|
|
67
65
|
// Time to provide the EL to generate a payload from new payload id
|
|
@@ -93,6 +91,8 @@ export type BlockAttributes = {
|
|
|
93
91
|
slot: Slot;
|
|
94
92
|
parentBlock: ProtoBlock;
|
|
95
93
|
feeRecipient?: string;
|
|
94
|
+
/** When provided, build block with this builder bid instead of a self-build bid */
|
|
95
|
+
builderBid?: gloas.SignedExecutionPayloadBid;
|
|
96
96
|
};
|
|
97
97
|
|
|
98
98
|
export enum BlockType {
|
|
@@ -152,6 +152,28 @@ export type ProduceResult =
|
|
|
152
152
|
| ProduceFullPhase0
|
|
153
153
|
| ProduceBlinded;
|
|
154
154
|
|
|
155
|
+
/**
|
|
156
|
+
* Drop voluntary exits that `parent_execution_requests` have invalidated (e.g. a withdrawal
|
|
157
|
+
* request initiating an exit on the same validator). Op pool selected against the unapplied
|
|
158
|
+
* state, so re-validate against the post-apply state to avoid producing an invalid block.
|
|
159
|
+
*
|
|
160
|
+
* `getStateAfterParentPayload` is a thunk so the post-apply state is only materialized when
|
|
161
|
+
* actually needed (i.e. when extending the parent payload and there are exits to filter).
|
|
162
|
+
*/
|
|
163
|
+
function maybeFilterInvalidatedVoluntaryExits(
|
|
164
|
+
commonBlockBody: CommonBlockBody,
|
|
165
|
+
isExtendingPayload: boolean,
|
|
166
|
+
getStateAfterParentPayload: () => IBeaconStateViewBellatrix
|
|
167
|
+
): CommonBlockBody["voluntaryExits"] {
|
|
168
|
+
if (!isExtendingPayload || commonBlockBody.voluntaryExits.length === 0) {
|
|
169
|
+
return commonBlockBody.voluntaryExits;
|
|
170
|
+
}
|
|
171
|
+
const state = getStateAfterParentPayload();
|
|
172
|
+
return commonBlockBody.voluntaryExits.filter((signedVoluntaryExit) =>
|
|
173
|
+
state.isValidVoluntaryExit(signedVoluntaryExit, false)
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
155
177
|
export async function produceBlockBody<T extends BlockType>(
|
|
156
178
|
this: BeaconChain,
|
|
157
179
|
blockType: T,
|
|
@@ -174,6 +196,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
174
196
|
proposerIndex,
|
|
175
197
|
proposerPubKey,
|
|
176
198
|
commonBlockBodyPromise,
|
|
199
|
+
builderBid,
|
|
177
200
|
} = blockAttr;
|
|
178
201
|
let executionPayloadValue: Wei;
|
|
179
202
|
let blockBody: AssembledBodyType<T>;
|
|
@@ -194,7 +217,43 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
194
217
|
};
|
|
195
218
|
this.logger.verbose("Producing beacon block body", logMeta);
|
|
196
219
|
|
|
197
|
-
if (
|
|
220
|
+
if (builderBid !== undefined) {
|
|
221
|
+
if (!isStatePostGloas(currentState)) {
|
|
222
|
+
throw new Error("Expected Gloas state for builder bid block production");
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const isExtendingPayload = byteArrayEquals(
|
|
226
|
+
builderBid.message.parentBlockHash,
|
|
227
|
+
currentState.latestExecutionPayloadBid.blockHash
|
|
228
|
+
);
|
|
229
|
+
const parentExecutionRequests = isExtendingPayload
|
|
230
|
+
? await this.getParentExecutionRequests(parentBlock.slot, parentBlock.blockRoot)
|
|
231
|
+
: ssz.electra.ExecutionRequests.defaultValue();
|
|
232
|
+
executionPayloadValue = BigInt(builderBid.message.value) * GWEI_TO_WEI;
|
|
233
|
+
|
|
234
|
+
const commonBlockBody = await commonBlockBodyPromise;
|
|
235
|
+
const gloasBody = Object.assign({}, commonBlockBody) as gloas.BeaconBlockBody;
|
|
236
|
+
gloasBody.signedExecutionPayloadBid = builderBid;
|
|
237
|
+
gloasBody.payloadAttestations = this.payloadAttestationPool.getPayloadAttestationsForBlock(
|
|
238
|
+
parentBlock.blockRoot,
|
|
239
|
+
blockSlot - 1
|
|
240
|
+
);
|
|
241
|
+
gloasBody.parentExecutionRequests = parentExecutionRequests;
|
|
242
|
+
gloasBody.voluntaryExits = maybeFilterInvalidatedVoluntaryExits(commonBlockBody, isExtendingPayload, () =>
|
|
243
|
+
currentState.withParentPayloadApplied(parentExecutionRequests)
|
|
244
|
+
);
|
|
245
|
+
blockBody = gloasBody as AssembledBodyType<T>;
|
|
246
|
+
|
|
247
|
+
this.logger.verbose("Produced block with builder bid", {
|
|
248
|
+
slot: blockSlot,
|
|
249
|
+
builderIndex: builderBid.message.builderIndex,
|
|
250
|
+
bidValue: builderBid.message.value,
|
|
251
|
+
parentBlockHash: toRootHex(builderBid.message.parentBlockHash),
|
|
252
|
+
parentBlockRoot: toRootHex(builderBid.message.parentBlockRoot),
|
|
253
|
+
blockHash: toRootHex(builderBid.message.blockHash),
|
|
254
|
+
isExtendingPayload,
|
|
255
|
+
});
|
|
256
|
+
} else if (isForkPostGloas(fork)) {
|
|
198
257
|
if (!isStatePostGloas(currentState)) {
|
|
199
258
|
throw new Error("Expected Gloas state for Gloas block production");
|
|
200
259
|
}
|
|
@@ -204,23 +263,23 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
204
263
|
// this into a completely separate function and have pre/post gloas more separated
|
|
205
264
|
const safeBlockHash = getSafeExecutionBlockHash(this.forkChoice);
|
|
206
265
|
const finalizedBlockHash = this.forkChoice.getFinalizedBlock().executionPayloadBlockHash ?? ZERO_HASH_HEX;
|
|
266
|
+
// TODO GLOAS: post-Gloas, proposer feeRecipient is also carried (signed) in
|
|
267
|
+
// ProposerPreferencesPool. Consider using this unified cache instead
|
|
268
|
+
// see https://github.com/ChainSafe/lodestar/issues/9379
|
|
207
269
|
const feeRecipient = requestedFeeRecipient ?? this.beaconProposerCache.getOrDefault(proposerIndex);
|
|
208
270
|
|
|
209
271
|
const endExecutionPayload = this.metrics?.executionBlockProductionTimeSteps.startTimer();
|
|
210
272
|
|
|
211
|
-
this.logger.verbose("Preparing execution payload from engine", {
|
|
212
|
-
slot: blockSlot,
|
|
213
|
-
parentBlockRoot: toRootHex(parentBlockRoot),
|
|
214
|
-
feeRecipient,
|
|
215
|
-
});
|
|
216
|
-
|
|
217
273
|
// Get execution payload from EL
|
|
218
274
|
let parentBlockHash: Bytes32;
|
|
219
275
|
let parentExecutionRequests: electra.ExecutionRequests;
|
|
220
276
|
// Apply parent payload once here as it's reused by EL prep and voluntary exit filtering below
|
|
221
277
|
let stateAfterParentPayload: IBeaconStateViewBellatrix = currentState;
|
|
222
|
-
|
|
223
|
-
|
|
278
|
+
// Spec: should_build_on_full(store, head). `parentBlock` is the proposer's head
|
|
279
|
+
// (set by chain.getProposerHead(slot)). Returns false when the PTC majority
|
|
280
|
+
// signalled the blob data is not available, forcing a build on EMPTY (reorg).
|
|
281
|
+
const isBuildingOnFull = this.forkChoice.shouldBuildOnFull(parentBlock);
|
|
282
|
+
if (isBuildingOnFull) {
|
|
224
283
|
parentBlockHash = currentState.latestExecutionPayloadBid.blockHash;
|
|
225
284
|
parentExecutionRequests = await this.getParentExecutionRequests(parentBlock.slot, parentBlock.blockRoot);
|
|
226
285
|
stateAfterParentPayload = currentState.withParentPayloadApplied(parentExecutionRequests);
|
|
@@ -243,6 +302,16 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
243
302
|
const {prepType, payloadId} = prepareRes;
|
|
244
303
|
Object.assign(logMeta, {executionPayloadPrepType: prepType});
|
|
245
304
|
|
|
305
|
+
this.logger.verbose("Prepared execution payload from engine", {
|
|
306
|
+
slot: blockSlot,
|
|
307
|
+
parentBlockRoot: toRootHex(parentBlockRoot),
|
|
308
|
+
parentBlockHash: toRootHex(parentBlockHash),
|
|
309
|
+
feeRecipient,
|
|
310
|
+
prepType,
|
|
311
|
+
payloadId,
|
|
312
|
+
isBuildingOnFull,
|
|
313
|
+
});
|
|
314
|
+
|
|
246
315
|
if (prepType !== PayloadPreparationType.Cached) {
|
|
247
316
|
await sleep(PAYLOAD_GENERATION_TIME_MS);
|
|
248
317
|
}
|
|
@@ -296,14 +365,11 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
296
365
|
blockSlot - 1
|
|
297
366
|
);
|
|
298
367
|
gloasBody.parentExecutionRequests = parentExecutionRequests;
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
stateAfterParentPayload.isValidVoluntaryExit(signedVoluntaryExit, false)
|
|
305
|
-
);
|
|
306
|
-
}
|
|
368
|
+
gloasBody.voluntaryExits = maybeFilterInvalidatedVoluntaryExits(
|
|
369
|
+
commonBlockBody,
|
|
370
|
+
isBuildingOnFull,
|
|
371
|
+
() => stateAfterParentPayload
|
|
372
|
+
);
|
|
307
373
|
blockBody = gloasBody as AssembledBodyType<T>;
|
|
308
374
|
|
|
309
375
|
// Store execution payload data required to construct execution payload envelope later
|
|
@@ -324,6 +390,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
324
390
|
fetchedTime,
|
|
325
391
|
executionBlockHash: toRootHex(executionPayload.blockHash),
|
|
326
392
|
blobs: blobsBundle.commitments.length,
|
|
393
|
+
gasLimit: executionPayload.gasLimit,
|
|
327
394
|
});
|
|
328
395
|
|
|
329
396
|
Object.assign(logMeta, {
|
|
@@ -633,6 +700,8 @@ export async function prepareExecutionPayload(
|
|
|
633
700
|
chain: {
|
|
634
701
|
executionEngine: IExecutionEngine;
|
|
635
702
|
config: ChainForkConfig;
|
|
703
|
+
forkChoice: IForkChoice;
|
|
704
|
+
proposerPreferencesPool: ProposerPreferencesPool;
|
|
636
705
|
},
|
|
637
706
|
logger: Logger,
|
|
638
707
|
fork: ForkPostBellatrix,
|
|
@@ -733,6 +802,7 @@ export function getPayloadAttributesForSSE(
|
|
|
733
802
|
chain: {
|
|
734
803
|
config: ChainForkConfig;
|
|
735
804
|
forkChoice: IForkChoice;
|
|
805
|
+
proposerPreferencesPool: ProposerPreferencesPool;
|
|
736
806
|
},
|
|
737
807
|
{
|
|
738
808
|
prepareState,
|
|
@@ -789,6 +859,8 @@ function preparePayloadAttributes(
|
|
|
789
859
|
fork: ForkPostBellatrix,
|
|
790
860
|
chain: {
|
|
791
861
|
config: ChainForkConfig;
|
|
862
|
+
forkChoice: IForkChoice;
|
|
863
|
+
proposerPreferencesPool: ProposerPreferencesPool;
|
|
792
864
|
},
|
|
793
865
|
{
|
|
794
866
|
prepareState,
|
|
@@ -851,12 +923,73 @@ function preparePayloadAttributes(
|
|
|
851
923
|
}
|
|
852
924
|
|
|
853
925
|
if (ForkSeq[fork] >= ForkSeq.gloas) {
|
|
926
|
+
if (!isStatePostGloas(prepareState)) {
|
|
927
|
+
throw new Error("Expected Gloas state for Gloas payload attributes");
|
|
928
|
+
}
|
|
854
929
|
(payloadAttributes as gloas.SSEPayloadAttributes["payloadAttributes"]).slotNumber = prepareSlot;
|
|
930
|
+
(payloadAttributes as gloas.SSEPayloadAttributes["payloadAttributes"]).targetGasLimit = getProposerTargetGasLimit(
|
|
931
|
+
chain,
|
|
932
|
+
prepareSlot,
|
|
933
|
+
parentBlockRoot,
|
|
934
|
+
parentBlockHash
|
|
935
|
+
);
|
|
855
936
|
}
|
|
856
937
|
|
|
857
938
|
return payloadAttributes;
|
|
858
939
|
}
|
|
859
940
|
|
|
941
|
+
/**
|
|
942
|
+
* Resolve the proposer's preferred (target) gas limit for the Gloas `PayloadAttributesV4`
|
|
943
|
+
* `targetGasLimit` field (consensus-specs#5235, execution-apis#796).
|
|
944
|
+
*
|
|
945
|
+
* Sourced from the `SignedProposerPreferences` the proposer's VC submitted to the pool
|
|
946
|
+
* (same `(slot, dependent_root)` lookup as gossip bid validation). When no matching
|
|
947
|
+
* preferences are pooled, target the parent payload's gas limit so the gas limit stays
|
|
948
|
+
* unchanged (`is_gas_limit_target_compatible` then requires `gas_limit == parent_gas_limit`).
|
|
949
|
+
*
|
|
950
|
+
* The parent payload's gas_limit is read from fork choice — the variant matching
|
|
951
|
+
* `(parentBlockRoot, parentBlockHash)` carries the correct value for both FULL parents
|
|
952
|
+
* (FULL.executionPayloadGasLimit = delivered payload's gas_limit) and EMPTY parents
|
|
953
|
+
* (EMPTY.executionPayloadGasLimit = inherited grandparent's gas_limit).
|
|
954
|
+
*/
|
|
955
|
+
function getProposerTargetGasLimit(
|
|
956
|
+
chain: {forkChoice: IForkChoice; proposerPreferencesPool: ProposerPreferencesPool},
|
|
957
|
+
prepareSlot: Slot,
|
|
958
|
+
parentBlockRoot: Root,
|
|
959
|
+
parentBlockHash: Bytes32
|
|
960
|
+
): number {
|
|
961
|
+
const parentBlockRootHex = toRootHex(parentBlockRoot);
|
|
962
|
+
const parentBlock = chain.forkChoice.getBlockHexDefaultStatus(parentBlockRootHex);
|
|
963
|
+
const dependentRootHex = (() => {
|
|
964
|
+
if (parentBlock === null) {
|
|
965
|
+
return null;
|
|
966
|
+
}
|
|
967
|
+
try {
|
|
968
|
+
return getShufflingDependentRoot(
|
|
969
|
+
chain.forkChoice,
|
|
970
|
+
computeEpochAtSlot(prepareSlot),
|
|
971
|
+
computeEpochAtSlot(parentBlock.slot),
|
|
972
|
+
parentBlock
|
|
973
|
+
);
|
|
974
|
+
} catch {
|
|
975
|
+
return null;
|
|
976
|
+
}
|
|
977
|
+
})();
|
|
978
|
+
|
|
979
|
+
const pref = dependentRootHex !== null ? chain.proposerPreferencesPool.get(prepareSlot, dependentRootHex) : null;
|
|
980
|
+
if (pref !== null) {
|
|
981
|
+
return pref.message.targetGasLimit;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
const parentPayloadVariant = chain.forkChoice.getBlockHexAndBlockHash(parentBlockRootHex, toRootHex(parentBlockHash));
|
|
985
|
+
if (parentPayloadVariant === null || parentPayloadVariant.executionPayloadBlockHash === null) {
|
|
986
|
+
throw new Error(
|
|
987
|
+
`Cannot resolve parent payload gas_limit for proposer targetGasLimit fallback parentBlockRoot=${parentBlockRootHex} parentBlockHash=${toRootHex(parentBlockHash)}`
|
|
988
|
+
);
|
|
989
|
+
}
|
|
990
|
+
return parentPayloadVariant.executionPayloadGasLimit;
|
|
991
|
+
}
|
|
992
|
+
|
|
860
993
|
export async function produceCommonBlockBody<T extends BlockType>(
|
|
861
994
|
this: BeaconChain,
|
|
862
995
|
blockType: T,
|
|
@@ -4,10 +4,12 @@ import {
|
|
|
4
4
|
createSingleSignatureSetFromComponents,
|
|
5
5
|
getExecutionPayloadBidSigningRoot,
|
|
6
6
|
isActiveBuilder,
|
|
7
|
+
isGasLimitTargetCompatible,
|
|
7
8
|
isStatePostGloas,
|
|
8
9
|
} from "@lodestar/state-transition";
|
|
9
|
-
import {gloas} from "@lodestar/types";
|
|
10
|
-
import {toRootHex} from "@lodestar/utils";
|
|
10
|
+
import {ValidatorIndex, gloas} from "@lodestar/types";
|
|
11
|
+
import {byteArrayEquals, toHex, toRootHex} from "@lodestar/utils";
|
|
12
|
+
import {getShufflingDependentRoot} from "../../util/dependentRoot.js";
|
|
11
13
|
import {ExecutionPayloadBidError, ExecutionPayloadBidErrorCode, GossipAction} from "../errors/index.js";
|
|
12
14
|
import {IBeaconChain} from "../index.js";
|
|
13
15
|
import {RegenCaller} from "../regen/index.js";
|
|
@@ -15,21 +17,21 @@ import {RegenCaller} from "../regen/index.js";
|
|
|
15
17
|
export async function validateApiExecutionPayloadBid(
|
|
16
18
|
chain: IBeaconChain,
|
|
17
19
|
signedExecutionPayloadBid: gloas.SignedExecutionPayloadBid
|
|
18
|
-
): Promise<
|
|
20
|
+
): Promise<{proposerIndex: ValidatorIndex}> {
|
|
19
21
|
return validateExecutionPayloadBid(chain, signedExecutionPayloadBid);
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
export async function validateGossipExecutionPayloadBid(
|
|
23
25
|
chain: IBeaconChain,
|
|
24
26
|
signedExecutionPayloadBid: gloas.SignedExecutionPayloadBid
|
|
25
|
-
): Promise<
|
|
27
|
+
): Promise<{proposerIndex: ValidatorIndex}> {
|
|
26
28
|
return validateExecutionPayloadBid(chain, signedExecutionPayloadBid);
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
async function validateExecutionPayloadBid(
|
|
30
32
|
chain: IBeaconChain,
|
|
31
33
|
signedExecutionPayloadBid: gloas.SignedExecutionPayloadBid
|
|
32
|
-
): Promise<
|
|
34
|
+
): Promise<{proposerIndex: ValidatorIndex}> {
|
|
33
35
|
const bid = signedExecutionPayloadBid.message;
|
|
34
36
|
const parentBlockRootHex = toRootHex(bid.parentBlockRoot);
|
|
35
37
|
const parentBlockHashHex = toRootHex(bid.parentBlockHash);
|
|
@@ -48,12 +50,55 @@ async function validateExecutionPayloadBid(
|
|
|
48
50
|
});
|
|
49
51
|
}
|
|
50
52
|
|
|
53
|
+
// [IGNORE] `bid.parent_block_root` is the hash tree root of a known beacon block in fork choice.
|
|
54
|
+
// Moved earlier than the spec ordering so we can derive the proposer dependent root for the
|
|
55
|
+
// proposer-preferences lookup below from a known fork-choice block.
|
|
56
|
+
const parentBlock = chain.forkChoice.getBlockHexDefaultStatus(parentBlockRootHex);
|
|
57
|
+
if (parentBlock === null) {
|
|
58
|
+
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
59
|
+
code: ExecutionPayloadBidErrorCode.UNKNOWN_BLOCK_ROOT,
|
|
60
|
+
parentBlockRoot: parentBlockRootHex,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
51
64
|
// [IGNORE] A `SignedProposerPreferences` matching `bid.slot` and the bid's branch has been
|
|
52
65
|
// seen — i.e. `proposal_slot == bid.slot` AND `dependent_root ==
|
|
53
|
-
// get_proposer_dependent_root(parent_state, compute_epoch_at_slot(bid.slot))
|
|
54
|
-
|
|
55
|
-
//
|
|
56
|
-
//
|
|
66
|
+
// get_proposer_dependent_root(parent_state, compute_epoch_at_slot(bid.slot))`.
|
|
67
|
+
const bidEpoch = computeEpochAtSlot(bid.slot);
|
|
68
|
+
// gloas is always post-Fulu, so `get_proposer_dependent_root` is the post-Fulu (deterministic
|
|
69
|
+
// proposer lookahead) form `block_root_at(start_slot(epoch - MIN_SEED_LOOKAHEAD) - 1)` with
|
|
70
|
+
// `MIN_SEED_LOOKAHEAD == 1` — identical to the attester-shuffling dependent root for the same
|
|
71
|
+
// epoch (both 1-epoch lookahead), hence `getShufflingDependentRoot`. `null` on a
|
|
72
|
+
// unknown/finalized-pruned ancestor or genesis edge → degrade to IGNORE below instead of
|
|
73
|
+
// letting a raw `ForkChoiceError` escape the `GossipActionError` contract.
|
|
74
|
+
const dependentRootHex = (() => {
|
|
75
|
+
try {
|
|
76
|
+
return getShufflingDependentRoot(chain.forkChoice, bidEpoch, computeEpochAtSlot(parentBlock.slot), parentBlock);
|
|
77
|
+
} catch {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
})();
|
|
81
|
+
|
|
82
|
+
if (dependentRootHex === null) {
|
|
83
|
+
// Could not derive the dependent root for this branch (unknown/finalized-pruned ancestor,
|
|
84
|
+
// genesis edge, etc.) → definitionally no matching `SignedProposerPreferences`.
|
|
85
|
+
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
86
|
+
code: ExecutionPayloadBidErrorCode.NO_MATCHING_PROPOSER_PREFERENCES,
|
|
87
|
+
slot: bid.slot,
|
|
88
|
+
parentBlockRoot: parentBlockRootHex,
|
|
89
|
+
dependentRoot: "unknown",
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const proposerPreferences = chain.proposerPreferencesPool.get(bid.slot, dependentRootHex);
|
|
94
|
+
if (proposerPreferences === null) {
|
|
95
|
+
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
96
|
+
code: ExecutionPayloadBidErrorCode.NO_MATCHING_PROPOSER_PREFERENCES,
|
|
97
|
+
slot: bid.slot,
|
|
98
|
+
parentBlockRoot: parentBlockRootHex,
|
|
99
|
+
dependentRoot: dependentRootHex,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
57
102
|
|
|
58
103
|
// [REJECT] `bid.builder_index` is a valid/active builder index -- i.e.
|
|
59
104
|
// `is_active_builder(state, bid.builder_index)` returns `True`.
|
|
@@ -75,10 +120,44 @@ async function validateExecutionPayloadBid(
|
|
|
75
120
|
}
|
|
76
121
|
|
|
77
122
|
// [REJECT] `bid.fee_recipient == proposer_preferences.fee_recipient`.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
123
|
+
if (!byteArrayEquals(bid.feeRecipient, proposerPreferences.message.feeRecipient)) {
|
|
124
|
+
throw new ExecutionPayloadBidError(GossipAction.REJECT, {
|
|
125
|
+
code: ExecutionPayloadBidErrorCode.PROPOSER_PREFERENCES_FEE_RECIPIENT_MISMATCH,
|
|
126
|
+
builderIndex: bid.builderIndex,
|
|
127
|
+
bidFeeRecipient: toHex(bid.feeRecipient),
|
|
128
|
+
expectedFeeRecipient: toHex(proposerPreferences.message.feeRecipient),
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// [IGNORE] `bid.parent_block_hash` is the block hash of a known execution payload in fork
|
|
133
|
+
// choice. Looks up the variant of `bid.parent_block_root` whose payload hash matches
|
|
134
|
+
// `bid.parent_block_hash` — works for both FULL parents (FULL variant carries the delivered
|
|
135
|
+
// payload's hash) and EMPTY parents (EMPTY/PENDING variants carry the inherited parent
|
|
136
|
+
// payload's hash, since the new block doesn't have its own payload). Variant carries the
|
|
137
|
+
// executed payload's gas_limit, which we use as `parent_gas_limit` below.
|
|
138
|
+
const parentPayloadVariant = chain.forkChoice.getBlockHexAndBlockHash(parentBlockRootHex, parentBlockHashHex);
|
|
139
|
+
if (parentPayloadVariant === null || parentPayloadVariant.executionPayloadBlockHash === null) {
|
|
140
|
+
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
141
|
+
code: ExecutionPayloadBidErrorCode.UNKNOWN_PARENT_BLOCK_HASH,
|
|
142
|
+
parentBlockHash: parentBlockHashHex,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// [IGNORE] `is_gas_limit_target_compatible(parent_gas_limit, bid.gas_limit, target_gas_limit)`,
|
|
147
|
+
// where `parent_gas_limit` is the `gas_limit` of the parent execution payload and
|
|
148
|
+
// `target_gas_limit` is `proposer_preferences.target_gas_limit`.
|
|
149
|
+
const bidGasLimit = Number(bid.gasLimit);
|
|
150
|
+
const parentGasLimit = parentPayloadVariant.executionPayloadGasLimit;
|
|
151
|
+
const targetGasLimit = proposerPreferences.message.targetGasLimit;
|
|
152
|
+
if (!isGasLimitTargetCompatible(parentGasLimit, bidGasLimit, targetGasLimit)) {
|
|
153
|
+
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
154
|
+
code: ExecutionPayloadBidErrorCode.PROPOSER_PREFERENCES_GAS_LIMIT_MISMATCH,
|
|
155
|
+
builderIndex: bid.builderIndex,
|
|
156
|
+
bidGasLimit,
|
|
157
|
+
parentGasLimit,
|
|
158
|
+
targetGasLimit,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
82
161
|
|
|
83
162
|
// [REJECT] The length of KZG commitments is less than or equal to the limitation defined in the
|
|
84
163
|
// consensus layer -- i.e. validate that
|
|
@@ -107,11 +186,11 @@ async function validateExecutionPayloadBid(
|
|
|
107
186
|
// [IGNORE] this bid is the highest value bid seen for the tuple
|
|
108
187
|
// `(bid.slot, bid.parent_block_hash, bid.parent_block_root)`.
|
|
109
188
|
const bestBid = chain.executionPayloadBidPool.getBestBid(bid.slot, parentBlockHashHex, parentBlockRootHex);
|
|
110
|
-
if (bestBid !== null && bestBid.value >= bid.value) {
|
|
189
|
+
if (bestBid !== null && bestBid.message.value >= bid.value) {
|
|
111
190
|
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
112
191
|
code: ExecutionPayloadBidErrorCode.BID_TOO_LOW,
|
|
113
192
|
bidValue: bid.value,
|
|
114
|
-
currentHighestBid: bestBid.value,
|
|
193
|
+
currentHighestBid: bestBid.message.value,
|
|
115
194
|
});
|
|
116
195
|
}
|
|
117
196
|
// [IGNORE] `bid.value` is less or equal than the builder's excess balance --
|
|
@@ -124,19 +203,6 @@ async function validateExecutionPayloadBid(
|
|
|
124
203
|
});
|
|
125
204
|
}
|
|
126
205
|
|
|
127
|
-
// [IGNORE] `bid.parent_block_hash` is the block hash of a known execution
|
|
128
|
-
// payload in fork choice.
|
|
129
|
-
// TODO GLOAS: implement this
|
|
130
|
-
|
|
131
|
-
// [IGNORE] `bid.parent_block_root` is the hash tree root of a known beacon
|
|
132
|
-
// block in fork choice.
|
|
133
|
-
if (!chain.forkChoice.hasBlock(bid.parentBlockRoot)) {
|
|
134
|
-
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
135
|
-
code: ExecutionPayloadBidErrorCode.UNKNOWN_BLOCK_ROOT,
|
|
136
|
-
parentBlockRoot: parentBlockRootHex,
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
|
|
140
206
|
// [REJECT] `signed_execution_payload_bid.signature` is valid with respect to the `bid.builder_index`.
|
|
141
207
|
const signatureSet = createSingleSignatureSetFromComponents(
|
|
142
208
|
PublicKey.fromBytes(builder.pubkey),
|
|
@@ -154,4 +220,6 @@ async function validateExecutionPayloadBid(
|
|
|
154
220
|
|
|
155
221
|
// Valid
|
|
156
222
|
chain.seenExecutionPayloadBids.add(bid.slot, bid.builderIndex);
|
|
223
|
+
|
|
224
|
+
return {proposerIndex: proposerPreferences.message.validatorIndex};
|
|
157
225
|
}
|
|
@@ -11,7 +11,7 @@ import {IBeaconChain} from "../index.js";
|
|
|
11
11
|
|
|
12
12
|
export type PayloadAttestationValidationResult = {
|
|
13
13
|
attDataRootHex: RootHex;
|
|
14
|
-
|
|
14
|
+
validatorCommitteeIndices: number[];
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
export async function validateApiPayloadAttestationMessage(
|
|
@@ -80,9 +80,11 @@ async function validatePayloadAttestationMessage(
|
|
|
80
80
|
// [REJECT] The message's validator index is within the payload committee in
|
|
81
81
|
// `get_ptc(state, data.slot)`. The `state` is the head state corresponding to
|
|
82
82
|
// processing the block up to the current slot as determined by the fork choice.
|
|
83
|
-
|
|
83
|
+
// The validator may occupy multiple PTC positions because `compute_ptc` samples
|
|
84
|
+
// by effective balance — collect all of them so duplicate votes are counted.
|
|
85
|
+
const validatorCommitteeIndices = state.getIndicesInPayloadTimelinessCommittee(validatorIndex, data.slot);
|
|
84
86
|
|
|
85
|
-
if (
|
|
87
|
+
if (validatorCommitteeIndices.length === 0) {
|
|
86
88
|
throw new PayloadAttestationError(GossipAction.REJECT, {
|
|
87
89
|
code: PayloadAttestationErrorCode.INVALID_ATTESTER,
|
|
88
90
|
attesterIndex: validatorIndex,
|
|
@@ -115,6 +117,6 @@ async function validatePayloadAttestationMessage(
|
|
|
115
117
|
|
|
116
118
|
return {
|
|
117
119
|
attDataRootHex: toRootHex(ssz.gloas.PayloadAttestationData.hashTreeRoot(data)),
|
|
118
|
-
|
|
120
|
+
validatorCommitteeIndices,
|
|
119
121
|
};
|
|
120
122
|
}
|