Skip to content

internal, accounts, eth: utilize vm failed flag to help gas estimation #15030

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

Merged
merged 1 commit into from
Oct 2, 2017

Conversation

rjl493456442
Copy link
Member

@rjl493456442 rjl493456442 commented Aug 24, 2017

Motivation for this PR:

Now the gas is estimated through the gas is consumed all. But this method does not apply to all scenes. e.g. in the frontier contract deploys can fail without consuming all gas due to have not enough gas to store contract code. And in metropolish will have a revert opcode that can also revert without using all gas.

So a failed flag returned by vm is useful to detect whether an error occurred during the execution of the transaction. It can help to estimate gas accurately.

Besides, I raise the lower limit of the gas estimate to 21000, since the minimum gas cost is 21000.

Though there is another situation we can not handle it. If the call itself has a logical problem, no matter how much gas assigned, it always failed.

Copy link
Contributor

@fjl fjl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks OK, didn’t try it though.

@rjl493456442
Copy link
Member Author

@karalabe PTAL

@karalabe karalabe added this to the 1.7.1 milestone Oct 2, 2017
@karalabe
Copy link
Member

karalabe commented Oct 2, 2017

I've pushed a minor polish for this PR so it can also estimate 21000 exactly (it would only do 21001 until now).

One thing we need to check though is if this PR breaks pre-byzantium chains estimation or not. I don't remember exactly when we return failed, but it must keep working until the chain actually forks.

@karalabe
Copy link
Member

karalabe commented Oct 2, 2017

Seems to work for both plain value transfers as well as a funky gas contract on both pre- and post Byzantium. Will merge as is and hope we don't break anything (given that post Byz is currently borked).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants