@lodestar/beacon-node 1.42.0-dev.78c54f483b → 1.42.0-dev.7bdb87e586
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 +24 -12
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/beacon/pool/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/pool/index.js +4 -0
- package/lib/api/impl/beacon/pool/index.js.map +1 -1
- package/lib/api/impl/beacon/state/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/state/index.js +13 -10
- package/lib/api/impl/beacon/state/index.js.map +1 -1
- package/lib/api/impl/debug/index.js.map +1 -1
- package/lib/api/impl/lodestar/index.d.ts.map +1 -1
- package/lib/api/impl/lodestar/index.js +4 -0
- package/lib/api/impl/lodestar/index.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +7 -1
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/ColumnReconstructionTracker.d.ts +2 -1
- package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
- package/lib/chain/ColumnReconstructionTracker.js +5 -5
- package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
- package/lib/chain/GetBlobsTracker.d.ts +2 -1
- package/lib/chain/GetBlobsTracker.d.ts.map +1 -1
- package/lib/chain/GetBlobsTracker.js +14 -12
- package/lib/chain/GetBlobsTracker.js.map +1 -1
- package/lib/chain/blocks/blockInput/blockInput.d.ts +5 -5
- package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
- package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
- package/lib/chain/blocks/blockInput/types.d.ts +4 -4
- package/lib/chain/blocks/blockInput/types.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.js +19 -5
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts +10 -8
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +67 -39
- package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +14 -6
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +33 -2
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +2 -1
- package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +3 -2
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksSignatures.js +4 -2
- package/lib/chain/blocks/verifyBlocksSignatures.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 +64 -24
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/emitter.d.ts +29 -7
- package/lib/chain/emitter.d.ts.map +1 -1
- package/lib/chain/emitter.js +12 -3
- package/lib/chain/emitter.js.map +1 -1
- package/lib/chain/errors/dataColumnSidecarError.d.ts +31 -1
- package/lib/chain/errors/dataColumnSidecarError.d.ts.map +1 -1
- package/lib/chain/errors/dataColumnSidecarError.js +7 -0
- package/lib/chain/errors/dataColumnSidecarError.js.map +1 -1
- package/lib/chain/forkChoice/index.d.ts.map +1 -1
- package/lib/chain/forkChoice/index.js +10 -8
- package/lib/chain/forkChoice/index.js.map +1 -1
- package/lib/chain/interface.d.ts +4 -2
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/lightClient/index.d.ts +2 -2
- package/lib/chain/lightClient/index.d.ts.map +1 -1
- package/lib/chain/lightClient/index.js +7 -0
- package/lib/chain/lightClient/index.js.map +1 -1
- package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
- package/lib/chain/opPools/aggregatedAttestationPool.js +5 -2
- package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
- package/lib/chain/opPools/executionPayloadBidPool.d.ts +2 -2
- package/lib/chain/opPools/executionPayloadBidPool.d.ts.map +1 -1
- package/lib/chain/opPools/executionPayloadBidPool.js +2 -2
- package/lib/chain/opPools/executionPayloadBidPool.js.map +1 -1
- package/lib/chain/prepareNextSlot.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +7 -1
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/computeNewStateRoot.d.ts +2 -2
- package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
- package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +3 -3
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +10 -1
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/seenCache/seenGossipBlockInput.d.ts +1 -1
- package/lib/chain/seenCache/seenGossipBlockInput.d.ts.map +1 -1
- package/lib/chain/seenCache/seenGossipBlockInput.js +2 -2
- package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +1 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +2 -2
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
- package/lib/chain/validation/block.d.ts.map +1 -1
- package/lib/chain/validation/block.js +2 -2
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.d.ts +11 -4
- package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.js +184 -5
- package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
- package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/validation/executionPayloadBid.js +7 -4
- 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 +4 -1
- package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
- package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
- package/lib/chain/validation/payloadAttestationMessage.js +4 -1
- package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
- package/lib/chain/validation/syncCommittee.d.ts.map +1 -1
- package/lib/chain/validation/syncCommittee.js +4 -0
- package/lib/chain/validation/syncCommittee.js.map +1 -1
- package/lib/chain/validation/syncCommitteeContributionAndProof.js +4 -1
- package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
- package/lib/chain/validatorMonitor.d.ts.map +1 -1
- package/lib/chain/validatorMonitor.js +3 -3
- package/lib/chain/validatorMonitor.js.map +1 -1
- package/lib/db/buckets.d.ts +2 -2
- package/lib/db/buckets.d.ts.map +1 -1
- package/lib/db/buckets.js +2 -2
- package/lib/db/buckets.js.map +1 -1
- package/lib/db/repositories/blockArchiveIndex.d.ts +2 -2
- package/lib/db/repositories/blockArchiveIndex.d.ts.map +1 -1
- package/lib/db/repositories/dataColumnSidecar.d.ts.map +1 -1
- package/lib/db/repositories/dataColumnSidecar.js +4 -2
- package/lib/db/repositories/dataColumnSidecar.js.map +1 -1
- package/lib/db/repositories/dataColumnSidecarArchive.d.ts.map +1 -1
- package/lib/db/repositories/dataColumnSidecarArchive.js +4 -2
- package/lib/db/repositories/dataColumnSidecarArchive.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +20 -0
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +33 -0
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/interface.d.ts +3 -2
- package/lib/network/interface.d.ts.map +1 -1
- package/lib/network/libp2p/index.d.ts.map +1 -1
- package/lib/network/libp2p/index.js +19 -13
- package/lib/network/libp2p/index.js.map +1 -1
- package/lib/network/network.d.ts +3 -2
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js +3 -0
- package/lib/network/network.js.map +1 -1
- package/lib/network/options.d.ts.map +1 -1
- package/lib/network/options.js +7 -2
- package/lib/network/options.js.map +1 -1
- package/lib/network/processor/extractSlotRootFns.d.ts +1 -1
- package/lib/network/processor/extractSlotRootFns.d.ts.map +1 -1
- package/lib/network/processor/extractSlotRootFns.js +25 -5
- package/lib/network/processor/extractSlotRootFns.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +260 -73
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/index.d.ts +11 -1
- package/lib/network/processor/index.d.ts.map +1 -1
- package/lib/network/processor/index.js +234 -22
- package/lib/network/processor/index.js.map +1 -1
- package/lib/network/reqresp/types.d.ts +3 -3
- package/lib/network/reqresp/types.d.ts.map +1 -1
- package/lib/network/reqresp/types.js +9 -3
- package/lib/network/reqresp/types.js.map +1 -1
- package/lib/node/nodejs.d.ts.map +1 -1
- package/lib/node/nodejs.js +4 -1
- package/lib/node/nodejs.js.map +1 -1
- package/lib/node/notifier.d.ts.map +1 -1
- package/lib/node/notifier.js +2 -2
- package/lib/node/notifier.js.map +1 -1
- package/lib/sync/unknownBlock.js +2 -2
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/downloadByRange.d.ts +3 -3
- package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRange.js +4 -2
- package/lib/sync/utils/downloadByRange.js.map +1 -1
- package/lib/sync/utils/downloadByRoot.d.ts +3 -3
- package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRoot.js +10 -5
- package/lib/sync/utils/downloadByRoot.js.map +1 -1
- package/lib/util/blobs.d.ts +3 -3
- package/lib/util/blobs.d.ts.map +1 -1
- package/lib/util/blobs.js +21 -10
- package/lib/util/blobs.js.map +1 -1
- package/lib/util/dataColumns.d.ts +18 -11
- package/lib/util/dataColumns.d.ts.map +1 -1
- package/lib/util/dataColumns.js +51 -17
- package/lib/util/dataColumns.js.map +1 -1
- package/lib/util/execution.d.ts +6 -2
- package/lib/util/execution.d.ts.map +1 -1
- package/lib/util/execution.js +49 -25
- package/lib/util/execution.js.map +1 -1
- package/lib/util/sszBytes.d.ts +25 -1
- package/lib/util/sszBytes.d.ts.map +1 -1
- package/lib/util/sszBytes.js +189 -2
- package/lib/util/sszBytes.js.map +1 -1
- package/package.json +15 -15
- package/src/api/impl/beacon/blocks/index.ts +32 -15
- package/src/api/impl/beacon/pool/index.ts +4 -0
- package/src/api/impl/beacon/state/index.ts +15 -15
- package/src/api/impl/debug/index.ts +2 -2
- package/src/api/impl/lodestar/index.ts +4 -0
- package/src/api/impl/validator/index.ts +7 -0
- package/src/chain/ColumnReconstructionTracker.ts +6 -5
- package/src/chain/GetBlobsTracker.ts +14 -12
- package/src/chain/blocks/blockInput/blockInput.ts +8 -8
- package/src/chain/blocks/blockInput/types.ts +4 -4
- package/src/chain/blocks/importBlock.ts +29 -8
- package/src/chain/blocks/importExecutionPayload.ts +72 -42
- package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +53 -12
- package/src/chain/blocks/payloadEnvelopeInput/types.ts +2 -1
- package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +2 -1
- package/src/chain/blocks/verifyBlocksSignatures.ts +9 -2
- package/src/chain/chain.ts +73 -28
- package/src/chain/emitter.ts +25 -7
- package/src/chain/errors/dataColumnSidecarError.ts +32 -1
- package/src/chain/forkChoice/index.ts +11 -8
- package/src/chain/interface.ts +4 -2
- package/src/chain/lightClient/index.ts +15 -3
- package/src/chain/opPools/aggregatedAttestationPool.ts +6 -1
- package/src/chain/opPools/executionPayloadBidPool.ts +3 -3
- package/src/chain/prepareNextSlot.ts +8 -0
- package/src/chain/produceBlock/computeNewStateRoot.ts +2 -1
- package/src/chain/produceBlock/produceBlockBody.ts +25 -5
- package/src/chain/seenCache/seenGossipBlockInput.ts +2 -2
- package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +2 -2
- package/src/chain/validation/block.ts +2 -1
- package/src/chain/validation/dataColumnSidecar.ts +230 -7
- package/src/chain/validation/executionPayloadBid.ts +7 -3
- package/src/chain/validation/executionPayloadEnvelope.ts +8 -1
- package/src/chain/validation/payloadAttestationMessage.ts +4 -0
- package/src/chain/validation/syncCommittee.ts +5 -1
- package/src/chain/validation/syncCommitteeContributionAndProof.ts +5 -1
- package/src/chain/validatorMonitor.ts +3 -2
- package/src/db/buckets.ts +2 -2
- package/src/db/repositories/dataColumnSidecar.ts +4 -2
- package/src/db/repositories/dataColumnSidecarArchive.ts +4 -2
- package/src/metrics/metrics/lodestar.ts +34 -0
- package/src/network/interface.ts +3 -2
- package/src/network/libp2p/index.ts +21 -15
- package/src/network/network.ts +7 -4
- package/src/network/options.ts +7 -2
- package/src/network/processor/extractSlotRootFns.ts +32 -6
- package/src/network/processor/gossipHandlers.ts +325 -86
- package/src/network/processor/index.ts +304 -22
- package/src/network/reqresp/types.ts +13 -5
- package/src/node/nodejs.ts +5 -2
- package/src/node/notifier.ts +7 -2
- package/src/sync/unknownBlock.ts +3 -3
- package/src/sync/utils/downloadByRange.ts +9 -7
- package/src/sync/utils/downloadByRoot.ts +16 -12
- package/src/util/blobs.ts +35 -15
- package/src/util/dataColumns.ts +69 -25
- package/src/util/execution.ts +49 -30
- package/src/util/sszBytes.ts +245 -3
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import {routes} from "@lodestar/api";
|
|
2
2
|
import {ApplicationMethods} from "@lodestar/api/server";
|
|
3
|
-
import {
|
|
4
|
-
EPOCHS_PER_HISTORICAL_VECTOR,
|
|
5
|
-
SLOTS_PER_EPOCH,
|
|
6
|
-
SYNC_COMMITTEE_SUBNET_SIZE,
|
|
7
|
-
isForkPostElectra,
|
|
8
|
-
isForkPostFulu,
|
|
9
|
-
} from "@lodestar/params";
|
|
3
|
+
import {EPOCHS_PER_HISTORICAL_VECTOR, SLOTS_PER_EPOCH, SYNC_COMMITTEE_SUBNET_SIZE} from "@lodestar/params";
|
|
10
4
|
import {
|
|
11
5
|
IBeaconStateView,
|
|
12
6
|
computeEpochAtSlot,
|
|
13
7
|
computeStartSlotAtEpoch,
|
|
14
8
|
getCurrentEpoch,
|
|
9
|
+
isStatePostAltair,
|
|
10
|
+
isStatePostElectra,
|
|
11
|
+
isStatePostFulu,
|
|
15
12
|
} from "@lodestar/state-transition";
|
|
16
13
|
import {ValidatorIndex, getValidatorStatus, ssz} from "@lodestar/types";
|
|
17
14
|
import {ApiError} from "../../errors.js";
|
|
@@ -303,6 +300,9 @@ export function getBeaconStateApi({
|
|
|
303
300
|
if (stateEpoch < config.ALTAIR_FORK_EPOCH) {
|
|
304
301
|
throw new ApiError(400, "Requested state before ALTAIR_FORK_EPOCH");
|
|
305
302
|
}
|
|
303
|
+
if (!isStatePostAltair(state)) {
|
|
304
|
+
throw new Error("Expected Altair state for sync committee lookup");
|
|
305
|
+
}
|
|
306
306
|
|
|
307
307
|
const syncCommitteeCache = state.getIndexedSyncCommitteeAtEpoch(epoch ?? stateEpoch);
|
|
308
308
|
const validatorIndices = new Array<ValidatorIndex>(...syncCommitteeCache.validatorIndices);
|
|
@@ -324,9 +324,9 @@ export function getBeaconStateApi({
|
|
|
324
324
|
|
|
325
325
|
async getPendingDeposits({stateId}, context) {
|
|
326
326
|
const {state, executionOptimistic, finalized} = await getState(stateId);
|
|
327
|
-
const fork =
|
|
327
|
+
const fork = state.forkName;
|
|
328
328
|
|
|
329
|
-
if (!
|
|
329
|
+
if (!isStatePostElectra(state)) {
|
|
330
330
|
throw new ApiError(400, `Cannot retrieve pending deposits for pre-electra state fork=${fork}`);
|
|
331
331
|
}
|
|
332
332
|
|
|
@@ -340,9 +340,9 @@ export function getBeaconStateApi({
|
|
|
340
340
|
|
|
341
341
|
async getPendingPartialWithdrawals({stateId}, context) {
|
|
342
342
|
const {state, executionOptimistic, finalized} = await getState(stateId);
|
|
343
|
-
const fork =
|
|
343
|
+
const fork = state.forkName;
|
|
344
344
|
|
|
345
|
-
if (!
|
|
345
|
+
if (!isStatePostElectra(state)) {
|
|
346
346
|
throw new ApiError(400, `Cannot retrieve pending partial withdrawals for pre-electra state fork=${fork}`);
|
|
347
347
|
}
|
|
348
348
|
|
|
@@ -358,9 +358,9 @@ export function getBeaconStateApi({
|
|
|
358
358
|
|
|
359
359
|
async getPendingConsolidations({stateId}, context) {
|
|
360
360
|
const {state, executionOptimistic, finalized} = await getState(stateId);
|
|
361
|
-
const fork =
|
|
361
|
+
const fork = state.forkName;
|
|
362
362
|
|
|
363
|
-
if (!
|
|
363
|
+
if (!isStatePostElectra(state)) {
|
|
364
364
|
throw new ApiError(400, `Cannot retrieve pending consolidations for pre-electra state fork=${fork}`);
|
|
365
365
|
}
|
|
366
366
|
|
|
@@ -376,9 +376,9 @@ export function getBeaconStateApi({
|
|
|
376
376
|
|
|
377
377
|
async getProposerLookahead({stateId}, context) {
|
|
378
378
|
const {state, executionOptimistic, finalized} = await getState(stateId);
|
|
379
|
-
const fork =
|
|
379
|
+
const fork = state.forkName;
|
|
380
380
|
|
|
381
|
-
if (!
|
|
381
|
+
if (!isStatePostFulu(state)) {
|
|
382
382
|
throw new ApiError(400, `Cannot retrieve proposer lookahead for pre-fulu state fork=${fork}`);
|
|
383
383
|
}
|
|
384
384
|
|
|
@@ -2,7 +2,7 @@ import {routes} from "@lodestar/api";
|
|
|
2
2
|
import {ApplicationMethods} from "@lodestar/api/server";
|
|
3
3
|
import {ExecutionStatus} from "@lodestar/fork-choice";
|
|
4
4
|
import {ForkPostDeneb, ZERO_HASH_HEX, isForkPostDeneb, isForkPostFulu} from "@lodestar/params";
|
|
5
|
-
import {BeaconState, DataColumnSidecars, type SignedBeaconBlock, sszTypesFor} from "@lodestar/types";
|
|
5
|
+
import {BeaconState, DataColumnSidecar, DataColumnSidecars, type SignedBeaconBlock, sszTypesFor} from "@lodestar/types";
|
|
6
6
|
import {toRootHex} from "@lodestar/utils";
|
|
7
7
|
import {getBlobKzgCommitments} from "../../../util/dataColumns.js";
|
|
8
8
|
import {isOptimisticBlock} from "../../../util/forkChoice.js";
|
|
@@ -98,7 +98,7 @@ export function getDebugApi({
|
|
|
98
98
|
const fork = config.getForkName(block.message.slot);
|
|
99
99
|
const blockRoot = sszTypesFor(fork).BeaconBlock.hashTreeRoot(block.message);
|
|
100
100
|
|
|
101
|
-
let dataColumnSidecars:
|
|
101
|
+
let dataColumnSidecars: DataColumnSidecar[];
|
|
102
102
|
|
|
103
103
|
const blobCount = isForkPostDeneb(fork)
|
|
104
104
|
? getBlobKzgCommitments(fork, block as SignedBeaconBlock<ForkPostDeneb>).length
|
|
@@ -3,6 +3,7 @@ import {ApplicationMethods} from "@lodestar/api/server";
|
|
|
3
3
|
import {ChainForkConfig} from "@lodestar/config";
|
|
4
4
|
import {Repository} from "@lodestar/db";
|
|
5
5
|
import {ForkSeq, SLOTS_PER_EPOCH} from "@lodestar/params";
|
|
6
|
+
import {isStatePostCapella} from "@lodestar/state-transition";
|
|
6
7
|
import {ssz} from "@lodestar/types";
|
|
7
8
|
import {Checkpoint} from "@lodestar/types/phase0";
|
|
8
9
|
import {fromHex, toHex, toRootHex} from "@lodestar/utils";
|
|
@@ -218,6 +219,9 @@ export function getLodestarApi({
|
|
|
218
219
|
if (ForkSeq[fork] < ForkSeq.capella) {
|
|
219
220
|
throw new Error("Historical summaries are not supported before Capella");
|
|
220
221
|
}
|
|
222
|
+
if (!isStatePostCapella(stateView)) {
|
|
223
|
+
throw new Error("Expected Capella state for historical summaries");
|
|
224
|
+
}
|
|
221
225
|
|
|
222
226
|
const {gindex} = ssz[fork].BeaconState.getPathInfo(["historicalSummaries"]);
|
|
223
227
|
const proof = stateView.getSingleProof(gindex);
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
computeStartSlotAtEpoch,
|
|
26
26
|
computeTimeAtSlot,
|
|
27
27
|
getCurrentSlot,
|
|
28
|
+
isStatePostAltair,
|
|
28
29
|
proposerShufflingDecisionRoot,
|
|
29
30
|
} from "@lodestar/state-transition";
|
|
30
31
|
import {
|
|
@@ -1282,6 +1283,9 @@ export function getValidatorApi(
|
|
|
1282
1283
|
if (indices.length === 0) {
|
|
1283
1284
|
throw new ApiError(400, "No validator to get attester duties");
|
|
1284
1285
|
}
|
|
1286
|
+
if (epoch < config.ALTAIR_FORK_EPOCH) {
|
|
1287
|
+
throw new ApiError(400, "Sync committee duties are not supported before Altair");
|
|
1288
|
+
}
|
|
1285
1289
|
|
|
1286
1290
|
// May request for an epoch that's in the future
|
|
1287
1291
|
await waitForNextClosestEpoch();
|
|
@@ -1291,6 +1295,9 @@ export function getValidatorApi(
|
|
|
1291
1295
|
// Note: does not support requesting past duties
|
|
1292
1296
|
const head = chain.forkChoice.getHead();
|
|
1293
1297
|
const state = chain.getHeadState();
|
|
1298
|
+
if (!isStatePostAltair(state)) {
|
|
1299
|
+
throw new ApiError(400, "Sync committee duties are not available before Altair");
|
|
1300
|
+
}
|
|
1294
1301
|
|
|
1295
1302
|
// Check that all validatorIndex belong to the state before calling getCommitteeAssignments()
|
|
1296
1303
|
const pubkeys = getPubkeysForIndices(state, indices);
|
|
@@ -3,6 +3,7 @@ import {Logger, sleep} from "@lodestar/utils";
|
|
|
3
3
|
import {Metrics} from "../metrics/metrics.js";
|
|
4
4
|
import {DataColumnReconstructionCode, recoverDataColumnSidecars} from "../util/dataColumns.js";
|
|
5
5
|
import {BlockInputColumns} from "./blocks/blockInput/index.js";
|
|
6
|
+
import {PayloadEnvelopeInput} from "./blocks/payloadEnvelopeInput/index.js";
|
|
6
7
|
import {ChainEventEmitter} from "./emitter.js";
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -53,25 +54,25 @@ export class ColumnReconstructionTracker {
|
|
|
53
54
|
this.maxDelayMs = this.config.getSlotComponentDurationMs(RECONSTRUCTION_DELAY_MAX_BPS);
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
triggerColumnReconstruction(
|
|
57
|
+
triggerColumnReconstruction(input: BlockInputColumns | PayloadEnvelopeInput): void {
|
|
57
58
|
if (this.running) {
|
|
58
59
|
return;
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
if (this.lastBlockRootHex ===
|
|
62
|
+
if (this.lastBlockRootHex === input.blockRootHex) {
|
|
62
63
|
return;
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
// We don't care about the outcome of this call,
|
|
66
67
|
// just that it has been triggered for this block root.
|
|
67
68
|
this.running = true;
|
|
68
|
-
this.lastBlockRootHex =
|
|
69
|
+
this.lastBlockRootHex = input.blockRootHex;
|
|
69
70
|
const delay = this.minDelayMs + Math.random() * (this.maxDelayMs - this.minDelayMs);
|
|
70
71
|
sleep(delay)
|
|
71
72
|
.then(() => {
|
|
72
|
-
const logCtx = {slot:
|
|
73
|
+
const logCtx = {slot: input.slot, root: input.blockRootHex};
|
|
73
74
|
this.logger.debug("Attempting data column sidecar reconstruction", logCtx);
|
|
74
|
-
recoverDataColumnSidecars(
|
|
75
|
+
recoverDataColumnSidecars(input, this.emitter, this.metrics)
|
|
75
76
|
.then((result) => {
|
|
76
77
|
this.metrics?.recoverDataColumnSidecars.reconstructionResult.inc({result});
|
|
77
78
|
this.logger.debug("Data column sidecar reconstruction complete", {...logCtx, result});
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
getDataColumnSidecarsFromExecution,
|
|
12
12
|
} from "../util/execution.js";
|
|
13
13
|
import {IBlockInput, isBlockInputBlobs} from "./blocks/blockInput/index.js";
|
|
14
|
+
import {PayloadEnvelopeInput} from "./blocks/payloadEnvelopeInput/index.js";
|
|
14
15
|
import {ChainEventEmitter} from "./emitter.js";
|
|
15
16
|
|
|
16
17
|
export type GetBlobsTrackerInit = {
|
|
@@ -43,22 +44,22 @@ export class GetBlobsTracker {
|
|
|
43
44
|
this.config = init.config;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
triggerGetBlobs(
|
|
47
|
-
if (this.activeReconstructions.has(
|
|
47
|
+
triggerGetBlobs(input: IBlockInput | PayloadEnvelopeInput, onComplete?: () => void): void {
|
|
48
|
+
if (this.activeReconstructions.has(input.blockRootHex)) {
|
|
48
49
|
return;
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
if (isBlockInputBlobs(
|
|
52
|
+
if (!(input instanceof PayloadEnvelopeInput) && isBlockInputBlobs(input)) {
|
|
52
53
|
// there is not preallocation for blob sidecars like there is for columns sidecars so no need to
|
|
53
54
|
// store the index for the preallocated buffers
|
|
54
|
-
this.activeReconstructions.add(
|
|
55
|
+
this.activeReconstructions.add(input.blockRootHex);
|
|
55
56
|
callInNextEventLoop(() => {
|
|
56
|
-
const logCtx = {slot:
|
|
57
|
+
const logCtx = {slot: input.slot, root: input.blockRootHex};
|
|
57
58
|
this.logger.verbose("Trigger getBlobsV1 for block", logCtx);
|
|
58
|
-
getBlobSidecarsFromExecution(this.config, this.executionEngine, this.metrics, this.emitter,
|
|
59
|
+
getBlobSidecarsFromExecution(this.config, this.executionEngine, this.metrics, this.emitter, input).finally(
|
|
59
60
|
() => {
|
|
60
61
|
this.logger.verbose("Completed getBlobsV1 for block", logCtx);
|
|
61
|
-
this.activeReconstructions.delete(
|
|
62
|
+
this.activeReconstructions.delete(input.blockRootHex);
|
|
62
63
|
}
|
|
63
64
|
);
|
|
64
65
|
});
|
|
@@ -72,7 +73,7 @@ export class GetBlobsTracker {
|
|
|
72
73
|
this.blobsAndProofsBuffers[freeIndex] = {inUse: false, buffers: []};
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
const maxBlobs = this.config.getMaxBlobsPerBlock(computeEpochAtSlot(
|
|
76
|
+
const maxBlobs = this.config.getMaxBlobsPerBlock(computeEpochAtSlot(input.slot));
|
|
76
77
|
// double check that there is enough pre-allocated space (blob schedule may have changed since the last use)
|
|
77
78
|
const timer = this.metrics?.peerDas.getBlobsV2PreAllocationTime.startTimer();
|
|
78
79
|
for (let i = 0; i < maxBlobs; i++) {
|
|
@@ -84,22 +85,23 @@ export class GetBlobsTracker {
|
|
|
84
85
|
|
|
85
86
|
// We don't care about the outcome of this call,
|
|
86
87
|
// just that it has been triggered for this block root.
|
|
87
|
-
this.activeReconstructions.add(
|
|
88
|
+
this.activeReconstructions.add(input.blockRootHex);
|
|
88
89
|
this.blobsAndProofsBuffers[freeIndex].inUse = true;
|
|
89
90
|
callInNextEventLoop(() => {
|
|
90
|
-
const logCtx = {slot:
|
|
91
|
+
const logCtx = {slot: input.slot, root: input.blockRootHex};
|
|
91
92
|
this.logger.verbose("Trigger getBlobsV2 for block", logCtx);
|
|
92
93
|
getDataColumnSidecarsFromExecution(
|
|
93
94
|
this.config,
|
|
94
95
|
this.executionEngine,
|
|
95
96
|
this.emitter,
|
|
96
|
-
|
|
97
|
+
input,
|
|
97
98
|
this.metrics,
|
|
98
99
|
this.blobsAndProofsBuffers[freeIndex].buffers
|
|
99
100
|
)
|
|
100
101
|
.then((result) => {
|
|
101
102
|
this.logger.debug("getBlobsV2 result for block", {...logCtx, result});
|
|
102
103
|
this.metrics?.dataColumns.dataColumnEngineResult.inc({result});
|
|
104
|
+
onComplete?.();
|
|
103
105
|
})
|
|
104
106
|
.catch((error) => {
|
|
105
107
|
this.logger.debug("Error during getBlobsV2 for block", logCtx, error as Error);
|
|
@@ -107,7 +109,7 @@ export class GetBlobsTracker {
|
|
|
107
109
|
})
|
|
108
110
|
.finally(() => {
|
|
109
111
|
this.logger.verbose("Completed getBlobsV2 for block", logCtx);
|
|
110
|
-
this.activeReconstructions.delete(
|
|
112
|
+
this.activeReconstructions.delete(input.blockRootHex);
|
|
111
113
|
this.blobsAndProofsBuffers[freeIndex].inUse = false;
|
|
112
114
|
});
|
|
113
115
|
});
|
|
@@ -617,7 +617,7 @@ type BlockInputColumnsState =
|
|
|
617
617
|
* - The block is not yet seen and all required sampled columns are seen
|
|
618
618
|
* - The block is not yet seen and all required sampled columns are not yet seen
|
|
619
619
|
*/
|
|
620
|
-
export class BlockInputColumns extends AbstractBlockInput<ForkColumnsDA, fulu.
|
|
620
|
+
export class BlockInputColumns extends AbstractBlockInput<ForkColumnsDA, fulu.DataColumnSidecar[]> {
|
|
621
621
|
type = DAType.Columns as const;
|
|
622
622
|
|
|
623
623
|
state: BlockInputColumnsState;
|
|
@@ -630,7 +630,7 @@ export class BlockInputColumns extends AbstractBlockInput<ForkColumnsDA, fulu.Da
|
|
|
630
630
|
*
|
|
631
631
|
* This is different from `dataPromise` which resolves when all data is available or could become available (e.g. through reconstruction)
|
|
632
632
|
*/
|
|
633
|
-
protected computedDataPromise = createPromise<fulu.
|
|
633
|
+
protected computedDataPromise = createPromise<fulu.DataColumnSidecar[]>();
|
|
634
634
|
|
|
635
635
|
private constructor(
|
|
636
636
|
init: BlockInputInit,
|
|
@@ -854,8 +854,8 @@ export class BlockInputColumns extends AbstractBlockInput<ForkColumnsDA, fulu.Da
|
|
|
854
854
|
return this.state.versionedHashes;
|
|
855
855
|
}
|
|
856
856
|
|
|
857
|
-
getCustodyColumns(): fulu.
|
|
858
|
-
const columns: fulu.
|
|
857
|
+
getCustodyColumns(): fulu.DataColumnSidecar[] {
|
|
858
|
+
const columns: fulu.DataColumnSidecar[] = [];
|
|
859
859
|
for (const index of this.custodyColumns) {
|
|
860
860
|
const column = this.columnsCache.get(index);
|
|
861
861
|
if (column) {
|
|
@@ -876,8 +876,8 @@ export class BlockInputColumns extends AbstractBlockInput<ForkColumnsDA, fulu.Da
|
|
|
876
876
|
return columns;
|
|
877
877
|
}
|
|
878
878
|
|
|
879
|
-
getSampledColumns(): fulu.
|
|
880
|
-
const columns: fulu.
|
|
879
|
+
getSampledColumns(): fulu.DataColumnSidecar[] {
|
|
880
|
+
const columns: fulu.DataColumnSidecar[] = [];
|
|
881
881
|
for (const index of this.sampledColumns) {
|
|
882
882
|
const column = this.columnsCache.get(index);
|
|
883
883
|
if (column) {
|
|
@@ -891,7 +891,7 @@ export class BlockInputColumns extends AbstractBlockInput<ForkColumnsDA, fulu.Da
|
|
|
891
891
|
return [...this.columnsCache.values()];
|
|
892
892
|
}
|
|
893
893
|
|
|
894
|
-
getAllColumns(): fulu.
|
|
894
|
+
getAllColumns(): fulu.DataColumnSidecar[] {
|
|
895
895
|
return this.getAllColumnsWithSource().map(({columnSidecar}) => columnSidecar);
|
|
896
896
|
}
|
|
897
897
|
|
|
@@ -919,7 +919,7 @@ export class BlockInputColumns extends AbstractBlockInput<ForkColumnsDA, fulu.Da
|
|
|
919
919
|
return this.state.hasComputedAllData;
|
|
920
920
|
}
|
|
921
921
|
|
|
922
|
-
waitForComputedAllData(timeout: number, signal?: AbortSignal): Promise<fulu.
|
|
922
|
+
waitForComputedAllData(timeout: number, signal?: AbortSignal): Promise<fulu.DataColumnSidecar[]> {
|
|
923
923
|
if (!this.state.hasComputedAllData) {
|
|
924
924
|
return withTimeout(() => this.computedDataPromise.promise, timeout, signal);
|
|
925
925
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {ForkName} from "@lodestar/params";
|
|
2
|
-
import {ColumnIndex,
|
|
2
|
+
import {ColumnIndex, DataColumnSidecar, RootHex, SignedBeaconBlock, Slot, deneb, fulu} from "@lodestar/types";
|
|
3
3
|
import {VersionedHashes} from "../../../execution/index.js";
|
|
4
4
|
|
|
5
5
|
export enum DAType {
|
|
@@ -9,7 +9,7 @@ export enum DAType {
|
|
|
9
9
|
NoData = "no-data",
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export type DAData = null | deneb.BlobSidecars | fulu.
|
|
12
|
+
export type DAData = null | deneb.BlobSidecars | fulu.DataColumnSidecar[];
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Represents were input originated. Blocks and Data can come from different
|
|
@@ -108,9 +108,9 @@ export type MissingColumnMeta = {
|
|
|
108
108
|
export interface IDataColumnsInput {
|
|
109
109
|
readonly slot: Slot;
|
|
110
110
|
readonly blockRootHex: string;
|
|
111
|
-
getCustodyColumns():
|
|
111
|
+
getCustodyColumns(): DataColumnSidecar[];
|
|
112
112
|
hasComputedAllData(): boolean;
|
|
113
|
-
waitForComputedAllData(timeout: number, signal?: AbortSignal): Promise<
|
|
113
|
+
waitForComputedAllData(timeout: number, signal?: AbortSignal): Promise<DataColumnSidecar[]>;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
/**
|
|
@@ -25,6 +25,8 @@ import {
|
|
|
25
25
|
computeStartSlotAtEpoch,
|
|
26
26
|
computeTimeAtSlot,
|
|
27
27
|
isStartSlotOfEpoch,
|
|
28
|
+
isStatePostAltair,
|
|
29
|
+
isStatePostBellatrix,
|
|
28
30
|
} from "@lodestar/state-transition";
|
|
29
31
|
import {
|
|
30
32
|
Attestation,
|
|
@@ -140,9 +142,10 @@ export async function importBlock(
|
|
|
140
142
|
|
|
141
143
|
// For Gloas blocks, create PayloadEnvelopeInput so it's available for later payload import
|
|
142
144
|
if (fork >= ForkSeq.gloas) {
|
|
143
|
-
this.seenPayloadEnvelopeInputCache.add({
|
|
145
|
+
const payloadInput = this.seenPayloadEnvelopeInputCache.add({
|
|
144
146
|
blockRootHex,
|
|
145
147
|
block: block as SignedBeaconBlock<ForkPostGloas>,
|
|
148
|
+
forkName: blockInput.forkName,
|
|
146
149
|
sampledColumns: this.custodyConfig.sampledColumns,
|
|
147
150
|
custodyColumns: this.custodyConfig.custodyColumns,
|
|
148
151
|
timeCreatedSec: fullyVerifiedBlock.seenTimestampSec,
|
|
@@ -153,6 +156,22 @@ export async function importBlock(
|
|
|
153
156
|
source: source.source,
|
|
154
157
|
...(opts.seenTimestampSec !== undefined ? {recvToImport: Date.now() / 1000 - opts.seenTimestampSec} : {}),
|
|
155
158
|
});
|
|
159
|
+
|
|
160
|
+
// Immediately attempt fetch of data columns from execution engine as the bid contains kzg commitments
|
|
161
|
+
// which is all the information we need so there is no reason to delay until execution payload arrives
|
|
162
|
+
// TODO GLOAS: If we want EL retries after this initial attempt, add an explicit retry policy here
|
|
163
|
+
// (for example later in the slot). Do not couple retries to incoming gossip columns.
|
|
164
|
+
this.getBlobsTracker.triggerGetBlobs(payloadInput, () => {
|
|
165
|
+
// TODO GLOAS: come up with a better mechanism to trigger processExecutionPayload after data becomes available,
|
|
166
|
+
// similar to how pre-gloas uses waitForBlockAndAllData with a cutoff timeout and incompleteBlockInput event
|
|
167
|
+
this.processExecutionPayload(payloadInput, {validSignature: true}).catch((e) => {
|
|
168
|
+
this.logger.debug(
|
|
169
|
+
"Error processing execution payload after getBlobs",
|
|
170
|
+
{slot: blockSlot, root: blockRootHex},
|
|
171
|
+
e as Error
|
|
172
|
+
);
|
|
173
|
+
});
|
|
174
|
+
});
|
|
156
175
|
}
|
|
157
176
|
|
|
158
177
|
this.metrics?.importBlock.bySource.inc({source: source.source});
|
|
@@ -371,11 +390,13 @@ export async function importBlock(
|
|
|
371
390
|
// we want to import block asap so do this in the next event loop
|
|
372
391
|
callInNextEventLoop(() => {
|
|
373
392
|
try {
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
393
|
+
if (isStatePostAltair(postBlockState)) {
|
|
394
|
+
this.lightClientServer?.onImportBlockHead(
|
|
395
|
+
block.message as BeaconBlock<ForkPostAltair>,
|
|
396
|
+
postBlockState,
|
|
397
|
+
parentBlockSlot
|
|
398
|
+
);
|
|
399
|
+
}
|
|
379
400
|
} catch (e) {
|
|
380
401
|
this.logger.verbose("Error lightClientServer.onImportBlock", {slot: blockSlot}, e as Error);
|
|
381
402
|
}
|
|
@@ -394,7 +415,7 @@ export async function importBlock(
|
|
|
394
415
|
// and the block is weak and can potentially be reorged out.
|
|
395
416
|
let shouldOverrideFcu = false;
|
|
396
417
|
|
|
397
|
-
if (blockSlot >= currentSlot && postBlockState.isExecutionStateType) {
|
|
418
|
+
if (blockSlot >= currentSlot && isStatePostBellatrix(postBlockState) && postBlockState.isExecutionStateType) {
|
|
398
419
|
let notOverrideFcuReason = NotReorgedReason.Unknown;
|
|
399
420
|
const proposalSlot = blockSlot + 1;
|
|
400
421
|
try {
|
|
@@ -581,7 +602,7 @@ export async function importBlock(
|
|
|
581
602
|
this.metrics?.parentBlockDistance.observe(blockSlot - parentBlockSlot);
|
|
582
603
|
this.metrics?.proposerBalanceDeltaAny.observe(fullyVerifiedBlock.proposerBalanceDelta);
|
|
583
604
|
this.validatorMonitor?.registerImportedBlock(block.message, fullyVerifiedBlock);
|
|
584
|
-
if (
|
|
605
|
+
if (isStatePostAltair(fullyVerifiedBlock.postBlockState)) {
|
|
585
606
|
this.validatorMonitor?.registerSyncAggregateInBlock(
|
|
586
607
|
blockEpoch,
|
|
587
608
|
(block as altair.SignedBeaconBlock).message.body.syncAggregate,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {routes} from "@lodestar/api";
|
|
2
2
|
import {ExecutionStatus, PayloadExecutionStatus} from "@lodestar/fork-choice";
|
|
3
|
-
import {
|
|
4
|
-
import {getExecutionPayloadEnvelopeSignatureSet} from "@lodestar/state-transition";
|
|
3
|
+
import {SLOTS_PER_EPOCH} from "@lodestar/params";
|
|
4
|
+
import {getExecutionPayloadEnvelopeSignatureSet, isStatePostGloas} from "@lodestar/state-transition";
|
|
5
5
|
import {byteArrayEquals, fromHex, toRootHex} from "@lodestar/utils";
|
|
6
6
|
import {ExecutionPayloadStatus} from "../../execution/index.js";
|
|
7
7
|
import {isQueueErrorAborted} from "../../util/queue/index.js";
|
|
@@ -69,14 +69,16 @@ function toForkChoiceExecutionStatus(status: ExecutionPayloadStatus): PayloadExe
|
|
|
69
69
|
* Import an execution payload envelope after all data is available.
|
|
70
70
|
*
|
|
71
71
|
* This function:
|
|
72
|
-
* 1.
|
|
73
|
-
* 2.
|
|
74
|
-
* 3.
|
|
75
|
-
* 4.
|
|
76
|
-
* 5.
|
|
77
|
-
* 6.
|
|
78
|
-
* 7.
|
|
79
|
-
* 8.
|
|
72
|
+
* 1. Emits `execution_payload_available` if payload is for current slot
|
|
73
|
+
* 2. Gets the ProtoBlock from fork choice
|
|
74
|
+
* 3. Applies write-queue backpressure (waitForSpace) early, before verification
|
|
75
|
+
* 4. Regenerates the block state
|
|
76
|
+
* 5. Runs EL verification (notifyNewPayload) in parallel with signature verification and processExecutionPayloadEnvelope
|
|
77
|
+
* 6. Persists verified payload envelope to hot DB
|
|
78
|
+
* 7. Updates fork choice
|
|
79
|
+
* 8. Caches the post-execution payload state
|
|
80
|
+
* 9. Records metrics for column sources
|
|
81
|
+
* 10. Emits `execution_payload` for recent enough payloads after successful import
|
|
80
82
|
*
|
|
81
83
|
*/
|
|
82
84
|
export async function importExecutionPayload(
|
|
@@ -84,10 +86,24 @@ export async function importExecutionPayload(
|
|
|
84
86
|
payloadInput: PayloadEnvelopeInput,
|
|
85
87
|
opts: ImportPayloadOpts = {}
|
|
86
88
|
): Promise<void> {
|
|
87
|
-
const
|
|
89
|
+
const signedEnvelope = payloadInput.getPayloadEnvelope();
|
|
90
|
+
const envelope = signedEnvelope.message;
|
|
88
91
|
const blockRootHex = payloadInput.blockRootHex;
|
|
92
|
+
const blockHashHex = payloadInput.getBlockHashHex();
|
|
93
|
+
const fork = this.config.getForkName(envelope.slot);
|
|
89
94
|
|
|
90
|
-
// 1.
|
|
95
|
+
// 1. Emit `execution_payload_available` event at the start of import. At this point the payload input
|
|
96
|
+
// is already complete, so the payload and required data are available for payload attestation.
|
|
97
|
+
// This event is only about availability, not validity of the execution payload, hence we can emit
|
|
98
|
+
// it before getting a response from the execution client on whether the payload is valid or not.
|
|
99
|
+
if (this.clock.currentSlot - envelope.slot < EVENTSTREAM_EMIT_RECENT_EXECUTION_PAYLOAD_SLOTS) {
|
|
100
|
+
this.emitter.emit(routes.events.EventType.executionPayloadAvailable, {
|
|
101
|
+
slot: envelope.slot,
|
|
102
|
+
blockRoot: blockRootHex,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// 2. Get ProtoBlock for parent root lookup
|
|
91
107
|
const protoBlock = this.forkChoice.getBlockHexDefaultStatus(blockRootHex);
|
|
92
108
|
if (!protoBlock) {
|
|
93
109
|
throw new PayloadError({
|
|
@@ -96,11 +112,11 @@ export async function importExecutionPayload(
|
|
|
96
112
|
});
|
|
97
113
|
}
|
|
98
114
|
|
|
99
|
-
//
|
|
115
|
+
// 3. Apply backpressure from the write queue early, before doing verification work.
|
|
100
116
|
// The actual DB write is deferred until after verification succeeds.
|
|
101
117
|
await this.unfinalizedPayloadEnvelopeWrites.waitForSpace();
|
|
102
118
|
|
|
103
|
-
//
|
|
119
|
+
// 4. Get pre-state for processExecutionPayloadEnvelope
|
|
104
120
|
// We need the block state (post-block, pre-payload) to process the envelope
|
|
105
121
|
const blockState = await this.regen.getBlockSlotState(
|
|
106
122
|
protoBlock,
|
|
@@ -108,17 +124,23 @@ export async function importExecutionPayload(
|
|
|
108
124
|
{dontTransferCache: true},
|
|
109
125
|
RegenCaller.processBlock
|
|
110
126
|
);
|
|
127
|
+
if (!isStatePostGloas(blockState)) {
|
|
128
|
+
throw new PayloadError({
|
|
129
|
+
code: PayloadErrorCode.STATE_TRANSITION_ERROR,
|
|
130
|
+
message: `Expected gloas+ block state for payload import, got fork=${blockState.forkName}`,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
111
133
|
|
|
112
|
-
//
|
|
134
|
+
// 5. Run verification steps in parallel
|
|
113
135
|
// Note: No data availability check needed here - importExecutionPayload is only
|
|
114
136
|
// called when payloadInput.isComplete() is true, so all data is already available.
|
|
115
137
|
const [execResult, signatureValid, postPayloadResult] = await Promise.all([
|
|
116
138
|
this.executionEngine.notifyNewPayload(
|
|
117
|
-
|
|
118
|
-
envelope.
|
|
139
|
+
fork,
|
|
140
|
+
envelope.payload,
|
|
119
141
|
payloadInput.getVersionedHashes(),
|
|
120
142
|
fromHex(protoBlock.parentRoot),
|
|
121
|
-
envelope.
|
|
143
|
+
envelope.executionRequests
|
|
122
144
|
),
|
|
123
145
|
|
|
124
146
|
opts.validSignature === true
|
|
@@ -128,7 +150,7 @@ export async function importExecutionPayload(
|
|
|
128
150
|
this.config,
|
|
129
151
|
this.pubkeyCache,
|
|
130
152
|
blockState,
|
|
131
|
-
|
|
153
|
+
signedEnvelope,
|
|
132
154
|
payloadInput.proposerIndex
|
|
133
155
|
);
|
|
134
156
|
return this.bls.verifySignatureSets([signatureSet]);
|
|
@@ -139,7 +161,7 @@ export async function importExecutionPayload(
|
|
|
139
161
|
(async () => {
|
|
140
162
|
try {
|
|
141
163
|
return {
|
|
142
|
-
postPayloadState: blockState.processExecutionPayloadEnvelope(
|
|
164
|
+
postPayloadState: blockState.processExecutionPayloadEnvelope(signedEnvelope, {
|
|
143
165
|
verifySignature: false,
|
|
144
166
|
verifyStateRoot: false,
|
|
145
167
|
}),
|
|
@@ -156,12 +178,12 @@ export async function importExecutionPayload(
|
|
|
156
178
|
})(),
|
|
157
179
|
]);
|
|
158
180
|
|
|
159
|
-
//
|
|
181
|
+
// 5a. Check signature verification result
|
|
160
182
|
if (!signatureValid) {
|
|
161
183
|
throw new PayloadError({code: PayloadErrorCode.INVALID_SIGNATURE});
|
|
162
184
|
}
|
|
163
185
|
|
|
164
|
-
//
|
|
186
|
+
// 5b. Handle EL response
|
|
165
187
|
switch (execResult.status) {
|
|
166
188
|
case ExecutionPayloadStatus.VALID:
|
|
167
189
|
break;
|
|
@@ -187,61 +209,69 @@ export async function importExecutionPayload(
|
|
|
187
209
|
});
|
|
188
210
|
}
|
|
189
211
|
|
|
190
|
-
//
|
|
212
|
+
// 5c. Verify envelope state root matches post-state
|
|
191
213
|
const postPayloadState = postPayloadResult.postPayloadState;
|
|
192
214
|
const postPayloadStateRoot = postPayloadState.hashTreeRoot();
|
|
193
|
-
if (!byteArrayEquals(envelope.
|
|
215
|
+
if (!byteArrayEquals(envelope.stateRoot, postPayloadStateRoot)) {
|
|
194
216
|
throw new PayloadError({
|
|
195
217
|
code: PayloadErrorCode.STATE_TRANSITION_ERROR,
|
|
196
|
-
message: `Envelope state root mismatch expected=${toRootHex(envelope.
|
|
218
|
+
message: `Envelope state root mismatch expected=${toRootHex(envelope.stateRoot)} actual=${toRootHex(postPayloadStateRoot)}`,
|
|
197
219
|
});
|
|
198
220
|
}
|
|
199
221
|
|
|
200
|
-
//
|
|
222
|
+
// 6. Persist payload envelope to hot DB (performed asynchronously to avoid blocking)
|
|
201
223
|
this.unfinalizedPayloadEnvelopeWrites.push(payloadInput).catch((e) => {
|
|
202
224
|
if (!isQueueErrorAborted(e)) {
|
|
203
225
|
this.logger.error(
|
|
204
226
|
"Error pushing payload envelope to unfinalized write queue",
|
|
205
|
-
{slot:
|
|
227
|
+
{slot: envelope.slot, blockRoot: blockRootHex},
|
|
206
228
|
e as Error
|
|
207
229
|
);
|
|
208
230
|
}
|
|
209
231
|
});
|
|
210
232
|
|
|
211
|
-
//
|
|
233
|
+
// 7. Update fork choice
|
|
212
234
|
this.forkChoice.onExecutionPayload(
|
|
213
235
|
blockRootHex,
|
|
214
|
-
|
|
215
|
-
envelope.
|
|
236
|
+
blockHashHex,
|
|
237
|
+
envelope.payload.blockNumber,
|
|
216
238
|
toRootHex(postPayloadStateRoot),
|
|
217
239
|
toForkChoiceExecutionStatus(execResult.status)
|
|
218
240
|
);
|
|
219
241
|
|
|
220
|
-
//
|
|
242
|
+
// 8. Cache payload state
|
|
221
243
|
this.regen.processPayloadState(postPayloadState);
|
|
222
244
|
if (postPayloadState.slot % SLOTS_PER_EPOCH === 0) {
|
|
223
245
|
const {checkpoint} = postPayloadState.computeAnchorCheckpoint();
|
|
224
246
|
this.regen.addCheckpointState(checkpoint, postPayloadState, true);
|
|
225
247
|
}
|
|
226
248
|
|
|
227
|
-
//
|
|
249
|
+
// 9. Record metrics for payload envelope and column sources
|
|
228
250
|
this.metrics?.importPayload.bySource.inc({source: payloadInput.getPayloadEnvelopeSource().source});
|
|
229
251
|
for (const {source} of payloadInput.getSampledColumnsWithSource()) {
|
|
230
252
|
this.metrics?.importPayload.columnsBySource.inc({source});
|
|
231
253
|
}
|
|
232
254
|
|
|
233
|
-
|
|
234
|
-
slot: payloadInput.slot,
|
|
235
|
-
root: blockRootHex,
|
|
236
|
-
blockHash: payloadInput.getBlockHashHex(),
|
|
237
|
-
});
|
|
255
|
+
const stateRootHex = toRootHex(envelope.stateRoot);
|
|
238
256
|
|
|
239
|
-
//
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
257
|
+
// 10. Emit event after payload is fully verified and imported to fork choice, only for recent enough payloads
|
|
258
|
+
if (this.clock.currentSlot - envelope.slot < EVENTSTREAM_EMIT_RECENT_EXECUTION_PAYLOAD_SLOTS) {
|
|
259
|
+
this.emitter.emit(routes.events.EventType.executionPayload, {
|
|
260
|
+
slot: envelope.slot,
|
|
261
|
+
builderIndex: envelope.builderIndex,
|
|
262
|
+
blockHash: blockHashHex,
|
|
244
263
|
blockRoot: blockRootHex,
|
|
264
|
+
stateRoot: stateRootHex,
|
|
265
|
+
// TODO GLOAS: revisit once we support optimistic import
|
|
266
|
+
executionOptimistic: false,
|
|
245
267
|
});
|
|
246
268
|
}
|
|
269
|
+
|
|
270
|
+
this.logger.verbose("Execution payload imported", {
|
|
271
|
+
slot: envelope.slot,
|
|
272
|
+
builderIndex: envelope.builderIndex,
|
|
273
|
+
blockRoot: blockRootHex,
|
|
274
|
+
blockHash: blockHashHex,
|
|
275
|
+
stateRoot: stateRootHex,
|
|
276
|
+
});
|
|
247
277
|
}
|