@lodestar/beacon-node 1.42.0-dev.d32f5153b6 → 1.42.0-dev.d4d0b21dfe
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 +11 -11
- 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 +9 -3
- 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.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +14 -5
- package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
- package/lib/chain/blocks/index.js +1 -1
- package/lib/chain/blocks/index.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/types.d.ts +3 -3
- package/lib/chain/blocks/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 +68 -28
- 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/blockError.d.ts +11 -1
- package/lib/chain/errors/blockError.d.ts.map +1 -1
- package/lib/chain/errors/blockError.js +4 -0
- package/lib/chain/errors/blockError.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 +3 -3
- package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
- package/lib/chain/produceBlock/computeNewStateRoot.js +8 -8
- package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +5 -5
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +23 -4
- 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 +27 -5
- 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 +6 -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/gossip/topic.d.ts +2 -729
- package/lib/network/gossip/topic.d.ts.map +1 -1
- package/lib/network/interface.d.ts +3 -2
- package/lib/network/interface.d.ts.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/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 +246 -66
- 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 +17 -14
- 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 +9 -2
- 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 +15 -5
- package/src/chain/blocks/index.ts +1 -1
- package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +53 -12
- package/src/chain/blocks/payloadEnvelopeInput/types.ts +2 -1
- package/src/chain/blocks/types.ts +3 -3
- package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +2 -1
- package/src/chain/blocks/verifyBlocksSignatures.ts +9 -2
- package/src/chain/chain.ts +77 -32
- package/src/chain/emitter.ts +25 -7
- package/src/chain/errors/blockError.ts +7 -1
- 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 +11 -10
- package/src/chain/produceBlock/produceBlockBody.ts +40 -10
- package/src/chain/seenCache/seenGossipBlockInput.ts +2 -2
- package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +2 -2
- package/src/chain/validation/block.ts +30 -7
- package/src/chain/validation/dataColumnSidecar.ts +230 -7
- package/src/chain/validation/executionPayloadBid.ts +7 -3
- package/src/chain/validation/executionPayloadEnvelope.ts +10 -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/network.ts +7 -4
- package/src/network/processor/extractSlotRootFns.ts +32 -6
- package/src/network/processor/gossipHandlers.ts +310 -79
- 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
|
@@ -14,7 +14,16 @@ import {
|
|
|
14
14
|
isForkPostBellatrix,
|
|
15
15
|
isForkPostGloas,
|
|
16
16
|
} from "@lodestar/params";
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
G2_POINT_AT_INFINITY,
|
|
19
|
+
IBeaconStateView,
|
|
20
|
+
type IBeaconStateViewBellatrix,
|
|
21
|
+
computeTimeAtSlot,
|
|
22
|
+
isParentBlockFull,
|
|
23
|
+
isStatePostBellatrix,
|
|
24
|
+
isStatePostCapella,
|
|
25
|
+
isStatePostGloas,
|
|
26
|
+
} from "@lodestar/state-transition";
|
|
18
27
|
import {
|
|
19
28
|
BLSPubkey,
|
|
20
29
|
BLSSignature,
|
|
@@ -103,11 +112,11 @@ export type ProduceFullGloas = {
|
|
|
103
112
|
blobsBundle: BlobsBundle<ForkPostGloas>;
|
|
104
113
|
cells: fulu.Cell[][];
|
|
105
114
|
/**
|
|
106
|
-
* Cached envelope state root computed during block production.
|
|
115
|
+
* Cached payload envelope state root computed during block production.
|
|
107
116
|
* This is the state root after running `processExecutionPayloadEnvelope` on the
|
|
108
117
|
* post-block state, and later used to construct the `ExecutionPayloadEnvelope`.
|
|
109
118
|
*/
|
|
110
|
-
|
|
119
|
+
payloadEnvelopeStateRoot: Root;
|
|
111
120
|
};
|
|
112
121
|
export type ProduceFullFulu = {
|
|
113
122
|
type: BlockType.Full;
|
|
@@ -191,6 +200,10 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
191
200
|
this.logger.verbose("Producing beacon block body", logMeta);
|
|
192
201
|
|
|
193
202
|
if (isForkPostGloas(fork)) {
|
|
203
|
+
if (!isStatePostGloas(currentState)) {
|
|
204
|
+
throw new Error("Expected Gloas state for Gloas block production");
|
|
205
|
+
}
|
|
206
|
+
|
|
194
207
|
// TODO GLOAS: support non self-building here, the block type differentiation between
|
|
195
208
|
// full and blinded no longer makes sense in gloas, it might be a good idea to move
|
|
196
209
|
// this into a completely separate function and have pre/post gloas more separated
|
|
@@ -297,6 +310,10 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
297
310
|
shouldOverrideBuilder,
|
|
298
311
|
});
|
|
299
312
|
} else if (isForkPostBellatrix(fork)) {
|
|
313
|
+
if (!isStatePostBellatrix(currentState)) {
|
|
314
|
+
throw new Error("Expected Bellatrix state for execution block production");
|
|
315
|
+
}
|
|
316
|
+
|
|
300
317
|
const safeBlockHash = getSafeExecutionBlockHash(this.forkChoice);
|
|
301
318
|
const finalizedBlockHash = this.forkChoice.getFinalizedBlock().executionPayloadBlockHash ?? ZERO_HASH_HEX;
|
|
302
319
|
const feeRecipient = requestedFeeRecipient ?? this.beaconProposerCache.getOrDefault(proposerIndex);
|
|
@@ -598,7 +615,7 @@ export async function prepareExecutionPayload(
|
|
|
598
615
|
parentBlockRoot: Root,
|
|
599
616
|
safeBlockHash: RootHex,
|
|
600
617
|
finalizedBlockHash: RootHex,
|
|
601
|
-
state:
|
|
618
|
+
state: IBeaconStateViewBellatrix,
|
|
602
619
|
suggestedFeeRecipient: string
|
|
603
620
|
): Promise<{prepType: PayloadPreparationType; payloadId: PayloadId}> {
|
|
604
621
|
const parentHash = state.latestBlockHash;
|
|
@@ -666,7 +683,7 @@ async function prepareExecutionPayloadHeader(
|
|
|
666
683
|
config: ChainForkConfig;
|
|
667
684
|
},
|
|
668
685
|
fork: ForkPostBellatrix,
|
|
669
|
-
state:
|
|
686
|
+
state: IBeaconStateViewBellatrix,
|
|
670
687
|
proposerPubKey: BLSPubkey
|
|
671
688
|
): Promise<{
|
|
672
689
|
header: ExecutionPayloadHeader;
|
|
@@ -693,7 +710,7 @@ export function getPayloadAttributesForSSE(
|
|
|
693
710
|
prepareSlot,
|
|
694
711
|
parentBlockRoot,
|
|
695
712
|
feeRecipient,
|
|
696
|
-
}: {prepareState:
|
|
713
|
+
}: {prepareState: IBeaconStateViewBellatrix; prepareSlot: Slot; parentBlockRoot: Root; feeRecipient: string}
|
|
697
714
|
): SSEPayloadAttributes {
|
|
698
715
|
const parentHash = prepareState.latestBlockHash;
|
|
699
716
|
const payloadAttributes = preparePayloadAttributes(fork, chain, {
|
|
@@ -736,7 +753,7 @@ function preparePayloadAttributes(
|
|
|
736
753
|
parentBlockRoot,
|
|
737
754
|
feeRecipient,
|
|
738
755
|
}: {
|
|
739
|
-
prepareState:
|
|
756
|
+
prepareState: IBeaconStateViewBellatrix;
|
|
740
757
|
prepareSlot: Slot;
|
|
741
758
|
parentBlockRoot: Root;
|
|
742
759
|
feeRecipient: string;
|
|
@@ -751,9 +768,22 @@ function preparePayloadAttributes(
|
|
|
751
768
|
};
|
|
752
769
|
|
|
753
770
|
if (ForkSeq[fork] >= ForkSeq.capella) {
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
771
|
+
if (!isStatePostCapella(prepareState)) {
|
|
772
|
+
throw new Error("Expected Capella state for withdrawals");
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
if (isStatePostGloas(prepareState) && !isParentBlockFull(prepareState)) {
|
|
776
|
+
// When the parent block is empty, state.payloadExpectedWithdrawals holds a batch
|
|
777
|
+
// already deducted from CL balances but never credited on the EL (the envelope
|
|
778
|
+
// was not delivered). The next payload must carry those same withdrawals to
|
|
779
|
+
// restore CL/EL consistency, otherwise validators permanently lose that balance.
|
|
780
|
+
(payloadAttributes as capella.SSEPayloadAttributes["payloadAttributes"]).withdrawals =
|
|
781
|
+
prepareState.payloadExpectedWithdrawals;
|
|
782
|
+
} else {
|
|
783
|
+
// withdrawals logic is now fork aware as it changes on electra fork post capella
|
|
784
|
+
(payloadAttributes as capella.SSEPayloadAttributes["payloadAttributes"]).withdrawals =
|
|
785
|
+
prepareState.getExpectedWithdrawals().expectedWithdrawals;
|
|
786
|
+
}
|
|
757
787
|
}
|
|
758
788
|
|
|
759
789
|
if (ForkSeq[fork] >= ForkSeq.deneb) {
|
|
@@ -149,8 +149,8 @@ export class SeenBlockInput {
|
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
|
|
153
|
-
return this.blockInputs.
|
|
152
|
+
hasBlock(rootHex: RootHex): boolean {
|
|
153
|
+
return this.blockInputs.get(rootHex)?.hasBlock() ?? false;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
get(rootHex: RootHex): IBlockInput | undefined {
|
|
@@ -84,8 +84,8 @@ export class SeenPayloadEnvelopeInput {
|
|
|
84
84
|
return this.payloadInputs.get(blockRootHex);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
return this.payloadInputs.
|
|
87
|
+
hasPayload(blockRootHex: RootHex): boolean {
|
|
88
|
+
return this.payloadInputs.get(blockRootHex)?.hasPayloadEnvelope() ?? false;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
prune(blockRootHex: RootHex): void {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {ChainForkConfig} from "@lodestar/config";
|
|
2
|
+
import {ExecutionStatus} from "@lodestar/fork-choice";
|
|
2
3
|
import {ForkName, isForkPostBellatrix, isForkPostDeneb, isForkPostGloas} from "@lodestar/params";
|
|
3
4
|
import {
|
|
4
5
|
computeEpochAtSlot,
|
|
@@ -6,6 +7,7 @@ import {
|
|
|
6
7
|
computeTimeAtSlot,
|
|
7
8
|
getBlockProposerSignatureSet,
|
|
8
9
|
isExecutionBlockBodyType,
|
|
10
|
+
isStatePostBellatrix,
|
|
9
11
|
} from "@lodestar/state-transition";
|
|
10
12
|
import {SignedBeaconBlock, deneb, gloas, isGloasBeaconBlock} from "@lodestar/types";
|
|
11
13
|
import {byteArrayEquals, sleep, toRootHex} from "@lodestar/utils";
|
|
@@ -70,12 +72,7 @@ export async function validateGossipBlock(
|
|
|
70
72
|
// [REJECT] The current finalized_checkpoint is an ancestor of block -- i.e.
|
|
71
73
|
// get_ancestor(store, block.parent_root, compute_start_slot_at_epoch(store.finalized_checkpoint.epoch)) == store.finalized_checkpoint.root
|
|
72
74
|
const parentRoot = toRootHex(block.parentRoot);
|
|
73
|
-
const parentBlock =
|
|
74
|
-
? chain.forkChoice.getBlockHexAndBlockHash(
|
|
75
|
-
parentRoot,
|
|
76
|
-
toRootHex(block.body.signedExecutionPayloadBid.message.parentBlockHash)
|
|
77
|
-
)
|
|
78
|
-
: chain.forkChoice.getBlockHexDefaultStatus(parentRoot);
|
|
75
|
+
const parentBlock = chain.forkChoice.getBlockHexDefaultStatus(parentRoot);
|
|
79
76
|
if (parentBlock === null) {
|
|
80
77
|
// If fork choice does *not* consider the parent to be a descendant of the finalized block,
|
|
81
78
|
// then there are two more cases:
|
|
@@ -90,6 +87,27 @@ export async function validateGossipBlock(
|
|
|
90
87
|
throw new BlockGossipError(GossipAction.IGNORE, {code: BlockErrorCode.PARENT_UNKNOWN, parentRoot});
|
|
91
88
|
}
|
|
92
89
|
|
|
90
|
+
// [IGNORE] The block's parent (defined by `block.parent_root`) passes all validation
|
|
91
|
+
// (including execution node verification of the `block.body.execution_payload`)
|
|
92
|
+
if (isForkPostBellatrix(fork) && parentBlock.executionStatus === ExecutionStatus.Invalid) {
|
|
93
|
+
throw new BlockGossipError(GossipAction.IGNORE, {
|
|
94
|
+
code: BlockErrorCode.PARENT_EXECUTION_INVALID,
|
|
95
|
+
parentRoot,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// [IGNORE] The block's parent execution payload (defined by bid.parent_block_hash) has been seen
|
|
100
|
+
// (via gossip or non-gossip sources) (a client MAY queue blocks for processing once the parent payload is retrieved).
|
|
101
|
+
if (isGloasBeaconBlock(block)) {
|
|
102
|
+
const parentBlockHashHex = toRootHex(block.body.signedExecutionPayloadBid.message.parentBlockHash);
|
|
103
|
+
if (chain.forkChoice.getBlockHexAndBlockHash(parentRoot, parentBlockHashHex) === null) {
|
|
104
|
+
throw new BlockGossipError(GossipAction.IGNORE, {
|
|
105
|
+
code: BlockErrorCode.PARENT_PAYLOAD_UNKNOWN,
|
|
106
|
+
parentBlockHash: parentBlockHashHex,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
93
111
|
// [IGNORE] The attestation head block is too far behind the attestation slot, causing many skip slots.
|
|
94
112
|
// This is deemed a DoS risk because we need to get the proposerShuffling. To get the shuffling we have
|
|
95
113
|
// to do a bunch of epoch transitions, the longer the distance between the parent and block,
|
|
@@ -174,7 +192,7 @@ export async function validateGossipBlock(
|
|
|
174
192
|
if (isForkPostBellatrix(fork) && !isForkPostGloas(fork)) {
|
|
175
193
|
if (!isExecutionBlockBodyType(block.body)) throw Error("Not execution block body type");
|
|
176
194
|
const executionPayload = block.body.executionPayload;
|
|
177
|
-
if (blockState.isExecutionStateType && blockState.isExecutionEnabled(block)) {
|
|
195
|
+
if (isStatePostBellatrix(blockState) && blockState.isExecutionStateType && blockState.isExecutionEnabled(block)) {
|
|
178
196
|
const expectedTimestamp = computeTimeAtSlot(config, blockSlot, chain.genesisTime);
|
|
179
197
|
if (executionPayload.timestamp !== computeTimeAtSlot(config, blockSlot, chain.genesisTime)) {
|
|
180
198
|
throw new BlockGossipError(GossipAction.REJECT, {
|
|
@@ -186,6 +204,11 @@ export async function validateGossipBlock(
|
|
|
186
204
|
}
|
|
187
205
|
}
|
|
188
206
|
|
|
207
|
+
// [REJECT] The proposer index is a valid validator index
|
|
208
|
+
if (proposerIndex >= blockState.validatorCount) {
|
|
209
|
+
throw new BlockGossipError(GossipAction.REJECT, {code: BlockErrorCode.UNKNOWN_PROPOSER, proposerIndex});
|
|
210
|
+
}
|
|
211
|
+
|
|
189
212
|
// [REJECT] The proposer signature, signed_beacon_block.signature, is valid with respect to the proposer_index pubkey.
|
|
190
213
|
if (!chain.seenBlockInputCache.isVerifiedProposerSignature(blockSlot, blockRoot, signedBlock.signature)) {
|
|
191
214
|
const signatureSet = getBlockProposerSignatureSet(chain.config, signedBlock);
|
|
@@ -10,11 +10,13 @@ import {
|
|
|
10
10
|
getBlockHeaderProposerSignatureSetByHeaderSlot,
|
|
11
11
|
getBlockHeaderProposerSignatureSetByParentStateSlot,
|
|
12
12
|
} from "@lodestar/state-transition";
|
|
13
|
-
import {DataColumnSidecar, Root, Slot, SubnetID, fulu, ssz} from "@lodestar/types";
|
|
13
|
+
import {DataColumnSidecar, Root, Slot, SubnetID, fulu, gloas, ssz} from "@lodestar/types";
|
|
14
14
|
import {byteArrayEquals, toRootHex, verifyMerkleBranch} from "@lodestar/utils";
|
|
15
15
|
import {BeaconMetrics} from "../../metrics/metrics/beacon.js";
|
|
16
16
|
import {Metrics} from "../../metrics/metrics.js";
|
|
17
|
+
import {getDataColumnSidecarSlot} from "../../util/dataColumns.js";
|
|
17
18
|
import {kzg} from "../../util/kzg.js";
|
|
19
|
+
import {PayloadEnvelopeInput} from "../blocks/payloadEnvelopeInput/index.js";
|
|
18
20
|
import {
|
|
19
21
|
DataColumnSidecarErrorCode,
|
|
20
22
|
DataColumnSidecarGossipError,
|
|
@@ -26,7 +28,7 @@ import {RegenCaller} from "../regen/interface.js";
|
|
|
26
28
|
|
|
27
29
|
// SPEC FUNCTION
|
|
28
30
|
// https://github.com/ethereum/consensus-specs/blob/v1.6.0-alpha.4/specs/fulu/p2p-interface.md#data_column_sidecar_subnet_id
|
|
29
|
-
export async function
|
|
31
|
+
export async function validateGossipFuluDataColumnSidecar(
|
|
30
32
|
chain: IBeaconChain,
|
|
31
33
|
dataColumnSidecar: fulu.DataColumnSidecar,
|
|
32
34
|
gossipSubnet: SubnetID,
|
|
@@ -36,7 +38,7 @@ export async function validateGossipDataColumnSidecar(
|
|
|
36
38
|
const blockRootHex = toRootHex(ssz.phase0.BeaconBlockHeader.hashTreeRoot(blockHeader));
|
|
37
39
|
|
|
38
40
|
// 1) [REJECT] The sidecar is valid as verified by verify_data_column_sidecar
|
|
39
|
-
|
|
41
|
+
verifyFuluDataColumnSidecar(chain.config, dataColumnSidecar);
|
|
40
42
|
|
|
41
43
|
// 2) [REJECT] The sidecar is for the correct subnet -- i.e. compute_subnet_for_data_column_sidecar(sidecar.index) == subnet_id
|
|
42
44
|
if (computeSubnetForDataColumnSidecar(chain.config, dataColumnSidecar) !== gossipSubnet) {
|
|
@@ -203,11 +205,75 @@ export async function validateGossipDataColumnSidecar(
|
|
|
203
205
|
// -- Handled in seenGossipBlockInput
|
|
204
206
|
}
|
|
205
207
|
|
|
208
|
+
// SPEC FUNCTION
|
|
209
|
+
// https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.3/specs/gloas/p2p-interface.md#data_column_sidecar_subnet_id
|
|
210
|
+
export async function validateGossipGloasDataColumnSidecar(
|
|
211
|
+
chain: IBeaconChain,
|
|
212
|
+
payloadInput: PayloadEnvelopeInput,
|
|
213
|
+
dataColumnSidecar: gloas.DataColumnSidecar,
|
|
214
|
+
gossipSubnet: SubnetID,
|
|
215
|
+
metrics: Metrics | null
|
|
216
|
+
): Promise<void> {
|
|
217
|
+
const blockRootHex = toRootHex(dataColumnSidecar.beaconBlockRoot);
|
|
218
|
+
const block = chain.forkChoice.getBlockHexDefaultStatus(blockRootHex);
|
|
219
|
+
|
|
220
|
+
// [IGNORE] A valid block for the sidecar's `slot` has been seen.
|
|
221
|
+
if (block === null) {
|
|
222
|
+
throw new DataColumnSidecarGossipError(GossipAction.IGNORE, {
|
|
223
|
+
code: DataColumnSidecarErrorCode.BLOCK_UNKNOWN,
|
|
224
|
+
blockRoot: blockRootHex,
|
|
225
|
+
slot: dataColumnSidecar.slot,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// [REJECT] The sidecar slot matches the slot of the block with root beacon_block_root.
|
|
230
|
+
if (block.slot !== dataColumnSidecar.slot) {
|
|
231
|
+
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
232
|
+
code: DataColumnSidecarErrorCode.INCORRECT_SIDECAR_SLOT,
|
|
233
|
+
columnIndex: dataColumnSidecar.index,
|
|
234
|
+
expected: block.slot,
|
|
235
|
+
actual: dataColumnSidecar.slot,
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// [REJECT] The sidecar must pass verify_data_column_sidecar against the block commitments
|
|
240
|
+
const kzgCommitments = payloadInput.getBlobKzgCommitments();
|
|
241
|
+
verifyGloasDataColumnSidecar(dataColumnSidecar, kzgCommitments);
|
|
242
|
+
|
|
243
|
+
// [REJECT] The sidecar must be on the correct subnet
|
|
244
|
+
if (computeSubnetForDataColumnSidecar(chain.config, dataColumnSidecar) !== gossipSubnet) {
|
|
245
|
+
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
246
|
+
code: DataColumnSidecarErrorCode.INVALID_SUBNET,
|
|
247
|
+
columnIndex: dataColumnSidecar.index,
|
|
248
|
+
gossipSubnet,
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// [REJECT] The sidecar kzg proofs must verify
|
|
253
|
+
const kzgProofTimer = metrics?.peerDas.dataColumnSidecarKzgProofsVerificationTime.startTimer();
|
|
254
|
+
try {
|
|
255
|
+
await verifyDataColumnSidecarKzgProofs(
|
|
256
|
+
kzgCommitments,
|
|
257
|
+
Array.from({length: dataColumnSidecar.column.length}, () => dataColumnSidecar.index),
|
|
258
|
+
dataColumnSidecar.column,
|
|
259
|
+
dataColumnSidecar.kzgProofs
|
|
260
|
+
);
|
|
261
|
+
} catch {
|
|
262
|
+
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
263
|
+
code: DataColumnSidecarErrorCode.INVALID_KZG_PROOF,
|
|
264
|
+
slot: dataColumnSidecar.slot,
|
|
265
|
+
columnIndex: dataColumnSidecar.index,
|
|
266
|
+
});
|
|
267
|
+
} finally {
|
|
268
|
+
kzgProofTimer?.();
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
206
272
|
/**
|
|
207
273
|
* SPEC FUNCTION
|
|
208
274
|
* https://github.com/ethereum/consensus-specs/blob/v1.6.0-alpha.4/specs/fulu/p2p-interface.md#verify_data_column_sidecar
|
|
209
275
|
*/
|
|
210
|
-
function
|
|
276
|
+
function verifyFuluDataColumnSidecar(config: ChainForkConfig, dataColumnSidecar: fulu.DataColumnSidecar): void {
|
|
211
277
|
if (dataColumnSidecar.index >= NUMBER_OF_COLUMNS) {
|
|
212
278
|
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
213
279
|
code: DataColumnSidecarErrorCode.INVALID_INDEX,
|
|
@@ -250,6 +316,41 @@ function verifyDataColumnSidecar(config: ChainForkConfig, dataColumnSidecar: ful
|
|
|
250
316
|
}
|
|
251
317
|
}
|
|
252
318
|
|
|
319
|
+
/**
|
|
320
|
+
* SPEC FUNCTION
|
|
321
|
+
* https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.3/specs/gloas/p2p-interface.md#modified-verify_data_column_sidecar
|
|
322
|
+
*/
|
|
323
|
+
function verifyGloasDataColumnSidecar(dataColumnSidecar: gloas.DataColumnSidecar, kzgCommitments: Uint8Array[]): void {
|
|
324
|
+
const slot = getDataColumnSidecarSlot(dataColumnSidecar);
|
|
325
|
+
if (dataColumnSidecar.index >= NUMBER_OF_COLUMNS) {
|
|
326
|
+
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
327
|
+
code: DataColumnSidecarErrorCode.INVALID_INDEX,
|
|
328
|
+
slot,
|
|
329
|
+
columnIndex: dataColumnSidecar.index,
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
if (dataColumnSidecar.column.length === 0) {
|
|
334
|
+
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
335
|
+
code: DataColumnSidecarErrorCode.NO_COMMITMENTS,
|
|
336
|
+
slot,
|
|
337
|
+
columnIndex: dataColumnSidecar.index,
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if (
|
|
342
|
+
dataColumnSidecar.column.length !== kzgCommitments.length ||
|
|
343
|
+
dataColumnSidecar.column.length !== dataColumnSidecar.kzgProofs.length
|
|
344
|
+
) {
|
|
345
|
+
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
346
|
+
code: DataColumnSidecarErrorCode.MISMATCHED_LENGTHS,
|
|
347
|
+
columnLength: dataColumnSidecar.column.length,
|
|
348
|
+
commitmentsLength: kzgCommitments.length,
|
|
349
|
+
proofsLength: dataColumnSidecar.kzgProofs.length,
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
253
354
|
/**
|
|
254
355
|
* SPEC FUNCTION
|
|
255
356
|
* https://github.com/ethereum/consensus-specs/blob/v1.6.0-alpha.4/specs/fulu/p2p-interface.md#verify_data_column_sidecar_kzg_proofs
|
|
@@ -287,19 +388,19 @@ export function verifyDataColumnSidecarInclusionProof(dataColumnSidecar: fulu.Da
|
|
|
287
388
|
}
|
|
288
389
|
|
|
289
390
|
/**
|
|
290
|
-
* Validate a subset of data column sidecars
|
|
391
|
+
* Validate a subset of fulu data column sidecars against a block
|
|
291
392
|
*
|
|
292
393
|
* Requires the block to be known to the node
|
|
293
394
|
*
|
|
294
395
|
* NOTE: chain is optional to skip signature verification. Helpful for testing purposes and so that can control whether
|
|
295
396
|
* signature gets checked depending on the reqresp method that is being checked
|
|
296
397
|
*/
|
|
297
|
-
export async function
|
|
398
|
+
export async function validateFuluBlockDataColumnSidecars(
|
|
298
399
|
chain: IBeaconChain | null,
|
|
299
400
|
blockSlot: Slot,
|
|
300
401
|
blockRoot: Root,
|
|
301
402
|
blockBlobCount: number,
|
|
302
|
-
dataColumnSidecars: fulu.
|
|
403
|
+
dataColumnSidecars: fulu.DataColumnSidecar[],
|
|
303
404
|
metrics?: BeaconMetrics["peerDas"] | null
|
|
304
405
|
): Promise<void> {
|
|
305
406
|
metrics?.dataColumnSidecarProcessingRequests.inc(dataColumnSidecars.length);
|
|
@@ -467,6 +568,128 @@ export async function validateBlockDataColumnSidecars(
|
|
|
467
568
|
"DataColumnSidecar has invalid KZG proof batch"
|
|
468
569
|
);
|
|
469
570
|
}
|
|
571
|
+
|
|
572
|
+
metrics?.dataColumnSidecarProcessingSuccesses.inc();
|
|
573
|
+
} finally {
|
|
574
|
+
verificationTimer?.();
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* Validate a subset of gloas data column sidecars against a block
|
|
580
|
+
* Gloas sidecars don't carry signed block headers, kzg commitments, or inclusion proofs
|
|
581
|
+
*/
|
|
582
|
+
export async function validateGloasBlockDataColumnSidecars(
|
|
583
|
+
blockSlot: Slot,
|
|
584
|
+
blockRoot: Root,
|
|
585
|
+
blockKzgCommitments: Uint8Array[],
|
|
586
|
+
dataColumnSidecars: gloas.DataColumnSidecar[],
|
|
587
|
+
metrics?: BeaconMetrics["peerDas"] | null
|
|
588
|
+
): Promise<void> {
|
|
589
|
+
metrics?.dataColumnSidecarProcessingRequests.inc(dataColumnSidecars.length);
|
|
590
|
+
const verificationTimer = metrics?.dataColumnSidecarGossipVerificationTime.startTimer();
|
|
591
|
+
try {
|
|
592
|
+
if (dataColumnSidecars.length === 0) {
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
if (blockKzgCommitments.length === 0) {
|
|
597
|
+
throw new DataColumnSidecarValidationError(
|
|
598
|
+
{
|
|
599
|
+
code: DataColumnSidecarErrorCode.INCORRECT_SIDECAR_COUNT,
|
|
600
|
+
slot: blockSlot,
|
|
601
|
+
expected: 0,
|
|
602
|
+
actual: dataColumnSidecars.length,
|
|
603
|
+
},
|
|
604
|
+
"Block has no blob commitments but data column sidecars were provided"
|
|
605
|
+
);
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
const commitments: Uint8Array[] = [];
|
|
609
|
+
const cellIndices: number[] = [];
|
|
610
|
+
const cells: Uint8Array[] = [];
|
|
611
|
+
const proofs: Uint8Array[] = [];
|
|
612
|
+
for (const columnSidecar of dataColumnSidecars) {
|
|
613
|
+
if (columnSidecar.slot !== blockSlot) {
|
|
614
|
+
throw new DataColumnSidecarValidationError({
|
|
615
|
+
code: DataColumnSidecarErrorCode.INCORRECT_SIDECAR_SLOT,
|
|
616
|
+
columnIndex: columnSidecar.index,
|
|
617
|
+
expected: blockSlot,
|
|
618
|
+
actual: columnSidecar.slot,
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
if (!byteArrayEquals(columnSidecar.beaconBlockRoot, blockRoot)) {
|
|
623
|
+
throw new DataColumnSidecarValidationError({
|
|
624
|
+
code: DataColumnSidecarErrorCode.INCORRECT_BLOCK,
|
|
625
|
+
slot: blockSlot,
|
|
626
|
+
columnIndex: columnSidecar.index,
|
|
627
|
+
expected: toRootHex(blockRoot),
|
|
628
|
+
actual: toRootHex(columnSidecar.beaconBlockRoot),
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
if (columnSidecar.index >= NUMBER_OF_COLUMNS) {
|
|
633
|
+
throw new DataColumnSidecarValidationError(
|
|
634
|
+
{
|
|
635
|
+
code: DataColumnSidecarErrorCode.INVALID_INDEX,
|
|
636
|
+
slot: blockSlot,
|
|
637
|
+
columnIndex: columnSidecar.index,
|
|
638
|
+
},
|
|
639
|
+
"DataColumnSidecar has invalid index"
|
|
640
|
+
);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
if (columnSidecar.column.length !== blockKzgCommitments.length) {
|
|
644
|
+
throw new DataColumnSidecarValidationError({
|
|
645
|
+
code: DataColumnSidecarErrorCode.INCORRECT_CELL_COUNT,
|
|
646
|
+
slot: blockSlot,
|
|
647
|
+
columnIndex: columnSidecar.index,
|
|
648
|
+
expected: blockKzgCommitments.length,
|
|
649
|
+
actual: columnSidecar.column.length,
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
if (columnSidecar.column.length !== columnSidecar.kzgProofs.length) {
|
|
654
|
+
throw new DataColumnSidecarValidationError({
|
|
655
|
+
code: DataColumnSidecarErrorCode.INCORRECT_KZG_PROOF_COUNT,
|
|
656
|
+
slot: blockSlot,
|
|
657
|
+
columnIndex: columnSidecar.index,
|
|
658
|
+
expected: columnSidecar.column.length,
|
|
659
|
+
actual: columnSidecar.kzgProofs.length,
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
commitments.push(...blockKzgCommitments);
|
|
664
|
+
cellIndices.push(...Array.from({length: columnSidecar.column.length}, () => columnSidecar.index));
|
|
665
|
+
cells.push(...columnSidecar.column);
|
|
666
|
+
proofs.push(...columnSidecar.kzgProofs);
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
let reason: string | undefined;
|
|
670
|
+
// batch verification for the cases: downloadByRange and downloadByRoot
|
|
671
|
+
const kzgVerificationTimer = metrics?.kzgVerificationDataColumnBatchTime.startTimer();
|
|
672
|
+
try {
|
|
673
|
+
const valid = await kzg.asyncVerifyCellKzgProofBatch(commitments, cellIndices, cells, proofs);
|
|
674
|
+
if (!valid) {
|
|
675
|
+
reason = "Invalid KZG proof batch";
|
|
676
|
+
}
|
|
677
|
+
} catch (e) {
|
|
678
|
+
reason = (e as Error).message;
|
|
679
|
+
} finally {
|
|
680
|
+
kzgVerificationTimer?.();
|
|
681
|
+
}
|
|
682
|
+
if (reason !== undefined) {
|
|
683
|
+
throw new DataColumnSidecarValidationError(
|
|
684
|
+
{
|
|
685
|
+
code: DataColumnSidecarErrorCode.INVALID_KZG_PROOF_BATCH,
|
|
686
|
+
slot: blockSlot,
|
|
687
|
+
reason,
|
|
688
|
+
},
|
|
689
|
+
"DataColumnSidecar has invalid KZG proof batch"
|
|
690
|
+
);
|
|
691
|
+
}
|
|
692
|
+
|
|
470
693
|
metrics?.dataColumnSidecarProcessingSuccesses.inc();
|
|
471
694
|
} finally {
|
|
472
695
|
verificationTimer?.();
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
createSingleSignatureSetFromComponents,
|
|
4
4
|
getExecutionPayloadBidSigningRoot,
|
|
5
5
|
isActiveBuilder,
|
|
6
|
+
isStatePostGloas,
|
|
6
7
|
} from "@lodestar/state-transition";
|
|
7
8
|
import {gloas} from "@lodestar/types";
|
|
8
9
|
import {toRootHex} from "@lodestar/utils";
|
|
@@ -32,6 +33,9 @@ async function validateExecutionPayloadBid(
|
|
|
32
33
|
const parentBlockRootHex = toRootHex(bid.parentBlockRoot);
|
|
33
34
|
const parentBlockHashHex = toRootHex(bid.parentBlockHash);
|
|
34
35
|
const state = await chain.getHeadStateAtCurrentEpoch(RegenCaller.validateGossipExecutionPayloadBid);
|
|
36
|
+
if (!isStatePostGloas(state)) {
|
|
37
|
+
throw new Error(`Expected gloas+ state for execution payload bid validation, got fork=${state.forkName}`);
|
|
38
|
+
}
|
|
35
39
|
|
|
36
40
|
// [IGNORE] `bid.slot` is the current slot or the next slot.
|
|
37
41
|
const currentSlot = chain.clock.currentSlot;
|
|
@@ -83,9 +87,9 @@ async function validateExecutionPayloadBid(
|
|
|
83
87
|
});
|
|
84
88
|
}
|
|
85
89
|
|
|
86
|
-
// [IGNORE] this bid is the highest value bid seen for the
|
|
87
|
-
//
|
|
88
|
-
const bestBid = chain.executionPayloadBidPool.getBestBid(
|
|
90
|
+
// [IGNORE] this bid is the highest value bid seen for the tuple
|
|
91
|
+
// `(bid.slot, bid.parent_block_hash, bid.parent_block_root)`.
|
|
92
|
+
const bestBid = chain.executionPayloadBidPool.getBestBid(bid.slot, parentBlockHashHex, parentBlockRootHex);
|
|
89
93
|
if (bestBid !== null && bestBid.value >= bid.value) {
|
|
90
94
|
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
91
95
|
code: ExecutionPayloadBidErrorCode.BID_TOO_LOW,
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import {PayloadStatus} from "@lodestar/fork-choice";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
computeStartSlotAtEpoch,
|
|
4
|
+
getExecutionPayloadEnvelopeSignatureSet,
|
|
5
|
+
isStatePostGloas,
|
|
6
|
+
} from "@lodestar/state-transition";
|
|
3
7
|
import {gloas} from "@lodestar/types";
|
|
4
8
|
import {toRootHex} from "@lodestar/utils";
|
|
5
9
|
import {ExecutionPayloadEnvelopeError, ExecutionPayloadEnvelopeErrorCode, GossipAction} from "../errors/index.js";
|
|
@@ -113,7 +117,12 @@ async function validateExecutionPayloadEnvelope(
|
|
|
113
117
|
slot: envelope.slot,
|
|
114
118
|
});
|
|
115
119
|
});
|
|
120
|
+
if (!isStatePostGloas(blockState)) {
|
|
121
|
+
throw new Error(`Expected gloas+ state for execution payload envelope validation, got fork=${blockState.forkName}`);
|
|
122
|
+
}
|
|
116
123
|
|
|
124
|
+
// [REJECT] `signed_execution_payload_envelope.signature` is valid as verified
|
|
125
|
+
// by `verify_execution_payload_envelope_signature`.
|
|
117
126
|
const signatureSet = getExecutionPayloadEnvelopeSignatureSet(
|
|
118
127
|
chain.config,
|
|
119
128
|
chain.pubkeyCache,
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
computeEpochAtSlot,
|
|
3
3
|
createSingleSignatureSetFromComponents,
|
|
4
4
|
getPayloadAttestationDataSigningRoot,
|
|
5
|
+
isStatePostGloas,
|
|
5
6
|
} from "@lodestar/state-transition";
|
|
6
7
|
import {RootHex, gloas, ssz} from "@lodestar/types";
|
|
7
8
|
import {toRootHex} from "@lodestar/utils";
|
|
@@ -66,6 +67,9 @@ async function validatePayloadAttestationMessage(
|
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
const state = chain.getHeadState();
|
|
70
|
+
if (!isStatePostGloas(state)) {
|
|
71
|
+
throw new Error(`Expected gloas+ state for payload attestation validation, got fork=${state.forkName}`);
|
|
72
|
+
}
|
|
69
73
|
|
|
70
74
|
// [REJECT] The message's block `data.beacon_block_root` passes validation.
|
|
71
75
|
// TODO GLOAS: implement this. Technically if we cannot get proto block from fork choice,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {SYNC_COMMITTEE_SUBNET_COUNT, SYNC_COMMITTEE_SUBNET_SIZE} from "@lodestar/params";
|
|
2
|
-
import {IBeaconStateView} from "@lodestar/state-transition";
|
|
2
|
+
import {IBeaconStateView, isStatePostAltair} from "@lodestar/state-transition";
|
|
3
3
|
import {SubnetID, altair} from "@lodestar/types";
|
|
4
4
|
import {toRootHex} from "@lodestar/utils";
|
|
5
5
|
import {GossipAction, SyncCommitteeError, SyncCommitteeErrorCode} from "../errors/index.js";
|
|
@@ -148,6 +148,10 @@ function getIndicesInSubcommittee(
|
|
|
148
148
|
subnet: SubnetID,
|
|
149
149
|
data: Pick<altair.SyncCommitteeMessage, "slot" | "validatorIndex">
|
|
150
150
|
): IndexInSubcommittee[] | null {
|
|
151
|
+
if (!isStatePostAltair(headState)) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
|
|
151
155
|
const syncCommittee = headState.getIndexedSyncCommittee(data.slot);
|
|
152
156
|
const indexesInCommittee = syncCommittee.validatorIndexMap.get(data.validatorIndex);
|
|
153
157
|
if (indexesInCommittee === undefined) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {SYNC_COMMITTEE_SUBNET_SIZE} from "@lodestar/params";
|
|
2
|
-
import {IBeaconStateView, isSyncCommitteeAggregator} from "@lodestar/state-transition";
|
|
2
|
+
import {IBeaconStateView, isStatePostAltair, isSyncCommitteeAggregator} from "@lodestar/state-transition";
|
|
3
3
|
import {ValidatorIndex, altair} from "@lodestar/types";
|
|
4
4
|
import {GossipAction, SyncCommitteeError, SyncCommitteeErrorCode} from "../errors/index.js";
|
|
5
5
|
import {IBeaconChain} from "../interface.js";
|
|
@@ -107,6 +107,10 @@ function getContributionIndices(
|
|
|
107
107
|
state: IBeaconStateView,
|
|
108
108
|
contribution: altair.SyncCommitteeContribution
|
|
109
109
|
): ValidatorIndex[] {
|
|
110
|
+
if (!isStatePostAltair(state)) {
|
|
111
|
+
throw new Error("Expected Altair state for sync committee contribution");
|
|
112
|
+
}
|
|
113
|
+
|
|
110
114
|
const startIndex = contribution.subcommitteeIndex * SYNC_COMMITTEE_SUBNET_SIZE;
|
|
111
115
|
|
|
112
116
|
const syncCommittee = state.getIndexedSyncCommittee(contribution.slot);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {ChainForkConfig} from "@lodestar/config";
|
|
2
|
-
import {
|
|
2
|
+
import {MIN_ATTESTATION_INCLUSION_DELAY, SLOTS_PER_EPOCH} from "@lodestar/params";
|
|
3
3
|
import {
|
|
4
4
|
IBeaconStateView,
|
|
5
5
|
ParticipationFlags,
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
computeStartSlotAtEpoch,
|
|
8
8
|
computeTimeAtSlot,
|
|
9
9
|
getCurrentSlot,
|
|
10
|
+
isStatePostAltair,
|
|
10
11
|
parseAttesterFlags,
|
|
11
12
|
parseParticipationFlags,
|
|
12
13
|
} from "@lodestar/state-transition";
|
|
@@ -740,7 +741,7 @@ export function createValidatorMonitor(
|
|
|
740
741
|
|
|
741
742
|
const rootCache = new RootHexCache(headState);
|
|
742
743
|
|
|
743
|
-
if (
|
|
744
|
+
if (isStatePostAltair(headState)) {
|
|
744
745
|
const prevEpochStartSlot = computeStartSlotAtEpoch(prevEpoch);
|
|
745
746
|
const prevEpochTargetRoot = toRootHex(headState.getBlockRootAtSlot(prevEpochStartSlot));
|
|
746
747
|
|
package/src/db/buckets.ts
CHANGED
|
@@ -67,8 +67,8 @@ export enum Bucket {
|
|
|
67
67
|
// lightClient_bestLightClientUpdate = 55, // SyncPeriod -> LightClientUpdate // DEPRECATED on v1.5.0
|
|
68
68
|
lightClient_bestLightClientUpdate = 56, // SyncPeriod -> [Slot, LightClientUpdate]
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
allForks_dataColumnSidecars = 57, // BeaconBlockRoot -> DataColumnSidecars
|
|
71
|
+
allForks_dataColumnSidecarsArchive = 58, // BeaconBlockSlot -> DataColumnSidecars
|
|
72
72
|
|
|
73
73
|
gloas_executionPayloadEnvelope = 59, // GLOAS BeaconBlockRoot -> SignedExecutionPayloadEnvelope
|
|
74
74
|
gloas_executionPayloadEnvelopeArchive = 60, // GLOAS Slot -> SignedExecutionPayloadEnvelope
|