Merge pull request #3433 from patricklodder/1.14.7-discard-old-feefile

policy: only load fee_estimates.dat from 1.14.7 and later
This commit is contained in:
chromatic 2024-02-24 18:30:44 -08:00 committed by GitHub
commit a08d6f6635
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 1 deletions

View File

@ -890,7 +890,7 @@ CTxMemPool::WriteFeeEstimates(CAutoFile& fileout) const
{ {
try { try {
LOCK(cs); LOCK(cs);
fileout << 139900; // version required to read: 0.13.99 or later fileout << FEEFILE_MIN_BACKCOMPAT_VERSION;
fileout << CLIENT_VERSION; // version that wrote the file fileout << CLIENT_VERSION; // version that wrote the file
minerPolicyEstimator->Write(fileout); minerPolicyEstimator->Write(fileout);
} }
@ -909,6 +909,16 @@ CTxMemPool::ReadFeeEstimates(CAutoFile& filein)
filein >> nVersionRequired >> nVersionThatWrote; filein >> nVersionRequired >> nVersionThatWrote;
if (nVersionRequired > CLIENT_VERSION) if (nVersionRequired > CLIENT_VERSION)
return error("CTxMemPool::ReadFeeEstimates(): up-version (%d) fee estimate file", nVersionRequired); 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); LOCK(cs);
minerPolicyEstimator->Read(filein, nVersionThatWrote); minerPolicyEstimator->Read(filein, nVersionThatWrote);
} }

View File

@ -31,6 +31,19 @@
class CAutoFile; class CAutoFile;
class CBlockIndex; 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 = 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() inline double AllowFreeThreshold()
{ {
return COIN * 144 / 250; return COIN * 144 / 250;