Commit Graph

7663 Commits

Author SHA1 Message Date
merge-script
39ca015259 Merge bitcoin/bitcoin#33140: test: Avoid shutdown race in NetworkThread
fa6db79302 test: Avoid shutdown race in NetworkThread (MarcoFalke)

Pull request description:

  Locally, I am seeing rare intermittent exceptions in the network thread:

  ```
  stderr:
  Exception in thread NetworkThread:
  Traceback (most recent call last):
  File "/python3.10/threading.py", line 1016, in _bootstrap_inner
  self.run()
  File "./test/functional/test_framework/p2p.py", line 744, in run
  self.network_event_loop.run_forever()
  File "/python3.10/asyncio/base_events.py", line 603, in run_forever
  self._run_once()
  File "/python3.10/asyncio/base_events.py", line 1871, in _run_once
  event_list = self._selector.select(timeout)
  AttributeError: 'NoneType' object has no attribute 'select'
  ```

  I can reproduce this intermittently via `while ./bld-cmake/test/functional/test_runner.py $(for i in {1..400}; do echo -n "tool_rpcauth "; done)  -j 400 ; do true ; done`.

  I suspect this is a race where the shutdown starts the close of the network thread while it is starting.

  A different exception showing this race can be reproduced via:

  ```diff
  diff --git a/test/functional/test_framework/p2p.py b/test/functional/test_framework/p2p.py
  index 610aa4ccca..64561e157c 100755
  --- a/test/functional/test_framework/p2p.py
  +++ b/test/functional/test_framework/p2p.py
  @@ -741,6 +741,7 @@ class NetworkThread(threading.Thread):

       def run(self):
           """Start the network thread."""
  +        import time;time.sleep(.1)
           self.network_event_loop.run_forever()

       def close(self, *, timeout=10):
  ```

  It is trivial to reproduce via any test (e.g. `./bld-cmake/test/functional/tool_rpcauth.py`) and shows a similar traceback to the one above:

  ```
  Exception in thread NetworkThread:
  Traceback (most recent call last):
    File "/python3.10/threading.py", line 1016, in _bootstrap_inner
      self.run()
    File "./test/functional/test_framework/p2p.py", line 745, in run
      self.network_event_loop.run_forever()
    File "/python3.10/asyncio/base_events.py", line 591, in run_forever
      self._check_closed()
    File "/python3.10/asyncio/base_events.py", line 515, in _check_closed
      raise RuntimeError('Event loop is closed')
  RuntimeError: Event loop is closed
  ```

  So fix the second runtime error in hope of fixing the first one as well.

ACKs for top commit:
  brunoerg:
    code review ACK fa6db79302

Tree-SHA512: ca352ebf7929456ea2bbfcfe4f726adcbfcfb3dc0edeaddae7f6926f998888f0bd8b987ddef60308266eeab6bffa7ebdc32f5908db9de5404df95635dae4a8f6
2025-12-03 10:42:30 +00:00
merge-script
bcf794d5f3 Merge bitcoin/bitcoin#30455: test: assumeutxo: add missing tests in wallet_assumeutxo.py
cb7d5bfe4a test, assumeutxo: loading a wallet (backup) on a pruned node (Alfonso Roman Zubeldia)
7a365244f8 test, refactor snapshot import and background validation (Alfonso Roman Zubeldia)

Pull request description:

  Adding tests in `./test/functional/wallet_assumeutxo.py` to cover the following scenario:
  - test loading a wallet (backup) on a pruned node

ACKs for top commit:
  fjahr:
    re-ACK cb7d5bfe4a
  theStack:
    re-ACK cb7d5bfe4a

Tree-SHA512: 88cc419f340d31e80120e0c6cafe567efc678df27576db6e08aeab62d2b50ed1153d56f3f3343e9bae49262e38f9fb81db7769f02a4a01e4ef25c5d029c12323
2025-12-03 10:09:40 +00:00
merge-script
af0e6a65c9 Merge bitcoin/bitcoin#33702: contrib: Remove brittle, confusing and redundant UTF8 encoding from Python IO
fad6118586 test: Fix "typo" in written invalid content (MarcoFalke)
fab085c15f contrib: Use text=True in subprocess over manual encoding handling (MarcoFalke)
fa71c15f86 scripted-diff: Bump copyright headers after encoding changes (MarcoFalke)
fae612424b contrib: Remove confusing and redundant encoding from IO (MarcoFalke)
fa7d72bd1b lint: Drop check to enforce encoding to be specified in Python scripts (MarcoFalke)
faf39d8539 test: Clarify that Python UTF-8 mode is the default today for most systems (MarcoFalke)
fa83e3a81d lint: Do not allow locale dependent shell scripts (MarcoFalke)

Pull request description:

  Historically, there was an attempt via `test/lint/lint-python-utf8-encoding.py` to enforce explicit UTF8 in every Python IO statement (`open`, `subprocess`, ...). However, the lint check has many problems:

  * The check is incomplete and many IO statements lack the explicit UTF8 specification.
  * It was added at a time when some systems were not UTF8 by default.
  * The check is brittle, as it depends on a fragile regex.

  In theory, now that the minimum Python version is 3.10 (since commit 2123c94448), the check could be replaced by `PYTHONWARNDEFAULTENCODING=1` from https://docs.python.org/3/whatsnew/3.10.html#optional-encodingwarning-and-encoding-locale-option. However, this comes with many other problems:

  * All our Python scripts already assume and require UTF8 to be set externally. On almost all modern systems, this is already the default. Some Windows versions do not have UTF8 by default and require `PYTHONUTF8=1` to be set for the tests to run already today (with or without the changes in this pull). Also, the CI and many other Bash scripts force UTF8 via `LC_ALL`. Finally, Python 3.15 will likely enable UTF8 on *all* systems by default, per https://peps.python.org/pep-0686/#abstract.
  * So adding UTF8 to every single IO call is redundant, verbose, and confusing, given that it is the expected default.

  So fix all issues, by:

  * Removing the `test/lint/lint-python-utf8-encoding.py` check.
  * Removing the encoding on the individual IO calls.
  * Clarifying the existing docs around the existing UTF8 requirement and assumption.

  Obviously, every IO call is still free to specify UTF8 or any other encoding explicitly, if there is a documented need for it in the future.

ACKs for top commit:
  theStack:
    re-ACK fad6118586
  laanwj:
    Re-ACK fad6118586

Tree-SHA512: 78025ea3508597d2299490347614f0ee3e4c66e3ba559ff50e498045a9c8bbd92f3a5ced18719d8fcebbd1e47bdbb56a0c85a5b73b425adb0ea4f02fe69c3149
2025-12-03 09:54:47 +00:00
merge-script
ce771726f3 Merge bitcoin/bitcoin#33960: log: Use more severe log level (warn/err) where appropriate
fa45a1503e log: Use LogWarning for non-critical logs (MarcoFalke)
fa0018d011 log: Use LogError for fatal errors (MarcoFalke)
22229de728 doc: Fix typo in init log (MarcoFalke)

Pull request description:

  Logging supports severity levels above info via the legacy `LogPrintf`. So use the more appropriate `LogError` or `LogWarning`, where it applies.

  This has a few small benefits:

  * It often allows to remove the manual and literal "error: ", "Warning:", ... prefixes. Instead the uniform log level formatting is used.
  * It is easier to grep or glance for more severe logs, which indicate some kind of alert.
  * `LogPrintf` didn't indicate any severity level, but it is an alias for `LogInfo`. So having the log level explicitly spelled out makes it easier to read the code.
  * Also, remove the redundant trailing `\n` newline, while touching.
  * Also, remove the `__func__` formatting in the log string, which is redundant with `-logsourcelocations`. Instead, use a unique log string for each location.

ACKs for top commit:
  l0rinc:
    Code review ACK fa45a1503e
  stickies-v:
    ACK fa45a1503e
  rkrux:
    crACK fa45a1503e

Tree-SHA512: 516d439c36716f969c6e82d00bcda03c92c8765a9e41593b90052c86f8fa3a3dacbb2c3dc98bfc862cefa54cae34842b488671a20dd86cf1d15fb94aa5563406
2025-12-02 13:35:16 +00:00
Alfonso Roman Zubeldia
cb7d5bfe4a test, assumeutxo: loading a wallet (backup) on a pruned node 2025-12-02 09:43:06 -03:00
Alfonso Roman Zubeldia
7a365244f8 test, refactor snapshot import and background validation
Move snapshot import validation and background validation logic
into dedicated helper functions.
2025-12-02 09:27:32 -03:00
merge-script
e0ba6bbed9 Merge bitcoin/bitcoin#33591: Cluster mempool followups
b8d279a81c doc: add comment to explain correctness of GatherClusters() (Suhas Daftuar)
aba7500a30 Fix parameter name in getmempoolcluster rpc (Suhas Daftuar)
6c1325a091 Rename weight -> clusterweight in RPC output, and add doc explaining mempool terminology (Suhas Daftuar)
bc2eb931da Require mempool lock to be held when invoking TRUC checks (Suhas Daftuar)
957ae23241 Improve comments for getTransactionAncestry to reference cluster counts instead of descendants (Suhas Daftuar)
d97d6199ce Fix comment to reference cluster limits, not chain limits (Suhas Daftuar)
a1b341ef98 Sanity check feerate diagram in CTxMemPool::check() (Suhas Daftuar)
23d6f457c4 rpc: improve getmempoolcluster output (Suhas Daftuar)
d2dcd37aac Avoid using mapTx.modify() to update modified fees (Suhas Daftuar)
d84ffc24d2 doc: add release notes snippet for cluster mempool (Suhas Daftuar)
b0417ba944 doc: Add design notes for cluster mempool and explain new mempool limits (Suhas Daftuar)
2d88966e43 miner: replace "package" with "chunk" (Suhas Daftuar)
6f3e8eb300 Add a GetFeePerVSize() accessor to CFeeRate, and use it in the BlockAssembler (Suhas Daftuar)
b5f245f6f2 Remove unused DEFAULT_ANCESTOR_SIZE_LIMIT_KVB and DEFAULT_DESCENDANT_SIZE_LIMIT_KVB (Suhas Daftuar)
1dac54d506 Use cluster size limit instead of ancestor size limit in txpackage unit test (Suhas Daftuar)
04f65488ca Use cluster size limit instead of ancestor/descendant size limits when sanity checking TRUC policy limits (Suhas Daftuar)
634291a7dc Use cluster limits instead of ancestor/descendant limits when sanity checking package policy limits (Suhas Daftuar)
fc18ef1f3f Remove ancestor and descendant vsize limits from MemPoolLimits (Suhas Daftuar)
ed8e819121 Warn user if using -limitancestorsize/-limitdescendantsize that the options have no effect (Suhas Daftuar)
80d8df2d47 Invoke removeUnchecked() directly in removeForBlock() (Suhas Daftuar)
9292570f4c Rewrite GetChildren without sets (Suhas Daftuar)
3e39ea8c30 Rewrite removeForReorg to avoid using sets (Suhas Daftuar)
a3c31dfd71 scripted-diff: rename AddToMempool -> TryAddToMempool (Suhas Daftuar)
a5a7905d83 Simplify removeRecursive (Suhas Daftuar)
01d8520038 Remove unused argument to RemoveStaged (Suhas Daftuar)
bc64013e6f Remove unused variable (cacheMap) in mempool (Suhas Daftuar)

Pull request description:

  As suggested in the main cluster mempool PR (https://github.com/bitcoin/bitcoin/pull/28676#pullrequestreview-3177119367), I've pulled out some of the non-essential optimizations and cleanups into this separate PR.

  Will continue to add more commits here to address non-blocking suggestions/improvements as they come up.

ACKs for top commit:
  instagibbs:
    ACK b8d279a81c
  sipa:
    ACK b8d279a81c

Tree-SHA512: 1a05e99eaf8db2e274a1801307fed5d82f8f917e75ccb9ab0e1b0eb2f9672b13c79d691d78ea7cd96900d0e7d5031a3dd582ebcccc9b1d66eb7455b1d3642235
2025-12-02 09:46:00 +00:00
Suhas Daftuar
6c1325a091 Rename weight -> clusterweight in RPC output, and add doc explaining mempool terminology
Co-authored-by: glozow <gloriajzhao@gmail.com>
2025-12-01 10:53:22 -05:00
Suhas Daftuar
23d6f457c4 rpc: improve getmempoolcluster output 2025-12-01 10:53:19 -05:00
Suhas Daftuar
3e39ea8c30 Rewrite removeForReorg to avoid using sets
Also improve test coverage for removeForReorg by creating a scenario where
there are in-mempool descendants that are only invalidated due to an in-mempool
parent no longer spending a mature coin.
2025-11-30 11:01:57 -05:00
MarcoFalke
fa45a1503e log: Use LogWarning for non-critical logs
As per doc/developer-notes#logging, LogWarning should be used for severe
problems that do not warrant shutting down the node
2025-11-27 14:33:59 +01:00
Sebastian Falbesoner
52230a7f69 test: check for output to stdout in TestShell test 2025-11-26 16:51:12 +01:00
MarcoFalke
fad6118586 test: Fix "typo" in written invalid content
The appended content is irrelevant, but fix the "typo" to avoid
spellchecker warnings.
2025-11-26 11:31:30 +01:00
MarcoFalke
fab085c15f contrib: Use text=True in subprocess over manual encoding handling
All touched Python scripts already assume and require UTF8, so manually
specifying encoding or decoding for functions in the subprocess module
is redundant to just using text=True, which exists since Python 3.7
2025-11-26 11:31:29 +01:00
MarcoFalke
fa71c15f86 scripted-diff: Bump copyright headers after encoding changes
Historically, the headers have been bumped some time after a file has
been touched. Do it now to avoid having to touch them again in the
future for that reason.

-BEGIN VERIFY SCRIPT-
 sed -i --regexp-extended 's;( 20[0-2][0-9])(-20[0-2][0-9])? The Bitcoin Core developers;\1-present The Bitcoin Core developers;g' $( git show --pretty="" --name-only HEAD~0 )
-END VERIFY SCRIPT-
2025-11-26 11:31:25 +01:00
MarcoFalke
fae612424b contrib: Remove confusing and redundant encoding from IO
The encoding arg is confusing, because it is not applied consistently
for all IO.

Also, it is useless, as the majority of files are ASCII encoded, which
are fine to encode and decode with any mode.

Moreover, UTF-8 is already required for most scripts to work properly,
so setting the encoding twice is redundant.

So remove the encoding from most IO. It would be fine to remove from all
IO, however I kept it for two files:

* contrib/asmap/asmap-tool.py: This specifically looks for utf-8
  encoding errors, so it makes sense to sepecify the utf-8 encoding
  explicitly.
* test/functional/test_framework/test_node.py: Reading the debug log in
  text mode specifically counts the utf-8 characters (not bytes), so it
  makes sense to specify the utf-8 encoding explicitly.
2025-11-26 11:31:16 +01:00
MarcoFalke
fa7d72bd1b lint: Drop check to enforce encoding to be specified in Python scripts
The check was incomplete and brittle. A better check would be to enable
`PYTHONWARNDEFAULTENCODING=1`
https://docs.python.org/3/whatsnew/3.10.html#optional-encodingwarning-and-encoding-locale-option

However, it is unclear what the goal of adding explicit encodings
everywhere is, given that:

* Most modern systems already have UTF-8 enabled by default, except for
  Windows.
* Python 3.15 will likely enable it globally by default, according to
  https://peps.python.org/pep-0686/#abstract
* Adding the explicit encodings will bloat all code for no benefit.

So remove the lint check and drop all redundant encoding= kwargs.

All encoding= that are set for a reason, are kept.
2025-11-26 11:31:05 +01:00
MarcoFalke
faf39d8539 test: Clarify that Python UTF-8 mode is the default today for most systems
It will likely be the default for all systems, starting with Python
3.15, according to https://peps.python.org/pep-0686/#abstract.

It is hard to find a system other than Windows that has it not enabled
today. Nonetheless, Bitcoin Core requires UTF-8 in scripts and normally
enforces it via LC_ALL=C.UTF-8 or PYTHONUTF8=1.
2025-11-26 11:31:01 +01:00
MarcoFalke
fa83e3a81d lint: Do not allow locale dependent shell scripts
Bash is discouraged, and there was never a need to write locale
dependent Bash.

So remove the option and clarify that the LC_ALL settings enable UTF-8
mode in Python.
2025-11-26 11:31:00 +01:00
yuvicc
70d9e8f0a1 fix: reorg behaviour in mempool tests to match real one 2025-11-26 13:44:18 +05:30
yuvicc
540ed333f6 Move the create_empty_fork method to the test framework's blocktools.py module to enable reuse across multiple tests. 2025-11-26 13:44:17 +05:30
merge-script
7e129b644e Merge bitcoin/bitcoin#33893: test: add -alertnotify test for large work invalid chain warning
8343a9ffcc test: add `-alertnotify` test for large work invalid chain warning (Sebastian Falbesoner)

Pull request description:

  This PR adds missing test coverage for the `LARGE_WORK_INVALID_CHAIN` fork warning, checked with the `-alertnotify` option:
  ead849c9f1/src/validation.cpp (L2033-L2040)
  Found that this is missing during review of #32587. The test works by first creating a bunch of invalid blocks, that are first announced by headers and then submitted fully in reverse (invalid tip first), in order to set `m_best_invalid` to that value, finally leading to the best chain / invalid chain gap of >= 6 blocks. I'd be curious if there are other (more realistic?) ways to test this. One simple alternative is just to call `invalidateblock` twice (once at the tip, once at the base of the invalid chain).

  Note that the written warning doesn't include the exclamation mark, as it is removed via `SanitizeString` in the `AlertNotify` function.

ACKs for top commit:
  brunoerg:
    reACK 8343a9ffcc
  mzumsande:
    re-ACK 8343a9ffcc

Tree-SHA512: d81e9ce7622026498cad5cdcdb867a22068670983737502888c72c72209ca6ff183e77d7429f758765a42c25cda439e01f795884864ac6fe6ff258a98d0bbcbc
2025-11-25 11:45:07 +00:00
merge-script
fa283d28e2 Merge bitcoin/bitcoin#33629: Cluster mempool
17cf9ff7ef Use cluster size limit for -maxmempool bound, and allow -maxmempool=0 in general (Suhas Daftuar)
315e43e5d8 Sanity check `GetFeerateDiagram()` in CTxMemPool::check() (Suhas Daftuar)
de2e9a24c4 test: extend package rbf functional test to larger clusters (Suhas Daftuar)
4ef4ddb504 doc: update policy/packages.md for new package acceptance logic (Suhas Daftuar)
79f73ad713 Add check that GetSortedScoreWithTopology() agrees with CompareMiningScoreWithTopology() (Suhas Daftuar)
a86ac11768 Update comments for CTxMemPool class (Suhas Daftuar)
9567eaa66d Invoke TxGraph::DoWork() at appropriate times (Suhas Daftuar)
6c5c44f774 test: add functional test for new cluster mempool RPCs (Suhas Daftuar)
72f60c877e doc: Update mempool_replacements.md to reflect feerate diagram checks (Suhas Daftuar)
21693f031a Expose cluster information via rpc (Suhas Daftuar)
72e74e0d42 fuzz: try to add more code coverage for mempool fuzzing (Suhas Daftuar)
f107417490 bench: add more mempool benchmarks (Suhas Daftuar)
7976eb1ae7 Avoid violating mempool policy limits in tests (Suhas Daftuar)
84de685cf7 Stop tracking parents/children outside of txgraph (Suhas Daftuar)
88672e205b Rewrite GatherClusters to use the txgraph implementation (Suhas Daftuar)
1ca4f01090 Fix miniminer_tests to work with cluster limits (Suhas Daftuar)
1902111e0f Eliminate CheckPackageLimits, which no longer does anything (Suhas Daftuar)
3a646ec462 Rework RBF and TRUC validation (Suhas Daftuar)
19b8479868 Make getting parents/children a function of the mempool, not a mempool entry (Suhas Daftuar)
5560913e51 Rework truc_policy to use descendants, not children (Suhas Daftuar)
a4458d6c40 Use txgraph to calculate descendants (Suhas Daftuar)
c8b6f70d64 Use txgraph to calculate ancestors (Suhas Daftuar)
241a3e666b Simplify ancestor calculation functions (Suhas Daftuar)
b9cec7f0a1 Make removeConflicts private (Suhas Daftuar)
0402e6c780 Remove unused limits from CalculateMemPoolAncestors (Suhas Daftuar)
08be765ac2 Remove mempool logic designed to maintain ancestor/descendant state (Suhas Daftuar)
fc4e3e6bc1 Remove unused members from CTxMemPoolEntry (Suhas Daftuar)
ff3b398d12 mempool: eliminate accessors to mempool entry ancestor/descendant cached state (Suhas Daftuar)
b9a2039f51 Eliminate use of cached ancestor data in miniminer_tests and truc_policy (Suhas Daftuar)
ba09fc9774 mempool: Remove unused function CalculateDescendantMaximum (Suhas Daftuar)
8e49477e86 wallet: Replace max descendant count with cluster_count (Suhas Daftuar)
e031085fd4 Eliminate Single-Conflict RBF Carve Out (Suhas Daftuar)
cf3ab8e1d0 Stop enforcing descendant size/count limits (Suhas Daftuar)
89ae38f489 test: remove rbf carveout test from mempool_limit.py (Suhas Daftuar)
c0bd04d18f Calculate descendant information for mempool RPC output on-the-fly (Suhas Daftuar)
bdcefb8a8b Use mempool/txgraph to determine if a tx has descendants (Suhas Daftuar)
69e1eaa6ed Add test case for cluster size limits to TRUC logic (Suhas Daftuar)
9cda64b86c Stop enforcing ancestor size/count limits (Suhas Daftuar)
1f93227a84 Remove dependency on cached ancestor data in mini-miner (Suhas Daftuar)
9fbe0a4ac2 rpc: Calculate ancestor data from scratch for mempool rpc calls (Suhas Daftuar)
7961496dda Reimplement GetTransactionAncestry() to not rely on cached data (Suhas Daftuar)
feceaa42e8 Remove CTxMemPool::GetSortedDepthAndScore (Suhas Daftuar)
21b5cea588 Use cluster linearization for transaction relay sort order (Suhas Daftuar)
6445aa7d97 Remove the ancestor and descendant indices from the mempool (Suhas Daftuar)
216e693729 Implement new RBF logic for cluster mempool (Suhas Daftuar)
ff8f115dec policy: Remove CPFP carveout rule (Suhas Daftuar)
c3f1afc934 test: rewrite PopulateMempool to not violate mempool policy (cluster size) limits (Suhas Daftuar)
47ab32fdb1 Select transactions for blocks based on chunk feerate (Suhas Daftuar)
dec138d1dd fuzz: remove comparison between mini_miner block construction and miner (Suhas Daftuar)
6c2bceb200 bench: rewrite ComplexMemPool to not create oversized clusters (Suhas Daftuar)
1ad4590f63 Limit mempool size based on chunk feerate (Suhas Daftuar)
b11c89cab2 Rework miner_tests to not require large cluster limit (Suhas Daftuar)
95a8297d48 Check cluster limits when using -walletrejectlongchains (Suhas Daftuar)
95762e6759 Do not allow mempool clusters to exceed configured limits (Suhas Daftuar)
edb3e7cdf6 [test] rework/delete feature_rbf tests requiring large clusters (glozow)
435fd56711 test: update feature_rbf.py replacement test (Suhas Daftuar)
34e32985e8 Add new (unused) limits for cluster size/count (Suhas Daftuar)
838d7e3553 Add transactions to txgraph, but without cluster dependencies (Suhas Daftuar)
d5ed9cb3eb Add accessor for sigops-adjusted weight (Suhas Daftuar)
1bf3b51396 Add sigops adjusted weight calculator (Suhas Daftuar)
c18c68a950 Create a txgraph inside CTxMemPool (Suhas Daftuar)
29a94d5b2f Make CTxMemPoolEntry derive from TxGraph::Ref (Suhas Daftuar)
92b0079fe3 Allow moving CTxMemPoolEntry objects, disallow copying (Suhas Daftuar)
6c73e47448 mempool: Store iterators into mapTx in mapNextTx (Suhas Daftuar)
51430680ec Allow moving an Epoch::Marker (Suhas Daftuar)

Pull request description:

  [Reopening #28676 here as a new PR, because GitHub is slow to load the page making it hard to scroll through and see comments.  Also, that PR was originally opened with a prototype implementation which has changed significantly with the introduction of `TxGraph`.]

  This is an implementation of the [cluster mempool proposal](https://delvingbitcoin.org/t/an-overview-of-the-cluster-mempool-proposal/393).

  This branch implements the following observable behavior changes:

   - Maintains a partitioning of the mempool into connected clusters (via the `txgraph` class), which are limited in vsize to 101 kvB by default, and limited in count to 64 by default.
   - Each cluster is sorted ("linearized") to try to optimize for selecting highest-feerate-subsets of a cluster first
   - Transaction selection for mining is updated to use the cluster linearizations, selecting highest feerate "chunks" first for inclusion in a block template.
   - Mempool eviction is updated to use the cluster linearizations, selecting lowest feerate "chunks" first for removal.
   - The RBF rules are updated to: (a) drop the requirement that no new inputs are introduced; (b) change the feerate requirement to instead check that the feerate diagram of the mempool will strictly improve; (c) replace the direct conflicts limit with a directly-conflicting-clusters limit.
   - The CPFP carveout rule is eliminated (it doesn't make sense in a cluster-limited mempool)
   - The ancestor and descendant limits are no longer enforced.
   - New cluster count/cluster vsize limits are now enforced instead.
   - Transaction relay now uses chunk feerate comparisons to determine the order that newly received transactions are announced to peers.

  Additionally, the cached ancestor and descendant data are dropped from the mempool, along with the multi_index indices that were maintained to sort the mempool by ancestor and descendant feerates. For compatibility (eg with wallet behavior or RPCs exposing this), this information is now calculated dynamically instead.

ACKs for top commit:
  instagibbs:
    reACK 17cf9ff7ef
  glozow:
    reACK 17cf9ff7ef
  sipa:
    ACK 17cf9ff7ef

Tree-SHA512: bbde46d913d56f8d9c0426cb0a6c4fa80b01b0a4c2299500769921f886082fb4f51f1694e0ee1bc318c52e1976d7ebed8134a64eda0b8044f3a708c04938eee7
2025-11-25 10:35:11 +00:00
Sebastian Falbesoner
8343a9ffcc test: add -alertnotify test for large work invalid chain warning 2025-11-24 14:28:04 +01:00
Suhas Daftuar
17cf9ff7ef Use cluster size limit for -maxmempool bound, and allow -maxmempool=0 in general
Previously we would sanity check the -maxmempool configuration based on a
multiple of the descendant size limit, but with cluster mempool the maximum
evicted size is now the cluster size limit, so use that instead.

Also allow -maxmempool=0 in general (and not just if
-limitdescendantsize/-limitclustersize is set to 0).
2025-11-21 22:02:07 -05:00
Suhas Daftuar
de2e9a24c4 test: extend package rbf functional test to larger clusters
Co-Authored-By: Gregory Sanders <gsanders87@gmail.com>
2025-11-21 22:02:07 -05:00
Ava Chow
0690514d4f Merge bitcoin/bitcoin#33770: init: Require explicit -asmap filename
288b8c30be doc: Drop (default: none) from -i2psam description (Ryan Ofsky)
f6ec3519a3 init: Require explicit -asmap filename (Ryan Ofsky)

Pull request description:

  Currently, if `-asmap` is specified without a filename bitcoind tries to load `ip_asn.map` data file.

  This change now requires `-asmap=ip_asn.map` or another filename to be specified explicitly.

  The change is intended to make behavior of the option explicit and avoid confusion reported https://github.com/bitcoin/bitcoin/issues/33386 where documentation specifies a default file which is not actually loaded by default. It was originally implemented in
  https://github.com/bitcoin/bitcoin/pull/33631#issuecomment-3410302383 and various alternatives are discussed there.

ACKs for top commit:
  brunoerg:
    reACK 288b8c30be
  fjahr:
    re-ACK 288b8c30be
  vostrnad:
    utACK 288b8c30be
  achow101:
    ACK 288b8c30be

Tree-SHA512: 11a38a03892a58d6ccc1505cfbf915f58a86df9891761d89dc54b92d40593ee3cbb2d7c7bdbb922b871b3529072ef7f34cc98393aff6e8f0633b56352315b27c
2025-11-21 15:28:36 -08:00
Ava Chow
b2f88b53e0 Merge bitcoin/bitcoin#33286: doc: update multisig tutorial to use multipath descriptors
de7c3587cd doc: Update add checksum instructions in tutorial (Ben Westgate)
2a46e94a16 doc: Update multisig-tutorial.md to use multipath descriptors (Ben Westgate)

Pull request description:

  ### Summary

  Update `doc/multisig-tutorial.md` to use multipath descriptor format
  instead of separate external/internal descriptors. The tutorial now:

  - extracts a single `xpub_n` per participant
  - constructs a multipath `wsh(sortedmulti(...))` descriptor with `<0;1>`
    change index semantics
  - uses `getdescriptorinfo` to compute descriptor checksum
  - explains that `importdescriptors` expands the multipath descriptor
    into internal and external descriptors
  - update `/test/functional/wallet_multisig_descriptor_psbt.py` functional test / documentation to use multi-path descriptors

  ---

  ### Motivation

  A single multipath descriptor is the most convenient pattern for multisig; our documentation should use it.

  ---

  ### What changed

  - replaced extraction of `external_xpub_n` and `internal_xpub_n` with
    extraction of a single `xpub_n`
  - removed instructions to create and import separate external/internal
    descriptors
  - added instructions to build a multipath `wsh(sortedmulti(...))`
    descriptor and derive checksum with `getdescriptorinfo`
  - checksum field is parsed and appended as the multipath descriptor is not the canonical "desc" output
  - clarified that `importdescriptors` automatically expands multipath
    descriptors into internal and external forms
  - similar changes to the functional test: wallet_multisig_descriptor_psbt.

  ---

  ### Testing

  I have run the updated shell snippets and confirmed the multipath descriptor produces the same `listdescriptors` output after importing as the two descriptor method in bitcoin:master.

  ---

  ### Related issues / PRs

  This tutorial change references the multipath descriptor
  consolidation (see commit / PR referenced in the change). The commit
  message points to bitcoin#22838 as the upstream change that enables
  this behavior.

  ---

  ### Release note (for changelog)

  Documentation: update multisig tutorial and multisig functional test to use multipath descriptors

ACKs for top commit:
  Sjors:
    utACK de7c3587cd
  kannapoix:
    Core review ACK: de7c3587cd
  achow101:
    ACK de7c3587cd
  rkrux:
    crACK de7c3587cd

Tree-SHA512: ca7275d8ad04922b3fa8d2a3084ff96aa2104265f1fc2f749814dd16776351ab692d67e7e643d08052f7492e3eaa1a9a4dfe3470163e57939a49f782d3df511a
2025-11-21 15:05:50 -08:00
Ava Chow
313cdd2bfb Merge bitcoin/bitcoin#33915: test: Retry download in get_previous_releases.py
fad06f3bb4 test: retry download in get_previous_releases.py (MarcoFalke)

Pull request description:

  Hopefully fixes https://github.com/bitcoin/bitcoin/issues/33913 (intermittent download issues)

  If not, the diff there to cache the bins can be considered.

ACKs for top commit:
  davidgumberg:
    ACK fad06f3bb4
  achow101:
    ACK fad06f3bb4
  enirox001:
    ACK fad06f3
  TheCharlatan:
    ACK fad06f3bb4
  janb84:
    ACK fad06f3bb4

Tree-SHA512: 6597e993cc64259e361f65045a938e693b47ff73a7dc22f5a70b6c9890986817849915f90096e3b87684f25152a6d8ae4ec5480c326c32d36273cdb0a33ceb0c
2025-11-21 13:35:03 -08:00
merge-script
6b2d17b132 Merge bitcoin/bitcoin#33888: ci: Re-enable LINT_CI_SANITY_CHECK_COMMIT_SIG
55555db055 doc: Add missing --platform=linux to docker build command (MarcoFalke)
fa0ce4c148 ci: Re-enable LINT_CI_SANITY_CHECK_COMMIT_SIG (MarcoFalke)
faa0973de2 ci: [refactor] Rename CIRRUS_PR env var to LINT_CI_IS_PR (MarcoFalke)
fa1dacaebe ci: Move lint exec snippet to stand-alone py file (MarcoFalke)

Pull request description:

  The sanity check to check the last few merge commit signatures on the main branch was accidentally and silently disabled while moving from the `cirrus-ci.com` platform to the GHA platform.

  So fix that by re-enabling it.

  Also, contains a few other lint cleanup commits.

ACKs for top commit:
  janb84:
    re ACK 55555db055
  willcl-ark:
    ACK 55555db055

Tree-SHA512: e623dc88035ee4d1c6a8efa5fad33c35cface87f54e78c7ebfe5d468d28d8d8097150344d276f90f8ed52a89e61609ce95380476ea0151b50f73ad5919233933
2025-11-20 17:29:57 +00:00
merge-script
29c37651c7 Merge bitcoin/bitcoin#33880: test: Fix race condition in IPC interface block progation test
2578e6fc0f test: Fix race condition in IPC interface block propagation test (Fabian Jahr)

Pull request description:

  CI failed on this condition here: https://github.com/bitcoin/bitcoin/actions/runs/19395398994/job/55494696022?pr=33878#step:9:3983

  The check was added not too long ago in https://github.com/bitcoin/bitcoin/pull/33745 and the fix here switches the check to the node which actually produces the block. There are also some comments added to make the checks easier so understand.

  Closes #33884

ACKs for top commit:
  Sjors:
    re-utACK 2578e6fc0f
  maflcko:
    lgtm ACK 2578e6fc0f

Tree-SHA512: bfb7ae44aede50a00d4096e1a9922f9b8df31ce4242e12863e329d0d1e714d8cb46c852f694c32314e4bd26b524535e3a6967b7c57861a9b00cf09831a950b99
2025-11-20 17:19:26 +00:00
MarcoFalke
fad06f3bb4 test: retry download in get_previous_releases.py 2025-11-20 12:47:03 +01:00
Fabian Jahr
2578e6fc0f test: Fix race condition in IPC interface block propagation test 2025-11-19 23:20:24 +01:00
Ava Chow
53b72372da Merge bitcoin/bitcoin#31734: miniscript: account for all StringType variants in Miniscriptdescriptor::ToString()
28a4fcb03c test: check listdescriptors do not return a mix of hardened derivation marker (pythcoiner)
975783cb79 descriptor: account for all StringType in MiniscriptDescriptor::ToStringHelper() (pythcoiner)

Pull request description:

  In `MiniscriptDescriptor::ToStringHelper()` only the `StringType::Private` variant of the `type` argument was handled. This PR implements serializing w/ all variants of `StringType` & add a functional test for the descriptor triggering the related issue.

  Closes #31694: previously when calling `listdescriptors` RPC on a wallet containing a taproot descriptor w/ a (miniscript) taptree, origins of internal key & taptree were serialized w/ differents hardened derivation markers:
   - origin of the internal key were serialized w/ `StringType::Normalized` type (using `h` as marker)
   - origins of taptree keys were serialized w/ `StringType::Private` type (using `'` as marker)

  Note: Origins in segwit (`wsh()`) miniscript descriptors were also serialized w/ `StringType::Private` type (`'` marker) and are now serialized w/ `StringType::Normalized` type (`h` marker).

ACKs for top commit:
  sipa:
    Code review ACK 28a4fcb03c
  achow101:
    ACK 28a4fcb03c
  rkrux:
    Concept ACK 28a4fcb03c

Tree-SHA512: 15d14000b5951ca69a64a05b9a0b138c48a07b81eaf2fa86b91ac20cc8735533355a787363c64ba88403dd8a56ef5232cba57d34bea80835a0f40774d62fbc2b
2025-11-18 14:32:01 -08:00
Ava Chow
a7f9bbe4c5 Merge bitcoin/bitcoin#32821: rpc: Handle -named argument parsing where '=' character is used
f53dbbc505 test: Add functional tests for named argument parsing (zaidmstrr)
694f04e2bd rpc: Handle -named argument parsing where '=' character is used (zaidmstrr)

Pull request description:

  Addresses [comment](https://github.com/bitcoin/bitcoin/pull/31375#discussion_r2091886628) and [this](https://github.com/bitcoin/bitcoin/pull/31375#discussion_r2092039999).

  The [PR #31375](https://github.com/bitcoin/bitcoin/pull/31375) got merged and enables `-named` by default in the `bitcoin rpc` interface; `bitcoin rpc` corresponds to `bitcoin-cli -named` as it's just a wrapper.  Now, the problem arises when we try to parse the positional paramater which might contain "=" character.  This splits the parameter into two parts first, before the "=" character, which treats this as the parameter name, but the other half is mostly passed as an empty string. Here, the first part of the string is an unknown parameter name; thus, an error is thrown. These types of errors are only applicable to those RPCs which might contain the `=` character as a parameter. Some examples are `finalizepsbt`, `decodepsbt`, `verifymessage` etc.

  This is the one example of the error in `finalizepsbt` RPC:
  ```
  ./bitcoin-cli -named -regtest finalizepsbt cHNidP8BAJoCAAAAAqvNEjSrzRI0q80SNKvNEjSrzRI0q80SNKvNEjSrzRI0AAAAAAD9////NBLNqzQSzas0Es2rNBLNqzQSzas0Es2rNBLNqzQSzasBAAAAAP3///8CoIYBAAAAAAAWABQVQBGVs/sqFAmC8HZ8O+g1htqivkANAwAAAAAAFgAUir7MzgyzDnRMjdkVa7d+Dwr07jsAAAAAAAAAAAA=
  error code: -8
  error message:
  Unknown named parameter cHNidP8BAJoCAAAAAqvNEjSrzRI0q80SNKvNEjSrzRI0q80SNKvNEjSrzRI0AAAAAAD9////NBLNqzQSzas0Es2rNBLNqzQSzas0Es2rNBLNqzQSzasBAAAAAP3///8CoIYBAAAAAAAWABQVQBGVs/sqFAmC8HZ8O+g1htqivkANAwAAAAAAFgAUir7MzgyzDnRMjdkVa7d+Dwr07jsAAAAAAAAAAAA
  ```
  This PR fixes this by updating the `vRPCConvertParams` table that identifies parameters that need special handling in `-named` parameter mode. The parser now recognises these parameters and handles strings with "=" char correctly, preventing them from being incorrectly split as parameter assignments.

ACKs for top commit:
  ryanofsky:
    Code review ACK f53dbbc505. Just applied comment & test suggestions since last review
  kannapoix:
    Code review ACK: f53dbbc505
  achow101:
    ACK f53dbbc505

Tree-SHA512: 1b517144efeff45a4c4256c27a39ddf187f1d6189d133402a45171678214a10ff2925c31edcfd556d67f85bd26d42f63c528b941b68c9880eab443f2c883e681
2025-11-18 14:06:54 -08:00
MarcoFalke
55555db055 doc: Add missing --platform=linux to docker build command
This is required to pick the native arch, similar to how the
CI_IMAGE_PLATFORM is set to linux.
2025-11-18 20:15:55 +01:00
Suhas Daftuar
6c5c44f774 test: add functional test for new cluster mempool RPCs
Co-authored-by: glozow <gloriajzhao@gmail.com>
2025-11-18 11:14:52 -05:00
Suhas Daftuar
21693f031a Expose cluster information via rpc
Co-authored-by: glozow <gloriajzhao@gmail.com>
2025-11-18 11:14:52 -05:00
Suhas Daftuar
cf3ab8e1d0 Stop enforcing descendant size/count limits
Cluster size limits should be enough.
2025-11-18 08:57:51 -05:00
Suhas Daftuar
89ae38f489 test: remove rbf carveout test from mempool_limit.py 2025-11-18 08:57:51 -05:00
Suhas Daftuar
69e1eaa6ed Add test case for cluster size limits to TRUC logic 2025-11-18 08:57:51 -05:00
Suhas Daftuar
9cda64b86c Stop enforcing ancestor size/count limits
The cluster limits should be sufficient.

Co-Authored-By: Gregory Sanders <gsanders87@gmail.com>
2025-11-18 08:57:51 -05:00
Suhas Daftuar
21b5cea588 Use cluster linearization for transaction relay sort order
Previously, transaction batches were first sorted by ancestor count and then
feerate, to ensure transactions are announced in a topologically valid order,
while prioritizing higher feerate transactions. Ancestor count is a crude
topological sort criteria, so replace this with linearization order so that the
highest feerate transactions (as would be observed by the mining algorithm) are
relayed before lower feerate ones, in a topologically valid way.

This also fixes a test that only worked due to the ancestor-count-based sort
order.
2025-11-18 08:53:59 -05:00
Suhas Daftuar
216e693729 Implement new RBF logic for cluster mempool
With a total ordering on mempool transactions, we are now able to calculate a
transaction's mining score at all times. Use this to improve the RBF logic:

- we no longer enforce a "no new unconfirmed parents" rule

- we now require that the mempool's feerate diagram must improve in order
  to accept a replacement

- the topology restrictions for conflicts in the package rbf setting have been
  eliminated

Revert the temporary change to mempool_ephemeral_dust.py that were previously
made due to RBF validation checks being reordered.

Co-authored-by: Gregory Sanders <gsanders87@gmail.com>, glozow <gloriajzhao@gmail.com>
2025-11-18 08:53:59 -05:00
Suhas Daftuar
ff8f115dec policy: Remove CPFP carveout rule
The addition of a cluster size limit makes the CPFP carveout rule useless,
because carveout cannot be used to bypass the cluster size limit. Remove this
policy rule and update tests to no longer rely on the behavior.
2025-11-18 08:53:59 -05:00
Suhas Daftuar
95762e6759 Do not allow mempool clusters to exceed configured limits
Include an adjustment to mempool_tests.cpp due to the additional memory used by
txgraph.

Includes a temporary change to the mempool_ephemeral_dust.py functional test,
due to validation checks being reordered. This change will revert once the RBF
rules are changed in a later commit.
2025-11-18 08:53:58 -05:00
glozow
edb3e7cdf6 [test] rework/delete feature_rbf tests requiring large clusters 2025-11-18 08:53:58 -05:00
Suhas Daftuar
435fd56711 test: update feature_rbf.py replacement test
Preparatory commit to the rbf functional test, before changes are made to the
rbf rules as part of cluster mempool.
2025-11-18 08:53:58 -05:00
Sebastian Falbesoner
0aebdac95d init: completely remove -maxorphantx option 2025-11-13 19:02:39 +01:00
merge-script
dfde31f2ec Merge bitcoin/bitcoin#33864: scripted-diff: fix leftover references to policy/fees.h
b0a3887154 scripted-diff: fix leftover references to `policy/fees.h` (ismaelsadeeq)

Pull request description:

  Fixes #33863

  ryanofsky wrote
  > I still see some references to the src/policy/fees.h file removed by this PR:

  ```
  $ git grep -n policy/fees.h
  src/wallet/rpc/spend.cpp:206: * @param[in]     conf_target       UniValue integer; confirmation target in blocks, values between 1 and 1008 are valid per policy/fees.h;
  test/functional/rpc_estimatefee.py:39:        # max value of 1008 per src/policy/fees.h
  test/functional/rpc_psbt.py:604:                assert_raises_rpc_error(-8, "Invalid conf_target, must be between 1 and 1008",  # max value of 1008 per src/policy/fees.h
  test/functional/wallet_basic.py:337:            assert_raises_rpc_error(-8, "Invalid conf_target, must be between 1 and 1008",  # max value of 1008 per src/policy/fees.h
  test/functional/wallet_fundrawtransaction.py:851:                assert_raises_rpc_error(-8, "Invalid conf_target, must be between 1 and 1008",  # max value of 1008 per src/policy/fees.h
  test/functional/wallet_send.py:315:                expect_error=(-8, "Invalid conf_target, must be between 1 and 1008"))  # max value of 1008 per src/policy/fees.h
  ```

  This is fixed in this PR by running a script that searches for what he greps and replaces it with the right reference.

  ```
  git grep -l "policy\/fees\.h" | xargs sed -i "s/policy\/fees.h/policy\/fees\/block_policy_estimator.h/g"
  ```

ACKs for top commit:
  kevkevinpal:
    ACK [b0a3887](b0a3887154)
  janb84:
    ACK b0a3887154
  rkrux:
    lgtm ACK b0a3887154

Tree-SHA512: e24f2aaf18fcfb0ae047a53ed209135a644ff08f5a8bc162c1522be3f99d7d01d550fc2e73d8db5fec7b748902daf68e61e7a5624f5913b9824feba5641fc78c
2025-11-13 09:48:50 +00:00