diff --git a/src/cli/setupServer.ts b/src/cli/setupServer.ts index cd5d96c8..9635d2fe 100644 --- a/src/cli/setupServer.ts +++ b/src/cli/setupServer.ts @@ -79,6 +79,7 @@ const getValidator = ({ gasPriceManager, parsedArgs["chain-type"], parsedArgs["entrypoint-simulation-contract"], + parsedArgs["fixed-gas-limit-for-estimation"], parsedArgs.tenderly, parsedArgs["balance-override"] ) @@ -93,6 +94,7 @@ const getValidator = ({ gasPriceManager, parsedArgs["chain-type"], parsedArgs["entrypoint-simulation-contract"], + parsedArgs["fixed-gas-limit-for-estimation"], parsedArgs.tenderly, parsedArgs["balance-override"], parsedArgs["expiration-check"] diff --git a/src/rpc/gasEstimation.ts b/src/rpc/gasEstimation.ts index 49fc2cd3..16049067 100644 --- a/src/rpc/gasEstimation.ts +++ b/src/rpc/gasEstimation.ts @@ -82,23 +82,24 @@ export async function simulateHandleOpV06( publicClient: PublicClient, targetAddress: Address, targetCallData: Hex, - finalParam: StateOverrides | undefined = undefined + finalParam: StateOverrides | undefined = undefined, + fixedGasLimitForEstimation?: bigint ): Promise { try { await publicClient.request({ method: "eth_call", - // @ts-ignore params: [ - // @ts-ignore { to: entryPoint, data: encodeFunctionData({ abi: EntryPointV06Abi, functionName: "simulateHandleOp", args: [userOperation, targetAddress, targetCallData] - }) + }), + ...(fixedGasLimitForEstimation !== undefined && { + gas: `0x${fixedGasLimitForEstimation.toString(16)}` + }), }, - // @ts-ignore "latest", // @ts-ignore ...(finalParam ? [finalParam] : []) @@ -198,7 +199,8 @@ async function callPimlicoEntryPointSimulations( entryPoint: Address, entryPointSimulationsCallData: Hex[], entryPointSimulationsAddress: Address, - stateOverride?: StateOverrides + stateOverride?: StateOverrides, + fixedGasLimitForEstimation?: bigint ) { const callData = encodeFunctionData({ abi: PimlicoEntryPointSimulationsAbi, @@ -211,7 +213,10 @@ async function callPimlicoEntryPointSimulations( params: [ { to: entryPointSimulationsAddress, - data: callData + data: callData, + ...(fixedGasLimitForEstimation !== undefined && { + gas: `0x${fixedGasLimitForEstimation.toString(16)}` + }) }, "latest", // @ts-ignore @@ -382,7 +387,8 @@ export async function simulateHandleOpV07( publicClient: PublicClient, entryPointSimulationsAddress: Address, chainId: number, - finalParam: StateOverrides | undefined = undefined + finalParam: StateOverrides | undefined = undefined, + fixedGasLimitForEstimation?: bigint ): Promise { const userOperations = [...queuedUserOperations, userOperation] @@ -516,7 +522,8 @@ export async function simulateHandleOpV07( entryPointSimulationsSimulateTargetCallData ], entryPointSimulationsAddress, - finalParam + finalParam, + fixedGasLimitForEstimation ) try { @@ -576,7 +583,8 @@ export function simulateHandleOp( balanceOverrideEnabled: boolean, chainId: number, stateOverride: StateOverrides = {}, - entryPointSimulationsAddress?: Address + entryPointSimulationsAddress?: Address, + fixedGasLimitForEstimation?: bigint ): Promise { let finalStateOverride = undefined @@ -596,7 +604,9 @@ export function simulateHandleOp( publicClient, targetAddress, targetCallData, - finalStateOverride + finalStateOverride, + // Enable fixed gas limit for estimation only for Vanguard testnet and Vanar mainnet + chainId === 2040 || chainId ===78600 ? fixedGasLimitForEstimation : undefined ) } @@ -614,6 +624,8 @@ export function simulateHandleOp( publicClient, entryPointSimulationsAddress, chainId, - finalStateOverride + finalStateOverride, + // Enable fixed gas limit for estimation only for Vanguard testnet and Vanar mainnet + chainId === 2040 || chainId ===78600 ? fixedGasLimitForEstimation : undefined ) } diff --git a/src/rpc/validation/SafeValidator.ts b/src/rpc/validation/SafeValidator.ts index 283be190..33d306df 100644 --- a/src/rpc/validation/SafeValidator.ts +++ b/src/rpc/validation/SafeValidator.ts @@ -72,6 +72,7 @@ export class SafeValidator gasPriceManager: GasPriceManager, chainType: ChainType, entryPointSimulationsAddress?: Address, + fixedGasLimitForEstimation?: bigint, usingTenderly = false, balanceOverrideEnabled = false ) { @@ -82,6 +83,7 @@ export class SafeValidator gasPriceManager, chainType, entryPointSimulationsAddress, + fixedGasLimitForEstimation, usingTenderly, balanceOverrideEnabled ) diff --git a/src/rpc/validation/UnsafeValidator.ts b/src/rpc/validation/UnsafeValidator.ts index 2ae908c4..017ffd68 100644 --- a/src/rpc/validation/UnsafeValidator.ts +++ b/src/rpc/validation/UnsafeValidator.ts @@ -138,6 +138,7 @@ export class UnsafeValidator implements InterfaceValidator { chainId: number gasPriceManager: GasPriceManager entryPointSimulationsAddress?: Address + fixedGasLimitForEstimation?: bigint chainType: ChainType constructor( @@ -147,6 +148,7 @@ export class UnsafeValidator implements InterfaceValidator { gasPriceManager: GasPriceManager, chainType: ChainType, entryPointSimulationsAddress?: Address, + fixedGasLimitForEstimation?: bigint, usingTenderly = false, balanceOverrideEnabled = false, expirationCheck = true @@ -160,6 +162,7 @@ export class UnsafeValidator implements InterfaceValidator { this.chainId = publicClient.chain.id this.gasPriceManager = gasPriceManager this.entryPointSimulationsAddress = entryPointSimulationsAddress + this.fixedGasLimitForEstimation = fixedGasLimitForEstimation this.chainType = chainType } @@ -180,7 +183,8 @@ export class UnsafeValidator implements InterfaceValidator { this.balanceOverrideEnabled, this.chainId, stateOverrides, - this.entryPointSimulationsAddress + this.entryPointSimulationsAddress, + this.fixedGasLimitForEstimation ) if (error.result === "failed") {