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 result may not be enough #61

Open
davidmurdoch opened this issue Feb 24, 2020 · 0 comments
Open

eth_estimateGas result may not be enough #61

davidmurdoch opened this issue Feb 24, 2020 · 0 comments

Comments

@davidmurdoch
Copy link

Gas estimation is tricky.

  1. A transactions gasUsed amount is not the same as the amount of gas required for a transaction.
  2. Gas refunds are deducted from the gasUsed amount, but the refunded amount must be available when running the transactions
  3. For some OPCODES (like CALL) 1/64th of the current gasLeft is withheld from the CALL. This has a strange side effect that can cause the CALL (et al) opcode's internal context to run out of gas, even if the transaction itself DOES have enough gas (i.e., gasLeft - gasUsed >= 0).
  4. Since istanbul, some opcodes, under certain circumstances, actually require more gas to run than they actually spend.
  5. The gasLimit of a transaction can cause the transaction's gasUsed as well as the required gas to vary.

@nicholasjpaterno, did I miss any other tricky cases?

Take a look at ganache-core's gas estimation algorithm for implementation details.

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

No branches or pull requests

1 participant