0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-08 10:31:50 -05:00
Commit graph

43653 commits

Author SHA1 Message Date
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
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
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
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
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