Skip GPM and other checks for transactions whose gas limit exceeds what's left it the block #1490
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 an optimization to remove a large inefficiency in block creation. The worker goes through, trying to add the transactions in order of decreasing gas price, until it . If it encounters a transaction that requires more gas than is left in the block, it would try to process it and give an error
core.ErrGasLimitReached
which is then handled by skipping the transaction and continuing trying others (since there may be other transactions later on which require less gas and could fit). The problem was that before this error is returned it does a bunch of work, including core contract calls. This meant that going through transactions which aren't included was taking a long time when the transaction pool had 1000 or more pending transactions.With this PR, we first check whether the block has enough gas left for the transaction, and if not then we skip right away rather than skipping after getting
core.ErrGasLimitReached
. Only transactions which would have been skipped anyway are skipped.This optimization, combined with #1489 and #1467, means the size of the transaction pool will no longer be a bottleneck.
Tested
Backwards compatibility
No backwards compatibility issues.