Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions packages/beacon-node/src/api/impl/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ export function renderJsonSpec(config: ChainConfig): routes.config.Spec {
const configJson = chainConfigToJson(config);
const presetJson = presetToJson(activePreset);
const constantsJson = specValuesToJson(specConstants);

// TODO Fulu: remove this check once interop issues are resolved
// see https://github.com/attestantio/go-eth2-client/issues/230
if (config.FULU_FORK_EPOCH === Infinity) {
delete configJson.BLOB_SCHEDULE;
}

return {...configJson, ...presetJson, ...constantsJson};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe("gossip block validation", () => {
beforeEach(() => {
// Fill up with kzg commitments
block.body.blobKzgCommitments = Array.from(
{length: config.BLOB_SCHEDULE[0].MAX_BLOBS_PER_BLOCK},
{length: config.getMaxBlobsPerBlock(clockSlot)},
() => new Uint8Array([0])
);

Expand Down
10 changes: 1 addition & 9 deletions packages/beacon-node/test/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export function getConfig(fork: ForkName, forkEpoch = 0): ChainForkConfig {
BELLATRIX_FORK_EPOCH: 0,
CAPELLA_FORK_EPOCH: 0,
DENEB_FORK_EPOCH: forkEpoch,
BLOB_SCHEDULE: [{EPOCH: forkEpoch, MAX_BLOBS_PER_BLOCK: 6}],
});
case ForkName.electra:
return createChainForkConfig({
Expand All @@ -38,10 +37,6 @@ export function getConfig(fork: ForkName, forkEpoch = 0): ChainForkConfig {
CAPELLA_FORK_EPOCH: 0,
DENEB_FORK_EPOCH: 0,
ELECTRA_FORK_EPOCH: forkEpoch,
BLOB_SCHEDULE: [
{EPOCH: 0, MAX_BLOBS_PER_BLOCK: 6},
{EPOCH: forkEpoch, MAX_BLOBS_PER_BLOCK: 9},
],
});
case ForkName.fulu:
return createChainForkConfig({
Expand All @@ -51,10 +46,7 @@ export function getConfig(fork: ForkName, forkEpoch = 0): ChainForkConfig {
DENEB_FORK_EPOCH: 0,
ELECTRA_FORK_EPOCH: 0,
FULU_FORK_EPOCH: forkEpoch,
BLOB_SCHEDULE: [
{EPOCH: 0, MAX_BLOBS_PER_BLOCK: 6},
{EPOCH: 0, MAX_BLOBS_PER_BLOCK: 9},
],
BLOB_SCHEDULE: [],
});
}
}
11 changes: 3 additions & 8 deletions packages/config/src/chainConfig/configs/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const chainConfig: ChainConfig = {
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: 4096,
BLOB_SIDECAR_SUBNET_COUNT: 6,
MAX_BLOBS_PER_BLOCK: 6,
// MAX_REQUEST_BLOCKS_DENEB * BLOB_SCHEDULE[0].MAX_BLOBS_PER_BLOCK
// MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK
MAX_REQUEST_BLOB_SIDECARS: 768,

// Electra
Expand All @@ -119,7 +119,7 @@ export const chainConfig: ChainConfig = {
MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA: 128000000000,
BLOB_SIDECAR_SUBNET_COUNT_ELECTRA: 9,
MAX_BLOBS_PER_BLOCK_ELECTRA: 9,
// MAX_REQUEST_BLOCKS_DENEB * BLOB_SCHEDULE[1].MAX_BLOBS_PER_BLOCK
// MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_ELECTRA
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: 1152,

// Fulu
Expand All @@ -133,10 +133,5 @@ export const chainConfig: ChainConfig = {

// Blob Scheduling
// ---------------------------------------------------------------
BLOB_SCHEDULE: [
// Deneb
{EPOCH: 269568, MAX_BLOBS_PER_BLOCK: 6},
// Electra
{EPOCH: 364032, MAX_BLOBS_PER_BLOCK: 9},
],
BLOB_SCHEDULE: [],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as per ethereum/consensus-specs#4342 should be empty array

};
11 changes: 3 additions & 8 deletions packages/config/src/chainConfig/configs/minimal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const chainConfig: ChainConfig = {
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: 4096,
BLOB_SIDECAR_SUBNET_COUNT: 6,
MAX_BLOBS_PER_BLOCK: 6,
// MAX_REQUEST_BLOCKS_DENEB * BLOB_SCHEDULE[0].MAX_BLOBS_PER_BLOCK
// MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK
MAX_REQUEST_BLOB_SIDECARS: 768,

// Electra
Expand All @@ -115,7 +115,7 @@ export const chainConfig: ChainConfig = {
MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA: 64000000000,
BLOB_SIDECAR_SUBNET_COUNT_ELECTRA: 9,
MAX_BLOBS_PER_BLOCK_ELECTRA: 9,
// MAX_REQUEST_BLOCKS_DENEB * BLOB_SCHEDULE[1].MAX_BLOBS_PER_BLOCK
// MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_ELECTRA
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: 1152,

// Fulu
Expand All @@ -129,10 +129,5 @@ export const chainConfig: ChainConfig = {

// Blob Scheduling
// ---------------------------------------------------------------
BLOB_SCHEDULE: [
// Deneb
{EPOCH: Infinity, MAX_BLOBS_PER_BLOCK: 6},
// Electra
{EPOCH: Infinity, MAX_BLOBS_PER_BLOCK: 9},
],
BLOB_SCHEDULE: [],
};
7 changes: 1 addition & 6 deletions packages/config/src/chainConfig/networks/chiado.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,5 @@ export const chiadoChainConfig: ChainConfig = {
FULU_FORK_EPOCH: Infinity,

// Blob Scheduling
BLOB_SCHEDULE: [
// Deneb
{EPOCH: 516608, MAX_BLOBS_PER_BLOCK: 2},
// Electra
{EPOCH: 948224, MAX_BLOBS_PER_BLOCK: 2},
],
BLOB_SCHEDULE: [],
};
7 changes: 1 addition & 6 deletions packages/config/src/chainConfig/networks/ephemery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,7 @@ const baseChainConfig: ChainConfig = {

// Blob Scheduling
// ---------------------------------------------------------------
BLOB_SCHEDULE: [
// Deneb
{EPOCH: 0, MAX_BLOBS_PER_BLOCK: 6},
// Electra
{EPOCH: 10, MAX_BLOBS_PER_BLOCK: 9},
],
BLOB_SCHEDULE: [],
};

// Reset interval (7 days) in milliseconds, based on ephemery-genesis values.env:
Expand Down
9 changes: 2 additions & 7 deletions packages/config/src/chainConfig/networks/gnosis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,9 @@ export const gnosisChainConfig: ChainConfig = {
MAX_PER_EPOCH_ACTIVATION_EXIT_CHURN_LIMIT: 64000000000,
BLOB_SIDECAR_SUBNET_COUNT_ELECTRA: 2,
MAX_BLOBS_PER_BLOCK_ELECTRA: 2,
// MAX_REQUEST_BLOCKS_DENEB * BLOB_SCHEDULE[1].MAX_BLOBS_PER_BLOCK
// MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_ELECTRA
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: 256,

// Blob Scheduling
BLOB_SCHEDULE: [
// Deneb
{EPOCH: 889856, MAX_BLOBS_PER_BLOCK: 2},
// Electra
{EPOCH: 1337856, MAX_BLOBS_PER_BLOCK: 2},
],
BLOB_SCHEDULE: [],
};
7 changes: 1 addition & 6 deletions packages/config/src/chainConfig/networks/holesky.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,5 @@ export const holeskyChainConfig: ChainConfig = {

// Blob Scheduling
// ---------------------------------------------------------------
BLOB_SCHEDULE: [
// Deneb
{EPOCH: 29696, MAX_BLOBS_PER_BLOCK: 6},
// Electra
{EPOCH: 115968, MAX_BLOBS_PER_BLOCK: 9},
],
BLOB_SCHEDULE: [],
};
7 changes: 1 addition & 6 deletions packages/config/src/chainConfig/networks/hoodi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,5 @@ export const hoodiChainConfig: ChainConfig = {

// Blob Scheduling
// ---------------------------------------------------------------
BLOB_SCHEDULE: [
// Deneb
{EPOCH: 0, MAX_BLOBS_PER_BLOCK: 6},
// Electra
{EPOCH: 2048, MAX_BLOBS_PER_BLOCK: 9},
],
BLOB_SCHEDULE: [],
};
7 changes: 1 addition & 6 deletions packages/config/src/chainConfig/networks/sepolia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,5 @@ export const sepoliaChainConfig: ChainConfig = {

// Blob Scheduling
// ---------------------------------------------------------------
BLOB_SCHEDULE: [
// Deneb
{EPOCH: 132608, MAX_BLOBS_PER_BLOCK: 6},
// Electra
{EPOCH: 222464, MAX_BLOBS_PER_BLOCK: 9},
],
BLOB_SCHEDULE: [],
};
7 changes: 1 addition & 6 deletions packages/config/src/forkConfig/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ export function createForkConfig(config: ChainConfig): ForkConfig {
return sszTypesFor(forkName);
},
getMaxBlobsPerBlock(epoch: Epoch): number {
// TODO Fulu: Max blobs of Deneb and Electra are hardcoded for fusaka devnet-0. Remove this for devnet-1
const fork = this.getForkInfoAtEpoch(epoch).name;

switch (fork) {
Expand All @@ -149,10 +148,6 @@ export function createForkConfig(config: ChainConfig): ForkConfig {
return config.MAX_BLOBS_PER_BLOCK;
}

if (config.BLOB_SCHEDULE.length === 0) {
throw Error("Attempt to get MAX_BLOBS_PER_BLOCK from empty BLOB_SCHEDULE");
}

// Sort by epoch in descending order to find the latest applicable value
const blobSchedule = [...config.BLOB_SCHEDULE].sort((a, b) => {
if (a.EPOCH !== b.EPOCH) {
Expand All @@ -168,7 +163,7 @@ export function createForkConfig(config: ChainConfig): ForkConfig {
}

// Only for testing. Should never reach this line on a public network.
return Math.min(...blobSchedule.map((e) => e.MAX_BLOBS_PER_BLOCK));
return config.MAX_BLOBS_PER_BLOCK_ELECTRA;
},
getMaxRequestBlobSidecars(fork: ForkName): number {
return isForkPostElectra(fork) ? config.MAX_REQUEST_BLOB_SIDECARS_ELECTRA : config.MAX_REQUEST_BLOB_SIDECARS;
Expand Down
12 changes: 5 additions & 7 deletions packages/config/test/unit/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ describe("getMaxBlobsPerBlock", () => {

beforeAll(() => {
// Force tests to run on fulu fork
// TODO Fulu: getMaxBlobsPerBlock's result is hardcoded for deneb and electra in fusaka devnet-0. So we need to define
// defaultConfig to force tests to run on fulu to get expected result. Remove this after devnet-0.
defaultConfig = {
...chainConfig,
ALTAIR_FORK_EPOCH: 0,
Expand All @@ -20,10 +18,10 @@ describe("getMaxBlobsPerBlock", () => {
};
});

it("should throw an error if BLOB_SCHEDULE is empty", () => {
it("should return MAX_BLOBS_PER_BLOCK_ELECTRA if BLOB_SCHEDULE is empty", () => {
const config = createForkConfig({...defaultConfig, BLOB_SCHEDULE: []});

expect(() => config.getMaxBlobsPerBlock(0)).toThrowError();
expect(config.getMaxBlobsPerBlock(0)).toEqual(defaultConfig.MAX_BLOBS_PER_BLOCK_ELECTRA);
});

it("should return same value for passed epochs if there is only a single BLOB_SCHEDULE entry", () => {
Expand Down Expand Up @@ -64,15 +62,15 @@ describe("getMaxBlobsPerBlock", () => {
{EPOCH: 10, MAX_BLOBS_PER_BLOCK: 5},
],
});
expect(config.getMaxBlobsPerBlock(0)).toEqual(1);
expect(config.getMaxBlobsPerBlock(5)).toEqual(3);
expect(config.getMaxBlobsPerBlock(6)).toEqual(3);
expect(config.getMaxBlobsPerBlock(10)).toEqual(5);
expect(config.getMaxBlobsPerBlock(14)).toEqual(5);
expect(config.getMaxBlobsPerBlock(15)).toEqual(1);
expect(config.getMaxBlobsPerBlock(16)).toEqual(1);
});

it("should return minimum value if epoch is below lowest configured BLOB_SCHEDULE epoch", () => {
it("should return MAX_BLOBS_PER_BLOCK_ELECTRA if epoch is below lowest configured BLOB_SCHEDULE epoch", () => {
const config = createForkConfig({
...defaultConfig,
BLOB_SCHEDULE: [
Expand All @@ -81,6 +79,6 @@ describe("getMaxBlobsPerBlock", () => {
{EPOCH: 15, MAX_BLOBS_PER_BLOCK: 2},
],
});
expect(config.getMaxBlobsPerBlock(0)).toEqual(2);
expect(config.getMaxBlobsPerBlock(0)).toEqual(defaultConfig.MAX_BLOBS_PER_BLOCK_ELECTRA);
});
});
Loading