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

chore: integrate peerdas-kzg #6923

Draft
wants to merge 25 commits into
base: peerDAS
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
08884f8
feat: placeholder PR for electra
g11tech Jan 24, 2024
b1481f1
feat: implement peerDAS on electra
g11tech Jan 24, 2024
7dab01e
fix: docker build issue for c-kzg
matthewkeil Jun 21, 2024
ae1a03e
rebase fixes
g11tech Jun 26, 2024
38fc1b4
fix: update c-zkg install workflow
matthewkeil Jun 26, 2024
2b26a4e
feat: add trustedSetupPrecompute cli flag
matthewkeil Jun 26, 2024
33e8ba2
fix: update trusted-setup for testing
matthewkeil Jun 26, 2024
c210176
fix: update c-zkg install workflow to remove sudo
matthewkeil Jun 26, 2024
952b65f
add dep
kevaundray Jun 29, 2024
ca67a07
update peerdas lib
kevaundray Jun 30, 2024
1cb31a4
add rough idea
kevaundray Jun 30, 2024
f2d2917
modify code to call the exported computeCellsAndProofs method
kevaundray Jun 30, 2024
83a137c
add false to use ckzg
kevaundray Jun 30, 2024
ae0c46c
add todo re lib switching
kevaundray Jun 30, 2024
50dfe26
revert yarn.lock
kevaundray Jun 30, 2024
89ca708
yarn add "@crate-crypto/peerdas-kzg@0.2.2-5f4e791.0" --exact
kevaundray Jun 30, 2024
02f7c67
use tsc --define to set the library to use
kevaundray Jun 30, 2024
039f170
Merge branch 'peerDAS' into kw/peerdas-rust-lib-integration
kevaundray Aug 16, 2024
313af86
use v0.4.1 plus name-change
kevaundray Aug 16, 2024
5e9c747
refactor: package name has changed
kevaundray Aug 16, 2024
f8f5bf8
yarn lint
kevaundray Aug 16, 2024
5557728
Fix: github has problems merging branch due to force merge
kevaundray Aug 16, 2024
c03f297
revert lockfile and regenerate by running `yarn`
kevaundray Aug 16, 2024
3b69703
change import to node-eth-kzg
kevaundray Aug 16, 2024
0f04d36
update API and add notes on how to upgrade
kevaundray Aug 16, 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
Next Next commit
feat: placeholder PR for electra
add types stub and epoch config

fix types
  • Loading branch information
g11tech committed Jun 25, 2024
commit 08884f8f114655249b38adfb00af5f8db786f660
2 changes: 1 addition & 1 deletion packages/beacon-node/src/chain/blocks/types.ts
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ export enum GossipedInputType {

type BlobsCacheMap = Map<number, {blobSidecar: deneb.BlobSidecar; blobBytes: Uint8Array | null}>;

type ForkBlobsInfo = {fork: ForkName.deneb};
type ForkBlobsInfo = {fork: ForkName.deneb | ForkName.electra};
type BlobsData = {blobs: deneb.BlobSidecars; blobsBytes: (Uint8Array | null)[]; blobsSource: BlobsSource};
export type BlockInputDataBlobs = ForkBlobsInfo & BlobsData;
export type BlockInputData = BlockInputDataBlobs;
2 changes: 2 additions & 0 deletions packages/beacon-node/test/spec/presets/fork.test.ts
Original file line number Diff line number Diff line change
@@ -35,6 +35,8 @@ const fork: TestRunnerFn<ForkStateCase, BeaconStateAllForks> = (forkNext) => {
return slotFns.upgradeStateToCapella(preState as CachedBeaconStateBellatrix);
case ForkName.deneb:
return slotFns.upgradeStateToDeneb(preState as CachedBeaconStateCapella);
case ForkName.electra:
throw Error("not Implemented");
}
},
options: {
8 changes: 8 additions & 0 deletions packages/beacon-node/test/spec/presets/transition.test.ts
Original file line number Diff line number Diff line change
@@ -102,6 +102,14 @@ function getTransitionConfig(fork: ForkName, forkEpoch: number): Partial<ChainCo
return {ALTAIR_FORK_EPOCH: 0, BELLATRIX_FORK_EPOCH: 0, CAPELLA_FORK_EPOCH: forkEpoch};
case ForkName.deneb:
return {ALTAIR_FORK_EPOCH: 0, BELLATRIX_FORK_EPOCH: 0, CAPELLA_FORK_EPOCH: 0, DENEB_FORK_EPOCH: forkEpoch};
case ForkName.electra:
return {
ALTAIR_FORK_EPOCH: 0,
BELLATRIX_FORK_EPOCH: 0,
CAPELLA_FORK_EPOCH: 0,
DENEB_FORK_EPOCH: 0,
ELECTRA_FORK_EPOCH: forkEpoch,
};
}
}

Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ describe("UpgradeLightClientHeader", function () {
BELLATRIX_FORK_EPOCH: 2,
CAPELLA_FORK_EPOCH: 3,
DENEB_FORK_EPOCH: 4,
ELECTRA_FORK_EPOCH: Infinity,
});

const genesisValidatorsRoot = Buffer.alloc(32, 0xaa);
@@ -27,6 +28,7 @@ describe("UpgradeLightClientHeader", function () {
capella: ssz.capella.LightClientHeader.defaultValue(),
bellatrix: ssz.altair.LightClientHeader.defaultValue(),
deneb: ssz.deneb.LightClientHeader.defaultValue(),
electra: ssz.electra.LightClientHeader.defaultValue(),
};

testSlots = {
@@ -35,11 +37,18 @@ describe("UpgradeLightClientHeader", function () {
bellatrix: 17,
capella: 25,
deneb: 33,
electra: 0,
};
});

for (let i = ForkSeq.altair; i < Object.values(ForkName).length; i++) {
for (let j = i + 1; j < Object.values(ForkName).length; j++) {
// Since electra is not implemented for loop is till deneb (Object.values(ForkName).length-1)
// Once electra is implemnted run for loop till Object.values(ForkName).length

// for (let i = ForkSeq.altair; i < Object.values(ForkName).length; i++) {
// for (let j = i + 1; j < Object.values(ForkName).length; j++) {

for (let i = ForkSeq.altair; i < Object.values(ForkName).length - 1; i++) {
for (let j = i + 1; j < Object.values(ForkName).length - 1; j++) {
const fromFork = ForkName[ForkSeq[i] as ForkName];
const toFork = ForkName[ForkSeq[j] as ForkName];

@@ -53,7 +62,27 @@ describe("UpgradeLightClientHeader", function () {
}
}

// for electra not implemented
for (let i = ForkSeq.altair; i < Object.values(ForkName).length; i++) {
const fromFork = ForkName[ForkSeq[i] as ForkName];
const toFork = ForkName["electra"];

it(`Throw error ${fromFork}=>${toFork}`, function () {
lcHeaderByFork[fromFork].beacon.slot = testSlots[fromFork];
lcHeaderByFork[toFork].beacon.slot = testSlots[fromFork];

expect(() => {
upgradeLightClientHeader(config, toFork, lcHeaderByFork[fromFork]);
}).toThrow("Not Implemented");
});
}

// Since electra is not implemented for loop is till deneb (Object.values(ForkName).length-1)
// Once electra is implemnted run for loop till Object.values(ForkName).length

// for (let i = ForkSeq.altair; i < Object.values(ForkName).length; i++) {

for (let i = ForkSeq.altair; i < Object.values(ForkName).length - 1; i++) {
for (let j = i; j > 0; j--) {
const fromFork = ForkName[ForkSeq[i] as ForkName];
const toFork = ForkName[ForkSeq[j] as ForkName];
13 changes: 12 additions & 1 deletion packages/beacon-node/test/unit/network/fork.test.ts
Original file line number Diff line number Diff line change
@@ -9,12 +9,14 @@ function getForkConfig({
bellatrix,
capella,
deneb,
electra,
}: {
phase0: number;
altair: number;
bellatrix: number;
capella: number;
deneb: number;
electra: number;
}): BeaconConfig {
const forks: Record<ForkName, ForkInfo> = {
phase0: {
@@ -57,6 +59,14 @@ function getForkConfig({
prevVersion: Buffer.from([0, 0, 0, 3]),
prevForkName: ForkName.capella,
},
electra: {
name: ForkName.electra,
seq: ForkSeq.electra,
epoch: electra,
version: Buffer.from([0, 0, 0, 5]),
prevVersion: Buffer.from([0, 0, 0, 4]),
prevForkName: ForkName.deneb,
},
};
const forksAscendingEpochOrder = Object.values(forks);
const forksDescendingEpochOrder = Object.values(forks).reverse();
@@ -133,9 +143,10 @@ const testScenarios = [
for (const testScenario of testScenarios) {
const {phase0, altair, bellatrix, capella, testCases} = testScenario;
const deneb = Infinity;
const electra = Infinity;

describe(`network / fork: phase0: ${phase0}, altair: ${altair}, bellatrix: ${bellatrix} capella: ${capella}`, () => {
const forkConfig = getForkConfig({phase0, altair, bellatrix, capella, deneb});
const forkConfig = getForkConfig({phase0, altair, bellatrix, capella, deneb, electra});
const forks = forkConfig.forks;
for (const testCase of testCases) {
const {epoch, currentFork, nextFork, activeForks} = testCase;
8 changes: 8 additions & 0 deletions packages/beacon-node/test/utils/config.ts
Original file line number Diff line number Diff line change
@@ -31,5 +31,13 @@ export function getConfig(fork: ForkName, forkEpoch = 0): ChainForkConfig {
CAPELLA_FORK_EPOCH: 0,
DENEB_FORK_EPOCH: forkEpoch,
});
case ForkName.electra:
return createChainForkConfig({
ALTAIR_FORK_EPOCH: 0,
BELLATRIX_FORK_EPOCH: 0,
CAPELLA_FORK_EPOCH: 0,
DENEB_FORK_EPOCH: 0,
ELECTRA_FORK_EPOCH: forkEpoch,
});
}
}
4 changes: 4 additions & 0 deletions packages/config/src/chainConfig/configs/mainnet.ts
Original file line number Diff line number Diff line change
@@ -49,6 +49,10 @@ export const chainConfig: ChainConfig = {
DENEB_FORK_VERSION: b("0x04000000"),
DENEB_FORK_EPOCH: 269568, // March 13, 2024, 01:55:35pm UTC

// Electra
ELECTRA_FORK_VERSION: b("0x05000000"),
ELECTRA_FORK_EPOCH: Infinity,

// Time parameters
// ---------------------------------------------------------------
// 12 seconds
4 changes: 4 additions & 0 deletions packages/config/src/chainConfig/configs/minimal.ts
Original file line number Diff line number Diff line change
@@ -46,6 +46,10 @@ export const chainConfig: ChainConfig = {
DENEB_FORK_VERSION: b("0x04000001"),
DENEB_FORK_EPOCH: Infinity,

// Electra
ELECTRA_FORK_VERSION: b("0x05000001"),
ELECTRA_FORK_EPOCH: Infinity,

// Time parameters
// ---------------------------------------------------------------
// [customized] Faster for testing purposes
6 changes: 6 additions & 0 deletions packages/config/src/chainConfig/types.ts
Original file line number Diff line number Diff line change
@@ -40,6 +40,9 @@ export type ChainConfig = {
// DENEB
DENEB_FORK_VERSION: Uint8Array;
DENEB_FORK_EPOCH: number;
// ELECTRA
ELECTRA_FORK_VERSION: Uint8Array;
ELECTRA_FORK_EPOCH: number;

// Time parameters
SECONDS_PER_SLOT: number;
@@ -99,6 +102,9 @@ export const chainConfigTypes: SpecTypes<ChainConfig> = {
// DENEB
DENEB_FORK_VERSION: "bytes",
DENEB_FORK_EPOCH: "number",
// ELECTRA
ELECTRA_FORK_VERSION: "bytes",
ELECTRA_FORK_EPOCH: "number",

// Time parameters
SECONDS_PER_SLOT: "number",
10 changes: 9 additions & 1 deletion packages/config/src/forkConfig/index.ts
Original file line number Diff line number Diff line change
@@ -59,10 +59,18 @@ export function createForkConfig(config: ChainConfig): ForkConfig {
prevVersion: config.CAPELLA_FORK_VERSION,
prevForkName: ForkName.capella,
};
const electra: ForkInfo = {
name: ForkName.electra,
seq: ForkSeq.electra,
epoch: config.ELECTRA_FORK_EPOCH,
version: config.ELECTRA_FORK_VERSION,
prevVersion: config.DENEB_FORK_VERSION,
prevForkName: ForkName.deneb,
};

/** Forks in order order of occurence, `phase0` first */
// Note: Downstream code relies on proper ordering.
const forks = {phase0, altair, bellatrix, capella, deneb};
const forks = {phase0, altair, bellatrix, capella, deneb, electra};

// Prevents allocating an array on every getForkInfo() call
const forksAscendingEpochOrder = Object.values(forks);
4 changes: 4 additions & 0 deletions packages/light-client/src/spec/utils.ts
Original file line number Diff line number Diff line change
@@ -112,6 +112,10 @@ export function upgradeLightClientHeader(

// Break if no further upgradation is required else fall through
if (ForkSeq[targetFork] <= ForkSeq.deneb) break;

// eslint-disable-next-line no-fallthrough
case ForkName.electra:
throw Error("Not Implemented");
}
return upgradedHeader;
}
2 changes: 2 additions & 0 deletions packages/params/src/forkName.ts
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ export enum ForkName {
bellatrix = "bellatrix",
capella = "capella",
deneb = "deneb",
electra = "electra",
}

/**
@@ -18,6 +19,7 @@ export enum ForkSeq {
bellatrix = 2,
capella = 3,
deneb = 4,
electra = 5,
}

export type ForkAll = ForkName;
8 changes: 8 additions & 0 deletions packages/state-transition/test/unit/upgradeState.test.ts
Original file line number Diff line number Diff line change
@@ -55,5 +55,13 @@ function getConfig(fork: ForkName, forkEpoch = 0): ChainForkConfig {
CAPELLA_FORK_EPOCH: 0,
DENEB_FORK_EPOCH: forkEpoch,
});
case ForkName.electra:
return createChainForkConfig({
ALTAIR_FORK_EPOCH: 0,
BELLATRIX_FORK_EPOCH: 0,
CAPELLA_FORK_EPOCH: 0,
DENEB_FORK_EPOCH: 0,
ELECTRA_FORK_EPOCH: forkEpoch,
});
}
}
3 changes: 3 additions & 0 deletions packages/types/src/electra/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./types.js";
export * as ts from "./types.js";
export * as ssz from "./sszTypes.js";
Loading