From df9e7de09f4defa2ca893f32eb23e0e863add6f5 Mon Sep 17 00:00:00 2001 From: Nazar Hussain Date: Thu, 21 Mar 2024 19:39:55 +0100 Subject: [PATCH 01/10] Fix validator produceBlockV3 req param --- packages/api/src/beacon/routes/validator.ts | 27 +++++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/packages/api/src/beacon/routes/validator.ts b/packages/api/src/beacon/routes/validator.ts index 5b6fa7797d88..109dbc4a1f5a 100644 --- a/packages/api/src/beacon/routes/validator.ts +++ b/packages/api/src/beacon/routes/validator.ts @@ -486,7 +486,7 @@ export type ReqTypes = { query: { randao_reveal: string; graffiti: string; - skip_randao_verification?: boolean; + skip_randao_verification?: string; fee_recipient?: string; builder_selection?: string; builder_boost_factor?: string; @@ -550,24 +550,31 @@ export function getReqSerializers(): ReqSerializers { ); const produceBlockV3: ReqSerializers["produceBlockV3"] = { - writeReq: (slot, randaoReveal, graffiti, skipRandaoVerification, opts) => ({ - params: {slot}, - query: { + writeReq(slot, randaoReveal, graffiti, skipRandaoVerification, opts) { + const query: ReqTypes["produceBlockV3"]["query"] = { randao_reveal: toHexString(randaoReveal), graffiti: toGraffitiHex(graffiti), fee_recipient: opts?.feeRecipient, - skip_randao_verification: skipRandaoVerification, builder_selection: opts?.builderSelection, builder_boost_factor: opts?.builderBoostFactor?.toString(), strict_fee_recipient_check: opts?.strictFeeRecipientCheck, blinded_local: opts?.blindedLocal, - }, - }), + }; + + if (skipRandaoVerification) { + query["skip_randao_verification"] = ""; + } + + return { + params: {slot}, + query, + }; + }, parseReq: ({params, query}) => [ params.slot, fromHexString(query.randao_reveal), fromGraffitiHex(query.graffiti), - query.skip_randao_verification, + parseSkipRandaoVerification(query.skip_randao_verification), { feeRecipient: query.fee_recipient, builderSelection: query.builder_selection as BuilderSelection, @@ -795,3 +802,7 @@ export function getReturnTypes(): ReturnTypes { function parseBuilderBoostFactor(builderBoostFactorInput?: string | number | bigint): bigint | undefined { return builderBoostFactorInput !== undefined ? BigInt(builderBoostFactorInput) : undefined; } + +function parseSkipRandaoVerification(skipRandaoVerification?: string): boolean { + return skipRandaoVerification !== undefined && ["", "true"].includes(skipRandaoVerification) ? true : false; +} From 3e1ee02f1afb3b6a97a5c76a2e21137dd463d025 Mon Sep 17 00:00:00 2001 From: Nazar Hussain Date: Thu, 21 Mar 2024 19:40:18 +0100 Subject: [PATCH 02/10] Update the lighthouse version for sim tests --- .env.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.test b/.env.test index 6dd87a441199..9d3b289a5151 100644 --- a/.env.test +++ b/.env.test @@ -4,7 +4,7 @@ GETH_DOCKER_IMAGE=ethereum/client-go:v1.13.14 # Use either image or local binary for the testing GETH_BINARY_DIR= -LIGHTHOUSE_DOCKER_IMAGE=sigp/lighthouse:v4.6.0-amd64-modern-dev +LIGHTHOUSE_DOCKER_IMAGE=sigp/lighthouse:v5.1.1-amd64-modern-dev # We can't upgrade nethermind further due to genesis hash mismatch with the geth # https://github.com/NethermindEth/nethermind/issues/6683 From f1a5e44b3c634afd1811674070249832c37ba4b6 Mon Sep 17 00:00:00 2001 From: Nazar Hussain Date: Thu, 21 Mar 2024 19:41:20 +0100 Subject: [PATCH 03/10] Include deneb in mixed-client sim tests --- packages/cli/test/sim/mixed_client.test.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/cli/test/sim/mixed_client.test.ts b/packages/cli/test/sim/mixed_client.test.ts index 9d56349457e6..f4f25a4996be 100644 --- a/packages/cli/test/sim/mixed_client.test.ts +++ b/packages/cli/test/sim/mixed_client.test.ts @@ -9,13 +9,15 @@ import {connectAllNodes, waitForSlot} from "../utils/simulation/utils/network.js const altairForkEpoch = 2; const bellatrixForkEpoch = 4; const capellaForkEpoch = 6; -const runTillEpoch = 8; +const denebForkEpoch = 8; +const runTillEpoch = 10; const syncWaitEpoch = 2; const {estimatedTimeoutMs, forkConfig} = defineSimTestConfig({ ALTAIR_FORK_EPOCH: altairForkEpoch, BELLATRIX_FORK_EPOCH: bellatrixForkEpoch, CAPELLA_FORK_EPOCH: capellaForkEpoch, + DENEB_FORK_EPOCH: denebForkEpoch, runTillEpoch: runTillEpoch + syncWaitEpoch, initialNodes: 2, }); @@ -41,18 +43,11 @@ const env = await SimulationEnvironment.initWithDefaults( keysCount: 32, remote: true, beacon: BeaconClient.Lighthouse, - // for cross client make sure lodestar doesn't use v3 for now untill lighthouse supports validator: { type: ValidatorClient.Lodestar, options: { clientOptions: { - useProduceBlockV3: false, - // this should cause usage of produceBlockV2 - // - // but if blinded production is enabled in lighthouse beacon then this should cause - // usage of produce blinded block which should return execution block in blinded format - // but only enable that after testing lighthouse beacon - "builder.selection": "executiononly", + useProduceBlockV3: true, }, }, }, From e765907f7c4e7b6c64e0e91329405cfb84ba49e8 Mon Sep 17 00:00:00 2001 From: Nazar Hussain Date: Thu, 21 Mar 2024 20:21:40 +0100 Subject: [PATCH 04/10] Fix query param schema type --- packages/api/src/beacon/routes/validator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/api/src/beacon/routes/validator.ts b/packages/api/src/beacon/routes/validator.ts index 109dbc4a1f5a..ddae735db1d5 100644 --- a/packages/api/src/beacon/routes/validator.ts +++ b/packages/api/src/beacon/routes/validator.ts @@ -589,7 +589,7 @@ export function getReqSerializers(): ReqSerializers { randao_reveal: Schema.StringRequired, graffiti: Schema.String, fee_recipient: Schema.String, - skip_randao_verification: Schema.Boolean, + skip_randao_verification: Schema.String, builder_selection: Schema.String, builder_boost_factor: Schema.String, strict_fee_recipient_check: Schema.Boolean, From 31a699e2f04274f4dc3a3290cbd93fe352beaa03 Mon Sep 17 00:00:00 2001 From: Nazar Hussain Date: Thu, 21 Mar 2024 20:21:49 +0100 Subject: [PATCH 05/10] Fix the unit tests --- packages/api/test/unit/beacon/testData/validator.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/api/test/unit/beacon/testData/validator.ts b/packages/api/test/unit/beacon/testData/validator.ts index 0769fbc47d9b..6b410b724e4f 100644 --- a/packages/api/test/unit/beacon/testData/validator.ts +++ b/packages/api/test/unit/beacon/testData/validator.ts @@ -49,7 +49,7 @@ export const testData: GenericServerTestCases = { 32000, randaoReveal, graffiti, - undefined, + false, { feeRecipient, builderSelection: undefined, @@ -65,7 +65,7 @@ export const testData: GenericServerTestCases = { 32000, randaoReveal, graffiti, - undefined, + false, { feeRecipient, builderSelection: undefined, @@ -109,7 +109,7 @@ export const testData: GenericServerTestCases = { 32000, randaoReveal, graffiti, - undefined, + false, { feeRecipient, builderSelection: undefined, From df95b6900939679992971b086560668664f61eb7 Mon Sep 17 00:00:00 2001 From: Nazar Hussain Date: Thu, 21 Mar 2024 20:27:35 +0100 Subject: [PATCH 06/10] Fix the code as per feedback --- packages/api/src/beacon/routes/validator.ts | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/packages/api/src/beacon/routes/validator.ts b/packages/api/src/beacon/routes/validator.ts index ddae735db1d5..e97704de6c9b 100644 --- a/packages/api/src/beacon/routes/validator.ts +++ b/packages/api/src/beacon/routes/validator.ts @@ -550,26 +550,19 @@ export function getReqSerializers(): ReqSerializers { ); const produceBlockV3: ReqSerializers["produceBlockV3"] = { - writeReq(slot, randaoReveal, graffiti, skipRandaoVerification, opts) { - const query: ReqTypes["produceBlockV3"]["query"] = { + writeReq: (slot, randaoReveal, graffiti, skipRandaoVerification, opts) => ({ + params: {slot}, + query: { randao_reveal: toHexString(randaoReveal), graffiti: toGraffitiHex(graffiti), fee_recipient: opts?.feeRecipient, + ...(skipRandaoVerification && {skip_randao_verification: ""}), builder_selection: opts?.builderSelection, builder_boost_factor: opts?.builderBoostFactor?.toString(), strict_fee_recipient_check: opts?.strictFeeRecipientCheck, blinded_local: opts?.blindedLocal, - }; - - if (skipRandaoVerification) { - query["skip_randao_verification"] = ""; - } - - return { - params: {slot}, - query, - }; - }, + }, + }), parseReq: ({params, query}) => [ params.slot, fromHexString(query.randao_reveal), From 3266f457b89109a6b1c10acc47d5d83bb300706a Mon Sep 17 00:00:00 2001 From: Nazar Hussain Date: Thu, 21 Mar 2024 20:59:20 +0100 Subject: [PATCH 07/10] Update the parse method --- packages/api/src/beacon/routes/validator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/api/src/beacon/routes/validator.ts b/packages/api/src/beacon/routes/validator.ts index e97704de6c9b..2bcc9ee06578 100644 --- a/packages/api/src/beacon/routes/validator.ts +++ b/packages/api/src/beacon/routes/validator.ts @@ -797,5 +797,5 @@ function parseBuilderBoostFactor(builderBoostFactorInput?: string | number | big } function parseSkipRandaoVerification(skipRandaoVerification?: string): boolean { - return skipRandaoVerification !== undefined && ["", "true"].includes(skipRandaoVerification) ? true : false; + return skipRandaoVerification !== undefined && skipRandaoVerification === ""; } From 6fde9d93657a8880e213bdb2c5662f2c4b729b19 Mon Sep 17 00:00:00 2001 From: Nazar Hussain Date: Thu, 21 Mar 2024 21:44:48 +0100 Subject: [PATCH 08/10] Add cancun support to geth client for sim tests --- .../utils/simulation/execution_clients/index.ts | 14 +++++++++++--- packages/cli/test/utils/simulation/interfaces.ts | 1 + .../utils/simulation/utils/execution_genesis.ts | 3 ++- packages/cli/test/utils/simulation/utils/index.ts | 10 +++++----- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/packages/cli/test/utils/simulation/execution_clients/index.ts b/packages/cli/test/utils/simulation/execution_clients/index.ts index b0d4086e663d..0bc28ca32db1 100644 --- a/packages/cli/test/utils/simulation/execution_clients/index.ts +++ b/packages/cli/test/utils/simulation/execution_clients/index.ts @@ -8,7 +8,7 @@ import { ExecutionNode, ExecutionStartMode, } from "../interfaces.js"; -import {getEstimatedShanghaiTime} from "../utils/index.js"; +import {getEstimatedForkTime} from "../utils/index.js"; import {getGethGenesisBlock} from "../utils/execution_genesis.js"; import {ensureDirectories} from "../utils/paths.js"; import {generateGethNode} from "./geth.js"; @@ -28,8 +28,16 @@ export async function createExecutionNode( cliqueSealingPeriod: options.cliqueSealingPeriod ?? CLIQUE_SEALING_PERIOD, shanghaiTime: options.shanghaiTime ?? - getEstimatedShanghaiTime({ - capellaForkEpoch: forkConfig.CAPELLA_FORK_EPOCH, + getEstimatedForkTime({ + forkEpoch: forkConfig.CAPELLA_FORK_EPOCH, + genesisTime: options.genesisTime, + secondsPerSlot: forkConfig.SECONDS_PER_SLOT, + additionalSlots: 0, + }), + cancunTime: + options.cancunTime ?? + getEstimatedForkTime({ + forkEpoch: forkConfig.DENEB_FORK_EPOCH, genesisTime: options.genesisTime, secondsPerSlot: forkConfig.SECONDS_PER_SLOT, additionalSlots: 0, diff --git a/packages/cli/test/utils/simulation/interfaces.ts b/packages/cli/test/utils/simulation/interfaces.ts index d8708c199eb1..dc2b09a6ed9f 100644 --- a/packages/cli/test/utils/simulation/interfaces.ts +++ b/packages/cli/test/utils/simulation/interfaces.ts @@ -128,6 +128,7 @@ export interface ExecutionGenesisOptions => { - const {ttd, cliqueSealingPeriod, shanghaiTime, genesisTime} = options; + const {ttd, cliqueSealingPeriod, shanghaiTime, genesisTime, cancunTime} = options; const genesis = { config: { @@ -24,6 +24,7 @@ export const getGethGenesisBlock = ( berlinBlock: 0, londonBlock: 0, shanghaiTime, + cancunTime, terminalTotalDifficulty: Number(ttd as bigint), clique: {period: cliqueSealingPeriod, epoch: 30000}, }, diff --git a/packages/cli/test/utils/simulation/utils/index.ts b/packages/cli/test/utils/simulation/utils/index.ts index bc0a4ee98d6f..82bdef27b269 100644 --- a/packages/cli/test/utils/simulation/utils/index.ts +++ b/packages/cli/test/utils/simulation/utils/index.ts @@ -125,20 +125,20 @@ export const getEstimatedTTD = ({ return BigInt(Math.ceil(secondsTillBellatrix / cliqueSealingPeriod) * ETH_TTD_INCREMENT); }; -export const getEstimatedShanghaiTime = ({ +export const getEstimatedForkTime = ({ genesisTime, secondsPerSlot, - capellaForkEpoch, + forkEpoch, additionalSlots, }: { genesisTime: number; secondsPerSlot: number; - capellaForkEpoch: number; + forkEpoch: number; additionalSlots: number; }): number => { - const secondsTillCapella = capellaForkEpoch * activePreset.SLOTS_PER_EPOCH * secondsPerSlot; + const secondsTillFork = forkEpoch * activePreset.SLOTS_PER_EPOCH * secondsPerSlot; - return genesisTime + secondsTillCapella + additionalSlots * secondsPerSlot; + return genesisTime + secondsTillFork + additionalSlots * secondsPerSlot; }; export const squeezeString = (val: string, length: number, sep = "..."): string => { From 1418586beeaab3fc7f6c749d1b8eb70440ebeeb9 Mon Sep 17 00:00:00 2001 From: Nazar Hussain Date: Thu, 21 Mar 2024 21:59:14 +0100 Subject: [PATCH 09/10] Fix the types --- .../execution_clients/nethermind.ts | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/packages/cli/test/utils/simulation/execution_clients/nethermind.ts b/packages/cli/test/utils/simulation/execution_clients/nethermind.ts index 88932f1ffc87..08acfb2fad27 100644 --- a/packages/cli/test/utils/simulation/execution_clients/nethermind.ts +++ b/packages/cli/test/utils/simulation/execution_clients/nethermind.ts @@ -15,8 +15,19 @@ export const generateNethermindNode: ExecutionNodeGenerator Date: Thu, 21 Mar 2024 22:25:57 +0100 Subject: [PATCH 10/10] Add deneb support to multi-fork sim tests --- packages/cli/test/sim/multi_fork.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/cli/test/sim/multi_fork.test.ts b/packages/cli/test/sim/multi_fork.test.ts index 6feb6adaaf8b..6ee4bc975536 100644 --- a/packages/cli/test/sim/multi_fork.test.ts +++ b/packages/cli/test/sim/multi_fork.test.ts @@ -24,13 +24,15 @@ import {createWithdrawalAssertions} from "../utils/simulation/assertions/withdra const altairForkEpoch = 2; const bellatrixForkEpoch = 4; const capellaForkEpoch = 6; -const runTillEpoch = 8; +const denebForkEpoch = 8; +const runTillEpoch = 10; const syncWaitEpoch = 2; const {estimatedTimeoutMs, forkConfig} = defineSimTestConfig({ ALTAIR_FORK_EPOCH: altairForkEpoch, BELLATRIX_FORK_EPOCH: bellatrixForkEpoch, CAPELLA_FORK_EPOCH: capellaForkEpoch, + DENEB_FORK_EPOCH: denebForkEpoch, runTillEpoch: runTillEpoch + syncWaitEpoch, initialNodes: 5, });