openethereum/ethcore
David aefa8d5f59
Change how RPCs eth_call and eth_estimateGas handle "Pending" (#11127)
* Change how RPCs eth_call and eth_estimateGas handle "Pending"

Before this PR we would return a rather confusing error when calling `eth_call` and `eth_estimateGas` with `"Pending"`, e.g.:

```
{"jsonrpc":"2.0","error":{"code":-32000,"message":"This request is not supported because your node is running with state pruning. Run with --pruning=archive."},"id":"e237678f6648ed12ff05a74933d06d17"}
```

In reality what is going on is that users often use `"Pending"` when they really mean `"Latest"` (e.g. MyCrypto…) and when the block in question is not actually pending. This changes our behaviour for these two RPC calls to fall back to `"Latest"` when the query with `"Pending"` fails.
Note that we already behave this way for many other RPCs:

	- eth_call (after this PR)
	- eth_estimateGas (after this PR)
	- eth_getBalance
	- eth_getCode
	- eth_getStorageAt

Closes https://github.com/paritytech/parity-ethereum/issues/10096

* Fetch jsonrpc from git

* No real need to wait for new jsonrpc

* Add tests for calling eth_call/eth_estimateGas with "Pending"

* Fix a todo, add another

* Change client.latest_state to return the best header as well so we avoid potential data races and do less work

* Impl review suggestions

* Update rpc/src/v1/impls/eth.rs

Co-Authored-By: Niklas Adolfsson <niklasadolfsson1@gmail.com>

* Review grumbles

* update docs
2019-10-11 15:54:36 +02:00
..
account-db Update ethereum types to 0.8.0 version (#11139) 2019-10-08 14:18:44 +02:00
account-state Update ethereum types to 0.8.0 version (#11139) 2019-10-08 14:18:44 +02:00
benches Fix ethcore/benches build. (#10964) 2019-08-13 15:27:28 +02:00
block-reward Update ethereum types to 0.8.0 version (#11139) 2019-10-08 14:18:44 +02:00
blockchain Update ethereum types to 0.8.0 version (#11139) 2019-10-08 14:18:44 +02:00
builtin Use TryFrom instead of From+panic for Builtin (#11140) 2019-10-09 14:42:03 +02:00
call-contract Update ethereum types to 0.8.0 version (#11139) 2019-10-08 14:18:44 +02:00
client-traits Change how RPCs eth_call and eth_estimateGas handle "Pending" (#11127) 2019-10-11 15:54:36 +02:00
db Update ethereum types to 0.8.0 version (#11139) 2019-10-08 14:18:44 +02:00
engine RPC method for clearing the engine signer (#10920) 2019-10-09 14:42:51 +02:00
engines RPC method for clearing the engine signer (#10920) 2019-10-09 14:42:51 +02:00
evm Update ethereum types to 0.8.0 version (#11139) 2019-10-08 14:18:44 +02:00
executive-state Update ethereum types to 0.8.0 version (#11139) 2019-10-08 14:18:44 +02:00
light Update ethereum types to 0.8.0 version (#11139) 2019-10-08 14:18:44 +02:00
machine Use TryFrom instead of From+panic for Builtin (#11140) 2019-10-09 14:42:03 +02:00
node-filter Update ethereum types to 0.8.0 version (#11139) 2019-10-08 14:18:44 +02:00
pod Update ethereum types to 0.8.0 version (#11139) 2019-10-08 14:18:44 +02:00
private-tx Update ethereum types to 0.8.0 version (#11139) 2019-10-08 14:18:44 +02:00
res Deduplicate registrar contract & calling logic (#11110) 2019-10-03 15:15:25 +02:00
service Update ethereum types to 0.8.0 version (#11139) 2019-10-08 14:18:44 +02:00
snapshot Update ethereum types to 0.8.0 version (#11139) 2019-10-08 14:18:44 +02:00
spec Use TryFrom instead of From+panic for Builtin (#11140) 2019-10-09 14:42:03 +02:00
src Change how RPCs eth_call and eth_estimateGas handle "Pending" (#11127) 2019-10-11 15:54:36 +02:00
state-db Update ethereum types to 0.8.0 version (#11139) 2019-10-08 14:18:44 +02:00
sync Update ethereum types to 0.8.0 version (#11139) 2019-10-08 14:18:44 +02:00
trace Update ethereum types to 0.8.0 version (#11139) 2019-10-08 14:18:44 +02:00
trie-vm-factories Update to latest trie version. (#10972) 2019-08-15 15:36:48 +02:00
types Update ethereum types to 0.8.0 version (#11139) 2019-10-08 14:18:44 +02:00
verification Update ethereum types to 0.8.0 version (#11139) 2019-10-08 14:18:44 +02:00
vm Update ethereum types to 0.8.0 version (#11139) 2019-10-08 14:18:44 +02:00
wasm Update ethereum types to 0.8.0 version (#11139) 2019-10-08 14:18:44 +02:00
Cargo.toml Update ethereum types to 0.8.0 version (#11139) 2019-10-08 14:18:44 +02:00