Add workaround for logic bug in 'canPayFee()'.#1310
Closed
oneeman wants to merge 1 commit intooneeman/merge-upstream-1.9.13from
Closed
Add workaround for logic bug in 'canPayFee()'.#1310oneeman wants to merge 1 commit intooneeman/merge-upstream-1.9.13from
oneeman wants to merge 1 commit intooneeman/merge-upstream-1.9.13from
Conversation
The correct behavior is to allow a transaction if it has enough funds to pay the fee. This was how it worked if the fee was paid in Celo. However, if the fee was in another currency, the check uses '>' rather than '>='. Changing that requires a hard fork, since it would allow transactions that are currently being rejected. Until such a hard fork, however, this '>' is causing eth_call and eth_estimateGas to fail when the fee currency isn't Celo (and the account has no funds), even though the gas price is zero. This commit fixes that by adding special handling to use '>=' if the state transition is part of eth_call or eth_estimateGas, while leaving the '>' as is otherwise (e.g. as part of mining or processing a block).
Contributor
Author
|
Closing this until we have a better idea of plans for the hard fork change. |
This file contains hidden or 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
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.
Description
This PR implements a non-hard-fork fix for the issue brought up in #1292. It does not modify the behavior during mining and block processing, but rather only for state transitions done as part of
eth_callandeth_estimateGas. Though the the error during gas estimation is not a regression from the 1.9.13 merge (it already happens with prior versions of celo-blockchain), I am opening this PR against the 1.9.13 merge branch because it includes some changes the code foreth_callandeth_estimateGas, and doing it this way will avoid gratuitous conflicts.Note that we should still do a hard fork to fix the behavior during mining and block processing.
The correct behavior is to allow a transaction if it has enough funds to pay the fee. This was how it worked if the fee was paid in Celo. However, if the fee was in another currency, the check currently uses '>' rather than '>='. Changing that requires a hard fork, since it would allow transactions that are currently being rejected. Until such a hard fork, however, this '>' is causing eth_call and eth_estimateGas to fail when the fee currency isn't Celo (and the account has no funds), even though the gas price is zero. This commit fixes that by adding special handling to use '>=' if the state transition is part of eth_call or eth_estimateGas, while leaving the '>' as is otherwise (e.g. as part of mining or processing a block).
Alternatives
I considered using the minimum gas price being 0 as the condition instead of adding a new field, since in actual transactions that are mined we have a non-zero minimum gas price. However, the approach taken in this commit seems safer and more explicit.
Tested
Trying to send a transaction with fees in cUSD without having any cUSD in the account.
Before the fix, gas estimation fails:
After the fix, gas estimation succeeds (since estimation uses gas price zero), and then sending the transaction fails, as it should, since for that the gas price isn't zero:
Backwards compatibility
This will make
eth_callandeth_estimateGassucceed in certain cases where they were currently failing.