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

EstimateGas API sometimes returns wrong results, and propose some possible optimizations #390

Open
trinhdn2 opened this issue Oct 9, 2023 · 0 comments

Comments

@trinhdn2
Copy link

trinhdn2 commented Oct 9, 2023

  • Sometimes we always get the error {"jsonrpc":"2.0","error":"gas required exceeds allowance or always failing transaction"} when estimate gas from Remix IDE or RPC in general, although the transactions don't cause any execution error.
  • Currently if a transaction is reverting, EstimateGas will exhibit worst-case behavior and binary search up to the max gas limit (~40 state-clone + tx executions) which is very expensive and reducible.
  • We could consider is whether it's worth it to hone in on the exact gas usage needed, or if something "close enough" is enough. Currently by binary searching until hi == lo + 1, we're wasting a lot of executions to get the exact to-the-gas accuracy, which is unnecessary while most wallets will just add some random number on top to account for network conditions.
  • Most txs don't need much higher gas limit than their gas used, and most txs don't require near the full block limit of gas. So the selection of where to bisect the range is skewed to favour the low side.
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