Commit Graph

8065 Commits

Author SHA1 Message Date
Ava Chow
fe3d2be1d6 Merge bitcoin/bitcoin#32757: net: Fix Discover() not running when using -bind=0.0.0.0:port
bb00fd2142 test: use dynamic ports and add coverage in feature_bind_port_discover (b-l-u-e)
4f19508ae7 test: dont connect nodes in feature_bind_port_discover (b-l-u-e)
b8827ce619 net: Fix Discover() not running when using -bind=0.0.0.0:port (b-l-u-e)

Pull request description:

  This PR fixes two related issues with address discovery when using explicit bind addresses in Bitcoin Core:

    -  #31293
    -  #31336

  When using `-bind=0.0.0.0:port` (or `-bind=::`), the `Discover()` function was not being executed because the code only checked the `bind_on_any` flag. This led to two problems:
  - The node would not discover its own local addresses if an explicit "any" bind was used.
  - The functional test `feature_bind_port_discover.py` would fail, as it expects local addresses to be discovered in these cases.

  This PR:
  1. Checks both `bind_on_any` and any bind addresses using `IsBindAny()`
     Ensures `Discover()` runs when binding to 0.0.0.0 or ::, even if specified explicitly.
  2. Ensures correct address discovery
     The node will now discover its own addresses when using explicit "any" binds, matching user expectations and fixing the test.
  3. Maintains backward compatibility
     The semantic meaning of `bind_on_any` is preserved as defined in `net.h`:
     > "True if the user did not specify -bind= or -whitebind= and thus we should bind on 0.0.0.0 (IPv4) and :: (IPv6)"
  4. Updates the test to use dynamic ports
     The functional test `feature_bind_port_discover.py` is updated to use dynamic ports instead of hardcoded ones, improving reliability.

  References

  - Implementation follows the approach proposed in my [review comment on #31492](https://github.com/bitcoin/bitcoin/pull/31492#issuecomment-2941773645).

  Closes #31293

  The #31336 has the overall test failure and requires both this PR and #33362 to be fully resolved.

ACKs for top commit:
  NicolaLS:
    tested ACK bb00fd2142
  pinheadmz:
    ACK bb00fd2142
  vasild:
    ACK bb00fd2142
  achow101:
    ACK bb00fd2142

Tree-SHA512: 6f1b0b29cc539e4b49b3594f9ad70be90cfff28e31497a8b85e11d8a2509faaa8ca803e542ea3280588ece5a065c4c54193cec87cad221f1abae34d8b13cfdc5
2026-04-09 14:26:40 -07:00
merge-script
2b541eeb36 Merge bitcoin/bitcoin#34495: Replace boost signals with minimal compatible implementation
242b0ebb5c btcsignals: use a single shared_ptr for liveness and callback (Cory Fields)
b12f43a0a8 signals: remove boost::signals2 from depends and vcpkg (Cory Fields)
a4b1607983 signals: remove boost::signals2 mentions in linters and docs (Cory Fields)
375397ebd9 signals: remove boost includes where possible (Cory Fields)
091736a153 signals: re-add forward-declares to interface headers (Cory Fields)
9958f4fe49 Revert "signals: Temporarily add boost headers to bitcoind and bitcoin-node builds" (Cory Fields)
34eabd77a2 signals: remove boost compatibility guards (Cory Fields)
e60a0b9a22 signals: Add a simplified boost-compatible implementation (Cory Fields)
63c68e2a3f signals: add signals tests (Cory Fields)
edc2978058 signals: use an alias for the boost::signals2 namespace (Cory Fields)
9ade3929aa signals: remove forward-declare for signals (Cory Fields)
037e58b57b signals: use forwarding header for boost signals (Cory Fields)
2150153f37 signals: Temporarily add boost headers to bitcoind and bitcoin-node builds (Cory Fields)
fd5e9d9904 signals: Use a lambda to avoid connecting a signal to another signal (Cory Fields)

Pull request description:

  This drops our dependency on `boost::signals2`, leaving `boost::multi_index` as the only remaining boost dependency for bitcoind.

  `boost::signals2` is a complex beast, but we only use a small portion of it. Namely: it's a way for multiple subscribers to connect to the same event, and the ability to later disconnect individual subscribers from that event.

  `btcsignals` adheres to the subset of the `boost::signals2` API that we currently use, and thus is a drop-in replacement. Rather than implementing a complex `slot` tracking class that we never used anyway (and which was much more useful in the days before std::function existed), callbacks are simply wrapped directly in `std::function`s.

  The new tests work with either `boost::signals2` or the new `btcsignals` implementation. Reviewers can verify
  functional equivalency by running the tests in the commit that introduces them against `boost::signals2`, then again with `btcsignals`.

  The majority of the commits in this PR are preparation and cleanup. Once `boost::signals2` is no longer needed, it is removed from depends. Additionally, a few CMake targets no longer need boost includes as they were previously only required for signals.

  I think this is actually pretty straightforward to review. I kept things simple, including keeping types unmovable/uncopyable where possible rather than trying to define those semantics. In doing so, the new implementation has even fewer type requirements than boost, which I believe is due to a boost bug. I've opened a PR upstream for that to attempt to maintain parity between the implementations.

  See individual commits for more details.

  Closes #26442.

ACKs for top commit:
  fjahr:
    Code review ACK 242b0ebb5c
  maflcko:
    re-review ACK 242b0ebb5c 🎯
  w0xlt:
    reACK 242b0ebb5c

Tree-SHA512: 9a472afa4f655624fa44493774a63b57509ad30fb61bf1d89b6d0b52000cb9a1409a5b8d515a99c76e0b26b2437c30508206c29a7dd44ea96eb1979d572cd4d4
2026-04-09 16:25:47 +08:00
Ava Chow
80572c7555 Merge bitcoin/bitcoin#34158: torcontrol: Remove libevent usage
1401011f71 test: Add test for exceeding max line length in torcontrol (Fabian Jahr)
84c1f32071 test: Add torcontrol coverage for PoW defense enablement (Fabian Jahr)
7dff9ec298 test: Add test for partial message handling in torcontrol (Fabian Jahr)
569383356e test: Add simple functional test for torcontrol (Fabian Jahr)
4117b92e67 fuzz: Improve torcontrol fuzz test (Fabian Jahr)
b1869e9a2d torcontrol: Move tor controller into node context (Fabian Jahr)
eae193e750 torcontrol: Remove libevent usage (Fabian Jahr)
8444efbd4a refactor: Get rid of unnecessary newlines in logs (Fabian Jahr)
6bcb60354e refactor: Modernize member variable names in torcontrol (Fabian Jahr)
a36591d194 refactor: Use constexpr in torcontrol where possible (Fabian Jahr)

Pull request description:

  This is part of the effort to remove the libevent dependency from our code base: https://github.com/bitcoin/bitcoin/issues/31194

  The current approach tries to reuse existing code and follows roughly similar design decisions. It replaces the libevent-based async I/O with blocking I/O utilizing the existing `Sock` and `CThreadInterrupt`. The controller runs in a dedicated thread.

  There are some optional code modernizations thrown in made along the way (namings, constexpr etc.). These are not strictly necessary but make the end result with the new code more consistent.

ACKs for top commit:
  achow101:
    ACK 1401011f71
  janb84:
    re ACK 1401011f71
  pinheadmz:
    ACK 1401011f71

Tree-SHA512: 167f1d98a634524568cb1d723e7bdb7234bade2c5686586caf2accea58c3308f83a32e0705edc570d6db691ae578a91e474ae4773f126ec2e1619d3adf7df622
2026-04-08 15:15:12 -07:00
Alfonso Roman Zubeldia
b555a0b789 test: remove macOS REDUCE_EXPORTS exception workaround
The underlying issue was fixed in bitcoin-core/libmultiprocess#268.

Remove the workaround that accepted degraded error messages on Darwin.
2026-04-07 17:40:43 -03:00
Fabian Jahr
1401011f71 test: Add test for exceeding max line length in torcontrol
Also deduplicates the repetitive tor mock setup for each test case a bit.

Co-authored-by: janb84 <githubjanb.drainer976@passmail.net>
2026-04-03 22:00:30 +02:00
Fabian Jahr
84c1f32071 test: Add torcontrol coverage for PoW defense enablement 2026-04-03 22:00:29 +02:00
Fabian Jahr
7dff9ec298 test: Add test for partial message handling in torcontrol 2026-04-03 22:00:29 +02:00
Fabian Jahr
569383356e test: Add simple functional test for torcontrol 2026-04-03 22:00:29 +02:00
Cory Fields
a4b1607983 signals: remove boost::signals2 mentions in linters and docs
The documented example is no longer relevant, so remove it rather than updating
it to mention btcsignals.
2026-04-03 18:20:50 +00:00
Ava Chow
fa1f4feac4 Merge bitcoin/bitcoin#34965: cli: Return more helpful authentication errors
257769a7ce qa: Improve error message (Hodlinator)
20a94c1524 cli: Clearer error messages on authentication failure (Hodlinator)
84c3f8d325 refactor(rpc): GenerateAuthCookieResult -> AuthCookieResult (Hodlinator)

Pull request description:

  Increases precision of error messages to help the user correct authentication issues.

  Inspired by #34935.

ACKs for top commit:
  davidgumberg:
    utACK 257769a7ce
  maflcko:
    review ACK 257769a7ce 🦇
  achow101:
    ACK 257769a7ce
  janb84:
    concept ACK 257769a7ce

Tree-SHA512: 1799db4b2c0ab3b67ed3d768da08c6be4f4beaad91a77406884b73950b420c8264c70b8e60a26a9e6fac058370f6accdb73c821d19bebb6edfbc8d7b84d01232
2026-04-02 15:55:28 -07:00
Ava Chow
8cc690ea9b Merge bitcoin/bitcoin#34379: wallet: fix gethdkeys RPC for descriptors with partial xprvs
43c528aba9 wallet, test: update `gethdkeys` functional test (rkrux)
6e3a0afc2f wallet: fix `gethdkeys` RPC for descriptors with partial xprvs (rkrux)

Pull request description:

  Fixes #34378

  A non-watch-only wallet allows to import descriptors with partial private keys, eg: a multisig descriptor with one private key and one public key. In case an xpub is imported in any such descriptors whose private key the wallet doesn't have, then the `gethdkeys` RPC throws an unhandled error like below when the private keys are requested.

  This fix ensures that such calls are properly handled by conditionally finding the corresponding xprv and the related functional test is accordingly updated.

  ```
  ➜ bitcoincli -named gethdkeys private=true
  error code: -1
  error message:
  map::at:  key not found
  ```

ACKs for top commit:
  achow101:
    ACK 43c528aba9
  w0xlt:
    ACK 43c528aba9
  Eunovo:
    Tested ACK 43c528aba9

Tree-SHA512: 106e02ee368a3fa94d116f54f2fa71f9886e4753e331b91ce13a346559d5497ef6cd7ddaa8736fcfe1a7ac427a44d647fb75e523eb72f917fa866adbe0dbad30
2026-04-01 14:32:49 -07:00
MarcoFalke
fa955af618 lint: Clarify rmtree/remove_all error message with preferred alternatives 2026-04-01 10:21:52 +02:00
merge-script
5deed3deab Merge bitcoin/bitcoin#34958: test: mining: add coverage for GBT's "coinbasevalue" result field
12c3c3f81d test: mining: add coverage for GBT's "coinbasevalue" result field (Sebastian Falbesoner)

Pull request description:

  This PR adds missing coverage for the "coinbasevalue" result field of the `getblocktemplate` RPC call. Specifically, the introduced test checks that the value is set to claim the full block reward (subsidy plus fees). Can be verified with the following patch, which succeeds on master and fails on the PR branch:

  ```diff
  diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
  index a935810d91..ba9ac9dadb 100644
  --- a/src/rpc/mining.cpp
  +++ b/src/rpc/mining.cpp
  @@ -998,7 +998,7 @@ static RPCHelpMan getblocktemplate()
       result.pushKV("previousblockhash", block.hashPrevBlock.GetHex());
       result.pushKV("transactions", std::move(transactions));
       result.pushKV("coinbaseaux", std::move(aux));
  -    result.pushKV("coinbasevalue", block.vtx[0]->vout[0].nValue);
  +    result.pushKV("coinbasevalue", block.vtx[0]->vout[0].nValue - 1);
       result.pushKV("longpollid", tip.GetHex() + ToString(nTransactionsUpdatedLast));
       result.pushKV("target", hashTarget.GetHex());
       result.pushKV("mintime", GetMinimumTime(pindexPrev, consensusParams.DifficultyAdjustmentInterval()));

  ```

  I'm not sure how relevant this field is nowadays in real-world mining scenarios (we use it for the signet miner at least), but it seems useful to have a test for it anyways. Stumbled upon this while looking at https://github.com/bitcoin-inquisition/bitcoin/pull/111.

ACKs for top commit:
  maflcko:
    lgtm ACK 12c3c3f81d
  Sjors:
    ACK 12c3c3f81d

Tree-SHA512: ae10f63c99b21cf7771feefe3d0e47b2e0d511aceb344cf11efa9182d78f2960f1e079797b8a36db110a3c54acb27a3706413a710a74bf56aed29ea162a6aab2
2026-03-31 23:57:26 +08:00
Hodlinator
257769a7ce qa: Improve error message 2026-03-31 12:25:06 +02:00
Hodlinator
20a94c1524 cli: Clearer error messages on authentication failure
Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
2026-03-31 12:25:05 +02:00
Ava Chow
c97ac44c34 Merge bitcoin/bitcoin#32297: bitcoin-cli: Add -ipcconnect option
4565cff72c bitcoin-gui: Implement missing Init::makeMining method (Ryan Ofsky)
fbea576c26 test: add interface_ipc_cli.py testing bitcoin-cli -ipcconnect (Ryan Ofsky)
0448a19b1b ipc: Improve -ipcconnect error checking (Ryan Ofsky)
8d614bfa47 bitcoin-cli: Add -ipcconnect option (Ryan Ofsky)
6a54834895 ipc: Expose an RPC interface over the -ipcbind socket (Ryan Ofsky)
df76891a3b refactor: Add ExecuteHTTPRPC function (Ryan Ofsky)
3cd1cd3ad3 ipc: Add MakeBasicInit function (Ryan Ofsky)

Pull request description:

  This implements an idea from sipa in https://github.com/bitcoin/bitcoin/issues/28722#issuecomment-2807026958 to allow `bitcoin-cli` to connect to the node via IPC instead of TCP, if the ENABLE_IPC cmake option is enabled and the node has been started with `-ipcbind`.

  This feature can be tested with:

  ```
  build/bin/bitcoin-node -regtest -ipcbind=unix -debug=ipc
  build/bin/bitcoin-cli -regtest -ipcconnect=unix -getinfo
  ```

  The -ipconnect parameter can also be omitted, since this change also makes `bitcoin-cli` prefer IPC over HTTP by default, and falling back to HTTP if an IPC connection can't be established.

  ---

  This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/issues/28722).

ACKs for top commit:
  achow101:
    ACK 4565cff72c
  pinheadmz:
    ACK 4565cff72c
  enirox001:
    Tested ACK 4565cff72c

Tree-SHA512: cb0dc521d82591e4eb2723a37ae60949309a206265e0ccfbee1f4d59b426b770426fafa1e842819a2fa27322ecdfcd226f31da70f91c2c31b8095e1380666f1f
2026-03-30 15:12:04 -07:00
Sebastian Falbesoner
12c3c3f81d test: mining: add coverage for GBT's "coinbasevalue" result field
Add missing test coverage for the `getblocktemplate` RPC call
"coinbasevalue" field, specifically that it is set to claim the
full block reward.
2026-03-30 19:05:08 +02:00
merge-script
550f603025 Merge bitcoin/bitcoin#34382: test: wallet: Check fallbackfee default argument behavior.
3dcdb2b9ba test: wallet: Warning for excessive fallback fee. (David Gumberg)
6664e41e56 test: wallet: -fallbackfee default is 0 (David Gumberg)
d28c989243 test: wallet: refactor: fallbackfee extract common send failure checks. (David Gumberg)

Pull request description:

  In an unmerged branch of #32636 (097e00f907) I unintentionally broke default `-fallbackfee` behavior, but this was not caught by any tests. See https://github.com/bitcoin/bitcoin/pull/32636#discussion_r2706102550.

  Something like the following diff does not cause any test failures on master despite causing a behavior change:

  ```diff
  diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
  index bc27018cd2..079610fba0 100644
  --- a/src/wallet/wallet.cpp
  +++ b/src/wallet/wallet.cpp
  @@ -3048,24 +3048,24 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
       if (const auto arg{args.GetArg("-fallbackfee")}) {
           std::optional<CAmount> fallback_fee = ParseMoney(*arg);
           if (!fallback_fee) {
               error = strprintf(_("Invalid amount for %s=<amount>: '%s'"), "-fallbackfee", *arg);
               return nullptr;
           } else if (fallback_fee.value() > HIGH_TX_FEE_PER_KB) {
               warnings.push_back(AmountHighWarn("-fallbackfee") + Untranslated(" ") +
                                  _("This is the transaction fee you may pay when fee estimates are not available."));
           }
           walletInstance->m_fallback_fee = CFeeRate{fallback_fee.value()};
  +        // Disable fallback fee in case value was set to 0, enable if non-null value
  +        walletInstance->m_allow_fallback_fee = walletInstance->m_fallback_fee.GetFeePerK() != 0;
       }

  -    // Disable fallback fee in case value was set to 0, enable if non-null value
  -    walletInstance->m_allow_fallback_fee = walletInstance->m_fallback_fee.GetFeePerK() != 0;
  ```

  This PR adds a functional test check that when no `-fallbackfee` argument is set and fee estimation is not possible, that sending fails because `-fallbackfee` is disabled by default.

ACKs for top commit:
  maflcko:
    review ACK 3dcdb2b9ba 🐞
  w0xlt:
    reACK 3dcdb2b9ba
  ismaelsadeeq:
    reACK 3dcdb2b9ba 👾

Tree-SHA512: 715625673a781ba3ddfed25f0836b01c2197480bd56732fd1ce548e8969573c2a36601de0b8913b3b79a47b8149022aabcf409b62297e7c2c47b68a8843e6570
2026-03-30 19:50:19 +08:00
Ava Chow
21da421b42 Merge bitcoin/bitcoin#34439: qa: Drop recursive deletes from test code, add lint checks.
0d1301b47a test: functional: drop rmtree usage and add lint check (David Gumberg)
8bfb422de8 test: functional: drop unused --keepcache argument (David Gumberg)
a7e4a59d6d qa: Remove all instances of `remove_all` except test cleanup (David Gumberg)

Pull request description:

  Both `fs::remove_all` and `shutil::rmtree()` are a bit dangerous, and most of their uses are not necessary, this PR removes most instances of both.

  `remove_all()` is still used in in `src/test/util/setup_common.cpp` as part of `BasicTestingSetup::BasicTestingSetup`'s constructor and destructor, and it is used in the kernel test code's [`TestDirectory`](4ae00e9a71/src/test/kernel/test_kernel.cpp (L100-L112)):

  734899a4c4/src/test/kernel/test_kernel.cpp (L100-L112)

  In both cases, `remove_all` is likely necessary, but the kernel's test code is RAII, ideally `BasicTestingSetup` could be made similar in a follow-up or in this PR if reviewers think it is important.

  Similarly in the python code, most usage was unnecessary, but there are a few places where `rmtree()` was necessary, I have added sanity checks to make sure these are inside of the `tmpdir` before doing recursive delete there.

ACKs for top commit:
  achow101:
    ACK 0d1301b47a
  hodlinator:
    ACK 0d1301b47a
  sedited:
    ACK 0d1301b47a

Tree-SHA512: da8ca23846b73eff0eaff61a5f80ba1decf63db783dcd86b25f88f4862ae28816fc9e2e9ee71283ec800d73097b1cfae64e3c5ba0e991be69c200c6098f24d6e
2026-03-26 13:05:01 -07:00
David Gumberg
3dcdb2b9ba test: wallet: Warning for excessive fallback fee. 2026-03-25 19:51:09 -07:00
David Gumberg
6664e41e56 test: wallet: -fallbackfee default is 0
Also check more RPC's for success and check that we are using
`-fallbackfee`.
2026-03-25 19:51:07 -07:00
David Gumberg
d28c989243 test: wallet: refactor: fallbackfee extract common send failure checks. 2026-03-25 19:48:45 -07:00
David Gumberg
0d1301b47a test: functional: drop rmtree usage and add lint check
`shutil.rmtree` is dangerous because it recursively deletes. There are
not likely to be any issues with it's current uses, but it is possible
that some of the assumptions being made now won't always be true, e.g.
about what some of the variables being passed to `rmtree` represent.

For some remaining uses of rmtree that can't be avoided for now, use
`cleanup_dir` which asserts that the recursively deleted folder is a
child of the the `tmpdir` of the test run. Otherwise,
`tempfile.TemporaryDirectory` should be used which does it's own
deleting on being garbage collected, or old fashioned unlinking and
rmdir in the case of directories with known contents.
2026-03-24 16:06:35 -07:00
David Gumberg
8bfb422de8 test: functional: drop unused --keepcache argument
At the time this was added in  #10197, building the test cache took 21
seconds, as described in that PR, but this is no longer true, as
demonstrated by running the functional test framework with and without
the --keepcache arguments on master prior to this commit:

```
hyperfine   --warmup 1  --export-markdown results.md --runs 3 \
    -n 'without --keepcache'    './build/test/functional/test_runner.py -j $(nproc)' \
    -n 'with --keepcache'       './build/test/functional/test_runner.py -j $(nproc) --keepcache'
```

| Command               | Mean [s]       | Min [s] | Max [s] | Relative |
|:----------------------|---------------:|--------:|---:|---:|
| `without --keepcache` | 76.373 ± 3.058 | 74.083  | 79.846  | 1.00 |
| `with --keepcache`    | 77.384 ± 1.836 | 75.952  | 79.454  | 1.01 ± 0.05 |

As a consequence, this argument can be removed from the test runner and
this also has the benefit of being able to use an RAII-like
`tempfile.TemporaryDirectory` instead of having to clean up the cache
manually at the end of test runs.

bitcoin/bitcoin#10197: https://github.com/bitcoin/bitcoin/pull/10197
2026-03-24 16:03:02 -07:00
David Gumberg
a7e4a59d6d qa: Remove all instances of remove_all except test cleanup
Adds a lint check for `remove_all()`

`fs::remove_all()`/`std::filesystem::remove_all()` is extremely
dangerous, all user-facing instances of it have been removed, and it
also deserves to be removed from the places in our test code where it is
being used unnecessarily.
2026-03-24 16:03:02 -07:00
Ava Chow
bfc84eb2ea Merge bitcoin/bitcoin#33259: rpc, logging: add backgroundvalidation to getblockchaininfo
25f69d970a release note (Pol Espinasa)
af629821cf test: add background validation test for getblockchaininfo (Pol Espinasa)
a3d6f32a39 rpc, log: add backgroundvalidation to getblockchaininfo (Pol Espinasa)
5b2e4c4a88 log: update progress calculations for background validation (Pol Espinasa)

Pull request description:

  `getblockchaininfo` returns `verificationprogress=1` and `initialblockdownload=false` even if there's background validation.
  This PR adds information about background validation to rpc `getblockchaininfo` in a similar way to `validationprogress` does.

  If assume utxo was used the output of a "sync" node performing background validation:
  ```
  $ ./build/bin/bitcoin-cli getblockchaininfo
  ...
    "mediantime": 1756933740,
    "verificationprogress": 1,
    "initialblockdownload": false,
    "backgroundvalidation": {
      "snapshotheight": 880000,
      "blocks": 527589,
      "bestblockhash": "0000000000000000002326308420fa5ccd28a9155217f4d1896ab443d84148fa",
      "mediantime": 1529076654,
      "chainwork": "0000000000000000000000000000000000000000020c92fab9e5e1d8ed2d8dbc",
      "verificationprogress": 0.2815790617966284
    },
    "chainwork": "0000000000000000000000000000000000000000df97866c410b0302954919d2",
    "size_on_disk": 61198817285,

  ...
  ```

  If assume utxo was not used the progress is hidden:
  ```
  $ ./build/bin/bitcoin-cli getblockchaininfo
  ...
    "mediantime": 1756245700,
    "verificationprogress": 1,
    "initialblockdownload": false,
    "chainwork": "00000000000000000000000000000000000000000000000000000656d6bb052b",
    "size_on_disk": 3964972194,
  ...
  ```

  The PR also updates the way we estimate the verification progress returning a 100% on the snapshot block and not on the tip as we will stop doing background validation when reaching it.

ACKs for top commit:
  fjahr:
    ACK 25f69d970a
  danielabrozzoni:
    ACK 25f69d970a
  achow101:
    ACK 25f69d970a
  sedited:
    ACK 25f69d970a

Tree-SHA512: 5e5e08fd39af5f764962b862bc6d8257b0d2175fe920d4b79dc5105578fd4ebe08aee2fe9bfa5c9cad5d7610197a435ebaac0de23e7a5efa740dfea031a8a9d4
2026-03-24 14:36:09 -07:00
Ava Chow
4ecf473c36 Merge bitcoin/bitcoin#34727: test: Add IPC wake-up test and reuse mining context
ad75b147b5 test: scale IPC mining wait timeouts by timeout_factor (Enoch Azariah)
e7a918b69a test: verify IPC error handling for invalid coinbase (Enoch Azariah)
63684d6922 test: move make_mining_ctx to ipc_util.py (Enoch Azariah)
4ada575d6c test: verify createNewBlock wakes promptly when tip advances (Enoch Azariah)

Pull request description:

  This is a follow-up to implement a couple of test improvements discussed in recent IPC PRs and issues.

  - adds a test to `interface_ipc_mining.py` to verify that `createNewBlock` wakes up immediately when the tip advances, rather than waiting for the cooldown timer to expire (https://github.com/bitcoin/bitcoin/pull/34184#discussion_r2842239399).
  - moves `make_mining_ctx` into `ipc_util.py` so it can be reused across the IPC tests instead of duplicating the setup code (https://github.com/bitcoin/bitcoin/pull/34422#discussion_r2852445430).
  - adds a test case to verify that providing an invalid coinbase to `submitSolution` returns a remote exception instead of crashing the node, closing the loop on the issue reported in #33341.
  - scales IPC wait timeouts using the test suite's `timeout_factor` to prevent spurious failures in heavily loaded CI environments, capping extended waits to avoid test runner hangs (bitcoin-core/libmultiprocess#253 (comment)).

  Closes #33341.

ACKs for top commit:
  Sjors:
    ACK ad75b147b5
  achow101:
    ACK ad75b147b5
  sedited:
    ACK ad75b147b5

Tree-SHA512: 812aa64c03657761f06707e6a15b8b435ab7c75717a6748a919fcbcae317128e18403b0c1bddd4cdad877d286e69db52389633e4012faaa656acc01939091719
2026-03-24 13:34:30 -07:00
Pol Espinasa
af629821cf test: add background validation test for getblockchaininfo 2026-03-24 15:51:24 +01:00
Pol Espinasa
a3d6f32a39 rpc, log: add backgroundvalidation to getblockchaininfo 2026-03-24 15:51:24 +01:00
merge-script
16613c9de9 Merge bitcoin/bitcoin#34857: test: Remove confusing assert_debug_log in wallet_reindex.py
fa30951af5 test: Remove confusing assert_debug_log in wallet_reindex.py (MarcoFalke)

Pull request description:

  The `wallet_reindex.py` test has many issues:

  * It uses a `assert_debug_log` to ensure the reindex happened via `initload thread exit`. However, no other test uses this pattern, because `restart_node` already achieves the same internally (via `getmempoolinfo.loaded`).
  * The `assert_debug_log` may intermittently fail, because the `initload thread exit` log may happen at any time after the inner thread function (lambda) is fully done.
  * The test uses an `node.syncwithvalidationinterfacequeue()` without any explanation. No other test uses this pattern, because all wallet RPCs, in particular the next one (`gettransaction`) call it internally (via `BlockUntilSyncedToCurrentChain`).

  Fix all issues by removing all confusing, useless, and brittle calls.

  Example failure: https://github.com/bitcoin/bitcoin/actions/runs/22671604602/job/65716917459?pr=34419#step:11:22339

  ```
  ...
   node0 2026-03-04T13:55:23.784715Z (mocktime: 2026-03-04T22:15:17Z) [scheduler] [validationinterface.cpp:185] [operator()] [validation] UpdatedBlockTip: new block hash=24b5cc4c1352bc8841ecbe67a43827acd1adc609bd26b2691e80e89b97eff135 fork block hash=24a4dc8be9c157ac31913397d8bb1653900e12b55539c234039559fdeb6dd2fb (in IBD=true)
   node0 2026-03-04T13:55:23.784851Z (mocktime: 2026-03-04T22:15:17Z) [initload] [util/thread.cpp:22] [TraceThread] initload thread exit
   test  2026-03-04T13:55:23.813824Z TestFramework (ERROR): Unexpected exception:
                                     Traceback (most recent call last):
                                       File "/home/admin/actions-runner/_work/_temp/test/functional/test_framework/test_framework.py", line 142, in main
                                         self.run_test()
                                       File "/home/admin/actions-runner/_work/_temp/build/test/functional/wallet_reindex.py", line 90, in run_test
                                         self.birthtime_test(node, miner_wallet)
                                       File "/home/admin/actions-runner/_work/_temp/build/test/functional/wallet_reindex.py", line 64, in birthtime_test
                                         with node.assert_debug_log(expected_msgs=["initload thread exit"]):
                                       File "/usr/lib/python3.12/contextlib.py", line 144, in __exit__
                                         next(self.gen)
                                       File "/home/admin/actions-runner/_work/_temp/test/functional/test_framework/test_node.py", line 607, in assert_debug_log
                                         self._raise_assertion_error(f'Expected message(s) {remaining_expected!s} '
                                       File "/home/admin/actions-runner/_work/_temp/test/functional/test_framework/test_node.py", line 241, in _raise_assertion_error
                                         raise AssertionError(self._node_msg(msg))
                                     AssertionError: [node 0] Expected message(s) ['initload thread exit'] not found in log:
  ```

  Diff to reproduce failure:

  ```diff
  diff --git a/src/util/thread.cpp b/src/util/thread.cpp
  index 0fde73c4e2..de4c05e752 100644
  --- a/src/util/thread.cpp
  +++ b/src/util/thread.cpp
  @@ -8,2 +8,3 @@
   #include <util/log.h>
  +#include <util/time.h>
   #include <util/threadnames.h>
  @@ -21,2 +22,3 @@ void util::TraceThread(std::string_view thread_name, std::function<void()> threa
           thread_func();
  +    UninterruptibleSleep(999ms);
           LogInfo("%s thread exit", thread_name);
  diff --git a/test/functional/wallet_reindex.py b/test/functional/wallet_reindex.py
  index 71ab69e01b..649df4301a 100755
  --- a/test/functional/wallet_reindex.py
  +++ b/test/functional/wallet_reindex.py
  @@ -62,2 +62,3 @@ class WalletReindexTest(BitcoinTestFramework):

  +        import time; time.sleep(1) # Wait for previous initload thread to exit fully
           # Reindex and wait for it to finish
  ```

  Before on master: Test fails
  After on this pull: Test passes

ACKs for top commit:
  rkrux:
    ACK fa30951af5 if this PR needs to be backported.

Tree-SHA512: 1e6599511e09b5b9ac4aed96a6b1b8239d5dc63b164fc0c163b6f9f5bc72c1c61f72ad8256a01875208d825af46d057c4d9de61758002f256388ddb324006bb5
2026-03-24 12:06:25 +08:00
Ava Chow
696b5457c5 Merge bitcoin/bitcoin#34667: test: ensure FastWalletRescanFilter is correctly updated during scanning
92287ae753 test/wallet: ensure FastWalletRescanFilter is updated during scanning (Novo)

Pull request description:

  Part of https://github.com/bitcoin/bitcoin/pull/34400

  On master, the `wallet_fast_rescan.py` test will pass even if the fast rescan filters are not updated during wallet rescan. This PR improves the `wallet_fast_rescan.py` test so that this no longer happens. Testers can verify by applying this diff
  ```diff
  diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
  index 63dab29972..f7d6c5f84a 100644
  --- a/src/wallet/wallet.cpp
  +++ b/src/wallet/wallet.cpp
  @@ -1898,7 +1898,7 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc

           bool fetch_block{true};
           if (fast_rescan_filter) {
  -            fast_rescan_filter->UpdateIfNeeded();
  +            // fast_rescan_filter->UpdateIfNeeded();
               auto matches_block{fast_rescan_filter->MatchesBlock(block_hash)};
               if (matches_block.has_value()) {
                   if (*matches_block) {

  ```
  and running the `wallet_fast_rescan.py` test. The test will pass on master but fail on this PR.

ACKs for top commit:
  achow101:
    ACK 92287ae753
  Bortlesboat:
    re-ACK 92287ae753
  rkrux:
    tACK 92287ae
  ismaelsadeeq:
    Tested ACK 92287ae753

Tree-SHA512: bcd66db0be6604b084230fa3d3aa8d99f5a1a679a7a92592a5e8962abbcf35a14fb6883f25c9e8e6c4799893b774b1c6766876587417f35c4190562ef5ad39fb
2026-03-23 17:34:47 -07:00
merge-script
a703c70bb8 Merge bitcoin/bitcoin#34589: ci: Temporarily use clang in valgrind tasks
fa70b9ebaa ci: Temporarily use clang in valgrind tasks (MarcoFalke)
faf3ef4ee7 ci: Clarify why valgrind task has gui disabled (MarcoFalke)
fadb77169b test: Scale feature_dbcrash.py timeout with factor (MarcoFalke)

Pull request description:

  valgrind currently does not work on GCC compiled executables, due to an upstream bug. https://bugs.kde.org/show_bug.cgi?id=472329

  So temporarily switch to clang, so that a long term solution can be figured out in the meantime.

ACKs for top commit:
  l0rinc:
    ACK fa70b9ebaa
  fanquake:
    ACK fa70b9ebaa - also checked that it doesn't currently work under aarch64.

Tree-SHA512: 2e7c7a709311efa7bf29c3f9b1db60886b189b2d2bfebb516062163d65f0d7e8de3b6fc21c94cd62f6bd7e786e9c36fba55c4bae956b849851eb8b08e772c03e
2026-03-23 12:35:14 +08:00
Ava Chow
483769c046 Merge bitcoin/bitcoin#26201: Remove Taproot BIP 9 deployment
74f71c5054 Remove Taproot activation height (Sjors Provoost)

Pull request description:

  Drop `DEPLOYMENT_TAPROOT` from `consensus.vDeployments`.

  Now that the commit (7c08d81e11) which changes taproot to be enforced for all blocks is included in v24.0, it seems a good time to remove no longer needed non-consensus code.

  Clarify what is considered a `BuriedDeployment`.

  We drop taproot from `getdeploymentinfo` RPC, rather than mark it as `buried`, because this is not a buried deployment in the sense of [BIP 90](https://github.com/bitcoin/bips/blob/master/bip-0090.mediawiki). This is because the activation height has been completely removed from the code, unlike the hardcoded `DEPLOYMENT_SEGWIT` height which is still relied on.[^1]

  See discussion in #24737 and #26162.

  [^1]: `DEPLOYMENT_SEGWIT` is used in `IsBlockMutated` to determine if witness data is allowed, it's used for [BIP147](https://github.com/bitcoin/bips/blob/master/bip-0147.mediawiki), to trigger `NeedsRedownload()` for users who upgraded after a decade, and for a few other things.

ACKs for top commit:
  ajtowns:
    reACK 74f71c5054
  achow101:
    ACK 74f71c5054
  sedited:
    Re-ACK 74f71c5054
  darosior:
    utACK 74f71c5054

Tree-SHA512: 217e0ee2e144ccfb04cf012f45b75d08f8541287a5531bd18aa81e38bad2f38d28b772137f471c46b63875840ec044cb61a2a832e3a9e89a6183e8ab36b1b9c9
2026-03-20 15:22:24 -07:00
Enoch Azariah
ad75b147b5 test: scale IPC mining wait timeouts by timeout_factor
The IPC mining tests (interface_ipc_mining.py) currently use
hardcoded timeouts (e.g., 1000ms, 60000ms) for operations like
waitTipChanged and waiting for block templates. In heavily
loaded CI environments, such as those running sanitizers with
high parallelism, these hardcoded timeouts can be too short,
leading to spurious test failures and brittleness.

This commit multiplies these timeout variables by the test
suite's global `self.options.timeout_factor`. This ensures that
the IPC wait conditions scale appropriately when the test suite
is run with a higher timeout factor, making the tests robust
against slow execution environments.

Addresses CI brittleness observed in bitcoin-core/libmultiprocess#253.
2026-03-20 19:55:28 +01:00
Enoch Azariah
e7a918b69a test: verify IPC error handling for invalid coinbase
Add a test case to interface_ipc_mining.py to verify that the IPC
server correctly handles and reports serialization errors rather than
crashing the node.

This covers the scenario where submitSolution is called with data
that cannot be deserialized, as discussed in #33341

Also introduces the assert_capnp_failed helper in ipc_util.py to
cleanly handle macOS-specific Cap'n Proto exception strings, and
refactors an existing block weight test to use it.
2026-03-20 19:55:28 +01:00
Enoch Azariah
63684d6922 test: move make_mining_ctx to ipc_util.py
The async routines in both interface_ipc.py and interface_ipc_mining.py
contain redundant code to initialize the mining proxy object.

Move the make_mining_ctx helper into test_framework/ipc_util.py and
update both test files to use it. This removes the boilerplate and
prevents code duplication across the IPC test suite.
2026-03-20 19:55:28 +01:00
Enoch Azariah
4ada575d6c test: verify createNewBlock wakes promptly when tip advances
This adds a complementary test to interface_ipc_mining.py to ensure
that createNewBlock() wakes up immediately once submitblock advances
the tip, rather than needlessly waiting for the cooldown timer to
expire on its own.
2026-03-20 19:55:15 +01:00
merge-script
f80bf5128d Merge bitcoin/bitcoin#34869: tests: applied PYTHON_GIL to the env for every test
b14f2c76a1 tests: applied PYTHON_GIL to the env for every test (kevkevinpal)

Pull request description:

  ## Summay
  If a user is running python3.14.0t they would see a warning log that would fail the integration test suite.

  This change adds `PYTHON_GIL=1` to the env when running our functional test suite to ensure that the tests pass for users running python3.14.0t and are not manually setting `PYTHON_GIL=1`.

  This resolves https://github.com/bitcoin/bitcoin/issues/33582

  ### Tests before and after
  #### Before
  ```
  ./build/test/functional/test_runner.py interface_ipc.py
  Temporary test directory at /tmp/test_runner_₿_🏃_20260319_142327
  Remaining jobs: [interface_ipc.py]
  1/1 - interface_ipc.py failed, Duration: 2 s

  stdout:
  2026-03-19T18:23:27.330123Z TestFramework (INFO): PRNG seed is: 4933091336597497631
  2026-03-19T18:23:27.380917Z TestFramework (INFO): Initializing test directory /tmp/test_runner_₿_🏃_20260319_142327/interface_ipc_0
  2026-03-19T18:23:28.625944Z TestFramework (INFO): Running echo test
  2026-03-19T18:23:28.635856Z TestFramework (INFO): Running mining test
  2026-03-19T18:23:28.648965Z TestFramework (INFO): Running deprecated mining interface test
  2026-03-19T18:23:28.653589Z TestFramework (INFO): Running disconnect during BlockTemplate.waitNext
  2026-03-19T18:23:28.821124Z TestFramework (INFO): Running thread busy test
  2026-03-19T18:23:29.195589Z TestFramework (INFO): Stopping nodes
  2026-03-19T18:23:29.299135Z TestFramework (INFO): Cleaning up /tmp/test_runner_₿_🏃_20260319_142327/interface_ipc_0 on exit
  2026-03-19T18:23:29.299329Z TestFramework (INFO): Tests successful

  stderr:
  <frozen importlib._bootstrap>:491: RuntimeWarning: The global interpreter lock (GIL) has been enabled to load module 'capnp.lib.capnp', which has not declared that it can run safely without the GIL. To override this behavior and keep the GIL disabled (at your own risk), run with PYTHON_GIL=0 or -Xgil=0.

  TEST             | STATUS    | DURATION

  interface_ipc.py | ✖ Failed  | 2 s

  ALL              | ✖ Failed  | 2 s (accumulated)
  Runtime: 2 s

  ```
  #### After
  ```
  ./build/test/functional/test_runner.py interface_ipc.py
  Temporary test directory at /tmp/test_runner_₿_🏃_20260319_142221
  Remaining jobs: [interface_ipc.py]
  1/1 - interface_ipc.py passed, Duration: 2 s

  TEST             | STATUS    | DURATION

  interface_ipc.py | ✓ Passed  | 2 s

  ALL              | ✓ Passed  | 2 s (accumulated)
  Runtime: 2 s
  ```

ACKs for top commit:
  maflcko:
    review ACK b14f2c76a1
  fanquake:
    ACK b14f2c76a1

Tree-SHA512: e5862d2e9211154d4834c88864e8c4e35de195986511ba151871d39266d177e0718960b28020e815ef6b353a0d82800b7cb68e9a6dee82fc85f12d8705e787a8
2026-03-20 11:18:31 +08:00
Ava Chow
bc1c540920 Merge bitcoin/bitcoin#29060: Policy: Report debug message why inputs are non standard
d8f4e7caf0 doc: add release notes (ismaelsadeeq)
248c175e3d test: ensure `ValidateInputsStandardness` optionally returns debug string (ismaelsadeeq)
d2716e9e5b policy: update `AreInputsStandard` to return error string (ismaelsadeeq)

Pull request description:

  This PR is another attempt at  #13525.

  Transactions that fail `PreChecks` Validation due to non-standard inputs now  returns invalid validation state`TxValidationResult::TX_INPUTS_NOT_STANDARD` along with a debug error message.

  Previously, the debug error message for non-standard inputs do not specify why the inputs were considered non-standard.
  Instead, the same error string, `bad-txns-nonstandard-inputs`, used for all types of non-standard input scriptSigs.

  This PR updates the `AreInputsStandard`  to include the reason why inputs are non-standard in the debug message.
  This improves the `Precheck` debug message to be more descriptive.

  Furthermore, I have addressed all remaining comments from #13525 in this PR.

ACKs for top commit:
  instagibbs:
    ACK d8f4e7caf0
  achow101:
    ACK d8f4e7caf0
  sedited:
    Re-ACK d8f4e7caf0

Tree-SHA512: 19b1a73c68584522f863b9ee2c8d3a735348667f3628dc51e36be3ba59158509509fcc1ffc5683555112c09c8b14da3ad140bb879eac629b6f60b8313cfd8b91
2026-03-19 15:43:18 -07:00
kevkevinpal
b14f2c76a1 tests: applied PYTHON_GIL to the env for every test 2026-03-19 15:21:33 -04:00
MarcoFalke
fa30951af5 test: Remove confusing assert_debug_log in wallet_reindex.py 2026-03-19 07:55:38 +01:00
merge-script
81bf3ebff7 Merge bitcoin/bitcoin#34852: test: Fix intermittent issue in feature_assumeutxo.py
faf71d6cb4 test: [refactor] Use verbosity=0 named arg (MarcoFalke)
99996f6c06 test: Fix intermittent issue in feature_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/33635)
  * Using `-stopatheight` is expensive, because it requires two restarts, making the test slow

  Fix all issues by using `dumb_sync_blocks` and avoid the two restarts.

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

  Diff to test:

  ```diff
  diff --git a/src/util/tokenpipe.cpp b/src/util/tokenpipe.cpp
  index c982fa6fc4..1dc12ea1d5 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(999ms);
           if (result < 0) {
  ```

  On master: Test fails
  On this pull: Test passes

ACKs for top commit:
  fjahr:
    Code review ACK faf71d6cb4
  sedited:
    ACK faf71d6cb4

Tree-SHA512: 8f7705d2b3f17881134d6e696207fe6710d7c4766f1b74edf5a40b4a6eb5e0f4b12be1adfabe56934d27abc46e789437526bcdd26e4f8172f41a11bc6bed8605
2026-03-19 14:04:18 +08:00
merge-script
33eaf910bd Merge bitcoin/bitcoin#34820: test: Use asyncio.SelectorEventLoop() over deprecated asyncio.WindowsSelectorEventLoopPolicy(), move loop creation
fa050da980 test: Move event loop creation to network thread (MarcoFalke)
fa9168ffcd test: Use asyncio.SelectorEventLoop() over deprecated asyncio.WindowsSelectorEventLoopPolicy() (MarcoFalke)

Pull request description:

  It is deprecated according to https://docs.python.org/3.14/library/asyncio-policy.html#asyncio.WindowsSelectorEventLoopPolicy The replacement exists since python 3.7

  Also, move the event loop creation to happen in the thread that runs the loop.

ACKs for top commit:
  l0rinc:
    ACK fa050da980
  sedited:
    ACK fa050da980

Tree-SHA512: dce25596a04e8f133630d84c03a770185a81b1bcd0aae975f0dbdd579d22b7b79a9b1172abf46c61d0845d3f5ab4a6414fa0f17c59f0ea0f6fa9bdcac085a2a7
2026-03-18 18:24:35 +01:00
MarcoFalke
faf71d6cb4 test: [refactor] Use verbosity=0 named arg
This is less confusing than the verbose=0 alias.
2026-03-18 16:16:22 +01:00
MarcoFalke
99996f6c06 test: Fix intermittent issue in feature_assumeutxo.py 2026-03-18 16:13:09 +01:00
MarcoFalke
fa70b9ebaa ci: Temporarily use clang in valgrind tasks
valgrind currently does not work on GCC -O2 compiled executables, which
contain std::optional use, due to an upstream bug. See
https://bugs.kde.org/show_bug.cgi?id=472329

One workaround could be to use -O1. However, that seems brittle, as
variantions of the bug were seen with -O1 as well.

So temporarily use clang in the valgrind CI tasks, because this also
allows to drop a false-positive suppression for:
-DCMAKE_CXX_FLAGS='-Wno-error=array-bounds'

Also, update the comment in contrib/valgrind.supp to mention the
background:

* GCC -O2 wasn't tested with the suppressions file, due to the mentioned
  bug.
* Clang-17 (or later) on aarch64 wasn't tested due to bug
  https://github.com/bitcoin/bitcoin/issues/29635 and the minimum
  supported clang version is clang-17 right now.
* GUI isn't tested, because it requires a debug build, see the prior
  commit.

This means the only tested config right now is the one mentioned in the
suppression file.
2026-03-18 10:27:44 +01:00
fanquake
f55c891a65 lint: more reuse of SHARED_EXCLUDED_SUBTREES 2026-03-16 23:24:52 +08:00
fanquake
8864917d8b lint: add missing ipc/test to grep_boost_fixture_test_suite 2026-03-16 23:24:52 +08:00
fanquake
ecefc12927 lint: fix lint issue in lint script
Replace the tabs with spaces.
2026-03-16 23:24:52 +08:00
fanquake
ee8c22eb6a contrib: fix whitespace issues in scripts 2026-03-16 23:24:48 +08:00