eth-infinitism/bundler

verificationGasLimit calculation unnecessarily includes preVerificationGas

voltrevo opened this issue · 1 comments

Hi

On this line:

    const verificationGasLimit = BigNumber.from(preOpGas).toNumber()

https://github.com/eth-infinitism/bundler/blob/26e4f4c/packages/bundler/src/UserOpMethodHandler.ts#L157

preOpGas is used for the verificationGasLimit for the response.

However, preOpGas includes preVerificationGas:

            outOpInfo.preOpGas = preGas - gasleft() + userOp.preVerificationGas;

https://github.com/eth-infinitism/account-abstraction/blob/8fae866/contracts/core/EntryPoint.sol#L672

In addition to this seeming to be unnecessary (since the gas needed for verification should be unrelated to preVerificationGas), this caused me confusion because I was setting high values for all gas fields when calling eth_estimateUserOperationGas so that I could then follow with the appropriate values returned by this call. This caused the bundler to respond with an unreasonably high value for verificationGas, which is supposed to be only the amount necessary for the operation. In my case, it was higher than the hardcoded 10e6 overall gas limit, causing bundle failure.

Yes, the verfiicationGas calculation is currently incorrect. We are in the process of fixing and standarizing gas limit calculations.
It is indeed a complex issue, and affect more than just this method.