0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-01 09:35:52 -05:00

Compare commits

...

317 commits

Author SHA1 Message Date
fanquake
9fce0f206b
depends: use -O0 in depends DEBUG=1 flags 2025-01-31 14:22:04 +00:00
fanquake
644438aa2c
depends: patch qt rounding bugs
When compiled under -O0, this code was causing runtime failures in the
32-bit Clang gui wallet tests. Work around that by importing a commit from upstream:
8c8b9a4173.
2025-01-31 14:22:01 +00:00
Ryan Ofsky
8fa10edcd1
Merge bitcoin/bitcoin#31428: ci: Allow build dir on CI host
8888ee4403 ci: Allow build dir on CI host (MarcoFalke)

Pull request description:

  This is required to pass cross builds on to a different machine after the build.

  See for example https://github.com/bitcoin/bitcoin/pull/31176, but this pull will also allow someone to implement it outside this repo.

ACKs for top commit:
  davidgumberg:
    lgtm ACK 8888ee4403
  hebasto:
    re-ACK 8888ee4403.

Tree-SHA512: a1e2c32bc1b95efbd0b48287ac5b49e0e1bacbf5a5800845be5352bbdd3e17fa478e90348b2e94e95cf3ae863cdf75ab444089376588f6f8eec438f73a4b5b97
2025-01-30 19:34:00 -05:00
Ava Chow
809d7e763c
Merge bitcoin/bitcoin#31751: test: fix intermittent timeout in p2p_1p1c_network.py
152a2dcdef test: fix intermittent timeout in p2p_1p1c_network.py (Martin Zumsande)

Pull request description:

  The timeout is due to outstanding txrequests with python peers, which have the same timeout (`60s`) as the mempool sync timeout.
  I explained this in more detail in https://github.com/bitcoin/bitcoin/issues/31721#issuecomment-2620169640 and also mentioned there how to reproduce it.

  Fix this by disconnecting the python peers after they send their txns, they aren't needed after this point anyway because the main goal of the test is the sync between the 4 full nodes.

  Fixes #31721

ACKs for top commit:
  achow101:
    ACK 152a2dcdef
  instagibbs:
    reACK 152a2dcdef
  marcofleon:
    ACK 152a2dcdef
  glozow:
    reACK 152a2dcdef

Tree-SHA512: 908c58933d8e9fcca91425fce1b7c9c7cb7121a6d26840630e03a442356ad2a327d1e087df72a19caa97024ea827593e10f2ff93838f88939458e73df9857df0
2025-01-29 18:07:32 -05:00
Ava Chow
6835e9686c
Merge bitcoin/bitcoin#31545: ci: optionally use local docker build cache
e87429a2d0 ci: optionally use local docker build cache (0xb10c)

Pull request description:

  By setting `DANGER_DOCKER_BUILD_CACHE_HOST_DIR`, the task-specific docker images built during the CI run can be cached. This allows, for example, ephemeral CI runners to reuse the docker images (or layers of it) from earlier runs, by persisting the image cache before the ephemeral CI runner is shut down. The cache keyed by `CONTAINER_NAME`.

  As `--cache-to` doesn't remove old cache files, the existing cache is removed after a successful `docker build` and the newly cached image is moved to it's location to avoid the cache from growing indefinitely with old, unused layers.

  When `--cache-from` doesn't find the directory, the cached version is a cache-miss, or the cache can't be imported for whatever other reason, it warns and `docker build` continues by building the docker image.

  This feature is opt-in. The documentation for the docker build cache of `type=local` can be found on https://docs.docker.com/build/cache/backends/local/

  This replaces https://github.com/bitcoin/bitcoin/pull/31377 - some of the discussion there might provide more context.

ACKs for top commit:
  maflcko:
    I haven't tested this, and it looks harmless and is easy to revert, if needed. So lgtm ACK e87429a2d0
  achow101:
    ACK e87429a2d0
  TheCharlatan:
    tACK e87429a2d0
  willcl-ark:
    ACK e87429a2d0

Tree-SHA512: 0887c395dee2e2020394933246d4c1bfb6dde7165219cbe93eccfe01379e05c75dce8920b6edd7df07364c703fcee7be4fba8fa45fd0e0e89da9e24759f67a71
2025-01-29 16:50:19 -05:00
Ava Chow
c7869cb214
Merge bitcoin/bitcoin#30844: RPC: improve SFFO arg parsing, error catching and coverage
cddcbaf81e RPC: improve SFFO arg parsing, error catching and coverage (furszy)
4f4cd35319 rpc: decouple sendtoaddress 'subtractfeefromamount' boolean parsing (furszy)

Pull request description:

  Following changes were made:

  1) Catch and signal error for duplicate string destinations.
  2) Catch and signal error for invalid value type.
  3) Catch and signal error for string destination not found in tx outputs.
  4) Improved `InterpretSubtractFeeFromOutputInstructions()` code organization.
  5) Added test coverage for all possible error failures.

  Also, fixed two PEP 8 warnings at the 'wallet_sendmany.py' file:
  - PEP 8: E302 expected 2 blank lines, found 1 at the SendmanyTest class declaration.
  - PEP 8: E303 too many blank lines (2) at skip_test_if_missing_module() and set_test_params()

ACKs for top commit:
  achow101:
    ACK cddcbaf81e
  murchandamus:
    crACK cddcbaf81e
  naiyoma:
    TACK [cddcbaf81e)
  ismaelsadeeq:
    Code review and Tested ACK cddcbaf81e

Tree-SHA512: c9c15582b81101a93987458d155394ff2c9ca42864624c034ee808a31c3a7d7f55105dea98e86fce17d3c7b2c1a6b5b77942da66b287f8b8881a60cde78c1a3c
2025-01-29 16:33:13 -05:00
Ava Chow
1e0c5bd74a
Merge bitcoin/bitcoin#30125: test: improve BDB parser (handle internal/overflow pages, support all page sizes)
d45eb3964f test: compare BDB dumps of test framework parser and wallet tool (Sebastian Falbesoner)
01ddd9f646 test: complete BDB parser (handle internal/overflow pages, support all page sizes) (Sebastian Falbesoner)

Pull request description:

  This PR adds missing features to our test framework's BDB parser with the goal of hopefully being able to read all legacy wallets that are created with current and past versions of Bitcoin Core. This could be useful both for making review of https://github.com/bitcoin/bitcoin/pull/26606 easier and to also possibly improve our functional tests for the wallet BDB-ro parser by additionally validating it with an alternative implementation. The second commits introduces a test that create a legacy wallet with huge label strings (in order to create overflow pages, i.e. pages needed for key/value data than is larger than the page size) and compares the dump outputs of wallet tool and the extended test framework BDB parser.
  It can be exercised via `$ ./test/functional/tool_wallet.py --legacy`. BDB support has to be compiled in (obviously).

  For some manual tests regarding different page sizes, the following patch can be used:
  ```diff
  diff --git a/src/wallet/bdb.cpp b/src/wallet/bdb.cpp
  index 38cca32f80..1bf39323d3 100644
  --- a/src/wallet/bdb.cpp
  +++ b/src/wallet/bdb.cpp
  @@ -395,6 +395,7 @@ void BerkeleyDatabase::Open()
                               DB_BTREE,                                 // Database type
                               nFlags,                                   // Flags
                               0);
  +            pdb_temp->set_pagesize(1<<9); /* valid BDB pagesizes are from 1<<9 (=512) to <<16 (=65536) */

               if (ret != 0) {
                   throw std::runtime_error(strprintf("BerkeleyDatabase: Error %d, can't open database %s", ret, strFile));
  ```
  I verified that the newly introduced test passes with all valid page sizes between 512 and 65536.

ACKs for top commit:
  achow101:
    ACK d45eb3964f
  furszy:
    utACK d45eb3964f
  brunoerg:
    code review ACK d45eb3964f

Tree-SHA512: 9f8ac80452545f4fcd24a17ea6f9cf91b487cfb1fcb99a0ba9153fa4e3b239daa126454e26109fdcb72eb1c76a4ee3b46fd6af21dc318ab67bd12b3ebd26cfdd
2025-01-29 15:56:36 -05:00
Ava Chow
1d6c6e98c1
Merge bitcoin/bitcoin#31633: net: Disconnect message follow-ups to #28521
551a09486c net: Switch to DisconnectMsg in CConnman (Hodlinator)
bbac17608d net: Bring back log message when resetting socket (Hodlinator)
04b848e482 net: Specify context in disconnecting log message (Hodlinator)
0c4954ac7d net_processing: Add missing use of DisconnectMsg (Hodlinator)

Pull request description:

  - Add missing calls to `DisconnectMsg()` - https://github.com/bitcoin/bitcoin/pull/28521#discussion_r1890824361
  - Specify context when stopping nodes - https://github.com/bitcoin/bitcoin/pull/28521#discussion_r1890780754
  - Bring back log message when resetting socket in case new entrypoints are added - https://github.com/bitcoin/bitcoin/pull/28521#discussion_r1890795074
  - Use `DisconnectMsg()` in `CConnman` as well - https://github.com/bitcoin/bitcoin/pull/28521#discussion_r1791797716

ACKs for top commit:
  Sjors:
    re-utACK 551a09486c
  l0rinc:
    utACK 551a09486c
  davidgumberg:
    Tested and Review ACK 551a09486c
  achow101:
    ACK 551a09486c
  danielabrozzoni:
    ACK 551a09486c

Tree-SHA512: 95ab8e7436e20ca3abc949ea09697facb6fbeb19981ddc7e0bf294e7ec914e72cbf836c21184a2a887f04cb264f26daf5b0cbcbebc9db633a7b1672b4e488063
2025-01-29 15:26:53 -05:00
Martin Zumsande
152a2dcdef test: fix intermittent timeout in p2p_1p1c_network.py
The timeout is due to outstanding txrequests with
python peers. Fix this by disconnecting these peers
after they send their txns, they aren't needed after
this point anyway.
2025-01-29 10:46:55 -05:00
merge-script
ad2f9324c6
Merge bitcoin/bitcoin#31740: depends: Update libmultiprocess library before converting to subtree
4e0aa1835b test: Add test for IPC serialization bug (Ryan Ofsky)
2221c8814d depends: Update libmultiprocess library before converting to subtree (Ryan Ofsky)

Pull request description:

  This should be the final update to the libmultiprocess package via the depends system. It brings in the libmultiprocess cmake changes from https://github.com/chaincodelabs/libmultiprocess/pull/136 needed to support building as subtree. After this, followup PR #31741 will add libmultiprocess as a git subtree and depends will just use the git subtree instead of hardcoding its own version hash.

  Since there have been libmultiprocess API changes since the last update, this commit also updates bitcoin code to be compatible with them.

  This update has the following new changes since previous update #31105:

  https://github.com/chaincodelabs/libmultiprocess/pull/121 ProxyClientBase: avoid static_cast to partially constructed object
  https://github.com/chaincodelabs/libmultiprocess/pull/120 proxy-types.h: add static_assert to detect int/enum size mismatch
  https://github.com/chaincodelabs/libmultiprocess/pull/127 ProxyClientBase: avoid static_cast to partially destructed object
  https://github.com/chaincodelabs/libmultiprocess/pull/129 Fix "disconnected: write(m_post_fd, &buffer, 1): Broken pipe" EventLoop shutdown races.
  https://github.com/chaincodelabs/libmultiprocess/pull/130 refactor: Add CleanupRun function to dedup clean list code
  https://github.com/chaincodelabs/libmultiprocess/pull/131 doc: fix startAsyncThread comment
  https://github.com/chaincodelabs/libmultiprocess/pull/133 Fix debian "libatomic not found" error in downstream builds
  https://github.com/chaincodelabs/libmultiprocess/pull/94 c++ 20 cleanups
  https://github.com/chaincodelabs/libmultiprocess/pull/135 refactor: proxy-types.h API cleanup
  https://github.com/chaincodelabs/libmultiprocess/pull/136 cmake: Support being included with add_subdirectory
  https://github.com/chaincodelabs/libmultiprocess/pull/137 doc: Fix broken markdown links

ACKs for top commit:
  Sjors:
    ACK 4e0aa1835b
  vasild:
    ACK 4e0aa1835b
  TheCharlatan:
    ACK 4e0aa1835b

Tree-SHA512: 6d81cdf7f44762c7f476212295f6224054fd0a61315bb54786bc7758a2b33e5a2fce925c71e36f7bda320049aa14e7218a458ceb03dacbb869632c466c4789b0
2025-01-29 12:10:23 +00:00
merge-script
b432e36742
Merge bitcoin/bitcoin#31736: doc: update links in ci.yml
1681c08d42 doc: update links in ci.yml (espi3)

Pull request description:

  Updated three outdated GitHub links to avoid redirects.

ACKs for top commit:
  Sjors:
    ACK 1681c08d42

Tree-SHA512: 0ef934ebf308f0fee338cb6ac80b2826b9d442285c64af9e2547b020f5f0e5a0eaba7efeee6220e55790b78649d3060470ce65f35cb0ecc1f60041e5d640c6cb
2025-01-28 10:13:15 +00:00
merge-script
74ea7edafa
Merge bitcoin/bitcoin#31522: ci: Enable DEBUG=1 for one GCC-12+ build to catch 117966 regressions
fa8ade300f refactor: Avoid GCC false positive error (MarcoFalke)
fa40807fa8 ci: Enable DEBUG=1 for one GCC-12+ build to catch 117966 regressions (MarcoFalke)

Pull request description:

  It is possible that someone accidentally removes the workaround in fa9e0489f5, or more likely that someone accidentally adds new code without the workaround.

  Avoid this by adding a temporary CI check.

  This can be tested by reverting the workaround and observing a failure.

ACKs for top commit:
  hebasto:
    ACK fa8ade300f, I've tested locally on Ubuntu 24.04.

Tree-SHA512: 7ee1538fd5304a5ab91ac8c7619a573548d7e0345592a1e9d38b3b73729e09e7c77a9ee703d64cf02a8218de3148376d7836e294abb939aa7533034ba36dfb6c
2025-01-28 10:12:41 +00:00
merge-script
f34c580bd8
Merge bitcoin/bitcoin#31620: test: Remove --noshutdown flag, Tidy startup failures
faf2f2c654 test: Avoid redundant stop and error spam on shutdown (MarcoFalke)
fae3bf6b87 test: Avoid redundant stop and error spam on startup failure (MarcoFalke)
fa0dc09b90 test: Remove --noshutdown flag (MarcoFalke)
fad441fba0 test: Treat leftover process as error (MarcoFalke)

Pull request description:

  The `--noshutdown` flag is brittle, confusing, and redundant:

  * Someone wanting to inspect the state after a test failure will likely also want to debug the state on the python side, so the option is redundant with `--pdbonfailure`. If there was a use case to replicate `--pdbonfailure` without starting pdb, a dedicated flag could be added for that use case.
  * It is brittle to use the flag for a passing test, because it will disable checks in the test. For example, on shutdown LSan will perform a leak check, and the test framework will check that the node did not crash, and it will check that the node did not print errors to stderr.

  Fix all issues by removing it.

  Also, tidy up startup error messages to be less confusing as a result.

ACKs for top commit:
  hodlinator:
    re-ACK faf2f2c654
  pablomartin4btc:
    re tACK faf2f2c654

Tree-SHA512: 46d7ae59c7be88b93f1f9e0b6be21af0fc101e646512e2c5e725682cb18bfec8aa010e0ebe89ce9ffe239e5caac0da5f81cc97b79e738d26ca5fa31930e8e4e3
2025-01-28 10:11:18 +00:00
espi3
1681c08d42 doc: update links in ci.yml
Updated three GitHub links to avoid redirects.
2025-01-27 18:59:28 -08:00
Ava Chow
b0869648aa
Merge bitcoin/bitcoin#21590: Safegcd-based modular inverses in MuHash3072
f5883286e3 Add a fuzz test for Num3072 multiplication and inversion (Pieter Wuille)
a26ce62894 Safegcd based modular inverse for Num3072 (Pieter Wuille)
91ce8cef2d Add benchmark for MuHash finalization (Pieter Wuille)

Pull request description:

  This implements a safegcd-based modular inverse for MuHash3072. It is a fairly straightforward translation of [the libsecp256k1 implementation](https://github.com/bitcoin-core/secp256k1/pull/831), with the following changes:
  * Generic for 32-bit and 64-bit
  * Specialized for the specific MuHash3072 modulus (2^3072 - 1103717).
  * A bit more C++ish
  * Far fewer sanity checks

  A benchmark is also included for MuHash3072::Finalize. The new implementation is around 100x faster on x86_64 for me (from 5.8 ms to 57 μs); for 32-bit code the factor is likely even larger.

  For more information:
    * [Original paper](https://gcd.cr.yp.to/papers.html) by Daniel J. Bernstein and Bo-Yin Yang
    * [Implementation](https://github.com/bitcoin-core/secp256k1/pull/767) for libsecp256k1 by Peter Dettman; and the [final](https://github.com/bitcoin-core/secp256k1/pull/831) version
    * [Explanation](https://github.com/bitcoin-core/secp256k1/blob/master/doc/safegcd_implementation.md) of the algorithm using Python snippets
    * [Analysis](https://github.com/sipa/safegcd-bounds) of the maximum number of iterations the algorithm needs
     * [Formal proof in Coq](https://medium.com/blockstream/a-formal-proof-of-safegcd-bounds-695e1735a348) by Russell O'Connor (for the 256-bit version of the algorithm; here we use a 3072-bit one).

ACKs for top commit:
  achow101:
    ACK f5883286e3
  TheCharlatan:
    Re-ACK f5883286e3
  dergoegge:
    tACK f5883286e3

Tree-SHA512: 275872c61d30817a82901dee93fc7153afca55c32b72a95b8768f3fd464da1b09b36f952f30e70225e766b580751cfb9b874b2feaeb73ffaa6943c8062aee19a
2025-01-27 16:50:16 -05:00
Ryan Ofsky
4e0aa1835b test: Add test for IPC serialization bug
Add regression test for serialization bug in IPC mining code that is not
currently being called anywhere reported:

https://github.com/Sjors/bitcoin/issues/71
https://github.com/chaincodelabs/libmultiprocess/issues/122
2025-01-26 14:13:47 -05:00
Ryan Ofsky
2221c8814d depends: Update libmultiprocess library before converting to subtree
This should be the final update to the libmultiprocess package via the depends
system. It brings in the libmultiprocess cmake changes from
https://github.com/chaincodelabs/libmultiprocess/pull/136 needed to support
building as subtree. After this, a followup PR will add libmultiprocess as a
git subtree and depends will just use the git subtree instead of hardcoding its
own version hash.

Since there have been libmultiprocess API changes since the last update, this
commit also updates bitcoin code to be compatible with them.

This update brings in the following changes:

https://github.com/chaincodelabs/libmultiprocess/pull/121 ProxyClientBase: avoid static_cast to partially constructed object
https://github.com/chaincodelabs/libmultiprocess/pull/120 proxy-types.h: add static_assert to detect int/enum size mismatch
https://github.com/chaincodelabs/libmultiprocess/pull/127 ProxyClientBase: avoid static_cast to partially destructed object
https://github.com/chaincodelabs/libmultiprocess/pull/129 Fix "disconnected: write(m_post_fd, &buffer, 1): Broken pipe" EventLoop shutdown races.
https://github.com/chaincodelabs/libmultiprocess/pull/130 refactor: Add CleanupRun function to dedup clean list code
https://github.com/chaincodelabs/libmultiprocess/pull/131 doc: fix startAsyncThread comment
https://github.com/chaincodelabs/libmultiprocess/pull/133 Fix debian "libatomic not found" error in downstream builds
https://github.com/chaincodelabs/libmultiprocess/pull/94 c++ 20 cleanups
https://github.com/chaincodelabs/libmultiprocess/pull/135 refactor: proxy-types.h API cleanup
https://github.com/chaincodelabs/libmultiprocess/pull/136 cmake: Support being included with add_subdirectory
https://github.com/chaincodelabs/libmultiprocess/pull/137 doc: Fix broken markdown links
2025-01-26 14:13:47 -05:00
Ava Chow
0a931a9787
Merge bitcoin/bitcoin#31599: qa: Improve framework.generate* enforcement (#31403 follow-up)
1b51616f2e test: improve rogue calls in mining functions (i-am-yuvi)

Pull request description:

  #31403 follow-up, see [comment](https://github.com/bitcoin/bitcoin/pull/31403#pullrequestreview-2498806354)

  - Rename `invalid_call` parameter to `called_by_framework` in `generateblock`, `generatetoaddress` and `generatetodescriptor` mining methods to better express its intended usage.
  - Add explicit assertion message clarifying that these functions should only be called by TestFramework itself to maintain proper node synchronization.

ACKs for top commit:
  maflcko:
    lgtm ACK 1b51616f2e
  achow101:
    ACK 1b51616f2e
  hodlinator:
    re-ACK 1b51616f2e
  Prabhat1308:
    ACK [1b51616](1b51616f2e)

Tree-SHA512: 56832626fe54dcaa07dacb4f9c960c0a83fad3fb12272155114ac697856c59b7f44805e1152eddeec7a5e8f7daf487382dc01b5b9ae2e74b62b2df6bd1f81f77
2025-01-24 18:33:14 -05:00
Ava Chow
4ac1efb147
Merge bitcoin/bitcoin#30322: test: raise an error in _bulk_tx_ when target_vsize is too low
92787dd52c test: raise an error when target_vsize is below tx virtual size (ismaelsadeeq)
a8780c937f test: raise an error if output value is <= 0 in `create_self_transfer` (ismaelsadeeq)
f6e88931f0 test: test that `create_self_transfer_multi` respects `target_vsize` (ismaelsadeeq)

Pull request description:

  This is a simple test PR that does two things:

  1. Raise an exception in `_bulk_tx_` when `target_vsize` is too low, i.e., below the tx vsize.
  2. Addresses some review comments from https://github.com/bitcoin/bitcoin/pull/30162, which are:
     - Raise an error if the output value is less than or equal to zero in `create_self_transfer`.
  This prevents creating transactions with a value of 0 or less.
     - Add a test to verify that `create_self_transfer_multi` also respects the passed `target_vsize`.

ACKs for top commit:
  achow101:
    ACK 92787dd52c
  theStack:
    ACK 92787dd52c
  rkrux:
    reACK 92787dd52c
  glozow:
    ACK 92787dd52c

Tree-SHA512: 1f2767f2cf715ed65074c5fff347eec160b142685777d833d5e872cfef364d3dc1916b52ee442e99c7b9a8d514ff62bc67a9899d8854f65a4b93ac3ae300d18e
2025-01-24 18:27:32 -05:00
Ava Chow
8775731e6d
Merge bitcoin/bitcoin#31241: wallet: remove BDB dependency from wallet migration benchmark
18619b4732 wallet: remove BDB dependency from wallet migration benchmark (furszy)

Pull request description:

  Part of the legacy wallet removal working path #20160.

  Stops creating a bdb database in the wallet migration benchmark.
  Instead, the benchmark now creates the db in memory and re-uses it for the migration process.

ACKs for top commit:
  achow101:
    ACK 18619b4732
  brunoerg:
    code review ACK 18619b4732
  theStack:
    Code-review ACK 18619b4732

Tree-SHA512: a107deee3d2c00b980e3606be07d038ca524b98251442956d702a7996e2ac5e2901f656482018cacbac8ef6a628ac1fb03f677d1658aeaded4036d834a95d7e0
2025-01-24 18:21:50 -05:00
Ava Chow
9ecc7af41f
Merge bitcoin/bitcoin#31674: init: Lock blocksdir in addition to datadir
2656a5658c tests: add a test for the new blocksdir lock (Cory Fields)
bdc0a68e67 init: lock blocksdir in addition to datadir (Cory Fields)
cabb2e5c24 refactor: introduce a more general LockDirectories for init (Cory Fields)
1db331ba76 init: allow a new xor key to be written if the blocksdir is newly created (Cory Fields)

Pull request description:

  This probably should've been included in #12653 when `-blocksdir` was introduced. Credit TheCharlatan for noticing that it's missing.

  This guards against 2 processes running with separate datadirs but the same blocksdir. I didn't add `walletdir` as I assume sqlite has us covered there.

  It's not likely to happen currently, but may be more relevant in the future with applications using the kernel. Note that the kernel does not currently do any dir locking, but it should.

ACKs for top commit:
  maflcko:
    review ACK 2656a5658c 🏼
  kevkevinpal:
    ACK [2656a56](2656a5658c)
  achow101:
    ACK 2656a5658c
  tdb3:
    Code review and light test ACK 2656a5658c

Tree-SHA512: 3ba17dc670126adda104148e14d1322ea4f67d671c84aaa9c08c760ef778ca1936832c0dc843cd6367e09939f64c6f0a682b0fa23a5967e821b899dff1fff961
2025-01-24 18:15:00 -05:00
Hodlinator
551a09486c
net: Switch to DisconnectMsg in CConnman 2025-01-24 23:16:32 +01:00
merge-script
2d07384243
Merge bitcoin/bitcoin#31658: test: p2p: fix sending of manual INVs in tx download test
8996fef8ae test: p2p: check that INV messages not matching wtxidrelay are ignored (Sebastian Falbesoner)
e0b3336822 test: p2p: fix sending of manual INVs in tx download test (Sebastian Falbesoner)

Pull request description:

  The `test_inv_block` sub-test in p2p_tx_download.py has a subtle bug: the manual msg_inv announcements from peers currently have no effect, since they don't match the wtxidrelay setting (=true by default for `P2PInterface` instances) and are hence ignored by the nodes (since 2d282e0c / PR #18044):

  e7c4794955/src/net_processing.cpp (L3904-L3911)

  Though the test still passes on master, it does so without the intended scenario of asking an additional peer (triggering the GETDATA_TX_INTERVAL delay). Fix this by sending the INV message with MSG_WTX instead of MSG_TX. This increases the test run time by about one minute intentionally.

  It might be good to avoid issues like this in the future, happy to add test framework improvements if someone has a concrete idea.

  (Got into the topic of tx/wtx announcements via the discussion https://github.com/bitcoin/bitcoin/pull/31397#discussion_r1904121487)

ACKs for top commit:
  maflcko:
    ACK 8996fef8ae 😸
  danielabrozzoni:
    ACK 8996fef8ae
  mzumsande:
    Code Review ACK 8996fef8ae

Tree-SHA512: 3da26f9539c89d64c3b0d0579d9af2a6a4577615eed192506e1fb4318421b235f99a6672a497dea3050fba85dad32678f37fd2cda9ecb70cbf52982db37982e8
2025-01-24 10:49:17 +00:00
merge-script
796e1a4c5d
Merge bitcoin/bitcoin#31718: Docs: fix typos in documentation files
81b9800c87 fix typos (wgyt)

Pull request description:

ACKs for top commit:
  maflcko:
    lgtm ACK 81b9800c87

Tree-SHA512: 6a4f718c0afb0e3bf80ab7fa7fed32f882614c60b6e4972f54584aecac2f19384d781232e923a47b72d76229af907ebf7717d7b34f9be6c00394ce5d7ed0b8d4
2025-01-24 10:39:34 +00:00
wgyt
81b9800c87 fix typos 2025-01-24 09:12:38 +08:00
merge-script
d5a2ba44ba
Merge bitcoin/bitcoin#31416: doc: Fix incorrect send RPC docs
fad83e759a doc: Fix incorrect send RPC docs (MarcoFalke)

Pull request description:

  It would be good to have accurate RPC docs, so that humans and machines can read them and rely on them.

  This fixes one issue.

ACKs for top commit:
  fjahr:
    utACK fad83e759a
  rkrux:
    tACK fad83e759a
  luke-jr:
    tACK fad83e759a

Tree-SHA512: 65d0cc18a62ef44833621464d74b743d24ffe2b853596dce2c4f423df0495142d50387c02ba1b54f5ca77d4ddb083d55116a8ac92698aa6558762d841664911e
2025-01-23 17:42:53 +00:00
merge-script
9914e73729
Merge bitcoin/bitcoin#31704: doc: add a section in the fuzzing documentation about using MSan
5c3e4d8b29 doc: add a section about using MSan (Antoine Poinsot)

Pull request description:

  Just a couple lines in a subsection of the sanitizers section mentioning that using the memory sanitizer is a bit more involve than other sanitizers, describing the steps and pointing to an example.

ACKs for top commit:
  fanquake:
    ACK 5c3e4d8b29
  dergoegge:
    ACK 5c3e4d8b29

Tree-SHA512: 4ff73c2dd0f25cb96148e54bd867b8d340bd0fbc9b9a736a705125039352eb1d40bd724f9f262a44d3dbd1bea8f03166cf30e571d882fec02ceb1dd399ef7422
2025-01-23 14:25:28 +00:00
MarcoFalke
faf2f2c654
test: Avoid redundant stop and error spam on shutdown
Trying to shut down a node after a test failure may fail and lead to an
RPC error.

Also, it is confusing to sidestep the existing fallback to kill any
leftover nodes on a test failure.

So just rely on the fallback.

Idea by Hodlinator.

Co-Authored-By: Hodlinator <172445034+hodlinator@users.noreply.github.com>
2025-01-23 15:15:36 +01:00
merge-script
188b02116d
Merge bitcoin/bitcoin#31635: test: add coverage for unknown address type for createwalletdescriptor
4da7bfdcc9 test: add coverage for unknown address type for `createwalletdescriptor` (brunoerg)

Pull request description:

  Calling `createwalletdescriptor` RPC with an unknown address type throws an error. This PR adds test coverage for it as done for other RPCs (`getnewaddress `, `getrawchangeaddress`, etc).

ACKs for top commit:
  maflcko:
    lgtm ACK 4da7bfdcc9
  rkrux:
    tACK 4da7bfdcc9

Tree-SHA512: 490bc3ffeb70b0f26db0a44d3950d7410fef35d4056487f2e82c081fb14ca277a18943c487235e0163a29f90fc741a262c29835beb9f41936affa4e73ddad25f
2025-01-23 12:50:38 +00:00
merge-script
2317e6cf2d
Merge bitcoin/bitcoin#31696: test: Check that reindex with prune wipes blk files
fa9aced800 test: Check that reindex with prune wipes blk files (MarcoFalke)
fa9593efc2 test: Use high-level python types (MarcoFalke)

Pull request description:

  This adds missing test coverage for `CleanupBlockRevFiles`.

ACKs for top commit:
  TheCharlatan:
    Re-ACK fa9aced800
  l0rinc:
    ACK fa9aced800
  tdb3:
    re ACK fa9aced800

Tree-SHA512: b31ff8a896ce344437715e7fb7efdb8cd7e11470e8465d8972fddfdb58ffd78257786c4060e8596cc53b6278f8ac6a9b6eb05a06e9df58b8b240bdaa719a8e5b
2025-01-23 12:42:55 +00:00
merge-script
94f0adcc31
Merge bitcoin/bitcoin#31541: qa: Use sys.executable when invoking other Python scripts
d38ade7bc4 qa: Use `sys.executable` when invoking other Python scripts (Hennadii Stepanov)

Pull request description:

  This PR fixes the `rpc_signer.py` and `wallet_signer.py` functional tests on systems where `python3` is not available in the `PATH`, causing the shebang `#!/usr/bin/env python3` to fail.

  Here are logs on NetBSD 10.0:
  - without this PR:
  ```
  $ python3.12 ./build/test/functional/test_runner.py rpc_signer.py wallet_signer.py
  Temporary test directory at /tmp/test_runner_₿_🏃_20241219_160538
  Remaining jobs: [rpc_signer.py, wallet_signer.py --descriptors]
  1/2 - rpc_signer.py failed, Duration: 1 s

  stdout:
  2024-12-19T16:05:40.012000Z TestFramework (INFO): PRNG seed is: 1833166631173850775
  2024-12-19T16:05:40.012000Z TestFramework (INFO): Initializing test directory /tmp/test_runner_₿_🏃_20241219_160538/rpc_signer_1
  2024-12-19T16:05:40.754000Z TestFramework (ERROR): Assertion failed
  Traceback (most recent call last):
    File "/home/hebasto/dev/bitcoin/test/functional/test_framework/util.py", line 160, in try_rpc
      fun(*args, **kwds)
    File "/home/hebasto/dev/bitcoin/test/functional/test_framework/coverage.py", line 50, in __call__
      return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/hebasto/dev/bitcoin/test/functional/test_framework/authproxy.py", line 146, in __call__
      raise JSONRPCException(response['error'], status)
  test_framework.authproxy.JSONRPCException: RunCommandParseJSON error: process(/home/hebasto/dev/bitcoin/test/functional/mocks/signer.py enumerate) returned 127: env: python3: No such file or directory
   (-1)

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "/home/hebasto/dev/bitcoin/test/functional/test_framework/test_framework.py", line 135, in main
      self.run_test()
    File "/home/hebasto/dev/bitcoin/build/test/functional/rpc_signer.py", line 72, in run_test
      assert_raises_rpc_error(-1, 'fingerprint not found',
    File "/home/hebasto/dev/bitcoin/test/functional/test_framework/util.py", line 151, in assert_raises_rpc_error
      assert try_rpc(code, message, fun, *args, **kwds), "No exception raised"
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/hebasto/dev/bitcoin/test/functional/test_framework/util.py", line 166, in try_rpc
      raise AssertionError(
  AssertionError: Expected substring not found in error message:
  substring: 'fingerprint not found'
  error message: 'RunCommandParseJSON error: process(/home/hebasto/dev/bitcoin/test/functional/mocks/signer.py enumerate) returned 127: env: python3: No such file or directory
  '.
  2024-12-19T16:05:40.756000Z TestFramework (INFO): Stopping nodes
  2024-12-19T16:05:40.873000Z TestFramework (WARNING): Not cleaning up dir /tmp/test_runner_₿_🏃_20241219_160538/rpc_signer_1
  2024-12-19T16:05:40.873000Z TestFramework (ERROR): Test failed. Test logging available at /tmp/test_runner_₿_🏃_20241219_160538/rpc_signer_1/test_framework.log
  2024-12-19T16:05:40.873000Z TestFramework (ERROR):
  2024-12-19T16:05:40.873000Z TestFramework (ERROR): Hint: Call /home/hebasto/dev/bitcoin/test/functional/combine_logs.py '/tmp/test_runner_₿_🏃_20241219_160538/rpc_signer_1' to consolidate all logs
  2024-12-19T16:05:40.873000Z TestFramework (ERROR):
  2024-12-19T16:05:40.873000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
  2024-12-19T16:05:40.873000Z TestFramework (ERROR): https://github.com/bitcoin/bitcoin/issues
  2024-12-19T16:05:40.873000Z TestFramework (ERROR):

  stderr:

  Remaining jobs: [wallet_signer.py --descriptors]
  2/2 - wallet_signer.py --descriptors failed, Duration: 1 s

  stdout:
  2024-12-19T16:05:40.014000Z TestFramework (INFO): PRNG seed is: 7530764367977090686
  2024-12-19T16:05:40.014000Z TestFramework (INFO): Initializing test directory /tmp/test_runner_₿_🏃_20241219_160538/wallet_signer_0
  2024-12-19T16:05:40.526000Z TestFramework (ERROR): JSONRPC error
  Traceback (most recent call last):
    File "/home/hebasto/dev/bitcoin/test/functional/test_framework/test_framework.py", line 135, in main
      self.run_test()
    File "/home/hebasto/dev/bitcoin/build/test/functional/wallet_signer.py", line 66, in run_test
      self.test_valid_signer()
    File "/home/hebasto/dev/bitcoin/build/test/functional/wallet_signer.py", line 83, in test_valid_signer
      self.nodes[1].createwallet(wallet_name='hww', disable_private_keys=True, descriptors=True, external_signer=True)
    File "/home/hebasto/dev/bitcoin/test/functional/test_framework/test_node.py", line 935, in createwallet
      return self.__getattr__('createwallet')(wallet_name, disable_private_keys, blank, passphrase, avoid_reuse, descriptors, load_on_startup, external_signer)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/hebasto/dev/bitcoin/test/functional/test_framework/coverage.py", line 50, in __call__
      return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/hebasto/dev/bitcoin/test/functional/test_framework/authproxy.py", line 146, in __call__
      raise JSONRPCException(response['error'], status)
  test_framework.authproxy.JSONRPCException: RunCommandParseJSON error: process(/home/hebasto/dev/bitcoin/test/functional/mocks/signer.py enumerate) returned 127: env: python3: No such file or directory
   (-1)
  2024-12-19T16:05:40.528000Z TestFramework (INFO): Stopping nodes
  2024-12-19T16:05:40.645000Z TestFramework (WARNING): Not cleaning up dir /tmp/test_runner_₿_🏃_20241219_160538/wallet_signer_0
  2024-12-19T16:05:40.646000Z TestFramework (ERROR): Test failed. Test logging available at /tmp/test_runner_₿_🏃_20241219_160538/wallet_signer_0/test_framework.log
  2024-12-19T16:05:40.646000Z TestFramework (ERROR):
  2024-12-19T16:05:40.646000Z TestFramework (ERROR): Hint: Call /home/hebasto/dev/bitcoin/test/functional/combine_logs.py '/tmp/test_runner_₿_🏃_20241219_160538/wallet_signer_0' to consolidate all logs
  2024-12-19T16:05:40.646000Z TestFramework (ERROR):
  2024-12-19T16:05:40.646000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
  2024-12-19T16:05:40.646000Z TestFramework (ERROR): https://github.com/bitcoin/bitcoin/issues
  2024-12-19T16:05:40.646000Z TestFramework (ERROR):

  stderr:

  TEST                           | STATUS    | DURATION

  rpc_signer.py                  | ✖ Failed  | 1 s
  wallet_signer.py --descriptors | ✖ Failed  | 1 s

  ALL                            | ✖ Failed  | 2 s (accumulated)
  Runtime: 1 s

  ```
  - with this PR:
  ```
  $ python3.12 ./build/test/functional/test_runner.py rpc_signer.py wallet_signer.py
  Temporary test directory at /tmp/test_runner_₿_🏃_20241219_160011
  Remaining jobs: [rpc_signer.py, wallet_signer.py --descriptors]
  1/2 - rpc_signer.py passed, Duration: 2 s
  Remaining jobs: [wallet_signer.py --descriptors]
  2/2 - wallet_signer.py --descriptors passed, Duration: 3 s

  TEST                           | STATUS    | DURATION

  rpc_signer.py                  | ✓ Passed  | 2 s
  wallet_signer.py --descriptors | ✓ Passed  | 3 s

  ALL                            | ✓ Passed  | 5 s (accumulated)
  Runtime: 3 s

  ```

ACKs for top commit:
  maflcko:
    lgtm ACK d38ade7bc4
  stickies-v:
    ACK d38ade7bc4 . I have a minor concern about `sys.executable` not being guaranteed to return a valid Python path, but this patch seems good enough as is so no blocker.

Tree-SHA512: 91fe0abc0b7e2b599c5562f8b225ba60f94c5bd6baa77d8df532155ef4d3ef6c6a862cee7f4a7f565ed4bb3251adcda813b4a4f79be1aa6a4ffdfda8b4e53415
2025-01-23 11:18:20 +00:00
merge-script
59876b3ad7
Merge bitcoin/bitcoin#31376: Miner: never create a template which exploits the timewarp bug
733fa0b0a1 miner: never create a template which exploits the timewarp bug (Antoine Poinsot)

Pull request description:

  This check was introduced in #30681 but only enabled for testnet4. To avoid potentially creating an invalid block template if a soft fork to fix the timewarp attack were to activate in the future, we should have this check on all networks. It also seems wise for our miner to not support it whether or not a soft fork activates to fix it at the consensus level.

ACKs for top commit:
  Sjors:
    ACK 733fa0b0a1
  fjahr:
    utACK 733fa0b0a1
  TheCharlatan:
    ACK 733fa0b0a1

Tree-SHA512: 9b3bc8b26a57f93425b17dda80bcfac4ecb750a3d26bc3eb8df619135634e369ac15982fac0c9770b1df207bd2e418ffe02a98f37968f024e55262d97715a4f5
2025-01-23 10:54:47 +00:00
merge-script
449a25b958
Merge bitcoin/bitcoin#31709: cmake: Fail if Libmultiprocess is missing when WITH_MULTIPROCESS=ON
c31166ac77 cmake: Fail if `Libmultiprocess` is missing when `WITH_MULTIPROCESS=ON` (Hennadii Stepanov)

Pull request description:

  Fixes https://github.com/bitcoin/bitcoin/issues/31708:
  ```
  $ cmake -B build -DWITH_MULTIPROCESS=ON
  -- The CXX compiler identification is GNU 13.3.0
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Check for working CXX compiler: /usr/bin/c++ - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Found SQLite3: /usr/include (found suitable version "3.45.1", minimum required is "3.7.17")
  CMake Error at CMakeLists.txt:146 (find_package):
    By not providing "FindLibmultiprocess.cmake" in CMAKE_MODULE_PATH this
    project has asked CMake to find a package configuration file provided by
    "Libmultiprocess", but CMake did not find one.

    Could not find a package configuration file provided by "Libmultiprocess"
    with any of the following names:

      LibmultiprocessConfig.cmake
      libmultiprocess-config.cmake

    Add the installation prefix of "Libmultiprocess" to CMAKE_PREFIX_PATH or
    set "Libmultiprocess_DIR" to a directory containing one of the above files.
    If "Libmultiprocess" provides a separate development package or SDK, be
    sure it has been installed.

  -- Configuring incomplete, errors occurred!
  ```

ACKs for top commit:
  vasild:
    ACK c31166ac77
  ryanofsky:
    Code review ACK c31166ac77
  TheCharlatan:
    ACK c31166ac77

Tree-SHA512: 503e6d7ff253c9ae95b13ff0649af7db97c74a97c04ca6fe88130defae251b94bfe9f4466300d3fab16397c7c8346b392a80a7b80a2d6517464a4eabe3aa40db
2025-01-23 09:46:25 +00:00
Ryan Ofsky
5acf12bafe
Merge bitcoin/bitcoin#31583: rpc: add target to getmininginfo field and show next block info
a4df12323c doc: add release notes (Sjors Provoost)
c75872ffdd test: use DIFF_1_N_BITS in tool_signet_miner (tdb3)
4131f322ac test: check difficulty adjustment using alternate mainnet (Sjors Provoost)
c4f68c12e2 Use OP_0 for BIP34 padding in signet and tests (Sjors Provoost)
cf0a62878b rpc: add next to getmininginfo (Sjors Provoost)
2d18a078a2 rpc: add target and bits to getchainstates (Sjors Provoost)
f153f57acc rpc: add target and bits to getblockchaininfo (Sjors Provoost)
baa504fdfa rpc: add target to getmininginfo result (Sjors Provoost)
2a7bfebd5e Add target to getblock(header) in RPC and REST (Sjors Provoost)
341f932516 rpc: add GetTarget helper (Sjors Provoost)
d20d96fa41 test: use REGTEST_N_BITS in feature_block (tdb3)
7ddbed4f9f rpc: add nBits to getmininginfo (Sjors Provoost)
ba7b9f3d7b build: move pow and chain to bitcoin_common (Sjors Provoost)
c4cc9e3e9d consensus: add DeriveTarget() to pow.h (Sjors Provoost)

Pull request description:

  **tl&dr for consensus-code only reviewers**: the first commit splits `CheckProofOfWorkImpl()` in order to create a `DeriveTarget()` helper. The rest of this PR does not touch consensus code.

  There are three ways to represent the proof-of-work in a block:

  1. nBits
  2. Difficulty
  3. Target

  The latter notation is useful when you want to compare share work against either the pool target (to get paid) or network difficulty (found an actual block). E.g. for difficulty 1 which corresponds to an nBits value of `0x00ffff`:

  ```
  share hash: f6b973257df982284715b0c7a20640dad709d22b0b1a58f2f88d35886ea5ac45
  target:     7fffff0000000000000000000000000000000000000000000000000000000000
  ```

  It's immediately clear that the share is invalid because the hash is above the target.

  This type of logging is mostly done by the pool software. It's a nice extra convenience, but not very important. It impacts the following RPC calls:

  1. `getmininginfo` displays the `target` for the tip block
  2. `getblock` and `getblockheader` display the `target` for a specific block (ditto for their REST equivalents)

  The `getdifficulty` method is a bit useless in its current state, because what miners really want to know if the difficulty for the _next_ block. So I added a boolean argument `next` to `getdifficulty`. (These values are typically the same, except for the first block in a retarget period. On testnet3 / testnet4 they change when no block is found after 20 minutes).

  Similarly I added a `next` object to `getmininginfo` which shows `bit`, `difficulty` and `target` for the next block.

  In order to test the difficulty transition, an alternate mainnet chain with 2016 blocks was generated and used in `mining_mainnet.py`. The chain is deterministic except for its timestamp and nonce values, which are stored in `mainnet_alt.json`.

  As described at the top, this PR introduces a helper method `DeriveTarget()` which is split out from `CheckProofOfWorkImpl`. The proposed `checkblock` RPC in #31564 needs this helper method internally to figure out the consensus target.

  Finally, this PR moves `pow.cpp` and `chain.cpp` from `bitcoin_node` to `bitcoin_common`, in order to give `rpc/util.cpp` (which lives in `bitcoin_common`) access to `pow.h`.

ACKs for top commit:
  ismaelsadeeq:
    re-ACK a4df12323c
  tdb3:
    code review re ACK a4df12323c
  ryanofsky:
    Code review ACK a4df12323c. Only overall changes since last review were dropping new `gettarget` method and dropping changes to `getdifficulty`, but there were also various internal changes splitting and rearranging commits.

Tree-SHA512: edef5633590379c4be007ac96fd1deda8a5b9562ca6ff19fe377cb552b5166f3890d158554c249ab8345977a06da5df07866c9f42ac43ee83dfe3830c61cd169
2025-01-22 15:01:23 -05:00
Ryan Ofsky
78fa88c53a
Merge bitcoin/bitcoin#31548: fuzz: Abort when global PRNG is used before SeedRand::ZEROS
fa3c787b62 fuzz: Abort when global PRNG is used before SeedRand::ZEROS (MarcoFalke)

Pull request description:

  This adds one more check to abort when global PRNG is used before SeedRand::ZEROS in fuzz tests. This is achieved by carving out the two remaining uses. First, `g_rng_temp_path_init`, and second the random fallback for `RANDOM_CTX_SEED`, which isn't used in fuzz tests anyway.

  Requested in https://github.com/bitcoin/bitcoin/pull/31521#issuecomment-2554669015

  Can be tested by reverting fadd568931 and observing an abort when running the `utxo_total_supply` fuzz target.

ACKs for top commit:
  marcofleon:
    ACK fa3c787b62
  hodlinator:
    re-ACK fa3c787b62
  ryanofsky:
    Code review ACK fa3c787b62. This adds a new check to make that sure that RNG is never seeded during fuzzing after the RNG has been used. Together with existing checks which ensure RNG can only be seeded with zeroes during fuzzing, and that RNG must was seeded at some point if used after fuzzing, this implies it must have been seeded by zeros before being used.

Tree-SHA512: 2614928d31c310309bd9021b3e5637b35f64196020fbf9409e978628799691d0efd3f4cf606be9a2db0ef60b010f890c2e70c910eaa2934a7fbf64cd1598fe22
2025-01-22 12:40:21 -05:00
Hennadii Stepanov
c31166ac77
cmake: Fail if Libmultiprocess is missing when WITH_MULTIPROCESS=ON 2025-01-22 17:33:57 +00:00
Ryan Ofsky
5d6f6fd00d
Merge bitcoin/bitcoin#31490: refactor: inline UndoWriteToDisk and WriteBlockToDisk to reduce serialization calls
223081ece6 scripted-diff: rename block and undo functions for consistency (Lőrinc)
baaa3b2846 refactor,blocks: remove costly asserts and modernize affected logs (Lőrinc)
fa39f27a0f refactor,blocks: deduplicate block's serialized size calculations (Lőrinc)
dfb2f9d004 refactor,blocks: inline `WriteBlockToDisk` (Lőrinc)
42bc491465 refactor,blocks: inline `UndoWriteToDisk` (Lőrinc)
86b85bb11f bench: add SaveBlockBench (Lőrinc)
34f9a0157a refactor,bench: rename bench/readblock.cpp to bench/readwriteblock.cpp (Lőrinc)

Pull request description:

  `UndoWriteToDisk` and `WriteBlockToDisk` were delegating a subset of their functionality to single-use methods that didn't optimally capture a meaningful chunk of the algorithm, resulting in calculating things twice (serialized size, header size).
  This change inlines the awkward methods (asserting that all previous behavior was retained), and in separate commits makes the usages less confusing.
  Besides making the methods slightly more intuitive, the refactorings reduce duplicate calculations as well.

  The speed difference is insignificant for now (~0.5% for the new `SaveBlockToDiskBench`), but are a cleanup for follow-ups such as https://github.com/bitcoin/bitcoin/pull/31539

ACKs for top commit:
  ryanofsky:
    Code review ACK 223081ece6. Since last review, "Save" was renamed to "Write", uint32_t references were dropped, some log statements and comments were improved as suggested, and a lot of tweaks made to commits and commit messages which should make this easier to review.
  hodlinator:
    ACK 223081ece6
  TheCharlatan:
    ACK 223081ece6
  andrewtoth:
    ACK 223081ece6

Tree-SHA512: 951bc8ad3504c510988afd95c561e3e259c6212bd14f6536fe56e8eb5bf5c35c32a368bbdb1d5aea1acc473d7e5bd9cdcde02008a148b05af1f955e413062d5c
2025-01-22 12:28:18 -05:00
merge-script
7b4d072e4f
Merge bitcoin/bitcoin#31690: doc: Amend notes on benchmarking
e94c9d1712 [doc] Amend notes on benchmarking (dergoegge)

Pull request description:

  This gives some more context on the motivation and larger picture of benchmarks.

ACKs for top commit:
  l0rinc:
    ACK e94c9d1712
  instagibbs:
    reACK e94c9d1712
  darosior:
    reACK e94c9d1712
  brunoerg:
    reACK e94c9d1712

Tree-SHA512: 2cbf51f283f2efc0938e7021ae48db51fe89caf9ef9780821e99fa745dff839e2d202ca956ce6cc48b8319db304069728e77883feefe486264eb1783a0610c93
2025-01-22 16:44:58 +00:00
dergoegge
e94c9d1712 [doc] Amend notes on benchmarking 2025-01-22 16:50:16 +01:00
Antoine Poinsot
5c3e4d8b29 doc: add a section about using MSan
Thanks to Niklas Pieter and Michael for the pointers.
2025-01-22 09:47:30 -05:00
Sjors Provoost
a4df12323c
doc: add release notes
Co-Authored-By: tdb3 <106488469+tdb3@users.noreply.github.com>
2025-01-22 12:31:46 +01:00
tdb3
c75872ffdd
test: use DIFF_1_N_BITS in tool_signet_miner 2025-01-22 12:31:46 +01:00
Sjors Provoost
4131f322ac
test: check difficulty adjustment using alternate mainnet 2025-01-22 12:31:46 +01:00
Sjors Provoost
c4f68c12e2
Use OP_0 for BIP34 padding in signet and tests
For blocks 1 through 15 the script_BIP34_coinbase_height appends OP_1
to comply with BIP34 and avoid bad-cb-length.

This is inconsistent with BlockAssembler::CreateNewBlock() which adds
OP_0 instead.

The utxo_total_supply fuzzer and MinerTestingSetup::Block also use OP_0.

Changing it is required to import the test vectors in the next commit.

It also ensures the test vectors can be regenerated using the CPU miner
at https://github.com/pooler/cpuminer without patches (it uses OP_0).

The same helper is used by the signet miner, so this will impact newly
bootstrapped signets.
2025-01-22 12:29:16 +01:00
Sjors Provoost
cf0a62878b
rpc: add next to getmininginfo
Obtain difficulty and target for the next block without having to call
getblocktemplate.
2025-01-22 12:28:45 +01:00
Sjors Provoost
2d18a078a2
rpc: add target and bits to getchainstates 2025-01-22 12:28:42 +01:00
Sjors Provoost
f153f57acc
rpc: add target and bits to getblockchaininfo 2025-01-22 12:28:38 +01:00
merge-script
523520f827
Merge bitcoin/bitcoin#30866: descriptor: Add proper Clone function to miniscript::Node
66d21d0eb6 qa: check parsed multipath descriptors dont share references (Antoine Poinsot)
09a1875ad8 miniscript: Make NodeRef a unique_ptr (Ava Chow)
9ccb46f91a miniscript: Ensure there is no NodeRef copy constructor or assignment operator (Ava Chow)
6d11c9c60b descriptor: Add proper Clone function to miniscript::Node (Ava Chow)

Pull request description:

  Multipath descriptors requires performing a deep copy, so a Clone function that does that is added to miniscript::Node instead of the current shallow copy.

  Fixes #30864

ACKs for top commit:
  darosior:
    re-ACK 66d21d0eb6
  hodlinator:
    re-ACK 66d21d0eb6 🚀
  brunoerg:
    reACK 66d21d0eb6

Tree-SHA512: bea017497ed3cc0b2da2df7e3ccae1fa4a324769b7da1065963da131235bd8bfdcdfe337a3fabbb3ab4d3822611211fca6a9772e18e2ee1cb3d853e831ff6f88
2025-01-22 11:23:09 +00:00
Sjors Provoost
baa504fdfa
rpc: add target to getmininginfo result 2025-01-22 12:04:02 +01:00
Sjors Provoost
2a7bfebd5e
Add target to getblock(header) in RPC and REST 2025-01-22 12:04:02 +01:00
Sjors Provoost
341f932516
rpc: add GetTarget helper 2025-01-22 12:04:02 +01:00
tdb3
d20d96fa41
test: use REGTEST_N_BITS in feature_block 2025-01-22 11:29:06 +01:00
Sjors Provoost
7ddbed4f9f
rpc: add nBits to getmininginfo
Also expands nBits test coverage.
2025-01-22 11:29:06 +01:00
Sjors Provoost
ba7b9f3d7b
build: move pow and chain to bitcoin_common
The next commit needs pow.cpp in rpc/util.cpp.
2025-01-22 11:29:05 +01:00
Sjors Provoost
c4cc9e3e9d
consensus: add DeriveTarget() to pow.h
Split CheckProofOfWorkImpl() to introduce a helper function
DeriveTarget() which converts the nBits value to the target.

The function takes pow_limit as an argument so later commits can
avoid having to pass ChainstateManager through the call stack.

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2025-01-22 11:29:05 +01:00
MarcoFalke
fa9aced800
test: Check that reindex with prune wipes blk files 2025-01-22 08:52:04 +01:00
Antoine Poinsot
66d21d0eb6 qa: check parsed multipath descriptors dont share references 2025-01-21 13:17:20 -05:00
Ava Chow
09a1875ad8 miniscript: Make NodeRef a unique_ptr
There's no need for it to be a shared_ptr.
2025-01-21 13:17:20 -05:00
Ava Chow
9ccb46f91a miniscript: Ensure there is no NodeRef copy constructor or assignment operator 2025-01-21 13:17:20 -05:00
Ava Chow
6d11c9c60b descriptor: Add proper Clone function to miniscript::Node
Multipath descriptors requires performing a deep copy, so a Clone
function that does that is added to miniscript::Node instead of the
current shallow copy.

Co-Authored-By: Antoine Poinsot <darosior@protonmail.com>
2025-01-21 13:17:18 -05:00
merge-script
5691fa93c4
Merge bitcoin/bitcoin#31661: depends: Override default build type for libevent
d44626a9c2 depends: Override default build type for `libevent` (Hennadii Stepanov)

Pull request description:

  This PR fixes a regression for the `libevent` package introduced in https://github.com/bitcoin/bitcoin/pull/29835.

  The `libevent` package defaults to the "Release" build type, which overrides our per-build-type optimization flags with `-O3`.

  To prevent this behavior, set `CMAKE_BUILD_TYPE` to "None", consistent with how other packages are handled.

ACKs for top commit:
  fanquake:
    ACK d44626a9c2

Tree-SHA512: 77abd2e28ad8dda86eb0548d8e49ecf23bac08a2e07dc35c71db62539aa659d471c863d361534c3cf693f9945c1b4f12de7e04eef05d11f8cc5e86d6eff5242d
2025-01-21 17:04:38 +00:00
merge-script
8fc7140846
Merge bitcoin/bitcoin#31671: Update leveldb subtree to latest upstream
910a11fa66 build: remove LEVELDB_IS_BIG_ENDIAN (fanquake)
d336b7ab85 Squashed 'src/leveldb/' changes from 688561cba8..04b5790928 (fanquake)

Pull request description:

  Includes:
  * https://github.com/bitcoin-core/leveldb-subtree/pull/40 (used in #29852)
  * https://github.com/bitcoin-core/leveldb-subtree/pull/45
  * https://github.com/bitcoin-core/leveldb-subtree/pull/46

ACKs for top commit:
  kevkevinpal:
    Concept ACK [910a11f](910a11fa66)
  l0rinc:
    ACK 910a11fa66
  hebasto:
    ACK 910a11fa66, I've performed a subtree update locally and got the same changes.
  theuni:
    utACK 910a11fa66

Tree-SHA512: c5a2224c67d3fd598bc682589b805c324abf91003032a85764766048030285f56154779f29d3f0b3673c8f7f497ae62de5fc6b95ef0b022c873750053c7d27d5
2025-01-21 17:01:10 +00:00
merge-script
a9edec9419
Merge bitcoin/bitcoin#31701: test: Bump sync_mempools timeout in p2p_1p1c_network.py
fa80a7dac4 test: Bump sync_mempools timeout in p2p_1p1c_network.py (MarcoFalke)
1111b0ac19 ci: Add missing --combinedlogslen to test-each-commit task (MarcoFalke)

Pull request description:

  This should address the two issues that happened in https://github.com/bitcoin/bitcoin/actions/runs/12885576442/job/35924329657?pr=25832#step:6:7601:

  * The combined log isn't printed on a test failure.
  * The timeout is too strict for the GHA virtual machines.

  For reference, the output was:

  ```
  ...
  149/315 - rpc_blockchain.py --v2transport passed, Duration: 10 s
  150/315 - p2p_addrfetch.py passed, Duration: 1 s
  151/315 - p2p_1p1c_network.py failed, Duration: 31 s

  stdout:
  2025-01-21T12:05:49.465000Z TestFramework (INFO): PRNG seed is: 6581340712385622842
  2025-01-21T12:05:49.466000Z TestFramework (INFO): Initializing test directory /tmp/test_runner_₿_🏃_20250121_120233/p2p_1p1c_network_207
  2025-01-21T12:05:52.408000Z TestFramework (INFO): Fill mempools with large transactions to raise mempool minimum feerates
  2025-01-21T12:05:52.408000Z TestFramework (INFO): Fill the mempool until eviction is triggered and the mempoolminfee rises
  2025-01-21T12:05:59.692000Z TestFramework (INFO): Pre-send some transactions to nodes
  2025-01-21T12:06:00.203000Z TestFramework (INFO): Submit full packages to node0
  2025-01-21T12:06:00.220000Z TestFramework (INFO): Wait for mempools to sync
  2025-01-21T12:06:20.384000Z TestFramework (ERROR): Assertion failed
  Traceback (most recent call last):
    File "/home/runner/work/bitcoin/bitcoin/test/functional/test_framework/test_framework.py", line 135, in main
      self.run_test()
    File "/home/runner/work/bitcoin/bitcoin/build/test/functional/p2p_1p1c_network.py", line 153, in run_test
      self.sync_mempools(timeout=20)
    File "/home/runner/work/bitcoin/bitcoin/test/functional/test_framework/test_framework.py", line 803, in sync_mempools
      raise AssertionError("Mempool sync timed out after {}s:{}".format(
  AssertionError: Mempool sync timed out after 20s:
  ...

ACKs for top commit:
  l0rinc:
    utACK fa80a7dac4
  glozow:
    ACK fa80a7dac4

Tree-SHA512: b326b7906b184fb47abc50d0d7ec91a6c90d324997f2abc40f156f588090e8d89bd8486bb8950cac604e77b1b336142a47b53ad463b2670d81222814eeb313d4
2025-01-21 16:49:42 +00:00
MarcoFalke
fa80a7dac4
test: Bump sync_mempools timeout in p2p_1p1c_network.py 2025-01-21 15:34:51 +01:00
MarcoFalke
1111b0ac19
ci: Add missing --combinedlogslen to test-each-commit task 2025-01-21 15:34:39 +01:00
Hennadii Stepanov
d44626a9c2
depends: Override default build type for libevent
The `libevent` package defaults to the "Release" build type, which
overrides our per-build-type optimization flags with `-O3`.

To prevent this behavior, set `CMAKE_BUILD_TYPE` to "None", consistent
with how other packages are handled.
2025-01-21 10:39:11 +00:00
merge-script
d7f56cc5d9
Merge bitcoin/bitcoin#31590: descriptors: Try pubkeys of both parities when retrieving the private keys for an xonly pubkey in a descriptor
c0045e6cee Add test for multipath miniscript expression (David Gumberg)
b4ac48090f descriptor: Use InferXOnlyPubkey for miniscript XOnly pubkey from script (Ava Chow)
4c50c21f6b tests: Check ExpandPrivate matches for both parsed descriptors (Ava Chow)
092569e858 descriptor: Try the other parity in ConstPubkeyProvider::GetPrivKey() (Ava Chow)

Pull request description:

  When a `ConstPubkeyProvider` is xonly, the stored pubkey does not necessarily have the correct parity bit. `ToPrivateString()` is correctly handling this by looking up the keys for both parity bits, but `GetPrivKey` does not. This results in not finding the private key when it is actually available if its pubkey has the other parity bit value.

  To fix this, this key finding is refactored into `GetPrivKey()` so that its behavior is corrected, and `ToPrivateString()` is changed to use `GetPrivKey()` as well.

  Additionally, the descriptor test checks are updated to include a check for `ExpandPrivate()` to verify that both the parsed public and private descriptors produce `SigningProvider`s with the same contents.

  Fixes #31589

ACKs for top commit:
  Pttn:
    ACK c0045e6cee
  davidgumberg:
    utACK c0045e6cee
  kevkevinpal:
    Concept and Code review ACK [c0045e6](c0045e6cee)
  furszy:
    ACK c0045e6cee
  theStack:
    re-ACK c0045e6cee
  rkrux:
    Concept ACK c0045e6cee

Tree-SHA512: 3dcf2a802b996e0680a3f819075e5a689eb22e484c81ea79b40ec04197ee4ba3f6b9c87c45dfe8a847c9b805b2fd0fad77ffb92a93e65dc3aad74d69d9e3d97f
2025-01-21 10:20:13 +00:00
MarcoFalke
fa9593efc2
test: Use high-level python types
Using the built-in open() and pathlib is identical and requires less code.

Also, remove redundant sync_blocks call.
2025-01-21 11:19:45 +01:00
MarcoFalke
fa8ade300f
refactor: Avoid GCC false positive error
This avoids an overly agressive GCC false positive warning:

error: ‘tmp’ may be used uninitialized [-Werror=maybe-uninitialized]
2025-01-20 17:43:58 +01:00
MarcoFalke
fa40807fa8
ci: Enable DEBUG=1 for one GCC-12+ build to catch 117966 regressions 2025-01-20 17:43:52 +01:00
merge-script
4601b7ca61
Merge bitcoin/bitcoin#31125: depends: add *FLAGS to gen_id
01df180bfb depends: add mold & ld.lld to gen_id (fanquake)
d032ac8063 depends: add *FLAGS to gen_id (fanquake)

Pull request description:

  The depends cache should be busted when flags change, the same as any other tooling change. I'd also like to start passing `*FLAGS` into depends inside the Guix env, which, without this change, doesn't bust the cache.

ACKs for top commit:
  hebasto:
    ACK 01df180bfb.

Tree-SHA512: 3809359fe763af9dde484e0c6bd3e262c4c09fcbe2f96ccf64194f5f9f840f5476b9c9929cf7bda7b8c14efeffd369cdb8c233625b79a944e1380df20698246f
2025-01-20 16:25:39 +00:00
merge-script
eb243ff06c
Merge bitcoin/bitcoin#31593: ci: Bump centos stream 10
faaabfaea7 ci: Bump centos stream 10 (MarcoFalke)

Pull request description:

  This is a follow-up to fa47baa03b, which bumped the gcc version to avoid a warning bloat in the CI log. However, it is also required to bump python3, see https://github.com/bitcoin/bitcoin/issues/31476#issue-2735206340

  > This will uncover an issue in the centos task that the correct python version is missing. I guess this should be fixed by installing and activating an acceptable python version.

  Instead of bumping the packages individually in centos stream 9, just bump to stream 10.

ACKs for top commit:
  fanquake:
    ACK faaabfaea7

Tree-SHA512: a564ff3a2a0dc4d39874e87540e67072f293bbed82c8eca22266fcadc16c5571e0e41d38576a63e466b64d13f7e3acbd95be10cf2420de33127aa420eca3b928
2025-01-20 16:11:58 +00:00
merge-script
6dc6012670
Merge bitcoin/bitcoin#31657: ci: Supply --platform argument to docker commands.
6e29de2101 ci: Supply `platform` argument to docker commands. (David Gumberg)

Pull request description:

  I ran into this issue when following the instructions in `ci/README.md` for running CI locally.

  Newer versions of docker require a `--platform` argument when building from a platform-specific image that differs from the host platform, I'm not sure when this change took place, but trying to build any of the cross-platform CI images on Docker 27.5.0 fails in the following manner:
  ```console
  $ # From ci/README.md
  $ env -i HOME="$HOME" PATH="$PATH" USER="$USER" bash -c 'FILE_ENV="./ci/test/00_setup_env_arm.sh" ./ci/test_run_all.sh'
  WARNING: The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64/v4) and no specific platform was requested
  Creating docker.io/arm64v8/debian:bookworm container to run in
  + docker build --file $BITCOIN_SRC/ci/test_imagefile --build-arg CI_IMAGE_NAME_TAG=docker.io/arm64v8/debian:bookworm --build-arg FILE_ENV=./ci/test/00_setup_env_arm.sh --label=bitcoin-ci-test --tag=ci_arm_linux $BITCOIN_SRC
  [+] Building 0.6s (2/2) FINISHED                                                                                                                                                 docker:default
   => [internal] load build definition from test_imagefile                                                                                                                                   0.0s
   => => transferring dockerfile: 600B                                                                                                                                                       0.0s
   => WARN: InvalidDefaultArgInFrom: Default value for ARG ${CI_IMAGE_NAME_TAG} results in empty or invalid base image name (line 8)                                                         0.0s
   => ERROR [internal] load metadata for docker.io/arm64v8/debian:bookworm                                                                                                                   0.5s
  ------
   > [internal] load metadata for docker.io/arm64v8/debian:bookworm:
  ------

   1 warning found (use docker --debug to expand):
   - InvalidDefaultArgInFrom: Default value for ARG ${CI_IMAGE_NAME_TAG} results in empty or invalid base image name (line 8)
  test_imagefile:8
  --------------------
     6 |
     7 |     ARG CI_IMAGE_NAME_TAG
     8 | >>> FROM ${CI_IMAGE_NAME_TAG}
     9 |
    10 |     ARG FILE_ENV
  --------------------
  ERROR: failed to solve: docker.io/arm64v8/debian:bookworm: failed to resolve source metadata for docker.io/arm64v8/debian:bookworm: no match for platform in manifest: not found
  ```

  This branch fixes this by setting the `--platform` argument of `docker build` and `docker run` with an environment variable `CI_IMAGE_PLATFORM` for each platform specific job, and `linux/{$cpuarch}` for any native jobs.

  Thi

  ## Steps to reproduce
  1. Install relevant dependencies, on Ubuntu:
  ```bash
  sudo apt install bash docker.io python3 qemu-user-static
  ```
  2. Run one of the platform-specific CI images, e.g.:
  ```bash
  env -i HOME="$HOME" PATH="$PATH" USER="$USER" bash -c 'FILE_ENV="./ci/test/00_setup_env_arm.sh" ./ci/test_run_all.sh'
  ```

ACKs for top commit:
  maflcko:
    lgtm ACK 6e29de2101
  hebasto:
    ACK 6e29de2101

Tree-SHA512: 81b9fa8ec1f3d21619d37d864047c8d7917ef2c8536851f80facf7f1973dfe14628d7755f12d2a9c6edebb6cb16877c582d4d41cdab52b73b23c44f08c6e6b30
2025-01-20 16:10:40 +00:00
merge-script
4e52a63443
Merge bitcoin/bitcoin#31691: util: fix compiler warning about deprecated space before _MiB
d3339a7cd5 util: fix compiler warning about deprecated space before _MiB (Vasil Dimov)

Pull request description:

  ```
  src/util/byte_units.h:13:29: error: identifier '_MiB' preceded by whitespace in a literal operator declaration is deprecated [-Werror,-Wdeprecated-literal-operator]
     13 | constexpr size_t operator"" _MiB(unsigned long long mebibytes)
        |                  ~~~~~~~~~~~^~~~
        |                  operator""_MiB
  1 error generated.
  ```

  Clang 20.0.0

ACKs for top commit:
  maflcko:
    lgtm ACK d3339a7cd5
  TheCharlatan:
    ACK d3339a7cd5

Tree-SHA512: 534537eefae2b6a9cef1ba3aa9ef16c491c84c0e55fb827f4ea0bae7ab61a5cc266a71499a79da97a9e68953a2c7f9cd1864ddde41fda173c829ed2b7bd73a46
2025-01-20 14:09:01 +00:00
merge-script
2e839dd641
Merge bitcoin/bitcoin#30774: depends: Qt 5.15.16
31a0e5f090 depends: Qt 5.15.16 (fanquake)

Pull request description:

  Contains a handful of miscellaneous bug fixes.
  We can drop a few of our patches.

  See https://github.com/qt/qtbase/compare/v5.15.14-lts-lgpl...v5.15.16-lts-lgpl.

ACKs for top commit:
  hebasto:
    ACK 31a0e5f090.
  TheCharlatan:
    ACK 31a0e5f090

Tree-SHA512: dd7b3332dd6ecb95189bc72364883425fb8869e03850791d2ee92555a37046c7abaaee16575a0396f1ce9674856b894563dbd36868c2cf46f9fee48028fd967b
2025-01-20 14:03:54 +00:00
Vasil Dimov
d3339a7cd5
util: fix compiler warning about deprecated space before _MiB
```
src/util/byte_units.h:13:29: error: identifier '_MiB' preceded by whitespace in a literal operator declaration is deprecated [-Werror,-Wdeprecated-literal-operator]
   13 | constexpr size_t operator"" _MiB(unsigned long long mebibytes)
      |                  ~~~~~~~~~~~^~~~
      |                  operator""_MiB
1 error generated.
```

Clang 20.0.0
2025-01-20 14:32:20 +01:00
David Gumberg
6e29de2101 ci: Supply platform argument to docker commands.
Later versions of docker require a `--platform` argument when building
and running from a platform-specific image that differs from the host
platform.
2025-01-17 10:36:41 -08:00
MarcoFalke
faaabfaea7
ci: Bump centos stream 10 2025-01-17 15:34:11 +01:00
merge-script
89720b7a1b
Merge bitcoin/bitcoin#31543: cmake: Always provide RPATH on NetBSD
11115e9aa8 cmake: Always provide `RPATH` on NetBSD (Hennadii Stepanov)

Pull request description:

  Apparently, runtime paths cannot be skipped on NetBSD, even for system-wide packages.

  On NetBSD 10.0:
  - on the master branch @ bb57017b29:
  ```
  $ cmake -B build -DCMAKE_C_COMPILER="/usr/pkg/gcc14/bin/gcc" -DCMAKE_CXX_COMPILER="/usr/pkg/gcc14/bin/g++"
  $ cmake --build build
  $ ./build/src/bitcoin-wallet -version
  ./build/src/bitcoin-wallet: Shared object "libsqlite3.so.0" not found
  $ cmake --install build --prefix /home/hebasto/INSTALL
  $ /home/hebasto/INSTALL/bin/bitcoin-wallet -version
  /home/hebasto/INSTALL/bin/bitcoin-wallet: Shared object "libsqlite3.so.0" not found
  ```
  - with this PR:
  ```
  $ cmake -B build -DCMAKE_C_COMPILER="/usr/pkg/gcc14/bin/gcc" -DCMAKE_CXX_COMPILER="/usr/pkg/gcc14/bin/g++"
  $ cmake --build build
  $ ./build/src/bitcoin-wallet -version | head -1
  Bitcoin Core bitcoin-wallet utility version v28.99.0-11115e9aa845
  $ cmake --install build --prefix /home/hebasto/INSTALL
  $ /home/hebasto/INSTALL/bin/bitcoin-wallet -version | head -1
  Bitcoin Core bitcoin-wallet utility version v28.99.0-11115e9aa845
  ```

ACKs for top commit:
  theuni:
    utACK 11115e9aa8

Tree-SHA512: c9cd5d8c65fcf12677c381060dd53794396b7cd3e61ec39d3c5dadd7cdc08ab9790c59aa346402d53f8f9f317830919edf7f8135a6c0d5703c3bd9e519b157a4
2025-01-17 14:11:33 +00:00
merge-script
5b3a81f44d
Merge bitcoin/bitcoin#31626: depends: Use base system's sha256sum utility on FreeBSD
727c542769 depends: Use base system's `sha256sum` utility (Hennadii Stepanov)

Pull request description:

  On FreeBSD, the `shasum` utility is provided by the [`perl5`](https://ports.freebsd.org/cgi/ports.cgi?query=%5Eperl5&stype=all&sektion=all) port, which is not part of the base system and must be [installed](0e3518579a/.github/workflows/freebsd.yml (L104)) separately. Note that this requirement is currently not documented in [`depends/README.md`](https://github.com/bitcoin/bitcoin/blob/master/depends/README.md).

  This PR switches to using the [`sha256sum`](https://man.freebsd.org/cgi/man.cgi?query=sha256sum&apropos=0&sektion=0&manpath=FreeBSD+14.2-RELEASE+and+Ports&arch=default&format=html) utility, which is included in the base system.

ACKs for top commit:
  davidgumberg:
    ACK 727c542769

Tree-SHA512: 41f11b80c2dc32514116400aa8ae57ef809edcbff5883dd62042d12ff14a54557864e2f1979c8705914242a2334880463da3e376f32c5b57a68fe41a90db1f85
2025-01-17 14:02:03 +00:00
merge-script
832d573073
Merge bitcoin/bitcoin#31651: ci: Turn CentOS task into native one
fabefd9915 ci: Turn CentOS task into native one (MarcoFalke)

Pull request description:

  Cross-compiling to `i686-pc-linux-gnu` on CentOS in the CI is mostly redundant with the `ci/test/00_setup_env_i686_multiprocess.sh` task (albeit it using clang):

  35bf426e02/ci/test/00_setup_env_i686_multiprocess.sh (L9-L12)

  One task seems sufficient as a sanity check, given that there seems to be no real demand for this architecture anyway.

  Turning the task into a native one makes it possible to run the task natively on aarch64 or any other supported architecture.

  Also, remove the install of the `lbzip2` package, which is unused since commit a46065e36c

  Also, remove the `CONFIG_SHELL` env var, which is unused since the cmake migration. (`CONFIG_SHELL` in depends is still kept).

ACKs for top commit:
  davidgumberg:
    ACK fabefd9915
  hebasto:
    ACK fabefd9915, tested locally on Ubuntu 24.10.

Tree-SHA512: 5a7b3131b379d11ef602e5821165861e9bdf61d605014bf8fcb33b8e12d8823450798af2d3289b96f7559dfa47b839bf939ddc0b3725efecfeac7ae570a981e7
2025-01-17 11:42:48 +00:00
merge-script
5ac1e0814a
Merge bitcoin/bitcoin#31621: doc: Update dependency installation for Debian/Ubuntu
160c27ec07 doc: Update dependency installation for Debian/Ubuntu and CI (Adlai Chandrasekhar)

Pull request description:

  This is similar to the recently-pushed 8d20348 and results in slightly cleaner systems for future Debian/Ubuntu builds.

  According to the description for pkg-config, "pkgconf is a replacement for pkg-config, providing additional functionality while also maintaining compatibility. This package only provides a dependency link to the pkgconf package to help with package upgrades. It can be safely removed."

  Thus the relevant sections of `doc/build-unix.md` and `depends/README.md` are updated.

ACKs for top commit:
  maflcko:
    weak ACK 160c27ec07
  fanquake:
    ACK 160c27ec07 - seems correct for modern distro versions, and using pkgconf on older ones also seems to work fine.

Tree-SHA512: fadeffe464073df91b706e30f560bfe332ce676521cc5d2044d3bf499f08d986ccaab0a10dd1178f626a90bbac3a4f8c445fe4f8e3a63960721664a247b758f7
2025-01-17 11:03:11 +00:00
merge-script
370b9c1a0b
Merge bitcoin/bitcoin#31675: [test] fix p2p_orphan_handling.py empty orphanage check
2e75ebb616 [test] fix p2p_orphan_handling.py empty orphanage check (glozow)

Pull request description:

  Fix CI: https://cirrus-ci.com/task/4584274617171968?logs=ci#L2784

ACKs for top commit:
  maflcko:
    lgtm ACK 2e75ebb616
  instagibbs:
    ACK 2e75ebb616
  theStack:
    ACK 2e75ebb616

Tree-SHA512: 7c5c4d1eb816368b2fdd8e090769ff586f69a9800a99ab99d42beda96c933b5c449dfece91b659d48e4c2d7dcaae0dde6441a294d33c991db3d85c15df0123b6
2025-01-17 09:37:21 +00:00
Sebastian Falbesoner
8996fef8ae test: p2p: check that INV messages not matching wtxidrelay are ignored 2025-01-17 01:44:15 +01:00
Cory Fields
2656a5658c tests: add a test for the new blocksdir lock 2025-01-16 21:06:21 +00:00
Cory Fields
bdc0a68e67 init: lock blocksdir in addition to datadir
This guards against 2 processes running with separate datadirs but the same
blocksdir.

It's not likely to happen currently, but may be more relevant in the future
with applications using the kernel.

Note that the kernel does not currently do any dir locking, but it should.
2025-01-16 21:06:21 +00:00
Cory Fields
cabb2e5c24 refactor: introduce a more general LockDirectories for init
No functional change. This is in preparation for adding additional directory
locks on startup.
2025-01-16 21:06:21 +00:00
Cory Fields
1db331ba76 init: allow a new xor key to be written if the blocksdir is newly created
A subsequent commit will add a .lock file to this dir at startup, meaning that
the blocksdir is never empty by the time the xor key is being read/written.

Ignore all hidden files when determining if this is the first run.
2025-01-16 21:06:21 +00:00
glozow
2e75ebb616 [test] fix p2p_orphan_handling.py empty orphanage check
It's possible getorphantxs isn't empty immediately. Prevent intermittent errors.
2025-01-16 13:56:12 -05:00
merge-script
f9032a4abb
Merge bitcoin/bitcoin#31242: wallet, desc spkm: Return SigningProvider only if we have the privkey
f6a6d91205 test: add check for getting SigningProvider for a CPubKey (Sebastian Falbesoner)
62a95f5af9 test: refactor: move `CreateDescriptor` helper to wallet test util module (Sebastian Falbesoner)
493656763f desc spkm: Return SigningProvider only if we have the privkey (Ava Chow)

Pull request description:

  If we know about a pubkey that's in our descriptor, but we don't have the private key, don't return a SigningProvider for that pubkey.

  This is specifically an issue for Taproot outputs that use the H point as the resulting PSBTs may end up containing irrelevant information because the H point was detected as a pubkey each unrelated descriptor knew about.

  Split from #29675

ACKs for top commit:
  fjahr:
    ACK f6a6d91205
  theStack:
    re-ACK f6a6d91205
  furszy:
    utACK f6a6d91205. Only reviewed the actual change in detail, not the test commit.

Tree-SHA512: 30a196e611a0c5d9ebe5baf6d896caaa6af66f1615463dbb0c31e52604d53cf342922bb9967b3c697b47083d76b0485c77a5f545bd6381247c8bc44321c70f97
2025-01-16 17:30:36 +00:00
merge-script
9dc4eedb67
Merge bitcoin/bitcoin#31673: doc: fix minor typos in comments
b30cc71e85 doc: fix typos (Adlai Chandrasekhar)

Pull request description:

  In the unrelated PR #31621 the linter reported a few typos, that are fixed in this commit. I used the "doc" prefix as it only modifies comments, so none of the more significant prefixes seem appropriate.

ACKs for top commit:
  maflcko:
    lgtm ACK b30cc71e85

Tree-SHA512: 7bba2d928fc0b98f62f96d9abf6dba98f699b386b75730271fa3e7b57a8a220df2265b699007f066e585e1db2ee3cbe5a272b74a8c153f6f8814c01e6de7a3ee
2025-01-16 16:21:14 +00:00
Adlai Chandrasekhar
b30cc71e85 doc: fix typos 2025-01-16 17:36:16 +02:00
Adlai Chandrasekhar
160c27ec07 doc: Update dependency installation for Debian/Ubuntu and CI
According to the description for pkg-config, "pkgconf is a
replacement for pkg-config, providing additional functionality
while also maintaining compatibility. This package only provides
a dependency link to the pkgconf package to help with package
upgrades. It can be safely removed."

Thus several scripts and markdown files are updated.
2025-01-16 17:31:13 +02:00
merge-script
df8bf65745
Merge bitcoin/bitcoin#31483: kernel: Move kernel-related cache constants to kernel cache
2a92702baf init: Use size_t consistently for cache sizes (TheCharlatan)
65cde3621d kernel: Move default cache constants to caches (TheCharlatan)
8826cae285 kernel: Move non-kernel db cache size constants (TheCharlatan)
e758b26b85 kernel: Move kernel-specific cache size options to kernel (TheCharlatan)
d5e2c4a409 fuzz: Add fuzz test for checked and saturating add and left shift (TheCharlatan)
c03a2795a8 util: Add integer left shift helpers (TheCharlatan)
8bd5f8a38c [refactor] init: Simplify coinsdb cache calculation (TheCharlatan)
5db7d4d3d2 doc: Correct docstring describing max block tree db cache (TheCharlatan)

Pull request description:

  Carrying non-kernel related fields in the cache sizes for the indexes is confusing for kernel library users. The cache sizes are set currently with magic numbers in bitcoin-chainstate. The comments for the cache size calculations are not completely clear. The constants for the cache sizes are also currently in `txdb.h`, which is not an ideal place for holding all cache size related constants.

  Solve these things by moving the kernel-specific cache size fields to their own struct and moving the constants to either the node or the kernel cache sizes.

  This slightly changes the way the cache is allocated if (and only if) the txindex and/or blockfilterindex is used. Since they are now given precedence over the block tree db cache, this results in a bit less cache being allocated to the block tree db, coinsdb and coins caches. The effect is negligible though, i.e. cache sizes with default dbcache reported through the logs are:

  master:
  ```
  Cache configuration:
  * Using 2.0 MiB for block index database
  * Using 56.0 MiB for transaction index database
  * Using 49.0 MiB for basic block filter index database
  * Using 8.0 MiB for chain state database
  * Using 335.0 MiB for in-memory UTXO set (plus up to 286.1 MiB of unused mempool space)
  ```

  this PR:
  ```
  Cache configuration:
  * Using 2.0 MiB for block index database
  * Using 56.2 MiB for transaction index database
  * Using 49.2 MiB for basic block filter index database
  * Using 8.0 MiB for chain state database
  * Using 334.5 MiB for in-memory UTXO set (plus up to 286.1 MiB of unused mempool space)
  ```

  ---
  This PR is part of the [libbitcoinkernel project](https://github.com/bitcoin/bitcoin/issues/27587).

ACKs for top commit:
  stickies-v:
    re-ACK 2a92702baf
  ryanofsky:
    Code review ACK 2a92702baf. Changes since last review are fixing size options to use size_t instead of int64_t again, simplifying CheckedLeftShift more, and making other minor suggested cleanups
  hodlinator:
    re-ACK 2a92702baf

Tree-SHA512: 98376eaa0660b1b8c096a5ce1f3e7c8c30e7cd6644de36856c2d3e573108cfc9473c93ebb3952b7881047b5ae6c85c5b096e6726f30f35be58b98eca07c8c785
2025-01-16 15:04:58 +00:00
merge-script
335798c496
Merge bitcoin/bitcoin#31397: p2p: track and use all potential peers for orphan resolution
86d7135e36 [p2p] only attempt 1p1c when both txns provided by the same peer (glozow)
f7658d9b14 [cleanup] remove p2p_inv from AddTxAnnouncement (glozow)
063c1324c1 [functional test] getorphantxs reflects multiple announcers (glozow)
0da693f7e1 [functional test] orphan handling with multiple announcers (glozow)
b6ea4a9afe [p2p] try multiple peers for orphan resolution (glozow)
1d2e1d709c [refactor] move creation of unique_parents to helper function (glozow)
c6893b0f0b [txdownload] remove unique_parents that we already have (glozow)
163aaf285a [fuzz] orphanage multiple announcer functions (glozow)
22b023b09d [unit test] multiple orphan announcers (glozow)
96c1a822a2 [unit test] TxOrphanage EraseForBlock (glozow)
04448ce32a [txorphanage] add GetTx so that orphan vin can be read (glozow)
e810842acd [txorphanage] support multiple announcers (glozow)
62a9ff1870 [refactor] change type of unique_parents to Txid (glozow)
6951ddcefd [txrequest] GetCandidatePeers (glozow)

Pull request description:

  Part of #27463.

  (Transaction) **orphan resolution** is a process that kicks off when we are missing UTXOs to validate an unconfirmed transaction. We currently request missing parents by txid; BIP 331 also defines a way to [explicitly request ancestors](https://github.com/bitcoin/bips/blob/master/bip-0331.mediawiki#handle-orphans-better).

  Currently, when we find that a transaction is an orphan, we only try to resolve it with the peer who provided the `tx`. If this doesn't work out (e.g. they send a `notfound` or don't respond), we do not try again. We actually can't, because we've already forgotten who else could resolve this orphan (i.e. all the other peers who announced the transaction).

  What is wrong with this? It makes transaction download less reliable, particularly for 1p1c packages which must go through orphan resolution in order to be downloaded.

  Can we fix this with BIP 331 / is this "duct tape" before the real solution?
  BIP 331 (receiver-initiated ancestor package relay) is also based on the idea that there is an orphan that needs resolution, but it's just a new way of communicating information. It's not inherently more honest; you can request ancestor package information and get a `notfound`. So ancestor package relay still requires some kind of procedure for retrying when an orphan resolution attempt fails. See the #27742 implementation which builds on this orphan resolution tracker to keep track of what packages to download (it just isn't rebased on this exact branch). The difference when using BIP 331 is that we request `ancpkginfo` and then `pkgtxns` instead of the parent txids.

  Zooming out, we'd like orphan handling to be:
  - Bandwidth-efficient: don't have too many requests out at once. As already implemented today, transaction requests for orphan parents and regular download both go through the `TxRequestTracker` so that we don't have duplicate requests out.
  - Not vulnerable to censorship: don't give up too easily, use all candidate peers. See e.g. https://bitcoincore.org/en/2024/07/03/disclose_already_asked_for/
  - Load-balance between peers: don't overload peers; use all peers available. This is also useful for when we introduce per-peer orphan protection, since each peer will have limited slots.

  The approach taken in this PR is to think of each peer who announces an orphan as a potential "orphan resolution candidate." These candidates include:
  - the peer who sent us the orphan tx
  - any peers who announced the orphan prior to us downloading it
  - any peers who subsequently announce the orphan after we have started trying to resolve it
  For each orphan resolution candidate, we treat them as having "announced" all of the missing parents to us at the time of receipt of this orphan transaction (or at the time they announced the tx if they do so after we've already started tracking it as an orphan). We add the missing parents as entries to `m_txrequest`, incorporating the logic of typical txrequest processing, which means we prefer outbounds, try not to have duplicate requests in flight, don't overload peers, etc.

ACKs for top commit:
  marcofleon:
    Code review ACK 86d7135e36
  instagibbs:
    reACK 86d7135e36
  dergoegge:
    Code review ACK 86d7135e36
  mzumsande:
    ACK 86d7135e36

Tree-SHA512: 618d523b86e60c3ea039e88326d50db4e55e8e18309c6a20e8f2b10ed9e076f1de0315c335fd3b8abdabcc8b53cbceb66fb59147d05470ea25b83a2b4bd9c877
2025-01-16 13:42:26 +00:00
merge-script
98939ce7b7
Merge bitcoin/bitcoin#31655: refactor: Avoid UB in SHA3_256::Write
fabeca3458 refactor: Avoid UB in SHA3_256::Write (MarcoFalke)
fad4032b21 refactor: Drop unused UCharCast (MarcoFalke)

Pull request description:

  It is UB to apply a distance to a pointer or iterator further than the
  end itself, even if the distance is (partially) revoked later on.

  Fix the issue by advancing the data pointer at most to the end.

  This fix is required to adopt C++ safe buffers https://github.com/bitcoin/bitcoin/issues/31272.

  Also included is a somewhat unrelated commit.

ACKs for top commit:
  sipa:
    utACK fabeca3458
  theuni:
    utACK fabeca3458
  hebasto:
    ACK fabeca3458.

Tree-SHA512: 78c53691322b72c3ba9c25ec94eec275dbbbc3049b0ad45e7d9fb2df0afbbaa905b0d8fa7106a3582f937bb1dc15a7592c4ad2d80fe4cff1062a3acfd3638f08
2025-01-16 12:20:05 +00:00
fanquake
910a11fa66
build: remove LEVELDB_IS_BIG_ENDIAN 2025-01-16 11:10:23 +00:00
fanquake
9ec64253ab
Update leveldb subtree to latest upstream 2025-01-16 11:09:56 +00:00
fanquake
d336b7ab85 Squashed 'src/leveldb/' changes from 688561cba8..04b5790928
04b5790928 Merge bitcoin-core/leveldb-subtree#46: Fix invalid pointer arithmetic in Hash (#1222)
59669817c5 Merge bitcoin-core/leveldb-subtree#40: cherry-pick: Remove leveldb::port::kLittleEndian.
73013d1a37 Merge bitcoin-core/leveldb-subtree#45: [jumbo] Add begin()/end() to Slice.
a8844b23ab Fix invalid pointer arithmetic in Hash (#1222)
be4dfc94b3 [jumbo] Add begin()/end() to Slice.
2e3c0131d3 Remove leveldb::port::kLittleEndian.

git-subtree-dir: src/leveldb
git-subtree-split: 04b57909285c7335c1908d53bcde9b90fe0439be
2025-01-16 11:09:56 +00:00
merge-script
712cab3a8f
Merge bitcoin/bitcoin#31061: refactor: Check translatable format strings at compile-time
fa3efb5729 refactor: Introduce struct to hold a runtime format string (MarcoFalke)
fa6adb0134 lint: Remove unused and broken format string linter (MarcoFalke)
fadc6b9bac refactor: Check translatable format strings at compile-time (MarcoFalke)
fa1d5acb8d refactor: Use TranslateFn type consistently (MarcoFalke)
eeee6cf2ff refactor: Delay translation of _() literals (MarcoFalke)

Pull request description:

  All translatable format strings are fixed. This change surfaces errors in them at compile-time.

  The implementation achieves this by allowing to delay the translation (or `std::string` construction) that previously happened in `_()` by returning a new type from this function. The new type can be converted to `bilingual_str` where needed.

  This can be tested by adding a format string error in an original string literal and observing a new compile-time failure.

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

ACKs for top commit:
  stickies-v:
    re-ACK fa3efb5729
  ryanofsky:
    Code review ACK fa3efb5729. Since last review added TranslateFn commit, clarified FormatStringCheck documentation, dropped redundant `inline` keyword

Tree-SHA512: 28fa1db11e85935d998031347bd519675d75c171c8323b0ed6cdd0b628c95250bb86b30876946cc48840ded541e95b8a152696f9f2b13a5f28f5673228ee0509
2025-01-15 15:47:00 +00:00
TheCharlatan
2a92702baf
init: Use size_t consistently for cache sizes
This avoids having to rely on implicit casts when passing them to the
various functions allocating the caches.

This also ensures that if the requested amount of db_cache does not fit
in a size_t, it is clamped to the maximum value of a size_t.

Also take this opportunity to make the total amounts of cache in the
chainstate manager a size_t too.
2025-01-15 15:44:56 +01:00
TheCharlatan
65cde3621d
kernel: Move default cache constants to caches
They are not related to the txdb, so a better place for them is the
new kernel and node cache file. Re-use the default amount of kernel
cache for the default node cache.
2025-01-15 15:44:55 +01:00
TheCharlatan
8826cae285
kernel: Move non-kernel db cache size constants
These have nothing to do with the txdb, so move them out and into the
node caches.
2025-01-15 15:44:44 +01:00
TheCharlatan
e758b26b85
kernel: Move kernel-specific cache size options to kernel
Carrying non-kernel related fields in the cache sizes for the indexes is
confusing for kernel library users. The cache sizes also are set
currently with magic numbers in bitcoin-chainstate. The comments for the
cache size calculations are also not completely clear.

Solve these things by moving the kernel-specific cache size fields to
their own struct.

This slightly changes the way the cache is allocated if the txindex
and/or blockfilterindex is used. Since they are now given precedence
over the block tree db cache, this results in a bit less cache being
allocated to the block tree db, coinsdb and coins caches. The effect is
negligible though, i.e. cache sizes with default dbcache reported
through the logs are:

master:
Cache configuration:
* Using 2.0 MiB for block index database
* Using 56.0 MiB for transaction index database
* Using 49.0 MiB for basic block filter index database
* Using 8.0 MiB for chain state database
* Using 335.0 MiB for in-memory UTXO set (plus up to 286.1 MiB of unused mempool space)

this branch:
Cache configuration:
* Using 2.0 MiB for block index database
* Using 56.2 MiB for transaction index database
* Using 49.2 MiB for basic block filter index database
* Using 8.0 MiB for chain state database
* Using 334.5 MiB for in-memory UTXO set (plus up to 286.1 MiB of unused mempool space)
2025-01-15 15:44:16 +01:00
TheCharlatan
d5e2c4a409
fuzz: Add fuzz test for checked and saturating add and left shift
Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2025-01-15 15:44:03 +01:00
TheCharlatan
c03a2795a8
util: Add integer left shift helpers
The helpers are used in the following commits to increase the safety of
conversions during cache size calculations.

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
Co-authored-by: stickies-v <stickies-v@protonmail.com>
2025-01-15 15:43:05 +01:00
fanquake
31a0e5f090
depends: Qt 5.15.16 2025-01-15 11:52:27 +00:00
MarcoFalke
fa3efb5729
refactor: Introduce struct to hold a runtime format string
This brings the format types closer to the standard library types:

* FormatStringCheck corresponds to std::basic_format_string, with
  compile-time checks done via ConstevalFormatString
* RuntimeFormat corresponds to std::runtime_format, with no compile-time
  checks done.

Also, it documents where no compile-time checks are done.
2025-01-15 12:16:08 +01:00
MarcoFalke
fa6adb0134
lint: Remove unused and broken format string linter
The linter has many implementation bugs and missing features.

Also, it is completely redundant with FormatStringCheck, which
constructs from ConstevalFormatString or a runtime format string.
2025-01-15 12:16:07 +01:00
MarcoFalke
fadc6b9bac
refactor: Check translatable format strings at compile-time 2025-01-15 12:15:54 +01:00
MarcoFalke
fa1d5acb8d
refactor: Use TranslateFn type consistently
The type was introduced in the previous commit.
2025-01-15 12:15:40 +01:00
Sebastian Falbesoner
e0b3336822 test: p2p: fix sending of manual INVs in tx download test
The `test_inv_block` sub-test in p2p_tx_download.py has a subtle bug:
the manual msg_inv announcements from peers currently have no effect,
since they don't match the wtxidrelay setting (=true by default for
`P2PInterface` instances) and are hence ignored by the nodes (since
2d282e0c / PR #18044).  Though the test still passes, it does so without
the intended scenario of asking an additional peer (triggering the
GETDATA_TX_INTERVAL delay). Fix this by sending the INV message with
MSG_WTX instead of MSG_TX. This increases the test run time by about one
minute.
2025-01-15 03:50:23 +01:00
glozow
e7c4794955
Merge bitcoin/bitcoin#31630: doc: Archive 28.1 release notes
bb5f76ee01 doc: Archive 28.1 release notes (Ava Chow)

Pull request description:

ACKs for top commit:
  rkrux:
    reACK bb5f76ee01
  laanwj:
    ACK bb5f76ee01

Tree-SHA512: f146f760f61154627df6109fa4cceb9717e7bfae8c04c82a0562a458a26f47036e3831374108d1261bbc35f3ff51615840c8f7e074d0f83ed3489b224eb6ec07
2025-01-14 16:06:24 -05:00
glozow
7cd862aab9
Merge bitcoin/bitcoin#31646: test: avoid internet traffic
2ed161c5ce test: avoid generating non-loopback traffic from p2p_dns_seeds.py (Vasil Dimov)
a5746dc559 test: avoid generating non-loopback traffic from feature_config_args.py (Vasil Dimov)
6b3f6eae70 test: avoid generating non-loopback traffic from p2p_seednode.py (Vasil Dimov)

Pull request description:

  Avoid generating outbound traffic on a non-loopback interface during tests. Fix all tests, including ones that generate DNS traffic.

  ---

  This is a subset of https://github.com/bitcoin/bitcoin/pull/31349 containing only the changes to the tests, without the CI changes to detect future regressions.

ACKs for top commit:
  kevkevinpal:
    light code review ACK [2ed161c](2ed161c5ce)
  brunoerg:
    code review ACK 2ed161c5ce
  BrandonOdiwuor:
    Code Review ACK 2ed161c5ce
  jonatack:
    ACK 2ed161c5ce

Tree-SHA512: 34dcd4a4d0c4edaa68cc7263540af01afd6ef6e90fd6a43dcd1e989dbd7d32cb2c24ad9e68fde75866a935e6dbfe10d45c10f0bc674f40f9ac72ef964e5a380a
2025-01-14 16:01:34 -05:00
MarcoFalke
eeee6cf2ff
refactor: Delay translation of _() literals
This is required for a future commit that requires _() to be consteval
for format literals.

Co-Authored-By: Ryan Ofsky <ryan@ofsky.org>
2025-01-14 19:21:37 +01:00
MarcoFalke
fabeca3458
refactor: Avoid UB in SHA3_256::Write
It is UB to apply a distance to a pointer or iterator further than the
end itself, even if the distance is (partially) revoked later on.

Fix the issue by advancing the data pointer at most to the end.
2025-01-14 19:09:30 +01:00
MarcoFalke
fad4032b21
refactor: Drop unused UCharCast
This is no longer needed after commit
6aa0e70ccb
2025-01-14 19:01:53 +01:00
Vasil Dimov
2ed161c5ce
test: avoid generating non-loopback traffic from p2p_dns_seeds.py
`p2p_dns_seeds.py` would try to connect to the DNS server configured on
the machine and resolve `dummySeed.invalid`.

To block that configure an unavailable proxy which will be used also to
connect to the name server. The test needs 2 successful connections to
other peers (two Python `P2PInterface`s) and they work in spite of the
unavailable proxy because they are on `127.0.0.1` (`NET_UNROUTABLE`) and
the proxy is not used for that.
2025-01-14 09:21:24 +01:00
Vasil Dimov
a5746dc559
test: avoid generating non-loopback traffic from feature_config_args.py
`feature_config_args.py` uses a proxy address of `1.2.3.4`. This results
in actually trying to open TCP connections over the internet to
`1.2.3.4:9050`.

The test does not need those to succeed so use `127.0.0.1:1` instead.

Also avoid `-noconnect=0` because that is interpreted as `-connect=1`
which is interpreted as `-connect=0.0.0.1` and a connection to
`0.0.0.1:18444` is attempted.
2025-01-14 09:21:23 +01:00
Vasil Dimov
6b3f6eae70
test: avoid generating non-loopback traffic from p2p_seednode.py
`p2p_seednode.py` would try to connect to `0.0.0.1` and `0.0.0.2` as
seed nodes. This sends outbound TCP packets on a non-loopback interface
to the default router.

Configure an unavailable proxy for all executions of `bitcoind` during
this test. Also change `0.0.0.1` and `0.0.0.2` because connecting to
them would skip the `-proxy=` setting because for such an address:
* `CNetAddr::IsLocal()` is true, thus
* `CNetAddr::IsRoutable()` is false, thus
* `CNetAddr::GetNetwork()` is `NET_UNROUTABLE`, even though
  `CNetAddr::m_net` is `NET_IPV4`.

This speeds up the execution time of `p2p_seednode.py`
from 12.5s to 2.5s.
2025-01-14 09:20:58 +01:00
MarcoFalke
fabefd9915
ci: Turn CentOS task into native one 2025-01-13 23:50:08 +01:00
Ava Chow
bb5f76ee01 doc: Archive 28.1 release notes 2025-01-13 11:52:54 -05:00
merge-script
35bf426e02
Merge bitcoin/bitcoin#28724: wallet: Cleanup accidental encryption keys in watchonly wallets
69e95c2b4f tests: Test cleanup of mkeys from wallets without privkeys (Andrew Chow)
2b9279b50a wallet: Remove unused encryption keys from watchonly wallets (Andrew Chow)
813a16a463 wallet: Add HasCryptedKeys (Andrew Chow)

Pull request description:

  An earlier version allowed users to create watchonly wallets (wallets without private keys) that were "encrypted". Such wallets would have a stored encryption keys, but nothing would actually be encrypted with them. This can cause unexpected behavior such as https://github.com/bitcoin-core/gui/issues/772.

  We can detect such wallets as they will have the disable private keys flag set, no encrypted keys, and encryption keys. For such wallets, we can remove those encryption keys thereby avoiding any issues that may result from this unexpected situation.

ACKs for top commit:
  sipa:
    utACK 69e95c2b4f.
  laanwj:
    Code review re-ACK 69e95c2b4f
  furszy:
    Code review ACK 69e95c2b4f

Tree-SHA512: 901932cd709c57e66c598f011f0105a243b5a8b539db2ef3fcf370dca4cf35ae09bc1110e8fca8353be470f159468855a4dd96b99bc9c1112adc86ccc50e1b9d
2025-01-10 15:29:47 +00:00
brunoerg
4da7bfdcc9 test: add coverage for unknown address type for createwalletdescriptor 2025-01-10 11:41:50 -03:00
merge-script
2168406597
Merge bitcoin/bitcoin#31608: doc: Clarify min macOS and Xcode version
fa029a7878 doc: Clarify min macOS and Xcode version (MarcoFalke)

Pull request description:

  Two minor doc fixups:

  * Clarify that `macOS 13.0+` means `macOS 13+`, indicating that on any major version, only the latest security release is supported.
  * Clarify that the Xcode version was selected based on the minimum required macOS version and the minimum required clang version.

ACKs for top commit:
  jarolrod:
    ACK fa029a7878
  hebasto:
    re-ACK fa029a7878.
  theuni:
    ACK fa029a7878

Tree-SHA512: d34910fcc22e57021d7642938e5886419d2b711e1062cbc4fc3da48baf07377231f9d7b394e22ccb17e830d058c8c797dbd1bbffcc7c8828601bb500e1154a9e
2025-01-10 13:53:37 +00:00
merge-script
2f6c7e7f6c
Merge bitcoin/bitcoin#31612: ci: build msan's libc++ with _LIBCPP_ABI_BOUNDED_*
fb37acd932 ci: build msan's libc++ with _LIBCPP_ABI_BOUNDED_* (Vasil Dimov)

Pull request description:

  For the task `MSan, depends (Cirrus CI)` we build a custom libc++ for which we already use `-DLIBCXX_HARDENING_MODE=debug`. Compile it also with `_LIBCPP_ABI_BOUNDED_*` to enable further checks.

  Docs at: https://libcxx.llvm.org/Hardening.html#abi-options

ACKs for top commit:
  maflcko:
    review ACK fb37acd932

Tree-SHA512: 7687b47e86c524c947dd4311289cdd9bc3dd25e31e844375781a37c110f8ab65bdfcc485f17fd3b20f070cc93187f0ba2ad45089451220f31309c143bb21cc3f
2025-01-10 13:48:20 +00:00
fanquake
01df180bfb
depends: add mold & ld.lld to gen_id
We use `lld` when cross-compiling for macOS, and it's version should
be tied to LLVM. However someone compiling with GCC and `-fuse-ld=lld`
would not see a cache bust if the LLVM toolchain was updated.

We don't use `mold` directly, but I'm aware of it's usage in
infrastructure, along with depends, used to test the project.
2025-01-10 12:38:47 +00:00
fanquake
d032ac8063
depends: add *FLAGS to gen_id
The depends cache should be busted when flags change, the same as any
other tooling change. Id also like to start passing *FLAGS into depends
inside the Guix env, which, without this change, doesn't bust the cache.
2025-01-10 12:38:25 +00:00
merge-script
528354e213
Merge bitcoin/bitcoin#31616: init,log: Unify block index log line
e04be3731f init,log: Unify block index and chainstate loading log line (Lőrinc)

Pull request description:

  The line has been present since the beginning.

  Removed redundant duration as well since it can be recovered from the timestamps.

  Example logs before the change:
  ```
  2025-01-07T11:58:33Z Verification progress: 99%
  2025-01-07T11:58:33Z Verification: No coin database inconsistencies in last 6 blocks (18905 transactions)
  2025-01-07T11:58:33Z  block index           31892ms
  2025-01-07T11:58:33Z Setting NODE_NETWORK on non-prune mode
  ```

ACKs for top commit:
  maflcko:
    lgtm ACK e04be3731f
  TheCharlatan:
    ACK e04be3731f
  danielabrozzoni:
    tACK e04be3731f
  BrandonOdiwuor:
    Code Review ACK e04be3731f

Tree-SHA512: cbe4569a17f56ff23e829b837a083c2f730cc490b47bee3bac12126e2257e0ba9ebe9b4384deb03203a0a60aac3b8d283c5d31a6d0481635ba011ac6e2c61ad1
2025-01-10 11:27:04 +00:00
merge-script
4bedfb5c83
Merge bitcoin/bitcoin#31623: tracing: Rename the MIN macro to _TRACEPOINT_TEST_MIN in log_raw_p2p_msgs
f93f0c9396 tracing: Rename the `MIN` macro to `_TRACEPOINT_TEST_MIN` in log_raw_p2p_msgs (0xb10c)

Pull request description:

  Inspired by: 00c1dbd26d (#31419)

  Unless there's a reason we *don't* want the same change here...?

ACKs for top commit:
  maflcko:
    review ACK f93f0c9396 🔶
  0xB10C:
    tested ACK f93f0c9396

Tree-SHA512: 2af2c21e575f496b966928bcffeb92847d1acab8d5e7442d0e08e27358228df326783eb576f0364001b666e956fd8efde1c50dab67d7750a0a6b65b7acec12ae
2025-01-10 11:23:32 +00:00
merge-script
e5c268084e
Merge bitcoin/bitcoin#31627: depends: Fix spacing issue
8a46286da6 depends: Fix spacing issue (Hennadii Stepanov)

Pull request description:

  This PR resolves an issue where a missing space caused the value of the `build_AR` variable to be concatenated with the "NM=" string. This resulted in subsequent calls to `${AR}` and `${NM}` failing.

  Here is a diff for the `make -C depends print-build_id DEBUG=1` output:
  ```diff
  @@ -110,50 +110,18 @@
   CXX_STANDARD=c++20
   END CXX
   BEGIN AR
  -ar: invalid option -- '='
  -Usage: ar [emulation options] [-]{dmpqrstx}[abcDfilMNoOPsSTuvV] [--plugin <name>] [member-name] [count] archive-file file...
  -       ar -M [<mri-script]
  - commands:
  -  d            - delete file(s) from the archive
  -  m[ab]        - move file(s) in the archive
  -  p            - print file(s) found in the archive
  -  q[f]         - quick append file(s) to the archive
  -  r[ab][f][u]  - replace existing or insert new file(s) into the archive
  -  s            - act as ranlib
  -  t[O][v]      - display contents of the archive
  -  x[o]         - extract file(s) from the archive
  - command specific modifiers:
  -  [a]          - put file(s) after [member-name]
  -  [b]          - put file(s) before [member-name] (same as [i])
  -  [D]          - use zero for timestamps and uids/gids (default)
  -  [U]          - use actual timestamps and uids/gids
  -  [N]          - use instance [count] of name
  -  [f]          - truncate inserted file names
  -  [P]          - use full path names when matching
  -  [o]          - preserve original dates
  -  [O]          - display offsets of files in the archive
  -  [u]          - only replace files that are newer than current archive contents
  - generic modifiers:
  -  [c]          - do not warn if the library had to be created
  -  [s]          - create an archive index (cf. ranlib)
  -  [l <text> ]  - specify the dependencies of this library
  -  [S]          - do not build a symbol table
  -  [T]          - deprecated, use --thin instead
  -  [v]          - be verbose
  -  [V]          - display the version number
  -  @<file>      - read options from <file>
  -  --target=BFDNAME - specify the target object format as BFDNAME
  -  --output=DIRNAME - specify the output directory for extraction operations
  -  --record-libdeps=<text> - specify the dependencies of this library
  -  --thin       - make a thin archive
  - optional:
  -  --plugin <p> - load the specified plugin
  - emulation options:
  -  No emulation specific options
  -ar: supported targets: elf64-x86-64 elf32-i386 elf32-iamcu elf32-x86-64 pei-i386 pe-x86-64 pei-x86-64 elf64-little elf64-big elf32-little elf32-big elf64-littleaarch64 elf64-bigaarch64 elf32-littleaarch64 elf32-bigaarch64 elf32-littlearm elf32-bigarm pei-aarch64-little pe-aarch64-little elf64-alpha ecoff-littlealpha elf32-littlearm-fdpic elf32-bigarm-fdpic elf32-hppa-linux elf32-hppa elf64-ia64-little elf64-ia64-big pei-ia64 elf64-loongarch elf32-loongarch pei-loongarch64 elf32-m32r-linux elf32-m32rle-linux elf32-m68k elf32-tradbigmips elf32-tradlittlemips ecoff-bigmips ecoff-littlemips elf32-ntradbigmips elf64-tradbigmips elf32-ntradlittlemips elf64-tradlittlemips elf32-powerpc aixcoff-rs6000 elf32-powerpcle ppcboot elf64-powerpc elf64-powerpcle aixcoff64-rs6000 aix5coff64-rs6000 elf64-littleriscv elf32-littleriscv elf32-bigriscv elf64-bigriscv pei-riscv64-little elf32-s390 elf64-s390 elf32-sh-linux elf32-shbig-linux elf32-sh-fdpic elf32-shbig-fdpic elf32-sparc elf64-sparc pe-bigobj-x86-64 pe-i386 pdb srec symbolsrec verilog tekhex binary ihex plugin
  +GNU ar (GNU Binutils for Ubuntu) 2.42
  +Copyright (C) 2024 Free Software Foundation, Inc.
  +This program is free software; you may redistribute it under the terms of
  +the GNU General Public License version 3 or (at your option) any later version.
  +This program has absolutely no warranty.
   END AR
   BEGIN NM
  -bash: line 1: --version: command not found
  +GNU nm (GNU Binutils for Ubuntu) 2.42
  +Copyright (C) 2024 Free Software Foundation, Inc.
  +This program is free software; you may redistribute it under the terms of
  +the GNU General Public License version 3 or (at your option) any later version.
  +This program has absolutely no warranty.
   END NM
   BEGIN RANLIB
   GNU ranlib (GNU Binutils for Ubuntu) 2.42
  @@ -321,5 +289,5 @@
   NO_HARDEN=
   END NO_HARDEN
   END ALL
  -build_id=b7effe2aa166e73f6d2587fb4805ea1cca4d3f1e5c3aae2cfd59c592816b05e3
  +build_id=4173a5f75182c792550652e621f6b4a68cc27c8909385580d4efc7bc7a769f51
   make: Leaving directory '/home/hebasto/git/bitcoin/depends'
  ```

  It was accidentally introduced in https://github.com/bitcoin/bitcoin/pull/29249.

ACKs for top commit:
  theuni:
    Nice catch. utACK 8a46286da6
  TheCharlatan:
    ACK 8a46286da6

Tree-SHA512: f50f3dea1f5fa545316743e61f69ad1a3b7de674604a560fd2a8d7095788cddfae4f88bee19eb2eed2e27800f94ec12bd8ee7e17d65f2a6839530d3646e5440d
2025-01-10 11:17:28 +00:00
merge-script
d695d13917
Merge bitcoin/bitcoin#31611: doc: upgrade license to 2025.
b537a2c02a doc: upgrade license to 2025. (Kay)

Pull request description:

ACKs for top commit:
  maflcko:
    lgtm ACK b537a2c02a
  theuni:
    ACK b537a2c02a

Tree-SHA512: 245a2c2a6b4b422f6013e12283fc74da52909c64d5d1bf6622deb5a06e6d4a114e8dccfaa106fb4b5e5fa7abf166e3c34baef2463276d2f110605fe0389680cd
2025-01-10 11:03:05 +00:00
Hodlinator
bbac17608d
net: Bring back log message when resetting socket
Useful in case new disconnects creep in which are not using DisconnectMsg().
2025-01-10 11:25:08 +01:00
Hodlinator
04b848e482
net: Specify context in disconnecting log message 2025-01-10 11:25:08 +01:00
Hodlinator
0c4954ac7d
net_processing: Add missing use of DisconnectMsg
Makes it easier to grep logs for "disconnecting" when investigating disconnections.
2025-01-10 11:25:08 +01:00
Ava Chow
37af8bfb34
Merge bitcoin/bitcoin#31549: fuzz: Abort if system time is called without mock time being set
a96b84cb1b fuzz: Abort when calling system time without setting mock time (marcofleon)
ff21870e20 fuzz: Add SetMockTime() to necessary targets (marcofleon)

Pull request description:

  This PR expands the `CheckGlobals` utility that was introduced in https://github.com/bitcoin/bitcoin/pull/31486 and should help with fuzz stability (https://github.com/bitcoin/bitcoin/issues/29018).

  System time shouldn't be used when running a fuzz test, as it is likely to introduce instability (non-determinism). This PR identifies and fixes the targets that were calling system time without setting mock time at the start of an iteration.

  Removing`SetMockTime()` from any one of these targets should result in a crash and a message describing the issue.

ACKs for top commit:
  achow101:
    ACK a96b84cb1b
  dergoegge:
    Code review ACK a96b84cb1b
  brunoerg:
    crACK a96b84cb1b

Tree-SHA512: e093a9feb8a397954f7b1416dfa8790b2733f09d5ac51fda5a9d225a55ebd8f99135aa52bdf5ab531653ad1a3739c4ca2b5349c1d989bb4b009ec8eaad684f7d
2025-01-09 19:31:07 -05:00
Ava Chow
54115d8de5
Merge bitcoin/bitcoin#31617: build, test: Build db_tests.cpp regardless of USE_BDB
fd2d96d908 build, test: Build `db_tests.cpp` regardless of `USE_BDB` (Hennadii Stepanov)

Pull request description:

  When the building of `db_tests.cpp` was made conditional on `USE_BDB` in commit a58b719cf7, all `db_tests` were indeed specific to BDB wallets.

  However, the tests have since been [extended](ba616b932c) to include SQLite wallets as well.

  On the master branch @ 433412fd84, tests specific to SQLite wallets are not built and run if configured with `WITH_BDB=OFF` (the default option).

  This PR resolves this issue by guarding BDB-specific code in `db_tests.cpp` and ensuring this source file is compiled regardless of the `WITH_BDB` option.

ACKs for top commit:
  achow101:
    ACK fd2d96d908
  maflcko:
    review ACK fd2d96d908 🔺
  theuni:
    utACK fd2d96d908

Tree-SHA512: bd9eddf16af60c568e931467d39e9e23a268e82e367ab630c23ac3cfd37e6007c6d78579b69ccbeebc1911c749cdbe75794fd56d7fbdb30c6fea6d2ab11017a3
2025-01-09 18:46:07 -05:00
Ava Chow
0a77441158
Merge bitcoin/bitcoin#31451: wallet: migration, avoid loading legacy wallet after failure when BDB isn't compiled
589ed1a8ea wallet: migration, avoid loading wallet after failure when it wasn't loaded before (furszy)

Pull request description:

  Fixes #31447.

  During migration failure, only load wallet back into memory when the wallet was
  loaded prior to migration. This fixes the case where BDB is not supported, which
  implies that no legacy wallet can be loaded into memory due to the lack of db
  writing functionality.

  Link to error description https://github.com/bitcoin/bitcoin/issues/31447#issuecomment-2528757140.

  This PR also improves migration backup related comments to better document the
  current workflow.

ACKs for top commit:
  achow101:
    ACK 589ed1a8ea
  rkrux:
    ACK 589ed1a8ea
  pablomartin4btc:
    tACK 589ed1a8ea

Tree-SHA512: c7a489d2b253c574ee0287b691ebe29fe8d026f659f68a3f6108eca8b4e1e420c67ca7803c6bd70c1e1440791833fabca3afbcf8fe8524c6c9fc08de95b618d0
2025-01-09 18:33:23 -05:00
Ava Chow
56725f8829
Merge bitcoin/bitcoin#31462: test: raise explicit error if any of the needed release binaries is missing
1ea7e45a1f test: raise explicit error if any of the needed release binaries is missing (Sebastian Falbesoner)

Pull request description:

  If the `releases` directory exists, but still only a subset of the necessary previous release binaries are available, the test fails by throwing an exception (sometimes leading to follow-up exceptions like `AssertionError: [node 0] Error: no RPC connection`) and printing out a stack trace, which can be confusing and at a first glance suggests that the node crashed or some alike.
  Improve this by checking and printing out *all* of the missing release binaries and failing with an explicit error in this case. Also add an info on how to download previous releases binaries. Noticed while testing #30328.

  Can be tested by e.g.

  ```
  $ rm -rf ./releases
  $ ./test/get_previous_releases.py -b
  $ rm -rf ./releases/v28.0/
  $ ./build/test/functional/wallet_migration.py
  ```

  master:
  <details>
  <summary>Long test fail output</summary>

  ```
  ...
  2024-12-10T18:48:54.067000Z TestFramework (ERROR): Assertion failed
  Traceback (most recent call last):
    File "/home/thestack/bitcoin/test/functional/test_framework/test_framework.py", line 590, in start_nodes
      node.start(extra_args[i], *args, **kwargs)
    File "/home/thestack/bitcoin/test/functional/test_framework/test_node.py", line 257, in start
      self.process = subprocess.Popen(self.args + extra_args, env=subp_env, stdout=stdout, stderr=stderr, cwd=cwd, **kwargs)
    File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
      self._execute_child(args, executable, preexec_fn, close_fds,
    File "/usr/lib/python3.10/subprocess.py", line 1863, in _execute_child
      raise child_exception_type(errno_num, err_msg, err_filename)
  FileNotFoundError: [Errno 2] No such file or directory: '/home/thestack/bitcoin/releases/v28.0/bin/bitcoind'

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "/home/thestack/bitcoin/test/functional/test_framework/test_framework.py", line 131, in main
      self.setup()
    File "/home/thestack/bitcoin/test/functional/test_framework/test_framework.py", line 315, in setup
      self.setup_network()
    File "/home/thestack/bitcoin/test/functional/test_framework/test_framework.py", line 409, in setup_network
      self.setup_nodes()
    File "/home/thestack/bitcoin/./build/test/functional/wallet_migration.py", line 54, in setup_nodes
      self.start_nodes()
    File "/home/thestack/bitcoin/test/functional/test_framework/test_framework.py", line 595, in start_nodes
      self.stop_nodes()
    File "/home/thestack/bitcoin/test/functional/test_framework/test_framework.py", line 610, in stop_nodes
      node.stop_node(wait=wait, wait_until_stopped=False)
    File "/home/thestack/bitcoin/test/functional/test_framework/test_node.py", line 396, in stop_node
      self.stop(wait=wait)
    File "/home/thestack/bitcoin/test/functional/test_framework/test_node.py", line 215, in __getattr__
      assert self.rpc_connected and self.rpc is not None, self._node_msg("Error: no RPC connection")
  AssertionError: [node 0] Error: no RPC connection
  2024-12-10T18:48:54.118000Z TestFramework (INFO): Stopping nodes
  Traceback (most recent call last):
    File "/home/thestack/bitcoin/./build/test/functional/wallet_migration.py", line 1097, in <module>
      WalletMigrationTest(__file__).main()
    File "/home/thestack/bitcoin/test/functional/test_framework/test_framework.py", line 159, in main
      exit_code = self.shutdown()
    File "/home/thestack/bitcoin/test/functional/test_framework/test_framework.py", line 331, in shutdown
      self.stop_nodes()
    File "/home/thestack/bitcoin/test/functional/test_framework/test_framework.py", line 610, in stop_nodes
      node.stop_node(wait=wait, wait_until_stopped=False)
    File "/home/thestack/bitcoin/test/functional/test_framework/test_node.py", line 396, in stop_node
      self.stop(wait=wait)
    File "/home/thestack/bitcoin/test/functional/test_framework/test_node.py", line 215, in __getattr__
      assert self.rpc_connected and self.rpc is not None, self._node_msg("Error: no RPC connection")
  AssertionError: [node 0] Error: no RPC connection
  [node 0] Cleaning up leftover process
  ...
  ```
  </details>

  PR:
  ```
  ...
  2025-01-01T20:26:27.999000Z TestFramework (INFO): PRNG seed is: 4570383538468804512
  2025-01-01T20:26:28.000000Z TestFramework (INFO): Initializing test directory /tmp/bitcoin_func_test_lz66_zcu
  2025-01-01T20:26:28.003000Z TestFramework (ERROR): Binary not found: /home/thestack/bitcoin/releases/v28.0/bin/bitcoind
  2025-01-01T20:26:28.003000Z TestFramework (ERROR): Binary not found: /home/thestack/bitcoin/releases/v28.0/bin/bitcoin-cli
  2025-01-01T20:26:28.003000Z TestFramework (INFO): Previous releases binaries can be downloaded via `test/get_previous_releases.py -b`.
  2025-01-01T20:26:28.003000Z TestFramework (ERROR): Assertion failed
  Traceback (most recent call last):
    File "/home/thestack/bitcoin/test/functional/test_framework/test_framework.py", line 131, in main
      self.setup()
    File "/home/thestack/bitcoin/test/functional/test_framework/test_framework.py", line 315, in setup
      self.setup_network()
    File "/home/thestack/bitcoin/test/functional/test_framework/test_framework.py", line 409, in setup_network
      self.setup_nodes()
    File "/home/thestack/bitcoin/./build/test/functional/wallet_migration.py", line 50, in setup_nodes
      self.add_nodes(self.num_nodes, versions=[
    File "/home/thestack/bitcoin/test/functional/test_framework/test_framework.py", line 537, in add_nodes
      raise AssertionError("At least one release binary is missing")
  AssertionError: At least one release binary is missing
  2025-01-01T20:26:28.061000Z TestFramework (INFO): Stopping nodes
  ...
  ```

ACKs for top commit:
  fjahr:
    re-ACK 1ea7e45a1f
  kevkevinpal:
    ACK [1ea7e45](1ea7e45a1f)
  maflcko:
    lgtm ACK 1ea7e45a1f
  achow101:
    ACK 1ea7e45a1f
  pablomartin4btc:
    tACK 1ea7e45a1f

Tree-SHA512: b621c3ce044ca8fc8715a4f4b1f96a8592a470c319a64444cced9ba692d315cfd4885a066679bf377b19136fa3530d9cff6f18894a45aa9c716d39b12719baa0
2025-01-09 18:22:26 -05:00
Hennadii Stepanov
727c542769
depends: Use base system's sha256sum utility
On FreeBSD, the `shasum` utility is provided by the `perl5` port, which
is not part of the base system and must be installed separately.
Note that this requirement is currently not documented in
`depends/README.md`.

This change switches to using the `sha256sum` utility, which is included
in the base system.
2025-01-09 20:24:05 +00:00
Pieter Wuille
f5883286e3 Add a fuzz test for Num3072 multiplication and inversion 2025-01-09 10:11:46 -05:00
Pieter Wuille
a26ce62894 Safegcd based modular inverse for Num3072 2025-01-09 10:04:36 -05:00
Pieter Wuille
91ce8cef2d Add benchmark for MuHash finalization 2025-01-09 09:49:02 -05:00
Lőrinc
223081ece6 scripted-diff: rename block and undo functions for consistency
Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
Co-authored-by: Hodlinator <172445034+hodlinator@users.noreply.github.com>

-BEGIN VERIFY SCRIPT-
grep -r -wE 'WriteBlock|ReadRawBlock|ReadBlock|WriteBlockUndo|ReadBlockUndo' $(git ls-files src/ ':!src/leveldb') && \
    echo "Error: One or more target names already exist!" && exit 1
sed -i \
    -e 's/\bSaveBlockToDisk/WriteBlock/g' \
    -e 's/\bReadRawBlockFromDisk/ReadRawBlock/g' \
    -e 's/\bReadBlockFromDisk/ReadBlock/g' \
    -e 's/\bWriteUndoDataForBlock/WriteBlockUndo/g' \
    -e 's/\bUndoReadFromDisk/ReadBlockUndo/g' \
    $(git ls-files src/ ':!src/leveldb')
-END VERIFY SCRIPT-
2025-01-09 15:17:02 +01:00
Lőrinc
baaa3b2846 refactor,blocks: remove costly asserts and modernize affected logs
When the behavior was changes in a previous commit (caching `GetSerializeSize` and avoiding `AutoFile.tell`), (static)asserts were added to make sure the behavior was kept - to make sure reviewers and CI validates it.
We can safely remove them now.

Logs were also slightly modernized since they were trivial to do.

Co-authored-by: Anthony Towns <aj@erisian.com.au>
Co-authored-by: Hodlinator <172445034+hodlinator@users.noreply.github.com>
2025-01-09 15:16:49 +01:00
Lőrinc
fa39f27a0f refactor,blocks: deduplicate block's serialized size calculations
For consistency `UNDO_DATA_DISK_OVERHEAD` was also extracted to avoid the constant's ambiguity.
Asserts were added to help with the review - they are removed in the next commit.

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2025-01-09 15:16:28 +01:00
Hennadii Stepanov
8a46286da6
depends: Fix spacing issue
This change resolves an issue where a missing space caused the value of
the `build_AR` variable to be concatenated with the "NM=" string. This
resulted in subsequent calls to `${AR}` and `${NM}` failing.
2025-01-09 13:36:19 +00:00
Lőrinc
e04be3731f init,log: Unify block index and chainstate loading log line
Example logs before the change:
```
2025-01-07T11:58:33Z Verification progress: 99%
2025-01-07T11:58:33Z Verification: No coin database inconsistencies in last 6 blocks (18905 transactions)
2025-01-07T11:58:33Z  block index           31892ms
2025-01-07T11:58:33Z Setting NODE_NETWORK on non-prune mode
2025-01-07T11:58:33Z block tree size = 878086
2025-01-07T11:58:33Z nBestHeight = 878085
```

Removed redundant duration as well since it can be recovered from the timestamps.

Co-authored-by: TheCharlatan <seb.kung@gmail.com>
Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
2025-01-09 14:14:43 +01:00
Lőrinc
dfb2f9d004 refactor,blocks: inline WriteBlockToDisk
Similarly, `WriteBlockToDisk` wasn't really extracting a meaningful subset of the `SaveBlockToDisk` functionality, it's tied closely to the only caller (needs the header size twice, recalculated block serializes size, returns multiple branches, mutates parameter).

The inlined code should only differ in these parts (modernization will be done in other commits):
* renamed `blockPos` to `pos` in `SaveBlockToDisk` to match the parameter name;
* changed `return false` to `return FlatFilePos()`.

Also removed remaining references to `SaveBlockToDisk`.

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2025-01-09 13:24:53 +01:00
Lőrinc
42bc491465 refactor,blocks: inline UndoWriteToDisk
`UndoWriteToDisk` wasn't really extracting a meaningful subset of the `WriteUndoDataForBlock` functionality, it's tied closely to the only caller (needs the header size twice, recalculated undo serializes size, returns multiple branches, modifies parameter, needs documentation).

The inlined code should only differ in these parts (modernization will be done in other commits):
* renamed `_pos` to `pos` in `WriteUndoDataForBlock` to match the parameter name;
* inlined `hashBlock` parameter usage into `hasher << block.pprev->GetBlockHash()`;
* changed `return false` to `return FatalError`;
* capitalize comment.

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2025-01-09 13:18:22 +01:00
Lőrinc
86b85bb11f bench: add SaveBlockBench 2025-01-09 12:54:58 +01:00
Lőrinc
34f9a0157a refactor,bench: rename bench/readblock.cpp to bench/readwriteblock.cpp
Done in separate commit to simplify review.
Also renames benchmarks, since they're not strictly tests.

Co-authored-by: Hodlinator <172445034+hodlinator@users.noreply.github.com>
2025-01-09 12:48:46 +01:00
TheCharlatan
8bd5f8a38c
[refactor] init: Simplify coinsdb cache calculation
(total_cache / 4) + (1 << 23) is at least 8 MiB and nMaxCoinsDBCache is
also 8 MiB, so the minimum between the two will always be
nMaxCoinsDBCache. This is just a simplification and not changing the
result of the calculation.

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2025-01-09 10:21:49 +01:00
0xb10c
f93f0c9396 tracing: Rename the MIN macro to _TRACEPOINT_TEST_MIN in log_raw_p2p_msgs
Inspired by: 00c1dbd26d (#31419)
2025-01-09 06:43:05 +00:00
glozow
66aa6a47bd
Merge bitcoin/bitcoin#30391: BlockAssembler: return selected packages virtual size and fee
7c123c08dd  miner: add package feerate vector to CBlockTemplate (ismaelsadeeq)

Pull request description:

  This PR enables `BlockAssembler` to add all selected packages' fee and virtual size to a vector, and then return the vector as a member of `CBlockTemplate` struct.

  This PR is the first step in the https://github.com/bitcoin/bitcoin/issues/30392 project.

  The packages' vsize and fee are used in #30157 to select a percentile fee rate of the top block in the mempool.

ACKs for top commit:
  rkrux:
    tACK 7c123c08dd
  ryanofsky:
    Code review ACK 7c123c08dd. Changes since last review are rebasing due to a test conflict, giving the new field a better name and description, resolving the test conflict, and renaming a lot of test variables. The actual code change is still one-line change.
  glozow:
    reACK 7c123c08dd

Tree-SHA512: 767b0b3d4273cf1589fd2068d729a66c7414c0f9574b15989fbe293f8c85cd6c641dd783cde55bfabab32cd047d7d8a071d6897b06ed4295c0d071e588de0861
2025-01-08 13:01:23 -05:00
MarcoFalke
fa3c787b62
fuzz: Abort when global PRNG is used before SeedRand::ZEROS 2025-01-08 15:58:42 +01:00
ismaelsadeeq
92787dd52c
test: raise an error when target_vsize is below tx virtual size 2025-01-08 09:35:02 -05:00
ismaelsadeeq
a8780c937f
test: raise an error if output value is <= 0 in create_self_transfer 2025-01-08 09:35:02 -05:00
ismaelsadeeq
f6e88931f0
test: test that create_self_transfer_multi respects target_vsize 2025-01-08 09:34:51 -05:00
MarcoFalke
fae3bf6b87
test: Avoid redundant stop and error spam on startup failure
Trying to immediately shut down a node after a startup failure without
waiting for the RPC to be fully up will in most cases just fail and lead
to an RPC error.

Also, it is confusing to sidestep the existing fallback to kill any
leftover nodes on a test failure.

So just rely on the fallback.
2025-01-08 11:09:49 +01:00
MarcoFalke
fa0dc09b90
test: Remove --noshutdown flag 2025-01-08 11:02:10 +01:00
MarcoFalke
fad441fba0
test: Treat leftover process as error
Printing to stderr instead of stdout makes the test_runner.py fail on
leftover processes. This is desired and fine, because a leftover process
should only happen on a test failure anyway.
2025-01-08 10:55:15 +01:00
ismaelsadeeq
7c123c08dd
miner: add package feerate vector to CBlockTemplate
- The package feerates are ordered by the sequence in which
  packages are selected for inclusion in the block template.

- The commit also tests this new behaviour.

Co-authored-by: willcl-ark <will@256k1.dev>
2025-01-07 15:29:17 -05:00
Hennadii Stepanov
fd2d96d908
build, test: Build db_tests.cpp regardless of USE_BDB
While some tests are specific to BDB, `db_tests` as a whole are not
limited to BDB.
2025-01-07 15:50:39 +00:00
Vasil Dimov
fb37acd932
ci: build msan's libc++ with _LIBCPP_ABI_BOUNDED_*
For the task `MSan, depends (Cirrus CI)` we build a custom libc++ for
which we already use `-DLIBCXX_HARDENING_MODE=debug`. Compile it also
with `_LIBCPP_ABI_BOUNDED_*` to enable further checks.

Docs at: https://libcxx.llvm.org/Hardening.html#abi-options
2025-01-07 15:57:01 +01:00
Sebastian Falbesoner
1ea7e45a1f test: raise explicit error if any of the needed release binaries is missing
If the `releases` directory exists, but still only a subset of the
necessary previous release binaries are available, the test fails by
throwing an exception (sometimes leading to follow-up exceptions like
"AssertionError: [node 0] Error: no RPC connection") and printing out
a stack trace, which can be confusing and at a first glance suggests
that the node crashed or some alike.
Improve this by checking and printing out *all* of the missing release
binaries and failing with an explicit error in this case. Also add an
info on how to download previous releases binaries.
Noticed while testing #30328.

Can be tested by e.g.

$ ./test/get_previous_releases.py -b
$ rm -rf ./releases/v28.0/
$ ./build/test/functional/wallet_migration.py
2025-01-07 01:25:15 +01:00
David Gumberg
c0045e6cee Add test for multipath miniscript expression 2025-01-06 19:10:54 -05:00
Ava Chow
b4ac48090f descriptor: Use InferXOnlyPubkey for miniscript XOnly pubkey from script 2025-01-06 19:10:54 -05:00
Ava Chow
433412fd84
Merge bitcoin/bitcoin#31596: doc: Clarify comments about endianness after #30526
3e0a992a3f doc: Clarify comments about endianness after #30526 (Ryan Ofsky)

Pull request description:

  This is a documentation-only change following up on suggestions made in the #30526 review.

  Motivation for this change is that I was recently reviewing #31583, which reminded me how confusing the arithmetic blob code was and made me want to write better comments.

ACKs for top commit:
  achow101:
    ACK 3e0a992a3f
  TheCharlatan:
    ACK 3e0a992a3f
  Sjors:
    ACK 3e0a992a3f
  BrandonOdiwuor:
    LGTM ACK 3e0a992a3f

Tree-SHA512: 90d5582a25a51fc406d83ca6b8c4e5e4d3aee828a0497f4b226b2024ff89e29b9b50d0ae8ddeac6abf2757fe78548d58cf3dd54df4b6d623f634a2106048091d
2025-01-06 18:52:59 -05:00
Ava Chow
c506f2cee7
Merge bitcoin/bitcoin#31581: test: have miner_tests use Mining interface
04249682e3 test: use Mining interface in miner_tests (Sjors Provoost)

Pull request description:

  Needed for both #31283 and #31564.

  By using the Mining interface in `miner_tests.cpp` we increase its coverage in unit tests.

ACKs for top commit:
  achow101:
    ACK 04249682e3
  ryanofsky:
    Code review ACK 04249682e3, just minor suggested changes (renames, comments, BOOST_REQUIREs) since last review and some more extra clarifications and checks added to the CreateNewBlock_validity test. The CreateNewBlock_validity changes seem clear and easy to understand now.
  vasild:
    ACK 04249682e3
  tdb3:
    ACK 04249682e3

Tree-SHA512: 2761cb7555d759670e40d8f37b96a079f8e12a588ac43313b9e63c69afd478321515873a8896ea56784f0100dac4476b0c0e0ef8b5418f8aea24d9965cace4d4
2025-01-06 18:28:33 -05:00
Ava Chow
4c50c21f6b tests: Check ExpandPrivate matches for both parsed descriptors 2025-01-06 14:52:03 -05:00
Ava Chow
092569e858 descriptor: Try the other parity in ConstPubkeyProvider::GetPrivKey()
GetPrivKey() needs the same handling of all keyids for xonly keys that
ToPrivateString() does. Refactor that into GetPrivKey() and reuse it in
ToPrivateString() to resolve this.
2025-01-06 14:52:01 -05:00
marcofleon
a96b84cb1b fuzz: Abort when calling system time without setting mock time 2025-01-06 15:43:13 +00:00
marcofleon
ff21870e20 fuzz: Add SetMockTime() to necessary targets 2025-01-06 15:43:04 +00:00
i-am-yuvi
1b51616f2e test: improve rogue calls in mining functions 2025-01-06 21:05:14 +05:30
merge-script
41a2ce9b7d
Merge bitcoin/bitcoin#31464: util: Add missing types in make_secure_unique
fa397177ac util: Add missing types in make_secure_unique (MarcoFalke)

Pull request description:

  The return type of `std::forward` depends on the template type, and can not be recovered from the args. Attempting to do so will result in a compile failure. For example, `make_secure_unique<std::string>(std::string{});` does not compile on current master, but does with this pull.

  Another example would be `make_secure_unique<std::pair<std::string, std::unique_ptr<int>>>(std::string{}, std::make_unique<int>(21));`

ACKs for top commit:
  hodlinator:
    ACK fa397177ac
  hebasto:
    ACK fa397177ac.
  TheCharlatan:
    ACK fa397177ac

Tree-SHA512: cc902c1111c929a79a6f806b5097136a465e8c727474176bad30a5777ebbb30bedb0bd35273b43bf839d2c00492500ddec724bd17349250451f6b329cb71e6f2
2025-01-06 15:19:24 +00:00
glozow
86d7135e36 [p2p] only attempt 1p1c when both txns provided by the same peer
Now that we track all announcers of an orphan, it's not helpful to
consider an orphan provided by a peer that didn't send us this parent.
It can only hurt our chances of finding the right orphan when there are
multiple candidates.

Adapt the 2 tests in p2p_opportunistic_1p1c.py that looked at 1p1c
packages from different peers. Instead of checking that the right peer
is punished, we now check that the package is not submitted. We can't
use the functional test to see that the package was not considered
because the behavior is indistinguishable (except for the logs).
2025-01-06 09:02:05 -05:00
glozow
f7658d9b14 [cleanup] remove p2p_inv from AddTxAnnouncement
This param is no longer needed since orphan parent requests are added to
the TxRequestTracker directly.
2025-01-06 09:02:05 -05:00
glozow
063c1324c1 [functional test] getorphantxs reflects multiple announcers 2025-01-06 09:02:05 -05:00
glozow
0da693f7e1 [functional test] orphan handling with multiple announcers 2025-01-06 09:02:05 -05:00
glozow
b6ea4a9afe [p2p] try multiple peers for orphan resolution
Co-authored-by: dergoegge <n.goeggi@gmail.com>
2025-01-06 09:02:05 -05:00
glozow
1d2e1d709c [refactor] move creation of unique_parents to helper function
This function will be reused in a later commit.
2025-01-06 09:02:05 -05:00
glozow
c6893b0f0b [txdownload] remove unique_parents that we already have
This means we no longer return parents we already have in the
m_unique_parents result from MempoolRejectedTx.

We need to separate the loop that checks AlreadyHave parents from the
loop that adds parents as announcements, because we may do the latter
loop multiple times for different peers.
2025-01-06 09:02:05 -05:00
glozow
163aaf285a [fuzz] orphanage multiple announcer functions 2025-01-06 09:02:05 -05:00
glozow
22b023b09d [unit test] multiple orphan announcers 2025-01-06 09:02:05 -05:00
glozow
96c1a822a2 [unit test] TxOrphanage EraseForBlock 2025-01-06 09:02:05 -05:00
glozow
04448ce32a [txorphanage] add GetTx so that orphan vin can be read 2025-01-06 09:02:05 -05:00
glozow
e810842acd [txorphanage] support multiple announcers
Add ability to add and track multiple announcers per orphan transaction,
erasing announcers but not the entire orphan.

The tx creation code in orphanage_tests needs to be updated so that each
tx is unique, because the CountOrphans() check assumes that calling
EraseForPeer necessarily means its orphans are deleted.

Unused for now.
2025-01-06 09:02:05 -05:00
glozow
62a9ff1870 [refactor] change type of unique_parents to Txid 2025-01-06 09:02:05 -05:00
glozow
6951ddcefd [txrequest] GetCandidatePeers
Needed for a later commit adding logic to ask the TxRequestTracker for a
list of announcers.  These announcers should know the parents of the
transaction they announced.
2025-01-06 09:02:05 -05:00
merge-script
6475849c40
Merge bitcoin/bitcoin#31435: lint: Move assertion linter into lint runner
e8f0e6efaf lint: output-only - Avoid repeated arrows, trim (Hodlinator)
fa9aacf614 lint: Move assertion linter into lint runner (MarcoFalke)

Pull request description:

  On failure, this makes the output more consistent with the other linters. Each failure will be marked with an '⚠️ ' emoji and explanation, making it easier to spot.

  Also, add --line-number to the filesystem linter.

  Also, add newlines after each failing check, to visually separate different failures from each other.

  Can be reviewed with:
  `--color-moved=dimmed-zebra --color-moved-ws=ignore-all-space`

ACKs for top commit:
  davidgumberg:
    crACK e8f0e6efaf
  hodlinator:
    re-ACK e8f0e6efaf
  TheCharlatan:
    ACK e8f0e6efaf

Tree-SHA512: 9896ff882af9d673ec3e6d2718f877b2fdc8514faba50942fcebacb9de95b1f5b4a5db595e1338fa7f505d06df2df304897350cc55c558c7a85232800e5fd804
2025-01-06 13:35:40 +00:00
Kay
b537a2c02a doc: upgrade license to 2025. 2025-01-06 12:23:11 +00:00
merge-script
49fc2258cf
Merge bitcoin/bitcoin#31526: doc: Install net/py-pyzmq port on FreeBSD for interface_zmq.py
0a76c292ac doc: Install `net/py-pyzmq` port on FreeBSD for `interface_zmq.py` (Hennadii Stepanov)

Pull request description:

  On FreeBSD, Python's `zmq` module is provided as a separate port.

  This PR updates the FreeBSD Build Guide to include this port, enabling the `interface_zmq.py` functional test.

ACKs for top commit:
  maflcko:
    lgtm ACK 0a76c292ac
  vasild:
    ACK 0a76c292ac

Tree-SHA512: c13eada3e870149f47348145d6a29f41125ac75efd88eabe6dd2d0429e0377ed280e76a764cfaf627498c1d07b9135a995cc644146fa666bc3bfa0eb2c86e88b
2025-01-06 11:36:11 +00:00
merge-script
ac918c7cc0
Merge bitcoin/bitcoin#31552: depends: Update capnproto to 1.1.0
b0b8d96d93 depends: Update capnproto to 1.1.0 (Hennadii Stepanov)

Pull request description:

  This change fixes compilation on NetBSD with GCC 14:

  ```
  $ gmake -C depends capnp MULTIPROCESS=1 CC=/usr/pkg/gcc14/bin/gcc CXX=/usr/pkg/gcc14/bin/g++
  gmake: Entering directory '/home/hebasto/dev/bitcoin/depends'
  <snip>
  In file included from /home/hebasto/dev/bitcoin/depends/work/build/x86_64-unknown-netbsd10.0/capnp/1.0.2-ffdefffd9f5/src/kj/memory.h:24,
                   from /home/hebasto/dev/bitcoin/depends/work/build/x86_64-unknown-netbsd10.0/capnp/1.0.2-ffdefffd9f5/src/kj/exception.h:24,
                   from /home/hebasto/dev/bitcoin/depends/work/build/x86_64-unknown-netbsd10.0/capnp/1.0.2-ffdefffd9f5/src/kj/async-prelude.h:27,
                   from /home/hebasto/dev/bitcoin/depends/work/build/x86_64-unknown-netbsd10.0/capnp/1.0.2-ffdefffd9f5/src/kj/async.h:24,
                   from /home/hebasto/dev/bitcoin/depends/work/build/x86_64-unknown-netbsd10.0/capnp/1.0.2-ffdefffd9f5/src/kj/async-io.h:24,
                   from /home/hebasto/dev/bitcoin/depends/work/build/x86_64-unknown-netbsd10.0/capnp/1.0.2-ffdefffd9f5/src/kj/async-io-unix.c++:35:
  /home/hebasto/dev/bitcoin/depends/work/build/x86_64-unknown-netbsd10.0/capnp/1.0.2-ffdefffd9f5/src/kj/async-io-unix.c++: In lambda function:
  /home/hebasto/dev/bitcoin/depends/work/build/x86_64-unknown-netbsd10.0/capnp/1.0.2-ffdefffd9f5/src/kj/async-io-unix.c++:1243:24: error: 'AI_V4MAPPED' was not declared in this scope
   1243 |       hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG;
        |                        ^~~~~~~~~~~
  gmake[3]: *** [src/kj/CMakeFiles/kj-async.dir/build.make:146: src/kj/CMakeFiles/kj-async.dir/async-io-unix.c++.o] Error 1
  gmake[2]: *** [CMakeFiles/Makefile2:203: src/kj/CMakeFiles/kj-async.dir/all] Error 2
  gmake[1]: *** [Makefile:136: all] Error 2
  gmake[1]: Leaving directory '/home/hebasto/dev/bitcoin/depends/work/build/x86_64-unknown-netbsd10.0/capnp/1.0.2-ffdefffd9f5'
  gmake: *** [funcs.mk:302: /home/hebasto/dev/bitcoin/depends/work/build/x86_64-unknown-netbsd10.0/capnp/1.0.2-ffdefffd9f5/./.stamp_built] Error 2
  gmake: Leaving directory '/home/hebasto/dev/bitcoin/depends'
  ```

  See: ccaa1f87c1.

  However, the other changes between [`v1.0.2`](https://github.com/capnproto/capnproto/releases/tag/v1.0.2) and [`v1.1.0`](https://github.com/capnproto/capnproto/releases/tag/v1.1.0) require a sanity check.

ACKs for top commit:
  hodlinator:
    cr-ACK b0b8d96d93

Tree-SHA512: bb3ee29a609fd452f07fe8a67859d5bc4f0570e6b0f8245a5fe7576caa328220f94565b410757f727d0076a13916ce6b1c0243627b5c509ec4e0d90f1e28d673
2025-01-06 11:31:26 +00:00
MarcoFalke
fa029a7878
doc: Clarify min macOS and Xcode version 2025-01-06 12:30:55 +01:00
merge-script
a0f0c48ae2
Merge bitcoin/bitcoin#31584: txmempool: fix typos in comments
34e8ee23b8 txmempool: fix typos in comments (Boris Nagaev)

Pull request description:

  Fixed typos identified by codespell lint in CI.

ACKs for top commit:
  maflcko:
    lgtm ACK 34e8ee23b8
  hebasto:
    ACK 34e8ee23b8.

Tree-SHA512: b36cddb26e33f042c074185aa6ef1b0339ae0ff05643e1c30bac56b8c9620d89c834ea5befb25d2c602a3dd541209f5a7c04da6ef9f10724144c35a6548ea52c
2025-01-06 11:10:56 +00:00
merge-script
558783625c
Merge bitcoin/bitcoin#31586: doc: Update NetBSD Build Guide
2bdaf52ed1 doc: Update NetBSD Build Guide (Hennadii Stepanov)

Pull request description:

  This PR:

  1. Updates the documented NetBSD version.

  2. Adds the optional ZeroMQ package to align the guide with other *BSD systems.

  3. Updates the Python version to meet the minimum requirement specified in https://github.com/bitcoin/bitcoin/pull/30527.

  4. Suggests to Install [`net/py-zmq`](https://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/net/py-zmq/index.html) package to enable the `interface_zmq.py` functional test.

  5. Fix a formatting issue.

  See also the recent NetBSD nightly build at https://github.com/hebasto/bitcoin-core-nightly/actions/runs/12554769828/job/35003929261.

ACKs for top commit:
  tdb3:
    ACK 2bdaf52ed1

Tree-SHA512: 16562e7325dd92e44fa641c8d4e64df69ee76175fc8eba61da06775d4a751307825a6ffe1743fb614a591ba1d33d197ea6b7f9111f5a5b335f6b257bb4868bf6
2025-01-06 10:36:43 +00:00
merge-script
3e936789b1
Merge bitcoin/bitcoin#31592: ci: Run functional tests in msan task
fa0411ee30 ci: Run functional tests in msan task (MarcoFalke)

Pull request description:

  Now that the CI machines have a bit more CPU, it seems good to run the functional tests as well under msan. (Also, bump the llvm minor version)

ACKs for top commit:
  TheCharlatan:
    ACK fa0411ee30

Tree-SHA512: 0dbb2b934485ed54b8caafb5bcd96ddef87088b148dab72a584f721c398bb7fda4095fb720b9ad602dc71f8f40a1e0f29e1b08b2879b78b90b29d46604df36c3
2025-01-06 10:22:52 +00:00
merge-script
5af642bf48
Merge bitcoin/bitcoin#31604: test: fix typo in mempool_ephemeral_dust
29bca9713d test: fix typo in mempool_ephemeral_dust (epysqyli)

Pull request description:

  The `test_node_restart` test in `test/functional/mempool_ephemeral_dust.py` has a repetition in the comment.

ACKs for top commit:
  maflcko:
    lgtm ACK 29bca9713d

Tree-SHA512: 9828d23ca27e24d64031cd103ce9f9bd9e997ef9b63e6122ad6573073fb3c956964a72cd23dfa5773e52e195eee668762ab470bb540e686a4abd3d7561b40c59
2025-01-06 10:22:18 +00:00
MarcoFalke
8888ee4403
ci: Allow build dir on CI host 2025-01-06 09:45:03 +01:00
epysqyli
29bca9713d
test: fix typo in mempool_ephemeral_dust 2025-01-04 22:50:29 +01:00
Ava Chow
4036ee3f2b
Merge bitcoin/bitcoin#31542: test: Embed univalue json tests in binary
faf7eac364 test: clang-format -i src/univalue/test/unitester.cpp (MarcoFalke)
fafa9cc7a5 test: Embed univalue json tests in binary (MarcoFalke)
fa044857ca test: Re-enable univalue test fail18.json (MarcoFalke)
63b6b638aa build: Use character literals for generated headers to avoid narrowing (Lőrinc)

Pull request description:

  All other benchmarks and tests have their data embedded, except for the univalue json tests.

  This is not only confusing, but also problematic, when the test binary is moved to a different system for testing, because one has to put the test files in the source dir that was used at compile-time.

  Fix all issues by embedding them. Also, re-enable a disabled test. Also, fix an issue in the GenerateHeaderFromJson.cmake.

  Requested in https://github.com/bitcoin/bitcoin/pull/31434/files#r1876000910

ACKs for top commit:
  l0rinc:
    ACK faf7eac364
  fjahr:
    tACK faf7eac364
  achow101:
    ACK faf7eac364
  TheCharlatan:
    Re-ACK faf7eac364
  hebasto:
    Re-ACK faf7eac364. The commit, which modifies CMake scripts, has been replaced with the one from https://github.com/bitcoin/bitcoin/pull/31547, and a formatting commit has been added since my recent [review](https://github.com/bitcoin/bitcoin/pull/31542#pullrequestreview-2517189261).

Tree-SHA512: 72ad202125746f32ccf07411ad3efd2771f27a40525c204cba3c9c83b3ca46d05dd18f6fa5985720c6684bdcbb4c4853fc609ced095ddd1a124832318dd8a55d
2025-01-03 13:58:20 -05:00
Sebastian Falbesoner
f6a6d91205 test: add check for getting SigningProvider for a CPubKey
Verify that the DescriptorSPKM method `GetSigningProvider` should
only return a signing provider for the passed public key if its
corresponding private key of the passed public key is available.
2025-01-03 13:12:32 -05:00
Sebastian Falbesoner
62a95f5af9 test: refactor: move CreateDescriptor helper to wallet test util module
Can be reviewed via `--color-moved=dimmed-zebra`.
2025-01-03 13:12:27 -05:00
TheCharlatan
5db7d4d3d2
doc: Correct docstring describing max block tree db cache
It is always applied in the same way, no matter how the txindex is
setup. This was no longer accurate after 8181db8, where their
initialization was made independent.
2025-01-03 18:11:35 +01:00
Ryan Ofsky
6aa0e70ccb
Merge bitcoin/bitcoin#31524: refactor: Allow std::byte in Read(LE/BE)
fa83bec78e refactor: Allow std::byte in Read(LE/BE) (MarcoFalke)

Pull request description:

  Starting with C++17, `std::byte` is often (not always) a better choice over `uint8_t` for new code.

  However, the existing codebase discourages the use of `std::byte`, when helpers such as `ReadLE32` are used. This is because calling code will be cluttered with byte-casts.

  Fix it by allowing `std::byte` pointers in `ReadLE32` (and friends).

ACKs for top commit:
  sipa:
    utACK fa83bec78e
  fjahr:
    Code review ACK fa83bec78e
  theuni:
    utACK fa83bec78e
  l0rinc:
    ACK fa83bec78e

Tree-SHA512: 83604dc9df9ad447ad1b6f81f1e1844554c2c5331fcb78bdba1300e050d9dcbe9cf7a1b2dd250772bb23a8bf02a4ec26441012fe2f4bcc670ef31c15151adb15
2025-01-03 09:29:04 -05:00
Ryan Ofsky
3e0a992a3f doc: Clarify comments about endianness after #30526
This is a documentation-only change following up on suggestions made in the
#30526 review.

Motivation for this change is that I was recently reviewing #31583, which
reminded me how confusing the arithmetic blob code was and made me want to
write better comments.
2025-01-03 09:19:53 -05:00
glozow
604bf2ea37
Merge bitcoin/bitcoin#28121: include verbose "reject-details" field in testmempoolaccept response
b6f0593f43 doc: add release note about testmempoolaccept debug-message (Matthew Zipkin)
f9cac63523 test: cover testmempoolaccept debug-message in RBF test (Matthew Zipkin)
f9650e18ea rbf: remove unecessary newline at end of error string (Matthew Zipkin)
221c789e91 rpc: include verbose reject-details field in testmempoolaccept response (Matthew Zipkin)

Pull request description:

  Adds a new field `reject-details` in `testmempoolaccept` responses to include `m_debug_message` from `ValidationState`. This string is the complete error message thrown by the mempool in response to `sendrawtransaction`.

  The extra verbosity is helpful to consumers of `testmempoolaccept`, which is sort of a debug tool anyway.

  example:
  >
  > {
  >   "txid": "07d7a59a7bdad4c3a5070659ea04147c9b755ad9e173c52b6a38e017abf0f5b8",
  >   "wtxid": "5dc243b1b92ee2f5a43134eb3e23449be03d1abb3d7f3c03c836ed0f13c50185",
  >   "allowed": false,
  >   "reject-reason": "insufficient fee",
  >   "reject-details": "insufficient fee, rejecting replacement 07d7a59a7bdad4c3a5070659ea04147c9b755ad9e173c52b6a38e017abf0f5b8; new feerate 0.00300000 BTC/kvB <= old feerate 0.00300000 BTC/kvB"
  > }

ACKs for top commit:
  rkrux:
    re-ACK b6f0593f43
  glozow:
    ACK b6f0593f43

Tree-SHA512: 340b8023d59cefa84598879c4efdb7c399a3f62da126e87c595523f302e53d33098fc69da9c5f8c92b7580dc75466c66cea372051f935b197265648fe15c43a3
2025-01-03 07:03:23 -05:00
Sjors Provoost
04249682e3
test: use Mining interface in miner_tests 2025-01-03 11:48:05 +01:00
MarcoFalke
fa0411ee30
ci: Run functional tests in msan task 2025-01-02 13:46:52 +01:00
Hennadii Stepanov
2bdaf52ed1
doc: Update NetBSD Build Guide
1. Update the documented NetBSD version.

2. Add the optional ZeroMQ package to align the guide with other *BSD
systems.

3. Update the Python version to meet the minimum requirement specified
in https://github.com/bitcoin/bitcoin/pull/30527.

4. Install `net/py-zmq` package to enable the `interface_zmq.py`
functional test.

5. Fix a formatting issue.
2024-12-31 10:14:02 +00:00
Boris Nagaev
34e8ee23b8
txmempool: fix typos in comments 2024-12-31 00:04:20 -03:00
Ava Chow
228aba2c4d
Merge bitcoin/bitcoin#31555: descriptor: remove unreachable verification for pkh
366ae00b77 descriptor: Assume `ParseScript` is not being called with a P2WPKH context (brunoerg)
e366408590 descriptor: remove unreachable verification for `pkh` (brunoerg)

Pull request description:

  This PR removes an unreachable verification in the `ParseScript` function. It returns an error if `pkh` is not being used at top level, sh, wsh or tr. However, any usage of `pkh` without these contexts will not reach this verification but other ones like "invalid keys" (e.g. `wpkh(pkh(L4gM1FBdyHNpkzsFh9ipnofLhpZRp2mwobpeULy1a6dBTvw8Ywtd))`).

ACKs for top commit:
  davidgumberg:
    crACK 366ae00b77
  achow101:
    ACK 366ae00b77
  tdb3:
    cr ACK 366ae00b77
  sipa:
    crACK 366ae00b77

Tree-SHA512: b954221a77eed623aeed5eb54f14e82c49540a151d3388831924caa7a784e48a2a975e418af1e13d491e4f8cded3b1797aa39e0e4e39e302a991105df09cdec0
2024-12-30 16:40:11 -05:00
Ava Chow
9b9752217f
Merge bitcoin/bitcoin#31570: test: descriptor: fix test for MaxSatisfactionWeight
b29d68f942 test: descriptor: fix test for `MaxSatisfactionWeight` (brunoerg)

Pull request description:

  To get the maximum size of a satisfaction for a descriptor with no max sig, the parameter `use_max_sig` should be false.

ACKs for top commit:
  fjahr:
    utACK b29d68f942
  achow101:
    ACK b29d68f942
  tdb3:
    re ACK b29d68f942
  furszy:
    utACK b29d68f942

Tree-SHA512: 8559718d126e60ce21a34183f74d227546108b43e3897e49622d6677ed9e7707caa962fd811d8787bd4dafc48a0e779ef11050d5990293faa2f91ded4aaa4f4b
2024-12-30 15:04:51 -05:00
Ava Chow
87c9ebd889
Merge bitcoin/bitcoin#31563: rpc: Extend scope of validation mutex in generateblock
fa63b8232f test: generateblocks called by multiple threads (MarcoFalke)
fa62c8b1f0 rpc: Extend scope of validation mutex in generateblock (MarcoFalke)

Pull request description:

  The mutex (required by TestBlockValidity) must be held after creating the block, until TestBlockValidity is called. Otherwise, it is possible that the chain advances in the meantime and leads to a crash in TestBlockValidity: `Assertion failed: pindexPrev && pindexPrev == chainstate.m_chain.Tip() (validation.cpp: TestBlockValidity: 4338)`

  Fixes #31562

ACKs for top commit:
  davidgumberg:
    reACK fa63b8232f
  achow101:
    ACK fa63b8232f
  ismaelsadeeq:
    re-ACK fa63b8232f
  mzumsande:
    utACK fa63b8232f

Tree-SHA512: 3dfda1192af52546ab11fbffe44af8713073763863f4a63fbcdbdf95b1c6cbeb003dc4b8b29e7ec67362238ad15e07d8f6855832a0c68dc5370254f8cbf9445c
2024-12-30 14:49:21 -05:00
Ava Chow
df5c643f92
Merge bitcoin/bitcoin#31556: validation: Send correct notification during snapshot completion
bc43ecaf6d test: add functional test for balance after snapshot completion (Martin Zumsande)
226d03dd61 validation: Send correct notification during snapshot completion (Martin Zumsande)

Pull request description:

  After AssumeUtxo background sync is completed in a `ActivateBestChain()` call, the `GetRole()` function called with `BlockConnected()` returns `ChainstateRole::NORMAL` instead of `ChainstateRole::BACKGROUND` for this chainstate.
  This would make the wallet (which ignores `BlockConnected` notifications for the background chainstate) process it, change `m_last_block_processed_height` to the (ancient) snapshot height, and display an incorrect balance.

  Fix this by caching the chainstate role before calling `ActivateBestChainStep()`.
  Also contains a test for this situation that fails on master.

  Fixes #31546

ACKs for top commit:
  fjahr:
    re-ACK bc43ecaf6d
  achow101:
    ACK bc43ecaf6d
  furszy:
    Code review ACK bc43ecaf6d
  TheCharlatan:
    lgtm ACK bc43ecaf6d

Tree-SHA512: c5db677cf3fbab3a33ec127ec6c27c8812299e8368fd3c986bc34d0e515c4eb256f6104479f27829eefc098197de3af75d64ddca636b6b612900a0e21243e4f2
2024-12-30 14:40:27 -05:00
Ava Chow
fa3de038f7
Merge bitcoin/bitcoin#31537: qa: Limit -maxconnections in tests
d9d5bc2e74 qa: Limit `-maxconnections` in tests (Hennadii Stepanov)

Pull request description:

  On systems such as NetBSD, the `bitcoind` typically prints the following warning:
  ```
  Warning: Reducing -maxconnections from 125 to 96, because of system limitations.
  ```

  This breaks the functional test framework (see https://github.com/bitcoin/bitcoin/issues/23968).

  This PR limits the `-maxconnections` to mitigate the issue and enable functional tests on NetBSD.

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

  Here is CI log from the [`bitcoin-core-nightly`](https://github.com/hebasto/bitcoin-core-nightly) repository: https://github.com/hebasto/bitcoin-core-nightly/actions/runs/12415868523/job/34663207030

ACKs for top commit:
  maflcko:
    re-ACK d9d5bc2e74
  achow101:
    ACK d9d5bc2e74
  mzumsande:
    Code Review ACK d9d5bc2e74
  tdb3:
    tested ACK d9d5bc2e74

Tree-SHA512: ad02adce98ce609176c9688289a0ca347932da5b6f259c6ab4e686914352f3d61f819adc150be80220f969200ee6a0c1c8737426525816fa0df58d688c51410c
2024-12-30 14:34:22 -05:00
Ava Chow
ba0cb7d5a5
Merge bitcoin/bitcoin#31468: test: Avoid intermittent error in assert_equal(pruneheight_new, 248)
fa0998f0a0 test: Avoid intermittent error in assert_equal(pruneheight_new, 248) (MarcoFalke)

Pull request description:

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

  The test uses the P2P network to sync blocks, which has no inherent guarantee that the blocks are sent and received in the right order, assuming the headers are received first.

  This can mean that the first block file is flushed with block at height 249 and block at height 248 is added to the second file. In the log it looks like: `Leaving block file 0: CBlockFileInfo(blocks=249, size=65319, heights=0...249, time=2011-02-02...2024-12-03) (onto 1) (height 248)`. The test assumes that the height of the last pruned block in the first file is 248, expecting it to look like: `Leaving block file 0: CBlockFileInfo(blocks=249, size=65319, heights=0...248, time=2011-02-02...2024-12-09) (onto 1) (height 249) `.

  Fix the issue by using a linear dumb sync.

ACKs for top commit:
  achow101:
    ACK fa0998f0a0
  mzumsande:
    Code Review ACK fa0998f0a0
  i-am-yuvi:
    Code Review ACK fa0998f0a0
  fjahr:
    Code review ACK fa0998f0a0

Tree-SHA512: 59cb4317be6cf9012c9bf7a3e9f5ba96b8b114b30bd2ac42af4fe742cd26a634d685b075f04a84bd782b2a43a342d75bb20a042bd82ad2831dbf844d39517ca2
2024-12-30 14:28:01 -05:00
Ava Chow
69e35f5c60
Merge bitcoin/bitcoin#31403: test: Call generate RPCs through test framework only
fa6e599cf9 test: Call generate through test framework only (MarcoFalke)

Pull request description:

  The generate RPCs are special in that they should only be called by the test framework itself. This way, they will call the sync function on the nodes, which can avoid intermittent test issues. Also, when the sync is disabled, it will happen explicitly by setting the `sync_fun`.

  Apply this rule here, so that all generate calls are written consistently.

ACKs for top commit:
  achow101:
    ACK fa6e599cf9
  rkrux:
    tACK fa6e599cf9
  hodlinator:
    ACK fa6e599cf9
  i-am-yuvi:
    Tested ACK fa6e599cf9

Tree-SHA512: 31079997f1e17031ecd577904457e0560388aa53cadb1bbda281865271e8e4cf244bc6bf315838a717bf9d6620c201093e30039aa0007bec3629f7ca56abfba3
2024-12-30 14:19:07 -05:00
Ava Chow
17db84dbb8
Merge bitcoin/bitcoin#31251: test: report detailed msg during utf8 response decoding error
a2c45ae548 test: report failure during utf8 response decoding (furszy)

Pull request description:

  Useful for debugging issues such https://github.com/bitcoin/bitcoin/pull/31241#issuecomment-2462816933.

  Prints the entire response content instead of printing only the position of the byte it can't be decoded.

  The diff between the error messages can be seen by running the `wallet_migration.py` functional test with the following patch applied:
  ```
  diff --git a/src/wallet/rpc/wallet.cpp b/src/wallet/rpc/wallet.cpp
  --- a/src/wallet/rpc/wallet.cpp(revision d65918c5da52c7d5035b4151dee9ffb2e94d4761)
  +++ b/src/wallet/rpc/wallet.cpp(date 1731005254673)
  @@ -801,7 +801,7 @@
               }

               UniValue r{UniValue::VOBJ};
  -            r.pushKV("wallet_name", res->wallet_name);
  +            r.pushKV("wallet_name", "\xc3\x28");
               if (res->watchonly_wallet) {
                   r.pushKV("watchonly_name", res->watchonly_wallet->GetName());
               }
  ```

ACKs for top commit:
  achow101:
    ACK a2c45ae548
  theStack:
    re-ACK a2c45ae548
  rkrux:
    tACK a2c45ae548
  ismaelsadeeq:
    utACK a2c45ae548

Tree-SHA512: 6abb524b5a215c51ec881eea91ebe8174140a88ff3874c8c88676157edae7818801356586a904dbb21b45053183315a6d71dbf917d753611d8e413776b57c484
2024-12-30 14:12:57 -05:00
Ava Chow
e6f14241f6
Merge bitcoin/bitcoin#31540: refactor: std::span compat fixes
fa494a1d53 refactor: Specify const in std::span constructor, where needed (MarcoFalke)
faaf4800aa Allow std::span in stream serialization (MarcoFalke)
faa5391f77 refactor: test: Return std::span from StringBytes (MarcoFalke)
fa86223475 refactor: Avoid passing span iterators when data pointers are expected (MarcoFalke)
faae6fa5f6 refactor: Simplify SpanPopBack (MarcoFalke)
facc4f120b refactor: Replace fwd-decl with proper include (MarcoFalke)
fac3a782ea refactor: Avoid needless, unsafe c-style cast (MarcoFalke)

Pull request description:

  The `std::span` type is already used in some parts of the codebase, and in most contexts can implicitly convert to and from `Span`. However, the two types are not identical in behavior and trying to use one over the other can result in compile failures in some contexts.

  Fix all those issues by allowing either `Span` or `std::span` in any part of the codebase.

  All of the changes are also required for the scripted-diff to replace `Span` with `std::span` in https://github.com/bitcoin/bitcoin/pull/31519

ACKs for top commit:
  sipa:
    utACK fa494a1d53
  fjahr:
    Code review ACK fa494a1d53
  achow101:
    ACK fa494a1d53
  theuni:
    utACK fa494a1d53.
  adamandrews1:
    utACK fa494a1d53

Tree-SHA512: 9440941823e884ff5d7ac161f58b9a0704d8e803b4c91c400bdb5f58f898e4637d63ae627cfc7330e98a721fc38285a04641175aa18d991bd35f8b69ed1d74c4
2024-12-30 14:05:55 -05:00
Ava Chow
a137b0bd6b
Merge bitcoin/bitcoin#31215: rpc: increase the defaults for -rpcthreads and -rpcworkqueue
e56fc7ce6a rpc: increase the defaults for -rpcthreads and -rpcworkqueue (Vasil Dimov)

Pull request description:

  `rpcthreads` was introduced with a default of 4 in 2013 in 21eb5adadb

  `rpcworkqueue` was introduced with a default of 16 in 2015 in 40b556d374

  Resolves: https://github.com/bitcoin/bitcoin/issues/29386

  ---

  Just bump the ancient default values. There is no perfect default that would fit everybody. This could lead to https://bikeshed.com/

ACKs for top commit:
  achow101:
    ACK e56fc7ce6a
  andrewtoth:
    ACK e56fc7ce6a
  storopoli:
    ACK e56fc7ce6a
  tdb3:
    ACK e56fc7ce6a

Tree-SHA512: ba3ea7392fda57950daa6b4c4d38ecdef9eebe5e786824d25f8b5cea03e760ffff7f77f3acd8eb6c6178b1e92b282e02cabb940ed7222eec7f73efdb819eef06
2024-12-30 13:45:00 -05:00
Ava Chow
67bfe28995
Merge bitcoin/bitcoin#31531: rpc: Add signet_challenge field to getblockchaininfo and getmininginfo
ecaa786cc1 rpc: add signet_challenge field to getblockchaininfo and getmininginfo (Ash Manning)

Pull request description:

  Signet challenges are currently only available via `getblocktemplate` RPC.
  `getblockchaininfo` and `getmininginfo` both provide inadequate information to distinguish signets. Since these are the RPCs used to determine the current network, they should also provide the signet challenge for signets.

  Test coverage is included in `test/functional/feature_signet.py`.

ACKs for top commit:
  sipa:
    utACK ecaa786cc1
  achow101:
    ACK ecaa786cc1
  i-am-yuvi:
    Concept ACK ecaa786cc1
  Sjors:
    ACK ecaa786cc1
  zaidmstrr:
    Tested ACK [ecaa786](ecaa786cc1)

Tree-SHA512: 9ccf4ae634ee74353a2a895efb881fdc62ae703a134ccd219da2cd6080c7d38319e689054584722457a7cc79004bd6022292a3b0b90eaab9f7003564665e1ea4
2024-12-30 13:31:08 -05:00
Ava Chow
ad174c2817
Merge bitcoin/bitcoin#31497: Remove unused variable assignment
b9766c9977 Remove unused variable assignment (yancy)

Pull request description:

  The variable is conditionally assigned toward the end of the loop and not used after.  It's then set back to its default value at the beginning of the loop.

ACKs for top commit:
  theuni:
    utACK b9766c9977
  achow101:
    ACK b9766c9977
  hodlinator:
    crACK b9766c9977
  danielabrozzoni:
    code review ACK b9766c9977
  murchandamus:
    ACK b9766c9977

Tree-SHA512: 45e62b0dd561a473f5ae21bfa91db494940b752886669c85b63a83b68d2a157a301e9450082635e921f3dc812e6307f4ad1674806b74b3e7e0f9f4db543ad93d
2024-12-30 13:22:31 -05:00
brunoerg
b29d68f942 test: descriptor: fix test for MaxSatisfactionWeight
To get the maximum size of a satisfaction for a descriptor
without considering the max sig, the parameter `use_max_sig`
should be false.
2024-12-27 17:55:58 -03:00
Ryan Ofsky
9355578a77
Merge bitcoin/bitcoin#31534: coins: warn on shutdown for big UTXO set flushes
5709718b83 coins: warn on shutdown for big UTXO set flushes (Lőrinc)

Pull request description:

  Split out of https://github.com/bitcoin/bitcoin/pull/30611#issuecomment-2549027130

  Setting a large `-dbcache` size postpones the index writes until the coins cache size exceeds the specified limit. This causes the final flush after manual termination to seemingly hang forever (e.g. tens of minutes for 20 GiB); Now that the `dbcache` upper cap has been lifted, this will become even more apparent, so a warning will be shown when large UTXO sets are flushed (currently >1 GiB), such as:
  > 2024-12-18T18:25:03Z Flushed fee estimates to fee_estimates.dat.
  > 2024-12-18T18:25:03Z [warning] Flushing large (1 GiB) UTXO set to disk, it may take several minutes
  > 2024-12-18T18:25:09Z Shutdown: done

  ---

  You can reproduce it by starting `bitcoind` with a large `-dbcache`:
  > mkdir demo  && cmake -B build -DCMAKE_BUILD_TYPE=Release && cmake --build build -j$(nproc) && build/src/bitcoind -datadir=demo **-dbcache=10000**

  Waiting until the used memory is over 1 GiB
  > 2024-12-18T18:25:02Z UpdateTip: [...] progress=0.069009 cache=**1181.1MiB**(8827981txo)

  And cancelling the process from the terminal:
  > ^C2024-12-18T18:25:03Z tor: Thread interrupt
  > [...]
  > 2024-12-18T18:25:03Z **[warning] Flushing large (1 GiB) UTXO set to disk, it may take several minutes*

ACKs for top commit:
  sipa:
    utACK 5709718b83
  tdb3:
    re ACK 5709718b83
  1440000bytes:
    ACK 5709718b83
  danielabrozzoni:
    tACK 5709718b83

Tree-SHA512: 608cf797de788501ccb2986508c155f5660c5f6f7a414524bfcc2820cfa9ebe3da558d13f2317d1f121a82d49ffe1e711a1152c743c22dab9f9807363f4ed8d5
2024-12-27 09:54:11 -05:00
Ryan Ofsky
f95fb79372
Merge bitcoin/bitcoin#28521: net, net_processing: additional and consistent disconnect logging
06443b8f28 net: clarify if we ever sent or received from peer (Sjors Provoost)
1d01ad4d73 net: add LogIP() helper, use in net_processing (Sjors Provoost)
937ef9eb40 net_processing: use CNode::DisconnectMsg helper (Sjors Provoost)
ad224429f8 net: additional disconnection logging (Sjors Provoost)

Pull request description:

  While debugging unexpected disconnections, possibly related to #28331, I found some additional [net] logging to be useful.

  All cases where we disconnect now come with a log message that has the word `disconnecting`:

  * all calls to `CloseSocketDisconnect()` log `disconnecting peer=…`
  * wherever we set `pnode->fDisconnect = true;`
  * for all `InactivityCheck` cases (which in turn sets `fDisconnect`)
  * replaces "dropping" with "disconnecting" in `Network not active, dropping peer=…`

  A few exceptions are listed here: https://github.com/bitcoin/bitcoin/pull/28521#discussion_r1890824361

  I changed `CloseSocketDisconnect()` to no longer log `disconnecting`, and instead have all the call sites do so.

  This PR introduces two helper functions on `CNode`: `DisconnectMsg` and `LogIP`. The second and third commit use these helpers in `net_processing.cpp` so these disconnect messages are more consistent now (e.g. some didn't log the IP). No new messages are added there though.

  The `LogIP()` helper is rarely used outside of a disconnect event, but it's available for future use.

  Any `LogPrint` this PR touches is replaced with `LogDebug` (superseded by #30750), and every `LogPrintf ` with `LogInfo`.

ACKs for top commit:
  davidgumberg:
    reACK 06443b8f28
  vasild:
    ACK 06443b8f28
  danielabrozzoni:
    ACK 06443b8f28
  hodlinator:
    ACK 06443b8f28

Tree-SHA512: 525f4c11568616e1d48455a3fcab9e923da7432377fe9230468c15403d2e9b7ce712112df8fbd547cfec01dce0d1f26107cfc1b90f78cfc1fe13e08d57b08464
2024-12-27 09:09:29 -05:00
Martin Zumsande
bc43ecaf6d test: add functional test for balance after snapshot completion
Use a third node for this, which doesn't get restarted like the second
node.
This test would fail without the previous commit.
2024-12-26 12:11:28 -05:00
Martin Zumsande
226d03dd61 validation: Send correct notification during snapshot completion
If AssumeUtxo background sync is completed in this
ActivateBestChain() call, the GetRole() function
returns "normal" instead of "background" for this chainstate.
This would make the wallet (which ignores BlockConnected
notifcation for the background chainstate) process it, change
m_last_block_processed_height, and display an incorrect
balance.
2024-12-26 12:11:25 -05:00
MarcoFalke
fa63b8232f
test: generateblocks called by multiple threads
Co-Authored-By: David Gumberg <davidzgumberg@gmail.com>
2024-12-25 10:29:34 +01:00
MarcoFalke
fa62c8b1f0
rpc: Extend scope of validation mutex in generateblock
The mutex (required by TestBlockValidity) must be held after creating
the block, until TestBlockValidity is called. Otherwise, it is possible
that the chain advances in the meantime and leads to a crash in
TestBlockValidity:

 Assertion failed: pindexPrev && pindexPrev == chainstate.m_chain.Tip() (validation.cpp: TestBlockValidity: 4338)

The diff can be reviewed with the git options
--ignore-all-space --function-context
2024-12-24 15:51:56 +01:00
brunoerg
366ae00b77 descriptor: Assume ParseScript is not being called with a P2WPKH context 2024-12-24 11:01:47 -03:00
brunoerg
e366408590 descriptor: remove unreachable verification for pkh 2024-12-23 08:41:35 -03:00
Lőrinc
5709718b83 coins: warn on shutdown for big UTXO set flushes
Setting a large `-dbcache` size postpones the index writes until the coins cache size exceeds the specified limit.
This causes the final flush after manual termination to seemingly hang forever (e.g. tens of minutes for 20 GiB);
Now that the `dbcache` upper cap has been lifted, this will become even more apparent, so a warning will be shown when large UTXO sets are flushed (currently >1 GiB), such as:
> 2024-12-18T18:25:03Z Flushed fee estimates to fee_estimates.dat.
> 2024-12-18T18:25:03Z [warning] Flushing large (1 GiB) UTXO set to disk, it may take several minutes
> 2024-12-18T18:25:09Z Shutdown: done

Note that the related BCLog::BENCH units were also converted to `KiB` from `kB` to unify the bases.

Co-authored-by: Cory Fields <cory-nospam-@coryfields.com>
2024-12-22 14:08:58 +01:00
Hennadii Stepanov
b0b8d96d93
depends: Update capnproto to 1.1.0
This change fixes compilation on NetBSD with GCC 14.
2024-12-21 17:39:19 +00:00
0xb10c
e87429a2d0
ci: optionally use local docker build cache
By setting DANGER_DOCKER_BUILD_CACHE_HOST_DIR, the task-specific
docker images built during the CI run can be cached. This allows,
for example, ephemeral CI runners to reuse the docker images (or
layers of it) from earlier runs, by persisting the image cache
before the ephemeral CI runner is shut down. The cache keyed by
`CONTAINER_NAME`.

As --cache-to doesn't remove old cache files, the existing cache
is removed after a successful `docker build` and the newly cached
image is moved to it's location to avoid the cache from growing
indefinitly with old, unused layers.

When --cache-from doesn't find the directory, the cached version is
a cache-miss, or the cache can't be imported for whatever other reason,
it warns and `docker build` continues by building the docker image.

This feature is opt-in. The documentation for the cache type=local
can be found https://docs.docker.com/build/cache/backends/local/

This replaces https://github.com/bitcoin/bitcoin/pull/31377
2024-12-21 14:35:28 +01:00
merge-script
fc7b214847
Merge bitcoin/bitcoin#31529: guix: latest 2.31 glibc
b8710201fb guix: disable timezone tools & profiling in glibc (fanquake)
23b8a424fb guix: bump glibc 2.31 to 7b27c450c34563a28e634cccb399cd415e71ebfe (fanquake)

Pull request description:

  An additional commit has been backported to the 2.31 branch:
  https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/release/2.31/master.

  Pass `--disable-timezone-tools`: removes `var/profiles/x86_64-linux-gnu/sbin/zdump`.
  Pass `--disable-profile`: profiling is disabled by default, but make that explicit.

ACKs for top commit:
  theuni:
    utACK b8710201fb
  hebasto:
    ACK b8710201fb.

Tree-SHA512: 0d9a0e7451cc42384bbdd0b46c740c7aa964dc12e3f0376de586bf90e57799ebb04675892861cb38a53b5ca0e265061fa7111596cf1c94171303d0d048785ab4
2024-12-20 15:19:05 +00:00
merge-script
273440d5c9
Merge bitcoin/bitcoin#31535: doc: Install py3-zmq port on OpenBSD for interface_zmq.py
be1a2e5dfb doc: Install `py3-zmq` port on OpenBSD for `interface_zmq.py` (Hennadii Stepanov)

Pull request description:

  On OpenBSD, Python's `zmq` module is provided as a separate [port](https://www.ports.to/path/net/py-zmq,python3.html).

  This PR updates the OpenBSD Build Guide to include this port, enabling the `interface_zmq.py` functional test.

  Also updates the documented OpenBSD version.

ACKs for top commit:
  theStack:
    Tested ACK be1a2e5dfb

Tree-SHA512: 4d560385b94e8c7491aa19d2157d8a799617e08136601dc565a909d4c74e12582a1d273bc97ad7c2d0e57c5cf7377560ba02ef58c12f8991652322553740d2ba
2024-12-20 15:17:05 +00:00
merge-script
4cdf50c4ba
Merge bitcoin/bitcoin#31544: cmake: Remove unused BUILD_TESTING variable from "dev-mode" preset
e196190a28 cmake: Remove unused `BUILD_TESTING` variable from "dev-mode" preset (Hennadii Stepanov)

Pull request description:

  On the master branch @ bb57017b29:
  ```
  $ cmake -B build --preset dev-mode -DWITH_MULTIPROCESS=OFF
  <snip>
  -- Configuring done (12.0s)
  -- Generating done (0.1s)
  CMake Warning:
    Manually-specified variables were not used by the project:

      BUILD_TESTING

  -- Build files have been written to: /home/hebasto/git/bitcoin/build
  ```

  This PR resolves the issue.

  The removed `BUILD_TESTING` variable is a part of the [`CTest`](https://cmake.org/cmake/help/latest/module/CTest.html) module, which we do not include in the project.

ACKs for top commit:
  TheCharlatan:
    ACK e196190a28

Tree-SHA512: 8110a0f5bdcdd0844ce7dd75160a61d8b3aff95e12da1ec4d55c56c82da41145736da0fad072adeb97551c99e46683a3493435c3bac7d8e4e62ea6086f60fb7a
2024-12-20 15:15:10 +00:00
MarcoFalke
faf7eac364
test: clang-format -i src/univalue/test/unitester.cpp 2024-12-20 15:01:44 +01:00
MarcoFalke
fafa9cc7a5
test: Embed univalue json tests in binary 2024-12-20 15:01:36 +01:00
MarcoFalke
fa044857ca
test: Re-enable univalue test fail18.json
Also, extend the pass2.json test to the maximum depth possible. The two
tests are now similar to fail45.json and pass4.json, except for the
string element in the inner-most array.

Also, sort.
2024-12-20 15:01:36 +01:00
Lőrinc
63b6b638aa build: Use character literals for generated headers to avoid narrowing
Use character literals instead of integer hex values (i.e. `'\x5b','\x0a', ...` instead of `0x5b, 0x0a, ...`) for generated headers.
This avoids C++11 narrowing warnings in a more concise way than using explicit char casts.

Extra whitespace is also removed between elements for brevity.
2024-12-20 14:37:31 +01:00
Ash Manning
ecaa786cc1 rpc: add signet_challenge field to getblockchaininfo and getmininginfo 2024-12-20 17:57:15 +08:00
Hennadii Stepanov
e196190a28
cmake: Remove unused BUILD_TESTING variable from "dev-mode" preset 2024-12-19 22:25:11 +00:00
Hennadii Stepanov
11115e9aa8
cmake: Always provide RPATH on NetBSD 2024-12-19 18:35:49 +00:00
Hennadii Stepanov
d38ade7bc4
qa: Use sys.executable when invoking other Python scripts
This change fixes tests on systems where `python3` is not available
in the `PATH`, causing the shebang `#!/usr/bin/env python3` to fail.
2024-12-19 17:10:20 +00:00
Ryan Ofsky
bb57017b29
Merge bitcoin/bitcoin#31521: fuzz: Fix misplaced SeedRand::ZEROS
fadd568931 fuzz: Fix misplaced SeedRand::ZEROS (MarcoFalke)

Pull request description:

  After commit fae63bf130 this must be placed even before test_setup. This is nice, because it makes the usage consistently appear in the first line.

  The change is moving a `SeedRandomForTest(SeedRand::ZEROS)` to happen earlier. This is fine, because it will either have no effect, or make the code more deterministic, because after commit fae63bf, no other re-seeding other than `ZEROS` can happen in fuzz tests.

ACKs for top commit:
  marcofleon:
    Re ACK fadd568931
  brunoerg:
    code review ACK fadd568931
  hodlinator:
    ACK fadd568931

Tree-SHA512: 54eadf19a1e850157a280fb252ece8797f37a9a50d3b0a01aa2c267bacbe8ef4ddea6cf3faadcbaa4ab9f53148edf08e3cee5dfb3eae928db582adf8373a5206
2024-12-19 10:23:27 -05:00
Ryan Ofsky
5bbbc0d0ee
Merge bitcoin/bitcoin#31325: Make m_tip_block std::optional
81cea5d4ee Ensure m_tip_block is never ZERO (Sjors Provoost)
e058544d0e Make m_tip_block an std::optional (Sjors Provoost)

Pull request description:

  Suggested in https://github.com/bitcoin/bitcoin/pull/31297#discussion_r1844244309

ACKs for top commit:
  fjahr:
    re-ACK 81cea5d4ee
  tdb3:
    code review re ACK 81cea5d4ee
  l0rinc:
    ACK 81cea5d4ee

Tree-SHA512: 31a75ba29e3d567bab32e4e7925a419d9d7a4d2d85ed1c1012116d8d22adc14d31d5b4ce5f6c499c994188dcd26a01cced05be74f94c892fc90ae17a6783a472
2024-12-19 10:05:31 -05:00
Hennadii Stepanov
d9d5bc2e74
qa: Limit -maxconnections in tests
On systems such as NetBSD, this change enables the execution of
functional tests.
2024-12-19 15:04:22 +00:00
MarcoFalke
fa494a1d53
refactor: Specify const in std::span constructor, where needed
The std::span constructor requires std::ranges::borrowed_range, which
tries to protect against dangling references.

One way to disable the check is to specify the std::span's element type
as const in the constructor call.

Otherwise, a compile error will look like:

 include/c++/span: note: candidate constructor not viable: no known conversion from 'std::vector<unsigned char>' to 'const span<unsigned char>' for 1st argument
      |       span(const span&) noexcept = default;
      |       ^    ~~~~~~~~~~~
 ...
 include/c++/span: note: candidate template ignored: constraints not satisfied [with _Range = std::vector<unsigned char>]
      |         span(_Range&& __range)
      |         ^
 include/c++/span: note: because 'std::vector<unsigned char>' does not satisfy 'borrowed_range'
      |           && (ranges::borrowed_range<_Range> || is_const_v<element_type>)
      |               ^
 include/c++/bits/ranges_base.h: note: because 'std::vector<unsigned char>' does not satisfy '__maybe_borrowed_range'
      |       = range<_Tp> && __detail::__maybe_borrowed_range<_Tp>;
      |                       ^
 include/c++/bits/ranges_base.h: note: because 'is_lvalue_reference_v<std::vector<unsigned char> >' evaluated to false
      |         = is_lvalue_reference_v<_Tp>
      |           ^
 include/c++/bits/ranges_base.h: note: and 'enable_borrowed_range<remove_cvref_t<vector<unsigned char, allocator<unsigned char> > > >' evaluated to false
      |           || enable_borrowed_range<remove_cvref_t<_Tp>>;
      |              ^
 include/c++/span: note: and 'is_const_v<element_type>' evaluated to false
      |           && (ranges::borrowed_range<_Range> || is_const_v<element_type>)
      |                                                 ^
2024-12-19 14:41:23 +01:00
MarcoFalke
faaf4800aa
Allow std::span in stream serialization
Future code can now use std::span in stream serialization, similar to
the existing serialization helpers for std::array or Span.
2024-12-19 14:41:21 +01:00
MarcoFalke
faa5391f77
refactor: test: Return std::span from StringBytes
This is possible and safe, because std::span can implicitly convert into
Span, if needed.

Changing this function is required, because std::span requires the
extent template parameter to be specified as well.

Instead of explicilty specifying them, just let the compiler derive the
template parameters correctly.

Otherwise, there would be a compile error later on:

 src/wallet/test/db_tests.cpp:39:37: error: no matching function for call to ‘as_bytes<const char>(<brace-enclosed initializer list>)’
 ...
 /usr/include/c++/11/span:420:5: note: candidate: ...
       |     as_bytes(span<_Type, _Extent> __sp) noexcept
       |     ^~~~~~~~
 /usr/include/c++/11/span:420:5: note:   template argument deduction/substitution failed:
 src/wallet/test/db_tests.cpp:39:37: note:   couldn’t deduce template parameter ‘_Extent’
       |     return std::as_bytes<const char>({str.data(), str.size()});
       |            ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
2024-12-19 14:40:32 +01:00
MarcoFalke
fa86223475
refactor: Avoid passing span iterators when data pointers are expected
For Span, iterators are just raw data pointers. However, for std::span
they are not.

This change makes it explicit where data pointers are expected.

Otherwise, there could be a compile error later on:

  No known conversion from 'iterator' (aka '__normal_iterator<const std::byte *, std::span<const std::byte, 18446744073709551615>>') to 'std::byte *'.
2024-12-19 14:39:55 +01:00
MarcoFalke
faae6fa5f6
refactor: Simplify SpanPopBack
Use the equivalent back() and first() member functions.
2024-12-19 13:46:52 +01:00
MarcoFalke
facc4f120b
refactor: Replace fwd-decl with proper include
This is fine, because the span.h include is lightweight and a proper
include will be needed anyway when switching to std::span.
2024-12-19 13:46:43 +01:00
MarcoFalke
fac3a782ea
refactor: Avoid needless, unsafe c-style cast 2024-12-19 13:46:31 +01:00
Ryan Ofsky
c1252b14d7
Merge bitcoin/bitcoin#31520: #31318 followups
4f06ae05ed refactor: fix typo in node/types.h (Sjors Provoost)
366fbf152c test: drop extraneous bracket in mining util (Sjors Provoost)

Pull request description:

  #31318 followups

  Drops an extraneous bracket and fixes a typo.

ACKs for top commit:
  maflcko:
    lgtm ACK 4f06ae05ed
  vasild:
    ACK 4f06ae05ed
  ryanofsky:
    Code review ACK 4f06ae05ed

Tree-SHA512: e168bab124f1e62f6666a21349ee4ac8ac11aadeb04813513e89f6c8f8479a67bcf3490460fd49c8d7f9b7264a32e7ea95ac727dfe4597a59b934017ec9fe44e
2024-12-18 15:41:28 -05:00
Hennadii Stepanov
be1a2e5dfb
doc: Install py3-zmq port on OpenBSD for interface_zmq.py
Also updates the documented OpenBSD version.
2024-12-18 19:48:03 +00:00
Ryan Ofsky
fa0c473d4c
Merge bitcoin/bitcoin#31196: Prune mining interface
c991cea1a0 Remove processNewBlock() from mining interface (Sjors Provoost)
9a47852d88 Remove getTransactionsUpdated() from mining interface (Sjors Provoost)
bfc4e029d4 Remove testBlockValidity() from mining interface (Sjors Provoost)

Pull request description:

  There are three methods in the mining interface that can be dropped. The Template Provider doesn't need them and other application should probably not use them either.

  1. `processNewBlock()` was added in 7b4d3249ce, but became unnecessary with the introduction of interfaces::BlockTemplate::submitSolution in 7b4d3249ce.

  Dropping it was suggested in https://github.com/bitcoin/bitcoin/pull/30200#issuecomment-2404460342

  2. `getTransactionsUpdated()`: this is used in the implementation of #31003 `waitFeesChanged`. It's not very useful generically because the mempool updates very frequently.

  3. `testBlockValidity()`: it might be useful for mining application to have a way to check the validity of a block template they modified, but the Stratum v2 Template Provider doesn't do that, and this method is a bit brittle (e.g. the block needs to build on the tip).

ACKs for top commit:
  TheCharlatan:
    Re-ACK c991cea1a0
  ryanofsky:
    Code review ACK c991cea1a0. Since last review, just rebased to avoid conflicts in surrounding code, and edited a commit message
  tdb3:
    code review ACK c991cea1a0

Tree-SHA512: 2138e54f920b26e01c068b24498c6a210c5c4358138dce0702ab58185d9ae148a18f04c97ac9f043646d40f8031618d80a718a176b1ce4779c237de6fb9c4a67
2024-12-18 14:44:14 -05:00
Ryan Ofsky
ea53568a06
Merge bitcoin/bitcoin#31393: refactor: Move GuessVerificationProgress into ChainstateManager
facb4d010c refactor: Move GuessVerificationProgress into ChainstateManager (MarcoFalke)

Pull request description:

  Currently the function is standalone, which means any passed-in data like `TxData` or the block pointer needs to be taken from the `ChainstateManager` and passed in. This is currently verbose and may become even more verbose if the function is reworked in the future. As the function can not be called without a `ChainstateManager` in production code anyway, make it a member function on the class.

ACKs for top commit:
  ryanofsky:
    Code review ACK facb4d010c. Nice cleanup, that should make this code less awkward to work with
  TheCharlatan:
    ACK facb4d010c
  danielabrozzoni:
    reACK facb4d010c

Tree-SHA512: b17977e12cd7c6e308c47e6a1aa920acecd4442696e46d1f30bd7c201e9898ca2d581ff0bf2cc9f7334e146c1b0c50925adb849c8c17f65dcdf6877be1c5f776
2024-12-18 13:58:10 -05:00
fanquake
b8710201fb
guix: disable timezone tools & profiling in glibc
Removes `var/profiles/x86_64-linux-gnu/sbin/zdump`.

Profiling is disabled by default, but make that explicit.
2024-12-18 13:30:24 +00:00
fanquake
23b8a424fb
guix: bump glibc 2.31 to 7b27c450c34563a28e634cccb399cd415e71ebfe
An additional commit has been backported to the 2.31 branch:
https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/release/2.31/master.
2024-12-18 12:16:42 +00:00
Hennadii Stepanov
0a76c292ac
doc: Install net/py-pyzmq port on FreeBSD for interface_zmq.py 2024-12-18 12:09:49 +00:00
MarcoFalke
fadd568931
fuzz: Fix misplaced SeedRand::ZEROS
After commit fae63bf130 this must be
placed even before test_setup.
2024-12-18 12:10:58 +01:00
MarcoFalke
fa83bec78e
refactor: Allow std::byte in Read(LE/BE) 2024-12-18 10:59:25 +01:00
Sjors Provoost
4f06ae05ed
refactor: fix typo in node/types.h 2024-12-18 14:55:35 +07:00
Sjors Provoost
366fbf152c
test: drop extraneous bracket in mining util 2024-12-18 14:55:19 +07:00
Sjors Provoost
c991cea1a0
Remove processNewBlock() from mining interface
processNewBlock was added in 7b4d3249ce, but became unnecessary with the introduction of interfaces::BlockTemplate::submitSolution in 7b4d3249ce.

getTransactionsUpdated() is only needed by the implementation of waitFeesChanged() (not yet part of the interface).
2024-12-18 09:20:26 +07:00
Sjors Provoost
9a47852d88
Remove getTransactionsUpdated() from mining interface
It's unnecessary to expose it via this interface.
2024-12-18 09:19:12 +07:00
Sjors Provoost
bfc4e029d4
Remove testBlockValidity() from mining interface
It's very low level and not used by the proposed Template Provider.

This method was introduced in d8a3496b5a
and a74b0f93ef.
2024-12-18 09:18:21 +07:00
Ryan Ofsky
477b357460
Merge bitcoin/bitcoin#31493: refactor: Use immediate lambda to work around GCC bug 117966
fa9e0489f5 refactor: Use immediate lambda to work around GCC bug 117966 (MarcoFalke)

Pull request description:

  Currently the libstdc++ debug mode can only be used with version 11, or 15 (and later), due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117966

  This seems restrictive.

  Add a temporary workaround for now, which makes the global (temporary) `std::span` local to a lambda.

ACKs for top commit:
  theuni:
    utACK fa9e0489f5
  hebasto:
    ACK fa9e0489f5, tested on Ubuntu 24.10.
  vasild:
    ACK fa9e0489f5

Tree-SHA512: 0cc54f089f329592f7a92a6f938b7de46c92d5362615310748225a42789e858e871432721e3101271b00871d523af5fbaadba2f52433fe79e928b1d1253931f6
2024-12-17 13:32:21 -05:00
Ryan Ofsky
a60d5702fd
Merge bitcoin/bitcoin#31486: fuzz: Abort when using global PRNG without re-seed
fae63bf130 fuzz: Clarify that only SeedRandomStateForTest(SeedRand::ZEROS) is allowed (MarcoFalke)
fa18acb457 fuzz: Abort when using global PRNG without re-seed (MarcoFalke)
fa7809aeab fuzz: Add missing SeedRandomStateForTest(SeedRand::ZEROS) (MarcoFalke)

Pull request description:

  This is the first step toward improving fuzz stability and determinism (https://github.com/bitcoin/bitcoin/issues/29018).

  A fuzz target using the global test-only PRNG will now abort if the seed is re-used across fuzz inputs.

  Also, temporarily add `SeedRandomStateForTest(SeedRand::ZEROS)` to all affected fuzz targets. This may slow down the libfuzzer leak detector, but it will disable itself after some time, or it can be disabled explicitly with `-detect_leaks=0`.

  In a follow-up, each affected fuzz target can be stripped of the global random use and a local `RandomMixin` (or similar) can be added instead.

  (Can be tested by removing any one of the re-seed calls and observing a fuzz abort)

ACKs for top commit:
  hodlinator:
    ACK fae63bf130
  dergoegge:
    utACK fae63bf130
  marcofleon:
    Tested ACK fae63bf130

Tree-SHA512: 4a0db69af7f715408edf4f8b08b44f34ce12ee2c79d33b336ad19a6e6bd079c4ff7c971af0a3efa428213407c1171f4e2837ec6a2577086c2f94cd15618a0892
2024-12-17 12:55:38 -05:00
Ryan Ofsky
a95a8ba3a3
Merge bitcoin/bitcoin#31197: refactor: mining interface 30955 followups
f86678156a Check leaves size maximum in MerkleComputation (Sjors Provoost)
4d57288246 refactor: use CTransactionRef in submitSolution (Sjors Provoost)
2e81791d90 Drop TransactionMerklePath default position arg (Sjors Provoost)
39d3b538e6 Rename merkle branch to path (Sjors Provoost)

Pull request description:

  This PR implements the refactors suggested in https://github.com/bitcoin/bitcoin/pull/30955#pullrequestreview-2354931253.

ACKs for top commit:
  tdb3:
    code review re-ACK f86678156a
  itornaza:
    re ACK f86678156a
  ryanofsky:
    Code review ACK f86678156a only changes since last review are a whitespace change and adding an Assume statement to check for size_t -> uint32_t overflows

Tree-SHA512: 661b5d5d0e24b2269bf33ab1484e37c36e67b32a7796d77ca3b1856d3043378b081ad43c32a8638b46fa8c0de51c823fd9747dd9fc81f958f20d327bf330a47c
2024-12-17 12:32:45 -05:00
Ryan Ofsky
cd3d9fa5ea
Merge bitcoin/bitcoin#31318: Drop script_pub_key arg from createNewBlock
52fd1511a7 test: drop scriptPubKeyIn arg from CreateNewBlock (Sjors Provoost)
ff41b9e296 Drop script_pub_key arg from createNewBlock (Sjors Provoost)
7ab733ede4 rpc: rename coinbase_script to coinbase_output_script (Sjors Provoost)

Pull request description:

  Providing a script for the coinbase transaction is only done in test code and for (unoptimized) CPU solo mining.

  Production miners use the `getblocktemplate` RPC which omits the coinbase transaction entirely from its block template, leaving it to external (pool) software to construct it.

  This commit removes the `script_pub_key argument` from `createNewBlock()` in the Mining interface.

  A coinbase script can still be passed via `BlockCreateOptions` instead. Tests are modified to do so.

ACKs for top commit:
  ryanofsky:
    Code review ACK 52fd1511a7. No change since last review other than rebase
  TheCharlatan:
    Re-ACK 52fd1511a7
  vasild:
    ACK 52fd1511a7

Tree-SHA512: c4b3a53774d9a5dc90950e77f47a64dbb68f971baffbb9a0d8f59332ef8e52d0c039130c925bde73135b3d0e79e65d91d1df30dc4cff13f32d8a72e5c56669d8
2024-12-17 11:50:44 -05:00
MarcoFalke
fae63bf130
fuzz: Clarify that only SeedRandomStateForTest(SeedRand::ZEROS) is allowed 2024-12-17 08:46:37 +01:00
Sjors Provoost
81cea5d4ee
Ensure m_tip_block is never ZERO
To avoid future code changes from reintroducing the ambiguity fixed
by the previous commit, mark m_tip_block private and Assume that
it's not set to uint256::ZERO.
2024-12-17 10:19:00 +07:00
Sjors Provoost
e058544d0e
Make m_tip_block an std::optional
This change avoids ambiguity when no tip is connected and it is
compared to uint256::ZERO.
2024-12-17 10:18:36 +07:00
Sjors Provoost
f86678156a
Check leaves size maximum in MerkleComputation
Belt and suspenders for future code changes.

Currently this function is only called from TransactionMerklePath() which sets leaves to the block transactions, so the Assume always holds.
2024-12-17 10:12:31 +07:00
Sjors Provoost
4d57288246
refactor: use CTransactionRef in submitSolution 2024-12-17 10:12:31 +07:00
Sjors Provoost
2e81791d90
Drop TransactionMerklePath default position arg 2024-12-17 10:12:31 +07:00
Sjors Provoost
39d3b538e6
Rename merkle branch to path 2024-12-17 10:12:31 +07:00
MarcoFalke
fa18acb457
fuzz: Abort when using global PRNG without re-seed 2024-12-16 15:23:56 +01:00
MarcoFalke
fa9e0489f5
refactor: Use immediate lambda to work around GCC bug 117966 2024-12-16 10:39:28 +01:00
yancy
b9766c9977 Remove unused variable assignment
The variable is conditionally assigned toward the end of the loop and
not used after.  It's then set back to its default value at the beginning
of the loop.
2024-12-13 21:00:07 -06:00
Hodlinator
e8f0e6efaf
lint: output-only - Avoid repeated arrows, trim
- No empty line separating errors and arrows ("^^^"). Keeping them together signals they are related.
- No empty line separating error message and linter failure line (not completely empty, it contains several spaces left over from Rust multi-line literal).
- Keep the linter description on the same line as the failure line, otherwise it looks like it's a description for the following step.
2024-12-13 17:25:18 +01:00
MarcoFalke
facb4d010c
refactor: Move GuessVerificationProgress into ChainstateManager 2024-12-13 16:12:30 +01:00
MarcoFalke
fa7809aeab
fuzz: Add missing SeedRandomStateForTest(SeedRand::ZEROS) 2024-12-13 14:22:25 +01:00
MarcoFalke
fa0998f0a0
test: Avoid intermittent error in assert_equal(pruneheight_new, 248) 2024-12-13 11:06:17 +01:00
MarcoFalke
fa9aacf614
lint: Move assertion linter into lint runner
On failure, this makes the output more consistent with the other linter.
Each failure will be marked with an '⚠️ ' emoji and explanation, making
it easier to spot.

Also, add --line-number to the filesystem linter.

Also, add newlines after each failing check, to visually separate
different failures from each other.

Can be reviewed with:
"--color-moved=dimmed-zebra --color-moved-ws=ignore-all-space"
2024-12-13 09:49:04 +01:00
furszy
589ed1a8ea
wallet: migration, avoid loading wallet after failure when it wasn't loaded before
During migration failure, only load wallet back into memory when the
wallet was loaded prior to migration. This fixes the case where BDB
is not supported, which implies that no legacy wallet can be loaded
into memory due to the lack of db writing functionality.

This commit also improves migration backup related comments to better
document the current workflow.

Co-authored-by: Ava Chow <github@achow101.com>
2024-12-11 20:26:36 -05:00
MarcoFalke
fa397177ac
util: Add missing types in make_secure_unique 2024-12-10 21:51:48 +01:00
Matthew Zipkin
b6f0593f43
doc: add release note about testmempoolaccept debug-message 2024-12-10 11:00:43 -05:00
Matthew Zipkin
f9cac63523
test: cover testmempoolaccept debug-message in RBF test 2024-12-10 11:00:25 -05:00
furszy
18619b4732
wallet: remove BDB dependency from wallet migration benchmark
Stops creating a bdb database in the wallet migration benchmark.
Instead, the benchmark now creates the db in memory and re-uses
it for the migration process.
2024-12-06 11:17:28 -05:00
MarcoFalke
fa6e599cf9
test: Call generate through test framework only 2024-12-06 08:20:52 +01:00
Matthew Zipkin
f9650e18ea
rbf: remove unecessary newline at end of error string 2024-12-04 14:37:48 -05:00
Matthew Zipkin
221c789e91
rpc: include verbose reject-details field in testmempoolaccept response 2024-12-04 14:37:37 -05:00
MarcoFalke
fad83e759a
doc: Fix incorrect send RPC docs 2024-12-04 15:52:46 +01:00
Sjors Provoost
52fd1511a7
test: drop scriptPubKeyIn arg from CreateNewBlock
This removes the temporary overload added in the previous commit.

Also drop unneeded custom coinbase output scripts.
2024-12-04 12:46:33 +07:00
Sjors Provoost
ff41b9e296
Drop script_pub_key arg from createNewBlock
Providing a script for the coinbase transaction is only done in test code
and for CPU solo mining.

Production miners use the getblocktemplate RPC which omits the coinbase
transaction entirely from its block template, leaving it to external (pool)
software to construct it.

A coinbase script can still be passed via BlockCreateOptions instead.

A temporary overload is added so that the test can be modified in the
next commit.
2024-12-04 12:44:57 +07:00
Sjors Provoost
7ab733ede4
rpc: rename coinbase_script to coinbase_output_script 2024-12-04 12:44:57 +07:00
Antoine Poinsot
733fa0b0a1 miner: never create a template which exploits the timewarp bug 2024-11-26 12:48:29 -05:00
Sjors Provoost
06443b8f28
net: clarify if we ever sent or received from peer 2024-11-26 14:01:36 +01:00
Sjors Provoost
1d01ad4d73
net: add LogIP() helper, use in net_processing 2024-11-26 13:22:55 +01:00
Sjors Provoost
937ef9eb40
net_processing: use CNode::DisconnectMsg helper
This is not a pure refactor:
1. It slightly changes the log messages, as reflected in the test changes
2. It adds the IP address to all disconnect logging (when fLogIPs is set)
2024-11-26 13:22:55 +01:00
Sjors Provoost
ad224429f8
net: additional disconnection logging
Use the word "disconnecting" everywhere for easier grep.
2024-11-26 13:22:55 +01:00
furszy
a2c45ae548
test: report failure during utf8 response decoding
Useful for debugging issues.
2024-11-11 10:45:01 -05:00
Ava Chow
493656763f desc spkm: Return SigningProvider only if we have the privkey
If we know about a pubkey that's in our descriptor, but we don't have
the private key, don't return a SigningProvider for that pubkey.

This is specifically an issue for Taproot outputs that use the H point
as the resulting PSBTs may end up containing irrelevant information
because the H point was detected as a pubkey each unrelated descriptor
knew about.
2024-11-07 11:41:25 -05:00
Vasil Dimov
e56fc7ce6a
rpc: increase the defaults for -rpcthreads and -rpcworkqueue
`rpcthreads` was introduced with a default of 4 in 2013 in
21eb5adadb

`rpcworkqueue` was introduced with a default of 16 in 2015 in
40b556d374

Resolves: https://github.com/bitcoin/bitcoin/issues/29386
2024-11-04 17:08:21 +01:00
Sebastian Falbesoner
d45eb3964f test: compare BDB dumps of test framework parser and wallet tool 2024-10-24 15:55:36 +02:00
Sebastian Falbesoner
01ddd9f646 test: complete BDB parser (handle internal/overflow pages, support all page sizes)
This aims to complete our test framework BDB parser to reflect
our read-only BDB parser in the wallet codebase. This could be
useful both for making review of #26606 easier and to also possibly
improve our functional tests for the BDB parser by comparing with
an alternative implementation.
2024-10-24 14:23:54 +02:00
Andrew Chow
69e95c2b4f tests: Test cleanup of mkeys from wallets without privkeys 2024-10-16 05:54:45 -04:00
Andrew Chow
2b9279b50a wallet: Remove unused encryption keys from watchonly wallets
Due to a bug in earlier versions, some wallets without private keys may
have an encryption key. This encryption key is unused and can lead to
confusing behavior elsewhere. When such wallets are detected, those
encryption keys will now be deleted from the wallet. For safety, we only
do this to wallets which have private keys disabled, have encryption keys,
and definitely do not have encrypted keys.
2024-10-16 05:54:45 -04:00
Andrew Chow
813a16a463 wallet: Add HasCryptedKeys 2024-10-16 05:54:45 -04:00
furszy
cddcbaf81e
RPC: improve SFFO arg parsing, error catching and coverage
Following changes were made:

1) Catch and signal error for duplicate string destinations.
2) Catch and signal error for invalid value type.
3) Catch and signal error for string destination not found in tx outputs.
4) Improved 'InterpretSubtractFeeFromOutputInstructions()' code organization.
5) Added test coverage for all possible error failures.

Also, fixed two PEP 8 warnings at the 'wallet_sendmany.py' file:
- PEP 8: E302 expected 2 blank lines, found 1 at the SendmanyTest class declaration.
- PEP 8: E303 too many blank lines (2) at skip_test_if_missing_module() and set_test_params()
2024-09-07 13:06:41 -03:00
furszy
4f4cd35319
rpc: decouple sendtoaddress 'subtractfeefromamount' boolean parsing
The 'subtractfeefromamount' arg is only boolean for sendtoaddress().
Other commands should never provide it as a boolean.
2024-09-07 12:15:46 -03:00
322 changed files with 8723 additions and 2365 deletions

View file

@ -140,13 +140,13 @@ task:
FILE_ENV: "./ci/test/00_setup_env_win64.sh"
task:
name: '32-bit CentOS, dash, gui'
name: 'CentOS, depends, gui'
<< : *GLOBAL_TASK_TEMPLATE
persistent_worker:
labels:
type: small
env:
FILE_ENV: "./ci/test/00_setup_env_i686_centos.sh"
FILE_ENV: "./ci/test/00_setup_env_native_centos.sh"
task:
name: 'previous releases, depends DEBUG'

View file

@ -1,12 +1,12 @@
# Copyright (c) 2023 The Bitcoin Core developers
# Copyright (c) 2023-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
name: CI
on:
# See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request.
# See: https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request.
pull_request:
# See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push.
# See: https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#push.
push:
branches:
- '**'
@ -26,7 +26,7 @@ jobs:
name: 'test each commit'
runs-on: ubuntu-24.04
if: github.event_name == 'pull_request' && github.event.pull_request.commits != 1
timeout-minutes: 360 # Use maximum time, see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idtimeout-minutes. Assuming a worst case time of 1 hour per commit, this leads to a --max-count=6 below.
timeout-minutes: 360 # Use maximum time, see https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idtimeout-minutes. Assuming a worst case time of 1 hour per commit, this leads to a --max-count=6 below.
env:
MAX_COUNT: 6
steps:
@ -67,16 +67,16 @@ jobs:
echo "TEST_BASE=$(git rev-list -n$((${{ env.MAX_COUNT }} + 1)) --reverse HEAD $EXCLUDE_MERGE_BASE_ANCESTORS | head -1)" >> "$GITHUB_ENV"
- run: |
sudo apt-get update
sudo apt-get install clang ccache build-essential cmake pkg-config python3-zmq libevent-dev libboost-dev libsqlite3-dev libdb++-dev systemtap-sdt-dev libzmq3-dev qtbase5-dev qttools5-dev qttools5-dev-tools qtwayland5 libqrencode-dev -y
sudo apt-get install clang ccache build-essential cmake pkgconf python3-zmq libevent-dev libboost-dev libsqlite3-dev libdb++-dev systemtap-sdt-dev libzmq3-dev qtbase5-dev qttools5-dev qttools5-dev-tools qtwayland5 libqrencode-dev -y
- name: Compile and run tests
run: |
# Run tests on commits after the last merge commit and before the PR head commit
# Use clang++, because it is a bit faster and uses less memory than g++
git rebase --exec "echo Running test-one-commit on \$( git log -1 ) && CC=clang CXX=clang++ cmake -B build -DWERROR=ON -DWITH_ZMQ=ON -DBUILD_GUI=ON -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON -DWITH_BDB=ON -DWITH_USDT=ON -DCMAKE_CXX_FLAGS='-Wno-error=unused-member-function' && cmake --build build -j $(nproc) && ctest --output-on-failure --stop-on-failure --test-dir build -j $(nproc) && ./build/test/functional/test_runner.py -j $(( $(nproc) * 2 ))" ${{ env.TEST_BASE }}
git rebase --exec "echo Running test-one-commit on \$( git log -1 ) && CC=clang CXX=clang++ cmake -B build -DWERROR=ON -DWITH_ZMQ=ON -DBUILD_GUI=ON -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON -DWITH_BDB=ON -DWITH_USDT=ON -DCMAKE_CXX_FLAGS='-Wno-error=unused-member-function' && cmake --build build -j $(nproc) && ctest --output-on-failure --stop-on-failure --test-dir build -j $(nproc) && ./build/test/functional/test_runner.py -j $(( $(nproc) * 2 )) --combinedlogslen=99999999" ${{ env.TEST_BASE }}
macos-native-arm64:
name: ${{ matrix.job-name }}
# Use latest image, but hardcode version to avoid silent upgrades (and breaks).
# Use any image to support the xcode-select below, but hardcode version to avoid silent upgrades (and breaks).
# See: https://github.com/actions/runner-images#available-images.
runs-on: macos-14
@ -111,6 +111,10 @@ jobs:
- name: Clang version
run: |
# Use the earliest Xcode supported by the version of macOS denoted in
# doc/release-notes-empty-template.md and providing at least the
# minimum clang version denoted in doc/dependencies.md.
# See: https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes
sudo xcode-select --switch /Applications/Xcode_15.0.app
clang --version
@ -266,16 +270,16 @@ jobs:
timeout-minutes: 120
env:
FILE_ENV: "./ci/test/00_setup_env_native_asan.sh"
DANGER_CI_ON_HOST_CACHE_FOLDERS: 1
DANGER_CI_ON_HOST_FOLDERS: 1
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set Ccache directory
run: echo "CCACHE_DIR=${RUNNER_TEMP}/ccache_dir" >> "$GITHUB_ENV"
- name: Set base root directory
run: echo "BASE_ROOT_DIR=${RUNNER_TEMP}" >> "$GITHUB_ENV"
- name: Set CI directories
run: |
echo "CCACHE_DIR=${{ runner.temp }}/ccache_dir" >> "$GITHUB_ENV"
echo "BASE_ROOT_DIR=${{ runner.temp }}" >> "$GITHUB_ENV"
echo "BASE_BUILD_DIR=${{ runner.temp }}/build-asan" >> "$GITHUB_ENV"
- name: Restore Ccache cache
id: ccache-cache

View file

@ -22,7 +22,7 @@ set(CLIENT_VERSION_MINOR 99)
set(CLIENT_VERSION_BUILD 0)
set(CLIENT_VERSION_RC 0)
set(CLIENT_VERSION_IS_RELEASE "false")
set(COPYRIGHT_YEAR "2024")
set(COPYRIGHT_YEAR "2025")
# During the enabling of the CXX and CXXOBJ languages, we modify
# CMake's compiler/linker invocation strings by appending the content
@ -143,8 +143,8 @@ cmake_dependent_option(WITH_DBUS "Enable DBus support." ON "CMAKE_SYSTEM_NAME ST
option(WITH_MULTIPROCESS "Build multiprocess bitcoin-node and bitcoin-gui executables in addition to monolithic bitcoind and bitcoin-qt executables. Requires libmultiprocess library. Experimental." OFF)
if(WITH_MULTIPROCESS)
find_package(Libmultiprocess COMPONENTS Lib)
find_package(LibmultiprocessNative COMPONENTS Bin
find_package(Libmultiprocess REQUIRED COMPONENTS Lib)
find_package(LibmultiprocessNative REQUIRED COMPONENTS Bin
NAMES Libmultiprocess
)
endif()
@ -397,6 +397,7 @@ target_link_libraries(core_interface INTERFACE warn_interface)
if(MSVC)
try_append_cxx_flags("/W3" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("/wd4018" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("/wd4146" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("/wd4244" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("/wd4267" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("/wd4715" TARGET warn_interface SKIP_LINK)
@ -580,8 +581,13 @@ endif()
# Relevant discussions:
# - https://github.com/hebasto/bitcoin/pull/236#issuecomment-2183120953
# - https://github.com/bitcoin/bitcoin/pull/30312#issuecomment-2191235833
set(CMAKE_SKIP_BUILD_RPATH TRUE)
set(CMAKE_SKIP_INSTALL_RPATH TRUE)
# NetBSD always requires runtime paths to be set for executables.
if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
else()
set(CMAKE_SKIP_BUILD_RPATH TRUE)
set(CMAKE_SKIP_INSTALL_RPATH TRUE)
endif()
add_subdirectory(test)
add_subdirectory(doc)

View file

@ -71,7 +71,6 @@
"BUILD_GUI_TESTS": "ON",
"BUILD_KERNEL_LIB": "ON",
"BUILD_SHARED_LIBS": "ON",
"BUILD_TESTING": "ON",
"BUILD_TESTS": "ON",
"BUILD_TX": "ON",
"BUILD_UTIL": "ON",

View file

@ -1,7 +1,7 @@
The MIT License (MIT)
Copyright (c) 2009-2024 The Bitcoin Core developers
Copyright (c) 2009-2024 Bitcoin Developers
Copyright (c) 2009-2025 The Bitcoin Core developers
Copyright (c) 2009-2025 Bitcoin Developers
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View file

@ -9,7 +9,7 @@ If the repository is not a fresh git clone, you might have to clean files from p
The ci needs to perform various sysadmin tasks such as installing packages or writing to the user's home directory.
While it should be fine to run
the ci system locally on you development box, the ci scripts can generally be assumed to have received less review and
the ci system locally on your development box, the ci scripts can generally be assumed to have received less review and
testing compared to other parts of the codebase. If you want to keep the work tree clean, you might want to run the ci
system in a virtual machine with a Linux operating system of your choice.

View file

@ -64,7 +64,10 @@ export BASE_OUTDIR=${BASE_OUTDIR:-$BASE_SCRATCH_DIR/out}
# The folder for previous release binaries.
# This folder exists only on the ci guest, and on the ci host as a volume.
export PREVIOUS_RELEASES_DIR=${PREVIOUS_RELEASES_DIR:-$BASE_ROOT_DIR/prev_releases}
export CI_BASE_PACKAGES=${CI_BASE_PACKAGES:-build-essential pkg-config curl ca-certificates ccache python3 rsync git procps bison e2fsprogs cmake}
export CI_BASE_PACKAGES=${CI_BASE_PACKAGES:-build-essential pkgconf curl ca-certificates ccache python3 rsync git procps bison e2fsprogs cmake}
export GOAL=${GOAL:-install}
export DIR_QA_ASSETS=${DIR_QA_ASSETS:-${BASE_SCRATCH_DIR}/qa-assets}
export CI_RETRY_EXE=${CI_RETRY_EXE:-"retry --"}
# The --platform argument used with `docker build` and `docker run`.
export CI_IMAGE_PLATFORM=${CI_IMAGE_PLATFORM:-"linux"} # Force linux, but use native arch by default

View file

@ -10,7 +10,8 @@ export HOST=arm-linux-gnueabihf
export DPKG_ADD_ARCH="armhf"
export PACKAGES="python3-zmq g++-arm-linux-gnueabihf busybox libc6:armhf libstdc++6:armhf libfontconfig1:armhf libxcb1:armhf"
export CONTAINER_NAME=ci_arm_linux
export CI_IMAGE_NAME_TAG="docker.io/arm64v8/debian:bookworm" # Check that https://packages.debian.org/bookworm/g++-arm-linux-gnueabihf (version 12.2, similar to guix) can cross-compile
export CI_IMAGE_NAME_TAG="docker.io/debian:bookworm" # Check that https://packages.debian.org/bookworm/g++-arm-linux-gnueabihf (version 12.2, similar to guix) can cross-compile
export CI_IMAGE_PLATFORM="linux/arm64"
export USE_BUSY_BOX=true
export RUN_UNIT_TESTS=true
export RUN_FUNCTIONAL_TESTS=false

View file

@ -1,17 +0,0 @@
#!/usr/bin/env bash
#
# Copyright (c) 2020-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
export LC_ALL=C.UTF-8
export HOST=i686-pc-linux-gnu
export CONTAINER_NAME=ci_i686_centos
export CI_IMAGE_NAME_TAG="quay.io/centos/amd64:stream9"
export STREAM_GCC_V="12"
export CI_BASE_PACKAGES="gcc-toolset-${STREAM_GCC_V}-gcc-c++ glibc-devel.x86_64 gcc-toolset-${STREAM_GCC_V}-libstdc++-devel.x86_64 glibc-devel.i686 gcc-toolset-${STREAM_GCC_V}-libstdc++-devel.i686 ccache make git python3 python3-pip which patch lbzip2 xz procps-ng dash rsync coreutils bison e2fsprogs cmake"
export PIP_PACKAGES="pyzmq"
export GOAL="install"
export BITCOIN_CONFIG="-DWITH_ZMQ=ON -DBUILD_GUI=ON -DREDUCE_EXPORTS=ON"
export CONFIG_SHELL="/bin/dash"

View file

@ -8,7 +8,8 @@ export LC_ALL=C.UTF-8
export HOST=i686-pc-linux-gnu
export CONTAINER_NAME=ci_i686_multiprocess
export CI_IMAGE_NAME_TAG="docker.io/amd64/ubuntu:24.04"
export CI_IMAGE_NAME_TAG="docker.io/ubuntu:24.04"
export CI_IMAGE_PLATFORM="linux/amd64"
export PACKAGES="llvm clang g++-multilib"
export DEP_OPTS="DEBUG=1 MULTIPROCESS=1"
export GOAL="install"

View file

@ -0,0 +1,15 @@
#!/usr/bin/env bash
#
# Copyright (c) 2020-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
export LC_ALL=C.UTF-8
export CONTAINER_NAME=ci_native_centos
export CI_IMAGE_NAME_TAG="quay.io/centos/centos:stream10"
export CI_BASE_PACKAGES="gcc-c++ glibc-devel libstdc++-devel ccache make git python3 python3-pip which patch xz procps-ng ksh rsync coreutils bison e2fsprogs cmake"
export PIP_PACKAGES="pyzmq"
export DEP_OPTS="DEBUG=1" # Temporarily enable a DEBUG=1 build to check for GCC-bug-117966 regressions. This can be removed once the minimum GCC version is bumped to 12 in the previous releases task, see https://github.com/bitcoin/bitcoin/issues/31436#issuecomment-2530717875
export GOAL="install"
export BITCOIN_CONFIG="-DWITH_ZMQ=ON -DBUILD_GUI=ON -DREDUCE_EXPORTS=ON -DCMAKE_BUILD_TYPE=Debug"

View file

@ -27,4 +27,3 @@ export BITCOIN_CONFIG="\
-DAPPEND_CPPFLAGS='-U_FORTIFY_SOURCE' \
"
export USE_MEMORY_SANITIZER="true"
export RUN_FUNCTIONAL_TESTS="false"

View file

@ -9,7 +9,8 @@ export LC_ALL=C.UTF-8
export HOST=s390x-linux-gnu
export PACKAGES="python3-zmq"
export CONTAINER_NAME=ci_s390x
export CI_IMAGE_NAME_TAG="docker.io/s390x/ubuntu:24.04"
export CI_IMAGE_NAME_TAG="docker.io/ubuntu:24.04"
export CI_IMAGE_PLATFORM="linux/s390x"
export TEST_RUNNER_EXTRA="--exclude rpc_bind,feature_bind_extra" # Excluded for now, see https://github.com/bitcoin/bitcoin/issues/17765#issuecomment-602068547
export RUN_FUNCTIONAL_TESTS=true
export GOAL="install"

View file

@ -7,7 +7,8 @@
export LC_ALL=C.UTF-8
export CONTAINER_NAME=ci_win64
export CI_IMAGE_NAME_TAG="docker.io/amd64/debian:bookworm" # Check that https://packages.debian.org/bookworm/g++-mingw-w64-x86-64-posix (version 12.2, similar to guix) can cross-compile
export CI_IMAGE_NAME_TAG="docker.io/debian:bookworm" # Check that https://packages.debian.org/bookworm/g++-mingw-w64-x86-64-posix (version 12.2, similar to guix) can cross-compile
export CI_IMAGE_PLATFORM="linux/amd64"
export HOST=x86_64-w64-mingw32
export DPKG_ADD_ARCH="i386"
export PACKAGES="nsis g++-mingw-w64-x86-64-posix wine-binfmt wine64 wine32 file"

View file

@ -49,7 +49,7 @@ if [ -n "$PIP_PACKAGES" ]; then
fi
if [[ ${USE_MEMORY_SANITIZER} == "true" ]]; then
${CI_RETRY_EXE} git clone --depth=1 https://github.com/llvm/llvm-project -b "llvmorg-19.1.0" /msan/llvm-project
${CI_RETRY_EXE} git clone --depth=1 https://github.com/llvm/llvm-project -b "llvmorg-19.1.6" /msan/llvm-project
cmake -G Ninja -B /msan/clang_build/ \
-DLLVM_ENABLE_PROJECTS="clang" \
@ -74,6 +74,7 @@ if [[ ${USE_MEMORY_SANITIZER} == "true" ]]; then
-DLLVM_TARGETS_TO_BUILD=Native \
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \
-DLIBCXXABI_USE_LLVM_UNWINDER=OFF \
-DLIBCXX_ABI_DEFINES="_LIBCPP_ABI_BOUNDED_ITERATORS;_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY;_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING;_LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR;_LIBCPP_ABI_BOUNDED_UNIQUE_PTR" \
-DLIBCXX_HARDENING_MODE=debug \
-S /msan/llvm-project/runtimes

View file

@ -14,7 +14,7 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
# Though, exclude those with newlines to avoid parsing problems.
python3 -c 'import os; [print(f"{key}={value}") for key, value in os.environ.items() if "\n" not in value and "HOME" != key and "PATH" != key and "USER" != key]' | tee "/tmp/env-$USER-$CONTAINER_NAME"
# System-dependent env vars must be kept as is. So read them from the container.
docker run --rm "${CI_IMAGE_NAME_TAG}" bash -c "env | grep --extended-regexp '^(HOME|PATH|USER)='" | tee --append "/tmp/env-$USER-$CONTAINER_NAME"
docker run --platform="${CI_IMAGE_PLATFORM}" --rm "${CI_IMAGE_NAME_TAG}" bash -c "env | grep --extended-regexp '^(HOME|PATH|USER)='" | tee --append "/tmp/env-$USER-$CONTAINER_NAME"
# Env vars during the build can not be changed. For example, a modified
# $MAKEJOBS is ignored in the build process. Use --cpuset-cpus as an
@ -25,16 +25,50 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
fi
echo "Creating $CI_IMAGE_NAME_TAG container to run in"
DOCKER_BUILD_CACHE_ARG=""
DOCKER_BUILD_CACHE_TEMPDIR=""
DOCKER_BUILD_CACHE_OLD_DIR=""
DOCKER_BUILD_CACHE_NEW_DIR=""
# If set, use an `docker build` cache directory on the CI host
# to cache docker image layers for the CI container image.
# This cache can be multiple GB in size. Prefixed with DANGER
# as setting it removes (old cache) files from the host.
if [ "$DANGER_DOCKER_BUILD_CACHE_HOST_DIR" ]; then
# Directory where the current cache for this run could be. If not existing
# or empty, "docker build" will warn, but treat it as cache-miss and continue.
DOCKER_BUILD_CACHE_OLD_DIR="${DANGER_DOCKER_BUILD_CACHE_HOST_DIR}/${CONTAINER_NAME}"
# Temporary directory for a newly created cache. We can't write the new
# cache into OLD_DIR directly, as old cache layers would not be removed.
# The NEW_DIR contents are moved to OLD_DIR after OLD_DIR has been cleared.
# This happens after `docker build`. If a task fails or is aborted, the
# DOCKER_BUILD_CACHE_TEMPDIR might be retained on the host. If the host isn't
# ephemeral, it has to take care of cleaning old TEMPDIR's up.
DOCKER_BUILD_CACHE_TEMPDIR="$(mktemp --directory ci-docker-build-cache-XXXXXXXXXX)"
DOCKER_BUILD_CACHE_NEW_DIR="${DOCKER_BUILD_CACHE_TEMPDIR}/${CONTAINER_NAME}"
DOCKER_BUILD_CACHE_ARG="--cache-from type=local,src=${DOCKER_BUILD_CACHE_OLD_DIR} --cache-to type=local,dest=${DOCKER_BUILD_CACHE_NEW_DIR},mode=max"
fi
# shellcheck disable=SC2086
DOCKER_BUILDKIT=1 docker build \
--file "${BASE_READ_ONLY_DIR}/ci/test_imagefile" \
--build-arg "CI_IMAGE_NAME_TAG=${CI_IMAGE_NAME_TAG}" \
--build-arg "FILE_ENV=${FILE_ENV}" \
$MAYBE_CPUSET \
--platform="${CI_IMAGE_PLATFORM}" \
--label="${CI_IMAGE_LABEL}" \
--tag="${CONTAINER_NAME}" \
$DOCKER_BUILD_CACHE_ARG \
"${BASE_READ_ONLY_DIR}"
if [ "$DANGER_DOCKER_BUILD_CACHE_HOST_DIR" ]; then
if [ -e "${DOCKER_BUILD_CACHE_NEW_DIR}/index.json" ]; then
echo "Removing the existing docker build cache in ${DOCKER_BUILD_CACHE_OLD_DIR}"
rm -rf "${DOCKER_BUILD_CACHE_OLD_DIR}"
echo "Moving the contents of ${DOCKER_BUILD_CACHE_NEW_DIR} to ${DOCKER_BUILD_CACHE_OLD_DIR}"
mv "${DOCKER_BUILD_CACHE_NEW_DIR}" "${DOCKER_BUILD_CACHE_OLD_DIR}"
fi
fi
docker volume create "${CONTAINER_NAME}_ccache" || true
docker volume create "${CONTAINER_NAME}_depends" || true
docker volume create "${CONTAINER_NAME}_depends_sources" || true
@ -44,18 +78,21 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
CI_DEPENDS_MOUNT="type=volume,src=${CONTAINER_NAME}_depends,dst=$DEPENDS_DIR/built"
CI_DEPENDS_SOURCES_MOUNT="type=volume,src=${CONTAINER_NAME}_depends_sources,dst=$DEPENDS_DIR/sources"
CI_PREVIOUS_RELEASES_MOUNT="type=volume,src=${CONTAINER_NAME}_previous_releases,dst=$PREVIOUS_RELEASES_DIR"
CI_BUILD_MOUNT=""
if [ "$DANGER_CI_ON_HOST_CACHE_FOLDERS" ]; then
if [ "$DANGER_CI_ON_HOST_FOLDERS" ]; then
# ensure the directories exist
mkdir -p "${CCACHE_DIR}"
mkdir -p "${DEPENDS_DIR}/built"
mkdir -p "${DEPENDS_DIR}/sources"
mkdir -p "${PREVIOUS_RELEASES_DIR}"
mkdir -p "${BASE_BUILD_DIR}" # Unset by default, must be defined externally
CI_CCACHE_MOUNT="type=bind,src=${CCACHE_DIR},dst=$CCACHE_DIR"
CI_DEPENDS_MOUNT="type=bind,src=${DEPENDS_DIR}/built,dst=$DEPENDS_DIR/built"
CI_DEPENDS_SOURCES_MOUNT="type=bind,src=${DEPENDS_DIR}/sources,dst=$DEPENDS_DIR/sources"
CI_PREVIOUS_RELEASES_MOUNT="type=bind,src=${PREVIOUS_RELEASES_DIR},dst=$PREVIOUS_RELEASES_DIR"
CI_BUILD_MOUNT="--mount type=bind,src=${BASE_BUILD_DIR},dst=${BASE_BUILD_DIR}"
fi
if [ "$DANGER_CI_ON_HOST_CCACHE_FOLDER" ]; then
@ -97,9 +134,11 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
--mount "${CI_DEPENDS_MOUNT}" \
--mount "${CI_DEPENDS_SOURCES_MOUNT}" \
--mount "${CI_PREVIOUS_RELEASES_MOUNT}" \
${CI_BUILD_MOUNT} \
--env-file /tmp/env-$USER-$CONTAINER_NAME \
--name "$CONTAINER_NAME" \
--network ci-ip6net \
--platform="${CI_IMAGE_PLATFORM}" \
"$CONTAINER_NAME")
export CI_CONTAINER_ID
export CI_EXEC_CMD_PREFIX="docker exec ${CI_CONTAINER_ID}"

View file

@ -92,9 +92,7 @@ fi
if [ -z "$NO_DEPENDS" ]; then
if [[ $CI_IMAGE_NAME_TAG == *centos* ]]; then
SHELL_OPTS="CONFIG_SHELL=/bin/dash"
# shellcheck disable=SC1090
source "/opt/rh/gcc-toolset-${STREAM_GCC_V}/enable"
SHELL_OPTS="CONFIG_SHELL=/bin/ksh" # Temporarily use ksh instead of dash, until https://bugzilla.redhat.com/show_bug.cgi?id=2335416 is fixed.
else
SHELL_OPTS="CONFIG_SHELL="
fi

View file

@ -60,7 +60,6 @@ target_compile_definitions(leveldb
HAVE_FULLFSYNC=$<BOOL:${HAVE_FULLFSYNC}>
HAVE_O_CLOEXEC=$<BOOL:${HAVE_O_CLOEXEC}>
FALLTHROUGH_INTENDED=[[fallthrough]]
LEVELDB_IS_BIG_ENDIAN=$<STREQUAL:${CMAKE_CXX_BYTE_ORDER},BIG_ENDIAN>
$<$<NOT:$<BOOL:${WIN32}>>:LEVELDB_PLATFORM_POSIX>
$<$<BOOL:${WIN32}>:LEVELDB_PLATFORM_WINDOWS>
$<$<BOOL:${WIN32}>:_UNICODE;UNICODE>

View file

@ -6,7 +6,7 @@ cmake_path(GET JSON_SOURCE_PATH STEM json_source_basename)
file(READ ${JSON_SOURCE_PATH} hex_content HEX)
string(REGEX REPLACE "................" "\\0\n" formatted_bytes "${hex_content}")
string(REGEX REPLACE "[^\n][^\n]" "0x\\0, " formatted_bytes "${formatted_bytes}")
string(REGEX REPLACE "[^\n][^\n]" "'\\\\x\\0'," formatted_bytes "${formatted_bytes}")
set(header_content
"#include <string_view>

View file

@ -6,7 +6,7 @@ cmake_path(GET RAW_SOURCE_PATH STEM raw_source_basename)
file(READ ${RAW_SOURCE_PATH} hex_content HEX)
string(REGEX REPLACE "................" "\\0\n" formatted_bytes "${hex_content}")
string(REGEX REPLACE "[^\n][^\n]" "std::byte{0x\\0}, " formatted_bytes "${formatted_bytes}")
string(REGEX REPLACE "[^\n][^\n]" "std::byte{0x\\0}," formatted_bytes "${formatted_bytes}")
set(header_content
"#include <cstddef>

View file

@ -5,7 +5,7 @@ Upstream-Contact: Satoshi Nakamoto <satoshin@gmx.com>
Source: https://github.com/bitcoin/bitcoin
Files: *
Copyright: 2009-2024, Bitcoin Core Developers
Copyright: 2009-2025, Bitcoin Core Developers
License: Expat
Comment: The Bitcoin Core Developers encompasses all contributors to the
project, listed in the release notes or the git log.

View file

@ -247,7 +247,7 @@ details.
* _**SDK_PATH**_
Set the path where _extracted_ SDKs can be found. This is passed through to
the depends tree. Note that this is should be set to the _parent_ directory of
the depends tree. Note that this should be set to the _parent_ directory of
the actual SDK (e.g. `SDK_PATH=$HOME/Downloads/macOS-SDKs` instead of
`$HOME/Downloads/macOS-SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers`).

View file

@ -451,7 +451,7 @@ inspecting signatures in Mach-O binaries.")
#t))))))))
(define-public glibc-2.31
(let ((commit "8e30f03744837a85e33d84ccd34ed3abe30d37c3"))
(let ((commit "7b27c450c34563a28e634cccb399cd415e71ebfe"))
(package
(inherit glibc) ;; 2.35
(version "2.31")
@ -463,7 +463,7 @@ inspecting signatures in Mach-O binaries.")
(file-name (git-file-name "glibc" commit))
(sha256
(base32
"1zi0s9yy5zkisw823vivn7zlj8w6g9p3mm7lmlqiixcxdkz4dbn6"))
"017qdpr5id7ddb4lpkzj2li1abvw916m3fc6n7nw28z4h5qbv2n0"))
(patches (search-our-patches "glibc-guix-prefix.patch"))))
(arguments
(substitute-keyword-arguments (package-arguments glibc)
@ -474,6 +474,8 @@ inspecting signatures in Mach-O binaries.")
"--enable-cet",
"--enable-bind-now",
"--disable-werror",
"--disable-timezone-tools",
"--disable-profile",
building-on)))
((#:phases phases)
`(modify-phases ,phases

View file

@ -155,7 +155,7 @@ $ python3 contrib/tracing/log_raw_p2p_msgs.py $(pidof bitcoind)
```
Logging raw P2P messages.
Messages larger that about 32kb will be cut off!
Messages larger than about 32kb will be cut off!
Some messages might be lost!
outbound msg 'inv' from peer 4 (outbound-full-relay, XX.XXX.XX.4:8333) with 253 bytes: 0705000000be2245c8f844c9f763748e1a7…

View file

@ -41,7 +41,8 @@ from bcc import BPF, USDT
program = """
#include <uapi/linux/ptrace.h>
#define MIN(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
// A min() macro. Prefixed with _TRACEPOINT_TEST to avoid collision with other MIN macros.
#define _TRACEPOINT_TEST_MIN(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
// Maximum possible allocation size
// from include/linux/percpu.h in the Linux kernel
@ -88,7 +89,7 @@ int trace_inbound_message(struct pt_regs *ctx) {
bpf_usdt_readarg_p(3, ctx, &msg->peer_conn_type, MAX_PEER_CONN_TYPE_LENGTH);
bpf_usdt_readarg_p(4, ctx, &msg->msg_type, MAX_MSG_TYPE_LENGTH);
bpf_usdt_readarg(5, ctx, &msg->msg_size);
bpf_usdt_readarg_p(6, ctx, &msg->msg, MIN(msg->msg_size, MAX_MSG_DATA_LENGTH));
bpf_usdt_readarg_p(6, ctx, &msg->msg, _TRACEPOINT_TEST_MIN(msg->msg_size, MAX_MSG_DATA_LENGTH));
inbound_messages.perf_submit(ctx, msg, sizeof(*msg));
return 0;
@ -108,7 +109,7 @@ int trace_outbound_message(struct pt_regs *ctx) {
bpf_usdt_readarg_p(3, ctx, &msg->peer_conn_type, MAX_PEER_CONN_TYPE_LENGTH);
bpf_usdt_readarg_p(4, ctx, &msg->msg_type, MAX_MSG_TYPE_LENGTH);
bpf_usdt_readarg(5, ctx, &msg->msg_size);
bpf_usdt_readarg_p(6, ctx, &msg->msg, MIN(msg->msg_size, MAX_MSG_DATA_LENGTH));
bpf_usdt_readarg_p(6, ctx, &msg->msg, _TRACEPOINT_TEST_MIN(msg->msg_size, MAX_MSG_DATA_LENGTH));
outbound_messages.perf_submit(ctx, msg, sizeof(*msg));
return 0;
@ -167,7 +168,7 @@ def main(pid):
bpf["outbound_messages"].open_perf_buffer(handle_outbound)
print("Logging raw P2P messages.")
print("Messages larger that about 32kb will be cut off!")
print("Messages larger than about 32kb will be cut off!")
print("Some messages might be lost!")
while True:
try:

View file

@ -141,8 +141,16 @@ include packages/packages.mk
# 2. Before including packages/*.mk (excluding packages/packages.mk), since
# they rely on the build_id variables
#
build_id:=$(shell env CC='$(build_CC)' C_STANDARD='$(C_STANDARD)' CXX='$(build_CXX)' CXX_STANDARD='$(CXX_STANDARD)' AR='$(build_AR) 'NM='$(build_NM)' RANLIB='$(build_RANLIB)' STRIP='$(build_STRIP)' SHA256SUM='$(build_SHA256SUM)' DEBUG='$(DEBUG)' LTO='$(LTO)' NO_HARDEN='$(NO_HARDEN)' ./gen_id '$(BUILD_ID_SALT)' 'GUIX_ENVIRONMENT=$(realpath $(GUIX_ENVIRONMENT))')
$(host_arch)_$(host_os)_id:=$(shell env CC='$(host_CC)' C_STANDARD='$(C_STANDARD)' CXX='$(host_CXX)' CXX_STANDARD='$(CXX_STANDARD)' AR='$(host_AR)' NM='$(host_NM)' RANLIB='$(host_RANLIB)' STRIP='$(host_STRIP)' SHA256SUM='$(build_SHA256SUM)' DEBUG='$(DEBUG)' LTO='$(LTO)' NO_HARDEN='$(NO_HARDEN)' ./gen_id '$(HOST_ID_SALT)' 'GUIX_ENVIRONMENT=$(realpath $(GUIX_ENVIRONMENT))')
build_id:=$(shell env CC='$(build_CC)' C_STANDARD='$(C_STANDARD)' CXX='$(build_CXX)' CXX_STANDARD='$(CXX_STANDARD)' \
AR='$(build_AR)' NM='$(build_NM)' RANLIB='$(build_RANLIB)' STRIP='$(build_STRIP)' SHA256SUM='$(build_SHA256SUM)' \
DEBUG='$(DEBUG)' NO_HARDEN='$(NO_HARDEN)' \
./gen_id '$(BUILD_ID_SALT)' 'GUIX_ENVIRONMENT=$(realpath $(GUIX_ENVIRONMENT))')
$(host_arch)_$(host_os)_id:=$(shell env CC='$(host_CC)' C_STANDARD='$(C_STANDARD)' CXX='$(host_CXX)' CXX_STANDARD='$(CXX_STANDARD)' \
CPPFLAGS='$(CPPFLAGS)' CFLAGS='$(CFLAGS)' CXXFLAGS='$(CXXFLAGS)' LDFLAGS='$(LDFLAGS)' \
AR='$(host_AR)' NM='$(host_NM)' RANLIB='$(host_RANLIB)' STRIP='$(host_STRIP)' SHA256SUM='$(build_SHA256SUM)' \
DEBUG='$(DEBUG)' LTO='$(LTO)' NO_HARDEN='$(NO_HARDEN)' \
./gen_id '$(HOST_ID_SALT)' 'GUIX_ENVIRONMENT=$(realpath $(GUIX_ENVIRONMENT))')
boost_packages_$(NO_BOOST) = $(boost_packages)

View file

@ -47,7 +47,7 @@ The paths are automatically configured and no other options are needed.
Skip the following packages if you don't intend to use the GUI and will build with [`NO_QT=1`](#dependency-options):
apt install bison g++ pkg-config python3 xz-utils
apt install bison g++ pkgconf python3 xz-utils
#### For macOS cross compilation

View file

@ -1,5 +1,5 @@
build_freebsd_CC=clang
build_freebsd_CXX=clang++
build_freebsd_SHA256SUM = shasum -a 256
build_freebsd_SHA256SUM = sha256sum
build_freebsd_DOWNLOAD = curl --location --fail --connect-timeout $(DOWNLOAD_CONNECT_TIMEOUT) --retry $(DOWNLOAD_RETRIES) -o

View file

@ -1,8 +1,9 @@
#!/usr/bin/env bash
# Usage: env [ CC=... ] [ C_STANDARD=...] [ CXX=... ] [CXX_STANDARD=...] \
# [ CPPFLAGS=... ] [CFLAGS=...] [CXXFLAGS=...] [LDFLAGS=...] \
# [ AR=... ] [ NM=... ] [ RANLIB=... ] [ STRIP=... ] [ DEBUG=... ] \
# [ LTO=... ] [ NO_HARDEN=... ] ./build-id [ID_SALT]...
# [ LTO=... ] [ NO_HARDEN=... ] ./gen_id [ID_SALT]...
#
# Prints to stdout a SHA256 hash representing the current toolset, used by
# depends/Makefile as a build id for caching purposes (detecting when the
@ -34,6 +35,13 @@
echo "$@"
echo "END ID SALT"
echo "BEGIN FLAGS"
echo "CPPFLAGS=${CPPFLAGS}"
echo "CFLAGS=${CFLAGS}"
echo "CXXFLAGS=${CXXFLAGS}"
echo "LDFLAGS=${LDFLAGS}"
echo "END FLAGS"
# GCC only prints COLLECT_LTO_WRAPPER when invoked with just "-v", but we want
# the information from "-v -E -" as well, so just include both.
echo "BEGIN CC"
@ -50,6 +58,17 @@
echo "CXX_STANDARD=${CXX_STANDARD}"
echo "END CXX"
# We use lld when cross-compiling for macOS, and it's version should
# be tied to LLVM. However someone compiling with GCC and -fuse-ld=lld
# would not see a cache bust if the LLVM toolchain was updated.
echo "BEGIN lld"
bash -c "ld.lld --version"
echo "END lld"
echo "BEGIN mold"
bash -c "mold --version"
echo "END mold"
echo "BEGIN AR"
bash -c "${AR} --version"
env | grep '^AR_'

View file

@ -72,7 +72,7 @@ endif
darwin_release_CFLAGS=-O2
darwin_release_CXXFLAGS=$(darwin_release_CFLAGS)
darwin_debug_CFLAGS=-O1 -g
darwin_debug_CFLAGS=-O0 -g
darwin_debug_CXXFLAGS=$(darwin_debug_CFLAGS)
darwin_cmake_system_name=Darwin

View file

@ -4,7 +4,7 @@ freebsd_CXXFLAGS=-pipe -std=$(CXX_STANDARD)
freebsd_release_CFLAGS=-O2
freebsd_release_CXXFLAGS=$(freebsd_release_CFLAGS)
freebsd_debug_CFLAGS=-O1 -g
freebsd_debug_CFLAGS=-O0 -g
freebsd_debug_CXXFLAGS=$(freebsd_debug_CFLAGS)
ifeq (86,$(findstring 86,$(build_arch)))

View file

@ -10,7 +10,7 @@ endif
linux_release_CFLAGS=-O2
linux_release_CXXFLAGS=$(linux_release_CFLAGS)
linux_debug_CFLAGS=-O1 -g
linux_debug_CFLAGS=-O0 -g
linux_debug_CXXFLAGS=$(linux_debug_CFLAGS)
# https://gcc.gnu.org/onlinedocs/libstdc++/manual/debug_mode.html

View file

@ -17,7 +17,7 @@ endif
mingw32_release_CFLAGS=-O2
mingw32_release_CXXFLAGS=$(mingw32_release_CFLAGS)
mingw32_debug_CFLAGS=-O1 -g
mingw32_debug_CFLAGS=-O0 -g
mingw32_debug_CXXFLAGS=$(mingw32_debug_CFLAGS)
mingw32_debug_CPPFLAGS=-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC

View file

@ -10,7 +10,7 @@ endif
netbsd_release_CFLAGS=-O2
netbsd_release_CXXFLAGS=$(netbsd_release_CFLAGS)
netbsd_debug_CFLAGS=-O1 -g
netbsd_debug_CFLAGS=-O0 -g
netbsd_debug_CXXFLAGS=$(netbsd_debug_CFLAGS)
ifeq (86,$(findstring 86,$(build_arch)))

View file

@ -4,7 +4,7 @@ openbsd_CXXFLAGS=-pipe -std=$(CXX_STANDARD)
openbsd_release_CFLAGS=-O2
openbsd_release_CXXFLAGS=$(openbsd_release_CFLAGS)
openbsd_debug_CFLAGS=-O1 -g
openbsd_debug_CFLAGS=-O0 -g
openbsd_debug_CXXFLAGS=$(openbsd_debug_CFLAGS)
ifeq (86,$(findstring 86,$(build_arch)))

View file

@ -10,9 +10,10 @@ $(package)_build_subdir=build
# version as we do in releases. Due to quirks in libevents build system, this
# is also required to enable support for ipv6. See #19375.
define $(package)_set_vars
$(package)_config_opts=-DEVENT__DISABLE_BENCHMARK=ON -DEVENT__DISABLE_OPENSSL=ON
$(package)_config_opts=-DCMAKE_BUILD_TYPE=None -DEVENT__DISABLE_BENCHMARK=ON -DEVENT__DISABLE_OPENSSL=ON
$(package)_config_opts+=-DEVENT__DISABLE_SAMPLES=ON -DEVENT__DISABLE_REGRESS=ON
$(package)_config_opts+=-DEVENT__DISABLE_TESTS=ON -DEVENT__LIBRARY_TYPE=STATIC
$(package)_cflags += -ffile-prefix-map=$($(package)_extract_dir)=/usr
$(package)_cppflags += -D_GNU_SOURCE
$(package)_cppflags_mingw32=-D_WIN32_WINNT=0x0A00

View file

@ -1,9 +1,9 @@
package=native_capnp
$(package)_version=1.0.2
$(package)_version=1.1.0
$(package)_download_path=https://capnproto.org/
$(package)_download_file=capnproto-c++-$($(package)_version).tar.gz
$(package)_file_name=capnproto-cxx-$($(package)_version).tar.gz
$(package)_sha256_hash=9057dbc0223366b74bbeca33a05de164a229b0377927f1b7ef3828cdd8cb1d7e
$(package)_sha256_hash=07167580e563f5e821e3b2af1c238c16ec7181612650c5901330fa9a0da50939
define $(package)_set_vars
$(package)_config_opts := -DBUILD_TESTING=OFF

View file

@ -1,8 +1,8 @@
package=native_libmultiprocess
$(package)_version=abe254b9734f2e2b220d1456de195532d6e6ac1e
$(package)_version=07c917f7ca910d66abc6d3873162fc9061704074
$(package)_download_path=https://github.com/chaincodelabs/libmultiprocess/archive
$(package)_file_name=$($(package)_version).tar.gz
$(package)_sha256_hash=85777073259fdc75d24ac5777a19991ec1156c5f12db50b252b861c95dcb4f46
$(package)_sha256_hash=ac9db311e3b22aac3c7b7b7b3f6b7fee5cf3043ebb3c3bf412049e8b17166de8
$(package)_dependencies=native_capnp
define $(package)_config_cmds

View file

@ -1,9 +1,9 @@
package=qt
$(package)_version=5.15.14
$(package)_version=5.15.16
$(package)_download_path=https://download.qt.io/official_releases/qt/5.15/$($(package)_version)/submodules
$(package)_suffix=everywhere-opensource-src-$($(package)_version).tar.xz
$(package)_file_name=qtbase-$($(package)_suffix)
$(package)_sha256_hash=500d3b390048e9538c28b5f523dfea6936f9c2e10d24ab46580ff57d430b98be
$(package)_sha256_hash=b04815058c18058b6ba837206756a2c87d1391f07a0dcb0dd314f970fd041592
$(package)_linux_dependencies=freetype fontconfig libxcb libxkbcommon libxcb_util libxcb_util_render libxcb_util_keysyms libxcb_util_image libxcb_util_wm
$(package)_qt_libs=corelib network widgets gui plugins testlib
$(package)_linguist_tools = lrelease lupdate lconvert
@ -17,19 +17,18 @@ $(package)_patches += no_warnings_for_symbols.patch
$(package)_patches += rcc_hardcode_timestamp.patch
$(package)_patches += duplicate_lcqpafonts.patch
$(package)_patches += guix_cross_lib_path.patch
$(package)_patches += fix-macos-linker.patch
$(package)_patches += memory_resource.patch
$(package)_patches += normalize_round.patch
$(package)_patches += clang_18_libpng.patch
$(package)_patches += utc_from_string_no_optimize.patch
$(package)_patches += windows_lto.patch
$(package)_patches += darwin_no_libm.patch
$(package)_patches += zlib-timebits64.patch
$(package)_qttranslations_file_name=qttranslations-$($(package)_suffix)
$(package)_qttranslations_sha256_hash=5b94d1a11b566908622fcca2f8b799744d2f8a68da20be4caa5953ed63b10489
$(package)_qttranslations_sha256_hash=415dbbb82a75dfc9a7be969e743bee54c0e6867be37bce4cf8f03da39f20112a
$(package)_qttools_file_name=qttools-$($(package)_suffix)
$(package)_qttools_sha256_hash=12061a85baf5f4de8fbc795e1d3872b706f340211b9e70962caeffc6f5e89563
$(package)_qttools_sha256_hash=1cab11887faca54af59f4995ee435c9ad98d194e9e6889c846692c8b6815fc1c
$(package)_extra_sources = $($(package)_qttranslations_file_name)
$(package)_extra_sources += $($(package)_qttools_file_name)
@ -223,10 +222,10 @@ endef
define $(package)_preprocess_cmds
cp $($(package)_patch_dir)/qt.pro qt.pro && \
cp $($(package)_patch_dir)/qttools_src.pro qttools/src/src.pro && \
patch -p1 -i $($(package)_patch_dir)/fix-macos-linker.patch && \
patch -p1 -i $($(package)_patch_dir)/dont_hardcode_pwd.patch && \
patch -p1 -i $($(package)_patch_dir)/no-xlib.patch && \
patch -p1 -i $($(package)_patch_dir)/qtbase-moc-ignore-gcc-macro.patch && \
patch -p1 -i $($(package)_patch_dir)/normalize_round.patch && \
patch -p1 -i $($(package)_patch_dir)/memory_resource.patch && \
patch -p1 -i $($(package)_patch_dir)/no_warnings_for_symbols.patch && \
patch -p1 -i $($(package)_patch_dir)/clang_18_libpng.patch && \
@ -236,7 +235,6 @@ define $(package)_preprocess_cmds
patch -p1 -i $($(package)_patch_dir)/guix_cross_lib_path.patch && \
patch -p1 -i $($(package)_patch_dir)/windows_lto.patch && \
patch -p1 -i $($(package)_patch_dir)/darwin_no_libm.patch && \
patch -p1 -i $($(package)_patch_dir)/zlib-timebits64.patch && \
mkdir -p qtbase/mkspecs/macx-clang-linux &&\
cp -f qtbase/mkspecs/macx-clang/qplatformdefs.h qtbase/mkspecs/macx-clang-linux/ &&\
cp -f $($(package)_patch_dir)/mac-qmake.conf qtbase/mkspecs/macx-clang-linux/qmake.conf && \

View file

@ -1,55 +0,0 @@
qmake: Don't error out if QMAKE_DEFAULT_LIBDIRS is empty on macOS
The new linker in Xcode 15 doesn't provide any default linker or
framework paths when requested via -v, but still seems to use the
default paths documented in the ld man page.
We trust that linker will do the right thing, even if we don't
know of its default linker paths.
We also need to opt out of the default fallback logic to
set the libdirs to /lib and /usr/lib.
This may result in UnixMakefileGenerator::findLibraries finding
different libraries than expected, if additional paths are
passed with -L, which will then take precedence for qmake,
even if the linker itself will use the library from the
SDK's default paths. This should hopefully not be an issue
in practice, as we don't turn -lFoo into absolute paths in
qmake, so the only risk is that we're picking up the wrong
prl files and adding additional dependencies that the lib
in the SDK doesn't have.
Upstream commits:
- Qt 5.15.16: Not yet publicly available.
- Qt dev: cdf64b0e47115cc473e1afd1472b4b09e130b2a5
For other Qt branches see
https://codereview.qt-project.org/q/I2347b26e2df0828471373b0e15b8c9089274c65d
--- old/qtbase/mkspecs/features/toolchain.prf
+++ new/qtbase/mkspecs/features/toolchain.prf
@@ -288,9 +288,12 @@ isEmpty($${target_prefix}.INCDIRS) {
}
}
}
- isEmpty(QMAKE_DEFAULT_LIBDIRS)|isEmpty(QMAKE_DEFAULT_INCDIRS): \
+ isEmpty(QMAKE_DEFAULT_INCDIRS): \
!integrity: \
- error("failed to parse default search paths from compiler output")
+ error("failed to parse default include paths from compiler output")
+ isEmpty(QMAKE_DEFAULT_LIBDIRS): \
+ !integrity:!darwin: \
+ error("failed to parse default library paths from compiler output")
QMAKE_DEFAULT_LIBDIRS = $$unique(QMAKE_DEFAULT_LIBDIRS)
} else: ghs {
cmd = $$QMAKE_CXX $$QMAKE_CXXFLAGS -$${LITERAL_HASH} -o /tmp/fake_output /tmp/fake_input.cpp
@@ -412,7 +415,7 @@ isEmpty($${target_prefix}.INCDIRS) {
QMAKE_DEFAULT_INCDIRS = $$split(INCLUDE, $$QMAKE_DIRLIST_SEP)
}
- unix:if(!cross_compile|host_build) {
+ unix:!darwin:if(!cross_compile|host_build) {
isEmpty(QMAKE_DEFAULT_INCDIRS): QMAKE_DEFAULT_INCDIRS = /usr/include /usr/local/include
isEmpty(QMAKE_DEFAULT_LIBDIRS): QMAKE_DEFAULT_LIBDIRS = /lib /usr/lib
}

View file

@ -14,36 +14,3 @@ and https://bugreports.qt.io/browse/QTBUG-114316
# include <unordered_set>
# include <memory_resource>
#else
--- a/qtbase/src/corelib/global/qcompilerdetection.h
+++ b/qtbase/src/corelib/global/qcompilerdetection.h
@@ -1055,16 +1055,22 @@
# endif // !_HAS_CONSTEXPR
# endif // !__GLIBCXX__ && !_LIBCPP_VERSION
# endif // Q_OS_QNX
-# if (defined(Q_CC_CLANG) || defined(Q_CC_INTEL)) && defined(Q_OS_MAC) && defined(__GNUC_LIBSTD__) \
- && ((__GNUC_LIBSTD__-0) * 100 + __GNUC_LIBSTD_MINOR__-0 <= 402)
+# if (defined(Q_CC_CLANG) || defined(Q_CC_INTEL)) && defined(Q_OS_MAC)
+# if defined(__GNUC_LIBSTD__) && ((__GNUC_LIBSTD__-0) * 100 + __GNUC_LIBSTD_MINOR__-0 <= 402)
// Apple has not updated libstdc++ since 2007, which means it does not have
// <initializer_list> or std::move. Let's disable these features
-# undef Q_COMPILER_INITIALIZER_LISTS
-# undef Q_COMPILER_RVALUE_REFS
-# undef Q_COMPILER_REF_QUALIFIERS
+# undef Q_COMPILER_INITIALIZER_LISTS
+# undef Q_COMPILER_RVALUE_REFS
+# undef Q_COMPILER_REF_QUALIFIERS
// Also disable <atomic>, since it's clearly not there
-# undef Q_COMPILER_ATOMICS
-# endif
+# undef Q_COMPILER_ATOMICS
+# endif
+# if defined(__cpp_lib_memory_resource) \
+ && ((defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 140000) \
+ || (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 170000))
+# undef __cpp_lib_memory_resource // Only supported on macOS 14 and iOS 17
+# endif
+# endif // (defined(Q_CC_CLANG) || defined(Q_CC_INTEL)) && defined(Q_OS_MAC)
# if defined(Q_CC_CLANG) && defined(Q_CC_INTEL) && Q_CC_INTEL >= 1500
// ICC 15.x and 16.0 have their own implementation of std::atomic, which is activated when in Clang mode
// (probably because libc++'s <atomic> on OS X failed to compile), but they're missing some

View file

@ -0,0 +1,100 @@
Taken from https://github.com/qt/qtbase/commit/8c8b9a4173f4add522ec13de85107deba7c82da0.
Unclean cherry-pick with the restoration of Q_DECL_CONSTEXPR.
Can be dropped with Qt 6.0.
Normalize rounding
Change the rounding of negative half values to match standard C++
round, this will also allow future optimizations.
Change-Id: I8f8c71bed1f05891e82ea787c6bc284297de9c5c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 5ad82c259de..b64f772fe3f 100644
--- a/qtbase/src/corelib/global/qglobal.cpp
+++ b/qtbase/src/corelib/global/qglobal.cpp
@@ -994,7 +994,7 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
Rounds \a d to the nearest integer.
- Rounds half up (e.g. 0.5 -> 1, -0.5 -> 0).
+ Rounds half away from zero (e.g. 0.5 -> 1, -0.5 -> -1).
Example:
@@ -1006,7 +1006,7 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
Rounds \a d to the nearest integer.
- Rounds half up (e.g. 0.5f -> 1, -0.5f -> 0).
+ Rounds half away from zero (e.g. 0.5f -> 1, -0.5f -> -1).
Example:
@@ -1018,7 +1018,7 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
Rounds \a d to the nearest 64-bit integer.
- Rounds half up (e.g. 0.5 -> 1, -0.5 -> 0).
+ Rounds half away from zero (e.g. 0.5 -> 1, -0.5 -> -1).
Example:
@@ -1030,7 +1030,7 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
Rounds \a d to the nearest 64-bit integer.
- Rounds half up (e.g. 0.5f -> 1, -0.5f -> 0).
+ Rounds half away from zero (e.g. 0.5f -> 1, -0.5f -> -1).
Example:
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index ff7167d9cc9..44b71760d25 100644
--- a/qtbase/src/corelib/global/qglobal.h
+++ b/qtbase/src/corelib/global/qglobal.h
@@ -660,14 +660,14 @@ template <typename T>
Q_DECL_CONSTEXPR inline T qAbs(const T &t) { return t >= 0 ? t : -t; }
Q_DECL_CONSTEXPR inline int qRound(double d)
-{ return d >= 0.0 ? int(d + 0.5) : int(d - double(int(d-1)) + 0.5) + int(d-1); }
+{ return d >= 0.0 ? int(d + 0.5) : int(d - 0.5); }
Q_DECL_CONSTEXPR inline int qRound(float d)
-{ return d >= 0.0f ? int(d + 0.5f) : int(d - float(int(d-1)) + 0.5f) + int(d-1); }
+{ return d >= 0.0f ? int(d + 0.5f) : int(d - 0.5f); }
Q_DECL_CONSTEXPR inline qint64 qRound64(double d)
-{ return d >= 0.0 ? qint64(d + 0.5) : qint64(d - double(qint64(d-1)) + 0.5) + qint64(d-1); }
+{ return d >= 0.0 ? qint64(d + 0.5) : qint64(d - 0.5); }
Q_DECL_CONSTEXPR inline qint64 qRound64(float d)
-{ return d >= 0.0f ? qint64(d + 0.5f) : qint64(d - float(qint64(d-1)) + 0.5f) + qint64(d-1); }
+{ return d >= 0.0f ? qint64(d + 0.5f) : qint64(d - 0.5f); }
template <typename T>
constexpr inline const T &qMin(const T &a, const T &b) { return (a < b) ? a : b; }
diff --git a/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp b/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp
index e78a8e30823..ef08352dfc8 100644
--- a/qtbase/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp
+++ b/qtbase/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp
@@ -381,7 +381,7 @@ void tst_QPointF::toPoint_data()
QTest::newRow("(0.0, 0.0) ==> (0, 0)") << QPointF(0, 0) << QPoint(0, 0);
QTest::newRow("(0.5, 0.5) ==> (1, 1)") << QPointF(0.5, 0.5) << QPoint(1, 1);
- QTest::newRow("(-0.5, -0.5) ==> (0, 0)") << QPointF(-0.5, -0.5) << QPoint(0, 0);
+ QTest::newRow("(-0.5, -0.5) ==> (-1, -1)") << QPointF(-0.5, -0.5) << QPoint(-1, -1);
}
void tst_QPointF::toPoint()
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
index f1efeebd91e..83154aa8b74 100644
--- a/qtbase/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
+++ b/qtbase/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
@@ -4893,6 +4893,7 @@ public:
{
setFlag(QGraphicsItem::ItemIsFocusable, true);
setFlag(QGraphicsItem::ItemAcceptsInputMethod, true);
+ setPen(Qt::NoPen); // Avoid adding a half pixel border to the rect.
}
QVariant inputMethodQuery(Qt::InputMethodQuery) const

View file

@ -1,31 +0,0 @@
From a566e156b3fa07b566ddbf6801b517a9dba04fa3 Mon Sep 17 00:00:00 2001
From: Mark Adler <madler@alumni.caltech.edu>
Date: Sat, 29 Jul 2023 22:13:09 -0700
Subject: [PATCH] Avoid compiler complaints if _TIME_BITS defined when building
zlib.
zlib does not use time_t, so _TIME_BITS is irrelevant. However it
may be defined anyway as part of a sledgehammer indiscriminately
applied to all builds.
From https://github.com/madler/zlib/commit/a566e156b3fa07b566ddbf6801b517a9dba04fa3.patch
---
qtbase/src/3rdparty/zlib/src/gzguts.h | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/qtbase/src/3rdparty/zlib/src/gzguts.h b/qtbase/src/3rdparty/zlib/src/gzguts.h
index e23f831f5..f9375047e 100644
--- a/qtbase/src/3rdparty/zlib/src/gzguts.h
+++ b/qtbase/src/3rdparty/zlib/src/gzguts.h
@@ -26,9 +26,8 @@
# ifndef _LARGEFILE_SOURCE
# define _LARGEFILE_SOURCE 1
# endif
-# ifdef _FILE_OFFSET_BITS
-# undef _FILE_OFFSET_BITS
-# endif
+# undef _FILE_OFFSET_BITS
+# undef _TIME_BITS
#endif
#ifdef HAVE_HIDDEN

View file

@ -47,12 +47,29 @@ or using a regex filter to only run certain benchmarks.
Notes
---------------------
More benchmarks are needed for, in no particular order:
- Script Validation
- Coins database
- Memory pool
- Cuckoo Cache
- P2P throughput
Benchmarks help with monitoring for performance regressions and can act as a
scope for future performance improvements. They should cover components that
impact performance critical functions of the system. Functions are performance
critical if their performance impacts users and the cost associated with a
degradation in performance is high. A non-exhaustive list:
- Initial block download (Cost: slow IBD results in full node operation being
less accessible)
- Block template creation (Cost: slow block template creation may result in
lower fee revenue for miners)
- Block propagation (Cost: slow block propagation may increase the rate of
orphaned blocks and mining centralization)
A change aiming to improve the performance may be rejected when a clear
end-to-end performance improvement cannot be demonstrated. The change might
also be rejected if the code bloat or review/maintenance burden is too high to
justify the improvement.
Benchmarks are ill-suited for testing denial-of-service issues as they are
restricted to the same input set (introducing bias). [Fuzz
tests](/doc/fuzzing.md) are better suited for this purpose, as they are
specifically aimed at exploring the possible input space.
Going Further
--------------------

View file

@ -96,7 +96,7 @@ There is an included test suite that is useful for testing code changes when dev
To run the test suite (recommended), you will need to have Python 3 installed:
```bash
pkg install python3 databases/py-sqlite3
pkg install python3 databases/py-sqlite3 net/py-pyzmq
```
---

View file

@ -1,6 +1,6 @@
# NetBSD Build Guide
**Updated for NetBSD [10.0](https://netbsd.org/releases/formal-10/NetBSD-10.0.html)**
**Updated for NetBSD [10.1](https://netbsd.org/releases/formal-10/NetBSD-10.1.html)**
This guide describes how to build bitcoind, command-line utilities, and GUI on NetBSD.
@ -83,6 +83,13 @@ pkgin install qrencode
Otherwise, if you don't need QR encoding support, use the `-DWITH_QRENCODE=OFF` option to disable this feature in order to compile the GUI.
#### Notifications
###### ZeroMQ
Bitcoin Core can provide notifications via ZeroMQ. If the package is installed, support will be compiled in.
```bash
pkgin zeromq
```
#### Test Suite Dependencies
@ -90,10 +97,10 @@ There is an included test suite that is useful for testing code changes when dev
To run the test suite (recommended), you will need to have Python 3 installed:
```bash
pkgin install python39
pkgin install python310 py310-zmq
```
### Building Bitcoin Core
## Building Bitcoin Core
### 1. Configuration

View file

@ -1,6 +1,6 @@
# OpenBSD Build Guide
**Updated for OpenBSD [7.5](https://www.openbsd.org/75.html)**
**Updated for OpenBSD [7.6](https://www.openbsd.org/76.html)**
This guide describes how to build bitcoind, command-line utilities, and GUI on OpenBSD.
@ -90,7 +90,7 @@ There is an included test suite that is useful for testing code changes when dev
To run the test suite (recommended), you will need to have Python 3 installed:
```bash
pkg_add python # Select the newest version of the package.
pkg_add python py3-zmq # Select the newest version of the python package if necessary.
```
## Building Bitcoin Core

View file

@ -44,7 +44,7 @@ Finally, clang (often less resource hungry) can be used instead of gcc, which is
Build requirements:
sudo apt-get install build-essential cmake pkg-config python3
sudo apt-get install build-essential cmake pkgconf python3
Now, you can either build from self-compiled [depends](#dependencies) or install the required dependencies:

View file

@ -29,7 +29,7 @@ You can find installation instructions in the `build-*.md` file for your platfor
| [Fontconfig](../depends/packages/fontconfig.mk) | [link](https://www.freedesktop.org/wiki/Software/fontconfig/) | [2.12.6](https://github.com/bitcoin/bitcoin/pull/23495) | 2.6 | Yes |
| [FreeType](../depends/packages/freetype.mk) | [link](https://freetype.org) | [2.11.0](https://github.com/bitcoin/bitcoin/commit/01544dd78ccc0b0474571da854e27adef97137fb) | 2.3.0 | Yes |
| [qrencode](../depends/packages/qrencode.mk) | [link](https://fukuchi.org/works/qrencode/) | [4.1.1](https://github.com/bitcoin/bitcoin/pull/27312) | | No |
| [Qt](../depends/packages/qt.mk) | [link](https://download.qt.io/official_releases/qt/) | [5.15.14](https://github.com/bitcoin/bitcoin/pull/30198) | [5.11.3](https://github.com/bitcoin/bitcoin/pull/24132) | No |
| [Qt](../depends/packages/qt.mk) | [link](https://download.qt.io/official_releases/qt/) | [5.15.16](https://github.com/bitcoin/bitcoin/pull/30774) | [5.11.3](https://github.com/bitcoin/bitcoin/pull/24132) | No |
### Notifications
| Dependency | Releases | Version used | Minimum required | Runtime |

View file

@ -101,6 +101,18 @@ INFO: seed corpus: files: 991 min: 1b max: 1858b total: 288291b rss: 150Mb
```
## Using the MemorySanitizer (MSan)
MSan [requires](https://clang.llvm.org/docs/MemorySanitizer.html#handling-external-code)
that all linked code be instrumented. The exact steps to achieve this may vary
but involve compiling `clang` from source, using the built `clang` to compile
an instrumentalized libc++, then using it to build [Bitcoin Core dependencies
from source](../depends/README.md) and finally the Bitcoin Core fuzz binary
itself. One can use the MSan CI job as an example for how to perform these
steps.
Valgrind is an alternative to MSan that does not require building a custom libc++.
## Run without sanitizers for increased throughput
Fuzzing on a harness compiled with `-DSANITIZERS=address,fuzzer,undefined` is

View file

@ -45,7 +45,7 @@ The following rules are enforced for all packages:
- No more than MAX_REPLACEMENT_CANDIDATES transactions can be replaced, analogous to
regular [replacement rule](./mempool-replacements.md) 5).
- Replacements must pay more total total fees at the incremental relay fee (analogous to
- Replacements must pay more total fees at the incremental relay fee (analogous to
regular [replacement rules](./mempool-replacements.md) 3 and 4).
- Parent feerate must be lower than package feerate.

View file

@ -0,0 +1,2 @@
The RPC `testmempoolaccept` response now includes a "reject-details" field in some cases,
similar to the complete error messages returned by `sendrawtransaction` (#28121)

View file

@ -0,0 +1,9 @@
Updated RPCs
---
- `getmininginfo` now returns `nBits` and the current target in the `target` field. It also returns a `next` object which specifies the `height`, `nBits`, `difficulty`, and `target` for the next block.
- `getblock` and `getblockheader` now return the current target in the `target` field
- `getblockchaininfo` and `getchainstates` now return `nBits` and the current target in the `target` field
REST interface
---
- `GET /rest/block/<BLOCK-HASH>.json` and `GET /rest/headers/<BLOCK-HASH>.json` now return the current target in the `target` field

View file

@ -43,7 +43,7 @@ Compatibility
==============
Bitcoin Core is supported and tested on operating systems using the
Linux Kernel 3.17+, macOS 13.0+, and Windows 10 and newer. Bitcoin
Linux Kernel 3.17+, macOS 13+, and Windows 10+. Bitcoin
Core should also work on most other Unix-like systems but is not as
frequently tested on them. It is not recommended to use Bitcoin Core on
unsupported systems.

View file

@ -0,0 +1,107 @@
Bitcoin Core version 28.1 is now available from:
<https://bitcoincore.org/bin/bitcoin-core-28.1>
This release includes new features, various bug fixes and performance
improvements, as well as updated translations.
Please report bugs using the issue tracker at GitHub:
<https://github.com/bitcoin/bitcoin/issues>
To receive security and update notifications, please subscribe to:
<https://bitcoincore.org/en/list/announcements/join/>
How to Upgrade
==============
If you are running an older version, shut it down. Wait until it has completely
shut down (which might take a few minutes in some cases), then run the
installer (on Windows) or just copy over `/Applications/Bitcoin-Qt` (on macOS)
or `bitcoind`/`bitcoin-qt` (on Linux).
Upgrading directly from a version of Bitcoin Core that has reached its EOL is
possible, but it might take some time if the data directory needs to be migrated. Old
wallet versions of Bitcoin Core are generally supported.
Running Bitcoin Core binaries on macOS requires self signing.
```
cd /path/to/bitcoin-28.x/bin
xattr -d com.apple.quarantine bitcoin-cli bitcoin-qt bitcoin-tx bitcoin-util bitcoin-wallet bitcoind test_bitcoin
codesign -s - bitcoin-cli bitcoin-qt bitcoin-tx bitcoin-util bitcoin-wallet bitcoind test_bitcoin
```
Compatibility
==============
Bitcoin Core is supported and extensively tested on operating systems
using the Linux Kernel 3.17+, macOS 11.0+, and Windows 7 and newer. Bitcoin
Core should also work on most other UNIX-like systems but is not as
frequently tested on them. It is not recommended to use Bitcoin Core on
unsupported systems.
Notable changes
===============
### P2P
- When the `-port` configuration option is used, the default onion listening port will now
be derived to be that port + 1 instead of being set to a fixed value (8334 on mainnet).
This re-allows setups with multiple local nodes using different `-port` and not using `-bind`,
which would lead to a startup failure in v28.0 due to a port collision.
Note that a `HiddenServicePort` manually configured in `torrc` may need adjustment if used in
connection with the `-port` option.
For example, if you are using `-port=5555` with a non-standard value and not using `-bind=...=onion`,
previously Bitcoin Core would listen for incoming Tor connections on `127.0.0.1:8334`.
Now it would listen on `127.0.0.1:5556` (`-port` plus one). If you configured the hidden service manually
in torrc now you have to change it from `HiddenServicePort 8333 127.0.0.1:8334` to `HiddenServicePort 8333
127.0.0.1:5556`, or configure bitcoind with `-bind=127.0.0.1:8334=onion` to get the previous behavior.
(#31223)
- #30568 addrman: change internal id counting to int64_t
### Key
- #31166 key: clear out secret data in DecodeExtKey
### Build
- #31013 depends: For mingw cross compile use `-gcc-posix` to prevent library conflict
- #31502 depends: Fix CXXFLAGS on NetBSD
### Test
- #31016 test: add missing sync to feature_fee_estimation.py
- #31448 fuzz: add cstdlib to FuzzedDataProvider
- #31419 test: fix MIN macro redefinition
- #31563 rpc: Extend scope of validation mutex in generateblock
### Doc
- #31007 doc: add testnet4 section header for config file
### CI
- #30961 ci: add LLVM_SYMBOLIZER_PATH to Valgrind fuzz job
### Misc
- #31267 refactor: Drop deprecated space in `operator""_mst`
- #31431 util: use explicit cast in MultiIntBitSet::Fill()
Credits
=======
Thanks to everyone who directly contributed to this release:
- fanquake
- Hennadii Stepanov
- laanwj
- MarcoFalke
- Martin Zumsande
- Marnix
- Sebastian Falbesoner
As well as to everyone that helped with translations on
[Transifex](https://www.transifex.com/bitcoin/bitcoin/).

View file

@ -109,6 +109,7 @@ add_library(bitcoin_common STATIC EXCLUDE_FROM_ALL
addresstype.cpp
base58.cpp
bech32.cpp
chain.cpp
chainparams.cpp
chainparamsbase.cpp
coins.cpp
@ -142,6 +143,7 @@ add_library(bitcoin_common STATIC EXCLUDE_FROM_ALL
outputtype.cpp
policy/feerate.cpp
policy/policy.cpp
pow.cpp
protocol.cpp
psbt.cpp
rpc/external_signer.cpp
@ -200,7 +202,6 @@ add_library(bitcoin_node STATIC EXCLUDE_FROM_ALL
bip324.cpp
blockencodings.cpp
blockfilter.cpp
chain.cpp
consensus/tx_verify.cpp
dbwrapper.cpp
deploymentstatus.cpp
@ -262,7 +263,6 @@ add_library(bitcoin_node STATIC EXCLUDE_FROM_ALL
policy/rbf.cpp
policy/settings.cpp
policy/truc_policy.cpp
pow.cpp
rest.cpp
rpc/blockchain.cpp
rpc/fees.cpp

View file

@ -229,3 +229,7 @@ arith_uint256 UintToArith256(const uint256 &a)
b.pn[x] = ReadLE32(a.begin() + x*4);
return b;
}
// Explicit instantiations for base_uint<6144> (used in test/fuzz/muhash.cpp).
template base_uint<6144>& base_uint<6144>::operator*=(const base_uint<6144>& b);
template base_uint<6144>& base_uint<6144>::operator/=(const base_uint<6144>& b);

View file

@ -26,6 +26,7 @@ class base_uint
protected:
static_assert(BITS / 32 > 0 && BITS % 32 == 0, "Template parameter BITS must be a positive multiple of 32.");
static constexpr int WIDTH = BITS / 32;
/** Big integer represented with 32-bit digits, least-significant first. */
uint32_t pn[WIDTH];
public:

View file

@ -30,7 +30,7 @@ void BanMan::LoadBanlist()
{
LOCK(m_banned_mutex);
if (m_client_interface) m_client_interface->InitMessage(_("Loading banlist…").translated);
if (m_client_interface) m_client_interface->InitMessage(_("Loading banlist…"));
const auto start{SteadyClock::now()};
if (m_ban_db.Read(m_banned)) {

View file

@ -139,7 +139,7 @@ std::string EncodeBase58Check(Span<const unsigned char> input)
// add 4-byte hash check to the end
std::vector<unsigned char> vch(input.begin(), input.end());
uint256 hash = Hash(vch);
vch.insert(vch.end(), (unsigned char*)&hash, (unsigned char*)&hash + 4);
vch.insert(vch.end(), hash.data(), hash.data() + 4);
return EncodeBase58(vch);
}

View file

@ -44,7 +44,7 @@ add_executable(bench_bitcoin
pool.cpp
prevector.cpp
random.cpp
readblock.cpp
readwriteblock.cpp
rollingbloom.cpp
rpc_blockchain.cpp
rpc_mempool.cpp

View file

@ -20,19 +20,23 @@
#include <memory>
#include <vector>
using node::BlockAssembler;
static void AssembleBlock(benchmark::Bench& bench)
{
const auto test_setup = MakeNoLogFileContext<const TestingSetup>();
CScriptWitness witness;
witness.stack.push_back(WITNESS_STACK_ELEM_OP_TRUE);
BlockAssembler::Options options;
options.coinbase_output_script = P2WSH_OP_TRUE;
// Collect some loose transactions that spend the coinbases of our mined blocks
constexpr size_t NUM_BLOCKS{200};
std::array<CTransactionRef, NUM_BLOCKS - COINBASE_MATURITY + 1> txs;
for (size_t b{0}; b < NUM_BLOCKS; ++b) {
CMutableTransaction tx;
tx.vin.emplace_back(MineBlock(test_setup->m_node, P2WSH_OP_TRUE));
tx.vin.emplace_back(MineBlock(test_setup->m_node, options));
tx.vin.back().scriptWitness = witness;
tx.vout.emplace_back(1337, P2WSH_OP_TRUE);
if (NUM_BLOCKS - b >= COINBASE_MATURITY)
@ -48,7 +52,7 @@ static void AssembleBlock(benchmark::Bench& bench)
}
bench.run([&] {
PrepareBlock(test_setup->m_node, P2WSH_OP_TRUE);
PrepareBlock(test_setup->m_node, options);
});
}
static void BlockAssemblerAddPackageTxns(benchmark::Bench& bench)
@ -56,11 +60,12 @@ static void BlockAssemblerAddPackageTxns(benchmark::Bench& bench)
FastRandomContext det_rand{true};
auto testing_setup{MakeNoLogFileContext<TestChain100Setup>()};
testing_setup->PopulateMempool(det_rand, /*num_transactions=*/1000, /*submit=*/true);
node::BlockAssembler::Options assembler_options;
BlockAssembler::Options assembler_options;
assembler_options.test_block_validity = false;
assembler_options.coinbase_output_script = P2WSH_OP_TRUE;
bench.run([&] {
PrepareBlock(testing_setup->m_node, P2WSH_OP_TRUE, assembler_options);
PrepareBlock(testing_setup->m_node, assembler_options);
});
}

View file

@ -249,6 +249,19 @@ static void MuHashPrecompute(benchmark::Bench& bench)
});
}
static void MuHashFinalize(benchmark::Bench& bench)
{
FastRandomContext rng(true);
MuHash3072 acc{rng.randbytes(32)};
acc /= MuHash3072{rng.rand256()};
bench.run([&] {
uint256 out;
acc.Finalize(out);
acc /= MuHash3072{out};
});
}
BENCHMARK(BenchRIPEMD160, benchmark::PriorityLevel::HIGH);
BENCHMARK(SHA1, benchmark::PriorityLevel::HIGH);
BENCHMARK(SHA256_STANDARD, benchmark::PriorityLevel::HIGH);
@ -272,3 +285,4 @@ BENCHMARK(MuHash, benchmark::PriorityLevel::HIGH);
BENCHMARK(MuHashMul, benchmark::PriorityLevel::HIGH);
BENCHMARK(MuHashDiv, benchmark::PriorityLevel::HIGH);
BENCHMARK(MuHashPrecompute, benchmark::PriorityLevel::HIGH);
BENCHMARK(MuHashFinalize, benchmark::PriorityLevel::HIGH);

View file

@ -1,60 +0,0 @@
// Copyright (c) 2023 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <bench/bench.h>
#include <bench/data/block413567.raw.h>
#include <flatfile.h>
#include <node/blockstorage.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
#include <serialize.h>
#include <span.h>
#include <streams.h>
#include <test/util/setup_common.h>
#include <validation.h>
#include <cassert>
#include <cstdint>
#include <memory>
#include <vector>
static FlatFilePos WriteBlockToDisk(ChainstateManager& chainman)
{
DataStream stream{benchmark::data::block413567};
CBlock block;
stream >> TX_WITH_WITNESS(block);
return chainman.m_blockman.SaveBlockToDisk(block, 0);
}
static void ReadBlockFromDiskTest(benchmark::Bench& bench)
{
const auto testing_setup{MakeNoLogFileContext<const TestingSetup>(ChainType::MAIN)};
ChainstateManager& chainman{*testing_setup->m_node.chainman};
CBlock block;
const auto pos{WriteBlockToDisk(chainman)};
bench.run([&] {
const auto success{chainman.m_blockman.ReadBlockFromDisk(block, pos)};
assert(success);
});
}
static void ReadRawBlockFromDiskTest(benchmark::Bench& bench)
{
const auto testing_setup{MakeNoLogFileContext<const TestingSetup>(ChainType::MAIN)};
ChainstateManager& chainman{*testing_setup->m_node.chainman};
std::vector<uint8_t> block_data;
const auto pos{WriteBlockToDisk(chainman)};
bench.run([&] {
const auto success{chainman.m_blockman.ReadRawBlockFromDisk(block_data, pos)};
assert(success);
});
}
BENCHMARK(ReadBlockFromDiskTest, benchmark::PriorityLevel::HIGH);
BENCHMARK(ReadRawBlockFromDiskTest, benchmark::PriorityLevel::HIGH);

View file

@ -0,0 +1,68 @@
// Copyright (c) 2023 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <bench/bench.h>
#include <bench/data/block413567.raw.h>
#include <flatfile.h>
#include <node/blockstorage.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
#include <serialize.h>
#include <span.h>
#include <streams.h>
#include <test/util/setup_common.h>
#include <validation.h>
#include <cassert>
#include <cstdint>
#include <memory>
#include <vector>
static CBlock CreateTestBlock()
{
DataStream stream{benchmark::data::block413567};
CBlock block;
stream >> TX_WITH_WITNESS(block);
return block;
}
static void SaveBlockBench(benchmark::Bench& bench)
{
const auto testing_setup{MakeNoLogFileContext<const TestingSetup>(ChainType::MAIN)};
auto& blockman{testing_setup->m_node.chainman->m_blockman};
const CBlock block{CreateTestBlock()};
bench.run([&] {
const auto pos{blockman.WriteBlock(block, 413'567)};
assert(!pos.IsNull());
});
}
static void ReadBlockBench(benchmark::Bench& bench)
{
const auto testing_setup{MakeNoLogFileContext<const TestingSetup>(ChainType::MAIN)};
auto& blockman{testing_setup->m_node.chainman->m_blockman};
const auto pos{blockman.WriteBlock(CreateTestBlock(), 413'567)};
CBlock block;
bench.run([&] {
const auto success{blockman.ReadBlock(block, pos)};
assert(success);
});
}
static void ReadRawBlockBench(benchmark::Bench& bench)
{
const auto testing_setup{MakeNoLogFileContext<const TestingSetup>(ChainType::MAIN)};
auto& blockman{testing_setup->m_node.chainman->m_blockman};
const auto pos{blockman.WriteBlock(CreateTestBlock(), 413'567)};
std::vector<uint8_t> block_data;
blockman.ReadRawBlock(block_data, pos); // warmup
bench.run([&] {
const auto success{blockman.ReadRawBlock(block_data, pos)};
assert(success);
});
}
BENCHMARK(SaveBlockBench, benchmark::PriorityLevel::HIGH);
BENCHMARK(ReadBlockBench, benchmark::PriorityLevel::HIGH);
BENCHMARK(ReadRawBlockBench, benchmark::PriorityLevel::HIGH);

View file

@ -48,8 +48,9 @@ struct TestBlockAndIndex {
static void BlockToJsonVerbose(benchmark::Bench& bench)
{
TestBlockAndIndex data;
const uint256 pow_limit{data.testing_setup->m_node.chainman->GetParams().GetConsensus().powLimit};
bench.run([&] {
auto univalue = blockToJSON(data.testing_setup->m_node.chainman->m_blockman, data.block, data.blockindex, data.blockindex, TxVerbosity::SHOW_DETAILS_AND_PREVOUT);
auto univalue = blockToJSON(data.testing_setup->m_node.chainman->m_blockman, data.block, data.blockindex, data.blockindex, TxVerbosity::SHOW_DETAILS_AND_PREVOUT, pow_limit);
ankerl::nanobench::doNotOptimizeAway(univalue);
});
}
@ -59,7 +60,8 @@ BENCHMARK(BlockToJsonVerbose, benchmark::PriorityLevel::HIGH);
static void BlockToJsonVerboseWrite(benchmark::Bench& bench)
{
TestBlockAndIndex data;
auto univalue = blockToJSON(data.testing_setup->m_node.chainman->m_blockman, data.block, data.blockindex, data.blockindex, TxVerbosity::SHOW_DETAILS_AND_PREVOUT);
const uint256 pow_limit{data.testing_setup->m_node.chainman->GetParams().GetConsensus().powLimit};
auto univalue = blockToJSON(data.testing_setup->m_node.chainman->m_blockman, data.block, data.blockindex, data.blockindex, TxVerbosity::SHOW_DETAILS_AND_PREVOUT, pow_limit);
bench.run([&] {
auto str = univalue.write();
ankerl::nanobench::doNotOptimizeAway(str);

View file

@ -5,6 +5,7 @@
#include <bitcoin-build-config.h> // IWYU pragma: keep
#include <bench/bench.h>
#include <kernel/chain.h>
#include <interfaces/chain.h>
#include <node/context.h>
#include <test/util/mining.h>
@ -16,7 +17,7 @@
#include <optional>
#if defined(USE_BDB) && defined(USE_SQLITE) // only enable benchmark when bdb and sqlite are enabled
#if defined(USE_SQLITE) // only enable benchmark when sqlite is enabled
namespace wallet{
@ -32,41 +33,39 @@ static void WalletMigration(benchmark::Bench& bench)
int NUM_WATCH_ONLY_ADDR = 20;
// Setup legacy wallet
DatabaseOptions options;
options.use_unsafe_sync = true;
options.verify = false;
DatabaseStatus status;
bilingual_str error;
auto database = MakeWalletDatabase(fs::PathToString(test_setup->m_path_root / "legacy"), options, status, error);
uint64_t create_flags = 0;
auto wallet = TestLoadWallet(std::move(database), context, create_flags);
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(test_setup->m_node.chain.get(), "", CreateMockableWalletDatabase());
wallet->chainStateFlushed(ChainstateRole::NORMAL, CBlockLocator{});
LegacyDataSPKM* legacy_spkm = wallet->GetOrCreateLegacyDataSPKM();
// Add watch-only addresses
std::vector<CScript> scripts_watch_only;
for (int w = 0; w < NUM_WATCH_ONLY_ADDR; ++w) {
CKey key = GenerateRandomKey();
LOCK(wallet->cs_wallet);
const CScript& script = scripts_watch_only.emplace_back(GetScriptForDestination(GetDestinationForKey(key.GetPubKey(), OutputType::LEGACY)));
bool res = wallet->ImportScriptPubKeys(strprintf("watch_%d", w), {script},
/*have_solving_data=*/false, /*apply_label=*/true, /*timestamp=*/1);
assert(res);
const auto& dest = GetDestinationForKey(key.GetPubKey(), OutputType::LEGACY);
const CScript& script = scripts_watch_only.emplace_back(GetScriptForDestination(dest));
assert(legacy_spkm->LoadWatchOnly(script));
assert(wallet->SetAddressBook(dest, strprintf("watch_%d", w), /*purpose=*/std::nullopt));
}
// Generate transactions and local addresses
for (int j = 0; j < 400; ++j) {
for (int j = 0; j < 500; ++j) {
CKey key = GenerateRandomKey();
CPubKey pubkey = key.GetPubKey();
// Load key, scripts and create address book record
Assert(legacy_spkm->LoadKey(key, pubkey));
CTxDestination dest{PKHash(pubkey)};
Assert(wallet->SetAddressBook(dest, strprintf("legacy_%d", j), /*purpose=*/std::nullopt));
CMutableTransaction mtx;
mtx.vout.emplace_back(COIN, GetScriptForDestination(*Assert(wallet->GetNewDestination(OutputType::BECH32, strprintf("bench_%d", j)))));
mtx.vout.emplace_back(COIN, GetScriptForDestination(*Assert(wallet->GetNewDestination(OutputType::LEGACY, strprintf("legacy_%d", j)))));
mtx.vout.emplace_back(COIN, GetScriptForDestination(dest));
mtx.vout.emplace_back(COIN, scripts_watch_only.at(j % NUM_WATCH_ONLY_ADDR));
mtx.vin.resize(2);
wallet->AddToWallet(MakeTransactionRef(mtx), TxStateInactive{}, /*update_wtx=*/nullptr, /*fFlushOnClose=*/false, /*rescanning_old_block=*/true);
}
// Unload so the migration process loads it
TestUnloadWallet(std::move(wallet));
bench.epochs(/*numEpochs=*/1).run([&] {
util::Result<MigrationResult> res = MigrateLegacyToDescriptor(fs::PathToString(test_setup->m_path_root / "legacy"), "", context);
bench.epochs(/*numEpochs=*/1).run([&context, &wallet] {
util::Result<MigrationResult> res = MigrateLegacyToDescriptor(std::move(wallet), /*passphrase=*/"", context, /*was_loaded=*/false);
assert(res);
assert(res->wallet);
assert(res->watchonly_wallet);

View file

@ -19,9 +19,9 @@
#include <consensus/validation.h>
#include <core_io.h>
#include <kernel/caches.h>
#include <logging.h>
#include <node/blockstorage.h>
#include <node/caches.h>
#include <node/chainstate.h>
#include <random.h>
#include <script/sigcache.h>
@ -123,10 +123,7 @@ int main(int argc, char* argv[])
util::SignalInterrupt interrupt;
ChainstateManager chainman{interrupt, chainman_opts, blockman_opts};
node::CacheSizes cache_sizes;
cache_sizes.block_tree_db = 2 << 20;
cache_sizes.coins_db = 2 << 22;
cache_sizes.coins = (450 << 20) - (2 << 20) - (2 << 22);
kernel::CacheSizes cache_sizes{DEFAULT_KERNEL_CACHE};
node::ChainstateLoadOptions options;
auto [status, error] = node::LoadChainstate(chainman, cache_sizes, options);
if (status != node::ChainstateLoadStatus::SUCCESS) {

View file

@ -50,7 +50,7 @@ using util::ToString;
// just use a plain system_clock.
using CliClock = std::chrono::system_clock;
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
const TranslateFn G_TRANSLATION_FUN{nullptr};
static const char DEFAULT_RPCCONNECT[] = "127.0.0.1";
static const int DEFAULT_HTTP_CLIENT_TIMEOUT=900;

View file

@ -41,7 +41,7 @@ static bool fCreateBlank;
static std::map<std::string,UniValue> registers;
static const int CONTINUE_EXECUTION=-1;
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
const TranslateFn G_TRANSLATION_FUN{nullptr};
static void SetupBitcoinTxArgs(ArgsManager &argsman)
{

View file

@ -26,7 +26,7 @@
static const int CONTINUE_EXECUTION=-1;
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
const TranslateFn G_TRANSLATION_FUN{nullptr};
static void SetupBitcoinUtilArgs(ArgsManager &argsman)
{

View file

@ -26,7 +26,7 @@
using util::Join;
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
const TranslateFn G_TRANSLATION_FUN{nullptr};
static void SetupWalletToolArgs(ArgsManager& argsman)
{

View file

@ -34,7 +34,7 @@
using node::NodeContext;
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
const TranslateFn G_TRANSLATION_FUN{nullptr};
#if HAVE_DECL_FORK
@ -228,10 +228,10 @@ static bool AppInit(NodeContext& node)
return InitError(Untranslated("-daemon is not supported on this operating system"));
#endif // HAVE_DECL_FORK
}
// Lock data directory after daemonization
if (!AppInitLockDataDirectory())
// Lock critical directories after daemonization
if (!AppInitLockDirectories())
{
// If locking the data directory failed, exit immediately
// If locking a directory failed, exit immediately
return false;
}
fRet = AppInitInterfaces(node) && AppInitMain(node);

View file

@ -95,7 +95,7 @@ std::string LicenseInfo()
strprintf(_("The source code is available from %s."), URL_SOURCE_CODE).translated +
"\n" +
"\n" +
_("This is experimental software.").translated + "\n" +
_("This is experimental software.") + "\n" +
strprintf(_("Distributed under the MIT software license, see the accompanying file %s or %s"), "COPYING", "<https://opensource.org/licenses/MIT>").translated +
"\n";
}

View file

@ -4,6 +4,7 @@
#include <consensus/merkle.h>
#include <hash.h>
#include <util/check.h>
/* WARNING! If you're reading this because you're learning about crypto
and/or designing a new system that will use merkle trees, keep in mind
@ -84,8 +85,10 @@ uint256 BlockWitnessMerkleRoot(const CBlock& block, bool* mutated)
}
/* This implements a constant-space merkle root/path calculator, limited to 2^32 leaves. */
static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot, bool* pmutated, uint32_t branchpos, std::vector<uint256>* pbranch) {
if (pbranch) pbranch->clear();
static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot, bool* pmutated, uint32_t leaf_pos, std::vector<uint256>* path)
{
if (path) path->clear();
Assume(leaves.size() <= UINT32_MAX);
if (leaves.size() == 0) {
if (pmutated) *pmutated = false;
if (proot) *proot = uint256();
@ -105,18 +108,18 @@ static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot
// First process all leaves into 'inner' values.
while (count < leaves.size()) {
uint256 h = leaves[count];
bool matchh = count == branchpos;
bool matchh = count == leaf_pos;
count++;
int level;
// For each of the lower bits in count that are 0, do 1 step. Each
// corresponds to an inner value that existed before processing the
// current leaf, and each needs a hash to combine it.
for (level = 0; !(count & ((uint32_t{1}) << level)); level++) {
if (pbranch) {
if (path) {
if (matchh) {
pbranch->push_back(inner[level]);
path->push_back(inner[level]);
} else if (matchlevel == level) {
pbranch->push_back(h);
path->push_back(h);
matchh = true;
}
}
@ -144,8 +147,8 @@ static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot
// If we reach this point, h is an inner value that is not the top.
// We combine it with itself (Bitcoin's special rule for odd levels in
// the tree) to produce a higher level one.
if (pbranch && matchh) {
pbranch->push_back(h);
if (path && matchh) {
path->push_back(h);
}
h = Hash(h, h);
// Increment count to the value it would have if two entries at this
@ -154,11 +157,11 @@ static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot
level++;
// And propagate the result upwards accordingly.
while (!(count & ((uint32_t{1}) << level))) {
if (pbranch) {
if (path) {
if (matchh) {
pbranch->push_back(inner[level]);
path->push_back(inner[level]);
} else if (matchlevel == level) {
pbranch->push_back(h);
path->push_back(h);
matchh = true;
}
}
@ -171,18 +174,18 @@ static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot
if (proot) *proot = h;
}
static std::vector<uint256> ComputeMerkleBranch(const std::vector<uint256>& leaves, uint32_t position) {
static std::vector<uint256> ComputeMerklePath(const std::vector<uint256>& leaves, uint32_t position) {
std::vector<uint256> ret;
MerkleComputation(leaves, nullptr, nullptr, position, &ret);
return ret;
}
std::vector<uint256> BlockMerkleBranch(const CBlock& block, uint32_t position)
std::vector<uint256> TransactionMerklePath(const CBlock& block, uint32_t position)
{
std::vector<uint256> leaves;
leaves.resize(block.vtx.size());
for (size_t s = 0; s < block.vtx.size(); s++) {
leaves[s] = block.vtx[s]->GetHash();
}
return ComputeMerkleBranch(leaves, position);
return ComputeMerklePath(leaves, position);
}

View file

@ -28,10 +28,10 @@ uint256 BlockWitnessMerkleRoot(const CBlock& block, bool* mutated = nullptr);
* Compute merkle path to the specified transaction
*
* @param[in] block the block
* @param[in] position transaction for which to calculate the merkle path, defaults to coinbase
* @param[in] position transaction for which to calculate the merkle path (0 is the coinbase)
*
* @return merkle path ordered from the deepest
*/
std::vector<uint256> BlockMerkleBranch(const CBlock& block, uint32_t position = 0);
std::vector<uint256> TransactionMerklePath(const CBlock& block, uint32_t position);
#endif // BITCOIN_CONSENSUS_MERKLE_H

View file

@ -1,4 +1,4 @@
// Copyright (c) 2017-2022 The Bitcoin Core developers
// Copyright (c) 2017-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -25,14 +25,14 @@
void ChaCha20Aligned::SetKey(Span<const std::byte> key) noexcept
{
assert(key.size() == KEYLEN);
input[0] = ReadLE32(UCharCast(key.data() + 0));
input[1] = ReadLE32(UCharCast(key.data() + 4));
input[2] = ReadLE32(UCharCast(key.data() + 8));
input[3] = ReadLE32(UCharCast(key.data() + 12));
input[4] = ReadLE32(UCharCast(key.data() + 16));
input[5] = ReadLE32(UCharCast(key.data() + 20));
input[6] = ReadLE32(UCharCast(key.data() + 24));
input[7] = ReadLE32(UCharCast(key.data() + 28));
input[0] = ReadLE32(key.data() + 0);
input[1] = ReadLE32(key.data() + 4);
input[2] = ReadLE32(key.data() + 8);
input[3] = ReadLE32(key.data() + 12);
input[4] = ReadLE32(key.data() + 16);
input[5] = ReadLE32(key.data() + 20);
input[6] = ReadLE32(key.data() + 24);
input[7] = ReadLE32(key.data() + 28);
input[8] = 0;
input[9] = 0;
input[10] = 0;
@ -59,7 +59,7 @@ void ChaCha20Aligned::Seek(Nonce96 nonce, uint32_t block_counter) noexcept
inline void ChaCha20Aligned::Keystream(Span<std::byte> output) noexcept
{
unsigned char* c = UCharCast(output.data());
std::byte* c = output.data();
size_t blocks = output.size() / BLOCKLEN;
assert(blocks * BLOCKLEN == output.size());
@ -161,8 +161,8 @@ inline void ChaCha20Aligned::Keystream(Span<std::byte> output) noexcept
inline void ChaCha20Aligned::Crypt(Span<const std::byte> in_bytes, Span<std::byte> out_bytes) noexcept
{
assert(in_bytes.size() == out_bytes.size());
const unsigned char* m = UCharCast(in_bytes.data());
unsigned char* c = UCharCast(out_bytes.data());
const std::byte* m = in_bytes.data();
std::byte* c = out_bytes.data();
size_t blocks = out_bytes.size() / BLOCKLEN;
assert(blocks * BLOCKLEN == out_bytes.size());

View file

@ -56,8 +56,8 @@ void ComputeTag(ChaCha20& chacha20, Span<const std::byte> aad, Span<const std::b
poly1305.Update(cipher).Update(Span{PADDING}.first(cipher_padding_length));
// - Process the AAD and plaintext length with Poly1305.
std::byte length_desc[Poly1305::TAGLEN];
WriteLE64(UCharCast(length_desc), aad.size());
WriteLE64(UCharCast(length_desc + 8), cipher.size());
WriteLE64(length_desc, aad.size());
WriteLE64(length_desc + 8, cipher.size());
poly1305.Update(length_desc);
// Output tag.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014-2020 The Bitcoin Core developers
// Copyright (c) 2014-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -7,82 +7,99 @@
#include <compat/endian.h>
#include <concepts>
#include <cstddef>
#include <cstdint>
#include <cstring>
uint16_t static inline ReadLE16(const unsigned char* ptr)
template <typename B>
concept ByteType = std::same_as<B, unsigned char> || std::same_as<B, std::byte>;
template <ByteType B>
inline uint16_t ReadLE16(const B* ptr)
{
uint16_t x;
memcpy(&x, ptr, 2);
return le16toh_internal(x);
}
uint32_t static inline ReadLE32(const unsigned char* ptr)
template <ByteType B>
inline uint32_t ReadLE32(const B* ptr)
{
uint32_t x;
memcpy(&x, ptr, 4);
return le32toh_internal(x);
}
uint64_t static inline ReadLE64(const unsigned char* ptr)
template <ByteType B>
inline uint64_t ReadLE64(const B* ptr)
{
uint64_t x;
memcpy(&x, ptr, 8);
return le64toh_internal(x);
}
void static inline WriteLE16(unsigned char* ptr, uint16_t x)
template <ByteType B>
inline void WriteLE16(B* ptr, uint16_t x)
{
uint16_t v = htole16_internal(x);
memcpy(ptr, &v, 2);
}
void static inline WriteLE32(unsigned char* ptr, uint32_t x)
template <ByteType B>
inline void WriteLE32(B* ptr, uint32_t x)
{
uint32_t v = htole32_internal(x);
memcpy(ptr, &v, 4);
}
void static inline WriteLE64(unsigned char* ptr, uint64_t x)
template <ByteType B>
inline void WriteLE64(B* ptr, uint64_t x)
{
uint64_t v = htole64_internal(x);
memcpy(ptr, &v, 8);
}
uint16_t static inline ReadBE16(const unsigned char* ptr)
template <ByteType B>
inline uint16_t ReadBE16(const B* ptr)
{
uint16_t x;
memcpy(&x, ptr, 2);
return be16toh_internal(x);
}
uint32_t static inline ReadBE32(const unsigned char* ptr)
template <ByteType B>
inline uint32_t ReadBE32(const B* ptr)
{
uint32_t x;
memcpy(&x, ptr, 4);
return be32toh_internal(x);
}
uint64_t static inline ReadBE64(const unsigned char* ptr)
template <ByteType B>
inline uint64_t ReadBE64(const B* ptr)
{
uint64_t x;
memcpy(&x, ptr, 8);
return be64toh_internal(x);
}
void static inline WriteBE16(unsigned char* ptr, uint16_t x)
template <ByteType B>
inline void WriteBE16(B* ptr, uint16_t x)
{
uint16_t v = htobe16_internal(x);
memcpy(ptr, &v, 2);
}
void static inline WriteBE32(unsigned char* ptr, uint32_t x)
template <ByteType B>
inline void WriteBE32(B* ptr, uint32_t x)
{
uint32_t v = htobe32_internal(x);
memcpy(ptr, &v, 4);
}
void static inline WriteBE64(unsigned char* ptr, uint64_t x)
template <ByteType B>
inline void WriteBE64(B* ptr, uint64_t x)
{
uint64_t v = htobe64_internal(x);
memcpy(ptr, &v, 8);

View file

@ -7,7 +7,9 @@
#include <crypto/chacha20.h>
#include <crypto/common.h>
#include <hash.h>
#include <util/check.h>
#include <bit>
#include <cassert>
#include <cstdio>
#include <limits>
@ -15,10 +17,22 @@
namespace {
using limb_t = Num3072::limb_t;
using signed_limb_t = Num3072::signed_limb_t;
using double_limb_t = Num3072::double_limb_t;
using signed_double_limb_t = Num3072::signed_double_limb_t;
constexpr int LIMB_SIZE = Num3072::LIMB_SIZE;
constexpr int SIGNED_LIMB_SIZE = Num3072::SIGNED_LIMB_SIZE;
constexpr int LIMBS = Num3072::LIMBS;
constexpr int SIGNED_LIMBS = Num3072::SIGNED_LIMBS;
constexpr int FINAL_LIMB_POSITION = 3072 / SIGNED_LIMB_SIZE;
constexpr int FINAL_LIMB_MODULUS_BITS = 3072 % SIGNED_LIMB_SIZE;
constexpr limb_t MAX_LIMB = (limb_t)(-1);
constexpr limb_t MAX_SIGNED_LIMB = (((limb_t)1) << SIGNED_LIMB_SIZE) - 1;
/** 2^3072 - 1103717, the largest 3072-bit safe prime number, is used as the modulus. */
constexpr limb_t MAX_PRIME_DIFF = 1103717;
/** The modular inverse of (2**3072 - MAX_PRIME_DIFF) mod (MAX_SIGNED_LIMB + 1). */
constexpr limb_t MODULUS_INVERSE = limb_t(0x70a1421da087d93);
/** Extract the lowest limb of [c0,c1,c2] into n, and left shift the number by 1 limb. */
inline void extract3(limb_t& c0, limb_t& c1, limb_t& c2, limb_t& n)
@ -72,23 +86,6 @@ inline void muladd3(limb_t& c0, limb_t& c1, limb_t& c2, const limb_t& a, const l
c2 += (c1 < th) ? 1 : 0;
}
/** [c0,c1,c2] += 2 * a * b */
inline void muldbladd3(limb_t& c0, limb_t& c1, limb_t& c2, const limb_t& a, const limb_t& b)
{
double_limb_t t = (double_limb_t)a * b;
limb_t th = t >> LIMB_SIZE;
limb_t tl = t;
c0 += tl;
limb_t tt = th + ((c0 < tl) ? 1 : 0);
c1 += tt;
c2 += (c1 < tt) ? 1 : 0;
c0 += tl;
th += (c0 < tl) ? 1 : 0;
c1 += th;
c2 += (c1 < th) ? 1 : 0;
}
/**
* Add limb a to [c0,c1]: [c0,c1] += a. Then extract the lowest
* limb of [c0,c1] into n, and left shift the number by 1 limb.
@ -103,8 +100,7 @@ inline void addnextract2(limb_t& c0, limb_t& c1, const limb_t& a, limb_t& n)
c1 += 1;
// Handle case when c1 has overflown
if (c1 == 0)
c2 = 1;
if (c1 == 0) c2 = 1;
}
// extract
@ -113,13 +109,6 @@ inline void addnextract2(limb_t& c0, limb_t& c1, const limb_t& a, limb_t& n)
c1 = c2;
}
/** in_out = in_out^(2^sq) * mul */
inline void square_n_mul(Num3072& in_out, const int sq, const Num3072& mul)
{
for (int j = 0; j < sq; ++j) in_out.Square();
in_out.Multiply(mul);
}
} // namespace
/** Indicates whether d is larger than the modulus. */
@ -141,41 +130,326 @@ void Num3072::FullReduce()
}
}
Num3072 Num3072::GetInverse() const
namespace {
/** A type representing a number in signed limb representation. */
struct Num3072Signed
{
// For fast exponentiation a sliding window exponentiation with repunit
// precomputation is utilized. See "Fast Point Decompression for Standard
// Elliptic Curves" (Brumley, Järvinen, 2008).
/** The represented value is sum(limbs[i]*2^(SIGNED_LIMB_SIZE*i), i=0..SIGNED_LIMBS-1).
* Note that limbs may be negative, or exceed 2^SIGNED_LIMB_SIZE-1. */
signed_limb_t limbs[SIGNED_LIMBS];
Num3072 p[12]; // p[i] = a^(2^(2^i)-1)
Num3072 out;
p[0] = *this;
for (int i = 0; i < 11; ++i) {
p[i + 1] = p[i];
for (int j = 0; j < (1 << i); ++j) p[i + 1].Square();
p[i + 1].Multiply(p[i]);
/** Construct a Num3072Signed with value 0. */
Num3072Signed()
{
memset(limbs, 0, sizeof(limbs));
}
out = p[11];
/** Convert a Num3072 to a Num3072Signed. Output will be normalized and in
* range 0..2^3072-1. */
void FromNum3072(const Num3072& in)
{
double_limb_t c = 0;
int b = 0, outpos = 0;
for (int i = 0; i < LIMBS; ++i) {
c += double_limb_t{in.limbs[i]} << b;
b += LIMB_SIZE;
while (b >= SIGNED_LIMB_SIZE) {
limbs[outpos++] = limb_t(c) & MAX_SIGNED_LIMB;
c >>= SIGNED_LIMB_SIZE;
b -= SIGNED_LIMB_SIZE;
}
}
Assume(outpos == SIGNED_LIMBS - 1);
limbs[SIGNED_LIMBS - 1] = c;
c >>= SIGNED_LIMB_SIZE;
Assume(c == 0);
}
square_n_mul(out, 512, p[9]);
square_n_mul(out, 256, p[8]);
square_n_mul(out, 128, p[7]);
square_n_mul(out, 64, p[6]);
square_n_mul(out, 32, p[5]);
square_n_mul(out, 8, p[3]);
square_n_mul(out, 2, p[1]);
square_n_mul(out, 1, p[0]);
square_n_mul(out, 5, p[2]);
square_n_mul(out, 3, p[0]);
square_n_mul(out, 2, p[0]);
square_n_mul(out, 4, p[0]);
square_n_mul(out, 4, p[1]);
square_n_mul(out, 3, p[0]);
/** Convert a Num3072Signed to a Num3072. Input must be in range 0..modulus-1. */
void ToNum3072(Num3072& out) const
{
double_limb_t c = 0;
int b = 0, outpos = 0;
for (int i = 0; i < SIGNED_LIMBS; ++i) {
c += double_limb_t(limbs[i]) << b;
b += SIGNED_LIMB_SIZE;
if (b >= LIMB_SIZE) {
out.limbs[outpos++] = c;
c >>= LIMB_SIZE;
b -= LIMB_SIZE;
}
}
Assume(outpos == LIMBS);
Assume(c == 0);
}
return out;
/** Take a Num3072Signed in range 1-2*2^3072..2^3072-1, and:
* - optionally negate it (if negate is true)
* - reduce it modulo the modulus (2^3072 - MAX_PRIME_DIFF)
* - produce output with all limbs in range 0..2^SIGNED_LIMB_SIZE-1
*/
void Normalize(bool negate)
{
// Add modulus if this was negative. This brings the range of *this to 1-2^3072..2^3072-1.
signed_limb_t cond_add = limbs[SIGNED_LIMBS-1] >> (LIMB_SIZE-1); // -1 if this is negative; 0 otherwise
limbs[0] += signed_limb_t(-MAX_PRIME_DIFF) & cond_add;
limbs[FINAL_LIMB_POSITION] += (signed_limb_t(1) << FINAL_LIMB_MODULUS_BITS) & cond_add;
// Next negate all limbs if negate was set. This does not change the range of *this.
signed_limb_t cond_negate = -signed_limb_t(negate); // -1 if this negate is true; 0 otherwise
for (int i = 0; i < SIGNED_LIMBS; ++i) {
limbs[i] = (limbs[i] ^ cond_negate) - cond_negate;
}
// Perform carry (make all limbs except the top one be in range 0..2^SIGNED_LIMB_SIZE-1).
for (int i = 0; i < SIGNED_LIMBS - 1; ++i) {
limbs[i + 1] += limbs[i] >> SIGNED_LIMB_SIZE;
limbs[i] &= MAX_SIGNED_LIMB;
}
// Again add modulus if *this was negative. This brings the range of *this to 0..2^3072-1.
cond_add = limbs[SIGNED_LIMBS-1] >> (LIMB_SIZE-1); // -1 if this is negative; 0 otherwise
limbs[0] += signed_limb_t(-MAX_PRIME_DIFF) & cond_add;
limbs[FINAL_LIMB_POSITION] += (signed_limb_t(1) << FINAL_LIMB_MODULUS_BITS) & cond_add;
// Perform another carry. Now all limbs are in range 0..2^SIGNED_LIMB_SIZE-1.
for (int i = 0; i < SIGNED_LIMBS - 1; ++i) {
limbs[i + 1] += limbs[i] >> SIGNED_LIMB_SIZE;
limbs[i] &= MAX_SIGNED_LIMB;
}
}
};
/** 2x2 transformation matrix with signed_limb_t elements. */
struct SignedMatrix
{
signed_limb_t u, v, q, r;
};
/** Compute the transformation matrix for SIGNED_LIMB_SIZE divsteps.
*
* eta: initial eta value
* f: bottom SIGNED_LIMB_SIZE bits of initial f value
* g: bottom SIGNED_LIMB_SIZE bits of initial g value
* out: resulting transformation matrix, scaled by 2^SIGNED_LIMB_SIZE
* return: eta value after SIGNED_LIMB_SIZE divsteps
*/
inline limb_t ComputeDivstepMatrix(signed_limb_t eta, limb_t f, limb_t g, SignedMatrix& out)
{
/** inv256[i] = -1/(2*i+1) (mod 256) */
static const uint8_t NEGINV256[128] = {
0xFF, 0x55, 0x33, 0x49, 0xC7, 0x5D, 0x3B, 0x11, 0x0F, 0xE5, 0xC3, 0x59,
0xD7, 0xED, 0xCB, 0x21, 0x1F, 0x75, 0x53, 0x69, 0xE7, 0x7D, 0x5B, 0x31,
0x2F, 0x05, 0xE3, 0x79, 0xF7, 0x0D, 0xEB, 0x41, 0x3F, 0x95, 0x73, 0x89,
0x07, 0x9D, 0x7B, 0x51, 0x4F, 0x25, 0x03, 0x99, 0x17, 0x2D, 0x0B, 0x61,
0x5F, 0xB5, 0x93, 0xA9, 0x27, 0xBD, 0x9B, 0x71, 0x6F, 0x45, 0x23, 0xB9,
0x37, 0x4D, 0x2B, 0x81, 0x7F, 0xD5, 0xB3, 0xC9, 0x47, 0xDD, 0xBB, 0x91,
0x8F, 0x65, 0x43, 0xD9, 0x57, 0x6D, 0x4B, 0xA1, 0x9F, 0xF5, 0xD3, 0xE9,
0x67, 0xFD, 0xDB, 0xB1, 0xAF, 0x85, 0x63, 0xF9, 0x77, 0x8D, 0x6B, 0xC1,
0xBF, 0x15, 0xF3, 0x09, 0x87, 0x1D, 0xFB, 0xD1, 0xCF, 0xA5, 0x83, 0x19,
0x97, 0xAD, 0x8B, 0xE1, 0xDF, 0x35, 0x13, 0x29, 0xA7, 0x3D, 0x1B, 0xF1,
0xEF, 0xC5, 0xA3, 0x39, 0xB7, 0xCD, 0xAB, 0x01
};
// Coefficients of returned SignedMatrix; starts off as identity matrix. */
limb_t u = 1, v = 0, q = 0, r = 1;
// The number of divsteps still left.
int i = SIGNED_LIMB_SIZE;
while (true) {
/* Use a sentinel bit to count zeros only up to i. */
int zeros = std::countr_zero(g | (MAX_LIMB << i));
/* Perform zeros divsteps at once; they all just divide g by two. */
g >>= zeros;
u <<= zeros;
v <<= zeros;
eta -= zeros;
i -= zeros;
/* We're done once we've performed SIGNED_LIMB_SIZE divsteps. */
if (i == 0) break;
/* If eta is negative, negate it and replace f,g with g,-f. */
if (eta < 0) {
limb_t tmp;
eta = -eta;
tmp = f; f = g; g = -tmp;
tmp = u; u = q; q = -tmp;
tmp = v; v = r; r = -tmp;
}
/* eta is now >= 0. In what follows we're going to cancel out the bottom bits of g. No more
* than i can be cancelled out (as we'd be done before that point), and no more than eta+1
* can be done as its sign will flip once that happens. */
int limit = ((int)eta + 1) > i ? i : ((int)eta + 1);
/* m is a mask for the bottom min(limit, 8) bits (our table only supports 8 bits). */
limb_t m = (MAX_LIMB >> (LIMB_SIZE - limit)) & 255U;
/* Find what multiple of f must be added to g to cancel its bottom min(limit, 8) bits. */
limb_t w = (g * NEGINV256[(f >> 1) & 127]) & m;
/* Do so. */
g += f * w;
q += u * w;
r += v * w;
}
out.u = (signed_limb_t)u;
out.v = (signed_limb_t)v;
out.q = (signed_limb_t)q;
out.r = (signed_limb_t)r;
return eta;
}
/** Apply matrix t/2^SIGNED_LIMB_SIZE to vector [d,e], modulo modulus.
*
* On input and output, d and e are in range 1-2*modulus..modulus-1.
*/
inline void UpdateDE(Num3072Signed& d, Num3072Signed& e, const SignedMatrix& t)
{
const signed_limb_t u = t.u, v=t.v, q=t.q, r=t.r;
/* [md,me] start as zero; plus [u,q] if d is negative; plus [v,r] if e is negative. */
signed_limb_t sd = d.limbs[SIGNED_LIMBS - 1] >> (LIMB_SIZE - 1);
signed_limb_t se = e.limbs[SIGNED_LIMBS - 1] >> (LIMB_SIZE - 1);
signed_limb_t md = (u & sd) + (v & se);
signed_limb_t me = (q & sd) + (r & se);
/* Begin computing t*[d,e]. */
signed_limb_t di = d.limbs[0], ei = e.limbs[0];
signed_double_limb_t cd = (signed_double_limb_t)u * di + (signed_double_limb_t)v * ei;
signed_double_limb_t ce = (signed_double_limb_t)q * di + (signed_double_limb_t)r * ei;
/* Correct md,me so that t*[d,e]+modulus*[md,me] has SIGNED_LIMB_SIZE zero bottom bits. */
md -= (MODULUS_INVERSE * limb_t(cd) + md) & MAX_SIGNED_LIMB;
me -= (MODULUS_INVERSE * limb_t(ce) + me) & MAX_SIGNED_LIMB;
/* Update the beginning of computation for t*[d,e]+modulus*[md,me] now md,me are known. */
cd -= (signed_double_limb_t)1103717 * md;
ce -= (signed_double_limb_t)1103717 * me;
/* Verify that the low SIGNED_LIMB_SIZE bits of the computation are indeed zero, and then throw them away. */
Assume((cd & MAX_SIGNED_LIMB) == 0);
Assume((ce & MAX_SIGNED_LIMB) == 0);
cd >>= SIGNED_LIMB_SIZE;
ce >>= SIGNED_LIMB_SIZE;
/* Now iteratively compute limb i=1..SIGNED_LIMBS-2 of t*[d,e]+modulus*[md,me], and store them in output
* limb i-1 (shifting down by SIGNED_LIMB_SIZE bits). The corresponding limbs in modulus are all zero,
* so modulus/md/me are not actually involved here. */
for (int i = 1; i < SIGNED_LIMBS - 1; ++i) {
di = d.limbs[i];
ei = e.limbs[i];
cd += (signed_double_limb_t)u * di + (signed_double_limb_t)v * ei;
ce += (signed_double_limb_t)q * di + (signed_double_limb_t)r * ei;
d.limbs[i - 1] = (signed_limb_t)cd & MAX_SIGNED_LIMB; cd >>= SIGNED_LIMB_SIZE;
e.limbs[i - 1] = (signed_limb_t)ce & MAX_SIGNED_LIMB; ce >>= SIGNED_LIMB_SIZE;
}
/* Compute limb SIGNED_LIMBS-1 of t*[d,e]+modulus*[md,me], and store it in output limb SIGNED_LIMBS-2. */
di = d.limbs[SIGNED_LIMBS - 1];
ei = e.limbs[SIGNED_LIMBS - 1];
cd += (signed_double_limb_t)u * di + (signed_double_limb_t)v * ei;
ce += (signed_double_limb_t)q * di + (signed_double_limb_t)r * ei;
cd += (signed_double_limb_t)md << FINAL_LIMB_MODULUS_BITS;
ce += (signed_double_limb_t)me << FINAL_LIMB_MODULUS_BITS;
d.limbs[SIGNED_LIMBS - 2] = (signed_limb_t)cd & MAX_SIGNED_LIMB; cd >>= SIGNED_LIMB_SIZE;
e.limbs[SIGNED_LIMBS - 2] = (signed_limb_t)ce & MAX_SIGNED_LIMB; ce >>= SIGNED_LIMB_SIZE;
/* What remains goes into output limb SINGED_LIMBS-1 */
d.limbs[SIGNED_LIMBS - 1] = (signed_limb_t)cd;
e.limbs[SIGNED_LIMBS - 1] = (signed_limb_t)ce;
}
/** Apply matrix t/2^SIGNED_LIMB_SIZE to vector (f,g).
*
* The matrix t must be chosen such that t*(f,g) results in multiples of 2^SIGNED_LIMB_SIZE.
* This is the case for matrices computed by ComputeDivstepMatrix().
*/
inline void UpdateFG(Num3072Signed& f, Num3072Signed& g, const SignedMatrix& t, int len)
{
const signed_limb_t u = t.u, v=t.v, q=t.q, r=t.r;
signed_limb_t fi, gi;
signed_double_limb_t cf, cg;
/* Start computing t*[f,g]. */
fi = f.limbs[0];
gi = g.limbs[0];
cf = (signed_double_limb_t)u * fi + (signed_double_limb_t)v * gi;
cg = (signed_double_limb_t)q * fi + (signed_double_limb_t)r * gi;
/* Verify that the bottom SIGNED_LIMB_BITS bits of the result are zero, and then throw them away. */
Assume((cf & MAX_SIGNED_LIMB) == 0);
Assume((cg & MAX_SIGNED_LIMB) == 0);
cf >>= SIGNED_LIMB_SIZE;
cg >>= SIGNED_LIMB_SIZE;
/* Now iteratively compute limb i=1..SIGNED_LIMBS-1 of t*[f,g], and store them in output limb i-1 (shifting
* down by SIGNED_LIMB_BITS bits). */
for (int i = 1; i < len; ++i) {
fi = f.limbs[i];
gi = g.limbs[i];
cf += (signed_double_limb_t)u * fi + (signed_double_limb_t)v * gi;
cg += (signed_double_limb_t)q * fi + (signed_double_limb_t)r * gi;
f.limbs[i - 1] = (signed_limb_t)cf & MAX_SIGNED_LIMB; cf >>= SIGNED_LIMB_SIZE;
g.limbs[i - 1] = (signed_limb_t)cg & MAX_SIGNED_LIMB; cg >>= SIGNED_LIMB_SIZE;
}
/* What remains is limb SIGNED_LIMBS of t*[f,g]; store it as output limb SIGNED_LIMBS-1. */
f.limbs[len - 1] = (signed_limb_t)cf;
g.limbs[len - 1] = (signed_limb_t)cg;
}
} // namespace
Num3072 Num3072::GetInverse() const
{
// Compute a modular inverse based on a variant of the safegcd algorithm:
// - Paper: https://gcd.cr.yp.to/papers.html
// - Inspired by this code in libsecp256k1:
// https://github.com/bitcoin-core/secp256k1/blob/master/src/modinv32_impl.h
// - Explanation of the algorithm:
// https://github.com/bitcoin-core/secp256k1/blob/master/doc/safegcd_implementation.md
// Local variables d, e, f, g:
// - f and g are the variables whose gcd we compute (despite knowing the answer is 1):
// - f is always odd, and initialized as modulus
// - g is initialized as *this (called x in what follows)
// - d and e are the numbers for which at every step it is the case that:
// - f = d * x mod modulus; d is initialized as 0
// - g = e * x mod modulus; e is initialized as 1
Num3072Signed d, e, f, g;
e.limbs[0] = 1;
// F is initialized as modulus, which in signed limb representation can be expressed
// simply as 2^3072 + -MAX_PRIME_DIFF.
f.limbs[0] = -MAX_PRIME_DIFF;
f.limbs[FINAL_LIMB_POSITION] = ((limb_t)1) << FINAL_LIMB_MODULUS_BITS;
g.FromNum3072(*this);
int len = SIGNED_LIMBS; //!< The number of significant limbs in f and g
signed_limb_t eta = -1; //!< State to track knowledge about ratio of f and g
// Perform divsteps on [f,g] until g=0 is reached, keeping (d,e) synchronized with them.
while (true) {
// Compute transformation matrix t that represents the next SIGNED_LIMB_SIZE divsteps
// to apply. This can be computed from just the bottom limb of f and g, and eta.
SignedMatrix t;
eta = ComputeDivstepMatrix(eta, f.limbs[0], g.limbs[0], t);
// Apply that transformation matrix to the full [f,g] vector.
UpdateFG(f, g, t, len);
// Apply that transformation matrix to the full [d,e] vector (mod modulus).
UpdateDE(d, e, t);
// Check if g is zero.
if (g.limbs[0] == 0) {
signed_limb_t cond = 0;
for (int j = 1; j < len; ++j) {
cond |= g.limbs[j];
}
// If so, we're done.
if (cond == 0) break;
}
// Check if the top limbs of both f and g are both 0 or -1.
signed_limb_t fn = f.limbs[len - 1], gn = g.limbs[len - 1];
signed_limb_t cond = ((signed_limb_t)len - 2) >> (LIMB_SIZE - 1);
cond |= fn ^ (fn >> (LIMB_SIZE - 1));
cond |= gn ^ (gn >> (LIMB_SIZE - 1));
if (cond == 0) {
// If so, drop the top limb, shrinking the size of f and g, by
// propagating the sign to the previous limb.
f.limbs[len - 2] |= (limb_t)f.limbs[len - 1] << SIGNED_LIMB_SIZE;
g.limbs[len - 2] |= (limb_t)g.limbs[len - 1] << SIGNED_LIMB_SIZE;
--len;
}
}
// At some point, [f,g] will have been rewritten into [f',0], such that gcd(f,g) = gcd(f',0).
// This is proven in the paper. As f started out being modulus, a prime number, we know that
// gcd is 1, and thus f' is 1 or -1.
Assume((f.limbs[0] & MAX_SIGNED_LIMB) == 1 || (f.limbs[0] & MAX_SIGNED_LIMB) == MAX_SIGNED_LIMB);
// As we've maintained the invariant that f = d * x mod modulus, we get d/f mod modulus is the
// modular inverse of x we're looking for. As f is 1 or -1, it is also true that d/f = d*f.
// Normalize d to prepare it for output, while negating it if f is negative.
d.Normalize(f.limbs[len - 1] >> (LIMB_SIZE - 1));
Num3072 ret;
d.ToNum3072(ret);
return ret;
}
void Num3072::Multiply(const Num3072& a)
@ -215,43 +489,6 @@ void Num3072::Multiply(const Num3072& a)
if (c0) this->FullReduce();
}
void Num3072::Square()
{
limb_t c0 = 0, c1 = 0, c2 = 0;
Num3072 tmp;
/* Compute limbs 0..N-2 of this*this into tmp, including one reduction. */
for (int j = 0; j < LIMBS - 1; ++j) {
limb_t d0 = 0, d1 = 0, d2 = 0;
for (int i = 0; i < (LIMBS - 1 - j) / 2; ++i) muldbladd3(d0, d1, d2, this->limbs[i + j + 1], this->limbs[LIMBS - 1 - i]);
if ((j + 1) & 1) muladd3(d0, d1, d2, this->limbs[(LIMBS - 1 - j) / 2 + j + 1], this->limbs[LIMBS - 1 - (LIMBS - 1 - j) / 2]);
mulnadd3(c0, c1, c2, d0, d1, d2, MAX_PRIME_DIFF);
for (int i = 0; i < (j + 1) / 2; ++i) muldbladd3(c0, c1, c2, this->limbs[i], this->limbs[j - i]);
if ((j + 1) & 1) muladd3(c0, c1, c2, this->limbs[(j + 1) / 2], this->limbs[j - (j + 1) / 2]);
extract3(c0, c1, c2, tmp.limbs[j]);
}
assert(c2 == 0);
for (int i = 0; i < LIMBS / 2; ++i) muldbladd3(c0, c1, c2, this->limbs[i], this->limbs[LIMBS - 1 - i]);
extract3(c0, c1, c2, tmp.limbs[LIMBS - 1]);
/* Perform a second reduction. */
muln2(c0, c1, MAX_PRIME_DIFF);
for (int j = 0; j < LIMBS; ++j) {
addnextract2(c0, c1, tmp.limbs[j], this->limbs[j]);
}
assert(c1 == 0);
assert(c0 == 0 || c0 == 1);
/* Perform up to two more reductions if the internal state has already
* overflown the MAX of Num3072 or if it is larger than the modulus or
* if both are the case.
* */
if (this->IsOverflow()) this->FullReduce();
if (c0) this->FullReduce();
}
void Num3072::SetToOne()
{
this->limbs[0] = 1;

View file

@ -22,14 +22,22 @@ public:
#ifdef __SIZEOF_INT128__
typedef unsigned __int128 double_limb_t;
typedef signed __int128 signed_double_limb_t;
typedef uint64_t limb_t;
typedef int64_t signed_limb_t;
static constexpr int LIMBS = 48;
static constexpr int SIGNED_LIMBS = 50;
static constexpr int LIMB_SIZE = 64;
static constexpr int SIGNED_LIMB_SIZE = 62;
#else
typedef uint64_t double_limb_t;
typedef int64_t signed_double_limb_t;
typedef uint32_t limb_t;
typedef int32_t signed_limb_t;
static constexpr int LIMBS = 96;
static constexpr int SIGNED_LIMBS = 103;
static constexpr int LIMB_SIZE = 32;
static constexpr int SIGNED_LIMB_SIZE = 30;
#endif
limb_t limbs[LIMBS];
@ -37,6 +45,8 @@ public:
static_assert(LIMB_SIZE * LIMBS == 3072, "Num3072 isn't 3072 bits");
static_assert(sizeof(double_limb_t) == sizeof(limb_t) * 2, "bad size for double_limb_t");
static_assert(sizeof(limb_t) * 8 == LIMB_SIZE, "LIMB_SIZE is incorrect");
static_assert(SIGNED_LIMB_SIZE * SIGNED_LIMBS > 3072, "SIGNED_LIMBS * SIGNED_LIMB_SIZE is too small");
static_assert(3072 / SIGNED_LIMB_SIZE == SIGNED_LIMBS - 1, "Bit 3072 must land in top signed limb");
// Hard coded values in MuHash3072 constructor and Finalize
static_assert(sizeof(limb_t) == 4 || sizeof(limb_t) == 8, "bad size for limb_t");
@ -44,7 +54,6 @@ public:
void Multiply(const Num3072& a);
void Divide(const Num3072& a);
void SetToOne();
void Square();
void ToBytes(unsigned char (&out)[BYTE_SIZE]);
Num3072() { this->SetToOne(); };

View file

@ -105,9 +105,9 @@ void KeccakF(uint64_t (&st)[25])
SHA3_256& SHA3_256::Write(Span<const unsigned char> data)
{
if (m_bufsize && m_bufsize + data.size() >= sizeof(m_buffer)) {
if (m_bufsize && data.size() >= sizeof(m_buffer) - m_bufsize) {
// Fill the buffer and process it.
std::copy(data.begin(), data.begin() + sizeof(m_buffer) - m_bufsize, m_buffer + m_bufsize);
std::copy(data.begin(), data.begin() + (sizeof(m_buffer) - m_bufsize), m_buffer + m_bufsize);
data = data.subspan(sizeof(m_buffer) - m_bufsize);
m_state[m_pos++] ^= ReadLE64(m_buffer);
m_bufsize = 0;

View file

@ -14,8 +14,17 @@ namespace util {
class SignalInterrupt;
} // namespace util
static const int DEFAULT_HTTP_THREADS=4;
static const int DEFAULT_HTTP_WORKQUEUE=16;
/**
* The default value for `-rpcthreads`. This number of threads will be created at startup.
*/
static const int DEFAULT_HTTP_THREADS=16;
/**
* The default value for `-rpcworkqueue`. This is the maximum depth of the work queue,
* we don't allocate this number of work queue items upfront.
*/
static const int DEFAULT_HTTP_WORKQUEUE=64;
static const int DEFAULT_HTTP_SERVER_TIMEOUT=30;
struct evhttp_request;

View file

@ -188,7 +188,7 @@ void BaseIndex::Sync()
CBlock block;
interfaces::BlockInfo block_info = kernel::MakeBlockInfo(pindex);
if (!m_chainstate->m_blockman.ReadBlockFromDisk(block, *pindex)) {
if (!m_chainstate->m_blockman.ReadBlock(block, *pindex)) {
FatalErrorf("%s: Failed to read block %s from disk",
__func__, pindex->GetBlockHash().ToString());
return;
@ -256,7 +256,7 @@ bool BaseIndex::Rewind(const CBlockIndex* current_tip, const CBlockIndex* new_ti
// In the case of a reorg, ensure persisted block locator is not stale.
// Pruning has a minimum of 288 blocks-to-keep and getting the index
// out of sync may be possible but a users fault.
// In case we reorg beyond the pruned depth, ReadBlockFromDisk would
// In case we reorg beyond the pruned depth, ReadBlock would
// throw and lead to a graceful shutdown
SetBestBlockIndex(new_tip);
if (!Commit()) {

View file

@ -256,7 +256,7 @@ bool BlockFilterIndex::CustomAppend(const interfaces::BlockInfo& block)
// pindex variable gives indexing code access to node internals. It
// will be removed in upcoming commit
const CBlockIndex* pindex = WITH_LOCK(cs_main, return m_chainstate->m_blockman.LookupBlockIndex(block.hash));
if (!m_chainstate->m_blockman.UndoReadFromDisk(block_undo, *pindex)) {
if (!m_chainstate->m_blockman.ReadBlockUndo(block_undo, *pindex)) {
return false;
}
}

View file

@ -123,7 +123,7 @@ bool CoinStatsIndex::CustomAppend(const interfaces::BlockInfo& block)
// pindex variable gives indexing code access to node internals. It
// will be removed in upcoming commit
const CBlockIndex* pindex = WITH_LOCK(cs_main, return m_chainstate->m_blockman.LookupBlockIndex(block.hash));
if (!m_chainstate->m_blockman.UndoReadFromDisk(block_undo, *pindex)) {
if (!m_chainstate->m_blockman.ReadBlockUndo(block_undo, *pindex)) {
return false;
}
@ -287,7 +287,7 @@ bool CoinStatsIndex::CustomRewind(const interfaces::BlockRef& current_tip, const
do {
CBlock block;
if (!m_chainstate->m_blockman.ReadBlockFromDisk(block, *iter_tip)) {
if (!m_chainstate->m_blockman.ReadBlock(block, *iter_tip)) {
LogError("%s: Failed to read block %s from disk\n",
__func__, iter_tip->GetBlockHash().ToString());
return false;
@ -415,7 +415,7 @@ bool CoinStatsIndex::ReverseBlock(const CBlock& block, const CBlockIndex* pindex
// Ignore genesis block
if (pindex->nHeight > 0) {
if (!m_chainstate->m_blockman.UndoReadFromDisk(block_undo, *pindex)) {
if (!m_chainstate->m_blockman.ReadBlockUndo(block_undo, *pindex)) {
return false;
}

View file

@ -32,6 +32,7 @@
#include <interfaces/ipc.h>
#include <interfaces/mining.h>
#include <interfaces/node.h>
#include <kernel/caches.h>
#include <kernel/context.h>
#include <key.h>
#include <logging.h>
@ -121,7 +122,6 @@ using common::ResolveErrMsg;
using node::ApplyArgsManOptions;
using node::BlockManager;
using node::CacheSizes;
using node::CalculateCacheSizes;
using node::ChainstateLoadResult;
using node::ChainstateLoadStatus;
@ -487,7 +487,7 @@ void SetupServerArgs(ArgsManager& argsman, bool can_listen_ipc)
argsman.AddArg("-conf=<file>", strprintf("Specify path to read-only configuration file. Relative paths will be prefixed by datadir location (only useable from command line, not configuration file) (default: %s)", BITCOIN_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-datadir=<dir>", "Specify data directory", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_NEGATION, OptionsCategory::OPTIONS);
argsman.AddArg("-dbbatchsize", strprintf("Maximum database write batch size in bytes (default: %u)", nDefaultDbBatchSize), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::OPTIONS);
argsman.AddArg("-dbcache=<n>", strprintf("Maximum database cache size <n> MiB (minimum %d, default: %d). Make sure you have enough RAM. In addition, unused memory allocated to the mempool is shared with this cache (see -maxmempool).", nMinDbCache, nDefaultDbCache), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-dbcache=<n>", strprintf("Maximum database cache size <n> MiB (minimum %d, default: %d). Make sure you have enough RAM. In addition, unused memory allocated to the mempool is shared with this cache (see -maxmempool).", MIN_DB_CACHE >> 20, DEFAULT_DB_CACHE >> 20), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-includeconf=<file>", "Specify additional configuration file, relative to the -datadir path (only useable from configuration file, not command line)", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-allowignoredconf", strprintf("For backwards compatibility, treat an unused %s file in the datadir as a warning, not an error.", BITCOIN_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-loadblock=<file>", "Imports blocks from external file on startup", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
@ -665,7 +665,7 @@ void SetupServerArgs(ArgsManager& argsman, bool can_listen_ipc)
argsman.AddArg("-rpcuser=<user>", "Username for JSON-RPC connections", ArgsManager::ALLOW_ANY | ArgsManager::SENSITIVE, OptionsCategory::RPC);
argsman.AddArg("-rpcwhitelist=<whitelist>", "Set a whitelist to filter incoming RPC calls for a specific user. The field <whitelist> comes in the format: <USERNAME>:<rpc 1>,<rpc 2>,...,<rpc n>. If multiple whitelists are set for a given user, they are set-intersected. See -rpcwhitelistdefault documentation for information on default whitelist behavior.", ArgsManager::ALLOW_ANY, OptionsCategory::RPC);
argsman.AddArg("-rpcwhitelistdefault", "Sets default behavior for rpc whitelisting. Unless rpcwhitelistdefault is set to 0, if any -rpcwhitelist is set, the rpc server acts as if all rpc users are subject to empty-unless-otherwise-specified whitelists. If rpcwhitelistdefault is set to 1 and no -rpcwhitelist is set, rpc server acts as if all rpc users are subject to empty whitelists.", ArgsManager::ALLOW_ANY, OptionsCategory::RPC);
argsman.AddArg("-rpcworkqueue=<n>", strprintf("Set the depth of the work queue to service RPC calls (default: %d)", DEFAULT_HTTP_WORKQUEUE), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::RPC);
argsman.AddArg("-rpcworkqueue=<n>", strprintf("Set the maximum depth of the work queue to service RPC calls (default: %d)", DEFAULT_HTTP_WORKQUEUE), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::RPC);
argsman.AddArg("-server", "Accept command line and JSON-RPC commands", ArgsManager::ALLOW_ANY, OptionsCategory::RPC);
if (can_listen_ipc) {
argsman.AddArg("-ipcbind=<address>", "Bind to Unix socket address and listen for incoming connections. Valid address values are \"unix\" to listen on the default path, <datadir>/node.sock, or \"unix:/custom/path\" to specify a custom path. Can be specified multiple times to listen on multiple paths. Default behavior is not to listen on any path. If relative paths are specified, they are interpreted relative to the network data directory. If paths include any parent directory components and the parent directories do not exist, they will be created.", ArgsManager::ALLOW_ANY, OptionsCategory::IPC);
@ -1072,19 +1072,23 @@ bool AppInitParameterInteraction(const ArgsManager& args)
return true;
}
static bool LockDataDirectory(bool probeOnly)
static bool LockDirectory(const fs::path& dir, bool probeOnly)
{
// Make sure only a single Bitcoin process is using the data directory.
const fs::path& datadir = gArgs.GetDataDirNet();
switch (util::LockDirectory(datadir, ".lock", probeOnly)) {
// Make sure only a single process is using the directory.
switch (util::LockDirectory(dir, ".lock", probeOnly)) {
case util::LockResult::ErrorWrite:
return InitError(strprintf(_("Cannot write to data directory '%s'; check permissions."), fs::PathToString(datadir)));
return InitError(strprintf(_("Cannot write to directory '%s'; check permissions."), fs::PathToString(dir)));
case util::LockResult::ErrorLock:
return InitError(strprintf(_("Cannot obtain a lock on data directory %s. %s is probably already running."), fs::PathToString(datadir), CLIENT_NAME));
return InitError(strprintf(_("Cannot obtain a lock on directory %s. %s is probably already running."), fs::PathToString(dir), CLIENT_NAME));
case util::LockResult::Success: return true;
} // no default case, so the compiler can warn about missing cases
assert(false);
}
static bool LockDirectories(bool probeOnly)
{
return LockDirectory(gArgs.GetDataDirNet(), probeOnly) && \
LockDirectory(gArgs.GetBlocksDirPath(), probeOnly);
}
bool AppInitSanityChecks(const kernel::Context& kernel)
{
@ -1099,19 +1103,19 @@ bool AppInitSanityChecks(const kernel::Context& kernel)
return InitError(strprintf(_("Elliptic curve cryptography sanity check failure. %s is shutting down."), CLIENT_NAME));
}
// Probe the data directory lock to give an early error message, if possible
// We cannot hold the data directory lock here, as the forking for daemon() hasn't yet happened,
// and a fork will cause weird behavior to it.
return LockDataDirectory(true);
// Probe the directory locks to give an early error message, if possible
// We cannot hold the directory locks here, as the forking for daemon() hasn't yet happened,
// and a fork will cause weird behavior to them.
return LockDirectories(true);
}
bool AppInitLockDataDirectory()
bool AppInitLockDirectories()
{
// After daemonization get the data directory lock again and hold on to it until exit
// After daemonization get the directory locks again and hold on to them until exit
// This creates a slight window for a race condition to happen, however this condition is harmless: it
// will at most make us exit without printing a message to console.
if (!LockDataDirectory(false)) {
// Detailed error printed inside LockDataDirectory
if (!LockDirectories(false)) {
// Detailed error printed inside LockDirectory
return false;
}
return true;
@ -1177,7 +1181,7 @@ static ChainstateLoadResult InitAndLoadChainstate(
NodeContext& node,
bool do_reindex,
const bool do_reindex_chainstate,
CacheSizes& cache_sizes,
const kernel::CacheSizes& cache_sizes,
const ArgsManager& args)
{
const CChainParams& chainparams = Params();
@ -1244,9 +1248,8 @@ static ChainstateLoadResult InitAndLoadChainstate(
_("Error reading from database, shutting down."),
"", CClientUIInterface::MSG_ERROR);
};
uiInterface.InitMessage(_("Loading block index…").translated);
const auto load_block_index_start_time{SteadyClock::now()};
auto catch_exceptions = [](auto&& f) {
uiInterface.InitMessage(_("Loading block index…"));
auto catch_exceptions = [](auto&& f) -> ChainstateLoadResult {
try {
return f();
} catch (const std::exception& e) {
@ -1256,14 +1259,14 @@ static ChainstateLoadResult InitAndLoadChainstate(
};
auto [status, error] = catch_exceptions([&] { return LoadChainstate(chainman, cache_sizes, options); });
if (status == node::ChainstateLoadStatus::SUCCESS) {
uiInterface.InitMessage(_("Verifying blocks…").translated);
uiInterface.InitMessage(_("Verifying blocks…"));
if (chainman.m_blockman.m_have_pruned && options.check_blocks > MIN_BLOCKS_TO_KEEP) {
LogWarning("pruned datadir may not have more than %d blocks; only checking available blocks\n",
MIN_BLOCKS_TO_KEEP);
}
std::tie(status, error) = catch_exceptions([&] { return VerifyLoadedChainstate(chainman, options); });
if (status == node::ChainstateLoadStatus::SUCCESS) {
LogPrintf(" block index %15dms\n", Ticks<std::chrono::milliseconds>(SteadyClock::now() - load_block_index_start_time));
LogInfo("Block index and chainstate loaded");
}
}
return {status, error};
@ -1419,7 +1422,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
// Initialize addrman
assert(!node.addrman);
uiInterface.InitMessage(_("Loading P2P addresses…").translated);
uiInterface.InitMessage(_("Loading P2P addresses…"));
auto addrman{LoadAddrman(*node.netgroupman, args)};
if (!addrman) return InitError(util::ErrorString(addrman));
node.addrman = std::move(*addrman);
@ -1588,7 +1591,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
g_zmq_notification_interface = CZMQNotificationInterface::Create(
[&chainman = node.chainman](std::vector<uint8_t>& block, const CBlockIndex& index) {
assert(chainman);
return chainman->m_blockman.ReadRawBlockFromDisk(block, WITH_LOCK(cs_main, return index.GetBlockPos()));
return chainman->m_blockman.ReadRawBlock(block, WITH_LOCK(cs_main, return index.GetBlockPos()));
});
if (g_zmq_notification_interface) {
@ -1603,18 +1606,18 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
ReadNotificationArgs(args, kernel_notifications);
// cache size calculations
CacheSizes cache_sizes = CalculateCacheSizes(args, g_enabled_filter_types.size());
const auto [index_cache_sizes, kernel_cache_sizes] = CalculateCacheSizes(args, g_enabled_filter_types.size());
LogPrintf("Cache configuration:\n");
LogPrintf("* Using %.1f MiB for block index database\n", cache_sizes.block_tree_db * (1.0 / 1024 / 1024));
LogInfo("Cache configuration:");
LogInfo("* Using %.1f MiB for block index database", kernel_cache_sizes.block_tree_db * (1.0 / 1024 / 1024));
if (args.GetBoolArg("-txindex", DEFAULT_TXINDEX)) {
LogPrintf("* Using %.1f MiB for transaction index database\n", cache_sizes.tx_index * (1.0 / 1024 / 1024));
LogInfo("* Using %.1f MiB for transaction index database", index_cache_sizes.tx_index * (1.0 / 1024 / 1024));
}
for (BlockFilterType filter_type : g_enabled_filter_types) {
LogPrintf("* Using %.1f MiB for %s block filter index database\n",
cache_sizes.filter_index * (1.0 / 1024 / 1024), BlockFilterTypeName(filter_type));
LogInfo("* Using %.1f MiB for %s block filter index database",
index_cache_sizes.filter_index * (1.0 / 1024 / 1024), BlockFilterTypeName(filter_type));
}
LogPrintf("* Using %.1f MiB for chain state database\n", cache_sizes.coins_db * (1.0 / 1024 / 1024));
LogInfo("* Using %.1f MiB for chain state database", kernel_cache_sizes.coins_db * (1.0 / 1024 / 1024));
assert(!node.mempool);
assert(!node.chainman);
@ -1627,7 +1630,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
node,
do_reindex,
do_reindex_chainstate,
cache_sizes,
kernel_cache_sizes,
args);
if (status == ChainstateLoadStatus::FAILURE && !do_reindex && !ShutdownRequested(node)) {
// suggest a reindex
@ -1646,7 +1649,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
node,
do_reindex,
do_reindex_chainstate,
cache_sizes,
kernel_cache_sizes,
args);
}
if (status != ChainstateLoadStatus::SUCCESS && status != ChainstateLoadStatus::INTERRUPTED) {
@ -1672,12 +1675,12 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
// ********************************************************* Step 8: start indexers
if (args.GetBoolArg("-txindex", DEFAULT_TXINDEX)) {
g_txindex = std::make_unique<TxIndex>(interfaces::MakeChain(node), cache_sizes.tx_index, false, do_reindex);
g_txindex = std::make_unique<TxIndex>(interfaces::MakeChain(node), index_cache_sizes.tx_index, false, do_reindex);
node.indexes.emplace_back(g_txindex.get());
}
for (const auto& filter_type : g_enabled_filter_types) {
InitBlockFilterIndex([&]{ return interfaces::MakeChain(node); }, filter_type, cache_sizes.filter_index, false, do_reindex);
InitBlockFilterIndex([&]{ return interfaces::MakeChain(node); }, filter_type, index_cache_sizes.filter_index, false, do_reindex);
node.indexes.emplace_back(GetBlockFilterIndex(filter_type));
}
@ -1704,7 +1707,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
if (chainman.m_blockman.m_blockfiles_indexed) {
LOCK(cs_main);
for (Chainstate* chainstate : chainman.GetAll()) {
uiInterface.InitMessage(_("Pruning blockstore…").translated);
uiInterface.InitMessage(_("Pruning blockstore…"));
chainstate->PruneAndFlush();
}
}
@ -1807,7 +1810,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
{
WAIT_LOCK(kernel_notifications.m_tip_block_mutex, lock);
kernel_notifications.m_tip_block_cv.wait(lock, [&]() EXCLUSIVE_LOCKS_REQUIRED(kernel_notifications.m_tip_block_mutex) {
return !kernel_notifications.m_tip_block.IsNull() || ShutdownRequested(node);
return kernel_notifications.TipBlock() || ShutdownRequested(node);
});
}
@ -1827,7 +1830,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
if (tip_info) {
tip_info->block_height = chain_active_height;
tip_info->block_time = best_block_time;
tip_info->verification_progress = GuessVerificationProgress(chainman.GetParams().TxData(), &tip);
tip_info->verification_progress = chainman.GuessVerificationProgress(&tip);
}
if (tip_info && chainman.m_best_header) {
tip_info->header_height = chainman.m_best_header->nHeight;
@ -2000,7 +2003,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
// ChainstateManager's active tip.
SetRPCWarmupFinished();
uiInterface.InitMessage(_("Done loading").translated);
uiInterface.InitMessage(_("Done loading"));
for (const auto& client : node.chain_clients) {
client->start(scheduler);

View file

@ -55,11 +55,11 @@ bool AppInitParameterInteraction(const ArgsManager& args);
*/
bool AppInitSanityChecks(const kernel::Context& kernel);
/**
* Lock bitcoin core data directory.
* Lock bitcoin core critical directories.
* @note This should only be done after daemonization. Do not call Shutdown() if this function fails.
* @pre Parameters should be parsed and config file should be read, AppInitSanityChecks should have been called.
*/
bool AppInitLockDataDirectory();
bool AppInitLockDirectories();
/**
* Initialize node and wallet interface pointers. Has no prerequisites or side effects besides allocating memory.
*/
@ -67,7 +67,7 @@ bool AppInitInterfaces(node::NodeContext& node);
/**
* Bitcoin core main initialization.
* @note This should only be done after daemonization. Call Shutdown() if this function fails.
* @pre Parameters should be parsed and config file should be read, AppInitLockDataDirectory should have been called.
* @pre Parameters should be parsed and config file should be read, AppInitLockDirectories should have been called.
*/
bool AppInitMain(node::NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info = nullptr);

View file

@ -55,7 +55,7 @@ public:
*
* @returns if the block was processed, independent of block validity
*/
virtual bool submitSolution(uint32_t version, uint32_t timestamp, uint32_t nonce, CMutableTransaction coinbase) = 0;
virtual bool submitSolution(uint32_t version, uint32_t timestamp, uint32_t nonce, CTransactionRef coinbase) = 0;
};
//! Interface giving clients (RPC, Stratum v2 Template Provider in the future)
@ -88,36 +88,10 @@ public:
/**
* Construct a new block template
*
* @param[in] script_pub_key the coinbase output
* @param[in] options options for creating the block
* @returns a block template
*/
virtual std::unique_ptr<BlockTemplate> createNewBlock(const CScript& script_pub_key, const node::BlockCreateOptions& options = {}) = 0;
/**
* Processes new block. A valid new block is automatically relayed to peers.
*
* @param[in] block The block we want to process.
* @param[out] new_block A boolean which is set to indicate if the block was first received via this call
* @returns If the block was processed, independently of block validity
*/
virtual bool processNewBlock(const std::shared_ptr<const CBlock>& block, bool* new_block) = 0;
//! Return the number of transaction updates in the mempool,
//! used to decide whether to make a new block template.
virtual unsigned int getTransactionsUpdated() = 0;
/**
* Check a block is completely valid from start to finish.
* Only works on top of our current best block.
* Does not check proof-of-work.
*
* @param[in] block the block to validate
* @param[in] check_merkle_root call CheckMerkleRoot()
* @param[out] state details of why a block failed to validate
* @returns false if it does not build on the current tip, or any of the checks fail
*/
virtual bool testBlockValidity(const CBlock& block, bool check_merkle_root, BlockValidationState& state) = 0;
virtual std::unique_ptr<BlockTemplate> createNewBlock(const node::BlockCreateOptions& options = {}) = 0;
//! Get internal node context. Useful for RPC and testing,
//! but not accessible across processes.

View file

@ -14,6 +14,19 @@
#include <cstddef>
#include <mp/proxy-types.h>
#include <mp/type-chrono.h>
#include <mp/type-context.h>
#include <mp/type-data.h>
#include <mp/type-decay.h>
#include <mp/type-interface.h>
#include <mp/type-message.h>
#include <mp/type-number.h>
#include <mp/type-optional.h>
#include <mp/type-pointer.h>
#include <mp/type-string.h>
#include <mp/type-struct.h>
#include <mp/type-threadmap.h>
#include <mp/type-vector.h>
#include <type_traits>
#include <utility>
@ -94,26 +107,6 @@ requires ipc::capnp::Deserializable<LocalType>
return read_dest.construct(::deserialize, wrapper);
}
//! Overload CustomBuildField and CustomReadField to serialize std::chrono
//! parameters and return values as numbers.
template <class Rep, class Period, typename Value, typename Output>
void CustomBuildField(TypeList<std::chrono::duration<Rep, Period>>, Priority<1>, InvokeContext& invoke_context, Value&& value,
Output&& output)
{
static_assert(std::numeric_limits<decltype(output.get())>::lowest() <= std::numeric_limits<Rep>::lowest(),
"capnp type does not have enough range to hold lowest std::chrono::duration value");
static_assert(std::numeric_limits<decltype(output.get())>::max() >= std::numeric_limits<Rep>::max(),
"capnp type does not have enough range to hold highest std::chrono::duration value");
output.set(value.count());
}
template <class Rep, class Period, typename Input, typename ReadDest>
decltype(auto) CustomReadField(TypeList<std::chrono::duration<Rep, Period>>, Priority<1>, InvokeContext& invoke_context,
Input&& input, ReadDest&& read_dest)
{
return read_dest.construct(input.get());
}
//! Overload CustomBuildField and CustomReadField to serialize UniValue
//! parameters and return values as JSON strings.
template <typename Value, typename Output>
@ -134,32 +127,6 @@ decltype(auto) CustomReadField(TypeList<UniValue>, Priority<1>, InvokeContext& i
});
}
//! Generic ::capnp::Data field builder for any C++ type that can be converted
//! to a span of bytes, like std::vector<char> or std::array<uint8_t>, or custom
//! blob types like uint256 or PKHash with data() and size() methods pointing to
//! bytes.
//!
//! Note: it might make sense to move this function into libmultiprocess, since
//! it is fairly generic. However this would require decreasing its priority so
//! it can be overridden, which would require more changes inside
//! libmultiprocess to avoid conflicting with the Priority<1> CustomBuildField
//! function it already provides for std::vector. Also, it might make sense to
//! provide a CustomReadField counterpart to this function, which could be
//! called to read C++ types that can be constructed from spans of bytes from
//! ::capnp::Data fields. But so far there hasn't been a need for this.
template <typename LocalType, typename Value, typename Output>
void CustomBuildField(TypeList<LocalType>, Priority<2>, InvokeContext& invoke_context, Value&& value, Output&& output)
requires
(std::is_same_v<decltype(output.get()), ::capnp::Data::Builder>) &&
(std::convertible_to<Value, std::span<const std::byte>> ||
std::convertible_to<Value, std::span<const char>> ||
std::convertible_to<Value, std::span<const unsigned char>> ||
std::convertible_to<Value, std::span<const signed char>>)
{
auto data = std::span{value};
auto result = output.init(data.size());
memcpy(result.begin(), data.data(), data.size());
}
} // namespace mp
#endif // BITCOIN_IPC_CAPNP_COMMON_TYPES_H

View file

@ -0,0 +1,12 @@
// Copyright (c) 2025 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_IPC_CAPNP_ECHO_TYPES_H
#define BITCOIN_IPC_CAPNP_ECHO_TYPES_H
#include <mp/type-context.h>
#include <mp/type-decay.h>
#include <mp/type-string.h>
#endif // BITCOIN_IPC_CAPNP_ECHO_TYPES_H

View file

@ -9,7 +9,7 @@ $Cxx.namespace("ipc::capnp::messages");
using Proxy = import "/mp/proxy.capnp";
$Proxy.include("interfaces/echo.h");
$Proxy.include("ipc/capnp/echo.capnp.h");
$Proxy.includeTypes("ipc/capnp/echo-types.h");
interface Echo $Proxy.wrap("interfaces::Echo") {
destroy @0 (context :Proxy.Context) -> ();

View file

@ -17,10 +17,7 @@ interface Mining $Proxy.wrap("interfaces::Mining") {
isInitialBlockDownload @1 (context :Proxy.Context) -> (result: Bool);
getTip @2 (context :Proxy.Context) -> (result: Common.BlockRef, hasResult: Bool);
waitTipChanged @3 (context :Proxy.Context, currentTip: Data, timeout: Float64) -> (result: Common.BlockRef);
createNewBlock @4 (scriptPubKey: Data, options: BlockCreateOptions) -> (result: BlockTemplate);
processNewBlock @5 (context :Proxy.Context, block: Data) -> (newBlock: Bool, result: Bool);
getTransactionsUpdated @6 (context :Proxy.Context) -> (result: UInt32);
testBlockValidity @7 (context :Proxy.Context, block: Data, checkMerkleRoot: Bool) -> (state: BlockValidationState, result: Bool);
createNewBlock @4 (options: BlockCreateOptions) -> (result: BlockTemplate);
}
interface BlockTemplate $Proxy.wrap("interfaces::BlockTemplate") {

View file

@ -73,7 +73,7 @@ public:
}
void addCleanup(std::type_index type, void* iface, std::function<void()> cleanup) override
{
mp::ProxyTypeRegister::types().at(type)(iface).cleanup.emplace_back(std::move(cleanup));
mp::ProxyTypeRegister::types().at(type)(iface).cleanup_fns.emplace_back(std::move(cleanup));
}
Context& context() override { return m_context; }
void startLoop(const char* exe_name)

View file

@ -1,10 +1,11 @@
// Copyright (c) 2022 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <util/translation.h>
#include <functional>
#include <string>
// Define G_TRANSLATION_FUN symbol in libbitcoinkernel library so users of the
// library aren't required to export this symbol
extern const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
extern const TranslateFn G_TRANSLATION_FUN{nullptr};

36
src/kernel/caches.h Normal file
View file

@ -0,0 +1,36 @@
// Copyright (c) 2024-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_KERNEL_CACHES_H
#define BITCOIN_KERNEL_CACHES_H
#include <util/byte_units.h>
#include <algorithm>
//! Suggested default amount of cache reserved for the kernel (bytes)
static constexpr size_t DEFAULT_KERNEL_CACHE{450_MiB};
//! Max memory allocated to block tree DB specific cache (bytes)
static constexpr size_t MAX_BLOCK_DB_CACHE{2_MiB};
//! Max memory allocated to coin DB specific cache (bytes)
static constexpr size_t MAX_COINS_DB_CACHE{8_MiB};
namespace kernel {
struct CacheSizes {
size_t block_tree_db;
size_t coins_db;
size_t coins;
CacheSizes(size_t total_cache)
{
block_tree_db = std::min(total_cache / 8, MAX_BLOCK_DB_CACHE);
total_cache -= block_tree_db;
coins_db = std::min(total_cache / 2, MAX_COINS_DB_CACHE);
total_cache -= coins_db;
coins = total_cache; // the rest goes to the coins cache
}
};
} // namespace kernel
#endif // BITCOIN_KERNEL_CACHES_H

View file

@ -28,9 +28,6 @@ option(LEVELDB_BUILD_TESTS "Build LevelDB's unit tests" ON)
option(LEVELDB_BUILD_BENCHMARKS "Build LevelDB's benchmarks" ON)
option(LEVELDB_INSTALL "Install LevelDB's header and library" ON)
include(TestBigEndian)
test_big_endian(LEVELDB_IS_BIG_ENDIAN)
include(CheckIncludeFile)
check_include_file("unistd.h" HAVE_UNISTD_H)

View file

@ -52,6 +52,9 @@ class LEVELDB_EXPORT Slice {
// Return true iff the length of the referenced data is zero
bool empty() const { return size_ == 0; }
const char* begin() const { return data(); }
const char* end() const { return data() + size(); }
// Return the ith byte in the referenced data.
// REQUIRES: n < size()
char operator[](size_t n) const {

View file

@ -30,10 +30,4 @@
#cmakedefine01 HAVE_SNAPPY
#endif // !defined(HAVE_SNAPPY)
// Define to 1 if your processor stores words with the most significant byte
// first (like Motorola and SPARC, unlike Intel and VAX).
#if !defined(LEVELDB_IS_BIG_ENDIAN)
#cmakedefine01 LEVELDB_IS_BIG_ENDIAN
#endif // !defined(LEVELDB_IS_BIG_ENDIAN)
#endif // STORAGE_LEVELDB_PORT_PORT_CONFIG_H_

View file

@ -18,10 +18,6 @@ namespace port {
// TODO(jorlow): Many of these belong more in the environment class rather than
// here. We should try moving them and see if it affects perf.
// The following boolean constant must be true on a little-endian machine
// and false otherwise.
static const bool kLittleEndian = true /* or some other expression */;
// ------------------ Threading -------------------
// A Mutex represents an exclusive lock.

Some files were not shown because too many files have changed in this diff Show more