Commit graph

27848 commits

Author SHA1 Message Date
merge-script
9f3dcacef7
Merge bitcoin/bitcoin#31978: kernel: pre-29.x chainparams and headerssync update
11a2d3a63e [headerssync] update headerssync config for v29 (glozow)
dd23c53258 [kernel] update chainTxData for v29 (glozow)
80926af8c2 [kernel] update assumevalid and minimumChainWork for v29 (glozow)
0683b8ebf3 [kernel] update assumed blockchain and chainstate sizes for v29 (glozow)

Pull request description:

  Update chainparams and headerssync config for v29.0 (see [release process](https://github.com/bitcoin/bitcoin/blob/master/doc/release-process.md#before-branch-off)).

ACKs for top commit:
  achow101:
    ACK 11a2d3a63e
  Sjors:
    ACK 11a2d3a63e

Tree-SHA512: 726cbb16a3bc8b11419c2888b17552d70217f616f17a715ba4983fdfccb0cfd9705c528601a6bb3e62563a6f43d41543181e13cdbad89d75abba3b7899328031
2025-03-06 10:23:01 +00:00
glozow
11a2d3a63e [headerssync] update headerssync config for v29 2025-03-04 14:23:18 -05:00
glozow
dd23c53258 [kernel] update chainTxData for v29 2025-03-04 14:23:18 -05:00
glozow
80926af8c2 [kernel] update assumevalid and minimumChainWork for v29 2025-03-04 14:23:18 -05:00
glozow
0683b8ebf3 [kernel] update assumed blockchain and chainstate sizes for v29 2025-03-04 14:23:17 -05:00
glozow
e13c18f6ce
Merge bitcoin/bitcoin#31969: Add mainnet assumeutxo param at height 880,000
14f1674855 chainparams: add mainnet assumeutxo param at height 880_000 (Sjors Provoost)

Pull request description:

  #31940 suggests adding a snapshot at every major release.

  This snapshot should be suitable for v29. I picked the most recent multiple of 10K blocks.

  You can either download this torrent:

  ```
  magnet:?xt=urn:btih:559bd78170502971e15e97d7572e4c824f033492&dn=utxo-880000.dat&tr=udp%3A%2F%2Ftracker.bitcoin.sprovoost.nl%3A6969
  ```

  Or generate the snapshot yourself:

  ```sh
  bitcoin-cli -rpcclienttimeout=0 -named dumptxoutset utxo-880000.dat rollback=880000
  ```

  The SHA-256 hash should be:

  ```
  shasum -a 256 utxo-880000.dat
  43b3b1ad6e1005ffc0ff49514d0ffcc3e3ce671cc8d02da7fa7bac5405f89de4
  ```

  And then load it on a fresh node during IBD with:

  ```
  bitcoin-cli -rpcclienttimeout=0 loadtxoutset utxo-880000.dat
  ```

  Note that it's more performant to turn off networking while the snapshot is loading, see #29993:

  ```sh
  bitcoin-cli setnetworkactive false
  ```

  Once the snapshot is loaded:

  ```sh
  bitcoin-cli setnetworkactive true
  ```

  And enjoy a speedy ride to the tip.

ACKs for top commit:
  achow101:
    ACK 14f1674855
  fjahr:
    tACK 14f1674855
  hodlinator:
    ACK 14f1674855
  rkrux:
    Concept ACK 14f1674855
  polespinasa:
    ACK 14f1674855

Tree-SHA512: e7ed3e8ce3a247614545ecd3254a91814d7f87b3ca1be46df3b9a4c1e6353b46c82ab97d9fc9c5bed8938f28a6a61e6b70baa7c9649fe5da0f2f390b7932f15e
2025-03-04 14:14:50 -05:00
Ava Chow
15717f0ef3
Merge bitcoin/bitcoin#31916: init: Handle dropped UPnP support more gracefully
44041ae0ec init: Handle dropped UPnP support more gracefully (laanwj)

Pull request description:

  Closes bitcoin-core/gui#843.

  In that issue it was brought up that users likely don't care what kind of port forwarding is used, and that the setting is opportunistic anyway, so instead of showing an extensive warning, we can simply "upgrade" from UPNP to NAT-PMP+PCP.

  - Change the logic for removed runtime setting `-upnp` to set `-natpmp` instead, and log a message.

  - Also remove any lingering `upnp` from `settings.json` and replace it with `natpmp`, when it makes sense (this is important so that the UI shows the right values in the settings):

  ```json
  {
      "upnp": true
  }
  ```
  becomes
  ```json
  {
      "natpmp": true
  }
  ```

  and

  ```json
  {
      "upnp": false
  }
  ```
  becomes
  ```json
  {
      "natpmp": false
  }
  ```

ACKs for top commit:
  darosior:
    tACK 44041ae0ec
  davidgumberg:
    lightly reviewed code, tested ACK 44041ae0ec
  achow101:
    ACK 44041ae0ec
  ryanofsky:
    Code review ACK 44041ae0ec. Code changes look good. Could potentially add test coverage for this, though I don't think it is too important.
  hodlinator:
    cr-ACK 44041ae0ec

Tree-SHA512: ca822f7160529e59973bab6a7cc31753ffa3caaa806887b5073b42c4ae5c918a5ea2cf93c666e5125ea70d10c6954709a535a264b04c2fd4cf916b3c59ab9964
2025-03-03 16:40:26 -08:00
merge-script
79bbb381a1
Merge bitcoin/bitcoin#30901: cmake: Revamp handling of data files
ecf54a32ed cmake: Add support for builtin `codegen` target (Hennadii Stepanov)
a8c78a0574 cmake: Revamp handling of data files (Hennadii Stepanov)

Pull request description:

  This PR leverages the approach from the https://github.com/chaincodelabs/libmultiprocess project and introduces a new functions `target_json_data_sources()` and `target_raw_data_sources()`, which minimize the amount of code required to assign to assign a `*.json` or `*.raw` data file to the `test_bitcoin`,  `bench_bitcoin` or `unitester` targets.

  As requested in https://github.com/bitcoin/bitcoin/pull/30901#issuecomment-2654622689, the `codegen` build target is now supported, if available:
  ```
  $ cmake --version
  cmake version 3.31.5

  CMake suite maintained and supported by Kitware (kitware.com/cmake).
  $ cmake -G "Ninja" -B build
  $ cmake --build build --target codegen
  ```

ACKs for top commit:
  fjahr:
    re-ACK ecf54a32ed
  Sjors:
    re-tACK ecf54a32ed
  theuni:
    ACK ecf54a32ed

Tree-SHA512: bab92df6b81c47d9d97ba8db37470a6d7aa435d5578afe40df7154885eda55afc59f0bf20dc9db3b2fd88ceb9a0319b9678f9e9af01e7afd4851ec3a79f3f402
2025-03-03 14:41:05 +00:00
Sjors Provoost
14f1674855
chainparams: add mainnet assumeutxo param at height 880_000 2025-03-01 10:53:48 -05:00
laanwj
44041ae0ec init: Handle dropped UPnP support more gracefully
Closes bitcoin-core/gui#843.

In that issue it was brought up that users likely don't care what kind
of port forwarding is used, and the setting is opportunistic anyway, so
instead of showing an extensive warning, we can simply migrate from
UPNP to NAT-PMP+PCP. This prevents nodes dropping from the public
network.

- Change the logic for removed runtime setting `-upnp` to set `-natpmp`
  instead, and only log a message.

- Also replace any lingering `upnp` in `settings.json` with `natpmp`.
2025-02-26 14:42:35 +01:00
merge-script
e486597f9a
Merge bitcoin/bitcoin#31918: fuzz: add basic TxOrphanage::EraseForBlock cov
8400b742fa fuzz: add basic TxOrphanage::EraseForBlock cov (Greg Sanders)

Pull request description:

  Currently uncovered

ACKs for top commit:
  dergoegge:
    utACK 8400b742fa
  marcofleon:
    ACK 8400b742fa

Tree-SHA512: 8c032ffa15ccce73ee1e0b2425d9c303acd4ec87c43f05de0cb96f4d831faeb5651175a32a7fc3ed81bf9400ee4416ca826999777326c29d06e3bd67cb06068c
2025-02-21 11:05:17 -05:00
merge-script
44bd315924
Merge bitcoin/bitcoin#31676: fuzz: add targets for PCP and NAT-PMP port mapping requests
c73b59d47f fuzz: implement targets for PCP and NAT-PMP port mapping requests (Antoine Poinsot)
1695c8ab5b fuzz: in FuzzedSock::GetSockName(), return a random-length name (Antoine Poinsot)
0d472c1953 fuzz: never return an uninitialized sockaddr in FuzzedSock::GetSockName (Antoine Poinsot)
39b7e2b590 fuzz: add steady clock mocking to FuzzedSock (Antoine Poinsot)
6fe1c35c05 pcp: make NAT-PMP error codes uint16_t (Antoine Poinsot)
01906ce912 pcp: make the ToString method const (Antoine Poinsot)

Pull request description:

  Based on https://github.com/bitcoin/bitcoin/pull/31022, this introduces a fuzz target for `PCPRequestPortMap` and `NATPMPRequestPortMap`.

  Like in #31022 we set `CreateSock` to return a `Sock` which mocks the responses from the server and uses a mocked steady clock for the `Wait`s. Except here we simply respond with fuzzer-provided data until the client stop sending requests. We also sometimes inject errors and connection failures based on fuzzer-provided data.

  We reuse the existing `FuzzedSock`, so a preparatory commit is included that adds steady clock mocking to it. This may be useful for other harnesses as well.

ACKs for top commit:
  laanwj:
    re-ACK c73b59d47f
  marcofleon:
    ACK c73b59d47f
  dergoegge:
    utACK c73b59d47f

Tree-SHA512: 24cd4d958a0999946a0c3d164a242fc3f0a0b66770630252b881423ad0065d29fdaab765014d193b705d3eff397f201d51a88a3ca80c63fd3867745e6f21bb2b
2025-02-21 10:57:09 -05:00
Hennadii Stepanov
a8c78a0574
cmake: Revamp handling of data files
This change introduces new functions `target_json_data_sources()` and
`target_raw_data_sources()`.
2025-02-21 11:11:29 +00:00
Hennadii Stepanov
5b8fd7c3a6
Merge bitcoin-core/gui#854: qt: Update src/qt/locale/bitcoin_en.xlf after string freeze
7267ed0518 qt: Update `src/qt/locale/bitcoin_en.xlf` after string freeze (Hennadii Stepanov)

Pull request description:

  This PR follows our [Release Process](864386a744/doc/release-process.md) and implements the ["Translation string freeze"](https://github.com/bitcoin/bitcoin/issues/31029) step.

  Steps to reproduce the diff on Ubuntu:
  ```
  $ cmake --preset dev-mode -DWITH_USDT=OFF -DWITH_MULTIPROCESS=OFF
  $ cmake --build build_dev_mode --target translate
  ```

  At the moment, the multiprocess-specific code does not introduce any new translatable strings. Therefore, there is no need to build depends with `MULTIPROCESS=1` to review this PR.

ACKs for top commit:
  stickies-v:
    ACK 7267ed0518 - I get the same results when building the `translate` target.
  pablomartin4btc:
    tACK 7267ed0518

Tree-SHA512: dc3641d3288c00cb7802714680508de517e56c615716e52181555634ad489fbed676229063995170edb8efeaa4e900ef2d3d5a0f1b8ce7cec143ef364c96e1c0
2025-02-20 22:42:15 +00:00
merge-script
db63bfbe7c
Merge bitcoin/bitcoin#31580: test: Remove non-portable IPv6 test
d871d77825 test: Remove non-portable IPv6 test (Hennadii Stepanov)

Pull request description:

  On Illumos-based systems, such as OpenIndiana and OmniOS, the assumption that "the default zone ID of 0 can be omitted for the default scope" is incorrect. As a result, `getaddrinfo("fe80::1%0", ...)` returns the `EAI_NONAME` error instead of resolving to "fe80::1".

  See: https://www.illumos.org/man/3SOCKET/getaddrinfo.

  This PR removes the problematic code introduced in https://github.com/bitcoin/bitcoin/pull/19951.

ACKs for top commit:
  fanquake:
    ACK d871d77825

Tree-SHA512: 2ef5c22f826d16661deb1d6d005cbda64179e8b83be43d3d6ac51caff02187cf224355c9da144ff110a6ae2cb68f0338ea9b62af8e0f9f1014a518cf9dad6ab5
2025-02-20 16:02:31 -05:00
Ava Chow
77bf99012a
Merge bitcoin/bitcoin#30302: doc: clarify loadwallet path loading for wallets
ca6aa0b9be doc: loadwallet loads from relative walletdir (am-sq)

Pull request description:

  ## Why this change?

  https://github.com/bitcoin/bitcoin/issues/30269 describes a need for documentation improvement with the `loadwallet` RPC. Namely, [some users have found](https://bitcoin.stackexchange.com/questions/123331/how-do-you-load-a-regtest-wallet) the usage description confusing when it comes to loading wallets that are not in the normal case of being in the default wallet directory.

  The default wallet directory, depending on the machine OS, has the base directory defined here: 9c5cdf07f3/src/common/args.cpp (L699) which is then appended with `/wallets`. So for example, for MacOS, it would be `~/Library/Application Support/Bitcoin/wallets`.

  ## The changes implemented
  1. Change the help text to indicate that the filename (or directory) passed in to `loadwallet` is relative to the base wallet directory
  2. Adds additional examples to the help page showing how to fetch a wallet within a subdirectory of the base data directory for wallets, or from an absolute path

ACKs for top commit:
  achow101:
    ACK ca6aa0b9be
  maflcko:
    lgtm ACK ca6aa0b9be
  rkrux:
    ACK ca6aa0b9be
  jonatack:
    ACK ca6aa0b9be

Tree-SHA512: 123ae118c79ee1843ed65861e7a008658a53e47d4d14f2b7612561bba1b1dbdb6744f9aaac1587aac231c62d0c1804de848a6d732f1382788b437d9fe6474012
2025-02-20 11:40:59 -08:00
Greg Sanders
8400b742fa fuzz: add basic TxOrphanage::EraseForBlock cov 2025-02-20 14:00:21 -05:00
merge-script
eb51963d87
Merge bitcoin/bitcoin#31884: cmake: Make implicit libbitcoinkernel dependencies explicit
3b42e05aa9 cmake: Make implicit `libbitcoinkernel` dependencies explicit (Hennadii Stepanov)
3fd64efb43 cmake: Avoid using `OBJECT` libraries (Hennadii Stepanov)

Pull request description:

  This PR fixes two regressions introduced in https://github.com/bitcoin/bitcoin/pull/30911.

  For example, on the master branch @ 28dec6c5f8:
  - first regression:
  ```
  $ cmake -B build -G "Ninja" -DBUILD_UTIL_CHAINSTATE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/home/hebasto/INSTALL
  $ cmake --build build -j $(nproc) -t libbitcoinkernel
  $ cmake --install build --component libbitcoinkernel
  - Install configuration: "RelWithDebInfo"
  CMake Error at build/src/kernel/cmake_install.cmake:46 (file):
    file INSTALL cannot find
    "/home/hebasto/dev/bitcoin/build/src/crypto/libbitcoin_crypto.a": No such
    file or directory.
  Call Stack (most recent call first):
    build/src/cmake_install.cmake:172 (include)
    build/cmake_install.cmake:57 (include)

  ```

  - second regression:
  ```
  $ cmake -B build -G "Unix Makefiles" -DBUILD_UTIL_CHAINSTATE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/home/hebasto/INSTALL
  $ cmake --build build -j $(nproc) -t libbitcoinkernel
  ...
  gmake[3]: *** No rule to make target 'src/CMakeFiles/bitcoin_clientversion.dir/clientversion.cpp.o', needed by 'src/kernel/libbitcoinkernel.a'.  Stop.
  gmake[2]: *** [CMakeFiles/Makefile2:1360: src/kernel/CMakeFiles/bitcoinkernel.dir/all] Error 2
  gmake[1]: *** [CMakeFiles/Makefile2:1367: src/kernel/CMakeFiles/bitcoinkernel.dir/rule] Error 2
  gmake: *** [Makefile:647: bitcoinkernel] Error 2
  ```

  With this PR:
  ```
  $ cmake -B build -G "Ninja" -DBUILD_UTIL_CHAINSTATE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/home/hebasto/INSTALL
  $ cmake --build build -j $(nproc) -t libbitcoinkernel
  $ cmake --install build --component libbitcoinkernel
  ```
  and
  ```
  $ cmake -B build -G "Unix Makefiles" -DBUILD_UTIL_CHAINSTATE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/home/hebasto/INSTALL
  $ cmake --build build -j $(nproc) -t libbitcoinkernel
  $ cmake --install build --component libbitcoinkernel
  ```

  ---

  **A note for reviewers:** An alternative approach would be to disable the `OPTIMIZE_DEPENDENCIES` property for the `bitcoinkernel` target. However, I contend that this PR is preferable because (1) it preserves parallel builds for the `libbitcoinkernel` target, and (2) the resulting code has one less workaround for a CMake bug.

ACKs for top commit:
  TheCharlatan:
    ACK 3b42e05aa9
  theuni:
    utACK 3b42e05aa9

Tree-SHA512: 73e9da845688a02e5d61770b7cfd5e1a17440182eb524c7329a47df8f1daa6fe0f9cbde5274832bf43f52e17de86473881dc876dee4276c9c06b173b1b78b7a2
2025-02-20 12:08:35 -05:00
Hennadii Stepanov
7267ed0518
qt: Update src/qt/locale/bitcoin_en.xlf after string freeze
Steps to reproduce the diff on Ubuntu:
```
$ cmake --preset dev-mode -DWITH_USDT=OFF -DWITH_MULTIPROCESS=OFF
$ cmake --build build_dev_mode --target translate
```
2025-02-20 17:04:16 +00:00
merge-script
58f15d4b21
Merge bitcoin/bitcoin#31379: cmake: Fix passing APPEND_*FLAGS to secp256k1 subtree
c4c5cf1748 cmake: Fix passing `APPEND_*FLAGS` to `secp256k1` subtree (Hennadii Stepanov)
eb540a2629 cmake: Remove `core_sanitizer_{cxx,linker}_flags` helper variables (Hennadii Stepanov)

Pull request description:

  On the master branch @ 70e20ea024, the `APPEND_CPPFLAGS`, `APPEND_CFLAGS`  and `APPEND_LDFLAGS` are not correctly applied when building C code in the  `secp256k1` subtree, as intended.

  This behaviour occurs due to two issues:
  1. The command here: 70e20ea024/src/CMakeLists.txt (L77)
  does not affect the code in `add_subdirectory(secp256k1)` above it.

  2.  `APPEND_LDFLAGS`  is not passed to the subtree's build system at all.

  This PR fixes both issues.

  Additionally, the helper variables `core_sanitizer_cxx_flags` and `core_sanitizer_linker_flags` have been removed.

ACKs for top commit:
  theuni:
    utACK c4c5cf1748.
  TheCharlatan:
    ACK c4c5cf1748

Tree-SHA512: 707acfa623f0436e34e9e6ba8ce2979e0fde5e196e2242fd1cde4c50f433938549781193d8a06419a0866bbe6d69d76f8383d973afbd87d944407963b318c5c9
2025-02-20 09:36:48 -05:00
merge-script
e606c577cb
Merge bitcoin/bitcoin#31899: cmake: Exclude generated sources from translation
ff4ddd3d2e Revert "cmake: Ensure generated sources are up to date for `translate` target" (Hennadii Stepanov)
03b3166aac cmake: Exclude generated sources from translation (Hennadii Stepanov)

Pull request description:

  This PR fixes an error encountered when building the `translate` target:
  ```
  $ gmake -j $(nproc) -C depends MULTIPROCESS=1
  $ cmake -G "Unix Makefiles" --preset dev-mode --toolchain depends/x86_64-pc-linux-gnu/toolchain.cmake -DWITH_USDT=OFF
  $ cmake --build build_dev_mode -t translate
  gmake[3]: *** No rule to make target 'src/test/ipc_test.capnp.c++', needed by 'src/qt/CMakeFiles/translate'. Stop.
  gmake[2]: *** [CMakeFiles/Makefile2:1646: src/qt/CMakeFiles/translate.dir/all] Error 2
  gmake[1]: *** [CMakeFiles/Makefile2:1653: src/qt/CMakeFiles/translate.dir/rule] Error 2
  gmake: *** [Makefile:699: translate] Error 2
  ```

  The previous [attempt](864386a744) to address this issue worked only with Ninja generators and has been reverted.

  Essentially, this PR modifies the `translate` target so that it ignores generated sources rather than attempting to update them.

  At present, multiprocess-specific sources do not contain any translatable strings. Nonetheless, it is prudent to maintain a general approach.

ACKs for top commit:
  TheCharlatan:
    ACK ff4ddd3d2e
  pablomartin4btc:
    tACK ff4ddd3d2e

Tree-SHA512: 6471498a33b145e073f76bd007591b0449e5d520f141c3e3afeca02a09c160fd0f572ec7172dd84703cdc2a1175ad8f3c91e8b0bf705d671338d760786765f56
2025-02-19 16:11:22 -05:00
Antoine Poinsot
3e9b12b3e0 Revert "Merge bitcoin/bitcoin#31826: random: Check GetRNDRRS is supported in InitHardwareRand to avoid infinite loop"
This reverts commit 139640079f, reversing
changes made to dc3a714633.
2025-02-19 10:28:13 -05:00
Ava Chow
139640079f
Merge bitcoin/bitcoin#31826: random: Check GetRNDRRS is supported in InitHardwareRand to avoid infinite loop
09b150bb8a In `InitHardwareRand`, do trail test for `RNDRRS` by `VerifyRNDRRS` (Eval EXEC)

Pull request description:

  This PR want to fix #31817 by added a maximum retry limit (`max_retries`) to the `GetRNDRRS` function to prevent it from entering an infinite loop if the hardware random number generator fails to return a valid random number. This change improves stability and ensures that the function terminates after a predefined number of retries.

ACKs for top commit:
  achow101:
    ACK 09b150bb8a
  sipa:
    utACK 09b150bb8a

Tree-SHA512: 5626b6b182a55d344a3aba11b782259ecc6bbec513771d50077874c5f70934750e68add8f63aa0bf69c6b7b313112940a85508af5447622c703cc5e92439ab4a
2025-02-18 18:43:12 -08:00
Ava Chow
dc3a714633
Merge bitcoin/bitcoin#31794: wallet: abandon orphan coinbase txs, and their descendants, during startup
e4dd5a351b test: wallet, abandon coinbase txs and their descendants during startup (furszy)
474139aa9b wallet: abandon inactive coinbase tx and their descendants during startup (furszy)

Pull request description:

  Since #26499, we mark coinbase transactions and their descendants as abandoned when a reorg arises through the "block disconnection" signal handler. However, this does not cover all scenarios; external wallets could contain coinbase transactions from blocks the node has not seen yet, or the user could have replaced the chain with an earlier or different version (one without the coinbase chain).

  This affects balance calculation as well as mempool rebroadcast (descendants shouldn't be relayed).
  Fix this by marking orphaned coinbase transactions and their descendants as abandoned during wallet startup.

ACKs for top commit:
  achow101:
    ACK e4dd5a351b
  rkrux:
    tACK e4dd5a351b
  mzumsande:
    Code Review ACK e4dd5a351b

Tree-SHA512: 461a43de7a6f5a580f2e6e3b56ec9bc92239cd45e850a2ff594ab5488dcd4a507f68fbbf550a33d7173b2add0de80de1e1b3841e1dfab0c95b284212d8ced08a
2025-02-18 18:39:00 -08:00
am-sq
ca6aa0b9be doc: loadwallet loads from relative walletdir
Improves the documentation of help output for loadwallet
to clarify that filename is relative to the default
wallet directory. Adds examples that get a wallet from
sub-directories.
2025-02-18 15:38:34 -08:00
Hennadii Stepanov
ff4ddd3d2e
Revert "cmake: Ensure generated sources are up to date for translate target"
This reverts commit 864386a744.
2025-02-18 16:05:08 +00:00
Hennadii Stepanov
03b3166aac
cmake: Exclude generated sources from translation 2025-02-18 16:02:56 +00:00
Hennadii Stepanov
3b42e05aa9
cmake: Make implicit libbitcoinkernel dependencies explicit
This change fixes a regression introduced by enabling the
`OPTIMIZE_DEPENDENCIES` property.
2025-02-18 12:30:41 +00:00
Hennadii Stepanov
3fd64efb43
cmake: Avoid using OBJECT libraries
`OBJECT` libraries have historically exhibited poor support for various
features, both in the past and now. For example, see one of the latest
issues:
- https://gitlab.kitware.com/cmake/cmake/-/issues/24058

Furthermore, CMake maintainers have acknowledged:
> In general, however, where there is a choice, static libraries will
> typically be the more convenient choice in CMake projects.

This change:
1. Converts the `bitcoin_clientversion` library from an `OBJECT` library
   to a `STATIC` library.
2. Removes an obsolete workaround.
2025-02-18 12:29:18 +00:00
merge-script
28dec6c5f8
Merge bitcoin/bitcoin#31268: cmake: add optional source files to bitcoin_crypto and crc32c directly
9cf746d663 cmake: add optional source files to crc32c directly (Daniel Pfeifer)
9c7823c5b5 cmake: add optional source files to bitcoin_crypto directly (Daniel Pfeifer)

Pull request description:

  Avoid having many static libraries by adding the optional sources to the target `bitcoin_crypto` directly.
  Set the necessary compile options at the source file level, rather than the target level.

  fixes: #31697

ACKs for top commit:
  s373nZ:
    ACK 9cf746d663
  hebasto:
    re-ACK 9cf746d663.
  TheCharlatan:
    ACK 9cf746d663

Tree-SHA512: 04b468ccbd284d63fc83b382177bb8183b325369835c3b92e555e159955c73d71712a63a2e556f8da68a1232ac07d3845e11f1057c50666843db91db98fca979
2025-02-18 12:08:51 +00:00
merge-script
9da0820ec5
Merge bitcoin/bitcoin#31869: cmake: Add libbitcoinkernel target
3a914ab96b cmake: Rename `bitcoinkernel` component to `libbitcoinkernel` (Hennadii Stepanov)
7ce09a5992 cmake: Add `libbitcoinkernel` target (Hennadii Stepanov)

Pull request description:

  This PR amends https://github.com/bitcoin/bitcoin/pull/31844 by:
  1.  Adding a convenience `libbitcoinkernel` target as a synonym for `bitcoinkernel`.
  2. Renaming the `bitcoinkernel` component to `libbitcoinkernel`, as initially intended in https://github.com/bitcoin/bitcoin/pull/31844

  Here is an example of usage:
  ```sh
  cmake -B build -DBUILD_UTIL_CHAINSTATE=ON
  cmake --build build --target libbitcoinkernel
  cmake --install build --component libbitcoinkernel
  ```

ACKs for top commit:
  s373nZ:
    ACK 3a914ab96b
  theuni:
    ACK 3a914ab96b
  TheCharlatan:
    ACK 3a914ab96b
  BrandonOdiwuor:
    Tested ACK 3a914ab96b

Tree-SHA512: 3576ce6261413ba803711a4448ab8da8a5ad161189ab22be51d40f85b3847547060f537f37cc2d6062c193258f1c61f25df21a1e73cf86336f37705cdfd16d7e
2025-02-17 15:31:06 +00:00
Eval EXEC
09b150bb8a
In InitHardwareRand, do trail test for RNDRRS by VerifyRNDRRS
Signed-off-by: Eval EXEC <execvy@gmail.com>
2025-02-15 11:38:00 +08:00
Ava Chow
e53310c47a
Merge bitcoin/bitcoin#30529: Fix -norpcwhitelist, -norpcallowip, and similar corner case behavior
a85e8c0e61 doc: Add some general documentation about negated options (Ryan Ofsky)
490c8fa178 doc: Add release notes summarizing negated option behavior changes. (Ryan Ofsky)
458ef0a11b refactor: Avoid using IsArgSet() on -connect list option (Ryan Ofsky)
752ab9c3c6 test: Add test to make sure -noconnect disables -dnsseed and -listen by default (Ryan Ofsky)
3c2920ec98 refactor: Avoid using IsArgSet() on -signetseednode and -signetchallenge list options (Ryan Ofsky)
d05668922a refactor: Avoid using IsArgSet() on -debug, -loglevel, and -vbparams list options (Ryan Ofsky)
3d1e8ca53a Normalize inconsistent -noexternalip behavior (Ryan Ofsky)
ecd590d4c1 Normalize inconsistent -noonlynet behavior (Ryan Ofsky)
5544a19f86 Fix nonsensical bitcoin-cli -norpcwallet behavior (Ryan Ofsky)
6e8e7f433f Fix nonsensical -noasmap behavior (Ryan Ofsky)
b6ab350806 Fix nonsensical -notest behavior (Ryan Ofsky)
6768389917 Fix nonsensical -norpcwhitelist behavior (Ryan Ofsky)
e03409c70f Fix nonsensical -norpcbind and -norpcallowip behavior (Ryan Ofsky)
40c4899bc2 Fix nonsensical -nobind and -nowhitebind behavior (Ryan Ofsky)
5453e66fd9 Fix nonsensical -noseednode behavior (Ryan Ofsky)

Pull request description:

  The PR changes behavior of negated `-noseednode`, `-nobind`, `-nowhitebind`, `-norpcbind`, `-norpcallowip`, `-norpcwhitelist`, `-notest`, `-noasmap`, `-norpcwallet`, `-noonlynet`, and `-noexternalip` options, so negating these options just clears previously specified values doesn't have other side effects.

  Negating options on the command line can be a useful way of resetting options that may have been set earlier in the command line or config file. But before this change, negating these options wouldn't fully reset them, and would have confusing and undocumented side effects (see commit descriptions for details). Now, negating these options just resets them and behaves the same as not specifying them.

  Motivation for this PR is to fix confusing behaviors and also to remove incorrect usages of the `IsArgSet()` function. Using `IsArgSet()` tends to lead to negated option bugs in general, but it especially causes bugs when used with list settings returned by `GetArgs()`, because when these settings are negated, `IsArgSet()` will return true but `GetArgs()` will return an empty list. This PR eliminates all uses of `IsArgSet()` and `GetArgs()` together, and followup PR #17783 makes it an error to use `IsArgSet()` on list settings, since calling `IsArgSet()` is never actually necessary. Most of the changes here were originally made in #17783 and then moved here to be easier to review and avoid a dependency on #16545.

ACKs for top commit:
  achow101:
    ACK a85e8c0e61
  danielabrozzoni:
    re-ACK a85e8c0e61
  hodlinator:
    re-ACK a85e8c0e61

Tree-SHA512: dd4b19faac923aeaa647b1c241d929609ce8242b43e3b7bc32523cc48ec92a83ac0dc5aee79f1eba8794535e0314b96cb151fd04ac973671a1ebb9b52dd16697
2025-02-14 15:10:09 -08:00
Ava Chow
254fd89d39
Merge bitcoin/bitcoin#31863: random: Initialize variables in hardware RNG functions
99755e04ff random: Initialize variables in hardware RNG functions (Eval EXEC)

Pull request description:

  See: https://github.com/bitcoin/bitcoin/pull/31826#discussion_r1955045279 , So this PR want to prevent potential uninitialized value issues and improve code clarity.

ACKs for top commit:
  sipa:
    utACK 99755e04ff
  achow101:
    ACK 99755e04ff

Tree-SHA512: 4cf9c214617769cf051b4f36453275b407e37d96315b6a206102d17019375b3834ba07e2ccb28c7650c90ff8e1f1034522fccafaa33e136dfe63cc68396a1f6e
2025-02-14 15:03:32 -08:00
Ava Chow
75f8396c90
Merge bitcoin/bitcoin#30746: test: cover base[32|58|64] with symmetric roundtrip fuzz (and padding) tests
f919d919eb fuzz: Add fuzzing for max_ret_len in DecodeBase58/DecodeBase58Check (LÅ‘rinc)
635bc58f46 test: Fuzz Base32/Base58/Base64 roundtrip conversions (LÅ‘rinc)
5dd3a0d8a8 test: Extend base58_encode_decode.json with edge cases (LÅ‘rinc)
ae40cf1a8e test: Add padding tests for Base32/Base64 (LÅ‘rinc)

Pull request description:

  Added fuzzed roundtrips for `base[32|58|64]` encoding to make sure encoding/decoding are symmetric.
  Note that if we omit the padding in `EncodeBase32` we won't be able to decode it with `DecodeBase32`.
  Added dedicated padding tests to cover failure behavior
  Also moved over the Base58 json test edge cases from https://github.com/bitcoin/bitcoin/pull/30035

ACKs for top commit:
  hodlinator:
    re-ACK f919d919eb
  achow101:
    ACK f919d919eb

Tree-SHA512: 6a6c63d0a659b70d42aad7a8f37ce6e372756e2c88c84e7be5c1ff1f2a7c58860ed7113acbe1a9658a7d19deb91f0abe2ec527ed660335845cd1e0a9380b4295
2025-02-14 14:48:01 -08:00
Ava Chow
c4b46b4589
Merge bitcoin/bitcoin#31629: wallet: fix rescanning inconsistency
4818da809f wallet: fix rescanning inconsistency (Martin Zumsande)

Pull request description:

  If the chain advances during a rescan, ScanForWalletTransactions would previously process the new blocks without adjusting `m_last_processed_block`, which would leave the wallet in an inconsistent state temporarily, and could lead to crashes in the GUI reported in #31474.
  Fix this by not rescanning blocks beyond `m_last_processed_block` - for all blocks beyond that height, there will be pending BlockConnected notifications that will process them after the rescan is finished.

  This means that if rescanning was triggered with `cs_wallet` permanently held (`AttachChain`), additional blocks that were connected during the rescan will only be processed with the pending `blockConnected` notifications after the lock is released.
  If rescanning without a permanent `cs_wallet` lock (`RescanFromTime`), additional blocks that were connected during the rescan can be re-processed here because `m_last_processed_block` was already updated by `blockConnected`.

  Fixes #31474

ACKs for top commit:
  psgreco:
    Not that it matters much, but UTACK 4818da809f
  achow101:
    ACK 4818da809f
  furszy:
    utACK 4818da809f

Tree-SHA512: 8e7dbc9e00019aef4f80a11776f3089cd671e0eadd3c548cc6267b5c722433f80339a9b2b338ff9b611863de75ed0a817a845e1668e729b71af70c9038b075af
2025-02-14 14:42:12 -08:00
Ava Chow
d0dfd6d3f6
Merge bitcoin/bitcoin#31865: build: move rpc/external_signer to node library
e501246e77 build: move rpc/external_signer to node library (fanquake)

Pull request description:

  Move `rpc/external_signer` from `bitcoin_common` to `bitcoin_node`.
  Remove the check-deps suppression.

ACKs for top commit:
  maflcko:
    lgtm ACK e501246e77
  achow101:
    ACK e501246e77
  TheCharlatan:
    ACK e501246e77

Tree-SHA512: d535da9038a6b37bd83e852721b42c0806b9ddf060a9b96544027a34d11c1728b3b97385768fca1acc483c6632c28050e2194e2d2ac831d944f332431bfd6792
2025-02-14 14:32:28 -08:00
Ava Chow
504d0c21e2
Merge bitcoin/bitcoin#31439: validation: In case of a continued reindex, only activate chain in the end
c9136ca906 validation: fix issue with an interrupted -reindex (Martin Zumsande)
a2675897e2 validation: Don't loop over all chainstates in LoadExternalBlock (Martin Zumsande)

Pull request description:

  If a user interrupts a reindex while it is iterating over the block files, it will continue to reindex with the next node start (if the `-reindex` arg is dropped, otherwise it will start reindexing from scratch).
  However, due to an early call to `ActivateBestChainState()` that only exists to connect the genesis block during
  the original `-reindex`, it wil start connecting blocks immediately before having iterated through all block files.
  Because later headers above the minchainwork threshold won't be loaded in this case, `-assumevalid` will not
  be applied and the process is much slower due to script validation being done.

  Fix this by only calling `ActivateBestChainState()` here if Genesis is not connected yet (equivalent to `ActiveHeight() == -1`).
  Also simplify this spot by only doing this for the active chainstate instead of looping over all chainstates (first commit).

  This issue was discussed in the thread below https://github.com/bitcoin/bitcoin/pull/31346#discussion_r1856824817, the impact on assumevalid was found by l0rinc.

  The fix can be tested by manually aborting a `-reindex` e.g. on signet and observing in the debug log the order in which blockfiles are indexed / blocks are connected with this branch vs master.

ACKs for top commit:
  achow101:
    ACK c9136ca906
  ryanofsky:
    Code review ACK c9136ca906. Only comments changed since last review. Appreciate the new comments, I think they make a little clearer what things code is trying to do and what things are just side-effects.
  TheCharlatan:
    Re-ACK c9136ca906

Tree-SHA512: 6f34abc317ad7e605ccc0c2f4615e4ea6978223d207f80f768f39cc135a9ac0adf31681fadfa2aed45324a5d27a4f68c5e118ee7eec18ca5c40ef177caa9cc47
2025-02-14 13:59:34 -08:00
Ava Chow
0b48f77e10
Merge bitcoin/bitcoin#31413: rpc: Remove deprecated dummy alias for listtransactions::label
fa8e0956c2 rpc: Remove deprecated dummy alias for listtransactions::label (MarcoFalke)

Pull request description:

  The RPC arg is not a dummy, but a label, so offering an undocumented alias is inconsistent with all other label interfaces and confusing at best, if not entirely unused.

  Fix it by removing the deprecated alias.

  This pull is a breaking change, but it should be limited, because it only affects someone using the deprecated named arg on this RPC. I can't imagine anyone doing this, because in all other places where label args are accepted, they are called `label`. If someone really didn't use `label` here as named arg, it would be trivial and less confusing for them to fix it up.

ACKs for top commit:
  achow101:
    ACK fa8e0956c2
  rkrux:
    tACK fa8e0956c2
  ryanofsky:
    Code review ACK fa8e0956c2

Tree-SHA512: 0d0f3f53237ff9fac8c065b7d0a4245f5ff86efa427dbeeca711765494b7315a9d72b44751d346c76422847daf3d7ff90dbccb5ba200b089fb96128bd95da9f0
2025-02-14 13:29:17 -08:00
Ava Chow
e58605e04f
Merge bitcoin/bitcoin#31854: net: reduce CAddress usage to CService or CNetAddr
cd4bfaee10 net: reduce CAddress usage to CService or CNetAddr (Vasil Dimov)

Pull request description:

  Using `CAddress` when only `CService` or `CNetAddr` is needed is excessive and confusing. Fix those occurrences to use the class they need:

  * `CConnman::CalculateKeyedNetGroup()` needs `CNetAddr`, not `CAddress`, thus change its argument.

  * Both callers of `CConnman::CreateNodeFromAcceptedSocket()` create a dummy `CAddress` from `CService`, so use `CService` instead.

  * `GetBindAddress()` only needs to return `CService`.

  * `CNode::addrBind` only needs to be `CService`.

ACKs for top commit:
  Sjors:
    ACK cd4bfaee10
  achow101:
    ACK cd4bfaee10
  hodlinator:
    ACK cd4bfaee10
  laanwj:
    Code review ACK cd4bfaee10

Tree-SHA512: 0b41c1519784eeeaf9926c6a4d24f583b90c3376741f37a3199a3808b0dd6d143d3f929bd7c06f87b031f4fc1c2bd7a6dfc7d715ec1f79bf36b862c00fd67085
2025-02-14 10:56:14 -08:00
Hennadii Stepanov
3a914ab96b
cmake: Rename bitcoinkernel component to libbitcoinkernel
The new component name is more convenient for the library and aligns
with the `libbitcoinkernel` target introduced in the previous commit.
2025-02-14 17:06:14 +00:00
Hennadii Stepanov
7ce09a5992
cmake: Add libbitcoinkernel target
This is a convenience target as a synonym for `bitcoinkernel`.
2025-02-14 17:02:11 +00:00
fanquake
e501246e77
build: move rpc/external_signer to node library 2025-02-14 14:38:41 +01:00
merge-script
73e2ec1373
Merge bitcoin/bitcoin#31844: cmake: add a component for each binary
9b033bebb1 cmake: rename Kernel component to bitcoinkernel for consistency (Cory Fields)
2e0c92558e cmake: add and use install_binary_component (Cory Fields)
0264c5d86c cmake: use per-target components for bitcoin-qt and bitcoin-gui (Cory Fields)
fb0546b1c5 ci: don't try to install for a fuzz build (Cory Fields)

Pull request description:

  This makes it possible to build/install only the desired binaries regardless of the configuration.
  For consistency, the component names match the binary names. `Kernel` and `GUI` have been renamed.

  Additionally it fixes #31762 by installing only the manpages for the configured targets (and includes them in the component installs for each).

  Also fixes #31745.

  Alternative to #31765 which is (imo) more correct/thorough.

  Can be tested using (for ex):
  ```bash
  $ cmake -B build
  $ cmake --build build -t bitcoind -t bitcoin-cli
  $ cmake --install build --component bitcoind
  $ cmake --install build --component bitcoin-cli
  ```

ACKs for top commit:
  hebasto:
    ACK 9b033bebb1.
  TheCharlatan:
    Re-ACK 9b033bebb1
  stickies-v:
    re-ACK 9b033bebb1

Tree-SHA512: fd4818e76f190dbeafbf0c246b466f829771902c9d6d7111ed917093b811c8a5536a4a45e20708f73e7f581d6cb77c8e61cfa69e065788dcf0886792f553a355
2025-02-14 14:19:12 +01:00
Eval EXEC
99755e04ff
random: Initialize variables in hardware RNG functions 2025-02-14 19:26:29 +08:00
merge-script
9491676438
Merge bitcoin/bitcoin#31157: Cleanups to port mapping module post UPnP drop
70398ae05b mapport: make ProcessPCP void (Antoine Poinsot)
9e6cba2988 mapport: remove unnecessary 'g_mapport_enabled' (Antoine Poinsot)
8fb45fcda0 mapport: remove unnecessary 'g_mapport_current' variable (Antoine Poinsot)
1b223cb19b mapport: merge DispatchMapPort into StartMapPort (Antoine Poinsot)
9bd936fa34 mapport: drop unnecessary function (Antoine Poinsot)
2a6536ceda mapport: rename 'use_pcp' to 'enable' (Antoine Poinsot)
c4e82b854c mapport: make 'enabled' and 'current' bool (Antoine Poinsot)

Pull request description:

  Followup to #31130, this does a couple cleanups to `src/mapport.*` to clarify the logic now that there is a single protocol option for port mapping.

ACKs for top commit:
  laanwj:
    Code review ACK 70398ae05b
  TheCharlatan:
    ACK 70398ae05b

Tree-SHA512: d9a3ab4fcd59a7cf4872415c40cc7ac3a98dfc5aa25e195d4df880bb588bac286c30c3471e9d9499de379a75f45dcd0a82019eba3cb9f342004ae1482d0ba075
2025-02-14 11:15:53 +01:00
Cory Fields
9b033bebb1 cmake: rename Kernel component to bitcoinkernel for consistency 2025-02-13 18:25:58 +00:00
Cory Fields
2e0c92558e cmake: add and use install_binary_component
Add a separate component for each binary for fine-grained installation options.

Also install the man pages for only for the targets enabled.
2025-02-13 18:14:41 +00:00
glozow
96d30ed4f9
Merge bitcoin/bitcoin#31495: wallet: Utilize IsMine() and CanProvide() in migration to cover edge cases
af76664b12 test: Test migration of a solvable script with no privkeys (Ava Chow)
17f01b0795 test: Test migration of taproot output scripts (Ava Chow)
1eb9a2a39f test: Test migration of miniscript in legacy wallets (Ava Chow)
e8c3efc7d8 wallet migration: Determine Solvables with CanProvide (Ava Chow)
fa1b7cd6e2 migration: Skip descriptors which do not parse (Ava Chow)
440ea1ab63 legacy spkm: use IsMine() to extract watched output scripts (Ava Chow)
b777e84cd7 legacy spkm: Move CanProvide to LegacyDataSPKM (Ava Chow)
b1ab927bbf tests: Test migration of additional P2WSH scripts (Ava Chow)
c39b3cfcd1 test: Extra verification that migratewallet migrates (Ava Chow)

Pull request description:

  The legacy wallet `IsMine()` is essentially a black box that would tell us whether the wallet is watching an output script. In order to migrate legacy wallets to descriptor wallets, we need to be able to compute all of the output scripts that a legacy wallet would watch. The original approach for this was to understand `IsMine()` and write a function which would be its inverse. This was partially done in the original migration code, and attempted to be completed in #30328. However, further analysis of `IsMine()` has continued to reveal additional edge cases which make writing an inverse function increasingly difficult to verify correctness.

  This PR instead changes migration to utilize `IsMine()` to produce the output scripts by first computing a superset of all of the output scripts that `IsMine()` would watch and testing each script against `IsMine()` to filter for the ones that actually are watched. The superset is constructed by computing all possible output scripts for the keys and scripts in the wallet - for keys, every key could be a P2PK, P2PKH, P2WPKH, and P2SH-P2WPKH; for scripts, every script could be an output script, the redeemScript of a P2SH, the witnessScript of a P2WSH, and the witnessScript of a P2SH-P2WSH.

  Additionally, the legacy wallet can contain scripts that are redeemScripts and witnessScripts, while not watching for any output script utilizing that script. These are known as solvable scripts and are migrated to a separate "solvables" wallet. The previous approach to identifying these solvables was similar to identifying output scripts - finding known solvable conditions and computing the scripts. However, this also can miss scripts, so the solvables are now identified in a manner similar to the output scripts but using the function `CanProvide()`. Using the same superset as before, all output scripts which are `ISMINE_NO` are put through `CanProvide()` which will perform a dummy signing and then a key lookup to determine whether the legacy wallet could provide any solving data for the output script. The scripts that pass will have their descriptors inferred and the script included in the solvables wallet.

  The main downside of this approach is that `IsMine()` and `CanProvide()` can no longer be deleted. They will need to be refactored to be migration only code instead in #28710.

  Lastly, I've added 2 test cases for the edge cases that prompted this change of approach. In particular, miniscript witnessScripts and `rawtr()` output scripts are  solvable and signable in a legacy wallet, although never `ISMINE_SPENDABLE`.

ACKs for top commit:
  sipa:
    Code review ACK af76664b12d8611b606a7e755a103a20542ee539; I did not review the tests in detail.
  brunoerg:
    code review ACK af76664b12
  rkrux:
    ACK af76664b12

Tree-SHA512: 7f58a90de6f38fe9801fb6c2a520627072c8d66358652ad0872ff59deb678a82664b99babcfd874288bebcb1487d099a77821f03ae063c2b4cbf2d316e77d141
2025-02-13 12:30:15 -05:00
Ryan Ofsky
458ef0a11b refactor: Avoid using IsArgSet() on -connect list option
This commit does not change behavior, it just changes code to handle -noconnect
values explicitly with IsArgNegated() instead of implicitly with IsArgSet(),
and adds comments to make it clear what behavior is intended when -noconnect is
specified.
2025-02-13 12:30:15 -05:00