Commit graph

44344 commits

Author SHA1 Message Date
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
Some checks are pending
CI / test each commit (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Windows native, VS 2022 (push) Waiting to run
CI / Windows native, fuzz, VS 2022 (push) Waiting to run
CI / Linux->Windows cross, no tests (push) Waiting to run
CI / Windows, test cross-built (push) Blocked by required conditions
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
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
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
Ryan Ofsky
74d9598bfb
Merge bitcoin/bitcoin#32134: descriptors: Multipath/PR 22838 follow-ups
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Windows native, VS 2022 (push) Waiting to run
CI / Windows native, fuzz, VS 2022 (push) Waiting to run
CI / Linux->Windows cross, no tests (push) Waiting to run
CI / Windows, test cross-built (push) Blocked by required conditions
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
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
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
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
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
Hennadii Stepanov
4c1906a500
Merge bitcoin/bitcoin#31992: cmake: Avoid fuzzer "multiple definition of `main'" errors
Some checks failed
CI / test each commit (push) Has been cancelled
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Has been cancelled
CI / macOS 14 native, arm64, fuzz (push) Has been cancelled
CI / Win64 native, VS 2022 (push) Has been cancelled
CI / Win64 native fuzz, VS 2022 (push) Has been cancelled
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Has been cancelled
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
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / Win64 native fuzz, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
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
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / Win64 native fuzz, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
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
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / Win64 native fuzz, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
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
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / Win64 native fuzz, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
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
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
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / Win64 native fuzz, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
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
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / Win64 native fuzz, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
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
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