Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eth_estimateUserOperationGas fails with "account: not from EntryPoint" #242

Open
bhavyakukkar opened this issue Jan 29, 2025 · 0 comments
Open

Comments

@bhavyakukkar
Copy link

Since the call to EntryPointSimulations.simulateHandleOp is made from the simulation entrypoint deployed by the bundler (this.entryPoint in the MethodHandlerERC4337 class) (deployed here) and not the existing entrypoint specified in the config (this.config.entryPoint), the Account reverts it from BaseAccount._requireFromEntryPoint due to msg.sender not being the expected entrypoint.

estimateUserOperationGas handler at MethodHandlerERC4337.ts:139 making the off-chain simulateHandleOp call:

    await this._validateParameters(deepHexlify(userOp), entryPointInput)
    // todo: validation manager duplicate?
    const provider = this.provider
    const rpcParams = simulationRpcParams('simulateHandleOp', this.entryPoint.address, userOp, [AddressZero, '0x'],
      stateOverride
      // {
      // allow estimation when account's balance is zero.
      // todo: need a way to flag this, and not enable always.
      // [userOp.sender]: {
      //   balance: hexStripZeros(parseEther('1').toHexString())
      // }
      // }
    )
    const ret = await provider.send('eth_call', rpcParams)
      .catch((e: any) => { throw new RpcError(decodeRevertReason(e) as string, ValidationErrors.SimulateValidation) })

Is the entryPointAddress passed to simulationRpcParams supposed to be the simulation entrypoint? It is strange because the state-override ends up unnecessarily overriding that address with its own bytecode at rpcSimulateValidations.ts:16:

  const stateOverride = {
    [entryPointAddress]: {
      code: EntryPointSimulationsJson.deployedBytecode
    }
  }

This small update would make it so that the deployed bytecode of the simulation entrypoint corresponds to the entrypoint-address expected by the Account:

-    const rpcParams = simulationRpcParams('simulateHandleOp', this.entryPoint.address, userOp, [AddressZero, '0x'],
+    const rpcParams = simulationRpcParams('simulateHandleOp', this.config.entryPoint, userOp, [AddressZero, '0x'],
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant