-
Notifications
You must be signed in to change notification settings - Fork 86
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
Optimize EstimateGas API #391
Closed
trinhdn2
wants to merge
107
commits into
BuildOnViction:upgrade-core-develop
from
trinhdn2:optimize/estimate_gas
Closed
Optimize EstimateGas API #391
trinhdn2
wants to merge
107
commits into
BuildOnViction:upgrade-core-develop
from
trinhdn2:optimize/estimate_gas
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ft/dynamic state snapshot
…th_call' into develop
Show the detailed revert errors when estimate gas or fail to execute transactions
…th_call' into devnet
1 task
Superseded by #409 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolve issue #390
EstimateGas
repeatedly executes a transaction, performing a binary search with multiple gas prices to determine proper pricing. Each call retrieves a new copy of the state https://github.com/tomochain/tomochain/blob/76420ee3ba79120351018b86c1a84c4001ad9064/internal/ethapi/api.go#L1136Because the pending/latest state can be changed during the execution of
EstimateGas
, this can potentially cause strange behaviors.EstimateGas
currently conducts a binary search to determine a suitable gas limit for a tx, and continues searching with a higher gas limit whenever the transaction's execution results in revert. While this makes sense if the reason for revert is out of gas, increasing the gas limit is highly unlikely to allow a non-OOG reverting transaction to succeed (unless it is making unusual use of the GAS opcode).This PR modifies EstimateGas to retrieve the state once and use a copy of it for every call invocation it does. This has two benefits: