Skip to content

Commit

Permalink
adding rpc timeout to config
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilkumar1612 committed Feb 4, 2025
1 parent 98bb20d commit b2a6907
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
8 changes: 8 additions & 0 deletions packages/executor/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -449,6 +456,7 @@ const bundlerDefaultConfigs: BundlerConfig = {
blockscoutApiKeys: [],
tenderlyApiUrl: "",
tenderlyKey: "",
rpcTimeout: "10s",
};

function getEnvVar<T>(envVar: string, fallback: T): T | string {
Expand Down
1 change: 1 addition & 0 deletions packages/executor/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export interface NetworkConfig {
blockscoutApiKeys: string[];
tenderlyApiUrl: string;
tenderlyKey: string;
rpcTimeout: string;
}

export type BundlerConfig = Omit<
Expand Down
9 changes: 6 additions & 3 deletions packages/executor/src/services/UserOpValidation/GethTracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand All @@ -45,7 +48,7 @@ export class GethTracer {
},
"latest",
{
timeout: "10s",
timeout: this.config.rpcTimeout,
tracer: stringifiedTracer,
},
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

Expand Down

0 comments on commit b2a6907

Please sign in to comment.