feat: change priority in mempool to take into account age #4737
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
Changes the mempool to look at insertion time and not input maturity.
These changes reflect the new updated mempool rfc
Motivation and Context
The current code looks at the min input maturity, aka spending the oldest input, as an equalizer on the fee_per_gram when determining the transaction to pick for mining. This check is moot as even our default implementation of transaction sending uses 0 for all transactions except the coinbases which have their maturity checked on consensus rules. This means that most users will just keep that 0 as its not enforceable and, it will in most cases be 0, meaning this check is moot.
This update adds in a local time as the equalizer for the same fee_per_gram so that we still choose the oldest transactions to put in a block. Adding in this behavior gives preference to older transactions and is desireable for the network as it means most transactions will be mined at some point, and it won't lead to stale transactions sitting in a mempool.