From 6b0ac5a4f3d608e3512b7dea65d766de1165dcda Mon Sep 17 00:00:00 2001 From: Jochem Brouwer Date: Sun, 13 Oct 2024 21:25:32 +0200 Subject: [PATCH] Fix engine-cancun hive tests (#3308) * client: attempt to fix some hive tests [no ci] * client: fix test --- packages/client/src/rpc/error-code.ts | 1 + packages/client/src/service/skeleton.ts | 9 +++++---- .../client/test/rpc/engine/forkchoiceUpdatedV1.spec.ts | 10 +++++----- packages/vm/benchmarks/run.ts | 4 ++-- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/packages/client/src/rpc/error-code.ts b/packages/client/src/rpc/error-code.ts index 9698444c91..9019f2060a 100644 --- a/packages/client/src/rpc/error-code.ts +++ b/packages/client/src/rpc/error-code.ts @@ -8,6 +8,7 @@ export const INTERNAL_ERROR = -32603 export const TOO_LARGE_REQUEST = -38004 export const UNSUPPORTED_FORK = -38005 export const UNKNOWN_PAYLOAD = -32001 +export const INVALID_FORKCHOICE_STATE = -38002 export const INVALID_HEX_STRING = -32000 export const validEngineCodes = [ diff --git a/packages/client/src/service/skeleton.ts b/packages/client/src/service/skeleton.ts index 4f0da81a90..5025002c3a 100644 --- a/packages/client/src/service/skeleton.ts +++ b/packages/client/src/service/skeleton.ts @@ -15,6 +15,7 @@ import { utf8ToBytes, } from '@ethereumjs/util' +import { INVALID_FORKCHOICE_STATE } from '../rpc/error-code.js' import { short, timeDuration } from '../util/index.js' import { DBKey, MetaDBManager } from '../util/metaDBManager.js' @@ -749,7 +750,7 @@ export class Skeleton extends MetaDBManager { if (this.status.linked || shouldBeSafeNumber >= subchain0.tail) { if (safeBlock === undefined) { throw { - code: INVALID_PARAMS, + code: INVALID_FORKCHOICE_STATE, message: `safe block not available in canonical chain`, } } else { @@ -759,7 +760,7 @@ export class Skeleton extends MetaDBManager { !equalsBytes(safeBlock.hash(), canonicalBlock.hash()) ) { throw { - code: INVALID_PARAMS, + code: INVALID_FORKCHOICE_STATE, message: `safe block not canonical in chain`, } } @@ -769,7 +770,7 @@ export class Skeleton extends MetaDBManager { if (this.status.linked || shouldBeFinalizedNumber >= subchain0.tail) { if (finalizedBlock === undefined) { throw { - code: INVALID_PARAMS, + code: INVALID_FORKCHOICE_STATE, message: `finalized block not available in canonical chain`, } } else { @@ -779,7 +780,7 @@ export class Skeleton extends MetaDBManager { !equalsBytes(finalizedBlock.hash(), canonicalBlock.hash()) ) { throw { - code: INVALID_PARAMS, + code: INVALID_FORKCHOICE_STATE, message: `finalized block not canonical in chain`, } } diff --git a/packages/client/test/rpc/engine/forkchoiceUpdatedV1.spec.ts b/packages/client/test/rpc/engine/forkchoiceUpdatedV1.spec.ts index e02bc6d7f6..3ea24e455b 100644 --- a/packages/client/test/rpc/engine/forkchoiceUpdatedV1.spec.ts +++ b/packages/client/test/rpc/engine/forkchoiceUpdatedV1.spec.ts @@ -3,7 +3,7 @@ import { Common, Hardfork, Mainnet } from '@ethereumjs/common' import { bytesToHex, randomBytes } from '@ethereumjs/util' import { assert, describe, it, vi } from 'vitest' -import { INVALID_PARAMS } from '../../../src/rpc/error-code.js' +import { INVALID_FORKCHOICE_STATE, INVALID_PARAMS } from '../../../src/rpc/error-code.js' import { blockToExecutionPayload } from '../../../src/rpc/modules/index.js' import { beaconData } from '../../testdata/blocks/beacon.js' import { postMergeData } from '../../testdata/geth-genesis/post-merge.js' @@ -183,7 +183,7 @@ describe(method, () => { finalizedBlockHash: '0x3b8fb240d288781d4aac94d3fd16809ee413bc99294a085798a589dae51ddd4b', }, ]) - assert.equal(res.error.code, INVALID_PARAMS) + assert.equal(res.error.code, INVALID_FORKCHOICE_STATE) assert.ok(res.error.message.includes('finalized block not available in canonical chain')) }) @@ -196,7 +196,7 @@ describe(method, () => { safeBlockHash: '0x3b8fb240d288781d4aac94d3fd16809ee413bc99294a085798a589dae51ddd4b', }, ]) - assert.equal(res.error.code, INVALID_PARAMS) + assert.equal(res.error.code, INVALID_FORKCHOICE_STATE) assert.ok(res.error.message.includes('safe block not available')) }) @@ -277,7 +277,7 @@ describe(method, () => { }, ]) - assert.equal(res.error.code, -32602) + assert.equal(res.error.code, INVALID_FORKCHOICE_STATE) assert.ok(res.error.message.includes('safe')) assert.ok(res.error.message.includes('canonical')) }) @@ -317,7 +317,7 @@ describe(method, () => { }, ]) - assert.equal(res.error.code, -32602) + assert.equal(res.error.code, INVALID_FORKCHOICE_STATE) assert.ok(res.error.message.includes('finalized')) assert.ok(res.error.message.includes('canonical')) }) diff --git a/packages/vm/benchmarks/run.ts b/packages/vm/benchmarks/run.ts index 3ed25d1a8a..e97e3af814 100644 --- a/packages/vm/benchmarks/run.ts +++ b/packages/vm/benchmarks/run.ts @@ -19,10 +19,10 @@ async function main() { // Input validation if (args.length < 4) { console.log( - 'Please provide at least one benchmark name when running a benchmark or doing profiling.' + 'Please provide at least one benchmark name when running a benchmark or doing profiling.', ) console.log( - 'Usage: npm run benchmarks|profiling -- BENCHMARK_NAME[:NUM_SAMPLES][,BENCHMARK_NAME[:NUM_SAMPLES]]' + 'Usage: npm run benchmarks|profiling -- BENCHMARK_NAME[:NUM_SAMPLES][,BENCHMARK_NAME[:NUM_SAMPLES]]', ) console.log(`Benchmarks available: ${Object.keys(BENCHMARKS).join(', ')}`) return process.exit(1)