@lodestar/beacon-node 1.52.0-dev.b59a889970 → 1.52.0-dev.b6f233b964
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 +4 -3
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/beacon/pool/index.js +1 -1
- 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 +74 -44
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.js +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
- package/lib/chain/chain.d.ts +1 -1
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +18 -21
- package/lib/chain/chain.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 +7 -0
- package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.js +1 -0
- package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
- package/lib/chain/prepareNextSlot.d.ts +45 -0
- package/lib/chain/prepareNextSlot.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +265 -69
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +6 -2
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +54 -64
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
- package/lib/chain/validation/attesterSlashing.js +4 -2
- package/lib/chain/validation/attesterSlashing.js.map +1 -1
- package/lib/chain/validation/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 +21 -5
- package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
- package/lib/chain/validation/proposerSlashing.js +4 -2
- package/lib/chain/validation/proposerSlashing.js.map +1 -1
- package/lib/chain/validation/signatureSets/contributionAndProof.d.ts +2 -2
- package/lib/chain/validation/signatureSets/contributionAndProof.d.ts.map +1 -1
- package/lib/chain/validation/signatureSets/contributionAndProof.js +2 -2
- package/lib/chain/validation/signatureSets/contributionAndProof.js.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommittee.d.ts +2 -2
- package/lib/chain/validation/signatureSets/syncCommittee.d.ts.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommittee.js +2 -2
- package/lib/chain/validation/signatureSets/syncCommittee.js.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts +2 -2
- package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommitteeContribution.js +2 -2
- package/lib/chain/validation/signatureSets/syncCommitteeContribution.js.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts +2 -2
- package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts.map +1 -1
- package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js +2 -2
- package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js.map +1 -1
- package/lib/chain/validation/syncCommittee.d.ts +1 -1
- package/lib/chain/validation/syncCommittee.d.ts.map +1 -1
- package/lib/chain/validation/syncCommittee.js +5 -5
- package/lib/chain/validation/syncCommittee.js.map +1 -1
- package/lib/chain/validation/syncCommitteeContributionAndProof.js +3 -3
- package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
- package/lib/chain/validation/voluntaryExit.d.ts.map +1 -1
- package/lib/chain/validation/voluntaryExit.js +39 -6
- package/lib/chain/validation/voluntaryExit.js.map +1 -1
- package/lib/execution/engine/blockHash.d.ts +12 -0
- package/lib/execution/engine/blockHash.d.ts.map +1 -0
- package/lib/execution/engine/blockHash.js +17 -0
- package/lib/execution/engine/blockHash.js.map +1 -0
- package/lib/execution/engine/http.d.ts +2 -2
- package/lib/execution/engine/http.d.ts.map +1 -1
- package/lib/execution/engine/http.js +13 -7
- package/lib/execution/engine/http.js.map +1 -1
- package/lib/execution/engine/interface.d.ts +16 -3
- package/lib/execution/engine/interface.d.ts.map +1 -1
- package/lib/execution/engine/interface.js +11 -0
- package/lib/execution/engine/interface.js.map +1 -1
- package/lib/execution/engine/jsonRpcHttpClient.d.ts +2 -0
- package/lib/execution/engine/jsonRpcHttpClient.d.ts.map +1 -1
- package/lib/execution/engine/jsonRpcHttpClient.js +14 -6
- package/lib/execution/engine/jsonRpcHttpClient.js.map +1 -1
- package/lib/execution/engine/jsonRpcTransport.d.ts +2 -2
- package/lib/execution/engine/jsonRpcTransport.d.ts.map +1 -1
- package/lib/execution/engine/jsonRpcTransport.js +4 -4
- package/lib/execution/engine/jsonRpcTransport.js.map +1 -1
- package/lib/execution/engine/mock.d.ts.map +1 -1
- package/lib/execution/engine/mock.js +6 -6
- package/lib/execution/engine/mock.js.map +1 -1
- package/lib/execution/engine/payloadIdCache.d.ts +6 -1
- package/lib/execution/engine/payloadIdCache.d.ts.map +1 -1
- package/lib/execution/engine/payloadIdCache.js +7 -2
- package/lib/execution/engine/payloadIdCache.js.map +1 -1
- package/lib/execution/engine/restHttpClient.d.ts.map +1 -1
- package/lib/execution/engine/restHttpClient.js +9 -5
- package/lib/execution/engine/restHttpClient.js.map +1 -1
- package/lib/execution/engine/restTransport.d.ts +2 -2
- package/lib/execution/engine/restTransport.d.ts.map +1 -1
- package/lib/execution/engine/restTransport.js +4 -4
- package/lib/execution/engine/restTransport.js.map +1 -1
- package/lib/execution/engine/signal.d.ts +6 -0
- package/lib/execution/engine/signal.d.ts.map +1 -0
- package/lib/execution/engine/signal.js +24 -0
- package/lib/execution/engine/signal.js.map +1 -0
- package/lib/execution/engine/transport.d.ts +2 -2
- package/lib/execution/engine/transport.d.ts.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/metrics/metrics/beacon.d.ts +5 -0
- package/lib/metrics/metrics/beacon.d.ts.map +1 -1
- package/lib/metrics/metrics/beacon.js +5 -0
- package/lib/metrics/metrics/beacon.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +1 -0
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +5 -0
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/core/events.d.ts +6 -2
- package/lib/network/core/events.d.ts.map +1 -1
- package/lib/network/core/events.js +9 -0
- package/lib/network/core/events.js.map +1 -1
- package/lib/network/core/networkCoreWorkerHandler.d.ts.map +1 -1
- package/lib/network/core/networkCoreWorkerHandler.js +3 -2
- package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
- package/lib/network/peers/peerManager.d.ts.map +1 -1
- package/lib/network/peers/peerManager.js +10 -1
- package/lib/network/peers/peerManager.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
- package/lib/sync/range/batch.d.ts +4 -0
- package/lib/sync/range/batch.d.ts.map +1 -1
- package/lib/sync/range/batch.js +12 -0
- package/lib/sync/range/batch.js.map +1 -1
- package/lib/sync/range/chain.d.ts +17 -2
- package/lib/sync/range/chain.d.ts.map +1 -1
- package/lib/sync/range/chain.js +52 -19
- 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 +1 -0
- package/lib/sync/range/range.js.map +1 -1
- package/lib/sync/range/utils/batches.d.ts +20 -4
- package/lib/sync/range/utils/batches.d.ts.map +1 -1
- package/lib/sync/range/utils/batches.js +31 -13
- package/lib/sync/range/utils/batches.js.map +1 -1
- package/lib/sync/range/utils/peerBalancer.d.ts +1 -1
- package/lib/sync/range/utils/peerBalancer.d.ts.map +1 -1
- package/lib/sync/range/utils/peerBalancer.js +5 -2
- package/lib/sync/range/utils/peerBalancer.js.map +1 -1
- package/lib/sync/types.d.ts +2 -0
- package/lib/sync/types.d.ts.map +1 -1
- package/lib/sync/types.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +60 -19
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/downloadByRange.d.ts +8 -0
- package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRange.js +43 -23
- package/lib/sync/utils/downloadByRange.js.map +1 -1
- package/lib/util/asyncIterableToEvents.d.ts +20 -3
- package/lib/util/asyncIterableToEvents.d.ts.map +1 -1
- package/lib/util/asyncIterableToEvents.js +76 -20
- package/lib/util/asyncIterableToEvents.js.map +1 -1
- package/lib/util/dataColumns.d.ts +1 -1
- package/lib/util/dataColumns.d.ts.map +1 -1
- package/lib/util/dataColumns.js +4 -1
- package/lib/util/dataColumns.js.map +1 -1
- package/package.json +17 -17
- package/src/api/impl/beacon/blocks/index.ts +4 -3
- package/src/api/impl/beacon/pool/index.ts +1 -1
- package/src/api/impl/validator/index.ts +107 -61
- package/src/chain/archiveStore/utils/archiveBlocks.ts +1 -1
- package/src/chain/chain.ts +17 -41
- package/src/chain/errors/executionPayloadBid.ts +6 -0
- package/src/chain/errors/executionPayloadEnvelope.ts +8 -0
- package/src/chain/prepareNextSlot.ts +347 -89
- package/src/chain/produceBlock/produceBlockBody.ts +69 -80
- package/src/chain/validation/attesterSlashing.ts +4 -2
- package/src/chain/validation/executionPayloadBid.ts +20 -2
- package/src/chain/validation/executionPayloadEnvelope.ts +28 -5
- package/src/chain/validation/proposerSlashing.ts +4 -2
- package/src/chain/validation/signatureSets/contributionAndProof.ts +4 -6
- package/src/chain/validation/signatureSets/syncCommittee.ts +2 -3
- package/src/chain/validation/signatureSets/syncCommitteeContribution.ts +2 -3
- package/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts +2 -3
- package/src/chain/validation/syncCommittee.ts +3 -5
- package/src/chain/validation/syncCommitteeContributionAndProof.ts +3 -3
- package/src/chain/validation/voluntaryExit.ts +44 -6
- package/src/execution/engine/blockHash.ts +27 -0
- package/src/execution/engine/http.ts +18 -10
- package/src/execution/engine/interface.ts +18 -3
- package/src/execution/engine/jsonRpcHttpClient.ts +26 -14
- package/src/execution/engine/jsonRpcTransport.ts +8 -4
- package/src/execution/engine/mock.ts +13 -8
- package/src/execution/engine/payloadIdCache.ts +12 -4
- package/src/execution/engine/restHttpClient.ts +17 -11
- package/src/execution/engine/restTransport.ts +5 -4
- package/src/execution/engine/signal.ts +28 -0
- package/src/execution/engine/transport.ts +3 -2
- package/src/index.ts +6 -1
- package/src/metrics/metrics/beacon.ts +9 -0
- package/src/metrics/metrics/lodestar.ts +5 -0
- package/src/network/core/events.ts +12 -0
- package/src/network/core/networkCoreWorkerHandler.ts +6 -2
- package/src/network/peers/peerManager.ts +14 -1
- package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +1 -1
- package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +1 -1
- package/src/sync/range/batch.ts +13 -0
- package/src/sync/range/chain.ts +64 -17
- package/src/sync/range/range.ts +1 -0
- package/src/sync/range/utils/batches.ts +38 -13
- package/src/sync/range/utils/peerBalancer.ts +4 -1
- package/src/sync/types.ts +2 -0
- package/src/sync/unknownBlock.ts +65 -21
- package/src/sync/utils/downloadByRange.ts +60 -26
- package/src/util/asyncIterableToEvents.ts +100 -21
- package/src/util/dataColumns.ts +4 -1
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
G2_POINT_AT_INFINITY,
|
|
25
25
|
IBeaconStateView,
|
|
26
26
|
type IBeaconStateViewBellatrix,
|
|
27
|
+
type IBeaconStateViewGloas,
|
|
27
28
|
computeEpochAtSlot,
|
|
28
29
|
computeTimeAtSlot,
|
|
29
30
|
getExpectedGasLimit,
|
|
@@ -111,6 +112,12 @@ export type BlockAttributes = {
|
|
|
111
112
|
graffiti: Bytes32;
|
|
112
113
|
slot: Slot;
|
|
113
114
|
parentBlock: ProtoBlock;
|
|
115
|
+
// the state of parentBlock processed to slot
|
|
116
|
+
parentState: IBeaconStateView;
|
|
117
|
+
// parentStateWithPayload is the same as parentState for pre-gloas or if building on EMPTY
|
|
118
|
+
parentStateWithPayload: IBeaconStateView;
|
|
119
|
+
// Parent's execution requests, undefined pre-gloas.
|
|
120
|
+
parentExecutionRequests?: gloas.ExecutionRequests;
|
|
114
121
|
feeRecipient?: string;
|
|
115
122
|
/** Verify that a locally produced execution payload uses `feeRecipient`. */
|
|
116
123
|
strictFeeRecipientCheck?: boolean;
|
|
@@ -175,32 +182,9 @@ export type ProduceResult =
|
|
|
175
182
|
| ProduceFullPhase0
|
|
176
183
|
| ProduceBlinded;
|
|
177
184
|
|
|
178
|
-
/**
|
|
179
|
-
* Drop voluntary exits that `parent_execution_requests` have invalidated (e.g. a withdrawal
|
|
180
|
-
* request initiating an exit on the same validator). Op pool selected against the unapplied
|
|
181
|
-
* state, so re-validate against the post-apply state to avoid producing an invalid block.
|
|
182
|
-
*
|
|
183
|
-
* `getStateAfterParentPayload` is a thunk so the post-apply state is only materialized when
|
|
184
|
-
* actually needed (i.e. when extending the parent payload and there are exits to filter).
|
|
185
|
-
*/
|
|
186
|
-
function maybeFilterInvalidatedVoluntaryExits(
|
|
187
|
-
commonBlockBody: CommonBlockBody,
|
|
188
|
-
isExtendingPayload: boolean,
|
|
189
|
-
getStateAfterParentPayload: () => IBeaconStateViewBellatrix
|
|
190
|
-
): CommonBlockBody["voluntaryExits"] {
|
|
191
|
-
if (!isExtendingPayload || commonBlockBody.voluntaryExits.length === 0) {
|
|
192
|
-
return commonBlockBody.voluntaryExits;
|
|
193
|
-
}
|
|
194
|
-
const state = getStateAfterParentPayload();
|
|
195
|
-
return commonBlockBody.voluntaryExits.filter((signedVoluntaryExit) =>
|
|
196
|
-
state.isValidVoluntaryExit(signedVoluntaryExit, false)
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
185
|
export async function produceBlockBody<T extends BlockType>(
|
|
201
186
|
this: BeaconChain,
|
|
202
187
|
blockType: T,
|
|
203
|
-
currentState: IBeaconStateView,
|
|
204
188
|
blockAttr: BlockAttributes & {
|
|
205
189
|
proposerIndex: ValidatorIndex;
|
|
206
190
|
proposerPubKey: BLSPubkey;
|
|
@@ -221,6 +205,9 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
221
205
|
proposerPubKey,
|
|
222
206
|
commonBlockBodyPromise,
|
|
223
207
|
builderBid,
|
|
208
|
+
parentState,
|
|
209
|
+
parentStateWithPayload,
|
|
210
|
+
parentExecutionRequests,
|
|
224
211
|
} = blockAttr;
|
|
225
212
|
let executionPayloadValue: Wei;
|
|
226
213
|
let blockBody: AssembledBodyType<T>;
|
|
@@ -242,17 +229,17 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
242
229
|
this.logger.verbose("Producing beacon block body", logMeta);
|
|
243
230
|
|
|
244
231
|
if (builderBid !== undefined) {
|
|
245
|
-
if (!isStatePostGloas(
|
|
246
|
-
throw new Error(
|
|
232
|
+
if (!isStatePostGloas(parentState)) {
|
|
233
|
+
throw new Error(`Expected Gloas state for builder bid block production slot=${blockSlot}`);
|
|
234
|
+
}
|
|
235
|
+
if (parentExecutionRequests === undefined) {
|
|
236
|
+
throw new Error(`Expected parentExecutionRequests for gloas block production slot=${blockSlot}`);
|
|
247
237
|
}
|
|
248
238
|
|
|
249
239
|
const isExtendingPayload = byteArrayEquals(
|
|
250
240
|
builderBid.message.parentBlockHash,
|
|
251
|
-
|
|
241
|
+
parentState.latestExecutionPayloadBid.blockHash
|
|
252
242
|
);
|
|
253
|
-
const parentExecutionRequests = isExtendingPayload
|
|
254
|
-
? await this.getParentExecutionRequests(parentBlock.slot, parentBlock.blockRoot)
|
|
255
|
-
: ssz.gloas.ExecutionRequests.defaultValue();
|
|
256
243
|
executionPayloadValue = (BigInt(builderBid.message.value) + builderBid.message.executionPayment) * GWEI_TO_WEI;
|
|
257
244
|
|
|
258
245
|
const commonBlockBody = await commonBlockBodyPromise;
|
|
@@ -262,10 +249,9 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
262
249
|
parentBlock.blockRoot,
|
|
263
250
|
blockSlot - 1
|
|
264
251
|
);
|
|
252
|
+
// parentExecutionRequests fetched once by the entrypoint (isExtendingPayload aligns with the
|
|
253
|
+
// build-on-full decision used to select this bid; default value when building on an empty parent)
|
|
265
254
|
gloasBody.parentExecutionRequests = parentExecutionRequests;
|
|
266
|
-
gloasBody.voluntaryExits = maybeFilterInvalidatedVoluntaryExits(commonBlockBody, isExtendingPayload, () =>
|
|
267
|
-
currentState.withParentPayloadApplied(parentExecutionRequests)
|
|
268
|
-
);
|
|
269
255
|
blockBody = gloasBody as AssembledBodyType<T>;
|
|
270
256
|
|
|
271
257
|
this.logger.verbose("Produced block with builder bid", {
|
|
@@ -278,8 +264,11 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
278
264
|
isExtendingPayload,
|
|
279
265
|
});
|
|
280
266
|
} else if (isForkPostGloas(fork)) {
|
|
281
|
-
if (!isStatePostGloas(
|
|
282
|
-
throw new Error(
|
|
267
|
+
if (!isStatePostGloas(parentState)) {
|
|
268
|
+
throw new Error(`Expected Gloas state for Gloas block production slot=${blockSlot}`);
|
|
269
|
+
}
|
|
270
|
+
if (parentExecutionRequests === undefined) {
|
|
271
|
+
throw new Error(`Expected parentExecutionRequests for gloas block production slot=${blockSlot}`);
|
|
283
272
|
}
|
|
284
273
|
|
|
285
274
|
// TODO GLOAS: support non self-building here, the block type differentiation between
|
|
@@ -299,20 +288,16 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
299
288
|
|
|
300
289
|
// Get execution payload from EL
|
|
301
290
|
let parentBlockHash: Bytes32;
|
|
302
|
-
|
|
303
|
-
//
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
const isBuildingOnFull = this.forkChoice.shouldBuildOnFull(parentBlock, blockSlot);
|
|
291
|
+
const stateAfterParentPayload = parentStateWithPayload as IBeaconStateViewGloas;
|
|
292
|
+
// Spec: should_build_on_full(store, head, slot), decided by the caller when applying the parent payload
|
|
293
|
+
const isBuildingOnFull = byteArrayEquals(
|
|
294
|
+
stateAfterParentPayload.latestBlockHash,
|
|
295
|
+
parentState.latestExecutionPayloadBid.blockHash
|
|
296
|
+
);
|
|
309
297
|
if (isBuildingOnFull) {
|
|
310
|
-
parentBlockHash =
|
|
311
|
-
parentExecutionRequests = await this.getParentExecutionRequests(parentBlock.slot, parentBlock.blockRoot);
|
|
312
|
-
stateAfterParentPayload = currentState.withParentPayloadApplied(parentExecutionRequests);
|
|
298
|
+
parentBlockHash = parentState.latestExecutionPayloadBid.blockHash;
|
|
313
299
|
} else {
|
|
314
|
-
parentBlockHash =
|
|
315
|
-
parentExecutionRequests = ssz.gloas.ExecutionRequests.defaultValue();
|
|
300
|
+
parentBlockHash = parentState.latestExecutionPayloadBid.parentBlockHash;
|
|
316
301
|
}
|
|
317
302
|
const prepareRes = await prepareExecutionPayload(
|
|
318
303
|
this,
|
|
@@ -326,7 +311,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
326
311
|
feeRecipient
|
|
327
312
|
);
|
|
328
313
|
|
|
329
|
-
const {prepType, payloadId} = prepareRes;
|
|
314
|
+
const {prepType, payloadId, preparedAtMs} = prepareRes;
|
|
330
315
|
Object.assign(logMeta, {executionPayloadPrepType: prepType});
|
|
331
316
|
|
|
332
317
|
this.logger.verbose("Prepared execution payload from engine", {
|
|
@@ -339,9 +324,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
339
324
|
isBuildingOnFull,
|
|
340
325
|
});
|
|
341
326
|
|
|
342
|
-
|
|
343
|
-
await sleep(PAYLOAD_GENERATION_TIME_MS);
|
|
344
|
-
}
|
|
327
|
+
await waitForPayloadGeneration(preparedAtMs);
|
|
345
328
|
|
|
346
329
|
this.logger.verbose("Fetching execution payload from engine", {slot: blockSlot, payloadId});
|
|
347
330
|
const payloadRes = await this.executionEngine.getPayload(fork, payloadId);
|
|
@@ -379,7 +362,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
379
362
|
parentBlockHash,
|
|
380
363
|
parentBlockRoot,
|
|
381
364
|
blockHash: executionPayload.blockHash,
|
|
382
|
-
prevRandao:
|
|
365
|
+
prevRandao: parentState.getRandaoMix(parentState.epoch),
|
|
383
366
|
feeRecipient: executionPayload.feeRecipient,
|
|
384
367
|
gasLimit: BigInt(executionPayload.gasLimit),
|
|
385
368
|
builderIndex: BUILDER_INDEX_SELF_BUILD,
|
|
@@ -416,12 +399,8 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
416
399
|
parentBlock.blockRoot,
|
|
417
400
|
blockSlot - 1
|
|
418
401
|
);
|
|
402
|
+
// parentExecutionRequests fetched once by the entrypoint (default value when building on an empty parent)
|
|
419
403
|
gloasBody.parentExecutionRequests = parentExecutionRequests;
|
|
420
|
-
gloasBody.voluntaryExits = maybeFilterInvalidatedVoluntaryExits(
|
|
421
|
-
commonBlockBody,
|
|
422
|
-
isBuildingOnFull,
|
|
423
|
-
() => stateAfterParentPayload
|
|
424
|
-
);
|
|
425
404
|
blockBody = gloasBody as AssembledBodyType<T>;
|
|
426
405
|
|
|
427
406
|
// Store execution payload data required to construct execution payload envelope later
|
|
@@ -451,7 +430,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
451
430
|
shouldOverrideBuilder,
|
|
452
431
|
});
|
|
453
432
|
} else if (isForkPostBellatrix(fork)) {
|
|
454
|
-
if (!isStatePostBellatrix(
|
|
433
|
+
if (!isStatePostBellatrix(parentState)) {
|
|
455
434
|
throw new Error("Expected Bellatrix state for execution block production");
|
|
456
435
|
}
|
|
457
436
|
|
|
@@ -480,10 +459,10 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
480
459
|
this.logger,
|
|
481
460
|
fork,
|
|
482
461
|
parentBlockRoot,
|
|
483
|
-
|
|
462
|
+
parentState.latestExecutionPayloadHeader.blockHash,
|
|
484
463
|
safeBlockHash,
|
|
485
464
|
finalizedBlockHash ?? ZERO_HASH_HEX,
|
|
486
|
-
|
|
465
|
+
parentState,
|
|
487
466
|
executionBuilder.issueLocalFcUWithFeeRecipient
|
|
488
467
|
);
|
|
489
468
|
}
|
|
@@ -495,7 +474,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
495
474
|
slot: blockSlot,
|
|
496
475
|
proposerPubKey: toHex(proposerPubKey),
|
|
497
476
|
});
|
|
498
|
-
const headerRes = await prepareExecutionPayloadHeader(this, fork,
|
|
477
|
+
const headerRes = await prepareExecutionPayloadHeader(this, fork, parentState, proposerPubKey);
|
|
499
478
|
|
|
500
479
|
endExecutionPayloadHeader?.({
|
|
501
480
|
step: BlockProductionStep.executionPayload,
|
|
@@ -530,7 +509,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
530
509
|
});
|
|
531
510
|
} else {
|
|
532
511
|
const headerGasLimit = builderRes.header.gasLimit;
|
|
533
|
-
const parentGasLimit =
|
|
512
|
+
const parentGasLimit = parentState.latestExecutionPayloadHeader.gasLimit;
|
|
534
513
|
const expectedGasLimit = getExpectedGasLimit(parentGasLimit, targetGasLimit);
|
|
535
514
|
|
|
536
515
|
const lowerBound = Math.min(parentGasLimit, expectedGasLimit);
|
|
@@ -584,24 +563,17 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
584
563
|
this.logger,
|
|
585
564
|
fork,
|
|
586
565
|
parentBlockRoot,
|
|
587
|
-
|
|
566
|
+
parentState.latestExecutionPayloadHeader.blockHash,
|
|
588
567
|
safeBlockHash,
|
|
589
568
|
finalizedBlockHash ?? ZERO_HASH_HEX,
|
|
590
|
-
|
|
569
|
+
parentState,
|
|
591
570
|
feeRecipient
|
|
592
571
|
);
|
|
593
572
|
|
|
594
|
-
const {prepType, payloadId} = prepareRes;
|
|
573
|
+
const {prepType, payloadId, preparedAtMs} = prepareRes;
|
|
595
574
|
Object.assign(logMeta, {executionPayloadPrepType: prepType});
|
|
596
575
|
|
|
597
|
-
|
|
598
|
-
// Wait for 500ms to allow EL to add some txs to the payload
|
|
599
|
-
// the pitfalls of this have been put forward here, but 500ms delay for block proposal
|
|
600
|
-
// seems marginal even with unhealthy network
|
|
601
|
-
//
|
|
602
|
-
// See: https://discord.com/channels/595666850260713488/892088344438255616/1009882079632314469
|
|
603
|
-
await sleep(PAYLOAD_GENERATION_TIME_MS);
|
|
604
|
-
}
|
|
576
|
+
await waitForPayloadGeneration(preparedAtMs);
|
|
605
577
|
|
|
606
578
|
this.logger.verbose("Fetching execution payload from engine", {slot: blockSlot, payloadId});
|
|
607
579
|
const payloadRes = await this.executionEngine.getPayload(fork, payloadId);
|
|
@@ -763,7 +735,7 @@ export async function prepareExecutionPayload(
|
|
|
763
735
|
suggestedFeeRecipient: string,
|
|
764
736
|
/** Attributes already computed for the same state and fee recipient, e.g. for the SSE event */
|
|
765
737
|
payloadAttributes?: PayloadAttributes
|
|
766
|
-
): Promise<{prepType: PayloadPreparationType; payloadId: PayloadId}> {
|
|
738
|
+
): Promise<{prepType: PayloadPreparationType; payloadId: PayloadId; preparedAtMs: number}> {
|
|
767
739
|
const timestamp = computeTimeAtSlot(chain.config, state.slot, state.genesisTime);
|
|
768
740
|
const prevRandao = state.getRandaoMix(state.epoch);
|
|
769
741
|
|
|
@@ -792,10 +764,11 @@ export async function prepareExecutionPayload(
|
|
|
792
764
|
// the EL returns Syncing on this request to prepare a payload
|
|
793
765
|
// TODO: Handle only this case, DO NOT put a generic try / catch that discards all errors
|
|
794
766
|
let payloadId: PayloadId | null;
|
|
767
|
+
let preparedAtMs: number;
|
|
795
768
|
let prepType: PayloadPreparationType;
|
|
796
769
|
|
|
797
770
|
if (payloadIdCached) {
|
|
798
|
-
payloadId = payloadIdCached;
|
|
771
|
+
({payloadId, preparedAtMs} = payloadIdCached);
|
|
799
772
|
prepType = PayloadPreparationType.Cached;
|
|
800
773
|
} else {
|
|
801
774
|
// If there was a payload assigned to this timestamp, it would imply that there some sort
|
|
@@ -821,6 +794,7 @@ export async function prepareExecutionPayload(
|
|
|
821
794
|
feeRecipient: suggestedFeeRecipient,
|
|
822
795
|
})
|
|
823
796
|
);
|
|
797
|
+
preparedAtMs = performance.now();
|
|
824
798
|
logger.verbose("Prepared payload id from execution engine", {payloadId});
|
|
825
799
|
}
|
|
826
800
|
|
|
@@ -833,7 +807,23 @@ export async function prepareExecutionPayload(
|
|
|
833
807
|
// We are only returning payloadId here because prepareExecutionPayload is also called from
|
|
834
808
|
// prepareNextSlot, which is an advance call to execution engine to start building payload
|
|
835
809
|
// Actual payload isn't produced till getPayload is called.
|
|
836
|
-
return {payloadId, prepType};
|
|
810
|
+
return {payloadId, prepType, preparedAtMs};
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
* Give the engine PAYLOAD_GENERATION_TIME_MS since the payload was requested before fetching it. A payload prepared
|
|
815
|
+
* in advance usually had seconds, one prepared or re-prepared right before the slot gets the same time as a fresh one.
|
|
816
|
+
*
|
|
817
|
+
* The pitfalls of this delay have been put forward here, but 500ms delay for block proposal
|
|
818
|
+
* seems marginal even with unhealthy network
|
|
819
|
+
*
|
|
820
|
+
* See: https://discord.com/channels/595666850260713488/892088344438255616/1009882079632314469
|
|
821
|
+
*/
|
|
822
|
+
async function waitForPayloadGeneration(preparedAtMs: number): Promise<void> {
|
|
823
|
+
const remainingMs = PAYLOAD_GENERATION_TIME_MS - (performance.now() - preparedAtMs);
|
|
824
|
+
if (remainingMs > 0) {
|
|
825
|
+
await sleep(remainingMs);
|
|
826
|
+
}
|
|
837
827
|
}
|
|
838
828
|
|
|
839
829
|
async function prepareExecutionPayloadHeader(
|
|
@@ -1102,8 +1092,7 @@ export function getPooledProposerPreferences(
|
|
|
1102
1092
|
export async function produceCommonBlockBody<T extends BlockType>(
|
|
1103
1093
|
this: BeaconChain,
|
|
1104
1094
|
blockType: T,
|
|
1105
|
-
|
|
1106
|
-
{randaoReveal, graffiti, slot, parentBlock}: BlockAttributes
|
|
1095
|
+
{randaoReveal, graffiti, slot, parentBlock, parentStateWithPayload}: BlockAttributes
|
|
1107
1096
|
): Promise<CommonBlockBody> {
|
|
1108
1097
|
const stepsMetrics =
|
|
1109
1098
|
blockType === BlockType.Full
|
|
@@ -1124,7 +1113,7 @@ export async function produceCommonBlockBody<T extends BlockType>(
|
|
|
1124
1113
|
// }
|
|
1125
1114
|
// }
|
|
1126
1115
|
const [attesterSlashings, proposerSlashings, voluntaryExits, blsToExecutionChanges] =
|
|
1127
|
-
this.opPool.getSlashingsAndExits(
|
|
1116
|
+
this.opPool.getSlashingsAndExits(parentStateWithPayload, blockType, this.metrics);
|
|
1128
1117
|
|
|
1129
1118
|
const endAttestations = stepsMetrics?.startTimer();
|
|
1130
1119
|
// TODO: extract to a separate BeaconChain method to coordinate the 2 op-pools
|
|
@@ -1132,7 +1121,7 @@ export async function produceCommonBlockBody<T extends BlockType>(
|
|
|
1132
1121
|
fork,
|
|
1133
1122
|
this.forkChoice,
|
|
1134
1123
|
this.shufflingCache,
|
|
1135
|
-
|
|
1124
|
+
parentStateWithPayload,
|
|
1136
1125
|
this.singleAttestationPool
|
|
1137
1126
|
);
|
|
1138
1127
|
endAttestations?.({
|
|
@@ -1163,7 +1152,7 @@ export async function produceCommonBlockBody<T extends BlockType>(
|
|
|
1163
1152
|
};
|
|
1164
1153
|
|
|
1165
1154
|
if (!isForkPostHeze(fork)) {
|
|
1166
|
-
commonBlockBody.eth1Data =
|
|
1155
|
+
commonBlockBody.eth1Data = parentStateWithPayload.eth1Data;
|
|
1167
1156
|
commonBlockBody.deposits = [];
|
|
1168
1157
|
}
|
|
1169
1158
|
|
|
@@ -61,8 +61,10 @@ export async function validateAttesterSlashing(
|
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
const
|
|
64
|
+
// Head state may lag behind a fork transition, verify against the fork of the clock slot
|
|
65
|
+
const currentSlot = chain.clock.currentSlot;
|
|
66
|
+
const signatureSets = getAttesterSlashingSignatureSets(chain.config, currentSlot, attesterSlashing);
|
|
67
|
+
const verifiedDomains = getAttesterSlashingSignatureDomains(chain.config, currentSlot, attesterSlashing);
|
|
66
68
|
if (!(await chain.bls.verifySignatureSets(signatureSets, {batchable: true, priority: prioritizeBls}))) {
|
|
67
69
|
throw new AttesterSlashingError(GossipAction.REJECT, {
|
|
68
70
|
code: AttesterSlashingErrorCode.INVALID_SIGNATURE,
|
|
@@ -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)) &&
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from "@lodestar/state-transition";
|
|
8
8
|
import {gloas, ssz} from "@lodestar/types";
|
|
9
9
|
import {byteArrayEquals, toRootHex} from "@lodestar/utils";
|
|
10
|
+
import {computeExecutionBlockHash} from "../../execution/engine/blockHash.js";
|
|
10
11
|
import {
|
|
11
12
|
getBeaconBlockRootFromExecutionPayloadEnvelopeSerialized,
|
|
12
13
|
getSlotFromExecutionPayloadEnvelopeSerialized,
|
|
@@ -55,7 +56,7 @@ export function validateGossipExecutionPayloadEnvelopeSerialized(
|
|
|
55
56
|
|
|
56
57
|
const maxTransactionCount = getMaxTransactionCount(chain, block, payloadInput);
|
|
57
58
|
if (BigInt(transactionCount) > maxTransactionCount) {
|
|
58
|
-
throw new ExecutionPayloadEnvelopeError(GossipAction.
|
|
59
|
+
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
59
60
|
code: ExecutionPayloadEnvelopeErrorCode.TOO_MANY_TRANSACTIONS,
|
|
60
61
|
slot,
|
|
61
62
|
root: blockRootHex,
|
|
@@ -199,12 +200,13 @@ async function validateExecutionPayloadEnvelope(
|
|
|
199
200
|
});
|
|
200
201
|
}
|
|
201
202
|
|
|
202
|
-
//
|
|
203
|
-
|
|
204
|
-
//
|
|
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
|
|
205
207
|
const maxTransactionCount = getMaxTransactionCount(chain, block, payloadInput);
|
|
206
208
|
if (BigInt(payload.transactions.length) > maxTransactionCount) {
|
|
207
|
-
throw new ExecutionPayloadEnvelopeError(GossipAction.
|
|
209
|
+
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
208
210
|
code: ExecutionPayloadEnvelopeErrorCode.TOO_MANY_TRANSACTIONS,
|
|
209
211
|
slot: payload.slotNumber,
|
|
210
212
|
root: blockRootHex,
|
|
@@ -251,6 +253,8 @@ async function validateExecutionPayloadEnvelope(
|
|
|
251
253
|
}
|
|
252
254
|
|
|
253
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.
|
|
254
258
|
for (let i = 0; i < payload.transactions.length; i++) {
|
|
255
259
|
if (payload.transactions.getSize(i) === 0) {
|
|
256
260
|
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
@@ -275,6 +279,25 @@ async function validateExecutionPayloadEnvelope(
|
|
|
275
279
|
});
|
|
276
280
|
}
|
|
277
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
|
+
|
|
278
301
|
// [REJECT] `signed_execution_payload_envelope.signature` is valid as verified
|
|
279
302
|
// by `verify_execution_payload_envelope_signature`.
|
|
280
303
|
const signatureSet = getExecutionPayloadEnvelopeSignatureSet(
|
|
@@ -46,8 +46,10 @@ async function validateProposerSlashing(
|
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
const
|
|
49
|
+
// Head state may lag behind a fork transition, verify against the fork of the clock slot
|
|
50
|
+
const currentSlot = chain.clock.currentSlot;
|
|
51
|
+
const signatureSets = getProposerSlashingSignatureSets(chain.config, currentSlot, proposerSlashing);
|
|
52
|
+
const verifiedDomain = getProposerSlashingSignatureDomain(chain.config, currentSlot, proposerSlashing);
|
|
51
53
|
if (!(await chain.bls.verifySignatureSets(signatureSets, {batchable: true, priority: prioritizeBls}))) {
|
|
52
54
|
throw new ProposerSlashingError(GossipAction.REJECT, {
|
|
53
55
|
code: ProposerSlashingErrorCode.INVALID_SIGNATURE,
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import {BeaconConfig} from "@lodestar/config";
|
|
2
2
|
import {DOMAIN_CONTRIBUTION_AND_PROOF} from "@lodestar/params";
|
|
3
|
-
import {
|
|
3
|
+
import {ISignatureSet, SignatureSetType, computeSigningRoot} from "@lodestar/state-transition";
|
|
4
4
|
import {altair, ssz} from "@lodestar/types";
|
|
5
5
|
|
|
6
6
|
export function getContributionAndProofSignatureSet(
|
|
7
7
|
config: BeaconConfig,
|
|
8
|
-
state: IBeaconStateView,
|
|
9
8
|
signedContributionAndProof: altair.SignedContributionAndProof
|
|
10
9
|
): ISignatureSet {
|
|
11
|
-
const domain = config.
|
|
12
|
-
|
|
13
|
-
DOMAIN_CONTRIBUTION_AND_PROOF
|
|
14
|
-
signedContributionAndProof.message.contribution.slot
|
|
10
|
+
const domain = config.getDomainAtFork(
|
|
11
|
+
config.getForkName(signedContributionAndProof.message.contribution.slot),
|
|
12
|
+
DOMAIN_CONTRIBUTION_AND_PROOF
|
|
15
13
|
);
|
|
16
14
|
const signingData = signedContributionAndProof.message;
|
|
17
15
|
return {
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import {BeaconConfig} from "@lodestar/config";
|
|
2
2
|
import {DOMAIN_SYNC_COMMITTEE} from "@lodestar/params";
|
|
3
|
-
import {
|
|
3
|
+
import {ISignatureSet, SignatureSetType, computeSigningRoot} from "@lodestar/state-transition";
|
|
4
4
|
import {altair, ssz} from "@lodestar/types";
|
|
5
5
|
|
|
6
6
|
export function getSyncCommitteeSignatureSet(
|
|
7
7
|
config: BeaconConfig,
|
|
8
|
-
state: IBeaconStateView,
|
|
9
8
|
syncCommittee: altair.SyncCommitteeMessage
|
|
10
9
|
): ISignatureSet {
|
|
11
|
-
const domain = config.
|
|
10
|
+
const domain = config.getDomainAtFork(config.getForkName(syncCommittee.slot), DOMAIN_SYNC_COMMITTEE);
|
|
12
11
|
|
|
13
12
|
return {
|
|
14
13
|
type: SignatureSetType.indexed,
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import {BeaconConfig} from "@lodestar/config";
|
|
2
2
|
import {DOMAIN_SYNC_COMMITTEE} from "@lodestar/params";
|
|
3
|
-
import {
|
|
3
|
+
import {ISignatureSet, SignatureSetType, computeSigningRoot} from "@lodestar/state-transition";
|
|
4
4
|
import {altair, ssz} from "@lodestar/types";
|
|
5
5
|
|
|
6
6
|
export function getSyncCommitteeContributionSignatureSet(
|
|
7
7
|
config: BeaconConfig,
|
|
8
|
-
state: IBeaconStateView,
|
|
9
8
|
contribution: altair.SyncCommitteeContribution,
|
|
10
9
|
participantIndices: number[]
|
|
11
10
|
): ISignatureSet {
|
|
12
|
-
const domain = config.
|
|
11
|
+
const domain = config.getDomainAtFork(config.getForkName(contribution.slot), DOMAIN_SYNC_COMMITTEE);
|
|
13
12
|
return {
|
|
14
13
|
type: SignatureSetType.aggregate,
|
|
15
14
|
indices: participantIndices,
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import {BeaconConfig} from "@lodestar/config";
|
|
2
2
|
import {DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF} from "@lodestar/params";
|
|
3
|
-
import {
|
|
3
|
+
import {ISignatureSet, SignatureSetType, computeSigningRoot} from "@lodestar/state-transition";
|
|
4
4
|
import {altair, ssz} from "@lodestar/types";
|
|
5
5
|
|
|
6
6
|
export function getSyncCommitteeSelectionProofSignatureSet(
|
|
7
7
|
config: BeaconConfig,
|
|
8
|
-
state: IBeaconStateView,
|
|
9
8
|
contributionAndProof: altair.ContributionAndProof
|
|
10
9
|
): ISignatureSet {
|
|
11
10
|
const slot = contributionAndProof.contribution.slot;
|
|
12
|
-
const domain = config.
|
|
11
|
+
const domain = config.getDomainAtFork(config.getForkName(slot), DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF);
|
|
13
12
|
const signingData: altair.SyncAggregatorSelectionData = {
|
|
14
13
|
slot,
|
|
15
14
|
subcommitteeIndex: contributionAndProof.contribution.subcommitteeIndex,
|
|
@@ -40,7 +40,7 @@ export async function validateGossipSyncCommittee(
|
|
|
40
40
|
// > Checked in validateGossipSyncCommitteeExceptSig()
|
|
41
41
|
|
|
42
42
|
// [REJECT] The signature is valid for the message beacon_block_root for the validator referenced by validator_index.
|
|
43
|
-
await validateSyncCommitteeSigOnly(chain,
|
|
43
|
+
await validateSyncCommitteeSigOnly(chain, syncCommittee);
|
|
44
44
|
|
|
45
45
|
// Re-check after the await: concurrent messages from the same validator all pass the check above.
|
|
46
46
|
// Metrics were already counted by the first check.
|
|
@@ -89,11 +89,10 @@ function assertSyncCommitteeMessageNotKnown(
|
|
|
89
89
|
|
|
90
90
|
export async function validateApiSyncCommittee(
|
|
91
91
|
chain: IBeaconChain,
|
|
92
|
-
headState: IBeaconStateView,
|
|
93
92
|
syncCommittee: altair.SyncCommitteeMessage
|
|
94
93
|
): Promise<void> {
|
|
95
94
|
const prioritizeBls = true;
|
|
96
|
-
return validateSyncCommitteeSigOnly(chain,
|
|
95
|
+
return validateSyncCommitteeSigOnly(chain, syncCommittee, prioritizeBls);
|
|
97
96
|
}
|
|
98
97
|
|
|
99
98
|
/**
|
|
@@ -101,11 +100,10 @@ export async function validateApiSyncCommittee(
|
|
|
101
100
|
*/
|
|
102
101
|
async function validateSyncCommitteeSigOnly(
|
|
103
102
|
chain: IBeaconChain,
|
|
104
|
-
headState: IBeaconStateView,
|
|
105
103
|
syncCommittee: altair.SyncCommitteeMessage,
|
|
106
104
|
prioritizeBls = false
|
|
107
105
|
): Promise<void> {
|
|
108
|
-
const signatureSet = getSyncCommitteeSignatureSet(chain.config,
|
|
106
|
+
const signatureSet = getSyncCommitteeSignatureSet(chain.config, syncCommittee);
|
|
109
107
|
if (!(await chain.bls.verifySignatureSets([signatureSet], {batchable: true, priority: prioritizeBls}))) {
|
|
110
108
|
throw new SyncCommitteeError(GossipAction.REJECT, {
|
|
111
109
|
code: SyncCommitteeErrorCode.INVALID_SIGNATURE,
|
|
@@ -76,14 +76,14 @@ export async function validateSyncCommitteeGossipContributionAndProof(
|
|
|
76
76
|
const signatureSets = [
|
|
77
77
|
// [REJECT] The contribution_and_proof.selection_proof is a valid signature of the SyncAggregatorSelectionData
|
|
78
78
|
// derived from the contribution by the validator with index contribution_and_proof.aggregator_index.
|
|
79
|
-
getSyncCommitteeSelectionProofSignatureSet(chain.config,
|
|
79
|
+
getSyncCommitteeSelectionProofSignatureSet(chain.config, contributionAndProof),
|
|
80
80
|
|
|
81
81
|
// [REJECT] The aggregator signature, signed_contribution_and_proof.signature, is valid.
|
|
82
|
-
getContributionAndProofSignatureSet(chain.config,
|
|
82
|
+
getContributionAndProofSignatureSet(chain.config, signedContributionAndProof),
|
|
83
83
|
|
|
84
84
|
// [REJECT] The aggregate signature is valid for the message beacon_block_root and aggregate pubkey derived from
|
|
85
85
|
// the participation info in aggregation_bits for the subcommittee specified by the contribution.subcommittee_index.
|
|
86
|
-
getSyncCommitteeContributionSignatureSet(chain.config,
|
|
86
|
+
getSyncCommitteeContributionSignatureSet(chain.config, contribution, syncCommitteeParticipantIndices),
|
|
87
87
|
];
|
|
88
88
|
|
|
89
89
|
if (!(await chain.bls.verifySignatureSets(signatureSets, {batchable: true}))) {
|