diff --git a/packages/executor/src/modules/eth.ts b/packages/executor/src/modules/eth.ts index eab45ea6..98003135 100644 --- a/packages/executor/src/modules/eth.ts +++ b/packages/executor/src/modules/eth.ts @@ -148,14 +148,14 @@ export class Eth { async estimateUserOperationGas( args: EstimateUserOperationGasArgs ): Promise { - const { userOp, entryPoint } = args; + const { userOp: partialUserOp, entryPoint } = args; if (!this.validateEntryPoint(entryPoint)) { throw new RpcError("Invalid Entrypoint", RpcErrorCodes.INVALID_REQUEST); } - const userOpComplemented: UserOperationStruct = { - paymasterAndData: userOp.paymasterAndData ?? "0x", - ...userOp, + const userOp: UserOperationStruct = { + ...partialUserOp, + paymasterAndData: partialUserOp.paymasterAndData ?? "0x", callGasLimit: BigNumber.from(10e6), preVerificationGas: BigNumber.from(1e6), verificationGasLimit: BigNumber.from(10e6), @@ -163,12 +163,18 @@ export class Eth { maxPriorityFeePerGas: 1, }; - if (userOpComplemented.signature.length <= 2) { - userOpComplemented.signature = ECDSA_DUMMY_SIGNATURE; + if (this.chainId == 80002) { + userOp.callGasLimit = BigNumber.from(20e6); + userOp.preVerificationGas = BigNumber.from(50000); + userOp.verificationGasLimit = BigNumber.from(3e6); + } + + if (userOp.signature.length <= 2) { + userOp.signature = ECDSA_DUMMY_SIGNATURE; } const returnInfo = await this.userOpValidationService.validateForEstimation( - userOpComplemented, + userOp, entryPoint ); @@ -176,24 +182,19 @@ export class Eth { let { preOpGas, validAfter, validUntil, paid } = returnInfo; const verificationGasLimit = BigNumber.from(preOpGas) - .sub(userOpComplemented.preVerificationGas) + .sub(userOp.preVerificationGas) .mul(130) .div(100) // 130% markup .add(this.config.vglMarkup) .toNumber(); - let preVerificationGas: BigNumberish = - this.calcPreVerificationGas(userOpComplemented); - userOpComplemented.preVerificationGas = preVerificationGas; - let callGasLimit: BigNumber = BigNumber.from(0); - // calculate callGasLimit based on paid fee const { cglMarkup } = this.config; - callGasLimit = BigNumber.from(paid).div(userOpComplemented.maxFeePerGas); - callGasLimit = callGasLimit.sub(preOpGas).add(cglMarkup || 0); + const totalGas: BigNumber = BigNumber.from(paid).div(userOp.maxFeePerGas); + let callGasLimit = totalGas.sub(preOpGas).add(cglMarkup || 0); - if (callGasLimit.lt(0)) { - callGasLimit = BigNumber.from(cglMarkup || 0); + if (callGasLimit.lt(cglMarkup)) { + callGasLimit = BigNumber.from(cglMarkup); } //< checking for execution revert @@ -210,14 +211,16 @@ export class Eth { }); //> + userOp.callGasLimit = callGasLimit; + let preVerificationGas: BigNumberish = this.calcPreVerificationGas(userOp); const gasFee = await this.skandhaModule.getGasPrice(); if (this.pvgEstimator) { - userOpComplemented.maxFeePerGas = gasFee.maxFeePerGas; - userOpComplemented.maxPriorityFeePerGas = gasFee.maxPriorityFeePerGas; + userOp.maxFeePerGas = gasFee.maxFeePerGas; + userOp.maxPriorityFeePerGas = gasFee.maxPriorityFeePerGas; preVerificationGas = await this.pvgEstimator( entryPoint, - userOpComplemented, + userOp, preVerificationGas ); } @@ -226,13 +229,13 @@ export class Eth { return { preVerificationGas, - verificationGasLimit: verificationGasLimit, + verificationGasLimit, + callGasLimit, verificationGas: verificationGasLimit, - validAfter: validAfter ? BigNumber.from(validAfter) : undefined, - validUntil: validUntil ? BigNumber.from(validUntil) : undefined, - callGasLimit: callGasLimit, maxFeePerGas: gasFee.maxFeePerGas, maxPriorityFeePerGas: gasFee.maxPriorityFeePerGas, + validAfter: validAfter ? BigNumber.from(validAfter) : undefined, + validUntil: validUntil ? BigNumber.from(validUntil) : undefined, }; }