eth-infinitism / bundler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`preVerificationGas` cannot be changed when using `VerifyingPaymaster`

skyh24 opened this issue · comments

commented

When using VerifyingPaymaster.sol, preVerificationGas is packed in userOpHash.
Thus we have to calculate signature in VerifyingPaymaster(gasless verifyingSigner).
However we use @account-abstraction/sdk, after calculating the paymasterAndData, we will change preVerificationGas
This will lead to failure when using VerifyingPaymaster, see code:

// BaseAccountAPI.ts
async createUnsignedUserOp (info: TransactionDetailsForUserOp): Promise<UserOperationStruct> {
partialUserOp.paymasterAndData = paymasterAndData ?? '0x'
return {
      ...partialUserOp,
      preVerificationGas: this.getPreVerificationGas(partialUserOp),
      signature: ''
    }

To solve this is either

  1. The simplest way is to omit preVerificationGas field in VerifyingPaymaster.sol
    or
  2. The other solution is to pre-calculate preVerificationGas with exact number of words in calcPreVerificationGas or resersve some words in calcPreVerificationGas

I prefer the first solution, which will modify the contract.

the above first solution means the user is allowed to put any value of preVerificationGas (say, 5 eth), and the paymaster will accept this payment...
I don't think this is a good idea - the paymater sign (that is, approve) these fields and values for a reason..
The right way to create the userOp (and we will need to fix the SDK for that):

  • create partial userop, with stub paymasterAndData, which has to be in the right length as the paymaster needs. This is probably done by a call into the "paymaster service api" - but no need to contact any external server. a local
  • use that to createUnsignedUserOp
  • now contact the paymaster service to sign the userop.
  • finally, let the user sign the generated UserOp

@drortirosh I've come to the same problem, and it looks like this issue still needs to be fixed in the SDK.
Is there a reason why you closed the issue?