add special state transition to allow for gas estimation #825
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.
Description
Currently gas estimation does not work for accounts with low balance, as is the case for new accounts invited to Celo with an invite code. The issue is that the binary search used for gas estimation makes an assumption that if there is an error, raising the gas limit on the transaction will fix it, or that the transaction will always fails. This assumption is broken when the gas price is non-zero and the account does not have a high enough balance to pay fees for a transaction with maximum gas. In that case there is only a window of gas values that will work, which cannot be found via binary search.
It would be easy to set the gas price to zero and run the transaction, which solves the issue mentioned above, but the gas price minimum functionality prevents the transaction from running.
Alternative solutions
Tested
Synced a node against integration and observed that gas estimation for a sample transaction failed before the changes and succeeds after. Also ran all e2e tests, which implicitly use gas estimation.
Related issues
Backwards compatibility
Changes are backwards compatible.