erigontech / erigon

Ethereum implementation on the efficiency frontier https://erigon.gitbook.io
GNU Lesser General Public License v3.0
3.09k stars 1.08k forks source link

"insufficient funds for gas * price + value" for eth_call when address doesn't have enough funds #11312

Open Serhy opened 1 month ago

Serhy commented 1 month ago

System information

Erigon version: ./erigon --version

OS & Version: Windows/Linux/OSX Linux

Erigon Command (with flags/config):

erigon \
  --chain gnosis \
  --datadir /data/er-gno-mainnet/ \
  --private.api.addr 0.0.0.0:9090 \
  --prune htcr \
  --http.addr 0.0.0.0 \
  --authrpc.addr 0.0.0.0 \
  --authrpc.vhosts "*" \
  --authrpc.jwtsecret /secrets/jwtsecret \
  --http.vhosts "*" \
  --http.corsdomain "*" \
  --http.api eth,net,web3,admin,trace,debug \
  --pprof \
  --pprof.addr 0.0.0.0 \
  --metrics \
  --metrics.addr 0.0.0.0 \
  --metrics.port 6061 \
  --ws \
  --log.console.verbosity 3 \
  --db.size.limit 8TB

Consensus Layer: lighthouse:v5.1.0 Consensus Layer Command (with flags/config):

lighthouse \
  beacon_node \
  --datadir /data \
  --testnet-dir /data/config \
  --port 13000 \
  --discovery-port 13000 \
  --eth1 \
  --disable-enr-auto-update \
  --http \
  --http-address 0.0.0.0 \
  --http-port 3500 \
  --metrics \
  --metrics-address 0.0.0.0 \
  --metrics-port 5054 \
  --metrics-allow-origin "*" \
  --target-peers 100 \
  --disable-packet-filter \
  --execution-endpoints http://erigon:8551 \
  --jwt-secrets /secrets/jwtsecret \
  --http-allow-sync-stalled

Chain/Network: Gnosis Mainnet

Expected behaviour

{
    "jsonrpc": "2.0",
    "result": "0x",
    "id": 9
}

Actual behaviour

{
    "jsonrpc": "2.0",
    "id": 9,
    "error": {
        "code": -32000,
        "message": "insufficient funds for gas * price + value: address 0x5aaEb6b20D8eDd123C63Aaa3Cf3C13f5969e630c have 0 want 350000000"
    }
}

Steps to reproduce the behaviour

--header 'Content-Type: application/json' \
--data '{
  "method": "eth_call",
  "params": [
    {
      "from": "0x5aAEB6B20d8EDD123c63aAa3Cf3c13F59F9e130c",
      "to": "0x3a0e542d1c1ac4b7593b00d262424f28456b7fd2",
      "data": "0x2d0335ab0000000000000000000000005aAEB6B20d8EDD123c63aAa3Cf3c13F59F9e130c"
    },
    "latest"
  ],
  "id": 9,
  "jsonrpc": "2.0"
}
'
awskii commented 1 month ago

So you asking of a regression - remove exact error why eth_call cannot be performed and get empty result instead?

Serhy commented 1 month ago

I have to admit now, @awskii that the issue might be more intentional behavior than a bug.

Essentially as I see it's about excluding gas by default in read-only eth_call method (i.e. when it's not specified explicitly).

That would align behavior with other clients I checked. Let me know if makes sense (then it would fall under 'improvement') or whether that's by design in Erigon.

awskii commented 1 month ago

0x result is also stated as wrong - 0 should be encoded as 0x0

Serhy commented 1 month ago

Example where expected result is not wrong but 0

{
  "method": "eth_call",
  "params": [
    {
      "from": "0x5aAEB6B20d8EDD123c63aAa3Cf3c13F5969e630c",
      "to": "0x3a0e542d1c1ac4b7593b00d262424f28456b7fd2",
      "data": "0x2d0335ab0000000000000000000000005aAEB6B20d8EDD123c63aAa3Cf3c13F59F9e130c"
    },
    "latest"
  ],
  "id": 1,
  "jsonrpc": "2.0"
}

Expected result:

{
    "jsonrpc": "2.0",
    "result": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "id": 1
}

Current result:

{
    "jsonrpc": "2.0",
    "id": 9,
    "error": {
        "code": -32000,
        "message": "insufficient funds for gas * price + value: address 0x5aaEb6b20D8eDd123C63Aaa3Cf3C13f5969e630c have 0 want 350000000"
    }
}
quickchase commented 1 month ago

IMO it doesn't make sense for a "read-only" eth_call to error out here because the from account has no/not enough gas in their account.

We already have rpc.gascap to weed out max gas per RPC calls, and this is a departure from how other clients handle this.

We see this same issue on Polygon/Matic - if the from account has 0 MATIC the eth_calls error out, if you remove from key it works as expected and returns a result.