Skip to content

Commit 4c719b3

Browse files
committed
Merge bitcoin#28157: test doc: tests acceptstalefeeestimates option is only supported on regtest chain
ee5a036 test: ensure acceptstalefeeestimates is supported only on regtest chain (ismaelsadeeq) 22d5d4b tx fees, policy: doc: update and delete unnecessary comment (ismaelsadeeq) Pull request description: This PR Follow up comments from [bitcoin#27622](bitcoin#27622) It test that the new `regtest-only` option `acceptstalefeeestimates` is not supported on [main, signet and test chains](https://github.com/bitcoin/bitcoin/pull/27622/files#r1235218268), removes an unnecessary [comment](https://github.com/bitcoin/bitcoin/pull/27622/files#r1235204323), and update fee estimator `MAXFILEAGE` [description comment](https://github.com/bitcoin/bitcoin/pull/27622/files#r1233887314). ACKs for top commit: jonatack: ACK ee5a036 glozow: utACK ee5a036 Tree-SHA512: 4755f25b08db62f37614ea768272b12580ee0d481fb7fa339379901a6132c66828777c6747d3fe67490ceace3a6ff248bf13bdf65720f6e5ba8642eb762acd3c
1 parent c7fcabb commit 4c719b3

3 files changed

Lines changed: 19 additions & 4 deletions

File tree

‎src/policy/fees.cpp‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,14 +561,12 @@ CBlockPolicyEstimator::CBlockPolicyEstimator(const fs::path& estimation_filepath
561561

562562
AutoFile est_file{fsbridge::fopen(m_estimation_filepath, "rb")};
563563

564-
// Whenever the fee estimation file is not present return early
565564
if (est_file.IsNull()) {
566565
LogPrintf("%s is not found. Continue anyway.\n", fs::PathToString(m_estimation_filepath));
567566
return;
568567
}
569568

570569
std::chrono::hours file_age = GetFeeEstimatorFileAge();
571-
// fee estimate file must not be too old to avoid wrong fee estimates.
572570
if (file_age > MAX_FILE_AGE && !read_stale_estimates) {
573571
LogPrintf("Fee estimation file %s too old (age=%lld > %lld hours) and will not be used to avoid serving stale estimates.\n", fs::PathToString(m_estimation_filepath), Ticks<std::chrono::hours>(file_age), Ticks<std::chrono::hours>(MAX_FILE_AGE));
574572
return;

‎src/policy/fees.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525
// How often to flush fee estimates to fee_estimates.dat.
2626
static constexpr std::chrono::hours FEE_FLUSH_INTERVAL{1};
2727

28-
/** fee_estimates.dat that are more than 60 hours (2.5 days) will not be read,
29-
* as the estimates in the file are stale.
28+
/** fee_estimates.dat that are more than 60 hours (2.5 days) old will not be read,
29+
* as fee estimates are based on historical data and may be inaccurate if
30+
* network activity has changed.
3031
*/
3132
static constexpr std::chrono::hours MAX_FILE_AGE{60};
3233

‎test/functional/feature_config_args.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import os
88
import pathlib
99
import re
10+
import shutil
1011
import sys
1112
import tempfile
1213
import time
@@ -367,6 +368,20 @@ def test_ignored_default_conf(self):
367368
f'is being used instead.') + r"[\s\S]*", env=env, match=ErrorMatch.FULL_REGEX)
368369
node.args = node_args
369370

371+
def test_acceptstalefeeestimates_arg_support(self):
372+
self.log.info("Test -acceptstalefeeestimates option support")
373+
conf_file = self.nodes[0].datadir_path / "dash.conf"
374+
existing_paths = set(self.nodes[0].datadir_path.iterdir())
375+
for chain, chain_name in {("main", ""), ("test", "testnet3"), ("devnet", "devnet")}:
376+
util.write_config(conf_file, n=0, chain=chain_name, extra_config='acceptstalefeeestimates=1\n')
377+
self.nodes[0].assert_start_raises_init_error(expected_msg=f'Error: acceptstalefeeestimates is not supported on {chain} chain.')
378+
util.write_config(conf_file, n=0, chain="regtest") # Reset to regtest
379+
# Remove the chain dirs created by the failed starts above, so node0 keeps a single
380+
# chain dir holding a debug.log, as combine_logs.py (run by Dash CI on every test) expects
381+
for path in set(self.nodes[0].datadir_path.iterdir()) - existing_paths:
382+
if path.is_dir():
383+
shutil.rmtree(path)
384+
370385
def run_test(self):
371386
self.test_log_buffer()
372387
self.test_args_log()
@@ -380,6 +395,7 @@ def run_test(self):
380395
self.test_invalid_command_line_options()
381396
self.test_ignored_conf()
382397
self.test_ignored_default_conf()
398+
self.test_acceptstalefeeestimates_arg_support()
383399

384400
# Remove the -datadir argument so it doesn't override the config file
385401
self.nodes[0].args = [arg for arg in self.nodes[0].args if not arg.startswith("-datadir")]

0 commit comments

Comments
 (0)