Skip to content

Group jsonrpc batched eth_calls into one multicall internally and decode the output #2585

Description

@carneiro-cw

When processing an eth_call batch request we could group it and create a multicall from it before passing it along, we'd then need to parse the response back to the jsonrpc batch format.

One thing to note is that this can only work by grouping by the point in time the call will run on.

example request/response format:

curl -sS http://localhost:3000/?app=carneiro \
           -H 'content-type: application/json' \
           --data '[
  {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "eth_call",
    "params": [
      {
        "to": "<contract>",
        "data": "0x18160ddd"
      },
      "latest"
    ]
  },
  {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "eth_call",
    "params": [
      {
        "to": "<contract>",
        "data": "0x18160ddd"
      },
      "latest"
    ]
  },
  {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "eth_call",
    "params": [
      {
        "to": "<contract>",
        "data": "0x18160ddd"
      },
      "latest"
    ]
  },
  {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "eth_call",
    "params": [
      {
        "to": "<contract>",
        "data": "0x18160ddd"
      },
      "latest"
    ]
  },
  {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "eth_call",
    "params": [
      {
        "to": "<contract>",
        "data": "0x18160ddd"
      },
      "latest"
    ]
  }
]
' | jq

response:

[
  {
    "jsonrpc": "2.0",
    "id": 1,
    "result": "0x00000000000000000000000000000000000000000000000000ffffffffffffff"
  },
  {
    "jsonrpc": "2.0",
    "id": 1,
    "result": "0x00000000000000000000000000000000000000000000000000ffffffffffffff"
  },
  {
    "jsonrpc": "2.0",
    "id": 1,
    "result": "0x00000000000000000000000000000000000000000000000000ffffffffffffff"
  },
  {
    "jsonrpc": "2.0",
    "id": 1,
    "result": "0x00000000000000000000000000000000000000000000000000ffffffffffffff"
  },
  {
    "jsonrpc": "2.0",
    "id": 1,
    "result": "0x00000000000000000000000000000000000000000000000000ffffffffffffff"
  }
]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancerpcBugs or requests about the ETH JSON RPC

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions