47094 Commits

Author SHA1 Message Date
merge-script
516ae5ede4
Merge bitcoin/bitcoin#31533: fuzz: Add fuzz target for block index tree and related validation events
db2d39f642979f929261e5f1cd67f0c2f2ca045f fuzz: add subtest for re-downloading a previously pruned block (Eugene Siegel)
45f5b2dac330906368352a1c585183f0d75d779d fuzz: Add fuzzer for block index (Martin Zumsande)
c011e3aa542631a8857039df796ebf13a653e8a6 test: Wrap validation functions with TestChainstateManager (Martin Zumsande)

Pull request description:

  This adds a fuzz target for the block index and various events in validation that interact with it.

  It can create arbitrary tree-like structure of block indexes, simulating (so far) the following events:
  - Adding a header
  - Receiving the full block (may be valid or not)
  - `ActivateBestChain()` - Reorging the chain to a new chain tip (possibly encountering invalid blocks on the way)
  - Pruning a block in the best chain
  - Receiving a previously pruned block again (`getblockfrompeer`)

  It might be interesting / possible to extend this to more events, such as dealing with more than one chainstate (assumeutxo).

  The test skips all actual validation of header/ block / transaction data by just simulating the outcome, and also doesn't interact with the data directory.
  The main goal is to ensure the integrity of the block index tree in all fuzzed constellations, by calling `CheckBlockIndex()` at the end of each iteration.

  Compared to #29158 this approach has a more limited scope (by skipping all actual validation), but it is fast - it doesn't do a full init sequence on each iteration, but "cleans up" after itself by resetting the global validation state after each iteration.

ACKs for top commit:
  Crypt-iQ:
    reACK db2d39f642
  maflcko:
    review ACK db2d39f642979f929261e5f1cd67f0c2f2ca045f 🍶
  sedited:
    Re-ACK db2d39f642979f929261e5f1cd67f0c2f2ca045f

Tree-SHA512: 76cd5f8f4d7d7258620b46d7438bad4508c3bdc98825b48b60f694b5a9838e2b2cf4967c0ead181f86f66f4939ddfe552471851b9d18f84f584c03dd7e09fc43
2025-12-18 15:26:42 +00:00
merge-script
9272fd517f
Merge bitcoin/bitcoin#34105: kernel: revert accidentally removed copyright header
85314dc0bf871226c0e43446bb79f49630d15f4a kernel: revert accidentally removed copyright header (Lőrinc)

Pull request description:

  Accidentally removed in #30595.
  The author mentioned it was likely a bad rebase.

  See:
  7990463b10 (diff-04e685224f1ac5bfd91d47d8d7528a2e44f94fab5535d4b6b5af79b5a13aeb93L1-L12)

  Found while reviewing https://github.com/bitcoin/bitcoin/pull/34084#issuecomment-3670396535

ACKs for top commit:
  fanquake:
    ACK 85314dc0bf871226c0e43446bb79f49630d15f4a

Tree-SHA512: 2b4f199e33f71c3051f1362a5e9eac66d48eb45d1216a65cd9d5a5cbba004445eddc3ff6f52132a151a353046e8a82cf7aed366b2100353731c5ce0a64d01d2c
2025-12-18 15:16:00 +00:00
Lőrinc
85314dc0bf
kernel: revert accidentally removed copyright header
See:
7990463b10 (diff-04e685224f1ac5bfd91d47d8d7528a2e44f94fab5535d4b6b5af79b5a13aeb93L1-L12)
2025-12-18 16:07:31 +01:00
merge-script
09a1fa190e
Merge bitcoin/bitcoin#34094: chore: bump checkout to v6
cd98caea438a61f1e2c6ea8331afa545478f8f94 Update ci.yml (Woolfgm)

Pull request description:

  Updated actions/checkout from v5 to v6 in ci.yml workflow

ACKs for top commit:
  fanquake:
    ACK cd98caea438a61f1e2c6ea8331afa545478f8f94

Tree-SHA512: c2e8168400e0ef959d9a166070a91196d4b6abefda557b7a455fe4e5e6295d10132fb2c46885072379b844a9a9bd6adb25ac3301461db446c610967ca3363fbf
2025-12-18 12:20:25 +00:00
merge-script
80b1b5917d
Merge bitcoin/bitcoin#34088: log: Use __func__ for -logsourcelocations
facd3d56ccbe2414a5f2b75be7132cd8b904f1e9 log: Use `__func__` for -logsourcelocations (MarcoFalke)

Pull request description:

  The `-logsourcelocations` option was recently changed to print the full function signature, as a side-effect of moving toward `std::source_location` internally.

  This is fine, but at least for me, it makes debugging functional test failures harder, because the log is just so massively verbose, with questionable benefit.

  I think the historically used file name, line number, and plain `__func__` name are more than sufficient for `-logsourcelocations`.

  So switch back to using that.

  For reference, a verbose log may look like:

  ```
  ...
  node0 2025-12-17T07:28:37.528146Z [init] [checkqueue.h:147] [CCheckQueue<T, R>::CCheckQueue(unsigned int, int) [with T = CScriptCheck; R = std::pair<ScriptError_t, std::__cxx11::basic_string<char> >]] Script verificatio
  n uses 1 additional threads
  ...
  ```

  I don't think there is value in printing stuff, like the (anon) namespace, the class template args, or the functionn (template) args. The following should be more than sufficient:

  ```
  ...
  node0 2025-12-17T09:45:57.017122Z [init] [checkqueue.h:147] [CCheckQueue] Script verification uses 1 additional threads
  ...

ACKs for top commit:
  ajtowns:
    ACK facd3d56ccbe2414a5f2b75be7132cd8b904f1e9 -- those long signatures are terrible
  stickies-v:
    ACK facd3d56ccbe2414a5f2b75be7132cd8b904f1e9

Tree-SHA512: 22fd1f0074fc6e85754967f9219659f57c905005a2bea9176f0b439abec324d7e6c2f875c8951934a3b11ef7e9d7e38d5d5d307e2bd1e000bc27ee85635cd668
2025-12-18 12:17:20 +00:00
merge-script
3a2807ad95
Merge bitcoin/bitcoin#33875: qa: Account for unset errno in ConnectionResetError
76e0e6087d0310ec31f43d751de60adf0c0a2faa qa: Account for errno not always being set for ConnectionResetError (Hodlinator)

Pull request description:

  The lack of errno can cause unclear and long log output.

  Issue can be triggered by:

  ```diff
  --- a/src/httpserver.cpp
  +++ b/src/httpserver.cpp
  @@ -263,6 +263,7 @@ std::string RequestMethodString(HTTPRequest::RequestMethod m)
   /** HTTP request callback */
   static void http_request_cb(struct evhttp_request* req, void* arg)
   {
  +    throw std::runtime_error{"Hello"};
       evhttp_connection* conn{evhttp_request_get_connection(req)};
       // Track active requests
       {
  ```
  and running a functional test such as *test/functional/feature_abortnode.py*.

  `http.client.RemoteDisconnected` not specifying `errno` to `ConnectionResetError`-ctor: ce4b0ede16/Lib/http/client.py (L1556C9-L1556C29)

  <details><summary>Before/after log examples</summary>

  #### Log before
  ```
  2025-11-14T20:53:05.272804Z TestFramework (ERROR): Unexpected exception
  Traceback (most recent call last):
    File "/home/hodlinator/bc/3/test/functional/test_framework/test_framework.py", line 138, in main
      self.setup()
      ~~~~~~~~~~^^
    File "/home/hodlinator/bc/3/test/functional/test_framework/test_framework.py", line 268, in setup
      self.setup_network()
      ~~~~~~~~~~~~~~~~~~^^
    File "/home/hodlinator/bc/3/./build/test/functional/feature_abortnode.py", line 21, in setup_network
      self.setup_nodes()
      ~~~~~~~~~~~~~~~~^^
    File "/home/hodlinator/bc/3/test/functional/test_framework/test_framework.py", line 381, in setup_nodes
      self.start_nodes()
      ~~~~~~~~~~~~~~~~^^
    File "/home/hodlinator/bc/3/test/functional/test_framework/test_framework.py", line 527, in start_nodes
      node.wait_for_rpc_connection()
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
    File "/home/hodlinator/bc/3/test/functional/test_framework/test_node.py", line 326, in wait_for_rpc_connection
      rpc.getblockcount()
      ~~~~~~~~~~~~~~~~~^^
    File "/home/hodlinator/bc/3/test/functional/test_framework/coverage.py", line 50, in __call__
      return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
    File "/home/hodlinator/bc/3/test/functional/test_framework/authproxy.py", line 137, in __call__
      response, status = self._request('POST', self.__url.path, postdata.encode('utf-8'))
                         ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/hodlinator/bc/3/test/functional/test_framework/authproxy.py", line 111, in _request
      return self._get_response()
             ~~~~~~~~~~~~~~~~~~^^
    File "/home/hodlinator/bc/3/test/functional/test_framework/authproxy.py", line 174, in _get_response
      http_response = self.__conn.getresponse()
    File "/nix/store/62fdlzq1x1ak2lsxp4ij7ip5k9nia3hc-python3-3.13.7/lib/python3.13/http/client.py", line 1430, in getresponse
      response.begin()
      ~~~~~~~~~~~~~~^^
    File "/nix/store/62fdlzq1x1ak2lsxp4ij7ip5k9nia3hc-python3-3.13.7/lib/python3.13/http/client.py", line 331, in begin
      version, status, reason = self._read_status()
                                ~~~~~~~~~~~~~~~~~^^
    File "/nix/store/62fdlzq1x1ak2lsxp4ij7ip5k9nia3hc-python3-3.13.7/lib/python3.13/http/client.py", line 300, in _read_status
      raise RemoteDisconnected("Remote end closed connection without"
                               " response")
  http.client.RemoteDisconnected: Remote end closed connection without response
  ```

  #### Log after

  ```
  2025-11-14T20:48:10.552126Z TestFramework (ERROR): Unexpected exception
  Traceback (most recent call last):
    File "/home/hodlinator/bc/3/test/functional/test_framework/test_framework.py", line 138, in main
      self.setup()
      ~~~~~~~~~~^^
    File "/home/hodlinator/bc/3/test/functional/test_framework/test_framework.py", line 268, in setup
      self.setup_network()
      ~~~~~~~~~~~~~~~~~~^^
    File "/home/hodlinator/bc/3/./build/test/functional/feature_abortnode.py", line 21, in setup_network
      self.setup_nodes()
      ~~~~~~~~~~~~~~~~^^
    File "/home/hodlinator/bc/3/test/functional/test_framework/test_framework.py", line 381, in setup_nodes
      self.start_nodes()
      ~~~~~~~~~~~~~~~~^^
    File "/home/hodlinator/bc/3/test/functional/test_framework/test_framework.py", line 527, in start_nodes
      node.wait_for_rpc_connection()
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
    File "/home/hodlinator/bc/3/test/functional/test_framework/test_node.py", line 316, in wait_for_rpc_connection
      raise FailedToStartError(self._node_msg(
          f'bitcoind exited with status {self.process.returncode} during initialization. {str_error}'))
  test_framework.test_node.FailedToStartError: [node 0] bitcoind exited with status -6 during initialization. terminate called after throwing an instance of 'std::runtime_error'
    what():  Hello
  ************************
  ```
  Note how even the C++ exception message is now included.

  </details>

ACKs for top commit:
  maflcko:
    review ACK 76e0e6087d0310ec31f43d751de60adf0c0a2faa 🌬
  furszy:
    Tested ACK 76e0e6087d0310ec31f43d751de60adf0c0a2faa
  l0rinc:
    untested code review ACK 76e0e6087d0310ec31f43d751de60adf0c0a2faa

Tree-SHA512: 55a83d664624932b919ab2a5b6369121db448d27628029f21c5df297892dd56d179d710ad744f6407b51aa576fb6905a38bbc29885c534ec20704c22717a0880
2025-12-18 11:46:13 +00:00
merge-script
8d38b6f5f1
Merge bitcoin/bitcoin#34091: fuzz: doc: remove any mention to address_deserialize_v2
caf4843a59a9d2512d69f8fd88a9672112bd80ac fuzz: doc: remove any mention to address_deserialize_v2 (brunoerg)

Pull request description:

  We don't have `address_deserialize_v2` target anymore since fac81affb527132945773a5315bd27fec61ec52f (we used to have `address_deserialize_v1_notime`, `address_deserialize_v1_withtime` and `address_deserialize_v2` but now we only have a single `address_deserialize` target) so it removes any mention to it.

ACKs for top commit:
  maflcko:
    review ACK caf4843a59a9d2512d69f8fd88a9672112bd80ac 🎾
  marcofleon:
    ACK caf4843a59a9d2512d69f8fd88a9672112bd80ac

Tree-SHA512: 539d69edbfe4ca11eb0701ed5c789ad81976e3e85e8a229e39e9dc1b1c72264f01d10a1c16d0a3bb4a354794412dc8b625298f4f72430905a00b65faeaa37d6b
2025-12-18 11:35:41 +00:00
Woolfgm
cd98caea43
Update ci.yml 2025-12-17 22:41:02 +01:00
Ryan Ofsky
ab513103df
Merge bitcoin/bitcoin#33192: refactor: unify container presence checks
d9319b06cf82664d55f255387a348135fd7f91c7 refactor: unify container presence checks - non-trivial counts (Lőrinc)
039307554eb311ce41648d1f9a12b543f480f871 refactor: unify container presence checks - trivial counts (Lőrinc)
8bb9219b6301215f53e43967d17445aaf1b81090 refactor: unify container presence checks - find (Lőrinc)

Pull request description:

  ### Summary
  Instead of counting occurrences in sets and maps, the C++20 `::contains` method expresses the intent unambiguously and can return early on first encounter.

  ### Context
  Applied clang‑tidy's [readability‑container‑contains](https://clang.llvm.org/extra/clang-tidy/checks/readability/container-contains.html) check, though many cases required manual changes since tidy couldn't fix them automatically.

  ### Changes
  The changes made here were:

  | From                   | To               |
  |------------------------|------------------|
  | `m.find(k) == m.end()` | `!m.contains(k)` |
  | `m.find(k) != m.end()` | `m.contains(k)`  |
  | `m.count(k)`           | `m.contains(k)`  |
  | `!m.count(k)`          | `!m.contains(k)` |
  | `m.count(k) == 0`      | `!m.contains(k)` |
  | `m.count(k) != 1`      | `!m.contains(k)` |
  | `m.count(k) == 1`      | `m.contains(k)`  |
  | `m.count(k) < 1`       | `!m.contains(k)`  |
  | `m.count(k) > 0`       | `m.contains(k)`  |
  | `m.count(k) != 0`      | `m.contains(k)`  |

  > Note that `== 1`/`!= 1`/`< 1` only apply to simple [maps](https://en.cppreference.com/w/cpp/container/map/contains)/[sets](https://en.cppreference.com/w/cpp/container/set/contains) and had to be changed manually.

  There are many other cases that could have been changed, but we've reverted most of those to reduce conflict with other open PRs.

  -----

  <details>
  <summary>clang-tidy command on Mac</summary>

  ```bash
  rm -rfd build && \
  cmake -B build \
    -DCMAKE_C_COMPILER="$(brew --prefix llvm)/bin/clang" \
    -DCMAKE_CXX_COMPILER="$(brew --prefix llvm)/bin/clang++" \
    -DCMAKE_OSX_SYSROOT="$(xcrun --show-sdk-path)" \
    -DCMAKE_C_FLAGS="-target arm64-apple-macos11" \
    -DCMAKE_CXX_FLAGS="-target arm64-apple-macos11" \
    -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON -DBUILD_FOR_FUZZING=ON

   "$(brew --prefix llvm)/bin/run-clang-tidy" -quiet -p build -j$(nproc) -checks='-*,readability-container-contains' | grep -v 'clang-tidy'
  ```

  </details>

  Note: this is a take 2 of https://github.com/bitcoin/bitcoin/pull/33094 with fewer contentious changes.

ACKs for top commit:
  optout21:
    reACK d9319b06cf82664d55f255387a348135fd7f91c7
  sedited:
    ACK d9319b06cf82664d55f255387a348135fd7f91c7
  janb84:
    re ACK d9319b06cf82664d55f255387a348135fd7f91c7
  pablomartin4btc:
    re-ACK d9319b06cf82664d55f255387a348135fd7f91c7
  ryanofsky:
    Code review ACK d9319b06cf82664d55f255387a348135fd7f91c7. I manually reviewed the full change, and it seems there are a lot of positive comments about this and no more very significant conflicts, so I will merge it shortly.

Tree-SHA512: e4415221676cfb88413ccc446e5f4369df7a55b6642347277667b973f515c3c8ee5bfa9ee0022479c8de945c89fbc9ff61bd8ba086e70f30298cbc1762610fe1
2025-12-17 16:17:29 -05:00
MarcoFalke
facd3d56cc
log: Use __func__ for -logsourcelocations 2025-12-17 18:35:49 +01:00
merge-script
fe0e31f1ef
Merge bitcoin/bitcoin#34053: lint: Remove confusing, redundant, and brittle lint-spelling
fa904fc683c0892eb800ddb986fdc0c646721077 lint: Remove confusing, redundant, and brittle lint-spelling (MarcoFalke)

Pull request description:

  `codespell` was a fun experiment. However, it has many issues, when used in this project:

  * The number of false-positives and true-positives are in the same ballpark. There are also many false-negatives, so the overall net-benefit is questionable.
  * There is often confusion around spelling errors leading to a failing CI (they do not, which was intended).
  * LLMs released this year are capable to detect typos with less false-positives and less false-negatives, so the `codespell` integration is a bit redundant in that sense.

  Fix all issues by removing it.

  Going forward, anyone is free to continue to use `codespell`, or any LLM, or any other tool, locally. Also, DrahtBot has the LLM typo linter integrated in the summary comment. I think the options are plenty, and are more than sufficient for now.

ACKs for top commit:
  l0rinc:
    ACK fa904fc683c0892eb800ddb986fdc0c646721077
  rkrux:
    ACK fa904fc683c0892eb800ddb986fdc0c646721077
  pablomartin4btc:
    ACK fa904fc683c0892eb800ddb986fdc0c646721077

Tree-SHA512: 5e2008a77c2c313605f30d73286111eba034a2a6bb2a0a48e2f77ec6ccc7afaa274e00bbfcb727be0ac5e547b8ae9c801d30c43589b0cad2099565e6716b9ec7
2025-12-17 17:19:45 +00:00
merge-script
e5c600dc0e
Merge bitcoin/bitcoin#34063: Make transaction_indentifier hex string constructor evaluated at comptime
5ac35795206d252c9f464e967b84521ddaad38f1 refactor: Add compile-time-checked hex txid (rustaceanrob)

Pull request description:

  Suggested by l0rinc as a comment in #34004.

  There are tests that utilize `FromHex` that will only fail during runtime if malformed. Adds a compile time constructor that can be caught by LSPs.

ACKs for top commit:
  l0rinc:
    ACK 5ac35795206d252c9f464e967b84521ddaad38f1
  maflcko:
    review ACK 5ac35795206d252c9f464e967b84521ddaad38f1 🦎
  rkrux:
    crACK 5ac35795206d252c9f464e967b84521ddaad38f1

Tree-SHA512: b0bae2bf0b8cd8c9a90765a14c46146313cf8b224a29d58a253e65ca95c4205c0beddea9c49ae58901e72c8c5202b91695d074ffb1c48e448d2e5606eb1bd5b4
2025-12-17 17:16:30 +00:00
Hennadii Stepanov
41f2cc6d3d
Merge bitcoin-core/gui#919: move-only: MAX_BLOCK_TIME_GAP to src/qt
fa5ed16aa4d9dbe3ed47cb53f3cb15b0685a2b96 move-only: MAX_BLOCK_TIME_GAP to src/qt (MarcoFalke)

Pull request description:

  `MAX_BLOCK_TIME_GAP` was used in some incorrect heuristics, which were removed in commit e30b6ea194fee3bb95a45e7b732a99566b88f1f5.

  This leaves a single module in src/qt using the constant.

  Instead of exposing it in a central kernel header, just move it to the single gui module that uses it.

ACKs for top commit:
  sedited:
    ACK fa5ed16aa4d9dbe3ed47cb53f3cb15b0685a2b96
  hebasto:
    ACK fa5ed16aa4d9dbe3ed47cb53f3cb15b0685a2b96, I have reviewed the code and it looks OK.

Tree-SHA512: d0e0e5257f6585d793bfed118d61a3e5d56b2be397fa3b09b34db64e3e018eba9f223cd56541d258b422119fdd7501f07cd3bb8ad5dc28b535922aa21ea76fa6
2025-12-17 17:11:59 +00:00
merge-script
7c7cd8c296
Merge bitcoin/bitcoin#34089: contrib: asmap-tool.py - Don't write binary to TTY
e7e51952dc24531932b6c06e4599be3a3d6bede8 contrib: Avoid outputting binary data to TTY (Hodlinator)

Pull request description:

  Verify that we wouldn't be writing encoded asmap binary data directly to the TTY since it is the default but makes no sense. (Having stdout as default does make sense when piping to other applications however).

  Found while exploring the ASMap data pipeline (https://github.com/asmap/asmap-data/pull/38#pullrequestreview-3547352533) from Kartograf into Bitcoin Core.

ACKs for top commit:
  fjahr:
    tACK e7e51952dc24531932b6c06e4599be3a3d6bede8
  sipa:
    ACK e7e51952dc24531932b6c06e4599be3a3d6bede8

Tree-SHA512: e1ae1ee129715471cbb824268e68cec267d159d4073297af35c06eadfb6b98eeae040beaafeb6489c2853ea9b83cd04471bcd0b27f0ae8fcb377e6e10b4ae6c5
2025-12-17 15:16:30 +00:00
merge-script
e3a4cb127f
Merge bitcoin/bitcoin#34080: ci: Pin native tests on cross-builds to same commit
faa8ee62f5c1606217fbe9eacdd504ec133920a4 ci: Pin native tests on cross-builds to same commit (MarcoFalke)

Pull request description:

  After commit 13809b867ad980a12f886316b18bb2d3d2848ac2, the native tests may check out a different commit than the cross-build task that produced the artefacts they run on.

  Obviously, this may lead to test failures.

  Fix it, by first determining a fixed commit, to be used for both the build and the native tests.

  An alternative could be to fully or partially revert 13809b867ad980a12f886316b18bb2d3d2848ac2, but that comes again with the downsides making it harder to detect silent merge conflicts by re-running CI, or clearing unrelated and fixed intermittent test issues by re-running CI. Then, the only alternative would be to close and re-open the pull request.

ACKs for top commit:
  janb84:
    ACK faa8ee62f5c1606217fbe9eacdd504ec133920a4
  ryanofsky:
    Code review ACK faa8ee62f5c1606217fbe9eacdd504ec133920a4. Thanks for the naming & display updates since last review!
  hodlinator:
    crACK faa8ee62f5c1606217fbe9eacdd504ec133920a4

Tree-SHA512: 01391cdfad34e3f2f5b3a6247b1aeb412d023e368bc17572aa66324688439786e79e263288276053ffcfa8521635b07339dbf087b8a30d6670373556a77c22ee
2025-12-17 15:15:58 +00:00
merge-script
a005fdff6c
Merge bitcoin/bitcoin#34074: A few followups after introducing /rest/blockpart/ endpoint
59b93f11e8600d5224359f4d05619c0f56aef1e6 rest: print also HTTP response reason in case of an error (Roman Zeyde)
7fe94a04934a89b63f1248cb46d59f0ab45439b5 rest: add a test for unsuported `/blockpart/` request type (Roman Zeyde)
55d0d19b5c02a65d8dfafd99f352769224ab51a4 rest: deduplicate `interface_rest.py` negative tests (Roman Zeyde)
89eb531024d9921f5c825d390b90c0a7bd3756cc rest: update release notes for `/blockpart/` endpoint (Roman Zeyde)
41118e17f87561afc8cbe1f3dd528624f06906a7 blockstorage: simplify partial block read validation (Roman Zeyde)
599effdeab4d6687da783de04f8edf1d88959169 rest: reformat `uri_prefixes` initializer list (Roman Zeyde)

Pull request description:

  The commits below should resolve a few leftovers from #33657.

ACKs for top commit:
  l0rinc:
    ACK 59b93f11e8600d5224359f4d05619c0f56aef1e6
  hodlinator:
    re-ACK 59b93f11e8600d5224359f4d05619c0f56aef1e6

Tree-SHA512: ae45e08edd315018e11283b354fb32f9658f5829c956554dc662a81c2e16397def7c3700e6354e0a91ff03c850def35638a69ec2668b7c015d25d6fed42b92bb
2025-12-17 15:09:15 +00:00
brunoerg
caf4843a59 fuzz: doc: remove any mention to address_deserialize_v2 2025-12-17 11:57:11 -03:00
MarcoFalke
fa5ed16aa4
move-only: MAX_BLOCK_TIME_GAP to src/qt
Can be reviewed via the git option:
--color-moved=dimmed-zebra
2025-12-17 13:55:03 +01:00
Roman Zeyde
59b93f11e8 rest: print also HTTP response reason in case of an error 2025-12-17 00:14:10 +01:00
Roman Zeyde
7fe94a0493 rest: add a test for unsuported /blockpart/ request type 2025-12-17 00:14:10 +01:00
MarcoFalke
faa8ee62f5
ci: Pin native tests on cross-builds to same commit 2025-12-16 18:04:42 +01:00
Eugene Siegel
db2d39f642 fuzz: add subtest for re-downloading a previously pruned block
This imitates the use of the getblockfrompeer rpc.
Note that currently pruning is limited to blocks in the active chain.

Co-authored-by: Martin Zumsande <mzumsande@gmail.com>
2025-12-16 11:25:46 -05:00
Martin Zumsande
45f5b2dac3 fuzz: Add fuzzer for block index
This fuzz target creates arbitrary tree-like structure of indices,
simulating the following events:
- Adding a header to the block tree db
- Receiving the full block (may be valid or not)
- Reorging to a new chain tip (possibly encountering invalid blocks on
  the way)
- pruning
The test skips all actual validation of header/ block / transaction data
by just simulating the outcome, and also doesn't interact with the data directory.

The main goal is to test the integrity of the block index tree in
all fuzzed constellations, by calling CheckBlockIndex()
at the end of each iteration.
2025-12-16 11:25:46 -05:00
Martin Zumsande
c011e3aa54 test: Wrap validation functions with TestChainstateManager
This allows to access them in the fuzz test in the next commit
without making them public.

Co-authored-by: TheCharlatan <seb.kung@gmail.com>
2025-12-16 11:25:46 -05:00
merge-script
13891a8a68
Merge bitcoin/bitcoin#34050: fuzz: exercise ComputeMerkleRoot without mutated parameter
7e9de20c0c144f5ccea5efe6d90601dd72bc7461 fuzz: exercise `ComputeMerkleRoot` without mutated parameter (Lőrinc)

Pull request description:

  The `mutated` parameter in `ComputeMerkleRoot` unlocks a different path that was always exercised in the fuzz test.
  Adjusted to be fuzzer to pass `nullptr` as well to make sure that path is also tested: 24ed820d4f/src/consensus/merkle.cpp (L49-L53)

  Follow-up to https://github.com/bitcoin/bitcoin/pull/33805#discussion_r2589073735

ACKs for top commit:
  frankomosh:
    ACK [7e9de20](7e9de20c0c)
  hodlinator:
    ACK 7e9de20c0c144f5ccea5efe6d90601dd72bc7461
  sedited:
    ACK 7e9de20c0c144f5ccea5efe6d90601dd72bc7461

Tree-SHA512: bf27029ac04003447b24a95544ec863f9ceca6c28d51ea811dd6ca2b412a2a780bb9fdbcdc82719f39dd710a746eb2446263e8377d67a8be52a1694571d03498
2025-12-16 14:25:55 +00:00
merge-script
ab643efc0a
Merge bitcoin/bitcoin#34003: test: interface_ipc.py minor fixes and cleanup
d8fe5f0326c5c0505e0f7e6e978961d24c27b175 test: improve interface_ipc.py waitNext tests (Ryan Ofsky)
a5e61b1917aff7567599beb59cc7093978b7e336 test: interface_ipc.py minor fixes and cleanup (Ryan Ofsky)
ded11fb04d8231dd820bfa04b11a4b7b2b0a06f8 test: fix interface_ipc.py template destruction (Ryan Ofsky)

Pull request description:

  This PR cleans up the `interface_ipc.py` test, fixing broken checks, fixing missing await calls, removing to_dict calls, renaming variables, reducing `.result` accesses, and giving template objects explicit lifetimes. More details are in the commit messages.

  The first commit changes a lot of indentation so is easiest to review ignoring whitespace.

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

Tree-SHA512: f0de309a15cb23f109cf6909e51ddd132a60bd4d4cb25b20bdc74545516670f1cdb0c9cc98c397c2f24e67e2380c2dac9d00435009618a3c00b6b85cca5c3e2e
2025-12-16 14:05:20 +00:00
merge-script
4f11ef058b
Merge bitcoin/bitcoin#30214: refactor: Improve assumeutxo state representation
82be652e40ec7e1bea4b260ee804a92a3e05f496 doc: Improve ChainstateManager documentation, use consistent terms (Ryan Ofsky)
af455dcb39dbd53700105e29c87de5db65ecf43c refactor: Simplify pruning functions (TheCharlatan)
ae85c495f1b507ca5871ea98f5d884fccb15adba refactor: Delete ChainstateManager::GetAll() method (Ryan Ofsky)
6a572dbda92ceb8c5af379f51cf6f9b93fb5e486 refactor: Add ChainstateManager::ActivateBestChains() method (Ryan Ofsky)
491d827d5284ed984ee2b11daaee50321217eac5 refactor: Add ChainstateManager::m_chainstates member (Ryan Ofsky)
e514fe61168109bd467d7cb2ac7561442b17b5f6 refactor: Delete ChainstateManager::SnapshotBlockhash() method (Ryan Ofsky)
ee35250683ab9a395b70a0e90ebc68b1858387c7 refactor: Delete ChainstateManager::IsSnapshotValidated() method (Ryan Ofsky)
d9e82299fc4e45fbc0f5a34dcbb1d51397d0bd35 refactor: Delete ChainstateManager::IsSnapshotActive() method (Ryan Ofsky)
4dfe383912761669a968f8535ed43437da160ec8 refactor: Convert ChainstateRole enum to struct (Ryan Ofsky)
352ad27fc1b1b350c8dbeb26a9813b01025cad31 refactor: Add ChainstateManager::ValidatedChainstate() method (Ryan Ofsky)
a229cb9477e6622087241be7a105551d1329503b refactor: Add ChainstateManager::CurrentChainstate() method (Ryan Ofsky)
a9b7f5614c24fe6f386448604c325ec4fa6c98a5 refactor: Add Chainstate::StoragePath() method (Ryan Ofsky)
840bd2ef230ed0582fe33a90ec2636bfefa21709 refactor: Pass chainstate parameters to MaybeCompleteSnapshotValidation (Ryan Ofsky)
1598a15aedb9fd9c4e4a671785ebebf56fc1e072 refactor: Deduplicate Chainstate activation code (Ryan Ofsky)
9fe927b6d654e752dac82156e209e45d31b75779 refactor: Add Chainstate m_assumeutxo and m_target_utxohash members (Ryan Ofsky)
6082c84713f42f5fa66f9a76baef17e8ed231633 refactor: Add Chainstate::m_target_blockhash member (Ryan Ofsky)
de00e87548f7ddd623355b7094924b0387a36280 test: Fix broken chainstatemanager_snapshot_init check (Ryan Ofsky)

Pull request description:

  This PR contains the first part of #28608, which tries to make assumeutxo code more maintainable, and improve it by not locking `cs_main` for a long time when the snapshot block is connected, and by deleting the snapshot validation chainstate when it is no longer used, instead of waiting until the next restart.

  The changes in this PR are just refactoring. They make `Chainstate` objects self-contained, so for example, it is possible to determine what blocks to connect to a chainstate without querying `ChainstateManager`, and to determine whether a Chainstate is validated without basing it on inferences like `&cs != &ActiveChainstate()` or `GetAll().size() == 1`.

  The PR also tries to make assumeutxo terminology less confusing, using "current chainstate" to refer to the chainstate targeting the current network tip, and "historical chainstate" to refer to the chainstate downloading old blocks and validating the assumeutxo snapshot. It removes uses of the terms "active chainstate," "usable chainstate," "disabled chainstate," "ibd chainstate," and "snapshot chainstate" which are confusing for various reasons.

ACKs for top commit:
  maflcko:
    re-review ACK 82be652e40ec7e1bea4b260ee804a92a3e05f496 🕍
  fjahr:
    re-ACK 82be652e40ec7e1bea4b260ee804a92a3e05f496
  sedited:
    Re-ACK 82be652e40ec7e1bea4b260ee804a92a3e05f496

Tree-SHA512: 81c67abba9fc5bb170e32b7bf8a1e4f7b5592315b4ef720be916d5f1f5a7088c0c59cfb697744dd385552f58aa31ee36176bae6a6e465723e65861089a1252e5
2025-12-16 14:03:34 +00:00
merge-script
cbafd3ddf8
Merge bitcoin/bitcoin#34060: test: fix race condition in p2p_v2_misbehaving.py peerid assertion
09dfa4d3f8dfbea61a73d4add79e2464ca776571 test: fix race condition in p2p_v2_misbehaving.py peerid assertion (stratospher)

Pull request description:

  Remove the hard-coded peer id from the debug message in `p2p_v2_misbehaving.py`.

  asyncio's non-deterministic task scheduling might cause [peer2](938d7aacab/test/functional/p2p_v2_misbehaving.py (L181))'s connection to happen before [peer1](938d7aacab/test/functional/p2p_v2_misbehaving.py (L179))'s. since we test that peer2 [remains connected](938d7aacab/test/functional/p2p_v2_misbehaving.py (L182)), any disconnection must originate from peer1, making the specific peer id not necessary for test correctness. so we can remove the hard coded peer id from the expected debug log message.

  Fixes #34035.

ACKs for top commit:
  maflcko:
    lgtm ACK 09dfa4d3f8dfbea61a73d4add79e2464ca776571
  mzumsande:
    Code Review ACK 09dfa4d3f8dfbea61a73d4add79e2464ca776571

Tree-SHA512: 542b08ddae09db7454e8c08b1d26aade50a53c2505683df99556cf071a6a38195b64f8700f6db3f4e1b318497fc4b5232246ad4e9d6f3af45fad83e333fa91fb
2025-12-16 13:55:52 +00:00
Roman Zeyde
55d0d19b5c rest: deduplicate interface_rest.py negative tests 2025-12-15 23:34:35 +01:00
Roman Zeyde
89eb531024 rest: update release notes for /blockpart/ endpoint 2025-12-15 23:34:35 +01:00
Hennadii Stepanov
41bf8f2d5e
Merge bitcoin-core/gui#877: Add a menu action to restore then migrate a legacy wallet
14371fd1fca5c88764073a015aa3ff2ac96710bf gui: Add a menu item to restore then migrate a wallet file (Ava Chow)
f11a7d248cf5bdac5164bf527054b0822b5294ab gui: Add restore_and_migrate function to restore then migrate a wallet (Ava Chow)
16ab6dfc1074b43c6fa80181574dc6e77b9aae1c gui: Move actual migration part of migrate() to its own function (Ava Chow)
4ec2d18a0734f44c0a74f05b59ad1269d323dfdb wallet, interfaces, gui: Expose load_after_restore parameter (Ava Chow)

Pull request description:

  Some users will have a backup of their legacy wallet. These cannot be restored since the "Restore Wallet" action expects to be able to load the wallet after restoring, and this fails for legacy wallets now that they are deleted. Furthermore, the "Migrate Wallet" action only allows users to migrate wallets that are in the wallets directory, so such backups cannot be migrated from the GUI.

  This PR resolves this issue by adding a menu item in the "Migrate Wallet" menu which allows users to select their backup file so that it will first be restored but not loaded, and then migrated.

  Depends on https://github.com/bitcoin/bitcoin/pull/32620

ACKs for top commit:
  hebasto:
    ACK 14371fd1fca5c88764073a015aa3ff2ac96710bf.

Tree-SHA512: 2b09c012f4c70d0cb283305bf3d1a18ae5a2bfb80977c91544ac1fbc29d6360df49438cfdc8f66661ddb42ddab728c8ef1f9e0d7031877fbd846f9cea957398e
2025-12-15 15:42:40 +00:00
merge-script
2210feb446
Merge bitcoin/bitcoin#34051: log: Remove brittle and confusing LogPrintLevel
fa8a5d215c5a81a7282fd5dd1098f9d3fa40e5db log: Remove brittle and confusing LogPrintLevel (MarcoFalke)
fac24bbec85fc930900ff755192a9954c7c2e27c test: Clarify logging_SeverityLevels test (MarcoFalke)
f2731676619d14fa4527aa9086fb73078d20f26f ipc: separate log statements per level (stickies-v)
94c51ae540723f5f648477789c11f6395730ae05 libevent: separate log statements per level (stickies-v)

Pull request description:

  `LogPrintLevel` has many issues:

  * It encourages to log several levels in one source location. This is problematic, because all levels (even warnings and errors) will be rate limited equally for the same location.
  * Its warning and error logs are specially formatted compared to all other warning and error logs in the codebase, making them harder to spot (both in the debug log and in the code).
  * It is verbose to type and read.
  * It is confusing, because the majority of code uses the `Log$LEVEL(...)` macros. Having less ways to achieve the same makes the code more consistent and easier to review.

  Fix all issues by removing it

ACKs for top commit:
  stickies-v:
    re-ACK fa8a5d215c5a81a7282fd5dd1098f9d3fa40e5db
  ajtowns:
    ACK fa8a5d215c5a81a7282fd5dd1098f9d3fa40e5db
  pablomartin4btc:
    re-ACK fa8a5d215c5a81a7282fd5dd1098f9d3fa40e5db

Tree-SHA512: 9fbb04962d9c26e566338694a7725b3c0e88ef733322d890bcc6aeddb45266c754e7c885c69bbfebd1588cc09912c6784cfc00e69882f1271a8c87d201490478
2025-12-14 12:30:48 +00:00
merge-script
58251bf9fa
Merge bitcoin/bitcoin#34061: fuzz: Fix bugs in clusterlin_postlinearize_tree target
a70a14a3f4f4d66025302c00eb4ff8108835cc5d refactor: Separate out logic for building a tree-shaped dependency graph (marcofleon)
ce29d7d6262c8ba2e258b36794992ec79feb6e1f fuzz: Fix variable in `clusterlin_postlinearize_tree` check (marcofleon)
876e2849b4ec9e1f4b89773c2faadcca77831b82 fuzz: Fix incorrect loop bounds in `clusterlin_postlinearize_tree` (marcofleon)

Pull request description:

  Addresses two issues in the `clusterlin_postlinearize_tree` target:

  1. The loop iteration while creating tree dependency graphs was incorrect.
  2. We were accidentally passing in `post_linearization` to `PostLinearize` instead of the copy we just made, resulting in an ineffective check.

ACKs for top commit:
  sipa:
    ACK a70a14a3f4f4d66025302c00eb4ff8108835cc5d
  instagibbs:
    ACK a70a14a3f4f4d66025302c00eb4ff8108835cc5d

Tree-SHA512: 2cc1b70d572250d8e7b8db8957ae1f3447f8524c09e638ce08af27ff3f6b7aace3cf834c300f2a7947553cc919e2feedfd64355ff94eb2311fb9cd632cb7358a
2025-12-14 12:16:28 +00:00
Roman Zeyde
41118e17f8 blockstorage: simplify partial block read validation
Use `SaturatingAdd` following https://github.com/bitcoin/bitcoin/pull/33657#discussion_r2610832092.
2025-12-14 10:44:12 +01:00
Roman Zeyde
599effdeab rest: reformat uri_prefixes initializer list
There was an extra indentation level (found during #33657):
```
$ git show -U0 07135290c1 | ./contrib/devtools/clang-format-diff.py -p1 -i -v
```
2025-12-14 10:04:37 +01:00
rustaceanrob
5ac3579520
refactor: Add compile-time-checked hex txid
Suggested by @l0rinc in #34004

Message by @l0rinc:

This adds a consteval constructor to transaction_identifier (Txid/Wtxid) to allow parsing hex strings at compile-time.
This replaces runtime FromHex checks in tests, ensuring that malformed hardcoded hashes cause build failures rather than runtime test failures.

Test variables are explicitly marked constexpr. This is required to workaround a regression in GCC 14 (Bug 117501) where the compiler incorrectly flags consteval initialization of non-constexpr variables as "statements with no effect".

GCC Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117501
Reproducer: https://godbolt.org/z/xb5TMaPs6

Co-authored-by: l0rinc <pap.lorinc@gmail.com>
2025-12-13 18:23:48 +00:00
MarcoFalke
fa8a5d215c
log: Remove brittle and confusing LogPrintLevel 2025-12-13 13:43:24 +01:00
MarcoFalke
fac24bbec8
test: Clarify logging_SeverityLevels test
The test was a bit confusing, because it just referred to the "global
log level" without explicitly specifying what it is. The level is set
though the LogSetup constructor. However, it is easier to follow unit
tests, if they are self-contained. So just set the level to Debug
explicitly here.

Also, add a new debug_3 log, to further document the intended behavior
of the unit test.

Also, replace the LogPrintLevel with the shorter and exact replacements
LogTrace and LogDebug.
2025-12-13 12:50:12 +01:00
stickies-v
f273167661 ipc: separate log statements per level
Avoids ratelimiting unconditional log statements when debug logging
is enabled. Introduces slight behaviour change by removing
the category from unconditional logs, making them more uniform
with the other unconditional logs in the codebase.

Also, in a slight behavior change, prefix the info-level (and higher)
messages with "ipc:".
2025-12-13 12:49:39 +01:00
stickies-v
94c51ae540 libevent: separate log statements per level
Avoids ratelimiting unconditional log statements when debug logging
is enabled. Introduces slight behaviour change by removing
the category from unconditional logs, making them more uniform
with the other unconditional logs in the codebase.

Also, in a slight behavior change, prefix the info-level (and higher)
messages with "libevent:".
2025-12-13 12:48:27 +01:00
marcofleon
a70a14a3f4 refactor: Separate out logic for building a tree-shaped dependency graph 2025-12-12 16:09:53 +01:00
marcofleon
ce29d7d626 fuzz: Fix variable in clusterlin_postlinearize_tree check
The test intends to verify that running `PostLinearize` a
second time on a tree-structured graph doesn't change the
result. But `PostLinearize` was being called on the original
variable, not the copy. So the check was comparing the
unmodified copy against itself, which is useless.

Fix by post-linearizing the correct variable.
2025-12-12 15:04:10 +00:00
marcofleon
876e2849b4 fuzz: Fix incorrect loop bounds in clusterlin_postlinearize_tree
The dependency graphs generated by this test can have holes
(unused indices) in them. This means some of the transactions
were skipped when using `depgraph_gen.TxCount()` as the upper
bound of the loop. Switch to using `depgraph.Positions()` to
correctly handle sparse graphs.
2025-12-12 15:02:26 +00:00
stratospher
09dfa4d3f8 test: fix race condition in p2p_v2_misbehaving.py peerid assertion
due to asyncio's non-deterministic task scheduling, peer2's
connection might happen before peer1's, causing peer2 to get
assigned peer_id=1 on bitcoind side and peer1 to get assigned
peer_id=2 on bitcoind side.

since we test that peer2 remains connected, any disconnection
must originate from peer1, making the specific peer id unnecessary
for test correctness. so we can remove the specific peer_id from
the expected debug log.
2025-12-12 20:13:24 +05:30
merge-script
938d7aacab
Merge bitcoin/bitcoin#33657: rest: allow reading partial block data from storage
07135290c1720a14c9d2f18a5700bb6565ae7a10 rest: allow reading partial block data from storage (Roman Zeyde)
4e2af1c06547230b9245d94e7bcb1129f2c49714 blockstorage: allow reading partial block data from storage (Roman Zeyde)
f2fd1aa21c7694cef393b4a13e472ae9d3fc54fc blockstorage: return an error code from `ReadRawBlock()` (Roman Zeyde)

Pull request description:

  It allows fetching specific transactions using an external index, following https://github.com/bitcoin/bitcoin/pull/32541#issuecomment-3267485313.

  Currently, electrs and other indexers map between an address/scripthash to the list of the relevant transactions.

  However, in order to fetch those transactions from bitcoind, electrs relies on reading the whole block and post-filtering for a specific transaction[^1]. Other indexers use a `txindex` to fetch a transaction using its txid [^2][^3][^4].

  The above approach has significant storage and CPU overhead, since the `txid` is a pseudo-random 32-byte value. Also, mainnet `txindex` takes ~60GB today.

  This PR is adding support for using the transaction's position within its block to be able to fetch it directly using [REST API](https://github.com/bitcoin/bitcoin/blob/master/doc/REST-interface.md), using the following HTTP request:

  ```
  GET /rest/blockpart/BLOCKHASH.bin?offset=OFFSET&size=SIZE
  ```

  - The offsets' index can be encoded much more efficiently ([~1.3GB today](https://github.com/romanz/bindex-rs/pull/66#issuecomment-3508476436)).

  - Address history query performance can be tested on mainnet using [1BitcoinEaterAddressDontSendf59kuE](https://mempool.space/address/1BitcoinEaterAddressDontSendf59kuE) - assuming warm OS block cache, [it takes <1s to fetch 5200 txs, i.e. <0.2ms per tx](https://github.com/romanz/bindex-rs/pull/66#issuecomment-3508476436) with [bindex](https://github.com/romanz/bindex-rs).

  - Only binary and hex response formats are supported.

  [^1]: https://github.com/romanz/electrs/blob/master/doc/schema.md
  [^2]: https://github.com/Blockstream/electrs/blob/new-index/doc/schema.md#txstore
  [^3]: https://github.com/spesmilo/electrumx/blob/master/docs/HOWTO.rst#prerequisites
  [^4]: https://github.com/cculianu/Fulcrum/blob/master/README.md#requirements

ACKs for top commit:
  maflcko:
    review ACK 07135290c1720a14c9d2f18a5700bb6565ae7a10 🏪
  l0rinc:
    ACK 07135290c1720a14c9d2f18a5700bb6565ae7a10
  hodlinator:
    re-ACK 07135290c1720a14c9d2f18a5700bb6565ae7a10

Tree-SHA512: bcce7bf4b9a3e5e920ab5a83e656f50d5d7840cdde6b7147d329cf578f8a2db555fc1aa5334e8ee64d5630d25839ece77a2cf421c6c3ac1fa379bb453163bd4f
2025-12-12 13:22:00 +00:00
Ryan Ofsky
82be652e40 doc: Improve ChainstateManager documentation, use consistent terms 2025-12-12 06:49:59 -04:00
merge-script
597b8be223
Merge bitcoin/bitcoin#34025: net: Waste less time in socket handling
5f5c1ea01955d277581f6c2acbeb982949088960 net: Cache -capturemessages setting (Anthony Towns)
cea443e246185c0aa89a8b5dd9f78f6ab09af523 net: Pass time to InactivityChecks fuctions (Anthony Towns)

Pull request description:

  Cuts out some wasted time in net socket handling. First, only calculates the current time once every 50ms, rather than once for each peer, which given we only care about second-level precision seems more than adequate. Second, caches the value of the `-capturemessages` setting in `CConnman` rather than re-evaluating it every time we invoke `PushMessaage`.

ACKs for top commit:
  maflcko:
    review ACK 5f5c1ea01955d277581f6c2acbeb982949088960 🏣
  vasild:
    ACK 5f5c1ea01955d277581f6c2acbeb982949088960
  sedited:
    ACK 5f5c1ea01955d277581f6c2acbeb982949088960
  mzumsande:
    ACK 5f5c1ea01955d277581f6c2acbeb982949088960

Tree-SHA512: 0194143a3a4481c6355ac9eab27ce6ae4bed5db1d483ba5d06288dd92f195ccb9f0f055a9eb9d7e16e9bbf72f145eca1ff17c6700ee9aa42730103a8f047b32c
2025-12-12 10:49:59 +00:00
TheCharlatan
af455dcb39 refactor: Simplify pruning functions
Move GetPruneRange from ChainstateManager to Chainstate.
2025-12-12 11:49:59 +01:00
Ryan Ofsky
ae85c495f1 refactor: Delete ChainstateManager::GetAll() method
Just use m_chainstates array instead.
2025-12-12 06:49:59 -04:00
Ryan Ofsky
6a572dbda9 refactor: Add ChainstateManager::ActivateBestChains() method
Deduplicate code looping over chainstate objects and calling
ActivateBestChain() and avoid need for code outside ChainstateManager to use
the GetAll() method.
2025-12-12 06:49:59 -04:00