This is a substantial improvement of fee estimation code built off #9942. Although in many cases the estimates will not appear to differ by much from previous estimates, they will handle some situations much better.
A longer writeup of the original algorithm and the changes in this PR can be found here: https://gist.github.com/morcos/d3637f015bc4e607e1fd10d8351e9f41
A summary of major changes:
- Estimates can now be given for up to a 1008 block target.
- Estimates are tracked on 3 different time horizons which allows for both the longer targets and lets the estimates adjust more quickly to changes in conditions.
- estimatefee is deprecated in favor of using only estimatesmartfee (already used by the GUI)
- estimateSmartFee now requires a 60% success rate at target/2, an 85% rate at target and a 95% rate at 2*target.
- estimates are by default conservative which requires the 95% rate for 2*target to be met at longer time horizons as well, but by choosing non-conservative estimates, the estimates are drastically reduced during periods of less transaction activity (such as the weekend).
- estimates are smarter about making sure enough data has been gathered in order to return a valid estimate (at least twice the number of blocks as the requested target much have been recorded)
- Fee rate buckets are half as big leading to a bit more precision.
- estimaterawfee is added so that customized logic can be implemented to analyze the raw data and calculate estimates.
- Transactions which leave the mempool due to eviction or other non-confirmed reasons now count as failures. These are also saved at shutdown.
A summary of open issues:
- Estimates are not backwards compatible. Currently when updating to this patch, any old fee estimates will be discarded and your node will have to be running for a while to provide new estimates. It is a possibility to add logic to return the old estimates for targets 2-25 until the new estimates have gathered enough data.
- estimatefee is probably a roughly similar calculation to what it used to be, but I’ve made no effort to make sure the quality of the estimates it gives have not degraded, so infrastructure which doesn’t support estimatesmartfee should update.
- The GUI needs to be updated to access the new range of estimates. I would suggest providing options for targets of: 2,4,6,12,24,48,144,504,1008