From b2a69078070a2dff9cc49f11f1efe9c617dc83ae Mon Sep 17 00:00:00 2001 From: nikhil kumar Date: Wed, 5 Feb 2025 00:40:53 +0530 Subject: [PATCH] adding rpc timeout to config --- packages/executor/src/config.ts | 8 ++++++++ packages/executor/src/interfaces.ts | 1 + .../executor/src/services/UserOpValidation/GethTracer.ts | 9 ++++++--- .../services/UserOpValidation/validators/estimation.ts | 3 ++- .../src/services/UserOpValidation/validators/safe.ts | 3 ++- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/packages/executor/src/config.ts b/packages/executor/src/config.ts index 6b402aa6..0a610900 100644 --- a/packages/executor/src/config.ts +++ b/packages/executor/src/config.ts @@ -360,6 +360,13 @@ export class Config { ) ); + config.rpcTimeout = String( + fromEnvVar( + "RPC_TIMEOUT", + config.rpcTimeout || bundlerDefaultConfigs.rpcTimeout + ) + ); + config.blockscoutApiKeys = fromEnvVar( "BLOCKSCOUT_API_KEYS", config.blockscoutApiKeys != undefined @@ -449,6 +456,7 @@ const bundlerDefaultConfigs: BundlerConfig = { blockscoutApiKeys: [], tenderlyApiUrl: "", tenderlyKey: "", + rpcTimeout: "10s", }; function getEnvVar(envVar: string, fallback: T): T | string { diff --git a/packages/executor/src/interfaces.ts b/packages/executor/src/interfaces.ts index c49a2d9d..99eb8842 100644 --- a/packages/executor/src/interfaces.ts +++ b/packages/executor/src/interfaces.ts @@ -178,6 +178,7 @@ export interface NetworkConfig { blockscoutApiKeys: string[]; tenderlyApiUrl: string; tenderlyKey: string; + rpcTimeout: string; } export type BundlerConfig = Omit< diff --git a/packages/executor/src/services/UserOpValidation/GethTracer.ts b/packages/executor/src/services/UserOpValidation/GethTracer.ts index eddd6d21..2f75f003 100644 --- a/packages/executor/src/services/UserOpValidation/GethTracer.ts +++ b/packages/executor/src/services/UserOpValidation/GethTracer.ts @@ -2,7 +2,7 @@ import { readFileSync } from "node:fs"; import { resolve } from "node:path"; import { BigNumber, providers } from "ethers"; import { BundlerCollectorReturn } from "@skandha/types/lib/executor"; -import { TracerPrestateResponse } from "../../interfaces"; +import { NetworkConfig, TracerPrestateResponse } from "../../interfaces"; const tracer = readFileSync( resolve(process.cwd(), "packages", "executor", "tracer.js") @@ -29,7 +29,10 @@ const stringifiedTracer = tracer // ); export class GethTracer { - constructor(private provider: providers.JsonRpcProvider) {} + constructor( + private provider: providers.JsonRpcProvider, + private config: NetworkConfig + ) {} async debug_traceCall( tx: providers.TransactionRequest @@ -45,7 +48,7 @@ export class GethTracer { }, "latest", { - timeout: "10s", + timeout: this.config.rpcTimeout, tracer: stringifiedTracer, }, ]); diff --git a/packages/executor/src/services/UserOpValidation/validators/estimation.ts b/packages/executor/src/services/UserOpValidation/validators/estimation.ts index f3b42fcf..304a77e4 100644 --- a/packages/executor/src/services/UserOpValidation/validators/estimation.ts +++ b/packages/executor/src/services/UserOpValidation/validators/estimation.ts @@ -40,7 +40,8 @@ export class EstimationService { private logger: Logger ) { this.gethTracer = new GethTracer( - this.provider as providers.JsonRpcProvider + this.provider as providers.JsonRpcProvider, + this.networkConfig ); } diff --git a/packages/executor/src/services/UserOpValidation/validators/safe.ts b/packages/executor/src/services/UserOpValidation/validators/safe.ts index ebc402eb..5a0c3d7b 100644 --- a/packages/executor/src/services/UserOpValidation/validators/safe.ts +++ b/packages/executor/src/services/UserOpValidation/validators/safe.ts @@ -73,7 +73,8 @@ export class SafeValidationService { private logger: Logger ) { this.gethTracer = new GethTracer( - this.provider as providers.JsonRpcProvider + this.provider as providers.JsonRpcProvider, + this.networkConfig ); }