mirror of
https://github.com/ChainSafe/lodestar.git
synced 2026-01-10 08:08:16 -05:00
feat: wire in gloas containers (#8485)
Update gloas types in `packages/types/src/types.ts` to use the containers defined in #8464 and fix all type error that come along with it --------- Co-authored-by: Nico Flaig <nflaig@protonmail.com>
This commit is contained in:
@@ -3,12 +3,14 @@ import {ApiError, ApplicationMethods} from "@lodestar/api/server";
|
||||
import {
|
||||
ForkPostBellatrix,
|
||||
ForkPostFulu,
|
||||
ForkPreGloas,
|
||||
NUMBER_OF_COLUMNS,
|
||||
SLOTS_PER_HISTORICAL_ROOT,
|
||||
isForkPostBellatrix,
|
||||
isForkPostDeneb,
|
||||
isForkPostElectra,
|
||||
isForkPostFulu,
|
||||
isForkPostGloas,
|
||||
} from "@lodestar/params";
|
||||
import {
|
||||
computeEpochAtSlot,
|
||||
@@ -360,6 +362,10 @@ export function getBeaconBlockApi({
|
||||
);
|
||||
const fork = config.getForkName(slot);
|
||||
|
||||
if (isForkPostGloas(fork)) {
|
||||
throw new ApiError(400, `Blinded blocks are not available for post-gloas fork=${fork}`);
|
||||
}
|
||||
|
||||
// Either the payload/blobs are cached from i) engine locally or ii) they are from the builder
|
||||
const producedResult = chain.blockProductionCache.get(blockRoot);
|
||||
if (producedResult !== undefined && producedResult.type !== BlockType.Blinded) {
|
||||
@@ -518,9 +524,12 @@ export function getBeaconBlockApi({
|
||||
async getBlindedBlock({blockId}) {
|
||||
const {block, executionOptimistic, finalized} = await getBlockResponse(chain, blockId);
|
||||
const fork = config.getForkName(block.message.slot);
|
||||
if (isForkPostGloas(fork)) {
|
||||
throw new ApiError(400, `Blinded blocks are not available for post-gloas fork=${fork}`);
|
||||
}
|
||||
return {
|
||||
data: isForkPostBellatrix(fork)
|
||||
? signedBeaconBlockToBlinded(config, block as SignedBeaconBlock<ForkPostBellatrix>)
|
||||
? signedBeaconBlockToBlinded(config, block as SignedBeaconBlock<ForkPostBellatrix & ForkPreGloas>)
|
||||
: block,
|
||||
meta: {
|
||||
executionOptimistic,
|
||||
|
||||
@@ -5,6 +5,7 @@ import {ExecutionStatus} from "@lodestar/fork-choice";
|
||||
import {
|
||||
ForkName,
|
||||
ForkPostBellatrix,
|
||||
ForkPreGloas,
|
||||
ForkSeq,
|
||||
GENESIS_SLOT,
|
||||
SLOTS_PER_EPOCH,
|
||||
@@ -887,13 +888,14 @@ export function getValidatorApi(
|
||||
opts
|
||||
);
|
||||
|
||||
if (opts.blindedLocal === true && ForkSeq[meta.version] >= ForkSeq.bellatrix) {
|
||||
const fork = ForkSeq[meta.version];
|
||||
if (opts.blindedLocal === true && fork >= ForkSeq.bellatrix && fork < ForkSeq.gloas) {
|
||||
if (meta.executionPayloadBlinded) {
|
||||
return {data, meta};
|
||||
}
|
||||
|
||||
const {block} = data as BlockContents;
|
||||
const blindedBlock = beaconBlockToBlinded(config, block as BeaconBlock<ForkPostBellatrix>);
|
||||
const blindedBlock = beaconBlockToBlinded(config, block as BeaconBlock<ForkPostBellatrix & ForkPreGloas>);
|
||||
return {
|
||||
data: blindedBlock,
|
||||
meta: {...meta, executionPayloadBlinded: true},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {ForkName, ForkPreDeneb} from "@lodestar/params";
|
||||
import {BlobIndex, ColumnIndex, SignedBeaconBlock, Slot, deneb, fulu} from "@lodestar/types";
|
||||
import {ForkName, ForkPostFulu, ForkPreDeneb, ForkPreGloas} from "@lodestar/params";
|
||||
import {BeaconBlockBody, BlobIndex, ColumnIndex, SignedBeaconBlock, Slot, deneb, fulu} from "@lodestar/types";
|
||||
import {fromHex, prettyBytes, toRootHex, withTimeout} from "@lodestar/utils";
|
||||
import {VersionedHashes} from "../../../execution/index.js";
|
||||
import {kzgCommitmentToVersionedHash} from "../../../util/blobs.js";
|
||||
@@ -715,7 +715,9 @@ export class BlockInputColumns extends AbstractBlockInput<ForkColumnsDA, fulu.Da
|
||||
);
|
||||
}
|
||||
|
||||
const hasAllData = props.block.message.body.blobKzgCommitments.length === 0 || this.state.hasAllData;
|
||||
const hasAllData =
|
||||
(props.block.message.body as BeaconBlockBody<ForkPostFulu & ForkPreGloas>).blobKzgCommitments.length === 0 ||
|
||||
this.state.hasAllData;
|
||||
|
||||
this.state = {
|
||||
...this.state,
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
ForkName,
|
||||
ForkPostAltair,
|
||||
ForkPostBellatrix,
|
||||
ForkPreGloas,
|
||||
ForkSeq,
|
||||
MIN_SYNC_COMMITTEE_PARTICIPANTS,
|
||||
SYNC_COMMITTEE_SIZE,
|
||||
@@ -741,17 +742,24 @@ export function sumBits(bits: BitArray): number {
|
||||
return bits.getTrueBitIndexes().length;
|
||||
}
|
||||
|
||||
export function blockToLightClientHeader(fork: ForkName, block: BeaconBlock<ForkPostAltair>): LightClientHeader {
|
||||
// TODO GLOAS: Pending light-client spec but this function probably won't be used
|
||||
// in Gloas. So we can assume any types here are pre-gloas
|
||||
export function blockToLightClientHeader(
|
||||
fork: ForkName,
|
||||
block: BeaconBlock<ForkPostAltair & ForkPreGloas>
|
||||
): LightClientHeader {
|
||||
const blockSlot = block.slot;
|
||||
const beacon: phase0.BeaconBlockHeader = {
|
||||
slot: blockSlot,
|
||||
proposerIndex: block.proposerIndex,
|
||||
parentRoot: block.parentRoot,
|
||||
stateRoot: block.stateRoot,
|
||||
bodyRoot: (ssz[fork].BeaconBlockBody as SSZTypesFor<ForkPostAltair, "BeaconBlockBody">).hashTreeRoot(block.body),
|
||||
bodyRoot: (ssz[fork].BeaconBlockBody as SSZTypesFor<ForkPostAltair & ForkPreGloas, "BeaconBlockBody">).hashTreeRoot(
|
||||
block.body
|
||||
),
|
||||
};
|
||||
if (ForkSeq[fork] >= ForkSeq.capella) {
|
||||
const blockBody = block.body as BeaconBlockBody<ForkPostBellatrix>;
|
||||
const blockBody = block.body as BeaconBlockBody<ForkPostBellatrix & ForkPreGloas>;
|
||||
const execution = executionPayloadToPayloadHeader(ForkSeq[fork], blockBody.executionPayload);
|
||||
return {
|
||||
beacon,
|
||||
|
||||
@@ -4,9 +4,11 @@ import {
|
||||
ForkPostBellatrix,
|
||||
ForkPostDeneb,
|
||||
ForkPostFulu,
|
||||
ForkPreGloas,
|
||||
ForkSeq,
|
||||
isForkPostAltair,
|
||||
isForkPostBellatrix,
|
||||
isForkPostGloas,
|
||||
} from "@lodestar/params";
|
||||
import {
|
||||
CachedBeaconStateAllForks,
|
||||
@@ -182,7 +184,14 @@ export async function produceBlockBody<T extends BlockType>(
|
||||
};
|
||||
this.logger.verbose("Producing beacon block body", logMeta);
|
||||
|
||||
if (isForkPostBellatrix(fork)) {
|
||||
if (isForkPostGloas(fork)) {
|
||||
// TODO GLOAS: Set body.signedExecutionPayloadBid and body.payloadAttestation
|
||||
const commonBlockBody = await commonBlockBodyPromise;
|
||||
blockBody = Object.assign({}, commonBlockBody) as AssembledBodyType<T>;
|
||||
executionPayloadValue = BigInt(0);
|
||||
|
||||
// We don't deal with blinded blocks, execution engine, blobs and execution requests post-gloas
|
||||
} else if (isForkPostBellatrix(fork)) {
|
||||
const safeBlockHash = this.forkChoice.getJustifiedBlock().executionPayloadBlockHash ?? ZERO_HASH_HEX;
|
||||
const finalizedBlockHash = this.forkChoice.getFinalizedBlock().executionPayloadBlockHash ?? ZERO_HASH_HEX;
|
||||
const feeRecipient = requestedFeeRecipient ?? this.beaconProposerCache.getOrDefault(proposerIndex);
|
||||
@@ -307,6 +316,7 @@ export async function produceBlockBody<T extends BlockType>(
|
||||
|
||||
// blockType === BlockType.Full
|
||||
else {
|
||||
// enginePromise only supports pre-gloas
|
||||
const enginePromise = (async () => {
|
||||
const endExecutionPayload = this.metrics?.executionBlockProductionTimeSteps.startTimer();
|
||||
|
||||
@@ -384,13 +394,13 @@ export async function produceBlockBody<T extends BlockType>(
|
||||
blockBody = Object.assign({}, commonBlockBody) as AssembledBodyType<BlockType.Blinded>;
|
||||
|
||||
if (engineRes.isPremerge) {
|
||||
(blockBody as BeaconBlockBody<ForkPostBellatrix>).executionPayload = engineRes.executionPayload;
|
||||
(blockBody as BeaconBlockBody<ForkPostBellatrix & ForkPreGloas>).executionPayload = engineRes.executionPayload;
|
||||
executionPayloadValue = engineRes.executionPayloadValue;
|
||||
} else {
|
||||
const {prepType, payloadId, executionPayload, blobsBundle, executionRequests} = engineRes;
|
||||
shouldOverrideBuilder = engineRes.shouldOverrideBuilder;
|
||||
|
||||
(blockBody as BeaconBlockBody<ForkPostBellatrix>).executionPayload = executionPayload;
|
||||
(blockBody as BeaconBlockBody<ForkPostBellatrix & ForkPreGloas>).executionPayload = executionPayload;
|
||||
(produceResult as ProduceFullBellatrix).executionPayload = executionPayload;
|
||||
executionPayloadValue = engineRes.executionPayloadValue;
|
||||
Object.assign(logMeta, {transactions: executionPayload.transactions.length, shouldOverrideBuilder});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {ChainForkConfig} from "@lodestar/config";
|
||||
import {CheckpointWithHex} from "@lodestar/fork-choice";
|
||||
import {ForkName, ForkPostFulu, isForkPostDeneb, isForkPostFulu} from "@lodestar/params";
|
||||
import {ForkName, ForkPostFulu, ForkPreGloas, isForkPostDeneb, isForkPostFulu, isForkPostGloas} from "@lodestar/params";
|
||||
import {computeStartSlotAtEpoch} from "@lodestar/state-transition";
|
||||
import {RootHex, SignedBeaconBlock, Slot, deneb, fulu} from "@lodestar/types";
|
||||
import {LodestarError, Logger} from "@lodestar/utils";
|
||||
@@ -155,6 +155,12 @@ export class SeenBlockInput {
|
||||
let blockInput = this.blockInputs.get(blockRootHex) as IBlockInput;
|
||||
if (!blockInput) {
|
||||
const {forkName, daOutOfRange} = this.buildCommonProps(block.message.slot);
|
||||
|
||||
// TODO GLOAS: Implement
|
||||
if (isForkPostGloas(forkName)) {
|
||||
throw Error("Not implemented");
|
||||
}
|
||||
// Pre-deneb
|
||||
if (!isForkPostDeneb(forkName)) {
|
||||
blockInput = BlockInputPreData.createFromBlock({
|
||||
block,
|
||||
@@ -165,9 +171,10 @@ export class SeenBlockInput {
|
||||
seenTimestampSec,
|
||||
peerIdStr,
|
||||
});
|
||||
// Fulu Only
|
||||
} else if (isForkPostFulu(forkName)) {
|
||||
blockInput = BlockInputColumns.createFromBlock({
|
||||
block: block as SignedBeaconBlock<ForkPostFulu>,
|
||||
block: block as SignedBeaconBlock<ForkPostFulu & ForkPreGloas>,
|
||||
blockRootHex,
|
||||
daOutOfRange,
|
||||
forkName,
|
||||
@@ -177,6 +184,7 @@ export class SeenBlockInput {
|
||||
seenTimestampSec,
|
||||
peerIdStr,
|
||||
});
|
||||
// Deneb and Electra
|
||||
} else {
|
||||
blockInput = BlockInputBlobs.createFromBlock({
|
||||
block: block as SignedBeaconBlock<ForkBlobsDA>,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {ChainForkConfig} from "@lodestar/config";
|
||||
import {ForkPostDeneb, ForkPostFulu} from "@lodestar/params";
|
||||
import {ForkPostDeneb, ForkPostFulu, ForkPreFulu, ForkPreGloas} from "@lodestar/params";
|
||||
import {SignedBeaconBlock, Slot, deneb, fulu, phase0} from "@lodestar/types";
|
||||
import {LodestarError, Logger, fromHex, prettyBytes, prettyPrintIndices, toRootHex} from "@lodestar/utils";
|
||||
import {
|
||||
@@ -458,14 +458,16 @@ export function validateBlockByRangeResponse(
|
||||
}
|
||||
|
||||
/**
|
||||
* Should not be called directly. Only exported for unit testing purposes
|
||||
* Should not be called directly. Only exported for unit testing purposes.
|
||||
* This is used only in Deneb and Electra
|
||||
*/
|
||||
export async function validateBlobsByRangeResponse(
|
||||
dataRequestBlocks: ValidatedBlock[],
|
||||
blobSidecars: deneb.BlobSidecars
|
||||
): Promise<ValidatedBlobSidecars[]> {
|
||||
const expectedBlobCount = dataRequestBlocks.reduce(
|
||||
(acc, {block}) => (block as SignedBeaconBlock<ForkPostDeneb>).message.body.blobKzgCommitments.length + acc,
|
||||
(acc, {block}) =>
|
||||
(block as SignedBeaconBlock<ForkPostDeneb & ForkPreFulu>).message.body.blobKzgCommitments.length + acc,
|
||||
0
|
||||
);
|
||||
if (blobSidecars.length > expectedBlobCount) {
|
||||
@@ -492,7 +494,8 @@ export async function validateBlobsByRangeResponse(
|
||||
const validateSidecarsPromises: Promise<ValidatedBlobSidecars>[] = [];
|
||||
for (let blockIndex = 0, blobSidecarIndex = 0; blockIndex < dataRequestBlocks.length; blockIndex++) {
|
||||
const {block, blockRoot} = dataRequestBlocks[blockIndex];
|
||||
const blockKzgCommitments = (block as SignedBeaconBlock<ForkPostDeneb>).message.body.blobKzgCommitments;
|
||||
const blockKzgCommitments = (block as SignedBeaconBlock<ForkPostDeneb & ForkPreFulu>).message.body
|
||||
.blobKzgCommitments;
|
||||
if (blockKzgCommitments.length === 0) {
|
||||
continue;
|
||||
}
|
||||
@@ -532,8 +535,9 @@ export async function validateColumnsByRangeResponse(
|
||||
columnSidecars: fulu.DataColumnSidecars
|
||||
): Promise<WarnResult<ValidatedColumnSidecars[], DownloadByRangeError>> {
|
||||
// Expected column count considering currently-validated batch blocks
|
||||
// TODO GLOAS: Post-gloas's blobKzgCommitments is not in beacon block body. Need to source it from somewhere else.
|
||||
const expectedColumnCount = dataRequestBlocks.reduce((acc, {block}) => {
|
||||
return (block as SignedBeaconBlock<ForkPostDeneb>).message.body.blobKzgCommitments.length > 0
|
||||
return (block as SignedBeaconBlock<ForkPostDeneb & ForkPreGloas>).message.body.blobKzgCommitments.length > 0
|
||||
? request.columns.length + acc
|
||||
: acc;
|
||||
}, 0);
|
||||
@@ -566,7 +570,9 @@ export async function validateColumnsByRangeResponse(
|
||||
const {block, blockRoot} = dataRequestBlocks[blockIndex];
|
||||
const slot = block.message.slot;
|
||||
const blockRootHex = toRootHex(blockRoot);
|
||||
const blockKzgCommitments = (block as SignedBeaconBlock<ForkPostFulu>).message.body.blobKzgCommitments;
|
||||
// TODO GLOAS: Post-gloas's blobKzgCommitments is not in beacon block body. Need to source it from somewhere else.
|
||||
const blockKzgCommitments = (block as SignedBeaconBlock<ForkPostFulu & ForkPreGloas>).message.body
|
||||
.blobKzgCommitments;
|
||||
const expectedColumns = blockKzgCommitments.length ? request.columns.length : 0;
|
||||
|
||||
if (expectedColumns === 0) {
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
import {routes} from "@lodestar/api";
|
||||
import {ChainForkConfig} from "@lodestar/config";
|
||||
import {ForkPostDeneb, ForkPostFulu, ForkPreFulu, isForkPostDeneb, isForkPostFulu} from "@lodestar/params";
|
||||
import {BlobIndex, ColumnIndex, SignedBeaconBlock, Slot, deneb, fulu} from "@lodestar/types";
|
||||
import {
|
||||
ForkPostDeneb,
|
||||
ForkPostFulu,
|
||||
ForkPreFulu,
|
||||
ForkPreGloas,
|
||||
isForkPostDeneb,
|
||||
isForkPostFulu,
|
||||
} from "@lodestar/params";
|
||||
import {BeaconBlockBody, BlobIndex, ColumnIndex, SignedBeaconBlock, Slot, deneb, fulu} from "@lodestar/types";
|
||||
import {LodestarError, fromHex, prettyBytes, prettyPrintIndices, toHex, toRootHex} from "@lodestar/utils";
|
||||
import {isBlockInputBlobs, isBlockInputColumns} from "../../chain/blocks/blockInput/blockInput.js";
|
||||
import {BlockInputSource, IBlockInput} from "../../chain/blocks/blockInput/types.js";
|
||||
@@ -269,7 +276,7 @@ export async function fetchByRoot({
|
||||
missing: network.custodyConfig.sampledColumns,
|
||||
});
|
||||
} else if (isForkPostDeneb(forkName)) {
|
||||
const commitments = (block as SignedBeaconBlock<ForkPostDeneb>).message.body.blobKzgCommitments;
|
||||
const commitments = (block as SignedBeaconBlock<ForkPostDeneb & ForkPreFulu>).message.body.blobKzgCommitments;
|
||||
const blobCount = commitments.length;
|
||||
blobSidecars = await fetchAndValidateBlobs({
|
||||
config,
|
||||
@@ -369,7 +376,8 @@ export async function fetchAndValidateColumns({
|
||||
}: FetchByRootAndValidateColumnsProps): Promise<WarnResult<fulu.DataColumnSidecars, DownloadByRootError>> {
|
||||
const {peerId: peerIdStr} = peerMeta;
|
||||
const slot = block.message.slot;
|
||||
const blobCount = block.message.body.blobKzgCommitments.length;
|
||||
// TODO GLOAS: Get blob count from somewhere else since blobKzgCommitments is absent from block body
|
||||
const blobCount = (block.message.body as BeaconBlockBody<ForkPostFulu & ForkPreGloas>).blobKzgCommitments.length;
|
||||
if (blobCount === 0) {
|
||||
return {result: [], warnings: null};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
import {digest} from "@chainsafe/as-sha256";
|
||||
import {Tree} from "@chainsafe/persistent-merkle-tree";
|
||||
import {ChainForkConfig} from "@lodestar/config";
|
||||
import {ForkAll, ForkName, ForkPostFulu, KZG_COMMITMENTS_GINDEX, NUMBER_OF_COLUMNS} from "@lodestar/params";
|
||||
import {
|
||||
ForkAll,
|
||||
ForkName,
|
||||
ForkPostFulu,
|
||||
ForkPreGloas,
|
||||
KZG_COMMITMENTS_GINDEX,
|
||||
NUMBER_OF_COLUMNS,
|
||||
} from "@lodestar/params";
|
||||
import {signedBlockToSignedHeader} from "@lodestar/state-transition";
|
||||
import {
|
||||
BeaconBlockBody,
|
||||
@@ -303,7 +310,9 @@ export function getDataColumnSidecarsFromBlock(
|
||||
signedBlock: SignedBeaconBlock<ForkPostFulu>,
|
||||
cellsAndKzgProofs: {cells: Uint8Array[]; proofs: Uint8Array[]}[]
|
||||
): fulu.DataColumnSidecars {
|
||||
const blobKzgCommitments = signedBlock.message.body.blobKzgCommitments;
|
||||
// TODO GLOAS: Need to get blobKzgCommitments from somewhere else
|
||||
const blobKzgCommitments = (signedBlock.message.body as BeaconBlockBody<ForkPostFulu & ForkPreGloas>)
|
||||
.blobKzgCommitments;
|
||||
|
||||
// No need to create data column sidecars if there are no blobs
|
||||
if (blobKzgCommitments.length === 0) {
|
||||
|
||||
@@ -4,7 +4,15 @@ import {expect} from "vitest";
|
||||
import {toHexString} from "@chainsafe/ssz";
|
||||
import {createBeaconConfig} from "@lodestar/config";
|
||||
import {CheckpointWithHex, ForkChoice} from "@lodestar/fork-choice";
|
||||
import {ACTIVE_PRESET, ForkPostDeneb, ForkPostFulu, ForkSeq} from "@lodestar/params";
|
||||
import {
|
||||
ACTIVE_PRESET,
|
||||
ForkPostDeneb,
|
||||
ForkPostFulu,
|
||||
ForkPreDeneb,
|
||||
ForkPreFulu,
|
||||
ForkPreGloas,
|
||||
ForkSeq,
|
||||
} from "@lodestar/params";
|
||||
import {InputType} from "@lodestar/spec-test-util";
|
||||
import {BeaconStateAllForks, isExecutionStateType, signedBlockToSignedHeader} from "@lodestar/state-transition";
|
||||
import {
|
||||
@@ -220,13 +228,14 @@ const forkChoiceTest =
|
||||
await validateBlockDataColumnSidecars(
|
||||
slot,
|
||||
blockRoot,
|
||||
(signedBlock as SignedBeaconBlock<ForkPostFulu>).message.body.blobKzgCommitments.length,
|
||||
(signedBlock as SignedBeaconBlock<ForkPostFulu & ForkPreGloas>).message.body.blobKzgCommitments
|
||||
.length,
|
||||
columns
|
||||
);
|
||||
|
||||
blockImport = BlockInputColumns.createFromBlock({
|
||||
forkName: fork,
|
||||
block: signedBlock as SignedBeaconBlock<ForkPostFulu>,
|
||||
block: signedBlock as SignedBeaconBlock<ForkPostFulu & ForkPreGloas>,
|
||||
blockRootHex,
|
||||
custodyColumns:
|
||||
// in most test case instances we do not want to assign any custody as there are no columns provided
|
||||
@@ -286,7 +295,7 @@ const forkChoiceTest =
|
||||
|
||||
blockImport = BlockInputBlobs.createFromBlock({
|
||||
forkName: fork,
|
||||
block: signedBlock as SignedBeaconBlock<ForkPostDeneb>,
|
||||
block: signedBlock as SignedBeaconBlock<ForkPostDeneb & ForkPreFulu>,
|
||||
blockRootHex,
|
||||
source: BlockInputSource.gossip,
|
||||
seenTimestampSec: 0,
|
||||
@@ -303,7 +312,7 @@ const forkChoiceTest =
|
||||
} else {
|
||||
blockImport = BlockInputPreData.createFromBlock({
|
||||
forkName: fork,
|
||||
block: signedBlock as SignedBeaconBlock<ForkPostDeneb>,
|
||||
block: signedBlock as SignedBeaconBlock<ForkPreDeneb>,
|
||||
blockRootHex,
|
||||
source: BlockInputSource.gossip,
|
||||
seenTimestampSec: 0,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {describe, expect, it} from "vitest";
|
||||
import {createChainForkConfig, defaultChainConfig} from "@lodestar/config";
|
||||
import {ForkName, ForkPostCapella, ForkPostDeneb} from "@lodestar/params";
|
||||
import {ForkName, ForkPostCapella, ForkPostDeneb, ForkPreGloas} from "@lodestar/params";
|
||||
import {computeStartSlotAtEpoch, signedBlockToSignedHeader} from "@lodestar/state-transition";
|
||||
import {SignedBeaconBlock, deneb, ssz} from "@lodestar/types";
|
||||
import {BeaconBlockBody, SignedBeaconBlock, deneb, ssz} from "@lodestar/types";
|
||||
import {toRootHex} from "@lodestar/utils";
|
||||
import {
|
||||
AddBlob,
|
||||
@@ -58,7 +58,7 @@ type BlockAndBlobTestSet<F extends ForkPostDeneb = ForkPostDeneb> = BlockTestSet
|
||||
function buildBlockAndBlobsTestSet(forkName: ForkPostDeneb, numberOfBlobs: number): BlockAndBlobTestSet<ForkPostDeneb> {
|
||||
const {block, blockRoot, rootHex} = buildBlockTestSet<ForkPostDeneb>(forkName);
|
||||
const commitments = Array.from({length: numberOfBlobs}, () => Buffer.alloc(48, 0x77));
|
||||
block.message.body.blobKzgCommitments = commitments;
|
||||
(block.message.body as BeaconBlockBody<ForkPostDeneb & ForkPreGloas>).blobKzgCommitments = commitments;
|
||||
const signedBlockHeader = signedBlockToSignedHeader(config, block);
|
||||
const blobSidecars: deneb.BlobSidecars = [];
|
||||
for (const kzgCommitment of commitments) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {generateKeyPair} from "@libp2p/crypto/keys";
|
||||
import {beforeEach, describe, expect, it} from "vitest";
|
||||
import {ForkName, ForkPostFulu} from "@lodestar/params";
|
||||
import {ForkName, ForkPostFulu, ForkPreGloas} from "@lodestar/params";
|
||||
import {signedBlockToSignedHeader} from "@lodestar/state-transition";
|
||||
import {SignedBeaconBlock} from "@lodestar/types";
|
||||
import {toRootHex} from "@lodestar/utils";
|
||||
@@ -310,7 +310,7 @@ describe("SeenBlockInputCache", async () => {
|
||||
});
|
||||
expect(() =>
|
||||
blockInput.addBlock({
|
||||
block: block as SignedBeaconBlock<ForkPostFulu>,
|
||||
block: block as SignedBeaconBlock<ForkPostFulu & ForkPreGloas>,
|
||||
blockRootHex: rootHex,
|
||||
source: BlockInputSource.gossip,
|
||||
seenTimestampSec: Date.now() / 1000,
|
||||
|
||||
@@ -2,7 +2,7 @@ import {Mock, Mocked, beforeEach, describe, it, vi} from "vitest";
|
||||
import {createChainForkConfig} from "@lodestar/config";
|
||||
import {config} from "@lodestar/config/default";
|
||||
import {ProtoBlock} from "@lodestar/fork-choice";
|
||||
import {ForkName, ForkPostDeneb} from "@lodestar/params";
|
||||
import {ForkName, ForkPostDeneb, ForkPreFulu} from "@lodestar/params";
|
||||
import {SignedBeaconBlock, ssz} from "@lodestar/types";
|
||||
import {BlockErrorCode} from "../../../../src/chain/errors/index.js";
|
||||
import {QueuedStateRegenerator} from "../../../../src/chain/regen/index.js";
|
||||
@@ -216,7 +216,7 @@ describe("gossip block validation", () => {
|
||||
// Force proposer shuffling cache to return correct value
|
||||
vi.spyOn(state.epochCtx, "getBeaconProposer").mockReturnValue(proposerIndex + 1);
|
||||
// Add one extra kzg commitment in the block so it goes over the limit
|
||||
(job as SignedBeaconBlock<ForkPostDeneb>).message.body.blobKzgCommitments.push(new Uint8Array([0]));
|
||||
(job as SignedBeaconBlock<ForkPostDeneb & ForkPreFulu>).message.body.blobKzgCommitments.push(new Uint8Array([0]));
|
||||
|
||||
await expectRejectedWithLodestarError(
|
||||
validateGossipBlock(denebConfig, chain, job, ForkName.deneb),
|
||||
|
||||
@@ -7,13 +7,15 @@ import {
|
||||
ForkPostCapella,
|
||||
ForkPostDeneb,
|
||||
ForkPostFulu,
|
||||
ForkPreFulu,
|
||||
ForkPreGloas,
|
||||
NUMBER_OF_COLUMNS,
|
||||
SLOTS_PER_EPOCH,
|
||||
isForkPostDeneb,
|
||||
isForkPostFulu,
|
||||
} from "@lodestar/params";
|
||||
import {computeStartSlotAtEpoch, signedBlockToSignedHeader} from "@lodestar/state-transition";
|
||||
import {SignedBeaconBlock, Slot, deneb, fulu, ssz} from "@lodestar/types";
|
||||
import {BeaconBlockBody, SignedBeaconBlock, Slot, deneb, fulu, ssz} from "@lodestar/types";
|
||||
import {toRootHex} from "@lodestar/utils";
|
||||
import {VersionedHashes} from "../../src/execution/index.js";
|
||||
import {computeNodeIdFromPrivateKey} from "../../src/network/subnets/index.js";
|
||||
@@ -123,11 +125,11 @@ function generateRoots<F extends ForkPostCapella>(
|
||||
}
|
||||
|
||||
function generateBlobSidecars(
|
||||
block: SignedBeaconBlock<ForkPostDeneb>,
|
||||
block: SignedBeaconBlock<ForkPostDeneb & ForkPreFulu>,
|
||||
count: number,
|
||||
oomProtection = false
|
||||
): {
|
||||
block: SignedBeaconBlock<ForkPostDeneb>;
|
||||
block: SignedBeaconBlock<ForkPostDeneb & ForkPreFulu>;
|
||||
blobSidecars: deneb.BlobSidecars;
|
||||
versionedHashes: VersionedHashes;
|
||||
} {
|
||||
@@ -165,7 +167,7 @@ function generateColumnSidecars<F extends ForkPostFulu>(
|
||||
} {
|
||||
const blobs = Array.from({length: numberOfBlobs}, () => generateRandomBlob());
|
||||
const kzgCommitments = blobs.map((blob) => kzg.blobToKzgCommitment(blob));
|
||||
block.message.body.blobKzgCommitments = kzgCommitments;
|
||||
(block.message.body as BeaconBlockBody<ForkPostFulu & ForkPreGloas>).blobKzgCommitments = kzgCommitments;
|
||||
|
||||
const signedBlockHeader = signedBlockToSignedHeader(config, block);
|
||||
const cellsAndProofs = blobs.map((blob) => kzg.computeCellsAndKzgProofs(blob));
|
||||
@@ -253,7 +255,7 @@ export type BlockWithColumnsTestSet<F extends ForkPostFulu> = BlockTestSet<F> &
|
||||
blobs?: deneb.Blob[];
|
||||
};
|
||||
|
||||
export function generateBlockWithBlobSidecars<F extends ForkPostDeneb>({
|
||||
export function generateBlockWithBlobSidecars<F extends ForkPostDeneb & ForkPreFulu>({
|
||||
forkName,
|
||||
slot,
|
||||
count,
|
||||
@@ -331,7 +333,7 @@ export function generateChainOfBlocksWithBlobs<F extends ForkPostDeneb>({
|
||||
const blockWithSidecars = (
|
||||
isForkPostFulu(forkName)
|
||||
? generateBlockWithColumnSidecars<ForkPostFulu>({forkName, parentRoot, slot, oomProtection})
|
||||
: generateBlockWithBlobSidecars<ForkPostDeneb>({
|
||||
: generateBlockWithBlobSidecars<ForkPostDeneb & ForkPreFulu>({
|
||||
forkName,
|
||||
parentRoot,
|
||||
slot,
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
ForkName,
|
||||
ForkPostBellatrix,
|
||||
ForkPostDeneb,
|
||||
ForkPreGloas,
|
||||
ForkSeq,
|
||||
isForkPostBellatrix,
|
||||
isForkPostDeneb,
|
||||
@@ -64,7 +65,7 @@ export function blindedOrFullBlockToHeader(
|
||||
|
||||
export function beaconBlockToBlinded(
|
||||
config: ChainForkConfig,
|
||||
block: BeaconBlock<ForkPostBellatrix>
|
||||
block: BeaconBlock<ForkPostBellatrix & ForkPreGloas>
|
||||
): BlindedBeaconBlock {
|
||||
const fork = config.getForkName(block.slot);
|
||||
const executionPayloadHeader = executionPayloadToPayloadHeader(ForkSeq[fork], block.body.executionPayload);
|
||||
@@ -74,7 +75,7 @@ export function beaconBlockToBlinded(
|
||||
|
||||
export function signedBeaconBlockToBlinded(
|
||||
config: ChainForkConfig,
|
||||
signedBlock: SignedBeaconBlock<ForkPostBellatrix>
|
||||
signedBlock: SignedBeaconBlock<ForkPostBellatrix & ForkPreGloas>
|
||||
): SignedBlindedBeaconBlock {
|
||||
return {
|
||||
message: beaconBlockToBlinded(config, signedBlock.message),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {ForkName, ForkPostBellatrix, ForkSeq} from "@lodestar/params";
|
||||
import {ForkName, ForkPostBellatrix, ForkPreGloas, ForkSeq} from "@lodestar/params";
|
||||
import {
|
||||
BeaconBlock,
|
||||
BeaconBlockBody,
|
||||
@@ -98,8 +98,10 @@ export function isExecutionCachedStateType(state: CachedBeaconStateAllForks): st
|
||||
}
|
||||
|
||||
/** Type guard for ExecutionBlockBody */
|
||||
export function isExecutionBlockBodyType(blockBody: BeaconBlockBody): blockBody is BeaconBlockBody<ForkPostBellatrix> {
|
||||
return (blockBody as BeaconBlockBody<ForkPostBellatrix>).executionPayload !== undefined;
|
||||
export function isExecutionBlockBodyType(
|
||||
blockBody: BeaconBlockBody
|
||||
): blockBody is BeaconBlockBody<ForkPostBellatrix & ForkPreGloas> {
|
||||
return (blockBody as BeaconBlockBody<ForkPostBellatrix & ForkPreGloas>).executionPayload !== undefined;
|
||||
}
|
||||
|
||||
export function getFullOrBlindedPayload(block: BeaconBlock): ExecutionPayload | ExecutionPayloadHeader {
|
||||
|
||||
@@ -5,6 +5,7 @@ import {ts as capella} from "./capella/index.js";
|
||||
import {ts as deneb} from "./deneb/index.js";
|
||||
import {ts as electra} from "./electra/index.js";
|
||||
import {ts as fulu} from "./fulu/index.js";
|
||||
import {ts as gloas} from "./gloas/index.js";
|
||||
import {ts as phase0} from "./phase0/index.js";
|
||||
import {Slot} from "./primitive/types.js";
|
||||
|
||||
@@ -276,10 +277,10 @@ type TypesByFork = {
|
||||
[ForkName.gloas]: {
|
||||
BeaconBlockHeader: phase0.BeaconBlockHeader;
|
||||
SignedBeaconBlockHeader: phase0.SignedBeaconBlockHeader;
|
||||
BeaconBlock: electra.BeaconBlock; // TODO GLOAS: Use Gloas type
|
||||
BeaconBlockBody: electra.BeaconBlockBody; // TODO GLOAS: Use Gloas type
|
||||
BeaconState: electra.BeaconState; // TODO GLOAS: Use Gloas type
|
||||
SignedBeaconBlock: electra.SignedBeaconBlock; // TODO GLOAS: Use Gloas type
|
||||
BeaconBlock: gloas.BeaconBlock;
|
||||
BeaconBlockBody: gloas.BeaconBlockBody;
|
||||
BeaconState: gloas.BeaconState;
|
||||
SignedBeaconBlock: gloas.SignedBeaconBlock;
|
||||
Metadata: fulu.Metadata;
|
||||
Status: fulu.Status;
|
||||
LightClientHeader: deneb.LightClientHeader;
|
||||
|
||||
Reference in New Issue
Block a user