6814 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
furszy
ac3bea07cd
test: improve rpc_gettxspendingprevout.py code
Grouped changes to improve the overall readability and maintainability of the test.
A lot more can be done, but this is a good first step.

1) Use for-loops instead of duplicating lines to perform the same checks for each
   node.

2) The {'txid': x, 'vout': y} dict is repeated everywhere in the test, both as
   input to gettxspendingprevout and as part of its result when an output has no
   known spender, making the test tedious to read and maintain.

   This introduces a prevout(txid, vout) query helper and an unspent_out(txid, vout)
   result helper to reduce the repetition. These two helpers are intentionally kept
   separate to make it immediately clear whether a dict is an input to
   gettxspendingprevout or an assertion on its result.

3) The same repetition problem mentioned above applies to other gettxspendingprevout
   possible results:
   Spent outputs returns {'txid': x, 'vout': y, 'spendingtxid': z} and
   Spent outputs when requesting spending tx returns {'txid': x, 'vout': y,
   'spendingtxid': z, 'blockhash': w, 'spendingtx': v}

   To fix it, this introduces:
   - spent_out(txid, vout, spending_tx_id): for outputs with a known spender
   - spent_out_in_block(txid, vout, spending_tx_id, blockhash, spending_tx): for
     outputs spent in a confirmed block, when full tx data is requested

4) Rename overloaded confirmed_utxo variable (used in three different tests) to more
   descriptive names: root_utxo, reorg_replace_utxo, reorg_cancel_utxo to clarify
   their roles in each of the tests.
2026-02-23 11:26:46 -03:00
sedited
e5f0613503
net processing: Check if we are in ibd before processing block for txdownloadman
This avoids wasting work on calculating bloom filters that aren't
consumed during ibd and continuously re-calculated as now blocks get
validated.

Also update the functional test to document that transactions would now
be requested again once out of IBD.

Co-authored-by: Lőrinc <pap.lorinc@gmail.com>
2026-02-22 13:04:27 +01:00
Lőrinc
ce8b692897
Add functional test exercising tx downloadman recently confirmed filter
This documents existing behaviour before the change in the following
commit: The bloom filter maintained by the txdownload manager tracks
recently confirmed transasctions even during ibd. If a peer sends an INV
once IBD is over it does not re-request them.

Co-authored-by: sedited <seb.kung@gmail.com>
2026-02-22 13:03:52 +01:00
Vasil Dimov
c462e54f9d
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
```
2026-02-21 18:04:36 +01:00
Vasil Dimov
3710566305
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})
```
2026-02-21 16:45:47 +01:00
merge-script
d9c7364ac5
Merge bitcoin/bitcoin#34141: miniscript: Use Func and Expr when parsing keys, hashes, and locktimes
4b53cbd69220c1c786bb23a72c0b26a6f78a38f7 test: Test for musig() in various miniscript expressions (Ava Chow)
ec0f47b15cb3269015523e6fab8ae9241f4181a1 miniscript: Using Func and Expr when parsing keys, hashes, and locktimes (Ava Chow)
6fd780d4fbc497b657025afe48d0dfbf103ee120 descriptors: Increment key_exp_index in ParsePubkey(Inner) (Ava Chow)
b12281bd86e2298ba6cdd79d55c9d6e23e5136a5 miniscript: Use a reference to key_exp_index in KeyParser (Ava Chow)
ce4c66eb7c5e99e3df1c20d5c0ae8278a714b9f8 test: Test that key expression indexes match key count (Ava Chow)

Pull request description:

  The miniscript parser currently only looks for the next `)` when parsing key, hash, and locktime expressions. This fails to parse when the expressions contain a nested expression. Currently, this is only possible with `musig()` inside of key expressions. However, this pattern can be generalized to handling hashes and locktimes, so I implemented those too.

  Fixes #34076

ACKs for top commit:
  rkrux:
    ACK 4b53cbd69220c1c786bb23a72c0b26a6f78a38f7
  sipa:
    ACK 4b53cbd69220c1c786bb23a72c0b26a6f78a38f7
  darosior:
    Other than that, Approach ACK 4b53cbd69220c1c786bb23a72c0b26a6f78a38f7. That makes sense to me but i have not closely reviewed the code.

Tree-SHA512: 01040c7b07a59d8e3725ff11ab9543b256aea22535fb94059f490a5bb45319e859666af04c2f0a4edcb8cf1e6dfc7bd8a8271b21ad81143bafccd4d0a39cae9c
2026-02-21 12:18:56 +01:00
Ava Chow
fa194fca8e
Merge bitcoin/bitcoin#34622: test: assert_debug_log timeouts follow-up
fa4424fd98b6b6998e1f55c707400dae53d2b9e9 test: Fixup assert_debug_log timeouts in feature_config_args.py (MarcoFalke)
faed837f274aeea9fdd59bb69430cfc1644d56cf test: Add missing syncwithvalidationinterfacequeue (MarcoFalke)

Pull request description:

  Small fixups that fell through. See the commit messages for details.

  Can be tested via:

  ```diff
  diff --git a/src/util/thread.cpp b/src/util/thread.cpp
  index 0fde73c..4fcfe4f 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>
  @@ -18,2 +19,3 @@ void util::TraceThread(std::string_view thread_name, std::function<void()> threa
       util::ThreadRename(std::string{thread_name});
  +    UninterruptibleSleep(999ms);
       try {
  diff --git a/src/validationinterface.cpp b/src/validationinterface.cpp
  index c7be6ab..3237aec 100644
  --- a/src/validationinterface.cpp
  +++ b/src/validationinterface.cpp
  @@ -14,2 +14,3 @@
   #include <primitives/transaction.h>
  +#include <random.h>
   #include <util/check.h>
  @@ -156,2 +157,4 @@ void ValidationSignals::SyncWithValidationInterfaceQueue()

  +static FastRandomContext g_rnd{};
  +
   // Use a macro instead of a function for conditional logging to prevent
  @@ -166,2 +169,3 @@ void ValidationSignals::SyncWithValidationInterfaceQueue()
               LOG_EVENT(fmt, local_name, __VA_ARGS__);           \
  +            if(g_rnd.randrange(2)<1)UninterruptibleSleep(55ms);\
               event();                                           \
  ```

  With this diff and without the changes here, the touched tests fail.
  With this diff and with the changes here, the touched tests pass.

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

ACKs for top commit:
  achow101:
    ACK fa4424fd98b6b6998e1f55c707400dae53d2b9e9
  hodlinator:
    ACK fa4424fd98b6b6998e1f55c707400dae53d2b9e9

Tree-SHA512: 51315c061f34c22ee4b198ff761fd7d14d5585498d0cde2f483aa73ea8bd1f6f5dfacb0295b4bc3731a734f207c9c8fa28bfb18b7ba25a65d7627f3690043b78
2026-02-20 16:46:03 -08:00
Ava Chow
d907d65acd
Merge bitcoin/bitcoin#29770: index: Check all necessary block data is available before starting to sync
fd06157d1465d93b960e8be6e8e419295abde9a1 test: Add coverage for restarted node without any block sync (Fabian Jahr)
3d7ab7ecb7dfcdfb8aaa45869388887b948841c8 rpc, test: Address feedback from #29668 (Fabian Jahr)
312919c9dd5dba7da20317604e1638bdc5010f14 test: Indices can not start based on block data without undo data (Fabian Jahr)
a9a3b29dd687b4c355e131fefc145e8e48b48b17 index: Check availability of undo data for indices (Fabian Jahr)
881ab4fc82fe3cf36b227cf1ba704448df160745 support multiple block status checks in CheckBlockDataAvailability (furszy)

Pull request description:

  Currently, we check that `BLOCK_HAVE_DATA` is available for all blocks an index needs to sync during startup. However, for `coinstatsindex` and `blockfilterindex` we also need the undo data for these blocks. If that data is missing in the blocks, we are currently still starting to sync each of these indices and then crash later when we encounter the missing data.

  This PR adds explicit knowledge of which block data is needed for each index and then checks its availability during startup before initializing the sync process on them.

  This also addresses a few open comments from #29668 in the last commit.

ACKs for top commit:
  achow101:
    ACK fd06157d1465d93b960e8be6e8e419295abde9a1
  furszy:
    utACK fd06157d1465d93b960e8be6e8e419295abde9a1
  sedited:
    Re-ACK fd06157d1465d93b960e8be6e8e419295abde9a1

Tree-SHA512: e2ed81c93372b02daa8ddf2819df4164f96d92de05b1d48855410ecac78d5fcd9612d7f0e63a9d57d7e75a0b46e1bea278e43ea87f2693af0220d1f9c600e416
2026-02-20 15:58:48 -08:00
Sjors Provoost
1e82fa498c
mining: add interrupt()
Both waitTipChanged() and createNewBlock() can take a long time to
return. Add a way for clients to interrupt them.

The new m_interrupt_mining is safely accessed with a lock on
m_tip_block_mutex, but it has no guard annotation. A more thorough
solution is discussed here:
https://github.com/bitcoin/bitcoin/pull/34184#discussion_r2743566474
2026-02-20 16:49:52 +01:00
Sjors Provoost
a11297a904
mining: add cooldown argument to createNewBlock()
At startup, if the needs to catch up, connected mining clients will
receive a flood of new templates as new blocks are connected.

Fix this by adding a cooldown argument to createNewBlock(). When set
to true, block template creation is briefly paused while the best
header chain is ahead of the tip.

This wait only happens when the best header extends the current tip,
to ignore competing branches.

Additionally, cooldown waits for isInitialBlockDownload() to latch to
false, which happens when there is less than a day of blocks left to sync.

When cooldown is false createNewBlock() returns immediately. The argument
is optional, because many tests are negatively impacted by this
mechanism, and single miner signets could end up stuck if no block
was mined for a day.

The getblocktemplate RPC also opts out, because it would add a delay
to each call.

Fixes #33994
2026-02-20 16:49:15 +01:00
Greg Sanders
a9e59f7d95 rpc: add optimal result to getmempoolinfo
Expose this value to allow rpc based tooling to track this
value for network health diagnostics.
2026-02-20 09:26:41 -05:00
merge-script
cb3473a680
Merge bitcoin/bitcoin#34568: mining: Break compatibility with existing IPC mining clients
f700609e8ada3b48fd45ec19979cd72d943d47a6 doc: Release notes for mining IPC interface bump (Ryan Ofsky)
9453c153612ae9b30308362048099bc53afcde6f ipc mining: break compatibility with existing clients (version bump) (Sjors Provoost)
70de5cc2d205672743379f2e1a94290ee8b4b84b ipc mining: pass missing context to BlockTemplate methods (incompatible schema change) (Sjors Provoost)
2278f017afad4d2c570527b15df776ee64fc1ee2 ipc mining: remove deprecated methods (incompatible schema change) (Ryan Ofsky)
c6638fa7c5e97f9fd7a5ea8feb29f8caeac788bd ipc mining: provide default option values (incompatible schema change) (Ryan Ofsky)
a4603ac77412790b6498ab1750017e31353740bf ipc mining: declare constants for default field values (Ryan Ofsky)
ff995b50cf9e1ea521f3cf546339f05d10b79a4d ipc test: add workaround to block_reserved_weight exception test (Ryan Ofsky)
b970cdf20fce43fb58dde1cbf713e97ff21d7a2e test framework: expand expected_stderr, expected_ret_code options (Ryan Ofsky)
df53a3e5ec8781833c29682ff9e459fca489fa7b rpc refactor: stop using deprecated getCoinbaseCommitment method (Ryan Ofsky)

Pull request description:

  This PR increments the field number of the `Init.makeMining` method and makes the old `makeMining` method return an error, so IPC mining clients not using the latest schema file will get an error and not be able to access the Mining interface.

  Normally, there shouldn't be a need to break compatibility this way, but the mining interface has evolved a lot since it was first introduced, with old clients using the original methods less stable and performant than newer clients. So now is a good time to introduce a cutoff, drop deprecated methods, and stop supporting old clients which can't function as well.

  Bumping the field number is also an opportunity to make other improvements that would be awkward to implement compatibly:
  - Making Cap'n Proto default parameter and field values match default values of corresponding C++ methods and structs.
  - Adding missing Context parameters to Mining.createNewBlock and checkBlock methods so these methods will be executed on separate execution threads and not block the Cap'n Proto event loop thread.

  More details about these changes are in the commit messages.

ACKs for top commit:
  Sjors:
    ACK f700609e8ada3b48fd45ec19979cd72d943d47a6
  enirox001:
    ACK f700609e8ada3b48fd45ec19979cd72d943d47a6
  ismaelsadeeq:
    ACK f700609e8ada3b48fd45ec19979cd72d943d47a6
  sedited:
    ACK f700609e8ada3b48fd45ec19979cd72d943d47a6

Tree-SHA512: 0901886af00214c138643b33cec21647de5671dfff2021afe06d78dfd970664a844cde9a1e28f685bb27edccaf6e0c3f2d1e6bb4164bde6b84f42955946e366d
2026-02-20 11:06:06 +01:00
merge-script
1a54886b63
Merge bitcoin/bitcoin#24539: Add a "tx output spender" index
0b96b9c600e0dd946fd4d0e827e7f7cbef7a571a Minimize mempool lock, sync txo spender index only when and if needed (sstone)
3d82ec5bdd019cf1c048c41fe44faa855fcb8b53 Add a "tx output spender" index (sstone)

Pull request description:

  This PR adds a new "tx output spender" index, which allows users to query which tx spent a given outpoint with the `gettxspendingprevout` RPC call that was added by https://github.com/bitcoin/bitcoin/pull/24408.

  Such an index would be extremely useful for Lightning, and probably for most layer-2 protocols that rely on chains of unpublished transactions.

  UPDATE: this PR is ready for review and issues have been addressed:
  - using a watch-only wallet instead would not work if there is a significant number of outpoints to watch (see https://github.com/bitcoin/bitcoin/pull/24539#issuecomment-1276595646)
  - this PR does not require `-txindex` anymore

  We use a composite key with 2 parts (suggested by romanz): hash(spent outpoint) and tx position, with an empty value. Average composite key size is 15 bytes.

  The spending tx can optionally be returned by `gettxspendingprevout` (even it `-txindex is not set`).

ACKs for top commit:
  hodlinator:
    re-ACK 0b96b9c600e0dd946fd4d0e827e7f7cbef7a571a
  sedited:
    Re-ACK 0b96b9c600e0dd946fd4d0e827e7f7cbef7a571a
  fjahr:
    ACK 0b96b9c600e0dd946fd4d0e827e7f7cbef7a571a
  w0xlt:
    reACK 0b96b9c600e0dd946fd4d0e827e7f7cbef7a571a

Tree-SHA512: 95c2c313ef4086e7d5bf1cf1a3c7b91cfe2bb1a0dcb4c9d3aa8a6e5bfde66aaca48d85a1f1251a780523c3e4356ec8a97fe6f5c7145bc6ccb6f820b26716ae01
2026-02-20 09:27:17 +01:00
MarcoFalke
fa4424fd98
test: Fixup assert_debug_log timeouts in feature_config_args.py
* The bitcoin.conf related checks do not need any timeout, because the
  logging happens in the main thread, before the node is fully started.
* The net thread related checks do need a timeout, because the threads
  may be late to start after the node is fully started.
2026-02-20 09:03:35 +01:00
MarcoFalke
faed837f27
test: Add missing syncwithvalidationinterfacequeue
This is required to actually erase the orphan transaction when the
BlockConnected event is handled in the background validation interface
queue thread.
2026-02-20 09:02:25 +01:00
Ava Chow
76de2f8e55
Merge bitcoin/bitcoin#34571: test: Fix intermittent issues in feature_assumevalid.py
fa90d44a22838591e47eec206c23f87d69ad842a test: Fix intermittent issues in feature_assumevalid.py (MarcoFalke)

Pull request description:

  The test has many issues:

  * The `send_blocks_until_disconnected` seems to imply to wait until a disconnect happens. However, in reality it will blindly send all blocks and then return early, when done or when a disconnect happens. This will cause test failures when python is running faster than Bitcoin Core, for example when using sanitizers.
  * The `assert_debug_log` scopes are bloated, which makes finding the above issue harder. This is, because a test failure will basically print the 1000+ line debug log excerpt twice, with the second instance stripped of useful python test logs. Also, the checks are less precise, if they happen over a larger scope/snippet.

  Fix all issues, by:

  * Removing `send_blocks_until_disconnected` and just sending the blocks that are needed to get the disconnect and then explicitly waiting for the disconnect.
  * Reduce the scopes of the debug log checks. This can be reviewed with the git options `--color-moved=dimmed-zebra --color-moved-ws=ignore-all-space`.

ACKs for top commit:
  l0rinc:
    ACK fa90d44a22838591e47eec206c23f87d69ad842a
  achow101:
    ACK fa90d44a22838591e47eec206c23f87d69ad842a

Tree-SHA512: 8a18fa0009fb40a47317976e20b230625182874391babe0da3c3dfd55d2cc8e2da7008ce8f38691d01cd37ae02cac7c9e88b8193c2ed66d3621ee3f792649f71
2026-02-19 16:52:30 -08:00
Ava Chow
c808dfbbdc
Merge bitcoin/bitcoin#34329: rpc,net: Add private broadcast RPCs
2a1d0db7994eb2aa8527944f62161b6b8af682da doc: Mention private broadcast RPCs in release notes (Andrew Toth)
c3378be10b0a90e81b46e53eb85c41eb8caabac5 test: Cover abortprivatebroadcast in p2p_private_broadcast (Andrew Toth)
557260ca14ac5fb4732f4ce0692a2bf364bb5238 rpc: Add abortprivatebroadcast (Andrew Toth)
15dff452eb61ae9e2fd7b48c957e795c4c397443 test: Cover getprivatebroadcastinfo in p2p_private_broadcast (Andrew Toth)
996f20c18af02281034c51af4b2766d8f4d37a2c rpc: Add getprivatebroadcastinfo (Andrew Toth)
5e64982541f301773156a87988c60ca7797a3f06 net: Add PrivateBroadcast::GetBroadcastInfo (Andrew Toth)
573bb542be80b63b1713a0b76bedaa5e37c3783f net: Store recipient node address in private broadcast (Andrew Toth)

Pull request description:

  Follow up from #29415

  Sending a transaction via private broadcast does not have any way for a user to track the status of the transaction before it gets returned by another peer. The default logs have been removed as well in #34267. Nor is there any way to abort a transaction once it has been added to the private broadcast queue.

  This adds two new RPCs:
  - `getprivatebroadastinfo` returns information about what transactions are in the private broadcast queue, including all the peers' addresses we have chosen and timestamps.
  - `abortprivatebroadcast` stops broadcasting a transaction in the private broadcast queue.

ACKs for top commit:
  nervana21:
    tACK 2a1d0db7994eb2aa8527944f62161b6b8af682da
  achow101:
    ACK 2a1d0db7994eb2aa8527944f62161b6b8af682da
  l0rinc:
    ACK 2a1d0db7994eb2aa8527944f62161b6b8af682da
  danielabrozzoni:
    tACK 2a1d0db7994eb2aa8527944f62161b6b8af682da
  sedited:
    ACK 2a1d0db7994eb2aa8527944f62161b6b8af682da

Tree-SHA512: cc8682d0be68a57b42bea6e3d091da2b80995d9e6d3b98644cb120a05c2b48a97c2e211173289b758c4f4e23f1d1a1f9be528a9b8c6644f71d1dd0ae5f673326
2026-02-19 13:42:11 -08:00
sstone
0b96b9c600
Minimize mempool lock, sync txo spender index only when and if needed
We sync txospenderindex after we've checked the mempool for spending transaction, and only if search is not limited to the mempool and no
spending transactions have been found for some of the provided outpoints.
This should minimize the chance of having a block containing a spending transaction that is no longer in the mempool but has not been indexed yet.
2026-02-19 21:09:31 +01:00
Ava Chow
d0998cbe34
Merge bitcoin/bitcoin#33199: fees: enable CBlockPolicyEstimator return sub 1 sat/vb fee rate estimates
8966352df3fc56fd2c00a45eecd292a240a34546 doc: add release notes (ismaelsadeeq)
704a09fe7187d5e4c949dea05baba7fe13bdb676 test: ensure fee estimator provide fee rate estimate < 1 s/vb (ismaelsadeeq)
243e48cf493378acd3a4bde638765544ade9f7b2 fees: delete unused dummy field (ismaelsadeeq)
fc4fbda42af1e84f74acbd8b6a0f384d2711c85b fees: bump fees file version (ismaelsadeeq)
b54dedcc8563286861b2ccda68bc246ad61338c0 fees: reduce `MIN_BUCKET_FEERATE` to 100 (ismaelsadeeq)

Pull request description:

  This is a simple PR that updates the block policy estimator’s `MIN_BUCKET_FEERATE` constant to be 100, which is identical to the policy `DEFAULT_MIN_RELAY_TX_FEE`.

  This change enables the block policy fee rate estimator to return sub-1 sat/vB fee rate estimates.

  The change is correct because the estimator creates buckets of fee rates from
  `MIN_BUCKET_FEERATE`,
  `MIN_BUCKET_FEERATE` + `FEE_SPACING`,
  `MIN_BUCKET_FEERATE` + `2 * FEE_SPACING`,
  … up to `MAX_BUCKET_FEERATE`.

  This means it will record sub-1 sat/vB fee rates in the buckets and may return them as a fee rate estimate when that bucket is the lowest one with sufficient transactions for a given target.

  ---

  While touching this part of the fee estimator code, this PR got rid of the dummy value persisted in the file

ACKs for top commit:
  achow101:
    ACK 8966352df3fc56fd2c00a45eecd292a240a34546
  musaHaruna:
    ACK [8966352](8966352df3)
  polespinasa:
    ACK 8966352df3fc56fd2c00a45eecd292a240a34546

Tree-SHA512: 9424e0820fcbe124adf5e5d9101a8a2983ba802887101875b2d1856d700c8b563d7a6f6ca3e3db29cb939f786719603aadbf5480d59d55d0951ed1c0caa49868
2026-02-19 11:41:34 -08:00
merge-script
37e449dcc7
Merge bitcoin/bitcoin#34512: rpc: add coinbase_tx field to getblock
e0463b4e8c25f8a5fe10999f2821e7b221d2e40a rpc: add coinbase_tx field to getblock (Sjors Provoost)

Pull request description:

  This adds a `coinbase_tx` field to the `getblock` RPC result, starting at verbosity level 1. It contains only fields guaranteed to be small, i.e. not the outputs.

  Initial motivation for this was to more efficiently scan for BIP54 compliance. Without this change, it requires verbosity level 2 to get the coinbase, which makes such scan very slow. See https://github.com/bitcoin-inquisition/bitcoin/pull/99#issuecomment-3852370506.

  Adding these fields should be useful in general though and hardly makes the verbosity 1 result longer.

  ```
  bitcoin rpc help getblock

  getblock "blockhash" ( verbosity )

  If verbosity is 0, returns a string that is serialized, hex-encoded data for block 'hash'.
  If verbosity is 1, returns an Object with information about block <hash>.
  If verbosity is 2, returns an Object with information about block <hash> and information about each transaction.
  ...
  Result (for verbosity = 1):
  {                                 (json object)
    "hash" : "hex",                 (string) the block hash (same as provided)
    "confirmations" : n,            (numeric) The number of confirmations, or -1 if the block is not on the main chain
    "size" : n,                     (numeric) The block size
    "strippedsize" : n,             (numeric) The block size excluding witness data
    "weight" : n,                   (numeric) The block weight as defined in BIP 141
    "coinbase_tx" : {               (json object) Coinbase transaction metadata
      "version" : n,                (numeric) The coinbase transaction version
      "locktime" : n,               (numeric) The coinbase transaction's locktime (nLockTime)
      "sequence" : n,               (numeric) The coinbase input's sequence number (nSequence)
      "coinbase" : "hex",         (string) The coinbase input's script
      "witness" : "hex"             (string, optional) The coinbase input's first (and only) witness stack element, if present
    },
    "height" : n,                   (numeric) The block height or index
    "version" : n,                  (numeric) The block version
  ...
  ```

  ```
  bitcoin rpc getblock 000000000000000000013c986f9aebe800a78454c835ccd07ecae2650bfad3f6 1
  ```

  ```json
  {
    "hash": "000000000000000000013c986f9aebe800a78454c835ccd07ecae2650bfad3f6",
    "confirmations": 2,
    "height": 935113,
    "version": 561807360,
    "...": "...",
    "weight": 3993624,
    "coinbase_tx": {
      "version": 2,
      "locktime": 0,
      "sequence": 4294967295,
      "coinbase": "03c9440e04307c84692f466f756e6472792055534120506f6f6c202364726f70676f6c642ffabe6d6d9a8624235259d3680c972b0dd42fa3fe1c45c5e5ae5a96fe10c182bda17080e70100000000000000184b17d3f138020000000000",
      "witness": "0000000000000000000000000000000000000000000000000000000000000000"
    },
    "tx": [
      "70eb053340c7978c5aa1b34d75e1ba9f9d1879c09896317f306f30c243536b62",
      "5bcf8ed2900cb70721e808b8977898e47f2c9001fcee83c3ccd29e51c7775dcd",
      "3f1991771aef846d7bb379d2931cccc04e8421a630ec9f52d22449d028d2e7f4",
      "..."
    ]
  }
  ```

ACKs for top commit:
  sedited:
    Re-ACK e0463b4e8c25f8a5fe10999f2821e7b221d2e40a
  darosior:
    re-utACK e0463b4e8c25f8a5fe10999f2821e7b221d2e40a

Tree-SHA512: 1b3e7111e6a0edffde8619c49b3e9bca833c8e90e416defc66811bd56dd00d45b69a84c8fd9715508f4e6515f77ac4fb5c59868ab997ae111017c78c05b74ba3
2026-02-19 20:31:33 +01:00
Sjors Provoost
e0463b4e8c
rpc: add coinbase_tx field to getblock
This adds a "coinbase_tx" field to the getblock RPC result, starting
at verbosity level 1. It contains only fields guaranteed to be small,
i.e. not the outputs.
2026-02-19 14:59:34 +01:00
sstone
3d82ec5bdd
Add a "tx output spender" index
Adds an outpoint -> txid index, which can be used to find which transactions spent a given output.
We use a composite key with 2 parts (suggested by @romanz): hash(spent outpoint) and tx position, with an empty value.
To find the spending tx for a given outpoint, we do a prefix search (prefix being the hash of the provided outpoint), and for all keys that match this prefix
we load the tx at the position specified in the key and return it, along with the block hash, if does spend the provided outpoint.
To handle reorgs we just erase the keys computed from the removed block.

This index is extremely useful for Lightning and more generally for layer-2 protocols that rely on chains of unpublished transactions.
If enabled, this index will be used by `gettxspendingprevout` when it does not find a spending transaction in the mempool.
2026-02-19 11:41:53 +01:00
Ava Chow
4933d1fbba
Merge bitcoin/bitcoin#28792: build: Embedded ASMap [3/3]: Build binary dump header file
24699fec8422a4d9219f8c5272370351e7adea7f doc: Add initial asmap data documentation (Fabian Jahr)
bab085d282b1ad1790861d710fd570f8531c9364 ci: Use without embedded asmap build option in one ci job (Fabian Jahr)
e53934422a29bdcb022d32f8eb6e171218cd3a26 doc: Expand documentation on asmap feature and tooling (Fabian Jahr)
6244212a5532a8a625e344fdbc8144f4befdd385 init, net: Implement usage of binary-embedded asmap data (Fabian Jahr)
6202b50fb9003a4feadd879ae189ee6f730e8155 build: Generate ip_asn.dat.h during build process (Fabian Jahr)
634cd60dc8f646b25701c45ac35a1175ce4c4da9 build: Add embedded asmap data (Fabian Jahr)

Pull request description:

  This is the final in a series of PRs that implement the necessary changes for embedding of asmap data into the binary. This last part add the initial asmap data, implements the build changes and adds further documentation.

  Currently an asmap file needs to be acquired by there user from some location or the user needs to generate one themselves. Then they need to move the file to the right place in datadir or pass the path to the file as `-asmap=PATH` in order to use the asmap feature. The change here allows for builds to embed asmap data into the bitcoind binary which makes it possible to use the feature without handling of the asmap file by the user. If the user starts bitcoind with `-asmap` the embedded data will be used for bucketing of nodes.

  The data lives in the repository at `src/node/data/ip_asn.dat` and can be replaced with a new version at any time. The idea is that the data should be updated with every release. By default the data at that location is embedded into the binary but there is also a build option to prevent this (`-DWITH_EMBEDDED_ASMAP=OFF`). In this case the original behavior of the `-asmap` option is maintained.

ACKs for top commit:
  achow101:
    ACK 24699fec8422a4d9219f8c5272370351e7adea7f
  sipa:
    ACK 24699fec8422a4d9219f8c5272370351e7adea7f
  hodlinator:
    ACK 24699fec8422a4d9219f8c5272370351e7adea7f

Tree-SHA512: c2e33dbeea387efdfd3d415432bf8fa64de80f272c1207015ea53b85bb77f5c29f1dae5644513a23c844a98fb0a4bb257bf765f38b15bfc4c41984f0315b4c6a
2026-02-18 16:43:34 -08:00
Ava Chow
6d482b22de
Merge bitcoin/bitcoin#32138: wallet, rpc: remove settxfee and paytxfee
24f93c9af7f6627cd7d09a1a5f10667846b048eb release note (Pol Espinasa)
331a5279d2775fb701a0bf4607436ec05e476df3 wallet, rpc:remove settxfee and paytxfee (Pol Espinasa)

Pull request description:

  **Summary**

  This PR removes the settxfee RPC and paytxfee setting (Bitcoin Core 31.0).
  These two features were deprecated in https://github.com/bitcoin/bitcoin/pull/31278.

ACKs for top commit:
  achow101:
    ACK 24f93c9af7f6627cd7d09a1a5f10667846b048eb
  w0xlt:
    reACK 24f93c9af7f6627cd7d09a1a5f10667846b048eb

Tree-SHA512: e090f1a72ba2cbeba7c982dd51dfdcf6baf0a164827337cf56fd85f733e143b8d6116b8cd53c59c812cacef193dfa0b101a830fc455e32bf225e8505e7b2a554
2026-02-18 16:36:13 -08:00
merge-script
9e4567b17a
Merge bitcoin/bitcoin#34581: test: Set assert_debug_log timeout to 0
fa4cb96bdec21319cc54c6dd96a14acf1719e3c6 test: Set assert_debug_log timeout to 0 (MarcoFalke)

Pull request description:

  The `assert_debug_log` helper is meant to be a context manager. However, it has a  default timeout of 2 seconds, and can act as a silent polling/wait/sync function. This is confusing and brittle, and leads to intermittent bugs such as https://github.com/bitcoin/bitcoin/pull/34571.

  Fix all issues, by setting the default timeout to zero. Then adjust all call sites to either use this correctly like a context manager, or adjust them explicitly to specify a timeout, to document that this is a polling sync function.

ACKs for top commit:
  hodlinator:
    re-ACK fa4cb96bdec21319cc54c6dd96a14acf1719e3c6
  brunoerg:
    ACK fa4cb96bdec21319cc54c6dd96a14acf1719e3c6

Tree-SHA512: 111a45c84327c3afea98fd9f8de13dd7d11969b2309471b4ad21694b290a3734f6e1eda75a41b39613b0995c5b7075298085cea2ca06aa07d4385eb8d72fe95b
2026-02-18 17:03:32 +00:00
MarcoFalke
fa4cb96bde
test: Set assert_debug_log timeout to 0 2026-02-17 16:10:47 +01:00
Fabian Jahr
fd06157d14
test: Add coverage for restarted node without any block sync 2026-02-17 12:44:23 +01:00
Fabian Jahr
312919c9dd
test: Indices can not start based on block data without undo data 2026-02-17 12:44:23 +01:00
Fabian Jahr
a9a3b29dd6
index: Check availability of undo data for indices 2026-02-17 12:44:21 +01:00
MarcoFalke
211111b804
test: Avoid empty errmsg in JSONRPCException
It is unclear why the fallback should be an empty message, when it is
better to include all rpc_error details that are available.

Also, include the http status.

This allows to revert commit 6354b4fd7fe819eb13274b212e426a7d10ca75d3,
because it is no longer needed.
2026-02-13 18:55:53 +01:00
Pol Espinasa
331a5279d2
wallet, rpc:remove settxfee and paytxfee 2026-02-13 10:52:25 +01:00
MarcoFalke
fa90d44a22
test: Fix intermittent issues in feature_assumevalid.py 2026-02-12 11:23:24 +01:00