Commit Graph

8280 Commits

Author SHA1 Message Date
Matthew Zipkin
881d4b6c75 test: cover common HTTP attacks and common malformed requests 2026-06-22 05:46:31 -04:00
merge-script
ea626c268a Merge bitcoin/bitcoin#35560: lint: Require scripted-diff script to succeed (take 2)
fab2874269 lint: Require scripted-diff script to succeed (MarcoFalke)

Pull request description:

  Currently, scripted diffs may silently pass with errors.

  Fix this issue by calling the script from a Bash instance with error checking enabled: `bash -o errexit -o nounset -o pipefail -c "$SCRIPT"`.

  Also, use Bash (not sh) when launching the script itself, because Bash is required anyway.

  Can be tested by running something like this and observing the behavior before and after:

  ```
  git commit --allow-empty -m $'scripted-diff: foo\n\n-BEGIN VERIFY SCRIPT-\n  false;falseasfsafsaf;true;false|cat; echo "${NO_UN_SET}"|cat  \n-END VERIFY SCRIPT-\n' && ./test/lint/commit-script-check.sh HEAD~..HEAD ; echo $?
  ```

  Alternatively, an ancient brittle script can be tested:

  ```
  ./test/lint/commit-script-check.sh fb65dde147f63422c4148b089c2f5be0bf5ba80f~..fb65dde147f63422c4148b089c2f5be0bf5ba80f

ACKs for top commit:
  hodlinator:
    ACK fab2874269
  sedited:
    ACK fab2874269

Tree-SHA512: e3e8167e150be45a096d4883057640eb5624456f21b134cfa901fe490e5afb192855e55a752cb6121399314f65db155544a60645a101c39a084a62de4af23298
2026-06-21 15:47:03 +02:00
Ava Chow
1a2523e901 Merge bitcoin/bitcoin#34937: Fix startup failure with RLIM_INFINITY fd limits
735b25519a support: clamp RLIMIT_MEMLOCK to size_t (Sjors Provoost)
8ab4b9fc85 init: clamp fd limits to int (Sjors Provoost)
4afbabdcef Fix startup failure with RLIM_INFINITY fd limits (Sjors Provoost)

Pull request description:

  When setting the fd limit to unlimited, the node fails to start:

  ```sh
  ulimit -n unlimited
  build/bin/bitcoind
  Error: Not enough file descriptors available. -1 available, 160 required.
  ```

  This was caused by `RaiseFileDescriptorLimit()` (introduced in #2568) casting `limitFD.rlim_cur` to `int`, which for `RLIM_INFINITY` overflows to `-1`. Fix it by returning `std::numeric_limits<int>::max()` instead.

  Some platforms implement `RLIM_INFINITY` as the maximum uint64, others as int64 (-1). So simply changing the return type to `uint64_t` wouldn't work.

  Similarly, though unlikely to actually happen:

  ```sh
  ulimit -n 214748364
  build/bin/bitcoind
  Error: Not enough file descriptors available. -2147483648 available, 160 required.
  ```

  The second commit expands the fix by clamping all values above `std::numeric_limits<int>::max()` instead of letting them overflow.

  This PR also expands `test/functional/feature_init.py` to cover these, using `resource.setrlimit`. The check is skipped on environments with a hard limit below infinity (or that don't have the Python [Resource module](https://docs.python.org/3/library/resource.html)).

  macOS by default has a hard limit of infinity, but on e.g. Ubuntu the default hard limit is 524288.

  The third commit applies a similar fix to `PosixLockedPageAllocator::GetLimit()` for 32-bit systems, but without a test.

ACKs for top commit:
  winterrdog:
    Re-ACK 735b25519a
  achow101:
    ACK 735b25519a
  sedited:
    Re-ACK 735b25519a
  pinheadmz:
    ACK 735b25519a

Tree-SHA512: 0ce0292ecd61456bdec6943b06cbb9ecfc5180ee6dce850f8496ef54af22c1fae6ea473085202f5ba6f72e4dc51a29247620c9a0eae31e96658adc77b293129f
2026-06-19 15:57:59 -07:00
Ryan Ofsky
794befd4b0 Merge bitcoin/bitcoin#35384: util: Check write failures before renaming settings.json
0654511e1b util: Check write failures before renaming settings.json (Shrey)

Pull request description:

  This PR Fixes #35373.
  The error message was updated from: "This is probably caused by disk corruption or a crash" to: "This is probably caused by a full disk, disk corruption or a crash"

  The following files were updated:
  1. src/common/settings.cpp -- Updated the main string formatting for the parse failure.
  2. src/test/settings_tests.cpp -- Updated the exact string expectation in the C++ unit test.
  3. test/functional/feature_settings.py -- Updated the expected error message in the Python test suite.

  Configured the Bitcoin Core project natively on Windows using Visual Studio (cmake --preset vs2026-static -DBUILD_GUI=OFF) and it compiled with 100% of the C++ tests passed successfully (347 out of 347).

ACKs for top commit:
  maflcko:
    review ACK 0654511e1b 💧
  winterrdog:
    ACK 0654511e1b
  sedited:
    ACK 0654511e1b
  ryanofsky:
    Code review ACK 0654511e1b with commit message and error message improved since last review

Tree-SHA512: d7b49860f2081a5a9d1d44917b0cf372a77f10cf21773c9b3291871c788a122ec5dde063fdf9e1052cf45b8d2667e15585b952e9f037e84f98fb41546bdd1fa9
2026-06-19 07:38:26 -04:00
MarcoFalke
fab2874269 lint: Require scripted-diff script to succeed 2026-06-18 11:35:26 +02:00
Shrey
0654511e1b util: Check write failures before renaming settings.json
In WriteSettings(), verify that writing to the stream and closing it
succeeded before returning true. This prevents RenameOver() from replacing
a valid settings.json with a corrupted or zero-byte file when write limits
or a full disk are encountered.

Additionally, update the ReadSettings() parse failure message to mention
power loss, full disk, or storage error as possible causes.

Fixes #35373
2026-06-17 20:47:21 +05:30
Hennadii Stepanov
f570d7cd53 Merge bitcoin/bitcoin#35547: lint: Require scripted-diff script to succeed
2a36d6a561 lint: Require scripted-diff script to succeed (Hodlinator)

Pull request description:

  Previous version of commit-script-check.sh would succeed as long as git diff succeeded.

  Can be verified through adding a failing scripted diff commit such as:
  ```
  git commit --allow-empty -m $'scripted-diff: foo\n\n-BEGIN VERIFY SCRIPT-\nadsasd\n-END VERIFY SCRIPT-\n'
  ```
  ...and running...
  ```
  cargo run --manifest-path ./test/lint/test_runner/Cargo.toml -- --lint=scripted_diff
  ```

ACKs for top commit:
  maflcko:
    lgtm ACK 2a36d6a561
  furszy:
    ACK 2a36d6a561
  hebasto:
    ACK 2a36d6a561.

Tree-SHA512: 160397cc009b18ccb3bc66c85c1b89404a81c9a85acee534638f4752577165aead56d6cfb21d9fcb424484bc6710658cd0f1d2f483d8298e9e3a2f5243ef8e8b
2026-06-17 14:59:34 +01:00
Hodlinator
2a36d6a561 lint: Require scripted-diff script to succeed
Previous version of commit-script-check.sh would succeed as long as git diff succeeded.

Can be verified through adding a failing scripted diff commit such as:
    git commit --allow-empty -m $'scripted-diff: foo\n\n-BEGIN VERIFY SCRIPT-\nadsasd\n-END VERIFY SCRIPT-\n'
...and running...
    cargo run --manifest-path ./test/lint/test_runner/Cargo.toml -- --lint=scripted_diff
2026-06-17 14:59:46 +02:00
merge-script
9460090f1a Merge bitcoin/bitcoin#35520: lint: remove redundant test suite uniqueness check
946feb3f1f test: remove redundant test suite uniqueness lint (Lőrinc)

Pull request description:

  Follow-up to https://github.com/bitcoin/bitcoin/pull/35451#discussion_r3403672298.

  **Problem:** That duplicate check in `test/lint/lint-tests.py` is redundant now: CMake already registers each Boost test suite as a CTest test name and rejects duplicates there.

  **Fix:** Remove the `check_unique_test_names` path and its now-unused duplicate helper and inline remaining helper into `main()`.

  **Reproducers:** These throwaway patches pass `test/lint/lint-tests.py` and fail during CMake test registration.

  <details><summary>Internal `src/test` duplicate</summary>

  ```diff
  diff --git a/src/test/base32_tests.cpp b/src/test/base32_tests.cpp
  index 051a8fcd25..3b50bff724 100644
  --- a/src/test/base32_tests.cpp
  +++ b/src/test/base32_tests.cpp
  @@ -54,3 +54,7 @@ BOOST_AUTO_TEST_CASE(base32_padding)
   }

   BOOST_AUTO_TEST_SUITE_END()
  +
  +BOOST_AUTO_TEST_SUITE(base32_tests)
  +BOOST_AUTO_TEST_CASE(base32_duplicate_probe) { BOOST_CHECK(true); }
  +BOOST_AUTO_TEST_SUITE_END()
  ```
  </details>
  <details><summary>Internal `src/wallet/test` duplicate</summary>

  ```diff
  diff --git a/src/wallet/test/wallet_rpc_tests.cpp b/src/wallet/test/wallet_rpc_tests.cpp
  index 8bf5eab443..854d010ec0 100644
  --- a/src/wallet/test/wallet_rpc_tests.cpp
  +++ b/src/wallet/test/wallet_rpc_tests.cpp
  @@ -37,5 +37,10 @@ BOOST_AUTO_TEST_CASE(ensure_unique_wallet_name)
       BOOST_CHECK_THROW(TestWalletName("/wallet/foobar", "foo"), UniValue);
   }

  +BOOST_AUTO_TEST_SUITE_END()
  +
  +BOOST_FIXTURE_TEST_SUITE(wallet_rpc_tests, BasicTestingSetup)
  +BOOST_AUTO_TEST_CASE(wallet_rpc_duplicate_probe) { BOOST_CHECK(true); }
  +
   BOOST_AUTO_TEST_SUITE_END()
   } // namespace wallet
  ```
  </details>
  <details><summary>Cross `src/test` and `src/wallet/test` duplicate</summary>

  ```diff
  diff --git a/src/wallet/test/CMakeLists.txt b/src/wallet/test/CMakeLists.txt
  index 524c7218f4..04628e0327 100644
  --- a/src/wallet/test/CMakeLists.txt
  +++ b/src/wallet/test/CMakeLists.txt
  @@ -8,6 +8,7 @@ target_sources(test_bitcoin
     PRIVATE
       init_test_fixture.cpp
       wallet_test_fixture.cpp
  +    base32_tests.cpp
       db_tests.cpp
       coinselector_tests.cpp
       coinselection_tests.cpp
  diff --git a/src/wallet/test/base32_tests.cpp b/src/wallet/test/base32_tests.cpp
  new file mode 100644
  index 0000000000..da91d87dca
  --- /dev/null
  +++ b/src/wallet/test/base32_tests.cpp
  @@ -0,0 +1,5 @@
  +#include <boost/test/unit_test.hpp>
  +
  +BOOST_AUTO_TEST_SUITE(base32_tests)
  +BOOST_AUTO_TEST_CASE(wallet_cross_duplicate_probe) { BOOST_CHECK(true); }
  +BOOST_AUTO_TEST_SUITE_END()
  ```
  </details>

  The CMake failures are in the form:

  ```text
  CMake Error at src/test/CMakeLists.txt:199 (add_test):
    add_test given test NAME "<duplicate_suite>" which already exists in this
    directory.
  ```

ACKs for top commit:
  maflcko:
    lgtm ACK 946feb3f1f
  sedited:
    ACK 946feb3f1f

Tree-SHA512: a511507d21db142b3f2ed6e966d9e8f1e7016e750de122d88f4502edc84c0cfc696054e757bf905ca58d9774ad6263b2a59ec8cbbcc1f3e28ed1896ba4cdd8aa
2026-06-16 14:28:31 +02:00
Lőrinc
d3e40af259 index: shorten indexer thread names
`BaseIndex` currently uses the same name for logs, `getindexinfo`, prune locks, and the sync thread.
Linux truncates system thread names to 15 visible bytes after the `b-` prefix, so long indexer names are clipped in system tools.

Pass a separate thread name explicitly at each `BaseIndex` call site and shorten the OS-visible indexer names to `txidx`, `blkfltbscidx`, `coinstatsidx`, and `txospenderidx`.
Add an `Assume` to `ThreadRename()` so future OS-visible thread names keep fitting the same Linux limit.
The public index names, `getindexinfo` keys, command-line options, and on-disk paths stay unchanged.

Co-authored-by: winterrdog <winterrdog@users.noreply.github.com>
Co-authored-by: Hodlinator <172445034+hodlinator@users.noreply.github.com>
Co-authored-by: sedited <seb.kung@gmail.com>
Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
2026-06-16 11:16:00 +02:00
merge-script
355fffb8cc Merge bitcoin/bitcoin#35528: test: doc: remove --perf profiling from functional test framework
9fae7e9886 test: doc: remove `--perf` profiling from functional test framework (Sebastian Falbesoner)

Pull request description:

  This PR is an alternative to #35509. Rather than fixing, it removes the `--perf` option / `profile_with_perf` context manager features (both introduced in #14519) from the functional test framework. Given that no developer apparently even noticed that it's been broken for more than a year, we can conclude that it's largely unused and getting rid of it to reduce maintenance burden seems a reasonable choice. So far, neither in #35509 nor [on IRC](https://bitcoin-irc.chaincode.com/bitcoin-core-dev/2026-06-12#1227556;) anyone has signaled strong interest to use or wanting to keep this feature.

  The corresponding test documentation is removed as well, though the mentioning of `perf` profiling is still kept in the general developer docs -- only the reference to functional test framework integration is removed there.

ACKs for top commit:
  l0rinc:
    lightweight code review ACK 9fae7e9886
  maflcko:
    lgtm ACK 9fae7e9886  While this seems useful, no one using it is a good reason to remove it. If a user comes after this is merged, it should be trivial to revert.

Tree-SHA512: cf7bdce72aed877c7dfa52a230840e0729e74b00f0c40c6ceecf04957707f4699f123c2cde5fc1c4ee21f4b1b14319c74acc78cd8066eab2b9a4d6efb4d11539
2026-06-15 15:04:45 +02:00
merge-script
46927cf82c Merge bitcoin/bitcoin#35504: test/doc: Follow-up nits for #35269
b3371029dc doc: use signing pubkey instead of aggregate xonly key (kevkevinpal)
ddceb4e603 test: updated different_key to be different_field and also used a single assert_equal with 3 args instead of multiple assert_equals (kevkevinpal)

Pull request description:

  ## Summary:
  This is a follow-up to https://github.com/bitcoin/bitcoin/pull/35269

  - Rename `different_key` to `different_field` in `assert_musig_signer_data` ([discussion](https://github.com/bitcoin/bitcoin/pull/35269#discussion_r3337676268))
  - Use 3-argument `assert_equal` for pubnonce/partial-sig length checks, matching the pattern already used for `finalized["complete"]` ([discussion](https://github.com/bitcoin/bitcoin/pull/35269#discussion_r3337695530))
  - Fix `MuSig2SessionID` doc to say "signing pubkey" instead of "aggregate xonly key" ([discussion](https://github.com/bitcoin/bitcoin/pull/35269#pullrequestreview-4350165352))

ACKs for top commit:
  rkrux:
    code review ACK b3371029dc
  theStack:
    ACK b3371029dc

Tree-SHA512: 5fa46ef8a5c2710dbbb50ece22c50e423fad81617c0f7f235a01c862d3d6a650a301aa3076fbbe0101b06a7fbeb7403bcc556dafcca16d1873199fad645b7c14
2026-06-15 14:51:59 +02:00
Sebastian Falbesoner
9fae7e9886 test: doc: remove --perf profiling from functional test framework
This feature was broken for more than a year and no developer apparently
even noticed, so one can conclude that it is largely unused; it seems
thus reasonable to remove it to reduce maintenance burden.
2026-06-13 22:59:23 +02:00
stringintech
406c2348dd rpc: tighten setmocktime upper bound to UINT32_MAX
The previous bound (~year 2262) was too permissive: paths that add an offset to the mocked time (e.g. the future-time check in ContextualCheckBlockHeader) can overflow int64_t (caught by UBSan), and paths that assign it to a uint32_t field (e.g. pblock->nTime in miner.cpp) silently truncate it (caught by the integer sanitizer). UINT32_MAX is the natural ceiling since block header nTime is uint32_t, and mocking beyond it is meaningless for anything consensus-related.

Add setmocktime bound checks to the existing _test_y2106 case in rpc_blockchain.py, and remove the negative bound check from rpc_uptime.py.
2026-06-13 13:17:15 +03:30
Lőrinc
946feb3f1f test: remove redundant test suite uniqueness lint
Duplicate Boost test suite names are already rejected by CMake when the suites are registered as CTest tests.
Follow-up to https://github.com/bitcoin/bitcoin/pull/35451#discussion_r3403672298.

Co-authored-by: maflcko <6399679+maflcko@users.noreply.github.com>
2026-06-12 23:00:57 +02:00
merge-script
142e86a65c Merge bitcoin/bitcoin#35458: qa: Avoid extra tracebacks when exception is raised
472b950b7f qa: Use custom assert_greater_than() over naked assert (Hodlinator)
f42226d526 qa: Silence socket.timeout exception when substituting it for a JSONRPCException (Hodlinator)
659671ac3d qa: Avoid cleanup when exception is raised (Hodlinator)

Pull request description:

  Clean up some cases in which we would trigger multiple tracebacks, which makes it unclear what issue is occuring (https://github.com/bitcoin/bitcoin/issues/31894#issuecomment-4616130031).

  CI log of this occurring: https://github.com/bitcoin/bitcoin/actions/runs/26907239657/job/79375388058?pr=35179

  <details><summary>Relevant log excerpt</summary>

  ```
   test  2026-06-03T19:28:28.119804Z TestFramework.node0 (DEBUG): TestNode.generate() dispatches `generate` call to `generatetoaddress`
   test  2026-06-03T19:28:28.120483Z TestFramework (ERROR): Unexpected exception:
                                     Traceback (most recent call last):
                                       File "/home/runner/work/bitcoin/bitcoin/test/functional/test_framework/authproxy.py", line 165, in _get_response
                                         http_response = self.__conn.getresponse()
                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^
                                       File "/usr/lib/python3.12/http/client.py", line 1448, in getresponse
                                         response.begin()
                                       File "/usr/lib/python3.12/http/client.py", line 336, in begin
                                         version, status, reason = self._read_status()
                                                                   ^^^^^^^^^^^^^^^^^^^
                                       File "/usr/lib/python3.12/http/client.py", line 297, in _read_status
                                         line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                       File "/usr/lib/python3.12/socket.py", line 707, in readinto
                                         return self._sock.recv_into(b)
                                                ^^^^^^^^^^^^^^^^^^^^^^^
                                     TimeoutError: timed out
                                     During handling of the above exception, another exception occurred:
                                     Traceback (most recent call last):
                                       File "/home/runner/work/bitcoin/bitcoin/ci_build/test/functional/p2p_orphan_handling.py", line 54, in wrapper
                                         func(self)
                                       File "/home/runner/work/bitcoin/bitcoin/ci_build/test/functional/p2p_orphan_handling.py", line 633, in test_maximal_package_protected
                                         testres = node.testmempoolaccept([large_orphan.serialize().hex()])
                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                       File "/home/runner/work/bitcoin/bitcoin/test/functional/test_framework/coverage.py", line 50, in __call__
                                         return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                       File "/home/runner/work/bitcoin/bitcoin/test/functional/test_framework/authproxy.py", line 128, in __call__
                                         response, status = self._request('POST', self.__url.path, postdata.encode('utf-8'))
                                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                       File "/home/runner/work/bitcoin/bitcoin/test/functional/test_framework/authproxy.py", line 102, in _request
                                         return self._get_response()
                                                ^^^^^^^^^^^^^^^^^^^^
                                       File "/home/runner/work/bitcoin/bitcoin/test/functional/test_framework/authproxy.py", line 167, in _get_response
                                         raise JSONRPCException({
                                     test_framework.util.JSONRPCException: 'testmempoolaccept' RPC took longer than 30.000000 seconds. Consider using larger timeout for calls that take longer to return. (-344)  [http_status=None]
                                     During handling of the above exception, another exception occurred:
                                     Traceback (most recent call last):
                                       File "/home/runner/work/bitcoin/bitcoin/test/functional/test_framework/test_framework.py", line 143, in main
                                         self.run_test()
                                       File "/home/runner/work/bitcoin/bitcoin/ci_build/test/functional/p2p_orphan_handling.py", line 837, in run_test
                                         self.test_maximal_package_protected()
                                       File "/home/runner/work/bitcoin/bitcoin/ci_build/test/functional/p2p_orphan_handling.py", line 57, in wrapper
                                         self.generate(self.nodes[0], 1)
                                       File "/home/runner/work/bitcoin/bitcoin/test/functional/test_framework/test_framework.py", line 666, in generate
                                         blocks = generator.generate(*args, called_by_framework=True, **kwargs)
                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                       File "/home/runner/work/bitcoin/bitcoin/test/functional/test_framework/test_node.py", line 445, in generate
                                         return self.generatetoaddress(nblocks=nblocks, address=self.get_deterministic_priv_key().address, maxtries=maxtries, **kwargs)
                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                       File "/home/runner/work/bitcoin/bitcoin/test/functional/test_framework/test_node.py", line 453, in generatetoaddress
                                         return self.__getattr__('generatetoaddress')(*args, **kwargs)
                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                       File "/home/runner/work/bitcoin/bitcoin/test/functional/test_framework/coverage.py", line 50, in __call__
                                         return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                       File "/home/runner/work/bitcoin/bitcoin/test/functional/test_framework/authproxy.py", line 128, in __call__
                                         response, status = self._request('POST', self.__url.path, postdata.encode('utf-8'))
                                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                       File "/home/runner/work/bitcoin/bitcoin/test/functional/test_framework/authproxy.py", line 101, in _request
                                         self.__conn.request(method, path, postdata, headers)
                                       File "/usr/lib/python3.12/http/client.py", line 1356, in request
                                         self._send_request(method, url, body, headers, encode_chunked)
                                       File "/usr/lib/python3.12/http/client.py", line 1367, in _send_request
                                         self.putrequest(method, url, **skips)
                                       File "/usr/lib/python3.12/http/client.py", line 1193, in putrequest
                                         raise CannotSendRequest(self.__state)
                                     http.client.CannotSendRequest: Request-sent
   test  2026-06-03T19:28:28.124908Z TestFramework (DEBUG): Closing down network thread
  ```

  </details>

  Fix in authproxy.py can be verified through applying the below diff with/without PR changes and running `./build/test/functional/p2p_orphan_handling.py`:

  ```diff
  --- a/test/functional/test_framework/authproxy.py
  +++ b/test/functional/test_framework/authproxy.py
  @@ -162,6 +162,8 @@ class AuthServiceProxy():
       def _get_response(self):
           req_start_time = time.time()
           try:
  +            if AuthServiceProxy.__id_count > 55:
  +                raise socket.timeout()
               http_response = self.__conn.getresponse()
           except socket.timeout:
               raise JSONRPCException({
  ```

ACKs for top commit:
  maflcko:
    review ACK 472b950b7f 🔼
  polespinasa:
    reACK 472b950b7f

Tree-SHA512: ec1ede0340da9d1338643980e7f2e4646f0aed2e64f339f8b41a447cbbfb4da8158c1cbcb22f2d0cc383c2dd945075602d02b07a47b33b44cc6215f3292c1d46
2026-06-12 10:51:47 +02:00
Ava Chow
216b50c9a6 Merge bitcoin/bitcoin#35179: test: Add importdescriptors rpc error coverage
ed11dd6a5f test: add coverage for importdescriptors when manually interrupting a wallet rescan (Pol Espinasa)
d90d7f0a55 test: add coverage for importdescriptors errors when using assumeutxo (Pol Espinasa)
ad388bf254 test: add coverage for importdescriptors while wallet is rescanning (Pol Espinasa)
84d07e471c test: add coverage for importdescriptor with an encrypted wallet (Pol Espinasa)

Pull request description:

  The current tests for `importdescriptors` RPC do not check for cases where RPC errors should be thrown.

  This PR adds coverage for _importing a descriptor when the wallet is encrypted_ , for _importing a descriptor while the wallet is rescanning_ and _importing a descriptor while using assumeutxo_

  For context, this lack of coverage was found while implementing #34861 when a reviewer found that this was being silently broken in the PR.

  I am not sure if the "rescanning test" approach is the optimal solution, I am open to suggestions.

ACKs for top commit:
  achow101:
    ACK ed11dd6a5f
  w0xlt:
    ACK ed11dd6a5f

Tree-SHA512: 18e7111314ff003d39538d53899a3e2261027f5f965945f259eec4b56ece5c22706faf2891694c47575f3a5089ca02c80ea0bd05c453c4e072335d4a45ab8edd
2026-06-11 16:05:33 -07:00
Hennadii Stepanov
46d0e21d75 Merge bitcoin/bitcoin#35288: ci: Bump toward Ubuntu 26.04
fab52281f7 refactor: Drop unused includes after iwyu CI bump (MarcoFalke)
fa4774d032 ci: Bump APT_LLVM_V-based task configs to Ubuntu 26.04 (MarcoFalke)
fa1414a36a ci: Debian Trixie -> Ubuntu 26.04 (MarcoFalke)

Pull request description:

  This is for the upcoming 32.x, because I presume users and devs are more likely using a later distro. This comes with tool bumps, such as:

  * GCC 14 -> 15 (https://packages.debian.org/trixie/g++ -> https://packages.ubuntu.com/resolute/g++)
  * Clang 19 -> 21
  * Cmake 3.31 -> 4.2
  * Valgrind 3.24 -> 3.26

ACKs for top commit:
  l0rinc:
    code review ACK fab52281f7
  hebasto:
    re-ACK fab52281f7.

Tree-SHA512: 9d5be2f5b15cf7904c50687ce5e8cceeb2f740c7d5180190d6a10e751998ce2c2156098f89352eac49f24c8cd9ab55b78321e310240ac829dcbe48b576b6240c
2026-06-11 10:36:31 +01: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
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
Hodlinator
472b950b7f qa: Use custom assert_greater_than() over naked assert
Co-authored-by: DrahtBot <39886733+DrahtBot@users.noreply.github.com>
2026-06-10 21:55:51 +02: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
Pol Espinasa
ed11dd6a5f test: add coverage for importdescriptors when manually interrupting a wallet rescan
Co-authored-by: w0xlt <woltx@protonmail.com>
2026-06-10 16:16:21 +02:00
Pol Espinasa
d90d7f0a55 test: add coverage for importdescriptors errors when using assumeutxo
Co-authored-by: w0xlt <woltx@protonmail.com>
2026-06-10 16:16:20 +02:00
Pol Espinasa
ad388bf254 test: add coverage for importdescriptors while wallet is rescanning
Co-authored-by: w0xlt <woltx@protonmail.com>
2026-06-10 16:16:17 +02:00
kevkevinpal
ddceb4e603 test: updated different_key to be different_field and also used a single assert_equal with 3 args instead of multiple assert_equals 2026-06-10 08:27:11 -04:00
MarcoFalke
fa1414a36a ci: Debian Trixie -> Ubuntu 26.04 2026-06-10 10:58: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
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
Pol Espinasa
84d07e471c test: add coverage for importdescriptor with an encrypted wallet 2026-06-08 17:06:04 +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
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
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
merge-script
47da4f9b71 Merge bitcoin/bitcoin#35410: net: use the proxy if overriden when doing v2->v1 reconnections
bf0d257c11 net: un-default the OpenNetworkConnection()'s proxy_override argument (Eugene Siegel)
5a3756d150 test: add a regression test for private broadcast v1 retries (Vasil Dimov)
ab35a028ed test: make reusable filling of a node's addrman (Vasil Dimov)
2333be9cbc test: make reusable starting a standalone P2P listener (Vasil Dimov)
2ffa81fac4 test: make reusable SOCKS5 server starting (Vasil Dimov)
32d072a49f doc: add release notes for #35319 (Vasil Dimov)
d01b461f71 net: ensure no direct private broadcast connections (Vasil Dimov)
fd230f942d net: use the proxy if overriden when doing v2->v1 reconnections (Vasil Dimov)

Pull request description:

  This PR includes https://github.com/bitcoin/bitcoin/pull/35319 and on top of that adds a regression functional test.

  The functional test exercises the relevant code paths without modifying non-test code. To do that it does:

  * Add a bunch of IPv4 addresses to the node's addrman (they will be added without P2P_V2 flag).
  * Get them to report P2P_V2 in their service flags and connect to each one, so that the flags
    in addrman are updated to contain P2P_V2.
  * Get one successful connection to a Tor peer (.onion) so that bitcoind assumes the configured
    Tor proxy works and is indeed a proxy to the Tor network. This will make it open private
    broadcast connections also to IPv4 addresses via that proxy.
  * Start some private broadcast connections.
  * Remember the destination IPv4 address of the first connection and get it to fail the v2
    transport.
  * Wait for a subsequent connection also through the Tor proxy to the same IPv4 and expect
    it to be v1, i.e. the v2->v1 downgrade retry.

  The test fails without the fix - the v1 retry never arrives to the Tor proxy. And passes with the fix. The fix is in the first commit here and in https://github.com/bitcoin/bitcoin/pull/35319, can remove it by `git show fd230f942d | git apply -R`.

ACKs for top commit:
  Crypt-iQ:
    reACK bf0d257c11
  andrewtoth:
    ACK bf0d257c11
  instagibbs:
    ACK bf0d257c11
  sedited:
    utACK bf0d257c11

Tree-SHA512: 11e89be36577199e0312e5e63efeac04e295faaba1cf1c13a30e683d35f473c8dbb419d1897b0333c2e993c10637adecafcf90fe08c812065c793cbc903744c9
2026-06-04 10:38:54 +01:00
merge-script
0cac23b66e Merge bitcoin/bitcoin#35431: test: pass -datadir to bitcoin-cli -ipcconnect check
7735c13488 test: run bitcoin-cli -ipcconnect check under valgrind with -datadir (Michael Dietz)

Pull request description:

  This case invokes bitcoin-cli via raw subprocess.run() without -datadir, so it reads the default datadir's bitcoin.conf (e.g. ~/.bitcoin) and fails whenever that real config is unusable. Pass the node's -datadir so the check reads the test's own bitcoin.conf and depends only on the build's IPC support, not the host environment.

ACKs for top commit:
  maflcko:
    lgtm ACK 7735c13488
  sedited:
    ACK 7735c13488

Tree-SHA512: 5264433e2cd1747b9b9b4437b80f1849b5fa01620dd958c34c124925270dfca85c3809186285bf1dd70a8358552e1ebb589ec84093e11bb0d66cfe10f04dde81
2026-06-04 11:04:40 +02:00
Hodlinator
f42226d526 qa: Silence socket.timeout exception when substituting it for a JSONRPCException
This prevents "During handling of the above exception, another exception occurred:" and an extra traceback.
2026-06-04 10:40:03 +02:00
Hodlinator
659671ac3d qa: Avoid cleanup when exception is raised
If an exception is raised before we get to cleanup, do not swallow it and attempt to reset the state. Doing so could trigger knock-on exceptions and extra tracebacks.
2026-06-04 10:40:03 +02:00
Ava Chow
5bd990a3dd Merge bitcoin/bitcoin#34779: BIP 323: reserve version bits 5-28 as extra nonce space
107d4178d9 versionbits: update VersionBitsCache doc comment to match current behaviour (Antoine Poinsot)
94e3ac0b21 doc: release notes and bips doc update for #34779 (Antoine Poinsot)
1d5240574a qa: test we don't warn for ignored unknown version bits deployments (Antoine Poinsot)
f802edf57c versionbits: Limit live activation params and activation warnings per BIP323 (Anthony Towns)

Pull request description:

  This implements https://github.com/bitcoin/bips/pull/2116, which repurposes 24 version bits as extra nonce space for miners rather than soft fork deployment coordination. 24 bits allows a miner to perform up to 72 PH before needing a fresh job from its controller. The current 16 bits in use by miners only allow up to 280 TH, which [apparently led some ASIC designers to start rolling the timestamp field](https://github.com/bitaxeorg/ESP-Miner/pull/1553#issuecomment-3937736319) on their beefier machines.

  Mailing list discussion available [here](https://gnusha.org/pi/bitcoindev/6fa0cb45-37d6-4b41-9ff8-03730fd96d6e@mattcorallo.com/). A previous shot at this is https://github.com/bitcoin/bitcoin/pull/13972 (with a smaller extranonce space).

  This change only affects the warning logic.

ACKs for top commit:
  ajtowns:
    ACK 107d4178d9
  achow101:
    ACK 107d4178d9
  sedited:
    Re-ACK 107d4178d9
  optout21:
    ACK 107d4178d9

Tree-SHA512: cfaf5d7de1e8c020a4d7f4b1096b6c3e0e3b41ea840a4652ebcdabc345c5c557161c8304f1d7d6de541a2bf1df3c855ad7b64e49dd8c8af3937876d134bb5aba
2026-06-03 11:56:14 -07:00
merge-script
2669019fe8 Merge bitcoin/bitcoin#35269: musig: Include pubnonce in session id
2ef6679c2c test: Check that MuSig2 signing does not reuse nonces (Ava Chow)
bb05986c0a musig: Include pubnonce in session id (Ava Chow)

Pull request description:

  It is safe to have multiple musig signing sessions over the same message so long as the nonces used are different. Including the pubnonce in the session id allows for multiple simultaneous signing sessions over the same message, rather than asserting when the user tries to do this.

  The second commit tests this behavior, both ensuring that there is no crash, and verifying that both sessions produce unique nonces and signatures to verify that no reuse is occurring.

  Lastly, the assertion in `SetMuSig2SecNonce` is retained as hitting it now would indicate that a nonce has been reused. We prefer to assert and crash rather than do something that is highly likely to leak a private key.

  Fixes #35250

ACKs for top commit:
  rkrux:
    lgtm ACK 2ef6679c2c
  junbyjun1238:
    utACK 2ef6679c2c
  theStack:
    ACK 2ef6679c2c

Tree-SHA512: 9fb60b68ebe0ea9656408afb65b9ec9f280632e1bb84a4821b074c8d8569847845f7c29da800c757b9ddf3aa31aa890dd9e3646cf119917a714e7daf20be2198
2026-06-02 21:33:01 +02:00
Michael Dietz
7735c13488 test: run bitcoin-cli -ipcconnect check under valgrind with -datadir
This case invoked bitcoin-cli via raw subprocess.run() without the
valgrind wrapper (bypassing valgrind) and without -datadir (so it read
the default datadir's bitcoin.conf, e.g. ~/.bitcoin, and failed whenever
that real config was unusable). Build the command like the rest of the
framework: prepend binaries.valgrind_cmd and pass the node's -datadir so
the check runs under valgrind and depends only on the build's IPC
support, not the host environment.
2026-06-02 09:28:46 -05:00
merge-script
2e0a36c360 Merge bitcoin/bitcoin#35439: test: Improve loopback address check in rpc_bind.py
c8b8c275fa test: Improve loopback address check in `rcp_bind.py` (xyzconstant)

Pull request description:

  A [loopback address](https://www.geeksforgeeks.org/computer-networks/what-is-a-loopback-address/) can range from `127.0.0.0` to `127.255.255.255`. This commit relaxes the loopback check in `rpc_bind.py` by checking whether an IP address (from `all_interfaces()`) starts with `'127.'` instead of strictly matching `'127.0.0.1'`.

  Programs like VPNs might add an extra loopback address (e.g., 127.1.130.83), which failed under the previous state. These addresses will now pass with this update.

  ---
  **For context:** I found this while running tests with the Mullvad daemon active. Mullvad adds a custom lo0 interface like `inet 127.141.11.239 netmask 0xff000000` that failed with `--nonloopback`, which should not be the case since the address is a valid loopback IP.

ACKs for top commit:
  maflcko:
    lgtm ACK c8b8c275fa
  willcl-ark:
    ACK c8b8c275fa

Tree-SHA512: 3b82002d6bc90cfc4023dd0274a40970abb2dc6a9ced77dd97e275b31340bb657d5222bb55a768ebf71047ac1521dd4ba77fb427398f7cc9857738bcd16c5818
2026-06-02 12:36:28 +02:00
merge-script
255f7c720f Merge bitcoin/bitcoin#35404: wallet: allow anti-fee-sniping in sendall RPC while not relying on RBF default
9c1fcaca5c wallet, test: fix sendall anti-fee-sniping when locktime is not specified (rkrux)
8877eec726 wallet: allow anti-fee-sniping in sendall RPC while not relying on RBF default (rkrux)

Pull request description:

  Partially fixes https://github.com/bitcoin/bitcoin/issues/32661.
  Prerequisite to #35405.

  The test change in the second commit would fail without the presence
  of the first commit.

ACKs for top commit:
  maflcko:
    review ACK 9c1fcaca5c 🍅
  xyzconstant:
    Tested ACK 9c1fcaca5c
  polespinasa:
    code review ACK 9c1fcaca5c
  sedited:
    ACK 9c1fcaca5c

Tree-SHA512: 048c1a6c64c104f8c27053e4dea139fb8740f30096f4d85daf23aa53a9ad21f0120151a7d1d6ea19b12d174976999335b3f9ac863800629774d8030b7f34918f
2026-06-02 11:59:27 +02:00
xyzconstant
c8b8c275fa test: Improve loopback address check in rcp_bind.py
A loopback address can range from `127.0.0.0` to `127.255.255.255`.
This commit relaxes the loopback check in `rpc_bind.py` by checking whether
an IP address (from `all_interfaces()`) starts with `'127.'` instead of
strictly matching `'127.0.0.1'`.

Programs like VPNs might add an extra loopback address (e.g., 127.1.130.83),
which failed under the previous state. These addresses will now pass with this update.
2026-06-01 19:01:12 -03:00
Antoine Poinsot
1d5240574a qa: test we don't warn for ignored unknown version bits deployments
Co-Authored-by: Anthony Towns <aj@erisian.com.au>
2026-06-01 09:53:27 -04:00
Anthony Towns
f802edf57c versionbits: Limit live activation params and activation warnings per BIP323
Test bits are conserved. This only has an effect on the warnings.

Co-Authored-By: Antoine Poinsot <mail@antoinep.com>
2026-06-01 09:50:48 -04:00
Vasil Dimov
5a3756d150 test: add a regression test for private broadcast v1 retries 2026-05-30 06:32:19 +02:00