Skip to content

Commit

Permalink
rename electra to verkle
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech committed Sep 5, 2024
1 parent fca5169 commit 9fb1b70
Show file tree
Hide file tree
Showing 30 changed files with 150 additions and 147 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const ELECTRA_ELEPHANTWITHWINGS_BANNER = String.raw`
export const VERKLE_ELEPHANTWITHWINGS_BANNER = String.raw`
:~~.
:!:^::^^!!^
:!^^ !:J.
Expand Down
8 changes: 4 additions & 4 deletions packages/beacon-node/src/chain/blocks/verifyBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {BlockInput, ImportBlockOpts, BlockInputType} from "./types.js";
import {POS_PANDA_MERGE_TRANSITION_BANNER} from "./utils/pandaMergeTransitionBanner.js";
import {CAPELLA_OWL_BANNER} from "./utils/ownBanner.js";
import {DENEB_BLOWFISH_BANNER} from "./utils/blowfishBanner.js";
import {ELECTRA_ELEPHANTWITHWINGS_BANNER} from "./utils/elephantWithWings.js";
import {VERKLE_ELEPHANTWITHWINGS_BANNER} from "./utils/elephantWithWings.js";
import {verifyBlocksStateTransitionOnly} from "./verifyBlocksStateTransitionOnly.js";
import {verifyBlocksSignatures} from "./verifyBlocksSignatures.js";
import {verifyBlocksExecutionPayload, SegmentExecStatus} from "./verifyBlocksExecutionPayloads.js";
Expand Down Expand Up @@ -153,9 +153,9 @@ export async function verifyBlocksInEpoch(
this.logger.info("Activating withdrawals", {epoch: this.config.CAPELLA_FORK_EPOCH});
break;

case ForkName.electra:
this.logger.info(ELECTRA_ELEPHANTWITHWINGS_BANNER);
this.logger.info("Activating verkle", {epoch: this.config.ELECTRA_FORK_EPOCH});
case ForkName.verkle:
this.logger.info(VERKLE_ELEPHANTWITHWINGS_BANNER);
this.logger.info("Activating verkle", {epoch: this.config.VERKLE_FORK_EPOCH});
break;

case ForkName.deneb:
Expand Down
26 changes: 10 additions & 16 deletions packages/beacon-node/src/execution/engine/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {capella, deneb, Wei, bellatrix, Root, electra, ExecutionPayload, ssz} from "@lodestar/types";
import {capella, deneb, Wei, bellatrix, Root, verkle, ExecutionPayload, ssz} from "@lodestar/types";
import {
BYTES_PER_LOGS_BLOOM,
FIELD_ELEMENTS_PER_BLOB,
Expand All @@ -18,7 +18,6 @@ import {
} from "../../eth1/provider/utils.js";
import {ExecutionPayloadStatus, BlobsBundle, PayloadAttributes, VersionedHashes} from "./interface.js";
import {WithdrawalV1} from "./payloadIdCache.js";
import * as util from "node:util"
/* eslint-disable @typescript-eslint/naming-convention */

export type EngineApiRpcParamTypes = {
Expand Down Expand Up @@ -213,14 +212,14 @@ export function serializeExecutionPayload(fork: ForkName, data: ExecutionPayload
payload.excessBlobGas = numToQuantity(excessBlobGas);
}

// ELECTRA adds executionWitness to the ExecutionPayload
if (ForkSeq[fork] >= ForkSeq.electra) {
const {executionWitness} = data as electra.ExecutionPayload;
// VERKLE adds executionWitness to the ExecutionPayload
if (ForkSeq[fork] >= ForkSeq.verkle) {
const {executionWitness} = data as verkle.ExecutionPayload;
// right now the caseMap of ssz ExecutionWitness is camel cased and can
// directly be used to serialize tojson
payload.executionWitness = ssz.electra.ExecutionWitness.toJson(executionWitness);
payload.executionWitness = ssz.verkle.ExecutionWitness.toJson(executionWitness);
// serialization with ssz serialize suffix diff's suffix to a string while geth expects num
(payload.executionWitness as electra.ExecutionWitness).stateDiff.forEach((sDiff) => {
(payload.executionWitness as verkle.ExecutionWitness).stateDiff.forEach((sDiff) => {
sDiff.suffixDiffs.forEach((sfDiff) => {
sfDiff.suffix = Number(sfDiff.suffix);
});
Expand Down Expand Up @@ -312,18 +311,13 @@ export function parseExecutionPayload(
(executionPayload as deneb.ExecutionPayload).excessBlobGas = quantityToBigint(excessBlobGas);
}

// ELECTRA adds execution witness to the payload
if (ForkSeq[fork] >= ForkSeq.electra) {
// VERKLE adds execution witness to the payload
if (ForkSeq[fork] >= ForkSeq.verkle) {
// right now the casing of executionWitness is camel case in the ssz caseMap
// we can directly use fromJson to read the serialized data from payload
const {executionWitness} = data;
console.log(
"parse executionWitness from EL",
util.inspect(executionWitness, false, null, true /* enable colors */),
{blockNumber: data.blockNumber}
);
(executionPayload as electra.ExecutionPayload).executionWitness =
ssz.electra.ExecutionWitness.fromJson(executionWitness);
(executionPayload as verkle.ExecutionPayload).executionWitness =
ssz.verkle.ExecutionWitness.fromJson(executionWitness);
}

return {executionPayload, executionPayloadValue, blobsBundle, shouldOverrideBuilder};
Expand Down
4 changes: 2 additions & 2 deletions packages/beacon-node/test/spec/presets/fork.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,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:
return slotFns.upgradeStateToElectra(preState as CachedBeaconStateDeneb);
case ForkName.verkle:
return slotFns.upgradeStateToVerkle(preState as CachedBeaconStateDeneb);
}
},
options: {
Expand Down
4 changes: 2 additions & 2 deletions packages/beacon-node/test/spec/presets/transition.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ 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:
case ForkName.verkle:
return {
ALTAIR_FORK_EPOCH: 0,
BELLATRIX_FORK_EPOCH: 0,
CAPELLA_FORK_EPOCH: 0,
DENEB_FORK_EPOCH: 0,
ELECTRA_FORK_EPOCH: forkEpoch,
VERKLE_FORK_EPOCH: forkEpoch,
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe("UpgradeLightClientHeader", function () {
capella: ssz.capella.LightClientHeader.defaultValue(),
bellatrix: ssz.altair.LightClientHeader.defaultValue(),
deneb: ssz.deneb.LightClientHeader.defaultValue(),
electra: ssz.electra.LightClientHeader.defaultValue(),
verkle: ssz.verkle.LightClientHeader.defaultValue(),
};

testSlots = {
Expand All @@ -36,7 +36,7 @@ describe("UpgradeLightClientHeader", function () {
bellatrix: 17,
capella: 25,
deneb: 33,
electra: 41,
verkle: 41,
};
});

Expand Down
16 changes: 8 additions & 8 deletions packages/beacon-node/test/unit/network/fork.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ function getForkConfig({
bellatrix,
capella,
deneb,
electra,
verkle,
}: {
phase0: number;
altair: number;
bellatrix: number;
capella: number;
deneb: number;
electra: number;
verkle: number;
}): BeaconConfig {
const forks: Record<ForkName, ForkInfo> = {
phase0: {
Expand Down Expand Up @@ -59,10 +59,10 @@ function getForkConfig({
prevVersion: Buffer.from([0, 0, 0, 3]),
prevForkName: ForkName.capella,
},
electra: {
name: ForkName.electra,
seq: ForkSeq.electra,
epoch: electra,
verkle: {
name: ForkName.verkle,
seq: ForkSeq.verkle,
epoch: verkle,
version: Buffer.from([0, 0, 0, 4]),
prevVersion: Buffer.from([0, 0, 0, 3]),
prevForkName: ForkName.capella,
Expand Down Expand Up @@ -143,10 +143,10 @@ const testScenarios = [
for (const testScenario of testScenarios) {
const {phase0, altair, bellatrix, capella, testCases} = testScenario;
const deneb = Infinity;
const electra = Infinity;
const verkle = Infinity;

describe(`network / fork: phase0: ${phase0}, altair: ${altair}, bellatrix: ${bellatrix} capella: ${capella}`, () => {
const forkConfig = getForkConfig({phase0, altair, bellatrix, capella, deneb, electra});
const forkConfig = getForkConfig({phase0, altair, bellatrix, capella, deneb, verkle});
const forks = forkConfig.forks;
for (const testCase of testCases) {
const {epoch, currentFork, nextFork, activeForks} = testCase;
Expand Down
4 changes: 2 additions & 2 deletions packages/beacon-node/test/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ export function getConfig(fork: ForkName, forkEpoch = 0): ChainForkConfig {
CAPELLA_FORK_EPOCH: 0,
DENEB_FORK_EPOCH: forkEpoch,
});
case ForkName.electra:
case ForkName.verkle:
return createChainForkConfig({
ALTAIR_FORK_EPOCH: 0,
BELLATRIX_FORK_EPOCH: 0,
CAPELLA_FORK_EPOCH: 0,
DENEB_FORK_EPOCH: 0,
ELECTRA_FORK_EPOCH: forkEpoch,
VERKLE_FORK_EPOCH: forkEpoch,
});
}
}
6 changes: 3 additions & 3 deletions packages/config/src/chainConfig/configs/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ 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,
// VERKLE
VERKLE_FORK_VERSION: b("0x05000000"),
VERKLE_FORK_EPOCH: Infinity,

// Time parameters
// ---------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions packages/config/src/chainConfig/configs/minimal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ export const chainConfig: ChainConfig = {
// Deneb
DENEB_FORK_VERSION: b("0x04000001"),
DENEB_FORK_EPOCH: Infinity,
// Electra
ELECTRA_FORK_VERSION: b("0x05000001"),
ELECTRA_FORK_EPOCH: Infinity,
// Verkle
VERKLE_FORK_VERSION: b("0x05000001"),
VERKLE_FORK_EPOCH: Infinity,

// Time parameters
// ---------------------------------------------------------------
Expand Down
12 changes: 6 additions & 6 deletions packages/config/src/chainConfig/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ export type ChainConfig = {
// DENEB
DENEB_FORK_VERSION: Uint8Array;
DENEB_FORK_EPOCH: number;
// ELECTRA
ELECTRA_FORK_VERSION: Uint8Array;
ELECTRA_FORK_EPOCH: number;
// VERKLE
VERKLE_FORK_VERSION: Uint8Array;
VERKLE_FORK_EPOCH: number;

// Time parameters
SECONDS_PER_SLOT: number;
Expand Down Expand Up @@ -102,9 +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",
// VERKLE
VERKLE_FORK_VERSION: "bytes",
VERKLE_FORK_EPOCH: "number",

// Time parameters
SECONDS_PER_SLOT: "number",
Expand Down
12 changes: 6 additions & 6 deletions packages/config/src/forkConfig/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +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,
const verkle: ForkInfo = {
name: ForkName.verkle,
seq: ForkSeq.verkle,
epoch: config.VERKLE_FORK_EPOCH,
version: config.VERKLE_FORK_VERSION,
prevVersion: config.CAPELLA_FORK_VERSION,
prevForkName: ForkName.capella,
};

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

// Prevents allocating an array on every getForkInfo() call
const forksAscendingEpochOrder = Object.values(forks);
Expand Down
18 changes: 12 additions & 6 deletions packages/params/src/forkName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export enum ForkName {
bellatrix = "bellatrix",
capella = "capella",
deneb = "deneb",
electra = "electra",
verkle = "verkle",
}

/**
Expand All @@ -18,8 +18,8 @@ export enum ForkSeq {
altair = 1,
bellatrix = 2,
capella = 3,
// Electra is scheduled after capella for now
electra = 4,
// Verkle is scheduled after capella for now
verkle = 4,
deneb = 5,
}

Expand Down Expand Up @@ -82,9 +82,15 @@ export function isForkVerge(fork: ForkName): fork is ForkVerge {
return isForkWithdrawals(fork) && fork !== ForkName.capella;
}

export type ForkPreBlobs = ForkPreVerge | ForkName.electra;
export type ForkPreBlobs = ForkPreVerge | ForkName.verkle;
export type ForkBlobs = Exclude<ForkName, ForkPreBlobs>;
export const forkBlobs = exclude(forkAll, [ForkName.phase0, ForkName.altair, ForkName.bellatrix, ForkName.capella, ForkName.electra]);
export const forkBlobs = exclude(forkAll, [
ForkName.phase0,
ForkName.altair,
ForkName.bellatrix,
ForkName.capella,
ForkName.verkle,
]);
export function isForkBlobs(fork: ForkName): fork is ForkBlobs {
return isForkVerge(fork) && fork !== ForkName.electra;
return isForkVerge(fork) && fork !== ForkName.verkle;
}
2 changes: 1 addition & 1 deletion packages/params/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export const KZG_COMMITMENT_SUBTREE_INDEX0 = KZG_COMMITMENT_GINDEX0 - 2 ** KZG_C
// ssz.deneb.BlobSidecars.elementType.fixedSize
export const BLOBSIDECAR_FIXED_SIZE = ACTIVE_PRESET === PresetName.minimal ? 131672 : 131928;

// TODO: Electra spec notes these as preset but there's only one value
// TODO: Verkle spec notes these as preset but there's only one value
// https://github.com/ethereum/consensus-specs/blob/db74090c1e8dc1fb2c052bae268e22dc63061e32/specs/verge/beacon-chain.md#preset
export const MAX_STEMS = 2 ** 16;
export const MAX_COMMITMENTS_PER_STEM = 33;
Expand Down
4 changes: 2 additions & 2 deletions packages/state-transition/src/cache/stateCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
BeaconStateBellatrix,
BeaconStateCapella,
BeaconStateDeneb,
BeaconStateElectra,
BeaconStateVerkle,
} from "./types.js";
import {RewardCache, createEmptyRewardCache} from "./rewardCache.js";

Expand Down Expand Up @@ -131,7 +131,7 @@ export type CachedBeaconStateAltair = CachedBeaconState<BeaconStateAltair>;
export type CachedBeaconStateBellatrix = CachedBeaconState<BeaconStateBellatrix>;
export type CachedBeaconStateCapella = CachedBeaconState<BeaconStateCapella>;
export type CachedBeaconStateDeneb = CachedBeaconState<BeaconStateDeneb>;
export type CachedBeaconStateElectra = CachedBeaconState<BeaconStateElectra>;
export type CachedBeaconStateVerkle = CachedBeaconState<BeaconStateVerkle>;

export type CachedBeaconStateAllForks = CachedBeaconState<BeaconStateAllForks>;
export type CachedBeaconStateExecutions = CachedBeaconState<BeaconStateExecutions>;
Expand Down
2 changes: 1 addition & 1 deletion packages/state-transition/src/cache/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export type BeaconStatePhase0 = CompositeViewDU<SSZTypesFor<ForkName.phase0, "Be
export type BeaconStateAltair = CompositeViewDU<SSZTypesFor<ForkName.altair, "BeaconState">>;
export type BeaconStateBellatrix = CompositeViewDU<SSZTypesFor<ForkName.bellatrix, "BeaconState">>;
export type BeaconStateCapella = CompositeViewDU<SSZTypesFor<ForkName.capella, "BeaconState">>;
export type BeaconStateElectra = CompositeViewDU<SSZTypesFor<ForkName.electra, "BeaconState">>;
export type BeaconStateVerkle = CompositeViewDU<SSZTypesFor<ForkName.verkle, "BeaconState">>;
export type BeaconStateDeneb = CompositeViewDU<SSZTypesFor<ForkName.deneb, "BeaconState">>;

export type BeaconStateAllForks = CompositeViewDU<SSZTypesFor<ForkAll, "BeaconState">>;
Expand Down
2 changes: 1 addition & 1 deletion packages/state-transition/src/slot/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export {upgradeStateToAltair} from "./upgradeStateToAltair.js";
export {upgradeStateToBellatrix} from "./upgradeStateToBellatrix.js";
export {upgradeStateToCapella} from "./upgradeStateToCapella.js";
export {upgradeStateToDeneb} from "./upgradeStateToDeneb.js";
export {upgradeStateToElectra} from "./upgradeStateToElectra.js";
export {upgradeStateToVerkle} from "./upgradeStateToVerkle.js";

/**
* Dial state to next slot. Common for all forks
Expand Down
26 changes: 0 additions & 26 deletions packages/state-transition/src/slot/upgradeStateToElectra.ts

This file was deleted.

Loading

0 comments on commit 9fb1b70

Please sign in to comment.