Don't check GPM before mining tx (instead, handle error from state transition if it happens) #1500
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 is an optimization for block generation. Previously, for each transaction we want to add, we check that its gas price meets the gas price minimum before applying the transaction. However, this is unnecessary, because applying the transaction includes a GPM check as well (inside the state transition). This PR removes the redundant check and instead handles the error that is returned by the state transition if the transaction's gas price is below the GPM. If the error appears, it breaks out of the loop (which is the same as what we were previously doing if the gas price was below the GPM).
Other Changes
Tested
core.ErrGasPriceDoesNotExceedMinimum
actually being returned. This will not normally happened, because the transaction pool does not admit transactions below the GPM, and if the GPM increases it removes transactions that don't meet the GPM. As such, this code path (and also the original code path breaking out of the loop due to GPM) are unlikely to ever occur (they would only happen if the gas price minimum increases beyond some pending transaction's gas price and the miner gets the list of transactions before the transaction pool has had time to remove the transaction).Backwards compatibility
No incompatibilities. This would result in the same transactions being included in the proposed block as before.