Skip to content

eth_estimateGas Call Incorrectly Limited to 2 Parameters #1144

@tonatoz

Description

@tonatoz

System information

Geth version: latest
OS & Version: Windows/Linux/OSX

Expected behaviour

The eth_estimateGas call should support up to 4 parameters, as stated in the Ethereum JSON-RPC API specification. It should follow the same parameter format as eth_call, which allows:
1. Transaction object (from, to, data, etc.)
2. Block identifier (latest, pending, etc.)
3. Override state (optional)
4. State override context (optional)

Actual behaviour

Currently, eth_estimateGas on the Scroll node only accepts up to 2 parameters, rejecting valid calls with more parameters.

Attempting to call eth_estimateGas with 3 or 4 parameters results in the following error:

{
  "id": 1,
  "jsonrpc": "2.0",
  "error": {
    "message": "too many arguments, want at most 2",
    "code": -32602
  }
}

Root Cause in Scroll Code

In the Scroll node implementation (go-ethereum/internal/web3ext/web3ext.go), the method definition incorrectly limits eth_estimateGas to 2 parameters:

new web3._extend.Method({
    name: 'estimateGas',
    call: 'eth_estimateGas',
    params: 2,
    inputFormatter: [web3._extend.formatters.inputCallFormatter, web3._extend.formatters.inputBlockNumberFormatter],
    outputFormatter: web3._extend.utils.toDecimal
}),

However, it should allow 4 parameters to match eth_call:

new web3._extend.Method({
    name: 'estimateGas',
    call: 'eth_estimateGas',
    params: 4,
    inputFormatter: [web3._extend.formatters.inputCallFormatter, web3._extend.formatters.inputBlockNumberFormatter, null, null],
    outputFormatter: web3._extend.utils.toDecimal
}),

Steps to reproduce the behaviour

  1. Call eth_estimateGas with 3 or 4 parameters using the following JSON-RPC request:
{
  "jsonrpc": "2.0",
  "method": "eth_estimateGas",
  "params": [
    {
      "data": "0x5f3bd1c8000000000000000000000000530000000000000000000000000000000000000400000000000000000000000000000000000000000000000000b1a2bc2ec5000000000000000000000000000023defc2ca207e7fbd84ae43b00048fb5cb4db5b20000000000000000000000003c1bca5a656e69edcd0d4e36bebb3fcdaca60cf1000000000000000000000000000000000000000000000000000000000001bec800000000000000000000000085cd07ea01423b1e937929b44e4ad8c40bbb5e7100000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000184dd9c5f96000000000000000000000000530000000000000000000000000000000000000400000000000000000000000000000000000000000000000000b1a2bc2ec500000000000000000000000000003c1bca5a656e69edcd0d4e36bebb3fcdaca60cf1000000000000000000000000000000000000000000000000000000000001bf3b000000000000000000000000000000000000000000000000000000000001bec800000000000000000000000023defc2ca207e7fbd84ae43b00048fb5cb4db5b200000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004301530000000000000000000000000000000000000401ffff013Cc5375F08D5DF15611C3a446D31fA99a08BD1820085CD07Ea01423b1E937929B44E4Ad8c40BbB5E7100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
      "from": "0x23DefC2Ca207e7FBD84AE43B00048Fb5Cb4DB5B2",
      "to": "0xAC4c6e212A361c968F1725b4d055b47E63F80b75"
    },
    "latest",
    {
      "0x5300000000000000000000000000000000000004": {
        "stateDiff": {
          "0x142f45ef67bd9814daffa145548c97faa388198bdf1e225e51ab47e9e589148b": "0x00000000000000000000000000000000000000000000000000b1a2bc2ec50000"
        }
      }
    }
  ],
  "id": 1
}
  1. Observe the incorrect response:
{
  "id": 1,
  "jsonrpc": "2.0",
  "error": {
    "message": "too many arguments, want at most 2",
    "code": -32602
  }
}

Suggested Fix

Modify the Scroll node implementation in go-ethereum/internal/web3ext/web3ext.go to allow 4 parameters for eth_estimateGas:

new web3._extend.Method({
    name: 'estimateGas',
    call: 'eth_estimateGas',
    params: 4,
    inputFormatter: [web3._extend.formatters.inputCallFormatter, web3._extend.formatters.inputBlockNumberFormatter, null, null],
    outputFormatter: web3._extend.utils.toDecimal
}),

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions