Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eth_estimateGas produces an incorrect value when run multiple times in parallel #15896

Closed
nuevoalex opened this issue Jan 16, 2018 · 1 comment

Comments

@nuevoalex
Copy link

nuevoalex commented Jan 16, 2018

System information

Geth version: Version: 1.7.3
OS & Version: Alpine Linux v3.7
Commit hash : 4bb3c89d44e372e6a9ab85a8be0c9345265c763a

Expected behavior

Calls to estimateGas return a deterministic amount that is sufficient to run the estimated transaction.

Actual behavior

Making many eth_estimateGas calls running in parallel for the same transaction will in rare cases return an anomalous value that is less than the gas required for the transaction to succeed.

Steps to reproduce the behavior

Upload this contract:

contract TestContract {
    bool private flag;

    function test() public {
        flag = true;
    }
}

Now using curl run several (10 worked with just a couple attempts) gas estimate requests in parallel with the relevant data filled in as appropriate for your setup:

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_estimateGas","params":[{"from": "0xfromaddess", "to": "0xcontractaddresss", "data": "0xf8a8fd6d"}], "id": 1}' --url http://localhost:port -H "Content-Type: application/json" & ... & ...

The results should come back identical, however after a few attempts you will get something like this:

{"jsonrpc":"2.0","id":1,"result":"0x682b"}
{"jsonrpc":"2.0","id":1,"result":"0x682b"}
{"jsonrpc":"2.0","id":1,"result":"0x682b"}
{"jsonrpc":"2.0","id":1,"result":"0x682b"}
{"jsonrpc":"2.0","id":1,"result":"0x682b"}
{"jsonrpc":"2.0","id":1,"result":"0x682b"}
{"jsonrpc":"2.0","id":1,"result":"0x682b"}
{"jsonrpc":"2.0","id":1,"result":"0x6821"}

Note that the last response is incorrect.

Worth noting in the actual node setup is that we are using 1 second block times.

@stale
Copy link

stale bot commented Jan 19, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot closed this as completed Mar 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant