Skip to content

Commit

Permalink
mempool: ignore fee estimate files from older versions
Browse files Browse the repository at this point in the history
Do not load fee estimate files from before 1.14.7, because the
previous min, max and spacing parametrization will override the
newly introduced values from 35c2910
  • Loading branch information
patricklodder authored and chromatic committed Feb 25, 2024
1 parent 5bcfe69 commit e809a32
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/txmempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,16 @@ CTxMemPool::ReadFeeEstimates(CAutoFile& filein)
filein >> nVersionRequired >> nVersionThatWrote;
if (nVersionRequired > CLIENT_VERSION)
return error("CTxMemPool::ReadFeeEstimates(): up-version (%d) fee estimate file", nVersionRequired);

/* From 1.14.7, only accept fee estimate files created by a version equal to or higher than the
* minimum writer version.
*
* If in the future any of the MIN_FEERATE, MAX_FEERATE or FEE_SPACING in policy/fees.h change,
* or these values become configurable, this logic will need to be adapted. */
if (nVersionThatWrote < FEEFILE_MIN_COMPAT_VERSION_WRITER) {
return error("CTxMemPool::ReadFeeEstimates(): cannot re-use fee estimate files from version %d, ignoring file (non-fatal)", nVersionThatWrote);
}

LOCK(cs);
minerPolicyEstimator->Read(filein, nVersionThatWrote);
}
Expand Down
10 changes: 9 additions & 1 deletion src/txmempool.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@ class CBlockIndex;
/** Minimum client version required to read fee_estimates.dat
* Clients with a lower version than this should ignore the file
*/
static const int FEEFILE_MIN_BACKCOMPAT_VERSION = 139900; // 0.13.99.0
static const int FEEFILE_MIN_BACKCOMPAT_VERSION = 1140700; // 1.14.7.0

/** Minimum client version required to read fee_estimates.dat
* Files created with a lower version than this are ignored
*
* Due to bucket spacing and min/max changes in 1.14.7, set this
* to 1.14.7.0 exactly.
*/
static const int FEEFILE_MIN_COMPAT_VERSION_WRITER = 1140700; // 1.14.7.0

inline double AllowFreeThreshold()
{
Expand Down

0 comments on commit e809a32

Please sign in to comment.