Skip to content

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

Description

@bhavyakukkar

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'],

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions