From 66c765a29ad4daaaa286c4ba68fa4f1019c22c4d Mon Sep 17 00:00:00 2001 From: Logan Nguyen Date: Mon, 29 Sep 2025 11:04:20 -0400 Subject: [PATCH] feat: add optional stateOverride parameter validation to eth_call (#4420) Signed-off-by: Logan Nguyen --- packages/relay/src/lib/eth.ts | 1 + packages/relay/src/lib/validators/types.ts | 8 ++++++++ packages/server/tests/acceptance/rpc_batch3.spec.ts | 1 + 3 files changed, 10 insertions(+) diff --git a/packages/relay/src/lib/eth.ts b/packages/relay/src/lib/eth.ts index 5c3238fb0f..79587d8e4b 100644 --- a/packages/relay/src/lib/eth.ts +++ b/packages/relay/src/lib/eth.ts @@ -951,6 +951,7 @@ export class EthImpl implements Eth { @rpcParamValidationRules({ 0: { type: 'transaction', required: true }, 1: { type: 'blockParams', required: true }, + 2: { type: 'stateOverride', required: false }, }) @cache({ skipParams: [{ index: '1', value: constants.NON_CACHABLE_BLOCK_PARAMS }], diff --git a/packages/relay/src/lib/validators/types.ts b/packages/relay/src/lib/validators/types.ts index 4a7fbaebef..78cd17cf05 100644 --- a/packages/relay/src/lib/validators/types.ts +++ b/packages/relay/src/lib/validators/types.ts @@ -150,6 +150,14 @@ export const TYPES = { }, error: 'Expected TracerConfigWrapper which contains a valid TracerType and/or TracerConfig', }, + stateOverride: { + test: (param: any) => { + // Must be an object if provided + // TODO: This validation should be more detailed when state override is officially supported. + return typeof param === 'object' && !Array.isArray(param); + }, + error: 'Expected StateOverride object (currently accepting any object structure)', + }, } satisfies { [paramTypeName: string]: { test: (param: any) => boolean; diff --git a/packages/server/tests/acceptance/rpc_batch3.spec.ts b/packages/server/tests/acceptance/rpc_batch3.spec.ts index 5ac04dcd4e..17a9d7c431 100644 --- a/packages/server/tests/acceptance/rpc_batch3.spec.ts +++ b/packages/server/tests/acceptance/rpc_batch3.spec.ts @@ -2094,6 +2094,7 @@ describe('@api-batch-3 RPC Server Acceptance Tests', function () { data: '0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE', }, 'latest', + {}, null, ], eth_getTransactionByHash: ['0x4cc9a77780cf0e6d0dc75373bf00e3437db450ede45cb51b5da936fb46342c99', null],