7971 Commits

Author SHA1 Message Date
merge-script
aefa8e6d14
Merge bitcoin/bitcoin#34361: test: clean up tx resurrection (re-org) test in feature_block.py
5b2c3960b929bd015911783fb59e3660b0810f03 test: clean up tx resurrection (re-org) test in feature_block.py (Sebastian Falbesoner)

Pull request description:

  The following comment about ECDSA signatures created with the test framework not passing mempool policy has been obsolete for a long time (at least since 2019, see PR #15826):

  8c07800b19/test/functional/feature_block.py (L1167-L1172)

  so remove it. While at it, change the resurrected txs to be indeed standard valid, so the `acceptnonstdtxn=1` parameter can also be removed from the functional test.

  Kudos to stratospher, who (IIRC) mentioned this outdated comment a while ago.

ACKs for top commit:
  sedited:
    ACK 5b2c3960b929bd015911783fb59e3660b0810f03
  Bortlesboat:
    Tested ACK 5b2c3960b929. Ran feature_block.py locally, passes. Nice cleanup — removing `-acceptnonstdtxn=1` by making the resurrection txs standard (P2PK) is the right approach. The old unsigned OP_TRUE workaround comment explains why this was needed, glad to see it gone.
  stratospher:
    ACK 5b2c3960. nice!

Tree-SHA512: 94517e432647a8e8db51fad90a26493c57ce9dfd924b17ce909ea40d50bc6279d974c6d2046b34f5f92b481ca5e0abdedaf412ce41b4cb904605c140a8dba583
2026-03-09 10:21:10 +00:00
Ava Chow
8b70ed6996
Merge bitcoin/bitcoin#34521: validation: fix UB in LoadChainTip
20ae9b98eab20117344cf31f7cde39cadd70ca22 Extend functional test for setBlockIndexCandidates UB (marcofleon)
854a6d5a9a0e40329a2852efb2a8dfec4b54886e validation: fix UB in LoadChainTip (marcofleon)
9249e6089ec4e2eb63f0896961f04d9dbe14651a validation: remove LoadChainTip call from ActivateSnapshot (marcofleon)

Pull request description:

  Addresses https://github.com/bitcoin/bitcoin/issues/34503. See this issue for more details as well.

  Fixes a bug where, under certain conditions, `setBlockIndexCandidates` had blocks in it that were worse than the tip. The block index candidate set uses `nSequenceId` as a sort key, so modifying this field while blocks are in the set results in undefined behavior. This PR populates `setBlockIndexCandidates` after the `nSequenceId` modifications, avoiding the UB.

ACKs for top commit:
  achow101:
    ACK 20ae9b98eab20117344cf31f7cde39cadd70ca22
  sedited:
    Re-ACK 20ae9b98eab20117344cf31f7cde39cadd70ca22
  sipa:
    Code review ACK 20ae9b98eab20117344cf31f7cde39cadd70ca22

Tree-SHA512: 121c170bb70fb6365089d578db63c811e7926e129d7206e569947f7a1f6c5ddc8d5f4937b80f1ba1b7d7daa42789b143ca5b56f154b7ab968a1cd55f925f378d
2026-03-06 08:22:42 -08:00
merge-script
f6d3201e14
Merge bitcoin/bitcoin#33929: test: Remove system_tests/run_command runtime dependencies
97e7e79435c69e90cb7f056c704c275421bf0892 test: Enable `system_tests/run_command` "stdin" test on Windows (Hennadii Stepanov)
a4324ce09546d80ab847dbfce715f015139ed593 test: Remove `system_tests/run_command` runtime dependencies (Hennadii Stepanov)

Pull request description:

  `system_tests` currently rely on `cat`, `echo`, `false` and `sh` being available in `PATH` at runtime.

  This PR:
  1. Removes these dependencies.
  2. Reduces the number of platform-specific code paths.

  The change is primarily motivated by my work on maintaining the [`bitcoin-core`](https://packages.guix.gnu.org/packages/bitcoin-core) package in Guix. It enables the removal of the existing `bash` and `coreutils` native inputs, which in turn makes it possible to drop the implicit dependency on `qtbase@5` (see https://codeberg.org/guix/guix/pulls/4386#issuecomment-8613333).

ACKs for top commit:
  maflcko:
    re-ACK 97e7e79435c69e90cb7f056c704c275421bf0892 👓
  janb84:
    ACK 97e7e79435c69e90cb7f056c704c275421bf0892
  sedited:
    ACK 97e7e79435c69e90cb7f056c704c275421bf0892

Tree-SHA512: 1375c676f85c75d571df1ddfc3a4405767dbf0ed7bfea2927c93ec01b29f9f7ae3383e546d2658f595e8ffafa9ab20bba6fcc628a9f5ebdb288bbef03b645fb6
2026-03-06 12:40:11 +00:00
merge-script
d97df29d5d
Merge bitcoin/bitcoin#34747: test: Sync mempools and wait for txospender index to be synced in rpc_gettxspendingprevout
cbdb891de23d98dae3cfb3c4d993d6111df0aaa4 test: Wait for txospender index to be synced in rpc_gettxspendingprevout (Ava Chow)
2db5c049bb3cf9a323c100ce9d4957a937c01624 test: Sync mempools after tx creation in rpc_gettxspendingprevout (Ava Chow)

Pull request description:

  On slower runs, the txospender index may not be synced yet when the tests of its behavior begin, causing intermittent failures. Wait for them to be synced before starting the tests.

  The tests also query mempool txs from other nodes, make sure mempools are synced before doing so.

  The first commit with the following diff reproduces #34735:

  ```
  diff --git a/src/index/txospenderindex.cpp b/src/index/txospenderindex.cpp
  index d451bb1e0a4..e786f05a98c 100644
  --- a/src/index/txospenderindex.cpp
  +++ b/src/index/txospenderindex.cpp
  @@ -129,6 +129,7 @@ static std::vector<std::pair<COutPoint, CDiskTxPos>> BuildSpenderPositions(const

   bool TxoSpenderIndex::CustomAppend(const interfaces::BlockInfo& block)
   {
  +    UninterruptibleSleep(100ms);
       WriteSpenderInfos(BuildSpenderPositions(block));
       return true;
   }
  ```

  Fixes #34735

ACKs for top commit:
  furszy:
    ACK cbdb891de23d98dae3cfb3c4d993d6111df0aaa4
  andrewtoth:
    ACK cbdb891de23d98dae3cfb3c4d993d6111df0aaa4
  sedited:
    ACK cbdb891de23d98dae3cfb3c4d993d6111df0aaa4
  rkrux:
    crACK cbdb891de23d98dae3cfb3c4d993d6111df0aaa4

Tree-SHA512: ba1ab6216ac3b647a5f9e20f4899e51e643bf20829e698aa63c127c88ed4e33afa222bebeae1210fc869c46288e99c0b344330197913e244ffe1a6aca943568d
2026-03-06 10:30:45 +00:00
merge-script
c12be53f85
Merge bitcoin/bitcoin#34635: rpc, index: txospenderindex improve formatting, docs and test coverage
15c4889497b96037e41019a8f43090af841b36ec index: document TxoSpenderIndex::FindSpender (furszy)
f8b9595aaa966c373b02e6227dc799fed6d038ba test: Add missing txospenderindex coverage in feature_init (Fabian Jahr)
a1074d852a7a46b746fb4ed90d94cb4cc346f9b3 index, rpc, test: Misc formatting fixes (Fabian Jahr)

Pull request description:

  This addresses my own comments in the last review of #24539: https://github.com/bitcoin/bitcoin/pull/24539#pullrequestreview-3829110465

  The first commit fixes three small formatting errors.

  The second commit adds some missing coverage in `feature_init` and refactors the code a bit as well so these misses don't happen so easily in the future.

  The third commit is by furzy:

  > TxoSpenderIndex::FindSpender returns an Expected<optional<TxoSpender>> but
  the two levels of the return type were undocumented, making it unclear what a returned
  nullopt means. So added doc clarifying each return case.

ACKs for top commit:
  furszy:
    ACK 15c4889497b96037e41019a8f43090af841b36ec
  sedited:
    ACK 15c4889497b96037e41019a8f43090af841b36ec
  rkrux:
    crACK 15c4889497b96037e41019a8f43090af841b36ec

Tree-SHA512: 2e0f060a54b558d2967ebae0835cf81bd86c2d8d983d670a48d1bee7d347f186623e75db7ae311ca1566807f715c1b3fa67cf734c9467d35e13b84d082f28253
2026-03-06 10:08:50 +00:00
Fabian Jahr
f8b9595aaa
test: Add missing txospenderindex coverage in feature_init
Also refactors the list of all index args into a constant that can be reused across tests.

Co-authored-by: sedited <seb.kung@gmail.com>
2026-03-06 00:48:34 +01:00
Ava Chow
cbdb891de2 test: Wait for txospender index to be synced in rpc_gettxspendingprevout
Each node's txospender index needs to catch up with the existing chain
before the tests will work.
2026-03-05 11:19:58 -08:00
Ava Chow
2db5c049bb test: Sync mempools after tx creation in rpc_gettxspendingprevout
The test will query information from the other nodes about mempool txs,
ensure that the txs are in their mempools beforehand.
2026-03-05 11:19:13 -08:00
Fabian Jahr
a1074d852a
index, rpc, test: Misc formatting fixes 2026-03-05 13:15:09 +01:00
merge-script
f2f5619360
Merge bitcoin/bitcoin#34709: wallet, test: improve wallet functional tests
5c005363a880c136cc44ff2456a402e398fcbf44 test: improve `wallet_backup` test (rkrux)
04d95157485e31b6a8a0f2eb2d7a65023b4199ac test: improve `wallet_assumeutxo` func test (rkrux)

Pull request description:

  Relates to #34354

  While the actual fix of the issue is in another PR, this one improves the
  affected tests by trying to reduce the chain notifications that
  need to be processed while simulating erroneous wallet restoration
  scenarios.

ACKs for top commit:
  maflcko:
    lgtm ACK 5c005363a880c136cc44ff2456a402e398fcbf44
  furszy:
    ACK 5c005363a880c136cc44ff2456a402e398fcbf44
  w0xlt:
    ACK 5c005363a880c136cc44ff2456a402e398fcbf44
  brunoerg:
    code review ACK 5c005363a880c136cc44ff2456a402e398fcbf44

Tree-SHA512: 176e3ea8275c7aa082af695f5b76d82c079ff9a7178855b4ce95504edb8ce89b59a772e2d38dd43e997a5bea3d64be700b74cfec7bbc6992538f837877ab7222
2026-03-05 11:19:00 +00:00
marcofleon
20ae9b98ea Extend functional test for setBlockIndexCandidates UB
Fix the from-disk subtest to use a separate node so it builds on a
clean genesis block, rather than the leftover chain from the
in-memory subtest.

Change from a two-way to a three-way block race. The UB in the old
LoadChainTip (mutating nSequenceId, a sort key, while the block is
in setBlockIndexCandidates) corrupts the internal tree structure,
resulting in a failed erase that leaves stale blocks in the set
alongside the tip. With only two competing blocks, this is caught
by libstdc++ but not by libc++. A three-way split triggers the bug
on both implementations.

To trigger CheckBlockIndex (where the crashing assertion is), replace
the restart loop with sending a new block after a single restart.
2026-03-04 20:13:53 +00:00
Ava Chow
4c40a923f0
Merge bitcoin/bitcoin#34728: test: Fix intermittent issue in wallet_assumeutxo.py
faa68ed4bdce6540f99d23c9b200ca575794a1b2 test: Fix intermittent issue in wallet_assumeutxo.py (MarcoFalke)

Pull request description:

  The test has many issues:

  * It fails intermittently, due to the use of `-stopatheight` (https://github.com/bitcoin/bitcoin/issues/34710)
  * Using `-stopatheight` is expensive, because it requires two restarts, making the test slow
  * The overwritten `def setup_network` does not store the extra args via the `add_nodes` call, so if code is added in the future to restart a node, it may not pick up its global extra args.

  Fix all issues by:

  * Adding and using a fast `dumb_sync_blocks` util helper to achieve what `-stopatheight` doesn't achieve
  * Calling `self.add_nodes(self.num_nodes, self.extra_args)` in the overridden `setup_network`

  Can be tested via this diff:

  ```diff
  diff --git a/src/node/kernel_notifications.cpp b/src/node/kernel_notifications.cpp
  index ab0e5ccb69..49384c10b8 100644
  --- a/src/node/kernel_notifications.cpp
  +++ b/src/node/kernel_notifications.cpp
  @@ -61,2 +61,3 @@ kernel::InterruptResult KernelNotifications::blockTip(SynchronizationState state
       if (m_stop_at_height && index.nHeight >= m_stop_at_height) {
  +        LogInfo("Send shutdown signal after reaching stop height");
           if (!m_shutdown_request()) {
  diff --git a/src/util/tokenpipe.cpp b/src/util/tokenpipe.cpp
  index c982fa6fc4..a5565ebd36 100644
  --- a/src/util/tokenpipe.cpp
  +++ b/src/util/tokenpipe.cpp
  @@ -4,2 +4,3 @@
   #include <util/tokenpipe.h>
  +#include <util/time.h>

  @@ -60,2 +61,3 @@ int TokenPipeEnd::TokenRead()
           ssize_t result = read(m_fd, &token, 1);
  +        UninterruptibleSleep(500ms);
           if (result < 0) {
  ```

  On master: The test fails
  On this pull: The test passes

  Fixes https://github.com/bitcoin/bitcoin/issues/34710

ACKs for top commit:
  kevkevinpal:
    ACK [faa68ed](faa68ed4bd)
  achow101:
    ACK faa68ed4bdce6540f99d23c9b200ca575794a1b2
  w0xlt:
    ACK faa68ed4bdce6540f99d23c9b200ca575794a1b2

Tree-SHA512: 6fcd52b6f6a5fa5a5e41e7b3cf5c733af62af9c60271e7d22c266aca90f2af67f91ffe80a3ed8b8d1a91d001700870f493207998bac988c4e3671a3a0dba7ba7
2026-03-04 11:47:38 -08:00
MarcoFalke
faa68ed4bd
test: Fix intermittent issue in wallet_assumeutxo.py 2026-03-04 17:43:15 +01:00
merge-script
e09b81638b
Merge bitcoin/bitcoin#34219: psbt: validate pubkeys in MuSig2 pubnonce/partial sig deserialization
f51665bee72c26d3f3cc6813b6c02adad5f0af6a psbt: validate pubkeys in MuSig2 pubnonce/partial sig deserialization (tboy1337)

Pull request description:

  The previous fix for invalid MuSig2 pubkeys (bitcoin/bitcoin#34010) only
  addressed the PSBT_IN_MUSIG2_PARTICIPANT_PUBKEYS field. However, the
  PSBT_IN_MUSIG2_PUB_NONCE and PSBT_IN_MUSIG2_PARTIAL_SIG fields also
  deserialize pubkeys without validation, which could lead to crashes when
  invalid pubkeys are processed.

  This commit adds validation to the DeserializeMuSig2ParticipantDataIdentifier
  function to ensure all pubkeys in MuSig2 pubnonce and partial signature
  fields are fully valid elliptic curve points.

  The fix:
  - Validates both aggregate and participant pubkeys in MuSig2 pubnonce and
    partial signature deserialization
  - Throws std::ios_base::failure with descriptive error messages for invalid
    pubkeys
  - Prevents potential crashes from invalid elliptic curve points
  - Maintains backward compatibility for valid PSBTs

  This completes the fix for issues [#33999](https://github.com/bitcoin/bitcoin/issues/33999) and [#34201](https://github.com/bitcoin/bitcoin/issues/34201).

ACKs for top commit:
  rkrux:
    lgtm ACK f51665bee72c26d3f3cc6813b6c02adad5f0af6a
  w0xlt:
    ACK f51665bee7
  darosior:
    utACK f51665bee72c26d3f3cc6813b6c02adad5f0af6a

Tree-SHA512: 8454d77a05aa003a3121b0a5975e8a000125ee0d62343bfa625a75db113358ba7a210ae0376ca1666957b7de7005e06e5a54c95170430ee5e9e1416719b8af53
2026-03-04 15:17:02 +00:00
merge-script
01dcb2fcc5
Merge bitcoin/bitcoin#34715: test: avoid interface_ipc.py race and null pointer dereference
1c1de334e9c0e3b4c72c3f3fe45b1f4df5ce4502 test: avoid interface_ipc.py race and null pointer dereference (Ryan Ofsky)

Pull request description:

  Avoid race condition in `run_deprecated_mining_test` caused by creating and immediately destroying an unused worker thread. This is leading to test failures reported by maflcko in #34711

ACKs for top commit:
  optout21:
    utACK 1c1de334e9c0e3b4c72c3f3fe45b1f4df5ce4502
  l0rinc:
    Tested ACK 1c1de334e9c0e3b4c72c3f3fe45b1f4df5ce4502
  w0xlt:
    ACK 1c1de334e9c0e3b4c72c3f3fe45b1f4df5ce4502
  enirox001:
    ACK 1c1de33

Tree-SHA512: d0af9676a46e991a3f4fda3795c02d1998d30de24991436b8ada425585c6699ff32a7057ca7a0ef2925f782fd3bf73e0381f5d4325e4f1c09f487fce1de49e45
2026-03-04 13:47:03 +00:00
merge-script
2eaf701bc0
Merge bitcoin/bitcoin#34679: ci: Download script_assets_test.json for Windows CI
fa7612f2536b0ef47334105cf657879cdcc3a579 ci: Download script_assets_test.json for Windows CI (MarcoFalke)
7777a13306babd17e6c5956b2efb7c7886e8fc7c test: Move Fetching-print to download_from_url util (MarcoFalke)
faf96286ce69937d141d06f2a71b9fce3a5b89aa test: move-only download_from_url to stand-alone util file (MarcoFalke)
fa0cc1c5a4a760280afd7942fc3b554d1781eb09 test: [doc] Remove outdated comment (MarcoFalke)

Pull request description:

  Fixes https://github.com/bitcoin/bitcoin/issues/34670 by adding a new `download_script_assets` Python helper and calling it.

ACKs for top commit:
  hebasto:
    re-ACK fa7612f2536b0ef47334105cf657879cdcc3a579.
  janb84:
    re ACK fa7612f2536b0ef47334105cf657879cdcc3a579
  hodlinator:
    utACK fa7612f2536b0ef47334105cf657879cdcc3a579

Tree-SHA512: 73c2cb3a31f231174566fb880b82de92734b1679ef000f8d793d774b7e5f5a7b8c7994a3998ca78821115bdc80c16aada69cf596e92c083cf9b9a95c7cee16ea
2026-03-04 10:39:47 +00:00
merge-script
bf9ef4f043
Merge bitcoin/bitcoin#34422: Update libmultiprocess subtree to be more stable with rust IPC client
8fe91f37194edcca1b7dfdd06bd0d4f5b2154e9b test: Updates needed after bitcoin-core/libmultiprocess#240 (Ryan Ofsky)
b7ca3bf061b51108d155283c1ad503c0af7eab0d Squashed 'src/ipc/libmultiprocess/' changes from 1fc65008f7d..1868a84451f (Ryan Ofsky)
1fea3bae5cabc2cd3105bfc277f219454698b00a ipc, test: Add tests for unclean disconnect and thread busy behavior (Ryan Ofsky)

Pull request description:

  Includes:

  - https://github.com/bitcoin-core/libmultiprocess/pull/241
  - https://github.com/bitcoin-core/libmultiprocess/pull/240
  - https://github.com/bitcoin-core/libmultiprocess/pull/244
  - https://github.com/bitcoin-core/libmultiprocess/pull/245

  The main change is https://github.com/bitcoin-core/libmultiprocess/pull/240 which fixes issues with asynchronous requests (https://github.com/bitcoin/bitcoin/issues/33923) and unclean disconnects (https://github.com/bitcoin/bitcoin/issues/34250) that happen with the rust mining client. It also adds tests for these fixes which had some previous review in #34284 (that PR was closed to simplify dependencies between PRs).

  The changes can be verified by running `test/lint/git-subtree-check.sh src/ipc/libmultiprocess` as described in [developer notes](https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#subtrees) and [lint instructions](https://github.com/bitcoin/bitcoin/tree/master/test/lint#git-subtree-checksh)

  Resolves #33923 and #34250

ACKs for top commit:
  Sjors:
    re-ACK 8fe91f37194edcca1b7dfdd06bd0d4f5b2154e9b
  janb84:
    reACK 8fe91f37194edcca1b7dfdd06bd0d4f5b2154e9b
  Eunovo:
    ACK 8fe91f3719

Tree-SHA512: 7e8923610502ebd8603bbea703f82178ab9e956874d394da3451f5268afda2b964d0eeb399a74d49c4123e728a14c27c0296118577a6063ff03b2b8203a257ce
2026-03-03 17:03:56 +00:00
Ryan Ofsky
1c1de334e9 test: avoid interface_ipc.py race and null pointer dereference
Avoid race condition in run_deprecated_mining_test caused by creating and
immediately destroying an unused worker thread. This leads to test failures
reported by maflcko in #34711
2026-03-02 14:22:05 -05:00
Ava Chow
6b0a980de9
Merge bitcoin/bitcoin#34410: test: let connections happen in any order in p2p_private_broadcast.py
da7f70a5322843b70f29456a8bc2227209a0718b test: use port 0 for I2P addresses in p2p_private_broadcast.py (Vasil Dimov)
a8ebcfd34c63f142064b4f5ef7d52299739d4cd6 test: let connections happen in any order in p2p_private_broadcast.py (Vasil Dimov)
67696b207f370e902c8d5fb765e4ff10f6c9e1b4 net: extend log message to include attempted connection type (Vasil Dimov)

Pull request description:

  If the following two events happen:

  * (likely) the automatic 10 initial connections are not made to all
    networks
  * (unlikely) the network-specific logic kicks in almost immediately.
    It is using exponential distribution with a mean of 5 minutes
    (`rng.rand_exp_duration(EXTRA_NETWORK_PEER_INTERVAL)`).

  So if both happen, then the 11th connection may not be the expected
  private broadcast, but a network-specific connection.

  Fix this by retrieving the connection type from
  `destinations_factory()`. This is more flexible because it allows
  connections to happen in any order and does not break if e.g. the 11th
  connection is not the expected first private broadcast.

  This also makes the test run faster:
  before: 19-44 sec
  now: 10-25 sec
  because for example there is no need to wait for the initial 10
  automatic outbound connections to be made in order to proceed.

  Fixes: https://github.com/bitcoin/bitcoin/issues/34387

ACKs for top commit:
  achow101:
    ACK da7f70a5322843b70f29456a8bc2227209a0718b
  andrewtoth:
    ACK da7f70a5322843b70f29456a8bc2227209a0718b
  mzumsande:
    Code Review ACK da7f70a5322843b70f29456a8bc2227209a0718b

Tree-SHA512: 7c293e59c15c148a438e0119343b05eb278205640658c99336d4caf4848c5bae92b48e15f325fa616cbc9d5f394649abfa02406a76e802cffbd3d312a22a6885
2026-03-02 07:47:53 -08:00
rkrux
5c005363a8
test: improve wallet_backup test
Remove the unused functions that were ported many years back.
2026-03-02 14:30:04 +05:30
rkrux
04d9515748
test: improve wallet_assumeutxo func test
Reduce the number of blocks that need to be generated before pruning
the blockchain.

Unload the wallet that was restored in a prior test because it is not
needed anymore after the test.

Both the above steps should reduce the number of chain notifications
that need to be processed by the wallet(s) when an erroneous scenario
of restoring wallet is checked.
2026-03-02 14:28:46 +05:30
Ava Chow
9cad97f6cd
Merge bitcoin/bitcoin#34690: test: Add missing timeout_factor to zmq socket
fa48f8c8655d93e78b32b560a870577909b666d3 test: Add missing timeout_factor to zmq socket (MarcoFalke)

Pull request description:

  Fixes https://github.com/bitcoin/bitcoin/issues/34189

  Otherwise, the test may intermittently fail on slow CI systems that have `--timeout-factor=` properly set.

  It can be tested by running `./bld-cmake/test/functional/interface_zmq.py --timeout-factor=10` with this diff:

  ```diff
  diff --git a/src/validationinterface.cpp b/src/validationinterface.cpp
  index c7be6abc3a..b14cf2aee6 100644
  --- a/src/validationinterface.cpp
  +++ b/src/validationinterface.cpp
  @@ -166,2 +166,3 @@ void ValidationSignals::SyncWithValidationInterfaceQueue()
               LOG_EVENT(fmt, local_name, __VA_ARGS__);           \
  +            UninterruptibleSleep(45ms); \
               event();                                           \
  diff --git a/test/functional/interface_zmq.py b/test/functional/interface_zmq.py
  index 6717007626..eee377daea 100755
  --- a/test/functional/interface_zmq.py
  +++ b/test/functional/interface_zmq.py
  @@ -176,3 +176,3 @@ class ZMQTest (BitcoinTestFramework):
           for sub in subscribers:
  -            sub.socket.set(zmq.RCVTIMEO, recv_timeout*1000)
  +            sub.socket.set(zmq.RCVTIMEO, int(recv_timeout * 1000))

  @@ -271,3 +271,3 @@ class ZMQTest (BitcoinTestFramework):
               [(topic, address) for topic in ["hashblock", "hashtx"]],
  -            recv_timeout=2)  # 2 second timeout to check end of notifications
  +            recv_timeout=0.2)  # 2 second timeout to check end of notifications
           self.disconnect_nodes(0, 1)
  ```

  Before this pull: Test fails with `zmq.error.Again: Resource temporarily unavailable`

  After this pull: Test passes

ACKs for top commit:
  l0rinc:
    code review ACK fa48f8c8655d93e78b32b560a870577909b666d3
  achow101:
    ACK fa48f8c8655d93e78b32b560a870577909b666d3

Tree-SHA512: 5ff8bdd807ff4b644daa634bb7b469da3da3915f58afba63a90e662df99cbebc86636e34e2b1b313c8629773aef2a239fb3025226a84d2ec22f6ecd4cea666c4
2026-02-27 15:26:08 -08:00
Ava Chow
5a6dd7c693
Merge bitcoin/bitcoin#34661: ipc mining: Prevent `Assertion m_node.chainman' failed`` errors on early startup
bbc8f1e0a7e5739f15b2e646a4ace338083309a3 ipc mining: Prevent ``Assertion `m_node.chainman' failed`` errors on early startup (Ryan Ofsky)
a7cabf92e4de83c87f6b9274ddd2fb70712d29f8 init refactor: Only initialize node.notifications one time (Ryan Ofsky)
c8e332cb33594cc307cdf89b6036a0e95c238cd8 init refactor: Remove node.init accesss in AppInitInterfaces (Ryan Ofsky)

Pull request description:

  This fixes ``Assertion `m_node.chainman' failed`` errors first reported https://github.com/bitcoin/bitcoin/issues/33994#issuecomment-3602551596 when IPC mining methods are called before ChainstateManager is loaded.

  The fix works by making the `Init.makeMining` method wait until chainstate data is loaded. It's probably the simplest possible fix but other alternatives like moving the wait to `Mining.createNewBlock` were discussed in the thread https://github.com/bitcoin/bitcoin/pull/34661#discussion_r2848176298 and could be implemented later without changes to clients.

ACKs for top commit:
  Sjors:
    utACK bbc8f1e0a7e5739f15b2e646a4ace338083309a3
  ismaelsadeeq:
    ACK bbc8f1e0a7e5739f15b2e646a4ace338083309a3
  achow101:
    ACK bbc8f1e0a7e5739f15b2e646a4ace338083309a3

Tree-SHA512: 3e2e4e28ccff364b2303efd06ce337a229c28609076638500acb29559f716a15ad99409c6970ce9ad91776d53e3f9d959f1bbbd144ea9a4a2fb578ddbf2da267
2026-02-27 15:07:57 -08:00
MarcoFalke
fa48f8c865
test: Add missing timeout_factor to zmq socket 2026-02-27 14:02:04 +01:00
MarcoFalke
fab51e470e
test: Move valgrind.supp to the other sanitizer_suppressions files 2026-02-27 12:27:49 +01:00
MarcoFalke
fa9cf81d39
test: Add missing resolve() to valgrind.supp file
Normally, when a symlinked test script is executed directly (e.g.,
`./bld-cmake/test/functional/wallet_disable.py`), Python's default
behavior is to resolve the symlink of the script itself, setting
`sys.path[0]` to the directory containing the physical source file.
Consequently, the test framework util.py is imported from the source
tree, and `Path(__file__).parents[3]` correctly resolves to the source
root.

However, `feature_framework_testshell.py` is unique because it manually
inserts `Path(__file__).parent` into `sys.path`. That refers to the
build tree and when importing the test framework util.py, the
`Path(__file__).parents[3]` will incorrectly point to the build
directory instead of the source root.

Use `.resolve()` to ensure the Valgrind suppressions file path is always
calculated relative to the physical source file, regardless of how the
framework was imported.
2026-02-27 12:27:42 +01:00
merge-script
05cd3b00b9
Merge bitcoin/bitcoin#34597: util: Fix UB in SetStdinEcho when ENOTTY
fa6af856341384e4a84c5674e66fe7c1f13dd73c refactor: Use static_cast<decltype(...)> to suppress integer sanitizer warning (MarcoFalke)
fa692974ac2d69e01091f03625cd8a227e310065 util: Fix UB in SetStdinEcho when ENOTTY (MarcoFalke)

Pull request description:

  The call to `tcgetattr` may fail with `ENOTTY`, leaving the struct possibly uninitialized (UB).

  Fix this UB by returning early when `isatty` fails, or when `tcgetattr` fails. (Same for Windows)

  This can be tested by a command that fails valgrind before the change and passes after:

  ```
  echo 'pipe' | valgrind --quiet ./bld-cmake/bin/bitcoin-cli -stdinrpcpass uptime

ACKs for top commit:
  achow101:
    ACK fa6af856341384e4a84c5674e66fe7c1f13dd73c
  l0rinc:
    lightly tested code review ACK fa6af856341384e4a84c5674e66fe7c1f13dd73c
  sedited:
    ACK fa6af856341384e4a84c5674e66fe7c1f13dd73c

Tree-SHA512: 76e2fbcb6c323b17736ee057dbd5e932b2e8cbb7d9fe4488c1dc7ab6ea928a3cde7e72ca0a63f8c8c78871ccb8b669263b712c0e1b530d88f2d45ea41f071201
2026-02-27 10:41:23 +00:00
Hennadii Stepanov
701b8d7148
Merge bitcoin/bitcoin#34609: test: remove appveyor reference in comment
8834e4e86c851c4eb01a7e978cdbde5b3cbd24cc test: remove appveyor reference in comment (Max Edwards)

Pull request description:

  Appveyor is not longer used however the test still requires to check for permissions including 666 as otherwise the tests fail on Windows

  Fixes: #32576

ACKs for top commit:
  maflcko:
    lgtm ACK 8834e4e86c851c4eb01a7e978cdbde5b3cbd24cc
  hebasto:
    ACK 8834e4e86c851c4eb01a7e978cdbde5b3cbd24cc.

Tree-SHA512: 655b44e52da5e0c6c11c79bb4f92c701c6e0e66dce8d7791ccf1d64e4561fe4d1d5f37c1317bead89c88e4d7208a278925168b419482a6be17abf93d0ebc5dfa
2026-02-27 09:28:17 +00:00
Ava Chow
b6b8f8ac55
Merge bitcoin/bitcoin#34562: ThreadPool follow-ups, proactive shutdown and HasReason dependency cleanup
408d5b12e80151feded31c2a5509e2dc5f15edf3 test: include response body in non-JSON HTTP error msg (Matthew Zipkin)
9dc653b3b4f3049b0e742499b762f7c13bb006cc test: threadpool, add coverage for all Submit() errors (furszy)
ce2a984ee324d37ba1dd7c2c4e27e40e0508bedc test: cleanup, use HasReason in threadpool_tests.cpp (l0rinc)
d9c6769d0324b65121935b7c8a285c6421fe74a6 test: refactor, decouple HasReason from test framework machinery (furszy)
dbbb780af02d850a1f9257f18610cfb9de9cb828 test: move and simplify BOOST_CHECK ostream helpers (Hodlinator)
3b7cbcafcb9b318bf1fa00a3499f514c5ebe9bb6 test: ensure Stop() thread helps drain the queue (seduless)
ca101a2315774f0ed65da633ba99899fd0dad740 test: coverage for queued tasks completion after interrupt (furszy)
bf2c607aaa22d253b9367c11b0a198bd4244ad2f threadpool: active-wait during shutdown (furszy)
e88d2744301a434064714f0a21e1395d41ac3984 test: add threadpool Start-Stop race coverage (furszy)
8cd4a4363fb85f5487a19ace82aa0d12d5fab450 threadpool: guard against Start-Stop race (furszy)
9ff1e82e7dbdf31ddf1c534853da4581a1f41bd5 test: cleanup, block threads via semaphore instead of shared_future (l0rinc)

Pull request description:

  A few follow-ups to #33689, includes:

  1) `ThreadPool` active-wait during shutdown:
  Instead of just waiting for workers to finish processing tasks, `Stop()` now helps them actively.
  This speeds up the JSON-RPC and REST server shutdown, resulting in a faster node shutdown when many requests remain unhandled. This wasn't included in the original PR due to the behavior change this introduces.

  2) Decouple `HasReason` from the unit test framework machinery
  This avoids providing the entire unit test framework dependency to low-level tests that only require access to the `HasReason` utility class. Examples are: `reverselock_tests.cpp`, `sync_tests.cpp`, `util_check_tests.cpp`, `util_string_tests.cpp`, `script_parse_tests.cpp` and `threadpool_tests.cpp`. These tests no longer gain access to unnecessary components like the chainstate, node context, caches, etc. It includes l0rinc's `threadpool_tests.cpp` `HasReason` changes.

  3) Include response body in non-JSON HTTP error messages
  Straight from pinheadmz [comment](https://github.com/bitcoin/bitcoin/pull/33689#discussion_r2783817192), it makes debugging CI issues easier.

ACKs for top commit:
  maflcko:
    review ACK 408d5b12e80151feded31c2a5509e2dc5f15edf3 🕗
  achow101:
    ACK 408d5b12e80151feded31c2a5509e2dc5f15edf3
  hodlinator:
    re-ACK 408d5b12e80151feded31c2a5509e2dc5f15edf3

Tree-SHA512: 57aa0ef96886f32bf95a0bd7f87c878d31c9df9e34cb96de615eee703ce0824b5cfdf8f5c9cd19a3594559994295b5810c38c94f5efd6291cbbd83a95473357a
2026-02-26 12:44:11 -08:00
Max Edwards
8834e4e86c test: remove appveyor reference in comment
Appveyor is not longer used however the test still requires to check for
permissions including 666 as otherwise the tests fail on Windows
2026-02-26 17:32:34 +00:00
MarcoFalke
fa7612f253
ci: Download script_assets_test.json for Windows CI 2026-02-26 17:59:34 +01:00
merge-script
bb3ac00cf8
Merge bitcoin/bitcoin#34001: test: fix test_limit_enforcement_package
0a8d303d667cc10a68fd15d799039b9ae26c3315 test: fix test_limit_enforcement_package (Greg Sanders)

Pull request description:

  The current test has a couple issues:

  1) the parent_tx_good is regenerating the exact same transaction that is already in the cluster, so it's resulting in no replacements on submission
  2) once fixed, the additional fee needs to be allocated to the parent transaction in the package, not the child. If the RBF fees are allocated to the child, this triggers the package RBF logic, which requires no in-mempool ancestors to be present.

  Fix the bug and add a few assertions to protect against regressions.

ACKs for top commit:
  bensig:
    ACK 0a8d303d667cc10a68fd15d799039b9ae26c3315
  achow101:
    ACK 0a8d303d667cc10a68fd15d799039b9ae26c3315
  sipa:
    ACK 0a8d303d667cc10a68fd15d799039b9ae26c3315

Tree-SHA512: 0ba184d82edc5a502e9119a6876e80c4564c876fa51ee39293d47bd30c18bf3ded50fbd2f6f2a3394784fad05d8f6370a90682068b30358b077280abd2477252
2026-02-26 16:14:32 +00:00
MarcoFalke
7777a13306
test: Move Fetching-print to download_from_url util
This does not change any behavior.
2026-02-26 16:55:54 +01:00
MarcoFalke
faf96286ce
test: move-only download_from_url to stand-alone util file
Can be reviewed via --color-moved=dimmed-zebra
2026-02-26 16:55:48 +01:00
Matthew Zipkin
408d5b12e8
test: include response body in non-JSON HTTP error msg
Useful for debugging issues.

Co-authored-by: Matias Furszyfer <matiasfurszyfer@protonmail.com>
2026-02-26 11:28:55 -03:00
merge-script
af99643454
Merge bitcoin/bitcoin#34054: net processing: Add ibd check before processing block for txdownloadman
e5f0613503b6973dbc886eba8e999f208d84853b net processing: Check if we are in ibd before processing block for txdownloadman (sedited)
ce8b692897f6aacbe936fe2220e85f23cd83cbf2 Add functional test exercising tx downloadman recently confirmed filter (Lőrinc)

Pull request description:

  Calculating the rolling bloom filters for the txorphanage takes some CPU time from the scheduler thread. This can be observed for example in [this flamegraph](https://bitcoin-dev-tools.github.io/benchcoin/results/pr-172/20066462508/mainnet-default-instrumented-base-flamegraph.svg?x=920203898521&y=780), where handling the filter takes about 2.6% of total time (and most of the scheduler thread's time).

  During ibd the entries in the tx download bloom filter are just continuously rolled over and aren't consumed, since no mempool entries are created by incoming transactions from peers during ibd. The mempool does accept transactions via RPC, or the wallet at the time, however these don't interact with the orphanage and the txdownloadman, because adding anything to those is guarded by IsInitialBlockDownload() checks as well.

  We're usually latching ibd to false a few blocks before catching up to the tip, so this should also not significantly degrade the performance of the filter once fully caught up.

ACKs for top commit:
  l0rinc:
    ACK e5f0613503b6973dbc886eba8e999f208d84853b
  instagibbs:
    ACK e5f0613503b6973dbc886eba8e999f208d84853b
  fjahr:
    Code review ACK e5f0613503b6973dbc886eba8e999f208d84853b

Tree-SHA512: d667e677f5723c438cdf5b34f0f9c1ade7cc1b2e98530c23f14384514daa38217c4e7c3b756194b6831b590a487449c4514b52bf0fb461ae8083061722824270
2026-02-26 10:33:29 +00:00
MarcoFalke
fa0cc1c5a4
test: [doc] Remove outdated comment
The curl requirement has long been removed, when windows support was
added to the script. Also, the build support has long been dropped,
since the project switched from autotools to cmake.
2026-02-26 10:51:25 +01:00
merge-script
7c80301439
Merge bitcoin/bitcoin#33616: policy: don't CheckEphemeralSpends on reorg
33fbaed310a6a37d41d26af8fb34308d088d72c8 policy: don't CheckEphemeralSpends on reorg (Greg Sanders)

Pull request description:

  Similar reasoning to https://github.com/bitcoin/bitcoin/pull/33504

  During a deeper reorg it's possible that a long sequence of dust-having transactions that are connected in a linear fashion. On reorg, this could cause each subsequent "generation" to be rejected. These rejected transactions may contain a large amount of competitive fees via normal means.

  PreCheck based `PreCheckEphemeralSpends` is left in place because we wouldn't have relayed them prior to the reorg.

ACKs for top commit:
  darosior:
    re-ACK 33fbaed310a
  ismaelsadeeq:
    reACK 33fbaed310a6a37d41d26af8fb34308d088d72c8
  sedited:
    ACK 33fbaed310a6a37d41d26af8fb34308d088d72c8

Tree-SHA512: cf0a6945066e9f5f8f9a847394c2c1225facf475a8aa4bc811b436513eff79c0a720d4ad21ba6b0f1cc4dfdd61cf46acb148333ac592b2ee252953732326ad1d
2026-02-25 17:38:13 +01:00
Ryan Ofsky
8fe91f3719 test: Updates needed after bitcoin-core/libmultiprocess#240
Upstream PR bitcoin-core/libmultiprocess#240 fixed various issues which require
updates to python IPC tests. Those changes are made in this commit.
2026-02-25 11:08:49 -05:00
Greg Sanders
33fbaed310 policy: don't CheckEphemeralSpends on reorg 2026-02-25 09:23:45 -05:00
Ryan Ofsky
403523127b
Merge bitcoin/bitcoin#34608: test: Fix broken --valgrind handling after bitcoin wrapper
fa5d478853a88ce7d7095b6abfe8112390298b65 test: valgrind --trace-children=yes for bitcoin wrapper (MarcoFalke)
fa29fb72cb21bec798ddae49b842c78ac84a5a3b test: Remove redundant warning about missing binaries (MarcoFalke)
fa03fbf7e31f384627230e1bc042f7f29c05ff68 test: Fix broken --valgrind handling after bitcoin wrapper (MarcoFalke)

Pull request description:

  Currently, tool_bitcoin.py is failing under `--valgrind`:

  ```sh
  $ ./bld-cmake/test/functional/tool_bitcoin.py --valgrind
  TestFramework (ERROR): Unexpected exception
  Traceback (most recent call last):
    File "./test/functional/test_framework/test_framework.py", line 138, in main
      self.setup()
      ~~~~~~~~~~^^
    File "./test/functional/test_framework/test_framework.py", line 269, in setup
      self.setup_network()
      ~~~~~~~~~~~~~~~~~~^^
    File "./test/functional/tool_bitcoin.py", line 38, in setup_network
      assert all(node.args[:len(node_argv)] == node_argv for node in self.nodes)
             ~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  AssertionError
  ```

  Fix this issue by running `bitcoin` under valgrind.

ACKs for top commit:
  achow101:
    ACK fa5d478853a88ce7d7095b6abfe8112390298b65
  ryanofsky:
    Code review ACK fa5d478853a88ce7d7095b6abfe8112390298b65 just squashing commits since last review (Thanks!)

Tree-SHA512: 503685ac69e1ca3046958655bed4fe6d0aee1525c5ea58ebf098efd0332c0e16f138540baffaf9af1263a8c42ac6b150ed8bca5a5371a3c49802e21957ec6632
2026-02-25 05:03:05 -05:00
Ava Chow
21cd1ba182
Merge bitcoin/bitcoin#34286: test: verify node state after restart in assumeutxo
5cd57943b8adc76ed0b8a75a83f27bc0f971cbef test: verify node state after restart in assumeutxo (Yash Bhutwala)

Pull request description:

  ## Summary

  This PR replaces the TODO comment in `wallet_assumeutxo.py` (line 242) with actual test assertions that verify node and wallet behavior after a restart during assumeutxo background sync.

  ## Changes

  The new tests verify:
  - Two chainstates exist (background validation not complete)
  - Background chainstate is still at `START_HEIGHT`
  - Snapshot chainstate has synced to at least `PAUSE_HEIGHT`
  - Wallets cannot be loaded after restart (expected behavior)
  - Wallet backup from before snapshot height cannot be restored

  ## Motivation

  During implementation, I discovered that **wallets cannot be loaded after a node restart during assumeutxo background sync**. This is expected behavior because:
  - The wallet loading code checks if required blocks are available for rescanning
  - During assumeutxo background sync, blocks before the snapshot are not available
  - This applies to all wallets, including watch-only wallets created at the snapshot height

  This is a valuable test addition because it documents this expected behavior and ensures it doesn't regress. Users should be aware that if they restart their node during assumeutxo background sync, they won't be able to load their wallets until the background sync completes.

  ## Related

  refs #28648

  Addresses the TODO comment that was originally added as part of the assumeutxo wallet test implementation.

ACKs for top commit:
  Bicaru20:
    Code review ACK 5cd57943b8adc76ed0b8a75a83f27bc0f971cbef
  achow101:
    ACK 5cd57943b8adc76ed0b8a75a83f27bc0f971cbef
  fjahr:
    ACK 5cd57943b8adc76ed0b8a75a83f27bc0f971cbef
  sedited:
    ACK 5cd57943b8adc76ed0b8a75a83f27bc0f971cbef
  polespinasa:
    code lgtm ACK 5cd57943b8adc76ed0b8a75a83f27bc0f971cbef

Tree-SHA512: 4a125c5247168da2bbf4d855b4150ca453bb5e4cce1a62e633ce5e43acdc2c58883a6a94dcc46b38f8b4c44206fe42cec4db151a76aded53d8ea433ea5eb2562
2026-02-24 14:32:27 -08:00
Ava Chow
c88c916e72
Merge bitcoin/bitcoin#34653: test: improve txospender index tests code
e8f8b74a46aa075bf6c74c104fd572cc89d3b53b test: index, improve txospenderindex_initial_sync() test code (furszy)
ac3bea07cdceac9e316448a9a5f190848156efd5 test: improve rpc_gettxspendingprevout.py code (furszy)

Pull request description:

  Fixes #34637.

  Was reviewing #34637 and, while reading the new txospender index
  test code for the first time, found it could use some cleanups. Finding
  stuff in there is harder than it should be due to the amount of dup code.

  The first commit cleans up `rpc_gettxspendingprevout.py` by introducing
  helper functions to avoid repeating the same dicts everywhere, using
  for-loops instead of duplicating the same checks for each node, and
  renaming variables to better reflect what they actually represent.

  The second commit reorganizes `txospenderindex_initial_sync()`
  moving index initialization after the test setup phase, since the index
  doesn't participate in it anyway. It adds a post-sync check to catch
  cases where `Sync()` aborted prematurely.

  Note:
  This is just a pre-work for deeper index changes I'm cooking.

ACKs for top commit:
  achow101:
    ACK e8f8b74a46aa075bf6c74c104fd572cc89d3b53b
  sedited:
    Re-ACK e8f8b74a46aa075bf6c74c104fd572cc89d3b53b
  w0xlt:
    reACK e8f8b74a46aa075bf6c74c104fd572cc89d3b53b

Tree-SHA512: 3f7026712ab20a43f376afa28c683dcd5daec8ed1bbf1c36d7ec6bbf231f468d4de74efae4aa8295ff3afb83986286ccaf31c03b34e45fc9971652f064791ed0
2026-02-24 11:12:23 -08:00
Ryan Ofsky
bbc8f1e0a7 ipc mining: Prevent `Assertion m_node.chainman' failed`` errors on early startup
This fixes ``Assertion `m_node.chainman' failed`` errors first reported
https://github.com/bitcoin/bitcoin/issues/33994#issuecomment-3602551596 when
IPC mining methods are called before ChainstateManager is loaded.

The fix works by making the `Init.makeMining` method block until chainstate
data is loaded.
2026-02-24 10:15:14 -05:00
MarcoFalke
fa5d478853
test: valgrind --trace-children=yes for bitcoin wrapper 2026-02-24 13:16:08 +01:00
MarcoFalke
fa29fb72cb
test: Remove redundant warning about missing binaries
The error was added in commit 1ea7e45a1f445d32a2b690d52befb2e63418653b,
because there was an additional confusing `AssertionError: [node 0]
Error: no RPC connection` instead of just a single `FileNotFoundError:
[Errno 2] No such file or directory`.

This is no longer needed on current master.

Also, the test is incomplete, because it was just checking bitcoind and
bitcoin-cli, not any other missing binaries.

Also, after the previous commit, it would not work in combination with
--valgrind.

Instead of trying to make it complete, and work in all combinations,
just remove it, because the already existing error will be clear in any
case.

This can be tested via:

```sh
 ./test/get_previous_releases.py

 mv releases releases_backup
 # Confirm the test is skipped due to missing releases
 ./bld-cmake/test/functional/wallet_migration.py
 # Confirm the test fails due to missing releases
 ./bld-cmake/test/functional/wallet_migration.py --previous-releases
 mv releases_backup releases

 mv ./releases/v28.2 ./releases/v28.2_backup
 # Confirm the test fails with a single FileNotFoundError
 ./bld-cmake/test/functional/wallet_migration.py
 mv ./releases/v28.2_backup ./releases/v28.2
 # Confirm the test runs and passes
 ./bld-cmake/test/functional/wallet_migration.py

 rm ./bld-cmake/bin/bitcoind
 # Confirm the test fails with a single "No such file or directory",
 # testing with and without --valgrind
 ./bld-cmake/test/functional/wallet_migration.py
 ./bld-cmake/test/functional/wallet_migration.py --valgrind
```
2026-02-24 13:15:58 +01:00
MarcoFalke
fa03fbf7e3
test: Fix broken --valgrind handling after bitcoin wrapper
Prior to this commit, tool_bitcoin.py was failing:

```sh
$ ./bld-cmake/test/functional/tool_bitcoin.py --valgrind
TestFramework (ERROR): Unexpected exception
Traceback (most recent call last):
  File "./test/functional/test_framework/test_framework.py", line 138, in main
    self.setup()
    ~~~~~~~~~~^^
  File "./test/functional/test_framework/test_framework.py", line 269, in setup
    self.setup_network()
    ~~~~~~~~~~~~~~~~~~^^
  File "./test/functional/tool_bitcoin.py", line 38, in setup_network
    assert all(node.args[:len(node_argv)] == node_argv for node in self.nodes)
           ~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
```

This commit fixes this issue by running `bitcoin` under valgrind. Also,
it comes with other improvements:

* Drop the outdated valgrind 3.14 requirement, because there is no
  distro that ships a version that old anymore.
* Drop the VALGRIND_SUPPRESSIONS_FILE env var handling, because it was
  presumably never used since it was introduced. Also, the use-case
  seems limited.

Review note:

The set_cmd_args was ignoring the --valgrind test option.

In theory, this could be fixed by refactoring Binaries::node_argv() to
be used here. However, for now, just re-implement the node_argv logic in
set_cmd_args to prepend the valgrind cmd.
2026-02-24 13:15:57 +01:00
Ryan Ofsky
bd9e0e65f5
Merge bitcoin/bitcoin#34184: mining: add cooldown to createNewBlock() immediately after IBD
fcaec2544b32226fd5357a88506fe080058d25bc doc: release note for IPC cooldown and interrupt (Sjors Provoost)
1e82fa498cf4881466f0539146c101242b9dc30d mining: add interrupt() (Sjors Provoost)
a11297a9048e0d910915e1a37b2be467c057a78d mining: add cooldown argument to createNewBlock() (Sjors Provoost)

Pull request description:

  As reported in #33994, connected mining clients will receive a flood of new templates if the node is still going through IBD or catching up on the last 24 hours. This PR fixes that using an _optional_ cooldown mechanism, only applied to `createNewBlock()`.

  First, cooldown waits for IBD. Then, as the tip keeps moving forward, it waits a few seconds to see if the tip updated. If so, it restarts the timer and waits again. The trade-offs for this mechanism are explained below.

  Because this PR changes `createNewBlock()` from a method that returns quickly to one that can block for minutes, we rely on #34568 to fix a bug in our `.capnp` definition, adding the missing `context` to `createNewBlock` (and `checkBlock`).

  The second commit then adds an `interrupt()` method so that clients can cleanly disconnect.

  ---

  ## Rationale

  The cooldown argument is optional, and not used by internal non-IPC code, for two reasons:

  1. The mechanism wreaks havoc on the functional test suite, which would require very careful mock time handling to work around. But that's pointless, because only IPC clients need it.
  2. It needs to be optional for IPC clients too, because in some situations, like a signet with only one miner, waiting for IBD can mean being stuck forever.

  The reason it's only applied to `createNewBlock()` is that this is the first method called by clients; `waitNext()` is a method on the interface returned by `createNewBlock()`, at which point the cooldown is done.

  After IBD, we wait N seconds if the header is N blocks ahead of the tip, with a minimum of 3 and a maximum of 20 seconds. The minimum waiting time is short enough that it shouldn't be annoying or confusing for someone manually starting up a client. While the maximum should be harmless if it happens spuriously (which it shouldn't).

  If the minimum wait is too short, clients get a burst of templates, as observed in the original issue. We can't entirely rule this out without a lot of additional complexity (like scanning our own log file for heuristics). This PR should make it a lot less likely, and thanks to the IBD wait also limit it to one day worth of blocks (`-maxtipage`).

  Some test runs on an M4 MacBook Pro, where I had a node catch up on the last few days worth of blocks:

  <img width="872" height="972" alt="Schermafbeelding 2026-02-04 om 18 21 17" src="https://github.com/user-attachments/assets/7902a0f2-0e0b-4604-9688-cec2da073261" />

  As the chart shows, sometimes it takes longer than 3 seconds. But it turns out that in all those cases there were quite a few headers ahead of the tip. It also demonstrates that it's important to first wait for IBD, because it's less likely a random tip update takes longer than 20 seconds.

  - modified sv2-apps: https://github.com/Sjors/sv2-apps/tree/2026/02/cooldown
  - test script: https://gist.github.com/Sjors/feb6122c97acc2b9e6d66b168614609c#file-run_mainnet_pool_loop-zsh
  - chart script: https://gist.github.com/Sjors/feb6122c97acc2b9e6d66b168614609c#file-tip_interval_charts-py

ACKs for top commit:
  ryanofsky:
    Code review ACK fcaec2544b32226fd5357a88506fe080058d25bc. Only changes since last review were removing two cooldown arguments from the mining IPC test to simplify it
  enirox001:
    ACK fcaec2544b

Tree-SHA512: 08b75470f7c5c80a583a2fdb918fad145e7d5377309e5c599f67fc0d0e3139d09881067ba50c74114f117e69da17ee50666838259491691c031b1feaf050853f
2026-02-24 06:54:17 -05:00
Ava Chow
ab8a7af742
Merge bitcoin/bitcoin#34646: Fix two issues in p2p_private_broadcast.py
c462e54f9df431434e6480d8293060645468d3ab test: don't always assert NUM_PRIVATE_BROADCAST_PER_TX broadcasts (Vasil Dimov)
3710566305e569bed8458809f0dedc83420b7de2 test: move abortprivatebroadcast test at the end (Vasil Dimov)

Pull request description:

  _test: move abortprivatebroadcast test at the end_

  The piece of `p2p_private_broadcast.py` which tests the correctness of
  `abortprivatebroadcast` issues a new `sendrawtransaction` call. That
  call schedules up to 3 new connections: peer=13, peer=14 and possibly
  peer=15 before it gets aborted.

  These up to 3 in-the-process-of-opening private broadcast connections
  have `CNode::m_connected` set early - when the `CNode` object is
  created. Later in the test the mock time is advanced by 20 minutes and
  those "old" connections pick a transaction for rebroadcast but that
  triggers `PRIVATE_BROADCAST_MAX_CONNECTION_LIFETIME` immediately:

  ```
  2026-02-21T13:28:14.209766Z [privbcast] [net.cpp:4006] [CNode] [net] Added connection peer=20
  2026-02-21T13:28:14.309792Z (mocktime: 2026-02-21T13:48:14Z) [msghand] [net.cpp:4074] [PushMessage] [net] sending inv (37 bytes) peer=20
  2026-02-21T13:28:14.309801Z (mocktime: 2026-02-21T13:48:14Z) [msghand] [net_processing.cpp:5745] [SendMessages] [privatebroadcast] Disconnecting: did not complete the transaction send within 180 seconds, peer=20
  ```

  This prematurely stops the private broadcast connection and results in
  a failure like:

  ```
  AssertionError: ... not({} == {'ping': 1, 'tx': 1})
  ```

  ---

  _test: don't always assert NUM_PRIVATE_BROADCAST_PER_TX broadcasts_

  In `p2p_private_broadcast.py` in the function `check_broadcasts()` we
  should assert that the broadcast was done to `broadcasts_to_expect`
  peers, not to `NUM_PRIVATE_BROADCAST_PER_TX`. This is because in the
  "Basic" test we check the first broadcast manually because it is done to
  `nodes[1]` and then check the other two by
  `check_broadcasts(..., NUM_PRIVATE_BROADCAST_PER_TX - 1, ...)`.
  The first broadcast might not have fully concluded by the time we call
  `check_broadcasts()` to check the remaining 2.

  Demanding always `NUM_PRIVATE_BROADCAST_PER_TX` can lead to:

  ```
  Traceback (most recent call last):
    File "/home/vd/gh/bitcoin/bitcoin/test/functional/test_framework/test_framework.py", line 142, in main
      self.run_test()
      ~~~~~~~~~~~~~^^
    File "/tmp/build/clang22/test/functional/p2p_private_broadcast.py", line 347, in run_test
      self.check_broadcasts("Basic", txs[0], NUM_PRIVATE_BROADCAST_PER_TX - 1, NUM_INITIAL_CONNECTIONS + 1)
      ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/tmp/build/clang22/test/functional/p2p_private_broadcast.py", line 313, in check_broadcasts
      assert_greater_than_or_equal(sum(1 for p in peers if "received" in p), NUM_PRIVATE_BROADCAST_PER_TX)
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/vd/gh/bitcoin/bitcoin/test/functional/test_framework/util.py", line 94, in assert_greater_than_or_equal
      raise AssertionError("%s < %s" % (str(thing1), str(thing2)))
  AssertionError: 2 < 3
  ```

ACKs for top commit:
  l0rinc:
    ACK c462e54f9df431434e6480d8293060645468d3ab
  achow101:
    ACK c462e54f9df431434e6480d8293060645468d3ab
  andrewtoth:
    ACK c462e54f9df431434e6480d8293060645468d3ab

Tree-SHA512: 0de8d0eae079eeedc3bfad39df8129a8fa0d7734bdc03b4fb3e520a2f13a187d68118ffc210556af125d634f0ff51a1b081b34a023ac68a1c6a0caf541cecb91
2026-02-23 13:45:25 -08:00
merge-script
9581a0a5b1
Merge bitcoin/bitcoin#34615: mempool: expose optimality of mempool to log / rpc
a9e59f7d955f995078b3e0bf3b527c03c74fef8d rpc: add optimal result to getmempoolinfo (Greg Sanders)
a3fb3dd55c2326452a5085add220bd3682052352 mempool: log if we detect a non-optimal mempool (Greg Sanders)

Pull request description:

  Post-SFL #34023 I don't think we expect the mempool to be unordered for long periods of time. If we consider it likely to be a serious regression in production, it would be useful to expose the fact  that the mempool is not known to be optimal.

  1. do a MEMPOOL log after any `DoWork()` returns false, meaning non-optimal
  2. expose it via getmempoolinfo, by calling `DoWork(0)`, which does nothing but return known-optimality

  I'm not wedded to either approach, I just think something is better than nothing for the next release.

ACKs for top commit:
  ajtowns:
    ACK a9e59f7d955f995078b3e0bf3b527c03c74fef8d
  ismaelsadeeq:
    reACK a9e59f7d955f995078b3e0bf3b527c03c74fef8d [c89b93b95..a9e59f7d95](c89b93b958..a9e59f7d95) fixed typo, added more logging for block/reorg additions to mempool, and fixed brittle test case.
  sedited:
    ACK a9e59f7d955f995078b3e0bf3b527c03c74fef8d
  sipa:
    ACK a9e59f7d955f995078b3e0bf3b527c03c74fef8d

Tree-SHA512: 1560ad21cc1606df7279c102f35f61d4555c0ac920f02208b2a6eb89b14d7e22befb6d7f510a00a9074c2f9931f32e9af86bcea3a8dd9a1d947b0398c84666dd
2026-02-23 17:10:20 +01:00