Commit Graph

49262 Commits

Author SHA1 Message Date
Vasil Dimov
9a8ef9b0a3 test: SOCKS5 proxy: expect that connection may be reset during handshake
The client (e.g. `bitcoind`) may open a connection to the proxy and
close it in the middle of the SOCKS5 handshake if it is restarted for
example. Log these as debug messages instead of full blown Python
exception error messages with backtraces.
2026-06-17 08:36:58 +02:00
Vasil Dimov
eb3208364a test: SOCKS5 proxy: expect that connection may be reset when forwarding
The `forward_sockets()` function used by the SOCKS5 proxy forwards data
between two connected sockets. It might happen that one of those sockets
gets closed/reset abruptly, without sending EOF first. This is to be
expected if e.g. `bitcoind` is shutdown and shouldn't result in noisy
harmless messages like:

```
2026-06-03T13:23:56.966859Z TestFramework.socks5 (ERROR): socks5 request handling failed (running True)
Traceback (most recent call last):
  File ".../socks5.py", line 199, in handle
    forward_sockets(self.conn, conn_to, self.wakeup_socket_pair[1], self.serv)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../socks5.py", line 76, in forward_sockets
    data = s.recv(4096)
ConnectionResetError: [Errno 104] Connection reset by peer
```

Instead turn this into a debug log message with a nice prefix containing
enough information to identify the two forwarded sockets.
2026-06-17 08:36:57 +02:00
merge-script
d0b8d445fb Merge bitcoin/bitcoin#35455: fuzz: improve dbwrapper_concurrent_reads performance
1ce9e26239 fuzz: improve dbwrapper_concurrent_reads performance (Andrew Toth)

Pull request description:

  The recently merged fuzz harness targeting concurrent reads suffers from poor performance and memory leaks (https://github.com/bitcoin/bitcoin/pull/34866#issuecomment-4614323925).

  Fix this by
  - using a global thread pool instead of a local one per iteration
  - reduce thread count to 8 from 16
  - use a std::map oracle to check results inline instead of reading from the db to get a baseline and storing results

ACKs for top commit:
  marcofleon:
    reACK 1ce9e26239
  l0rinc:
    ACK 1ce9e26239
  sedited:
    ACK 1ce9e26239

Tree-SHA512: 2e532caf246f389105e4a9b487496386d1fe9add7b27fba9ecbbf51a432ef493765ad7095288dd7e0a896860ff150d89ecb6afb8baf311a4af94d8e01b77dba5
2026-06-11 09:47:12 +02:00
merge-script
e0fb41fd2a Merge bitcoin/bitcoin#35489: fuzz: test non-max descriptor satisfaction weight
526aae3768 fuzz: test non-max descriptor satisfaction weight (woltx)

Pull request description:

  The descriptor fuzz target is intended to exercise descriptor satisfaction-size estimation for solvable descriptors.

  It currently calls `MaxSatisfactionWeight(true)` twice, so the `false` branch is never exercised.

  This PR changes `max_sat_nonmaxsig` to call `MaxSatisfactionWeight(false)`, so fuzzing covers both branches.

ACKs for top commit:
  brunoerg:
    reACK 526aae3768
  sedited:
    ACK 526aae3768

Tree-SHA512: 029750d76c1d50f5c6a008b826a0a2dc187feb420be96401d2e15747b44901341d32ac75e86a5e10585919d419c607800d8e117a1cbce50b1db40121d3610f9c
2026-06-11 09:22:29 +02:00
merge-script
50e9f2ad33 Merge bitcoin/bitcoin#35497: test: FakeNodeClock follow-ups in unit tests
fa03852e9c test: Use SteadyClockContext in pcp_tests (MarcoFalke)
fa3716c439 test: Use FakeNodeClock in more places (MarcoFalke)
fae9623c8d test: Add FakeNodeClock m_clock to TestChain100Setup (MarcoFalke)

Pull request description:

  This switches the remaining cases in the unit tests from `SetMockTime` to `FakeNodeClock` for clarity, as explained in the commit messages.

ACKs for top commit:
  frankomosh:
    crACK fa03852e9c. This PR continues the FakeNodeClock migration from #35114.
  sedited:
    ACK fa03852e9c
  w0xlt:
    ACK fa03852e9c

Tree-SHA512: 4d4f1ff170ce8cfa606a6dc0dc47ff8b89e2db0d0188daeabbbaa422df00143fd99426905adcff1fd152a00ebf8a9004e312cbc77a1d078e57895d5f1334a3b2
2026-06-11 09:11:08 +02:00
Ava Chow
809f909e58 Merge bitcoin/bitcoin#35451: lint: Grep for AUTO test suites in file names
f6bdbcf79d lint: Grep for `AUTO` test suites in file names (rustaceanrob)

Pull request description:

  Tests without a fixture did not have their file names linted because the grep matches on `BOOST_FIXTURE`. Updates to match `BOOST_FIXTURE` or `BOOST_TEST`.

ACKs for top commit:
  l0rinc:
    ACK f6bdbcf79d
  achow101:
    ACK f6bdbcf79d
  hebasto:
    ACK f6bdbcf79d.

Tree-SHA512: dd1763b6ac90fa87b7e0d2faa56d1c7beedb1e2d37d16367c60ebcadd155f5955113fff7cf5c0ce5eaa9e63aeeb67ffff2c8e081f7c23978cb072207f072f2ef
2026-06-10 14:49:00 -07:00
Ava Chow
530e1f5290 Merge bitcoin/bitcoin#34636: node: allocate index caches proportional to usage patterns
5a2e359213 clarify blockfilterindex cache allocation rationale (Sebastian van Staa)
d06dabf26b node: allocate index caches proportional to usage patterns (Sebastian van Staa)

Pull request description:

  The current cache allocation for optional indexes (txindex, txospenderindex, blockfilterindex) uses a sequential total_cache / 8 approach where each index gets 1/8 of the remaining budget after the previous index has been allocated. This means the order in which indexes appear in the code silently determines how much cache each one gets.

  |Index|Current share of total|
  |---|---|
  |txindex|~12%|
  |txospenderindex|~11%|
  |blockfilterindex|~10%|

  This is unintuitive, undocumented, and probably doesn't reflect actual usage patterns. This PR replaces the sequential 1/8 allocation with explicit percentages based on how the indexes are typically used. The current values are an educated guess, and subject to further benchmark and research of typical client usage patterns.

  |Index|Allocation|Rationale|
  |---|---|---|
  |txindex |10% |Serves getrawtransaction RPCs with mostly unique lookups across the entire blockchain: low cache reuse|
  |txospenderindex|5%|Serves gettxspendingprevout RPCs with very specific outpoint queries: likely the least repetitive access pattern|
  |blockfilterindex|5%|Serves BIP 157 light clients that repeatedly query the same recent blocks: highest cache benefit|

  UPDATE: blockfilterindex allocation changed from 15% to 5% in the course of the discussion

  This is a continuation of  the related discussion: https://github.com/bitcoin/bitcoin/pull/24539#discussion_r2809088034 and https://github.com/bitcoin/bitcoin/pull/31483.

  Further feedback and input is very much appreciated.

ACKs for top commit:
  fjahr:
    ACK 5a2e359213
  rustaceanrob:
    ACK 5a2e359213
  achow101:
    ACK 5a2e359213
  sedited:
    ACK 5a2e359213

Tree-SHA512: 69be2b0c274b975da58aef2513c3042be8a4c8acf0a86af86b962d4ebfd8cf90bcb1d9251d53995652b4825d0d1da24aabe92cdada9148c627690f8ad2ad8a29
2026-06-10 14:24:06 -07:00
Ava Chow
8598ec2204 Merge bitcoin/bitcoin#35221: BIP 434 Support: Peer feature negotiation
da74ff9ca4 test: Add functional test for BIP434 (Fabian Jahr)
01b8a117d2 test_framework: BIP 434 support (Anthony Towns)
6a129983c9 BIP434: FEATURE message support (Anthony Towns)
3210fc477a net: Add AdvertisedVersion() for protocol version advertised to a peer (Anthony Towns)
94ed45427c serialize: add LimitedVectorFormatter (Anthony Towns)
1b3f776ebb serialize: string_view serialization (Anthony Towns)

Pull request description:

  Adds support for [BIP 434](https://github.com/bitcoin/bips/blob/master/bip-0434.md).

ACKs for top commit:
  fjahr:
    ACK da74ff9ca4
  pseudoramdom:
    ACK da74ff9ca4
  achow101:
    ACK da74ff9ca4
  darosior:
    ACK da74ff9ca4
  w0xlt:
    reACK da74ff9ca4
  sedited:
    ACK da74ff9ca4

Tree-SHA512: 74aa01b9b296a1a498b3aa119af6db906453f0809ec7ae271fc26690491c3f5677bf2cd03817caf9e287f5b3bc977768cdfefbe74ed2dd0da1cd339e043fe010
2026-06-10 13:40:45 -07:00
woltx
526aae3768 fuzz: test non-max descriptor satisfaction weight
Also assert that the availability of the satisfaction weight estimate
does not depend on the signature-size assumption, and that assuming
non-max-size signatures never increases the estimate.
2026-06-10 13:37:23 -07:00
Andrew Toth
1ce9e26239 fuzz: improve dbwrapper_concurrent_reads performance 2026-06-10 14:31:03 -04:00
Ava Chow
fb47793b99 Merge bitcoin/bitcoin#35168: validation: Don't add pruned blocks to m_blocks_unlinked on startup
3f44f9aef7 test: Add coverage for m_blocks_unlinked invariant in LoadBlockIndex (marcofleon)
0e4b0bacec validation: Don't add pruned blocks to m_blocks_unlinked on startup (marcofleon)

Pull request description:

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

  The `m_blocks_unlinked` map keeps track of blocks that have transactions but whose parent (or any ancestor) does not. This happens when a block is received before its parent, or during a reorg, when `FindMostWorkChain()` encounters a block whose ancestors were pruned.

  The bug this PR addresses is a rare interaction of these two cases, which happens on startup when `BlockManager::LoadBlockIndex()` rebuilds `m_blocks_unlinked`. The check there only considers whether a block has transactions, and pruned blocks keep `nTx > 0` but clear `BLOCK_HAVE_DATA`. So if there's a pruned block on a stale fork whose parent has no transactions, that block is added to `m_blocks_unlinked` without having data on disk. This violates an [assertion](ad3f73862b/src/validation.cpp (L5352)) in `CheckBlockIndex()`.

  Get rid of this unintended case by gating on `BLOCK_HAVE_DATA` before adding to `m_blocks_unlinked`.

ACKs for top commit:
  achow101:
    ACK 3f44f9aef7
  sedited:
    Re-ACK 3f44f9aef7
  stratospher:
    ACK 3f44f9a. nice!

Tree-SHA512: 275d0f8588524c01c4e701c8635973cd4a086d31c10d252a498c1ef668bdb3895ba1cae265dbe88f8983ca7ddbe32247824753c7c1f49e59c8bce0df377b784c
2026-06-10 11:30:50 -07:00
Ava Chow
53b836cdce Merge bitcoin/bitcoin#34028: p2p: Prevent integer overflow in LocalServiceInfo::nScore
2189a6f5f2 p2p: Saturate LocalServiceInfo::nScore updates at INT_MAX (codeabysss)

Pull request description:

  The overflow for signed arithmetic yields undefined behavior.
  This changes prevents undefined behavior in local address scoring by saturating `nScore` updates at `INT_MAX` in both `SeenLocal()` and `AddLocal()` update paths.

  Fixes: #24049.

ACKs for top commit:
  Crypt-iQ:
    ACK 2189a6f5f2 pending CI
  achow101:
    ACK 2189a6f5f2
  sedited:
    ACK 2189a6f5f2

Tree-SHA512: b861e58ec9d6e18b17768f5cbee31ee825717e1a7216c332eb6fcbe63a7ac24e213ba638aea6f03cb710d9c2d8fe736cc626f11011ed66c3938acf6c38b0ef2a
2026-06-10 11:12:37 -07:00
Ava Chow
3bbc3c67ad Merge bitcoin/bitcoin#35101: refactor: disable default std::hash for CTransactionRef
a9301cfa07 refactor: disable default std::hash for CTransactionRef (Sjors Provoost)
47d68cd981 ci: backport iwyu PR 2013 std::hash mapping (Sjors Provoost)

Pull request description:

  While working on #33922 I initially forgot to add `CTransactionRefComp` to the `std::unordered_map<CTransactionRef` defined there. This PR turns that into a compiler error. See https://github.com/bitcoin/bitcoin/pull/33922#discussion_r2894597519

  This change triggers a false positive IWYU error, and an inconsistent one at that: our CI wants `<variant>`, while a manual build on Ubuntu (version 0.26 with clang version 22.1.1) wants `<string_view>`.

  Various workarounds were discussed in:
  - https://github.com/include-what-you-use/include-what-you-use/issues/2007
  - https://github.com/bitcoin/bitcoin/pull/35073
  - https://github.com/bitcoin/bitcoin/pull/33922#discussion_r3100806462

  Addressed by back-porting:
  - https://github.com/include-what-you-use/include-what-you-use/pull/2013

ACKs for top commit:
  achow101:
    ACK a9301cfa07
  vasild:
    ACK a9301cfa07
  w0xlt:
    lgtm ACK a9301cfa07

Tree-SHA512: 11b3f8698e66457a14d1c16f55cac3ee17a572e9c1c98f5aa9c8a8f1e8928246b1676f7544f2819bc16ec4dcf025585b9cbd60ab3f20839d3d9bcc65ee9e7c0f
2026-06-10 11:04:39 -07:00
Ava Chow
288018131e Merge bitcoin/bitcoin#35254: crypto: cleanse HMAC stack buffers after use and ChainCode
21a1380c13 key: cleanse ChainCode on destruction (Thomas)
b3a3f88346 crypto: cleanse HMAC stack buffers after use (Thomas)

Pull request description:

  `CHMAC_SHA256` and `CHMAC_SHA512` leave two stack buffers populated on return: `rkey[]` holds `K' ⊕ ipad` after the constructor, and `temp[]` holds the inner-hash output after `Finalize()`.

  When the HMAC is keyed with sensitive material (chain code in `BIP32Hash()` in `hash.cpp` for BIP32 child key derivation; PRK in HKDF-Expand in `hkdf_sha256_32.cpp`, used for BIP324 transport keying), `rkey` is one constant XOR from that key, and `temp` is a one-way digest covering it.

  This PR cleanses both buffers with `memory_cleanse()`, matching the convention already used in `chacha20.cpp` and `chacha20poly1305.cpp`. No observable change for callers.

  Update: Cleansing the HMAC primitive's internal buffers still leaves a caller's `ChainCode` value populated in memory after use. The second commit promotes `ChainCode` from `typedef uint256` to a `base_blob<256>` subclass with a `memory_cleanse()` destructor, so chain codes in `CExtKey`, `CExtPubKey`, and local variables are cleansed on scope exit. `MUSIG_CHAINCODE` is retyped from `constexpr uint256` to `const ChainCode` to match its BIP328 semantic role; this also removes the GCC-14 consteval lambda workaround.

ACKs for top commit:
  davidgumberg:
    crACK 21a1380c13
  optout21:
    ACK 21a1380c13
  achow101:
    ACK 21a1380c13
  winterrdog:
    ACK 21a1380c13

Tree-SHA512: 022c8372da3e2c9c269ef55b695d8415241acf64be04692f30da0e682dd1d05178f95601a3bd208573fd0630656b3dedcf6de34a2a3cf794515c0268e710af75
2026-06-10 10:47:16 -07:00
merge-script
c85e04f079 Merge bitcoin/bitcoin#35478: fuzz: reset the mockable steady clock between iterations
19b32a2e18 fuzz: reset the mockable steady clock between iterations (Hao Xu)

Pull request description:

  Fix the issue mentioned by https://github.com/bitcoin/bitcoin/issues/29018#issuecomment-4422112607
  And this is my investigation on it: https://github.com/bitcoin/bitcoin/issues/29018#issuecomment-4639472489

  `CheckGlobalsImpl`'s constructor runs at the start of every fuzz iteration and already resets the global RNG flags and the mockable `NodeClock` (`SetMockTime(0s)`), but it never reset the mockable steady clock. A value written to `g_mock_steady_time` by one input therefore leaks into the next iteration.

    The most common source is `FuzzedSock`'s constructor, which calls `SetMockTime(INITIAL_MOCK_TIME)` (through `ElapseTime(0s)`) and never clears it: once any input constructs a `FuzzedSock`, the steady clock stays mocked for every subsequent iteration in the same process. This is one of the global-state leaks tracked
    in #29018.

    ### Fix

    Reset `MockableSteadyClock` symmetrically with `NodeClock`:

    ```diff
     g_used_system_time = false;
     SetMockTime(0s);
    +MockableSteadyClock::ClearMockTime();
    ```

    Besides removing the leak, this puts the steady clock under the same discipline as the system clock: a target that reads `MockableSteadyClock::now()` without first mocking it (via `FuzzedSock`, `SteadyClockContext`, …) is now caught by the existing `g_used_system_time` check at the end of the iteration, instead of
    silently reusing a value left over from a previous input.

    Clearing in `~FuzzedSock()` would be wrong: several `FuzzedSock`s can be alive simultaneously (e.g. `process_messages` adds 1–3 peers), so clearing in one destructor would corrupt the mock observed by the others. Resetting at the iteration boundary keeps it decoupled from socket lifetimes.

    ### Testing

    Verified with the global-state-detector approach from #29018 (snapshotting/diffing the writable globals around each iteration):

    - **Before:** a single empty input to `process_message` reports `g_mock_steady_time` changing `00 → 01` (`0` → `INITIAL_MOCK_TIME`).
    - **After:** that report is gone; the only remaining diffs are the benign one-time initialization of `ConsumeTime`'s function-local statics.

    `p2p_headers_presync` (uses `SteadyClockContext`) and `pcp_request_port_map` (uses `FuzzedSock`) still run to `succeeded` without aborting, confirming existing steady-clock readers are unaffected.

    This leak is invisible to coverage-based checks such as `deterministic-fuzz-coverage`, because `g_mock_steady_time` is only consumed through coarse time comparisons (e.g. the 250 ms presync rate-limiter): a changed value doesn't change the executed branches, so only a memory-diffing detector can see it.

ACKs for top commit:
  maflcko:
    lgtm ACK 19b32a2e18
  marcofleon:
    Nice catch, ACK 19b32a2e18

Tree-SHA512: b875795addb2914eae489adc703438483f8e464b9a210bd5d76189f13266dae5843c8749590d59e78bf171f19aa7cee21ca678cd311843d8a88cbe9831f20b6a
2026-06-10 17:05:07 +02:00
Hennadii Stepanov
4b91316643 Merge bitcoin/bitcoin#35459: guix: add setup.sh
54de023a7c guix: add setup.sh (fanquake)

Pull request description:

  This is the first change in #25573, which splits out the setup & tarball generation code from `build.sh`, so that it can be re-used, from multiple (future) build scripts.

ACKs for top commit:
  willcl-ark:
    ACK 54de023a7c
  hebasto:
    ACK 54de023a7c.

Tree-SHA512: 9a7f2fe322d281b9867414511af5243f4dd659ea42637f4eb8cc0c8629c94dab842669bb7c503f9fa67cab3fac65561364f07b5c0fda8e6d8c24e7bf161025ef
2026-06-09 19:38:36 +01:00
MarcoFalke
fa03852e9c test: Use SteadyClockContext in pcp_tests
This is easier to reason about, because it will automatically take care
of properly setting INITIAL_MOCK_TIME in the ctor. Also, it allows to
drop the ElapseTime and replace it with a call to operator+=()
2026-06-09 20:06:07 +02:00
MarcoFalke
fa3716c439 test: Use FakeNodeClock in more places
The context is easier to reason about: E.g.,

* in TestBasicMining it allows to drop manual SetMockTime(0) calls,
* in connections_desirable_service_flags it allows to drop manual calls
  to SetMockTime(GetTime<std::chrono::seconds>() + _n_) and replace them
  by operator+=(_n_)
* in wallet_tests it clarifies that the mocktime does not persist
  outside the AddTx function
2026-06-09 20:05:11 +02:00
MarcoFalke
fae9623c8d test: Add FakeNodeClock m_clock to TestChain100Setup
Currently, all test cases using TestChain100Setup or a derived class
like BuildChainTestingSetup are using mocktime by default due to the
SetMockTime call in the TestChain100Setup ctor.

This is confusing, because test cases using mocktime explicitly seem to
imply that before they set the mocktime, real time was used.

E.g. index_reorg_crash claimed in a comment to "Enable mock time".

Fix this issue by adding a FakeNodeClock m_clock field to
TestChain100Setup. Then, use the m_clock instead of explicit calls to
SetMockTime or to a (now) shadowing local FakeNodeClock variable.
2026-06-09 20:01:12 +02:00
merge-script
bcbf5bae16 Merge bitcoin/bitcoin#35114: test: NodeClockContext follow-ups
35a814a045 test: Limit clocks to one active instance (MarcoFalke)
55e402ffef scripted-diff: Rename NodeClockContext to FakeNodeClock (seduless)
1e9546fcf4 test: Use NodeClockContext in more call sites (seduless)
758fea59a8 test: Drop ++ from NodeClockContext default constructor (seduless)
7c2ec3949a test: Enter mocktime before peer creation in block_relay_only_eviction (seduless)

Pull request description:

  Follow-up to #34858

  Updates remaining `SetMockTime` call sites that are clean, mechanical swaps fitting the spirit of the original PR (see: https://github.com/bitcoin/bitcoin/pull/34858#pullrequestreview-4031647119 and https://github.com/bitcoin/bitcoin/pull/34858#issuecomment-4221757881). Further updates to `SetMockTime` are more complex and deserve separate, isolated PRs.

  The default constructor for `NodeClockContext` increments to the next tick, which is a defensive measure to prevent time going backwards on construction. This has caused some confusion (see thread: https://github.com/bitcoin/bitcoin/pull/34858#discussion_r3057648646) and can be safely removed after updating the only test where this is load-bearing (b3c9bd7f2df230525c8e339394a315a2c500055d) (see: https://github.com/bitcoin/bitcoin/pull/34858#discussion_r3091085328). The removal also tightens the `addrman_tests/addrman_evictionworks` test to sit exactly on the `ADDRMAN_REPLACEMENT` boundary (4h), catching mutations such as:

  ```diff
  diff --git a/src/addrman.cpp b/src/addrman.cpp
  index d3dae59ae7..d0929c62cb 100644
  --- a/src/addrman.cpp
  +++ b/src/addrman.cpp
  @@ -920,3 +920,3 @@ void AddrManImpl::ResolveCollisions_()
                   // Has successfully connected in last X hours
  -                if (current_time - info_old.m_last_success < ADDRMAN_REPLACEMENT) {
  +                if (current_time - info_old.m_last_success <= ADDRMAN_REPLACEMENT) {
                       erase_collision = true;
  ```

  The last follow-up item is updating `NodeClockContext` to `FakeNodeClock` to make it clear it is intended for testing (motivated by https://github.com/bitcoin/bitcoin/pull/34858#pullrequestreview-4082110904 and supported in https://github.com/bitcoin/bitcoin/pull/34858#issuecomment-4214352770).

ACKs for top commit:
  maflcko:
    re-ACK 35a814a045 🛒
  sedited:
    ACK 35a814a045

Tree-SHA512: ade776e288a4b7bbc4c8855c14d61381b5b20329fe1e72fee87f773e47a9519975d58c277fbacda37dd73c0c1d4ce358c92dcdc4ca049d58cb3453ddf751b45b
2026-06-09 14:46:08 +02:00
merge-script
543c00f47d Merge bitcoin/bitcoin#35448: ci: don't build libunwind in msan
087f02c929 ci: skip libunwind runtime in LLVM build (fanquake)
6d47f7cc6f ci: use llvm 22.1.7 (fanquake)

Pull request description:

  Also document why we use `LIBCXXABI_USE_LLVM_UNWINDER=OFF`. Upstream issue is https://github.com/llvm/llvm-project/issues/84348.

ACKs for top commit:
  maflcko:
    lgtm ACK 087f02c929
  sedited:
    ACK 087f02c929

Tree-SHA512: b93c798fd5a016cad40db9d24cb36cb72e531b284aee5458de41e062960514783e30c6f1413c0e62fa261758d783d0004a0973541cbb36bd34b77800c629bd7a
2026-06-09 14:09:19 +02:00
merge-script
17ed7f5060 Merge bitcoin/bitcoin#35297: p2p: Release m_peer_mutex early in InitiateTxBroadcastToAll
fa2afba28b p2p: Release m_peer_mutex early in InitiateTxBroadcastToAll (MarcoFalke)

Pull request description:

  The `InitiateTxBroadcastToAll` method holds the `m_peer_mutex` while updating the bloom filters for all peers. This is perfectly fine, because updating the bloom filters is fast. Though, from a style-perspective, the lock does not need to be held for the whole function. Also, holding the lock longer, may confuse Tsan into a lock-order inversion false-positive (ref: https://github.com/bitcoin/bitcoin/issues/19303#issuecomment-1514926359).

  So "fix" both issues in this style-refactor.

ACKs for top commit:
  xyzconstant:
    Code review ACK fa2afba28b
  shuv-amp:
    ACK fa2afba28b
  danielabrozzoni:
    Code Review ACK fa2afba28b
  sedited:
    ACK fa2afba28b

Tree-SHA512: c47849a4c3cc11c74b61fec3425db8ec7f78db4ca43d7bf3145ce640f7b0872701c09495f0dfe77109d09d5716d920ad3d7308483fe41564c30867b3e80432e7
2026-06-09 11:26:22 +02:00
fanquake
087f02c929 ci: skip libunwind runtime in LLVM build
Document why we use LIBCXXABI_USE_LLVM_UNWINDER=OFF.
2026-06-09 11:10:54 +02:00
fanquake
6d47f7cc6f ci: use llvm 22.1.7 2026-06-09 11:10:54 +02:00
merge-script
9868e1bf65 Merge bitcoin/bitcoin#35487: scripted-diff: Rename UNIQUE_NAME to BITCOIN_UNIQUE_NAME
fba713a28c scripted-diff: Rename UNIQUE_NAME to BITCOIN_UNIQUE_NAME (Hennadii Stepanov)

Pull request description:

  https://github.com/bitcoin/bitcoin/pull/34454#issuecomment-3822800049:
  > ... it is annoying that we keep running into the same bug over and over again (IIRC it happened in the past at least once for Bitcoin Core). Surely this is going to happen again in the future.

  And here we go again.

  ---

  The `nb30.h` Windows header [defines](b536c4fdb0/mingw-w64-headers/include/nb30.h (L78)) `UNIQUE_NAME` as a macro.

  This introduces a fragile dependency on header inclusion order: if Windows headers happen to be included before `UNIQUE_NAME` is used, the preprocessor expands it into a numeric literal, causing syntax errors.

  Rename the macro to `BITCOIN_UNIQUE_NAME` to remove this fragility and avoid the collision entirely.

  ---

  Noticed while doing a Guix build of the [QML repo](https://github.com/bitcoin-core/gui-qml) for Windows.

  Recent similar PRs: https://github.com/bitcoin/bitcoin/pull/34454 and https://github.com/bitcoin/bitcoin/pull/34868.

ACKs for top commit:
  maflcko:
    lgtm ACK fba713a28c
  sedited:
    ACK fba713a28c
  w0xlt:
    ACK fba713a28c

Tree-SHA512: 7a63b99a754e797eb8fa5d6a598606150f47ae1130d1d26067c509830e6575f0378ce63fe0ca35c69dce9a394451a34ddadd8b3d5f6f9a7e4c529108af546fb6
2026-06-09 10:31:34 +02:00
merge-script
577999c2ce Merge bitcoin/bitcoin#35462: test: remove unnecessary nodes from wallet_multisig_descriptor_psbt
5b65e31270 test: remove two unnecessary nodes from the test (rkrux)

Pull request description:

  A discussion in the review of #35443 PR brought this test to my attention.

  The test needs multiple wallets that can be created on a single node, multiple nodes are not required.

  As there is a cost associated with setting-up and tearing-down nodes, this patch helps in reducing the test time as well.

ACKs for top commit:
  ekzyis:
    ACK 5b65e31270
  polespinasa:
    lgtm ACK 5b65e31270
  sedited:
    ACK 5b65e31270

Tree-SHA512: f6b4a96b9beee968ef5438fd9db582a48834ff36ba27c19dd7012902528fa713424212530e34cc16b58c19c023f1accd2b89fe846ef2cc36677c24e160c5b817
2026-06-08 22:07:39 +02:00
merge-script
e36f5d5d0b Merge bitcoin/bitcoin#35456: test: Perform full reset of CoinsResult in order to avoid passing 21M BTC
d0b76c7f3e rpc+bitcoin-tx: Specify correct type for ParseFixedPoint() (Hodlinator)
43ca54ca00 refactor(test): Make CAmount arg explicit for BuildCreditingTransaction() (Hodlinator)
b5e91e946c wallet: Remove CoinsResult::Clear() (Hodlinator)

Pull request description:

  The *knapsack_solver_test* in *coinselector_tests.cpp* was accumulating satoshi amounts beyond 21M BTC. This was uncovered while experimenting with adding checks to `CAmount`. Fix that by fully resetting the `CoinsResult` object accumulating those amounts, inspired by https://github.com/bitcoin/bitcoin/issues/35449#issuecomment-4613968627.

  Also, while we're at it, add 2 commits which correct some `int64_t`/`CAmount` confusion.

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

ACKs for top commit:
  sedited:
    ACK d0b76c7f3e
  furszy:
    utACK d0b76c7f3e
  brunoerg:
    code review ACK d0b76c7f3e

Tree-SHA512: 6d989ded6f6327dc657f437dc256d4adf42a34a1252621421ee38d7851c6cdc97a462f033a4728e3aa7d5514deee4db6e83646105633f9cf7ed6e7e90406b67d
2026-06-08 21:59:58 +02:00
merge-script
1d3bc816c3 Merge bitcoin/bitcoin#35267: rpc: make getprivatebroadcastinfo and abortprivatebroadcast fail if privatebroadcast is not enabled
0bfc5e4fff add release notes (Pol Espinasa)
fdc9fc1df2 test: check getprivatebroadcast and abortprivatebroadcast throw if the node is running without -privatebroadcast set (Pol Espinasa)
7b821ef9b7 rpc: getprivatebroadcastinfo and abortprivatebroadcast throw if -privatebroadcast is disabled (Pol Espinasa)

Pull request description:

  Makes `getprivatebroadcast` and `abortprivatebroadcast` throw if `-privatebroadcast=0`.

  This is motivated by: https://github.com/sparrowwallet/sparrow/issues/1989

  Knowing if `privatebroadcast` is set can be useful for some external software like Sparrow to avoid call `getprivatebroadcastinfo` each time to see if broadcast was done through that.

ACKs for top commit:
  stickies-v:
    ACK 0bfc5e4fff
  sedited:
    ACK 0bfc5e4fff
  rkrux:
    code review ACK 0bfc5e4fff
  andrewtoth:
    ACK 0bfc5e4fff

Tree-SHA512: 3bdb3909e93fc3835d801e1efc2bbec673a75a1ff089debd59e8970a0ff2b44d4e00b7ac26f10c972dcb50bf042521921370e1ec57885d67cd8459b3831da898
2026-06-08 21:51:51 +02:00
Hennadii Stepanov
fba713a28c scripted-diff: Rename UNIQUE_NAME to BITCOIN_UNIQUE_NAME
The `nb30.h` Windows header defines `UNIQUE_NAME` as a macro.

This introduces a fragile dependency on header inclusion order: if
Windows headers happen to be included before `UNIQUE_NAME` is used, the
preprocessor expands it into a numeric literal, causing syntax errors.

Rename the macro to `BITCOIN_UNIQUE_NAME` to remove this fragility and
avoid the collision entirely.

-BEGIN VERIFY SCRIPT-
sed -i 's/\<UNIQUE_NAME\>/BITCOIN_UNIQUE_NAME/g' $(git grep -l 'UNIQUE_NAME' ./src/)
-END VERIFY SCRIPT-
2026-06-08 19:06:33 +01:00
merge-script
1aafd49077 Merge bitcoin/bitcoin#35359: blockstorage: Remove cs_LastBlockFile recursive mutex
ec6cf49b91 blockstorage: Remove cs_LastBlockFile recursive mutex (sedited)

Pull request description:

  The `cs_LastBlockFile` mutex is redundant: all critical sections are already covered by cs_main. This is demonstrated in this patch by replacing all instances of locking `cs_LastBlockFile` with pairs of `AssertLockHeld(::cs_main)` and `EXCLUSIVE_LOCKS_REQUIRED(::cs_main)` annotations. No additional `::cs_main` LOCK(...)s are introduced (besides for test-only code).

  It is also not clear for which sections `cs_LastBlockFile` is responsible for. It is annotated for `m_blockfile_cursors`, but sporadically and inconsistently also covers `m_blockfile_info` (e.g. in `LoadBlockIndexDB`).

  Since it has no semantic meaning, and seems confusing to developers, remove it.

  An alternative to this patch would be expanding the scope of what `cs_LastBlockFile` covers and turning it into a non-recursive mutex. I prepared such a patch some time ago, but found it unsatisfactory. It was not clear to me if the lock was now covering too much or too little, and its purpose remained unclear. If this patch is accepted, I would expect the project to eventually implement a separate, narrowly-scoped block storage lock to allow for a more parallelizable block processing routine.

ACKs for top commit:
  stickies-v:
    re-ACK ec6cf49b91
  janb84:
    re- ACK ec6cf49b91
  pablomartin4btc:
    ACK ec6cf49b91

Tree-SHA512: e5942bc87300b0db9a0b91d5fe26dab455049e6cef7c96bb12b28141fa04711d46c6af105c0e1a83a9f261edde2c8b8b43ecf577a27d54b4610d784676a85627
2026-06-08 19:30:36 +02:00
sedited
ec6cf49b91 blockstorage: Remove cs_LastBlockFile recursive mutex
The cs_LastBlockFile mutex is redundant: all critical sections are
already covered by cs_main. This is demonstrated in this patch by
replacing all instances of locking cs_LastBlockFile with pairs of
`AssertLockHeld(::cs_main)` and `EXCLUSIVE_LOCKS_REQUIRED(::cs_main)`
annotations. No additional `::cs_main` LOCK(...)s are introduced.

It is also not clear for which sections `cs_LastBlockFile` is
responsible for. It is annotated for `m_blockfile_cursors`, but
sporadically and inconsistently also covers `m_blockfile_info`.

Since it has no semantic meaning, and seems confusing to developers,
remove it.
2026-06-08 16:57:28 +02:00
MarcoFalke
35a814a045 test: Limit clocks to one active instance
SteadyClockContext and FakeNodeClock assume they are the only active
instance. Overlapping them in the same scope would silently clobber
each other.

Add a CRTP base class, LimitOne, that asserts at construction if
another instance already exists.
2026-06-08 14:27:32 +00:00
seduless
55e402ffef scripted-diff: Rename NodeClockContext to FakeNodeClock
The previous name did not indicate the type was intended for
testing. Renaming to FakeNodeClock makes this explicit and
allows call sites to drop the ctx suffix on the variable name.

Suggested in #34858 review feedback.

-BEGIN VERIFY SCRIPT-
s() { git grep -l "$1" -- src | xargs sed -i "s/$1/$2/g"; }

s '\<NodeClockContext\>' 'FakeNodeClock'
s '\<clock_ctx\>'        'clock'
-END VERIFY SCRIPT-
2026-06-08 14:27:24 +00:00
seduless
1e9546fcf4 test: Use NodeClockContext in more call sites
This refactor is a follow-up to commit
faad08e59c and does not
change any behavior.

These call sites are clean mechanical swaps. The remaining ones
require non-trivial test refactoring and are left for future
follow-ups.
2026-06-08 14:27:18 +00:00
seduless
758fea59a8 test: Drop ++ from NodeClockContext default constructor
The increment was originally added so that mocked time would not appear
to go backward relative to real-clock timestamps captured before
construction, since Now<NodeSeconds>() rounds the current time down to
a whole second. In practice the tests do not mix real and mocked
timestamps in a way that exposes this, so the increment is unnecessary.
2026-06-08 14:27:10 +00:00
seduless
7c2ec3949a test: Enter mocktime before peer creation in block_relay_only_eviction
This is a follow-up to commit faad08e59c.
Hoisting the NodeClockContext above peer creation ensures m_connected is
captured under mocktime, making the MINIMUM_CONNECT_TIME check
deterministic regardless of which peer is selected for eviction.

This is a prerequisite for the next commit, which removes the
one-second advance from the NodeClockContext default constructor.
2026-06-08 14:27:03 +00:00
Pol Espinasa
0bfc5e4fff add release notes 2026-06-08 15:16:29 +02:00
Pol Espinasa
fdc9fc1df2 test: check getprivatebroadcast and abortprivatebroadcast throw if the node is running without -privatebroadcast set 2026-06-08 15:13:14 +02:00
Pol Espinasa
7b821ef9b7 rpc: getprivatebroadcastinfo and abortprivatebroadcast throw if -privatebroadcast is disabled 2026-06-08 15:13:09 +02:00
merge-script
5f33da9aa3 Merge bitcoin/bitcoin#35481: fuzz: fix dead HD keypaths (de)serialization round-trip
5deb053a75 fuzz: fix dead HD keypaths (de)serialization round-trip (Sebastian Falbesoner)

Pull request description:

  `DeserializeHDKeypaths()` was writing into the original `hd_keypaths` map instead of `deserialized_hd_keypaths`. As a result the latter was always empty and the round-trip assertion following was trivially true, so the serialize/deserialize round-trip wasn't actually being exercised.

  That bug was introduced with the commit introducing the fuzz target (commit f898ef65c9, #18994).

ACKs for top commit:
  sedited:
    ACK 5deb053a75

Tree-SHA512: 0d8770aa5da2e132caedd522c8c95c4ceb6d1bcc4d5b6605784fd7d2df41fce29fcd25fc2741c4e751b942b548888833eb9d9d6318505a5c59f7b1f105c990ae
2026-06-07 22:12:29 +02:00
Sebastian Falbesoner
5deb053a75 fuzz: fix dead HD keypaths (de)serialization round-trip
`DeserializeHDKeypaths()` was writing into the original `hd_keypaths`
map instead of `deserialized_hd_keypaths`. As a result the latter was
always empty and the round-trip assertion following was trivially true,
so the serialize/deserialize round-trip wasn't actually being exercised.

That bug was introduced with the commit introducing the fuzz target
(commit f898ef65c9, #18994).
2026-06-07 20:56:03 +02:00
Hao Xu
19b32a2e18 fuzz: reset the mockable steady clock between iterations
CheckGlobalsImpl's constructor runs at the start of every fuzz iteration
and already resets the global RNG flags and the mockable NodeClock via
SetMockTime(0s), but it never reset the mockable steady clock. A value
written to g_mock_steady_time by one input therefore leaked into the
next one. For example, FuzzedSock's constructor calls
SetMockTime(INITIAL_MOCK_TIME) and never clears it, so the mocked steady
time stays set for all subsequent iterations.

Reset MockableSteadyClock symmetrically with NodeClock so each input
starts from an unmocked steady clock. This also brings the steady clock
under the same discipline as the system clock: a target that reads
MockableSteadyClock::now() without first mocking it is now caught by the
existing g_used_system_time check instead of silently reusing a leaked
value.
2026-06-07 15:49:52 +08:00
merge-script
27472a542c Merge bitcoin/bitcoin#35466: ci: run ipc functional tests in arm job
b2fbd5b5dd ci: run ipc functional tests in arm job (fanquake)

Pull request description:

  These are currently skipped, because `pycapnp` isn't installed (https://github.com/bitcoin/bitcoin/actions/runs/26943765833/job/79499532298#step:10:4286):
  ```bash
  interface_ipc.py                                                                 | ○ Skipped | 0 s
  interface_ipc_mining.py                                                          | ○ Skipped | 0 s
  ```
  They seem to work fine locally. Not sure if this was missed, or on purpose.

ACKs for top commit:
  Sjors:
    ACK b2fbd5b5dd
  sedited:
    ACK b2fbd5b5dd

Tree-SHA512: d9ec06c0d65447102c3354ccddf5c03505e6338a08efd43f6ef495fafba3a6d9bf8c9d8f8e2a29f16931bcc5058911597a08aa938fb40bd9beab8b501c5194ef
2026-06-06 13:53:32 +02:00
rustaceanrob
f6bdbcf79d lint: Grep for AUTO test suites in file names
Tests without a fixture did not have their file names linted because the
grep matches on `BOOST_FIXTURE`. Updates to match `BOOST_FIXTURE` or
`BOOST_TEST`.

Co-authored-by: l0rinc <pap.lorinc@gmail.com>
2026-06-05 09:37:48 +01:00
fanquake
b2fbd5b5dd ci: run ipc functional tests in arm job 2026-06-04 22:58:58 +01:00
Fabian Jahr
da74ff9ca4 test: Add functional test for BIP434 2026-06-04 21:58:56 +10:00
Anthony Towns
01b8a117d2 test_framework: BIP 434 support 2026-06-04 21:58:56 +10:00
Anthony Towns
6a129983c9 BIP434: FEATURE message support
BIP434 defines FEATURE messages which are sent between VERSION and VERACK
to indicate support for new P2P protocol features. This commit provides
the infrastructure for easily using BIP434 negotiation when implementing
such new P2P protocol features. Note that advertised protocol version
is bumped to 70017, as per BIP434's specification.
2026-06-04 21:58:56 +10:00
Anthony Towns
3210fc477a net: Add AdvertisedVersion() for protocol version advertised to a peer 2026-06-04 21:58:55 +10:00
rkrux
5b65e31270 test: remove two unnecessary nodes from the test
The test needs multiple wallets that can be created on a single node, multiple
nodes are not required.

As there is a cost associated with setting-up and tearing-down nodes, this patch
helps in reducing the test time as well.
2026-06-04 17:27:02 +05:30