Skip to content
10 changes: 10 additions & 0 deletions packages/config/src/chainConfig/configs/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,14 @@ export const chainConfig: ChainConfig = {
MAX_BLOBS_PER_BLOCK_ELECTRA: 9,
// MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_ELECTRA
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: 1152,

// Fulu
// `2**12` (= 4096 epochs, ~18 days)
MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS: 4096,
SAMPLES_PER_SLOT: 8,
CUSTODY_REQUIREMENT: 4,
NODE_CUSTODY_REQUIREMENT: 1,
VALIDATOR_CUSTODY_REQUIREMENT: 8,
BALANCE_PER_ADDITIONAL_CUSTODY_GROUP: 32000000000,
MAX_BLOBS_PER_BLOCK_FULU: 12,
};
10 changes: 10 additions & 0 deletions packages/config/src/chainConfig/configs/minimal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,14 @@ export const chainConfig: ChainConfig = {
MAX_BLOBS_PER_BLOCK_ELECTRA: 9,
// MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_ELECTRA
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: 1152,

// Fulu
// `2**12` (= 4096 epochs, ~18 days)
MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS: 4096,
SAMPLES_PER_SLOT: 8,
CUSTODY_REQUIREMENT: 4,
NODE_CUSTODY_REQUIREMENT: 1,
VALIDATOR_CUSTODY_REQUIREMENT: 8,
BALANCE_PER_ADDITIONAL_CUSTODY_GROUP: 32000000000,
MAX_BLOBS_PER_BLOCK_FULU: 12,
};
16 changes: 16 additions & 0 deletions packages/config/src/chainConfig/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,20 @@ export type ChainConfig = {
// Networking
MIN_EPOCHS_FOR_BLOCK_REQUESTS: number;
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: number;
MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS: number;
BLOB_SIDECAR_SUBNET_COUNT: number;
MAX_BLOBS_PER_BLOCK: number;
MAX_REQUEST_BLOB_SIDECARS: number;
BLOB_SIDECAR_SUBNET_COUNT_ELECTRA: number;
MAX_BLOBS_PER_BLOCK_ELECTRA: number;
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: number;

SAMPLES_PER_SLOT: number;
CUSTODY_REQUIREMENT: number;
NODE_CUSTODY_REQUIREMENT: number;
VALIDATOR_CUSTODY_REQUIREMENT: number;
BALANCE_PER_ADDITIONAL_CUSTODY_GROUP: number;
MAX_BLOBS_PER_BLOCK_FULU: number;
};

export const chainConfigTypes: SpecTypes<ChainConfig> = {
Expand Down Expand Up @@ -150,12 +158,20 @@ export const chainConfigTypes: SpecTypes<ChainConfig> = {
// Networking
MIN_EPOCHS_FOR_BLOCK_REQUESTS: "number",
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: "number",
MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS: "number",
BLOB_SIDECAR_SUBNET_COUNT: "number",
MAX_BLOBS_PER_BLOCK: "number",
MAX_REQUEST_BLOB_SIDECARS: "number",
BLOB_SIDECAR_SUBNET_COUNT_ELECTRA: "number",
MAX_BLOBS_PER_BLOCK_ELECTRA: "number",
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: "number",

SAMPLES_PER_SLOT: "number",
CUSTODY_REQUIREMENT: "number",
NODE_CUSTODY_REQUIREMENT: "number",
VALIDATOR_CUSTODY_REQUIREMENT: "number",
BALANCE_PER_ADDITIONAL_CUSTODY_GROUP: "number",
MAX_BLOBS_PER_BLOCK_FULU: "number",
};

/** Allows values in a Spec file */
Expand Down
9 changes: 8 additions & 1 deletion packages/config/src/forkConfig/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,14 @@ export function createForkConfig(config: ChainConfig): ForkConfig {
return sszTypesFor(forkName);
},
getMaxBlobsPerBlock(fork: ForkName): number {
return isForkPostElectra(fork) ? config.MAX_BLOBS_PER_BLOCK_ELECTRA : config.MAX_BLOBS_PER_BLOCK;
switch (fork) {
case ForkName.fulu:
return config.MAX_BLOBS_PER_BLOCK_FULU;
case ForkName.electra:
return config.MAX_BLOBS_PER_BLOCK_ELECTRA;
default:
return config.MAX_BLOBS_PER_BLOCK;
}
},
getMaxRequestBlobSidecars(fork: ForkName): number {
return isForkPostElectra(fork) ? config.MAX_REQUEST_BLOB_SIDECARS_ELECTRA : config.MAX_REQUEST_BLOB_SIDECARS;
Expand Down
14 changes: 14 additions & 0 deletions packages/params/src/forkName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,20 @@ export function isForkPostElectra(fork: ForkName): fork is ForkPostElectra {
return isForkPostDeneb(fork) && fork !== ForkName.deneb;
}

export type ForkPreFulu = ForkPreElectra | ForkName.electra;
export type ForkPostFulu = Exclude<ForkName, ForkPreFulu>;
export const forkPostFulu = exclude(forkAll, [
ForkName.phase0,
ForkName.altair,
ForkName.bellatrix,
ForkName.capella,
ForkName.deneb,
ForkName.electra,
]);
export function isForkPostFulu(fork: ForkName): fork is ForkPostFulu {
return isForkPostElectra(fork) && fork !== ForkName.electra;
}

/*
* Aliases only exported for backwards compatibility. This will be removed in
* lodestar v2.0. The types and guards above should be used in all places as
Expand Down
17 changes: 17 additions & 0 deletions packages/params/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ export const {
MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP,
MAX_PENDING_DEPOSITS_PER_EPOCH,
WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA,

FIELD_ELEMENTS_PER_CELL,
FIELD_ELEMENTS_PER_EXT_BLOB,
KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH,
} = activePreset;

////////////
Expand Down Expand Up @@ -273,3 +277,16 @@ export const NEXT_SYNC_COMMITTEE_INDEX_ELECTRA = 23;
export const DEPOSIT_REQUEST_TYPE = 0x00;
export const WITHDRAWAL_REQUEST_TYPE = 0x01;
export const CONSOLIDATION_REQUEST_TYPE = 0x02;

// 128
export const NUMBER_OF_COLUMNS = (FIELD_ELEMENTS_PER_BLOB * 2) / FIELD_ELEMENTS_PER_CELL;
export const BYTES_PER_CELL = FIELD_ELEMENTS_PER_CELL * BYTES_PER_FIELD_ELEMENT;
export const CELLS_PER_EXT_BLOB = FIELD_ELEMENTS_PER_EXT_BLOB / FIELD_ELEMENTS_PER_CELL;

// ssz.fulu.BeaconBlockBody.getPathInfo(['blobKzgCommitments']).gindex
export const KZG_COMMITMENTS_GINDEX = 27;
export const KZG_COMMITMENTS_SUBTREE_INDEX = KZG_COMMITMENTS_GINDEX - 2 ** KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH;

export const MAX_REQUEST_DATA_COLUMN_SIDECARS = MAX_REQUEST_BLOCKS_DENEB * NUMBER_OF_COLUMNS; // 16384
export const DATA_COLUMN_SIDECAR_SUBNET_COUNT = 128;
export const NUMBER_OF_CUSTODY_GROUPS = 128;
6 changes: 6 additions & 0 deletions packages/params/src/presets/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,10 @@ export const mainnetPreset: BeaconPreset = {
PENDING_CONSOLIDATIONS_LIMIT: 262144,
MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: 2,
WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA: 4096,

// FULU
///////////
FIELD_ELEMENTS_PER_CELL: 64,
FIELD_ELEMENTS_PER_EXT_BLOB: 8192,
KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH: 4,
};
10 changes: 8 additions & 2 deletions packages/params/src/presets/minimal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ export const minimalPreset: BeaconPreset = {
// DENEB
///////////
FIELD_ELEMENTS_PER_BLOB: 4096,
MAX_BLOB_COMMITMENTS_PER_BLOCK: 32,
KZG_COMMITMENT_INCLUSION_PROOF_DEPTH: 10,

// ELECTRA
MAX_DEPOSIT_REQUESTS_PER_PAYLOAD: 4,
Expand All @@ -134,4 +132,12 @@ export const minimalPreset: BeaconPreset = {
PENDING_CONSOLIDATIONS_LIMIT: 64,
MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: 2,
WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA: 4096,
MAX_BLOB_COMMITMENTS_PER_BLOCK: 32,
KZG_COMMITMENT_INCLUSION_PROOF_DEPTH: 10,

// FULU
///////////
FIELD_ELEMENTS_PER_CELL: 64,
FIELD_ELEMENTS_PER_EXT_BLOB: 8192,
KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH: 4,
};
12 changes: 12 additions & 0 deletions packages/params/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ export type BeaconPreset = {
PENDING_CONSOLIDATIONS_LIMIT: number;
MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: number;
WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA: number;

// FULU
///////////
FIELD_ELEMENTS_PER_CELL: number;
FIELD_ELEMENTS_PER_EXT_BLOB: number;
KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH: number;
};

/**
Expand Down Expand Up @@ -195,6 +201,12 @@ export const beaconPresetTypes: BeaconPresetTypes = {
PENDING_CONSOLIDATIONS_LIMIT: "number",
MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: "number",
WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA: "number",

// FULU
///////////
FIELD_ELEMENTS_PER_CELL: "number",
FIELD_ELEMENTS_PER_EXT_BLOB: "number",
KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH: "number",
};

type BeaconPresetTypes = {
Expand Down
15 changes: 6 additions & 9 deletions packages/params/test/e2e/ensure-config-is-synced.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,12 @@ function assertCorrectPreset(localPreset: BeaconPreset, remotePreset: BeaconPres

async function downloadRemoteConfig(preset: "mainnet" | "minimal", commit: string): Promise<BeaconPreset> {
const downloadedParams = await Promise.all(
Object.values(ForkName)
// TODO Fulu: check against remote presets
.filter((forkName) => forkName !== ForkName.fulu)
.map((forkName) =>
axios({
url: `https://raw.githubusercontent.com/ethereum/consensus-specs/${commit}/presets/${preset}/${forkName}.yaml`,
timeout: 30 * 1000,
}).then((response) => loadConfigYaml(response.data))
)
Object.values(ForkName).map((forkName) =>
axios({
url: `https://raw.githubusercontent.com/ethereum/consensus-specs/${commit}/presets/${preset}/${forkName}.yaml`,
timeout: 30 * 1000,
}).then((response) => loadConfigYaml(response.data))
)
);

// Merge all the fetched yamls for the different forks
Expand Down
8 changes: 4 additions & 4 deletions packages/params/test/unit/forkName.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ describe("forkName", () => {
expect(forkAll).toMatchSnapshot();
});

it("should have valid post-bellatrix forks", () => {
expect(forkPostBellatrix).toMatchSnapshot();
});

it("should have valid post-altair forks", () => {
expect(forkPostAltair).toMatchSnapshot();
});

it("should have valid post-bellatrix forks", () => {
expect(forkPostBellatrix).toMatchSnapshot();
});

it("should have valid post-capella forks", () => {
expect(forkPostCapella).toMatchSnapshot();
});
Expand Down
4 changes: 4 additions & 0 deletions packages/types/src/fulu/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from "./types.js";
import * as ssz from "./sszTypes.js";
import * as ts from "./types.js";
export {ts, ssz};
75 changes: 75 additions & 0 deletions packages/types/src/fulu/sszTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import {ByteVectorType, ContainerType, ListBasicType, ListCompositeType, VectorCompositeType} from "@chainsafe/ssz";
import {
BYTES_PER_FIELD_ELEMENT,
FIELD_ELEMENTS_PER_CELL,
KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH,
MAX_BLOB_COMMITMENTS_PER_BLOCK,
MAX_REQUEST_DATA_COLUMN_SIDECARS,
NUMBER_OF_COLUMNS,
} from "@lodestar/params";

import {ssz as altairSsz} from "../altair/index.js";
import {ssz as denebSsz} from "../deneb/index.js";
import {ssz as phase0Ssz} from "../phase0/index.js";
import {ssz as primitiveSsz} from "../primitive/index.js";

const {Root, ColumnIndex, RowIndex, Bytes32, Slot, UintNum64} = primitiveSsz;

export const Metadata = new ContainerType(
{
...altairSsz.Metadata.fields,
custodyGroupCount: UintNum64,
},
{typeName: "Metadata", jsonCase: "eth2"}
);

export const Cell = new ByteVectorType(BYTES_PER_FIELD_ELEMENT * FIELD_ELEMENTS_PER_CELL);
export const DataColumn = new ListCompositeType(Cell, MAX_BLOB_COMMITMENTS_PER_BLOCK);
export const ExtendedMatrix = new ListCompositeType(Cell, MAX_BLOB_COMMITMENTS_PER_BLOCK * NUMBER_OF_COLUMNS);
export const KzgCommitmentsInclusionProof = new VectorCompositeType(Bytes32, KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH);

export const DataColumnSidecar = new ContainerType(
{
index: ColumnIndex,
column: DataColumn,
kzgCommitments: denebSsz.BlobKzgCommitments,
kzgProofs: denebSsz.KZGProofs,
signedBlockHeader: phase0Ssz.SignedBeaconBlockHeader,
kzgCommitmentsInclusionProof: KzgCommitmentsInclusionProof,
},
{typeName: "DataColumnSidecar", jsonCase: "eth2"}
);

export const DataColumnSidecars = new ListCompositeType(DataColumnSidecar, NUMBER_OF_COLUMNS);

export const MatrixEntry = new ContainerType(
{
cell: Cell,
kzgProof: denebSsz.KZGProof,
columnIndex: ColumnIndex,
rowIndex: RowIndex,
},
{typeName: "MatrixEntry", jsonCase: "eth2"}
);

export const DataColumnIdentifier = new ContainerType(
{
blockRoot: Root,
index: ColumnIndex,
},
{typeName: "DataColumnIdentifier", jsonCase: "eth2"}
);

export const DataColumnSidecarsByRootRequest = new ListCompositeType(
DataColumnIdentifier,
MAX_REQUEST_DATA_COLUMN_SIDECARS
);

export const DataColumnSidecarsByRangeRequest = new ContainerType(
{
startSlot: Slot,
count: UintNum64,
columns: new ListBasicType(ColumnIndex, NUMBER_OF_COLUMNS),
},
{typeName: "DataColumnSidecarsByRangeRequest", jsonCase: "eth2"}
);
16 changes: 16 additions & 0 deletions packages/types/src/fulu/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {ValueOf} from "@chainsafe/ssz";
import * as ssz from "./sszTypes.js";

export type Metadata = ValueOf<typeof ssz.Metadata>;

export type Cell = ValueOf<typeof ssz.Cell>;
export type DataColumn = ValueOf<typeof ssz.DataColumn>;
export type ExtendedMatrix = ValueOf<typeof ssz.ExtendedMatrix>;
export type KzgCommitmentsInclusionProof = ValueOf<typeof ssz.KzgCommitmentsInclusionProof>;
export type DataColumnSidecar = ValueOf<typeof ssz.DataColumnSidecar>;
export type DataColumnSidecars = ValueOf<typeof ssz.DataColumnSidecars>;
export type MatrixEntry = ValueOf<typeof ssz.MatrixEntry>;

export type DataColumnIdentifier = ValueOf<typeof ssz.DataColumnIdentifier>;
export type DataColumnSidecarsByRootRequest = ValueOf<typeof ssz.DataColumnSidecarsByRootRequest>;
export type DataColumnSidecarsByRangeRequest = ValueOf<typeof ssz.DataColumnSidecarsByRangeRequest>;
3 changes: 3 additions & 0 deletions packages/types/src/primitive/sszTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,6 @@ export const BLSSignature = Bytes96;
export const Domain = Bytes32;
export const ParticipationFlags = new UintNumberType(1, {setBitwiseOR: true});
export const ExecutionAddress = new ExecutionAddressType();
export const ColumnIndex = UintNum64;
export const CustodyIndex = UintNum64;
export const RowIndex = UintNum64;
3 changes: 3 additions & 0 deletions packages/types/src/primitive/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@ export type ExecutionAddress = Bytes20;
export type RootHex = string;
/** Non-spec type to signal time is represented in seconds */
export type TimeSeconds = number;
export type ColumnIndex = UintNum64;
export type CustodyIndex = UintNum64;
export type RowIndex = UintNum64;
Loading
Loading