Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement peerDAS on electra #6353

Draft
wants to merge 57 commits into
base: unstable
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
4805a2e
feat: placeholder PR for electra
g11tech Jan 24, 2024
499d93c
feat: implement peerDAS on electra
g11tech Jan 24, 2024
156ef53
fix: docker build issue for c-kzg
matthewkeil Jun 21, 2024
47eedae
feat: get various sync mechanisms working with/without sharded data
g11tech Jul 14, 2024
d423004
feat: add the modifications to work with devnet2
g11tech Jul 14, 2024
a0c5d27
fix: refactor to add and use nodeid computation and clear out nodeid …
g11tech Jul 16, 2024
c7f6341
fix the types/test
g11tech Aug 9, 2024
81aaeb5
feat: add and use metadatav3 for peer custody subnet
g11tech Aug 12, 2024
e6c613f
rename electra fork to peerdas for rebase and make csc in metadata uint8
g11tech Aug 27, 2024
a3533f8
add supernode flag to configure node custody requirement and make it …
g11tech Aug 27, 2024
54579b0
add more info for debugging
g11tech Aug 27, 2024
180f7d8
fix log
g11tech Aug 27, 2024
4b6f167
fix bug
g11tech Aug 27, 2024
ae7678e
fx
g11tech Aug 27, 2024
a33a72f
subnet count 128
g11tech Aug 27, 2024
585165e
remove banning unknown block, addmore log
g11tech Aug 28, 2024
2833ac0
make the csc encoding updates as per latest spec
g11tech Sep 5, 2024
bf08852
resolve availability when datacolumns are downloaded and matched
g11tech Sep 7, 2024
006e781
add debug log
g11tech Sep 7, 2024
aece0ab
fix add missing data availability resolutions
g11tech Sep 10, 2024
387da88
add more log
g11tech Sep 10, 2024
2bc1a0d
add cache tracking
g11tech Sep 10, 2024
5e1de6f
trying some fix
g11tech Sep 10, 2024
d7721f8
fix bug
g11tech Sep 10, 2024
bd84892
more log
g11tech Sep 10, 2024
de341b5
add send more log
g11tech Sep 10, 2024
8c21168
make pull a little less agressive
g11tech Sep 10, 2024
d35873e
further wait till cutoff for all data to be available
g11tech Sep 11, 2024
f7571f4
add some more loggig and availaibility tracking
g11tech Sep 11, 2024
74d8122
add some log for debugging inbound data columns request
g11tech Sep 11, 2024
af933fb
some fixes
g11tech Sep 11, 2024
56c8c6e
custodied column fetch debugging log
g11tech Sep 12, 2024
2b10e4d
datacolumns retrival fix
g11tech Sep 12, 2024
cdd9bae
update compute spec tests
g11tech Sep 12, 2024
c4d04ee
fix the column id compute
g11tech Sep 13, 2024
3470076
more debug log
g11tech Sep 13, 2024
4ec7aff
edge case optimization
g11tech Sep 13, 2024
a33303f
feat: refactor and unit test getDataColumnSidecars (#7072)
matthewkeil Sep 16, 2024
bd4f7f9
feat: update ckzg to final DAS version (#7050)
matthewkeil Sep 16, 2024
b1940ee
fix: remove ckzg build script (#7089)
matthewkeil Sep 17, 2024
20ef4c6
feat: validate data column sidecars (#7073)
matthewkeil Sep 17, 2024
fee7c08
validate inclusion proof
g11tech Sep 17, 2024
574837a
use sample subnets for data availability
g11tech Sep 21, 2024
6a77828
add debug console log
g11tech Sep 21, 2024
cec27d6
handle edge case
g11tech Sep 21, 2024
a3de70f
turn persisting network identity to default true
g11tech Sep 26, 2024
cce193b
improve logging for debugging
g11tech Oct 1, 2024
2736b8c
add enhance datacolumn serving logs
g11tech Oct 1, 2024
a0e0087
more log
g11tech Oct 1, 2024
b04aaef
migrate datacolumns to finalized
g11tech Oct 2, 2024
7c9a01c
add debug and fix datacolumns migration and improve log
g11tech Oct 2, 2024
1c08ab3
some fixing of beacon params
g11tech Oct 2, 2024
513bccc
fix
g11tech Oct 2, 2024
fccf9a2
add prevdownload tracker
g11tech Oct 8, 2024
8689c76
feat: check for no commitments on block or column in sidecar validati…
matthewkeil Oct 22, 2024
c8075d0
feat: log peer disconnect info (#7231)
matthewkeil Nov 25, 2024
e8bc729
refactor: peerdas types (#7243)
matthewkeil Dec 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rename electra fork to peerdas for rebase and make csc in metadata uint8
  • Loading branch information
g11tech committed Aug 27, 2024
commit e6c613f423e5810f96c02560da12209ac5c5cd3e
6 changes: 3 additions & 3 deletions packages/beacon-node/src/api/impl/beacon/blocks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import {ForkExecution, SLOTS_PER_HISTORICAL_ROOT, isForkExecution, ForkName} from "@lodestar/params";
import {sleep, fromHex, toHex} from "@lodestar/utils";
import {
electra,
peerdas,
deneb,
isSignedBlockContents,
ProducedBlockSource,
Expand Down Expand Up @@ -72,13 +72,13 @@ export function getBeaconBlockApi({
let blockForImport: BlockInput,
signedBlock: SignedBeaconBlock,
blobSidecars: deneb.BlobSidecars,
dataColumnSidecars: electra.DataColumnSidecars;
dataColumnSidecars: peerdas.DataColumnSidecars;

if (isSignedBlockContents(signedBlockOrContents)) {
({signedBlock} = signedBlockOrContents);
const fork = config.getForkName(signedBlock.message.slot);
let blockData: BlockInputData;
if (fork === ForkName.electra) {
if (fork === ForkName.peerdas) {
dataColumnSidecars = computeDataColumnSidecars(config, signedBlock, signedBlockOrContents);
blockData = {
fork,
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/src/chain/blocks/importBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export async function importBlock(
versionedHash: toHexString(kzgCommitmentToVersionedHash(kzgCommitment)),
});
}
} else if (blockData.fork === ForkName.electra) {
} else if (blockData.fork === ForkName.peerdas) {
// TODO peerDAS build and emit the event for the datacolumns
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/beacon-node/src/chain/blocks/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {CachedBeaconStateAllForks, computeEpochAtSlot} from "@lodestar/state-transition";
import {MaybeValidExecutionStatus, DataAvailabilityStatus} from "@lodestar/fork-choice";
import {deneb, Slot, RootHex, SignedBeaconBlock, electra, ColumnIndex} from "@lodestar/types";
import {deneb, Slot, RootHex, SignedBeaconBlock, peerdas, ColumnIndex} from "@lodestar/types";
import {ForkSeq, ForkName} from "@lodestar/params";
import {ChainForkConfig} from "@lodestar/config";

Expand Down Expand Up @@ -45,19 +45,19 @@ export enum GossipedInputType {
export type BlobsCacheMap = Map<number, {blobSidecar: deneb.BlobSidecar; blobBytes: Uint8Array | null}>;
export type DataColumnsCacheMap = Map<
number,
{dataColumnSidecar: electra.DataColumnSidecar; dataColumnBytes: Uint8Array | null}
{dataColumnSidecar: peerdas.DataColumnSidecar; dataColumnBytes: Uint8Array | null}
>;

type ForkBlobsInfo = {fork: ForkName.deneb};
type BlobsData = {blobs: deneb.BlobSidecars; blobsBytes: (Uint8Array | null)[]; blobsSource: BlobsSource};
export type BlockInputDataBlobs = ForkBlobsInfo & BlobsData;

type ForkDataColumnsInfo = {fork: ForkName.electra};
type ForkDataColumnsInfo = {fork: ForkName.peerdas};
type DataColumnsData = {
// marker of that columns are to be custodied
dataColumnsLen: number;
dataColumnsIndex: Uint8Array;
dataColumns: electra.DataColumnSidecars;
dataColumns: peerdas.DataColumnSidecars;
dataColumnsBytes: (Uint8Array | null)[];
dataColumnsSource: DataColumnsSource;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ async function maybeValidateBlobs(
// but other checks to match blobs with block data still need to be performed
const skipProofsCheck = opts.validBlobSidecars === BlobSidecarValidation.Individual;
validateBlobSidecars(blockSlot, beaconBlockRoot, blobKzgCommitments, blobs, {skipProofsCheck});
} else if (blockData.fork === ForkName.electra) {
} else if (blockData.fork === ForkName.peerdas) {
const {dataColumns} = blockData;
const skipProofsCheck = opts.validBlobSidecars === BlobSidecarValidation.Individual;
// might require numColumns, custodyColumns from blockData as input to below
Expand Down
12 changes: 6 additions & 6 deletions packages/beacon-node/src/chain/blocks/writeBlockInputToDb.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {ForkName} from "@lodestar/params";
import {toHex} from "@lodestar/utils";
import {electra, ssz} from "@lodestar/types";
import {peerdas, ssz} from "@lodestar/types";
import {BeaconChain} from "../chain.js";
import {BlockInput, BlockInputType} from "./types.js";

Expand Down Expand Up @@ -48,11 +48,11 @@ export async function writeBlockInputToDb(this: BeaconChain, blocksInput: BlockI
});
} else {
const {dataColumnsLen, dataColumnsIndex, dataColumns: dataColumnSidecars} = blockData;
const blobsLen = (block.message as electra.BeaconBlock).body.blobKzgCommitments.length;
const blobsLen = (block.message as peerdas.BeaconBlock).body.blobKzgCommitments.length;

const dataColumnsSize =
ssz.electra.DataColumnSidecar.minSize +
blobsLen * (ssz.electra.Cell.fixedSize + ssz.deneb.KZGCommitment.fixedSize + ssz.deneb.KZGProof.fixedSize);
ssz.peerdas.DataColumnSidecar.minSize +
blobsLen * (ssz.peerdas.Cell.fixedSize + ssz.deneb.KZGCommitment.fixedSize + ssz.deneb.KZGProof.fixedSize);
const slot = block.message.slot;
const writeData = {
blockRoot,
Expand Down Expand Up @@ -99,8 +99,8 @@ export async function removeEagerlyPersistedBlockInputs(this: BeaconChain, block
blobsToRemove.push({blockRoot, slot, blobSidecars});
} else {
const {dataColumnsLen, dataColumnsIndex, dataColumns: dataColumnSidecars} = blockData;
const blobsLen = (block.message as electra.BeaconBlock).body.blobKzgCommitments.length;
const dataColumnsSize = ssz.electra.Cell.fixedSize * blobsLen;
const blobsLen = (block.message as peerdas.BeaconBlock).body.blobKzgCommitments.length;
const dataColumnsSize = ssz.peerdas.Cell.fixedSize * blobsLen;

dataColumnsToRemove.push({
blockRoot,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {toHexString} from "@chainsafe/ssz";
import {deneb, RootHex, SignedBeaconBlock, ssz, electra} from "@lodestar/types";
import {deneb, RootHex, SignedBeaconBlock, ssz, peerdas} from "@lodestar/types";
import {ChainForkConfig} from "@lodestar/config";
import {pruneSetToMax} from "@lodestar/utils";
import {BLOBSIDECAR_FIXED_SIZE, isForkBlobs, ForkName, NUMBER_OF_COLUMNS} from "@lodestar/params";
Expand Down Expand Up @@ -31,7 +31,7 @@ type GossipedBlockInput =
| {type: GossipedInputType.blob; blobSidecar: deneb.BlobSidecar; blobBytes: Uint8Array | null}
| {
type: GossipedInputType.dataColumn;
dataColumnSidecar: electra.DataColumnSidecar;
dataColumnSidecar: peerdas.DataColumnSidecar;
dataColumnBytes: Uint8Array | null;
};

Expand Down Expand Up @@ -127,8 +127,8 @@ export class SeenGossipBlockInput {

blockHex = toHexString(blockRoot);
blockCache = this.blockInputCache.get(blockHex) ?? getEmptyBlockInputCacheEntry(fork);
if (blockCache.cachedData?.fork !== ForkName.electra) {
throw Error(`blob data at non electra fork=${blockCache.fork}`);
if (blockCache.cachedData?.fork !== ForkName.peerdas) {
throw Error(`blob data at non peerdas fork=${blockCache.fork}`);
}

// TODO: freetheblobs check if its the same blob or a duplicate and throw/take actions
Expand Down Expand Up @@ -215,7 +215,7 @@ export class SeenGossipBlockInput {
},
};
}
} else if (cachedData.fork === ForkName.electra) {
} else if (cachedData.fork === ForkName.peerdas) {
const {dataColumnsCache} = cachedData;

// block is available, check if all blobs have shown up
Expand Down Expand Up @@ -330,7 +330,7 @@ export class SeenGossipBlockInput {
},
blockInputMeta: {pending: GossipedInputType.block, haveBlobs: blobsCache.size, expectedBlobs: null},
};
} else if (fork === ForkName.electra) {
} else if (fork === ForkName.peerdas) {
const {dataColumnsCache} = cachedData;

return {
Expand Down Expand Up @@ -376,7 +376,7 @@ export function getEmptyBlockInputCacheEntry(fork: ForkName): BlockInputCacheTyp
const blobsCache = new Map();
const cachedData: CachedData = {fork, blobsCache, availabilityPromise, resolveAvailability};
return {fork, blockInputPromise, resolveBlockInput, cachedData};
} else if (fork === ForkName.electra) {
} else if (fork === ForkName.peerdas) {
let resolveAvailability: ((blobs: BlockInputDataDataColumns) => void) | null = null;
const availabilityPromise = new Promise<BlockInputDataDataColumns>((resolveCB) => {
resolveAvailability = resolveCB;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
DATA_COLUMN_SIDECAR_SUBNET_COUNT,
NUMBER_OF_COLUMNS,
} from "@lodestar/params";
import {ssz, deneb, electra, Slot, Root} from "@lodestar/types";
import {ssz, deneb, peerdas, Slot, Root} from "@lodestar/types";
import {verifyMerkleBranch} from "@lodestar/utils";

import {DataColumnSidecarGossipError, DataColumnSidecarErrorCode} from "../errors/dataColumnSidecarError.js";
Expand All @@ -13,7 +13,7 @@ import {IBeaconChain} from "../interface.js";

export async function validateGossipDataColumnSidecar(
chain: IBeaconChain,
dataColumnSideCar: electra.DataColumnSidecar,
dataColumnSideCar: peerdas.DataColumnSidecar,
gossipIndex: number
): Promise<void> {
const dataColumnSlot = dataColumnSideCar.signedBlockHeader.message.slot;
Expand Down Expand Up @@ -48,14 +48,14 @@ export function validateDataColumnsSidecars(
_blockSlot: Slot,
_blockRoot: Root,
_expectedKzgCommitments: deneb.BlobKzgCommitments,
_dataColumnSidecars: electra.DataColumnSidecars,
_dataColumnSidecars: peerdas.DataColumnSidecars,
_opts: {skipProofsCheck: boolean} = {skipProofsCheck: false}
): void {
// stubbed
return;
}

function validateInclusionProof(dataColumnSidecar: electra.DataColumnSidecar): boolean {
function validateInclusionProof(dataColumnSidecar: peerdas.DataColumnSidecar): boolean {
return verifyMerkleBranch(
ssz.deneb.BlobKzgCommitments.hashTreeRoot(dataColumnSidecar.kzgCommitments),
dataColumnSidecar.kzgCommitmentsInclusionProof,
Expand Down
4 changes: 2 additions & 2 deletions packages/beacon-node/src/db/buckets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ export enum Bucket {
// lightClient_bestLightClientUpdate = 55, // SyncPeriod -> LightClientUpdate // DEPRECATED on v1.5.0
lightClient_bestLightClientUpdate = 56, // SyncPeriod -> [Slot, LightClientUpdate]

allForks_dataColumnSidecars = 57, // ELECTRA BeaconBlockRoot -> DataColumnSidecars
allForks_dataColumnSidecarsArchive = 58, // ELECTRA BeaconBlockSlot -> DataColumnSidecars
allForks_dataColumnSidecars = 57, // PEERDAS BeaconBlockRoot -> DataColumnSidecars
allForks_dataColumnSidecarsArchive = 58, // PEERDAS BeaconBlockSlot -> DataColumnSidecars
}

export function getBucketNameByValue<T extends Bucket>(enumValue: T): keyof typeof Bucket {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const dataColumnSidecarsWrapperSsz = new ContainerType(
// // each byte[i] tells what index (1 based) the column i is stored, 0 means not custodied
// max value to represent will be 128 which can be represented in a byte
dataColumnsIndex: new ByteVectorType(NUMBER_OF_COLUMNS),
dataColumnSidecars: ssz.electra.DataColumnSidecars,
dataColumnSidecars: ssz.peerdas.DataColumnSidecars,
},
{typeName: "DataColumnSidecarsWrapper", jsonCase: "eth2"}
);
Expand Down
6 changes: 3 additions & 3 deletions packages/beacon-node/src/network/gossip/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
phase0,
SignedBeaconBlock,
Slot,
electra,
peerdas,
} from "@lodestar/types";
import {BeaconConfig} from "@lodestar/config";
import {Logger} from "@lodestar/utils";
Expand Down Expand Up @@ -83,7 +83,7 @@ export type SSZTypeOfGossipTopic<T extends GossipTopic> = T extends {type: infer
export type GossipTypeMap = {
[GossipType.beacon_block]: SignedBeaconBlock;
[GossipType.blob_sidecar]: deneb.BlobSidecar;
[GossipType.data_column_sidecar]: electra.DataColumnSidecar;
[GossipType.data_column_sidecar]: peerdas.DataColumnSidecar;
[GossipType.beacon_aggregate_and_proof]: phase0.SignedAggregateAndProof;
[GossipType.beacon_attestation]: phase0.Attestation;
[GossipType.voluntary_exit]: phase0.SignedVoluntaryExit;
Expand All @@ -99,7 +99,7 @@ export type GossipTypeMap = {
export type GossipFnByType = {
[GossipType.beacon_block]: (signedBlock: SignedBeaconBlock) => Promise<void> | void;
[GossipType.blob_sidecar]: (blobSidecar: deneb.BlobSidecar) => Promise<void> | void;
[GossipType.data_column_sidecar]: (blobSidecar: electra.DataColumnSidecar) => Promise<void> | void;
[GossipType.data_column_sidecar]: (blobSidecar: peerdas.DataColumnSidecar) => Promise<void> | void;
[GossipType.beacon_aggregate_and_proof]: (aggregateAndProof: phase0.SignedAggregateAndProof) => Promise<void> | void;
[GossipType.beacon_attestation]: (attestation: phase0.Attestation) => Promise<void> | void;
[GossipType.voluntary_exit]: (voluntaryExit: phase0.SignedVoluntaryExit) => Promise<void> | void;
Expand Down
6 changes: 3 additions & 3 deletions packages/beacon-node/src/network/gossip/topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function getGossipSSZType(topic: GossipTopic) {
case GossipType.blob_sidecar:
return ssz.deneb.BlobSidecar;
case GossipType.data_column_sidecar:
return ssz.electra.DataColumnSidecar;
return ssz.peerdas.DataColumnSidecar;
case GossipType.beacon_aggregate_and_proof:
return ssz.phase0.SignedAggregateAndProof;
case GossipType.beacon_attestation:
Expand Down Expand Up @@ -224,8 +224,8 @@ export function getCoreTopicsAtFork(
{type: GossipType.attester_slashing},
];

// After Electra also track data_column_sidecar_{index}
if (ForkSeq[fork] >= ForkSeq.electra) {
// After Peerdas also track data_column_sidecar_{index}
if (ForkSeq[fork] >= ForkSeq.peerdas) {
for (let index = 0; index < DATA_COLUMN_SIDECAR_SUBNET_COUNT; index++) {
topics.push({type: GossipType.data_column_sidecar, index});
}
Expand Down
12 changes: 6 additions & 6 deletions packages/beacon-node/src/network/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
capella,
deneb,
phase0,
electra,
peerdas,
} from "@lodestar/types";
import {PeerIdStr} from "../util/peerId.js";
import {CustodyConfig} from "../util/dataColumns.js";
Expand Down Expand Up @@ -77,17 +77,17 @@ export interface INetwork extends INetworkCorePublic {
sendBlobSidecarsByRoot(peerId: PeerIdStr, request: deneb.BlobSidecarsByRootRequest): Promise<deneb.BlobSidecar[]>;
sendDataColumnSidecarsByRange(
peerId: PeerIdStr,
request: electra.DataColumnSidecarsByRangeRequest
): Promise<electra.DataColumnSidecar[]>;
request: peerdas.DataColumnSidecarsByRangeRequest
): Promise<peerdas.DataColumnSidecar[]>;
sendDataColumnSidecarsByRoot(
peerId: PeerIdStr,
request: electra.DataColumnSidecarsByRootRequest
): Promise<electra.DataColumnSidecar[]>;
request: peerdas.DataColumnSidecarsByRootRequest
): Promise<peerdas.DataColumnSidecar[]>;

// Gossip
publishBeaconBlock(signedBlock: SignedBeaconBlock): Promise<number>;
publishBlobSidecar(blobSidecar: deneb.BlobSidecar): Promise<number>;
publishDataColumnSidecar(dataColumnSideCar: electra.DataColumnSidecar): Promise<number>;
publishDataColumnSidecar(dataColumnSideCar: peerdas.DataColumnSidecar): Promise<number>;
publishBeaconAggregateAndProof(aggregateAndProof: phase0.SignedAggregateAndProof): Promise<number>;
publishBeaconAttestation(attestation: phase0.Attestation, subnet: number): Promise<number>;
publishVoluntaryExit(voluntaryExit: phase0.SignedVoluntaryExit): Promise<number>;
Expand Down
12 changes: 6 additions & 6 deletions packages/beacon-node/src/network/metadata.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {BitArray} from "@chainsafe/ssz";
import {ForkSeq} from "@lodestar/params";
import {computeStartSlotAtEpoch} from "@lodestar/state-transition";
import {altair, Epoch, phase0, ssz, electra} from "@lodestar/types";
import {altair, Epoch, phase0, ssz, peerdas} from "@lodestar/types";
import {BeaconConfig} from "@lodestar/config";
import {FAR_FUTURE_EPOCH} from "../constants/index.js";
import {getCurrentAndNextFork} from "./forks.js";
Expand All @@ -19,7 +19,7 @@ export enum SubnetType {
}

export type MetadataOpts = {
metadata?: electra.Metadata;
metadata?: peerdas.Metadata;
};

export type MetadataModules = {
Expand All @@ -35,13 +35,13 @@ export type MetadataModules = {
export class MetadataController {
private onSetValue: (key: string, value: Uint8Array) => void;
private config: BeaconConfig;
private _metadata: electra.Metadata;
private _metadata: peerdas.Metadata;

constructor(opts: MetadataOpts, modules: MetadataModules) {
this.config = modules.config;
this.onSetValue = modules.onSetValue;
this._metadata = opts.metadata ?? {
...ssz.electra.Metadata.defaultValue(),
...ssz.peerdas.Metadata.defaultValue(),
csc: Math.max(this.config.CUSTODY_REQUIREMENT, this.config.NODE_CUSTODY_REQUIREMENT),
};
}
Expand All @@ -58,7 +58,7 @@ export class MetadataController {
this.onSetValue(ENRKey.syncnets, ssz.phase0.AttestationSubnets.serialize(this._metadata.syncnets));
}

if (this.config.getForkSeq(computeStartSlotAtEpoch(currentEpoch)) >= ForkSeq.electra) {
if (this.config.getForkSeq(computeStartSlotAtEpoch(currentEpoch)) >= ForkSeq.peerdas) {
this.onSetValue(ENRKey.csc, ssz.Uint8.serialize(this._metadata.csc));
}
}
Expand Down Expand Up @@ -96,7 +96,7 @@ export class MetadataController {
}

/** Consumers that need the phase0.Metadata type can just ignore the .syncnets property */
get json(): electra.Metadata {
get json(): peerdas.Metadata {
return this._metadata;
}

Expand Down
12 changes: 6 additions & 6 deletions packages/beacon-node/src/network/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
LightClientFinalityUpdate,
LightClientOptimisticUpdate,
LightClientUpdate,
electra,
peerdas,
ColumnIndex,
} from "@lodestar/types";
import {routes} from "@lodestar/api";
Expand Down Expand Up @@ -335,7 +335,7 @@ export class Network implements INetwork {
});
}

async publishDataColumnSidecar(dataColumnSidecar: electra.DataColumnSidecar): Promise<number> {
async publishDataColumnSidecar(dataColumnSidecar: peerdas.DataColumnSidecar): Promise<number> {
const slot = dataColumnSidecar.signedBlockHeader.message.slot;
const fork = this.config.getForkName(slot);
const index = dataColumnSidecar.index % DATA_COLUMN_SIDECAR_SUBNET_COUNT;
Expand Down Expand Up @@ -551,8 +551,8 @@ export class Network implements INetwork {

async sendDataColumnSidecarsByRange(
peerId: PeerIdStr,
request: electra.DataColumnSidecarsByRangeRequest
): Promise<electra.DataColumnSidecar[]> {
request: peerdas.DataColumnSidecarsByRangeRequest
): Promise<peerdas.DataColumnSidecar[]> {
return collectMaxResponseTyped(
this.sendReqRespRequest(peerId, ReqRespMethod.DataColumnSidecarsByRange, [Version.V1], request),
// request's count represent the slots, so the actual max count received could be slots * blobs per slot
Expand All @@ -563,8 +563,8 @@ export class Network implements INetwork {

async sendDataColumnSidecarsByRoot(
peerId: PeerIdStr,
request: electra.DataColumnSidecarsByRootRequest
): Promise<electra.DataColumnSidecar[]> {
request: peerdas.DataColumnSidecarsByRootRequest
): Promise<peerdas.DataColumnSidecar[]> {
return collectMaxResponseTyped(
this.sendReqRespRequest(peerId, ReqRespMethod.DataColumnSidecarsByRoot, [Version.V1], request),
request.length,
Expand Down
Loading