44176 Commits

Author SHA1 Message Date
l0rinc
23190f2bc1
Merge a06a674b4361061432d20dc21f183b7eac0175b3 into 5f4422d68dc3530c353af1f87499de1c864b60ad 2025-03-17 09:50:15 +07:00
merge-script
5f4422d68d
Merge bitcoin/bitcoin#32010: qa: Fix TxIndex race conditions
3301d2cbe8c3b76c97285d75fa59637cb6952d0b qa: Wait for txindex to avoid race condition (Hodlinator)
9bfb0d75ba10591cc6c9620f9fd1ecc0e55e7a48 qa: Remove unnecessary -txindex args (Hodlinator)
7ac281c19cd3d11f316dbbb3308eabf1ad4f26d6 qa: Add missing coverage of corrupt indexes (Hodlinator)

Pull request description:

  - Add synchronization in 3 places where if the Transaction Index happens to be slow, we get rare test failures when querying it for transactions (one such case experienced on Windows, prompting investigation).
  - Remove unnecessary TxIndex initialization in some tests.
  - Add some test coverage where TxIndex aspect could be tested in feature_init.py.

ACKs for top commit:
  fjahr:
    re-ACK 3301d2cbe8c3b76c97285d75fa59637cb6952d0b
  mzumsande:
    Code Review ACK 3301d2cbe8c3b76c97285d75fa59637cb6952d0b
  furszy:
    Code review ACK 3301d2cbe8c3b76c97285d75fa59637cb6952d0b
  Prabhat1308:
    Concept ACK [`3301d2c`](3301d2cbe8)

Tree-SHA512: 7c2019e38455f344856aaf6b381faafbd88d53dc88d13309deb718c1dcfbee4ccca7c7f1b66917395503a6f94c3b216a007ad432cc8b93d0309db9805f38d602
2025-03-17 10:28:14 +08:00
merge-script
cd8089c20b
Merge bitcoin/bitcoin#32069: test: fix intermittent failure in wallet_reorgsrestore.py
36b0713edc4655f6e0c291975d6d280fbc89cf2e test: fix intermittent failure in wallet_reorgsrestore.py (furszy)

Pull request description:

  In response to #32066 intermittent failure.

  Wait until the node's process has fully stopped before starting a new instance of it.
  Same behavior as in the [tool_wallet.py](698f86964c/test/functional/tool_wallet.py (L540)) test.

ACKs for top commit:
  maflcko:
    lgtm ACK 36b0713edc4655f6e0c291975d6d280fbc89cf2e
  Chand-ra:
    tACK [36b0713](36b0713edc)

Tree-SHA512: 8e01493ef1fb58589479f3e12d7429d02ca75a2183d5f79d3b6a2fbf13334878926274a20857f1b4729afc1d30b65789daed229ce06ba236b91d949b73f45d5a
2025-03-16 22:29:14 +08:00
merge-script
70a0ee89c6
Merge bitcoin/bitcoin#32063: test: fix intermittent failure in p2p_orphan_handling.py
02942056fd861581503a8a35a06dcf22d4ba1473 test: fix intermittent failure in p2p_orphan_handling.py (Martin Zumsande)

Pull request description:

  If the mocktime is bumped before the node has successfully disconnected the peer, the requests for both parents could be spread over two GETDATAS: The first time `GetRequestsToSend` is invoked it would only request one tx from peer2, because the other one would only be available after peer1  was disconnected and its outstanding txrequest cleared.
  So two GETDATAs would be sent, which would make the test fail.

  Fixes #31700

ACKs for top commit:
  maflcko:
    lgtm ACK 02942056fd861581503a8a35a06dcf22d4ba1473
  instagibbs:
    ACK 02942056fd

Tree-SHA512: 769200898345da197d86d673d9506f08f0a64b72a456e7e7c988ac37450d9c54ec65da1c8447c566c8578f7cfccdc5723ea680e636bfbe0b3d38265e5ef57774
2025-03-16 22:27:40 +08:00
merge-script
83a9e55ae1
Merge bitcoin/bitcoin#32070: build: use make < 3.82 syntax for define directive
9157d9e449870851ef455e077249ac46fc2df24c build: use make < 3.82 syntax for define directive (Sjors Provoost)

Pull request description:

  From the GNU make 3.82 [release announcement](https://lists.gnu.org/archive/html/info-gnu/2010-07/msg00023.html) (2010):

  > The 'define' make directive now allows a variable assignment operator
    after the variable name, to allow for simple, conditional, or appending
    multi-line variable assignment.

  macOS ships with 3.81 (2006). This caused the multiprocess config options to be ignored.

  Fixes #32068

ACKs for top commit:
  ryanofsky:
    Code review ACK 9157d9e449870851ef455e077249ac46fc2df24c. This is a pretty unusual bug and I don't understand how it wasn't causing any errors with make 3.81, just causing the flags to be ignored.

Tree-SHA512: a07322e25ef18296264379a2704f31c654df196d3ea09fe712885c38813e54d758a2d603ee9f7a302da8011fba6d139aa30a356175ca99df728ade2572a87560
2025-03-16 17:22:19 +08:00
merge-script
ca05b28710
Merge bitcoin/bitcoin#31859: test: Rename send_message to send_without_ping
fa9cf38ab666b50b0d8e82cb17f9e5a8a613547d scripted-diff: test: Rename send_message to send_without_ping (MarcoFalke)
fa4356717d6efcc41709f62a5116c62519d1a853 test: Prefer send_and_ping over send_message+sync_with_ping (MarcoFalke)

Pull request description:

  `send_message` is problematic, because it is easy to forget a `sync_with_ping` (or other `wait_until`), leading to intermittent test failures. (Example: https://github.com/bitcoin/bitcoin/pull/31837#discussion_r1950370246)

  There are more uses of `send_and_ping` in the codebase than `send_message`, so in most cases `send_and_ping` is needed anyway.

  For the remaining cases, clearly document that no sync happens by renaming `send_message` to `send_without_ping`.

ACKs for top commit:
  instagibbs:
    ACK fa9cf38ab6

Tree-SHA512: 31caa6568d292ae3d3dda931a94aaa30cc1205ec2ef537a484393eb55687f86c212f1e751ac4a7636610bdf591502a50995dc63bf02f97be9fdc482072160b07
2025-03-16 17:08:12 +08:00
merge-script
ab2df1726e
Merge bitcoin/bitcoin#31917: fuzz: provide more realistic values to the base58(check) decoders
d5537c18a9034647ba4c9ed4008abd7fee33989e fuzz: make sure DecodeBase58(Check) is called with valid values more often (Lőrinc)
bad1433ef2b5b02ac4b1c6c1d9482c513e5b2192 fuzz: Always restrict base conversion input lengths (Lőrinc)

Pull request description:

  This is a follow-up to https://github.com/bitcoin/bitcoin/pull/30746, expanding coverage by:
  * restricting every input for the base58 conversions, capping max sizes to `100` instead of `1000` or all available input (suggested by marcofleon in https://github.com/bitcoin/bitcoin/pull/30746#discussion_r1963718683) since most actual usage has lengths of e.g. `21`, `34`, `78`.
  * providing more valid values to the decoder (suggested by maflcko in https://github.com/bitcoin/bitcoin/pull/30746#discussion_r1957847712) by randomly providing a random input or a valid encoded one; this also enables unifying the roundtrip tests to a single roundtrip per fuzz.

ACKs for top commit:
  mzumsande:
    Code Review / lightly tested ACK d5537c18a9034647ba4c9ed4008abd7fee33989e
  maflcko:
    review ACK d5537c18a9034647ba4c9ed4008abd7fee33989e 🚛

Tree-SHA512: 50365654cdac8a38708a7475eaa43396642b7337e2ee8999374c3faafff4f05457abc1a54c701211e0ed24d36c12af77bcad17b49695699be42664f2be660659
2025-03-16 17:02:58 +08:00
merge-script
51a20e56c2
Merge bitcoin/bitcoin#31977: test: Use rpc_deprecated only for testing deprecation
2819c514825577dc8d73690882f25117d412ed9f test: Use rpc_deprecated only for testing deprecation (Fabian Jahr)

Pull request description:

  The comment in `functional/rpc_deprecated.py` says "This test should be used to verify correct behaviour of deprecated RPC methods with and without the -deprecatedrpc flags." I think we can get rid of the "with" part since we can assume that every deprecated RPC is already tested in at least one other functional test. (I didn't look but I could verify in our coverage if someone has doubts about that.) In order for this test to continue working, the flag will need to be used there. Otherwise this seems to prescribe copy+pasting a basic test from another file and I don't see a good reason for that.

ACKs for top commit:
  maflcko:
    lgtm ACK 2819c514825577dc8d73690882f25117d412ed9f
  janb84:
    re ACK [2819c51](2819c51482)
  polespinasa:
    reACK 2819c514825577dc8d73690882f25117d412ed9f

Tree-SHA512: 96edfd07be863ad19f99feb27afbc2c3ad53560c93c93eac8de8d766ad8c46e5aa02fd013fec99af794cbe9adca8e459d5b80b454caea7e67b2388003e010bb6
2025-03-16 16:59:39 +08:00
Fabian Jahr
2819c51482
test: Use rpc_deprecated only for testing deprecation 2025-03-14 22:48:24 +01:00
Sjors Provoost
9157d9e449
build: use make < 3.82 syntax for define directive
From the GNU make 3.82 release announcement:

* The 'define' make directive now allows a variable assignment operator
  after the variable name, to allow for simple, conditional, or appending
  multi-line variable assignment.

macOS ships with 3.81. This caused the multiprocess config options
to be ignored.

Fixes #32068

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2025-03-14 16:19:45 +01:00
furszy
36b0713edc
test: fix intermittent failure in wallet_reorgsrestore.py
Wait until the node's process has fully stopped before starting a new instance.

Since the same code is used in tool_wallet.py, this consolidates the behavior
into a 'kill_process()' function.
2025-03-14 11:06:44 -04:00
MarcoFalke
fa9cf38ab6
scripted-diff: test: Rename send_message to send_without_ping
send_message only drops the bytes in a buffer and a sync is needed to
avoid intermittent test issues. Change the name of the method to make
this more apparent during review.

-BEGIN VERIFY SCRIPT-
 sed -i 's/send_message(/send_without_ping(/g' $( git grep -l 'send_message(' )
-END VERIFY SCRIPT-
2025-03-14 12:45:20 +01:00
MarcoFalke
fa4356717d
test: Prefer send_and_ping over send_message+sync_with_ping
Also, add an explanation for the preference in the docs.
2025-03-14 12:44:34 +01:00
merge-script
698f86964c
Merge bitcoin/bitcoin#31961: Require sqlite when building the wallet
36b6f36ac4724cb2c9ed0e25314c3bbf55e4ebb8 build: require sqlite when building the wallet (Sjors Provoost)

Pull request description:

  Require that sqlite is available in order to compile the wallet. Removes instances of `USE_SQLITE` since it is no longer possible to not have sqlite available.

  The `NO_SQLITE` option is dropped from depends.

  This is another step towards dropping the legacy wallet, extracted from #31250.

ACKs for top commit:
  m3dwards:
    ACK 36b6f36ac4724cb2c9ed0e25314c3bbf55e4ebb8
  davidgumberg:
    crACK 36b6f36ac4
  hebasto:
    re-ACK 36b6f36ac4724cb2c9ed0e25314c3bbf55e4ebb8.

Tree-SHA512: 870a0135671c80c4f28602119eb8637a1ed43b51b1673bfe88425782fb62ec6ef0f3d6baf0d5984d6a243779b0f63423fd4c4dc324ef87bffba13d63e05ad793
2025-03-14 11:23:35 +08:00
merge-script
f4b3a5858a
Merge bitcoin/bitcoin#32064: build: Remove manpages when making MacOS app
80b5e7f2cb7fbfbd724e1f52b00c0e72b79a200b build: Remove manpages when making MacOS app (Ava Chow)

Pull request description:

  When creating the MacOS app, the only file that should be in `Bitcoin-Qt.app/Contents/MacOS` is `Bitcoin-Qt`. Since #31844, there was also a `share/` containing the manpage for bitcoin-qt. This manpage is not useful to app users, and it is also causing code signing issues. Thus the directory should be removed when making the app.

  Fixes https://github.com/bitcoin/bitcoin/issues/32052#issuecomment-2723007926

ACKs for top commit:
  fanquake:
    ACK 80b5e7f2cb7fbfbd724e1f52b00c0e72b79a200b

Tree-SHA512: fd15b7f99737484e40d31c583e01acc7470d038b0c584dfaefecc740811565ceee048913b6e5e37e7935b74d8100dc8323aed3f69d9a6baa5f434754009eb18c
2025-03-14 11:13:58 +08:00
merge-script
92f553eaa9
Merge bitcoin/bitcoin#32038: depends: remove NO_HARDEN option
5dfef6b9b379f51e69f2a358c05ae3c3e8a26e13 depends: remove NO_HARDEN option (fanquake)

Pull request description:

  This was only needed to work around a (Libtool related iirc) Windows issue, when hardening was disabled. I can no-longer recreate this failure, so it'd be good to remove this Windows carveout.

ACKs for top commit:
  davidgumberg:
    crACK 5dfef6b9b379f51e
  laanwj:
    Code review ACK 5dfef6b9b379f51e69f2a358c05ae3c3e8a26e13

Tree-SHA512: 38657f09c537ba02ecaf0676d47087a835283cabfc81ad9b2d5e68858dcd7a610b6a1df6730920d40b48be2bbc55a45d6b8aea4364884b5f1c1bd12126940f5b
2025-03-14 11:02:02 +08:00
Ava Chow
80b5e7f2cb build: Remove manpages when making MacOS app 2025-03-13 17:56:09 -07:00
merge-script
1b251f6b67
Merge bitcoin/bitcoin#31649: consensus: Remove checkpoints (take 2)
3c5d1a468199722da620f1f3d8ae3319980a46d5 Remove checkpoints (marcofleon)
632ae47372de90064f61e3e622d8da766d1d12de update comment on MinimumChainWork check (marcofleon)

Pull request description:

  The headers presync logic (only downloading headers that lead to a chain with sufficient work, implemented in https://github.com/bitcoin/bitcoin/pull/25717) should be enough to prevent memory DoS using low-work headers. Therefore, we no longer have any use for checkpoints.

  All checkpoints and checkpoint logic are removed in a single commit, to make it easy to revert if necessary.

  Some previous discussion can be found in https://github.com/bitcoin/bitcoin/pull/25725. The conclusion at the time was that more testing of the presync logic was needed. Now that we have [unit](https://github.com/bitcoin/bitcoin/blob/master/src/test/headers_sync_chainwork_tests.cpp), [functional](https://github.com/bitcoin/bitcoin/blob/master/test/functional/p2p_headers_sync_with_minchainwork.py), and [fuzz](https://github.com/bitcoin/bitcoin/blob/master/src/test/fuzz/p2p_headers_presync.cpp) tests for this logic, it seems safe to move forward with checkpoint removal.

ACKs for top commit:
  Sjors:
    Code review ACK 3c5d1a468199722da620f1f3d8ae3319980a46d5
  instagibbs:
    reACK 3c5d1a468199722da620f1f3d8ae3319980a46d5
  dergoegge:
    ACK 3c5d1a468199722da620f1f3d8ae3319980a46d5

Tree-SHA512: 051a6f9b82cd0262f4d3be4403906812fc6d1be022731fac16bb1c02bca471f31dfc7fc4b834ab2469e8f087265a6d99e84a1d665823cda1b112363a8e8f337d
2025-03-14 08:09:15 +08:00
Martin Zumsande
02942056fd test: fix intermittent failure in p2p_orphan_handling.py
If we bump the mocktime before the node has successfully disconnected
the peer, the requests for both parents could be spread over
two GETDATAS, which would make the test fail.
2025-03-13 17:59:02 -04:00
glozow
5c2f04413e
Merge bitcoin/bitcoin#32049: contrib: Fix gen-bitcoin-conf.sh
a24419f8bed5e1145ce171dbbdad957750585471 contrib: Fix `gen-bitcoin-conf.sh`. (David Gumberg)

Pull request description:

  In #31118, the format of bitcoind's `--help` output changed slightly in a way that breaks `gen-bitcoin-conf.sh`, modify the script to accommodate the new format, by starting after the line that says "Options:" and stripping the `-help` options and descriptions from the script output.

  Before this PR, all options above `-help` were excluded from the example bitcoin.conf.

ACKs for top commit:
  mabu44:
    Tested ACK a24419f8bed5e1145ce171dbbdad957750585471
  glozow:
    ACK a24419f8bed5e1145ce171dbbdad957750585471
  rkrux:
    tACK a24419f8bed5e1145ce171dbbdad957750585471
  BrandonOdiwuor:
    crACK a24419f8bed5e1145ce171dbbdad957750585471

Tree-SHA512: 2ef697166d0b37b61ec1a20e357b91d611c932a0e453c4669f74ab69e6310ea1776dce09c1b77e82746072265763cb0c750e6df4c8b4a7d39068fc03f97b221b
2025-03-13 16:58:44 -04:00
Ryan Ofsky
5d96c2eab9
Merge bitcoin/bitcoin#31907: qa: clarify and document one assumeutxo test case with malleated snapshot
e5ff4e416ecc8a51367022eb8a7a291f8cbc0c65 qa: use a clearer and documented amount error in malleated snapshot (Antoine Poinsot)
b34fdb5ade0b48384636f8c7c9673554bf82cedf test: introduce output amount (de)compression routines (Sebastian Falbesoner)
a7911ed101ff5b6b624a207f1526b1c347bf635f test: introduce VARINT (de)serialization routines (Sebastian Falbesoner)

Pull request description:

  The `feature_assumeutxo.py` functional test checks various errors with malleated snapshots. Some of these cases are brittle or use confusing and undocumented values. Fix one of those by using a clear, documented and forward-compatible value.

  I ran across those when working on an unrelated changeset which affected the snapshot. It took me a while to understand where the seemingly magic byte string was coming from, so i figured it was worth proposing this patch on its own for the sake of making the test more maintainable.

  See commit messages for details.

ACKs for top commit:
  janb84:
    re ACK [e5ff4e4](e5ff4e416e)
  theStack:
    ACK e5ff4e416ecc8a51367022eb8a7a291f8cbc0c65
  fjahr:
    Code review ACK e5ff4e416ecc8a51367022eb8a7a291f8cbc0c65
  i-am-yuvi:
    tACK e5ff4e416ecc8a51367022eb8a7a291f8cbc0c65

Tree-SHA512: 60f022b7176836ce05e8f287b436329d7ca6460f3fcd95f78cd24e07a95a7d4d9cbbb68a117916a113fe451732b09a012d300fe860ff33d61823eca797ceddaf
2025-03-13 16:34:56 -04:00
Ryan Ofsky
57d611e53b
Merge bitcoin/bitcoin#31757: wallet: fix crash on double block disconnection
11f8ab140fe63857f6a93b81021efda8f90ceeda test: wallet, coverage for crash on dup block disconnection during unclean shutdown (Martin Zumsande)
9ef429b6ae65f6ad3e9ac11c2d9c0a6c52beb865 wallet: fix crash on double block disconnection (furszy)

Pull request description:

  The wallet crashes if it processes the same block disconnection event twice in a row due
  to an incompatible coinbase transaction state.
  This happens because `disconnectBlock` provides `TxStateInactive` without the "abandoned"
  flag for coinbase transactions to `SyncTransaction`, while `AddToWallet()` internally modifies
  it to retain the abandoned state.

  The crash flow is as follows:
  1) On the first disconnection, the transaction state transitions from "confirmed" to
  "inactive," bypassing the state equality check since the provided state differs. Then,
  `AddToWallet` internally updates the state to "inactive + abandoned"

  2) On the second disconnection, as we provide only the "inactive" state
  to `SyncTransaction()`, the state equality assertion fails and crashes the wallet.

  Reviewers Note:
  The crash can easily be replicated by cherry-picking the test commit in master.

ACKs for top commit:
  mzumsande:
    Code Review ACK 11f8ab140fe63857f6a93b81021efda8f90ceeda
  rkrux:
    ACK 11f8ab140fe63857f6a93b81021efda8f90ceeda
  pinheadmz:
    ACK 11f8ab140fe63857f6a93b81021efda8f90ceeda

Tree-SHA512: 971069bca562f0afb06c34a2516842d01b5cbc2b18ed851392aa3caa3bb7488f4a84a5d017ea334e6361261d3c44aa597cc67a1d4fa16781f85e081f3d1f8771
2025-03-13 15:06:49 -04:00
merge-script
199d47d962
Merge bitcoin/bitcoin#32056: doc: Adjust path in comment
de1ada079bf52b9d751bbeb1e7bb3011beb62429 doc: Adjust path in comment (Hennadii Stepanov)

Pull request description:

  It was overlooked in bitcoin/bitcoin#31161.

ACKs for top commit:
  l0rinc:
    utACK de1ada079bf52b9d751bbeb1e7bb3011beb62429
  dergoegge:
    ACK de1ada079bf52b9d751bbeb1e7bb3011beb62429

Tree-SHA512: ea2b858f9c6520a71a3e14a3877ad38acfcddee6ee4aad5fa8fc1c08a0589d9d4df9b5fdbae834bd03bbb956f8b52fdd2b35144fe0bf943bc9455ed6c3fc1c80
2025-03-13 20:18:27 +08:00
Hennadii Stepanov
de1ada079b
doc: Adjust path in comment
It was overlooked in bitcoin/bitcoin#31161.
2025-03-13 11:47:41 +00:00
Hennadii Stepanov
72c150dfe7
Merge bitcoin/bitcoin#32055: contrib: Fix deterministic-unittest-coverage tool path
893ca5458503b432b055f0cf8a9a5aa2cfe7f6e4 contrib: Fix deterministic-unittest-coverage tool path (janb84)

Pull request description:

  Fix for the tooling introduced/modified in #31901 but the tool path is broken due to silent merge conflict introduced by #31161.

  The `deterministic-unittest-coverage` and `deterministic-fuzz-coverage` tools uses the `fuzz` and `test_bitcoind` binaries, for which the location was modified in #31161. This patch updates the location to align with that change.

ACKs for top commit:
  maflcko:
    lgtm ACK 893ca5458503b432b055f0cf8a9a5aa2cfe7f6e4
  hebasto:
    ACK 893ca5458503b432b055f0cf8a9a5aa2cfe7f6e4, I have reviewed the code and it looks OK.

Tree-SHA512: efd5a75b607a6a7889333674b9a1fccf30b6a80bb2aa941f9dcc10b2e0b6158d8c870d58aa76cef2a0280782570400730828d6a4aaf806b83959e9f4bc7313f4
2025-03-13 11:37:56 +00:00
marcofleon
3c5d1a4681 Remove checkpoints
The headers presync logic should be enough to prevent memory DoS using
low-work headers. Therefore, we no longer have any use for checkpoints.
2025-03-13 11:13:13 +00:00
marcofleon
632ae47372 update comment on MinimumChainWork check 2025-03-13 11:05:17 +00:00
janb84
893ca54585 contrib: Fix deterministic-unittest-coverage tool path 2025-03-13 11:56:39 +01:00
merge-script
c20a5ce106
Merge bitcoin/bitcoin#31901: contrib: Add deterministic-unittest-coverage
fa99c3b544b631cfe34d52fb5e71636aedb1b423 test: Exclude SeedStartup from coverage counts (MarcoFalke)
fa579d663d716c967ccd45d67b46e779e2fa0b48 contrib: Add deterministic-unittest-coverage (MarcoFalke)
fa3940b1cbc94c8ccfde36be1db1adca04fbcaa6 contrib: deterministic-fuzz-coverage fixups (MarcoFalke)
faf905b9b694313bed4531d1299568a101f33fb8 doc: Remove unused -fPIC (MarcoFalke)
fa1e0a72281fde13d704c7766d4d704e009274da gitignore: target/ (MarcoFalke)

Pull request description:

  The `contrib/devtools/test_deterministic_coverage.sh` script is problematic:

  * It is written in bash. This can lead to issues when running with the ancient bash version shipped by macOS by default, or can lead to other compatibility issues, such as https://github.com/bitcoin/bitcoin/pull/31588#discussion_r1946784827. Also, pipefail isn't set, so IO errors may be silently ignored.
  * It is based on gcov. This can lead to issues, such as https://github.com/bitcoin/bitcoin/pull/31588#pullrequestreview-2602169248 (possibly due to prefix-map), or https://github.com/bitcoin/bitcoin/pull/31588#issuecomment-2646395385 (gcovr processing error), or https://github.com/bitcoin/bitcoin/pull/31588#pullrequestreview-2605954001 (gcovr assertion error).
  * The script is severely outdated, with the last update to `NON_DETERMINISTIC_TESTS` being in the prior decade.

  Instead of patching around all issues one-by-one, just provide a fresh rewrite, based on the recently added `deterministic-fuzz-coverage` tool based on clang, llvm-cov, and llvm-profdata. (Initial feedback indicates that this is a more promising attempt: https://github.com/bitcoin/bitcoin/pull/31588#issuecomment-2649356408 and https://github.com/bitcoin/bitcoin/pull/31588#issuecomment-2649354598).

  The new tool also sets `RANDOM_CTX_SEED=21` as suggested by hodlinator in https://github.com/bitcoin/bitcoin/pull/31588#issuecomment-2650784726.

ACKs for top commit:
  Prabhat1308:
    Concept ACK [`fa99c3b`](fa99c3b544)
  hodlinator:
    re-ACK fa99c3b544b631cfe34d52fb5e71636aedb1b423
  brunoerg:
    light ACK fa99c3b544b631cfe34d52fb5e71636aedb1b423
  dergoegge:
    tACK fa99c3b544b631cfe34d52fb5e71636aedb1b423
  janb84:
    Concept ACK [fa99c3b](fa99c3b544)

Tree-SHA512: 491d5e6413d929395a5c7caea54817bdc1a0e00562c9728a374d4e92f2e2017dba4a770ecdb2e7317e049df9fdeb390d83c90dff9aa5709f97aa3f6a0e70cdb4
2025-03-13 12:30:32 +08:00
merge-script
a50af6e4c4
Merge bitcoin/bitcoin#32044: ci: Revert "Temporary workaround for old CCACHE_DIR cirrus env"
fa21597064b8599b04461b8d3553e802e47d063e ci: Revert "Temporary workaround for old CCACHE_DIR cirrus env" (MarcoFalke)

Pull request description:

  Seems fine to revert this now. If this still happens it should be rare enough and trivial to fix via a new push (normal push, force-push, rebase, ...), or to just ignore the failure.

ACKs for top commit:
  fanquake:
    ACK fa21597064b8599b04461b8d3553e802e47d063e

Tree-SHA512: 125946dcd4025b04f11276e1df1e0f1b361fc2deed2e3919d680d58df97e6d82881b21c0c683142df6995226b4c12b2dde5415ad78474b8fcda115cc69fa0207
2025-03-13 09:00:05 +08:00
merge-script
a5a582d852
Merge bitcoin/bitcoin#31998: depends: patch around PlacementNew issue in capnp
1ef22ce3351708bdd294d675f818880b7c93fffc depends: patch around PlacementNew issue in capnp (fanquake)

Pull request description:

  See #31772 and https://github.com/capnproto/capnproto/pull/2235.

  Given there isn't agreement in #29796, pulled this out so it could be merged separately, and it's easier to run different test configurations externally.

  Closes #31772.

ACKs for top commit:
  ryanofsky:
    Code review ACK 1ef22ce3351708bdd294d675f818880b7c93fffc. Confirmed patch is identical to one merged upstream. Only change since last review was tweaking the file paths and commit data in the patch.
  TheCharlatan:
    ACK 1ef22ce3351708bdd294d675f818880b7c93fffc

Tree-SHA512: 9c9ecf50c43cf74315f6659afab55aeafb436f70e83b328016ad574136dce46867220c6e1a85aefd8d3d3d027cd94cc807c79721a4983da9428de70f11224e52
2025-03-13 08:52:36 +08:00
David Gumberg
a24419f8be contrib: Fix gen-bitcoin-conf.sh.
In #31118, the format of bitcoind's `--help` output changed slightly in
a way that breaks `gen-bitcoin-conf.sh`, modify the script to accomodate
the new format, by starting after the line that says "Options:" and
strip the `-help` option and its description from the output.
2025-03-12 15:14:51 -07:00
Lőrinc
a06a674b43 optimization: refactor: Introduce Uint256ExtraSipHasher to cache SipHash constant state
Previously, only k0 and k1 were stored, causing the constant xor operations to be recomputed in every call to `SipHashUint256Extra`.
This commit adds a dedicated `Uint256ExtraSipHasher` class that caches the initial state (v0-v3) and to perform the `SipHash` computation on a `uint256` (with an extra parameter), hiding the constant computation details from higher-level code and improving efficiency.
This basically brings the precalculations in the `CSipHasher` constructor to the `uint256` specialized SipHash implementation.

> cmake -B build -DBUILD_BENCH=ON -DCMAKE_BUILD_TYPE=Release && cmake --build build -j$(nproc) && build/src/bench/bench_bitcoin -filter='SaltedOutpointHasherBench' -min-time=10000

> C++ compiler .......................... AppleClang 16.0.0.16000026

|               ns/op |                op/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|               57.27 |       17,462,299.19 |    0.1% |     11.02 | `SaltedOutpointHasherBench_create_set`
|               11.24 |       88,997,888.48 |    0.3% |     11.04 | `SaltedOutpointHasherBench_hash`
|               13.91 |       71,902,014.20 |    0.2% |     11.01 | `SaltedOutpointHasherBench_match`
|               13.29 |       75,230,390.31 |    0.1% |     11.00 | `SaltedOutpointHasherBench_mismatch`

compared to master:
create_set - 17,462,299.19/17,065,922.04 - 2.3% faster
hash       - 88,997,888.48/83,576,684.83 - 6.4% faster
match      - 71,902,014.20/68,985,850.12 - 4.2% faster
mismatch   - 75,230,390.31/71,942,033.47 - 4.5% faster

> C++ compiler .......................... GNU 13.3.0

|               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |         bra/op |   miss% |     total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
|              135.38 |        7,386,349.49 |    0.0% |        1,078.19 |          486.16 |  2.218 |         119.56 |    1.1% |     11.00 | `SaltedOutpointHasherBench_create_set`
|               23.67 |       42,254,558.08 |    0.0% |          247.01 |           85.01 |  2.906 |           4.00 |    0.0% |     11.00 | `SaltedOutpointHasherBench_hash`
|               58.95 |       16,962,220.14 |    0.1% |          446.55 |          211.74 |  2.109 |          20.86 |    1.4% |     11.01 | `SaltedOutpointHasherBench_match`
|               76.98 |       12,991,047.69 |    0.1% |          548.93 |          276.50 |  1.985 |          20.25 |    2.3% |     10.72 | `SaltedOutpointHasherBench_mismatch`

compared to master:
create_set -  7,386,349.49/7,312,133.16  - 1% faster
hash       - 42,254,558.08/41,978,882.62 - 0.6% faster
match      - 16,962,220.14/16,549,695.42 - 2.4% faster
mismatch   - 12,991,047.69/12,713,595.35 - 2% faster
2025-03-12 20:53:12 +01:00
Lőrinc
39e33d4928 refactor: Extract C0-C3 Siphash constants 2025-03-12 20:53:12 +01:00
Lőrinc
09131cc9d1 test: Rename k1/k2 to k0/k1 for consistency 2025-03-12 20:53:12 +01:00
Lőrinc
24d35ec4ec bench: Add COutPoint and SaltedOutpointHasher benchmarks
This commit introduces new benchmarks to measure the performance of various operations using
SaltedOutpointHasher, including hash computation, set operations, and set creation.

These benchmarks are intended to provide insights about coin caching performance (e.g. during IBD).

> cmake -B build -DBUILD_BENCH=ON -DCMAKE_BUILD_TYPE=Release && cmake --build build -j$(nproc) && build/src/bench/bench_bitcoin -filter='SaltedOutpointHasherBench' -min-time=10000

> C++ compiler .......................... AppleClang 16.0.0.16000026

|               ns/op |                op/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|               58.60 |       17,065,922.04 |    0.3% |     11.02 | `SaltedOutpointHasherBench_create_set`
|               11.97 |       83,576,684.83 |    0.1% |     11.01 | `SaltedOutpointHasherBench_hash`
|               14.50 |       68,985,850.12 |    0.3% |     10.96 | `SaltedOutpointHasherBench_match`
|               13.90 |       71,942,033.47 |    0.4% |     11.03 | `SaltedOutpointHasherBench_mismatch`

> C++ compiler .......................... GNU 13.3.0

|               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |         bra/op |   miss% |     total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
|              136.76 |        7,312,133.16 |    0.0% |        1,086.67 |          491.12 |  2.213 |         119.54 |    1.1% |     11.01 | `SaltedOutpointHasherBench_create_set`
|               23.82 |       41,978,882.62 |    0.0% |          252.01 |           85.57 |  2.945 |           4.00 |    0.0% |     11.00 | `SaltedOutpointHasherBench_hash`
|               60.42 |       16,549,695.42 |    0.1% |          460.51 |          217.04 |  2.122 |          21.00 |    1.4% |     10.99 | `SaltedOutpointHasherBench_match`
|               78.66 |       12,713,595.35 |    0.1% |          555.59 |          282.52 |  1.967 |          20.19 |    2.2% |     10.74 | `SaltedOutpointHasherBench_mismatch`
2025-03-12 20:53:12 +01:00
Hennadii Stepanov
eb9730ab65
Merge bitcoin/bitcoin#31987: wallet: Replace "non-0" with "non-zero" in translatable error message
18e83534ace7aa2d26bc7dfa521b1d591b66edfa wallet: Replace "non-0" with "non-zero" in translatable error message (Hennadii Stepanov)

Pull request description:

  Transifex interprets the "-0" substring as a number in translatable strings. Since not all translations preserve "-0," this triggers a corresponding warning. While this warning could be disabled globally, it is more reasonable to adjust the original string instead.

ACKs for top commit:
  davidgumberg:
    ACK 18e83534ac
  l0rinc:
    ACK 18e83534ace7aa2d26bc7dfa521b1d591b66edfa
  1440000bytes:
    ACK 18e83534ac
  BrandonOdiwuor:
    Code Review ACK 18e83534ace7aa2d26bc7dfa521b1d591b66edfa
  laanwj:
    Code review ACK 18e83534ace7aa2d26bc7dfa521b1d591b66edfa

Tree-SHA512: 5c38cfc4b352dbbcc8de5fb907cf988a77a7ecded7a90fe0517bfb9e4cd5097bdeb1aa6edf5d9ca37de54d1d7939d5e49533ec93c403db90d9169ad7732e5124
2025-03-12 19:32:05 +00:00
Ryan Ofsky
f347d7980e
Merge bitcoin/bitcoin#31283: Add waitNext() to BlockTemplate interface
cadbd4137d84b71be26effd6a2ae177d5031345e miner: have waitNext return after 20 min on testnet (Sjors Provoost)
d4020f502a63cb4390ec241fc5f989e988afa022 Add waitNext() to BlockTemplate interface (Sjors Provoost)

Pull request description:

  This PR introduces `waitNext()`. It waits for either the tip to update or for fees at the top of the mempool to rise sufficiently. It then returns a new template, with which the caller can rinse and repeat.

  On testnet3 and testnet4 the difficulty drops after 20 minutes, so the second ensures that a new template is returned in that case.

  Alternative approach to #31003, suggested in https://github.com/bitcoin/bitcoin/issues/31109#issuecomment-2451942362

ACKs for top commit:
  ryanofsky:
    Code review ACK cadbd4137d84b71be26effd6a2ae177d5031345e. Main change since last review is adding back a missing `m_interrupt` check in the waitNext loop. Also made various code cleanups in both commits.
  ismaelsadeeq:
    Code review ACK cadbd4137d84b71be26effd6a2ae177d5031345e
  vasild:
    ACK cadbd4137d84b71be26effd6a2ae177d5031345e

Tree-SHA512: c5a40053723c1c1674449ba1e4675718229a2022c8b0a4853b12a2c9180beb87536a1f99fde969a0ef099bca9ac69ca14ea4f399d277d2db7f556465ce47de95
2025-03-12 15:20:48 -04:00
Lőrinc
626d55b9a8 coins: bump default LevelDB write batch size to 64 MiB
The UTXO set has grown significantly, and flushing it from memory to LevelDB often takes over 20 minutes after a successful IBD with large dbcache values.
The final UTXO set is written to disk in batches, which LevelDB sorts into SST files.
By increasing the default batch size, we can reduce overhead from repeated compaction cycles, minimize constant overhead per batch, and achieve more sequential writes.

Experiments with different batch sizes (loaded via assumeutxo at block 840k, then measuring final flush time) show that 64 MiB batches significantly reduce flush time without notably increasing memory usage:

| dbbatchsize | flush_sum (ms) |
|-------------|----------------|
| 8 MiB       | ~240,000       |
| 16 MiB      | ~220,000       |
| 32 MiB      | ~200,000       |
| *64 MiB*    | *~150,000*     |
| 128 MiB     | ~156,000       |
| 256 MiB     | ~166,000       |
| 512 MiB     | ~186,000       |
| 1 GiB       | ~186,000       |

Checking the impact of a `-reindex-chainstate` with `-stopatheight=878000` and `-dbcache=30000` gives:
16 << 20
```
2025-01-12T07:31:05Z Flushed fee estimates to fee_estimates.dat.
2025-01-12T07:31:05Z [warning] Flushing large (26 GiB) UTXO set to disk, it may take several minutes
2025-01-12T07:53:51Z Shutdown: done
```
Flush time: 22 minutes and 46 seconds

64 >> 20
```
2025-01-12T18:30:00Z Flushed fee estimates to fee_estimates.dat.
2025-01-12T18:30:00Z [warning] Flushing large (26 GiB) UTXO set to disk, it may take several minutes
2025-01-12T18:44:43Z Shutdown: done
```
Flush time: ~14 minutes 43 seconds.
2025-03-12 19:16:07 +01:00
Lőrinc
9f601c0cab optimization: look for NULL prevouts in the sorted values
For the 2 input case we simply check them both, like we did with equality.

For the general case, we take advantage of sorting, making invalid value detection constant time instead of linear in the worst case.

> cmake -B build -DBUILD_BENCH=ON -DCMAKE_BUILD_TYPE=Release && cmake --build build -j$(nproc) && build/src/bench/bench_bitcoin -filter='CheckBlockBench|DuplicateInputs|ProcessTransactionBench' -min-time=10000

> C++ compiler .......................... AppleClang 16.0.0.16000026

|            ns/block |             block/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|          179,971.00 |            5,556.45 |    0.3% |     11.02 | `CheckBlockBench`

|               ns/op |                op/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|          963,177.98 |            1,038.23 |    1.7% |     10.92 | `DuplicateInputs`
|            9,410.90 |          106,259.75 |    0.3% |     11.01 | `ProcessTransactionBench`

> C++ compiler .......................... GNU 13.3.0

|            ns/block |             block/s |    err% |       ins/block |       cyc/block |    IPC |      bra/block |   miss% |     total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
|          834,855.94 |            1,197.81 |    0.0% |    6,518,548.86 |    2,656,039.78 |  2.454 |     919,160.84 |    1.5% |     10.78 | `CheckBlockBench`

|               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |         bra/op |   miss% |     total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
|        4,261,492.75 |              234.66 |    0.0% |   17,379,823.40 |   13,559,793.33 |  1.282 |   4,265,714.28 |    3.4% |     11.00 | `DuplicateInputs`
|           55,819.53 |           17,914.88 |    0.1% |      227,828.15 |      177,520.09 |  1.283 |      15,184.36 |    0.4% |     10.91 | `ProcessTransactionBench`
2025-03-12 19:16:07 +01:00
Lőrinc
ce6840f701 optimization: replace tree with sorted vector
A pre-sized vector retains locality (enabling SIMD operations), speeding up sorting and equality checks.
It's also simpler (therefore more reliable) than a sorted set. It also causes less memory fragmentation.

> cmake -B build -DBUILD_BENCH=ON -DCMAKE_BUILD_TYPE=Release && cmake --build build -j$(nproc) && build/src/bench/bench_bitcoin -filter='CheckBlockBench|DuplicateInputs|ProcessTransactionBench' -min-time=10000

> C++ compiler .......................... AppleClang 16.0.0.16000026

|            ns/block |             block/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|          181,922.54 |            5,496.85 |    0.2% |     10.98 | `CheckBlockBench`

|               ns/op |                op/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|          997,739.30 |            1,002.27 |    1.0% |     10.94 | `DuplicateInputs`
|            9,449.28 |          105,828.15 |    0.3% |     10.99 | `ProcessTransactionBench`

Co-authored-by: Pieter Wuille <pieter@wuille.net>
2025-03-12 19:16:07 +01:00
Lőrinc
2a5df20ca9 optimization: simplify duplicate checks for trivial inputs
No need to create a set for checking duplicates for two-input-transactions.

> cmake -B build -DBUILD_BENCH=ON -DCMAKE_BUILD_TYPE=Release && cmake --build build -j$(nproc) && build/src/bench/bench_bitcoin -filter='CheckBlockBench|DuplicateInputs|ProcessTransactionBench' -min-time=10000

> C++ compiler .......................... AppleClang 16.0.0.16000026

|            ns/block |             block/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|          314,137.30 |            3,183.32 |    1.2% |     11.04 | `CheckBlockBench`

|               ns/op |                op/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|        3,220,592.73 |              310.50 |    1.3% |     10.92 | `DuplicateInputs`
|            9,425.98 |          106,089.77 |    0.3% |     11.00 | `ProcessTransactionBench`
2025-03-12 19:16:07 +01:00
Lőrinc
45f8cda9bb optimization: move duplicate checks outside of coinbase branch
`IsCoinBase` means single input with NULL prevout, so it makes sense to restrict duplicate check to non-coinbase transactions only.
The behavior is the same as before, except that single-input-transactions aren't checked for duplicates anymore (~70-90% of the cases, see https://transactionfee.info/charts/transactions-1in).
I've added braces to the conditions and loops to simplify review of followup commits.

> cmake -B build -DBUILD_BENCH=ON -DCMAKE_BUILD_TYPE=Release && cmake --build build -j$(nproc) && build/src/bench/bench_bitcoin -filter='CheckBlockBench|DuplicateInputs|ProcessTransactionBench' -min-time=10000

> C++ compiler .......................... AppleClang 16.0.0.16000026

|            ns/block |             block/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|          335,917.12 |            2,976.92 |    1.3% |     11.01 | `CheckBlockBench`

|               ns/op |                op/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|        3,286,337.42 |              304.29 |    1.1% |     10.90 | `DuplicateInputs`
|            9,561.02 |          104,591.35 |    0.2% |     11.02 | `ProcessTransactionBench`
2025-03-12 19:16:07 +01:00
Lőrinc
452baf49e1 bench: add ProcessTransactionBench to measure CheckBlock in context
The newly introduced `ProcessTransactionBench` incorporates multiple steps in the validation pipeline, offering a more comprehensive view of `CheckBlock` performance within a realistic transaction validation context.

Previous microbenchmarks, such as DeserializeAndCheckBlockTest and DuplicateInputs, focused on isolated aspects of transaction and block validation. While these tests provided valuable insights for targeted profiling, they lacked context regarding the broader validation process, where interactions between components play a critical role.

> cmake -B build -DBUILD_BENCH=ON -DCMAKE_BUILD_TYPE=Release && cmake --build build -j$(nproc) && build/src/bench/bench_bitcoin -filter='ProcessTransactionBench' -min-time=10000

> C++ compiler .......................... AppleClang 16.0.0.16000026

|               ns/op |                op/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|            9,585.10 |          104,328.55 |    0.1% |     11.03 | `ProcessTransactionBench`

> C++ compiler .......................... GNU 13.3.0

|               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |         bra/op |   miss% |     total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
|           56,199.57 |           17,793.73 |    0.1% |      229,263.01 |      178,766.31 |  1.282 |      15,509.97 |    0.5% |     10.91 | `ProcessTransactionBench`
2025-03-12 19:16:07 +01:00
Lőrinc
99fe67e132 bench: measure CheckBlock speed separately from serialization
> cmake -B build -DBUILD_BENCH=ON -DCMAKE_BUILD_TYPE=Release && cmake --build build -j$(nproc) && build/src/bench/bench_bitcoin -filter='CheckBlockBench|DuplicateInputs' -min-time=10000

> C++ compiler .......................... AppleClang 16.0.0.16000026

|            ns/block |             block/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|          372,743.63 |            2,682.81 |    1.1% |     10.99 | `CheckBlockBench`

|               ns/op |                op/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|        3,304,694.54 |              302.60 |    0.5% |     11.05 | `DuplicateInputs`

> C++ compiler .......................... GNU 13.3.0

|            ns/block |             block/s |    err% |       ins/block |       cyc/block |    IPC |      bra/block |   miss% |     total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
|        1,096,261.84 |              912.19 |    0.1% |    7,963,390.88 |    3,487,375.26 |  2.283 |   1,266,941.00 |    1.8% |     11.03 | `CheckBlockBench`

|               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |         bra/op |   miss% |     total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
|        8,366,309.48 |              119.53 |    0.0% |   23,865,177.67 |   26,620,160.23 |  0.897 |   5,972,887.41 |    4.0% |     10.78 | `DuplicateInputs`
2025-03-12 19:16:07 +01:00
Lőrinc
b07cdbe542 test: validate duplicate detection in CheckTransaction
The `CheckTransaction` validation function in https://github.com/bitcoin/bitcoin/blob/master/src/consensus/tx_check.cpp#L41-L45 relies on a correct ordering relation for detecting duplicate transaction inputs.

This update to the tests ensures that:
* Accurate detection of duplicates: Beyond trivial cases (e.g., two identical inputs), duplicates are detected correctly in more complex scenarios.
* Consistency across methods: Both sorted sets and hash-based sets behave identically when detecting duplicates for `COutPoint` and related values.
* Robust ordering and equality relations: The function maintains expected behavior for ordering and equality checks.

Using randomized testing with shuffled inputs (to avoid any remaining bias introduced), the enhanced test validates that `CheckTransaction` remains robust and reliable across various input configurations. It confirms identical behavior to a hashing-based duplicate detection mechanism, ensuring consistency and correctness.

To make sure the new branches in the follow-up commits will be covered, `basic_transaction_tests` was extended a randomized test one comparing against the old implementation (and also an alternative duplicate). The iterations and ranges were chosen such that every new branch is expected to be hit once.
2025-03-12 19:16:07 +01:00
Lőrinc
c072498305 optimization: merge SizeComputer specializations + add new ones
Endianness doesn't affect the final size, we can skip it for `SizeComputer`.
We can `if constexpr` previous calls into existing method, short-circuiting existing logic when we only need their serialized sizes.

> cmake -B build -DBUILD_BENCH=ON -DCMAKE_BUILD_TYPE=Release && cmake --build build -j$(nproc) && build/src/bench/bench_bitcoin -filter='SizeComputerBlock|SerializeBlock|DeserializeBlock' --min-time=10000

> C compiler ............................ AppleClang 16.0.0.16000026

|            ns/block |             block/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|          888,859.82 |            1,125.04 |    0.4% |     10.87 | `DeserializeBlock`
|          168,502.88 |            5,934.62 |    0.1% |     10.99 | `SerializeBlock`
|           10,200.88 |           98,030.75 |    0.1% |     11.00 | `SizeComputerBlock`

> C++ compiler .......................... GNU 13.3.0

|            ns/block |             block/s |    err% |       ins/block |       cyc/block |    IPC |      bra/block |   miss% |     total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
|        4,460,428.52 |              224.19 |    0.0% |   53,692,507.13 |   16,015,347.97 |  3.353 |   2,410,105.48 |    0.5% |     11.01 | `DeserializeBlock`
|          567,042.65 |            1,763.54 |    0.0% |    7,386,775.59 |    2,035,613.84 |  3.629 |   1,385,368.57 |    0.5% |     11.01 | `SerializeBlock`
|           25,728.56 |           38,867.32 |    0.0% |      172,750.03 |       92,366.64 |  1.870 |      42,131.03 |    1.7% |     11.00 | `SizeComputerBlock`
2025-03-12 19:16:07 +01:00
Lőrinc
c02600b8e1 optimization: Add single byte write
Single byte writes are used very often (used for every (u)int8_t or std::byte or bool and for every VarInt's first byte which is also needed for every (pre)Vector).
It makes sense to avoid the generalized serialization infrastructure that isn't needed:
* AutoFile write doesn't need to allocate 4k buffer for a single byte now;
* `VectorWriter` and `DataStream` avoids memcpy/insert calls.

> cmake -B build -DBUILD_BENCH=ON -DCMAKE_BUILD_TYPE=Release && cmake --build build -j$(nproc) && build/src/bench/bench_bitcoin -filter='SizeComputerBlock|SerializeBlock|DeserializeBlock' --min-time=10000

> C compiler ............................ AppleClang 16.0.0.16000026

|            ns/block |             block/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|          934,120.45 |            1,070.53 |    0.2% |     11.01 | `DeserializeBlock`
|          170,719.27 |            5,857.57 |    0.1% |     10.99 | `SerializeBlock`
|           12,048.40 |           82,998.58 |    0.2% |     11.01 | `SizeComputerBlock`

> C++ compiler .......................... GNU 13.3.0

|            ns/block |             block/s |    err% |       ins/block |       cyc/block |    IPC |      bra/block |   miss% |     total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
|        4,433,835.04 |              225.54 |    0.0% |   53,688,481.60 |   15,918,730.23 |  3.373 |   2,409,056.47 |    0.5% |     11.01 | `DeserializeBlock`
|          563,663.10 |            1,774.11 |    0.0% |    7,386,775.59 |    2,023,525.77 |  3.650 |   1,385,368.57 |    0.5% |     11.00 | `SerializeBlock`
|           27,351.60 |           36,560.93 |    0.1% |      225,261.03 |       98,209.77 |  2.294 |      53,037.03 |    0.9% |     11.00 | `SizeComputerBlock`
2025-03-12 19:16:07 +01:00
Lőrinc
028c006541 cleanup: remove unused ser_writedata16be and ser_readdata16be 2025-03-12 19:16:07 +01:00
Lőrinc
794180e8f8 refactor: reduce template bloat in primitive serialization
Merged multiple template methods into single constexpr-delimited implementation to reduce template bloat (i.e. related functionality is grouped into a single method, but can be optimized because of C++20 constexpr conditions).
This unifies related methods that were only bound before by similar signatures - and enables `SizeComputer` optimizations later
2025-03-12 19:16:07 +01:00