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

feat: placeholder PR for verge #7069

Draft
wants to merge 8 commits into
base: unstable
Choose a base branch
from
Draft
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
3 changes: 3 additions & 0 deletions packages/beacon-node/src/api/impl/validator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,9 @@ export function getValidatorApi(
controller.abort();
}
return engineBlock;
}).catch((e) => {
console.log("enginePromise", e);
throw e;
})
: Promise.reject(new Error("Engine disabled"));

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export const VERKLE_ELEPHANTWITHWINGS_BANNER = String.raw`
:~~.
:!:^::^^!!^
:!^^ !:J.
.!!:! .^7^
.?7~: ^#! !!!^!~.
:!^ GP~..^^?^ ^!:
!^ Y5 #7:
.:^^~7~. ! ~~6800~~^ ^6800^ ~~6800 68 00 68~~ 00~ ||
.~! 55J ~~6800~~ :! !^ .YP :JP 7B. ^7#
^7 :: 5 #:::^::~~6800~~^^?!?.~:: :! !^ 6800 .^PJ JG ~!B
:G ^7 ^ !^68 00^ ~~6800~~ :! !: .&~ ^#! ^!55~~~6800~~7G~ !7B
7G ~!5J ^? !.----. ~! ~~6800~~ .7#: 6800 ~
?G :^?G. ...... ^?^.!G. ?G :^?G. ...... ^?^.!G. !
~! ~~6800~~ .7#: 6800 G~ 7G ~!5J ^? !.----. ::
:! !: .&~ ^#! ^!55~~~6800~~7G~ !7B :G ^7 ^ !^68 00^ ~~6800~~ ::
:! !^ 6800 .^PJ JG ~!B ^7 :: 5 ^^ !!!! #:::^::~~6800~~^^?!?.~
:! !^ .YP :JP 7B. ^7# .~!~ ~~6800 ^6800^ ~~6800~~
6800 68 00 68~~ 00~ 6800
`;
6 changes: 6 additions & 0 deletions packages/beacon-node/src/chain/blocks/verifyBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +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 {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 @@ -152,6 +153,11 @@ export async function verifyBlocksInEpoch(
this.logger.info("Activating withdrawals", {epoch: this.config.CAPELLA_FORK_EPOCH});
break;

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

case ForkName.deneb:
this.logger.info(DENEB_BLOWFISH_BANNER);
this.logger.info("Activating blobs", {epoch: this.config.DENEB_FORK_EPOCH});
Expand Down
32 changes: 31 additions & 1 deletion packages/beacon-node/src/execution/engine/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {capella, deneb, electra, Wei, bellatrix, Root, ExecutionPayload} from "@lodestar/types";
import * as util from "node:util";
import {capella, deneb, Wei, bellatrix, Root, verkle, electra, ExecutionPayload, ssz} from "@lodestar/types";
import {
BYTES_PER_LOGS_BLOOM,
FIELD_ELEMENTS_PER_BLOB,
Expand Down Expand Up @@ -166,6 +167,7 @@ export type ExecutionPayloadRpc = {
depositRequests?: DepositRequestRpc[]; // ELECTRA
withdrawalRequests?: WithdrawalRequestRpc[]; // ELECTRA
consolidationRequests?: ConsolidationRequestRpc[]; // ELECTRA
executionWitness?: Record<string, unknown>; // DENEB
};

export type WithdrawalRpc = {
Expand Down Expand Up @@ -234,6 +236,20 @@ export function serializeExecutionPayload(fork: ForkName, data: ExecutionPayload
payload.withdrawals = withdrawals.map(serializeWithdrawal);
}

// 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.verkle.ExecutionWitness.toJson(executionWitness);
// serialization with ssz serialize suffix diff's suffix to a string while geth expects num
(payload.executionWitness as verkle.ExecutionWitness).stateDiff.forEach((sDiff) => {
sDiff.suffixDiffs.forEach((sfDiff) => {
sfDiff.suffix = Number(sfDiff.suffix);
});
});
}

// DENEB adds blobGasUsed & excessBlobGas to the ExecutionPayload
if (ForkSeq[fork] >= ForkSeq.deneb) {
const {blobGasUsed, excessBlobGas} = data as deneb.ExecutionPayload;
Expand Down Expand Up @@ -315,6 +331,20 @@ export function parseExecutionPayload(
(executionPayload as capella.ExecutionPayload).withdrawals = withdrawals.map((w) => deserializeWithdrawal(w));
}

// 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 verkle.ExecutionPayload).executionWitness =
ssz.verkle.ExecutionWitness.fromJson(executionWitness);
}

// DENEB adds excessBlobGas to the ExecutionPayload
if (ForkSeq[fork] >= ForkSeq.deneb) {
const {blobGasUsed, excessBlobGas} = data;
Expand Down
1 change: 1 addition & 0 deletions packages/beacon-node/test/sim/electra-interop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ describe("executionEngine / ExecutionEngineHttp", function () {
ALTAIR_FORK_EPOCH: 0,
BELLATRIX_FORK_EPOCH: 0,
CAPELLA_FORK_EPOCH: 0,
VERKLE_FORK_EPOCH: 0,
DENEB_FORK_EPOCH: 0,
ELECTRA_FORK_EPOCH: electraEpoch,
TERMINAL_TOTAL_DIFFICULTY: ttd,
Expand Down
3 changes: 3 additions & 0 deletions packages/beacon-node/test/spec/presets/fork.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
CachedBeaconStateAltair,
CachedBeaconStatePhase0,
CachedBeaconStateCapella,
CachedBeaconStateVerkle,
CachedBeaconStateDeneb,
} from "@lodestar/state-transition";
import * as slotFns from "@lodestar/state-transition/slot";
Expand Down Expand Up @@ -34,6 +35,8 @@ const fork: TestRunnerFn<ForkStateCase, BeaconStateAllForks> = (forkNext) => {
return slotFns.upgradeStateToBellatrix(preState as CachedBeaconStateAltair);
case ForkName.capella:
return slotFns.upgradeStateToCapella(preState as CachedBeaconStateBellatrix);
case ForkName.verkle:
return slotFns.upgradeStateToVerkle(preState as CachedBeaconStateCapella);
case ForkName.deneb:
return slotFns.upgradeStateToDeneb(preState as CachedBeaconStateCapella);
case ForkName.electra:
Expand Down
15 changes: 14 additions & 1 deletion packages/beacon-node/test/spec/presets/transition.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,21 @@ function getTransitionConfig(fork: ForkName, forkEpoch: number): Partial<ChainCo
return {ALTAIR_FORK_EPOCH: 0, BELLATRIX_FORK_EPOCH: forkEpoch};
case ForkName.capella:
return {ALTAIR_FORK_EPOCH: 0, BELLATRIX_FORK_EPOCH: 0, CAPELLA_FORK_EPOCH: forkEpoch};
case ForkName.verkle:
return {
ALTAIR_FORK_EPOCH: 0,
BELLATRIX_FORK_EPOCH: 0,
CAPELLA_FORK_EPOCH: 0,
VERKLE_FORK_EPOCH: forkEpoch,
};
case ForkName.deneb:
return {ALTAIR_FORK_EPOCH: 0, BELLATRIX_FORK_EPOCH: 0, CAPELLA_FORK_EPOCH: 0, DENEB_FORK_EPOCH: forkEpoch};
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ describe("UpgradeLightClientHeader", function () {
ALTAIR_FORK_EPOCH: 1,
BELLATRIX_FORK_EPOCH: 2,
CAPELLA_FORK_EPOCH: 3,
DENEB_FORK_EPOCH: 4,
ELECTRA_FORK_EPOCH: 5,
VERKLE_FORK_EPOCH: 4,
DENEB_FORK_EPOCH: 5,
ELECTRA_FORK_EPOCH: 6,
});

const genesisValidatorsRoot = Buffer.alloc(32, 0xaa);
Expand All @@ -27,6 +28,7 @@ describe("UpgradeLightClientHeader", function () {
altair: ssz.altair.LightClientHeader.defaultValue(),
capella: ssz.capella.LightClientHeader.defaultValue(),
bellatrix: ssz.altair.LightClientHeader.defaultValue(),
verkle: ssz.verkle.LightClientHeader.defaultValue(),
deneb: ssz.deneb.LightClientHeader.defaultValue(),
electra: ssz.electra.LightClientHeader.defaultValue(),
};
Expand All @@ -36,8 +38,9 @@ describe("UpgradeLightClientHeader", function () {
altair: 10,
bellatrix: 17,
capella: 25,
deneb: 33,
electra: 41,
verkle: 33,
deneb: 41,
electra: 49,
};
});

Expand Down
23 changes: 17 additions & 6 deletions packages/beacon-node/test/unit/network/fork.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ function getForkConfig({
altair,
bellatrix,
capella,
verkle,
deneb,
electra,
}: {
phase0: number;
altair: number;
bellatrix: number;
capella: number;
verkle: number;
deneb: number;
electra: number;
}): BeaconConfig {
Expand Down Expand Up @@ -51,20 +53,28 @@ function getForkConfig({
prevVersion: Buffer.from([0, 0, 0, 2]),
prevForkName: ForkName.bellatrix,
},
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,
},
deneb: {
name: ForkName.deneb,
seq: ForkSeq.deneb,
epoch: deneb,
version: Buffer.from([0, 0, 0, 4]),
prevVersion: Buffer.from([0, 0, 0, 3]),
prevForkName: ForkName.capella,
version: Buffer.from([0, 0, 0, 5]),
prevVersion: Buffer.from([0, 0, 0, 4]),
prevForkName: ForkName.verkle,
},
electra: {
name: ForkName.electra,
seq: ForkSeq.electra,
epoch: electra,
version: Buffer.from([0, 0, 0, 5]),
prevVersion: Buffer.from([0, 0, 0, 4]),
version: Buffer.from([0, 0, 0, 6]),
prevVersion: Buffer.from([0, 0, 0, 5]),
prevForkName: ForkName.deneb,
},
};
Expand Down Expand Up @@ -142,11 +152,12 @@ const testScenarios = [

for (const testScenario of testScenarios) {
const {phase0, altair, bellatrix, capella, testCases} = testScenario;
const verkle = Infinity;
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, electra});
const forkConfig = getForkConfig({phase0, altair, bellatrix, capella, verkle, deneb, electra});
const forks = forkConfig.forks;
for (const testCase of testCases) {
const {epoch, currentFork, nextFork, activeForks} = testCase;
Expand Down
9 changes: 9 additions & 0 deletions packages/beacon-node/test/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,27 @@ export function getConfig(fork: ForkName, forkEpoch = 0): ChainForkConfig {
BELLATRIX_FORK_EPOCH: 0,
CAPELLA_FORK_EPOCH: forkEpoch,
});
case ForkName.verkle:
return createChainForkConfig({
ALTAIR_FORK_EPOCH: 0,
BELLATRIX_FORK_EPOCH: 0,
CAPELLA_FORK_EPOCH: 0,
VERKLE_FORK_EPOCH: forkEpoch,
});
case ForkName.deneb:
return createChainForkConfig({
ALTAIR_FORK_EPOCH: 0,
BELLATRIX_FORK_EPOCH: 0,
CAPELLA_FORK_EPOCH: 0,
VERKLE_FORK_EPOCH: 0,
DENEB_FORK_EPOCH: forkEpoch,
});
case ForkName.electra:
return createChainForkConfig({
ALTAIR_FORK_EPOCH: 0,
BELLATRIX_FORK_EPOCH: 0,
CAPELLA_FORK_EPOCH: 0,
VERKLE_FORK_EPOCH: 0,
DENEB_FORK_EPOCH: 0,
ELECTRA_FORK_EPOCH: forkEpoch,
});
Expand Down
11 changes: 10 additions & 1 deletion packages/cli/src/config/beaconParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,23 @@ export function getBeaconConfigFromArgs(args: GlobalArgs): {config: ChainForkCon
* @see getBeaconParams
*/
export function getBeaconParamsFromArgs(args: GlobalArgs): ChainConfig {
return getBeaconParams({
const beaconParams = getBeaconParams({
network: args.network,
paramsFile: args.paramsFile,
additionalParamsCli: {
...parseBeaconParamsArgs(args as IBeaconParamsUnparsed),
...parseTerminalPowArgs(args as ITerminalPowArgs),
},
});

beaconParams["VERKLE_FORK_EPOCH"] = beaconParams["ELECTRA_FORK_EPOCH"]
beaconParams["VERKLE_FORK_VERSION"] = beaconParams["ELECTRA_FORK_VERSION"]

beaconParams["DENEB_FORK_EPOCH"] = Infinity
beaconParams["ELECTRA_FORK_EPOCH"] = Infinity


return beaconParams;
}

/**
Expand Down
10 changes: 7 additions & 3 deletions packages/config/src/chainConfig/configs/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,16 @@ export const chainConfig: ChainConfig = {
CAPELLA_FORK_VERSION: b("0x03000000"),
CAPELLA_FORK_EPOCH: 194048, // April 12 (epoch: 194048 slot: 6209536 UTC: 4/12/2023, 10:27:35 PM)

// VERKLE
VERKLE_FORK_VERSION: b("0x04000000"),
VERKLE_FORK_EPOCH: Infinity,

// Deneb
DENEB_FORK_VERSION: b("0x04000000"),
DENEB_FORK_EPOCH: 269568, // March 13, 2024, 01:55:35pm UTC
DENEB_FORK_VERSION: b("0x05000000"),
DENEB_FORK_EPOCH: Infinity,

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

// Time parameters
Expand Down
7 changes: 5 additions & 2 deletions packages/config/src/chainConfig/configs/minimal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@ export const chainConfig: ChainConfig = {
// Capella
CAPELLA_FORK_VERSION: b("0x03000001"),
CAPELLA_FORK_EPOCH: Infinity,
// Verkle
VERKLE_FORK_VERSION: b("0x04000001"),
VERKLE_FORK_EPOCH: Infinity,
// Deneb
DENEB_FORK_VERSION: b("0x04000001"),
DENEB_FORK_VERSION: b("0x05000001"),
DENEB_FORK_EPOCH: Infinity,
// ELECTRA
ELECTRA_FORK_VERSION: b("0x05000001"),
ELECTRA_FORK_VERSION: b("0x06000001"),
ELECTRA_FORK_EPOCH: Infinity,

// Time parameters
Expand Down
6 changes: 6 additions & 0 deletions packages/config/src/chainConfig/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ export type ChainConfig = {
// Capella
CAPELLA_FORK_VERSION: Uint8Array;
CAPELLA_FORK_EPOCH: number;
// VERKLE
VERKLE_FORK_VERSION: Uint8Array;
VERKLE_FORK_EPOCH: number;
// DENEB
DENEB_FORK_VERSION: Uint8Array;
DENEB_FORK_EPOCH: number;
Expand Down Expand Up @@ -101,6 +104,9 @@ export const chainConfigTypes: SpecTypes<ChainConfig> = {
// Capella
CAPELLA_FORK_VERSION: "bytes",
CAPELLA_FORK_EPOCH: "number",
// VERKLE
VERKLE_FORK_VERSION: "bytes",
VERKLE_FORK_EPOCH: "number",
// DENEB
DENEB_FORK_VERSION: "bytes",
DENEB_FORK_EPOCH: "number",
Expand Down
12 changes: 11 additions & 1 deletion packages/config/src/forkConfig/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,19 @@ export function createForkConfig(config: ChainConfig): ForkConfig {
prevVersion: config.BELLATRIX_FORK_VERSION,
prevForkName: ForkName.bellatrix,
};
const verkle: ForkInfo = {
name: ForkName.verkle,
seq: ForkSeq.verkle,
// testnet uses electra to specify
epoch: config.VERKLE_FORK_EPOCH,
version: config.VERKLE_FORK_VERSION,
prevVersion: config.CAPELLA_FORK_VERSION,
prevForkName: ForkName.capella,
};
const deneb: ForkInfo = {
name: ForkName.deneb,
seq: ForkSeq.deneb,
// no scheduling deneb and electra
epoch: config.DENEB_FORK_EPOCH,
version: config.DENEB_FORK_VERSION,
prevVersion: config.CAPELLA_FORK_VERSION,
Expand All @@ -70,7 +80,7 @@ export function createForkConfig(config: ChainConfig): ForkConfig {

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

// Prevents allocating an array on every getForkInfo() call
const forksAscendingEpochOrder = Object.values(forks);
Expand Down
Loading
Loading