Commit graph

44524 commits

Author SHA1 Message Date
merge-script
e364e6b509
Merge bitcoin/bitcoin#32176: net: Prevent accidental circuit sharing when using Tor stream isolation
Some checks are pending
CI / Windows, test cross-built (push) Blocked by required conditions
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
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
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
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
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
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
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
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
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
Some checks are pending
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
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
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)
Some checks are pending
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
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
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
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 / Windows native, VS 2022 (push) Has been cancelled
CI / Windows native, fuzz, VS 2022 (push) Has been cancelled
CI / Linux->Windows cross, no tests (push) Has been cancelled
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Has been cancelled
CI / Windows, test cross-built (push) Has been cancelled
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
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
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
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