Commit graph

27032 commits

Author SHA1 Message Date
Fabian Jahr
7e3dbe4180
wallet: Write best block to disk before backup
This ensures that the best block is included in the backup which leads to a more consistent behavior when loading the backup.
2024-09-20 17:16:35 +02:00
merge-script
ab0b5706b2
Merge bitcoin/bitcoin#30875: doc: fixed inconsistencies in documentation between autotools to cmake change
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
a9964c0444 doc: Updating docs from autotools to cmake (kevkevinpal)

Pull request description:

  A bit of a followup from https://github.com/bitcoin/bitcoin/pull/30840

  - In this change the documentation where we refer to the `./configure` script which is now gone and have converted the configure params to use the `cmake` equivalent.

ACKs for top commit:
  maflcko:
    ACK a9964c0444
  jonatack:
    utACK a9964c0444
  jarolrod:
    ACK a9964c0444
  tdb3:
    ACK a9964c0444
  pablomartin4btc:
    re-ACK a9964c0444

Tree-SHA512: f7ed20b8ad61f028c0d242b9cc70650d8da63057d4a8f7da88f0117a8d3241c5fe8fcf19d56ec82088160b9fee9b175fe9f64e5a845260d3696dc7e94bfdd0bd
2024-09-18 18:44:02 +01:00
kevkevinpal
a9964c0444
doc: Updating docs from autotools to cmake
replaced --enable-debug with -DCMAKE_BUILD_TYPE=Debug in developer-notes
replaced --enable-multiprocess with -DWITH_MULTIPROCESS=ON
replaced --disable-zmq with -DWITH_ZMQ=OFF
2024-09-18 11:04:52 -04:00
Sjors Provoost
af9f987893
doc: update NeedsRedownload() comment 2024-09-17 09:54:18 +02:00
Ava Chow
9f1aa88d4d
Merge bitcoin/bitcoin#30884: streams: cache file position within AutoFile
Some checks are pending
CI / Win64 native, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
CI / test each commit (push) Waiting to run
CI / macOS 13 native, x86_64, no depends, sqlite only, gui (push) Waiting to run
a240e150e8 streams: remove AutoFile::Get() entirely (Pieter Wuille)
e624a9bef1 streams: cache file position within AutoFile (Pieter Wuille)

Pull request description:

  Fixes #30833.

  Instead of relying on frequent `ftell` calls (which appear to cause a significant slowdown on some systems) in XOR-enabled `AutoFile`s, cache the file position within `AutoFile` itself.

ACKs for top commit:
  achow101:
    ACK a240e150e8
  davidgumberg:
    untested reACK a240e150e8
  theStack:
    Code-review ACK a240e150e8

Tree-SHA512: fd3681edc018afaf955dc7a41a0c953ca80d46c1129e3c5b306c87c95aae93b2fe7b900794eb8b6f10491f9211645e7939918a28838295e6873eb226fca7006f
2024-09-16 23:09:16 -04:00
Ava Chow
06329eb134
Merge bitcoin/bitcoin#29436: net: call Select with reachable networks in ThreadOpenConnections
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 13 native, x86_64, no depends, sqlite only, gui (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
e4e3b44e9c net: call `Select` with reachable networks in `ThreadOpenConnections` (brunoerg)
829becd990 addrman: change `Select` to support multiple networks (brunoerg)
f698636ec8 net: add `All()` in `ReachableNets` (brunoerg)

Pull request description:

  This PR changes addrman's `Select` to support multiple networks and change `ThreadOpenConnections` to call it with reachable networks. It can avoid unnecessary `Select` calls and avoid exceeding the max number of tries (100), especially when turning a clearnet + Tor/I2P/CJDNS node to Tor/I2P/CJDNS. Compared to #29330, this approach is "less aggresive". It does not add a new init flag and does not impact address relay.

  I did an experiment of calling `Select` without passing a network until it finds an address from a network that compose 20% ~ 25% of the addrman (limited to 100 tries).

  ![Screenshot 2024-02-14 at 14 37 58](https://github.com/bitcoin/bitcoin/assets/19480819/7b6863a5-d7a6-40b6-87d5-01667c2de66a)

ACKs for top commit:
  achow101:
    ACK e4e3b44e9c
  vasild:
    ACK e4e3b44e9c
  naumenkogs:
    ACK e4e3b44e9c

Tree-SHA512: e8466b72b85bbc2ad8bfb14471eb27d2c50d4e84218f5ede2c15a6fa3653af61b488cde492dbd398f7502bd847e95bfee1abb7e01092daba2236d3ce3d6d2268
2024-09-16 16:49:25 -04:00
Ava Chow
e983ed41d9
Merge bitcoin/bitcoin#30410: rpc, rest: Improve block rpc error handling, check header before attempting to read block data.
6a1aa510e3 rpc: check block index before reading block / undo data (Martin Zumsande)
6cbf2e5f81 rpc: Improve gettxoutproof error when only header is available. (Martin Zumsande)
69fc867ea1 test: add coverage to getblock and getblockstats (Martin Zumsande)
5290cbd585 rpc: Improve getblock / getblockstats error when only header is available. (Martin Zumsande)
e5b537bbdf rest: improve error when only header of a block is available. (Martin Zumsande)

Pull request description:

  Fixes #20978

  If a block was pruned, `getblock` already returns a specific error: "Block not available (pruned data)".
  But if we haven't received the full block yet (e.g. in a race with block downloading after a new block was received headers-first, or during IBD) we just return an unspecific "Block not found on disk" error and log
  `ERROR: ReadBlockFromDisk: OpenBlockFile failed for FlatFilePos(nFile=-1, nPos=0) `
  which suggest something went wrong even though this is a completely normal and expected situation.

  This PR improves the error message and stops calling `ReadRawBlockFromDisk()`, when we already know from the header that the block is not available on disk.
  Similarly, it prevents all other rpcs from calling blockstorage read functions unless we expect the data to be there, so that `LogError()` will only be thrown when there is an actual file system problem.

  I'm not  completely sure if the cause is important enough to change the wording of the rpc error, that some scripts may rely on.
  If reviewers prefer it, an alternative solution would be to keep returning the current "Block not found on disk" error, but return it immediately instead of calling `ReadRawBlockFromDisk`, which would at least prevent the log error and also be an improvement in my opinion.

ACKs for top commit:
  fjahr:
    re-ACK 6a1aa510e3
  achow101:
    ACK 6a1aa510e3
  andrewtoth:
    re-ACK 6a1aa510e3

Tree-SHA512: 491aef880e8298a05841c4bf8eb913ef84820d1ad5415fd17d9b441bff181959ebfdd432b5eb8347dc9c568433f9a2384ca9d84cd72c79d8a58323ca117538fe
2024-09-16 16:17:59 -04:00
Ava Chow
fce9e065c1
Merge bitcoin/bitcoin#28358: Drop -dbcache limit
bb3b980dfd validation: drop maximum -dbcache (Sjors Provoost)

Pull request description:

  Due to recent UTXO set growth, the current maximum value for `-dbcache` of 16GB is ~just months away from being~ insufficient (for those who wish to complete IBD with the UTXO set held in RAM).

  This drops the limit. It also adds a warning that it's up to users to check that they have enough RAM.

  Fixes #28249.

  ---

  A previous version of this PR increased the maximum to 64GB. It also made startup abort if the value provided is too high, rather than quietly round it down. But this didn't get much support.

ACKs for top commit:
  achow101:
    ACK bb3b980dfd
  tdb3:
    ACK bb3b980dfd
  BenWestgate:
    crACK bb3b980dfd.

Tree-SHA512: 8515fff468c2387a0b04bd9523ab1df46d6325738588b7550fabddbb8624817a583d95b95ea246407f9f0ff3e43e760cf7334621bec6af79710176328528a3ef
2024-09-16 15:56:02 -04:00
Ava Chow
8d000b85dd
Merge bitcoin/bitcoin#30868: refactor: add clang-tidy modernize-use-starts-ends-with check
fc7b507e9a tidy: add clang-tidy `modernize-use-starts-ends-with` check (Roman Zeyde)

Pull request description:

ACKs for top commit:
  jonatack:
    re-ACK fc7b507e9a only change since my previous ACK is the commit message
  achow101:
    ACK fc7b507e9a
  stickies-v:
    ACK fc7b507e9a
  hebasto:
    ACK fc7b507e9a, I have reviewed the code and it looks OK.

Tree-SHA512: 334e0ff91b9b108a57cdfc12ee53685b792d377e11124c7c394b8f681a8168a8d65a56c7f884555238e65e97e9ad62ede52b79219ce258979e54abdd76721df1
2024-09-16 15:47:04 -04:00
Ava Chow
3f66642820
Merge bitcoin/bitcoin#30440: Have createNewBlock() return a BlockTemplate interface
a93c171faa Drop unneeded nullptr check from CreateNewBlock() (Sjors Provoost)
dd87b6dff3 Have createNewBlock return BlockTemplate interface (Sjors Provoost)

Pull request description:

  Suggested in https://github.com/bitcoin/bitcoin/pull/29432#issuecomment-2225337100

  An external program that uses the Mining interface may need quick access to some information in the block template, while it can wait a bit longer for the full raw transaction data.

  This would be the case for a Stratum v2 Template Provider which needs to send a [NewTemplate](https://github.com/stratum-mining/sv2-spec/blob/main/07-Template-Distribution-Protocol.md#72-newtemplate-server---client) message message (which doesn't include transactions) as quickly as possible. It does not include the serialized block transactions.

ACKs for top commit:
  achow101:
    ACK a93c171faa
  ryanofsky:
    Code review ACK a93c171faa. Since last review, just rebased with no changes or conflicts
  itornaza:
    Code review ACK a93c171faa
  TheCharlatan:
    Re-ACK a93c171faa

Tree-SHA512: 17cb61eb5548e9d4a69e34dd732f68a06cde2ad3d82c8339efee704c7860d5de144d93b23d6ecd6ee4ec205844e5560ad0f6d3917822fa75bb8e640c5f51af9a
2024-09-16 15:35:09 -04:00
glozow
2bf721e76a
Merge bitcoin/bitcoin#30661: fuzz: Test headers pre-sync through p2p
a97f43d63a fuzz: Add harness for p2p headers sync (marcofleon)
a0eaa4749f Add FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION in PoW check (marcofleon)
a3f6f5acd8 build: Automatically define FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION for fuzz builds (marcofleon)
0c02d4b2bd net_processing: Make MAX_HEADERS_RESULTS a PeerManager option (marcofleon)

Pull request description:

  This PR reopens https://github.com/bitcoin/bitcoin/pull/28043. It's a regression fuzz test for https://github.com/bitcoin/bitcoin/pull/26355 and [a couple bugs](ed6cddd98e) that were addressed in https://github.com/bitcoin/bitcoin/pull/25717. This should help us move forward with the [removal of mainnet checkpoints](https://github.com/bitcoin/bitcoin/pull/25725).

  It seems like the main concern in https://github.com/bitcoin/bitcoin/pull/28043 was the global mock function for proof of work. This PR aims to be an improvement by replacing the previous approach with a fuzz build configured using `FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION`. This ensures that the simplified test code will never be in a release binary. If we agree this is the way to go, there are some other places (for future targets) where this method could be used.

  In this target, PoW isn't being tested, so the goal is to bypass the check and let the fuzzer do its thing. In the other harnesses where PoW is actually being fuzzed, `CheckProofOfWork` is now `CheckProofOfWorkImpl`. So, the only change to that function is in the name.

  More about `FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION` can be found at https://llvm.org/docs/LibFuzzer.html#fuzzer-friendly-build-mode and https://github.com/AFLplusplus/AFLplusplus/blob/stable/docs/fuzzing_in_depth.md#d-modifying-the-target.

ACKs for top commit:
  naumenkogs:
    ACK a97f43d63a
  dergoegge:
    reACK a97f43d63a
  instagibbs:
    tested ACK a97f43d63a
  brunoerg:
    ACK a97f43d63a

Tree-SHA512: 60b0bc6aadd8ca4c39db9cbba2da2debaaf68afcb6a8dd75c1ce48ca9e3996948fda8020930b6771a424e0f7c41b0b1068db4aa7dbe517f8fc152f1f712058ad
2024-09-16 13:59:22 -04:00
glozow
c38e9993de
Merge bitcoin/bitcoin#30286: cluster mempool: optimized candidate search
9ad2fe7e69 clusterlin: only start/use search when enough iterations left (Pieter Wuille)
bd044356ed clusterlin: improve heuristic to decide split transaction (optimization) (Pieter Wuille)
71f2629398 clusterlin: include topological pot subsets automatically (optimization) (Pieter Wuille)
e20fda77a2 clusterlin: reduce computation of unnecessary pot sets (optimization) (Pieter Wuille)
6060a948ca clusterlin bench: add example hard cluster benchmarks (Pieter Wuille)
2965fbf203 clusterlin: track upper bound potential set for work items (optimization) (Pieter Wuille)
9e43e4ce10 clusterlin: use feerate-sorted depgraph in SearchCandidateFinder (Pieter Wuille)
b80e6dfe78 clusterlin: add reordering support for DepGraph (Pieter Wuille)
85a285a306 clusterlin: separate initial search entries per component (optimization) (Pieter Wuille)
e4faea9ca7 clusterlin bench: have low/high iter benchmarks instead of per-iter (Pieter Wuille)

Pull request description:

  Part of cluster mempool: #30289

  Depends on #30126, and was split off from it.

  This improves the candidate search algorithm introduced in the previous PR with a variety of optimizations.

  The resulting search algorithm largely follows Section 2 of [How to linearize your cluster](https://delvingbitcoin.org/t/how-to-linearize-your-cluster/303#h-2-finding-high-feerate-subsets-5), though with a few changes:
  * Connected component analysis is performed inside the search algorithm (creating initial work items per component for each candidate), rather than once at a higher level. This duplicates some work but is significantly simpler in implementation.
  * No ancestor-set based presplitting inside the search is performed; instead, the `best` value is initialized with the best topologically valid set known to the LIMO algorithm before search starts: the better one out of the highest-feerate remaining ancestor set, and the highest-feerate prefix of remaining transactions in `old_linearization`.
  * Work items are represented using an included set *inc* and an undefined set *und*, rather than included and excluded.
  * Potential sets *pot* are not computed for work items with empty *inc*.

  At a high level, the only missing optimization from that post is bottleneck analysis; my thinking is that it only really helps with clusters that are already relatively cheap to linearize (doing so would need to be done at a higher level, not inside the search algorithm).

  ---

  Overview of the impact of each commit here on linearize performance:
  * **[clusterlin bench: have low/high iter benchmarks instead of per-iter](21a184db63)**: no impact
  * **[separate initial search entries per component (optimization)](c84c5c86ba)**: reduce iterations, increase start-up cost
  * **[add reordering support for DepGraph](019ff29609)**: no impact
  * **[use feerate-sorted depgraph in SearchCandidateFinder](8e27dd5a22)**: typically reduce iterations, increase start-up cost
  * **[track upper bound potential set for work items](781e0fb3aa)**: reduce iterations, increase cost per iteration
  * **[reduce computation of unnecessary pot sets](9fe834fa97)**: reduce cost per iteration
  * **[include topological pot subsets automatically](30612710a4)**: reduce iterations, increase cost per iteration
  * **[improve heuristic to decide split transaction](1880c00ab1)**: typically reduce iterations, increase cost per iteration
  * **[only start/use search when enough iterations left](12760a57b3)**: just account for start-up cost as equivalent iterations

ACKs for top commit:
  sdaftuar:
    ACK 9ad2fe7e69
  instagibbs:
    reACK 9ad2fe7e69
  glozow:
    reACK 9ad2fe7e69, just have a question about the docs

Tree-SHA512: 108bcbb0676f36071eb83954059b5f3d6646c745015b644a2a5d7f5a8ac9424c2d01d339fa6318a3aff4cf313308e85bb80b0090899720a3fcba027b8025590a
2024-09-16 13:40:33 -04:00
merge-script
37679b856c
Merge bitcoin/bitcoin#30899: qt: Translations update
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 13 native, x86_64, no depends, sqlite only, gui (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
ae05295761 qt: Translations update (Hennadii Stepanov)

Pull request description:

  The recent translations from Transifex.com fetched with the bitcoin-maintainer-tools/update-translations.py tool.

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

  Translations are updated, while skipping removing translations for 2 languages.

  Related:
  - https://github.com/bitcoin/bitcoin/pull/30827#issuecomment-2349332544

ACKs for top commit:
  achow101:
    ACK ae05295761
  pablomartin4btc:
    ACK ae05295761

Tree-SHA512: 52107dfccaaaef187389ecb114eef4283ff40a3b855de811685fc2d6cfb1d869b2610edf86b25a235266fd7dcb36f693a6816a60639246b5d439c4f6482b2ebd
2024-09-16 09:59:32 +01:00
Roman Zeyde
fc7b507e9a
tidy: add clang-tidy modernize-use-starts-ends-with check 2024-09-14 20:33:32 +03:00
Pieter Wuille
a240e150e8 streams: remove AutoFile::Get() entirely
Co-Authored-By: David Gumberg <davidzgumberg@gmail.com>
2024-09-13 21:59:29 -04:00
Ava Chow
0c4ff18ee9
Merge bitcoin/bitcoin#30896: kernel: Move background load thread to node context
Some checks failed
CI / test each commit (push) Has been cancelled
CI / macOS 13 native, x86_64, no depends, sqlite only, gui (push) Has been cancelled
CI / Win64 native, VS 2022 (push) Has been cancelled
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Has been cancelled
bc7900f33d kernel: Move background load thread to node context (TheCharlatan)

Pull request description:

  The thread handle is never used by the ChainstateManager, so move it out and into the node context. Users of the kernel library now no longer have to manually join the thread when destructing the ChainstateManager.

ACKs for top commit:
  maflcko:
    ACK bc7900f33d 🔄
  achow101:
    ACK bc7900f33d
  ryanofsky:
    Code review ACK bc7900f33d. Nice cleanup
  jonatack:
    Light ACK bc7900f33d
  stickies-v:
    ACK bc7900f33d

Tree-SHA512: add9c4823731324e3db50f95e023e99d55db7cc75c69083ae7c9c2157e5540968caa6cf10674aa4901f91366b02ebb1ff18bb977fec0a46431e2196448958b9d
2024-09-13 17:58:16 -04:00
Ava Chow
71af7435ef
Merge bitcoin/bitcoin#30233: refactor: move m_is_inbound out of CNodeState
07f4cebe57 refactor: move m_is_inbound out of CNodeState (Sergi Delgado Segura)

Pull request description:

  `m_is_inbound` cannot be changed throughout the life of a `Peer`. However, we are currently storing it in `CNodeState`, which requires locking `cs_main` in order to access it. This can be moved to the outside scope and only require `m_peer_mutex`.

  This is a refactor in preparation for Erlay reworks.

ACKs for top commit:
  maflcko:
    ACK 07f4cebe57 🗞
  achow101:
    ACK 07f4cebe57
  marcofleon:
    ACK 07f4cebe57
  naumenkogs:
    ACK 07f4cebe57

Tree-SHA512: bcc77135646c697204a4605971774cb3ccdf11b3e363a7339bfb4d1678de1681d6ca642dc467f7d71834a94dd56e05367e7fd32a3e6dc6be30c89342f39bf695
2024-09-13 15:40:43 -04:00
Hennadii Stepanov
ae05295761
qt: Translations update
The recent translations from Transifex.com 28.x fetched with the
bitcoin-maintainer-tools/update-translations.py tool.
2024-09-13 17:26:39 +01:00
merge-script
fea550b480
Merge bitcoin/bitcoin#30890: doc: unit test runner help fixup and improvements
282f0e9255 Unit test runner documentation fix and improvements (Jon Atack)

Pull request description:

  Running `test_bitcoin --help` prints the list of arguments that may be passed, not the list of tests, so fix that.

  Improve the content and order of the unit test documentation.

ACKs for top commit:
  pablomartin4btc:
    re-ACK 282f0e9255
  tdb3:
    re ACK 282f0e9255

Tree-SHA512: 0d25108ab641bcd9b53f99d139afeec90a34f44d5b00c3c677f7539d87782440a28fadc348663b8c28ace43552834737b9c1e8f5517c68edc8547695a9cb5063
2024-09-13 16:58:38 +01:00
Jon Atack
282f0e9255 Unit test runner documentation fix and improvements
- Running `test_bitcoin --help` prints the list of arguments that may be passed,
  not the list of tests, so fix that.

- Improve the content and order of the unit test documentation.
2024-09-13 08:54:51 -06:00
Martin Zumsande
6a1aa510e3 rpc: check block index before reading block / undo data
This avoids low-level log errors that are supposed to only occur when
there is an actual problem with the block on disk missing unexpectedly,
but not in the case where the block and/or undo data are expected not to be there.

It changes behavior such that in the first case (block index indicates
data is available but retrieving it fails) an error is thrown.

It also adjusts a functional tests that tried to simulate not
having undo data (but having block data) by deleting the undo file.
This situation should occur reality because block and undo data are pruned together.
Instead, test this situation with a block that hasn't been connected.
2024-09-13 10:50:49 -04:00
Martin Zumsande
6cbf2e5f81 rpc: Improve gettxoutproof error when only header is available. 2024-09-13 10:50:49 -04:00
Martin Zumsande
5290cbd585 rpc: Improve getblock / getblockstats error when only header is available.
This improves the error message of the getblock and getblockstats rpc and prevents calls to
ReadRawBlockFromDisk(), which are unnecessary if we know
from the header nStatus field that the block is not available.
2024-09-13 10:50:49 -04:00
Martin Zumsande
e5b537bbdf rest: improve error when only header of a block is available.
This avoids calling ReadRawBlockFromDisk() when the block is expected
not to be available because we haven't downloaded it yet and only know
the header.
2024-09-13 10:50:43 -04:00
TheCharlatan
bc7900f33d
kernel: Move background load thread to node context
The thread handle is never used by the ChainstateManager, so move it out
and into the node context. Users of the kernel library now no longer
have to manually join the thread when destructing the ChainstateManager.
2024-09-13 16:10:31 +02:00
Pieter Wuille
e624a9bef1 streams: cache file position within AutoFile 2024-09-13 07:35:41 -04:00
Sjors Provoost
a93c171faa
Drop unneeded nullptr check from CreateNewBlock() 2024-09-13 10:14:53 +02:00
Sjors Provoost
dd87b6dff3
Have createNewBlock return BlockTemplate interface
An external program that uses the Mining interface may need quick access to some information in the block template, while it can wait a bit longer for the full raw transaction data.

This would be the case for a Stratum v2 Template Provider which needs to send a NewTemplate message (which doesn't include transactions) as quickly as possible.
2024-09-13 10:14:53 +02:00
furszy
a965f2bc07
gui: fix crash when closing wallet
The crash occurs because 'WalletController::removeAndDeleteWallet' is called
twice for the same wallet model: first in the GUI's button connected function
'WalletController::closeWallet', and then again when the backend emits the
'WalletModel::unload' signal.

This causes the issue because 'removeAndDeleteWallet' inlines an
erase(std::remove()). So, if 'std::remove' returns an iterator to the end
(indicating the element wasn't found because it was already erased), the
subsequent call to 'erase' leads to an undefined behavior.
2024-09-12 19:25:45 -03:00
Pieter Wuille
9ad2fe7e69 clusterlin: only start/use search when enough iterations left 2024-09-12 15:15:36 -04:00
Pieter Wuille
bd044356ed clusterlin: improve heuristic to decide split transaction (optimization)
Empirically, this approach seems to be more efficient in common real-life
clusters, and does not change the worst case.

Co-Authored-By: Suhas Daftuar <sdaftuar@gmail.com>
2024-09-12 15:15:36 -04:00
Pieter Wuille
71f2629398 clusterlin: include topological pot subsets automatically (optimization)
Automatically add topologically-valid subsets of the potential set pot
to inc. It can be proven that these must be part of the best reachable
topologically-valid set from that work item.

This is a crucial optimization that (apparently) reduces the maximum
number of iterations from ~2^(N-1) to ~sqrt(2^N).

Co-Authored-By: Suhas Daftuar <sdaftuar@gmail.com>
2024-09-12 15:15:36 -04:00
Pieter Wuille
e20fda77a2 clusterlin: reduce computation of unnecessary pot sets (optimization)
Keep track of which transactions in the graph have an individual
feerate that is better than the best included set so far. Others do not
need to be added to the pot set, as they cannot possibly help beating
best.
2024-09-12 15:15:36 -04:00
Pieter Wuille
6060a948ca clusterlin bench: add example hard cluster benchmarks
Co-Authored-By: Suhas Daftuar <sdaftuar@gmail.com>
2024-09-12 15:15:36 -04:00
Pieter Wuille
2965fbf203 clusterlin: track upper bound potential set for work items (optimization)
In each work item, keep track of a conservative overestimate of the best
possible feerate that can be reached from it, and then use these to avoid
exploring hopeless work items.
2024-09-12 15:15:36 -04:00
Pieter Wuille
9e43e4ce10 clusterlin: use feerate-sorted depgraph in SearchCandidateFinder
This is a requirement for a future commit, which will rely on quickly iterating
over transaction sets in decreasing individual feerate order.
2024-09-12 15:15:36 -04:00
Pieter Wuille
b80e6dfe78 clusterlin: add reordering support for DepGraph
Add a DepGraph(depgraph, reordering) function that constructs a new DepGraph
corresponding to an old one, but with its transactions is a modified order
(given as a vector from old to new positions).

Also use this reordering feature inside DepGraphFormatter::Unser, which needs
a small modification so that its reordering mapping is old-to-new (rather than
the new-to-old it used before).
2024-09-12 15:15:36 -04:00
Pieter Wuille
85a285a306 clusterlin: separate initial search entries per component (optimization)
Before this commit, the worst case for linearization involves clusters which
break apart in several smaller components after the first candidate is
included in the output linearization.

Address this by never considering work items that span multiple components
of what remains of the cluster.
2024-09-12 15:15:36 -04:00
Pieter Wuille
e4faea9ca7 clusterlin bench: have low/high iter benchmarks instead of per-iter 2024-09-12 15:15:36 -04:00
Ryan Ofsky
e46bebb444
Merge bitcoin/bitcoin#30546: util: Use consteval checked format string in FatalErrorf, LogConnectFailure
fa5bc450d5 util: Use compile-time check for LogConnectFailure (MarcoFalke)
fa7087b896 util: Use compile-time check for FatalErrorf (MarcoFalke)
faa62c0112 util: Add ConstevalFormatString (MarcoFalke)
fae7b83eb5 lint: Remove forbidden functions from lint-format-strings.py (MarcoFalke)

Pull request description:

  The `test/lint/lint-format-strings.py` was designed to count the number of format specifiers and assert that they are equal to the number of parameters passed to the format function. The goal seems reasonable, but the implementation has many problems:

  * It is written in Python, meaning that C++ code can not be parsed correctly. Currently it relies on brittle regex and string parsing.
  * Apart from the parsing errors, there are also many logic errors. For example, `count_format_specifiers` allows a mix of positional specifiers and non-positional specifiers, which can lead to runtime format bugs. Also, `count_format_specifiers` silently skipped over "special" format specifiers, which are valid in tinyformat, which again can lead to runtime format bugs being undetected.
  * The brittle logic has a history of breaking in pull requests that are otherwise fine. This causes the CI to fail and the pull request being blocked from progress until the bug in the linter is fixed, or the code is rewritten to work around the bug.
  * It is only run in the CI, or when the developer invokes the script. It would be better if the developer got the error message at compile-time, directly when writing the code.

  Fix all issues by using a `consteval` checked format string in `FatalErrorf` and `LogConnectFailure`.

  This is the first step toward https://github.com/bitcoin/bitcoin/issues/30530 and a follow-up will apply the approach to the other places.

ACKs for top commit:
  stickies-v:
    re-ACK fa5bc450d5
  l0rinc:
    ACK fa5bc450d5
  hodlinator:
    ACK fa5bc450d5
  ryanofsky:
    Code review ACK fa5bc450d5

Tree-SHA512: d6189096b16083143687ed1b1559cf4f92f97dd87bc5d00673e44f4fb9fce7bb7b215cfdfc39b6e6a24f0b75a79a03ededce966639e554f7172e1fc22cf015ae
2024-09-12 13:21:53 -04:00
Ryan Ofsky
be768dbd18
Merge bitcoin/bitcoin#30618: test: support std::optional in BOOST_CHECK_* and increase FromUserHex fuzz feature coverage
1eac96a503 Compare FromUserHex result against other hex validators and parsers (Lőrinc)
19947863e1 Use BOOST_CHECK_EQUAL for optional, arith_uint256, uint256, uint160 (Lőrinc)
743ac30e34 Add std::optional support to Boost's equality check (Lőrinc)

Pull request description:

  Enhanced `FromUserHex` coverage by:

  * Added `std::optional` support to `BOOST_CHECK_EQUAL`, allowing direct comparisons of `std::optional<T>` with other `T` expected values.
  * Increased fuzz testing for hex parsing to validate against other hex validators and parsers.

  ----

  * Use BOOST_CHECK_EQUAL for https://github.com/bitcoin/bitcoin/pull/30569#discussion_r1706637780 arith_uint256, uint256, uint160

  Example error before:
  > unknown location:0: fatal error: in "validation_chainstatemanager_tests/chainstatemanager_args": std::bad_optional_access: bad_optional_access
  test/validation_chainstatemanager_tests.cpp:781: last checkpoint

  after:
  > test/validation_chainstatemanager_tests.cpp:801: error: in "validation_chainstatemanager_tests/chainstatemanager_args": check set_opts({"-assumevalid=0"}).assumed_valid_block == uint256::ZERO has failed [std::nullopt != 0000000000000000000000000000000000000000000000000000000000000000]

ACKs for top commit:
  stickies-v:
    re-ACK 1eac96a503
  ryanofsky:
    Code review ACK 1eac96a503. Only changes since last review were auto type and fuzz test tweaks.
  hodlinator:
    ACK 1eac96a503

Tree-SHA512: f1d2c65f0ee4e97830700be5b330189207b11ed0c89a8cebf0f97d43308402a6b3732e10130c79a0c044f7d2eeabfb5359990825aadf02c4ec19428dcd982b00
2024-09-12 12:36:37 -04:00
merge-script
24817e8b15
Merge bitcoin/bitcoin#30814: kernel: Create usable static kernel library
0dd16d7118 build: Add a pkg-config file for libbitcoinkernel (TheCharlatan)
45be32f838 build: Produce a usable static kernel library (TheCharlatan)

Pull request description:

  Since the move to cmake, the kernel static library that is installed after a cmake --install build is unusable. It lacks symbols for the internal libraries, besides those defined in the kernel library target.

  Fix this by explicitly installing all the required internal static libraries. To make usage of these installed libraries easy, add a pkg-config file that can be used during linking.

  This patch can be tested with:

  ```
  cmake -B build -DBUILD_SHARED_LIBS=OFF -DBUILD_KERNEL_LIB=ON
  cmake --build build
  cmake --install build
  g++ -std=c++20 -o test_chainstate src/bitcoin-chainstate.cpp -I/home/drgrid/bitcoin/src $(pkg-config --libs --static libbitcoinkernel)
  ```

  Attempts to solve #30801

ACKs for top commit:
  hebasto:
    ACK 0dd16d7118.
  fanquake:
    ACK 0dd16d7118 - this looks like a good place to start.
  ryanofsky:
    Code review ACK 0dd16d7118

Tree-SHA512: 92f7bc959584bdc595f4aa6d0ab133355481075fe8564224fd7ac122fd7bdd75f98cf26ef0a6a7d84fd552d2258ddca1b674eca91122469a58bacc5f0a0ec2ef
2024-09-12 16:39:34 +01:00
Sergi Delgado Segura
07f4cebe57 refactor: move m_is_inbound out of CNodeState
`m_is_inbound` cannot be changed throughout the life of a `Peer`. However, we
are currently storing it in `CNodeState`, which requires locking `cs_main` in
order to access it. This can be moved to the outside scope and only require
`m_peer_mutex`.

This is a refactor in preparation for Erlay reworks.
2024-09-12 11:20:44 -04:00
Hennadii Stepanov
23eedc5d1e
build: Skip secp256k1 ctime tests when tests are not being built
Co-authored-by: fanquake <fanquake@gmail.com>
2024-09-12 14:24:26 +01:00
MarcoFalke
fa5bc450d5
util: Use compile-time check for LogConnectFailure 2024-09-12 15:01:35 +02:00
MarcoFalke
fa7087b896
util: Use compile-time check for FatalErrorf 2024-09-12 15:01:20 +02:00
MarcoFalke
faa62c0112
util: Add ConstevalFormatString
The type is used to wrap a format string once it has been compile-time
checked to contain the right number of format specifiers.
2024-09-12 15:00:53 +02:00
merge-script
85833cf05f
Merge bitcoin/bitcoin#30847: test: Drop no longer needed workarounds
5c80192ff6 test: Drop no longer needed workarounds (Hennadii Stepanov)

Pull request description:

  This PR deletes the workarounds introduced in https://github.com/bitcoin/bitcoin/pull/16564 and https://github.com/bitcoin/bitcoin/pull/15382, as `ctest` skips these cases gracefully: 5c80192ff6/src/test/CMakeLists.txt (L201-L203)

ACKs for top commit:
  kevkevinpal:
    ACK [5c80192](5c80192ff6)
  fanquake:
    ACK 5c80192ff6. Looks correct:

Tree-SHA512: c47c606ecf7d64016b3c6353c3d4898350edc2caeac494dfd44484417f500a73f0c88c39f0f24651f3a02ef31ed9ca5c70d938bb9a8ca1eea54927e4d6a8fcd2
2024-09-12 11:28:27 +01:00
merge-script
11e2f9fff4
Merge bitcoin/bitcoin#30835: build: Introduce "Kernel" installation component
7b04fabe2d build: Introduce "Kernel" installation component (Hennadii Stepanov)

Pull request description:

  This PR enables building and installing only `libbitcoinkernel`, without the need to disable other targets during the project build system generation:

  ```
  $ rm -rf build && cmake -B build -DBUILD_KERNEL_LIB=ON
  $ cmake --build build --target bitcoinkernel
  $ cmake --install build --component Kernel --prefix /home/hebasto/INSTALL
  -- Install configuration: "RelWithDebInfo"
  -- Installing: /home/hebasto/INSTALL/lib/libbitcoinkernel.so
  ```

  Please note, that only the `bitcoinkernel` target is being built.

  Related to https://github.com/bitcoin/bitcoin/issues/30801 and https://github.com/bitcoin/bitcoin/pull/30814.

ACKs for top commit:
  TheCharlatan:
    ACK 7b04fabe2d
  ryanofsky:
    Code review ACK 7b04fabe2d

Tree-SHA512: eac114dde059e47c91938a4a9108fc0fc693b5342ed3b6ecb971615be8ad3225b9985aae12d6ad18e673edf1bd39a5ecf259c1b61734f221669091bf2ce93a67
2024-09-12 10:58:52 +01:00
merge-script
db8350b0e3
Merge bitcoin/bitcoin#30803: build: Minor build system fixes and amendments
1cc93fe7b4 build: Delete dead code that implements `IF_CHECK_FAILED` option (Hennadii Stepanov)
341ad23809 build: Delete MSVC special case for `BUILD_FOR_FUZZING` option (Hennadii Stepanov)
fdad128b52 build: Stop enabling CMake's CMP0141 policy (Hennadii Stepanov)
b2a6f545b4 doc: Drop `ctest` command from Windows cross-compiling instructions (Hennadii Stepanov)
73b618582d build: Print `CMAKE_CXX_COMPILER_ARG1` in summary (Hennadii Stepanov)
f03c942095 build, test: Add missed log options (Hennadii Stepanov)
6f2cb0eafd doc: Amend comment about ZeroMQ config files (Hennadii Stepanov)

Pull request description:

  This PR addresses the following comments:
  - https://github.com/bitcoin/bitcoin/pull/30454#discussion_r1742342524
  - https://github.com/bitcoin/bitcoin/pull/30454#discussion_r1728692369
  - https://github.com/bitcoin/bitcoin/pull/30454#discussion_r1736110362
  - https://github.com/bitcoin/bitcoin/pull/30454#discussion_r1742931121
  - https://github.com/bitcoin/bitcoin/pull/30454#discussion_r1747723657
  - https://github.com/bitcoin/bitcoin/pull/30454#discussion_r1742328675
  - https://github.com/bitcoin/bitcoin/pull/30454#discussion_r1723106474

ACKs for top commit:
  sipsorcery:
    tACK 1cc93fe7b4 (win11 msvc).
  maflcko:
    re-ACK 1cc93fe7b4

Tree-SHA512: a390797bb4d3b7eb9163653b6c9c324e7a01090f6cdda74df7349a24a5c4a2084e5912878747f56561315afc70cae9adb1c363f47ceb0af96004ea591d25171b
2024-09-12 10:30:06 +01:00