- This PR implements the core component of #30392, introducing a new fee rate forecasting module.
The primary addition is a
ForecasterManagerthat coordinates multiple forecasting strategies to be able to provide better transaction fee rate predictions.
Key Changes
-
Refactoring of
CBlockPolicyEstimator#33218- Renames
feestoblock_policy_estimatorfor clarity. - Renames
fees_argstoblock_policy_estimator_argsfor clarity - Renames
policy_fee_teststofeerounder_testsalso for clarity.
- Renames
-
Addition of Fee Rate Forecasting Utility Structures
Forecasterabstract class, serving as the base class for all fee rate forecasters.ForecastResult(the response from aForecaster) with all metadata.ForecastTypeenum, identify and distinguish forecasters.
-
Introduce
FeeRateForecasterManagerclass- Adds the
FeeRateForecasterManagerclass, responsible for managing all fee rate forecasters, includingCBlockPolicyEstimator, which is now a forecaster. - Updates the node context to hold a unique pointer to
FeeRateForecasterManagerinstead ofCBlockPolicyEstimator. - Changes
CBlockPolicyEstimatorinstance fromunique_ptrto ashared_pointer, allowing it to be registered in the validation interface without requiring explicit unregistration during shutdown (current master behaviour). Registering forCBlockPolicyEstimatorflushes also get ashared_pointer. - Exposes a raw pointer of
CBlockPolicyEstimatorthroughFeeRateForecasterManagerfor compatibility withestimateSmartFee, friends, and node interfaces. - Modifies
CBlockPolicyEstimatorto inherit from theForecasterclass and implement the pure abstract classes
- Adds the
-
Introduce
MempoolForecasterclass- Adds the
MempoolForecaster, which forecast the fee rate required for a transaction to confirm as soon as possible. It generates a block template and returns the 75th and 50th percentile fee rates as low-priority and high-priority fee rate forecasts. - Implements caching for the last fee rate forecast, using a 30-second rate limit to avoid frequent block generation via the block assembler.
- Adds the
The FeeRateForecasterManager now includes a method ForecastFeeRateFromForecasters. This method polls forecasts from all registered forecasters and returns the lowest value. This behavior aligns with discussions and research outlined in this post. But the primary aim of the FeeRateForecasterManager is to be able to perform sanity checks and potentially apply heuristics to determine the most appropriate fee rate forecast from polled forecasters, for now it just return the lowest.
This PR also add unit tests for the classes.
In Draft because it depends on #33218