-
Notifications
You must be signed in to change notification settings - Fork 38.6k
New fee estimation code #5159
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
New fee estimation code #5159
Conversation
|
Ooh, that sounds like a pretty slick improvement! |
|
@gavinandresen can you have a look here? |
|
@laanwj : yes, I'll review, but that might not happen until next week (I'm headed to Dublin tomorrow). |
|
Thanks. I really like the new GUI in #5200. I think we should also change |
|
Code review mostly ACK, apart from a couple of nits. I'll try to get a node up and running, generating estimates over time, to see how this behaves compared to the existing estimation code. |
|
OK, I moved the dependency checking logic to main.cpp. It was a pretty clean change I think, and is more efficient because it saves us looping through all the inputs again. If that code ever gets moved out of main, I think it makes sense for those two checks on inputs to stay together. However if you don't like that, I can revert back to putting the logic inside |
|
Node running this code and generating graphs at: http://core2.bitcoincore.org/smartfee/ (current HEAD code is running at http://bitcoincore.org/smartfee/ ) |
|
@gavinandresen How come the fee for 3 confirmation txs has stayed constant over the entire period. That can't be right, can it? |
|
@rebroad The reason that happens is there aren't enough data points for transactions with lower fee rates. As people start placing transactions with lower fees, there will be more data points in the lower fee rate ranges and the estimate will get lower. I believe it makes sense for all of the 3+ confirmation estimates to be the same, because basically any fee will be confirmed within 3 confirms right now, so its just a matter of how low an estimate can you accurately give. |
|
This doesn't seem to work well with #5200 currently. Even after leaving the node running for a while, the fee estimation doesn't kick in for anything other than 2 confirms. So sliding the slider to 20 gives the same fee as sliding it to 2, and then sliding it to 1 makes it say it needs longer to calculate (which then never happens). |
|
I'm curious what fee its returning for you and how long it's been running. You can see by Gavin's charts linked above what the estimates are over time. But I do agree that if/when this is going to be merged, the GUI could be slightly modified to better handle the case where 1 doesn't give an estimate. It's not always a matter of not having enough data, but sometimes there really is no answer to the question, because there is no fee that is high enough that you'll reliably (> 85%) get confirmed within 1 block. In any case, I was operating under the assumption that this wasn't making it in for 0.10, so I was planning on waiting for that and then rebasing. I also have a couple small improvements to make. |
4f8aed0 to
56cc084
Compare
|
OK I rebased off 0.10 (so the first 3 commits should still be what you reviewed Gavin). But then the 4th commit is new. It's addressing your comments above in a better way than I had previously done. |
|
@gavinandresen, I've rebased this and added a couple of improvements, most notably, doing some tracking of transactions that are in the mempool and haven't been mined yet. So in particular the are code changes from what you reviewed before. |
|
My compiler is unhappy. Unhappiness: ... and: |
|
Since the format of fee_estimates.dat will change, CTxMemPool::WriteFeeEstimates should change: |
|
ah sorry, pushed too fast, i'd noticed that compilation problem, not sure why it was a problem, but i think i just pushed a fix... will wait for more comments before adding more fixes. |
|
Been running this at home for a couple of days, estimates look reasonable. I've updated the bitcoind on core2.bitcoincore.org; as soon as it catches up with the chain it will start generating new fee/priority estimate charts again. |
|
Any thoughts on whether this is something we'd like to merge? I'd like to get it in early enough in the 0.11 release cycle that it gets some usage. I realize its a lot of complicated code, but it really only affects fee and priority estimates. I think the increased accuracy of the estimates makes it worthwhile. Compare (core2.) and bitcoincore.org/smartfee/fee_graph.html. |
|
I'd like to see this in the 0.11 release. |
|
Could you rename src/policyestimator.o to src/policy/estimator.o ? It will obviously have to change after this PR, but maybe you can get some ideas from there as well, and hopefully make the "rebase/rewrite" of that encapsulation easier. If you manage to incorporate the essence of that commit in your PR, I would love you for it, but that's probably too much to ask at this point. |
|
I'd be happy to give it shot. I'll ping you when I get around to it. |
|
Rebased, cleaned up and squashed original commits. Added 3 new commits. |
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.
The transaction being added to the mempool has actually been copied twice at this point. The first time when the CTxMemPoolEntry was created, and now again when its copied into the map, which will be its permanent home. This was not introduced by this PR, but a further PR should consider eliminating one of the copy operations.
|
Thanks for incorporating some of my suggestions, I'm specially happy about not using the minRelayTxFee global inside the estimator which was the most important nit. I agree all the suggestions not incorporated can wait and it's better not to slow this down. |
src/txmempool.cpp
Outdated
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.
The comment above is no longer relevant here.
|
Addressed nits (above and offline) by @sdaftuar and improved the readability of the rpc test. |
src/policy/fees.cpp
Outdated
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.
nit: succeess -> success
|
I've reviewed the code (particularly to understand the details of the calculations in policy/fees.cpp), and I've tested by running a node with this code, and this looks good to me (and improves the estimates substantially). ACK. |
|
I'm going to make a summary of my review of this PR, hopefully it helps getting it merged soon. In summary, still-untested-but-pretty-confident-ACK. |
|
I didn't try to check or understand that code, but wanted to ask if the GUI (e.g. coincontrol and smart fees) is working with this without problems or if that needs to be verified. |
|
@Diapolo Thanks for thinking about that. I think it could certainly use some more testing. There are two things in my mind that could use improving.
|
A suggestion: if fractional arguments are allowed for With fractional |
With regard to fee buckets clearing the This means that if a transaction has been in the mempool for less than 60 seconds, there is a chance it won't be considered for block inclusion at all by the miner, regardless of the tx fee. After removing these transactions from the estimation, I've found that the relative frequency of high-fee transactions being included in the next block is pretty high and consistent, typically > 95%. |
|
@bitcoinfees, thanks for the comments. I think asking for the mean number of blocks to confirmation is a slightly different question than I answered. It's not clear if one question is better than another, but the way I defined the question is what fee would you need to have a sufficiently high percentage chance of getting confirmed in the desired number of blocks, so it kind of requires a MIN_SUCCESS_PCT. But to your point, I do think that there could be a lot of improvements to this estimation algorithm, and hopefully they could build off the framework it provides. I agree with your conclusion on why the success percentage has a ceiling around 90%. Hopefully with an improved transaction selection algorithm for mining in the future that will get better. |
|
Code review and lightly tested ACK. I'm updating core2.bitcoincore.org to run this version of the code now. |
|
squashed to hopefully make it mergeable |
src/policy/fees.cpp
Outdated
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.
nit: just MIT
This class groups transactions that have been confirmed in blocks into buckets, based on either their fee or their priority. Then for each bucket, the class calculates what percentage of the transactions were confirmed within various numbers of blocks. It does this by keeping an exponentially decaying moving history for each bucket and confirm block count of the percentage of transactions in that bucket that were confirmed within that number of blocks. -Eliminate txs which didn't have all inputs available at entry from fee/pri calcs -Add dynamic breakpoints and tracking of confirmation delays in mempool transactions -Remove old CMinerPolicyEstimator and CBlockAverage code -New smartfees.py -Pass a flag to the estimation code, using IsInitialBlockDownload as a proxy for when we are still catching up and we shouldn't be counting how many blocks it takes for transactions to be included. -Add a policyestimator unit test
|
nits addressed |
|
utACK |
b649e03 Create new BlockPolicyEstimator for fee estimates (Alex Morcos)
4038de4 [QA] Restore 'feature_fee_estimation.py' functional test (random-zebra) 988f349 [qt] Properly display required fee instead of minTxFee (random-zebra) c5c9df0 [Trivial] Fix typos (random-zebra) a8fa99b [Trivial] Remove redundat check in ContainsZerocoins (random-zebra) 8ebcbcd PolicyEstimator: exclude zerocoin spends when computing estimates (random-zebra) b67049b Create new BlockPolicyEstimator for fee estimates (random-zebra) Pull request description: This introduces the new fee and priority estimation code described here <https://www.mail-archive.com/[email protected]/msg06405.html>. Instead of calculating the median fee for each possible number of blocks needed to confirm, the new code divides the possible fee rates into buckets (spaced logarithmically) and keeps track of the number of blocks needed to confirm for each transaction in each bucket. Backports: - bitcoin#5159 - bitcoin#6887 except for the functional test (`smartfees.py`) which is based on an older version of the framework. Instead I've restored a more recent `feature_fee_estimation.py` (commenting out the check for `estimatesmartfee` which can be reintroduced once bitcoin#6134 is backported). Additional commits exclude zerocoins txes from the estimates calculation, as they have fixed fee/priority. ACKs for top commit: Fuzzbawls: ACK 4038de4 furszy: ACK 4038de4 and merging Tree-SHA512: 25777af469f7fa84d2dab991544392bea8418bccb4d2c23113de2c6ed7047891bdaedad1728cb04ba343e82f4bc0c1446f88e28def698dd25168769abf8620bb
I reworked the fee and priority estimation code to gather statistics by binning transactions of various fee rates and tracking how many blocks they took to get confirmed. See post to mailing list.