-
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
|
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.
Thanks for taking this on @rafaelcr!
This is something that I think is going to need somewhat extensive real-world testing before we make it the default behavior. Do you think you could add this new mempool walk logic as an opt-in alternative, which the node operator can opt to use? This would give miners a chance to compare/contrast the new behavior with the old behavior in an easy-to-rollback manner. A subsequent PR could make the new behavior the default.
What do you think?
Great idea @jcnelson and thanks for the feedback! I'll get on it. |
From the call:
|
@jcnelson @rafaelcr I have a PR that adds Nakamoto support to cargo build --release --bin=stacks-inspect And using hyperfine -w 3 -r 20 "command 1" "command 2" |
@obycode @jcnelson I just updated the code to
Can you take another look? Local tests look very good, including the query plan which uses only indexes Also looking forward to trying this out with @jbencin 's tools once you think it's in good shape |
632a20f
to
5038c4d
Compare
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 adds a new mempool walk strategy (
NextNonceWithHighestFeeRate
) which prioritizes transactions that can be confirmed as fast as possible (next expected nonces for both origin and sponsor) with the highest fee rates 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 immediately therefore optimizing block building time and allowing the miner to fit in more transactions in total within the allotted time. This strategy also mixes in transactions with null fee rates in results by simulating a fee rate for the purposes of ordering only.For easier testing, a mempool walk strategy enum value was added to the
MinerConfig
, which includes:GlobalFeeRate
: Current global fee rate sorting behavior. Enabled by default.NextNonceWithHighestFeeRate
: The new strategy added by this PR