Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

pending for defaultBlock causes issues during estimateGas #9288

Closed
iFA88 opened this issue Aug 6, 2018 · 12 comments
Closed

pending for defaultBlock causes issues during estimateGas #9288

iFA88 opened this issue Aug 6, 2018 · 12 comments
Labels
F2-bug 🐞 The client fails to follow expected behavior. M6-rpcapi 📣 RPC API.
Milestone

Comments

@iFA88
Copy link

iFA88 commented Aug 6, 2018

Greetings!

I have tried the following nodes:
Parity-Ethereum/v2.0.0-beta-6eae372-20180717/x86_64-linux-gnu/rustc1.27.1
Parity-Ethereum/v2.0.1-beta-e7dc0be-20180726/x86_64-linux-gnu/rustc1.27.2

where I have the same issue for eth_estimateGas when I use pending for defaultBlock parameter:

-> {"jsonrpc": "2.0", "params": [{"to": "0xa8711bf8f25e9d87498777e4b3b651f6e811cc7d", "from": "0xa8711bf8f25e9d87498777e4b3b651f6e811cc7d", "value": "0x2386f26fc10000", "data": "0x"}, "pending"], "method": "eth_estimateGas", "id": 1}
<- {"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":1}

This happens not every time, about 1/5 times. Maybe it happens during the block import process.

When it works then I receive:

-> [{"to": "0xa8711bf8f25e9d87498777e4b3b651f6e811cc7d", "from": "0xa8711bf8f25e9d87498777e4b3b651f6e811cc7d", "value": "0x2386f26fc10000", "data": "0x"}, "pending"], "method": "eth_estimateGas", "id": 1}
<- {"jsonrpc":"2.0","result":"0x5208","id":1}
@iFA88
Copy link
Author

iFA88 commented Aug 6, 2018

Not only the eth_estimateGas are affected, eth_getLogs and every method who can put defaultBlock parameter is affected.
If I use latest they produces the same error.

@Tbaut
Copy link
Contributor

Tbaut commented Aug 6, 2018

I could reproduce the problem.

If I use latest they produces the same error.

I did not reproduce with "latest" however. In general @iFA88, for a non mining node, "pending" will be the same as "latest" since your node is not creating any block.

@Tbaut Tbaut added F3-annoyance 💩 The client behaves within expectations, however this “expected behaviour” itself is at issue. M6-rpcapi 📣 RPC API. labels Aug 6, 2018
@Tbaut Tbaut added this to the 2.1 milestone Aug 6, 2018
@Tbaut
Copy link
Contributor

Tbaut commented Aug 6, 2018

Can you have a look @tomusdrw ?

@iFA88
Copy link
Author

iFA88 commented Aug 6, 2018

I have forgot to say that I use the following parameters:

--no-persistent-txqueue --jsonrpc-server-threads 8 --no-ancient-blocks --min-gas-price=10000000 --tx-queue-mem-limit=4096 --tx-queue-size=256000 --reseal-on-txs=all --force-sealing --rpcport 8548 --port 30306 --no-ws --no-secretstore --cache-size 2048

@Tbaut
Copy link
Contributor

Tbaut commented Aug 7, 2018

That's indeed important as --force-sealing lets you take into account the latest transactions. This is most probably a bug.

@Tbaut Tbaut added F2-bug 🐞 The client fails to follow expected behavior. and removed F3-annoyance 💩 The client behaves within expectations, however this “expected behaviour” itself is at issue. labels Aug 7, 2018
@tomusdrw
Copy link
Collaborator

tomusdrw commented Aug 8, 2018

@iFA88 I checked the code paths for latest resulting in the same error, but it's not clear for me how this could happen (if ever).

Could you provide -lrpc=trace,client=trace,miner=trace logs from the period when that happens for you using latest?

@iFA88
Copy link
Author

iFA88 commented Aug 8, 2018

Ofc!
The request is on: 2018-08-08 13:00:18

https://www.fusionsolutions.io/doc/log.txt

@tomusdrw
Copy link
Collaborator

tomusdrw commented Aug 8, 2018

@iFA88 Thanks! Although the request there is for pending block, do you have the same logs for latest as you mentioned it also happens in such case.

The logs highlighted some other issue with the code though, I will update #9310

@iFA88
Copy link
Author

iFA88 commented Aug 8, 2018

Yeah, i'm trying to reproduce the error for latest but unsuccessful.

@5chdn 5chdn modified the milestones: 2.1, 2.2 Sep 11, 2018
@5chdn 5chdn modified the milestones: 2.2, 2.3 Oct 29, 2018
@5chdn 5chdn modified the milestones: 2.3, 2.4 Jan 10, 2019
@iFA88
Copy link
Author

iFA88 commented Jan 18, 2019

Hi! I would like to report, that the bug is still available.

I'm using Parity-Ethereum/v2.2.7-stable-b00a21f-20190115/x86_64-linux-gnu/rustc1.31.1 fresh resynced with the following parameters:

--infinite-pending-block --no-persistent-txqueue --jsonrpc-server-threads 8 --no-ancient-blocks --min-gas-price=10000000 --tx-queue-mem-limit=4096 --tx-queue-size=256000 --reseal-on-txs=all --force-se
aling --base-path /mnt/node-1/fastEth --rpcport 8548 --port 30306 --no-ws --no-secretstore --cache-size 2048 --log-file /own/log/nodes/fastEth/parity_eth.log

Request:

-> {"jsonrpc": "2.0", "params": [{"to": "0xc937f5027d47250fa2df8cbf21f6f88e98817845", "from": "0xa8711bf8f25e9d87498777e4b3b651f6e811cc7d", "value": "0x0", "data": "0xa9059cbb000000000000000000000000610e3b4e804b367c182c5fc4d65d09c0897233890000000000000000000000000000000000000000000000000000000005f5e100"}, "pending"], "method": "eth_estimateGas", "id": 1}
<- {"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":1}

With earliest is the same result. With latest works and calculates the estimated gas amount.

If i want to send several transactions to the same contract I can not get how much gas should i attach it or even it throws/reverts or not.

@tomusdrw
Copy link
Collaborator

Indeed we don't have atomicity when we try to work on the pending state, so:

ensure_pending_block_exists();
call_into_pending_state();

This code works most of the time, but in case you have --reseal-on-txs=all it's very likely that in between the calls we will attempt to recreate the pednign state and it's going to be temporarily unavailable.

We should replace the pending RPC apis with something that allows us to get a copy of pending state and then call into it so that it's not susceptible to races like that.
(on the second though the RPC might be fine it might be issue with internal miner implementation)

@5chdn 5chdn modified the milestones: 2.4, 2.5 Feb 21, 2019
@soc1c soc1c removed this from the 2.5 milestone Apr 2, 2019
@soc1c soc1c added this to the 2.6 milestone Apr 2, 2019
@ordian ordian modified the milestones: 2.6, 2.7 Jul 12, 2019
@seunlanlege
Copy link
Member

closed by #11127

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
F2-bug 🐞 The client fails to follow expected behavior. M6-rpcapi 📣 RPC API.
Projects
None yet
Development

No branches or pull requests

7 participants