openethereum/parity-ethereum

Light client gas estimation does not work

danuker opened this issue · 8 comments

I'm running:

  • Which Parity version?: 1.11.4-beta-cc44ae9cb-20180619/x86_64-linux-gnu/rustc1.26.1
  • Which operating system?: Linux Debian
  • How installed?: via binaries (Deb packages)
  • Are you fully synchronized?: yes (in light mode)
  • Which network are you connected to?: ethereum
  • Did you try to restart the node?: yes

I am running the light client (--light CLI option).

Steps to reproduce
When I try to get a gas estimation for a plain transaction, I get a weird "Unknown block number" error.

> curl --data '{"method":"eth_estimateGas","params":[{"from":"0x_my_address_here"}],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545

{"jsonrpc":"2.0","error":{"code":-32602,"message":"Unknown block number"},"id":1}

Actual behavior
{"jsonrpc":"2.0","error":{"code":-32602,"message":"Unknown block number"},"id":1}

Expected behavior
I should either get a real gas estimate, or a useful error message.

Note: While waiting for a "real" sync, I can get a proper response to eth_estimateGas.

Tbaut commented

Thanks for reporting the issue.
Can you try with "latest":

curl --data '{"method":"eth_estimateGas","params":[{"from":"0x_my_address_here"}, "latest"],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545

(I could not reproduce on Kovan)

I tried it. Same response:

> curl --data '{"method":"eth_estimateGas","params":[{"from":"0x_my_address_here"}, "latest"],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8544
{"jsonrpc":"2.0","error":{"code":-32602,"message":"Unknown block number"},"id":1}

Edit: had to start on different ports; my default node was using the default ones.

Seems to work on Kovan for me as well.

Tbaut commented

I can reproduce a slightly different problem on mainnet, the call is simply not resolving. This is a known issue though: #8996

I could not reproduce your problem though.

@danuker @Tbaut

I can reproduce this on the main net what I have discovered is that the merkle proof fails because your account is not in the state db and then it will just return an empty account!

This gets then propagated via the network to the rpc helper which in turn pattern match on the account to get the nonce. Thus, if the nonce is missing it will be regarded as an invalid block number that's the reason why you see the following error message :

{"jsonrpc":"2.0","error":{"code":-32602,"message":"Unknown block number"},"id":1}

@rphmeier
Is it safe to provide a default value for the nonce in this context, i.e. on either of the following places:

I'm not sure of what implications this would have on the other RPCs!

The right place to change it would be in light_fetch, where we should use the default account nonce when we get the None variant of the returned Option<BasicAccount>.