-
Notifications
You must be signed in to change notification settings - Fork 677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: update miner mempool iterator query to consider both nonces and fee rates #5541
base: develop
Are you sure you want to change the base?
Conversation
|
1 similar comment
|
CASE | ||
WHEN fee_rate IS NULL THEN (ABS(RANDOM()) % 10000 / 10000.0) * (SELECT MAX(fee_rate) FROM mempool) | ||
ELSE fee_rate | ||
END AS sort_fee_rate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@obycode I added a simulated fee rate (for sorting only) when it's NULL. It successfully mixes in null txs with estimated txs in a randomized order. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a great idea! I like it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also take into account the settings.consider_no_estimate_tx_prob
here? I'm not sure how important it is to keep that config parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we don't need it anymore, however, if necessary I could use it as a probability to skip a null transaction altogether. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think probably this random mix in is good on its own and we can deprecate that option.
Problem
The current query used by Stacks miners to iterate over pending mempool transactions sorts them only by
fee_rate
in descending order. This approach creates the following problems:Solution
This PR changes the transaction selection query to a new one that prioritizes those that can be confirmed as fast as possible (lowest valid nonces) with the highest fees as possible. This means that even if it doesn't select the transactions with the highest global fees first, it will select those that can be mined faster therefore optimizing block building time and allowing the miner to fit in more transactions in total within the allotted time.
The new query also mixes in transactions with null fee rates in results by simulating a fee rate for the purposes of ordering only.