From 03b99c5f8463bc4d091f40dea2469f2874744497 Mon Sep 17 00:00:00 2001 From: marie-fourier Date: Tue, 13 Aug 2024 18:39:06 +0500 Subject: [PATCH] fix --- packages/executor/src/modules/eth.ts | 7 ++++--- packages/executor/src/utils/bignumber.ts | 9 +++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 packages/executor/src/utils/bignumber.ts diff --git a/packages/executor/src/modules/eth.ts b/packages/executor/src/modules/eth.ts index b9e586e3..edf0521c 100644 --- a/packages/executor/src/modules/eth.ts +++ b/packages/executor/src/modules/eth.ts @@ -28,6 +28,7 @@ import { import { GetNodeAPI, NetworkConfig } from "../interfaces"; import { EntryPointVersion } from "../services/EntryPointService/interfaces"; import { getUserOpGasLimit } from "../services/BundlingService/utils"; +import { maxBn, minBn } from "../utils/bignumber"; import { EstimateUserOperationGasArgs, SendUserOperationGasArgs, @@ -223,17 +224,17 @@ export class Eth { }); //> - let callGasLimit = binarySearchCGL; + let callGasLimit = minBn(binarySearchCGL, paidFeeCGL); if (userOp.factoryData !== undefined && userOp.factoryData.length > 2) { await this.provider .estimateGas({ from: entryPoint, to: userOp.sender, data: userOp.callData, - gasLimit: binarySearchCGL, + gasLimit: callGasLimit, }) .catch((_) => { - callGasLimit = paidFeeCGL; + callGasLimit = maxBn(binarySearchCGL, paidFeeCGL); }); } this.logger.debug( diff --git a/packages/executor/src/utils/bignumber.ts b/packages/executor/src/utils/bignumber.ts new file mode 100644 index 00000000..bbe9164c --- /dev/null +++ b/packages/executor/src/utils/bignumber.ts @@ -0,0 +1,9 @@ +import { BigNumber } from "ethers"; + +export function minBn(lhs: BigNumber, rhs: BigNumber): BigNumber { + return lhs.gt(rhs) ? rhs : lhs; +} + +export function maxBn(lhs: BigNumber, rhs: BigNumber): BigNumber { + return lhs.lt(rhs) ? rhs : lhs; +}