Compare commits

...

2178 Commits

Author SHA1 Message Date
Ava Chow b510893d00
Merge bitcoin/bitcoin#33494: depends: Update URL for `qrencode` package source tarball
93a70a42d3 depends: Update URL for `qrencode` package source tarball (Hennadii Stepanov)
6de8051263 depends: Use hash instead of file name for package download stamp (Hennadii Stepanov)
46135d90ea depends: Drop redundant check for downloaded file (Hennadii Stepanov)
771978952a depends: Fix `$(package)_fetched` target (Hennadii Stepanov)

Pull request description:

  The https://fukuchi.org/ homepage no longer links to the source tarball, and previously available files appear to have been removed. The homepage now instructs users to download source tarballs from the GitHub [releases](https://github.com/fukuchi/libqrencode/releases) page instead.

  The diff between the source trees is immaterial:
  ```diff
  --- old
  +++ new
  @@ -1,19 +1,16 @@
   27e7deccd2925c94e4190ee64794a051199f215f145f76fd664cdebedbbf8a35  acinclude.m4
  -e1e35b1309482f699a9700a2065a0bce09c2108dd1f78ba7bfbe0f7f0bdcd2e6  aclocal.m4
   a9308eec78790720dbcd5452ab8f241b5f1c6939ccf3389917b8e78cb2b58c9e  autogen.sh
   aa36725d577048f0370dc7415a1acb578fbdfb531c1b384a836d9360a81f6f5c  bitstream.c
   3feaacd7d096834fc5956215598564ec287ad443185c4433c3f8007cc53ceaa6  bitstream.h
   21bd5a34c90d3d6ee540ceb48c3d5aea5f21bd6b829ef3112db832af0bd423d8  ChangeLog
   f8a7a94c9622fab721df47e8121533ebfcb79885aca01ecec2fff00dfb84caef  cmake/FindIconv.cmake
   6345e7eecb92473f361a8eb98dd373aa09cae79a43408cf4b42b00b411c9c197  CMakeLists.txt
  -031d560570eab2eda57c2f9ee9952445002f8bf4a23965fcaf43bbc2c61590e2  config.h.in
  -d2f42cc5771b69f2d2ecd4b31509864ae2b18b25c823986390bb372ee07030fa  configure
   02867a8ea08206c84d5f4c05f41a15c639291091e3dfac27f3a9029d8f5d3028  configure.ac
   a9bdde5616ecdd1e980b44f360600ee8783b1f99b8cc83a2beb163a0a390e861  COPYING
   76c41754bccbf69a60fb7833776637c60b86f59104705c0a5cea9ee3a2968f3d  Doxyfile
   36d84f714cf28397b02d6c44860106a7cb858fc6d25239a2698a72fa5136e5c3  libqrencode.pc.in
   f0ce93a7e1b1f0fab87dd071ec3c8dd80a567d778dfc5930d9f375d676ecb9a0  Makefile.am
  -507c2385fb49c5724e8e3dfca97feb24cbdd4e651f3f0bfa62524e60088091a0  Makefile.in
  +dcb782b1b382328c0bce9194944bdcc65a6035d8e9f89e39436ed2e55ae8b969  makeREADME.sh
   6046d347c6c564fc13a24dc0a15a09a83023e00a4e0d0f23029a81f86ac4d024  mask.c
   9f853cee7d72191a8dbf018b7a86c0f0b6ca661e27a51fab677af911f2ff9e7e  mask.h
   a4e17b68d8db573e152132ebcbdc837b55415c12027f81232662db645faf79f0  mmask.c
  @@ -30,7 +27,7 @@
   6e9ff66002b4a839c6e78bcd6a55342d9eb8b289273fa838441b27ee9969e293  qrinput.h
   68831e02ee1ba602b1937328abec000e616c4472d9dc40067dd45ab7072df172  qrspec.c
   a2a9a5af4d62015e82b48b8316aea2b70031dcdc1ed2b829c0102ea5dc02aca2  qrspec.h
  -8730d006f1d45b90dc0ef9a20e4119420f15b37a09483c929baa4225e21f7900  README
  +a56773b55989ea5cae8a43f2d845ce0afa9576a26170937fbe36a69fee953cd4  README.md
   ace480f2e16001e276c73a5e965c282915ad81e2c28cce3ef574b5a8db7210e8  rsecc.c
   c731ebe26d58d5e5df3b2d694de0fb1c4ae80a36cf0559c49b04e989dee8b182  rsecc.h
   8ed1af4414b5628845519581c82bf51ba2b4dee1f8352c1fd01b50afcd0a0ed7  split.c
  @@ -46,7 +43,6 @@
   e26b20198a7393b3c060891876fa45edb81488aef9df6d6cf45893a605e5e5e4  tests/decoder.h
   adabfbddb0f25de2e2cae970195fcfdf11ad1fa66ce64e237d83f821346f64c4  tests/frame
   23c283a3d3b5f1bbb3108603ebf05d7a95951ba86a288e09140eab612a5eb258  tests/Makefile.am
  -c8b819bf7f00c979ab0b6f0d0fb10289d2006bc6acda1737d2f1c383a60e1e66  tests/Makefile.in
   ebd71b937d4d39f382f8c57f362a01f11fd617b66dbdf6f1a3c4897c8c42e235  tests/prof_qrencode.c
   d4adcb234d4c31473cd9ffedd1bfa9645ba336d426640ba5893dfe6e75db171d  tests/pthread_qrencode.c
   62298641504b0a2c1d199cd7f656cb376959200169042de76f7c5950d2d42395  tests/rscode.c
  @@ -63,6 +59,7 @@
   cf5792cbfb92ba46f7f5f14b98f00813b0e7e4f5e7c790c6a28793774474bf26  tests/test_monkey.c
   3a2c58346d57f6bb2a634d6febf3c65ac524259a2d789657f8d60c678bf8d658  tests/test_mqrspec.c
   b9d8c569ba36a2258cb1ad0d1f85ce4fb2935fad519e902bade59aa9772321aa  tests/test_qrencode.c
  +785fe14a6f8bc096b20ec271771fb09f22f29eb4f9d729f5b40d6b4cc824ce36  tests/test_qrenc.sh
   d0eee6eddf98ee4595c07f7da40c7de548651bf839b26995756e94db2599451f  tests/test_qrinput.c
   ace7885e435ef77cc127da0ac23c724498aaa8d80d53b908063f79c9f0b7acce  tests/test_qrspec.c
   fde9c2735ce94be51e1b0bbffe65415aa3afd2da5bd4c0e2c5e50e1a2f1ea3f7  tests/test_rs.c
  @@ -71,12 +68,4 @@
   6f35c0e1235b31d0068c4ab175d8110c736e60df0309d4be7b3e57dd62d316f6  tests/URI_testset.inc
   6be3983fc397cd5dade1dd219ad6cbe7977f416410b1509984006ecec51605b5  tests/view_qrcode.c
   92b5be1ca2239399232d51503715c848dae9bf3db71b1f03157bfa9779826910  TODO
  -c8af04e62bad4ab75dafd22119026e5e3943f385bdcbe7731a4938102453754c  use/compile
  -1d9048b0ac9d4d1dfce7aa4e3a0b59ccfd32db2f7693814aa6f4c778560f5669  use/config.guess
   b522487f9c47661d321367d133f3d41247dd16d435f2d4b9c643dee95bf65eee  use/config.rpath
  -5bf0da2576ebb21ab60a9d9291a85b40af0e956a9eafb709ca8b20dcb105f4ee  use/config.sub
  -732bcd6b9e23f241e015d71b0a3a862104053aba20718c1f56b292cee7e29371  use/depcomp
  -608b76d735bb2ec2bcb1271644c3d5e7a428fb8d2338e114e8a48ebf91ccfd23  use/install-sh
  -2304d53af1f63b76a11651efdd18578adf2bda1ffc2c257100cba374b55f284b  use/ltmain.sh
  -f038345dab184e538098d22a8edc423762da66a90ebe269f23bfef85287cd30c  use/missing
  -7c1ae35455771ae32050c2ed109e3d297160b6d1a2f70b0278cf6968e5e7e98c  use/test-driver
  ```

  ---

  **UPDATE 2025-09-30**

  A few commits have been added:

  1. The first commit fixes the `$(package)_fetched` target, which erroneously succeeds on the second run after a failure on the master branch:
  ```
  $ gmake -C depends clean-all
  $ gmake -C depends qrencode_fetched FALLBACK_DOWNLOAD_PATH="https://fallback.invalid"
  $ gmake -C depends qrencode_fetched FALLBACK_DOWNLOAD_PATH="https://fallback.invalid"
  $ echo $?
  0
  ```
  With the first commit applied:
  ```
  $ gmake -C depends clean-all
  $ gmake -C depends qrencode_fetched FALLBACK_DOWNLOAD_PATH="https://fallback.invalid"
  $ gmake -C depends qrencode_fetched FALLBACK_DOWNLOAD_PATH="https://fallback.invalid"
  $ echo $?
  2
  ```

  2. The second and third commits allow the depends build subsystem to detect when the source tarball content has been modified and needs to be re-downloaded, even if the file name remains the same.

ACKs for top commit:
  m3dwards:
    ACK 93a70a42d3
  achow101:
    ACK 93a70a42d3
  vasild:
    ACK 93a70a42d3
  janb84:
    ACK 93a70a42d3

Tree-SHA512: 38b7c029070426196c747fc45c9d00bae534eeeb2d9cd9f221580fce8380f4f8aecb6c48b2563e322edd8c9534f5dd42d8f4e110ada42bb83568cf2dcfb7dc22
2025-10-07 16:57:58 -07:00
Hennadii Stepanov ec5841888d
Merge bitcoin/bitcoin#32513: ci: remove 3rd party js from windows dll gha job
156927903d ci: Check windows manifests for all executables (Max Edwards)
e1a1b14c93 ci: use a more generic way of finding mt.exe (Max Edwards)
7ae0497eef ci: remove 3rd party js from windows dll gha job (Max Edwards)

Pull request description:

  The windows job uses the external dependency `ilammy/msvc-dev-cmd` which runs javascript. We use this to put various tools on the path such as `MSBuild.exe` and `mt.exe`. We can remove this dependency and use `vswhere.exe` directly to find these tools and create a "[Developer command prompt](https://github.com/microsoft/vswhere/wiki/Start-Developer-Command-Prompt#using-powershell)" as someone would on their dev machine.

  While in this area of the code, this PR also runs some additional manifest checks on the windows binaries.

  Fixes: #32508

ACKs for top commit:
  davidgumberg:
    crACK 156927903d
  hebasto:
    ACK 156927903d.

Tree-SHA512: df640dff27579a1c95daddc5a5ba8fd655bbd0a6f2aff74d0f63439c7185c0b18a90abfee3f1f032fe833cd19b822ef71812f44b24c4c044222e46d01c271864
2025-10-08 00:44:05 +01:00
Ava Chow d735e2e9b3
Merge bitcoin/bitcoin#32998: Bump SCRIPT_VERIFY flags to 64 bit
652424ad16 test: additional test coverage for script_verify_flags (Anthony Towns)
417437eb01 script/verify_flags: extend script_verify_flags to 64 bits (Anthony Towns)
3cbbcb66ef script/interpreter: make script_verify_flag_name an ordinary enum (Anthony Towns)
bddcadee82 script/verify_flags: make script_verify_flags type safe (Anthony Towns)
a5ead122fe script/interpreter: introduce script_verify_flags typename (Anthony Towns)
4577fb2b1e rpc: have getdeploymentinfo report script verify flags (Anthony Towns)
a3986935f0 validation: export GetBlockScriptFlags() (Anthony Towns)
5db8cd2d37 Move mapFlagNames and FormatScriptFlags logic to script/interpreter.h (Anthony Towns)

Pull request description:

  We currently use 21 of 32 possible bits for `SCRIPT_VERIFY_*` flags, with open PRs that may use 8 more (#29247, #31989, #32247, #32453). The mutinynet fork that has included many experimental soft fork features is [already reusing bits here](d4a86277ed/src/script/interpreter.h (L175-L195)). Therefore, bump this to 64 bits.

  In order to make it easier to update this logic in future, this PR also introduces a dedicated type for the script flags, and disables implicit conversion between that type and the underlying integer type. To make verifying that this change doesn't cause flags to disappear, this PR also resurrects the changes from #28806 so that the script flags that are consensus enforced on each block can be queried via getdeploymentinfo.

ACKs for top commit:
  instagibbs:
    reACK 652424ad16
  achow101:
    ACK 652424ad16
  darosior:
    ACK 652424ad16
  theStack:
    Code-review ACK 652424ad16 🎏

Tree-SHA512: 7b30152196cdfdef8b9700b571b7d7d4e94d28fbc5c26ea7532788037efc02e4b1d8de392b0b20507badfdc26f5c125f8356a479604a9149b8aae23a7cf5549f
2025-10-07 14:51:22 -07:00
Ava Chow de1dc6b47b
Merge bitcoin/bitcoin#33515: Improve LastCommonAncestor performance + add tests
3635d62f5a chain: make use of pskip in LastCommonAncestor (optimization) (Pieter Wuille)
2e09d66fbb tests: add unit tests for CBlockIndex::GetAncestor and LastCommonAncestor (Pieter Wuille)

Pull request description:

  In theory, the `LastCommonAncestor` function in chain.cpp can take $\mathcal{O}(n)$ time, walking over the entire chain, if the forking point is very early, which could take ~milliseconds. I expect this to be very rare in normal occurrences, but it seems nontrivial to reason about worst cases as it's accessible from several places in net_processing.

  This PR modifies the algorithm to make use of the `CBlockIndex::pskip` skip pointers to find the forking point in sublinear time (a simulation shows that for heights up to $34 \cdot 4^k - 2$ and $k \geq 8$, no more than $k^2 + 10k + 13$ steps are ever needed), in a way that should be nearly free - at worst the same number of memory accesses should be made, with a tiny increase in computation.

  As it appears we didn't really have tests for this function, unit tests are added for that function as well as `CBlockIndex::GetAncestor()`.

  This is inspired by https://github.com/bitcoin/bitcoin/pull/32180#discussion_r2394877881

ACKs for top commit:
  optout21:
    ACK 3635d62f5a
  achow101:
    ACK 3635d62f5a
  vasild:
    ACK 3635d62f5a
  mzumsande:
    Code Review ACK 3635d62f5a
  furszy:
    ACK 3635d62f5a
  stratospher:
    ACK 3635d62f5a.

Tree-SHA512: f9b7dea1e34c1cc1ec1da3fb9e90c4acbf4aaf0f04768844f538201efa6b11eeeefc97b720509e78c21878977192e2c4031fd8974151667e2e756247002b8164
2025-10-07 13:54:25 -07:00
merge-script 919e6d01e9
Merge bitcoin/bitcoin#33489: build: Drop support for EOL macOS 13
1aaaaa078b fuzz: Drop unused workaround after Apple-Clang bump (MarcoFalke)
fadad7a494 Drop support for EOL macOS 13 (MarcoFalke)

Pull request description:

  Now that macOS 13 is EOL (https://en.wikipedia.org/wiki/MacOS_Ventura), it seems odd to still support it.

  (macOS Ventura 13.7.8 received its final security update on 20 Aug 2025: https://support.apple.com/en-us/100100)

  This patch will only be released in version 31.x, another 6 months out from now.

  So:

  * Update the depends build and release note template to drop EOL macOS 13.
  * As a result, update the earliest Xcode to version 16 in CI.
  * Also, bump the macOS CI runner to version 15, to avoid issues when version 14 will be at its EOL in about 1 year.

  This also allows to drop a small workaround in the fuzz tests and unlocks libcpp hardening (https://github.com/bitcoin/bitcoin/pull/33462)

ACKs for top commit:
  stickies-v:
    re-ACK 1aaaaa078b
  l0rinc:
    code review ACK 1aaaaa078b
  hodlinator:
    re-ACK 1aaaaa078b
  hebasto:
    ACK 1aaaaa078b.

Tree-SHA512: 6d247a8432ef8ea8c6ff2a221472b278f8344346b172980299507f9898bb9e8e16480c128b1f4ca692bcbcc393da2b2fd6895ac5f118bc09e0f30f910529d20c
2025-10-06 12:48:00 -04:00
merge-script 452ea59281
Merge bitcoin/bitcoin#33454: net: support overriding the proxy selection in ConnectNode()
c76de2eea1 net: support overriding the proxy selection in ConnectNode() (Vasil Dimov)

Pull request description:

  Normally `ConnectNode()` would choose whether to use a proxy and which one. Make it possible to override this from the callers and same for `OpenNetworkConnection()` - pass down the proxy to `ConnectNode()`.

  Document both functions.

  This is useful if we want to open connections to IPv4 or IPv6 peers through the Tor SOCKS5 proxy.

  Also have `OpenNetworkConnection()` return whether the connection succeeded or not. This can be used when the caller needs to keep track of how many (successful) connections were opened.

  ---

  This is part of [#29415 Broadcast own transactions only via short-lived Tor or I2P connections](https://github.com/bitcoin/bitcoin/pull/29415). Putting it in its own PR to reduce the size of #29415 and because it does not depend on the other commits from there.

ACKs for top commit:
  stratospher:
    ACK c76de2e.
  optout21:
    ACK c76de2eea1
  mzumsande:
    Code Review ACK c76de2eea1
  andrewtoth:
    ACK c76de2eea1

Tree-SHA512: 1d266e4280cdb1d0599971fa8b5da58b1b7451635be46abb15c0b823a1e18cf6e7bcba4a365ad198e6fd1afee4097d81a54253fa680c8b386ca6b9d68d795ff0
2025-10-06 12:43:14 -04:00
merge-script a33bd767a3
Merge bitcoin/bitcoin#33464: p2p: Use network-dependent timers for inbound inv scheduling
0f7d4ee4e8 p2p: Use different inbound inv timer per network (Martin Zumsande)
94db966a3b net: use generic network key for addrcache (Martin Zumsande)

Pull request description:

  Currently, `NextInvToInbounds` schedules  each round of `inv` at the same time for all inbound peers. It's being done this way because with a separate timer per peer (like it's done for outbounds), an attacker could do multiple connections to learn about the time a transaction arrived. (#13298).

  However, having a single timer for inbounds of all networks is also an obvious fingerprinting vector: Connecting to a suspected pair of privacy-network and clearnet addresses and observing the `inv` pattern makes it trivial to confirm or refute that they are the same node.

  This PR changes it such that a separate timer is used for each network.
  It uses the existing method  from `getaddr` caching and generalizes it to be saved in a new field `m_network_key` in `CNode` which will be used for both `getaddr` caching and `inv` scheduling, and can also be used for any future anti-fingerprinting measures.

ACKs for top commit:
  sipa:
    utACK 0f7d4ee4e8
  stratospher:
    reACK 0f7d4ee.
  naiyoma:
    Tested ACK 0f7d4ee4e8
  danielabrozzoni:
    reACK 0f7d4ee4e8

Tree-SHA512: e197c3005b2522051db432948874320b74c23e01e66988ee1ee11917dac0923f58c1252fa47da24e68b08d7a355d8e5e0a3ccdfa6e4324cb901f21dfa880cd9c
2025-10-03 23:45:17 +01:00
merge-script 2578da69f4
Merge bitcoin/bitcoin#33485: test: set par=2 in default config for functional test framework
dda5228e02 test: set par=2 in default config for functional test framework (Andrew Toth)

Pull request description:

  Depending on the host machine, a default `par` value can spawn up to 15 script verification threads for each node. Running the functional test suite with default `par` can exhaust file descriptors or hit other resource limits when many threads are spawned. These threads are mostly idle and the same code paths are executed with a value of `par=2`. Limit this to 2 for functional tests that do not override the default option.

ACKs for top commit:
  maflcko:
    lgtm ACK dda5228e02
  pablomartin4btc:
    ACK dda5228e02
  l0rinc:
    Code review ACK dda5228e02
  theStack:
    ACK dda5228e02

Tree-SHA512: 4459972330ff50ac7391141db6382579de09d84e68959eaeb5f20972bb9daf9aac1bd68355028ded9ee65e838c12dbd53e6f3bb6cdc375d269f666c19a19eaec
2025-10-03 22:36:34 +01:00
merge-script 25dbe4bc86
Merge bitcoin/bitcoin#33533: test: addrman: check isTerrible when time is more than 10min in the future
8e47ed6906 test: addrman: check isTerrible when time is more than 10min in the future (brunoerg)

Pull request description:

  This PR adds test coverage to kill the following mutant (https://corecheck.dev/mutation/src/addrman.cpp#L76):
  ```diff
  diff --git a/src/addrman.cpp b/src/addrman.cpp
  index 9c3a24db90..0ffd349315 100644
  --- a/src/addrman.cpp
  +++ b/src/addrman.cpp
  @@ -73,7 +73,7 @@ bool AddrInfo::IsTerrible(NodeSeconds now) const
       }

       if (nTime > now + 10min) { // came in a flying DeLorean
  -        return true;
  +        return false;
       }
  ```

  When the `nTime` is set 10 minutes in the future the addr should be marked as terrible.

ACKs for top commit:
  Crypt-iQ:
    crACK 8e47ed6906
  danielabrozzoni:
    tACK 8e47ed6906
  marcofleon:
    Nice, code review ACK 8e47ed6906

Tree-SHA512: b53b3aa234a73ec7808cb1555916ac64dd707f230ec290a1712493ece8e274a060e16d862b31df0f744804ebd3c0c2825c49becb7d3040cc358e48c4002524cb
2025-10-03 20:20:46 +01:00
merge-script cfb0d74698
Merge bitcoin/bitcoin#33121: test: fix p2p_leak_tx.py
14ae71f323 test: make notfound_on_unannounced more reliable (David Gumberg)
99bc552980 test: fix (w)txid confusion in p2p_leak_tx.py (Martin Zumsande)
576dd97cb9 test: increase timeout in p2p_leak_tx.py (Martin Zumsande)

Pull request description:

  This fixes two issues with `p2p_leak_tx.py`:

  1.) #33090: As far as I can see, this is just the randomness of `NextInvToInbounds`/ `rand_exp_duration`, which has a probability of `e^-(60s/5s) = 6.14×10^−6` to result in a period > 60s (our waiting time), so that the test would fail every 160k runs... Doubling the timeout should be sufficient to lower the probability drastically.

  2.) The subtest `test_notfound_on_unannounced_tx` has some (w)txid confusion: we send a `MSG_TX`-type getdata with a `wtxid` in it, which necessarily always results in a NOTFOUND. Fixed this, and change the subtest to be more deterministic based on `mocktime`.

ACKs for top commit:
  stratospher:
    ACK 14ae71f. nice restructuring using mocktime!
  davidgumberg:
    reACK 14ae71f323
  vasild:
    ACK 14ae71f323

Tree-SHA512: be5a4ca7bf56f82b6fa04d90ef9312dc2e6f8ff7ddf70b39d979dc42fbdd823157109b8b5dc46eb7f81ac1e816f40e6966b3c8a7d384aadee01e2189c20d3e3a
2025-10-03 20:06:50 +01:00
merge-script 86eaa4d6cd
Merge bitcoin/bitcoin#33482: contrib: fix macOS deployment with no translations
7b5261f7ef contrib: fix using macdploy script without translations. (amisha)

Pull request description:

  **Description**
  From what I deciphered reading the line https://github.com/bitcoin/bitcoin/blob/master/contrib/macdeploy/macdeployqtplus#L390 is that qt translations are optional to have hence we should be able to build without it but the case where the flag translations_dir falls back to its default Null value it raises this error.

  The config comments also mentioned that adding translation file is optional.

  ```
  ./macdeployqtplus --help
  usage: macdeployqtplus [-h] [-verbose [VERBOSE]] [-no-plugins] [-no-strip] [-translations-dir path] [-zip zip] app-bundle

  Improved version of macdeployqt. Outputs a ready-to-deploy app in a folder "dist" and optionally wraps it in a .zip file. Note, that the "dist" folder will be deleted before deploying on each run. Optionally, Qt translation files
  (.qm) can be added to the bundle.
  ```

  **Steps to reproduce**
  So I was following the general steps to set up app on macos however I didn't download any qt translations presuming it was optional from the comment linkedin in PR, so to reproduce if you have translation directories in place ull need to delete them and then try to build the file, otherwise don't download it at all and try to build it. It should fail on that flag as translations dir was never downloaded.

  **Approach taken**
  I have moved the code which adds language files under the if statement that first checks if the value of the flag is not Null before referencing it.

ACKs for top commit:
  ismaelsadeeq:
    ACK 7b5261f7ef

Tree-SHA512: 8d51b17569e42c9feb95e1be17b1551c708a05eb44b82c74db0b25e07006b4ee223d64484f8bdb2ee1420f6e571686561ae1c09bd3362f77dcbb507bc5085f86
2025-10-03 15:40:38 +01:00
merge-script 007900ee9b
Merge bitcoin/bitcoin#33434: depends: static libxcb-cursor
eca50854e1 depends: static libxcb_cursor (fanquake)

Pull request description:

  Remove the runtime requirement of `libxcb-cursor`. This library is no-longer present on modern Ubuntu.
  Fixes #33432.
  Also related to #32097.

ACKs for top commit:
  davidgumberg:
    Addendum ACK eca50854e1
  willcl-ark:
    Code review ACK eca50854e1

Tree-SHA512: d545a03baf5030de64874b79add87b6ef5f95eb5ca31aa66007ee03554103d2eda5e56dfd4395d0a12e24b2e489457e4f19ed9e6d390351c72a0da630f03cc42
2025-10-03 15:26:20 +01:00
brunoerg 8e47ed6906 test: addrman: check isTerrible when time is more than 10min in the future 2025-10-03 10:24:29 -03:00
Pieter Wuille 3635d62f5a chain: make use of pskip in LastCommonAncestor (optimization)
By using the pskip pointer, which regularly allows jumping back much faster
than pprev, the forking point between two CBlockIndex entries can be found
much faster.

A simulation shows that no more than 136 steps are needed to jump anywhere
within the first 2^20 block heights, and on average 65 jumps for uniform
forking points around that height.
2025-10-02 10:34:12 -04:00
Pieter Wuille 2e09d66fbb tests: add unit tests for CBlockIndex::GetAncestor and LastCommonAncestor 2025-10-02 10:34:09 -04:00
Max Edwards 156927903d ci: Check windows manifests for all executables
The other executables have manifests and these should be checked in
addition to bitcoind. Skipping fuzz.exe, bench_bitcoin.exe and
test_bitcoin-qt.exe as they do not have manifests.
2025-10-02 15:13:29 +01:00
Max Edwards e1a1b14c93 ci: use a more generic way of finding mt.exe
This sets up a vs developer command prompt and should hopefully should
be more resilient to upstream changes

Co-authored-by: David Gumberg <davidzgumberg@gmail.com>
2025-10-02 15:13:26 +01:00
merge-script 1ed00a0d39
Merge bitcoin/bitcoin#33504: Mempool: Do not enforce TRUC checks on reorg
06df14ba75 test: add more TRUC reorg coverge (Greg Sanders)
26e71c237d Mempool: Do not enforce TRUC checks on reorg (Greg Sanders)
bbe8e9063c fuzz: don't bypass_limits for most mempool harnesses (Greg Sanders)

Pull request description:

  This was the intended behavior but our tests didn't cover the scenario where in-block transactions themselves violate TRUC topological constraints.

  The behavior in master will potentially lead to many erroneous evictions during a reorg, where evicted TRUC packages may be very high feerate and make sense to mine all together in the next block and are well within the normal anti-DoS chain limits.

  This issue exists since the merge of https://github.com/bitcoin/bitcoin/pull/28948/files#diff-97c3a52bc5fad452d82670a7fd291800bae20c7bc35bb82686c2c0a4ea7b5b98R956

ACKs for top commit:
  sdaftuar:
    ACK 06df14ba75
  glozow:
    ACK 06df14ba75
  ismaelsadeeq:
    Code review ACK 06df14ba75

Tree-SHA512: bdb6e4dd622ed8b0b11866263fff559fcca6e0ca1c56a884cca9ac4572f0026528a63a9f4c8a0660df2f5efe0766310a30e5df1d6c560f31e4324ea5d4b3c1a8
2025-10-02 13:22:22 +01:00
Vasil Dimov c76de2eea1
net: support overriding the proxy selection in ConnectNode()
Normally `ConnectNode()` would choose whether to use a proxy and which
one. Make it possible to override this from the callers and same for
`OpenNetworkConnection()` - pass down the proxy to `ConnectNode()`.

Document both functions.

This is useful if we want to open connections to IPv4 or IPv6 peers
through the Tor SOCKS5 proxy.

Also have `OpenNetworkConnection()` return whether the connection
succeeded or not. This can be used when the caller needs to keep track
of how many (successful) connections were opened.
2025-10-02 08:39:26 +02:00
Ava Chow 75353a0163
Merge bitcoin/bitcoin#32326: net: improve the interface around FindNode() and avoid a recursive mutex lock
87e7f37918 doc: clarify peer address in getpeerinfo and addnode RPC help (Vasil Dimov)
2a4450ccbb net: change FindNode() to not return a node and rename it (Vasil Dimov)
4268abae1a net: avoid recursive m_nodes_mutex lock in DisconnectNode() (Vasil Dimov)
3a4d1a25cf net: merge AlreadyConnectedToAddress() and FindNode(CNetAddr) (Vasil Dimov)

Pull request description:

  `CConnman::FindNode()` would lock `m_nodes_mutex`, find the node in `m_nodes`, release the mutex and return the node. The current code is safe but it is a dangerous interface where a caller may end up using the node returned from `FindNode()` without owning `m_nodes_mutex` and without having that node's reference count incremented.

  Change `FindNode()` to return a boolean since all but one of its callers used its return value to check whether a node exists and did not do anything else with the return value.

  Remove a recursive lock on `m_nodes_mutex`.

  Rename `FindNode()` to better describe what it does.

ACKs for top commit:
  achow101:
    ACK 87e7f37918
  furszy:
    Code review ACK 87e7f37918
  hodlinator:
    re-ACK 87e7f37918

Tree-SHA512: 44fb64cd1226eca124ed1f447b4a1ebc42cc5c9e8561fc91949bbeaeaa7fa16fcfd664e85ce142e5abe62cb64197c178ca4ca93b3b3217b913e3c498d0b7d1c9
2025-10-01 14:17:22 -07:00
Vasil Dimov 87e7f37918
doc: clarify peer address in getpeerinfo and addnode RPC help
The returned value in `getpeerinfo/addr` could be a hostname as well as
an IP address and the `:port` part could be missing. It is displayed
from `CNode::m_addr_name` which could have been set from RPC `addnode`
where the argument is allowed to be a hostname and an optional port.
2025-10-01 16:39:56 +02:00
Vasil Dimov 2a4450ccbb
net: change FindNode() to not return a node and rename it
All callers of `CConnman::FindNode()` use its return value `CNode*` only
as a boolean null/notnull. So change that method to return `bool`.

This removes the dangerous pattern of handling a `CNode` object (the
return value of `FindNode()`) without holding `CConnman::m_nodes_mutex`
and without having that object's reference count incremented for the
duration of the usage.

Also rename the method to better describe what it does.
2025-10-01 16:39:56 +02:00
Vasil Dimov 4268abae1a
net: avoid recursive m_nodes_mutex lock in DisconnectNode()
Have `CConnman::DisconnectNode()` iterate `m_nodes` itself instead of
using `FindNode()`. This avoids recursive mutex lock and drops the only
caller of `FindNode()` which used the return value for something else
than a boolean found/notfound.
2025-10-01 16:39:55 +02:00
Hennadii Stepanov acc7f2a433
Merge bitcoin/bitcoin#33401: ci: Remove bash -c from cmake invocation using eval
50194029e7 ci: Remove bash -c from cmake invocation using eval (Brandon Odiwuor)

Pull request description:

  Follow up to https://github.com/bitcoin/bitcoin/pull/32970

  https://github.com/bitcoin/bitcoin/pull/32970#r2213730157

  > Does `cmake -S ...` still need to be wrapped in `bash -c "..."`?

  https://github.com/bitcoin/bitcoin/pull/32970#r2213741192
  > It is not trivial to replace. Maybe the `eval` hack from below can be used:
  >
  > ```shell
  >   # parses TEST_RUNNER_EXTRA as an array which allows for multiple arguments such as TEST_RUNNER_EXTRA='--exclude "rpc_bind.py --ipv6"'
  >
  >   eval "TEST_RUNNER_EXTRA=($TEST_RUNNER_EXTRA)"
  > ```
  >however, I haven't tried this yet.

  https://github.com/bitcoin/bitcoin/pull/32970#r2213801696
  > Yeah, the eval hack should work:
  >
  > ```
  > $ export T="-DREDUCE_EXPORTS=ON -DCMAKE_CXX_FLAGS='-Wno-psabi     -Wno-error=maybe-uninitialized'";  eval "T=($T)"; for i in "${T[@]}"; do  echo "_${i}_" ; done
  > _-DREDUCE_EXPORTS=ON_
  > _-DCMAKE_CXX_FLAGS=-Wno-psabi     -Wno-error=maybe-uninitialized_
  > ```
  >
  > (can be done in a follow-up)

  This replaces the `bash -c` wrapper with an eval-based array parsing to preserve spaces in flag values (e.g., in CMAKE_CXX_FLAGS), allowing ShellCheck to lint the cmake command

ACKs for top commit:
  maflcko:
    lgtm ACK 50194029e7
  hebasto:
    ACK 50194029e7.

Tree-SHA512: 6fd22569e2c719a8d13805f18e1e7e3b8eb57d0a6307f2e7175988b25750eafb7c8260796c8e7350db67d622dbe97e6af7bab8ee52187bb8e8eeae3740a47c01
2025-10-01 11:36:10 +01:00
MarcoFalke 1aaaaa078b
fuzz: Drop unused workaround after Apple-Clang bump 2025-10-01 08:09:34 +02:00
MarcoFalke fadad7a494
Drop support for EOL macOS 13 2025-10-01 08:09:30 +02:00
Brandon Odiwuor 50194029e7 ci: Remove bash -c from cmake invocation using eval 2025-10-01 08:58:17 +03:00
Ava Chow f41f97240c
Merge bitcoin/bitcoin#28584: Fuzz: extend CConnman tests
0802398e74 fuzz: make it possible to mock (fuzz) CThreadInterrupt (Vasil Dimov)
6d9e5d130d fuzz: add CConnman::SocketHandler() to the tests (Vasil Dimov)
3265df63a4 fuzz: add CConnman::InitBinds() to the tests (Vasil Dimov)
91cbf4dbd8 fuzz: add CConnman::CreateNodeFromAcceptedSocket() to the tests (Vasil Dimov)
50da7432ec fuzz: add CConnman::OpenNetworkConnection() to the tests (Vasil Dimov)
e6a917c8f8 fuzz: add Fuzzed NetEventsInterface and use it in connman tests (Vasil Dimov)
e883b37768 fuzz: set the output argument of FuzzedSock::Accept() (Vasil Dimov)

Pull request description:

  Extend `CConnman` fuzz tests to also exercise the methods `OpenNetworkConnection()`, `CreateNodeFromAcceptedSocket()`, `InitBinds()` and `SocketHandler()`.

  Previously fuzzing those methods would have resulted in real socket functions being called in the operating system which is undesirable during fuzzing. Now that https://github.com/bitcoin/bitcoin/pull/21878 is complete all those are mocked to a fuzzed socket and a fuzzed DNS resolver (see how `CreateSock` and `g_dns_lookup` are replaced in the first commit).

ACKs for top commit:
  achow101:
    ACK 0802398e74
  jonatack:
    Review re-ACK 0802398e74
  dergoegge:
    Code review ACK 0802398e74

Tree-SHA512: a717d4e79f42bacf2b029c821fdc265e10e4e5c41af77cd4cb452cc5720ec83c62789d5b3dfafd39a22cc8c0500b18169aa7864d497dded729a32ab863dd6c4d
2025-09-30 15:59:09 -07:00
Ava Chow cc4a2cc6bd
Merge bitcoin/bitcoin#33453: docs: Undeprecate datacarrier and datacarriersize configuration options
451ba9ada4 datacarrier: Undeprecate configuration option (Anthony Towns)

Pull request description:

  Removes the deprecation for the `datacarrier` and `datacarriersize` options by reverting commit 0b4048c733 from https://github.com/bitcoin/bitcoin/pull/32406

  **Many current Bitcoin Core users want to continue using this option**
  This statement is based on public postings from many Bitcoin Core users and not a formal survey. AJ Towns’ observation from [#32406](0b4048c733 (r2084024874)) that “_for now there seem to be a bunch of users who like the option_” has only become more apparent in the months since.

  **The deprecation intent is unclear to users**
  This echo’s Ava Chow’s comment from #32714 that “_IMO we should not have removal warnings if there is no current plan to actually remove them._” In months since that comment, partially due to increased feedback from Bitcoin Core users wanting to keep this option, there is even less likelihood of a near term plan to remove these options. That leaves Bitcoin Core users in an unclear situation: the option could be removed in the next version or perhaps never. Removing the deprecation gives clarity for their planning purposes. Deprecating the option in the future, preferably with a removal schedule to better inform users, would still be possible.

  **Minimal downsides to removing deprecation**
  As a best practice, Bitcoin Core has avoided an option when the developers cannot articulate when they should be used. There is non-zero maintenance cost to keeping this code around (although leaving the options deprecated for a long time has the same effect). “Don’t offer users footguns” is also a good principle, but with this option, there seems to be only small impacts that can quickly be remedied by changing the option value by Bitcoin Core users. There already exist in Bitcoin Core more potentially-user-harmful options/values than what datacarrier might cause.

ACKs for top commit:
  ajtowns:
    ACK 451ba9ada4
  darosior:
    That said, certain users care strongly about using those options. In these conditions, i do not see the project removing the option anytime soon. Therefore i think it's technically incorrect (and confusing) to mark it as deprecated. utACK 451ba9ada4 on removing the deprecation.
  instagibbs:
    crACK 451ba9ada4
  Raimo33:
    ACK 451ba9ada4
  Ademan:
    utACK 451ba9a
  ryanofsky:
    Code review ACK 451ba9ada4
  marcofleon:
    ACK 451ba9ada4
  achow101:
    ACK 451ba9ada4
  moonsettler:
    ACK 451ba9ada4
  ismaelsadeeq:
    utACK 451ba9ada4 🛰️
  jonatack:
    ACK 451ba9ada4
  Zero-1729:
    crACK 451ba9ada4
  vasild:
    ACK 451ba9ada4

Tree-SHA512: b83fc509f5dd820976596e1ae9fb69a22ada567e0e0ac88da5fc5e940a46d8894b40cc70c3eff2cbdabd4da5ec913f0d18c1632fc906f210b308855868410699
2025-09-30 15:23:20 -07:00
Ava Chow 7502d4e940
Merge bitcoin/bitcoin#33260: test: Use extra_port() helper in feature_bind_extra.py
fabc2615af test: Use extra_port() helper in feature_bind_extra.py (MarcoFalke)

Pull request description:

  This is a refactor for self-validating and self-documenting code.

  Currently, the test assumes that extra ports are available and just increments them without checking. However, this may not be the case when the test is modified to use more ports. In this case, the tests may fail intermittently and the failure is hard to debug.

  Fix this confusion, by calling `p2p_port` each time. This ensures the required `assert n <= MAX_NODES` is checked each time.

  Closes https://github.com/bitcoin/bitcoin/issues/33250

ACKs for top commit:
  achow101:
    ACK fabc2615af
  janb84:
    crACK fabc2615af
  w0xlt:
    ACK fabc2615af

Tree-SHA512: 1eff00be7f43104ae8a66e79fbf64075ec22bb20f392ac1e4c8a7dd694d4f1760aa44ea54ab7b1f2b947ab018851ab3c10d3c717714c0bee4d8d24617594c2bb
2025-09-30 13:30:36 -07:00
David Gumberg 14ae71f323 test: make notfound_on_unannounced more reliable
By using mocktime, we will always hit both the notfound
branch and the tx sent branch.
The previous version didn't achieve that due to timing
issues.

Co-authored-by: Martin Zumsande <mzumsande@gmail.com>
2025-09-30 15:57:31 -04:00
Martin Zumsande 99bc552980 test: fix (w)txid confusion in p2p_leak_tx.py
Before, we'd send a MSG_TX with a wtxid in it, which
would always result in a notfound answer
2025-09-30 15:57:31 -04:00
Martin Zumsande 576dd97cb9 test: increase timeout in p2p_leak_tx.py
With a low but not negligible probability in the order
of 10^-6 the exponential timer NextInvToInBounds can lead
to an interval >60s, making the test fail.
Also uses mocktime to speed up the test and fixes a
non-matching on_inv override.

Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
2025-09-30 15:56:17 -04:00
Ava Chow 8f73d95221
Merge bitcoin/bitcoin#33299: wallet: reduce unconditional logging during load
fc861332b3 wallet, log: reduce unconditional logging during load (furszy)

Pull request description:

  Currently the unconditional log during init with a default wallet happens three times:
  ```
  2025-09-03T19:57:16Z init message: Verifying wallet(s)…
  2025-09-03T19:57:16Z Using SQLite Version 3.45.1
  2025-09-03T19:57:16Z Using wallet XXX/.bitcoin/regtest
  2025-09-03T19:57:16Z Using SQLite Version 3.45.1
  2025-09-03T19:57:16Z Using wallet XXX/.bitcoin/regtest
  (...)
  2025-09-03T19:57:16Z Using SQLite Version 3.45.1
  2025-09-03T19:57:16Z Using wallet XXX/.bitcoin/regtest
  2025-09-03T19:57:16Z init message: Loading wallet…
  ```
  For non-default wallets it's logged two times.

  That seems a bit too much, so just log the SQLite version just one, and remove the log for the full path of the wallet, since it's already clear from other logs which wallet is being loaded.

ACKs for top commit:
  achow101:
    ACK fc861332b3
  furszy:
    utACK fc861332b3
  stickies-v:
    ACK fc861332b3

Tree-SHA512: ca45c8ede985e6feab0cb93d718a6d633691276ca6e5f13f6471759f11dee98b312e1c802a7fb42c7fa859b6edc44a8c54b9e2ca389655cf028aebf2dabe51f6
2025-09-30 11:01:27 -07:00
Martin Zumsande 0f7d4ee4e8 p2p: Use different inbound inv timer per network
Currently nodes schedule their invs to all inbound peers at the same time.
It is trivial to make use this timing pattern for fingerprinting
identities on different networks. Using a separate timers for each network will
make the fingerprinting harder.
2025-09-30 11:17:17 -04:00
Hennadii Stepanov 93a70a42d3
depends: Update URL for `qrencode` package source tarball
The https://fukuchi.org/ homepage no longer links to the source tarball,
and previously available files appear to have been removed. The homepage
now instructs users to download source tarballs from the GitHub releases
page instead.

The diff between the source trees is immaterial.
2025-09-30 11:26:47 +01:00
Hennadii Stepanov 6de8051263
depends: Use hash instead of file name for package download stamp
The package version is still included for convenience.
2025-09-30 11:26:29 +01:00
Hennadii Stepanov 46135d90ea
depends: Drop redundant check for downloaded file
The `fetch_file` commands are invoked for the `$($(package)_fetched)`
target, so the existence of the download stamp has already been tested.
2025-09-30 11:22:50 +01:00
Hennadii Stepanov 771978952a
depends: Fix `$(package)_fetched` target
Ensure the download timestamp is created only after a successful
download.
2025-09-30 11:20:12 +01:00
Hennadii Stepanov 25212dfdb4
Merge bitcoin/bitcoin#33487: ci: use latest versions of lint deps
d4f47f9771 ci: use latest versions of lint deps (fanquake)

Pull request description:

  Some of the versions used here are > 2 years old. i.e `mypy`. Use the latest avilable versions, except for LIEF, which is generally changed with Guix.

  Side note. I can't remember the last time one of these tools (mypy, ruff, vulture) actually caught an issue in the lint job.

ACKs for top commit:
  maflcko:
    lgtm ACK d4f47f9771
  janb84:
    lgtm ACK d4f47f9771
  hebasto:
    ACK d4f47f9771, I have reviewed the code and it looks OK.

Tree-SHA512: 8b312535c9fea8e76d58f517ada6d6ea7a119c5e03c8cb84a41b5b6ca80dfaaff65a81478bdc1a5acf734cfb0bc66a8b3ba5400db8973c43ca913b07568abfe4
2025-09-30 08:17:14 +01:00
Greg Sanders 06df14ba75 test: add more TRUC reorg coverge 2025-09-29 16:25:54 -04:00
Greg Sanders 26e71c237d Mempool: Do not enforce TRUC checks on reorg
Not enforcing TRUC topology on reorg was the intended
behavior, but the appropriate bypass argument was not
checked.

This mistake means we could potentially invalidate a long
chain of perfectly incentive-compatible transactions that
were made historically, including subsequent non-TRUC
transactions, all of which may have been very high feerate.

Lastly, it wastes CPU cycles doing topology checks since
this behavior cannot actually enforce the topology in
general for the reorg setting.
2025-09-29 16:25:54 -04:00
Greg Sanders bbe8e9063c fuzz: don't bypass_limits for most mempool harnesses
Using bypass_limits=true is essentially fuzzing part of a
reorg only, and results in TRUC invariants unable to be
checked. Remove most instances of bypassing limits, leaving
one harness able to do so.
2025-09-29 16:25:54 -04:00
fanquake d4f47f9771
ci: use latest versions of lint deps
Some of the versions used here are > 2 years old. i.e mypy. Use the
latest avilable versions, except for LIEF, which is generally changed
with Guix.
2025-09-29 14:47:41 -04:00
furszy fc861332b3 wallet, log: reduce unconditional logging during load
The removed statements were logged up to two or three times for each loaded
wallet. The SQLite version only needs to be logged once.
The full wallet path is dropped, since the existing unconditional
logging while loading wallets is sufficient (also reduces anonymization
efforts in case of sharing logs).

Co-authored-by: Martin Zumsande <mzumsande@gmail.com>
2025-09-29 13:59:44 -04:00
Vasil Dimov 3a4d1a25cf
net: merge AlreadyConnectedToAddress() and FindNode(CNetAddr)
`CConnman::AlreadyConnectedToAddress()` is the only caller of
`CConnman::FindNode(CNetAddr)`, so merge the two in one function.

The unit test that checked whether `AlreadyConnectedToAddress()` ignores
the port is now unnecessary because now the function takes a `CNetAddr`
argument. It has no access to the port.
2025-09-29 12:51:52 +02:00
merge-script d8fe258cd6
Merge bitcoin/bitcoin#33484: doc: rpc: fix case typo in `finalizepsbt` help (final_scriptwitness)
ff05bebcc4 doc: rpc: fix case typo in `finalizepsbt` help (final_scriptwitness) (Sebastian Falbesoner)

Pull request description:

  The lower-case spelling matches the `decodepsbt` result field:
  200150beba/src/rpc/rawtransaction.cpp (L871)
  200150beba/src/rpc/rawtransaction.cpp (L1253)

ACKs for top commit:
  l0rinc:
    ACK ff05bebcc4
  rkrux:
    Ah crACK ff05bebcc4

Tree-SHA512: c0a0e29e95fed3fcee4df4f3fc87b32774d76bebadcda5aa010bc45142727536d6a71e4c0e70564db8bdb734e8647c80953793ac9ecd6c434345e972f8d9b7b0
2025-09-28 18:12:44 -04:00
Andrew Toth dda5228e02 test: set par=2 in default config for functional test framework
Depending on the host machine, a default `par` value can spawn up to 15 script verification threads for each node.
Running the functional test suite with default `par` can exhaust file descriptors or hit other resource limits when many threads are spawned.
These threads are mostly idle and the same code paths are executed with a value of `par=2`.
Limit this to 2 for functional tests that do not override the default option.

Co-authored-by: maflcko <6399679+maflcko@users.noreply.github.com>
2025-09-27 16:31:01 -04:00
Sebastian Falbesoner ff05bebcc4 doc: rpc: fix case typo in `finalizepsbt` help (final_scriptwitness) 2025-09-26 19:27:55 +02:00
merge-script 200150beba
Merge bitcoin/bitcoin#33313: test/refactor: use test deque to avoid quadratic iteration
75e6984ec8 test/refactor: use test deque to avoid quadratic iteration (Lőrinc)

Pull request description:

  Extracted from https://github.com/bitcoin/bitcoin/pull/33141#discussion_r2323012972.

  -----

  In Python, [list `pop(0)` is linear](https://docs.python.org/3/tutorial/datastructures.html#using-lists-as-queues), so consuming all items in the test results in quadratic iteration.

  Switching to `collections.deque` with `popleft()` expresses FIFO intent and avoids the O(n^2) path.
  Behavior is unchanged - for a few hundred items the perf impact is likely negligible.

ACKs for top commit:
  maflcko:
    lgtm ACK 75e6984ec8
  theStack:
    re-ACK 75e6984ec8
  enirox001:
    reACK 75e6984
  w0xlt:
    reACK 75e6984ec8

Tree-SHA512: 290f6aeeb33d8b12b7acbbfede7ce0bef1c831a7ab9efc9c3a08c049986572e289cdece0844db908cf198395f574575ce4073c268033bf6dbaadc3828c96c1d8
2025-09-26 11:50:15 -04:00
merge-script 7e08445449
Merge bitcoin/bitcoin#33399: key: use static context for libsecp256k1 calls where applicable
1ff9e92948 key: use static context for libsecp256k1 calls where applicable (Sebastian Falbesoner)

Pull request description:

  The dynamically created [signing context](2d6a0c4649/src/key.cpp (L19)) for libsecp256k1 calls is only needed for functions that involve generator point multiplication with a secret key, i.e. different variants of public key creation and signing. The API docs hint to those by stating "[(not secp256k1_context_static)](b475654302/include/secp256k1.h (L645))" for the context parameter. In our case that applies to the following calls:
  - `secp256k1_ec_pubkey_create`
  - `secp256k1_keypair_create`
  - `secp256k1_ellswift_create`
  - `secp256k1_ecdsa_sign`
  - `secp256k1_ecdsa_sign_recoverable`
  - `secp256k1_schnorrsig_sign32`
  - `ec_seckey_export_der` (not a direct secp256k1 function, but calls `secp256k1_ec_pubkey_create` inside)

  For all the other secp256k1 calls we can simply use the static context. This is done for consistency to other calls that already use `secp256k1_context_static`, and also to reduce dependencies on the global signing context variable. Looked closer at this in the course of reviewing #29675, where some functions used the signing context that didn't need to, avoiding a move to another module (see https://github.com/bitcoin/bitcoin/pull/29675#discussion_r2333831377).

ACKs for top commit:
  Eunovo:
    ACK 1ff9e92948
  furszy:
    ACK 1ff9e92948
  rkrux:
    crACK 1ff9e92948

Tree-SHA512: f091efa56c358057828f3455d4ca9ce40ec0d35f3e38ab147fe3928bb5dbf7ffbc27dbf97b71937828ab95ea4e9be5f96d89a2d29e2aa18df4542aae1b33e258
2025-09-26 11:44:29 -04:00
amisha 7b5261f7ef contrib: fix using macdploy script without translations.
QT translations are optional, but the script would error when
'translations_dir' falls back to its default value NULL.

This PR fixes it by moving the set-up of QT translations under
the check for 'translations_dir' presence.
2025-09-26 10:09:30 +05:30
Ava Chow 65e909dfdd
Merge bitcoin/bitcoin#33430: rpc: addpeeraddress: throw on invalid IP
316a0c5132 rpc: addpeeraddress: throw on invalid IP (John Moffett)

Pull request description:

  Right now we return an opaque `{"success" : false}` in `addpeeraddress` for an empty or invalid IP. This changes it to throw `RPC_CLIENT_INVALID_IP_OR_SUBNET` with the error message `Invalid IP address`. Tests updated to match.

ACKs for top commit:
  sipa:
    utACK 316a0c5132
  achow101:
    ACK 316a0c5132
  vasild:
    ACK 316a0c5132
  pablomartin4btc:
    tACK 316a0c5132

Tree-SHA512: 79a8ce127d0a24b2eb1f31bc3294b895d0c6424032a6b49168259e0e94aff69723d067adf1b4dc3c9b79e597531e5b65e4b8fc5a8e21fba0b81f99168de12b96
2025-09-25 15:42:12 -07:00
Ava Chow 31b29f8eb6
Merge bitcoin/bitcoin#33229: multiprocess: Don't require bitcoin -m argument when IPC options are used
453b0fa286 bitcoin: Make wrapper not require -m (Ryan Ofsky)
29e836fae6 test: add tool_bitcoin to test bitcoin wrapper behavior (Ryan Ofsky)
0972f55040 init: add exe name to bitcoind, bitcoin-node -version output to be able to distinguish these in tests (Ryan Ofsky)

Pull request description:

  This change makes the `bitcoin` command respect IPC command line options and _bitcoin.conf_ settings, so IPC listening can be enabled by just running `bitcoin node -ipcbind=unix` or `bitcoin node` with `ipcbind=unix` in the configuration file, and there is no longer a need to specify a multiprocess `-m` option like `bitcoin -m node [...]`

  sipa and theuni in #31802 pointed out that users shouldn't be exposed to multiprocess implementation details just to use IPC features, so current need to specify the `bitcoin -m` option in conjunction with `-ipcbind` could be seen as a design mistake and not just a usage inconvenience.

  This PR also adds a dedicated functional test for the `bitcoin` wrapper command and to make sure it calls the right binaries and test the new functionality.

  ---

  This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/issues/28722).

ACKs for top commit:
  Sjors:
    re-ACK 453b0fa286
  achow101:
    ACK 453b0fa286
  TheCharlatan:
    Re-ACK 453b0fa286

Tree-SHA512: 9e49cb7e183fd220fa7a4e8ac68cef55f3cb2ccec40ad2a9d3e3f31db64c4953db8337f8caf7fce877bc97002ae97568dcf47ee269a06ca1f503f119bfe392c1
2025-09-25 14:36:40 -07:00
merge-script e62e0a12b3
Merge bitcoin/bitcoin#33230: cli: Handle arguments that can be either JSON or string
df67bb6fd8 test: Remove convert_to_json_for_cli (Ava Chow)
44a493e150 cli: Allow arguments to be both strings and json (Ava Chow)

Pull request description:

  There are some RPCs where the argument can be either JSON that needs to be parsed, or a string that we can pass straight through. However, `bitcoin-cli` would always parse those arguments as JSON which makes for some cumbersome argument passing when using those RPCs. Notably, `hash_or_height` in `getblockstats` and `gettxoutsetinfo` do this, and results in a more cumbersome command of `bitcoin-cli getblockstats '"<hash>"'`. Otherwise, using a normal invocation of `bitcoin-cli getblockstats <hash>` results in `error: Error parsing JSON`. This PR marks those particular options as also being a string so that when `bitcoin-cli` fails to parse the argument as JSON, it will assume that the argument is a string and pass it straight through.

ACKs for top commit:
  ryanofsky:
    Code review ACK df67bb6fd8, just rebased since last review. I do still think it would be good to improve the test (https://github.com/bitcoin/bitcoin/pull/33230#discussion_r2369570345)
  rkrux:
    Light code review, lgtm ACK df67bb6fd8
  mzumsande:
    Code Review ACK df67bb6fd8

Tree-SHA512: 6c488570fbb24d0cf10508416c56accfc7af5163b7a7187d22d78c812424a9e3ecc95906d3e295fbf6af54bf80903aa448fd879dd6a9944ba8b4d1a33eb29ef2
2025-09-25 15:50:56 -04:00
Max Edwards 7ae0497eef ci: remove 3rd party js from windows dll gha job
We can use vswhere.exe directly to create a vs developer
prompt and so can remove this third party dependency.

Co-authored-by: David Gumberg <davidzgumberg@gmail.com>
2025-09-25 18:12:02 +01:00
merge-script 05d984b1a4
Merge bitcoin/bitcoin#33475: bugfix: miner: fix `addPackageTxs` unsigned integer overflow
b807dfcdc5 miner: fix `addPackageTxs` unsigned integer overflow (ismaelsadeeq)

Pull request description:

  This PR fixes an unsigned integer overflow in the `addPackageTxs` method of the `BlockAssembler`.

  The overflow is a rare edge case that might occur on master when a miner reserves 2000 WU and wants to create an block to be empty.

  i.e, by starting with `-blockmaxweight=2000`, `-blockreservedweight=2000`, or just `blockmaxweight=2000`, and then calling the mining interface `createNewBlock` with `blockReservedWeight` set to `2000`.

  Instead of bailing out after going through transactions equivalent to `MAX_CONSECUTIVE_FAILURES`, the loop never breaks until all mempool transactions are visited.

  See https://github.com/bitcoin/bitcoin/pull/33421#issuecomment-3324859282

  The fix avoids the overflow by using addition instead adding `BLOCK_FULL_ENOUGH_WEIGHT_DELTA` to the block weight and comparing it with `m_options.nBlockMaxWeight`.

  Another alternative that preserves the same structure is to use `static_cast`. See c9530cf35d.

  This fix can be tested by cherry-picking the commits from #33421 without the static cast fix and running:

  ```bash
  echo "AQAAAAAAA
  AAnJycnAAAAAAAAAAAAAAAAAA" | base64 --decode > miner.crash

  FUZZ=block_template_cache ./build_fuzz/bin/fuzz miner.crash
  ```

  ---

  This is part of a larger inconsistency in how size/weight is represented in the codebase. It may be worth defining a dedicated type for size/weight.

ACKs for top commit:
  glozow:
    nice, utACK b807dfcdc5
  furszy:
    Code ACK b807dfcdc5

Tree-SHA512: c1d2f7e500f9b0624a4c22a146921a1644017065e6c94d0c5027486392321f5de26c61751a24765e025e45b34c535adfd6d0e2ac809dea6846b99f37d13043c9
2025-09-25 08:18:20 -04:00
ismaelsadeeq b807dfcdc5
miner: fix `addPackageTxs` unsigned integer overflow 2025-09-24 17:10:51 +02:00
merge-script d41b503ae1
Merge bitcoin/bitcoin#33446: rpc: fix getblock(header) returns target for tip
bf7996cbc3 rpc: fix getblock(header) returns target for tip (Sjors Provoost)
4c3c1f42cf test: add block 2016 to mock mainnet (Sjors Provoost)

Pull request description:

  A `target` field was added to the `getblock` and `getblockheader` RPC calls in #31583, but it mistakingly always used the tip value.

  This PR fixes it to return the target for the given block. Because regtest does not have difficulty adjustment, the mainnet test is expanded to cover the fix.

  A preliminary commit deals with mining block 2016 that's needed for the test. It also:
  - renames the `create_coinbase` `retarget_period` argument to `halving_period`. Before #31583 this was hardcoded for regtest where these values are the same.
  - drops unused `fees` argument from `mine` helper
  - expands the CPU miner instructions for generating the alternative mainnet chain

  Fixes #33440

ACKs for top commit:
  sipa:
    utACK bf7996cbc3
  luke-jr:
    crACK bf7996cbc3
  TheCharlatan:
    ACK bf7996cbc3
  ismaelsadeeq:
    Code review ACK bf7996cbc3

Tree-SHA512: 2a2e11efd91f4aaccf9d2ec4dff9fd82c366b8a7e797ce5981dca2e6f08028f69154f4e6a27aef20d78b0e6c3304416789267c2fad42d7aa5072f8537d0c8b0d
2025-09-24 10:08:10 -04:00
merge-script 5ae8edbc30
Merge bitcoin/bitcoin#33158: macdeploy: avoid use of `Bitcoin Core` in Linux cross build
8e434a8499 macdeploy: rename macOS output to bitcoin-macos-app.zip (fanquake)
05353d9cf0 macdeploy: combine appname & -zip arguments (fanquake)

Pull request description:

  Output `bitcoin-macos-app.zip`, similar to what we do for Windows: `bitcoin-win64-setup.exe`.

ACKs for top commit:
  hodlinator:
    re-ACK 8e434a8499
  willcl-ark:
    ACK 8e434a8499

Tree-SHA512: e762c9866630c4f8c577027ee9492d74a5c7f4b194df73876d702703b9100c356a30986c2f209ba3f3e2d483017f5e61596a2a7cdfae0a684f8dc244420cd108
2025-09-24 09:59:45 -04:00
Ava Chow df67bb6fd8 test: Remove convert_to_json_for_cli 2025-09-23 12:58:00 -07:00
Ava Chow 44a493e150 cli: Allow arguments to be both strings and json 2025-09-23 12:57:34 -07:00
merge-script ad4a49090d
Merge bitcoin/bitcoin#33408: msvc: Update vcpkg manifest
ef20c2d11d build, msvc: Update vcpkg manifest baseline (Hennadii Stepanov)

Pull request description:

  This PR updates the vcpkg manifest baseline from the ["2025.03.19 Release"](https://github.com/microsoft/vcpkg/releases/tag/2025.03.19) to the ["2025.08.27 Release"](https://github.com/microsoft/vcpkg/releases/tag/2025.08.27), with the following package
  changes:
   - `boost`: 1.87.0 --> 1.88.0
   - `qtbase`: 6.8.2#1 -> 6.9.1
   - `qttools`: 6.8.2 -> 6.9.1
   - `sqlite3`: 3.49.1 --> 3.50.4

  The previous update was made in https://github.com/bitcoin/bitcoin/pull/32213.

ACKs for top commit:
  hodlinator:
    ACK ef20c2d11d

Tree-SHA512: 3c95fea911e1481b3536958d83dcaa52012abdff350cd08c21b30b3df61a501b2f3272e879882820bb59456066e9270de820bcb47810d3d1b8e8a1267d987d90
2025-09-23 15:54:39 -04:00
merge-script dd61f08fd5
Merge bitcoin/bitcoin#33031: wallet: Set descriptor cache upgraded flag for migrated wallets
88b0647f02 wallet: Always write last hardened cache flag in migrated wallets (Ava Chow)
8a08eef645 tests: Check that the last hardened cache upgrade occurs (Ava Chow)

Pull request description:

  #32597 set the descriptor cache upgraded flag for newly created wallets, but migrated wallets still did not have the flag set when they are migrated. For consistency, and to avoid an unnecessary upgrade, we should be setting this flag for migrated wallets.

  The flag would end up being set anyways at the end of migration when the wallet is reloaded as it would perform the automatic upgrade at that time. However, this is unnecessary and we should just set it from the get go.

  This PR also adds a couple tests to verify that the flag is being set, and that the upgrade is being performed.

ACKs for top commit:
  cedwies:
    re-ACK 88b0647
  rkrux:
    lgtm ACK 88b0647f02
  pablomartin4btc:
    ACK 88b0647f02

Tree-SHA512: 7d0850db0ae38eedd1e6a3bfaa548c6c612182291059fb1a47279a4c4984ee7914ecd02d8c7e427ef67bf9f5e67cbc57a7ae4412fad539e1bf3e05c512a60d69
2025-09-23 15:27:17 -04:00
merge-script 350692e561
Merge bitcoin/bitcoin#33388: test: don't throw from the destructor of DebugLogHelper
2427939935 test: forbid copying of DebugLogHelper (Daniel Pfeifer)
d6aa266d43 test: don't throw from the destructor of DebugLogHelper (Vasil Dimov)

Pull request description:

  Throwing an exception from the destructor of a class is a bad practice because the destructor will be called when an object of that type is alive on the stack and another exception is thrown, which will result in "exception during the exception". This would terminate the program without any messages.

  Instead print the message to the standard error output and call `std::abort()`.

  ---

  This change is part of https://github.com/bitcoin/bitcoin/pull/26812. It is an improvement on its own, so creating a separate PR for it following the discussion at https://github.com/bitcoin/bitcoin/pull/32604#discussion_r2345091587. Getting it in will reduce the size of #26812.

ACKs for top commit:
  Crypt-iQ:
    crACK 2427939
  l0rinc:
    Code review reACK 2427939935
  optout21:
    crACK 2427939935
  furszy:
    utACK 2427939935

Tree-SHA512: 918c1e40d2db4ded6213cd78a18490ad10a9f43c0533df64bdf09f0b216715415030e444712981e4407c32ebf552fbb0e3cce718e048df10c2b8937caf015564
2025-09-23 15:01:52 -04:00
Martin Zumsande 94db966a3b net: use generic network key for addrcache
The generic key can also be used in other places
where behavior between different network identities should
be uncorrelated to avoid fingerprinting.
This also changes RANDOMIZER_ID - since it is not
being persisted to disk, there are no compatibility issues.
2025-09-23 10:56:44 -04:00
fanquake eca50854e1
depends: static libxcb_cursor
Modern Ubuntu isn't shipping with this library installed by default.
Staticly link it to remove the need for end-users to install it.

Closes #33432.
2025-09-23 10:43:55 -04:00
merge-script 89144eb473
Merge bitcoin/bitcoin#33448: net/rpc: Report inv information for debugging
2738b63e02 test: validate behaviour of getpeerinfo last_inv_sequence and inv_to_send (Anthony Towns)
77b2ebb811 rpc/net: report per-peer last_inv_sequence (Anthony Towns)
adefb51c54 rpc/net: add per-peer inv_to_send sizes (Anthony Towns)

Pull request description:

  Adds per-peer entries to `getpeerinfo` for the size of the inv_to_send queue and the mempool sequence number as at the last INV. Can be helpful for debugging tx relay performance and privacy/fingerprinting issues.

ACKs for top commit:
  sipa:
    utACK 2738b63e02
  instagibbs:
    ACK 2738b63e02

Tree-SHA512: e3c9c52e8e38b099d405a177ffba6783c5821cc5ce1432b98218843e00906986ce2141dcd5b04a67006c328211a672e519fa3390e012688499bfc9ac99767599
2025-09-23 10:29:23 -04:00
merge-script eaa1a3cd0b
Merge bitcoin/bitcoin#33425: ci: remove Clang build from msan fuzz job
b77137a564 ci: link against -lstdc++ in native fuzz with msan job (fanquake)

Pull request description:

  Remove the Clang build from msan fuzz by using the apt install LLVM / Clang, and just linking against `-lstdc++`.

ACKs for top commit:
  maflcko:
    lgtm ACK b77137a564

Tree-SHA512: dc32b22a93196120a343d91265db3f42f6dc00afc887929986987ea62f2513580c855e98d088f037adb4c2e62358f98e47b914a412ef9c1069037917a36c0b03
2025-09-23 10:09:57 -04:00
fanquake b77137a564
ci: link against -lstdc++ in native fuzz with msan job 2025-09-23 09:53:58 -04:00
merge-script a86e1a6e32
Merge bitcoin/bitcoin#33427: rpc: Always return per-wtxid entries in submitpackage tx-results
cad9a7fd73 rpc: Always return per-wtxid entries in submitpackage tx-results (John Moffett)

Pull request description:

  Follow-up to #28848

  When `submitpackage` produced no per-transaction result for a member, the RPC set `"error": "unevaluated"` but then continued without inserting the entry into `tx-results`, making it impossible for callers to know which `wtxids` were unevaluated.

  This inserts the error result before continuing, updates help text, and adjusts functional tests to expect entries for all submitted `wtxids`.

ACKs for top commit:
  instagibbs:
    ACK cad9a7fd73
  glozow:
    ACK cad9a7fd73

Tree-SHA512: 8df5c9b3d1f17aaf0311c38f028ae4b55d4c52a660f85171f105c4f65d130b14ab00698ac5d7c27403a0c37fff391c154c3ad44cc99ba4d549d9c30751b8360f
2025-09-23 09:36:18 -04:00
merge-script 6861dadfcb
Merge bitcoin/bitcoin#33459: doc: remove unrelated `bitcoin-wallet` binary from `libbitcoin_ipc` description
fbde8d9a81 doc: remove unrelated `bitcoin-wallet` binary from `libbitcoin_ipc` description (Sebastian Falbesoner)

Pull request description:

  `bitcoin-wallet` as-is is merely an offline wallet inspection tool (introduced more than 9 years ago in PR #13926) that doesn't have any relation with IPC/multiprocess, so remove it from the list of binaries that use `libbitcoin_ipc`.

ACKs for top commit:
  pablomartin4btc:
    ACK fbde8d9a81

Tree-SHA512: e11720d35596575cd9785b9b00e6b11e46ba4c8aad6fe98e952d4aa4310f9e5c719dd2f177da8b5c3abefc831cbace0e1a0620f428d847f9bdcf7252a8889641
2025-09-23 09:11:15 -04:00
merge-script 3b3ab3a50a
Merge bitcoin/bitcoin#33302: ci: disable cirrus cache in 32bit arm job
00c253d494 ci: disable cirrus cache in 32bit arm job (will)
ff18b6bbaf ci: refactor docker action to return provider str (will)

Pull request description:

  Add an optional matrix field allowing opt-out of configuring cirrus GHA cache when not using cirrus runners.

  This is not needed for the cirruslabs/[save|restore]-cache actions, as they automatically fallback based on runner type.

  Addresses https://github.com/bitcoin/bitcoin/issues/31965#issuecomment-3252638785

ACKs for top commit:
  m3dwards:
    ACK 00c253d494

Tree-SHA512: 4c79deec2b0018f62a982b2d1051c78e94e242a1b8faf5db037353b05b707827dafded56c9b5ffbc861fcadac5a90571077e6ab69410975f7a2f40c755630a8e
2025-09-23 09:05:50 -04:00
Anthony Towns 2738b63e02 test: validate behaviour of getpeerinfo last_inv_sequence and inv_to_send
Co-Authored-By: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
2025-09-23 14:58:01 +10:00
Sebastian Falbesoner fbde8d9a81 doc: remove unrelated `bitcoin-wallet` binary from `libbitcoin_ipc` description
`bitcoin-wallet` as-is is merely an offline wallet inspection tool
(introduced more than 9 years ago in PR #13926) that doesn't have any
relation with IPC/multiprocess, so remove it from the list of binaries
that use `libbitcoin_ipc`.
2025-09-22 21:07:41 +02:00
Hennadii Stepanov 34fefb6335
Merge bitcoin/bitcoin#33435: system: improve handling around GetTotalRAM()
56791b5829 test: split out `system_ram_tests` to signal when total ram cannot be determined (Lőrinc)
337a6e7386 system: improve handling around GetTotalRAM() (Vasil Dimov)

Pull request description:

  1. Fix unused variable warning (https://github.com/bitcoin/bitcoin/pull/33333#discussion_r2362493046)
  2. Enable `GetTotalRAM()` on other platforms where it was tested to work.
  3. Skip the `GetTotalRAM()` unit test on unsupported platforms.

  Prior discussion: https://github.com/bitcoin/bitcoin/pull/33333#discussion_r2362493046

ACKs for top commit:
  l0rinc:
    ACK 56791b5829
  hebasto:
    ACK 56791b5829.

Tree-SHA512: bc419aa55edad77473dbcf810f02d02fa0c45a6355a93d17f7881051117b753c584296ab3840893270ecdc9bb2bee0fe4e070607c6560b794e97a25da733c47d
2025-09-22 17:00:50 +01:00
Lőrinc 56791b5829
test: split out `system_ram_tests` to signal when total ram cannot be determined
when `GetTotalRAM` returns an `std::nullopt` now we're getting:
```
The following tests did not run:
        106 - system_ram_tests (Skipped)
```
2025-09-22 12:25:45 +02:00
Vasil Dimov 337a6e7386
system: improve handling around GetTotalRAM()
This patch achieves two things:
1. Fix unused variable warning (https://github.com/bitcoin/bitcoin/pull/33333#discussion_r2362493046)
2. Enable GetTotalRAM() on other platforms where it was tested to work.

Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2025-09-22 12:24:49 +02:00
Anthony Towns 451ba9ada4
datacarrier: Undeprecate configuration option
Reverts commit 0b4048c733
2025-09-22 02:47:02 -05:00
Anthony Towns 77b2ebb811 rpc/net: report per-peer last_inv_sequence 2025-09-22 10:46:26 +10:00
Sjors Provoost bf7996cbc3
rpc: fix getblock(header) returns target for tip
A target field was added to the getblock and getblockheader RPC calls in bitcoin#31583, but it mistakingly always used the tip value.

Because regtest does not have difficulty adjustment, a test is added for mainnet instead.
2025-09-20 21:36:39 +02:00
Sjors Provoost 4c3c1f42cf
test: add block 2016 to mock mainnet
The next commit requires an additional mainnet block which changes the difficulty.

Also fix a few minor mistakes in the test (suite):
- rename the create_coinbase retarger_period argument to halving_period. Before bitcoin#31583 this was hardcoded for regtest where these values are the same.
- drop unused fees argument from mine helper

Finally the CPU miner instructions for generating the alternative mainnet chain are expanded.
2025-09-20 21:36:39 +02:00
merge-script 953544d028
Merge bitcoin/bitcoin#33429: fuzz: reduce iterations in slow targets
6a33970fef fuzz: Reduce iterations in slow targets (marcofleon)

Pull request description:

  The `mini_miner`, `txdownloadman`, `txdownloadman_impl`, and `tx_pool_standard` fuzz targets are all slow-running targets. Fix this by reducing the iteration count in the `LIMITED_WHILE` loops.

  This should help decrease the run time of the fuzz CI jobs. See https://github.com/bitcoin/bitcoin/pull/33425.

  Addresses https://github.com/bitcoin/bitcoin/issues/32870 as well.

ACKs for top commit:
  Crypt-iQ:
    crACK 6a33970fef
  dergoegge:
    utACK 6a33970fef
  enirox001:
    Concept ACK 6a33970
  brunoerg:
    ACK 6a33970fef

Tree-SHA512: d03d687507f497e587f7199866266298ca67d9843985dc96d1c957a6fbffb3c6cd5144a4876c471b84c84318295b0438908c745f3a4ac0254dca3e72655ecc14
2025-09-20 14:53:31 +01:00
Hennadii Stepanov df101c97c2
Merge bitcoin/bitcoin#33422: build: Remove lingering Windows registry & shortcuts (#32132 follow-up)
79752b9c0b build(windows): Remove lingering registry entries and shortcuts upon install (Hodlinator)

Pull request description:

  ### Problem

  Prior to fb2b05b125 / #32132 we installed using paths with an extra " (64-bit)"-suffix. Installing a version including that commit on top of a version that does not results in 2 entries in the "Installed apps" list. Both of them end up running the same `C:\Program Files\Bitcoin\uninstall.exe`. However, only one of the entries is removed by the uninstaller. The left over registry entry will now point to an executable that no longer exists and fail to work.

  Removing the left over "Installed apps"  entry on master currently requires the user to manually remove the Windows Registry entries (or run the correct old/new installer to ensure the uninstaller exists again).

  ### Solution

  This PR automates removal of old entries (& shortcuts) when installing the new version.

  ### Disclaimer

  Not an NSIS expert - confirmed that added deletion commands work without causing any visible errors both when prior items exist and when they don't.

ACKs for top commit:
  achow101:
    ACK 79752b9c0b
  hebasto:
    ACK 79752b9c0b.

Tree-SHA512: d23bd2e8f035ca93c3bd6187b3e5545c89c541b51d7b2b91b79bae1ebe328cd08c38b57e75a39bb376771fc85a537fe1d628903b9eadd32d04c3eb976c2e6d87
2025-09-19 22:49:43 +01:00
merge-script 56c6daa64f
Merge bitcoin/bitcoin#28592: p2p: Increase tx relay rate
b81f37031c p2p: Increase tx relay rate (Anthony Towns)

Pull request description:

  In the presence of smaller transactions on the network, blocks can sustain a higher relay rate than 7tx/second. In this event, the per-peer inventory queues can grow too large.

  This commit bumps the rate up to 14 tx/s (for inbound peers), increasing the safety margin by a factor of 2.

  Outbound peers continue to receive relayed transactions at 2.5x the rate of inbound peers, for a rate of 35tx/second.

ACKs for top commit:
  sipa:
    ACK b81f37031c
  achow101:
    ACK b81f37031c
  darosior:
    utACK b81f37031c.
  glozow:
    utACK b81f37031c

Tree-SHA512: 854ea0824d5f4c629f1dceb9ee61cc9226c8f0d4d26664737e68db917f65341d4800362ab55ed32673db920b2b59aa116b4cb9ee063367b2e43c94a904b41c08
2025-09-19 17:53:45 +01:00
Hodlinator 79752b9c0b
build(windows): Remove lingering registry entries and shortcuts upon install
Prior releases installed using these paths. Especially annoying was that the lingering registry entry for the uninstaller would show up as "Bitcoin Core (64-bit)" besides the current "Bitcoin Core" entry in the list of installed programs, and whichever was uninstalled last would fail to work as they would default to the same install directory.
2025-09-19 16:40:58 +02:00
John Moffett cad9a7fd73 rpc: Always return per-wtxid entries in submitpackage tx-results
When submitpackage produced no per-transaction result for a member,
the RPC previously set "error": "unevaluated" but then continued
without inserting the entry into tx-results, making it impossible for
callers to know which wtxids were unevaluated.

Insert the placeholder result before continuing, update help text, and
adjust functional tests to expect entries for all submitted wtxids.
2025-09-19 10:29:00 -04:00
marcofleon 6a33970fef fuzz: Reduce iterations in slow targets 2025-09-19 15:13:15 +01:00
merge-script edb871cba2
Merge bitcoin/bitcoin#33412: Update libmultiprocess subtree to fix intermittent mptest hang
535fa0ad0d Squashed 'src/ipc/libmultiprocess/' changes from 13424cf2ecc1..47d79db8a552 (Ryan Ofsky)

Pull request description:

  Includes:

  - https://github.com/bitcoin-core/libmultiprocess/pull/207
  - https://github.com/bitcoin-core/libmultiprocess/pull/208
  - https://github.com/bitcoin-core/libmultiprocess/pull/211
  - https://github.com/bitcoin-core/libmultiprocess/pull/201

  The last change fixes the test hang reported https://github.com/bitcoin/bitcoin/issues/33244

  The changes can be verified by running `test/lint/git-subtree-check.sh src/ipc/libmultiprocess` as described in [developer notes](https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#subtrees) and [lint instructions](https://github.com/bitcoin/bitcoin/tree/master/test/lint#git-subtree-checksh)

ACKs for top commit:
  Sjors:
    ACK c49a43591f
  TheCharlatan:
    ACK c49a43591f

Tree-SHA512: e87e92caee20693d969308a9250804ffdea4d6fb84a23a2399c3ee43419e6dceb46a224e2410d35a5690dea14b5af9e94017a8f2ca733fa27781154ef8377e6d
2025-09-19 10:54:01 +01:00
Daniel Pfeifer 2427939935
test: forbid copying of DebugLogHelper 2025-09-19 11:27:44 +02:00
Vasil Dimov d6aa266d43
test: don't throw from the destructor of DebugLogHelper
Throwing an exception from the destructor of a class is a bad practice,
avoid that and instead print the message to the standard error output
and call `std::abort()`.
2025-09-19 11:27:40 +02:00
Ava Chow eaf2c46475
Merge bitcoin/bitcoin#33378: Remove unnecessary casts when calling socket operations
67f632b6de net: remove unnecessary casts in socket operations (Matthew Zipkin)

Pull request description:

  During review of https://github.com/bitcoin/bitcoin/pull/32747 several casting operations were questioned in existing code that had been copied or moved. That lead me to find a few other similar casts in the codebase.

  It turns out that since the `Sock` class wraps syscalls with its own internal casting (see https://github.com/bitcoin/bitcoin/pull/24357 and https://github.com/bitcoin/bitcoin/pull/20788 written in 2020-2022) we no longer need to cast the arguments when calling these functions. The original argument-casts are old and were cleaned up a bit in https://github.com/bitcoin/bitcoin/pull/12855 written in 2018.

  The casting is only needed for windows compatibility, where those syscalls require a data argument to be of type `char*` specifically:

  https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-getsockopt

  ```
  int getsockopt(
    [in]      SOCKET s,
    [in]      int    level,
    [in]      int    optname,
    [out]     char   *optval,
    [in, out] int    *optlen
  );
  ```

  but on POSIX the argument is `void*`:

  https://www.man7.org/linux/man-pages/man2/getsockopt.2.html

  ```
         int getsockopt(socklen *restrict optlen;
                        int sockfd, int level, int optname,
                        void optval[_Nullable restrict *optlen],
                        socklen_t *restrict optlen);
  ```

ACKs for top commit:
  Raimo33:
    ACK 67f632b6de
  achow101:
    ACK 67f632b6de
  hodlinator:
    ACK 67f632b6de
  vasild:
    ACK 67f632b6de
  davidgumberg:
    ACK 67f632b6de

Tree-SHA512: c326d7242698b8d4d019f630fb6281398da2773c4e5aad1e3bba093a012c2119ad8815f42bd009e61a9a90db9b8e6ed5c75174aac059c9df83dd3aa5618a9ba6
2025-09-18 13:53:51 -07:00
Ava Chow 5aec516b2c
Merge bitcoin/bitcoin#33333: coins: warn on oversized `-dbcache`
168360f4ae coins: warn on oversized -dbcache (Lőrinc)
6c720459be system: add helper for fetching total system memory (Lőrinc)

Pull request description:

  ### Summary

  Oversized allocations can cause out-of-memory errors or [heavy swapping](https://github.com/getumbrel/umbrel-os/issues/64#issuecomment-663637321), [grinding the system to a halt](https://x.com/murchandamus/status/1964432335849607224).

  ### Fix

  Added a minimal system helper to query total physical RAM on [Linux/macOS/Windows](https://stackoverflow.com/a/2513561) (on unsupported platforms we just disable this warning completely).
  The added test checks if the value is roughly correct by checking if the CI platforms are returning any value and if the value is at least 1 GB (as a simple property test checking if the unit size is correct, e.g. doesn't return megabytes or bits).

  ### Details

  `LogOversizedDbCache()` now emits a startup warning if the configured `-dbcache` exceeds a cap derived from system RAM, using the same parsing/clamping as cache sizing via `CalculateDbCacheBytes()`. This isn't meant as a recommended setting, rather a likely upper limit.

  Note that we're not modifying the set value, just issuing a warning.
  Also note that the 75% calculation is rounded for the last two numbers since we have to divide first before multiplying, otherwise we wouldn't stay inside `size_t` on 32-bit systems - and this was simpler than casting back and forth.

  We could have chosen the remaining free memory for the warning (e.g. warn if free memory is less than 1 GiB), but this is just a heuristic, we assumed that on systems with a lot of memory, other processes are also running, while memory constrained ones run only Core.

  ### Cap

  If total RAM < 2 GiB, cap is `DEFAULT_DB_CACHE` (`450 MiB`), otherwise it's 75% of total RAM.
  The threshold is chosen to be close to values commonly used in [raspiblitz](https://github.com/raspiblitz/raspiblitz/blob/dev/home.admin/_provision.setup.sh#L98-L115) for common setups:

  | Total RAM | `dbcache` (MiB) | raspiblitz % | proposed cap (MiB) |
  |----------:|----------------:|-------------:|-------------------:|
  |     1 GiB |             512 |        50.0% |               450* |
  |     2 GiB |            1536 |        75.0% |               1536 |
  |     4 GiB |            2560 |        62.5% |               3072 |
  |     8 GiB |            4096 |        50.0% |               6144 |
  |    16 GiB |            4096 |        25.0% |              12288 |
  |    32 GiB |            4096 |        12.5% |              24576 |

  [Umbrel issues](https://github.com/getumbrel/umbrel-os/issues/64#issuecomment-663816367) also mention 75% being the upper limit.

  ### Reproducer

  Starting `bitcoind` on an 8 GiB rpi4b with a dbcache of 7 GiB:
  > ./build/bin/bitcoind -dbcache=7000

  warns now as follows:
  ```
  2025-09-07T17:24:29Z [warning] A 7000 MiB dbcache may be too large for a system memory of only 7800 MiB.
  Warning: A 7000 MiB dbcache may be too large for a system memory of only 7800 MiB.
  2025-09-07T17:24:29Z Cache configuration:
  2025-09-07T17:24:29Z * Using 2.0 MiB for block index database
  2025-09-07T17:24:29Z * Using 8.0 MiB for chain state database
  2025-09-07T17:24:29Z * Using 6990.0 MiB for in-memory UTXO set (plus up to 286.1 MiB of unused mempool space)
  ```

  ### Manual testing

  Besides the [godbolt](https://godbolt.org/z/ec81Tjvrj) reproducers for the new total memory method, we also tested the warnings manually on:
  - [x] Apple M4 Max, macOS 15.6.1
  - [x] Intel Core i9-9900K, Ubuntu 24.04.2 LTS
  - [x] Raspberry Pi 4 Model B, Armbian Linux 6.12.22-current-bcm2711
  - [x] Intel Xeon x64, Windows 11 Home Version 24H2, OS Build 26100.4351

ACKs for top commit:
  achow101:
    ACK 168360f4ae
  w0xlt:
    reACK 168360f4ae
  hodlinator:
    re-ACK 168360f4ae
  danielabrozzoni:
    reACK 168360f4ae

Tree-SHA512: aa0c9b1034d55a6a4212685a19715d8cd89668ab7c33c688711a15559e6ad81aa65f3cd8b488c91385306e1e16cd9eeefa8f659ba90ef19ce9c7a2e64f8b561a
2025-09-18 11:42:02 -07:00
John Moffett 316a0c5132 rpc: addpeeraddress: throw on invalid IP
Throw RPC_CLIENT_INVALID_IP_OR_SUBNET when LookupHost(addr, false) fails
in addpeeraddress. This aligns with setban/addconnection and avoids the
opaque {"success": false} result for input errors. The JSON {success,
error?} object remains for addrman outcomes only. Update test to match.
2025-09-18 14:29:50 -04:00
merge-script 74fa028da1
Merge bitcoin/bitcoin#33420: test: Avoid interface_ipc.py Duplicate ID errors
e9c52272eb test: Avoid interface_ipc.py Duplicate ID errors (Ryan Ofsky)

Pull request description:

  This change should fix issue https://github.com/bitcoin/bitcoin/issues/33417 reported by zaidmstrr. It's possible to reproduce the `mp/proxy.capnp:0: failed: Duplicate ID @0xcc316e3f71a040fb` error by installing libmultiprocess system-wide, or to one of the locations listed in the python test's `imports` list before the local libmultiprocess subtree, and then running the test.

ACKs for top commit:
  zaidmstrr:
    Tested ACK [e9c5227](e9c52272eb)

Tree-SHA512: 5df7fe767989b91245ce96f7c43b6767b7af49ec6c7007175e462341ffd69e161f21632697804060ce286b3e102a8d141a57a53f7e0e32299ef9a3a69ca8794a
2025-09-18 11:34:44 +01:00
Lőrinc 168360f4ae coins: warn on oversized -dbcache
Oversized allocations can cause out-of-memory errors or [heavy swapping](https://github.com/getumbrel/umbrel-os/issues/64#issuecomment-663637321), [grinding the system to a halt](https://x.com/murchandamus/status/1964432335849607224).

`LogOversizedDbCache()` now emits a startup warning if the configured `-dbcache` exceeds a cap derived from system RAM, using the same parsing/clamping as cache sizing via CalculateDbCacheBytes(). This isn't meant as a recommended setting, rather a likely upper limit.

Note that we're not modifying the set value, just issuing a warning.
Also note that the 75% calculation is rounded for the last two numbers since we have to divide first before multiplying, otherwise we wouldn't stay inside size_t on 32-bit systems - and this was simpler than casting back and forth.

We could have chosen the remaining free memory for the warning (e.g. warn if free memory is less than 1 GiB), but this is just a heuristic, we assumed that on systems with a lot of memory, other processes are also running, while memory constrained ones run only Core.

If total RAM < 2 GiB, cap is `DEFAULT_DB_CACHE` (`450 MiB`), otherwise it's 75% of total RAM.
The threshold is chosen to be close to values commonly used in [raspiblitz](https://github.com/raspiblitz/raspiblitz/blob/dev/home.admin/_provision.setup.sh#L98-L115) for common setups:

| Total RAM | `dbcache` (MiB) | raspiblitz % | proposed cap (MiB) |
|----------:|----------------:|-------------:|-------------------:|
|     1 GiB |             512 |        50.0% |               450* |
|     2 GiB |            1536 |        75.0% |               1536 |
|     4 GiB |            2560 |        62.5% |               3072 |
|     8 GiB |            4096 |        50.0% |               6144 |
|    16 GiB |            4096 |        25.0% |              12288 |
|    32 GiB |            4096 |        12.5% |              24576 |

[Umbrel issues](https://github.com/getumbrel/umbrel-os/issues/64#issuecomment-663816367) also mention 75% being the upper limit.

Starting `bitcoind` on an 8 GiB rpi4b with a dbcache of 7 GiB:
> ./build/bin/bitcoind -dbcache=7000

warns now as follows:
```
2025-09-07T17:24:29Z [warning] A 7000 MiB dbcache may be too large for a system memory of only 7800 MiB.
2025-09-07T17:24:29Z Cache configuration:
2025-09-07T17:24:29Z * Using 2.0 MiB for block index database
2025-09-07T17:24:29Z * Using 8.0 MiB for chain state database
2025-09-07T17:24:29Z * Using 6990.0 MiB for in-memory UTXO set (plus up to 286.1 MiB of unused mempool space)
```

Besides the [godbolt](https://godbolt.org/z/EPsaE3xTj) reproducers for the new total memory method, we also tested the warnings manually on:
- [x] Apple M4 Max, macOS 15.6.1
- [x] Intel Core i9-9900K, Ubuntu 24.04.2 LTS
- [x] Raspberry Pi 4 Model B, Armbian Linux 6.12.22-current-bcm2711
- [x] Intel Xeon x64, Windows 11 Home Version 24H2, OS Build 26100.4351

Co-authored-by: stickies-v <stickies-v@protonmail.com>
Co-authored-by: Hodlinator <172445034+hodlinator@users.noreply.github.com>
Co-authored-by: w0xlt <woltx@protonmail.com>
2025-09-17 11:36:21 -07:00
Lőrinc 6c720459be system: add helper for fetching total system memory
Added a minimal system helper to query total physical RAM on [Linux/macOS/Windows](https://stackoverflow.com/a/2513561) (on other platforms we just return an empty optional).

The added test checks if the value is roughly correct by checking if the CI platforms are returning any value and if the value is at least 1 GiB and not more than 10 TiB.

The max value is only validated on 64 bits, since it's not unreasonable for 32 bits to have max memory, but on 64 bits it's likely an error.

https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/ns-sysinfoapi-memorystatusex
> ullTotalPhys The amount of actual physical memory, in bytes.

https://man7.org/linux/man-pages/man3/sysconf.3.html:
> _SC_PHYS_PAGES The number of pages of physical memory. Note that it is possible for the product of this value and the value of _SC_PAGESIZE to overflow.
> _SC_PAGESIZE Size of a page in bytes. Must not be less than 1.

See https://godbolt.org/z/ec81Tjvrj for further details
2025-09-17 11:36:21 -07:00
Ryan Ofsky e9c52272eb test: Avoid interface_ipc.py Duplicate ID errors
This change should fix issue https://github.com/bitcoin/bitcoin/issues/33417
reported by zaidmstrr. It's possible to reproduce the `mp/proxy.capnp:0:
failed: Duplicate ID @0xcc316e3f71a040fb` error by installing libmultiprocess
system-wide, or to one of the locations listed in the python test's `imports`
list before the local libmultiprocess subtree, and then running the test.
2025-09-17 12:34:07 -04:00
Ryan Ofsky c49a43591f Merge commit '535fa0ad0d2637f845beae92ea9dbbbbbe377c74' into pr/subtree-5 2025-09-17 05:30:43 -04:00
Ryan Ofsky 535fa0ad0d Squashed 'src/ipc/libmultiprocess/' changes from 13424cf2ecc1..47d79db8a552
47d79db8a552 Merge bitcoin-core/libmultiprocess#201: bug: fix mptest hang, ProxyClient<Thread> deadlock in disconnect handler
f15ae9c9b9fb Merge bitcoin-core/libmultiprocess#211: Add .gitignore
4a269b21b8c8 bug: fix ProxyClient<Thread> deadlock if disconnected as IPC call is returning
85df96482c49 Use try_emplace in SetThread instead of threads.find
ca9b380ea91a Use std::optional in ConnThreads to allow shortening locks
9b0799113557 doc: describe ThreadContext struct and synchronization requirements
d60db601ed9b proxy-io.h: add Waiter::m_mutex thread safety annotations
4e365b019a9f ci: Use -Wthread-safety not -Wthread-safety-analysis
15d7bafbb001 Add .gitignore
fe1cd8c76131 Merge bitcoin-core/libmultiprocess#208: ci: Test minimum cmake version in olddeps job
b713a0b7bfbc Merge bitcoin-core/libmultiprocess#207: ci: output CMake version in CI script
0f580397c913 ci: Test minimum cmake version in olddeps job
d603dcc0eef0 ci: output CMake version in CI script

git-subtree-dir: src/ipc/libmultiprocess
git-subtree-split: 47d79db8a5528097b408e18f7b0bae11a6702d26
2025-09-17 05:30:43 -04:00
Ryan Ofsky 453b0fa286 bitcoin: Make wrapper not require -m
Choose the right binary by default if an IPC option is specified
2025-09-17 04:57:09 -04:00
merge-script 1444ed855f
Merge bitcoin/bitcoin#33407: cmake: Install `bitcoin` manpage
7584a4fda9 cmake: Install `bitcoin` manpage (Hennadii Stepanov)

Pull request description:

  This PR is an amendment to https://github.com/bitcoin/bitcoin/pull/31375.

ACKs for top commit:
  ryanofsky:
    Code review ACK 7584a4fda9.

Tree-SHA512: 66810c1d65fa8ae469b8161a5f807aa7b43a7b18e88d40b05617c7110b2e03e07bcb8f310c1736fb2c3738e274fc524032ff5d34d5c644824a4edd64372f1e9f
2025-09-17 09:57:09 +01:00
Ryan Ofsky 29e836fae6 test: add tool_bitcoin to test bitcoin wrapper behavior 2025-09-17 04:57:09 -04:00
Ryan Ofsky 0972f55040 init: add exe name to bitcoind, bitcoin-node -version output to be able to distinguish these in tests 2025-09-17 04:57:09 -04:00
merge-script 2b0cd1f3fb
Merge bitcoin/bitcoin#33395: net: do not apply whitelist permissions to onion inbounds
f563ce9081 net: Do not apply whitelist permission to onion inbounds (Martin Zumsande)

Pull request description:

  Tor inbound connections do not reveal the peer's actual network address. Do not apply whitelist permissions to them since address-based matching is ineffective.

ACKs for top commit:
  darosior:
    ACK f563ce9081
  furszy:
    ACK f563ce9081
  vasild:
    ACK f563ce9081

Tree-SHA512: 49ae70e382fc2f78b7073553fe649a6843a41214b2986ea7f77e285d02b7bd00fe0320a1b71d1aaca08713808fb14af058f0b1f19f19adb3a77b97cb9d3449ce
2025-09-17 09:53:55 +01:00
Hennadii Stepanov ef20c2d11d
build, msvc: Update vcpkg manifest baseline
This change updates the vcpkg manifest baseline from the "2025.03.19
Release" to the "2025.08.27 Release", with the following package
changes:
 - boost: 1.87.0 --> 1.88.0
 - qtbase: 6.8.2#1 -> 6.9.1
 - qttools: 6.8.2 -> 6.9.1
 - sqlite3: 3.49.1 --> 3.50.4
2025-09-16 22:03:27 +01:00
Sebastian Falbesoner 1ff9e92948 key: use static context for libsecp256k1 calls where applicable
The dynamically created signing context for libsecp256k1 calls is only
needed for functions that involve generator point multiplication with a
secret key, i.e. different variants of public key creation and signing.
The API docs hint to this by stating "not secp256k1_context_static" for
the context parameter. In our case that applies to the following calls:
- `secp256k1_ec_pubkey_create`
- `secp256k1_keypair_create`
- `secp256k1_ellswift_create`
- `secp256k1_ecdsa_sign`
- `secp256k1_ecdsa_sign_recoverable`
- `secp256k1_schnorrsig_sign32`
- `ec_seckey_export_der` (not a direct secp256k1 function, but calls
  `secp256k1_ec_pubkey_create` inside)

For all the other secp256k1 calls we can simply use the static context.
2025-09-16 21:46:18 +02:00
Martin Zumsande f563ce9081 net: Do not apply whitelist permission to onion inbounds
Tor inbound connections do not reveal the peer's actual network address.
Therefore do not apply whitelist permissions to them.

Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
2025-09-16 13:35:34 -04:00
merge-script 947bed28fe
Merge bitcoin/bitcoin#33380: test: Add submitblock test in interface_ipc
0a26731c4c test: Add submitblock test in interface_ipc (TheCharlatan)

Pull request description:

  Expands the ipc mining test a bit with submitting a solved block and checking its validity.

ACKs for top commit:
  Sjors:
    ACK 0a26731c4c
  marcofleon:
    code review ACK 0a26731c4c
  zaidmstrr:
    Tested ACK [0a26731](0a26731c4c)

Tree-SHA512: 35c87d88496eec469bddedf2ae82c494626abb47ae15d5a45d6ab0400199c86501199c3e569e83836549830042be76b197b470e1100a317bdfef2578a9d5a92f
2025-09-16 12:44:35 -04:00
Hennadii Stepanov 7584a4fda9
cmake: Install `bitcoin` manpage 2025-09-16 14:18:59 +01:00
Matthew Zipkin 67f632b6de
net: remove unnecessary casts in socket operations
These methods in the Sock class wrap corresponding syscalls,
accepting void* arguments and casting to char* internally, which is
needed for Windows support and ignored on other platforms because
the syscall itself accepts void*:

Send()
Recv()
GetSockOpt()
SetSockOpt()
2025-09-16 06:26:01 -04:00
merge-script c4adfbf706
Merge bitcoin/bitcoin#33373: depends: systemtap 5.3
28efd724b4 depends: systemtap 5.3 (fanquake)

Pull request description:

  The diff in the copied header is:
  ```diff
  < #if __STDC_VERSION__ >= 199901L
  ---
  > #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  ```

  From
  https://sourceware.org/git/?p=systemtap.git;a=commit;h=b8345d8e07b725a943a97b19aa4866e74baadd98.

ACKs for top commit:
  0xB10C:
    ACK 28efd724b4

Tree-SHA512: 30eb4656d354e463937b68f8977d3c3bfe1e5a63be19a9e446a41cabcd1222290f4c7ecc64e516c4f5cc38b744229906fd92a9a56f4e1380dfb8db9ed518ebb4
2025-09-16 11:20:54 +01:00
Ava Chow 5aa3d3135d
Merge bitcoin/bitcoin#33391: test: Prevent disk space warning during node_init_tests
bdf01c6f61 test: Prevent disk space warning during node_init_tests (Ryan Ofsky)

Pull request description:

  mzumsande pointed out https://github.com/bitcoin/bitcoin/pull/32345#issuecomment-3286964369 that this test was print a warning:

  ```
  Warning: Disk space for "/tmp/test_common bitcoin/node_init_tests/init_test/bf78678cb7723a3e84b5/blocks" may not accommodate the block files. Approximately 810 GB of data will be stored in this directory.
  ```

  Fix by setting regtest instead of mainnet network before running the test.

ACKs for top commit:
  achow101:
    ACK bdf01c6f61
  Eunovo:
    Tested ACK bdf01c6f61:
  janb84:
    ACK bdf01c6f61
  l0rinc:
    tested ACK bdf01c6f61
  mzumsande:
    utACK bdf01c6f61
  enirox001:
    utACK bdf01c6

Tree-SHA512: ac4e1e48246c84a4c4b80ccb25e962b0090359ab0e541ee4f1a9e18ac9da8ec35a78c9a55501d231423053e945ff785862f0db141d4b620d622327670c764f8c
2025-09-15 18:21:08 -07:00
Ryan Ofsky bdf01c6f61 test: Prevent disk space warning during node_init_tests
mzumsande pointed out https://github.com/bitcoin/bitcoin/pull/32345#issuecomment-3286964369 that this test was causing a warning:

   Warning: Disk space for "/tmp/test_common bitcoin/node_init_tests/init_test/bf78678cb7723a3e84b5/blocks" may not accommodate the block files. Approximately 810 GB of data will be stored in this directory.

Fix by setting regtest instead of mainnet network before running the test.
2025-09-15 09:48:36 -04:00
TheCharlatan 0a26731c4c
test: Add submitblock test in interface_ipc
Co-Authored-By: Sjors Provoost <sjors@sprovoost.nl>
2025-09-15 12:25:43 +02:00
merge-script 2d6a0c4649
Merge bitcoin/bitcoin#33379: cmake: Fix regression in `secp256k1.cmake`
9193c3e434 cmake: Fix regression in `secp256k1.cmake` (Hennadii Stepanov)

Pull request description:

  This PR fixes a regression introduced in https://github.com/bitcoin/bitcoin/pull/33101 (mea culpa).

  From the CMake [docs](https://cmake.org/cmake/help/latest/command/enable_language.html):
  > The following restrictions apply to where `enable_language()` may be called:
  >
  >    - It must be called in file scope, not in a function call.

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

ACKs for top commit:
  TheCharlatan:
    ACK 9193c3e434
  furszy:
    ACK 9193c3e434

Tree-SHA512: 5f9ca2209af195a5eefefffdceae1acf650db29b371616f803b482a6b8acc4e87acc66714488520ef91d06ad4436438d9030be9979bd4c482cb5d1ce65b7f67e
2025-09-15 09:49:29 +01:00
Hennadii Stepanov 9193c3e434
cmake: Fix regression in `secp256k1.cmake`
The `enable_language` command must be called in file scope, not in a
function call.

See: https://cmake.org/cmake/help/latest/command/enable_language.html
2025-09-12 17:56:12 +01:00
merge-script d20f10affb
Merge bitcoin/bitcoin#33268: wallet: Identify transactions spending 0-value outputs, and add tests for anchor outputs in a wallet
113a422822 wallet: Add m_cached_from_me to cache "from me" status (Ava Chow)
609d265ebc test: Add a test for anchor outputs in the wallet (Ava Chow)
c40dc822d7 wallet: Throw an error in sendall if the tx size cannot be calculated (Ava Chow)
39a7dbdd27 wallet: Determine IsFromMe by checking for TXOs of inputs (Ava Chow)
e76c2f7a41 test: Test wallet 'from me' status change (Ava Chow)

Pull request description:

  One of the ways that the wallet would determine if a transaction was sent from the wallet was by checking if the total amount being spent by a transaction from outputs known to the wallet was greater than 0. This has worked fine until recently since there was no reason for 0-value outputs to be created. However, with ephemeral dust and P2A, it is possible to create standard 0-value outputs, and the wallet was not correctly identifying the spends of such outputs. This PR updates `IsFromMe` to only check whether the wallet knows any of the inputs, rather than checking the debit amount of a transaction.

  Additionally, a new functional test is added to test for this case, as well as a few other anchor output related scenarios. This also revealed a bug in `sendall` which would cause an assertion error when trying to spend all of the outputs in a wallet that has anchor outputs.

  Fixes #33265

ACKs for top commit:
  rkrux:
    lgtm ACK 113a422822
  enirox001:
    Tested ACK 113a422. Ran the full functional test suite including `wallet_anchor.py`; all tests passed. Fix for 0 value anchor detection and sendall size errors looks good. LGTM.
  furszy:
    ACK 113a422822

Tree-SHA512: df2ce4b258d1875ad0b4f27a5b9b4437137a5889a7d5ed7fbca65f904615e9572d232a8b8d070760f75ac168c1a49b7981f6b5052308575866dc610d191ca964
2025-09-12 14:42:08 +01:00
fanquake 28efd724b4
depends: systemtap 5.3
The diff in the copied header is:
```diff
< #if __STDC_VERSION__ >= 199901L
---
> #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
```

From
https://sourceware.org/git/?p=systemtap.git;a=commit;h=b8345d8e07b725a943a97b19aa4866e74baadd98.
2025-09-12 11:59:45 +01:00
merge-script 9a5ba154be
Merge bitcoin/bitcoin#33310: trace: Workaround GCC bug compiling with old systemtap
93a29ff283 trace: Workaround GCC bug compiling with old systemtap (Luke Dashjr)

Pull request description:

ACKs for top commit:
  0xB10C:
    lgtm ACK 93a29ff283 - I did not test this.

Tree-SHA512: 9ce9ed8b7733af721134462073a3417e52d67e9e9853eebbddfa795842b381de98e28756ebfa6652536cbfdd08181142eccd198f4dc00a57d8748801b362b4b7
2025-09-12 11:49:38 +01:00
merge-script 853f0d8811
Merge bitcoin/bitcoin#33364: ci: always use tag for LLVM checkout
b736052e39 ci: always use tag for LLVM checkout (fanquake)

Pull request description:

  Rather than trying to match the apt installed clang version, which is prone to intermittent issues. i.e #33345.

ACKs for top commit:
  davidgumberg:
    ACK b736052e39
  willcl-ark:
    ACK b736052e39

Tree-SHA512: 8e3fcc8219f573cec65941576c7995f21cae3330bcdbf615f799e8c5facd1146d3239a7284e9af7b013c37170ddf7435d7df6d2966f63fe7b4a8e4937311ff36
2025-09-12 09:46:25 +01:00
Ava Chow b81445333a
Merge bitcoin/bitcoin#33243: test: Fix CLI_MAX_ARG_SIZE issues
fa96a4afea ci: Enable CI_LIMIT_STACK_SIZE=1 in i686_no_ipc task (MarcoFalke)
facfde2cdc test: Fix CLI_MAX_ARG_SIZE issues (MarcoFalke)

Pull request description:

  `CLI_MAX_ARG_SIZE` has many edge case issues:

  * It seems to be lower on some systems, but it is unknown how to reproduce locally: https://github.com/bitcoin/bitcoin/pull/33079#issuecomment-3139957274
  * `MAX_ARG_STRLEN` is a limit per arg, but we probably want "The maximum length of [all of] the arguments": See https://www.man7.org/linux/man-pages/man3/sysconf.3.html, section `ARG_MAX - _SC_ARG_MAX`.
  * It doesn't account for the additional args added by the `bitcoin` command later on: 73220fc0f9/src/bitcoin.cpp (L85-L92)
  * It doesn't account for unicode encoding a string to bytes before taking its length.

  The issues are mostly harmless edge cases, but it would be good to fix them. So do that here, by:

  * Replacing `max()` by `sum()`, to correctly take into account all args, not just the largest one.
  * Reduce `CLI_MAX_ARG_SIZE`, to account for the `bitcoin` command additional args.

  Also, there is a test. The test can be called with `ulimit` to hopefully limit the max args size to the hard-coded value in the test framework. For reference:

  ```
  $ ( ulimit -s 512 && python3 -c 'import os; print(os.sysconf("SC_ARG_MAX") )' )
  131072
  ```

  On top of this pull it should pass, ...

  ```
  bash -c 'ulimit -s 512 && BITCOIN_CMD="bitcoin -M" ./bld-cmake/test/functional/rpc_misc.py --usecli -l DEBUG'
  ```

  ... and with the test_framework changes reverted, it should fail:

  ```
  OSError: [Errno 7] Argument list too long: 'bitcoin'
  ```

  Also, there is a commit to enable `CI_LIMIT_STACK_SIZE=1` in the i686 task, because it should now be possible and no longer hit the hard-to-reproduce issue mentioned above.

ACKs for top commit:
  cedwies:
    ACK fa96a4a
  achow101:
    ACK fa96a4afea
  enirox001:
    ACK fa96a4a — thanks for addressing the nits and clarifying the test; LGTM.
  mzumsande:
    Code Review ACK fa96a4afea

Tree-SHA512: d12211bd097d692d560c3615970ec0e911707d8c6cbbb145591abc548beed55f487a80b08f0a8c89d4eef4d76a9fbd6a33edc0b42b5860a93dd7b954355bc887
2025-09-11 15:37:48 -07:00
Ava Chow f757da87f5
Merge bitcoin/bitcoin#33332: common: Make arith_uint256 trivially copyable
653a9849d5 common: Make arith_uint256 trivially copyable (Fabian Jahr)

Pull request description:

  Makes `arith_uint256`/`base_uint` trivially copyable by removing the custom copy constructor and copy assignment operators. Removing of the custom code should not result in a change of behavior since `base_uint` contains a simple array of `uint32_t` and compiler generated versions of the code could be better optimized.

  This was suggested by maflcko here: https://github.com/bitcoin/bitcoin/pull/30469#pullrequestreview-3186533494

ACKs for top commit:
  Raimo33:
    ACK 653a9849d5
  l0rinc:
    ACK 653a9849d5
  achow101:
    ACK 653a9849d5
  hodlinator:
    re-ACK 653a9849d5

Tree-SHA512: 38db5220a2cf773c0c5fb5591671e329b6b87458d972db4f5f3f98c025ec329a8c39b32b5bc24ef8b50b1002b43bb248d8b35aa1c9a56c68c6bbd1d470485bd7
2025-09-11 14:43:17 -07:00
Ava Chow e416dc2fbb
Merge bitcoin/bitcoin#33321: kernel: make blockTip index const
75d9b72475 kernel: make blockTip index const (stickies-v)

Pull request description:

  Notification interface subscribers need to view, but not mutate, the index.

  This change allows improving the #30595 kernel interface, see e.g. `BlockTreeEntry` where [currently](https://github.com/bitcoin/bitcoin/pull/30595/files#diff-4d05cd02fdce641be603f0f9abcecfeaf76944285d4539ba4bbc40337fa9bbc2R617) a `View` is constructed from a non-const pointer, whereas really this should be a `const btck_BlockTreeEntry* entry`.

ACKs for top commit:
  achow101:
    ACK 75d9b72475
  TheCharlatan:
    ACK  75d9b72475
  l0rinc:
    Code review ACK 75d9b72475
  yuvicc:
    Code review ACK 75d9b72475

Tree-SHA512: 6151374a040cead36490c5fa5ce9dc4d93499a02110f444c50bd90f9095912747bc5b2fd7294815e6794c96a6843f43eb0507706d41d7296af96071b5f704ff4
2025-09-11 13:46:20 -07:00
Lőrinc 75e6984ec8 test/refactor: use test deque to avoid quadratic iteration
Extracted from https://github.com/bitcoin/bitcoin/pull/33141#discussion_r2323012972.
In Python, list `pop(0)` is linear, so consuming all items is quadratic.
Switched to `collections.deque` with `popleft()` to express FIFO intent and avoid the O(n^2) path.
Behavior is unchanged; for a few hundred items the perf impact is likely negligible.

Ref: https://docs.python.org/3/tutorial/datastructures.html#using-lists-as-queues
> While appends and pops from the end of list are fast, doing inserts or pops
> from the beginning of a list is slow (because all of the other elements have
> to be shifted by one).

Co-authored-by: maflcko <6399679+maflcko@users.noreply.github.com>
2025-09-11 13:09:23 -07:00
Ava Chow 176fac0f16
Merge bitcoin/bitcoin#33141: test: Remove polling loop from test_runner (take 2)
fa4885ef2f test: Remove polling loop from test_runner (MarcoFalke)

Pull request description:

  (This picks up my prior attempt from https://github.com/bitcoin/bitcoin/pull/13384)

  Currently, the test_runner is using a `time.sleep` before polling to check if any tests have completed. This is largely fine when running a few tests, or when the tests take a long time.

  However, when running many fast tests, this can accumulate and leave the CPU idle for no reason.

  A trivial improvement would be to only sleep when really needed:

  ```diff
  diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py
  index 7c8c15f391..1d9f28cee4 100755
  --- a/test/functional/test_runner.py
  +++ b/test/functional/test_runner.py
  @@ -747,7 +747,6 @@ class TestHandler:
           dot_count = 0
           while True:
               # Return all procs that have finished, if any. Otherwise sleep until there is one.
  -            time.sleep(.5)
               ret = []
               for job in self.jobs:
                   (name, start_time, proc, testdir, log_out, log_err) = job
  @@ -771,6 +770,7 @@ class TestHandler:
                       ret.append((TestResult(name, status, int(time.time() - start_time)), testdir, stdout, stderr, skip_reason))
               if ret:
                   return ret
  +            time.sleep(.5)
               if self.use_term_control:
                   print('.', end='', flush=True)
               dot_count += 1
  ```

  However, ideally there is no sleep at all. So do that by using a `ThreadPoolExecutor`.

  This can be tested via something like:

  ```
  time ./bld-cmake/test/functional/test_runner.py $(for i in {1..200}; do echo -n "tool_rpcauth "; done) -j 200
  ```

  The result should show:

  * Current `master` is the slowest
  * The "sleep patch" from above is a bit faster (1.5x improvement)
  * This pull request is the fastest (2x improvement)

ACKs for top commit:
  achow101:
    ACK fa4885ef2f
  l0rinc:
    tested ACK fa4885ef2f
  Eunovo:
    ReACK fa4885ef2f

Tree-SHA512: f097636c5d9e005781012d8e20c2886cd9968544d4d555b1d2e28982d420ff63fec15cfabb6bd30e4d3c389b8b8350a1ddad721cceaf4b7760cad38b95160175
2025-09-11 13:05:13 -07:00
merge-script 593d5fe37d
Merge bitcoin/bitcoin#33354: txgraph: use enum Level instead of bool main_only
d45f3717d2 txgraph: use enum Level instead of bool main_only (Pieter Wuille)

Pull request description:

  Part of #30289. Inspired by https://github.com/bitcoin/bitcoin/pull/28676#discussion_r2331387778.

  Since there has been more than one case in the development of #28676 of calling a `TxGraph` function without correctly setting the `bool main_only` argument that many of its interface functions have, make these mandatory and explicit, using an `enum class Level`:

  ```c++
  enum class Level {
      TOP, //!< Refers to staging if it exists, main otherwise.
      MAIN //!< Always refers to the main graph, whether staging is present or not.
  };
  ```

ACKs for top commit:
  instagibbs:
    ACK d45f3717d2
  vasild:
    ACK d45f3717d2
  glozow:
    code review ACK d45f3717d2

Tree-SHA512: d1c4b37e8ab3ec91b414df8970cb47aa080803f68da5881c8e1cbdc6939dea7851e0f715192cf3edd44b7f328cd6b678474d41f9cd9da8cb68f6c5fd78cb71b1
2025-09-11 11:21:26 -04:00
Fabian Jahr 653a9849d5
common: Make arith_uint256 trivially copyable
Replacing the custom code with default behavior should not result in a change of behavior since base_uint contains a simple array of uint32_t and compiler generated versions of the code could be better optimized.

Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
2025-09-11 16:50:26 +02:00
fanquake b736052e39
ci: always use tag for LLVM checkout
Rather than trying to match the apt installed clang version, which is
prone to intermittent issues. i.e #33345.
2025-09-11 10:40:11 +01:00
Anthony Towns 652424ad16 test: additional test coverage for script_verify_flags 2025-09-11 11:24:09 +10:00
will 00c253d494
ci: disable cirrus cache in 32bit arm job
Co-authored-by: Max Edwards <youwontforgetthis@gmail.com>
Add an optional matrix field allowing opt-out of configuring cirrus
GHA cache when not using cirrus runners.

This is not needed for the cirruslabs/[save|restore]-cache actions, as
they automatically fallback based on runner type.
2025-09-10 21:34:09 +01:00
will ff18b6bbaf
ci: refactor docker action to return provider str
Avoid relying on future truthy evaluations of string 'false'.
2025-09-10 21:34:07 +01:00
Pieter Wuille d45f3717d2 txgraph: use enum Level instead of bool main_only 2025-09-10 08:03:17 -04:00
Hennadii Stepanov ee42d59d4d
Merge bitcoin-core/gui#886: Avoid pathological QT text/markdown behavior...
6a371b70c8 gui: Avoid pathological QT text/markdown behavior... (David Gumberg)

Pull request description:

  ...during text selection by only setting plaintext mime data.

  Fixes the OOM described in #887.

  The issue is related to the construction of the [`text/markdown`](b617d11765/src/widgets/widgets/qwidgettextcontrol.cpp (L3539)) MIME data for the selection. Using the `heaptrack` utility, I observed that nearly all of the allocations when reproducing happen in [`QTextMarkdownWriter::writeFrame`](b617d11765/src/gui/text/qtextmarkdownwriter.cpp (L95)). I am not 100% sure what is causing this issue in QT's conversion of our HTML to markdown; I have tried changing the [HTML tags](689a321976/src/qt/rpcconsole.cpp (L916-L924)) (e.g. using `<p></p`> and `<ul><li></li></ul>` in place of tables)  used in our `rpcconsole` messages, but the issue recurs.

  The solution applied here is to override `createMimeDataFromSelection()` to avoid construction of the (likely never-used anyways) `text/markdown` mime data, and only set plaintext mime data in the clipboard.

ACKs for top commit:
  hebasto:
    ACK 6a371b70c8.

Tree-SHA512: 3edc4da47e6dbe939f27664d2265376938eed4f83ded3706e4b73677eac5c9a4ba8819f241428b45a08e8834982ee7759ee096afd090586db3b523d0ccbbbf73
2025-09-10 12:26:58 +01:00
Ava Chow 2c8a478db4
Merge bitcoin/bitcoin#33231: net: Prevent node from binding to the same `CService`
4d4789dffa net: Prevent node from binding to the same CService (woltx)

Pull request description:

  Currently, if the node inadvertently starts with repeated `-bind` options (e.g. `./build/bin/bitcoind -listen -bind=0.0.0.0 -bind=0.0.0.0`), the user will receive a misleading message followed by the node shutdown:

  ```
  [net:error] Unable to bind to 0.0.0.0:8333 on this computer. Bitcoin Core is probably already running.
  [error] Unable to bind to 0.0.0.0:8333 on this computer. Bitcoin Core is probably already running.
  ```

  And the user might spend some time looking for a `bitcoind` process or what application is using port 8333, when what happens is that Bitcoin Core successfully connected to port 8333 and then tries again, generating this fatal error.

  This PR proposes that repeated `-bind` options have no effect.

ACKs for top commit:
  l0rinc:
    ACK 4d4789dffa
  yuvicc:
    re-ACK 4d4789dffa
  sipa:
    utACK 4d4789dffa
  achow101:
    ACK 4d4789dffa
  vasild:
    ACK 4d4789dffa
  naiyoma:
    Tested ACK 4d4789dffa

Tree-SHA512: f1042c00417da16550403cfcb75cb8b12740e67cf92a1d8e3c007ae81fcf741907088a633129ce12a6a48ad07fc9f320602792cafed73ec33f6306cd854514b4
2025-09-09 14:57:16 -07:00
Ava Chow 591eea7b5a
Merge bitcoin/bitcoin#33082: wallet, refactor: Remove Legacy check and error
d3c5e47391 wallet, refactor: Remove Legacy check and error (pablomartin4btc)
30c6f64eed test: Remove unnecessary LoadWallet() calls (pablomartin4btc)

Pull request description:

  Remove dead code due to legacy wallet removal.

  Leftovers from previous #32481.

  ---

  **Note**:

  While attempting to remove the legacy check in `CWallet::UpgradeDescriptorCache()` (which is called from `DBErrors WalletBatch::LoadWallet(CWallet* pwallet))`, I once again ran into the fact that `LoadWallet()` is used in two distinct scenarios — something I was already aware of:
  - Wallet creation – the upgrade is ignored here because no wallet flags are yet set; attempting to set a flag (ie `WALLET_FLAG_LAST_HARDENED_XPUB_CACHED` at the end of the upgrade function, if the legacy check is removed) would produce a failure (`DBErrors CWallet::LoadWallet()` -> `Assert(m_wallet_flags == 0)`).
  - Wallet loading – the upgrade proceeds correctly and the flag `WALLET_FLAG_LAST_HARDENED_XPUB_CACHED` is set.

  While revisiting this, I also noticed that some `LoadWallet()` calls in the wallet tests are unnecessary and I've removed them in the first commit.

  The following change in `UpgradeDescriptorCache()` could be done in PR #32636 as part of the separation between wallet loading and creation responsibilities.

  ```diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp

   void CWallet::UpgradeDescriptorCache()
   {
  +    // Only descriptor wallets can upgrade descriptor cache
  +    Assert(IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));
  +
  -    if (!IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS) || IsLocked() || IsWalletFlagSet(WALLET_FLAG_LAST_HARDENED_XPUB_CACHED)) {
  +    if (IsLocked() || IsWalletFlagSet(WALLET_FLAG_LAST_HARDENED_XPUB_CACHED)) {
           return;
       }
  ```

ACKs for top commit:
  davidgumberg:
    crACK d3c5e47391
  achow101:
    ACK d3c5e47391
  l0rinc:
    code review ACK d3c5e47391

Tree-SHA512: ead37cf4061dfce59feb41ac50e807e6790e1a5e6b358e3b9c13e63d61a9cb82317a2e596cecb543f62f88a4338171788b651452425c1f40b5c1bec7fe78339e
2025-09-09 14:36:56 -07:00
David Gumberg 6a371b70c8 gui: Avoid pathological QT text/markdown behavior...
during text selection by only setting plaintext mime data.
2025-09-09 11:12:36 -07:00
merge-script c0894a0a2b
Merge bitcoin/bitcoin#33348: contrib: add bitcoin binary to gen-manpages
53e6db91ef contrib: add placeholder manpage for bitcoin binary (fanquake)
f5887a8de4 contrib: add bitcoin binary to gen-manpages (fanquake)

Pull request description:

  This was missed in #31375.

ACKs for top commit:
  dergoegge:
    ACK 53e6db91ef

Tree-SHA512: ff283ee02fadb57dbb335425d0348533b1322c6de323020f3ce5b6f01ff958cc731cb2191b8a774cd6a53b462f831e0ee86bbd522283357a6f6121962ef0abf1
2025-09-09 11:54:01 +01:00
fanquake 53e6db91ef
contrib: add placeholder manpage for bitcoin binary 2025-09-09 11:36:29 +01:00
fanquake f5887a8de4
contrib: add bitcoin binary to gen-manpages 2025-09-09 11:25:11 +01:00
merge-script 314c42b55b
Merge bitcoin/bitcoin#33347: build: bump `CLIENT_VERSION_MAJOR` to 30
9f744fffc3 build: bump CLIENT_VERSION_MAJOR to 30 (fanquake)

Pull request description:

  Last step before branch off.

ACKs for top commit:
  hebasto:
    ACK 9f744fffc3.

Tree-SHA512: f8ddbaa56213707c4d1719a6ade89103bcc1142d71f47cc527a20669995c1598ddbd61a88487841aa794340219e956deed403d8a7c229fc8b526e67e07dd7d69
2025-09-09 11:14:53 +01:00
fanquake 9f744fffc3
build: bump CLIENT_VERSION_MAJOR to 30 2025-09-09 10:56:50 +01:00
merge-script 042817ddb8
Merge bitcoin/bitcoin#33346: doc: remove release note fragment
0f0e6fe7f5 doc: remove release note fragment (fanquake)

Pull request description:

  I've added the content to https://github.com/bitcoin-core/bitcoin-devwiki/wiki/v30.0-Release-Notes-Draft.

ACKs for top commit:
  dergoegge:
    ACK 0f0e6fe7f5

Tree-SHA512: e0fc01945b15342aa87ce9d1312759acabf4be4c2a177d47d57f46fab42ea8ee3c04356f3a5d262c3f0e3fbe1090ae1d1e8b51659228c00bc1273b0b41f8dea3
2025-09-09 10:47:25 +01:00
fanquake 0f0e6fe7f5
doc: remove release note fragment
I've added the content to
https://github.com/bitcoin-core/bitcoin-devwiki/wiki/v30.0-Release-Notes-Draft.
2025-09-09 10:43:27 +01:00
merge-script 84cf542039
Merge bitcoin/bitcoin#33275: Release: 30.0 translations update
b320f5efa1 qt: 30.0 translations update (Hennadii Stepanov)

Pull request description:

  This PR follows our [Release Process](53a996f122/doc/release-process.md) and concludes the translation-specific efforts for this release cycle. It follows two previous translation-related PRs, https://github.com/bitcoin/bitcoin/pull/33152 and https://github.com/bitcoin/bitcoin/pull/33193.

  It is one of the steps required _before_ branch-off, as scheduled in https://github.com/bitcoin/bitcoin/issues/32275.

  A previous similar PR: https://github.com/bitcoin/bitcoin/pull/32004.

  **Notes for reviewers:**
  1. The actual translations on Transifex is a moving target. As a result, your diff after running [`bitcoin-maintainer-tools/update-translations.py`](https://github.com/bitcoin-core/bitcoin-maintainer-tools/blob/main/update-translations.py) may differ.

  2. The Polish translation update has been discarded. See https://github.com/bitcoin/bitcoin/pull/33275#issuecomment-3265688565 and https://github.com/bitcoin/bitcoin/pull/33275#issuecomment-3265829027.

ACKs for top commit:
  fanquake:
    ACK b320f5efa1

Tree-SHA512: 3e34c0fc7471dd27deeff2c871baa523e8741724e2aee5ed8afdf90263904f489dd77df849953425c9f0395dc23932dc4729646e0e4445f53225683f4f635087
2025-09-09 10:20:05 +01:00
merge-script 13809b867a
Merge bitcoin/bitcoin#33303: ci: Checkout latest merged pulls
fa8f081af3 ci: Checkout latest merged pulls (MarcoFalke)

Pull request description:

  Currently, the `actions/checkout@v5` checks out pull requests merged against master, which is what we want.

  However, it checks out ancient/stale merge commits on a re-run. This is documented (https://docs.github.com/en/actions/how-tos/manage-workflow-runs/re-run-workflows-and-jobs):

  >  Re-run workflows [...] will also use the same GITHUB_SHA (commit SHA) and GITHUB_REF (git ref) of the original event that triggered the workflow run.

  For example:

  * https://github.com/bitcoin/bitcoin/actions/runs/17458152407/job/49579638898?pr=29641#step:9:914 compiles with IPC=ON, even though latest master is at ed2ff3c63d
  * https://github.com/bitcoin/bitcoin/pull/32989#issuecomment-3133536724 (example explained in comment)

  This is problematic, because:

  * Unrelated CI failures and intermittent issues, which are fixed or worked around in latest master can not be cleaned by re-running the task. The author has to actively go out and (force-)push the branch, invalidating review.
  * It is odd to have a recent CI run, but it uses code and config from the past.
  * Detecting silent merge conflicts by re-running the CI task is impossible.

  Fix all issues by checking out the latest merged state of the pull request. The behavior is unchanged for non-pull-request actions. This patch changes the "re-run" default behaviour. Forcing it to use the new state instead of running the old state again.

ACKs for top commit:
  janb84:
    re ACK fa8f081af3
  hebasto:
    ACK fa8f081af3.

Tree-SHA512: c22c6f837402f61ec46be46817473e1946424b5312e36ed0e246cadb1ca89c04163bb471f71c309765a3d327f198a83cd83679d231f03828a99a97562a622fdd
2025-09-09 10:16:00 +01:00
merge-script e749205f83
Merge bitcoin/bitcoin#33319: ci: reduce runner sizes on various jobs
5eeb2facbb ci: reduce runner sizes on various jobs (will)

Pull request description:

  These jobs can likely use reduced runner sizes to avoid wasting our CPU quota, as much of the long-running part of the job is single-threaded.

  This will also give us more (job) parallelisem from the same number of CPU that we are using.

  Suggested in: https://github.com/bitcoin/bitcoin/pull/32989#discussion_r2321775620

ACKs for top commit:
  kevkevinpal:
    ACK [5eeb2fa](5eeb2facbb)
  m3dwards:
    ACK 5eeb2facbb
  janb84:
    ACK 5eeb2facbb

Tree-SHA512: 6fb0352bc40623dd63b9bd6169d753d1ec9667c272445fda7a2db8bbedfa35350a51d08c1adf3fa5e070e84855c3f491668726d3c7ded07a39f2f9c63edacefc
2025-09-09 10:12:28 +01:00
merge-script 9cbd346daa
Merge bitcoin/bitcoin#33340: Fix benchmark CSV output
790b440197 Fix benchmark CSV output (Hennadii Stepanov)

Pull request description:

  The `SHA256AutoDetect` return output is used, among other use cases, to name benchmarks. Using a comma breaks the `bench_bitcoin` CSV output.

  This PR replaces the comma with a semicolon, which fixes https://github.com/bitcoin/bitcoin/issues/33331.

ACKs for top commit:
  Raimo33:
    Code Review ACK 790b440197
  l0rinc:
    Code review ACK 790b440197
  janb84:
    code review ACK 790b440197

Tree-SHA512: 096bfa29a0639a4d97d510a3e2a15f071f384148c3035e4d0fc525794682e499c45a0d0c95728d5c78010098393b2c486a7fa9c21c1e2fbb600dea7c5638a55f
2025-09-09 10:11:29 +01:00
Ava Chow 4776179be9
Merge bitcoin/bitcoin#33342: guix: strip binaries in libexec
3cceda9f48 guix: strip binaries in libexec (fanquake)

Pull request description:

  #31679 moved some internal binaries to `libexec/`, but the Guix build wasn't updated to stip these binaries of their debug symbols.

ACKs for top commit:
  achow101:
    ACK 3cceda9f48
  ryanofsky:
    Code review ACK 3cceda9f48. Good catch and thanks for the fix
  hebasto:
    ACK 3cceda9f48, I've checked Guix build outputs.

Tree-SHA512: 96ad57c2d3670a9ae8c58cdb428918d1dc0fa90014bb7c6fb7a7a68b3ece3fbea9c4fac90a626a005a0edb3cca8b6a33adc9a037fe6b915319387588ffe09e7b
2025-09-08 17:24:05 -07:00
Ava Chow 0ba44d9c38
Merge bitcoin/bitcoin#33296: net: check for empty header before calling FillBlock
8b62647680 test: send duplicate blocktxn message in p2p_compactblocks.py (Eugene Siegel)
5e585a0fc4 net: check for empty header before calling FillBlock (Eugene Siegel)

Pull request description:

  This avoids an Assume crash if multiple blocktxn messages are received. The first call to `FillBlock` would make the header empty via `SetNull` and the call right before the second `FillBlock` would crash [here](689a321976/src/net_processing.cpp (L3333)) since `LookupBlockIndex` won't find anything. Fix that by checking for an empty header before the Assume.

ACKs for top commit:
  instagibbs:
    reACK 8b62647680
  fjahr:
    tACK 8b62647680
  achow101:
    ACK 8b62647680
  mzumsande:
    Code Review ACK 8b62647680

Tree-SHA512: d43a6f652161d4f7e6137f207a3e95259fc51509279d20347b1698c91179c39c8fcb75d2668b13a6b220f478a03578573208a415804be1d8843acb057fa1a73a
2025-09-08 17:16:28 -07:00
Ava Chow 1861030bea
Merge bitcoin/bitcoin#30469: index: Fix coinstats overflow
c767974811 clang-tidy: Fix critical warnings (Fabian Jahr)
54dc34ec22 index: Remove unused coinstatsindex recovery code (Fabian Jahr)
37c4fba1f4 index: Check BIP30 blocks when rewinding Coinstatsindex (Fabian Jahr)
51df9de8e5 doc: Add release note for 30469 (Fabian Jahr)
bb8d673183 test: Add coinstatsindex compatibility test (Fabian Jahr)
b2e8b64ddc index, refactor: Append blocks to coinstatsindex without db read (Fabian Jahr)
431a076ae6 index: Fix coinstatsindex overflow issue (Fabian Jahr)
84e813a02b index, refactor: DRY coinbase check (Fabian Jahr)
fab842b324 index, refactor: Rename ReverseBlock to RevertBlock (Fabian Jahr)

Pull request description:

  Closes https://github.com/bitcoin/bitcoin/issues/26362

  This continues the work that was started with #26426. It fixes the overflow issue by switching the tracked values that are in danger of overflowing from `CAmount` to `arith_uint256`.

  The current approach opts for a simple solution to ensure compatibility with datadirs including the previous version of the index: The new version of the index goes into a separate location in the datadir (`index/coinstatsindex/` rather than `index/coinstats/` before, the new naming is more consistent with the naming of the other indexes). There is no explicit concept of versioning of the index which earlier versions of this PR had. Having the two different versions of the index in separate places allows for downgrading of the node without having to rebuild the index. However, there will be a warning printed in the logs if the new code (v30) detects the old index still being present. A future version could delete a left-over legacy index automatically.

  The PR also includes several minor improvements but most notably it lets new entries be calculated and stored without needing to read any DB records.

ACKs for top commit:
  achow101:
    ACK c767974811
  TheCharlatan:
    ACK c767974811
  mzumsande:
    Tested / Code Review ACK c767974811

Tree-SHA512: 3fa4a19dd1a01c1b01390247bc9daa6871eece7c1899eac976e0cc21ede09c79c65f758d14daafc46a43c4ddd7055c85fb28ff03029132d48936b248639c6ab9
2025-09-08 17:06:30 -07:00
Eugene Siegel 8b62647680 test: send duplicate blocktxn message in p2p_compactblocks.py
Add test_multiple_blocktxn_response that checks that the peer is
disconnected.
2025-09-08 17:03:24 -04:00
Eugene Siegel 5e585a0fc4 net: check for empty header before calling FillBlock
Previously in debug builds, this would cause an Assume crash if
FillBlock had been called previously. This could happen when multiple
blocktxn messages were received.

Co-Authored-By: Greg Sanders <gsanders87@gmail.com>
2025-09-08 17:03:24 -04:00
Ava Chow cb825a07ac
Merge bitcoin/bitcoin#33338: net: Add interrupt to pcp retry loop
188de70c86 net: Add interrupt to pcp retry loop (TheCharlatan)

Pull request description:

  Without this interrupt bitcoind takes a long time to exit if requested to do so after a failed pcp lookup on startup.

ACKs for top commit:
  achow101:
    ACK 188de70c86
  fjahr:
    utACK 188de70c86
  hodlinator:
    utACK 188de70c86

Tree-SHA512: 426dabd10ac0ef5de246c83d281ba70957e4032d251054aa6028b4d7ce4e35cd35ac70e67dc07bd418673bcdd2f4457b76f174ac5e7d0dd3caa05de5da952dac
2025-09-08 13:44:44 -07:00
Ava Chow 0b0bd74c3e
Merge bitcoin/bitcoin#33312: clang-tidy: Disable `UndefinedBinaryOperatorResult` check in `src/ipc`
589b65f06c clang-tidy: Disable `UndefinedBinaryOperatorResult` check in `src/ipc` (Hennadii Stepanov)

Pull request description:

  The warnings are false positive and have been fixed upstream. See: https://github.com/capnproto/capnproto/pull/2334.

  This PR:

  1. Disables the `UndefinedBinaryOperatorResult` clang-tidy check for source files generated by the `mpgen` tool.

  2. Is an alternative to the draft https://github.com/bitcoin/bitcoin/pull/33281.

  3. Fixes https://github.com/bitcoin/bitcoin/issues/33256.

ACKs for top commit:
  Sjors:
    ACK 589b65f06c
  fjahr:
    ACK 589b65f06c
  achow101:
    ACK 589b65f06c
  ryanofsky:
    Code review ACK 589b65f06c. Thanks for the fix!

Tree-SHA512: 6d376a82641a5b85d4dd1fa164fdcbd8e15f1262e7d4f582f4d9959031d35852e28ff1b8268336e39ba6779fdd10ecdb986af42407d0545f4217f41d64556272
2025-09-08 13:28:01 -07:00
Hennadii Stepanov 790b440197
Fix benchmark CSV output
The `SHA256AutoDetect` return output is used, among other use cases, to
name benchmarks. Using a comma breaks the CSV output.

This change replaces the comma with a semicolon, which fixes the issue.
2025-09-08 18:39:55 +01:00
fanquake 3cceda9f48
guix: strip binaries in libexec
31679 moved some internal binaries to libexec/, but the Guix build
wasn't updated to stip these binaries of their debug symbols.
2025-09-08 16:21:28 +01:00
merge-script 3eea9fd395
Merge bitcoin/bitcoin#33308: doc: fix `LIBRARY_PATH` comment
a2a35b58cb doc: fix LIBRARY_PATH comment (fanquake)

Pull request description:

  Now that we build capnp, qt isn't the only native package.

ACKs for top commit:
  l0rinc:
    code review ACK a2a35b58cb
  willcl-ark:
    ACK a2a35b58cb

Tree-SHA512: 7b4a54b53b4c673e31dea011e569c6ef9e7238a56a7f09c7f5a7bc521fb0ffdda3794f2b65764908005333a30f7c8c7b4d6b45d985bc92a70dc2daf8c3d1ff3d
2025-09-08 14:31:15 +01:00
merge-script 0b38cc9bf7
Merge bitcoin/bitcoin#33339: doc: move release notes to wiki pre branch off
905c1a77f5 doc: move release notes to wiki pre branch off (fanquake)

Pull request description:

  See https://github.com/bitcoin-core/bitcoin-devwiki/wiki/v30.0-Release-Notes-Draft.

ACKs for top commit:
  janb84:
    ACK 905c1a77f5
  willcl-ark:
    ACK 905c1a77f5

Tree-SHA512: c883ca135e61e28891ac088b53da299ff2031a11db5c5805ba3fadba2e6bd7b9c68d7ab27e6439e3885604d623bef5c87206ce05826af3a58265d06205464782
2025-09-08 13:41:54 +01:00
Hennadii Stepanov b320f5efa1
qt: 30.0 translations update 2025-09-08 12:24:41 +01:00
fanquake 905c1a77f5
doc: move release notes to wiki pre branch off
See
https://github.com/bitcoin-core/bitcoin-devwiki/wiki/v30.0-Release-Notes-Draft.
2025-09-08 12:09:34 +01:00
merge-script 2d799590fe
Merge bitcoin/bitcoin#33283: contrib: update fixed seeds
939678940f contrib: update fixed seeds (fanquake)
6cdd8ee676 contrib: update makeseeds minblocks (fanquake)
b8da9f4034 contrib: update makeseeds UA regex (fanquake)

Pull request description:

  Update the fixed seeds pre 30 branch off.

ACKs for top commit:
  dergoegge:
    ACK 939678940f
  marcofleon:
    ACK 939678940f

Tree-SHA512: 7488f895a9c5a5fc115dd9fffced6e4846a238feef30a70795e189e4167404286e4142d93f91b62e0c765fb798bbbfb09c7b8194e8bdac1b480b230c58b66044
2025-09-08 10:32:52 +01:00
TheCharlatan 188de70c86
net: Add interrupt to pcp retry loop
Without this interrupt bitcoind takes a long time to exit if requested
to do so after a failed pcp lookup on startup.
2025-09-08 11:18:51 +02:00
merge-script 9c6fa07b12
Merge bitcoin/bitcoin#33322: Update libmultiprocess subtree to improve build and logs
a334bbe9b7 Squashed 'src/ipc/libmultiprocess/' changes from 1b8d4a6f1e54..13424cf2ecc1 (Ryan Ofsky)

Pull request description:

  Includes:

  - https://github.com/bitcoin-core/libmultiprocess/pull/197
  - https://github.com/bitcoin-core/libmultiprocess/pull/202
  - https://github.com/bitcoin-core/libmultiprocess/pull/203
  - https://github.com/bitcoin-core/libmultiprocess/pull/200
  - https://github.com/bitcoin-core/libmultiprocess/pull/205

  These changes should give better feedback when there are build errors, and also make IPC logs more readable.

  The changes can be verified by running `test/lint/git-subtree-check.sh src/ipc/libmultiprocess` as described in [developer notes](https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#subtrees) and [lint instructions](https://github.com/bitcoin/bitcoin/tree/master/test/lint#git-subtree-checksh)

ACKs for top commit:
  Sjors:
    ACK a4ee70e5b6

Tree-SHA512: ddddd0ed44522ade98a5b94f44b57210794d64f8c378a00438082b8c377f41e9b86c0c5ed29add45472549758f7478ab220af8e268b90b30f57a236c639497d3
2025-09-08 10:05:27 +01:00
Fabian Jahr c767974811
clang-tidy: Fix critical warnings
The std::move in coinstatsindex was not necessary since it was passed as a const reference argument.

The other change in the utxo supply fuzz test changes a line that seems to have triggered a false alarm.
2025-09-07 17:28:31 +02:00
Fabian Jahr 54dc34ec22
index: Remove unused coinstatsindex recovery code
The coinstatsindex currently looks for block data at a hash key if the prev block in CustomAppend is different than expected. This is not needed since base index should always prevent us ending up in this scenario since it should rewind the index before calling CustomAppend in this case. But even if we run into this and our belt-and-suspenders code is getting hit, the index could not recover properly from the hash key index data so it can be removed without any real impact.
2025-09-07 17:21:19 +02:00
Fabian Jahr 37c4fba1f4
index: Check BIP30 blocks when rewinding Coinstatsindex
This is practically irrelevant due to the unlikeliness of a re-org
reaching so deep that it would drop the BIP30 blocks from the chain
(91842 and 91880). However this serves as documentation and ensures that
the functions RevertBlock and CustomAppend are consistent.
2025-09-07 17:21:19 +02:00
Fabian Jahr 51df9de8e5
doc: Add release note for 30469 2025-09-07 17:21:19 +02:00
Fabian Jahr bb8d673183
test: Add coinstatsindex compatibility test 2025-09-07 17:21:19 +02:00
Fabian Jahr b2e8b64ddc
index, refactor: Append blocks to coinstatsindex without db read 2025-09-07 17:21:19 +02:00
Fabian Jahr 431a076ae6
index: Fix coinstatsindex overflow issue
The index originally stored cumulative values in a CAmount type but this allowed for
potential overflow issues which were observed on Signet. Fix this by
storing the values that are in danger of overflowing in a arith_uint256.

Also turns an unnecessary copy into a reference in RevertBlock and
CustomAppend and gets
rid of the explicit total unspendable tracking which can be calculated
by adding the four categories of unspendables together.
2025-09-07 17:21:00 +02:00
MarcoFalke fa8f081af3
ci: Checkout latest merged pulls 2025-09-07 11:33:42 +02:00
Hennadii Stepanov 36e40417de
Merge bitcoin-core/gui#884: Fix compatibility with `-debuglogfile` command-line option
c0d28c8f5b qt: Fix compatibility with `-debuglogfile` command-line option (Hennadii Stepanov)

Pull request description:

  This change avoids hardcoding the "debug.log" filename, ensuring compatibility with custom filenames provided via the `-debuglogfile` command-line option.

ACKs for top commit:
  maflcko:
    tested ACK c0d28c8f5b 💳
  pablomartin4btc:
    ACK c0d28c8f5b

Tree-SHA512: 0453b5f918e1831f6c6b4f04031959c391936e5ee6fc742a3d0189fce9c4dcf060ff2138f0cd15c93919a8bf750860c1c926159cad7a7f8a361833017f89ad76
2025-09-06 00:22:48 +01:00
Ryan Ofsky a334bbe9b7 Squashed 'src/ipc/libmultiprocess/' changes from 1b8d4a6f1e54..13424cf2ecc1
13424cf2ecc1 Merge bitcoin-core/libmultiprocess#205: cmake: check for Cap'n Proto / Clang / C++20 incompatibility
72dce118649b Merge bitcoin-core/libmultiprocess#200: event loop: add LogOptions struct and reduce the log size
85003409f964 eventloop: add `LogOptions` struct
657d80622f81 cmake: capnproto pkg missing helpful error
d314057775a5 cmake: check for Cap'n Proto / Clang / C++20 incompatibility
878e84dc3030 Merge bitcoin-core/libmultiprocess#203: cmake: search capnproto in package mode only
1a85da5873c2 Merge bitcoin-core/libmultiprocess#202: doc: correct the build instructions for the example
df01873e1ecb Merge bitcoin-core/libmultiprocess#197: ci: Add freebsd and macos build
3bee07ab3367 cmake: search capnproto in package mode only
b6d3dc44194c doc: correct the build instructions for example
fa1ac3000055 ci: Add macos and freebsd task

git-subtree-dir: src/ipc/libmultiprocess
git-subtree-split: 13424cf2ecc1e5eadc85556cf1f4c65e915f702a
2025-09-05 15:43:16 -04:00
Ryan Ofsky a4ee70e5b6 Merge commit 'a334bbe9b79ddf1999003c792bc8945639b7e9c1' into pr/subtree-4 2025-09-05 15:43:16 -04:00
merge-script e04cb9c1bd
Merge bitcoin/bitcoin#33201: Add functional test for IPC interface
a341e11ac9 ci: test IPC on additional hosts (Sjors Provoost)
6aee573bfc ci: enable IPC tests in CI (Pieter Wuille)
8d2ee88fa2 tests: add functional tests for IPC interface (Pieter Wuille)
3cc9a06c8d test: Add TestNode ipcbind option (Ryan Ofsky)
3cceb60a71 test: Provide path to `bitcoin` binary (Ryan Ofsky)
8c7f005629 test: add is_ipc_compiled() and skip_if_no_ipc() functions (Ryan Ofsky)

Pull request description:

  This adds support to the functional test framework to run the multiprocess `bitcoin-node` binary, and then tests it in a new `interface_ipc.py` functional test through the `pycapnp` module.

ACKs for top commit:
  Sjors:
    ACK a341e11ac9
  ryanofsky:
    Code review ACK a341e11ac9. Changes since last review: rebasing, switching to miniwallet and expanding wallet test, improving pycapnp install steps in instructions and CI.
  TheCharlatan:
    ACK a341e11ac9

Tree-SHA512: 98330283cf0d66d5537eec1219345b8aec5740dbc2171bd8b70680d7a282e0962fcdf0588a75518110761e8bc95af57d6097c93937cac710805b0df10837093c
2025-09-05 13:00:46 -04:00
stickies-v 75d9b72475
kernel: make blockTip index const
Notification interface subscribers need to view, but not mutate,
the index.
2025-09-05 15:46:44 +01:00
Sjors Provoost a341e11ac9 ci: test IPC on additional hosts
Install pycapnp on all (active) CI hosts which have IPC enabled and
run the functional tests.

Except for previous_releases, which uses an older version of pip
that doesn't support --break-system-packages.
2025-09-05 09:31:54 -04:00
Pieter Wuille 6aee573bfc ci: enable IPC tests in CI 2025-09-05 09:24:17 -04:00
Pieter Wuille 8d2ee88fa2 tests: add functional tests for IPC interface
Co-Authored-By: ismaelsadeeq <ask4ismailsadiq@gmail.com>
Co-Authored-By: ryanofsky <ryan@ofsky.org>
Co-Authored-By: TheCharlatan <seb.kung@gmail.com>
Co-Authored-By: Sjors Provoost <sjors@sprovoost.nl>
2025-09-05 09:24:14 -04:00
Ryan Ofsky 3cc9a06c8d test: Add TestNode ipcbind option
With this change, tests can specify `self.extra_init = [{ipcbind: True}]` to
start a node listening on an IPC socket, instead of needing to choose which
node binary to invoke and what `self.extra_args=[["-ipcbind=..."]]` value to
pass to it.

The eliminates boilerplate code #30437 (interface_ipc_mining.py), #32297
(interface_ipc_cli.py), and #33201 (interface_ipc.py) previously needed in
their test setup.
2025-09-05 07:15:29 -04:00
Ryan Ofsky 3cceb60a71 test: Provide path to `bitcoin` binary
Set new `BitcoinTestFramework.binary_paths.bitcoin_bin` property with path to
the `bitcoin` wrapper binary. This allows new tests for `bitcoin-mine` in
#30437 and `bitcoin-cli` in #32297 to find the `bitcoin` binary and call
`bitcoin -m` to start nodes with IPC support. This way the new tests can run
whenever the ENABLE_IPC build option is enabled, instead of only running when
the `BITCOIN_CMD` environment variable is set to `bitcoin -m`
2025-09-05 07:15:29 -04:00
Ryan Ofsky 8c7f005629 test: add is_ipc_compiled() and skip_if_no_ipc() functions
Expose ENABLE_IPC build option to functional tests so new tests can test
IPC-only features.
2025-09-05 07:15:29 -04:00
merge-script 37c21ebe40
Merge bitcoin/bitcoin#33309: doc: archive v29.1 release notes
61ec8866c6 [doc] archive v29.1 release notes (glozow)

Pull request description:

  Copied from https://github.com/bitcoin/bitcoin/blob/v29.1/doc/release-notes.md

  This is needed for announcement links and so we can see historical release notes in master.

ACKs for top commit:
  l0rinc:
    review ACK 61ec8866c6

Tree-SHA512: da9692c8cd8de54e848caab19da41975e8e75049b4fd3e1c6475ee86bf9947132597ceb4bf2e217710a73178b54c05b8f27668c67da202ba5fb1799b582fb15d
2025-09-05 10:24:06 +01:00
merge-script 32e2484b67
Merge bitcoin/bitcoin#33304: depends: strip when installing qt binaries
c9d5f211c1 depends: strip when installing qt (fanquake)

Pull request description:

  Otherwise we end up with ~1.5GB of binaries (Linux) when `DEBUG=1`. This isn't great generally, but is worse in the CI, where disk may be limited (#33293).

ACKs for top commit:
  TheCharlatan:
    ACK c9d5f211c1
  hebasto:
    ACK c9d5f211c1.

Tree-SHA512: bf83e0d8c41c64aaa6d841e24c4f25bbe33034ae54a32f34ca14aca59eaa1a004809d48acf171414ed43b99f7d3d1f4b973aee0b272475bd7cc2ca708718b8da
2025-09-05 10:14:49 +01:00
woltx 4d4789dffa net: Prevent node from binding to the same CService
Currently, if the user inadvertently starts the node with duplicate bind options,
such as `-bind=0.0.0.0 -bind=0.0.0.0`, it will cause a fatal error with the
misleading message "Bitcoin Core is probably already running".

This commit adds early validation to detect duplicate bindings across all binding
configurations (-bind, -whitebind, and onion bindings) before attempting to bind.
When duplicates are detected, the node terminates with a clear, specific error
message: "Duplicate binding configuration for address <addr>. Please check your
-bind, -bind=...=onion and -whitebind settings."

The validation catches duplicates both within the same option type (e.g.,
`-bind=X -bind=X`) and across different types (e.g., `-bind=X -whitebind=Y@X`),
helping users identify and fix configuration mistakes.
2025-09-04 23:40:02 -07:00
Ava Chow 647cdb4f7e
Merge bitcoin/bitcoin#33311: net: Quiet down logging when router doesn't support natpmp/pcp
4f1a4cbccd net: Quiet down logging when router doesn't support natpmp/pcp (laanwj)

Pull request description:

  When the router doesn't support natpmp and PCP, one'd normally expect the UDP packet to be ignored, and hit a time out. This logs a message that is already in the debug category. However, there's also the case in which sending an UDP packet causes a ICMP response (type 3, code 3 "port unreachable"). This is returned to user space as "connection refused" (despite UDP having no concept of connections).

  Move the warnings from `Send` and `Recv` to debug level too, to reduce log spam in that case.

  Closes #33301.

ACKs for top commit:
  willcl-ark:
    utACK 4f1a4cbccd
  sipa:
    utACK 4f1a4cbccd
  davidgumberg:
    Tested ACK 4f1a4cbccd
  achow101:
    ACK 4f1a4cbccd
  darosior:
    utACK 4f1a4cbccd
  mzumsande:
    utACK 4f1a4cbccd

Tree-SHA512: 2c99a5679720482ece47af33616b6b207509fb58ba1962a1c2d30f8d0e68554f8f5ef25224313d93f4c5a1cc702183fcf8e6119abc411209c9884119ef680aad
2025-09-04 15:24:28 -07:00
Hennadii Stepanov 589b65f06c
clang-tidy: Disable `UndefinedBinaryOperatorResult` check in `src/ipc`
The warnings are false positive and have been fixed upstream.
See: https://github.com/capnproto/capnproto/pull/2334.

This change disables the `UndefinedBinaryOperatorResult` clang-tidy
check for source files generated by the `mpgen` tool.
2025-09-04 23:07:40 +01:00
laanwj 4f1a4cbccd net: Quiet down logging when router doesn't support natpmp/pcp
When the router doesn't support natpmp and PCP, one'd normally expect
the UDP packet to be ignored, and hit a time out. This logs a warning
that is already in the debug category. However, there's also the case in
which sending an UDP packet causes a ICMP response. This is returned to
user space as "connection refused" (despite UDP having no concept of
connections).

Move the warnings from `Send` and `Recv` to debug level too, to reduce
log spam in that case.

Closes #33301.
2025-09-04 21:26:29 +02:00
Luke Dashjr 93a29ff283 trace: Workaround GCC bug compiling with old systemtap 2025-09-04 19:25:42 +00:00
will 5eeb2facbb
ci: reduce runner sizes on various jobs
These jobs can use reduced runner size to avoid wasting CPU, as much of
the long-running part of the job is single-threaded.

Suggested in: https://github.com/bitcoin/bitcoin/pull/32989#discussion_r2321775620

Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
2025-09-04 19:58:42 +01:00
glozow 61ec8866c6 [doc] archive v29.1 release notes 2025-09-04 14:13:52 -04:00
fanquake a2a35b58cb
doc: fix LIBRARY_PATH comment
Now that we build capnp, qt isn't the only native package.
2025-09-04 17:30:11 +01:00
Hennadii Stepanov e1ce0c525c
Merge bitcoin/bitcoin#33291: ci: cd into BASE_BUILD_DIR for GetCMakeLogFiles
9b76eef2d2 ci: cd into BASE_BUILD_DIR for GetCMakeLogFiles (Sjors Provoost)

Pull request description:

  When a bug is introduced in cmake, we render its logs, which was broken:
  https://github.com/bitcoin/bitcoin/pull/33290#issuecomment-3248645770

ACKs for top commit:
  maflcko:
    lgtm ACK 9b76eef2d2 💽
  hebasto:
    ACK 9b76eef2d2, [obviously](https://github.com/bitcoin/bitcoin/pull/33290#issuecomment-3248645770).

Tree-SHA512: 97a440efcaa058af1144d66257ac0157d499b66fd9a00fa01e0eaa013267af1643cb062ec6c74366fab88cb706c9cf9d5fb0316195e79582679c7ae8d39ec200
2025-09-04 16:09:13 +01:00
Fabian Jahr 84e813a02b
index, refactor: DRY coinbase check
Also marks a few additional variables const.
2025-09-04 15:57:25 +02:00
Fabian Jahr fab842b324
index, refactor: Rename ReverseBlock to RevertBlock
Semantically this is the correct name for what the function is doing.
2025-09-04 15:57:24 +02:00
merge-script 2d8f5b9188
Merge bitcoin/bitcoin#33136: ci: Remove redundant RUN_UNIT_TESTS_SEQUENTIAL
fae610d858 ci: Remove redundant RUN_UNIT_TESTS_SEQUENTIAL (MarcoFalke)

Pull request description:

  `RUN_UNIT_TESTS_SEQUENTIAL` is useful to detect cases where global state is left dirty in the test process and leads to subsequent unit test cases failing. However, one CI task is sufficient to catch this.

  As there already is one, add docs there and remove this env var (and extra logic).

ACKs for top commit:
  fanquake:
    ACK fae610d858

Tree-SHA512: b7ace1257d039f144cb0acb08d5d19d641028464517e6a2468e248ed79b2511512dc904867dacd66157b7483ec8041c95cce00f8ce3c89f3a2c3bb47939d7ff9
2025-09-04 13:53:16 +01:00
fanquake c9d5f211c1
depends: strip when installing qt
Otherwise we end up with ~1.5GB of binaries (Linux) when DEBUG=1..
2025-09-04 13:36:14 +01:00
MarcoFalke fae610d858
ci: Remove redundant RUN_UNIT_TESTS_SEQUENTIAL 2025-09-04 12:08:39 +02:00
merge-script 2562fe1b2b
Merge bitcoin/bitcoin#32159: net, pcp: handle multi-part responses and filter for default route while querying default gateway
88db09bafe net: handle multi-part netlink responses (willcl-ark)
42e99ad773 net: skip non-route netlink responses (willcl-ark)
57ce645f05 net: filter for default routes in netlink responses (willcl-ark)

Pull request description:

  ...for default route in pcp pinholing.

  Currently we only make a single recv call, which trucates results from large routing tables, or in the case the kernel may split the message into multiple responses (which may happen with `NLM_F_DUMP`).

  We also do not filter on the default route. For IPv6, this led to selecting the first route with an `RTA_GATEWAY` attribute, often a non-default route instead of the actual default. This caused PCP port mapping failures because the wrong gateway was used.

  Fix both issues by adding multi-part handling of responses and filter for the default route.

  Limit responses to ~ 1MB to prevent any router-based DoS.

ACKs for top commit:
  achow101:
    ACK 88db09bafe
  davidgumberg:
    Code Review re-ACK 88db09b
  Sjors:
    re-utACK 88db09bafe

Tree-SHA512: ea5948edebfad5896a487a61737aa5af99f529fad3cf3da68dced456266948238a7143383847e79a7bb90134e023eb173c25116d8eb80ff57fa4c4a0377ca1ed
2025-09-04 11:06:48 +01:00
merge-script ed2ff3c63d
Merge bitcoin/bitcoin#33235: build: set ENABLE_IPC to OFF when fuzzing
af4156ab75 build: set ENABLE_IPC to OFF when fuzzing (fanquake)

Pull request description:

  A `BUILD_FOR_FUZZING` build will currently failure to configure, with missing `capnp`.

ACKs for top commit:
  Crypt-iQ:
    tACK af4156ab75
  marcofleon:
    ACK af4156ab75
  dergoegge:
    utACK af4156ab75
  janb84:
    ACK af4156ab75

Tree-SHA512: e3c5238cb5823116a958502eab84ee72a94cac0853fc3908ef97b6b6dc037db27806be0726f321d70ab706c37924dec526b46a3a46ea3f3f3684ce48da46a803
2025-09-04 10:07:03 +01:00
willcl-ark 88db09bafe
net: handle multi-part netlink responses
Handle multi-part netlink responses to prevent truncated results from
large routing tables.

Previously, we only made a single recv call, which led to incomplete
results when the kernel split the message into multiple responses (which
happens frequently with NLM_F_DUMP).

Also guard against a potential hanging issue where the code would
indefinitely wait for NLMSG_DONE for non-multi-part responses by
detecting the NLM_F_MULTI flag and only continue waiting when necessary.
2025-09-03 21:09:39 +01:00
Ava Chow 113a422822 wallet: Add m_cached_from_me to cache "from me" status
m_cached_from_me is used to track whether a transaction is "from me", i.e. has
any inputs which belong to the wallet. This is held in memory only in
the same way that a transaction's balances are.
2025-09-03 13:04:52 -07:00
Ava Chow 609d265ebc test: Add a test for anchor outputs in the wallet 2025-09-03 13:02:06 -07:00
Ava Chow c40dc822d7 wallet: Throw an error in sendall if the tx size cannot be calculated 2025-09-03 12:58:59 -07:00
Ava Chow 39a7dbdd27 wallet: Determine IsFromMe by checking for TXOs of inputs
Instead of checking whether the total amount of inputs known by the
wallet is greater than 0, we should be checking for whether the input is
known by the wallet. This enables us to determine whether a transaction
spends an of output with an amount of 0, which is necessary for marking
0-value dust outputs as spent.
2025-09-03 12:55:53 -07:00
Ava Chow e76c2f7a41 test: Test wallet 'from me' status change
If something is imported into the wallet, it can change the 'from me'
status of a transaction. This status is only visible through
gettransaction's "fee" field which is only shown for transactions that
are 'from me'.
2025-09-03 12:55:50 -07:00
merge-script 689a321976
Merge bitcoin/bitcoin#33220: doc: truc packages allow sub min feerate transactions
7270839af4 doc: truc packages allow sub min feerate transactions (Pol Espinasa)

Pull request description:

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

  Some policy documentation is outdated since TRUC. This PR aims to update the documentation to the actual policy state.

ACKs for top commit:
  w0xlt:
    reACK 7270839af4
  glozow:
    ACK 7270839af4

Tree-SHA512: 1272e7acc76c76d7e145cdd07827ece31253dba4b99b9a22fc986fcd538830e46392fda877736cb496f3e53a0abcb9d8403d439bb1da63b88da7f8b6f17b6c8b
2025-09-03 10:07:45 -04:00
Sjors Provoost 9b76eef2d2
ci: cd into BASE_BUILD_DIR for GetCMakeLogFiles 2025-09-03 14:23:08 +02:00
fanquake 8e434a8499
macdeploy: rename macOS output to bitcoin-macos-app.zip
We were naming this "Bitcoin-Core.zip", just to immediately rename it.
Similar to what we do with Windows, i.e `bitcoin-win64-setup.exe`.
2025-09-03 13:00:38 +01:00
fanquake 05353d9cf0
macdeploy: combine appname & -zip arguments
appname is only used by -zip.
2025-09-03 13:00:35 +01:00
fanquake 939678940f
contrib: update fixed seeds 2025-09-03 11:23:30 +01:00
fanquake 6cdd8ee676
contrib: update makeseeds minblocks 2025-09-03 11:23:30 +01:00
fanquake b8da9f4034
contrib: update makeseeds UA regex 2025-09-03 11:23:30 +01:00
merge-script ba0b4304ec
Merge bitcoin/bitcoin#32989: ci: Migrate CI to hosted Cirrus Runners
3c5da69a23 ci: remove un-needed lint_run*.sh files (willcl-ark)
2aa288efdd ci: fix annoying docker warning (will)
dd1c5903e8 ci: add ccache hit-rate warning when < 75% (will)
f427284483 doc: Detail configuration of hosted CI runners (will)
3f339e99e0 ci: dynamically match makejobs with cores (will)
4393ffdd83 ci: remove .cirrus.yml (will)
bc41848d00 ci: port lint (will)
d290a8e6ea ci: port msan-depends (will)
9bbae61e3b ci: port tsan-depends (will)
bf7d536452 ci: port tidy (will)
549074bc64 ci: port centos-depends-gui (will)
58e38c3a04 ci: port previous-releases-depends-debug (will)
341196d75c ci: port fuzzer-address-undefined-integer-nodepends (will)
f2068f26c1 ci: port no-IPC-i686-DEBUG (will)
2a00b12d73 ci: port nowallet-libbitcoinkernel (will)
9c2514de53 ci: port mac-cross-gui-notests (will)
2c990d84a3 ci: force reinstall of kernel headers in asan (will)
884251441b ci: update asan-lsan-ubsan (will)
f253031cb8 ci: port arm 32-bit job (will)
04e7bfbceb ci: update windows-cross job (will)
cc1735d777 ci: add job to determine runner type (will)
020069e6b7 ci: add Cirrus cache host (will)
9c2b96e0d0 ci: have base install run in right dir (will)
18f6be09d0 ci: use docker build cache arg directly (will)
94a0932547 ci: use buildx in ci (will)
fdf64e5532 ci: add configure-docker action (will)
33ba073df7 ci: add REPO_USE_CIRRUS_RUNNERS (will)
b232b0fa5e ci: add caching actions (will)
b8fcc9fcbc ci: add configure environment action (will)

Pull request description:

  This changeset migrates all current self-hosted CI jobs over to hosted [Cirrus Runners](https://cirrus-runners.app/).

  These runners cost a flat rate of $150/month, and we qualify for an open source discount of 50%. Therefore they are $75/month/runner.

  One "runner" should more accurately be thought of in terms of the number of vCPU you are purchasing: https://cirrus-runners.app/pricing/ or in terms of "concurrency", where 1 runners gets you 1.0 concurrency.
  e.g. a Linux x86 Runner gets you 16 vCPU (1.0 concurrency) and 64GB RAM to be provisioned as you choose, amongst one or more jobs.

  Cirrus Runners currently only support Linux (x86 and Arm64) and MacOS (Arm64).
  This changeset does **not** move the existing Github Actions native MacOS runners away from being run on Github's infrastructure. This could be a follow up optimisation.

  Runs from this changeset using Cirrus Runners can be found at: https://github.com/testing-cirrus-runners/bitcoin2/actions which shows an uncached run on master ([CI#1](https://github.com/testing-cirrus-runners/bitcoin2/actions/runs/16298637161)), an outside pull request ([CI#3](https://github.com/testing-cirrus-runners/bitcoin2/actions/runs/16303305483?pr=1)) and an updated push to master ([CI#4](https://github.com/testing-cirrus-runners/bitcoin2/actions/runs/16304182527)).

  These workflows were run on 10 runners, and we would recommend purchasing a similar number for our CI in this repo to achieve the speed and concurrency we expect.

  We include some optional performance commits, but these could be split out and made into followups or dropped entirely.

  ## Benefits

  ### Maintenance

  As we are not self-hosting, nobody needs to maintain servers, disks etc.

  ### Bus factor

  Currently we have a very small number of people with the know-how working on server setup and maintenance. This setup fixes that so that "anyone" familiar with GitHub-style CI systems can work on it.

  ### Scaling

  These do _not_ "auto-scale"/have "unlimited concurrency" like some solutions, but if we want more workers/cpu to increase parallism or increase the runner size of certain jobs for a speed-up we can simply buy more concurrency using the web interface.

  ### Speed

  Runtimes aproximate current runtimes pretty well, with some jobs being faster.
  Caching improvements on pull request (re-runs) are left as future optimisations from the current changeset (see below).

  ### GitHub workflow syntax

  With a migration to the more-commonly-used GitHub workflow syntax, migration to other providers in the future is often as simple as a one-line change (and installing a new GitHub app to the repo).

  If we decide to self-host again, then we can also self-host GitHub runners (using https://github.com/actions/runner) and maintain new GH-style CI syntax.

  ### Reporting

  GitHub workflows provide nicer built-in reporting directly on the "Checks" page of a pr. This includes more-detailed action reporting, and a host of pretty nice integrated features, such as [Workflow Commands](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions) for creating annotations that can print messages during runs. See for example at the bottom of this window where we report `ccache` hitrate, if it was below 90%: https://github.com/testing-cirrus-runners/bitcoin/actions/runs/16163449125?pr=1

  These could be added conditionally into our CI scripts to report interesting or other information.

  ## Costs

  ### Financial

  Relative to competitors Cirrus runners are cheap for the hosted CI-world. However these are likely more expensive than our current setup, or a well-configured (new) self-hosted setup.

  If we started with 10 runners to be shared amongst all migrated jobs, this would total $750/mo = $9000/yr.

  Note that we are not trying to comptete here on cost directly.

  ### Dependencies

  We would be dependent on Cirrus infra.

  ## Forks

  - Forks should be able to run CI without paid Cirrus runners. This behaviour is achieved through a rather verbose `runs-on:` directive.
    - This directive hardcodes the main repo (unfortunately you cannot use the `env` github context in this field in particular, for some reason).
    - This directive also allows for a fork to patch the `runs-on:` field in the ci.yml file if they want to use Cirrus Runners too.
    - The workflow otherwise will fallback to the GitHub free runners on forks.
  - This cirrus cache action transparently falls back to github actions cache when not running on cirrus, so forks will get some free github caching (10GB per repo).

  All jobs work on forks, but will run (slowly) on GitHub native free hosted runners, instead of Cirrus runners. They will also suffer from poor cache hit-rates, but there's nothing that can be done about that, and the situtation is an improvement on today.

  ## Migration process

  The main org should also, in addition to pulling code changes:

  1. Permit the actions `docker/setup-buildx-action@v3` and `docker/login-action@v3` to be run in this repo.

  ## Caching

  For the number of CI jobs we have, cache usage on GitHub would be an issue as GH only provides 10GB of cache space, **per repo**. However cirrus provides [10 GB per runner](https://cirrus-runners.app/setup/#speeding-up-the-cache), which scales better with the number of runners.

  The `cirruslabs/action/[restore|save]` action we use here redirects this to Cirrus' own cache and is both faster and larger.

  In the case that user is running CI on a fork, the cirrus cache falls back transparently to GitHub default cache without error.

  ### ccache, depends-sources, built-depends

  - Cached as blobs via `cirruslabs/actions/cache` action.
  - Current implementation:
    - On `push`: restores and saves caches.
    - On `pull_request`: restores but does **not** save caches.

  This means a new pull request should hit a _pretty relevant_ cache.
  Old pull requests **which are not being rebased on master** may suffer from lower cache hit-rate.

  If we save caches on all pull request runs we run the risk of evicting recent (and more relevant) cache blobs.
  It may be possible in a future optimisation to widen this to save on pull request runs too, but it will also depend on how many runners we provision and what cache churn rates are like in the main repo.

  ### Docker build layer caching

  - Cached using the `gha` cache backend
  - These cache blobs compete for space with `ccache`, `depends-sources` and `depends-built` caches
  - `gha` cache allows `--cache-from` to be used from pull requests, which does not work using a registry cache type (technically we could use a public read-only token to get this working, but that feels wrong)

  This backend does network i/o and so are marginally slower than our current disk i/o cache.

  ## But what about... `x`?

  We have tested many other providers, including [Runs-on](https://runs-on.com/), [Buildjet](https://buildjet.com/), [WarpBuild](https://www.warpbuild.com/), and GitHub hosted runners (and investigated even more). But they all fall short in one-way or another.

  - Runs-On and Buildjet (and others) require installing GH apps with much too-liberal permissions (e.g. `Administration: Read|Write`) for our use-case.
  - GitHub hosted runners suffer from all of high costs, lower speed, small cache, and the requirement for a GitHub Teams subscription.
  - WarpBuild seems to be simply too expensive.

  ## TODO:

  To complete migration from self-hosted to hosted for this repo, the backport branches `27.x`, `28.x` and `29.x` would also need their CI ported, but these are left for followups to this change (and pending review/changes here first).

  -----

  Work and experimentation undertaken with m3dwards

ACKs for top commit:
  maflcko:
    re-ACK 3c5da69a23 🏗
  m3dwards:
    ACK 3c5da69a23
  achow101:
    ACK 3c5da69a23
  janb84:
    re ACK 3c5da69a23

Tree-SHA512: 9f7f2dddf1a5eebc56b4101663283d4219d189cda6054dba760f1288bed9e6ed3f2fa029a5caedc76c31b1271ea0a0cb0967a796086360d8f5be8277379b6397
2025-09-03 11:19:29 +01:00
merge-script 0eb3eae548
Merge bitcoin/bitcoin#33274: kernel: chainparams & headersync updates for 30.0
755152ac81 kernel: add testnet4 assumeutxo param at height 90'000 (fanquake)
a6512686e3 kernel: add mainnet assumeutxo param at height 910'000 (fanquake)
943de66b50 kernel: update headersync params (fanquake)
66fb962426 kernel: update chainTxData (fanquake)
c3cb26e028 kernel: update assumevalid and minimumChainWork (fanquake)
b4adae76d4 kernel: update assumed blockchain & chainstate sizes (fanquake)

Pull request description:

  Also adds assumeutxo params for mainnet at `910'000` & testnet4 & `90'000`.

ACKs for top commit:
  Sjors:
    re-ACK 755152ac81
  achow101:
    ACK 755152ac81
  w0xlt:
    ACK 755152ac81
  hodlinator:
    ACK 755152ac81

Tree-SHA512: d26b023b1fdbb72e81c3879aa274e3900742f015d77c1bb3cde00b3b882642c6b35a6268c6ccf35fa9243b58b5a1ebe6eba3eb7f58678eee5bd8a6d6e7518a6f
2025-09-03 11:08:38 +01:00
MarcoFalke fa4885ef2f
test: Remove polling loop from test_runner 2025-09-03 10:30:16 +02:00
Pol Espinasa 7270839af4
doc: truc packages allow sub min feerate transactions 2025-09-03 01:11:33 +02:00
Ava Chow 46369583f3
Merge bitcoin/bitcoin#33224: doc: unify `datacarriersize` warning with release notes
2885bd0e1c doc: unify `datacarriersize` warning with release notes (Lőrinc)

Pull request description:

  Follow-up to https://github.com/bitcoin/bitcoin/pull/32406

  ---

  The [release notes](a189d63618/doc/release-notes-32406.md (L1)) claim

  > [...] marked as deprecated and are expected to be removed in a future release

  but the [warning itself](2885bd0e1c/src/init.cpp (L907)) claims

  > [...] marked as deprecated. They **will** be removed in a future version.

  To be less aggressive (since some have objected against this version online) - and to unify the deprecation warning with the release notes - I have changed the warning to communicate our expectation in a friendlier way.

ACKs for top commit:
  cedwies:
    ACK 2885bd0
  ryanofsky:
    Code review ACK 2885bd0e1c. I don't think it is good for the release notes and the runtime warning message to say two different things. I'd also be happy if release notes were updated to match the runtime warning, instead of vice versa. Whatever is more accurate is better.
  ajtowns:
    ACK 2885bd0e1c
  kevkevinpal:
    ACK [2885bd0](2885bd0e1c)
  achow101:
    ACK 2885bd0e1c
  janb84:
    ACK 2885bd0e1c
  Zero-1729:
    crACK 2885bd0e1c
  jonatack:
    ACK 2885bd0e1c
  hodlinator:
    ACK 2885bd0e1c
  w0xlt:
    ACK 2885bd0e1c
  optout21:
    ACK 2885bd0e1c

Tree-SHA512: a9d2a64ab96b3dd7f3a1a29622930054fd5c56e573bc96330f4ef3327dc024b21b3fbc8a698d17aea7c76f57f0c2ccd6403b2df344ae2f69c645ceb8b6fa54a5
2025-09-02 15:48:41 -07:00
fanquake 755152ac81
kernel: add testnet4 assumeutxo param at height 90'000 2025-09-02 11:59:48 +01:00
fanquake a6512686e3
kernel: add mainnet assumeutxo param at height 910'000 2025-09-02 11:59:48 +01:00
fanquake 943de66b50
kernel: update headersync params 2025-09-02 11:59:48 +01:00
fanquake 66fb962426
kernel: update chainTxData 2025-09-02 11:59:47 +01:00
fanquake c3cb26e028
kernel: update assumevalid and minimumChainWork 2025-09-02 11:59:45 +01:00
fanquake b4adae76d4
kernel: update assumed blockchain & chainstate sizes 2025-09-02 11:59:01 +01:00
merge-script 7e58c94112
Merge bitcoin/bitcoin#33269: test: Fixup fill_mempool docstring
fa3f682032 test: Fixup fill_mempool docstring (MarcoFalke)

Pull request description:

  The assumption was removed in commit
  3eab8b7240.

ACKs for top commit:
  l0rinc:
    ACK fa3f682032
  enirox001:
    ACK https://github.com/bitcoin/bitcoin/commit/fa3f682 - docstring cleanup, looks good.
  pablomartin4btc:
    ACK fa3f682032
  naiyoma:
    ACK fa3f682032

Tree-SHA512: 5b1fc003b5bea4f98c1b79376b06f5565ccddaf6b4969e1b16f1225755e1c68a5fde3ccafa86d2923a92aa8a8f9c47dfd048be2ff705d7269664188cf11da3f4
2025-09-02 10:57:23 +01:00
willcl-ark 3c5da69a23
ci: remove un-needed lint_run*.sh files
ci/lint_run.sh: Only used in .cirrus.yml. Refer to test/lint/README.md on how to run locally.
ci/lint_run_all.sh: Only used in .cirrus.yml for stale re-runs of old pull request tasks.
2025-09-01 16:22:35 +01:00
will 2aa288efdd
ci: fix annoying docker warning
Docker currently warns that we are missing a default value.

Set this to scratch which will error if an appropriate image tag is not
passed in to silence the warning.
2025-09-01 16:22:34 +01:00
will dd1c5903e8
ci: add ccache hit-rate warning when < 75%
Print the ccache hit-rate for the job using a GitHub annotation if it
was below 75%.
2025-09-01 16:22:33 +01:00
will f427284483
doc: Detail configuration of hosted CI runners 2025-09-01 16:22:32 +01:00
will 3f339e99e0
ci: dynamically match makejobs with cores
Previously jobs were running on a large multi-core server where 10 jobs
as default made sense (or may even have been on the low side).

Using hosted runners with fixed (and lower) numbers of vCPUs we should
adapt compilation to match the number of cpus we have dynamically.

This is cross-platform compatible with macos and linux only.
2025-09-01 16:22:31 +01:00
will 4393ffdd83
ci: remove .cirrus.yml
Removed as unused.
2025-09-01 16:22:30 +01:00
will bc41848d00
ci: port lint
Co-authored-by: Max Edwards <youwontforgetthis@gmail.com>
2025-09-01 16:22:29 +01:00
will d290a8e6ea
ci: port msan-depends
Co-authored-by: Max Edwards <youwontforgetthis@gmail.com>
2025-09-01 16:22:28 +01:00
will 9bbae61e3b
ci: port tsan-depends
Co-authored-by: Max Edwards <youwontforgetthis@gmail.com>
2025-09-01 16:22:27 +01:00
will bf7d536452
ci: port tidy
Co-authored-by: Max Edwards <youwontforgetthis@gmail.com>
2025-09-01 16:22:26 +01:00
will 549074bc64
ci: port centos-depends-gui
Co-authored-by: Max Edwards <youwontforgetthis@gmail.com>
2025-09-01 16:22:25 +01:00
will 58e38c3a04
ci: port previous-releases-depends-debug
Co-authored-by: Max Edwards <youwontforgetthis@gmail.com>
2025-09-01 16:22:24 +01:00
will 341196d75c
ci: port fuzzer-address-undefined-integer-nodepends
Co-authored-by: Max Edwards <youwontforgetthis@gmail.com>
2025-09-01 16:22:23 +01:00
will f2068f26c1
ci: port no-IPC-i686-DEBUG
Co-authored-by: Max Edwards <youwontforgetthis@gmail.com>
2025-09-01 16:22:22 +01:00
will 2a00b12d73
ci: port nowallet-libbitcoinkernel
Co-authored-by: Max Edwards <youwontforgetthis@gmail.com>
2025-09-01 16:22:21 +01:00
will 9c2514de53
ci: port mac-cross-gui-notests
Co-authored-by: Max Edwards <youwontforgetthis@gmail.com>
2025-09-01 16:22:20 +01:00
will 2c990d84a3
ci: force reinstall of kernel headers in asan
When using hosted runners in combination with cached docker images,
there is the possibility that the host runner image is updated,
rendering the linux-headers package (stored in the cached docker image)
incompatible.

Fix this by doing a re-install of the headers package in
03_test_script.sh.

If the underlying runner kernel has not changed thie has no effect, but
prevents the job from failing if it has.
2025-09-01 16:22:19 +01:00
will 884251441b
ci: update asan-lsan-ubsan
Co-authored-by: Max Edwards <youwontforgetthis@gmail.com>
2025-09-01 16:22:18 +01:00
will f253031cb8
ci: port arm 32-bit job
Co-authored-by: Max Edwards <youwontforgetthis@gmail.com>
2025-09-01 16:22:17 +01:00
will 04e7bfbceb
ci: update windows-cross job
Co-authored-by: Max Edwards <youwontforgetthis@gmail.com>
2025-09-01 10:32:06 +01:00
will cc1735d777
ci: add job to determine runner type
To remove multiple occurances of the respository name, against which we
compare `${{ github.repository }}` to check if we should use Cirrus
Runners, introduce a helper job which can check a single environment
variable and output this as an input to subsequent jobs.

Forks can maintain a trivial patch of their repo name against the
`REPO_USE_CIRRUS_RUNNERS` variable in ci.yml if they have Cirrus Runners
of their own, which will then enable cache actions and docker build
cache to use Cirrus Cache.

It's not possible to use `${{ env.USE_CIRRUS_RUNNERS }}` in the
`runs-on:` directive as the context is not supported by GitHub.

If it was, this job would no longer be necessary.
2025-09-01 10:32:05 +01:00
will 020069e6b7
ci: add Cirrus cache host
Whilst the action cirruslabs/actions/cache will automatically set this
host, the docker `gha` build cache backend will not be aware of it.

Set the value here, which will later be used in the docker build args to
enable docker build cache on the cirrus cache.
2025-09-01 10:32:04 +01:00
will 9c2b96e0d0
ci: have base install run in right dir
This sets the build dir at build time so that Apple SDK gets installed
in the correct/expected location for the runtime to find it.

Co-authored-by: Max Edwards <youwontforgetthis@gmail.com>
2025-09-01 10:32:03 +01:00
will 18f6be09d0
ci: use docker build cache arg directly
Reverts: e87429a2d0

This was added in PR #31545 with the intention that self-hosted runners
might use it to save build cache.

As we are not using hosted runners with a registry build cache, the bulk
of this commit can be reverted, simply using the value of
$DOCKER_BUILD_CACHE_ARG in the script.

link: https://github.com/bitcoin/bitcoin/pull/31545
2025-09-01 10:32:02 +01:00
will 94a0932547
ci: use buildx in ci
Using buildx is required to properly load the correct driver, for use
with registry caching. Neither build, nor BUILDKIT=1 currently do this
properly.

Use of `docker buildx build` is compatible with podman.
2025-09-01 10:32:01 +01:00
will fdf64e5532
ci: add configure-docker action
Another action to reduce boilerplate in the main ci.yml file.

This action will set up a docker builder compatible with caching build
layers to a container registry using the `gha` build driver.

It will then configure the docker build cache args.
2025-09-01 10:32:00 +01:00
will 33ba073df7
ci: add REPO_USE_CIRRUS_RUNNERS
If set, Cirrus runners will be used on pushes to, and pull requests
against, this repository.

Forks can set this if they have their own cirrus runners.
2025-09-01 10:31:59 +01:00
will b232b0fa5e
ci: add caching actions
Add "Restore" and "Save" caching actions.

These actions reduce boilerplate in the main ci.yml configuration file.

These actions are implemented so that caches will be saved on `push`
only.

When a pull request is opened it will cache hit on the caches from the
lastest push, or in the case of depends will hit on any matching depends
hash, falling back to partial matches.

Depends caches are hashed using
`$(git ls-tree HEAD depends "ci/test/$FILE_ENV" | sha256sum | cut -d' ' -f1)`
and this hash is passed in as an input to the actions. This means we
direct cache hit in cases where depends would not be re-built, otherwise
falling back to a partial match.

Previous releases cache is hashed similarly to depends, but using the
test/get_previous_releases.py file.

The cirruslabs cache action will fallback transparently to GitHub's
cache in the case that the job is not being run on a Cirrus Runner,
making these compatible with running on forks (on free GH hardware).
2025-09-01 10:31:58 +01:00
will b8fcc9fcbc
ci: add configure environment action 2025-09-01 10:31:58 +01:00
MarcoFalke fa3f682032
test: Fixup fill_mempool docstring
The assumption was removed in commit
3eab8b7240.
2025-08-29 08:05:40 +02:00
Ava Chow 7cc9a08706
Merge bitcoin/bitcoin#33253: Revert compact block cache inefficiencies
b7b249d3ad Revert "[refactor] rewrite vTxHashes as a vector of CTransactionRef" (Anthony Towns)
b9300d8d0a Revert "refactor: Simplify `extra_txn` to be a vec of CTransactionRef instead of a vec of pair<Wtxid, CTransactionRef>" (Anthony Towns)
df5a50e5de bench/blockencodings: add compact block reconstruction benchmark (Anthony Towns)

Pull request description:

  Reconstructing compact blocks is on the hot path for block relay, so revert changes from #28391 and #29752 that made it slower. Also add a benchmark to validate reconstruction performance, and a comment giving some background as to the approach.

ACKs for top commit:
  achow101:
    ACK b7b249d3ad
  polespinasa:
    lgtm code review and tested ACK b7b249d3ad
  cedwies:
    code-review ACK b7b249d
  davidgumberg:
    crACK b7b249d3ad
  instagibbs:
    ACK b7b249d3ad

Tree-SHA512: dc266e7ac08281a5899fb1d8d0ad43eb4085f8ec42606833832800a568f4a43e3931f942d4dc53cf680af620b7e893e80c9fe9220f83894b4609184b1b3b3b42
2025-08-28 16:10:42 -07:00
merge-script 084fd68fda
Merge bitcoin/bitcoin#33258: ci: use LLVM 21
4cf0ae474b ci: use LLVM 21 (fanquake)

Pull request description:

  Use LLVM 21 in the *san & fuzz CIs.

ACKs for top commit:
  maflcko:
    lgtm ACK 4cf0ae474b
  janb84:
    ACK 4cf0ae474b
  l0rinc:
    utACK 4cf0ae474b

Tree-SHA512: bc91982060fd0cdf0fb3b2cc895a53ca374bd76f4d75c493087e23309d3f5ea870a12d9c29ac3309b338d9508dd3f0045ae524965d2875ec9174da04e13436a0
2025-08-28 19:45:06 +01:00
merge-script 6ff2d42362
Merge bitcoin/bitcoin#33189: rpc: followups for 33106
daa40a3ff9 doc fixups for 33106 (glozow)
c568511e8c test fixup for incremental feerate (glozow)
636fa219d3 test fixups (glozow)
9169a50d52 [rpc] expose blockmintxfee via getmininginfo (glozow)

Pull request description:

  Followups from #33106:
  - https://github.com/bitcoin/bitcoin/pull/33106#discussion_r2271855287
  - https://github.com/bitcoin/bitcoin/pull/33106#discussion_r2271909132
  - https://github.com/bitcoin/bitcoin/pull/33106#discussion_r2274373368
  - https://github.com/bitcoin/bitcoin/pull/33106#discussion_r2275327727
  - https://github.com/bitcoin/bitcoin/pull/33106#discussion_r2275120698
  - https://github.com/bitcoin/bitcoin/pull/33106#discussion_r2275470140
  - https://github.com/bitcoin/bitcoin/pull/33106#discussion_r2271864670
  - https://github.com/bitcoin/bitcoin/pull/33106#discussion_r2275120698
  - https://github.com/bitcoin/bitcoin/pull/33106#discussion_r2277786375
  - https://github.com/bitcoin/bitcoin/pull/33106#discussion_r2277669475
  - https://github.com/bitcoin/bitcoin/pull/33106#discussion_r2279251263

ACKs for top commit:
  ajtowns:
    ACK daa40a3ff9 ; cursory review, seems reasonable
  davidgumberg:
    ACK daa40a3ff9
  instagibbs:
    ACK daa40a3ff9

Tree-SHA512: d6f0ae5d00dadfbaf0998ac332c8536c997628de4f2b9947eb57712f05d3afa19a823c9cc007435be320640cd13a4c500db20c9606988cdd371934496dec009d
2025-08-28 19:44:31 +01:00
merge-script 4d54bb2b92
Merge bitcoin/bitcoin#33264: threading: reduce the scope of lock in getblocktemplate
493ba0f688 threading: reduce the scope of lock in getblocktemplate (kevkevinpal)

Pull request description:

  This change was motivated by https://github.com/bitcoin/bitcoin/pull/32592#discussion_r2294770722

  It does exactly what is said in the comment. Reducing the scope of the lock by a bit before it is needed

ACKs for top commit:
  stickies-v:
    re-ACK 493ba0f688
  maflcko:
    lgtm ACK 493ba0f688

Tree-SHA512: aa3a21ef3da6be6c0af78aa2dda61ee21c3f6d4d9c897413dba9e7d7d2a91e9e069bbc6b6684b45aadaa28d8603dd310f2c2d2e58c31bb4d864204e468fefaf1
2025-08-28 19:35:48 +01:00
merge-script 9ae23950ef
Merge bitcoin/bitcoin#33261: ci: return to using dash in CentOS job
509ffea40a ci: return to using dash in CentOS job (fanquake)

Pull request description:

  `dash` is available again: https://bugzilla.redhat.com/show_bug.cgi?id=2335416.

ACKs for top commit:
  maflcko:
    lgtm ACK 509ffea40a
  davidgumberg:
    ACK 509ffea40a
  janb84:
    crACK 509ffea40a

Tree-SHA512: c57194b6158f6453cadb2487be232af5e37aa2234852f04a76fc80909fbfa48c7f8dd30e7be41be67dedb7ec4886930e165fdbaf746d358bb94c6ccc49d6bde6
2025-08-28 19:28:01 +01:00
kevkevinpal 493ba0f688
threading: reduce the scope of lock in getblocktemplate 2025-08-28 08:43:21 -04:00
fanquake 509ffea40a
ci: return to using dash in CentOS job 2025-08-27 11:56:44 +01:00
MarcoFalke fabc2615af
test: Use extra_port() helper in feature_bind_extra.py 2025-08-27 09:46:26 +02:00
Anthony Towns b7b249d3ad Revert "[refactor] rewrite vTxHashes as a vector of CTransactionRef"
This reverts commit a03aef9cec.
2025-08-27 03:33:32 +10:00
Anthony Towns b9300d8d0a Revert "refactor: Simplify `extra_txn` to be a vec of CTransactionRef instead of a vec of pair<Wtxid, CTransactionRef>"
This reverts commit a8203e9412.
2025-08-27 03:33:32 +10:00
Anthony Towns df5a50e5de bench/blockencodings: add compact block reconstruction benchmark 2025-08-27 03:33:32 +10:00
fanquake 4cf0ae474b
ci: use LLVM 21 2025-08-26 17:11:45 +01:00
MarcoFalke fa96a4afea
ci: Enable CI_LIMIT_STACK_SIZE=1 in i686_no_ipc task 2025-08-26 13:20:20 +02:00
MarcoFalke facfde2cdc
test: Fix CLI_MAX_ARG_SIZE issues 2025-08-26 13:20:19 +02:00
Ava Chow 6ca6f3b37b
Merge bitcoin/bitcoin#33241: Update libmultiprocess subtree to fix build issues
dd68d0f40b Squashed 'src/ipc/libmultiprocess/' changes from b4120d34bad2..1b8d4a6f1e54 (Ryan Ofsky)

Pull request description:

  Includes:

  - https://github.com/bitcoin-core/libmultiprocess/pull/193
  - https://github.com/bitcoin-core/libmultiprocess/pull/195
  - https://github.com/bitcoin-core/libmultiprocess/pull/194

  These changes are needed to build fix libmultiprocess build issue that happens on OpenBSD and work around an incompatibility between GCC versions <14 and cap'nproto versions  <0.9 when compiling with c++20 that was fixed upstream in https://github.com/capnproto/capnproto/pull/1170. The issues were reported:

  - https://github.com/bitcoin/bitcoin/issues/33219
  - https://github.com/bitcoin/bitcoin/issues/33176
  - https://github.com/willcl-ark/bitcoin-core-docker/pull/43

  The fixes added CI jobs upstream to catch these issues earlier.

  The changes can be verified by running `test/lint/git-subtree-check.sh src/ipc/libmultiprocess` as described in [developer notes](https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#subtrees) and [lint instructions](https://github.com/bitcoin/bitcoin/tree/master/test/lint#git-subtree-checksh)

ACKs for top commit:
  Sjors:
    ACK 323b3fd272
  achow101:
    ACK 323b3fd272
  hebasto:
    ACK 323b3fd272, I've reproduced the subtree update locally. The two issues noted in this PR are unrelated to its changes and can be addressed separately.

Tree-SHA512: 3d03693d269c04d9ed10e8dd03e8059062929f37616d974c6fdf346ee62737c990ec550e013575e7474bfa4efcead3938bf9b259d62c073d76e720ebafe4ff66
2025-08-25 14:11:42 -07:00
merge-script 9703b7e6d5
Merge bitcoin/bitcoin#32592: threading: remove ancient CRITICAL_SECTION macros
46ca7712cb threading: remove unused template instantiations (Cory Fields)
b537a6a6db threading: remove obsolete critsect macros (Cory Fields)
0d0e0a39b4 threading: use a reverse lock rather than manual critsect macros (Cory Fields)
3ddd554d31 tests: Add Assertions in reverse_lock tests to exercise thread-safety annotations (Cory Fields)
c88b1cbf57 tests: get rid of remaining manual critsect usage (Cory Fields)

Pull request description:

  Now that #32467 is merged, the only remaining usage of our old `CRITICAL_SECTION` macros (other than tests) is in `getblocktemplate()` and it can safely be replaced with a `REVERSE_LOCK`.

  This PR makes that replacement, replaces the old `CRITICAL_SECTION` macro usage in tests, then deletes the macros themselves.

  ~While testing this a few weeks ago, I noticed that `REVERSE_LOCK` does not currently work properly with our thread-safety annotations as after the `REVERSE_LOCK` is acquired, clang still believes that the mutex is locked. #32465 fixes this problem. Without that fix, this PR would potentially allow a false-negative if code were added in the future to this chunk of `getblocktemplate` which required `cs_main` to be locked.~

  ~I added a test for the reverse lock here in the form of a compiler warning in `reverselock_tests.cpp` to simulate that possibility. This PR will therefore cause a new warning (and should fail a warnings-as-errors ci check) until #32465 is merged and this is rebased on top of it.~

  Edit: Rebased on top of #32465, so this should now pass tests.

ACKs for top commit:
  maflcko:
    review ACK 46ca7712cb 📌
  fjahr:
    Code review ACK 46ca7712cb
  TheCharlatan:
    ACK 46ca7712cb
  furszy:
    ACK 46ca7712cb

Tree-SHA512: 5e423c8539ed5ddd784f5c3657bbd63be509d54942c25149f04e3764bcdf897bebf655553338d5af7b8c4f546fc1d4dd4176c2bce6f4683e76ae4bb91ba2ec80
2025-08-23 17:18:29 +01:00
Ryan Ofsky dd68d0f40b Squashed 'src/ipc/libmultiprocess/' changes from b4120d34bad2..1b8d4a6f1e54
1b8d4a6f1e54 Merge bitcoin-core/libmultiprocess#194: mpgen: Work around c++20 / capnproto 0.8 incompatibility
f1fad396bf5f Merge bitcoin-core/libmultiprocess#195: ci: Add openbsd
eed42f210d17 ci: Bump all tasks to actions/checkout@v5
486a510bbeff ci: Remove ancient and problematic -lstdc++fs in mpexample
dd40897efe79 Add missing thread include
98414e7d2867 ci: Add openbsd
dc3ba2204606 cmake, doc: Add check for CVE-2022-46149
cb170d4913a2 Merge bitcoin-core/libmultiprocess#193: build: require CapnProto 0.7.0 or better
8ceeaa6ae401 ci: Add olddeps job to test old dependencies versions
c4cb758eccb5 mpgen: Work around c++20 / capnproto 0.8 incompatibility
30930dff7b06 build: require CapnProto 0.7.0 or better

git-subtree-dir: src/ipc/libmultiprocess
git-subtree-split: 1b8d4a6f1e54b92708bd2ad627ec6d440a1daf3d
2025-08-22 17:15:44 -04:00
Ryan Ofsky 323b3fd272 Merge commit 'dd68d0f40b614474f24469fbe1ba02f8f9146b31' into pr/subtree-3 2025-08-22 17:15:44 -04:00
pablomartin4btc d3c5e47391 wallet, refactor: Remove Legacy check and error
Remove dead code due to legacy wallet removal.
2025-08-22 16:49:14 -03:00
merge-script 73220fc0f9
Merge bitcoin/bitcoin#33212: index: Don't commit state in BaseIndex::Rewind
a602f6fb7b test: index with an unclean restart after a reorg (Martin Zumsande)
01b95ac6f4 index: don't commit state in BaseIndex::Rewind (Martin Zumsande)

Pull request description:

  The committed state of an index should never be ahead of the flushed chainstate.
  Otherwise, in the case of an unclean shutdown, the blocks necessary to revert
  from the prematurely committed state are not be available, which would corrupt the coinstatsindex in particular.
  Instead, the index state will be committed with the next ChainStateFlushed notification.

  Fixes #33208

ACKs for top commit:
  achow101:
    ACK a602f6fb7b
  stickies-v:
    re-ACK a602f6fb7b

Tree-SHA512: 2559ea3fe066caf746a54ad7daac5031332f3976848e937c3dc8b35fa2ce925674115d8742458bf3703b3916f04f851c26523b6b94aeb1da651ba5a1b167a419
2025-08-22 15:51:41 +01:00
Cory Fields 46ca7712cb threading: remove unused template instantiations
These were only required for the ENTER_CRITICAL_SECTION macro.
2025-08-22 14:25:39 +00:00
Cory Fields b537a6a6db threading: remove obsolete critsect macros 2025-08-22 14:25:39 +00:00
Cory Fields 0d0e0a39b4 threading: use a reverse lock rather than manual critsect macros
No functional change.
2025-08-22 14:25:39 +00:00
Cory Fields 3ddd554d31 tests: Add Assertions in reverse_lock tests to exercise thread-safety annotations 2025-08-22 14:25:39 +00:00
Cory Fields c88b1cbf57 tests: get rid of remaining manual critsect usage 2025-08-22 14:25:39 +00:00
merge-script 2c223de2af
Merge bitcoin/bitcoin#33237: doc: use new block_to_connect parameter name
1c3db0ed8e doc: use new block_to_connect parameter name (stickies-v)

Pull request description:

  The parameter name was previously changed from `pblock` to `block_to_connect` in 9ba1fff29e, without updating the documentation.

  Addresses https://github.com/bitcoin/bitcoin/pull/33078#discussion_r2279914775.

ACKs for top commit:
  purpleKarrot:
    ACK 1c3db0ed8e
  janb84:
    ACK 1c3db0ed8e
  musaHaruna:
    ACK [1c3db0e](1c3db0ed8e)

Tree-SHA512: 8b12243f1d9e5586e487dd705dc5b40ff12025bb5539eb4195f7fde4df38a9fe8eb0a9570a72f9463a2420f7307358409804fcb23bb73e32ff691ac4ef5bc35a
2025-08-22 14:13:20 +01:00
merge-script 02f6758e0c
Merge bitcoin/bitcoin#33233: doc: follow-ups to "Add bitcoin-{node,gui} to release binaries for IPC"
de65c86572 doc: capnproto instruction for Alpine and Arch (Sjors Provoost)
49d1a1a363 doc: add capnproto-devel to Fedora build instruction (Sjors Provoost)
eab5518913 doc: mark bitcoin-{node,gui} installed in files.md (Sjors Provoost)
2a815d126b doc: link to capnp version bump PR (Sjors Provoost)

Pull request description:

  - have `dependencies.md` link to the PR that updated the capnp version: https://github.com/bitcoin/bitcoin/pull/31802#discussion_r2290393840

ACKs for top commit:
  maflcko:
    lgtm ACK de65c86572
  janb84:
    re ACK de65c86572

Tree-SHA512: 842d7a89ef18a8c597ca05720c41a72e67500bc93430cf2c3b074cb2f4b936f1df58b5b1e99010e1ea5c1f8a9f8875fb9c20398f915feeacecee9b2fed3cb03c
2025-08-22 12:46:15 +01:00
merge-script 682bd04462
Merge bitcoin/bitcoin#33236: doc: Remove wrong and redundant doxygen tag
966666de9a doc: Remove wrong and redundant doxygen tag (MarcoFalke)

Pull request description:

  `param@[in]` is not a valid doxygen tag. Also, no other function in this file uses the annotations, and they are redundant with the line above, so just remove them in `feerate` to fix all issues.

  In other places, fix them.

ACKs for top commit:
  cedwies:
    ACK 966666d
  janb84:
    ACK 966666de9a
  pablomartin4btc:
    ACK 966666de9a
  w0xlt:
    ACK 966666de9a

Tree-SHA512: fcb6aa75c0f03b36f3caad023854ba276e0335cf47908a77006e182633b6a68f7b7d3115ef9fb97d143ca23730def05550f970265bb1fde97594ba68e724bde9
2025-08-22 11:27:10 +01:00
merge-script a9701de0c9
Merge bitcoin/bitcoin#33217: depends: remove xinerama extension from libxcb
decc3671c8 guix: remove libxcb-xinerama.so.0 from allowed libs (fanquake)
3d9314f383 depends: remove xinerama extension from libxcb (fanquake)

Pull request description:

  This is listed on https://doc.qt.io/qt-5.15/linux-requirements.html as "recommended", and doesn't seem to be needed (only used for windowing over multiple screens support?) , and the fact that it's no-longer installed by default on modern linux distros (i.e Ubuntu), is annoying/confusing for users. See:

  https://github.com/bitcoin/bitcoin/issues/30061
  https://github.com/bitcoin/bitcoin/issues/32097
  https://github.com/bitcoin/bitcoin/pull/33197
  https://bitcoin.stackexchange.com/questions/122646/libxcb-xinerama0-library-required-by-bitcoin-qt

  I haven't tested the GUI with these changes. Just opening an alternative to #33197. Note that we also already have `libxcb-cursor0` documented as a potentially missing runtime dependency (see `build-unix.md`).

ACKs for top commit:
  hebasto:
    ACK decc3671c8.

Tree-SHA512: 4131e665a0c48a866d2a6d1d3909a19481c20cf69c19ab14de63b379f73bff5151759b63504857f5ed2e01f58b895def1b7db532323ecc353fcd11493aa45c90
2025-08-22 11:06:53 +01:00
Ava Chow 78351ed083
Merge bitcoin/bitcoin#33222: miner: clamp options instead of asserting
7392b8b084 miner: clamp options instead of asserting (Pieter Wuille)

Pull request description:

  The `BlockAssembler::ClampOptions` function currently doesn't actually clamp most of the provided settings, but asserts that some are in range. This made sense while it was a purely internal interface.

  However, with the mining IPC interface exposed in #30510, these options are now externally accessible, and it is not entirely intuitive how to set them. In particular, calling `Mining::createNewBlock` with a default-constructed `BlockCreateOptions` will right now instantly crash the bitcoin node.

  This isn't a security issue, as the IPC interface is considered trusted, but it is highly unexpected I think, and rather unergonomical to have the node crash while developing against the interface.

  An alternative would be exposing a way for the interface to return a failure, but I think in this case, just correcting to reasonable values is acceptable.

ACKs for top commit:
  Sjors:
    ACK 7392b8b084
  achow101:
    ACK 7392b8b084
  stickies-v:
    ACK 7392b8b084
  ryanofsky:
    Code review ACK 7392b8b084. I think ideally this would throw an exception and return a clear error to the caller, or maybe log as stickies suggested, but clamping is much better than crashing.

Tree-SHA512: 7a1e05b68edbf57beb682ee63e27666f42af6a2b70a81874d368a2cb10d107a589e0a388658c1039330b8cc9f6048479870095a9d552ca387a250ac118c1abf2
2025-08-21 13:58:23 -07:00
Sjors Provoost de65c86572
doc: capnproto instruction for Alpine and Arch 2025-08-21 18:29:21 +02:00
Sjors Provoost 49d1a1a363
doc: add capnproto-devel to Fedora build instruction
Co-authored-by: maflcko <6399679+maflcko@users.noreply.github.com>
2025-08-21 18:15:50 +02:00
Martin Zumsande a602f6fb7b test: index with an unclean restart after a reorg
This test fails without the previous commit.
2025-08-21 17:42:04 +02:00
Martin Zumsande 01b95ac6f4 index: don't commit state in BaseIndex::Rewind
The committed state of an index should never
be ahead of the flushed chainstate. Otherwise, in the case
of an unclean shutdown, the blocks necessary to revert
from the prematurely committed state would not be
available, which would corrupt the coinstatsindex in particular.
Instead, the index state will be committed with the next
ChainStateFlushed notification.
2025-08-21 17:41:42 +02:00
stickies-v 1c3db0ed8e
doc: use new block_to_connect parameter name
This was previously changed in 9ba1fff29e,
without updating the documentation.

Co-authored-by: stringintech <stringintech@gmail.com>
2025-08-21 15:54:02 +01:00
merge-script 8333aa5302
Merge bitcoin/bitcoin#32523: wallet: Remove isminetypes
be776a1443 wallet: Remove isminetype (Ava Chow)
009a69a616 wallet: Remove ISMINE_USED (Ava Chow)
6a7aa01574 wallet: Remove COutput::spendable and AvailableCoinsListUnspent (Ava Chow)
620abe985e interfaces, gui: Remove is_mine output parameter from getAddress (Ava Chow)

Pull request description:

  The remaining isminetypes are `ISMINE_SPENDABLE` and `ISMINE_USED`.

  `ISMINE_USED` is only used as a filter for caching balances and is never actually returned from `IsMine`. Since we do still want this behavior, This PR changes the caching to utilize bools and explicit members variables to account for the avoid_reuse case. This allows us to remove `ISMINE_USED`.

  `ISMINE_SPENDABLE` and `ISMINE_NO` are the only things that are returned by `IsMine`. This is a bool, so it can be replaced as such.

  After removing `ISMINE_USED` and `ISMINE_SPENDABLE`, we are able to remove isminetypes altogether.

ACKs for top commit:
  murchandamus:
    ACK be776a1443
  fjahr:
    reACK be776a1443
  davidgumberg:
    crACK be776a1443
  enirox001:
    re-ACK be776a1
  jlest01:
    reACK be776a1443

Tree-SHA512: 689759f6a6ba20a1ae988b0c3abacb15424844f29a1ec2fcb2d1ca9d87b44ae68313e8f61d6fd310281b681144f0ade67e90fcfab807e982b52ed99441d9c987
2025-08-21 15:52:49 +01:00
Sjors Provoost eab5518913
doc: mark bitcoin-{node,gui} installed in files.md 2025-08-21 15:20:20 +02:00
MarcoFalke 966666de9a
doc: Remove wrong and redundant doxygen tag
Remove it in feerate.

Fix it in the other places.
2025-08-21 15:16:54 +02:00
fanquake af4156ab75
build: set ENABLE_IPC to OFF when fuzzing
Currently a `BUILD_FOR_FUZZING` build will failure to configure, with
missing `capnp`.
2025-08-21 12:16:13 +01:00
Sjors Provoost 2a815d126b
doc: link to capnp version bump PR 2025-08-21 12:10:06 +02:00
fanquake decc3671c8
guix: remove libxcb-xinerama.so.0 from allowed libs 2025-08-20 23:04:20 +01:00
fanquake 3d9314f383
depends: remove xinerama extension from libxcb
This is listed on https://doc.qt.io/qt-5.15/linux-requirements.html as
"recommended", however doesn't seem to be needed, and the fact that it's
no-longer installed by default on modern linux distros, is
annoying/confusing for users. See:

https://github.com/bitcoin/bitcoin/issues/30061
https://bitcoin.stackexchange.com/questions/122646/libxcb-xinerama0-library-required-by-bitcoin-qt
https://github.com/bitcoin/bitcoin/pull/33197
https://github.com/bitcoin/bitcoin/issues/32097
2025-08-20 23:04:19 +01:00
Ryan Ofsky 7d9789401b
Merge bitcoin/bitcoin#31802: Add bitcoin-{node,gui} to release binaries for IPC
ce7d94a492 doc: add release note (Sjors Provoost)
71f29d4fa9 doc: update build and dependencies docs for IPC (Sjors Provoost)
3cbf747c32 cmake: set ENABLE_IPC by default (Sjors Provoost)
32a90e1b90 ci: use bitcoin-node for one depends job (Sjors Provoost)
b333cc14d5 ci: build one depends job without multiprocess (Sjors Provoost)
16bce9ac4c build: depends makes libmultiprocess by default (Sjors Provoost)

Pull request description:

  Have depends make libmultiprocess by default. This PR causes the following behavior changes:

  1. **bitcoin-node and bitcoin-gui binaries are included in releases**, due to `ENABLE_IPC` option being switched on by default in depends builds
  2. `ENABLE_IPC` is also switched on by default in non-depends builds (instructions updated, #33190 does this as a standalone PR)
  3. Various changes to CI: switching on `ENABLE_IPC` on in most configurations and using `bitcoin-node` binary (`bitcoin -m`) for functional tests in two of them.
  4. The `bitcoin-node` and `bitcoin-gui` are added to `Maintenance.cmake` (since they're now in the release)

  This PR doesn't need to do all of these things at once. However it's is simpler, avoids code churn (especially in CI), and  probably less confusing to make all these changes in the same PR.

  Windows is not supported yet, so `ENABLE_IPC` is off by default for it. It can be enabled after https://github.com/bitcoin/bitcoin/pull/32387.

  The initial main use case for IPC is to enable experimental support for the Mining IPC interface. A working example of a Stratum v2 Template Provider client using this interface can be found here: https://github.com/Sjors/bitcoin/pull/48.

  See #31756 for discussion of when this should happen. Supersedes #30975.

  ## Wait what, why?

  The [Stratum v2 spec](https://stratumprotocol.org/specification) has been around for a few years now, mostly stable but with [ongoing activity](https://github.com/stratum-mining/sv2-spec/commits/main/) to clarify and fix more subtle issues encountered by implementers. Most of the implementation is built in Rust in a project called the Stratum Reference Implementation ([SRI](https://github.com/stratum-mining/stratum)).

  [Braiins](https://demand.work) added Stratum v2 support to both their (custom) firmware and pool several years ago, though they have fallen behind on recent spec changes (update: it seems they've fixed that). Apparently [new hardware is underway](https://github.com/bitcoin/bitcoin/pull/31802#issuecomment-3189623427) that supports Stratum v2 without the need for custom firmware.

  [DMND pool](https://www.dmnd.work) is Stratum v2 native from the start and employs several of the SRI developers (they haven't fully launched though). The industry is rather secretive, but apparently [there is more underway](https://github.com/bitcoin/bitcoin/pull/31802#issuecomment-3190601926).

  What does Bitcoin Core have to do with this? Well, in Stratum v2 jargon we are the Template Provider.

  Or at least, the Template Provider role needs us to make block templates. Initially back in 2023 the plan was to have Bitcoin Core implement this role entirely, see #23049. It would speak the sv2 encrypted message protocol. In fact the spec was designed around this assumption, making sure to only use cryptographic primitives already in our codebase.

  I took over that effort in late 2023, but during 2024 it became quite clear there was [strong resistance](https://github.com/bitcoin/bitcoin/pull/29432#pullrequestreview-2132699185) to the idea of including all this new code, opening another network ports, etc.

  At the same time there was the long running multiprocess / IPC project #10102, and the idea was born to apply that here: instead of including Stratum v2 specific stuff, we offer a general Mining interface via an IPC connection that can e.g. push out fresh block templates as fees rise above a threshold (something not possible and/or very inefficient with `getblocktemplate`). A client sidecar application then sits between the Stratum v2 world and our node.

  Currently there's only one such sidecar application, maintained by me, and reusing the same codebase from the integrated approach. An attempt has been made to connect to our interface from Rust https://github.com/bitcoin-core/libmultiprocess/issues/174, which would pave the way for SRI include the Template Provider role. Plebhash below indicates he's also working on that: https://github.com/bitcoin/bitcoin/pull/31802#issuecomment-3191547244.

  So with this new approach in mind, between mid 2024 until spring 2025, I introduced a new Mining interface (#30200 - #31785). At the same time Russ Ryanosky worked on more tight integration of [libmultiprocess](https://github.com/bitcoin-core/libmultiprocess), including making it a subtree in #31741. See [design/multiprocess.md](https://github.com/bitcoin/bitcoin/blob/master/doc/design/multiprocess.md).

  Meanwhile I've been maintaining a fork of Bitcoin Core that includes the Template Provider, in the original integrated approach (https://github.com/Sjors/bitcoin/pull/68) as well as an IPC + sidecar variant (https://github.com/Sjors/bitcoin/pull/48). I've been shipping [regular releases](https://github.com/Sjors/bitcoin/releases), mostly after bug fixes or major rebases. The SRI team has been testing both variants, though the "official" [instruction on their web page](https://stratumprotocol.org/developers) is to stick to integrated version. Bug reports on [my repo fork](https://github.com/Sjors/bitcoin/issues?q=is%3Aissue) as well as on the [SRI repo](https://github.com/stratum-mining/stratum/issues?q=is%3Aissue%20%20label%3A%22template%20provider%22) are evidence of actual testing happening.

  But as Pavlenex writes below:

  > one recurring feedback I kept getting regardless of the size/type of miner is that the need to run a forked version of Bitcoin Core remains a significant barrier to adoption

  This PR gets rids of that significant barrier. People can download a "pristine" version of Bitcoin Core and the only change is to start it with `bitcoin node -m -ipcconnect=unix` instead of the usual `bitcoind`.

  Once that's released, I can dramatically simplify my sidecar codebase (https://github.com/Sjors/bitcoin/pull/48) by removing pretty much all Bitcoin Core code  that it doesn't need. My plan is to then make that a separate repository, which should be much easier to contribute to. I can then also make (deterministically built) signed releases, while making it clear that sidecar code has nothing to do with Bitcoin Core. Perhaps later on SRI implements the same and I can stop maintaining that project.

  Conceptually the situation will be a lot clearer;
  - today: download forked version of `bitcoind` (or a forked version of `bitcoin-node`, plus `bitcoin-mine`), install SRI stuff
  - tomorrow: download Bitcoin Core v30, install `bitcoin-mine` and SRI
  - future: download Bitcoin Core v30 and SRI

  <details>
  <summary>
  Guix hashes:
  </summary>

  ```
  find guix-build-$(git rev-parse --short=12 HEAD)/output/ -type f -print0 | env LC_ALL=C sort -z | xargs -r0 sha256sum
  6dbf29baecb1d1593087ef1306ae7c78aa160c8beb04dc016e02549ae2d6d90d  guix-build-ce7d94a492e6/output/aarch64-linux-gnu/SHA256SUMS.part
  4b465e5e8f9652c176aa57cfe5c289267c28c3a3c684034a9ce471b529b95275  guix-build-ce7d94a492e6/output/aarch64-linux-gnu/bitcoin-ce7d94a492e6-aarch64-linux-gnu-debug.tar.gz
  85bc6fa008b83419d96443d9dcc212b46f0992387fd58fd2dda5da76536ee22c  guix-build-ce7d94a492e6/output/aarch64-linux-gnu/bitcoin-ce7d94a492e6-aarch64-linux-gnu.tar.gz
  5ed9ea52a8bd55361d2d9c01fbd1b25ec9970530c2776e6c1959424ba1689f52  guix-build-ce7d94a492e6/output/arm-linux-gnueabihf/SHA256SUMS.part
  2e483011fac64462d3aa000b577c3c05c825506032d879e39612e096d7a6c65b  guix-build-ce7d94a492e6/output/arm-linux-gnueabihf/bitcoin-ce7d94a492e6-arm-linux-gnueabihf-debug.tar.gz
  7ff1e3ba54944a2be89dd7d68cb91dff6f8950de9d7b521e15dfb746965f81bd  guix-build-ce7d94a492e6/output/arm-linux-gnueabihf/bitcoin-ce7d94a492e6-arm-linux-gnueabihf.tar.gz
  abdf89e701b21b8c1238a8cec46aeaa55e0c3a0b88ad718636e89cde9813ca08  guix-build-ce7d94a492e6/output/arm64-apple-darwin/SHA256SUMS.part
  fb55cff0296cd5474811fe5cedcf28603628729dd085eeefa007c72582459b33  guix-build-ce7d94a492e6/output/arm64-apple-darwin/bitcoin-ce7d94a492e6-arm64-apple-darwin-codesigning.tar.gz
  e9aa566b1e79c467d7987b7c68fa608db788e6ddf89c4d90e524cd47b4faaf86  guix-build-ce7d94a492e6/output/arm64-apple-darwin/bitcoin-ce7d94a492e6-arm64-apple-darwin-unsigned.tar.gz
  bb428fc62a1230a55f49fa3b5c7ba8d588e8fed491357f890d5a6724a38b14e9  guix-build-ce7d94a492e6/output/arm64-apple-darwin/bitcoin-ce7d94a492e6-arm64-apple-darwin-unsigned.zip
  5ef4b75e94b2c8265fbc588bbb42467a84438af969fddac0ea61ced3e4113345  guix-build-ce7d94a492e6/output/dist-archive/bitcoin-ce7d94a492e6.tar.gz
  4f55d56a108c8f312a502cd5dfdf0840b091861a6d502df31caf4636a203697a  guix-build-ce7d94a492e6/output/powerpc64-linux-gnu/SHA256SUMS.part
  66c5b1242c60e37098885a00e24efe19baee4afcd2e3d6407207523d8872f055  guix-build-ce7d94a492e6/output/powerpc64-linux-gnu/bitcoin-ce7d94a492e6-powerpc64-linux-gnu-debug.tar.gz
  d9dbbee7217544eda26e77158cd82caeaef2b40fb9fc7033323e7ffe64264109  guix-build-ce7d94a492e6/output/powerpc64-linux-gnu/bitcoin-ce7d94a492e6-powerpc64-linux-gnu.tar.gz
  d9b808cc5685c819abcebb4ace65f003ebc4bfedf3fca046b34de37994358782  guix-build-ce7d94a492e6/output/riscv64-linux-gnu/SHA256SUMS.part
  eeeea470b1cf76515bfae14c779a3ea356d89f719d1fef1a81e8f0d6b04ab747  guix-build-ce7d94a492e6/output/riscv64-linux-gnu/bitcoin-ce7d94a492e6-riscv64-linux-gnu-debug.tar.gz
  9993da4eb51618b8bd25ec88cc576496720e5589315e9eba6f3ddab25f9c3e60  guix-build-ce7d94a492e6/output/riscv64-linux-gnu/bitcoin-ce7d94a492e6-riscv64-linux-gnu.tar.gz
  1b5a676580e0e79598d182f6ebbb05fb8aee2381edc3c09c042cae2600f448ab  guix-build-ce7d94a492e6/output/x86_64-apple-darwin/SHA256SUMS.part
  9152122d95a34d5df75305c6883c87707e7b09033fffd08e264d703ed177ef12  guix-build-ce7d94a492e6/output/x86_64-apple-darwin/bitcoin-ce7d94a492e6-x86_64-apple-darwin-codesigning.tar.gz
  2793f75730dbef6bdf12b5ed7135e22ed21178abff2926dee92843837d4ab544  guix-build-ce7d94a492e6/output/x86_64-apple-darwin/bitcoin-ce7d94a492e6-x86_64-apple-darwin-unsigned.tar.gz
  e89aafd7e4a330a41f470e8f0a91ea876fad7d19547b404600867413f1a8ccb7  guix-build-ce7d94a492e6/output/x86_64-apple-darwin/bitcoin-ce7d94a492e6-x86_64-apple-darwin-unsigned.zip
  955b27f881927a86da3c566357ad8ca68dbe17e9652bde8c482a57ceacba92cb  guix-build-ce7d94a492e6/output/x86_64-linux-gnu/SHA256SUMS.part
  fd012be97bdf5c75ac12ddef21526bfdb5e17ecc77cde9c34d832194b0dc3293  guix-build-ce7d94a492e6/output/x86_64-linux-gnu/bitcoin-ce7d94a492e6-x86_64-linux-gnu-debug.tar.gz
  0ecf7f80e9049369760d0e27fe6c026391ab25eae0f42336bef43e51a2621726  guix-build-ce7d94a492e6/output/x86_64-linux-gnu/bitcoin-ce7d94a492e6-x86_64-linux-gnu.tar.gz
  2e8085f5fecc246d841b0bf6f28ecd0684a6cee49252fc88c1019d7586c7b7a2  guix-build-ce7d94a492e6/output/x86_64-w64-mingw32/SHA256SUMS.part
  c60041e8137eda352557254c5f67fb83eeb97ecfec342ee528451bd44ee4523a  guix-build-ce7d94a492e6/output/x86_64-w64-mingw32/bitcoin-ce7d94a492e6-win64-codesigning.tar.gz
  b1be6b2f4de1c69c2e0e4de6dd97a4891ae9eb50d89435ef47247b5a187915a9  guix-build-ce7d94a492e6/output/x86_64-w64-mingw32/bitcoin-ce7d94a492e6-win64-debug.zip
  bfe143f41a20c537145c7044aca889b28efe19072b0150042a3bd865983b3d7e  guix-build-ce7d94a492e6/output/x86_64-w64-mingw32/bitcoin-ce7d94a492e6-win64-setup-unsigned.exe
  94a906b83d84db7b25f7e3cfdce2a2030243f2ee6cc70b1fc088459f0b2f382d  guix-build-ce7d94a492e6/output/x86_64-w64-mingw32/bitcoin-ce7d94a492e6-win64-unsigned.zip
  ```

  </details>

ACKs for top commit:
  ryanofsky:
    Code review ACK ce7d94a492. This was just rebased to fix a conflict since last review.
  josibake:
    ACK ce7d94a492
  achow101:
    ACK ce7d94a492
  ismaelsadeeq:
    ACK ce7d94a492 and tested again on macOS by building via depends and source.
  janb84:
    ACK ce7d94a492

Tree-SHA512: f7ab72933854e9dfce5746cdf764944bc26eec815f97cd0aa6b54fa499c3cccb1b678861ef5c1c793de28153d46bbb6e4d1b9aa0652163b74262e2d55ec8b813
2025-08-20 17:29:07 -04:00
Ava Chow 04c115dfde
Merge bitcoin/bitcoin#33078: kernel: improve BlockChecked ownership semantics
1d9f1cb4bd kernel: improve BlockChecked ownership semantics (stickies-v)
9ba1fff29e kernel: refactor: ConnectTip to pass block pointer by value (stickies-v)

Pull request description:

  Subscribers to the BlockChecked validation interface event may need access to the block outside of the callback scope. Currently, this is only possible by copying the block, which makes exposing this validation interface event publicly either cumbersome or with significant copy overhead.

  By using shared_ptr, we make the shared ownership explicit and allow users to safely use the block outside of the callback scope. By using a const-ref shared_ptr, no atomic reference count cost is incurred if a subscriber does not require block ownership.

  For example: in  #30595, this would allow us to drop the `kernel_BlockPointer` handle entirely, and generalize everything into `kernel_Block`. This PoC is implemented in https://github.com/stickies-v/bitcoin/commits/kernel/remove-blockpointer/.

  ---

  ### Performance

  I have added a benchmark in a [separate branch](https://github.com/stickies-v/bitcoin/commits/2025-07/validation-interface-ownership-benched/), to ensure this change does not lead to a problematic performance regression. Since most of the overhead comes from the subscribers, I have added scenarios for `One`, `Two`, and `Ten` subscribers. From these results, it appears there is no meaningful performance difference on my machine.

  When `BlockChecked()` takes a `const CBlock&` reference _(master)_:
  |               ns/op |                op/s |    err% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------:|:----------
  |              170.09 |        5,879,308.26 |    0.3% |      0.01 | `BlockCheckedOne`
  |            1,603.95 |          623,460.10 |    0.5% |      0.01 | `BlockCheckedTen`
  |              336.00 |        2,976,173.37 |    1.1% |      0.01 | `BlockCheckedTwo`

  When `BlockChecked()` takes a `const std::shared_ptr<const CBlock>&` _(this PR)_:
  |               ns/op |                op/s |    err% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------:|:----------
  |              172.20 |        5,807,155.33 |    0.1% |      0.01 | `BlockCheckedOne`
  |            1,596.79 |          626,254.52 |    0.0% |      0.01 | `BlockCheckedTen`
  |              333.38 |        2,999,603.17 |    0.3% |      0.01 | `BlockCheckedTwo`

ACKs for top commit:
  achow101:
    ACK 1d9f1cb4bd
  w0xlt:
    reACK 1d9f1cb4bd
  ryanofsky:
    Code review ACK 1d9f1cb4bd. These all seem like simple changes that make sense
  TheCharlatan:
    ACK 1d9f1cb4bd
  yuvicc:
    Code Review ACK 1d9f1cb4bd

Tree-SHA512: 7ed0cccb7883dbb1885917ef749ab7cae5d60ee803b7e3145b2954d885e81ba8c9d5ab1edb9694ce6b308235c621094c029024eaf99f1aab1b47311c40958095
2025-08-20 10:45:36 -07:00
merge-script bc797d2271
Merge bitcoin/bitcoin#33154: test: use local `CBlockIndex` in block read hash mismatch check
cb173b8e93 test: use local `CBlockIndex` in block read hash mismatch test to avoid data race (Lőrinc)

Pull request description:

  Avoid mutating the shared active tip `CBlockIndex` in the `blockmanager_readblock_hash_mismatch` test.
  Instead, construct a local `CBlockIndex` with only the required fields set, ensuring the test remains self-contained and hopefully eliminating the data race reported in https://github.com/bitcoin/bitcoin/issues/33150.

ACKs for top commit:
  stickies-v:
    ACK cb173b8e93
  maflcko:
    lgtm ACK cb173b8e93

Tree-SHA512: 790528db0659f8cc5b87ed2b316bf274af68edc6158b0ce8821baccddf8d9bc4074afcb7260e3a61d5013d24ab51cc5c31e36693b8fb5ab913a44229fd6ad36b
2025-08-20 17:42:24 +01:00
merge-script d3c58a5be9
Merge bitcoin/bitcoin#33193: Release: Prepare "Translation string freeze" step
0df2c3c42e qt: Update `src/qt/locale/bitcoin_en.xlf` translation source file (Hennadii Stepanov)

Pull request description:

  This PR follows our [Release Process](53a996f122/doc/release-process.md).

  It is required for the translation string freeze, as the following PRs introduced new translatable strings:
   - #31296:7b4a1350df/src/wallet/wallet.h (L945)

  - #31453:7b4a1350df/src/init.cpp (L1878-L1879)

  - #32896:22e689587a/src/wallet/spend.cpp (L288-L292)

  **Notes for reviewers:**

  1. To reproduce the diff, run:
  ```
  cmake --preset dev-mode
  cmake --build build_dev_mode --target translate
  ```

  2. The structure of `bitconstrings.cpp` has been altered due to #33209.

  3. The diff in `bitcoin_en.xlf` contains many unrelated metadata changes, so it may be easier to verify the changes in `bitcoin_en.ts`.

ACKs for top commit:
  janb84:
    re ACK 0df2c3c42e

Tree-SHA512: be87c096ef99ce7148d046f30427bc1480cb72b080eb8537a4eda3dfe4e856eeaa50cf6efb9a1c6af3d15e1123ec87a07101c539c066a8d4dd6afb817cd95137
2025-08-20 17:26:55 +01:00
merge-script 9cf7b3d90c
Merge bitcoin/bitcoin#33211: test: modify logging_filesize_rate_limit params
5dda364c4b test: modify logging_filesize_rate_limit params (Eugene Siegel)

Pull request description:

  Change `time_window` from 20s to 1h so `Reset` is not accidentally called if the test takes a while.

  Change `num_lines` from 1024 to 10 since `LogRateLimiter` is parameterized and does not require logging 1MiB of data.

  Fixes #33195

ACKs for top commit:
  stickies-v:
    re-ACK 5dda364c4b for more helpful failure logging, no other changes
  janb84:
    re ACK 5dda364c4b
  dergoegge:
    utACK 5dda364c4b

Tree-SHA512: f781402a3a47abc26314ee7cdf6c74e77da9b9d0dde44ba52e3c42f6c400830147554d7875e7d1217a2a378383e56d87e9712c84e877bb448112f703b87a52b1
2025-08-20 10:30:04 +01:00
Lőrinc 2885bd0e1c doc: unify `datacarriersize` warning with release notes
Unified the deprecation warning for the recently deprecated datacarrier[size] options to match the phrasing of release-notes-32406.md.
2025-08-19 20:34:07 -07:00
Ava Chow be776a1443 wallet: Remove isminetype
Since the only remaining isminetypes are ISMINE_NO and ISMINE_SPENDABLE,
this enum is now just a bool and can be removed. IsMine is changed to
return a bool and any usage of isminetypes and isminefilters are changed
to be the remaining ISMINE_SPENDABLE case.
2025-08-19 14:49:37 -07:00
Ava Chow 009a69a616 wallet: Remove ISMINE_USED
This isminetype is not a real isminetype as it is never returned by
IsMine. This is only used for isminefilters in one function, which can
be better represented with a bool parameter avoid_reuse.
2025-08-19 14:49:37 -07:00
Ava Chow 6a7aa01574 wallet: Remove COutput::spendable and AvailableCoinsListUnspent
In descriptor wallets, we consider all outputs to be spendable as we no
longer have mixed mine and watchonly in a wallet. As such,
COutput::spendable is meaningless and can be removed.

Furthermore, CoinFilterParams::only_spendable can be removed as that was
essentially checking for COutput::spendable.

Lastly, AvailableCoinsListUnspent can also be removed as the wrapper is
now only setting the feerate to std::nullopt which is trivial enough that
a dedicated wrapper is not needed.
2025-08-19 14:49:37 -07:00
Pieter Wuille 7392b8b084 miner: clamp options instead of asserting 2025-08-19 16:52:02 -04:00
Ava Chow f5f853d952
Merge bitcoin/bitcoin#32878: index: fix wrong assert of current_tip == m_best_block_index
3aef38f44b test: exercise index reorg assertion failure (furszy)
acf50233cd index: fix wrong assert of current_tip == m_best_block_index (Hao Xu)

Pull request description:

  In BaseIndex::Sync(), pindex in `Rewind(pindex, pindex_next->pprev)` isn't always equal to m_best_block_index since m_best_block_index is updated every SYNC_LOCATOR_WRITE_INTERVAL seconds, during which multiple pindex update could happen. Thus the assert here is wrong.

ACKs for top commit:
  achow101:
    ACK 3aef38f44b
  furszy:
    ACK 3aef38f
  mzumsande:
    Code Review ACK 3aef38f44b

Tree-SHA512: 3ef9cc6dfdec10a9f95d7414c6a11aa216e4cf5974440d80ab19fc919abd2a3bd4c875718c9dc94523c33826f8582ec5a016374deb8fb2d35cd2fb7799b5c82e
2025-08-19 12:19:52 -07:00
Ava Chow 620abe985e interfaces, gui: Remove is_mine output parameter from getAddress
The is_mine output parameter is never used by any callers.
2025-08-19 10:16:57 -07:00
Eugene Siegel 5dda364c4b test: modify logging_filesize_rate_limit params
Change time_window from 20s to 1h so Reset is not accidentally called
if the test takes a while.

Change num_lines from 1024 to 10 since LogRateLimiter is parameterized
and does not require logging 1MiB of data.

Co-Authored-By: stickies-v <stickies-v@protonmail.com>
2025-08-19 10:25:30 -04:00
Hennadii Stepanov 0df2c3c42e
qt: Update `src/qt/locale/bitcoin_en.xlf` translation source file
Steps to reproduce the diff:
```
cmake --preset dev-mode
cmake --build build_dev_mode --target translate
```
2025-08-19 14:32:42 +01:00
merge-script 22e689587a
Merge bitcoin/bitcoin#33209: cmake: Drop python dependency for translate
3c4a109aa8 cmake: Drop python dependency for translate (Daniel Pfeifer)

Pull request description:

  Translate the `share/qt/extract_strings_qt.py` script to CMake. This removes the python dependency from the `translate` target.

  Resolves #33146

ACKs for top commit:
  hebasto:
    re-ACK 3c4a109aa8.
  janb84:
    re ACK 3c4a109aa8

Tree-SHA512: 4fda8efd4301c49eef8bf2908073475fcff3f995cf6860187f8d08821559612303b303052c1e54a01ad31703fe63aea01e999d08f5471f2c479c97de8c240605
2025-08-19 13:47:39 +01:00
Hennadii Stepanov c0d28c8f5b
qt: Fix compatibility with `-debuglogfile` command-line option
This change avoids hardcoding the "debug.log" filename, ensuring
compatibility with custom filenames provided via the `-debuglogfile`
command-line option.
2025-08-19 11:27:45 +01:00
merge-script be356fc49b
Merge bitcoin/bitcoin#32896: wallet, rpc: add v3 transaction creation and wallet support
5c8bf7b39e doc: add release notes for version 3 transactions (ishaanam)
4ef8065a5e test: add truc wallet tests (ishaanam)
5d932e14db test: extract `bulk_vout` from `bulk_tx` so it can be used by wallet tests (ishaanam)
2cb473d9f2 rpc: Support version 3 transaction creation (Bue-von-hon)
4c20343b4d rpc: Add transaction min standard version parameter (Bue-von-hon)
c5a2d08011 wallet: don't return utxos from multiple truc txs in AvailableCoins (ishaanam)
da8748ad62 wallet: limit v3 tx weight in coin selection (ishaanam)
85c5410615 wallet: mark unconfirmed v3 siblings as mempool conflicts (ishaanam)
0804fc3cb1 wallet: throw error at conflicting tx versions in pre-selected inputs (ishaanam)
cc155226fe wallet: set m_version in coin control to default value (ishaanam)
2e9617664e  wallet: don't include unconfirmed v3 txs with children in available coins (ishaanam)
ec2676becd wallet: unconfirmed ancestors and descendants are always truc (ishaanam)

Pull request description:

  This PR Implements the following:
  - If creating a v3 transaction, `AvailableCoins` doesn't return unconfirmed v2 utxos (and vice versa)
  - `AvailableCoins` doesn't return an unconfirmed v3 utxo if its transaction already has a child
  - If a v3 transaction is kicked out of the mempool by a sibling, mark the sibling as a mempool conflict
  - Throw an error if pre-selected inputs are of the wrong transaction version
  - Allow setting version to 3 manually in `createrawtransaction` (uses commits from #31936)
  - Limits a v3 transaction weight in coin selection

  Closes #31348

  To-Do:
  - [x] Test a v3 sibling conflict kicking out one of our transactions from the mempool
  - [x] Implement separate size limit for TRUC children
  - [x] Test that we can't fund a v2 transaction when everything is v3 unconfirmed
  - [x] Test a v3 sibling conflict being removed from the mempool
  - [x] Test limiting v3 transaction weight in coin selection
  - [x] Simplify tests
  - [x] Add documentation
  - [x] Test that user-input max weight is not overwritten by truc max weight
  - [x] Test v3 in RPCs other than `createrawtransaction`

ACKs for top commit:
  glozow:
    reACK 5c8bf7b39e
  achow101:
    ACK 5c8bf7b39e
  rkrux:
    ACK 5c8bf7b39e

Tree-SHA512: da8aea51c113e193dd0b442eff765bd6b8dc0e5066272d3e52190a223c903f48788795f32c554f268af0d2607b5b8c3985c648879cb176c65540837c05d0abb5
2025-08-19 06:00:50 -04:00
Daniel Pfeifer 3c4a109aa8
cmake: Drop python dependency for translate
Resolves #33146
2025-08-19 10:00:05 +02:00
merge-script f58de8749e
Merge bitcoin/bitcoin#32345: ipc: Handle unclean shutdowns better
2581258ec2 ipc: Handle bitcoin-wallet disconnections (Ryan Ofsky)
2160995916 ipc: Add Ctrl-C handler for spawned subprocesses (Ryan Ofsky)
0c28068ceb doc: Improve IPC interface comments (Ryan Ofsky)
7f65aac78b ipc: Avoid waiting for clients to disconnect when shutting down (Ryan Ofsky)
6eb09fd614 test: Add unit test coverage for Init and Shutdown code (Ryan Ofsky)
9a9fb19536 ipc: Use EventLoopRef instead of addClient/removeClient (Ryan Ofsky)
e886c65b6b Squashed 'src/ipc/libmultiprocess/' changes from 27c7e8e5a581..b4120d34bad2 (Ryan Ofsky)

Pull request description:

  This PR fixes various problems when IPC connections are broken or hang which were reported in https://github.com/bitcoin-core/libmultiprocess/issues/123, https://github.com/bitcoin-core/libmultiprocess/issues/176, and https://github.com/bitcoin-core/libmultiprocess/pull/182. The different fixes are described in commit messages.

  ---

  The first two commits of this PR update the libmultiprocess subtree including the following PRs:

  - https://github.com/bitcoin-core/libmultiprocess/pull/181
  - https://github.com/bitcoin-core/libmultiprocess/pull/179
  - https://github.com/bitcoin-core/libmultiprocess/pull/160
  - https://github.com/bitcoin-core/libmultiprocess/pull/184
  - https://github.com/bitcoin-core/libmultiprocess/pull/187
  - https://github.com/bitcoin-core/libmultiprocess/pull/186
  - https://github.com/bitcoin-core/libmultiprocess/pull/192

  The subtree changes can be verified by running `test/lint/git-subtree-check.sh src/ipc/libmultiprocess` as described in [developer notes](https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#subtrees) and [lint instructions](https://github.com/bitcoin/bitcoin/tree/master/test/lint#git-subtree-checksh).

  The remaining commits are:

  - [`9a9fb19536fa` ipc: Use EventLoopRef instead of addClient/removeClient](9a9fb19536)
  - [`6eb09fd6141f` test: Add unit test coverage for Init and Shutdown code](6eb09fd614)
  - [`7f65aac78b95` ipc: Avoid waiting for clients to disconnect when shutting down](7f65aac78b)
  - [`0c28068ceb7b` doc: Improve IPC interface comments](0c28068ceb)
  - [`216099591632` ipc: Add Ctrl-C handler for spawned subprocesses](2160995916)
  - [`2581258ec200` ipc: Handle bitcoin-wallet disconnections](2581258ec2)

  The new commits depend on the subtree update, and because the subtree update includes an incompatible API change, the "Use EventLoopRef" commit needs to be part of the same PR to avoid breaking the build. The other commits also make sense to merge at the same time because the bitcoin & libmultiprocess changes were written and tested together.

  ---

  This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/issues/28722).

ACKs for top commit:
  Sjors:
    re-utACK 2581258ec2
  josibake:
    code review ACK 2581258ec2
  pinheadmz:
    re-ACK 2581258ec2

Tree-SHA512: 0095aa22d507803e2a2d46eff51fb6caf965cc0c97ccfa615bd97805d5d51e66a5b4b040640deb92896438b1fb9f6879847124c9d0e120283287bfce37b8d748
2025-08-18 20:19:19 +01:00
Hennadii Stepanov d31dc8f818
Merge bitcoin/bitcoin#33200: cmake: Introduce translate.cmake script for translate target
05255d5d1e cmake: Drop dependency on sed for translate target (Daniel Pfeifer)
d5054beca5 cmake: Introduce translate.cmake script for translate target (Daniel Pfeifer)

Pull request description:

  Using `file(GLOB)` in the generates step is discouraged because the globbing result may be out of date when the target is built. Performing the globbing in a script that is executed as the build target means the result is always reproducable and the overhead of globbing is only paid when used.

  As a follow up, the dependency on `sed` may be removed by performing the replacement with cmake. Also, the logic from extract_strings_qt.py can be migrated to cmake.

ACKs for top commit:
  hebasto:
    ACK 05255d5d1e.

Tree-SHA512: ae55d9199e6294109b37e5e18f21f2b0e582c1f9903421cf22a237cfdbd215cc431706563b3caa03068cdba79f936b019526638fe3a1f83b4f01a72817e39be1
2025-08-18 11:54:21 +01:00
Daniel Pfeifer 05255d5d1e
cmake: Drop dependency on sed for translate target 2025-08-18 09:03:34 +02:00
Daniel Pfeifer d5054beca5
cmake: Introduce translate.cmake script for translate target
Using `file(GLOB)` in the generates step is discouraged because the
globbing result may be out of date when the target is built.
Performing the globbing in a script that is executed as the build
target means the result is always reproducable and the overhead
of globbing is only paid when used.

As a follow up, the dependency on `sed` may be removed by performing
the replacement with cmake. Also, the logic from extract_strings_qt.py
can be migrated to cmake.
2025-08-18 09:03:28 +02:00
Ava Chow 57e8f34fe2
Merge bitcoin/bitcoin#32977: wallet: Remove wallet version and several legacy related functions
60d1042b9a wallet: Remove unused `WalletFeature` enums (woltx)
66de58208a wallet: Remove `CWallet::nWalletVersion` and related functions (woltx)
7cda3d0f5b wallet: Remove `IsFeatureSupported()` and `CanSupportFeature()` (woltx)
ba01585229 wallet: `MigrateToDescriptor` no longer calls `CanSupportFeature` (woltx)
63acee2797 wallet: Remove `GetClosestWalletFeature()` (woltx)
e27da3150b wallet: Remove `GetVersion()` (woltx)

Pull request description:

  This PR incorporates the suggestion provided by PRabahy and pablomartin4btc in https://github.com/bitcoin/bitcoin/pull/32944 of removing `CWallet::nWalletVersion` and several related functions, such as `SetMinVersion()`, `GetVersion()`, `GetClosestWalletFeature()`, `IsFeatureSupported()`, `CanSupportFeature()`, etc ...

  This field is no longer used in the descriptor wallet and there is still a lot of code related to it, so the changes here provide a good cleanup in the wallet code.

  Built on top of https://github.com/bitcoin/bitcoin/pull/32944

ACKs for top commit:
  maflcko:
    review ACK 60d1042b9a 🐾
  achow101:
    ACK 60d1042b9a
  pablomartin4btc:
    ACK 60d1042b9a

Tree-SHA512: 1a7ad8e15d57df8f66545776e7d178a2cd5312c87769a29770588375e3de5f24247aab9919acf004ed3eca16d08ba595b5f1c7b2b3eef7752e89d9c295624583
2025-08-15 16:38:19 -07:00
Ava Chow 97593c1fd3
Merge bitcoin/bitcoin#32975: assumevalid: log every script validation state change
fab2980bdc assumevalid: log every script validation state change (Lőrinc)

Pull request description:

  The `-assumevalid` option skips script verification for a specified block and all its ancestors during Initial Block Download.
  Many new [users are surprised](https://github.com/bitcoin/bitcoin/issues/32832) when this suddenly slows their node to a halt.
  This commit adds a log message to clearly indicate when this optimization ends and full validation begins (and vice versa).

  <details>
  <summary>Testing instructions</summary>

  The behavior can easily be tested by adding this before the new log:
  ```C++
      // TODO hack to enable/disable script checks based on block height for testing purposes
           if (pindex->nHeight < 100) fScriptChecks = false;
      else if (pindex->nHeight < 200) fScriptChecks = true;
      else if (pindex->nHeight < 300) fScriptChecks = false;
      else if (pindex->nHeight < 400) fScriptChecks = true;
  ```
  and exercise the new code with:
  ```bash
  cmake -B build && cmake --build build && mkdir -p demo && build/bin/bitcoind -datadir=demo -stopatheight=500 | grep 'signature validation'
  ```
  showing something like:
  * Disabling signature validations at block #1 (00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048).
  * Enabling signature validations at block #100 (000000007bc154e0fa7ea32218a72fe2c1bb9f86cf8c9ebf9a715ed27fdb229a).
  * Disabling signature validations at block #200 (000000008f1a7008320c16b8402b7f11e82951f44ca2663caf6860ab2eeef320).
  * Enabling signature validations at block #300 (0000000062b69e4a2c3312a5782d7798b0711e9ebac065cd5d19f946439f8609).

  </details>

ACKs for top commit:
  achow101:
    ACK fab2980bdc
  ajtowns:
    crACK fab2980bdc
  davidgumberg:
    untested crACK fab2980bdc

Tree-SHA512: e90b66f7423b639356daace476942ce83e65e70466544394cbe2f15738bdbf716163eaf590c64c5448f9b41aeeaafe3342c48c6a7a478678a70b0310ca94e11d
2025-08-15 13:54:09 -07:00
glozow daa40a3ff9 doc fixups for 33106 2025-08-15 13:36:47 -04:00
glozow c568511e8c test fixup for incremental feerate
Clarify that the purpose of some parameters are to ensure identical
transactions are not created. Also, strengthen the test to catch these cases.
2025-08-15 13:36:47 -04:00
glozow 636fa219d3 test fixups 2025-08-15 13:36:47 -04:00
glozow 9169a50d52 [rpc] expose blockmintxfee via getmininginfo 2025-08-15 13:36:47 -04:00
ishaanam 5c8bf7b39e doc: add release notes for version 3 transactions 2025-08-15 11:24:51 -04:00
ishaanam 4ef8065a5e test: add truc wallet tests 2025-08-15 11:24:51 -04:00
ishaanam 5d932e14db test: extract `bulk_vout` from `bulk_tx` so it can be used by wallet tests 2025-08-15 11:24:51 -04:00
Bue-von-hon 2cb473d9f2 rpc: Support version 3 transaction creation
Adds v3 support to the following RPCs:
- createrawtransaction
- createpsbt
- send
- sendall
- walletcreatefundedpsbt

Co-authored-by: chungeun-choi <cucuridas@gmail.com>
Co-authored-by: dongwook-chan <dongwook.chan@gmail.com>
Co-authored-by: sean-k1 <uhs2000@naver.com>
Co-authored-by: ishaanam <ishaana.misra@gmail.com>
2025-08-15 11:24:46 -04:00
Bue-von-hon 4c20343b4d rpc: Add transaction min standard version parameter 2025-08-15 11:05:31 -04:00
ishaanam c5a2d08011 wallet: don't return utxos from multiple truc txs in AvailableCoins 2025-08-15 11:05:28 -04:00
ishaanam da8748ad62 wallet: limit v3 tx weight in coin selection 2025-08-15 10:45:36 -04:00
ishaanam 85c5410615 wallet: mark unconfirmed v3 siblings as mempool conflicts 2025-08-15 10:45:36 -04:00
ishaanam 0804fc3cb1 wallet: throw error at conflicting tx versions in pre-selected inputs 2025-08-15 10:45:36 -04:00
ishaanam cc155226fe wallet: set m_version in coin control to default value
In future commits we assume that coin_control.m_version has a
value when making sure that we follow truc rules, so we should
give it a default value of CTransaction::CURRENT_VERSION.
2025-08-15 10:45:36 -04:00
ishaanam 2e9617664e wallet: don't include unconfirmed v3 txs with children in available coins 2025-08-15 10:45:36 -04:00
ishaanam ec2676becd wallet: unconfirmed ancestors and descendants are always truc 2025-08-15 10:45:36 -04:00
merge-script 7b4a1350df
Merge bitcoin/bitcoin#33183: validation: rename block script verification error from "mandatory" to "block"
c0d91fc69c Add release note for #33050 and #33183 error string changes (Antoine Poinsot)
b3f781a0ef contrib: adapt max reject string size in tracing demo (Antoine Poinsot)
9a04635432 scripted-diff: validation: rename mandatory errors into block errors (Antoine Poinsot)

Pull request description:

  This is a followup to #33050 now that it's merged. Using "block"/"mempool" as the error reason is clearer to a user than "mandatory"/"non-mandatory". The "non-mandatory" errors got renamed to "mempool" in #33050 (see https://github.com/bitcoin/bitcoin/pull/33050#discussion_r2230103371). This takes care of the second part of the renaming.

ACKs for top commit:
  fjahr:
    utACK c0d91fc69c
  davidgumberg:
    lgtm ACK c0d91fc69c
  ajtowns:
    utACK c0d91fc69c
  Crypt-iQ:
    utACK c0d91fc69c
  janb84:
    utACK c0d91fc69c
  instagibbs:
    ACK c0d91fc69c

Tree-SHA512: b463e633c57dd1eae7c49d23239a59066a672f355142ec194982eddc927a7646bc5cde583dc8d6f45075bf5cbb96dbe73f7e339e728929b0eff356b674d1b68c
2025-08-15 12:13:38 +01:00
merge-script c99f5c5e1b
Merge bitcoin/bitcoin#33106: policy: lower the default blockmintxfee, incrementalrelayfee, minrelaytxfee
ba84a25dee [doc] update mempool-replacements.md for incremental relay feerate change (glozow)
18720bc5d5 [doc] release note for min feerate changes (glozow)
6da5de58ca [policy] lower default minrelaytxfee and incrementalrelayfee to 100sat/kvB (glozow)
2e515d2897 [prep/test] make wallet_fundrawtransaction's minrelaytxfee assumption explicit (glozow)
457cfb61b5 [prep/util] help MockMempoolMinFee handle more precise feerates (glozow)
3eab8b7240 [prep/test] replace magic number 1000 with respective feerate vars (glozow)
5f2df0ef78 [miner] lower default -blockmintxfee to 1sat/kvB (glozow)
d6213d6aa1 [doc] assert that default min relay feerate and incremental are the same (glozow)
1fbee5d7b6 [test] explicitly check default -minrelaytxfee and -incrementalrelayfee (glozow)
72dc18467d [test] RBF rule 4 for various incrementalrelayfee settings (glozow)
85f498893f [test] check bypass of minrelay for various minrelaytxfee settings (glozow)
e5f896bb1f [test] check miner doesn't select 0fee transactions (glozow)

Pull request description:

  ML post for discussion about the general concept, how this impacts the wider ecosystem, philosophy about minimum feerates, etc: https://delvingbitcoin.org/t/changing-the-minimum-relay-feerate/1886

  This PR is inspired by #13922 and #32959 to lower the minimum relay feerate in response to bitcoin's exchange rate changes in the last ~10 years. It lowers the default `-minrelaytxfee` and `-incrementalrelayfee`, and knocks `-blockmintxfee` down to the minimum nonzero setting. Also adds some tests for the settings and pulls in #32750.

  The minimum relay feerate is a DoS protection rule, representing a price on the network bandwidth used to relay transactions that have no PoW. While relay nodes don't all collect fees, the assumption is that if nodes on the network use their resources to relay this transaction, it will reach a miner and the attacker's money will be spent once it is mined. The incremental relay feerate is similar: it's used to price the relay of replacement transactions (the additional fees need to cover the new transactions at this feerate) and evicted transactions (following a trim, the new mempool minimum feerate is the package feerate of what was removed + incremental).

  Also note that many nodes on the network have elected to relay/mine lower feerate transactions. Miners (some say up to 85%) are choosing to mine these low feerate transactions instead of leaving block space unfilled, but these blocks have extremely poor compact block reconstruction rates with nodes that rejected or didn't hear about those transactions earlier.
  - https://github.com/bitcoin/bitcoin/pull/33106#issuecomment-3155627414
  - https://x.com/caesrcd/status/1947022514267230302
  - https://mempool.space/block/00000000000000000001305770e0aa279dcd8ba8be18c3d5cf736a26f77e06fd
  - https://mempool.space/block/00000000000000000001b491649ec030aa8e003e1f4f9d3b24bb99ba16f91e97
  - https://x.com/mononautical/status/1949452586391855121

  While it wouldn't make sense to loosen DoS restrictions recklessly in response to these events, I think the current price is higher than necessary, and this motivates us changing the default soon. Since the minimum relay feerate defines an amount as too small based on what it costs the attacker, it makes sense to consider BTC's conversion rate to what resources you can buy in the "real world."

  Going off of [this comment](https://github.com/bitcoin/bitcoin/pull/32959#issuecomment-3095260286) and [this comment](https://github.com/bitcoin/bitcoin/pull/33106#issuecomment-3142444090)
  - Let's say an attacker wants to use/exhaust the network's bandwidth, and has the choice between renting resources from a commercial provider and getting the network to "spam" itself it by sending unconfirmed transactions. We'd like the latter to be more expensive than the former.
  - The bandwidth for relaying a transaction across the network is roughly its serialized size (plus relay overhead) x number of nodes. A 1000vB transaction is 1000-4000B serialized. With 100k nodes, that's 0.1-0.4GB
  - If the going rate for ec2 bandwidth is 10c/GB, that's like 1-4c per kvB of transaction data
  - Then a 1000vB transaction should pay at least 4c
  - $0.04 USD is 40 satoshis at 100k USD/BTC
  - Baking in some margin for changes in USD/BTC conversion rate, number of nodes (and thus bandwidth), and commercial service costs, I think 50-100 satoshis is on the conservative end but in the right ballpark
  - At least 97% of the recent sub-1sat/vB transactions would be accepted with a new threshold of 0.1sat/vB: https://github.com/bitcoin/bitcoin/pull/33106#issuecomment-3156213089

  List of feerates that are changed and why:
  - min relay feerate: significant conversion rate changes, see above
  - incremental relay feerate: should follow min relay feerate, see above
  - block minimum feerate: shouldn’t be above min relay feerate, otherwise the node accepts transactions it will never mine. I've knocked it down to the bare minimum of 1sat/kvB. Now that we no longer have coin age priority (removed in v0.15), I think we can leave it to the `CheckFeeRate` policy rule to enforce a minimum entry price, and the block assembly code should just fill up the block with whatever it finds in mempool.

  List of feerates that are not changed and why:
  - dust feerate: this feerate cannot be changed as flexibly as the minrelay feerate. A much longer record of low feerate transactions being mined is needed to motivate a decrease there.
  - maxfeerate (RPC, wallet): I think the conversion rate is relevant as well, but out of scope for this PR
  - minimum feerate returned by fee estimator: should be done later. In the past, we've excluded new policy defaults from fee estimation until we feel confident they represent miner policy (e.g. #9519). Also, the fee estimator itself doesn't have support for sub-1sat/vB yet.
  - all wallet feerates (mintxfee, fallbackfee, discardfee, consolidatefeerate, WALLET_INCREMENTAL_RELAY_FEE, etc.): should be done later. Our standard procedure is to do wallet changes at least 1 release after policy changes.

ACKs for top commit:
  achow101:
    ACK ba84a25dee
  gmaxwell:
    ACK ba84a25dee
  jsarenik:
    Tested ACK ba84a25dee
  darosior:
    ACK ba84a25dee
  ajtowns:
    ACK ba84a25dee
  davidgumberg:
    crACK  ba84a25dee
  w0xlt:
    ACK ba84a25dee
  caesrcd:
    reACK ba84a25dee
  ismaelsadeeq:
    re-ACK ba84a25dee

Tree-SHA512: b4c35e8b506b1184db466551a7e2e48bb1e535972a8dbcaa145ce3a8bfdcc70a8807dc129460f129a9d31024174d34077154a387c32f1a3e6831f6fa5e9c399e
2025-08-15 10:39:16 +01:00
Ava Chow 578b512bdd
Merge bitcoin/bitcoin#33011: log: rate limiting followups
5c74a0b397 config: add DEBUG_ONLY -logratelimit (Eugene Siegel)
9f3b017bcc test: logging_filesize_rate_limit improvements (stickies-v)
350193e5e2 test: don't leak log category mask across tests (stickies-v)
05d7c22479 test: add ReadDebugLogLines helper function (stickies-v)
3d630c2544 log: make m_limiter a shared_ptr (stickies-v)
e8f9c37a3b log: clean up LogPrintStr_ and Reset, prefix all logs with "[*]" when there are suppressions (Eugene Siegel)
3c7cae49b6 log: change LogLimitStats to struct LogRateLimiter::Stats (Eugene Siegel)
8319a13468 log: clarify RATELIMIT_MAX_BYTES comment, use RATELIMIT_WINDOW (Eugene Siegel)
5f70bc80df log: remove const qualifier from arguments in LogPrintFormatInternal (Eugene Siegel)
b8e92fb3d4 log: avoid double hashing in SourceLocationHasher (Eugene Siegel)
616bc22f13 test: remove noexcept(false) comment in ~DebugLogHelper (Eugene Siegel)

Pull request description:

  Followups to #32604.

  There are two behavior changes:
  - prefixing with `[*]` is done to all logs (regardless of `should_ratelimit`) per [this comment](https://github.com/bitcoin/bitcoin/pull/32604#discussion_r2195710943).
  - a DEBUG_ONLY `-disableratelimitlogging` flag is added by default to functional tests so they don't encounter rate limiting.

ACKs for top commit:
  stickies-v:
    re-ACK 5c74a0b397
  achow101:
    ACK 5c74a0b397
  l0rinc:
    Code review ACK 5c74a0b397

Tree-SHA512: d32db5fcc28bb9b2a850f0048c8062200a3725b88f1cd9a0e137da065c0cf9a5d22e5d03cb16fe75ea7494801313ab34ffec7cf3e8577cd7527e636af53591c4
2025-08-14 15:15:25 -07:00
Sjors Provoost ce7d94a492
doc: add release note 2025-08-14 21:00:03 +02:00
Sjors Provoost 71f29d4fa9
doc: update build and dependencies docs for IPC
OpenBSD does not have this package, so recommend building from
source for now.
2025-08-14 20:59:51 +02:00
Sjors Provoost 3cbf747c32
cmake: set ENABLE_IPC by default
Install capnp on non-depends CI jobs.

Use the bitcoin-node binary in the macOS native non-depends job.
2025-08-14 20:57:38 +02:00
Sjors Provoost 32a90e1b90
ci: use bitcoin-node for one depends job
The bitcoin-node binary is built on all platforms which have
multiprocess enabled, but for functional tests it's only used in
CentOS native (depends) job. The next commit will also add a
non-depends job.
2025-08-14 20:57:38 +02:00
Sjors Provoost b333cc14d5
ci: build one depends job without multiprocess 2025-08-14 20:57:38 +02:00
Sjors Provoost 16bce9ac4c
build: depends makes libmultiprocess by default
This causes IPC binaries (bitcoin-node, bitcoin-gui) to be included
in releases.

The effect on CI is that this causes more depends builds to build IPC
binaries, but still the only build running functional tests with them
is the i686_multiprocess one.

Except for Windows.
2025-08-14 20:57:38 +02:00
Ava Chow 8405fdb06e
Merge bitcoin/bitcoin#33169: interfaces, chain, refactor: Remove unused getTipLocator and incaccurate getActiveChainLocator
2b00030af8 interfaces, chain, refactor: Remove inaccurate getActiveChainLocator (pablomartin4btc)
110a0f405c interfaces, chain, refactor: Remove unused getTipLocator (pablomartin4btc)

Pull request description:

  Remove `Chain::getTipLocator`, `Chain::GetLocator()`, and `Chain::getActiveChainLocator`:
  - `Chain::getTipLocator` is no longer used.
  - `Chain::GetLocator`, replaced its call by `GetLocator()`, which uses `LocatorEntries`, avoiding direct access to the chain itself (change suggested by l0rinc while reviewing this PR to maintain consistency with the overall refactoring).
  - `Chain::getActiveChainLocator`, whose name was misleading, has functionality redundant with Chain::findBlock.
    - Additionally, the comment for getActiveChainLocator became inaccurate following changes in commit ed470940cd (from PR #25717).

  This is a [follow-up](https://github.com/bitcoin/bitcoin/pull/29652#issuecomment-3151665095) to #29652.

ACKs for top commit:
  achow101:
    ACK 2b00030af8
  furszy:
    ACK 2b00030af8
  stickies-v:
    ACK 2b00030af8
  w0xlt:
    ACK 2b00030af8

Tree-SHA512: b12ba6a15feeaeec692d69204a6e155e3af43edfac25597dabf14cacca1e4a2152574816e58dc544f39043c5721f5e707acf544f4541d3b9c0f8c0c40069215e
2025-08-14 11:30:45 -07:00
Antoine Poinsot c0d91fc69c Add release note for #33050 and #33183 error string changes 2025-08-14 14:11:04 -04:00
Ava Chow e17b5da0d6
Merge bitcoin/bitcoin#33179: doc: update wallet build instruction
67e186deb0 doc: update wallet build instruction (Sjors Provoost)

Pull request description:

  Sqlite and the wallet are no longer optional, but they can still be opted out of. This PR updates the build instructions accordingly.

  Updating this text now reduces churn in #31802.

ACKs for top commit:
  jonatack:
    ACK 67e186deb0
  achow101:
    ACK 67e186deb0
  w0xlt:
    reACK 67e186deb0
  pablomartin4btc:
    ACK 67e186deb0
  janb84:
    ACK 67e186deb0

Tree-SHA512: ea87a83c9fcb884f9ca380a006a93ede3cd1af5eb2bb5ccb54fc8124faa532e9473ae2461d775439da59e86178fbd04983113b43ce3d4c382cabe27866acd027
2025-08-14 11:06:24 -07:00
Anthony Towns 417437eb01 script/verify_flags: extend script_verify_flags to 64 bits 2025-08-14 10:17:32 +10:00
Anthony Towns 3cbbcb66ef script/interpreter: make script_verify_flag_name an ordinary enum
Instead of having `SCRIPT_VERIFY_FOO = (1U << n)` just have it
be `n` directly, and do the bit shifting when converting it to
`script_verify_flags`.
2025-08-14 10:17:32 +10:00
Anthony Towns bddcadee82 script/verify_flags: make script_verify_flags type safe
`using script_verify_flags = uint32_t` allows implicit conversion to
and from int, so replace it with a class to have the compiler ensure we
use the correct type. Provide from_int and as_int to allow for explicit
conversions when desired.

Introduces the type `script_verify_flag_name` for the individual flag
name enumeration.
2025-08-14 10:17:32 +10:00
Anthony Towns a5ead122fe script/interpreter: introduce script_verify_flags typename
Previously the SCRIPT_VERIFY_* flags were specified as either uint32_t,
unsigned int, or unsigned. This converts them to a common type alias in
preparation for changing the underlying type.
2025-08-14 10:17:32 +10:00
Anthony Towns 4577fb2b1e rpc: have getdeploymentinfo report script verify flags 2025-08-14 10:17:32 +10:00
Anthony Towns a3986935f0 validation: export GetBlockScriptFlags() 2025-08-14 10:17:32 +10:00
Anthony Towns 5db8cd2d37 Move mapFlagNames and FormatScriptFlags logic to script/interpreter.h
Moves FormatScriptFlags logic into GetScriptFlagNames which returns a
vector of strings. For completeness, also has GetScriptFlagNames report
on any bits that do not match a known script flag.
2025-08-14 10:17:30 +10:00
merge-script 9b1a7c3e8d
Merge bitcoin/bitcoin#33116: refactor: Convert uint256 to Txid
de0675f9de refactor: Move `transaction_identifier.h` to primitives (marcofleon)
6f068f65de Remove implicit uint256 conversion and comparison (marcofleon)
9c24cda72e refactor: Convert remaining instances from uint256 to Txid (marcofleon)
d2ecd6815d policy, refactor: Convert uint256 to Txid (marcofleon)
f6c0d1d231 mempool, refactor: Convert uint256 to Txid (marcofleon)
aeb0f78330 refactor: Convert `mini_miner` from uint256 to Txid (marcofleon)
326f244724 refactor: Convert RPCs and `merkleblock` from uint256 to Txid (marcofleon)
49b3d3a92a Clean up `FindTxForGetData` (marcofleon)

Pull request description:

  This is the final leg of the [type safety refactor](https://github.com/bitcoin/bitcoin/pull/32189).

  All of these changes are straightforward `uint256` --> `Txid` along with any necessary explicit conversions. Also, `transaction_identifier.h` is moved to primitives in the last commit, as `Txid` and `Wtxid` become fundamental types after this PR.

ACKs for top commit:
  stickies-v:
    re-ACK de0675f9de, no changes since a20724d926d5844168c6a13fa8293df8c8927efe except address review nits.
  janb84:
    re ACK de0675f9de
  dergoegge:
    re-ACK de0675f9de
  theStack:
    Code-review ACK de0675f9de

Tree-SHA512: 2413160fca7ab146a8d79d18ce3afcf7384cacc73c513d41928904aa453b4dd7a350064cee71e9c5d015da5904c7c81ac17603e50a47441ebc5b0c653235dd08
2025-08-13 14:50:51 -04:00
Antoine Poinsot b3f781a0ef contrib: adapt max reject string size in tracing demo
The Script errors were last touched in 2020. This value was calculated after that
in 2022 (commit 4b7aec2951). The previous commit
made the size of the largest reject reason string 4 characters smaller ("mandatory"
became "block"), so adapt the constant.
2025-08-13 11:06:01 -04:00
Antoine Poinsot 9a04635432 scripted-diff: validation: rename mandatory errors into block errors
Using "block" or "mempool" as the prefix in place of "mandatory" or "non-mandatory" is clearer
to a user. "non-mandatory" was renamed into "mempool" as part of #33050. This takes care of the
other half of this renaming as a scripted diff.

-BEGIN VERIFY SCRIPT-
sed -i 's/mandatory-script-verify/block-script-verify/g' $(git grep -l mandatory-script-verify)
-END VERIFY SCRIPT-
2025-08-13 11:05:54 -04:00
merge-script dbf8b0980b
Merge bitcoin/bitcoin#33171: ci: Update `actions/checkout` version
f83c01d882 ci: Update `actions/checkout` version (Hennadii Stepanov)

Pull request description:

  See: https://github.com/actions/checkout/releases/tag/v5.0.0.

ACKs for top commit:
  bc1cindy:
    ACK f83c01d8
  pablomartin4btc:
    ACK f83c01d882
  janb84:
    ACK f83c01d882

Tree-SHA512: 491652abcb99f6e5c9a7bc66867c5e5fc7032d35d091cdbef5cdf7ed125bd93e612c058a771373e4a67ddc320b3bb8e22a6294aeade73df0f24b5584df8e47ab
2025-08-13 10:51:46 +01:00
merge-script d6887f0cec
Merge bitcoin/bitcoin#33178: guix: increase maximum allowed (runtime) GCC to 7
776a163374 guix: increase maximum allowed (runtime) GCC to 7 (fanquake)

Pull request description:

  Fixes:
  ```bash
  /distsrc-base/distsrc-d3b8a54a8120-x86_64-linux-gnu/build/bin/bitcoind: symbol __divmodti4 from unsupported version GCC_7.0.0(14)
  /distsrc-base/distsrc-d3b8a54a8120-x86_64-linux-gnu/build/bin/bitcoind: failed IMPORTED_SYMBOLS
  ```

  which is occuring after #32750. I can't see any supported distro that is shipping a new enough glibc (2.31), but a GCC older than 7.0.

  Fixes #33177.

ACKs for top commit:
  hebasto:
    ACK 776a163374.

Tree-SHA512: 8e5a77c509eb6164314fdb644ea199916e151eb0c7f48703f3a2bdedf0dea29b7f402ceacb2aaf42ebffba59080cefbb84253b2721047d973a851090447ba3b5
2025-08-13 09:14:04 +01:00
Anthony Towns adefb51c54 rpc/net: add per-peer inv_to_send sizes 2025-08-13 13:21:26 +10:00
pablomartin4btc 2b00030af8 interfaces, chain, refactor: Remove inaccurate getActiveChainLocator
The getActiveChainLocator method name was misleading, and its functionality
duplicated `Chain::findBlock`. This commit removes the method and replaces
all its usages with direct `Chain::findBlock` calls.

Additionally, the comment of getActiveChainLocator has been outdated since
commit ed47094 from #25717.

Finally, in CWallet::ScanForWalletTransactions, the findBlock calls are now
unified into a single call at the start of the function.

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
Co-authored-by: Matias Furszyfer <mfurszy@protonmail.com>
2025-08-13 00:21:17 -03:00
pablomartin4btc 110a0f405c interfaces, chain, refactor: Remove unused getTipLocator
Also removed CChain::GetLocator() and replaced its call
with GetLocator() which uses LocatorEntries instead.

Co-authored-by: ryanofsky <ryan@ofsky.org>
Co-authored-by: l0rinc <l0rinc@users.noreply.github.com>
2025-08-13 00:08:37 -03:00
Ava Chow dadf15f88c
Merge bitcoin/bitcoin#33050: net, validation: don't punish peers for consensus-invalid txs
876dbdfb47 tests: drop expect_disconnect behaviour for tx relay (Anthony Towns)
b29ae9efdf validation: only check input scripts once (Anthony Towns)
266dd0e10d net_processing: drop MaybePunishNodeForTx (Anthony Towns)

Pull request description:

  Because we do not discourage nodes for transactions we consider non-standard, we don't get any DoS protection from this check in adversarial scenarios, so remove the check entirely both to simplify the code and reduce the risk of splitting the network due to changes in tx relay policy.

  Then, because we no longer make use of the distinction between consensus and standardness failures during script validation, don't re-validate each script with only-consensus rules, reducing the cost to us of transactions that we won't relay.

ACKs for top commit:
  achow101:
    ACK 876dbdfb47
  darosior:
    re-ACK 876dbdfb47
  sipa:
    re-ACK 876dbdfb47
  glozow:
    ACK 876dbdfb47

Tree-SHA512: 8bb0395766dde54fc48f7077b80b88e35581aa6e3054d6d65735965147abefffa7348f0850bb3d46f6c2541fd384ecd40a00a57fa653adabff8a35582e2d1811
2025-08-12 14:35:18 -07:00
Lőrinc cb173b8e93 test: use local `CBlockIndex` in block read hash mismatch test to avoid data race
Co-authored-by: stickies-v <stickies-v@protonmail.com>
2025-08-12 11:34:58 -07:00
Ava Chow 73972d5617
Merge bitcoin/bitcoin#31296: wallet: Translate [default wallet] string in progress messages
db225cea56 wallet, refactor: Replace GetDisplayName() with LogName() (Ryan Ofsky)
01737883b3 wallet: Translate [default wallet] string in progress messages (Ryan Ofsky)

Pull request description:

  Noticed while reviewing https://github.com/bitcoin/bitcoin/pull/31287#discussion_r1843809721 that the [default wallet] part of progress messages remains untranslated while the rest of the string is translated.

  Fix this in all places where `CWallet::ShowProgress` (which has a cancel button) and `Chain::showProgress` (which doesn't have a cancel button) are called by making "default wallet" into a translated string.

ACKs for top commit:
  achow101:
    ACK db225cea56
  pablomartin4btc:
    ACK db225cea56
  furszy:
    utACK db225cea56

Tree-SHA512: 3e76e22ee692a7403d61c66615f56d0fa5f7883dd47553bcaec2f9ffd942daaa90ceb61830206bece50da53dcd737b6438c36bcb086030b2deb68c44172f3931
2025-08-12 11:33:42 -07:00
Sjors Provoost 67e186deb0
doc: update wallet build instruction
Sqlite is expected to be installed, but can still be opted out of.
2025-08-12 19:39:07 +02:00
Eugene Siegel 5c74a0b397 config: add DEBUG_ONLY -logratelimit
Use -nologratelimit by default in functional tests if the bitcoind
version supports it.

Co-Authored-By: stickies-v <stickies-v@protonmail.com>
2025-08-12 11:28:36 -04:00
stickies-v 9f3b017bcc test: logging_filesize_rate_limit improvements
- Add helper functions and structs to improve readability and
  reusability of test code
- Make tests more specific by comparing all produced log lines with
  expected log lines instead of relying on approximations or proxies.
2025-08-12 11:28:36 -04:00
stickies-v 350193e5e2 test: don't leak log category mask across tests
This ensures log tests behave consistently when other tests modify
the log category mask.
2025-08-12 11:28:36 -04:00
stickies-v 05d7c22479 test: add ReadDebugLogLines helper function
Deduplicates repeated usage of the same functionality.
2025-08-12 11:28:36 -04:00
stickies-v 3d630c2544 log: make m_limiter a shared_ptr
This allows us to safely and explicitly manage the dual dependency
on the limiter: one for the Logger, and one for the CScheduler.
2025-08-12 11:28:36 -04:00
merge-script ec484bd5ce
Merge bitcoin/bitcoin#31453: util: detect and warn when using exFAT on MacOS
db3228042b util: detect and warn when using exFAT on macOS (willcl-ark)

Pull request description:

  exFAT is known to cause intermittent corruption on MacOS.

  Therefore we should warn when using this fs format for either the blocks or data directories.

  See #28552 for more context.

ACKs for top commit:
  l0rinc:
    ACK db3228042b
  marcofleon:
    reACK db3228042b
  ismaelsadeeq:
    reACK db3228042b

Tree-SHA512: e4453a8e24b35c135e4eb0b4e47fe0c80f8b54700f458909c403aa37a0d2979ee165347bcd76e48e4d1ae5d3bae13f50e6afe714e33226a52f907b95df9d3b46
2025-08-12 10:23:13 -04:00
fanquake 776a163374
guix: increase maximum allowed (runtime) GCC to 7
Fixes:
```bash
/distsrc-base/distsrc-d3b8a54a8120-x86_64-linux-gnu/build/bin/bitcoind: symbol __divmodti4 from unsupported version GCC_7.0.0(14)
/distsrc-base/distsrc-d3b8a54a8120-x86_64-linux-gnu/build/bin/bitcoind: failed IMPORTED_SYMBOLS
```

which is occuring after #32750. I can't see any supported distro that is
shipping a new enough glibc (2.31), but a GCC older than 7.0.
2025-08-12 14:45:03 +01:00
glozow ba84a25dee [doc] update mempool-replacements.md for incremental relay feerate change 2025-08-12 09:22:53 -04:00
Ava Chow 273e600e65
Merge bitcoin/bitcoin#33021: test/refactor: revive test verifying that `GetCoinsCacheSizeState` switches from OK→LARGE→CRITICAL
554befd873 test: revive `getcoinscachesizestate` (Lőrinc)
64ed0fa6b7 refactor: modernize `LargeCoinsCacheThreshold` (Lőrinc)
1b40dc02a6 refactor: extract `LargeCoinsCacheThreshold` from `GetCoinsCacheSizeState` (Lőrinc)

Pull request description:

  After the changes in https://github.com/bitcoin/bitcoin/pull/25325 `getcoinscachesizestate` [always ended the test early](https://maflcko.github.io/b-c-cov/test_bitcoin.coverage/src/test/validation_flush_tests.cpp.gcov.html#L65):

  | File                         | Line Rate | Line Total | Line Hit | Branch Rate | Branch Total | Branch Hit |
  |------------------------------|---------:|-----------:|---------:|------------:|-------------:|-----------:|
  | validation_flush_tests.cpp   | **31.5 %**   | 54         | 17       | 22.3 %      | 242          | 54         |

  The test revival was [extracted from a related PR](https://github.com/bitcoin/bitcoin/pull/28531#discussion_r2109417797) where it was [discovered](https://github.com/bitcoin/bitcoin/pull/28531#discussion_r2044004503).

ACKs for top commit:
  achow101:
    ACK 554befd873
  LarryRuane:
    ACK 554befd873
  w0xlt:
    ACK 554befd873

Tree-SHA512: f5057254de8fb3fa627dd20fee6818cfadeb2e9f629f9972059ad7b32e01fcd7dc9922eff9da2d363b36a9f0954d9bc1c4131d47b2a9c6cc348d9864953b91be
2025-08-11 15:15:53 -07:00
glozow 18720bc5d5 [doc] release note for min feerate changes 2025-08-11 17:08:39 -04:00
glozow 6da5de58ca [policy] lower default minrelaytxfee and incrementalrelayfee to 100sat/kvB
Let's say an attacker wants to use/exhaust the network's bandwidth, and
has the choice between renting resources from a commercial provider and
getting the network to "spam" itself it by sending unconfirmed
transactions. We'd like the latter to be more expensive than the former.

The bandwidth for relaying a transaction across the network is roughly
its serialized size (plus relay overhead) x number of nodes. A 1000vB
transaction is 1000-4000B serialized. With 100k nodes, that's 0.1-0.4GB
If the going rate for commercial services is 10c/GB, that's like 1-4c per kvB
of transaction data, so a 1000vB transaction should pay at least $0.04.

At a price of 120k USD/BTC, 100sat is about $0.12. This price allows us
to tolerate a large decrease in the conversion rate or increase in the
number of nodes.
2025-08-11 17:07:43 -04:00
glozow 2e515d2897 [prep/test] make wallet_fundrawtransaction's minrelaytxfee assumption explicit 2025-08-11 16:58:26 -04:00
glozow 457cfb61b5 [prep/util] help MockMempoolMinFee handle more precise feerates
Use a virtual size of 1000 to keep precision when using a feerate
(which is rounded to the nearest satoshi per kvb) that isn't just an
integer.
2025-08-11 16:58:26 -04:00
glozow 3eab8b7240 [prep/test] replace magic number 1000 with respective feerate vars 2025-08-11 16:58:26 -04:00
glozow 5f2df0ef78 [miner] lower default -blockmintxfee to 1sat/kvB
Back when we implemented coin age priority as a miner policy, miners
mempools might admit transactions paying very low fees, but then want to
set a higher fee for block inclusion. However, since coin age priority
was removed in v0.15, the block assembly policy is solely based on fees,
so we do not need to apply minimum feerate rules in multiple places. In
fact, the block assembly policy ignoring transactions that are added to
the mempool is likely undesirable as we waste resources accepting and
storing this transaction.

Instead, rely on mempool policy to enforce a minimum entry feerate to
the mempool (minrelaytxfee). Set the minimum block feerate to the
minimum non-zero amount (1sat/kvB) so it collects everything it finds in
mempool into the block.
2025-08-11 16:58:26 -04:00
glozow d6213d6aa1 [doc] assert that default min relay feerate and incremental are the same 2025-08-11 16:58:26 -04:00
glozow 1fbee5d7b6 [test] explicitly check default -minrelaytxfee and -incrementalrelayfee 2025-08-11 16:58:21 -04:00
glozow 72dc18467d [test] RBF rule 4 for various incrementalrelayfee settings 2025-08-11 16:48:56 -04:00
glozow 85f498893f [test] check bypass of minrelay for various minrelaytxfee settings 2025-08-11 16:46:22 -04:00
glozow e5f896bb1f [test] check miner doesn't select 0fee transactions 2025-08-11 16:44:54 -04:00
marcofleon de0675f9de refactor: Move `transaction_identifier.h` to primitives
Moves the file from `src/util` to `src/primitives`. Now that the
refactor is complete, Txid and Wtxid are fundamental types, so it
makes sense for them to reside in `src/primitives`.
2025-08-11 16:47:51 +01:00
marcofleon 6f068f65de Remove implicit uint256 conversion and comparison 2025-08-11 16:47:51 +01:00
marcofleon 9c24cda72e refactor: Convert remaining instances from uint256 to Txid
These remaining miscellaneous changes were identified by commenting out
the `operator const uint256&` conversion and the `Compare(const uint256&)`
method from `transaction_identifier.h`.
2025-08-11 16:47:43 +01:00
marcofleon d2ecd6815d policy, refactor: Convert uint256 to Txid 2025-08-11 16:28:59 +01:00
marcofleon f6c0d1d231 mempool, refactor: Convert uint256 to Txid 2025-08-11 16:26:35 +01:00
marcofleon aeb0f78330 refactor: Convert `mini_miner` from uint256 to Txid 2025-08-11 16:12:42 +01:00
marcofleon 326f244724 refactor: Convert RPCs and `merkleblock` from uint256 to Txid 2025-08-11 15:53:34 +01:00
merge-script 41642d43b3
Merge bitcoin/bitcoin#33162: test: fix scripts in `blockfilter_basic_test`
ca64b71ed5 test: fix scripts in `blockfilter_basic_test` (UdjinM6)

Pull request description:

  `std::vector` fill ctor is like this:
  ```
  // Constructs a vector with `count` copies of elements with value `value`.
  explicit vector( size_type count, const T& value = T(), const Allocator& alloc = Allocator() ); // (until C++11)
  vector( size_type count, const T& value, const Allocator& alloc = Allocator() ); // (since C++11)(constexpr since C++20)
  ```
  https://en.cppreference.com/w/cpp/container/vector/vector.html

  i.e. `std::vector<unsigned char>(0, 65)` means a vector with `0` copies of `65` which feels wrong. I believe `count` and `value` were swapped in `blockfilter_basic_test` scripts.

ACKs for top commit:
  furszy:
    ACK ca64b71ed5
  pablomartin4btc:
    ACK ca64b71ed5
  janb84:
    ACK ca64b71ed5

Tree-SHA512: 2cfc7f09788b0a1afdffc9cd6663204c7f1775dabdbe1046cdcd42936c479658c348cb46e0d8835645e6c508e8b40a598cbe6534084b6780a6b60378bcbd0f96
2025-08-11 10:44:57 -04:00
Hennadii Stepanov f83c01d882
ci: Update `actions/checkout` version 2025-08-11 14:54:40 +01:00
merge-script a27430e259
Merge bitcoin/bitcoin#32473: Introduce per-txin sighash midstate cache for legacy/p2sh/segwitv0 scripts
83950275ed qa: unit test sighash caching (Antoine Poinsot)
b221aa80a0 qa: simple differential fuzzing for sighash with/without caching (Antoine Poinsot)
92af9f74d7 script: (optimization) introduce sighash midstate caching (Pieter Wuille)
8f3ddb0bcc script: (refactor) prepare for introducing sighash midstate cache (Pieter Wuille)
9014d4016a tests: add sighash caching tests to feature_taproot (Pieter Wuille)

Pull request description:

  This introduces a per-txin cache for sighash midstate computation to the script interpreter for legacy (bare), P2SH, P2WSH, and (as collateral effect, but not actually useful) P2WPKH. This reduces the impact of certain types of quadratic hashing attacks that use standard transactions. It is not known to improve the situation for attacks involving non-standard transaction attacks.

  The cache works by remembering for each of the 6 sighash modes a `(scriptCode, midstate)` tuple, which gives a midstate `CSHA256` object right before the appending of the sighash type itself (to permit all 256, rather than just the 6 ones that match the modes). The midstate is only reused if the `scriptCode` matches. This works because - within a single input - only the sighash type and the `scriptCode` affect the actual sighash used.

  The PR implements two different approaches:
  * The initial commits introduce the caching effect always, for both consensus and relay relation validation. Despite being primarily intended for improving the situation for standard transactions only, I chose this approach as the code paths are already largely common between the two, and this approach I believe involves fewer code changes than a more targetted approach, and furthermore, it should not hurt (it may even help common multisig cases slightly).
  * The final commit changes the behavior to only using the cache for non-consensus script validation. I'm open to feedback about whether adding this commit is worth it.

  Functional tests are included that construct contrived cases with many sighash types (standard and non-standard ones) and `OP_CODESEPARATOR`s in all script types (including P2TR, which isn't modified by this PR).

ACKs for top commit:
  achow101:
    ACK 83950275ed
  dergoegge:
    Code review ACK 83950275ed
  darosior:
    re-ACK 83950275ed

Tree-SHA512: 65ae8635429a4d563b19969bac8128038ac2cbe01d9c9946abd4cac3c0780974d1e8b9aae9bb83f414e5d247a59f4a18fef5b37d93ad59ed41b6f11c3fe05af4
2025-08-11 10:26:19 +01:00
merge-script 34b366fa2c
Merge bitcoin/bitcoin#33155: contrib: drop `bitcoin-util` exception from FORTIFY check
4bff4ce561 contrib: drop bitcoin-util exception from FORTIFY check (fanquake)

Pull request description:

  It's got `memcpy_chk`.

  Guix Build (aarch64):
  ```bash
  955c15e4b40dae5f0a80185a5a759764eb650003b56a997f2f18b058f979e212  guix-build-4bff4ce561b0/output/aarch64-linux-gnu/SHA256SUMS.part
  4e57193921b5a96b1da82e964577e20fdc8f287de9f28dc15b818f94bdc12fd2  guix-build-4bff4ce561b0/output/aarch64-linux-gnu/bitcoin-4bff4ce561b0-aarch64-linux-gnu-debug.tar.gz
  fb9779bfe3412f80393b85c7c12763fe34909879a34edbfe08d00bbea222d357  guix-build-4bff4ce561b0/output/aarch64-linux-gnu/bitcoin-4bff4ce561b0-aarch64-linux-gnu.tar.gz
  42068fd17c33c7de75556b257de7e9ec7f94f9a0610c2a2be75050053cf18aff  guix-build-4bff4ce561b0/output/arm-linux-gnueabihf/SHA256SUMS.part
  a0297f846e03f79f99d812f879eb09587c90bd03b8573aeb98bf8e56ef81544c  guix-build-4bff4ce561b0/output/arm-linux-gnueabihf/bitcoin-4bff4ce561b0-arm-linux-gnueabihf-debug.tar.gz
  fb20033e5a9f61a2d5f932ddfb1f402226d33b776f3c6fb5df1de8cecde36eeb  guix-build-4bff4ce561b0/output/arm-linux-gnueabihf/bitcoin-4bff4ce561b0-arm-linux-gnueabihf.tar.gz
  b0298c7c5176f67039e32d7691f99e0e9cd53d50af1c4a3a745ff02810867aac  guix-build-4bff4ce561b0/output/arm64-apple-darwin/SHA256SUMS.part
  0c498c6721dfae596a15bd3b083a635951ff4441cf5545d63f00fd743c481527  guix-build-4bff4ce561b0/output/arm64-apple-darwin/bitcoin-4bff4ce561b0-arm64-apple-darwin-codesigning.tar.gz
  04f7ac0d9c6103c302c165db21428f39afbd2bb506def903d259feae740f758d  guix-build-4bff4ce561b0/output/arm64-apple-darwin/bitcoin-4bff4ce561b0-arm64-apple-darwin-unsigned.tar.gz
  899b2efa608200508153bbb4d745099d525c2196b0f00a8bb0e960070c3cd3c6  guix-build-4bff4ce561b0/output/arm64-apple-darwin/bitcoin-4bff4ce561b0-arm64-apple-darwin-unsigned.zip
  51aeb7a040a0910e7466c14ce554362b4924b821be093ba73dffdda07c73618b  guix-build-4bff4ce561b0/output/dist-archive/bitcoin-4bff4ce561b0.tar.gz
  3119f9da15028a5d84645360dad9eab2e85b8ef363af919ea3e60104211b7d62  guix-build-4bff4ce561b0/output/powerpc64-linux-gnu/SHA256SUMS.part
  6d4d7cd1d8e294b65340669c2979079ff5c73e09df1e9629b182af8414a45b66  guix-build-4bff4ce561b0/output/powerpc64-linux-gnu/bitcoin-4bff4ce561b0-powerpc64-linux-gnu-debug.tar.gz
  9c36b47c37b0f77c23ab9a5a0b080e6e82b17e8d1de352b3096f2b96994e1d49  guix-build-4bff4ce561b0/output/powerpc64-linux-gnu/bitcoin-4bff4ce561b0-powerpc64-linux-gnu.tar.gz
  ef8ebcb015e282a969f36564b4c430dd1e74237b2362256f0485a3fc20d86bcf  guix-build-4bff4ce561b0/output/riscv64-linux-gnu/SHA256SUMS.part
  ff6313218a98a73603f2efa9f66f14289eb84f2561715ff99833b55aabc694d5  guix-build-4bff4ce561b0/output/riscv64-linux-gnu/bitcoin-4bff4ce561b0-riscv64-linux-gnu-debug.tar.gz
  75047bd03387b45995186ba4fad0d403f15b0590f064ed9a7bac7a38b07ef227  guix-build-4bff4ce561b0/output/riscv64-linux-gnu/bitcoin-4bff4ce561b0-riscv64-linux-gnu.tar.gz
  f714833a5fa772f4617e268ba75aa83435e755c97e378903b80dbf0808a5d4f5  guix-build-4bff4ce561b0/output/x86_64-apple-darwin/SHA256SUMS.part
  567925e2e2438fac7e5928f63088ae32ff8b4a6feaceb94b404e087377bacf8b  guix-build-4bff4ce561b0/output/x86_64-apple-darwin/bitcoin-4bff4ce561b0-x86_64-apple-darwin-codesigning.tar.gz
  1b018bc5e57512de19ff671ec03bb0fc5ff4be2e03a49263b7baa9b3c9cccf23  guix-build-4bff4ce561b0/output/x86_64-apple-darwin/bitcoin-4bff4ce561b0-x86_64-apple-darwin-unsigned.tar.gz
  06f41fad17071ca96013cd645bdbef4b81d1ead2dd83e3b484241fb9c092c5ae  guix-build-4bff4ce561b0/output/x86_64-apple-darwin/bitcoin-4bff4ce561b0-x86_64-apple-darwin-unsigned.zip
  77003ff6a044d55d72a8e8bf7d66d65da07a7ce22c2d6bb6ff41d3cd2540c826  guix-build-4bff4ce561b0/output/x86_64-linux-gnu/SHA256SUMS.part
  3160e76ddc373c5c9b3f230a8d21ee0d9f46f19cf547f4799d6bd6f692369400  guix-build-4bff4ce561b0/output/x86_64-linux-gnu/bitcoin-4bff4ce561b0-x86_64-linux-gnu-debug.tar.gz
  ff4a05d53920efd903f7f3ea13a0a7738548f1eb92165d32bd707e09a687262a  guix-build-4bff4ce561b0/output/x86_64-linux-gnu/bitcoin-4bff4ce561b0-x86_64-linux-gnu.tar.gz
  150b79a688eb5b2718b6a12a32eaeaf296fe5b7e0c5090dfc30f3f749c88fc44  guix-build-4bff4ce561b0/output/x86_64-w64-mingw32/SHA256SUMS.part
  692612b7989c4a90cff9cd30821d8210e4a556003d77c48560c0038e7cd7bc89  guix-build-4bff4ce561b0/output/x86_64-w64-mingw32/bitcoin-4bff4ce561b0-win64-codesigning.tar.gz
  b480ec868f6d4e070707a8ff98ae53416de88c7cb1125e475de823e6046c2a52  guix-build-4bff4ce561b0/output/x86_64-w64-mingw32/bitcoin-4bff4ce561b0-win64-debug.zip
  ac2108d4c80a85aa9d72258e5d69f90b8fa8475ab91a0305717d5ce478f4951c  guix-build-4bff4ce561b0/output/x86_64-w64-mingw32/bitcoin-4bff4ce561b0-win64-setup-unsigned.exe
  daef011a4775354b715591ca3e629bcfd9a7b582875c16dae26dc1cb91bde829  guix-build-4bff4ce561b0/output/x86_64-w64-mingw32/bitcoin-4bff4ce561b0-win64-unsigned.zip
  ```

ACKs for top commit:
  hebasto:
    ACK 4bff4ce561.

Tree-SHA512: a5e373e5e7d2d3c626ac639816fadb6aed8acd63d1a7a54613b00c23c1361d5e6731bb3caa573d549135a7ccec0ff22133a301474780b386ad5b82792fe5f3b9
2025-08-11 10:12:46 +01:00
UdjinM6 ca64b71ed5
test: fix scripts in `blockfilter_basic_test` 2025-08-09 12:31:59 +03:00
Ava Chow daca51bf80
Merge bitcoin/bitcoin#32750: refactor: CFeeRate encapsulates FeeFrac internally
d3b8a54a81 Refactor CFeeRate to use FeeFrac internally (Pol Espinasa)

Pull request description:

  The `FeeFrac` type represents a fraction, intended to be used for `sats/vbyte` or `sats/WU`. It was added to improve accuracy when evaluating fee rates in cluster mempool. [1]
  But it can also be used to fix the precision issues that the current `CFeeRate` class has now.

  At the moment, `CFeeRate` handles the fee rate as  satoshis per kilovirtualbyte: `CAmount / kvB` using an integer.
  This PR fix `CFeeRate` precision issues by encapsulating `FeeFrac` internally keeping backwards compatibility.

  This PR can also be used as a based to use multiple units on RPC calls as detailed in this issue [2].

  Some previous discussions:
  [1] https://github.com/bitcoin/bitcoin/pull/30535
  [2] https://github.com/bitcoin/bitcoin/issues/32093

ACKs for top commit:
  achow101:
    ACK d3b8a54a81
  murchandamus:
    code review, lightly tested ACK d3b8a54a81
  ismaelsadeeq:
    re-ACK d3b8a54a81 📦
  theStack:
    Code-review ACK d3b8a54a81

Tree-SHA512: 5a8149d81e82ad4e60a0e76ff6a82a5b1c4e212cf5156c1cdd16bf9acbb351e7be458eac3f0a2ae89107f331062b299c1d9ca649d3b820ad0b68e6d1a14292e5
2025-08-08 18:11:05 -07:00
Lőrinc fab2980bdc assumevalid: log every script validation state change
The `-assumevalid` option skips script verification for a specified block and all its ancestors during Initial Block Download.
Many new users are surprised when this suddenly slows their node to a halt.
This commit adds a log message to clearly indicate when this optimization ends and full validation begins (and vice versa).

When using `-assumeutxo`, logging is suppressed for the active assumed-valid chainstate and for the background validation chainstate to avoid the confusing toggles.

-------

> cmake -B build && cmake --build build && mkdir -p demo && build/bin/bitcoind -datadir=demo -stopatheight=500 | grep 'signature validation'

```
2025-08-08T20:59:21Z Disabling signature validations at block #1 (00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048).
2025-08-08T20:59:21Z Enabling signature validations at block #100 (000000007bc154e0fa7ea32218a72fe2c1bb9f86cf8c9ebf9a715ed27fdb229a).
2025-08-08T20:59:21Z Disabling signature validations at block #200 (000000008f1a7008320c16b8402b7f11e82951f44ca2663caf6860ab2eeef320).
2025-08-08T20:59:21Z Enabling signature validations at block #300 (0000000062b69e4a2c3312a5782d7798b0711e9ebac065cd5d19f946439f8609).
```
2025-08-08 16:47:34 -07:00
Eugene Siegel e8f9c37a3b log: clean up LogPrintStr_ and Reset, prefix all logs with "[*]" when there are suppressions
In LogPrintStr_:
- remove an unnecessary BCLog since we are in the BCLog namespace.
- remove an unnecessary \n when rate limiting is triggered since
  FormatLogStrInPlace will add it.
- move the ratelimit bool into an else if block.
- prefix all log lines with [*] when suppressions exist. Previously this
  was only done if should_ratelimit was true.

In Reset:
- remove an unnecessary \n since FormatLogStrInPlace will add it.
- Change Level::Info to Level::Warning.
2025-08-08 16:45:01 -04:00
Eugene Siegel 3c7cae49b6 log: change LogLimitStats to struct LogRateLimiter::Stats
Clean up the noisy LogLimitStats and remove references to the time
window.

Co-Authored-By: stickies-v <stickies-v@protonmail.com>
2025-08-08 16:45:01 -04:00
Anthony Towns 876dbdfb47 tests: drop expect_disconnect behaviour for tx relay 2025-08-09 05:10:27 +10:00
Anthony Towns b29ae9efdf validation: only check input scripts once
Previously, we would check failing input scripts twice when considering
a transaction for the mempool, in order to distinguish policy failures
from consensus failures. This allowed us both to provide a different
error message and to discourage peers for consensus failures. Because we
are no longer discouraging peers for consensus failures during tx relay,
and because checking a script can be expensive, only do this once.

Also renames non-mandatory-script-verify-flag error to
mempool-script-verify-flag-failed.
2025-08-09 05:06:01 +10:00
Anthony Towns 266dd0e10d net_processing: drop MaybePunishNodeForTx
Do not discourage nodes even when they send us consensus invalid
transactions.

Because we do not discourage nodes for transactions we consider
non-standard, we don't get any DoS protection from this check in
adversarial scenarios, so remove the check entirely both to simplify the
code and reduce the risk of splitting the network due to changes in tx
relay policy.
2025-08-09 04:45:51 +10:00
willcl-ark db3228042b
util: detect and warn when using exFAT on macOS
exFAT is known to cause corruption on macOS. See #28552.

Therefore we should warn when using this fs format for either the blocks
or data directories on macOS.

Co-authored-by: l0rinc <pap.lorinc@gmail.com>
2025-08-08 19:21:06 +01:00
merge-script f679bad605
Merge bitcoin/bitcoin#33105: validation: detect witness stripping without re-running Script checks
27aefac425 validation: detect witness stripping without re-running Script checks (Antoine Poinsot)
2907b58834 policy: introduce a helper to detect whether a transaction spends Segwit outputs (Antoine Poinsot)
eb073209db qa: test witness stripping in p2p_segwit (Antoine Poinsot)

Pull request description:

  Since it was introduced in 4eb515574e (#18044), the detection of a stripped witness relies on running the Script checks 3 times. In the worst case, this consists in running Script validation for every single input 3 times.

  Detection of a stripped witness is necessary because in this case wtxid==txid, and the transaction's wtxid must not be added to the reject filter or it could allow a malicious peer to interfere with txid-based orphan resolution as used in 1p1c package relay.

  However it is not necessary to run Script validation to detect a stripped witness (much less so doing it 3 times in a row). There are 3 types of witness program: defined program types (Taproot, P2WPKH and P2WSH), undefined types, and the Pay-to-anchor carve-out.

  For defined program types, Script validation with an empty witness will always fail (by consensus). For undefined program types, Script validation is always going to fail regardless of the witness (by standardness). For P2A, an empty witness is never going to lead to a failure.

  Therefore it holds that we can always detect a stripped witness without re-running Script validation. However this might lead to more "false positives" (cases where we return witness stripping for an otherwise invalid transaction) than the existing implementation. For instance a transaction with one P2PKH input with an invalid signature and one P2WPKH input with its witness stripped. The existing implementation would treat it as consensus invalid while the implementation in this PR would always consider it witness stripped.

  h/t AJ: this essentially implements a variant of https://github.com/bitcoin/bitcoin/pull/33066#issuecomment-3135258539.

ACKs for top commit:
  sipa:
    re-ACK 27aefac425
  Crypt-iQ:
    re-ACK 27aefac425
  glozow:
    reACK 27aefac425

Tree-SHA512: 70cf76b655b52bc8fa2759133315a3f11140844b6b80d9de3c95f592050978cc01a87bd2446e3a9c25cc872efea7659d6da3337b1a709511771fece206e9f149
2025-08-08 14:18:04 -04:00
Hennadii Stepanov 63d604af05
Merge bitcoin/bitcoin#33152: Release: Prepare "Open Transifex translations for v30.0" step
656e16aa5e qt: Update the `src/qt/locale/bitcoin_en.xlf` translation source file (Hennadii Stepanov)
a0eaa44925 Fix typos (Hennadii Stepanov)
8d4aaaec49 Update Transifex slug for 30.x (Hennadii Stepanov)

Pull request description:

  This PR follows our [Release Process](53a996f122/doc/release-process.md).

  It is required to open Transifex translations for v30.0, as scheduled in https://github.com/bitcoin/bitcoin/issues/32275.

  For reference, see the previous similar PR: https://github.com/bitcoin/bitcoin/pull/31809.

  **Note for reviewers:**

  To reproduce the diff in the last commit, run:
  ```
  cmake --preset dev-mode
  cmake --build build_dev_mode --target translate
  ```

ACKs for top commit:
  laanwj:
    Code review ACK 656e16aa5e
  stickies-v:
    ACK 656e16aa5e , was able to reproduce

Tree-SHA512: 403b534329755079584fcdf98b696e3e75952dfc8d069f305843dbfa85de95f6816ee1d5dfc9b553c7c7f52cc296cb8d3cb03207051d26e0e76ff30d377f49e4
2025-08-08 16:40:22 +01:00
Antoine Poinsot 27aefac425 validation: detect witness stripping without re-running Script checks
Since it was introduced in 4eb515574e (#18044), the detection of a
stripped witness relies on running the Script checks 3 times. In the worst case, this consists in
running Script validation 3 times for every single input.

Detection of a stripped witness is necessary because in this case wtxid==txid, and the transaction's
wtxid must not be added to the reject filter or it could allow a malicious peer to interfere with
txid-based orphan resolution as used in 1p1c package relay.

However it is not necessary to run Script validation to detect a stripped witness (much less so
doing it 3 times in a row). There are 3 types of witness program: defined program types (Taproot,
P2WPKH, P2WSH), undefined types, and the Pay-to-anchor carve-out.

For defined program types, Script validation with an empty witness will always fail (by consensus).
For undefined program types, Script validation is always going to fail regardless of the witness (by
standardness). For P2A, an empty witness is never going to lead to a failure.

Therefore it holds that we can always detect a stripped witness without re-running Script validation.
However this might lead to more "false positives" (cases where we return witness stripping for an
otherwise invalid transaction) than the existing implementation. For instance a transaction with one
P2PKH input with an invalid signature and one P2WPKH input with its witness stripped. The existing
implementation would treat it as consensus invalid while the implementation in this commit would
always consider it witness stripped.
2025-08-08 11:07:47 -04:00
Antoine Poinsot 2907b58834 policy: introduce a helper to detect whether a transaction spends Segwit outputs
We will use this helper in later commits to detect witness stripping without having
to execute every input Script three times in a row.
2025-08-08 11:07:47 -04:00
fanquake 4bff4ce561
contrib: drop bitcoin-util exception from FORTIFY check
It's got memcpy_chk.
2025-08-08 08:47:44 +01:00
Ryan Ofsky 26e9db2df0
Merge bitcoin/bitcoin#31886: cli: return local services in -netinfo
721a051320 test: add coverage for -netinfo header and local services (l0rinc)
f7d2db28e9 netinfo: return shortened services, if peers list requested (Jon Atack)
4489ab526a netinfo: return local services in the default report (Jon Atack)

Pull request description:

  Add local services info to -netinfo dashboard that already provides this info for each of the peer connections.

  - `bitcoin-cli -netinfo` with no args passed provides a nice easy-to-understand services list:

  ```
  Bitcoin Core client v28.99.0 - server 70016/Satoshi:28.99.0/

           ipv4    ipv6   onion     i2p   cjdns   total   block  manual
  in          0       0      12       8       0      20
  out         6       0       4       3       2      15       3       4
  total       6       0      16      11       2      35

  Local services: network, bloom, witness, compact filters, network limited, p2p v2

  Local addresses
  ```

  - With a details level passed, e.g. `-netinfo 3`, print the services in the versions header instead (to avoid adding a line for more static information), in the same format as the peers list (see `-netinfo help` for info on the output of the `serv` column):

  ```
  Bitcoin Core client v28.99.0 - server 70016/Satoshi:28.99.0/ - services nbwcl2

  <->   type   net   serv  v  mping   ping send recv  txn  blk  hb addrp addrl  age  asmap  id version
   in        onion         1    283    498   48   48    *              .         77        388 70016
   in        onion   nwl2  2    318    485    5  111                             79        372 70016/Satoshi:28.0.0/
   in        onion    nwl  1    342    344    4    1   53             96         84        344 70016/Satoshi:26.0.0/
   in        onion    nwl  1    411    601    4    1   35            124         85        339 70016/Satoshi:26.0.0/
   in        onion  nwcl2  2    436   4330    2    2    2             31         13        623 70016/Satoshi:28.0.0/
   in        onion    wl2  2    445    503    4    4    6            138         81        363 70016/Satoshi:28.0.0/
   in        onion    nwl  1    462    726    4    1   56             92         81        365 70016/Satoshi:23.0.0/
   in        onion    nwl  1    500    765    4    1   34             94         83        351 70016/Satoshi:25.0.0/
   in        onion   nwl2  2    578    684    4    0    1            134         87        327 70016/Satoshi:28.0.0/
   in          i2p   nwl2  2    712   1322    4    2   35            204     1   93        308 70016/Satoshi:27.2.0/
   in        onion   nwl2  2    727    873    5    5   56            162         85        342 70016/Satoshi:27.1.0/
   in          i2p   nwl2  2    749    976    4    2   25            120         72        408 70016/Satoshi:27.1.0/
   in          i2p   nwl2  2    776    954    4    1    0             72         68        426 70016/Satoshi:28.0.0/
   in          i2p   nbwl  1    883   1735    4    4                  53         34        551 70016/Satoshi:26.0.0/
   in          i2p  nwcl2  2    920   1044    2    0    0            131         83        350 70016/Satoshi:28.0.0/
   in        onion     wl  1   1021  20832   29   67                   3         49        501 70016/Satoshi:23.0.0/
   in          i2p  nwcl2  2   1830   1830    5    0                   3          3        668 70016/Satoshi:27.1.0/
   in        onion    nwl  1  41155  41155   87  204                              4        658 70016/Satoshi:25.0.0/
  out   full  ipv4   nwl2  2     74     93    0    0    0           1028         85   1221 338 70016/Satoshi:27.1.0/
  out   full  ipv4    nwl  1     82    104    0    2    0    5  .   1076         95  13536 301 70016/Satoshi:26.0.0/
  out   full  ipv4    nwl  1    147    178    2    2    0   28  .   1104         95 395570 300 70016/Satoshi:25.0.0/
  out  block  ipv4   nwl2  2    166    513    2    2    *              .         88  38001 324 70016/Satoshi:27.2.0/
  out   full  ipv4     wl  1    193    201    0    4    0           1035         94  31376 307 70016/Satoshi:25.99.0/
  out   full  ipv4   nwl2  2    199    796    1    1    0           1027         94   9723 304 70016/Satoshi:27.2.0/
  out manual cjdns   nwl2  2    213    235    1    9    0           1109         83        353 70016/Satoshi:28.99.0/
  out   full onion   nbwl  1    282    457    3    3    1           1130         73        404 70016/Satoshi:25.0.0/
  out  block onion   nbwl  1    324    353   23   23    *              .         85        341 70016/Satoshi:26.0.0/
  out manual cjdns   nwl2  2    340    445    1    1    7           1059         82        361 70016/Satoshi:27.0.0/
  out manual onion    wl2  2    386    386    1    1    1           1048         84        345 70016/Satoshi:28.99.0/
  out manual   i2p  nwcl2  2    697   1084    1    1    8           1113     3   93        310 70016/Satoshi:27.0.0/
  out   full   i2p  nwcl2  2    730   1254    1    9    0           1128         89        318 70016/Satoshi:28.0.0/
  out   full   i2p  nwcl2  2    765   1804    1    1    1           1132         72        409 70016/Satoshi:28.0.0/
                                 ms     ms  sec  sec  min  min                  min

           ipv4    ipv6   onion     i2p   cjdns   total   block  manual
  in          0       0      12       6       0      18
  out         6       0       3       3       2      14       2       4
  total       6       0      15       9       2      32

  Local addresses
  ```

ACKs for top commit:
  l0rinc:
    Redid the rebase, reran the test, reACK 721a051320
  0xB10C:
    ACK 721a051320
  danielabrozzoni:
    reACK 721a051320

Tree-SHA512: 7206b0eadfe6bafea2a483eb898e7e5b104aca9c117d3bf68cd4c01bfa1108f179ff8a1061d97cdfc57f71ff5351774c83824b035892f7f382fdeaf10d3df359
2025-08-07 22:43:55 -04:00
merge-script 2bb06bcaf2
Merge bitcoin/bitcoin#31679: cmake: Install internal binaries to <prefix>/libexec/
f49840dd90 doc: Fix typo in files.md (Ryan Ofsky)
f5cf0b1ccc bitcoin wrapper: improve help output (Ryan Ofsky)
c810b168b8 doc: Add description of installed files to files.md (Ryan Ofsky)
94ffd01a02 doc: Add release notes describing libexec/ binaries (Ryan Ofsky)
cd97905ebc cmake: Move internal binaries from bin/ to libexec/ (Ryan Ofsky)

Pull request description:

  This change moves binaries that are not typically invoked directly by users from the `bin/` directory to the `libexec/` directory in CMake installs and binary releases. The goal of the PR is to introduce a distinction between internal and external binaries so starting with #31802, we can use IPC to implement features in new binaries without adding those binaries to the CLI. The change also helps reduce clutter in `bin/`, making it easier for users to identify useful tools to run. Summary of changes:

  - For **source builds** (i.e. developer builds) — There are no changes.
  - For **source installs** (i.e. `cmake --install` result) — `test_bitcoin`, `test_bitcoin-qt`, and `bench_bitcoin` are installed in `${CMAKE_PREFIX_PATH}/libexec` instead of `${CMAKE_PREFIX_PATH}/bin`, so they are no longer on the system `PATH`. However, they can still be invoked from the `libexec/` directory, or from the CLI as `bitcoin test`, `bitcoin test-gui`, and `bitcoin bench`, respectively.
  - For **binary releases** — Since `test_bitcoin` is the only test binary enabled in releases, the only change is moving `test_bitcoin` from `bin/` to `libexec/`.

  <details><summary>Details</summary>
  <p>

   The table below shows the install location of each binary after this change, and the availability of each binary.

  | Binary               | Location     | Availability         | Change                        |
  |----------------------|--------------|----------------------|-------------------------------|
  | `bitcoin`            | `bin/`       | 📦 Binary release (since #31375) | Unchanged                     |
  | `bitcoin-cli`        | `bin/`       | 📦 Binary release     | Unchanged                     |
  | `bitcoind`           | `bin/`       | 📦 Binary release     | Unchanged                     |
  | `bitcoin-qt`         | `bin/`       | 📦 Binary release     | Unchanged                     |
  | `bitcoin-tx`         | `bin/`       | 📦 Binary release     | Unchanged                     |
  | `bitcoin-util`       | `bin/`       | 📦 Binary release     | Unchanged                     |
  | `bitcoin-wallet`     | `bin/`       | 📦 Binary release     | Unchanged                     |
  | `bench_bitcoin`      | `libexec/`   | 🛠 Source build only  | Moved from `bin/`             |
  | `bitcoin-chainstate` | `libexec/`   | 🛠 Source build only  | Newly installed (was built)   |
  | `bitcoin-gui`        | `libexec/`   | 🛠 Source build only (until #31802) | Moved from `bin/`             |
  | `bitcoin-node`       | `libexec/`   | 🛠 Source build only (until #31802) | Moved from `bin/`             |
  | `test_bitcoin`       | `libexec/`    | 📦 Binary release     | Moved from `bin/`             |
  | `test_bitcoin-qt`    | `libexec/`   | 🛠 Source build only  | Moved from `bin/`             |

  </p>
  </details>

  ---

  This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/issues/28722).

ACKs for top commit:
  l0rinc:
    re-ACK f49840dd90
  Sjors:
    re-ACK f49840dd90
  achow101:
    ACK f49840dd90
  janb84:
    re ACK f49840dd90
  BrandonOdiwuor:
    Tested ACK f49840dd90
  hodlinator:
    re-ACK f49840dd90
  willcl-ark:
    utACK f49840dd90

Tree-SHA512: 858a2e1a53db11ee3c5c759bfdeea566f242b9ce5e8a898fa435222e41662b8184577c0dc2c4c058294b4de41d8cb3ba3e5d24c748c280efa4a3f84e3ec4344d
2025-08-07 14:53:26 +01:00
merge-script 6a2bb0fd83
Merge bitcoin/bitcoin#33151: subtree: update crc32c subtree
9a5d29711a Squashed 'src/crc32c/' changes from b60d2b7334..efb8ea04e4 (fanquake)

Pull request description:

  Sync the subtree with latest upstream. The changes here are a no-op, but pull them to fix the drive-by-typo-fixing: #33057.

  Includes https://github.com/bitcoin-core/crc32c-subtree/pull/8.

ACKs for top commit:
  maflcko:
    lgtm ACK 8ef8dd6871
  janb84:
    ACK 8ef8dd6871

Tree-SHA512: b20a47514218206b934c4aa27ec667fb9b3ec7f7388a78725c52fc6e916358d2b9a2075a37808dbc2430b4c7816511ecf20e36bfe2fbd2d8a26bc8882a46d5e7
2025-08-07 12:59:44 +01:00
Hennadii Stepanov 656e16aa5e
qt: Update the `src/qt/locale/bitcoin_en.xlf` translation source file
Steps to reproduce the diff on Ubuntu 25.04:
```
cmake --preset dev-mode
cmake --build build_dev_mode --target translate
```
2025-08-07 12:55:54 +01:00
Hennadii Stepanov a0eaa44925
Fix typos 2025-08-07 12:55:18 +01:00
merge-script b43b8be782
Merge bitcoin/bitcoin#33125: ci: Use mlc `v1` and fix typos
f28a94b40e ci: update shellcheck to v0.11.0 (fanquake)
e46af30441 ci: update mlc to v1 (fanquake)
7d60c0eb69 fix typo (hoffman)
49f2f3c89f doc: fix typos (fanquake)
d818340e7e test: Rename shuffled_indeces to shuffled_indices (fuder.eth)
96f8673b87 doc: fix typos (kilavvy)

Pull request description:

  Update mcl to `v1` & shellcheck to `0.11.0`.
  Includes other cherry-picked lint-related changes.

ACKs for top commit:
  maflcko:
    lgtm ACK f28a94b40e

Tree-SHA512: 5a84d1bf862a38918237d37de7713338388c3c8d66228b05d19aaf651835d955037c79dc8825ea8f8693a5a9ece64d245e2a747d2c25b9c6cb44a3b28f056fb8
2025-08-07 11:57:39 +01:00
Hennadii Stepanov 8d4aaaec49
Update Transifex slug for 30.x
Update the Transifex slug to match the new resource created for the
upcoming 30.x branch.
2025-08-07 11:48:29 +01:00
fanquake 8ef8dd6871
Update crc32c subtree to latest upstream master 2025-08-07 09:27:25 +01:00
fanquake 9a5d29711a Squashed 'src/crc32c/' changes from b60d2b7334..efb8ea04e4
efb8ea04e4 Merge bitcoin-core/crc32c-subtree#8: Sync to upstream
4a7a05c48d Merge remote-tracking branch 'google/main' into bitcoin-fork
21fc8ef304 Fix typo (#59)
89f69843a1 Fix misspelled "Proccess" in comment
02e65f4fd3 Bump deps (#56)
b9d6e825a1 Fix Windows CI build. (#54)
bbbb93ab5d Switch CI to GitHub Actions (#55)
d46cd17d70 Add clangd cache directory to .gitignore.

git-subtree-dir: src/crc32c
git-subtree-split: efb8ea04e4a5b6a18dc4bc1908fd1cb2dcefb585
2025-08-07 09:27:25 +01:00
fanquake f28a94b40e
ci: update shellcheck to v0.11.0 2025-08-07 09:03:15 +01:00
fanquake e46af30441
ci: update mlc to v1 2025-08-07 09:03:15 +01:00
hoffman 7d60c0eb69
fix typo 2025-08-07 09:03:15 +01:00
fanquake 49f2f3c89f
doc: fix typos 2025-08-07 09:01:56 +01:00
fuder.eth d818340e7e
test: Rename shuffled_indeces to shuffled_indices 2025-08-07 09:01:56 +01:00
kilavvy 96f8673b87
doc: fix typos 2025-08-07 09:01:55 +01:00
Ava Chow d767503b6a
Merge bitcoin/bitcoin#33039: refactor,test: follow-ups to multi-byte block obfuscation
86e3a0a8cb refactor: standardize obfuscation memory alignment (Lőrinc)
13f00345c0 refactor: write `Obfuscation` object when new key is generated in dbwrapper (Lőrinc)
e5b1b7c557 refactor: rename `OBFUSCATION_KEY_KEY` (Lőrinc)
298bf95105 refactor: simplify `Obfuscation::HexKey` (Lőrinc)
2dea045425 test: make `obfuscation_serialize` more thorough (Lőrinc)
a17d8202c3 test: merge xor_roundtrip_random_chunks and xor_bytes_reference (Lőrinc)

Pull request description:

  Follow up for https://github.com/bitcoin/bitcoin/pull/31144
  Applied the remaining comments in separate commits - except for the last one where I could group them.
  Please see the commit messages for more context.

ACKs for top commit:
  achow101:
    ACK 86e3a0a8cb
  ryanofsky:
    Code review ACK 86e3a0a8cb, just tweaking key write assert as suggested
  hodlinator:
    ACK 86e3a0a8cb

Tree-SHA512: 967510a141fbb57bf9d088d92b554cf2fffc2f6aa0eab756cbae3230f53e9b04ceebcc6fea5f3383c01ad41985ecde5b5686c64a771ca9deae3497b9b88c1c8b
2025-08-06 15:46:18 -07:00
merge-script cf15d45192
Merge bitcoin/bitcoin#33044: contrib: drop use of `PermissionsStartOnly` & `Group=`
18d1071dd1 init: replace deprecated PermissionsStartOnly systemd directive (Florian Schmaus)
1caaf65043 init: remove Group= as it will default to the user's default group (Florian Schmaus)

Pull request description:

  > This removes the redundant 'Group=' directive and replaces the deprecated 'PermissionsStartOnly' directive.

  Picks up #16994 / #19513. The concern in both of these PRs was changing this too early, while systemd v240 was still prelevant on supported systems. That was ~5 years ago, and from what I can see, no modern/supported OS is still using an older systemd.

  Separately , I am wondering if we should move these files out to https://github.com/bitcoin-core/packaging/.

ACKs for top commit:
  willcl-ark:
    reACK 18d1071dd1

Tree-SHA512: a994e38099e68e8377ac820d3cd2047cbfca065ba617eff0d621e3c3b99b05bbd2329631aa8c885a83cf5d0066d97ff5be75bf5834e9f759d8f0d2c6c9b64851
2025-08-06 14:50:47 +01:00
Antoine Poinsot 83950275ed qa: unit test sighash caching 2025-08-06 09:40:17 -04:00
Antoine Poinsot b221aa80a0 qa: simple differential fuzzing for sighash with/without caching 2025-08-06 09:33:30 -04:00
Pieter Wuille 92af9f74d7 script: (optimization) introduce sighash midstate caching 2025-08-06 09:33:17 -04:00
Pieter Wuille 8f3ddb0bcc script: (refactor) prepare for introducing sighash midstate cache 2025-08-06 09:33:17 -04:00
Pieter Wuille 9014d4016a tests: add sighash caching tests to feature_taproot 2025-08-06 09:33:14 -04:00
merge-script d7ed47fb80
Merge bitcoin/bitcoin#33077: kernel: create monolithic kernel static library
fdbade6f8d kernel: create monolithic kernel static library (Cory Fields)

Pull request description:

  Currently, consuming `libbitcoinkernel.a` requires all its dependency static libraries to be available. A switch to a monolithic variant, which contains object files from its dependencies, was discussed in the Kernel WG. The necessary preparations in the libsecp256k1 build scripts were completed in https://github.com/bitcoin-core/secp256k1/pull/1678, which are now available in this repository since https://github.com/bitcoin/bitcoin/pull/33036.

  The changes in this PR were picked from https://github.com/theuni/bitcoin/commits/static_kernel/, with an additional adjustment in `libbitcoinkernel.pc.in`.

  This PR can be tested as described in https://github.com/bitcoin/bitcoin/pull/30814#issue-2505698234.

ACKs for top commit:
  TheCharlatan:
    ACK fdbade6f8d
  stickies-v:
    tACK fdbade6f8d

Tree-SHA512: bd9e9dbb0b765bdcb162fb3f4ad3c4e01fe5fa0b7061f97d0bad64442b21db036cbe0e4341fd45d43a8862df76d62c9532ca8945f76423aca753c6b528f70873
2025-08-06 13:08:58 +01:00
merge-script 38e6ea9f3a
Merge bitcoin/bitcoin#33101: cmake: Proactively avoid use of `SECP256K1_DISABLE_SHARED`
b093a19ae2 cmake: Proactively avoid use of `SECP256K1_DISABLE_SHARED` (Hennadii Stepanov)
eb59a192d9 cmake, refactor: Encapsulate adding secp256k1 subtree in function (Hennadii Stepanov)

Pull request description:

  The `SECP256K1_DISABLE_SHARED` CMake variable has been [removed](https://github.com/bitcoin-core/secp256k1/pull/1688) upstream.

  This PR removes its usage ahead of the next `secp256k1` subtree update to prevent breakage and simplify integration.

ACKs for top commit:
  fanquake:
    ACK b093a19ae2

Tree-SHA512: a87cee71cf356f458f68d3163253ca5c4f86e56d268006b6b8e1d4b2c009ba436148a07a6b67b89ddbb2d0e3c1113ab4b4906c5fc5624cb3082b20e916e0e82b
2025-08-06 11:31:17 +01:00
merge-script c92115dcb2
Merge bitcoin/bitcoin#33119: rpc: Fix 'getdescriptoractivity' RPCHelpMan, add test to verify fix
3543bfdfec test: Fix 'getdescriptoractivity' RPCHelpMan, add test to verify 'spend_vin' is the correct field (Chris Stewart)

Pull request description:

  Fixes bug in `getdescriptoractivity` RPC help manual.

  Here is the line that pushes `spend_vin` field, there is no `spend_vout` json field.

  https://github.com/bitcoin/bitcoin/blob/master/src/rpc/blockchain.cpp#L2757

ACKs for top commit:
  nervana21:
    tACK 3543bfd
  luke-jr:
    utACK 3543bfdfec
  jonatack:
    ACK 3543bfdfec

Tree-SHA512: 2cd543569a87261d8d804d9afe36f8e8ead55839c01da9c4831aea3ced7d1251e6885621e628898105700aae4d76cbb8a682f518f33c1c52163e66f75ec87a61
2025-08-06 11:16:32 +01:00
merge-script 1dab8d0635
Merge bitcoin/bitcoin#33113: refactor: Use immediate lambda to work around GCC bug 117966
c7a24c3052 ci: Re-enable DEBUG=1 in centos task (MarcoFalke)
a7bafb3e05 refactor: Use immediate lambda to work around GCC bug 117966 (Hennadii Stepanov)

Pull request description:

  This PR is a follow-up to the recently merged [#31244](https://github.com/bitcoin/bitcoin/pull/31244), and provides a workaround for affected GCC compilers, similar to https://github.com/bitcoin/bitcoin/pull/31493.

  Without this workaround, building the master branch using GCC 13 or 14 with the `-D_GLIBCXX_DEBUG` flag fails with the following error:
  ```
  $ cmake -B build -DAPPEND_CPPFLAGS="-D_GLIBCXX_DEBUG"
  -- The CXX compiler identification is GNU 13.3.0
  <snip>
  $ cmake --build build
  [2/10] Building CXX object src/CMakeFiles/bitcoin_common.dir/musig.cpp.o
  FAILED: src/CMakeFiles/bitcoin_common.dir/musig.cpp.o
  /usr/bin/ccache /usr/bin/c++ -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_NO_CXX98_FUNCTION_BASE -I/home/hebasto/dev/bitcoin/build/src -I/home/hebasto/dev/bitcoin/src -I/home/hebasto/dev/bitcoin/src/univalue/include -I/home/hebasto/dev/bitcoin/src/secp256k1/include -O2 -g -std=c++20 -fPIC -fno-extended-identifiers -fdebug-prefix-map=/home/hebasto/dev/bitcoin/src=. -fmacro-prefix-map=/home/hebasto/dev/bitcoin/src=. -fstack-reuse=none -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -Wstack-protector -fstack-protector-all -fcf-protection=full -fstack-clash-protection -Wall -Wextra -Wformat -Wformat-security -Wvla -Wredundant-decls -Wdate-time -Wduplicated-branches -Wduplicated-cond -Wlogical-op -Woverloaded-virtual -Wsuggest-override -Wimplicit-fallthrough -Wunreachable-code -Wbidi-chars=any -Wundef -Wno-unused-parameter -MD -MT src/CMakeFiles/bitcoin_common.dir/musig.cpp.o -MF src/CMakeFiles/bitcoin_common.dir/musig.cpp.o.d -o src/CMakeFiles/bitcoin_common.dir/musig.cpp.o -c /home/hebasto/dev/bitcoin/src/musig.cpp -D_GLIBCXX_DEBUG
  In file included from /usr/include/c++/13/debug/stl_iterator.h:32,
                   from /usr/include/c++/13/bits/stl_iterator.h:3003,
                   from /usr/include/c++/13/string:48,
                   from ../src/crypto/sha256.h:10,
                   from ../src/hash.h:12,
                   from ../src/pubkey.h:10,
                   from ../src/musig.h:8,
                   from ../src/musig.cpp:5:
  ../src/musig.h:17:108:   in ‘constexpr’ expansion of ‘std::span<const unsigned char>(util::hex_literals::operator""_hex_u8<util::detail::Hex<65>{std::array<std::byte, 32>{std::__array_traits<std::byte, 32>::_Type{(std::byte)134, (std::byte)128, (std::byte)135, (std::byte)202, (std::byte)2, (std::byte)166, (std::byte)249, (std::byte)116, (std::byte)196, (std::byte)89, (std::byte)137, (std::byte)36, (std::byte)195, (std::byte)107, (std::byte)87, (std::byte)118, (std::byte)45, (std::byte)50, (std::byte)203, (std::byte)69, (std::byte)113, (std::byte)113, (std::byte)103, (std::byte)227, (std::byte)0, (std::byte)98, (std::byte)44, (std::byte)113, (std::byte)103, (std::byte)227, (std::byte)137, (std::byte)101}}}>())’
  /usr/include/c++/13/span:204:57:   in ‘constexpr’ expansion of ‘((std::span<const unsigned char>*)this)->std::span<const unsigned char>::span<const unsigned char*>((& __arr)->std::array<unsigned char, 32>::data(), 32)’
  /usr/include/c++/13/span:167:4:   in ‘constexpr’ expansion of ‘__gnu_debug::__valid_range<const unsigned char*>(__first, (__first + ((sizetype)__count)))’
  /usr/include/c++/13/debug/helper_functions.h:267:44:   in ‘constexpr’ expansion of ‘__gnu_debug::__valid_range_aux<const unsigned char*>(__first, __last, (_Integral(), _Integral()))’
  /usr/include/c++/13/debug/helper_functions.h:197:44:   in ‘constexpr’ expansion of ‘__gnu_debug::__valid_range_aux<const unsigned char*>(__first, __last, (std::__iterator_category<const unsigned char*>(__first), std::iterator_traits<const unsigned char*>::iterator_category()))’
  /usr/include/c++/13/debug/helper_functions.h:183:44:   in ‘constexpr’ expansion of ‘__gnu_debug::__valid_range_aux<const unsigned char*>(__first, __last, (std::input_iterator_tag(), std::input_iterator_tag()))’
  /usr/include/c++/13/debug/helper_functions.h:143:20: error: ‘(((const unsigned char*)(&<anonymous>.std::array<unsigned char, 32>::_M_elems)) == 0)’ is not a constant expression
    143 |     { return __ptr == 0; }
        |              ~~~~~~^~~~
  [3/10] Building CXX object src/CMakeFiles/bitcoin_common.dir/script/descriptor.cpp.o
  FAILED: src/CMakeFiles/bitcoin_common.dir/script/descriptor.cpp.o
  /usr/bin/ccache /usr/bin/c++ -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_NO_CXX98_FUNCTION_BASE -I/home/hebasto/dev/bitcoin/build/src -I/home/hebasto/dev/bitcoin/src -I/home/hebasto/dev/bitcoin/src/univalue/include -I/home/hebasto/dev/bitcoin/src/secp256k1/include -O2 -g -std=c++20 -fPIC -fno-extended-identifiers -fdebug-prefix-map=/home/hebasto/dev/bitcoin/src=. -fmacro-prefix-map=/home/hebasto/dev/bitcoin/src=. -fstack-reuse=none -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -Wstack-protector -fstack-protector-all -fcf-protection=full -fstack-clash-protection -Wall -Wextra -Wformat -Wformat-security -Wvla -Wredundant-decls -Wdate-time -Wduplicated-branches -Wduplicated-cond -Wlogical-op -Woverloaded-virtual -Wsuggest-override -Wimplicit-fallthrough -Wunreachable-code -Wbidi-chars=any -Wundef -Wno-unused-parameter -MD -MT src/CMakeFiles/bitcoin_common.dir/script/descriptor.cpp.o -MF src/CMakeFiles/bitcoin_common.dir/script/descriptor.cpp.o.d -o src/CMakeFiles/bitcoin_common.dir/script/descriptor.cpp.o -c /home/hebasto/dev/bitcoin/src/script/descriptor.cpp -D_GLIBCXX_DEBUG
  In file included from /usr/include/c++/13/debug/stl_iterator.h:32,
                   from /usr/include/c++/13/bits/stl_iterator.h:3003,
                   from /usr/include/c++/13/string:48,
                   from ../src/crypto/sha256.h:10,
                   from ../src/hash.h:12,
                   from ../src/pubkey.h:10,
                   from ../src/addresstype.h:9,
                   from ../src/outputtype.h:9,
                   from ../src/script/descriptor.h:8,
                   from ../src/script/descriptor.cpp:5:
  ../src/musig.h:17:108:   in ‘constexpr’ expansion of ‘std::span<const unsigned char>(util::hex_literals::operator""_hex_u8<util::detail::Hex<65>{std::array<std::byte, 32>{std::__array_traits<std::byte, 32>::_Type{(std::byte)134, (std::byte)128, (std::byte)135, (std::byte)202, (std::byte)2, (std::byte)166, (std::byte)249, (std::byte)116, (std::byte)196, (std::byte)89, (std::byte)137, (std::byte)36, (std::byte)195, (std::byte)107, (std::byte)87, (std::byte)118, (std::byte)45, (std::byte)50, (std::byte)203, (std::byte)69, (std::byte)113, (std::byte)113, (std::byte)103, (std::byte)227, (std::byte)0, (std::byte)98, (std::byte)44, (std::byte)113, (std::byte)103, (std::byte)227, (std::byte)137, (std::byte)101}}}>())’
  /usr/include/c++/13/span:204:57:   in ‘constexpr’ expansion of ‘((std::span<const unsigned char>*)this)->std::span<const unsigned char>::span<const unsigned char*>((& __arr)->std::array<unsigned char, 32>::data(), 32)’
  /usr/include/c++/13/span:167:4:   in ‘constexpr’ expansion of ‘__gnu_debug::__valid_range<const unsigned char*>(__first, (__first + ((sizetype)__count)))’
  /usr/include/c++/13/debug/helper_functions.h:267:44:   in ‘constexpr’ expansion of ‘__gnu_debug::__valid_range_aux<const unsigned char*>(__first, __last, (_Integral(), _Integral()))’
  /usr/include/c++/13/debug/helper_functions.h:197:44:   in ‘constexpr’ expansion of ‘__gnu_debug::__valid_range_aux<const unsigned char*>(__first, __last, (std::__iterator_category<const unsigned char*>(__first), std::iterator_traits<const unsigned char*>::iterator_category()))’
  /usr/include/c++/13/debug/helper_functions.h:183:44:   in ‘constexpr’ expansion of ‘__gnu_debug::__valid_range_aux<const unsigned char*>(__first, __last, (std::input_iterator_tag(), std::input_iterator_tag()))’
  /usr/include/c++/13/debug/helper_functions.h:143:20: error: ‘(((const unsigned char*)(&<anonymous>.std::array<unsigned char, 32>::_M_elems)) == 0)’ is not a constant expression
    143 |     { return __ptr == 0; }
        |              ~~~~~~^~~~
  ninja: build stopped: subcommand failed.
  ```

ACKs for top commit:
  achow101:
    ACK c7a24c3052

Tree-SHA512: bce0b98e89b763a2cd38976131f4e1b24071829ae19a46aa313f0983766c54c9494b5af72ce3f2bf0feee2e958c6ab9d90f814fd9b7bfb633caac3749363b279
2025-08-06 11:12:20 +01:00
merge-script 45bdbb1317
Merge bitcoin/bitcoin#33122: test: remove duplicated code in test/functional/wallet_migration.py
6a7c0d3f87 test: refactor to remove duplicated test code (kevkevinpal)

Pull request description:

  This is a followup to https://github.com/bitcoin/bitcoin/pull/32273

  This removes duplicated code in `test/functional/wallet_migration.py`
  [6a7c0d3](6a7c0d3f87) addresses https://github.com/bitcoin/bitcoin/pull/32273/files#r2237317368

ACKs for top commit:
  l0rinc:
    code review ACK 6a7c0d3f87
  ryanofsky:
    Code review ACK 6a7c0d3f87. Nice test deduplication, thanks for following on this!
  jonatack:
    ACK 6a7c0d3f87

Tree-SHA512: 7c1a00106be93304b30f1296d8db0082e99135e2b4574aa4efbefba9b0f0aebe602a0bfabdd9fc188185b0045842c6e8fd031f9bd4d12fe35d3feb6ff5a95e5d
2025-08-06 11:08:28 +01:00
merge-script a45cc17d34
Merge bitcoin/bitcoin#33115: cmake: Switch to generated `ts_files.cmake` file
a26fbee38f qt: Translations update (Hennadii Stepanov)
ca04eebd72 cmake: Switch to generated `ts_files.cmake` file (Hennadii Stepanov)
95341de6ca cmake, refactor: Move handling of Qt TS files into `locale` directory (Hennadii Stepanov)

Pull request description:

  This PR:
  1. Moves handling of Qt TS files into the `locale` directory.
  2. Switches from inferior globbing to the explicit file list generated by the [`bitcoin-maintainer-tools/update-translations.py`](https://github.com/bitcoin-core/bitcoin-maintainer-tools/blob/main/update-translations.py) script.

  Closes #32653.

ACKs for top commit:
  fanquake:
    ACK a26fbee38f

Tree-SHA512: 10596768c120d9da21a2340b693c5f39e9e1e02976805e14284cf9785780756f953d73d3d2b4a7246ada37acafe3e5d0e8927a8f51bf9fce3bc93a3544231489
2025-08-06 10:47:06 +01:00
merge-script b90da9c2e9
Merge bitcoin/bitcoin#33138: ci: Pass CI_FAILFAST_TEST_LEAVE_DANGLING into container
fa1d2f6380 ci: Pass CI_FAILFAST_TEST_LEAVE_DANGLING into container (MarcoFalke)

Pull request description:

  After commit fd813bf863, the env var `CI_FAILFAST_TEST_LEAVE_DANGLING` is no longer passed into the container.

  This is harmless, because it isn't needed for the Linux containers and macos doesn't use containers at all.

  However, it would be nice to document it as an allowed setting and consistently pass it on, when set. So do that here.

ACKs for top commit:
  fanquake:
    ACK fa1d2f6380

Tree-SHA512: b61780a27f4c2e11359827b1360a34a132e15bff94f358cbf4d453805afcafb873e2c395908b17610fae026ead93226c19a8f6be40fbb87b623ee992f3e2b43e
2025-08-06 10:30:47 +01:00
MarcoFalke fa1d2f6380
ci: Pass CI_FAILFAST_TEST_LEAVE_DANGLING into container 2025-08-05 18:59:43 +02:00
merge-script fd813bf863
Merge bitcoin/bitcoin#33002: ci: Only pass documented env vars
3333d3f75f ci: Only pass documented env vars (MarcoFalke)

Pull request description:

  The CI currently inherits almost all env vars from the host. This was problematic in the past and causing non-determinism, e.g. the fix in commit fa12558d21. It is still problematic today, see e.g. https://github.com/bitcoin/bitcoin/pull/31349#issuecomment-2586828644, or https://github.com/bitcoin/bitcoin/issues/32935

  This fixes https://github.com/bitcoin/bitcoin/issues/32935 by only passing env vars documented in `./ci/test/00_setup_env.sh`.

  Implementation-wise, instead of cramming the python code into the `python -c ""` statement, just start a fresh py file, which is easier to handle.

ACKs for top commit:
  willcl-ark:
    ACK 3333d3f75f

Tree-SHA512: f922e481a844128d7fbf773563278a3992c178ead60a3050eceb9ded2aad979afc815a5cbdb9f68494493c5d8d942cdd1111c21e32a5746d19505b87745cb84a
2025-08-05 14:19:11 +01:00
marcofleon 49b3d3a92a Clean up `FindTxForGetData`
Adds back a comment that was unintentionally deleted in
the GenTxid refactor.
2025-08-05 13:57:53 +01:00
merge-script 9617a42fdb
Merge bitcoin/bitcoin#32581: allocators: Apply manual ASan poisoning to `PoolResource`
ad132761fc [allocators] Apply manual ASan poisoning to PoolResource (dergoegge)

Pull request description:

  Currently ASan will not detect use-after-free issues for memory allocated by a `PoolResource`. This is because ASan is only aware of the memory chunks allocated by `PoolResource` but not the individual "sub-chunks" within.

  E.g. this test will not produce an ASan error even though the referenced coin has been deallocated:

  ```c++
  diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp
  index c46144b34b..aa6ca15ce1 100644
  --- a/src/test/coins_tests.cpp
  +++ b/src/test/coins_tests.cpp
  @@ -508,6 +508,17 @@ BOOST_FIXTURE_TEST_CASE(updatecoins_simulation_test, UpdateTest)
       BOOST_CHECK(spent_a_duplicate_coinbase);
   }

  +BOOST_AUTO_TEST_CASE(asan_uaf)
  +{
  +    CCoinsMapMemoryResource cache_coins_memory_resource{};
  +    CCoinsMap map(0, SaltedOutpointHasher(/*deterministic=*/true), CCoinsMap::key_equal{}, &cache_coins_memory_resource);
  +    COutPoint outpoint{};
  +    map.emplace(outpoint, Coin{});
  +    auto& coin = map.at(outpoint);
  +    map.erase(outpoint);
  +    coin.coin.nHeight = 1;
  +}
  +
   BOOST_AUTO_TEST_CASE(ccoins_serialization)
   {
       // Good example
  ```

  Fix this by applying [manual ASan poisoning](https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning) for memory allocated by `PoolResource`:

  * Newly allocated chunks are poisoned as a whole
  * "Sub-chunks" are unpoisoned/re-poisoned during allocation/deallocation

  With the poisoning applied, ASan catches the issue in the test above:
  ```
  $ ./build_unit/bin/test_bitcoin --run_test="coins_tests/asan_uaf"
  Running 1 test case...
  =================================================================
  ==366064==ERROR: AddressSanitizer: use-after-poison on address 0x7f99c3204870 at pc 0x55569dab6f8a bp 0x7ffe0210e4d0 sp 0x7ffe0210e4c8
  READ of size 4 at 0x7f99c3204870 thread T0 (b-test)
  ```

ACKs for top commit:
  achow101:
    ACK ad132761fc
  marcofleon:
    code review ACK ad132761fc

Tree-SHA512: eb5e80bfa9509225e784151807bd8aa21fb0826ca1781dfe81b1d60bd3766019384ea3f9cb8e53398fde2f4e994a9c201b5a9962b4d279d7e52bb60e8961be11
2025-08-05 10:47:01 +01:00
merge-script 33e7fc51f4
Merge bitcoin/bitcoin#33133: rpc: fix getpeerinfo ping duration unit docs
1252eeb997 rpc: fix getpeerinfo ping duration unit docs (0xb10c)

Pull request description:

  The docs have been incorrect since a3789c700b (released in v25; master since Sept. 2022). Noticed while setting up monitoring using getpeerinfo.

  0cb1ed2b7c/src/rpc/net.cpp (L249-L257)

ACKs for top commit:
  luke-jr:
    utACK 1252eeb997
  maflcko:
    lgtm ACK 1252eeb997
  jonatack:
    ACK 1252eeb997
  theStack:
    ACK 1252eeb997
  janb84:
    ACK 1252eeb997

Tree-SHA512: 33f576336b2a4d9533f51f4641d564ee59ef692c5fa9a3cad239fc31465883d5da534bfd0e069be1e1d688e5f0dea3fe6850be19bf35335041b8f414d08f7f09
2025-08-05 09:40:37 +01:00
l0rinc 721a051320 test: add coverage for -netinfo header and local services
Co-authored-by: Jon Atack <jon@atack.com>
2025-08-04 15:33:25 -06:00
Jon Atack f7d2db28e9 netinfo: return shortened services, if peers list requested
When the detailed peers list is requested, return the shortened services in the
-netinfo header in the same format as the "serv" column, instead of the full names
list in the report.
2025-08-04 15:33:25 -06:00
Jon Atack 4489ab526a netinfo: return local services in the default report
Credit to l0rinc for refactoring ServicesList().

Co-authored-by: l0rinc <pap.lorinc@gmail.com>
Co-authored-by: Daniela Brozzoni <danielabrozzoni@protonmail.com>
2025-08-04 15:33:25 -06:00
0xb10c 1252eeb997
rpc: fix getpeerinfo ping duration unit docs
The getpeerinfo docs incorrectly specified the ping durations as
milliseconds. This was incorrectly changed in a3789c700b
(released in v25; master since Sept. 2022). The correct duration unit
is seconds.

Also, remove the documentation of the getpeerinfo RPC response from the
ping RPC since it's incomplete. Better to just reference the getpeerinfo
RPC and it's documenation for this.
2025-08-04 22:24:13 +02:00
Antoine Poinsot eb073209db qa: test witness stripping in p2p_segwit
A stripped witness is detected as a special case in mempool acceptance to make sure we do not add
the wtxid (which is =txid since witness is stripped) to the reject filter. This is because it may
interfere with 1p1c parent relay which currently uses orphan reconciliation (and originally it was
until wtxid-relay was widely adopted on the network.

This commit adds a test for this special case in the p2p_segwit function test, both when spending
a native segwit output and when spending a p2sh-wrapped segwit output.

Thanks to Eugene Siegel for pointing out the p2sh-wrapped detection did not have test coverage by
finding a bug in a related patch of mine.
2025-08-04 14:13:04 -04:00
kevkevinpal 6a7c0d3f87
test: refactor to remove duplicated test code 2025-08-04 14:08:12 -04:00
merge-script d1b583181d
Merge bitcoin/bitcoin#32654: init: make `-blockmaxweight` startup option debug only
e017ef3c7e init: make `-blockmaxweight` startup option debug-only (ismaelsadeeq)

Pull request description:

  This PR updates `-blockmaxweight` startup option to be debug-only so that it will be hidden from help text.

  The option is currently unlikely to be used on mainnet, after the addition of the new `blockreservedweight` option. however it can be useful for test and signet network see https://github.com/bitcoin/bitcoin/pull/32654#issuecomment-2925674473

ACKs for top commit:
  Sjors:
    tACK e017ef3c7e
  fjahr:
    ACK e017ef3c7e
  polespinasa:
    tACK e017ef3c7e

Tree-SHA512: 6c18781826b2f96b13b70b7f1624481f5971746a613079d0d9528366f274ba657a02611f134d7a64f35ecb7e5faf2e3cd025458b04574ac68f804372f6eb715f
2025-08-04 14:04:21 -04:00
merge-script 50a92cd56f
Merge bitcoin/bitcoin#33060: test: Slay BnB Mutants
a3cf623364 test: Test max_selection_weight edge cases (Murch)
57fe8acc8a test: Check max_weight_exceeded error (Murch)

Pull request description:

  I tested all of the reported surviving mutants that @brunoerg reported in https://gist.github.com/brunoerg/834063398d5002f738506d741513e310.

  I found that all Mutants except for 12, 14, 17, 37, and 39 were now being caught by one of the existing tests. This fixes Mutants 14, 37, and 39.

  Mutant 17 is not fixed, because I consider it acceptable that running BnB for 100,001 instead of 100,000 comparisons doesn’t cause an issue, and Mutant 12 is not yet fixed, because at `fee` = `long_term_fee`, the waste of inputs is 0 and only excess matters, and I haven’t evaluated yet, whether it needs to be fixed.

ACKs for top commit:
  achow101:
    ACK a3cf623364
  jlest01:
    ACK a3cf623364
  brunoerg:
    code review ACK a3cf623364

Tree-SHA512: db67c52127ed98f809f64a903c6b3a012e56cf665a0cd851457af7c85c37ec3af8bb72035d7ad370dd883f99cf3014464e3576559899e37c1d6ee01230511754
2025-08-04 13:56:29 -04:00
Ryan Ofsky e886c65b6b Squashed 'src/ipc/libmultiprocess/' changes from 27c7e8e5a581..b4120d34bad2
b4120d34bad2 Merge bitcoin-core/libmultiprocess#192: doc: fix typos
6ecbdcd35a93 doc: fix typos
a11e6905c238 Merge bitcoin-core/libmultiprocess#186: Fix mptest failures in bitcoin CI
6f340a583f2b doc: fix DrahtBot LLM Linter error
c6f7fdf17350 type-context: revert client disconnect workaround
e09143d2ea2f proxy-types: fix UndefinedBehaviorSanitizer: null-pointer-use
84b292fcc4db mptest: fix MemorySanitizer: use-of-uninitialized-value
fe4a188803c6 proxy-io: fix race conditions in disconnect callback code
d8011c83608e proxy-io: fix race conditions in ProxyClientBase cleanup handler
97e82ce19c47 doc: Add note about Waiter::m_mutex and interaction with the EventLoop::m_mutex
81d58f5580e8 refactor: Rename ProxyClient cleanup_it variable
07230f259f55 refactor: rename ProxyClient<Thread>::m_cleanup_it
c0efaa5e8cb1 Merge chaincodelabs/libmultiprocess#187: ci: have bash scripts explicitly opt out of locale dependence.
0d986ff144cd mptest: fix race condition in TestSetup constructor
d2f6aa2e84ef ci: add thread sanitizer job
3a6db38e561f ci: rename configs to .bash
401e0ce1d9c3 ci: add copyright to bash scripts
e956467ae464 ci: export LC_ALL
8954cc0377d8 Merge chaincodelabs/libmultiprocess#184: Add CI jobs and fix clang-tidy and iwyu errors
757e13a75546 ci: add gnu32 cross-compiled 32-bit build
15bf349000eb doc: fix typo found by DrahtBot
1a598d5905f7 clang-tidy: drop 'bitcoin-*' check
cbb1e43fdc6e ci: test libc++ instead of libstdc++ in one job
76313450c2c4 type-context: disable clang-tidy UndefinedBinaryOperatorResult error
4896e7fe51ba proxy-types: fix clang-tidy EnumCastOutOfRange error
060a73926956 proxy-types: fix clang-tidy StackAddressEscape error
977d721020f6 ci: add github actions jobs testing gcc, clang-20, clang-tidy, and iwyu
0d5f1faae5da iwyu: fix add/remove include errors
753d2b10cc27 util: fix clang-tidy modernize-use-equals-default error
ae4f1dc2bb1a type-number: fix clang-tidy modernize-use-nullptr error
07a741bf6946 proxy-types: fix clang-tidy bugprone-use-after-move error
3673114bc9d9 proxy-types: fix clang-tidy bugprone-use-after-move error
422923f38485 proxy-types: fix clang-tidy bugprone-use-after-move error
c6784c6adefa mpgen: disable clang-tidy misc-no-recursion error
c5498aa11ba6 tidy: copy clang-tidy file from bitcoin core
258a617c1eec Merge chaincodelabs/libmultiprocess#160: refactor: EventLoop locking cleanups + client disconnect exception
84cf56a0b5f4 test: Test disconnects during IPC calls
949573da8411 Prevent IPC server crash if disconnected during IPC call
019839758085 Merge chaincodelabs/libmultiprocess#179: scripted-diff: Remove copyright year (ranges)
ea38392960e1 Prevent EventLoop async cleanup thread early exit during shutdown
616d9a75d20a doc: Document ProxyClientBase destroy_connection option
56fff76f940b Improve IPC client disconnected exceptions
9b8ed3dc5f87 refactor: Add clang thread safety annotations to EventLoop
52256e730f51 refactor: Remove DestructorCatcher and AsyncCallable
f24894794adf refactor: Drop addClient/removeClient methods
2b830e558e61 refactor: Use EventLoopRef instead of addClient/removeClient
315ff537fb65 refactor: Add ProxyContext EventLoop* member
9aaeec3678d3 proxy-io.h: Add EventLoopRef RAII class handle addClient/removeClient refcounting
f58c8d8ba2f0 proxy-io.h: Add more detailed EventLoop comment
5108445e5d16 test: Add test coverage for client & server disconnections
59030c68cb5f Merge chaincodelabs/libmultiprocess#181: type-function.h: Fix CustomBuildField overload
688140b1dffc test: Add coverage for type-function.h
8b96229da58e type-function.h: Fix CustomBuildField overload
fa2ff9a66842 scripted-diff: Remove copyright year (ranges)

git-subtree-dir: src/ipc/libmultiprocess
git-subtree-split: b4120d34bad2de28141c5770f6e8df8e54898987
2025-08-04 13:38:26 -04:00
Ryan Ofsky 2581258ec2 ipc: Handle bitcoin-wallet disconnections
This fixes an error reported by Antoine Poinsot <darosior@protonmail.com> in
https://github.com/bitcoin-core/libmultiprocess/issues/123 that does not happen
in master, but does happen with https://github.com/bitcoin/bitcoin/pull/10102
applied, where if the child bitcoin-wallet process is killed (either by an
external signal or by Ctrl-C as reported in the issue) the bitcoin-node process
will not shutdown cleanly after that because chain client stop()
calls will fail.

This change fixes the problem by handling ipc::Exception errors thrown during
the stop() calls, and it relies on the fixes to disconnect detection
implemented in https://github.com/bitcoin-core/libmultiprocess/pull/160 to work
effectively.
2025-08-04 13:38:26 -04:00
Ryan Ofsky 2160995916 ipc: Add Ctrl-C handler for spawned subprocesses
This fixes an error reported by Antoine Poinsot <darosior@protonmail.com> in
https://github.com/bitcoin-core/libmultiprocess/issues/123 that does not happen
in master, but does happen with https://github.com/bitcoin/bitcoin/pull/10102
applied, where if Ctrl-C is pressed when `bitcoin-node` is started, it is
handled by both `bitcoin-node` and `bitcoin-wallet` processes, causing the
wallet to shutdown abruptly instead of waiting for the node and shutting down
cleanly.

This change fixes the problem by having the wallet process print to stdout when
it receives a Ctrl-C signal but not otherwise react, letting the node shut
everything down cleanly.
2025-08-04 13:38:26 -04:00
Ryan Ofsky 0c28068ceb doc: Improve IPC interface comments
Fix some comments that were referring to previous versions of these methods and
did not make sense.
2025-08-04 13:38:26 -04:00
Ryan Ofsky 7f65aac78b ipc: Avoid waiting for clients to disconnect when shutting down
This fixes behavior reported by Antoine Poinsot <darosior@protonmail.com>
https://github.com/bitcoin/bitcoin/pull/29409#issuecomment-2546088852 where if
an IPC client is connected, the node will wait forever for it to disconnect
before exiting.
2025-08-04 13:38:26 -04:00
Ryan Ofsky 6eb09fd614 test: Add unit test coverage for Init and Shutdown code
Currently this code is not called in unit tests. Calling should make it
possible to write tests for things like IPC exceptions being thrown during
shutdown.
2025-08-04 13:38:26 -04:00
Ryan Ofsky 9a9fb19536 ipc: Use EventLoopRef instead of addClient/removeClient
Use EventLoopRef to avoid reference counting bugs and be more exception safe
and deal with removal of addClient/removeClient methods in
https://github.com/bitcoin-core/libmultiprocess/pull/160

A test update is also required due to
https://github.com/bitcoin-core/libmultiprocess/pull/160 to deal with changed
reference count semantics. In IpcPipeTest(), it is now necessary to destroy
the client Proxy object instead of just the client Connection object to
decrease the event loop reference count and allow the loop to exit so the test
does not hang on shutdown.
2025-08-04 12:38:26 -05:00
Ryan Ofsky 5c45bc989b Merge commit 'e886c65b6b37aaaf5d22ca68bc14e55d8ec78212' into pr/ipc-stop-base 2025-08-04 13:38:26 -04:00
merge-script 643bacd124
Merge bitcoin/bitcoin#33058: test: add assertions to SRD max weight test
cc33e45789 test: improve assertion for SRD max weight test (yancy)

Pull request description:

  Replace generic assertion with a result specific assertion showing the correctness of the solution found.  If the max weight parameter is exceeded, the least valuable `UTXOs` are removed from the result. Therefore, only the most valued _encountered_ `UTXO's` are selected. While the smallest set would include all the most valued `UTXO's`, in the case of the test there is one high value `UTXO` that is never found before the target value is reached.

  Correct the test comment to be more specific about why the assertion is a good result.

ACKs for top commit:
  murchandamus:
    ACK cc33e45789
  furszy:
    ACK cc33e45789

Tree-SHA512: bad224063ba830c27fba1b7b80e411ac7cd6c3edcb60bade4e6e3010f3b5d360a921de742c7c20efea8fa839d7939f338270658f66bbcebedebe5c5c8a3e8f9b
2025-08-04 12:07:18 -04:00
merge-script eeb0b31e3a
Merge bitcoin/bitcoin#32941: p2p: TxOrphanage revamp cleanups
c0642e558a [fuzz] fix latency score check in txorphan_protected (glozow)
3d4d4f0d92 scripted-diff: rename "ann" variables to "latency_score" (monlovesmango)
3b92448923 [doc] comment fixups for orphanage changes (glozow)
1384dbaf6d [config] emit warning for -maxorphantx, but allow it to be set (glozow)
b10c55b298 fix up TxOrphanage lower_bound sanity checks (glozow)
cfd71c6704 scripted-diff: rename TxOrphanage outpoints index (glozow)
edb97bb3f1 [logging] add logs for inner loop of LimitOrphans (glozow)
8a58d0e87d scripted-diff: rename OrphanTxBase to OrphanInfo (glozow)
cc50f2f0df [cleanup] replace TxOrphanage::Size() with CountUniqueOrphans (glozow)
ed24e01696 [optimization] Maintain at most 1 reconsiderable announcement per wtxid (Pieter Wuille)
af7402ccfa [refactor] make TxOrphanage keep itself trimmed (glozow)
d1fac25ff3 [doc] 31829 release note (glozow)

Pull request description:

  Followup to #31829:
  - Release notes
  - Have the orphanage auto-trim itself whenever necessary (and test changes) https://github.com/bitcoin/bitcoin/pull/31829#discussion_r2169508690
  - Reduce duplicate reconsiderations by keeping track of which txns are already reconsiderable so we only mark it for reconsideration for 1 peer at a time https://github.com/bitcoin/bitcoin/pull/31829#issuecomment-3001627814
  - Rename `OrphanTxBase` to `OrphanInfo`
  - Get rid of `Size()` method by replacing all calls with `CountUniqueOrphans`
  - Rename outpoints index since they point to wtxids, not iterators https://github.com/bitcoin/bitcoin/pull/31829#discussion_r2205557613
  - Add more logging in the `LimitOrphans` inner loop to make it easy to see which peers are being trimmed https://github.com/bitcoin/bitcoin/pull/31829#issuecomment-3074385460

ACKs for top commit:
  sipa:
    utACK c0642e558a
  marcofleon:
    Nice, ACK c0642e558a

Tree-SHA512: f298eae92cf906ed5e4f15a24eeffa7b9e620bcff457772cd77522dd9f0b3b183ffc976871b1b0e6fe93009e64877d518e53d4b9e186e0df58fc16d17f6de90a
2025-08-04 16:47:54 +01:00
glozow c0642e558a [fuzz] fix latency score check in txorphan_protected 2025-08-04 10:47:48 -04:00
merge-script 0cb1ed2b7c
Merge bitcoin/bitcoin#33132: fuzz: txgraph: fix `real_is_optimal` flag propagation in `CommitStaging`
444dcb2f99 fuzz: txgraph: fix `real_is_optimal` flag propagation in `CommitStaging` (Sebastian Falbesoner)

Pull request description:

  In the `txgraph` fuzz test, the `CommitStaging` step updates the `SimTxGraph` levels simply by erasing the front (=main) one in the `sims` vector, i.e. the staging level instance takes the place of the main level instance:

  83a2216f52/src/test/fuzz/txgraph.cpp (L668-L672)

  This also includes the `real_is_optimal` flag (reflecting whether the corresponding real graph is known to be optimally linearized), without taking into account that this flag should only be set if _both_ levels before the commiting are optimal.

  E.g. in case of #33097, at this point the main level is not optimally linearized, while the staging level is, and due to the incorrect propagation of the latter the simulation incorrectly assumes that the main level is optimal after, leading to the assertion fail in the additional checks that are ran in this case[1]. Fix this by setting the flag in the resulting main level explicitly. This is done in a generic way, in case there will ever be more than two levels (not sure what is planned in this direction), a simpler alternative would be e.g. `main_optimal = sim[0].real_is_optimal && sim[1].real_is_optimal`.

  Fixes #33097.

  [1] see 0aedf09ccc for the printf-debug-session-clutter, if that is useful/interesting for anyone (most of the output turned out to be irrelevant to the actual cause of #33097, but it was an entertaining way to discover the interface and get a first glimpse of `TxGraph` internals as a cluster-mempool newbie).

ACKs for top commit:
  sipa:
    ACK 444dcb2f99
  glozow:
    ACK 444dcb2f99

Tree-SHA512: c20580e14628fcdc34dabb646a097e02e95b26c5740fcd5ce50f3472e4ee08f20b9a146c9ff16c85e19e57b05af1560e41a9220289c60c15083ad897dc62a0f0
2025-08-04 10:06:18 -04:00
Hennadii Stepanov a26fbee38f
qt: Translations update
The translations for the following languages, which appear to be the
result of a mistake or an act of vandalism, have been discarded:
- Greek (el)
- Vietnamese (vi)
2025-08-04 12:40:21 +01:00
Sebastian Falbesoner 444dcb2f99 fuzz: txgraph: fix `real_is_optimal` flag propagation in `CommitStaging`
In the `txgraph` fuzz test, the `CommitStaging` step updates the
`SimTxGraph` levels simply by erasing the front (=main) one in the
`sims` vector, i.e. the staging level instance takes the place of the
main level instance. This also includes the `real_is_optimal` flag
(reflecting whether the corresponding real graph is known to be
optimally linearized), without taking into account that this flag
should only be set if _both_ levels before the commiting are optimal.

E.g. in case of #33097, the main level is not optimally linearized,
while the staging level is, and due to the incorrect propagation of the
latter to the simulation incorrectly assumes that the main level is
optimal, leading to the assertion fail. Fix this by setting the flag
in the resulting main level explicitly.

Resolves the fuzzing assertion fail in issue #33097.
2025-08-04 02:17:14 +02:00
merge-script 83a2216f52
Merge bitcoin/bitcoin#33118: test: fix anti-fee-sniping off-by-one error
e07e2532b4 test: fix anti-fee-sniping off-by-one error (ishaanam)

Pull request description:

  This fixes the off-by-one error in the anti-fee-sniping tests for `send` and `sendall`. `assert_greater_than` fails if the two values are equal.

  Closes #33114

ACKs for top commit:
  achow101:
    ACK e07e2532b4
  glozow:
    utACK e07e2532b4

Tree-SHA512: 6c9c3d1256faf563361946703d9a51279777d73bc1a849873e03e5b5db52c3c2b9dea4bfe27b1f01b9c830ca246200a895b6a28484da6d822b93b0c7cba237c1
2025-08-03 11:53:28 +01:00
Chris Stewart 3543bfdfec test: Fix 'getdescriptoractivity' RPCHelpMan, add test to verify 'spend_vin' is the correct field 2025-08-02 10:26:32 -05:00
ishaanam e07e2532b4 test: fix anti-fee-sniping off-by-one error 2025-08-01 15:50:12 -04:00
MarcoFalke c7a24c3052
ci: Re-enable DEBUG=1 in centos task
This reverts the workaround in commit fa079538e3, as it is no longer needed.
2025-08-01 17:14:03 +01:00
furszy 3aef38f44b test: exercise index reorg assertion failure 2025-08-02 00:10:24 +08:00
Hao Xu acf50233cd index: fix wrong assert of current_tip == m_best_block_index
In BaseIndex::Sync(), pindex in `Rewind(pindex, pindex_next->pprev)` isn't always
equal to m_best_block_index since m_best_block_index is updated every
SYNC_LOCATOR_WRITE_INTERVAL seconds, during which multiple pindex update could
happen. Thus the assert here is wrong.

Signed-off-by: Hao Xu <hao.xu@linux.dev>
2025-08-02 00:10:24 +08:00
monlovesmango 3d4d4f0d92 scripted-diff: rename "ann" variables to "latency_score"
-BEGIN VERIFY SCRIPT-
sed -i 's/max_global_ann/max_global_latency_score/g' src/node/txorphanage.cpp
sed -i 's/max_global_ann/max_global_latency_score/g' src/node/txorphanage.h
sed -i 's/max_global_ann/max_global_latency_score/g' src/test/orphanage_tests.cpp
sed -i 's/max_global_ann/max_global_latency_score/g' src/test/fuzz/txorphan.cpp
sed -i 's/max_global_ann/max_global_latency_score/g' src/bench/txorphanage.cpp
sed -i 's/max_ann/max_lat/g' src/node/txorphanage.cpp
-END VERIFY SCRIPT-
2025-08-01 11:52:32 -04:00
glozow 3b92448923 [doc] comment fixups for orphanage changes 2025-08-01 11:52:32 -04:00
glozow 1384dbaf6d [config] emit warning for -maxorphantx, but allow it to be set 2025-08-01 11:52:32 -04:00
glozow b10c55b298 fix up TxOrphanage lower_bound sanity checks
Co-authored-by: Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
2025-08-01 11:52:32 -04:00
glozow cfd71c6704 scripted-diff: rename TxOrphanage outpoints index
-BEGIN VERIFY SCRIPT-
sed -i 's/m_outpoint_to_orphan_it/m_outpoint_to_orphan_wtxids/g' src/node/txorphanage.cpp
-END VERIFY SCRIPT-
2025-08-01 11:52:32 -04:00
glozow edb97bb3f1 [logging] add logs for inner loop of LimitOrphans 2025-08-01 11:52:32 -04:00
glozow 8a58d0e87d scripted-diff: rename OrphanTxBase to OrphanInfo
-BEGIN VERIFY SCRIPT-
sed -i 's/OrphanTxBase/OrphanInfo/g' $(git grep -l 'OrphanTxBase')
-END VERIFY SCRIPT-
2025-08-01 11:52:32 -04:00
glozow cc50f2f0df [cleanup] replace TxOrphanage::Size() with CountUniqueOrphans 2025-08-01 11:52:32 -04:00
Pieter Wuille ed24e01696 [optimization] Maintain at most 1 reconsiderable announcement per wtxid
This introduces an invariant that TxOrphanageImpl never holds more than one
announcement with m_reconsider=true for a given wtxid. This avoids duplicate
work, both in the caller might otherwise reconsider the same transaction multiple
times before it is ready, and internally in AddChildrenToWorkSet, which might
otherwise iterate over all announcements multiple times.
2025-08-01 11:52:32 -04:00
glozow af7402ccfa [refactor] make TxOrphanage keep itself trimmed 2025-08-01 11:50:13 -04:00
glozow d1fac25ff3 [doc] 31829 release note 2025-08-01 11:50:13 -04:00
merge-script 75ed673193
Merge bitcoin/bitcoin#33048: test: reduce runtime of p2p_opportunistic_1p1c.py
eb65f57f31 [test] setmocktime instead of waiting in 1p1c tests (glozow)
70772dd469 [test] cut the number of transactions involved in 1p1c DoS tests (glozow)

Pull request description:

  It was brought to my attention that the runtime of this test is Too Damn High. The test is slow due to the many `wait_for_getdata`s with delays (inbound peer + txid request) and the large volume of messages sent in the dos-related tests. This PR cuts the runtime by about 60% by reducing the number of messages/transactions and using `setmocktime` instead of waiting.

  On my machine, master:
  ```
  84.51s user 1.55s system 57% cpu 2:28.53 total
  ```
  After first commit (about 1min faster):
  ```
  28.29s user 0.88s system 35% cpu 1:22.84 total
  ```
  After second commit (about 30sec faster):
  ```
  28.17s user 0.87s system 59% cpu 49.082 total
  ```

  Reviewers should verify that the transactions in the DoS tests are still enough to cause evictions, and that the `bumpmocktime` amounts are not more than necessary.

  Alternatives:
  - If we don't like mocking the times, we can use outbound connections for all the peers. However, that approach won't improve the runtime as much because we impose a 2-second delay on all txid requests regardless of peer type.
  - Note that `noban_tx_relay` is not relevant for this test because all delays are related to downloading, not announcing.

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

Tree-SHA512: 6ffe1f9e5144653e2ded744cec9ddb62ad728c587705542565400a0e8f1fba4843aced4e0d929843874ca7f56f670f5871b7e009ff6be58b791ab24d2e6fcc0e
2025-08-01 16:06:40 +01:00
Hennadii Stepanov ca04eebd72
cmake: Switch to generated `ts_files.cmake` file
See the `update-translations.py` script in the
`bitcoin-maintainer-tools` repository.
2025-08-01 15:52:16 +01:00
Hennadii Stepanov 95341de6ca
cmake, refactor: Move handling of Qt TS files into `locale` directory
This change offers a few advantages, such as:
- a more readable and cleaner `ts_files.cmake` (see the next commit);
- a scoped `ts_files` variable;
- improved code locality;
- no need to adjust the location of the resulting `*.qm` files.
2025-08-01 15:52:08 +01:00
merge-script 24246c3deb
Merge bitcoin/bitcoin#31385: package validation: relax the package-not-child-with-unconfirmed-parents rule
ea17a9423f [doc] release note for relaxing requirement of all unconfirmed parents present (glozow)
12f48d5ed3 test: add chained 1p1c propagation test (Greg Sanders)
525be56741 [unit test] package submission 2p1c with 1 parent missing (glozow)
f24771af05 relax child-with-unconfirmed-parents rule (glozow)

Pull request description:

  Broadens the package validation interface, see #27463 for wider context.

  On master, package rules include that (1) the package topology must be child-wth-parents (2) all of the child's unconfirmed parents must be present. This PR relaxes the second rule, leaving the first rule untouched (there are plans to change that as well, but not here).

  Original motivation for this rule was based on the idea that we would have a child-with-unconfirmed-parents package relay protocol, and this would verify that the peer provided the "correct" package. For various reasons, we're not planning on doing this. We could potentially do this for ancestor packages (with a similar definition that all UTXOs to make the tx valid are available in this package), but it's also questionable whether it's useful to enforce this.

  This rule gets in the way of certain usage of 1p1c package relay currently. If a transaction has multiple parents, of which only 1 requires a package CPFP, this rule blocks the package from relaying. Even if all the non-low-feerate parents are already in mempool, when the p2p logic submits the 1p1c package, it gets rejected for not meeting this rule.

ACKs for top commit:
  ishaanam:
    re-utACK ea17a9423f
  instagibbs:
    ACK ea17a9423f

Tree-SHA512: c2231761ae7b2acea10a96735e7a36c646f517964d0acb59bacbae1c5a1950e0223458b84c6d5ce008f0c1d53c1605df0fb3cd0064ee535ead006eb7c0fa625b
2025-08-01 15:45:20 +01:00
merge-script b8025b30cc
Merge bitcoin/bitcoin#32559: doc: add alpine build instructions
4f502baf8f doc: add alpine depends build instructions (will)
5332082d00 doc: add alpine build instructions (will)

Pull request description:

  Closes: #32512

  - Provide Alpine build instructions in build-unix.md.
  - Instructions cover building all components except USDT which is marked as unsupported for Alpine.

ACKs for top commit:
  hebasto:
    ACK 4f502baf8f.

Tree-SHA512: 821565714aa556d16c0c721748420333fb5574aa13858186a799a5ccbda981c5b77da2d74a23de01c505591ed3b872eb5552051922ba101fedd50dfddc926b06
2025-08-01 14:42:44 +01:00
Florian Schmaus 18d1071dd1
init: replace deprecated PermissionsStartOnly systemd directive
PermissionsStartOnly is deprecated [1]. This removes the directives
and instead we prefixes the value of the ExecStartPre directive with
'!', which means the executable, 'chgrp' in this case, is run with
full privileges and able to change the group of /etc/bitcoin.

1: 60b45a80c1/NEWS (L2434)
2025-08-01 14:41:07 +01:00
Florian Schmaus 1caaf65043
init: remove Group= as it will default to the user's default group
Setting Group=bitcoin is redundant. It is typically the default group
of the user and if not explicitly specified, systemd will run the
service with the default group of the user.
2025-08-01 14:40:52 +01:00
stickies-v 1d9f1cb4bd
kernel: improve BlockChecked ownership semantics
Subscribers to the BlockChecked validation interface event may need
access to the block outside of the callback scope. Currently, this
is only possible by copying the block, which makes exposing this
validation interface event publicly either cumbersome or with significant
copy overhead.

By using shared_ptr, we make the shared ownership explicit and allow
users to safely use the block outside of the callback scope.
2025-08-01 15:12:37 +02:00
Hennadii Stepanov a7bafb3e05
refactor: Use immediate lambda to work around GCC bug 117966 2025-08-01 12:07:26 +01:00
Hennadii Stepanov b093a19ae2
cmake: Proactively avoid use of `SECP256K1_DISABLE_SHARED`
The `SECP256K1_DISABLE_SHARED` CMake variable has been removed upstream.

This change removes its usage ahead of the next `secp256k1` subtree
update to prevent breakage and simplify integration.
2025-08-01 10:32:50 +01:00
Hennadii Stepanov eb59a192d9
cmake, refactor: Encapsulate adding secp256k1 subtree in function 2025-08-01 10:32:44 +01:00
merge-script 4f27e8ca4d
Merge bitcoin/bitcoin#33083: qa: test that we do not disconnect a peer for submitting an invalid compact block
c157438116 qa: test that we do disconnect upon a second invalid compact block being announced (Antoine Poinsot)
fb2dcbb160 qa: test cached failure for compact block (Antoine Poinsot)
f12d8b104e qa: test a compact block with an invalid transaction (Antoine Poinsot)
d6c37b28a7 qa: remove unnecessary tx removal from compact block (Antoine Poinsot)

Pull request description:

  In thinking about https://github.com/bitcoin/bitcoin/pull/33050 and https://github.com/bitcoin/bitcoin/pull/33012#issuecomment-3111631541, i went through the code paths for peer disconnection upon submitting an invalid block. It turns out that the fact we exempt a peer from disconnection upon submitting an invalid compact block was not properly tested, as can be checked with these diffs:
  ```diff
  diff --git a/src/net_processing.cpp b/src/net_processing.cpp
  index 0c4a89c44c..d243fb88d4 100644
  --- a/src/net_processing.cpp
  +++ b/src/net_processing.cpp
  @@ -1805,10 +1805,10 @@ void PeerManagerImpl::MaybePunishNodeForBlock(NodeId nodeid, const BlockValidati
       // The node is providing invalid data:
       case BlockValidationResult::BLOCK_CONSENSUS:
       case BlockValidationResult::BLOCK_MUTATED:
  -        if (!via_compact_block) {
  +        //if (!via_compact_block) {
               if (peer) Misbehaving(*peer, message);
               return;
  -        }
  +        //}
           break;
       case BlockValidationResult::BLOCK_CACHED_INVALID:
           {
  ```

  ```diff
  diff --git a/src/net_processing.cpp b/src/net_processing.cpp
  index 0c4a89c44cb..e8e0c805367 100644
  --- a/src/net_processing.cpp
  +++ b/src/net_processing.cpp
  @@ -1814,10 +1814,10 @@ void PeerManagerImpl::MaybePunishNodeForBlock(NodeId nodeid, const BlockValidati
           {
               // Discourage outbound (but not inbound) peers if on an invalid chain.
               // Exempt HB compact block peers. Manual connections are always protected from discouragement.
  -            if (peer && !via_compact_block && !peer->m_is_inbound) {
  +            //if (peer && !via_compact_block && !peer->m_is_inbound) {
                   if (peer) Misbehaving(*peer, message);
                   return;
  -            }
  +            //}
               break;
           }
       case BlockValidationResult::BLOCK_INVALID_HEADER:
  ```

  We do have a test for this, but it actually uses a coinbase witness commitment error, which is checked much earlier in `FillBlock`. This PR adds coverage for the two exemptions in `MaybePunishNodeForBlock`.

ACKs for top commit:
  kevkevinpal:
    ACK [c157438](c157438116)
  nervana21:
    tACK [c157438](c157438116)
  instagibbs:
    crACK c157438116
  stratospher:
    ACK c157438116.

Tree-SHA512: a77d5a9768c0d73f122b06db2e416e80d0b3c3fd261dae8e340ecec2ae92d947d31988894bc732cb6dad2e338b3c82f33e75eb3280f8b0933b285657cf3b212c
2025-08-01 10:15:10 +01:00
merge-script bfc9d95129
Merge bitcoin/bitcoin#33104: test: Perform backup filename checks in migrate_and_get_rpc in wallet_migration.py
4b80147feb test: Perform backup filename checks in migrate_and_get_rpc (Ava Chow)

Pull request description:

  Some test cases were unnecessarily checking the backup filename, which involved setting the mocktime before `migrate_and_get_rpc`. However, this could cause a failure if the test was slow since `migrate_and_get_rpc` also sets the mocktime. Since it also already checks that the backup file is named correctly, there's no need for those tests to also do their own mocktime and filename check.

  The CI failure can be reproduced locally by adding a sleep to `migrate_and_get_rpc`:
  ```diff
  diff --git a/test/functional/wallet_migration.py b/test/functional/wallet_migration.py
  index 704204425c7..e87a6100623 100755
  --- a/test/functional/wallet_migration.py
  +++ b/test/functional/wallet_migration.py
  @@ -129,6 +129,7 @@ class WalletMigrationTest(BitcoinTestFramework):
                   assert_equal(w["warnings"], ["This wallet is a legacy wallet and will need to be migrated with migratewallet before it can be loaded"])

           # Mock time so that we can check the backup filename.
  +        time.sleep(1)
           mocked_time = int(time.time())
           self.master_node.setmocktime(mocked_time)
           # Migrate, checking that rescan does not occur
  ```

  Fixes #33096

ACKs for top commit:
  fjahr:
    reACK 4b80147feb
  Sammie05:
     tACK 4b80147
  pablomartin4btc:
    utACK 4b80147feb
  rkrux:
    ACK 4b80147feb

Tree-SHA512: 045d4acf2ad0b56a7083ff2ee5ef09f0d74ad097c01a290660daca096c71fc07109848024256d84f74abbc87dd52691d160f9968b3654726626d3dbd21a84ab6
2025-08-01 09:51:08 +01:00
pablomartin4btc 30c6f64eed test: Remove unnecessary LoadWallet() calls 2025-07-31 21:17:08 -03:00
Ava Chow 8712e074bb
Merge bitcoin/bitcoin#33093: refactor: remove unused `ser_writedata16be` and `ser_readdata16be`
0431a690c3 cleanup: remove unused `ser_writedata16be` and `ser_readdata16be` (Lőrinc)

Pull request description:

  Remove dead code from serialization logic - extracted from https://github.com/bitcoin/bitcoin/pull/31868

ACKs for top commit:
  maflcko:
    lgtm ACK 0431a690c3
  achow101:
    ACK 0431a690c3
  jlest01:
    ACK 0431a690c3

Tree-SHA512: 1881a164b2a91bb6033770db625f10b845bfb17a9898efb7612ca29ba113175b29e345beb84488f388b4639ade98df98e3411e663149bcbaec6e3abeffe1cbef
2025-07-31 16:13:22 -07:00
merge-script 5ee4e79669
Merge bitcoin/bitcoin#31244: descriptors: MuSig2
5fe7915c86 doc: Add musig() example (Ava Chow)
d576079ab4 tests: Test musig() parsing (Ava Chow)
a53924bee3 descriptor: Parse musig() key expressions (Ava Chow)
9473e9606c descriptors: Move DeriveType parsing into its own function (Ava Chow)
4af0dca096 descriptor: Add MuSigPubkeyProvider (Ava Chow)
d00d95437d Add MuSig2 Keyagg Cache helper functions (Ava Chow)
8ecea91bf2 sign: Add GetMuSig2ParticipantPubkeys to SigningProvider (Ava Chow)
fac0ee0bfc build: Enable secp256k1 musig module (Ava Chow)
1894f97503 descriptors: Add PubkeyProvider::IsBIP32() (Ava Chow)
12bc1d0b1e util/string: Allow Split to include the separator (Ava Chow)
8811312571 script/parsing: Allow Const to not skip the found constant (Ava Chow)
5fe4c66462 XOnlyPubKey: Add GetCPubKeys (Ava Chow)

Pull request description:

  Implements parsing of BIP 390 `musig()` descriptors.

  Split from #29675

ACKs for top commit:
  w0xlt:
    reACK 5fe7915c86
  rkrux:
    ACK 5fe7915c86
  theStack:
    re-ACK 5fe7915c86 🎹
  Sjors:
    ACK 5fe7915c86

Tree-SHA512: a5be6288e277187fb9a1e2adf4e9822b46b1b8380d732b2fabd53f317c839aecb1971b04410486cbd65047fbc20956675d4d676f56caa37a44ff0e4d12b9b081
2025-07-31 16:51:39 -04:00
Ava Chow 4b80147feb test: Perform backup filename checks in migrate_and_get_rpc
Some test cases were unnecessarily checking the backup filename, which
involved setting the mocktime before `migrate_and_get_rpc`. However,
this could cause a failure if the test was slow since
`migrate_and_get_rpc` also sets the mocktime. Since it also already
checks that the backup file is named correctly, there's no need for
those tests to also do their own mocktime and filename check.
2025-07-31 10:45:50 -07:00
Ava Chow 88b0647f02 wallet: Always write last hardened cache flag in migrated wallets 2025-07-31 10:29:32 -07:00
Ava Chow 8a08eef645 tests: Check that the last hardened cache upgrade occurs
When loading an older wallet without the last hardened cache, an
automatic upgrade should be performed. Check this in
wallet_backwards_compatibility.py

When migrating a wallet, the migrated wallet should always have the last
hardened cache, so verify in wallet_migration.py
2025-07-31 10:29:32 -07:00
merge-script aef2dbb402
Merge bitcoin/bitcoin#33099: ci: allow for any libc++ intrumentation & use it for TSAN
7aa5b67132 ci: remove DEBUG_LOCKORDER from TSAN job (fanquake)
b09af2ce50 ci: instrument libc++ in TSAN job (fanquake)
6653cafd0b ci: allow libc++ instrumentation other than msan (fanquake)

Pull request description:

  Allow for instrumenting libc++ with a sanitizer other than MemoryWithOrigins.

  Would also close #33087, as with the extra instrumentation, the issue from https://github.com/bitcoin/bitcoin/pull/32862#issuecomment-3114706601 is avoided (also see https://github.com/bitcoin/bitcoin/pull/33081), and we can drop `DEBUG_LOCKORDER`.

ACKs for top commit:
  maflcko:
    re-ACK 7aa5b67132 🦀
  dergoegge:
    utACK 7aa5b67132

Tree-SHA512: 95f123e37da5e81d571244e4b1cd7658107676f1ea763ff16e5b69f4dfadb88236a577bb2ee52230ff542872c1da151c88fc50aba0f32540e765080120cec55e
2025-07-31 15:08:16 +01:00
Ava Chow 8283af13fe
Merge bitcoin/bitcoin#32584: depends: hard-code necessary c(xx)flags rather than setting them per-host
9954d6c833 depends: hard-code necessary c(xx)flags rather than setting them per-host (Cory Fields)

Pull request description:

  The per-host flag variables hold platform-specific defaults that are ignored when flag environment variables are set, so it was wrong for them to contain -std options relied on by package definitions.

  Additionally, these flags (-pipe and -std=xx) will no longer be passed into the CMake build, meaning less duplication in the build summary.

  Pulled out of #31920.

ACKs for top commit:
  achow101:
    ACK 9954d6c833
  ryanofsky:
    Code review ACK 9954d6c833. No changes since last review other than improving the commit message. Change overall makes sense because it deduplicates host definitions, stops dropping `-std` flags from package builds when custom CFLAGS/CXXFLAGS environment variables are set, and stops passing duplicate flags to cmake that have no effect.
  theuni:
    ACK 9954d6c833

Tree-SHA512: 62a2a21b741893cf708ca71fb5f0626c30d52685c845f9016f428a5e38fc8515acd4bf2c83635d6505b63830d1c296472026ec3d341c8069f1e490a991b6b5ef
2025-07-30 13:56:14 -07:00
Ava Chow 547c64814d
Merge bitcoin/bitcoin#32987: init: [gui] Avoid UB/crash in InitAndLoadChainstate
fac90e5261 test: Check that the GUI interactive reindex works (MarcoFalke)
faaaddaaf8 init: [gui] Avoid UB/crash in InitAndLoadChainstate (MarcoFalke)

Pull request description:

  `InitAndLoadChainstate` is problematic, when called twice in the GUI. This can happen when it returns a failure and the user selects an interactive reindex.

  There are several bugs that have been introduced since the last time this was working correctly:

  * The first one is a crash (assertion failure), which happens due to a cached tip block in the notifiications from the previous run. See https://github.com/bitcoin/bitcoin/pull/31346#discussion_r2207914726
  * The second one is UB (use-after-free), which happens because the block index db in the blockmanager is not reset. See https://github.com/bitcoin/bitcoin/pull/30965#discussion_r2207822121

  Fix both bugs by resetting any dirty state in `InitAndLoadChainstate`.

  Also, add a test, because I don't really want to keep testing this manually every time. (A failing test run can be seen in https://github.com/bitcoin/bitcoin/pull/32979/checks)

ACKs for top commit:
  achow101:
    ACK fac90e5261
  TheCharlatan:
    ACK fac90e5261
  mzumsande:
    Tested ACK fac90e5261

Tree-SHA512: 9f744d36e7cdd3f5871764386ec5a5cca1ae144f1bacc26c07e60313c2bdacdc5fca351aa185cb51359540eea4534dda17e4fb6073ad90f91ba0a6936faeead8
2025-07-30 13:55:01 -07:00
Hennadii Stepanov e6bfd95d50
Merge bitcoin-core/gui#881: Move `FreespaceChecker` class into its own module
3a03f07560 qt: Avoid header circular dependency (Anthony Towns)
25884bd896 qt, refactor: Move `FreespaceChecker` class into its own module (Hennadii Stepanov)

Pull request description:

  For some reason, the MOC compiler in older versions of Qt 6 fails to parse `qt/intro.cpp`, as noted in [this comment](https://github.com/bitcoin/bitcoin/pull/32998#issuecomment-3082011233).

  This PR proposes a move-only refactoring to simplify the source structure by eliminating the need for the inline `#include <qt/intro.moc>`, thereby effectively working around the issue.

  Required for https://github.com/bitcoin/bitcoin/pull/32998.

ACKs for top commit:
  ajtowns:
    ACK 3a03f07560

Tree-SHA512: 4a7261f04fff9bd8edd4dc2df619c90e06417e19da672dd688a917cd0b9a324a6db7185a47c48f0385713b5e6c45d2204bef58cbe6c77299386136ed5682bd8d
2025-07-30 20:27:44 +01:00
merge-script 8a94cf8efe
Merge bitcoin/bitcoin#30635: rpc: add optional blockhash to waitfornewblock, unhide wait methods in help
c6e2c31c55 rpc: unhide waitfor{block,newblock,blockheight} (Sjors Provoost)
0786b7509a rpc: add optional blockhash to waitfornewblock (Sjors Provoost)

Pull request description:

  The `waitfornewblock` is inherently racy as the tip may have changed since the last RPC call, and can even change during initial processing of this call.

  Add an optional `blockhash` argument so the caller can specify their current tip. Return immediately if our tip is different.

  I've made it fail if `LookupBlockIndex` fails. This should never happen if the user got the block hash from our RPC in the first place.

  Finally, the `waitfor{block,newblock,blockheight}` RPC methods are no longer hidden in `help`:
  - the changes in #30409 ensured these methods _could_ work in the GUI
  - #31785 removed the guards that prevented GUI users from using them
  - this PR makes `waitfornewblock` reliable

  So there's no more reason to hide them.

ACKs for top commit:
  TheCharlatan:
    Re-ACK c6e2c31c55
  ryanofsky:
    Code review ACK c6e2c31c55. Just rebased and tweaked documentation since last review.
  glozow:
    utACK c6e2c31c55

Tree-SHA512: 84a0c94cb9a2e4449e7a395cf3dce1650626bd852e30e0e238a1aafae19d57bf440bfac226fd4da44eaa8d1b2fa4a8c1177b6c716235ab862a72ff5bf8fc67ac
2025-07-30 14:30:22 -04:00
merge-script dc78ed2140
Merge bitcoin/bitcoin#33005: refactor: GenTxid type safety followups
94b39ce738 refactor: Change `m_tx_inventory_to_send` from `std::set<GenTxid>` to `std::set<Wtxid>` (marcofleon)
a9819b0e9d refactor: Change `FindTxForGetData` to take GenTxid instead of CInv (marcofleon)
d588575ed1 refactor: miscellaneous GenTxid followups (marcofleon)

Pull request description:

  This is a followup to https://github.com/bitcoin/bitcoin/pull/32631.

  Addresses:
  https://github.com/bitcoin/bitcoin/pull/32631#discussion_r2200291621
  https://github.com/bitcoin/bitcoin/pull/32631#discussion_r2199951996
  https://github.com/bitcoin/bitcoin/pull/32631#discussion_r2201874252
  https://github.com/bitcoin/bitcoin/pull/32631#discussion_r2201918072
  https://github.com/bitcoin/bitcoin/pull/32631#issuecomment-3063383775

ACKs for top commit:
  glozow:
    ACK 94b39ce738
  maflcko:
    review ACK 94b39ce738 🎲
  stickies-v:
    ACK 94b39ce738

Tree-SHA512: 3c88656b2e4e676653db87df5b1b694e1b1f40d89d7b825dad068e57c9c9f8add098ba797413274bd992b1c1fdec94c794ab3fd086d2a9561f5de92ae9f6d942
2025-07-30 14:20:03 -04:00
merge-script 3cb65ffa83
Merge bitcoin/bitcoin#33100: ci: remove `ninja-build` from MSAN jobs
cab6736b70 ci: remove ninja-build from MSAN jobs (fanquake)

Pull request description:

  It is part of `CI_BASE_PACKAGES`.

ACKs for top commit:
  maflcko:
    review ACK cab6736b70 🕸
  hebasto:
    ACK cab6736b70, I have reviewed the code and it looks OK.

Tree-SHA512: 8da5f0b07310a1e003d405ade19408b390781121a317ecc0ebdf48cb63bb3abf39bcfb635e4a43200568e0debabb463c2a3a843705e625fa455609eb3f0ba416
2025-07-30 16:23:51 +01:00
fanquake 7aa5b67132
ci: remove DEBUG_LOCKORDER from TSAN job 2025-07-30 15:30:04 +01:00
fanquake b09af2ce50
ci: instrument libc++ in TSAN job
Qt is disabled, as the build is now taking a very long time.
2025-07-30 15:29:54 +01:00
fanquake 6653cafd0b
ci: allow libc++ instrumentation other than msan 2025-07-30 14:39:48 +01:00
MarcoFalke 3333d3f75f
ci: Only pass documented env vars 2025-07-30 15:38:03 +02:00
merge-script 3fe3fdb02b
Merge bitcoin/bitcoin#33102: fuzz: cover BanMan::IsDiscouraged
c2ed576d2c fuzz: cover BanMan::IsDiscouraged (brunoerg)

Pull request description:

  This PR adds fuzz coverage for the `IsDiscouraged` function in the banman target. This is the only function missing from `BanMan`.

ACKs for top commit:
  maflcko:
    lgtm ACK c2ed576d2c
  marcofleon:
    ACK c2ed576d2c

Tree-SHA512: 1dc5fc138f89413c46ed41195940f4c578ef996ce84595271b7433cae8a8f576205b649b493a7ec4804c712327d6c77b1004ba116b0144916377042adaaf6c5f
2025-07-30 14:29:26 +01:00
brunoerg c2ed576d2c fuzz: cover BanMan::IsDiscouraged 2025-07-30 09:24:11 -03:00
Anthony Towns 3a03f07560
qt: Avoid header circular dependency 2025-07-30 12:56:41 +01:00
fanquake cab6736b70
ci: remove ninja-build from MSAN jobs
It is part of CI_BASE_PACKAGES.
2025-07-30 11:17:20 +01:00
Lőrinc 0431a690c3 cleanup: remove unused `ser_writedata16be` and `ser_readdata16be` 2025-07-29 16:25:47 -07:00
Ava Chow 00604296e1
Merge bitcoin/bitcoin#32866: doc: add note for watch-only wallet migration
5888b4a2a5 doc: add note for watch-only wallet migration (rkrux)

Pull request description:

  This was suggested in a previous PR #31423.

ACKs for top commit:
  achow101:
    ACK 5888b4a2a5
  brunoerg:
    reACK 5888b4a2a5
  jonatack:
    ACK 5888b4a2a5

Tree-SHA512: 96e51eda30a1f31cfd82ae3296ca97c9236599b18e19086dbde3a908f6fe66af8f2de7aa147bdb9ebccb2059c809a25ddfb0c23da57e1a84a35b62ca0a44e3c3
2025-07-29 11:40:23 -07:00
Ava Chow 91058877ff
Merge bitcoin/bitcoin#32273: wallet: Fix relative path backup during migration.
76fe0e59ec test: Migration of a wallet ending in `../` (David Gumberg)
f0bb3d50fe test: Migration of a wallet ending in `/` (David Gumberg)
41faef5f80 test: Migration fail recovery w/ `../` in path (David Gumberg)
63c6d36437 test: Migration of a wallet with `../` in path. (David Gumberg)
70f1c99c90 wallet: Fix migration of wallets with pathnames. (David Gumberg)
f6ee59b6e2 wallet: migration: Make backup in walletdir (David Gumberg)
e22c3599c6 test: wallet: Check direct file backup name. (David Gumberg)

Pull request description:

  Support for wallets outside of the default wallet directory was added in #11687, and these external wallets can be specified with paths relative to the wallet directory, e.g.  `bitcoin-cli loadwallet ../../mywallet`. In the RPC commands, there is no distinction between a wallet's 'name' and a wallet's 'path'. This PR fixes an issue with wallet backup during migration where the wallet's 'name-path' is used in the backup filename. This goes south when that filename is appended to the directory where we want to put the file and the wallet's 'name' actually gets treated as a path:

  ```cpp
      fs::path backup_filename = fs::PathFromString(strprintf("%s_%d.legacy.bak", (wallet_name.empty() ? "default_wallet" : wallet_name), GetTime()));
      fs::path backup_path = this_wallet_dir / backup_filename;
  ```

  Attempting to migrate a wallet with the 'name' `../../../mywallet` results in a backup being placed in `datadir/wallets/../../../mywallet/../../../mywallet_1744683963.legacy.bak`.

  If permissions don't exist to write to that folder, migration can fail.

  The solution implemented here is to put backup files in the top-level of the node's `walletdir` directory, using the folder name (and in some rare cases the file name)  of the wallet to name the backup file:

  9fa5480fc4/src/wallet/wallet.cpp (L4254-L4268)

  ##### Steps to reproduce on master
  Build and run `bitcoind` with legacy wallet creation enabled:
  ```bash
  $ cmake -B build -DWITH_BDB=ON && cmake --build build -j $(nproc)
  $ ./build/bin/bitcoind -regtest -deprecatedrpc=create_bdb
  ```

  Create a wallet with some relative path specifiers (exercise caution with where this file may be written)

  ```bash
  $ ./build/bin/bitcoin-cli -regtest -named createwallet wallet_name="../../../myrelativewallet" descriptors=false
  ```

  Try to migrate the wallet:
  ```bash
  $ ./build/bin/bitcoin-cli -regtest -named migratewallet wallet_name="../../../myrelativewallet"
  ```

  You will see a message in `debug.log` about trying to backup a file somewhere like: `/home/user/.bitcoin/regtest/wallets/../../../myrelativewallet/../../../myrelativewallet_1744686627.legacy.bak` and migration might fail because `bitcoind` doesn't have permissions to write the backup file.

ACKs for top commit:
  pablomartin4btc:
    tACK 76fe0e59ec
  achow101:
    ACK 76fe0e59ec
  ryanofsky:
    Code review ACK 76fe0e59ec. Nice changes that (1) fix potential errors when names of wallets being migrated contain slashes, and (2) store migration backups in the top-level `-walletdir` instead of in individual wallet subdirectories.

Tree-SHA512: 5cf6ed9f44ac7d204e4e9854edd3fb9b43812e930f76343b142b3c19df3de2ae5ca1548d4a8d26226d537bca231e3a50b3ff0d963c200303fb761f2b4eb3f0d9
2025-07-29 11:15:59 -07:00
Ava Chow 6b99670e3c
Merge bitcoin/bitcoin#33075: doc: Add legacy wallet removal release notes
fa45ccc15d doc: Add legacy wallet removal release notes (MarcoFalke)

Pull request description:

  This spans over several pulls, so add a single note for all of them.

ACKs for top commit:
  glozow:
    lgtm ACK fa45ccc15d
  achow101:
    ACK fa45ccc15d
  pablomartin4btc:
    ACK fa45ccc15d
  janb84:
    re ACK fa45ccc15d

Tree-SHA512: e753cc3afbd66a88099ff62c2591aa31d32d784098e433e392c20a8dfd40d5c85807e955b264a287c3778d68605cd7022278886a43cd1635c080d563c88fc0cc
2025-07-29 11:02:41 -07:00
merge-script 2cef200340
Merge bitcoin/bitcoin#28944: wallet, rpc: add anti-fee-sniping to `send` and `sendall`
aac0b6dd79 test: test sendall and send do anti-fee-sniping (ishaanam)
20802c7b65 wallet, rpc: add anti-fee-sniping to `send` and `sendall` (ishaanam)

Pull request description:

  Currently, `send` and `sendall` don't do anti-fee-sniping because they don't use `CreateTransaction`. This PR adds anti-fee-sniping to these RPCs by calling `DiscourageFeeSniping` from `FinishTransaction` when the user does not specify a locktime.

ACKs for top commit:
  achow101:
    ACK aac0b6dd79
  murchandamus:
    ACK aac0b6dd79
  glozow:
    ACK aac0b6dd79

Tree-SHA512: d4f1b43b5bda489bdba46b0af60e50bff0de604a35670e6ea6e1de2b539f16b3f68805492f51d6d2078d421b63432ca22a561a5721d1a37686f2e48284e1e646
2025-07-29 12:07:08 -04:00
merge-script 932e993b37
Merge bitcoin/bitcoin#33073: guix: warn SOURCE_DATE_EPOCH set in guix-codesign
1bed0f734b guix: warn SOURCE_DATE_EPOCH set in guix-codesign (will)

Pull request description:

  #32678 added a sanity check for this environment variable when running `guix-build` but missed that `guix-codesign` also relies on `SOURCE_DATE_EPOCH`, which can result in non-determinism in the codesigning step: https://github.com/bitcoin-core/guix.sigs/pull/1720#issuecomment-3124332676

  To avoid repeating the logic move common functionality into the prelude and call the function in both guix actions.

ACKs for top commit:
  fanquake:
    ACK 1bed0f734b

Tree-SHA512: ad3de8ab06e7f4ffcee5c02e8185b20879d63a02a614a706ea54da5087cca4ba75817ca1aa95301572c34723317fcc44e4478261ac73dd223ee9fa827e6b35b3
2025-07-29 16:33:52 +01:00
merge-script 0bed946e5d
Merge bitcoin/bitcoin#33079: ci: limit max stack size to 512 KiB
3b23f95e34 ci: limit max stack size to 512 KiB (dergoegge)
2931a87477 ci: limit stack size to 512kb in native macOS jobs (fanquake)

Pull request description:

  Picks up #31367.
  Closes #29840.

  Limit adjustment is moved until after compilation, otherwise compilation might not succeed.
  I've used compilation flags to limit the stack size in the native macOS jobs, because trying to use `ulimit` resulted in:
  ```bash
  + '[' -n 1 ']'
  + ulimit -s 262144
  /Users/runner/work/bitcoin/bitcoin/ci/test/03_test_script.sh: line 17: ulimit: stack size: cannot modify limit: Operation not permitted
  ```

  See example failures (`ulimit -s 64`) here: https://github.com/bitcoin/bitcoin/runs/46861548042.

ACKs for top commit:
  dergoegge:
    utACK 3b23f95e34

Tree-SHA512: 7e00626f3ca9e860d79a301af2427008ce27c329b618e24f95e7a55b284459a446216d2859c2e63be50abb9d4f0d343c12ff50445231652d354f225477928a35
2025-07-29 16:17:35 +01:00
merge-script 28ec91c30e
Merge bitcoin/bitcoin#33088: doc: move `cmake -B build -LH` up in Unix build docs
6757052fc4 doc: move `cmake -B build -LH` up in Unix build docs (Bufo)

Pull request description:

  #32269 rebased.

  > I had trouble building bitcoin core the way I wanted since now more features require a flag while building. IMO it makes sense to make it a bit more prominent in the build docs how to get the needed flags.

  > Related issue: https://github.com/bitcoin/bitcoin/issues/32258

ACKs for top commit:
  maflcko:
    lgtm ACK 6757052fc4
  stickies-v:
    ACK 6757052fc4
  janb84:
    ACK 6757052fc4

Tree-SHA512: 8e6dc1e432c067f862560776176112d5c24c4009bdf8e9a4e8d1ea3328b88732188fc4d8a7cd29f8a9ed8a1809a7a8a86d63b7ae3ec4ebae74be466727c8d730
2025-07-29 16:16:18 +01:00
Antoine Poinsot c157438116 qa: test that we do disconnect upon a second invalid compact block being announced
This was in fact untested until now. This can be checked with the following diff.

```diff
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 0c4a89c44cb..f8b9adf910a 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -1822,7 +1822,7 @@ void PeerManagerImpl::MaybePunishNodeForBlock(NodeId nodeid, const BlockValidati
         }
     case BlockValidationResult::BLOCK_INVALID_HEADER:
     case BlockValidationResult::BLOCK_INVALID_PREV:
-        if (peer) Misbehaving(*peer, message);
+        if (!via_compact_block && peer) Misbehaving(*peer, message);
         return;
     // Conflicting (but not necessarily invalid) data or different policy:
     case BlockValidationResult::BLOCK_MISSING_PREV:
```
2025-07-29 09:52:32 -04:00
merge-script 2f410ad78c
Merge bitcoin/bitcoin#32263: cluster mempool: add TxGraph work controls
62ed1f92ef txgraph: check that DoWork finds optimal if given high budget (tests) (Pieter Wuille)
f3c2fc867f txgraph: add work limit to DoWork(), try optimal (feature) (Pieter Wuille)
e96b00d99e txgraph: make number of acceptable iterations configurable (feature) (Pieter Wuille)
cfe9958852 txgraph: track amount of work done in linearization (preparation) (Pieter Wuille)
6ba316eaa0 txgraph: 1-or-2-tx split-off clusters are optimal (optimization) (Pieter Wuille)
fad0eb091e txgraph: reset quality when merging clusters (bugfix) (Pieter Wuille)

Pull request description:

  Part of #30289. Builds on top of #31553.

  So far, the `TxGraph::DoWork()` function took no parameters, and just made all clusters reach the "acceptable" internal quality level by performing a minimum number of improvement iterations on it, but:
  * Did not attempt to go beyond that.
  * Was broken, as the QualityLevel of optimal clusters that merge together was not being reset.

  Fix this by adding an argument to `DoWork()` to control how much work it is allowed to do right now, which will first be used to get all clusters to the acceptable level, and if more budget remains, use it to try to get some or all clusters optimal. The function will now return `true` if all clusters are known to be optimal (and thus no further work remains). This is verified in the tests, by remembering whether the graph is optimal, and if it is at the end of the simulation run, verify that the overall linearization cannot be improved further.

ACKs for top commit:
  instagibbs:
    ACK 62ed1f92ef
  ismaelsadeeq:
    Code review ACK 62ed1f92ef
  glozow:
    ACK 62ed1f92ef

Tree-SHA512: 5f57d4052e369f3444e72e724f04c02004e0f66e365faa59c9f145323e606508380fc97bb038b68783a62ae9c10757f1b628b3b00b2ce9a46161fca2d4336d73
2025-07-29 09:07:10 -04:00
Bufo 6757052fc4
doc: move `cmake -B build -LH` up in Unix build docs 2025-07-29 11:55:26 +01:00
Cory Fields 9954d6c833
depends: hard-code necessary c(xx)flags rather than setting them per-host
The per-host flag variables hold platform-specific defaults that are ignored
when flag environment variables are set, so it was wrong for them to contain
-std options relied on by package definitions.

Additionally, these flags (-pipe and -std=xx) will no longer be passed into
the CMake build, meaning less duplication in the build summary.

Pulled out of #31920.
2025-07-29 11:13:39 +01:00
merge-script 953c90d764
Merge bitcoin/bitcoin#33086: contrib: [tracing] fix pointer argument handling in mempool_monitor.py
0ce041ea88 tracing: fix pointer argument handling in mempool_monitor.py (deadmanoz)

Pull request description:

  The BPF code was incorrectly passing pointer variables by value to `bpf_usdt_readarg()`, causing the function to fail silently and resulting in transaction hashes showing as zeros and reason strings displaying empty strings.

  This fix adds the missing reference operator (&) when passing pointer variables to `bpf_usdt_readarg()`, allowing the function to properly write the pointer values and enabling correct display of transaction hashes and removal/rejection reasons.

  Fixes the regression introduced in [ec47ba349d](ec47ba349d) where `bpf_usdt_readarg_p` was replaced with `bpf_usdt_readarg` but the calling convention wasn't properly updated for pointer arguments.

  **Before: "0000000000000000000000000000000000000000000000000000000000000000" tx hashes, and missing reasons (empty strings) for removal.**

  <img width="1683" height="1330" alt="Screenshot 2025-07-29 at 4 30 03 PM" src="https://github.com/user-attachments/assets/71ba88be-dbcc-43a6-bfe7-bd49ae082b13" />

  **After: tx hashes show, reasons for removal showing.**

  <img width="1682" height="1330" alt="Screenshot 2025-07-29 at 4 29 23 PM" src="https://github.com/user-attachments/assets/03738c75-5526-4c1e-82c2-ba100cdf128a" />

ACKs for top commit:
  0xB10C:
    tested ACK 0ce041ea88

Tree-SHA512: cb50748fa2cd38be4b0abed36723917c2c82a92f588928bb0650eed0049c121df89b33d53421037b12836a497f30b449fe3d041ff7755a1fd9da43544392cf40
2025-07-29 10:53:24 +01:00
rkrux 5888b4a2a5
doc: add note for watch-only wallet migration
This was suggested in a previous PR 31423.
2025-07-29 15:18:36 +05:30
dergoegge 3b23f95e34
ci: limit max stack size to 512 KiB
Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
2025-07-29 10:29:19 +01:00
fanquake 2931a87477
ci: limit stack size to 512kb in native macOS jobs 2025-07-29 10:02:06 +01:00
merge-script 3724e9b40a
Merge bitcoin/bitcoin#32973: validation: docs and cleanups for MemPoolAccept coins views
b6d4688f77 [doc] reword comments in test_mid_package_replacement (glozow)
f3a613aa5b [cleanup] delete brittle test_mid_package_eviction (glozow)
c3cd7fcb2c [doc] remove references to now-nonexistent Finalize() function (glozow)
d8140f5f05 don't make a copy of m_non_base_coins (glozow)
98ba2b1db2 [doc] MemPoolAccept coins views (glozow)
ba02c30b8a [doc] always CleanupTemporaryCoins after a mempool trim (glozow)

Pull request description:

  Deletes `test_mid_package_eviction` that is brittle and already covered in other places. It was introduced in #28251 addressing 2 issues: (1) calling `LimitMempoolSize()` in the middle of package validation and (2) not updating coins view cache when the mempool contents change, leading to "disappearing coins."

  (1) If you let `AcceptSingleTransaction` call `LimitMempoolSize` in the middle of package validation, you should get a failure in `test_mid_package_eviction_success` (the package is rejected):
  ```
  diff --git a/src/validation.cpp b/src/validation.cpp
  index f2f6098e214..4bd6f059849 100644
  --- a/src/validation.cpp
  +++ b/src/validation.cpp
  @@ -1485,7 +1485,7 @@ MempoolAcceptResult MemPoolAccept::AcceptSingleTransaction(const CTransactionRef
       FinalizeSubpackage(args);

       // Limit the mempool, if appropriate.
  -    if (!args.m_package_submission && !args.m_bypass_limits) {
  +    if (!args.m_bypass_limits) {
           LimitMempoolSize(m_pool, m_active_chainstate.CoinsTip());
           // If mempool contents change, then the m_view cache is dirty. Given this isn't a package
           // submission, we won't be using the cache anymore, but clear it anyway for clarity.
  ```
  Mempool modifications have a pretty narrow interface since #31122 and `TrimToSize()` cannot be called while there is an outstanding mempool changeset. So I think there is a low likelihood of accidentally reintroducing this problem and not immediately hitting e.g. a fuzzer crash on this line b53fab1467/src/txmempool.cpp (L1143)

  (2) If you remove the `CleanupTemporaryCoins()` call from `ClearSubPackageState()` you should get a failure from `test_mid_package_replacement`:
  ```
  diff --git a/src/validation.cpp b/src/validation.cpp
  index f2f6098e214..01b904b69ef 100644
  --- a/src/validation.cpp
  +++ b/src/validation.cpp
  @@ -779,7 +779,7 @@ private:
           m_subpackage = SubPackageState{};

           // And clean coins while at it
  -        CleanupTemporaryCoins();
  +        // CleanupTemporaryCoins();
       }
   };
  ```
  I also added/cleaned up the documentation about coins views to hopefully make it extremely clear when people should `CleanupTemporaryCoins`.

ACKs for top commit:
  instagibbs:
    reACK b6d4688f77
  sdaftuar:
    utACK b6d4688f77
  marcofleon:
    ACK b6d4688f77

Tree-SHA512: 79c68e263013b1153520f5453e6b579b8fe7e1d6a9952b1ac2c3c3c017034e6d21d7000a140bba4cc9d2ce50ea3a84cc6f91fd5febc52d7b3fa4f797955d987d
2025-07-29 10:01:02 +01:00
deadmanoz 0ce041ea88 tracing: fix pointer argument handling in mempool_monitor.py
The BPF code was incorrectly passing pointer variables by value to
bpf_usdt_readarg(), causing the function to fail silently and resulting
in transaction hashes and reason strings displaying as zeros or garbage.

This fix adds the missing reference operator (&) when passing pointer
variables to bpf_usdt_readarg(), allowing the function to properly
write the pointer values and enabling correct display of transaction
hashes and removal/rejection reasons.

Fixes the regression introduced in ec47ba349d where bpf_usdt_readarg_p
was replaced with bpf_usdt_readarg but the calling convention wasn't
properly updated for pointer arguments.
2025-07-29 08:24:47 +00:00
Hennadii Stepanov 25884bd896
qt, refactor: Move `FreespaceChecker` class into its own module 2025-07-29 08:54:24 +01:00
Antoine Poinsot fb2dcbb160 qa: test cached failure for compact block
Submit the block with an invalid transaction Script again, leading to
CACHED_INVALID being returned by AcceptBlockHeader(). Ensure that also this
code path does not lead to a disconnection.

This was previously untested, as can be checked with the following diff:
```diff
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 0c4a89c44cb..e8e0c805367 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -1814,10 +1814,10 @@ void PeerManagerImpl::MaybePunishNodeForBlock(NodeId nodeid, const BlockValidati
         {
             // Discourage outbound (but not inbound) peers if on an invalid chain.
             // Exempt HB compact block peers. Manual connections are always protected from discouragement.
-            if (peer && !via_compact_block && !peer->m_is_inbound) {
+            //if (peer && !via_compact_block && !peer->m_is_inbound) {
                 if (peer) Misbehaving(*peer, message);
                 return;
-            }
+            //}
             break;
         }
     case BlockValidationResult::BLOCK_INVALID_HEADER:
```
2025-07-28 17:54:14 -04:00
Antoine Poinsot f12d8b104e qa: test a compact block with an invalid transaction
The current test to exercise a block with an invalid transaction actually
creates a block with an invalid coinbase witness, which is checked early and
for which MaybePunishNodeForBlock() is not called.

Add a test case with an invalid regular transaction, which will lead
CheckInputScripts to return a CONSENSUS error and MaybePunishNodeForBlock() to
be called, appropriately not disconnecting upon an invalid compact block. This
was until now untested as can be checked with the following diff:
```diff
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 0c4a89c44cb..d243fb88d4b 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -1805,10 +1805,10 @@ void PeerManagerImpl::MaybePunishNodeForBlock(NodeId nodeid, const BlockValidati
     // The node is providing invalid data:
     case BlockValidationResult::BLOCK_CONSENSUS:
     case BlockValidationResult::BLOCK_MUTATED:
-        if (!via_compact_block) {
+        //if (!via_compact_block) {
             if (peer) Misbehaving(*peer, message);
             return;
-        }
+        //}
         break;
     case BlockValidationResult::BLOCK_CACHED_INVALID:
         {
```

Finally, note this failure is cached (unlike the malleated witness failure),
which will be used in the following commits.
2025-07-28 17:39:02 -04:00
Antoine Poinsot d6c37b28a7 qa: remove unnecessary tx removal from compact block
The error being checked here is BLOCK_MUTATED, as returned by IsBlockMutated()
in FillBlock(). Dropping the fourth transaction from the block is unnecessary
and would make testing of other block validation failures in following commits
more verbose.
2025-07-28 17:16:20 -04:00
Lőrinc 554befd873 test: revive `getcoinscachesizestate`
After the changes in https://github.com/bitcoin/bitcoin/pull/25325 `getcoinscachesizestate` always end the test early, see:
https://maflcko.github.io/b-c-cov/test_bitcoin.coverage/src/test/validation_flush_tests.cpp.gcov.html

The test revival was extracted from a related PR where it was discovered, see: https://github.com/bitcoin/bitcoin/pull/28531#discussion_r2109417797

Co-authored-by: Larry Ruane <larryruane@gmail.com>
2025-07-28 13:17:30 -07:00
Lőrinc 64ed0fa6b7 refactor: modernize `LargeCoinsCacheThreshold`
* parameter name uses underscores
* commit message typo fixed and compacted
* used `10_MiB` to avoid having to comment
* swapped order of operands in (9 * x / 10) to make it obvious that we're calculating 90%
* inlined return value
2025-07-28 13:17:17 -07:00
Lőrinc 1b40dc02a6 refactor: extract `LargeCoinsCacheThreshold` from `GetCoinsCacheSizeState`
Move-only commit, enabled reusing the large cache size calculation logic later. The only difference is the removal of the `static` keyword  (since in a constexpr function it's a C++23 extension)
2025-07-28 13:17:17 -07:00
Ava Chow 321984705d
Merge bitcoin/bitcoin#32279: [IBD] prevector: store `P2WSH`/`P2TR`/`P2PK` scripts inline
d5104cfbae prevector: store `P2WSH`/`P2TR`/`P2PK` scripts inline (Lőrinc)
52121506b2 test: assert `CScript` allocation characteristics (Lőrinc)
65ac7f6d4d refactor: modernize `CScriptBase` definition (Lőrinc)
756da2a994 refactor: extract `STATIC_SIZE` constant to prevector (Lőrinc)

Pull request description:

  This change is part of [[IBD] - Tracking PR for speeding up Initial Block Download](https://github.com/bitcoin/bitcoin/pull/32043)

  ### Summary

  The current `prevector` size of 28 bytes (chosen to fill the `sizeof(CScript)` aligned size) was introduced in 2015 (https://github.com/bitcoin/bitcoin/pull/6914) before `SegWit` and `TapRoot`.
  However, the increasingly common `P2WSH` and `P2TR` scripts are both 34 bytes, and are forced to use heap (re)allocation rather than efficient inline storage.

  The core trade-off of this change is to eliminate heap allocations for common 34-36 byte scripts at the cost of increasing the base memory footprint of all `CScript` objects by 8 bytes (while still respecting peak memory usage defined by `-dbcache`).

  ### Context
  Increasing the `prevector` size allows these scripts to be stored inline, avoiding heap allocations, reducing potential memory fragmentation, and improving performance during cache flushes. Massif analysis confirms a lower stable memory usage after flushing, suggesting the elimination of heap allocations outweighs the larger base size for common workloads.

  Due to memory alignment, increasing the prevector size to 36 bytes doesn't change the overall `sizeof(CScript)` compared to an increase to 34 bytes, allowing us to include `P2PK` scripts as well at no additional memory cost.

  <details>
  <summary>Massif measurements</summary>

  > dbcache=440

  Massif before, with a heap threshold of `28`:
  ```bash
      MB
  744.1^#
       |#: ::::::@: :::::::   :@:: @::::::::::::::@@
       |#: ::::::@::::: :::   :@:::@:::::: :: ::::@
       |#: ::::::@::::: :::   :@:::@:::::: :: ::::@
       |#: ::::::@::::: ::: : :@:::@:::::: :: ::::@
       |#: ::::::@::::: ::: : :@:::@:::::: :: ::::@
       |#: ::::::@::::: ::: : :@:::@:::::: :: ::::@
       |#::::::::@::::: ::: : :@:::@:::::: :: ::::@
       |#::::::::@::::: ::: :::@:::@:::::: :: ::::@
       |#::::::::@::::: ::: :::@:::@:::::: :: ::::@
       |#::::::::@::::: ::: :::@:::@:::::: :: ::::@
       |#::::::::@::::: ::: :::@:::@:::::: :: ::::@
       |#::::::::@::::: :::::::@:::@:::::: :: ::::@
       |#::::::::@::::: :::::::@:::@:::::: :: ::::@ :::::@:::::@:::::@:::::@::::
       |#::::::::@::::: :::::::@:::@:::::: :: ::::@ :::::@:::::@:::::@:::::@::::
       |#::::::::@::::: :::::::@:::@:::::: :: ::::@ :::::@:::::@:::::@:::::@::::
       |#::::::::@::::: :::::::@:::@:::::: :: ::::@ :::::@:::::@:::::@:::::@::::
       |#::::::::@::::: :::::::@:::@:::::: :: ::::@ :::::@:::::@:::::@:::::@::::
       |#::::::::@::::: :::::::@:::@:::::: :: ::::@ :::::@:::::@:::::@:::::@::::
       |#::::::::@::::: :::::::@:::@:::::: :: ::::@ :::::@:::::@:::::@:::::@::::
     0 +----------------------------------------------------------------------->h
       0                                                                   1.805
  ```

  and after, with a heap threshold of `36`:
  ```bash
      MB
  744.2^       :
       |#  :  :::::::::::   : : :: ::: @@:::::: ::  :
       |#  :  :::: ::::::   : : :: ::: @ :: ::  :   :
       |#  :  :::: :::::::  : :@:: ::: @ :: ::  : :::
       |#  :  :::: :::::::  : :@:: ::: @ :: ::  : : :
       |#  :  :::: :::::::  : :@:: ::: @ :: ::  : : :
       |#  :  :::: :::::::  : :@:: ::: @ :: ::  : : :
       |#  :: :::: :::::::  : :@:: ::: @ :: ::  : : :
       |#  :: :::: :::::::  : :@:: ::::@ :: ::  : : :
       |#:::: :::: :::::::  :::@:: ::::@ :: ::  : : :
       |#: ::::::: :::::::  :::@:: ::::@ :: :: @: : :
       |#: ::::::: :::::::  :::@:::::::@ :: :: @: : :
       |#: ::::::: ::::::::::::@:::::::@ :: :: @: : :
       |#: ::::::: :::::::: :::@:::::::@ :: :: @: : :
       |#: ::::::: :::::::: :::@:::::::@ :: :: @: : :::@:::@::::@::::::@:::::@::
       |#: ::::::: :::::::: :::@:::::::@ :: :: @: : :::@:::@::::@::::::@:::::@::
       |#: ::::::: :::::::: :::@:::::::@ :: :: @: : :::@:::@::::@::::::@:::::@::
       |#: ::::::: :::::::: :::@:::::::@ :: :: @: : :::@:::@::::@::::::@:::::@::
       |#: ::::::: :::::::: :::@:::::::@ :: :: @: : :::@:::@::::@::::::@:::::@::
       |#: ::::::: :::::::: :::@:::::::@ :: :: @: : :::@:::@::::@::::::@:::::@::
     0 +----------------------------------------------------------------------->h
       0                                                                   1.618
  ```

  ---

  > for `dbcache=4500`:

  Massif before, with a heap threshold of `28`:
  ```bash
      GB
  4.565^   ::
       | ##:   @@:::  :::: :@::::  :::: ::::
       | # :   @ ::   :::  :@: ::  : :: :::
       | # :   @ :: :::::  :@: ::  : :: :::
       | # :   @ :: : :::  :@: :: @: :: :::
       | # :   @ :: : :::  :@: :: @: :: :::
       | # :   @ :: : :::  :@: :: @: :: :::
       | # :   @ :: : :::  :@: :: @: :: :::
       | # : ::@ :: : :::  :@: :: @: :: :::
       | # : : @ :: : :::  :@: :: @: :: :::
       | # : : @ :: : :::  :@: :: @: ::::::
       | # : : @ :: : :::  :@: :: @: ::::::
       | # : : @ :: : :::  :@: :: @: ::::::
       | # : : @ :: : ::: ::@: :: @: ::::::
       | # : : @ :: : ::: ::@: :: @: ::::::
       | # : : @ :: : ::: ::@: :: @: ::::::
       | # : : @ :: : ::: ::@: :: @: :::::: @::
       | # : : @ :: : ::: ::@: :: @: :::::: @:
       | # : : @ :: : ::: ::@: :::@: :::::: @:
       | # : : @ :: : ::: ::@: :::@: :::::: @: :::::::::::::::::::::::::::::@:::
     0 +----------------------------------------------------------------------->h
       0                                                                   1.500
  ```

  and after, with a heap threshold of `36`:
  ```
      GB
  4.640^    :
       | ##::  :::::   ::::  ::::::@  ::::
       | # ::  : :::   ::::  :: :::@  ::::
       | # :: :: :::   ::::  :: :::@  ::::
       | # :: :: :::  :::::  :: :::@  ::::
       | # :: :: :::  :::::  :: :::@  ::::
       | # :: :: :::  :::::  :: :::@  ::::
       | # :: :: :::  :::::  :: :::@  ::::
       | # :: :: :::  :::::  :: :::@  ::::  :@@
       | # :: :: :::  ::::: ::: :::@  :::::::@
       | # :: :: :::  ::::: ::: :::@  ::::: :@
       | # :: :: :::  ::::: ::: :::@::::::: :@
       | # ::::: :::  ::::: ::: :::@: ::::: :@
       | # ::::: :::  ::::: ::: :::@: ::::: :@
       | # ::::: :::::::::: ::: :::@: ::::: :@
       | # ::::: :::: ::::: ::: :::@: ::::: :@
       | # ::::: :::: ::::: ::: :::@: ::::: :@
       | # ::::: :::: ::::::::: :::@: ::::: :@
       | # ::::: :::: ::::::::: :::@: ::::: :@
       | # ::::: :::: ::::::::: :::@: ::::: :@ ::::::@:::@:::@::::@:::::@::::@::
     0 +----------------------------------------------------------------------->h
       0                                                                   1.360
  ```

  </details>

  ### Benchmarks and Memory

  Performance benchmarks for `AssumeUTXO` load and flush show:
  - Small dbcache (450MB): ~1-3% performance improvement (despite more frequent flushes)
  - Large dbcache (4500MB): ~6-8% performance improvement due to fewer heap allocations (and basically the number of flushes)
  - Very large dbcache (4500MB): ~5-6% performance improvement due to fewer heap allocations (and memory limit not being reached, so there's no memory penalty)

  Full IBD and `-reindex-chainstate` with also show an overall ~3-4% speedup (both for smaller and larger dbcache values).

  We haven't investigated using different `prevector` sizes based on script type, though this could be explored in the future if needed.

  ### Historical explanation for the speedup (by [Anthony Towns](https://github.com/bitcoin/bitcoin/pull/32279#issuecomment-3111757079))

  > I think the tradeoff is something like:
  >
  > * spends of p2pk, p2sh, p2pkh coins -- these cost 8 more bytes
  > * spends of p2wpkh -- these cost 16 more bytes (sPK and scriptSig didn't need an allocation)
  > * spends of p2wsh and p2tr -- these cost ~48 fewer bytes (save 64 byte allocation on 64bit system, lose 8 bytes for both scriptSig and sPK)
  > * spends of nested p2wsh -- presumably save ~96 bytes, since the scriptSig would save an allocation, but I'm bundling it in the previous section
  >
  > Based on mainnet.observer stats for 2025-05-08, p2wpkh is about 55% of txs, p2tr is about 28%, p2pkh about 13%, p2wsh about 4% and the rest is noise, maybe? Those numbers net out to a saving of ~5.5 bytes per input. If p2wpkh rose from 55% to 80% and p2tr dropped to 20%, that would net to wasting ~3.2 bytes per input.

ACKs for top commit:
  maflcko:
    review ACK d5104cfbae 🐺
  achow101:
    reACK d5104cfbae
  jonatack:
    Review ACK d5104cfbae
  andrewtoth:
    ACK d5104cfbae

Tree-SHA512: 7c5271ebaf4f6d91dc4b679ecbde4b7d0467579f072289f30da988a17c38a552d0b8cdf0e9c001739975dd019894c35e541908571527916cec56e04a8e214ae2
2025-07-28 11:55:48 -07:00
marcofleon 94b39ce738 refactor: Change `m_tx_inventory_to_send` from `std::set<GenTxid>` to `std::set<Wtxid>`
Simplifies `m_tx_inventory_to_send` a bit by making it a set of Wtxids.
Wtxid relay is prevalent throughout the network, so the complexity of
dealing with a GenTxid in this data structure isn't necessary.

For peers that aren't wtxid relay, the txid is now retrieved from our
mempool entry when the inv is constructed.
2025-07-28 18:19:04 +01:00
MarcoFalke fa45ccc15d
doc: Add legacy wallet removal release notes 2025-07-28 16:48:25 +02:00
Eugene Siegel 8319a13468 log: clarify RATELIMIT_MAX_BYTES comment, use RATELIMIT_WINDOW
Co-Authored-By: stickies-v <stickies-v@protonmail.com>
2025-07-28 10:17:04 -04:00
Eugene Siegel 5f70bc80df log: remove const qualifier from arguments in LogPrintFormatInternal
Co-Authored-By: l0rinc <pap.lorinc@gmail.com>
2025-07-28 10:17:04 -04:00
Eugene Siegel b8e92fb3d4 log: avoid double hashing in SourceLocationHasher
Co-Authored-By: l0rinc <pap.lorinc@gmail.com>
2025-07-28 10:17:04 -04:00
Eugene Siegel 616bc22f13 test: remove noexcept(false) comment in ~DebugLogHelper 2025-07-28 10:17:04 -04:00
merge-script 2a97ff466d
Merge bitcoin/bitcoin#29954: RPC: Return `permitbaremultisig` and `maxdatacarriersize` in `getmempoolinfo`
1c10b7351e RPC: Return permitbaremultisig and maxdatacarriersize in getmempoolinfo (Kristaps Kaupe)

Pull request description:

  Other node relay settings like `fullrbf` and `minrelaytxfee` are already returned, makes sense to add these two too.

ACKs for top commit:
  ajtowns:
    ACK 1c10b7351e
  maflcko:
    lgtm ACK 1c10b7351e
  theStack:
    ACK 1c10b7351e

Tree-SHA512: 1750d7d12de511f0ac34922ea9c58c4b9b55c3aaf22109abfd7dbe01ad1eb7b48fb4a6b074a0baf0e55ee2270fcc969b6830e499ff33adbcd0b9c761fb25e563
2025-07-28 09:32:03 -04:00
merge-script fd068257e0
Merge bitcoin/bitcoin#33065: rpc, wallet: replace remaining hardcoded output types with `FormatAllOutputTypes`
251d020846 init, wallet: replace hardcoded output types with `FormatAllOutputTypes` (Sebastian Falbesoner)
e3ba0757a9 rpc, wallet: replace remaining hardcoded output types with `FormatAllOutputTypes` (Sebastian Falbesoner)

Pull request description:

  This PR takes use of the `FormatAllOutputTypes` helper (introduced in PR #32432, commit 8cc9845b8d) to get rid of the remaining hardcoded output types in wallet RPC and command line arguments documentation [1]. Note that it can't be used in the [`createmultisig` RPC](fc162299f0/src/rpc/output_script.cpp (L100)), as this one is only for pre-taproot output types and hence doesn't contain "bech32m" in the list.

  [1] instances were found via `$ git grep legacy.*p2sh-segwit ./src/rpc/ ./src/wallet/`

ACKs for top commit:
  nervana21:
    tACK [251d020](251d020846)
  maflcko:
    review ACK 251d020846 🌨
  pablomartin4btc:
    re-utACK 251d020846
  rkrux:
    crACK 251d020846

Tree-SHA512: 23d1025d068f3a44b115a34b217b808fcae59fc574e35a899f0d43a85512935c90675d2e98c621287e02adc3a9f4a08289a26596c66e2122262af0cd2dfbde72
2025-07-28 13:51:14 +01:00
stickies-v 9ba1fff29e
kernel: refactor: ConnectTip to pass block pointer by value
By passing by value, we can remove the need to allocate a new pointer if
the callsite uses move semantics. In the process, simplify naming.
2025-07-28 13:45:15 +01:00
merge-script 9cafdf8941
Merge bitcoin/bitcoin#33064: test: fix RPC coverage check
8aed477c33 test: fix RPC coverage check (Brandon Odiwuor)
2630b64f81 test: add abortrescan RPC test (Brandon Odiwuor)

Pull request description:

  This is #27593 cleaned up / rebased, now that the legacy wallet has been dropped.

  Closes #27593.

ACKs for top commit:
  maflcko:
    lgtm ACK 8aed477c33
  cedwies:
    ACK 8aed477

Tree-SHA512: 14a28b1ef0c1f63236d04c2ff6c11adddc40642e4a23d30398e8a03fc47f911465af91affc6e66ee2d548515ef4f65fb1cb5d69985c5a771a17b1c9c009f48ad
2025-07-28 10:53:07 +01:00
Cory Fields fdbade6f8d
kernel: create monolithic kernel static library 2025-07-28 10:37:42 +01:00
merge-script c8309198f8
Merge bitcoin/bitcoin#33070: doc/zmq: fix unix socket path example
e83699a626 doc/zmq: fix unix socket path example (Roman Zeyde)

Pull request description:

  Following 75a5c8258e/doc/release-notes/release-notes-28.0.md?plain=1#L105

ACKs for top commit:
  pinheadmz:
    tested ACK e83699a626
  cedwies:
    ACK e83699a

Tree-SHA512: a697d96762083f7a7c44c0ed366b68065a2538208cf7d2b9bcfc567bffeaa530ea5c16dc38bfd4bc38b926a5044d2fa880ffce6309366f3a11d181e59e122627
2025-07-28 10:17:58 +01:00
will 1bed0f734b
guix: warn SOURCE_DATE_EPOCH set in guix-codesign
Currently there is a warning for this in guix-build, but we also need
one in guix-codesign, otherwise the codesigned hashes are not
reproducible.

Move common functionality into prelude and call the function in both
guix actions.
2025-07-27 21:51:39 +01:00
yancy cc33e45789 test: improve assertion for SRD max weight test
Previously, the assertion only showed that a result was found, however
made no assertion about the quality of the result.

Remove comment about what UTXOs are selected and what are not
since the test does not reflect that.

Co-authored-by: Mark "Murch" Erhardt <murch@murch.one>
2025-07-26 16:07:13 -05:00
Kristaps Kaupe 1c10b7351e RPC: Return permitbaremultisig and maxdatacarriersize in getmempoolinfo
Co-authored-by: Andrew Toth <andrewstoth@gmail.com>
Co-authored-by: Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
Co-authored-by: Anthony Towns <aj@erisian.com.au>
2025-07-26 15:26:55 +03:00
Roman Zeyde e83699a626
doc/zmq: fix unix socket path example
Following 75a5c8258e/doc/release-notes/release-notes-28.0.md?plain=1#L105
2025-07-26 13:58:01 +03:00
Brandon Odiwuor 8aed477c33
test: fix RPC coverage check 2025-07-26 10:21:41 +01:00
Brandon Odiwuor 2630b64f81
test: add abortrescan RPC test 2025-07-26 10:21:41 +01:00
merge-script 75a5c8258e
Merge bitcoin/bitcoin#33063: util: Revert "common: Close non-std fds before exec in RunCommandJSON"
faa1c3e80d Revert "Merge bitcoin/bitcoin#32343: common: Close non-std fds before exec in RunCommandJSON" (MarcoFalke)

Pull request description:

  After a fork() in a multithreaded program, the child can safely
  call only async-signal-safe functions (see [signal-safety(7)](https://www.man7.org/linux/man-pages/man7/signal-safety.7.html))
  until such time as it calls execv.

  The standard library (`std` namespace) is not async-signal-safe. Also, `throw`, isn't.

  There was an alternative implementation using `readdir` (https://github.com/bitcoin/bitcoin/pull/32529), but that isn't async-signal-safe either, and that implementation was still using `throw`.

  So temporarily revert this feature.

  A follow-up in the future can add it back, using only async-signal-safe functions, or by using a different approach.

  Fixes https://github.com/bitcoin/bitcoin/issues/32524
  Fixes https://github.com/bitcoin/bitcoin/issues/33015
  Fixes https://github.com/bitcoin/bitcoin/issues/32855

  For reference, a failure can manifest in the GCC debug mode:

  * While `fork`ing, a debug mode mutex is held (by any other thread).
  * The `fork`ed child tries to use the stdard libary before `execv` and deadlocks.

  This may look like the following:

  ```
  (gdb) thread apply all bt

  Thread 1 (Thread 0xf58f4b40 (LWP 774911) "b-httpworker.2"):
  #0  0xf7f4f589 in __kernel_vsyscall ()
  #1  0xf79e467e in ?? () from /lib32/libc.so.6
  #2  0xf79eb582 in pthread_mutex_lock () from /lib32/libc.so.6
  #3  0xf7d93bf2 in ?? () from /lib32/libstdc++.so.6
  #4  0xf7d93f36 in __gnu_debug::_Safe_iterator_base::_M_attach(__gnu_debug::_Safe_sequence_base*, bool) () from /lib32/libstdc++.so.6
  #5  0x5668810a in __gnu_debug::_Safe_iterator_base::_Safe_iterator_base (this=0xf58f13ac, __seq=0xf58f13f8, __constant=false) at /bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/debug/safe_base.h:91
  #6  0x56ddfb50 in __gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<int*, std::__cxx1998::vector<int, std::allocator<int> > >, std::__debug::vector<int, std::allocator<int> >, std::forward_iterator_tag>::_Safe_iterator (this=0xf58f13a8, __i=3, __seq=0xf58f13f8) at /bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/debug/safe_iterator.h:162
  #7  0x56ddfacb in __gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<int*, std::__cxx1998::vector<int, std::allocator<int> > >, std::__debug::vector<int, std::allocator<int> >, std::bidirectional_iterator_tag>::_Safe_iterator (this=0xf58f13a8, __i=3, __seq=0xf58f13f8) at /bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/debug/safe_iterator.h:539
  #8  0x56ddfa5b in __gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<int*, std::__cxx1998::vector<int, std::allocator<int> > >, std::__debug::vector<int, std::allocator<int> >, std::random_access_iterator_tag>::_Safe_iterator (this=0xf58f13a8, __i=3, __seq=0xf58f13f8) at /bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/debug/safe_iterator.h:687
  #9  0x56ddd3f6 in std::__debug::vector<int, std::allocator<int> >::begin (this=0xf58f13f8) at /bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/debug/vector:300
  #10 0x57d83701 in subprocess::detail::Child::execute_child (this=0xf58f156c) at ./util/subprocess.h:1372
  #11 0x57d80a7c in subprocess::Popen::execute_process (this=0xf58f1cd8) at ./util/subprocess.h:1231
  #12 0x57d6d2b4 in subprocess::Popen::Popen<subprocess::input, subprocess::output, subprocess::error, subprocess::close_fds> (this=0xf58f1cd8, cmd_args="fake.py enumerate", args=..., args=..., args=..., args=...) at ./util/subprocess.h:964
  #13 0x57d6b597 in RunCommandParseJSON (str_command="fake.py enumerate", str_std_in="") at ./common/run_command.cpp:27
  #14 0x57a90547 in ExternalSigner::Enumerate (command="fake.py", signers=std::__debug::vector of length 0, capacity 0, chain="regtest") at ./external_signer.cpp:28
  #15 0x56defdab in enumeratesigners()::$_0::operator()(RPCHelpMan const&, JSONRPCRequest const&) const (this=0xf58f2ba0, self=..., request=...) at ./rpc/external_signer.cpp:51
  ...
  (truncated, only one thread exists)
  ```

ACKs for top commit:
  fanquake:
    ACK faa1c3e80d
  darosior:
    ACK faa1c3e80d

Tree-SHA512: 602da5f2eba08d7fe01ba19baf411e287ae27fe2d4b82f41734e05b7b1d938ce94cc0041e86ba677284fa92838e96ebee687023ff28047e2b036fd9a53567e0a
2025-07-26 10:20:58 +01:00
Lőrinc d5104cfbae prevector: store `P2WSH`/`P2TR`/`P2PK` scripts inline
The current `prevector` size of 28 bytes (chosen to fill the `sizeof(CScript)` aligned size) was introduced in 2015 (https://github.com/bitcoin/bitcoin/pull/6914) before SegWit and TapRoot.
However, the increasingly common `P2WSH` and `P2TR` scripts are both 34 bytes, and are forced to use heap (re)allocation rather than efficient inline storage.

The core trade-off of this change is to eliminate heap allocations for common 34-36 byte scripts at the cost of increasing the base memory footprint of all `CScript` objects by 8 bytes (while still respecting peak memory usage defined by `-dbcache`).

Increasing the `prevector` size allows these scripts to be stored inline, avoiding extra heap allocations, reducing potential memory fragmentation, and improving performance during cache flushes. Massif analysis confirms a lower stable memory usage after flushing, suggesting the elimination of heap allocations outweighs the larger base size for common workloads.

Due to memory alignment, increasing the `prevector` size to 36 bytes doesn't change the overall `sizeof(CScript)` compared to an increase to 34 bytes, allowing us to include `P2PK` scripts as well at no additional memory cost.

Performance benchmarks for AssumeUTXO load and flush show:
* Small dbcache (450MB): ~1-3% performance improvement (despite more frequent flushes)
* Large dbcache (4500MB): ~6-8% performance improvement due to fewer heap allocations (and basically the number of flushes)
* Very large dbcache (4500MB): ~5-6% performance improvement due to fewer heap allocations (and memory limit not being reached, so there's no memory penalty)

Full IBD and reindex-chainstate with larger `dbcache` values also show an overall ~3-4% speedup.

Co-authored-by: Ava Chow <github@achow101.com>
Co-authored-by: Andrew Toth <andrewstoth@gmail.com>
Co-authored-by: maflcko <6399679+maflcko@users.noreply.github.com>
2025-07-25 22:33:50 -07:00
Lőrinc 52121506b2 test: assert `CScript` allocation characteristics
Verifies that script types are correctly allocated using prevector's direct or indirect storage based on their size:

Direct allocated script types (size ≤ 28 bytes):
* OP_RETURN (small)
* P2WPKH
* P2SH
* P2PKH

Indirect allocated script types (size > 28 bytes):
* P2WSH
* P2TR
* P2PK
* MULTISIG (small)

This test provides a baseline for verifying changes to prevector's inline capacity.

The `CHECK_SCRIPT_STATIC_SIZE` and `CHECK_SCRIPT_DYNAMIC_SIZE` macros were added to differentiate the two cases - while preserving the correct source code line in case of failure.
2025-07-25 22:33:13 -07:00
Lőrinc 65ac7f6d4d refactor: modernize `CScriptBase` definition 2025-07-25 16:23:38 -07:00
Lőrinc 756da2a994 refactor: extract `STATIC_SIZE` constant to prevector
Co-authored-by: Anthony Towns <aj@erisian.com.au>
2025-07-25 16:23:37 -07:00
Sebastian Falbesoner 251d020846 init, wallet: replace hardcoded output types with `FormatAllOutputTypes` 2025-07-26 00:27:36 +02:00
woltx 60d1042b9a wallet: Remove unused `WalletFeature` enums 2025-07-25 14:49:47 -07:00
woltx 66de58208a wallet: Remove `CWallet::nWalletVersion` and related functions 2025-07-25 14:49:47 -07:00
Ava Chow 3b188b8b3d
Merge bitcoin/bitcoin#31576: test: Move `script_assets_tests` into its own suite
c40dbbbf77 test: Move `script_assets_tests` into its own suite (Hennadii Stepanov)

Pull request description:

  This PR ensures that the `script_assets_tests` test case is explicitly reported as "Skipped" when it is not run, making it clearer when running the test suite with `ctest`:

  - on the master branch @ 9355578a77978a0c2f189bd7315a2883142d8119:
  ```
  $ env -u DIR_UNIT_TEST_DATA ctest --test-dir build -j 16 -R "^script_"
  Internal ctest changing into directory: /home/hebasto/git/bitcoin/build
  Test project /home/hebasto/git/bitcoin/build
      Start 87: script_tests
      Start 83: script_p2sh_tests
      Start 85: script_segwit_tests
      Start 86: script_standard_tests
      Start 84: script_parse_tests
  1/5 Test #84: script_parse_tests ...............   Passed    0.11 sec
  2/5 Test #86: script_standard_tests ............   Passed    0.11 sec
  3/5 Test #85: script_segwit_tests ..............   Passed    0.12 sec
  4/5 Test #83: script_p2sh_tests ................   Passed    0.12 sec
  5/5 Test #87: script_tests .....................   Passed    0.36 sec

  100% tests passed, 0 tests failed out of 5

  Total Test time (real) =   0.37 sec
  ```
  - with this PR:
  ```
  $ env -u DIR_UNIT_TEST_DATA ctest --test-dir build -j 16 -R "^script_"
  Internal ctest changing into directory: /home/hebasto/git/bitcoin/build
  Test project /home/hebasto/git/bitcoin/build
      Start 83: script_assets_tests
      Start 88: script_tests
      Start 84: script_p2sh_tests
      Start 86: script_segwit_tests
      Start 87: script_standard_tests
      Start 85: script_parse_tests
  1/6 Test #85: script_parse_tests ...............   Passed    0.11 sec
  2/6 Test #83: script_assets_tests ..............***Skipped   0.12 sec
  3/6 Test #86: script_segwit_tests ..............   Passed    0.11 sec
  4/6 Test #87: script_standard_tests ............   Passed    0.11 sec
  5/6 Test #84: script_p2sh_tests ................   Passed    0.12 sec
  6/6 Test #88: script_tests .....................   Passed    0.36 sec

  100% tests passed, 0 tests failed out of 6

  Total Test time (real) =   0.37 sec

  The following tests did not run:
   83 - script_assets_tests (Skipped)
  $ env DIR_UNIT_TEST_DATA=/home/hebasto/git/bitcoin/qa-assets/unit_test_data ctest --test-dir build -j 16 -R "^script_"
  Internal ctest changing into directory: /home/hebasto/git/bitcoin/build
  Test project /home/hebasto/git/bitcoin/build
      Start 83: script_assets_tests
      Start 88: script_tests
      Start 84: script_p2sh_tests
      Start 86: script_segwit_tests
      Start 87: script_standard_tests
      Start 85: script_parse_tests
  1/6 Test #85: script_parse_tests ...............   Passed    0.11 sec
  2/6 Test #87: script_standard_tests ............   Passed    0.11 sec
  3/6 Test #86: script_segwit_tests ..............   Passed    0.11 sec
  4/6 Test #84: script_p2sh_tests ................   Passed    0.12 sec
  5/6 Test #88: script_tests .....................   Passed    0.35 sec
  6/6 Test #83: script_assets_tests ..............   Passed    1.58 sec

  100% tests passed, 0 tests failed out of 6

  Total Test time (real) =   1.58 sec
  ```

ACKs for top commit:
  maflcko:
    re-ACK c40dbbbf77 👈
  ajtowns:
    ACK c40dbbbf77
  achow101:
    ACK c40dbbbf77

Tree-SHA512: 25713e1c3b507b6f2a5fecc7b1ea285a6642b906c248769238a58fc0df48489ac5f7606778f9e3653b407b7f1d06563e1554d04321303b350c80eb888500cc5d
2025-07-25 14:48:14 -07:00
woltx 7cda3d0f5b wallet: Remove `IsFeatureSupported()` and `CanSupportFeature()` 2025-07-25 14:45:01 -07:00
woltx ba01585229 wallet: `MigrateToDescriptor` no longer calls `CanSupportFeature` 2025-07-25 14:10:32 -07:00
woltx 63acee2797 wallet: Remove `GetClosestWalletFeature()` 2025-07-25 14:10:32 -07:00
woltx e27da3150b wallet: Remove `GetVersion()` 2025-07-25 14:10:32 -07:00
Ava Chow 2e97541396
Merge bitcoin/bitcoin#32944: wallet: Remove `upgradewallet` RPC
d89c6fa4a7 wallet: Remove `upgradewallet` RPC (w0xlt)

Pull request description:

  Based on discussions  in https://github.com/bitcoin/bitcoin/pull/32803, this PR proposes removing the ` upgradewallet`  RPC.

ACKs for top commit:
  maflcko:
    review ACK d89c6fa4a7 🤙
  achow101:
    ACK d89c6fa4a7
  pablomartin4btc:
    ACK d89c6fa4a7
  brunoerg:
    Concept & light cr ACK d89c6fa4a7

Tree-SHA512: 9ab89c9137ff83d7826da6b9d00d3617149a5d144129086a2685ee525087534c5ed06259075c0689ded52d33e075acb5067d185be04ecc638e27469f958f9a56
2025-07-25 12:59:52 -07:00
Ava Chow b08041cac8
Merge bitcoin/bitcoin#32845: rpc, test: Fix JSON parsing errors in unloadwallet and getdescriptoractivity RPCs
c5c1960f93 doc: Add release notes for changes in RPCs (pablomartin4btc)
90fd5acbe5 rpc, test: Fix error message in getdescriptoractivity (pablomartin4btc)
39fef1d203 test: Add missing logging info for each test (pablomartin4btc)
53ac704efd rpc, test: Fix error message in unloadwallet (pablomartin4btc)
1fc3a8e8e7 rpc, test: Add EnsureUniqueWalletName tests (pablomartin4btc)
b635bc0896 rpc, util: Add EnsureUniqueWalletName (pablomartin4btc)

Pull request description:

  Currently, `unloadwallet` RPC call fails with a JSON parsing error when no `wallet_name` argument is provided. This behavior is misleading because the error originates from a low-level JSON type mismatch, rather than clearly indicating that the wallet name or RPC endpoint (`-rpcwallet=...`) is missing. Also, found out that the [issue](https://github.com/bitcoin/bitcoin/pull/13111#issuecomment-398831543) was noticed during its implementation but never addressed.

  In addition, I've verified all RPC commands calls finding that `getdescriptoractivity` had the same problem, but related to the array input types (blockhashes & descriptors), so I've corrected that RPC as well. For consistency I've added the missing logging info for each test case in `test/functional/rpc_getdescriptoractivity.py` in preparation for the new test.

  **_-Before_**
  ```
  ./build/bin/bitcoin-cli -regtest -datadir=/tmp/btc unloadwallet
  error code: -3
  error message:
  JSON value of type number is not of expected type string
  ```
  ```
  ./build/bin/bitcoin-cli -regtest -datadir=/tmp/btc getdescriptoractivity
  error code: -3
  error message:
  JSON value of type null is not of expected type array
  ```
  ```
  ./build/bin/bitcoin-cli -regtest -datadir=/tmp/btc getdescriptoractivity '[]'
  error code: -3
  error message:
  JSON value of type null is not of expected type array
  ```
  **_-After_**
  ```
  ./build/bin/bitcoin-cli -regtest -datadir=/tmp/btc unloadwallet
  error code: -8
  error message:
  Either the RPC endpoint wallet or the wallet name parameter must be provided
  ```
  ```
  ./build/bin/bitcoin-cli -regtest -datadir=/tmp/btc getdescriptoractivity
  error code: -1
  error message:
  getdescriptoractivity ["blockhash",...] [scanobjects,...] ( include_mempool )

  Get spend and receive activity associated with a set of descriptors for a set of blocks. This command pairs well with the `relevant_blocks` output of `scanblocks()`.
  This call may take several minutes. If you encounter timeouts, try specifying no RPC timeout (bitcoin-cli -rpcclienttimeout=0)

  Arguments:
  1. blockhashes                   (json array, required) The list of blockhashes to examine for activity. Order doesn't matter. Must be along main chain or an error is thrown.

       [
         "blockhash",              (string) A valid blockhash
         ...
       ]
  2. scanobjects                   (json array, required) Array of scan objects. Every scan object is either a string descriptor or an object:
       [
         "descriptor",             (string) An output descriptor
         {                         (json object) An object with output descriptor and metadata
           "desc": "str",          (string, required) An output descriptor
           "range": n or [n,n],    (numeric or array, optional, default=1000) The range of HD chain indexes to explore (either end or [begin,end])
         },
         ...
       ]
  3. include_mempool               (boolean, optional, default=true) Whether to include unconfirmed activity

  ...
  ```
  ```
  ./build/bin/bitcoin-cli -regtest -datadir=/tmp/btc getdescriptoractivity '[]'
  error code: -1
  error message:
  getdescriptoractivity ["blockhash",...] [scanobjects,...] ( include_mempool )

  ...
  ```

ACKs for top commit:
  achow101:
    ACK c5c1960f93
  stickies-v:
    re-ACK c5c1960f93
  furszy:
    ACK c5c1960f93

Tree-SHA512: e831ff1acbfd15d2ce3a69bb408cce94664c0b63b2aa2f4627a05c6c052241ae3b5cc238219ef1b30afb489a4a3f4c3030e2168b0c8f08b4d20805d050d810f5
2025-07-25 12:46:13 -07:00
Murch a3cf623364
test: Test max_selection_weight edge cases
Slays Mutant 37 from Bruno’s report:
https://gist.github.com/brunoerg/834063398d5002f738506d741513e310

diff --git a/src/wallet/coinselection.cpp b/muts/coinselection.mutant.37.cpp
index cee558088f..9747cd26c9 100644
--- a/src/wallet/coinselection.cpp
+++ b/muts/coinselection.mutant.37.cpp
@@ -128,7 +128,7 @@ util::Result<SelectionResult> SelectCoinsBnB(std::vector<OutputGroup>& utxo_pool
             curr_value > selection_target + cost_of_change || // Selected value is out of range, go back and try other branch
             (curr_waste > best_waste && is_feerate_high)) { // Don't select things which we know will be more wasteful if the waste is increasing
             backtrack = true;
-        } else if (curr_selection_weight > max_selection_weight) { // Selected UTXOs weight exceeds the maximum weight allowed, cannot find more solutions by adding more inputs
+        } else if (curr_selection_weight >= max_selection_weight) { // Selected UTXOs weight exceeds the maximum weight allowed, cannot find more solutions by adding more inputs
             max_tx_weight_exceeded = true; // at least one selection attempt exceeded the max weight
             backtrack = true;
         } else if (curr_value >= selection_target) {       // Selected value is within range
2025-07-25 11:08:44 -07:00
Murch 57fe8acc8a
test: Check max_weight_exceeded error
This slays the mutants 14 and 39 Bruno reported via
https://gist.github.com/brunoerg/834063398d5002f738506d741513e310,
that changing the intial or subsequent value of
`max_tx_weight_exceeded` in BnB would not fail any tests:

diff --git a/src/wallet/coinselection.cpp b/muts/coinselection.mutant.14.cpp
index cee558088f..947bf7b642 100644
--- a/src/wallet/coinselection.cpp
+++ b/muts/coinselection.mutant.14.cpp
@@ -118,7 +118,7 @@ util::Result<SelectionResult> SelectCoinsBnB(std::vector<OutputGroup>& utxo_pool
     CAmount best_waste = MAX_MONEY;

     bool is_feerate_high = utxo_pool.at(0).fee > utxo_pool.at(0).long_term_fee;
-    bool max_tx_weight_exceeded = false;
+    bool max_tx_weight_exceeded = true;

     // Depth First search loop for choosing the UTXOs
     for (size_t curr_try = 0, utxo_pool_index = 0; curr_try < TOTAL_TRIES; ++curr_try, ++utxo_pool_index) {

diff --git a/src/wallet/coinselection.cpp b/muts/coinselection.mutant.39.cpp
index cee558088f..bbfdc23889 100644
--- a/src/wallet/coinselection.cpp
+++ b/muts/coinselection.mutant.39.cpp
@@ -129,7 +129,7 @@ util::Result<SelectionResult> SelectCoinsBnB(std::vector<OutputGroup>& utxo_pool
             (curr_waste > best_waste && is_feerate_high)) { // Don't select things which we know will be more wasteful if the waste is increasing
             backtrack = true;
         } else if (curr_selection_weight > max_selection_weight) { // Selected UTXOs weight exceeds the maximum weight allowed, cannot find more solutions by adding more inputs
-            max_tx_weight_exceeded = true; // at least one selection attempt exceeded the max weight
+            max_tx_weight_exceeded = false; // at least one selection attempt exceeded the max weight
             backtrack = true;
         } else if (curr_value >= selection_target) {       // Selected value is within range
             curr_waste += (curr_value - selection_target); // This is the excess value which is added to the waste for the below comparison
2025-07-25 11:08:06 -07:00
Sebastian Falbesoner e3ba0757a9 rpc, wallet: replace remaining hardcoded output types with `FormatAllOutputTypes`
This commit takes use of the `FormatAllOutputTypes` helper
(introduced in PR #32432, commit 8cc9845b8d)
to get rid of the hardcoded output types in wallet RPC documentation.
Note that it can't be used in the `createmultisig` RPC, as this one is
only for pre-taproot output types and hence doesn't contain "bech32m" in the list.
2025-07-25 18:49:54 +02:00
merge-script fc162299f0
Merge bitcoin/bitcoin#32994: p2p: rename GetAddresses -> GetAddressesUnsafe
1cb2399703 doc: clarify the GetAddresses/GetAddressesUnsafe documentation (Daniela Brozzoni)
e5a7dfd79f p2p: rename GetAddresses -> GetAddressesUnsafe (Daniela Brozzoni)

Pull request description:

  Rename GetAddresses to GetAddressesUnsafe to make it clearer that this function should only be used in trusted contexts. This helps avoid accidental privacy leaks by preventing the uncached version from being used in non-trusted scenarios, like P2P.

  Additionally, better reflect in the documentation that the two methods should be used in different contexts.
  Also update the outdated "call the function without a parameter" phrasing in the cached version. This wording was accurate when the cache was introduced in #18991, but became outdated after later commits (f26502e9fc, 81b00f8780) added parameters to each
  function, and the previous commit changed the function naming completely.

ACKs for top commit:
  stickies-v:
    re-ACK 1cb2399703
  l0rinc:
    ACK 1cb2399703
  luisschwab:
    ACK 1cb2399703
  brunoerg:
    ACK 1cb2399703
  theStack:
    Code-review ACK 1cb2399703
  mzumsande:
    Code review ACK 1cb2399703

Tree-SHA512: 02c05d88436abcdfabad994f47ec5144e9ba47668667a2c1818f57bf8710727505faf8426fd0672c63de14fcf20b96f17cea2acc39fe3c1f56abbc2b1a9e9c23
2025-07-25 16:15:50 +01:00
merge-script 633d8ea17b
Merge bitcoin/bitcoin#32970: ci: Enable more shellcheck
fa1fd07468 ci: Enable more shellcheck (MarcoFalke)

Pull request description:

  shellcheck is often the main "reviewer" of CI code written in Bash, so it seems odd to disable it by putting commands into `bash -c "cmd..."`.

  Fix that by removing `bash -c`, where it isn't intended and where the removal is easily possible.

ACKs for top commit:
  hebasto:
    ACK fa1fd07468.

Tree-SHA512: 6412dd3f8d702bca7762a8f1be3f9d2782132936fcc7ae5c31690b594e04f69708110e6f6233d5a61901289d13c7089ab5646a2c3ef2266fffc36d0543f4b7ae
2025-07-25 15:35:47 +01:00
MarcoFalke faa1c3e80d
Revert "Merge bitcoin/bitcoin#32343: common: Close non-std fds before exec in RunCommandJSON"
This reverts commit 31d3eebfb9, reversing
changes made to 4b26ca0e2f.
2025-07-25 15:30:42 +02:00
merge-script 6cdc5a90cf
Merge bitcoin/bitcoin#32967: log: [refactor] Use info level for init logs
face8123fd log: [refactor] Use info level for init logs (MarcoFalke)
fa183761cb log: Remove function name from init logs (MarcoFalke)

Pull request description:

  Many of the normal, and expected init logs, which are run once after startup use the deprecated alias of `LogInfo`.

  Fix that by using `LogInfo` directly, which is a refactor, except for a few log lines that also have `__func__` removed.

  (Also remove the unused trailing `\n` char while touching those logs)

ACKs for top commit:
  stickies-v:
    re-ACK face8123fd
  fanquake:
    ACK face8123fd

Tree-SHA512: 28c296129c9a31dff04f529c53db75057eae8a73fc7419e2f3068963dbb7b7fb9a457b2653f9120361fdb06ac97d1ee2be815c09ac659780dff01d7cd29f8480
2025-07-25 12:04:44 +01:00
merge-script 443c32a3e6
Merge bitcoin/bitcoin#32822: fuzz: Make process_message(s) more deterministic
fa1a14a13a fuzz: Reset chainman state in process_message(s) targets (MarcoFalke)
fa9a3de09b fuzz: DisableNextWrite (MarcoFalke)
aeeeeec9f7 fuzz: Reset dirty connman state in process_message(s) targets (MarcoFalke)
fa11eea405 fuzz: Avoid non-determinism in process_message(s) target (PeerMan) (MarcoFalke)

Pull request description:

  `process_message(s)` are the least stable fuzz targets, according to OSS-Fuzz.

  Tracking issue: https://github.com/bitcoin/bitcoin/issues/29018.

  ### Testing

  Needs coverage compilation, as explained in `./contrib/devtools/README.md`. And then, using 32 threads:

  ```
  cargo run --manifest-path ./contrib/devtools/deterministic-fuzz-coverage/Cargo.toml -- $PWD/bld-cmake/ $PWD/../b-c-qa-assets/fuzz_corpora/ process_messages 32
  ```

  Each commit can be reverted to see more non-determinism re-appear.

ACKs for top commit:
  marcofleon:
    ReACK fa1a14a13a
  dergoegge:
    reACK fa1a14a13a

Tree-SHA512: 37b5b6dbdde6a39b4f83dc31e92cffb4a62a4b8f5befbf17029d943d0b2fd506f4a0833570dcdbf79a90b42af9caca44e98e838b03213d6bc1c3ecb70a6bb135
2025-07-25 10:15:07 +01:00
MarcoFalke face8123fd
log: [refactor] Use info level for init logs
This refactor does not change behavior.
2025-07-25 09:50:50 +02:00
MarcoFalke fa183761cb
log: Remove function name from init logs
It is redundant with -logsourcelocations and the log messages are
clearer without it.

Also, remove a double-space.

Also, add braces around `if` touched in the next commit.

This tiny behavior change requires a test fixup.
2025-07-25 09:50:24 +02:00
merge-script 5ad79b2035
Merge bitcoin/bitcoin#32593: wallet, rpc: Move (Un)LockCoin WalletBatch creation out of RPC
6135e0553e wallet, rpc: Move (Un)LockCoin WalletBatch creation out of RPC (Ava Chow)

Pull request description:

  If the locked coin needs to be persisted to the wallet database, insteead of having the RPC figure out when to create a WalletBatch and having LockCoin's behavior depend on it, have LockCoin take whether to persist as a parameter so it makes the batch.

  Since unlocking a persisted locked coin requires a database write as well, we need to track whether the locked coin was persisted to the wallet database so that it can erase the locked coin when necessary.

  Keeping track of whether a locked coin was persisted is also useful information for future PRs.

  Split from #32489

ACKs for top commit:
  rkrux:
    ACK 6135e05
  Sjors:
    ACK 6135e0553e
  w0xlt:
    ACK 6135e0553e

Tree-SHA512: 0e2367fc4d50c62ec41443374b64c4c5ecf679998677df47fb8776cfb44704713bc45547e32e96cd30d1dbed766f5d333efb6f10eb0e71271606638e07e61a01
2025-07-24 13:38:58 -04:00
glozow ea17a9423f [doc] release note for relaxing requirement of all unconfirmed parents present 2025-07-24 09:44:49 -04:00
Greg Sanders 12f48d5ed3 test: add chained 1p1c propagation test 2025-07-24 09:44:49 -04:00
glozow 525be56741 [unit test] package submission 2p1c with 1 parent missing 2025-07-24 09:44:49 -04:00
glozow f24771af05 relax child-with-unconfirmed-parents rule
This rule was originally introduced along with a very early proposal for
package relay as a way to verify that the "correct"
child-with-unconfirmed-parents package was provided for a transaction,
where correctness was defined as all of the transactions unconfirmed
parents. However, we are not planning to introduce a protocol where
peers would be asked to send these packages.

This rule has downsides: if a transaction has multiple parents but only
1 that requires package CPFP to be accepted, the current rule prevents
us from accepting that package. Even if the other parents are already in
mempool, the p2p logic will only submit the 1p1c package, which fails
this check. See the test in p2p_1p1c_network.py
2025-07-24 09:44:48 -04:00
merge-script e17fb86382
Merge bitcoin/bitcoin#32888: ci: Use optimized Debug build type in test-each-commit
faa3171ff2 ci: Use optimized Debug build type in test-each-commit (MarcoFalke)
fa21c3401e ci: [doc] reword debug log message (MarcoFalke)

Pull request description:

  An optimized debug build is mostly as fast as a release build, because hot loops of heavy debug-only code are rare. So use that setting in the test-each-commit CI, to enable more checks almost "for free".

ACKs for top commit:
  Prabhat1308:
    re-ACK [`faa3171`](faa3171ff2)
  willcl-ark:
    crACK faa3171ff2

Tree-SHA512: ca041cf7f79d7abb6f93e17b58b2aea730f3bb9fc51256c1ca1b9f7ce7e7188d18fd99d3754cdbe3f504f4e08d560e72d4b7a75409c214ee2c3771c9a8ba7f96
2025-07-24 12:45:05 +01:00
merge-script fd3d80c209
Merge bitcoin/bitcoin#33047: test: check proper OP_2ROT behavior
b94c6356a2 test: check proper OP_2ROT behavior (brunoerg)

Pull request description:

  According to corecheck, the following mutant is not caught by any test (https://corecheck.dev/mutation/src/script/interpreter.cpp).

  ```diff
  diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
  index 61ea7f4503..4f6fa34836 100644
  --- a/src/script/interpreter.cpp
  +++ b/src/script/interpreter.cpp
  @@ -746,7 +746,6 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript&
                           return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION);
                       valtype vch1 = stacktop(-6);
                       valtype vch2 = stacktop(-5);
  -                    stack.erase(stack.end()-6, stack.end()-4);
                       stack.push_back(vch1);
                       stack.push_back(vch2);
                   }
  ```

  It means we're not testing the behavior of the OP_2ROT opcode properly. The normal behavior is: `[1, 2, 3, 4, 5, 6] → OP_2ROT → [3, 4, 5, 6, 1, 2]` (6 elements). However, by deleting the `erase`, it becomes: `[1, 2, 3, 4, 5, 6] → OP_2ROT → [1, 2, 3, 4, 5, 6, 1, 2] (8 elements)` which is obviously wrong. In `script_tests.json`, we have some test cases that includes the OP_2ROT which correctly tests the move part of 2ROT but not the erase one. See:

  ```
  ["25 24 23 22 21 20", "2ROT 24 EQUAL", "P2SH,STRICTENC", "OK"],
  ["25 24 23 22 21 20", "2ROT DROP 25 EQUAL", "P2SH,STRICTENC", "OK"],
  ["25 24 23 22 21 20", "2ROT 2DROP 20 EQUAL", "P2SH,STRICTENC", "OK"],
  ["25 24 23 22 21 20", "2ROT 2DROP DROP 21 EQUAL", "P2SH,STRICTENC", "OK"],
  ["25 24 23 22 21 20", "2ROT 2DROP 2DROP 22 EQUAL", "P2SH,STRICTENC", "OK"],
  ["25 24 23 22 21 20", "2ROT 2DROP 2DROP DROP 23 EQUAL", "P2SH,STRICTENC", "OK"],
  ["25 24 23 22 21 20", "2ROT 2ROT 22 EQUAL", "P2SH,STRICTENC", "OK"],
  ["25 24 23 22 21 20", "2ROT 2ROT 2ROT 20 EQUAL", "P2SH,STRICTENC", "OK"],
  ```

  That said, this PR adds one more test case to the case mentioned.

ACKs for top commit:
  maflcko:
    lgtm ACK b94c6356a2
  l0rinc:
    ACK b94c6356a2
  w0xlt:
    ACK b94c6356a2

Tree-SHA512: 077d83faedcf444b9489928e1601c96bee91ee5c793a494e7e6fa34eabd216ab8706b5fed3d979fba910bd39f3f917c8562380e79cd35d6b7487ad68ca409d5f
2025-07-24 12:24:19 +01:00
merge-script 1119ac51f0
Merge bitcoin/bitcoin#33040: doc: update headers and remove manual TOCs
ca38cf701d doc: fix a few obvious typos in the affected files (Lőrinc)
ddab466e0d doc: remove manual TOCs (Lőrinc)
26a3730711 doc: unify `developer-notes` and `productivity` header styles (Lőrinc)

Pull request description:

  The table of contents of our markdown documents weren't always adjusted when corresponding entries were added/removed e.g.
  * `Ignoring IDE/editor files`: faf65f0531 (diff-5e319039d67254bed6ca82562ec5f560f102004aa4806e4ca77f5d0065c65fbbL788-L802)
  * `Shebang`: 7777fb8bc7 (diff-5e319039d67254bed6ca82562ec5f560f102004aa4806e4ca77f5d0065c65fbbL1128-L1144)
  * `Wallet`: fa69c5b170 (diff-5e319039d67254bed6ca82562ec5f560f102004aa4806e4ca77f5d0065c65fbbL882-L885)
  * `Fetch and update PRs individually` 45b1d39757 (diff-fb3fb3681e7dbfc61c47a7d1f890941b8c886cd46fc06cf7839a03a68dc2aa02R188-R200)
  * `External libmultiprocess installation` 9ccee9cd02 (diff-41e578ab9c8df11d4143597ad73dbe7be92dba4521a5d17c074b79aad1776ee4R38-R40)

  Since GitHub generates these automatically, it suffices if we unify the header styles instead and delete the manual TOC sections.

ACKs for top commit:
  maflcko:
    lgtm ACK ca38cf701d 🌔
  janb84:
    ACK ca38cf701d
  yuvicc:
    re-ACK ca38cf701d

Tree-SHA512: a2edcae9a1c4fa9b910dc1cf43f4461f1d79016949b5b4a93fb204ffd735dc2de884785e9796dc084a9852419047a438784a8eec2c38d7e1573a494d81a77494
2025-07-24 12:06:54 +01:00
merge-script e2f2df0ead
Merge bitcoin/bitcoin#32984: wallet: Set migrated wallet name only on success
060695c22a test: Failed load after migrate should restore backup (MarcoFalke)
8a4cfddf23 wallet: Set migrated wallet name only on success (Ava Chow)

Pull request description:

  After a wallet is migrated and we are trying to load it, if it could not be loaded, don't try to set the wallet name. Otherwise we have a segfault.

  This can be tested by migrated a legacy wallet from another network (e.g. trying to migrate a testnet wallet on mainnet). The fixed behavior is return an error and restore the backup.

ACKs for top commit:
  davidgumberg:
    ACK 060695c22a
  furszy:
    ACK 060695c22a
  rkrux:
    ACK 060695c22a
  w0xlt:
    reACK 060695c22a
  pablomartin4btc:
    ACK 060695c22a

Tree-SHA512: f4289e0b3dedef0a3d734c18604f2fd0df0dc65e9641bc342cfa45088d2540a3f6631bbea8bdd394b2631fa83b38e8ac37c83cfc4b53b19dcbd0b820a9beb6e4
2025-07-24 12:00:52 +01:00
merge-script 16f7b43b68
Merge bitcoin/bitcoin#33049: doc: Fix typos in asmap README
b59dc21847 doc: Fix typos in asmap README (nervana21)

Pull request description:

  This minor PR fixes some spelling mistakes found while reviewing #33026.

ACKs for top commit:
  fanquake:
    ACK b59dc21847

Tree-SHA512: e76f7f97c10f3e506d024da0cbf804f4975cf07f31f0dd0abad6fcb97a5fa1032087459dba46de3715f6275d47e2fde4d8db3d38341540110d87fd5669855359
2025-07-24 11:10:23 +01:00
nervana21 b59dc21847
doc: Fix typos in asmap README 2025-07-24 01:24:42 -04:00
Lőrinc ca38cf701d doc: fix a few obvious typos in the affected files 2025-07-23 22:00:40 -07:00
Lőrinc ddab466e0d doc: remove manual TOCs 2025-07-23 21:31:35 -07:00
Lőrinc 26a3730711 doc: unify `developer-notes` and `productivity` header styles 2025-07-23 21:31:06 -07:00
Ava Chow eb13718448
Merge bitcoin/bitcoin#31179: RPC: Add reserve member function to `UniValue` and use it in `blockToJSON` function
5d82d92aff rpc: reserve space for `UniValue` variables  in `blockToJSON` (ismaelsadeeq)
6a506d5c37 UniValue: add reserve member function (ismaelsadeeq)
bd461195f4 bench: support benching all verbosity of `BlockToJson` (ismaelsadeeq)

Pull request description:

  This PR is motivated by https://github.com/bitcoin/bitcoin/issues/30495#issuecomment-2444881418,
  It adds a `reserve` member function to `UniValue` and applies it within the `blockToJSON` function to pre-allocate memory, minimizing reallocation's.

  <details>
  <summary>Slight performance increase in verbosity 1</summary>

  On **master**:

  |         ns/op |        op/s |  err% | total | benchmark              |
  |--------------:|------------:|------:|------:|:------------------------|
  |      190,342  |     5,254   |  2.3% |  0.01 | `BlockToJsonVerbose1`   |
  |  34,812,292   |       28.73 |  1.0% |  0.38 | `BlockToJsonVerbose2`   |
  |  34,457,167   |       29.02 |  1.0% |  0.38 | `BlockToJsonVerbose3`   |

  On **this PR**:

  |         ns/op |        op/s |  err% | total | benchmark              |
  |--------------:|------------:|------:|------:|:------------------------|
  |      172,278  |     5,805   |  0.7% |  0.01 | `BlockToJsonVerbose1`   |
  |  33,720,584   |       29.66 |  0.4% |  0.37 | `BlockToJsonVerbose2`   |
  |  33,884,417   |       29.51 |  1.2% |  0.38 | `BlockToJsonVerbose3`   |
  </details>

ACKs for top commit:
  maflcko:
    review ACK 5d82d92aff 🐀
  l0rinc:
    ACK 5d82d92aff
  achow101:
    ACK 5d82d92aff
  Eunovo:
    Re-ACK 5d82d92aff

Tree-SHA512: bdd2c1bcdc4d060d30ad3be0b10f0d722dda0c2286bc4156af851503220e8854e76a4dc53456826b543c110982455268838172d3a1026eee754d4c673b48ea05
2025-07-23 13:29:07 -07:00
Lőrinc 86e3a0a8cb refactor: standardize obfuscation memory alignment
See:
* https://github.com/bitcoin/bitcoin/pull/31144#discussion_r2216962117
* https://github.com/bitcoin/bitcoin/pull/31144#discussion_r2220277161
* https://github.com/bitcoin/bitcoin/pull/31144#discussion_r2210851772

Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
2025-07-23 12:56:48 -07:00
Lőrinc 13f00345c0 refactor: write `Obfuscation` object when new key is generated in dbwrapper
See:
* https://github.com/bitcoin/bitcoin/pull/31144#discussion_r2215720251
* https://github.com/bitcoin/bitcoin/pull/31144#discussion_r2223539466

Co-authored-by: maflcko <6399679+maflcko@users.noreply.github.com>
Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2025-07-23 12:56:15 -07:00
glozow eb65f57f31 [test] setmocktime instead of waiting in 1p1c tests
Significantly speed up the runtime of the test.
2025-07-23 15:15:06 -04:00
glozow 70772dd469 [test] cut the number of transactions involved in 1p1c DoS tests
We just need enough transactions to push us above the orphanage limits
and trigger trimming. Reducing the number of transactions cuts the
runtime of this test significantly.
2025-07-23 15:14:47 -04:00
brunoerg b94c6356a2 test: check proper OP_2ROT behavior 2025-07-23 13:52:17 -03:00
merge-script 73e754bd01
Merge bitcoin/bitcoin#33001: test: Do not pass tests on unhandled exceptions
faa3e68411 test: Log KeyboardInterrupt as exception (MarcoFalke)
fa30b34026 test: Do not pass tests on unhandled exceptions (MarcoFalke)

Pull request description:

  Currently the functional tests are problematic, because they pass, even if they encounter an unhanded exception.

  Fix this by handling all exceptions: Catch `BaseException` as fallback and mark it as failure.

  Can be tested via:

  ```diff
  diff --git a/test/functional/wallet_disable.py b/test/functional/wallet_disable.py
  index da6e5d408f..ecc41fb041 100755
  --- a/test/functional/wallet_disable.py
  +++ b/test/functional/wallet_disable.py
  @@ -19,6 +19,7 @@ class DisableWalletTest (BitcoinTestFramework):
           self.wallet_names = []

       def run_test (self):
  +        import sys;sys.exit("fatal error")
           # Make sure wallet is really disabled
           assert_raises_rpc_error(-32601, 'Method not found', self.nodes[0].getwalletinfo)
           x = self.nodes[0].validateaddress('3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy')
  ```

  Previously, the test would pass. With this patch, it would fail.

ACKs for top commit:
  enirox001:
    Looks good to me—ACK faa3e68
  stickies-v:
    re-ACK faa3e68411
  pablomartin4btc:
    tACK faa3e68411

Tree-SHA512: 11ecd5201982e2c776e48d98834b17c15a415306a95524bc702daeba20a316aac797748e9592be8db575597804f149ee7ef104416037cc9e5891758625810e2d
2025-07-23 16:44:41 +01:00
marcofleon a9819b0e9d refactor: Change `FindTxForGetData` to take GenTxid instead of CInv
Addresses
https://github.com/bitcoin/bitcoin/pull/32631#discussion_r2200291621
from #32631
2025-07-23 15:01:43 +01:00
marcofleon d588575ed1 refactor: miscellaneous GenTxid followups
Addresses a few comments from #32631:
https://github.com/bitcoin/bitcoin/pull/32631#discussion_r2199951996
https://github.com/bitcoin/bitcoin/pull/32631#discussion_r2201874252
https://github.com/bitcoin/bitcoin/pull/32631#discussion_r2201918072
2025-07-23 15:01:18 +01:00
merge-script cfb859e82e
Merge bitcoin/bitcoin#33037: doc: Add release notes for 32521 (MAX_TX_LEGACY_SIGOPS)
faa2f3b1af doc: Add release notes for 32521 (MAX_TX_LEGACY_SIGOPS) (MarcoFalke)

Pull request description:

  ref https://github.com/bitcoin/bitcoin/pull/32521

ACKs for top commit:
  Sjors:
    ACK faa2f3b1af

Tree-SHA512: 58694545eca38cd4391d2ce6ddb9f4785c19af3df639da9d17fa1ade5d56369723e0e7fece71b50e2186a65aa55919c8f64ae12833d676e07b448e0cfc53ce3c
2025-07-23 10:50:02 +01:00
merge-script afd3b34dc5
Merge bitcoin/bitcoin#33004: Enable `-natpmp` by default
b2d07f872c Add release notes for -natpmp enabled by default (Antoine Poinsot)
3fc660d267 mapport: turn -natpmp to on by default (Antoine Poinsot)

Pull request description:

  This turns the default for NAT hole-punching (with [PCP](https://en.wikipedia.org/wiki/Port_Control_Protocol) or [NAT-PMP](https://en.wikipedia.org/wiki/NAT_Port_Mapping_Protocol)) to on. Closes #31663.

ACKs for top commit:
  ajtowns:
    ACK b2d07f872c

Tree-SHA512: 7449510aa97ce225a662947184046cba6c8f0409719cd0b279639cedd8fdbf55a769a0088e66c7ac5b6ebabec9b2c81141ae14b7a87a5ad13be01d36c4e56661
2025-07-23 09:57:05 +01:00
merge-script 49bbf9ff28
Merge bitcoin/bitcoin#33036: Update secp256k1 subtree to latest master
5600e6fc4b Squashed 'src/secp256k1/' changes from 4187a46649..b9313c6e1a (fanquake)

Pull request description:

  Updates the subtree to b9313c6e1a. See https://github.com/bitcoin-core/secp256k1/blob/master/CHANGELOG.md#070---2025-07-21 for the most relevant changes.

ACKs for top commit:
  theStack:
    ACK 336b8be37b
  stickies-v:
    ACK 336b8be37b

Tree-SHA512: 8494850b979e3d27c98d89f8bac75c8a1180184adf134b1f2ba009bd21877836855f50d074535f06e2e0e62636464eaa926db82f1fb4d5f252a8804d6ba70c87
2025-07-23 09:45:50 +01:00
pablomartin4btc c5c1960f93 doc: Add release notes for changes in RPCs
Adding notes for both `unloadwallet` and `getdescriptoractivity`.
2025-07-22 23:25:14 -03:00
pablomartin4btc 90fd5acbe5 rpc, test: Fix error message in getdescriptoractivity
Mark blockhashes and scanobjects arguments as required, so the user receives
a clear help message when either is missing.

Added a new functional test for this use case.

Co-authored-by: stickies-v <stickies-v@users.noreply.github.com>
2025-07-22 23:23:23 -03:00
pablomartin4btc 39fef1d203 test: Add missing logging info for each test
Add self.log.info(...) calls at the beginning of each test
in GetBlocksActivityTest.

This improves readability and provides debugging information
by logging the purpose of each test upon its correct
execution.

This is in preparation for the next commit, which adds a new test
with log info, and it would look inconsistent without this commit.
2025-07-22 23:12:10 -03:00
pablomartin4btc 53ac704efd rpc, test: Fix error message in unloadwallet
The unloadwallet RPC previously failed with a low-level JSON parsing error
when called without any arguments (wallet_name).

Although this issue was first identified during review of the original unloadwallet
implementation in #13111, it was never addressed.

Raise RPC_INVALID_PARAMETER instead describing that either the RPC endpoint or wallet
name must be provided.

Adding a new functional test for this use case.

Refactor migratewallet to use the same logic as the wallet_name argument handling
is identical.

Co-authored-by:  maflcko <maflcko@users.noreply.github.com>
2025-07-22 23:12:09 -03:00
pablomartin4btc 1fc3a8e8e7 rpc, test: Add EnsureUniqueWalletName tests
Co-authored-by: stickies-v <stickies-v@users.noreply.github.com>
2025-07-22 23:12:04 -03:00
Ava Chow 900bb53905
Merge bitcoin/bitcoin#32990: wallet: remove outdated `pszSkip` arg of database `Rewrite` func
2dfeb6668c wallet: remove outdated `pszSkip` arg of database `Rewrite` func (rkrux)

Pull request description:

  This argument might have been used in the legacy wallets, but I don't see any implementation using this argument in the SQLite wallets. Removing it cleans up the code a bit.

ACKs for top commit:
  achow101:
    ACK 2dfeb6668c
  brunoerg:
    code review ACK 2dfeb6668c

Tree-SHA512: de2178ad6862125f084434ec6a7271d567544870c474c5ea2e75a4f69f3f5eb2170ff46947e098f58e1fa47c35bbe4ebafcd8180581d1f100f1f8d177b32dd91
2025-07-22 16:41:18 -07:00
Ava Chow c8ec423719
Merge bitcoin/bitcoin#33020: test: delete commented-out tests and add a test case in wallet_signer
da318fe53f test: delete commented out tests (naiyoma)
6d80e999a0 test: external signer returns invalid JSON response (naiyoma)

Pull request description:

  I noticed that some test cases had been commented out in wallet_signer.py.
  This PR uncomments and modifies some of those test cases so that they can pass.

  dac74c6949 -> deleting this assertion since multiple signers is being tested here https://github.com/bitcoin/bitcoin/blob/master/test/functional/wallet_signer.py#L273

  1707c90566 test when  an external signer returns malformed or invalid JSON, which would trigger this error:
  → https://github.com/bitcoin/bitcoin/blob/master/src/common/run_command.cpp#L42

  b96156821e test  importdescriptors with external signer

ACKs for top commit:
  Sjors:
    ACK da318fe53f
  achow101:
    ACK da318fe53f
  theStack:
    ACK da318fe53f

Tree-SHA512: 6416f83abed1923d72a8a83c5937e8f732e02b5396b5bd3fe868d28e8f3cb2bf55f3bcbc2ec8219302b55045fa1d9e7ce119b4e8bdea2df2103fede9f109eacf
2025-07-22 15:48:59 -07:00
Ava Chow 09f004bd9f
Merge bitcoin/bitcoin#32945: tests: speed up coins_tests by parallelizing
06ab3a394a tests: speed up coins_tests by parallelizing (Anthony Towns)

Pull request description:

  Updates the cmake logic to generate a separate test for each BOOST_FIXTURE_TEST_SUITE declaration in a file, and splits coins_tests.cpp into three separate suites so that they can be run in parallel. Also updates the convention enforced by test/lint/lint-tests.py.

ACKs for top commit:
  l0rinc:
    reACK 06ab3a394a
  maflcko:
    lgtm ACK 06ab3a394a
  achow101:
    ACK 06ab3a394a

Tree-SHA512: 940d9aa31dab60d1000b5f57d8dc4b2c5b4045c7e5c979ac407aba39f2285d53bc00c5e4d7bf2247551fd7e1c8681144e11fc8c005a874282c4c59bd362fb467
2025-07-22 11:19:18 -07:00
Ava Chow 5d98fc7559
Merge bitcoin/bitcoin#33030: test: check tx is final when there is no locktime
065e42976a test: IsFinalTx returns true when there is no locktime (brunoerg)

Pull request description:

  According to https://corecheck.dev/mutation/src/consensus/tx_verify.cpp, there is no proper test for the `tx.nLockTime == 0` check in the `IsFinalTx` function, which is understandable, since this check will only be useful for a specific case where the `nBlockHeight` (block height) is zero. Otherwise, the following check `if ((int64_t)tx.nLockTime < ((int64_t)tx.nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime))` would catch any of it. This PR adds a test case for it.

ACKs for top commit:
  maflcko:
    lgtm ACK 065e42976a
  enirox001:
    ACK 065e429: Valuable test case that explicitly demonstrates `IsFinalTx` behavior when nLockTime is 0
  achow101:
    ACK 065e42976a
  darosior:
    utACK 065e42976a

Tree-SHA512: e44a7c060bd4c3d746fab166442cadc3fd449ddd8b02cabf22024a5dde6f438f24c6e1bff2a6dc49b57c8e01234aa0fd393fbfe6194df9d9b6c3d4fa2655c99b
2025-07-22 11:07:45 -07:00
Lőrinc e5b1b7c557 refactor: rename `OBFUSCATION_KEY_KEY`
See: https://github.com/bitcoin/bitcoin/pull/31144#discussion_r2216425882

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2025-07-22 10:26:15 -07:00
Lőrinc 298bf95105 refactor: simplify `Obfuscation::HexKey`
See: https://github.com/bitcoin/bitcoin/pull/31144#discussion_r2215746554

Co-authored-by: maflcko <6399679+maflcko@users.noreply.github.com>
2025-07-22 10:26:15 -07:00
Lőrinc 2dea045425 test: make `obfuscation_serialize` more thorough
See: https://github.com/bitcoin/bitcoin/pull/31144#discussion_r2216849672

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2025-07-22 10:26:15 -07:00
Lőrinc a17d8202c3 test: merge xor_roundtrip_random_chunks and xor_bytes_reference
Instead of a separate roundtrip test and a simplified xor reference test, we can merge the two and provide the same coverage

See: https://github.com/bitcoin/bitcoin/pull/31144#discussion_r2211205949

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2025-07-22 10:24:13 -07:00
pablomartin4btc b635bc0896 rpc, util: Add EnsureUniqueWalletName
Add a new function called EnsureUniqueWalletNamet that returns the
selected wallet name across the RPC request endpoint and wallet_name.

Supports the case where the wallet_name argument may be omitted—either
when using a wallet endpoint, or when not provided at all. In the latter
case, if no wallet endpoint is used, an error is raised.

Internally reuses the existing implementation to avoid redundant URL
decoding and logic duplication.

This is a preparatory change for upcoming refactoring of unloadwallet
and migratewallet, which will adopt EnsureUniqueWalletName for improved
clarity and consistency.
2025-07-22 12:28:10 -03:00
naiyoma da318fe53f test: delete commented out tests 2025-07-22 16:16:50 +03:00
naiyoma 6d80e999a0 test: external signer returns invalid JSON response 2025-07-22 16:09:24 +03:00
brunoerg 065e42976a test: IsFinalTx returns true when there is no locktime 2025-07-22 10:03:07 -03:00
Daniela Brozzoni 1cb2399703
doc: clarify the GetAddresses/GetAddressesUnsafe documentation
Better reflect in the documentation that the two methods should be
used in different contexts.
Also update the outdated "call the function without a parameter" phrasing
in the cached version. This wording was accurate when the cache was
introduced in #18991, but became outdated after later commits
(f26502e9fc,
81b00f8780) added parameters to each
function, and the previous commit changed the function naming completely.

Co-Authored-By: stickies-v <stickies-v@protonmail.com>
2025-07-22 14:29:37 +02:00
Daniela Brozzoni e5a7dfd79f
p2p: rename GetAddresses -> GetAddressesUnsafe
Rename GetAddresses to GetAddressesUnsafe to make it clearer that this
function should only be used in trusted contexts. This helps avoid
accidental privacy leaks by preventing the uncached version from being
used in non-trusted scenarios, like P2P.
2025-07-22 14:29:36 +02:00
MarcoFalke faa2f3b1af
doc: Add release notes for 32521 (MAX_TX_LEGACY_SIGOPS) 2025-07-22 12:10:48 +02:00
fanquake 336b8be37b
Update secp256k1 subtree to latest master 2025-07-22 09:35:01 +01:00
fanquake 5600e6fc4b Squashed 'src/secp256k1/' changes from 4187a46649..b9313c6e1a
b9313c6e1a Merge bitcoin-core/secp256k1#1708: release cleanup: bump version after 0.7.0
a660a4976e Merge bitcoin-core/secp256k1#1707: release: Prepare for 0.7.0
7ab8b0cc01 release cleanup: bump version after 0.7.0
a3e742d947 release: Prepare for 0.7.0
f67b0ac1a0 ci: Don't hardcode ABI version
020ee60495 Merge bitcoin-core/secp256k1#1706: musig/tests: initialize keypair
cde4130898 musig/tests: initialize keypair
6037833c9e Merge bitcoin-core/secp256k1#1702: changelog: update
40b4a06520 changelog: update
5e74086dc8 Merge bitcoin-core/secp256k1#1705: musig/test: Remove dead code
7c3380423c Merge bitcoin-core/secp256k1#1696: build: Refactor visibility logic and add override
8d967a602b musig/test: Remove dead code
983711cd6d musig/tests: Refactor vectors_signverify
73a695958a Merge bitcoin-core/secp256k1#1704: cmake: Make `secp256k1_objs` inherit interface defines from `secp256k1`
bf082221ff cmake: Make `secp256k1_objs` inherit interface defines from `secp256k1`
c82d84bb86 build: add CMake option for disabling symbol visibility attributes
ce7923874f build: Add SECP256K1_NO_API_VISIBILITY_ATTRIBUTES
e5297f6d79 build: Refactor visibility logic
cbbbf3bd6e Merge bitcoin-core/secp256k1#1699: ci: enable musig module for native macOS arm64 job
943479a7a3 Merge bitcoin-core/secp256k1#1694: Revert "cmake: configure libsecp256k1.pc during install"
3352f9d667 ci: enable musig module for native macOS arm64 job
ad60ef7ea7 Merge bitcoin-core/secp256k1#1689: ci: Convert `arm64` Cirrus tasks to GHA jobs
c498779096 Merge bitcoin-core/secp256k1#1687: cmake: support the use of launchers in ctest -S scripts
44b205e9ee Revert "cmake: configure libsecp256k1.pc during install"
0dfe387dbe cmake: support the use of launchers in ctest -S scripts
89096c234d Merge bitcoin-core/secp256k1#1692: cmake: configure libsecp256k1.pc during install
7106dce6fd cmake: configure libsecp256k1.pc during install
29e73f4ba5 Merge bitcoin-core/secp256k1#1685: cmake: Emulate Libtool's behavior on FreeBSD
746e36b141 Merge bitcoin-core/secp256k1#1678: cmake: add a helper for linking into static libs
a28c2ffa5c Merge bitcoin-core/secp256k1#1683: README: add link to musig example
2a9d374735 Merge bitcoin-core/secp256k1#1690: ci: Bump GCC snapshot major version to 16
add146e101 ci: Bump GCC snapshot major version to 16
004f57fcd8 ci: Move Valgrind build for `arm64` from Cirrus to GHA
5fafdfc30f ci: Move `gcc-snapshot` build for `arm64` from Cirrus to GHA
e814b79a8b ci: Switch `arm64_debian` from QEMU to native `arm64` Docker image
bcf77346b9 ci: Add `arm64` architecture to `docker_cache` job
b77aae9226 ci: Rename Docker image tag to reflect architecture
145ae3e28d cmake: add a helper for linking into static libs
819210974b README: add link to musig example, generalize module enabling hint
95db29b144 Merge bitcoin-core/secp256k1#1679: cmake: Use `PUBLIC_HEADER` target property in installation logic
37dd422b5c cmake: Emulate Libtool's behavior on FreeBSD
f24b838bed Merge bitcoin-core/secp256k1#1680: doc: Promote "Building with CMake" to standard procedure
3f31ac43e0 doc: Promote "Building with CMake" to standard procedure
6f67151ee2 cmake: Use `PUBLIC_HEADER` target property
c32715b2a0 cmake, move-only: Move module option processing to `src/CMakeLists.txt`
201b2b8f06 Merge bitcoin-core/secp256k1#1675: cmake: Bump minimum required CMake version to 3.22
3af71987a8 cmake: Bump minimum required CMake version to 3.22
92394476e9 Merge bitcoin-core/secp256k1#1673: Assert field magnitude at control-flow join
3a4f448cb4 Assert field magnitude at control-flow join
9fab425256 Merge bitcoin-core/secp256k1#1668: bench_ecmult: add benchmark for ecmult_const_xonly
05445377f4 bench_ecmult: add benchmark for ecmult_const_xonly
bb597b3d39 Merge bitcoin-core/secp256k1#1670: tests: update wycheproof files
d73ed99479 tests: update wycheproof files

git-subtree-dir: src/secp256k1
git-subtree-split: b9313c6e1a6082a66b4c75777e18ca4b176fcf9d
2025-07-22 09:35:01 +01:00
Anthony Towns 06ab3a394a tests: speed up coins_tests by parallelizing
Updates the cmake logic to generate a separate test for each
BOOST_FIXTURE_TEST_SUITE declaration in a file, and splits coins_tests.cpp
into three separate suites so that they can be run in parallel. Also
updates the convention enforced by test/lint/lint-tests.py.
2025-07-22 12:56:26 +10:00
merge-script 7129c9ea8e
Merge bitcoin/bitcoin#32827: mempool: Avoid needless vtx iteration during IBD
249889bee6 orphanage: avoid vtx iteration when no orphans (furszy)
41ad2be434 mempool: Avoid expensive loop in `removeForBlock` during IBD (Lőrinc)

Pull request description:

  During Initial Block Download, the mempool is usually empty, but `CTxMemPool::removeForBlock` is still called for every connected block where we:
  * iterate over every transaction in the block even though none will be found in the empty `mapTx`, always leaving `txs_removed_for_block` empty...
  * which is pre-allocated regardless with `40 bytes * vtx.size()`, even though it will always remain empty.

  Similarly to https://github.com/bitcoin/bitcoin/pull/32730#discussion_r2140691354, this change introduces a minor performance & memory optimization by only executing the loop if any of the affected mempool maps have any contents. The second commit is cherry-picked from there since it's related to this change as well.

ACKs for top commit:
  optout21:
    ACK 249889bee6
  glozow:
    ACK 249889bee6
  ismaelsadeeq:
    reACK 249889bee6

Tree-SHA512: 80d06ff1515164529cdc3ad21db3041bb5b2a1d4b72ba9e6884cdf40c5f1477fee7479944b8bca32a6f0bf27c4e5501fccd085f6041a2dbb101438629cfb9e4b
2025-07-21 11:01:12 -04:00
merge-script 11c6a864c9
Merge bitcoin/bitcoin#33007: test: fix `ReadTopologicalSet` unsigned integer overflow
31c4e77a25 test: fix ReadTopologicalSet unsigned integer overflow (ismaelsadeeq)

Pull request description:

  This PR is a simple fix for a potential unsigned integer overflow in ReadTopologicalSet.
  We obtain the value of `mask` from fuzz input, which can be the maximum representable value.
  Adding 1 to it would then cause an overflow.

  The fix skips the addition when the read value is already the maximum.

  See https://github.com/bitcoin/bitcoin/pull/30605#discussion_r2215338569 for more context

ACKs for top commit:
  maflcko:
    lgtm ACK 31c4e77a25

Tree-SHA512: f58d7907f66a0de0ed8d4b1cad6a4971f65925a99f3c030537c21c4d84126b643257c65865242caf7d445b9cbb7a71a1816a9f870ab7520625c4c16cd41979cb
2025-07-21 12:08:05 +01:00
merge-script 9bc33432e2
Merge bitcoin/bitcoin#32999: ci: Use APT_LLVM_V in msan task
fad040a578 ci: Use APT_LLVM_V in msan task (MarcoFalke)

Pull request description:

  This skips compilation of clang by using the apt.

ACKs for top commit:
  m3dwards:
    ACK fad040a578
  willcl-ark:
    ACK fad040a578

Tree-SHA512: cc8977a0e97f731b15a2bb9321442d4fc935e310a9cd1993c4ec08ddfd8d7f08a128bbe51ad4d820627bbdcdc748dd58feeec00dee6ee0723e528c546d209f92
2025-07-21 11:54:42 +01:00
Ava Chow 5878f35446
Merge bitcoin/bitcoin#31144: [IBD] multi-byte block obfuscation
248b6a27c3 optimization: peel align-head and unroll body to 64 bytes (Lőrinc)
e7114fc6dc optimization: migrate fixed-size obfuscation from `std::vector<std::byte>` to `uint64_t` (Lőrinc)
478d40afc6 refactor: encapsulate `vector`/`array` keys into `Obfuscation` (Lőrinc)
377aab8e5a refactor: move `util::Xor` to `Obfuscation().Xor` (Lőrinc)
fa5d296e3b refactor: prepare mempool_persist for obfuscation key change (Lőrinc)
6bbf2d9311 refactor: prepare `DBWrapper` for obfuscation key change (Lőrinc)
0b8bec8aa6 scripted-diff: unify xor-vs-obfuscation nomenclature (Lőrinc)
972697976c bench: make ObfuscationBench more representative (Lőrinc)
618a30e326 test: compare util::Xor with randomized inputs against simple impl (Lőrinc)
a5141cd39e test: make sure dbwrapper obfuscation key is never obfuscated (Lőrinc)
54ab0bd64c refactor: commit to 8 byte obfuscation keys (Lőrinc)
7aa557a37b random: add fixed-size `std::array` generation (Lőrinc)

Pull request description:

  This change is part of [[IBD] - Tracking PR for speeding up Initial Block Download](https://github.com/bitcoin/bitcoin/pull/32043)

  ### Summary

  Current block obfuscations are done byte-by-byte, this PR batches them to 64 bit primitives to speed up obfuscating bigger memory batches.
  This is especially relevant now that https://github.com/bitcoin/bitcoin/pull/31551 was merged, having bigger obfuscatable chunks.

  Since this obfuscation is optional, the speedup measured here depends on whether it's a [random value](https://github.com/bitcoin/bitcoin/pull/31144#issuecomment-2523295114) or [completely turned off](https://github.com/bitcoin/bitcoin/pull/31144#issuecomment-2519764142) (i.e. XOR-ing with 0).

  ### Changes in testing, benchmarking and implementation

  * Added new tests comparing randomized inputs against a trivial implementation and performing roundtrip checks with random chunks.
  * Migrated `std::vector<std::byte>(8)` keys to plain `uint64_t`;
  * Process unaligned bytes separately and unroll body to 64 bytes.

  ### Assembly

  Memory alignment is enforced by a small peel-loop (`std::memcpy` is optimized out on tested platform), with an `std::assume_aligned<8>` check, see the Godbolt listing at https://godbolt.org/z/59EMv7h6Y for details

  <details>
  <summary>Details</summary>

  Target & Compiler | Stride (per hot-loop iter) | Main operation(s) in loop | Effective XORs / iter
  -- | -- | -- | --
  Clang x86-64 (trunk) | 64 bytes | 4 × movdqu → pxor → store | 8 × 64-bit
  GCC x86-64 (trunk) | 64 bytes | 4 × movdqu/pxor sequence, enabled by 8-way unroll | 8 × 64-bit
  GCC RV32 (trunk) | 8 bytes | copy 8 B to temp → 2 × 32-bit XOR → copy back | 1 × 64-bit (as 2 × 32-bit)
  GCC s390x (big-endian 14.2) | 64 bytes | 8 × XC (mem-mem 8-B XOR) with key cached on stack | 8 × 64-bit

  </details>

  ### Endianness

  The only endianness issue was with bit rotation, intended to realign the key if obfuscation halted before full key consumption.
  Elsewhere, memory is read, processed, and written back in the same endianness, preserving byte order.
  Since CI lacks a big-endian machine, testing was done locally via Docker.
  <details>
  <summary>Details</summary>

  ```bash
  brew install podman pigz
  softwareupdate --install-rosetta
  podman machine init
  podman machine start
  docker run --platform linux/s390x -it ubuntu:latest /bin/bash
    apt update && apt install -y git build-essential cmake ccache pkg-config libevent-dev libboost-dev libssl-dev libsqlite3-dev python3 && \
    cd /mnt && git clone --depth=1 https://github.com/bitcoin/bitcoin.git && cd bitcoin && git remote add l0rinc https://github.com/l0rinc/bitcoin.git && git fetch --all && git checkout l0rinc/optimize-xor && \
    cmake -B build && cmake --build build --target test_bitcoin -j$(nproc) && \
    ./build/bin/test_bitcoin --run_test=streams_tests
  ```

  </details>

  ### Measurements (micro benchmarks and full IBDs)

  > cmake -B build -DBUILD_BENCH=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc/clang -DCMAKE_CXX_COMPILER=g++/clang++ && \
    cmake --build build -j$(nproc) && \
    build/bin/bench_bitcoin -filter='ObfuscationBench' -min-time=5000

  <details>
  <summary>GNU 14.2.0</summary>

  > Before:

  |             ns/byte |              byte/s |    err% |        ins/byte |        cyc/byte |    IPC |       bra/byte |   miss% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
  |                0.84 |    1,184,138,235.64 |    0.0% |            9.01 |            3.03 |  2.971 |           1.00 |    0.1% |      5.50 | `ObfuscationBench`

  > After (first optimizing commit):

  |             ns/byte |              byte/s |    err% |        ins/byte |        cyc/byte |    IPC |       bra/byte |   miss% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
  |                0.04 |   28,365,698,819.44 |    0.0% |            0.34 |            0.13 |  2.714 |           0.07 |    0.0% |      5.33 | `ObfuscationBench`

  > and (second optimizing commit):

  |             ns/byte |              byte/s |    err% |        ins/byte |        cyc/byte |    IPC |       bra/byte |   miss% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
  |                0.03 |   32,464,658,919.11 |    0.0% |            0.50 |            0.11 |  4.474 |           0.08 |    0.0% |      5.29 | `ObfuscationBench`

  </details>

  <details>
  <summary>Clang 20.1.7</summary>

  > Before:

  |             ns/byte |              byte/s |    err% |        ins/byte |        cyc/byte |    IPC |       bra/byte |   miss% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
  |                0.89 |    1,124,087,330.23 |    0.1% |            6.52 |            3.20 |  2.041 |           0.50 |    0.2% |      5.50 | `ObfuscationBench`

  > After (first optimizing commit):

  |             ns/byte |              byte/s |    err% |        ins/byte |        cyc/byte |    IPC |       bra/byte |   miss% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
  |                0.08 |   13,012,464,203.00 |    0.0% |            0.65 |            0.28 |  2.338 |           0.13 |    0.8% |      5.50 | `ObfuscationBench`

  > and (second optimizing commit):

  |             ns/byte |              byte/s |    err% |        ins/byte |        cyc/byte |    IPC |       bra/byte |   miss% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
  |                0.02 |   41,231,547,045.17 |    0.0% |            0.30 |            0.09 |  3.463 |           0.02 |    0.0% |      5.47 | `ObfuscationBench`

  </details>

  i.e. 27.4x faster obfuscation with GCC, 36.7x faster with Clang

  For other benchmark speedups see  https://corecheck.dev/bitcoin/bitcoin/pulls/31144

  ------

  Running an IBD until 888888 blocks reveals a 4% speedup.

  <details>
  <summary>Details</summary>

  SSD:

  ```bash
  COMMITS="8324a00bd4a6a5291c841f2d01162d8a014ddb02 5ddfd31b4158a89b0007cfb2be970c03d9278525"; \
  STOP_HEIGHT=888888; DBCACHE=1000; \
  CC=gcc; CXX=g++; \
  BASE_DIR="/mnt/my_storage"; DATA_DIR="$BASE_DIR/BitcoinData"; LOG_DIR="$BASE_DIR/logs"; \
  (for c in $COMMITS; do git fetch origin $c -q && git log -1 --pretty=format:'%h %s' $c || exit 1; done) && \
  hyperfine \
    --sort 'command' \
    --runs 1 \
    --export-json "$BASE_DIR/ibd-${COMMITS// /-}-$STOP_HEIGHT-$DBCACHE-$CC.json" \
    --parameter-list COMMIT ${COMMITS// /,} \
    --prepare "killall bitcoind; rm -rf $DATA_DIR/*; git checkout {COMMIT}; git clean -fxd; git reset --hard; \
      cmake -B build -DCMAKE_BUILD_TYPE=Release -DENABLE_WALLET=OFF && \
      cmake --build build -j$(nproc) --target bitcoind && \
      ./build/bin/bitcoind -datadir=$DATA_DIR -stopatheight=1 -printtoconsole=0; sleep 100" \
    --cleanup "cp $DATA_DIR/debug.log $LOG_DIR/debug-{COMMIT}-$(date +%s).log" \
    "COMPILER=$CC ./build/bin/bitcoind -datadir=$DATA_DIR -stopatheight=$STOP_HEIGHT -dbcache=$DBCACHE -blocksonly -printtoconsole=0"
  ```

  > 8324a00bd4 test: Compare util::Xor with randomized inputs against simple impl
  > 5ddfd31b41 optimization: Xor 64 bits together instead of byte-by-byte

  ```python
  Benchmark 1: COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=888888 -dbcache=1000 -blocksonly -printtoconsole=0 (COMMIT = 8324a00bd4a6a5291c841f2d01162d8a014ddb02)
    Time (abs ≡):        25033.413 s               [User: 33953.984 s, System: 2613.604 s]

  Benchmark 2: COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=888888 -dbcache=1000 -blocksonly -printtoconsole=0 (COMMIT = 5ddfd31b4158a89b0007cfb2be970c03d9278525)
    Time (abs ≡):        24110.710 s               [User: 33389.536 s, System: 2660.292 s]

  Relative speed comparison
          1.04          COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=888888 -dbcache=1000 -blocksonly -printtoconsole=0 (COMMIT = 8324a00bd4a6a5291c841f2d01162d8a014ddb02)
          1.00          COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=888888 -dbcache=1000 -blocksonly -printtoconsole=0 (COMMIT = 5ddfd31b4158a89b0007cfb2be970c03d9278525)
  ```

  > HDD:

  ```bash
  COMMITS="71eb6eaa740ad0b28737e90e59b89a8e951d90d9 46854038e7984b599d25640de26d4680e62caba7"; \
  STOP_HEIGHT=888888; DBCACHE=4500; \
  CC=gcc; CXX=g++; \
  BASE_DIR="/mnt/my_storage"; DATA_DIR="$BASE_DIR/BitcoinData"; LOG_DIR="$BASE_DIR/logs"; \
  (for c in $COMMITS; do git fetch origin $c -q && git log -1 --pretty=format:'%h %s' $c || exit 1; done) && \
  hyperfine \
    --sort 'command' \
    --runs 2 \
    --export-json "$BASE_DIR/ibd-${COMMITS// /-}-$STOP_HEIGHT-$DBCACHE-$CC.json" \
    --parameter-list COMMIT ${COMMITS// /,} \
    --prepare "killall bitcoind; rm -rf $DATA_DIR/*; git checkout {COMMIT}; git clean -fxd; git reset --hard; \
      cmake -B build -DCMAKE_BUILD_TYPE=Release -DENABLE_WALLET=OFF && cmake --build build -j$(nproc) --target bitcoind && \
      ./build/bin/bitcoind -datadir=$DATA_DIR -stopatheight=1 -printtoconsole=0; sleep 100" \
    --cleanup "cp $DATA_DIR/debug.log $LOG_DIR/debug-{COMMIT}-$(date +%s).log" \
    "COMPILER=$CC ./build/bin/bitcoind -datadir=$DATA_DIR -stopatheight=$STOP_HEIGHT -dbcache=$DBCACHE -blocksonly -printtoconsole=0"
  ```

  > 71eb6eaa74 test: compare util::Xor with randomized inputs against simple impl
  > 46854038e7 optimization: migrate fixed-size obfuscation from `std::vector<std::byte>` to `uint64_t`

  ```python
  Benchmark 1: COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=888888 -dbcache=4500 -blocksonly -printtoconsole=0 (COMMIT = 71eb6eaa740ad0b28737e90e59b89a8e951d90d9)
    Time (mean ± σ):     37676.293 s ± 83.100 s    [User: 36900.535 s, System: 2220.382 s]
    Range (min … max):   37617.533 s … 37735.053 s    2 runs

  Benchmark 2: COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=888888 -dbcache=4500 -blocksonly -printtoconsole=0 (COMMIT = 46854038e7984b599d25640de26d4680e62caba7)
    Time (mean ± σ):     36181.287 s ± 195.248 s    [User: 34962.822 s, System: 1988.614 s]
    Range (min … max):   36043.226 s … 36319.349 s    2 runs

  Relative speed comparison
          1.04 ±  0.01  COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=888888 -dbcache=4500 -blocksonly -printtoconsole=0 (COMMIT = 71eb6eaa740ad0b28737e90e59b89a8e951d90d9)
          1.00          COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=888888 -dbcache=4500 -blocksonly -printtoconsole=0 (COMMIT = 46854038e7984b599d25640de26d4680e62caba7)
  ```

  </details>

ACKs for top commit:
  achow101:
    ACK 248b6a27c3
  maflcko:
    review ACK 248b6a27c3 🎻
  ryanofsky:
    Code review ACK 248b6a27c3. Looks good! Thanks for adapting this and considering all the suggestions. I did leave more comments below but non are important and this looks good as-is

Tree-SHA512: ef541cd8a1f1dc504613c4eaa708202e32ae5ac86f9c875e03bcdd6357121f6af0860ef83d513c473efa5445b701e59439d416effae1085a559716b0fd45ecd6
2025-07-18 22:17:11 -07:00
furszy 249889bee6 orphanage: avoid vtx iteration when no orphans 2025-07-18 16:54:16 -07:00
Lőrinc 41ad2be434 mempool: Avoid expensive loop in `removeForBlock` during IBD
During Initial Block Download, the mempool is usually empty, but `CTxMemPool::removeForBlock` is still called for every connected block where we:
* iterate over every transaction in the block even though none will be found in the empty `mapTx`, always leaving `txs_removed_for_block` empty...
* which is pre-allocated regardless with 40 bytes * vtx.size(), even though it will always remain empty.

This change introduces a minor performance optimization by only executing the loop if any of the core mempool maps have any contents.

The call to `MempoolTransactionsRemovedForBlock` and the updates to the rolling fee logic remain unchanged.

The `removeForBlock` was also updated stylistically to match the surrounding methods and a clarification was added to clarify that it affects fee estimation as well.
2025-07-18 16:50:42 -07:00
Ava Chow e9edd43a95
Merge bitcoin/bitcoin#32521: policy: make pathological transactions packed with legacy sigops non-standard
96da68a38f qa: functional test a transaction running into the legacy sigop limit (Antoine Poinsot)
367147954d qa: unit test standardness of inputs packed with legacy sigops (Antoine Poinsot)
5863315e33 policy: make pathological transactions packed with legacy sigops non-standard. (Antoine Poinsot)

Pull request description:

  The Consensus Cleanup soft fork proposal includes a limit on the number of legacy signature
  operations potentially executed when validating a transaction. If this change is to be implemented
  here and activated by Bitcoin users in the future, we should make transactions that are not valid
  according to the new rules non-standard first because it would otherwise be a trivial DoS to
  potentially unupgraded miners after the soft fork activates.

  ML post: https://gnusha.org/pi/bitcoindev/49dyqqkf5NqGlGdinp6SELIoxzE_ONh3UIj6-EB8S804Id5yROq-b1uGK8DUru66eIlWuhb5R3nhRRutwuYjemiuOOBS2FQ4KWDnEh0wLuA=@protonmail.com/T/#u

ACKs for top commit:
  instagibbs:
    reACK 96da68a38f
  maflcko:
    review ACK 96da68a38f 🚋
  achow101:
    ACK 96da68a38f
  glozow:
    light code review ACK 96da68a38f, looks correct to me

Tree-SHA512: 106ffe62e48952affa31c5894a404a17a3b4ea8971815828166fba89069f757366129f7807205e8c6558beb75c6f67d8f9a41000be2f8cf95be3b1a02d87bfe9
2025-07-18 13:24:54 -07:00
Ava Chow 80067ac111
Merge bitcoin/bitcoin#31829: p2p: improve TxOrphanage denial of service bounds
50024620b9 [bench] worst case LimitOrphans and EraseForBlock (glozow)
45c7a4b56d [functional test] orphan resolution works in the presence of DoSy peers (glozow)
835f5c77cd [prep/test] restart instead of bumpmocktime between p2p_orphan_handling subtests (glozow)
b113877545 [fuzz] Add simulation fuzz test for TxOrphanage (Pieter Wuille)
03aaaedc6d [prep] Return the made-reconsiderable announcements in AddChildrenToWorkSet (Pieter Wuille)
ea29c4371e [p2p] bump DEFAULT_MAX_ORPHANAGE_LATENCY_SCORE to 3,000 (glozow)
24afee8d8f [fuzz] TxOrphanage protects peers that don't go over limit (glozow)
a2878cfb4a [unit test] strengthen GetChildrenFromSamePeer tests: results are in recency order (glozow)
7ce3b7ee57 [unit test] basic TxOrphanage eviction and protection (glozow)
4d23d1d7e7 [cleanup] remove unused rng param from LimitOrphans (glozow)
067365d2a8 [p2p] overhaul TxOrphanage with smarter limits (glozow)
1a41e7962d [refactor] create aliases for TxOrphanage Count and Usage (glozow)
b50bd72c42 [prep] change return type of EraseTx to bool (glozow)
3da6d7f8f6 [prep/refactor] make TxOrphanage a virtual class implemented by TxOrphanageImpl (glozow)
77ebe8f280 [prep/test] have TxOrphanage remember its own limits in LimitOrphans (glozow)
d0af4239b7 [prep/refactor] move DEFAULT_MAX_ORPHAN_TRANSACTIONS to txorphanage.h (glozow)
51365225b8 [prep/config] remove -maxorphantx (glozow)
8dd24c29ae [prep/test] modify test to not access TxOrphanage internals (glozow)
44f5327824 [fuzz] add SeedRandomStateForTest(SeedRand::ZEROS) to txorphan (glozow)
15a4ec9069 [prep/rpc] remove entry and expiry time from getorphantxs (glozow)
08e58fa911 [prep/refactor] move txorphanage to node namespace and directory (glozow)
bb91d23fa9 [txorphanage] change type of usage to int64_t (glozow)

Pull request description:

  This PR is part of the orphan resolution project, see #27463.

  This design came from collaboration with sipa - thanks.

  We want to limit the CPU work and memory used by `TxOrphanage` to avoid denial of service attacks. On master, this is achieved by limiting the number of transactions in this data structure to 100, and the weight of each transaction to 400KWu (the largest standard tx) [0]. We always allow new orphans, but if the addition causes us to exceed 100, we evict one randomly. This is dead simple, but has problems:
  - It makes the orphanage trivially churnable: any one peer can render it useless by spamming us with lots of orphans. It's possible this is happening: "Looking at data from node alice on 2024-09-14 shows that we’re sometimes removing more than 100k orphans per minute. This feels like someone flooding us with orphans." [1]
  - Effectively, opportunistic 1p1c is useless in the presence of adversaries: it is *opportunistic* and pairs a low feerate tx with a child that happens to be in the orphanage. So if nothing is able to stay in orphanages, we can't expect 1p1cs to propagate.
  - This number is also often insufficient for the volume of orphans we handle: historical data show that overflows are pretty common, and there are times where "it seems like [the node] forgot about the orphans and re-requested them multiple times." [1]

  Just jacking up the `-maxorphantxs` number is not a good enough solution, because it doesn't solve the churnability problem, and the effective resource bounds scale poorly.

  This PR introduces numbers for {global, per-peer} {memory usage, announcements + number of inputs}, representing resource limits:
  - The (constant) **global latency score limit** is the number of unique (wtxid, peer) pairs in the orphanage + the number of inputs spent by those (deduplicated) transactions floor-divided by 10 [2]. This represents a cap on CPU or latency for any given operation, and does not change with the number of peers we have. Evictions must happen whenever this limit is reached. The primary goal of this limit is to ensure we do not spend more than a few ms on any call to `LimitOrphans` or `EraseForBlock`.
  - The (variable) **per-peer latency score limit** is the global latency score limit divided by the number of peers. Peers are allowed to exceed this limit provided the global announcement limit has not been reached. The per-peer announcement limit decreases with more peers.
  - The (constant) **per-peer memory usage reservation** is the amount of orphan weight [3] reserved per peer [4]. Reservation means that peers are effectively guaranteed this amount of space. Peers are allowed to exceed this limit provided the global usage limit is not reached. The primary goal of this limit is to ensure we don't oom.
  - The (variable) **global memory usage limit** is the number of peers multiplied by the per-peer reservation [5]. As such, the global memory usage limit scales up with the number of peers we have. Evictions must happen whenever this limit is reached.
  - We introduce a "Peer DoS Score" which is the maximum between its "CPU Score" and "Memory Score." The CPU score is the ratio between the number of orphans announced by this peer / peer announcement limit. The memory score is the total usage of all orphans announced by this peer / peer usage reservation.

  Eviction changes in a few ways:
  - It is triggered if either limit is exceeded.
  - On each iteration of the loop, instead of selecting a random orphan, we select a peer and delete 1 of its announcements. Specifically, we select the peer with the highest DoS score, which is the maximum between its CPU DoS score (based on announcements) and Memory DoS score (based on tx weight). After the peer has been selected, we evict the oldest orphan (non-reconsiderable sorted before reconsiderable).
  - Instead of evicting orphans, we evict announcements. An orphan is still in the orphanage as long as there is 1 peer announcer. Of course, over the course of several iteration loops, we may erase all announcers, thus erasing the orphan itself. The purpose of this change is to prevent a peer from being able to trigger eviction of another peer's orphans.

  This PR also:
  - Reimplements `TxOrphanage` as single multi-index container.
  - Effectively bounds the number of transactions that can be in a peer's work set by ensuring it is a subset of the peer's announcements.
  - Removes the `-maxorphantxs` config option, as the orphanage no longer limits by unique orphans.

  This means we can receive 1p1c packages in the presence of spammy peers. It also makes the orphanage more useful and increases our download capacity without drastically increasing orphanage resource usage.

  [0]: This means the effective memory limit in orphan weight is 100 * 400KWu = 40MWu
  [1]: https://delvingbitcoin.org/t/stats-on-orphanage-overflows/1421
  [2]: Limit is 3000, which is equivalent to one max size ancestor package (24 transactions can be missing inputs) for each peer (default max connections is 125).
  [3]: Orphan weight is used in place of actual memory usage because something like "one maximally sized standard tx" is easier to reason about than "considering the bytes allocated for vin and vout vectors, it needs to be within N bytes..." etc. We can also consider a different formula to encapsulate more the memory overhead but still have an interface that is easy to reason about.
  [4]: The limit is 404KWu, which is the maximum size of an ancestor package.
  [5]: With 125 peers, this is 50.5MWu, which is a small increase from the existing limit of 40MWu. While the actual memory usage limit is higher (this number does not include the other memory used by `TxOrphanage` to store the outpoints map, etc.), this is within the same ballpark as the old limit.

ACKs for top commit:
  marcofleon:
    ReACK 50024620b9
  achow101:
    light ACK 50024620b9
  instagibbs:
    ACK 50024620b9
  theStack:
    Code-review ACK 50024620b9

Tree-SHA512: 270c11a2d116a1bf222358a1b4e25ffd1f01e24da958284fa8c4678bee5547f9e0554e87da7b7d5d5d172ca11da147f54a69b3436cc8f382debb6a45a90647fd
2025-07-18 13:01:24 -07:00
ismaelsadeeq 31c4e77a25
test: fix ReadTopologicalSet unsigned integer overflow 2025-07-18 14:57:39 +01:00
merge-script 672c85cb1e
Merge bitcoin/bitcoin#32868: test: refactor: overhaul block hash determination for `CBlock{,Header}` objects
5fa34951ea test: avoid unneeded block header hash -> integer conversions (Sebastian Falbesoner)
2118301d77 test: rename CBlockHeader `.hash` -> `.hash_hex` for consistency (Sebastian Falbesoner)
23be0ec2f0 test: rename CBlockHeader `.rehash()`/`.sha256` -> `.hash_int` for consistency (Sebastian Falbesoner)
8b09cc350a test: remove bare CBlockHeader `.rehash()`/`.calc_sha256()` calls (Sebastian Falbesoner)
0716382c20 test: remove header hash caching in CBlockHeader class (Sebastian Falbesoner)
0f044e82bd test: avoid direct block header modification in feature_block.py (Sebastian Falbesoner)
f3c791d2e3 test: refactor: dedup `CBlockHeader` serialization (Sebastian Falbesoner)

Pull request description:

  Similar to what #32421 did for `CTransaction` instances, this PR aims to improve the block hash determination of `CBlockHeader`/`CBlock` (the latter is a subclass of the former) instances by removing the block header caching mechanism and introducing consistent naming. Without the statefulness, sneaky testing bugs like #32742 and #32823 are less likely to happen in the future. Note that performance is even less of an issue here compared to `CTransaction`, as we only need to hash 80 bytes, which is less than typical standard transaction sizes [2].
  The only instance where the testing logic was relying on caching (i.e. we want to return an outdated value) is tackled in the second commit, the rest should be straight-forward to review, especially for contributors who already reviewed #32421.

  Summary table showing block hash determaination before/after this PR:
  | Task                               | master                   | PR           |
  |:-----------------------------------|:-------------------------|:-------------|
  | get block header hash (hex string) | `.hash`[1]               | `.hash_hex`  |
  | get block header hash (integer)    | `rehash()`, `.sha256`[1] | `.hash_int`  |

  [1] = returned value might be `None` or out-of-date, if rehashing function wasn't called after modification
  [2] = the only exception I could think of are transaction with pay-to-anchor (P2A) outputs

ACKs for top commit:
  rkrux:
    re-ACK 5fa34951ea modulo failing CI due to silent merge conflict.
  maflcko:
    re-ACK 5fa34951ea 🎩
  danielabrozzoni:
    reACK 5fa34951ea

Tree-SHA512: 3d13540012654effa063846958a3166d56c1bcb58e1321f52ca4d5c3bcb7abdea72c54d1fb566d04e636d84d06a41d293e16232dbe5d5e78a73c903bb6ffc80d
2025-07-18 14:24:24 +01:00
MarcoFalke fa1a14a13a
fuzz: Reset chainman state in process_message(s) targets 2025-07-18 14:03:21 +02:00
MarcoFalke fa9a3de09b
fuzz: DisableNextWrite
This is required in the process_message(s) fuzz targets to avoid leaking
the next write time from one run to the next. Also, disable it
completely because it is not needed and due to leveldb-internal
non-determinism.
2025-07-18 14:02:59 +02:00
MarcoFalke aeeeeec9f7
fuzz: Reset dirty connman state in process_message(s) targets 2025-07-18 14:02:58 +02:00
MarcoFalke fa11eea405
fuzz: Avoid non-determinism in process_message(s) target (PeerMan)
The PeerManager has several members, such as the FastRandomContext,
which need to be reset before every run to avoid leaking state from one
run into the next.

Also, style fixups in p2p_handshake.cpp, where this code is copied from.
2025-07-18 14:02:55 +02:00
MarcoFalke faa3e68411
test: Log KeyboardInterrupt as exception
log.exception is more verbose and useful to debug timeouts.

Also, log stderr for CalledProcessError to make debugging easier.
2025-07-18 07:32:39 +02:00
MarcoFalke fac90e5261
test: Check that the GUI interactive reindex works 2025-07-17 20:20:00 +02:00
Antoine Poinsot b2d07f872c Add release notes for -natpmp enabled by default 2025-07-17 13:01:05 -04:00
Antoine Poinsot 3fc660d267 mapport: turn -natpmp to on by default 2025-07-17 12:43:04 -04:00
MarcoFalke fa30b34026
test: Do not pass tests on unhandled exceptions
This adds a missing catch for BaseException (e.g. SystemExit), which
would otherwise be silently ignored.

Also, remove the redundant other catches, which are just calling
log.exception with a redundant log message.
2025-07-17 17:04:57 +02:00
Antoine Poinsot 96da68a38f qa: functional test a transaction running into the legacy sigop limit
It's useful to have an end-to-end test in addition to the unit test to sanity check the RPC error as
well as making sure the transaction is otherwise fully standard.
2025-07-17 09:18:30 -04:00
Antoine Poinsot 367147954d qa: unit test standardness of inputs packed with legacy sigops
Check bounds and different output types.
2025-07-17 09:18:30 -04:00
Antoine Poinsot 5863315e33 policy: make pathological transactions packed with legacy sigops non-standard.
The Consensus Cleanup soft fork proposal includes a limit on the number of legacy signature
operations potentially executed when validating a transaction. If this change is to be implemented
here and activated by Bitcoin users in the future, we should prevent the ability for someone to
broadcast a transaction through the p2p network that is not valid according to the new rules. This
is because if it was possible it would be a trivial DoS to potentially unupgraded miners after the
soft fork activates.

We do not know for sure whether users will activate the Consensus Cleanup. However if they do such
transactions must have been made non-standard long in advance, due to the time it takes for most
nodes on the network to upgrade. In addition this limit may only be run into by pathological
transactions which pad the Script with sigops but do not use actual signatures when spending, as
otherwise they would run into the standard transaction size limit.
2025-07-17 09:18:30 -04:00
Sebastian Falbesoner 5fa34951ea test: avoid unneeded block header hash -> integer conversions 2025-07-17 12:45:39 +02:00
Sebastian Falbesoner 2118301d77 test: rename CBlockHeader `.hash` -> `.hash_hex` for consistency
Note that we unfortunately can't use a scripted diff here, as the
`.hash` symbol is also used for other instances (e.g. CInv).
2025-07-17 12:45:35 +02:00
Sebastian Falbesoner 23be0ec2f0 test: rename CBlockHeader `.rehash()`/`.sha256` -> `.hash_int` for consistency
Note that we unfortunately can't use a scripted diff here, as the
`sha256` symbol is also used for other instances (e.g. as function
in hashlib, or in the `UTXO` class in p2p_segwit.py).
2025-07-17 11:59:10 +02:00
Sebastian Falbesoner 8b09cc350a test: remove bare CBlockHeader `.rehash()`/`.calc_sha256()` calls
Since the previous commit, CBlockHeader/CBlock object calls to the
methods `.rehash()` and `.calc_sha256()` are effectively no-ops
if the returned value is not used, so we can just remove them.
2025-07-17 11:59:09 +02:00
Sebastian Falbesoner 0716382c20 test: remove header hash caching in CBlockHeader class
Rather than block hashes (represented by the fields `.sha256` and
`.hash`) being stateful, simply compute them on-the-fly. This ensures
that the correct values are always returned and takes the burden of
rehashing from test writers, making the code shorter overall.  In a
first step, the fields are kept at the same name with @property
functions as drop-in replacements, for a minimal diff. In later commits,
the names are changed to be more descriptive and indicating the return
type of the block hash.
2025-07-17 11:59:09 +02:00
Sebastian Falbesoner 0f044e82bd test: avoid direct block header modification in feature_block.py
This is a preparatory commit for removing the header hash
caching in the CBlockHeader class. In order to not lose the
old block hash, necessary for updating the internal state of
the test (represented by `self.block_heights` and `self.blocks`),
we should only modify it within the `update_block` method.
2025-07-17 11:59:09 +02:00
Sebastian Falbesoner f3c791d2e3 test: refactor: dedup `CBlockHeader` serialization
Note that we can't call `.serialize()` directly in
the `.calc_sha256()` method, as this could wrongly lead
to the serialization of the derived class (CBlock) if
called from an instance there.
2025-07-17 11:59:08 +02:00
MarcoFalke fad040a578
ci: Use APT_LLVM_V in msan task
Also, use update-alternatives to avoid having to manually specify
clang-${APT_LLVM_V} or llvm-symbolizer-${APT_LLVM_V} everywhere.
2025-07-17 11:16:21 +02:00
David Gumberg 76fe0e59ec test: Migration of a wallet ending in `../` 2025-07-16 17:50:58 -07:00
David Gumberg f0bb3d50fe test: Migration of a wallet ending in `/` 2025-07-16 17:50:58 -07:00
David Gumberg 41faef5f80 test: Migration fail recovery w/ `../` in path 2025-07-16 17:50:58 -07:00
David Gumberg 63c6d36437 test: Migration of a wallet with `../` in path. 2025-07-16 17:50:58 -07:00
David Gumberg 70f1c99c90 wallet: Fix migration of wallets with pathnames.
Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
2025-07-16 17:50:58 -07:00
David Gumberg f6ee59b6e2 wallet: migration: Make backup in walletdir 2025-07-16 17:50:58 -07:00
David Gumberg e22c3599c6 test: wallet: Check direct file backup name.
This check ensures that when migrating a legacy wallet with a direct
filename, the backup file is named as expected.

Co-authored-by: Ava Chow <github@achow101.com>
2025-07-16 17:50:54 -07:00
MarcoFalke 060695c22a test: Failed load after migrate should restore backup 2025-07-16 15:18:17 -07:00
Lőrinc 248b6a27c3 optimization: peel align-head and unroll body to 64 bytes
Benchmarks indicated that obfuscating multiple bytes already gives an order of magnitude speed-up, but:
* GCC still emitted scalar code;
* Clang’s auto-vectorized loop ran on the slow unaligned-load path.

Fix contains:
* peeling the misaligned head enabled the hot loop starting at an 8-byte address;
* `std::assume_aligned<8>` tells the optimizer the promise holds - required to keep Apple Clang happy;
* manually unrolling the body to 64 bytes enabled GCC to auto-vectorize.

Note that `target.size() > KEY_SIZE` condition is just an optimization, the aligned and unaligned loops work without it as well - it's why the alignment calculation still contains `std::min`.

>  C++ compiler .......................... GNU 14.2.0

|             ns/byte |              byte/s |    err% |        ins/byte |        cyc/byte |    IPC |       bra/byte |   miss% |     total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
|                0.03 |   32,464,658,919.11 |    0.0% |            0.50 |            0.11 |  4.474 |           0.08 |    0.0% |      5.29 | `ObfuscationBench`

> C++ compiler .......................... Clang 20.1.7

|             ns/byte |              byte/s |    err% |        ins/byte |        cyc/byte |    IPC |       bra/byte |   miss% |     total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
|                0.02 |   41,231,547,045.17 |    0.0% |            0.30 |            0.09 |  3.463 |           0.02 |    0.0% |      5.47 | `ObfuscationBench`

Co-authored-by: Hodlinator <172445034+hodlinator@users.noreply.github.com>
2025-07-16 14:37:19 -07:00
Lőrinc e7114fc6dc optimization: migrate fixed-size obfuscation from `std::vector<std::byte>` to `uint64_t`
All former `std::vector<std::byte>` keys were replaced with `uint64_t` (we still serialize them as vectors but convert immediately to `uint64_t` on load).
This is why some tests still generate vector keys and convert them to `uint64_t` later instead of generating them directly.

In `Obfuscation::Unserialize` we can safely throw an `std::ios_base::failure` since during mempool fuzzing `mempool_persist.cpp#L141` catches and ignored these errors.

>  C++ compiler .......................... GNU 14.2.0

|             ns/byte |              byte/s |    err% |        ins/byte |        cyc/byte |    IPC |       bra/byte |   miss% |     total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
|                0.04 |   28,365,698,819.44 |    0.0% |            0.34 |            0.13 |  2.714 |           0.07 |    0.0% |      5.33 | `ObfuscationBench`

> C++ compiler .......................... Clang 20.1.7

|             ns/byte |              byte/s |    err% |        ins/byte |        cyc/byte |    IPC |       bra/byte |   miss% |     total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
|                0.08 |   13,012,464,203.00 |    0.0% |            0.65 |            0.28 |  2.338 |           0.13 |    0.8% |      5.50 | `ObfuscationBench`

Co-authored-by: Hodlinator <172445034+hodlinator@users.noreply.github.com>
Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2025-07-16 14:33:07 -07:00
Lőrinc 478d40afc6 refactor: encapsulate `vector`/`array` keys into `Obfuscation` 2025-07-16 14:33:07 -07:00
Lőrinc 377aab8e5a refactor: move `util::Xor` to `Obfuscation().Xor`
This is meant to focus the usages to narrow the scope of the obfuscation optimization.

`Obfuscation::Xor` is mostly a move.

Co-authored-by: maflcko <6399679+maflcko@users.noreply.github.com>
2025-07-16 14:33:07 -07:00
Lőrinc fa5d296e3b refactor: prepare mempool_persist for obfuscation key change
These changes are meant to simplify the diffs for the riskier optimization commits later.
2025-07-16 14:33:07 -07:00
Lőrinc 6bbf2d9311 refactor: prepare `DBWrapper` for obfuscation key change
Since `FastRandomContext` delegates to `GetRandBytes` anyway, we can simplify new key generation to a Write/Read combo, unifying the flow of enabling obfuscation via `Read`.

The comments were also adjusted to clarify that the `m_obfuscation` field affects the behavior of `Read` and `Write` methods.

These changes are meant to simplify the diffs for the riskier optimization commits later.
2025-07-16 14:33:06 -07:00
Lőrinc 0b8bec8aa6 scripted-diff: unify xor-vs-obfuscation nomenclature
Mechanical refactor of the low-level "xor" wording to signal the intent instead of the implementation used.
The renames are ordered by heaviest-hitting substitutions first, and were constructed such that after each replacement the code is still compilable.

-BEGIN VERIFY SCRIPT-
sed -i \
  -e 's/\bGetObfuscateKey\b/GetObfuscation/g' \
  -e 's/\bxor_key\b/obfuscation/g' \
  -e 's/\bxor_pat\b/obfuscation/g' \
  -e 's/\bm_xor_key\b/m_obfuscation/g' \
  -e 's/\bm_xor\b/m_obfuscation/g' \
  -e 's/\bobfuscate_key\b/m_obfuscation/g' \
  -e 's/\bOBFUSCATE_KEY_KEY\b/OBFUSCATION_KEY_KEY/g' \
  -e 's/\bSetXor(/SetObfuscation(/g' \
  -e 's/\bdata_xor\b/obfuscation/g' \
  -e 's/\bCreateObfuscateKey\b/CreateObfuscation/g' \
  -e 's/\bobfuscate key\b/obfuscation key/g' \
  $(git ls-files '*.cpp' '*.h')
-END VERIFY SCRIPT-
2025-07-16 14:32:01 -07:00
Lőrinc 972697976c bench: make ObfuscationBench more representative
A previous PR already solved the tiny byte-array-xors during serialization, so it makes sense to keep focusing on the performance of bigger continuous chunks.

This also renames the file from `xor` to `obfuscation` to enable scripted diff name unification later.

> C++ compiler .......................... GNU 14.2.0

|             ns/byte |              byte/s |    err% |        ins/byte |        cyc/byte |    IPC |       bra/byte |   miss% |     total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
|                0.84 |    1,184,138,235.64 |    0.0% |            9.01 |            3.03 |  2.971 |           1.00 |    0.1% |      5.50 | `ObfuscationBench`

> C++ compiler .......................... Clang 20.1.7

|             ns/byte |              byte/s |    err% |        ins/byte |        cyc/byte |    IPC |       bra/byte |   miss% |     total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
|                0.89 |    1,124,087,330.23 |    0.1% |            6.52 |            3.20 |  2.041 |           0.50 |    0.2% |      5.50 | `ObfuscationBench`
2025-07-16 14:32:01 -07:00
Lőrinc 618a30e326 test: compare util::Xor with randomized inputs against simple impl
The two tests are doing different things - `xor_roundtrip_random_chunks` does black-box style property-based testing to validate that certain invariants hold - that deobfuscating an obfuscation results in the original message (higher level, it doesn't have to know about the implementation details).

The `xor_bytes_reference` test makes sure the optimized xor implementation behaves in every imaginable scenario exactly as the simplest possible obfuscation - with random chunks, random alignment, random data, random key.

Since we're touching the file, other related small refactors were also applied:
* `nullpt` typo fixed;
* manual byte-by-byte xor key creations were replaced with `_hex` factories;
* since we're only using 64 bit keys in production, smaller keys were changed to reflect real-world usage;

Co-authored-by: Hodlinator <172445034+hodlinator@users.noreply.github.com>
2025-07-16 14:28:05 -07:00
Lőrinc a5141cd39e test: make sure dbwrapper obfuscation key is never obfuscated 2025-07-16 14:18:23 -07:00
Lőrinc 54ab0bd64c refactor: commit to 8 byte obfuscation keys
Since 31 byte xor-keys are not used in the codebase, using the common size (8 bytes) makes the benchmarks more realistic.

Co-authored-by: maflcko <6399679+maflcko@users.noreply.github.com>
2025-07-16 13:19:18 -07:00
Lőrinc 7aa557a37b random: add fixed-size `std::array` generation
Co-authored-by: Hodlinator <172445034+hodlinator@users.noreply.github.com>
2025-07-16 13:19:18 -07:00
glozow b6d4688f77 [doc] reword comments in test_mid_package_replacement
The comment about eviction seems to be erroneously copy-pasted. Reword
another comment for clarity.
2025-07-16 13:27:27 -04:00
glozow f3a613aa5b [cleanup] delete brittle test_mid_package_eviction
This test was introduced in #28251 to ensure that the mempool is not
trimmed in the middle of a package evaluation and the m_view cache
is updated when evictions and replacements happen so coins are no longer
visible in subsequent package transactions. These two things have
coverage in other tests as well, and are pretty unlikely to happen.

This test is also brittle: it requires evaluation of the parents in a
particular order, and creates a transaction that itself is not
enough to trigger eviction but will be pushed out immediately by the
package spending from it. While the current magic number 2000 works, we
do not have a way to query remaining space in the mempool if mempool
data structures change, and it can differ across platforms.
2025-07-16 13:22:48 -04:00
merge-script 9f713b83dc
Merge bitcoin/bitcoin#32837: depends: fix libevent `_WIN32_WINNT` usage
f5647c6c5a depends: fix libevent _WIN32_WINNT usage (fanquake)

Pull request description:

  Starting with version 13.x, the mingw headers will define the value of
  `NTDDI_VERSION`, based on the value of `_WIN32_WINNT`, if that version is <
  Windows 10. Given that libevent was undefining our `_WIN32_WINNT`, and
  redefining it to a value < Windows 10 (`0x0501`), `NTDDI_VERSION` was also
  being defined to that value, leading to functions not being exposed in
  the mingw-w64 headers; see here: 9c2668ef77/mingw-w64-headers/include/iphlpapi.h (L36-L41).

  Imports a commit from usptream ([a14ff91254f40cf36e0fee199e26fb11260fab49](a14ff91254)).

  Fixes #32707.

ACKs for top commit:
  willcl-ark:
    crACK f5647c6c5a

Tree-SHA512: eb429457a4af6191dd27ef3d1087667c5304ff0f49d4c6824883651e3c2dbab5d9784fa1f170402f23cd9238005c5214e0a71a4160562a59dfa35618dc702132
2025-07-16 13:49:26 +01:00
rkrux 2dfeb6668c
wallet: remove outdated `pszSkip` arg of database `Rewrite` func
This argument might have been used in the legacy wallets, but I don't
see any implementation using this argument in the SQLite wallets.
Removing it cleans up the code a bit.
2025-07-16 14:27:17 +05:30
MarcoFalke faaaddaaf8
init: [gui] Avoid UB/crash in InitAndLoadChainstate 2025-07-16 07:10:30 +02:00
Ava Chow 8a4cfddf23 wallet: Set migrated wallet name only on success
After a wallet is migrated and we are trying to load it, if it could not be
loaded, don't try to set the wallet name.
2025-07-15 16:11:36 -07:00
will 4f502baf8f
doc: add alpine depends build instructions 2025-07-15 21:32:54 +01:00
w0xlt d89c6fa4a7 wallet: Remove `upgradewallet` RPC 2025-07-15 11:00:48 -07:00
merge-script 184159e4f3
Merge bitcoin/bitcoin#32922: test: use notarized v28.2 binaries and fix macOS detection
4bb4c86599 test: document HOST for get_previous_releases.py (Sjors Provoost)
609203d507 test: stop signing previous releases >= v28.2 (Sjors Provoost)
c6dc2c29f8 test: replace v28.0 with notarized v28.2 (Sjors Provoost)
5bd73d96a3 test: fix macOS detection (Sjors Provoost)

Pull request description:

  Since https://github.com/bitcoin/bitcoin/pull/31407 macOS guix builds are signed and notarized. This was included in v29 and backported to 28.x.

  This PR bumps the v28.0 previous release binary to v28.2 and adjusts the test that uses it. Additionally it no longer manually code signs binaries >= v28.2.

  While testing on an M4 mac and redownloading all the binaries, I noticed that `platform == "arm64-apple-darwin"` doesn't actually work. This initially used `args.platform` in #26694, but that was changed to just `platform` in #32219.

  So the first commit switches this to use `args.host`. I manually tested on Intel macOS 13.7.6 that code-signing still isn't needed there (when downloading using a script).

  Also documented that you can set `HOST`.

ACKs for top commit:
  m3dwards:
    ACK 4bb4c86599
  maflcko:
    review ACK 4bb4c86599 🚏

Tree-SHA512: b4803d39a21cb622fd2388a0528b76d2b502956e2505385d3da201143b0afcf6f9d71c8c28937f27b70d2588fb6da677da058bdcd67b90fb53617acc3a727818
2025-07-15 14:46:31 +01:00
merge-script 5d17e64a02
Merge bitcoin/bitcoin#32677: test: headers sync timeout
61e800e75c test: headers sync timeout (stringintech)

Pull request description:

  When reviewing PR #32051 and considering which functional tests might need to be adapted/extended accordingly, I noticed there appears to be limited functional test coverage for header sync timeouts and thought it might be helpful to add one.

  This test attempts to cover two scenarios:

  1. **Normal peer timeout behavior:** When a peer fails to respond to initial getheaders requests within the timeout period, it should be disconnected and the node should attempt to sync headers from the next available peer.

  2. **Noban peer behavior:** When a peer with noban privileges times out, it should remain connected while the node still attempts to sync headers from other peers.

ACKs for top commit:
  maflcko:
    re-ACK 61e800e75c 🗝
  stratospher:
    reACK 61e800e7.

Tree-SHA512: b8a867e7986b6f0aa00d81a84b205f2bf8fb2e6047a2e37272e0244229d1f43020e9031467827dabbfe7849a91429f2685e00a25356e2ed477fa1a035fa0b1fd
2025-07-15 11:47:11 +01:00
merge-script 0087ba409b
Merge bitcoin/bitcoin#32968: test: fix intermittent failure in rpc_invalidateblock.py
28416f367a test: fix intermittent failure in rpc_invalidateblock.py (stratospher)

Pull request description:

  resolves #32965.

  node1 (with 24 blocks) causes node0 (with 6 blocks + 1 extra header) to silently reorg. so move the subtest to a point before the 20 blocks are generated so that node1's state doesn't cause node0 to silently reorg.

ACKs for top commit:
  maflcko:
    lgtm ACK 28416f367a
  mzumsande:
    Code Review ACK 28416f367a

Tree-SHA512: f6cc682b8e5416125f887c094d5e291dd37f0bfc41d7c0de218f3e24fa1ea0cd642f7a1e362f3127f68cde725a67f3054501326b9bd25f0caa9a05de7d0052b0
2025-07-15 11:35:46 +01:00
glozow 50024620b9 [bench] worst case LimitOrphans and EraseForBlock
Co-authored-by: Greg Sanders <gsanders87@gmail.com>
2025-07-14 16:13:47 -04:00
glozow 45c7a4b56d [functional test] orphan resolution works in the presence of DoSy peers
Co-authored-by: Greg Sanders <gsanders87@gmail.com>
2025-07-14 16:13:47 -04:00
glozow 835f5c77cd [prep/test] restart instead of bumpmocktime between p2p_orphan_handling subtests
If we want to restart at all during the tests, we can't have future timestamps.
2025-07-14 16:13:47 -04:00
Pieter Wuille b113877545 [fuzz] Add simulation fuzz test for TxOrphanage
This adds a large simulation fuzz test for all TxOrphanage public interface
functions, using a mix of comparison with expected behavior (in case it is
fully specified), and testing of properties exhibited otherwise.
2025-07-14 16:13:47 -04:00
Pieter Wuille 03aaaedc6d [prep] Return the made-reconsiderable announcements in AddChildrenToWorkSet
This is preparation for the simulation fuzz test added in a later commit. Since
AddChildrenToWorkSet consumes randomness, there is no way for the simulator to
exactly predict its behavior. By returning the set of made-reconsiderable announcements
instead, the simulator can instead test that it is *a* valid choice, and then
apply it to its own data structures.
2025-07-14 16:13:47 -04:00
glozow ea29c4371e [p2p] bump DEFAULT_MAX_ORPHANAGE_LATENCY_SCORE to 3,000
For the default number of peers (125), allows each to relay a default
descendant package (up to 25-1=24 can be missing inputs) of small (9
inputs or fewer) transactions out of order.

This limit also gives acceptable bounds for worst case LimitOrphans iterations.

Functional tests aren't changed to check for larger cap because it would
make the runtime too long.

Also deletes the now-unused DEFAULT_MAX_ORPHAN_TRANSACTIONS.
2025-07-14 16:13:47 -04:00
glozow 24afee8d8f [fuzz] TxOrphanage protects peers that don't go over limit
Co-authored-by: Greg Sanders <gsanders87@gmail.com>
2025-07-14 16:13:47 -04:00
glozow a2878cfb4a [unit test] strengthen GetChildrenFromSamePeer tests: results are in recency order 2025-07-14 16:13:47 -04:00
glozow 7ce3b7ee57 [unit test] basic TxOrphanage eviction and protection 2025-07-14 16:13:47 -04:00
glozow 4d23d1d7e7 [cleanup] remove unused rng param from LimitOrphans 2025-07-14 16:13:47 -04:00
glozow 067365d2a8 [p2p] overhaul TxOrphanage with smarter limits
This is largely a reimplementation using boost::multi_index_container.
All the same public methods are available. It has an index by outpoint,
per-peer tracking, peer worksets, etc.

A few differences:
- Limits have changed: instead of a global limit of 100 unique orphans,
  we have a maximum number of announcements (which can include duplicate
orphans) and a global memory limit which scales with the number of
peers.
- The maximum announcements limit is 100 to match the original limit,
  but this is actually a stricter limit because the announcement count
is not de-duplicated.
- Eviction strategy: when global limits are reached, a per-peer limit
  comes into play. While limits are exceeded, we choose the peer whose
“DoS score” (max usage / limit ratio for announcements and memory
limits) is highest and evict announcements by entry time, sorting
non-reconsiderable ones before reconsiderable ones. Since announcements
are unique by (wtxid, peer), as long as 1 announcement remains for a
transaction, it remains in the orphanage.
- This eviction strategy means no peer can influence the eviction of
  another peer’s orphans.
- Also, since global limits are a multiple of per-peer limits, as long
  as a peer does not exceed its limits, its orphans are protected from
eviction.
- Orphans no longer expire, since older announcements are generally
  removed before newer ones.
- GetChildrenFromSamePeer returns the transactions from newest to
  oldest.

Co-authored-by: Pieter Wuille <pieter@wuille.net>
2025-07-14 16:13:47 -04:00
glozow 1a41e7962d [refactor] create aliases for TxOrphanage Count and Usage 2025-07-14 16:13:47 -04:00
glozow b50bd72c42 [prep] change return type of EraseTx to bool
This function only ever returns 0 or 1 (number of unique orphans
erased).
2025-07-14 16:13:47 -04:00
glozow 3da6d7f8f6 [prep/refactor] make TxOrphanage a virtual class implemented by TxOrphanageImpl 2025-07-14 16:13:46 -04:00
glozow 77ebe8f280 [prep/test] have TxOrphanage remember its own limits in LimitOrphans
Move towards a model where TxOrphanage is initialized with limits that
it remembers throughout its lifetime.
Remove the param. Limiting by number of unique orphans will be removed
in a later commit.
Now that -maxorphantx is gone, this does not change the node behavior.
The parameter is only used in tests.
2025-07-14 16:13:10 -04:00
glozow d0af4239b7 [prep/refactor] move DEFAULT_MAX_ORPHAN_TRANSACTIONS to txorphanage.h
This is move only.
2025-07-14 16:13:10 -04:00
glozow 51365225b8 [prep/config] remove -maxorphantx
The orphanage will no longer have a maximum number of unique orphans.
2025-07-14 16:13:10 -04:00
glozow 8dd24c29ae [prep/test] modify test to not access TxOrphanage internals
These internals should and will be private.
2025-07-14 16:12:47 -04:00
glozow c3cd7fcb2c [doc] remove references to now-nonexistent Finalize() function 2025-07-14 14:48:26 -04:00
glozow d8140f5f05 don't make a copy of m_non_base_coins 2025-07-14 14:48:26 -04:00
glozow 98ba2b1db2 [doc] MemPoolAccept coins views 2025-07-14 14:48:25 -04:00
glozow ba02c30b8a [doc] always CleanupTemporaryCoins after a mempool trim 2025-07-14 14:43:11 -04:00
merge-script b53fab1467
Merge bitcoin/bitcoin#32948: refactor: cleanup index logging
c18bf0bd9b refactor: cleanup index logging (Sjors Provoost)

Pull request description:

  This PR removes the use of `__func__` from index logging, since we have `-logsourcelocations`.

  It also improves readability by putting `GetName()` in a more logical place.

  Before

  > coinstatsindex: best block of the index not found. Please rebuild the index.

  After:

  > best block of coinstatsindex not found. Please rebuild the index.

  I found myself maintaining this commit as part of https://github.com/Sjors/bitcoin/pull/86, but since that might never land here, it seemed better to split it into its own PR (or get rid of it).

ACKs for top commit:
  l0rinc:
    Lightweight code review ACK c18bf0bd9b
  maflcko:
    review ACK c18bf0bd9b 🚣

Tree-SHA512: 755948371e3ff7a5515b63ce48075631ec7868d69c3c1469176d5be0e8b28e1c071e206ae3f7320f87d8c441f815894acfef61621f05795b5ff6b8a5a3031e3b
2025-07-14 16:26:56 +01:00
Pieter Wuille 62ed1f92ef txgraph: check that DoWork finds optimal if given high budget (tests) 2025-07-14 10:37:00 -04:00
Pieter Wuille f3c2fc867f txgraph: add work limit to DoWork(), try optimal (feature)
This adds an `iters` parameter to DoWork(), which controls how much work it is
allowed to do right now.

Additionally, DoWork() won't stop at just getting everything ACCEPTABLE, but if
there is work budget left, will also attempt to get every cluster linearized
optimally.
2025-07-14 10:28:54 -04:00
MarcoFalke fa1fd07468
ci: Enable more shellcheck 2025-07-14 16:27:07 +02:00
Pieter Wuille e96b00d99e txgraph: make number of acceptable iterations configurable (feature) 2025-07-14 09:42:58 -04:00
Pieter Wuille cfe9958852 txgraph: track amount of work done in linearization (preparation) 2025-07-14 09:41:17 -04:00
Pieter Wuille 6ba316eaa0 txgraph: 1-or-2-tx split-off clusters are optimal (optimization) 2025-07-14 09:30:24 -04:00
Pieter Wuille fad0eb091e txgraph: reset quality when merging clusters (bugfix) 2025-07-14 09:30:24 -04:00
stringintech 61e800e75c test: headers sync timeout 2025-07-14 16:48:23 +03:30
stratospher 28416f367a test: fix intermittent failure in rpc_invalidateblock.py
node1 (with 24 blocks) causes node0 (with 6 blocks) to silently
reorg. so move the subtest to a point before the 20 blocks are
generated so that node1's state doesn't cause node0 to silently
reorg.
2025-07-14 18:37:29 +05:30
merge-script e72cb20c3f
Merge bitcoin/bitcoin#32943: depends: Force `CMAKE_EXPORT_NO_PACKAGE_REGISTRY=TRUE`
44f3bae300 depends: Force `CMAKE_EXPORT_NO_PACKAGE_REGISTRY=TRUE` (Hennadii Stepanov)

Pull request description:

  When using CMake policies 3.14 and below, the `export(PACKAGE)` command by default populates the user package registry, which is stored outside the build tree. Setting the `CMAKE_EXPORT_NO_PACKAGE_REGISTRY` variable disables this side effect.

  In CMake 3.15 and later, this behavior is disabled by default, and the variable has no effect.

  This PR forces `CMAKE_EXPORT_NO_PACKAGE_REGISTRY=TRUE` globally, rather than managing it for each dependency package individually rather. It may be reverted once all CMake-based packages have updated to policies 3.15 or newer.

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

ACKs for top commit:
  fanquake:
    ACK 44f3bae300

Tree-SHA512: 0aac398b7182e80185b064d59f81aece4d8477a609fad9cc3fee317da2aff43b66ef7db1efec0135b4f0feaad23b1db664e33bd035fe659712c5b2a9bf2d6fb6
2025-07-14 13:32:44 +01:00
merge-script 97fb46d0a0
Merge bitcoin/bitcoin#32880: ci: Avoid cd into build dir
fad191ff48 ci: Avoid cd into build dir (MarcoFalke)

Pull request description:

  Changing into the build dir is confusing and brittle, because the following commands implicitly assume it. So they could break on unrelated changes.

  The changes are required for stuff like:

  * cmake presets (see https://github.com/bitcoin/bitcoin/pull/30871#issuecomment-2344031208)
  * meta ci tests (like https://github.com/bitcoin/bitcoin/pull/32874)

  So remove the `cd` and just make the build dir explicit.

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

Tree-SHA512: a88a9341445ffe28a0dac3815f235ec8eb0459d10a91a80829fd3184762d3c807d0f68c56243b20c04a6efa5becd8a7fad568f43c2b1e6af1ff8ba07b140ef87
2025-07-14 11:46:56 +01:00
merge-script 69b9ad02da
Merge bitcoin/bitcoin#32954: cmake: Drop no longer necessary "cmakeMinimumRequired" object
12a6959892 cmake: Drop no longer necessary "cmakeMinimumRequired" object (Hennadii Stepanov)

Pull request description:

  The minimum required CMake version is 3.22:6a13a6106e/CMakeLists.txt (L10)

ACKs for top commit:
  fanquake:
    ACK 12a6959892 - has been unneeded since it was introduced (minimum was already 3.22).

Tree-SHA512: 26f97662bfe52986e19e38dbf4ab8e1e7558bc78c3a65593cbecd1f35887bba7a9f7d8a3d08ccfab8396f41c2334cdad5b0e503999a759cfa158d3bb8d0d14d7
2025-07-14 11:06:40 +01:00
merge-script 7566b40bd2
Merge bitcoin/bitcoin#32961: fix spelling in tor.md docs
84ef5524d5 fix spelling in tor.md docs (stutxo)

Pull request description:

  This PR is to fix some spelling mistakes i found of the word occurrences! there are two occurrences of this mistake.

  thanks!

ACKs for top commit:
  maflcko:
    lgtm ACK 84ef5524d5
  willcl-ark:
    ACK 84ef5524d5
  delta1:
    ACK 84ef5524d5

Tree-SHA512: 4ba71b772fdc8cf36ada7493d29fb5b312a7a6085099347162eb3495db4de984b0417b7861f2927c617cbd552741356e26688479601bdf7e835c15e097aa28f3
2025-07-14 10:07:55 +01:00
MarcoFalke faa3171ff2
ci: Use optimized Debug build type in test-each-commit 2025-07-14 09:35:03 +02:00
MarcoFalke fa21c3401e
ci: [doc] reword debug log message 2025-07-14 09:34:55 +02:00
stutxo 84ef5524d5 fix spelling in tor.md docs 2025-07-13 23:25:37 +01:00
Hennadii Stepanov 12a6959892
cmake: Drop no longer necessary "cmakeMinimumRequired" object 2025-07-12 14:03:35 +01:00
Hennadii Stepanov 6a13a6106e
Merge bitcoin/bitcoin#32937: Enable `-Werror=dev` in CI & Guix
8f766f39df ci: enable -Werror=dev (fanquake)
7b420ca834 guix: configure with -Werror=dev (fanquake)
44097ddb19 cmake: enable -Werror=dev in dev-mode preset (fanquake)

Pull request description:

  Pass `-Werror=dev` in the CI, Guix and the `dev-mode` preset.

  https://cmake.org/cmake/help/latest/manual/cmake.1.html#cmdoption-cmake-Werror:
  > Make developer warnings errors.
  > Make warnings that are meant for the author of the CMakeLists.txt files errors. By default this will also turn on deprecated warnings as errors.

  Pulled out of #32865.

ACKs for top commit:
  Sjors:
    re-ACK 8f766f39df
  hebasto:
    ACK 8f766f39df, tested on Ubuntu 24.04.

Tree-SHA512: 0fa321b77d2519b5249d90590664c4e5938ac86209b068658647adf97ab55ea4d54c913aae2f622385fe2f41d7c851cd5d7371905fdad38b66cb124371e16ac7
2025-07-11 23:10:20 +01:00
glozow 44f5327824 [fuzz] add SeedRandomStateForTest(SeedRand::ZEROS) to txorphan 2025-07-11 13:52:50 -04:00
glozow 15a4ec9069 [prep/rpc] remove entry and expiry time from getorphantxs
Expiry is going away in a later commit.
This is only an RPC change. Behavior of the orphanage does not change.
Note that getorphantxs is marked experimental.
2025-07-11 13:52:50 -04:00
glozow 08e58fa911 [prep/refactor] move txorphanage to node namespace and directory
This is move-only.
2025-07-11 13:52:50 -04:00
glozow bb91d23fa9 [txorphanage] change type of usage to int64_t
Since this field holds a total number of bytes, overflow is within the
realm of possibility. Use int64 to be safe.
2025-07-11 13:50:40 -04:00
merge-script 23e15d40b9
Merge bitcoin/bitcoin#32631: refactor: Convert GenTxid to `std::variant`
a60f863d3e scripted-diff: Replace GenTxidVariant with GenTxid (marcofleon)
c8ba199598 Remove old GenTxid class (marcofleon)
072a198ea4 Convert remaining instances of GenTxid to GenTxidVariant (marcofleon)
1b528391c7 Convert `txrequest` to GenTxidVariant (marcofleon)
bde4579b07 Convert `txdownloadman_impl` to GenTxidVariant (marcofleon)
c876a892ec Replace GenTxid with Txid/Wtxid overloads in `txmempool` (marcofleon)
de858ce2be move-only: make GetInfo a private CTxMemPool member (stickies-v)
eee473d9f3 Convert `CompareInvMempoolOrder` to GenTxidVariant (marcofleon)
243553d590 refactor: replace get_iter_from_wtxid with GetIter(const Wtxid&) (stickies-v)
fcf92fd640 refactor: make CTxMemPool::GetIter strongly typed (marcofleon)
11d28f21bb Implement GenTxid as a variant (marcofleon)

Pull request description:

  Part of the [type safety refactor](https://github.com/bitcoin/bitcoin/pull/32189).

  This PR changes the GenTxid class to a variant, which holds both Txids and Wtxids. This provides compile-time type safety and eliminates the manual type check (bool m_is_wtxid). Variables that can be either a Txid or a Wtxid are now using the new GenTxid variant, instead of uint256.

ACKs for top commit:
  w0xlt:
    ACK a60f863d3e
  dergoegge:
    Code review ACK a60f863d3e
  maflcko:
    review ACK a60f863d3e 🎽
  theStack:
    Code-review ACK a60f863d3e

Tree-SHA512: da9b73b7bdffee2eb9281a409205519ac330d3336094d17681896703fbca8099608782c9c85801e388e4d90af5af8abf1f34931f57bbbe6e9674d802d6066047
2025-07-11 13:47:19 -04:00
merge-script 8ffbd7b778
Merge bitcoin/bitcoin#32940: cmake: Use newer signature of `qt6_add_lrelease` when available
94931656b5 cmake: Use newer signature of `qt6_add_lrelease` when available (Hennadii Stepanov)

Pull request description:

  See Qt docs here: https://doc.qt.io/qt-6/qtlinguist-cmake-qt-add-lrelease.html.

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

ACKs for top commit:
  fanquake:
    ACK 94931656b5

Tree-SHA512: bf0320306967164374499dd0be122473799e830fdff5e070ef13f87af3c14a3b799d90afb423881edd7eea17c13d27af8ced381bbb3cd149353b31b3990dde67
2025-07-11 14:26:16 +01:00
merge-script 80ce513766
Merge bitcoin/bitcoin#32933: log: Properly log warnings with warn loglevel in addrdb
fa894b0f3e log: Properly log warnings with warn loglevel in addrdb (MarcoFalke)

Pull request description:

  The logging in addrdb is confusing, because it uses `LogPrintf` (info level) to log warnings.

  Fix this by properly using the `warn` level, where needed. Also, drop unused trailing `\n` while touching the lines.

ACKs for top commit:
  stickies-v:
    ACK fa894b0f3e
  dergoegge:
    utACK fa894b0f3e

Tree-SHA512: 96d3823623ea8e1698e8cb541ca97cbab7b2a9934b2f894884171045abbca7be796f07965082e997001c97d06d1e0c4d13b29354eb4fe71c3a2ee680eada5516
2025-07-11 14:24:24 +01:00
Sjors Provoost c18bf0bd9b
refactor: cleanup index logging
- don't log function name
- take into account that GetName() always ends with " index"
- replace deprecated LogPrintf with LogInfo
- remove trailing \n
- adjusted log level where needed
2025-07-11 15:18:22 +02:00
fanquake 8f766f39df
ci: enable -Werror=dev
Turn developer & deprecation warnings into errors.
2025-07-11 13:59:29 +01:00
fanquake 7b420ca834
guix: configure with -Werror=dev 2025-07-11 13:59:29 +01:00
fanquake 44097ddb19
cmake: enable -Werror=dev in dev-mode preset 2025-07-11 13:59:28 +01:00
merge-script 12fb00fd42
Merge bitcoin/bitcoin#32927: fuzz: Add missing calls to `SetMockTime` for determinism
fa8862723c fuzz: CheckGlobals in init (MarcoFalke)
fa26bfde98 test: Avoid resetting mocktime in testing setup (MarcoFalke)
fa6b45fa8e Add SetMockTime for time_point types (MarcoFalke)

Pull request description:

  (Tracking issue https://github.com/bitcoin/bitcoin/issues/29018)

  During fuzzing, `AppInitParameterInteraction` may actually disable a previously set mocktime. This is confusing and can also cause non-determinism.

  Fix this issue, by

  * fixing the erroneous `-mocktime` parsing in `AppInitParameterInteraction`.
  * adding the missing `SetMockTime` calls to the affected fuzz init functions.
  * adding a `CheckGlobals` to the fuzz init, to prevent this issue in the future.

  This can be tested by

  * Cherry-picking the `CheckGlobals`-commit onto current master and observing a fuzz failure in the touched fuzz targets.
  * Reverting the touched fuzz fixups and observing a fuzz failure for each target.

ACKs for top commit:
  w0xlt:
    ACK fa8862723c
  dergoegge:
    utACK fa8862723c

Tree-SHA512: 5a9400f0467c82fa224713af4cc2b525afbefefc7c3f419077110925ad7af6c7fda3dcd2b50f7facf0ee7df2547c6ac20336906d707adcdfd1d652a9d9a735fe
2025-07-11 11:18:03 +01:00
fanquake f5647c6c5a
depends: fix libevent _WIN32_WINNT usage
Starting with version 13.x, the mingw headers will define the value of
NTDDI_VERSION, based on the value of _WIN32_WINNT, if that version is <
Windows 10. Given that libevent was undefining our _WIN32_WINNT, and
redefining it to a value < Windows 10 (0x0501), NTDDI_VERSION was also
being defined to that value, leading to functions not being exposed in
the mingw-w64 headers; see here:
9c2668ef77/mingw-w64-headers/include/iphlpapi.h (L36-L41).

Imports a commit from usptream (a14ff91254f40cf36e0fee199e26fb11260fab49).

Fixes #32707.
2025-07-11 10:25:04 +01:00
merge-script 3c1418666b
Merge bitcoin/bitcoin#32930: Resolve guix non-determinism with emplace_back instead of push_back
f43571010e Resolve guix non-determinism with emplace_back instead of push_back (Ava Chow)

Pull request description:

  For some reason, building x86_64-w64-mingw32 on x86_64 and aarch64 results in a single instruction difference which can be traced down to prevector.h:174. The ultimate caller of this is the copy constructor for a prevector that ends up being called by std::vector::push_back in walletmodel.cpp:183. By replacing the push_back with an emplace_back, somehow this non-determinism goes away.

  Closes #32923

ACKs for top commit:
  l0rinc:
    code review ACK f43571010e
  Sjors:
    utACK f43571010e
  maflcko:
    lgtm ACK f43571010e

Tree-SHA512: 5bf0571f32cb72efc0c533e16d2704cfc3a79bcef2943f0892743572808610fb00ca8ab41223897536f8e5090bf4030735be910942de8116652d02bc3f231e2e
2025-07-11 10:24:40 +01:00
Ava Chow bad998b7c0
Merge bitcoin/bitcoin#32921: test: less ambiguous error if bitcoind is missing
83bb414557 test: less ambiguous error if bitcoind is missing (Sjors Provoost)

Pull request description:

  Before this change, when a functional test is run without building the source,  the error message suggested that previous release binaries were missing.

  When no previous release version is set, make the error message more specifically about bitcoind.

  To test, try this before and after:

  ```sh
  git clean -dfx
  cmake -B build
  build/test/functional/mining_basic.py
  cmake --build build
  build/test/functional/mining_basic.py
  build/test/functional/wallet_backwards_compatibility.py
  test/get_previous_releases.py
  build/test/functional/wallet_backwards_compatibility.py
  ```

ACKs for top commit:
  achow101:
    ACK 83bb414557
  janb84:
    ACK 83bb414557
  w0xlt:
    ACK 83bb414557

Tree-SHA512: c6df65019de99d6c214951cf70944c4ddca9b635c5ab60ac2c47e4589478e9c65d5e079c394ace9b470a7eaeea3c9cf68b7246dd413e802c4a1e071913a7fc32
2025-07-10 14:51:11 -07:00
Ava Chow 7f28e80329
Merge bitcoin/bitcoin#32758: wallet: remove dead code in legacy wallet migration
150b5c99ca wallet: replace `reload_wallet` with inline functionality (rkrux)
0f86da382d wallet: remove dead code in legacy wallet migration (rkrux)

Pull request description:

  A discussion on a previous [PR 32481](https://github.com/bitcoin/bitcoin/pull/32481#discussion_r2145152084) related to legacy wallet dead
  code removal made me realize that checking if the legacy
  wallet was loaded prior to the start of the migration is not
  required ever since legacy wallets can't be loaded in the first
  place. I also verified that the `load_on_start` persistent
  setting can also not cause the legacy wallets to be loaded, which
  further makes the case for removal of the above mentioned checks
  during migration.
  The current test coverage also shows these lines uncovered.

ACKs for top commit:
  achow101:
    ACK 150b5c99ca
  furszy:
    ACK 150b5c99ca

Tree-SHA512: 9bc7043cac1f4051228557208895e43648de3c7ffae6860c0676d1aa2db3a8ed3a09d1f9defacd96ca50bbb9699ba86652ccb0c5e55cc88be248a1fe727c13d9
2025-07-10 14:41:44 -07:00
merge-script 5ef0d4897b
Merge bitcoin/bitcoin#30605: Cluster linearization: separate tests from tests-of-tests
d7fca5c171 clusterlin: add big comment explaning the relation between tests (Pieter Wuille)
b64e61d2de clusterlin: abstract try-permutations into ExhaustiveLinearize function (Pieter Wuille)
1fa55a64ed clusterlin tests: verify that chunks are minimal (Pieter Wuille)
da23ecef29 clusterlin tests: support non-empty ReadTopologicalSubset() (Pieter Wuille)
94f3e17c33 clusterlin tests: compare with fuzz-provided linearizations (Pieter Wuille)
5f92ebee0d clusterlin tests: compare with fuzz-provided topological sets (Pieter Wuille)
6e37824ac3 clusterlin tests: optimize clusterlin_simple_linearize (Pieter Wuille)
98c1c88b6f clusterlin tests: separate testing of SimpleLinearize and Linearize (Pieter Wuille)
10e90f7aef clusterlin tests: make SimpleCandidateFinder always find connected (Pieter Wuille)
a38c38951e clusterlin tests: separate testing of Search- and SimpleCandidateFinder (Pieter Wuille)
77a432ee70 clusterlin tests: count SimpleCandidateFinder iterations better (Pieter Wuille)

Pull request description:

  Part of the cluster mempool project: #30289

  The current cluster linearization fuzz tests contain two tests which combine testing of production code with testing of the test code itself:
  * `clusterlin_search_finder`: establishes the correctness of `SearchCandidateFinder` by comparing against both `SimpleCandidateFinder` and `ExhaustiveCandidateFinder` (which is even more simple than `SimpleCandidateFinder`). If `SimpleCandidateFinder` works correctly, then this comparison with `ExhaustiveCandidateFinder` is redundant. If it isn't, we ought to find that in a test specific to `SimpleCandidateFinder` rather than as a side-effect of testing `SearchCandidateFinder`. Split this functionality out into a new `clusterlin_simple_finder`.
  * `clusterlin_linearize`: establishes the correctness of `Linearize` by comparing against both `SimpleLinearize` and literally every valid linearization for the cluster. Again, if `SimpleLinearize` works correctly, then this comparison with all valid linearizations is redundant, and if it isn't we should find it in a test for `SimpleLinearize`. Do so by splitting off that functionality into `clusterlin_simple_linearize`.

  After that, a few general improvements to the affected tests are made (comparing with linearizations and subsets read from the fuzz input, plus a performance improvement).

ACKs for top commit:
  marcofleon:
    Re ACK d7fca5c171
  ismaelsadeeq:
    re-ACK d7fca5c171
  monlovesmango:
    ACK d7fca5c171

Tree-SHA512: 33cb76bd9b9547a5f3ee231fa452e928f064ad03af98e3d9e64246eb972f2b026c13e7367257ccdac1ae57982ee8ef98c907684588ecbb4bc4c82cbec160b3e8
2025-07-10 13:52:31 -04:00
Ava Chow f43571010e Resolve guix non-determinism with emplace_back instead of push_back
For some reason, building x86_64-w64-mingw32 on x86_64 and aarch64
results in a single instruction difference which can be traced down to
prevector.h:174. The ultimate caller of this is the copy constructor for
a prevector that ends up being called by std::vector::push_back in
walletmodel.cpp:183. By replacing the push_back with an emplace_back,
somehow this non-determinism goes away.
2025-07-10 10:29:53 -07:00
Hennadii Stepanov 44f3bae300
depends: Force `CMAKE_EXPORT_NO_PACKAGE_REGISTRY=TRUE`
When using CMake policies 3.14 and below, the `export(PACKAGE)` command
by default populates the user package registry, which is stored outside
the build tree. Setting the `CMAKE_EXPORT_NO_PACKAGE_REGISTRY` variable
disables this side effect.

In CMake 3.15 and later, this behavior is disabled by default, and the
variable has no effect.
2025-07-10 17:55:34 +01:00
Hennadii Stepanov 94931656b5 cmake: Use newer signature of `qt6_add_lrelease` when available 2025-07-10 16:45:15 +01:00
MarcoFalke fad191ff48
ci: Avoid cd into build dir
Changing into the build dir is confusing and brittle.

This can be reviewed using the git option `--word-diff-regex=.`.

Also:
* add missing -j1 to the fallback that prints a verbose build failure
* remove quotes around $GOAL in the fallback
2025-07-10 16:39:15 +02:00
merge-script b80ead8a71
Merge bitcoin/bitcoin#32890: bench: Avoid tmp files in pwd
fa2fbaa4a2 bench: Avoid tmp files in pwd (MarcoFalke)

Pull request description:

  It is a bit confusing that one bench run, when aborted, could leave behind temp files in the current working directory. It is similarly confusing to delete those files in the next run of bench.

  Fix all issues by using `BasicTestingSetup`, which provides a proper temp folder to use and also cleans up after itself.

  Can be tested via:

  ```
  ( echo 'my file content' > streams_tmp ) && ls streams_tmp && ./bld-cmake/bin/bench_bitcoin --filter=FindByte && ls streams_tmp
  ```

  Previously the file would be deleted, now it is kept.

ACKs for top commit:
  stickies-v:
    ACK fa2fbaa4a2

Tree-SHA512: 33798030f990d1b4c95be4682d8dbfad95e8716d5fc0b99d65937196f2ced1ba649193c2adba4155f4eec9fd06e16be6667f3c3705af1880f47b2ff57a76243b
2025-07-10 13:34:39 +01:00
merge-script c4f90900b5
Merge bitcoin/bitcoin#32932: test: Add missing convert_to_json_for_cli
fa0528479d test: Add missing convert_to_json_for_cli (MarcoFalke)

Pull request description:

  Currently the tests are failing on current master, if they use the `--usecli` flag. See https://github.com/bitcoin/bitcoin/runs/45676472375, https://cirrus-ci.com/task/5707897310543872.

  This can be reproduced locally via:

  ```
  ./bld-cmake/test/functional/wallet_reorgsrestore.py --usecli
  ```

  Fix it by adding the missing `hash_or_height=self.convert_to_json_for_cli(tip)` for the value that could either be a string (needs quotes in json), or a number (does not need quotes in json).

ACKs for top commit:
  fanquake:
    ACK fa0528479d

Tree-SHA512: 3d6deafca1249b2266cfabcd883edc9daaf985c417035a4b0223da4693f4165f8c9ce91a0e128d626000c10c32fe31f323f4b3f6ea0d0b3a771237a4f1d4cf44
2025-07-10 11:04:02 +01:00
MarcoFalke fa894b0f3e
log: Properly log warnings with warn loglevel in addrdb 2025-07-10 11:24:40 +02:00
merge-script 83ae7802fe
Merge bitcoin/bitcoin#32881: test: Turn rpcauth.py test into functional test
fa4d68cf97 Turn rpcauth.py test into functional test (MarcoFalke)

Pull request description:

  Currently the `rpcauth-test.py` is problematic, because:

  * The boilerplate for the test runner is duplicate or inconsistent with the other (functional) tests. Specifically `ConfigParser`.
  * The cmake/ci behavior is brittle and can silently fail, as explained in https://github.com/bitcoin/bitcoin/issues/31476.
  * Outside of ctest, this single test has to be run manually and separately, which is easy to forget.
  * If the test is manually called, it runs single threaded, when it could just run in parallel with the other functional tests.
  * It is also the only "unit" test written in Python, but not called by the functional test runner.

  Fix all issues by turning it into a functional test.

ACKs for top commit:
  l0rinc:
    ACK fa4d68cf97
  janb84:
    LGTM ACK fa4d68cf97
  w0xlt:
    ACK fa4d68cf97

Tree-SHA512: a3b2b03be31c33288dee23c544b33ec43295e796c2047777597ceb86acce9f697478e32d891aa986c1d7d5749d62eded65eeb858e9d7479bda7a400eb1167040
2025-07-10 10:00:30 +01:00
MarcoFalke fa0528479d
test: Add missing convert_to_json_for_cli 2025-07-10 10:59:55 +02:00
Ava Chow a40e953658
Merge bitcoin/bitcoin#30479: validation: Add eligible ancestors of reconsidered block to setBlockIndexCandidates
8cc3ac6c23 validation: Don't use IsValid() to filter for invalid blocks (Martin Zumsande)
86d98b94e5 test: verify that ancestors of a reconsidered block can become the chain tip (stratospher)
3c39a55e64 validation: Add ancestors of reconsiderblock to setBlockIndexCandidates (Martin Zumsande)

Pull request description:

  When we call `reconsiderblock` for some block,  `Chainstate::ResetBlockFailureFlags` puts the descendants of that block into `setBlockIndexCandidates` (if they meet the criteria, i.e. have more work than the tip etc.), but never put any ancestors into the set even though we do clear their failure flags.

  I think that this is wrong, because `setBlockIndexCandidates` should always contain all eligible indexes that have at least as much work as the current tip, which can include ancestors of the reconsidered block. This is being checked by `CheckBlockIndex()`, which could fail if it was invoked after `ActivateBestChain` connects a block and releases `cs_main`:
  ``` diff
  diff --git a/src/validation.cpp b/src/validation.cpp
  index 7b04bd9a5b..ff0c3c9f58 100644
  --- a/src/validation.cpp
  +++ b/src/validation.cpp
  @@ -3551,6 +3551,7 @@ bool Chainstate::ActivateBestChain(BlockValidationState& state, std::shared_ptr<
               }
           }
           // When we reach this point, we switched to a new tip (stored in pindexNewTip).
  +        m_chainman.CheckBlockIndex();
   
           if (exited_ibd) {
               // If a background chainstate is in use, we may need to rebalance our
  ```
  makes `rpc_invalidateblock.py` fail on master.

  Even though we don't currently have a `CheckBlockIndex()` in that place, after `cs_main` is released other threads could invoke it, which is happening in the rare failures of #16444 where an invalid header received from another peer could trigger a `CheckBlockIndex()` call that would fail.

  Fix this by adding eligible ancestors to `setBlockIndexCandidates` in `Chainstate::ResetBlockFailureFlags` (also simplifying that function a bit).

  Fixes #16444

ACKs for top commit:
  achow101:
    ACK 8cc3ac6c23
  TheCharlatan:
    Re-ACK 8cc3ac6c23
  stratospher:
    reACK 8cc3ac6.

Tree-SHA512: 53f27591916246be4093d64b86a0494e55094abd8c586026b1247e4a36747bc3d6dbe46dc26ee4a22f47b8eb0d9699d13e577dee0e7198145f3c9b11ab2a30b7
2025-07-09 16:55:43 -07:00
Ava Chow 1ca62edd85
Merge bitcoin/bitcoin#32580: wallet, test: best block locator matches scan state follow-ups
1b5c545e82 wallet, test: best block locator matches scan state follow-ups (rkrux)

Pull request description:

  Few follows-ups from #30221: Use `SetLastBlockProcessedInMem` more in `AttachChain`, add not null locator check in `WriteBestBlock`. Add log and few assertions in `wallet_reorgstore` test.

ACKs for top commit:
  achow101:
    ACK 1b5c545e82
  pablomartin4btc:
    cr-ACK 1b5c545e82

Tree-SHA512: 34edde55beef5714cea2e1131c29b57da2dc32ea091cd81878014de503c128f02c3ab88aee1e456541d7937e033dca5a81b03e9e2888cf781d71b62ad9b5ca5c
2025-07-09 14:35:13 -07:00
merge-script 2cad7226c2
Merge bitcoin/bitcoin#32799: mempool: use `FeeFrac` for ancestor/descendant score comparators
922adf66ac mempool: use `FeeFrac` for calculating regular score (Sebastian Falbesoner)
3322b3a059 mempool: use `FeeFrac` for calculating ancestor score (Sebastian Falbesoner)
ac9c113bd2 mempool: use `FeeFrac` for calculating descendant score (Sebastian Falbesoner)

Pull request description:

  Rather than determining fee-rates for the mempool index scores and comparators manually in a rather tedious way (even involving floating-points), use the `FeeFrac` class [1] to simplify and deduplicate the code. Note that though this is intended to be a refactoring PR, there might be subtle differences in behaviour due to floating-point arithmetic involved in the original code (to avoid overflows at the cost of precision loss), but these shouldn't matter.

  [1] introduced in PR #29242, commit ce8e22542e

ACKs for top commit:
  ismaelsadeeq:
    Code review ACK 922adf66ac
  glozow:
    ACK 922adf66ac

Tree-SHA512: 6c3a9436f2be668aa8561b40c1b93efa7dc97b4ef354e98233ac3d3286a88804668164a55f2fcce4239fee5830e4e70f520e6285b667b87baa65c7cec09159cf
2025-07-09 15:15:53 -04:00
merge-script 2d59977601
Merge bitcoin/bitcoin#32604: log: Mitigate disk filling attacks by rate limiting LogPrintf, LogInfo, LogWarning, LogError
4c772cbd83 doc: add release notes for new rate limiting logging behavior (Eugene Siegel)
d541409a64 log: Add rate limiting to LogPrintf, LogInfo, LogWarning, LogError, LogPrintLevel (Eugene Siegel)
a6a35cc0c2 log: use std::source_location in place of __func__, __FILE__, __LINE__ (Eugene Siegel)
afb9e39ec5 log: introduce LogRateLimiter, LogLimitStats, Status (Eugene Siegel)
df7972a6cf test: Mark ~DebugLogHelper as noexcept(false) (Eugene Siegel)

Pull request description:

  This revives the work done by dergoegge in https://github.com/bitcoin/bitcoin/pull/21603. The approach is similar — this PR uses `std::source_location` under the hood now that we can use c++20 features. It also resets the rate limiting statistics via the `CScheduler`. The logging functions have also changed slightly since that PR was opened, so work has been done to preserve the intent of the original rate limiting change. I have tried to give commit attribution where possible.

  **Approach:**
  Each source code location is given an hourly logging quota of 1MiB of logging per hour. Logging is only dropped from source locations that exceed the quota.
  - Only logging to disk is rate limited. Logging to console is not rate limited.
  - Printing with the category argument is not rate limited.
  - `UpdateTip: new best=[…]` is logged without rate limiting. High log volume is expected for that source location during IBD.
  - When logging is restarted a tally of how many bytes were dropped is printed.
  - All logs will be prefixed with [*] if there is at least one source location that is currently being suppressed.

  I've repurposed the old logging rpc mentioned in #21603 in another branch for testing [here](https://github.com/Crypt-iQ/bitcoin/tree/log_ratelimiting_05192025_rpc). This can be used to log from source locations and test out the new changes in logging behavior. Note that the `setmocktime` RPC needs to be used to set the mock time past the current clock time to reset the logging messages.

  Example usage:
  ```
  bitcoin-cli -regtest excessivelog 1 1048500 # log just under 1MiB
  bitcoin-cli -regtest excessivelog 1 100 # this should get the total amount logged above 1MiB
                                          # and the rate limiting logic should kick in
  bitcoin-cli -regtest excessivelog 2 1048500
  bitcoin-cli -regtest excessivelog 2 100 # trigger rate limiting from another location
  bitcoin-cli -regtest mockscheduler 3600 # fast-forward the scheduler
  bitcoin-cli -regtest excessivelog 1 100 # this should trigger logging to resume and will log the source locations that were reset
  ```

  Example output:
  ```
  2025-07-02T22:03:56Z [warning] Excessive logging detected from rpc/node.cpp:142 (RPCHelpMan excessivelog()): >1048576 bytes logged during the last time window of 3600s. Suppressing logging to disk from this source location until time window resets. Console logging unaffected. Last log entry.
  [*] 2025-07-02T22:03:56Z aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  2025-07-02T22:04:58Z (mocktime: 2262-04-11T23:47:15Z) Restarting logging from rpc/node.cpp:142 (RPCHelpMan excessivelog()): 121 bytes were dropped during the last 3600s.
  2025-07-02T22:04:58Z (mocktime: 2262-04-11T23:47:15Z) Restarting logging from rpc/node.cpp:139 (RPCHelpMan excessivelog()): 121 bytes were dropped during the last 3600s.
  ```

ACKs for top commit:
  maflcko:
    re-ACK 4c772cbd83 🕚
  glozow:
    reACK 4c772cb
  stickies-v:
    re-ACK 4c772cbd83, no changes except release notes update

Tree-SHA512: d07087cd0f2b188100b51c9b8c3da376fa24ec3612a2a284bd83f650bba0ea409f9fa0acd5f3b10f45e664ef4fdf3abc97ed3da08098d2beb599cc83e3fc4504
2025-07-09 14:43:39 -04:00
Eugene Siegel 4c772cbd83
doc: add release notes for new rate limiting logging behavior 2025-07-09 09:13:00 -04:00
Eugene Siegel d541409a64
log: Add rate limiting to LogPrintf, LogInfo, LogWarning, LogError, LogPrintLevel
To mitigate disk-filling attacks caused by unsafe usages of LogPrintf and
friends, we rate-limit them by passing a should_ratelimit bool that
eventually makes its way to LogPrintStr which may call
LogRateLimiter::Consume. The rate limiting is accomplished by
adding a LogRateLimiter member to BCLog::Logger which tracks source
code locations for the given logging window.

Every hour, a source location can log up to 1MiB of data. Source
locations that exceed the limit will have their logs suppressed for the
rest of the window determined by m_limiter.

This change affects the public LogPrintLevel function if called with
a level >= BCLog::Level::Info.

The UpdateTipLog function has been changed to use the private LogPrintLevel_
macro with should_ratelimit set to false. This allows UpdateTipLog to log
during IBD without hitting the rate limit.

Note that on restart, a source location that was rate limited before the
restart will be able to log until it hits the rate limit again.

Co-Authored-By: Niklas Gogge <n.goeggi@gmail.com>
Co-Authored-By: stickies-v <stickies-v@protonmail.com>
2025-07-09 09:13:00 -04:00
Eugene Siegel a6a35cc0c2
log: use std::source_location in place of __func__, __FILE__, __LINE__
The std::source_location conveniently stores the file name, line number,
and function name of a source code location. We switch to using it instead
of the __func__ identifier and the __FILE__ and __LINE__ macros.

BufferedLog is changed to have a std::source_location member, replacing the
source_file, source_line, and logging_function members. As a result,
MemUsage no longer explicitly counts source_file or logging_function as the
std::source_location memory usage is included in the MallocUsage call.

This also changes the behavior of -logsourcelocations as std::source_location
includes the entire function signature. Because of this, the functional test
feature_config_args.py must be changed to no longer include the function
signature as the function signature can differ across platforms.

Co-Authored-By: Niklas Gogge <n.goeggi@gmail.com>
Co-Authored-By: stickies-v <stickies-v@protonmail.com>
2025-07-09 09:12:59 -04:00
Eugene Siegel afb9e39ec5
log: introduce LogRateLimiter, LogLimitStats, Status
LogRateLimiter will be used to keep track of source locations and our
current time-based logging window. It contains an unordered_map and a
m_suppressions_active bool to track source locations. The map is keyed
by std::source_location, so a custom Hash function (SourceLocationHasher)
and custom KeyEqual function (SourceLocationEqual) is provided.
SourceLocationHasher uses CSipHasher(0,0) under the hood to get a
uniform distribution.

A public Reset method is provided so that a scheduler (e.g. the
"b-scheduler" thread) can periodically reset LogRateLimiter's state when
the time window has elapsed.

The LogRateLimiter::Consume method checks if we have enough available
bytes in our rate limiting budget to log an additional string. It
returns a Status enum that denotes the rate limiting status and can
be used by the caller to emit a warning, skip logging, etc.

The Status enum has three states:
- UNSUPPRESSED     (logging was successful)
- NEWLY_SUPPRESSED (logging was succcesful, next log will be suppressed)
- STILL_SUPPRESSED (logging was unsuccessful)

LogLimitStats counts the available bytes left for logging per source
location for the current logging window. It does not track actual source
locations; it is used as a value in m_source_locations.

Also exposes a SuppressionsActive() method so the logger can use
that in a later commit to prefix [*] to logs whenenever suppressions
are active.

Co-Authored-By: Niklas Gogge <n.goeggi@gmail.com>
Co-Authored-By: stickies-v <stickies-v@protonmail.com>
2025-07-09 09:12:59 -04:00
Eugene Siegel df7972a6cf
test: Mark ~DebugLogHelper as noexcept(false)
We mark ~DebugLogHelper as noexcept(false) to be able to catch the
exception it throws. This lets us use it in test in combination with
BOOST_CHECK_THROW and BOOST_CHECK_NO_THROW to check that certain log
messages are (not) logged.

Co-Authored-By: Niklas Gogge <n.goeggi@gmail.com>
2025-07-09 09:12:59 -04:00
MarcoFalke fa8862723c
fuzz: CheckGlobals in init 2025-07-09 14:28:23 +02:00
MarcoFalke fa26bfde98
test: Avoid resetting mocktime in testing setup
This allows to set the mocktime before the testing setup.

Also, in some fuzz tests the mocktime was reset to 0 before this change,
so set it.
2025-07-09 14:28:14 +02:00
MarcoFalke fa6b45fa8e
Add SetMockTime for time_point types 2025-07-09 13:57:54 +02:00
marcofleon a60f863d3e scripted-diff: Replace GenTxidVariant with GenTxid
-BEGIN VERIFY SCRIPT-
sed -i 's/GenTxidVariant/GenTxid/g' $(git grep -l 'GenTxidVariant')
-END VERIFY SCRIPT-
2025-07-08 20:00:51 +01:00
marcofleon c8ba199598 Remove old GenTxid class 2025-07-08 20:00:51 +01:00
marcofleon 072a198ea4 Convert remaining instances of GenTxid to GenTxidVariant 2025-07-08 20:00:51 +01:00
marcofleon 1b528391c7 Convert `txrequest` to GenTxidVariant
Switch all instances of GenTxid to the new variant
in `txrequest` and complete `txdownloadman_impl` by
converting `GetRequestsToSend`.
2025-07-08 20:00:51 +01:00
marcofleon bde4579b07 Convert `txdownloadman_impl` to GenTxidVariant
Convert all of `txdownloadman_impl` to the new variant except for
`GetRequestsToSend`, which will be easier to switch at the same
time as `txrequest`.
2025-07-08 20:00:43 +01:00
marcofleon c876a892ec Replace GenTxid with Txid/Wtxid overloads in `txmempool`
Co-authored-by: stickies-v <stickies-v@protonmail.com>
2025-07-08 19:31:02 +01:00
stickies-v de858ce2be move-only: make GetInfo a private CTxMemPool member
This allows it to be used by templated functions in a future commit.
2025-07-08 19:30:48 +01:00
Sjors Provoost 4bb4c86599
test: document HOST for get_previous_releases.py 2025-07-08 20:22:46 +02:00
Sjors Provoost 609203d507
test: stop signing previous releases >= v28.2 2025-07-08 20:22:23 +02:00
Sjors Provoost c6dc2c29f8
test: replace v28.0 with notarized v28.2
Since #31407 guix builds are signed and notarized. This was backported to v28, so bump the version.
2025-07-08 18:04:05 +02:00
Sjors Provoost 5bd73d96a3
test: fix macOS detection 2025-07-08 18:04:02 +02:00
marcofleon eee473d9f3 Convert `CompareInvMempoolOrder` to GenTxidVariant
Now that we are storing `CTxMemPool::CompareDepthAndScore` parameters using
`std::variant` we have no portable zero-overhead way of accessing them,
so use `std::visit` and drop `bool wtxid` in-parameter.

Co-authored-by: stickies-v <stickies-v@protonmail.com>
2025-07-08 16:03:05 +01:00
merge-script b7e9dc8e46
Merge bitcoin/bitcoin#32884: rest: replace `rf_names[0].rf` by `RESTResponseFormat::UNDEF`
6d19815cd4 rest: replace `rf_names[0].rf` by `RESTResponseFormat::UNDEF` for code clarity (Eval EXEC)

Pull request description:

  I'm reviewing the bitcoin's rest.cpp source code.
  In the function: `ParseDataFormat`, `rf_names[0].rf` is actualy `RESTResponseFormat::UNDEF`:
  e3f416dbf7/src/rest.cpp (L48-L57)
  so it would be more clarity and code readability to use `return RESTResponseFormat::UNDEF;` to replace `return rf_names[0].rf;`

ACKs for top commit:
  maflcko:
    lgtm ACK 6d19815cd4
  brunoerg:
    code review ACK 6d19815cd4

Tree-SHA512: 420454f1cc09db44c1d76423d8623a0b8865d41d6c34015844ff83d78a9373e3e26f3f62818d1502b33eb063caf904750e858b74ddecd76750577ae82b64b0c1
2025-07-08 15:59:30 +01:00
MarcoFalke fa4d68cf97
Turn rpcauth.py test into functional test 2025-07-08 16:51:17 +02:00
Sjors Provoost 83bb414557
test: less ambiguous error if bitcoind is missing
Before this change, when a functional test is run without building
the source, the error message suggested that previous release binaries
were missing.

When no previous release version is set, make the error message more
specifically about bitcoind.
2025-07-08 13:19:48 +02:00
rkrux 150b5c99ca
wallet: replace `reload_wallet` with inline functionality
Also, update related comments because a reload is not happening
anymore. It is done because the legacy wallets could not have been
loaded prior to migration, so I don't think a reload is happening
post a successful migration, it's just load IMO.
2025-07-08 16:07:30 +05:30
merge-script 927055e42a
Merge bitcoin/bitcoin#32893: doc: fix `BlockConnected` incorrect comment
4e69aa5701 doc: fix `BlockConnected` incorrect comment (ismaelsadeeq)

Pull request description:

  This is a simple PR  that fixes the `BlockConnected` validation interface notification comment, which incorrectly states that a vector of transactions removed from the mempool is as a parameter of the method.

  Originally, this was the case when the method was first introduced in https://github.com/bitcoin/bitcoin/pull/9725

  However, the method has since changed, and this is no longer accurate. Keeping the outdated comment is now misleading.

  This PR removes the information about the method parameters from the docstring, aligning it with the style of other notifications methods. As noticed in this PR, comments listing parameters can become stale and go uncorrected.

  Therefore, this PR simply removes the inaccurate comment without listing the current returned values.

ACKs for top commit:
  l0rinc:
    ACK 4e69aa5701
  maflcko:
    lgtm ACK 4e69aa5701

Tree-SHA512: 3737313f7a9da55c67c78ce01bab5005946f4e1fccbb471560ff3af8c8275cb5cf876f6c53400c93f0ba1fdf134f28766ed573cbe62903127a3129ca8ce88db6
2025-07-08 10:37:56 +01:00
Ava Chow a8bff38236
Merge bitcoin/bitcoin#32862: rpc: use CScheduler for relocking wallet and remove RPCTimer
fcfd3db563 remove RPCTimerInterface and RPCRunLater (Matthew Zipkin)
8a1765795f use WalletContext scheduler for walletpassphrase callback (Matthew Zipkin)

Pull request description:

  This removes the dependency on libevent for events scheduled by RPC commands, like re-locking a wallet some time after decryption with walletpassphrase. Since walletpassphrase is currently the only RPC that does this, `RPCRunLater`, `RPCTimerInterface` and all related methods are left unused, and deleted in the second commit. Any future RPC that needs to execute a callback in the future can follow the pattern in this PR and just use a scheduler from node or wallet context.

  This is an alternative approach to #32796, described in https://github.com/bitcoin/bitcoin/pull/32796#issuecomment-3014309449

ACKs for top commit:
  fjahr:
    Code Review ACK fcfd3db563
  achow101:
    ACK fcfd3db563
  furszy:
    ACK fcfd3db563

Tree-SHA512: 04f5e9c3f73f598c3d41d6e35bb59c64c7b93b03ad9fce3c40901733147ce7764f41f475fef1527d44af18f722759996a31ca83b48cb52153795d5022fecfd14
2025-07-07 17:59:21 -07:00
Ava Chow 21b42f3c55
Merge bitcoin/bitcoin#32660: rpc: Use type-safe exception to pass RPC help
fa946520d2 refactor: Use structured binding for-loop (MarcoFalke)
eeeec1579e rpc: Use type-safe exception to pass RPC help (MarcoFalke)

Pull request description:

  The current "catch-all" `catch (const std::exception& e)` in `CRPCTable::help` is problematic, because it could catch exceptions unrelated to passing the help string up.

  Fix this by using a dedicated exception type.

ACKs for top commit:
  l0rinc:
    tested ACK fa946520d2 (edited)
  achow101:
    ACK fa946520d2
  rkrux:
    re-ACK fa946520d2

Tree-SHA512: 23dac6e0fe925561bfbf421e6a7441d546eed8c1492ac41ca4ed7dfcd12f4d2ef39c35f105a0291aac511365d98f08fbdc9a4f0bf627172873b8f23c2be45e76
2025-07-07 17:47:20 -07:00
Ava Chow 528f79f010
Merge bitcoin/bitcoin#32835: test: fix feature_init.py intermittencies
4207d9bf82 test: feature_init, ensure indexes are synced prior to perturbing files (furszy)
abd07cf733 test: feature_init, only init what's needed per perturbation/deletion round (furszy)

Pull request description:

  Aims to solve #32600. Found it while working on #26966 (this was really annoying there).

  This ensures the node is index-synced before perturbing files.
  If the index sync gets interrupted before it starts, the database could be empty,
  making any following perturbation ineffective (which explains why the node
  does not abort during startup in the #32600 logs).

  Also, the first commit avoids initializing components not under test.
  This reduces log flooding, which helped in understanding the issue.

  Patch to reproduce the issue on master using `feature_init.py` (this simulates
  a node shutting down before the index starts syncing):
  ```
  diff --git a/src/index/base.cpp b/src/index/base.cpp
  --- a/src/index/base.cpp(revision 1e03052c3fefb188f047e72548f2c6b0cc019e50)
  +++ b/src/index/base.cpp(date 1751293306725)
  @@ -185,6 +185,7 @@
   void BaseIndex::Sync()
   {
       const CBlockIndex* pindex = m_best_block_index.load();
  +    m_interrupt();
       if (!m_synced) {
           std::chrono::steady_clock::time_point last_log_time{0s};
           std::chrono::steady_clock::time_point last_locator_write_time{0s};
  ```

ACKs for top commit:
  maflcko:
    lgtm ACK 4207d9bf82 🍄
  achow101:
    ACK 4207d9bf82
  hodlinator:
    ACK 4207d9bf82

Tree-SHA512: c8c89c7af9d473a12756b6a59b97f8fb473500181620eb96ecc10da954fe185d13fbb1d00a4ecb181e8daf149ec93cc547e292da0877522a4d23425fa7fd646b
2025-07-07 17:26:03 -07:00
merge-script fc543f94a9
Merge bitcoin/bitcoin#32385: test: refactor out same-txid-diff-wtxid tx to reuse in other tests
afaaba69ed test: refactor out same-txid-diff-wtxid tx to reuse in other tests (stratospher)

Pull request description:

  It's useful to easily create transactions with same txid, different wtxid and valid witness for testing scenarios in other places in the codebase (ex: private broadcast connections, see https://github.com/bitcoin/bitcoin/pull/29415#discussion_r2055915118)

  So refactor out the current `same-txid-diff-wtxid` transaction in `mempool_accept_wtxid.py` so that it can be reused.

ACKs for top commit:
  maflcko:
    review ACK afaaba69ed 📎
  theStack:
    ACK afaaba69ed
  vasild:
    ACK afaaba69ed

Tree-SHA512: 0fc51ac326725d4abe76a15b6b5be55d070b96c303c444f4dd31c2b0a82f266836382389a123a7f6a71aa35e61fbfae27f843b31cc19474e49f3dc82f36ebf73
2025-07-07 16:37:04 -04:00
merge-script 09add84fc5
Merge bitcoin/bitcoin#32618: wallet: Remove ISMINE_WATCHONLY and watchonly from RPCs
b1a8ac07e9 doc: Release note for removed watchonly parameters and results (Ava Chow)
15710869e1 wallet: Remove ISMINE_WATCH_ONLY (Ava Chow)
4439bf4b41 wallet, spend: Remove fWatchOnly from CCoinControl (Ava Chow)
1337c72198 wallet, rpc: Remove watchonly from RPCs (Ava Chow)
e81d95d435 wallet: Remove watchonly balances (Ava Chow)
d20dc9c6aa wallet: Wallets without private keys cannot grind R (Ava Chow)
9991f49c38 test: Watchonly wallets should estimate larger size (Ava Chow)

Pull request description:

  Descriptor wallets do not use the watchonly behavior as it is not possible to mix watchonly and non-watchonly in a descriptor wallet. With legacy wallets now removed, all of the watchonly handling and reporting code is no longer needed. This PR removes watchonly options and results from the RPCs and the handling of watchonly things from the wallet's internals.

  With all of the watchonly things removed, ISMINE_WATCH_ONLY is removed as well.

  Split from #32523

  Depends on #32594 for tests that are easier to read

ACKs for top commit:
  Eunovo:
    ACK b1a8ac07e9
  maflcko:
    re-ACK b1a8ac07e9 🌈
  rkrux:
    ACK b1a8ac07e9
  furszy:
    light code review ACK b1a8ac07e9

Tree-SHA512: bc87f37a13294f7208991be8f93899b49e5bdf87c70e0f66d9c4cb09c03be6c202320406f27e9a35aa2f57319d19a3f0c07d5e5ddbc97c7edab165b1656d6612
2025-07-07 16:28:33 -04:00
merge-script 87ab69155d
Merge bitcoin/bitcoin#31553: cluster mempool: add TxGraph reorg functionality
1632fc104b txgraph: Track multiple potential would-be clusters in Trim (improvement) (Pieter Wuille)
4608df37e0 txgraph: add Trim benchmark (benchmark) (Pieter Wuille)
9c436ff01c txgraph: add fuzz test scenario that avoids cycles inside Trim() (tests) (Pieter Wuille)
938e86f8fe txgraph: add unit test for TxGraph::Trim (tests) (glozow)
a04e205ab0 txgraph: Add ability to trim oversized clusters (feature) (Pieter Wuille)
eabcd0eb6f txgraph: remove unnecessary m_group_oversized (simplification) (Greg Sanders)
19b14e61ea txgraph: Permit transactions that exceed cluster size limit (feature) (Pieter Wuille)
c4287b9b71 txgraph: Add ability to configure maximum cluster size/weight (feature) (Pieter Wuille)

Pull request description:

  Part of cluster mempool (#30289).

  During reorganisations, it is possible that dependencies get added which would result in clusters that violate policy limits (cluster count, cluster weight), when linking the new from-block transactions to the old from-mempool transactions. Unlike RBF scenarios, we cannot simply reject the changes when they are due to received blocks. To accommodate this, add a `TxGraph::Trim()`, which removes some subset of transactions (including descendants) in order to make all resulting clusters satisfy the limits.

  Conceptually, the way this is done is by defining a rudimentary linearization for the entire would-be too-large cluster, iterating it from beginning to end, and reasoning about the counts and weights of the clusters that would be reached using transactions up to that point. If a transaction is encountered whose addition would violate the limit, it is removed, together with all its descendants.

  This rudimentary linearization is like a merge sort of the chunks of the clusters being combined, but respecting topology. More specifically, it is continuously picking the highest-chunk-feerate remaining transaction among those which have no unmet dependencies left. For efficiency, this rudimentary linearization is computed lazily, by putting all viable transactions in a heap, sorted by chunk feerate, and adding new transactions to it as they become viable.

  The `Trim()` function is rather unusual compared to the `TxGraph` functionality added in previous PRs, in that `Trim()` makes it own decisions about what the resulting graph contents will be, without good specification of how it makes that decision - it is just a best-effort attempt (which is improved in the last commit). All other `TxGraph` mutators are simply to inform the graph about changes the calling mempool code decided on; this one lets the decision be made by txgraph.

  As part of this, the "oversized" property is expanded to also encompass a configurable cluster weight limit (in addition to cluster count limit).

ACKs for top commit:
  instagibbs:
    reACK 1632fc104b
  glozow:
    reACK 1632fc104b via range-diff
  ismaelsadeeq:
    reACK 1632fc104b 🛰️

Tree-SHA512: ccacb54be8ad622bd2717905fc9b7e42aea4b07f824de1924da9237027a97a9a2f1b862bc6a791cbd2e1a01897ad2c7c73c398a2d5ccbce90bfbeac0bcebc9ce
2025-07-07 16:11:51 -04:00
ismaelsadeeq 4e69aa5701 doc: fix `BlockConnected` incorrect comment 2025-07-07 18:14:52 +01:00
merge-script d33c111448
Merge bitcoin/bitcoin#32829: threading: use correct mutex name in reverse_lock fatal error messages
de4eef52d1 threading: use correct mutex name in reverse_lock fatal error messages (Cory Fields)

Pull request description:

  "Now that REVERSE_LOCK requires the name of the actual mutex, it can be used for better error messages." - theuni

  This is a follow-up to this comment https://github.com/bitcoin/bitcoin/pull/32465#issuecomment-2981287545

  I just cherry-picked the commit 85c2848eb575f4abaa81fdd4e8f3b2048693dd98

ACKs for top commit:
  theuni:
    Re-ACK de4eef52d1
  TheCharlatan:
    ACK de4eef52d1

Tree-SHA512: 1109381e1f0589093f7c737cb1ebd1c43324a9e1ea34b5f05a9171d06ab44cca0c5ead43c581f6e37ded1f0463ab8a280f3319c288d39a4625109b5c08a7cb68
2025-07-07 15:51:37 +01:00
Cory Fields de4eef52d1
threading: use correct mutex name in reverse_lock fatal error messages
Now that REVERSE_LOCK requires the name of the actual mutex, it can be used for
better error messages.
2025-07-07 10:34:05 -04:00
MarcoFalke fa2fbaa4a2
bench: Avoid tmp files in pwd 2025-07-07 13:11:26 +02:00
Pol Espinasa d3b8a54a81
Refactor CFeeRate to use FeeFrac internally
Co-authored-by: Abubakar Sadiq Ismail <48946461+ismaelsadeeq@users.noreply.github.com>
2025-07-07 10:39:45 +02:00
Eval EXEC 6d19815cd4 rest: replace `rf_names[0].rf` by `RESTResponseFormat::UNDEF` for code clarity 2025-07-06 11:20:18 +08:00
Ryan Ofsky f49840dd90 doc: Fix typo in files.md
Suggested by l0rinc https://github.com/bitcoin/bitcoin/pull/31679#discussion_r2185083314
2025-07-04 11:06:30 -04:00
furszy 4207d9bf82
test: feature_init, ensure indexes are synced prior to perturbing files 2025-07-04 09:45:49 -04:00
Ava Chow e3f416dbf7
Merge bitcoin/bitcoin#32463: test: fix an incorrect `feature_fee_estimation.py` subtest
9b75cfda4d test: retain the intended behavior of `feature_fee_estimation.py` nodes (ismaelsadeeq)
5c1236f04a test: fix incorrect subtest in `feature_fee_estimation.py` (ismaelsadeeq)

Pull request description:

  Attempt to fix #32461

  In the `estimatesmartfee` RPC, we return the maximum of the following: the feerate estimate for the target, `minrelaytxfee`, and `mempoolminfee`.

  9a05b45da6/src/rpc/fees.cpp (L85)

  The test `test_feerate_mempoolminfee`, originally introduced in ea31caf6b4, is incorrect.

  It should calculate the fee rate ceiling by taking the maximum of the custom `minrelaytxfee`, `mempoolminfee`, and the highest fee rate observed during the test (`check_smart_estimates`). This is necessary because:

  * There is no guarantee that the generated fee rates will exceed both `minrelaytxfee` and `mempoolminfee`.
  * Users can start a node with custom fee settings.

  Due to the non-deterministic nature of the `feature_fee_estimation.py` test, it often passes by chance. The randomly generated fees typically include a value higher than the custom `minrelaytxfee`, inadvertently hiding the issue.

  Issue #32461 identified a random seeds that consistently fails the test because the generated fees never exceed the custom `minrelaytxfee`:

  e.g
  ```
  build/test/functional/feature_fee_estimation.py --random=3450808900320758527
  ```

  This PR has two commits which :

  * Correctly fixes the test by calculating the fee rate ceiling as the maximum of the node `minrelaytxfee`, `mempoolminfee`, and the highest seen fee rate, when verifying smart fee estimates.
  * Improves the subtest name and comment for clarity.
  * Restores the original test behavior by appending 4000 WU to the custom `blockmaxweight`.

ACKs for top commit:
  achow101:
    ACK 9b75cfda4d
  glozow:
    ACK 9b75cfda4d
  theStack:
    Light ACK 9b75cfda4d

Tree-SHA512: 0f7fb0496b50a399b58f6fb1afd95414fad454795fbc0046e22dfc54a2062ae0c519a12ebfeb6ad7ef547438868d99eca2351c0d19d0346adaadb500eff6f15f
2025-07-03 16:45:29 -07:00
Ava Chow ea4285775e
Merge bitcoin/bitcoin#29307: util: explicitly close all AutoFiles that have been written
c10e382d2a flatfile: check whether the file has been closed successfully (Vasil Dimov)
4bb5dd78ea util: check that a file has been closed before ~AutoFile() is called (Vasil Dimov)
8bb34f07df Explicitly close all AutoFiles that have been written (Vasil Dimov)
a69c4098b2 rpc: take ownership of the file by WriteUTXOSnapshot() (Hodlinator)

Pull request description:

  `fclose(3)` may fail to flush the previously written data to disk, thus a failing `fclose(3)` is as serious as a failing `fwrite(3)`.

  Previously the code ignored `fclose(3)` failures. This PR improves that by changing all users of `AutoFile` that use it to write data to explicitly close the file and handle a possible error.

  ---

  Other alternatives are:

  1. `fflush(3)` after each write to the file (and throw if it fails from the `AutoFile::write()` method) and hope that `fclose(3)` will then always succeed. Assert that it succeeds from the destructor 🙄. Will hurt performance.
  2. Throw nevertheless from the destructor. Exception within the exception in C++ I think results in terminating the program without a useful message.
  3. (this is implemented in the latest incarnation of this PR) Redesign `AutoFile` so that its destructor cannot fail. Adjust _all_ its users 😭. For example, if the file has been written to, then require the callers to explicitly call the `AutoFile::fclose()` method before the object goes out of scope. In the destructor, as a sanity check, assume/assert that this is indeed the case. Defeats the purpose of a RAII wrapper for `FILE*` which automatically closes the file when it goes out of scope and there are a lot of users of `AutoFile`.
  4. Pass a new callback function to the `AutoFile` constructor which will be called from the destructor to handle `fclose()` errors, as described in https://github.com/bitcoin/bitcoin/pull/29307#issuecomment-2243842400. My thinking is that if that callback is going to only log a message, then we can log the message directly from the destructor without needing a callback. If the callback is going to do more complicated error handling then it is easier to do that at the call site by directly calling `AutoFile::fclose()` instead of getting the `AutoFile` object out of scope (so that its destructor is called) and inspecting for side effects done by the callback (e.g. set a variable to indicate a failed `fclose()`).

ACKs for top commit:
  l0rinc:
    ACK c10e382d2a
  achow101:
    ACK c10e382d2a
  hodlinator:
    re-ACK c10e382d2a

Tree-SHA512: 3994ca57e5b2b649fc84f24dad144173b7500fc0e914e06291d5c32fbbf8d2b1f8eae0040abd7a5f16095ddf4e11fe1636c6092f49058cda34f3eb2ee536d7ba
2025-07-03 15:37:44 -07:00
Ryan Ofsky f5cf0b1ccc bitcoin wrapper: improve help output
Try to make extra commands more obvious based on a suggestion from Sjors:
https://github.com/bitcoin/bitcoin/pull/31679#issuecomment-2922787970i

When `bitcoin` is invoked with no arguments, still show short help output, but
now explicitly state that more commands are available and `bitcoin help` will
list them.

Also:

- Get rid of -a/--all option. Just show all commands when `bitcoin help` or
  `bitcoin --help` is used. It maybe a helpful to add an option like this if
  more commands are added in the future, but right now there are not very many.

- Just show name of executable, not full path of executable in help output. This
  can be a little easier to read if the path is long.
2025-07-03 17:03:00 -04:00
merge-script 51ccc71b1b
Merge bitcoin/bitcoin#32858: doc: Add workaround for vcpkg issue with paths with embedded spaces
0a1af4418e doc: Add workaround for vcpkg issue with paths with embedded spaces (Hennadii Stepanov)

Pull request description:

  This PR is an alternative to https://github.com/bitcoin/bitcoin/pull/32397 suggested in https://github.com/bitcoin/bitcoin/pull/32397#issuecomment-2883438040.

ACKs for top commit:
  sipsorcery:
    ACK 0a1af4418e.

Tree-SHA512: 09efc3f8b8c38eb8d8de1022c5b11685fba334cdb950209d35b3b0d907fa50de3f85f45c66ac3670b5b104d5bb0b01461c36a0c1e595327b5e62c6abca323deb
2025-07-03 16:24:13 +01:00
Matthew Zipkin fcfd3db563
remove RPCTimerInterface and RPCRunLater 2025-07-03 06:26:23 -04:00
Matthew Zipkin 8a1765795f
use WalletContext scheduler for walletpassphrase callback 2025-07-03 06:26:13 -04:00
merge-script 927e9b220f
Merge bitcoin/bitcoin#32716: depends: Override host compilers for FreeBSD and OpenBSD
4f10a57671 depends: Override host compilers for FreeBSD and OpenBSD (Hennadii Stepanov)

Pull request description:

  When building depends on FreeBSD/OpenBSD `aarch64`, the host compilers default to `default_host_{CC,CXX}`, which resolves to `gcc`/`g++`. This is incorrect on these systems, where Clang is the default system compiler.

  To ensure proper compiler selection, this PR adopts the same approach used for `darwin`:c1d4253d31/depends/builders/darwin.mk (L12-L14)

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

ACKs for top commit:
  Sjors:
    ACK 4f10a57671

Tree-SHA512: 66ace60b63671f2ab7facb84776298e1489aa0a984559c9a22323adaaedcc86f67158078b18c333cb7bdc2b17a4573e321ee7361596bc941db060c5659014069
2025-07-03 11:00:45 +01:00
merge-script c7fe8abb5f
Merge bitcoin/bitcoin#31233: cmake: Improve Python robustness and test usability
67dc7523f3 cmake, test: Disable tests instead of ignoring them (Hennadii Stepanov)
bb9157db5d cmake, refactor: Switch to `Python3::Interpreter` imported target (Hennadii Stepanov)

Pull request description:

  This PR:

  1. Switches to a modern CMake approach by using the `Python3::Interpreter` imported target, which is more robust than using variables.

  2. Disables the `util_rpcauth_test` test explicitly instead of silently ignoring it.

  A build and test log for the case when Python is unavailable is provided below:
  ```
  $ cmake -B build
  $ cmake --build build -j 16
  $ ctest --test-dir build -j $(nproc) -R "^util"
  Internal ctest changing into directory: /bitcoin/build
  Test project /bitcoin/build
      Start 115: util_tests
      Start 117: util_trace_tests
      Start 114: util_string_tests
      Start 116: util_threadnames_tests
      Start   1: util_rpcauth_test
  1/5 Test   #1: util_rpcauth_test ................***Not Run (Disabled)   0.00 sec
  2/5 Test #114: util_string_tests ................   Passed    0.11 sec
  3/5 Test #117: util_trace_tests .................   Passed    0.11 sec
  4/5 Test #116: util_threadnames_tests ...........   Passed    0.11 sec
  5/5 Test #115: util_tests .......................   Passed    0.13 sec

  100% tests passed, 0 tests failed out of 4

  Total Test time (real) =   0.13 sec

  The following tests did not run:
    1 - util_rpcauth_test (Disabled)
  ```

ACKs for top commit:
  purpleKarrot:
    ACK 67dc7523f3
  janb84:
    tACK 67dc7523f3

Tree-SHA512: 5fc7ebe31ac03f4b8a53ecfcfc1cace0f647a1d2c989651988edae96bdfbbe2dee171714e57cb028e65ead1bb40806a82d9821746451dbf005538601fd33ea88
2025-07-03 10:47:25 +01:00
merge-script 6251949443
Merge bitcoin/bitcoin#32290: test: allow all functional tests to be run or skipped with --usecli
666016e56b ci: use --usecli in one of the CI jobs (Martin Zumsande)
7ea248a020 test: Disable several (sub)tests with cli (Martin Zumsande)
f420b6356b test: skip subtests that check for wrong types with cli (Martin Zumsande)
6530d0015b test: add function to convert to json for height_or_hash params (Martin Zumsande)
54d28722ba test: Don't send empty named args with cli (Martin Zumsande)
cca422060e test: convert tuple to json for cli (Martin Zumsande)
af34e98086 test: make rpc_psbt.py usable with --usecli (Martin Zumsande)
8f8ce9e174 test: rename .rpc to ._rpc and remove unnecessary uses (Martin Zumsande)
5b08885986 test: enable functional tests with large rpc args for cli (Martin Zumsande)
7d5352ac73 test: use -stdin for large rpc commands (Martin Zumsande)
6c364e0c10 test: Enable various tests for usage with cli (Martin Zumsande)

Pull request description:

  Fixes #32264

  I looked into all current failures listed in the issue, as well all tests that are already disabled for the cli with `self.supports_cli = False`. There are several reasons why existing tests fail  with `--usecli` on many systems, the most important ones are:

  - Most common reason is that the test executes a RPC call with a large arg that exceeds `MAX_ARG_STRLEN` of the OS, which is usually 128kb on linux: This is fixed by using `-stdin` for these large calls (idea by 0xB10C)
  - they test specifically the rpc interface - nothing to do there except disabling.
  - Some functional test submit wrong types to params on purpose to test the error message (which is different when using the cli) - deactivated these specific subtests locally for the cli when there is just one or two of them, deactivated the entire tests when there are more spots
  - When python sets `None` for an arg, the cli converts this to 'null' in `arg_to_cli`. This is fine e.g. for boolean args, but doesn't work for strings where it's interpreted as the string 'null'. Bypass this for named args by not including args in case the value is `None` for the cli is used (it's effectively the same as leaving the optional arg out).
  -  the `height_or_hash` param used in some RPC needs to be converted to a JSON (effectively adding full quotes).
  - Some tests were marked with `self.supports_cli = False` in the past but run fine on master today - enabled those.

  In total, this PR fixes all tests that fail on master and reduces the number of tests that are deactivated (`self.supports_cli = False`) from 40 to 21.
  It also adds `--usecli` to one CI job (multiprocess, i686, DEBUG) to detect regressions.

ACKs for top commit:
  maflcko:
    re-ACK 666016e56b 🔀
  pinheadmz:
    re-ACK 666016e56b

Tree-SHA512: 7a1efd212649ca100b236a1239294d40ecd36e2720e3b173a230b14545bb40b135111db7fed8a0d1448120f5387da146a03f1912e2028c8d03a0b6a3ca8761b0
2025-07-03 10:20:03 +01:00
rkrux 0f86da382d
wallet: remove dead code in legacy wallet migration
A discussion on a previous PR 32481 related to legacy wallet dead
code removal made me realize that checking if the legacy
wallet was loaded prior to the start of the migration is not
required ever since legacy wallets can't be loaded in the first
place. I also verified that the `load_on_start` persistent
setting can also not cause the legacy wallets to be loaded, which
further makes the case for removal of the above mentioned checks
during migration.
The current test coverage also shows these lines uncovered.
2025-07-03 14:27:47 +05:30
merge-script 49d5f1f2c6
Merge bitcoin/bitcoin#32850: test: check P2SH sigop count for coinbase tx
d6aaffcb11 test: check P2SH sigop count for coinbase tx (brunoerg)

Pull request description:

  We currently do not test that `GetP2SHSigOpCount` returns 0 for coinbase transactions (see line L129 at https://corecheck.dev/mutation/src/consensus/tx_verify.cpp). This PR addresses it.

ACKs for top commit:
  darosior:
    That said, i guess unit-tested dead consensus code is better than not-unit-tested dead consensus code. utACK d6aaffcb11
  theStack:
    ACK d6aaffcb11
  w0xlt:
    ACK d6aaffcb11
  ishaanam:
    ACK d6aaffcb11
  pablomartin4btc:
    ACK d6aaffcb11

Tree-SHA512: a7d7306f064bb2ec7e93e92625848ae38e150ebb67bde37cd15be1038816b154e867ad21ecd2685d8de5341b67e3b768d30b7654e27b541f33e8f9d63e52261d
2025-07-03 09:46:53 +01:00
furszy abd07cf733
test: feature_init, only init what's needed per perturbation/deletion round
Avoids initializing and syncing components not under test.
This not only speeds up execution a bit but also helps isolate
and debug issues more easily, as logs aren't flooded with
unrelated details.
2025-07-02 19:56:14 -04:00
Ava Chow 1927432354
Merge bitcoin/bitcoin#32859: functional test: correctly detect nonstd TRUC tx vsize in feature_taproot
f0524cda39 functional test: correctly detect nonstd TRUC tx vsize in feature_taproot (Greg Sanders)

Pull request description:

  Resolves https://github.com/bitcoin/bitcoin/pull/32841#discussion_r2180240391

ACKs for top commit:
  davidgumberg:
    utACK f0524cda39
  achow101:
    ACK f0524cda39
  darosior:
    utACK f0524cda39
  w0xlt:
    ACK f0524cda39

Tree-SHA512: b803c94f7a683b51bab88ae788384ff484a3e6597153bf022263bbc9531dd3faebb7832db26f2b8b4c0d0337c59991d0beca167def5aebe3e9a5d8a9bfdaaba5
2025-07-02 16:01:37 -07:00
Ava Chow 68ca13e1f9
Merge bitcoin/bitcoin#32823: test: Fix wait_for_getheaders() call in test_outbound_eviction_blocks_relay_only()
ec004cdb86 test: Use rehash() in outbound eviction block-relay (pablomartin4btc)
26598ed21e test: Clarify roles in outbound eviction comments (pablomartin4btc)

Pull request description:

  This change avoids relying on `tip_header.hash`, which is `None` when the header is deserialized from hex during `CBlockHeader()` construction.
  Instead, `tip_header.rehash()` explicitly computes the hash, making the test behavior more robust.

  Using the explicit `rehash()` avoids depending on `wait_for_getheaders()` falling back to any received message, thus making the test more deterministic.

  This is a follow-up to #32742.

  Also, as noted in a previous review [comment](https://github.com/bitcoin/bitcoin/pull/32742#pullrequestreview-2923802386), "_the hash field is wrong either way, simply due to being the wrong type (it is an optional hex string), as opposed to an optional int_".

  ---

  The first commit intention is to improve clarity around the tests purpose, helping reviewers follow what's being verified and why. What started as a small comment during review of #32742 led me reviewing and try to improve most relevant tests comments for consistency and correctness.

ACKs for top commit:
  achow101:
    ACK ec004cdb86
  theStack:
    lgtm ACK ec004cdb86 #️⃣
  yuvicc:
    ACK ec004cdb86
  danielabrozzoni:
    ACK ec004cdb86

Tree-SHA512: 6a14dedfdc425cd806f63443b3b9f79df69a7717452739f5d7fef1b2bdba23402670d63cf1d6b66c9f1a6b460d4d4a6f185426d0a4982fa95115a234cd6baef7
2025-07-02 13:44:20 -07:00
Ava Chow 35cae56a92
Merge bitcoin/bitcoin#31423: wallet: migration, avoid creating spendable wallet from a watch-only legacy wallet
b789907346 wallet: migration, avoid creating spendable wallet from a watch-only legacy wallet (furszy)
e86d71b749 wallet: refactor, dedup wallet re-loading code (furszy)
1de423e0a0 wallet: introduce method to return all db created files (furszy)
d04f6a97ba refactor: remove sqlite dir path back-and-forth conversion (furszy)

Pull request description:

  Currently, the migration process creates a brand-new descriptor wallet with no
  connection to the user's legacy wallet when the legacy wallet lacks key material
  and contains only watch-only scripts. This behavior is not aligned with user
  expectations. If the legacy wallet contains only watch-only scripts, the migration
  process should only generate a watch-only wallet instead.

  TODO List:
  * Explain that `migratewallet` renames the watch-only after migration, and
  also that the wallet will not have keys enabled.

ACKs for top commit:
  achow101:
    ACK b789907346
  pablomartin4btc:
    tACK b789907346
  rkrux:
    LGTM ACK b789907346

Tree-SHA512: 1d583ac4b206fb477e9727daf4b5ad9c3e18b12d40e1ab4a61e8565da44c3d0327c892b51cf47b4894405d122e414cefb6b6366c357e02a74a7ca96e06762d83
2025-07-02 13:25:33 -07:00
Pieter Wuille 1632fc104b txgraph: Track multiple potential would-be clusters in Trim (improvement)
In the existing Trim function, as soon as the set of accepted transactions
would exceed the max cluster size or count limit, the acceptance loop is
stopped, removing all later transactions. However, it is possible that by
excluding some of those transactions the would-be cluster splits apart into
multiple would-clusters. And those clusters may well permit far more
transactions before their limits are reached.

Take this into account by using a union-find structure inside TrimTxData to
keep track of the count/size of all would-be clusters that would be formed
at any point, and only reject transactions which would cause these resulting
partitions to exceed their limits.

This is not an optimization in terms of CPU usage or memory; it just
improves the quality of the transactions removed by Trim().
2025-07-02 16:01:57 -04:00
Pieter Wuille 4608df37e0 txgraph: add Trim benchmark (benchmark) 2025-07-02 16:01:57 -04:00
Pieter Wuille 9c436ff01c txgraph: add fuzz test scenario that avoids cycles inside Trim() (tests)
Trim internally builds an approximate dependency graph of the merged cluster,
replacing all existing dependencies within existing clusters with a simple
linear chain of dependencies. This helps keep the complexity of the merging
operation down, but may result in cycles to appear in the general case, even
though in real scenarios (where Trim is called for stitching re-added mempool
transactions after a reorg back to the existing mempool transactions) such
cycles are not possible.

Add a test that specifically targets Trim() but in scenarios where it is
guaranteed not to have any cycles. It is a special case, is much more a
whitebox test than a blackbox test, and relies on randomness rather than
fuzz input. The upside is that somewhat stronger properties can be tested.

Co-authored-by: Greg Sanders <gsanders87@gmail.com>
2025-07-02 15:06:53 -04:00
glozow 938e86f8fe txgraph: add unit test for TxGraph::Trim (tests)
Co-Authored-By: Pieter Wuille <pieter@wuille.net>
2025-07-02 15:06:48 -04:00
Pieter Wuille a04e205ab0 txgraph: Add ability to trim oversized clusters (feature)
During reorganisations, it is possible that dependencies get add which
result in clusters that violate limits (count, size), when linking the
new from-block transactions to the old from-mempool transactions.

Unlike RBF scenarios, we cannot simply reject these policy violations
when they are due to received blocks. To accomodate this, add a Trim()
function to TxGraph, which removes transactions (including descendants)
in order to make all resulting clusters satisfy the limits.

In the initial version of the function added here, the following approach
is used:
- Lazily compute a naive linearization for the to-be-merged cluster (using
  an O(n log n) algorithm, optimized for far larger groups of transactions
  than the normal linearization code).
- Initialize a set of accepted transactions to {}
- Iterate over the transactions in this cluster one by one:
  - If adding the transaction to the set makes it exceed the max cluster size
    or count limit, stop.
  - Add the transaction to the set.
- Remove all transactions from the cluster that were not included in the set
  (note that this necessarily includes all descendants too, because they
  appear later in the naive linearization).

Co-authored-by: Greg Sanders <gsanders87@gmail.com>
2025-07-02 14:52:54 -04:00
Greg Sanders eabcd0eb6f txgraph: remove unnecessary m_group_oversized (simplification) 2025-07-02 14:52:54 -04:00
Pieter Wuille 19b14e61ea txgraph: Permit transactions that exceed cluster size limit (feature)
This removes the restriction added in the previous commit that individual
transactions do not exceed the max cluster size limit.

With this change, the responsibility for enforcing cluster size limits can
be localized purely in TxGraph, without callers (and in particular, tests)
needing to duplicate the enforcement for individual transactions.
2025-07-02 14:52:54 -04:00
Pieter Wuille c4287b9b71 txgraph: Add ability to configure maximum cluster size/weight (feature)
This is integrated with the oversized property: the graph is oversized when
any connected component within it contains more than the cluster count limit
many transactions, or when their combined size/weight exceeds the cluster size
limit.

It becomes disallowed to call AddTransaction with a size larger than this limit,
though this limit will be lifted in the next commit.

In addition, SetTransactionFeeRate becomes SetTransactionFee, so that we do not
need to deal with the case that a call to this function might affect the
oversizedness.
2025-07-02 14:52:54 -04:00
Greg Sanders f0524cda39 functional test: correctly detect nonstd TRUC tx vsize in feature_taproot 2025-07-02 11:23:53 -04:00
Hennadii Stepanov 0a1af4418e
doc: Add workaround for vcpkg issue with paths with embedded spaces 2025-07-02 15:45:00 +01:00
merge-script a92e8b10a5
Merge bitcoin/bitcoin#32564: miniscript, refactor: Make `operator""_mst` `consteval` (re-take)
a34fb9ad6c miniscript: Make `operator""_mst` `consteval` (Pieter Wuille)
14052162b1 Revert "miniscript: make operator_mst consteval" (Hennadii Stepanov)

Pull request description:

  Same as https://github.com/bitcoin/bitcoin/pull/28657, but without the refactoring required to work around [fixed](https://github.com/bitcoin/bitcoin/pull/28657#discussion_r2095743353) MSVC bugs.

  The second commit has been taken from https://github.com/bitcoin/bitcoin/pull/29167.

ACKs for top commit:
  sipa:
    ACK a34fb9ad6c
  hodlinator:
    re-ACK a34fb9ad6c

Tree-SHA512: 8b531f9d6c450a8a5218865da05ffb5093d09ce2c0bee9874c0160795c4b1713928730d894ea3cd0b12b133346971ae3a00ed2fe8d9fd8a50b67a74ef81fde98
2025-07-02 15:06:33 +01:00
merge-script bf75c9964f
Merge bitcoin/bitcoin#32828: build, docs: Fix Boost-related issues on NetBSD
5a5ddbd789 build: Add workaround for NetBSD bug in `Boost::headers` target (Hennadii Stepanov)
4eb3cee919 doc: Update NetBSD Build Guide (Hennadii Stepanov)

Pull request description:

  The recently merged https://github.com/bitcoin/bitcoin/pull/32667 broke builds on NetBSD due to the following issues:

  1. The `boost-headers` package does not provide CMake configuration files now required since https://github.com/bitcoin/bitcoin/pull/32667.

     The first commit updates the Build Guide to recommend using the `boost` package instead.

  2. The CMake configuration file provided by the `boost` package is [broken](https://github.com/NetBSD/pkgsrc/issues/167).

     The second commit adds a workaround for this issue.

  Upstream issues:
  - https://github.com/NetBSD/pkgsrc/issues/167
  - https://github.com/NetBSD/pkgsrc/issues/168

  Successful CI job: https://github.com/hebasto/bitcoin-core-nightly/actions/runs/15958818914/job/45008576879.

ACKs for top commit:
  purpleKarrot:
    ACK 5a5ddbd789

Tree-SHA512: 617543edf2216c3673195cc562541d7637d7ea199320916c3660a91f6ee1ff01c014f519c5eeb3fc224f7a7304fdb75965ee3f4554d7fb277dd05ba3a6583b45
2025-07-02 13:29:49 +01:00
merge-script 7fa9b58bd9
Merge bitcoin/bitcoin#32841: feature_taproot: sample tx version border values more
4be81e9746 feature_taproot: sample tx version border values more (Greg Sanders)

Pull request description:

  Currently if the version 3 is selected for an otherwise standard spender, the test will fail. It's unlikely but possible, so change the test to update expectations and sample more aggressively on border values to instigate failures much quicker in the future if another version is made standard.

ACKs for top commit:
  maflcko:
    lgtm ACK 4be81e9746
  darosior:
    ACK 4be81e9746

Tree-SHA512: 53267a201aaa495bea9d624930a19e40af3633427b6715965f43b9e1a060b2c9f19c8b10c8168778349fa50715e44cb8e5e9d2ce477d5f324ca8ed28ff7996cd
2025-07-02 11:45:26 +01:00
rkrux 1b5c545e82
wallet, test: best block locator matches scan state follow-ups
Few follows-ups from #30221: Use `SetLastBlockProcessedInMem` more in
`AttachChain`, add not null locator check in `WriteBestBlock`. Add log
and few assertions in `wallet_reorgstore` test.
2025-07-02 14:30:52 +05:30
Ava Chow fa33592898
Merge bitcoin/bitcoin#32723: Refactor: Redefine CTransaction equality to include witness data
6efbd1e1dc refactor: CTransaction equality should consider witness data (Cory Fields)
cbf9b2dab1 mempool: codify existing assumption about duplicate txids during removal (Cory Fields)
e9331cd6ab wallet: IsEquivalentTo should strip witness data in addition to scriptsigs (Cory Fields)

Pull request description:

  I stumbled upon the `CTransaction` comparison operators while refactoring some nearby code. I found it surprising and not at all obvious that two transactions would test equal even if their witness data differed. It seems like an unnecessary potential footgun. Fix that by comparing against wtxid rather than txid.

  Outside of tests, there were only 3 users of these functions in the code-base:
  - Its use in the mempool has been replaced with an explicit txid comparison, as that's a tighter constraint and matches the old behavior. glozow suggested also upgrading this to an `Assume()`.
  - Its use in the wallet was accidentally doing the correct thing by ignoring witness data. I've changed that to an explicit witness removal so that `IsEquivalentTo` continues to work as-intended.
  - Its use in `getrawtransaction` is indifferent to the change.

ACKs for top commit:
  maflcko:
    review ACK 6efbd1e1dc 🦋
  achow101:
    ACK 6efbd1e1dc
  glozow:
    ACK 6efbd1e1dc

Tree-SHA512: 89be424889f49e7e26dd2bdab7fbc8b2def59bf002ae8b94989b349ce97245f007d6c96e409a626cbf0de9df83ae2485b4815b40a70f7aa5b6c720eb34a6c017
2025-07-01 14:53:16 -07:00
Ava Chow ce000c8ee0
Merge bitcoin/bitcoin#32219: test: enabling wallet migration functional test on windows
941b8f54c0 ci: run get_previous_releases as part of test cross win job (Max Edwards)
5e2182140b test: increment mocked time for migrating wallet backups (Max Edwards)
5174565802 ci: disable feature_unsupported_utxo_db functional test (Max Edwards)
3dc90d69a6 test: remove mempool.dat before copying (Max Edwards)
67a6b20d50 test: add windows support to get previous releases script (Max Edwards)
1a1b478ca3 scripted-diff: rename tarball to archive (Max Edwards)
4f06dc8484 test: remove building from source from get prev releases script (Max Edwards)

Pull request description:

  This PR updates the `test/get_previous_releases.py` script to also work on Windows by changing to be pure python rather than using unix tools such as `curl` and `tar`.

  This enables additional functional tests to run such as `wallet_migration.py`, `mempool_compatability.py` and `wallet_backwards_compatibility.py`.

  Unfortunately `feature_unsupported_utxo_db.py` _could_ run but this test requires Bitcoin `v0.14.3` which will not run under windows with emojis in the data directory (as the functional test runner has by default) . This test could be run as it's own step in the ci workflow file and would pass but as it's quite an old version / feature I have assumed it's not worth worrying about and best just to exclude.

  Two tests needed to be slightly modified to run under windows. Both were issues with trying to overwrite a file that already exists which windows seems to be more strict on than the unix based systems.

  Finally, building from source has been dropped from the `get_previous_releases.py` script. This had not been updated after the move to cmake and so it was assumed that nobody could have been using that feature.

ACKs for top commit:
  maflcko:
    re-ACK 941b8f54c0 🍪
  achow101:
    ACK 941b8f54c0
  hodlinator:
    re-ACK 941b8f54c0

Tree-SHA512: 22933d0ec278b9b0ffcd2a8e90026e1a3631b00186e7f78bd65be925049021e319367d488c36a82ab526a07b264bac18c2777f87ca1174b231ed49fed56d11cb
2025-07-01 13:58:54 -07:00
Ava Chow f33154c464
Merge bitcoin/bitcoin#32432: wallet, rpc: Use `OUTPUT_TYPES` to describe the output types instead of hardcoding them
8cc9845b8d wallet, rpc: Use `OUTPUT_TYPES` to describe the output types instead of hardcoding them (w0xlt)

Pull request description:

  Follow-up to https://github.com/bitcoin/bitcoin/pull/32429, built on top of it.

  This PR addresses the https://github.com/bitcoin/bitcoin/pull/32429#discussion_r2076251627 that the RPC documentation does not use `OUTPUT_TYPES`, but rather hardcodes them, as is already the case for the `getnewaddress` command.
  So here the output types are changed from `std::string` to `std::string_view` so that the values are known at compile time or during the early stages of program startup, before main() execution.

  It also updates `wallet/rpc/addresses.cpp` to write the RPC docs according to `OUTPUT_TYPES` instead of using hardcoded version.

  It also updates the documentation in outputtypes.h, adding Doxygen comments,

ACKs for top commit:
  maflcko:
    lgtm ACK 8cc9845b8d
  achow101:
    ACK 8cc9845b8d

Tree-SHA512: e86d813d6d158dd2f6c62519a7ecaa878f2e4f686b5bae82028a106bd6671a13b10fb366f9bb7b94974777217e1852f38e8aa05bba00cd27f94f4412167a3562
2025-07-01 13:53:11 -07:00
Ava Chow fa9b1e3544
Merge bitcoin/bitcoin#32846: doc: clarify that the "-j N" goes after the "--build build" part
0e9f409db3 doc: clarify that the "-j N" goes after the "--build build" part (Salvatore Ingala)

Pull request description:

  I was surprised that something like `cmake -j 4 --build build` doesn't work, so this might help others to not make the same mistake.

ACKs for top commit:
  achow101:
    ACK 0e9f409db3
  hebasto:
    ACK 0e9f409db3.
  stickies-v:
    ACK 0e9f409db3
  pablomartin4btc:
    ACK 0e9f409db3
  theStack:
    ACK 0e9f409db3
  brunoerg:
    ACK 0e9f409db3
  w0xlt:
    ACK 0e9f409db3

Tree-SHA512: 5283f87a68abae4905b773e73aa4529f52d2302d804165b560b22f300a449d8ce1ae3194d2e1fe69be6f7e4d279dd32b8ef0daa18af4ac6a76a51f5abc39ec63
2025-07-01 11:56:37 -07:00
Ava Chow b1a8ac07e9 doc: Release note for removed watchonly parameters and results 2025-07-01 11:26:42 -07:00
Ava Chow 15710869e1 wallet: Remove ISMINE_WATCH_ONLY
ISMINE_WATCH_ONLY has been removed from all places it was being used,
and migration does not need ISMINE_WATCH_ONLY, so remove the enum.
2025-07-01 11:26:42 -07:00
Ava Chow 4439bf4b41 wallet, spend: Remove fWatchOnly from CCoinControl
Descriptor wallets do not have a concept of watchonly within a wallet,
so remove the watchonly option from coin control.
2025-07-01 11:26:42 -07:00
Ava Chow 1337c72198 wallet, rpc: Remove watchonly from RPCs
Descriptor wallets don't have a conception of watchonly within a wallet,
so remove all of these options and results from the RPCs
2025-07-01 11:26:42 -07:00
Ava Chow e81d95d435 wallet: Remove watchonly balances
Descriptor wallets do not have mixed mine and watchonly, so there is no
need to report a watchonly balance.
2025-07-01 11:10:25 -07:00
Ava Chow d20dc9c6aa wallet: Wallets without private keys cannot grind R 2025-07-01 10:40:58 -07:00
Ava Chow 9991f49c38 test: Watchonly wallets should estimate larger size
Test that when a watchonly wallet and the wallet with private keys fund
the same tx, the watchonly wallet should use a higher fee since it
should be estimating the size to be larger as it assumes the signer
cannot grind the R value.
2025-07-01 10:40:58 -07:00
brunoerg d6aaffcb11 test: check P2SH sigop count for coinbase tx 2025-07-01 12:08:20 -03:00
merge-script b1821d8dd3
Merge bitcoin/bitcoin#27286: wallet: Keep track of the wallet's own transaction outputs in memory
215e5999e2 wallet: Remove unused CachedTxGet{Available,Immature}Credit (Ava Chow)
49675de035 wallet: Have GetDebit use the wallet's TXO set (Ava Chow)
17d453cb3a wallet: Recompute wallet TXOs after descriptor migration (Ava Chow)
764016eb22 wallet: Retrieve TXO directly in FetchSelectedInputs (Ava Chow)
c1801b78f1 wallet: Use wallet's TXO set in AvailableCoins (Ava Chow)
dde7cbe105 wallet: Change balance calculation to use m_txos (Ava Chow)
96e7a89c5e wallet: Recalculate the wallet's txos after any imports (Ava Chow)
ae888c38d0 wallet: Exit IsTrustedTx early if wtx is already in trusted_parents (Ava Chow)
ae0876ec42 wallet: Keep track of transaction outputs owned by the wallet (Ava Chow)
0f269bc48c walletdb: Load Txs last (Ava Chow)
5cc32ee2a7 test: Test for balance update due to untracked output becoming spendable (Ava Chow)
8222341d4f wallet: MarkDirty after AddWalletDescriptor (Ava Chow)
e02f2d331c bench: Have AvailableCoins benchmark include a lot of unrelated utxos (Ava Chow)

Pull request description:

  Currently, the wallet is not actually aware about its own transaction outputs. Instead, it will iterate all of the transactions stored in `mapWallet`, and then all of the outputs of those transactions, in order to figure out what belongs to it for the purposes of coin selection and balance calculation. For balance calculation, there is caching that results in it only iterating all of the transactions, but not all of the outputs. However when the cache is dirty, everything is iterated. This is especially problematic for wallets that have a lot of transactions, or transactions that have a lot of unrelated outputs (as may occur with coinjoins or batched payments).

  This PR helps to resolve this issue by making the wallet track all of the outputs that belong to it in a new member `m_txos`. Note that this includes outputs that may have already been spent. Both balance calculation (`GetBalance`) and coin selection (`AvailableCoins`) are updated to iterate `m_txos`. This is generally faster since it ignores all of the unrelated outputs, and it is not slower as in the worst case of wallets containing only single output transactions, it's exactly the same number of outputs iterated.

  `m_txos` is memory only, and it is populated during wallet loading. When each transaction is loaded, all of its outputs are checked to see if it is `IsMine`, and if so, an entry added to `m_txos`. When new transactions are received, the same procedure is done.

  Since imports can change the `IsMine` status of a transaction (although they can only be "promoted" from watchonly to spendable), all of the import RPCs will be a bit slower as they re-iterate all transactions and all outputs to update `m_txos`.

  Each output in `m_txos` is stored in a new `WalletTXO` class. This class contains references to the parent `CWalletTx` and the `CTxOut` itself. It also caches the `IsMine` value of the txout. This should be safe as `IsMine` should not change unless there are imports. This allows us to have additional performance improvements in places that use these `WalletTXO`s as they can use the cached `IsMine` rather than repeatedly calling `IsMine` which can be expensive.

  The existing `WalletBalance` benchmark demonstrates the performance improvement that this PR makes. The existing `WalletAvailableCoins` benchmark doesn't as all of the outputs used in that benchmark belong to the test wallet. I've updated that benchmark to have a bunch of unrelated outputs in each transaction so that the difference is demonstrated.

  This is part of a larger project to have the wallet actually track and store a set of its UTXOs.

  Built on #24914 as it requires loading the txs last in order for `m_txos` to be built correctly.

  ***

  ## Benchmarks:

  Master:

  |               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |         bra/op |   miss% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
  |       34,590,013.00 |               28.91 |    0.0% |  812,669,269.00 |  148,360,642.50 |  5.478 |  18,356,853.00 |    0.2% |      0.76 | `WalletAvailableCoins`
  |            3,193.46 |          313,139.91 |    0.4% |       96,868.06 |       13,731.82 |  7.054 |      26,238.01 |    0.1% |      0.01 | `WalletBalanceClean`
  |           26,871.18 |           37,214.59 |    3.3% |      768,179.50 |      115,544.39 |  6.648 |     154,171.09 |    0.1% |      0.01 | `WalletBalanceDirty`
  |            3,177.30 |          314,732.47 |    0.2% |       96,868.06 |       13,646.20 |  7.099 |      26,238.01 |    0.1% |      0.01 | `WalletBalanceMine`
  |               10.73 |       93,186,952.53 |    0.1% |          157.00 |           46.14 |  3.403 |          36.00 |    0.0% |      0.01 | `WalletBalanceWatch`
  |      590,497,920.00 |                1.69 |    0.1% |12,761,692,005.00 |2,536,899,595.00 |  5.030 | 129,124,399.00 |    0.7% |      6.50 | `WalletCreateEncrypted`
  |      182,929,529.00 |                5.47 |    0.0% |4,199,271,397.00 |  785,477,302.00 |  5.346 |  75,363,377.00 |    1.1% |      2.01 | `WalletCreatePlain`
  |          699,337.20 |            1,429.93 |    0.7% |   18,054,294.00 |    3,005,072.20 |  6.008 |     387,756.60 |    0.3% |      0.04 | `WalletCreateTxUseOnlyPresetInputs`
  |       32,068,583.80 |               31.18 |    0.5% |  562,026,110.00 |  137,457,635.60 |  4.089 |  90,667,459.40 |    0.3% |      1.78 | `WalletCreateTxUsePresetInputsAndCoinSelection`
  |               36.62 |       27,306,578.40 |    0.5% |          951.00 |          157.05 |  6.056 |         133.00 |    0.0% |      0.01 | `WalletIsMineDescriptors`
  |               35.00 |       28,569,989.42 |    0.7% |          937.00 |          150.33 |  6.233 |         129.00 |    0.0% |      0.01 | `WalletIsMineMigratedDescriptors`
  |      203,284,889.00 |                4.92 |    0.0% |4,622,691,895.00 |  872,875,275.00 |  5.296 |  90,345,002.00 |    1.2% |      1.02 | `WalletLoadingDescriptors`
  |    1,165,766,084.00 |                0.86 |    0.0% |24,139,316,211.00 |5,005,218,705.00 |  4.823 |2,664,455,775.00 |    0.1% |      1.17 | `WalletMigration`

  PR:

  |               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |         bra/op |   miss% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
  |       33,975,750.50 |               29.43 |    0.1% |  794,719,150.50 |  145,763,550.00 |  5.452 |  16,036,630.50 |    0.2% |      0.75 | `WalletAvailableCoins`
  |            2,442.01 |          409,498.46 |    0.2% |       60,782.04 |       10,500.60 |  5.788 |       9,492.01 |    0.3% |      0.01 | `WalletBalanceClean`
  |            2,763.12 |          361,909.21 |    0.2% |       61,493.05 |       11,859.48 |  5.185 |       9,625.01 |    0.2% |      0.01 | `WalletBalanceDirty`
  |            2,347.98 |          425,898.72 |    0.3% |       60,782.04 |       10,082.73 |  6.028 |       9,492.01 |    0.2% |      0.01 | `WalletBalanceMine`
  |               11.67 |       85,654,630.36 |    0.2% |          176.00 |           50.18 |  3.508 |          40.00 |    0.0% |      0.01 | `WalletBalanceWatch`
  |      590,119,519.00 |                1.69 |    0.1% |12,754,398,258.00 |2,534,998,522.00 |  5.031 | 129,078,027.00 |    0.7% |      6.50 | `WalletCreateEncrypted`
  |      183,124,790.00 |                5.46 |    0.1% |4,199,212,926.00 |  786,323,886.00 |  5.340 |  75,354,437.00 |    1.1% |      2.02 | `WalletCreatePlain`
  |          669,643.00 |            1,493.33 |    0.1% |   17,213,904.20 |    2,877,336.40 |  5.983 |     394,292.80 |    0.3% |      0.04 | `WalletCreateTxUseOnlyPresetInputs`
  |       26,205,987.80 |               38.16 |    0.8% |  365,551,340.80 |  112,376,905.20 |  3.253 |  65,684,276.20 |    0.4% |      1.44 | `WalletCreateTxUsePresetInputsAndCoinSelection`
  |               34.75 |       28,778,846.38 |    0.1% |          937.00 |          149.41 |  6.271 |         129.00 |    0.0% |      0.01 | `WalletIsMineDescriptors`
  |               29.91 |       33,428,072.85 |    0.2% |          920.00 |          128.63 |  7.152 |         126.00 |    0.0% |      0.01 | `WalletIsMineMigratedDescriptors`
  |      202,437,985.00 |                4.94 |    0.1% |4,626,686,256.00 |  869,439,274.00 |  5.321 |  90,961,305.00 |    1.1% |      1.02 | `WalletLoadingDescriptors`
  |    1,158,394,152.00 |                0.86 |    0.0% |24,143,589,972.00 |4,971,946,380.00 |  4.856 |2,665,355,654.00 |    0.1% |      1.16 | `WalletMigration`

ACKs for top commit:
  davidgumberg:
    untested reACK 215e599
  murchandamus:
    reACK 215e5999e2
  ishaanam:
    reACK 215e5999e2
  w0xlt:
    reACK 215e5999e2

Tree-SHA512: d6b929de56f67930678db654e46f15fb71008390189c701a026b2d76af8f14a7c9769e49835ce7e2b6515d2934a77aad8de0b1a82231a2e1de5337de25db9629
2025-07-01 08:56:21 -04:00
Salvatore Ingala 0e9f409db3
doc: clarify that the "-j N" goes after the "--build build" part
Also, capitalized the comments in build-unix.md for uniformity
with the docs on other targets.
2025-07-01 18:00:31 +08:00
Hennadii Stepanov 67dc7523f3
cmake, test: Disable tests instead of ignoring them 2025-07-01 10:50:55 +01:00
Hennadii Stepanov bb9157db5d
cmake, refactor: Switch to `Python3::Interpreter` imported target
Imported targets are more robust than using variables.
2025-07-01 10:48:22 +01:00
merge-script ed7a841f82
Merge bitcoin/bitcoin#32816: contrib: correct variable name in p2p_monitor.py
6bb38bf37f Update p2p_monitor.py (leopardracer)

Pull request description:

  Fix typo in variable name in p2p_monitor.py.

ACKs for top commit:
  maflcko:
    lgtm ACK 6bb38bf37f

Tree-SHA512: 3d18b56766acd35f86e002fda7460f57ef8d09dd8948cc5aa172f720789624f52e1a2e4f7b095fcee7e524bdc63228903056ab2339d206efd5fbbb4189eeb969
2025-07-01 09:45:25 +01:00
merge-script 2ae5154dd8
Merge bitcoin/bitcoin#32842: doc: add `/spenttxouts` to REST-interface.md
dd99cedc0b doc: add `/spenttxouts` to REST-interface.md (Sebastian Falbesoner)

Pull request description:

  Seems like adding the `spenttxouts` endpoint to the REST interface description was forgotten in #32540.

ACKs for top commit:
  maflcko:
    lgtm ACK dd99cedc0b
  pablomartin4btc:
    ACK dd99cedc0b

Tree-SHA512: 9b1da9cbab914664217cc7f8792092e672518ec7f79c7670eb1c54ef94e6cd52b139e1051035ce33ad62b7b74a169e3abc793d1804760787a11a0dc269d26402
2025-07-01 09:38:01 +01:00
stickies-v 243553d590 refactor: replace get_iter_from_wtxid with GetIter(const Wtxid&)
Overloading GetIter makes it easier to use std::visit patterns
from a GenTxid.
2025-07-01 09:21:12 +01:00
marcofleon fcf92fd640 refactor: make CTxMemPool::GetIter strongly typed
This allows adding a GetIter(const Wtxid&) overload in a next
commit, making it easier to visit this function from a variant.

Co-authored-by: stickies-v <stickies-v@protonmail.com>
2025-07-01 09:00:27 +01:00
Ava Chow 23a00fcf57
Merge bitcoin/bitcoin#32783: doc: Add fetching single PRs from upstream to productivity.md
45b1d39757 doc: Add fetching single PRs from upstream (will)

Pull request description:

  Current recommendation is to add a new remote fetching all PRs, but this is resource-intensive.

  Document a better way to fetch a single PR, and to update a PR which has been force-pushed.

  Follows up on a [comment from 32774](https://github.com/bitcoin/bitcoin/pull/32774#discussion_r2156728913)

ACKs for top commit:
  pablomartin4btc:
    re-ACK 45b1d39
  achow101:
    ACK 45b1d39757
  janb84:
    re ACK 45b1d39757
  theStack:
    ACK 45b1d39757

Tree-SHA512: 3af02aa1335fd941538fabaa527bcfa92907dc6c272e72bc37ca38211b8aeebf32dd1837f976308058360ed1364fec749b49213f2b8bc4e35542da55a7bd30e1
2025-06-30 18:26:14 -07:00
Sebastian Falbesoner dd99cedc0b doc: add `/spenttxouts` to REST-interface.md 2025-06-30 23:26:27 +02:00
Greg Sanders 4be81e9746 feature_taproot: sample tx version border values more
Currently if the version 3 is selected for an otherwise
standard spender, the test will fail. It's unlikely but
possible, so change the test to update expectations and
sample more aggressively on border values to instigate
failures much quicker in the future if another version is
made standard.
2025-06-30 17:02:58 -04:00
merge-script 6e5b67a370
Merge bitcoin/bitcoin#32697: test: Turn util/test_runner into functional test
fa21631595 test: Use self.log (MarcoFalke)
fa346f7797 test: Move error string into exception (MarcoFalke)
fa1986181f test: Remove useless catch-throw (MarcoFalke)
fa2f1c55b7 move-only util data to test/functional/data/util (MarcoFalke)
faa18bf287 test: Turn util/test_runner into functional test (MarcoFalke)
fa955154c7 test: Add missing skip_if_no_bitcoin_tx (MarcoFalke)
fac9db6eb0 test: Add missing tx util to Binaries (MarcoFalke)
fa91835ec6 test: Use lowercase env var as attribute name (MarcoFalke)
fac49094cd test: Remove duplicate ConfigParser (MarcoFalke)

Pull request description:

  The `test/util/test_runner.py` has many issues:

  * The boilerplate for the test runner is duplicate or inconsistent with the other (functional) tests. For example, logging options, `ConfigParser` handling, `Binaries` handling ...
  * The cmake/ci behavior is brittle and can silently fail, as explained in https://github.com/bitcoin/bitcoin/issues/31476
  * corecheck (and likely other places that manually run the tests) completely forget to run it
  * If the test is manually called, it runs single threaded, when it could just run in parallel with the other functional tests

  Fix all issues by removing the util test_runner and moving the test logic into a new functional test file.

ACKs for top commit:
  janb84:
    re ACK fa21631595
  brunoerg:
    re-ACK fa21631595
  hebasto:
    re-ACK fa21631595, additional feedback has been addressed since my previous [review](https://github.com/bitcoin/bitcoin/pull/32697#pullrequestreview-2940350432).

Tree-SHA512: 694e647887801f002843a74011035d5ed3dfed091d3f0ae18e812a16a4680e04e60e50de0a92af7e047e8ddd6ff5a7834c690f16fd42b74ebc1674bf9989406f
2025-06-30 13:45:14 -04:00
merge-script fb2c16cf7b
Merge bitcoin/bitcoin#32826: p2p: add more bad ports
6967e8e8ab add more bad p2p ports (Jameson Lopp)

Pull request description:

  Add a few more ports used by extremely well adopted services that require authentication and really ought not be used by bitcoin nodes for p2p traffic.

ACKs for top commit:
  Sjors:
    utACK 6967e8e8ab
  l0rinc:
    ACK 6967e8e8ab
  glozow:
    ACK 6967e8e8ab

Tree-SHA512: bbe86aef2be9727338712ded8f90227f5d12f633ab5d324c8907c01173945d1c4d9899e05565f78688842bbf5ebb010d22173969e4168ea08d4e33f01fe9569d
2025-06-30 13:28:17 -04:00
merge-script f5f3e1f263
Merge bitcoin/bitcoin#32646: p2p: Add witness mutation check inside FillBlock
28299ce776 p2p: remove vestigial READ_STATUS_CHECKBLOCK_FAILED (Greg Sanders)
bac9ee4830 p2p: Add witness mutation check inside FillBlock (Greg Sanders)

Pull request description:

  Since #29412, we have not allowed mutated blocks to continue being processed immediately the block is received, but this is only done for the legacy BLOCK message.

  Extend these checks as belt-and-suspenders to not allow similar mutation strategies to affect relay by honest peers by applying the check inside `PartiallyDownloadedBlock::FillBlock`, immediately before returning `READ_STATUS_OK`.

ACKs for top commit:
  Crypt-iQ:
    ACK 28299ce776
  achow101:
    ACK 28299ce776
  stratospher:
    ACK 28299ce7.
  dergoegge:
    Code review ACK 28299ce776

Tree-SHA512: 883d7c12ca096234b425e6fe12e46b0611607600916e6ac8d1c8112224aa76924b7b074754910163ac2ec15379075d618a9ece3642649ac7629cddb0d4e432ea
2025-06-30 13:15:37 -04:00
merge-script a763497b1d
Merge bitcoin/bitcoin#32834: test: Use msg_generic in p2p_ping.py
fa3f100010 test: Use msg_generic in p2p_ping.py (MarcoFalke)

Pull request description:

  It seems odd to derive `msg_pong_corrupt` from `msg_pong`, but then overwrite the serialize method, when one can just directly use `msg_generic` to pass the raw bytes to send over the wire.

  Fix that by using `msg_generic`. This also serves as a regression test against the fix in commit 33480573cb.

  (Can be tested by reverting that commit to observe a failure)

ACKs for top commit:
  dergoegge:
    utACK fa3f100010
  theStack:
    ACK fa3f100010

Tree-SHA512: 53d7d2289f27646fdf7d3b86c53e8e707fa4ca4b006d232850f9dc27409d79b7abe1dece95ccef429d4b52c6a89579c0cc5c0ee37046375c3c0310a2d6f9ddd5
2025-06-30 14:41:21 +01:00
MarcoFalke fa3f100010
test: Use msg_generic in p2p_ping.py 2025-06-30 14:50:55 +02:00
merge-script 33480573cb
Merge bitcoin/bitcoin#32833: test: Add `msgtype` to `msg_generic` slots
7dc43ea503 test: Add msgtype to msg_generic slots (dergoegge)

Pull request description:

  `msg_generic` can't be used unless `msgtype` is listed in `__slots__`

  Example from a [custom test](6329ce979f/test/functional/p2p_bug28676.py):

  ```
  2025-06-30T10:14:55.418000Z TestFramework (INFO): PRNG seed is: 3137163719543762151
  2025-06-30T10:14:55.418000Z TestFramework (INFO): Initializing test directory /tmp/nix-shell-110135-0/bitcoin_func_test_7lmiemmp
  2025-06-30T10:14:55.675000Z TestFramework (INFO): Setting up connections & mining some blocks...
  2025-06-30T10:14:56.511000Z TestFramework (ERROR): Unexpected exception caught during testing
  Traceback (most recent call last):
    File "/home/dergoegge/workspace/bitcoin/worktrees/master/test/functional/test_framework/test_framework.py", line 189, in main
      self.run_test()
    File "/home/dergoegge/workspace/bitcoin/worktrees/master/./build/test/functional/p2p_bug28676.py", line 46, in run_test
      self.connections[0].send_without_ping(msg_generic(b"block", bytes.fromhex("0500000006226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f06b816712ffab8c59299a6abb58ccefa1995a1368ca4348782ef268cbc9bacacdbe5494dffff7f200200000001010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff075105ffffffff00ffffffff0200f90295000000002200204ae81572f06e1b88fd5ced7a1a000945432e83e1551e6f721ee9c00b8cc332600000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf90120000000000000000000000000000000000000000000000000000000000000000000000000")))
    File "/home/dergoegge/workspace/bitcoin/worktrees/master/test/functional/test_framework/messages.py", line 1386, in __init__
      self.msgtype = msgtype
  AttributeError: 'msg_generic' object has no attribute 'msgtype'
  ```

ACKs for top commit:
  maflcko:
    lgtm ACK 7dc43ea503
  theStack:
    ACK 7dc43ea503

Tree-SHA512: 8c634d50a884b063117e8ae29510ffd013e73dda9f8b0f73d098e80038b610ef8d80bd2e576c37f0cedfb4b6baa3d4ebeceb0902f29f90d59e1525f418f712fe
2025-06-30 13:27:55 +01:00
merge-script 9501738e1c
Merge bitcoin/bitcoin#32825: rest: rename `strURIPart` to `uri_part`
856f4235b1 scripted-diff: rest: rename `strURIPart` -> `uri_part` (Roman Zeyde)

Pull request description:

  Following https://github.com/bitcoin/bitcoin/pull/32540#discussion_r2172902737.

ACKs for top commit:
  l0rinc:
    reACK 856f4235b1
  maflcko:
    lgtm ACK 856f4235b1

Tree-SHA512: a56a66872e632eed65fe1f75b9873dcf1d713cf09eba6e1e4031c58d88a5427a5bb7e49be4951ba22dfe4c9b558bb86f0f071fa42fc9cb50689564fe0b3b0297
2025-06-30 13:20:52 +01:00
Hennadii Stepanov 5a5ddbd789
build: Add workaround for NetBSD bug in `Boost::headers` target
Due to a bug in `boost_headers-config.cmake`, the `Boost::headers`
target's `INTERFACE_INCLUDE_DIRECTORIES` property is set to "/usr",
which is incorrect.
2025-06-30 11:34:29 +01:00
Jameson Lopp 6967e8e8ab
add more bad p2p ports 2025-06-30 06:24:00 -04:00
dergoegge 7dc43ea503 test: Add msgtype to msg_generic slots 2025-06-30 11:13:11 +01:00
Hennadii Stepanov 4eb3cee919
doc: Update NetBSD Build Guide
The `boost-headers` package does not provide CMake configuration files
required since https://github.com/bitcoin/bitcoin/pull/32667. Install
the `boost` package instead.
2025-06-29 20:04:49 +01:00
Roman Zeyde 856f4235b1
scripted-diff: rest: rename `strURIPart` -> `uri_part`
Following https://github.com/bitcoin/bitcoin/pull/32540#discussion_r2172902737.

-BEGIN VERIFY SCRIPT-
sed -i 's/\<strURIPart\>/uri_part/g' src/rest.cpp
-END VERIFY SCRIPT-
2025-06-28 14:59:08 +03:00
Ava Chow b3bb4031ab
Merge bitcoin/bitcoin#32540: rest: fetch spent transaction outputs by blockhash
c48846ec41 doc: add release notes for #32540 (Roman Zeyde)
d4e212e8a6 rest: fetch spent transaction outputs by blockhash (Roman Zeyde)

Pull request description:

  Today, it is possible to fetch a block's spent prevouts in order to build an external index by using the `/rest/block/BLOCKHASH.json` endpoint. However, its performance is low due to JSON serialization overhead.

  We can significantly optimize it by adding a new [REST API](https://github.com/bitcoin/bitcoin/blob/master/doc/REST-interface.md) endpoint, using a binary response format (returning a collection of spent txout lists, one per each block transaction):

  ```
  $ BLOCKHASH=00000000000000000002a7c4c1e48d76c5a37902165a270156b7a8d72728a054

  $ ab -k -c 1 -n 100 http://localhost:8332/rest/block/$BLOCKHASH.json
  Document Length:        13278152 bytes
  Requests per second:    3.53 [#/sec] (mean)
  Time per request:       283.569 [ms] (mean)

  $ ab -k -c 1 -n 10000 http://localhost:8332/rest/spenttxouts/$BLOCKHASH.bin
  Document Length:        195591 bytes
  Requests per second:    254.47 [#/sec] (mean)
  Time per request:       3.930 [ms] (mean)
  ```

  Currently, this PR is being used and tested by Bindex[^1].

  This PR would allow to improve the performance of external indexers such as electrs[^2], ElectrumX[^3], Fulcrum[^4] and Blockbook[^5].

  [^1]: https://github.com/romanz/bindex-rs
  [^2]: https://github.com/romanz/electrs (also [blockstream.info](https://github.com/Blockstream/electrs) and [mempool.space](https://github.com/mempool/electrs) forks)
  [^3]: https://github.com/spesmilo/electrumx
  [^4]: https://github.com/cculianu/Fulcrum
  [^5]: https://github.com/trezor/blockbook

ACKs for top commit:
  maflcko:
    re-ACK c48846ec41 📶
  TheCharlatan:
    Re-ACK c48846ec41
  achow101:
    ACK c48846ec41

Tree-SHA512: cf423541be90d6615289760494ae849b7239b69427036db6cc528ac81df10900f514471d81a460125522c5ffa31e9747ddfca187a1f93151e4ae77fe773c6b7b
2025-06-27 14:44:41 -07:00
Ava Chow 3086c21df4
Merge bitcoin/bitcoin#32243: test: added fuzz coverage for consensus/merkle.cpp
95969bc58a test: added fuzz coverage to consensus/merkle.cpp (kevkevinpal)

Pull request description:

  ### Summary
  This adds a new fuzz target "merkle" which adds fuzz coverage to `consensus/merkle.cpp`

  I can also add this to an existing fuzz target if that is preferable

  Before:
  ![Screenshot 2025-04-09 at 10 12 54 PM](https://github.com/user-attachments/assets/e5f8da56-4583-441d-b08f-dfcc255ff248)

  After:
  ![Screenshot 2025-04-11 at 4 20 41 PM](https://github.com/user-attachments/assets/849ee079-b715-4089-9e36-d156233236c6)

ACKs for top commit:
  marcofleon:
    ReACK 95969bc58a
  Prabhat1308:
    ACK [`95969bc`](95969bc58a)
  maflcko:
    lgtm ACK 95969bc58a
  achow101:
    ACK 95969bc58a

Tree-SHA512: e1fe8b69444733516bfa6cf2adaa199fde4c7c5582b7b908408f9313ed0f2e8cb803d27d707a1716d49606d5eaef8c1e722990bbc3cffc30fa91fe73d2233e9d
2025-06-27 13:34:30 -07:00
Ava Chow 319ff58bbd
Merge bitcoin/bitcoin#32638: blocks: force hash validations on disk read
9341b5333a blockstorage: make block read hash checks explicit (Lőrinc)
2371b9f4ee test/bench: verify hash in `ComputeFilter` reads (Lőrinc)
5d235d50d6 net: assert block hash in `ProcessGetBlockData` and `ProcessMessage` (Lőrinc)

Pull request description:

  A follow-up to https://github.com/bitcoin/bitcoin/pull/32487#discussion_r2094072165, after which validating the hash of a read block from disk doesn't incur the cost of calculating its hash anymore.

  ### Summary

  This PR adds explicit checks that the read block header's hash matches the one we were expecting.

  ### Context

  After the previous PR, validating a block's hash during read operations became essentially free. This PR leverages that by requiring callers to provide a block's expected hash (or `std::nullopt`), preventing silent failures caused by corrupted or mismatched data. Most `ReadBlock` usages were updated with expected hashes and now fail on mismatch.

  ### Changes

  * added hash assertions in `ProcessGetBlockData` and `ProcessMessage` to validate that the block read from disk matches the expected hash;
  * updated tests and benchmark to pass the correct block hash to `ReadBlock()`, ensuring the hash validation is tested - or none if we already expect PoW failure;
  * removed the default value for `expected_hash`, requiring an explicit hash for all block reads.

  ### Why is the hash still optional (but no longer has a default value)

  * for header-error tests, where the goal is to trigger failures early in the parsing process;
  * for out-of-order orphan blocks, where the child hash isn't available before the initial disk read.

ACKs for top commit:
  maflcko:
    review ACK 9341b5333a 🕙
  achow101:
    ACK 9341b5333a
  hodlinator:
    ACK 9341b5333a
  janb84:
    re ACK 9341b5333a

Tree-SHA512: cf1d4fff4c15e3f8898ec284929cb83d7e747125d4ee759e77d369f1716728e843ef98030be32c8d608956a96ae2fbefa0e801200c333b9eefd6c086ec032e1f
2025-06-27 13:28:26 -07:00
pablomartin4btc ec004cdb86 test: Use rehash() in outbound eviction block-relay
Ensure that tip_header.rehash() is used instead of tip_header.hash, which is None when the header is deserialized from hex.

This avoids depending on wait_for_getheaders() falling back to any received message, making the test more explicit and robust.
2025-06-27 13:54:01 -03:00
pablomartin4btc 26598ed21e test: Clarify roles in outbound eviction comments
Some ambiguous uses of "we" referring to either the node or the peer are replaced with clearer phrasing.

Also rephrase some comments for consistency and readability.

Applies to all relevant outbound eviction tests in p2p_eviction_logic.py.
2025-06-27 13:41:06 -03:00
merge-script 689318ccd9
Merge bitcoin/bitcoin#32667: build: Find Boost in config mode
14653b869b build: Find Boost in config mode (Hennadii Stepanov)

Pull request description:

  The `FindBoost` module has been removed by policy [CMP0167](https://cmake.org/cmake/help/latest/policy/CMP0167.html).

ACKs for top commit:
  purpleKarrot:
    ACK 14653b869b

Tree-SHA512: 5ec88647af83158f9bc04b41a3b72d4da7d84a7c81af351b8dac61cdf7f2f3b34bedd6ff164f21c229f2fd442918aaf21ba7c2c81c346b64de9032aae27b10ce
2025-06-27 14:54:54 +01:00
merge-script 4a3475a43e
Merge bitcoin/bitcoin#32819: Add release note for #32530
558f0880a8 Add release note for #32530 (Antoine Poinsot)

Pull request description:

ACKs for top commit:
  fanquake:
    ACK 558f0880a8

Tree-SHA512: 018e02d8f49a23f29d1d2ec38200ae1af9138727da3823c8afad62244c16e0076eef80bbf7ad3d3d73d553de3870bafbe9c35485cbac8d794ab7be320bbee09e
2025-06-27 12:07:36 +01:00
Antoine Poinsot 558f0880a8 Add release note for #32530 2025-06-26 12:40:26 -04:00
merge-script c43cc48aaa
Merge bitcoin/bitcoin#32530: node: cap `-maxmempool` and `-dbcache` values for 32-bit
9f8e7b0b3b node: cap -dbcache to 1GiB on 32-bit architectures (Antoine Poinsot)
2c43b6adeb init: cap -maxmempool to 500 MB on 32-bit systems (Antoine Poinsot)

Pull request description:

  32-bit architecture is limited to 4GiB of RAM, so it doesn't make sense to set a too high value. A too high value could cause an OOM unbeknownst to the user a while after startup as mempool / dbcache fills.

ACKs for top commit:
  achow101:
    ACK 9f8e7b0b3b
  instagibbs:
    utACK 9f8e7b0b3b
  dergoegge:
    Code review ACK 9f8e7b0b3b
  glozow:
    utACK 9f8e7b0b3b

Tree-SHA512: cc7541b2c0040fc21a43916caec464dfb443af808f4e85deffa1187448ffff6edb0d69f9ebdb43915d145b8b4694d8465afe548f88da53ccebc9ce4b7c34b735
2025-06-26 17:33:23 +01:00
merge-script 4145a9463a
Merge bitcoin/bitcoin#32731: depends: Build `qt` package for FreeBSD hosts
173394d951 depends: Build `qt` package for FreeBSD hosts (Hennadii Stepanov)

Pull request description:

  This PR continues the work started in https://github.com/bitcoin/bitcoin/pull/23948.

  Here is an excerpt from the log:
  ```
  $ ./build/bin/bitcoin-qt -printtoconsole
  2025-06-12T01:06:56Z Bitcoin Core version v29.99.0-15de25ba2a28 (release build)
  2025-06-12T01:06:56Z Qt 6.7.3 (static), plugin=xcb
  2025-06-12T01:06:56Z Static plugins:
  2025-06-12T01:06:56Z  QMinimalIntegrationPlugin, version 395008
  2025-06-12T01:06:56Z  QXcbIntegrationPlugin, version 395008
  2025-06-12T01:06:56Z Style: fusion / QFusionStyle
  2025-06-12T01:06:56Z System: FreeBSD 14.3-RELEASE, x86_64-little_endian-lp64
  ```

  And here are the screenshots:

  ![image](https://github.com/user-attachments/assets/acf3fefc-ee3f-41cb-ab9a-3bc4d49c7054)

  ![image](https://github.com/user-attachments/assets/6280303f-9c7b-445d-8428-172ea998343d)

ACKs for top commit:
  vasild:
    ACK 173394d951

Tree-SHA512: 42a0bd11e4ef1a23efcfe6c4ab179dc667a076e65060891ce8358b3fe78de4e3ea33f975387d4236cc2ac620e2935b0a29c278065a47f038c66658106bf36755
2025-06-26 17:28:59 +01:00
Hennadii Stepanov 14653b869b
build: Find Boost in config mode
The `FindBoost` module has been removed by policy CMP0167.
2025-06-26 16:49:24 +01:00
merge-script 67ea4b9994
Merge bitcoin/bitcoin#32814: cmake: Explicitly specify `Boost_ROOT` for Homebrew's package
8800b5acc1 cmake: Explicitly specify `Boost_ROOT` for Homebrew's package (Hennadii Stepanov)

Pull request description:

  On macOS, this PR ensures that the Boost package is located at its real path rather than via the symlink in the default prefix.

  A backport to 29.x is required for https://github.com/bitcoin/bitcoin/pull/32804, as this change prevents contamination of include directories by broad locations such as `/usr/local/include` or `/opt/homebrew/include`, which take precedence over Qt’s `-iframework` flags.

  Below is the relevant change in the configuration logs on my macOS 15.5 `x64`:
  - master branch @ ead44687483e9c936ba970de890c01d5e7ad3485:
  ```
  % cmake -B build
  <snip>
  -- Found Boost: /usr/local/include (found suitable version "1.88.0", minimum required is "1.73.0")
  <snip>
  ```
  - this PR:
  ```
  % cmake -B build
  <snip>
  -- Found Boost: /usr/local/opt/boost/include (found suitable version "1.88.0", minimum required is "1.73.0")
  <snip>
  ```

  This PR is forward-compatible with the changes proposed in https://github.com/bitcoin/bitcoin/pull/32667.

ACKs for top commit:
  fanquake:
    ACK 8800b5acc1 Checked that this plus #32805 fixes #31009

Tree-SHA512: 114bd945ec0c06a8d15b565e5b9aafc3bcfdf2a4ba4400e072b8e31053dff0f9ef423b941ee1dff2113f83e08f7fada728383ae88b3ec380b5c3e40553205f7d
2025-06-26 15:00:48 +01:00
merge-script 5170ec1ae3
Merge bitcoin/bitcoin#32665: depends: Bump boost to 1.88.0 and use new CMake buildsystem
6c2538d5bf depends: Bump boost to 1.88.0 and use new CMake buildsystem (Cory Fields)

Pull request description:

  Originally #30434.

  This has a few advantages over the old method of simply copying headers:
  - Installs proper CMake files which can be picked up by our buildsystem
  - Only installs necessary headers, not all of Boost

  Pulls in upstreamed https://github.com/boostorg/test/pull/445.

ACKs for top commit:
  willcl-ark:
    tACK 6c2538d5bf
  hebasto:
    re-ACK 6c2538d5bf, only rebased since my previous [review](https://github.com/bitcoin/bitcoin/pull/32665#pullrequestreview-2891203225).

Tree-SHA512: fc3fce77b21c8ea500370841f44f1cc87e0bb09cdde55f75d2f90853cb06a6f8c73ac6ca9ca3e91a879e9f95dd59aa40254c1b04e7a168c52fa1b31cc5b7f537
2025-06-26 14:21:08 +01:00
merge-script 8fafb81320
Merge bitcoin/bitcoin#32805: cmake: Use `HINTS` instead of `PATHS` in `find_*` commands
ead4468748 cmake: Use `HINTS` instead of `PATHS` in `find_*` commands (Hennadii Stepanov)

Pull request description:

  According to the CMake documentation, `HINTS` "should be paths computed by system introspection, such as a hint provided by the location of another item already found", which is precisely the case in the `FindQRencode` module.

  Entries in `HINTS` are searched before those in `PATHS`. On macOS, Homebrew’s `libqrencode` will therefore be located at its real path rather than via the symlink in the default prefix.

  A backport to 29.x is required for https://github.com/bitcoin/bitcoin/pull/32804, as this change prevents contamination of include directories by broad locations such as `/usr/local/include` or `/opt/homebrew/include`, which take precedence over Qt’s `-iframework` flags.

  Below is the relevant change in the configuration logs on my macOS 15.5 `x64`:
  - master branch @ ead44687483e9c936ba970de890c01d5e7ad3485:
  ```
  % cmake -B build -DBUILD_GUI=ON
  <snip>
  -- Found QRencode: /usr/local/lib/libqrencode.dylib (found version "4.1.1")
  <snip>
  ```
  - this PR:
  ```
  % cmake -B build -DBUILD_GUI=ON
  <snip>
  -- Found QRencode: /usr/local/Cellar/qrencode/4.1.1/lib/libqrencode.dylib (found version "4.1.1")
  <snip>
  ```

ACKs for top commit:
  fanquake:
    ACK ead4468748

Tree-SHA512: 1f0b04e3efeb7fe3efbb969be911abbcf56030d715acd87c0fbaf24422cdf1122f169e32242571256916c96a159212842e1e73092145c63ecc495ce429c6e587
2025-06-26 12:10:00 +01:00
leopardracer 6bb38bf37f
Update p2p_monitor.py 2025-06-26 13:06:14 +03:00
ismaelsadeeq 9b75cfda4d test: retain the intended behavior of `feature_fee_estimation.py` nodes
- Increase block weight by 4000 for all nodes with custom -blockmaxweight.
  Prior to this commit, we generated blocks with 4000 weight units less worth of transactions.
  See https://github.com/bitcoin/bitcoin/issues/32461#issuecomment-2925282272 for details.
  This commit fixes it by increasing the block weight by 4000.
2025-06-26 07:13:27 +01:00
ismaelsadeeq 5c1236f04a test: fix incorrect subtest in `feature_fee_estimation.py`
- Update `check_smart_estimates` to calculate the fee rate ceiling
   by taking the maximum of fees seen, minrelaytxfee, and mempoolminfee.
- Improve the subtest name and comments.
2025-06-26 07:11:25 +01:00
merge-script e5f9218b6a
Merge bitcoin/bitcoin#32742: test: fix catchup loop in outbound eviction functional test
dd8447f70f test: fix catchup loop in outbound eviction functional test (Sebastian Falbesoner)

Pull request description:

  In the course of working on an equivalent of #32421 for the `CBlockHeader` class, I noticed that the [catchup loop in the outbound eviction functional test](19765dca19/test/functional/p2p_outbound_eviction.py (L86-L103)) currently has a small flaw: the contained waiting for a `getheaders` message

  19765dca19/test/functional/p2p_outbound_eviction.py (L98-L99)

  only waits for _any_ such message instead of one with the intended block hash after the first iteration. The reason is that the `prev_prev_hash` variable is set incorrectly, since the `tip_header` instance is not updated and its field `.hash` is None [1]. Fix that by updating `tip_header` after generating a new block and also use the correct field on it -- we want the tip header's previous hash (`.hashPrevBlock`), which will be the previous-previous hash in the next iteration as intended.

  Can be demonstrated by adding a debug output for `prev_prev_hash`, e.g.

  ```diff
  diff --git a/test/functional/p2p_outbound_eviction.py b/test/functional/p2p_outbound_eviction.py
  index 30ac85e32f..9886a49512 100755
  --- a/test/functional/p2p_outbound_eviction.py
  +++ b/test/functional/p2p_outbound_eviction.py
  @@ -85,6 +85,7 @@ class P2POutEvict(BitcoinTestFramework):

           self.log.info("Keep catching up with the old tip and check that we are not evicted")
           for i in range(10):
  +            print(f"i={i}, prev_prev_hash={prev_prev_hash}")
               # Generate an additional block so the peers is 2 blocks behind
               prev_header = from_hex(CBlockHeader(), node.getblockheader(best_block_hash, False))
               best_block_hash = self.generateblock(node, output="raw(42)", transactions=[])["hash"]
  ```

  master branch
  ```
  ...
  i=0, prev_prev_hash=21722572577213525620063947414919931742473663114977483853465070858884938201585
  i=1, prev_prev_hash=None
  i=2, prev_prev_hash=None
  i=3, prev_prev_hash=None
  i=4, prev_prev_hash=None
  i=5, prev_prev_hash=None
  i=6, prev_prev_hash=None
  i=7, prev_prev_hash=None
  i=8, prev_prev_hash=None
  i=9, prev_prev_hash=None
  ...
  ```

  PR branch
  ```
  ...
  i=0, prev_prev_hash=21722572577213525620063947414919931742473663114977483853465070858884938201585
  i=1, prev_prev_hash=23204083306104595181276643925327085197417756603258684897360269464191973063397
  i=2, prev_prev_hash=18117007775254206852722585270408843074799046031613422902091537272077477361634
  i=3, prev_prev_hash=30556804635951812756130312631227721973553160707632138130845362630877961299882
  i=4, prev_prev_hash=16476515948153779819467376247405243058769281687868039119037064816106574626111
  i=5, prev_prev_hash=14965506521435221774966695805624206855826023174786191695076697927307467053159
  i=6, prev_prev_hash=14510815979277079515923749862202324542606166669768865640616202929053689167149
  i=7, prev_prev_hash=15360268707191667685151951417759114642582372006627142890517655217275478262166
  i=8, prev_prev_hash=55984929479619644661389829786223559362979512070332438490054115824374865094074
  i=9, prev_prev_hash=6591573629906616262191232272909118561529534571119028248829355592878183757083
  ...
  ```

  [1] that's in my opinion another example how caching hashes is confusing and easy to be misused; it's better to remove it and just compute the hash on-the-fly, so returning None is not even possible anymore

ACKs for top commit:
  maflcko:
    lgtm ACK dd8447f70f
  mzumsande:
    Code Review ACK dd8447f70f
  pablomartin4btc:
    cr-ACK dd8447f70f

Tree-SHA512: bd8e786b52e3e96661453006140d6b8fad5a35f1c8d38243c61df52b19c97cd3800404745a2f9603bcdf0006e9780b4f15f8f7e4fa34ff07d52dba04d87b68d0
2025-06-25 18:13:33 -04:00
marcofleon 11d28f21bb Implement GenTxid as a variant
Reimplements the GenTxid class as a variant for better type safety.
Also adds two temporary functions to the old GenTxid class that
convert to and from the new variant.
2025-06-25 23:08:15 +01:00
Ava Chow 215e5999e2 wallet: Remove unused CachedTxGet{Available,Immature}Credit
These two functions are no longer used as GetBalances now uses the TXO
set rather than per-tx cached balances
2025-06-25 14:08:49 -07:00
Ava Chow 49675de035 wallet: Have GetDebit use the wallet's TXO set
Instead of looking up the previous tx in mapWallet, and then calling
IsMine on the specified output, use the TXO set and its cached IsMine
value.
2025-06-25 14:08:49 -07:00
Ava Chow 17d453cb3a wallet: Recompute wallet TXOs after descriptor migration
When a legacy wallet has been migrated to contain descriptors, but
before the transactions have been updated to match, we need to recompute
the wallet TXOs so that the transaction update will work correctly.
2025-06-25 14:08:49 -07:00
Ava Chow 764016eb22 wallet: Retrieve TXO directly in FetchSelectedInputs
Instead of searching mapWallet for the preselected inputs, search
m_txos.

wallet_fundrawtransaction.py spends external inputs and needs the change
output to also belong to the test wallet for the oversized tx test.
2025-06-25 14:08:49 -07:00
Ava Chow c1801b78f1 wallet: Use wallet's TXO set in AvailableCoins
Instead of iterating every transaction and every output stored in wallet
when trying to figure out what outputs can be spent, iterate the TXO set
which should be a lot smaller.
2025-06-25 14:08:49 -07:00
Ava Chow dde7cbe105 wallet: Change balance calculation to use m_txos
Since we track the outputs owned by the wallet with m_txos, we can now
calculate the balance of the wallet by iterating m_txos and summing up
the amounts of the unspent txos.

As ISMINE_USED is not an actual isminetype that we attach to outputs and
was just passed into `CachedTxGetAvailableCredit` for convenience, we
pull the same determining logic from that function into `GetBalances` in
order to preserve existing behavior.
2025-06-25 14:08:49 -07:00
Ava Chow 96e7a89c5e wallet: Recalculate the wallet's txos after any imports 2025-06-25 14:08:49 -07:00
Ava Chow ae888c38d0 wallet: Exit IsTrustedTx early if wtx is already in trusted_parents 2025-06-25 14:08:49 -07:00
Ava Chow ae0876ec42 wallet: Keep track of transaction outputs owned by the wallet
When loading transactions to the wallet, check the outputs, and keep
track of the ones that are IsMine.
2025-06-25 14:08:49 -07:00
Ava Chow 0f269bc48c walletdb: Load Txs last
Need to load txs last so that IsMine works.
2025-06-25 14:08:49 -07:00
Ava Chow 5cc32ee2a7 test: Test for balance update due to untracked output becoming spendable 2025-06-25 14:08:27 -07:00
Ava Chow 8222341d4f wallet: MarkDirty after AddWalletDescriptor
After adding a wallet descriptor (typically by import), mark all balance
caches dirty. This allows transactions that the wallet already knows
about that have outputs that are now ISMINE_SPENDABLE after the import
to actually be shown in balance calculations. Legacy wallet imports
would do this, but importdescriptors did not.
2025-06-25 14:08:27 -07:00
Ava Chow e02f2d331c bench: Have AvailableCoins benchmark include a lot of unrelated utxos
One of the main issues with AvailableCoins is its performance when txs
have unrelated outputs, so update the benchmark to check the performance
of that.
2025-06-25 14:08:27 -07:00
merge-script f27898c8bf
Merge bitcoin/bitcoin#32721: wallet, rpc: Remove deprecated balances from getwalletinfo and getunconfirmedbalance
c3fe85e2d6 wallet, rpc, test: Remove deprecated getunconfirmedbalance (Ava Chow)
0ec255139b wallet, rpc: Remove deprecated balances from getwalletinfo (Ava Chow)

Pull request description:

  `getwalletinfo` result fields `balance`, `immature_balance`, and `unconfirmed_balance`, and the `getunconfirmedbalance` RPC have all been deprecated since 0.19.0. It's been long enough that they should either be removed or undeprecated. The functionality provided by these RPCs is provided by `getbalances`.

ACKs for top commit:
  davidgumberg:
    ACK c3fe85e2d6
  rkrux:
    ACK c3fe85e2d6
  BrandonOdiwuor:
    ACK c3fe85e2d6 removing the deprecated `balance, unconfirmed_balance, immature_balance` fields from `getwalletinfo` and `getunconfirmedbalance` RPCs, as this infomation can be found on the `getbalances` RPC
  w0xlt:
    reACK c3fe85e2d6

Tree-SHA512: c7c4acfd9cabc7517ba813b95281a6c6a717a417312afd9346298669b4f7bd37724ad977148ce42db7fd47fc3d1f5a8482d8ff2e7b9cb74756b171a5b8b91ef2
2025-06-25 16:43:09 -04:00
merge-script 8578fabb95
Merge bitcoin/bitcoin#32597: wallet: Always set descriptor cache upgraded flag for new wallets
47237cd193 wallet, rpc: Output wallet flags in getwalletinfo (Ava Chow)
bc2a26b296 wallet: Add GetWalletFlags (Ava Chow)
69f588a99a wallet: Set upgraded descriptor cache flag for newly created wallets (Ava Chow)

Pull request description:

  Newly created wallets will always have an upgraded descriptor cache, so set those.

  Also, to verify this behavior, add a new `flags` field to `getwalletinfo` and check that in the functional tests.

  Split from #32489

ACKs for top commit:
  Sjors:
    ACK 47237cd193
  w0xlt:
    ACK 47237cd193
  rkrux:
    ACK 47237cd193

Tree-SHA512: 97c7f85b858efe5ced9b8aafb6cd7c1a547de6f8013b82bfc75bc567cf73c9db5e168e3980355756541305520022fd776b8d4d240d3fb34ed86c27d2acaf4863
2025-06-25 16:14:01 -04:00
Max Edwards 941b8f54c0 ci: run get_previous_releases as part of test cross win job
This should enable wallet_migration functional test to run on Windows
2025-06-25 21:06:10 +01:00
Max Edwards 5e2182140b test: increment mocked time for migrating wallet backups
The wallet backups performed before migration use the time as part of
their filename. As the time is mocked, increment it between migration
attempts to prevent file name conflicts which is a problem on Windows.
2025-06-25 21:06:10 +01:00
Max Edwards 5174565802 ci: disable feature_unsupported_utxo_db functional test
This test required v0.14.3 which doesn't support special characters like
emojis in the datapath on windows. Functional test runner includes a few
emojis in it's default data directory.
2025-06-25 21:06:10 +01:00
Max Edwards 3dc90d69a6 test: remove mempool.dat before copying
Renaming mempool.dat from old node to new node fails on windows as the
file already exists.
2025-06-25 21:06:10 +01:00
Max Edwards 67a6b20d50 test: add windows support to get previous releases script
Needed to allow the wallet migration functional test to run under native
windows. Platform variable renamed to not clash with platform package.
2025-06-25 21:06:08 +01:00
merge-script 01f9081955
Merge bitcoin/bitcoin#32768: wallet: Remove `CWalletTx::fTimeReceivedIsTxTime`
9eb2c82e7c walletdb: Remove unused upgraded_txs (Ava Chow)
c668033709 wallet: Remove unused fTimeReceivedIsTxTime (Ava Chow)

Pull request description:

  `CWalletTx::fTimeReceivedIsTxTime` is no longer used and can be removed. This additionally allows the removal of the `upgraded_txs` loop in `LoadWallet`.

ACKs for top commit:
  maflcko:
    lgtm ACK 9eb2c82e7c
  Eunovo:
    ACK 9eb2c82e7c
  davidgumberg:
    ACK 9eb2c82e7c
  PeterWrighten:
    ACK 9eb2c82e7c
  rkrux:
    ACK 9eb2c82e7c
  w0xlt:
    ACK 9eb2c82e7c

Tree-SHA512: 05cf3a50f0d8ab6ef423ad1113c5ce6f45bfdc90e2c0dcf61c2dceced2465502e574b4b5b0091fcbb4bdd2182f8d69224f1e5516c7c505de07102b84a5f40e9c
2025-06-25 16:04:54 -04:00
merge-script c1d8a542b4
Merge bitcoin/bitcoin#32727: doc: add release notes for #32425
b9a2e8ee96 doc: add release notes for https://github.com/bitcoin/bitcoin/pull/32425 (Vasil Dimov)

Pull request description:

  Add release notes for https://github.com/bitcoin/bitcoin/pull/32425.

ACKs for top commit:
  pablomartin4btc:
    re-ACK b9a2e8ee96
  janb84:
    reACK b9a2e8ee96
  glozow:
    ACK b9a2e8ee96, thanks for taking suggestions!

Tree-SHA512: 617612504977007909fde921e7e40286bcf81310f9cf3996783d6148219906784e9749d67f7a9a13305d7788208143e5f6ecceafbc6790f52dd08ffd9f91944c
2025-06-25 15:58:30 -04:00
Max Edwards 1a1b478ca3 scripted-diff: rename tarball to archive
Windows zip files are added in the next commit which are not tarballs so
renaming tarball to the more generic term archive which can cover both.

-BEGIN VERIFY SCRIPT-
sed -i 's/tarball/archive/g' test/get_previous_releases.py
-END VERIFY SCRIPT-
2025-06-25 20:56:28 +01:00
Max Edwards 4f06dc8484 test: remove building from source from get prev releases script
Using the get_previous_releases.py script to build from source only works for
releases prior to v29 due to removal of Autotools (in favor of CMake). It also
does not support building on Windows, and we are adding support for downloading
Windows release binaries in later commits of this PR.

As there were no complaints during review, it is assumed nobody uses this
functionality.
2025-06-25 20:56:22 +01:00
will 45b1d39757
doc: Add fetching single PRs from upstream
Current recommendation is to add a new remote fetching all PRs, but this
is resource-intensive.

Document a better way to fetch a single PR, and to update a PR which has
been force-pushed.
2025-06-25 20:27:04 +01:00
Hennadii Stepanov 8800b5acc1 cmake: Explicitly specify `Boost_ROOT` for Homebrew's package
On macOS, this change ensures that the Boost package is located at its
real path rather than via the symlink in the default prefix.
2025-06-25 18:45:43 +01:00
Vasil Dimov b9a2e8ee96
doc: add release notes for https://github.com/bitcoin/bitcoin/pull/32425
Co-authored-by: Jan B <608446+janb84@users.noreply.github.com>
2025-06-25 18:23:31 +02:00
ishaanam aac0b6dd79 test: test sendall and send do anti-fee-sniping 2025-06-25 11:56:07 -04:00
ishaanam 20802c7b65 wallet, rpc: add anti-fee-sniping to `send` and `sendall` 2025-06-25 11:55:46 -04:00
Cory Fields 6c2538d5bf
depends: Bump boost to 1.88.0 and use new CMake buildsystem
This has a few advantages over the old method of simply copying headers:
- Installs proper cmake files which can be picked up by our buildsystem
- Only installs necessary headers, not all of boost

Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2025-06-25 13:37:50 +01:00
merge-script 7d5a6d1739
Merge bitcoin/bitcoin#32798: build: add root dir to CMAKE_PREFIX_PATH in toolchain
e27a94596f build: add root dir to CMAKE_PREFIX_PATH (will)

Pull request description:

  Fixes: #32428

  Nix patches `cmake` to remove the root directory `/` from `CMAKE_PREFIX_PATH`:
  428b49b28e/pkgs/by-name/cm/cmake/001-search-path.diff (L10)

  Without this, and when using the toolchain for depends builds, cmake's `find_path()` and `find_package()` do not know where to find dependencies, causing issues like as seen in #32428

  Adding this path back is harmless on other systems, and fixes the toolchain for Nix users.

  As described in https://github.com/bitcoin/bitcoin/issues/32428#issuecomment-2991258328 I think this can be taken as a temporary fix whilst a longer-term solution is worked on.

ACKs for top commit:
  josibake:
    reACK e27a94596f
  hebasto:
    ACK e27a94596f, I have reviewed the code and it looks OK.
  janb84:
    reACK e27a94596f

Tree-SHA512: f299f2bab2620179518da866cbb7992d41d142ad42e79c14496e72f725a1dc60698b3e4b1daf45d28f71f32a23f0c8d7b4f6c6cf33aeedf322b7ef565b70b4af
2025-06-25 11:37:37 +01:00
Pieter Wuille a34fb9ad6c
miniscript: Make `operator""_mst` `consteval` 2025-06-25 11:33:18 +01:00
Hennadii Stepanov 14052162b1
Revert "miniscript: make operator_mst consteval"
This reverts commit 63317103c9.

operator""_mst has been manually adjusted according to commit
faf2162565
2025-06-25 11:32:57 +01:00
Ava Chow 5fe7915c86 doc: Add musig() example 2025-06-24 13:43:32 -07:00
Ava Chow d576079ab4 tests: Test musig() parsing 2025-06-24 13:43:32 -07:00
Ava Chow a53924bee3 descriptor: Parse musig() key expressions 2025-06-24 13:40:12 -07:00
Ava Chow 9473e9606c descriptors: Move DeriveType parsing into its own function 2025-06-24 13:39:54 -07:00
Ava Chow 4af0dca096 descriptor: Add MuSigPubkeyProvider 2025-06-24 13:35:29 -07:00
Hennadii Stepanov ead4468748 cmake: Use `HINTS` instead of `PATHS` in `find_*` commands
According to the CMake documentation, `HINTS` "should be paths computed
by system introspection, such as a hint provided by the location of
another item already found", which is precisely the case in the
`FindQRencode` module.

Entries in `HINTS` are searched before those in `PATHS`. On macOS,
Homebrew’s `libqrencode` will therefore be located at its real path
rather than via the symlink in the default prefix.
2025-06-24 20:49:27 +01:00
merge-script ad654a4807
Merge bitcoin/bitcoin#32767: ci: Allow running CI in worktrees
fa68dcb207 ci: Add missing errexit to lint CI install (MarcoFalke)
fa535a6de7 ci: Allow running CI in worktrees (MarcoFalke)
faf6a04597 ci: Clean UID/GID mismatch (MarcoFalke)

Pull request description:

  Fixes #30028 (modulo lint and tidy CI).

  The error on current master in a worktree is:

  ```
  $ git worktree add ./main origin/master && cd ./main
  $ MAKEJOBS="-j$(nproc)" FILE_ENV="./ci/test/00_setup_env_mac_cross.sh" ./ci/test_run_all.sh
  ...
  + git config --global ci.base-install-done true
  fatal: not a git repository: /root/b-c-ci/.git/worktrees/main
  ```

  So just use a plain file, instead of git. Also, enable pipefail while touching this bash script.

ACKs for top commit:
  willcl-ark:
    tACK fa68dcb207

Tree-SHA512: 0ce360a80883b4aa655fe8a99c38eb54a465b17c7cdb0a69a2d886ff78da32d6af996412ffc5b0db0322acafa9650619838573484de8243dc41594a04a6e17ec
2025-06-24 14:18:20 +01:00
merge-script 67e6746dc8
Merge bitcoin/bitcoin#32780: lsan: add more Qt suppressions
5be31b20e5 lsan: add more Qt suppressions (fanquake)

Pull request description:

  Using Clang clang version 20.1.6 (Fedora 20.1.6-9.fc43) and:
  ```bash
  export CC=clang
  export CXX=clang++
  cmake -B build -DBUILD_GUI=ON -DSANITIZERS=address
  cmake --build build
  export LSAN_OPTIONS="suppressions=/root/bitcoin/test/sanitizer_suppressions/lsan"
  ctest --test-dir build
  ```

  ```bash
  Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted, 1589ms
  ********* Finished testing of AddressBookTests *********

  =================================================================
  ==21869==ERROR: LeakSanitizer: detected memory leaks

  Direct leak of 88 byte(s) in 1 object(s) allocated from:
      #0 0xaaaab5d5af40 in operator new(unsigned long) (/root/bitcoin/build/bin/test_bitcoin-qt+0x39af40) (BuildId: c0e038f1c507ea6860d1cfd499ac54ad83359872)
      #1 0xffff8c8f56cc in QLayoutPrivate::createWidgetItem(QLayout const*, QWidget*) (/lib64/libQt6Widgets.so.6+0x1a56cc) (BuildId: 8b7b9e470f4d4cd920282a4f963abb01225814fa)
      #2 0xffff8c8d2f90 in QBoxLayout::insertWidget(int, QWidget*, int, QFlags<Qt::AlignmentFlag>) (/lib64/libQt6Widgets.so.6+0x182f90) (BuildId: 8b7b9e470f4d4cd920282a4f963abb01225814fa)
      #3 0xaaaab5fc7188 in SendCoinsDialog::addEntry() /root/bitcoin/build/src/qt/./qt/sendcoinsdialog.cpp:596:18
      #4 0xaaaab5fc4eec in SendCoinsDialog::SendCoinsDialog(PlatformStyle const*, QWidget*) /root/bitcoin/build/src/qt/./qt/sendcoinsdialog.cpp:84:5
      #5 0xaaaab5da67ac in (anonymous namespace)::MiniGUI::MiniGUI(interfaces::Node&, PlatformStyle const*) /root/bitcoin/build/src/qt/test/./qt/test/wallettests.cpp:235:75
      #6 0xaaaab5da2000 in (anonymous namespace)::TestGUI(interfaces::Node&, std::shared_ptr<wallet::CWallet> const&) /root/bitcoin/build/src/qt/test/./qt/test/wallettests.cpp:270:13
      #7 0xaaaab5d9ebc8 in (anonymous namespace)::TestGUI(interfaces::Node&) /root/bitcoin/build/src/qt/test/./qt/test/wallettests.cpp:453:5
      #8 0xaaaab5d9ebc8 in WalletTests::walletTests() /root/bitcoin/build/src/qt/test/./qt/test/wallettests.cpp:475:5
      #9 0xffff8b1c5314 in QMetaMethodInvoker::invokeImpl(QMetaMethod, void*, Qt::ConnectionType, long long, void const* const*, char const* const*, QtPrivate::QMetaTypeInterface const* const*) (/lib64/libQt6Core.so.6+0x195314) (BuildId: eacb2d1228362560e5df1a1ce496c99ad61960e7)
      #10 0xffff8b1c5dc8 in QMetaMethod::invokeImpl(QMetaMethod, void*, Qt::ConnectionType, long long, void const* const*, char const* const*, QtPrivate::QMetaTypeInterface const* const*) (/lib64/libQt6Core.so.6+0x195dc8) (BuildId: eacb2d1228362560e5df1a1ce496c99ad61960e7)
      #11 0xffff8cf57c54  (/lib64/libQt6Test.so.6+0x27c54) (BuildId: 96bb1cdeead53af0ced36d7970cf9cd79c4c4ccd)
      #12 0xffff8cf5fa18  (/lib64/libQt6Test.so.6+0x2fa18) (BuildId: 96bb1cdeead53af0ced36d7970cf9cd79c4c4ccd)
      #13 0xffff8cf6067c  (/lib64/libQt6Test.so.6+0x3067c) (BuildId: 96bb1cdeead53af0ced36d7970cf9cd79c4c4ccd)
      #14 0xffff8cf610a4  (/lib64/libQt6Test.so.6+0x310a4) (BuildId: 96bb1cdeead53af0ced36d7970cf9cd79c4c4ccd)
      #15 0xffff8cf61aa4 in QTest::qRun() (/lib64/libQt6Test.so.6+0x31aa4) (BuildId: 96bb1cdeead53af0ced36d7970cf9cd79c4c4ccd)
      #16 0xffff8cf61eb4 in QTest::qExec(QObject*, int, char**) (/lib64/libQt6Test.so.6+0x31eb4) (BuildId: 96bb1cdeead53af0ced36d7970cf9cd79c4c4ccd)
      #17 0xaaaab5d7d77c in main /root/bitcoin/build/src/qt/test/./qt/test/test_main.cpp:95:30
      #18 0xffff8aad6398 in __libc_start_call_main (/lib64/libc.so.6+0x26398) (BuildId: 627f878dd454ee3cc1dfdbd347bb565f1ffb53e7)
      #19 0xffff8aad6478 in __libc_start_main@GLIBC_2.17 (/lib64/libc.so.6+0x26478) (BuildId: 627f878dd454ee3cc1dfdbd347bb565f1ffb53e7)
      #20 0xaaaab5c74cac in _start (/root/bitcoin/build/bin/test_bitcoin-qt+0x2b4cac) (BuildId: c0e038f1c507ea6860d1cfd499ac54ad83359872)
  ```

  This happens when building using depends:
  ```bash
  Indirect leak of 24 byte(s) in 1 object(s) allocated from:
      #0 0xaaaabdbe86f8 in malloc (/root/bitcoin/build/bin/test_bitcoin-qt+0x4386f8) (BuildId: dd54811dc11325890f7bac3e3a49d38f5a7ffef5)
      #1 0xfbff97f8c164  (<unknown module>)
      #2 0xaaaabf0cfaa4 in QDBusConnectionPrivate::QDBusConnectionPrivate() (/root/bitcoin/build/bin/test_bitcoin-qt+0x191faa4) (BuildId: dd54811dc11325890f7bac3e3a49d38f5a7ffef5)
      #3 0xaaaabf0c9e30 in QDBusConnectionManager::doConnectToStandardBus(QDBusConnection::BusType, QString const&, bool) (/root/bitcoin/build/bin/test_bitcoin-qt+0x1919e30) (BuildId: dd54811dc11325890f7bac3e3a49d38f5a7ffef5)
      #4 0xaaaabf0cb0e4 in QtPrivate::QCallableObject<QDBusConnectionPrivate* (QDBusConnectionManager::*)(QDBusConnection::BusType, QString const&, bool), QtPrivate::List<QDBusConnection::BusType&, QString const&, bool&>, QDBusConnectionPrivate*>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) (/root/bitcoin/build/bin/test_bitcoin-qt+0x191b0e4) (BuildId: dd54811dc11325890f7bac3e3a49d38f5a7ffef5)
      #5 0xaaaabf5cbaf0 in QObject::event(QEvent*) (/root/bitcoin/build/bin/test_bitcoin-qt+0x1e1baf0) (BuildId: dd54811dc11325890f7bac3e3a49d38f5a7ffef5)
      #6 0xaaaabf5a4ce0 in QCoreApplicationPrivate::notify_helper(QObject*, QEvent*) (/root/bitcoin/build/bin/test_bitcoin-qt+0x1df4ce0) (BuildId: dd54811dc11325890f7bac3e3a49d38f5a7ffef5)
      #7 0xaaaabf5a486c in QCoreApplication::notifyInternal2(QObject*, QEvent*) (/root/bitcoin/build/bin/test_bitcoin-qt+0x1df486c) (BuildId: dd54811dc11325890f7bac3e3a49d38f5a7ffef5)
      #8 0xaaaabf5a575c in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) (/root/bitcoin/build/bin/test_bitcoin-qt+0x1df575c) (BuildId: dd54811dc11325890f7bac3e3a49d38f5a7ffef5)
      #9 0xaaaabf66b858 in QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (/root/bitcoin/build/bin/test_bitcoin-qt+0x1ebb858) (BuildId: dd54811dc11325890f7bac3e3a49d38f5a7ffef5)
      #10 0xaaaabf5a9e3c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (/root/bitcoin/build/bin/test_bitcoin-qt+0x1df9e3c) (BuildId: dd54811dc11325890f7bac3e3a49d38f5a7ffef5)
      #11 0xaaaabf632a44 in QThread::exec() (/root/bitcoin/build/bin/test_bitcoin-qt+0x1e82a44) (BuildId: dd54811dc11325890f7bac3e3a49d38f5a7ffef5)
      #12 0xaaaabf0c9bd0 in QDBusConnectionManager::run() (/root/bitcoin/build/bin/test_bitcoin-qt+0x1919bd0) (BuildId: dd54811dc11325890f7bac3e3a49d38f5a7ffef5)
      #13 0xaaaabf669c30 in QThreadPrivate::start(void*) (/root/bitcoin/build/bin/test_bitcoin-qt+0x1eb9c30) (BuildId: dd54811dc11325890f7bac3e3a49d38f5a7ffef5)
      #14 0xaaaabdbe5f2c in asan_thread_start(void*) asan_interceptors.cpp.o
      #15 0xffff99538608 in thread_start (/lib64/libc.so.6+0xf8608) (BuildId: 627f878dd454ee3cc1dfdbd347bb565f1ffb53e7)

  SUMMARY: AddressSanitizer: 3592 byte(s) leaked in 37 allocation(s).
  ```

ACKs for top commit:
  maflcko:
    lgtm ACK 5be31b20e5

Tree-SHA512: 0c33661c7ec83ea9b874c1ee4ee2de513131690287363e216a88560dfb31a59ef563a50af756c86a991583aa64a600a74e20fd5d6a104cf4c0a27532de8d2211
2025-06-24 14:07:59 +01:00
will e27a94596f
build: add root dir to CMAKE_PREFIX_PATH
Nix patches cmake to remove the root directory `/` from
`CMAKE_SYSTEM_PREFIX_PATH`:
428b49b28e/pkgs/by-name/cm/cmake/001-search-path.diff (L10)

Without this, and when using the toolchain for depends builds, cmake's
`find_path()` and `find_package()` do not know where to find
dependencies, causing issues like:
https://github.com/bitcoin/bitcoin/issues/32428

Adding this path back via CMAKE_PREFIX_PATH is harmless on other
systems, and fixes the toolchain for Nix users.

We append the `/` dir a maximum of once, as the toolchain may be called
repeatedly during builds.

Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
Co-authored-by: josibake <josibake@protonmail.com>
2025-06-24 14:02:02 +01:00
Hennadii Stepanov 173394d951
depends: Build `qt` package for FreeBSD hosts 2025-06-24 12:23:02 +01:00
Sebastian Falbesoner 922adf66ac mempool: use `FeeFrac` for calculating regular score 2025-06-24 02:49:31 +02:00
Sebastian Falbesoner 3322b3a059 mempool: use `FeeFrac` for calculating ancestor score 2025-06-24 02:34:29 +02:00
Sebastian Falbesoner ac9c113bd2 mempool: use `FeeFrac` for calculating descendant score 2025-06-24 02:23:09 +02:00
merge-script e95bfc1d53
Merge bitcoin/bitcoin#32797: doc: archive 28.2 release notes
907842363c doc: archive 28.2 release notes (fanquake)

Pull request description:

  v28.2 is now tagged: https://github.com/bitcoin/bitcoin/releases/tag/v28.2.

ACKs for top commit:
  glozow:
    ACK  907842363c

Tree-SHA512: 49cde7ac9bbf08510c1914e5c9e0b80e31333a554318e29c9b61a9975d6d6308dabf5c3d8c736eba7aedee815de95d013f39456716c60cef76f0bc712dd74d6c
2025-06-23 17:50:21 -04:00
Martin Zumsande 666016e56b ci: use --usecli in one of the CI jobs
This helps avoid regressions (changes to functional tests
that are not compatible with -usecli).
2025-06-23 17:42:56 -04:00
Martin Zumsande 7ea248a020 test: Disable several (sub)tests with cli
Reason for each test:
rpc_whitelist.py: Relies on direct RPC calls
wallet_encryption.py: Null characters cannot be passed to suprocess.Popen
wallet_fundrawtransaction.py: multiple checks for wrong types, which have different error messages with cli
wallet_send.py: multiple checks for wrong types
2025-06-23 17:42:56 -04:00
Martin Zumsande f420b6356b test: skip subtests that check for wrong types with cli
The error messages returned for wrong type differ betwen
using rpc or cli - skip these subtests where they happen.
2025-06-23 17:42:56 -04:00
Martin Zumsande 6530d0015b test: add function to convert to json for height_or_hash params
This is necessary for bitcoin-cli because a string without quotes
is not a valid json.
2025-06-23 17:42:56 -04:00
Martin Zumsande 54d28722ba test: Don't send empty named args with cli
If python passed None for an optional (i.e. 'null' is
sent), this will lead to the arg being interpreted as not
provided by bitcoind - except for string args, for which the arg is
interpreted as as 'null' string. Bypass this by not sending
named args to bitcoin-cli - so that the default value will
actually be used.

Also drops an unnecessary str() conversion, kwargs keys
are always strings.
2025-06-23 17:42:56 -04:00
Martin Zumsande cca422060e test: convert tuple to json for cli
This makes it possible to run rpc_createmultisig.py with --usecli.
2025-06-23 17:42:56 -04:00
Martin Zumsande af34e98086 test: make rpc_psbt.py usable with --usecli
The psbt string would include a "=" sign, which would
make the cli interpret this as a named argument.
Fix this by making it an actual named arg with the
correct name.
2025-06-23 17:42:56 -04:00
Martin Zumsande 8f8ce9e174 test: rename .rpc to ._rpc and remove unnecessary uses
It is usually not necessary, and makes it impossible to use --usecli
2025-06-23 17:42:55 -04:00
Martin Zumsande 5b08885986 test: enable functional tests with large rpc args for cli
Also, the following tests (for which self.supports_cli = False was not
set) will now work with --usecli:

feature_fastprune.py
feature_fee_estimation.py
feature_reindex_readonly.py
feature_taproot.py
mempool_package_rbf.py
p2p_net_deadlock.py
p2p_tx_download.py
rpc_packages.py
2025-06-23 17:42:55 -04:00
Martin Zumsande 7d5352ac73 test: use -stdin for large rpc commands
Because of the MAX_ARG_STRLEN limit (128kb on most systems)
for args, these would usually fail. As a workaround, use
-stdin for these large calls. Idea by 0xB10C.

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2025-06-23 17:42:55 -04:00
Martin Zumsande 6c364e0c10 test: Enable various tests for usage with cli
These tests run successfully on current master without any changes.
2025-06-23 17:42:55 -04:00
fanquake 907842363c
doc: archive 28.2 release notes 2025-06-23 10:15:14 +01:00
merge-script c5849663ba
Merge bitcoin/bitcoin#32771: contrib: tracing: Fix read of `pmsg_type` in p2p_monitor.py
3473986fe1 contrib: tracing: Correctly read msg type in p2p_monitor.py (David Gumberg)

Pull request description:

  This fixes a bug in the contrib tracing script `p2p_monitor.py`. currently the script fails to read the `msg_type` of inbound and outbound messages, which is useful in the per-peer message view.

  <details>
  <summary>Screenshot of p2p_monitor.py on master</summary>

  ![Screenshot From 2025-06-18 11-37-43](https://github.com/user-attachments/assets/56612088-54d7-465c-b0b6-1b425b919785)
  </details>

  <details>
  <summary>Screenshot of p2p_monitor.py on this branch</summary>

  ![Screenshot From 2025-06-18 11-41-38](https://github.com/user-attachments/assets/4438a483-938c-450b-a12e-6d6909b2c37e)

  </details>

ACKs for top commit:
  yuvicc:
    ACK 3473986fe1
  janb84:
    ut ACK 3473986fe1
  0xB10C:
    ACK 3473986fe1

Tree-SHA512: 94da0dc35072933a20ef693024855b3c382fc6f5ae0a3108d092d7aa5a4004df478f5de07b80f675be13e00f3f4596b0f34c49ec1d8d2c38a15797dcf86c2a56
2025-06-23 09:53:36 +01:00
merge-script 8a36a471e6
Merge bitcoin/bitcoin#32781: refactor: modernize deprecated ipc headers
74b7e9c7db refactor: modernize deprecated ipc headers (Sjors Provoost)

Pull request description:

  Split off from #31802.

  Pre-empt tidy warning when multiprocess is on by default:

  ```
  [10:33:51.654] /ci_container_base/src/ipc/capnp/protocol.cpp:20:10: error: inclusion of deprecated C++ header 'errno.h'; consider using 'cerrno' instead [modernize-deprecated-headers,-warnings-as-errors]
  [10:33:51.654]    20 | #include <errno.h>
  [10:33:51.654]       |          ^~~~~~~~~
  [10:33:51.654]       |          <cerrno>
  [10:33:51.654] 919 warnings generated.
  ```

  https://github.com/bitcoin/bitcoin/pull/31802/checks?check_run_id=43968493627

ACKs for top commit:
  maflcko:
    lgtm ACK 74b7e9c7db
  ryanofsky:
    Code review ACK 74b7e9c7db

Tree-SHA512: a629e9849b420c9de52dc7a74d35ca14c3522784ac101a189b20d3439a4735e2f3bb766864938abb2fc248eb94ec15c71c35db69a3267b6c29ef26e0f91a79ab
2025-06-23 09:48:45 +01:00
Ava Chow ed060e01e7
Merge bitcoin/bitcoin#32725: test: round difficulty and networkhashps
578ea3eedb test: round difficulty and networkhashps (Sjors Provoost)

Pull request description:

  Both are rational numbers. Client software should only use them to display information to humans. Followup calculations should use the underlying values such as target.

  Therefore it's not necessary to test the handling of these floating point values. Round them down to avoid spurious test failures.

  Fixes #32515

ACKs for top commit:
  Prabhat1308:
    Code Review ACK [`578ea3e`](578ea3eedb)
  achow101:
    ACK 578ea3eedb
  w0xlt:
    Code review ACK 578ea3eedb
  janb84:
    ACK 578ea3eedb

Tree-SHA512: 5fc63c73ad236b7cd55c15da0f1d1e6b45e4289d252147a86717bf77d79f897f42c3e38aa514df6a4a8deca10c87a8710b61b454c533ad56b0daf738365f426c
2025-06-20 16:30:41 -07:00
Ava Chow daf393b3f1
Merge bitcoin/bitcoin#32642: test: update BIP340 test vectors and implementation (variable-length messages)
b184f5c87c test: update BIP340 test vectors and implementation (variable-length messages) (Sebastian Falbesoner)

Pull request description:

  This PR updates the Schnorr signatures implementation in the functional test framework to the latest BIP changes (see https://github.com/bitcoin/bips/pull/1446,commit 200f9b26fe0a2f235a2af8b30c4be9f12f6bc9cb) and syncs the [test vectors](https://github.com/bitcoin/bips/blob/master/bip-0340/test-vectors.csv) accordingly. Practically, we probably don't need non-32-bytes message signing/verifying any time soon, but it seems good practice anyways to update.

ACKs for top commit:
  stratospher:
    ACK b184f5c.
  achow101:
    ACK b184f5c87c
  real-or-random:
    utACK b184f5c87c
  jonasnick:
    utACK b184f5c87c

Tree-SHA512: b566823aa0f1cd7151215178c57551d772b338d022ccb2807a0df2670df6d59c4b63a6fc936708ccf2922c7e59f474f544adaafc4aea731bfd896250c0d45fa6
2025-06-20 14:45:34 -07:00
Ava Chow 482d255376
Merge bitcoin/bitcoin#32736: wallet: Correct dir iteration error handling
272cd09b79 log: Use warning level while scanning wallet dir (MarcoFalke)
1777644367 qa, wallet: Verify warning when failing to scan (Hodlinator)
893e51ffeb wallet: Correct dir iteration error handling (Hodlinator)

Pull request description:

  Make wallet DB properly detect and report failure to scan wallet directory. Seems to have been broken since moving from Boost to `std::filesystem`.

  Found while reviewing: https://github.com/bitcoin/bitcoin/pull/31410#pullrequestreview-2604068753

ACKs for top commit:
  achow101:
    ACK 272cd09b79
  maflcko:
    re-ACK 272cd09b79 🍽
  rkrux:
    tACK 272cd09b79

Tree-SHA512: 969afde2e37f885ed0c823dc36d2dbeaa0378639849c6a26f8ac67b4f1997eea95bbcae6d58aef5b716807210f37eb166c0cda7ba1d6caffd34249970833af3a
2025-06-20 12:47:28 -07:00
Hennadii Stepanov c40dbbbf77
test: Move `script_assets_tests` into its own suite
This change ensures that the `script_assets_tests` test case is
explicitly reported as "Skipped" when it is not run, making it clearer
when running the test suite with `ctest`.
2025-06-20 10:09:32 +01:00
Sjors Provoost 74b7e9c7db
refactor: modernize deprecated ipc headers
Co-authored-by: fanquake <fanquake@gmail.com>
2025-06-19 16:29:55 +02:00
merge-script 154b98a7aa
Merge bitcoin/bitcoin#32772: fuzz: wallet: remove `FundTx` from `FuzzedWallet`
cd1ae1b4df fuzz: wallet: remove FundTx from FuzzedWallet (brunoerg)

Pull request description:

  `FundTx` was used by the `wallet_notifications` target which we recently removed. So it's now unused and can be removed.

ACKs for top commit:
  maflcko:
    lgtm ACK cd1ae1b4df
  kevkevinpal:
    ACK [cd1ae1b](cd1ae1b4df)
  dergoegge:
    utACK cd1ae1b4df

Tree-SHA512: 909cc4c8a0ac2a5f8844993ccf0e725021932888da3591925799145daf9196eadfcd0ebbc74a44f4a245074ded4cb8c3c099513f109ce2681dceff36b5f74bcc
2025-06-19 15:14:18 +01:00
merge-script fa183045a1
Merge bitcoin/bitcoin#32765: test: Fix list index out of range error in feature_bip68_sequence.py
e285e691b7 test: Fix list index out of range error in feature_bip68_sequence.py (zaidmstrr)

Pull request description:

  Fixes [#32334](https://github.com/bitcoin/bitcoin/issues/32334)

  The test `feature_bip68_sequence.py` fails with `IndexError: list index out of range` error due to a mismatch between the number of inputs requested (at random) and the number of UTXOs available. The error is reproducible with the randomseed:
  ```
  $ ./build/test/functional/feature_bip68_sequence.py --randomseed 6169832640268785903
  ```
  This PR adds a valid upper bound to randomly select the inputs.

ACKs for top commit:
  maflcko:
    lgtm ACK e285e691b7
  Prabhat1308:
    re-ACK [`e285e69`](e285e691b7)
  theStack:
    ACK e285e691b7

Tree-SHA512: 2e5e19d5db2880915f556ed4444abed94e9ceb1ecee5f857df5616040c850dae682aaa4ade3060c48acb16676df92ba81c3af078c1958965e9e874e7bb489388
2025-06-19 15:03:58 +01:00
fanquake 5be31b20e5
lsan: add more Qt suppressions
Using Clang clang version 20.1.6 (Fedora 20.1.6-9.fc43) and:
```bash
export CC=clang
export CXX=clang++
cmake -B build -DBUILD_GUI=ON -DSANITIZERS=address
cmake --build build
export LSAN_OPTIONS="suppressions=/root/bitcoin/test/sanitizer_suppressions/lsan"
ctest --test-dir build
```

```bash
Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted, 1589ms
********* Finished testing of AddressBookTests *********

=================================================================
==21869==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 88 byte(s) in 1 object(s) allocated from:
    #0 0xaaaab5d5af40 in operator new(unsigned long) (/root/bitcoin/build/bin/test_bitcoin-qt+0x39af40) (BuildId: c0e038f1c507ea6860d1cfd499ac54ad83359872)
    #1 0xffff8c8f56cc in QLayoutPrivate::createWidgetItem(QLayout const*, QWidget*) (/lib64/libQt6Widgets.so.6+0x1a56cc) (BuildId: 8b7b9e470f4d4cd920282a4f963abb01225814fa)
    #2 0xffff8c8d2f90 in QBoxLayout::insertWidget(int, QWidget*, int, QFlags<Qt::AlignmentFlag>) (/lib64/libQt6Widgets.so.6+0x182f90) (BuildId: 8b7b9e470f4d4cd920282a4f963abb01225814fa)
    #3 0xaaaab5fc7188 in SendCoinsDialog::addEntry() /root/bitcoin/build/src/qt/./qt/sendcoinsdialog.cpp:596:18
    #4 0xaaaab5fc4eec in SendCoinsDialog::SendCoinsDialog(PlatformStyle const*, QWidget*) /root/bitcoin/build/src/qt/./qt/sendcoinsdialog.cpp:84:5
    #5 0xaaaab5da67ac in (anonymous namespace)::MiniGUI::MiniGUI(interfaces::Node&, PlatformStyle const*) /root/bitcoin/build/src/qt/test/./qt/test/wallettests.cpp:235:75
    #6 0xaaaab5da2000 in (anonymous namespace)::TestGUI(interfaces::Node&, std::shared_ptr<wallet::CWallet> const&) /root/bitcoin/build/src/qt/test/./qt/test/wallettests.cpp:270:13
    #7 0xaaaab5d9ebc8 in (anonymous namespace)::TestGUI(interfaces::Node&) /root/bitcoin/build/src/qt/test/./qt/test/wallettests.cpp:453:5
    #8 0xaaaab5d9ebc8 in WalletTests::walletTests() /root/bitcoin/build/src/qt/test/./qt/test/wallettests.cpp:475:5
    #9 0xffff8b1c5314 in QMetaMethodInvoker::invokeImpl(QMetaMethod, void*, Qt::ConnectionType, long long, void const* const*, char const* const*, QtPrivate::QMetaTypeInterface const* const*) (/lib64/libQt6Core.so.6+0x195314) (BuildId: eacb2d1228362560e5df1a1ce496c99ad61960e7)
    #10 0xffff8b1c5dc8 in QMetaMethod::invokeImpl(QMetaMethod, void*, Qt::ConnectionType, long long, void const* const*, char const* const*, QtPrivate::QMetaTypeInterface const* const*) (/lib64/libQt6Core.so.6+0x195dc8) (BuildId: eacb2d1228362560e5df1a1ce496c99ad61960e7)
    #11 0xffff8cf57c54  (/lib64/libQt6Test.so.6+0x27c54) (BuildId: 96bb1cdeead53af0ced36d7970cf9cd79c4c4ccd)
    #12 0xffff8cf5fa18  (/lib64/libQt6Test.so.6+0x2fa18) (BuildId: 96bb1cdeead53af0ced36d7970cf9cd79c4c4ccd)
    #13 0xffff8cf6067c  (/lib64/libQt6Test.so.6+0x3067c) (BuildId: 96bb1cdeead53af0ced36d7970cf9cd79c4c4ccd)
    #14 0xffff8cf610a4  (/lib64/libQt6Test.so.6+0x310a4) (BuildId: 96bb1cdeead53af0ced36d7970cf9cd79c4c4ccd)
    #15 0xffff8cf61aa4 in QTest::qRun() (/lib64/libQt6Test.so.6+0x31aa4) (BuildId: 96bb1cdeead53af0ced36d7970cf9cd79c4c4ccd)
    #16 0xffff8cf61eb4 in QTest::qExec(QObject*, int, char**) (/lib64/libQt6Test.so.6+0x31eb4) (BuildId: 96bb1cdeead53af0ced36d7970cf9cd79c4c4ccd)
    #17 0xaaaab5d7d77c in main /root/bitcoin/build/src/qt/test/./qt/test/test_main.cpp:95:30
    #18 0xffff8aad6398 in __libc_start_call_main (/lib64/libc.so.6+0x26398) (BuildId: 627f878dd454ee3cc1dfdbd347bb565f1ffb53e7)
    #19 0xffff8aad6478 in __libc_start_main@GLIBC_2.17 (/lib64/libc.so.6+0x26478) (BuildId: 627f878dd454ee3cc1dfdbd347bb565f1ffb53e7)
    #20 0xaaaab5c74cac in _start (/root/bitcoin/build/bin/test_bitcoin-qt+0x2b4cac) (BuildId: c0e038f1c507ea6860d1cfd499ac54ad83359872)
```

This happens when building using depends:
```bash
Indirect leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0xaaaabdbe86f8 in malloc (/root/bitcoin/build/bin/test_bitcoin-qt+0x4386f8) (BuildId: dd54811dc11325890f7bac3e3a49d38f5a7ffef5)
    #1 0xfbff97f8c164  (<unknown module>)
    #2 0xaaaabf0cfaa4 in QDBusConnectionPrivate::QDBusConnectionPrivate() (/root/bitcoin/build/bin/test_bitcoin-qt+0x191faa4) (BuildId: dd54811dc11325890f7bac3e3a49d38f5a7ffef5)
    #3 0xaaaabf0c9e30 in QDBusConnectionManager::doConnectToStandardBus(QDBusConnection::BusType, QString const&, bool) (/root/bitcoin/build/bin/test_bitcoin-qt+0x1919e30) (BuildId: dd54811dc11325890f7bac3e3a49d38f5a7ffef5)
    #4 0xaaaabf0cb0e4 in QtPrivate::QCallableObject<QDBusConnectionPrivate* (QDBusConnectionManager::*)(QDBusConnection::BusType, QString const&, bool), QtPrivate::List<QDBusConnection::BusType&, QString const&, bool&>, QDBusConnectionPrivate*>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) (/root/bitcoin/build/bin/test_bitcoin-qt+0x191b0e4) (BuildId: dd54811dc11325890f7bac3e3a49d38f5a7ffef5)
    #5 0xaaaabf5cbaf0 in QObject::event(QEvent*) (/root/bitcoin/build/bin/test_bitcoin-qt+0x1e1baf0) (BuildId: dd54811dc11325890f7bac3e3a49d38f5a7ffef5)
    #6 0xaaaabf5a4ce0 in QCoreApplicationPrivate::notify_helper(QObject*, QEvent*) (/root/bitcoin/build/bin/test_bitcoin-qt+0x1df4ce0) (BuildId: dd54811dc11325890f7bac3e3a49d38f5a7ffef5)
    #7 0xaaaabf5a486c in QCoreApplication::notifyInternal2(QObject*, QEvent*) (/root/bitcoin/build/bin/test_bitcoin-qt+0x1df486c) (BuildId: dd54811dc11325890f7bac3e3a49d38f5a7ffef5)
    #8 0xaaaabf5a575c in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) (/root/bitcoin/build/bin/test_bitcoin-qt+0x1df575c) (BuildId: dd54811dc11325890f7bac3e3a49d38f5a7ffef5)
    #9 0xaaaabf66b858 in QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (/root/bitcoin/build/bin/test_bitcoin-qt+0x1ebb858) (BuildId: dd54811dc11325890f7bac3e3a49d38f5a7ffef5)
    #10 0xaaaabf5a9e3c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (/root/bitcoin/build/bin/test_bitcoin-qt+0x1df9e3c) (BuildId: dd54811dc11325890f7bac3e3a49d38f5a7ffef5)
    #11 0xaaaabf632a44 in QThread::exec() (/root/bitcoin/build/bin/test_bitcoin-qt+0x1e82a44) (BuildId: dd54811dc11325890f7bac3e3a49d38f5a7ffef5)
    #12 0xaaaabf0c9bd0 in QDBusConnectionManager::run() (/root/bitcoin/build/bin/test_bitcoin-qt+0x1919bd0) (BuildId: dd54811dc11325890f7bac3e3a49d38f5a7ffef5)
    #13 0xaaaabf669c30 in QThreadPrivate::start(void*) (/root/bitcoin/build/bin/test_bitcoin-qt+0x1eb9c30) (BuildId: dd54811dc11325890f7bac3e3a49d38f5a7ffef5)
    #14 0xaaaabdbe5f2c in asan_thread_start(void*) asan_interceptors.cpp.o
    #15 0xffff99538608 in thread_start (/lib64/libc.so.6+0xf8608) (BuildId: 627f878dd454ee3cc1dfdbd347bb565f1ffb53e7)

SUMMARY: AddressSanitizer: 3592 byte(s) leaked in 37 allocation(s).
```
2025-06-19 14:15:33 +01:00
merge-script e18322eff2
Merge bitcoin/bitcoin#32774: doc: Explain how to fetch commits directly
fa94fd53c9 doc: Explain how to fetch commits directly (MarcoFalke)

Pull request description:

  This is often needed, and works better than the existing refspec documentation, because even commits that have been force-pushed away can be fetched (as long as they are not garbage collected on the remote).

ACKs for top commit:
  Sjors:
    ACK fa94fd53c9
  l0rinc:
    ACK fa94fd53c9
  willcl-ark:
    ACK fa94fd53c9
  rkrux:
    ACK fa94fd53c9
  janb84:
    ACK fa94fd53c9

Tree-SHA512: b68c0c612e13f501ad4c1c709502e060b0a2d0eb55ef888c7466e2a10bdf3ca63d81b8bd7927de49cde9e29f0b06f8233d51b99d015ae0b39d556854be542b8a
2025-06-19 12:32:30 +01:00
merge-script b861419254
Merge bitcoin/bitcoin#32777: doc: fix Transifex 404s
53a996f122 doc: fix transifex 404s (fanquake)

Pull request description:

  https://www.transifex.com/bitcoin/bitcoin/ is now a 404.

ACKs for top commit:
  maflcko:
    lgtm ACK 53a996f122
  hebasto:
    ACK 53a996f122, I've verified all the links.

Tree-SHA512: 8e698c83095a3d3a225b0bf2ee9c39ad434b2917ead4271ff39a282cea6283710091d1e8b91edafd280bf356dec2bdbe42981aafe4d64f623a975232c5ca848c
2025-06-19 11:43:55 +01:00
merge-script 79afe6b7c0
Merge bitcoin/bitcoin#32776: doc: taproot became always active in v24.0 (doc/bips.md)
8ee8a951c2 doc: taproot became always active in v24.0 (Sjors Provoost)

Pull request description:

  Split from #26201.

ACKs for top commit:
  maflcko:
    lgtm ACK 8ee8a951c2
  janb84:
    ACK 8ee8a951c2

Tree-SHA512: 1ac6994c6775ca5423f022d1e02e3d531fb7fa295be9940355b8aa9d173787a8d65945a0cf976ab344bcaa3ea8a0f3aa6f8da851325bf475e59375981b115cab
2025-06-19 11:40:47 +01:00
fanquake 53a996f122
doc: fix transifex 404s 2025-06-19 11:22:14 +01:00
Sjors Provoost 8ee8a951c2
doc: taproot became always active in v24.0 2025-06-19 11:15:00 +02:00
MarcoFalke fa21631595
test: Use self.log
This is in line with all other functional tests.
2025-06-19 09:00:26 +02:00
MarcoFalke fa346f7797
test: Move error string into exception
This is normally expected and also less code.
2025-06-19 09:00:22 +02:00
MarcoFalke fa1986181f
test: Remove useless catch-throw
This is not done anywhere else in the tests for open or subprocess.run
2025-06-19 09:00:05 +02:00
MarcoFalke fa94fd53c9
doc: Explain how to fetch commits directly 2025-06-19 08:33:43 +02:00
Ava Chow 9a7eece5a4
Merge bitcoin/bitcoin#31981: Add checkBlock() to Mining interface
a18e572328 test: more template verification tests (Sjors Provoost)
10c908808f test: move gbt proposal mode tests to new file (Sjors Provoost)
94959b8dee Add checkBlock to Mining interface (Sjors Provoost)
6077157531 ipc: drop BlockValidationState special handling (Sjors Provoost)
74690f4ed8 validation: refactor TestBlockValidity (Sjors Provoost)

Pull request description:

  This PR adds the IPC equivalent of the `getblocktemplate` RPC in `proposal` mode.

  In order to do so it has `TestBlockValidity` return error reasons as a string instead of `BlockValidationState`. This avoids complexity in IPC code for handling the latter struct.

  The new Mining interface method is used in `miner_tests`.

  It's not used by the `getblocktemplate` and `generateblock` RPC calls, see https://github.com/bitcoin/bitcoin/pull/31981#discussion_r2096473337

  The `inconclusive-not-best-prevblk` check is moved from RPC
  code to `TestBlockValidity`.

  Test coverage is increased by `mining_template_verification.py`.

  Superseedes #31564

  ## Background

  ### Verifying block templates (no PoW)

  Stratum v2 allows miners to generate their own block template. Pools may wish (or need) to verify these templates. This typically involves comparing mempools, asking miners to providing missing transactions and then reconstructing the proposed block.[^0] This is not sufficient to ensure a proposed block is actually valid. In some schemes miners could take advantage of incomplete validation[^1].

  The Stratum Reference Implementation (SRI), currently the only Stratum v2 implementation, collects all missing mempool transactions, but does not yet fully verify the block.[^2]. It could use the `getblocktemplate` RPC in `proposal` mode, but using IPC is more performant, as it avoids serialising up to 4 MB of transaction data as JSON.

  (although SRI could use this PR, the Template Provider role doesn't need it, so this is _not_ part of #31098)

  [^0]: https://github.com/stratum-mining/sv2-spec/blob/main/06-Job-Declaration-Protocol.md
  [^1]: https://delvingbitcoin.org/t/pplns-with-job-declaration/1099/45?u=sjors
  [^2]: https://github.com/stratum-mining/stratum/blob/v1.1.0/roles/jd-server/src/lib/job_declarator/message_handler.rs#L196

ACKs for top commit:
  davidgumberg:
    reACK a18e572328
  achow101:
    ACK a18e572328
  TheCharlatan:
    ACK a18e572328
  ryanofsky:
    Code review ACK a18e572328 just adding another NONFATAL_UNREACHABLE since last review

Tree-SHA512: 1a6c29f45a1666114f10f55aed155980b90104db27761c78aada4727ce3129e6ae7a522d90a56314bd767bd7944dfa46e85fb9f714370fc83e6a585be7b044f1
2025-06-18 17:07:21 -07:00
w0xlt 8cc9845b8d wallet, rpc: Use `OUTPUT_TYPES` to describe the output types instead of hardcoding them 2025-06-18 18:11:28 -03:00
David Gumberg 3473986fe1 contrib: tracing: Correctly read msg type in p2p_monitor.py 2025-06-18 11:35:06 -07:00
brunoerg cd1ae1b4df fuzz: wallet: remove FundTx from FuzzedWallet 2025-06-18 11:11:25 -03:00
MarcoFalke fa68dcb207
ci: Add missing errexit to lint CI install
Otherwise, a possible failure is silently ignored.

Also, rename the file, while touching it, to clarify installing is the
first step.
2025-06-18 14:11:11 +02:00
MarcoFalke fa535a6de7
ci: Allow running CI in worktrees 2025-06-18 10:23:45 +02:00
MarcoFalke faf6a04597
ci: Clean UID/GID mismatch
rsync --archive will preserve owner and group, which is then required to
be handled by adding a git safe.directory workaround.

Remove the need for the workaround by only preserving permissions during
the recursive rsync copy.
2025-06-18 10:22:53 +02:00
Ava Chow 9eb2c82e7c walletdb: Remove unused upgraded_txs 2025-06-17 17:41:46 -07:00
Ava Chow c668033709 wallet: Remove unused fTimeReceivedIsTxTime
fTimeReceivedIsTxTime has been unused unused since 0.3.24
2025-06-17 17:41:43 -07:00
Ryan Ofsky 5e6dbfd14e
Merge bitcoin/bitcoin#32465: thread-safety: fix annotations with REVERSE_LOCK
a201a99f8c thread-safety: fix annotations with REVERSE_LOCK (Cory Fields)
aeea5f0ec1 thread-safety: add missing lock annotation (Cory Fields)
832c57a534 thread-safety: modernize thread safety macros (Cory Fields)

Pull request description:

  This is one of several PRs to cleanup/modernize our threading primitives.

  While replacing the old critical section locks in the mining code with a `REVERSE_LOCK`, I noticed that our thread-safety annotations weren't hooked up to it. This PR gets `REVERSE_LOCK` working properly.

  Firstly it modernizes the attributes as-recommended by the [clang docs](https://clang.llvm.org/docs/ThreadSafetyAnalysis.html) (ctrl+f for `USE_LOCK_STYLE_THREAD_SAFETY_ATTRIBUTES`). There's a subtle difference between the old `unlock_function` and new `release_capability`, where our `reverse_lock` only works with the latter. I believe this is an upstream bug. I've [reported and attempted a fix here](https://github.com/llvm/llvm-project/pull/139343), but either way it makes sense to me to modernize.

  The second adds a missing annotation pointed out by a fixed `REVERSE_LOCK`. Because clang's thread-safety annotations aren't passed through a reference to `UniqueLock` as one may assume (see [here](https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#no-alias-analysis) for more details), `cs_main` has to be listed explicitly as a requirement.

  The last commit actually fixes the `reverse_lock` by making it a `SCOPED_LOCK` and using the pattern [found in a clang test](https://github.com/llvm/llvm-project/blob/main/clang/test/SemaCXX/warn-thread-safety-analysis.cpp#L3126). Though the docs don't describe how to accomplish it, the functionality was added [in this commit](6a68efc959). Due to aliasing issues (see link above), in order to work correctly, the original mutex has to be passed along with the lock, so all existing `REVERSE_LOCK`s have been updated. To ensure that the mutexes actually match, a runtime assertion is added.

ACKs for top commit:
  fjahr:
    re-ACK a201a99f8c
  davidgumberg:
    reACK a201a99f8c
  theuni:
    Ok, done. Those last pushes can be ignored. ACKs on a201a99 are still fresh.
  ryanofsky:
    Code review ACK a201a99f8c. Just dropping 0065b9673db5da2994b0b07c1d50ebfb19af39d0 and fixing incorrect `reverse_lock::lockname` initialization since last review.
  TheCharlatan:
    Re-ACK a201a99f8c

Tree-SHA512: 2755fae0c41021976a1a633014a86d927f104ccbc8014c01c06dae89af363f92e5bc5d4276ad6d759302ac4679fe02a543758124d48318074db1c370989af7a7
2025-06-17 14:12:43 -04:00
zaidmstrr e285e691b7
test: Fix list index out of range error in feature_bip68_sequence.py 2025-06-17 20:38:21 +05:30
Ava Chow 1be688f575
Merge bitcoin/bitcoin#32682: wallet: have external signer use PSBT error code EXTERNAL_SIGNER_NOT_FOUND
9dfc61d95f test: detect no external signer connected (Sjors Provoost)
0a4ee93529 wallet: use PSBTError::EXTERNAL_SIGNER_NOT_FOUND (Sjors Provoost)
8ba2f9b7c8 refactor: use util::Result for GetExternalSigner() (Sjors Provoost)

Pull request description:

  When attempting to sign a transaction involving an external signer, if the device isn't connected we throw an `std::runtime_error`. This prevents the (mainly GUI) code that's actually supposed to handle this case from running.

  This PR returns a `PSBTError::EXTERNAL_SIGNER_NOT_FOUND` instead of throwing.

  The first commit is a refactor to have `GetExternalSigner()` return a `util::Result<ExternalSigner>` so the caller can decide how to handle the error. There are two other places where call `GetExternalSigner()` which this PR doesn't change (which I think is fine there).

  Before:
  ![before](https://github.com/user-attachments/assets/2e08863b-fe76-479f-9cc0-60571b357a27)

  After (the translation already exist):
  ![after](https://github.com/user-attachments/assets/0e91c7ed-7d44-4030-beec-20d1694c270c)

  Fixes #32426

  Additionally use `LogWarning` instead of `std::cerr` for both a missing signer and failure to sign.

ACKs for top commit:
  achow101:
    ACK 9dfc61d95f
  brunoerg:
    code review ACK 9dfc61d95f

Tree-SHA512: 22515f4f0b4f50cb0ef532b729e247f11a68be9c90e384942d4277087b2e76806a1cdaa57fb51d5883dacf0a428e5279674aab37cce8c0d3d7de0f96346b8233
2025-06-16 17:32:57 -07:00
Cory Fields a201a99f8c thread-safety: fix annotations with REVERSE_LOCK
Without proper annotations, clang thinks that mutexes are still held for the
duration of a reverse_lock. This could lead to subtle bugs as
EXCLUSIVE_LOCKS_REQUIRED(foo) passes when it shouldn't.

As mentioned in the docs [0], clang's thread-safety analyzer is unable to deal
with aliases of mutexes, so it is not possible to use the lock's copy of the
mutex for that purpose. Instead, the original mutex needs to be passed back to
the reverse_lock for the sake of thread-safety analysis, but it is not actually
used otherwise.

[0]: https://clang.llvm.org/docs/ThreadSafetyAnalysis.html
2025-06-16 18:09:14 +00:00
Ryan Ofsky 26747d9f3e
Merge bitcoin/bitcoin#32760: depends: capnp 1.2.0
c7eaac326a depends: capnp 1.2.0 (fanquake)

Pull request description:

  See https://github.com/capnproto/capnproto/compare/release-1.1.0...release-1.2.0. We can drop all the patches we are currently applying.

ACKs for top commit:
  Sjors:
    ACK c7eaac326a
  theStack:
    ACK c7eaac326a
  ryanofsky:
    Code review ACK c7eaac326a. Just checked hashes, compared tarball to git and diffed 1.1.0 and 1.2.0 tarballs which showed only minor and expected changes.

Tree-SHA512: 75085ec96952e9693c67531c3d04cd0d7df580dd1df35ce50dff618b29f651674c17a84e9089c6b7ed230e2b4fd0a7f24e2220e983ec00235db9a9d1ee2d7116
2025-06-16 12:58:25 -04:00
Vasil Dimov c10e382d2a
flatfile: check whether the file has been closed successfully 2025-06-16 15:33:19 +02:00
Vasil Dimov 4bb5dd78ea
util: check that a file has been closed before ~AutoFile() is called
If an `AutoFile` has been written to, then expect callers to have closed
it explicitly via the `AutoFile::fclose()` method. This is because if
the destructor calls `std::fclose()` and encounters an error, then it
is too late to indicate this to the caller in a meaningful way.
2025-06-16 15:33:19 +02:00
Vasil Dimov 8bb34f07df
Explicitly close all AutoFiles that have been written
There is no way to report a close error from `AutoFile` destructor.
Such an error could be serious if the file has been written to because
it may mean the file is now corrupted (same as if write fails).

So, change all users of `AutoFile` that use it to write data to
explicitly close the file and handle a possible error.
2025-06-16 15:33:15 +02:00
Hodlinator a69c4098b2
rpc: take ownership of the file by WriteUTXOSnapshot()
Have `WriteUTXOSnapshot()` take rvalue reference to make it obvious that
it takes ownership of the file.
2025-06-16 15:20:47 +02:00
fanquake c7eaac326a
depends: capnp 1.2.0 2025-06-16 10:55:14 +01:00
stratospher afaaba69ed test: refactor out same-txid-diff-wtxid tx to reuse in other tests
useful to easily create transactions with same txid, different
wtxid and valid witness for testing scenarios in other places
(ex: private broadcast connections)
2025-06-16 14:48:17 +05:30
merge-script 084eee0291
Merge bitcoin/bitcoin#32743: refactor: use `std::vector<std::byte>` for `BlockManager::ReadRawBlock()`
6ecb9fc65f chore: use `std::vector<std::byte>` for `BlockManager::ReadRawBlock()` (Roman Zeyde)

Pull request description:

  Following [this comment](https://github.com/bitcoin/bitcoin/pull/32540#discussion_r2135820932), this PR changes `BlockManager::ReadRawBlock()` to accept a `std::vector<std::byte>` instead of `std::vector<uint8_t>`, in order to avoid casts during its invocations.

  It also adds a new `SpanReader` constructor to allow reading from a span of `std::byte`s (in addition to span of `uint8_t`).

ACKs for top commit:
  l0rinc:
    ACK 6ecb9fc65f
  maflcko:
    re-ACK 6ecb9fc65f
  TheCharlatan:
    Re-ACK 6ecb9fc65f

Tree-SHA512: b0976c34b8da4fa1e6d805a89de2883f48ba431a71069e8c1ae450f48e425cc41aff1a5d479a7d40312a972aaf1f92e9478a985a14a1357c6b3e564e988d03e5
2025-06-16 09:52:53 +01:00
Roman Zeyde c48846ec41
doc: add release notes for #32540 2025-06-15 21:20:17 +03:00
Pieter Wuille d7fca5c171 clusterlin: add big comment explaning the relation between tests 2025-06-14 18:35:33 -04:00
Pieter Wuille b64e61d2de clusterlin: abstract try-permutations into ExhaustiveLinearize function
Rather than this exhaustive linearization check happening inline inside
clusterlin_simple_linearize, abstract it out into a Linearize()-like
function for clarity.

Note that this isn't exactly a refactor, because the old code would compare the
found linearization against all (valid) permutations, while the new code instead
first computes the best linearization from all valid permutations, and then
compares it with the found one.
2025-06-14 18:28:13 -04:00
Pieter Wuille 1fa55a64ed clusterlin tests: verify that chunks are minimal 2025-06-14 18:27:24 -04:00
Pieter Wuille da23ecef29 clusterlin tests: support non-empty ReadTopologicalSubset()
In several call sites for ReadTopologicalSubset, a non-empty result is
expected, necessitating a special case at the call site for empty results.

Fix this by adding a bool non_empty argument, which does this special
casing (more efficiently) inside ReadTopologicalSubset itself.
2025-06-14 18:27:24 -04:00
Pieter Wuille 94f3e17c33 clusterlin tests: compare with fuzz-provided linearizations 2025-06-14 18:27:24 -04:00
Pieter Wuille 5f92ebee0d clusterlin tests: compare with fuzz-provided topological sets 2025-06-14 18:27:24 -04:00
Pieter Wuille 6e37824ac3 clusterlin tests: optimize clusterlin_simple_linearize
Whenever a non-topological permutation is encountered, fast forward to the
last permutation with the same non-topological prefix, skipping over
potentially many permutations that are non-topological for the same reason.

With that, increase the checking of all permutations to clusters of size 8
instead of 7.
2025-06-14 18:27:24 -04:00
Pieter Wuille 98c1c88b6f clusterlin tests: separate testing of SimpleLinearize and Linearize
The separates the existing fuzz test into:

* clusterlin_linearize: establishes the correctness of Linearize() using the
                        simpler SimpleLinearize() function.
* clusterlin_simple_linearize: establishes the correctness of SimpleLinearize() by
                        comparing with all valid linearizations computed by
                        std::next_permutation.

rather than combining the first two into a single fuzz test.
2025-06-14 18:27:24 -04:00
Pieter Wuille 10e90f7aef clusterlin tests: make SimpleCandidateFinder always find connected
Make a small change to guarantee that SimpleCandidateFinder only ever returns
connected solutions, even when non-optimal. Then test this property.
2025-06-14 18:27:24 -04:00
Pieter Wuille a38c38951e clusterlin tests: separate testing of Search- and SimpleCandidateFinder
This separates the existing fuzz test into:

* clusterlin_search_finder: establishes SearchCandidateFinder's correctness using the
                            simpler SimpleCandidateFinder.
* clusterlin_simple_finder: establishes SimpleCandidateFinder's correctness using the
                            (even) simpler ExhaustiveCandidateFinder.

rather than trying to do both at once.
2025-06-14 18:27:24 -04:00
Pieter Wuille 77a432ee70 clusterlin tests: count SimpleCandidateFinder iterations better
Only count the number of actual new subsets added. If the queue contains
a work item that completely covers a component, no transaction can be added
to it without creating a disconnected component. In this case, also don't
count it as an iteration.

With this, the number of iterations performed by SimpleCandidateFinder is
bounded by the number of distinct connected topologically-valid subsets of
the cluster.
2025-06-14 18:27:24 -04:00
Sjors Provoost a18e572328
test: more template verification tests 2025-06-14 14:36:02 +02:00
Sjors Provoost 10c908808f
test: move gbt proposal mode tests to new file
Additionally this commit gives each test its
own function.

The assert_submitblock helper is absorbed into
assert_template.

Review hint:
git show --color-moved=dimmed-zebra
2025-06-14 14:32:45 +02:00
Sjors Provoost 94959b8dee
Add checkBlock to Mining interface
Use it in miner_tests.

The getblocktemplate and generateblock RPC calls don't use this,
because it would make the code more verbose.
2025-06-14 14:32:45 +02:00
Sjors Provoost 6077157531
ipc: drop BlockValidationState special handling
The Mining interface avoids using BlockValidationState.
2025-06-14 14:32:45 +02:00
Sjors Provoost 74690f4ed8
validation: refactor TestBlockValidity
Comments are expanded.

Return BlockValidationState instead of passing a reference.
Lock Chainman mutex instead of cs_main.
Remove redundant chainparams and pindexPrev arguments.
Drop defaults for checking proof-of-work and merkle root.

The ContextualCheckBlockHeader check is moved to after CheckBlock,
which is more similar to normal validation where context-free checks
are done first.

Validation failure reasons are no longer printed through LogError(),
since it depends on the caller whether this implies an actual bug
in the node, or an externally sourced block that happens to be invalid.
When called from getblocktemplate, via BlockAssembler::CreateNewBlock(),
this method already throws an std::runtime_error if validation fails.

Additionally it moves the inconclusive-not-best-prevblk check from RPC
code to TestBlockValidity.

There is no behavior change when callling getblocktemplate with proposal.
Previously this would return a BIP22ValidationResult which can throw for
state.IsError(). But CheckBlock() and the functions it calls only use
state.IsValid().

The final assert is changed into Assume, with a LogError.

Co-authored-by: <Ryan Ofsky <ryan@ofsky.org>
2025-06-14 14:32:45 +02:00
Ava Chow 2def858473
Merge bitcoin/bitcoin#32481: wallet, refactor: Remove Legacy wallet unused warnings and errors
ce90f0c99f rpc, wallet, refactor: Remove non-descriptor errors (pablomartin4btc)
573bcd75d7 wallet, refactor: Remove unused SetupGeneration (pablomartin4btc)
5431f2dc21 wallet, refactor: Remove Legacy warnings and errors (pablomartin4btc)

Pull request description:

  Remove dead code due to legacy wallet support removal.

  These changes have no impact on functionality. They are transparent to the end user, as legacy wallets can't be created or loaded anymore, so these checks are no longer reached. The legacy-to-descriptor wallet migration flow is not affected either, as these removals are not part of its process.

ACKs for top commit:
  achow101:
    ACK ce90f0c99f
  rkrux:
    utACK ce90f0c99f

Tree-SHA512: 9229ad9dda9ff1dece73b5b15a20d69c6ab1ff2c75b2ec430ddbbaeb3467f6a850f53df527bcb4a8114ccbf1aa9c794462d71a8d516aed6f9a9da74edae16feb
2025-06-13 17:27:39 -07:00
merge-script 287cd04a32
Merge bitcoin/bitcoin#32594: wallet, rpc: Return normalized descriptor in parent_descs
0def84d407 test: Verify parent_desc in RPCs (Ava Chow)
2554cee988 test: Enable default wallet for wallet_descriptor.py (Ava Chow)
3fc9d9f241 wallet, rpc: Push the normalized parent descriptor (Ava Chow)

Pull request description:

  Instead of prividing the descriptor string as stored in the db, use the normalized descriptor as is done for getaddressinfo's parent_desc field.

  Split from #32489

ACKs for top commit:
  Sjors:
    re-utACK 0def84d407
  rkrux:
    ACK 0def84d407
  w0xlt:
    reACK 0def84d407

Tree-SHA512: 575c5b545d6f0aa7e135696b7a55c004e754fca4dd35dd9cf71b0b45b49a2e86e7b20570e768534d587005953bb893645379ec1ba4f98cfd26811f9c2f17de2d
2025-06-13 18:25:13 -04:00
merge-script fd74d609be
Merge bitcoin/bitcoin#32620: wallet: Fix wallet interface detection of encrypted wallets
130a922980 wallet, interfaces: Use BERKELEY_RO in isEncrypted (Ava Chow)

Pull request description:

  The GUI uses `WalletLoader::isEncrypted()` to detect whether a wallet file is encrypted so that it knows whether to prompt for a passphrase when migrating a legacy wallet. However, legacy wallets need to be opened with `options.require_format = BERKELEY_RO`. Since this wasn't being provided, following #28710, encrypted legacy wallets could not be migrated.

  This fixes the issue by detecting when a wallet file is for a legacy wallet, and re-attempting with `options.require_format = BERKELEY_RO` in that case.

  Depends on #32449 for `DatabaseStatus::FAILED_LEGACY_DISABLED`

ACKs for top commit:
  davidgumberg:
    Tested ACK 130a922980
  furszy:
    utACK 130a922980
  pablomartin4btc:
    tACK 130a922980
  w0xlt:
    Code review ACK 130a922980
  rkrux:
    utACK 130a922980

Tree-SHA512: aa70defc3b5f41635333a4d83c46ecdb5cd3cb129d590b4c0fe7a5f16e8aeaba1592f932ead242ed5f84524b146d87319154f4a1820bb34d9e80f63d24fc6b20
2025-06-13 18:17:24 -04:00
Roman Zeyde 6ecb9fc65f
chore: use `std::vector<std::byte>` for `BlockManager::ReadRawBlock()` 2025-06-13 19:19:44 +03:00
merge-script 65b26507b8
Merge bitcoin/bitcoin#32746: test: remove unnecessary m_best_header setting hack in feature_assumeutxo.py
206bc05e62 test: remove unnecessary m_best_header setting hack in feature_assumeutxo.py (Sebastian Falbesoner)

Pull request description:

  The mentioned bug (issue #26245) has been fixed in PR #30666, so the workaround is not needed anymore.

ACKs for top commit:
  fjahr:
    ACK 206bc05e62
  janb84:
    ACK 206bc05e62
  mzumsande:
    utACK 206bc05e62

Tree-SHA512: 92ad6c09c80318a02e00d8c2a4ca1ec8a6caa6aa310916ff705871c91fe5c960c15ed394ead8ce9c7466b592dba176aa87a635b3228ddc93f57082124f04613f
2025-06-13 15:56:00 +01:00
merge-script 3e81684426
Merge bitcoin/bitcoin#32739: tsan: remove note about dropping Qt wildcards
5db0a4a2db tsan: remove note about dropping Qt wildcards (fanquake)

Pull request description:

  Doing so looks unmaintainable.

ACKs for top commit:
  maflcko:
    lgtm ACK 5db0a4a2db

Tree-SHA512: 619ce944e5fc49d7e4d0de91f02599e0f8fff9b2ecaa354276bf4bd335238df99c7666f865400d00b6d44674bcda19313b9a51a722cb304657f0da4290666e64
2025-06-13 14:01:40 +01:00
merge-script b8eb17792e
Merge bitcoin/bitcoin#32175: fuzz: doc: add info about `afl-system-config` for macOS
61ea5f348d fuzz: doc: add info about `afl-system-config` for macOS (brunoerg)

Pull request description:

  `afl-system-config` adjusts the shared memory segment size limits and configures kernel parameters for better fuzzing performance. Since macOS has more conservative values on shared memory, it's necessary to run `afl-system-config`, or manually adjust the values to fuzz with AFL++.

  e.g.:
  ```sh
  kern.sysv.shmmax: 524288000
  kern.sysv.shmmin: 1
  kern.sysv.shmseg: 48
  kern.sysv.shmall: 131072000
  ```

ACKs for top commit:
  janb84:
    reACK [61ea5f3](61ea5f348d)
  w0xlt:
    ACK 61ea5f348d
  Crypt-iQ:
    ACK 61ea5f3

Tree-SHA512: 8fd9fcb397a6b22e344ac37d3d18052ce8b6b32a5118ab3554c49116d7dd8769cdcbad41f0784d9ab525d4284a82e3d7a89b2c66966b725bf3781d9389d7454d
2025-06-13 14:00:00 +01:00
Sebastian Falbesoner 206bc05e62 test: remove unnecessary m_best_header setting hack in feature_assumeutxo.py
The mentioned bug has been fixed in PR #30666,
so the workaround is not needed anymore.
2025-06-13 14:42:13 +02:00
MarcoFalke 272cd09b79
log: Use warning level while scanning wallet dir 2025-06-13 13:55:54 +02:00
Hodlinator 1777644367
qa, wallet: Verify warning when failing to scan 2025-06-13 13:55:54 +02:00
Hodlinator 893e51ffeb
wallet: Correct dir iteration error handling
Seems to have been broken since conversion from Boost in #20744. The std::filesystem iteration aborts upon failure while Boost might have allowed skipping over faulty entries.
2025-06-13 13:41:59 +02:00
merge-script 52e6e93c3f
Merge bitcoin/bitcoin#32693: depends: fix cmake compatibility error for freetype
d7c37906e7 build: patch cmake min version on freetype (josibake)

Pull request description:

  ## Problem

  While doing a depends build with CMake 4.0.1, I got the following error:

  ```
  Extracting freetype...
  /root/bitcoin/depends/sources/freetype-2.11.0.tar.xz: OK
  Preprocessing freetype...
  Configuring freetype...
  CMake Error at CMakeLists.txt:100 (cmake_minimum_required):
    Compatibility with CMake < 3.5 has been removed from CMake.

    Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
    to tell CMake that the project requires at least <min> but has been updated
    to work with policies introduced by <max> or earlier.

    Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.

  -- Configuring incomplete, errors occurred!
  make: *** [funcs.mk:343: /root/bitcoin/depends/x86_64-pc-linux-gnu/.freetype_stamp_configured] Error 1
  make: Leaving directory '/root/bitcoin/depends'
  ```

  .. which led me to https://cmake.org/cmake/help/latest/release/4.0.html#deprecated-and-removed-features, which states compatibility with CMake versions less than 3.5 has been removed in 4.0.

  ## Fix
  Based on the suggestion from the error message (and from reading the CMake docs), I added `-DCMAKE_POLICY_VERSION_MINIMUM=3.22`. I picked `3.22` (as opposed to 3.5) since that is the minimum version of CMake we specify in `doc/dependencies.md`. Would be nice if there was a way to pipe the min version in as a variable (since presumably we'd want to update this to be in lock step with the minimum CMake version of the whole project), but I couldn't think of a simple way to do this. Open to suggestions on a more robust way to do this if this is deemed too brittle.

ACKs for top commit:
  fanquake:
    ACK d7c37906e7
  hebasto:
    ACK d7c37906e7. Tested on Ubuntu 25.04 with both cmake 4.0.2 and the default cmake 3.31.6.

Tree-SHA512: fb664ec73bfffc504f1dcc9076072307f443d056d14325de41c4a29f3ee4077f1922e79b5895b49e7354f45ad6a35be4973c153c2baf3376df6c0d209efc9c54
2025-06-13 12:27:46 +01:00
MarcoFalke fa2f1c55b7
move-only util data to test/functional/data/util 2025-06-13 13:07:12 +02:00
MarcoFalke faa18bf287
test: Turn util/test_runner into functional test
The moved portion can be reviewed via:

--color-moved=dimmed-zebra  --color-moved-ws=ignore-all-space
2025-06-13 13:06:59 +02:00
MarcoFalke fa955154c7
test: Add missing skip_if_no_bitcoin_tx 2025-06-13 13:03:48 +02:00
Lőrinc 9341b5333a blockstorage: make block read hash checks explicit
Dropped the default expected_hash parameter from `ReadBlock()`.

In `blockmanager_flush_block_file` tests, we pass {} since the tests would already fail at PoW validation for corrupted blocks.

In `ChainstateManager::LoadExternalBlockFile`, we pass {} when processing child blocks because their hashes aren't known beforehand.
2025-06-13 12:32:56 +02:00
Lőrinc 2371b9f4ee test/bench: verify hash in `ComputeFilter` reads
Switch to the index-aware `ReadBlock()` overload in `ComputeFilter` so that filter creation will abort if the stored block header hash doesn't match the expected one.

In the `readwriteblock` benchmark, pass the expected hash to `ReadBlock()` to match the new signature without affecting benchmark performance.
2025-06-13 12:32:22 +02:00
Lőrinc 5d235d50d6 net: assert block hash in `ProcessGetBlockData` and `ProcessMessage`
The non-recent-block code path in `ProcessGetBlockData` already has `inv.hash` available (equaling `pindex->GetBlockHash()`).
Pass it to `ReadBlock()` and assert that the on-disk header matches the requested hash.

The `GETBLOCKTXN` message handler in `ProcessMessage` receives `req.blockhash` from the peer (equaling `pindex->GetBlockHash()`).
Pass this hash to `ReadBlock()` for verification and assert that the index lookup matches.

Co-authored-by: TheCharlatan <seb.kung@gmail.com>
Co-authored-by: Hodlinator <172445034+hodlinator@users.noreply.github.com>
2025-06-13 12:32:07 +02:00
fanquake 5db0a4a2db
tsan: remove note about dropping Qt wildcards
Doing so looks unmaintainable.
2025-06-13 09:45:47 +01:00
merge-script d91c718a68
Merge bitcoin/bitcoin#32717: doc: Update Qt 6 packages on FreeBSD
1df96f5931 doc: Update Qt 6 packages on FreeBSD (Hennadii Stepanov)

Pull request description:

  See:
  - https://cgit.freebsd.org/ports/tree/devel/qt6-base
  - https://cgit.freebsd.org/ports/tree/devel/qt6-translations

ACKs for top commit:
  vasild:
    ACK 1df96f5931

Tree-SHA512: 3ba44c9cd948f193648e49461b787ae1e443c55900e274e026d2a1c7490935348d733d76a01701157423d7acea17439f8900907e65017a802c040af1f1e219d2
2025-06-13 09:37:40 +01:00
MarcoFalke fac9db6eb0
test: Add missing tx util to Binaries 2025-06-13 09:48:38 +02:00
MarcoFalke fa91835ec6
test: Use lowercase env var as attribute name
This is a refactor.
2025-06-13 09:48:32 +02:00
MarcoFalke fac49094cd
test: Remove duplicate ConfigParser
It is sufficient to parse once.
2025-06-13 09:48:28 +02:00
Sjors Provoost 9dfc61d95f
test: detect no external signer connected 2025-06-13 09:40:23 +02:00
Sebastian Falbesoner dd8447f70f test: fix catchup loop in outbound eviction functional test
The catchup loop in the outbound eviction functional test currently has
a small flaw, as the contained waiting for a `getheaders` message just
waits for any such message instead of one with the intended block hash.
The reason is that the `prev_prev_hash` variable is set incorrectly,
since the `tip_header` instance is not updated and its field `.hash` is
None. Fix that by updating `tip_header` and use the correct field -- we
want the tip header's previous hash (`.hashPrevBlock`).
2025-06-13 01:44:07 +02:00
Ava Chow 19765dca19
Merge bitcoin/bitcoin#32694: index: move disk read lookups to base class
029ba1a21d index: remove CBlockIndex access from CustomAppend() (furszy)
91b7ab6c69 refactor: index, simplify CopyHeightIndexToHashIndex to process single block (furszy)
6f1392cc42 indexes, refactor: Remove remaining CBlockIndex* uses in index Rewind methods (Ryan Ofsky)
0a248708dc indexes, refactor: Stop requiring CBlockIndex type to call IsBIP30Unspendable (Ryan Ofsky)
331a25cb16 test: indexes, avoid creating threads when sync runs synchronously (furszy)

Pull request description:

  Combining common refactors from #24230 and #26966, aiming to move both efforts forward while reducing their size and review burden.

  Broadly, #24230 focuses on enabling indexes to run in a separate process, and #26966 aims to parallelize the indexes initial synchronization process. A shared prerequisite for both is ensuring that only the base index class interacts with the node’s chain internals - child index classes should instead operate solely through chain events.

  This PR moves disk read lookups from child index classes to the base index class. It also includes a few documentation improvements and a test-only code cleanup.

ACKs for top commit:
  maflcko:
    review ACK 029ba1a21d 👡
  achow101:
    ACK 029ba1a21d
  TheCharlatan:
    Re-ACK 029ba1a21d
  davidgumberg:
    ACK 029ba1a21d
  mzumsande:
    Code Review ACK 029ba1a21d

Tree-SHA512: f073af407fc86f228cb47a32c7bcf2241551cc89ff32059317eb81d5b86fd5fda35f228d2567e0aedbc9fd6826291f5fee05619db35ba44108421ae04d11e6fb
2025-06-12 16:01:04 -07:00
Martin Zumsande 8cc3ac6c23 validation: Don't use IsValid() to filter for invalid blocks
IsValid() also returns false for blocks that have not been
validated yet up to the default validity level of BLOCK_VALID_TRANSACTIONS but
are not marked as invalid - e.g. if we only know the header.
Here, we specifically want to filter for invalid blocks.

Also removes the default arg from IsValid() which is now unused outside
of tests, to prevent this kind of misuse for the future.

Co-authored-by: TheCharlatan <seb.kung@gmail.com>
2025-06-12 14:40:59 -04:00
stratospher 86d98b94e5 test: verify that ancestors of a reconsidered block can become the chain tip
when we reconsiderblock, previously only block and it's
descendants were considered as chain tip candidates/inserted into
setBlockIndexCandidates

ex: on this chain, with block 4 invalidated
1 -> 2 -> 3 -> 4 -> 5 -> 6 -> header 7
blocks 4, 5, 6, header 7 have BLOCK_FAILED_* flags set

previously:
- if we reconsiderblock header 7, the chain would have all the
BLOCK_FAILED_* flags cleared but would report chain tip as block 3.
- after restart, it reports correct chain tip block 6.

now:
- if we reconsiderblock header 7, the correct chain tip block 6 is
reported since ancestors are also considered as chain tip
candidates/inserted into setBlockIndexCandidates.

Co-authored-by: Martin Zumsande <mzumsande@gmail.com>
2025-06-12 14:40:59 -04:00
Martin Zumsande 3c39a55e64 validation: Add ancestors of reconsiderblock to setBlockIndexCandidates
When we call reconsiderblock for some block, ResetBlockFailureFlags puts the descendants of that block
into setBlockIndexCandidates (if they meet the criteria, i.e. have more work than the tip etc.)
We also clear the failure flags of the ancestors, but we never put any of those into setBlockIndexCandidates
this is wrong and could lead to failures in CheckBlockIndex().
2025-06-12 14:40:57 -04:00
Hennadii Stepanov 1df96f5931
doc: Update Qt 6 packages on FreeBSD 2025-06-12 18:20:19 +01:00
josibake d7c37906e7
build: patch cmake min version on freetype
Patch cmake_minimum_required version for freetype, using the version from
https://gitlab.freedesktop.org/freetype/freetype/-/merge_requests/352/diffs

This fixes a failure when building with CMake 4, where compatibility
with CMake versions < 3.5 has been removed (see https://cmake.org/cmake/help/latest/release/4.0.html#deprecated-and-removed-features)
2025-06-12 12:31:26 +02:00
MarcoFalke fa946520d2
refactor: Use structured binding for-loop 2025-06-12 11:37:02 +02:00
MarcoFalke eeeec1579e
rpc: Use type-safe exception to pass RPC help 2025-06-12 11:36:43 +02:00
Ava Chow 5757de4ddd
Merge bitcoin/bitcoin#32673: clang-tidy: Apply modernize-deprecated-headers
fa9ca13f35 refactor: Sort includes of touched source files (MarcoFalke)
facb152697 scripted-diff: Bump copyright headers after include changes (MarcoFalke)
fae71d30f7 clang-tidy: Apply modernize-deprecated-headers (MarcoFalke)

Pull request description:

  Bitcoin Core is written in C++, so it is confusing to sometimes use the deprecated C headers (with the `.h` extension). For example, it is less clear whether `string.h` refers to the file in this repo or the cstring stdlib header (https://github.com/bitcoin/bitcoin/pull/31308#discussion_r2121492797).

  The check is currently disabled for headers, to exclude subtree headers.

ACKs for top commit:
  l0rinc:
    ACK fa9ca13f35
  achow101:
    ACK fa9ca13f35
  janb84:
    ACK fa9ca13f35
  stickies-v:
    ACK fa9ca13f35

Tree-SHA512: 6639608308c598d612e24435aa519afe92d71b955874b87e527245291fb874b67f3ab95d3a0a5125c6adce5eb41c0d62f6ca488fbbfd60a94f2063d734173f4d
2025-06-11 15:08:23 -07:00
Ava Chow 1473f69924
Merge bitcoin/bitcoin#32421: test: refactor: overhaul (w)txid determination for `CTransaction` objects
4ef6253017 test: avoid unneeded (w)txid hex -> integer conversions (Sebastian Falbesoner)
472f3770ae scripted-diff: test: rename CTransaction `.getwtxid()` -> `wtxid_hex` for consistency (Sebastian Falbesoner)
81af4334e8 test: rename CTransaction `.sha256` -> `.txid_int` for consistency (Sebastian Falbesoner)
ce83924237 test: rename CTransaction `.rehash()`/`.hash` -> `.txid_hex` for consistency (Sebastian Falbesoner)
e9cdaefb0a test: introduce and use CTransaction `.wtxid_int` property (Sebastian Falbesoner)
9b3dce24a3 test: remove bare CTransaction `.rehash()`/`.calc_sha256()` calls (Sebastian Falbesoner)
a2724e3ea3 test: remove txid caching in CTransaction class (Sebastian Falbesoner)

Pull request description:

  In the functional test framework, determining a (w)txid for a `CTransaction` instance is currently rather confusing and footgunny due to inconsistent naming/interfaces (see table below) and statefulness involved. This PR aims to improve that by:
  * removing the (w)txid caching mechanism, in order to avoid the need to call additional rehashing functions (`.rehash()`/`.calculate_sha256()`, see first two commits and https://github.com/bitcoin/bitcoin/pull/32050#discussion_r1993286997). This change in theory decreases the performance, as the involved serialization and hashing involved might be called more often than previously, but I couldn't find a functional test where this leads to a measurable run-time increase on my machine.
  * introduce consistent naming that shows the type of the returned txid, i.e. hex string vs. test-framework-internal representation [currently integers] (see remaining commits)

  Summary table showing (w)txid determaination before/after this PR:

  | Task                   | master                 | PR           |
  |:-----------------------|:-----------------------|:-------------|
  | get TXID (hex string)  | `.rehash()` / `.hash`[1] | `.txid_hex`  |
  | get TXID (integer)     | `.sha256`[1]             | `.txid_int`  |
  | get WTXID (hex string) | `.getwtxid()`          | `.wtxid_hex` |
  | get WTXID (integer)    | `.calc_sha256(True)`   | `.wtxid_int` |

  Unfortunately, most renames can't be done with a scripted-diff, as the property names (`.hash`, `.sha256`) are also used for blocks and other message types. The PR is rather invasive and touches a lot of files, but I think it's worth to do it, also to make life easier for new contributors. Future tasks like e.g. doing the same overhaul for block (header) objects or getting rid of the integer representation (see https://github.com/bitcoin/bitcoin/pull/32050) become easier should become easier after this one.

  [1] = returned value might be out-of-date, if rehashing function wasn't called after modification

ACKs for top commit:
  maflcko:
    re-ACK 4ef6253017 🏈
  achow101:
    ACK 4ef6253017
  marcofleon:
    code review ACK 4ef6253017

Tree-SHA512: 4b472c31d169966b6f6878911a8404d25bf3e503b6e8ef30f36a7415d21ad4bc1265083af2d3ead6edfcd9fac9ccb0a8be57e1b0739ad431b836413070d7d583
2025-06-11 14:21:11 -07:00
Ryan Ofsky 7c0cfce20d
Merge bitcoin/bitcoin#31405: validation: stricter internal handling of invalid blocks
f6b782f3aa doc: Improve m_best_header documentation (Martin Zumsande)
ee673b9aa0 validation: remove m_failed_blocks (Martin Zumsande)
ed764ea2b4 validation: Add more checks to CheckBlockIndex() (Martin Zumsande)
9a70883002 validation: in invalidateblock, calculate m_best_header right away (Martin Zumsande)
8e39f2d20d validation: in invalidateblock, mark children as invalid right away (Martin Zumsande)
4c29326183 validation: cache all headers with enough PoW in invalidateblock (Martin Zumsande)
15fa5b5a90 validation: call InvalidBlockFound also from AcceptBlock (Martin Zumsande)

Pull request description:

  Some fields in validation are set opportunistically by "best effort":
  - The `BLOCK_FAILED_CHILD` status (which means that the block index has an invalid predecessor)
  - `m_best_header` (the most-work header not known to be invalid).

  This means that there are known situations in which these fields are not set when they should be, or set to wrong values. This is tolerated because the fields are not used for anything consensus-critical and triggering these situations involved creating invalid blocks with valid PoW header, so would have a cost attached. Also, having stricter guarantees for these fields requires iterating over the entire block index, which has some DoS potential, especially with any header above the checkpoint being accepted int he past (see e.g. #11531).

  However, there are reasons to change this now:
  - RPCs use these fields and can report wrong results
  - There is the constant possibility that someone could add code that expects these fields to be correct, especially because it is not well documented that these fields cannot always be relied upon.
  - DoS concerns have become less of an issue after #25717 - now an attacker would need to invest much more work because they can't fork off the last checkpoint anymore

  This PR continues the work from #30666 to ensure that `BLOCK_FAILED_CHILD` status and `m_best_header` are always correct:
  - it adds a call to `InvalidChainFound()` in `AcceptBlock()`.
  - it adds checks for `BLOCK_FAILED_CHILD` and `m_best_header`  to `CheckBlockIndex()`. In order to be able to do this, the existing cache in the RPC-only `InvalidateBlock()` is adjusted to handle these as well. These are performance optimizations with the goal of avoiding having a call of `InvalidChainFound()` / looping over the block index after each disconnected block.
  I also wrote a fuzz test to find possible edge cases violating `CheckBlockIndex`, which I will PR separately soon.
  - it removes the `m_failed_blocks` set, which was a heuristic necessary when we couldn't be sure if a given block index had an invalid predecessor or not. Now that we have that guarantee, the set is no longer needed.

ACKs for top commit:
  stickies-v:
    re-ACK f6b782f3aa
  achow101:
    reACK f6b782f3aa
  ryanofsky:
    Code review ACK f6b782f3aa with only minor code & comment updates
  TheCharlatan:
    Re-ACK f6b782f3aa

Tree-SHA512: 1bee324216eeee6af401abdb683abd098b18212833f9600dbc0a46244e634cb0e6f2a320c937a5675a12af7ec4a7d10fabc1db9e9bc0d9d0712e6e6ca72d084f
2025-06-11 16:17:22 -04:00
Ava Chow d00d95437d Add MuSig2 Keyagg Cache helper functions
secp256k1 provides us secp256k1_musig_keyagg_cache objects which we are
used as part of session info and to get the aggregate pubkey. These
helper functions help us convert to/from the secp256k1 C objects into
the Bitcoin Core C++ objects.
2025-06-11 11:11:48 -07:00
Ava Chow 8ecea91bf2 sign: Add GetMuSig2ParticipantPubkeys to SigningProvider 2025-06-11 11:11:48 -07:00
Ava Chow fac0ee0bfc build: Enable secp256k1 musig module 2025-06-11 11:11:48 -07:00
Ava Chow 1894f97503 descriptors: Add PubkeyProvider::IsBIP32() 2025-06-11 11:11:48 -07:00
Ava Chow 12bc1d0b1e util/string: Allow Split to include the separator
When splitting a string, sometimes the separator needs to be included.
Split will now optionally include the separator at the end of the left
side of the splits, i.e. it appears at the end of the splits, except
for the last one.

Specifically, for musig() descriptors, Split is used to separate a
musig() from any derivation path that follows it by splitting on the
closing parentheses. Since that parentheses is needed for Func() and
Expr(), Split() needs to preserve the end parentheses instead of
discarding it.
2025-06-11 11:09:42 -07:00
Ava Chow 8811312571 script/parsing: Allow Const to not skip the found constant
When parsing a descriptor, it is useful to be able to check whether a
string begins with a substring without consuming that substring as
another function such as Func() will be used later which requires that
substring to be present at the beginning.

Specifically, for MuSig2, this modified Const will be used to determine
whether a an expression begins with "musig(" before a subsequent
Func("musig", ...) is used.
2025-06-11 11:07:35 -07:00
merge-script 851f540d0e
Merge bitcoin/bitcoin#32703: test: Explain how to reproduce zmq:: upstream race
fa0b766f43 test: Remove intermittent and presumed fixed tsan race suppressions (MarcoFalke)
fa4b659dcd test: Explain how to reproduce zmq:: upstream race (MarcoFalke)

Pull request description:

  An explanation makes it easier to reproduce, if needed.

ACKs for top commit:
  fanquake:
    ACK fa0b766f43

Tree-SHA512: 4857cc1e2c97e3d8c194fd12d0bb2a3293136c51ae1b89e0320161d1b8f22ef5122519e099288e52e42bb828ee4a56bfdfbe80717d95178748b76dd7209e12db
2025-06-11 16:55:55 +01:00
merge-script 5af5e9791d
Merge bitcoin/bitcoin#32690: depends: fix multiprocess build on OpenBSD (apply capnp patch, correct SHA256SUM command)
8713e8060d depends: fix SHA256SUM command on OpenBSD (use GNU mode output) (Sebastian Falbesoner)
2d938720bd depends: add patch to fix capnp build on OpenBSD (Sebastian Falbesoner)

Pull request description:

  This PR fixes the multiprocess depends build for OpenBSD by applying upstream patch https://github.com/capnproto/capnproto/pull/2308 and switching the SHA256SUM command to output hash sums in the expected format (the default is BSD format [1], but we need GNU format [2], see commit message for details). Note that the hashing issue is only prevailing for packages defining the `$(package)_local_dir` variable (introduced in 5d105fb8c3, part of #31741), where the following line of the `fetch_local_dir_sha256` function leads to the wrong output:
  ae024137bd/depends/funcs.mk (L57)

  The first commit can be replaced with a simple capnp version bump once this is available in a release.

  Tested on OpenBSD 7.7 (x86_64) via
  ```
  $ gmake -C depends MULTIPROCESS=1 NO_BOOST=1 NO_LIBEVENT=1 NO_QT=1 NO_QR=1 NO_WALLET=1 NO_ZMQ=1 NO_USDT=1
  ```

  [1] example output: `SHA256 (/home/thestack/.vimrc) = 6ba69d100e8c5ca0488ded6293d4e5f740a6a5d5ace96cbcf0599c18d27389e4`
  [2] example output: `6ba69d100e8c5ca0488ded6293d4e5f740a6a5d5ace96cbcf0599c18d27389e4 /home/thestack/.vimrc`

ACKs for top commit:
  Sjors:
    ACK 8713e8060d
  hebasto:
    ACK 8713e8060d.
  fanquake:
    ACK 8713e8060d

Tree-SHA512: 178b8b41156e1f1eea101849110167d2636c3093b6a68c88a91a994f0750831aa02e415eb2793c522682c92cb3085de025300e0e2dee894e112dd7e1f495cc08
2025-06-11 16:04:47 +01:00
merge-script fed41b75fb
Merge bitcoin/bitcoin#32431: deps: Bump lief to 0.16.6
4f56c9145a refactor: contrib: Move FORTIFY check to BASE_ELF (David Gumberg)
f6d25e8a2d contrib: Re-enable FORTIFY check for RISCV (David Gumberg)
765922d802 deps: bump lief to 0.16.6 (David Gumberg)

Pull request description:

  Partially resolves https://github.com/bitcoin/bitcoin/issues/30520, updating `lief` to 0.16.6.

ACKs for top commit:
  fanquake:
    ACK 4f56c9145a

Tree-SHA512: f88dde626975044cee6c78f019dffe063d466c59d81bae0c1aee8a4964eb94d84e5197242e0ae05f130b3925955ac7406f47f8a222a128be7b5865f16ce7bdb6
2025-06-11 12:41:02 +01:00
ismaelsadeeq e017ef3c7e init: make `-blockmaxweight` startup option debug-only 2025-06-11 12:05:47 +01:00
Sjors Provoost 578ea3eedb
test: round difficulty and networkhashps
Both are rational numbers. Client software should only use them to
display information to humans. Followup calculations should use the
underlying values such as target.

Therefore it's not necessary to test the handling of these floating
point values. Round them down to avoid spurious test failures.

Fixes #32515
2025-06-11 11:37:24 +02:00
Hennadii Stepanov c8abd97281
Merge bitcoin/bitcoin#32719: doc, windows: CompanyName "Bitcoin" => "Bitcoin Core project"
239fc4d62e doc, windows: CompanyName "Bitcoin" => "Bitcoin Core project" (Hodlinator)

Pull request description:

  Brings Windows executables in line with */share/setup.nsi.in:14* used by the installer.

  Discovered while reviewing tangential PR: https://github.com/bitcoin/bitcoin/pull/32634#discussion_r2112641918

ACKs for top commit:
  maflcko:
    lgtm ACK 239fc4d62e
  Sjors:
    utACK 239fc4d62e
  janb84:
    utACK 239fc4d62e
  hebasto:
    ACK 239fc4d62e.

Tree-SHA512: 5855e78c32e15a1e4e9b1a6bdefd29c45676a64b3eb4470cb98fa0eea02701edadbde7153143757b525e9a66eb3b49bbba926e8e322307ae6ea4a44ac23eeffb
2025-06-11 10:26:07 +01:00
furszy 029ba1a21d
index: remove CBlockIndex access from CustomAppend()
Moved CBlockUndo disk read lookups from child index classes to
the base index class.

The goal is for child index classes to synchronize only through
events, without directly accessing the chain database.

This change will enable future parallel synchronization mechanisms,
reduce database access (when batched), and contribute toward the
goal of running indexes in a separate process (with no chain
database access).

Besides that, this commit also documents how NextSyncBlock() behaves.
It is not immediately clear this function could return the first
block after the fork point during a reorg.
2025-06-10 20:22:18 -04:00
furszy 91b7ab6c69
refactor: index, simplify CopyHeightIndexToHashIndex to process single block
The function previously handled a range of heights but now copies only a
single entry. This change simplifies the code to match its current usage.
2025-06-10 20:22:18 -04:00
David Gumberg 4f56c9145a refactor: contrib: Move FORTIFY check to BASE_ELF 2025-06-10 17:13:57 -07:00
David Gumberg f6d25e8a2d contrib: Re-enable FORTIFY check for RISCV
Skipping this check is no longer necessary since ab85865f27
resolved the issue.
2025-06-10 17:13:57 -07:00
David Gumberg 765922d802 deps: bump lief to 0.16.6
Some of the primary changes are:
- lief.EXE_FORMATS became lief.Binary.FORMATS IN 0.14.0
        - 494f116c6b/doc/sphinx/changelog.rst?plain=1#L702
- lief.ARCHITECTURES became lief.Header.ARCHITECTURES in 0.16.0
        - 494f116c6b/doc/sphinx/changelog.rst?plain=1#L226C18-L227C18
- lief.ELF.ARCH.x86_64 became lief.ELF.ARCH.X86_64

This commit includes a workaround for the bug fixed in
https://github.com/lief-project/LIEF/pull/1218, but the workaround can
be kept, since it makes `has_nx` checks stricter by enforcing both heap
and stack are non-executable.

This change also requires a patch to partially revert a commit to LIEF
(f23ced2f4f)
which broke compatibility with versions of scikit-build-core <= 0.10.x.

This patch can be dropped once the guix time machine advances to or
beyond 35c5f07e96,
which bumps the scikit-build-core version in guix from 0.9.3 to 0.10.7.

Co-authored-by: willcl-ark <will8clark@gmail.com>
Co-authored-by: fanquake <fanquake@gmail.com>
Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2025-06-10 17:13:57 -07:00
Ava Chow 4b8ac9eacd
Merge bitcoin/bitcoin#32680: ci: Rewrite test-each-commit as py script
fa9cfdf3be ci: [doc] fix url redirect (MarcoFalke)
fac60b9c48 ci: Rewrite test-each-commit as py script (MarcoFalke)

Pull request description:

  This was requested in https://github.com/bitcoin/bitcoin/pull/32573#issuecomment-2897546693, as it is currently not possible to catch this type of error in a Bash linter (https://github.com/bitcoin/bitcoin/pull/32573#pullrequestreview-2857077463). Also, reviewers are not familiar with it and didn't catch the above bug either. (Thus, it is discouraged in the dev notes: https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#scripts)

  So just use a simple python script.

ACKs for top commit:
  achow101:
    ACK fa9cfdf3be
  janb84:
    ACK fa9cfdf3be
  ryanofsky:
    Code review ACK fa9cfdf3be

Tree-SHA512: d884795a1db6c0b762a514acfab200e8dead05fc60d2147d988198d0cdb468a24081bb143d505c51fa34207c52685d227496988503e5828a75e667dda7efef63
2025-06-10 16:58:05 -07:00
Sebastian Falbesoner 4ef6253017 test: avoid unneeded (w)txid hex -> integer conversions
Rather than determining a CTransaction's (w)txid as an integer by
converting it's hex value, it can be directly accessed via the
introduced `.{w,}txid_int` property.
2025-06-11 00:52:25 +02:00
Sebastian Falbesoner 472f3770ae scripted-diff: test: rename CTransaction `.getwtxid()` -> `wtxid_hex` for consistency
-BEGIN VERIFY SCRIPT-

sed -i "s|def getwtxid|@property\n    def wtxid_hex|g" ./test/functional/test_framework/messages.py
sed -i "s|getwtxid()|wtxid_hex|g" $(git grep -l getwtxid)

-END VERIFY SCRIPT-
2025-06-11 00:52:25 +02:00
Sebastian Falbesoner 81af4334e8 test: rename CTransaction `.sha256` -> `.txid_int` for consistency
Note that we unfortunately can't use a scripted diff here, as the same
property name is also used for `CBlockHeader`/`CBlock` instances.
2025-06-11 00:52:25 +02:00
Sebastian Falbesoner ce83924237 test: rename CTransaction `.rehash()`/`.hash` -> `.txid_hex` for consistency
Note that we unfortunately can't use a scripted diff here, as the same
property and method name is also used for `CBlockHeader`/`CBlock` instances.
2025-06-11 00:49:10 +02:00
Cory Fields 6efbd1e1dc refactor: CTransaction equality should consider witness data
It is not at all obvious that two transactions with differing witness data
should test equal to each other.

There was only a single instance of a caller relying on this behavior, and that
one appears accidental (left-over from before segwit). That caller (in the
wallet) has been fixed.

Change the definition of transaction equality (and inequality) to use the wtxid
instead.
2025-06-10 22:10:05 +00:00
Cory Fields cbf9b2dab1 mempool: codify existing assumption about duplicate txids during removal
Also explicitly check for txid equality rather than transaction equality as the
former is a tighter constraint if witness data is included when comparing the
full transactions.

Co-authored-by: glozow <gloriajzhao@gmail.com>
2025-06-10 22:10:05 +00:00
Ava Chow c3fe85e2d6 wallet, rpc, test: Remove deprecated getunconfirmedbalance 2025-06-10 15:07:11 -07:00
Ava Chow 0ec255139b wallet, rpc: Remove deprecated balances from getwalletinfo 2025-06-10 14:49:02 -07:00
Cory Fields e9331cd6ab wallet: IsEquivalentTo should strip witness data in addition to scriptsigs 2025-06-10 21:25:14 +00:00
merge-script 157bbd0a07
Merge bitcoin/bitcoin#32425: config: allow setting -proxy per network
e98c51fcce doc: update tor.md to mention the new -proxy=addr:port=tor (Vasil Dimov)
ca5781e23a config: allow setting -proxy per network (Vasil Dimov)

Pull request description:

  `-proxy=addr:port` specifies the proxy for all networks (except I2P). Previously only the Tor proxy could have been specified separately via `-onion=addr:port`.

  Make it possible to specify separately the proxy for IPv4, IPv6, Tor and CJDNS by e.g. `-proxy=addr:port=ipv6`. Or remove the proxy for a given network, e.g. `-proxy=0=cjdns`.

  Resolves: https://github.com/bitcoin/bitcoin/issues/24450

ACKs for top commit:
  pinheadmz:
    ACK e98c51fcce
  caesrcd:
    reACK e98c51fcce
  danielabrozzoni:
    Code Review ACK e98c51fcce
  1440000bytes:
    ACK e98c51fcce

Tree-SHA512: 0cb590cb72b9393cc36357e8bd7861514ec4c5bc044a154e59601420b1fd6240f336ab538ed138bc769fca3d17e03725d56de382666420dc0787895d5bfec131
2025-06-10 15:57:09 -04:00
merge-script ebec7bf389
Merge bitcoin/bitcoin#32572: doc: Remove stale sections in dev notes
fac00d4ed3 doc: Move CI-must-pass requirement into readme section (MarcoFalke)
fab79c1a25 doc: Clarify and move "hygienic commit" note (MarcoFalke)
fac8b05197 doc: Clarify strprintf size specifier note (MarcoFalke)
faaf34ad72 doc: Remove section about RPC alias via function pointer (MarcoFalke)
2222d61e1c doc: Remove section about RPC arg names in table (MarcoFalke)
fa00b8c02c doc: Remove section about include guards (MarcoFalke)
fad6cd739b doc: Remove dev note section on includes (MarcoFalke)
fa6623d85a doc: Remove file name section (MarcoFalke)
7777fb8bc7 doc: Remove shebang section (MarcoFalke)
faf65f0531 doc: Remove .gitignore section (MarcoFalke)
faf2094f25 doc: Remove note about removed ParsePrechecks (MarcoFalke)
fa69c5b170 doc: Remove -disablewallet from dev notes (MarcoFalke)

Pull request description:

  This removes sections that I've been collecting as stale or overly redundant over the years. The rationale for each removal is in the commit message.

ACKs for top commit:
  yuvicc:
    ACK fac00d4ed3
  janb84:
    LGTM ACK fac00d4ed3
  glozow:
    ACK fac00d4ed3, all lgtm

Tree-SHA512: 17a5b4277fb30d265959d1230a705b36d8501a64c0f4a7f272ea5d9c22031421f95c491144f6d6f714dc7927df667d96ece9ceb43e0a07317d76fdcc4769aaa7
2025-06-10 15:41:11 -04:00
pablomartin4btc ce90f0c99f rpc, wallet, refactor: Remove non-descriptor errors
It is not possible to load a legacy/ non-descriptor wallet anymore
so no need to check for WALLET_FLAG_DESCRIPTORS in RPC calls, even when
passing -rpcwallet/ JSON `/wallet/<walletname>/` endpoint, that searches
for the wallets loaded already in the context.
2025-06-10 16:34:17 -03:00
pablomartin4btc 573bcd75d7 wallet, refactor: Remove unused SetupGeneration
SetupGeneration was supposed to be the function that all SPKMs used
to setup automatic generation, but it didn't work out that way and
ended up being legacy only. It should be deleted at this point.
2025-06-10 16:34:17 -03:00
pablomartin4btc 5431f2dc21 wallet, refactor: Remove Legacy warnings and errors
Remove dead code due to legacy wallet removal.
2025-06-10 16:27:42 -03:00
Ryan Ofsky 6f1392cc42
indexes, refactor: Remove remaining CBlockIndex* uses in index Rewind methods
Move ReadBlock code from CoinStatsIndex::CustomRewind to BaseIndex::Rewind

Move ReadUndo code from CoinStatsIndex::ReverseBlock to BaseIndex::Rewind

This commit does change behavior slightly. Since the new CustomRemove
methods only take a single block at a time instead of a range of
disconnected blocks, when they call CopyHeightIndexToHashIndex they will
now do an index seek for each removed block instead of only seeking once
to the height of the earliest removed block. Seeking instead of scanning
is a little worse for performance if there is a >1 block reorg, but
probably not noticeable unless the reorg is very deep.
2025-06-10 12:57:15 -04:00
Ryan Ofsky 0a248708dc
indexes, refactor: Stop requiring CBlockIndex type to call IsBIP30Unspendable
This commit does not change behavior in any way.
2025-06-10 12:57:15 -04:00
merge-script 011a8c5f01
Merge bitcoin/bitcoin#32696: doc: make `-DWITH_ZMQ=ON` explicit on `build-unix.md`
32d4e92b9a doc: make `-DWITH_ZMQ=ON` explicit on `build-unix.md` (Luis Schwab)

Pull request description:

  ZMQ support is not built by default on Linux, and the docs don't make that clear. This PR makes it explicit that the `-DWITH_ZMQ=ON` flag is required to build with ZMQ support on `build-unix.md`.

ACKs for top commit:
  maflcko:
    lgtm ACK 32d4e92b9a

Tree-SHA512: 322d0dd86bb80aa5a5640a5510cbeeec29f490c33b8f7360e3a202147a02c303064e6761ceb42e38e26982c61f35c9b048804c705a0d95c5737ebd2109febead
2025-06-10 17:26:04 +01:00
merge-script fe39050a66
Merge bitcoin/bitcoin#32678: guix: warn and abort when SOURCE_DATE_EPOCH is set
5c4a0f8009 guix: warn and abort when SOURCE_DATE_EPOCH is set (will)

Pull request description:

  Fixes: #29935

  Current behaviour will by-default use SOURCE_DATE_EPOCH from the environment without warning. This breaks the default reproducibility from a guix build.

  Warn when and exit when this variable is set, and
  FORCE_SOURCE_DATE_EPOCH is unset.

ACKs for top commit:
  maflcko:
    lgtm ACK 5c4a0f8009
  fanquake:
    ACK 5c4a0f8009

Tree-SHA512: fdd6095a91bd87ffdc22918dc43869edc2380501d1b047e95caadd8a6624928691bfe5b7af9693177cbc28e69366e3397e43a06f2f346cc3a9fe233b7fb9588f
2025-06-10 15:22:03 +01:00
merge-script 692fe280c2
Merge bitcoin/bitcoin#32713: doc: fuzz: fix AFL++ link
a39b7071cf doc: fuzz: fix AFL++ link (brunoerg)

Pull request description:

  Fix link about selecting the best AFL compiler.

ACKs for top commit:
  maflcko:
    lgtm ACK a39b7071cf

Tree-SHA512: 6366f18767f6c60f806faa374bd4a6a3bb71a1c74b7040867177ca9ded946707a75b4f39bf698530ba9c5ff708394d88f5b29f4a92f9e95aaca7b37c62b72093
2025-06-10 15:18:32 +01:00
Greg Sanders 28299ce776 p2p: remove vestigial READ_STATUS_CHECKBLOCK_FAILED 2025-06-10 10:07:56 -04:00
Greg Sanders bac9ee4830 p2p: Add witness mutation check inside FillBlock
Since #29412, we have not allowed mutated blocks to continue
being processed immediately the block is received, but this
is only done for the legacy BLOCK message.

Extend these checks as belt-and-suspenders to not allow
similar mutation strategies to affect relay by honest peers
by applying the check inside
PartiallyDownloadedBlock::FillBlock, immediately before
returning READ_STATUS_OK.

This also removes the extraneous CheckBlock call.
2025-06-10 10:07:56 -04:00
Hennadii Stepanov 4f10a57671
depends: Override host compilers for FreeBSD and OpenBSD
When building depends on FreeBSD/OpenBSD `aarch64`, the host compilers
default to `default_host_{CC,CXX}`, which resolves to `gcc`/`g++`. This
is incorrect on these systems, where Clang is the default system
compiler.
2025-06-10 14:59:46 +01:00
Hodlinator 239fc4d62e
doc, windows: CompanyName "Bitcoin" => "Bitcoin Core project"
Matches /share/setup.nsi.in:14
2025-06-10 15:14:24 +02:00
merge-script c1d4253d31
Merge bitcoin/bitcoin#32711: doc: add missing packages for BSDs (cmake, gmake, curl) to depends/README.md
89526deddf doc: add missing packages for BSDs (cmake, gmake, curl) to depends/README.md (Sebastian Falbesoner)

Pull request description:

  Suggested initially only for OpenBSD and cmake (see https://github.com/bitcoin/bitcoin/pull/32690#issuecomment-2949660658, https://github.com/bitcoin/bitcoin/pull/32690#issuecomment-2949729126), this PR adds missing package recommendations for other BSDs as well in order to build depends. I tested this only on OpenBSD, but found the package names for the other BSDs on the ports search engines:
  * FreeBSD: https://ports.freebsd.org/cgi/ports.cgi
  * NetBSD: https://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/index-all.html

  At least on OpenBSD, curl is a [dependency of git](879e73073b/devel/git/Makefile (L49-L50)), so most users will not need to install it explicitly. But as git is not the only way to obtain the source code, I think it doesn't hurt to list it, and we also do it already for Ubuntu & Debian:
  f3bbc74664/depends/README.md?plain=1#L9-L11

ACKs for top commit:
  maflcko:
    lgtm ACK 89526deddf
  Sjors:
    re-utACK 89526deddf
  hebasto:
    ACK 89526deddf.

Tree-SHA512: ba8b540f902b924740c81c5d874f9525d214b75c5892cd1234db2207e9ca96c2bc80e8b743e0d924a55f40a91894cbb4a6635f1561998a7e0ba26d9f68e0e1a4
2025-06-10 13:28:27 +01:00
Sebastian Falbesoner 89526deddf doc: add missing packages for BSDs (cmake, gmake, curl) to depends/README.md 2025-06-10 13:04:25 +02:00
brunoerg a39b7071cf doc: fuzz: fix AFL++ link
Co-authored-by: eugene <elzeigel@gmail.com>
2025-06-09 18:51:17 -03:00
Ava Chow dff208bd5a
Merge bitcoin/bitcoin#32708: rpc, doc: update `listdescriptors` RCP help
b44514b876 rpc, doc: update `listdescriptors` RCP help (rkrux)

Pull request description:

  This RPC lists all the descriptors present in the wallet, not only the ones that were imported, but also the ones generated when a new wallet is created.

  It can be verified by creating a new wallet and calling the `listdescriptors` RPC, which will contain 8 ranged descriptors that are created for every new wallet.

  Also, update the description to get rid of "descriptor-enabled" because this is the only wallet type available now after removal of legacy wallets.

ACKs for top commit:
  maflcko:
    lgtm ACK b44514b876
  achow101:
    ACK b44514b876
  pablomartin4btc:
    ACK b44514b876
  theStack:
    ACK b44514b876

Tree-SHA512: d1018dd42fc4de12793f3e4f3be79ecb3fdee46fbc93ec8adb62b29a86e74aba2605d9908632107061f48ef8ee6f39ef6d0e34cc5e91acd93bc02242a2cee3eb
2025-06-09 14:38:14 -07:00
Ava Chow d978a43d05
Merge bitcoin/bitcoin#32408: tests: Expand HTTP coverage to assert libevent behavior
f16c8c67bf tests: Expand HTTP coverage to assert libevent behavior (Matthew Zipkin)

Pull request description:

  These commits are cherry-picked from #32061  and part of a project to [remove libevent](https://github.com/bitcoin/bitcoin/issues/31194).

  This PR only adds functional tests to `interface_http` to cover some HTTP server behaviors we inherit from libevent, in order to maintain those behaviors when we replace libevent with our own HTTP server.

  1. Pipelining: The server must respond to requests from a client in the order in which they were received [RFC 7230 6.3.2](https://www.rfc-editor.org/rfc/rfc7230#section-6.3.2)
  2. `-rpcservertimeout` config option which sets the amount of time the server will keep an idle client connection alive
  3. "Chunked" Transfer-Encoding: Allows a client to send a request in pieces, without the `Content-Length` header [RFC 7230 4.1](https://www.rfc-editor.org/rfc/rfc7230#section-4.1)

ACKs for top commit:
  achow101:
    ACK f16c8c67bf
  vasild:
    ACK f16c8c67bf
  polespinasa:
    ACK f16c8c67bf
  fjahr:
    utACK f16c8c67bf

Tree-SHA512: 405b59431b4d2bf118fde04b270865dee06ef980ab120d9cc1dce28e5d65dfd880a57055b407009d22f4de614bc3eebdb3e203bcd39e86cb14fbfd62195ed06a
2025-06-09 13:08:25 -07:00
Sebastian Falbesoner e9cdaefb0a test: introduce and use CTransaction `.wtxid_int` property
This commits removes the `.calc_sha256` method from the CTransaction
and introduces a property `.wtxid_int` property as replacement.
2025-06-09 17:28:28 +02:00
Sebastian Falbesoner 9b3dce24a3 test: remove bare CTransaction `.rehash()`/`.calc_sha256()` calls
Since the previous commit, CTransaction object calls to the
methods `.rehash()` and `.calc_sha256()` are effectively no-ops
if the returned value is not used, so we can just remove them.
2025-06-09 17:28:24 +02:00
Sebastian Falbesoner a2724e3ea3 test: remove txid caching in CTransaction class
Rather than txids (represented by the fields `.sha256` and `.hash`)
being stateful, simply compute them on-the-fly. This ensures that
the correct values are always returned and takes the burden of
rehashing from test writers, making the code shorter overall.
In a first step, the fields are kept at the same name with @property
functions as drop-in replacements, for a minimal diff. In later commits,
the names are changed to be more descriptive and indicating the return
type of the txid.
2025-06-09 16:55:04 +02:00
MarcoFalke fa0b766f43
test: Remove intermittent and presumed fixed tsan race suppressions
LoadWallet was added in commit d77170d526, which
points to a traceback with BerkeleyBatch in it. Now that BDB is removed,
this can be removed as well.

The race in DatabaseBatch was added in commit
fd59670642, which does not point to a
traceback. This was likely also fixed with the BDB removal.

If not, the suppressions should be added back, mentioning that they are
intermittent and including a traceback and possibly steps to reproduce.
2025-06-09 16:28:48 +02:00
merge-script f3bbc74664
Merge bitcoin/bitcoin#32406: policy: uncap datacarrier by default
a189d63618 add release note for datacarriersize default change (Greg Sanders)
a141e1bf50 Add more OP_RETURN mempool acceptance functional tests (Peter Todd)
0b4048c733 datacarrier: deprecate startup arguments for future removal (Greg Sanders)
63091b79e7 test: remove unnecessary -datacarriersize args from tests (Greg Sanders)
9f36962b07 policy: uncap datacarrier by default (Greg Sanders)

Pull request description:

  Retains the `-datacarrier*` args, marks them as deprecated, and does not require another startup argument for multiple OP_RETURN outputs.

  If a user has set `-datacarriersize` the value is "budgeted" across all seen OP_RETURN output scriptPubKeys. In other words the total script bytes stays the same, but can be spread across any number of outputs. This is done to not introduce an additional argument to support multiple outputs.

  I do not advise people use the option with custom arguments and it is marked as deprecated to not mislead as a promise to offer it forever. The argument itself can be removed in some future release to clean up the code and minimize footguns for users.

ACKs for top commit:
  stickies-v:
    re-ACK a189d63618
  Sjors:
    re-ACK a189d63618
  polespinasa:
    re-ACK a189d63618
  hodlinator:
    re-ACK a189d63618
  ajtowns:
    reACK a189d63618
  mzumsande:
    re-ACK a189d63618
  petertodd:
    ACK a189d63618
  theStack:
    re-ACK a189d63618
  1440000bytes:
    re-ACK a189d63618
  willcl-ark:
    ACK a189d63618
  dergoegge:
    ACK a189d63618
  fanquake:
    ACK a189d63618
  murchandamus:
    ACK a189d63618
  darosior:
    Concept ACK a189d63618.

Tree-SHA512: 3da2f1ef2f50884d4da7e50df2121bf175cb826edaa14ba7c3068a6d5b2a70beb426edc55d50338ee1d9686b9f74fdf9e10d30fb26a023a718dd82fa1e77b038
2025-06-09 08:23:56 -04:00
Vasil Dimov 0802398e74
fuzz: make it possible to mock (fuzz) CThreadInterrupt
* Make the methods of `CThreadInterrupt` virtual and store a pointer to
  it in `CConnman`, thus making it possible to override with a mocked
  instance.
* Initialize `CConnman::m_interrupt_net` from the constructor, making it
  possible for callers to supply mocked version.
* Introduce `FuzzedThreadInterrupt` and `ConsumeThreadInterrupt()` and
  use them in `src/test/fuzz/connman.cpp` and `src/test/fuzz/i2p.cpp`.

This improves the CPU utilization of the `connman` fuzz test.

As a nice side effect, the `std::shared_ptr` used for
`CConnman::m_interrupt_net` resolves the possible lifetime issues with
it (see the removed comment for that variable).
2025-06-09 14:17:33 +02:00
Vasil Dimov 6d9e5d130d
fuzz: add CConnman::SocketHandler() to the tests 2025-06-09 14:17:33 +02:00
Vasil Dimov 3265df63a4
fuzz: add CConnman::InitBinds() to the tests 2025-06-09 14:17:29 +02:00
Vasil Dimov 91cbf4dbd8
fuzz: add CConnman::CreateNodeFromAcceptedSocket() to the tests 2025-06-09 14:13:53 +02:00
Vasil Dimov 50da7432ec
fuzz: add CConnman::OpenNetworkConnection() to the tests
Now that all network calls done by `CConnman::OpenNetworkConnection()`
are done via `Sock` they can be redirected (mocked) to `FuzzedSocket`
for testing.
2025-06-09 14:13:52 +02:00
Vasil Dimov e6a917c8f8
fuzz: add Fuzzed NetEventsInterface and use it in connman tests 2025-06-09 14:13:49 +02:00
rkrux b44514b876
rpc, doc: update `listdescriptors` RCP help
This RPC lists all the descriptors present in the wallet, not only
the ones that were imported, but also the ones generated when a
new wallet is created.

It can be verified by creating a new wallet and calling the
`listdescriptors` RPC, which will contain 8 ranged descriptors that
are created for every new wallet.

Also, update the description to get rid of "descriptor-enabled"
because this is the only wallet type available now after removal of
legacy wallets.
2025-06-09 15:15:47 +05:30
Vasil Dimov e883b37768
fuzz: set the output argument of FuzzedSock::Accept()
`FuzzedSock::Accept()` properly returns a new socket, but it forgot to
set the output argument `addr`, like `accept(2)` is expected to.

This could lead to reading uninitialized data during testing when we
read it, e.g. from `CService::SetSockAddr()` which reads the `sa_family`
member.

Set `addr` to a fuzzed IPv4 or IPv6 address.
2025-06-09 10:45:52 +02:00
MarcoFalke fa4b659dcd
test: Explain how to reproduce zmq:: upstream race 2025-06-08 16:39:33 +02:00
Roman Zeyde d4e212e8a6
rest: fetch spent transaction outputs by blockhash
Today, it is possible to fetch a block's spent prevouts in order to
build an external index by using the `/rest/block/HASH.json` endpoint.
However, its performance is low due to JSON serialization overhead.

We can significantly optimize it by adding a new REST endpoint, using
a binary response format:

```
$ BLOCKHASH=00000000000000000002a7c4c1e48d76c5a37902165a270156b7a8d72728a054

$ ab -k -c 1 -n 100 http://localhost:8332/rest/block/$BLOCKHASH.json
Document Length:        13278152 bytes
Requests per second:    3.53 [#/sec] (mean)
Time per request:       283.569 [ms] (mean)

$ ab -k -c 1 -n 10000 http://localhost:8332/rest/spentoutputs/$BLOCKHASH.bin
Document Length:        195591 bytes
Requests per second:    254.47 [#/sec] (mean)
Time per request:       3.930 [ms] (mean)
```

Currently, this PR is being used and tested by Bindex:

 * https://github.com/romanz/bindex-rs

This PR would allow to improve the performance of external indexers
such as electrs, ElectrumX, Fulcrum and Blockbook:

 * https://github.com/romanz/electrs (also https://github.com/Blockstream/electrs and https://github.com/mempool/electrs)
 * https://github.com/spesmilo/electrumx
 * https://github.com/cculianu/Fulcrum
 * https://github.com/trezor/blockbook
2025-06-07 20:17:50 +03:00
Luis Schwab 32d4e92b9a
doc: make `-DWITH_ZMQ=ON` explicit on `build-unix.md` 2025-06-06 19:42:01 -03:00
Ava Chow e2174378aa
Merge bitcoin/bitcoin#32539: init: Configure reachable networks before we start the RPC server
12ff4be9c7 test: ensure -rpcallowip is compatible with RFC4193 (Matthew Zipkin)
c02bd3c187 config: Explain RFC4193 and CJDNS interaction in help and init error (Matthew Zipkin)
f728b6b111 init: Configure reachable networks before we start the RPC server (Matthew Zipkin)

Pull request description:

  Closes https://github.com/bitcoin/bitcoin/issues/32433

  `MaybeFlipIPv6toCJDNS()` relies on `g_reachable_nets` to distinguish between CJDNS addresses and other IPv6 addresses. In particular, [RFC4193](https://www.rfc-editor.org/rfc/rfc4193#section-3.1) address or "Unique Local Address" with the L-bit unset also begins with the `fc` prefix. #32433 highlights a use case for these addresses that have nothing to do with CJDNS.

  On master we don't parse init flags like `-cjdnsreachable` until *after* the HTTP server has started, causing conflicts with `-rpcallowip` because CJDNS doesn't support subnets.

  This PR ensures that `NET_CJDNS` is only present in the reachable networks list if set by `-cjdnsreachable` *before* `-rpcallowip` is checked. If it is set all `fc` addresses are assumed to be CJDNS, can not have subnets, and can't be set for `-rpcallowip`.

  I also noted this specific parameter interaction in the init help as well as the error message if configured incorrectly.

  This can be tested locally:

  `bitcoind -regtest -rpcallowip=fc00:dead:beef::/64 -rpcuser=u -rpcpassword=p`

  On master this will just throw an error that doesn't even mention IPv6 at all.

  On the branch, this will succeed and can be tested by adding the ULA to a local interface.

  On linux: `sudo ip -6 addr add fc00:dead:beef::1/64 dev lo`

  On macos: `sudo ifconfig lo0 inet6 fc00:dead:beef::1/128 add`

  then: `curl -v -g -6 --interface fc00:dead:beef::1 u:p@[::1]:18443 --data '{"method":"getblockcount"}'`

  If the `rpcallowip` option is removed, the RPC request will fail to authorize.

  Finally, adding `-cjdnsreachable` to the start up command will throw an error and specify the incompatibility:

  > RFC4193 is allowed only if -cjdnsreachable=0.

ACKs for top commit:
  achow101:
    ACK 12ff4be9c7
  tapcrafter:
    tACK 12ff4be9c7
  ryanofsky:
    Code review ACK 12ff4be9c7
  willcl-ark:
    ACK 12ff4be9c7

Tree-SHA512: a4dd70ca2bb9f6ec2c0a9463fd73985d1ed80552c674a9067ac9a86662d1c018cc275ba757cebb2993c5f3971ecf4778b95d35fe7a7178fb41b1d18b601c9960
2025-06-06 15:31:36 -07:00
Ava Chow 2053c43684
Merge bitcoin/bitcoin#32675: test: wallet: cover wallet passphrase with a null char
7cfbb8575e test: wallet: cover wallet passphrase with a null char (brunoerg)

Pull request description:

  This PR adds test coverage for the `walletpassphrase`/`walletpassphrasechange` RPC when the passphrase is incorrect due to a null character.

  For reference: https://github.com/bitcoin/bitcoin/pull/27068 introduced the usage of `SecureString` to allow null characters.

ACKs for top commit:
  maflcko:
    lgtm ACK 7cfbb8575e
  achow101:
    ACK 7cfbb8575e
  w0xlt:
    Code review ACK 7cfbb8575e
  BrandonOdiwuor:
    Code Review ACK 7cfbb8575e
  theStack:
    ACK 7cfbb8575e
  pablomartin4btc:
    cr ACK 7cfbb8575e

Tree-SHA512: ecdb48662ceb6c55c4b301ca7f537c3159ece7b66ee40ea977583ffb74bd3d06e334ab3a5639a9cde3aa6443129f412f9aea0ee5a8b73b31dba0728d0890b7f1
2025-06-06 15:12:01 -07:00
furszy 331a25cb16
test: indexes, avoid creating threads when sync runs synchronously
The indexes test call StartBackgroundSync(), which spawns a thread to run Sync(),
only for the test thread to wait for it to complete by calling IndexWaitSynced().

So, since the sync is performed synchronously, we can skip the extra thread creation
entirely and call Sync() directly.
2025-06-06 16:32:54 -04:00
kevkevinpal 95969bc58a
test: added fuzz coverage to consensus/merkle.cpp
This adds a new fuzz target merkle which adds fuzz coverage to
consensus/merkle.cpp
2025-06-06 11:28:42 -04:00
Martin Zumsande f6b782f3aa doc: Improve m_best_header documentation 2025-06-06 11:23:44 -04:00
Martin Zumsande ee673b9aa0 validation: remove m_failed_blocks
After changes in previous commits, we now mark all blocks that descend from an invalid block
immediately as the block is found invalid. This happens both in the AcceptBlock
and ConnectBlock stages of block validation.
As a result, the pindexPrev->nStatus check in AcceptBlockHeader is now sufficient to detect
invalid blocks and checking m_failed_blocks there is no longer necessary.
2025-06-06 11:23:44 -04:00
Martin Zumsande ed764ea2b4 validation: Add more checks to CheckBlockIndex()
This adds checks that
1) Descendants of invalid block indexes are also marked invalid
2) m_best_header cannot be invalid, and there can be no valid
block with more work than it.
2025-06-06 11:23:44 -04:00
Martin Zumsande 9a70883002 validation: in invalidateblock, calculate m_best_header right away
Before, m_best_header would be calculated only after disconnecting
multiple blocks, letting go of cs_main in the meantime.
This is in preparation for adding checks to CheckBlockIndex()
requiring that m_best_header is the most-work header not known to be invalid.

Co-authored-by: stringintech <stringintech@gmail.com>
2025-06-06 11:23:44 -04:00
Martin Zumsande 8e39f2d20d validation: in invalidateblock, mark children as invalid right away
Before, they would be marked as invalid only after disconnecting
multiple blocks, letting go of cs_main in the meantime.
This is in preparation for adding a check to
CheckBlockIndex() requiring that descendants of invalid block indexes
are always marked as invalid.
Entries from highpow_outofchain_headers are now only removed if made invalid,
no longer after inserting into setBlockIndexCandidates, because they
might still become invalid later in the second case.
This means that blocks could be inserted multiple times now into
setBlockIndexCandidates - this won't have any effect, so
behavior isn't changed.
2025-06-06 11:23:44 -04:00
Martin Zumsande 4c29326183 validation: cache all headers with enough PoW in invalidateblock
We now include blocks without HaveNumChainTxs() / lower validation status
than BLOCK_VALID_TRANSACTIONS. These checks are still performed at the
spot where we use the cache to insert into setBlockIndexCandidates.

This is in preparation for using the cache for more things than
just setBlockIndexCandidates candidates in the following commits.

Co-authored-by: stickies-v <stickies-v@protonmail.com>
2025-06-06 11:23:44 -04:00
Martin Zumsande 15fa5b5a90 validation: call InvalidBlockFound also from AcceptBlock
When a block it found invalid during acceptance (but before connection)
we now mark its descendants with BLOCK_FAILED_CHILD and update
m_best_header when these things weren't done reliably before.

This does not fix a serious bug because the flags and m_best_header were being set on a best-effort basis before
and not used for anything critical.
Setting these reliably has a slight performance cost (iterating over the
entire block index) but leads to more consistency in validation and allows removing m_failed_blocks in a later commit.
This can only be triggered by providing a block with sufficient PoW
that is otherwise invalid, so it is not a DoS vector.
2025-06-06 11:23:44 -04:00
MarcoFalke fa9cfdf3be
ci: [doc] fix url redirect
This solves an URL redirect. (The commit is also used to trigger the test-each-commit CI)
2025-06-06 09:00:27 +02:00
MarcoFalke fac60b9c48
ci: Rewrite test-each-commit as py script 2025-06-06 09:00:24 +02:00
Sebastian Falbesoner 8713e8060d depends: fix SHA256SUM command on OpenBSD (use GNU mode output)
On OpenBSD, the `sha256` command by default outputs hashsums on files in
"BSD" mode, looking like this:

$ sha256 ~/.vimrc
SHA256 (/home/thestack/.vimrc) = 6ba69d100e8c5ca0488ded6293d4e5f740a6a5d5ace96cbcf0599c18d27389e4

This is not compatible with our depends commands, which expect the
hashes to be on the first column (to be extracted via `cut -d" " -f1`).
Fix this by switching to GNU mode output, looking like this:

$ sha256 -r ~/.vimrc
6ba69d100e8c5ca0488ded6293d4e5f740a6a5d5ace96cbcf0599c18d27389e4 /home/thestack/.vimrc

Without this change, the multiprocess depends build fails with the following output:

$ gmake -C depends MULTIPROCESS=1 NO_BOOST=1 NO_LIBEVENT=1 NO_QT=1 NO_QR=1 NO_WALLET=1 NO_ZMQ=1 NO_USDT=1
[ ..... ]
Extracting native_libmultiprocess...
sha256: /home/thestack/bitcoin/depends/work/build/x86_64-unknown-openbsd7.7/native_libmultiprocess/-2bc902f4693/.src-ipc-libmultiprocess.tar.hash: no properly formatted checksum lines found
gmake: *** [funcs.mk:342: /home/thestack/bitcoin/depends/work/build/x86_64-unknown-openbsd7.7/native_libmultiprocess/-2bc902f4693/.stamp_extracted] Error 1
2025-06-06 02:02:30 +02:00
Sebastian Falbesoner 2d938720bd depends: add patch to fix capnp build on OpenBSD
see https://github.com/capnproto/capnproto/pull/2308
2025-06-06 01:32:00 +02:00
Sjors Provoost 0a4ee93529
wallet: use PSBTError::EXTERNAL_SIGNER_NOT_FOUND
Instead of throwing a runtime error, let the caller decide how to handle a missing signer.

GUI code was already in place to handle this, but it was unused until this commit.

Fixes #32426

Additionally use LogWarning instead of std::cerr.
2025-06-05 11:46:08 +02:00
Sjors Provoost 8ba2f9b7c8
refactor: use util::Result for GetExternalSigner()
This commit does not change behavior, except that the error message no longer contains the function name.
2025-06-05 11:32:23 +02:00
merge-script ae024137bd
Merge bitcoin/bitcoin#32496: depends: drop `ltcg` for Windows Qt
9653ebc053 depends: remove support for Windows Qt LTO builds (fanquake)

Pull request description:

  The related Windows patches were dropped in 5e794e6202, and "Cross-compiling does not support LTO." (from #30997).

ACKs for top commit:
  maflcko:
    lgtm ACK 9653ebc053

Tree-SHA512: 40ae7b17669bf87f2e848055e85e1a6c946f0bb0bc1674e18f1622ec4a0613fe955a4daf83928c9375035dac289ce2a72dd7f347b15f86d108157f9da9499945
2025-06-05 10:54:08 +02:00
merge-script 6a2ff67909
Merge bitcoin/bitcoin#32679: doc: update tor docs to use bitcoind binary from path
4ce53495e5 doc: update tor docs to use bitcoind binary from path (ismaelsadeeq)

Pull request description:

  I noticed this while trying to run a node over Tor.
  Using `./bitcoind` as the executable path is incorrect.

  This is a simple documentation update PR that fixes the path by removing the prefix and just
  having `bitcoind`  as the usage example targeting those who have Bitcoin Core in their PATH.

ACKs for top commit:
  davidgumberg:
    ACK 4ce53495e5
  janb84:
    ACK 4ce53495e5
  jonatack:
    ACK 4ce53495e5

Tree-SHA512: a23c94a175f77d66ee1a81599a15a809ad768090eebb619c8e4a67b8a020a2256da4f40cec3c00ec35775b265d3c53cdb70c09fbed48d399416fbc9156ebff31
2025-06-05 10:38:40 +02:00
merge-script fd4399cb9c
Merge bitcoin/bitcoin#32602: fuzz: Add target for coins database
cfc42ae5b7 fuzz: add a target for the coins database (Antoine Poinsot)
46e14630f7 fuzz: move the coins_view target's body into a standalone function (Antoine Poinsot)
56d878c465 fuzz: avoid underflow in coins_view target (Antoine Poinsot)

Pull request description:

  This reopens https://github.com/bitcoin/bitcoin/pull/28216.

  The current `coins_view` target only tests `CCoinsViewCache` using a basic `CCoinsView` instance. The addition of the `coins_view_db` target enables testing with an actual `CCoinsViewDB` as the backend.

ACKs for top commit:
  maflcko:
    lgtm ACK cfc42ae5b7
  l0rinc:
    code review ACK cfc42ae5b7
  TheCharlatan:
    ACK cfc42ae5b7

Tree-SHA512: d3a92f122629f075767453a1abd9819a1c9716db53b997418993fef62d27683324740d0a8f84df76d8a7a45e508ccadeb69553b6f69e29a1238cd7c0be5276ca
2025-06-05 10:28:24 +02:00
Ava Chow 130a922980 wallet, interfaces: Use BERKELEY_RO in isEncrypted
Since isEncrypted opens a file to search for a particular record, it
needs to use BERKELEY_RO when opening a legacy wallet.
2025-06-04 16:51:51 -07:00
Ava Chow f94167512d
Merge bitcoin/bitcoin#32676: test: apply microsecond precision to test framework logging
ed179e0a65 test: apply microsecond precision to test framework logging (Martin Zumsande)

Pull request description:

  When analyzing functional test logs (produced with `combine_logs.py`), entries sometimes sort slightly out of order because even though python prints 6 digits for microsecond precision, it fills up the last 3 digits with zeroes. For example, it may look like a message was received by the test framework before it was sent by the node.

  Change this to actually use microsecond precision - this should make combined logs a little bit easier to analyze.

ACKs for top commit:
  davidgumberg:
    Tested ACK ed179e0a65
  achow101:
    ACK ed179e0a65
  maflcko:
    review ACK ed179e0a65 🗳
  janb84:
    ACK ed179e0a65

Tree-SHA512: 55cdb5024e8e910c5a5ce741ce512eb88f4f82f11f378ba0fe7a5a2b1c97d2e7b540bdf5603c76aab837d35798610b165f087fbeb7c9dc90aaad890bf4d0323d
2025-06-04 15:09:54 -07:00
Ava Chow 0dcb45290c
Merge bitcoin/bitcoin#32607: rpc: Note in fundrawtransaction doc, fee rate is for package
f98e1aaf34 rpc: Note in fundrawtransaction doc, fee rate is for package (benthecarman)

Pull request description:

  Accidentally made some transactions with a much higher fee rate than I wanted because I did not know this would do it for the package rather than the individual tx.

ACKs for top commit:
  achow101:
    ACK f98e1aaf34
  rkrux:
    re-ACK f98e1aaf34
  danielabrozzoni:
    ACK f98e1aaf34

Tree-SHA512: 9f961de1200803ec4d1c6901fd606bb6cf707ffd03942d9dc0d4b6554c827075f99d693b93e892f728679d67e63e12c71da4426dab091b3311d1605bc37251a2
2025-06-04 14:55:10 -07:00
ismaelsadeeq 4ce53495e5
doc: update tor docs to use bitcoind binary from path 2025-06-04 20:25:52 +01:00
merge-script a5e98dc3ae
Merge bitcoin/bitcoin#32651: cmake: Replace deprecated `qt6_add_translation` with `qt6_add_lrelease`
18cf727429 cmake: Replace deprecated `qt6_add_translation` with `qt6_add_lrelease` (Hennadii Stepanov)

Pull request description:

  See Qt docs:
  - https://doc.qt.io/archives/qt-6.2/qtlinguist-cmake-qt-add-translation.html
  - https://doc.qt.io/archives/qt-6.2/qtlinguist-cmake-qt-add-lrelease.html

ACKs for top commit:
  fanquake:
    ACK 18cf727429

Tree-SHA512: 10a4023b24d2936a41b8049063b0e210b76cd4d9c9e22a28de579a211f047b5446785005d6918f0b80c6461960717be62cf9b92b0c66000a95379a41dfa83fd2
2025-06-04 16:36:23 +02:00
fanquake 9653ebc053
depends: remove support for Windows Qt LTO builds
The patches needed to support this were dropped in
5e794e6202 and "Cross-compiling does not
support LTO." (from #30997), so remove it for now.
2025-06-04 15:49:49 +02:00
brunoerg 7cfbb8575e test: wallet: cover wallet passphrase with a null char 2025-06-04 09:50:03 -03:00
will 5c4a0f8009
guix: warn and abort when SOURCE_DATE_EPOCH is set
Current behaviour will by-default use SOURCE_DATE_EPOCH from the
environment without warning. This breaks the default reproducibility
from a guix build.

Warn when and exit when this variable is set, and
FORCE_SOURCE_DATE_EPOCH is unset.
2025-06-04 12:24:08 +01:00
merge-script 4af72d8b08
Merge bitcoin/bitcoin#32647: build: add -Wthread-safety-pointer
83bfe1485c build: add -Wthread-safety-pointer (fanquake)
240a4fb95d Squashed 'src/leveldb/' changes from 113db4962b..aba469ad6a (fanquake)

Pull request description:

  This will become available in Clang 21:

  > ThreadSafetyAnalysis now supports -Wthread-safety-pointer, which
  > enables warning on passing or returning pointers to guarded variables
  > as function arguments or return value respectively. Note that
  > ThreadSafetyAnalysis still does not perform alias analysis. The
  > feature will be default-enabled with -Wthread-safety in a future release.

  See https://github.com/llvm/llvm-project/blob/main/clang/docs/ReleaseNotes.rst.

  Also updates the leveldb subtree to pull: https://github.com/bitcoin-core/leveldb-subtree/pull/54.

ACKs for top commit:
  davidgumberg:
    Tested ACK  83bfe1485c
  maflcko:
    lgtm ACK 83bfe1485c
  theuni:
    utACK 83bfe1485c

Tree-SHA512: 9bc80bd04a9cebed8aca20bc23a17e52a6a89a1fb042993322f43dbf7bd93de509c091ebb69255063833b098ab11a64285eccf61e17b9f94f974c734a20ad8da
2025-06-04 10:58:04 +02:00
merge-script a980918f51
Merge bitcoin/bitcoin#32568: depends: use "mkdir -p" when installing xproto
df9ebbf659 depends: use "mkdir -p" when installing xproto (fanquake)

Pull request description:

  It looks like the mkdir detection in xproto is broken on Alpine. Ensure we always use `mkdir -p`.

  Fixes #32494.

ACKs for top commit:
  hebasto:
    ACK df9ebbf659, I have reviewed the code and it looks OK.
  janb84:
    ACK df9ebbf659
  willcl-ark:
    ACK df9ebbf659

Tree-SHA512: 0f23b1096ffdf5ffa13115665dc42b65835b78bb0ab04a8be8f210980356953ab518e1273302fe4c9239361201f4f9ac737c0ebf10625f4817f81b65b3b25572
2025-06-03 20:21:19 +01:00
Martin Zumsande ed179e0a65 test: apply microsecond precision to test framework logging
This makes it easier to compare test and bitcoind logs -
combine_logs.py orders by timestamp and will be more precise.
2025-06-03 14:02:01 -04:00
MarcoFalke fa9ca13f35
refactor: Sort includes of touched source files 2025-06-03 19:56:55 +02:00
MarcoFalke facb152697
scripted-diff: Bump copyright headers after include changes
Historically, the headers have been bumped some time after a file has
been touched. Do it now to avoid having to touch them again in the
future for that reason.

-BEGIN VERIFY SCRIPT-
 sed -i --regexp-extended 's;( 20[0-2][0-9])(-20[0-2][0-9])? The Bitcoin Core developers;\1-present The Bitcoin Core developers;g' $( git show --pretty="" --name-only HEAD~0 )
-END VERIFY SCRIPT-
2025-06-03 15:13:57 +02:00
MarcoFalke fae71d30f7
clang-tidy: Apply modernize-deprecated-headers
This can be reproduced according to the developer notes with something
like

( cd ./src/ && ../contrib/devtools/run-clang-tidy.py -p ../bld-cmake -fix -j $(nproc) )

Also, the header related changes were done manually.
2025-06-03 15:13:54 +02:00
merge-script e872a566f2
Merge bitcoin/bitcoin#32644: doc: miscellaneous changes
e50312eab0 doc: fix typos (fanquake)
c797e50dda ci: update codespell to 2.4.1 (fanquake)
21ee656337 doc: Remove obselete link in notificator.cpp (strmfos)
ee4406c04a doc: update URLs (fanquake)

Pull request description:

  A round up of #32629 + some other changes that had previously been PR'd.

ACKs for top commit:
  maflcko:
    review ACK e50312eab0 🥗

Tree-SHA512: 8fa3e14fdfa0cf65a42debc9cbb1f8b379aba44aa185e2e27337431e884d169bf1e811655c3a884d918e65ea28c5767ddaabaf25c862ebd9b4b38a0229ec5a93
2025-06-03 09:10:49 +01:00
fanquake e50312eab0
doc: fix typos
Co-authored-by: Ragnar <rodiondenmark@gmail.com>
Co-authored-by: VolodymyrBg <aqdrgg19@gmail.com>
2025-06-03 08:09:28 +01:00
fanquake c797e50dda
ci: update codespell to 2.4.1 2025-06-03 08:09:28 +01:00
strmfos 21ee656337
doc: Remove obselete link in notificator.cpp 2025-06-03 08:09:28 +01:00
fanquake ee4406c04a
doc: update URLs
Some are now redirecting, some are outdated, i.e qt5.
2025-06-03 08:09:21 +01:00
Ava Chow 2d819fa4df
Merge bitcoin/bitcoin#29032: signet: omit commitment for some trivial challenges
6ee32aaaca test: signet tool genpsbt and solvepsbt commands (Sjors Provoost)
0a99d99fe4 signet: miner skips PSBT step for OP_TRUE (Sjors Provoost)
cdfb70e5a6 signet: split decode_psbt miner helper (Sjors Provoost)

Pull request description:

  [BIP325](https://github.com/bitcoin/bips/blob/master/bip-0325.mediawiki) mentions the following rule:

  > In the special case where an empty solution is valid (ie scriptSig and scriptWitness are both empty) this additional commitment can optionally be left out. This special case is to allow non-signet-aware block generation code to be used to test a custom signet chain where the challenge is trivially true.

  Such a signet can be created using e.g. `-signetchallenge=51` (`OP_TRUE`). However `contrib/signet/miner` won't omit the commitment.

  This PR improves the miner by skipping the PSBT for known trivial scripts (just `OP_TRUE` and trivial pushes for now). This prevents it from appending the 4 byte signet header to the witness commitment, as allowed by the above rule.

  ---

  Previously the script would fail with `PSBT signing failed`, making it difficult to mine. This is no longer the case.

ACKs for top commit:
  achow101:
    ACK 6ee32aaaca
  theStack:
    re-ACK 6ee32aaaca
  danielabrozzoni:
    ACK 6ee32aaaca

Tree-SHA512: e47fbf471f2909286a6c1c073799ea388b9c19551afcce96cf9af45cc48d25c02f1e48e08861a88b604361e2c107a759d5baf393da8a37360de419f31651758a
2025-06-02 15:24:34 -07:00
Ava Chow f999c3775c
Merge bitcoin/bitcoin#32449: wallet: init, don't error out when loading legacy wallets
86e1111239 test: verify node skips loading legacy wallets during startup (furszy)
9f94de5bb5 wallet: init, don't error out when loading legacy wallets (furszy)

Pull request description:

  Instead of failing during initialization and shutting down the app when encountering a legacy wallet, skip loading the wallet and notify the user accordingly.

  This allows users to access migration functionalities without needing to manually remove the wallet from settings.json or resort to using the bitcoin-wallet utility.

  This means that GUI users will be able to use the migration button, and bitcoin-cli users will be able to call the migratewallet RPC directly after init.

ACKs for top commit:
  achow101:
    ACK 86e1111239
  w0xlt:
    ACK 86e1111239

Tree-SHA512: 85d594a503ee7a833a23754b71b6ba4869ca34ed802c9ac0cd7b2fa56978f5fcad84ee4bd3acdcc61cf8e7f08f0789336febc5d76beae1eebf7bd51462512b78
2025-06-02 13:31:35 -07:00
Ava Chow 6135e0553e wallet, rpc: Move (Un)LockCoin WalletBatch creation out of RPC
If the locked coin needs to be persisted to the wallet database,
insteead of having the RPC figure out when to create a WalletBatch and
having LockCoin's behavior depend on it, have LockCoin take whether to
persist as a parameter so it makes the batch.

Since unlocking a persisted locked coin requires a database write as
well, we need to track whether the locked coin was persisted to the
wallet database so that it can erase the locked coin when necessary.

Keeping track of whether a locked coin was persisted is also useful
information for future PRs.
2025-06-02 13:14:19 -07:00
Ava Chow 0def84d407 test: Verify parent_desc in RPCs
getaddressinfo, listunspent, listtransactions, listsinceblock, and
gettransaction all include parent_desc(s). Make sure that these are
consistent with each other, as well as being in normalized form.
2025-06-02 12:51:16 -07:00
benthecarman f98e1aaf34
rpc: Note in fundrawtransaction doc, fee rate is for package 2025-06-02 11:18:24 -05:00
Ryan Ofsky db225cea56 wallet, refactor: Replace GetDisplayName() with LogName()
The GetDisplayName() method name was confusing because it suggested the return
value could be used for display, while documentation and implementation
indicated it only meant to be used for logging. Also the name didn't suggest
that it was formatting the wallet names, which made it harder understand how
messages were formatted in the places it was called. Fix these issues by
splitting up the GetDisplayName() method and replacing it with LogName() /
DisplayName() methods.

This commit is a refactoring that does not change any behavior.
2025-06-02 08:46:03 -05:00
merge-script 1c6602399b
Merge bitcoin/bitcoin#32662: doc: Remove build instruction for running `clang-tidy`
4b1b36acb4 doc: Remove build instruction for running `clang-tidy` (Hennadii Stepanov)

Pull request description:

  One of the benefits of using a compilation database, which is available after the CMake build system generation step, is that it is not necessary to actually build the code in order to run `clang-tidy`.

ACKs for top commit:
  TheCharlatan:
    ACK 4b1b36acb4
  janb84:
    ACK 4b1b36acb4

Tree-SHA512: cf28fb1bcff83016b927522f1c719f3b91df7d107a310250c550308c8544b212fa6d2e8a5502d69fa424421acdf952469edd67504ac2a8465a2c1520593a1f26
2025-06-02 14:46:03 +01:00
Ryan Ofsky 01737883b3 wallet: Translate [default wallet] string in progress messages
Noticed while reviewing #31287
(https://github.com/bitcoin/bitcoin/pull/31287#discussion_r1843809721) that the
[default wallet] part of progress messages remains untranslated while the rest
of the string is translated. Fix this in all places where Wallet::ShowProgress
(which has a cancel button) and chain::showProgress (which doesn't have a
cancel button) are called by making "default wallet" into a translated string.

To minimize scope of this bugfix, this introduces a new wallet DisplayName()
method which behaves differently than the existing GetDisplayName() method. The
existing method will be cleaned up in the following commit.
2025-06-02 08:46:03 -05:00
Hennadii Stepanov 4b1b36acb4
doc: Remove build instruction for running `clang-tidy`
One of the benefits of using a compilation database, which is available
after the CMake build system generation step, is that it is not
necessary to actually build the code in order to run `clang-tidy`.
2025-06-02 13:49:19 +01:00
merge-script 9e105107bf
Merge bitcoin/bitcoin#32656: depends: don't install & then delete sqlite pkgconf
72a5aa9b79 depends: don't install & then delete sqlite pkgconf (fanquake)

Pull request description:

ACKs for top commit:
  stickies-v:
    ACK 72a5aa9b79
  hebasto:
    ACK 72a5aa9b79.

Tree-SHA512: d70b024ca68294ab79e5f9aa15ab8a17eca83f65713d5de3b421e868b0f24c26a459a6240d348438fd4706a9f46e96ab4979e952099d5f2a9bc00e8e1a7b558f
2025-06-02 12:34:51 +01:00
fanquake 72a5aa9b79
depends: don't install & then delete sqlite pkgconf 2025-06-01 12:40:45 +01:00
Hennadii Stepanov 18cf727429
cmake: Replace deprecated `qt6_add_translation` with `qt6_add_lrelease`
See Qt docs:
- https://doc.qt.io/archives/qt-6.2/qtlinguist-cmake-qt-add-translation.html
- https://doc.qt.io/archives/qt-6.2/qtlinguist-cmake-qt-add-lrelease.html
2025-05-31 08:29:09 +01:00
fanquake 83bfe1485c
build: add -Wthread-safety-pointer
This will become available in Clang 21:

> ThreadSafetyAnalysis now supports -Wthread-safety-pointer, which
> enables warning on passing or returning pointers to guarded variables
> as function arguments or return value respectively. Note that
> ThreadSafetyAnalysis still does not perform alias analysis. The
> feature will be default-enabled with -Wthread-safety in a future release.

See
https://github.com/llvm/llvm-project/blob/main/clang/docs/ReleaseNotes.rst.
2025-05-30 16:54:46 +01:00
fanquake e639ae0531
Update leveldb subtree to latest upstream 2025-05-30 16:51:49 +01:00
fanquake 240a4fb95d Squashed 'src/leveldb/' changes from 113db4962b..aba469ad6a
aba469ad6a Merge bitcoin-core/leveldb-subtree#54: Fix clang thread-safety-pointer warnings
7daf4ed575 Fix clang thread-safety-pointer warnings

git-subtree-dir: src/leveldb
git-subtree-split: aba469ad6a808da8381edf83a99e5ece18958b31
2025-05-30 16:51:49 +01:00
Greg Sanders a189d63618 add release note for datacarriersize default change 2025-05-30 10:14:18 -04:00
Peter Todd a141e1bf50 Add more OP_RETURN mempool acceptance functional tests
Credit: Sjors Provoost and Antoine Poinsot
2025-05-30 10:14:18 -04:00
Greg Sanders 0b4048c733 datacarrier: deprecate startup arguments for future removal 2025-05-30 10:14:18 -04:00
Greg Sanders 63091b79e7 test: remove unnecessary -datacarriersize args from tests 2025-05-30 10:14:18 -04:00
Greg Sanders 9f36962b07 policy: uncap datacarrier by default
Datacarrier output script sizes and output counts are now
uncapped by default.

To avoid introducing another startup argument, we modify the
OP_RETURN accounting to "budget" the spk sizes.

If a user has set a custom default, this results in that
budget being spent over the sum of all OP_RETURN outputs'
scripts in the transaction, no longer capping the number
of OP_RETURN outputs themselves. This should allow a
superset of current behavior while respecting the passed
argument in terms of total arbitrary data storage.

Co-authored-by: Anthony Towns <aj@erisian.com.au>
2025-05-30 10:12:38 -04:00
merge-script 4b1d48a686
Merge bitcoin/bitcoin#32598: walletdb: Log additional exception error messages for corrupted wallets
ad9a13fc42 walletdb: Log additional exception error messages for corrupted wallets (Ava Chow)

Pull request description:

  Many exceptions thrown for corruption are `std::runtime_error`; we should catch those and log the message to help with debugging.

  Split from #32489

ACKs for top commit:
  davidgumberg:
    ACK ad9a13fc42
  furszy:
    ACK ad9a13fc42
  rkrux:
    ACK ad9a13fc42
  Sjors:
    utACK ad9a13fc42

Tree-SHA512: 107b938d67346804733ea27c44ed38822db0e020e5b1ac889ee35280d812ec56dcc9af7b3eab7a521d72cdd9cb4a8d6d35f3a3dfbcb2a6fd170a981f34fbdfc2
2025-05-30 11:33:24 +01:00
merge-script b933813386
Merge bitcoin/bitcoin#32619: wallet, rpc, gui: List legacy wallets with a message about migration
f3a444c45f gui: Disallow loading legacy wallets (Ava Chow)
09955172f3 wallet, rpc: Give warning in listwalletdir for legacy wallets (Ava Chow)

Pull request description:

  A new field `warnings` is added for each wallet in `listwalletdir`. If a legacy wallet is detected, the warning will contain a message that the wallet is a legacy wallet and will need to be migrated before it can be loaded.

  In the GUI, the "Open Wallet" menu is changed to show legacy wallets greyed out with "(needs migration)" appended to their name to indicate to the user that the legacy wallet will need to be migrated.

ACKs for top commit:
  maflcko:
    lgtm ACK f3a444c45f
  adyshimony:
    Test ACK [f3a444c](f3a444c45f)
  furszy:
    Code review ACK f3a444c45f
  w0xlt:
    Code Review ACK f3a444c45f

Tree-SHA512: 496caec0ca37845487bd709e592240315eb23461fbd697e68a7fde8e4d9b74b48aab1212c88dbbcc8a107a896b824c2e1f69691068641812ae903f873fa2f22b
2025-05-30 11:17:40 +01:00
merge-script 053bda5d9f
Merge bitcoin/bitcoin#32460: fs: remove `_POSIX_C_SOURCE` defining
24e5fd3bed fs: remove _POSIX_C_SOURCE defining (fanquake)

Pull request description:

  On Linux systems, `_POSIX_C_SOURCE` will default to `200809L` (since glibc 2.10). There's currently no reason for us to undefine it, and then set it to an earlier value. Also tested with musl libc.

  I think if anything, the project should be settings macros like `_POSIX_C_SOURCE`, globally.

ACKs for top commit:
  hebasto:
    re-ACK 24e5fd3bed, only rebased since my recent [review](https://github.com/bitcoin/bitcoin/pull/32460#pullrequestreview-2854183748).

Tree-SHA512: 920d60058821992193616e0c73c2f7e4230a9e3ccb9d71d16493ae69696c868f4325d3dd2d4e8388749080c187aa7b205493b3e2c6986ad37440e591ebe107e1
2025-05-30 10:21:01 +01:00
merge-script 9393aeeca4
Merge bitcoin/bitcoin#32641: Update libmultiprocess subtree to fix clang-tidy errors
154af1eea1 Squashed 'src/ipc/libmultiprocess/' changes from 35944ffd23fa..27c7e8e5a581 (Ryan Ofsky)

Pull request description:

  Includes:

  - https://github.com/bitcoin-core/libmultiprocess/pull/165
  - https://github.com/bitcoin-core/libmultiprocess/pull/173
  - https://github.com/bitcoin-core/libmultiprocess/pull/172

  These changes are needed to fix CI errors in #31802.

  The changes can be verified by running `test/lint/git-subtree-check.sh src/ipc/libmultiprocess` as described in [developer notes](https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#subtrees) and [lint instructions](https://github.com/bitcoin/bitcoin/tree/master/test/lint#git-subtree-checksh)

ACKs for top commit:
  Sjors:
    ACK 9f6565488f
  TheCharlatan:
    ACK 9f6565488f

Tree-SHA512: 745789a6fba552aa066f9f69592b16a5277999dbf0413eaed7fe25cd440b78af57615edfce781592873659fda91463bef7c5dac202b80362bd86f6a90ab20d69
2025-05-30 10:12:51 +01:00
Sebastian Falbesoner b184f5c87c test: update BIP340 test vectors and implementation (variable-length messages)
See https://github.com/bitcoin/bips/pull/1446,
commit 200f9b26fe0a2f235a2af8b30c4be9f12f6bc9cb
2025-05-30 01:47:09 +02:00
Ava Chow 5471e29d05
Merge bitcoin/bitcoin#32304: test: test MAX_SCRIPT_SIZE for block validity
b1ea542ae6 test: test MAX_SCRIPT_SIZE for block validity (Greg Sanders)

Pull request description:

  I don't believe there are direct tests for this.

ACKs for top commit:
  achow101:
    ACK b1ea542ae6
  TheCharlatan:
    ACK b1ea542ae6
  theStack:
    ACK b1ea542ae6

Tree-SHA512: 1d7d3eab9c54977844bf2ca1aa403b070aae0f818db2fb5cae367d1c4d12f1e403b6fdec224af769a2ebb648cbca8bfd0d7df5db2a89fccf256c9c244484eba2
2025-05-29 14:32:10 -07:00
Ryan Ofsky 154af1eea1 Squashed 'src/ipc/libmultiprocess/' changes from 35944ffd23fa..27c7e8e5a581
27c7e8e5a581 Merge chaincodelabs/libmultiprocess#172: refactor: fix warnings from clang-tidy-20 and bitcoin-tidy
2fe87d016be4 Merge chaincodelabs/libmultiprocess#173: doc: Fix error string typo
57a65b854664 clang-tidy: Suppress bitcoin-nontrivial-threadlocal error
0d8012f656fe Merge chaincodelabs/libmultiprocess#165: clang-tidy: fix warnings introduced in version 19
3a96cdc18f2d clang-tidy: Fix bugprone-move-forwarding-reference error
c1e8c1a02864 clang-tidy: Fix bugprone-move-forwarding-reference errors
aa19285303ff use ranges transform
a78137ca73b8 make member function const
ca3226ec8ab7 replace custom tuple unpacking code with `std::apply`
949fe85fc91f replace SFINAE trick with `if constexpr`
44ee4b40b89a doc: Fix error string typo

git-subtree-dir: src/ipc/libmultiprocess
git-subtree-split: 27c7e8e5a581b3c41330e758951251ef11807b11
2025-05-29 13:57:08 -04:00
Ryan Ofsky 9f6565488f Merge commit '154af1eea1170f5626aa1c5f19cc77d1434bcc9d' into HEAD 2025-05-29 13:57:08 -04:00
Ryan Ofsky c810b168b8 doc: Add description of installed files to files.md 2025-05-29 08:51:08 -04:00
merge-script c540ede1cb
Merge bitcoin/bitcoin#32633: windows: Use predefined `RC_INVOKED` macro instead of custom one
55f1c2ac8b windows: Use predefined `RC_INVOKED` macro instead of custom one (Hennadii Stepanov)

Pull request description:

  See: https://learn.microsoft.com/en-us/windows/win32/menurc/predefined-macros.

ACKs for top commit:
  hodlinator:
    re-ACK 55f1c2ac8b
  fanquake:
    ACK 55f1c2ac8b

Tree-SHA512: cf18e03d0c2b1cd590e379707fc6d1775f08814f20aa51c0c40b9eac6227f42a6e07ba3e478da7d511ace29782bf964eae3edfeb04bcb1f87596966bdd3a55c9
2025-05-29 13:51:08 +01:00
Ryan Ofsky 94ffd01a02 doc: Add release notes describing libexec/ binaries 2025-05-29 08:51:08 -04:00
Ryan Ofsky cd97905ebc cmake: Move internal binaries from bin/ to libexec/
This change moves binaries that are not typically invoked directly by users
from the `bin/` directory to the `libexec/` directory in CMake installs and
binary releases. The goal is to simplify the contents of `bin/` for end users
while still making all binaries available when needed. After this change, the
binaries remaining in `bin/` are:

- bitcoin
- bitcoin-cli
- bitcoind
- bitcoin-qt
- bitcoin-tx
- bitcoin-util
- bitcoin-wallet

And the binaries that are moved to `libexec/` are:

- bench_bitcoin
- bitcoin-chainstate(*)
- bitcoin-gui(***)
- bitcoin-node(***)
- test_bitcoin(**)
- test_bitcoin-qt

(*) bitcoin-chainstate was previously missing an install rule and was actually
not installed even when it was enabled.

(**) test_bitcoin is the only libexec/ binary that is currently included in
bitcoin binary releases. The others are only installed when building from
source with relevant cmake options enabled.

(***) bitcoin-node and bitcoin-gui are not currently built by default or
included in binary releases but both of these changes are planned and
implemented in #31802
2025-05-29 07:51:08 -05:00
Antoine Poinsot cfc42ae5b7 fuzz: add a target for the coins database
It reuses the logic from the `coins_view` target, except it uses an
in-memory CCoinsViewDB as the backend.

Note `CCoinsViewDB` will assert the best block hash is never null, so we
slightly modify the coins_view fuzz logic to take care of this.
2025-05-29 12:14:13 +01:00
Hennadii Stepanov 55f1c2ac8b
windows: Use predefined `RC_INVOKED` macro instead of custom one 2025-05-29 11:18:36 +01:00
merge-script 14c16e8159
Merge bitcoin/bitcoin#32582: log: Additional compact block logging
83df64d749 log: Stats when fulfilling GETBLOCKTXN (David Gumberg)
3733ed2dae log: Size of missing tx'es when reconstructing compact block (David Gumberg)
36bcee05dc log: Log start of compact block initialization. (David Gumberg)

Pull request description:

  This PR adds some additional logging to help measure performance of compact block reconstruction.

  1. Adds a message to the beginning of `PartiallyDownloadedBlock::InitData()` so that that the logs indicate the amount of time it takes to populate a compact block from mempool transactions.
  2. Logs the size of the transactions which a node did not have in its mempool and was forced to request.
  3. Logs the size and number of transactions that a node sends to it's peer in a `BLOCKTXN` to fulfill a compact block `GETBLOCKTXN` request.

  Relevant to this discussion on delving bitcoin: https://delvingbitcoin.org/t/stats-on-compact-block-reconstructions/1052

ACKs for top commit:
  instagibbs:
    reACK 83df64d749
  w0xlt:
    reACK 83df64d749
  1440000bytes:
    ACK 83df64d749

Tree-SHA512: 92c3c7d55005dd47dad90ddb54e4127482260cea5390f7696e8b3b9defb337f5fb09166af6b12eb2ab8151d04dae08b0a570e3509a86509b0ab3151d84387e06
2025-05-29 10:58:19 +01:00
merge-script aad5938c49
Merge bitcoin/bitcoin#32516: test: add MAX_DISCONNECTED_TX_POOL_BYTES, chainlimits coverage
84aa484d45 test: fix transaction_graph_test reorg test (Greg Sanders)
eaf44f3767 test: check chainlimits respects on reorg (Greg Sanders)
47894367b5 functional test: add MAX_DISCONNECTED_TX_POOL_BYTES coverage (Greg Sanders)

Pull request description:

  `DisconnectedBlockTransactions::LimitMemoryUsage()` has unit test coverage, but the default value end to end doesn't have coverage.

  This test adds exercised coverage of memory limiting of the disconnect pool, and some basic behavior sanity checks.

  Another test added is making sure chainlimits are being respected on reorg, and the expected transactions pruned.

  Lastly, fix the existing test case which was using a deficient test via directly inducing reorgs with `invalidateblock`

ACKs for top commit:
  maflcko:
    re-ACK 84aa484d45 🚋
  TheCharlatan:
    ACK 84aa484d45

Tree-SHA512: f5cdb9647fadc8eb30352ce38de44064103825e5358787dfccd6416fa8faf6ceea42552fe2250b37d56271a6c3898b3912e1c028652da122f5c99304aafddb64
2025-05-29 10:50:48 +01:00
merge-script 1062df81ee
Merge bitcoin/bitcoin#32634: build: Add resource file and manifest to `bitcoin.exe`
dbb2d4c3d5 windows: Add application manifest to `bitcoin.exe` (Hennadii Stepanov)
df82c2dc17 windows: Add resource file for `bitcoin.exe` (Hennadii Stepanov)

Pull request description:

  This PR is a follow up to https://github.com/bitcoin/bitcoin/pull/31375, which:
  1. Adds a resource file for `bitcoin.exe` for consistency with other Windows executables.
  2. Adds an application manifest to `bitcoin.exe`, which has been required for release binaries since https://github.com/bitcoin/bitcoin/pull/32396.

ACKs for top commit:
  davidgumberg:
    ACK dbb2d4c3d5
  hodlinator:
    ACK dbb2d4c3d5

Tree-SHA512: 853c9e578bfd74bfd2e1f0fa39f978638723c8e061456caa165fca6f10497517f9503ae12dfb88e7229a02de593ccf22126f3362ca0d75c74becbb727e80c9ad
2025-05-29 10:42:11 +01:00
furszy b789907346
wallet: migration, avoid creating spendable wallet from a watch-only legacy wallet
Currently, the migration process creates a brand-new descriptor wallet with no
connection to the user's legacy wallet when the legacy wallet lacks key material
and contains only watch-only scripts. This behavior is not aligned with user
expectations. If the legacy wallet contains only watch-only scripts, the migration
process should only generate a watch-only wallet instead.
2025-05-29 01:46:26 -04:00
David Gumberg 83df64d749 log: Stats when fulfilling GETBLOCKTXN 2025-05-28 13:32:48 -07:00
Ava Chow 370c592612
Merge bitcoin/bitcoin#32630: test: fix sync function in rpc_psbt.py
4df4df45d7 test: fix sync function in rpc_psbt.py (Martin Zumsande)

Pull request description:

  Even though the block is created on `node2`, the sync is only between `node1` and `node0`. Accordingly the test fails if I put a sleep in `msg_type == NetMsgType::HEADERS` processing: In this case, `node1` and `node0` do not hear about the new  block, the sync still passes because they are in sync with each other, and later on in the `test_input_confs_control` subtest, `node1` would generate a forked block instead of building on the previous one, leading to test failure.

  Haven't seen this in the CI, but I ran into it on an experimental branch.

ACKs for top commit:
  maflcko:
    lgtm ACK 4df4df45d7
  achow101:
    ACK 4df4df45d7

Tree-SHA512: 1211ba0ad263ebcd0aa6ef7c856dec7ec6ca6010e1df705e7243f6c9d950ccca6df1275c36a73a83034f49ea8401e8f9800c05cdb74c39e860e7ebcaf2ce6ada
2025-05-28 12:44:51 -07:00
Hennadii Stepanov dbb2d4c3d5
windows: Add application manifest to `bitcoin.exe` 2025-05-28 20:22:00 +01:00
Hennadii Stepanov df82c2dc17
windows: Add resource file for `bitcoin.exe` 2025-05-28 20:20:54 +01:00
David Gumberg 3733ed2dae log: Size of missing tx'es when reconstructing compact block 2025-05-28 11:46:30 -07:00
Martin Zumsande 4df4df45d7 test: fix sync function in rpc_psbt.py
It currently only syncs between the first two nodes,
which may do nothing when the block is created on the
third node.
2025-05-28 11:01:47 -04:00
furszy e86d71b749
wallet: refactor, dedup wallet re-loading code 2025-05-28 06:33:00 -04:00
furszy 1de423e0a0
wallet: introduce method to return all db created files 2025-05-28 05:55:27 -04:00
furszy d04f6a97ba
refactor: remove sqlite dir path back-and-forth conversion 2025-05-28 05:52:41 -04:00
Ava Chow 88b22acc3d
Merge bitcoin/bitcoin#32528: rpc: Round verificationprogress to 1 for a recent tip
fab1e02086 refactor: Pass verification_progress into block tip notifications (MarcoFalke)
fa76b378e4 rpc: Round verificationprogress to exactly 1 for a recent tip (MarcoFalke)
faf6304bdf test: Use mockable time in GuessVerificationProgress (MarcoFalke)

Pull request description:

  Some users really seem to care about this. While it shouldn't matter much, the diff is so trivial that it is probably worth doing.

  Fixes #31127

  One could also consider to split the field into two dedicated ones (https://github.com/bitcoin/bitcoin/issues/28847#issuecomment-1807115357), but this is left for a more involved follow-up and may also be controversial.

ACKs for top commit:
  achow101:
    ACK fab1e02086
  pinheadmz:
    ACK fab1e02086
  sipa:
    utACK fab1e02086

Tree-SHA512: a3c24e3c446d38fbad9399c1e7f1ffa7904490a3a7d12623b44e583b435cc8b5f1ba83b84d29c7ffaf22028bc909c7cec07202b825480449c6419d2a190938f5
2025-05-27 16:45:23 -07:00
Ava Chow aee7cec0db
Merge bitcoin/bitcoin#32364: refactor: validation: mark CheckBlockIndex as const
3e6ac5bf77 refactor: validation: mark CheckBlockIndex as const (stickies-v)
61a51eccbb validation: don't use GetAll() in CheckBlockIndex() (stickies-v)
d05481df64 refactor: validation: mark SnapshotBase as const (stickies-v)

Pull request description:

  While reviewing another PR, I [noticed](https://github.com/bitcoin/bitcoin/pull/31405#discussion_r2056509235) that `ChainstateManager::CheckBlockIndex()`  is not a `const` method. To try and assert that this method was not causing any side-effects, I modified the method to make it `const`. It did not surface any errors, but I think it would be good to merge this change regardless, even if `CheckBlockIndex` is only used in regtest.

  This PR removes `CheckBlockIndex()`'s calls to non-const `ChainstateManager` methods by marking `SnapshotBase` `const` and ~inlining the `GetAll()` calls (thereby also performing consistency checks on invalid or fully validated `m_disabled==true` chainstates, as slight behaviour change), and finally marks `CheckBlockIndex()` as `const`.

ACKs for top commit:
  achow101:
    ACK 3e6ac5bf77
  mzumsande:
    Code Review ACK 3e6ac5bf77
  TheCharlatan:
    ACK 3e6ac5bf77

Tree-SHA512: 3d3cd351f5af1fab9a9498218ec62dba6e397fc7b5f4868ae0a77dc2b7c813d12c4f53f253f209101a3f6523695014e20c82dfac27cf0035611d5dd29feb80b5
2025-05-27 15:33:09 -07:00
Ava Chow ce46000712
Merge bitcoin/bitcoin#32509: qa: feature_framework_startup_failures.py fixes & improvements (#30660 follow-up)
bf950c4544 qa: Improve suppressed errors output (Hodlinator)
075352ec8e qa: assert_raises_message() - search in str(e) (Hodlinator)
bd8ebbc4ab qa: Make --timeout-factor=0 result in a smaller factor (Hodlinator)
d8f05e7bf3 qa: Fix dormant bug caused by multiple --tmpdir (Hodlinator)

Pull request description:

  * Handle multiple `--tmpdir` args properly.
  * Handle `--timeout-factor=0` properly (fixes #32506).
  * Improve readability of expected error message (`assert_raises_message()`).
  * Make suppressed error output less confusing (`wait_for_rpc_connection()`).

ACKs for top commit:
  i-am-yuvi:
    re-ACK bf950c4544
  ismaelsadeeq:
    Code review and tested ACK bf950c45
  achow101:
    ACK bf950c4544
  janb84:
    LGTM ACK bf950c4544

Tree-SHA512: 8993f53e962231adef9cad92594dc6a8b8e979b1571d1381cd0fffa1929833b2163c68c03b6a6e29995006a3c3121822ec25ac7725e71ccdab8876ac24aae86c
2025-05-27 14:45:11 -07:00
Ava Chow d21612fc4b
Merge bitcoin/bitcoin#32404: log: print reason when writing chainstate
53e9b71b2f log: print reason for why should_write was triggered in `FlushStateToDisk` (Lőrinc)

Pull request description:

  This PR addresses a leftover logging nit found while reviewing https://github.com/bitcoin/bitcoin/pull/30611#pullrequestreview-2809508852.
  This was also needed to validate its behavior properly, because currently there's no way to visualize how often (and why) we're flushing/syncing.

  Starting with `-debug=coindb` will now add log lines such as
  ```
  2025-05-03T08:34:57Z [coindb] Writing chainstate to disk: flush mode=PERIODIC, prune=0, large=0, critical=0, periodic=1
  2025-05-03T09:26:52Z [coindb] Writing chainstate to disk: flush mode=PERIODIC, prune=0, large=0, critical=0, periodic=1
  2025-05-03T10:27:58Z [coindb] Writing chainstate to disk: flush mode=PERIODIC, prune=0, large=0, critical=0, periodic=1
  2025-05-03T11:39:20Z [coindb] Writing chainstate to disk: flush mode=PERIODIC, prune=0, large=0, critical=0, periodic=1
  2025-05-03T12:41:48Z [coindb] Writing chainstate to disk: flush mode=PERIODIC, prune=0, large=0, critical=0, periodic=1
  2025-05-03T13:40:08Z [coindb] Writing chainstate to disk: flush mode=PERIODIC, prune=0, large=0, critical=0, periodic=1
  2025-05-03T14:49:16Z [coindb] Writing chainstate to disk: flush mode=PERIODIC, prune=0, large=0, critical=0, periodic=1
  2025-05-03T15:14:37Z [coindb] Writing chainstate to disk: flush mode=ALWAYS, prune=0, large=0, critical=0, periodic=0
  2025-05-03T15:17:28Z [coindb] Writing chainstate to disk: flush mode=ALWAYS, prune=0, large=0, critical=0, periodic=0
  ```

ACKs for top commit:
  davidgumberg:
    ACK 53e9b71b2f
  jonatack:
    diff-only review ACK 53e9b71b2f per `git range-diff 2df824 cfc8056 53e9b71`
  achow101:
    ACK 53e9b71b2f
  andrewtoth:
    utACK 53e9b71b2f

Tree-SHA512: 09f3a38cf3ecaa32cf3aba350a9e9dff9345c5468a05070c8b20987f0fdb23a8b1dc59370829c64ea356d2fc0ce99a66cc7240de7fa8c19ef3133da06db6bf3d
2025-05-27 14:30:34 -07:00
Greg Sanders 84aa484d45 test: fix transaction_graph_test reorg test
The current test directly uses invalidatblock to trigger
mempool re-entry of transactions. Unfortunately, the
behavior doesn't match what a real reorg would look like. As
a result you get surprising behavior such as the mempool
descendant chain limits being exceeded, or if a fork is
greater than 10 blocks deep, evicted block transactions stop
being submitted back into in the mempool.

Fix this by preparing an empty fork chain, and then
continuing with the logic, finally submitting the fork chain
once the rest of the test is prepared. This triggers a more
typical codepath.

Also, extend the descendant limit to 100, like ancestor
limit.
2025-05-27 17:08:15 -04:00
Greg Sanders eaf44f3767 test: check chainlimits respects on reorg 2025-05-27 17:02:42 -04:00
Greg Sanders 47894367b5 functional test: add MAX_DISCONNECTED_TX_POOL_BYTES coverage 2025-05-27 17:02:02 -04:00
Ava Chow 9bd9aee5a6
Merge bitcoin/bitcoin#32487: blocks: avoid recomputing block header hash in `ReadBlock`
09ee8b7f27 node: avoid recomputing block hash in `ReadBlock` (Lőrinc)
2bf173210f test: exercise `ReadBlock` hash‑mismatch path (Lőrinc)

Pull request description:

  Eliminate one block header hash calculation per block-read by reusing the hash for:
  * proof‑of‑work verification;
  * (optional) integrity check against the supplied hash.

  This part of the code wasn't covered by tests either, so the first commit exercises this part first, before pushing the validation to the delegate method.

ACKs for top commit:
  maflcko:
    lgtm ACK 09ee8b7f27
  achow101:
    ACK 09ee8b7f27
  jonatack:
    ACK 09ee8b7f27
  pinheadmz:
    ACK 09ee8b7f27

Tree-SHA512: 43fe51b478ea574b6d4c952684b13ca54fb8cbd67c3b6c136f460122d9ee953cc70b88778537117eecea71ccb8d88311faeac21b866e11d117f1145973204ed4
2025-05-27 13:02:27 -07:00
Ava Chow 4173805a15
Merge bitcoin/bitcoin#32623: test: Add missing ipc subtree to lint
fa4b8b16c3 test: Add missing ipc subtree to lint (MarcoFalke)

Pull request description:

  The subtree docs and lint checks list the subtrees in three places, making it hard to follow and update and easy to miss one.

  Fix all issues by including the missing one and removing the list in one place.

ACKs for top commit:
  l0rinc:
    ACK fa4b8b16c3
  davidgumberg:
    ACK fa4b8b16c3
  achow101:
    ACK fa4b8b16c3
  hebasto:
    re-ACK fa4b8b16c3, only a [comment](https://github.com/bitcoin/bitcoin/pull/32623#discussion_r2109243775) has been addressed since my recent [review](https://github.com/bitcoin/bitcoin/pull/32623#pullrequestreview-2871162934).
  BrandonOdiwuor:
    Re-ACK fa4b8b16c3

Tree-SHA512: 97a39cf63be2707b2e03502546797ef639a611030e0a860618256c7c0683381be0f05c8bf850f9542a25266a52f58cef690abf9cc243498b6e026c7a6f9a52b2
2025-05-27 12:47:55 -07:00
Ava Chow 012f347685
Merge bitcoin/bitcoin#31375: multiprocess: Add bitcoin wrapper executable
a5ac43d98d doc: Add release notes describing bitcoin wrapper executable (Ryan Ofsky)
258bda80c0 doc: Mention bitcoin wrapper executable in documentation (Ryan Ofsky)
d2739d75c9 build: add bitcoin.exe to windows installer (Sjors Provoost)
ba649c0006 ci: Run multiprocess tests through wrapper executable (Ryan Ofsky)
29bdd743bb test: Support BITCOIN_CMD environment variable (Ryan Ofsky)
9c8c68891b multiprocess: Add bitcoin wrapper executable (Ryan Ofsky)
5076d20fdb util: Add cross-platform ExecVp and GetExePath functions (Ryan Ofsky)

Pull request description:

  Intended to make bitcoin command line features more discoverable and allow installing new multiprocess binaries in libexec/ instead of bin/ so they don't cause confusion.

  Idea and implementation of this were discussed in https://github.com/bitcoin/bitcoin/issues/30983.

  ---

  Initial implementation of this feature is deliberately minimal so the UX can evolve in response to feedback and there are not too many details to debate and discuss in a single PR. But many improvements are possible or planned:

  - Adding manpage and bash completions.
  - Showing nicer error messages that detect if an executable isn't installed and suggest how to fix [(comment)](https://github.com/bitcoin/bitcoin/pull/31375#discussion_r2073194474)
  - Showing wrapper command lines in subcommand in help output [(comment)](https://github.com/bitcoin/bitcoin/pull/31375#discussion_r2077800405). This could be done conditionally as suggested in the comment or be unconditional.
  - Showing wrapper command lines in subcommand error output. There is a bitcoin-cli error pointed out in [(comment)](https://github.com/bitcoin/bitcoin/pull/31375#discussion_r2091152243) that is needlessly confusing.
  - Integrating help so `bitcoin help subcommand` invokes `bitcoin subcommand -h`. `bitcoin -h subcommand` should also be supported and be equivalent [(comment)](https://github.com/bitcoin/bitcoin/pull/31375#discussion_r2093116725)
  - Adding support for `bitcoin-util` subcommands. Ideal interface would probably be more like `bitcoin grind` not `bitcoin util grind` but this has been punted for now. Supporting subcommands directly would require some ArgsManager modifications
  - Adding a dedicated python functional test for the wrapper. Right now there is some CI coverage by setting the `BITCOIN_CMD` variable, but this doesn't cover things like the help output and version output, and support for different directory layouts.
  - Better `--multiprocess` (`-m`) / `--monolithic` (`-M`) default selection. Right now, default is monolithic but it probably makes sense to chose more intelligently depending on whether -ipc options are enabled and what binaries are available.
  - Maybe parsing `bitcoin.conf` and supporting options to control wrapper behavior like custom locations or preferences or aliases.
  - Better command command line usability. Allow combining short options like (`-ah`). Allow fuzzy matching of subcommands or suggestions if you misspell. (suggested by stickies in review club)
  - Not directly related to this PR but `bitcoin-cli named` implementation used by the wrapper should do a better job disambiguating named arguments from base64 arguments ending in = as pointed out in [(comment)](https://github.com/bitcoin/bitcoin/pull/31375#discussion_r2091886628)

  ---

  This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/issues/28722). A review club meeting for it took place in https://bitcoincore.reviews/31375

ACKs for top commit:
  Sjors:
    utACK a5ac43d98d
  achow101:
    ACK a5ac43d98d
  vasild:
    ACK a5ac43d98d
  theStack:
    ACK a5ac43d98d
  ismaelsadeeq:
    fwiw my last review implied an ACK a5ac43d98d
  hodlinator:
    ACK a5ac43d98d

Tree-SHA512: 570e6a4ff8bd79ef6554da3d01f36c0a7c6d2dd7dace8f8732eca98f4a8bc2284474a9beadeba783114fe2f3dd08b2041b3da7753bae0b7f881ec50668cb821f
2025-05-27 12:38:19 -07:00
Ava Chow 2554cee988 test: Enable default wallet for wallet_descriptor.py 2025-05-27 11:13:44 -07:00
Ava Chow 3fc9d9f241 wallet, rpc: Push the normalized parent descriptor
Instead of providing the descriptor string as stored in the db, use the
normalized descriptor as is done for getaddressinfo's parent_desc field.
2025-05-27 11:13:42 -07:00
merge-script 38ad8027a2
Merge bitcoin/bitcoin#32439: guix: accomodate migration to codeberg
c8d9baae94 guix: accomodate migration to codeberg (fanquake)

Pull request description:

  See https://guix.gnu.org/blog/2025/migrating-to-codeberg/.

ACKs for top commit:
  maflcko:
    lgtm ACK c8d9baae94
  hebasto:
    ACK c8d9baae94.

Tree-SHA512: 6a2221faf49c84cd2a4027e4b721553d700a9af0736dbbea80aa94289ff7665e7f4681c12fa3b5195e21dc3ac91fb1796635f26c1298bb5da1dee5690697edd0
2025-05-27 18:08:51 +01:00
MarcoFalke fa4b8b16c3
test: Add missing ipc subtree to lint 2025-05-27 18:33:56 +02:00
merge-script f7cc7f6468
Merge bitcoin/bitcoin#32591: test: fix and augment block tests of invalid_txs
8fcd684505 test: ensure reason is checked for invalid blocks rejection (Greg Sanders)
1a689a2c88 test: fix block tests of invalid_txs (Greg Sanders)

Pull request description:

  We are not actually testing some cases accidentally, for block inclusion.

  Issue discovered while reviewing https://github.com/bitcoin/bitcoin/pull/32533

ACKs for top commit:
  maflcko:
    review ACK 8fcd684505 🔶
  theStack:
    ACK 8fcd684505
  BrandonOdiwuor:
    Code Review ACK 8fcd684505
  TheCharlatan:
    ACK 8fcd684505

Tree-SHA512: 7e79ea35b64f56b29811b29df5752945cb10ec62465b385be5e4e2d295c3237b15d5dacf9e99661346967e84899da6fc82e3d2bd0ef6e5c51da85247da31e26a
2025-05-27 14:25:31 +01:00
merge-script 87860143be
Merge bitcoin/bitcoin#32270: test: fix pushdata scripts
f66b14d2ec test: fix pushdata scripts (Greg Sanders)

Pull request description:

  The original scripts were done incorrectly,
  so they are changed to represent two
  different 2-byte pushes.

  Fixes https://github.com/bitcoin/bitcoin/pull/32114#discussion_r2034051063

ACKs for top commit:
  ajtowns:
    ACK f66b14d2ec
  TheCharlatan:
    Re-ACK f66b14d2ec

Tree-SHA512: 0956124ee0d2e8b6a594f9feeb47c1f598c68e24d277e874f81a093268113e9da2c75a02863dbaab68b962063f7d910bfd10abe3ad33ec182bc21d72908f06e6
2025-05-27 11:59:31 +01:00
fanquake c8d9baae94
guix: accomodate migration to codeberg
See https://guix.gnu.org/blog/2025/migrating-to-codeberg/.

When interacting with the old repo you may now also see:
```bash
warning: redirecting to https://codeberg.org/guix/guix/
```
2025-05-27 11:34:03 +01:00
Ava Chow f3a444c45f gui: Disallow loading legacy wallets
Instead of allowing users to load a legacy wallet from the "Open Wallet"
menu, show the legacy wallet greyed out with a message that the wallet
needs to be migrated.
2025-05-26 15:14:41 -07:00
Ava Chow 09955172f3 wallet, rpc: Give warning in listwalletdir for legacy wallets 2025-05-26 15:14:41 -07:00
Lőrinc 09ee8b7f27 node: avoid recomputing block hash in `ReadBlock`
Eliminate one SHA‑256 double‑hash computation of the header per block read by reusing the hash for:
* proof‑of‑work verification;
* (optional) integrity check against the supplied hash.
2025-05-26 23:23:44 +02:00
Lőrinc 2bf173210f test: exercise `ReadBlock` hash‑mismatch path
Ensure `ReadBlock` rejects a block when the tip’s `phashBlock` differs from the expected hash.
2025-05-26 23:11:54 +02:00
MarcoFalke fab1e02086
refactor: Pass verification_progress into block tip notifications
It is cheap to calculate and the caller does not have to take a lock to
calculate it.

Also turn pointers that can never be null into references.
2025-05-24 13:49:32 +02:00
Ava Chow 638a4c0bd8
Merge bitcoin/bitcoin#32596: wallet, rpc, doc: various legacy wallet removal cleanups in RPCs
e5cbea416b rpc: doc: remove redundant "descriptors" parameter in `createwallet` examples (Sebastian Falbesoner)
7a05f941bb rpc: doc: drop descriptor wallet mentions in fast wallet rescan related RPCs (Sebastian Falbesoner)
db465a50e2 wallet, rpc: remove obsolete "keypoololdest" result field/code (Sebastian Falbesoner)

Pull request description:

  This PR contains a few smaller wallet RPC cleanups based on that we only ever operate on descriptor wallets now:
  * remove the now obsolete "keypoololdest" field from the `getwalletinfo` RPC and the corresponding CWallet/ScriptPubKeyMan methods
  * in RPCs where potential fast wallet rescan is documented, remove the "descriptor wallet" mentions (back then introduced in commit ca48a4694f, PR #25957)
  * for the `createwallet` RPC examples, remove the "descriptors" parameters that always have to be true now (proposed in https://github.com/bitcoin/bitcoin/pull/31250#discussion_r2042020967; corresponds to 86de8c1668, PR #32544 which did the same for functional tests)

ACKs for top commit:
  achow101:
    ACK e5cbea416b
  1440000bytes:
    ACK e5cbea416b
  rkrux:
    ACK e5cbea416b

Tree-SHA512: d785f621af3f3987b258e5d7fb8309344fb13c2cf41855f8adf99ff89f581142db36e3ba59919d6abf82662caa3f7e4a2bd38eba1be9e23665e6a4a23ee52acd
2025-05-23 12:34:39 -07:00
Lőrinc 53e9b71b2f log: print reason for why should_write was triggered in `FlushStateToDisk`
Co-authored-by: Jon Atack <jon@atack.com>
2025-05-23 21:18:00 +02:00
Ava Chow ad9a13fc42 walletdb: Log additional exception error messages for corrupted wallets 2025-05-23 11:31:21 -07:00
Antoine Poinsot 46e14630f7 fuzz: move the coins_view target's body into a standalone function
We'll reuse it for a target where the coins view is a DB.
2025-05-23 15:32:16 +01:00
Antoine Poinsot 56d878c465 fuzz: avoid underflow in coins_view target 2025-05-23 15:32:06 +01:00
dergoegge ad132761fc [allocators] Apply manual ASan poisoning to PoolResource 2025-05-23 10:09:39 +01:00
Ava Chow 47237cd193 wallet, rpc: Output wallet flags in getwalletinfo 2025-05-22 17:37:41 -07:00
Ava Chow bc2a26b296 wallet: Add GetWalletFlags 2025-05-22 17:37:41 -07:00
Ava Chow 69f588a99a wallet: Set upgraded descriptor cache flag for newly created wallets
Although WalletBatch::LoadWallet performs the descriptor cache upgrade,
because new wallets do not have the descriptor flag set yet, the upgrade
does not run and set the flag.

Since new wallets will always being using the upgraded cache, there's no
reason to wait to set the flag, so set it when the wallet flags are
being initialized for new wallets.
2025-05-22 17:36:32 -07:00
Sebastian Falbesoner e5cbea416b rpc: doc: remove redundant "descriptors" parameter in `createwallet` examples
This is the RPC example counterpart to commit
86de8c1668 (PR #32544).
Since the recent legacy wallet removal this parameter *must* be
true, so providing it in the examples doesn't contain valuable
information anymore and it seems best to remove them.
2025-05-23 00:30:42 +02:00
Sebastian Falbesoner 7a05f941bb rpc: doc: drop descriptor wallet mentions in fast wallet rescan related RPCs
Now that we only ever operate on descriptor wallets, mentioning
that a faster rescan is only available for them is redundant and
can be removed.

These texts were originally introduced in commit
ca48a4694f (PR #25957).
2025-05-23 00:26:19 +02:00
Sebastian Falbesoner db465a50e2 wallet, rpc: remove obsolete "keypoololdest" result field/code
This `getwalletinfo()` result field was only ever returned for
legacy wallets and is hence not relevant anymore, so we can
delete it and the corresponding CWallet/ScriptPubKeyMan code
behind it.
2025-05-23 00:26:01 +02:00
David Gumberg 36bcee05dc log: Log start of compact block initialization. 2025-05-22 13:25:31 -07:00
merge-script 2df824f4e6
Merge bitcoin/bitcoin#32586: ci: Downgrade DEBUG=1 to -D_GLIBCXX_ASSERTIONS in centos task
fa079538e3 ci: Downgrade DEBUG=1 to -D_GLIBCXX_ASSERTIONS in centos task (MarcoFalke)

Pull request description:

  to work around https://github.com/bitcoin/bitcoin/issues/32524#issuecomment-2900903169

  closes #32524

ACKs for top commit:
  laanwj:
    ACK fa079538e3
  fanquake:
    ACK fa079538e3 - we can followup

Tree-SHA512: 2d8b914c7390bbf22d8b2eb906bd2a363f92e1954646677a010b15721fca0887d5987a0af932fd0013f5c1b35c0a80c67579004a0cf635916954331c80c7bef0
2025-05-22 17:59:21 +01:00
merge-script 0a8ab55951
Merge bitcoin/bitcoin#32467: checkqueue: make the queue non-optional for CCheckQueueControl and drop legacy locking macro usage
fd290730f5 validation: clean up and clarify CheckInputScripts logic (Cory Fields)
1a37507895 validation: use a lock for CCheckQueueControl (Cory Fields)
c3b0e6c7f4 validation: make CCheckQueueControl's CCheckQueue non-optional (Cory Fields)
4c8c90b556 validation: only create a CCheckQueueControl if it's actually going to be used (Cory Fields)
11fed833b3 threading: add LOCK_ARGS macro (Cory Fields)

Pull request description:

  As part of an effort to cleanup our threading primitives and add safe `SharedMutex`/`SharedLock` impls, I'd like to get rid of the last of our legacy `ENTER_CRITICAL_SECTION`/`LEAVE_CRITICAL_SECTION` usage. This, along with a follow-up [after fixing REVERSE_LOCK](https://github.com/bitcoin/bitcoin/pull/32465) will allow us to do that.

  This replaces the old macros with an RAII lock, while simplifying `CCheckQueueControl`. It now requires a `CCheckQueue`, and optionality is handled externally. In the case of validation, it is wrapped in a `std::optional`.

  It also adds an `LOCK_ARGS` macro for `UniqueLock` initialization which may be helpful elsewhere.

ACKs for top commit:
  fjahr:
    re-ACK fd290730f5
  ryanofsky:
    Code review ACK fd290730f5, just removing assert since last review. Thanks for considering all the comments and feedback!
  TheCharlatan:
    Re-ACK fd290730f5

Tree-SHA512: 54b9db604ee1bda7d11bce1653a88d3dcbc4f525eed6a85abdd4d6409138674af4bb8b00afa4e0d3d29dadd045a3a39de253a45f0ef9c05f56cba1aac5b59303
2025-05-22 17:57:33 +01:00
Greg Sanders 8fcd684505 test: ensure reason is checked for invalid blocks rejection 2025-05-22 10:43:44 -04:00
Greg Sanders 1a689a2c88 test: fix block tests of invalid_txs 2025-05-22 10:30:13 -04:00
merge-script d2c9fc84e1
Merge bitcoin/bitcoin#32533: test: properly check for per-tx sigops limit
7bc64a8859 test: properly check for per-tx sigops limit (Sebastian Falbesoner)

Pull request description:

  Currently the per-tx sigops limit standardness check (bounded by `MAX_STANDARD_TX_SIGOPS_COST`, throwing "bad-txns-too-many-sigops" if exceeded):
  3f83c744ac/src/validation.cpp (L925-L927)

  is only indirectly tested with the much higher per-block consensus limit (`MAX_BLOCK_SIGOPS_COST`):
  3f83c744ac/test/functional/data/invalid_txs.py (L236-L242)

  I.e. an increase in the per-tx limit up to the per-block one would still pass all of our tests. Refine that by splitting up the invalid tx template `TooManySigops` in a per-block and a per-tx template.

  The involved functional tests taking use of these templates are `feature_block.py` and `p2p_invalid_txs.py`. Can be tested by applying e.g.
  ```diff
  diff --git a/src/policy/policy.h b/src/policy/policy.h
  index 2151ec13dd..e5766d2a55 100644
  --- a/src/policy/policy.h
  +++ b/src/policy/policy.h
  @@ -37,7 +37,7 @@ static constexpr unsigned int MIN_STANDARD_TX_NONWITNESS_SIZE{65};
   /** Maximum number of signature check operations in an IsStandard() P2SH script */
   static constexpr unsigned int MAX_P2SH_SIGOPS{15};
   /** The maximum number of sigops we're willing to relay/mine in a single tx */
  -static constexpr unsigned int MAX_STANDARD_TX_SIGOPS_COST{MAX_BLOCK_SIGOPS_COST/5};
  +static constexpr unsigned int MAX_STANDARD_TX_SIGOPS_COST{MAX_BLOCK_SIGOPS_COST/5 + 4};
   /** Default for -incrementalrelayfee, which sets the minimum feerate increase for mempool limiting or replacement **/
   static constexpr unsigned int DEFAULT_INCREMENTAL_RELAY_FEE{1000};
   /** Default for -bytespersigop */
  diff --git a/test/functional/mempool_accept.py b/test/functional/mempool_accept.py
  ```
  where the tests succeed on master, but fail on this PR.

  (Found by diving deeper into the jungle of current sig-ops limit, as preparation for reviewing the [BIP 54](https://github.com/bitcoin/bips/blob/master/bip-0054.md) draft and related preparatory PRs like #32521).

ACKs for top commit:
  fjahr:
    tACK 7bc64a8859
  tapcrafter:
    tACK 7bc64a8859
  darosior:
    ACK 7bc64a8859
  instagibbs:
    crACK 7bc64a8859

Tree-SHA512: 1365409349664a76a1d46b2fa358c0d0609fb17fffdd549423d22b61749481282c928be3c2fb428725735c82d319b4279f703bde01e94e4aec14bab206abb8cf
2025-05-22 10:06:03 -04:00
MarcoFalke fa079538e3
ci: Downgrade DEBUG=1 to -D_GLIBCXX_ASSERTIONS in centos task
to work around https://github.com/bitcoin/bitcoin/issues/32524#issuecomment-2900903169
2025-05-22 13:49:59 +02:00
merge-script 35bf3f8839
Merge bitcoin/bitcoin#32400: random: Use modern Windows randomness functions
6b4bcc1623 random: Use modern Windows randomness functions (David Gumberg)

Pull request description:

  This change resolves #32391 and is a follow-up to #14089.

  The old randomness API has been deprecated and will be removed at some point according to Microsoft.[^1] This PR removes all uses of that API from Bitcoin Core code, but the deprecated API is still invoked in Bitcoin Core binaries compiled after this PR because of upstream use, see this comment: https://github.com/bitcoin/bitcoin/pull/32400#issuecomment-2846972614.

  For reference on `BCryptGenRandom`, see: https://learn.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom.

  [`STATUS_SUCCESS`](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/596a1078-e883-4972-9bbc-49e60bebca55) gets defined here since including `ntstatus.h` is [more trouble](70f149b9a1/examples/examples_util.h (L19-L28)) than it's worth.

  [^1]: https://learn.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptacquirecontextw & https://learn.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptgenrandom

ACKs for top commit:
  laanwj:
    re-ACK 6b4bcc1623
  fanquake:
    ACK 6b4bcc1623

Tree-SHA512: ddd9093669dfd6ff0eee7e5e6a9c7dce798d03dd9a81dcc2e668e9b84779b7adab3105a7f0c8038e54accf28f19fe211628e13b3fc2200caa5b423f766725e37
2025-05-22 12:12:57 +01:00
merge-script a42faa25d8
Merge bitcoin/bitcoin#32551: cmake: Remove `ENABLE_{SSE41,AVX2,X86_SHANI,ARM_SHANI}` from `bitcoin-build-config.h`
800b7cc42c cmake: Add missed `SSE41_CXXFLAGS` (Hennadii Stepanov)
028476e71f cmake: Remove `ENABLE_ARM_SHANI` from `bitcoin-build-config.h` (Hennadii Stepanov)
1e900528d2 cmake: Remove `ENABLE_X86_SHANI` from `bitcoin-build-config.h` (Hennadii Stepanov)
8689628e2e cmake: Remove `ENABLE_AVX2` from `bitcoin-build-config.h` (Hennadii Stepanov)
a8e2342dca cmake: Remove `ENABLE_SSE41` from `bitcoin-build-config.h` (Hennadii Stepanov)

Pull request description:

  `ENABLE_{SSE41,AVX2,X86_SHANI,ARM_SHANI}`  are already conditionally defined for the [`bitcoin_crypto`](https://github.com/bitcoin/bitcoin/blob/master/src/crypto/CMakeLists.txt) target, and they are not used by any other targets. Defining them globally in `bitcoin-build-config.h` is therefore redundant.

  Additionally, the previously missing `SSE41_CXXFLAGS` variable has been [added](https://github.com/bitcoin/bitcoin/pull/32550#issuecomment-2890918551).

ACKs for top commit:
  fanquake:
    ACK 800b7cc42c

Tree-SHA512: da792a0b780c67b432b09c9288ca98d62545315c721fed13510d1c11f8bb0cddd9a4ed7a009b4d052471dda19d0641bbc1eae4805fc306d23bf9b4ef510089c8
2025-05-22 10:00:09 +01:00
Ava Chow 5fe4c66462 XOnlyPubKey: Add GetCPubKeys
We need to retrieve the even and odd compressed pubkeys for xonly
pubkeys, so add a function to do that. Also reuse it in GetKeyIDs.
2025-05-21 10:44:26 -07:00
fanquake 24e5fd3bed
fs: remove _POSIX_C_SOURCE defining
On Linux systems, `_POSIX_C_SOURCE` will default to `200809L` (since
glibc 2.10). There's currently no reason for us to undefine it, and then
set it to an earlier value. Also tested with musl libc.

I think if anything, the project should be settings macros like
`_POSIX_C_SOURCE`, globally.
2025-05-21 15:58:11 +01:00
Matthew Zipkin f16c8c67bf
tests: Expand HTTP coverage to assert libevent behavior
Covers:
- http pipelining
- rpcservertimeout

  Testing this requires adding an option to TestNode to force
  the test framework to establish a new HTTP connection for
  every RPC. Otherwise, attempting to reuse a persistent connection
  would cause framework RPCs during startup and shutdown to fail.

- "chunked" Transfer-Encoding
2025-05-21 10:47:23 -04:00
MarcoFalke fac00d4ed3
doc: Move CI-must-pass requirement into readme section
Seems fine to state it clearly once.
2025-05-21 16:19:40 +02:00
MarcoFalke fab79c1a25
doc: Clarify and move "hygienic commit" note
The prior version mentions to update the tests *first*, which is wrong.
It must be updated at the same time in the same commit.
2025-05-21 16:19:24 +02:00
MarcoFalke fac8b05197
doc: Clarify strprintf size specifier note 2025-05-21 16:19:04 +02:00
MarcoFalke faaf34ad72
doc: Remove section about RPC alias via function pointer
This is no longer possible with RPCHelpMan.
2025-05-21 16:18:36 +02:00
MarcoFalke 2222d61e1c
doc: Remove section about RPC arg names in table
The table no longer holds arg names. This is done automatically by
RPCHelpMan.
2025-05-21 16:17:58 +02:00
MarcoFalke fa00b8c02c
doc: Remove section about include guards 2025-05-21 16:17:51 +02:00
MarcoFalke fad6cd739b
doc: Remove dev note section on includes 2025-05-21 16:17:45 +02:00
MarcoFalke fa6623d85a
doc: Remove file name section
This is already checked by test/lint/lint-files.py

There is no need to reword all linters into the dev notes.
2025-05-21 16:17:39 +02:00
MarcoFalke 7777fb8bc7
doc: Remove shebang section
This is already checked by test/lint/lint-files.py

There is no need to reword all linters into the dev notes.

Also, allow scripts in Rust (there are already some).
2025-05-21 16:17:14 +02:00
MarcoFalke faf65f0531
doc: Remove .gitignore section
This was added to the gitignore file itself in commit
fada115cbe. The past violations are
evidence that the note in the dev notes was missed anyway.
2025-05-21 16:17:04 +02:00
MarcoFalke faf2094f25
doc: Remove note about removed ParsePrechecks 2025-05-21 16:16:55 +02:00
merge-script 87ec923d3a
Merge bitcoin/bitcoin#32475: wallet: Use `util::Error` throughout `AddWalletDescriptor` instead of returning `nullptr` for some errors
785e1407b0 wallet: Use util::Error throughout AddWalletDescriptor (Ava Chow)

Pull request description:

  #32023 changed `AddWalletDescriptor` to return `util::Error`, but did not change all of the failure cases to do so. This may result in some callers continuing when there was actually an error. Unify all of the failure cases to use `util::Error` so that all callers handle `AddWalletDescriptor` errors in the same way.

  The encapsulated return type is changed from `ScriptPubKeyMan*` to `std::reference_wrapper<DescriptorScriptPubKeyMan>`. This avoids having a value that can be interpreted as a bool, and also removes the need to constantly dynamic_cast the returned value. The only kind of `ScriptPubKeyMan` that can come out of `AddWalletDescriptor` is a `DescriptorScriptPubKeyMan` anyways.

ACKs for top commit:
  Sjors:
    utACK 785e1407b0
  ryanofsky:
    Code review ACK 785e1407b0
  furszy:
    Code review ACK 785e1407b0

Tree-SHA512: 52a48263c8d4161a8c0419b7289c25b0986f8e3bcd10b639eeeb0b6862d08b6c5e70998d20070ab26b39ecd90ab83dc8b71c65d85f70626282cf8cc6abff50e7
2025-05-21 14:24:39 +01:00
merge-script 7763e86afa
Merge bitcoin/bitcoin#32573: ci: Avoid && dropping errors
fab97f583f ci: Avoid && dropping errors (MarcoFalke)

Pull request description:

  In bash, `&&` will ignore errexit. This can lead to silently ignoring errors. Compare the output of:

  ```
  $ bash -c 'set -xe;   false && false   ; true; echo $?'
  + false
  + true
  + echo 0
  0
  ```

  In theory this could be fixed by using a subshell:

  ```
  $ bash -c 'set -xe; ( false && false ) ; true; echo $?'
  + false
  ```

  However, it is easier to just remove the `&&`.

  This was introduced in  commit faa807bdf8

ACKs for top commit:
  janb84:
    Code review ACK fab97f583f
  hebasto:
    ACK fab97f583f.
  laanwj:
    ACK fab97f583f

Tree-SHA512: 9d034829e03ef3aefdaad82c3cab59bf3fe18529762271c1ad3c838357e337e94bd403b77e30c0cf69715254b65addff6d12f2fb497d7a0e2cdcbcbf78858d47
2025-05-21 12:11:49 +01:00
merge-script 0a56ed1ac8
Merge bitcoin/bitcoin#32567: subprocess: Backport upstream changes
e63a7034f0 subprocess: Don't add an extra whitespace at end of Windows command line (laanwj)

Pull request description:

  A list of the backported PRs:
  - https://github.com/arun11299/cpp-subprocess/pull/119

  The following PRs were skipped for backporting:
  - https://github.com/arun11299/cpp-subprocess/pull/118 because there is no changes in the header code.

  Required for https://github.com/bitcoin/bitcoin/pull/32566.

ACKs for top commit:
  laanwj:
    Code review ACK e63a7034f0

Tree-SHA512: 69a74aa7f9c611a9ec910e27161c5e9e147067d37f8335953cd3875fcc88dc840a2f7b206bb603f22507159e406b1449f1dc4702fffe890bb824672641b4feed
2025-05-21 12:08:36 +01:00
merge-script 54e406a305
Merge bitcoin/bitcoin#32459: qt: drop unused watch-only functionality
e8661aac75 wallet: drop watch-only things from interface (Sjors Provoost)
e99188e7da qt: drop unused watch-only functionality (Sjors Provoost)

Pull request description:

  The watch-only functionality in the GUI was only used for legacy wallets. Watch-only descriptor wallets do not use this.

  The only visible changes of this PR should be:
  - dropped "Spendable:" label from the overview tab
  - column width cache is reset

  This PR also removes some unused variables from the interface.

ACKs for top commit:
  davidgumberg:
    Review ACK e8661aac75.
  hebasto:
    ACK e8661aac75, I have reviewed the code and it looks OK. The `src/qt/forms/overviewpage.ui` form was reviewed in Qt Designer.

Tree-SHA512: d7edb0f167e0b934075398a76eddca69890bb36848a918c932b1c2cea85ee87285e876cbfdf1f6dec7adf26b9f405fb558c70bec0c84585c0a9df33c2af78393
2025-05-21 10:13:00 +01:00
merge-script ec81204694
Merge bitcoin/bitcoin#31622: psbt: add non-default sighash types to PSBTs and unify sighash type match checking
ee045b61ef rpc, psbt: Require sighashes match for descriptorprocesspsbt (Ava Chow)
2b7682c372 psbt: use sighash type field to determine whether to remove non-witness utxos (Ava Chow)
28781b5f06 psbt: Add sighash types to PSBT when not DEFAULT or ALL (Ava Chow)
15ce1bd73f psbt: Enforce sighash type of signatures matches psbt (Ava Chow)
1f71cd337a wallet: Remove sighash type enforcement from FillPSBT (Ava Chow)
4c7d767e49 psbt: Check sighash types in SignPSBTInput and take sighash as optional (Ava Chow)
a118256948 script: Add IsPayToTaproot() (Ava Chow)
d6001dcd4a wallet: change FillPSBT to take sighash as optional (Ava Chow)
e58b680923 psbt: Return PSBTError from SignPSBTInput (Ava Chow)
2adfd81532 tests: Test PSBT sighash type mismatch (Ava Chow)
5a5d26d612 psbt: Require ECDSA signatures to be validly encoded (Ava Chow)

Pull request description:

  Currently, we do not add the sighash field to PSBTs at all, even when we have signed with a non-default sighash. This PR changes the behavior such that when we (attempt to) sign with a sighash other than DEFAULT or ALL, the sighash type field will be added to the PSBT to inform the later signers that a different sighash type was used by a signer. Notably, this is necessary for MuSig2 support as all signers must sign using the same sighash type, but the sighash is not provided in partial signatures.

  Furthermore, because the sighash type can also be provided on the command line, we require that if both a command line sighash type and the sighash field is present, they must specify the same sighash type. However, this was being checked by the wallet, rather than the signing code, so the `descriptorprocesspsbt` RPC was not enforcing this restriction at all, and in fact ignored the sighash field entirely. This PR refactors the checking code so that the underlying PSBT signing function `SignPSBTInput` does the check.

ACKs for top commit:
  theStack:
    re-ACK ee045b61ef
  rkrux:
    re-ACK ee045b61ef
  fjahr:
    Code review ACK ee045b61ef

Tree-SHA512: 4ead5be1ef6756251b827f594beba868a145d75bf7f4ef6f15ad21f0ae4b8d71b38c83494e5a6b75f37fadd097178cddd93d614b962a2c72fc134f00ba2f74ae
2025-05-21 10:02:49 +01:00
MarcoFalke fab97f583f
ci: Avoid && dropping errors 2025-05-20 21:38:07 +02:00
Ava Chow 9a887baade
Merge bitcoin/bitcoin#32344: Wallet: Fix Non-Ranged Descriptors with Range [0,0] Trigger Unexpected Wallet Errors in AddWalletDescriptor
97d383af6d Test updating non-ranged descriptor with [0,0] range succeeds (Novo)
2ae1788dd4 Skip range verification for non-ranged desc (Novo)

Pull request description:

  Closes https://github.com/bitcoin/bitcoin/issues/31728

  This PR updates the `DescriptorScriptPubKeyMan` to skip range checks for non-ranged descriptors, which previously caused errors when updating a non-ranged descriptor with the range [0,0]

  #### Testing
  A unit test was added to test the new behaviour

ACKs for top commit:
  achow101:
    ACK 97d383af6d
  rkrux:
    ACK 97d383a

Tree-SHA512: 6dbd058376d9e57d26477d9d6d89646e80a32e3ffcc9f4e30eeda273575d12583ce520cc0032cc67c12ea0b3ad344fbd3945d9fc5e389b6a6bce1ea7ad5d6e59
2025-05-20 12:30:52 -07:00
Ava Chow 26fba39bda
Merge bitcoin/bitcoin#32466: threading: drop CSemaphore in favor of c++20 std::counting_semaphore
6f7052a7b9 threading: semaphore: move CountingSemaphoreGrant to its own header (Cory Fields)
fd15469892 threading: semaphore: remove temporary convenience types (Cory Fields)
1f89e2a49a scripted-diff: threading: semaphore: use direct types rather than the temporary convenience ones (Cory Fields)
f21365c4fc threading: replace CountingSemaphore with std::counting_semaphore (Cory Fields)
1acacfbad7 threading: make CountingSemaphore/CountingSemaphoreGrant template types (Cory Fields)
e6ce5f9e78 scripted-diff: rename CSemaphore and CSemaphoreGrant (Cory Fields)
793166d381 wallet: change the write semaphore to a BinarySemaphore (Cory Fields)
6790ad27f1 scripted-diff: rename CSemaphoreGrant and CSemaphore for net (Cory Fields)
d870bc9451 threading: add temporary semaphore aliases (Cory Fields)
7b816c4e00 threading: rename CSemaphore methods to match std::semaphore (Cory Fields)

Pull request description:

  This is relatively simple, but done in a bunch of commits to enable scripted diffs.

  I wanted to add a semaphore in a branch I've been working on, but it was unclear if I should use `std::counting_semaphore` or stick with our old `CSemaphore`. I couldn't decide, so I just decided to remove all doubt and get rid of ours :)

  This replaces our old `CSemaphore` with `std::counting_semaphore` everywhere we used it. `CSemaphoreGrant` is still there as an RAII wrapper, but is now called `CountingSemaphoreGrant` and `BinarySemaphoreGrant` to match. Those have been moved out of `sync.h` to their own file.

ACKs for top commit:
  purpleKarrot:
    ACK 6f7052a7b9
  achow101:
    ACK 6f7052a7b9
  TheCharlatan:
    ACK 6f7052a7b9
  hebasto:
    ACK 6f7052a7b9, I have reviewed the code and it looks OK.

Tree-SHA512: 5975d13aa21739174e3a22c544620ae3f36345f172b51612346d3b7baf0a07c39ef6fd54f647c87878c21a67951b347a5d4a5f90e897f3f6c0db360a3779d0df
2025-05-20 12:21:17 -07:00
Ava Chow 878556947b
Merge bitcoin/bitcoin#32333: doc: Add missing top-level description to pruneblockchain RPC
135a0f0aa7 doc: Add missing top-level description to pruneblockchain RPC (nervana21)

Pull request description:

  Previously, the `pruneblockchain` RPC help output included only the method signature and arguments, with no top-level description explaining its purpose or constraints.

  This PR adds a top-level description, improving documentation consistency and alerting users to the potential impacts of using the command.

ACKs for top commit:
  maflcko:
    lgtm ACK 135a0f0aa7
  yancyribbens:
    cr ACK 135a0f0aa7
  achow101:
    ACK 135a0f0aa7
  janb84:
    re ACK [135a0f0](135a0f0aa7)

Tree-SHA512: e51475238e779555315668b7389ed312a5d2c4ad1c0b251f2314895ac473092fa458b6f931f70385e14047adb7e340e44fe2198643603da9e129f1c874578a28
2025-05-20 12:02:54 -07:00
Cory Fields fd290730f5 validation: clean up and clarify CheckInputScripts logic
CheckInputScripts behaves differently depending on whether or not it was called
with a vector for checks. Make this difference clear by calling it differently
depending on whether or not control exists. Though more verbose, it should be
more straightforward to understand what's happening this way.

Also remove parallel_script_checks, as `if(control)` is a better test.

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2025-05-20 18:24:34 +00:00
MarcoFalke fa69c5b170
doc: Remove -disablewallet from dev notes
No setting should crash. Most settings are tested as part of the
functional test suite, including -disablewallet.
2025-05-20 18:36:59 +02:00
fanquake df9ebbf659
depends: use "mkdir -p" when installing xproto
It looks like the mkdir detection in xproto is broken on Alpine. Ensure
we always use `mkdir -p`.

Fixes #32494.
2025-05-20 16:01:32 +01:00
merge-script fad009af49
Merge bitcoin/bitcoin#32520: Remove legacy `Parse(U)Int*`
faf55fc80b doc: Remove ParseInt mentions in documentation (MarcoFalke)
3333282933 refactor: Remove unused Parse(U)Int* (MarcoFalke)
fa84e6c36c bitcoin-tx: Reject + sign in MutateTxDel* (MarcoFalke)
face2519fa bitcoin-tx: Reject + sign in vout parsing (MarcoFalke)
fa8acaf0b9 bitcoin-tx: Reject + sign in replaceable parsing (MarcoFalke)
faff25a558 bitcoin-tx: Reject + sign in locktime (MarcoFalke)
dddd9e5fe3 bitcoin-tx: Reject + sign in nversion parsing (MarcoFalke)
fab06ac037 rest: Use SAFE_CHARS_URI in SanitizeString error msg (MarcoFalke)
8888bb499d rest: Reject + sign in /blockhashbyheight/ (MarcoFalke)
fafd43c691 test: Reject + sign when parsing regtest deployment params (MarcoFalke)
fa123afa0e Reject + sign when checking -ipcfd (MarcoFalke)
fa479857ed Reject + sign in SplitHostPort (MarcoFalke)
fab4c2967d net: Reject + sign when parsing subnet mask (MarcoFalke)
fa89652e68 init: Reject + sign in -*port parsing (MarcoFalke)
fa9c45577d cli: Reject + sign in -netinfo level parsing (MarcoFalke)
fa98041325 refactor: Use ToIntegral in CreateFromDump (MarcoFalke)
fa23ed7fc2 refactor: Use ToIntegral in ParseHDKeypath (MarcoFalke)

Pull request description:

  The legacy int parsing is problematic, because it accepts the `+` sign for unsigned integers. In all cases this is either:

  * Useless, because the `+` sign was already rejected.
  * Erroneous and inconsistent, when third party parsers reject it. (C.f. https://github.com/bitcoin/bitcoin/pull/32365)
  * Confusing, because the `+` sign is  neither documented, nor can it be assumed to be present.

  Fix all issues by removing the legacy int parsing.

ACKs for top commit:
  stickies-v:
    re-ACK faf55fc80b
  brunoerg:
    code review ACK faf55fc80b

Tree-SHA512: a311ab6a58fe02a37741c1800feb3dcfad92377b4bfb61b433b2393f52ba89ef45d00940972b2767b213a3dd7b59e5e35d5b659c586eacdfe4e565a77b12b19f
2025-05-20 15:55:38 +01:00
Greg Sanders f66b14d2ec test: fix pushdata scripts
The original scripts were done incorrectly,
so they are changed to represent two
different 2-byte pushes.
2025-05-20 10:39:39 -04:00
merge-script 0f9baba0fb
Merge bitcoin/bitcoin#29868: Reintroduce external signer support for Windows
3a18075aed ci: Drop `-DENABLE_EXTERNAL_SIGNER=ON` configure option (Hennadii Stepanov)
719fa9f4ef build: Re-enable external signer support for Windows (Hennadii Stepanov)
6e5fc2bf9b test: Reintroduce Windows support in `system_tests/run_command` test (Hennadii Stepanov)

Pull request description:

  This PR partially reverts:
  - https://github.com/bitcoin/bitcoin/pull/28967
  - https://github.com/bitcoin/bitcoin/pull/29489

  After this PR, we can proceed to actually remove the [unused code](https://github.com/bitcoin/bitcoin/pull/28981#pullrequestreview-1991272752) from `src/util/subprocess.h`.

ACKs for top commit:
  Sjors:
    ACK 3a18075aed.
  theStack:
    Light ACK 3a18075aed
  laanwj:
    Code review and lightly tested ACK 3a18075aed

Tree-SHA512: 00d200685906e716750aae7cffa0794cca451653738ea590f50dfa28e1f3c5762a9be0ae0917aa0cf7436f00fe1e565236bff2853896530a5879466f7f45cb25
2025-05-20 12:24:34 +01:00
merge-script cf2cbfac65
Merge bitcoin/bitcoin#32553: wallet: Fix logging of wallet version
4b2cd0b41f test: check that creating a wallet does not log version info (Ava Chow)
39a483c8e9 test: Check that the correct versions are logged on wallet load (Ava Chow)
359ecd3704 walletdb: Log the wallet version after it has been read from disk (Ava Chow)

Pull request description:

  The wallet's version (in the minversion record) needs to be logged only after we have read it from disk. Otherwise, we always log the lowest version number of 10500 which is incorrect. Furthermore, it doesn't make sense to log the last client version number if the record didn't exist. This is a regression caused by #26021.

  The wallet file version logging is moved inside of `LoadMinVersion` so that it is logged after the record is read. It will also log unconditionally if a version is read so that the version number is reported even when there is an error. The last client logging is split into its own log line that will only occur if a last client record is read. The only situation where we expect no version numbers to be logged is when a wallet is being created.

  A test is added in the second commit to check that the version number is correctly logged on loading. This commit can be cherrypicked to master to verify that it fails there. The last commit adds an additional check that creating a new wallet does not log any version info at all.

ACKs for top commit:
  laanwj:
    Code review ACK 4b2cd0b41f
  janb84:
    ACK 4b2cd0b41f
  furszy:
    ACK 4b2cd0b41f
  rkrux:
    ACK 4b2cd0b41f

Tree-SHA512: b30c76f414d87be6c14b42d2d3c8794a91a7e8601501f4c24641d51ff2b5c5144776563baf41ca1c38415844740b760b19a3e5791f78013b39984dfedd3b1de7
2025-05-20 12:22:25 +01:00
merge-script bc4b04c5bf
Merge bitcoin/bitcoin#31864: doc: add missing copyright headers
c7c3bfadfc doc: add & amend copyright headers (fanquake)
f667000c83 contrib: remove outdated entries from copyright_header.py (fanquake)
0817f2d6cf doc: update MIT license URL (fanquake)
6854497b47 contrib: remove GPL-3+ from debian/copyright (fanquake)

Pull request description:

  Add & amends a number of copyright headers.
  Remove some now obselete doc/code.

ACKs for top commit:
  willcl-ark:
    ACK c7c3bfadfc

Tree-SHA512: 746ca4217e310f7f907fcd5d1e03d481b65045d57048b892a2c993be690898b6681fe6003b4f6a448b551c0ddcb32cad07998de208284a64cc4853fd4d63df52
2025-05-20 12:18:42 +01:00
laanwj e63a7034f0
subprocess: Don't add an extra whitespace at end of Windows command line
The windows code adds an unnecessary extra space to the command line.
This can cause subtle issues, so avoid it.

Github-Pull: arun11299/cpp-subprocess#119
Rebased-From: 777cfa77d1f84bb08b3e445d5f7fc6c87282223b
2025-05-20 12:10:10 +01:00
Hennadii Stepanov 800b7cc42c
cmake: Add missed `SSE41_CXXFLAGS` 2025-05-20 11:14:17 +01:00
Hennadii Stepanov 028476e71f
cmake: Remove `ENABLE_ARM_SHANI` from `bitcoin-build-config.h`
`ENABLE_ARM_SHANI` is already conditionally defined for the
`bitcoin_crypto` target, so defining it in `bitcoin-build-config.h` is
redundant.
2025-05-20 11:14:17 +01:00
Hennadii Stepanov 1e900528d2
cmake: Remove `ENABLE_X86_SHANI` from `bitcoin-build-config.h`
`ENABLE_X86_SHANI` is already conditionally defined for the
`bitcoin_crypto` target, so defining it in `bitcoin-build-config.h` is
redundant.
2025-05-20 11:12:56 +01:00
Hennadii Stepanov 8689628e2e
cmake: Remove `ENABLE_AVX2` from `bitcoin-build-config.h`
`ENABLE_AVX2` is already conditionally defined for the `bitcoin_crypto`
target, so defining it in `bitcoin-build-config.h` is redundant.
2025-05-20 11:12:56 +01:00
Hennadii Stepanov a8e2342dca
cmake: Remove `ENABLE_SSE41` from `bitcoin-build-config.h`
`ENABLE_SSE41` is already conditionally defined for the `bitcoin_crypto`
target, so defining it in `bitcoin-build-config.h` is redundant.
2025-05-20 11:12:49 +01:00
will 5332082d00
doc: add alpine build instructions 2025-05-20 10:20:13 +01:00
MarcoFalke fa76b378e4
rpc: Round verificationprogress to exactly 1 for a recent tip
This requires a new lock annotation, but all relevant callers already
held the lock.
2025-05-20 11:17:29 +02:00
MarcoFalke faf6304bdf
test: Use mockable time in GuessVerificationProgress
Also add a test.
2025-05-20 11:16:35 +02:00
fanquake c7c3bfadfc
doc: add & amend copyright headers 2025-05-20 09:43:21 +01:00
fanquake f667000c83
contrib: remove outdated entries from copyright_header.py 2025-05-20 09:30:41 +01:00
fanquake 0817f2d6cf
doc: update MIT license URL 2025-05-20 09:30:41 +01:00
fanquake 6854497b47
contrib: remove GPL-3+ from debian/copyright
This is unused.
2025-05-20 09:30:41 +01:00
merge-script af65fd1a33
Merge bitcoin/bitcoin#32560: ci: Move DEBUG=1 to centos task
fa58d6cdab ci: Move DEBUG=1 to centos task (MarcoFalke)

Pull request description:

  The glibcxx debug mode has many bugs in prior gcc releases:

  * https://github.com/bitcoin/bitcoin/issues/32524#issuecomment-2890411766
  * https://github.com/bitcoin/bitcoin/issues/31436#issuecomment-2530717875
  * ...

  Instead of working around all of them, just use the existing `ci_native_centos` task with gcc-14 to have it enabled. This also follows the logic of other sanitizers (tsan, asan, ubsan, msan, valgrind, ...) to generally prefer the latest version of the sanitizer for the latests features and bugfixes.

  Fixes #32524.

  Also, while touching the `ci_native_previous_releases`, increase g0 to g2, so that it is easier for developers to use gdb inside the CI without having to re-compile

ACKs for top commit:
  hebasto:
    ACK fa58d6cdab.
  fanquake:
    ACK fa58d6cdab

Tree-SHA512: 26f151887bc39e88353b4ba1f91e913b830d24eac258b7caa0027aa592595150d5e713ededa3ed15a1b84165a94b14b0bfe3eb2fb7314d261d972b63ce01af43
2025-05-20 09:29:56 +01:00
merge-script 548f6b8cde
Merge bitcoin/bitcoin#32562: doc: remove // for ... comments
7193245cd6 doc: remove For ... comments (fanquake)
1b9cdc933f net: drop win32 ifdef (fanquake)
19ba499b1f init: cerrno is used on all platforms (fanquake)

Pull request description:

  We don't add or maintain these, and they are of little value, as
  well as having the effect of polluting diffs, if changed.

  They are also wrong, i.e `DEFAULT_SCRIPTCHECK_THREADS` is not in
  `validation.h`.

ACKs for top commit:
  stickies-v:
    re-ACK 7193245cd6
  fjahr:
    ACK 7193245cd6
  willcl-ark:
    reACK 7193245cd6

Tree-SHA512: 6b5f83cd1df699356e1cbb78949f8d456b13ce288f0064138118cfb45b4c77e2d1945babe91598dffe9823ab07dfae36f4c3b61c586cf98baf16890bdf322b08
2025-05-20 09:28:46 +01:00
merge-script 7c87a0e3fb
Merge bitcoin/bitcoin#32477: lint: Check for missing trailing newline
fa9198af55 lint: Check for missing trailing newline (MarcoFalke)
fa2b2aa27c lint: Add archived notes to default excludes (MarcoFalke)

Pull request description:

  A missing trailing newline is harmless, but a bit problematic:

  * `git` shows a warning by default
  * After another line is appended, the diff will be verbose and `git blame` will be wrong for the "untouched" line.

  Fix the problems by just requiring what is already the default, see also 663a9cabf8/.editorconfig (L9) and 663a9cabf8/test/lint/test_runner/src/main.rs (L327)

ACKs for top commit:
  l0rinc:
    utACK fa9198af55
  fanquake:
    ACK fa9198af55

Tree-SHA512: d144eebdeee68fc3404aa4a66ecd5c130f907ed4b869bd300f6e9ed74d125561d1f4cdd6dd20d9e969471a7d007399f928f072d1c1f626275ca31f32bc23fdbc
2025-05-20 09:25:09 +01:00
MarcoFalke faf55fc80b
doc: Remove ParseInt mentions in documentation
In the dev notes, remove the whole section, because:

* ParseDouble was removed in commit
  fa9d72a794
* The locale-dependent atoi is already checked by
  test/lint/lint-locale-dependence.py

Co-authored-by: Fabian Jahr <fjahr@protonmail.com>
2025-05-20 06:50:50 +02:00
Ava Chow 785e1407b0 wallet: Use util::Error throughout AddWalletDescriptor
32023 changed AddWalletDescriptor to return util::Error, but did not
change all of the failure cases to do so. This may result in some
callers continuing when there was actually an error. Unify all of the
failure cases to use util::Error so that all callers handle
AddWalletDescriptor errors in the same way.

The encapsulated return type is changed from ScriptPubKeyMan* to
std::reference_wrapper<DescriptorScriptPubKeyMan>. This avoids having a
value that can be interpreted as a bool, and also removes the need to
constantly dynamic_cast the returned value. The only kind of
ScriptPubKeyMan that can come out of AddWalletDescriptor is a
DescriptorScriptPubKeyMan anyways.
2025-05-19 18:09:56 -07:00
Cory Fields 1a37507895 validation: use a lock for CCheckQueueControl
Uses an RAII lock for the exact same behavior as the old critical sections.

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2025-05-19 22:06:48 +00:00
Cory Fields c3b0e6c7f4 validation: make CCheckQueueControl's CCheckQueue non-optional
This simplifies the construction logic and will allow the constructor and
destructor to lock and unlock uncondiationally.
2025-05-19 22:06:48 +00:00
Cory Fields 4c8c90b556 validation: only create a CCheckQueueControl if it's actually going to be used
This will allow CCheckQueueControl to require a CCheckQueue.
2025-05-19 22:06:48 +00:00
Cory Fields 11fed833b3 threading: add LOCK_ARGS macro
This is useful for initializing locks in a constructor.
2025-05-19 21:59:43 +00:00
Antoine Poinsot 9f8e7b0b3b node: cap -dbcache to 1GiB on 32-bit architectures
32-bit architecture is limited to 4GiB, so it doesn't make sense to set a too
high value. Since this setting is performance critical, pick an arbitrary value
higher than for -maxmempool but still reasonable.
2025-05-19 16:39:58 -04:00
Antoine Poinsot 2c43b6adeb init: cap -maxmempool to 500 MB on 32-bit systems
32-bit architecture is limited to 4GiB, so it doesn't make sense to set a too high value. 500 MB is
chosen as an arbitrary maximum value that seems reasonable.
2025-05-19 16:39:58 -04:00
Ryan Ofsky 33f8f8ae4c
Merge bitcoin/bitcoin#30221: wallet: Ensure best block matches wallet scan state
30a94b1ab9 test, wallet: Remove concurrent writes test (Ava Chow)
b44b7c03fe wallet: Write best block record on unload (Ava Chow)
876a2585a8 wallet: Remove unnecessary database Close step on shutdown (Ava Chow)
98a1a5275c wallet: Remove chainStateFlushed (Ava Chow)
7fd3e1cf0c wallet, bench: Write a bestblock record in WalletMigration (Ava Chow)
6d3a8b195a wallet: Replace chainStateFlushed in loading with SetLastBlockProcessed (Ava Chow)
7bacabb204 wallet: Update best block record after block dis/connect (Ava Chow)

Pull request description:

  Implements the idea discussed in https://github.com/bitcoin/bitcoin/pull/29652#issuecomment-2010579484

  Currently, `m_last_block_processed` and `m_last_block_processed_height` are not guaranteed to match the block locator stored in the wallet, nor do either of those fields actually represent the last block that the wallet is synced up to. This is confusing and unintuitive.

  This PR changes those last block fields to be updated whenever the wallet makes a change to the db for new transaction state found in new blocks. Whenever a block is received that contains a transaction relevant to the wallet, the last block locator will now be written to disk. Furthermore, every block disconnection will now write an updated locator.

  To ensure that the locator is relatively recent and loading rescans are fairly quick in the event of unplanned shutdown, it is also now written every 144 blocks (~1 day). Additionally it is now written when the wallet is unloaded so that it is accurate when the wallet is loaded again.

  Lastly, the `chainstateFlushed` notification in the wallet is changed to be a no-op. The best block locator record is no longer written when `chainstateFlushed` is received from the node since it should already be mostly up to date.

ACKs for top commit:
  rkrux:
    ACK 30a94b1ab9
  mzumsande:
    Code Review ACK 30a94b1ab9
  ryanofsky:
    Code review ACK 30a94b1ab9. Only changes since last review are using WriteBestBlock method more places and updating comments.

Tree-SHA512: 46117541f8aaf13dde57430e813b4bbbd5e146e2632769675803c8e65a82f149a7cc6026489a127d32684b90124bd2b7c28216dbcfa6a47447300e8f3814e029
2025-05-19 15:50:51 -04:00
Hennadii Stepanov 7054d24f11
Merge bitcoin-core/gui#875: Use WitnessV0KeyHash in TestAddAddressesToSendBook
fa982f1425 Use WitnessV0KeyHash in TestAddAddressesToSendBook (MarcoFalke)

Pull request description:

  Fixes https://github.com/bitcoin/bitcoin/issues/32558
  Fixes https://github.com/bitcoin-core/gui/issues/874

  This fixes a bug introduced in commit fafee85358, which changed the type of the dummy address from `WitnessV0KeyHash` to `PKHash`. It was expected that this is fine, given that this is just a dummy address. However, the base58 characters can include the substring "io", leading to test failures later on.

  Fix it by just using `WitnessV0KeyHash` again.

  For reference, a passing test could look like:

  ```
  Model contains 2 rows and 2 columns.
  --- Model Data ---
  Row 0 : "io - new A\tmxgkqJWAwfUwbgzZUsWrG1stKWV6fDn8YH"
  Row 1 : "io - new B\tmhsxP2yrYDQiEncT8HzKxQSFSFJmUsudsP"
  ------------------
  ```

  A failing test could look like:

  ```
  Model contains 3 rows and 2 columns.
  --- Model Data ---
  Row 0 : "already here (s)\tmyDFZSKDQdPMMoSQgzkDtq2yioo8DA8qCX"
  Row 1 : "io - new A\tmsAqQKjMrbxYRDhGXBBJ3yUEQxj5Bf5Njz"
  Row 2 : "io - new B\tmtALQiit8dw33kznVfHDgE38ohfgz2Pchc"
  ------------------
  FAIL!  : AddressBookTests::addressBookTests() Compared values are not the same
     Actual   (table_view->model()->rowCount()): 3
     Expected (2)                              : 2
     Loc: [qt/test/addressbooktests.cpp(219)]
  ```

ACKs for top commit:
  achow101:
    ACK fa982f1425
  hebasto:
    ACK fa982f1425, I have reviewed the code along with the related changes from https://github.com/bitcoin/bitcoin/pull/32511.

Tree-SHA512: f55d7fe4193a0706e1a3ca1a2c0fbf2f04dc5b177699add00013ec56d64218ac85b80dad6e99f9fde26f4c9fca79f99e68ded057c5862364064404ac06b77176
2025-05-19 20:02:40 +01:00
Ryan Ofsky 4272966d02
Merge bitcoin/bitcoin#32423: rpc: Undeprecate rpcuser/rpcpassword, store all credentials hashed in memory
e49a7274a2 rpc: Avoid join-split roundtrip for user:pass for auth credentials (Vasil Dimov)
98ff38a6f1 rpc: Perform HTTP user:pass split once in `RPCAuthorized` (laanwj)
879a17bcb1 rpc: Store all credentials hashed in memory (laanwj)
4ab9bedee9 rpc: Undeprecate rpcuser/rpcpassword, change message to security warning (laanwj)

Pull request description:

  This PR does two things:

  ### Undeprecate rpcuser/rpcpassword, change message to security warning

  Back in 2015, in https://github.com/bitcoin/bitcoin/pull/7044, we added configuration option `rpcauth` for multiple RPC users. At the same time the old settings for single-user configuration `rpcuser` and `rpcpassword` were "soon" to be deprecated.

  The main reason for this deprecation is that while `rpcpassword` stores the password in plain text, `rpcauth` stores a hash, so it doesn't appear in the configuration in plain text.

  As the options are still in active use, actually removing them is expected to be a hassle to many, and it's not clear that is worth it. As for the security risk, in many kinds of setups (no wallet, containerized, single-user-single-application, local-only, etc) it is an unlikely point of escalation.

  In the end, it is good to encourage secure practices, but it is the responsibility of the user. Log a clear warning but remove the deprecation notice (this is also the only place where the options appear as deprecated, they were never marked as such in the -help output).

  <hr>

  ### Store all credentials hashed in memory

  This gets rid of the special-casing of `strRPCUserColonPass` by hashing cookies as well as manually provided `-rpcuser`/`-rpcpassword` with a random salt before storing them.

  Also take the opportunity to modernize the surrounding code a bit. There should be no end-user visible differences in behavior.

  <hr>

  Closes #29240.

ACKs for top commit:
  1440000bytes:
    utACK e49a7274a2
  janb84:
    reACK e49a7274a2
  vasild:
    ACK e49a7274a2

Tree-SHA512: 7162848ada4545bc07b5843d1ab6fb7e31fb26de8d6385464b7c166491cd122eac2ec5e70887c414fc136600482df8277dc0cc0541d7b7cf62c4f72e25bb6145
2025-05-19 12:41:56 -04:00
fanquake 7193245cd6
doc: remove For ... comments
We don't add or maintain these, and they are of little value, as
well as having the effect of polluting diffs.

They are also wrong, i.e DEFAULT_SCRIPTCHECK_THREADS is not in
validation.h.
2025-05-19 16:40:33 +01:00
MarcoFalke 3333282933
refactor: Remove unused Parse(U)Int* 2025-05-19 17:16:13 +02:00
fanquake 1b9cdc933f
net: drop win32 ifdef 2025-05-19 13:45:04 +01:00
fanquake 19ba499b1f
init: cerrno is used on all platforms 2025-05-19 13:45:04 +01:00
MarcoFalke fa982f1425
Use WitnessV0KeyHash in TestAddAddressesToSendBook 2025-05-19 14:26:40 +02:00
MarcoFalke fa58d6cdab
ci: Move DEBUG=1 to centos task 2025-05-19 13:59:19 +02:00
Hennadii Stepanov ff1ee102c4
Merge bitcoin/bitcoin#32561: doc: Adjust stale MSVC bug url
fa330a5e38 doc: Adjust stale MSVC bug url (MarcoFalke)

Pull request description:

  The old url is stale, so use the current one. See https://github.com/bitcoin/bitcoin/pull/32552#issuecomment-2889188342

ACKs for top commit:
  hebasto:
    ACK fa330a5e38.

Tree-SHA512: eb7813edb85f4bac06807bf2a35caf106a0faeffcbd0a4732c57edac07db00171f720888dbb7c35fae3fd515408ea7cb8e5dcbd3cf393caec23904cb800b8907
2025-05-19 11:56:47 +01:00
MarcoFalke fa330a5e38
doc: Adjust stale MSVC bug url 2025-05-19 12:30:56 +02:00
merge-script 88791fb97b
Merge bitcoin/bitcoin#32544: scripted-diff: test: remove 'descriptors=True' argument for `createwallet` calls
86de8c1668 scripted-diff: test: remove 'descriptors=True' argument for `createwallet` calls (Sebastian Falbesoner)

Pull request description:

  Descriptor wallets are already created by default [since v23.0](7710a31f0c/doc/release-notes/release-notes-23.0.md?plain=1#L171), but since the recent legacy wallet removal the `descriptors` parameter *must* be True for the `createwallet` RPC (see commit 9f04e02ffa), i.e. still passing it wouldn't contain any information for test readers anymore. So simply drop them in the functional tests in order to reduce code bloat. The only exception is calls to older versions, which happens in `wallet_backwards_compatibility.py` and is explicitly excluded in the scripted diff.

ACKs for top commit:
  Sjors:
    ACK 86de8c1668
  maflcko:
    lgtm ACK 86de8c1668

Tree-SHA512: 1acfae27bd960aeef9e1cf6e3f042752164a4d6869773c42df4c22c03dde0922993a3220fa14d52e75a0ff1f48c5194932b74a21427efbd496b0aaad7a2eafb2
2025-05-19 10:29:38 +01:00
Sjors Provoost e8661aac75
wallet: drop watch-only things from interface 2025-05-19 10:11:18 +02:00
Sjors Provoost e99188e7da
qt: drop unused watch-only functionality
The watch-only functionality in the GUI was only used for legacy wallets.
Watch-only descriptor wallets do not use this.

The only visible changes of this commit are:
- dropped "Spendable:" label from the overview tab
- column width cache is reset
2025-05-19 10:11:18 +02:00
Sjors Provoost 6ee32aaaca
test: signet tool genpsbt and solvepsbt commands
Co-authored-by: Anthony Towns <aj@erisian.com.au>
2025-05-19 09:45:37 +02:00
Sjors Provoost 0a99d99fe4
signet: miner skips PSBT step for OP_TRUE 2025-05-19 09:45:35 +02:00
Sjors Provoost cdfb70e5a6
signet: split decode_psbt miner helper 2025-05-19 09:40:41 +02:00
Ava Chow 4b2cd0b41f test: check that creating a wallet does not log version info 2025-05-18 13:02:19 -07:00
Ava Chow 39a483c8e9 test: Check that the correct versions are logged on wallet load 2025-05-18 13:02:19 -07:00
Ava Chow 359ecd3704 walletdb: Log the wallet version after it has been read from disk
Logging the wallet version before anything has been read from disk results
in the wrong version being logged.

Also split the last client version logging as it may not always be
present to be logged.
2025-05-18 11:59:08 -07:00
Sebastian Falbesoner 86de8c1668 scripted-diff: test: remove 'descriptors=True' argument for `createwallet` calls
Descriptor wallets are already created by default since v23.0, but
since the recent legacy wallet removal this parameter *must* be True
(see commit 9f04e02ffa), i.e. still
passing it wouldn't contain any information for test readers
anymore. So simply drop them in the functional tests in order to
reduce code bloat.

-BEGIN VERIFY SCRIPT-
sed -i 's/, descriptors=True//g' $(git ls-files -- 'test/functional' ':(exclude)test/functional/wallet_backwards_compatibility.py')
sed -i '/descriptors=True,/d' ./test/functional/mempool_persist.py
-END VERIFY SCRIPT-
2025-05-17 18:14:24 +02:00
merge-script 7710a31f0c
Merge bitcoin/bitcoin#32452: test: Remove legacy wallet RPC overloads
b104d44227 test: Remove RPCOverloadWrapper (Ava Chow)
4d32c19516 test: Replace importpubkey (Ava Chow)
fe838dd391 test: Replace usage of addmultisigaddress (Ava Chow)
d314207779 test: Replace usage of importaddress (Ava Chow)
fcc457573f test: Replace importprivkey with wallet_importprivkey (Ava Chow)
94c87bbbd0 test: Remove unnecessary importprivkey from wallet_createwallet (Ava Chow)

Pull request description:

  `RPCOverloadWrapper` implemented overloads for legacy wallet only RPCs so that the same function call could be used within tests for both legacy wallets and descriptor wallets. With legacy wallets now removed, there is no need to continue to have these overloads.

  For `importaddress`, `addmultisigaddress`, and `importpubkey`, the uses of these are converted to `importdescriptors`.

  For `importprivkey`, a new helper function `wallet_imporprivkey` is introduced that does what the overload did. This is mainly to reduce verbosity as `importprivkey` was more widely used throughout the tests.

  Some tests that used these RPCs are now also no longer relevant and have been removed.

ACKs for top commit:
  Sjors:
    ACK b104d44227
  pablomartin4btc:
    cr ACK b104d44227
  rkrux:
    ACK b104d44227
  w0xlt:
    ACK b104d44227

Tree-SHA512: ded2f73829e2ce28466d4a9738eb382783ad990daee5d1859dbc4d354e6f8eec0c483ed5ecb1287fe0dd24ac332065b733a30d71b126b841bd7cd49e9a094b6d
2025-05-17 10:19:35 +01:00
merge-script b81e5076aa
Merge bitcoin/bitcoin#32514: scripted-diff: Remove unused leading newline in RPC docs
fa1f10a49e doc: Fix minor typos in rpc help (MarcoFalke)
fae840e94b rpc: Reject beginning newline in RPC docs (MarcoFalke)
fa414eda08 scripted-diff: Remove unused leading newline in RPC docs (MarcoFalke)

Pull request description:

  It is harmless, but newlines in the beginning read a bit odd ("nReturns"). So just require them to not be present.

  The diff is large, but a trivial scripted-diff.

ACKs for top commit:
  fanquake:
    ACK fa1f10a49e
  w0xlt:
    ACK fa1f10a49e

Tree-SHA512: 5d2f9632f42ec1c02814d050f223941f436e5b0df426d7d6eb93fdd0ff118d57185af07b271dd73af63735dd17231125826c0c9ce0aad36bc8829c5b050a628c
2025-05-17 10:10:35 +01:00
Hennadii Stepanov 3023d7e6ad
Merge bitcoin/bitcoin#32534: Update leveldb subtree to latest upstream
7015052eba build: remove Wsuggest-override suppression from leveldb build (fanquake)
e2c84b896f Squashed 'src/leveldb/' changes from 4188247086..113db4962b (fanquake)

Pull request description:

  Pulls in
  * https://github.com/bitcoin-core/leveldb-subtree/pull/51

  Remove the related warning suppression.

ACKs for top commit:
  l0rinc:
    utACK 7015052eba
  hebasto:
    ACK 7015052eba, I've updated the `leveldb` subtree locally and got zero diff with this branch.

Tree-SHA512: 1ac7c8ecc9025086b429e12c22fc25f654eaf68fc9500b95341fb635cea12e7f80d69298cff120e8557a4f2f5809956a3b158cdb4db745cfa605c0df6f346423
2025-05-17 09:42:01 +01:00
MarcoFalke fa84e6c36c
bitcoin-tx: Reject + sign in MutateTxDel* 2025-05-17 09:36:25 +02:00
MarcoFalke face2519fa
bitcoin-tx: Reject + sign in vout parsing 2025-05-17 09:36:15 +02:00
MarcoFalke fa8acaf0b9
bitcoin-tx: Reject + sign in replaceable parsing 2025-05-17 09:35:11 +02:00
MarcoFalke faff25a558
bitcoin-tx: Reject + sign in locktime 2025-05-17 09:34:59 +02:00
MarcoFalke dddd9e5fe3
bitcoin-tx: Reject + sign in nversion parsing
It would be confusing to specify the sign for an unsigned value here, so
reject it.
2025-05-17 09:34:02 +02:00
MarcoFalke fab06ac037
rest: Use SAFE_CHARS_URI in SanitizeString error msg
When dealing with URI parts, it seems more consistent to use
corresponding SAFE_CHARS_URI mode in error messages.

Co-Authored-By: stickies-v <stickies-v@protonmail.com>
2025-05-17 08:59:19 +02:00
Ava Chow c461d15287
Merge bitcoin/bitcoin#32511: refactor: bdb removals
fafee85358 remove unused GetDestinationForKey (MarcoFalke)
fac72fef27 remove unused GetAllDestinationsForKey (MarcoFalke)
fa91d57de3 remove unused AddrToPubKey (MarcoFalke)
faecf158d9 remove unused Import* function signatures (MarcoFalke)

Pull request description:

  remove dead code

ACKs for top commit:
  davidgumberg:
    crACK fafee85358
  achow101:
    ACK fafee85358
  rkrux:
    crACK fafee85358

Tree-SHA512: e48d4bf5f50b97dbd11260efdaf88277bd6a2478665b84353637d63e783003e90d29718836ffdc2e251ac9b77b22e616a0983a59d1b6658b3645a5575b871eae
2025-05-16 13:28:31 -07:00
furszy 86e1111239
test: verify node skips loading legacy wallets during startup 2025-05-16 15:36:27 -04:00
Matthew Zipkin 12ff4be9c7
test: ensure -rpcallowip is compatible with RFC4193 2025-05-16 15:25:30 -04:00
Matthew Zipkin c02bd3c187
config: Explain RFC4193 and CJDNS interaction in help and init error 2025-05-16 15:10:18 -04:00
Matthew Zipkin f728b6b111
init: Configure reachable networks before we start the RPC server
We need to determine if CJDNS is reachable before we parse any IPv6
addresses (for example, by the -rpcallowip setting) or an RFC4193
address might get flipped to CJDNS, which can not be used with subnets
2025-05-16 15:10:13 -04:00
merge-script b15c386933
Merge bitcoin/bitcoin#32519: ci: Enable feature_init and wallet_reorgsrestore in valgrind task
fa2be605fe ci: Enable feature_init and wallet_reorgsrestore in valgrind task (MarcoFalke)

Pull request description:

  The `fork()` isn't needed and in fact makes the forked process not react to signals (like kill or terminate), so just avoid it and run the valgrind process directly in the CI task.

  Can be tested with something like:

  `env -i HOME="$HOME" PATH="$PATH" USER="$USER" MAKEJOBS="-j$(nproc)" FILE_ENV="./ci/test/00_setup_env_native_valgrind.sh" ./ci/test_run_all.sh`

ACKs for top commit:
  fanquake:
    ACK fa2be605fe - x86_64, aarch64

Tree-SHA512: 6293447d501191598c08f0cb9fcb4ed91e4cfec11255e702a926346ef8011d6ebc0ca12e9a1c14fa53541318c4e05dee5c96dfe965dcf4cf833c9392158ab883
2025-05-16 18:01:07 +01:00
fanquake 7015052eba
build: remove Wsuggest-override suppression from leveldb build 2025-05-16 16:08:40 +01:00
Sebastian Falbesoner 7bc64a8859 test: properly check for per-tx sigops limit
Currently the per-tx sigops limit standardness check (bounded by
`MAX_STANDARD_TX_SIGOPS_COST`, throwing "bad-txns-too-many-sigops"
if exceeded) is only indirectly tested with the much higher per-block
consensus limit (`MAX_BLOCK_SIGOPS_COST`), i.e. an increase in the
limit would still pass all tests. Refine that by splitting up the invalid
tx template `TooManySigops` in a per-block and a per-tx one.

The involved functional tests taking use of these templates are
`feature_block.py` and `p2p_invalid_txs.py`.
2025-05-16 16:35:42 +02:00
merge-script 3f83c744ac
Merge bitcoin/bitcoin#32526: fuzz: Delete wallet_notifications
fad2faf6c5 fuzz: Delete wallet_notifications (MarcoFalke)

Pull request description:

  The fuzz target has many issues:

  * It has never found a meaningful issue.
  * It is still slow, despite https://github.com/bitcoin/bitcoin/pull/28933 and https://github.com/bitcoin/bitcoin/pull/31238.
  * It is unmaintained, see https://github.com/bitcoin/bitcoin/pull/28882#issuecomment-1814654792 (missing meaningful coverage) or https://github.com/bitcoin/bitcoin/pull/31238#issuecomment-2460821784 (unstable) or https://github.com/bitcoin/bitcoin/pull/31467#issuecomment-2672649759 (fix slowness), etc ...

  So remove it for now. It can be added back once one or all of the issues have been addressed.

ACKs for top commit:
  fanquake:
    ACK fad2faf6c5
  brunoerg:
    ACK fad2faf6c5

Tree-SHA512: e48c08352688c0eead5793ee1c7513ddd37459bc665e914a770a3f69772674ed0e14c05e5d07b333ca0ab03bb35d7d9d32561311af569958e19dc4607c11fade
2025-05-16 13:43:01 +01:00
MarcoFalke fa1f10a49e
doc: Fix minor typos in rpc help 2025-05-16 14:17:55 +02:00
fanquake e2c84b896f Squashed 'src/leveldb/' changes from 4188247086..113db4962b
113db4962b Merge bitcoin-core/leveldb-subtree#51: refactor: add missing overrides
9defe8494a refactor: add missing overrides

git-subtree-dir: src/leveldb
git-subtree-split: 113db4962b8be416c17ad2b4bdcc5514c51d7181
2025-05-16 12:39:59 +01:00
fanquake 0769c8fc99
Update leveldb subtree to latest upstream 2025-05-16 12:39:59 +01:00
merge-script 04c6c961b6
Merge bitcoin/bitcoin#32527: test: Remove unused verify_flags suppression
fab5a3c803 test: Remove unused verify_flags suppression (MarcoFalke)

Pull request description:

  `static bool verify_flags(unsigned)` was removed in commit 80f8b92f4f

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

Tree-SHA512: da0cfc6ee253419c0aef316cd9c8366b744231261b755a95618ca0e777c1d95cecba8199db5486fd35079ded89c64c1a9f5b056f01dada4176b815b0d97261b7
2025-05-16 11:55:03 +01:00
merge-script 742b30549f
Merge bitcoin/bitcoin#32491: build: document why we check for `std::system`
8f4ba90b8f build: document why we check for std::system (fanquake)

Pull request description:

  It's probably debatable if we support targets like iOS, but for now, document why we are checking for this standard library feature.

  Trying to use `std::system` for a `aarch64-darwin-ios` target results in:
  ```bash
  test.cpp:7:10: error: 'system' is unavailable: not available on iOS
      7 |     std::system("some_command");
        |          ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdlib.h:203:6: note: 'system' has been explicitly marked unavailable here
    203 | int      system(const char *) __DARWIN_ALIAS_C(system);
        |          ^
  1 error generated.
  ```

ACKs for top commit:
  Sjors:
    ACK 8f4ba90b8f

Tree-SHA512: 219cac205b36004c607194f6956c2ce6153f192bd4349e505b52c4e511e403e195ce0f462ae10c515e67f1e95d4b1636d526c8e4376004044853b574a84df427
2025-05-16 11:46:55 +01:00
MarcoFalke fab5a3c803
test: Remove unused verify_flags suppression 2025-05-16 11:17:49 +02:00
merge-script c521192d8b
Merge bitcoin/bitcoin#32485: Update minisketch subtree
bf25a0918f Squashed 'src/minisketch/' changes from d1e6bb8bbf..ea8f66b1ea (fanquake)

Pull request description:

  Includes:
  * https://github.com/bitcoin-core/minisketch/pull/89
  * https://github.com/bitcoin-core/minisketch/pull/94 (in #32482)

ACKs for top commit:
  maflcko:
    lgtm ACK 46b533dfe6
  willcl-ark:
    ACK 46b533dfe6

Tree-SHA512: 7655aa480381c711fd3397fc7031be4619d5bd67f9d68f7e69f5f903734e776b97f7a2384257b365fc4e1f504b9c97acfd4a355840d1064d4c2c2f259070f4ef
2025-05-16 10:04:19 +01:00
merge-script 3afde679c3
Merge bitcoin/bitcoin#32296: refactor: reenable `implicit-integer-sign-change` check for `serialize.h`
516f0689b5 refactor: re-enable UBSan implicit-sign-change in serialize.h (Lőrinc)
5827e93507 refactor: use consistent size type for serialization template parameters (Lőrinc)

Pull request description:

  Inspired by https://github.com/bitcoin/bitcoin/pull/32154, the main goal of this PR is to reenable sanitizer checks for `serialize.h` since it's modified in a few other PRs.

ACKs for top commit:
  maflcko:
    review ACK 516f0689b5 🎈
  stickies-v:
    ACK 516f0689b5, nice cleanup!

Tree-SHA512: 63da9bf1988a5b68e3c053b0ed786b8735f8f75b05763511522d1601b728b55798006e063137447615c266582622642d3226318fa83e488bd363f1756f8811e8
2025-05-16 09:51:30 +01:00
merge-script 5af757bb78
Merge bitcoin/bitcoin#32505: depends: bump to latest config.guess and config.sub
486bc91790 depends: bump to latest config.sub (Sebastian Falbesoner)
6880383427 depends: bump to latest config.guess (Sebastian Falbesoner)

Pull request description:

  Noticed that these files were last updated from [upstream](https://git.savannah.gnu.org/gitweb/?p=config.git) quite a while ago (in 2023, see #28781), so bump them again.

  Can be verified via e.g.
  ```
  $ git clone https://git.savannah.gnu.org/git/config.git /tmp/config.git
  $ diff /tmp/config.git/config.guess ./depends/config.guess
  $ diff /tmp/config.git/config.sub ./depends/config.sub
  ```

ACKs for top commit:
  fanquake:
    ACK 486bc91790

Tree-SHA512: cbfd21a351a2404e5821610b6ef84d1050ea1a8045da8bfb535ef1ed49b5ad3f4140e8332d1eed545332f96d3117adc531d73aa83e19e7154fe382d041102c93
2025-05-16 09:35:19 +01:00
merge-script c60455a645
Merge bitcoin/bitcoin#32500: init: drop `-upnp`
301993ebf7 init: drop -upnp (fanquake)

Pull request description:

  This was slated for removal in `30.0`, so remove it.

ACKs for top commit:
  i-am-yuvi:
    ACK 301993ebf7
  maflcko:
    review ACK 301993ebf7
  darosior:
    tACK 301993ebf7

Tree-SHA512: 635e374c013fa08c4cda7caadc465c89bb376d3ee2c66f67a27e3ed9031844674d3e996169aaffb9b65a67b0d44d92aaec000aaf69abe3dd10fce2f4138f3e27
2025-05-16 09:31:45 +01:00
merge-script e230affaa3
Merge bitcoin/bitcoin#32396: cmake: Add application manifests when cross-compiling for Windows
8f4fed7ec7 symbol-check: Add check for application manifest in Windows binaries (Hennadii Stepanov)
2bb6ab8f1b ci: Add "Get bitcoind manifest" steps to Windows CI jobs (Hennadii Stepanov)
282b4913c7 cmake: Add application manifests when cross-compiling for Windows (Hennadii Stepanov)

Pull request description:

  Windows [application manifests ](https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests) provide several benefits—such as enhanced security settings, and the ability to set a process-wide code page (required for https://github.com/bitcoin/bitcoin/pull/32380), as well as granular control over supported Windows versions. Most of these benefits lie beyond the scope of this PR and will be evaluated separately.

  On the current master branch @ fc6346dbc8, the linker generates and embeds a manifest only when building with MSVC:
  ```xml
  <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
      <security>
        <requestedPrivileges>
          <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
        </requestedPrivileges>
      </security>
    </trustInfo>
  </assembly>
  ```

  However, this manifest fails validation:
  ```
  > mt.exe -nologo -inputresource:build\bin\Release\bitcoind.exe -validate_manifest

  mt.exe : general error 10100ba: The manifest is missing the definition identity.
  ```

  This PR unifies manifest embedding for both native and cross-compilation builds.

  Here is the change in the manifest on Windows:
  ```diff
  --- bitcoind-master.manifest
  +++ bitcoind-pr.manifest
  @@ -1,5 +1,6 @@
   <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
   <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  +  <assemblyIdentity type="win32" name="org.bitcoincore.bitcoind" version="29.99.0.0"></assemblyIdentity>
     <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
       <security>
         <requestedPrivileges>
  ```

  which effectively resolves the "missing the definition identity" error.

  Finally, “Get bitcoind manifest” steps have been added to the Windows CI jobs to ensure the manifest is embedded and validated.

ACKs for top commit:
  sipsorcery:
    re-tACK 8f4fed7ec7.
  hodlinator:
    re-ACK 8f4fed7ec7
  davidgumberg:
    Reviewed and tested ACK 8f4fed7ec7

Tree-SHA512: 6e2dbdc77083eafdc242410eb89a6678e37b11efd786505dcd7844f0bac8f44d68625e62924a03b26549bdb4aaec5330dc608e6b4d66789f0255092e23aef6cb
2025-05-16 09:19:13 +01:00
merge-script 51be79c42b
Merge bitcoin/bitcoin#32238: qt, wallet: Convert uint256 to Txid
0671d66a8e wallet, refactor: Convert uint256 to Txid in wallet (marcofleon)
c8ed51e62b wallet, refactor: Convert uint256 to Txid in wallet interfaces (marcofleon)
b3214cefe6 qt, refactor: Convert uint256 to Txid in the GUI (marcofleon)

Pull request description:

  This is part of https://github.com/bitcoin/bitcoin/pull/32189.

  Converts all instances of transactions from `uint256` to `Txid` in the wallet, GUI, and related interfaces.

ACKs for top commit:
  stickies-v:
    re-ACK 0671d66a8e, no changes since 65fcfbb2b38bef20a58daa6c828c51890180611d except rebase.
  achow101:
    ACK 0671d66a8e
  furszy:
    Code review ACK 0671d66a8e

Tree-SHA512: 9fd4675db63195c4eed2d14c25015a1821fb597f51404674e4879a44a9cf18f475021a97c5f62f3926b7783ade5a38567386f663acba9f5861f1f59c1309ed60
2025-05-16 08:54:45 +01:00
merge-script f96ae941a1
Merge bitcoin/bitcoin#32525: build: Revert "Temporarily disable compiling `fuzz/utxo_snapshot.cpp` with MSVC
fa2c662362 build: Revert "Temporarily disable compiling `fuzz/utxo_snapshot.cpp` with MSVC" (MarcoFalke)

Pull request description:

  Now that GitHub Actions has a fixed version and the Windows developers have updated their compiler, the workaround is no longer needed.

ACKs for top commit:
  davidgumberg:
    reACK fa2c662362
  hodlinator:
    ACK fa2c662362

Tree-SHA512: 952b36c917c91d78d82b5013e1df338b23f860fad7be43327150581f403050e61f748fc75557ec96fb2b115a2cc0246a506bc2ddc25e05f5a41339bd466c4b1a
2025-05-16 08:48:50 +01:00
MarcoFalke fad2faf6c5
fuzz: Delete wallet_notifications 2025-05-16 09:26:42 +02:00
Hodlinator bf950c4544
qa: Improve suppressed errors output
Original discussion: https://github.com/bitcoin/bitcoin/pull/30660#discussion_r2080132673
2025-05-16 09:20:51 +02:00
Hodlinator 075352ec8e
qa: assert_raises_message() - search in str(e)
repr() is annoying because it requires escaping special characters, use str() instead.

Original discussion: https://github.com/bitcoin/bitcoin/pull/30660#discussion_r2080292165
2025-05-16 09:20:51 +02:00
Hodlinator bd8ebbc4ab
qa: Make --timeout-factor=0 result in a smaller factor
Would otherwise cause an OverflowError in feature_framework_startup_failures.py when calling subprocess.run() with 60 * factor.

Fixes #32506

Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
2025-05-16 09:20:51 +02:00
MarcoFalke fa2c662362
build: Revert "Temporarily disable compiling `fuzz/utxo_snapshot.cpp` with MSVC"
This reverts commit b2d5361002.

Also, adjust the doc to reflect the new minimum version. Versions 17.6
or 17.11 (or anything in between) may still work on a best-effor basis,
but it is not checked by CI or by developers.
2025-05-16 09:12:00 +02:00
MarcoFalke 8888bb499d
rest: Reject + sign in /blockhashbyheight/ 2025-05-15 22:51:15 +02:00
MarcoFalke fafd43c691
test: Reject + sign when parsing regtest deployment params
The + sign does not make sense for times or heights.
2025-05-15 22:12:24 +02:00
MarcoFalke fa123afa0e
Reject + sign when checking -ipcfd 2025-05-15 22:12:15 +02:00
MarcoFalke fa479857ed
Reject + sign in SplitHostPort
It is better to reject it with an error. For example,

$ bitcoin-cli -rpcconnect=127.0.0.1:+23501 -getinfo
error: Invalid port provided in -rpcconnect: 127.0.0.1:+23501
2025-05-15 22:12:14 +02:00
MarcoFalke fab4c2967d
net: Reject + sign when parsing subnet mask
It does not make sense and it is rejected by other parsers as well:

>>> ipaddress.ip_network("1.2.3.0/+24")
ValueError: '1.2.3.0/+24' does not appear to be an IPv4 or IPv6 network
2025-05-15 22:11:52 +02:00
MarcoFalke fa89652e68
init: Reject + sign in -*port parsing
It would be confusing to specify the sign for an unsigned value here, so
reject it.
2025-05-15 22:11:46 +02:00
furszy 9f94de5bb5
wallet: init, don't error out when loading legacy wallets
Instead of failing during initialization when encountering a legacy wallet, skip
loading the wallet and notify the user accordingly.

This allows users to access migration functionalities without needing to manually
remove the wallet from settings.json or resort to using the bitcoin-wallet utility.

This means that GUI users will be able to use the migration button, and bitcoin-cli
users will be able to call the migratewallet RPC directly after init.
2025-05-15 15:14:29 -04:00
MarcoFalke fa9c45577d
cli: Reject + sign in -netinfo level parsing
It would be confusing to specify the sign for an unsigned value here, so
reject it.
2025-05-15 19:48:38 +02:00
MarcoFalke fa98041325
refactor: Use ToIntegral in CreateFromDump
The unsigned version is never serialized with a `+` prefix, so the
stricter ToIntegral can be used.
2025-05-15 19:34:08 +02:00
MarcoFalke fa23ed7fc2
refactor: Use ToIntegral in ParseHDKeypath
ToIntegral<uint32_t> only accepts numbers, so just use that to replace
the equivalent but more verbose way with find_first_not_of+ParseUInt32.
2025-05-15 19:33:58 +02:00
MarcoFalke fa2be605fe
ci: Enable feature_init and wallet_reorgsrestore in valgrind task 2025-05-15 17:59:50 +02:00
merge-script 725c9f7780
Merge bitcoin/bitcoin#31895: doc: Improve `dependencies.md`
e62423d6f1 doc: Improve dependencies.md documentation (Nicola Leonardo Susca)
a3520f9d56 doc: Add dependency self-compilation info (Nicola Leonardo Susca)
d1fdc84c54 doc: Remove Linux Kernel from dep. table (Nicola Leonardo Susca)

Pull request description:

  Small improvements to the `dependencies.md` documentation as a follow-up for #31634.

  **Linux Kernel** does not need to be in the dependencies as it is not required for cross-compiling from other systems, and users building on Linux should not expect they can build using any EOL kernel, see: https://github.com/bitcoin/bitcoin/pull/31634#discussion_r1957123270

  **Runtime dependencies** can be in a separate table to improve readability. See: https://github.com/bitcoin/bitcoin/pull/31634#issuecomment-2589412550

  **Version used** is redundant as the depends package definition is already linked in the table and can thus be removed, see: https://github.com/bitcoin/bitcoin/pull/31895#discussion_r2063356972

ACKs for top commit:
  maflcko:
    lgtm ACK e62423d6f1 🛄
  hebasto:
    ACK e62423d6f1.
  jonatack:
    ACK e62423d6f1

Tree-SHA512: 586c450aec7ece5d543bcb12796a2bb7ff459e15c8813a7b5104a38d09fc51e7e902363ff023be48273ae2b1a1b0807a439c8523b4ea2e398b76b7c9a48d0dfb
2025-05-15 16:58:35 +01:00
merge-script bdc1cef1de
Merge bitcoin/bitcoin#32507: ci: Exclude failing wallet_reorgsrestore.py from valgrind task for now
fa981b90f5 ci: Exclude failing wallet_reorgsrestore.py from valgrind task for now (MarcoFalke)

Pull request description:

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

  For some reason terminate or kill do not work inside the CI system under valgrind.

  So disable the test for now, until a solution is found.

ACKs for top commit:
  fanquake:
    ACK fa981b90f5
  mzumsande:
    utACK fa981b90f5

Tree-SHA512: ce591fa7ffffbf757e2c15744e36a9e57300edf743400938e49fd02291f3977c551a3af1635bc7a6ccc1900d5ea150a64ee2ace46c1d765019ab11bd51035139
2025-05-15 16:24:42 +01:00
MarcoFalke fae840e94b
rpc: Reject beginning newline in RPC docs
It is harmless, but a bit confusing and not needed for new code.

Also, update the remaining instances that were not found by the
scripted-diff.
2025-05-15 16:34:27 +02:00
Nicola Leonardo Susca e62423d6f1
doc: Improve dependencies.md documentation
- Remove the "Version used" column from the dependencies tables as the
  depends package definition which defines the version used is already
  linked. In case a developer is interested in which PR introduced this
  file/version they can use `git blame` on the package definition as
  usual. This removes doc. maintenance overhead and eliminates the risk
  of stale information about the "Version used", see comment:
  https://github.com/bitcoin/bitcoin/pull/31895#discussion_r2063356972

- Separate dependency tables into build-time and run-time tables for
  easier distinction of the two and to avoid repeating the same
  information ("No"/"Yes") for better readability.

- Order dependencies alphabetically
2025-05-15 16:08:47 +02:00
Nicola Leonardo Susca a3520f9d56
doc: Add dependency self-compilation info
The `dependencies.md` should mention that it is possible to self-compile
the dependencies and reference `depends/README.md` for instructions.
Also mention full path to `/doc/build-*.md` for clarity.
2025-05-15 16:08:39 +02:00
Nicola Leonardo Susca d1fdc84c54
doc: Remove Linux Kernel from dep. table
Linux Kernel is neither an optional nor a required dependency for
Bitcoin Core.
2025-05-15 16:08:33 +02:00
nervana21 135a0f0aa7
doc: Add missing top-level description to pruneblockchain RPC
Previously, the `pruneblockchain` RPC help output included only the method signature and arguments, with no top-level description explaining its purpose or constraints.

This PR adds a concise top-level description, improving documentation consistency and alerting users to the potential impacts of using the command.
2025-05-15 09:42:40 -04:00
MarcoFalke fa414eda08
scripted-diff: Remove unused leading newline in RPC docs
-BEGIN VERIFY SCRIPT-
 perl -0777 -pi -e 's/RPCHelpMan{\s*("[^"]+"),\s*"\\n/RPCHelpMan{\n        \1,\n        "/g' $( git grep -l 'RPCHelpMan{' )
-END VERIFY SCRIPT-
2025-05-15 15:28:11 +02:00
MarcoFalke fafee85358
remove unused GetDestinationForKey
It is only used in test. There it is problematic, because it sometimes
relies on m_default_address_type. If the default were changed to
BECH32M, those tests would fail the assert(false).

So just use PKHash{} in all tests and remove GetDestinationForKey.
2025-05-15 14:59:03 +02:00
MarcoFalke fac72fef27
remove unused GetAllDestinationsForKey 2025-05-15 14:58:39 +02:00
MarcoFalke fa91d57de3
remove unused AddrToPubKey 2025-05-15 14:58:17 +02:00
Hennadii Stepanov 8f4fed7ec7 symbol-check: Add check for application manifest in Windows binaries
Check that the application manifest is present in all binaries.

Co-authored-by: laanwj <126646+laanwj@users.noreply.github.com>
2025-05-15 13:58:13 +01:00
Hennadii Stepanov 2bb6ab8f1b ci: Add "Get bitcoind manifest" steps to Windows CI jobs
This change makes it easy to verify any changes in the application
manifests.
2025-05-15 13:58:05 +01:00
Hennadii Stepanov 282b4913c7 cmake: Add application manifests when cross-compiling for Windows
Windows application manifests provide several benefits. However, on the
master branch, the linker generates and embeds manifests only when
building with MSVC.

This change unifies manifest embedding for both native and
cross-compilation.
2025-05-15 13:57:57 +01:00
MarcoFalke faecf158d9
remove unused Import* function signatures 2025-05-15 14:57:14 +02:00
Hodlinator d8f05e7bf3
qa: Fix dormant bug caused by multiple --tmpdir
We would only modify the parent process' first --tmpdir arg.

Now we tack on an additional --tmpdir after the parent's arguments. Also simplifies the code.

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2025-05-15 13:33:00 +02:00
MarcoFalke fa981b90f5
ci: Exclude failing wallet_reorgsrestore.py from valgrind task for now 2025-05-15 12:57:30 +02:00
merge-script c779ee3a40
Merge bitcoin/bitcoin#32492: test: add skip_if_running_under_valgrind()
75a185ea3d test: add skip_if_running_under_valgrind() (fanquake)

Pull request description:

  Enable it in the USDT tests. The context (from 0xB10C):

  > every time the tracepoint is reached a SIGTRAP is fired.
  > No matter the tracepoint contents, even with an empty one.
  > Valgrind intercepts SIGTRAP and aborts.

  See discussion in #32374.

ACKs for top commit:
  maflcko:
    lgtm ACK 75a185ea3d
  willcl-ark:
    ACK 75a185ea3d

Tree-SHA512: 7f45c3049ab39cc514024067bd6ac26598e99202c114b48459834c26c2e1273fa58af693878298e628a10c561b954850e49e76b39567b771bb0c0534a063a524
2025-05-15 10:17:50 +01:00
merge-script 89c7b6b97a
Merge bitcoin/bitcoin#32498: doc: remove Carls substitute server from Guix docs
3b824169c7 doc: remove Carls substitute server from Guix docs (fanquake)

Pull request description:

  This no-longer exists. Use one of the other Guix servers in the example.

ACKs for top commit:
  achow101:
    ACK 3b824169c7
  hebasto:
    ACK 3b824169c7, the listed substitute servers are the same as in https://guix.gnu.org/manual/en/html_node/Official-Substitute-Servers.html.

Tree-SHA512: dc3a362ccaa9ce8039d3c02158de9cd71082eb4dd790368bfb11c2942a5aae57e67779b5ff3108b532c4fb765811bd9e145eedb390fc48b52b43d334d5864865
2025-05-15 09:39:42 +01:00
David Gumberg 6b4bcc1623 random: Use modern Windows randomness functions
The old randomness API has been deprecated and may be removed soon.[^1]

For reference on `BCryptGenRandom`, see: https://learn.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom.

`STATUS_SUCCESS`[^2] gets defined here since including `ntstatus.h` is
more trouble than it's worth. [^3]

[^1]: https://learn.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptacquirecontextw & https://learn.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptgenrandom
[^2]: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/596a1078-e883-4972-9bbc-49e60bebca55
[^3]: See 70f149b9a1/examples/examples_util.h (L19-L28)
2025-05-14 22:55:10 -07:00
Ava Chow 31d3eebfb9
Merge bitcoin/bitcoin#32343: common: Close non-std fds before exec in RunCommandJSON
a0eed55398 run_command: Enable close_fds option to avoid lingering fds (Luke Dashjr)
c7c356a448 cpp-subprocess: Iterate through /proc/self/fd for close_fds option on Linux (Luke Dashjr)
4f5e04da13 Revert "remove unneeded close_fds option from cpp-subprocess" (Luke Dashjr)

Pull request description:

  Picks up stale #30756, while addressing my fallback comment (https://github.com/bitcoin/bitcoin/pull/30756#discussion_r2030844440).

  > Currently, RunCommandParseJSON runs its target with whatever fds happen to be open inherited on POSIX platforms. I don't think there's any practical scenario where this is a problem right now, but there's a lot of potential for weird problems (eg, if a process manages to outlive bitcoind - perhaps it's hanging - the listening port(s) won't get released and starting bitcoind again will fail). It's also a potential security issue if a child process is intended to be sandboxed at some point. Not to mention plain ugly :)
  >
  > cpp-subprocess has a feature to address this called close_fds. Not sure why it was removed in https://github.com/bitcoin/bitcoin/pull/29961 rather than fixing this during the migration, but this PR restores it, enables it for RunCommandParseJSON, and optimises it by iterating over /proc/self/fd/ like most other libraries do these days ([eg, glib]> (487b1fd20c/glib/gspawn.c (L1094))) since iterating all possible fd numbers [has been found to be problematic](https://bugzilla.redhat.com/show_bug.cgi?id=1537564).
  >
  > (Equivalent to https://github.com/bitcoin/bitcoin/pull/22417 was for boost::process)

ACKs for top commit:
  achow101:
    ACK a0eed55398
  hebasto:
    ACK a0eed55398, tested on Ubuntu 25.04:
  vasild:
    ACK a0eed55398

Tree-SHA512: 7dc1cb6cc1f45ff7c4f53512e400baad1a033b4ebf14ba6f6ffa38588314932d6d01ef67b197f081e8202bb802659ac6a87998277797721d6d7b20efde8e9a6b
2025-05-14 16:13:59 -07:00
Sebastian Falbesoner 486bc91790 depends: bump to latest config.sub
Upstream commit 00b15927496058d23e6258a28d8996f87cf1f191
from https://git.savannah.gnu.org/git/config.git
2025-05-15 00:19:07 +02:00
Sebastian Falbesoner 6880383427 depends: bump to latest config.guess
Upstream commit 00b15927496058d23e6258a28d8996f87cf1f191
from https://git.savannah.gnu.org/git/config.git
2025-05-15 00:16:14 +02:00
Ava Chow 4b26ca0e2f
Merge bitcoin/bitcoin#32502: wallet: Drop unused fFromMe from CWalletTx
5bf91ba880 wallet: Drop unused fFromMe from CWalletTx (David Gumberg)

Pull request description:

  This has been unused since commit fe52346, this is a re-opening of #9351.

ACKs for top commit:
  maflcko:
    lgtm ACK 5bf91ba880
  achow101:
    ACK 5bf91ba880

Tree-SHA512: b9a84f27b6cfe7796dcf629be6a8e01a97d931ea81ef088951d54d6691ffe79d22138baacc632375093cf3176a22c265e30a80f1f63c3bc620d08bf16f6a488f
2025-05-14 15:05:43 -07:00
Ava Chow d5786bc19a
Merge bitcoin/bitcoin#32490: refactor: Remove UB in prevector reverse iterators
faf9082a5f test: Fix whitespace in prevector_tests.cpp (MarcoFalke)
fa7f04c8a7 refactor: Remove UB in prevector reverse iterators (MarcoFalke)

Pull request description:

  `rend()` creates a pointer with offset `-1`. This is UB, according to the C++ standard: https://eel.is/c++draft/expr.add#4:

      When an expression J that has integral type is added to [...] an
      expression P of pointer type, the result has the type of P.

      ... if P points to a (possibly-hypothetical) array element i of an
      array object x with n elements [...] the expressions P + J and J + P
      (where J has the value j) point to the (possibly-hypothetical) array
      element i+j of x if 0≤i+j≤n [...]

      Otherwise, the behavior is undefined.

  Also, it is unclear why the functions exist at all, when stdlib utils such as `std::reverse_iterator{it}` or `std::views::reverse` can be used out of the box.

  So remove them, along with the ubsan suppressions, that are no longer used.

  I've tagged this a refactor, because the code was always dead (unused outside of tests). And since commit 2925bd537c it was completely dead. Also, I could not find a sanitizer that detects this type of UB.

ACKs for top commit:
  l0rinc:
    tested ACK faf9082a5f
  achow101:
    ACK faf9082a5f
  stickies-v:
    ACK faf9082a5f, nice find.
  theuni:
    utACK faf9082a5f

Tree-SHA512: 31511d520a1c0fdd65c2e5f1a8ef6fd17464303b6bff88a5d9d9577adfee849d431deb510882b6f4e15e8fb7168861bc0d26fca3bed4278f57a9d6e7b1235dce
2025-05-14 14:34:32 -07:00
Ava Chow ee045b61ef rpc, psbt: Require sighashes match for descriptorprocesspsbt 2025-05-14 14:00:43 -07:00
Ava Chow 2b7682c372 psbt: use sighash type field to determine whether to remove non-witness utxos
Since the sighash type field is written for atypical sighash types, we
can look at that field to figure out whether the psbt contains
unnecessary transactions.
2025-05-14 14:00:43 -07:00
Ava Chow 28781b5f06 psbt: Add sighash types to PSBT when not DEFAULT or ALL
When an atypical sighash type is specified by the user, add it to the
PSBT so that further signing can enforce sighash type matching.
2025-05-14 14:00:43 -07:00
Ava Chow 15ce1bd73f psbt: Enforce sighash type of signatures matches psbt
BIP 174 states that the sighash type of all signatures must match the
type given by the PSBT, so do that.
2025-05-14 14:00:43 -07:00
Ava Chow 1f71cd337a wallet: Remove sighash type enforcement from FillPSBT 2025-05-14 14:00:43 -07:00
Ava Chow 4c7d767e49 psbt: Check sighash types in SignPSBTInput and take sighash as optional 2025-05-14 14:00:43 -07:00
Ava Chow a118256948 script: Add IsPayToTaproot() 2025-05-14 14:00:43 -07:00
Ava Chow d6001dcd4a wallet: change FillPSBT to take sighash as optional
Instead of having the caller have to figure out the correct sane default
to provide to FillPSBT, have FillPSBT do that by having it take the
sighash type as an optional. This further allows it to distinguish
between an explicit sighash type being provided and expecting the
default value to be used.
2025-05-14 14:00:43 -07:00
Ava Chow e58b680923 psbt: Return PSBTError from SignPSBTInput
SignPSBTInput will need to report the specific things that caused an
error to callers, so change it to return a PSBTError. Additionally some
callers will now check the return value and report an error to the user.

Currently, this should not change any behavior as the things that
SignPBSTInput will error on are all first checked by its callers.
2025-05-14 14:00:43 -07:00
Ava Chow 2adfd81532 tests: Test PSBT sighash type mismatch 2025-05-14 14:00:42 -07:00
Ava Chow 5a5d26d612 psbt: Require ECDSA signatures to be validly encoded
Needed for later validation of sighash types.
2025-05-14 14:00:23 -07:00
Ava Chow 53eb5593f0
Merge bitcoin/bitcoin#32305: test: add test for decoding PSBT with MuSig2 PSBT key types (BIP 373)
4b24186756 test: add test for decoding PSBT with MuSig2 PSBT key types (BIP 373) (Sebastian Falbesoner)
8ba245cb83 test: add constants for MuSig2 PSBT key types (BIP 373) (Sebastian Falbesoner)

Pull request description:

  This PR is a follow-up to #31247 (see https://github.com/bitcoin/bitcoin/pull/31247#pullrequestreview-2427834909) and adds a functional test for decoding PSBTs (using the `decodepsbt` RPC) with MuSig2 per-input and per-output types. The first commit adds the new MuSig2 key types to the test frameworks and extends the PSBT serialization to cope with lists of bytestrings.

ACKs for top commit:
  achow101:
    ACK 4b24186756
  rkrux:
    re-ACK 4b24186

Tree-SHA512: f12919f71b3fff74df1d7ddaa8db455b1b139f7abd51d7f3fa5d750fc7dd613454b438c4e0dedad679476d414fa1da43ef1121e486b0bdfd97d5ef8bdf37f060
2025-05-14 13:19:43 -07:00
Ava Chow e7a9372376
Merge bitcoin/bitcoin#32378: interfaces: refactor: move `Mining` and `BlockTemplate` implementation to miner
62fc42d475 interfaces: refactor: move `waitTipChanged` implementation to miner (ismaelsadeeq)
c39ca9d4f7 interfaces: move getTip implementation to miner (Sjors Provoost)
720f201e65 interfaces: refactor: move `waitNext` implementation to miner (ismaelsadeeq)
e6c2f4ce7a interfaces: refactor: move `submitSolution` implementation to miner (ismaelsadeeq)
02d4bc776b interfaces: remove redundant coinbase fee check in `waitNext` (ismaelsadeeq)

Pull request description:

  #### Motivation

  In  [Internal interface guidelines](https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#internal-interface-guidelines)

  It's stated that

  > Interface method definitions should wrap existing functionality instead of implementing new functionality. Any substantial new node or wallet functionality should be implemented in [src/node/](https://github.com/bitcoin/bitcoin/blob/master/src/node) or [src/wallet/](https://github.com/bitcoin/bitcoin/blob/master/src/wallet) and just exposed in [src/interfaces/](https://github.com/bitcoin/bitcoin/blob/master/src/interfaces) instead of being implemented there, so it can be more modular and accessible to unit tests.

  However the some methods in the newly added  `BlockTemplateImpl` and `MinerImpl`  classes partially enforces this guideline, as the implementations of the `submitSolution`, `waitNext`, and `waitTipChanged` methods reside within the class itself.

  #### What the PR Does

  This PR introduces a simple refactor by moving certain method implementations from `BlockTemplateImpl` into the miner module. It introduces three new functions:

  1.  Remove rundundant coinbase fee check in `waitNext`
  2. **`AddMerkleRootAndCoinbase`**: Computes the block's Merkle root, inserts the coinbase transaction, and sets the Merkle root in the block. This function is called by `submitSolution` before the block is submitted for processing.

  3. **`WaitAndCreateNewBlock`**: Returns a new block template either when transaction fees reach a certain threshold or when a new tip is detected. If a timeout is reached, it returns `nullptr`. The `waitNext` method in `BlockTemplateImpl` now simply wraps this function.
  4. Move `GetTip` implementation to miner.

  5. **`WaitTipChanged`**: Returns the tip when the chain it changes, or `nullopt` if a timeout or interrupt occurs. The `waitTipChanged` method in `MinerImpl` now calls `GetTip` after invoking `ChainTipChanged`, and returns the tip.

  #### Behavior Change

  - We now only `Assert` for  a valid chainman and notifications pointer once.

ACKs for top commit:
  achow101:
    ACK 62fc42d475
  Sjors:
    ACK 62fc42d475
  ryanofsky:
    Code review ACK 62fc42d475. Lots of suggest suggest changes made since last review, altering function names and signatures and also adding new commit to drop negative fee handling. I like the idea of making the wait function return a BlockRef, that is clearer than what I suggested. Left some comments below but they are not important and this looks good as-is

Tree-SHA512: 502632f94ced81f576b2c43cf015f1527e2c259e6ca253f670f5a6889171e2246372b4e709575701afa3f01d488d6633557fef54f48fe83bbaf1836ac5326c4f
2025-05-14 12:57:50 -07:00
David Gumberg 5bf91ba880 wallet: Drop unused fFromMe from CWalletTx
This has been unused since commit fe52346, previously attempted to be
removed in PR #9351 (https://github.com/bitcoin/bitcoin/pull/9351/)

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2025-05-14 11:23:22 -07:00
Ava Chow 30a94b1ab9 test, wallet: Remove concurrent writes test
Since CWallet::chainStateFlushed is now no-op, this test no longer tests
the concurrent writes scenario. There are no other cases where multiple
DatabaseBatches are open at the same time.
2025-05-14 11:03:57 -07:00
Ava Chow b44b7c03fe wallet: Write best block record on unload 2025-05-14 11:03:57 -07:00
Ava Chow 876a2585a8 wallet: Remove unnecessary database Close step on shutdown
StopWallets, which was being called prior to UnloadWallets, performs an
unnecessary database closing step. This causes issues in UnloadWallets
which does additional database cleanups. Since the database closing step
is unnecessary, StopWallets is removed, and UnloadWallets is now called
from WalletLoaderImpl::stop.
2025-05-14 11:03:57 -07:00
Ava Chow 98a1a5275c wallet: Remove chainStateFlushed
chainStateFlushed is no longer needed since the best block is updated
after a block is scanned. Since the chainstate being flushed does not
necessarily coincide with the wallet having processed said block, it
does not entirely make sense for the wallet to be recording that block
as its best block, and this can cause race conditions where some blocks
are not processed. Thus, remove this notification.
2025-05-14 11:03:57 -07:00
Ava Chow 7fd3e1cf0c wallet, bench: Write a bestblock record in WalletMigration
Migrating a wallet requires having a bestblock record. This is always
the case in normal operation as such a record is always written on
wallet loading if it didn't already exist. However, within the unit
tests and benchmarks, this is not guaranteed. Since migration requires
the record, WalletMigration needs to also add this record before the
benchmark.
2025-05-14 11:03:57 -07:00
Ava Chow 6d3a8b195a wallet: Replace chainStateFlushed in loading with SetLastBlockProcessed
The only reason to call chainStateFlushed during wallet loading is to
ensure that the best block is written. Do these writes explicitly to
prepare for removing chainStateFlushed, while also ensuring that the
wallet's in memory state tracking is written to disk.

Additionally, after rescanning on wallet loading, instead of writing
the locator for the current chain tip, write the locator for the last
block that the rescan had scanned. This ensures that the stored best
block record matches the wallet's current state.

Any blocks dis/connected during the rescan are processed after the
rescan and the last block processed will be updated accordingly.
2025-05-14 11:03:57 -07:00
Ava Chow 7bacabb204 wallet: Update best block record after block dis/connect
When a block is connected, if the new block had anything relevant to the
wallet, update the best block record on disk. If not, also sync the best
block record to disk every 144 blocks.

Also reuse the new WriteBestBlock method in BackupWallet.
2025-05-14 11:03:43 -07:00
fanquake 301993ebf7
init: drop -upnp
This was slated for removal in 30.0, so remove it.
2025-05-14 16:01:36 +01:00
fanquake 3b824169c7
doc: remove Carls substitute server from Guix docs
This no-longer exists. Use one of the other Guix servers in the example.
2025-05-14 15:07:17 +01:00
Ryan Ofsky f1d78a3087
Merge bitcoin/bitcoin#31624: doc: warn that CheckBlock() underestimates sigops
a04f17a188 doc: warn that CheckBlock() underestimates sigops (Sjors Provoost)

Pull request description:

  Counting sigops in the witness requires context that `CheckBlock()`  does not have, so it only counts sigops for non-segwit transactions.

  It's useful to document, but it should not be a problem.

  The commit message contains some historical context.

ACKs for top commit:
  ismaelsadeeq:
    ACK a04f17a188
  ryanofsky:
    Code review ACK a04f17a188

Tree-SHA512: 26528367a7f3cfa8540ef0b90f7aa912c8f0bc057428f20a1fd1d4e232dac77747bc20044f0fcb0ffab8a2e1fb3dbe3dab46be749553a917744ddc7a829025cb
2025-05-14 10:05:41 -04:00
Lőrinc 516f0689b5 refactor: re-enable UBSan implicit-sign-change in serialize.h
Made every signed/unsigned conversion in the serialization helpers explicit so the UBSan `implicit-sign-change` check passes and the `serialize.h` suppression can be dropped.

For consistency, a few other simple changes were also applied to the serialization helpers:
* remove redundant `inline` on function templates;
* unify formatting to make the differences between similar methods obvious.
2025-05-14 15:41:20 +02:00
Lőrinc 5827e93507 refactor: use consistent size type for serialization template parameters 2025-05-14 15:40:57 +02:00
ismaelsadeeq 62fc42d475 interfaces: refactor: move `waitTipChanged` implementation to miner
- This commit creates a function `WaitTipChanged` that waits for the connected
  tip to change until timeout elapsed.

- This function is now used by `waitTipChanged`

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2025-05-14 13:55:12 +01:00
Sjors Provoost c39ca9d4f7
interfaces: move getTip implementation to miner 2025-05-14 13:55:05 +01:00
merge-script 33dfbbdff6
Merge bitcoin/bitcoin#32483: test: fix two intermittent failures in wallet_basic.py
e7ad86e1ca test: fix another intermittent failure in wallet_basic.py (Martin Zumsande)
07350e204d test: Fix intermittent failure in wallet_basic.py (Martin Zumsande)

Pull request description:

  Fixes two rare failures that happened in the CI:

  #27249:
  There could be a race with outstanding TxAddedToMempool notifications being applied to the soon-to-be created wallet:
  1. importdescriptors during rescan sets status to `TxStateConfirmed`
  2. old `transactionAddedToMempool` notification changes status back to  `TxStateInMempool`
  3. If the listunspent call happens here the test will fail
  4. blockConnected notification will change the status back to `TxStateConfirmed` (so it's not a persistent failure)

  I could reproduce this by adding a 100 microsecond sleep to `AddToWallet()`, the fix is to add a sync, so `transactionAddedToMempool` notifications won't affect the new wallet anymore.

  #32456:
  During init, the test framework will start using rpc after the mempool was loaded.
  It will not wait for `start()` / `postInitProcess` or outstanding `transactionAddedToMempool` notifications (which would both set the status to `TxStateInMempool`), leading to
  a possible race, in which `listunspent` can be called while the tx is still in `Inactive` status.

  Can be reproduced by adding two sleeps: To init  before calling `start()` for the chain clients, plus to `transactionAddedToMempool` in `wallet.cpp`.
  Prevent this by processing outstanding notifications.

  Fixes #27249
  Fixes #32456

ACKs for top commit:
  maflcko:
    review ACK e7ad86e1ca 🎩

Tree-SHA512: 1f1a11e5c8e1c6d3c39a49401c2c5122befdbbec25c0451953f5bfe8dfb53221ada552a68006e266570addda12bb16c1b9b1e49ad2198c33d91c4b96b764d73e
2025-05-14 13:22:27 +01:00
merge-script 8a65f03894
Merge bitcoin/bitcoin#32488: fuzz: Properly setup wallet in wallet_fees target
fa427ffcee fuzz: Properly setup wallet in wallet_fees target (MarcoFalke)

Pull request description:

  `g_wallet_ptr` is destructed after the `testing_setup`. This is not supported and will lead to issues such as https://github.com/bitcoin/bitcoin/pull/30221#issuecomment-2863875857 or https://github.com/bitcoin/bitcoin/pull/32409#issuecomment-2855259932.

  This could be fixed by fixing the initialization order.

  However, the global wallet is also modified in the fuzz target, which is bad fuzzing practise.

  So instead fix it by constructing a fresh wallet for each fuzz iteration.

ACKs for top commit:
  brunoerg:
    code review ACK fa427ffcee
  hebasto:
    ACK fa427ffcee, this change fixes the issue when building the "Debug" configuration with MSVC on Windows.
  marcofleon:
    Code review ACK fa427ffcee

Tree-SHA512: 161b93fc39a609cb16d9ffea7366c5e339bd01712577f0782aedff46c00f79edd2a907807ac83f9fcec687b4bbbe0fd6e6f75e32169639a310e4e7b771078b3b
2025-05-14 11:36:20 +01:00
fanquake 75a185ea3d
test: add skip_if_running_under_valgrind()
Enable it in the USDT tests. The context (from 0xB10C):

> every time the tracepoint is reached a SIGTRAP is fired.
> No matter the tracepoint contents, even with an empty one.
> Valgrind intercepts SIGTRAP and aborts.

See discussion in #32374.
2025-05-14 10:55:26 +01:00
fanquake 8f4ba90b8f
build: document why we check for std::system
It's probably debatable if we support targets like iOS, but for now,
document why we are checking for this standard library feature.

Trying to use `std::system` for a `aarch64-darwin-ios` target results in
```bash
test.cpp:7:10: error: 'system' is unavailable: not available on iOS
    7 |     std::system("some_command");
      |          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdlib.h:203:6: note: 'system' has been explicitly marked unavailable here
  203 | int      system(const char *) __DARWIN_ALIAS_C(system);
      |          ^
1 error generated.
```
2025-05-14 09:50:10 +01:00
MarcoFalke faf9082a5f
test: Fix whitespace in prevector_tests.cpp
Bitcoin Core uses 4 spaces indent, but the test was in some lines using
5 or more.

Just clang-format the whole file.
2025-05-14 09:55:27 +02:00
MarcoFalke fa7f04c8a7
refactor: Remove UB in prevector reverse iterators
rend() creates a pointer with offset -1. This is UB, according to the
C++ standard: https://eel.is/c++draft/expr.add#4:

    When an expression J that has integral type is added to [...] an
    expression P of pointer type, the result has the type of P.

    ... if P points to a (possibly-hypothetical) array element i of an
    array object x with n elements [...] the expressions P + J and J + P
    (where J has the value j) point to the (possibly-hypothetical) array
    element i+j of x if 0≤i+j≤n [...]

    Otherwise, the behavior is undefined.

Also, it is unclear why the functions exist at all, when stdlib utils
such as std::reverse_iterator{it} or std::views::reverse can be used out
of the box.

So remove them, along with the ubsan suppressions, that are no longer
used.
2025-05-14 09:35:32 +02:00
MarcoFalke fa427ffcee
fuzz: Properly setup wallet in wallet_fees target
Co-Authored-By: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2025-05-13 22:58:38 +02:00
merge-script f9d8910539
Merge bitcoin/bitcoin#31080: fees: document non-monotonic estimation edge case
1e0de7a6ba fees: document non-monotonic estimation edge case (willcl-ark)

Pull request description:

  Closes: https://github.com/bitcoin/bitcoin/issues/11800

  In scenarios where data is available for higher targets but not for lower ones, this method *may* return lower fee rates for higher confirmation targets. This could occur if `estimateCombinedFee` returns no valid data (`-1`) for some estimates for a low target, but **does** return valid data for a higher target.

  Users of this function should be aware of this potential, if unlikely, inconsistency in behaviour in data-sparse scenarios.

ACKs for top commit:
  adamandrews1:
    Code review ACK 1e0de7a
  ismaelsadeeq:
    Code review ACK 1e0de7a6ba
  glozow:
    ACK 1e0de7a6ba

Tree-SHA512: 161e5dafdd131570853a89491753ae39a7b725d1a86cab5a7294c2a5939da1a9a5f2c4aca0900e9ad810e828b6e0e636f256384e3d1fda6dd552da189bbbe747
2025-05-13 16:49:46 -04:00
merge-script 31650b458b
Merge bitcoin/bitcoin#32386: mining: rename gbt_force and gbt_force_name
0750249289 mining: document gbt_rule_value helper (Sjors Provoost)
5e87c3ec09 scripted-diff: rename gbt_force and gbt_force_name (Sjors Provoost)

Pull request description:

  The term "force" is ambiguous and not used in [BIP9](https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki#getblocktemplate-changes) where there ! rule prefix is introduced.

  E.g. this code is hard to read:

  ```cpp
  if (!gbt_force) {
     s.insert(s.begin(), '!');
  ```

  Additionally, #29039 renamed `gbt_vb_name` to `gbt_force_name` which, at least for me, further increased the confusion.

  This is a pure (variable rename) refactor (plus documentation) and does not change behavior.

  Reminder of how to verify a scripted diff:

  ```sh
  test/lint/commit-script-check.sh origin/master..HEAD
  ```

ACKs for top commit:
  achow101:
    ACK 0750249289
  janb84:
    ACK [0750249](0750249289)
  musaHaruna:
    ACK [0750249](0750249289)
  glozow:
    ACK 0750249289, seems sensible

Tree-SHA512: 8c88a273a3b36040f6c641843bd20579d0065b051aad4b39fc14f0d2af2808690dff6772bd8b1a4d9699b72279a700d2661012651bc315433a123dcc8996adaa
2025-05-13 16:42:49 -04:00
merge-script bac43b957e
Merge bitcoin/bitcoin#32312: test: Fix feature_pruning test after nTime typo fix
2aa63d511a test: Use uninvolved pruned node in feature_pruning undo test (enoch)
772ba7f9ce test: Fix nTimes typo in feature_pruning test (enoch)

Pull request description:

  This PR contains two commits:

  1. Fixes a typo in feature_pruning.py where 'nTimes' was incorrectly
     used instead of 'nTime'. This typo caused the test to always reset
     mine_large_blocks.nTime to 0, rather than only on the first run.

  2. Fixes the test failure exposed by the typo fix. The
     test_pruneheight_undo_presence test was failing because it was using
     node 2, which is involved in reorg testing and could be on a
     different chain than other nodes. The solution switches to using
     node 5, which is also a pruned node but isn't involved in reorg
     testing.

  Testing:
  - Ran test/functional/feature_pruning.py multiple times to verify
    consistent passing
  - Verified that the test now passes with the correct nTime variable name
  - Confirmed the test behavior matches the intended functionality of
    verifying pruned block availability
  - Ran the full test suite to ensure the changes did not introduce any
    regressions or affect other tests

  Thanks to fjahr for his assistance in diagnosing the issue and
  suggesting the solution.

  This fixes the test failure reported in #32249

ACKs for top commit:
  fjahr:
    tACK 2aa63d511a
  maflcko:
    lgtm ACK 2aa63d511a
  naiyoma:
     tACK 2aa63d511a
  stratospher:
    tested ACK 2aa63d5. verified that `nTime` is being incremented now.

Tree-SHA512: a543528fd4eeb30e978c0b43cfa109768252edaf1f94679dbbc7fe684122c00da34224e2cc1abd2a265af1b267eef1cd34246207946cf7d8e93d2c0f11aa56d8
2025-05-13 16:30:25 -04:00
merge-script c9ab10910c
Merge bitcoin/bitcoin#31444: cluster mempool: add txgraph diagrams/mining/eviction
8673e8f019 txgraph: Special-case singletons in chunk index (optimization) (Pieter Wuille)
abdd9d35a3 txgraph: Skipping end of cluster has no impact (optimization) (Pieter Wuille)
604acc2c28 txgraph: Reuse discarded chunkindex entries (optimization) (Pieter Wuille)
c734081454 txgraph: Introduce TxGraph::GetWorstMainChunk (feature) (Pieter Wuille)
394dbe2142 txgraph: Introduce BlockBuilder interface (feature) (Pieter Wuille)
883df3648e txgraph: Generalize GetClusterRefs to support subsections (preparation) (Pieter Wuille)
c28a602e00 txgraph: Introduce TxGraphImpl observer tracking (preparation) (Pieter Wuille)
9095d8ac1c txgraph: Maintain chunk index (preparation) (Pieter Wuille)
87e74e1242 txgraph: abstract out transaction ordering (refactor) (Pieter Wuille)
2614fea17f txgraph: Add GetMainStagingDiagrams function (feature) (Pieter Wuille)

Pull request description:

  Part of cluster mempool: #30289.

  This adds more functionality to the txgraph module, specifically:
  * `TxGraph::GetMainStagingDiagrams()`, a function to obtain feerate diagrams for both the main graph and the staged changes to it, including only the clusters that differ between the two.
  * `TxGraph::GetBlockBuilder()`, a function to obtain an object which can efficiently iterate the chunks of the (main) graph from high to low chunk feerate, allowing each to be skipped or included.
  * `TxGraph::GetWorstMainChunk()`, a function to obtain the last chunk that would be returned by `GetBlockBuilder()`'s returned object, intended for eviction.

ACKs for top commit:
  monlovesmango:
    reACK 8673e8f019
  instagibbs:
    reACK 8673e8f019
  glozow:
    reACK 8673e8f019

Tree-SHA512: 5c98c54919c44eb2f9545dfc130e54dfc25b5b54d43cf5ca9bcf46e019b9fd405a572fcd70e71e2a7c5b4b096cfd540a4d09ef1f52ba188504418682f1dfc4af
2025-05-13 16:27:30 -04:00
Martin Zumsande e7ad86e1ca test: fix another intermittent failure in wallet_basic.py
During init, the test framework will start using rpc after the
mempool was loaded. It will not wait for postInitProcess or
outstanding transactionAddedToMempool notifications, leading to
a possible race, in which listunspent is being called while the
tx is still in Inactive status. Prevent this by processing
outstanding notifications.
2025-05-13 13:09:33 -04:00
Martin Zumsande 07350e204d test: Fix intermittent failure in wallet_basic.py
There could be a race with outstanding TxAddedToMempool notifications
being applied to the soon-to-be created wallet.

Fixes an intermittent timeout reproducable by adding a sleep to
AddToWallet.
2025-05-13 13:09:25 -04:00
fanquake 46b533dfe6
Update minisketch subtree to latest upstream 2025-05-13 18:07:47 +01:00
fanquake bf25a0918f Squashed 'src/minisketch/' changes from d1e6bb8bbf..ea8f66b1ea
ea8f66b1ea Merge sipa/minisketch#89: header: Delete default Minisketch constructor
fc24958646 Merge sipa/minisketch#94: misc: trim trailing whitespace
485b16e7ff misc: trim trailing whitespace
5cc7d20866 header: Delete default Minisketch constructor

git-subtree-dir: src/minisketch
git-subtree-split: ea8f66b1eabb0388d221daaa4706120a5083da0c
2025-05-13 18:07:47 +01:00
merge-script 8309a9747a
Merge bitcoin/bitcoin#32028: Update `secp256k1` subtree to latest master
c31fcaaad3 Squashed 'src/secp256k1/' changes from 0cdc758a56..4187a46649 (Hennadii Stepanov)

Pull request description:

  This PR updates the `secp256k1` subtree to 4ba1ba2af9, which includes the following changes:
  - https://github.com/bitcoin-core/secp256k1/pull/1633
  - https://github.com/bitcoin-core/secp256k1/pull/1634
  - https://github.com/bitcoin-core/secp256k1/pull/1641
  - https://github.com/bitcoin-core/secp256k1/pull/1650
  - https://github.com/bitcoin-core/secp256k1/pull/1646
  - https://github.com/bitcoin-core/secp256k1/pull/1654
  - https://github.com/bitcoin-core/secp256k1/pull/1642
  - https://github.com/bitcoin-core/secp256k1/pull/1639
  - https://github.com/bitcoin-core/secp256k1/pull/1614
  - https://github.com/bitcoin-core/secp256k1/pull/1656
  - https://github.com/bitcoin-core/secp256k1/pull/1647
  - https://github.com/bitcoin-core/secp256k1/pull/1655
  - https://github.com/bitcoin-core/secp256k1/pull/1593
  - https://github.com/bitcoin-core/secp256k1/pull/1359
  - https://github.com/bitcoin-core/secp256k1/pull/1657
  - https://github.com/bitcoin-core/secp256k1/pull/1660
  - https://github.com/bitcoin-core/secp256k1/pull/1659
  - https://github.com/bitcoin-core/secp256k1/pull/1661
  - https://github.com/bitcoin-core/secp256k1/pull/1662
  - https://github.com/bitcoin-core/secp256k1/pull/1669
  - https://github.com/bitcoin-core/secp256k1/pull/1492

  https://github.com/bitcoin-core/secp256k1/pull/1647 is required for https://github.com/bitcoin/bitcoin/pull/31507.

ACKs for top commit:
  fanquake:
    ACK 915c1fa72c

Tree-SHA512: 2c409ef2cd14fb14c2ea108f65411b673da786e886aabf75015be25220d5a3983ad8d9e76db1cb95453357a07fbaf05497ef4e5bb83d92b96caf62c1cddaa616
2025-05-13 16:39:22 +01:00
ismaelsadeeq 720f201e65 interfaces: refactor: move `waitNext` implementation to miner
- We now assert for a valid chainman and notifications once when
 invoking WaitAndCreateNewBlock function.
2025-05-13 16:22:56 +01:00
ismaelsadeeq e6c2f4ce7a interfaces: refactor: move `submitSolution` implementation to miner
- Create a new function `AddMerkleRootAndCoinbase` that compute the
  block's merkle root, insert the coinbase transaction and the merkle
  root into the block.
2025-05-13 16:22:56 +01:00
ismaelsadeeq 02d4bc776b interfaces: remove redundant coinbase fee check in `waitNext`
- vTxFees now does not include the negative coinbase fee,
  hence this check can be removed.
2025-05-13 16:22:56 +01:00
MarcoFalke fa9198af55
lint: Check for missing trailing newline 2025-05-13 15:50:02 +02:00
MarcoFalke fa2b2aa27c
lint: Add archived notes to default excludes
No need to touch or lint them.
2025-05-13 15:46:55 +02:00
merge-script cbd8e3d511
Merge bitcoin/bitcoin#32476: refactor: Remove unused HaveKey and HaveWatchOnly
fabdc5ad06 Remove unused LegacyDataSPKM::HaveWatchOnly() (MarcoFalke)
fa7b7f796a Remove HaveKey helper, unused after sethdseed removal (MarcoFalke)

Pull request description:

  removes some dead code

ACKs for top commit:
  Sjors:
    utACK fabdc5ad06

Tree-SHA512: 3cf6838eff6cedfe6a7337071d41e17d34033a2875b3661a6a1741e13c7a8e81b57eb874aebbb9d96d05ea7efa261a3a98e1bcf982b12cfafb163405d860b8bf
2025-05-13 12:34:36 +01:00
Hennadii Stepanov c31fcaaad3 Squashed 'src/secp256k1/' changes from 0cdc758a56..4187a46649
4187a46649 Merge bitcoin-core/secp256k1#1492: tests: Add Wycheproof ECDH vectors
e266ba11ae tests: Add Wycheproof ECDH vectors
13906b7154 Merge bitcoin-core/secp256k1#1669: gitignore: Add Python cache files
c1bcb03276 gitignore: Add Python cache files
70f149b9a1 Merge bitcoin-core/secp256k1#1662: bench: add ellswift to bench help output
6b3fe51fb6 bench: add ellswift to bench help output
d84bb83e26 Merge bitcoin-core/secp256k1#1661: configure: Show exhaustive tests in summary
3f54ed8c1b Merge bitcoin-core/secp256k1#1659: include: remove WARN_UNUSED_RESULT for functions always returning 1
20b05c9d3f configure: Show exhaustive tests in summary
e56716a3bc Merge bitcoin-core/secp256k1#1660: ci: Fix exiting from ci.sh on error
d87c3bc58f ci: Fix exiting from ci.sh on error
1b6e081538 include: remove WARN_UNUSED_RESULT for functions always returning 1
2abb35b034 Merge bitcoin-core/secp256k1#1657: tests: remove unused uncounting_illegal_callback_fn
51907fa918 tests: remove unused uncounting_illegal_callback_fn
a7a5117144 Merge bitcoin-core/secp256k1#1359: Fix symbol visibility issues, add test for it
13ed6f65dc Merge bitcoin-core/secp256k1#1593: Remove deprecated `_ec_privkey_{negate,tweak_add,tweak_mul}` aliases from API
d1478763a5 build: Drop no longer needed  `-fvisibility=hidden` compiler option
8ed1d83d92 ci: Run `tools/symbol-check.py`
41d32ab2de test: Add `tools/symbol-check.py`
88548058b3 Introduce `SECP256K1_LOCAL_VAR` macro
03bbe8c615 Merge bitcoin-core/secp256k1#1655: gha: Print all *.log files, in a separate action
59860bcc24 gha: Print all *.log files, in a separate action
4ba1ba2af9 Merge bitcoin-core/secp256k1#1647: cmake: Adjust diagnostic flags for `clang-cl`
abd25054a1 Merge bitcoin-core/secp256k1#1656: musig: Fix clearing of pubnonces
961ec25a83 musig: Fix clearing of pubnonces
3186082387 Merge bitcoin-core/secp256k1#1614: Add _ge_set_all_gej and use it in musig for own public nonces
6c2a39dafb Merge bitcoin-core/secp256k1#1639: Make static context const
37d2c60bec Remove deprecated _ec_privkey_{negate,tweak_add,tweak_mul} aliases
432ac57705 Make static context const
1b1fc09341 Merge bitcoin-core/secp256k1#1642: Verify `compressed` argument in `secp256k1_eckey_pubkey_serialize`
c0d9480fbb Merge bitcoin-core/secp256k1#1654: use `EXIT_` constants over magic numbers for indicating program execution status
13d389629a CONTRIBUTING: mention that `EXIT_` codes should be used
c855581728 test, bench, precompute_ecmult: use `EXIT_...` constants for `main` return values
965393fcea examples: use `EXIT_...` constants for `main` return values
2e3bf13653 Merge bitcoin-core/secp256k1#1646: README: add instructions for verifying GPG signatures
b682dbcf84 README: add instructions for verifying GPG signatures
00774d0723 Merge bitcoin-core/secp256k1#1650: schnorrsig: clear out masked secret key in BIP-340 nonce function
a82287fb85 schnorrsig: clear out masked secret key in BIP-340 nonce function
4c50d73dd9 ci: Add new "Windows (clang-cl)" job
84c0bd1f72 cmake: Adjust diagnostic flags for clang-cl
f79f46c703 Merge bitcoin-core/secp256k1#1641: doc: Improve cmake instructions in README
2ac9f558c4 doc: Improve cmake instructions in README
1823594761 Verify `compressed` argument in `secp256k1_eckey_pubkey_serialize`
8deef00b33 Merge bitcoin-core/secp256k1#1634: Fix some misspellings
39705450eb Fix some misspellings
ec329c2501 Merge bitcoin-core/secp256k1#1633: release cleanup: bump version after 0.6.0
c97059f594 release cleanup: bump version after 0.6.0
64228a648f musig: Use _ge_set_all_gej for own public nonces
300aab1c05 tests: Improve _ge_set_all_gej(_var) tests
365f274ce3 group: Simplify secp256k1_ge_set_all_gej
d3082ddead group: Add constant-time secp256k1_ge_set_all_gej

git-subtree-dir: src/secp256k1
git-subtree-split: 4187a4664914dc6f6fb6a619c6b85c854fc33033
2025-05-13 11:31:34 +01:00
Hennadii Stepanov 915c1fa72c
Update secp256k1 subtree to latest master 2025-05-13 11:31:34 +01:00
Vasil Dimov e98c51fcce
doc: update tor.md to mention the new -proxy=addr:port=tor
Also change the formatting of `tor.md` to have more horizonal space for
the text.

Co-authored-by: Matthew Zipkin <pinheadmz@gmail.com>
2025-05-13 12:09:41 +02:00
Vasil Dimov ca5781e23a
config: allow setting -proxy per network
`-proxy=addr:port` specifies the proxy for all networks (except I2P).
Previously only the Tor proxy could have been specified separately via
`-onion=addr:port`.

Make it possible to specify separately the proxy for IPv4, IPv6, Tor and
CJDNS by e.g. `-proxy=addr:port=ipv6`. Or remove the proxy for a given
network, e.g. `-proxy=0=cjdns`.

Resolves: https://github.com/bitcoin/bitcoin/issues/24450
2025-05-13 12:09:40 +02:00
MarcoFalke fabdc5ad06
Remove unused LegacyDataSPKM::HaveWatchOnly() 2025-05-13 09:31:25 +02:00
MarcoFalke fa7b7f796a
Remove HaveKey helper, unused after sethdseed removal 2025-05-13 09:31:07 +02:00
Pieter Wuille 8673e8f019 txgraph: Special-case singletons in chunk index (optimization) 2025-05-12 17:07:30 -04:00
Pieter Wuille abdd9d35a3 txgraph: Skipping end of cluster has no impact (optimization) 2025-05-12 17:07:30 -04:00
Pieter Wuille 604acc2c28 txgraph: Reuse discarded chunkindex entries (optimization) 2025-05-12 17:07:30 -04:00
Pieter Wuille c734081454 txgraph: Introduce TxGraph::GetWorstMainChunk (feature)
It returns the last chunk that would be suggested for mining by BlockBuilder
objects. This is intended for eviction.
2025-05-12 17:07:30 -04:00
Pieter Wuille 394dbe2142 txgraph: Introduce BlockBuilder interface (feature)
This interface lets one iterate efficiently over the chunks of the main
graph in a TxGraph, in the same order as CompareMainOrder. Each chunk
can be marked as "included" or "skipped" (and in the latter case,
dependent chunks will be skipped).
2025-05-12 17:07:30 -04:00
Pieter Wuille 883df3648e txgraph: Generalize GetClusterRefs to support subsections (preparation)
This is preparation for a next commit which will need a way to extract Refs
for just individual chunks from a cluster.
2025-05-12 17:07:30 -04:00
Pieter Wuille c28a602e00 txgraph: Introduce TxGraphImpl observer tracking (preparation)
This is preparation for a next commit which will introduce a class whose
objects hold references to internals in TxGraphImpl, which disallows
modifications to the graph while such objects exist.
2025-05-12 17:07:30 -04:00
Pieter Wuille 9095d8ac1c txgraph: Maintain chunk index (preparation)
This is preparation for exposing mining and eviction functionality in
TxGraph.
2025-05-12 17:07:28 -04:00
Pieter Wuille 87e74e1242 txgraph: abstract out transaction ordering (refactor) 2025-05-12 17:00:33 -04:00
Pieter Wuille 2614fea17f txgraph: Add GetMainStagingDiagrams function (feature)
This allows determining whether the changes in a staging diagram unambiguously improve
the graph, through CompareChunks().
2025-05-12 16:00:24 -04:00
Ryan Ofsky a5ac43d98d doc: Add release notes describing bitcoin wrapper executable 2025-05-12 14:49:17 -04:00
merge-script 663a9cabf8
Merge bitcoin/bitcoin#32458: guix: move `*-check.py` scripts under contrib/guix/
415650cea9 guix: move *-check.py scripts under contrib/guix (fanquake)

Pull request description:

  These scripts are not meant for general developer usage. They are for use on the release binaries, which have been compiled in an environment that makes various assumptions in regards to c library, compiler options, hardening options, dependency patching etc.

  Anyone is free to run these scripts against self-compiled binaries, but this isn't something we want to modify/generalize the scripts to support.

ACKs for top commit:
  laanwj:
    Code review ACK 415650cea9
  TheCharlatan:
    ACK 415650cea9

Tree-SHA512: 469cc5da9df014b4a9dc39080f31c3283641691209497cdb7cc5dc4767681a7f4b67425768e81838153ce39a26547ed94cd3be4dc27352d33960765bfac9d0e5
2025-05-12 19:49:17 +01:00
Ryan Ofsky 258bda80c0 doc: Mention bitcoin wrapper executable in documentation 2025-05-12 14:49:17 -04:00
Sjors Provoost d2739d75c9 build: add bitcoin.exe to windows installer 2025-05-12 19:49:17 +01:00
Ryan Ofsky ba649c0006 ci: Run multiprocess tests through wrapper executable 2025-05-12 13:49:17 -05:00
Ryan Ofsky 29bdd743bb test: Support BITCOIN_CMD environment variable
Support new BITCOIN_CMD environment variable in functional test to be able to
test the new bitcoin wrapper executable and run other commands through it
instead of calling them directly.

Co-authored-by: Sjors Provoost <sjors@sprovoost.nl>
2025-05-12 13:49:17 -05:00
Ryan Ofsky 9c8c68891b multiprocess: Add bitcoin wrapper executable
Intended to make bitcoin command line features more discoverable and allow
installing new multiprocess binaries in libexec/ instead of bin/ so they don't
cause confusion.

Idea and implementation of this were discussed in
https://github.com/bitcoin/bitcoin/issues/30983

Co-authored-by: Sjors Provoost <sjors@sprovoost.nl>
2025-05-12 14:49:17 -04:00
Ryan Ofsky 5076d20fdb util: Add cross-platform ExecVp and GetExePath functions
These functions are just meant to serve the needs of the bitcoin wrapper
executable, and are intentionally not very general purpose so they can be
simple.
2025-05-12 13:49:17 -05:00
merge-script 05765b8818
Merge bitcoin/bitcoin#32472: doc: Fix typo
d847e17c96 doc: Fix typo (Hennadii Stepanov)

Pull request description:

  A translator on Transifex noticed:
  > This is the only label which has two dots: ..
  > Usually we see the elipsis (…)

  This PR addresses this issue.

ACKs for top commit:
  janb84:
    good find, ACK d847e17c96

Tree-SHA512: cbdc5f283fe30655a923c34813c97406bba85657554984c26acbfed585ce3a652bcb21348d7e0f6fd9c82ca04111c412ff62c7d4b046869d13785b713e69ab6d
2025-05-12 19:48:46 +01:00
Hennadii Stepanov d847e17c96
doc: Fix typo
An ellipsis (…) is typically used in such cases.
2025-05-12 17:11:27 +01:00
merge-script 3edf400b10
Merge bitcoin/bitcoin#32469: cmake: Allow `WITH_DBUS` on all Unix-like systems
5b7ed460c7 cmake: Allow `WITH_DBUS` on all Unix-like systems (Hennadii Stepanov)

Pull request description:

  This PR makes the `WITH_DBUS` option available on all Unix-like systems, not just Linux, thereby fixing a regression that was overlooked during the migration from Autotools.

  Note: Enabling D-Bus support on macOS still makes no sense, since the `Notificator` class uses the User Notification Center regardless:746ab19d5a/src/qt/notificator.cpp (L43-L56)

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

ACKs for top commit:
  laanwj:
    ACK 5b7ed460c7
  theStack:
    tACK 5b7ed460c7

Tree-SHA512: 01f5a365a8109c273489e2d46b08d8b64b82251c4814a486561221b55d8a47cb1effc9140dbd6b2ab5f12e2966d0ea0d07a4cbf67d310001ee681b0f5b63f300
2025-05-12 14:22:55 +01:00
Hennadii Stepanov 59e09e0fb7
Merge bitcoin-core/gui#871: qt, docs: Unify term "clipboard"
3bbdbc0a5e qt, docs: Unify term "clipboard" (Hennadii Stepanov)

Pull request description:

  A translator on Transifex noticed:
  > The term "system clipboard" appears twice. The term "clipboard" appears 10 times. Perhaps we could standardize on just saying "clipboard"?

  This PR addresses this issue.

ACKs for top commit:
  davidgumberg:
    ACK 3bbdbc0a5e
  pablomartin4btc:
    ACK 3bbdbc0a5e

Tree-SHA512: 61a100f60890d81122a4b8ce3e2cb7d355c7fb643de3196573f7f9107c6f52fa0b3e7a4f743ce2833e8c67b9cdad3568b761d730fef5c9781f5e1c45252888c4
2025-05-11 17:38:04 +01:00
Hennadii Stepanov 46f79dde67
Merge bitcoin-core/gui#841: Decouple WalletModel from RPCExecutor
002b792b9a gui: decouple WalletModel from RPCExecutor (furszy)

Pull request description:

  A more comprehensive fix for the issue described in #837.

  Since the `WalletModel` class is unavailable when compiling without wallet support
  `(-DENABLE_WALLET=0)`, the RPC executor class should not be coupled to it.
  This decoupling ensures GUI compatibility with builds that omit wallet support.

  This also drops an extra `#ifdef ENABLE_WALLET` block which is always good.

ACKs for top commit:
  w0xlt:
    Code Review ACK 002b792b9a
  pablomartin4btc:
    tACK 002b792b9a
  BrandonOdiwuor:
    tACK 002b792b9a
  hebasto:
    ACK 002b792b9a, I have reviewed the code and it looks OK.

Tree-SHA512: a8e6b7e9d88dd8e0ff5e2d0de91be2f85fd0559265267d3bf6cae5a37606cf1ab6bc7415d5817a11006008de362f2ca3557ba772b4e1bd9fbef5f564be3b53bb
2025-05-11 17:34:11 +01:00
Hennadii Stepanov 5b7ed460c7
cmake: Allow `WITH_DBUS` on all Unix-like systems
This change makes the `WITH_DBUS` option available on all Unix-like
systems, not just Linux, thereby fixing a regression that was
overlooked during the migration from Autotools.

Note: Enabling D-Bus support on macOS still makes no sense, since the
`Notificator` class uses the User Notification Center regardless.
2025-05-11 17:06:01 +01:00
merge-script 746ab19d5a
Merge bitcoin/bitcoin#32446: build: simplify *ifaddr handling
ab878a7e74 build: simplify *ifaddr handling (fanquake)

Pull request description:

  We really just want to skip this when building for Windows. So do that,
  and remove the two header checks (we also already use both of these
  headers, unguarded, in the !windows part of the codebase).

  Squash the two *iffaddrs defines into one, as I haven't seen an
  `iffaddrs.h` that implements one, but not the other.

ACKs for top commit:
  hebasto:
    ACK ab878a7e74. Only addressed my [comment](https://github.com/bitcoin/bitcoin/pull/32446#discussion_r2079994126) and rebased since my recent [review](https://github.com/bitcoin/bitcoin/pull/32446#pullrequestreview-2825606189).
  TheCharlatan:
    ACK ab878a7e74

Tree-SHA512: 7667305df9fef4728526c7217f85b51e739ec63b38e808da51d6ae65cb6f2696afa5ba82e5a72ed4a7a9b79ffa2402640448af4392587253027122eab7618e30
2025-05-10 15:50:01 +01:00
Cory Fields 6f7052a7b9 threading: semaphore: move CountingSemaphoreGrant to its own header 2025-05-10 03:31:30 +00:00
Cory Fields fd15469892 threading: semaphore: remove temporary convenience types 2025-05-10 00:53:16 +00:00
Cory Fields 1f89e2a49a scripted-diff: threading: semaphore: use direct types rather than the temporary convenience ones
-BEGIN VERIFY SCRIPT-
sed -i 's|BinarySemaphore|std::binary_semaphore|g' src/wallet/sqlite.h
sed -i 's|SemaphoreGrant|CountingGrant|g' src/net.h src/net.cpp
sed -i 's|Semaphore|std::counting_semaphore<>|g' src/net.h src/net.cpp
sed -i 's|CountingGrant|CountingSemaphoreGrant<>|g' src/net.h src/net.cpp

-END VERIFY SCRIPT-
2025-05-10 00:53:16 +00:00
Cory Fields f21365c4fc threading: replace CountingSemaphore with std::counting_semaphore 2025-05-10 00:53:16 +00:00
Cory Fields 1acacfbad7 threading: make CountingSemaphore/CountingSemaphoreGrant template types 2025-05-10 00:53:16 +00:00
Cory Fields e6ce5f9e78 scripted-diff: rename CSemaphore and CSemaphoreGrant
CountingSemaphore and CountingSemaphoreGrant model std::counting_semaphore.

-BEGIN VERIFY SCRIPT-
sed -i -e 's|CSemaphoreGrant|CountingSemaphoreGrant|g' -e 's|CSemaphore|CountingSemaphore|g' src/sync.h
-END VERIFY SCRIPT-
2025-05-10 00:53:16 +00:00
Cory Fields 793166d381 wallet: change the write semaphore to a BinarySemaphore
Follow-up commits will make a distinction between Semaphore and
BinarySemaphore.
2025-05-10 00:53:16 +00:00
Cory Fields 6790ad27f1 scripted-diff: rename CSemaphoreGrant and CSemaphore for net
-BEGIN VERIFY SCRIPT-
sed -i -e 's|CSemaphoreGrant|SemaphoreGrant|g' -e 's|CSemaphore|Semaphore|g' src/net.h src/net.cpp
-END VERIFY SCRIPT-
2025-05-10 00:53:16 +00:00
Cory Fields d870bc9451 threading: add temporary semaphore aliases 2025-05-10 00:53:00 +00:00
Ava Chow 19b1e177d6
Merge bitcoin/bitcoin#32155: miner: timelock the coinbase to the mined block's height
a58cb3b1c1 qa: sanity check mined block have their coinbase timelocked to height (Antoine Poinsot)
8f2078af6a miner: timelock coinbase transactions (Antoine Poinsot)
788aeebf34 qa: use prev height as nLockTime for coinbase txs created in unit tests (Antoine Poinsot)
c76dbe9b8b qa: timelock coinbase transactions created in fuzz targets (Antoine Poinsot)
9c94069d8b contrib: timelock coinbase transactions in signet miner (Antoine Poinsot)
a5f52cfcc4 qa: timelock coinbase transactions created in functional tests (Antoine Poinsot)

Pull request description:

  The Consensus Cleanup soft fork proposal includes enforcing that coinbase transactions set their
  nLockTime field to the block height minus 1, as well as their nSequence such as to not disable the
  timelock. If such a fork were to be activated by Bitcoin users, miners need to be ready to produce
  compliant blocks at the risk of losing substantial amounts mining would-be invalid blocks. As miners
  are unfamously slow to upgrade, it's good to make this change as early as possible.

  Although Bitcoin Core's GBT implementation does not provide the `coinbasetxn` field, and mining
  pool software crafts the coinbase on its own, updating the Bitcoin Core mining code is a first step
  toward convincing pools to update their (often closed source) code. A possible followup is also to
  introduce new fields to GBT. In addition, this first step also makes it possible to test future
  Consensus Cleanup changes.

  The commit making the change also updates a bunch of seemingly-unrelated tests. This is because those tests were asserting error messages based on the txid of transactions involved, and changing the coinbase transaction structure necessarily changes the txid of all tests' transactions.

ACKs for top commit:
  Sjors:
    Code review ACK a58cb3b1c1
  achow101:
    ACK a58cb3b1c1
  TheCharlatan:
    Re-ACK a58cb3b1c1

Tree-SHA512: a2aae009a187eb760d34435f518a895ee76c6b02a667eb030ddf6bd584da6e8eae2737d974dbf81a928d60c07bcb4820f055adc067e18d8819640db0240bb513
2025-05-09 15:09:27 -07:00
Ava Chow 6c6ef58b0b
Merge bitcoin/bitcoin#32436: test: refactor: negate signature-s using libsecp256k1
1ee698fde2 test: refactor: negate signature-s using libsecp256k1 (Sebastian Falbesoner)

Pull request description:

  This small PR gets rid of manual mod-n inversion of the ECDSA signature-s part in unit tests (introduced a long time ago in #5256, triggered by https://github.com/bitcoin-core/secp256k1/pull/69) by using secp256k1 instead. The function wasn't available at that time, but was introduced about three years later, see https://github.com/bitcoin-core/secp256k1/pull/408. Note that as the name suggests, `secp256k1_ec_seckey_negate` is meant to be used for secret keys, but it obviously works in general for scalars modulo the group order.

ACKs for top commit:
  achow101:
    ACK 1ee698fde2
  laanwj:
    Code review ACK 1ee698fde2
  w0xlt:
    ACK 1ee698fde2
  rkrux:
    tACK 1ee698fde2

Tree-SHA512: dc36ea1572b538d11ae34e1871f310a1cda8083ffb753e93e7ee9d56e91ebd8ec78d35758dfb700254720914b734ef7a071eeef71b6239f19e1e2fb289fb5435
2025-05-09 13:26:27 -07:00
Ava Chow b104d44227 test: Remove RPCOverloadWrapper
With the legacy wallet now removed, these overloads are no longer
needed.
2025-05-09 12:31:53 -07:00
Ava Chow 4d32c19516 test: Replace importpubkey 2025-05-09 12:31:53 -07:00
Ava Chow fe838dd391 test: Replace usage of addmultisigaddress 2025-05-09 12:31:53 -07:00
Ava Chow d314207779 test: Replace usage of importaddress 2025-05-09 11:42:46 -07:00
Ava Chow fcc457573f test: Replace importprivkey with wallet_importprivkey
importprivkey was a legacy wallet only RPC which had a helper for
descriptor wallets in tests. Add wallet_importprivkey helper and use it
wherever importprivkey is used (other than backward compatibility tests)
2025-05-09 11:42:33 -07:00
Ava Chow 94c87bbbd0 test: Remove unnecessary importprivkey from wallet_createwallet
This test was testing importprivkey behavior in a legacy wallet without
private keys. As legacy wallets no longer exist, this test case is no
longer relevant.
2025-05-09 11:40:54 -07:00
merge-script 9a05b45da6
Merge bitcoin/bitcoin#32438: refactor: Removals after bdb removal
fa061bfcdb Remove create options from wallet tool (MarcoFalke)
fa2125e7b8 Remove unused IsSingleKey (MarcoFalke)
fab5e2a094 doc: Remove note about bdb wallets (MarcoFalke)
eeeef88d46 doc: fix typo in abortrescan rpc (MarcoFalke)
fa7e5c15a7 Remove unused LegacyDataSPKM::DeleteRecords() (MarcoFalke)
ffff949472 remove NotifyWatchonlyChanged (MarcoFalke)
fa62a013a5 remove dead flush() (MarcoFalke)
fa5f3e62c8 vcpkg: Remove bdb (MarcoFalke)

Pull request description:

  This deletes some dead code

ACKs for top commit:
  Sjors:
    ACK fa061bfcdb if CI is also happy
  rkrux:
    utACK fa061bf

Tree-SHA512: 6c0b0705caa4ad024e6b921bd7f65aaa055d1f12f7884cd61823cbf0c32e46697ddbdaa209ab449d6a1df9761ce5d53763e25f26e4c36ce4c685b7524f5a3dd9
2025-05-09 16:47:55 +01:00
Vasil Dimov e49a7274a2 rpc: Avoid join-split roundtrip for user:pass for auth credentials 2025-05-09 17:07:28 +02:00
laanwj 98ff38a6f1 rpc: Perform HTTP user:pass split once in `RPCAuthorized` 2025-05-09 16:58:08 +02:00
laanwj 879a17bcb1 rpc: Store all credentials hashed in memory
This gets rid of the special-casing of `strRPCUserColonPass` by hashing
cookies as well as manually provided `-rpcuser`/`-rpcpassword` with a
random salt before storing them.

Also take the opportunity to modernize the surrounding code a bit. There
should be no end-user visible differences in behavior.
2025-05-09 16:58:06 +02:00
laanwj 4ab9bedee9 rpc: Undeprecate rpcuser/rpcpassword, change message to security warning
Back in 2015, in #7044, we added configuration option `rpcauth` for
multiple RPC users. At the same time the old settings for single-user
configuration `rpcuser` and `rpcpassword` were "soon" to be deprecated.

The main reason for this deprecation is that while `-rpcpassword` stores
the password in plain text, `-rpcauth` stores a hash, so it doesn't
appear in the configuration in plain text.

As the options are still in active use, actually removing them is
expected to be a hassle to many, and it's not clear that is worth it. As
for the security risk, in many kinds of setups (no wallet,
containerized, single-user-single-application, local-only, etc) it is an
unlikely point of escalation.

In the end, it is good to encourage secure practices, but it is the
responsibility of the user. Log a clear warning but remove the
deprecation notice.

Closes #29240.
2025-05-09 16:57:27 +02:00
MarcoFalke fa061bfcdb
Remove create options from wallet tool
Just create descriptor wallets.
2025-05-09 15:07:04 +02:00
MarcoFalke fa2125e7b8
Remove unused IsSingleKey 2025-05-09 15:06:51 +02:00
MarcoFalke fab5e2a094
doc: Remove note about bdb wallets 2025-05-09 15:06:50 +02:00
MarcoFalke eeeef88d46
doc: fix typo in abortrescan rpc 2025-05-09 15:06:37 +02:00
MarcoFalke fa7e5c15a7
Remove unused LegacyDataSPKM::DeleteRecords() 2025-05-09 15:06:20 +02:00
merge-script b070ce1696
Merge bitcoin/bitcoin#31360: depends: Avoid using helper variables in toolchain file
7343a1846c depends: Avoid using helper variables in toolchain file (Hennadii Stepanov)

Pull request description:

  Using helper variables has two issues:
  1. They contaminate the global namespace of the main build script.
  2. They can be used as `set(var)`, effectively [exposing](https://cmake.org/cmake/help/latest/command/set.html) a cache variable `var`, which makes the toolchain file susceptible to the build environment.

  The [`depends/Makefile`](https://github.com/bitcoin/bitcoin/blob/master/depends/Makefile) can generate values with "not-set" semantics as empty strings or strings containing only spaces. For example:2638fdb4f9/depends/Makefile (L157)
  Therefore, [`MATCHES`](https://cmake.org/cmake/help/latest/command/if.html#matches) must be used rather than [`STREQUAL`](https://cmake.org/cmake/help/latest/command/if.html#strequal).

ACKs for top commit:
  purpleKarrot:
    ACK 7343a1846c

Tree-SHA512: f2235321ac13daee8e82fa1ae9d02b95097a696265ad3a31fbda9cbc3c387c1dc7d01951154f99828468e50b73ed2889a6fa2720007f519dd11fe25ee5303d23
2025-05-09 14:04:39 +01:00
MarcoFalke ffff949472
remove NotifyWatchonlyChanged
The signal is never called.
2025-05-09 15:03:08 +02:00
MarcoFalke fa62a013a5
remove dead flush()
It is confusing that the chain client flush happens between
StopHTTPServer and StopMapPort. Also, it is unused code. Seems best to
just add it back properly when it is needed again.
2025-05-09 14:59:34 +02:00
MarcoFalke fa5f3e62c8
vcpkg: Remove bdb 2025-05-09 14:58:38 +02:00
fanquake 415650cea9
guix: move *-check.py scripts under contrib/guix
These scripts are not meant for general developer usage. They are for
use on the release binaries, which have been compiled in an environment
that makes various assumptions in regards to c library, compiler
options, hardening options, patching etc.
2025-05-09 13:42:07 +01:00
merge-script 5b8752198e
Merge bitcoin/bitcoin#32454: tracing: fix invalid argument in mempool_monitor
31c5ebc400 tracing: fix invalid argument in mempool_monitor (William Casarin)

Pull request description:

  The mempool_monitor tracing tool is incorrectly reading the reason as the first argument. Fix this!

  Noticed this during the bitcoin++ mempool hackathon 😅

  cc 0xB10C

ACKs for top commit:
  0xB10C:
    Code Review ACK 31c5ebc400

Tree-SHA512: 6f3d64f0f75a44e1fdcad71af8e737ce948833498cd3879ef74cbabf53e3649145b83febceca19b1662de55346c199bf4259e17f5b28cf0352aefa730e07ea63
2025-05-09 09:21:35 +01:00
William Casarin 31c5ebc400 tracing: fix invalid argument in mempool_monitor
The mempool_monitor tracing tool is incorrectly reading the reason
as the first argument. Fix this!
2025-05-08 22:04:28 -07:00
Ryan Ofsky ad5cd129f3
Merge bitcoin/bitcoin#30660: qa: Verify clean shutdown on startup failure
10845cd7cc qa: Add feature_framework_startup_failures.py (Hodlinator)
28e282ef9a qa: assert_raises_message() - Stop assuming certain structure for exceptions (Hodlinator)
1f639efca5 qa: Work around Python socket timeout issue (Hodlinator)
9b24a403fa qa: Only allow calling TestNode.stop() after connecting (Hodlinator)
6ad21b4c01 qa: Include ignored errors in RPC connection timeout (Hodlinator)
879243e81f qa refactor: wait_for_rpc_connection - Treat OSErrors the same (Hodlinator)

Pull request description:

  Improves handling of startup errors in functional tests and puts tests in place to ensure knock-on errors don't creep in.
  - `wait_for_rpc_connection()` now appends specific failures leading up to the `Unable to connect to bitcoind` error to that error message:
    `[node 0] Unable to connect to bitcoind after 60s (ignored errors: {'missing_credentials': 1, 'OSError.ECONNREFUSED': 239}, latest error: ConnectionRefusedError(111, 'Connection refused'))`
  - Fixes Windows Python issue where `socket.timeout` exceptions end up with unset `errno`-fields.
  - Also adds comments, refactors code, improves logging.

  The underlying purpose is to ensure developer efficiency in finding root causes of test failures.

  Prior iterations of the PR partially focused on fixing the same issue as #31620.
  Originally inspired by #30390.

  ### Testing

  Can be tested by reverting either faf2f2c654 or fae3bf6b87 from #31620, or the "qa: Avoid calling stop-RPC if not connected" from this PR, and running *feature_framework_startup_failures.py*.

ACKs for top commit:
  l0rinc:
    ACK 10845cd7cc
  ryanofsky:
    Code review ACK 10845cd7cc. Only changes since last review were adding a new commit tweaking assert_raises_message(), extending the new test to have a self-check, and to pass through all options to child tests instead of a hardcoded list of options. I left some cleanup suggestions below but they are not important.

Tree-SHA512: f0235c5cbb6d1bb85d8dc5de492a08a34f6edc83499cbf0a5f9a3824809ff84635888c62c9c01101e3cc9ef9f1cdee2c9ab6537fea6feeb005b29f428caf8b22
2025-05-08 16:57:46 -04:00
Cory Fields aeea5f0ec1 thread-safety: add missing lock annotation
No warning is currently emitted because our reverse_lock does not enforce our
thread-safety annotations. Once it is fixed, the unlock would cause a warning.
2025-05-08 20:14:00 +00:00
Cory Fields 832c57a534 thread-safety: modernize thread safety macros
Clang added new "capability"-based thread-safety attributes years ago, but the
old ones remain supported for backwards-compatibility.

However, while adding annotations for our reverse_lock, I noticed that there
is a difference between the unlock_function and release_capability attributes.

unlock_function actually maps to release_generic_capability, which does not
work properly when implementing a scoped unlocker.

To be consistent, the other capability-based attributes are updated here as
well. To avoid having to update our macro usage throughout the codebase, I
reused our existing ones.

Additionally, SHARED_UNLOCK_FUNCTION is added here, as a subsequent PR will
introduce annotations for shared_mutex and shared_lock.
2025-05-08 20:13:46 +00:00
Cory Fields 7b816c4e00 threading: rename CSemaphore methods to match std::semaphore 2025-05-08 18:42:09 +00:00
Ava Chow 1656f6dbba
Merge bitcoin/bitcoin#32448: contrib: remove bdb exception from FORTIFY check
f9dfe8d5e0 contrib: remove bdb exception from FORTIFY check (fanquake)

Pull request description:

  BDB has been removed (#28710), so we no-longer need to ignore functions from BDB in this check.

  Guix building this branch, and looking for `*_chk` functions across all binaries produces:
  ```
  # nm -C * | grep -i _chk | sort | uniq
                   U __fdelt_chk@GLIBC_2.15
                   U __fprintf_chk@GLIBC_2.3.4
                   U __fread_chk@GLIBC_2.7
                   U __longjmp_chk@GLIBC_2.11
                   U __memcpy_chk@GLIBC_2.3.4
                   U __printf_chk@GLIBC_2.3.4
                   U __snprintf_chk@GLIBC_2.3.4
                   U __sprintf_chk@GLIBC_2.3.4
                   U __stack_chk_fail@GLIBC_2.4
                   U __vsnprintf_chk@GLIBC_2.3.4
  ```

ACKs for top commit:
  achow101:
    ACK f9dfe8d5e0
  theuni:
    utACK f9dfe8d5e0
  laanwj:
    Code review ACK f9dfe8d5e0

Tree-SHA512: e9491c8b348a0d777c3f7186cab48b478548654712f8b85e7bde2f8b94f3a8b52bc7be8fb1b4a486954359d3109cfb74e3485ccfff67c6546f0efcabf2eda0e0
2025-05-08 11:06:59 -07:00
Sjors Provoost a04f17a188
doc: warn that CheckBlock() underestimates sigops
Counting sigops in the witness and for p2sh requires
context that CheckBlock()  does not have, so it only
counts a subset of sigops.

The check here was introduced by Satoshi as a "cleanup" in
f1e1fb4bde. With the attempted
introduction of OP_EVAL, it was replaced by the check in
ConnectBlock(). Commit e679ec969c
marked this code as a placeholder for backward compatibility.

Then when P2SH replaced OP_EVAL in 922e8e2929
the phrase "compatibility-breaking" was replaced by a simple
observation that before v0.6 this is how sigops were counted.

It's unclear why the check was kept and there were no review comments
about it.
2025-05-08 18:37:49 +02:00
fanquake ab878a7e74
build: simplify *ifaddr handling
We really just want to skip this when building for Windows. So do that,
and remove the two header checks (we also already use both of these
headers, unguarded, in the !windows part of the codebase).

Squash the two *iffaddrs defines into one, as I haven't seen an
iffaddrs.h that implements one, but not the other.
2025-05-08 16:49:58 +01:00
Ryan Ofsky 1b4ddb0c2d
Merge bitcoin/bitcoin#32356: cmake: Respect user-provided configuration-specific flags
edde96376a cmake: Respect user-provided configuration-specific flags (Hennadii Stepanov)

Pull request description:

  This PR addresses [this](https://github.com/bitcoin/bitcoin/issues/31491#issuecomment-2542140874) comment:
  > I suppose that should only happen if the `-O3` isn't coming from an explicitly set `CMAKE_CXX_FLAGS_RELEASE`.

  With this PR:
  ```
  $ cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS_RELEASE="-O3"
  <snip>
  C++ compiler flags .................... -O3 -std=c++20 -fPIC -fno-extended-identifiers -fdebug-prefix-map=/home/hebasto/dev/bitcoin/src=. -fmacro-prefix-map=/home/hebasto/dev/bitcoin/src=. -fstack-reuse=none -Wall -Wextra -Wformat -Wformat-security -Wvla -Wredundant-decls -Wdate-time -Wduplicated-branches -Wduplicated-cond -Wlogical-op -Woverloaded-virtual -Wsuggest-override -Wimplicit-fallthrough -Wunreachable-code -Wbidi-chars=any -Wundef -Wno-unused-parameter -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -Wstack-protector -fstack-protector-all -fcf-protection=full -fstack-clash-protection
  Linker flags .......................... -O3 -fstack-reuse=none -fstack-protector-all -fcf-protection=full -fstack-clash-protection -Wl,-z,relro -Wl,-z,now -Wl,-z,separate-code -fPIE -pie
  ```
  and
  ```
  $ cmake -B build -DCMAKE_BUILD_TYPE=Release
  <snip>
  C++ compiler flags .................... -O2 -std=c++20 -fPIC -fno-extended-identifiers -fdebug-prefix-map=/home/hebasto/dev/bitcoin/src=. -fmacro-prefix-map=/home/hebasto/dev/bitcoin/src=. -fstack-reuse=none -Wall -Wextra -Wformat -Wformat-security -Wvla -Wredundant-decls -Wdate-time -Wduplicated-branches -Wduplicated-cond -Wlogical-op -Woverloaded-virtual -Wsuggest-override -Wimplicit-fallthrough -Wunreachable-code -Wbidi-chars=any -Wundef -Wno-unused-parameter -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -Wstack-protector -fstack-protector-all -fcf-protection=full -fstack-clash-protection
  Linker flags .......................... -O2 -fstack-reuse=none -fstack-protector-all -fcf-protection=full -fstack-clash-protection -Wl,-z,relro -Wl,-z,now -Wl,-z,separate-code -fPIE -pie
  ```

  When calling `cmake` repeatedly using the same build directory, each newly provided `CMAKE_CXX_FLAGS_RELEASE` value will be accommodated. In such a scenario, if the user wishes to revert to the build system defaults, they should unset the `CMAKE_CXX_FLAGS_RELEASE` variable by passing `-UCMAKE_CXX_FLAGS_RELEASE`  to `cmake`.

  ---

  This PR does not aim to resolve _all_ issues mentioned in https://github.com/bitcoin/bitcoin/issues/31491.

ACKs for top commit:
  purpleKarrot:
    ACK edde96376a
  janb84:
    ACK [edde963](edde96376a)
  ryanofsky:
    Code review ACK edde96376a

Tree-SHA512: 1fbc879bd02cf0be726ced490f65985e728f0686ccb3a32cd38787b56377aa666e1965448e5069515abc814df49a0083c8000bc3f6f322f5f395695638168fb6
2025-05-08 11:06:13 -04:00
Sebastian Falbesoner 1ee698fde2 test: refactor: negate signature-s using libsecp256k1
Co-authored-by: laanwj <126646+laanwj@users.noreply.github.com>
2025-05-08 15:52:38 +02:00
fanquake f9dfe8d5e0
contrib: remove bdb exception from FORTIFY check
BDB has been removed (#28710), so we no-longer need to ignore functions
from BDB in this check.
2025-05-08 14:37:26 +01:00
merge-script 66c968b4b4
Merge bitcoin/bitcoin#32444: doc: swap "Docker image" for "container image"
1372eb09c5 doc: swap "Docker image" for "container image" (fanquake)

Pull request description:

  I haven't used Docker for some time (now Podman), and the images are generic, so just use "container image". I'll be pushing some changes to https://github.com/fanquake/core-review/tree/master/guix, to reflect this.

ACKs for top commit:
  janb84:
    ACK 1372eb09c5
  laanwj:
    ACK 1372eb09c5
  hebasto:
    ACK 1372eb09c5.

Tree-SHA512: 45bb74d25a0faf7e5c3666d6897fb6b999144308c43cdf8a290d3a4210285b1e95286d27bb3d90bc50be4784c2242ad3f93794086f4634439a46a48ff68c7343
2025-05-08 13:50:24 +01:00
merge-script 6469752952
Merge bitcoin/bitcoin#32434: lint: Remove string exclusion from locale check
fa24fdcb7f lint: Remove string exclusion from locale check (MarcoFalke)

Pull request description:

  The exclusion isn't needed. In fact, it prevents detection of `"bla" + wrong()`.

  For example, the following is not detected:

  ```diff
  diff --git a/src/wallet/rpc/addresses.cpp b/src/wallet/rpc/addresses.cpp
  index 1c2951deee..c1209013e5 100644
  --- a/src/wallet/rpc/addresses.cpp
  +++ b/src/wallet/rpc/addresses.cpp
  @@ -336,7 +336,8 @@ RPCHelpMan addmultisigaddress()
   RPCHelpMan keypoolrefill()
   {
       return RPCHelpMan{"keypoolrefill",
  -                "\nFills the keypool."+
  +                "\nRefills each descriptor keypool in the wallet up to the specified number of new keys.\n"
  +                "By default, descriptor wallets have 4 active ranged descriptors (\"legacy\", \"p2sh-segwit\", \"bech32\", and \"bech32m\"), each with " + std::to_string(DEFAULT_KEYPOOL_SIZE) + " entries.\n" +
           HELP_REQUIRING_PASSPHRASE,
                   {
                       {"newsize", RPCArg::Type::NUM, RPCArg::DefaultHint{strprintf("%u, or as set by -keypool", DEFAULT_KEYPOOL_SIZE)}, "The new keypool size"},
  ```

  Fix the script by detecting it.

ACKs for top commit:
  laanwj:
    Code review ACK fa24fdcb7f.
  rkrux:
    ACK fa24fdcb7f
  w0xlt:
    ACK fa24fdcb7f

Tree-SHA512: cb7e6ed9fec5d2089e94031329ebf26b83a1814ffbbbca94f7527c127bc759d13c0f4ea79b71ff7f5f009d071dcf01958c8921163d6dc5e1ae6256cc40b57eea
2025-05-08 10:42:30 +01:00
fanquake 1372eb09c5
doc: swap "Docker image" for "container image"
I haven't used Docker for some time (now Podman), and the images are
generic, so just use container image. I'll be pushing some changes to
https://github.com/fanquake/core-review/tree/master/guix, to reflect this.
2025-05-08 10:20:21 +01:00
merge-script 03ebdd0793
Merge bitcoin/bitcoin#32437: crypto: disable ASan for sha256_sse4 with Clang
4e8ab5e00f crypto: disable ASan for sha256_sse4 with Clang (fanquake)

Pull request description:

  This also fails to compile when optimisations are being used, see: https://github.com/bitcoin/bitcoin/issues/31913.
  So just disable ASan under any optimisation level.

  Closes #31913.

ACKs for top commit:
  maflcko:
    lgtm ACK 4e8ab5e00f
  davidgumberg:
    Tested ACK 4e8ab5e00f
  laanwj:
    Code review ACK 4e8ab5e00f

Tree-SHA512: 680fb424f43b35730e03e0c7443c80445a2cf423d4f9161414ea22fea0b955f49197f8a96d1241896d981c6c13814d3eb7b5e4d8c9138813fb69e437ac4768ea
2025-05-08 09:08:36 +01:00
Ava Chow 95bb305b96
Merge bitcoin/bitcoin#32429: docs: Improve `keypoolrefill` RPC docs
ff35a4b021 docs: Improve `keypoolrefill` RPC docs (w0xlt)

Pull request description:

  Update `keypoolrefill` RPC docs to make it clear that descriptor wallets have 4 ScriptPubKeyManagers by default and each of them is updated in this command, as suggested https://github.com/bitcoin/bitcoin/issues/29924#issuecomment-2849321859

  Closes https://github.com/bitcoin/bitcoin/issues/29924

ACKs for top commit:
  achow101:
    ACK ff35a4b021
  brunoerg:
    code review ACK ff35a4b021

Tree-SHA512: b6b9abe3fecebf9551b4ce9280794292c6ac44ccaeb2b9d60eeb4b2c177fe8372d0fe103f99c9cc0baeb2559ec019d1c495c233f24a600531153a38eeacb9670
2025-05-07 14:55:49 -07:00
Ava Chow 1b1b9f32cf
Merge bitcoin/bitcoin#32440: test: remove bdb assert in tool_wallet.py
e08e6567f2 test: remove assert_dump since it is not used anymore (kevkevinpal)
4b6dd9790b test: remove bdb assert in tool_wallet.py (kevkevinpal)

Pull request description:

  As suggested in https://github.com/bitcoin/bitcoin/pull/32438#issuecomment-2859123413

  legacy wallet and the BDB dependency was removed (https://github.com/bitcoin/bitcoin/pull/28710) so this assert is safe to delete

ACKs for top commit:
  davidgumberg:
    reACK e08e6567f2
  achow101:
    ACK e08e6567f2
  brunoerg:
    reACK e08e6567f2
  theStack:
    re-ACK e08e6567f2

Tree-SHA512: 6417537d7b9b5da6039dfcc94a86107211d57dcca43becea6f95d4a95f342e12918b0ff6a562261ba538b7b206de7d327e52bdb7d49e353f1917df8668558a99
2025-05-07 11:51:17 -07:00
kevkevinpal e08e6567f2
test: remove assert_dump since it is not used anymore 2025-05-07 14:18:12 -04:00
w0xlt ff35a4b021 docs: Improve `keypoolrefill` RPC docs 2025-05-07 14:44:10 -03:00
Sebastian Falbesoner 4b24186756 test: add test for decoding PSBT with MuSig2 PSBT key types (BIP 373) 2025-05-07 19:29:28 +02:00
Sebastian Falbesoner 8ba245cb83 test: add constants for MuSig2 PSBT key types (BIP 373)
Also, support serialization of lists of byte-strings as PSBTMap values,
which will be simply concatenated without any compact-size prefixes
(neither for the individual items nor for the size of the list).
2025-05-07 19:28:08 +02:00
kevkevinpal 4b6dd9790b
test: remove bdb assert in tool_wallet.py 2025-05-07 13:02:54 -04:00
Novo 97d383af6d Test updating non-ranged descriptor with [0,0] range succeeds 2025-05-07 17:33:12 +01:00
Hennadii Stepanov 7343a1846c
depends: Avoid using helper variables in toolchain file
Using helper variables has two issues:
1. They contaminate the global namespace of the main build script.
2. They can be used as `set(var)`, effectively exposing a cache variable
`var`, which makes the toolchain file susceptible to the build
environment.
2025-05-07 17:02:53 +01:00
marcofleon 0671d66a8e wallet, refactor: Convert uint256 to Txid in wallet
Switch all instances of transactions from uint256 to Txid in the
wallet and relevant tests.
2025-05-07 16:17:19 +01:00
marcofleon c8ed51e62b wallet, refactor: Convert uint256 to Txid in wallet interfaces
In most cases throughout the wallet, the implicit conversion from `Txid` to
`const uint256&` works. However, `commitBumpTransaction` requires a `uint256&`
out parameter, so `bumped_txid` in `feebumper::CommitTransaction` is also
updated here to use `Txid`.
2025-05-07 15:59:02 +01:00
marcofleon b3214cefe6 qt, refactor: Convert uint256 to Txid in the GUI
Switch all instances of a transaction from a uint256 to the Txid type.
2025-05-07 15:59:02 +01:00
merge-script efac285a0d
Merge bitcoin/bitcoin#28710: Remove the legacy wallet and BDB dependency
de054df6dc contrib: Remove legacy wallet RPCs from bash completions (Ava Chow)
5dff04a1bb legacy spkm: Make IsMine() and CanProvide() private and migration only (Ava Chow)
c0f3f3264f wallet: Remove unused db functions (Ava Chow)
83af1a3cca wallet: Delete LegacySPKM (Ava Chow)
8ede6dea0c wallet, rpc: Remove legacy wallet only RPCs (Ava Chow)
4de3cec28d test: rpcs disabled for descriptor wallets will be removed (Ava Chow)
84f671b01d test: Run multisig script limit test (Ava Chow)
810476f31e test: Remove unused options and variables, correct comments (Ava Chow)
04a7a7a28c build, wallet, doc: Remove BDB (Ava Chow)

Pull request description:

  The final step of #20160.

  A bare minimum of legacy wallet code is kept in order to perform wallet migration. Migration of legacy wallets uses the independent BDB parser and a minimal `LegacyDataSPKM` that allows the legacy data to be loaded so that the migration can be completed.

  BDB has been removed as a dependency and documentation have been updated to reflect that.

ACKs for top commit:
  Sjors:
    re-ACK de054df6dc
  maflcko:
    re-ACK de054df6dc 🔗
  w0xlt:
    reACK de054df6dc
  rkrux:
    Concept ACK de054df6dc

Tree-SHA512: 16a6c265bc1ada5e7a5ef9b95f0ff65015672ca46d9a43b7e10d60e9e085052e9bbfe01ac3e494cc606afb652a1b476b10e434d13e9877b67d2cb0196a9bd190
2025-05-07 15:19:17 +01:00
MarcoFalke fa24fdcb7f
lint: Remove string exclusion from locale check
The string exclusion would fail to detect `"bla" + wrong()`.

Also, remove /* */ comment exclusion, which would fail to detect stuff
like `/* bla */ wrong()`.

Instead, require the function to be called by adding \\( to the regex.

Finally, also remove the section in the dev notes, because:

* It was outdated and missing some functions such as std::to_string in
  the list.
* The maintenance overhead of having to update two places is fragile and
  questionable.
* Many other linters are also not mentioned in the dev notes, even
  though they are important.
* A dev (and CI) is more likely to run the linters than to read the dev
  notes.
* The dev notes are more than 1000 lines of dense information. It would
  be easier to digest if they focused on the important stuff that is not
  checked by automated tools.
2025-05-07 13:24:41 +02:00
fanquake 4e8ab5e00f
crypto: disable ASan for sha256_sse4 with Clang
This can alsofail to compile when optimisations are being used, see:
https://github.com/bitcoin/bitcoin/issues/31913.
So disable just ASan for this function under any optimisation level.
2025-05-07 11:53:21 +01:00
merge-script 6d5edfcc58
Merge bitcoin/bitcoin#32388: fuzz: Remove unused TimeoutExpired catch in fuzz runner
fa4804009c fuzz: Remove unused TimeoutExpired catch in fuzz runner (MarcoFalke)

Pull request description:

  Currently, the way to check for libFuzzer is to search the stderr of the fuzz executable when passed `-help=1` for the string `libFuzzer`. See also 14b8dfb2bd/contrib/devtools/deterministic-fuzz-coverage/src/main.rs (L90-L101)

  The python test runner additionally includes a timeout catch, which was needed before the plain `read_file` fallback was implemented, see 14b8dfb2bd/src/test/fuzz/fuzz.cpp (L251).

  However, it is no longer needed and the printed error message would be wrong, so remove it.

  (side-note: On Windows the fuzz executable seems to time out when an assert is hit in a debug build, see https://github.com/bitcoin/bitcoin/issues/32341#issuecomment-2842716175. However, no one is running fuzz debug on Windows. Also, the newly added debug logging is a preferable replacement in this case anyway.)

ACKs for top commit:
  kevkevinpal:
    crACK [fa48040](fa4804009c)
  Crypt-iQ:
    crACK fa4804009c
  marcofleon:
    crACK fa4804009c
  brunoerg:
    code review ACK fa4804009c

Tree-SHA512: 64f5e3862fece9ab2b6592615b72b81e9c087dcd394b1d062a96df0d88d8b5999674f0faa1165a5998c05289c1874e29311d7b24d84fee9bc6c46d1662d29e4d
2025-05-07 11:52:09 +01:00
Ava Chow de054df6dc contrib: Remove legacy wallet RPCs from bash completions
These RPCs no longer exist.
2025-05-06 16:53:16 -07:00
Ava Chow 5dff04a1bb legacy spkm: Make IsMine() and CanProvide() private and migration only 2025-05-06 16:53:16 -07:00
Ava Chow c0f3f3264f wallet: Remove unused db functions
SOme db functions were for BDB, these are no longer needed.
2025-05-06 16:53:16 -07:00
Ava Chow 83af1a3cca wallet: Delete LegacySPKM
Deletes LegacyScriptPubKeyMan and related tests

Best reviewed with `git diff --patience` or `git diff --histogram`
2025-05-06 16:53:16 -07:00
Ava Chow 59d3e4ed34
Merge bitcoin/bitcoin#32415: scripted-diff: adapt script error constant names in feature_taproot.py
b5f580c580 scripted-diff: adapt script error constant names in feature_taproot.py (Sebastian Falbesoner)

Pull request description:

  While reviewing #31622 I noticed that the constant name `(SCRIPT_)ERR_SIG_HASHTYPE` is used for two different script verification error codes, namely one for legacy and one for Schnorr signatures:

  eba5f9c4b6/src/script/script_error.cpp (L56-L57)
  eba5f9c4b6/test/functional/feature_taproot.py (L600)

  In order to resolve this confusion, this PR adapts all script error constant names in the functional tests (currently only in feature_taproot.py) to the ones used in our C++ codebase (see [script_error.cpp](https://github.com/bitcoin/bitcoin/blob/master/src/script/script_error.cpp)) with a scripted diff. This also makes checking whether we have test coverage for a certain script error easier.

ACKs for top commit:
  jamesob:
    crACK b5f580c580
  achow101:
    ACK b5f580c580
  rkrux:
    tACK b5f580c580
  stratospher:
    ACK b5f580c. liked the consistency in script error names.

Tree-SHA512: bc0ccec70bc3cb6ce51ce8e27a5e54770d1bb93c1db5a9c815caa25f3d96ebb382104bd9b51626f501d4f5b95148db8d20c806a27153e9bb9cf823a20d3046c0
2025-05-06 15:25:57 -07:00
Ava Chow fffb272c25
Merge bitcoin/bitcoin#29532: Refactor BnB tests
85368aafa0 test: Run simple tests at various feerates (Murch)
d610951c15 test: Recreate BnB iteration exhaustion test (Murch)
2a1b2754f1 test: Remove redundant repeated test (Murch)
4781f5c8be test: Recreate simple BnB failure tests (Murch)
a94030ae98 test: Recreate BnB clone skipping test (Murch)
7db6f012c0 test: Move BnB feerate sensitivity tests (Murch)
2bafc46261 test: Recreate simple BnB success tests (Murch)

Pull request description:

  This PR is splitting off some of the improvements made in #28985 and starts addressing the issues raised in #27754.

  I aim to completely replace `coinselector_tests` with `coinselection_tests`. The goal is to generally use coins created per a nominal _effective value_ so we can get away from testing with `CoinSelectionParams` that are non-representative and effectuate counterintuitive behavior such as `feerate = 0` or `cost_of_change = 0`

ACKs for top commit:
  achow101:
    ACK 85368aafa0
  monlovesmango:
    ACK 85368aafa0
  w0xlt:
    ACK 85368aafa0

Tree-SHA512: 1a984837b4efddc0d8abe11668898fb207fb539e784bf911d4038211274b82e0fe1f8fffe7e5a19e0e013ccb7dc40e3f62d853a2a729980d0d935e66f12b9156
2025-05-06 15:15:13 -07:00
Hennadii Stepanov 3bbdbc0a5e
qt, docs: Unify term "clipboard" 2025-05-06 22:06:24 +01:00
Ava Chow 8ede6dea0c wallet, rpc: Remove legacy wallet only RPCs 2025-05-06 12:33:16 -07:00
Ava Chow 4de3cec28d test: rpcs disabled for descriptor wallets will be removed 2025-05-06 12:33:16 -07:00
Ava Chow 84f671b01d test: Run multisig script limit test
This test was mistakenly disabled.
2025-05-06 12:33:16 -07:00
Ava Chow 810476f31e test: Remove unused options and variables, correct comments 2025-05-06 12:33:16 -07:00
Ava Chow 04a7a7a28c build, wallet, doc: Remove BDB 2025-05-06 12:21:32 -07:00
merge-script 44057fe38c
Merge bitcoin/bitcoin#32287: build: Fix `macdeployqtplus` after switching to Qt 6
84de8c93e7 ci: Add `deploy` target for native macOS CI job (Hennadii Stepanov)
fad57e9e0f build: Fix `macdeployqtplus` after switching to Qt 6 (Hennadii Stepanov)
938208d91a build: Resolve `@rpath` in `macdeployqtplus` (Hennadii Stepanov)

Pull request description:

  Homebrew's Qt 6 package — namely `qt` or `qt@6` — introduces a few differences that must be properly handled by the `macdeployqtplus` script:

  1. Use of `@rpath` references:
  ```
  % objdump --macho --dylibs-used $(brew --prefix qt@5)/Frameworks/QtGui.framework/QtGui
  /usr/local/opt/qt@5/Frameworks/QtGui.framework/QtGui:
  /usr/local/opt/qt@5/lib/QtGui.framework/Versions/5/QtGui (compatibility version 5.15.0, current version 5.15.16)
  /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 2575.30.19)
  /System/Library/Frameworks/Metal.framework/Versions/A/Metal (compatibility version 1.0.0, current version 367.6.0)
  /usr/local/Cellar/qt@5/5.15.16_1/lib/QtCore.framework/Versions/5/QtCore (compatibility version 5.15.0, current version 5.15.16)
  /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0)
  /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
  /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 1889.2.7)
  /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 3208.0.0)
  /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
  /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
  /usr/local/opt/libpng/lib/libpng16.16.dylib (compatibility version 64.0.0, current version 64.0.0)
  /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.12)
  /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 65.0.0)
  /usr/local/opt/md4c/lib/libmd4c.0.dylib (compatibility version 0.0.0, current version 0.5.2)
  /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1800.105.0)
  /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1351.0.0)
  /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 3208.0.0)
  /System/Library/Frameworks/CoreText.framework/Versions/A/CoreText (compatibility version 1.0.0, current version 844.2.0)
  /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
  % objdump --macho --dylibs-used $(brew --prefix qt@6)/Frameworks/QtGui.framework/QtGui
  /usr/local/opt/qt/Frameworks/QtGui.framework/QtGui:
  /usr/local/opt/qt/lib/QtGui.framework/Versions/A/QtGui (compatibility version 6.0.0, current version 6.9.0)
  /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 2575.30.19)
  /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 170.0.0)
  /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
  /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO (compatibility version 1.0.0, current version 1.0.0)
  /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 3208.0.0)
  /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 1889.2.7)
  /System/Library/Frameworks/CoreText.framework/Versions/A/CoreText (compatibility version 1.0.0, current version 844.2.0)
  /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 3208.0.0)
  /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore (compatibility version 1.2.0, current version 1.11.0)
  /System/Library/Frameworks/Metal.framework/Versions/A/Metal (compatibility version 1.0.0, current version 367.6.0)
  /usr/local/opt/glib/lib/libglib-2.0.0.dylib (compatibility version 8401.0.0, current version 8401.0.0)
  @rpath/QtDBus.framework/Versions/A/QtDBus (compatibility version 6.0.0, current version 6.9.0)
  /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
  /usr/local/opt/libpng/lib/libpng16.16.dylib (compatibility version 64.0.0, current version 64.0.0)
  /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.12)
  /usr/local/opt/harfbuzz/lib/libharfbuzz.0.dylib (compatibility version 61100.0.0, current version 61100.0.0)
  /usr/local/opt/md4c/lib/libmd4c.0.dylib (compatibility version 0.0.0, current version 0.5.2)
  /usr/local/opt/freetype/lib/libfreetype.6.dylib (compatibility version 27.0.0, current version 27.2.0)
  /usr/local/opt/glib/lib/libgthread-2.0.0.dylib (compatibility version 8401.0.0, current version 8401.0.0)
  @rpath/QtCore.framework/Versions/A/QtCore (compatibility version 6.0.0, current version 6.9.0)
  /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
  /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0)
  /System/Library/Frameworks/UniformTypeIdentifiers.framework/Versions/A/UniformTypeIdentifiers (compatibility version 1.0.0, current version 709.0.0)
  /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1800.105.0)
  /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1351.0.0)
  /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 1226.0.0)
  /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
  ```

  2. Different directory layout:
  ```
  % ls -l $(brew --prefix qt@5)/
  total 544
  drwxr-xr-x   79 hebasto  admin    2528 13 Nov 06:22 Frameworks
  -rw-r--r--    1 hebasto  admin    7533 16 Apr 09:09 INSTALL_RECEIPT.json
  -rw-r--r--    1 hebasto  admin   22961 13 Nov 06:22 LICENSE.FDL
  -rw-r--r--    1 hebasto  admin   36363 13 Nov 06:22 LICENSE.GPL3-EXCEPT
  -rw-r--r--    1 hebasto  admin   15351 13 Nov 06:22 LICENSE.GPLv2
  -rw-r--r--    1 hebasto  admin   35641 13 Nov 06:22 LICENSE.GPLv3
  -rw-r--r--    1 hebasto  admin   26828 13 Nov 06:22 LICENSE.LGPLv21
  -rw-r--r--    1 hebasto  admin    8174 13 Nov 06:22 LICENSE.LGPLv3
  -rw-r--r--    1 hebasto  admin  106262 13 Nov 06:22 LICENSE.QT-LICENSE-AGREEMENT
  -rw-r--r--    1 hebasto  admin    3842 13 Nov 06:22 README
  drwxr-xr-x   57 hebasto  admin    1824 16 Apr 09:09 bin
  drwxr-xr-x    4 hebasto  admin     128 13 Nov 06:22 doc
  drwxr-xr-x   95 hebasto  admin    3040 13 Nov 06:22 include
  drwxr-xr-x  119 hebasto  admin    3808 16 Apr 09:09 lib
  drwxr-xr-x    8 hebasto  admin     256 13 Nov 06:22 libexec
  drwxr-xr-x   79 hebasto  admin    2528 16 Apr 09:09 mkspecs
  drwxr-xr-x   15 hebasto  admin     480 13 Nov 06:22 phrasebooks
  drwxr-xr-x   31 hebasto  admin     992 13 Nov 06:22 plugins
  drwxr-xr-x   28 hebasto  admin     896 13 Nov 06:22 qml
  -rw-r--r--    1 hebasto  admin    6952 16 Apr 09:09 sbom.spdx.json
  drwxr-xr-x    3 hebasto  admin      96 13 Nov 06:22 share
  drwxr-xr-x  347 hebasto  admin   11104 13 Nov 06:22 translations
  % ls -l $(brew --prefix qt@6)/share/qt/
  total 0
  drwxr-xr-x    4 hebasto  admin   128 30 Mar 09:49 doc
  drwxr-xr-x   35 hebasto  admin  1120 16 Apr 09:16 libexec
  drwxr-xr-x  167 hebasto  admin  5344 30 Mar 09:49 metatypes
  drwxr-xr-x   70 hebasto  admin  2240 16 Apr 09:16 mkspecs
  drwxr-xr-x  178 hebasto  admin  5696 30 Mar 09:49 modules
  drwxr-xr-x   15 hebasto  admin   480 30 Mar 09:49 phrasebooks
  drwxr-xr-x   31 hebasto  admin   992 30 Mar 09:49 plugins
  drwxr-xr-x   34 hebasto  admin  1088 30 Mar 09:49 qml
  drwxr-xr-x   45 hebasto  admin  1440 30 Mar 09:49 sbom
  drwxr-xr-x  285 hebasto  admin  9120 30 Mar 09:49 translations
  ```

  This PR addresses both issues and additionally adds a `deploy` target to the native macOS CI job to prevent any similar recessions in the future.

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

ACKs for top commit:
  fanquake:
    ACK 84de8c93e7

Tree-SHA512: 27a0eff3cd9317647529ff4571bd79c5dd8f007775b19415c8c27ca4912a60d85074c840cf0443be314d9a404f78bb015029d46dab18e292462249a5d90c6c47
2025-05-06 18:10:22 +01:00
merge-script 229943b513
Merge bitcoin/bitcoin#32086: Shuffle depends instructions and recommend modern make for macOS
22cff32319 doc: recommend gmake for FreeBSD (Sjors Provoost)
b645c52071 doc: recommend modern make for macOS depends (Sjors Provoost)
99e6490dc5 doc: shuffle depends instructions (Sjors Provoost)

Pull request description:

  macOS ships with GNU Make 3.81 from 2006. This has caused
  difficult to debug issues, e.g. #32070 and #30978.

  Tell users / developers who use the depends system to install a modern version of `make`.

  This PR does not change the non-depends build.

  Although Homebrew allows overriding the system `make`, we instead just instruct users to build with `gmake`. This way there should be no impact on other projects they wish to compile.

  To increase the likeliness of anyone actually seeing and following this instruction, the first commit moves things around in `depends/README.md`. It now starts with instructions for a local build and moves cross-compilation to the end. For each platform it shows what to install (`apt install`, `brew install`, etc) and what command to run (`make` or `gmake`).

  There previously was no macOS specific section, so this is added. It points to the general `build-osx.md` for how to install the Xcode Command Line Tools and Homebrew Package Manager.

  I didn't test on an empty system.

  Preview: https://github.com/Sjors/bitcoin/tree/2025/03/mc-make/depends#depends-build

ACKs for top commit:
  maflcko:
    review ACK 22cff32319 🏣
  hebasto:
    re-ACK 22cff32319.
  willcl-ark:
    ACK 22cff32319

Tree-SHA512: 11648ae73f3b70bc2df771e4eddca37221cd88b88bea4139a183e3f67f24a4c3e5aadf61a713ed73f3fc206511dfcf8670e4c4143c49dd4e56e501030be9c7ba
2025-05-06 18:06:38 +01:00
stickies-v 3e6ac5bf77
refactor: validation: mark CheckBlockIndex as const
As a check/test method, this function should not mutate logical
state. Mark it as const to better help ensure this.
2025-05-06 14:29:49 +01:00
stickies-v 61a51eccbb
validation: don't use GetAll() in CheckBlockIndex()
GetAll() is non-const, preventing CheckBlockIndex() from being
const. Rather than add a const GetAll() method, just iterate over
the chainstates directly.

Slight behaviour change by also subjecting non-`IsUsable()`
chainstates to consistency checks.
2025-05-06 14:29:48 +01:00
Hennadii Stepanov edde96376a
cmake: Respect user-provided configuration-specific flags 2025-05-06 13:25:35 +01:00
Sjors Provoost 22cff32319
doc: recommend gmake for FreeBSD
Consistent with doc/build-freebsd.md
2025-05-06 11:24:32 +02:00
Sjors Provoost b645c52071
doc: recommend modern make for macOS depends
macOS ships with GNU Make 3.81 from 2006. This has caused
difficult to debug issues, see e.g.
9157d9e449.

Also add ninja, needed since qt6.
2025-05-06 11:24:32 +02:00
Sjors Provoost 99e6490dc5
doc: shuffle depends instructions
Native compilation is explained before cross-compilation. Move
install and (g)make steps up.

In the Configuring section, use Linux native compilation as the
example instead of Windows cross-compile.
2025-05-06 11:24:16 +02:00
willcl-ark 1e0de7a6ba
fees: document non-monotonic estimation edge case
Closes: #11800

Note: In certain rare edge cases, monotonically increasing estimates may
not be guaranteed. Specifically, given two targets N and M, where M > N,
if a sub-estimate for target N fails to return a valid fee rate, while
target M has valid fee rate for that sub-estimate, target M may result
in a higher fee rate estimate than target N.

See: https://github.com/bitcoin/bitcoin/issues/11800#issuecomment-349697807
2025-05-06 09:50:43 +01:00
Hennadii Stepanov baa848b8d3
Merge bitcoin/bitcoin#32405: build: replace header checks with `__has_include`
e1f543823b build: replace header checks with __has_include (fanquake)

Pull request description:

  Replace the checks in CMake, with the equivalent functionality provided by the standard library (since C++17).
  See https://en.cppreference.com/w/cpp/preprocessor/include.

  Guix Build:
  ```bash
  66d71c866bd111ffe65bc03b9e1653a95eb678f0b04451759c56af868bfc03d5  guix-build-e1f543823b30/output/aarch64-linux-gnu/SHA256SUMS.part
  1a4130d801620a63d86c3069b1fbca39ebc963e610101451d3f48b1c191ca4b3  guix-build-e1f543823b30/output/aarch64-linux-gnu/bitcoin-e1f543823b30-aarch64-linux-gnu-debug.tar.gz
  745adbc7767344a8cd0ebe1e7592239614d89f949558c9b6a2ae58f7b2602a32  guix-build-e1f543823b30/output/aarch64-linux-gnu/bitcoin-e1f543823b30-aarch64-linux-gnu.tar.gz
  cb69d205a20715ee58a324cc2b8475c2bae0443a062f5de2820baa45f822292c  guix-build-e1f543823b30/output/arm-linux-gnueabihf/SHA256SUMS.part
  081774dd903256dafa187ee47a569cd44b01eb16adc9dbfeb54b721abc39e944  guix-build-e1f543823b30/output/arm-linux-gnueabihf/bitcoin-e1f543823b30-arm-linux-gnueabihf-debug.tar.gz
  1dd857fe6b9e75fae746e73fbfc6b77302b4dbb13685baebb10e9686da7bad01  guix-build-e1f543823b30/output/arm-linux-gnueabihf/bitcoin-e1f543823b30-arm-linux-gnueabihf.tar.gz
  e035ba959da69263de2f29282328d4e5b455f94a800a15891801f26ba3b8b325  guix-build-e1f543823b30/output/arm64-apple-darwin/SHA256SUMS.part
  ebf973e0e44be688ea5e1ebae804dfce6e71b7ca8aaca5d8249a14d130f37c3f  guix-build-e1f543823b30/output/arm64-apple-darwin/bitcoin-e1f543823b30-arm64-apple-darwin-codesigning.tar.gz
  3ea687b53032b30d7c4a0760f8a35d19e2f60a8cb3f1f5e2c5cba05897f04e43  guix-build-e1f543823b30/output/arm64-apple-darwin/bitcoin-e1f543823b30-arm64-apple-darwin-unsigned.tar.gz
  ebb6a935f2fbc75167f5e61a039d13f231621f7eb0cbd1292616425f7677739c  guix-build-e1f543823b30/output/arm64-apple-darwin/bitcoin-e1f543823b30-arm64-apple-darwin-unsigned.zip
  9e77422977506f0c3f0373ee19d24c3ad86cbaf3a97cfcf5db202d4fff9c3ae4  guix-build-e1f543823b30/output/dist-archive/bitcoin-e1f543823b30.tar.gz
  62d7c8f63a3702b066f88498f829b2c371baa06c596b71b6d8969f638cc2d356  guix-build-e1f543823b30/output/powerpc64-linux-gnu/SHA256SUMS.part
  60c00fc85dea24548c212330e5fa097020f17bb74f511e7e764b8b33224afce0  guix-build-e1f543823b30/output/powerpc64-linux-gnu/bitcoin-e1f543823b30-powerpc64-linux-gnu-debug.tar.gz
  97b1aa4dc967c9a3767476a262a503900ea77e15b4b292928c6cdddf306cafc9  guix-build-e1f543823b30/output/powerpc64-linux-gnu/bitcoin-e1f543823b30-powerpc64-linux-gnu.tar.gz
  ed67fbb0768ce7b1d4d053de2ba0ea3b2798d01a276adf6430c4a2a413461ee2  guix-build-e1f543823b30/output/riscv64-linux-gnu/SHA256SUMS.part
  83f7b4e6c244d97caa2eb41b67cdef2bfa71f2f3ef1cfa378fae32db18fc8e25  guix-build-e1f543823b30/output/riscv64-linux-gnu/bitcoin-e1f543823b30-riscv64-linux-gnu-debug.tar.gz
  c8ca7793fdfac2346a21d5fc8f6e00f1feb6556d048896fef8148ac614921050  guix-build-e1f543823b30/output/riscv64-linux-gnu/bitcoin-e1f543823b30-riscv64-linux-gnu.tar.gz
  a3e99dd3369aa97cad2437fc1b29f84a8950327fd0f0a1c0a8a3e7ce49369f1a  guix-build-e1f543823b30/output/x86_64-apple-darwin/SHA256SUMS.part
  1c22d2967c72a5b901d54b9914d243aaf8f52216e48399f09bf17f34455369ec  guix-build-e1f543823b30/output/x86_64-apple-darwin/bitcoin-e1f543823b30-x86_64-apple-darwin-codesigning.tar.gz
  28c731d91d84f41a0b94cfb420474f150edd2bd33db1e9c38d52c9452e44b3f1  guix-build-e1f543823b30/output/x86_64-apple-darwin/bitcoin-e1f543823b30-x86_64-apple-darwin-unsigned.tar.gz
  f6b74d1756af4de4a7e250c11f0a48a93fafc67139951afc4a55888ce24dc01a  guix-build-e1f543823b30/output/x86_64-apple-darwin/bitcoin-e1f543823b30-x86_64-apple-darwin-unsigned.zip
  16d7a33003e89f53b3d8ce31a121250a4f836c83482f39b0c40721a2dd32faca  guix-build-e1f543823b30/output/x86_64-linux-gnu/SHA256SUMS.part
  d17606b3fec3c045d84dadff4b107186cc6e51daa80a16588de4e213585a98cd  guix-build-e1f543823b30/output/x86_64-linux-gnu/bitcoin-e1f543823b30-x86_64-linux-gnu-debug.tar.gz
  52ee77c9ff6bbe6965100165847d107c4e3ddcf8c2a960746f663ade074295a5  guix-build-e1f543823b30/output/x86_64-linux-gnu/bitcoin-e1f543823b30-x86_64-linux-gnu.tar.gz
  daeba27cb9ce21e3a6a01b9487ef81738eec0c84ad80ca0ba1287412c0d4eeda  guix-build-e1f543823b30/output/x86_64-w64-mingw32/SHA256SUMS.part
  38ccc35fe32895688f4fc0f22ed8a03233d06636a487b49de74a215fc6b67002  guix-build-e1f543823b30/output/x86_64-w64-mingw32/bitcoin-e1f543823b30-win64-codesigning.tar.gz
  22863abb1a4d1fed1e4753e602f33a743296caf297bdc7ed9330010f5d3f79f3  guix-build-e1f543823b30/output/x86_64-w64-mingw32/bitcoin-e1f543823b30-win64-debug.zip
  1cbc8ae43899d96664e75fa2c3fce2efbb2cfac34b279fe1e240a616646cb3e9  guix-build-e1f543823b30/output/x86_64-w64-mingw32/bitcoin-e1f543823b30-win64-setup-unsigned.exe
  b6d22f62c083aca24dc788df1676bfc2ce0abc85a796a4823e5802d71482082c  guix-build-e1f543823b30/output/x86_64-w64-mingw32/bitcoin-e1f543823b30-win64-unsigned.zip
  ```

ACKs for top commit:
  shahsb:
    ACK e1f543823b
  purpleKarrot:
    ACK e1f543823b
  TheCharlatan:
    ACK e1f543823b
  hebasto:
    ACK e1f543823b, I have reviewed the code and it looks OK.

Tree-SHA512: d4bcbc37d431113f0e6367e8f61e71ab9d9ef8a08c38a2db961d9f9cc8473636124f5f2bd4d66cbb3e5032f9d5f978d7d286033d80f7e148f9d571ff09f005ff
2025-05-05 15:19:20 +01:00
Hennadii Stepanov 3a18075aed
ci: Drop `-DENABLE_EXTERNAL_SIGNER=ON` configure option
This option is now enabled by default.
2025-05-05 12:37:40 +01:00
Hennadii Stepanov 719fa9f4ef
build: Re-enable external signer support for Windows 2025-05-05 12:37:29 +01:00
Hennadii Stepanov 6e5fc2bf9b
test: Reintroduce Windows support in `system_tests/run_command` test 2025-05-05 12:37:23 +01:00
Hennadii Stepanov 53ccb75f0c
Merge bitcoin/bitcoin#32358: subprocess: Backport upstream changes
cd95c9d6a7 subprocess: check and handle fcntl(F_GETFD) failure (Tomás Andróil)
b7288decdf subprocess: Proper implementation of wait() on Windows (Haowen Liu)
7423214d8d subprocess: Do not escape double quotes for command line arguments on Windows (Hennadii Stepanov)
bb9ffea53f subprocess: Explicitly define move constructor of Streams class (Shunsuke Shimizu)
174bd43f2e subprocess: Avoid leaking POSIX name aliases beyond `subprocess.h` (Hennadii Stepanov)
7997b7656f subprocess: Fix cross-compiling with mingw toolchain (Hennadii Stepanov)
647630462f subprocess: Get Windows return code in wait() (Haowen Liu)
d3f511b458 subprocess: Fix string_arg when used with rref (Haowen Liu)
2fd3f2fec6 subprocess: Fix memory leaks (Haoran Peng)

Pull request description:

  Most of these changes were developed during work on https://github.com/bitcoin/bitcoin/pull/29868 and https://github.com/bitcoin/bitcoin/pull/32342 and have since been upstreamed.

  As they are now merged, this PR backports them to our `src/util/subprocess.h` header.

  Required for https://github.com/bitcoin/bitcoin/pull/29868.

  A list of the backported PRs:
   - https://github.com/arun11299/cpp-subprocess/pull/106
  - https://github.com/arun11299/cpp-subprocess/pull/110
  - https://github.com/arun11299/cpp-subprocess/pull/109
  - https://github.com/arun11299/cpp-subprocess/pull/99
  - https://github.com/arun11299/cpp-subprocess/pull/112
  - https://github.com/arun11299/cpp-subprocess/pull/107
  - https://github.com/arun11299/cpp-subprocess/pull/113
  - https://github.com/arun11299/cpp-subprocess/pull/116
  - https://github.com/arun11299/cpp-subprocess/pull/117

  The following PRs were skipped for backporting:
  - https://github.com/arun11299/cpp-subprocess/pull/108 because we are not planning to support this feature.
  - https://github.com/arun11299/cpp-subprocess/pull/101 because that change has been already landed in https://github.com/bitcoin/bitcoin/pull/29849.

ACKs for top commit:
  theStack:
    Light ACK cd95c9d6a7
  laanwj:
    Code review re-ACK cd95c9d6a7

Tree-SHA512: f9b60b932957d2e1cad1d87f2ad8bb68c97136e9735eb78547018a42cc50c4652750367f29462eadb0512c27db1dd8a7d4b17a2f0aeab62b3dbf86db5f51a61c
2025-05-05 12:35:42 +01:00
Hennadii Stepanov fa2c548429
Merge bitcoin/bitcoin#32417: doc: Explain that .gitignore is not for IDE-specific excludes
fada115cbe doc: Explain that .gitignore is not for IDE-specific excludes (MarcoFalke)

Pull request description:

  This comes up frequently, so document it.

  Examples:

  * https://github.com/bitcoin/bitcoin/pull/27275
  * https://github.com/bitcoin/bitcoin/pull/21894
  * https://github.com/bitcoin/bitcoin/pull/32392
  * https://github.com/bitcoin/bitcoin/pull/17868

  ...

ACKs for top commit:
  l0rinc:
    ACK fada115cbe
  hebasto:
    ACK fada115cbe.
  janb84:
    ACK [fada115](fada115cbe)

Tree-SHA512: 6fd1e48de54b40118a49ef61ad157fea278bba568286a022559a4815e53f26650db98a779a1ea2b3085237ded5cbee20d4c2dd1ef51e6a2d3d6085d7063f5309
2025-05-05 07:40:08 +01:00
MarcoFalke fada115cbe
doc: Explain that .gitignore is not for IDE-specific excludes 2025-05-04 19:45:11 +02:00
Sebastian Falbesoner b5f580c580 scripted-diff: adapt script error constant names in feature_taproot.py
In order to remove potential confusion, this commit adapts all script
error constant names in the functional tests (currently only in
feature_taproot.py) to the ones used in our C++ codebase. This also
makes checking whether we have test coverage for a certain script error
easier.

-BEGIN VERIFY SCRIPT-

ren() { sed -i "s|$1|$2|g" $( git grep -l "$1" -- "./test" ) ; }

ren ERR_SIG_SIZE          ERR_SCHNORR_SIG_SIZE
ren ERR_SIG_HASHTYPE      ERR_SCHNORR_SIG_HASHTYPE
ren ERR_SIG_SCHNORR       ERR_SCHNORR_SIG
ren ERR_CONTROLBLOCK_SIZE ERR_TAPROOT_WRONG_CONTROL_SIZE
ren ERR_PUSH_LIMIT        ERR_PUSH_SIZE
ren ERR_MINIMALIF         ERR_TAPSCRIPT_MINIMALIF
ren ERR_UNKNOWN_PUBKEY    ERR_PUBKEYTYPE
ren ERR_STACK_EMPTY       ERR_INVALID_STACK_OPERATION
ren ERR_SIGOPS_RATIO      ERR_TAPSCRIPT_VALIDATION_WEIGHT
ren ERR_UNDECODABLE       ERR_BAD_OPCODE
ren ERR_NO_SUCCESS        ERR_EVAL_FALSE
ren ERR_EMPTY_WITNESS     ERR_WITNESS_PROGRAM_WITNESS_EMPTY

-END VERIFY SCRIPT-
2025-05-03 20:32:13 +02:00
Ava Chow eba5f9c4b6
Merge bitcoin/bitcoin#32403: test: remove Boost SIGCHLD workaround.
3add6ab9ad test: remove Boost SIGCHLD workaround. (fanquake)

Pull request description:

  The related code was removed from Boost in 2e3bd1025d.

ACKs for top commit:
  achow101:
    ACK 3add6ab9ad
  laanwj:
    ACK 3add6ab9ad
  hebasto:
    ACK 3add6ab9ad, I have reviewed the code and it looks OK.
  mabu44:
    ACK 3add6ab9ad

Tree-SHA512: a0db2bb4e6a476c920a97183bd807e800d935114ff28f8802373a08b5330df42a9be953e7ea6e3c09f2ed45175f60c26c33bb4e25010269e6e491f12867ba008
2025-05-02 14:10:23 -07:00
fanquake e1f543823b
build: replace header checks with __has_include
See https://en.cppreference.com/w/cpp/preprocessor/include.
2025-05-02 16:41:04 +01:00
fanquake 3add6ab9ad
test: remove Boost SIGCHLD workaround.
The related code was removed from Boost in
2e3bd1025d.
2025-05-02 10:59:46 +01:00
Tomás Andróil cd95c9d6a7
subprocess: check and handle fcntl(F_GETFD) failure
Add missing error check for fcntl(fd, F_GETFD, 0) in set_clo_on_exec.
Raise OSError on failure to align with existing FD_SETFD behavior.
This improves robustness in subprocess setup and error visibility.

Github-Pull: arun11299/cpp-subprocess#117
Rebased-From: 9974ff69cdd5fc1a2722cb63f006df9308628b35
2025-05-01 22:16:11 +01:00
Haowen Liu b7288decdf
subprocess: Proper implementation of wait() on Windows
This commit makes sure:
1. WaitForSingleObject returns with expected
code before proceeding.
2. Process handle is properly closed.

Github-Pull: arun11299/cpp-subprocess#116
Rebased-From: 625a8775791e62736f20f3fa3e6cc4f1b24aa89a
2025-05-01 22:15:57 +01:00
Hennadii Stepanov 7423214d8d
subprocess: Do not escape double quotes for command line arguments on Windows
* refactor: Guard `util::quote_argument()` with `#ifdef __USING_WINDOWS__`

The `util::quote_argument()` function is specific to Windows and is used
in code already guarded by `#ifdef __USING_WINDOWS__`.

* Do not escape double quotes for command line arguments on Windows

This change fixes the handling of double quotes and aligns the behavior
with Python's `Popen` class. For example:
```
>py -3
>>> import subprocess
>>> p = subprocess.Popen("cmd.exe /c dir \"C:\\Program Files\"", stdout=subprocess.PIPE, text=True)
>>> print(f"Captured stdout:\n{stdout}")
```

Currently, the same command line processed by the `quote_argument()`
function looks like `cmd.exe /c dir "\"C:\Program" "Files\""`, which is
broken.

With this change, it looks correct: `cmd.exe /c dir "C:\Program Files"`.

Github-Pull: arun11299/cpp-subprocess#113
Rebased-From: ed313971c04ac10dc006104aba07d016ffc6542a
2025-05-01 22:15:19 +01:00
Shunsuke Shimizu bb9ffea53f
subprocess: Explicitly define move constructor of Streams class
This suppresses the following warning caused by clang-20.

```
error: definition of implicit copy constructor for 'Streams' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
```

Copy constructor or move constructor is called when std::vector re-allocates
memory. In this case, move constructor should be called, because copying
Streams instances breaks file-descriptor management.

Communication class is modified as well, since it's instance is a member of
Streams class.

Github-Pull: arun11299/cpp-subprocess#107
Rebased-From: 38d98d9d20be50c7187b98ac9bc9a6e66920f6ef
2025-05-01 22:14:29 +01:00
Hennadii Stepanov 174bd43f2e
subprocess: Avoid leaking POSIX name aliases beyond `subprocess.h`
The commit a32c0f3df4b6bcd1d2e93f19e8f380bb890cd507 introduced code to
silence MSVC's "warning C4996: The POSIX name for this item is
deprecated."

However, it exhibits several issues:
1. The aliases may leak into code outside the `subprocess.hpp` header.
2. They are unnecessarily applied when using the MinGW-w64 toolchain.
3. The fix is incomplete: downstream projects still see C4996 warnings.
4. The implementation lacks documentation.

This change addresses all of the above shortcomings.

Github-Pull: arun11299/cpp-subprocess#112
Rebased-From: 778543b2f2ca7f5d1c4f0241b635bbb265d750dd

Co-authored-by: Luke Dashjr <luke-jr+git@utopios.org>
2025-05-01 22:10:35 +01:00
Hennadii Stepanov 7997b7656f
subprocess: Fix cross-compiling with mingw toolchain
Github-Pull: arun11299/cpp-subprocess#99
Rebased-From: 34033d03deacfdba892a708b7d8092b4d9e5e889
2025-05-01 22:07:39 +01:00
Haowen Liu 647630462f
subprocess: Get Windows return code in wait()
Currently, wait() returns 0 on windows regardless
of the actual return code of processes.

Github-Pull: arun11299/cpp-subprocess#109
Rebased-From: 04b015a8e52ead4d8bb5f0eb486419c77e418a17
2025-05-01 22:07:21 +01:00
Haowen Liu d3f511b458
subprocess: Fix string_arg when used with rref
When passing in a rvalue reference, compiler
considers it ambiguous between std::string and
std::string&&. Making one of them take a lvalue
reference makes compilers correctly pick the right
one depending on whether the passed in value binds
to a rvalue or lvalue reference.

Github-Pull: arun11299/cpp-subprocess#110
Rebased-From: 2d8a8eebb03e509840e2c3c755d1abf32d930f33
2025-05-01 22:06:28 +01:00
Haoran Peng 2fd3f2fec6
subprocess: Fix memory leaks
I encountered this issue while running my code with Valgrind today.
Below is part of the Valgrind error message:

```
==1578139== 472 bytes in 1 blocks are still reachable in loss record 1 of 1
==1578139==    at 0x4848899: malloc (...)
==1578139==    by 0x4B3AF62: fdopen@@GLIBC_2.2.5 (...)
==1578139==    by 0x118B09: subprocess::Popen::execute_process() (...)
```

I noticed that a similar fix had been proposed by another contributor
previously. I did not mean to scoop their work, but merely hoping to fix
it sooner so other people don't get confused by it just as I did today.

Github-Pull: arun11299/cpp-subprocess#106
Rebased-From: 3afe581c1f22f106d59cf54b9b65251e6c554671
2025-05-01 22:04:59 +01:00
Ava Chow 5b8046a6e8
Merge bitcoin/bitcoin#30611: validation: write chainstate to disk every hour
e976bd3045 validation: add randomness to periodic write interval (Andrew Toth)
2e2f410681 refactor: replace m_last_write with m_next_write (Andrew Toth)
b557fa7a17 refactor: rename fDoFullFlush to should_write (Andrew Toth)
d73bd9fbe4 validation: write chainstate to disk every hour (Andrew Toth)
0ad7d7abdb test: chainstate write test for periodic chainstate flush (Andrew Toth)

Pull request description:

  Since #28233, periodically writing the chainstate to disk every 24 hours does not clear the dbcache. Since #28280, periodically writing the chainstate to disk is proportional only to the amount of dirty entries in the cache. Due to these changes, it is no longer beneficial to only write the chainstate to disk every 24 hours. The periodic flush interval was necessary because every write of the chainstate would clear the dbcache. Now, we can get rid of the periodic flush interval and simply write the chainstate along with blocks and block index at least every hour.

  Three benefits of doing this:
  1. For IBD or reindex-chainstate with a combination of large dbcache setting, slow CPU, slow internet speed/unreliable peers, it could be up to 24 hours until the chainstate is persisted to disk. A power outage or crash could potentially lose up to 24 hours of progress. If there is a very large amount of dirty cache entries, writing to disk when a flush finally does occur will take a very long time. Crashing during this window of writing can cause https://github.com/bitcoin/bitcoin/issues/11600. By syncing every hour in unison with the block index we avoid this problem. Only a maximum of one hour of progress can be lost, and the window for crashing during writing is much smaller. For IBD with lower dbcache settings, faster CPU, or better internet speed/reliable peers, chainstate writes are already triggered more often than every hour so this change will have no effect on IBD.
  2. Based on discussion in #28280, writing only once every 24 hours during long running operation of a node causes IO spikes. Writing smaller chainstate changes every hour like we do with blocks and block index will reduce IO spikes.
  3. Faster shutdown speeds. All dirty chainstate entries must be persisted to disk on shutdown. If we have a lot of dirty entries, such as when close to 24 hours or if we sync with a large dbcache, it can take a long time to shutdown. By keeping the chainstate clean we avoid this problem.

  Inspired by [this comment](https://github.com/bitcoin/bitcoin/pull/28280#issuecomment-2121088705).

  Resolves https://github.com/bitcoin/bitcoin/issues/11600

ACKs for top commit:
  achow101:
    ACK e976bd3045
  davidgumberg:
    utACK e976bd3045
  sipa:
    utACK e976bd3045
  l0rinc:
    ACK  e976bd3045

Tree-SHA512: 5bccd8f1dea47f9820a3fd32fe3bb6841c0167b3d6870cc8f3f7e2368f124af1a914bca6acb06889cd7183638a8dbdbace54d3237c3683f2b567eb7355e015ee
2025-05-01 12:11:55 -07:00
merge-script fc6346dbc8
Merge bitcoin/bitcoin#32389: doc: Fix test_bitcoin path
6cbc28b8dd doc: Fix test_bitcoin path (monlovesmango)

Pull request description:

  This commit fixes a couple command paths for interacting with the test_bitcoin binary within the Unit Test documentation.

  If the commands are run as is a `command not found` error is returned.

  ```bash
  ❯ test_bitcoin --list_content
  bash: test_bitcoin: command not found
  ```

  ```bash
  ❯ test_bitcoin --help
  bash: test_bitcoin: command not found
  ```

ACKs for top commit:
  davidgumberg:
    ACK 6cbc28b8dd

Tree-SHA512: 0b10bc3aead360fa499beef7c9715f95a9acacdda44cbfac15566428594a7a8bdece24114a42618355959e20754bedc7a903bdddbf21b819c7b75375bdc80a93
2025-05-01 10:21:31 +01:00
Luke Dashjr a0eed55398 run_command: Enable close_fds option to avoid lingering fds 2025-05-01 11:18:04 +02:00
Luke Dashjr c7c356a448 cpp-subprocess: Iterate through /proc/self/fd for close_fds option on Linux
As an optimization, iterate through /proc/<pid>/fd on Linux.

Co-authored-by: laanwj <126646+laanwj@users.noreply.github.com>
2025-05-01 11:18:03 +02:00
Luke Dashjr 4f5e04da13 Revert "remove unneeded close_fds option from cpp-subprocess"
This reverts commit 79c3036373.
2025-05-01 11:18:03 +02:00
monlovesmango 6cbc28b8dd doc: Fix test_bitcoin path
This commit fixes a couple command paths for interacting with the
test_bitcoin binary within the Unit Test documentation.
2025-05-01 03:05:57 +00:00
Murch 85368aafa0
test: Run simple tests at various feerates 2025-04-30 15:38:04 -07:00
Murch d610951c15
test: Recreate BnB iteration exhaustion test 2025-04-30 15:38:02 -07:00
Murch 2a1b2754f1
test: Remove redundant repeated test
We do not need to repeat the same test multiple times because BnB is
deterministic and will therefore always have the same outcome.
Additionally, this test was redundant because it repeats the "Smallest
combination too big" test.
2025-04-30 15:38:01 -07:00
Murch 4781f5c8be
test: Recreate simple BnB failure tests 2025-04-30 15:37:59 -07:00
Murch a94030ae98
test: Recreate BnB clone skipping test 2025-04-30 15:37:58 -07:00
Murch 7db6f012c0
test: Move BnB feerate sensitivity tests
Originally these tests verified that at a SelectCoins level that a
solution with fewer inputs gets preferred at high feerates, and a
solution with more inputs gets preferred at low feerates. This outcome
relies on the behavior of BnB, so we move these tests under the umbrella
of BnB tests.

Originally these tests relied on SFFO to work.
2025-04-30 15:37:55 -07:00
Murch 2bafc46261
test: Recreate simple BnB success tests
Recreates the tests in a new test suite coinselection_tests.cpp that is
based on UTXOs being created per their effective values rather than
nominal values and uses transactions with non-zero feerates.
2025-04-30 15:37:44 -07:00
Andrew Toth e976bd3045
validation: add randomness to periodic write interval
Co-Authored-By: Pieter Wuille <pieter@wuille.net>
Co-Authored-By: l0rinc <pap.lorinc@gmail.com>
2025-04-30 18:35:03 -04:00
Andrew Toth 2e2f410681
refactor: replace m_last_write with m_next_write
Co-Authored-By: l0rinc <pap.lorinc@gmail.com>
2025-04-30 18:33:43 -04:00
Andrew Toth b557fa7a17 refactor: rename fDoFullFlush to should_write 2025-04-30 18:32:51 -04:00
Andrew Toth d73bd9fbe4
validation: write chainstate to disk every hour
Remove the 24 hour periodic flush interval and
write the chainstate along with blocks and block
index every hour
2025-04-30 18:32:41 -04:00
Ava Chow 68ac9f116c
Merge bitcoin/bitcoin#32383: util: Remove `fsbridge::get_filesystem_error_message()`
97eaadc3bf util: Remove `fsbridge::get_filesystem_error_message()` (Hennadii Stepanov)

Pull request description:

  The `fsbridge::get_filesystem_error_message()` function exhibits several drawbacks:

  1. It was introduced in https://github.com/bitcoin/bitcoin/pull/14192 to account for platform-specific variations in
  `boost::filesystem::filesystem_error::what()`. Since [migrating](https://github.com/bitcoin/bitcoin/pull/20744) to `std::filesystem`, those discrepancies no longer exist.

  2. It fails to display UTF-8 paths correctly on Windows:
  ```
  > build\bin\Release\bitcoind.exe -datadir="C:\Users\hebasto\dd_₿_🏃" -regtest
  ...
  2025-04-30T00:17:48Z DeleteAuthCookie: Unable to remove random auth cookie file: remove: Access is denied.: "C:\Users\hebasto\dd_?_??\regtest\.cookie"
  ...
  ```

  3. It relies on `std::wstring_convert`, which was deprecated in C++17 and removed in C++26 (also see https://github.com/bitcoin/bitcoin/issues/32361).

  This PR removes the obsolete `fsbridge::get_filesystem_error_message()` function, thereby resolving all of the above issues.

ACKs for top commit:
  maflcko:
    lgtm re-ACK 97eaadc3bf
  davidgumberg:
    untested crACK 97eaadc3bf
  achow101:
    ACK 97eaadc3bf
  laanwj:
    Code review ACK 97eaadc3bf

Tree-SHA512: 3c7378a9b143ac2a71add967318a13c346ae3bccbec6e9879d7873083f3fa469b3eef529b2c9c142b2489ba9563e4e12f685745c09a8a219d58b384f7ecf1be1
2025-04-30 10:56:14 -07:00
MarcoFalke fa4804009c
fuzz: Remove unused TimeoutExpired catch in fuzz runner
Can be reviewed with --ignore-all-space
2025-04-30 19:55:03 +02:00
Sjors Provoost 0750249289
mining: document gbt_rule_value helper 2025-04-30 14:51:44 +02:00
Sjors Provoost 5e87c3ec09
scripted-diff: rename gbt_force and gbt_force_name
The term "force" is ambiguous and not used in BIP9 where the ! rule
prefix is introduced.

Additionally, #29039 renamed gbt_vb_name to gbt_force_name which
might increase the confusion.

-BEGIN VERIFY SCRIPT-
sed -i s/gbt_force_name/gbt_rule_value/g ./src/rpc/mining.cpp
sed -i s/gbt_force/gbt_optional_rule/g $(git grep -l gbt_force)
-END VERIFY SCRIPT-
2025-04-30 14:51:21 +02:00
Hennadii Stepanov 97eaadc3bf
util: Remove `fsbridge::get_filesystem_error_message()`
The `fsbridge::get_filesystem_error_message()` function exhibits several
drawbacks:

1. It was introduced in https://github.com/bitcoin/bitcoin/pull/14192 to
account for platform-specific variations in
`boost::filesystem::filesystem_error::what()`. Since migrating to
`std::filesystem`, those discrepancies no longer exist.

2. It fails to display UTF-8 paths correctly on Windows.

3. It relies on `std::wstring_convert`, which was deprecated in C++17
and removed in C++26.

This change removes the `fsbridge::get_filesystem_error_message()`
function, thereby resolving all of the above issues.

Additionally, filesystem error messages now use the "Warning" log level.
2025-04-30 10:41:34 +01:00
Ava Chow 14b8dfb2bd
Merge bitcoin/bitcoin#31398: wallet: refactor: various master key encryption cleanups
a8333fc9ff scripted-diff: wallet: rename plain and encrypted master key variables (Sebastian Falbesoner)
5a92077fd5 wallet: refactor: dedup master key decryption (Sebastian Falbesoner)
846545947c wallet: refactor: dedup master key encryption / derivation rounds setting (Sebastian Falbesoner)
a6d9b415aa wallet: refactor: introduce `CMasterKey::DEFAULT_DERIVE_ITERATIONS` constant (Sebastian Falbesoner)
62c209f50d wallet: doc: remove mentions of unavailable scrypt derivation method (Sebastian Falbesoner)

Pull request description:

  This PR contains various cleanups around the wallet's master key encryption logic. The default/minimum key derivation rounds magic number of 25000 is hoisted into a constant (member of `CMasterKey`) and two new functions `EncryptMasterKey`/`DecryptMasterKey` are introduced in order to deduplicate code for the derivation round determination and master key en/decryption. Also, mentions of the never-implemented derivation method `scrypt` are removed from the wallet crypter header and both plain and encrypted master key instances are renamed to adapt to moderning coding style (hopefully improving readability).

ACKs for top commit:
  davidgumberg:
    ACK a8333fc9ff
  achow101:
    ACK a8333fc9ff

Tree-SHA512: 5a66d3b26f481347d0b5b4f742dd237803a35aad6e3480ed15fd38b7fa3700650bd5f67f4c30ed88f5fad45d6cd4c893fe4f1657e36e563b4294fd3596187724
2025-04-29 16:32:21 -07:00
Ava Chow a60445cd04
Merge bitcoin/bitcoin#32355: Bugfix: Miner: Don't reuse block_reserved_weight for "block is full enough to give up" weight delta
524f981bb8 Bugfix: Miner: Don't reuse block_reserved_weight for "block is full enough to give up" weight delta (Luke Dashjr)

Pull request description:

  PR #30356 incorrectly changed a constant of `4000` to `m_options.coinbase_max_additional_weight` in the check for when to give up finding another transaction to fill the block:

  ```diff
               if (nConsecutiveFailed > MAX_CONSECUTIVE_FAILURES && nBlockWeight >
  -                    m_options.nBlockMaxWeight - 4000) {
  +                    m_options.nBlockMaxWeight - m_options.block_reserved_weight) {
                   // Give up if we're close to full and haven't succeeded in a while
                   break;
               }
  ```

  But this constant did not deal with the reserved weight at all. It was in fact simply checking if the block was close to full, and if so, giving up finding another transaction to pad it with after `MAX_CONSECUTIVE_FAILURES` failed attempts.

  It doesn't seem very logical to reuse the reserve weight for this purpose, and it would be overcomplicated to add yet another setting, so this PR changes it to a new constexpr.

ACKs for top commit:
  achow101:
    ACK 524f981bb8
  darosior:
    utACK 524f981bb8
  ismaelsadeeq:
    ACK 524f981bb8

Tree-SHA512: c066debc34a021380424bd21b40444071b736325e41779a41590c2c8a6822ceeaf910fe067817c1dba108210b24c574977b0350b29520502e7af79d3b405928b
2025-04-29 15:51:18 -07:00
Ava Chow 2d5b424414
Merge bitcoin/bitcoin#32351: test: avoid stack overflow in `FindChallenges` via manual iteration
7e8ef959d0 refactor: Fix Sonar rule `cpp:S4998` - avoid unique_ptr const& as parameter (Lőrinc)
e400ac5352 refactor: simplify repeated comparisons in `FindChallenges` (Lőrinc)
f670836112 test: remove old recursive `FindChallenges_recursive` implementation (Lőrinc)
b80d0bdee4 test: avoid stack overflow in `FindChallenges` via manual iteration (Lőrinc)

Pull request description:

  `FindChallenges` explores the `Miniscript` node tree by going deep into the first child's subtree, then the second, and so on - effectively performing a pre-order Traversal (Depth-First Search) recursively, using the call stack which can result in stack overflows on Windows debug builds.

  This change replaces the recursive implementation with an iterative version using an explicit stack. The new implementation also performs a pre-order depth-first traversal, though it processes children in right-to-left order (rather than left-to-right) due to the LIFO nature of the stack. Since both versions store results in a `std::set`, which automatically sorts and deduplicates elements, the exact traversal order doesn't affect the final result.

  It is an alternative to increasing the Windows stack size, as proposed in #32349, and addresses the issue raised in #32341 by avoiding deep recursion altogether.

  The change is done in two commits:
  * add a new iterative `FindChallenges` method and rename the old method to `*_recursive` (to simplify the next commit where we remove it), asserting that its result matches the original;
  * remove the original recursive implementation.

  This approach avoids ignoring the `misc-no-recursion` warning as well.

  I tried modifying the new method to store results in a vector instead, but it demonstrated that the deduplication provided by `std::set` was necessary. One example showing the need for deduplication:

  Recursive (using set):
  ```
    (6, 9070746)
    (6, 19532513)
    (6, 3343376967)
  ```
  Iterative (using vector attempt):
  ```
    (6, 19532513)
    (6, 9070746)
    (6, 3343376967)
    (6, 9070746)  // Duplicate entry
  ```

  The performance of the test is the same as before, with the recursive method.

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

ACKs for top commit:
  achow101:
    ACK 7e8ef959d0
  sipa:
    utACK 7e8ef959d0
  hodlinator:
    re-ACK 7e8ef959d0

Tree-SHA512: 9e52eff82a7d76f5d37e3b74c508f08e5fced5386dad504bed111b27ed2b529008a6dd12a5116f009609a94c7ee7ebe3e80a759dda55dd1cb3ae52078f65ec71
2025-04-29 15:29:50 -07:00
Ava Chow 0ed5f37afe
Merge bitcoin/bitcoin#31014: net: Use GetAdaptersAddresses to get local addresses on Windows
b9d4d5f66a net: Use GetAdaptersAddresses to get local addresses on Windows (laanwj)

Pull request description:

  Instead of a `gethostname` hack, which is not guaranteed to return all addresses, use the official way of calling `GetAdaptersAddresses` to get local network addresses on Windows.

  Do the same checks as the UNIX path: interface is up, interface is not loopback.

  Suggested by Ava Chow.

  Addiional changes:

  - Cleanup: move out `FromSockAddr` in `netif.cpp` from MacOS and use it everywhere appropriate. This avoids code duplication.

ACKs for top commit:
  davidgumberg:
    utreACK b9d4d5f66a
  achow101:
    ACK b9d4d5f66a

Tree-SHA512: e9f0a7ec0c46f21c0377d5174e054a6569f858630727f94dac00c0cb7c241c56892d0b902706d6dd53880cc3b5ae1f2dba9caa1fec40e64cd4cf0d34493a49c1
2025-04-29 15:13:39 -07:00
Ava Chow 7a4a2a38ea
Merge bitcoin/bitcoin#27826: validation: log which peer sent us a header
abe43dfadd doc: release note for #27826 (Sjors Provoost)
f9fa28788e Use LogBlockHeader for compact blocks (Sjors Provoost)
bad7c91479 Log which peer sent us a header (Sjors Provoost)
9d3e39c29c Log block header in net_processing (Sjors Provoost)

Pull request description:

  Fixes #27744

  Since #27278 we log received headers. For compact blocks we also log which peer sent it (e5ce857634), but not for regular headers. That required an additional refactor, which this PR provides.

  Move the logging from validation to net_processing.

  This also reduces the number of log entries (under default configuration) per compact block header from 3 to 2: one for the header and one for the connected tip.

  The PR introduces a new helper method `LogBlockHeader`.

  When receiving a _compact block_ we call `LogBlockHeader` from the exact same place as where we previously logged. So that log message doesn't change. What does change is that we no longer _also_ log from `AcceptBlockHeader`.

  When receiving a regular header(s) message, _we only log the last one_. This is a change in behaviour because it was simpler to implement, but it's probably better anyway. It does mean that if a peer sends of a bunch of headers of which _any_ is invalid, we won't log it (here).

  Lastly I expanded the code comment explaining why we log this. It initially only covered selfish mining, but we also care about peers sending us headers but not following up (see e.g. #27626).

  Example log:

  ```
  2023-06-05T13:12:21Z Saw new header hash=000000000000000000045910263ef84b575ae3af151865238f1e5c619e69c330 height=792964 peer=0
  2023-06-05T13:12:23Z UpdateTip: new best=000000000000000000045910263ef84b575ae3af151865238f1e5c619e69c330 height=792964 version=0x20000000 log2_work=94.223098 tx=848176824 date='2023-06-05T13:11:49Z' progress=1.000000 cache=6.4MiB(54615txo)
  2023-06-05T13:14:05Z Saw new cmpctblock header hash=00000000000000000003c6fd4ef2e1246a3f9e1fffab7247344f94cadb9de979 height=792965 peer=0
  2023-06-05T13:14:05Z UpdateTip: new best=00000000000000000003c6fd4ef2e1246a3f9e1fffab7247344f94cadb9de979 height=792965 version=0x20000000 log2_work=94.223112 tx=848179461 date='2023-06-05T13:13:58Z' progress=1.000000 cache=7.2MiB(61275txo)
  2023-06-05T13:14:41Z Saw new header hash=000000000000000000048e6d69c8399992782d08cb57f5d6cbc81a9f996c3f43 height=792966 peer=8
  2023-06-05T13:14:42Z UpdateTip: new best=000000000000000000048e6d69c8399992782d08cb57f5d6cbc81a9f996c3f43 height=792966 version=0x2db3c000 log2_work=94.223126 tx=848182944 date='2023-06-05T13:14:35Z' progress=1.000000 cache=8.0MiB(69837txo)
  ```

ACKs for top commit:
  danielabrozzoni:
    tACK abe43dfadd
  achow101:
    ACK abe43dfadd
  vasild:
    ACK abe43dfadd

Tree-SHA512: 081e0de62cbd8a0b35cf54daaa09e3e6991d0cc9f706ef3eb50908752fe7815de69b367f7313381c90cd8d5de0ae5f532d1cd54948c5c1133b1832f266d9c232
2025-04-29 14:48:16 -07:00
Ava Chow 4694732bc4
Merge bitcoin/bitcoin#32338: net: remove unnecessary check from AlreadyConnectedToAddress()
f1b142856a test: Same addr, diff port is already connected (David Gumberg)
94e85a82a7 net: remove unnecessary check from AlreadyConnectedToAddress() (Vasil Dimov)

Pull request description:

  `CConnman::AlreadyConnectedToAddress()` searches the existent nodes by address or by address-and-port:

  ```cpp
  FindNode(static_cast<CNetAddr>(addr)) || FindNode(addr.ToStringAddrPort())
  ```

  but:

  * if there is a match by just the address, then the address-and-port search will not be evaluated and the whole condition will be `true`
  * if the there is no node with the same address, then the second search by address-and-port will not find a match either.

  The search by address-and-port is comparing against `CNode::m_addr_name` which could be a hostname, e.g. `"node.foobar.com:8333"`, but `addr.ToStringAddrPort()` is always going to be numeric.

  ---

  In other words: let `A` be "CNetAddr equals" and `B` be "addr:port string matches", then:

  * If `A` (is `true`), then `B` is irrelevant, so the condition `A || B` is equivalent to `A` is `true`.
  * Observation in this PR: if `!A` (`A` is `false`), then `!B` for sure, thus the condition `A || B` is equivalent to `A` is `false`.

  So, simplify `A || B` to `A`.

  https://en.wikipedia.org/wiki/Modus_tollens `!A => !B` is equivalent to `B => A`. So the added fuzz test asserts that if `B` is `true`, then `A` is `true`.

ACKs for top commit:
  davidgumberg:
    crACK f1b142856a
  achow101:
    ACK f1b142856a
  theuni:
    utACK f1b142856a
  mzumsande:
    Code Review ACK f1b142856a

Tree-SHA512: d744b60e9bace121faa3a746463f6b6e0e6ef08eac0e7879326cbd5f4721e47e6e10f6203dfd3870a2057c4ddd1860692c070ef048a76d773b84e6c2f840cc86
2025-04-29 14:31:59 -07:00
Ava Chow 7db096121d
Merge bitcoin/bitcoin#29039: versionbits refactoring
e3014017ba test: add IsActiveAfter tests for versionbits (Anthony Towns)
60950f77c3 versionbits: docstrings for BIP9Info (Anthony Towns)
7565563bc7 tests: refactor versionbits fuzz test (Anthony Towns)
2e4e9b9608 tests: refactor versionbits unit test (Anthony Towns)
525c00f91b versionbits: Expose VersionBitsConditionChecker via impl header (Anthony Towns)
e74a7049b4 versionbits: Expose StateName function (Anthony Towns)
d00d1ed52c versionbits: Split out internal details into impl header (Anthony Towns)
37b9b67a39 versionbits: Simplify VersionBitsCache API (Anthony Towns)
1198e7d2fd versionbits: Move BIP9 status logic for getblocktemplate to versionbits (Anthony Towns)
b1e967c3ec versionbits: Move getdeploymentinfo logic to versionbits (Anthony Towns)
3bd32c2055 versionbits: Move WarningBits logic from validation to versionbits (Anthony Towns)
5da119e5d0 versionbits: Change BIP9Stats to uint32_t types (Anthony Towns)
a679040ec1 consensus/params: Move version bits period/threshold to bip9 param (Anthony Towns)
e9d617095d versionbits: Remove params from AbstractThresholdConditionChecker (Anthony Towns)
9bc41f1b48 versionbits: Use std::array instead of C-style arrays (Anthony Towns)

Pull request description:

  Increases the encapsulation/modularity of the versionbits code, moving more of the logic into the versionbits module rather than having it scattered across validation and rpc code. Updates unit/fuzz tests to test the actual code used rather than just a close approximation of it.

ACKs for top commit:
  achow101:
    ACK e3014017ba
  TheCharlatan:
    Re-ACK e3014017ba
  darosior:
    ACK e3014017ba

Tree-SHA512: 2978db5038354b56fa1dd6aafd511099e9c16504d6a88daeac2ff2702c87bcf3e55a32e2f0a7697e3de76963b68b9d5ede7976ee007e45862fa306911194496d
2025-04-29 14:06:45 -07:00
Ava Chow 51d76634fb
Merge bitcoin/bitcoin#32365: descriptors: Reject + sign while parsing unsigned
fa655da159 test: [refactor] Use ToIntegral in CheckInferDescriptor (MarcoFalke)
fa55dd01df descriptors: Reject + sign when parsing multi threshold (MarcoFalke)
fa6f77ed3c descriptors: Reject + sign in ParseKeyPathNum (MarcoFalke)

Pull request description:

  As a follow-up to https://github.com/bitcoin/bitcoin/pull/30577, reject `+` for unsigned values in key-path parsing and multi threshold parsing as well.

  Both of those are using unsigned, and Bitcoin Core would never serialize a descriptor string with a stray `+`. Accepting stray `+` signs could lead to checksum mismatches, or other incompatibilities later on.

  Just like https://github.com/bitcoin/bitcoin/pull/30577, both changes are breaking changes on the RPC interface, but hopefully no one should be relying on this behavior in production. Similarly, both changes should be fine for the wallet, because it normalizes the strings on import, see https://github.com/bitcoin/bitcoin/pull/30577#pullrequestreview-2218436014.

ACKs for top commit:
  achow101:
    ACK fa655da159
  brunoerg:
    code review ACK fa655da159
  janb84:
    tACK [fa655da](fa655da159)

Tree-SHA512: d0c7262a167f7ba98b44ed8bf49ff4c15a1eb647cbac39a59b83c7cc379903c24dae3996e5f557497eb08e16d7121417916147058d97bdf168cd6eada57dceef
2025-04-29 10:25:21 -07:00
brunoerg 61ea5f348d fuzz: doc: add info about `afl-system-config` for macOS 2025-04-29 10:28:03 -03:00
merge-script c5e44a0435
Merge bitcoin/bitcoin#32369: test: Use the correct node for doubled keypath test
32d55e28af test: Use the correct node for doubled keypath test (Ava Chow)

Pull request description:

  #29124 had a silent merge conflict with #32350 which resulted in it using the wrong node. Fix the test to use the correct v22 node.

ACKs for top commit:
  maflcko:
    lgtm ACK 32d55e28af
  rkrux:
    ACK 32d55e28af
  BrandonOdiwuor:
    Code Review ACK 32d55e28af

Tree-SHA512: 1e0231985beb382b16e1d608c874750423d0502388db0c8ad450b22d17f9d96f5e16a6b44948ebda5efc750f62b60d0de8dd20131f449427426a36caf374af92
2025-04-29 09:59:42 +01:00
Ava Chow 32d55e28af test: Use the correct node for doubled keypath test 2025-04-28 14:44:17 -07:00
Ava Chow 65714c162c
Merge bitcoin/bitcoin#32327: test: Add missing check for empty stderr in util tester
fadf12a56c test: Add missing check for empty stderr in util tester (MarcoFalke)

Pull request description:

  Now that wine support was removed from the CI in 25b56fd9b4, it can probably be removed from the util tester as well.

  If someone really needs this, they can comment the new check out, or submit a patch to add an option/env var to silence the new check.

ACKs for top commit:
  achow101:
    ACK fadf12a56c
  i-am-yuvi:
    tACK fadf12a56c
  BrandonOdiwuor:
    Code Review ACK fadf12a56c
  ismaelsadeeq:
    Tested ACK fadf12a56c

Tree-SHA512: d9e4d7a7f724e114391070ea7f17b585a7e4c4f3221c3bf510eeb11df6ccd089b881ab5654adfef8d3a1f8fa7ec6bf5e3a3feeb0cdfe724a8f3e5a146c388e66
2025-04-28 14:43:32 -07:00
merge-script a4eee6d50b
Merge bitcoin/bitcoin#29124: test: Test that migration automatically repairs corrupted metadata with doubled derivation path
c7e2b9e264 tests: Test migration cleans up bad inactive chain derivation path (Ava Chow)

Pull request description:

  A bug in 0.21.x and 22.x resulted in some wallets having invalid derivation paths that are the concatenation of two derivation paths. These appear only when inactive hd chains are topped up.

  Since key metadata is a legacy wallet only record, migrating legacy wallets to descriptor wallets will fix this issue as all key metadata records are deleted. The derivation path information is derived on-the-fly from the descriptor that is produced for the inactive hd chain.

  Thus we only need a test to verify that the derivation paths are good, and that all key metadata records are deleted from the migrated wallet.

ACKs for top commit:
  murchandamus:
    re-ACK c7e2b9e264 via range-diff:
  rkrux:
    re-ACK c7e2b9e264
  furszy:
    utACK c7e2b9e264

Tree-SHA512: 3117c4a43798972109fe2d3539341a8b69db70c6457fcabdd019e6044834dc4b17212abbc006d7b8008f560dce4b7856142b057981b9404f406d58fa0955cbd9
2025-04-28 17:13:42 -04:00
Ava Chow af6cffa36d
Merge bitcoin/bitcoin#32350: test: Slim down previous releases bdb check
fa58f40b89 test: Slim down previous releases bdb check (MarcoFalke)

Pull request description:

  The check iterates over several previous BDB-only releases to check that descriptor wallets are considered "corrupt" when loading. It is unclear why this needs to be done for more than one release.

  Avoid the confusion by removing the unused releases from the test and from the download script.

ACKs for top commit:
  achow101:
    ACK fa58f40b89
  rkrux:
    ACK fa58f40b89

Tree-SHA512: 8084392481bfe1fba9b80bb865ffbdfa454e9e6e14e02c39fa3f61c1a596b1def2c531c5da1c7566e5fddb77ac7e56f19feabaaf9b5af043fa6c230d9e2370b5
2025-04-28 12:56:22 -07:00
Ava Chow 33e6538b30
Merge bitcoin/bitcoin#32360: test: Force named args for RPCOverloadWrapper optional args
fa48be3ba4 test: Force named args for RPCOverloadWrapper optional args (MarcoFalke)
aaaa45399c test: Remove unused createwallet_passthrough (MarcoFalke)
cccc1f4e91 test: Remove unused RPCOverloadWrapper is_cli field (MarcoFalke)

Pull request description:

  This can avoid bugs and makes the test code easier to read, because the
  order of positional args does not have to be known or assumed.

  Also, contains two commits to remove dead code.

ACKs for top commit:
  achow101:
    ACK fa48be3ba4
  rkrux:
    tACK fa48be3ba4
  janb84:
    tACK [fa48be3](fa48be3ba4)

Tree-SHA512: d938fbc18be5035ad0d0e1ad2bf7297b2b66ede3bb2d3f10b8d27aa2a19d27a897b024a5f5a2a1cceca467837890729c26054928cb06acbe282b9e9eea94ae69
2025-04-28 12:41:00 -07:00
merge-script 3a29ba33dc
Merge bitcoin/bitcoin#32357: depends: Fix cross-compiling `qt` package from macOS to Windows
35e57fbe33 depends: Fix cross-compiling `qt` package from macOS to Windows (Hennadii Stepanov)

Pull request description:

  Native packages cannot be used during cross-compiling. However, Qt still unconditionally tries to find them, which causes issues in some cases, such as when [cross-compiling from macOS to Windows](https://github.com/bitcoin/bitcoin/issues/32346).

  This PR explicitly disables this unnecessary Qt behaviour.

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

  Here is a full workflow on my macOS Sequoia 15.4.1 (Intel):
  ```
  % brew install make cmake ninja mingw-w64 nsis
  % gmake -C depends -j 10 HOST=x86_64-w64-mingw32
  % cmake -B build --toolchain depends/x86_64-w64-mingw32/toolchain.cmake
  % cmake --build build -j 10 -t deploy
  ```

ACKs for top commit:
  shahsb:
    ACK 35e57fbe33
  fanquake:
    ACK 35e57fbe33

Tree-SHA512: 2822fb49bc84dd094dbd189d8a9ca0f023e1e48127db7beaefb9db92de53df63bb0f399c9c430c33941f9a9ee6976b9161d80467d889f7717385b9d1ea9fee43
2025-04-28 16:15:13 +01:00
MarcoFalke fa655da159
test: [refactor] Use ToIntegral in CheckInferDescriptor 2025-04-28 17:05:43 +02:00
MarcoFalke fa55dd01df
descriptors: Reject + sign when parsing multi threshold 2025-04-28 17:05:37 +02:00
MarcoFalke fa6f77ed3c
descriptors: Reject + sign in ParseKeyPathNum 2025-04-28 17:05:36 +02:00
Lőrinc 7e8ef959d0 refactor: Fix Sonar rule `cpp:S4998` - avoid unique_ptr const& as parameter
Changed `FindChallenges()` parameter from `const std::unique_ptr<const Node<Key>>&` to const `Node*`.

Sonar rule `cpp:S4998` - https://sonarcloud.io/project/issues?issueStatuses=OPEN%2CCONFIRMED&branch=32351-8c0e673c4ac31c1c04750756de749fb813b2c33f&id=aureleoules_bitcoin&open=AZZ2q88IvFhp-eMuMy96:
> Replace this use of "unique_ptr" by a raw pointer or a reference (possibly const).
> Function parameters should not be of type "std::unique_ptr<T> const &" cpp:S4998
> Software qualities impacted: Maintainability
2025-04-28 16:10:35 +02:00
Lőrinc e400ac5352 refactor: simplify repeated comparisons in `FindChallenges`
This obviates that the LHS of the comparison is always the same
2025-04-28 16:09:34 +02:00
Lőrinc f670836112 test: remove old recursive `FindChallenges_recursive` implementation
The performance of the test is the same as before, with the recursive method.
2025-04-28 15:47:01 +02:00
Lőrinc b80d0bdee4 test: avoid stack overflow in `FindChallenges` via manual iteration
The original recursive `FindChallenges` explores the Miniscript node tree using depth-first search. Specifically, it performs a pre-order traversal (processing the node's data, then recursively visiting children from left-to-right). This recursion uses the call stack, which can lead to stack overflows on platforms with limited stack space, particularly noticeable in Windows debug builds.

This change replaces the recursive implementation with an iterative version using an explicit stack. The iterative version also performs a depth-first search and processes the node's data before exploring children (preserving pre-order characteristics), although the children are explored in right-to-left order due to the LIFO nature of the explicit stack.
Critically, both versions collect challenges into a `std::set`, which automatically deduplicates and sorts elements. This ensures that not only the final result, but the actual state of the set at any equivalent point in traversal remains identical, despite the difference in insertion order.

This iterative approach is an alternative to increasing the default stack size (as proposed in #32349) and directly addresses the stack overflow issue reported in #32341 by avoiding deep recursion.

The change is done in two commits:
* add a new iterative `FindChallenges` method and rename the old method to `*_recursive` (to simplify removal in the next commit), asserting that its result matches the original;
* Remove the original recursive implementation.

This approach avoids needing to suppress `misc-no-recursion` warnings and provides a portable, low-risk fix.

Using a `std::set` is necessary for deduplication, matching the original function's behavior. An experiment using an `std::vector` showed duplicate challenges being added, confirming the need for the set:
Example failure with vector:
  Recursive (set):
    (6, 9070746)
    (6, 19532513)
    (6, 3343376967)
  Iterative (vector attempt):
    (6, 19532513)
    (6, 9070746)
    (6, 3343376967)
    (6, 9070746) // Duplicate

Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2025-04-28 15:46:59 +02:00
MarcoFalke fa48be3ba4
test: Force named args for RPCOverloadWrapper optional args
This can avoid bugs and makes the test code easier to read, because the
order of positional args does not have to be known or assumed.
2025-04-28 15:15:05 +02:00
MarcoFalke aaaa45399c
test: Remove unused createwallet_passthrough 2025-04-28 15:14:52 +02:00
stickies-v d05481df64
refactor: validation: mark SnapshotBase as const
It does not modify any logical state. This change is required
for future const-correctness commits.
2025-04-28 15:11:23 +02:00
merge-script f409444d02
Merge bitcoin/bitcoin#32071: build: Drop option to disable hardening.
77e553ab6a build: refactor: hardening flags -> core_interface (David Gumberg)
00ba3ba303 build: Drop option for disabling hardening (David Gumberg)
f57db75e91 build: Use `-z noseparate-code` on NetBSD < 11.0 (David Gumberg)

Pull request description:

  Follow up to #32038 which dropped `NO_HARDEN` from depends builds, this PR drops the `ENABLE_HARDENING` build option since disabling hardening of binaries should not be a supported or maintained use case. With this change, hardening flags are always enabled.

  Individual hardening flags and options can still be disabled by appending flags, e.g.:

  ```bash
  cmake -B build \
    -DAPPEND_CPPFLAGS='-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -fno-stack-protector -fcf-protection=none -fno-stack-clash-protection' \
    -DAPPEND_LDFLAGS='-Wl,-z,lazy -Wl,-z,norelro -Wl,-z,noseparate-code'
  ```

  There is an issue with NetBSD 10.0's dynamic linker that makes one of the hardening linker flags, `-z separate-code`, [problematic](https://github.com/bitcoin/bitcoin/pull/28724#issuecomment-2589347934), so this PR also introduces a check to prevent the use of this flag in NetBSD versions < 11.0, (where this issue is [fixed](acf7fb3abf)). The fix for this [might be backported](https://mail-index.netbsd.org/tech-userlevel/2023/01/05/msg013670.html) to NetBSD 10.0.

  I suggest reviewing the diff with whitespace changes hidden (`git diff -w` or using github's hide whitespace option)

ACKs for top commit:
  hebasto:
    re-ACK 77e553ab6a.
  laanwj:
    re-ACK 77e553ab6a
  janb84:
    ACK [77e553a](77e553ab6a)
  vasild:
    ACK 77e553ab6a
  musaHaruna:
    tested ACK [77e553](77e553ab6a)

Tree-SHA512: b149fb0371d12312c140255bf674c2bdc9f5272a5750a5b9ec5f192323364bb2ea8e164af13b9ab981ab3aa7ceb91b7a64785081e7458470e81c2f5228abf7b1
2025-04-28 13:32:16 +01:00
MarcoFalke cccc1f4e91
test: Remove unused RPCOverloadWrapper is_cli field 2025-04-28 10:18:59 +02:00
Hennadii Stepanov d62c2d82e1
Merge bitcoin/bitcoin#32353: doc: Fix fuzz test_runner.py path
61f238e84a doc: Fix fuzz test_runner.py path (monlovesmango)

Pull request description:

  This commit fixes the path listed in the documentation for the fuzz testing test_runner.py. Previously the --help option worked but running fuzz tests from the documented path did not.

ACKs for top commit:
  kevkevinpal:
    ACK [61f238e](61f238e84a)
  maflcko:
    lgtm ACK 61f238e84a
  mabu44:
    Tested ACK 61f238e84a
  hebasto:
    ACK 61f238e84a.

Tree-SHA512: e8770f38e49a428e0e7f0450db193ec90cc1e66c05bcde307763c065ac7051f3f05923bb3e0eca7a337da9c14cfd17512ff0d01ffa330796159d4f3552103b7f
2025-04-27 16:16:21 +01:00
Hodlinator 10845cd7cc
qa: Add feature_framework_startup_failures.py 2025-04-26 23:30:26 +02:00
Hennadii Stepanov 35e57fbe33 depends: Fix cross-compiling `qt` package from macOS to Windows 2025-04-26 17:13:16 +01:00
Hennadii Stepanov d2ac748e9e
Merge bitcoin-core/gui#864: Crash fix, disconnect numBlocksChanged() signal during shutdown
71656bdfaa gui: crash fix, disconnect numBlocksChanged() signal during shutdown (furszy)

Pull request description:

  Aiming to fix bitcoin-core/gui#862.

  The crash stems from the order of the shutdown procedure:
  We first unset the client model, then destroy the wallet controller—but we leave
  the internal wallet models (`m_wallets`) untouched for a brief period. As a result,
  there’s a point in time where views still have connected signals and access to
  wallet models that are not connected to any wallet controller.
  Now.. since the `clientModel` is only replaced with nullptr locally and not destroyed
  yet, signals like `numBlocksChanged` can still emit. Thus, when wallet views receive
  them, they see a non-null wallet model ptr, and proceed to call backend functions
  from a model that is being torn down.

  As the shutdown procedure begins by unsetting `clientModel` from all views. It’s safe
  to ignore events when `clientModel` is nullptr.

ACKs for top commit:
  maflcko:
    lgtm ACK 71656bdfaa
  pablomartin4btc:
    re-ACK 71656bdfaa
  hebasto:
    ACK 71656bdfaa, I have reviewed the code and it looks OK.

Tree-SHA512: e6a369c40aad8a5a3da64e92daa10250006f60c53feef353a5580e1bdb17fe8e1ad102abf5419ddeff1caa703b69ab634265ef3b9cfef87e9304f97bfdd2c4aa
2025-04-26 13:45:31 +01:00
Luke Dashjr 524f981bb8 Bugfix: Miner: Don't reuse block_reserved_weight for "block is full enough to give up" weight delta
PR #30356 incorrectly changed a constant of `4000` to `m_options.coinbase_max_additional_weight` in the check for when to give up finding another transaction to fill the block:

```diff
             if (nConsecutiveFailed > MAX_CONSECUTIVE_FAILURES && nBlockWeight >
-                    m_options.nBlockMaxWeight - 4000) {
+                    m_options.nBlockMaxWeight - m_options.block_reserved_weight) {
                 // Give up if we're close to full and haven't succeeded in a while
                 break;
             }
```

But this constant did not deal with the reserved weight at all. It was in fact simply checking if the block was close to full, and if so, giving up finding another transaction to pad it with after `MAX_CONSECUTIVE_FAILURES` failed attempts.

It doesn't seem very logical to reuse the reserve weight for this purpose, and it would be overcomplicated to add yet another setting, so this PR changes it to a new constexpr.
2025-04-26 07:45:12 +00:00
Hennadii Stepanov 84de8c93e7
ci: Add `deploy` target for native macOS CI job 2025-04-26 08:01:41 +01:00
Hennadii Stepanov fad57e9e0f
build: Fix `macdeployqtplus` after switching to Qt 6
Homebrew’s `qt@6` package places the `translations` and `plugins`
directories in the `share/qt` subdirectory.
This change updates the `macdeployqtplus` script accordingly.
2025-04-26 08:00:51 +01:00
Hennadii Stepanov de90b47ea0
Merge bitcoin-core/gui#868: Replace stray tfm::format to cerr with qWarning
edd46566bd qt: Replace stray tfm::format to cerr with qWarning (laanwj)

Pull request description:

  GUI warnings should go to the log, not to the console (which may not be connected at all).

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

Tree-SHA512: 32944e00dae0c62bb23e3d7abd486b63e445702483ca03c74c3057ef942f06e771d4d3d3a58fd728582889d6b638fae11ecc536a25febfd89a28522b7d6d08ba
2025-04-26 07:56:23 +01:00
Antoine Poinsot a58cb3b1c1 qa: sanity check mined block have their coinbase timelocked to height 2025-04-25 12:44:08 -04:00
Antoine Poinsot 8f2078af6a miner: timelock coinbase transactions
The Consensus Cleanup soft fork proposal includes enforcing that coinbase transactions set their
locktime field to the block height, minus 1 (as well as their nSequence such as to not disable the
timelock). If such a fork were to be activated by Bitcoin users, miners need to be ready to produce
compliant blocks at the risk of losing substantial amounts mining would-be invalid blocks. As miners
are unfamously slow to upgrade, it's good to make this change as early as possible.

Although Bitcoin Core's GBT implementation does not provide the "coinbasetxn" field, and mining
pool software crafts the coinbase on its own, updating the Bitcoin Core mining code is a first step
toward convincing pools to update their (often closed source) code. A possible followup is also to
introduce new fields to GBT. In addition, this first step also makes it possible to test future
Consensus Cleanup changes.

The changes to the seemingly-unrelated RBF tests is because these tests assert an error message
which may vary depending on the txid of the transactions used in the test. This commit changes the
coinbase transaction structure and therefore impact the txid of transactions in all tests.

The change to the "Bad snapshot" error message in the assumeutxo functional test is because this
specific test case reads into the txid of the next transaction in the snapshot and asserts the error
message based it gets on deserializing this txid as a coin for the previous transaction. As this
commit changes this txid it impacts the deserialization error raised.
2025-04-25 12:44:08 -04:00
Antoine Poinsot 788aeebf34 qa: use prev height as nLockTime for coinbase txs created in unit tests
We don't set the nSequence as it will be set directly in the block template generator in a following
commit.
2025-04-25 12:44:08 -04:00
Antoine Poinsot c76dbe9b8b qa: timelock coinbase transactions created in fuzz targets 2025-04-25 12:44:08 -04:00
Antoine Poinsot 9c94069d8b contrib: timelock coinbase transactions in signet miner 2025-04-25 12:44:08 -04:00
Antoine Poinsot a5f52cfcc4 qa: timelock coinbase transactions created in functional tests 2025-04-25 12:44:08 -04:00
monlovesmango 61f238e84a doc: Fix fuzz test_runner.py path
This commit fixes the path listed in the documentation for the fuzz
testing test_runner.py. Previously the --help option worked but running
fuzz tests from the documented path did not.
2025-04-25 16:33:58 +00:00
Ava Chow c7e2b9e264 tests: Test migration cleans up bad inactive chain derivation path
A bug in 0.21.x and 22.x resulted in some wallets having invalid
derivation paths that are the concatenation of two derivation paths.
These appear only when inactive hd chains are topped up.

Since key metadata is a legacy wallet only record, migrating legacy
wallets to descriptor wallets will fix this issue as all key metadata
records are deleted. The derivation path information is derived
on-the-fly from the descriptor that is produced for the inactive hd
chain.

Thus we only need a test to verify that the derivation paths are good,
and that all key metadata records are deleted from the migrated wallet.
2025-04-25 09:12:53 -07:00
MarcoFalke fa58f40b89
test: Slim down previous releases bdb check 2025-04-25 16:04:07 +02:00
David Gumberg f1b142856a
test: Same addr, diff port is already connected 2025-04-25 15:20:34 +02:00
Vasil Dimov 94e85a82a7
net: remove unnecessary check from AlreadyConnectedToAddress()
`CConnman::AlreadyConnectedToAddress()` searches the existent nodes by
address or by address-and-port:

```cpp
FindNode(static_cast<CNetAddr>(addr)) || FindNode(addr.ToStringAddrPort())
```

but:

* if there is a match by just the address, then the address-and-port
  search will not be evaluated and the whole condition will be `true`
* if the there is no node with the same address, then the second search
  by address-and-port will not find a match either.

The search by address-and-port is comparing against `CNode::m_addr_name`
which could be a hostname, e.g. `"node.foobar.com:8333"`, but
`addr.ToStringAddrPort()` is always going to be numeric.
2025-04-25 15:12:03 +02:00
Hodlinator 28e282ef9a
qa: assert_raises_message() - Stop assuming certain structure for exceptions 2025-04-25 14:39:16 +02:00
merge-script 80e6ad9e30
Merge bitcoin/bitcoin#31250: wallet: Disable creating and loading legacy wallets
17bb63f9f9 wallet: Disallow loading legacy wallets (Ava Chow)
9f04e02ffa wallet: Disallow creating legacy wallets (Ava Chow)
6b247279b7 wallet: Disallow legacy wallet creation from the wallet tool (Ava Chow)
5e93b1fd6c bench: Remove WalletLoadingLegacy benchmark (Ava Chow)
56f959d829 wallet: Remove wallettool salvage (Ava Chow)
7a41c939f0 wallet: Remove -format and bdb from wallet tool's createfromdump (Ava Chow)
c847dee148 test: remove legacy wallet functional tests (Ava Chow)
20a9173717 test: Remove legacy wallet tests from wallet_reindex.py (Ava Chow)
446d480cb2 test: Remove legacy wallet tests from wallet_backwards_compatibility.py (Ava Chow)
aff80298d0 test: wallet_signer.py bdb will be removed (Ava Chow)
f94f9399ac test: Remove legacy wallet unit tests (Ava Chow)
d9ac9dbd8e tests, gui: Use descriptors watchonly wallet for watchonly test (Ava Chow)

Pull request description:

  To prepare for the deletion of legacy wallet code, disable creating or loading new legacy wallets.

  Tests for the legacy wallet specifically are deleted.

  Split from https://github.com/bitcoin/bitcoin/pull/28710

ACKs for top commit:
  Sjors:
    re-ACK 17bb63f9f9
  pablomartin4btc:
    re-ACK 17bb63f9f9
  laanwj:
    re-ACK 17bb63f9f9

Tree-SHA512: d7a86df1f71f12451b335f22f7c3f0394166ac3f8f5b81f6bbf0321026e2e8ed621576656c371d70e202df1be4410b2b1c1acb5d5f0c341e7b67aaa0ac792e7c
2025-04-25 13:11:24 +01:00
merge-script 971952588d
Merge bitcoin/bitcoin#32242: guix: Remove unused `file` package
513e2020a9 guix: Remove unused `file` package (Hennadii Stepanov)

Pull request description:

  The `file` utility has not been required since Guix builds were introduced in https://github.com/bitcoin/bitcoin/pull/15277.

  My Guix build:
  ```
  feeb8da87994724878ac8a62a6e9bfb9b1ece855f336327c900214d84d0a2bb9  guix-build-513e2020a9ac/output/aarch64-linux-gnu/SHA256SUMS.part
  216b287ffbff054a14e60e14b3376acb8cd41dd224223ecd508bd46efad020ba  guix-build-513e2020a9ac/output/aarch64-linux-gnu/bitcoin-513e2020a9ac-aarch64-linux-gnu-debug.tar.gz
  3e68be5a329cbf5f389ca0dde51c1b1dd16b63ec26f42b8aa97dbd455ee3f30e  guix-build-513e2020a9ac/output/aarch64-linux-gnu/bitcoin-513e2020a9ac-aarch64-linux-gnu.tar.gz
  da2d239a78e7ceaa944bd20d15118577daf5cb3817cde4bfe39ea014707326bd  guix-build-513e2020a9ac/output/arm-linux-gnueabihf/SHA256SUMS.part
  0c05b2ab0cd048d4b3b66b97f433895ca0258a68485d641a1c7aaec198114a59  guix-build-513e2020a9ac/output/arm-linux-gnueabihf/bitcoin-513e2020a9ac-arm-linux-gnueabihf-debug.tar.gz
  8cf7ff862c9eccfa7ebfb573674485082b5b797f0a8e9ba058156d3131b144fd  guix-build-513e2020a9ac/output/arm-linux-gnueabihf/bitcoin-513e2020a9ac-arm-linux-gnueabihf.tar.gz
  9464457cb7832b1805a25bb86cdc7c8670dd3c02333e229470d5348c587a73b8  guix-build-513e2020a9ac/output/arm64-apple-darwin/SHA256SUMS.part
  21f0b343cfd5a85f5b563e92931b254874a6dfad21eec91d40b485320ea37a27  guix-build-513e2020a9ac/output/arm64-apple-darwin/bitcoin-513e2020a9ac-arm64-apple-darwin-codesigning.tar.gz
  e34a91173eae3b5ebb6dfa5ca39aa5bb782a2bfd30331edfa0075edda766ac7b  guix-build-513e2020a9ac/output/arm64-apple-darwin/bitcoin-513e2020a9ac-arm64-apple-darwin-unsigned.tar.gz
  6c42015d14fb82f124450498299db15147ee3d93d5192f2fa45d700db9ef0fb9  guix-build-513e2020a9ac/output/arm64-apple-darwin/bitcoin-513e2020a9ac-arm64-apple-darwin-unsigned.zip
  ddd176d8fcf325c23cb1d9c17933f651b26ce3ef13d1c4962460b3bfdb9fd7ff  guix-build-513e2020a9ac/output/dist-archive/bitcoin-513e2020a9ac.tar.gz
  92af97145e0dbeac11a49da48e567f3ee6e08c88c17aa434f10dc4ae13125a57  guix-build-513e2020a9ac/output/powerpc64-linux-gnu/SHA256SUMS.part
  fe980f2d4a6a6c567f447bd86221887ea3f9dcceb14a42e20f9cb8682ff66efe  guix-build-513e2020a9ac/output/powerpc64-linux-gnu/bitcoin-513e2020a9ac-powerpc64-linux-gnu-debug.tar.gz
  41c9f8c46acafec1c80fc1727eddeb8e0373ef06ffc221b16af82b6d61b9c49a  guix-build-513e2020a9ac/output/powerpc64-linux-gnu/bitcoin-513e2020a9ac-powerpc64-linux-gnu.tar.gz
  42051e97efd6178630c65bd398db075342d2c4722f97ec774b4e506b28f7e83b  guix-build-513e2020a9ac/output/riscv64-linux-gnu/SHA256SUMS.part
  f136a82ee58d10db1360d3aa00e695c8e4017db483fe84080e8050efe4436042  guix-build-513e2020a9ac/output/riscv64-linux-gnu/bitcoin-513e2020a9ac-riscv64-linux-gnu-debug.tar.gz
  78d23a7b622e894fa150706a5981ef0bf5ec35b93caaaafdd4aa95c76689ca14  guix-build-513e2020a9ac/output/riscv64-linux-gnu/bitcoin-513e2020a9ac-riscv64-linux-gnu.tar.gz
  7faaa7151d85482a48c73416f0efc124f92fdf26ef232ec0dc9aa131661b2aa8  guix-build-513e2020a9ac/output/x86_64-apple-darwin/SHA256SUMS.part
  13b1bb0026c2441903210f13e61be6220abb75f50dd775bb0bea3bc388ed047c  guix-build-513e2020a9ac/output/x86_64-apple-darwin/bitcoin-513e2020a9ac-x86_64-apple-darwin-codesigning.tar.gz
  80296525f4c797b24e0ac9617ef1e3d4edbce638be3dee823face9554ba9f373  guix-build-513e2020a9ac/output/x86_64-apple-darwin/bitcoin-513e2020a9ac-x86_64-apple-darwin-unsigned.tar.gz
  58a2a3f7335a61c68f7023aa6e2668a958ea2a4acf241c0c9968866ca5da1a21  guix-build-513e2020a9ac/output/x86_64-apple-darwin/bitcoin-513e2020a9ac-x86_64-apple-darwin-unsigned.zip
  511e2f63b1f25e7c4309d8328cd9fa09b8b65dbcce8124334f89445f127f1fd2  guix-build-513e2020a9ac/output/x86_64-linux-gnu/SHA256SUMS.part
  6458af46a7960b668651c59a2a0fef9d44c3c17489fad06f92ca2c43a60b2b23  guix-build-513e2020a9ac/output/x86_64-linux-gnu/bitcoin-513e2020a9ac-x86_64-linux-gnu-debug.tar.gz
  f259a3364bcc3a35346498fb224e061d37d30555aa263fe74bc45e701fb4c9a6  guix-build-513e2020a9ac/output/x86_64-linux-gnu/bitcoin-513e2020a9ac-x86_64-linux-gnu.tar.gz
  246ea6cb2218518c490f9a92bcd1dcb5589ed50f11b3713e4d2721990e655e39  guix-build-513e2020a9ac/output/x86_64-w64-mingw32/SHA256SUMS.part
  beb17556e14916e2af8463090c4f0787e16721961a88ef54975b61dde36d1503  guix-build-513e2020a9ac/output/x86_64-w64-mingw32/bitcoin-513e2020a9ac-win64-codesigning.tar.gz
  85a46d84c0433a50410f1929babc1b22721e8ee7853e57ec5370a072c05146dc  guix-build-513e2020a9ac/output/x86_64-w64-mingw32/bitcoin-513e2020a9ac-win64-debug.zip
  b7191d93cb1524cfd610cee6844119739b9301550b99babb0cefe10546e53445  guix-build-513e2020a9ac/output/x86_64-w64-mingw32/bitcoin-513e2020a9ac-win64-setup-unsigned.exe
  f6615296b46fd064e02fa9b4007e5d59c255595530fc91a8303e417579a7fe80  guix-build-513e2020a9ac/output/x86_64-w64-mingw32/bitcoin-513e2020a9ac-win64-unsigned.zip
  ```

ACKs for top commit:
  janb84:
    Code review and Tested ACK [513e202](513e2020a9)
  fanquake:
    ACK 513e2020a9

Tree-SHA512: 9c684ad473ba6b298dd50c6fb2fb274aa83f5fbe54f6c3d12cd3b30cbc3f77390966ce9ac3be3f675948642743bac4fb45dcda661400bdfde4f347d300478a2a
2025-04-25 10:54:29 +01:00
merge-script ff69046e66
Merge bitcoin/bitcoin#32215: depends: Fix cross-compiling on macOS
d0cce4172c depends: Fix `mv` command compatibility with macOS (Hennadii Stepanov)
690f5da15a depends: Specify Objective C/C++ compilers for `native_qt` package (Hennadii Stepanov)

Pull request description:

  This PR:
  1. Specifies Objective C/C++ compilers for `native_qt` package.
  2. Removes the `-t` option, which is incompatible with `mv` on macOS.

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

ACKs for top commit:
  janb84:
    ACK [d0cce41](d0cce4172c)
  fanquake:
    ACK d0cce4172c

Tree-SHA512: a224407f393cc9a90c73ce156674ec90ed74f59104849b312a993218e28f76c3f97335eed6bd5a3e552fd50002a59aa2de775d8ed7557a74c25202a638bfda8c
2025-04-25 10:15:04 +01:00
Novo 2ae1788dd4 Skip range verification for non-ranged desc
Non-range desc  are always added to the wallet with the range [0,0]. After the descriptor is added, the wallet will  TopUp the keypool. For non-range descriptors, this process updates the desc range to [0,1].

Any attempts to update this non-range descriptor with a [0,0] range will result in an error because the range checks rejects new ranges not included in the old range.

Since  this is a non-range desc, the range information should be disregarded and AddWalletDescriptor should always succeed regardless of provided range information
2025-04-25 05:54:25 +01:00
Ava Chow 4eee328a98
Merge bitcoin/bitcoin#32318: Fix failing util_time_GetTime test on Windows
3dbd50a576 Fix failing util_time_GetTime test on Windows (VolodymyrBg)

Pull request description:

  Remove unreliable steady clock time checking from the test that was causing CI failures primarily on Windows. The test previously tried to verify that  steady_clock time increases after a 1ms sleep, but this approach is not reliable on all platforms where such a short sleep interval may not consistently result in observable clock changes.

  This addresses issue #32197 where the test was reporting failures in the  cross-built Windows CI environment. As noted in the discussion, the test is not critical to the functionality of Bitcoin Core, and removing the unreliable part is the most straightforward solution.

ACKs for top commit:
  maflcko:
    lgtm ACK 3dbd50a576
  achow101:
    ACK 3dbd50a576
  laanwj:
    re-ACK 3dbd50a576

Tree-SHA512: 25c80558d9587c7845d3c14464e8d263c8bd9838a510faf44926e5cda5178aee10b03a52464246604e5d27544011d936442ecfa1e4cdaacb66d32c35f7213902
2025-04-24 15:10:04 -07:00
furszy 71656bdfaa
gui: crash fix, disconnect numBlocksChanged() signal during shutdown
The crash stems from the order of the shutdown procedure:
We first unset the client model, then destroy the wallet controller—but we leave
the internal wallet models ('m_wallets') untouched for a brief period. As a result,
there’s a point in time where views still have connected signals and access to
wallet models that are not connected to any wallet controller.
Now.. since the clientModel is only replaced with nullptr locally and not destroyed
yet, signals like numBlocksChanged can still emit. Thus, when wallet views receive
them, they see a non-null wallet model ptr, and proceed to call backend functions
from a model that is being torn down.

As the shutdown procedure begins by unsetting clientModel from all views. It’s safe
to ignore events when clientModel is nullptr.
2025-04-24 15:33:00 -04:00
VolodymyrBg 3dbd50a576 Fix failing util_time_GetTime test on Windows
Remove unreliable steady clock time checking from the test that was causing
CI failures primarily on Windows. The test previously tried to verify that
steady_clock time increases after a 1ms sleep, but this approach is not reliable
on all platforms where such a short sleep interval may not consistently result
in observable clock changes.

This addresses issue #32197 where the test was reporting failures in the
cross-built Windows CI environment. As noted in the discussion, the test is not
critical to the functionality of Bitcoin Core, and removing the unreliable part
is the most straightforward solution.

Rename and refocus util_time_GetTime test to util_mocktime

Co-Authored-By: maflcko <6399679+maflcko@users.noreply.github.com>
2025-04-24 16:35:02 +03:00
laanwj edd46566bd qt: Replace stray tfm::format to cerr with qWarning
GUI warnings should go to the log, not to the console (which may not be
connected at all).
2025-04-24 12:13:14 +02:00
Hennadii Stepanov 458720e5e9
Merge bitcoin/bitcoin#32336: test: Suppress upstream `-Wduplicate-decl-specifier` in bpfcc
facb9b327b scripted-diff: Use bpf_cflags (MarcoFalke)
fa0c1baaf8 test: Add imports for util bpf_cflags (MarcoFalke)

Pull request description:

  On some Linux kernel versions, the bpf compiler invoked in the functional tests will issue a `-Wduplicate-decl-specifier` warning.

  This seems harmless and should be fixed upstream in the Linux kernel.

  Here, simply suppress it for now. Fixes https://github.com/bitcoin/bitcoin/issues/32322

ACKs for top commit:
  laanwj:
    Code review ACK facb9b327b
  hebasto:
    ACK facb9b327b, I have reviewed the code and it looks OK.

Tree-SHA512: 53387127e3c2a2dbfe05281b2d2e61efbd3c3adcc3b4bf2f11540042f86e1e8c06637f80d246310bc44ca0612318472f25545c1e1ca3636fda97d04381f9e905
2025-04-24 10:53:11 +01:00
MarcoFalke facb9b327b
scripted-diff: Use bpf_cflags
-BEGIN VERIFY SCRIPT-

 ren() { sed --regexp-extended -i "s/$1/$2/g" $( git grep --extended-regexp -l "$1" ) ; }

 ren 'cflags=\["-Wno-error=implicit-function-declaration"\]' 'cflags=bpf_cflags()'

-END VERIFY SCRIPT-
2025-04-24 10:47:57 +02:00
MarcoFalke fa0c1baaf8
test: Add imports for util bpf_cflags
This is required for the next commit.
2025-04-24 10:47:44 +02:00
Ava Chow 9efe546688
Merge bitcoin/bitcoin#31835: validation: set BLOCK_FAILED_CHILD correctly
3c3548a70e validation: clarify final |= BLOCK_FAILED_VALID in InvalidateBlock (Matt Corallo)
aac5488909 validation: correctly update BlockStatus for invalid block descendants (stratospher)
9e29653b42 test: check BlockStatus when InvalidateBlock is used (stratospher)
c99667583d validation: fix traversal condition to mark BLOCK_FAILED_CHILD (stratospher)

Pull request description:

  This PR addresses 3 issues related to how `BLOCK_FAILED_CHILD` is set:
  1. In `InvalidateBlock()`
  - Previously, `BLOCK_FAILED_CHILD` was not being set when it should have been.
  - This was due to an incorrect traversal condition, which is fixed in this PR.

  2. In `SetBlockFailure()`
  - `BLOCK_FAILED_VALID` is now cleared before setting `BLOCK_FAILED_CHILD`.

  3. In `InvalidateBlock()`
  - if block is already marked as `BLOCK_FAILED_CHILD`, don't mark it as `BLOCK_FAILED_VALID` again.

  Also adds a unit test to check `BLOCK_FAILED_VALID` and `BLOCK_FAILED_CHILD` status in `InvalidateBlock()`.

  <details>
  <summary><h3>looking for feedback on an alternate approach</h3></summary>
  <br>

  An alternate approach could be removing `BLOCK_FAILED_CHILD` since even though we have a distinction between
  `BLOCK_FAILED_VALID` and `BLOCK_FAILED_CHILD` in the codebase, we don't use it for anything. Whenever we check for BlockStatus, we use `BLOCK_FAILED_MASK` which encompasses both of them. See  similar discussion in https://github.com/bitcoin/bitcoin/pull/16856.

  I have a branch with this approach in https://github.com/stratospher/bitcoin/commits/2025_02_remove_block_failed_child/.
  Compared to the version in #16856, it also resets `BLOCK_FAILED_CHILD` already on disk to `BLOCK_FAILED_VALID` when loading from disk so that we won't be in a dirty state in a no-`BLOCK_FAILED_CHILD`-world.

  I'm not sure if it's a good idea to remove `BLOCK_FAILED_CHILD` though. would be curious to hear what others think of this approach.

  thanks @ mzumsande for helpful discussion regarding this PR!
  </details>

ACKs for top commit:
  achow101:
    ACK 3c3548a70e
  TheCharlatan:
    Re-ACK 3c3548a70e
  mzumsande:
    re-ACK 3c3548a70e

Tree-SHA512: 83e0d29dea95b97519d4868135c965b86f6f43be50b15c0bd8f998b3476388fc7cc22b49c0c54ec532ae8222e57dfc436438f0c8e98f54757b384f220488b6a6
2025-04-23 14:09:56 -07:00
Ava Chow bd158ab4e3
Merge bitcoin/bitcoin#32023: wallet: removed duplicate call to GetDescriptorScriptPubKeyMan
55b931934a removed duplicate calling of GetDescriptorScriptPubKeyMan (Saikiran)

Pull request description:

  Removed duplicate call to GetDescriptorScriptPubKeyMan and
  Instead of checking linearly I have used find method so time complexity reduced significantly for GetDescriptorScriptPubKeyMan
  after this fix improved performance of importdescriptor part refs https://github.com/bitcoin/bitcoin/issues/32013.

  **Steps to reproduce in testnet environment**

  **Input size:** 2 million address in the wallet

  **Step1:** call importaddresdescriptor rpc method
  observe the time it has taken.

  **With the provided fix:**
  Do the same steps again
  observe the time it has taken.

  There is a huge improvement in the performance. (previously it may take 5 to 6 seconds now it will take 1 seconds or less)

  main changes i've made during this pr:

  1. remove duplicate call to GetDescriptorScriptPubKeyMan method
  2. And inside GetDescriptorScriptPubKeyMan method previously we checking **each address linearly** so each time it is calling HasWallet method which has aquired lock.
  3. Now i've modified this logic call **find method on the map (O(logn)**) time it is taking, so only once we calling HasWallet method.

  **Note:** Smaller inputs in the wallet you may not see the issue but huge wallet size it will definitely impact the performance.

ACKs for top commit:
  achow101:
    ACK 55b931934a
  w0xlt:
    ACK 55b931934a

Tree-SHA512: 4a7fdbcbb4e55bd034e9cf28ab4e7ee3fb1745fc8847adb388c98a19c952a1fb66d7b54f0f28b4c2a75a42473923742b4a99fb26771577183a98e0bcbf87a8ca
2025-04-23 13:51:48 -07:00
Ava Chow 17bb63f9f9 wallet: Disallow loading legacy wallets
Legacy wallets do not have the descriptors flag set. Don't load wallets
without the descriptors flag.

At the same time, we will no longer load BDB databases since they are
only used for legacy wallets.
2025-04-23 12:11:56 -07:00
Ava Chow 9f04e02ffa wallet: Disallow creating legacy wallets
Remove the option to set descriptors=False when creating a wallet, and
enforce this in RPC and in CreateWallet
2025-04-23 12:11:56 -07:00
Ava Chow 6b247279b7 wallet: Disallow legacy wallet creation from the wallet tool 2025-04-23 12:10:30 -07:00
Ava Chow 5e93b1fd6c bench: Remove WalletLoadingLegacy benchmark 2025-04-23 12:10:30 -07:00
Ava Chow 56f959d829 wallet: Remove wallettool salvage
Salvage is bdb only which is about to be removed.
2025-04-23 12:10:30 -07:00
Ava Chow 7a41c939f0 wallet: Remove -format and bdb from wallet tool's createfromdump 2025-04-23 12:10:30 -07:00
Ava Chow c847dee148 test: remove legacy wallet functional tests
Removes all legacy wallet specific functional tests.

Also removes the --descriptor and --legacy-wallet options as these are
no longer necessary with the legacy wallet removed.
2025-04-23 12:10:30 -07:00
Ava Chow 20a9173717 test: Remove legacy wallet tests from wallet_reindex.py 2025-04-23 12:10:30 -07:00
Ava Chow 446d480cb2 test: Remove legacy wallet tests from wallet_backwards_compatibility.py 2025-04-23 12:10:30 -07:00
Ava Chow aff80298d0 test: wallet_signer.py bdb will be removed 2025-04-23 12:09:38 -07:00
Ava Chow f94f9399ac test: Remove legacy wallet unit tests 2025-04-23 12:09:38 -07:00
Ava Chow d9ac9dbd8e tests, gui: Use descriptors watchonly wallet for watchonly test 2025-04-23 12:09:38 -07:00
Hennadii Stepanov 9a4c92eb9a
Merge bitcoin/bitcoin#32226: ci: switch to LLVM 20 in tidy job
08aa7fe232 ci: clang-tidy 20 (fanquake)
2b85d31bcc refactor: starts/ends_with changes for clang-tidy 20 (fanquake)

Pull request description:

  Switch to LLVM 20 in the tidy job.

ACKs for top commit:
  l0rinc:
    ACK 08aa7fe232
  hebasto:
    ACK 08aa7fe232.

Tree-SHA512: 54b6c64adcf7556edf3b30f87935de7868354e8ad252da834796f347a5a77feda01f145f17e5a7419cf6f3b4f87fc2b168c1ec2a2d13bb4e0ffcc0fac667fd42
2025-04-23 13:35:43 +01:00
merge-script 82d1e94838
Merge bitcoin/bitcoin#32310: test: Run all benchmarks in the sanity check
faca46b042 test: Run all benchmarks in the sanity check (MarcoFalke)

Pull request description:

  It is unclear why not all benchmarks are run, given that:

  * they only run as a sanity check (fastest version)
  * no one otherwise runs them, not even CI
  * issues have been missed due to this

ACKs for top commit:
  l0rinc:
    ACK faca46b042
  BrandonOdiwuor:
    Code Review ACK faca46b042

Tree-SHA512: 866f1ccff0313017dd313d5a218d7ee088b823601a129b9ed4c5819b0d57fd808d78e3ea28ca00714ae6b209df5312b7b9dea091b2b028821ff46b8ba263c48a
2025-04-23 10:16:05 +01:00
Ryan Ofsky dda2d4e176
Merge bitcoin/bitcoin#32113: fuzz: enable running fuzz test cases in Debug mode
3669ecd4cc doc: Document fuzz build options (Anthony Towns)
c1d01f59ac fuzz: enable running fuzz test cases in Debug mode (Anthony Towns)

Pull request description:

  When building with

      BUILD_FOR_FUZZING=OFF
      BUILD_FUZZ_BINARY=ON
      CMAKE_BUILD_TYPE=Debug

  allow the fuzz binary to execute given test cases (without actual fuzzing) to make it easier to reproduce fuzz test failures in a more normal debug build.

  In Debug builds, deterministic fuzz behaviour is controlled via a runtime variable, which is normally false, but set to true automatically in the fuzz binary, unless the FUZZ_NONDETERMINISM environment variable is set.

ACKs for top commit:
  maflcko:
    re-ACK 3669ecd4cc 🏉
  marcofleon:
    re ACK 3669ecd4cc
  ryanofsky:
    Code review ACK 3669ecd4cc with just variable renamed and documentation added since last review

Tree-SHA512: 5da5736462f98437d0aa1bd01aeacb9d46a9cc446a748080291067f7a27854c89f560f3a6481b760b9a0ea15a8d3ad90cd329ee2a008e5e347a101ed2516449e
2025-04-22 22:00:59 -04:00
MarcoFalke faca46b042
test: Run all benchmarks in the sanity check 2025-04-22 19:07:18 +02:00
Hennadii Stepanov e5a00b2497
Merge bitcoin/bitcoin#32309: bench: close wallets after migration
cad39f86fb bench: ensure wallet migration benchmark runs exactly once (Lőrinc)
c1f458aaa0 ci: re-enable all benchmark runs (Lőrinc)
1da11dbc44 bench: clean up migrated descriptor wallets via loader teardown (Lőrinc)

Pull request description:

  The low-priority `WalletMigration` benchmark existed for some time but was never run automatically in our CI.

  Although the failure first surfaced on Windows as a hang during temporary directory cleanup, it could also be reproduced on Linux and macOS when forcing multiple iterations (e.g. via a long `--min-time`).

  ### Root causes

  1. **Leaked open wallets on Windows**
     `MigrateLegacyToDescriptor` produces two new descriptor wallets (the primary spendable wallet and a companion watch‑only wallet). Without unloading them, their database files remained open in the `WalletContext`, blocking directory removal and hanging the test harness.

  <details><summary>Details</summary>

  ```bash
  what():  filesystem error: cannot remove all: The process cannot access the file because it is being used by another process [C:\Users\RUNNER\~1\AppData\Local\Temp\test_common bitcoin\WalletMigration\d8ffd89a7700ce01c31f] [C:\Users\RUNNER~1\AppData\Local\Temp\test_common bitcoin\WalletMigration\d8ffd89a7700ce01c31f\regtest\wallet.dat]
  ```

  </details>

  2. **Undefined behavior on repeated runs**
     The benchmark body calls `std::move(wallet)`, invalidating the local `wallet` pointer. Running more than one iteration causes a use-after-move by the sanitizers.

  <details><summary>Details</summary>

  ```bash
  error: bench_bitcoin 0x00067927: DW_TAG_member '_M_local_buf' refers to type 0x00000000000b3ba7 which extends beyond the bounds of 0x0006791d
  * thread #1, name = 'b-test', stop reason = signal SIGSEGV: address not mapped to object (fault address: 0xc8)
    * frame #0: 0x00005555556a3f33 bench_bitcoin`... basic_string<char>::length(this=<unavailable>) const at basic_string.h:1079:16
  ```

  </details>

  ### Fixes

  - **Automatic wallet teardown**
    Wrap the benchmark in a `MakeWalletLoader` (owning a `WalletContext`), so that both migrated wallets are unloaded when the loader goes out of scope, eliminating any lingering open files.

  - **Re-enable benchmarks in CI**
    Drop the temporary filter in GitHub Actions. The `-sanity-check` run already executes each benchmark once, so `WalletMigration` now runs automatically without hangs or crashes.

  - **Single iteration**
    Configure the microbenchmark with `.epochs(1).epochIterations(1)`, ensuring the migration code runs exactly once and avoiding use-after-move.

  No measurable change in benchmark performance.

ACKs for top commit:
  maflcko:
    review ACK cad39f86fb 🍥
  furszy:
    utACK cad39f86fb
  hebasto:
    ACK cad39f86fb, tested on Ubuntu 25.04.

Tree-SHA512: 10343ce7ab9b63ba4f51a7673018215577ea7ec188e41d535a66d69d73b85bca6ba301c33f6920c02f8f7d686c75c65c4a4e9bdafb04b60be85d66aa743cfa20
2025-04-22 17:42:17 +01:00
merge-script 8406a9f4f1
Merge bitcoin/bitcoin#32325: ci: Add missing -Wno-error=array-bounds to valgrind fuzz
fa653cb416 ci: Add missing -Wno-error=array-bounds to valgrind fuzz (MarcoFalke)

Pull request description:

  Due to an upstream GCC issue, any debug/fuzz build which aborts on failed assumes will print a false positive array-bounds warning in `src/test/fuzz/txgraph.cpp`.

  This also affects one CI task.

  Fix the CI task by ignoring the error for now.

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

ACKs for top commit:
  fanquake:
    ACK fa653cb416 - checked native fuzz

Tree-SHA512: 0f6c5ec8d96e0bf96cd008e2de5db59e528086a67dcb77f3e59a0d83225d880a59e960d65c5bc8b5ae3de9d5d301bfc7737d95c282aa1bcc740a42561f610ca8
2025-04-22 17:02:38 +01:00
MarcoFalke fadf12a56c
test: Add missing check for empty stderr in util tester 2025-04-22 17:54:38 +02:00
MarcoFalke fa653cb416
ci: Add missing -Wno-error=array-bounds to valgrind fuzz 2025-04-22 16:20:47 +02:00
fanquake 08aa7fe232
ci: clang-tidy 20 2025-04-22 13:16:54 +01:00
fanquake 2b85d31bcc
refactor: starts/ends_with changes for clang-tidy 20 2025-04-22 13:16:54 +01:00
merge-script 96a5cd8000
Merge bitcoin/bitcoin#32293: doc: Add deps install notes for multiprocess
7f5a35cf4b doc: Add deps install notes for multiprocess (TheCharlatan)

Pull request description:

  These just mirror the content in src/ipc/libmultiprocess/doc/install.md

ACKs for top commit:
  Sjors:
    re-ACK 7f5a35cf4b
  ryanofsky:
    Code review ACK 7f5a35cf4b just dropping dependencies.md update since last review

Tree-SHA512: f9bf4f54542323aa4a0600db874640e575e40355f08515331a27fb139e6e47ee58aa0c6635206f978696e3da7b5aa93efb45b181b02e99e308537fcb90bd6751
2025-04-22 13:16:08 +01:00
merge-script 2844adc8ba
Merge bitcoin/bitcoin#32308: ci: Drop no longer necessary `-Wno-error=array-bounds`
e34f12bdd4 ci: Drop no longer necessary `-Wno-error=array-bounds` (Hennadii Stepanov)

Pull request description:

  The build log of the "Linux->Windows cross" CI job no longer shows any `-Warray-bounds` compiler warnings. Therefore, there's no need to suppress them with `-Wno-error=array-bounds`.

  I likely overlooked this when reviewing https://github.com/bitcoin/bitcoin/pull/29881, as I can run that CI job locally without such warnings even at commit 785649f397.

ACKs for top commit:
  TheCharlatan:
    ACK e34f12bdd4

Tree-SHA512: ac66160866097538af6f196c0cb22d370427c59c071b0ddcb1a6717e233bbd3dfed4e090d266221c55ae0ddd3d5dffb0ca7ae01582eda07f25fb886a775b6ac5
2025-04-22 13:13:11 +01:00
Lőrinc cad39f86fb bench: ensure wallet migration benchmark runs exactly once
The migration benchmark crashes if run more than once, because of `std::move(wallet)` and leaves subsequent iterations in an undefined state - avoiding `UndefinedBehaviorSanitizer` null‑dereference error.
2025-04-22 12:50:26 +02:00
Lőrinc c1f458aaa0 ci: re-enable all benchmark runs
Drop the temporary `-filter` that excluded the `WalletMigration` benchmark.
2025-04-22 12:49:53 +02:00
Lőrinc 1da11dbc44 bench: clean up migrated descriptor wallets via loader teardown
`MigrateLegacyToDescriptor` returns both a spendable descriptor wallet and a watch‑only wallet.
If these remain attached, their files stay open and on Windows this can hang CI when removing the test directory.

By constructing them via `MakeWalletLoader` (which owns the `WalletContext`), both wallets are automatically unloaded when the loader is destroyed at the end.
This ensures no lingering handles or resource leaks when running the benchmark on CI with `-sanity-check`.

Co-authored-by: furszy <matiasfurszyfer@protonmail.com>
2025-04-22 12:41:04 +02:00
Sjors Provoost c6e2c31c55
rpc: unhide waitfor{block,newblock,blockheight}
They are now reliable. An earlier commit dropped their
IsRPCRunning() guards so they also work in the GUI.
2025-04-22 10:34:35 +02:00
Sjors Provoost 0786b7509a
rpc: add optional blockhash to waitfornewblock 2025-04-22 10:34:35 +02:00
Anthony Towns 3669ecd4cc doc: Document fuzz build options
Co-Authored-By: Ryan Ofsky <ryan@ofsky.org>
2025-04-22 17:11:24 +10:00
Anthony Towns c1d01f59ac fuzz: enable running fuzz test cases in Debug mode
When building with

 BUILD_FOR_FUZZING=OFF
 BUILD_FUZZ_BINARY=ON
 CMAKE_BUILD_TYPE=Debug

allow the fuzz binary to execute given test cases (without actual
fuzzing) to make it easier to reproduce fuzz test failures in a more
normal debug build.

In Debug builds, deterministic fuzz behaviour is controlled via a runtime
variable, which is normally false, but set to true automatically in the
fuzz binary, unless the FUZZ_NONDETERMINISM environment variable is set.
2025-04-22 17:11:24 +10:00
Ava Chow 06439a14c8
Merge bitcoin/bitcoin#31953: rpc: Allow fullrbf fee bump in (psbt)bumpfee
fa86190e6e rpc: Allow fullrbf fee bump (MarcoFalke)

Pull request description:

  The RPCs (psbt)bumpfee, and the GUI, reject fee bumps when BIP 125 signalling is absent in the transaction even when the mempool and other RPCs allow them. Fix the confusion by allowing the fee bump.

  This is done after fullrbf is always on (https://github.com/bitcoin/bitcoin/pull/30592)

ACKs for top commit:
  1440000bytes:
    reACK fa86190e6e
  achow101:
    ACK fa86190e6e
  w0xlt:
    ACK fa86190e6e
  rkrux:
    reACK fa86190e6e
  glozow:
    ACK fa86190e6e

Tree-SHA512: b2ffe8dcadbe71e9be767a16cf8aa0bf383c2de7aa1aee9438d125f444e24f3f7e4f02ddb28981bd3b8b645b6a24a407b4ad6bb0b21946ae637e78f6386e05bf
2025-04-21 13:25:52 -07:00
merge-script 3e78ac6811
Merge bitcoin/bitcoin#31243: descriptor: Move filling of keys from `DescriptorImpl::MakeScripts` to `PubkeyProvider::GetPubKey`
acee5c59e6 descriptors: Have GetPrivKey fill keys directly (Ava Chow)
4b0303197e descriptors: Move FlatSigningProvider pubkey filling to GetPubKey (Ava Chow)
25a3b9b0f5 descriptors: Have GetPubKey fill origins directly (Ava Chow)
6268bde0af descriptor: Remove unused parent_info from BIP32PUbKeyProvider::GetPubKey (Ava Chow)
0ff072caa1 wallet, rpc: Only allow keypool import from single key descriptors (Ava Chow)

Pull request description:

  Instead of having `MakeScripts` infer what pubkeys need to go into the output `FlatSigningProvider`, have each of the `PubkeyProviders` that have `GetPubKey` and `GetPrivKey` called fill it directly with relevant keys and origins.

  This allows for keys and origins to be added that won't directly appear in the output, which is necessary for `musig()` descriptors.

  Split from #29675

ACKs for top commit:
  fjahr:
    Code review ACK acee5c59e6
  theStack:
    re-ACK acee5c59e6
  rkrux:
    ACK acee5c5

Tree-SHA512: c1841359bcb08cdd433122deef96579236928660785f3357a3eb584e47d290cd1c60ebe8f7fba50f178ba45c9a90773124e0f509e36c5a0df97c1a4890e03e5c
2025-04-21 14:53:55 -04:00
merge-script 728e86e3f3
Merge bitcoin/bitcoin#31640: tests: improves tapscript unit tests
e3d7533ac9 test: improves tapscript unit tests (Ethan Heilman)
3e167085ba test: Ensures test fails if witness is not hex (Ethan Heilman)

Pull request description:

  This commit creates new test utilities for future Taproot script tests within script_tests.json. The key features of this commit are the addition of three new tags: `#SCRIPT#`, `#CONTROLBLOCK#`, and `#TAPROOTOUTPUT#`. These tags streamline the test creation process by eliminating the need to manually generate these components outside the test suite.

  * `#SCRIPT#`: Parses Tapscript and outputs a byte string of opcodes.
  * `#CONTROLBLOCK#`: Automatically generates the control block for a given Taproot output.
  * `#TAPROOTOUTPUT#`: Generates the final Taproot scriptPubKey.

  This code was originally part of the OP_CAT PR https://github.com/bitcoin/bitcoin/pull/29247 but was pulled out into a separate PR to reduce the rebase treadmill for the OP_CAT PR.

  Additionally this PR adds a check to ensure that if the witness data can not be parsed as hex the test fails. Prior to this PR, the test code would fail silently and set the values it couldn't parse as empty stack elements. This fix was suggested by @instagibbs.

  ## Rationale

  While writing JSON script tests (script_tests.json) for https://github.com/bitcoin/bitcoin/pull/29247 we ran into the following problem. The JSON script tests are simple and easy to write for pre-Tapscript scripts, but adding or changing a Tapscript test requires substantial work per test. Consider the following pre-tapscript test:

  ```
  ["'aa' 'bb'", "CAT 0x4c 0x02 0xaabb EQUAL", "P2SH,STRICTENC", "DISABLED_OPCODE", "CAT disabled"]
  ````

  whereas a Tapscript test for the same script (annotated with comments for better readability) would look like:

  ```
  [
      [
          "aa",
          "bb",
          "7e4c02aabb87", // output script
          "c0d6889cb081036e0faefa3a35157ad71086b123b2b144b649798b494c300a961d", // control block
          0.00000001
      ],
      "",
      "0x51 0x20 0x15048ed3a65748549c27b671936987093cf73a4c9cb18522a74fb9553060ca99", // Tapscript output
      "P2SH,WITNESS,TAPROOT",
      "OK",
      "TAPSCRIPT CATs aa and bb together and checks if EQUAL to aabb"
  ]
  ```

  Computing the Tapscript output, such as `0x51 0x20 0x15048ed3a65748549c27b671936987093cf73a4c9cb18522a74fb9553060ca99`, requires writing custom code and running it for each test. The same is true for the Tapscript control block, such as `c0d6889cb081036e0faefa3a35157ad71086b123b2b144b649798b494c300a961d`. If a test is changed or updated new outputs and control blocks must be computed. The complexity of doing this is likely the reason that no one has added any Tapscript tests to JSON script tests until this PR.

  In this PR we address this issue by adding the following improvements to JSON script tests:

  Adding simple macros ("#SCRIPT# and #CONTROLBLOCK#) that allow the script test parser to automatically generate and inject a valid Tapscript output and control block to be computed automatically from the JSON script.
  Allowing Tapscript scripts to use the human readable strings like pre-script scripts by marking the location of the script in the witness stack using #SCRIPT#. This transforms the unreadable script 7e4c02aabb87 into #SCRIPT# CAT 0x4c 0x02 0xaabb EQUAL.
  This results in the following JSON script test which is far easier to write and easier to read.

  ```
  [
      [
          "aa",
          "bb",
          "#SCRIPT# CAT",
          "#CONTROLBLOCK#",
          0.00000001
      ],
      "",
      "0x51 0x20 #TAPROOTOUTPUT#",
      "P2SH,WITNESS,TAPROOT,OP_CAT",
      "OK",
      "TAPSCRIPT Test of OP_CAT flag by calling CAT on two elements. TAPSCRIPT_OP_CAT flag is set so CAT is executed."
  ],
  ```

ACKs for top commit:
  instagibbs:
    reACK e3d7533ac9
  sipa:
    utACK e3d7533ac9
  janb84:
    Re ACK [e3d7533](e3d7533ac9)

Tree-SHA512: 948c3ec28a4b2b222c2d77e48918ed19d298b51d64662fc20959073edd9978fc796516a392da9755a7e173f556e3021816dc6ce8eb3ed16bbe0fa6ebc574fd48
2025-04-21 14:50:48 -04:00
Hodlinator 1f639efca5
qa: Work around Python socket timeout issue
Observed on local machine running Windows / Python v3.13.1 when overriding rpc_timeout to small values (5- seconds). Next commit performs such overrides.
2025-04-21 20:35:22 +02:00
Ethan Heilman e3d7533ac9 test: improves tapscript unit tests
This commit creates new test utilities for future Taproot script
tests within script_tests.json. The key features of this commit are the
addition of three new tags: `#SCRIPT#`, `#CONTROLBLOCK#`, and
`#TAPROOTOUTPUT#`. These tags streamline the test creation process by
eliminating the need to manually generate these components outside the
test suite.

* `#SCRIPT#`: Parses Tapscript and outputs a byte string of opcodes.
* `#CONTROLBLOCK#`: Automatically generates the control block for a given
Taproot output.
* `#TAPROOTOUTPUT#`: Generates the final Taproot scriptPubKey.

Update src/test/script_tests.cpp

Co-authored-by: Jan B <608446+janb84@users.noreply.github.com>
2025-04-21 11:38:15 -04:00
enoch 2aa63d511a test: Use uninvolved pruned node in feature_pruning undo test
After fixing the nTime variable name, the test_pruneheight_undo_presence
test began failing because node 2, which is involved in reorg testing,
could be on a different chain than other nodes. This caused failures
when trying to fetch blocks from other nodes that didn't recognize
node 2's chain.

Switch to using node 5 instead, which is also a pruned node but isn't
involved in reorg testing, ensuring it stays on the same chain as the
other nodes. This allows the block fetching to work as intended in the
test.
2025-04-21 16:04:25 +01:00
enoch 772ba7f9ce test: Fix nTimes typo in feature_pruning test
Fix incorrect variable name in comment (nTimes -> nTime) in
feature_pruning.py. This typo caused the test to always reset
mine_large_blocks.nTime to 0, rather than only on the first run
as intended.
2025-04-21 16:03:19 +01:00
Greg Sanders b1ea542ae6 test: test MAX_SCRIPT_SIZE for block validity 2025-04-21 09:39:05 -04:00
Hodlinator 9b24a403fa
qa: Only allow calling TestNode.stop() after connecting
(Still tolerate calling it on a no longer (self.)running node, as in a node that has been queried for is_node_stopped() and modified state before returning True).

Tests should not attempt to use the non-functioning RPC interface to call stop() unless wait_for_connections() has succeeded.

No longer log and suppress http.client.CannotSendRequest as a consequence of stop()-RPC, as error conditions causing this knock-on issue are now guarded against before the call.
2025-04-19 21:09:33 +02:00
Hodlinator 6ad21b4c01
qa: Include ignored errors in RPC connection timeout
When an RPC connection attempt with bitcoind times out, include which ignored errors occurred in the exception message.

May provide clues of what has gone wrong.
2025-04-19 21:09:33 +02:00
Hodlinator 879243e81f
qa refactor: wait_for_rpc_connection - Treat OSErrors the same
ConnectionResetError is an OSError as well (ECONNRESET), no reason to have a separate except-block for it.

Also improves comments for other exceptions and make condition above more Pythonic.
2025-04-19 21:09:33 +02:00
Hennadii Stepanov d91a746815
Merge bitcoin/bitcoin#32306: ci: Temporarily disable `WalletMigration` benchmark
18a035145d ci: Temporarily disable `WalletMigration` benchmark (Hennadii Stepanov)

Pull request description:

  The `WalletMigration` benchmark is currently failing on CI.

  This PR temporarily disables it until the issue is resolved.

  An alternative to https://github.com/bitcoin/bitcoin/pull/32302.

ACKs for top commit:
  maflcko:
    lgtm ACK 18a035145d
  TheCharlatan:
    ACK 18a035145d

Tree-SHA512: bb1451fd0743a2955216a6d06916e411420a76bfed8b69ffcfadf99d0996d8f3b89ed72f855f25269f943ca4c3b4422065fde2374a1bf76c8bb64f14ab883092
2025-04-19 12:53:08 +01:00
Hennadii Stepanov ff136d046a
Merge bitcoin/bitcoin#32213: msvc: Update vcpkg manifest
d85895e5a7 build, msvc: Build only required `qtbase` features (Hennadii Stepanov)
fe5a6dcc53 build, msvc: Update vcpkg manifest baseline (Hennadii Stepanov)

Pull request description:

  This PR:

  1. Updates the vcpkg manifest baseline from the [2024.09.30 Release](https://github.com/microsoft/vcpkg/releases/tag/2024.09.30) to the [2025.03.19 Release](https://github.com/microsoft/vcpkg/releases/tag/2025.03.19), with the following package changes:

       - boost: 1.85.0#1,2 --> 1.87.0
       - qtbase: 6.7.2#3 -> 6.8.2#1
       - qttools: 6.7.2#1 -> 6.8.2
       - sqlite3: 3.46.1 --> 3.49.1

  The previous update was made in https://github.com/bitcoin/bitcoin/pull/31186.

  3. Explicitly specifies required features for the `qtbase` package, which makes vcpkg skip unused features such as `dnslookup`, `openssl`, etc.

ACKs for top commit:
  hodlinator:
    ACK d85895e5a7

Tree-SHA512: e05fb50825c6ba2e0caf8ded1dfb55fa42f28f06dcd28597f748c1843a1c4cc888e62ad87b6481c66481a576fa224dd4943fe76e286ff579c6d4dc2ec6a78a71
2025-04-19 11:12:19 +01:00
Hennadii Stepanov e34f12bdd4
ci: Drop no longer necessary `-Wno-error=array-bounds` 2025-04-19 08:11:47 +01:00
Ava Chow 055254e212
Merge bitcoin/bitcoin#32300: feefrac: avoid integer overflow in temporary
5cb1241814 feefrac: avoid integer overflow in temporary (Pieter Wuille)

Pull request description:

  In `FeeFrac::Div(__int128 n, int32_t d, bool round_down)` in src/util/feefrac.h, the following line computes the result:

  ```c++
          return quot + (mod > 0) - (mod && round_down);
  ```

  The function can only be called under conditions where the result is in range, and thus doesn't involve any integer overflow. However, the intermediary result computed by just `quot + (mod > 0)` may still overflow if it's going to be corrected by the `- (mod && round_down)` that follows.

  Fix this by balancing the two correction steps with each other first:
  ```c++
          return quot + ((mod > 0) - (mod && round_down));
  ```

  Fixes #32294.

ACKs for top commit:
  l0rinc:
    Tested ACK 5cb1241814
  maflcko:
    lgtm ACK 5cb1241814
  achow101:
    ACK 5cb1241814

Tree-SHA512: 9daaccdf9acd7652d53b52cad2dc12872558265e863acdde2d6015f885cb87c0505f9bd5be5499fc0a0eded29bec719643f6af1fbc3604518143985094226c95
2025-04-18 15:34:04 -07:00
Ava Chow 33d40a6ad4
Merge bitcoin/bitcoin#32282: torcontrol: Fix addrOnion outdated comment
bcaa23a2b7 torcontrol: Fix addrOnion outdate comment (Eval EXEC)

Pull request description:

  `m_randomize_credentials` is outdated name, remove it.
  Ref: https://github.com/bitcoin/bitcoin/pull/32176#discussion_r2044977356

ACKs for top commit:
  achow101:
    ACK bcaa23a2b7
  laanwj:
    ACK bcaa23a2b7
  w0xlt:
    ACK bcaa23a2b7
  jonatack:
    ACK bcaa23a2b7

Tree-SHA512: 38ba9b37e560598605077da7a84c455aa1a7e49365c417ceceff85a18de2af393b164cc8c93cdd6da9eac4d41f046f0ed12bc0f6833fe606c412ce7f1fce5189
2025-04-18 15:04:50 -07:00
Hennadii Stepanov 18a035145d
ci: Temporarily disable `WalletMigration` benchmark 2025-04-18 22:44:16 +01:00
merge-script c7b592fbd7
Merge bitcoin/bitcoin#31247: psbt: MuSig2 Fields
e261eb8d50 tests: Add BIP 373 test vectors (Ava Chow)
26370c68d0 rpc: Include MuSig2 fields in decodepsbt (Ava Chow)
ff3d460898 psbt: Implement un/ser of musig2 fields (Ava Chow)

Pull request description:

  Implements un/serialization of MuSig2 PSBT fields and prepares PSBT to be able to sign for MuSig2 inputs.

  Split from #29675

ACKs for top commit:
  fjahr:
    re-ACK e261eb8d50
  theStack:
    re-ACK e261eb8d50
  rkrux:
    tACK e261eb8d50

Tree-SHA512: bb852ad074978847ac4dc656332025e2d4d1025d4283537b89618c7cadd61a8ecd2eff24779b8a014bc8d7b431125060449768192fa05ad0577f29e3c64b2374
2025-04-18 16:44:33 -04:00
Ava Chow e261eb8d50 tests: Add BIP 373 test vectors 2025-04-17 16:31:57 -07:00
Ava Chow 26370c68d0 rpc: Include MuSig2 fields in decodepsbt 2025-04-17 16:31:57 -07:00
Ava Chow ff3d460898 psbt: Implement un/ser of musig2 fields 2025-04-17 16:31:57 -07:00
Pieter Wuille 5cb1241814 feefrac: avoid integer overflow in temporary 2025-04-17 17:37:35 -04:00
TheCharlatan 7f5a35cf4b
doc: Add deps install notes for multiprocess
These just mirror the content in src/ipc/libmultiprocess/doc/install.md
2025-04-17 20:26:43 +02:00
merge-script 247e9de622
Merge bitcoin/bitcoin#32191: Make TxGraph fuzz tests more deterministic
2835216ec0 txgraph: make GroupClusters use partition numbers directly (optimization) (Pieter Wuille)
c72c8d5d45 txgraph: compare sequence numbers instead of Cluster* (bugfix) (Pieter Wuille)

Pull request description:

  Part of cluster mempool: #30289

  The implicit transaction ordering for transactions in a TxGraphImpl is defined by:
  1. higher chunk feerate first
  2. lower Cluster* object pointer first
  3. lower position within cluster linearization first.

  Number (2) is not deterministic, as it intricately depends on the heap allocation algorithm. Fix this by giving each Cluster a unique `uint64_t m_sequence` value, and sorting by those instead.

  The second commit then uses this new approach to optimize GroupClusters a bit more, avoiding some repeated checks and dereferences, by making a local copy of the involved sequence numbers.

  Thanks to @dergoegge for pointing this out.

ACKs for top commit:
  instagibbs:
    reACK 2835216ec0
  marcofleon:
    ACK 2835216ec0
  glozow:
    utACK 2835216ec0

Tree-SHA512: d772a55b9ed620159b934a42a39fca7f900d4aa89c099a280a0c61ea0bd7c4fc39b388281ffc775064ea77b0b17263871b4c9763aa71c710a79287d5eb2cd4b4
2025-04-17 13:50:48 -04:00
merge-script bfeacc18b3
Merge bitcoin/bitcoin#32154: fuzz: Avoid integer sanitizer warnings in policy_estimator target
fa6a007b8e fuzz: Avoid integer sanitizer warnings in policy_estimator target (MarcoFalke)

Pull request description:

  It seems odd to write a fuzz target to trigger integer sanitizer warnings in `CBlockPolicyEstimator::processBlockTx` and then suppress them. If the scenario can happen in reality, the code should be properly fixed to handle the cases. If not, it seems better to fix the fuzz target to not trigger meaningless traces.

  Do that here by keeping track of the current height and limiting mempool entries to at most this entry height.

ACKs for top commit:
  brunoerg:
    ACK fa6a007b8e
  dergoegge:
    utACK fa6a007b8e

Tree-SHA512: 2092017dc309fb095fe5d43cfb76efb691795f303d567ee919be2b5cac19a944293636229903dc4d1e8b9fe5daf9dc3058544321eff1735f91f804c3baa36cd0
2025-04-17 13:34:53 +01:00
MarcoFalke fa86190e6e
rpc: Allow fullrbf fee bump
Also, fix the incorrect documention of the 'replaceable' RPC argument
with respect to sequence number handling. The docs were incorrect
before, so the fix could be extracted, but it seems fine to include here
as well.
2025-04-17 13:12:26 +02:00
merge-script 06f9ead9f9
Merge bitcoin/bitcoin#32271: doc: Document WITH_EXTERNAL_LIBMULTIPROCESS build option better
9ccee9cd02 doc: Document WITH_EXTERNAL_LIBMULTIPROCESS build option better (Ryan Ofsky)

Pull request description:

  This includes a cmake documentation change suggested https://github.com/bitcoin/bitcoin/pull/31741#discussion_r2039716492 and another change to mention the option in markdown documentation

ACKs for top commit:
  hebasto:
    ACK 9ccee9cd02, changes look good.
  TheCharlatan:
    ACK 9ccee9cd02

Tree-SHA512: c9103b001b970ac57afedc6dc384091f5661975d569573e93003cbd7df1891c54cefb06d7296eac5b9a5c57251803dcab2bd3b26c9d81aa476c62f211dcb3d6e
2025-04-17 11:41:06 +01:00
merge-script 4a964868f8
Merge bitcoin/bitcoin#32288: ci: drop -priority-level from bench in win cross CI
27f11217ca ci: drop -priority-level from bench in win cross CI (fanquake)

Pull request description:

  So there's at least one CI sanity checking all benchmarks.

  Related to #32277.

ACKs for top commit:
  l0rinc:
    utACK 27f11217ca
  hebasto:
    ACK 27f11217ca.
  mabu44:
    utACK 27f11217ca

Tree-SHA512: 4853584bf9db418f6e31aa0f558d08bc45479d672b193e1d25a25907f82fb225bc4388321f8f23286cd9fd9168c7546c713829607eb0cf5e3c62b98e88f8e68b
2025-04-17 11:34:36 +01:00
merge-script cd01c9a173
Merge bitcoin/bitcoin#32250: ci: Slim down lint image
faeb1babe2 ci: refactor: Use version id over version codename consistently (MarcoFalke)
fae322a43a ci: Slim down lint image (MarcoFalke)
3333273a8f ci: Bump lint imagefile FROM base (MarcoFalke)

Pull request description:

  Currently, the lint_test_runner is built and installed into the lint CI image. This is problematic, because it triggers a full image build on every change to its source code. Doing a build of the lint test_runner on every run is easier and faster.

ACKs for top commit:
  l0rinc:
    ACK faeb1babe2
  janb84:
    Re- ACK [faeb1ba](faeb1babe2)

Tree-SHA512: 39103e61ec2587096213bc1ce55b80087f6f03775592827d8c96a366453b798570d912690bf96fde4685798e5fc8ee2695ce851f473b4c8782d1a4c50c65a594
2025-04-17 11:34:11 +01:00
Hennadii Stepanov 513e2020a9
guix: Remove unused `file` package
The `file` utility has not been required since Guix builds were
introduced.
2025-04-17 10:33:01 +01:00
fanquake 27f11217ca
ci: drop -priority-level from bench in win cross CI
So there's at least one CI sanity checking all benchmarks.

Related to #32277.
2025-04-17 09:44:10 +01:00
merge-script 7a3afe6787
Merge bitcoin/bitcoin#32281: bench: Fix WalletMigration benchmark
7912cd4125 bench: Fix WalletMigration benchmark (pablomartin4btc)

Pull request description:

  The keys and scripts created for the Legacy Wallet needed to be persisted in order for the migration to work properly.

  Fixes #32277.

ACKs for top commit:
  achow101:
    ACK 7912cd4125
  davidgumberg:
    Tested ACK 7912cd4125
  furszy:
    utACK 7912cd4125

Tree-SHA512: fe7b8e0a80d4d030ad3fd6446717ee09a260ab2bd6140bc817bdca52d233e3af8a8fed2d754743ca2ba022f7d2c8615a36b5070991d12942c13835e8f72e359f
2025-04-17 09:43:42 +01:00
Ava Chow e66e30c9e5
Merge bitcoin/bitcoin#31862: doc: Fix and clarify description of ZMQ message format
7a93544cdc doc: Fix and clarify description of ZMQ message format (Jiri Jakes)

Pull request description:

  This change stresses that all ZMQ messages share the same structure and that they differ only in the format of the bodies. Previously this was not clear.

  Further it removes the notion of endianness of 32-byte hashes, as it was misleading, and replaces it with the term 'reversed byte order' (as opposed to natural or normal byte order produced by hashing functions).

  Additionally, it states that ZMQ 32-byte hashes are in the same format as in RPC. Previously it incorrectly stated that the two were in different formats.

  [Rendered](https://github.com/jirijakes/bitcoin/blob/zmq-doc/doc/zmq.md).

  Fixes #31856.

ACKs for top commit:
  w0xlt:
    Code review ACK 7a93544cdc
  achow101:
    ACK 7a93544cdc
  ryanofsky:
    Code review ACK 7a93544cdc. Nice changes. Documentation seems less repetitive and easier to understand now

Tree-SHA512: 8c5ab047c5fd9b5b6910d691b725886d7743dfd01510735b46e43d01c2d0d25ec52d79d71ec75dbeb142e96a88ad503d69ee14b971e3cdaeb8fd85e5292a8c21
2025-04-16 16:26:18 -07:00
Ava Chow b6282dbd45
Merge bitcoin/bitcoin#32079: test: Add test coverage for rpcwhitelistdefault when unset
2929da1dd5 test: Add coverage for rpcwhitelistdefault when unset (naiyoma)
535b874707 test: Combine rpcwhitelistdefault functions (naiyoma)
2b6ce9254d test: Update permissions and string formatting (naiyoma)

Pull request description:

  This is a follow-up PR to address review feedback from [https://github.com/bitcoin/bitcoin/pull/29858](https://github.com/bitcoin/bitcoin/pull/29858)

  - [x]  add  case where rpcwhitelistdefault setting is [unset](https://github.com/bitcoin/bitcoin/pull/29858#pullrequestreview-2532726241)
  - [x] Code [cleanup](https://github.com/bitcoin/bitcoin/pull/29858#discussion_r1927238617) , change password and f-string formatting
  - [x] [Combine](https://github.com/bitcoin/bitcoin/pull/29858#discussion_r1930137601) rpcwhitelistdefault tests into `test_rpcwhitelistdefault_permissions`
  I am not sure if my approach of adding` test_rpcwhitelistdefault_unset` is better or if I should just include the assertions in the existing `test_rpcwhitelistdefault_permissions`

ACKs for top commit:
  w0xlt:
    Code review ACK 2929da1dd5
  achow101:
    ACK 2929da1dd5
  ryanofsky:
    Code review ACK 2929da1dd5. Only change since last review was simplifying the last commit as suggested

Tree-SHA512: 6750dd3e6abaca3a09ad1fd5d07c64767bc59188ff953cbc26aa7796071774cb92745ac82cf91e479632d682fd450bc00d53032454b65b22654a3e770ec68e89
2025-04-16 16:24:01 -07:00
Ava Chow eb6b1003c1
Merge bitcoin/bitcoin#32286: test: Handle empty string returned by CLI as None in RPC tests
a4041c77f0 test: Handle empty string returned by CLI as None in RPC tests (Brandon Odiwuor)

Pull request description:

  Partially Fixes https://github.com/bitcoin/bitcoin/issues/32264

  Some tests are failing when `bitcoin-cli` returns an empty string. This change treats an empty response as `None`. See https://github.com/bitcoin/bitcoin/issues/32264#issuecomment-2807616694

  This fixes the error for:
  - feature_bip68_sequence.py
  - feature_nulldummy.py
  - feature_signet.py
  - mining_mainnet.py
  - rpc_scanblocks.py
  - rpc_scantxoutset.py
  - wallet_descriptor.py --descriptors

ACKs for top commit:
  maflcko:
    lgtm ACK a4041c77f0
  achow101:
    ACK a4041c77f0
  pablomartin4btc:
    ACK a4041c77f0
  mzumsande:
    ACK a4041c77f0

Tree-SHA512: 2f1a416a18e0b3eebdb014c2e2e8dadf1d46b15c231cb61f577d47f5e551994ab0e2aeb7c179c01be7c1f07ebc03476236d29cf2d04c358ffb1fae985aa385c9
2025-04-16 16:17:35 -07:00
Ava Chow 33df4aebae
Merge bitcoin/bitcoin#31551: [IBD] batch block reads/writes during `AutoFile` serialization
8d801e3efb optimization: bulk serialization writes in `WriteBlockUndo` and `WriteBlock` (Lőrinc)
520965e293 optimization: bulk serialization reads in `UndoRead`, `ReadBlock` (Lőrinc)
056cb3c0d2 refactor: clear up blockstorage/streams in preparation for optimization (Lőrinc)
67fcc64802 log: unify error messages for (read/write)[undo]block (Lőrinc)
a4de160492 scripted-diff: shorten BLOCK_SERIALIZATION_HEADER_SIZE constant (Lőrinc)
6640dd52c9 Narrow scope of undofile write to avoid possible resource management issue (Lőrinc)
3197155f91 refactor: collect block read operations into try block (Lőrinc)
c77e3107b8 refactor: rename leftover WriteBlockBench (Lőrinc)

Pull request description:

  This change is part of [[IBD] - Tracking PR for speeding up Initial Block Download](https://github.com/bitcoin/bitcoin/pull/32043)

  ### Summary
  We can serialize the blocks and undos to any `Stream` which implements the appropriate read/write methods.
  `AutoFile` is one of these, writing the results "directly" to disk (through the OS file cache). Batching these in memory first and reading/writing these to disk is measurably faster (likely because of fewer native fread calls or less locking, as [observed](https://github.com/bitcoin/bitcoin/pull/28226#issuecomment-1666842501) by Martinus in a similar change).

  ### Unlocking new optimization opportunities

  Buffered writes will also enable batched obfuscation calculations (implemented in https://github.com/bitcoin/bitcoin/pull/31144) - especially since currently we need to copy the write input's std::span to do the obfuscation on it, and batching enables doing the operations on the internal buffer directly.

  ### Measurements (micro benchmarks, full IBDs and reindexes)

  Microbenchmarks for `[Read|Write]BlockBench` show a ~**30%**/**168%** speedup with `macOS/Clang`, and ~**19%**/**24%** with `Linux/GCC` (the follow-up XOR batching improves these further):

  <details>
  <summary>macOS Sequoia - Clang 19.1.7</summary>

  > Before:

  |               ns/op |                op/s |    err% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------:|:----------
  |        2,271,441.67 |              440.25 |    0.1% |     11.00 | `ReadBlockBench`
  |        5,149,564.31 |              194.19 |    0.8% |     10.95 | `WriteBlockBench`

  > After:

  |               ns/op |                op/s |    err% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------:|:----------
  |        1,738,683.04 |              575.15 |    0.2% |     11.04 | `ReadBlockBench`
  |        3,052,658.88 |              327.58 |    1.0% |     10.91 | `WriteBlockBench`

  </details>

  <details>
  <summary>Ubuntu 24 - GNU 13.3.0</summary>

  > Before:

  |               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |         bra/op |   miss% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
  |        6,895,987.11 |              145.01 |    0.0% |   71,055,269.86 |   23,977,374.37 |  2.963 |   5,074,828.78 |    0.4% |     22.00 | `ReadBlockBench`
  |        5,152,973.58 |              194.06 |    2.2% |   19,350,886.41 |    8,784,539.75 |  2.203 |   3,079,335.21 |    0.4% |     23.18 | `WriteBlockBench`

  > After:

  |               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |         bra/op |   miss% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
  |        5,771,882.71 |              173.25 |    0.0% |   65,741,889.82 |   20,453,232.33 |  3.214 |   3,971,321.75 |    0.3% |     22.01 | `ReadBlockBench`
  |        4,145,681.13 |              241.21 |    4.0% |   15,337,596.85 |    5,732,186.47 |  2.676 |   2,239,662.64 |    0.1% |     23.94 | `WriteBlockBench`

  </details>

  2 full IBD runs against master (compiled with GCC where the gains seem more modest) for **888888** blocks (seeded from real nodes) indicates a ~**7%** total speedup.

  <details>
  <summary>Details</summary>

  ```bash
  COMMITS="d2b72b13699cf460ffbcb1028bcf5f3b07d3b73a 652b4e3de5c5e09fb812abe265f4a8946fa96b54"; \
  STOP_HEIGHT=888888; DBCACHE=1000; \
  C_COMPILER=gcc; CXX_COMPILER=g++; \
  BASE_DIR="/mnt/my_storage"; DATA_DIR="$BASE_DIR/BitcoinData"; LOG_DIR="$BASE_DIR/logs"; \
  (for c in $COMMITS; do git fetch origin $c -q && git log -1 --pretty=format:'%h %s' $c || exit 1; done) && \
  hyperfine \
    --sort 'command' \
    --runs 2 \
    --export-json "$BASE_DIR/ibd-${COMMITS// /-}-$STOP_HEIGHT-$DBCACHE-$C_COMPILER.json" \
    --parameter-list COMMIT ${COMMITS// /,} \
    --prepare "killall bitcoind; rm -rf $DATA_DIR/*; git checkout {COMMIT}; git clean -fxd; git reset --hard; \
      cmake -B build -DCMAKE_BUILD_TYPE=Release -DENABLE_WALLET=OFF -DCMAKE_C_COMPILER=$C_COMPILER -DCMAKE_CXX_COMPILER=$CXX_COMPILER && \
      cmake --build build -j$(nproc) --target bitcoind && \
      ./build/bin/bitcoind -datadir=$DATA_DIR -stopatheight=1 -printtoconsole=0; sleep 100" \
    --cleanup "cp $DATA_DIR/debug.log $LOG_DIR/debug-{COMMIT}-$(date +%s).log" \
    "COMPILER=$C_COMPILER COMMIT=${COMMIT:0:10} ./build/bin/bitcoind -datadir=$DATA_DIR -stopatheight=$STOP_HEIGHT -dbcache=$DBCACHE -blocksonly -printtoconsole=0"
  d2b72b1369 refactor: rename leftover WriteBlockBench
  652b4e3de5 optimization: Bulk serialization writes in `WriteBlockUndo` and `WriteBlock`
  Benchmark 1: COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=888888 -dbcache=1000 -blocksonly -printtoconsole=0 (COMMIT = d2b72b13699cf460ffbcb1028bcf5f3b07d3b73a)
    Time (mean ± σ):     41528.104 s ± 354.003 s    [User: 44324.407 s, System: 3074.829 s]
    Range (min … max):   41277.786 s … 41778.421 s    2 runs

  Benchmark 2: COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=888888 -dbcache=1000 -blocksonly -printtoconsole=0 (COMMIT = 652b4e3de5c5e09fb812abe265f4a8946fa96b54)
    Time (mean ± σ):     38771.457 s ± 441.941 s    [User: 41930.651 s, System: 3222.664 s]
    Range (min … max):   38458.957 s … 39083.957 s    2 runs

  Relative speed comparison
          1.07 ±  0.02  COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=888888 -dbcache=1000 -blocksonly -printtoconsole=0 (COMMIT = d2b72b13699cf460ffbcb1028bcf5f3b07d3b73a)
          1.00          COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=888888 -dbcache=1000 -blocksonly -printtoconsole=0 (COMMIT = 652b4e3de5c5e09fb812abe265f4a8946fa96b54)
  ```

  </details>

ACKs for top commit:
  maflcko:
    re-ACK 8d801e3efb 🐦
  achow101:
    ACK 8d801e3efb
  ryanofsky:
    Code review ACK 8d801e3efb. Most notable change is switching from BufferedReader to ReadRawBlock for block reads, which makes sense, and there are also various cleanups in blockstorage and test code.
  hodlinator:
    re-ACK 8d801e3efb

Tree-SHA512: 24e1dee653b927b760c0ba3c69d1aba15fa5d9c4536ad11cfc2d70196ae16b9228ecc3056eef70923364257d72dc929882e73e69c6c426e28139d31299d08adc
2025-04-16 15:16:22 -07:00
Ava Chow 679bb2aac2
Merge bitcoin/bitcoin#31958: rpc: add cli examples, update docs
32dcec269b rpc: update RPC help of `createpsbt` (rkrux)
931117a46f rpc: update the doc for `data` field in `outputs` argument (rkrux)
8134a6b5d4 rpc: add cli example for `walletcreatefundedpsbt` RPC (rkrux)

Pull request description:

  ### add cli example for `walletcreatefundedpsbt` and `createpsbt` RPCs
  The only example present earlier was one that creates an OP_RETURN output. This
      lack of examples has discouraged me earlier to use this RPC. Adding an example
      that creates PSBT sending bitcoin to address, a scenario that is much more common.

  ### rpc: update the doc for `data` field in `outputs` argument
  It was not evident to me that this field creates an `OP_RETURN` output until
      I read the code and tried it out. Thus, making the doc explicitly mention it.
  This affects docs of the following RPCs:
  `bumpfee`, `psbtbumpfee`, `send`, `walletcreatefundedpsbt`, `createpsbt`,
  and `createrawtransaction`

ACKs for top commit:
  sipa:
    utACK 32dcec269b
  1440000bytes:
    utACK 32dcec269b
  achow101:
    ACK 32dcec269b
  ryanofsky:
    Concept ACK 32dcec269b. These seem like helpful clarifications, but I did not look into the details

Tree-SHA512: f994488ba7d52d00960fc52064bb419cf548e29822fe23d6ee0452fdf514dd93f089145eddb32b8086a7918cf8cf33a4c3f16bfcb7948f3c9d5afd95e8d3a1cb
2025-04-16 13:13:20 -07:00
Ava Chow dfa2813e31
Merge bitcoin/bitcoin#32248: Remove support for RNDR/RNDRRS for aarch64
7749d929a0 Remove support for RNDR/RNDRRS for aarch64 on Linux (laanwj)

Pull request description:

  This hardware feature is

  - Rarely supported on SoCs (and broken on like half of the chips that support it in the first place) (#31817). It is not clear if, or how, the brokenness will be worked around in the kernel, but working around it in user space seems the wrong thing to do, this is not the place to maintain special workarounds for specific hardware (which despite that, was attempted in #31826, but had to be reverted in #31908 due to other problems).
  - Apparently not compiled into the release binary anymore (https://github.com/bitcoin/bitcoin/issues/31817#issuecomment-2795885962). Did check this at the time, but a build system change must have caused this, and went undetected.
  - Hard to test in CI (as well as manually), due to unavailability of hardware.

  Better to remove it.

  This reverts commit aee5404e02 from #26839.

  Closes #31817.

ACKs for top commit:
  sipa:
    utACK 7749d929a0
  davidgumberg:
    utACK 7749d929a0
  achow101:
    ACK 7749d929a0
  w0xlt:
    utACK 7749d929a0

Tree-SHA512: d243ad7f745fb46f711f24b6983d9ea1d94e5d8ee60959229bafdba5caa210a60801a1c2cb5b558a0e72f365371b32285aee9a8d0cd24a60589adc7b03dd6a44
2025-04-16 11:57:11 -07:00
pablomartin4btc 7912cd4125 bench: Fix WalletMigration benchmark
The keys and scripts created for the Legacy Wallet
needed to be persisted in order for the migration to work
properly.
2025-04-16 12:33:46 -03:00
Hennadii Stepanov 938208d91a build: Resolve `@rpath` in `macdeployqtplus`
Extend `getFrameworks()` with an optional `rpath` parameter to replace
`@rpath` in dependency paths. This fixes resolution of framework
dependencies when using Homebrew's `qt@6` package.
2025-04-16 13:16:17 +01:00
Eval EXEC bcaa23a2b7 torcontrol: Fix addrOnion outdate comment
Signed-off-by: Eval EXEC <execvy@gmail.com>
2025-04-16 19:59:52 +08:00
Brandon Odiwuor a4041c77f0 test: Handle empty string returned by CLI as None in RPC tests 2025-04-16 14:18:48 +03:00
Sjors Provoost abe43dfadd
doc: release note for #27826 2025-04-15 08:04:50 -04:00
Sjors Provoost f9fa28788e
Use LogBlockHeader for compact blocks
The only behavior change is that the block height is now added to the log message.
2025-04-15 08:04:50 -04:00
Sjors Provoost bad7c91479
Log which peer sent us a header
This also supports -logips.
2025-04-15 08:04:50 -04:00
Sjors Provoost 9d3e39c29c
Log block header in net_processing
Previously ChainstateManager::AcceptBlockHeader would log when it
saw a new header. This commit moves logging to the call site(s) in
net_processing. The next commits will then log which peer sent it
and whether it was part of a compact block.

This commit changes behavior:
- when multiple headers are received in a single message, only the
  last one is logged
- if any of the headers are invalid, the valid ones are not logged

This happens because net_processing calls ProcessNewBlockHeaders
with multiple headers, which then calls AcceptBlockHeader one
header at a time.

Additionally:
- when the header is received via a compact block, there's no more
  duplicate log (a later commit also unifies logging code paths)
2025-04-15 08:04:49 -04:00
merge-script cdc32994fe
Merge bitcoin/bitcoin#32272: [doc] archive 29.0 release notes
12dc507c4a [doc] archive 29.0 release notes (glozow)

Pull request description:

ACKs for top commit:
  achow101:
    ACK 12dc507c4a
  janb84:
    ACK [12dc507](12dc507c4a)

Tree-SHA512: 61aa6c1892d70c53ad4600d17dd8bc23bd181cff48aaa432272ce5dfb4f9b24e6f558629513ba731060b2748877f50b2731c3dc7f3fc437a76f9922a0d26c7cc
2025-04-15 11:07:52 +01:00
MarcoFalke faeb1babe2
ci: refactor: Use version id over version codename consistently
Also, remove the minor version from the comment, because it does not
matter and may even change at any time.
2025-04-15 09:43:59 +02:00
glozow 12dc507c4a [doc] archive 29.0 release notes 2025-04-14 21:02:18 -04:00
Ava Chow acee5c59e6 descriptors: Have GetPrivKey fill keys directly
Instead of GetPrivKey returning a key and having the caller fill the
FlatSigningProvider, have GetPrivKey take the FlatSigningProvider and
fill it by itself. This will be necessary for descriptors such as
musig() where there are private keys that need to be added to the
FlatSigningProvider but do not directly appear in any resulting scripts.

GetPrivKey is now changed to void as the caller no longer cares whether
it succeeds or fails.
2025-04-14 16:32:01 -07:00
Ava Chow 4b0303197e descriptors: Move FlatSigningProvider pubkey filling to GetPubKey
Instead of MakeScripts inconsistently filling the output
FlatSigningProvider with the pubkeys involved, just do it in GetPubKey.
2025-04-14 16:32:01 -07:00
Ava Chow 25a3b9b0f5 descriptors: Have GetPubKey fill origins directly
Instead of having ExpandHelper fill in the origins in the
FlatSigningProvider output, have GetPubKey do it by itself. This reduces
the extra variables needed in order to track and set origins in
ExpandHelper.

Also changes GetPubKey to return a std::optional<CPubKey> rather than
using a bool and output parameters.
2025-04-14 16:32:01 -07:00
Ava Chow 6268bde0af descriptor: Remove unused parent_info from BIP32PUbKeyProvider::GetPubKey 2025-04-14 16:32:01 -07:00
Ava Chow 0ff072caa1 wallet, rpc: Only allow keypool import from single key descriptors
Legacy wallets should only import keys to the keypool if they came in a
single key descriptor. Instead of relying on assumptions about the
descriptor based on how many pubkeys show up after expanding the
descriptor, explicitly mark descriptors as being single key type and use
that for the check.
2025-04-14 16:32:01 -07:00
Ava Chow 99a4ddf5ab
Merge bitcoin/bitcoin#31785: Have createNewBlock() wait for tip, make rpc handle shutdown during long poll and wait methods
05117e6e17 rpc: clarify longpoll behavior (Sjors Provoost)
5315278e7c Have createNewBlock() wait for a tip (Sjors Provoost)
64a2795fd4 rpc: handle shutdown during long poll and wait methods (Sjors Provoost)
a3bf43343f rpc: drop unneeded IsRPCRunning() guards (Sjors Provoost)
f9cf8bd0ab Handle negative timeout for waitTipChanged() (Sjors Provoost)

Pull request description:

  This PR prevents Mining interface methods from sometimes crashing when called during startup before a tip is connected. It also makes other improvements like making more RPC methods usable from the GUI. Specifically this PR:

  - Adds an `Assume` check to disallow passing negative timeout values to `Mining::waitTipChanged`
  - Makes `waitfornewblock`, `waitforblock` and `waitforblockheight` RPC methods usable from the GUI when `-server=1` is not set.
  - Changes `Mining::waitTipChanged` to return `optional<BlockRef>` instead of `BlockRef` and return `nullopt` instead of crashing if there is a timeout or if the node is shut down before a tip is connected.
  - Changes `Mining::waitTipChanged` to not time out before a tip is connected, so it is convenient and safe to call during startup, and only returns `nullopt` on early shutdowns.
  - Changes `Mining::createNewBlock` to block and wait for a tip to be connected if it is called on startup instead of crashing. Also documents that it will return null on early shutdowns.

  This allows `waitNext()` (added in https://github.com/bitcoin/bitcoin/pull/31283) to safely assume `TipBlock()` isn't `null`, not even during a scenario of early shutdown.

  Finally this PR clarifies long poll behaviour, mostly by adding code comments, but also through an early `break`.

ACKs for top commit:
  achow101:
    ACK 05117e6e17
  ryanofsky:
    Code review ACK 05117e6e17, just updated a commit message since last review
  TheCharlatan:
    ACK 05117e6e17
  vasild:
    ACK 05117e6e17

Tree-SHA512: 277c285a6e73dfff88fd379298190b264254996f98b93c91c062986ab35c2aa5e1fbfec4cd71d7b29dc2d68e33f252b5cfc501345f54939d6bd78599b71fec04
2025-04-14 14:39:57 -07:00
Ava Chow 22770ce8cb
Merge bitcoin/bitcoin#31282: refactor: Make node_id a const& in RemoveBlockRequest
fa21f83d29 ci: Use G++ in valgrind tasks (MarcoFalke)
fabd05bf65 refactor: Fix net_processing iwyu includes (MarcoFalke)
fa1622db20 refactor: Make node_id a const& in RemoveBlockRequest (MarcoFalke)

Pull request description:

  Currently, `valgrind` is not usable on a default build with GCC. Specifically, `p2p_compactblocks.py --valgrind` gives a false-positive in `RemoveBlockRequest` when comparing `node_id` with `from_peer`. According to the upstream bug report, this happens because both symbols are on the stack and the compiler can more aggressively optimize the compare (order). See https://bugs.kde.org/show_bug.cgi?id=472329#c7

  It is possible to work around this bug by pulling at least one value from the stack. For example, by making `from_peer` a `const` reference. Alternatively, by replacing `auto [node_id, list_it]` with `const auto& [node_id, list_it]`, which is done here.

  I think this workaround is acceptable, because it does not look like valgrind can trivially fix this. The alternative would be to add a (temporary?) suppression.

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

  Also, fix iwyu includes, while touching this module.

  Also, switch the CI valgrind scripts to use G++.

ACKs for top commit:
  achow101:
    ACK fa21f83d29
  TheCharlatan:
    ACK fa21f83d29
  darosior:
    utACK fa21f83d29
  ryanofsky:
    Code review ACK fa21f83d29. Code changes all look good but I'm a little confused about purpose of the third commit, so left a question about that

Tree-SHA512: 7b92cdafd525a5ac53ae2c1a7a92e599bc9b5fd5d315a694b493cd5079ac323d884393b57aa18581b7789247a588c9a27d47698de25b340bc76fc9f1dd1850b4
2025-04-14 14:22:56 -07:00
Ryan Ofsky 9ccee9cd02 doc: Document WITH_EXTERNAL_LIBMULTIPROCESS build option better
This includes a cmake documentation change suggested
https://github.com/bitcoin/bitcoin/pull/31741#discussion_r2039716492
and another change to mention the option in markdown documentation

Co-authored-by: Cory Fields <cory-nospam-@coryfields.com>
2025-04-14 16:32:37 -04:00
Lőrinc 8d801e3efb optimization: bulk serialization writes in `WriteBlockUndo` and `WriteBlock`
Similarly to the serialization reads optimization, buffered writes will enable batched XOR calculations.
This is especially beneficial since the current implementation requires copying the write input's `std::span` to perform obfuscation.
Batching allows us to apply XOR operations on the internal buffer instead, reducing unnecessary data copying and improving performance.

------

> macOS Sequoia 15.3.1
> C++ compiler .......................... Clang 19.1.7
> cmake -B build -DBUILD_BENCH=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ && cmake --build build -j$(nproc) && build/bin/bench_bitcoin -filter='WriteBlockBench' -min-time=10000

Before:

|               ns/op |                op/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|        5,149,564.31 |              194.19 |    0.8% |     10.95 | `WriteBlockBench`

After:

|               ns/op |                op/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|        2,990,564.63 |              334.39 |    1.5% |     11.27 | `WriteBlockBench`

------

> Ubuntu 24.04.2 LTS
> C++ compiler .......................... GNU 13.3.0
> cmake -B build -DBUILD_BENCH=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ && cmake --build build -j$(nproc) && build/bin/bench_bitcoin -filter='WriteBlockBench' -min-time=20000

Before:

|               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |         bra/op |   miss% |     total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
|        5,152,973.58 |              194.06 |    2.2% |   19,350,886.41 |    8,784,539.75 |  2.203 |   3,079,335.21 |    0.4% |     23.18 | `WriteBlockBench`

After:

|               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |         bra/op |   miss% |     total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
|        4,145,681.13 |              241.21 |    4.0% |   15,337,596.85 |    5,732,186.47 |  2.676 |   2,239,662.64 |    0.1% |     23.94 | `WriteBlockBench`

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
Co-authored-by: Cory Fields <cory-nospam-@coryfields.com>
2025-04-14 12:04:06 +02:00
Lőrinc 520965e293 optimization: bulk serialization reads in `UndoRead`, `ReadBlock`
The obfuscation (XOR) operations are currently done byte-by-byte during serialization. Buffering the reads will enable batching the obfuscation operations later.

Different operating systems handle file caching differently, so reading larger batches (and processing them from memory) is measurably faster, likely because of fewer native fread calls and reduced lock contention.

Note that `ReadRawBlock` doesn't need buffering since it already reads the whole block directly.
Unlike `ReadBlockUndo`, the new `ReadBlock` implementation delegates to `ReadRawBlock`, which uses more memory than a buffered alternative but results in slightly simpler code and a small performance increase (~0.4%). This approach also clearly documents that `ReadRawBlock` is a logical subset of `ReadBlock` functionality.

The current implementation, which iterates over a fixed-size buffer, provides a more general alternative to Cory Fields' solution of reading the entire block size in advance.

Buffer sizes were selected based on benchmarking to ensure the buffered reader produces performance similar to reading the whole block into memory. Smaller buffers were slower, while larger ones showed diminishing returns.

------

> macOS Sequoia 15.3.1
> C++ compiler .......................... Clang 19.1.7
> cmake -B build -DBUILD_BENCH=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ && cmake --build build -j$(nproc) && build/bin/bench_bitcoin -filter='ReadBlockBench' -min-time=10000

Before:

|               ns/op |                op/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|        2,271,441.67 |              440.25 |    0.1% |     11.00 | `ReadBlockBench`

After:

|               ns/op |                op/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|        1,738,971.29 |              575.05 |    0.2% |     10.97 | `ReadBlockBench`

------

> Ubuntu 24.04.2 LTS
> C++ compiler .......................... GNU 13.3.0
> cmake -B build -DBUILD_BENCH=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ && cmake --build build -j$(nproc) && build/bin/bench_bitcoin -filter='ReadBlockBench' -min-time=20000

Before:

|               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |         bra/op |   miss% |     total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
|        6,895,987.11 |              145.01 |    0.0% |   71,055,269.86 |   23,977,374.37 |  2.963 |   5,074,828.78 |    0.4% |     22.00 | `ReadBlockBench`

After:

|               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |         bra/op |   miss% |     total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
|        5,771,882.71 |              173.25 |    0.0% |   65,741,889.82 |   20,453,232.33 |  3.214 |   3,971,321.75 |    0.3% |     22.01 | `ReadBlockBench`

Co-authored-by: maflcko <6399679+maflcko@users.noreply.github.com>
Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
Co-authored-by: Martin Leitner-Ankerl <martin.ankerl@gmail.com>
Co-authored-by: Cory Fields <cory-nospam-@coryfields.com>
2025-04-14 12:04:06 +02:00
merge-script 5116655980
Merge bitcoin/bitcoin#32255: miniscript: Correct off-by-one assert guards (#31727 follow-up)
3693e4d6ee miniscript: Correct off-by-one assert guards (Hodlinator)

Pull request description:

  First instances discovered by darosior in https://github.com/bitcoin/bitcoin/pull/31727#issuecomment-2619342125.

ACKs for top commit:
  maflcko:
    lgtm ACK 3693e4d6ee
  sipa:
    ACK 3693e4d6ee
  l0rinc:
    Tested ACK 3693e4d6ee

Tree-SHA512: a41302bb9349d5ad2daf89431c67fdbe80f91690e1759d01529acd1b2fa5d99bad3383da684ee62c00584f7696cd3f87efff084c74edf52eb7cd88d60ee99829
2025-04-14 10:59:07 +01:00
Lőrinc 056cb3c0d2 refactor: clear up blockstorage/streams in preparation for optimization
Made every OpenBlockFile#fReadOnly value explicit.

Replaced hard-coded values in ReadRawBlock with STORAGE_HEADER_BYTES.
Changed `STORAGE_HEADER_BYTES` and `UNDO_DATA_DISK_OVERHEAD` to `uint32_t` to avoid casts.

Also added `LIFETIMEBOUND` to the `AutoFile` parameter of `BufferedFile`, which stores a reference to the underlying `AutoFile`, allowing Clang to emit warnings if the referenced `AutoFile` might be destroyed while `BufferedFile` still exists.
Without this attribute, code with lifetime violations wouldn't trigger compiler warnings.

Co-authored-by: maflcko <6399679+maflcko@users.noreply.github.com>
2025-04-14 11:57:14 +02:00
Lőrinc 67fcc64802 log: unify error messages for (read/write)[undo]block
Co-authored-by: maflcko <6399679+maflcko@users.noreply.github.com>
2025-04-13 23:44:46 +02:00
Lőrinc a4de160492 scripted-diff: shorten BLOCK_SERIALIZATION_HEADER_SIZE constant
Renames the constant to be less verbose and better reflect its purpose:
it represents the size of the storage header that precedes serialized block data on disk,
not to be confused with a block's own header.

-BEGIN VERIFY SCRIPT-
git grep -q "STORAGE_HEADER_BYTES" $(git ls-files) && echo "Error: Target name STORAGE_HEADER_BYTES already exists in the codebase" && exit 1
sed -i 's/BLOCK_SERIALIZATION_HEADER_SIZE/STORAGE_HEADER_BYTES/g' $(git grep -l 'BLOCK_SERIALIZATION_HEADER_SIZE')
-END VERIFY SCRIPT-
2025-04-13 23:44:46 +02:00
Lőrinc 6640dd52c9 Narrow scope of undofile write to avoid possible resource management issue
`AutoFile{OpenUndoFile(pos)}` was still in scope when `FlushUndoFile(pos.nFile)` was called, which could lead to file handle conflicts or other unexpected behavior.

Co-authored-by: Hodlinator <172445034+hodlinator@users.noreply.github.com>
Co-authored-by: maflcko <6399679+maflcko@users.noreply.github.com>
2025-04-13 23:44:46 +02:00
Lőrinc 3197155f91 refactor: collect block read operations into try block
Reorganized error handling in block-related operations by grouping related operations together within the same scope.

In `ReadBlockUndo()` and `ReadBlock()`, moved all deserialization operations, comments and checksum verification inside a single try/catch block for cleaner error handling.
In `WriteBlockUndo()`, consolidated hash calculation and data writing operations within a common block to better express their logical relationship.
2025-04-13 23:44:44 +02:00
Hodlinator 3693e4d6ee
miniscript: Correct off-by-one assert guards
Co-authored-by: Antoine Poinsot <darosior@protonmail.com>
2025-04-12 09:46:56 +02:00
merge-script 817edfb21e
Merge bitcoin/bitcoin#32245: doc: Updates how to reproduce fuzz CI failure locally
8fe001d597 doc: Updates how to reproduce fuzz CI failure locally (Sergi Delgado Segura)

Pull request description:

  The current version of the doc does not explain how to reproduce a recent fuzzing CI failure (not yet part of the corpora). Add instructions on how to manually create a crash file based on a report.

ACKs for top commit:
  maflcko:
    lgtm ACK 8fe001d597
  glozow:
    ACK 8fe001d597

Tree-SHA512: 7436d71a30bbbffc34770027f1deeacca2de528d8d1b333431d6070c2ba779ecfcdaf25dc791d2154ba4dd37824d06aed2695a8412d7ca1f29e5bd1796d42aeb
2025-04-11 16:34:41 -04:00
MarcoFalke fae322a43a
ci: Slim down lint image
Currently, the lint_test_runner is built and installed into the lint CI
image. This is problematic, because it triggers a full image build on
every change to its source code. Doing a build of the lint test_runner
on every run is easier and faster.
2025-04-11 18:56:46 +02:00
MarcoFalke 3333273a8f
ci: Bump lint imagefile FROM base
According to https://wiki.debian.org/DebianReleases#Production_Releases,
the current image will be EOL in about one year, so it seems fine to
slowly bump it to something more recent.
2025-04-11 18:55:57 +02:00
Pieter Wuille 2835216ec0 txgraph: make GroupClusters use partition numbers directly (optimization) 2025-04-11 10:43:56 -04:00
Pieter Wuille c72c8d5d45 txgraph: compare sequence numbers instead of Cluster* (bugfix)
This makes fuzz testing more deterministic, by avoiding the (arbitrary) pointer
value ordering in comparing transactions.
2025-04-11 10:43:34 -04:00
merge-script b2bb27f40c
Merge bitcoin/bitcoin#31741: multiprocess: Add libmultiprocess git subtree
babb9f5db6 depends: remove non-native libmultiprocess build (Cory Fields)
5d105fb8c3 depends: Switch libmultiprocess packages to use local git subtree (Ryan Ofsky)
9b35518d2f depends, moveonly: split up int_get_build_id function (Ryan Ofsky)
2d373e2707 lint: Add exclusions for libmultiprocess subtree (Ryan Ofsky)
e88ab394c1 doc: Update documentation to explain libmultiprocess subtree (Ryan Ofsky)
d4bc563982 cmake: Fix clang-tidy "no input files" errors (Ryan Ofsky)
abdf3cb645 cmake: Fix warnings from boost headers (Ryan Ofsky)
8532fcb1c3 cmake: Fix ctest mptest "Unable to find executable" errors (Ryan Ofsky)
d597ab1dee cmake: Support building with libmultiprocess subtree (Ryan Ofsky)
69f0d4adb7 scripted-diff: s/WITH_MULTIPROCESS/ENABLE_IPC/ in cmake (Ryan Ofsky)
a2f28e4be9 Squashed 'src/ipc/libmultiprocess/' content from commit 35944ffd23fa (Ryan Ofsky)
d6244f85c5 depends: Update libmultiprocess library to simplify cmake subtree build (Ryan Ofsky)

Pull request description:

  This adds the [libmultiprocess](https://github.com/chaincodelabs/libmultiprocess) library and code generator as a subtree in `src/ipc/libmultiprocess` and allows it to be built with the cmake `-DENABLE_IPC` option, which is disabled by default.

  This PR does not entirely remove the depends system [libmultiprocess package](https://github.com/bitcoin/bitcoin/blob/master/depends/packages/native_libmultiprocess.mk) because the package is useful when cross compiling. (A cross-compiling cmake build cannot easily build and run a native code generation tool.) However, it does update the depends package to build from the new git subtree, instead of being downloaded separately from github, so the same sources are used to build both the runtime library and the code generator.

  This PR includes the following manual changes (not created automatically with `git subtree add`) which just update the build system and documentation:

  - [`d6244f85c509` depends: Update libmultiprocess library to simplify cmake subtree build](d6244f85c5)
  - [`69f0d4adb72c` scripted-diff: s/WITH_MULTIPROCESS/ENABLE_IPC/ in cmake](69f0d4adb7)
  - [`d597ab1dee6b` cmake: Support building with libmultiprocess subtree](d597ab1dee)
  - [`8532fcb1c30d` cmake: Fix ctest mptest "Unable to find executable" errors](8532fcb1c3)
  - [`abdf3cb6456f` cmake: Fix warnings from boost headers](abdf3cb645)
  - [`d4bc5639829f` cmake: Fix clang-tidy "no input files" errors](d4bc563982)
  - [`e88ab394c163` doc: Update documentation to explain libmultiprocess subtree](e88ab394c1)
  - [`2d373e27071f` lint: Add exclusions for libmultiprocess subtree](2d373e2707)
  - [`9b35518d2f3f` depends, moveonly: split up int_get_build_id function](9b35518d2f)
  - [`5d105fb8c3ff` depends: Switch libmultiprocess packages to use local git subtree](5d105fb8c3)
  - [`babb9f5db641` depends: remove non-native libmultiprocess build](babb9f5db6)

  ---

  Previous minisketch subtree PR #23114 may be useful for comparison

  Instructions for subtree verification can be found:

  - https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#subtrees
  - https://github.com/bitcoin/bitcoin/tree/master/test/lint#git-subtree-checksh

  TL&DR:

  ```sh
  git remote add --fetch libmultiprocess https://github.com/chaincodelabs/libmultiprocess.git
  test/lint/git-subtree-check.sh -r src/ipc/libmultiprocess
  ```

  ---

  This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/issues/28722).

ACKs for top commit:
  Sjors:
    re-ACK babb9f5db6
  TheCharlatan:
    tACK babb9f5db6
  vasild:
    ACK babb9f5db6

Tree-SHA512: 43d4eecca5aab63e55c613de935965666eaced327f9fe859a0e9c9b85f7685dc16c5c8d6e03e09ca998628c5d468633f4f743529930b037049abe8e0101e0143
2025-04-11 13:40:31 +01:00
laanwj 7749d929a0 Remove support for RNDR/RNDRRS for aarch64 on Linux
This hardware feature is

- rarely supported on SoCs (and broken on like half of the chips that support it in the first place) (#31817)
- apparently not compiled into the release binary (https://github.com/bitcoin/bitcoin/issues/31817#issuecomment-2795885962)
- hard to test in CI, due to unavailable of hardware

Better to remove it.

This reverts commit aee5404e02.

Closes #31817.
2025-04-11 08:11:41 +02:00
merge-script a4fd565191
Merge bitcoin/bitcoin#31727: miniscript: convert non-critical asserts to CHECK_NONFATAL
ff0194a7ce miniscript: convert non-critical asserts to CHECK_NONFATAL (Antoine Poinsot)

Pull request description:

  The Miniscript code contains assertions to prevent ending up in an insane state or prevent UB, but also to enforce logical invariants. For the latter it is not necessary to crash the program if they are broken. Raising an exception suffices, especially as this code is often called through the RPC interface which can in turn handle the exception and the user can report it to developers.

  This revives #28678 from Pieter Wuille.

ACKs for top commit:
  hodlinator:
    ACK ff0194a7ce
  TheCharlatan:
    ACK ff0194a7ce
  brunoerg:
    code review ACK ff0194a7ce

Tree-SHA512: 8ed8f7b494e46ecf7cdebe75120cd0ffe543b6bc289bf882dac631fe2ec2cae590d5f7bc2316e52db085791694b136dffbc71c40c1e16886fa53ab00bd8cabd0
2025-04-10 14:06:21 -04:00
merge-script e364e6b509
Merge bitcoin/bitcoin#32176: net: Prevent accidental circuit sharing when using Tor stream isolation
ec81a72b36 net: Add randomized prefix to Tor stream isolation credentials (laanwj)
c47f81e8ac net: Rename `_randomize_credentials` Proxy parameter to `tor_stream_isolation` (laanwj)

Pull request description:

  Add a class TorsStreamIsolationCredentialsGenerator that generates unique credentials based on a randomly generated session prefix and an atomic counter. Use this in `ConnectThroughProxy` instead of a simple atomic int counter.

  This makes sure that different launches of the application won't share the same credentials, and thus circuits, even in edge cases.

  Example with `-debug=proxy`:
  ```
  2025-03-31T16:30:27Z [proxy] SOCKS5 sending proxy authentication 0afb2da441f5c105-0:0afb2da441f5c105-0
  2025-03-31T16:30:31Z [proxy] SOCKS5 sending proxy authentication 0afb2da441f5c105-1:0afb2da441f5c105-1
  ```

  Thanks to hodlinator in https://github.com/bitcoin/bitcoin/pull/32166#discussion_r2020973352 for the idea.

ACKs for top commit:
  hodlinator:
    re-ACK ec81a72b36
  jonatack:
    ACK ec81a72b36
  danielabrozzoni:
    tACK ec81a72b36

Tree-SHA512: 195f5885fade77545977b91bdc41394234ae575679cb61631341df443fd8482cd74650104e323c7dbfff7826b10ad61692cca1284d6810f84500a3488f46597a
2025-04-10 12:42:34 -04:00
Sergi Delgado Segura 8fe001d597 doc: Updates how to reproduce fuzz CI failure locally
The current version of the doc does not explain how to reproduce a recent fuzzing CI failure
(not yet part of the corpora). Add instructions on how to manually create a crash file based
on a report.
2025-04-10 11:10:41 -04:00
glozow c58ae197a3
Merge bitcoin/bitcoin#32198: fuzz: Make p2p_headers_presync more deterministic
faa3ce3199 fuzz: Avoid influence on the global RNG from peerman m_rng (MarcoFalke)
faf4c1b6fc fuzz: Disable unused validation interface and scheduler in p2p_headers_presync (MarcoFalke)
fafaca6cbc fuzz: Avoid setting the mock-time twice (MarcoFalke)
fad22149f4 refactor: Use MockableSteadyClock in ReportHeadersPresync (MarcoFalke)
fa9c38794e test: Introduce MockableSteadyClock::mock_time_point and ElapseSteady helper (MarcoFalke)
faf2d512c5 fuzz: Move global node id counter along with other global state (MarcoFalke)
fa98455e4b fuzz: Set ignore_incoming_txs in p2p_headers_presync (MarcoFalke)
faf2e238fb fuzz: Shuffle files before testing them (MarcoFalke)

Pull request description:

  This should make the `p2p_headers_presync` fuzz target more deterministic.

  Tracking issue: https://github.com/bitcoin/bitcoin/issues/29018.

  The first commits adds an `ElapseSteady` helper and type aliases. The second commit uses those helpers in `ReportHeadersPresync` and in the fuzz target to increase determinism.

  ### Testing

  It can be tested via (setting 32 parallel threads):

  ```
  cargo run --manifest-path ./contrib/devtools/deterministic-fuzz-coverage/Cargo.toml -- $PWD/bld-cmake/ $PWD/../b-c-qa-assets/fuzz_corpora/ p2p_headers_presync 32
  ```

  The failing diff is contained in the commit messages, if applicable.

ACKs for top commit:
  Crypt-iQ:
    tACK faa3ce3199
  janb84:
    Re-ACK [faa3ce3](faa3ce3199)
  marcofleon:
    ACK faa3ce3199

Tree-SHA512: 7e2e0ddf3b4e818300373d6906384df57a87f1eeb507fa43de1ba88cf03c8e6752a26b6e91bfb3ee26a21efcaf1d0d9eaf70d311d1637b671965ef4cb96e6b59
2025-04-10 11:08:11 -04:00
Hennadii Stepanov e1dfa4faeb
Merge bitcoin/bitcoin#32237: qt: Update SetHexDeprecated to FromHex
868816d962 refactor: Remove SetHexDeprecated (marcofleon)
6b63218ec2 qt: Update SetHexDeprecated to FromHex (marcofleon)

Pull request description:

  This is part of https://github.com/bitcoin/bitcoin/pull/32189. I'm separating this out because it's not immediately obvious that it's just a refactor. `SetHexDeprecated()` doesn't do any correctness checks on the input, while `FromHex()` does, so it's theoretically possible that there's a behavior change.

  Replaces `uint256::SetHexDeprecated()` calls with `Txid::FromHex()` in four locations:
  - `TransactionTableModel::updateTransaction`
  - `TransactionView::contextualMenu`
  - `TransactionView::abandonTx`
  - `TransactionView::bumpFee`

  The input strings in these cases aren't user input, so they should only be valid hex strings from `GetHex()` (through `TransactionRecord::getTxHash()`). These conversions should be safe without additional checks.

ACKs for top commit:
  laanwj:
    Code review ACK 868816d962
  w0xlt:
    Code review ACK 868816d962
  BrandonOdiwuor:
    Code Review ACK 868816d962
  TheCharlatan:
    ACK 868816d962
  hebasto:
    ACK 868816d962, I have reviewed the code and it looks OK.

Tree-SHA512: 121f149dcc7358231d0327cb3212ec96486a88410174d3c74ab8cbd61bad35185bc0a9740d534492b714811f72a6736bc7ac6eeae590c0ea1365c61cc791da37
2025-04-10 12:30:14 +01:00
Ava Chow b8cefeb221
Merge bitcoin/bitcoin#32149: wallet, migration: Fix empty wallet crash
0f602c5693 wallet, migration: Fix crash on empty wallet (pablomartin4btc)
42c13141b5 wallet, refactor: Decouple into HasLegacyRecords() (pablomartin4btc)

Pull request description:

  Same as with a blank wallet (#28976), wallets with no legacy records (i.e. empty, non-blank, watch-only wallet) do not require to be migrated.

  Steps to reproduce the issue:

  1.- `createwallet "empty_wo_noblank_legacy_wallet" true false "" false false`
  2.- `migratewallet`

  ```
  wallet/wallet.cpp:4071 GetDescriptorsForLegacy: Assertion `legacy_spkm' failed.
  Aborted (core dumped)
  ```

ACKs for top commit:
  davidgumberg:
    untested reACK 0f602c5693
  fjahr:
    re-ACK 0f602c5693
  achow101:
    ACK 0f602c5693
  furszy:
    ACK 0f602c5693
  BrandonOdiwuor:
    Code Review ACK 0f602c5693

Tree-SHA512: 796c3f0b1946281097f7ffc3563bc79f879e80a98237012535cc530a4a2239fd2d71a17b4f54e30258886dc9f0b83206d7a5d50312e4fc6d0abe4f559fbe07ec
2025-04-09 17:50:48 -07:00
glozow 874da961d0
Merge bitcoin/bitcoin#32240: feefrac test: avoid integer overflow (bugfix)
a2bc330da8 feefrac test: avoid integer overflow (bugfix) (Pieter Wuille)

Pull request description:

  The `feefrac_mul_div` fuzz test fails after #30535 with the following (base64) input: `Nb6Fc/97AACAAAD/ewAAgAAAAIAAAACAAAAAoA==` (see https://cirrus-ci.com/task/5240029192126464?logs=ci#L3353).

  This is caused by an internal multiplication inside `CFeeRate` that *just* exceeds the limit of the `int64_t` type. Fix that by tightening the bounds slightly further.

ACKs for top commit:
  sr-gi:
    utACK a2bc330da8
  instagibbs:
    ACK a2bc330da8
  glozow:
    ACK a2bc330da8, was able to reproduce + verify this fix

Tree-SHA512: cfbcdc8becfd518f4349ddc00c9af3ed0a23bb9534af71cc21df167d7038e5967127e5d97c4b3e8aeff6bf071c4f630c32ffaf81d8ec227954d21fdcbe205333
2025-04-09 14:26:55 -04:00
MarcoFalke faa3ce3199
fuzz: Avoid influence on the global RNG from peerman m_rng
This should avoid the remaining non-determistic code coverage paths.

Without this patch, the tool would report a diff (only when running
without libFuzzer):

cargo run --manifest-path ./contrib/devtools/deterministic-fuzz-coverage/Cargo.toml -- $PWD/bld-cmake/ $PWD/../qa-assets/fuzz_corpora/ p2p_headers_presync 32
2025-04-09 20:06:56 +02:00
MarcoFalke faf4c1b6fc
fuzz: Disable unused validation interface and scheduler in p2p_headers_presync
This may also avoid non-determinism in the scheduler thread.
2025-04-09 20:05:56 +02:00
MarcoFalke fafaca6cbc
fuzz: Avoid setting the mock-time twice
It should be sufficient to set it once. Especially, if the dynamic value
is only used by ResetAndInitialize.

This also avoids non-determistic code paths, when ResetAndInitialize may
re-initialize m_next_inv_to_inbounds.

Without this patch, the tool would report a diff:

cargo run --manifest-path ./contrib/devtools/deterministic-fuzz-coverage/Cargo.toml -- $PWD/bld-cmake/ $PWD/../qa-assets/fuzz_corpora/ p2p_headers_presync 32

...
- 1126|      3|        m_next_inv_to_inbounds = now + m_rng.rand_exp_duration(average_interval);
- 1127|      3|    }
+ 1126|     10|        m_next_inv_to_inbounds = now + m_rng.rand_exp_duration(average_interval);
+ 1127|     10|    }
  1128|    491|    return m_next_inv_to_inbounds;
...
2025-04-09 20:05:39 +02:00
MarcoFalke fad22149f4
refactor: Use MockableSteadyClock in ReportHeadersPresync
This allows the clock to be mockable in tests. Also, replace cs_main
with GetMutex() while touching this function.

Also, use the ElapseSteady test helper in the p2p_headers_presync fuzz
target to make it more deterministic.

The m_last_presync_update variable is a global that is not reset in
ResetAndInitialize. However, it is only used for logging, so completely
disable it for now.

Without this patch, the tool would report a diff:

cargo run --manifest-path ./contrib/devtools/deterministic-fuzz-coverage/Cargo.toml -- $PWD/bld-cmake/ $PWD/../qa-assets/fuzz_corpora/ p2p_headers_presync 32

...
  4468|     81|        auto now = std::chrono::steady_clock::now();
  4469|     81|        if (now < m_last_presync_update + std::chrono::milliseconds{250}) return;
-                                                                                        ^80
+                                                                                        ^79
...
2025-04-09 20:05:36 +02:00
MarcoFalke fa9c38794e
test: Introduce MockableSteadyClock::mock_time_point and ElapseSteady helper
This refactor clarifies that the MockableSteadyClock::mock_time_point
has millisecond precision by defining a type an using it.

Moreover, a ElapseSteady helper is added which can be re-used easily.
2025-04-09 20:05:17 +02:00
MarcoFalke faf2d512c5
fuzz: Move global node id counter along with other global state
The global m_headers_presync_stats is not reset in ResetAndInitialize.
This may lead to non-determinism.

Fix it by incrementing the global node id counter instead.

Without this patch, the tool would report a diff:

cargo run --manifest-path ./contrib/devtools/deterministic-fuzz-coverage/Cargo.toml -- $PWD/bld-cmake/ $PWD/../qa-assets/fuzz_corpora/ p2p_headers_presync 32

...
  2587|  3.73k|            if (best_it == m_headers_presync_stats.end()) {
   ------------------
-  |  Branch (2587:17): [True: 80, False: 3.65k]
+  |  Branch (2587:17): [True: 73, False: 3.66k]
   ------------------
...
2025-04-09 20:04:49 +02:00
MarcoFalke fa98455e4b
fuzz: Set ignore_incoming_txs in p2p_headers_presync
This avoids non-determistic code paths.

Without this patch, the tool would report a diff:

cargo run --manifest-path ./contrib/devtools/deterministic-fuzz-coverage/Cargo.toml -- $PWD/bld-cmake/ $PWD/../qa-assets/fuzz_corpora/ p2p_headers_presync 32

...
- 5371|    393|        peer.m_next_send_feefilter = current_time + m_rng.randrange<std::chrono::microseconds>(MAX_FEEFILTER_CHANGE_DELAY);
- 5372|    393|    }
+ 5371|    396|        peer.m_next_send_feefilter = current_time + m_rng.randrange<std::chrono::microseconds>(MAX_FEEFILTER_CHANGE_DELAY);
+ 5372|    396|    }
  5373|  16.2k|}
...
2025-04-09 20:04:46 +02:00
MarcoFalke faf2e238fb
fuzz: Shuffle files before testing them
When iterating over all fuzz input files in a folder, the order should
not matter.

However, shuffling may be useful to detect non-determinism.

Thus, shuffle in fuzz.cpp, when using neither libFuzzer, nor AFL.

Also, shuffle in the deterministic-fuzz-coverage tool, when using
libFuzzer.
2025-04-09 20:04:38 +02:00
marcofleon 868816d962 refactor: Remove SetHexDeprecated
After replacing all instances of `SetHexDeprecated` in the GUI,
remove it entirely and reimplement the behavior in `FromHex`.
2025-04-09 15:59:59 +01:00
marcofleon 6b63218ec2 qt: Update SetHexDeprecated to FromHex
Replace `uint256::SetHexDeprecated()` calls with `Txid::FromHex()`
in four locations:
- TransactionTableModel::updateTransaction
- TransactionView::contextualMenu
- TransactionView::abandonTx
- TransactionView::bumpFee

The input strings are generally expected to be valid hex strings
from `GetHex()`. However, due to the potentially unpredictable return
value of `.data(TransactionTableModel::TxHashRole)`, check the
`Txid::FromHex` result in `contextualMenu` and return early if the
transaction hash is invalid. The other two functions, `abandonTx`
and `bumpFee` will only be called if the context menu is enabled.
2025-04-09 15:32:14 +01:00
Ryan Ofsky bb92bb36f2
Merge bitcoin/bitcoin#32206: doc: Add fuzz based coverage report generation
7677fde4c7 Add fuzz test coverage report generation (Prabhat Verma)

Pull request description:

  Followup from [comment 1 31933](https://github.com/bitcoin/bitcoin/pull/31933#pullrequestreview-2685168897) and [comment 2 31933](https://github.com/bitcoin/bitcoin/pull/31933#pullrequestreview-2683653107) , have added the instructions to generate coverage report for fuzz tests.

ACKs for top commit:
  maflcko:
    lgtm ACK 7677fde4c7
  mabu44:
    Tested ACK 7677fde4c7

Tree-SHA512: b4883ec41e272443fc9fc97dce3fb0f05871ce5ddc07d97f4cf7e1d28506dc892324b42005387a2f5a844b27827785a68d10881067414fe93fd4fbb9645f765d
2025-04-08 17:26:54 -04:00
Ryan Ofsky 021b4f72db
Merge bitcoin/bitcoin#32216: bench: Match ConnectBlock tx output counts
924f25f6fc bench: Match ConnectBlock tx output counts (monlovesmango)

Pull request description:

  There turned out to be a mismatch in the tx output counts which caused 'ConnectBlockMixedEcdsaSchnorr' benchmark to run slower than 'ConnectBlockAllEcdsa' and 'ConnectBlockAllSchnorr'. This commit makes the tx output counts uniform across all benchmarks.

  This commit also renames the 'taproot_tx' variable to 'tx' to reflect that this variable represents a general tx and not just a taproot tx.

ACKs for top commit:
  davidgumberg:
    Tested ACK 924f25f6fc
  Prabhat1308:
    reACK [`924f25f`](924f25f6fc)
  janb84:
    re ACK [924f25f](924f25f6fc)
  josibake:
    ACK 924f25f6fc

Tree-SHA512: bbf33e0c31b0c46571fd5d6ecd32426e7e823f9e156fd3d39a975bd5f0c1b6cd3dda55fa869cb0954c68dcf28cf4d0a0af40a72e440c1c78380b5b98e1eb6615
2025-04-08 17:14:59 -04:00
Ryan Ofsky ff5b7b0b0a
Merge bitcoin/bitcoin#32214: test: Remove fragile and ancient release 0.17 wallet test
fac978fb21 test: Remove fragile and ancient release 0.17 wallet test (MarcoFalke)

Pull request description:

  The test checks that the 0.17 wallet rejects wallet files created in "the future".

  This is nice, and good to know. However,

  * The 0.17 release is ancient and should be unused outside of tests, especially to load future wallets.
  * The test intermittently fails, due to ancient RPC server bugs, that were fixed in the meantime. [1]
  * Albeit they are not identical, the 0.18 release is still checked in this test, so any theoretical bug that would be caught by 0.17 is hopefully still caught by 0.18 as well.

  So fix all issues by removing the test case.

  [1] For example from https://api.cirrus-ci.com/v1/task/6161588714995712/logs/ci.log:

  ```
  190/321 - [1mwallet_backwards_compatibility.py --descriptors[0m failed, Duration: 23 s
  [17:21:40.700]
  [17:21:40.700] [1mstdout:
  [17:21:40.700] [0m2025-04-02T21:21:16.575000Z TestFramework (INFO): PRNG seed is: 5772716217847090743
  [17:21:40.700] 2025-04-02T21:21:16.580000Z TestFramework (INFO): Initializing test directory /ci_container_base/ci/scratch/test_runner/test_runner_₿_🏃_20250402_210134/wallet_backwards_compatibility_134
  [17:21:40.700] 2025-04-02T21:21:26.378000Z TestFramework (INFO): Test wallet backwards compatibility...
  [17:21:40.700] 2025-04-02T21:21:33.191000Z TestFramework (INFO): Testing 0.19 addmultisigaddress case (#18075)
  [17:21:40.700] 2025-04-02T21:21:33.637000Z TestFramework (INFO): Test that a wallet made on master can be opened on:
  [17:21:40.700] 2025-04-02T21:21:33.637000Z TestFramework (INFO): - 250000
  [17:21:40.700] 2025-04-02T21:21:34.055000Z TestFramework (INFO): - 240001
  [17:21:40.700] 2025-04-02T21:21:34.435000Z TestFramework (INFO): - 230000
  [17:21:40.700] 2025-04-02T21:21:34.858000Z TestFramework (INFO): - 220000
  [17:21:40.700] 2025-04-02T21:21:35.614000Z TestFramework (INFO): - 210000
  [17:21:40.700] 2025-04-02T21:21:35.707000Z TestFramework (INFO): Test descriptor wallet incompatibility on:
  [17:21:40.700] 2025-04-02T21:21:35.707000Z TestFramework (INFO): - 200100
  [17:21:40.700] 2025-04-02T21:21:35.878000Z TestFramework (INFO): - 190100
  [17:21:40.700] 2025-04-02T21:21:36.021000Z TestFramework (INFO): - 180100
  [17:21:40.700] 2025-04-02T21:21:36.319000Z TestFramework (INFO): Test descriptor wallet incompatibility with 0.17
  [17:21:40.700] 2025-04-02T21:21:37.328000Z TestFramework (INFO): Test that 0.21 cannot open wallet containing tr() descriptors
  [17:21:40.700] 2025-04-02T21:21:37.356000Z TestFramework (INFO): Test that a wallet can upgrade to and downgrade from master, from:
  [17:21:40.700] 2025-04-02T21:21:37.361000Z TestFramework (INFO): - 250000
  [17:21:40.700] 2025-04-02T21:21:37.665000Z TestFramework (INFO): - 240001
  [17:21:40.700] 2025-04-02T21:21:37.970000Z TestFramework (INFO): - 230000
  [17:21:40.700] 2025-04-02T21:21:38.439000Z TestFramework (INFO): - 220000
  [17:21:40.700] 2025-04-02T21:21:38.793000Z TestFramework (INFO): - 210000
  [17:21:40.700] 2025-04-02T21:21:39.470000Z TestFramework (INFO): Stopping nodes
  [17:21:40.700]
  [17:21:40.700]
  [17:21:40.700] [1mstderr:
  [17:21:40.700] [0mTraceback (most recent call last):
  [17:21:40.700]   File "/ci_container_base/ci/scratch/build-x86_64-pc-linux-gnu/test/functional/wallet_backwards_compatibility.py", line 389, in <module>
  [17:21:40.700]     BackwardsCompatibilityTest(__file__).main()
  [17:21:40.700]   File "/ci_container_base/test/functional/test_framework/test_framework.py", line 206, in main
  [17:21:40.700]     exit_code = self.shutdown()
  [17:21:40.700]   File "/ci_container_base/test/functional/test_framework/test_framework.py", line 379, in shutdown
  [17:21:40.700]     self.stop_nodes()
  [17:21:40.700]   File "/ci_container_base/test/functional/test_framework/test_framework.py", line 643, in stop_nodes
  [17:21:40.700]     node.stop_node(wait=wait, wait_until_stopped=False)
  [17:21:40.700]   File "/ci_container_base/test/functional/test_framework/test_node.py", line 397, in stop_node
  [17:21:40.700]     self.stop()
  [17:21:40.700]   File "/ci_container_base/test/functional/test_framework/coverage.py", line 50, in __call__
  [17:21:40.700]     return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
  [17:21:40.700]   File "/ci_container_base/test/functional/test_framework/authproxy.py", line 132, in __call__
  [17:21:40.700]     response, status = self._request('POST', self.__url.path, postdata.encode('utf-8'))
  [17:21:40.700]   File "/ci_container_base/test/functional/test_framework/authproxy.py", line 106, in _request
  [17:21:40.700]     return self._get_response()
  [17:21:40.700]   File "/ci_container_base/test/functional/test_framework/authproxy.py", line 169, in _get_response
  [17:21:40.700]     http_response = self.__conn.getresponse()
  [17:21:40.700]   File "/usr/lib/python3.10/http/client.py", line 1375, in getresponse
  [17:21:40.700]     response.begin()
  [17:21:40.700]   File "/usr/lib/python3.10/http/client.py", line 318, in begin
  [17:21:40.700]     version, status, reason = self._read_status()
  [17:21:40.700]   File "/usr/lib/python3.10/http/client.py", line 287, in _read_status
  [17:21:40.700]     raise RemoteDisconnected("Remote end closed connection without"
  [17:21:40.700] http.client.RemoteDisconnected: Remote end closed connection without response
  [17:21:40.700] [node 10] Cleaning up leftover process
  [17:21:40.700] [node 9] Cleaning up leftover process
  [17:21:40.700] [node 8] Cleaning up leftover process
  [17:21:40.700] [node 7] Cleaning up leftover process
  [17:21:40.700] [node 6] Cleaning up leftover process
  [17:21:40.700] [node 5] Cleaning up leftover process
  [17:21:40.700] [node 4] Cleaning up leftover process
  [17:21:40.700] [node 3] Cleaning up leftover process
  [17:21:40.700] [node 2] Cleaning up leftover process
  [17:21:40.700] [node 1] Cleaning up leftover process
  [17:21:40.700] [node 0] Cleaning up leftover process

ACKs for top commit:
  laanwj:
    Code review ACK fac978fb21
  janb84:
    Re ACK [fac978f](fac978fb21)
  pablomartin4btc:
    re ACK fac978fb21
  BrandonOdiwuor:
    Code Review ACK fac978fb21

Tree-SHA512: 13acdfc6be4293a0ff45ae20b26ba60636e130097da380b7b51716faaa950320462399bef55e74b3cedc82944586dcc1bfd078babb96edb03c4efdb8f40af5a4
2025-04-08 17:03:48 -04:00
Ryan Ofsky 873a45fba0
Merge bitcoin/bitcoin#32200: net: Add Tor extended SOCKS5 error codes
b639417b39 net: Add Tor extended SOCKS5 error codes (laanwj)

Pull request description:

  Add support for reporting Tor extended SOCKS5 error codes as defined here:

  - https://spec.torproject.org/socks-extensions.html#extended-error-codes
  - https://gitlab.torproject.org/tpo/core/arti/-/blob/main/crates/tor-socksproto/src/msg.rs?ref_type=heads#L183

  These give a more direct indication of the problem in case of errors connecting to hidden services, for example:
  ```
  2025-04-02T10:34:13Z [net] Socks5() connect to [elided].onion:8333 failed: onion service descriptor can not be found
  ```

  In the C Tor implementation, to get these one should set the "ExtendedErrors" flag on the "SocksPort" definition, introduced in version 0.4.3.1.

  In Arti, extended error codes are always enabled.

  Also, report the raw error code in case of unknown reply values.

ACKs for top commit:
  1440000bytes:
    utACK b639417b39
  w0xlt:
    utACK b639417b39
  pablomartin4btc:
    utACK b639417b39

Tree-SHA512: b30e65cb0f5c9183701373b0ee64cdec40680a3de1a1a365b006538c4d0b7ca8a047d7c6f81a7f5b8a36bae3a20b47a4c2a9850423c7034866e3837fa8fdbfe2
2025-04-08 16:57:41 -04:00
Ryan Ofsky 8d2ead2a86
Merge bitcoin/bitcoin#32185: coins: replace manual `CDBBatch` size estimation with LevelDB's native `ApproximateSize`
e419b0e17f refactor: Remove manual CDBBatch size estimation (Lőrinc)
8b5e19d8b5 refactor: Delegate to LevelDB for CDBBatch size estimation (Lőrinc)
751077c6e2 Coins: Add `kHeader` to `CDBBatch::size_estimate` (Lőrinc)

Pull request description:

  ### Summary

  The manual batch size estimation of `CDBBatch` serialized size was [added](e66dbde6d1) when LevelDB [didn't expose this functionality  yet](https://github.com/google/leveldb/commit/69e2bd2).
  The PR refactors the logic to use the native `leveldb::WriteBatch::ApproximateSize()` function, structured in 3 focused commits to incrementally replace the old behavior safely.

  ### Context

  The previous manual size calculation initialized the estimate to 0, instead of LevelDB's header size (containing an 8-byte sequence number followed by a 4-byte count).
  This PR corrects that and transitions to the now-available native LevelDB function for improved accuracy and maintainability.

  ### Approach
  The fix and refactor follow a strangle pattern over three commits:
  * correct the initialization bug in the existing manual calculation, isolating the fix and ensuring the subsequent assertions use the corrected logic;
  * introduce the native `ApproximateSize()` method alongside the corrected manual one, adding assertions to verify their equivalence at runtime;
  * remove the verified manual calculation logic and assertions, leaving only the native method.

ACKs for top commit:
  sipa:
    utACK e419b0e17f
  TheCharlatan:
    ACK e419b0e17f
  laanwj:
    Code review ACK e419b0e17f

Tree-SHA512: a12b973dd480d4ffec4ec89a119bf0b6f73bde4e634329d6e4cc3454b867f2faf3742b78ec4a3b6d98ac4fb28fb2174f44ede42d6c701ed871987a7274560691
2025-04-08 16:20:00 -04:00
Ryan Ofsky ad0eee5492
Merge bitcoin/bitcoin#32139: test: remove strict restrictions on rpc_deprecated test
459807d566 test: remove strict restrictions on rpc_deprecated (Pol Espinasa)

Pull request description:

  Removed the wallet restrictions for `rpc_deprecated.py` and added specific test case for the current deprecated rpc.
  `skip_test_if_missing_module` will skip the whole test when the wallet is missing, even if a part of the test is non-wallet related. This PR ensures that other tests not related to wallet can be ran and only this specific test will be skipped if there's no wallet

  For more context check https://github.com/bitcoin/bitcoin/pull/31278#discussion_r2011661090

ACKs for top commit:
  maflcko:
    lgtm ACK 459807d566
  rkrux:
    ACK 459807d

Tree-SHA512: 922b0fafe8fb5bd88a677ce8be5c3fe2fdd4d0aadcd32cc11738a714cd6f765f07e7e7158c829f8338db0d46a15c030437a1ea09a3187c072bebebb4ca53ad85
2025-04-08 15:41:48 -04:00
Pieter Wuille a2bc330da8 feefrac test: avoid integer overflow (bugfix) 2025-04-08 15:18:03 -04:00
Ryan Ofsky 24d5033a62
Merge bitcoin/bitcoin#32114: test: Add encodable PUSHDATA1 examples to feature_taproot
f974359e21 test: Add encodable PUSHDATA1 examples to feature_taproot (Greg Sanders)

Pull request description:

  Inspired by discussion in https://github.com/bitcoin/bitcoin/pull/31640#issuecomment-2743492906 I made an example adding coverage I think is missing, with some extra commentary that might help future contributors (including myself when I forget how it works again).

  Open for suggestions how we can make it more welcoming beyond this.

  cc darosior EthanHeilman sipa

ACKs for top commit:
  janb84:
    Re-ACK [f974359](f974359e21)
  rkrux:
    ACK f974359e21

Tree-SHA512: 7544d41c39c13d245a8a33522e53f22b4dd7593c069631978303e5a349cd12cf9d45bed648c391618c4732831232c4b82b8de2bf6cba5bf5e1232501db926122
2025-04-08 15:08:52 -04:00
merge-script cfe025ff0e
Merge bitcoin/bitcoin#30535: feefrac: add support for evaluating at given size
58914ab459 fuzz: assert min diff between FeeFrac and CFeeRate (Pieter Wuille)
0c6bcfd8f7 feefrac: support both rounding up and down for Evaluate (Pieter Wuille)
ecf956ec9d feefrac: add support for evaluating at given size (Pieter Wuille)
7963aecead feefrac: add helper functions for 96-bit division (Pieter Wuille)
800c0dea9a feefrac: rework comments around Mul/MulFallback (Pieter Wuille)
fcfe008db2 feefrac fuzz: use arith_uint256 instead of ad-hoc multiply (Pieter Wuille)
46ff4220bf arith_uint256: modernize comparison operators (Pieter Wuille)

Pull request description:

  The `FeeFrac` type represents a fraction, intended to be used for sats/vbyte or sats/WU. This PR adds functionality to evaluate that feerate for a given size, in order to obtain the fee it corresponds with (rounding down, or rounding up).

  The motivation here is being able to do accurate feerate evaluations in cluster mempool block building heuristics (where rounding down is needed), but in principle this makes it possible to use `FeeFrac` as a more accurate replacement for `CFeeRate` (where for feerate estimation rounding up is desirable). Because of this, both rounding modes are implemented.

  Unit tests are included for known-correct values, plus a fuzz test that verifies the result using `arith_uint256`.

ACKs for top commit:
  l0rinc:
    ACK 58914ab459
  ismaelsadeeq:
    reACK  58914ab459
  glozow:
    light code review ACK 58914ab459

Tree-SHA512: 362b88454bf355cae1f12d6430b1bb9ab66824140e12b27db7c48385f1e8db936da7d0694fb5aad2a00eb9e5fe3083a3a2c0cc40b2a68e2d37e07b3481d4eeae
2025-04-07 17:59:42 -04:00
Pieter Wuille 58914ab459 fuzz: assert min diff between FeeFrac and CFeeRate
Co-Authored-By: Greg Sanders <gsanders87@gmail.com>
2025-04-07 10:51:41 -04:00
Pieter Wuille 0c6bcfd8f7 feefrac: support both rounding up and down for Evaluate
Co-Authored-By: l0rinc <pap.lorinc@gmail.com>
2025-04-07 10:51:41 -04:00
Pieter Wuille ecf956ec9d feefrac: add support for evaluating at given size 2025-04-07 10:51:41 -04:00
Pieter Wuille 7963aecead feefrac: add helper functions for 96-bit division
These functions are needed to implement FeeFrac evaluation later: given a
FeeFrac{fee, size}, its fee at at_size is (fee * at_size / size).
2025-04-07 10:50:56 -04:00
Pieter Wuille 800c0dea9a feefrac: rework comments around Mul/MulFallback 2025-04-07 10:45:13 -04:00
Pieter Wuille fcfe008db2 feefrac fuzz: use arith_uint256 instead of ad-hoc multiply
Rather than use an ad-hoc reimplementation of wide multiplication inside the
fuzz test, reuse arith_uint256, which already has this. It's larger than what we
need here, but performance isn't a concern in this test, and it does what we need.
2025-04-07 10:45:13 -04:00
Pieter Wuille 46ff4220bf arith_uint256: modernize comparison operators
Since C++20, operator!= is implicitly defaulted using operator==, and
operator<, operator<=, operator>, and operator>= are defaulted using
operator<=>, so it suffices to just provide these two.
2025-04-07 10:45:13 -04:00
Lőrinc e419b0e17f refactor: Remove manual CDBBatch size estimation
Remove the manual batch size estimation logic (`SizeEstimate()` method and `size_estimate` member) from `CDBBatch`.
Size is now determined solely by the `ApproximateSize()` method introduced in the previous commit, which delegates to the native LevelDB function.

The manual calculation is no longer necessary as LevelDB now provides this functionality directly, and the previous commit verified that the native function's results matched the manual estimation.

Assertions comparing the two methods are removed from `txdb.cpp`.

Co-authored-by: Wladimir J. van der Laan <laanwj@protonmail.com>
2025-04-07 15:59:41 +02:00
Lőrinc 8b5e19d8b5 refactor: Delegate to LevelDB for CDBBatch size estimation
Serialized batch size can be queried via the underlying LevelDB implementation calling the native `leveldb::WriteBatch::ApproximateSize()`.

The previous manual calculation was added in e66dbde6d1 as part of https://github.com/bitcoin/bitcoin/pull/10195. At that time (April 2017), the version of LevelDB used by Bitcoin Core (and even the latest source) lacked a native function for this. LevelDB added this capability in 69e2bd224b, merged later that year.

The old manual estimation method (`SizeEstimate()`) is kept temporarily in this commit, and assertions are added in `txdb.cpp` to verify its results against `ApproximateSize()` during batch writes. This ensures the native function behaves as expected before removing the manual calculation in the subsequent commit.
2025-04-07 13:36:55 +02:00
Lőrinc 751077c6e2 Coins: Add `kHeader` to `CDBBatch::size_estimate`
The initialization of the manual `size_estimate` in `CDBBatch::Clear()` is corrected from `0` to `kHeader` (LevelDB's fixed batch header size).
This aligns the manual estimate with LevelDB's actual size immediately after clearing, fixing discrepancies that would otherwise be caught by tests in the next commit (e.g., `coins_tests`, `validation_chainstatemanager_tests`).
2025-04-07 13:36:55 +02:00
Hennadii Stepanov 0dc74c92c0
Merge bitcoin/bitcoin#32212: test: Remove confusing and failing system time test
fadf8f078e test: Remove confusing and failing system time test (MarcoFalke)

Pull request description:

  This was just added as a sanity check in fa013664ae by myself.

  However, the test uses system time, so it may obviously (albeit rarely) fail.

  Fix it by removing it.

  Can be tested by running two bash loops at the same time:

  `while ( ./bld-cmake/bin/test_bitcoin -t util_tests/util_time_GetTime ) ; do true ; done`

  `while ( date -s "$(date -d 'now + 0.015 seconds' '+%Y-%m-%d %H:%M:%S.%3N')" && date -s "$(date -d 'now - 0.015 seconds' '+%Y-%m-%d %H:%M:%S.%3N')" ) ; do true ; done`

  Eventually, it will fail:

  ```
  test/util_tests.cpp(595): error: in "util_tests/util_time_GetTime": check ms_0 < GetTime<std::chrono::milliseconds>() has failed
  test/util_tests.cpp(596): error: in "util_tests/util_time_GetTime": check us_0 < GetTime<std::chrono::microseconds>() has failed

  *** 2 failures are detected in the test module "Bitcoin Core Test Suite"

ACKs for top commit:
  janb84:
    ACK [fadf8f0](fadf8f078e)
  mabu44:
    Tested ACK fadf8f078e
  hebasto:
    ACK fadf8f078e, tested on Ubuntu 24.10.

Tree-SHA512: fc468546f46a12804802df4f0e64d2898aca3db4df69602e5919ac31646c2fcb1e75b614fc2d1a3959c3db10fb0e315da5886d348b41589dba7cb43e618444a1
2025-04-07 11:47:15 +01:00
Prabhat Verma 7677fde4c7 Add fuzz test coverage report generation
Signed-off-by: Prabhat Verma <prabhatverma329@gmail.com>
2025-04-07 15:18:39 +05:30
Lőrinc c77e3107b8 refactor: rename leftover WriteBlockBench
The benchmark was referencing the old name of the method
2025-04-06 12:42:00 +02:00
merge-script d42e82d650
Merge bitcoin/bitcoin#32218: ci: Merge master in test-each-commit task (take 2)
fa10a1ded5 ci: Use GITHUB_BASE_REF over hard-coded master (MarcoFalke)
fa0d0be05c ci: Merge master in test-each-commit task (take 2) (MarcoFalke)

Pull request description:

  Calling the script `.github/ci-test-each-commit-exec.sh`, which merges `master`, obviously doesn't work, if the script itself is missing.

  Fix it by a move-only to first merge `master` and then call the script.

ACKs for top commit:
  l0rinc:
    Code review ACK fa10a1ded5
  sipa:
    ACK fa10a1ded5, this fixed the CI issue in #31444.

Tree-SHA512: bcab2b03cb46d456e29f8d4237312a4525b9acd819578b26b4d5670ca14e075cf473b77b235b3063e06422325b627587f12dec7b4fbba134086d162c67dc81b3
2025-04-06 17:25:24 +08:00
pablomartin4btc 0f602c5693 wallet, migration: Fix crash on empty wallet
Same as with a blank wallet, wallets with no legacy
records (i.e. empty, non-blank, watch-only wallet)
do not require to be migrated.
2025-04-04 17:38:41 -03:00
MarcoFalke fa10a1ded5
ci: Use GITHUB_BASE_REF over hard-coded master 2025-04-04 15:32:49 +02:00
MarcoFalke fa0d0be05c
ci: Merge master in test-each-commit task (take 2)
* Run git config earlier and only once
* Run git merge in the yaml, before calling the bash script
* Run git reset in the yaml as well, for symmetry
* Replace "git merge --abort" with "git reset --hard", because it does
  not fail when already up to date and no merge was started.
2025-04-04 15:32:42 +02:00
merge-script 65dcbec756
Merge bitcoin/bitcoin#32209: test: Preserve llvm profile path
c5a7ffd1e8 preserve llvm profile env (Prabhat Verma)

Pull request description:

  While generating `profraw` for fuzz tests using steps in [PR 32206](https://github.com/bitcoin/bitcoin/pull/32206) , the profraw was not being built at the desired location and only one `default.profraw` was being created which was being overwritten for multiple fuzz targets. This PR fixes that.

ACKs for top commit:
  maflcko:
    lgtm ACK c5a7ffd1e8
  mabu44:
    ACK c5a7ffd1e8

Tree-SHA512: 11f74caa8cba6f841aa899a5e294f658aed1b6a3d4cf68992609ea99fadb4a092b2350ffacea5c2d5eb377eb10082de018f27a1d6486a72460cb3905aaa15664
2025-04-04 15:42:52 +08:00
Hennadii Stepanov b34d49a27e
Merge bitcoin/bitcoin#32203: ci: Merge master in test-each-commit task
faa807bdf8 ci: Merge master in test-each-commit task (MarcoFalke)

Pull request description:

  The `test-each-commit` task will often fail, when the CI config yaml is updated along with code changes.

  This is because, GitHub seems to be merging the CI config on a fresh pull with the current target branch (`master`). However, the code changes are not.

  A tedious workaround would be for every developer to rebase on every intermittent (https://github.com/bitcoin/bitcoin/issues/31946#issuecomment-2740911853) and non-intermittent CI issue.

  However, fix this instead by merging with `master`.

ACKs for top commit:
  laanwj:
    ACK faa807bdf8
  hebasto:
    ACK faa807bdf8.

Tree-SHA512: 4849bd558dc6cdc7d86b95164ccee32ab7c08c9b7d31cf8ec5c8e9a2251fc819630f8fa9b929ed39e8e033c67bb006f0beb33e0de216e1224680be88c5fa0161
2025-04-04 07:19:35 +01:00
monlovesmango 924f25f6fc bench: Match ConnectBlock tx output counts
There turned out to be a mismatch in the tx output counts which caused
'ConnectBlockMixedEcdsaSchnorr' benchmark to run slower than
'ConnectBlockAllEcdsa' and 'ConnectBlockAllSchnorr'. This commit makes
the tx output counts uniform across all benchmarks.

This commit also renames the 'taproot_tx' variable to 'tx' to reflect
that this variable represents a general tx and not just a taproot tx.
2025-04-03 21:38:15 +00:00
Hennadii Stepanov d0cce4172c depends: Fix `mv` command compatibility with macOS 2025-04-03 19:03:52 +01:00
Hennadii Stepanov 690f5da15a depends: Specify Objective C/C++ compilers for `native_qt` package
This change fixes cross-compilation from macOS to macOS with another
architecture.
2025-04-03 19:03:27 +01:00
Prabhat Verma c5a7ffd1e8 preserve llvm profile env
Signed-off-by: Prabhat Verma <prabhatverma329@gmail.com>
2025-04-03 21:02:21 +05:30
MarcoFalke fac978fb21
test: Remove fragile and ancient release 0.17 wallet test 2025-04-03 14:34:06 +02:00
pablomartin4btc 42c13141b5 wallet, refactor: Decouple into HasLegacyRecords()
The new helper will be used to fix a crash in the
wallet migration process (watch-only, non-blank,
private keys disabled, empty wallet - no scripts
or addresses imported).

Co-authored-by: Matias Furszyfer <mfurszy@protonmail.com>
2025-04-03 07:55:51 -03:00
Hennadii Stepanov c66f7dab33
Merge bitcoin/bitcoin#32211: doc: Amend Qt 6 dependency packages for Ubuntu
2e751f559a doc: Amend Qt 6 dependency packages for Ubuntu (Hennadii Stepanov)

Pull request description:

  On older systems, such as Ubuntu 22.04, `qt6-tools-dev-tools` and `libgl-dev` are not treated as dependencies of `qt6-tools-dev` and `qt6-base-dev`, respectively. This PR explicitly lists them in the installation documentation.

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

ACKs for top commit:
  maflcko:
    lgtm ACK 2e751f559a
  laanwj:
    Code review ACK 2e751f559a

Tree-SHA512: a6997c74c83789cb5fe5b97a719b8ff6e2180d5f6ae5502ccccfce3a22394d25eef05204ecda0a6deb368de77975e2a1da89b5749eff01a979f2f60843efebff
2025-04-03 11:54:09 +01:00
laanwj ec81a72b36 net: Add randomized prefix to Tor stream isolation credentials
Add a class TorsStreamIsolationCredentialsGenerator that generates
unique credentials based on a randomly generated session prefix
and an atomic counter.

This makes sure that different launches of the application won't share
the same credentials, and thus circuits, even in edge cases.

Example with `-debug=proxy`:
```
2025-03-31T16:30:27Z [proxy] SOCKS5 sending proxy authentication 0afb2da441f5c105-0:0afb2da441f5c105-0
2025-03-31T16:30:31Z [proxy] SOCKS5 sending proxy authentication 0afb2da441f5c105-1:0afb2da441f5c105-1
```

Thanks to hodlinator for the idea.
2025-04-03 12:05:59 +02:00
Hennadii Stepanov d85895e5a7
build, msvc: Build only required `qtbase` features
This change makes vcpkg skip unused features such as `dnslookup`,
`openssl`, etc.
2025-04-03 10:26:58 +01:00
Hennadii Stepanov fe5a6dcc53
build, msvc: Update vcpkg manifest baseline
This change updates the vcpkg manifest baseline from the "2024.09.30
Release" to the "2025.03.19 Release", with the following package
changes:
 - boost: 1.85.0#1,2 --> 1.87.0
 - qtbase: 6.7.2#3 -> 6.8.2#1
 - qttools: 6.7.2#1 -> 6.8.2
 - sqlite3: 3.46.1 --> 3.49.1
2025-04-03 10:26:50 +01:00
MarcoFalke fadf8f078e
test: Remove confusing and failing system time test 2025-04-03 11:12:00 +02:00
Hennadii Stepanov 2e751f559a
doc: Amend Qt 6 dependency packages for Ubuntu
On older systems, such as Ubuntu 22.04, `qt6-tools-dev-tools` and
`libgl-dev` are not treated as dependencies of `qt6-tools-dev` and
`qt6-base-dev`, respectively. This change explicitly lists them in the
installation documentation.
2025-04-03 10:11:26 +01:00
Hennadii Stepanov df82a24508
Merge bitcoin-core/gui#863: refactor: Post Qt 6 cleanup
3aa58bea8e qt, refactor: Inline `GUIUtil::SplitSkipEmptyParts` function (Hennadii Stepanov)
d1ec6db249 qt, refactor: Inline `GUIUtil::GetImage` function (Hennadii Stepanov)
4b36ab3a6a qt, refactor: Remove outdated Qt version-specific code (Hennadii Stepanov)

Pull request description:

  This PR:
  - Removes outdated Qt version-specific code.
  - Inlines two functions from `GUIUtil`.

ACKs for top commit:
  davidgumberg:
    crACK 3aa58bea8e

Tree-SHA512: f56f6e3a219a5378d986bcb5fbfc50dcd752c080a92055da1f859433214c999905b456a12f6ac3d5b4871656dbf43a732adf04536c3479b1aa93110beafb2478
2025-04-03 08:45:37 +01:00
merge-script 77dff373a6
Merge bitcoin/bitcoin#32182: ci: Switch to dynamic library linkage in native Windows job
7967fe5bfd ci: Switch to dynamic library linkage in native Windows job (Hennadii Stepanov)

Pull request description:

  This PR significantly reduces the vcpkg binary cache size, improving CI caching performance:

  | Branch | Cache Size |
  |---|--:|
  | master | 2.6 GB |
  | this PR |  430 MB |

  Also see https://github.com/bitcoin/bitcoin/pull/31176#issuecomment-2766164288.

ACKs for top commit:
  maflcko:
    lgtm ACK 7967fe5bfd

Tree-SHA512: d52fcf9cdc95bcbbe35def4634cd94d3c934be939a486ac4740da7e5706ef813950984987a7dfef45edeca8a539438dc8fc8f3f92adb7f188af2f0088b88e4db
2025-04-03 14:03:11 +08:00
merge-script 99b9022844
Merge bitcoin/bitcoin#32177: TxGraph: Increase fuzz coverage
a40bd374aa Get*Union: disallow nulltpr Refs (Greg Sanders)
57433502e6 CountDistinctClusters: nullptrs disallowed (Greg Sanders)
8bca0d325a TxGraphImpl::Compact: m_main_clusterset.m_removed is always empty (Greg Sanders)
2c5cf987e9 TxGraphImpl::PullIn: only allowed when staging exists (Greg Sanders)

Pull request description:

  Was looking at my local coverage report, and noticed a few spots that will not or cannot be hit.

  CountDistinctClusters, GetAncestorsUnion, and GetDescendantsUnion accept nullptrs, but the test harness never employs them. Disallow them.

  We never call PullIn whenever there isn't staging, so just enforce that invariant via assertion.

  Remaining places that are not covered:

  1) Relinearize: Currently we seem to always start with a cold (not known to be optimal) cluster, and after one attempt at linearization result into something optimal. This means we never shortcircuit, nor run PostLinearization, nor store the quality as ACCEPTABLE. Reducing iterations causes these lines to be hit. sipa says he will take this on as varying the amount of iterations was meant to be done eventually anyways.
  2) We never do a move assignment operator when the lvalue already has a `m_graph` (so we never call UnlinkRef) 3358b1d105/src/txgraph.cpp (L2097)
  3) We never use the move constructor: 3358b1d105/src/txgraph.cpp (L2108)

ACKs for top commit:
  sipa:
    utACK a40bd374aa
  glozow:
    utACK a40bd374aa

Tree-SHA512: ca88297222e80e0d590889698899f892b9335cfa587a76a6c6ca62c8d846f208b6b0b9a9b1829bafabdb929a1a0c3a75f23edf7dd2b4f5e2dad0235e5bc68ba3
2025-04-03 09:51:28 +08:00
Hennadii Stepanov 3aa58bea8e
qt, refactor: Inline `GUIUtil::SplitSkipEmptyParts` function 2025-04-02 20:49:18 +01:00
Hennadii Stepanov d1ec6db249
qt, refactor: Inline `GUIUtil::GetImage` function 2025-04-02 20:48:36 +01:00
Hennadii Stepanov 4b36ab3a6a
qt, refactor: Remove outdated Qt version-specific code
Since bitcoin/bitcoin#30997, the minimum supported Qt version is 6.2.
2025-04-02 20:48:11 +01:00
MarcoFalke faa807bdf8
ci: Merge master in test-each-commit task 2025-04-02 20:46:43 +02:00
Hennadii Stepanov 7967fe5bfd
ci: Switch to dynamic library linkage in native Windows job
This change significantly reduces the vcpkg binary cache size, improving
CI caching performance.
2025-04-02 17:47:10 +01:00
Ryan Ofsky a2f28e4be9 Squashed 'src/ipc/libmultiprocess/' content from commit 35944ffd23fa
git-subtree-dir: src/ipc/libmultiprocess
git-subtree-split: 35944ffd23fa26652b82210351d50e896ce16c8f
2025-04-02 21:41:16 +08:00
merge-script 639279e86a
Merge bitcoin/bitcoin#30997: build: Switch to Qt 6
f00345727b doc: Update `dependencies.md` for Qt 6 (Hennadii Stepanov)
80b917991e build, msvc: Update `vcpkg.json` for Qt 6 (Hennadii Stepanov)
30dd1f1644 ci: Update for Qt 6 (Hennadii Stepanov)
629d292f4d test: Update sanitizer suppressions for Qt 6 (Hennadii Stepanov)
551e13abf8 guix: Adjust for Qt 6 (Hennadii Stepanov)
c3e9bd086c qt: Fix compiling for Windows (Hennadii Stepanov)
ab399c4db2 depends: Add `native_qt` package (Hennadii Stepanov)
248613eb3e depends: Factor out Qt modules' details (Hennadii Stepanov)
0268f52a4c depends: Introduce customizable `$(package)_patches_path` variables (Hennadii Stepanov)
5e794e6202 depends: Bump `qt` package up to 6.7.3 (Hennadii Stepanov)
6d4214925f cmake: Require Qt 6 to build GUI (Hennadii Stepanov)

Pull request description:

  The currently used Qt 5.15 is approaching [EOL](https://www.qt.io/blog/qt-5.15-extended-support-for-subscription-license-holders) and will reach it before the Bitcoin Core v30 release. The recent migration of the build system to CMake makes it possible to switch to Qt 6.

  This PR updates the OS runtime compatibility requirements for the Bitcoin Core GUI as follows:

  ### 1. Linux

  Starting with Qt 6.5.0, the `libxcb-cursor0` package is required to be installed at runtime.

  ### 2. Windows

  Cross-compiling does not support LTO. We have to re-add it in a follow-up.

  A new style plugin causes minor visual glitches, such as
  ![image](https://github.com/user-attachments/assets/e06f8685-aa79-49e7-9e61-4d54563f6d04)
  which will be fixed in follow-ups.

  ### 3. macOS

  `bitcoin-qt` now uses the [Metal](https://developer.apple.com/metal/) backend.

  ---

  **IMPORTANT.** Don't forget to install [Ninja](https://ninja-build.org/).

  ---

  For historical context, please refer to:
  - https://github.com/bitcoin/bitcoin/issues/20627
  - https://github.com/bitcoin/bitcoin/pull/24798

  ---

  UPD 2024-10-09. Qt 6.8 has been [released](https://www.qt.io/blog/qt-6.8-released), but it has some [drawbacks](https://github.com/bitcoin/bitcoin/pull/30997#issuecomment-2402990346) for us. As a result, this PR will stick to Qt 6.7.

  UPD 2025-03-18: [Standard support for Qt 5.15 will end after 26th of May 2025](https://www.qt.io/blog/extended-security-maintenance-for-qt-5.15-begins-may-2025)

ACKs for top commit:
  laanwj:
    re-ACK f00345727b
  hodlinator:
    re-ACK f00345727b

Tree-SHA512: 367f722e6c3ea4700b5395871c40b6df8c8062fdc822107090449ea4ae4ad2db75cc53a982a678f4c48ce8f9b2d43ed10e6d23b06165ab78713f161db712d895
2025-04-02 21:41:16 +08:00
Cory Fields babb9f5db6 depends: remove non-native libmultiprocess build
Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2025-04-02 13:41:16 +00:00
Ryan Ofsky 5d105fb8c3 depends: Switch libmultiprocess packages to use local git subtree
With newly introduced libmultiprocess subtree, there's no need for depends
system to download and track changes to the upstream repository.

Note that adding the libmultiprocess subtree does not allow dropping
libmultiprocess packages from the depends build, because libmultiprocess
includes a code generation tool called mpgen, and in cross-compiled builds,
bitcoin core's cmake build system doesn't have access to a native toolchain and
can't build mpgen itself, so the depends system (or the native environment if
not using depends) needs to supply it.
2025-04-02 08:41:16 -05:00
Ryan Ofsky 9b35518d2f depends, moveonly: split up int_get_build_id function
Move parts of the int_get_build_id into a new int_get_build_properties
function. There is no change in behavior. This just organizes assignments
better so some build properties can be used to help compute build ids in the
next commit.
2025-04-02 08:41:16 -05:00
Ryan Ofsky 2d373e2707 lint: Add exclusions for libmultiprocess subtree
Without this change linter produces errors about:

- Use of std::filesystem the libmultiprocess example program.
- Use of locale-dependent functions in example program, in the build time code
  generator, and in the runtime library for debug logging.
- Include guards not beginning with BITCOIN_
2025-04-02 08:41:16 -05:00
Ryan Ofsky e88ab394c1 doc: Update documentation to explain libmultiprocess subtree
Co-authored-by: Cory Fields <cory-nospam-@coryfields.com>
2025-04-02 08:41:16 -05:00
Ryan Ofsky d4bc563982 cmake: Fix clang-tidy "no input files" errors
This change is technically not needed to add libmultiprocess as a subtree, but
it avoids a CI failure in followup PR #30975 which enables multiprocess build
option in more CI jobs. In that PR, clang-tidy job fails due to missing
generated example files as reported
https://github.com/bitcoin/bitcoin/pull/30975#issuecomment-2627116832

Different fixes were suggested
https://github.com/bitcoin/bitcoin/pull/30975#issuecomment-2627152623 and
https://github.com/bitcoin/bitcoin/pull/30975#issuecomment-2627403382

Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2025-04-02 08:41:16 -05:00
Ryan Ofsky abdf3cb645 cmake: Fix warnings from boost headers
This change is technically not needed to add libmultiprocess as a subtree, but
it avoids a CI failure in followup PR #30975 which enables multiprocess build
option in more CI jobs. In that PR, the "macOS 14 native no depends job" fails
due to warnings in boost headers treated as errors, reported in
https://github.com/bitcoin/bitcoin/pull/30975#issuecomment-2623801480 and
https://github.com/chaincodelabs/libmultiprocess/issues/138
2025-04-02 08:41:16 -05:00
Ryan Ofsky 8532fcb1c3 cmake: Fix ctest mptest "Unable to find executable" errors
This change is technically not needed to add libmultiprocess as a subtree, but
it avoids a CI failure in followup PR #30975 which enables multiprocess build
option in more CI jobs. In that PR, several jobs fail due to the mptest
executable not being built by default, as reported
https://github.com/bitcoin/bitcoin/pull/30975#issuecomment-2623801480

Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2025-04-02 08:41:16 -05:00
Ryan Ofsky d597ab1dee cmake: Support building with libmultiprocess subtree
When ENABLE_IPC option is on, build with libmultiprocess subtree and
`add_subdirectory(src/ipc/libmultiprocess)` instead of external package
and `find_package(Libmultiprocess)` by default.

Behavior can be toggled with `WITH_EXTERNAL_LIBMULTIPROCESS` option. Using a
subtree should be more convenient for most bitcoin developers, but using an
external package is more convenient for developing in the libmultiprocess
repository.

The `WITH_EXTERNAL_LIBMULTIPROCESS` option is also used to avoid needing to
changing the depends build here. But in later commits, the depends build is
switched to use the add_subdirectory build as well.

Co-authored-by: Cory Fields <cory-nospam-@coryfields.com>
Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2025-04-02 08:41:16 -05:00
Ryan Ofsky 69f0d4adb7 scripted-diff: s/WITH_MULTIPROCESS/ENABLE_IPC/ in cmake
Rename WITH_MULTIPROCESS to ENABLE_IPC, because ENABLE_IPC is a more accurate
name for the feature. It controls whether the src/ipc/ directory is built and
whether IPC features like -ipcbind, -ipcconnect, and -ipcfd are available. It
does NOT currently enable multiprocess features which are implemented in #10102
building on top of the IPC features. It will also no longer (as of the next
commit), control whether a find_package call is made so the "WITH_" prefix is
also inappropriate.

-BEGIN VERIFY SCRIPT-
git grep -l WITH_MULTIPROCESS | xargs sed -i s/WITH_MULTIPROCESS/ENABLE_IPC/g
-END VERIFY SCRIPT-
2025-04-02 08:41:16 -05:00
Ryan Ofsky 3f6fb40114 Merge commit 'a2f28e4be96e92079a219567cf20214996aefc53' as 'src/ipc/libmultiprocess' 2025-04-02 21:41:16 +08:00
Ryan Ofsky d6244f85c5 depends: Update libmultiprocess library to simplify cmake subtree build
Bump libmultiprocess library to include MP_INCLUDE_DIR definition from
https://github.com/chaincodelabs/libmultiprocess/pull/168 which can simplify
the IPC cmake build as described
https://github.com/bitcoin/bitcoin/pull/31741#discussion_r2021118543

This update brings in the following changes:

https://github.com/bitcoin-core/libmultiprocess/pull/166 doc: rename from chaincodelabs to bitcoin-core
https://github.com/bitcoin-core/libmultiprocess/pull/168 Switch `MP_INCLUDE_DIR` to global property
2025-04-02 09:41:16 -04:00
laanwj b639417b39 net: Add Tor extended SOCKS5 error codes
Add support for reporting Tor extended SOCKS5 error codes as defined
here:

- https://spec.torproject.org/socks-extensions.html#extended-error-codes
- https://gitlab.torproject.org/tpo/core/arti/-/blob/main/crates/tor-socksproto/src/msg.rs?ref_type=heads#L183

These give a more direct indication of the problem in case of errors
connecting to hidden services, for example:
```
2025-04-02T10:34:13Z [net] Socks5() connect to [elided].onion:8333 failed: onion service descriptor can not be found
```

In the C Tor implementation, to get these one should set the
"ExtendedErrors" flag on the "SocksPort" definition, introduced in
version 0.4.3.1.

In Arti, extended error codes are always enabled.

Also, report the raw error code in case of unknown reply values.
2025-04-02 12:48:14 +02:00
willcl-ark 42e99ad773
net: skip non-route netlink responses
This shouldn't usually be hit, but is a good belt-and-braces.
2025-04-02 09:47:27 +01:00
willcl-ark 57ce645f05
net: filter for default routes in netlink responses
Filter netlink responses to only consider default routes by checking the
destination prefix length (rtm_dst_len == 0).

Previously, we selected the first route with an RTA_GATEWAY attribute,
which for IPv6 often resulted in choosing a non-default route instead of
the actual default.

This caused occasional PCP port mapping failures because a gateway for a
non-default route was selected.
2025-04-02 09:46:56 +01:00
Hennadii Stepanov f00345727b
doc: Update `dependencies.md` for Qt 6 2025-04-02 09:15:50 +01:00
Hennadii Stepanov 80b917991e
build, msvc: Update `vcpkg.json` for Qt 6 2025-04-02 09:15:37 +01:00
Hennadii Stepanov 30dd1f1644
ci: Update for Qt 6 2025-04-02 09:15:25 +01:00
Hennadii Stepanov 629d292f4d
test: Update sanitizer suppressions for Qt 6 2025-04-02 09:15:13 +01:00
Hennadii Stepanov 551e13abf8
guix: Adjust for Qt 6
1. Do not set `C{PLUS}_INCLUDE_PATH` variables

The build system for Qt 6 differs entirely from that of Qt 5. Building a
set of native Qt 6 tools now forms a separate step when cross-compiling.
Under these new circumstances, the `C{PLUS}_INCLUDE_PATH` environment
variables may alter the default include directories for both native and
cross compilers.

Previously, we explicitly unset these variables when invoking clang for
cross-compiling; however, that approach proved suboptimal (see #30451).

This change sets the native toolchain for dependencies explicitly,
rather than relying on the `C{PLUS}_INCLUDE_PATH` environment variables.
Additionally, it facilitates the transition towards using clang for
building native tools when cross-compiling for macOS.

2. Add `ninja` package.

3. Adjust allowed symbol lists.
2025-04-02 09:15:01 +01:00
Hennadii Stepanov c3e9bd086c
qt: Fix compiling for Windows
Static builds for Windows now require Qt 6.7 or newer. This holds
automatically to cross-compiled builds.
2025-04-02 09:14:49 +01:00
Hennadii Stepanov ab399c4db2
depends: Add `native_qt` package
Unlike Qt 5, Qt 6 requires a separate native Qt build for
cross-building.

See: https://www.qt.io/blog/qt-6-build-system.
2025-04-02 09:14:40 +01:00
Hennadii Stepanov 248613eb3e
depends: Factor out Qt modules' details 2025-04-02 09:14:07 +01:00
Hennadii Stepanov 0268f52a4c
depends: Introduce customizable `$(package)_patches_path` variables
This change helps avoid patch duplication between a package and its
native counterpart.
2025-04-02 09:13:31 +01:00
Hennadii Stepanov 5e794e6202
depends: Bump `qt` package up to 6.7.3 2025-04-02 09:12:27 +01:00
Hennadii Stepanov 6d4214925f
cmake: Require Qt 6 to build GUI 2025-04-02 09:11:48 +01:00
merge-script cfa7f70f6c
Merge bitcoin/bitcoin#31933: doc: Add Clang/LLVM based coverage report generation
b96f1a696a add clang/llvm based coverage report generation (Prabhat Verma)

Pull request description:

  Followed up from the [comment](https://github.com/bitcoin/bitcoin/issues/31927#issuecomment-2674522975) on the issue [#31927](https://github.com/bitcoin/bitcoin/issues/31927) , issues have been observed building coverage reports with `gcov` in MacOs and NixOs. This PR adds the steps to generate a coverage report based on the default llvm/clang tooling.

ACKs for top commit:
  Crypt-iQ:
    tACK b96f1a696a
  hodlinator:
    re-ACK b96f1a696a
  janb84:
    Re ACK [b96f1a6](b96f1a696a)

Tree-SHA512: bc54f170e84bb76b3eba7285bd49f051c0b99b784d583a550d8e51511497bcc4df8964bbe3991777648d2f829809db8eabb0cbf0d25f9da5e49e1cfc62f6d8d0
2025-04-02 14:15:09 +08:00
merge-script 772996ac8b
Merge bitcoin/bitcoin#32158: fuzz: Make partially_downloaded_block more deterministic
fa51310121 contrib: Warn about using libFuzzer for coverage check (MarcoFalke)
fa17cdb191 test: Avoid script check worker threads while fuzzing (MarcoFalke)
fa900bb2dc contrib: Only print fuzz output on failure (MarcoFalke)
fa82fe2c73 contrib: Use -Xdemangler=llvm-cxxfilt in deterministic-*-coverage (MarcoFalke)
fa7e931130 contrib: Add optional parallelism to deterministic-fuzz-coverage (MarcoFalke)

Pull request description:

  This should make the `partially_downloaded_block` fuzz target even more deterministic.

  Follow-up to https://github.com/bitcoin/bitcoin/pull/31841. Tracking issue: https://github.com/bitcoin/bitcoin/issues/29018.

  This bundles several changes:

  * First, speed up the `deterministic-fuzz-coverage` helper by introducing parallelism.
  * Then, a fix to remove spawned test threads or spawn them deterministically. (While testing this, high parallelism and thread contention may be needed)

  ### Testing

  It can be tested via (setting 32 parallel threads):

  ```
  cargo run --manifest-path ./contrib/devtools/deterministic-fuzz-coverage/Cargo.toml -- $PWD/bld-cmake/ $PWD/../b-c-qa-assets/fuzz_corpora/ partially_downloaded_block 32
  ```

  Locally, on a failure, the output would look like:

  ```diff
   ....
  -  150|      0|            m_worker_threads.emplace_back([this, n]() {
  -  151|      0|                util::ThreadRename(strprintf("scriptch.%i", n));
  +  150|      1|            m_worker_threads.emplace_back([this, n]() {
  +  151|      1|                util::ThreadRename(strprintf("scriptch.%i", n));
   ...
  ```

  This excerpt likely indicates that the script threads were started after the fuzz init function returned.

  Similarly, for the scheduler thread, it would look like:

  ```diff
   ...
     227|      0|        m_node.scheduler = std::make_unique<CScheduler>();
  -  228|      1|        m_node.scheduler->m_service_thread = std::thread(util::TraceThread, "scheduler", [&] { m_node.scheduler->serviceQueue(); });
  +  228|      0|        m_node.scheduler->m_service_thread = std::thread(util::TraceThread, "scheduler", [&] { m_node.scheduler->serviceQueue(); });
     229|      0|        m_node.validation_signals =
   ...
  ```

ACKs for top commit:
  Prabhat1308:
    re-ACK [`fa51310`](fa51310121)
  hodlinator:
    re-ACK fa51310121
  janb84:
    Re-ACK [fa51310](fa51310121)

Tree-SHA512: 1a935eb19da98c7c3810b8bcc5287e5649ffb55bf50ab78c414a424fef8e703839291bb24040a552c49274a4a0292910a00359bdff72fa29a4f53ad36d7a8720
2025-04-02 13:22:00 +08:00
merge-script 40de19164c
Merge bitcoin/bitcoin#32118: fuzz: wallet: fix crypter target
28dc118001 fuzz: wallet: fix crypter target (brunoerg)

Pull request description:

  The crypter target has an issue, it's calling `DecryptKey` with a random secret and a random public key that will unlikely be related to the key used to encrypt, so it won't have any effect. This PR changes fixes it and also removes the `DecryptSecret` call since this function is already (and only) called within `DecryptKey`.

ACKs for top commit:
  maflcko:
    lgtm ACK 28dc118001 🥊

Tree-SHA512: e96b7d33879bf06eeec0726e74e8e0d7020997659bf97dfca5d7c1a7ba65c4d93c78e666b97eebde110564cef2eefc7209d3e3586e4658145827b14d1b01dfc9
2025-04-02 13:17:49 +08:00
merge-script 5541f7ced7
Merge bitcoin/bitcoin#32187: refactor: Remove spurious virtual from final ~CZMQNotificationInterface
fa69c42fdf refactor: Remove spurious virtual from final ~CZMQNotificationInterface (MarcoFalke)

Pull request description:

  `virtual` does not make sense here, because:

  * The class is `final`, thus the destructor isn't overridden in a derived class
  * The destructor also isn't overriding the destructor of the base, clarified in commit 2b3ea39de4
  * Clang 21 may warn about this

  ```
  src/zmq/zmqnotificationinterface.h:25:13: error: virtual method '~CZMQNotificationInterface' is inside a 'final' class and can never be overridden [-Werror,-Wunnecessary-virtual-specifier]
     25 |     virtual ~CZMQNotificationInterface();
        |             ^
  ```

  Fix all issues by removing it.

ACKs for top commit:
  davidgumberg:
    crACK fa69c42fdf
  janb84:
    ACK [fa69c42](fa69c42fdf)
  TheCharlatan:
    ACK fa69c42fdf

Tree-SHA512: 26ea977f31fe24c116d68dea6c583de7c6fc480877e1baefcde11db4ac191e352027d492ee6ad69a60fe4ff537e0841c638b3a3e81356d9e00c60030845fc96e
2025-04-02 09:56:08 +08:00
merge-script 6f6f83a8ca
Merge bitcoin/bitcoin#32193: test: fix spelling in Python code comment
4774a0c923 test: fix spelling in Python code comment (John Bampton)

Pull request description:

  Fixed a couple of typos

Top commit has no ACKs.

Tree-SHA512: 5334995672b2c7d4a9cb916f71dff6a2ce13dc7ced6bbc30ddb0fe8e0ae0b4094b675b3dfced1ffc1b92e3a33ee22df07af3032b8c2928f27051b6376dca3361
2025-04-02 09:49:21 +08:00
merge-script 16b084f88d
Merge bitcoin/bitcoin#32194: ci, windows: Do not exclude `wallet_migration.py` in command line
4a679936bb ci, windows: Do not exclude `wallet_migration.py` in command line (Hennadii Stepanov)

Pull request description:

  This PR amends the recently merged https://github.com/bitcoin/bitcoin/pull/31176 to resolve a silent merge conflict with the previously merged https://github.com/bitcoin/bitcoin/pull/31248.

  Since https://github.com/bitcoin/bitcoin/pull/31248, it is no longer necessary to use `--exclude wallet_migration.py`, as the test is skipped due to not using previous releases.

  The `wallet_migration.py` test itself still needs to be fixed for Windows by someone who will work on https://github.com/bitcoin/bitcoin/issues/32192.

ACKs for top commit:
  davidgumberg:
    crACK 4a679936bb

Tree-SHA512: f42428016958cdaccb509cc49341e726eaf1314d85989a7b49888f3862dc4ea0c2988a4792ae62dd925302d0073906397801c8dd2fb06c23381d7cad38730249
2025-04-02 09:47:10 +08:00
Hennadii Stepanov 4a679936bb
ci, windows: Do not exclude `wallet_migration.py` in command line
Since https://github.com/bitcoin/bitcoin/pull/31248, it is no longer
necessary to use `--exclude wallet_migration.py`, as the test is skipped
due to not using previous releases.
2025-04-01 22:37:49 +01:00
Hennadii Stepanov 449e2eb7e4
Merge bitcoin/bitcoin#32184: ci: Add workaround for vcpkg's `libevent` package
30c59adda4 ci: Drop confusing comment (Hennadii Stepanov)
ef00a28414 ci: Add workaround for vcpkg's libevent package (Hennadii Stepanov)

Pull request description:

  This PR is necessary for Windows GHA [images](https://github.com/actions/runner-images/blob/win22/20250330.1/images/windows/Windows2022-Readme.md), which provide CMake >= 4.0.

  The idea has been taken from https://github.com/microsoft/vcpkg/pull/44273#discussion_r2009140242.

ACKs for top commit:
  maflcko:
    lgtm ACK 30c59adda4
  pinheadmz:
    ACK 30c59adda4

Tree-SHA512: 898a616a40c1aaec69d8a329d56f887cacec71b9588842feef2b689fbd21a12d8f8b3b4053a6373332008668960b9df7c71a44fcd97e637e250705daf1215c7f
2025-04-01 22:27:14 +01:00
John Bampton 4774a0c923 test: fix spelling in Python code comment 2025-04-02 07:20:41 +10:00
Pol Espinasa 459807d566
test: remove strict restrictions on rpc_deprecated
Removed the wallet restrictions for rpc_deprecated.py and added specific test case for the current deprecated rpc.
skip_test_if_missing_module will skip the whole test when the wallet is missing, even if a part of the test is non-wallet related.
2025-04-01 21:40:27 +02:00
laanwj c47f81e8ac net: Rename `_randomize_credentials` Proxy parameter to `tor_stream_isolation`
Rename the `_randomize_credentials` parameter to Proxy's constructor to
`tor_stream_isolation` to make it more clear, and more specific what its
purpose is.

Also change all call sites to use a named parameter.
2025-04-01 20:18:59 +02:00
merge-script 1a6fc04d81
Merge bitcoin/bitcoin#29500: test: create assert_not_equal util
7bb83f6718 test: create assert_not_equal util and add to where imports are needed (kevkevin)

Pull request description:

  In the functional tests there are lots of cases where we assert != which we now swap with assert_not_equal to be more readable

  This is motivated/uses logic from this PR which was closed https://github.com/bitcoin/bitcoin/pull/28528
  This partially helps https://github.com/bitcoin/bitcoin/issues/23119

  I've broken it up to just `assert_not_equal` to keep the PR smaller as suggested in https://github.com/bitcoin/bitcoin/pull/28528#issuecomment-1959945805

  I can create follow up PR's if this is wanted

ACKs for top commit:
  hodlinator:
    re-ACK 7bb83f6718
  ryanofsky:
    Code review ACK 7bb83f6718. Only change since last review is fixing error message formatting and passing it as a keyword argument
  janb84:
    Re-ACK [7bb83f6](7bb83f6718)

Tree-SHA512: de09f41a690033a5b61e6f861d3bd69a32b889d6655a28fbc0d5cfac9f7ec9c642432967d33913970882b4cfdd47bdd377d0ddc44e25976cbaa49f7f9d8f7b10
2025-04-01 13:52:41 -04:00
Ryan Ofsky 6af68bb84b
Merge bitcoin/bitcoin#32166: torcontrol: Define tor reply code as const to improve our maintainability
8e4a0ddd50 torcontrol: Add comment explaining Proxy credential randomization for Tor privacy (Eval EXEC)
ec5c0b26ce torcontrol: Define tor reply code as const to improve maintainability (Eval EXEC)

Pull request description:

  This PR want to:
  1. replace tor repy code with const to improve out maintainability.
  2. cherry-picked https://github.com/bitcoin/bitcoin/pull/31973 , add comment to explain Proxy credential randomization for Tor privacy

ACKs for top commit:
  hodlinator:
    re-ACK 8e4a0ddd50
  laanwj:
    re-ACK 8e4a0ddd50

Tree-SHA512: 038daa6508ca88fceed5c8e155430614cb56976f36d1f8baee5114bca1141122cf94f51814a869848b3442691ee765cbf609cf946b2b35d5135015a9b749d917
2025-04-01 13:16:27 -04:00
Ryan Ofsky 6593293e47
Merge bitcoin/bitcoin#32110: contrib: document asmap-tool commands more thoroughly
6afffba34e contrib: (asmap) add docs about encode and decode commands (jurraca)
67d5cc2a06 contrib: (asmap) add documentation on diff and diff-addrs commands (jurraca)
e047b1deca contrib: (asmap) add diff-addrs example to README (jurraca)

Pull request description:

  This README was a little sparse in my opinion, and was missing a mention of the `diff-addrs` command.

  The README updates add background and examples for each command, split in two sections (encode/decode and diff/diff-addrs). This is intended to help people know how and when to run the commands available in the `asmap-tool.py` script.

  However, I could use some confirmation on the behavior of the `--fill` flag. It's true that files generated with this flag set cannot be used to diff files after the fact, but i don't quite follow what the fill flag does to make that true. sipa could you maybe provide some insight?

ACKs for top commit:
  fjahr:
    re-ACK 6afffba34e
  brunoerg:
    reACK 6afffba34e
  laanwj:
    re-ACK 6afffba34e

Tree-SHA512: 073e8d7255f7270aa2f5a070332872f5fa6fbe6532eee1f7e3e4158ac0125a49c155f4933bf00655ff3a89f666f3f3bea521e70c516ab09a448845016d2b880a
2025-04-01 12:43:23 -04:00
Ryan Ofsky c8ade107c8
Merge bitcoin/bitcoin#31806: fuzz: coinselection: cover `SetBumpFeeDiscount`
0ff66b1c4a fuzz: coinselection: cover `SetBumpFeeDiscount` (brunoerg)

Pull request description:

  `SetBumpFeeDiscount` sets the bump fee discount which is used to calculate the waste. We currently have no fuzz coverage for this function, so this PR adds it by calling `SetBumpFeeDiscount` before `RecalculateWaste`.

ACKs for top commit:
  marcofleon:
    ACK 0ff66b1c4a

Tree-SHA512: d5c1d97daaeb7f9b096bf9bdf6374b8a674a75f464e2b9bb3e1e1774a5805b22840ca1f31bae63f106640d9ce27a99432c3034524340be91c235f6ec3b185cff
2025-04-01 12:40:01 -04:00
MarcoFalke fa69c42fdf
refactor: Remove spurious virtual from final ~CZMQNotificationInterface 2025-04-01 18:33:33 +02:00
Ryan Ofsky ea36d2720a
Merge bitcoin/bitcoin#31340: test: add missing segwitv1 test cases to `script_standard_tests`
8284229a28 refactor: deduplicate anchor witness program bytes (`0x4e,0x73`) (Sebastian Falbesoner)
41f2f058d0 test: add missing segwitv1 test cases to `script_standard_tests` (Sebastian Falbesoner)

Pull request description:

  Currently we have two segwitv1 output script types that are considered standard:
  - `TxoutType::WITNESS_V1_TAPROOT` (P2TR): witness program has size 32 (introduced with taproot soft-fork)
  - `TxoutType::ANCHOR` (P2A): witness program is {0x4e, 0x7e} (introduced with #30352)

  This PR adds them to the script standardness unit tests where missing, i.e. for using them with the `ExtractDestination` and `GetScriptForDestination` functions.

ACKs for top commit:
  rkrux:
    ACK  8284229a28
  instagibbs:
    reACK 8284229a28
  hodlinator:
    Code Review ACK 8284229a28

Tree-SHA512: d4a3b47fd31ba33f62d4367811e72a7f442c01b046b0a7217a66be0b9dea5c9041eebfe812c31839ec0f0b14c56948c7c016d3d2de79283583ad8e32c192c6ff
2025-04-01 12:32:27 -04:00
Ryan Ofsky 80e47b1920
Merge bitcoin/bitcoin#32096: Move some tests and documentation from testnet3 to testnet4
aa7a898c23 doc: use testnet4 in developer docs (Sjors Provoost)
6c217d22fd test: use testnet4 in argsman test (Sjors Provoost)
7c200ece80 test: use testnet4 in key_io_valid.json (Sjors Provoost)
d424bd5941 test: drop unused testnet3 magic bytes (Sjors Provoost)
8cfc09fafe test: cover testnet4 magic in assumeutxo.py (Sjors Provoost)
4281e3603a zmq: use testnet4 in zmq_sub.py example (Sjors Provoost)

Pull request description:

  In preparation for dropping testnet3 entirely in #31974 this PR migrates a few things to testnet4:

  * the ZMQ examples
  * developer docs
  * various unit tests
  * the snapshot magic byte check in `feature_assumeutxo.py`

  It drops `testnet3` from `MAGIC_BYTES` in the test framework, since no test uses it.

ACKs for top commit:
  fjahr:
    re-ACK aa7a898c23
  maflcko:
    lgtm ACK aa7a898c23 🔊
  hodlinator:
    re-ACK aa7a898c23

Tree-SHA512: 235f74273234e8fb2aedf0017dea5c16bb9813ec7a1f89a51abe85691f09830a5ead834115d7db0936e12e55a40bc81888856a8002fe507c1474407e77f8b9fb
2025-04-01 11:54:41 -04:00
Hennadii Stepanov 30c59adda4
ci: Drop confusing comment
GHA updates images anyway.
2025-04-01 15:14:57 +01:00
Hennadii Stepanov ef00a28414
ci: Add workaround for vcpkg's libevent package
This change is necessary for Windows GHA images, which provide
CMake >= 4.0.
2025-04-01 15:02:47 +01:00
kevkevin 7bb83f6718
test: create assert_not_equal util and add to where imports are needed
In the functional tests there are lots of cases where we assert != which
this new util will replace, we also are adding the imports and the new assertion
2025-04-01 08:39:24 -04:00
naiyoma 2929da1dd5 test: Add coverage for rpcwhitelistdefault when unset 2025-04-01 15:11:15 +03:00
MarcoFalke fa51310121
contrib: Warn about using libFuzzer for coverage check 2025-04-01 11:34:29 +02:00
MarcoFalke fa17cdb191
test: Avoid script check worker threads while fuzzing
Threads may execute their function any time after they are spawned, so
coverage could be non-deterministic.

Fix this,

* for the script check worker threads by disabling them while fuzzing.
* for the scheduler thread by waiting for it to fully start and run the
  service queue.
2025-04-01 10:22:20 +02:00
MarcoFalke fa900bb2dc
contrib: Only print fuzz output on failure
This makes it humanly possible to track progress as only "[N/M]"-lines are printed as long as we succeed.

Also, use char (a, b) to indicate run_id instead of u8 (0, 1).
Also, use emojis to indicate final success or error.

Co-Authored-By: Hodlinator <172445034+hodlinator@users.noreply.github.com>
2025-04-01 10:22:16 +02:00
Ryan Ofsky 74d9598bfb
Merge bitcoin/bitcoin#32134: descriptors: Multipath/PR 22838 follow-ups
56f271e9b9 descriptors refactor: Clarify multipath data relationships through local struct (Hodlinator)
7e974f474e descriptors refactor: Use range-for and limit scope of seen_multipath (Hodlinator)
99a92efdd9 descriptors doc: Correct Markdown format + wording (Hodlinator)

Pull request description:

  Follows up on unresolved suggestions from #22838. In order of priority:

  1. Fixes a couple of typos [^1][^2] and indentation to conform to Markdown.
  2. Solves `for`-loop nit [^3] and also limits variable scope.
  3. Clarifies data relationships [^4][^5] by introducing `struct` rather than comments.

  [^1]: https://github.com/bitcoin/bitcoin/pull/22838#discussion_r1713711352
  [^2]: https://github.com/bitcoin/bitcoin/pull/22838#discussion_r1735039600
  [^3]: https://github.com/bitcoin/bitcoin/pull/22838#discussion_r1735041704
  [^4]: https://github.com/bitcoin/bitcoin/pull/22838#discussion_r1715150336
  [^5]: https://github.com/bitcoin/bitcoin/pull/22838#discussion_r1715151078

ACKs for top commit:
  Prabhat1308:
    re-ACK [`56f271e`](56f271e9b9)
  mabu44:
    tACK 56f271e9b9
  l0rinc:
    utACK 56f271e9b9
  rkrux:
    crACK 56f271e9b9

Tree-SHA512: 75777c911640038a3e0ea48601c0f55463a5f8ff5b3462d81e8992d9fc8f988d5a240e2166befa67a2a246696b0863f8e2508524c14697c490d3b229fe048996
2025-03-31 16:08:15 -04:00
Greg Sanders a40bd374aa Get*Union: disallow nulltpr Refs 2025-03-31 13:07:37 -04:00
Greg Sanders 57433502e6 CountDistinctClusters: nullptrs disallowed 2025-03-31 13:07:37 -04:00
Greg Sanders 8bca0d325a TxGraphImpl::Compact: m_main_clusterset.m_removed is always empty 2025-03-31 13:07:14 -04:00
Greg Sanders 2c5cf987e9 TxGraphImpl::PullIn: only allowed when staging exists 2025-03-31 13:07:10 -04:00
MarcoFalke fa82fe2c73
contrib: Use -Xdemangler=llvm-cxxfilt in deterministic-*-coverage
This makes the result more readable.
2025-03-31 17:48:28 +02:00
MarcoFalke fa7e931130
contrib: Add optional parallelism to deterministic-fuzz-coverage
Co-Authored-By: Hodlinator <172445034+hodlinator@users.noreply.github.com>
2025-03-31 17:48:12 +02:00
merge-script 3358b1d105
Merge bitcoin/bitcoin#31176: ci: Test cross-built Windows executables on Windows natively
25b56fd9b4 ci: Test cross-built Windows executables on Windows natively (Hennadii Stepanov)
3501bca8c7 ci: Move "Windows cross" job from Cirrus CI to GHA CI (Hennadii Stepanov)
f8619196ce ci: Use `bash` by default for all platforms (Hennadii Stepanov)

Pull request description:

  This PR enables on the CI tests of cross-compiled Windows binaries on Windows.

  It is important to have such tests in CI because the release binaries for Windows are also cross-compiled.

  Two functional tests, `wallet_migration.py` and `wallet_multiwallet.py`, are temporarily disabled. They require fixes, such as https://github.com/bitcoin/bitcoin/pull/31410, and adjustments for error message handling. Re-enabling these tests will be addressed in follow-up PRs.

  Resolves https://github.com/bitcoin/bitcoin/issues/31071.

ACKs for top commit:
  davidgumberg:
    tested reACK 25b56fd9b4
  hodlinator:
    re-ACK 25b56fd9b4
  willcl-ark:
    utACK 25b56fd9b4
  maflcko:
    review-only ACK 25b56fd9b4 🍎

Tree-SHA512: fb9150807b7ebb248e8f4fe7b16e5179251e7be9336459287787f27e542583d73d937e6969667fd836378b676bb9be7f66756dc1abca8a01364bc9ee3e3720a5
2025-03-31 21:57:34 +08:00
Eval EXEC 8e4a0ddd50
torcontrol: Add comment explaining Proxy credential randomization for Tor privacy
Signed-off-by: Eval EXEC <execvy@gmail.com>
2025-03-31 21:14:08 +08:00
Greg Sanders f974359e21 test: Add encodable PUSHDATA1 examples to feature_taproot 2025-03-31 08:19:10 -04:00
Eval EXEC ec5c0b26ce
torcontrol: Define tor reply code as const to improve maintainability
Signed-off-by: Eval EXEC <execvy@gmail.com>
2025-03-31 14:20:30 +08:00
Matt Corallo 3c3548a70e validation: clarify final |= BLOCK_FAILED_VALID in InvalidateBlock
This has no functional affect, as the any CBlockIndex*s which
to_mark_failed is set to will already have been marked failed.

Also prevents a situation where block already marked as
BLOCK_FAILED_CHILD is again unconditionally marked as
BLOCK_FAILED_VALID in the final |= BLOCK_FAILED_VALID.
2025-03-31 08:37:07 +05:30
stratospher aac5488909 validation: correctly update BlockStatus for invalid block descendants
invalid_block ----------> block_index

- before this commit, only if block_index is not invalid, it will mark
  block_index as BLOCK_FAILED_CHILD
- it's possible that block_index encountered is invalid and was marked
  as BLOCK_FAILED_VALID previously
- in this case, correctly update BlockStatus of block_index by
  clearing BLOCK_FAILED_VALID and then setting it to BLOCK_FAILED_CHILD
2025-03-31 08:37:07 +05:30
stratospher 9e29653b42 test: check BlockStatus when InvalidateBlock is used
when a block is invalidated using InvalidateBlock, check that:
1. it's status is BLOCK_FAILED_VALID
2. it's children's status is BLOCK_FAILED_CHILD
   and not BLOCK_FAILED_VALID
3. it's ancestors are valid
2025-03-31 08:37:00 +05:30
stratospher c99667583d validation: fix traversal condition to mark BLOCK_FAILED_CHILD
this block of code is not reached on master since other than
initialisation, all other iterations have invalid_walk_tip
and to_mark_failed pointers in some form of this layout
where 1, 2, 3 and 4 are block heights.

	invalid_walk_tip
	  ↓
1 <- 2 <- 3 <- 4
	       ↑
	      to_mark_failed

fix it so that blocks are correctly marked as BLOCK_FAILED_CHILD
if it's a descendant of BLOCK_FAILED_VALID block.
2025-03-31 08:26:37 +05:30
Jiri Jakes 7a93544cdc
doc: Fix and clarify description of ZMQ message format
This change stresses that all ZMQ messages share the same structure
and that they differ only in the format of the bodies. Previously this
was not clear.

Further it removes the notion of endianness of 32-byte hashes,
as it was misleading, and replaces it with the term 'reversed byte
order' (as opposed to natural or normal byte order produced by hashing
functions).

Additionally, it states that ZMQ 32-byte hashes are in the same format
as in RPC. Previously it incorrectly stated that the two were in
different formats.
2025-03-30 12:05:43 +08:00
Hodlinator 56f271e9b9
descriptors refactor: Clarify multipath data relationships through local struct 2025-03-29 20:46:54 +01:00
Hodlinator 7e974f474e
descriptors refactor: Use range-for and limit scope of seen_multipath
* Range-for avoids ++i/i++ debate and decreases linecount.
* seen_multipath is only used if multipath_segment_index hasn't already been set. Rename it to seen_substitutes to better describe what it does, now that the context implies its involved in multipath.
2025-03-29 20:43:48 +01:00
Ethan Heilman 3e167085ba test: Ensures test fails if witness is not hex
This commit ensures that we do not fail silently when the test script encounters a witness string in the JSON test data that can not be parsed as hex.
2025-03-29 15:39:02 -04:00
Hennadii Stepanov 4c1906a500
Merge bitcoin/bitcoin#31992: cmake: Avoid fuzzer "multiple definition of `main'" errors
57d8b1f1b3 cmake: Avoid fuzzer "multiple definition of `main'" errors (Ryan Ofsky)

Pull request description:

  This change builds libraries with `-fsanitize=fuzzer-no-link` instead of `-fsanitize=fuzzer` when the cmake `-DSANITIZERS=fuzzer` option is specified. This is necessary to make fuzzing and IPC cmake options compatible with each other and avoid CI failures in #30975 which enables IPC in the fuzzer CI build:

  https://cirrus-ci.com/task/5366255504326656?logs=ci#L2817
  https://cirrus-ci.com/task/5233064575500288?logs=ci#L2384

  The failures can also be reproduced by checking out #31741 and building with `cmake -B build -DBUILD_FOR_FUZZING=ON -DSANITIZERS=fuzzer -DENABLE_IPC=ON` with this fix reverted.

  The fix updates the cmake build so when `-DSANITIZERS=fuzzer` is specified, the fuzz test binary is built with `-fsanitize=fuzzer` (so it can use libFuzzer's main function), and libraries are built with `-fsanitize=fuzzer-no-link` (so they can be linked into other executables with their own main functions).

  Previously when `-DSANITIZERS=fuzzer` was specified, `-fsanitize=fuzzer` was applied to ALL libraries and executables. This was inappropriate because it made it impossible to build any executables other than the fuzz test executable without triggering link errors:

  - `` multiple definition of `main' ``
  - `` "undefined reference to `LLVMFuzzerTestOneInput' ``

  if they depended on any libraries instrumented for fuzzing.

  This was especially a problem when the `ENABLE_IPC` option was set because it made building the `mpgen` code generator impossible so nothing else that depended on generated sources, including the fuzz test binary, could be built either.

  This commit was previously part of https://github.com/bitcoin/bitcoin/pull/31741 and had some discussion there starting in https://github.com/bitcoin/bitcoin/pull/31741#pullrequestreview-2619682385

  ---

  This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/issues/28722).

ACKs for top commit:
  hebasto:
    ACK 57d8b1f1b3, tested on Ubuntu 24.04.

Tree-SHA512: 4011adbc0b08742e83cf7c0560d3d5b5694a863358e6ac9a21239626b4a8fedceca66db34b5a46136a7b26849bb1d8710c894689322ae97e1c407687c3f57d50
2025-03-29 10:09:38 +00:00
Ryan Ofsky 9acc25bcb6
Merge bitcoin/bitcoin#32153: wallet: remove redundant `Assert` call when block is disconnected
ae6b6ea296 wallet: remove redundant `Assert` call when block is disconnected (rkrux)

Pull request description:

  It was highlighted in a PR discussion previously that the recently moved `Assert` macro call inside the block disconnected loop had been redundant for quite a while because of the presence of the `assert` macro call at the start of the function. Therefore, it is removed now.

  refs #https://github.com/bitcoin/bitcoin/pull/31757#discussion_r1995416821

ACKs for top commit:
  fjahr:
    utACK ae6b6ea296
  l0rinc:
    crACK ae6b6ea296
  hodlinator:
    Code Review ACK ae6b6ea296
  Prabhat1308:
    Code Review ACK [`ae6b6ea`](ae6b6ea296)

Tree-SHA512: 6bbced88f4b39afcacefb7babe97c180a397d9cd55f18c4c2875bd594547dcdccb2059ac32495e0e8d4e7263b4c1349ca80b2f0fbd46b4450d1d847ba5abd903
2025-03-28 11:14:20 -04:00
merge-script 0a1e36effa
Merge bitcoin/bitcoin#32151: Follow-ups for txgraph #31363
a52b53926b clusterlin: add GetConnectedComponent (Pieter Wuille)
c7d5dcaa61 clusterlin: fix typos (Pieter Wuille)
777179bc27 txgraph: rename group_data in ApplyDependencies (Pieter Wuille)

Pull request description:

  This addresses a few review comments in #31363 after merge:
  * https://github.com/bitcoin/bitcoin/pull/31363#discussion_r2012730654 (rename `group_data` to `group_entry`)
  * https://github.com/bitcoin/bitcoin/pull/31363#discussion_r2015001561 (introduce `GetConnectedComponent` and use it in the txgraph fuzz test).
  * https://github.com/bitcoin/bitcoin/pull/31363#discussion_r2015003889 (typo in `FixLinearization`)
  * https://github.com/bitcoin/bitcoin/pull/32151#discussion_r2015764185 (more typos)

ACKs for top commit:
  instagibbs:
    ACK a52b53926b
  glozow:
    ACK a52b53926b

Tree-SHA512: e8a98101ecb9c09b860306c7fbd22cf20bd12990768879753680dfbf7db31283506d9f30bb7ee726daebd90c34a1c565d07b3e1147b2a87426247acb19058ed3
2025-03-28 10:32:45 +08:00
merge-script e3c4bb12ba
Merge bitcoin/bitcoin#32058: test: get rid of redundant TODO tag
d065208f0f test: get rid of redundant TODO tag (Chandra Pratap)

Pull request description:

  The `FEE` parameter in `test/functional/feature_dbcrash.py::generate_small_transaction()` is not a fee rate, but an absolute fee. Hence, it doesn't make sense to replace it with node relay based fee calculation. Get rid of the TODO comment suggesting otherwise.

ACKs for top commit:
  maflcko:
    lgtm ACK d065208f0f

Tree-SHA512: f2b7f51ffb23de8e14ca071edd731410176a20750115a65db0ae67714389e03ffe1593ce88368e96d211329bd93c772f665de7c3a59b932681bc5b80db908d9f
2025-03-28 10:07:55 +08:00
Ryan Ofsky 930b237f16
Merge bitcoin/bitcoin#31874: qa wallet: Activate dormant checks in wallet_multisig_descriptor_psbt.py
35d17cd5ee qa wallet: Actually make use of expressions (Hodlinator)

Pull request description:

  Conditions had virtually no effect, lets activate them.

ACKs for top commit:
  maflcko:
    lgtm ACK 35d17cd5ee
  ryanofsky:
    Code review ACK 35d17cd5ee
  l0rinc:
    ACK 35d17cd5ee

Tree-SHA512: 852e325714e4f3083e28ef1a91c68250ee536d1c0ed09cac15d2ea74d47cefeffba19df4efe3d25d359ec8bc1588ce5bcf263efbcc2b392d102f5ff5c90307d4
2025-03-27 16:18:52 -04:00
Pieter Wuille a52b53926b clusterlin: add GetConnectedComponent
This abstracts out the finding of the connected component that includes
a given element from FindConnectedComponent (which just finds any connected
component).

Use this in the txgraph fuzz test, which was effectively reimplementing this
logic. At the same time, improve its performance by replacing a vector with a
set.
2025-03-27 15:48:44 -04:00
jurraca 6afffba34e contrib: (asmap) add docs about encode and decode commands 2025-03-27 19:46:38 +00:00
jurraca 67d5cc2a06 contrib: (asmap) add documentation on diff and diff-addrs commands 2025-03-27 19:46:38 +00:00
jurraca e047b1deca contrib: (asmap) add diff-addrs example to README
this command exists and works as expected.
2025-03-27 19:46:38 +00:00
Pieter Wuille c7d5dcaa61 clusterlin: fix typos 2025-03-27 12:41:24 -04:00
Pieter Wuille 777179bc27 txgraph: rename group_data in ApplyDependencies 2025-03-27 12:41:24 -04:00
Ryan Ofsky 74c23f80ab
Merge bitcoin/bitcoin#32145: test: Add functional test for bitcoin-chainstate
ca55613fd1 test: Add functional test for bitcoin-chainstate (TheCharlatan)
3f9c716e7f test: Fix docstring for cmake migration (TheCharlatan)

Pull request description:

  While the `bitcoin-chainstate` utility is not shipped in a release, it is the only current utility directly using the bitcoin kernel library. Adding a simple test for it is useful for checking that the library is actually usable. The test is also useful in future to demonstrate that the `bitcoin-chainstate` binary using the API for the kernel library introduced in #30595 actually works and offers similar features.

ACKs for top commit:
  laanwj:
    Code review ACK ca55613fd1
  maflcko:
    ACK ca55613fd1 🎭
  kevkevinpal:
    ACK ca55613fd1

Tree-SHA512: 282627f5fac868a84aab9962ef2cbd3a8d3941d9f9dc2a3f26db1e7706ffa8051637ab5f8372676800e426e077ca40449a9e3e42a003048472339d81ed81bca8
2025-03-27 11:02:01 -04:00
Ryan Ofsky bcb316bd88
Merge bitcoin/bitcoin#32050: test: avoid treating hash results as integers
a82829f37e test: simplify (w)txid checks by avoiding .calc_sha256 calls (Sebastian Falbesoner)
346a099fc1 test: avoid unneeded hash -> uint256 -> hash roundtrips (Sebastian Falbesoner)

Pull request description:

  In the functional test framework we currently have a strong tendency to treat and store identifiers that result from hash functions (e.g. (w)txids, block hashes) as integers, which seems an unnatural and confusing choice. Hashes are just pseudo-random sequences of bytes, and there is usually no need to apply integer operations on them; the only exceptions I could think of is PoW-verification of block hashes with the less-than (`<`) operator, or interpreting the byte-string as scalar in the EC-context for e.g. key derivation.

  I'd hence argue that most uses of `ser_uint256`/`uint256_from_str` and txid conversions via `int(txid/blockhash, 16)` are potential code smells and should be reduced to a minimum long-term if possible. This PR is a first step into this direction, intentionally kept small with (what I think) uncontroversial changes for demonstration purposes, to check out if other contributors are interested in this. A next step could be to change the classes of primitives (CTransaction, CBlock etc.) and network messages (msg_) to store hash results as actual bytes (maybe in a class wrapping the bytes that offers conversion from/to human-readable strings [1], for easier interaction with RPC calls and debug outputs) rather than ints. But that would of course need larger, potentially more controversial changes, and its questionable if its really worth the effort.

  [1] unfortunately, txids and block hashes are shown to user in reverse byte order, so e.g. a txid_bytes->txid_str conversion is not just a simple `txid_bytes.hex()`, but a `txid_bytes[::-1].hex()`

ACKs for top commit:
  maflcko:
    review ACK a82829f37e 🐘
  rkrux:
    Concept and utACK a82829f37e
  ryanofsky:
    Code review ACK a82829f37e. Nice changes, and sorry about the false bug report

Tree-SHA512: bb0465802d743a495207800f922b65f49ed0d20552f95bb0bee764944664092aad74812e29df6e01ef40bcb8f9bc6c84c7e9cbbe6f008ee1a14d94ed88e698b4
2025-03-27 10:30:41 -04:00
MarcoFalke fa6a007b8e
fuzz: Avoid integer sanitizer warnings in policy_estimator target 2025-03-27 11:54:39 +01:00
rkrux ae6b6ea296
wallet: remove redundant `Assert` call when block is disconnected
It was highlighted in a PR discussion previously that the recently
moved `Assert` macro call inside the block disconnected loop had
been redundant for quite a while because of the presence of the
`assert` macro call at the start of the function. Therefore, it
is removed now.

refs #https://github.com/bitcoin/bitcoin/pull/31757#discussion_r1995416821
2025-03-27 16:21:54 +05:30
merge-script a54baa8698
Merge bitcoin/bitcoin#32100: doc: clarify the documentation of `Assume` assertion
329a0dcdaf doc: clarify the documentation of `Assume` (ismaelsadeeq)

Pull request description:

  An Expression inside `Assume` may be optimized away in production builds when the compiler proves they are side-effect-free.
  This use case is demonstrated in #31363 and is suggested to be documented in https://github.com/bitcoin/bitcoin/pull/31363#issuecomment-2736410023.

ACKs for top commit:
  l0rinc:
    ACK 329a0dcdaf
  hodlinator:
    re-ACK 329a0dcdaf
  jonatack:
    ACK 329a0dcdaf
  rkrux:
    re-ACK 329a0dcdaf

Tree-SHA512: 4bbb807a1e632694863c1a1fa2e93cc5a756b19f8d78f0642ebe7ffafb01835765fa66c76a680dc6f3c412a5abb0c4a33fb7212c26b4b2d80b6b3b7ee8284b2e
2025-03-27 15:52:21 +08:00
merge-script b131e1bfc0
Merge bitcoin/bitcoin#32101: Accept unordered tracepoints in interface_usdt_utxocache.py
248fdd88dc test: accept unordered tracepoints in... (willcl-ark)

Pull request description:

  We have encountered an instance where the tracepoints were not collected in the same order they were fired (#31951).

  Tracepoint ordering is not guaranteed in userspace for a number of reasons.

  As this test does not require a strict collection/processing order collect `expected` and `actual` events into dicts and compare them.

  This will gracefully handle both the number of events, and out-of-order events should they reoccur in the future.

  Fixes: #31951

ACKs for top commit:
  0xB10C:
    re-ACK 248fdd88dc
  laanwj:
    Code review ACK 248fdd88dc

Tree-SHA512: 78d1aa936194d386d919ed26133aac3af5fc6d3d0b1fe1e767288d9e6226e2c701d640e71e994a63ccd48344bd2a0db508cb353cdd5ce1f644cd6f7313654623
2025-03-27 15:50:57 +08:00
merge-script 8cc601196b
Merge bitcoin/bitcoin#32129: doc: Update comments for AreInputsStandard to match code
52ede28a8a doc: Update comments for AreInputsStandard to match code (Anthony Towns)

Pull request description:

  The comment about extra data stuffed in scriptSigs was introduced in #4365 which introduced `ScriptSigArgsExpected()`, and became incorrect after #7387 / #7453 (checks are now performed by `SCRIPT_VERIFY_CLEANSTACK` during script validation and `IsPushOnly()` in `IsStandardTx()`). Drops the details on what a p2sh with many checksigs would look like, which was already done in #4365, but only for main.cpp not the duplicated comment in main.h, which was merged into policy/policy.cpp in #6335 and later moved to the right place in #10682.

ACKs for top commit:
  instagibbs:
    ACK 52ede28a8a
  darosior:
    ACK 52ede28a8a

Tree-SHA512: 5ee9a775c81d4c23aca2f8f938ab8bfa7605af489ddb78788613195be8744c7fb7a37bae271093f67f572577452651d4958706b55346e99cf8d32ac0fc34df03
2025-03-27 15:46:04 +08:00
merge-script 140f0d89bf
Merge bitcoin/bitcoin#32027: cmake: Add `NO_CACHE_IF_FAILED` option for checking linker flags
52ac17757e cmake: Add `NO_CACHE_IF_FAILED` option for checking linker flags (Hennadii Stepanov)

Pull request description:

  Use it for checking `-fsanitize`.

  This change improves the user experience when the configuration step fails due to a missing library. Now, there is no need to manually clean the CMake cache after installing the required library.

  Addresses [this](https://github.com/bitcoin/bitcoin/issues/31942#issuecomment-2703801270) comment from https://github.com/bitcoin/bitcoin/issues/31942.

ACKs for top commit:
  fanquake:
    ACK 52ac17757e

Tree-SHA512: 4004110585413792faa01551cf5a5b3b0de7f213c7a1dd333647107741f84abf626fd0ed067fc17e4c5a523de549432738d3752facf25d1e3dab240be8d13d03
2025-03-27 15:44:26 +08:00
merge-script 5dd6ebc7e1
Merge bitcoin/bitcoin#32148: test: fix intermittent timeout in p2p_ibd_stalling.py
9f35d4d070 test: fix intermittent timeout in p2p_ibd_stalling.py (Martin Zumsande)

Pull request description:

  After sending the headers message add a sync, so that we wait until the header message from the previous peer has been received before connecting additional peers.
  In the failed NetBSD run linked in #32090, the second node managed to complete the handshake and send its own headers message before the message from the first node was received.

  Fixes #32090

ACKs for top commit:
  maflcko:
    lgtm ACK 9f35d4d070

Tree-SHA512: 30a98c6ec04f819c892ab5ce76a309df81b3a4644be021f938eefddbd00ec4141e055c3cf735c9e04ce2fe9e950470a99d54cb6be43230110348a802a6a6c252
2025-03-27 15:42:18 +08:00
merge-script b413b088ae
Merge bitcoin/bitcoin#32141: fuzz: extract unsequenced operations with side-effects
b1de59e896 fuzz: extract unsequenced operations with side-effects (Lőrinc)

Pull request description:

  https://github.com/bitcoin/bitcoin/pull/30746#discussion_r1817851827 introduced unsequenced operations with side-effects - which is undefined behavior, i.e. the right hand side can be evaluated before the left hand side, which happens to mutate it.

  <details>
  <summary>Tried to find other occurrences</summary>

  ```bash
  clang++ --analyze -std=c++20 -I./src -I./src/test -I./src/test/fuzz src/test/fuzz/base_encode_decode.cpp src/psbt.cpp
  ```
  but it didn't warn about UB.

  Grepped for similar ones, but could find any other one in the codebase:
  ```bash
  > grep -rnE --include='*.cpp' --include='*.h' '\b(\w+)\(([^)]*\b(\w+)\b[^)]*)\)\s*==\s*\3\.' .

  ./src/test/arith_uint256_tests.cpp:373:    BOOST_CHECK(R1L.GetHex() == R1L.ToString());
  ./src/test/arith_uint256_tests.cpp:374:    BOOST_CHECK(R2L.GetHex() == R2L.ToString());
  ./src/test/arith_uint256_tests.cpp:375:    BOOST_CHECK(OneL.GetHex() == OneL.ToString());
  ./src/test/arith_uint256_tests.cpp:376:    BOOST_CHECK(MaxL.GetHex() == MaxL.ToString());
  ./src/test/fuzz/cluster_linearize.cpp:565:        assert(depgraph.FeeRate(best_anc.transactions) == best_anc.feerate);
  ./src/test/fuzz/cluster_linearize.cpp:646:        assert(depgraph.FeeRate(found.transactions) == found.feerate);
  ./src/test/fuzz/cluster_linearize.cpp:765:            assert(depgraph.FeeRate(chunk_info.transactions) == chunk_info.feerate);
  ./src/test/fuzz/base_encode_decode.cpp:95:    assert(DecodeBase64PSBT(psbt, random_string, error) == error.empty());
  ./src/test/fuzz/key.cpp:102:        assert(pubkey.data() == pubkey.begin());
  ./src/test/skiplist_tests.cpp:42:        BOOST_CHECK(vIndex[from].GetAncestor(0) == vIndex.data());
  ./src/script/signingprovider.cpp:535:                   ComputeTapbranchHash(node.sub[1]->hash, node.sub[1]->hash) == node.hash) {
  ./src/pubkey.h:78:      return vch.size() > 0 && GetLen(vch[0]) == vch.size();
  ./src/cluster_linearize.h:881:            Assume(elem.inc.feerate.IsEmpty() == elem.pot_feerate.IsEmpty());
  ```

  </details>

  Hodlinator deduced the UB on Windows in https://github.com/bitcoin/bitcoin/issues/32135#issuecomment-2751723855

  Fixes #32135

ACKs for top commit:
  maflcko:
    lgtm ACK b1de59e896
  hodlinator:
    ACK b1de59e896
  marcofleon:
    Nice, ACK b1de59e896
  brunoerg:
    code review ACK b1de59e896

Tree-SHA512: d66524424c7f749eba870f5bd6038da79666ac638047b31dd8ff15a77d927facb54b4735e8afb7984648fdc9e2dd59ea213996c352301fa05978f041511361d4
2025-03-27 15:37:36 +08:00
merge-script e563cb5c60
Merge bitcoin/bitcoin#31849: depends: set `CMAKE_*_COMPILER_TARGET` in toolchain
963355037f depends: set CMAKE_*_COMPILER_TARGET in toolchain (fanquake)

Pull request description:

  According to the CMake docs, this is the correct way to setup a toolchain file for cross-compilation using Clang. See https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-using-clang

  Internally it looks like CMake will only take this variable into account if it detects the compiler to be Clang, so this shouldn't effect other builds, but in the case of our Apple cross builds, we'd end up with a duplicated `--target=$ARCH-apple-darwin` on the compiler line, given we are already setting `--target` for Darwin builds.

  Would fix #31748.

ACKs for top commit:
  hebasto:
    ACK 963355037f, tested on Ubuntu 24.10.

Tree-SHA512: 1aa0c5d9cb069ce277e53b5551baf5249c449331b0a160edb9a8ceb56209f886a9e2051e2ba63e0874904f652ace0280b7483dd5d81bfff9e993eb18abb961ad
2025-03-27 15:35:04 +08:00
merge-script 603fcc07d5
Merge bitcoin/bitcoin#31896: refactor: Remove redundant and confusing calls to IsArgSet
0000fb3fd9 doc: Remove outdated and stale todo comment (MarcoFalke)
fa2b529f92 refactor: Remove redundant call to IsArgSet (MarcoFalke)
fa29842c1f refactor: Remove IsArgSet guard when fallback value is provided (MarcoFalke)

Pull request description:

  `IsArgSet` is problematic:

  * It returns whether an arg has been set, even if it has been negated. `IsArgSet` is sometimes used to check for a truthy value, which is wrong, but usually harmless. Cleanup of those cases may or may not be done in a follow-up.
  * In most other cases, calling it is redundant, because the immediately following `Get*Arg` calls can already return an `std::optional` nullopt value to indicate an unset arg.

  So relieve both issues by removing all `IsArgSet` that are redundant.

ACKs for top commit:
  pablomartin4btc:
    re-ACK 0000fb3fd9
  ryanofsky:
    Code review ACK 0000fb3fd9. No changes since last review other than rebase.

Tree-SHA512: d142d71d136b2dbd5fd005667875099777704176f5e08fdeb38f05d6afce40b435a257c5bb6a1f545459fe4f81f967cee3083ab666cb0befdef3f6234f1e3d32
2025-03-27 15:33:11 +08:00
merge-script 84bbb40558
Merge bitcoin/bitcoin#32132: build: Remove bitness suffix from Windows installer
fb2b05b125 build: Remove bitness suffix from Windows installer (Hennadii Stepanov)

Pull request description:

  Since support for 32-bit Windows has been dropped, the suffix is no longer necessary.

ACKs for top commit:
  l0rinc:
    utACK fb2b05b125
  hodlinator:
    ACK fb2b05b125
  laanwj:
    ACK fb2b05b125

Tree-SHA512: cef18ddbc21bb8b57fd1f6b26d0c8bdee4aa47a20552c1f02ac7fcc084ab9887dcb2632c9e0915fbce156d843625aaad01a3ad5e11fbed56548e404719cc9a52
2025-03-27 15:23:36 +08:00
merge-script 6971d3a0f5
Merge bitcoin/bitcoin#32144: lint: Remove needless borrow to fix Clippy warning
e3ce2bd982 Remove needless borrow to fix Clippy warning (dennsikl)

Pull request description:

  Pull Request Description

  **Summary**
  Removes a needless borrow in `test/lint/test_runner/src/main.rs` that triggered a
  Clippy warning (`needless_borrows_for_generic_args`). This minor refactoring
  makes the code cleaner without changing functionality.

  **Rationale**
  - Eliminates a Clippy warning when running:
    ```bash
    cargo clippy --manifest-path test/lint/test_runner/Cargo.toml -- -D warnings

ACKs for top commit:
  maflcko:
    lgtm ACK e3ce2bd982
  kevkevinpal:
    ACK [e3ce2bd](e3ce2bd982)
  TheCharlatan:
    ACK e3ce2bd982

Tree-SHA512: 9f3e07b45df0af6ad4bf87216b257108cc9b50b8e6bc591cac58b5cf6f78ebaeff27181cb0e8a6bc401626e1c707b925315f2e5ebd8dd5216e04c95d70237f85
2025-03-27 15:00:11 +08:00
merge-script f1d129d963
Merge bitcoin/bitcoin#31363: cluster mempool: introduce TxGraph
b2ea365648 txgraph: Add Get{Ancestors,Descendants}Union functions (feature) (Pieter Wuille)
54bceddd3a txgraph: Multiple inputs to Get{Ancestors,Descendant}Refs (preparation) (Pieter Wuille)
aded047019 txgraph: Add CountDistinctClusters function (feature) (Pieter Wuille)
b685d322c9 txgraph: Add DoWork function (feature) (Pieter Wuille)
295a1ca8bb txgraph: Expose ability to compare transactions (feature) (Pieter Wuille)
22c68cd153 txgraph: Allow Refs to outlive the TxGraph (feature) (Pieter Wuille)
82fa3573e1 txgraph: Destroying Ref means removing transaction (feature) (Pieter Wuille)
6b037ceddf txgraph: Cache oversizedness of graphs (optimization) (Pieter Wuille)
8c70688965 txgraph: Add staging support (feature) (Pieter Wuille)
c99c7300b4 txgraph: Abstract out ClearLocator (refactor) (Pieter Wuille)
34aa3da5ad txgraph: Group per-graph data in ClusterSet (refactor) (Pieter Wuille)
36dd5edca5 txgraph: Special-case removal of tail of cluster (Optimization) (Pieter Wuille)
5801e0fb2b txgraph: Delay chunking while sub-acceptable (optimization) (Pieter Wuille)
57f5499882 txgraph: Avoid looking up the same child cluster repeatedly (optimization) (Pieter Wuille)
1171953ac6 txgraph: Avoid representative lookup for each dependency (optimization) (Pieter Wuille)
64f69ec8c3 txgraph: Make max cluster count configurable and "oversize" state (feature) (Pieter Wuille)
1d27b74c8e txgraph: Add GetChunkFeerate function (feature) (Pieter Wuille)
c80aecc24d txgraph: Avoid per-group vectors for clusters & dependencies (optimization) (Pieter Wuille)
ee57e93099 txgraph: Add internal sanity check function (tests) (Pieter Wuille)
05abf336f9 txgraph: Add simulation fuzz test (tests) (Pieter Wuille)
8ad3ed2681 txgraph: Add initial version (feature) (Pieter Wuille)
6eab3b2d73 feefrac: Introduce tagged wrappers to distinguish vsize/WU rates (Pieter Wuille)
d449773899 scripted-diff: (refactor) ClusterIndex -> DepGraphIndex (Pieter Wuille)
bfeb69f6e0 clusterlin: Make IsAcyclic() a DepGraph member function (Pieter Wuille)
0aa874a357 clusterlin: Add FixLinearization function + fuzz test (Pieter Wuille)

Pull request description:

  Part of cluster mempool: #30289.

  ### 1. Overview

  This introduces the `TxGraph` class, which encapsulates knowledge about the (effective) fees, sizes, and dependencies between all mempool transactions, but nothing else. In particular, it lacks knowledge about `CTransaction`, inputs, outputs, txids, wtxids, prioritization, validatity, policy rules, and a lot more. Being restricted to just those aspects of the mempool makes the behavior very easy to fully specify (ignoring the actual linearizations produced), and write simulation-based tests for (which are included in this PR).

  ### 2. Interface

  The interface can be largely categorized into:
  * Mutation functions:
    * `AddTransaction` (add a new transaction with specified feerate, and get a `Ref` object back to identify it).
    * `RemoveTransaction` (given a `Ref` object, remove the transaction).
    * `AddDependency` (given two `Ref` objects, add a dependency between them).
    * `SetTransactionFee` (modify the fee associated with a Ref object).
  * Inspector functions:
    * `GetAncestors` (get the ancestor set in the form of `Ref*` pointers)
    * `GetAncestorsUnion` (like above, but for the union of ancestors of multiple `Ref*` pointers)
    * `GetDescendants` (get the descendant set in the form of `Ref*` pointers)
    * `GetDescendantsUnion` (like above, but for the union of ancestors of multiple `Ref*` pointers)
    * `GetCluster` (get the connected component set in the form of `Ref*` pointers, in the order they would be mined).
    * `GetIndividualFeerate` (get the feerate of a transaction)
    * `GetChunkFeerate` (get the mining score of a transaction)
    * `CountDistinctClusters` (count the number of distinct clusters a list of `Ref`s belong to)
  * Staging functions:
    * `StartStaging` (make all future mutations operate on a proposed transaction graph)
    * `CommitStaging` (apply all the changes that are staged)
    * `AbortStaging` (discard all the changes that are staged)
  * Miscellaneous functions:
    * `DoWork` (do queued-up computations now, so that future operations are fast)

  This `TxGraph::Ref` type used as a "handle" on transactions in the graph can be inherited from, and the idea is that in the full cluster mempool implementation (#28676, after it is rebased on this), `CTxMempoolEntry` will inherit from it, and all actually used Ref objects will be `CTxMempoolEntry`s. With that, the mempool code can just cast any `Ref*` returned by txgraph to `CTxMempoolEntry*`.

  ### 3. Implementation

  Internally the graph data is kept in clustered form (partitioned into connected components), for which linearizations are maintained and updated as needed using the `cluster_linearize.h` algorithms under the hood, but this is hidden from the users of this class. Implementation-wise, mutations are generally applied lazily, appending to queues of to-be-removed transactions and to-be-added dependencies, so they can be batched for higher performance. Inspectors will generally only evaluate as much as is needed to answer queries, with roughly 5 levels of processing to go to fully instantiated and acceptable cluster linearizations, in order:
  1. `ApplyRemovals` (take batches of to-be-removed transactions and translate them to "holes" in the corresponding Clusters/DepGraphs).
  2. `SplitAll` (creating holes in Clusters may cause them to break apart into smaller connected components, so make turn them into separate Clusters/linearizations).
  3. `GroupClusters` (figure out which Clusters will need to be combined in order to add requested to-be-added dependencies, as these may span clusters).
  4. `ApplyDependencies` (actually merge Clusters as precomputed by `GroupClusters`, and add the dependencies between them).
  5. `MakeAcceptable` (perform the LIMO linearization algorithm on Clusters to make sure their linearizations are acceptable).

  ### 4. Future work

  This is only an initial version of TxGraph, and some functionality is missing before #28676 can be rebased on top of it:
  * The ability to get comparative feerate diagrams before/after for the set of staged changes (to evaluate RBF incentive-compatibility).
  * Mining interface (ability to iterate transactions quickly in mining score order) (see #31444).
  * Eviction interface (reverse of mining order, plus memory usage accounting) (see #31444).
  * Ability to fix oversizedness of clusters (before or after committing) - this is needed for reorgs where aborting/rejecting the change just is not an option (see #31553).
  * Interface for controlling how much effort is spent on LIMO. In this PR it is hardcoded.

  Then there are further improvements possible which would not block other work:
  * Making Cluster a virtual class with different implementations based on transaction count (which could dramatically reduce memory usage, as most Clusters are just a single transaction, for which the current implementation is overkill).
  * The ability to have background thread(s) for improving cluster linearizations.

ACKs for top commit:
  instagibbs:
    reACK b2ea365648
  ajtowns:
    reACK b2ea365648
  ismaelsadeeq:
    reACK  b2ea365648 🚀
  glozow:
    ACK b2ea365648

Tree-SHA512: 0f86f73d37651fe47d469db1384503bbd1237b4556e5d50b1d0a3dd27754792d6fc3481f77a201cf2ed36c6ca76e0e44c30e175d112aacb53dfdb9e11d8abc6b
2025-03-26 17:39:06 -04:00
Martin Zumsande 9f35d4d070 test: fix intermittent timeout in p2p_ibd_stalling.py
by adding a sync, so that we wait until the header message from the
previous peer has been received before connecting additional peers.
2025-03-26 13:22:07 -04:00
Chandra Pratap d065208f0f test: get rid of redundant TODO tag
The 'FEE' parameter in test/functional/feature_dbcrash.py::
generate_small_transaction() is not a fee rate, but an
absolute fee. Hence, it doesn't make sense to replace it
with node relay based fee calculation. Get rid of the TODO
comment suggesting otherwise.
2025-03-26 16:44:48 +00:00
willcl-ark 248fdd88dc
test: accept unordered tracepoints in...
...interface_usdt_utxocache.py

We have encountered an instance where the tracepoints were not collected
in the same order they were fired (#31951).

Tracepoint ordering is not guaranteed in userspace for a number of
reasons.

As this test does not require a strict collection/processing order
collect `expected` and `actual` events into dicts and compare them.

This will gracefully handle both the number of events, and out-of-order
events should they reoccur in the future.
2025-03-26 14:13:09 +00:00
TheCharlatan ca55613fd1
test: Add functional test for bitcoin-chainstate
Adds basic coverage for successfully validating a mainnet block as well
as some duplicate and invalid data.
2025-03-26 15:05:17 +01:00
rkrux 32dcec269b
rpc: update RPC help of `createpsbt`
Update the example wherein the PSBT sends bitcoin to an address instead
of creating an OP_RETURN output. Also, update the RPC description to
reflect the fact that the created transaction is unsigned.
2025-03-26 18:56:45 +05:30
rkrux 931117a46f
rpc: update the doc for `data` field in `outputs` argument
This affects docs of the following RPCs:
`bumpfee`, `psbtbumpfee`, `send`, `walletcreatefundedpsbt`, `createpsbt`,
and `createrawtransaction`

It was not evident to me that this field creates an `OP_RETURN` output until
I read the code and tried it out. Thus, making the doc explicitly mention it.
2025-03-26 18:55:58 +05:30
Sjors Provoost aa7a898c23
doc: use testnet4 in developer docs 2025-03-26 12:29:05 +01:00
Sjors Provoost 6c217d22fd
test: use testnet4 in argsman test 2025-03-26 12:29:04 +01:00
Sjors Provoost 7c200ece80
test: use testnet4 in key_io_valid.json 2025-03-26 12:29:04 +01:00
Sjors Provoost d424bd5941
test: drop unused testnet3 magic bytes 2025-03-26 12:29:04 +01:00
Sjors Provoost 8cfc09fafe
test: cover testnet4 magic in assumeutxo.py
Replace testnet3 and use MAGIC_BYTES constants.
2025-03-26 12:29:04 +01:00
Sjors Provoost 4281e3603a
zmq: use testnet4 in zmq_sub.py example 2025-03-26 12:28:27 +01:00
TheCharlatan 3f9c716e7f
test: Fix docstring for cmake migration 2025-03-26 10:57:23 +01:00
Anthony Towns 52ede28a8a doc: Update comments for AreInputsStandard to match code 2025-03-26 18:58:02 +10:00
Hodlinator 35d17cd5ee
qa wallet: Actually make use of expressions
They were basically no-ops.
2025-03-26 09:47:38 +01:00
Prabhat Verma b96f1a696a add clang/llvm based coverage report generation
Signed-off-by: Prabhat Verma <prabhatverma329@gmail.com>
2025-03-26 14:07:59 +05:30
dennsikl e3ce2bd982 Remove needless borrow to fix Clippy warning 2025-03-26 09:07:11 +02:00
merge-script c0b7159de4
Merge bitcoin/bitcoin#32122: fuzz: Fix off-by-one in package_rbf target
fa5674c264 fuzz: Fix off-by-one in package_rbf target (MarcoFalke)

Pull request description:

  Running the while loop up to `NUM_ITERS` times may set `iter` to `g_outpoints.size()`, which will then lead to an out-of-bounds read.

  There was an assert, which I guess tried to catch this, but the condition in the assert was wrong as well.

  Fix all issues by replacing the broken assert with the internal and correct check inside `std::vector::at` and by limiting `iter` to `NUM_ITERS` in the while loop.

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

ACKs for top commit:
  glozow:
    ACK fa5674c264
  brunoerg:
    code review ACK fa5674c264

Tree-SHA512: 91b849ce969fd25c0ff8c90c2908d3096c77607d8e5fd81201ef33d88a57760199618174b8a6fd634cb5ef2a9068e94703b5c963ca473bd96a14d4bf9ec835cb
2025-03-25 16:57:38 -04:00
Lőrinc b1de59e896 fuzz: extract unsequenced operations with side-effects
https://github.com/bitcoin/bitcoin/pull/30746#discussion_r1817851827 introduced an unsequenced operations with side-effects - which is undefined behavior, i.e. the right hand side can be evaluated before the left hand side, which happens to mutate it.

Tried:
```
clang++ --analyze -std=c++20 -I./src -I./src/test -I./src/test/fuzz src/test/fuzz/base_encode_decode.cpp src/psbt.cpp
```
but it didn't warn about UB.

Grepped for similar ones, but could find any other one in the codebase:
> grep -rnE --include='*.cpp' --include='*.h' '\b(\w+)\(([^)]*\b(\w+)\b[^)]*)\)\s*==\s*\3\.' .
```
./src/test/arith_uint256_tests.cpp:373:    BOOST_CHECK(R1L.GetHex() == R1L.ToString());
./src/test/arith_uint256_tests.cpp:374:    BOOST_CHECK(R2L.GetHex() == R2L.ToString());
./src/test/arith_uint256_tests.cpp:375:    BOOST_CHECK(OneL.GetHex() == OneL.ToString());
./src/test/arith_uint256_tests.cpp:376:    BOOST_CHECK(MaxL.GetHex() == MaxL.ToString());
./src/test/fuzz/cluster_linearize.cpp:565:        assert(depgraph.FeeRate(best_anc.transactions) == best_anc.feerate);
./src/test/fuzz/cluster_linearize.cpp:646:        assert(depgraph.FeeRate(found.transactions) == found.feerate);
./src/test/fuzz/cluster_linearize.cpp:765:            assert(depgraph.FeeRate(chunk_info.transactions) == chunk_info.feerate);
./src/test/fuzz/base_encode_decode.cpp:95:    assert(DecodeBase64PSBT(psbt, random_string, error) == error.empty());
./src/test/fuzz/key.cpp:102:        assert(pubkey.data() == pubkey.begin());
./src/test/skiplist_tests.cpp:42:        BOOST_CHECK(vIndex[from].GetAncestor(0) == vIndex.data());
./src/script/signingprovider.cpp:535:                   ComputeTapbranchHash(node.sub[1]->hash, node.sub[1]->hash) == node.hash) {
./src/pubkey.h:78:      return vch.size() > 0 && GetLen(vch[0]) == vch.size();
./src/cluster_linearize.h:881:            Assume(elem.inc.feerate.IsEmpty() == elem.pot_feerate.IsEmpty());
```

Hodlinator deduced the UB on Windows in https://github.com/bitcoin/bitcoin/issues/32135#issuecomment-2751723855

Co-authored-by: Hodlinator <172445034+hodlinator@users.noreply.github.com>
2025-03-25 21:21:27 +01:00
Hodlinator 99a92efdd9
descriptors doc: Correct Markdown format + wording 2025-03-25 21:13:35 +01:00
merge-script dfb7d58108
Merge bitcoin/bitcoin#31897: mining: drop unused -nFees and sigops from CBlockTemplate
226d81f8b7 mining: drop unused -nFees and sigops from CBlockTemplate (Sjors Provoost)
53ad845fb9 test: check fees and sigops in getblocktemplate (Sjors Provoost)

Pull request description:

  For the coinbase `vTxFees` used a dummy value of -nFees.

  Similarly the first `vTxSigOpsCost` entry was calculated from
  the dummy coinbase transaction.

  This was introduced in #2115, but the values were never returned by the RPC or used in a test.

  Drop 'm and add code comments to prevent confusion.

  This PR also adds test coverage for the `fees` and `sigops` fields in `getblocktemplate`, so it closes #32053.

ACKs for top commit:
  ismaelsadeeq:
    re-ACK 226d81f8b7
  ryanofsky:
    Code review ACK 226d81f8b7. New test was added since last review, which seems very cleanly written and fixes some missing coverage.
  glozow:
    ACK 226d81f8b7

Tree-SHA512: 79c534e6bc4810d29114b04dd6db798877732cb473e773bf3cc28f83d14ee3982392587bd0baa39857bd53a79eae3b730d7a7029b08a9b6c3b5c51f86657ca5d
2025-03-25 08:41:59 -04:00
naiyoma 535b874707 test: Combine rpcwhitelistdefault functions
Replace test_rpcwhitelistdefault_0_no_permissions and
test_rpcwhitelistdefault_1_no_permissions with a single
test_rpcwhitelistdefault_permissions function.
2025-03-25 12:50:23 +03:00
MarcoFalke 0000fb3fd9
doc: Remove outdated and stale todo comment
If anything is left to be done, a new discussion issue or pull request
can be created.
2025-03-25 10:38:34 +01:00
MarcoFalke fa2b529f92
refactor: Remove redundant call to IsArgSet
Checking for IsArgSet before calling GetArg while providing an arbitrary
default value as fallback is both confusing and fragile.

It is confusing, because the provided fallback is dead code. So it would
be better to just call GetArg without a fallback.

Even better would be to provide the true fallback value and sanitize it
as if it were user-input, but this can be done in a follow-up.

Removing the redundant call to IsArgSet will have to be done either way,
so do it now.
2025-03-25 10:38:00 +01:00
MarcoFalke fa29842c1f
refactor: Remove IsArgSet guard when fallback value is provided
Checking for IsArgSet before calling GetArg while providing the args
default value as fallback is both confusing and fragile.

It is confusing, because the provided fallback is dead code. So it would
be better to just call GetArg without a fallback.

However, ignoring the fallback value is fragile, because it would not be
sanitized.

Fix all issues by sanitizing the fallback value.
2025-03-25 10:37:42 +01:00
naiyoma 2b6ce9254d test: Update permissions and string formatting
Update get_permissions function to remove unnecessary replace() and
improve password for strangedude6. Change all string concatenation to f-strings.
2025-03-25 12:37:30 +03:00
MarcoFalke fa5674c264
fuzz: Fix off-by-one in package_rbf target 2025-03-25 09:38:25 +01:00
Ryan Ofsky 1d281daf86
Merge bitcoin/bitcoin#32095: doc: clarify that testnet min-difficulty is not optional
288481aabd doc: clarify that testnet min-difficulty is not optional (Sjors Provoost)

Pull request description:

  When 20 minutes have gone by on testnet3 or testnet4, the next block `MUST` have difficulty 1. I've seen people be confused about this several times now in recent months. It doesn't help that the code comment is wrong. So fixing that.

  The reason is that `nBits` must match exactly:

  e568c1dd13/src/validation.cpp (L4212-L4215)

ACKs for top commit:
  fjahr:
    ACK 288481aabd
  kevkevinpal:
    ACK [288481a](288481aabd)

Tree-SHA512: 17d426301f386fa5810cceedfdb20a3523ab3ac2f17257ca7a525edd869fa409b150eff4cc258b27adecd0ded1c18ff48a9998fc9caed2faa461e410d4c5a884
2025-03-24 17:40:03 -04:00
Ryan Ofsky a0d737cd7a
Merge bitcoin/bitcoin#32073: net: Block v2->v1 transport downgrade if !fNetworkActive
6869fb4170 net: Block v2->v1 transport downgrade if !CConnman::fNetworkActive (Hodlinator)

Pull request description:

  We might have just set `CNode::fDisconnect` in the first loop because of `!CConnman::fNetworkActive`.

  Attempting to reconnect using v1 transport just because `fNetworkActive` was set to `false` at the "right" stage in the v2 handshake does not make sense.

  Issue [discovered](https://github.com/bitcoin/bitcoin/pull/31633#discussion_r1930908304) by davidgumberg.

ACKs for top commit:
  davidgumberg:
    Tested and Reviewed ACK 6869fb4170
  mabu44:
    ACK 6869fb4170
  stratospher:
    ACK 6869fb4. I've reviewed the code but don't have strong preference for this branch vs master since only functional change is just a single log not being printed in a low probability scenario (we happen to be attempting v2 connection when P2P network activity is being turned off).
  vasild:
    ACK 6869fb4170

Tree-SHA512: 54f596e54c5a6546f2c3fec2609aa8d10dec3adcf1001ca16666d8b374b8d79d64397f46c90d9b3915b4e91a5041b6ced3044fd2a5b4fb4aa7282eb51f61296a
2025-03-24 16:54:40 -04:00
David Gumberg 77e553ab6a build: refactor: hardening flags -> core_interface 2025-03-24 13:38:12 -07:00
David Gumberg 00ba3ba303 build: Drop option for disabling hardening
Building unhardened executables is not a supported use case that should
be maintained and those that want unhardened executables can still
override them by appending disable flags.

For example:

cmake -B build -DAPPEND_CPPFLAGS='-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -fno-stack-protector -fcf-protection=none -fno-stack-clash-protection' -DAPPEND_LDFLAGS='-Wl,-z,lazy -Wl,-z,norelro -Wl,-z,noseparate-code'
2025-03-24 13:37:49 -07:00
David Gumberg f57db75e91 build: Use `-z noseparate-code` on NetBSD < 11.0
This can be dropped once Bitcoin Core no longer supports NetBSD 10.0 or
if upstream fix is backported.

NetBSD's dynamic linker ld.elf_so < 11.0 supports exactly 2 `PT_LOAD`
segments and binaries linked with `-z separate-code` have 4 `PT_LOAD`
segments.

https://github.com/bitcoin/bitcoin/pull/28724#issuecomment-2589347934
https://mail-index.netbsd.org/tech-userlevel/2023/01/05/msg013666.html
2025-03-24 13:37:10 -07:00
Ryan Ofsky b3162d10ea
Merge bitcoin/bitcoin#31656: test: Add expected result assertions
a015b7e13d test: Add expected result assertions (yancy)

Pull request description:

  ~This is a trivial addition to the test suit, however it shouldn't be required to add debug statements and manually run the tests if someone needs to know the results of this test.~

  Add an assertion for the values returned. The goal of the test is to show that a minimal weight selection of UTXOs is returned by coin-grinder. Since there are multiple possible solutions, the added assertion shows that coin-grinder finds the solution with the lowest weight.  Without this assertion, it's ambiguous whether or not coin-grinder is returning the solution with the lowest weight.

  Remove the check that a result is returned since the expected result assertion implies a result.

ACKs for top commit:
  janb84:
    re ACK [a015b7e](a015b7e13d)
  murchandamus:
    ACK a015b7e13d

Tree-SHA512: ee3c2688b4a4a07ab209f7655c3956e62a1084419df5e87c27d751a38ff64d4c3457df2317f8077149a6947cdb05b249975de2b8f0e18ca8b17b41f4735fb1c6
2025-03-24 16:07:30 -04:00
Ryan Ofsky 5f3848c63b
Merge bitcoin/bitcoin#31278: wallet, rpc: deprecate settxfee and paytxfee
2f2ab47bf7 Release notes (Pol Espinasa)
bf194c920c wallet, rpc: deprecate settxfee and paytxfee (Pol Espinasa)

Pull request description:

  **Summary**

  This PR deprecates the settxfee RPC and paytxfee setting, marking it for removal in Bitcoin Core 31.0.

  **Motivation**

  The PR was initially motivated by https://github.com/bitcoin/bitcoin/issues/31088. The intention was to create a new function `settxfeerate` to allow users to set a static fee rate in `sat/vB` instead of `btc/kvB`.

  The `settxfee` RPC allows users to set a static fee rate for all transactions created by the wallet. However, in a dynamic fee environment, this can lead to poor fee choices, either overpaying when the mempool is empty or underpaying when congestion is high. The preferred approach is to rely on fee estimation, which is designed to adapt to network conditions, and is the one by default. Same argument apply for `paytxfee` setting.

  During discussion the consensus was that static fee settings are a footgun and that users should instead specify the fee rate per transaction if they don't want to rely on the fee estimation. Given this, rather than introducing a `settxfeerate` alternative, this PR goes towards removing `settxfee` and `paytxfee` entirely.

  **Key Changes**

  `settxfee` and `paytxfee` is now deprecated and will be removed in Bitcoin Core 31.0.
  Users should rely on fee estimation or explicitly specify a fee rate when constructing transactions.

  **Impact on Users**

  If users currently use settxfee or paytxfee, they should transition to specifying fees per transaction.
  No immediate breakage in 30.0 (must use `-deprecatedrpc=settxfee`), but `settxfee` and `paytxfee` will be removed in 31.0.

  **Alternative Approaches Considered**

  A settxfeerate alternative (using sat/vB) was initially proposed but ultimately rejected in favor of deprecating static fee setting entirely.

  **Notes for removal**
  - When removing paytxfee we should also update txconfirmtarget startup option help text.
  - Get back the comment from `rpc_deprecated.py` test. [+info](https://github.com/bitcoin/bitcoin/pull/31278#discussion_r1998876768)

ACKs for top commit:
  fjahr:
    re-ACK 2f2ab47bf7
  ismaelsadeeq:
    re-ACK 2f2ab47bf7
  rkrux:
    Concept and utACK 2f2ab47bf7

Tree-SHA512: 0272812cbe5a519737c5d0683acc2072e67559792b4a6472bca8b23426e5ce9e88a3a1eba987feda70a082b8b474b3126893848628d7bf11e1520357b18c8d3e
2025-03-24 13:40:31 -04:00
ismaelsadeeq 329a0dcdaf
doc: clarify the documentation of `Assume` 2025-03-24 15:28:41 +01:00
Hennadii Stepanov fb2b05b125
build: Remove bitness suffix from Windows installer
Since support for 32-bit Windows has been dropped, the suffix is no
longer necessary.
2025-03-24 14:19:11 +00:00
Pieter Wuille b2ea365648 txgraph: Add Get{Ancestors,Descendants}Union functions (feature)
Like GetAncestors and GetDescendants, but for the union of multiple inputs.
2025-03-24 10:03:06 -04:00
Pieter Wuille 54bceddd3a txgraph: Multiple inputs to Get{Ancestors,Descendant}Refs (preparation)
This is a preparation for the next commit, which adds a feature to request
the Refs to multiple ancestors/descendants at once.
2025-03-24 10:03:06 -04:00
Pieter Wuille aded047019 txgraph: Add CountDistinctClusters function (feature) 2025-03-24 10:03:06 -04:00
Pieter Wuille b685d322c9 txgraph: Add DoWork function (feature)
This can be called when the caller has time to spend now, and wants future operations
to be fast.
2025-03-24 10:03:06 -04:00
Pieter Wuille 295a1ca8bb txgraph: Expose ability to compare transactions (feature)
In order to make it possible for higher layers to compare transaction quality
(ordering within the implicit total ordering on the mempool), expose a comparison
function and test it.
2025-03-24 10:03:06 -04:00
Pieter Wuille 22c68cd153 txgraph: Allow Refs to outlive the TxGraph (feature) 2025-03-24 10:03:06 -04:00
Pieter Wuille 82fa3573e1 txgraph: Destroying Ref means removing transaction (feature)
Before this commit, if a TxGraph::Ref object is destroyed, it becomes impossible
to refer to, but the actual corresponding transaction node in the TxGraph remains,
and remains indefinitely as there is no way to remove it.

Fix this by making the destruction of TxGraph::Ref trigger immediate removal of
the corresponding transaction in TxGraph, both in main and staging if it exists.
2025-03-24 10:03:06 -04:00
Pieter Wuille 6b037ceddf txgraph: Cache oversizedness of graphs (optimization) 2025-03-24 10:03:06 -04:00
Pieter Wuille 8c70688965 txgraph: Add staging support (feature)
In order to make it easy to evaluate proposed changes to a TxGraph, introduce a
"staging" mode, where mutators (AddTransaction, AddDependency, RemoveTransaction)
do not modify the actual graph, but just a staging version of it. That staging
graph can then be commited (replacing the main one with it), or aborted (discarding
the staging).
2025-03-24 10:03:05 -04:00
Pieter Wuille c99c7300b4 txgraph: Abstract out ClearLocator (refactor)
Move a number of related modifications to TxGraphImpl into a separate
function for removal of transactions. This is preparation for a later
commit where this will be useful in more than one place.
2025-03-24 10:01:51 -04:00
Pieter Wuille 34aa3da5ad txgraph: Group per-graph data in ClusterSet (refactor)
This is a preparation for a next commit where a TxGraph will start representing
potentially two distinct graphs (a main one, and a staging one with proposed
changes).
2025-03-24 10:01:51 -04:00
Pieter Wuille 36dd5edca5 txgraph: Special-case removal of tail of cluster (Optimization)
When transactions are removed from the tail of a cluster, we know the existing
linearization remains acceptable (if it already was), but may just need splitting
and postlinearization, so special case these into separate quality levels.
2025-03-24 10:01:51 -04:00
Pieter Wuille 5801e0fb2b txgraph: Delay chunking while sub-acceptable (optimization)
Chunk-based information (primarily, chunk feerates) are never accessed without
first bringing the relevant Clusters to an "acceptable" quality level. Thus,
while operations are ongoing and Clusters are not acceptable, we can omit
computing the chunkings and chunk feerates for Clusters.
2025-03-24 10:01:51 -04:00
Pieter Wuille 57f5499882 txgraph: Avoid looking up the same child cluster repeatedly (optimization)
Since m_deps_to_add has been sorted by child Cluster* already, all dependencies
with the same child will be processed consecutively. Take advantage of this by
remember the last partition merged with, and reusing that if applicable.
2025-03-24 10:01:51 -04:00
Pieter Wuille 1171953ac6 txgraph: Avoid representative lookup for each dependency (optimization)
The m_deps_to_add vector is sorted by child Cluster*, which matches the
order of an_clusters. This means we can walk through m_deps_to_add while
doing the representative lookups for an_clusters, and reuse them.
2025-03-24 10:01:51 -04:00
Pieter Wuille 64f69ec8c3 txgraph: Make max cluster count configurable and "oversize" state (feature)
Instead of leaving the responsibility on higher layers to guarantee that
no connected component within TxGraph (a barely exposed concept, except through
GetCluster()) exceeds the cluster count limit, move this responsibility to
TxGraph itself:
* TxGraph retains a cluster count limit, but it becomes configurable at construction
  time (this primarily helps with testing that it is properly enforced).
* It is always allowed to perform mutators on TxGraph, even if they would cause the
  cluster count limit to be exceeded. Instead, TxGraph exposes an IsOversized()
  function, which queries whether it is in a special "oversize" state.
* During oversize state, many inspectors are unavailable, but mutators remain valid,
  so the higher layer can "fix" the oversize state before continuing.
2025-03-24 10:01:51 -04:00
Pieter Wuille 1d27b74c8e txgraph: Add GetChunkFeerate function (feature)
This adds a function to query the chunk feerate of a transaction, by caching it
inside the Entry objects.
2025-03-24 10:00:26 -04:00
Pieter Wuille c80aecc24d txgraph: Avoid per-group vectors for clusters & dependencies (optimization)
Instead construct a single vector with the list of all clusters in all groups,
and then store per-group offset/range in that list.

For dependencies, reuse m_deps_to_add, and store offset/range into that.
2025-03-24 09:49:49 -04:00
Pieter Wuille ee57e93099 txgraph: Add internal sanity check function (tests)
To make testing more powerful, expose a function to perform an internal sanity
check on the state of a TxGraph. This is especially important as TxGraphImpl
contains many redundantly represented pieces of information:

* graph contains clusters, which refer to entries, but the entries refer back
* graph maintains pointers to Ref objects, which point back to the graph.

This lets us make sure they are always in sync.
2025-03-24 09:49:49 -04:00
Pieter Wuille 05abf336f9 txgraph: Add simulation fuzz test (tests)
This adds a simulation fuzz test for txgraph, by comparing with a naive
reimplementation that models the entire graph as a single DepGraph, and
clusters in TxGraph as connected components within that DepGraph.
2025-03-24 09:49:49 -04:00
Pieter Wuille 8ad3ed2681 txgraph: Add initial version (feature)
This adds an initial version of the txgraph module, with the TxGraph class.
It encapsulates knowledge about the fees, sizes, and dependencies between all
mempool transactions, but nothing else.

In particular, it lacks knowledge about txids, inputs, outputs, CTransactions,
... and so forth. Instead, it exposes a generic TxGraph::Ref type to reference
nodes in the TxGraph, which can be passed around and stored by layers on top.
2025-03-24 09:49:46 -04:00
Pieter Wuille 6eab3b2d73 feefrac: Introduce tagged wrappers to distinguish vsize/WU rates 2025-03-24 09:34:54 -04:00
Pieter Wuille d449773899 scripted-diff: (refactor) ClusterIndex -> DepGraphIndex
Since cluster_linearize.h does not actually have a Cluster type anymore, it is more
appropriate to rename the index type to DepGraphIndex.

-BEGIN VERIFY SCRIPT-
sed -i 's/Data type to represent transaction indices in clusters./Data type to represent transaction indices in DepGraphs and the clusters they represent./' $(git grep -l 'using ClusterIndex')
sed -i 's|\<ClusterIndex\>|DepGraphIndex|g' $(git grep -l 'ClusterIndex')
-END VERIFY SCRIPT-
2025-03-24 09:34:54 -04:00
Pieter Wuille bfeb69f6e0 clusterlin: Make IsAcyclic() a DepGraph member function
... instead of being a separate test-only function.

Also add a fuzz test for it returning false.
2025-03-24 09:34:54 -04:00
Pieter Wuille 0aa874a357 clusterlin: Add FixLinearization function + fuzz test
This function takes an existing ordering for transactions in a DepGraph, and
makes it a valid linearization for it (i.e., topological). Any topological
prefix of the input remains untouched.
2025-03-24 09:34:54 -04:00
Saikiran 55b931934a removed duplicate calling of GetDescriptorScriptPubKeyMan
Removed duplicate call to GetDescriptorScriptPubKeyMan and
Instead of checking linearly I have used find method so time complexity reduced significantly for GetDescriptorScriptPubKeyMan
after this fix improved performance of importdescriptor part refs #32013.
2025-03-24 17:27:27 +05:30
Sjors Provoost 05117e6e17
rpc: clarify longpoll behavior
Move the comparison to hashWatchedChain inside the while loop.

Although this early return prevents the GetTransactionsUpdated()
call in cases where the tip updates, it's only done to improve
readability. The check itself is very cheap (although a more
useful check might not be).

Also add code comments.
2025-03-24 09:50:35 +01:00
Sjors Provoost 5315278e7c
Have createNewBlock() wait for a tip
- return null on shutdown instead of the last tip
- ignore timeout value node initialization

This allows consumers of BlockTemplate to safely
assume that a tip is connected, instead of having
to account for startup and early shutdown scenarios.
2025-03-24 09:48:49 +01:00
Sebastian Falbesoner 8284229a28 refactor: deduplicate anchor witness program bytes (`0x4e,0x73`)
Co-authored-by: Gregory Sanders <gsanders87@gmail.com>
2025-03-23 21:58:39 +01:00
Sebastian Falbesoner 41f2f058d0 test: add missing segwitv1 test cases to `script_standard_tests` 2025-03-23 21:58:36 +01:00
Ryan Ofsky 770d39a376
Merge bitcoin/bitcoin#31887: CLI cleanups
d423fd9ec8 cli, bugfix: for -getinfo, replace IsArgSet() with GetBoolArg() (Jon Atack)
e99e41b307 cli, refactor: simplify public-only classes with structs (Jon Atack)
fdbfd250fb cli, refactor: deduplicate NetworkStringToId() (Jon Atack)
be82139b2a cli, refactor: simplify DetailsRequested() (Jon Atack)

Pull request description:

  These have been accumulating over the past few years.

  Each is described in its commit message.

ACKs for top commit:
  pablomartin4btc:
    re-ACK d423fd9ec8
  hodlinator:
    Code review ACK d423fd9ec8
  l0rinc:
    ACK d423fd9ec8
  ryanofsky:
    Code review ACK d423fd9ec8, just running clang-format and updating commit messages since last review

Tree-SHA512: a8e5f7827cef308186d5a7c3a627d2cd8f57437f4465d181986e5d3274ff0e2b9faac252dd55d9257d66a7aa99fca62b3000cdc0988d23385df20ff1f870a046
2025-03-23 12:41:08 -04:00
Ryan Ofsky a203928693
Merge bitcoin/bitcoin#30538: Doc: add a comment referencing past vulnerability next to where it was fixed
eb0724f0de doc: banman: reference past vuln due to unbounded banlist (Antoine Poinsot)
ad616b6c01 doc: net: mention past vulnerability as rationale to limit incoming message size (Antoine Poinsot)
4489117c3f doc: txrequest: point to past censorship vulnerability in tx re-request handling (Antoine Poinsot)
68ac9542c4 doc: net_proc: reference past DoS vulnerability in orphan processing (Antoine Poinsot)
c02d9f6dd5 doc: net_proc: reference past defect regarding invalid GETDATA types (Antoine Poinsot)
5e3d9f21df doc: validation: add a reference to historical header spam vulnerability (Antoine Poinsot)

Pull request description:

  It is useful when reading code to have context about why it is written or behaves the way it does. Some instances in this PR may seem obvious but i think nonetheless offer important context to anyone willing to change (or review a change to) this code.

ACKs for top commit:
  ryanofsky:
    Code review ACK eb0724f0de. No changes since last review other than rebase

Tree-SHA512: 271902f45b8130d44153d793bc1096cd22b6ce05494e67c665a5bc45754e3fc72573d303ec8fc7db4098d473760282ddbf0c1cf316947539501dfd8d7d5b8828
2025-03-23 11:12:33 -04:00
Ryan Ofsky b9c281011b
Merge bitcoin/bitcoin#31689: Benchmark Chainstate::ConnectBlock duration
7edaf8b64c Benchmark Chainstate::ConnectBlock duration (Eunovo)

Pull request description:

  Introduce benchmarks to evaluate ConnectBlock performance for:
  - Blocks containing only Schnorr signatures
  - Blocks containing both Schnorr and ECDSA signatures
  - Blocks containing only ECDSA signatures

  The benchmarks in this PR, focus on signature validation. Additional benchmarks may be added in the future to assess other aspects of ConnectBlock.

  This is the first step toward implementing Batch Verification of Schnorr Signatures in Core. It provides a way to test and measure the performance improvements of batch verification on Core.
  For more details on batch validation, refer to the [batch-verify module on secp](https://github.com/bitcoin-core/secp256k1/pull/1134) and [batch-verify on core](https://github.com/bitcoin/bitcoin/pull/29491).

ACKs for top commit:
  josibake:
    reACK 7edaf8b64c
  fjahr:
    utACK 7edaf8b64c
  l0rinc:
    ACK 7edaf8b64c

Tree-SHA512: 883c8a5e4e4de401ffb9ac9b6789b7fe0737afefbdaf02c6d7e1645392efc4f0d2d28b423ba7e34366a33608e0835793f5e7a1312b5c8063de14446319529cc7
2025-03-23 09:03:28 -04:00
fanquake 963355037f
depends: set CMAKE_*_COMPILER_TARGET in toolchain
According to the CMake docs, this is the correct way to setup a
toolchain file for cross-compilation using Clang. See
https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-using-clang

Internally it looks like CMake will only take this variable into account
if it detects the compiler to be Clang, so this shouldn't effect other
builds, but in the case of our Apple cross builds, we'd end up with a
duplicated `--target=arm64-apple-darwin` on the compiler line, given we
are already setting `--target` for Darwin builds.

Would fix #31748.
2025-03-23 11:39:56 +08:00
merge-script af3dee0b8d
Merge bitcoin/bitcoin#32074: contrib: Make deterministic-coverage error messages more readable
fa7a40d952 contrib: Print deterministic-coverage runs (MarcoFalke)
fa751639fb contrib: Make deterministic-coverage error messages more readable (MarcoFalke)

Pull request description:

  This is almost a "refactor" to tidy up the error messages. Apart from the messages, the behavior of the tools is identical.

  This was requested in https://github.com/bitcoin/bitcoin/pull/31901#discussion_r1969502508.

  Previously, the tool would abort the program early on some errors. Now, the tool propagates an `std::result::Result::Err` up to `main` via an early return. Getting rid of the aborts also allows to drop the `RUST_BACKTRACE` env setting.

ACKs for top commit:
  hodlinator:
    re-ACK fa7a40d952
  janb84:
    ACK [fa7a40d](fa7a40d952)

Tree-SHA512: 6c97861306e2fececa14b2d12deafb78995fc2bcf75e4e22773cb0ab4231de78834db9f1f89b30c49d77499433b1c16c1d90b97eb4069c81855bd2a7944b554f
2025-03-22 11:12:14 +08:00
brunoerg 0ff66b1c4a fuzz: coinselection: cover `SetBumpFeeDiscount` 2025-03-21 10:13:36 -03:00
brunoerg 28dc118001 fuzz: wallet: fix crypter target 2025-03-21 10:09:47 -03:00
merge-script 8046759305
Merge bitcoin/bitcoin#31870: fuzz: split `coinselection` harness
ba82240553 fuzz: split `coinselection` harness (brunoerg)

Pull request description:

  This PR splits the `coinselection` fuzz harness into 3 targets (`coinselection_bnb`, `coinselection_knapsack`, `coinselection_srd`). The goal is to be able to fuzz each algorithm separately (to avoid performance issues) and also all of them together.

ACKs for top commit:
  janb84:
    Tested ACK [ba82240](ba82240553)
  maflcko:
    review ACK ba82240553 👐
  marcofleon:
    reACK ba82240553
  zaidmstrr:
    reACK [ba82240](ba82240553)

Tree-SHA512: 277cffd524e57d286dbbbcb2aa0a9f1d720b4c56331dfb0f4425e1666246330616508e47977da23f28a72705aa142bbaf536e2cf7fe4703a2cd2e4b2fd441d9d
2025-03-21 18:40:09 +08:00
merge-script 2db00278ea
Merge bitcoin/bitcoin#31910: qa: fix an off-by-one in utxo snapshot fuzz target and sanity check its snapshot data
63b534f97e fuzz: sanity check hardcoded snapshot in utxo_snapshot target (Antoine Poinsot)
3b85eba83a test util: split up ConnectBlock from MineBlock (Antoine Poinsot)
d1527f6b88 qa: correct off-by-one in utxo snapshot fuzz target (Antoine Poinsot)

Pull request description:

  The assumeutxo data for the fuzz target could change and invalidate the hash silently, preventing the fuzz target from reaching some code paths. Fix this by introducing a unit test which would break if the snapshot data the fuzz target relies on were to change.

  In implementing this i noticed the height used for coins in the fuzz target is actually off-by-one (as if the first block in the created chain was the genesis but it's block `1`), so fix that too.

ACKs for top commit:
  mzumsande:
    Code Review ACK 63b534f97e
  fjahr:
    tACK 63b534f97e

Tree-SHA512: 2399b6e74db9b78aab8efba67c57a405d2d7d880ae3b7d8518a1c96cc6266f61f5e77722cd999adeac5d3e03e73d84cf9ae7bdbcc0afae198cc87049dde4012f
2025-03-21 16:46:54 +08:00
merge-script c9a61509ba
Merge bitcoin/bitcoin#31979: torcontrol: Limit reconnect timeout to max seconds and log delay in whole seconds
f708498293 torcontrol: Limit reconnect timeout to max seconds and log delay in whole seconds (Eval EXEC)

Pull request description:

  I'm reviewing the Tor controller's reconnect-related code and noticed that the reconnect timeout had no limit. This could lead to excessively long delays.

  This PR introduces a maximum reconnect timeout of 600 seconds (10 minutes) to prevent excessive delays in reconnection attempts. It also updates the log message to display the retry delay in whole seconds for better readability.

ACKs for top commit:
  mabu44:
    ACK f708498293
  laanwj:
    Code review ACK f708498293
  luke-jr:
    utACK f708498293

Tree-SHA512: 8f18c6c84da6b4e7328638fd74539fbd3dd44f46c5107638de56b72fc079487690861199ceba1197ca34421dcedf79a1ca6bacf2a918a683e71bce9ff710b5d4
2025-03-21 15:34:29 +08:00
merge-script b43cfa20fd
Merge bitcoin/bitcoin#30142: doc: add guidance for RPC to developer notes
c6eca6f396 doc: add guidance for RPC to developer notes (tdb3)

Pull request description:

  Adds guidance statements to the RPC interface section of the developer notes with examples of when to implement `-deprecatedrpc=`.

  Wanted to increase awareness of preferred RPC implementation approaches for newer contributors.

  This implements some of what's discussed in https://github.com/bitcoin/bitcoin/issues/29912#issuecomment-2081678433

  Opinions may differ, so please don't be shy.  We want to make RPC as solid/safe as possible.

  Examples of discussions where guidelines/context might have added value:
  https://github.com/bitcoin/bitcoin/pull/30212#issuecomment-2347371722
  https://github.com/bitcoin/bitcoin/pull/29845#discussion_r1571053657
  https://github.com/bitcoin/bitcoin/pull/30381#pullrequestreview-2160865613
  https://github.com/bitcoin/bitcoin/pull/29954#issuecomment-2103628952
  https://github.com/bitcoin/bitcoin/pull/30410#pullrequestreview-2167870869
  https://github.com/bitcoin/bitcoin/pull/30713
  https://github.com/bitcoin/bitcoin/pull/30381
  https://github.com/bitcoin/bitcoin/pull/29060#pullrequestreview-2406688998

ACKs for top commit:
  l0rinc:
    ACK c6eca6f396
  fjahr:
    ACK c6eca6f396
  maflcko:
    lgtm ACK c6eca6f396
  jonatack:
    ACK c6eca6f396

Tree-SHA512: 01a98a8dc0eb91762b225d3278cdb4a5e380ceb7486fd096b4ad9122bed859cea8584d8996d3dce51272fdb792f4a793a1bd1c5445efeb87f0a30f9b6e59a790
2025-03-21 13:47:48 +08:00
merge-script 85feb094d4
Merge bitcoin/bitcoin#32092: test: Fix intermittent issue in p2p_orphan_handling.py
fa310cc6f4 test: Fix intermittent issue in p2p_orphan_handling.py (MarcoFalke)

Pull request description:

  The test may fail intermittently when the `net` thread is lagging while calling `DeleteNode`. This may result in a split `getdata`, meaning that `peer2.wait_for_parent_requests([int(parent_peekaboo_AB["txid"], 16), int(parent_missing["txid"], 16)])` fails.

  Fix it by adding a sync on the `net` thread.

  Fixes #31700

ACKs for top commit:
  mzumsande:
    Code Review ACK fa310cc6f4

Tree-SHA512: e4a58093ab5b9e280c479b845fecb5d228e65519ea3dc2111b393202225fd0feded423e8812452454b6b9348cb37a9c1b01b9d1b1802e9f4aa76b9e56b4b54ef
2025-03-21 13:46:11 +08:00
merge-script b858b72903
Merge bitcoin/bitcoin#31841: fuzz: Use immediate task runner to increase fuzz stability
fa4fb6a8f1 fuzz: Use serial task runner to increase fuzz stability (MarcoFalke)

Pull request description:

  Leaking a scheduler with a non-empty queue from the fuzz initialization phase into the fuzz target execution phase is problematic, because it messes with coverage data. This in turn is problematic, because it leads to:

  * Decrease in fuzz target execution stability (non-determinism when running the fuzz target).
  * Decrease in fuzz input merge stability (non-determinism when selecting a minimum set of fuzz input to reach maximum coverage), which leads to qa-assets bloat.

  Fix one such issue. Tracking issue: https://github.com/bitcoin/bitcoin/issues/29018

  Can be tested via: `RUST_BACKTRACE=1 cargo run --manifest-path ./contrib/devtools/deterministic-fuzz-coverage/Cargo.toml -- $PWD/bld-cmake $PWD/../b-c-qa-assets/fuzz_corpora/ partially_downloaded_block`.

  The failure is non-deterministic (obviously) and will show coverage in validation signals such as `UpdatedBlockTip` before this change and will have this one fixed after this change.

ACKs for top commit:
  marcofleon:
    ACK fa4fb6a8f1
  dergoegge:
    Code review ACK fa4fb6a8f1

Tree-SHA512: fd1f66562c1d3c21553c7dd324399cdc16faa2fedfdb8e7544ea6a68b8b356e7c81d81815ecf70e0d334307dab6b275c1889b3b889b6f15eec514beee22c95f4
2025-03-21 08:25:41 +08:00
MarcoFalke fa7a40d952
contrib: Print deterministic-coverage runs 2025-03-20 15:59:14 +01:00
MarcoFalke fa751639fb
contrib: Make deterministic-coverage error messages more readable 2025-03-20 15:59:03 +01:00
Ryan Ofsky 998386d446
Merge bitcoin/bitcoin#31866: test, refactor: Add TestNode.binaries to hold binary paths
d190f0facc test, contrib: Fix signer/miner command line escaping (Ryan Ofsky)
0d2eefca8b test, refactor: Add TestNode.binaries to hold binary paths (Ryan Ofsky)

Pull request description:

  Add new `TestNode.binaries` object to manage paths to bitcoin binaries.

  The `binaries` object makes it possible for the test framework to exercise the bitcoin wrapper executable introduced in https://github.com/bitcoin/bitcoin/pull/31375 and also makes it easier in general to add new binaries, and new options and environment variables controlling how they are invoked, because logic for invoking them that was previously spread out is now consolidated in one place.

  These changes were originally part of #31375 but made that PR harder to review because they were unrelated to the other changes there. If this PR can get merged first, python changes in #31375 will be simple, and the test framework changes here should also get a higher quality review.

ACKs for top commit:
  maflcko:
    re-review-ACK d190f0facc 🍓
  Sjors:
    ACK d190f0facc
  vasild:
    ACK d190f0facc

Tree-SHA512: 5a6c0553cd2822585810d827ef1c1772cbf3097d3336daf733f8378dd3da79c00fc3721e50ed0f7455908fbd7a509e9739f9be33f588d6bc1aaa400b9d75c650
2025-03-20 09:06:19 -04:00
merge-script aa87e0b446
Merge bitcoin/bitcoin#31519: refactor: Use std::span over Span
ffff4a293a bench: Update span-serialize comment (MarcoFalke)
fa4d6ec97b refactor: Avoid false-positive gcc warning (MarcoFalke)
fa942332b4 scripted-diff: Bump copyright headers after std::span changes (MarcoFalke)
fa0c6b7179 refactor: Remove unused Span alias (MarcoFalke)
fade0b5e5e scripted-diff: Use std::span over Span (MarcoFalke)
fadccc26c0 refactor: Make Span an alias of std::span (MarcoFalke)
fa27e36717 test: Fix broken span_tests (MarcoFalke)
fadf02ef8b refactor: Return std::span from MakeUCharSpan (MarcoFalke)
fa720b94be refactor: Return std::span from MakeByteSpan (MarcoFalke)

Pull request description:

  `Span` has some issues:

  * It does not support fixed-size spans, which are available through `std::span`.
  * It is confusing to have it available and in use at the same time with `std::span`.
  * It does not obey the standard library iterator build hardening flags. See https://github.com/bitcoin/bitcoin/issues/31272 for a discussion. For example, this allows to catch issues like the one fixed in commit fabeca3458.

  Both types are type-safe and can even implicitly convert into each other in most contexts.

  However, exclusively using `std::span` seems less confusing, so do it here with a scripted-diff.

ACKs for top commit:
  l0rinc:
    reACK ffff4a293a
  theuni:
    ACK ffff4a293a.

Tree-SHA512: 9cc2f1f43551e2c07cc09f38b1f27d11e57e9e9bc0c6138c8fddd0cef54b91acd8b14711205ff949be874294a121910d0aceffe0e8914c4cff07f1e0e87ad5b8
2025-03-20 13:41:54 +08:00
merge-script ef525e8b7c
Merge bitcoin/bitcoin#31457: fuzz: Speed up *_package_eval fuzz targets a bit
fac3d93c2b fuzz: Speed up *_package_eval fuzz targets a bit (MarcoFalke)
fa40fd043a fuzz: [refactor] Avoid confusing c-style cast (MarcoFalke)

Pull request description:

  Each target is at least 10% faster for me when running over the current set of qa-assets, which seems nice.

  The changes `outpoints_value` from a map to an unordered map, which is safe, because the element order is not used in the fuzz test and the map is only used for lookup.

  (`mempool_outpoints` can't be changed, because the order matters here. Using unordered_set here may result in a non-deterministic fuzz target, given the same fuzz input.)

ACKs for top commit:
  l0rinc:
    ACK fac3d93c2b
  dergoegge:
    Code review ACK fac3d93c2b

Tree-SHA512: 8ae5d4e281505aff76a4003d6e9ea388dbb73860e167385bd6a0a201b3acc939db29ee212594952a9e80e85b3cc4cd726ce6dd49551f74013cb4da8a15cbdfb3
2025-03-20 13:06:17 +08:00
merge-script 7d76c9725c
Merge bitcoin/bitcoin#31766: leveldb: pull upstream C++23 changes
c8fab35617 ci: remove -Wno-error=deprecated-declarations from ASAN (fanquake)
a130bbd154 Squashed 'src/leveldb/' changes from 04b5790928..4188247086 (fanquake)

Pull request description:

  Cherry-picks two commits from upstream (302786e211, e829478c6a), which remove the usage of `std::aligned_storage/std::aligned_union`.

  Note the first cherry-pick is not clean, because due to Google tooling issues, it accidently contained a revert of the prior two commits. See https://github.com/google/leveldb/pull/1249 for more details.

  Also see https://issues.chromium.org/issues/388068052, although note that they [reverted the roll to latest leveldb](https://issues.chromium.org/issues/388068052#comment9). I'm guessing due to the acidental reversion issue above.

ACKs for top commit:
  l0rinc:
    ACK c8fab35617
  darosior:
    ACK c8fab35617 -- checked it's a clean subtree pull from https://github.com/bitcoin-core/leveldb-subtree/tree/bitcoin-fork
  dergoegge:
    utACK c8fab35617

Tree-SHA512: 966e61b9ac88af5ae7bf71514bfd5bbdbd8c38c7af65feb6d5e4415062dcff5896dc33fe968ded3462cc599abd921d49ee8336db3e12ed3f59c91ceb949317b7
2025-03-20 13:03:52 +08:00
merge-script 780bcf80b5
Merge bitcoin/bitcoin#32091: test: replace assert with assert_equal and assert_greater_than
387385ba1e test: replace assert with assert_equal and assert_greater_than (Chandra Pratap)

Pull request description:

  In `test/functional/interface_usdt_net.py`, `assert_equal` is already used to check for equality between objects. Replace `assert.*==` with `assert_equal` and `assert.*>` with `assert_greater_than` to further easify debugging.

  Relevant issue: #23119

ACKs for top commit:
  maflcko:
    lgtm ACK 387385ba1e
  0xB10C:
    had a quick look, lgtm ACK 387385ba1e
  theStack:
    utACK 387385ba1e
  brunoerg:
    code review ACK 387385ba1e
  i-am-yuvi:
    Great! ACK 387385ba1e

Tree-SHA512: 741a3d98288c9999f62bcbaa3806716b0519ec9b521e1e6e17aa458392245f6eff886af6cb601c66f2147e0265ff1eae57cea3dcfd67af93bef6dff25b056935
2025-03-20 12:59:35 +08:00
tdb3 c6eca6f396
doc: add guidance for RPC to developer notes
Adds deprecatedrpc guidance statement to the
RPC interface guidelines section.
2025-03-19 18:56:17 -04:00
MarcoFalke fa310cc6f4
test: Fix intermittent issue in p2p_orphan_handling.py 2025-03-19 20:21:14 +01:00
Hennadii Stepanov 25b56fd9b4
ci: Test cross-built Windows executables on Windows natively 2025-03-19 15:21:06 +00:00
Sjors Provoost 288481aabd
doc: clarify that testnet min-difficulty is not optional 2025-03-19 08:59:08 +01:00
merge-script e568c1dd13
Merge bitcoin/bitcoin#32088: test: switch wallet_crosschain.py to signet and drop testnet4
cec14ee47d test: switch wallet_crosschain.py to signet (Sjors Provoost)
9c2951541c test: drop testnet4 from wallet_crosschain.py (Sjors Provoost)

Pull request description:

  It's sufficient to check only one test network, so this PR reverts the addition of testnet4 from #29775.

  Testnet3 is deprecated. Instead of moving to testnet4, which might also be deprecated in the future, use signet.

ACKs for top commit:
  fjahr:
    utACK cec14ee47d
  maflcko:
    lgtm ACK cec14ee47d 🌰

Tree-SHA512: c5aad6e7d251957f090145eac906f7985fddc3e3ba82df7184d72b961f9c856d324a1065ac98323b75501d136bd7b669fcc2565b9e66b0743eb3f3906ef37570
2025-03-19 07:39:30 +08:00
merge-script e8f6a48e31
Merge bitcoin/bitcoin#32057: test: avoid disk space warning for non-regtest
20fe41e9e8 test: avoid disk space warning for non-regtest (Sjors Provoost)

Pull request description:

  `feature_config_args.py` incorrectly assumed that its testnet4 node would not log a disk space warning.

  But when #31978 increased `m_assumed_blockchain_size` on testnet4 from 1 to 11 GiB, it triggered this bug on my RAM disk, see https://github.com/bitcoin/bitcoin/tree/master/test#speed-up-test-runs-with-a-ram-disk

  This PR fixes the issue by using `-prune` which prevents the warning.

ACKs for top commit:
  fjahr:
    ACK 20fe41e9e8
  maflcko:
    lgtm ACK 20fe41e9e8
  rkrux:
    ACK 20fe41e9e8

Tree-SHA512: f4bbb3ede307e06bf097a3cf7a4099eacc9388e33f551e1d0c4c5f53747bfa593a4b22e5d2e713ce6dd8adf91602fade36fbec9cfc2b250a6b1cf09f11bc8473
2025-03-19 07:22:00 +08:00
Chandra Pratap 387385ba1e test: replace assert with assert_equal and assert_greater_than
In test/functional/interface_usdt_net.py, assert_equal is already
used to check for equality between objects. Replace 'assert.*=='
with 'assert_equal' and 'assert.*>' with 'assert_greater_than'
to further easify debugging.
2025-03-18 14:05:43 +00:00
Ryan Ofsky 223fc24c4e
Merge bitcoin/bitcoin#31603: descriptor: check whitespace in keys within fragments
21e9d39a37 docs: add release notes for 31603 (brunoerg)
a8b548d75d test: `getdescriptorinfo`/`importdescriptors` with whitespace in pubkeys (brunoerg)
c7afca3d62 test: descriptor: check whitespace into keys (brunoerg)
cb722a3cea descriptor: check whitespace in ParsePubkeyInner (brunoerg)
50856695ef test: fix descriptors in `ismine_tests` (brunoerg)

Pull request description:

  Currently, we successfully parse descriptors which contains spaces in the beginning or end of the public/private key within a fragment (e.g. `pk( KEY)`, `pk(KEY )` or `pk( KEY )`). I have noticed that one of the reasons is that the `DecodeBase58` function simply ignore these whitespaces.

  This PR changes the `ParsePubkeyInner ` to reject pubkeys that contain a whitespace at the beginning and/or at the end. We will only check the whitespace in some RPCs (e.g. `importdescriptors`), but an already imported descriptor won't be affected by this check, especially because we store descriptors from `ToString`.

  For context: https://github.com/brunoerg/bitcoinfuzz/issues/72

ACKs for top commit:
  rkrux:
    tACK 21e9d39a37
  darosior:
    re-ACK 21e9d39a37
  sipa:
    utACK 21e9d39a37

Tree-SHA512: 54f48a89a235517e5cdc29a46dceeb7dabbee93c7616a166288ff3f90131808eb0ece43b0797a11fe827a5f7bd51d65e3e75c16789b0a42020934cabb684cc8f
2025-03-18 08:36:41 -04:00
Ryan Ofsky d190f0facc test, contrib: Fix signer/miner command line escaping
Pass bitcoin binary command lines from test framework to signet/miner utility
using shell escaping so they are unambigous and don't get mangled if they
contain spaces.

This change is not needed for tests to pass currently, but is a useful change
to avoid CI failures in followup PR
https://github.com/bitcoin/bitcoin/pull/31375 and to avoid other bugs.
2025-03-18 07:36:41 -05:00
Ryan Ofsky 0d2eefca8b test, refactor: Add TestNode.binaries to hold binary paths
Add new TestNode.binaries object to manage paths to bitcoin binaries.

Having this object makes it possible for the test framework to exercise the
bitcoin wrapper executable introduced in
https://github.com/bitcoin/bitcoin/pull/31375 and also makes it easier to add
new binaries and options and environment variables controlling how they are
invoked, because logic for invoking them that was previously spread out is now
consolidated in one place.

Co-authored-by: Sjors Provoost <sjors@sprovoost.nl>
2025-03-18 07:36:41 -05:00
Hennadii Stepanov 3501bca8c7
ci: Move "Windows cross" job from Cirrus CI to GHA CI
This change is required for testing cross-built executables on Windows
natively.
2025-03-18 10:28:44 +00:00
Hennadii Stepanov f8619196ce
ci: Use `bash` by default for all platforms
This change enforces fail-fast behavior for all platforms.
See: https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference
2025-03-18 10:28:01 +00:00
merge-script d61a847af0
Merge bitcoin/bitcoin#32019: cmake: Check for `makensis` and `zip` tools before using them for optional `deploy` targets
1f9b2e150c cmake: Require `zip` only for `deploy` target (Hennadii Stepanov)
0aeff29951 cmake: Check for `makensis` tool before using it (Hennadii Stepanov)

Pull request description:

  For `x86_64-w64-mingw32` and `*-apple-darwin` targets, the optional `deploy` target requires dedicated tools: `makensis` and `zip`, respectively.

  This PR introduces a uniform checks for those tools when attempting to build the `deploy` target, ensuring they are not required for configuring and building any other targets.

  Here is an example of workflow for `x86_64-w64-mingw32`:
  ```
  $ # `nsis` is not installed
  $ cmake -B build -G "GNU Makefiles" --toolchain depends/x86_64-w64-mingw32/toolchain.cmake
  $ cmake --build build -j $(nproc)
  $ cmake --build build -t deploy

  Error: NSIS not found.
  Please install NSIS and/or ensure that its executable is accessible to the find_program() command—
  for example, by setting the MAKENSIS_EXECUTABLE variable or another relevant CMake variable.
  Then re-run cmake to regenerate the build system.

  Built target deploy
  $ sudo apt install nsis
  $ cmake -B build
  $ cmake --build build -t deploy
  ...
  [100%] Generating bitcoin-win64-setup.exe
  [100%] Built target deploy
  ```

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

ACKs for top commit:
  hodlinator:
    re-ACK 1f9b2e150c
  fanquake:
    ACK 1f9b2e150c

Tree-SHA512: 5e2bd28a13bd8fa7c4ba8cf1756d200a4651afe83c463d76ece10027cca343e124eff97012a5368028f761df60f420ab891106b4e33b50045051d57c7464ff98
2025-03-18 17:10:40 +08:00
Sjors Provoost cec14ee47d
test: switch wallet_crosschain.py to signet
Testnet3 is deprecated. Instead of moving to testnet4, which might
also be deprecated in the future, use signet.
2025-03-18 09:45:04 +01:00
Sjors Provoost 9c2951541c
test: drop testnet4 from wallet_crosschain.py
This reverts the changes to test/functional/wallet_crosschain.py
in commit 74a04f9e7a.

It's sufficient to check only one test network. The next commit
will change that network away from testnet3.
2025-03-18 09:20:13 +01:00
merge-script 14fec6380d
Merge bitcoin/bitcoin#32059: test: Update coverage.cpp to drop linux restriction
54e6eacc1f test: Enable ResetCoverageCounters beyond Linux (janb84)

Pull request description:

  In PR [#31901](https://github.com/bitcoin/bitcoin/pull/31901), Coverage.cpp was introduced as a separate utility file, based on existing code. However, the macro defined in Coverage.cpp was limited to Clang and Linux, which caused issues for users on macOS when using the newly introduced deterministic test tooling.

  This change adds fallback functions which are used when building without code coverage on non linux env.
  This adds support for macOS to ResetCoverageCounters. ResetCoverageCounters is used by the unit tests in `g_rng_temp_path_init` to support the deterministic unit test tooling. It is also used in fuzz tests to completely suppress coverage from anything init-related.

  See [Readme](https://github.com/bitcoin/bitcoin/blob/master/contrib/devtools/README.md) on how to test this for deterministic unit & fuzz test.

  Suggestion for test files:

  - for  unit test: `util_string_tests`
  - for fuzz test: `addition_overflow `

  These files should give deterministic results

ACKs for top commit:
  maflcko:
    review-only ACK 54e6eacc1f
  hodlinator:
    re-ACK 54e6eacc1f

Tree-SHA512: dd71da6f76d4fc9e64bf521bbfe5e7483d77c2ca0380f9e692502e64b529068ea33f21b19399481feb7c6780a23d893d8b7f733cef641a2db18a13397c98deea
2025-03-18 15:22:44 +08:00
merge-script ece0b41da6
Merge bitcoin/bitcoin#32087: ci: Drop ENABLE_HARDENING=OFF from clang-tidy
7d34c19853 ci: Drop ENABLE_HARDENING=OFF from clang-tidy (David Gumberg)

Pull request description:

  Split out from #32071

  It's not clear why this was added in the first place, but it is not necessary currently.

  https://github.com/bitcoin/bitcoin/pull/32038#issuecomment-2723888193 https://github.com/bitcoin/bitcoin/pull/24753.

ACKs for top commit:
  fanquake:
    ACK 7d34c19853

Tree-SHA512: 9ffab10349f52aed77d002155da59f13f0954e6bc1ac1edbddcbb9e70aa2db3b0b0307eb35f8b791589f2157705a96d463589d4270f4873e9037a9ef88807b56
2025-03-18 12:47:02 +08:00
merge-script c9b633d119
Merge bitcoin/bitcoin#31948: ci: [lint] Use Cirrus dockerfile cache
fa3b442715 ci: Use Cirrus dockerfile cache (MarcoFalke)

Pull request description:

  The lint task is problematic, because:

  * It doesn't check modifications to `ci/lint_imagefile`
  * It calls a separate script that installs packages on every run (taking time)
  * It uses `*_cache` instructions to cache some installed parts, but not all

  Fix all issues by using `ci/lint_imagefile` (https://cirrus-ci.org/guide/docker-builder-vm/#dockerfile-as-a-ci-environment)

ACKs for top commit:
  willcl-ark:
    ACK fa3b442715

Tree-SHA512: 243d78219639b83721d4e5cb32d16e5c208a61c919d04646279be5825ba92d97c490b5d4d28ea103eb820b1a259904574cb3e32eaca3f11c3031810e3d87ff4a
2025-03-18 11:42:41 +08:00
merge-script 6245c23504
Merge bitcoin/bitcoin#32083: doc: shallow clone `qa-assets`
6f9f415a4f doc: shallow clone qa-assets (Lőrinc)

Pull request description:

  While reviewing https://github.com/bitcoin/bitcoin/pull/31457#pullrequestreview-2690077410 I noticed that cloning `qa-assets` takes a lot of time - shallow cloning should suffice here.

  I haven't checked the other clones in this file but suggestion are welcome.

ACKs for top commit:
  maflcko:
    lgtm ACK 6f9f415a4f

Tree-SHA512: 21bd676c7709dbf7fd30b239d0a72f9c230453ed8f8a1b5319ac92ef9c5e67780939f095a239dd31bcb4550f8d69eaed4931a221e19cb0b957f18fac623c4a01
2025-03-18 08:06:17 +08:00
Hodlinator 6869fb4170
net: Block v2->v1 transport downgrade if !CConnman::fNetworkActive
We might have just set CNode::fDisconnect in the first loop because of being offline.

Also caches CConnman::fNetworkActive in case it's changed concurrently with our own thread.
2025-03-17 16:56:39 +01:00
Hennadii Stepanov 257fd27e4b
Merge bitcoin/bitcoin#32033: test: Check datadir cleanup after assumeutxo was successful
52482cb244 test: Check datadir cleanup after assumeutxo was successful (Fabian Jahr)

Pull request description:

  I noticed that the proper datadir cleanup after a successful restart of an assumutxo node does not seem to be covered in our tests. This is added here.

ACKs for top commit:
  l0rinc:
    utACK 52482cb244
  mabu44:
    Re-ACK 52482cb244
  Prabhat1308:
    re-ACK [`52482cb`](52482cb244)
  TheCharlatan:
    Re-ACK 52482cb244

Tree-SHA512: cc941afeba250050eaccf5112255d961253fec9b2683545454a0d2fbe4d542178394b301d169a9dd79edbf6b5d478d95282727dbb0aca96ee79d4cd1ff80f19b
2025-03-17 13:43:45 +00:00
Lőrinc 6f9f415a4f doc: shallow clone qa-assets
While reviewing https://github.com/bitcoin/bitcoin/pull/31457#pullrequestreview-2690077410 I noticed that cloning `qa-assets` takes a lot of time - shallow cloning should suffice here.

I haven't checked the other clones in this file.
2025-03-17 13:06:22 +01:00
Hennadii Stepanov db2c57ae9e
Merge bitcoin-core/gui#858: qt: doc: adapt outdated binary paths to CMake changes
7ebc458a8c qt: doc: adapt outdated binary paths to CMake changes (Sebastian Falbesoner)

Pull request description:

  Adapt the qt-related instances of outdated binary paths to `./build/bin/...` (see [#30454](https://github.com/bitcoin/bitcoin/pull/30454) and the more recently merged [#31161](https://github.com/bitcoin/bitcoin/pull/31161)). According to `$ git grep src/qt.*bitcoin` there should be no more left to address.

ACKs for top commit:
  maflcko:
    lgtm ACK 7ebc458a8c
  Sjors:
    utACK 7ebc458a8c
  fanquake:
    ACK 7ebc458a8c
  hebasto:
    ACK 7ebc458a8c.

Tree-SHA512: 8cd6579fdf209ec4ee3c4c9cfb94cb11d5d5115068d31613d356ca1303214dc4461580535c2d3f2773f373a4271e9a82df25596d8369eef8235822f7030d88bd
2025-03-17 09:06:21 +00:00
fanquake c8fab35617
ci: remove -Wno-error=deprecated-declarations from ASAN
This is no-longer needed after the changes to leveldb.
2025-03-17 15:59:47 +08:00
fanquake a130bbd154 Squashed 'src/leveldb/' changes from 04b5790928..4188247086
4188247086 Merge bitcoin-core/leveldb-subtree#47: Fix C++23 compilation errors in leveldb
183e79a495 Fix speculatively some "placement new" issues in leveldb
82c31046ed Fix C++23 compilation errors in leveldb

git-subtree-dir: src/leveldb
git-subtree-split: 41882470862df219f74cdd38354007b91eb98191
2025-03-17 15:59:05 +08:00
fanquake 24fd0235e4
Update leveldb subtree to latest upstream 2025-03-17 15:59:05 +08:00
merge-script a799415d84
Merge bitcoin/bitcoin#31904: refactor: modernize outdated trait patterns using helper aliases (C++14/C++17)
4cd95a2921 refactor: modernize remaining outdated trait patterns (Lőrinc)
ab2b67fce2 scripted-diff: modernize outdated trait patterns - values (Lőrinc)
8327889f35 scripted-diff: modernize outdated trait patterns - types (Lőrinc)

Pull request description:

  The use of [`std::underlying_type_t<T>`](https://en.cppreference.com/w/cpp/types/underlying_type) or [`std::is_enum_v<T>`](https://en.cppreference.com/w/cpp/types/is_enum) (and similar ones, introduced in C++14) replace the `typename std::underlying_type<T>::type` and  `std::is_enum<T>::value` constructs (available in C++11).

  The `_t` and `_v` helper alias templates offer a more concise way to extract the type and value directly.

  I've modified the instances I found in the codebase one-by-one (noticed them while investigating https://github.com/bitcoin/bitcoin/pull/31868), and afterwards extracted scripted diff commits to do the trivial ones automatically.
  The last commit contains the values that were easier done manually.

  I've excluded changes from `src/bench/nanobench.h`, `src/leveldb`, `src/minisketch`, `src/span.h` and `src/sync.h` - let me know if you think they should be included instead.

  A few of the code changes can also be reproduced by clang-tidy (but not all of them):
  ```bash
  cmake -B build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON -DBUILD_FOR_FUZZING=ON && cmake --build build -j$(nproc)
  run-clang-tidy -quiet -p build -j $(nproc) -checks='-*,modernize-type-traits' -fix $(git grep -lE '::(value|type)' ./src ':(exclude)src/bench/nanobench.h' ':(exclude)src/leveldb' ':(exclude)src/minisketch' ':(exclude)src/span.h' ':(exclude)src/sync.h')
  ```

ACKs for top commit:
  laanwj:
    Concept and code review ACK 4cd95a2921

Tree-SHA512: a4bcf0f267c0f4e02983b4d548ed6f58d464ec379ac5cd1f998b9ec0cf698b53a9f2557a05a342b661f1d94adefc9a0ce2dc8f764d49453aaea95451e2c4c581
2025-03-17 13:10:10 +08:00
merge-script 5f4422d68d
Merge bitcoin/bitcoin#32010: qa: Fix TxIndex race conditions
3301d2cbe8 qa: Wait for txindex to avoid race condition (Hodlinator)
9bfb0d75ba qa: Remove unnecessary -txindex args (Hodlinator)
7ac281c19c qa: Add missing coverage of corrupt indexes (Hodlinator)

Pull request description:

  - Add synchronization in 3 places where if the Transaction Index happens to be slow, we get rare test failures when querying it for transactions (one such case experienced on Windows, prompting investigation).
  - Remove unnecessary TxIndex initialization in some tests.
  - Add some test coverage where TxIndex aspect could be tested in feature_init.py.

ACKs for top commit:
  fjahr:
    re-ACK 3301d2cbe8
  mzumsande:
    Code Review ACK 3301d2cbe8
  furszy:
    Code review ACK 3301d2cbe8
  Prabhat1308:
    Concept ACK [`3301d2c`](3301d2cbe8)

Tree-SHA512: 7c2019e38455f344856aaf6b381faafbd88d53dc88d13309deb718c1dcfbee4ccca7c7f1b66917395503a6f94c3b216a007ad432cc8b93d0309db9805f38d602
2025-03-17 10:28:14 +08:00
Fabian Jahr 52482cb244
test: Check datadir cleanup after assumeutxo was successful 2025-03-16 18:48:15 +01:00
Sebastian Falbesoner 7ebc458a8c qt: doc: adapt outdated binary paths to CMake changes 2025-03-16 17:15:04 +01:00
merge-script cd8089c20b
Merge bitcoin/bitcoin#32069: test: fix intermittent failure in wallet_reorgsrestore.py
36b0713edc test: fix intermittent failure in wallet_reorgsrestore.py (furszy)

Pull request description:

  In response to #32066 intermittent failure.

  Wait until the node's process has fully stopped before starting a new instance of it.
  Same behavior as in the [tool_wallet.py](698f86964c/test/functional/tool_wallet.py (L540)) test.

ACKs for top commit:
  maflcko:
    lgtm ACK 36b0713edc
  Chand-ra:
    tACK [36b0713](36b0713edc)

Tree-SHA512: 8e01493ef1fb58589479f3e12d7429d02ca75a2183d5f79d3b6a2fbf13334878926274a20857f1b4729afc1d30b65789daed229ce06ba236b91d949b73f45d5a
2025-03-16 22:29:14 +08:00
merge-script 70a0ee89c6
Merge bitcoin/bitcoin#32063: test: fix intermittent failure in p2p_orphan_handling.py
02942056fd test: fix intermittent failure in p2p_orphan_handling.py (Martin Zumsande)

Pull request description:

  If the mocktime is bumped before the node has successfully disconnected the peer, the requests for both parents could be spread over two GETDATAS: The first time `GetRequestsToSend` is invoked it would only request one tx from peer2, because the other one would only be available after peer1  was disconnected and its outstanding txrequest cleared.
  So two GETDATAs would be sent, which would make the test fail.

  Fixes #31700

ACKs for top commit:
  maflcko:
    lgtm ACK 02942056fd
  instagibbs:
    ACK 02942056fd

Tree-SHA512: 769200898345da197d86d673d9506f08f0a64b72a456e7e7c988ac37450d9c54ec65da1c8447c566c8578f7cfccdc5723ea680e636bfbe0b3d38265e5ef57774
2025-03-16 22:27:40 +08:00
janb84 54e6eacc1f test: Enable ResetCoverageCounters beyond Linux
Non-Linux linkers require a fallback implementation for when coverage is not enabled.
The fallbacks are marked weak to have lower precedence than built-in implementations when available, removing ambiguity from the linker.
2025-03-16 12:01:58 +01:00
Pol Espinasa 2f2ab47bf7
Release notes 2025-03-16 11:12:03 +01:00
Pol Espinasa bf194c920c
wallet, rpc: deprecate settxfee and paytxfee 2025-03-16 11:12:03 +01:00
merge-script 83a9e55ae1
Merge bitcoin/bitcoin#32070: build: use make < 3.82 syntax for define directive
9157d9e449 build: use make < 3.82 syntax for define directive (Sjors Provoost)

Pull request description:

  From the GNU make 3.82 [release announcement](https://lists.gnu.org/archive/html/info-gnu/2010-07/msg00023.html) (2010):

  > The 'define' make directive now allows a variable assignment operator
    after the variable name, to allow for simple, conditional, or appending
    multi-line variable assignment.

  macOS ships with 3.81 (2006). This caused the multiprocess config options to be ignored.

  Fixes #32068

ACKs for top commit:
  ryanofsky:
    Code review ACK 9157d9e449. This is a pretty unusual bug and I don't understand how it wasn't causing any errors with make 3.81, just causing the flags to be ignored.

Tree-SHA512: a07322e25ef18296264379a2704f31c654df196d3ea09fe712885c38813e54d758a2d603ee9f7a302da8011fba6d139aa30a356175ca99df728ade2572a87560
2025-03-16 17:22:19 +08:00
merge-script ca05b28710
Merge bitcoin/bitcoin#31859: test: Rename send_message to send_without_ping
fa9cf38ab6 scripted-diff: test: Rename send_message to send_without_ping (MarcoFalke)
fa4356717d test: Prefer send_and_ping over send_message+sync_with_ping (MarcoFalke)

Pull request description:

  `send_message` is problematic, because it is easy to forget a `sync_with_ping` (or other `wait_until`), leading to intermittent test failures. (Example: https://github.com/bitcoin/bitcoin/pull/31837#discussion_r1950370246)

  There are more uses of `send_and_ping` in the codebase than `send_message`, so in most cases `send_and_ping` is needed anyway.

  For the remaining cases, clearly document that no sync happens by renaming `send_message` to `send_without_ping`.

ACKs for top commit:
  instagibbs:
    ACK fa9cf38ab6

Tree-SHA512: 31caa6568d292ae3d3dda931a94aaa30cc1205ec2ef537a484393eb55687f86c212f1e751ac4a7636610bdf591502a50995dc63bf02f97be9fdc482072160b07
2025-03-16 17:08:12 +08:00
merge-script ab2df1726e
Merge bitcoin/bitcoin#31917: fuzz: provide more realistic values to the base58(check) decoders
d5537c18a9 fuzz: make sure DecodeBase58(Check) is called with valid values more often (Lőrinc)
bad1433ef2 fuzz: Always restrict base conversion input lengths (Lőrinc)

Pull request description:

  This is a follow-up to https://github.com/bitcoin/bitcoin/pull/30746, expanding coverage by:
  * restricting every input for the base58 conversions, capping max sizes to `100` instead of `1000` or all available input (suggested by marcofleon in https://github.com/bitcoin/bitcoin/pull/30746#discussion_r1963718683) since most actual usage has lengths of e.g. `21`, `34`, `78`.
  * providing more valid values to the decoder (suggested by maflcko in https://github.com/bitcoin/bitcoin/pull/30746#discussion_r1957847712) by randomly providing a random input or a valid encoded one; this also enables unifying the roundtrip tests to a single roundtrip per fuzz.

ACKs for top commit:
  mzumsande:
    Code Review / lightly tested ACK d5537c18a9
  maflcko:
    review ACK d5537c18a9 🚛

Tree-SHA512: 50365654cdac8a38708a7475eaa43396642b7337e2ee8999374c3faafff4f05457abc1a54c701211e0ed24d36c12af77bcad17b49695699be42664f2be660659
2025-03-16 17:02:58 +08:00
merge-script 51a20e56c2
Merge bitcoin/bitcoin#31977: test: Use rpc_deprecated only for testing deprecation
2819c51482 test: Use rpc_deprecated only for testing deprecation (Fabian Jahr)

Pull request description:

  The comment in `functional/rpc_deprecated.py` says "This test should be used to verify correct behaviour of deprecated RPC methods with and without the -deprecatedrpc flags." I think we can get rid of the "with" part since we can assume that every deprecated RPC is already tested in at least one other functional test. (I didn't look but I could verify in our coverage if someone has doubts about that.) In order for this test to continue working, the flag will need to be used there. Otherwise this seems to prescribe copy+pasting a basic test from another file and I don't see a good reason for that.

ACKs for top commit:
  maflcko:
    lgtm ACK 2819c51482
  janb84:
    re ACK [2819c51](2819c51482)
  polespinasa:
    reACK 2819c51482

Tree-SHA512: 96edfd07be863ad19f99feb27afbc2c3ad53560c93c93eac8de8d766ad8c46e5aa02fd013fec99af794cbe9adca8e459d5b80b454caea7e67b2388003e010bb6
2025-03-16 16:59:39 +08:00
MarcoFalke fac3d93c2b
fuzz: Speed up *_package_eval fuzz targets a bit 2025-03-16 09:26:37 +01:00
MarcoFalke fa40fd043a
fuzz: [refactor] Avoid confusing c-style cast 2025-03-16 09:26:26 +01:00
Sjors Provoost 20fe41e9e8
test: avoid disk space warning for non-regtest
feature_config_args.py incorrectly assumed that its testnet4 node
would not log a disk space warning.

0683b8ebf3 increased m_assumed_blockchain_size
on testnet4 from 1 to 11 GiB which triggers this bug on more
systems, e.g. a RAM disk.

Prevent the warning by setting -prune for these nodes.

Fix the same issue in feature_signet.py
2025-03-15 16:07:07 +01:00
Fabian Jahr 2819c51482
test: Use rpc_deprecated only for testing deprecation 2025-03-14 22:48:24 +01:00
David Gumberg 7d34c19853 ci: Drop ENABLE_HARDENING=OFF from clang-tidy
It's not clear why this was added in the first place, but it is not
necessary currently.

https://github.com/bitcoin/bitcoin/pull/32038#issuecomment-2723888193
https://github.com/bitcoin/bitcoin/pull/24753.
2025-03-14 10:31:04 -07:00
Sjors Provoost 9157d9e449
build: use make < 3.82 syntax for define directive
From the GNU make 3.82 release announcement:

* The 'define' make directive now allows a variable assignment operator
  after the variable name, to allow for simple, conditional, or appending
  multi-line variable assignment.

macOS ships with 3.81. This caused the multiprocess config options
to be ignored.

Fixes #32068

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2025-03-14 16:19:45 +01:00
furszy 36b0713edc
test: fix intermittent failure in wallet_reorgsrestore.py
Wait until the node's process has fully stopped before starting a new instance.

Since the same code is used in tool_wallet.py, this consolidates the behavior
into a 'kill_process()' function.
2025-03-14 11:06:44 -04:00
MarcoFalke fa9cf38ab6
scripted-diff: test: Rename send_message to send_without_ping
send_message only drops the bytes in a buffer and a sync is needed to
avoid intermittent test issues. Change the name of the method to make
this more apparent during review.

-BEGIN VERIFY SCRIPT-
 sed -i 's/send_message(/send_without_ping(/g' $( git grep -l 'send_message(' )
-END VERIFY SCRIPT-
2025-03-14 12:45:20 +01:00
MarcoFalke fa4356717d
test: Prefer send_and_ping over send_message+sync_with_ping
Also, add an explanation for the preference in the docs.
2025-03-14 12:44:34 +01:00
MarcoFalke fa4fb6a8f1
fuzz: Use serial task runner to increase fuzz stability 2025-03-14 10:11:45 +01:00
Anthony Towns e3014017ba test: add IsActiveAfter tests for versionbits 2025-03-14 13:58:08 +10:00
Anthony Towns 60950f77c3 versionbits: docstrings for BIP9Info 2025-03-14 13:38:53 +10:00
merge-script 698f86964c
Merge bitcoin/bitcoin#31961: Require sqlite when building the wallet
36b6f36ac4 build: require sqlite when building the wallet (Sjors Provoost)

Pull request description:

  Require that sqlite is available in order to compile the wallet. Removes instances of `USE_SQLITE` since it is no longer possible to not have sqlite available.

  The `NO_SQLITE` option is dropped from depends.

  This is another step towards dropping the legacy wallet, extracted from #31250.

ACKs for top commit:
  m3dwards:
    ACK 36b6f36ac4
  davidgumberg:
    crACK 36b6f36ac4
  hebasto:
    re-ACK 36b6f36ac4.

Tree-SHA512: 870a0135671c80c4f28602119eb8637a1ed43b51b1673bfe88425782fb62ec6ef0f3d6baf0d5984d6a243779b0f63423fd4c4dc324ef87bffba13d63e05ad793
2025-03-14 11:23:35 +08:00
merge-script f4b3a5858a
Merge bitcoin/bitcoin#32064: build: Remove manpages when making MacOS app
80b5e7f2cb build: Remove manpages when making MacOS app (Ava Chow)

Pull request description:

  When creating the MacOS app, the only file that should be in `Bitcoin-Qt.app/Contents/MacOS` is `Bitcoin-Qt`. Since #31844, there was also a `share/` containing the manpage for bitcoin-qt. This manpage is not useful to app users, and it is also causing code signing issues. Thus the directory should be removed when making the app.

  Fixes https://github.com/bitcoin/bitcoin/issues/32052#issuecomment-2723007926

ACKs for top commit:
  fanquake:
    ACK 80b5e7f2cb

Tree-SHA512: fd15b7f99737484e40d31c583e01acc7470d038b0c584dfaefecc740811565ceee048913b6e5e37e7935b74d8100dc8323aed3f69d9a6baa5f434754009eb18c
2025-03-14 11:13:58 +08:00
merge-script 92f553eaa9
Merge bitcoin/bitcoin#32038: depends: remove `NO_HARDEN` option
5dfef6b9b3 depends: remove NO_HARDEN option (fanquake)

Pull request description:

  This was only needed to work around a (Libtool related iirc) Windows issue, when hardening was disabled. I can no-longer recreate this failure, so it'd be good to remove this Windows carveout.

ACKs for top commit:
  davidgumberg:
    crACK 5dfef6b9b3
  laanwj:
    Code review ACK 5dfef6b9b3

Tree-SHA512: 38657f09c537ba02ecaf0676d47087a835283cabfc81ad9b2d5e68858dcd7a610b6a1df6730920d40b48be2bbc55a45d6b8aea4364884b5f1c1bd12126940f5b
2025-03-14 11:02:02 +08:00
Ava Chow 80b5e7f2cb build: Remove manpages when making MacOS app 2025-03-13 17:56:09 -07:00
merge-script 1b251f6b67
Merge bitcoin/bitcoin#31649: consensus: Remove checkpoints (take 2)
3c5d1a4681 Remove checkpoints (marcofleon)
632ae47372 update comment on MinimumChainWork check (marcofleon)

Pull request description:

  The headers presync logic (only downloading headers that lead to a chain with sufficient work, implemented in https://github.com/bitcoin/bitcoin/pull/25717) should be enough to prevent memory DoS using low-work headers. Therefore, we no longer have any use for checkpoints.

  All checkpoints and checkpoint logic are removed in a single commit, to make it easy to revert if necessary.

  Some previous discussion can be found in https://github.com/bitcoin/bitcoin/pull/25725. The conclusion at the time was that more testing of the presync logic was needed. Now that we have [unit](https://github.com/bitcoin/bitcoin/blob/master/src/test/headers_sync_chainwork_tests.cpp), [functional](https://github.com/bitcoin/bitcoin/blob/master/test/functional/p2p_headers_sync_with_minchainwork.py), and [fuzz](https://github.com/bitcoin/bitcoin/blob/master/src/test/fuzz/p2p_headers_presync.cpp) tests for this logic, it seems safe to move forward with checkpoint removal.

ACKs for top commit:
  Sjors:
    Code review ACK 3c5d1a4681
  instagibbs:
    reACK 3c5d1a4681
  dergoegge:
    ACK 3c5d1a4681

Tree-SHA512: 051a6f9b82cd0262f4d3be4403906812fc6d1be022731fac16bb1c02bca471f31dfc7fc4b834ab2469e8f087265a6d99e84a1d665823cda1b112363a8e8f337d
2025-03-14 08:09:15 +08:00
Martin Zumsande 02942056fd test: fix intermittent failure in p2p_orphan_handling.py
If we bump the mocktime before the node has successfully disconnected
the peer, the requests for both parents could be spread over
two GETDATAS, which would make the test fail.
2025-03-13 17:59:02 -04:00
glozow 5c2f04413e
Merge bitcoin/bitcoin#32049: contrib: Fix `gen-bitcoin-conf.sh`
a24419f8be contrib: Fix `gen-bitcoin-conf.sh`. (David Gumberg)

Pull request description:

  In #31118, the format of bitcoind's `--help` output changed slightly in a way that breaks `gen-bitcoin-conf.sh`, modify the script to accommodate the new format, by starting after the line that says "Options:" and stripping the `-help` options and descriptions from the script output.

  Before this PR, all options above `-help` were excluded from the example bitcoin.conf.

ACKs for top commit:
  mabu44:
    Tested ACK a24419f8be
  glozow:
    ACK a24419f8be
  rkrux:
    tACK a24419f8be
  BrandonOdiwuor:
    crACK a24419f8be

Tree-SHA512: 2ef697166d0b37b61ec1a20e357b91d611c932a0e453c4669f74ab69e6310ea1776dce09c1b77e82746072265763cb0c750e6df4c8b4a7d39068fc03f97b221b
2025-03-13 16:58:44 -04:00
Ryan Ofsky 5d96c2eab9
Merge bitcoin/bitcoin#31907: qa: clarify and document one assumeutxo test case with malleated snapshot
e5ff4e416e qa: use a clearer and documented amount error in malleated snapshot (Antoine Poinsot)
b34fdb5ade test: introduce output amount (de)compression routines (Sebastian Falbesoner)
a7911ed101 test: introduce VARINT (de)serialization routines (Sebastian Falbesoner)

Pull request description:

  The `feature_assumeutxo.py` functional test checks various errors with malleated snapshots. Some of these cases are brittle or use confusing and undocumented values. Fix one of those by using a clear, documented and forward-compatible value.

  I ran across those when working on an unrelated changeset which affected the snapshot. It took me a while to understand where the seemingly magic byte string was coming from, so i figured it was worth proposing this patch on its own for the sake of making the test more maintainable.

  See commit messages for details.

ACKs for top commit:
  janb84:
    re ACK [e5ff4e4](e5ff4e416e)
  theStack:
    ACK e5ff4e416e
  fjahr:
    Code review ACK e5ff4e416e
  i-am-yuvi:
    tACK e5ff4e416e

Tree-SHA512: 60f022b7176836ce05e8f287b436329d7ca6460f3fcd95f78cd24e07a95a7d4d9cbbb68a117916a113fe451732b09a012d300fe860ff33d61823eca797ceddaf
2025-03-13 16:34:56 -04:00
Ryan Ofsky 57d611e53b
Merge bitcoin/bitcoin#31757: wallet: fix crash on double block disconnection
11f8ab140f test: wallet, coverage for crash on dup block disconnection during unclean shutdown (Martin Zumsande)
9ef429b6ae wallet: fix crash on double block disconnection (furszy)

Pull request description:

  The wallet crashes if it processes the same block disconnection event twice in a row due
  to an incompatible coinbase transaction state.
  This happens because `disconnectBlock` provides `TxStateInactive` without the "abandoned"
  flag for coinbase transactions to `SyncTransaction`, while `AddToWallet()` internally modifies
  it to retain the abandoned state.

  The crash flow is as follows:
  1) On the first disconnection, the transaction state transitions from "confirmed" to
  "inactive," bypassing the state equality check since the provided state differs. Then,
  `AddToWallet` internally updates the state to "inactive + abandoned"

  2) On the second disconnection, as we provide only the "inactive" state
  to `SyncTransaction()`, the state equality assertion fails and crashes the wallet.

  Reviewers Note:
  The crash can easily be replicated by cherry-picking the test commit in master.

ACKs for top commit:
  mzumsande:
    Code Review ACK 11f8ab140f
  rkrux:
    ACK 11f8ab140f
  pinheadmz:
    ACK 11f8ab140f

Tree-SHA512: 971069bca562f0afb06c34a2516842d01b5cbc2b18ed851392aa3caa3bb7488f4a84a5d017ea334e6361261d3c44aa597cc67a1d4fa16781f85e081f3d1f8771
2025-03-13 15:06:49 -04:00
merge-script 199d47d962
Merge bitcoin/bitcoin#32056: doc: Adjust path in comment
de1ada079b doc: Adjust path in comment (Hennadii Stepanov)

Pull request description:

  It was overlooked in bitcoin/bitcoin#31161.

ACKs for top commit:
  l0rinc:
    utACK de1ada079b
  dergoegge:
    ACK de1ada079b

Tree-SHA512: ea2b858f9c6520a71a3e14a3877ad38acfcddee6ee4aad5fa8fc1c08a0589d9d4df9b5fdbae834bd03bbb956f8b52fdd2b35144fe0bf943bc9455ed6c3fc1c80
2025-03-13 20:18:27 +08:00
Hennadii Stepanov de1ada079b
doc: Adjust path in comment
It was overlooked in bitcoin/bitcoin#31161.
2025-03-13 11:47:41 +00:00
Hennadii Stepanov 72c150dfe7
Merge bitcoin/bitcoin#32055: contrib: Fix deterministic-unittest-coverage tool path
893ca54585 contrib: Fix deterministic-unittest-coverage tool path (janb84)

Pull request description:

  Fix for the tooling introduced/modified in #31901 but the tool path is broken due to silent merge conflict introduced by #31161.

  The `deterministic-unittest-coverage` and `deterministic-fuzz-coverage` tools uses the `fuzz` and `test_bitcoind` binaries, for which the location was modified in #31161. This patch updates the location to align with that change.

ACKs for top commit:
  maflcko:
    lgtm ACK 893ca54585
  hebasto:
    ACK 893ca54585, I have reviewed the code and it looks OK.

Tree-SHA512: efd5a75b607a6a7889333674b9a1fccf30b6a80bb2aa941f9dcc10b2e0b6158d8c870d58aa76cef2a0280782570400730828d6a4aaf806b83959e9f4bc7313f4
2025-03-13 11:37:56 +00:00
Hennadii Stepanov 1f9b2e150c
cmake: Require `zip` only for `deploy` target 2025-03-13 11:22:30 +00:00
Hennadii Stepanov 0aeff29951
cmake: Check for `makensis` tool before using it 2025-03-13 11:22:05 +00:00
marcofleon 3c5d1a4681 Remove checkpoints
The headers presync logic should be enough to prevent memory DoS using
low-work headers. Therefore, we no longer have any use for checkpoints.
2025-03-13 11:13:13 +00:00
Sjors Provoost 64a2795fd4
rpc: handle shutdown during long poll and wait methods
The waitTipChanged() now returns nullopt if the node is shutting down.

Previously it would return the last known tip during shutdown, but
this creates an ambiguous circumstance in the scenario where the
node is started and quickly shutdown, before notifications().TipBlock()
is set.

The getblocktemplate, waitfornewblock and waitforblockheight RPC
are updated to handle this. Existing behavior is preserved.

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2025-03-13 12:12:17 +01:00
Sjors Provoost a3bf43343f
rpc: drop unneeded IsRPCRunning() guards
This was preventing the (hidden) waitfornewblock, waitforblock and
waitforblockheight methods from being used in the GUI.

The check was added in d6a5dc4a2e
when these RPC methods were first introduced.

They could have been dropped when dca923150e
refactored these methods to use waitTipChanged(), which already
checks for shutdown.

Making this change now simplifies the next commit.
2025-03-13 12:12:17 +01:00
Sjors Provoost f9cf8bd0ab
Handle negative timeout for waitTipChanged() 2025-03-13 12:12:17 +01:00
marcofleon 632ae47372 update comment on MinimumChainWork check 2025-03-13 11:05:17 +00:00
janb84 893ca54585 contrib: Fix deterministic-unittest-coverage tool path 2025-03-13 11:56:39 +01:00
Sjors Provoost 226d81f8b7
mining: drop unused -nFees and sigops from CBlockTemplate
For the coinbase vTxFees used a dummy value of -nFees. This
value was never returned by the RPC or used in a test.

Similarly the fist vTxSigOpsCost entry was calculated from
the dummy coinbase transaction.

Drop both and add code comments to prevent confusion.
2025-03-13 11:16:57 +01:00
Sjors Provoost 53ad845fb9
test: check fees and sigops in getblocktemplate 2025-03-13 11:16:57 +01:00
MarcoFalke fa3b442715
ci: Use Cirrus dockerfile cache 2025-03-13 09:55:19 +01:00
merge-script c20a5ce106
Merge bitcoin/bitcoin#31901: contrib: Add deterministic-unittest-coverage
fa99c3b544 test: Exclude SeedStartup from coverage counts (MarcoFalke)
fa579d663d contrib: Add deterministic-unittest-coverage (MarcoFalke)
fa3940b1cb contrib: deterministic-fuzz-coverage fixups (MarcoFalke)
faf905b9b6 doc: Remove unused -fPIC (MarcoFalke)
fa1e0a7228 gitignore: target/ (MarcoFalke)

Pull request description:

  The `contrib/devtools/test_deterministic_coverage.sh` script is problematic:

  * It is written in bash. This can lead to issues when running with the ancient bash version shipped by macOS by default, or can lead to other compatibility issues, such as https://github.com/bitcoin/bitcoin/pull/31588#discussion_r1946784827. Also, pipefail isn't set, so IO errors may be silently ignored.
  * It is based on gcov. This can lead to issues, such as https://github.com/bitcoin/bitcoin/pull/31588#pullrequestreview-2602169248 (possibly due to prefix-map), or https://github.com/bitcoin/bitcoin/pull/31588#issuecomment-2646395385 (gcovr processing error), or https://github.com/bitcoin/bitcoin/pull/31588#pullrequestreview-2605954001 (gcovr assertion error).
  * The script is severely outdated, with the last update to `NON_DETERMINISTIC_TESTS` being in the prior decade.

  Instead of patching around all issues one-by-one, just provide a fresh rewrite, based on the recently added `deterministic-fuzz-coverage` tool based on clang, llvm-cov, and llvm-profdata. (Initial feedback indicates that this is a more promising attempt: https://github.com/bitcoin/bitcoin/pull/31588#issuecomment-2649356408 and https://github.com/bitcoin/bitcoin/pull/31588#issuecomment-2649354598).

  The new tool also sets `RANDOM_CTX_SEED=21` as suggested by hodlinator in https://github.com/bitcoin/bitcoin/pull/31588#issuecomment-2650784726.

ACKs for top commit:
  Prabhat1308:
    Concept ACK [`fa99c3b`](fa99c3b544)
  hodlinator:
    re-ACK fa99c3b544
  brunoerg:
    light ACK fa99c3b544
  dergoegge:
    tACK fa99c3b544
  janb84:
    Concept ACK [fa99c3b](fa99c3b544)

Tree-SHA512: 491d5e6413d929395a5c7caea54817bdc1a0e00562c9728a374d4e92f2e2017dba4a770ecdb2e7317e049df9fdeb390d83c90dff9aa5709f97aa3f6a0e70cdb4
2025-03-13 12:30:32 +08:00
merge-script a50af6e4c4
Merge bitcoin/bitcoin#32044: ci: Revert "Temporary workaround for old CCACHE_DIR cirrus env"
fa21597064 ci: Revert "Temporary workaround for old CCACHE_DIR cirrus env" (MarcoFalke)

Pull request description:

  Seems fine to revert this now. If this still happens it should be rare enough and trivial to fix via a new push (normal push, force-push, rebase, ...), or to just ignore the failure.

ACKs for top commit:
  fanquake:
    ACK fa21597064

Tree-SHA512: 125946dcd4025b04f11276e1df1e0f1b361fc2deed2e3919d680d58df97e6d82881b21c0c683142df6995226b4c12b2dde5415ad78474b8fcda115cc69fa0207
2025-03-13 09:00:05 +08:00
merge-script a5a582d852
Merge bitcoin/bitcoin#31998: depends: patch around PlacementNew issue in capnp
1ef22ce335 depends: patch around PlacementNew issue in capnp (fanquake)

Pull request description:

  See #31772 and https://github.com/capnproto/capnproto/pull/2235.

  Given there isn't agreement in #29796, pulled this out so it could be merged separately, and it's easier to run different test configurations externally.

  Closes #31772.

ACKs for top commit:
  ryanofsky:
    Code review ACK 1ef22ce335. Confirmed patch is identical to one merged upstream. Only change since last review was tweaking the file paths and commit data in the patch.
  TheCharlatan:
    ACK 1ef22ce335

Tree-SHA512: 9c9ecf50c43cf74315f6659afab55aeafb436f70e83b328016ad574136dce46867220c6e1a85aefd8d3d3d027cd94cc807c79721a4983da9428de70f11224e52
2025-03-13 08:52:36 +08:00
Sebastian Falbesoner a82829f37e test: simplify (w)txid checks by avoiding .calc_sha256 calls
Calls on the tx.calc_sha256 method can be confusing, as they return
the result (either txid or wtxid, depending on the with_witness
boolean parameter) as integer rather than as actual (w)txid. Use
.rehash() and .getwtxid() instead to improve readability and in some
cases avoid a conversion from string-txid to an integer.
2025-03-13 01:42:47 +01:00
Sebastian Falbesoner 346a099fc1 test: avoid unneeded hash -> uint256 -> hash roundtrips
In the functional test framework, we often treat hashes
as uint256 integers, which seems to be confusing and for no
good reason, as hashes are just sequences of bytes. This commit
gets rid of obvious internal instances of that where individual
functional tests are not affected. In the long-term, it might make
sense to store other hashes (mostly txids) as actual bytes to
avoid annoying conversions and improve code readability.
2025-03-13 01:41:25 +01:00
David Gumberg a24419f8be contrib: Fix `gen-bitcoin-conf.sh`.
In #31118, the format of bitcoind's `--help` output changed slightly in
a way that breaks `gen-bitcoin-conf.sh`, modify the script to accomodate
the new format, by starting after the line that says "Options:" and
strip the `-help` option and its description from the output.
2025-03-12 15:14:51 -07:00
Jon Atack d423fd9ec8 cli, bugfix: for -getinfo, replace IsArgSet() with GetBoolArg()
for consistency with the other CLI commands (-netinfo, -addrinfo, -generate).

This can be considered a bugfix because IsArgSet() returns whether an arg has
been set even if it has been negated. After this change, we no longer treat
-nogetinfo and -getinfo=0 the same as -getinfo and -getinfo=1, and instead as if
-getinfo was not specified.

Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2025-03-12 14:33:45 -06:00
Jon Atack e99e41b307 cli, refactor: simplify public-only classes with structs
and run clang-format on it
2025-03-12 14:33:10 -06:00
Jon Atack fdbfd250fb cli, refactor: deduplicate NetworkStringToId() 2025-03-12 14:10:28 -06:00
Jon Atack be82139b2a cli, refactor: simplify DetailsRequested()
The bounds check is no longer needed after the merge of PR 21192.
2025-03-12 14:10:18 -06:00
Hennadii Stepanov eb9730ab65
Merge bitcoin/bitcoin#31987: wallet: Replace "non-0" with "non-zero" in translatable error message
18e83534ac wallet: Replace "non-0" with "non-zero" in translatable error message (Hennadii Stepanov)

Pull request description:

  Transifex interprets the "-0" substring as a number in translatable strings. Since not all translations preserve "-0," this triggers a corresponding warning. While this warning could be disabled globally, it is more reasonable to adjust the original string instead.

ACKs for top commit:
  davidgumberg:
    ACK 18e83534ac
  l0rinc:
    ACK 18e83534ac
  1440000bytes:
    ACK 18e83534ac
  BrandonOdiwuor:
    Code Review ACK 18e83534ac
  laanwj:
    Code review ACK 18e83534ac

Tree-SHA512: 5c38cfc4b352dbbcc8de5fb907cf988a77a7ecded7a90fe0517bfb9e4cd5097bdeb1aa6edf5d9ca37de54d1d7939d5e49533ec93c403db90d9169ad7732e5124
2025-03-12 19:32:05 +00:00
Ryan Ofsky f347d7980e
Merge bitcoin/bitcoin#31283: Add waitNext() to BlockTemplate interface
cadbd4137d miner: have waitNext return after 20 min on testnet (Sjors Provoost)
d4020f502a Add waitNext() to BlockTemplate interface (Sjors Provoost)

Pull request description:

  This PR introduces `waitNext()`. It waits for either the tip to update or for fees at the top of the mempool to rise sufficiently. It then returns a new template, with which the caller can rinse and repeat.

  On testnet3 and testnet4 the difficulty drops after 20 minutes, so the second ensures that a new template is returned in that case.

  Alternative approach to #31003, suggested in https://github.com/bitcoin/bitcoin/issues/31109#issuecomment-2451942362

ACKs for top commit:
  ryanofsky:
    Code review ACK cadbd4137d. Main change since last review is adding back a missing `m_interrupt` check in the waitNext loop. Also made various code cleanups in both commits.
  ismaelsadeeq:
    Code review ACK cadbd4137d
  vasild:
    ACK cadbd4137d

Tree-SHA512: c5a40053723c1c1674449ba1e4675718229a2022c8b0a4853b12a2c9180beb87536a1f99fde969a0ef099bca9ac69ca14ea4f399d277d2db7f556465ce47de95
2025-03-12 15:20:48 -04:00
MarcoFalke ffff4a293a
bench: Update span-serialize comment
Commit faecca9a85 changed the type of
block413567 from vector to span, but forgot to update the comment. Do it
now.
2025-03-12 19:47:56 +01:00
MarcoFalke fa4d6ec97b
refactor: Avoid false-positive gcc warning
GCC 14.2.1 will complain about a dangling reference after replacing Span
wiht std::span. This is a false-positive, because std::find does not
return a reference.

Remove the `&` to silence the warning. Also use ranges::find while
touching the line.

src/i2p.cpp:312:21: error: possibly dangling reference to a temporary [-Werror=dangling-reference]
  312 |         const auto& pos = std::find(kv.begin(), kv.end(), '=');
      |                     ^~~
src/i2p.cpp:312:36: note: the temporary was destroyed at the end of the full expression ‘std::find<__gnu_cxx::__normal_iterator<const char*, span<const char> >, char>((& kv)->std::span<const char>::begin(), (& kv)->std::span<const char>::end(), '=')’
  312 |         const auto& pos = std::find(kv.begin(), kv.end(), '=');
      |                           ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
2025-03-12 19:47:01 +01:00
MarcoFalke fa942332b4
scripted-diff: Bump copyright headers after std::span changes
Historically, the headers have been bumped some time after a file has
been touched. Do it now to avoid having to touch them again in the
future for that reason.

-BEGIN VERIFY SCRIPT-
 sed -i --regexp-extended 's;( 20[0-2][0-9])(-20[0-2][0-9])? The Bitcoin Core developers;\1-present The Bitcoin Core developers;g' $( git show --pretty="" --name-only HEAD~1 )
-END VERIFY SCRIPT-
2025-03-12 19:46:54 +01:00
MarcoFalke fa0c6b7179
refactor: Remove unused Span alias
Also, fixup some wording.
2025-03-12 19:45:49 +01:00
MarcoFalke fade0b5e5e
scripted-diff: Use std::span over Span
-BEGIN VERIFY SCRIPT-

 ren() { sed -i "s!\<$1\>!$2!g" $( git grep -l "$1" -- "./src" ":(exclude)src/span.h" ":(exclude)src/leveldb/db/log_test.cc" ) ; }

 ren Span            std::span
 ren AsBytes         std::as_bytes
 ren AsWritableBytes std::as_writable_bytes

 sed -i 's!SpanPopBack(Span!SpanPopBack(std::span!g' ./src/span.h

-END VERIFY SCRIPT-
2025-03-12 19:45:37 +01:00
MarcoFalke fadccc26c0
refactor: Make Span an alias of std::span
This uses a macro, which can be a bit more brittle than an alias
template. However, class template argument deduction for alias templates
is only implemented in clang-19.
2025-03-12 19:44:40 +01:00
MarcoFalke fa27e36717
test: Fix broken span_tests
* The comment is wrong claiming that void* was returned when void was
  returned in reality.
* The namespace is missing a name, leading to compile errors that are
  suppressed with non-standard pragmas, and leading to compile errors in
  future commits. Instead of using more non-standard suppressions, just
  add the missing name.
* The SpanableYes/No types are missing begin/end iterators, which will
  be needed when using std::span.
2025-03-12 19:44:30 +01:00
MarcoFalke fadf02ef8b
refactor: Return std::span from MakeUCharSpan
This is possible and safe, because std::span can implicitly convert into
Span, if needed.
2025-03-12 19:44:25 +01:00
MarcoFalke fa720b94be
refactor: Return std::span from MakeByteSpan
In theory this commit should only touch the span.h header, because
std::span can implicilty convert into Span in most places, if needed.

However, at least when using the clang compiler, there are some
false-positive lifetimebound warnings and some implicit conversions can
not be resolved.

Thus, this refactoring commit also changed the affected places to
replace Span with std::span.
2025-03-12 19:44:20 +01:00
MarcoFalke fa21597064
ci: Revert "Temporary workaround for old CCACHE_DIR cirrus env"
This reverts commit fa9747a896.
2025-03-12 17:45:02 +01:00
merge-script aa68ed27b8
Merge bitcoin/bitcoin#32041: build: bump CLIENT_VERSION_MAJOR to 29
a3f0e9a433 [build] bump CLIENT_VERSION_MAJOR to 29 (glozow)

Pull request description:

ACKs for top commit:
  fanquake:
    ACK a3f0e9a433

Tree-SHA512: 23a421a2b457a8e9fe8d4a831fcb21b665902a522695294997cc5175af533d91467c51856001a7bb98bfa6b122022803327d4dabfb186489e24e08f48216183b
2025-03-12 23:03:48 +08:00
glozow a3f0e9a433 [build] bump CLIENT_VERSION_MAJOR to 29 2025-03-12 10:58:37 -04:00
Sjors Provoost 36b6f36ac4
build: require sqlite when building the wallet
Require that sqlite is available in order to compile the wallet. Removes
instances of USE_SQLITE since it is no longer possible to not have
sqlite available.

The NO_SQLITE option is dropped from depends.

Co-authored-by: Ava Chow <github@achow101.com>
Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2025-03-12 15:42:38 +01:00
fanquake 5dfef6b9b3
depends: remove NO_HARDEN option
This only existed to workaround a (iirc libtool related) windows issue
that only occured when compiling without hardening. We no-longer use
libtool, and I can no-longer create the failure.
2025-03-12 20:04:10 +08:00
fanquake 1ef22ce335
depends: patch around PlacementNew issue in capnp
See #31772 and https://github.com/capnproto/capnproto/pull/2235.
2025-03-12 16:08:02 +08:00
Hennadii Stepanov 52ac17757e
cmake: Add `NO_CACHE_IF_FAILED` option for checking linker flags
Use it for checking `-fsanitize`.

This change improves the user experience when the configuration step
fails due to a missing library. Now, there is no need to manually clean
the CMake cache after installing the required library.
2025-03-10 16:55:48 +00:00
Hodlinator 3301d2cbe8
qa: Wait for txindex to avoid race condition
Can be verified to be necessary through adding std::this_thread::sleep_for(0.5s) at the beginning of TxIndex::CustomAppend.
2025-03-10 15:24:16 +01:00
Hodlinator 9bfb0d75ba
qa: Remove unnecessary -txindex args
(Parent commit ensured indexes in feature_init.py are actually used, otherwise they would be removed here as well).
2025-03-07 22:22:31 +01:00
Hodlinator 7ac281c19c
qa: Add missing coverage of corrupt indexes 2025-03-07 22:22:31 +01:00
Lőrinc d5537c18a9 fuzz: make sure DecodeBase58(Check) is called with valid values more often
In Base58 fuzz the two roundtrips are merged now, the new `decode_input` switches between a completely random input and a valid encoded one, to make sure the decoding passes more often.
The `max_ret_len` can also exceed the original length now and is being validated more thoroughly.

Co-authored-by: maflcko <6399679+maflcko@users.noreply.github.com>
Co-authored-by: marcofleon <marleo23@proton.me>
2025-03-05 22:30:28 +01:00
Lőrinc bad1433ef2 fuzz: Always restrict base conversion input lengths
They seem to cause timeouts:
> Issue 397734700: bitcoin-core:base58check_encode_decode: Timeout in base58check_encode_decode

The `encoded_string.empty()` check was corrected here to `decoded.empty()` to make sure the `(0, decoded.size() - 1)` range is always valid.

Co-authored-by: maflcko <6399679+maflcko@users.noreply.github.com>
Co-authored-by: marcofleon <marleo23@proton.me>
Co-authored-by: Martin Zumsande <mzumsande@gmail.com>
2025-03-05 22:28:08 +01:00
Martin Zumsande 11f8ab140f
test: wallet, coverage for crash on dup block disconnection during unclean shutdown
Co-authored-by: furszy <matiasfurszyfer@protonmail.com>
2025-03-05 10:40:04 -05:00
Eval EXEC f708498293
torcontrol: Limit reconnect timeout to max seconds and log delay in whole seconds
Signed-off-by: Eval EXEC <execvy@gmail.com>
2025-03-05 11:42:07 +08:00
Ryan Ofsky 57d8b1f1b3 cmake: Avoid fuzzer "multiple definition of `main'" errors
This change builds libraries with -fsanitize=fuzzer-no-link instead of
-fsanitize=fuzzer when the cmake -DSANITIZERS=fuzzer option is specified. This
is necessary to make fuzzing and IPC cmake options compatible with each other
and avoid CI failures in #30975 which enables IPC in the fuzzer CI build:

https://cirrus-ci.com/task/5366255504326656?logs=ci#L2817
https://cirrus-ci.com/task/5233064575500288?logs=ci#L2384

The failures can also be reproduced by checking out #31741 and building with
`cmake -B build -DBUILD_FOR_FUZZING=ON -DSANITIZERS=fuzzer -DENABLE_IPC=ON`
with this fix reverted.

The fix updates the cmake build so when -DSANITIZERS=fuzzer is specified, the
fuzz test binary is built with -fsanitize=fuzzer (so it can use libFuzzer's
main function), and libraries are built with -fsanitize=fuzzer-no-link (so they
can be linked into other executables with their own main functions).

Previously when -DSANITIZERS=fuzzer was specified, -fsanitize=fuzzer was
applied to ALL libraries and executables. This was inappropriate because it
made it impossible to build any executables other than the fuzz test executable
without triggering link errors:

- "multiple definition of `main'"
- "undefined reference to `LLVMFuzzerTestOneInput'"

if they depended on any libraries instrumented for fuzzing.

This was especially a problem when the ENABLE_IPC option was set because it
made building the mpgen code generator impossible so nothing else that depended
on generated sources, including the fuzz test binary, could be built either.

This commit was previously part of
https://github.com/bitcoin/bitcoin/pull/31741 and had some discussion there
starting in
https://github.com/bitcoin/bitcoin/pull/31741#pullrequestreview-2619682385
2025-03-04 14:45:05 -05:00
Antoine Poinsot e5ff4e416e qa: use a clearer and documented amount error in malleated snapshot
In the assumeutxo functional tests, the final test case with alternated UTxO data tests the error
raised when deserializing a snapshot that contains a coin with an amount not in range (<0 or
>MAX_MONEY).

The current malleation uses an undocumented byte string and offset which makes it hard to maintain.
In addition, the undocumented offset is set surprisingly high (39 bytes is well into the
serialization of the amount which starts at offset 36). Similarly the value is surprisingly small,
presumably one was adjusted for the other. But there is no comment explaining how they were chosen,
why not in a clearer manner and what they are supposed to represent.

Instead replace this seemingly magic value with a clear one, MAX_MONEY + 1, serialize the whole
value for the amount field at the correct offset, and document the whole thing for the next person
around.
2025-03-04 12:50:17 -05:00
Sebastian Falbesoner b34fdb5ade test: introduce output amount (de)compression routines 2025-03-04 12:50:17 -05:00
Hennadii Stepanov 18e83534ac
wallet: Replace "non-0" with "non-zero" in translatable error message
Transifex interprets the "-0" substring as a number in translatable
strings. Since not all translations preserve "-0," this triggers a
corresponding warning. While this warning could be disabled globally, it
is more reasonable to adjust the original string instead.
2025-03-04 16:29:43 +00:00
Sebastian Falbesoner a7911ed101 test: introduce VARINT (de)serialization routines 2025-03-04 10:08:12 -05:00
rkrux 8134a6b5d4
rpc: add cli example for `walletcreatefundedpsbt` RPC
The only example present earlier was one that creates an OP_RETURN output. This
lack of examples has discouraged me earlier to use this RPC. Adding an example
that creates PSBT sending bitcoin to address, a scenario that is much more common.
2025-03-03 15:11:59 +05:30
yancy a015b7e13d test: Add expected result assertions
This test returns the lowest weight solution.  Other possibilities
either exceed allowed weight or result in a higher weight.  Add an
assertion which shows that the lowest weight solution is found and
update the test description accordingly.

Remove the check that a result is returned since the expected result
assertion implies a result.
2025-03-01 11:28:41 -06:00
MarcoFalke fa99c3b544
test: Exclude SeedStartup from coverage counts 2025-02-25 10:15:00 +01:00
MarcoFalke fa579d663d
contrib: Add deterministic-unittest-coverage
This replaces the bash script with a tool based on clang/llvm tools.
2025-02-25 10:14:41 +01:00
brunoerg 21e9d39a37 docs: add release notes for 31603 2025-02-24 09:58:11 -03:00
brunoerg a8b548d75d test: `getdescriptorinfo`/`importdescriptors` with whitespace in pubkeys 2025-02-24 09:57:22 -03:00
brunoerg c7afca3d62 test: descriptor: check whitespace into keys 2025-02-24 09:57:22 -03:00
brunoerg cb722a3cea descriptor: check whitespace in ParsePubkeyInner
Due to Base58, keys with whitespace at the beginning or
at the end are successfully parsed. This commit adds a
check into `ParsePubkeyInner` to verify whether if the
first or last char of the key is a space.
2025-02-24 09:55:40 -03:00
MarcoFalke fa3940b1cb
contrib: deterministic-fuzz-coverage fixups
* Name the fuzz_corpora dir after its real name.
* Add missing cargo lock file.
* Use git instead of diff command to increase compatibility
* Use --help instead of --version to increase compatibility
* Use assert consistently for unexpected errors.
* Remove redundant Stdio::from.
* Fix typos.
2025-02-24 11:41:41 +01:00
MarcoFalke faf905b9b6
doc: Remove unused -fPIC
This is harmless, but no longer needed after commit
06b9236f43.
2025-02-24 11:38:02 +01:00
Antoine Poinsot 63b534f97e fuzz: sanity check hardcoded snapshot in utxo_snapshot target
The assumeutxo data for the fuzz target could change and invalidate the hash silently, preventing
the fuzz target from reaching some code paths.

Fix this by sanity checking the snapshot values during initialization.
2025-02-21 20:55:01 -05:00
Antoine Poinsot 3b85eba83a test util: split up ConnectBlock from MineBlock 2025-02-21 20:55:01 -05:00
brunoerg ba82240553 fuzz: split `coinselection` harness 2025-02-21 13:26:48 -03:00
Lőrinc 4cd95a2921 refactor: modernize remaining outdated trait patterns 2025-02-21 10:43:41 +01:00
Lőrinc ab2b67fce2 scripted-diff: modernize outdated trait patterns - values
See https://en.cppreference.com/w/cpp/types/is_enum for more details.

-BEGIN VERIFY SCRIPT-
sed -i -E 's/(std::[a-z_]+)(<[^<>]+>)::value\b/\1_v\2/g' $(git grep -l '::value' ./src ':(exclude)src/bench/nanobench.h' ':(exclude)src/minisketch' ':(exclude)src/span.h')
-END VERIFY SCRIPT-
2025-02-21 10:43:01 +01:00
Lőrinc 8327889f35 scripted-diff: modernize outdated trait patterns - types
The use of e.g. `std::underlying_type_t<T>` replaces the older `typename std::underlying_type<T>::type`.
The `_t` helper alias template (such as `std::underlying_type_t<T>`) introduced in C++14 offers a cleaner and more concise way to extract the type directly.
See https://en.cppreference.com/w/cpp/types/underlying_type for details.

-BEGIN VERIFY SCRIPT-
sed -i -E 's/(typename )?(std::[a-z_]+)(<[^<>]+>)::type\b/\2_t\3/g' $(git grep -l '::type' ./src ':(exclude)src/bench/nanobench.h' ':(exclude)src/leveldb' ':(exclude)src/minisketch' ':(exclude)src/span.h' ':(exclude)src/sync.h')
-END VERIFY SCRIPT-
2025-02-21 10:41:27 +01:00
Antoine Poinsot d1527f6b88 qa: correct off-by-one in utxo snapshot fuzz target
The chain starts at block 1, not genesis.
2025-02-19 16:12:35 -05:00
Sjors Provoost cadbd4137d
miner: have waitNext return after 20 min on testnet
On testnet we need to create a min diff template after 20 min.
2025-02-19 17:20:58 +01:00
Sjors Provoost d4020f502a
Add waitNext() to BlockTemplate interface 2025-02-19 17:20:57 +01:00
furszy 9ef429b6ae
wallet: fix crash on double block disconnection
The wallet crashes if it processes the same block disconnection event twice in a row due
to an incompatible coinbase transaction state.
This happens because 'disconnectBlock' provides 'TxStateInactive' without the "abandoned"
flag for coinbase transactions to 'SyncTransaction', while 'AddToWallet()' internally
modifies it to retain the abandoned state.

The flow is as follows:
1) On the first disconnection, the transaction state transitions from "confirmed" to
"inactive," bypassing the state equality check since the provided state differs. Then,
'AddToWallet' internally updates the state to "inactive + abandoned"

2) On the second disconnection, as we provide only the "inactive" state
to 'SyncTransaction()', the state equality assertion fails and crashes the wallet.
2025-02-19 11:07:08 -03:00
MarcoFalke fa1e0a7228
gitignore: target/
Needed for the recently added
contrib/devtools/deterministic-fuzz-coverage/target/
2025-02-18 20:46:30 +01:00
laanwj b9d4d5f66a net: Use GetAdaptersAddresses to get local addresses on Windows
Instead of a `gethostname` hack, use the official way of calling
`GetAdaptersAddresses` to get local network addresses on Windows.

As additional cleanup, move out `FromSockAddr` from MacOS and use it
everywhere appropriate.

Suggested by Ava Chow.
2025-02-13 15:20:19 +01:00
Eunovo 7edaf8b64c Benchmark Chainstate::ConnectBlock duration
Measure ConnectBlock performance for
- blocks containing only schnorr sigs
- blocks containing both schnorr and ecdsa sigs
- blocks containing only ecdsa sigs

This will allow testing and measurement of performance improvement for features like
batch verification of schnorr signatures
2025-02-13 13:05:12 +00:00
Antoine Poinsot eb0724f0de doc: banman: reference past vuln due to unbounded banlist 2025-02-12 15:10:28 -05:00
Antoine Poinsot ad616b6c01 doc: net: mention past vulnerability as rationale to limit incoming message size 2025-02-12 15:10:28 -05:00
Antoine Poinsot 4489117c3f doc: txrequest: point to past censorship vulnerability in tx re-request handling 2025-02-12 15:10:28 -05:00
Antoine Poinsot 68ac9542c4 doc: net_proc: reference past DoS vulnerability in orphan processing 2025-02-12 15:10:27 -05:00
Antoine Poinsot c02d9f6dd5 doc: net_proc: reference past defect regarding invalid GETDATA types 2025-02-12 15:08:37 -05:00
Antoine Poinsot 5e3d9f21df doc: validation: add a reference to historical header spam vulnerability 2025-02-12 15:08:37 -05:00
Sebastian Falbesoner a8333fc9ff scripted-diff: wallet: rename plain and encrypted master key variables
-BEGIN VERIFY SCRIPT-
sed -i s/_vMasterKey/plain_master_key/g ./src/wallet/wallet.cpp
sed -i s/kMasterKey/master_key/g ./src/wallet/wallet.cpp
sed -i "s/const MasterKeyMap::value_type& pMasterKey/const auto\& \[_, master_key\]/g" ./src/wallet/wallet.cpp
sed -i s/pMasterKey\.second/master_key/g ./src/wallet/wallet.cpp
sed -i "s/MasterKeyMap::value_type& pMasterKey/auto\& \[master_key_id, master_key\]/g" ./src/wallet/wallet.cpp
sed -i s/pMasterKey\.first/master_key_id/g ./src/wallet/wallet.cpp
-END VERIFY SCRIPT-
2025-01-27 18:11:21 +01:00
Sebastian Falbesoner 5a92077fd5 wallet: refactor: dedup master key decryption 2025-01-27 18:11:21 +01:00
Sebastian Falbesoner 846545947c wallet: refactor: dedup master key encryption / derivation rounds setting 2025-01-27 18:11:21 +01:00
Sebastian Falbesoner a6d9b415aa wallet: refactor: introduce `CMasterKey::DEFAULT_DERIVE_ITERATIONS` constant
This gets rid of the magic number used in both the `CMasterKey` ctor
and the wallet encryption / passphrase change methods.
2025-01-27 18:11:05 +01:00
Sebastian Falbesoner 62c209f50d wallet: doc: remove mentions of unavailable scrypt derivation method
These comments are there since wallet encryption was first introduced
(see commit 4e87d341f7, PR #352), but scrypt
was actually never implemented as a derivation method.
2025-01-27 18:01:42 +01:00
Antoine Poinsot ff0194a7ce miniscript: convert non-critical asserts to CHECK_NONFATAL
The Miniscript code contains assertions to prevent ending up in an insane state or prevent UB, but
also to enforce logical invariants. For the latter it is not necessary to crash the program if they
are broken. Raising an exception suffices, especially as this code is often called through the RPC
interface which can in turn handle the exception and the user can report it to developers.

This is based on previous work from Pieter Wuille.
2025-01-23 11:10:13 -05:00
ismaelsadeeq 5d82d92aff rpc: reserve space for `UniValue` variables in `blockToJSON`
- Reserving space avoid reallocation, this provide noticeable
  performance increase in verbosity 1.
2025-01-22 17:31:22 -05:00
ismaelsadeeq 6a506d5c37 UniValue: add reserve member function
- Only reserve keys when the typ is of `VOBJ`.
2025-01-22 17:31:22 -05:00
ismaelsadeeq bd461195f4 bench: support benching all verbosity of `BlockToJson` 2025-01-22 17:31:21 -05:00
brunoerg 50856695ef test: fix descriptors in `ismine_tests`
Some descriptors contain whitespace in public keys
within fragments. This fixes it.
2025-01-21 14:58:38 -03:00
Anthony Towns 7565563bc7 tests: refactor versionbits fuzz test
Test `VersionBitsConditionChecker` behaviour directly, rather than
reimplementing it, thus slightly improving fuzz test coverage of the
real code.
2025-01-21 00:38:03 +10:00
Anthony Towns 2e4e9b9608 tests: refactor versionbits unit test
Base the unit test directly on `VersionBitsConditionChecker`, slightly
improving coverage, in particular adding coverage for the the logic
regarding setting the TOP_BITS.
2025-01-21 00:38:03 +10:00
Anthony Towns 525c00f91b versionbits: Expose VersionBitsConditionChecker via impl header 2025-01-21 00:38:03 +10:00
Anthony Towns e74a7049b4 versionbits: Expose StateName function
Rather than essentially duplicating StateName in the unit tests, expose
it via the impl header.
2025-01-21 00:38:03 +10:00
Anthony Towns d00d1ed52c versionbits: Split out internal details into impl header 2025-01-21 00:38:03 +10:00
Anthony Towns 37b9b67a39 versionbits: Simplify VersionBitsCache API
Replaces State() (which returned ACTIVE/STARTED/etc) with IsActiveAfter()
which just returns a bool, as this was all State was actually used
for. Drops Mask(), which was only used in tests and can be replaced with
`1<<bit`, and also drops StateSinceHeight() and Statistics(), which are
now only used internally for Info().
2025-01-21 00:38:03 +10:00
Anthony Towns 1198e7d2fd versionbits: Move BIP9 status logic for getblocktemplate to versionbits
Rather than having the RPC code have knowledge about how BIP9 is
implemented, create a reporting function in the versionbits code, and
limit the RPC code to coverting the result of that into the appropriate
output for getblocktemplate.
2025-01-21 00:38:03 +10:00
Anthony Towns b1e967c3ec versionbits: Move getdeploymentinfo logic to versionbits
Rather than having the RPC code have knowledge about how BIP9 is
implemented, create a reporting function in the versionbits code, and
limit the RPC code to coverting the result of that into Univalue/JSON.
2025-01-21 00:38:02 +10:00
Anthony Towns 3bd32c2055 versionbits: Move WarningBits logic from validation to versionbits 2025-01-21 00:38:02 +10:00
Anthony Towns 5da119e5d0 versionbits: Change BIP9Stats to uint32_t types 2025-01-21 00:38:02 +10:00
Anthony Towns a679040ec1 consensus/params: Move version bits period/threshold to bip9 param
Rather than having the rule change period/threshold be constant for all
potential deployments on a chain, have it be specific to the deployment
itself. This both matches history (BIP 9 specified a 2016 block period
and 1916 block threshold; BIP 91 specified a 336 block period and 269
block threshold; and BIP 341 specified a 2016 block period and 1815
block threshold), and allows the code to be simplified, as only the
BIP9Deployment structure is needed, not the full Consensus::Params
structure.
2025-01-21 00:38:02 +10:00
Andrew Toth 0ad7d7abdb
test: chainstate write test for periodic chainstate flush 2024-12-28 10:14:01 -05:00
Anthony Towns e9d617095d versionbits: Remove params from AbstractThresholdConditionChecker
For an abstract class, specifying parameters in detail serves no point;
and for the concrete implementation, changing the consensus parameters
between invocations doesn't make sense. So simplify the class by removing
the consensus params from the method arguments, and just make it a member
variable in the concrete object where needed. This also allows dropping
dummy parameters from the unit/fuzz tests.
2024-12-19 06:40:19 +10:00
Anthony Towns 9bc41f1b48 versionbits: Use std::array instead of C-style arrays 2024-12-19 06:40:19 +10:00
Anthony Towns b81f37031c p2p: Increase tx relay rate
In the presence of smaller transactions on the network, blocks can sustain a
higher relay rate than 7tx/second. In this event, the per-peer inventory queues
can grow too large.

This commit bumps the rate up to 14 tx/s (for inbound peers), increasing the
safety margin by a factor of 2.

Outbound peers continue to receive relayed transactions at 2.5x the rate of
inbound peers, for a rate of 35tx/second.

Co-Authored-By: Suhas Daftuar <sdaftuar@gmail.com>
2024-12-03 17:24:45 +10:00
MarcoFalke fa21f83d29
ci: Use G++ in valgrind tasks 2024-11-13 14:10:04 +01:00
MarcoFalke fabd05bf65
refactor: Fix net_processing iwyu includes 2024-11-13 14:09:58 +01:00
MarcoFalke fa1622db20
refactor: Make node_id a const& in RemoveBlockRequest
This works around a valgrind false-positive.
2024-11-13 14:08:14 +01:00
furszy 002b792b9a
gui: decouple WalletModel from RPCExecutor
Since the `WalletModel` class is unavailable when compiling
without wallet support `(-DENABLE_WALLET=0)`, the RPC executor
class should not be coupled to it. This decoupling ensures GUI
compatibility with builds that omit wallet support.
2024-10-04 16:58:49 -03:00
1487 changed files with 75675 additions and 106175 deletions

View File

@ -1,214 +0,0 @@
env: # Global defaults
CIRRUS_CLONE_DEPTH: 1
CIRRUS_LOG_TIMESTAMP: true
MAKEJOBS: "-j10"
TEST_RUNNER_PORT_MIN: "14000" # Must be larger than 12321, which is used for the http cache. See https://cirrus-ci.org/guide/writing-tasks/#http-cache
CI_FAILFAST_TEST_LEAVE_DANGLING: "1" # Cirrus CI does not care about dangling processes and setting this variable avoids killing the CI script itself on error
# A self-hosted machine(s) can be used via Cirrus CI. It can be configured with
# multiple users to run tasks in parallel. No sudo permission is required.
#
# https://cirrus-ci.org/guide/persistent-workers/
#
# Generally, a persistent worker must run Ubuntu 23.04+ or Debian 12+.
#
# The following specific types should exist, with the following requirements:
# - small: For an x86_64 machine, with at least 2 vCPUs and 8 GB of memory.
# - medium: For an x86_64 machine, with at least 4 vCPUs and 16 GB of memory.
# - arm64: For an aarch64 machine, with at least 2 vCPUs and 8 GB of memory.
#
# CI jobs for the latter configuration can be run on x86_64 hardware
# by installing qemu-user-static, which works out of the box with
# podman or docker. Background: https://stackoverflow.com/a/72890225/313633
#
# The above machine types are matched to each task by their label. Refer to the
# Cirrus CI docs for more details.
#
# When a contributor maintains a fork of the repo, any pull request they make
# to their own fork, or to the main repository, will trigger two CI runs:
# one for the branch push and one for the pull request.
# This can be avoided by setting SKIP_BRANCH_PUSH=true as a custom env variable
# in Cirrus repository settings, accessible from
# https://cirrus-ci.com/github/my-organization/my-repository
#
# On machines that are persisted between CI jobs, RESTART_CI_DOCKER_BEFORE_RUN=1
# ensures that previous containers and artifacts are cleared before each run.
# This requires installing Podman instead of Docker.
#
# Futhermore:
# - podman-docker-4.1+ is required due to the bugfix in 4.1
# (https://github.com/bitcoin/bitcoin/pull/21652#issuecomment-1657098200)
# - The ./ci/ dependencies (with cirrus-cli) should be installed. One-liner example
# for a single user setup with sudo permission:
#
# ```
# apt update && apt install git screen python3 bash podman-docker uidmap slirp4netns curl -y && curl -L -o cirrus "https://github.com/cirruslabs/cirrus-cli/releases/latest/download/cirrus-linux-$(dpkg --print-architecture)" && mv cirrus /usr/local/bin/cirrus && chmod +x /usr/local/bin/cirrus
# ```
#
# - There are no strict requirements on the hardware. Having fewer CPU threads
# than recommended merely causes the CI script to run slower.
# To avoid rare and intermittent OOM due to short memory usage spikes,
# it is recommended to add (and persist) swap:
#
# ```
# fallocate -l 16G /swapfile_ci && chmod 600 /swapfile_ci && mkswap /swapfile_ci && swapon /swapfile_ci && ( echo '/swapfile_ci none swap sw 0 0' | tee -a /etc/fstab )
# ```
#
# - To register the persistent worker, open a `screen` session and run:
#
# ```
# RESTART_CI_DOCKER_BEFORE_RUN=1 screen cirrus worker run --labels type=todo_fill_in_type --token todo_fill_in_token
# ```
# https://cirrus-ci.org/guide/tips-and-tricks/#sharing-configuration-between-tasks
filter_template: &FILTER_TEMPLATE
# Allow forks to specify SKIP_BRANCH_PUSH=true and skip CI runs when a branch is pushed,
# but still run CI when a PR is created.
# https://cirrus-ci.org/guide/writing-tasks/#conditional-task-execution
skip: $SKIP_BRANCH_PUSH == "true" && $CIRRUS_PR == ""
stateful: false # https://cirrus-ci.org/guide/writing-tasks/#stateful-tasks
base_template: &BASE_TEMPLATE
<< : *FILTER_TEMPLATE
merge_base_script:
# Require git (used in fingerprint_script).
- git --version || ( apt-get update && apt-get install -y git )
- if [ "$CIRRUS_PR" = "" ]; then exit 0; fi
- git fetch --depth=1 $CIRRUS_REPO_CLONE_URL "pull/${CIRRUS_PR}/merge"
- git checkout FETCH_HEAD # Use merged changes to detect silent merge conflicts
# Also, the merge commit is used to lint COMMIT_RANGE="HEAD~..HEAD"
main_template: &MAIN_TEMPLATE
timeout_in: 120m # https://cirrus-ci.org/faq/#instance-timed-out
ci_script:
- ./ci/test_run_all.sh
global_task_template: &GLOBAL_TASK_TEMPLATE
<< : *BASE_TEMPLATE
<< : *MAIN_TEMPLATE
compute_credits_template: &CREDITS_TEMPLATE
# https://cirrus-ci.org/pricing/#compute-credits
# Only use credits for pull requests to the main repo
use_compute_credits: $CIRRUS_REPO_FULL_NAME == 'bitcoin/bitcoin' && $CIRRUS_PR != ""
task:
name: 'lint'
<< : *BASE_TEMPLATE
container:
image: debian:bookworm
cpu: 1
memory: 1G
# For faster CI feedback, immediately schedule the linters
<< : *CREDITS_TEMPLATE
test_runner_cache:
folder: "/lint_test_runner"
fingerprint_script: echo $CIRRUS_TASK_NAME $(git rev-parse HEAD:test/lint/test_runner)
python_cache:
folder: "/python_build"
fingerprint_script: cat .python-version /etc/os-release
unshallow_script:
- git fetch --unshallow --no-tags
lint_script:
- ./ci/lint_run_all.sh
task:
name: 'tidy'
<< : *GLOBAL_TASK_TEMPLATE
persistent_worker:
labels:
type: medium
env:
FILE_ENV: "./ci/test/00_setup_env_native_tidy.sh"
task:
name: 'ARM, unit tests, no functional tests'
<< : *GLOBAL_TASK_TEMPLATE
persistent_worker:
labels:
type: arm64 # Use arm64 worker to sidestep qemu and avoid a slow CI: https://github.com/bitcoin/bitcoin/pull/28087#issuecomment-1649399453
env:
FILE_ENV: "./ci/test/00_setup_env_arm.sh"
task:
name: 'Win64-cross'
<< : *GLOBAL_TASK_TEMPLATE
persistent_worker:
labels:
type: small
env:
FILE_ENV: "./ci/test/00_setup_env_win64.sh"
task:
name: 'CentOS, depends, gui'
<< : *GLOBAL_TASK_TEMPLATE
persistent_worker:
labels:
type: small
env:
FILE_ENV: "./ci/test/00_setup_env_native_centos.sh"
task:
name: 'previous releases, depends DEBUG'
<< : *GLOBAL_TASK_TEMPLATE
persistent_worker:
labels:
type: small
env:
FILE_ENV: "./ci/test/00_setup_env_native_previous_releases.sh"
task:
name: 'TSan, depends, gui'
<< : *GLOBAL_TASK_TEMPLATE
persistent_worker:
labels:
type: medium
env:
FILE_ENV: "./ci/test/00_setup_env_native_tsan.sh"
task:
name: 'MSan, depends'
<< : *GLOBAL_TASK_TEMPLATE
persistent_worker:
labels:
type: small
timeout_in: 300m # Use longer timeout for the *rare* case where a full build (llvm + msan + depends + ...) needs to be done.
env:
FILE_ENV: "./ci/test/00_setup_env_native_msan.sh"
task:
name: 'fuzzer,address,undefined,integer, no depends'
<< : *GLOBAL_TASK_TEMPLATE
persistent_worker:
labels:
type: medium
timeout_in: 240m # larger timeout, due to the high CPU demand
env:
FILE_ENV: "./ci/test/00_setup_env_native_fuzz.sh"
task:
name: 'multiprocess, i686, DEBUG'
<< : *GLOBAL_TASK_TEMPLATE
persistent_worker:
labels:
type: medium
env:
FILE_ENV: "./ci/test/00_setup_env_i686_multiprocess.sh"
task:
name: 'no wallet, libbitcoinkernel'
<< : *GLOBAL_TASK_TEMPLATE
persistent_worker:
labels:
type: small
env:
FILE_ENV: "./ci/test/00_setup_env_native_nowallet_libbitcoinkernel.sh"
task:
name: 'macOS-cross, gui, no tests'
<< : *GLOBAL_TASK_TEMPLATE
persistent_worker:
labels:
type: small
env:
FILE_ENV: "./ci/test/00_setup_env_mac_cross.sh"

View File

@ -28,7 +28,7 @@ body:
id: useful-skills
attributes:
label: Useful Skills
description: For example, “`std::thread`”, “Qt5 GUI and async GUI design” or “basic understanding of Bitcoin mining and the Bitcoin Core RPC interface”.
description: For example, “`std::thread`”, “Qt6 GUI and async GUI design” or “basic understanding of Bitcoin mining and the Bitcoin Core RPC interface”.
value: |
* Compiling Bitcoin Core from source
* Running the C++ unit tests and the Python functional tests

View File

@ -0,0 +1,55 @@
name: 'Configure Docker'
description: 'Set up Docker build driver and configure build cache args'
inputs:
cache-provider:
description: 'gha or cirrus cache provider'
required: true
options:
- gh
- cirrus
runs:
using: 'composite'
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
# Use host network to allow access to cirrus gha cache running on the host
driver-opts: |
network=host
# This is required to allow buildkit to access the actions cache
- name: Expose actions cache variables
uses: actions/github-script@v6
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env['ACTIONS_CACHE_URL'])
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env['ACTIONS_RUNTIME_TOKEN'])
- name: Construct docker build cache args
shell: bash
run: |
# Configure docker build cache backend
#
# On forks the gha cache will work but will use Github's cache backend.
# Docker will check for variables $ACTIONS_CACHE_URL, $ACTIONS_RESULTS_URL and $ACTIONS_RUNTIME_TOKEN
# which are set automatically when running on GitHub infra: https://docs.docker.com/build/cache/backends/gha/#synopsis
# Use cirrus cache host
if [[ ${{ inputs.cache-provider }} == 'cirrus' ]]; then
url_args="url=${CIRRUS_CACHE_HOST},url_v2=${CIRRUS_CACHE_HOST}"
else
url_args=""
fi
# Always optimistically --cachefrom in case a cache blob exists
args=(--cache-from "type=gha${url_args:+,${url_args}},scope=${CONTAINER_NAME}")
# If this is a push to the default branch, also add --cacheto to save the cache
if [[ ${{ github.event_name }} == "push" && ${{ github.ref_name }} == ${{ github.event.repository.default_branch }} ]]; then
args+=(--cache-to "type=gha${url_args:+,${url_args}},mode=max,ignore-error=true,scope=${CONTAINER_NAME}")
fi
# Always `--load` into docker images (needed when using the `docker-container` build driver).
args+=(--load)
echo "DOCKER_BUILD_CACHE_ARG=${args[*]}" >> $GITHUB_ENV

View File

@ -0,0 +1,27 @@
name: 'Configure environment'
description: 'Configure CI, cache and container name environment variables'
runs:
using: 'composite'
steps:
- name: Set CI and cache directories
shell: bash
run: |
echo "BASE_ROOT_DIR=${{ runner.temp }}" >> "$GITHUB_ENV"
echo "BASE_BUILD_DIR=${{ runner.temp }}/build" >> "$GITHUB_ENV"
echo "CCACHE_DIR=${{ runner.temp }}/ccache_dir" >> $GITHUB_ENV
echo "DEPENDS_DIR=${{ runner.temp }}/depends" >> "$GITHUB_ENV"
echo "BASE_CACHE=${{ runner.temp }}/depends/built" >> $GITHUB_ENV
echo "SOURCES_PATH=${{ runner.temp }}/depends/sources" >> $GITHUB_ENV
echo "PREVIOUS_RELEASES_DIR=${{ runner.temp }}/previous_releases" >> $GITHUB_ENV
- name: Set cache hashes
shell: bash
run: |
echo "DEPENDS_HASH=$(git ls-tree HEAD depends "ci/test/$FILE_ENV" | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
echo "PREVIOUS_RELEASES_HASH=$(git ls-tree HEAD test/get_previous_releases.py | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- name: Get container name
shell: bash
run: |
source $FILE_ENV
echo "CONTAINER_NAME=$CONTAINER_NAME" >> "$GITHUB_ENV"

View File

@ -0,0 +1,47 @@
name: 'Restore Caches'
description: 'Restore ccache, depends sources, and built depends caches'
runs:
using: 'composite'
steps:
- name: Restore Ccache cache
id: ccache-cache
uses: cirruslabs/cache/restore@v4
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-${{ env.CONTAINER_NAME }}-${{ github.run_id }}
restore-keys: |
ccache-${{ env.CONTAINER_NAME }}-
- name: Restore depends sources cache
id: depends-sources
uses: cirruslabs/cache/restore@v4
with:
path: ${{ env.SOURCES_PATH }}
key: depends-sources-${{ env.CONTAINER_NAME }}-${{ env.DEPENDS_HASH }}
restore-keys: |
depends-sources-${{ env.CONTAINER_NAME }}-
- name: Restore built depends cache
id: depends-built
uses: cirruslabs/cache/restore@v4
with:
path: ${{ env.BASE_CACHE }}
key: depends-built-${{ env.CONTAINER_NAME }}-${{ env.DEPENDS_HASH }}
restore-keys: |
depends-built-${{ env.CONTAINER_NAME }}-
- name: Restore previous releases cache
id: previous-releases
uses: cirruslabs/cache/restore@v4
with:
path: ${{ env.PREVIOUS_RELEASES_DIR }}
key: previous-releases-${{ env.CONTAINER_NAME }}-${{ env.PREVIOUS_RELEASES_HASH }}
restore-keys: |
previous-releases-${{ env.CONTAINER_NAME }}-
- name: export cache hits
shell: bash
run: |
echo "depends-sources-cache-hit=${{ steps.depends-sources.outputs.cache-hit }}" >> $GITHUB_ENV
echo "depends-built-cache-hit=${{ steps.depends-built.outputs.cache-hit }}" >> $GITHUB_ENV
echo "previous-releases-cache-hit=${{ steps.previous-releases.outputs.cache-hit }}" >> $GITHUB_ENV

39
.github/actions/save-caches/action.yml vendored Normal file
View File

@ -0,0 +1,39 @@
name: 'Save Caches'
description: 'Save ccache, depends sources, and built depends caches'
runs:
using: 'composite'
steps:
- name: debug cache hit inputs
shell: bash
run: |
echo "depends sources direct cache hit to primary key: ${{ env.depends-sources-cache-hit }}"
echo "depends built direct cache hit to primary key: ${{ env.depends-built-cache-hit }}"
echo "previous releases direct cache hit to primary key: ${{ env.previous-releases-cache-hit }}"
- name: Save Ccache cache
uses: cirruslabs/cache/save@v4
if: ${{ (github.event_name == 'push') && (github.ref_name == github.event.repository.default_branch) }}
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-${{ env.CONTAINER_NAME }}-${{ github.run_id }}
- name: Save depends sources cache
uses: cirruslabs/cache/save@v4
if: ${{ (github.event_name == 'push') && (github.ref_name == github.event.repository.default_branch) && (env.depends-sources-cache-hit != 'true') }}
with:
path: ${{ env.SOURCES_PATH }}
key: depends-sources-${{ env.CONTAINER_NAME }}-${{ env.DEPENDS_HASH }}
- name: Save built depends cache
uses: cirruslabs/cache/save@v4
if: ${{ (github.event_name == 'push') && (github.ref_name == github.event.repository.default_branch) && (env.depends-built-cache-hit != 'true' )}}
with:
path: ${{ env.BASE_CACHE }}
key: depends-built-${{ env.CONTAINER_NAME }}-${{ env.DEPENDS_HASH }}
- name: Save previous releases cache
uses: cirruslabs/cache/save@v4
if: ${{ (github.event_name == 'push') && (github.ref_name == github.event.repository.default_branch) && (env.previous-releases-cache-hit != 'true' )}}
with:
path: ${{ env.PREVIOUS_RELEASES_DIR }}
key: previous-releases-${{ env.CONTAINER_NAME }}-${{ env.PREVIOUS_RELEASES_HASH }}

67
.github/ci-test-each-commit-exec.py vendored Executable file
View File

@ -0,0 +1,67 @@
#!/usr/bin/env python3
# Copyright (c) The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://opensource.org/license/mit/.
import subprocess
import sys
import shlex
def run(cmd, **kwargs):
print("+ " + shlex.join(cmd), flush=True)
try:
return subprocess.run(cmd, check=True, **kwargs)
except Exception as e:
sys.exit(e)
def main():
print("Running tests on commit ...")
run(["git", "log", "-1"])
num_procs = int(run(["nproc"], stdout=subprocess.PIPE).stdout)
run([
"cmake",
"-B",
"build",
"-Werror=dev",
# Use clang++, because it is a bit faster and uses less memory than g++
"-DCMAKE_C_COMPILER=clang",
"-DCMAKE_CXX_COMPILER=clang++",
# Use mold, because it is faster than the default linker
"-DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=mold",
# Use Debug build type for more debug checks, but enable optimizations
"-DAPPEND_CXXFLAGS='-O3 -g2'",
"-DAPPEND_CFLAGS='-O3 -g2'",
"-DCMAKE_BUILD_TYPE=Debug",
"-DWERROR=ON",
"-DWITH_ZMQ=ON",
"-DBUILD_GUI=ON",
"-DBUILD_BENCH=ON",
"-DBUILD_FUZZ_BINARY=ON",
"-DWITH_USDT=ON",
"-DCMAKE_CXX_FLAGS=-Wno-error=unused-member-function",
])
run(["cmake", "--build", "build", "-j", str(num_procs)])
run([
"ctest",
"--output-on-failure",
"--stop-on-failure",
"--test-dir",
"build",
"-j",
str(num_procs),
])
run([
sys.executable,
"./build/test/functional/test_runner.py",
"-j",
str(num_procs * 2),
"--combinedlogslen=99999999",
])
if __name__ == "__main__":
main()

View File

@ -1,6 +1,6 @@
# Copyright (c) 2023-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
# file COPYING or https://opensource.org/license/mit.
name: CI
on:
@ -19,9 +19,32 @@ concurrency:
env:
CI_FAILFAST_TEST_LEAVE_DANGLING: 1 # GHA does not care about dangling processes and setting this variable avoids killing the CI script itself on error
MAKEJOBS: '-j10'
CIRRUS_CACHE_HOST: http://127.0.0.1:12321/ # When using Cirrus Runners this host can be used by the docker `gha` build cache type.
REPO_USE_CIRRUS_RUNNERS: 'bitcoin/bitcoin' # Use cirrus runners and cache for this repo, instead of falling back to the slow GHA runners
defaults:
run:
# Enforce fail-fast behavior for all platforms.
# See: https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference
shell: bash
jobs:
runners:
name: 'determine runners'
runs-on: ubuntu-latest
outputs:
provider: ${{ steps.runners.outputs.provider }}
steps:
- id: runners
run: |
if [[ "${REPO_USE_CIRRUS_RUNNERS}" == "${{ github.repository }}" ]]; then
echo "provider=cirrus" >> "$GITHUB_OUTPUT"
echo "::notice title=Runner Selection::Using Cirrus Runners"
else
echo "provider=gha" >> "$GITHUB_OUTPUT"
echo "::notice title=Runner Selection::Using GitHub-hosted runners"
fi
test-each-commit:
name: 'test each commit'
runs-on: ubuntu-24.04
@ -32,7 +55,7 @@ jobs:
steps:
- name: Determine fetch depth
run: echo "FETCH_DEPTH=$((${{ github.event.pull_request.commits }} + 2))" >> "$GITHUB_ENV"
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: ${{ env.FETCH_DEPTH }}
@ -65,20 +88,24 @@ jobs:
EXCLUDE_MERGE_BASE_ANCESTORS=^${MERGE_BASE}^@
fi
echo "TEST_BASE=$(git rev-list -n$((${{ env.MAX_COUNT }} + 1)) --reverse HEAD $EXCLUDE_MERGE_BASE_ANCESTORS | head -1)" >> "$GITHUB_ENV"
- run: |
git fetch origin "${GITHUB_BASE_REF}"
git config user.email "ci@example.com"
git config user.name "CI"
- run: |
sudo apt-get update
sudo apt-get install clang ccache build-essential cmake pkgconf python3-zmq libevent-dev libboost-dev libsqlite3-dev libdb++-dev systemtap-sdt-dev libzmq3-dev qtbase5-dev qttools5-dev qttools5-dev-tools qtwayland5 libqrencode-dev -y
sudo apt-get install clang mold ccache build-essential cmake ninja-build pkgconf python3-zmq libevent-dev libboost-dev libsqlite3-dev systemtap-sdt-dev libzmq3-dev qt6-base-dev qt6-tools-dev qt6-l10n-tools libqrencode-dev capnproto libcapnp-dev -y
sudo pip3 install --break-system-packages pycapnp
- name: Compile and run tests
run: |
# Run tests on commits after the last merge commit and before the PR head commit
# Use clang++, because it is a bit faster and uses less memory than g++
git rebase --exec "echo Running test-one-commit on \$( git log -1 ) && CC=clang CXX=clang++ cmake -B build -DWERROR=ON -DWITH_ZMQ=ON -DBUILD_GUI=ON -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON -DWITH_BDB=ON -DWITH_USDT=ON -DCMAKE_CXX_FLAGS='-Wno-error=unused-member-function' && cmake --build build -j $(nproc) && ctest --output-on-failure --stop-on-failure --test-dir build -j $(nproc) && ./build/test/functional/test_runner.py -j $(( $(nproc) * 2 )) --combinedlogslen=99999999" ${{ env.TEST_BASE }}
git rebase --exec "git merge --no-commit origin/${GITHUB_BASE_REF} && python3 ./.github/ci-test-each-commit-exec.py && git reset --hard" ${{ env.TEST_BASE }}
macos-native-arm64:
name: ${{ matrix.job-name }}
# Use any image to support the xcode-select below, but hardcode version to avoid silent upgrades (and breaks).
# See: https://github.com/actions/runner-images#available-images.
runs-on: macos-14
runs-on: macos-15
# When a contributor maintains a fork of the repo, any pull request they make
# to their own fork, or to the main repository, will trigger two CI runs:
@ -96,26 +123,30 @@ jobs:
include:
- job-type: standard
file-env: './ci/test/00_setup_env_mac_native.sh'
job-name: 'macOS 14 native, arm64, no depends, sqlite only, gui'
job-name: 'macOS native, no depends, sqlite only, gui'
- job-type: fuzz
file-env: './ci/test/00_setup_env_mac_native_fuzz.sh'
job-name: 'macOS 14 native, arm64, fuzz'
job-name: 'macOS native, fuzz'
env:
DANGER_RUN_CI_ON_HOST: 1
BASE_ROOT_DIR: ${{ github.workspace }}
steps:
- name: Checkout
uses: actions/checkout@v4
- &CHECKOUT
name: Checkout
uses: actions/checkout@v5
with:
# Ensure the latest merged pull request state is used, even on re-runs.
ref: &CHECKOUT_REF_TMPL ${{ github.event_name == 'pull_request' && github.ref || '' }}
- name: Clang version
run: |
# Use the earliest Xcode supported by the version of macOS denoted in
# doc/release-notes-empty-template.md and providing at least the
# minimum clang version denoted in doc/dependencies.md.
# See: https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes
sudo xcode-select --switch /Applications/Xcode_15.0.app
# See: https://developer.apple.com/documentation/xcode-release-notes/xcode-16-release-notes
sudo xcode-select --switch /Applications/Xcode_16.0.app
clang --version
- name: Install Homebrew packages
@ -124,7 +155,12 @@ jobs:
run: |
# A workaround for "The `brew link` step did not complete successfully" error.
brew install --quiet python@3 || brew link --overwrite python@3
brew install --quiet coreutils ninja pkgconf gnu-getopt ccache boost libevent zeromq qt@5 qrencode
brew install --quiet coreutils ninja pkgconf gnu-getopt ccache boost libevent zeromq qt@6 qrencode capnp
- name: Install Python packages
run: |
git clone -b v2.1.0 https://github.com/capnproto/pycapnp
pip3 install ./pycapnp -C force-bundled-libcapnp=True --break-system-packages
- name: Set Ccache directory
run: echo "CCACHE_DIR=${RUNNER_TEMP}/ccache_dir" >> "$GITHUB_ENV"
@ -150,10 +186,8 @@ jobs:
# https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
key: ${{ github.job }}-${{ matrix.job-type }}-ccache-${{ github.run_id }}
win64-native:
windows-native-dll:
name: ${{ matrix.job-name }}
# Use latest image, but hardcode version to avoid silent upgrades (and breaks).
# See: https://github.com/actions/runner-images#available-images.
runs-on: windows-2022
if: ${{ vars.SKIP_BRANCH_PUSH != 'true' || github.event_name == 'pull_request' }}
@ -168,23 +202,28 @@ jobs:
job-type: [standard, fuzz]
include:
- job-type: standard
generate-options: '-DBUILD_GUI=ON -DWITH_BDB=ON -DWITH_ZMQ=ON -DBUILD_BENCH=ON -DWERROR=ON'
job-name: 'Win64 native, VS 2022'
generate-options: '-DBUILD_GUI=ON -DWITH_ZMQ=ON -DBUILD_BENCH=ON -DWERROR=ON'
job-name: 'Windows native, VS 2022'
- job-type: fuzz
generate-options: '-DVCPKG_MANIFEST_NO_DEFAULT_FEATURES=ON -DVCPKG_MANIFEST_FEATURES="sqlite" -DBUILD_GUI=OFF -DBUILD_FOR_FUZZING=ON -DWERROR=ON'
job-name: 'Win64 native fuzz, VS 2022'
generate-options: '-DVCPKG_MANIFEST_NO_DEFAULT_FEATURES=ON -DVCPKG_MANIFEST_FEATURES="wallet" -DBUILD_GUI=OFF -DBUILD_FOR_FUZZING=ON -DWERROR=ON'
job-name: 'Windows native, fuzz, VS 2022'
steps:
- name: Checkout
uses: actions/checkout@v4
- *CHECKOUT
- name: Configure Developer Command Prompt for Microsoft Visual C++
# Using microsoft/setup-msbuild is not enough.
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64
- &SET_UP_VS
name: Set up VS Developer Prompt
shell: pwsh -Command "$PSVersionTable; $PSNativeCommandUseErrorActionPreference = $true; $ErrorActionPreference = 'Stop'; & '{0}'"
run: |
$vswherePath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$installationPath = & $vswherePath -latest -property installationPath
& "${env:COMSPEC}" /s /c "`"$installationPath\Common7\Tools\vsdevcmd.bat`" -arch=x64 -no_logo && set" | foreach-object {
$name, $value = $_ -split '=', 2
echo "$name=$value" >> $env:GITHUB_ENV
}
- name: Get tool information
shell: pwsh
run: |
cmake -version | Tee-Object -FilePath "cmake_version"
Write-Output "---"
@ -192,12 +231,13 @@ jobs:
$env:VCToolsVersion | Tee-Object -FilePath "toolset_version"
py -3 --version
Write-Host "PowerShell version $($PSVersionTable.PSVersion.ToString())"
bash --version
- name: Using vcpkg with MSBuild
run: |
Set-Location "$env:VCPKG_INSTALLATION_ROOT"
Add-Content -Path "triplets\x64-windows.cmake" -Value "set(VCPKG_BUILD_TYPE release)"
Add-Content -Path "triplets\x64-windows-static.cmake" -Value "set(VCPKG_BUILD_TYPE release)"
echo "set(VCPKG_BUILD_TYPE release)" >> "${VCPKG_INSTALLATION_ROOT}/triplets/x64-windows.cmake"
# Workaround for libevent, which requires CMake 3.1 but is incompatible with CMake >= 4.0.
sed -i '1s/^/set(ENV{CMAKE_POLICY_VERSION_MINIMUM} 3.5)\n/' "${VCPKG_INSTALLATION_ROOT}/scripts/ports.cmake"
- name: vcpkg tools cache
uses: actions/cache@v4
@ -214,7 +254,7 @@ jobs:
- name: Generate build system
run: |
cmake -B build --preset vs2022-static -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT\scripts\buildsystems\vcpkg.cmake" ${{ matrix.generate-options }}
cmake -B build -Werror=dev --preset vs2022 -DCMAKE_TOOLCHAIN_FILE="${VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake" ${{ matrix.generate-options }}
- name: Save vcpkg binary cache
uses: actions/cache/save@v4
@ -226,32 +266,56 @@ jobs:
- name: Build
working-directory: build
run: |
cmake --build . -j $env:NUMBER_OF_PROCESSORS --config Release
cmake --build . -j $NUMBER_OF_PROCESSORS --config Release
- name: Check executable manifests
if: matrix.job-type == 'standard'
working-directory: build
shell: pwsh -Command "$PSVersionTable; $PSNativeCommandUseErrorActionPreference = $true; $ErrorActionPreference = 'Stop'; & '{0}'"
run: |
mt.exe -nologo -inputresource:bin\Release\bitcoind.exe -out:bitcoind.manifest
Get-Content bitcoind.manifest
Get-ChildItem -Filter "bin\Release\*.exe" | ForEach-Object {
$exeName = $_.Name
# Skip as they currently do not have manifests
if ($exeName -eq "fuzz.exe" -or $exeName -eq "bench_bitcoin.exe" -or $exeName -eq "test_bitcoin-qt.exe") {
Write-Host "Skipping $exeName (no manifest present)"
return
}
Write-Host "Checking $exeName"
& mt.exe -nologo -inputresource:$_.FullName -validate_manifest
}
- name: Run test suite
if: matrix.job-type == 'standard'
working-directory: build
env:
QT_PLUGIN_PATH: '${{ github.workspace }}\build\vcpkg_installed\x64-windows\Qt6\plugins'
run: |
ctest --output-on-failure --stop-on-failure -j $env:NUMBER_OF_PROCESSORS -C Release
ctest --output-on-failure --stop-on-failure -j $NUMBER_OF_PROCESSORS -C Release
- name: Run functional tests
if: matrix.job-type == 'standard'
working-directory: build
env:
BITCOIN_BIN: '${{ github.workspace }}\build\bin\Release\bitcoin.exe'
BITCOIND: '${{ github.workspace }}\build\bin\Release\bitcoind.exe'
BITCOINCLI: '${{ github.workspace }}\build\bin\Release\bitcoin-cli.exe'
BITCOINTX: '${{ github.workspace }}\build\bin\Release\bitcoin-tx.exe'
BITCOINUTIL: '${{ github.workspace }}\build\bin\Release\bitcoin-util.exe'
BITCOINWALLET: '${{ github.workspace }}\build\bin\Release\bitcoin-wallet.exe'
TEST_RUNNER_EXTRA: ${{ github.event_name != 'pull_request' && '--extended' || '' }}
shell: cmd
run: py -3 test\functional\test_runner.py --jobs %NUMBER_OF_PROCESSORS% --ci --quiet --tmpdirprefix=%RUNNER_TEMP% --combinedlogslen=99999999 --timeout-factor=%TEST_RUNNER_TIMEOUT_FACTOR% %TEST_RUNNER_EXTRA%
run: py -3 test/functional/test_runner.py --jobs $NUMBER_OF_PROCESSORS --ci --quiet --tmpdirprefix="${RUNNER_TEMP}" --combinedlogslen=99999999 --timeout-factor=${TEST_RUNNER_TIMEOUT_FACTOR} ${TEST_RUNNER_EXTRA}
- name: Clone corpora
if: matrix.job-type == 'fuzz'
run: |
git clone --depth=1 https://github.com/bitcoin-core/qa-assets "$env:RUNNER_TEMP\qa-assets"
Set-Location "$env:RUNNER_TEMP\qa-assets"
Write-Host "Using qa-assets repo from commit ..."
git clone --depth=1 https://github.com/bitcoin-core/qa-assets "${RUNNER_TEMP}/qa-assets"
cd "${RUNNER_TEMP}/qa-assets"
echo "Using qa-assets repo from commit ..."
git log -1
- name: Run fuzz tests
@ -259,48 +323,266 @@ jobs:
working-directory: build
env:
BITCOINFUZZ: '${{ github.workspace }}\build\bin\Release\fuzz.exe'
shell: cmd
run: |
py -3 test\fuzz\test_runner.py --par %NUMBER_OF_PROCESSORS% --loglevel DEBUG %RUNNER_TEMP%\qa-assets\fuzz_corpora
py -3 test/fuzz/test_runner.py --par $NUMBER_OF_PROCESSORS --loglevel DEBUG "${RUNNER_TEMP}/qa-assets/fuzz_corpora"
asan-lsan-ubsan-integer-no-depends-usdt:
name: 'ASan + LSan + UBSan + integer, no depends, USDT'
runs-on: ubuntu-24.04 # has to match container in ci/test/00_setup_env_native_asan.sh for tracing tools
windows-cross:
name: 'Linux->Windows cross, no tests'
needs: runners
runs-on: ${{ needs.runners.outputs.provider == 'cirrus' && 'ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-sm' || 'ubuntu-24.04' }}
if: ${{ vars.SKIP_BRANCH_PUSH != 'true' || github.event_name == 'pull_request' }}
timeout-minutes: 120
env:
FILE_ENV: "./ci/test/00_setup_env_native_asan.sh"
FILE_ENV: './ci/test/00_setup_env_win64.sh'
DANGER_CI_ON_HOST_FOLDERS: 1
steps:
- name: Checkout
uses: actions/checkout@v4
- *CHECKOUT
- name: Set CI directories
run: |
echo "CCACHE_DIR=${{ runner.temp }}/ccache_dir" >> "$GITHUB_ENV"
echo "BASE_ROOT_DIR=${{ runner.temp }}" >> "$GITHUB_ENV"
echo "BASE_BUILD_DIR=${{ runner.temp }}/build-asan" >> "$GITHUB_ENV"
- name: Configure environment
uses: ./.github/actions/configure-environment
- name: Restore Ccache cache
id: ccache-cache
uses: actions/cache/restore@v4
- name: Restore caches
id: restore-cache
uses: ./.github/actions/restore-caches
- name: Configure Docker
uses: ./.github/actions/configure-docker
with:
path: ${{ env.CCACHE_DIR }}
key: ${{ github.job }}-ccache-${{ github.run_id }}
restore-keys: ${{ github.job }}-ccache-
- name: Enable bpfcc script
# In the image build step, no external environment variables are available,
# so any settings will need to be written to the settings env file:
run: sed -i "s|\${INSTALL_BCC_TRACING_TOOLS}|true|g" ./ci/test/00_setup_env_native_asan.sh
cache-provider: ${{ needs.runners.outputs.provider }}
- name: CI script
run: ./ci/test_run_all.sh
- name: Save Ccache cache
uses: actions/cache/save@v4
if: github.event_name != 'pull_request' && steps.ccache-cache.outputs.cache-hit != 'true'
- name: Save caches
uses: ./.github/actions/save-caches
- name: Upload built executables
uses: actions/upload-artifact@v4
with:
path: ${{ env.CCACHE_DIR }}
# https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
key: ${{ github.job }}-ccache-${{ github.run_id }}
name: x86_64-w64-mingw32-executables-${{ github.run_id }}
path: |
${{ env.BASE_BUILD_DIR }}/bin/*.exe
${{ env.BASE_BUILD_DIR }}/src/secp256k1/bin/*.exe
${{ env.BASE_BUILD_DIR }}/src/univalue/*.exe
${{ env.BASE_BUILD_DIR }}/test/config.ini
windows-native-test:
name: 'Windows, test cross-built'
runs-on: windows-2022
needs: windows-cross
env:
PYTHONUTF8: 1
TEST_RUNNER_TIMEOUT_FACTOR: 40
steps:
- *CHECKOUT
- name: Download built executables
uses: actions/download-artifact@v4
with:
name: x86_64-w64-mingw32-executables-${{ github.run_id }}
- name: Run bitcoind.exe
run: ./bin/bitcoind.exe -version
- *SET_UP_VS
- name: Check executable manifests
shell: pwsh -Command "$PSVersionTable; $PSNativeCommandUseErrorActionPreference = $true; $ErrorActionPreference = 'Stop'; & '{0}'"
run: |
mt.exe -nologo -inputresource:bin\bitcoind.exe -out:bitcoind.manifest
Get-Content bitcoind.manifest
Get-ChildItem -Filter "bin\*.exe" | ForEach-Object {
$exeName = $_.Name
# Skip as they currently do not have manifests
if ($exeName -eq "fuzz.exe" -or $exeName -eq "bench_bitcoin.exe") {
Write-Host "Skipping $exeName (no manifest present)"
return
}
Write-Host "Checking $exeName"
& mt.exe -nologo -inputresource:$_.FullName -validate_manifest
}
- name: Run unit tests
# Can't use ctest here like other jobs as we don't have a CMake build tree.
run: |
./bin/test_bitcoin.exe -l test_suite # Intentionally run sequentially here, to catch test case failures caused by dirty global state from prior test cases.
./src/secp256k1/bin/exhaustive_tests.exe
./src/secp256k1/bin/noverify_tests.exe
./src/secp256k1/bin/tests.exe
./src/univalue/object.exe
./src/univalue/unitester.exe
- name: Run benchmarks
run: ./bin/bench_bitcoin.exe -sanity-check
- name: Adjust paths in test/config.ini
shell: pwsh
run: |
(Get-Content "test/config.ini") -replace '(?<=^SRCDIR=).*', '${{ github.workspace }}' -replace '(?<=^BUILDDIR=).*', '${{ github.workspace }}' -replace '(?<=^RPCAUTH=).*', '${{ github.workspace }}/share/rpcauth/rpcauth.py' | Set-Content "test/config.ini"
Get-Content "test/config.ini"
- name: Set previous release directory
run: |
echo "PREVIOUS_RELEASES_DIR=${{ runner.temp }}/previous_releases" >> "$GITHUB_ENV"
- name: Get previous releases
working-directory: test
run: ./get_previous_releases.py --target-dir $PREVIOUS_RELEASES_DIR
- name: Run functional tests
env:
# TODO: Fix the excluded test and re-enable it.
# feature_unsupported_utxo_db.py fails on windows because of emojis in the test data directory
EXCLUDE: '--exclude wallet_multiwallet.py,feature_unsupported_utxo_db.py'
TEST_RUNNER_EXTRA: ${{ github.event_name != 'pull_request' && '--extended' || '' }}
run: py -3 test/functional/test_runner.py --jobs $NUMBER_OF_PROCESSORS --ci --quiet --tmpdirprefix="$RUNNER_TEMP" --combinedlogslen=99999999 --timeout-factor=$TEST_RUNNER_TIMEOUT_FACTOR $EXCLUDE $TEST_RUNNER_EXTRA
ci-matrix:
name: ${{ matrix.name }}
needs: runners
runs-on: ${{ needs.runners.outputs.provider == 'cirrus' && matrix.cirrus-runner || matrix.fallback-runner }}
if: ${{ vars.SKIP_BRANCH_PUSH != 'true' || github.event_name == 'pull_request' }}
timeout-minutes: ${{ matrix.timeout-minutes }}
env:
DANGER_CI_ON_HOST_FOLDERS: 1
FILE_ENV: ${{ matrix.file-env }}
strategy:
fail-fast: false
matrix:
include:
- name: '32 bit ARM, unit tests, no functional tests'
cirrus-runner: 'ubuntu-24.04-arm' # Cirrus' Arm runners are Apple (with virtual Linux aarch64), which doesn't support 32-bit mode
fallback-runner: 'ubuntu-24.04-arm'
timeout-minutes: 120
file-env: './ci/test/00_setup_env_arm.sh'
provider: 'gha'
- name: 'ASan + LSan + UBSan + integer, no depends, USDT'
cirrus-runner: 'ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-md' # has to match container in ci/test/00_setup_env_native_asan.sh for tracing tools
fallback-runner: 'ubuntu-24.04'
timeout-minutes: 120
file-env: './ci/test/00_setup_env_native_asan.sh'
- name: 'macOS-cross, gui, no tests'
cirrus-runner: 'ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-sm'
fallback-runner: 'ubuntu-24.04'
timeout-minutes: 120
file-env: './ci/test/00_setup_env_mac_cross.sh'
- name: 'No wallet, libbitcoinkernel'
cirrus-runner: 'ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-sm'
fallback-runner: 'ubuntu-24.04'
timeout-minutes: 120
file-env: './ci/test/00_setup_env_native_nowallet_libbitcoinkernel.sh'
- name: 'no IPC, i686, DEBUG'
cirrus-runner: 'ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-md'
fallback-runner: 'ubuntu-24.04'
timeout-minutes: 120
file-env: './ci/test/00_setup_env_i686_no_ipc.sh'
- name: 'fuzzer,address,undefined,integer, no depends'
cirrus-runner: 'ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-lg'
fallback-runner: 'ubuntu-24.04'
timeout-minutes: 240
file-env: './ci/test/00_setup_env_native_fuzz.sh'
- name: 'previous releases, depends DEBUG'
cirrus-runner: 'ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-md'
fallback-runner: 'ubuntu-24.04'
timeout-minutes: 120
file-env: './ci/test/00_setup_env_native_previous_releases.sh'
- name: 'CentOS, depends, gui'
cirrus-runner: 'ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-lg'
fallback-runner: 'ubuntu-24.04'
timeout-minutes: 120
file-env: './ci/test/00_setup_env_native_centos.sh'
- name: 'tidy'
cirrus-runner: 'ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-md'
fallback-runner: 'ubuntu-24.04'
timeout-minutes: 120
file-env: './ci/test/00_setup_env_native_tidy.sh'
- name: 'TSan, depends, no gui'
cirrus-runner: 'ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-md'
fallback-runner: 'ubuntu-24.04'
timeout-minutes: 120
file-env: './ci/test/00_setup_env_native_tsan.sh'
- name: 'MSan, depends'
cirrus-runner: 'ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-lg'
fallback-runner: 'ubuntu-24.04'
timeout-minutes: 120
file-env: './ci/test/00_setup_env_native_msan.sh'
steps:
- *CHECKOUT
- name: Configure environment
uses: ./.github/actions/configure-environment
- name: Restore caches
id: restore-cache
uses: ./.github/actions/restore-caches
- name: Configure Docker
uses: ./.github/actions/configure-docker
with:
cache-provider: ${{ matrix.provider || needs.runners.outputs.provider }}
- name: Enable bpfcc script
if: ${{ env.CONTAINER_NAME == 'ci_native_asan' }}
# In the image build step, no external environment variables are available,
# so any settings will need to be written to the settings env file:
run: sed -i "s|\${INSTALL_BCC_TRACING_TOOLS}|true|g" ./ci/test/00_setup_env_native_asan.sh
- name: Set mmap_rnd_bits
if: ${{ env.CONTAINER_NAME == 'ci_native_tsan' || env.CONTAINER_NAME == 'ci_native_msan' }}
# Prevents crashes due to high ASLR entropy
run: sudo sysctl -w vm.mmap_rnd_bits=28
- name: CI script
run: ./ci/test_run_all.sh
- name: Save caches
uses: ./.github/actions/save-caches
lint:
name: 'lint'
needs: runners
runs-on: ${{ needs.runners.outputs.use-cirrus-runners == 'true' && 'ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-xs' || 'ubuntu-24.04' }}
if: ${{ vars.SKIP_BRANCH_PUSH != 'true' || github.event_name == 'pull_request' }}
timeout-minutes: 20
env:
CONTAINER_NAME: "bitcoin-linter"
steps:
- name: Checkout
uses: actions/checkout@v5
with:
ref: *CHECKOUT_REF_TMPL
fetch-depth: 0
- name: Configure Docker
uses: ./.github/actions/configure-docker
with:
cache-provider: ${{ needs.runners.outputs.provider }}
- name: CI script
run: |
set -o xtrace
docker buildx build -t "$CONTAINER_NAME" $DOCKER_BUILD_CACHE_ARG --file "./ci/lint_imagefile" .
CIRRUS_PR_FLAG=""
if [ "${{ github.event_name }}" = "pull_request" ]; then
CIRRUS_PR_FLAG="-e CIRRUS_PR=1"
fi
docker run --rm $CIRRUS_PR_FLAG -v "$(pwd)":/bitcoin "$CONTAINER_NAME"

9
.gitignore vendored
View File

@ -1,3 +1,8 @@
# Patterns that are specific to a text editor, IDE, operating system, or user
# environment are not added here. They should be added to your local gitignore
# file instead:
# https://docs.github.com/en/get-started/git-basics/ignoring-files#configuring-ignored-files-for-all-repositories-on-your-computer
# Build subdirectories.
/*build*
!/build-aux
@ -15,8 +20,8 @@
# Previous releases
/releases
#build tests
test/lint/test_runner/target/
# cargo default target dir
target/
/guix-build-*

View File

@ -1,7 +1,7 @@
[main]
host = https://www.transifex.com
[o:bitcoin:p:bitcoin:r:qt-translation-029x]
[o:bitcoin:p:bitcoin:r:qt-translation-030x]
file_filter = src/qt/locale/bitcoin_<lang>.xlf
source_file = src/qt/locale/bitcoin_en.xlf
source_lang = en

View File

@ -19,11 +19,15 @@ if(POLICY CMP0171)
cmake_policy(SET CMP0171 NEW)
endif()
# When adjusting CMake flag variables, we must not override those explicitly
# set by the user. These are a subset of the CACHE_VARIABLES property.
get_directory_property(precious_variables CACHE_VARIABLES)
#=============================
# Project / Package metadata
#=============================
set(CLIENT_NAME "Bitcoin Core")
set(CLIENT_VERSION_MAJOR 28)
set(CLIENT_VERSION_MAJOR 30)
set(CLIENT_VERSION_MINOR 99)
set(CLIENT_VERSION_BUILD 0)
set(CLIENT_VERSION_RC 0)
@ -90,11 +94,12 @@ endif()
#=============================
include(CMakeDependentOption)
# When adding a new option, end the <help_text> with a full stop for consistency.
option(BUILD_BITCOIN_BIN "Build bitcoin executable." ON)
option(BUILD_DAEMON "Build bitcoind executable." ON)
option(BUILD_GUI "Build bitcoin-qt executable." OFF)
option(BUILD_CLI "Build bitcoin-cli executable." ON)
option(BUILD_TESTS "Build test_bitcoin executable." ON)
option(BUILD_TESTS "Build test_bitcoin and other unit test executables." ON)
option(BUILD_TX "Build bitcoin-tx executable." ${BUILD_TESTS})
option(BUILD_UTIL "Build bitcoin-util executable." ${BUILD_TESTS})
@ -102,35 +107,16 @@ option(BUILD_UTIL_CHAINSTATE "Build experimental bitcoin-chainstate executable."
option(BUILD_KERNEL_LIB "Build experimental bitcoinkernel library." ${BUILD_UTIL_CHAINSTATE})
option(ENABLE_WALLET "Enable wallet." ON)
option(WITH_SQLITE "Enable SQLite wallet support." ${ENABLE_WALLET})
if(WITH_SQLITE)
if(ENABLE_WALLET)
if(VCPKG_TARGET_TRIPLET)
# Use of the `unofficial::` namespace is a vcpkg package manager convention.
find_package(unofficial-sqlite3 CONFIG REQUIRED)
else()
find_package(SQLite3 3.7.17 REQUIRED)
endif()
set(USE_SQLITE ON)
endif()
option(WITH_BDB "Enable Berkeley DB (BDB) wallet support." OFF)
cmake_dependent_option(WARN_INCOMPATIBLE_BDB "Warn when using a Berkeley DB (BDB) version other than 4.8." ON "WITH_BDB" OFF)
if(WITH_BDB)
find_package(BerkeleyDB 4.8 MODULE REQUIRED)
set(USE_BDB ON)
if(NOT BerkeleyDB_VERSION VERSION_EQUAL 4.8)
message(WARNING "Found Berkeley DB (BDB) other than 4.8.\n"
"BDB (legacy) wallets opened by this build will not be portable!"
)
if(WARN_INCOMPATIBLE_BDB)
message(WARNING "If this is intended, pass \"-DWARN_INCOMPATIBLE_BDB=OFF\".\n"
"Passing \"-DWITH_BDB=OFF\" will suppress this warning."
)
endif()
endif()
endif()
cmake_dependent_option(BUILD_WALLET_TOOL "Build bitcoin-wallet tool." ${BUILD_TESTS} "ENABLE_WALLET" OFF)
option(ENABLE_HARDENING "Attempt to harden the resulting executables." ON)
option(REDUCE_EXPORTS "Attempt to reduce exported symbols in the resulting executables." OFF)
option(WERROR "Treat compiler warnings as errors." OFF)
option(WITH_CCACHE "Attempt to use ccache for compiling." ON)
@ -145,7 +131,7 @@ if(WITH_USDT)
find_package(USDT MODULE REQUIRED)
endif()
cmake_dependent_option(ENABLE_EXTERNAL_SIGNER "Enable external signer support." ON "NOT WIN32" OFF)
option(ENABLE_EXTERNAL_SIGNER "Enable external signer support." ON)
cmake_dependent_option(WITH_QRENCODE "Enable QR code support." ON "BUILD_GUI" OFF)
if(WITH_QRENCODE)
@ -153,10 +139,11 @@ if(WITH_QRENCODE)
set(USE_QRCODE TRUE)
endif()
cmake_dependent_option(WITH_DBUS "Enable DBus support." ON "CMAKE_SYSTEM_NAME STREQUAL \"Linux\" AND BUILD_GUI" OFF)
cmake_dependent_option(WITH_DBUS "Enable DBus support." ON "NOT CMAKE_SYSTEM_NAME MATCHES \"(Windows|Darwin)\" AND BUILD_GUI" OFF)
option(WITH_MULTIPROCESS "Build multiprocess bitcoin-node and bitcoin-gui executables in addition to monolithic bitcoind and bitcoin-qt executables. Requires libmultiprocess library. Experimental." OFF)
if(WITH_MULTIPROCESS)
cmake_dependent_option(ENABLE_IPC "Build multiprocess bitcoin-node and bitcoin-gui executables in addition to monolithic bitcoind and bitcoin-qt executables." ON "NOT WIN32" OFF)
cmake_dependent_option(WITH_EXTERNAL_LIBMULTIPROCESS "Build with external libmultiprocess library instead of with local git subtree when ENABLE_IPC is enabled. This is not normally recommended, but can be useful for developing libmultiprocess itself." OFF "ENABLE_IPC" OFF)
if(ENABLE_IPC AND WITH_EXTERNAL_LIBMULTIPROCESS)
find_package(Libmultiprocess REQUIRED COMPONENTS Lib)
find_package(LibmultiprocessNative REQUIRED COMPONENTS Bin
NAMES Libmultiprocess
@ -176,7 +163,7 @@ if(BUILD_GUI)
if(BUILD_GUI_TESTS)
list(APPEND qt_components Test)
endif()
find_package(Qt 5.11.3 MODULE REQUIRED
find_package(Qt 6.2 MODULE REQUIRED
COMPONENTS ${qt_components}
)
unset(qt_components)
@ -216,6 +203,7 @@ target_link_libraries(core_interface INTERFACE
if(BUILD_FOR_FUZZING)
message(WARNING "BUILD_FOR_FUZZING=ON will disable all other targets and force BUILD_FUZZ_BINARY=ON.")
set(BUILD_BITCOIN_BIN OFF)
set(BUILD_DAEMON OFF)
set(BUILD_CLI OFF)
set(BUILD_TX OFF)
@ -229,6 +217,7 @@ if(BUILD_FOR_FUZZING)
set(BUILD_TESTS OFF)
set(BUILD_GUI_TESTS OFF)
set(BUILD_BENCH OFF)
set(ENABLE_IPC OFF)
set(BUILD_FUZZ_BINARY ON)
target_compile_definitions(core_interface INTERFACE
@ -290,6 +279,10 @@ if(WIN32)
/Zc:__cplusplus
/sdl
)
target_link_options(core_interface INTERFACE
# We embed our own manifests.
/MANIFEST:NO
)
# Improve parallelism in MSBuild.
# See: https://devblogs.microsoft.com/cppblog/improved-parallelism-in-msbuild/.
list(APPEND CMAKE_VS_GLOBALS "UseMultiToolTask=true")
@ -348,13 +341,28 @@ target_link_libraries(core_interface INTERFACE
Threads::Threads
)
# Define sanitize_interface with -fsanitize flags intended to apply to all
# libraries and executables.
add_library(sanitize_interface INTERFACE)
target_link_libraries(core_interface INTERFACE sanitize_interface)
if(SANITIZERS)
# Transform list of sanitizers into -fsanitize flags, replacing "fuzzer" with
# "fuzzer-no-link" in sanitize_interface flags, and moving "fuzzer" to
# fuzzer_interface flags. If -DSANITIZERS=fuzzer is specified, the fuzz test
# binary should be built with -fsanitize=fuzzer (so it can use libFuzzer's
# main function), but libraries should be built with -fsanitize=fuzzer-no-link
# (so they can be linked into other executables that have their own main
# functions).
string(REGEX REPLACE "(^|,)fuzzer($|,)" "\\1fuzzer-no-link\\2" sanitize_opts "${SANITIZERS}")
set(fuzz_flag "")
if(NOT sanitize_opts STREQUAL SANITIZERS)
set(fuzz_flag "-fsanitize=fuzzer")
endif()
# First check if the compiler accepts flags. If an incompatible pair like
# -fsanitize=address,thread is used here, this check will fail. This will also
# fail if a bad argument is passed, e.g. -fsanitize=undfeined
try_append_cxx_flags("-fsanitize=${SANITIZERS}" TARGET sanitize_interface
try_append_cxx_flags("-fsanitize=${sanitize_opts}" TARGET sanitize_interface
RESULT_VAR cxx_supports_sanitizers
SKIP_LINK
)
@ -367,15 +375,15 @@ if(SANITIZERS)
# flag. This is a separate check so we can give a better error message when
# the sanitize flags are supported by the compiler but the actual sanitizer
# libs are missing.
try_append_linker_flag("-fsanitize=${SANITIZERS}" VAR SANITIZER_LDFLAGS
try_append_linker_flag("-fsanitize=${sanitize_opts}" VAR SANITIZER_LDFLAGS
SOURCE "
#include <cstdint>
#include <cstddef>
extern \"C\" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { return 0; }
__attribute__((weak)) // allow for libFuzzer linking
int main() { return 0; }
"
RESULT_VAR linker_supports_sanitizers
NO_CACHE_IF_FAILED
)
if(NOT linker_supports_sanitizers)
message(FATAL_ERROR "Linker did not accept requested flags, you are missing required libraries.")
@ -383,8 +391,10 @@ if(SANITIZERS)
endif()
target_link_options(sanitize_interface INTERFACE ${SANITIZER_LDFLAGS})
# Define fuzzer_interface with flags intended to apply to the fuzz test binary,
# and perform a test compilation to determine correct value of
# FUZZ_BINARY_LINKS_WITHOUT_MAIN_FUNCTION.
if(BUILD_FUZZ_BINARY)
target_link_libraries(core_interface INTERFACE ${FUZZ_LIBS})
include(CheckSourceCompilesWithFlags)
check_cxx_source_compiles_with_flags("
#include <cstdint>
@ -392,9 +402,12 @@ if(BUILD_FUZZ_BINARY)
extern \"C\" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { return 0; }
// No main() function.
" FUZZ_BINARY_LINKS_WITHOUT_MAIN_FUNCTION
LDFLAGS ${SANITIZER_LDFLAGS}
LDFLAGS ${SANITIZER_LDFLAGS} ${fuzz_flag}
LINK_LIBRARIES ${FUZZ_LIBS}
)
add_library(fuzzer_interface INTERFACE)
target_link_options(fuzzer_interface INTERFACE ${fuzz_flag})
target_link_libraries(fuzzer_interface INTERFACE ${FUZZ_LIBS})
endif()
include(AddBoostIfNeeded)
@ -431,6 +444,7 @@ else()
try_append_cxx_flags("-Wvla" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("-Wshadow-field" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("-Wthread-safety" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("-Wthread-safety-pointer" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("-Wloop-analysis" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("-Wredundant-decls" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("-Wunused-member-function" TARGET warn_interface SKIP_LINK)
@ -483,63 +497,71 @@ try_append_cxx_flags("-fmacro-prefix-map=A=B" TARGET core_interface SKIP_LINK
# -fstack-reuse=none for all gcc builds. (Only gcc understands this flag).
try_append_cxx_flags("-fstack-reuse=none" TARGET core_interface)
if(ENABLE_HARDENING)
add_library(hardening_interface INTERFACE)
target_link_libraries(core_interface INTERFACE hardening_interface)
if(MSVC)
try_append_linker_flag("/DYNAMICBASE" TARGET hardening_interface)
try_append_linker_flag("/HIGHENTROPYVA" TARGET hardening_interface)
try_append_linker_flag("/NXCOMPAT" TARGET hardening_interface)
else()
if(MSVC)
try_append_linker_flag("/DYNAMICBASE" TARGET core_interface)
try_append_linker_flag("/HIGHENTROPYVA" TARGET core_interface)
try_append_linker_flag("/NXCOMPAT" TARGET core_interface)
else()
# _FORTIFY_SOURCE requires that there is some level of optimization,
# otherwise it does nothing and just creates a compiler warning.
try_append_cxx_flags("-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3"
RESULT_VAR cxx_supports_fortify_source
SOURCE "int main() {
# if !defined __OPTIMIZE__ || __OPTIMIZE__ <= 0
#error
#endif
}"
# _FORTIFY_SOURCE requires that there is some level of optimization,
# otherwise it does nothing and just creates a compiler warning.
try_append_cxx_flags("-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3"
RESULT_VAR cxx_supports_fortify_source
SOURCE "int main() {
# if !defined __OPTIMIZE__ || __OPTIMIZE__ <= 0
#error
#endif
}"
)
if(cxx_supports_fortify_source)
target_compile_options(core_interface INTERFACE
-U_FORTIFY_SOURCE
-D_FORTIFY_SOURCE=3
)
if(cxx_supports_fortify_source)
target_compile_options(hardening_interface INTERFACE
-U_FORTIFY_SOURCE
-D_FORTIFY_SOURCE=3
)
endif()
unset(cxx_supports_fortify_source)
endif()
unset(cxx_supports_fortify_source)
try_append_cxx_flags("-Wstack-protector" TARGET hardening_interface SKIP_LINK)
try_append_cxx_flags("-fstack-protector-all" TARGET hardening_interface)
try_append_cxx_flags("-fcf-protection=full" TARGET hardening_interface)
try_append_cxx_flags("-Wstack-protector" TARGET core_interface SKIP_LINK)
try_append_cxx_flags("-fstack-protector-all" TARGET core_interface)
try_append_cxx_flags("-fcf-protection=full" TARGET core_interface)
if(MINGW)
# stack-clash-protection is a no-op for Windows.
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90458 for more details.
else()
try_append_cxx_flags("-fstack-clash-protection" TARGET hardening_interface)
endif()
if(MINGW)
# stack-clash-protection is a no-op for Windows.
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90458 for more details.
else()
try_append_cxx_flags("-fstack-clash-protection" TARGET core_interface)
endif()
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
try_append_cxx_flags("-mbranch-protection=bti" TARGET hardening_interface SKIP_LINK)
else()
try_append_cxx_flags("-mbranch-protection=standard" TARGET hardening_interface SKIP_LINK)
endif()
endif()
try_append_linker_flag("-Wl,--enable-reloc-section" TARGET hardening_interface)
try_append_linker_flag("-Wl,--dynamicbase" TARGET hardening_interface)
try_append_linker_flag("-Wl,--nxcompat" TARGET hardening_interface)
try_append_linker_flag("-Wl,--high-entropy-va" TARGET hardening_interface)
try_append_linker_flag("-Wl,-z,relro" TARGET hardening_interface)
try_append_linker_flag("-Wl,-z,now" TARGET hardening_interface)
try_append_linker_flag("-Wl,-z,separate-code" TARGET hardening_interface)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
try_append_linker_flag("-Wl,-fixup_chains" TARGET hardening_interface)
try_append_cxx_flags("-mbranch-protection=bti" TARGET core_interface SKIP_LINK)
else()
try_append_cxx_flags("-mbranch-protection=standard" TARGET core_interface SKIP_LINK)
endif()
endif()
try_append_linker_flag("-Wl,--enable-reloc-section" TARGET core_interface)
try_append_linker_flag("-Wl,--dynamicbase" TARGET core_interface)
try_append_linker_flag("-Wl,--nxcompat" TARGET core_interface)
try_append_linker_flag("-Wl,--high-entropy-va" TARGET core_interface)
try_append_linker_flag("-Wl,-z,relro" TARGET core_interface)
try_append_linker_flag("-Wl,-z,now" TARGET core_interface)
# TODO: This can be dropped once Bitcoin Core no longer supports
# NetBSD 10.0 or if upstream fix is backported.
# NetBSD's dynamic linker ld.elf_so < 11.0 supports exactly 2
# `PT_LOAD` segments and binaries linked with `-z separate-code`
# have 4 `PT_LOAD` segments.
# Relevant discussions:
# - https://github.com/bitcoin/bitcoin/pull/28724#issuecomment-2589347934
# - https://mail-index.netbsd.org/tech-userlevel/2023/01/05/msg013666.html
if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD" AND CMAKE_SYSTEM_VERSION VERSION_LESS 11.0)
try_append_linker_flag("-Wl,-z,noseparate-code" TARGET core_interface)
else()
try_append_linker_flag("-Wl,-z,separate-code" TARGET core_interface)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
try_append_linker_flag("-Wl,-fixup_chains" TARGET core_interface)
endif()
endif()
if(REDUCE_EXPORTS)
@ -569,11 +591,9 @@ set(Python3_FIND_FRAMEWORK LAST CACHE STRING "")
set(Python3_FIND_UNVERSIONED_NAMES FIRST CACHE STRING "")
mark_as_advanced(Python3_FIND_FRAMEWORK Python3_FIND_UNVERSIONED_NAMES)
find_package(Python3 3.10 COMPONENTS Interpreter)
if(Python3_EXECUTABLE)
set(PYTHON_COMMAND ${Python3_EXECUTABLE})
else()
if(NOT TARGET Python3::Interpreter)
list(APPEND configure_warnings
"Minimum required Python not found. Utils and rpcauth tests are disabled."
"Minimum required Python not found."
)
endif()
@ -617,8 +637,6 @@ add_subdirectory(doc)
add_subdirectory(src)
include(cmake/tests.cmake)
include(Maintenance)
setup_split_debug_script()
add_maintenance_targets()
@ -629,15 +647,16 @@ message("\n")
message("Configure summary")
message("=================")
message("Executables:")
message(" bitcoin ............................. ${BUILD_BITCOIN_BIN}")
message(" bitcoind ............................ ${BUILD_DAEMON}")
if(BUILD_DAEMON AND WITH_MULTIPROCESS)
if(BUILD_DAEMON AND ENABLE_IPC)
set(bitcoin_daemon_status ON)
else()
set(bitcoin_daemon_status OFF)
endif()
message(" bitcoin-node (multiprocess) ......... ${bitcoin_daemon_status}")
message(" bitcoin-qt (GUI) .................... ${BUILD_GUI}")
if(BUILD_GUI AND WITH_MULTIPROCESS)
if(BUILD_GUI AND ENABLE_IPC)
set(bitcoin_gui_status ON)
else()
set(bitcoin_gui_status OFF)
@ -651,15 +670,21 @@ message(" bitcoin-chainstate (experimental) ... ${BUILD_UTIL_CHAINSTATE}")
message(" libbitcoinkernel (experimental) ..... ${BUILD_KERNEL_LIB}")
message("Optional features:")
message(" wallet support ...................... ${ENABLE_WALLET}")
if(ENABLE_WALLET)
message(" - descriptor wallets (SQLite) ...... ${WITH_SQLITE}")
message(" - legacy wallets (Berkeley DB) ..... ${WITH_BDB}")
endif()
message(" external signer ..................... ${ENABLE_EXTERNAL_SIGNER}")
message(" ZeroMQ .............................. ${WITH_ZMQ}")
if(ENABLE_IPC)
if (WITH_EXTERNAL_LIBMULTIPROCESS)
set(ipc_status "ON (with external libmultiprocess)")
else()
set(ipc_status ON)
endif()
else()
set(ipc_status OFF)
endif()
message(" IPC ................................. ${ipc_status}")
message(" USDT tracing ........................ ${WITH_USDT}")
message(" QR code (GUI) ....................... ${WITH_QRENCODE}")
message(" DBus (GUI, Linux only) .............. ${WITH_DBUS}")
message(" DBus (GUI) .......................... ${WITH_DBUS}")
message("Tests:")
message(" test_bitcoin ........................ ${BUILD_TESTS}")
message(" test_bitcoin-qt ..................... ${BUILD_GUI_TESTS}")
@ -675,7 +700,6 @@ message("Cross compiling ....................... ${cross_status}")
message("C++ compiler .......................... ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}, ${CMAKE_CXX_COMPILER}")
include(FlagsSummary)
flags_summary()
message("Attempt to harden executables ......... ${ENABLE_HARDENING}")
message("Treat compiler warnings as errors ..... ${WERROR}")
message("Use ccache for compiling .............. ${WITH_CCACHE}")
message("\n")

View File

@ -1,6 +1,5 @@
{
"version": 3,
"cmakeMinimumRequired": {"major": 3, "minor": 21, "patch": 0},
"configurePresets": [
{
"name": "vs2022",
@ -62,6 +61,7 @@
"name": "dev-mode",
"displayName": "Developer mode, with all features/dependencies enabled",
"binaryDir": "${sourceDir}/build_dev_mode",
"errors": {"dev": true},
"cacheVariables": {
"BUILD_BENCH": "ON",
"BUILD_CLI": "ON",
@ -77,13 +77,9 @@
"BUILD_UTIL_CHAINSTATE": "ON",
"BUILD_WALLET_TOOL": "ON",
"ENABLE_EXTERNAL_SIGNER": "ON",
"ENABLE_HARDENING": "ON",
"ENABLE_WALLET": "ON",
"WARN_INCOMPATIBLE_BDB": "OFF",
"WITH_BDB": "ON",
"WITH_MULTIPROCESS": "ON",
"ENABLE_IPC": "ON",
"WITH_QRENCODE": "ON",
"WITH_SQLITE": "ON",
"WITH_USDT": "ON",
"WITH_ZMQ": "ON"
}

View File

@ -80,7 +80,7 @@ facilitates social contribution, easy testing and peer review.
To contribute a patch, the workflow is as follows:
1. Fork repository ([only for the first time](https://docs.github.com/en/get-started/quickstart/fork-a-repo))
1. Fork repository ([only for the first time](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo))
1. Create topic branch
1. Commit patches
@ -115,13 +115,14 @@ fixes or code moves with actual code changes.
Make sure each individual commit is hygienic: that it builds successfully on its
own without warnings, errors, regressions, or test failures.
This means tests must be updated in the same commit that changes the behavior.
Commit messages should be verbose by default consisting of a short subject line
(50 chars max), a blank line and detailed explanatory text as separate
paragraph(s), unless the title alone is self-explanatory (like "Correct typo
in init.cpp") in which case a single title line is sufficient. Commit messages should be
helpful to people reading your code in the future, so explain the reasoning for
your decisions. Further explanation [here](https://chris.beams.io/posts/git-commit/).
your decisions. Further explanation [here](https://cbea.ms/git-commit/).
If a particular commit references another issue, please add the reference. For
example: `refs #1234` or `fixes #4321`. Using the `fixes` or `closes` keywords
@ -182,7 +183,7 @@ for more information on helping with translations.
### Work in Progress Changes and Requests for Comments
If a pull request is not to be considered for merging (yet), please
prefix the title with [WIP] or use [Tasks Lists](https://docs.github.com/en/github/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#task-lists)
prefix the title with [WIP] or use [Tasks Lists](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#task-lists)
in the body of the pull request to indicate tasks are pending.
### Address Feedback
@ -401,7 +402,7 @@ about:
- It may be because your code is too complex for all but a few people, and those people
may not have realized your pull request even exists. A great way to find people who
are qualified and care about the code you are touching is the
[Git Blame feature](https://docs.github.com/en/github/managing-files-in-a-repository/managing-files-on-github/tracking-changes-in-a-file). Simply
[Git Blame feature](https://docs.github.com/en/repositories/working-with-files/using-files/viewing-and-understanding-files). Simply
look up who last modified the code you are changing and see if you can find
them and give them a nudge. Don't be incessant about the nudging, though.
- Finally, if all else fails, ask on IRC or elsewhere for someone to give your pull request

View File

@ -1 +1 @@
See [doc/build-\*.md](/doc)
See [doc/build-\*.md](/doc)

View File

@ -19,7 +19,7 @@ License
-------
Bitcoin Core is released under the terms of the MIT license. See [COPYING](COPYING) for more
information or see https://opensource.org/licenses/MIT.
information or see https://opensource.org/license/MIT.
Development Process
-------------------
@ -56,8 +56,8 @@ in Python.
These tests can be run (if the [test dependencies](/test) are installed) with: `build/test/functional/test_runner.py`
(assuming `build` is your build directory).
The CI (Continuous Integration) systems make sure that every pull request is built for Windows, Linux, and macOS,
and that unit/sanity tests are run automatically.
The CI (Continuous Integration) systems make sure that every pull request is tested on Windows, Linux, and macOS.
The CI must pass on all commits before merge to avoid unrelated CI failures on new pull requests.
### Manual Quality Assurance (QA) Testing
@ -70,7 +70,7 @@ Translations
------------
Changes to translations as well as new translations can be submitted to
[Bitcoin Core's Transifex page](https://www.transifex.com/bitcoin/bitcoin/).
[Bitcoin Core's Transifex page](https://explore.transifex.com/bitcoin/bitcoin/).
Translations are periodically pulled from Transifex and merged into the git repository. See the
[translation process](doc/translation_process.md) for details on how this works.

View File

@ -1,8 +1,8 @@
## CI Scripts
# CI Scripts
This directory contains scripts for each build step in each build stage.
### Running a Stage Locally
## Running a Stage Locally
Be aware that the tests will be built and run in-place, so please run at your own risk.
If the repository is not a fresh git clone, you might have to clean files from previous builds or test runs first.
@ -27,7 +27,7 @@ with a specific configuration,
env -i HOME="$HOME" PATH="$PATH" USER="$USER" bash -c 'FILE_ENV="./ci/test/00_setup_env_arm.sh" ./ci/test_run_all.sh'
```
### Configurations
## Configurations
The test files (`FILE_ENV`) are constructed to test a wide range of
configurations, rather than a single pass/fail. This helps to catch build
@ -49,8 +49,32 @@ env -i HOME="$HOME" PATH="$PATH" USER="$USER" bash -c 'MAKEJOBS="-j1" FILE_ENV="
The files starting with `0n` (`n` greater than 0) are the scripts that are run
in order.
### Cache
## Cache
In order to avoid rebuilding all dependencies for each build, the binaries are
cached and reused when possible. Changes in the dependency-generator will
trigger cache-invalidation and rebuilds as necessary.
## Configuring a repository for CI
### Primary repository
To configure the primary repository, follow these steps:
1. Register with [Cirrus Runners](https://cirrus-runners.app/) and purchase runners.
2. Install the Cirrus Runners GitHub app against the GitHub organization.
3. Enable organisation-level runners to be used in public repositories:
1. `Org settings -> Actions -> Runner Groups -> Default -> Allow public repos`
4. Permit the following actions to run:
1. cirruslabs/cache/restore@\*
1. cirruslabs/cache/save@\*
1. docker/setup-buildx-action@\*
1. actions/github-script@\*
### Forked repositories
When used in a fork the CI will run on GitHub's free hosted runners by default.
In this case, due to GitHub's 10GB-per-repo cache size limitations caches will be frequently evicted and missed, but the workflows will run (slowly).
It is also possible to use your own Cirrus Runners in your own fork with an appropriate patch to the `REPO_USE_CIRRUS_RUNNERS` variable in ../.github/workflows/ci.yml
NB that Cirrus Runners only work at an organisation level, therefore in order to use your own Cirrus Runners, *the fork must be within your own organisation*.

View File

@ -6,16 +6,19 @@
export LC_ALL=C
set -o errexit -o pipefail -o xtrace
export CI_RETRY_EXE="/ci_retry --"
pushd "/"
${CI_RETRY_EXE} apt-get update
# Lint dependencies:
# - cargo (used to run the lint tests)
# - curl/xz-utils (to install shellcheck)
# - git (used in many lint scripts)
# - gpg (used by verify-commits)
${CI_RETRY_EXE} apt-get install -y curl xz-utils git gpg
${CI_RETRY_EXE} apt-get install -y cargo curl xz-utils git gpg
PYTHON_PATH="/python_build"
if [ ! -d "${PYTHON_PATH}/bin" ]; then
@ -35,31 +38,20 @@ export PATH="${PYTHON_PATH}/bin:${PATH}"
command -v python3
python3 --version
export LINT_RUNNER_PATH="/lint_test_runner"
if [ ! -d "${LINT_RUNNER_PATH}" ]; then
${CI_RETRY_EXE} apt-get install -y cargo
(
cd "/test/lint/test_runner" || exit 1
cargo build
mkdir -p "${LINT_RUNNER_PATH}"
mv target/debug/test_runner "${LINT_RUNNER_PATH}"
)
fi
${CI_RETRY_EXE} pip3 install \
codespell==2.2.6 \
lief==0.13.2 \
mypy==1.4.1 \
pyzmq==25.1.0 \
ruff==0.5.5 \
vulture==2.6
codespell==2.4.1 \
lief==0.16.6 \
mypy==1.18.2 \
pyzmq==27.1.0 \
ruff==0.13.2 \
vulture==2.14
SHELLCHECK_VERSION=v0.8.0
SHELLCHECK_VERSION=v0.11.0
curl -sL "https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz" | \
tar --xz -xf - --directory /tmp/
mv "/tmp/shellcheck-${SHELLCHECK_VERSION}/shellcheck" /usr/bin/
MLC_VERSION=v0.19.0
MLC_VERSION=v1
MLC_BIN=mlc-x86_64-linux
curl -sL "https://github.com/becheran/mlc/releases/download/${MLC_VERSION}/${MLC_BIN}" -o "/usr/bin/mlc"
chmod +x /usr/bin/mlc

View File

@ -16,7 +16,7 @@ if [ -n "$CIRRUS_PR" ]; then
fi
fi
RUST_BACKTRACE=1 "${LINT_RUNNER_PATH}/test_runner"
RUST_BACKTRACE=1 cargo run --manifest-path "./test/lint/test_runner/Cargo.toml"
if [ "$CIRRUS_REPO_FULL_NAME" = "bitcoin/bitcoin" ] && [ "$CIRRUS_PR" = "" ] ; then
# Sanity check only the last few commits to get notified of missing sigs,

View File

@ -11,7 +11,6 @@ export LC_ALL=C
git config --global --add safe.directory /bitcoin
export PATH="/python_build/bin:${PATH}"
export LINT_RUNNER_PATH="/lint_test_runner"
if [ -z "$1" ]; then
bash -ic "./ci/lint/06_script.sh"

View File

@ -4,7 +4,7 @@
# See test/lint/README.md for usage.
FROM mirror.gcr.io/debian:bookworm
FROM mirror.gcr.io/ubuntu:24.04
ENV DEBIAN_FRONTEND=noninteractive
ENV LC_ALL=C.UTF-8
@ -12,8 +12,7 @@ ENV LC_ALL=C.UTF-8
COPY ./ci/retry/retry /ci_retry
COPY ./.python-version /.python-version
COPY ./ci/lint/container-entrypoint.sh /entrypoint.sh
COPY ./ci/lint/04_install.sh /install.sh
COPY ./test/lint/test_runner /test/lint/test_runner
COPY ./ci/lint/01_install.sh /install.sh
RUN /install.sh && \
echo 'alias lint="./ci/lint/06_script.sh"' >> ~/.bashrc && \

View File

@ -1,17 +0,0 @@
#!/usr/bin/env bash
#
# Copyright (c) 2019-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
export LC_ALL=C.UTF-8
# Only used in .cirrus.yml. Refer to test/lint/README.md on how to run locally.
cp "./ci/retry/retry" "/ci_retry"
cp "./.python-version" "/.python-version"
mkdir --parents "/test/lint"
cp --recursive "./test/lint/test_runner" "/test/lint/"
set -o errexit; source ./ci/lint/04_install.sh
set -o errexit
./ci/lint/06_script.sh

View File

@ -35,7 +35,7 @@ fi
echo "Fallback to default values in env (if not yet set)"
# The number of parallel jobs to pass down to make and test_runner.py
export MAKEJOBS=${MAKEJOBS:--j4}
export MAKEJOBS=${MAKEJOBS:--j$(if command -v nproc > /dev/null 2>&1; then nproc; else sysctl -n hw.logicalcpu; fi)}
# Whether to prefer BusyBox over GNU utilities
export USE_BUSY_BOX=${USE_BUSY_BOX:-false}
@ -64,7 +64,7 @@ export BASE_OUTDIR=${BASE_OUTDIR:-$BASE_SCRATCH_DIR/out}
# The folder for previous release binaries.
# This folder exists only on the ci guest, and on the ci host as a volume.
export PREVIOUS_RELEASES_DIR=${PREVIOUS_RELEASES_DIR:-$BASE_ROOT_DIR/prev_releases}
export CI_BASE_PACKAGES=${CI_BASE_PACKAGES:-build-essential pkgconf curl ca-certificates ccache python3 rsync git procps bison e2fsprogs cmake}
export CI_BASE_PACKAGES=${CI_BASE_PACKAGES:-build-essential pkgconf curl ca-certificates ccache python3 rsync git procps bison e2fsprogs cmake ninja-build}
export GOAL=${GOAL:-install}
export DIR_QA_ASSETS=${DIR_QA_ASSETS:-${BASE_SCRATCH_DIR}/qa-assets}
export CI_RETRY_EXE=${CI_RETRY_EXE:-"retry --"}

View File

@ -10,12 +10,13 @@ export HOST=arm-linux-gnueabihf
export DPKG_ADD_ARCH="armhf"
export PACKAGES="python3-zmq g++-arm-linux-gnueabihf busybox libc6:armhf libstdc++6:armhf libfontconfig1:armhf libxcb1:armhf"
export CONTAINER_NAME=ci_arm_linux
export CI_IMAGE_NAME_TAG="mirror.gcr.io/ubuntu:noble" # Check that https://packages.ubuntu.com/noble/g++-arm-linux-gnueabihf (version 13.3, similar to guix) can cross-compile
export CI_IMAGE_NAME_TAG="mirror.gcr.io/ubuntu:24.04" # Check that https://packages.ubuntu.com/noble/g++-arm-linux-gnueabihf (version 13.x, similar to guix) can cross-compile
export CI_IMAGE_PLATFORM="linux/arm64"
export USE_BUSY_BOX=true
export RUN_UNIT_TESTS=true
export RUN_FUNCTIONAL_TESTS=false
export GOAL="install"
export CI_LIMIT_STACK_SIZE=1
# -Wno-psabi is to disable ABI warnings: "note: parameter passing for argument of type ... changed in GCC 7.1"
# This could be removed once the ABI change warning does not show up by default
export BITCOIN_CONFIG="-DREDUCE_EXPORTS=ON -DCMAKE_CXX_FLAGS='-Wno-psabi -Wno-error=maybe-uninitialized'"

View File

@ -7,17 +7,17 @@
export LC_ALL=C.UTF-8
export HOST=i686-pc-linux-gnu
export CONTAINER_NAME=ci_i686_multiprocess
export CONTAINER_NAME=ci_i686_no_multiprocess
export CI_IMAGE_NAME_TAG="mirror.gcr.io/ubuntu:24.04"
export CI_IMAGE_PLATFORM="linux/amd64"
export PACKAGES="llvm clang g++-multilib"
export DEP_OPTS="DEBUG=1 MULTIPROCESS=1"
export DEP_OPTS="DEBUG=1 NO_IPC=1"
export GOAL="install"
export TEST_RUNNER_EXTRA="--v2transport"
export CI_LIMIT_STACK_SIZE=1
export TEST_RUNNER_EXTRA="--v2transport --usecli"
export BITCOIN_CONFIG="\
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_COMPILER='clang;-m32' \
-DCMAKE_CXX_COMPILER='clang++;-m32' \
-DAPPEND_CPPFLAGS='-DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE' \
"
export BITCOIND=bitcoin-node # Used in functional tests

View File

@ -8,10 +8,12 @@ export LC_ALL=C.UTF-8
# Homebrew's python@3.12 is marked as externally managed (PEP 668).
# Therefore, `--break-system-packages` is needed.
export CONTAINER_NAME="ci_mac_native" # macos does not use a container, but the env var is needed for logging
export PIP_PACKAGES="--break-system-packages zmq"
export GOAL="install"
export GOAL="install deploy"
export CMAKE_GENERATOR="Ninja"
export BITCOIN_CONFIG="-DBUILD_GUI=ON -DWITH_ZMQ=ON -DREDUCE_EXPORTS=ON"
export BITCOIN_CONFIG="-DBUILD_GUI=ON -DWITH_ZMQ=ON -DREDUCE_EXPORTS=ON -DCMAKE_EXE_LINKER_FLAGS='-Wl,-stack_size -Wl,0x80000'"
export CI_OS_NAME="macos"
export NO_DEPENDS=1
export OSX_SDK=""
export BITCOIN_CMD="bitcoin -m" # Used in functional tests

View File

@ -6,8 +6,9 @@
export LC_ALL=C.UTF-8
export CONTAINER_NAME="ci_mac_native_fuzz" # macos does not use a container, but the env var is needed for logging
export CMAKE_GENERATOR="Ninja"
export BITCOIN_CONFIG="-DBUILD_FOR_FUZZING=ON"
export BITCOIN_CONFIG="-DBUILD_FOR_FUZZING=ON -DCMAKE_EXE_LINKER_FLAGS='-Wl,-stack_size -Wl,0x80000'"
export CI_OS_NAME="macos"
export NO_DEPENDS=1
export OSX_SDK=""

View File

@ -19,17 +19,19 @@ else
fi
export CONTAINER_NAME=ci_native_asan
export APT_LLVM_V="20"
export PACKAGES="systemtap-sdt-dev clang-${APT_LLVM_V} llvm-${APT_LLVM_V} libclang-rt-${APT_LLVM_V}-dev python3-zmq qtbase5-dev qttools5-dev qttools5-dev-tools libevent-dev libboost-dev libdb5.3++-dev libzmq3-dev libqrencode-dev libsqlite3-dev ${BPFCC_PACKAGE}"
export APT_LLVM_V="21"
export PACKAGES="systemtap-sdt-dev clang-${APT_LLVM_V} llvm-${APT_LLVM_V} libclang-rt-${APT_LLVM_V}-dev python3-zmq qt6-base-dev qt6-tools-dev qt6-l10n-tools libevent-dev libboost-dev libzmq3-dev libqrencode-dev libsqlite3-dev ${BPFCC_PACKAGE} libcapnp-dev capnproto python3-pip"
export PIP_PACKAGES="--break-system-packages pycapnp"
export NO_DEPENDS=1
export GOAL="install"
export CI_LIMIT_STACK_SIZE=1
export BITCOIN_CONFIG="\
-DWITH_USDT=ON -DWITH_ZMQ=ON -DWITH_BDB=ON -DWARN_INCOMPATIBLE_BDB=OFF -DBUILD_GUI=ON \
-DWITH_USDT=ON -DWITH_ZMQ=ON -DBUILD_GUI=ON \
-DSANITIZERS=address,float-divide-by-zero,integer,undefined \
-DCMAKE_C_COMPILER=clang-${APT_LLVM_V} \
-DCMAKE_CXX_COMPILER=clang++-${APT_LLVM_V} \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_FLAGS='-ftrivial-auto-var-init=pattern' \
-DCMAKE_CXX_FLAGS='-ftrivial-auto-var-init=pattern -Wno-error=deprecated-declarations' \
-DCMAKE_CXX_FLAGS='-ftrivial-auto-var-init=pattern' \
-DAPPEND_CXXFLAGS='-std=c++23' \
-DAPPEND_CPPFLAGS='-DARENA_DEBUG -DDEBUG_LOCKORDER' \
"

View File

@ -8,8 +8,14 @@ export LC_ALL=C.UTF-8
export CONTAINER_NAME=ci_native_centos
export CI_IMAGE_NAME_TAG="quay.io/centos/centos:stream10"
export CI_BASE_PACKAGES="gcc-c++ glibc-devel libstdc++-devel ccache make git python3 python3-pip which patch xz procps-ng ksh rsync coreutils bison e2fsprogs cmake"
export PIP_PACKAGES="pyzmq"
export DEP_OPTS="DEBUG=1" # Temporarily enable a DEBUG=1 build to check for GCC-bug-117966 regressions. This can be removed once the minimum GCC version is bumped to 12 in the previous releases task, see https://github.com/bitcoin/bitcoin/issues/31436#issuecomment-2530717875
export CI_BASE_PACKAGES="gcc-c++ glibc-devel libstdc++-devel ccache make ninja-build git python3 python3-pip which patch xz procps-ng rsync coreutils bison e2fsprogs cmake dash"
export PIP_PACKAGES="pyzmq pycapnp"
export DEP_OPTS="DEBUG=1"
export GOAL="install"
export BITCOIN_CONFIG="-DWITH_ZMQ=ON -DBUILD_GUI=ON -DREDUCE_EXPORTS=ON -DCMAKE_BUILD_TYPE=Debug"
export BITCOIN_CONFIG="\
-DWITH_ZMQ=ON \
-DBUILD_GUI=ON \
-DREDUCE_EXPORTS=ON \
-DCMAKE_BUILD_TYPE=Debug \
"
export BITCOIN_CMD="bitcoin -m" # Used in functional tests

View File

@ -8,8 +8,8 @@ export LC_ALL=C.UTF-8
export CI_IMAGE_NAME_TAG="mirror.gcr.io/ubuntu:24.04"
export CONTAINER_NAME=ci_native_fuzz
export APT_LLVM_V="20"
export PACKAGES="clang-${APT_LLVM_V} llvm-${APT_LLVM_V} libclang-rt-${APT_LLVM_V}-dev libevent-dev libboost-dev libsqlite3-dev"
export APT_LLVM_V="21"
export PACKAGES="clang-${APT_LLVM_V} llvm-${APT_LLVM_V} libclang-rt-${APT_LLVM_V}-dev libevent-dev libboost-dev libsqlite3-dev libcapnp-dev capnproto"
export NO_DEPENDS=1
export RUN_UNIT_TESTS=false
export RUN_FUNCTIONAL_TESTS=false
@ -19,9 +19,8 @@ export CI_CONTAINER_CAP="--cap-add SYS_PTRACE" # If run with (ASan + LSan), the
export BITCOIN_CONFIG="\
-DBUILD_FOR_FUZZING=ON \
-DSANITIZERS=fuzzer,address,undefined,float-divide-by-zero,integer \
-DCMAKE_C_COMPILER=clang-${APT_LLVM_V} \
-DCMAKE_CXX_COMPILER=clang++-${APT_LLVM_V} \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_FLAGS='-ftrivial-auto-var-init=pattern' \
-DCMAKE_CXX_FLAGS='-ftrivial-auto-var-init=pattern' \
"
export LLVM_SYMBOLIZER_PATH="/usr/bin/llvm-symbolizer-${APT_LLVM_V}"

View File

@ -7,15 +7,16 @@
export LC_ALL=C.UTF-8
export CI_IMAGE_NAME_TAG="mirror.gcr.io/ubuntu:24.04"
LIBCXX_DIR="/msan/cxx_build/"
export APT_LLVM_V="21"
LIBCXX_DIR="/cxx_build/"
export MSAN_FLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer -g -O1 -fno-optimize-sibling-calls"
LIBCXX_FLAGS="-nostdinc++ -nostdlib++ -isystem ${LIBCXX_DIR}include/c++/v1 -L${LIBCXX_DIR}lib -Wl,-rpath,${LIBCXX_DIR}lib -lc++ -lc++abi -lpthread -Wno-unused-command-line-argument"
# -lstdc++ to resolve link issues due to upstream packaging
LIBCXX_FLAGS="-nostdinc++ -nostdlib++ -isystem ${LIBCXX_DIR}include/c++/v1 -L${LIBCXX_DIR}lib -Wl,-rpath,${LIBCXX_DIR}lib -lc++ -lc++abi -lpthread -Wno-unused-command-line-argument -lstdc++"
export MSAN_AND_LIBCXX_FLAGS="${MSAN_FLAGS} ${LIBCXX_FLAGS}"
export CONTAINER_NAME="ci_native_fuzz_msan"
export PACKAGES="ninja-build"
# BDB generates false-positives and will be removed in future
export DEP_OPTS="DEBUG=1 NO_BDB=1 NO_QT=1 CC=clang CXX=clang++ CFLAGS='${MSAN_FLAGS}' CXXFLAGS='${MSAN_AND_LIBCXX_FLAGS}'"
export PACKAGES="clang-${APT_LLVM_V} llvm-${APT_LLVM_V} llvm-${APT_LLVM_V}-dev libclang-${APT_LLVM_V}-dev libclang-rt-${APT_LLVM_V}-dev"
export DEP_OPTS="DEBUG=1 NO_QT=1 CC=clang CXX=clang++ CFLAGS='${MSAN_FLAGS}' CXXFLAGS='${MSAN_AND_LIBCXX_FLAGS}'"
export GOAL="all"
# Setting CMAKE_{C,CXX}_FLAGS_DEBUG flags to an empty string ensures that the flags set in MSAN_FLAGS remain unaltered.
# _FORTIFY_SOURCE is not compatible with MSAN.
@ -27,7 +28,7 @@ export BITCOIN_CONFIG="\
-DSANITIZERS=fuzzer,memory \
-DAPPEND_CPPFLAGS='-DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE -U_FORTIFY_SOURCE' \
"
export USE_MEMORY_SANITIZER="true"
export USE_INSTRUMENTED_LIBCPP="MemoryWithOrigins"
export RUN_UNIT_TESTS="false"
export RUN_FUNCTIONAL_TESTS="false"
export RUN_FUZZ_TESTS=true

View File

@ -8,7 +8,7 @@ export LC_ALL=C.UTF-8
export CI_IMAGE_NAME_TAG="mirror.gcr.io/ubuntu:24.04"
export CONTAINER_NAME=ci_native_fuzz_valgrind
export PACKAGES="clang-16 llvm-16 libclang-rt-16-dev libevent-dev libboost-dev libsqlite3-dev valgrind"
export PACKAGES="libevent-dev libboost-dev libsqlite3-dev valgrind libcapnp-dev capnproto"
export NO_DEPENDS=1
export RUN_UNIT_TESTS=false
export RUN_FUNCTIONAL_TESTS=false
@ -17,8 +17,5 @@ export FUZZ_TESTS_CONFIG="--valgrind"
export GOAL="all"
export BITCOIN_CONFIG="\
-DBUILD_FOR_FUZZING=ON \
-DSANITIZERS=fuzzer \
-DCMAKE_C_COMPILER=clang-16 \
-DCMAKE_CXX_COMPILER=clang++-16 \
-DCMAKE_CXX_FLAGS='-Wno-error=array-bounds' \
"
export LLVM_SYMBOLIZER_PATH="/usr/bin/llvm-symbolizer-16"

View File

@ -7,16 +7,18 @@
export LC_ALL=C.UTF-8
export CI_IMAGE_NAME_TAG="mirror.gcr.io/ubuntu:24.04"
LIBCXX_DIR="/msan/cxx_build/"
export APT_LLVM_V="21"
LIBCXX_DIR="/cxx_build/"
export MSAN_FLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer -g -O1 -fno-optimize-sibling-calls"
LIBCXX_FLAGS="-nostdinc++ -nostdlib++ -isystem ${LIBCXX_DIR}include/c++/v1 -L${LIBCXX_DIR}lib -Wl,-rpath,${LIBCXX_DIR}lib -lc++ -lc++abi -lpthread -Wno-unused-command-line-argument"
export MSAN_AND_LIBCXX_FLAGS="${MSAN_FLAGS} ${LIBCXX_FLAGS}"
export CONTAINER_NAME="ci_native_msan"
export PACKAGES="ninja-build"
# BDB generates false-positives and will be removed in future
export DEP_OPTS="DEBUG=1 NO_BDB=1 NO_QT=1 CC=clang CXX=clang++ CFLAGS='${MSAN_FLAGS}' CXXFLAGS='${MSAN_AND_LIBCXX_FLAGS}'"
export PACKAGES="clang-${APT_LLVM_V} llvm-${APT_LLVM_V} llvm-${APT_LLVM_V}-dev libclang-${APT_LLVM_V}-dev libclang-rt-${APT_LLVM_V}-dev python3-pip"
export PIP_PACKAGES="--break-system-packages pycapnp"
export DEP_OPTS="DEBUG=1 NO_QT=1 CC=clang CXX=clang++ CFLAGS='${MSAN_FLAGS}' CXXFLAGS='${MSAN_AND_LIBCXX_FLAGS}'"
export GOAL="install"
export CI_LIMIT_STACK_SIZE=1
# Setting CMAKE_{C,CXX}_FLAGS_DEBUG flags to an empty string ensures that the flags set in MSAN_FLAGS remain unaltered.
# _FORTIFY_SOURCE is not compatible with MSAN.
export BITCOIN_CONFIG="\
@ -26,4 +28,4 @@ export BITCOIN_CONFIG="\
-DSANITIZERS=memory \
-DAPPEND_CPPFLAGS='-U_FORTIFY_SOURCE' \
"
export USE_MEMORY_SANITIZER="true"
export USE_INSTRUMENTED_LIBCPP="MemoryWithOrigins"

View File

@ -9,7 +9,8 @@ export LC_ALL=C.UTF-8
export CONTAINER_NAME=ci_native_nowallet_libbitcoinkernel
export CI_IMAGE_NAME_TAG="mirror.gcr.io/debian:bookworm"
# Use minimum supported python3.10 (or best-effort 3.11) and clang-16, see doc/dependencies.md
export PACKAGES="python3-zmq clang-16 llvm-16 libc++abi-16-dev libc++-16-dev"
export PACKAGES="python3-zmq python3-pip clang-16 llvm-16 libc++abi-16-dev libc++-16-dev"
export PIP_PACKAGES="--break-system-packages pycapnp"
export DEP_OPTS="NO_WALLET=1 CC=clang-16 CXX='clang++-16 -stdlib=libc++'"
export GOAL="install"
export BITCOIN_CONFIG="-DREDUCE_EXPORTS=ON -DBUILD_UTIL_CHAINSTATE=ON -DBUILD_KERNEL_LIB=ON -DBUILD_SHARED_LIBS=ON"

View File

@ -10,18 +10,17 @@ export CONTAINER_NAME=ci_native_previous_releases
export CI_IMAGE_NAME_TAG="mirror.gcr.io/ubuntu:22.04"
# Use minimum supported python3.10 and gcc-11, see doc/dependencies.md
export PACKAGES="gcc-11 g++-11 python3-zmq"
export DEP_OPTS="DEBUG=1 CC=gcc-11 CXX=g++-11"
export DEP_OPTS="CC=gcc-11 CXX=g++-11"
export TEST_RUNNER_EXTRA="--previous-releases --coverage --extended --exclude feature_dbcrash" # Run extended tests so that coverage does not fail, but exclude the very slow dbcrash
export RUN_UNIT_TESTS_SEQUENTIAL="true"
export RUN_UNIT_TESTS="false"
export GOAL="install"
export CI_LIMIT_STACK_SIZE=1
export DOWNLOAD_PREVIOUS_RELEASES="true"
export BITCOIN_CONFIG="\
-DWITH_ZMQ=ON -DBUILD_GUI=ON -DREDUCE_EXPORTS=ON \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_FLAGS='-funsigned-char' \
-DCMAKE_C_FLAGS_DEBUG='-g0 -O2' \
-DCMAKE_C_FLAGS_DEBUG='-g2 -O2' \
-DCMAKE_CXX_FLAGS='-funsigned-char' \
-DCMAKE_CXX_FLAGS_DEBUG='-g0 -O2' \
-DCMAKE_CXX_FLAGS_DEBUG='-g2 -O2' \
-DAPPEND_CPPFLAGS='-DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE' \
"

View File

@ -8,9 +8,9 @@ export LC_ALL=C.UTF-8
export CI_IMAGE_NAME_TAG="mirror.gcr.io/ubuntu:24.04"
export CONTAINER_NAME=ci_native_tidy
export TIDY_LLVM_V="19"
export TIDY_LLVM_V="20"
export APT_LLVM_V="${TIDY_LLVM_V}"
export PACKAGES="clang-${TIDY_LLVM_V} libclang-${TIDY_LLVM_V}-dev llvm-${TIDY_LLVM_V}-dev libomp-${TIDY_LLVM_V}-dev clang-tidy-${TIDY_LLVM_V} jq libevent-dev libboost-dev libzmq3-dev systemtap-sdt-dev qtbase5-dev qttools5-dev qttools5-dev-tools libqrencode-dev libsqlite3-dev libdb++-dev"
export PACKAGES="clang-${TIDY_LLVM_V} libclang-${TIDY_LLVM_V}-dev llvm-${TIDY_LLVM_V}-dev libomp-${TIDY_LLVM_V}-dev clang-tidy-${TIDY_LLVM_V} jq libevent-dev libboost-dev libzmq3-dev systemtap-sdt-dev qt6-base-dev qt6-tools-dev qt6-l10n-tools libqrencode-dev libsqlite3-dev libcapnp-dev capnproto"
export NO_DEPENDS=1
export RUN_UNIT_TESTS=false
export RUN_FUNCTIONAL_TESTS=false
@ -19,8 +19,7 @@ export RUN_CHECK_DEPS=true
export RUN_TIDY=true
export GOAL="install"
export BITCOIN_CONFIG="\
-DWITH_ZMQ=ON -DBUILD_GUI=ON -DBUILD_BENCH=ON -DWITH_USDT=ON -DWITH_BDB=ON -DWARN_INCOMPATIBLE_BDB=OFF \
-DENABLE_HARDENING=OFF \
-DWITH_ZMQ=ON -DBUILD_GUI=ON -DBUILD_BENCH=ON -DWITH_USDT=ON \
-DCMAKE_C_COMPILER=clang-${TIDY_LLVM_V} \
-DCMAKE_CXX_COMPILER=clang++-${TIDY_LLVM_V} \
-DCMAKE_C_FLAGS_RELWITHDEBINFO='-O0 -g0' \

View File

@ -8,9 +8,14 @@ export LC_ALL=C.UTF-8
export CONTAINER_NAME=ci_native_tsan
export CI_IMAGE_NAME_TAG="mirror.gcr.io/ubuntu:24.04"
export APT_LLVM_V="20"
export PACKAGES="clang-${APT_LLVM_V} llvm-${APT_LLVM_V} libclang-rt-${APT_LLVM_V}-dev libc++abi-${APT_LLVM_V}-dev libc++-${APT_LLVM_V}-dev python3-zmq"
export DEP_OPTS="CC=clang-${APT_LLVM_V} CXX='clang++-${APT_LLVM_V} -stdlib=libc++'"
export APT_LLVM_V="21"
LIBCXX_DIR="/cxx_build/"
LIBCXX_FLAGS="-fsanitize=thread -nostdinc++ -nostdlib++ -isystem ${LIBCXX_DIR}include/c++/v1 -L${LIBCXX_DIR}lib -Wl,-rpath,${LIBCXX_DIR}lib -lc++ -lc++abi -lpthread -Wno-unused-command-line-argument"
export PACKAGES="clang-${APT_LLVM_V} llvm-${APT_LLVM_V} llvm-${APT_LLVM_V}-dev libclang-${APT_LLVM_V}-dev libclang-rt-${APT_LLVM_V}-dev python3-zmq python3-pip"
export PIP_PACKAGES="--break-system-packages pycapnp"
export DEP_OPTS="CC=clang CXX=clang++ CXXFLAGS='${LIBCXX_FLAGS}' NO_QT=1"
export GOAL="install"
export CI_LIMIT_STACK_SIZE=1
export BITCOIN_CONFIG="-DWITH_ZMQ=ON -DSANITIZERS=thread \
-DAPPEND_CPPFLAGS='-DARENA_DEBUG -DDEBUG_LOCKORDER -DDEBUG_LOCKCONTENTION -D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES'"
-DAPPEND_CPPFLAGS='-DARENA_DEBUG -DDEBUG_LOCKCONTENTION -D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES'"
export USE_INSTRUMENTED_LIBCPP="Thread"

View File

@ -8,14 +8,14 @@ export LC_ALL=C.UTF-8
export CI_IMAGE_NAME_TAG="mirror.gcr.io/ubuntu:24.04"
export CONTAINER_NAME=ci_native_valgrind
export PACKAGES="valgrind clang-16 llvm-16 libclang-rt-16-dev python3-zmq libevent-dev libboost-dev libdb5.3++-dev libzmq3-dev libsqlite3-dev"
export PACKAGES="valgrind python3-zmq libevent-dev libboost-dev libzmq3-dev libsqlite3-dev libcapnp-dev capnproto python3-pip"
export PIP_PACKAGES="--break-system-packages pycapnp"
export USE_VALGRIND=1
export NO_DEPENDS=1
export TEST_RUNNER_EXTRA="--exclude feature_init,rpc_bind,feature_bind_extra" # feature_init excluded for now, see https://github.com/bitcoin/bitcoin/issues/30011 ; bind tests excluded for now, see https://github.com/bitcoin/bitcoin/issues/17765#issuecomment-602068547
# bind tests excluded for now, see https://github.com/bitcoin/bitcoin/issues/17765#issuecomment-602068547
export TEST_RUNNER_EXTRA="--exclude rpc_bind,feature_bind_extra"
export GOAL="install"
# TODO enable GUI
export BITCOIN_CONFIG="\
-DWITH_ZMQ=ON -DWITH_BDB=ON -DWARN_INCOMPATIBLE_BDB=OFF -DBUILD_GUI=OFF \
-DCMAKE_C_COMPILER=clang-16 \
-DCMAKE_CXX_COMPILER=clang++-16 \
-DWITH_ZMQ=ON -DBUILD_GUI=OFF \
"

View File

@ -7,15 +7,12 @@
export LC_ALL=C.UTF-8
export CONTAINER_NAME=ci_win64
export CI_IMAGE_NAME_TAG="mirror.gcr.io/ubuntu:noble" # Check that g++-mingw-w64-x86-64-posix (version 13.2, similar to guix) can cross-compile
export CI_IMAGE_NAME_TAG="mirror.gcr.io/ubuntu:24.04" # Check that https://packages.ubuntu.com/noble/g++-mingw-w64-x86-64-posix (version 13.x, similar to guix) can cross-compile
export CI_IMAGE_PLATFORM="linux/amd64"
export HOST=x86_64-w64-mingw32
export DPKG_ADD_ARCH="i386"
export PACKAGES="nsis g++-mingw-w64-x86-64-posix wine-binfmt wine64 wine32 file"
# Install wine, but do not run unit tests, as they surface frequent
# false-positives.
export RUN_UNIT_TESTS=${RUN_UNIT_TESTS:-false}
export PACKAGES="g++-mingw-w64-x86-64-posix nsis"
export RUN_UNIT_TESTS=false
export RUN_FUNCTIONAL_TESTS=false
export GOAL="deploy"
export BITCOIN_CONFIG="-DREDUCE_EXPORTS=ON -DBUILD_GUI_TESTS=OFF \
-DCMAKE_CXX_FLAGS='-Wno-error=maybe-uninitialized -Wno-error=array-bounds'"
-DCMAKE_CXX_FLAGS='-Wno-error=maybe-uninitialized'"

View File

@ -6,11 +6,11 @@
export LC_ALL=C.UTF-8
set -ex
set -o errexit -o pipefail -o xtrace
CFG_DONE="ci.base-install-done" # Use a global git setting to remember whether this script ran to avoid running it twice
CFG_DONE="${BASE_ROOT_DIR}/ci.base-install-done" # Use a global setting to remember whether this script ran to avoid running it twice
if [ "$(git config --global ${CFG_DONE})" == "true" ]; then
if [ "$( cat "${CFG_DONE}" || true )" == "done" ]; then
echo "Skip base install"
exit 0
fi
@ -34,7 +34,8 @@ fi
if [[ $CI_IMAGE_NAME_TAG == *centos* ]]; then
bash -c "dnf -y install epel-release"
bash -c "dnf -y --allowerasing install $CI_BASE_PACKAGES $PACKAGES"
# The ninja-build package is available in the CRB repository.
bash -c "dnf -y --allowerasing --enablerepo crb install $CI_BASE_PACKAGES $PACKAGES"
elif [ "$CI_OS_NAME" != "macos" ]; then
if [[ -n "${APPEND_APT_SOURCES_LIST}" ]]; then
echo "${APPEND_APT_SOURCES_LIST}" >> /etc/apt/sources.list
@ -43,32 +44,24 @@ elif [ "$CI_OS_NAME" != "macos" ]; then
${CI_RETRY_EXE} bash -c "apt-get install --no-install-recommends --no-upgrade -y $PACKAGES $CI_BASE_PACKAGES"
fi
if [ -n "${APT_LLVM_V}" ]; then
update-alternatives --install /usr/bin/clang++ clang++ "/usr/bin/clang++-${APT_LLVM_V}" 100
update-alternatives --install /usr/bin/clang clang "/usr/bin/clang-${APT_LLVM_V}" 100
update-alternatives --install /usr/bin/llvm-symbolizer llvm-symbolizer "/usr/bin/llvm-symbolizer-${APT_LLVM_V}" 100
fi
if [ -n "$PIP_PACKAGES" ]; then
# shellcheck disable=SC2086
${CI_RETRY_EXE} pip3 install --user $PIP_PACKAGES
fi
if [[ ${USE_MEMORY_SANITIZER} == "true" ]]; then
${CI_RETRY_EXE} git clone --depth=1 https://github.com/llvm/llvm-project -b "llvmorg-20.1.0" /msan/llvm-project
if [[ -n "${USE_INSTRUMENTED_LIBCPP}" ]]; then
${CI_RETRY_EXE} git clone --depth=1 https://github.com/llvm/llvm-project -b "llvmorg-21.1.1" /llvm-project
cmake -G Ninja -B /msan/clang_build/ \
-DLLVM_ENABLE_PROJECTS="clang" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_TARGETS_TO_BUILD=Native \
-DLLVM_ENABLE_RUNTIMES="compiler-rt;libcxx;libcxxabi;libunwind" \
-S /msan/llvm-project/llvm
ninja -C /msan/clang_build/ "$MAKEJOBS"
ninja -C /msan/clang_build/ install-runtimes
update-alternatives --install /usr/bin/clang++ clang++ /msan/clang_build/bin/clang++ 100
update-alternatives --install /usr/bin/clang clang /msan/clang_build/bin/clang 100
update-alternatives --install /usr/bin/llvm-symbolizer llvm-symbolizer /msan/clang_build/bin/llvm-symbolizer 100
cmake -G Ninja -B /msan/cxx_build/ \
cmake -G Ninja -B /cxx_build/ \
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_USE_SANITIZER=MemoryWithOrigins \
-DLLVM_USE_SANITIZER="${USE_INSTRUMENTED_LIBCPP}" \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DLLVM_TARGETS_TO_BUILD=Native \
@ -76,13 +69,13 @@ if [[ ${USE_MEMORY_SANITIZER} == "true" ]]; then
-DLIBCXXABI_USE_LLVM_UNWINDER=OFF \
-DLIBCXX_ABI_DEFINES="_LIBCPP_ABI_BOUNDED_ITERATORS;_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY;_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING;_LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR;_LIBCPP_ABI_BOUNDED_UNIQUE_PTR" \
-DLIBCXX_HARDENING_MODE=debug \
-S /msan/llvm-project/runtimes
-S /llvm-project/runtimes
ninja -C /msan/cxx_build/ "$MAKEJOBS"
ninja -C /cxx_build/ "$MAKEJOBS"
# Clear no longer needed source folder
du -sh /msan/llvm-project
rm -rf /msan/llvm-project
du -sh /llvm-project
rm -rf /llvm-project
fi
if [[ "${RUN_TIDY}" == "true" ]]; then
@ -104,4 +97,4 @@ if [ -n "$XCODE_VERSION" ] && [ ! -d "${DEPENDS_DIR}/SDKs/${OSX_SDK_BASENAME}" ]
tar -C "${DEPENDS_DIR}/SDKs" -xf "$OSX_SDK_PATH"
fi
git config --global ${CFG_DONE} "true"
echo -n "done" > "${CFG_DONE}"

52
ci/test/02_run_container.py Executable file
View File

@ -0,0 +1,52 @@
#!/usr/bin/env python3
# Copyright (c) The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://opensource.org/license/mit/.
import os
import shlex
import subprocess
import sys
def run(cmd, **kwargs):
print("+ " + shlex.join(cmd), flush=True)
try:
return subprocess.run(cmd, check=True, **kwargs)
except Exception as e:
sys.exit(e)
def main():
print("Export only allowed settings:")
settings = run(
["bash", "-c", "grep export ./ci/test/00_setup_env*.sh"],
stdout=subprocess.PIPE,
text=True,
encoding="utf8",
).stdout.splitlines()
settings = set(l.split("=")[0].split("export ")[1] for l in settings)
# Add "hidden" settings, which are never exported, manually. Otherwise,
# they will not be passed on.
settings.update([
"BASE_BUILD_DIR",
"CI_FAILFAST_TEST_LEAVE_DANGLING",
])
# Append $USER to /tmp/env to support multi-user systems and $CONTAINER_NAME
# to allow support starting multiple runs simultaneously by the same user.
env_file = "/tmp/env-{u}-{c}".format(
u=os.getenv("USER"),
c=os.getenv("CONTAINER_NAME"),
)
with open(env_file, "w", encoding="utf8") as file:
for k, v in os.environ.items():
if k in settings:
file.write(f"{k}={v}\n")
run(["cat", env_file])
run(["./ci/test/02_run_container.sh"]) # run the remainder
if __name__ == "__main__":
main()

View File

@ -10,10 +10,6 @@ export CI_IMAGE_LABEL="bitcoin-ci-test"
set -o errexit -o pipefail -o xtrace
if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
# Export all env vars to avoid missing some.
# Though, exclude those with newlines to avoid parsing problems.
python3 -c 'import os; [print(f"{key}={value}") for key, value in os.environ.items() if "\n" not in value and "HOME" != key and "PATH" != key and "USER" != key]' | tee "/tmp/env-$USER-$CONTAINER_NAME"
# Env vars during the build can not be changed. For example, a modified
# $MAKEJOBS is ignored in the build process. Use --cpuset-cpus as an
# approximation to respect $MAKEJOBS somewhat, if cpuset is available.
@ -23,34 +19,14 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
fi
echo "Creating $CI_IMAGE_NAME_TAG container to run in"
DOCKER_BUILD_CACHE_ARG=""
DOCKER_BUILD_CACHE_TEMPDIR=""
DOCKER_BUILD_CACHE_OLD_DIR=""
DOCKER_BUILD_CACHE_NEW_DIR=""
# If set, use an `docker build` cache directory on the CI host
# to cache docker image layers for the CI container image.
# This cache can be multiple GB in size. Prefixed with DANGER
# as setting it removes (old cache) files from the host.
if [ "$DANGER_DOCKER_BUILD_CACHE_HOST_DIR" ]; then
# Directory where the current cache for this run could be. If not existing
# or empty, "docker build" will warn, but treat it as cache-miss and continue.
DOCKER_BUILD_CACHE_OLD_DIR="${DANGER_DOCKER_BUILD_CACHE_HOST_DIR}/${CONTAINER_NAME}"
# Temporary directory for a newly created cache. We can't write the new
# cache into OLD_DIR directly, as old cache layers would not be removed.
# The NEW_DIR contents are moved to OLD_DIR after OLD_DIR has been cleared.
# This happens after `docker build`. If a task fails or is aborted, the
# DOCKER_BUILD_CACHE_TEMPDIR might be retained on the host. If the host isn't
# ephemeral, it has to take care of cleaning old TEMPDIR's up.
DOCKER_BUILD_CACHE_TEMPDIR="$(mktemp --directory ci-docker-build-cache-XXXXXXXXXX)"
DOCKER_BUILD_CACHE_NEW_DIR="${DOCKER_BUILD_CACHE_TEMPDIR}/${CONTAINER_NAME}"
DOCKER_BUILD_CACHE_ARG="--cache-from type=local,src=${DOCKER_BUILD_CACHE_OLD_DIR} --cache-to type=local,dest=${DOCKER_BUILD_CACHE_NEW_DIR},mode=max"
fi
# Use buildx unconditionally
# Using buildx is required to properly load the correct driver, for use with registry caching. Neither build, nor BUILDKIT=1 currently do this properly
# shellcheck disable=SC2086
DOCKER_BUILDKIT=1 docker build \
docker buildx build \
--file "${BASE_READ_ONLY_DIR}/ci/test_imagefile" \
--build-arg "CI_IMAGE_NAME_TAG=${CI_IMAGE_NAME_TAG}" \
--build-arg "FILE_ENV=${FILE_ENV}" \
--build-arg "BASE_ROOT_DIR=${BASE_ROOT_DIR}" \
$MAYBE_CPUSET \
--platform="${CI_IMAGE_PLATFORM}" \
--label="${CI_IMAGE_LABEL}" \
@ -58,15 +34,6 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
$DOCKER_BUILD_CACHE_ARG \
"${BASE_READ_ONLY_DIR}"
if [ "$DANGER_DOCKER_BUILD_CACHE_HOST_DIR" ]; then
if [ -e "${DOCKER_BUILD_CACHE_NEW_DIR}/index.json" ]; then
echo "Removing the existing docker build cache in ${DOCKER_BUILD_CACHE_OLD_DIR}"
rm -rf "${DOCKER_BUILD_CACHE_OLD_DIR}"
echo "Moving the contents of ${DOCKER_BUILD_CACHE_NEW_DIR} to ${DOCKER_BUILD_CACHE_OLD_DIR}"
mv "${DOCKER_BUILD_CACHE_NEW_DIR}" "${DOCKER_BUILD_CACHE_OLD_DIR}"
fi
fi
docker volume create "${CONTAINER_NAME}_ccache" || true
docker volume create "${CONTAINER_NAME}_depends" || true
docker volume create "${CONTAINER_NAME}_depends_sources" || true
@ -94,16 +61,11 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
fi
if [ "$DANGER_CI_ON_HOST_CCACHE_FOLDER" ]; then
# Temporary exclusion for https://github.com/bitcoin/bitcoin/issues/31108
# to allow CI configs and envs generated in the past to work for a bit longer.
# Can be removed in March 2025.
if [ "${CCACHE_DIR}" != "/tmp/ccache_dir" ]; then
if [ ! -d "${CCACHE_DIR}" ]; then
echo "Error: Directory '${CCACHE_DIR}' must be created in advance."
exit 1
fi
CI_CCACHE_MOUNT="type=bind,src=${CCACHE_DIR},dst=${CCACHE_DIR}"
fi # End temporary exclusion
fi
docker network create --ipv6 --subnet 1111:1111::/112 ci-ip6net || true
@ -123,8 +85,6 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
# When detecting podman-docker, `--external` should be added.
docker image prune --force --filter "label=$CI_IMAGE_LABEL"
# Append $USER to /tmp/env to support multi-user systems and $CONTAINER_NAME
# to allow support starting multiple runs simultaneously by the same user.
# shellcheck disable=SC2086
CI_CONTAINER_ID=$(docker run --cap-add LINUX_IMMUTABLE $CI_CONTAINER_CAP --rm --interactive --detach --tty \
--mount "type=bind,src=$BASE_READ_ONLY_DIR,dst=$BASE_READ_ONLY_DIR,readonly" \
@ -158,13 +118,9 @@ CI_EXEC () {
export -f CI_EXEC
# Normalize all folders to BASE_ROOT_DIR
CI_EXEC rsync --archive --stats --human-readable "${BASE_READ_ONLY_DIR}/" "${BASE_ROOT_DIR}" || echo "Nothing to copy from ${BASE_READ_ONLY_DIR}/"
CI_EXEC rsync --recursive --perms --stats --human-readable "${BASE_READ_ONLY_DIR}/" "${BASE_ROOT_DIR}" || echo "Nothing to copy from ${BASE_READ_ONLY_DIR}/"
CI_EXEC "${BASE_ROOT_DIR}/ci/test/01_base_install.sh"
# Fixes permission issues when there is a container UID/GID mismatch with the owner
# of the git source code directory.
CI_EXEC git config --global --add safe.directory \"*\"
CI_EXEC mkdir -p "${BINS_SCRATCH_DIR}"
CI_EXEC "${BASE_ROOT_DIR}/ci/test/03_test_script.sh"

View File

@ -24,6 +24,14 @@ fi
echo "Free disk space:"
df -h
# We force an install of linux-headers again here via $PACKAGES to fix any
# kernel mismatch between a cached docker image and the underlying host.
# This can happen occasionally on hosted runners if the runner image is updated.
if [[ "$CONTAINER_NAME" == "ci_native_asan" ]]; then
$CI_RETRY_EXE apt-get update
${CI_RETRY_EXE} bash -c "apt-get install --no-install-recommends --no-upgrade -y $PACKAGES"
fi
# What host to compile for. See also ./depends/README.md
# Tests that need cross-compilation export the appropriate HOST.
# Tests that run natively guess the host
@ -66,7 +74,7 @@ if [ "$RUN_FUZZ_TESTS" = "true" ]; then
echo "Using qa-assets repo from commit ..."
git log -1
)
elif [ "$RUN_UNIT_TESTS" = "true" ] || [ "$RUN_UNIT_TESTS_SEQUENTIAL" = "true" ]; then
elif [ "$RUN_UNIT_TESTS" = "true" ]; then
export DIR_UNIT_TEST_DATA=${DIR_QA_ASSETS}/unit_test_data/
if [ ! -d "$DIR_UNIT_TEST_DATA" ]; then
mkdir -p "$DIR_UNIT_TEST_DATA"
@ -92,14 +100,14 @@ fi
if [ -z "$NO_DEPENDS" ]; then
if [[ $CI_IMAGE_NAME_TAG == *centos* ]]; then
SHELL_OPTS="CONFIG_SHELL=/bin/ksh" # Temporarily use ksh instead of dash, until https://bugzilla.redhat.com/show_bug.cgi?id=2335416 is fixed.
SHELL_OPTS="CONFIG_SHELL=/bin/dash"
else
SHELL_OPTS="CONFIG_SHELL="
fi
bash -c "$SHELL_OPTS make $MAKEJOBS -C depends HOST=$HOST $DEP_OPTS LOG=1"
fi
if [ "$DOWNLOAD_PREVIOUS_RELEASES" = "true" ]; then
test/get_previous_releases.py -b -t "$PREVIOUS_RELEASES_DIR"
test/get_previous_releases.py --target-dir "$PREVIOUS_RELEASES_DIR"
fi
BITCOIN_CONFIG_ALL="-DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON"
@ -115,25 +123,41 @@ PRINT_CCACHE_STATISTICS="ccache --version | head -n 1 && ccache --show-stats"
# Folder where the build is done.
BASE_BUILD_DIR=${BASE_BUILD_DIR:-$BASE_SCRATCH_DIR/build-$HOST}
mkdir -p "${BASE_BUILD_DIR}"
cd "${BASE_BUILD_DIR}"
BITCOIN_CONFIG_ALL="$BITCOIN_CONFIG_ALL -DENABLE_EXTERNAL_SIGNER=ON -DCMAKE_INSTALL_PREFIX=$BASE_OUTDIR"
BITCOIN_CONFIG_ALL="$BITCOIN_CONFIG_ALL -DCMAKE_INSTALL_PREFIX=$BASE_OUTDIR -Werror=dev"
if [[ "${RUN_TIDY}" == "true" ]]; then
BITCOIN_CONFIG_ALL="$BITCOIN_CONFIG_ALL -DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
fi
bash -c "cmake -S $BASE_ROOT_DIR $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG || ( (cat $(cmake -P "${BASE_ROOT_DIR}/ci/test/GetCMakeLogFiles.cmake")) && false)"
eval "CMAKE_ARGS=($BITCOIN_CONFIG_ALL $BITCOIN_CONFIG)"
cmake -S "$BASE_ROOT_DIR" -B "$BASE_BUILD_DIR" "${CMAKE_ARGS[@]}" || (
cd "${BASE_BUILD_DIR}"
# shellcheck disable=SC2046
cat $(cmake -P "${BASE_ROOT_DIR}/ci/test/GetCMakeLogFiles.cmake")
false
)
bash -c "cmake --build . $MAKEJOBS --target all $GOAL" || ( echo "Build failure. Verbose build follows." && cmake --build . --target all "$GOAL" --verbose ; false )
# shellcheck disable=SC2086
cmake --build "${BASE_BUILD_DIR}" "$MAKEJOBS" --target all $GOAL || (
echo "Build failure. Verbose build follows."
# shellcheck disable=SC2086
cmake --build "${BASE_BUILD_DIR}" -j1 --target all $GOAL --verbose
false
)
bash -c "${PRINT_CCACHE_STATISTICS}"
if [ "$CI" = "true" ]; then
hit_rate=$(ccache -s | grep "Hits:" | head -1 | sed 's/.*(\(.*\)%).*/\1/')
if [ "${hit_rate%.*}" -lt 75 ]; then
echo "::notice title=low ccache hitrate::Ccache hit-rate in $CONTAINER_NAME was $hit_rate%"
fi
fi
du -sh "${DEPENDS_DIR}"/*/
du -sh "${PREVIOUS_RELEASES_DIR}"
if [[ $HOST = *-mingw32 ]]; then
"${BASE_ROOT_DIR}/ci/test/wrap-wine.sh"
if [ -n "${CI_LIMIT_STACK_SIZE}" ]; then
ulimit -s 512
fi
if [ -n "$USE_VALGRIND" ]; then
@ -141,21 +165,32 @@ if [ -n "$USE_VALGRIND" ]; then
fi
if [ "$RUN_CHECK_DEPS" = "true" ]; then
"${BASE_ROOT_DIR}/contrib/devtools/check-deps.sh" .
"${BASE_ROOT_DIR}/contrib/devtools/check-deps.sh" "${BASE_BUILD_DIR}"
fi
if [ "$RUN_UNIT_TESTS" = "true" ]; then
DIR_UNIT_TEST_DATA="${DIR_UNIT_TEST_DATA}" LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" CTEST_OUTPUT_ON_FAILURE=ON ctest --stop-on-failure "${MAKEJOBS}" --timeout $(( TEST_RUNNER_TIMEOUT_FACTOR * 60 ))
fi
if [ "$RUN_UNIT_TESTS_SEQUENTIAL" = "true" ]; then
DIR_UNIT_TEST_DATA="${DIR_UNIT_TEST_DATA}" LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" "${BASE_OUTDIR}"/bin/test_bitcoin --catch_system_errors=no -l test_suite
DIR_UNIT_TEST_DATA="${DIR_UNIT_TEST_DATA}" \
LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" \
CTEST_OUTPUT_ON_FAILURE=ON \
ctest --test-dir "${BASE_BUILD_DIR}" \
--stop-on-failure \
"${MAKEJOBS}" \
--timeout $(( TEST_RUNNER_TIMEOUT_FACTOR * 60 ))
fi
if [ "$RUN_FUNCTIONAL_TESTS" = "true" ]; then
# parses TEST_RUNNER_EXTRA as an array which allows for multiple arguments such as TEST_RUNNER_EXTRA='--exclude "rpc_bind.py --ipv6"'
eval "TEST_RUNNER_EXTRA=($TEST_RUNNER_EXTRA)"
LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" test/functional/test_runner.py --ci "${MAKEJOBS}" --tmpdirprefix "${BASE_SCRATCH_DIR}"/test_runner/ --ansi --combinedlogslen=99999999 --timeout-factor="${TEST_RUNNER_TIMEOUT_FACTOR}" "${TEST_RUNNER_EXTRA[@]}" --quiet --failfast
LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" \
"${BASE_BUILD_DIR}/test/functional/test_runner.py" \
--ci "${MAKEJOBS}" \
--tmpdirprefix "${BASE_SCRATCH_DIR}/test_runner/" \
--ansi \
--combinedlogslen=99999999 \
--timeout-factor="${TEST_RUNNER_TIMEOUT_FACTOR}" \
"${TEST_RUNNER_EXTRA[@]}" \
--quiet \
--failfast
fi
if [ "${RUN_TIDY}" = "true" ]; then
@ -189,5 +224,11 @@ fi
if [ "$RUN_FUZZ_TESTS" = "true" ]; then
# shellcheck disable=SC2086
LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" test/fuzz/test_runner.py ${FUZZ_TESTS_CONFIG} "${MAKEJOBS}" -l DEBUG "${DIR_FUZZ_IN}" --empty_min_time=60
LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" \
"${BASE_BUILD_DIR}/test/fuzz/test_runner.py" \
${FUZZ_TESTS_CONFIG} \
"${MAKEJOBS}" \
-l DEBUG \
"${DIR_FUZZ_IN}" \
--empty_min_time=60
fi

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
# Copyright (c) 2018-2021 The Bitcoin Core developers
# Copyright (c) 2018-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -12,7 +12,7 @@ for b_name in "${BASE_OUTDIR}/bin"/*; do
echo "Wrap $b ..."
mv "$b" "${b}_orig"
echo '#!/usr/bin/env bash' > "$b"
echo "valgrind --gen-suppressions=all --quiet --error-exitcode=1 --suppressions=${BASE_ROOT_DIR}/contrib/valgrind.supp \"${b}_orig\" \"\$@\"" >> "$b"
echo "exec valgrind --gen-suppressions=all --quiet --error-exitcode=1 --suppressions=${BASE_ROOT_DIR}/contrib/valgrind.supp \"${b}_orig\" \"\$@\"" >> "$b"
chmod +x "$b"
done
done

View File

@ -1,20 +0,0 @@
#!/usr/bin/env bash
#
# Copyright (c) 2020-2022 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
export LC_ALL=C.UTF-8
for b_name in {"${BASE_OUTDIR}/bin"/*,src/univalue/{test_json,unitester,object}}.exe; do
# shellcheck disable=SC2044
for b in $(find "${BASE_ROOT_DIR}" -executable -type f -name "$(basename "$b_name")"); do
if (file "$b" | grep "Windows"); then
echo "Wrap $b ..."
mv "$b" "${b}_orig"
echo '#!/usr/bin/env bash' > "$b"
echo "( wine \"${b}_orig\" \"\$@\" ) || ( sleep 1 && wine \"${b}_orig\" \"\$@\" )" >> "$b"
chmod +x "$b"
fi
done
done

View File

@ -4,12 +4,16 @@
# See ci/README.md for usage.
ARG CI_IMAGE_NAME_TAG
# We never want scratch, but default arg silences a Warning
ARG CI_IMAGE_NAME_TAG=scratch
FROM ${CI_IMAGE_NAME_TAG}
ARG FILE_ENV
ENV FILE_ENV=${FILE_ENV}
ARG BASE_ROOT_DIR
ENV BASE_ROOT_DIR=${BASE_ROOT_DIR}
COPY ./ci/retry/retry /usr/bin/retry
COPY ./ci/test/00_setup_env.sh ./${FILE_ENV} ./ci/test/01_base_install.sh /ci_container_base/ci/test/

View File

@ -8,4 +8,4 @@ export LC_ALL=C.UTF-8
set -o errexit; source ./ci/test/00_setup_env.sh
set -o errexit
"./ci/test/02_run_container.sh"
"./ci/test/02_run_container.py"

View File

@ -29,18 +29,9 @@
/* Copyright year */
#define COPYRIGHT_YEAR @COPYRIGHT_YEAR@
/* Define this symbol to build code that uses ARMv8 SHA-NI intrinsics */
#cmakedefine ENABLE_ARM_SHANI 1
/* Define this symbol to build code that uses AVX2 intrinsics */
#cmakedefine ENABLE_AVX2 1
/* Define if external signer support is enabled */
#cmakedefine ENABLE_EXTERNAL_SIGNER 1
/* Define this symbol to build code that uses SSE4.1 intrinsics */
#cmakedefine ENABLE_SSE41 1
/* Define to 1 to enable tracepoints for Userspace, Statically Defined Tracing
*/
#cmakedefine ENABLE_TRACING 1
@ -48,20 +39,12 @@
/* Define to 1 to enable wallet functions. */
#cmakedefine ENABLE_WALLET 1
/* Define this symbol to build code that uses x86 SHA-NI intrinsics */
#cmakedefine ENABLE_X86_SHANI 1
/* Define to 1 if you have the declaration of `fork', and to 0 if you don't.
*/
#cmakedefine01 HAVE_DECL_FORK
/* Define to 1 if you have the declaration of `freeifaddrs', and to 0 if you
don't. */
#cmakedefine01 HAVE_DECL_FREEIFADDRS
/* Define to 1 if you have the declaration of `getifaddrs', and to 0 if you
don't. */
#cmakedefine01 HAVE_DECL_GETIFADDRS
/* Define to 1 if '*ifaddrs' are available. */
#cmakedefine HAVE_IFADDRS 1
/* Define to 1 if you have the declaration of `pipe2', and to 0 if you don't.
*/
@ -108,18 +91,6 @@
/* Define to 1 if std::system or ::wsystem is available. */
#cmakedefine HAVE_SYSTEM 1
/* Define to 1 if you have the <sys/prctl.h> header file. */
#cmakedefine HAVE_SYS_PRCTL_H 1
/* Define to 1 if you have the <sys/resources.h> header file. */
#cmakedefine HAVE_SYS_RESOURCES_H 1
/* Define to 1 if you have the <sys/vmmeter.h> header file. */
#cmakedefine HAVE_SYS_VMMETER_H 1
/* Define to 1 if you have the <vm/vm_param.h> header file. */
#cmakedefine HAVE_VM_VM_PARAM_H 1
/* Define to the address where bug reports for this package should be sent. */
#define CLIENT_BUGREPORT "@CLIENT_BUGREPORT@"
@ -135,16 +106,10 @@
/* Define to 1 if strerror_r returns char *. */
#cmakedefine STRERROR_R_CHAR_P 1
/* Define if BDB support should be compiled in */
#cmakedefine USE_BDB 1
/* Define if dbus support should be compiled in */
#cmakedefine USE_DBUS 1
/* Define if QR support should be compiled in */
#cmakedefine USE_QRCODE 1
/* Define if sqlite support should be compiled in */
#cmakedefine USE_SQLITE 1
#endif //BITCOIN_CONFIG_H

View File

@ -4,13 +4,6 @@
include(CheckCXXSourceCompiles)
include(CheckCXXSymbolExists)
include(CheckIncludeFileCXX)
# The following HAVE_{HEADER}_H variables go to the bitcoin-build-config.h header.
check_include_file_cxx(sys/prctl.h HAVE_SYS_PRCTL_H)
check_include_file_cxx(sys/resources.h HAVE_SYS_RESOURCES_H)
check_include_file_cxx(sys/vmmeter.h HAVE_SYS_VMMETER_H)
check_include_file_cxx(vm/vm_param.h HAVE_VM_VM_PARAM_H)
check_cxx_symbol_exists(O_CLOEXEC "fcntl.h" HAVE_O_CLOEXEC)
check_cxx_symbol_exists(fdatasync "unistd.h" HAVE_FDATASYNC)
@ -18,9 +11,7 @@ check_cxx_symbol_exists(fork "unistd.h" HAVE_DECL_FORK)
check_cxx_symbol_exists(pipe2 "unistd.h" HAVE_DECL_PIPE2)
check_cxx_symbol_exists(setsid "unistd.h" HAVE_DECL_SETSID)
check_include_file_cxx(sys/types.h HAVE_SYS_TYPES_H)
check_include_file_cxx(ifaddrs.h HAVE_IFADDRS_H)
if(HAVE_SYS_TYPES_H AND HAVE_IFADDRS_H)
if(NOT WIN32)
include(TestAppendRequiredLibraries)
test_append_socket_library(core_interface)
endif()
@ -28,6 +19,8 @@ endif()
include(TestAppendRequiredLibraries)
test_append_atomic_library(core_interface)
# Even though ::system is part of the standard library, we still check
# for it, to support building targets that don't have it, such as iOS.
check_cxx_symbol_exists(std::system "cstdlib" HAVE_STD_SYSTEM)
check_cxx_symbol_exists(::_wsystem "stdlib.h" HAVE__WSYSTEM)
if(HAVE_STD_SYSTEM OR HAVE__WSYSTEM)
@ -62,13 +55,6 @@ check_cxx_source_compiles("
# Check for posix_fallocate().
check_cxx_source_compiles("
// same as in src/util/fs_helpers.cpp
#ifdef __linux__
#ifdef _POSIX_C_SOURCE
#undef _POSIX_C_SOURCE
#endif
#define _POSIX_C_SOURCE 200112L
#endif // __linux__
#include <fcntl.h>
int main()
@ -177,7 +163,6 @@ if(NOT MSVC)
" HAVE_SSE41
CXXFLAGS ${SSE41_CXXFLAGS}
)
set(ENABLE_SSE41 ${HAVE_SSE41})
# Check for AVX2 intrinsics.
set(AVX2_CXXFLAGS -mavx -mavx2)
@ -192,7 +177,6 @@ if(NOT MSVC)
" HAVE_AVX2
CXXFLAGS ${AVX2_CXXFLAGS}
)
set(ENABLE_AVX2 ${HAVE_AVX2})
# Check for x86 SHA-NI intrinsics.
set(X86_SHANI_CXXFLAGS -msse4 -msha)
@ -209,7 +193,6 @@ if(NOT MSVC)
" HAVE_X86_SHANI
CXXFLAGS ${X86_SHANI_CXXFLAGS}
)
set(ENABLE_X86_SHANI ${HAVE_X86_SHANI})
# Check for ARMv8 SHA-NI intrinsics.
set(ARM_SHANI_CXXFLAGS -march=armv8-a+crypto)
@ -227,5 +210,4 @@ if(NOT MSVC)
" HAVE_ARM_SHANI
CXXFLAGS ${ARM_SHANI_CXXFLAGS}
)
set(ENABLE_ARM_SHANI ${HAVE_ARM_SHANI})
endif()

View File

@ -90,9 +90,6 @@ else()
try_append_cxx_flags("-Wconditional-uninitialized" TARGET nowarn_leveldb_interface SKIP_LINK
IF_CHECK_PASSED "-Wno-conditional-uninitialized"
)
try_append_cxx_flags("-Wsuggest-override" TARGET nowarn_leveldb_interface SKIP_LINK
IF_CHECK_PASSED "-Wno-suggest-override"
)
endif()
target_link_libraries(leveldb PRIVATE

View File

@ -0,0 +1,38 @@
# Copyright (c) 2025 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://opensource.org/license/mit/.
function(add_libmultiprocess subdir)
# Set BUILD_TESTING to match BUILD_TESTS. BUILD_TESTING is a standard cmake
# option that controls whether enable_testing() is called, but in the bitcoin
# build a BUILD_TESTS option is used instead.
set(BUILD_TESTING "${BUILD_TESTS}")
add_subdirectory(${subdir} EXCLUDE_FROM_ALL)
# Apply core_interface compile options to libmultiprocess runtime library.
target_link_libraries(multiprocess PUBLIC $<BUILD_INTERFACE:core_interface>)
target_link_libraries(mputil PUBLIC $<BUILD_INTERFACE:core_interface>)
target_link_libraries(mpgen PUBLIC $<BUILD_INTERFACE:core_interface>)
# Mark capproto options as advanced to hide by default from cmake UI
mark_as_advanced(CapnProto_DIR)
mark_as_advanced(CapnProto_capnpc_IMPORTED_LOCATION)
mark_as_advanced(CapnProto_capnp_IMPORTED_LOCATION)
mark_as_advanced(CapnProto_capnp-json_IMPORTED_LOCATION)
mark_as_advanced(CapnProto_capnp-rpc_IMPORTED_LOCATION)
mark_as_advanced(CapnProto_capnp-websocket_IMPORTED_LOCATION)
mark_as_advanced(CapnProto_kj-async_IMPORTED_LOCATION)
mark_as_advanced(CapnProto_kj-gzip_IMPORTED_LOCATION)
mark_as_advanced(CapnProto_kj-http_IMPORTED_LOCATION)
mark_as_advanced(CapnProto_kj_IMPORTED_LOCATION)
mark_as_advanced(CapnProto_kj-test_IMPORTED_LOCATION)
mark_as_advanced(CapnProto_kj-tls_IMPORTED_LOCATION)
if(BUILD_TESTS)
# Add tests to "all" target so ctest can run them
set_target_properties(mptests PROPERTIES EXCLUDE_FROM_ALL OFF)
endif()
# Exclude examples from compilation database, because the examples are not
# built by default, and they contain generated c++ code. Without this
# exclusion, tools like clang-tidy and IWYU that make use of compilation
# database would complain that the generated c++ source files do not exist. An
# alternate fix could build "mpexamples" by default like "mptests" above.
set_target_properties(mpcalculator mpprinter mpexample PROPERTIES EXPORT_COMPILE_COMMANDS OFF)
endfunction()

View File

@ -17,17 +17,29 @@ function(add_boost_if_needed)
directory and other added INTERFACE properties.
]=]
# We cannot rely on find_package(Boost ...) to work properly without
# Boost_NO_BOOST_CMAKE set until we require a more recent Boost because
# upstream did not ship proper CMake files until 1.82.0.
# Until then, we rely on CMake's FindBoost module.
# See: https://cmake.org/cmake/help/latest/policy/CMP0167.html
if(POLICY CMP0167)
cmake_policy(SET CMP0167 OLD)
if(CMAKE_HOST_APPLE)
find_program(HOMEBREW_EXECUTABLE brew)
if(HOMEBREW_EXECUTABLE)
execute_process(
COMMAND ${HOMEBREW_EXECUTABLE} --prefix boost
OUTPUT_VARIABLE Boost_ROOT
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
endif()
find_package(Boost 1.73.0 REQUIRED CONFIG)
mark_as_advanced(Boost_INCLUDE_DIR boost_headers_DIR)
# Workaround for a bug in NetBSD pkgsrc.
# See: https://github.com/NetBSD/pkgsrc/issues/167.
if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
get_filename_component(_boost_include_dir "${boost_headers_DIR}/../../../include/" ABSOLUTE)
set_target_properties(Boost::headers PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${_boost_include_dir}
)
unset(_boost_include_dir)
endif()
set(Boost_NO_BOOST_CMAKE ON)
find_package(Boost 1.73.0 REQUIRED)
mark_as_advanced(Boost_INCLUDE_DIR)
set_target_properties(Boost::headers PROPERTIES IMPORTED_GLOBAL TRUE)
target_compile_definitions(Boost::headers INTERFACE
# We don't use multi_index serialization.
@ -45,34 +57,24 @@ function(add_boost_if_needed)
# older than 1.80.
# See: https://github.com/boostorg/config/pull/430.
set(CMAKE_REQUIRED_DEFINITIONS -DBOOST_NO_CXX98_FUNCTION_BASE)
set(CMAKE_REQUIRED_INCLUDES ${Boost_INCLUDE_DIR})
include(CMakePushCheckState)
cmake_push_check_state()
include(TryAppendCXXFlags)
get_target_property(CMAKE_REQUIRED_INCLUDES Boost::headers INTERFACE_INCLUDE_DIRECTORIES)
set(CMAKE_REQUIRED_FLAGS ${working_compiler_werror_flag})
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("
#include <boost/config.hpp>
" NO_DIAGNOSTICS_BOOST_NO_CXX98_FUNCTION_BASE
)
cmake_pop_check_state()
if(NO_DIAGNOSTICS_BOOST_NO_CXX98_FUNCTION_BASE)
target_compile_definitions(Boost::headers INTERFACE
BOOST_NO_CXX98_FUNCTION_BASE
)
else()
set(CMAKE_REQUIRED_DEFINITIONS)
endif()
# Some package managers, such as vcpkg, vendor Boost.Test separately
# from the rest of the headers, so we have to check for it individually.
if(BUILD_TESTS AND DEFINED VCPKG_TARGET_TRIPLET)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DBOOST_TEST_NO_MAIN)
include(CheckIncludeFileCXX)
check_include_file_cxx(boost/test/included/unit_test.hpp HAVE_BOOST_INCLUDED_UNIT_TEST_H)
if(NOT HAVE_BOOST_INCLUDED_UNIT_TEST_H)
message(FATAL_ERROR "Building test_bitcoin executable requested but boost/test/included/unit_test.hpp header not available.")
endif()
find_package(boost_included_unit_test_framework ${Boost_VERSION} EXACT REQUIRED CONFIG)
endif()
endfunction()

View File

@ -4,11 +4,21 @@
include_guard(GLOBAL)
macro(add_windows_resources target rc_file)
function(add_windows_resources target rc_file)
if(WIN32)
target_sources(${target} PRIVATE ${rc_file})
set_property(SOURCE ${rc_file}
APPEND PROPERTY COMPILE_DEFINITIONS WINDRES_PREPROC
)
endif()
endmacro()
endfunction()
# Add a fusion manifest to Windows executables.
# See: https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests
function(add_windows_application_manifest target)
if(WIN32)
configure_file(${PROJECT_SOURCE_DIR}/cmake/windows-app.manifest.in ${target}.manifest USE_SOURCE_PERMISSIONS)
file(CONFIGURE
OUTPUT ${target}-manifest.rc
CONTENT "1 /* CREATEPROCESS_MANIFEST_RESOURCE_ID */ 24 /* RT_MANIFEST */ \"${target}.manifest\""
)
add_windows_resources(${target} ${CMAKE_CURRENT_BINARY_DIR}/${target}-manifest.rc)
endif()
endfunction()

View File

@ -1,133 +0,0 @@
# Copyright (c) 2023-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://opensource.org/license/mit/.
#[=======================================================================[
FindBerkeleyDB
--------------
Finds the Berkeley DB headers and library.
Imported Targets
^^^^^^^^^^^^^^^^
This module provides imported target ``BerkeleyDB::BerkeleyDB``, if
Berkeley DB has been found.
Result Variables
^^^^^^^^^^^^^^^^
This module defines the following variables:
``BerkeleyDB_FOUND``
"True" if Berkeley DB found.
``BerkeleyDB_VERSION``
The MAJOR.MINOR version of Berkeley DB found.
#]=======================================================================]
set(_BerkeleyDB_homebrew_prefix)
if(CMAKE_HOST_APPLE)
find_program(HOMEBREW_EXECUTABLE brew)
if(HOMEBREW_EXECUTABLE)
# The Homebrew package manager installs the berkeley-db* packages as
# "keg-only", which means they are not symlinked into the default prefix.
# To find such a package, the find_path() and find_library() commands
# need additional path hints that are computed by Homebrew itself.
execute_process(
COMMAND ${HOMEBREW_EXECUTABLE} --prefix berkeley-db@4
OUTPUT_VARIABLE _BerkeleyDB_homebrew_prefix
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
endif()
find_path(BerkeleyDB_INCLUDE_DIR
NAMES db_cxx.h
HINTS ${_BerkeleyDB_homebrew_prefix}/include
PATH_SUFFIXES 4.8 48 db4.8 4 db4 5.3 db5.3 5 db5
)
mark_as_advanced(BerkeleyDB_INCLUDE_DIR)
unset(_BerkeleyDB_homebrew_prefix)
if(NOT BerkeleyDB_LIBRARY)
if(VCPKG_TARGET_TRIPLET)
# The vcpkg package manager installs the berkeleydb package with the same name
# of release and debug libraries. Therefore, the default search paths set by
# vcpkg's toolchain file cannot be used to search libraries as the debug one
# will always be found.
set(CMAKE_FIND_USE_CMAKE_PATH FALSE)
endif()
get_filename_component(_BerkeleyDB_lib_hint "${BerkeleyDB_INCLUDE_DIR}" DIRECTORY)
find_library(BerkeleyDB_LIBRARY_RELEASE
NAMES db_cxx-4.8 db4_cxx db48 db_cxx-5.3 db_cxx-5 db_cxx libdb48
NAMES_PER_DIR
HINTS ${_BerkeleyDB_lib_hint}
PATH_SUFFIXES lib
)
mark_as_advanced(BerkeleyDB_LIBRARY_RELEASE)
find_library(BerkeleyDB_LIBRARY_DEBUG
NAMES db_cxx-4.8 db4_cxx db48 db_cxx-5.3 db_cxx-5 db_cxx libdb48
NAMES_PER_DIR
HINTS ${_BerkeleyDB_lib_hint}
PATH_SUFFIXES debug/lib
)
mark_as_advanced(BerkeleyDB_LIBRARY_DEBUG)
unset(_BerkeleyDB_lib_hint)
unset(CMAKE_FIND_USE_CMAKE_PATH)
include(SelectLibraryConfigurations)
select_library_configurations(BerkeleyDB)
# The select_library_configurations() command sets BerkeleyDB_FOUND, but we
# want the one from the find_package_handle_standard_args() command below.
unset(BerkeleyDB_FOUND)
endif()
if(BerkeleyDB_INCLUDE_DIR)
file(STRINGS "${BerkeleyDB_INCLUDE_DIR}/db.h" _BerkeleyDB_version_strings REGEX "^#define[\t ]+DB_VERSION_(MAJOR|MINOR|PATCH)[ \t]+[0-9]+.*")
string(REGEX REPLACE ".*#define[\t ]+DB_VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" _BerkeleyDB_version_major "${_BerkeleyDB_version_strings}")
string(REGEX REPLACE ".*#define[\t ]+DB_VERSION_MINOR[ \t]+([0-9]+).*" "\\1" _BerkeleyDB_version_minor "${_BerkeleyDB_version_strings}")
string(REGEX REPLACE ".*#define[\t ]+DB_VERSION_PATCH[ \t]+([0-9]+).*" "\\1" _BerkeleyDB_version_patch "${_BerkeleyDB_version_strings}")
unset(_BerkeleyDB_version_strings)
# The MAJOR.MINOR.PATCH version will be logged in the following find_package_handle_standard_args() command.
set(_BerkeleyDB_full_version ${_BerkeleyDB_version_major}.${_BerkeleyDB_version_minor}.${_BerkeleyDB_version_patch})
set(BerkeleyDB_VERSION ${_BerkeleyDB_version_major}.${_BerkeleyDB_version_minor})
unset(_BerkeleyDB_version_major)
unset(_BerkeleyDB_version_minor)
unset(_BerkeleyDB_version_patch)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(BerkeleyDB
REQUIRED_VARS BerkeleyDB_LIBRARY BerkeleyDB_INCLUDE_DIR
VERSION_VAR _BerkeleyDB_full_version
)
unset(_BerkeleyDB_full_version)
if(BerkeleyDB_FOUND AND NOT TARGET BerkeleyDB::BerkeleyDB)
add_library(BerkeleyDB::BerkeleyDB UNKNOWN IMPORTED)
set_target_properties(BerkeleyDB::BerkeleyDB PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${BerkeleyDB_INCLUDE_DIR}"
)
if(BerkeleyDB_LIBRARY_RELEASE)
set_property(TARGET BerkeleyDB::BerkeleyDB APPEND PROPERTY
IMPORTED_CONFIGURATIONS RELEASE
)
set_target_properties(BerkeleyDB::BerkeleyDB PROPERTIES
IMPORTED_LOCATION_RELEASE "${BerkeleyDB_LIBRARY_RELEASE}"
)
endif()
if(BerkeleyDB_LIBRARY_DEBUG)
set_property(TARGET BerkeleyDB::BerkeleyDB APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(BerkeleyDB::BerkeleyDB PROPERTIES
IMPORTED_LOCATION_DEBUG "${BerkeleyDB_LIBRARY_DEBUG}"
)
endif()
endif()

View File

@ -21,16 +21,16 @@ endif()
find_path(QRencode_INCLUDE_DIR
NAMES qrencode.h
PATHS ${PC_QRencode_INCLUDE_DIRS}
HINTS ${PC_QRencode_INCLUDE_DIRS}
)
find_library(QRencode_LIBRARY_RELEASE
NAMES qrencode
PATHS ${PC_QRencode_LIBRARY_DIRS}
HINTS ${PC_QRencode_LIBRARY_DIRS}
)
find_library(QRencode_LIBRARY_DEBUG
NAMES qrencoded qrencode
PATHS ${PC_QRencode_LIBRARY_DIRS}
HINTS ${PC_QRencode_LIBRARY_DIRS}
)
include(SelectLibraryConfigurations)
select_library_configurations(QRencode)

View File

@ -27,19 +27,6 @@ if(CMAKE_HOST_APPLE)
endif()
endif()
# Save CMAKE_FIND_ROOT_PATH_MODE_LIBRARY state.
unset(_qt_find_root_path_mode_library_saved)
if(DEFINED CMAKE_FIND_ROOT_PATH_MODE_LIBRARY)
set(_qt_find_root_path_mode_library_saved ${CMAKE_FIND_ROOT_PATH_MODE_LIBRARY})
endif()
# The Qt config files internally use find_library() calls for all
# dependencies to ensure their availability. In turn, the find_library()
# inspects the well-known locations on the file system; therefore, it must
# be able to find platform-specific system libraries, for example:
# /usr/x86_64-w64-mingw32/lib/libm.a or /usr/arm-linux-gnueabihf/lib/libm.a.
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
find_package(Qt${Qt_FIND_VERSION_MAJOR} ${Qt_FIND_VERSION}
COMPONENTS ${Qt_FIND_COMPONENTS}
HINTS ${_qt_homebrew_prefix}
@ -47,14 +34,6 @@ find_package(Qt${Qt_FIND_VERSION_MAJOR} ${Qt_FIND_VERSION}
)
unset(_qt_homebrew_prefix)
# Restore CMAKE_FIND_ROOT_PATH_MODE_LIBRARY state.
if(DEFINED _qt_find_root_path_mode_library_saved)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ${_qt_find_root_path_mode_library_saved})
unset(_qt_find_root_path_mode_library_saved)
else()
unset(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Qt
REQUIRED_VARS Qt${Qt_FIND_VERSION_MAJOR}_DIR

View File

@ -36,6 +36,10 @@ if(USDT_INCLUDE_DIR)
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_INCLUDES ${USDT_INCLUDE_DIR})
check_cxx_source_compiles("
#if defined(__arm__)
# define STAP_SDT_ARG_CONSTRAINT g
#endif
// Setting SDT_USE_VARIADIC lets systemtap (sys/sdt.h) know that we want to use
// the optional variadic macros to define tracepoints.
#define SDT_USE_VARIADIC 1

View File

@ -7,6 +7,7 @@ function(generate_setup_nsi)
set(abs_top_builddir ${PROJECT_BINARY_DIR})
set(CLIENT_URL ${PROJECT_HOMEPAGE_URL})
set(CLIENT_TARNAME "bitcoin")
set(BITCOIN_WRAPPER_NAME "bitcoin")
set(BITCOIN_GUI_NAME "bitcoin-qt")
set(BITCOIN_DAEMON_NAME "bitcoind")
set(BITCOIN_CLI_NAME "bitcoin-cli")

View File

@ -7,14 +7,19 @@ include(GNUInstallDirs)
function(install_binary_component component)
cmake_parse_arguments(PARSE_ARGV 1
IC # prefix
"HAS_MANPAGE" # options
"" # one_value_keywords
"" # multi_value_keywords
IC # prefix
"HAS_MANPAGE;INTERNAL" # options
"" # one_value_keywords
"" # multi_value_keywords
)
set(target_name ${component})
if(IC_INTERNAL)
set(runtime_dest ${CMAKE_INSTALL_LIBEXECDIR})
else()
set(runtime_dest ${CMAKE_INSTALL_BINDIR})
endif()
install(TARGETS ${target_name}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
RUNTIME DESTINATION ${runtime_dest}
COMPONENT ${component}
)
if(INSTALL_MAN AND IC_HAS_MANPAGE)

View File

@ -19,11 +19,11 @@ function(setup_split_debug_script)
endfunction()
function(add_maintenance_targets)
if(NOT PYTHON_COMMAND)
if(NOT TARGET Python3::Interpreter)
return()
endif()
foreach(target IN ITEMS bitcoind bitcoin-qt bitcoin-cli bitcoin-tx bitcoin-util bitcoin-wallet test_bitcoin bench_bitcoin)
foreach(target IN ITEMS bitcoin bitcoind bitcoin-node bitcoin-qt bitcoin-gui bitcoin-cli bitcoin-tx bitcoin-util bitcoin-wallet test_bitcoin bench_bitcoin)
if(TARGET ${target})
list(APPEND executables $<TARGET_FILE:${target}>)
endif()
@ -31,19 +31,27 @@ function(add_maintenance_targets)
add_custom_target(check-symbols
COMMAND ${CMAKE_COMMAND} -E echo "Running symbol and dynamic library checks..."
COMMAND ${PYTHON_COMMAND} ${PROJECT_SOURCE_DIR}/contrib/devtools/symbol-check.py ${executables}
COMMAND Python3::Interpreter ${PROJECT_SOURCE_DIR}/contrib/guix/symbol-check.py ${executables}
VERBATIM
)
add_custom_target(check-security
COMMAND ${CMAKE_COMMAND} -E echo "Checking binary security..."
COMMAND ${PYTHON_COMMAND} ${PROJECT_SOURCE_DIR}/contrib/devtools/security-check.py ${executables}
COMMAND Python3::Interpreter ${PROJECT_SOURCE_DIR}/contrib/guix/security-check.py ${executables}
VERBATIM
)
endfunction()
function(add_windows_deploy_target)
if(MINGW AND TARGET bitcoin-qt AND TARGET bitcoind AND TARGET bitcoin-cli AND TARGET bitcoin-tx AND TARGET bitcoin-wallet AND TARGET bitcoin-util AND TARGET test_bitcoin)
if(MINGW AND TARGET bitcoin AND TARGET bitcoin-qt AND TARGET bitcoind AND TARGET bitcoin-cli AND TARGET bitcoin-tx AND TARGET bitcoin-wallet AND TARGET bitcoin-util AND TARGET test_bitcoin)
find_program(MAKENSIS_EXECUTABLE makensis)
if(NOT MAKENSIS_EXECUTABLE)
add_custom_target(deploy
COMMAND ${CMAKE_COMMAND} -E echo "Error: NSIS not found"
)
return()
endif()
# TODO: Consider replacing this code with the CPack NSIS Generator.
# See https://cmake.org/cmake/help/latest/cpack_gen/nsis.html
include(GenerateSetupNsi)
@ -51,6 +59,7 @@ function(add_windows_deploy_target)
add_custom_command(
OUTPUT ${PROJECT_BINARY_DIR}/bitcoin-win64-setup.exe
COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/release
COMMAND ${CMAKE_STRIP} $<TARGET_FILE:bitcoin> -o ${PROJECT_BINARY_DIR}/release/$<TARGET_FILE_NAME:bitcoin>
COMMAND ${CMAKE_STRIP} $<TARGET_FILE:bitcoin-qt> -o ${PROJECT_BINARY_DIR}/release/$<TARGET_FILE_NAME:bitcoin-qt>
COMMAND ${CMAKE_STRIP} $<TARGET_FILE:bitcoind> -o ${PROJECT_BINARY_DIR}/release/$<TARGET_FILE_NAME:bitcoind>
COMMAND ${CMAKE_STRIP} $<TARGET_FILE:bitcoin-cli> -o ${PROJECT_BINARY_DIR}/release/$<TARGET_FILE_NAME:bitcoin-cli>
@ -58,7 +67,7 @@ function(add_windows_deploy_target)
COMMAND ${CMAKE_STRIP} $<TARGET_FILE:bitcoin-wallet> -o ${PROJECT_BINARY_DIR}/release/$<TARGET_FILE_NAME:bitcoin-wallet>
COMMAND ${CMAKE_STRIP} $<TARGET_FILE:bitcoin-util> -o ${PROJECT_BINARY_DIR}/release/$<TARGET_FILE_NAME:bitcoin-util>
COMMAND ${CMAKE_STRIP} $<TARGET_FILE:test_bitcoin> -o ${PROJECT_BINARY_DIR}/release/$<TARGET_FILE_NAME:test_bitcoin>
COMMAND makensis -V2 ${PROJECT_BINARY_DIR}/bitcoin-win64-setup.nsi
COMMAND ${MAKENSIS_EXECUTABLE} -V2 ${PROJECT_BINARY_DIR}/bitcoin-win64-setup.nsi
VERBATIM
)
add_custom_target(deploy DEPENDS ${PROJECT_BINARY_DIR}/bitcoin-win64-setup.exe)
@ -83,27 +92,28 @@ function(add_macos_deploy_target)
COMMAND ${CMAKE_COMMAND} --install ${PROJECT_BINARY_DIR} --config $<CONFIG> --component bitcoin-qt --prefix ${macos_app}/Contents/MacOS --strip
COMMAND ${CMAKE_COMMAND} -E rename ${macos_app}/Contents/MacOS/bin/$<TARGET_FILE_NAME:bitcoin-qt> ${macos_app}/Contents/MacOS/Bitcoin-Qt
COMMAND ${CMAKE_COMMAND} -E rm -rf ${macos_app}/Contents/MacOS/bin
COMMAND ${CMAKE_COMMAND} -E rm -rf ${macos_app}/Contents/MacOS/share
VERBATIM
)
string(REPLACE " " "-" osx_volname ${CLIENT_NAME})
set(macos_zip "bitcoin-macos-app")
if(CMAKE_HOST_APPLE)
add_custom_command(
OUTPUT ${PROJECT_BINARY_DIR}/${osx_volname}.zip
COMMAND ${PYTHON_COMMAND} ${PROJECT_SOURCE_DIR}/contrib/macdeploy/macdeployqtplus ${macos_app} ${osx_volname} -translations-dir=${QT_TRANSLATIONS_DIR} -zip
OUTPUT ${PROJECT_BINARY_DIR}/${macos_zip}.zip
COMMAND Python3::Interpreter ${PROJECT_SOURCE_DIR}/contrib/macdeploy/macdeployqtplus ${macos_app} -translations-dir=${QT_TRANSLATIONS_DIR} -zip=${macos_zip}
DEPENDS ${PROJECT_BINARY_DIR}/${macos_app}/Contents/MacOS/Bitcoin-Qt
VERBATIM
)
add_custom_target(deploydir
DEPENDS ${PROJECT_BINARY_DIR}/${osx_volname}.zip
DEPENDS ${PROJECT_BINARY_DIR}/${macos_zip}.zip
)
add_custom_target(deploy
DEPENDS ${PROJECT_BINARY_DIR}/${osx_volname}.zip
DEPENDS ${PROJECT_BINARY_DIR}/${macos_zip}.zip
)
else()
add_custom_command(
OUTPUT ${PROJECT_BINARY_DIR}/dist/${macos_app}/Contents/MacOS/Bitcoin-Qt
COMMAND OBJDUMP=${CMAKE_OBJDUMP} ${PYTHON_COMMAND} ${PROJECT_SOURCE_DIR}/contrib/macdeploy/macdeployqtplus ${macos_app} ${osx_volname} -translations-dir=${QT_TRANSLATIONS_DIR}
COMMAND ${CMAKE_COMMAND} -E env OBJDUMP=${CMAKE_OBJDUMP} $<TARGET_FILE:Python3::Interpreter> ${PROJECT_SOURCE_DIR}/contrib/macdeploy/macdeployqtplus ${macos_app} -translations-dir=${QT_TRANSLATIONS_DIR}
DEPENDS ${PROJECT_BINARY_DIR}/${macos_app}/Contents/MacOS/Bitcoin-Qt
VERBATIM
)
@ -111,16 +121,22 @@ function(add_macos_deploy_target)
DEPENDS ${PROJECT_BINARY_DIR}/dist/${macos_app}/Contents/MacOS/Bitcoin-Qt
)
find_program(ZIP_COMMAND zip REQUIRED)
add_custom_command(
OUTPUT ${PROJECT_BINARY_DIR}/dist/${osx_volname}.zip
WORKING_DIRECTORY dist
COMMAND ${PROJECT_SOURCE_DIR}/cmake/script/macos_zip.sh ${ZIP_COMMAND} ${osx_volname}.zip
VERBATIM
)
add_custom_target(deploy
DEPENDS ${PROJECT_BINARY_DIR}/dist/${osx_volname}.zip
)
find_program(ZIP_EXECUTABLE zip)
if(NOT ZIP_EXECUTABLE)
add_custom_target(deploy
COMMAND ${CMAKE_COMMAND} -E echo "Error: ZIP not found"
)
else()
add_custom_command(
OUTPUT ${PROJECT_BINARY_DIR}/dist/${macos_zip}.zip
WORKING_DIRECTORY dist
COMMAND ${PROJECT_SOURCE_DIR}/cmake/script/macos_zip.sh ${ZIP_EXECUTABLE} ${macos_zip}.zip
VERBATIM
)
add_custom_target(deploy
DEPENDS ${PROJECT_BINARY_DIR}/dist/${macos_zip}.zip
)
endif()
endif()
add_dependencies(deploydir bitcoin-qt)
add_dependencies(deploy deploydir)

View File

@ -105,14 +105,13 @@ function(remove_cxx_flag_from_all_configs flag)
endfunction()
function(replace_cxx_flag_in_config config old_flag new_flag)
string(TOUPPER "${config}" config_uppercase)
string(REGEX REPLACE "(^| )${old_flag}( |$)" "\\1${new_flag}\\2" new_flags "${CMAKE_CXX_FLAGS_${config_uppercase}}")
set(CMAKE_CXX_FLAGS_${config_uppercase} "${new_flags}" PARENT_SCOPE)
set(CMAKE_CXX_FLAGS_${config_uppercase} "${new_flags}"
CACHE STRING
"Flags used by the CXX compiler during ${config_uppercase} builds."
FORCE
)
string(TOUPPER "CMAKE_CXX_FLAGS_${config}" var_name)
if("${var_name}" IN_LIST precious_variables)
return()
endif()
string(REGEX REPLACE "(^| )${old_flag}( |$)" "\\1${new_flag}\\2" ${var_name} "${${var_name}}")
set(${var_name} "${${var_name}}" PARENT_SCOPE)
set_property(CACHE ${var_name} PROPERTY VALUE "${${var_name}}")
endfunction()
set_default_config(RelWithDebInfo)

View File

@ -38,8 +38,7 @@ function(test_append_socket_library target)
message(FATAL_ERROR "Cannot figure out how to use getifaddrs/freeifaddrs.")
endif()
endif()
set(HAVE_DECL_GETIFADDRS TRUE PARENT_SCOPE)
set(HAVE_DECL_FREEIFADDRS TRUE PARENT_SCOPE)
set(HAVE_IFADDRS TRUE PARENT_SCOPE)
endfunction()
# Clang, when building for 32-bit,

View File

@ -20,7 +20,7 @@ In configuration output, this function prints a string by the following pattern:
function(try_append_linker_flag flag)
cmake_parse_arguments(PARSE_ARGV 1
TALF # prefix
"" # options
"NO_CACHE_IF_FAILED" # options
"TARGET;VAR;SOURCE;RESULT_VAR" # one_value_keywords
"IF_CHECK_PASSED" # multi_value_keywords
)
@ -68,6 +68,10 @@ function(try_append_linker_flag flag)
if(DEFINED TALF_RESULT_VAR)
set(${TALF_RESULT_VAR} "${${result}}" PARENT_SCOPE)
endif()
if(NOT ${result} AND TALF_NO_CACHE_IF_FAILED)
unset(${result} CACHE)
endif()
endfunction()
if(MSVC)

52
cmake/secp256k1.cmake Normal file
View File

@ -0,0 +1,52 @@
# Copyright (c) 2023-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://opensource.org/license/mit/.
enable_language(C)
function(add_secp256k1 subdir)
message("")
message("Configuring secp256k1 subtree...")
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS OFF)
set(SECP256K1_ENABLE_MODULE_ECDH OFF CACHE BOOL "" FORCE)
set(SECP256K1_ENABLE_MODULE_RECOVERY ON CACHE BOOL "" FORCE)
set(SECP256K1_ENABLE_MODULE_MUSIG ON CACHE BOOL "" FORCE)
set(SECP256K1_BUILD_BENCHMARK OFF CACHE BOOL "" FORCE)
set(SECP256K1_BUILD_TESTS ${BUILD_TESTS} CACHE BOOL "" FORCE)
set(SECP256K1_BUILD_EXHAUSTIVE_TESTS ${BUILD_TESTS} CACHE BOOL "" FORCE)
if(NOT BUILD_TESTS)
# Always skip the ctime tests, if we are building no other tests.
# Otherwise, they are built if Valgrind is available. See SECP256K1_VALGRIND.
set(SECP256K1_BUILD_CTIME_TESTS ${BUILD_TESTS} CACHE BOOL "" FORCE)
endif()
set(SECP256K1_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
include(GetTargetInterface)
# -fsanitize and related flags apply to both C++ and C,
# so we can pass them down to libsecp256k1 as CFLAGS and LDFLAGS.
get_target_interface(SECP256K1_APPEND_CFLAGS "" sanitize_interface COMPILE_OPTIONS)
string(STRIP "${SECP256K1_APPEND_CFLAGS} ${APPEND_CPPFLAGS}" SECP256K1_APPEND_CFLAGS)
string(STRIP "${SECP256K1_APPEND_CFLAGS} ${APPEND_CFLAGS}" SECP256K1_APPEND_CFLAGS)
set(SECP256K1_APPEND_CFLAGS ${SECP256K1_APPEND_CFLAGS} CACHE STRING "" FORCE)
get_target_interface(SECP256K1_APPEND_LDFLAGS "" sanitize_interface LINK_OPTIONS)
string(STRIP "${SECP256K1_APPEND_LDFLAGS} ${APPEND_LDFLAGS}" SECP256K1_APPEND_LDFLAGS)
set(SECP256K1_APPEND_LDFLAGS ${SECP256K1_APPEND_LDFLAGS} CACHE STRING "" FORCE)
# We want to build libsecp256k1 with the most tested RelWithDebInfo configuration.
foreach(config IN LISTS CMAKE_BUILD_TYPE CMAKE_CONFIGURATION_TYPES)
if(config STREQUAL "")
continue()
endif()
string(TOUPPER "${config}" config)
set(CMAKE_C_FLAGS_${config} "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
endforeach()
# If the CFLAGS environment variable is defined during building depends
# and configuring this build system, its content might be duplicated.
if(DEFINED ENV{CFLAGS})
deduplicate_flags(CMAKE_C_FLAGS)
endif()
add_subdirectory(${subdir})
set_target_properties(secp256k1 PROPERTIES
EXCLUDE_FROM_ALL TRUE
)
endfunction()

View File

@ -1,15 +0,0 @@
# Copyright (c) 2023-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://opensource.org/license/mit/.
if(TARGET bitcoin-util AND TARGET bitcoin-tx AND PYTHON_COMMAND)
add_test(NAME util_test_runner
COMMAND ${CMAKE_COMMAND} -E env BITCOINUTIL=$<TARGET_FILE:bitcoin-util> BITCOINTX=$<TARGET_FILE:bitcoin-tx> ${PYTHON_COMMAND} ${PROJECT_BINARY_DIR}/test/util/test_runner.py
)
endif()
if(PYTHON_COMMAND)
add_test(NAME util_rpcauth_test
COMMAND ${PYTHON_COMMAND} ${PROJECT_BINARY_DIR}/test/util/rpcauth-test.py
)
endif()

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
type="win32"
name="org.bitcoincore.${target}"
version="${CLIENT_VERSION_MAJOR}.${CLIENT_VERSION_MINOR}.${CLIENT_VERSION_BUILD}.0"
/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

View File

@ -9,4 +9,75 @@ Example usage:
python3 asmap-tool.py encode /path/to/input.file /path/to/output.file
python3 asmap-tool.py decode /path/to/input.file /path/to/output.file
python3 asmap-tool.py diff /path/to/first.file /path/to/second.file
python3 asmap-tool.py diff_addrs /path/to/first.file /path/to/second.file addrs.file
```
These commands may take a few minutes to run with `python3`,
depending on the amount of data involved and your machine specs.
Consider using `pypy3` for a faster run time.
### Encoding and Decoding
ASmap files are somewhat large in text form, and need to be encoded
to binary before being used with Bitcoin Core.
The `encode` command takes an ASmap and an output file.
The `--fill`/`-f` flag further reduces the size of the output file
by assuming an AS assignment for an unmapped network if an adjacent network is assigned.
This procedure is lossy, in the sense that it loses information
about which ranges were unassigned.
However, if the input ASmap is incomplete,
this procedure will also reassign ranges that should have an AS assignment,
resulting in an ASmap that may diverge from reality significantly.
Finally, another consequence is that the resulting encoded file
will no longer be meaningful for diffs.
Therefore only use `--fill` if
you want to optimise space, you have a reasonably complete ASmap,
and do not intend to diff the file at a later time.
The `decode` command takes an encoded ASmap and an output file.
As with `encode`, the `--fill`/`-f` flag reduces the output file size
by reassigning subnets. Conversely, the `--non-overlapping`/`-n` flag
increases output size by outputting strictly non-overlapping network ranges.
### Comparing ASmaps
AS control of IP networks changes frequently, therefore it can be useful to get
the changes between two ASmaps via the `diff` and `diff_addrs` commands.
`diff` takes two ASmap files, and returns a file detailing the changes
in the state of a network's AS assignment between the first and the second file.
This command may take a few minutes to run, depending on your machine.
The example below shows the three possible output states:
- reassigned to a new AS (`AS26496 # was AS20738`),
- present in the first but not the second (`# 220.157.65.0/24 was AS9723`),
- or present in the second but not the first (`# was unassigned`).
```
217.199.160.0/19 AS26496 # was AS20738
# 220.157.65.0/24 was AS9723
216.151.172.0/23 AS400080 # was unassigned
2001:470:49::/48 AS20205 # was AS6939
# 2001:678:bd0::/48 was AS207631
2001:67c:308::/48 AS26496 # was unassigned
```
`diff` accepts a `--ignore-unassigned`/`-i` flag
which ignores networks present in the second but not the first.
`diff_addrs` is intended to provide changes between two ASmaps and
a node's known peers.
The command takes two ASmap files, and a file of IP addresses as output by
the `bitcoin-cli getnodeaddresses` command.
It returns the changes between the two ASmaps for the peer IPs provided in
the `getnodeaddresses` output.
The resulting file is in the same format as the `diff` command shown above.
You can output address data to a file:
```
bitcoin-cli getnodeaddresses 0 > addrs.json
```
and pass in the address file as the third argument:
```
python3 asmap-tool.py diff_addrs path/to/first.file path/to/second.file addrs.json
```

View File

@ -39,7 +39,7 @@ _bitcoin_cli() {
if ((cword > 4)); then
case ${words[cword-4]} in
importaddress|listtransactions|setban)
listtransactions|setban)
COMPREPLY=( $( compgen -W "true false" -- "$cur" ) )
return 0
;;
@ -52,10 +52,7 @@ _bitcoin_cli() {
if ((cword > 3)); then
case ${words[cword-3]} in
addmultisigaddress)
return 0
;;
getbalance|gettxout|importaddress|importpubkey|importprivkey|listreceivedbyaddress|listsinceblock)
getbalance|gettxout|listreceivedbyaddress|listsinceblock)
COMPREPLY=( $( compgen -W "true false" -- "$cur" ) )
return 0
;;
@ -80,7 +77,7 @@ _bitcoin_cli() {
fi
case "$prev" in
backupwallet|dumpwallet|importwallet)
backupwallet)
_filedir
return 0
;;

View File

@ -121,17 +121,6 @@ Comment:
You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
License: GPL-3+
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU General Public License, Version 3 or any
later version published by the Free Software Foundation.
Comment:
On Debian systems the GNU General Public License (GPL) version 3 is
located in '/usr/share/common-licenses/GPL-3'.
.
You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
License: public-domain
This work is in the public domain.

View File

@ -8,18 +8,42 @@ deterministic-fuzz-coverage
A tool to check for non-determinism in fuzz coverage. To get the help, run:
```
RUST_BACKTRACE=1 cargo run --manifest-path ./contrib/devtools/deterministic-fuzz-coverage/Cargo.toml -- --help
cargo run --manifest-path ./contrib/devtools/deterministic-fuzz-coverage/Cargo.toml -- --help
```
To execute the tool, compilation has to be done with the build options
`-DCMAKE_C_COMPILER='clang' -DCMAKE_CXX_COMPILER='clang++'
-DBUILD_FOR_FUZZING=ON -DCMAKE_CXX_FLAGS='-fPIC -fprofile-instr-generate
-fcoverage-mapping'`. Both llvm-profdata and llvm-cov must be installed. Also,
the qa-assets repository must have been cloned. Finally, a fuzz target has to
be picked before running the tool:
To execute the tool, compilation has to be done with the build options:
```
RUST_BACKTRACE=1 cargo run --manifest-path ./contrib/devtools/deterministic-fuzz-coverage/Cargo.toml -- $PWD/build_dir $PWD/qa-assets/corpora-dir fuzz_target_name
-DCMAKE_C_COMPILER='clang' -DCMAKE_CXX_COMPILER='clang++' -DBUILD_FOR_FUZZING=ON -DCMAKE_CXX_FLAGS='-fprofile-instr-generate -fcoverage-mapping'
```
Both llvm-profdata and llvm-cov must be installed. Also, the qa-assets
repository must have been cloned. Finally, a fuzz target has to be picked
before running the tool:
```
cargo run --manifest-path ./contrib/devtools/deterministic-fuzz-coverage/Cargo.toml -- $PWD/build_dir $PWD/qa-assets/fuzz_corpora fuzz_target_name
```
deterministic-unittest-coverage
===========================
A tool to check for non-determinism in unit-test coverage. To get the help, run:
```
cargo run --manifest-path ./contrib/devtools/deterministic-unittest-coverage/Cargo.toml -- --help
```
To execute the tool, compilation has to be done with the build options:
```
-DCMAKE_C_COMPILER='clang' -DCMAKE_CXX_COMPILER='clang++' -DCMAKE_CXX_FLAGS='-fprofile-instr-generate -fcoverage-mapping'
```
Both llvm-profdata and llvm-cov must be installed.
```
cargo run --manifest-path ./contrib/devtools/deterministic-unittest-coverage/Cargo.toml -- $PWD/build_dir <boost unittest filter>
```
clang-format-diff.py
@ -135,35 +159,6 @@ For example:
BUILDDIR=$PWD/my-build-dir contrib/devtools/gen-bitcoin-conf.sh
```
security-check.py
=================
Perform basic security checks on a series of executables.
symbol-check.py
===============
A script to check that release executables only contain
certain symbols and are only linked against allowed libraries.
For Linux this means checking for allowed gcc, glibc and libstdc++ version symbols.
This makes sure they are still compatible with the minimum supported distribution versions.
For macOS and Windows we check that the executables are only linked against libraries we allow.
Example usage:
find ../path/to/executables -type f -executable | xargs python3 contrib/devtools/symbol-check.py
If no errors occur the return value will be 0 and the output will be empty.
If there are any errors the return value will be 1 and output like this will be printed:
.../64/test_bitcoin: symbol memcpy from unsupported version GLIBC_2.14
.../64/test_bitcoin: symbol __fdelt_chk from unsupported version GLIBC_2.15
.../64/test_bitcoin: symbol std::out_of_range::~out_of_range() from unsupported version GLIBCXX_3.4.15
.../64/test_bitcoin: symbol _ZNSt8__detail15_List_nod from unsupported version GLIBCXX_3.4.15
circular-dependencies.py
========================

View File

@ -41,9 +41,6 @@ ALLOWED_DEPENDENCIES+=(
# Declare list of known errors that should be suppressed.
declare -A SUPPRESS
# init.cpp file currently calls Berkeley DB sanity check function on startup, so
# there is an undocumented dependency of the node library on the wallet library.
SUPPRESS["init.cpp.o bdb.cpp.o _ZN6wallet27BerkeleyDatabaseSanityCheckEv"]=1
# init/common.cpp file calls InitError and InitWarning from interface_ui which
# is currently part of the node library. interface_ui should just be part of the
# common library instead, and is moved in

View File

@ -22,7 +22,6 @@ EXCLUDE = [
'src/test/fuzz/FuzzedDataProvider.h',
'src/tinyformat.h',
'src/bench/nanobench.h',
'test/functional/test_framework/bignum.py',
# python init:
'*__init__.py',
]
@ -94,7 +93,6 @@ EXPECTED_HOLDER_NAMES = [
r"Satoshi Nakamoto",
r"The Bitcoin Core developers",
r"BitPay Inc\.",
r"University of Illinois at Urbana-Champaign\.",
r"Pieter Wuille",
r"Wladimir J\. van der Laan",
r"Jeff Garzik",

View File

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "deterministic-fuzz-coverage"
version = "0.1.0"

View File

@ -2,89 +2,102 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://opensource.org/license/mit/.
use std::collections::VecDeque;
use std::env;
use std::fs::{read_dir, File};
use std::path::Path;
use std::process::{exit, Command, Stdio};
use std::fs::{read_dir, DirEntry, File};
use std::path::{Path, PathBuf};
use std::process::{Command, ExitCode};
use std::str;
use std::thread;
/// A type for a complete and readable error message.
type AppError = String;
type AppResult = Result<(), AppError>;
const LLVM_PROFDATA: &str = "llvm-profdata";
const LLVM_COV: &str = "llvm-cov";
const DIFF: &str = "diff";
const GIT: &str = "git";
fn exit_help(err: &str) -> ! {
eprintln!("Error: {}", err);
eprintln!();
eprintln!("Usage: program ./build_dir ./qa-assets-corpora-dir fuzz_target");
eprintln!();
eprintln!("Refer to the devtools/README.md for more details.");
exit(1)
const DEFAULT_PAR: usize = 1;
fn exit_help(err: &str) -> AppError {
format!(
r#"
Error: {err}
Usage: program ./build_dir ./qa-assets/fuzz_corpora fuzz_target_name [parallelism={DEFAULT_PAR}]
Refer to the devtools/README.md for more details."#
)
}
fn sanity_check(corpora_dir: &Path, fuzz_exe: &Path) {
for tool in [LLVM_PROFDATA, LLVM_COV, DIFF] {
let output = Command::new(tool).arg("--version").output();
fn sanity_check(corpora_dir: &Path, fuzz_exe: &Path) -> AppResult {
for tool in [LLVM_PROFDATA, LLVM_COV, GIT] {
let output = Command::new(tool).arg("--help").output();
match output {
Ok(output) if output.status.success() => {}
_ => {
exit_help(&format!("The tool {} is not installed", tool));
}
_ => Err(exit_help(&format!("The tool {} is not installed", tool)))?,
}
}
if !corpora_dir.is_dir() {
exit_help(&format!(
Err(exit_help(&format!(
"Fuzz corpora path ({}) must be a directory",
corpora_dir.display()
));
)))?;
}
if !fuzz_exe.exists() {
exit_help(&format!(
Err(exit_help(&format!(
"Fuzz executable ({}) not found",
fuzz_exe.display()
));
)))?;
}
Ok(())
}
fn main() {
fn app() -> AppResult {
// Parse args
let args = env::args().collect::<Vec<_>>();
let build_dir = args
.get(1)
.unwrap_or_else(|| exit_help("Must set build dir"));
let build_dir = args.get(1).ok_or(exit_help("Must set build dir"))?;
if build_dir == "--help" {
exit_help("--help requested")
Err(exit_help("--help requested"))?;
}
let corpora_dir = args
.get(2)
.unwrap_or_else(|| exit_help("Must set fuzz corpora dir"));
let corpora_dir = args.get(2).ok_or(exit_help("Must set fuzz corpora dir"))?;
let fuzz_target = args
.get(3)
// Require fuzz target for now. In the future it could be optional and the tool could
// iterate over all compiled fuzz targets
.unwrap_or_else(|| exit_help("Must set fuzz target"));
if args.get(4).is_some() {
exit_help("Too many args")
.ok_or(exit_help("Must set fuzz target"))?;
let par = match args.get(4) {
Some(s) => s
.parse::<usize>()
.map_err(|e| exit_help(&format!("Could not parse parallelism as usize ({s}): {e}")))?,
None => DEFAULT_PAR,
}
.max(1);
if args.get(5).is_some() {
Err(exit_help("Too many args"))?;
}
let build_dir = Path::new(build_dir);
let corpora_dir = Path::new(corpora_dir);
let fuzz_exe = build_dir.join("src/test/fuzz/fuzz");
let fuzz_exe = build_dir.join("bin/fuzz");
sanity_check(corpora_dir, &fuzz_exe);
sanity_check(corpora_dir, &fuzz_exe)?;
deterministic_coverage(build_dir, corpora_dir, &fuzz_exe, fuzz_target);
deterministic_coverage(build_dir, corpora_dir, &fuzz_exe, fuzz_target, par)
}
fn using_libfuzzer(fuzz_exe: &Path) -> bool {
fn using_libfuzzer(fuzz_exe: &Path) -> Result<bool, AppError> {
println!("Check if using libFuzzer ...");
let stderr = Command::new(fuzz_exe)
.arg("-help=1") // Will be interpreted as option (libfuzzer) or as input file
.env("FUZZ", "addition_overflow") // Any valid target
.output()
.expect("fuzz failed")
.map_err(|e| format!("fuzz failed with {e}"))?
.stderr;
let help_output = str::from_utf8(&stderr).expect("The -help=1 output must be valid text");
help_output.contains("libFuzzer")
let help_output = str::from_utf8(&stderr)
.map_err(|e| format!("The libFuzzer -help=1 output must be valid text ({e})"))?;
Ok(help_output.contains("libFuzzer"))
}
fn deterministic_coverage(
@ -92,115 +105,177 @@ fn deterministic_coverage(
corpora_dir: &Path,
fuzz_exe: &Path,
fuzz_target: &str,
) {
let using_libfuzzer = using_libfuzzer(fuzz_exe);
let profraw_file = build_dir.join("fuzz_det_cov.profraw");
let profdata_file = build_dir.join("fuzz_det_cov.profdata");
par: usize,
) -> AppResult {
let using_libfuzzer = using_libfuzzer(fuzz_exe)?;
if using_libfuzzer {
println!("Warning: The fuzz executable was compiled with libFuzzer as sanitizer.");
println!("This tool may be tripped by libFuzzer misbehavior.");
println!("It is recommended to compile without libFuzzer.");
}
let corpus_dir = corpora_dir.join(fuzz_target);
let mut entries = read_dir(&corpus_dir)
.unwrap_or_else(|err| {
.map_err(|err| {
exit_help(&format!(
"The fuzz target's input directory must exist! ({}; {})",
corpus_dir.display(),
err
))
})
})?
.map(|entry| entry.expect("IO error"))
.collect::<Vec<_>>();
entries.sort_by_key(|entry| entry.file_name());
let run_single = |run_id: u8, entry: &Path| {
let cov_txt_path = build_dir.join(format!("fuzz_det_cov.show.{run_id}.txt"));
assert!({
{
let run_single = |run_id: char, entry: &Path, thread_id: usize| -> Result<PathBuf, AppError> {
let cov_txt_path = build_dir.join(format!("fuzz_det_cov.show.t{thread_id}.{run_id}.txt"));
let profraw_file = build_dir.join(format!("fuzz_det_cov.t{thread_id}.{run_id}.profraw"));
let profdata_file = build_dir.join(format!("fuzz_det_cov.t{thread_id}.{run_id}.profdata"));
{
let output = {
let mut cmd = Command::new(fuzz_exe);
if using_libfuzzer {
cmd.arg("-runs=1");
cmd.args(["-runs=1", "-shuffle=1", "-prefer_small=0"]);
}
cmd
}
.env("LLVM_PROFILE_FILE", &profraw_file)
.env("FUZZ", fuzz_target)
.arg(entry)
.status()
.expect("fuzz failed")
.success()
});
assert!(Command::new(LLVM_PROFDATA)
.output()
.map_err(|e| format!("fuzz failed: {e}"))?;
if !output.status.success() {
Err(format!(
"fuzz failed!\nstdout:\n{}\nstderr:\n{}\n",
String::from_utf8_lossy(&output.stdout),
String::from_utf8_lossy(&output.stderr)
))?;
}
}
if !Command::new(LLVM_PROFDATA)
.arg("merge")
.arg("--sparse")
.arg(&profraw_file)
.arg("-o")
.arg(&profdata_file)
.status()
.expect("merge failed")
.success());
let cov_file = File::create(&cov_txt_path).expect("Failed to create coverage txt file");
let passed = Command::new(LLVM_COV)
.map_err(|e| format!("{LLVM_PROFDATA} merge failed with {e}"))?
.success()
{
Err(format!("{LLVM_PROFDATA} merge failed. This can be a sign of compiling without code coverage support."))?;
}
let cov_file = File::create(&cov_txt_path)
.map_err(|e| format!("Failed to create coverage txt file ({e})"))?;
if !Command::new(LLVM_COV)
.args([
"show",
"--show-line-counts-or-regions",
"--show-branches=count",
"--show-expansions",
"--show-instantiation-summary",
"-Xdemangler=llvm-cxxfilt",
&format!("--instr-profile={}", profdata_file.display()),
])
.arg(fuzz_exe)
.stdout(Stdio::from(cov_file))
.stdout(cov_file)
.spawn()
.expect("Failed to execute llvm-cov")
.map_err(|e| format!("{LLVM_COV} show failed with {e}"))?
.wait()
.expect("Failed to execute llvm-cov")
.success();
if !passed {
panic!("Failed to execute llvm-profdata")
}
cov_txt_path
.map_err(|e| format!("{LLVM_COV} show failed with {e}"))?
.success()
{
Err(format!("{LLVM_COV} show failed"))?;
};
Ok(cov_txt_path)
};
let check_diff = |a: &Path, b: &Path, err: &str| {
let same = Command::new(DIFF)
.arg("--unified")
let check_diff = |a: &Path, b: &Path, err: &str| -> AppResult {
let same = Command::new(GIT)
.args(["--no-pager", "diff", "--no-index"])
.arg(a)
.arg(b)
.status()
.expect("Failed to execute diff command")
.map_err(|e| format!("{GIT} diff failed with {e}"))?
.success();
if !same {
eprintln!();
eprintln!("The coverage was not determinstic between runs.");
eprintln!("{}", err);
eprintln!("Exiting.");
exit(1);
Err(format!(
r#"
The coverage was not deterministic between runs.
{err}"#
))?;
}
Ok(())
};
// First, check that each fuzz input is determinisic running by itself in a process.
// First, check that each fuzz input is deterministic running by itself in a process.
//
// This can catch issues and isolate where a single fuzz input triggers non-determinism, but
// all other fuzz inputs are deterministic.
//
// Also, This can catch issues where several fuzz inputs are non-deterministic, but the sum of
// their overall coverage trace remains the same across runs and thus remains undetected.
for entry in entries {
println!(
"Check each fuzz input individually ... ({} inputs with parallelism {par})",
entries.len()
);
let check_individual = |entry: &DirEntry, thread_id: usize| -> AppResult {
let entry = entry.path();
assert!(entry.is_file());
let cov_txt_base = run_single(0, &entry);
let cov_txt_repeat = run_single(1, &entry);
if !entry.is_file() {
Err(format!("{} should be a file", entry.display()))?;
}
let cov_txt_base = run_single('a', &entry, thread_id)?;
let cov_txt_repeat = run_single('b', &entry, thread_id)?;
check_diff(
&cov_txt_base,
&cov_txt_repeat,
&format!("The fuzz target input was {}.", entry.display()),
);
}
)?;
Ok(())
};
thread::scope(|s| -> AppResult {
let mut handles = VecDeque::with_capacity(par);
let mut res = Ok(());
for (i, entry) in entries.iter().enumerate() {
println!("[{}/{}]", i + 1, entries.len());
handles.push_back(s.spawn(move || check_individual(entry, i % par)));
while handles.len() >= par || i == (entries.len() - 1) || res.is_err() {
if let Some(th) = handles.pop_front() {
let thread_result = match th.join() {
Err(_e) => Err("A scoped thread panicked".to_string()),
Ok(r) => r,
};
if thread_result.is_err() {
res = thread_result;
}
} else {
return res;
}
}
}
res
})?;
// Finally, check that running over all fuzz inputs in one process is deterministic as well.
// This can catch issues where mutable global state is leaked from one fuzz input execution to
// the next.
println!("Check all fuzz inputs in one go ...");
{
assert!(corpus_dir.is_dir());
let cov_txt_base = run_single(0, &corpus_dir);
let cov_txt_repeat = run_single(1, &corpus_dir);
if !corpus_dir.is_dir() {
Err(format!("{} should be a folder", corpus_dir.display()))?;
}
let cov_txt_base = run_single('a', &corpus_dir, 0)?;
let cov_txt_repeat = run_single('b', &corpus_dir, 0)?;
check_diff(
&cov_txt_base,
&cov_txt_repeat,
&format!("All fuzz inputs in {} were used.", corpus_dir.display()),
);
)?;
}
println!("✨ Coverage test passed for {fuzz_target}. ✨");
Ok(())
}
fn main() -> ExitCode {
match app() {
Ok(()) => ExitCode::SUCCESS,
Err(err) => {
eprintln!("⚠️\n{}", err);
ExitCode::FAILURE
}
}
println!("Coverage test passed for {fuzz_target}.");
}

View File

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "deterministic-unittest-coverage"
version = "0.1.0"

View File

@ -0,0 +1,6 @@
[package]
name = "deterministic-unittest-coverage"
version = "0.1.0"
edition = "2021"
[dependencies]

View File

@ -0,0 +1,149 @@
// Copyright (c) The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://opensource.org/license/mit/.
use std::env;
use std::fs::File;
use std::path::{Path, PathBuf};
use std::process::{Command, ExitCode};
use std::str;
/// A type for a complete and readable error message.
type AppError = String;
type AppResult = Result<(), AppError>;
const LLVM_PROFDATA: &str = "llvm-profdata";
const LLVM_COV: &str = "llvm-cov";
const GIT: &str = "git";
fn exit_help(err: &str) -> AppError {
format!(
r#"
Error: {err}
Usage: program ./build_dir boost_unittest_filter
Refer to the devtools/README.md for more details."#
)
}
fn sanity_check(test_exe: &Path) -> AppResult {
for tool in [LLVM_PROFDATA, LLVM_COV, GIT] {
let output = Command::new(tool).arg("--help").output();
match output {
Ok(output) if output.status.success() => {}
_ => Err(exit_help(&format!("The tool {} is not installed", tool)))?,
}
}
if !test_exe.exists() {
Err(exit_help(&format!(
"Test executable ({}) not found",
test_exe.display()
)))?;
}
Ok(())
}
fn app() -> AppResult {
// Parse args
let args = env::args().collect::<Vec<_>>();
let build_dir = args.get(1).ok_or(exit_help("Must set build dir"))?;
if build_dir == "--help" {
Err(exit_help("--help requested"))?;
}
let filter = args
.get(2)
// Require filter for now. In the future it could be optional and the tool could provide a
// default filter.
.ok_or(exit_help("Must set boost test filter"))?;
if args.get(3).is_some() {
Err(exit_help("Too many args"))?;
}
let build_dir = Path::new(build_dir);
let test_exe = build_dir.join("bin/test_bitcoin");
sanity_check(&test_exe)?;
deterministic_coverage(build_dir, &test_exe, filter)
}
fn deterministic_coverage(build_dir: &Path, test_exe: &Path, filter: &str) -> AppResult {
let profraw_file = build_dir.join("test_det_cov.profraw");
let profdata_file = build_dir.join("test_det_cov.profdata");
let run_single = |run_id: char| -> Result<PathBuf, AppError> {
println!("Run with id {run_id}");
let cov_txt_path = build_dir.join(format!("test_det_cov.show.{run_id}.txt"));
if !Command::new(test_exe)
.env("LLVM_PROFILE_FILE", &profraw_file)
.env("BOOST_TEST_RUN_FILTERS", filter)
.env("RANDOM_CTX_SEED", "21")
.status()
.map_err(|e| format!("test failed with {e}"))?
.success()
{
Err("test failed".to_string())?;
}
if !Command::new(LLVM_PROFDATA)
.arg("merge")
.arg("--sparse")
.arg(&profraw_file)
.arg("-o")
.arg(&profdata_file)
.status()
.map_err(|e| format!("{LLVM_PROFDATA} merge failed with {e}"))?
.success()
{
Err(format!("{LLVM_PROFDATA} merge failed. This can be a sign of compiling without code coverage support."))?;
}
let cov_file = File::create(&cov_txt_path)
.map_err(|e| format!("Failed to create coverage txt file ({e})"))?;
if !Command::new(LLVM_COV)
.args([
"show",
"--show-line-counts-or-regions",
"--show-branches=count",
"--show-expansions",
"--show-instantiation-summary",
"-Xdemangler=llvm-cxxfilt",
&format!("--instr-profile={}", profdata_file.display()),
])
.arg(test_exe)
.stdout(cov_file)
.status()
.map_err(|e| format!("{LLVM_COV} show failed with {e}"))?
.success()
{
Err(format!("{LLVM_COV} show failed"))?;
}
Ok(cov_txt_path)
};
let check_diff = |a: &Path, b: &Path| -> AppResult {
let same = Command::new(GIT)
.args(["--no-pager", "diff", "--no-index"])
.arg(a)
.arg(b)
.status()
.map_err(|e| format!("{GIT} diff failed with {e}"))?
.success();
if !same {
Err("The coverage was not deterministic between runs.".to_string())?;
}
Ok(())
};
let r0 = run_single('a')?;
let r1 = run_single('b')?;
check_diff(&r0, &r1)?;
println!("✨ The coverage was deterministic across two runs. ✨");
Ok(())
}
fn main() -> ExitCode {
match app() {
Ok(()) => ExitCode::SUCCESS,
Err(err) => {
eprintln!("⚠️\n{}", err);
ExitCode::FAILURE
}
}
}

View File

@ -50,7 +50,8 @@ EOF
# adding newlines is a bit funky to ensure portability for BSD
# see here for more details: https://stackoverflow.com/a/24575385
${BITCOIND} --help \
| sed '1,/Print this help message and exit/d' \
| sed '1,/Options:/d' \
| sed -E '/^[[:space:]]{2}-help/,/^[[:space:]]*$/d' \
| sed -E 's/^[[:space:]]{2}\-/#/' \
| sed -E 's/^[[:space:]]{7}/# /' \
| sed -E '/[=[:space:]]/!s/#.*$/&=1/' \

View File

@ -9,6 +9,7 @@ import tempfile
import argparse
BINARIES = [
'bin/bitcoin',
'bin/bitcoind',
'bin/bitcoin-cli',
'bin/bitcoin-tx',

View File

@ -12,13 +12,13 @@ import random
# Parameters:
# Aim for still working fine at some point in the future. [datetime]
TIME = datetime(2027, 10, 6)
TIME = datetime(2028, 4, 2)
# Expected block interval. [timedelta]
BLOCK_INTERVAL = timedelta(seconds=600)
# The number of headers corresponding to the minchainwork parameter. [headers]
MINCHAINWORK_HEADERS = 886157
MINCHAINWORK_HEADERS = 912683
# Combined processing bandwidth from all attackers to one victim. [bit/s]
# 6 Gbit/s is approximately the speed at which a single thread of a Ryzen 5950X CPU thread can hash

View File

@ -1,151 +0,0 @@
#!/usr/bin/env bash
#
# Copyright (c) 2019-2020 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Test for deterministic coverage across unit test runs.
export LC_ALL=C
# Use GCOV_EXECUTABLE="gcov" if compiling with gcc.
# Use GCOV_EXECUTABLE="llvm-cov gcov" if compiling with clang.
GCOV_EXECUTABLE="gcov"
# Disable tests known to cause non-deterministic behaviour and document the source or point of non-determinism.
NON_DETERMINISTIC_TESTS=(
"blockfilter_index_tests/blockfilter_index_initial_sync" # src/checkqueue.h: In CCheckQueue::Loop(): while (queue.empty()) { ... }
"coinselector_tests/knapsack_solver_test" # coinselector_tests.cpp: if (equal_sets(setCoinsRet, setCoinsRet2))
"fs_tests/fsbridge_fstream" # deterministic test failure?
"miner_tests/CreateNewBlock_validity" # validation.cpp: if (signals.CallbacksPending() > 10)
"scheduler_tests/manythreads" # scheduler.cpp: CScheduler::serviceQueue()
"scheduler_tests/singlethreadedscheduler_ordered" # scheduler.cpp: CScheduler::serviceQueue()
"txvalidationcache_tests/checkinputs_test" # validation.cpp: if (signals.CallbacksPending() > 10)
"txvalidationcache_tests/tx_mempool_block_doublespend" # validation.cpp: if (signals.CallbacksPending() > 10)
"txindex_tests/txindex_initial_sync" # validation.cpp: if (signals.CallbacksPending() > 10)
"txvalidation_tests/tx_mempool_reject_coinbase" # validation.cpp: if (signals.CallbacksPending() > 10)
"validation_block_tests/processnewblock_signals_ordering" # validation.cpp: if (signals.CallbacksPending() > 10)
"wallet_tests/coin_mark_dirty_immature_credit" # validation.cpp: if (signals.CallbacksPending() > 10)
"wallet_tests/dummy_input_size_test" # validation.cpp: if (signals.CallbacksPending() > 10)
"wallet_tests/importmulti_rescan" # validation.cpp: if (signals.CallbacksPending() > 10)
"wallet_tests/importwallet_rescan" # validation.cpp: if (signals.CallbacksPending() > 10)
"wallet_tests/ListCoins" # validation.cpp: if (signals.CallbacksPending() > 10)
"wallet_tests/scan_for_wallet_transactions" # validation.cpp: if (signals.CallbacksPending() > 10)
"wallet_tests/wallet_disableprivkeys" # validation.cpp: if (signals.CallbacksPending() > 10)
)
TEST_BITCOIN_BINARY="src/test/test_bitcoin"
print_usage() {
echo "Usage: $0 [custom test filter (default: all but known non-deterministic tests)] [number of test runs (default: 2)]"
}
N_TEST_RUNS=2
BOOST_TEST_RUN_FILTERS=""
if [[ $# != 0 ]]; then
if [[ $1 == "--help" ]]; then
print_usage
exit
fi
PARSED_ARGUMENTS=0
if [[ $1 =~ [a-z] ]]; then
BOOST_TEST_RUN_FILTERS=$1
PARSED_ARGUMENTS=$((PARSED_ARGUMENTS + 1))
shift
fi
if [[ $1 =~ ^[0-9]+$ ]]; then
N_TEST_RUNS=$1
PARSED_ARGUMENTS=$((PARSED_ARGUMENTS + 1))
shift
fi
if [[ ${PARSED_ARGUMENTS} == 0 || $# -gt 2 || ${N_TEST_RUNS} -lt 2 ]]; then
print_usage
exit
fi
fi
if [[ ${BOOST_TEST_RUN_FILTERS} == "" ]]; then
BOOST_TEST_RUN_FILTERS="$(IFS=":"; echo "!${NON_DETERMINISTIC_TESTS[*]}" | sed 's/:/:!/g')"
else
echo "Using Boost test filter: ${BOOST_TEST_RUN_FILTERS}"
echo
fi
if ! command -v gcov > /dev/null; then
echo "Error: gcov not installed. Exiting."
exit 1
fi
if ! command -v gcovr > /dev/null; then
echo "Error: gcovr not installed. Exiting."
exit 1
fi
if [[ ! -e ${TEST_BITCOIN_BINARY} ]]; then
echo "Error: Executable ${TEST_BITCOIN_BINARY} not found. Run \"cmake -B build -DCMAKE_BUILD_TYPE=Coverage\" and compile."
exit 1
fi
get_file_suffix_count() {
find src/ -type f -name "*.$1" | wc -l
}
if [[ $(get_file_suffix_count gcno) == 0 ]]; then
echo "Error: Could not find any *.gcno files. The *.gcno files are generated by the compiler. Run \"cmake -B build -DCMAKE_BUILD_TYPE=Coverage\" and re-compile."
exit 1
fi
get_covr_filename() {
echo "gcovr.run-$1.txt"
}
TEST_RUN_ID=0
while [[ ${TEST_RUN_ID} -lt ${N_TEST_RUNS} ]]; do
TEST_RUN_ID=$((TEST_RUN_ID + 1))
echo "[$(date +"%Y-%m-%d %H:%M:%S")] Measuring coverage, run #${TEST_RUN_ID} of ${N_TEST_RUNS}"
find src/ -type f -name "*.gcda" -exec rm {} \;
if [[ $(get_file_suffix_count gcda) != 0 ]]; then
echo "Error: Stale *.gcda files found. Exiting."
exit 1
fi
TEST_OUTPUT_TEMPFILE=$(mktemp)
if ! BOOST_TEST_RUN_FILTERS="${BOOST_TEST_RUN_FILTERS}" ${TEST_BITCOIN_BINARY} > "${TEST_OUTPUT_TEMPFILE}" 2>&1; then
cat "${TEST_OUTPUT_TEMPFILE}"
rm "${TEST_OUTPUT_TEMPFILE}"
exit 1
fi
rm "${TEST_OUTPUT_TEMPFILE}"
if [[ $(get_file_suffix_count gcda) == 0 ]]; then
echo "Error: Running the test suite did not create any *.gcda files. The gcda files are generated when the instrumented test programs are executed. Run \"cmake -B build -DCMAKE_BUILD_TYPE=Coverage\" and re-compile."
exit 1
fi
GCOVR_TEMPFILE=$(mktemp)
if ! gcovr --gcov-executable "${GCOV_EXECUTABLE}" -r src/ > "${GCOVR_TEMPFILE}"; then
echo "Error: gcovr failed. Output written to ${GCOVR_TEMPFILE}. Exiting."
exit 1
fi
GCOVR_FILENAME=$(get_covr_filename ${TEST_RUN_ID})
mv "${GCOVR_TEMPFILE}" "${GCOVR_FILENAME}"
if grep -E "^TOTAL *0 *0 " "${GCOVR_FILENAME}"; then
echo "Error: Spurious gcovr output. Make sure the correct GCOV_EXECUTABLE variable is set in $0 (\"gcov\" for gcc, \"llvm-cov gcov\" for clang)."
exit 1
fi
if [[ ${TEST_RUN_ID} != 1 ]]; then
COVERAGE_DIFF=$(diff -u "$(get_covr_filename 1)" "${GCOVR_FILENAME}")
if [[ ${COVERAGE_DIFF} != "" ]]; then
echo
echo "The line coverage is non-deterministic between runs. Exiting."
echo
echo "The test suite must be deterministic in the sense that the set of lines executed at least"
echo "once must be identical between runs. This is a necessary condition for meaningful"
echo "coverage measuring."
echo
echo "${COVERAGE_DIFF}"
exit 1
fi
rm "${GCOVR_FILENAME}"
fi
done
echo
echo "Coverage test passed: Deterministic coverage across ${N_TEST_RUNS} runs."
exit

View File

@ -18,10 +18,10 @@ Otherwise, you may choose from one of the following options to install Guix:
- Works on nearly all Linux distributions
- Installs any release
- Binary installation only, requires high level of trust
3. Using fanquake's **Docker image** [↗︎ external instructions][install-fanquake-docker]
3. Using fanquake's **container image** [↗︎ external instructions][install-fanquake-container]
- Maintained by fanquake
- Easy (automatically performs *some* setup)
- Works wherever Docker images work
- Works wherever container images work (Docker/Podman)
- Installs any release
- Binary installation only, requires high level of trust
4. Using a **distribution-maintained package** [⤓ skip to section][install-distro-pkg]
@ -57,7 +57,7 @@ Regardless of which installation option you chose, the changes to
`/etc/profile.d` will not take effect until the next shell or desktop session,
so you should log out and log back in.
## Option 3: Using fanquake's Docker image
## Option 3: Using fanquake's container image
Please refer to fanquake's instructions
[here](https://github.com/fanquake/core-review/tree/master/guix).
@ -319,7 +319,7 @@ Source: https://logs.guix.gnu.org/guix/2020-11-12.log#232527
Start by cloning Guix:
```
git clone https://git.savannah.gnu.org/git/guix.git
git clone https://codeberg.org/guix/guix.git
cd guix
```
@ -415,7 +415,7 @@ make it "what Guix intended", then read the next few subsections.
This section definitely does not apply to you if you installed Guix using:
1. The shell installer script
2. fanquake's Docker image
2. fanquake's container image
3. Debian's `guix` package
#### Background
@ -607,7 +607,7 @@ checklist.
```
Generation 38 Feb 22 2021 16:39:31 (current)
guix f350df4
repository URL: https://git.savannah.gnu.org/git/guix.git
repository URL: https://codeberg.org/guix/guix.git
branch: version-1.2.0
commit: f350df405fbcd5b9e27e6b6aa500da7f101f41e7
```
@ -760,13 +760,13 @@ Please see the following links for more details:
- An upstream coreutils bug has been filed: [debbugs#47940](https://debbugs.gnu.org/cgi/bugreport.cgi?bug=47940)
- A Guix bug detailing the underlying problem has been filed: [guix-issues#47935](https://issues.guix.gnu.org/47935), [guix-issues#49985](https://issues.guix.gnu.org/49985#5)
- A commit to skip this test in Guix has been merged into the core-updates branch:
[savannah/guix@6ba1058](https://git.savannah.gnu.org/cgit/guix.git/commit/?id=6ba1058df0c4ce5611c2367531ae5c3cdc729ab4)
- A commit to skip this test is included since Guix 1.4.0:
[codeberg/guix@6ba1058](https://codeberg.org/guix/guix/commit/6ba1058df0c4ce5611c2367531ae5c3cdc729ab4)
[install-script]: #options-1-and-2-using-the-official-shell-installer-script-or-binary-tarball
[install-bin-tarball]: #options-1-and-2-using-the-official-shell-installer-script-or-binary-tarball
[install-fanquake-docker]: #option-3-using-fanquakes-docker-image
[install-fanquake-container]: #option-3-using-fanquakes-container-image
[install-distro-pkg]: #option-4-using-a-distribution-maintained-package
[install-source]: #option-5-building-from-source

View File

@ -365,12 +365,6 @@ Where `<PREFIX>` is likely:
- `/usr/local` if you installed Guix from source and didn't supply any
prefix-modifying flags to Guix's `./configure`
For dongcarl's substitute server at https://guix.carldong.io, run as root:
```sh
wget -qO- 'https://guix.carldong.io/signing-key.pub' | guix archive --authorize
```
#### Removing authorized keys
To remove previously authorized keys, simply edit `/etc/guix/acl` and remove the
@ -382,28 +376,28 @@ Once its key is authorized, the official Guix build farm at
https://ci.guix.gnu.org is automatically used unless the `--no-substitutes` flag
is supplied. This default list of substitute servers is overridable both on a
`guix-daemon` level and when you invoke `guix` commands. See examples below for
the various ways of adding dongcarl's substitute server after having [authorized
his signing key](#step-1-authorize-the-signing-keys).
the various ways of adding a substitute server after having [authorized
its signing key](#step-1-authorize-the-signing-keys).
Change the **default list** of substitute servers by starting `guix-daemon` with
the `--substitute-urls` option (you will likely need to edit your init script):
```sh
guix-daemon <cmd> --substitute-urls='https://guix.carldong.io https://ci.guix.gnu.org'
guix-daemon <cmd> --substitute-urls='https://bordeaux.guix.gnu.org https://ci.guix.gnu.org'
```
Override the default list of substitute servers by passing the
`--substitute-urls` option for invocations of `guix` commands:
```sh
guix <cmd> --substitute-urls='https://guix.carldong.io https://ci.guix.gnu.org'
guix <cmd> --substitute-urls='https://bordeaux.guix.gnu.org https://ci.guix.gnu.org'
```
For scripts under `./contrib/guix`, set the `SUBSTITUTE_URLS` environment
variable:
```sh
export SUBSTITUTE_URLS='https://guix.carldong.io https://ci.guix.gnu.org'
export SUBSTITUTE_URLS='https://bordeaux.guix.gnu.org https://ci.guix.gnu.org'
```
## Option 2: Disabling substitutes on an ad-hoc basis

View File

@ -69,6 +69,12 @@ fi
mkdir -p "$VERSION_BASE"
################
# SOURCE_DATE_EPOCH should not unintentionally be set
################
check_source_date_epoch
################
# Build directories should not exist
################

View File

@ -67,6 +67,12 @@ EOF
exit 1
fi
################
# SOURCE_DATE_EPOCH should not unintentionally be set
################
check_source_date_epoch
################
# The codesignature git worktree should not be dirty
################

View File

@ -69,11 +69,12 @@ unset CPLUS_INCLUDE_PATH
unset OBJC_INCLUDE_PATH
unset OBJCPLUS_INCLUDE_PATH
export C_INCLUDE_PATH="${NATIVE_GCC}/include"
export CPLUS_INCLUDE_PATH="${NATIVE_GCC}/include/c++:${NATIVE_GCC}/include"
# Set native toolchain
build_CC="${NATIVE_GCC}/bin/gcc -isystem ${NATIVE_GCC}/include"
build_CXX="${NATIVE_GCC}/bin/g++ -isystem ${NATIVE_GCC}/include/c++ -isystem ${NATIVE_GCC}/include"
case "$HOST" in
*darwin*) export LIBRARY_PATH="${NATIVE_GCC}/lib" ;; # Required for qt/qmake
*darwin*) export LIBRARY_PATH="${NATIVE_GCC}/lib" ;; # Required for native packages
*mingw*) export LIBRARY_PATH="${NATIVE_GCC}/lib" ;;
*)
NATIVE_GCC_STATIC="$(store_path gcc-toolchain static)"
@ -136,8 +137,7 @@ export GUIX_LD_WRAPPER_DISABLE_RPATH=yes
# Make /usr/bin if it doesn't exist
[ -e /usr/bin ] || mkdir -p /usr/bin
# Symlink file and env to a conventional path
[ -e /usr/bin/file ] || ln -s --no-dereference "$(command -v file)" /usr/bin/file
# Symlink env to a conventional path
[ -e /usr/bin/env ] || ln -s --no-dereference "$(command -v env)" /usr/bin/env
# Determine the correct value for -Wl,--dynamic-linker for the current $HOST
@ -171,6 +171,8 @@ make -C depends --jobs="$JOBS" HOST="$HOST" \
${SOURCES_PATH+SOURCES_PATH="$SOURCES_PATH"} \
${BASE_CACHE+BASE_CACHE="$BASE_CACHE"} \
${SDK_PATH+SDK_PATH="$SDK_PATH"} \
${build_CC+build_CC="$build_CC"} \
${build_CXX+build_CXX="$build_CXX"} \
x86_64_linux_CC=x86_64-linux-gnu-gcc \
x86_64_linux_CXX=x86_64-linux-gnu-g++ \
x86_64_linux_AR=x86_64-linux-gnu-gcc-ar \
@ -181,8 +183,6 @@ make -C depends --jobs="$JOBS" HOST="$HOST" \
case "$HOST" in
*darwin*)
# Unset now that Qt is built
unset C_INCLUDE_PATH
unset CPLUS_INCLUDE_PATH
unset LIBRARY_PATH
;;
esac
@ -242,6 +242,7 @@ mkdir -p "$DISTSRC"
cmake -S . -B build \
--toolchain "${BASEPREFIX}/${HOST}/toolchain.cmake" \
-DWITH_CCACHE=OFF \
-Werror=dev \
${CONFIGFLAGS}
# Build Bitcoin Core
@ -289,7 +290,7 @@ mkdir -p "$DISTSRC"
*)
# Split binaries from their debug symbols
{
find "${DISTNAME}/bin" -type f -executable -print0
find "${DISTNAME}/bin" "${DISTNAME}/libexec" -type f -executable -print0
} | xargs -0 -P"$JOBS" -I{} "${DISTSRC}/build/split-debug.sh" {} {} {}.dbg
;;
esac
@ -368,7 +369,7 @@ mkdir -p "$DISTSRC"
;;
*darwin*)
cmake --build build --target deploy ${V:+--verbose}
mv build/dist/Bitcoin-Core.zip "${OUTDIR}/${DISTNAME}-${HOST}-unsigned.zip"
mv build/dist/bitcoin-macos-app.zip "${OUTDIR}/${DISTNAME}-${HOST}-unsigned.zip"
mkdir -p "unsigned-app-${HOST}"
cp --target-directory="unsigned-app-${HOST}" \
contrib/macdeploy/detached-sig-create.sh

View File

@ -110,7 +110,7 @@ mkdir -p "$DISTSRC"
# Apply detached codesignatures (in-place)
signapple apply dist/Bitcoin-Qt.app codesignatures/osx/"${HOST}"/dist/Bitcoin-Qt.app
find "${DISTNAME}" -wholename "*/bin/*" -type f | while read -r bin
find "${DISTNAME}" \( -wholename "*/bin/*" -o -wholename "*/libexec/*" \) -type f | while read -r bin
do
signapple apply "${bin}" "codesignatures/osx/${HOST}/${bin}.${ARCH}sign"
done

View File

@ -21,6 +21,26 @@ check_tools() {
done
}
################
# SOURCE_DATE_EPOCH should not unintentionally be set
################
check_source_date_epoch() {
if [ -n "$SOURCE_DATE_EPOCH" ] && [ -z "$FORCE_SOURCE_DATE_EPOCH" ]; then
cat << EOF
ERR: Environment variable SOURCE_DATE_EPOCH is set which may break reproducibility.
Aborting...
Hint: You may want to:
1. Unset this variable: \`unset SOURCE_DATE_EPOCH\` before rebuilding
2. Set the 'FORCE_SOURCE_DATE_EPOCH' environment variable if you insist on
using your own epoch
EOF
exit 1
fi
}
check_tools cat env readlink dirname basename git
################
@ -50,7 +70,7 @@ fi
# across time.
time-machine() {
# shellcheck disable=SC2086
guix time-machine --url=https://git.savannah.gnu.org/git/guix.git \
guix time-machine --url=https://codeberg.org/guix/guix.git \
--commit=53396a22afc04536ddf75d8f82ad2eafa5082725 \
--cores="$JOBS" \
--keep-failed \

View File

@ -6,17 +6,19 @@
(gnu packages commencement)
(gnu packages compression)
(gnu packages cross-base)
(gnu packages file)
(gnu packages gawk)
(gnu packages gcc)
((gnu packages installers) #:select (nsis-x86_64))
((gnu packages linux) #:select (linux-libre-headers-6.1))
(gnu packages llvm)
(gnu packages mingw)
(gnu packages ninja)
(gnu packages pkg-config)
((gnu packages python) #:select (python-minimal))
((gnu packages python-build) #:select (python-tomli python-poetry-core))
((gnu packages python-build) #:select (python-poetry-core))
((gnu packages python-crypto) #:select (python-asn1crypto))
((gnu packages python-science) #:select (python-scikit-build-core))
((gnu packages python-xyz) #:select (python-pydantic-2 python-pydantic-core))
((gnu packages tls) #:select (openssl))
((gnu packages version-control) #:select (git-minimal))
(guix build-system cmake)
@ -158,37 +160,35 @@ chain for " target " development."))
(define-public python-lief
(package
(name "python-lief")
(version "0.13.2")
(version "0.16.6")
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/lief-project/LIEF")
(commit version)))
(file-name (git-file-name name version))
(modules '((guix build utils)))
(snippet
'(begin
;; Configure build for Python bindings.
(substitute* "api/python/config-default.toml"
(("(ninja = )true" all m)
(string-append m "false"))
(("(parallel-jobs = )0" all m)
(string-append m (number->string (parallel-job-count)))))))
(sha256
(base32
"0y48x358ppig5xp97ahcphfipx7cg9chldj2q5zrmn610fmi4zll"))))
(build-system python-build-system)
(native-inputs (list cmake-minimal python-tomli))
"1pq9nagrnkl1x943bqnpiyxmkd9vk99znfxiwqp6vf012b50bz2a"))
(patches (search-our-patches "lief-scikit-0-9.patch"))))
(build-system pyproject-build-system)
(native-inputs (list cmake-minimal
ninja
python-scikit-build-core
python-pydantic-core
python-pydantic-2))
(arguments
(list
#:tests? #f ;needs network
#:phases #~(modify-phases %standard-phases
(add-before 'build 'change-directory
(add-before 'build 'set-pythonpath
(lambda _
(chdir "api/python")))
(replace 'build
(setenv "PYTHONPATH"
(string-append (string-append (getcwd) "/api/python/backend")
":" (or (getenv "PYTHONPATH") "")))))
(add-after 'set-pythonpath 'change-directory
(lambda _
(invoke "python" "setup.py" "build"))))))
(chdir "api/python"))))))
(home-page "https://github.com/lief-project/LIEF")
(synopsis "Library to instrument executable formats")
(description
@ -530,7 +530,6 @@ inspecting signatures in Mach-O binaries.")
which
coreutils-minimal
;; File(system) inspection
file
grep
diffutils
findutils
@ -547,6 +546,7 @@ inspecting signatures in Mach-O binaries.")
gcc-toolchain-13
cmake-minimal
gnu-make
ninja
;; Scripting
python-minimal ;; (3.10)
;; Git

View File

@ -0,0 +1,21 @@
Partially revert f23ced2f4ffc170d0a6f40ff4a1bee575e3447cf
Restore compat with python-scikit-build-core 0.9.x
Can be dropped when using python-scikit-build-core >= 0.10.x
--- a/api/python/backend/setup.py
+++ b/api/python/backend/setup.py
@@ -101,12 +101,12 @@ def _get_hooked_config(is_editable: bool) -> Optional[dict[str, Union[str, List[
config_settings = {
"logging.level": "DEBUG",
"build-dir": config.build_dir,
- "build.targets": config.build.targets,
"install.strip": config.strip,
"backport.find-python": "0",
"wheel.py-api": config.build.py_api,
"cmake.source-dir": SRC_DIR.as_posix(),
"cmake.build-type": config.build.build_type,
+ "cmake.targets": config.build.targets,
"cmake.args": [
*config.cmake_generator,
*config.get_cmake_args(is_editable),

View File

@ -6,6 +6,10 @@
Perform basic security checks on a series of executables.
Exit status will be 0 if successful, and the program will be silent.
Otherwise the exit status will be 1 and it will log which executables failed which checks.
Example usage:
find ../path/to/guix/binaries -type f -executable | xargs python3 contrib/guix/security-check.py
'''
import re
import sys
@ -26,13 +30,13 @@ def check_ELF_RELRO(binary) -> bool:
# However, the dynamic linker need to write to this area so these are RW.
# Glibc itself takes care of mprotecting this area R after relocations are finished.
# See also https://marc.info/?l=binutils&m=1498883354122353
if segment.type == lief.ELF.SEGMENT_TYPES.GNU_RELRO:
if segment.type == lief.ELF.Segment.TYPE.GNU_RELRO:
have_gnu_relro = True
have_bindnow = False
try:
flags = binary.get(lief.ELF.DYNAMIC_TAGS.FLAGS)
if flags.value & lief.ELF.DYNAMIC_FLAGS.BIND_NOW:
flags = binary.get(lief.ELF.DynamicEntry.TAG.FLAGS)
if flags.has(lief.ELF.DynamicEntryFlags.FLAG.BIND_NOW):
have_bindnow = True
except Exception:
have_bindnow = False
@ -51,9 +55,9 @@ def check_ELF_SEPARATE_CODE(binary):
based on their permissions. This checks for missing -Wl,-z,separate-code
and potentially other problems.
'''
R = lief.ELF.SEGMENT_FLAGS.R
W = lief.ELF.SEGMENT_FLAGS.W
E = lief.ELF.SEGMENT_FLAGS.X
R = lief.ELF.Segment.FLAGS.R
W = lief.ELF.Segment.FLAGS.W
E = lief.ELF.Segment.FLAGS.X
EXPECTED_FLAGS = {
# Read + execute
'.init': R | E,
@ -95,7 +99,7 @@ def check_ELF_SEPARATE_CODE(binary):
# and for each section, remember the flags of the associated program header.
flags_per_section = {}
for segment in binary.segments:
if segment.type == lief.ELF.SEGMENT_TYPES.LOAD:
if segment.type == lief.ELF.Segment.TYPE.LOAD:
for section in segment.sections:
flags_per_section[section.name] = segment.flags
# Spot-check ELF LOAD program header flags per section
@ -119,8 +123,8 @@ def check_ELF_CONTROL_FLOW(binary) -> bool:
def check_ELF_FORTIFY(binary) -> bool:
# bitcoin-util does not currently contain any fortified functions
if 'Bitcoin Core bitcoin-util utility version ' in binary.strings:
# bitcoin wrapper does not currently contain any fortified functions
if '--monolithic' in binary.strings:
return True
chk_funcs = set()
@ -130,21 +134,20 @@ def check_ELF_FORTIFY(binary) -> bool:
if match:
chk_funcs.add(match.group(0))
# ignore stack-protector and bdb
# ignore stack-protector
chk_funcs.discard('__stack_chk')
chk_funcs.discard('__db_chk')
return len(chk_funcs) >= 1
def check_PE_DYNAMIC_BASE(binary) -> bool:
'''PIE: DllCharacteristics bit 0x40 signifies dynamicbase (ASLR)'''
return lief.PE.DLL_CHARACTERISTICS.DYNAMIC_BASE in binary.optional_header.dll_characteristics_lists
return lief.PE.OptionalHeader.DLL_CHARACTERISTICS.DYNAMIC_BASE in binary.optional_header.dll_characteristics_lists
# Must support high-entropy 64-bit address space layout randomization
# in addition to DYNAMIC_BASE to have secure ASLR.
def check_PE_HIGH_ENTROPY_VA(binary) -> bool:
'''PIE: DllCharacteristics bit 0x20 signifies high-entropy ASLR'''
return lief.PE.DLL_CHARACTERISTICS.HIGH_ENTROPY_VA in binary.optional_header.dll_characteristics_lists
return lief.PE.OptionalHeader.DLL_CHARACTERISTICS.HIGH_ENTROPY_VA in binary.optional_header.dll_characteristics_lists
def check_PE_RELOC_SECTION(binary) -> bool:
'''Check for a reloc section. This is required for functional ASLR.'''
@ -175,7 +178,7 @@ def check_MACHO_NOUNDEFS(binary) -> bool:
'''
Check for no undefined references.
'''
return binary.header.has(lief.MachO.HEADER_FLAGS.NOUNDEFS)
return binary.header.has(lief.MachO.Header.FLAGS.NOUNDEFS)
def check_MACHO_FIXUP_CHAINS(binary) -> bool:
'''
@ -200,7 +203,13 @@ def check_NX(binary) -> bool:
'''
Check for no stack execution
'''
return binary.has_nx
# binary.has_nx checks are only for the stack, but MachO binaries might
# have executable heaps.
if binary.format == lief.Binary.FORMATS.MACHO:
return binary.concrete.has_nx_stack and binary.concrete.has_nx_heap
else:
return binary.has_nx
def check_MACHO_CONTROL_FLOW(binary) -> bool:
'''
@ -223,6 +232,7 @@ def check_MACHO_BRANCH_PROTECTION(binary) -> bool:
return False
BASE_ELF = [
('FORTIFY', check_ELF_FORTIFY),
('PIE', check_PIE),
('NX', check_NX),
('RELRO', check_ELF_RELRO),
@ -247,21 +257,21 @@ BASE_MACHO = [
]
CHECKS = {
lief.EXE_FORMATS.ELF: {
lief.ARCHITECTURES.X86: BASE_ELF + [('CONTROL_FLOW', check_ELF_CONTROL_FLOW), ('FORTIFY', check_ELF_FORTIFY)],
lief.ARCHITECTURES.ARM: BASE_ELF + [('FORTIFY', check_ELF_FORTIFY)],
lief.ARCHITECTURES.ARM64: BASE_ELF + [('FORTIFY', check_ELF_FORTIFY)],
lief.ARCHITECTURES.PPC: BASE_ELF + [('FORTIFY', check_ELF_FORTIFY)],
lief.ARCHITECTURES.RISCV: BASE_ELF, # Skip FORTIFY. See https://github.com/lief-project/LIEF/issues/1082.
lief.Binary.FORMATS.ELF: {
lief.Header.ARCHITECTURES.X86_64: BASE_ELF + [('CONTROL_FLOW', check_ELF_CONTROL_FLOW)],
lief.Header.ARCHITECTURES.ARM: BASE_ELF,
lief.Header.ARCHITECTURES.ARM64: BASE_ELF,
lief.Header.ARCHITECTURES.PPC64: BASE_ELF,
lief.Header.ARCHITECTURES.RISCV: BASE_ELF,
},
lief.EXE_FORMATS.PE: {
lief.ARCHITECTURES.X86: BASE_PE,
lief.Binary.FORMATS.PE: {
lief.Header.ARCHITECTURES.X86_64: BASE_PE,
},
lief.EXE_FORMATS.MACHO: {
lief.ARCHITECTURES.X86: BASE_MACHO + [('PIE', check_PIE),
lief.Binary.FORMATS.MACHO: {
lief.Header.ARCHITECTURES.X86_64: BASE_MACHO + [('PIE', check_PIE),
('NX', check_NX),
('CONTROL_FLOW', check_MACHO_CONTROL_FLOW)],
lief.ARCHITECTURES.ARM64: BASE_MACHO + [('BRANCH_PROTECTION', check_MACHO_BRANCH_PROTECTION)],
lief.Header.ARCHITECTURES.ARM64: BASE_MACHO + [('BRANCH_PROTECTION', check_MACHO_BRANCH_PROTECTION)],
}
}
@ -269,9 +279,9 @@ if __name__ == '__main__':
retval: int = 0
for filename in sys.argv[1:]:
binary = lief.parse(filename)
etype = binary.format
arch = binary.abstract.header.architecture
binary.concrete
failed: list[str] = []
for (name, func) in CHECKS[etype][arch]:

View File

@ -8,7 +8,7 @@ and are only linked against allowed libraries.
Example usage:
find ../path/to/binaries -type f -executable | xargs python3 contrib/devtools/symbol-check.py
find ../path/to/guix/binaries -type f -executable | xargs python3 contrib/guix/symbol-check.py
'''
import sys
@ -32,9 +32,9 @@ import lief
# See https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html for more info.
MAX_VERSIONS = {
'GCC': (4,3,0),
'GCC': (7,0,0),
'GLIBC': {
lief.ELF.ARCH.x86_64: (2,31),
lief.ELF.ARCH.X86_64: (2,31),
lief.ELF.ARCH.ARM: (2,31),
lief.ELF.ARCH.AARCH64:(2,31),
lief.ELF.ARCH.PPC64: (2,31),
@ -52,41 +52,41 @@ IGNORE_EXPORTS = {
# Expected linker-loader names can be found here:
# https://sourceware.org/glibc/wiki/ABIList?action=recall&rev=16
ELF_INTERPRETER_NAMES: dict[lief.ELF.ARCH, dict[lief.ENDIANNESS, str]] = {
lief.ELF.ARCH.x86_64: {
lief.ENDIANNESS.LITTLE: "/lib64/ld-linux-x86-64.so.2",
ELF_INTERPRETER_NAMES: dict[lief.ELF.ARCH, dict[lief.Header.ENDIANNESS, str]] = {
lief.ELF.ARCH.X86_64: {
lief.Header.ENDIANNESS.LITTLE: "/lib64/ld-linux-x86-64.so.2",
},
lief.ELF.ARCH.ARM: {
lief.ENDIANNESS.LITTLE: "/lib/ld-linux-armhf.so.3",
lief.Header.ENDIANNESS.LITTLE: "/lib/ld-linux-armhf.so.3",
},
lief.ELF.ARCH.AARCH64: {
lief.ENDIANNESS.LITTLE: "/lib/ld-linux-aarch64.so.1",
lief.Header.ENDIANNESS.LITTLE: "/lib/ld-linux-aarch64.so.1",
},
lief.ELF.ARCH.PPC64: {
lief.ENDIANNESS.BIG: "/lib64/ld64.so.1",
lief.ENDIANNESS.LITTLE: "/lib64/ld64.so.2",
lief.Header.ENDIANNESS.BIG: "/lib64/ld64.so.1",
lief.Header.ENDIANNESS.LITTLE: "/lib64/ld64.so.2",
},
lief.ELF.ARCH.RISCV: {
lief.ENDIANNESS.LITTLE: "/lib/ld-linux-riscv64-lp64d.so.1",
lief.Header.ENDIANNESS.LITTLE: "/lib/ld-linux-riscv64-lp64d.so.1",
},
}
ELF_ABIS: dict[lief.ELF.ARCH, dict[lief.ENDIANNESS, list[int]]] = {
lief.ELF.ARCH.x86_64: {
lief.ENDIANNESS.LITTLE: [3,2,0],
ELF_ABIS: dict[lief.ELF.ARCH, dict[lief.Header.ENDIANNESS, list[int]]] = {
lief.ELF.ARCH.X86_64: {
lief.Header.ENDIANNESS.LITTLE: [3,2,0],
},
lief.ELF.ARCH.ARM: {
lief.ENDIANNESS.LITTLE: [3,2,0],
lief.Header.ENDIANNESS.LITTLE: [3,2,0],
},
lief.ELF.ARCH.AARCH64: {
lief.ENDIANNESS.LITTLE: [3,7,0],
lief.Header.ENDIANNESS.LITTLE: [3,7,0],
},
lief.ELF.ARCH.PPC64: {
lief.ENDIANNESS.LITTLE: [3,10,0],
lief.ENDIANNESS.BIG: [3,2,0],
lief.Header.ENDIANNESS.LITTLE: [3,10,0],
lief.Header.ENDIANNESS.BIG: [3,2,0],
},
lief.ELF.ARCH.RISCV: {
lief.ENDIANNESS.LITTLE: [4,15,0],
lief.Header.ENDIANNESS.LITTLE: [4,15,0],
},
}
@ -122,7 +122,6 @@ ELF_ALLOWED_LIBRARIES = {
'libxcb-shape.so.0',
'libxcb-sync.so.1',
'libxcb-xfixes.so.0',
'libxcb-xinerama.so.0',
'libxcb-xkb.so.1',
}
@ -146,19 +145,31 @@ MACHO_ALLOWED_LIBRARIES = {
'IOSurface', # cross process image/drawing buffers
'libobjc.A.dylib', # Objective-C runtime library
'Metal', # 3D graphics
'Security', # access control and authentication
'QuartzCore', # animation
'Security', # access control and authentication
'UniformTypeIdentifiers', # collection of types that map to MIME and file types
}
PE_ALLOWED_LIBRARIES = {
'ADVAPI32.dll', # security & registry
'ADVAPI32.dll', # legacy security & registry
'bcrypt.dll', # newer security and identity API
'IPHLPAPI.DLL', # IP helper API
'KERNEL32.dll', # win32 base APIs
'msvcrt.dll', # C standard library for MSVC
'SHELL32.dll', # shell API
'WS2_32.dll', # sockets
# bitcoin-qt only
'api-ms-win-core-synch-l1-2-0.dll', # Synchronization Primitives API
'api-ms-win-core-winrt-l1-1-0.dll', # Windows Runtime API
'api-ms-win-core-winrt-string-l1-1-0.dll', # WinRT String API
'AUTHZ.dll', # Windows Authorization Framework
'comdlg32.dll', # Common Dialog Box Library
'd3d11.dll', # Direct3D 11 API
'd3d12.dll', # Direct3D 12 API
'd3d9.dll', # Direct3D 9 API
'dwmapi.dll', # desktop window manager
'DWrite.dll', # DirectX Typography Services
'dxgi.dll', # DirectX Graphics Infrastructure
'GDI32.dll', # graphics device interface
'IMM32.dll', # input method editor
'NETAPI32.dll', # network management
@ -171,6 +182,8 @@ PE_ALLOWED_LIBRARIES = {
'VERSION.dll', # version checking
'WINMM.dll', # WinMM audio API
'WTSAPI32.dll', # Remote Desktop
'SETUPAPI.dll', # Windows Setup API
'SHCORE.dll', # Stream Handler Core
}
def check_version(max_versions, version, arch) -> bool:
@ -208,13 +221,13 @@ def check_exported_symbols(binary) -> bool:
name = symbol.name
if binary.header.machine_type == lief.ELF.ARCH.RISCV or name in IGNORE_EXPORTS:
continue
print(f'{binary.name}: export of symbol {name} not allowed!')
print(f'{filename}: export of symbol {name} not allowed!')
ok = False
return ok
def check_RUNPATH(binary) -> bool:
assert binary.get(lief.ELF.DYNAMIC_TAGS.RUNPATH) is None
assert binary.get(lief.ELF.DYNAMIC_TAGS.RPATH) is None
assert binary.get(lief.ELF.DynamicEntry.TAG.RUNPATH) is None
assert binary.get(lief.ELF.DynamicEntry.TAG.RPATH) is None
return True
def check_ELF_libraries(binary) -> bool:
@ -235,7 +248,7 @@ def check_MACHO_libraries(binary) -> bool:
return ok
def check_MACHO_min_os(binary) -> bool:
if binary.build_version.minos == [13,0,0]:
if binary.build_version.minos == [14,0,0]:
return True
return False
@ -264,6 +277,14 @@ def check_PE_subsystem_version(binary) -> bool:
return True
return False
def check_PE_application_manifest(binary) -> bool:
if not binary.has_resources:
# No resources at all.
return False
rm = binary.resources_manager
return rm.has_manifest
def check_ELF_interpreter(binary) -> bool:
expected_interpreter = ELF_INTERPRETER_NAMES[binary.header.machine_type][binary.abstract.header.endianness]
@ -271,12 +292,12 @@ def check_ELF_interpreter(binary) -> bool:
def check_ELF_ABI(binary) -> bool:
expected_abi = ELF_ABIS[binary.header.machine_type][binary.abstract.header.endianness]
note = binary.concrete.get(lief.ELF.NOTE_TYPES.ABI_TAG)
assert note.details.abi == lief.ELF.NOTE_ABIS.LINUX
return note.details.version == expected_abi
note = binary.concrete.get(lief.ELF.Note.TYPE.GNU_ABI_TAG)
assert note.abi == lief.ELF.NoteAbi.ABI.LINUX
return note.version == expected_abi
CHECKS = {
lief.EXE_FORMATS.ELF: [
lief.Binary.FORMATS.ELF: [
('IMPORTED_SYMBOLS', check_imported_symbols),
('EXPORTED_SYMBOLS', check_exported_symbols),
('LIBRARY_DEPENDENCIES', check_ELF_libraries),
@ -284,15 +305,16 @@ lief.EXE_FORMATS.ELF: [
('ABI', check_ELF_ABI),
('RUNPATH', check_RUNPATH),
],
lief.EXE_FORMATS.MACHO: [
lief.Binary.FORMATS.MACHO: [
('DYNAMIC_LIBRARIES', check_MACHO_libraries),
('MIN_OS', check_MACHO_min_os),
('SDK', check_MACHO_sdk),
('LLD', check_MACHO_lld),
],
lief.EXE_FORMATS.PE: [
lief.Binary.FORMATS.PE: [
('DYNAMIC_LIBRARIES', check_PE_libraries),
('SUBSYSTEM_VERSION', check_PE_subsystem_version),
('APPLICATION_MANIFEST', check_PE_application_manifest),
]
}
@ -300,6 +322,7 @@ if __name__ == '__main__':
retval: int = 0
for filename in sys.argv[1:]:
binary = lief.parse(filename)
etype = binary.format
failed: list[str] = []

View File

@ -25,8 +25,7 @@ ExecStart=/usr/bin/bitcoind -pid=/run/bitcoind/bitcoind.pid \
-shutdownnotify='systemd-notify --stopping'
# Make sure the config directory is readable by the service user
PermissionsStartOnly=true
ExecStartPre=/bin/chgrp bitcoin /etc/bitcoin
ExecStartPre=!/bin/chgrp bitcoin /etc/bitcoin
# Process management
####################
@ -44,7 +43,6 @@ TimeoutStopSec=600
# Run as bitcoin:bitcoin
User=bitcoin
Group=bitcoin
# /run/bitcoind
RuntimeDirectory=bitcoind

View File

@ -44,7 +44,7 @@ ${SIGNAPPLE} apply "${UNSIGNED_BUNDLE}" "${OUTROOT}/${BUNDLE_ROOT}/${BUNDLE_NAME
${SIGNAPPLE} notarize --detach "${OUTROOT}/${BUNDLE_ROOT}" --passphrase "${api_key_pass}" "$2" "$3" "${UNSIGNED_BUNDLE}"
# Sign each binary
find . -maxdepth 3 -wholename "*/bin/*" -type f -exec realpath --relative-to=. {} \; | while read -r bin
find . -maxdepth 3 \( -wholename "*/bin/*" -o -wholename "*/libexec/*" \) -type f -exec realpath --relative-to=. {} \; | while read -r bin
do
bin_dir=$(dirname "${bin}")
bin_name=$(basename "${bin}")

View File

@ -54,7 +54,7 @@ def run():
out_sdktgz_path = pathlib.Path("./{}.tar.gz".format(out_name))
def tarfp_add_with_base_change(tarfp, dir_to_add, alt_base_dir):
"""Add all files in dir_to_add to tarfp, but prepent alt_base_dir to the files'
"""Add all files in dir_to_add to tarfp, but prepend alt_base_dir to the files'
names
e.g. if the only file under /root/bazdir is /root/bazdir/qux, invoking:

View File

@ -157,20 +157,19 @@ class DeploymentInfo(object):
self.qtPath = None
self.pluginPath = None
self.deployedFrameworks = []
def detectQtPath(self, frameworkDirectory: str):
parentDir = os.path.dirname(frameworkDirectory)
if os.path.exists(os.path.join(parentDir, "translations")):
# Classic layout, e.g. "/usr/local/Trolltech/Qt-4.x.x"
if os.path.exists(os.path.join(parentDir, "share", "qt", "translations")):
self.qtPath = parentDir
else:
self.qtPath = os.getenv("QTDIR", None)
if self.qtPath is not None:
pluginPath = os.path.join(self.qtPath, "plugins")
pluginPath = os.path.join(self.qtPath, "share", "qt", "plugins")
if os.path.exists(pluginPath):
self.pluginPath = pluginPath
def usesFramework(self, name: str) -> bool:
for framework in self.deployedFrameworks:
if framework.endswith(".framework"):
@ -181,7 +180,7 @@ class DeploymentInfo(object):
return True
return False
def getFrameworks(binaryPath: str, verbose: int) -> list[FrameworkInfo]:
def getFrameworks(binaryPath: str, verbose: int, rpath: str = '') -> list[FrameworkInfo]:
objdump = os.getenv("OBJDUMP", "objdump")
if verbose:
print(f"Inspecting with {objdump}: {binaryPath}")
@ -195,17 +194,19 @@ def getFrameworks(binaryPath: str, verbose: int) -> list[FrameworkInfo]:
lines.pop(0) # First line is the inspected binary
if ".framework" in binaryPath or binaryPath.endswith(".dylib"):
lines.pop(0) # Frameworks and dylibs list themselves as a dependency.
libraries = []
for line in lines:
line = line.replace("@loader_path", os.path.dirname(binaryPath))
if rpath:
line = line.replace("@rpath", rpath)
info = FrameworkInfo.fromLibraryLine(line.strip())
if info is not None:
if verbose:
print("Found framework:")
print(info)
libraries.append(info)
return libraries
def runInstallNameTool(action: str, *args):
@ -318,7 +319,7 @@ def deployFrameworks(frameworks: list[FrameworkInfo], bundlePath: str, binaryPat
# install_name_tool it a new id.
changeIdentification(framework.deployedInstallName, deployedBinaryPath, verbose)
# Check for framework dependencies
dependencies = getFrameworks(deployedBinaryPath, verbose)
dependencies = getFrameworks(deployedBinaryPath, verbose, rpath=framework.frameworkDirectory)
for dependency in dependencies:
changeInstallName(dependency.installName, dependency.deployedInstallName, deployedBinaryPath, verbose)
@ -389,12 +390,11 @@ Note, that the "dist" folder will be deleted before deploying on each run.
Optionally, Qt translation files (.qm) can be added to the bundle.""")
ap.add_argument("app_bundle", nargs=1, metavar="app-bundle", help="application bundle to be deployed")
ap.add_argument("appname", nargs=1, metavar="appname", help="name of the app being deployed")
ap.add_argument("-verbose", nargs="?", const=True, help="Output additional debugging information")
ap.add_argument("-no-plugins", dest="plugins", action="store_false", default=True, help="skip plugin deployment")
ap.add_argument("-no-strip", dest="strip", action="store_false", default=True, help="don't run 'strip' on the binaries")
ap.add_argument("-translations-dir", nargs=1, metavar="path", default=None, help="Path to Qt's translations. Base translations will automatically be added to the bundle's resources.")
ap.add_argument("-zip", nargs="?", const="", metavar="zip", help="create a .zip containing the app bundle")
ap.add_argument("-zip", nargs=1, metavar="zip", help="create a .zip containing the app bundle")
config = ap.parse_args()
@ -403,7 +403,6 @@ verbose = config.verbose
# ------------------------------------------------
app_bundle = config.app_bundle[0]
appname = config.appname[0]
if not os.path.exists(app_bundle):
sys.stderr.write(f"Error: Could not find app bundle \"{app_bundle}\"\n")
@ -415,10 +414,6 @@ if os.path.exists("dist"):
print("+ Removing existing dist folder +")
shutil.rmtree("dist")
if os.path.exists(appname + ".zip"):
print("+ Removing existing .zip +")
os.unlink(appname + ".zip")
# ------------------------------------------------
target = os.path.join("dist", "Bitcoin-Qt.app")
@ -465,18 +460,18 @@ if config.translations_dir:
sys.stderr.write(f"Error: Could not find translation dir \"{config.translations_dir[0]}\"\n")
sys.exit(1)
print("+ Adding Qt translations +")
print("+ Adding Qt translations +")
translations = Path(config.translations_dir[0])
translations = Path(config.translations_dir[0])
regex = re.compile('qt_[a-z]*(.qm|_[A-Z]*.qm)')
regex = re.compile('qt_[a-z]*(.qm|_[A-Z]*.qm)')
lang_files = [x for x in translations.iterdir() if regex.match(x.name)]
lang_files = [x for x in translations.iterdir() if regex.match(x.name)]
for file in lang_files:
if verbose:
print(file.as_posix(), "->", os.path.join(applicationBundle.resourcesPath, file.name))
shutil.copy2(file.as_posix(), os.path.join(applicationBundle.resourcesPath, file.name))
for file in lang_files:
if verbose:
print(file.as_posix(), "->", os.path.join(applicationBundle.resourcesPath, file.name))
shutil.copy2(file.as_posix(), os.path.join(applicationBundle.resourcesPath, file.name))
# ------------------------------------------------
@ -498,7 +493,13 @@ if platform.system() == "Darwin":
# ------------------------------------------------
if config.zip is not None:
shutil.make_archive('{}'.format(appname), format='zip', root_dir='dist', base_dir='Bitcoin-Qt.app')
name = config.zip[0]
if os.path.exists(name + ".zip"):
print("+ Removing existing .zip +")
os.unlink(name + ".zip")
shutil.make_archive('{}'.format(name), format='zip', root_dir='dist', base_dir='Bitcoin-Qt.app')
# ------------------------------------------------

View File

@ -24,8 +24,8 @@ curl https://testnet.achownodes.xyz/seeds.txt.gz | gzip -dc > seeds_test.txt
curl https://testnet4.achownodes.xyz/seeds.txt.gz | gzip -dc > seeds_testnet4.txt
curl https://raw.githubusercontent.com/asmap/asmap-data/main/latest_asmap.dat > asmap-filled.dat
python3 makeseeds.py -a asmap-filled.dat -s seeds_main.txt > nodes_main.txt
python3 makeseeds.py -a asmap-filled.dat -s seeds_signet.txt -m 237800 > nodes_signet.txt
python3 makeseeds.py -a asmap-filled.dat -s seeds_test.txt > nodes_test.txt
python3 makeseeds.py -a asmap-filled.dat -s seeds_testnet4.txt -m 72600 > nodes_testnet4.txt
python3 makeseeds.py -a asmap-filled.dat -s seeds_signet.txt -m 266000 > nodes_signet.txt
python3 makeseeds.py -a asmap-filled.dat -s seeds_test.txt -m 4650000 > nodes_test.txt
python3 makeseeds.py -a asmap-filled.dat -s seeds_testnet4.txt -m 100000 > nodes_testnet4.txt
python3 generate-seeds.py . > ../../src/chainparamsseeds.h
```

View File

@ -26,7 +26,7 @@ MAX_SEEDS_PER_ASN = {
'ipv6': 10,
}
MIN_BLOCKS = 868000
MIN_BLOCKS = 910000
PATTERN_IPV4 = re.compile(r"^(([0-2]?\d{1,2})\.([0-2]?\d{1,2})\.([0-2]?\d{1,2})\.([0-2]?\d{1,2})):(\d{1,5})$")
PATTERN_IPV6 = re.compile(r"^\[([\da-f:]+)]:(\d{1,5})$", re.IGNORECASE)
@ -48,7 +48,8 @@ PATTERN_AGENT = re.compile(
r"|25\.(0|1|2|99)\.0"
r"|26\.(0|1|2|99)\.0"
r"|27\.(0|1|2|99)\.0"
r"|28\.(0|1|99)\.0"
r"|28\.(0|1|2|99)\.0"
r"|29\.(0|99)\.0"
r")")
def parseline(line: str) -> Union[dict, None]:

File diff suppressed because it is too large Load Diff

View File

@ -1,130 +1,113 @@
[fc10:efa7:ca6:1548:f8c:6bb9:1cc4:63ae]:38333
[fc1f:22c3:95dc:a3af:4a93:8251:beb9:1858]:38333
[fc32:2c16:d0d0:f1fb:3b27:c187:8cb5:9201]:38333
[fccb:248:11a6:1042:bca:1218:f7ce:7d3d]:38333
3cxteqanevzjd5iufktxxh3l5abj6fs6udqg3bomphzofqjl4aqa.b32.i2p:0
kmmq64ijxhaalfpatq7q6yyrf3rdfvjk3tsb5xc2rrmkgdqf3vwq.b32.i2p:0
nmmoytmmcwq4aclmtrxk3askrv7mgy6l27uw67ozvyolwca2dr6a.b32.i2p:0
qhlt7irano6s2pjfn2v4qrtynjj4peo7tfsnv2x6bm4e4vowptaq.b32.i2p:0
qn7uwi6nx6tuakxvzhjnjeuxwpcq6wcv4diecrv63ugain2tdopa.b32.i2p:0
regl2o33xgkhnuu5ywr7tw72dio46j6tylz7zpdl6pfaqsktboea.b32.i2p:0
rkf5lugxqdjrxva2n5wl43okxrqmm6prlf7arci4bgg4md55oo2a.b32.i2p:0
5.189.136.209:38333 # AS51167
15.235.55.158:38333 # AS16276
18.141.143.94:38333 # AS16509
18.216.1.71:38333 # AS8987
23.137.57.100:38333 # AS1002
23.226.164.192:38333 # AS3801
34.16.103.64:38333 # AS396982
35.217.29.66:38333 # AS15169
37.27.45.224:38333 # AS24940
38.88.125.238:38333 # AS394256
44.210.109.64:38333 # AS14618
45.32.127.199:38333 # AS20473
51.79.29.216:38333 # AS16276
54.255.186.152:38333 # AS16509
63.34.82.20:38333 # AS8987
65.109.54.101:38333 # AS24940
67.209.52.138:38333 # AS20326
85.190.242.80:38333 # AS51167
89.155.238.72:38333 # AS2860
103.16.128.63:38333 # AS133159
104.248.42.204:38333 # AS14061
116.163.20.113:38333 # AS4837
121.78.241.71:38333 # AS9286
124.156.198.249:38333 # AS132203
18.142.242.1:38333 # AS16509
34.171.112.142:38333 # AS396982
35.217.13.118:38333 # AS15169
38.247.82.124:38333 # AS174
45.94.168.5:38333 # AS400810
51.210.144.135:38333 # AS16276
54.151.174.170:38333 # AS16509
66.254.43.122:38333 # AS1403
72.48.253.168:38333 # AS7459
81.17.97.236:38333 # AS51167
91.134.73.14:38333 # AS16276
95.141.35.117:38333 # AS31034
129.226.149.150:38333 # AS132203
131.153.11.131:38333 # AS20454
135.180.99.74:38333 # AS1299
136.144.237.250:38333 # AS20857
143.42.65.56:38333 # AS63949
144.24.238.157:38333 # AS31898
144.24.241.206:38333 # AS31898
148.51.196.40:38333 # AS12025
152.53.3.192:38333 # AS47147
144.76.2.169:38333 # AS24940
147.182.229.68:38333 # AS14061
152.53.52.229:38333 # AS214996
153.126.143.201:38333 # AS7684
159.203.133.144:38333 # AS14061
159.223.59.213:38333 # AS14061
170.75.172.6:38333 # AS174
172.105.179.233:38333 # AS63949
174.50.212.60:38333 # AS22909
175.110.114.74:38333 # AS49981
178.250.189.42:38333 # AS214379
185.148.37.170:38333 # AS48347
202.182.105.108:38333 # AS20473
205.209.114.30:38333 # AS19318
178.250.189.42:38333 # AS203394
188.213.140.180:38333 # AS197922
194.163.134.64:38333 # AS51167
195.201.164.54:38333 # AS24940
202.61.205.162:38333 # AS197540
206.162.217.86:38333 # AS7871
208.68.4.71:38333 # AS397444
[2001:19f0:4400:63c7:5400:4ff:fecc:fc1e]:38333 # AS20473
[2001:19f0:7001:48b2:5400:4ff:fecf:6e5]:38333 # AS20473
209.141.62.48:38333 # AS53667
213.22.195.68:38333 # AS2860
[2001:41d0:304:400::d0a]:38333 # AS16276
[2001:41d0:306:4505::]:38333 # AS16276
[2001:41d0:347:e00::]:38333 # AS16276
[2001:41d0:403:4ecb::]:38333 # AS16276
[2001:41d0:800:330f::]:38333 # AS16276
[2001:5a8:4164:7a00::506]:38333 # AS7065
[2001:5a8:4164:7a00::1f8]:38333 # AS1299
[2400:8907::f03c:92ff:fe6f:ee2b]:38333 # AS63949
[2401:2500:102:3007:153:126:143:201]:38333 # AS7684
[2604:a880:4:1d0::352:6000]:38333 # AS14061
[2604:a880:800:14::3880:3000]:38333 # AS14061
[2605:3380:422e:1::50]:38333 # AS397444
[2607:5300:203:7467::]:38333 # AS16276
[2607:5300:203:a29e::]:38333 # AS16276
[2607:5300:205:300::1b0]:38333 # AS16276
[2607:fdc0:1c1:5:632:1ff:fe54:ba56]:38333 # AS20326
[2620:6e:a0a0:1::71]:38333 # AS397444
[2a01:4f8:121:4072::2]:38333 # AS24940
[2a01:4f8:13a:c56::2]:38333 # AS24940
[2a01:4f8:2190:1692::2]:38333 # AS24940
[2a01:4f8:190:72a4::2]:38333 # AS24940
[2a01:4f8:2190:29b0::2]:38333 # AS24940
[2a01:4f8:2220:1a70::2]:38333 # AS24940
[2a01:4f8:231:3d6f::2]:38333 # AS24940
[2a01:4f8:242:4246::2]:38333 # AS24940
[2a01:4f8:c17:bff8::1]:38333 # AS24940
[2a01:4f9:3080:3496::2]:38333 # AS24940
[2a01:4f9:1a:aa95::2]:38333 # AS24940
[2a01:4f9:3a:2496::2]:38333 # AS24940
[2a01:4f9:6b:301a::2]:38333 # AS24940
[2a01:4f9:6b:47ce::2]:38333 # AS24940
[2a01:4f9:4b:470d::2]:38333 # AS24940
[2a01:7c8:d008:e9::3]:38333 # AS20857
[2a02:29e0:1:420::64]:38333 # AS49367
[2a0c:b641:6f1:6::2]:38333 # AS214379
2ycyu2aba3xsqjr35beqporp5f64ntqs2sau2amn5ztq4j5q76amhqyd.onion:38333
3qeedpzgciv65tdy2tsdmjxswhyep4aj65jtboznf5nnwcyo2lbmiyqd.onion:38333
3xvum5nnvcchvfxwlbc2it7nbfxhml6ovt7xehjw2potempk2om4eoqd.onion:38333
43nk7wpojel47fmc2il4sunwkpj4d2sh5rpeconlymplvuf7mwvnidqd.onion:38333
4lrtpspzigxrso22dy4ux23ad5gxrs7z562azclspfhil5w55jxpnhyd.onion:38333
4n2rlrrnxcpnfrft4ivlsvsjiahk5ffxizcyfr5amjcqfwt4biitjpid.onion:38333
5ofovtlx424wnxyoohnsxqjktwqd4i2kiqawox3srsdttsp2pdrx6yyd.onion:38333
6fy45vxzgc6siecr7en4k6oft4k4ix47jvkxqyzopalzwyphqc3hv2ad.onion:38333
6ivh4quupqu3w3glr2puyi5bitjapbbl6ehvbjsvleopyy2yzjgp4oqd.onion:38333
7mgfpo4urwysuafbo6sb3u6vh5f7pkvgddrqohcobhbkblqrrozhn7ad.onion:38333
75ucqkuqndevjaqjnyfgyhzdfgcnknr6ki3skvkqjlxnrcfqc6wxqbad.onion:38333
a7mvea5xgpknsqaifyvfstdn2utjvph564i6ti3nbdr2cksby5jhykid.onion:38333
b3sbqhjstq34ae7lsrw3syhxcjdu2ssuf3f3kvbnyrvbp7cvuuopmbqd.onion:38333
b6lyxzxr2xmzmdy7543renqfe2btqopjptilw4wxgzoyftazzspwq5id.onion:38333
b6x3qw2ibiycnj67jww3sjvkokq4ssxdvj7vetq7s64fhet75zat5cad.onion:38333
ba3rwqombmuji3wxpmydrk7vcxfpq7pnn5bfw74wvvqyo6rrhwqrt6id.onion:38333
bodh6zsjtn6kvdk36ukx6fns5hqiiw3zhkqmcmj54nrtkz5tdtb6yayd.onion:38333
bux5jwkwzccba57zthctdgsuwp5mi3wocxndtuf6jg2qqab3vpnqnqqd.onion:38333
bxctkglm5qyt2ubhu4je35irvvcnjrjydl2p6ywfelo7fnjw2exoehyd.onion:38333
ckbugjazj2iotosxah7odbxfozxivuk6zu5npf3iwfphvoh5brdjfqad.onion:38333
cq3td34eu5xjymlxl7aq4rsskxjt4ag267i6mzhdqhdpfzcqctus6aid.onion:38333
d27tvdmi6wjjlffjyhm5mogwsw3433jxkaiwhti32eagvljdzseilqqd.onion:38333
dpzlvj7kmbifhbttfe7vwl6fgpy5os62iiznel6eocsaarssudtdzoyd.onion:38333
e6xhvtrt2ppjfxckbinu7a4jxmy7usjnvjx6st2cipmvlnnhxg7krbid.onion:38333
ecx2z3x4nwbzjh6dh6vyccljkhnxya2o2o2tz3pzvetxfjjmujxhctid.onion:38333
ehnxcigc6t34smlk5lftfyb7rntcsbwhlu3pe7ltft76gl6y262ekdqd.onion:38333
ejgeimjypsfuijpxzy5xpwmmjmkr4izwze6od5pw74csjglflib6nsid.onion:38333
eqhrqtvxkyjcggbkmzgocynaskblynl2bqeuel4lqs4w3f3rgpfpnkad.onion:38333
f7xfq5hijqptsdak6qjx3komxrff2hw3xa46d7cs3d7igvm5tylotbid.onion:38333
fo7cekwzd3ibyoxuo53mfqoxffgfaupg5ydxbl3rofvwxtzbvgy3ciqd.onion:38333
fqyzt7wikf6g6yxu6i2yar3lkqxbf6fu3c3pjnbg2oibt57usfmq42id.onion:38333
gd4gyokpcnnqqodklhltjimcrhhmqj7otwlzrolw76aag4leqsyolxad.onion:38333
hm7i5k5o37ffzytt5eym2muzlj7r3xw6sisafnb6s2lhvraqbma2azqd.onion:38333
hztyx76iaz4h3emavmzbuizqfg3q37ehfwr2k3afadtcmcepjsxhmeqd.onion:38333
immdwqfyz2hhcmxmyypstz7syq2cygaklr43mqjmqefnmtcyuspwkbad.onion:38333
jahtu4veqnvjldtbyxjiibdrltqiiighauai7hmvknwxhptsb4xat4qd.onion:38333
jgn75dy52o2lt5wr5qkf4z2cg7gupz4jc4z5az53srhxxyvkipqqqpid.onion:38333
jw6d7rlkcz252f6wv6cirzzrknzuu7xwxnzirab4c5x7wfzl2uzvezad.onion:38333
k4d6h4eyeqjn35b3x46f4s3g3eykn4bms52paxuxenkre6nmhfvy6bqd.onion:38333
k6z3aojwz2jngg5bumtf7qphcwvvve3idqol27s7slg2p3tp3yrbqsqd.onion:38333
kklfzzodnlinc3toltn7dlft4vzjf2ckmdw2n3dn4lx3pzw5di2womyd.onion:38333
lbfzxmkog5ntvcmo7ncsp7ye62onxprf3a42hdzxkjw4inulizd4ccid.onion:38333
litqgemqmpesu6gi2ctd4ubrpxdn4mcm2t6p7xhkfxnkk7lzpdx75vyd.onion:38333
lkgnafoa5nfd34pzyxpz5gnmpwkbdk5a5h6h7hk3rs53soh6nkb3snqd.onion:38333
lwiqghlmljzlarwn4gwdrvskd3nibtw63o5ok7ugx4nwuvh7b422ifad.onion:38333
lxied2447sbmnoi64xbrdtcekdfyneoo3xb3m6vscj452orvdi2cjsqd.onion:38333
n6tf5dfz25i4pprczevdkyo5bkpgfa3xigenn6skpjqqynbxpxzilfid.onion:38333
nhpn5jnzl64wuhke22bl3avgm7liycl2h2fqh5a5tjtejez6upze4tid.onion:38333
o2fumu43ugk6xayo2nvadn7ohqlxharakt4flqh3hjgxdbwzrwignmyd.onion:38333
oowqbk36g76cs37sk7myfoq62e7ly42etcfugol3p7haw6ewyn5qhiqd.onion:38333
ouohm2bcplkfvzgg4f5ltvtqt2obzyvaadb3jep7bb4gasdusqkkupad.onion:38333
oz5puzgtybzjisyw5kimddtmsnc32zwflkj5r43clfddawunk7wtsiad.onion:38333
pkpiv6cqqba3mb5cpccdvz5v5p3u5acrjv2zj2u4auzznceqculjrkid.onion:38333
pmjm644pzkp2khwixyis2c7mnfbte33bnmwxdx5lk6t6owvtmapdbhqd.onion:38333
q3z526imdoo2pdujkfp5vslshni2niewlbxfokejfkddkezxutagezyd.onion:38333
qpgnrxuwxc6474hvy3j5uk2hbm3ry4ikwrenoit6zjeqqqythsvjdvid.onion:38333
qzf5vm2exowrli5ksuowrhshtnef43exhtha76qdxz357hdqfq65zhid.onion:38333
qbjhndk6zjpzxfetanqjud3u6kiuspnjfapinw2r5cou6o5ae5mxdzid.onion:38333
r4y5pqyvdzq3bzg2fqu46ql4a32fadkftwejtxzckeyohd7wvqnnwtqd.onion:38333
sver4nn4i5i7klvvayqopjbk5eyu7lcrrhcchxmrouom224hrnarl6qd.onion:38333
tev7cdwka3av6ektydsjfpofmcam3r6qcw7sxbpkohckjvihtzp7hgyd.onion:38333
tgqpfwoxjidlwd5rgpj5zfuhctxrevsfueqndih4vx5hgxpmyg34jqyd.onion:38333
tsq7clffbfe636zfszymheqgy6tyzbsjogad2qet7qeijua5c53ye6ad.onion:38333
@ -133,8 +116,8 @@ wevmujl2p6mckcwaxnmtusweros7bu3bxf2g3lzutnfdkjl5gwbu36yd.onion:38333
ww4jycomjwnf7jtrrrngeahokqkcl32iufmjzvvk272svieavabjyiqd.onion:38333
xbulvl2bb4wvnlafmq3j3fzrjhsmnfz7ubyvl6yy3syeded4tqiubkad.onion:38333
xm4kxluodmeolmaugmaxnexnefrg3vsxnqo2ezu7rqmdct7i7xevcxad.onion:38333
y5f4rtma4uneqrkzkoghoiec2sy3mee44xs466hhsi74w5roccqxlzqd.onion:38333
xtmr2yizi5zibbapqdqedeu5whn2oy5cpy2zz7ea5adpcdo2nz4qyzad.onion:38333
yjhagyj65xcxu6b5yktu6ntkwsyd5rhjlrsb7sexq5lzchatdqmoqnqd.onion:38333
ykeyrl6bidrfexbjicdzgnx6lh5efwhe4sj5inpgiufwa5cdhjpgugid.onion:38333
ypi6qgnmabcqlmjfkcnqzpjdjihwmebxkd32tjwt6mrhgm2strfml6ad.onion:38333
yrzulzu5xxcd2vio34ciyj5h7bpnevikslbunm6yb4tjkty62fxl7uid.onion:38333
zgkvv542e4ewviremw3qp4bi52f2sxt4g4mrjrbwonbnfb5oujd44lid.onion:38333

View File

@ -1,219 +1,179 @@
[fc10:efa7:ca6:1548:f8c:6bb9:1cc4:63ae]:18333
[fc1f:22c3:95dc:a3af:4a93:8251:beb9:1858]:18333
[fc2b:f62e:6a76:cdb5:dceb:2fdd:a0f8:3d88]:18333
[fc32:2c16:d0d0:f1fb:3b27:c187:8cb5:9201]:18333
[fccb:248:11a6:1042:bca:1218:f7ce:7d3d]:18333
66lkz2cfzyrz3tde6gflrty63jqr4knyy6uv4dvldrsecpnfx4dq.b32.i2p:0
hedmbfis4h4inqrwo2uzmku5xu6xaq74tg7sofnetqikdvndtvja.b32.i2p:0
i7vrfdmgolc6dqfmsak5fvwgmn46y4ghtan44uhn2aw66cbk5nfa.b32.i2p:0
ica24vnstxip7gkr3c6dlmqgw4opmfrvv3dppjds7a3uddurpmxa.b32.i2p:0
nhla3xzibmhvav7meemluh2d2jxdrlwicq636a2sohwqhrfgqi4a.b32.i2p:0
o6j3b33bv26vthoqzjy3h7a3qsuqbtbe3ulajmjzsl43vaqyieyq.b32.i2p:0
ocqipbbxx4paopgkkbnj234ie7opzrtca5gtiwr6oda3h32rzgsa.b32.i2p:0
xgctj4seo3ofstiymoyeuzq74bvddrbr6jtia6erodlf5va3cz5a.b32.i2p:0
xy6ytjxel5ku4naqumj4f6hn4agrzh3w44gqcs6xkkzwm5s3jdgq.b32.i2p:0
zklt7hncdrl2hupfwnlbt3qaayhjayjhvwvj2m3fok3z36tlnxhq.b32.i2p:0
2.59.133.20:18333 # AS58212
2.86.50.136:18333 # AS6799
4.246.195.240:18333 # AS8075
5.39.218.162:18333 # AS57043
5.255.97.91:18333 # AS60404
3.126.103.252:18333 # AS16509
5.255.97.92:18333 # AS60404
8.217.160.32:18333 # AS45102
18.168.119.254:18333 # AS8987
18.209.9.240:18333 # AS8987
5.255.99.130:18333 # AS60404
20.238.17.253:18333 # AS8075
23.227.223.209:18333 # AS44486
27.148.206.140:18333 # AS133774
34.65.45.157:18333 # AS396982
34.69.221.24:18333 # AS396982
34.254.97.244:18333 # AS16509
43.133.47.138:18333 # AS132203
43.247.184.50:18333 # AS23724
44.208.161.158:18333 # AS14618
34.57.91.248:18333 # AS396982
34.136.139.120:18333 # AS396982
35.89.140.96:18333 # AS16509
45.77.25.14:18333 # AS20473
51.79.82.75:18333 # AS16276
52.193.79.181:18333 # AS16509
54.236.59.55:18333 # AS14618
59.186.7.131:18333 # AS3786
54.87.140.128:18333 # AS14618
57.129.97.56:18333 # AS16276
62.210.207.63:18333 # AS12876
66.94.114.229:18333 # AS40021
65.21.205.60:18333 # AS24940
67.4.82.9:18333 # AS209
69.61.32.242:18333 # AS141518
69.197.185.106:18333 # AS32097
70.114.196.140:18333 # AS11427
72.211.1.222:18333 # AS22773
73.22.9.231:18333 # AS33491
72.48.253.168:18333 # AS7459
74.48.195.218:18333 # AS35916
74.118.136.46:18333 # AS20326
85.203.53.149:18333 # AS39351
75.119.158.18:18333 # AS51167
77.163.221.171:18333 # AS1136
82.121.197.91:18333 # AS3215
82.181.221.241:18333 # AS16086
85.208.69.12:18333 # AS42275
85.208.69.13:18333 # AS42275
89.58.9.219:18333 # AS197540
89.155.238.72:18333 # AS2860
90.79.184.226:18333 # AS3215
91.109.204.214:18333 # AS199669
89.169.131.69:18333 # AS200350
90.38.214.224:18333 # AS3215
91.123.182.164:18333 # AS51648
92.115.99.159:18333 # AS8926
95.141.35.117:18333 # AS31034
104.243.38.96:18333 # AS23470
122.208.117.197:18333 # AS17506
124.236.16.91:18333 # AS134760
129.153.149.46:18333 # AS31898
129.213.114.91:18333 # AS31898
129.226.198.211:18333 # AS132203
132.145.129.60:18333 # AS31898
134.195.89.130:18333 # AS63473
135.180.99.74:18333 # AS1299
137.184.2.124:18333 # AS14061
141.98.219.199:18333 # AS20326
147.182.251.92:18333 # AS14061
148.51.196.40:18333 # AS12025
148.251.4.19:18333 # AS24940
149.202.79.199:18333 # AS16276
161.97.119.128:18333 # AS51167
162.55.243.11:18333 # AS24940
169.155.171.252:18333 # AS44486
176.108.193.97:18333 # AS47914
142.234.33.228:18333 # AS7979
148.113.218.157:18333 # AS16276
152.67.82.60:18333 # AS31898
157.90.95.170:18333 # AS24940
160.80.11.66:18333 # AS137
169.155.170.211:18333 # AS44486
172.173.81.233:18333 # AS8075
173.231.40.170:18333 # AS18450
178.162.218.121:18333 # AS28753
185.28.96.16:18333 # AS59845
185.44.206.111:18333 # AS44051
185.107.68.135:18333 # AS43350
185.130.224.146:18333 # AS57043
185.186.208.124:18333 # AS206428
185.210.125.33:18333 # AS205671
185.232.70.226:18333 # AS197540
186.154.207.228:18333 # AS19429
188.117.132.82:18333 # AS31242
188.42.129.156:18333 # AS7979
188.72.109.51:18333 # AS208677
188.213.90.149:18333 # AS206238
193.30.123.70:18333 # AS197540
194.9.6.11:18333 # AS58212
194.95.66.129:18333 # AS680
194.110.169.133:18333 # AS203576
195.154.241.13:18333 # AS12876
200.143.224.99:18333 # AS1916
194.145.201.243:18333 # AS29028
195.66.213.33:18333 # AS43641
203.132.94.196:18333 # AS38195
205.209.120.167:18333 # AS19318
206.204.104.7:18333 # AS212947
208.68.4.71:18333 # AS397444
213.199.42.73:18333 # AS51167
208.91.104.61:18333 # AS20326
209.38.135.43:18333 # AS14061
216.219.91.82:18333 # AS19318
219.117.221.162:18333 # AS2514
[2001:41d0:303:146e::]:18333 # AS16276
[2001:41d0:306:4505::]:18333 # AS16276
[2001:41d0:306:a3a::]:18333 # AS16276
[2001:41d0:700:544c::]:18333 # AS16276
[2001:41d0:340:c000::]:18333 # AS16276
[2001:41d0:72a:3100::]:18333 # AS16276
[2001:41d0:72a:3800::]:18333 # AS16276
[2001:41d0:800:1d55::]:18333 # AS16276
[2001:41d0:800:3e7f::]:18333 # AS16276
[2001:470:1f05:4e5::2020]:18333 # AS6939
[2001:5a8:4164:7a00::506]:18333 # AS7065
[2001:5a8:4164:7a00::1f8]:18333 # AS1299
[2001:b07:6469:3491:56be:f7ff:fe26:21bb]:18333 # AS12874
[2401:c080:1000:4cb2:3eec:efff:feb9:8604]:18333 # AS20473
[2401:d002:3902:700:8708:37c4:e231:d3d8]:18333 # AS38195
[2402:1f00:8101:713::]:18333 # AS16276
[2402:1f00:800a:1800::]:18333 # AS16276
[2402:1f00:800a:1c00::]:18333 # AS16276
[2604:1380:4531:1700::5]:18333 # AS54825
[2604:a00:50:58:216:3eff:fe2c:8371]:18333 # AS19318
[2605:3380:422e:1::50]:18333 # AS397444
[2605:4840:3:2c23::1]:18333 # AS63473
[2605:a141:2239:7674::1]:18333 # AS51167
[2607:5300:205:300::1b0]:18333 # AS16276
[2607:5300:60:85a9::]:18333 # AS16276
[2607:5300:60:8702::]:18333 # AS16276
[2620:6e:a000:1:43:43:43:43]:18333 # AS397444
[2607:5300:216:a600::]:18333 # AS16276
[2607:5300:21b:9d00::]:18333 # AS16276
[2620:6e:a0a0:1::71]:18333 # AS397444
[2804:431:e038:cd01:aaa1:59ff:fe0d:44b8]:18333 # AS27699
[2a01:4f8:121:4072::2]:18333 # AS24940
[2a01:4f8:160:1083::2]:18333 # AS24940
[2a01:4f8:173:1ed8::2]:18333 # AS24940
[2a01:4f8:173:230a::2]:18333 # AS24940
[2a01:4f8:190:4026::2]:18333 # AS24940
[2a01:4f9:2a:309d::2]:18333 # AS24940
[2a01:4f8:201:508f::2]:18333 # AS24940
[2a01:4f9:2a:2510::2]:18333 # AS24940
[2a01:4f9:3070:26e2::2]:18333 # AS24940
[2a01:4f9:3071:2154::2]:18333 # AS24940
[2a01:4f9:3071:219d::2]:18333 # AS24940
[2a01:4f9:6a:13c3::2]:18333 # AS24940
[2a01:4f9:6a:4891::2]:18333 # AS24940
[2a01:4f9:6b:2768::2]:18333 # AS24940
[2a02:c202:2238:2255::1]:18333 # AS51167
[2a02:c206:2239:7671::1]:18333 # AS51167
[2a02:c206:2240:1506::1]:18333 # AS51167
[2a03:4000:2a:514::]:18333 # AS197540
[2a01:e0a:98e:7450:be24:11ff:fe4a:7bc2]:18333 # AS12322
[2a02:29e0:1:420::64]:18333 # AS49367
[2a02:c206:2075:3352::1]:18333 # AS51167
[2a04:52c0:102:2219::1]:18333 # AS60404
[2a04:52c0:102:49af::1]:18333 # AS60404
[2a04:52c0:104:160c::1]:18333 # AS60404
2lsncqdflwk272dhydrxf7ikfy23ppnmm54dnynyxiym6lqf3wowrmqd.onion:18333
2mvycpm7ni6ix2pr4lkkfkqlivgo77mt4jx3s3dmhdlg3ogq46s6qbyd.onion:18333
36fwktckggarkclbpu2pumsdpck46ahe6cwpozd2gm6q7kgdqljclmad.onion:18333
3dt6kgfrilc3nwliwy5wbmc6oa2b5y3t33nkxlrxrkunr2hoaj56kgyd.onion:18333
3rfphqncnepbm7tvnaqjetkaqvauj566nw3ys27fert6zx3q75zetoid.onion:18333
3vnbi5o3hyzk4cm3hhnyo3h7tclr6pybmhmqwkbyclslfhqtg72pq2id.onion:18333
44sgcv5dvpplt32enlneddyl4gd4z3tbezl2scedwccndyzrrp6lcgyd.onion:18333
4w3f2mxe4ftodocermsazs3qlpo37igkdgne6ka2p6wnnrgwpzqw65yd.onion:18333
5axx4qyub7qtgssrvbbqudu6uqjbuknbvbld2wdscv5p6kh2hsfzjxqd.onion:18333
5qdgulsryjejkjinocpvknazwtnbqtuf4f4pui2at4jpedwwpg427qyd.onion:18333
67l6l2k7mqbl2btyvo5h5lki3kxcrgbunlk7brcloyaoaftbs5mnsuad.onion:18333
6bhop3n32rreiynu35epznhc2exxkhuleromdhnida2hgmu2bhczgmqd.onion:18333
6fdbuqf2kgeweeoeikmwfezauys657lzezzus4nxmekkumouptg5ezad.onion:18333
6rnqpqqcpllqhjoa4gwrtq5yi6fdch6uqzapdee2gq67gxgsl73v4uqd.onion:18333
6yuphwecg6apx3nrf6kyabqohh544l25xodxxowa74yr2tg5ulkzeead.onion:18333
7ph7mrc24te57mvppajfkfj4mk7zuz4teukymt3wgpdpw6vpndeivtyd.onion:18333
7poqajl6svz4vr3aqi7vdtar2t56crbrtj6yi75ydrt3ighyx7q6qvyd.onion:18333
7zlqrihb5do5ebbmjwgspxigqfdmkfslkqtg2ngdc6ypsunzb4iootqd.onion:18333
aesy6tfufadkut6flu2bsqgnw2422ur2ynjalguxlzuzuktg3zehttqd.onion:18333
axaaplqtf4z22xfj2j2xn6fhtj6ksv74bs7vae6rfw67qofdnqoacbid.onion:18333
ayx35r2mhwydczzoqu7b6dl3sup4oht74sgnlrjkxybzh2hmfnaix3qd.onion:18333
bizdwmm7naqq5pehkbfggznqtena5eodz3kprvsbj4nkkax4fvxx53id.onion:18333
bjqttlyt5kxcn7sitpiavf2cuhdf6rlwigericlh7um7gzkqyyefqnqd.onion:18333
bkzo7mpxuar7rhsbiwdaxqcymixarcbdmb3sdaqtv6yb2svqttz2s6ad.onion:18333
bzn63lsmsuvzlg4uqadyylxaggdcrzkb56muw2b43ft5qkynvzfopbyd.onion:18333
c7zrq2yqt6rtn5dxkczp5bv62k2jncv3mscoo24c24rljbplr2dvhsid.onion:18333
d63vf45ta4chrewnruyvypm7ybfxtut327crtq6qfyrvcwx434rli5qd.onion:18333
devwork6shguhs6miygeq7qpyszu2lizeyop33sbrey7hk53jw26hnad.onion:18333
dskf46hfkefyr6nio5gtqp7em7rh6aqwrugdegfooaoxcux5ym6bkuqd.onion:18333
euvmh5f637qwqgktjs5zwauvayybfdkiopnflnh5yjt7ouqat3427pqd.onion:18333
e7sseh62snwmipkyuv4mrhdbc5ew7ysyzv34fhjjgxuc6rdvj57vgnid.onion:18333
f472j4pynbgltb63mr2lhyvhecfqdjdcfmr2s2id4rreemyn32xtjuid.onion:18333
fbimesnyhzubbzqc3uaufzkbyfmnkxvypoxaveaub7rzpzh2foxrn2yd.onion:18333
gggan3nuzxpd655lafnsunqfxgy56bvsxuuzucgmaowyvq3d7a7o7jad.onion:18333
gsw6sn27quwf6u3swgra6o7lrp5qau6kt3ymuyoxgkth6wntzm2bjwyd.onion:18333
guudgx24aokistytvm3hj7u5cbvdkr2b643r5t33pa536ekfn2lfykid.onion:18333
gwtx5qluopwaxjhedlifnr6pptw2eihojzhq3stnv2gfbvqbgqdhi5qd.onion:18333
gy6nih4pmp5esyvvnhlj6qvk7zkbjuoswkxffyiip3dbkvsfxwz5zcqd.onion:18333
hj2txlxajdlh7jsfwqxtp3cltlptsr33ctjkbxhbzbyirkmcpfhsnyad.onion:18333
hjwzovgwou3py6ncemgmzpvcihay5cuzuxvqdn74axndmll25p4mwjqd.onion:18333
hqkdgpzzsv2qvafhdkdocszquj7o2ittxfmm5fc2arxqw7ikottozoid.onion:18333
htkiqaqoql7pjstenmw6v4blm6l57d6hl6mewxkmfi3qumozflx3gzyd.onion:18333
hvbmmzvqrpgps2x5u4ip4ksf3e5m2fneac754gtnhjn2rsevni6cz3ad.onion:18333
hvtxymvdb55u7lhdw6775akqy46inunl3uup27gnsxm2bqmv55wbacqd.onion:18333
i5fjp7ggx62zlfkibzn7s6glpjp3h2ypfom3lmqixig7qbdgej35wfyd.onion:18333
i5gphw2d224tniqkjebxdwz5ygbbo5gcushoyevv7x7o454b6qlrzeid.onion:18333
iysx2dl4tpojiclh32iyhel6z7h227c7o7buzk5wuqw6qhuytvsu66yd.onion:18333
j53y5paeb7xcrptntut7epccjglduquldjlzjlho4lj2msabnygrljqd.onion:18333
jsc4frvvnl2d3bhzyofsc72xpztgm23nl4fnb4dwkzsxr6fhij2q5iyd.onion:18333
jqos4drrg27j553syd4dfunajednqgz3w7y3cq2morckhc6ht7jm7aad.onion:18333
jtvqgaccxbtzshtulk5xlsb4wkoil3psmpn5avqyp2i5vm4hqh5cicyd.onion:18333
jun6gdmbgasr57bhr4zs3dfhc6pzpaw27nqb4dadbai7yrbq55zskeid.onion:18333
kamanho5clcpn5l3sc6ih3vb4skmfhgxw3h2mgs7e5idfezu5dw5oxyd.onion:18333
kwjxlauwjtecjfsiwopbl5pvn5n6z5rz76uk6osmlurd3uyuymcw7aid.onion:18333
lh3wfz2n7xe2muwdjrz5vgnjwjx7lc6iifojhr2rh53ojkwo5dr66uyd.onion:18333
lka74booetkbmat2q64haawcytbwx7mnctvo63ww4jgi4yuqnl6p3kad.onion:18333
lwfecq35ocqjfbdq4h2qmcwl3cfcyiyycxtvrz36ihdbuczehi3bmrad.onion:18333
n23anw4zb7f3paroac626oc2sqy3yn5kjfpcqvb3lvdyx7dzzpovd3id.onion:18333
n4e6fp6xoyo2glsafjwbaq3wirhldpjw4mskn5lzkm4o5lhh5n5k7uqd.onion:18333
nmazvezejolohnbza4rmqrwvjcprhi7w22fqvlbxp5sw3c25xy3dunqd.onion:18333
nyrekcbm2ici6wv2umogtmwg7o2ivu4vm7bpcge5fayos5l377zldlqd.onion:18333
o3zwhskjvuzbti3su3kfspgmvwoiq5iqw4drgo6jv6ehv2zfoyyy5nqd.onion:18333
o4fnldblck6fmycg55lh77owlw7wihb7qltjibantj45ijhow73otdad.onion:18333
o4zdqfdoe4jfvn35twqtjkzmptmk3bsg45sp46wuxanceg3euqtwdjqd.onion:18333
ohqcfz5kk6ufouxmhtq7nxyo2lyui4vjlhr2kftvra2ewgzxu3hsrxad.onion:18333
oobwtn5csi4auevb2ns2b5rrjnxmhlzdmay4zxtzvkj7tayrgwfddiqd.onion:18333
pcbipn5yyvhsedfjjywrcep4b5z43px7duemxvs7e6tvanxgw46ux7ad.onion:18333
pj2rxq2sfbwtsqqcbnfnwkg36d72yce56qmp2sjjmb7hvzpzai3ndead.onion:18333
ppe2pepzphox3swftj5lbyi7ckigspbih5qnyuhrb3r6bn3g7k7bp4qd.onion:18333
pqkhkpkvqmjcql5jccyxg5nahow6vixnjrvtsc6clnk7dab4weknvpqd.onion:18333
q5qox756id5nfdu6ht4dghc35jezls4bgjcdnrds3pwndvdx32zmwlad.onion:18333
qiep4hvuovedbbc36hl7nwslwi6ah6uw4nnseyjdtc73cc5rfdauvnad.onion:18333
qzx5f2ig2rk2ssrbopz2zlljq5mkeh3izhhx3t3cepse5qnhvpo2tzid.onion:18333
rfi2hdpjhhknalltbwdvyuhskh5yjs66rqzpy6ley7xtu4kvbeob6fqd.onion:18333
rw6reu6rdetz6rnpzoyn2hfy7sxpbja4v5ktmaicqqgszi2eata5lhqd.onion:18333
s3bxrurro4bmvsmntw74qf4vw3xl25xtnvqegayvlwj3b6t7d76kkwid.onion:18333
slpigm5ep4zan3a65bybne67phjiyesbuk5s3bodefuhnx2cfdtit6qd.onion:18333
sxm6kwrdp6f2ggaozhrl47xuy3es3sgm3ivppmh4xm3hfmetvwbyrcad.onion:18333
syzdz6dzc5grlcnhbsbhye27i7dllgozqm3ocpyr6g3ynfrcf4ngzdqd.onion:18333
t6hfkkujktjyzpepmphskoaivflu6fieyuxrshxfzwriwvoa2uccvvqd.onion:18333
ueyykmnyqk2bnmbgvmqrb4jfbjvpgeew6cuq4gaqe7v2oiyxaubkx4qd.onion:18333
urhagmjceyqbzhjitpa7j7mygivxw3wlwqzkibw6zezrxeantkikgcyd.onion:18333
vctlwaqgmu53eutz2hewuakcipfgtyljsd7czut4dd62xr3rp6fqezad.onion:18333
vi3z4khdvopuiljdjdhpetnxztuzsct2aacuzcm5ba27h4j3cfwsvjad.onion:18333
vqnkdmpmecc5kondj32jwbemmruhmd5gkmfngkscetibzozryp4elkad.onion:18333
wgc4wp25gtnb54vd7x5h2xtetzrdoiizeyyh6fv3vxzp3bbalejbd3ad.onion:18333
wpsahjbejxehpz772kzxonj777pejol2akcicduqov2r7ktm2b6l5pid.onion:18333
wqx56diehvnwca6mndqw3omsufbiem3o6lwivauiilxfx5iqsv7emfad.onion:18333
wui5m2y5b7cms36ai6shzyqsg6qteejwmxsf26nyms6vcykxbvmh4uad.onion:18333
xafcyh6mxwebvcsgw4wcbuw7n4v7vbqhcznhwqcpqcu6dww2mjuw4nad.onion:18333
xlx7k5qzawdld5xcfd5lhhasp5tiklc2z326lamcnkmoru56jv6os6ad.onion:18333
y5h652jz6sgmb4bkcfnfxnj24gnczqf7lhd5lqbvdhf5mpll4gye5kid.onion:18333
ya6s7ov7myixz3ql23u45hty7moxo3r4d26qainw55z656vtau676xid.onion:18333
yda7kwpii33j2qpq32ftf6lp22znknswipjwaccvsqj7l337jvfesnid.onion:18333
zcsn3j6aswnrf56xj2n5jn4tlwmyoq4benjn5ujcgz46co2y5tm642id.onion:18333
zefnna2a3ga4ez2nutvypma7my35prw3ycinbqwva7v4pf3aurqhjcyd.onion:18333
zhiju2obxifqpjbcm6xtlgjdbof7jhoctvw3x57vhiftstb5hi3gmsqd.onion:18333
zkqddzui5pkrqvjj2zwsf5kln7stlbmw5pmn6ut46fobvzyv2sn2ryid.onion:18333
zmvizz7fd5hdue6wt3lwqumd6qwt4ijymmmotfzh75curq3mzjm53hyd.onion:18333
zmxlrzoxg4fmso6l2xuq5tdxmlyakdqellzujh3a23iuzg4zlatnogqd.onion:18333
zsmxmusdzrcqusk5h6syfq6a3ph6lwx3wpiltun4dmkrt3pa2fp7qaid.onion:18333

Some files were not shown because too many files have changed in this diff Show More