- This PR implements the core component of #30392, introducing a new fee rate forecasting module.
The primary addition is a
ForecasterManager
that coordinates multiple forecasting strategies to be able to provide better transaction fee rate predictions.
Key Changes
-
Addition of Fee Rate Forecasting Utility Structures
Forecaster
abstract class, serving as the base class for all fee rate forecasters.ForecastResult
(the response from aForecaster
) with all metadata.ConfirmationTarget
, which represents the input fee rate forecasters receive. Currently, forecasters provide block-based fee rate forecasts, but this structure allows for potential time-based inputs, offering more flexibility.ForecastType
enum, identify and distinguish forecasters.
-
Refactoring of
CBlockPolicyEstimator
- Renames
fees
toblock_policy_estimator
for clarity. - Renames
fees_args
toblock_policy_estimator_args
for clarity - Renames
policy_fee_tests
tofeerounder_tests
also for clarity. - Modifies
CBlockPolicyEstimator
to inherit from theForecaster
class and implement theEstimateFee
method.
- Renames
-
Introduce
FeeRateForecasterManager
class- Adds the
FeeRateForecasterManager
class, responsible for managing all fee rate forecasters, includingCBlockPolicyEstimator
, which is now a forecaster. - Updates the node context to hold a unique pointer to
FeeRateForecasterManager
instead ofCBlockPolicyEstimator
. - Changes
CBlockPolicyEstimator
instance fromunique_ptr
to ashared_pointer
, allowing it to be registered in the validation interface without requiring explicit unregistration during shutdown (current master behaviour). Registering forCBlockPolicyEstimator
flushes also get ashared_pointer
. - Exposes a raw pointer of
CBlockPolicyEstimator
throughFeeRateForecasterManager
for compatibility withestimateSmartFee
, friends, and node interfaces.
- Adds the
-
Introduce
MempoolForecaster
class- 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 GetFeeRateForecast
. 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.