2298 Commits

Author SHA1 Message Date
merge-script
da6f041e39
Merge bitcoin/bitcoin#31645: [IBD] coins: increase default UTXO flush batch size to 32 MiB
b6f8c48946cbfceb066de660c485ae1bd2c27cc1 coins: increase default `dbbatchsize` to 32 MiB (Lőrinc)
8bbb7b8bf8e3b2b6465f318ec102cc5275e5bf8c refactor: Extract default batch size into kernel (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

  When the in-memory UTXO set is flushed to LevelDB (after IBD or AssumeUTXO load), it does so in batches to manage memory usage during the flush.
  A hidden `-dbbatchsize` config option exists to modify this value. This PR only changes the default from `16` MiB to `32` MiB.
  Using a larger default reduces the overhead of many small writes and improves I/O efficiency (especially on HDDs). It may also help LevelDB optimize writes more effectively (e.g., via internal ordering).
  The change is meant to speed up a critical part of IBD: dumping the accumulated work to disk.

  ### Context

  The UTXO set has grown significantly since [2017](https://github.com/bitcoin/bitcoin/pull/10148/files#diff-d102b6032635ce90158c1e6e614f03b50e4449aa46ce23370da5387a658342fdR26-R27), when the original fixed 16 MiB batch size was chosen.

  With the current multi-gigabyte UTXO set and the common practice of using larger `-dbcache` values, the fixed 16 MiB batch size leads to several inefficiencies:

  * Flushing the entire UTXO set often requires thousands of separate 16 MiB write operations.
  * Particularly on HDDs, the cumulative disk seek time and per-operation overhead from numerous small writes significantly slow down the flushing process.
  * Each `WriteBatch` call incurs internal LevelDB overhead (e.g., MemTable handling, compaction triggering logic). More frequent, smaller batches amplify this cumulative overhead.

  Flush times of 20-30 minutes are not uncommon, even on capable hardware.

  ### Considerations

  As [noted by sipa](https://github.com/bitcoin/bitcoin/pull/31645#issuecomment-2587500105), flushing involves a temporary memory usage increase as the batch is prepared. A larger batch size naturally leads to a larger peak during this phase. Crashing due to OOM during a flush is highly undesirable, but now that [#30611](https://github.com/bitcoin/bitcoin/pull/30611) is merged, the most we'd lose is the first hour of IBD.

  Increasing the LevelDB write batch size from 16 to 32 MiB raised the measured peaks by ~70 MiB in my tests during UTXO dump. The option remains hidden, and users can always override it.

  The increased peak memory usage (detailed below) is primarily attributed to LevelDB's `leveldb::Arena` (backing MemTables) and the temporary storage of serialized batch data (e.g., `std::string` in `CDBBatch::WriteImpl`).

  Performance gains are most pronounced on systems with slower I/O (HDDs), but some SSDs also show measurable improvements.

  ### Measurements:

  AssumeUTXO proxy, multiple runs with error bars (flushing time is faster that the measured loading + flushing):
  * Raspberry Pi, dbcache=500: ~30% faster with 32 MiB vs 16 MiB, peak +~75 MiB and still < 1 GiB.
  * i7 + HDD: results vary by dbcache, but 32 MiB usually beats 16 MiB and tracks close to 64 MiB without the larger peak.
  * i9 + fast NVMe: roughly flat across 16/32/64 MiB. The goal here is to avoid regressions, which holds.

  ### Reproducer:

  ```bash
  # Set up a clean demo environment
  rm -rfd demo && mkdir -p demo

  # Build Bitcoin Core
  cmake -B build -DCMAKE_BUILD_TYPE=Release && cmake --build build -j$(nproc)

  # Start bitcoind with minimal settings without mempool and internet connection
  build/bin/bitcoind -datadir=demo -stopatheight=1
  build/bin/bitcoind -datadir=demo -blocksonly=1 -connect=0 -dbcache=3000 -daemon

  # Load the AssumeUTXO snapshot, making sure the path is correct
  # Expected output includes `"coins_loaded": 184821030`
  build/bin/bitcoin-cli -datadir=demo -rpcclienttimeout=0 loadtxoutset ~/utxo-880000.dat

  # Stop the daemon and verify snapshot flushes in the logs
  build/bin/bitcoin-cli -datadir=demo stop
  grep "FlushSnapshotToDisk: completed" demo/debug.log
  ```

  ---

  This PR originally proposed 64 MiB, then a dynamic size, but both were dropped: 64 MiB increased peaks more than desired on low-RAM systems, and the dynamic variant underperformed across mixed hardware. 32 MiB is a simpler default that captures most of the gains with a modest peak increase.

  For more details see: https://github.com/bitcoin/bitcoin/pull/31645#issuecomment-3234329502
  ---

  While the PR isn't about IBD in general, rather about a critical section of it, I have measured a reindex-chainstate until 900k blocks, showing a 1% overall speedup:

  <details>
  <summary>Details</summary>

  ```python
  COMMITS="e6bfd95d5012fa1d91f83bf4122cb292afd6277f af653f321b135a59e38794b537737ed2f4a0040b"; \
  STOP=900000; DBCACHE=10000; \
  CC=gcc; CXX=g++; \
  BASE_DIR="/mnt/my_storage"; DATA_DIR="$BASE_DIR/BitcoinData"; LOG_DIR="$BASE_DIR/logs"; \
  (echo ""; for c in $COMMITS; do git fetch -q origin $c && git log -1 --pretty='%h %s' $c || exit 1; done; echo "") && \
  hyperfine \
    --sort command \
    --runs 1 \
    --export-json "$BASE_DIR/rdx-$(sed -E 's/(\w{8})\w+ ?/\1-/g;s/-$//'<<<"$COMMITS")-$STOP-$DBCACHE-$CC.json" \
    --parameter-list COMMIT ${COMMITS// /,} \
    --prepare "killall bitcoind 2>/dev/null; rm -f $DATA_DIR/debug.log; git checkout {COMMIT}; git clean -fxd; git reset --hard && \
      cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release && ninja -C build bitcoind && \
      ./build/bin/bitcoind -datadir=$DATA_DIR -stopatheight=$STOP -dbcache=1000 -printtoconsole=0; sleep 10" \
    --cleanup "cp $DATA_DIR/debug.log $LOG_DIR/debug-{COMMIT}-$(date +%s).log" \
    "COMPILER=$CC ./build/bin/bitcoind -datadir=$DATA_DIR -stopatheight=$STOP -dbcache=$DBCACHE -reindex-chainstate -blocksonly -connect=0 -printtoconsole=0"

  e6bfd95d50 Merge bitcoin-core/gui#881: Move `FreespaceChecker` class into its own module
  af653f321b coins: derive `batch_write_bytes` from `-dbcache` when unspecified

  Benchmark 1: COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=900000 -dbcache=10000 -reindex-chainstate -blocksonly -connect=0 -printtoconsole=0 (COMMIT = e6bfd95d5012fa1d91f83bf4122cb292afd6277f)
    Time (abs ≡):        25016.346 s               [User: 30333.911 s, System: 826.463 s]

  Benchmark 2: COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=900000 -dbcache=10000 -reindex-chainstate -blocksonly -connect=0 -printtoconsole=0 (COMMIT = af653f321b135a59e38794b537737ed2f4a0040b)
    Time (abs ≡):        24801.283 s               [User: 30328.665 s, System: 834.110 s]

  Relative speed comparison
          1.01          COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=900000 -dbcache=10000 -reindex-chainstate -blocksonly -connect=0 -printtoconsole=0 (COMMIT = e6bfd95d5012fa1d91f83bf4122cb292afd6277f)
          1.00          COMPILER=gcc ./build/bin/bitcoind -datadir=/mnt/my_storage/BitcoinData -stopatheight=900000 -dbcache=10000 -reindex-chainstate -blocksonly -connect=0 -printtoconsole=0 (COMMIT = af653f321b135a59e38794b537737ed2f4a0040b)
  ```

  </details>

ACKs for top commit:
  laanwj:
    Concept and code review ACK b6f8c48946cbfceb066de660c485ae1bd2c27cc1
  TheCharlatan:
    ACK b6f8c48946cbfceb066de660c485ae1bd2c27cc1
  andrewtoth:
    ACK b6f8c48946cbfceb066de660c485ae1bd2c27cc1

Tree-SHA512: a72008feca866e658f0cb4ebabbeee740f9fb13680e517b9d95eaa136e627a9dd5ee328456a2bf040401f4a1977ffa7446ad13f66b286b3419ff0c35095a3521
2025-10-31 13:13:53 -04:00
ismaelsadeeq
ab49480d9b fees: rename fees_args to block_policy_estimator_args
- Also move them to policy/fees/ and update includes
- Note: the block_policy_estimator_args.h include in block_policy_estimator_args.cpp was done manually.
2025-10-27 10:44:18 +01:00
ismaelsadeeq
06db08a435
fees: refactor: rename fees to block_policy_estimator
- Also move it to policy/fees and update the includes
2025-10-27 10:41:02 +01:00
Ryan Ofsky
b0113afd44 Fix windows libc++ fs::path fstream compile errors
As reported by hebasto in https://github.com/bitcoin/bitcoin/issues/33545,
newer libc++ versions implementing https://wg21.link/lwg3430 will no longer
implicitly convert `fs::path` objects to `std::filesystem::path` objects when
constructing `std::ifstream` and `std::ofstream` types.

This is not a problem in Unix systems since `fs::path` objects use
`std::string` as their native string type, but it causes compile errors on
Windows which use `std::wstring` as their string type, since `fstream`s can't
be constructed from `wstring`s.

Fix the windows libc++ compile errors by adding a new `fs::path::std_path()`
method and using it construct `fstream`s more portably.

Additionally, delete `fs::path`'s implicit `native_string` conversion so these
errors will not go undetected in the future, even though there is not currently
a CI job testing Windows libc++ builds.
2025-10-06 11:25:56 -04:00
Ava Chow
cc4a2cc6bd
Merge bitcoin/bitcoin#33453: docs: Undeprecate datacarrier and datacarriersize configuration options
451ba9ada41f687c0e4bb34d5925374a68a8f8a3 datacarrier: Undeprecate configuration option (Anthony Towns)

Pull request description:

  Removes the deprecation for the `datacarrier` and `datacarriersize` options by reverting commit 0b4048c73385166144d0b3e76beb9a2ac4cc1eca 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 451ba9ada41f687c0e4bb34d5925374a68a8f8a3
  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 451ba9ada41f687c0e4bb34d5925374a68a8f8a3 on removing the deprecation.
  instagibbs:
    crACK 451ba9ada41f687c0e4bb34d5925374a68a8f8a3
  Raimo33:
    ACK 451ba9ada41f687c0e4bb34d5925374a68a8f8a3
  Ademan:
    utACK 451ba9a
  ryanofsky:
    Code review ACK 451ba9ada41f687c0e4bb34d5925374a68a8f8a3
  marcofleon:
    ACK 451ba9ada41f687c0e4bb34d5925374a68a8f8a3
  achow101:
    ACK 451ba9ada41f687c0e4bb34d5925374a68a8f8a3
  moonsettler:
    ACK 451ba9ada4
  ismaelsadeeq:
    utACK 451ba9ada41f687c0e4bb34d5925374a68a8f8a3 🛰️
  jonatack:
    ACK 451ba9ada41f687c0e4bb34d5925374a68a8f8a3
  Zero-1729:
    crACK 451ba9ada41f687c0e4bb34d5925374a68a8f8a3
  vasild:
    ACK 451ba9ada41f687c0e4bb34d5925374a68a8f8a3

Tree-SHA512: b83fc509f5dd820976596e1ae9fb69a22ada567e0e0ac88da5fc5e940a46d8894b40cc70c3eff2cbdabd4da5ec913f0d18c1632fc906f210b308855868410699
2025-09-30 15:23:20 -07:00
Anthony Towns
451ba9ada4
datacarrier: Undeprecate configuration option
Reverts commit 0b4048c73385166144d0b3e76beb9a2ac4cc1eca
2025-09-22 02:47:02 -05: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
Ava Chow
2c8a478db4
Merge bitcoin/bitcoin#33231: net: Prevent node from binding to the same CService
4d4789dffad55b96f1cb96b718cc6923f5344454 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 4d4789dffad55b96f1cb96b718cc6923f5344454
  yuvicc:
    re-ACK 4d4789dffad55b96f1cb96b718cc6923f5344454
  sipa:
    utACK 4d4789dffad55b96f1cb96b718cc6923f5344454
  achow101:
    ACK 4d4789dffad55b96f1cb96b718cc6923f5344454
  vasild:
    ACK 4d4789dffad55b96f1cb96b718cc6923f5344454
  naiyoma:
    Tested ACK 4d4789dffad55b96f1cb96b718cc6923f5344454

Tree-SHA512: f1042c00417da16550403cfcb75cb8b12740e67cf92a1d8e3c007ae81fcf741907088a633129ce12a6a48ad07fc9f320602792cafed73ec33f6306cd854514b4
2025-09-09 14:57:16 -07: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
Lőrinc
8bbb7b8bf8 refactor: Extract default batch size into kernel
The constant for the default batch size is moved to `kernel/caches.h` to consolidate kernel-related cache constants.
2025-08-28 10:09:32 -07: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
merge-script
f58de8749e
Merge bitcoin/bitcoin#32345: ipc: Handle unclean shutdowns better
2581258ec200efb173ea6449ad09b2e7f1cc02e0 ipc: Handle bitcoin-wallet disconnections (Ryan Ofsky)
216099591632dc8a57cc1a3b1ad08e909f8c73cc ipc: Add Ctrl-C handler for spawned subprocesses (Ryan Ofsky)
0c28068ceb7b95885a5abb2685a89bb7c03c1689 doc: Improve IPC interface comments (Ryan Ofsky)
7f65aac78b95357e00e1c0cd996f05e944ea9d2e ipc: Avoid waiting for clients to disconnect when shutting down (Ryan Ofsky)
6eb09fd6141f4c96dae3e1fe1a1f1946c91d0131 test: Add unit test coverage for Init and Shutdown code (Ryan Ofsky)
9a9fb19536fa2f89c3c96860c1882b79b68c9e64 ipc: Use EventLoopRef instead of addClient/removeClient (Ryan Ofsky)
e886c65b6b37aaaf5d22ca68bc14e55d8ec78212 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 2581258ec200efb173ea6449ad09b2e7f1cc02e0
  josibake:
    code review ACK 2581258ec2
  pinheadmz:
    re-ACK 2581258ec200efb173ea6449ad09b2e7f1cc02e0

Tree-SHA512: 0095aa22d507803e2a2d46eff51fb6caf965cc0c97ccfa615bd97805d5d51e66a5b4b040640deb92896438b1fb9f6879847124c9d0e120283287bfce37b8d748
2025-08-18 20:19:19 +01:00
Ava Chow
578b512bdd
Merge bitcoin/bitcoin#33011: log: rate limiting followups
5c74a0b397cb3db94761bad78801eed4544155b9 config: add DEBUG_ONLY -logratelimit (Eugene Siegel)
9f3b017bcc067bba1d1682a5d4e65b5450dc10c4 test: logging_filesize_rate_limit improvements (stickies-v)
350193e5e2efabb3eb66197b91869b946ec5428c test: don't leak log category mask across tests (stickies-v)
05d7c22479bf96bab9f8c8b8fa90368429ad2c88 test: add ReadDebugLogLines helper function (stickies-v)
3d630c2544e19480268426cda245796d4ce34ac3 log: make m_limiter a shared_ptr (stickies-v)
e8f9c37a3b4c9c88baddb556c4b33a4cbba1f614 log: clean up LogPrintStr_ and Reset, prefix all logs with "[*]" when there are suppressions (Eugene Siegel)
3c7cae49b692bb6bf5cae5ee23479091bed0b8be log: change LogLimitStats to struct LogRateLimiter::Stats (Eugene Siegel)
8319a134684df2240057a5e8afaa6ae441fb8a58 log: clarify RATELIMIT_MAX_BYTES comment, use RATELIMIT_WINDOW (Eugene Siegel)
5f70bc80df06ca85d44e8201d47e7086e971fdea log: remove const qualifier from arguments in LogPrintFormatInternal (Eugene Siegel)
b8e92fb3d4137f91fe6a54829867fc54357da648 log: avoid double hashing in SourceLocationHasher (Eugene Siegel)
616bc22f131132b9239ef362dca8c6bce000a539 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 5c74a0b397cb3db94761bad78801eed4544155b9
  achow101:
    ACK 5c74a0b397cb3db94761bad78801eed4544155b9
  l0rinc:
    Code review ACK 5c74a0b397cb3db94761bad78801eed4544155b9

Tree-SHA512: d32db5fcc28bb9b2a850f0048c8062200a3725b88f1cd9a0e137da065c0cf9a5d22e5d03cb16fe75ea7494801313ab34ffec7cf3e8577cd7527e636af53591c4
2025-08-14 15:15:25 -07: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
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
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
d1b583181d
Merge bitcoin/bitcoin#32654: init: make -blockmaxweight startup option debug only
e017ef3c7eb775e2cf999674df341be56f7ba72d 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 e017ef3c7eb775e2cf999674df341be56f7ba72d
  fjahr:
    ACK e017ef3c7eb775e2cf999674df341be56f7ba72d
  polespinasa:
    tACK e017ef3c7eb775e2cf999674df341be56f7ba72d

Tree-SHA512: 6c18781826b2f96b13b70b7f1624481f5971746a613079d0d9528366f274ba657a02611f134d7a64f35ecb7e5faf2e3cd025458b04574ac68f804372f6eb715f
2025-08-04 14:04:21 -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
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
merge-script
eeb0b31e3a
Merge bitcoin/bitcoin#32941: p2p: TxOrphanage revamp cleanups
c0642e558a02319ade33dc1014e7ae981663ea46 [fuzz] fix latency score check in txorphan_protected (glozow)
3d4d4f0d92d42809e74377e4380abdc70f74de5d scripted-diff: rename "ann" variables to "latency_score" (monlovesmango)
3b924489238220710326e9031c7aaa0d606c9064 [doc] comment fixups for orphanage changes (glozow)
1384dbaf6d0bfcdb05f97e1e3cb3d5e498bee505 [config] emit warning for -maxorphantx, but allow it to be set (glozow)
b10c55b298d4d2b7dddfecdbeb0edc624b8e6eb2 fix up TxOrphanage lower_bound sanity checks (glozow)
cfd71c67043a2a46950fd3f055afbe4a93922f75 scripted-diff: rename TxOrphanage outpoints index (glozow)
edb97bb3f151600f00c94a2732d2595446011295 [logging] add logs for inner loop of LimitOrphans (glozow)
8a58d0e87d70580ae47da228e2f88cd53c40c675 scripted-diff: rename OrphanTxBase to OrphanInfo (glozow)
cc50f2f0df6e6e2cc9b9aeb3c3c8e1c78fa5be1d [cleanup] replace TxOrphanage::Size() with CountUniqueOrphans (glozow)
ed24e016969098c486f413f4f57dcffe35241785 [optimization] Maintain at most 1 reconsiderable announcement per wtxid (Pieter Wuille)
af7402ccfa7f19177b5f422f596a3ab2bd1e9633 [refactor] make TxOrphanage keep itself trimmed (glozow)
d1fac25ff3c3ac090b68e370efc6dd9374b6ad3b [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 c0642e558a02319ade33dc1014e7ae981663ea46
  marcofleon:
    Nice, ACK c0642e558a02319ade33dc1014e7ae981663ea46

Tree-SHA512: f298eae92cf906ed5e4f15a24eeffa7b9e620bcff457772cd77522dd9f0b3b183ffc976871b1b0e6fe93009e64877d518e53d4b9e186e0df58fc16d17f6de90a
2025-08-04 16:47:54 +01:00
glozow
1384dbaf6d [config] emit warning for -maxorphantx, but allow it to be set 2025-08-01 11:52:32 -04:00
Ava Chow
547c64814d
Merge bitcoin/bitcoin#32987: init: [gui] Avoid UB/crash in InitAndLoadChainstate
fac90e5261b811739ada56e06ea793a12f9c2c3d test: Check that the GUI interactive reindex works (MarcoFalke)
faaaddaaf8e5a63f19c4fc66aa79134987775f96 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 fac90e5261b811739ada56e06ea793a12f9c2c3d
  TheCharlatan:
    ACK fac90e5261b811739ada56e06ea793a12f9c2c3d
  mzumsande:
    Tested ACK fac90e5261b811739ada56e06ea793a12f9c2c3d

Tree-SHA512: 9f744d36e7cdd3f5871764386ec5a5cca1ae144f1bacc26c07e60313c2bdacdc5fca351aa185cb51359540eea4534dda17e4fb6073ad90f91ba0a6936faeead8
2025-07-30 13:55:01 -07: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
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
MarcoFalke
fac90e5261
test: Check that the GUI interactive reindex works 2025-07-17 20:20:00 +02:00
MarcoFalke
faaaddaaf8
init: [gui] Avoid UB/crash in InitAndLoadChainstate 2025-07-16 07:10:30 +02: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
merge-script
12fb00fd42
Merge bitcoin/bitcoin#32927: fuzz: Add missing calls to SetMockTime for determinism
fa8862723c14cdd471bbffc7a4897ece2e6d8a7f fuzz: CheckGlobals in init (MarcoFalke)
fa26bfde988b1940e6b0d21accc60fbc4e45f9b1 test: Avoid resetting mocktime in testing setup (MarcoFalke)
fa6b45fa8ec8248544d22ba8429be8f6df19024a 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 fa8862723c14cdd471bbffc7a4897ece2e6d8a7f

Tree-SHA512: 5a9400f0467c82fa224713af4cc2b525afbefefc7c3f419077110925ad7af6c7fda3dcd2b50f7facf0ee7df2547c6ac20336906d707adcdfd1d652a9d9a735fe
2025-07-11 11:18:03 +01: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
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
Roman Zeyde
6ecb9fc65f
chore: use std::vector<std::byte> for BlockManager::ReadRawBlock() 2025-06-13 19:19:44 +03:00
Ava Chow
5757de4ddd
Merge bitcoin/bitcoin#32673: clang-tidy: Apply modernize-deprecated-headers
fa9ca13f35be0a023aeed78775ad66f95717b28b refactor: Sort includes of touched source files (MarcoFalke)
facb152697b8d7b75a9e6108f8896f774b06b35f scripted-diff: Bump copyright headers after include changes (MarcoFalke)
fae71d30f7227594e2f59499cf7f7f9420284e04 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 fa9ca13f35be0a023aeed78775ad66f95717b28b
  achow101:
    ACK fa9ca13f35be0a023aeed78775ad66f95717b28b
  janb84:
    ACK fa9ca13f35be0a023aeed78775ad66f95717b28b
  stickies-v:
    ACK fa9ca13f35be0a023aeed78775ad66f95717b28b

Tree-SHA512: 6639608308c598d612e24435aa519afe92d71b955874b87e527245291fb874b67f3ab95d3a0a5125c6adce5eb41c0d62f6ca488fbbfd60a94f2063d734173f4d
2025-06-11 15:08:23 -07:00
ismaelsadeeq
e017ef3c7e init: make -blockmaxweight startup option debug-only 2025-06-11 12:05:47 +01:00
merge-script
157bbd0a07
Merge bitcoin/bitcoin#32425: config: allow setting -proxy per network
e98c51fcce9ae3f441a416cab32a5c85756c6c64 doc: update tor.md to mention the new -proxy=addr:port=tor (Vasil Dimov)
ca5781e23a8f299ff4f143d2355218f551e65944 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 e98c51fcce9ae3f441a416cab32a5c85756c6c64
  caesrcd:
    reACK e98c51fcce
  danielabrozzoni:
    Code Review ACK e98c51fcce9ae3f441a416cab32a5c85756c6c64
  1440000bytes:
    ACK e98c51fcce

Tree-SHA512: 0cb590cb72b9393cc36357e8bd7861514ec4c5bc044a154e59601420b1fd6240f336ab538ed138bc769fca3d17e03725d56de382666420dc0787895d5bfec131
2025-06-10 15:57:09 -04:00
merge-script
f3bbc74664
Merge bitcoin/bitcoin#32406: policy: uncap datacarrier by default
a189d636184b1c28fa4a325b56c1fab8f44527b1 add release note for datacarriersize default change (Greg Sanders)
a141e1bf501bb2660f3a62083a65678250085e56 Add more OP_RETURN mempool acceptance functional tests (Peter Todd)
0b4048c73385166144d0b3e76beb9a2ac4cc1eca datacarrier: deprecate startup arguments for future removal (Greg Sanders)
63091b79e70b8e230a122fa6fb3dac91c80638e7 test: remove unnecessary -datacarriersize args from tests (Greg Sanders)
9f36962b07eff2369577a17c8adeaa0433697e1c 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 a189d636184b1c28fa4a325b56c1fab8f44527b1
  Sjors:
    re-ACK a189d636184b1c28fa4a325b56c1fab8f44527b1
  polespinasa:
    re-ACK a189d636184b1c28fa4a325b56c1fab8f44527b1
  hodlinator:
    re-ACK a189d636184b1c28fa4a325b56c1fab8f44527b1
  ajtowns:
    reACK a189d636184b1c28fa4a325b56c1fab8f44527b1
  mzumsande:
    re-ACK a189d636184b1c28fa4a325b56c1fab8f44527b1
  petertodd:
    ACK a189d636184b1c28fa4a325b56c1fab8f44527b1
  theStack:
    re-ACK a189d636184b1c28fa4a325b56c1fab8f44527b1
  1440000bytes:
    re-ACK a189d636184b1c28fa4a325b56c1fab8f44527b1
  willcl-ark:
    ACK a189d636184b1c28fa4a325b56c1fab8f44527b1
  dergoegge:
    ACK a189d636184b1c28fa4a325b56c1fab8f44527b1
  fanquake:
    ACK a189d636184b1c28fa4a325b56c1fab8f44527b1
  murchandamus:
    ACK a189d636184b1c28fa4a325b56c1fab8f44527b1
  darosior:
    Concept ACK a189d636184b1c28fa4a325b56c1fab8f44527b1.

Tree-SHA512: 3da2f1ef2f50884d4da7e50df2121bf175cb826edaa14ba7c3068a6d5b2a70beb426edc55d50338ee1d9686b9f74fdf9e10d30fb26a023a718dd82fa1e77b038
2025-06-09 08:23:56 -04:00
Ava Chow
e2174378aa
Merge bitcoin/bitcoin#32539: init: Configure reachable networks before we start the RPC server
12ff4be9c724c752fe67835419be3ff4d0e65990 test: ensure -rpcallowip is compatible with RFC4193 (Matthew Zipkin)
c02bd3c1875abd877a0dc73fb8866c883b7fcd32 config: Explain RFC4193 and CJDNS interaction in help and init error (Matthew Zipkin)
f728b6b11100fae1e27f7a0ef92a5930fa8cffb3 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 12ff4be9c724c752fe67835419be3ff4d0e65990
  tapcrafter:
    tACK 12ff4be9c724c752fe67835419be3ff4d0e65990
  ryanofsky:
    Code review ACK 12ff4be9c724c752fe67835419be3ff4d0e65990
  willcl-ark:
    ACK 12ff4be9c724c752fe67835419be3ff4d0e65990

Tree-SHA512: a4dd70ca2bb9f6ec2c0a9463fd73985d1ed80552c674a9067ac9a86662d1c018cc275ba757cebb2993c5f3971ecf4778b95d35fe7a7178fb41b1d18b601c9960
2025-06-06 15:31:36 -07: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
Greg Sanders
0b4048c733 datacarrier: deprecate startup arguments for future removal 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
Ava Chow
88b22acc3d
Merge bitcoin/bitcoin#32528: rpc: Round verificationprogress to 1 for a recent tip
fab1e02086ceebd7d96417b7a386fe61158bfda9 refactor: Pass verification_progress into block tip notifications (MarcoFalke)
fa76b378e4b218fb4853088328b9b488de18dcd2 rpc: Round verificationprogress to exactly 1 for a recent tip (MarcoFalke)
faf6304bdfdf228354b4072b72f4c0ef90fdaade 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 fab1e02086ceebd7d96417b7a386fe61158bfda9
  pinheadmz:
    ACK fab1e02086ceebd7d96417b7a386fe61158bfda9
  sipa:
    utACK fab1e02086ceebd7d96417b7a386fe61158bfda9

Tree-SHA512: a3c24e3c446d38fbad9399c1e7f1ffa7904490a3a7d12623b44e583b435cc8b5f1ba83b84d29c7ffaf22028bc909c7cec07202b825480449c6419d2a190938f5
2025-05-27 16:45:23 -07: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
merge-script
fad009af49
Merge bitcoin/bitcoin#32520: Remove legacy Parse(U)Int*
faf55fc80b11f3d9b0b12c1b26a9612ea9ce9b40 doc: Remove ParseInt mentions in documentation (MarcoFalke)
33332829333b589420f8038541d04ec6970f051d refactor: Remove unused Parse(U)Int* (MarcoFalke)
fa84e6c36cb0accf87123ca4eb98f6219d55fb5e bitcoin-tx: Reject + sign in MutateTxDel* (MarcoFalke)
face2519fac9e840d52f0334d9079e664be7eb28 bitcoin-tx: Reject + sign in vout parsing (MarcoFalke)
fa8acaf0b993c879ee8c516baa36339ff7b72406 bitcoin-tx: Reject + sign in replaceable parsing (MarcoFalke)
faff25a558ab15b5d8eeea5dd4c9c0d76350051b bitcoin-tx: Reject + sign in locktime (MarcoFalke)
dddd9e5fe38b81f1af6b343661b65e16b0de7c60 bitcoin-tx: Reject + sign in nversion parsing (MarcoFalke)
fab06ac03788243847b799a3feaac56bc918fba9 rest: Use SAFE_CHARS_URI in SanitizeString error msg (MarcoFalke)
8888bb499dec79258b1857b404d72f93650503f4 rest: Reject + sign in /blockhashbyheight/ (MarcoFalke)
fafd43c69192fcb48a9e04d52eeb07fff15655d0 test: Reject + sign when parsing regtest deployment params (MarcoFalke)
fa123afa0ef752e8645bf695d121da66d8f1382b Reject + sign when checking -ipcfd (MarcoFalke)
fa479857ed234d54df31d33b60de14c6ffab3d6f Reject + sign in SplitHostPort (MarcoFalke)
fab4c2967d554ddbc15f732cea6cd190c547d89f net: Reject + sign when parsing subnet mask (MarcoFalke)
fa89652e68fc07fb6c9f3d9e34dc11d35f0cc1e1 init: Reject + sign in -*port parsing (MarcoFalke)
fa9c45577dfbae67535e4965b5660288557d3631 cli: Reject + sign in -netinfo level parsing (MarcoFalke)
fa980413257e2004a8d48a8be66c6d67f90b76ad refactor: Use ToIntegral in CreateFromDump (MarcoFalke)
fa23ed7fc24212d85cdc7f52b317906b37a1a120 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 faf55fc80b11f3d9b0b12c1b26a9612ea9ce9b40

Tree-SHA512: a311ab6a58fe02a37741c1800feb3dcfad92377b4bfb61b433b2393f52ba89ef45d00940972b2767b213a3dd7b59e5e35d5b659c586eacdfe4e565a77b12b19f
2025-05-20 15:55:38 +01:00
fanquake
19ba499b1f
init: cerrno is used on all platforms 2025-05-19 13:45:04 +01: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
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
fanquake
301993ebf7
init: drop -upnp
This was slated for removal in 30.0, so remove it.
2025-05-14 16:01:36 +01: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
Hennadii Stepanov
d847e17c96
doc: Fix typo
An ellipsis (…) is typically used in such cases.
2025-05-12 17:11:27 +01:00