alchemyplatform / rundler

An ERC-4337 Bundler in Rust
GNU Lesser General Public License v3.0
285 stars 43 forks source link

Running `Bundler` with `Anvil` fails: `Method not found`. #777

Closed sshmaxime closed 2 weeks ago

sshmaxime commented 2 months ago

Describe the bug I'm running an instance of Rundler (running on port 8546) and Anvil (running on port 8545) locally through docker-compose and upon calling eth_estimateUserOperationGas it fails with:

Something that caught my attention is that for reasons that I cannot explain, inside the RPC error payload returned by my server, the URL is set to my anvil node. That being said, I double checked everything and I'm 100% sure that the request goes to Rundler which then seems to pass it to then anvil node. I'm a bit lost here to be honest.

Can anyone help or has any idea where I did something wrong ? Thank you very much !

docker-compose.yaml:

version: "3.8"

x-entrypoint-version: &entrypoint-version
  DISABLE_ENTRY_POINT_V0_6: false
  DISABLE_ENTRY_POINT_V0_7: true

x-priority-fee: &priority-fee
  PRIORITY_FEE_MODE_KIND: base_fee_percent
  PRIORITY_FEE_MODE_VALUE: 0

services:
  anvil:
    platform: linux/amd64
    image: ghcr.io/foundry-rs/foundry
    working_dir: /anvil
    ports:
      - "8545:8545"
    entrypoint: anvil --fork-url https://opt-sepolia.g.alchemy.com/v2/x --host 0.0.0.0
    healthcheck:
      test: ["CMD-SHELL", "cast balance 0x0000000000000000000000000000000000000000"]
      interval: 1s
      retries: 10
      timeout: 10s

  rundler:
    depends_on:
      anvil: 
       condition: service_healthy
    image: rundler
    command: node
    ports:
      - "8546:3000"
      - "8080:8080"
    environment:
      RUST_LOG: info
      ENTRY_POINTS: 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789
      NODE_HTTP: http://anvil:8545
      CHAIN_ID: 11155420
      UNSAFE: true
      BUILDER_PRIVATE_KEY: 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
      <<: [*entrypoint-version, *priority-fee]

Full JSON RPC error:

{
  "body": {
    "jsonrpc": "2.0",
    "id": 46,
    "error": {
      "code": -32601,
      "message": "Method not found"
    }
  },
  "code": "SERVER_ERROR",
  "error": {
    "code": -32601
  },
  "level": "error",
  "reason": "processing response error",
  "requestBody": {
    "method": "eth_estimateUserOperationGas",
    "params": [
      {
        "sender": "0x31FBdBb4fC17c6819db86A6984b4Dae25c72aD79",
        "nonce": "0x0",
        "initCode": "0x29e69af6083f790d31804ed9adad40ccc32accc9af09872500000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000120728da5b63228c33d0f2e2797ee87fda099a2795a31831d5e8f406a4a8be80ad4000000000000000000000000000000000000000000000000000000000000009849960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97635d00000000fbfc3007154e4ecc8c0b6e020557d7bd0014c2c8cb8faf38cdf6063e0105972a75aa8b501b9ca5010203262001215820fd3589d834ccdc47af3c581637a0a9552a170b5bd0489427c03228b3d23826f92258209cb9349f5338d1151618921c39b1b2258a5d4868df0365f21ed8ab0872ed5ba6000000000000000000000000000000000000000000000000000000000000000000000000000000420072912f220eae93da272191aa4ab0854dbb290e81134eb16ab3f37c4e9d5a57a52fac99ac96c21aed9e503a4071fdd0e9b3910d0c3e4022359809a29493f2d69e1c000000000000000000000000000000000000000000000000000000000000",
        "callData": "0xb61d27f6000000000000000000000000770be037c2e8b80e1e2c27ab1dbcf19ecfb0223700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000041249c58b00000000000000000000000000000000000000000000000000000000",
        "callGasLimit": "0x0",
        "verificationGasLimit": "0x0",
        "preVerificationGas": "0x0",
        "maxFeePerGas": "0x0",
        "maxPriorityFeePerGas": "0x0",
        "paymasterAndData": "0x904dff443aac03cefc537a85a98c1cd590dbbcb9f35737941a88598d7ccf0707c8efed312f5b417e7bdeaab028f93999ec4da4f75e3febdd27267129253952f7d776bce9bef1912a5294b55be393375ce4bcf7cd1c",
        "signature": "0x0072912f220eae93da272191aa4ab0854dbb290e81134eb16ab3f37c4e9d5a57a52fac99ac96c21aed9e503a4071fdd0e9b3910d0c3e4022359809a29493f2d69e1c"
      },
      "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"
    ],
    "id": 46,
    "jsonrpc": "2.0"
  },
  "requestMethod": "POST",
  "url": "http://localhost:8545"
}
sshmaxime commented 2 months ago

Additionally, when i try to send the eth_estimateUserOperationGas manually over curl to Rundler, I'm getting this: {"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params","data":"data did not match any variant of untagged enum RpcUserOperationOptionalGas"},"id":44}

This is the command I run:

curl --request POST \
     --url http://localhost:8546 \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
    "method": "eth_estimateUserOperationGas",
    "params": [
      {
        "sender": "0xB795f0D4A90181C236ddb5f9E637Ea8a413aA9ef",
        "nonce": "0x0",
        "initCode": "0x29e69af6083f790d31804ed9adad40ccc32accc9af09872500000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000120728da5b63228c33d0f2e2797ee87fda099a2795a31831d5e8f406a4a8be80ad4000000000000000000000000000000000000000000000000000000000000009849960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97635d00000000fbfc3007154e4ecc8c0b6e020557d7bd001484f830e63015dcad3ef49e63901b98d59a352d45a5010203262001215820b677f3421a3c1afd27fb9a73b2ed15e0c6c784ebeba33e1dc32e3b7ddeafdf1722582031febbbf065dfb105c7e4f96524042c17b352ebff3c50f034e760bc34c5ff53500000000000000000000000000000000000000000000000000000000000000000000000000000042005e0fc121253f5ff3a16f2793c180aa743688a4f8ad580cfd6127cb8c06f2d9f57f6525bd5b9e56273184751fb805d14321246115b5afb58cffdf7aea047d94c21b000000000000000000000000000000000000000000000000000000000000",
        "callData": "0xb61d27f6000000000000000000000000770be037c2e8b80e1e2c27ab1dbcf19ecfb0223700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000041249c58b00000000000000000000000000000000000000000000000000000000",
        "callGasLimit": "0x0",
        "verificationGasLimit": "0x0",
        "preVerificationGas": "0x0",
        "maxFeePerGas": "0x0",
        "maxPriorityFeePerGas": "0x0",
        "paymasterAndData": "0x904dff443aac03cefc537a85a98c1cd590dbbcb90cece08a6cf646848b003ce0e64d2bcdf93a883b2d82e4b80671cd57545b5820349ad72ef85b4fb559d71c9f2275377e6ab46c11517d6ccc4da2b4004cb9513b1c",
        "signature": "0x005e0fc121253f5ff3a16f2793c180aa743688a4f8ad580cfd6127cb8c06f2d9f57f6525bd5b9e56273184751fb805d14321246115b5afb58cffdf7aea047d94c21b"
      },
      "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"
    ],
    "id": 44,
    "jsonrpc": "2.0"
  }
'
github-actions[bot] commented 3 weeks ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

sshmaxime commented 2 weeks ago

Can this issue be re-opened please ?

dancoombs commented 2 weeks ago

Your Method not found issue above is because you sent eth_estimateUserOperationGas on http://localhost:8545, which is the port that Anvil is running on. Only the bundler supports that RPC endpoint so you'll need to send it on 8546.

dancoombs commented 2 weeks ago

data did not match any variant of untagged enum RpcUserOperationOptionalGas

You have an odd number of hex characters in your callData field. I added a 0 at the end and it worked. This is on the feat/v0.4 branch which changed some of our serde logic (moved to using alloy/ruint for U256), so you might find a different answer on main for those 0x0 values which are also technically invalid hex.

dancoombs commented 2 weeks ago

0x0 will be accepted in v0.4 once released due to https://github.com/recmo/uint/blob/780f5d3173b85b6c91f52842763372fc953ad637/src/support/serde.rs#L21