Skip to content

Commit 9014c8c

Browse files
committed
feat: placeholder PR for electra
add types stub and epoch config fix types
1 parent 5c25185 commit 9014c8c

File tree

19 files changed

+323
-4
lines changed

19 files changed

+323
-4
lines changed

packages/beacon-node/test/spec/presets/fork.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ const fork: TestRunnerFn<ForkStateCase, BeaconStateAllForks> = (forkNext) => {
3535
return slotFns.upgradeStateToCapella(preState as CachedBeaconStateBellatrix);
3636
case ForkName.deneb:
3737
return slotFns.upgradeStateToDeneb(preState as CachedBeaconStateCapella);
38+
case ForkName.electra:
39+
throw Error("not Implemented");
3840
}
3941
},
4042
options: {

packages/beacon-node/test/spec/presets/transition.test.ts

+8
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ function getTransitionConfig(fork: ForkName, forkEpoch: number): Partial<ChainCo
102102
return {ALTAIR_FORK_EPOCH: 0, BELLATRIX_FORK_EPOCH: 0, CAPELLA_FORK_EPOCH: forkEpoch};
103103
case ForkName.deneb:
104104
return {ALTAIR_FORK_EPOCH: 0, BELLATRIX_FORK_EPOCH: 0, CAPELLA_FORK_EPOCH: 0, DENEB_FORK_EPOCH: forkEpoch};
105+
case ForkName.electra:
106+
return {
107+
ALTAIR_FORK_EPOCH: 0,
108+
BELLATRIX_FORK_EPOCH: 0,
109+
CAPELLA_FORK_EPOCH: 0,
110+
DENEB_FORK_EPOCH: 0,
111+
ELECTRA_FORK_EPOCH: forkEpoch,
112+
};
105113
}
106114
}
107115

packages/beacon-node/test/unit/chain/lightclient/upgradeLightClientHeader.test.ts

+31-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ describe("UpgradeLightClientHeader", function () {
1515
BELLATRIX_FORK_EPOCH: 2,
1616
CAPELLA_FORK_EPOCH: 3,
1717
DENEB_FORK_EPOCH: 4,
18+
ELECTRA_FORK_EPOCH: Infinity,
1819
});
1920

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

3234
testSlots = {
@@ -35,11 +37,18 @@ describe("UpgradeLightClientHeader", function () {
3537
bellatrix: 17,
3638
capella: 25,
3739
deneb: 33,
40+
electra: 0,
3841
};
3942
});
4043

41-
for (let i = ForkSeq.altair; i < Object.values(ForkName).length; i++) {
42-
for (let j = i + 1; j < Object.values(ForkName).length; j++) {
44+
// Since electra is not implemented for loop is till deneb (Object.values(ForkName).length-1)
45+
// Once electra is implemnted run for loop till Object.values(ForkName).length
46+
47+
// for (let i = ForkSeq.altair; i < Object.values(ForkName).length; i++) {
48+
// for (let j = i + 1; j < Object.values(ForkName).length; j++) {
49+
50+
for (let i = ForkSeq.altair; i < Object.values(ForkName).length - 1; i++) {
51+
for (let j = i + 1; j < Object.values(ForkName).length - 1; j++) {
4352
const fromFork = ForkName[ForkSeq[i] as ForkName];
4453
const toFork = ForkName[ForkSeq[j] as ForkName];
4554

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

65+
// for electra not implemented
5666
for (let i = ForkSeq.altair; i < Object.values(ForkName).length; i++) {
67+
const fromFork = ForkName[ForkSeq[i] as ForkName];
68+
const toFork = ForkName["electra"];
69+
70+
it(`Throw error ${fromFork}=>${toFork}`, function () {
71+
lcHeaderByFork[fromFork].beacon.slot = testSlots[fromFork];
72+
lcHeaderByFork[toFork].beacon.slot = testSlots[fromFork];
73+
74+
expect(() => {
75+
upgradeLightClientHeader(config, toFork, lcHeaderByFork[fromFork]);
76+
}).toThrow("Not Implemented");
77+
});
78+
}
79+
80+
// Since electra is not implemented for loop is till deneb (Object.values(ForkName).length-1)
81+
// Once electra is implemnted run for loop till Object.values(ForkName).length
82+
83+
// for (let i = ForkSeq.altair; i < Object.values(ForkName).length; i++) {
84+
85+
for (let i = ForkSeq.altair; i < Object.values(ForkName).length - 1; i++) {
5786
for (let j = i; j > 0; j--) {
5887
const fromFork = ForkName[ForkSeq[i] as ForkName];
5988
const toFork = ForkName[ForkSeq[j] as ForkName];

packages/beacon-node/test/unit/network/fork.test.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ function getForkConfig({
99
bellatrix,
1010
capella,
1111
deneb,
12+
electra,
1213
}: {
1314
phase0: number;
1415
altair: number;
1516
bellatrix: number;
1617
capella: number;
1718
deneb: number;
19+
electra: number;
1820
}): BeaconConfig {
1921
const forks: Record<ForkName, ForkInfo> = {
2022
phase0: {
@@ -57,6 +59,14 @@ function getForkConfig({
5759
prevVersion: Buffer.from([0, 0, 0, 3]),
5860
prevForkName: ForkName.capella,
5961
},
62+
electra: {
63+
name: ForkName.electra,
64+
seq: ForkSeq.electra,
65+
epoch: electra,
66+
version: Buffer.from([0, 0, 0, 5]),
67+
prevVersion: Buffer.from([0, 0, 0, 4]),
68+
prevForkName: ForkName.deneb,
69+
},
6070
};
6171
const forksAscendingEpochOrder = Object.values(forks);
6272
const forksDescendingEpochOrder = Object.values(forks).reverse();
@@ -133,9 +143,10 @@ const testScenarios = [
133143
for (const testScenario of testScenarios) {
134144
const {phase0, altair, bellatrix, capella, testCases} = testScenario;
135145
const deneb = Infinity;
146+
const electra = Infinity;
136147

137148
describe(`network / fork: phase0: ${phase0}, altair: ${altair}, bellatrix: ${bellatrix} capella: ${capella}`, () => {
138-
const forkConfig = getForkConfig({phase0, altair, bellatrix, capella, deneb});
149+
const forkConfig = getForkConfig({phase0, altair, bellatrix, capella, deneb, electra});
139150
const forks = forkConfig.forks;
140151
for (const testCase of testCases) {
141152
const {epoch, currentFork, nextFork, activeForks} = testCase;

packages/beacon-node/test/utils/config.ts

+8
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,13 @@ export function getConfig(fork: ForkName, forkEpoch = 0): ChainForkConfig {
3131
CAPELLA_FORK_EPOCH: 0,
3232
DENEB_FORK_EPOCH: forkEpoch,
3333
});
34+
case ForkName.electra:
35+
return createChainForkConfig({
36+
ALTAIR_FORK_EPOCH: 0,
37+
BELLATRIX_FORK_EPOCH: 0,
38+
CAPELLA_FORK_EPOCH: 0,
39+
DENEB_FORK_EPOCH: 0,
40+
ELECTRA_FORK_EPOCH: forkEpoch,
41+
});
3442
}
3543
}

packages/config/src/chainConfig/configs/mainnet.ts

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ export const chainConfig: ChainConfig = {
4949
DENEB_FORK_VERSION: b("0x04000000"),
5050
DENEB_FORK_EPOCH: 269568, // March 13, 2024, 01:55:35pm UTC
5151

52+
// Electra
53+
ELECTRA_FORK_VERSION: b("0x05000000"),
54+
ELECTRA_FORK_EPOCH: Infinity,
55+
5256
// Time parameters
5357
// ---------------------------------------------------------------
5458
// 12 seconds

packages/config/src/chainConfig/configs/minimal.ts

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ export const chainConfig: ChainConfig = {
4646
DENEB_FORK_VERSION: b("0x04000001"),
4747
DENEB_FORK_EPOCH: Infinity,
4848

49+
// Electra
50+
ELECTRA_FORK_VERSION: b("0x05000001"),
51+
ELECTRA_FORK_EPOCH: Infinity,
52+
4953
// Time parameters
5054
// ---------------------------------------------------------------
5155
// [customized] Faster for testing purposes

packages/config/src/chainConfig/types.ts

+6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ export type ChainConfig = {
4040
// DENEB
4141
DENEB_FORK_VERSION: Uint8Array;
4242
DENEB_FORK_EPOCH: number;
43+
// ELECTRA
44+
ELECTRA_FORK_VERSION: Uint8Array;
45+
ELECTRA_FORK_EPOCH: number;
4346

4447
// Time parameters
4548
SECONDS_PER_SLOT: number;
@@ -96,6 +99,9 @@ export const chainConfigTypes: SpecTypes<ChainConfig> = {
9699
// DENEB
97100
DENEB_FORK_VERSION: "bytes",
98101
DENEB_FORK_EPOCH: "number",
102+
// ELECTRA
103+
ELECTRA_FORK_VERSION: "bytes",
104+
ELECTRA_FORK_EPOCH: "number",
99105

100106
// Time parameters
101107
SECONDS_PER_SLOT: "number",

packages/config/src/forkConfig/index.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,18 @@ export function createForkConfig(config: ChainConfig): ForkConfig {
5555
prevVersion: config.CAPELLA_FORK_VERSION,
5656
prevForkName: ForkName.capella,
5757
};
58+
const electra: ForkInfo = {
59+
name: ForkName.electra,
60+
seq: ForkSeq.electra,
61+
epoch: config.ELECTRA_FORK_EPOCH,
62+
version: config.ELECTRA_FORK_VERSION,
63+
prevVersion: config.DENEB_FORK_VERSION,
64+
prevForkName: ForkName.deneb,
65+
};
5866

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

6371
// Prevents allocating an array on every getForkInfo() call
6472
const forksAscendingEpochOrder = Object.values(forks);

packages/light-client/src/spec/utils.ts

+4
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ export function upgradeLightClientHeader(
105105

106106
// Break if no further upgradation is required else fall through
107107
if (ForkSeq[targetFork] <= ForkSeq.deneb) break;
108+
109+
// eslint-disable-next-line no-fallthrough
110+
case ForkName.electra:
111+
throw Error("Not Implemented");
108112
}
109113
return upgradedHeader;
110114
}

packages/params/src/forkName.ts

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export enum ForkName {
77
bellatrix = "bellatrix",
88
capella = "capella",
99
deneb = "deneb",
10+
electra = "electra",
1011
}
1112

1213
/**
@@ -18,6 +19,7 @@ export enum ForkSeq {
1819
bellatrix = 2,
1920
capella = 3,
2021
deneb = 4,
22+
electra = 5,
2123
}
2224

2325
export type ForkPreLightClient = ForkName.phase0;

packages/state-transition/test/unit/upgradeState.test.ts

+8
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,13 @@ function getConfig(fork: ForkName, forkEpoch = 0): ChainForkConfig {
5555
CAPELLA_FORK_EPOCH: 0,
5656
DENEB_FORK_EPOCH: forkEpoch,
5757
});
58+
case ForkName.electra:
59+
return createChainForkConfig({
60+
ALTAIR_FORK_EPOCH: 0,
61+
BELLATRIX_FORK_EPOCH: 0,
62+
CAPELLA_FORK_EPOCH: 0,
63+
DENEB_FORK_EPOCH: 0,
64+
ELECTRA_FORK_EPOCH: forkEpoch,
65+
});
5866
}
5967
}

packages/types/src/allForks/sszTypes.ts

+38
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {ssz as altair} from "../altair/index.js";
33
import {ssz as bellatrix} from "../bellatrix/index.js";
44
import {ssz as capella} from "../capella/index.js";
55
import {ssz as deneb} from "../deneb/index.js";
6+
import {ssz as electra} from "../electra/index.js";
67

78
/**
89
* Index the ssz types that differ by fork
@@ -44,6 +45,13 @@ export const allForks = {
4445
BeaconState: deneb.BeaconState,
4546
Metadata: altair.Metadata,
4647
},
48+
electra: {
49+
BeaconBlockBody: electra.BeaconBlockBody,
50+
BeaconBlock: electra.BeaconBlock,
51+
SignedBeaconBlock: electra.SignedBeaconBlock,
52+
BeaconState: electra.BeaconState,
53+
Metadata: altair.Metadata,
54+
},
4755
};
4856

4957
/**
@@ -85,6 +93,17 @@ export const allForksExecution = {
8593
SignedBuilderBid: deneb.SignedBuilderBid,
8694
SSEPayloadAttributes: deneb.SSEPayloadAttributes,
8795
},
96+
electra: {
97+
BeaconBlockBody: electra.BeaconBlockBody,
98+
BeaconBlock: electra.BeaconBlock,
99+
SignedBeaconBlock: electra.SignedBeaconBlock,
100+
BeaconState: electra.BeaconState,
101+
ExecutionPayload: electra.ExecutionPayload,
102+
ExecutionPayloadHeader: electra.ExecutionPayloadHeader,
103+
BuilderBid: electra.BuilderBid,
104+
SignedBuilderBid: electra.SignedBuilderBid,
105+
SSEPayloadAttributes: electra.SSEPayloadAttributes,
106+
},
88107
};
89108

90109
/**
@@ -107,6 +126,11 @@ export const allForksBlinded = {
107126
BeaconBlock: deneb.BlindedBeaconBlock,
108127
SignedBeaconBlock: deneb.SignedBlindedBeaconBlock,
109128
},
129+
electra: {
130+
BeaconBlockBody: electra.BlindedBeaconBlockBody,
131+
BeaconBlock: electra.BlindedBeaconBlock,
132+
SignedBeaconBlock: electra.SignedBlindedBeaconBlock,
133+
},
110134
};
111135

112136
export const allForksLightClient = {
@@ -150,11 +174,25 @@ export const allForksLightClient = {
150174
LightClientOptimisticUpdate: deneb.LightClientOptimisticUpdate,
151175
LightClientStore: deneb.LightClientStore,
152176
},
177+
electra: {
178+
BeaconBlock: electra.BeaconBlock,
179+
BeaconBlockBody: electra.BeaconBlockBody,
180+
LightClientHeader: electra.LightClientHeader,
181+
LightClientBootstrap: electra.LightClientBootstrap,
182+
LightClientUpdate: electra.LightClientUpdate,
183+
LightClientFinalityUpdate: electra.LightClientFinalityUpdate,
184+
LightClientOptimisticUpdate: electra.LightClientOptimisticUpdate,
185+
LightClientStore: electra.LightClientStore,
186+
},
153187
};
154188

155189
export const allForksBlobs = {
156190
deneb: {
157191
BlobSidecar: deneb.BlobSidecar,
158192
ExecutionPayloadAndBlobsBundle: deneb.ExecutionPayloadAndBlobsBundle,
159193
},
194+
electra: {
195+
BlobSidecar: electra.BlobSidecar,
196+
ExecutionPayloadAndBlobsBundle: electra.ExecutionPayloadAndBlobsBundle,
197+
},
160198
};

packages/types/src/electra/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from "./types.js";
2+
export * as ts from "./types.js";
3+
export * as ssz from "./sszTypes.js";

0 commit comments

Comments
 (0)