elements/src/test/fuzz
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
..
util refactor: Introduce struct to hold a runtime format string 2025-01-15 12:16:08 +01:00
addition_overflow.cpp build, msvc: Build fuzz.exe binary 2024-04-18 10:27:25 +01:00
addrman.cpp fuzz: Add missing SeedRandomStateForTest(SeedRand::ZEROS) 2024-12-13 14:22:25 +01:00
asmap.cpp [netgroupman] Add GetMappedAS() and GetGroup() 2022-04-20 14:35:52 +01:00
asmap_direct.cpp scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
autofile.cpp streams: remove AutoFile::Get() entirely 2024-09-13 21:59:29 -04:00
banman.cpp fuzz: Add missing SeedRandomStateForTest(SeedRand::ZEROS) 2024-12-13 14:22:25 +01:00
base_encode_decode.cpp util: Move util/string.h functions to util namespace 2024-05-16 10:16:08 -05:00
bech32.cpp fuzz: replace hardcoded numbers for bech32 limits 2024-08-06 11:03:31 +02:00
bip324.cpp refactor: Remove Span operator==, Use std::ranges::equal 2024-08-13 07:44:31 +02:00
bitdeque.cpp fuzz: Avoid timeout in bitdeque 2023-12-06 15:44:38 +01:00
bitset.cpp random: convert XoRoShiRo128PlusPlus into full RNG 2024-07-01 10:26:46 -04:00
block.cpp fuzz: Drop unused version from fuzz input format 2023-11-30 11:27:21 +01:00
block_header.cpp refactor: Hand-replace some uint256S -> uint256 2024-08-05 14:51:47 +02:00
block_index.cpp qa: a fuzz target for the block index database 2024-05-29 18:55:04 +02:00
blockfilter.cpp fuzz: Add missing SeedRandomStateForTest(SeedRand::ZEROS) 2024-12-13 14:22:25 +01:00
bloom_filter.cpp Use ParamsWrapper for witness serialization 2023-11-14 08:45:30 +10:00
buffered_file.cpp fuzz: make FuzzedDataProvider usage deterministic 2023-12-09 19:31:06 +01:00
chain.cpp chain: Rename HaveTxsDownloaded to HaveNumChainTxs 2023-10-06 19:43:32 +02:00
checkqueue.cpp [checkqueue] support user-defined return type through std::optional 2024-12-02 16:25:13 -05:00
cluster_linearize.cpp clusterlin: merge two DepGraph fuzz tests into simulation test 2024-10-07 13:49:36 -04:00
CMakeLists.txt fuzz: Add fuzz test for checked and saturating add and left shift 2025-01-15 15:44:03 +01:00
coins_view.cpp coins, refactor: Split up AddFlags to remove invalid states 2024-12-02 13:48:04 +01:00
coinscache_sim.cpp refactor: Rely on returned value of GetCoin instead of parameter 2024-09-18 20:03:47 +02:00
connman.cpp fuzz: Add missing SeedRandomStateForTest(SeedRand::ZEROS) 2024-12-13 14:22:25 +01:00
crypto.cpp fuzz: make FuzzedDataProvider usage deterministic 2023-12-09 19:31:06 +01:00
crypto_aes256.cpp scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
crypto_aes256cbc.cpp scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
crypto_chacha20.cpp Merge bitcoin/bitcoin#29043: fuzz: make FuzzedDataProvider usage deterministic 2024-09-04 15:04:53 -04:00
crypto_chacha20poly1305.cpp fuzz: reduce number of iterations in crypto_aeadchacha20poly1305 target 2024-09-05 17:56:54 -03:00
crypto_common.cpp crypto: Add missing WriteBE16 function 2024-09-21 12:37:36 +02:00
crypto_diff_fuzz_chacha20.cpp crypto: require key on ChaCha20 initialization 2023-08-17 15:31:27 -04:00
crypto_hkdf_hmac_sha256_l32.cpp scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
crypto_poly1305.cpp fuzz: support std::byte in Consume{Fixed,Variable}LengthByteVector 2023-08-17 15:31:56 -04:00
cuckoocache.cpp fuzz: make FuzzedDataProvider usage deterministic 2023-12-09 19:31:06 +01:00
decode_tx.cpp
descriptor_parse.cpp Merge bitcoin/bitcoin#22838: descriptors: Be able to specify change and receiving in a single descriptor string 2024-08-28 15:56:15 +01:00
deserialize.cpp scripted-diff: get rid of remaining "command" terminology in protocol.{h,cpp} 2024-10-26 23:44:15 +02:00
eval_script.cpp Adapt to libsecp256k1 API changes 2022-12-13 15:08:24 -05:00
fee_rate.cpp scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
feefrac.cpp Add fuzz test for FeeFrac 2024-03-18 10:32:00 -04:00
feeratediagram.cpp Avoid explicitly computing diagram; compare based on chunks 2024-04-22 09:36:36 -04:00
fees.cpp util: move fees.h and error.h to common/messages.h 2024-05-16 10:16:08 -05:00
flatfile.cpp Refactor: Remove unused FlatFilePos::SetNull 2023-03-21 13:54:11 +01:00
float.cpp Remove unused version.h include 2023-11-30 11:28:19 +01:00
fuzz.cpp fuzz: Add SetMockTime() to necessary targets 2025-01-06 15:43:04 +00:00
fuzz.h fuzz: Use std::span in FuzzBufferType 2024-06-12 15:21:31 +02:00
FuzzedDataProvider.h fuzz: add cstdlib to FuzzedDataProvider 2024-12-09 17:01:10 +00:00
golomb_rice.cpp fuzz: Add missing SeedRandomStateForTest(SeedRand::ZEROS) 2024-12-13 14:22:25 +01:00
headerssync.cpp fuzz: Add missing SeedRandomStateForTest(SeedRand::ZEROS) 2024-12-13 14:22:25 +01:00
hex.cpp Merge bitcoin/bitcoin#30618: test: support std::optional in BOOST_CHECK_* and increase FromUserHex fuzz feature coverage 2024-09-12 12:36:37 -04:00
http_request.cpp refactor: Remove call to ShutdownRequested from HTTPRequest 2023-12-04 15:39:15 -04:00
i2p.cpp fuzz: Add missing SeedRandomStateForTest(SeedRand::ZEROS) 2024-12-13 14:22:25 +01:00
integer.cpp Merge bitcoin/bitcoin#30661: fuzz: Test headers pre-sync through p2p 2024-09-16 13:59:22 -04:00
key.cpp fuzz: Add missing SeedRandomStateForTest(SeedRand::ZEROS) 2024-12-13 14:22:25 +01:00
key_io.cpp test: Use ECC_Context helper in bench and fuzz tests 2024-05-09 15:56:04 +02:00
kitchen_sink.cpp rpc: clarify ALREADY_IN_CHAIN rpc errors 2024-08-05 15:45:58 +01:00
load_external_block_file.cpp fuzz: Add SetMockTime() to necessary targets 2025-01-06 15:43:04 +00:00
locale.cpp util: Move util/string.h functions to util namespace 2024-05-16 10:16:08 -05:00
merkleblock.cpp refactor: Use Txid in CMerkleBlock 2023-11-28 17:49:41 +01:00
message.cpp Merge bitcoin/bitcoin#29043: fuzz: make FuzzedDataProvider usage deterministic 2024-09-04 15:04:53 -04:00
mini_miner.cpp fuzz: Add SetMockTime() to necessary targets 2025-01-06 15:43:04 +00:00
miniscript.cpp refactor: Drop deprecated space in operator""_mst 2024-11-11 12:14:08 +01:00
minisketch.cpp [fuzz] Improve fuzzing stability for minisketch harness 2023-12-14 20:10:21 +00:00
muhash.cpp refactor: Hand-replace some uint256S -> uint256 2024-08-05 14:51:47 +02:00
multiplication_overflow.cpp build, msvc: Build fuzz.exe binary 2024-04-18 10:27:25 +01:00
net.cpp fuzz: Add SetMockTime() to necessary targets 2025-01-06 15:43:04 +00:00
net_permissions.cpp Merge bitcoin/bitcoin#27114: p2p: Allow whitelisting manual connections 2024-03-12 12:59:02 -04:00
netaddress.cpp fuzz: Add missing SeedRandomStateForTest(SeedRand::ZEROS) 2024-12-13 14:22:25 +01:00
netbase_dns_lookup.cpp p2p: return CSubNet in LookupSubNet 2023-05-30 16:27:21 -03:00
node_eviction.cpp scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
overflow.cpp fuzz: Add fuzz test for checked and saturating add and left shift 2025-01-15 15:44:03 +01:00
p2p_handshake.cpp fuzz: Add missing SeedRandomStateForTest(SeedRand::ZEROS) 2024-12-13 14:22:25 +01:00
p2p_headers_presync.cpp fuzz: Add SetMockTime() to necessary targets 2025-01-06 15:43:04 +00:00
p2p_transport_serialization.cpp scripted-diff: get rid of remaining "command" terminology in protocol.{h,cpp} 2024-10-26 23:44:15 +02:00
package_eval.cpp Merge bitcoin/bitcoin#31486: fuzz: Abort when using global PRNG without re-seed 2024-12-17 12:55:38 -05:00
parse_hd_keypath.cpp Switch hardened derivation marker to h in descriptors 2023-04-04 18:33:08 +02:00
parse_iso8601.cpp Remove wallet::ParseISO8601DateTime, use ParseISO8601DateTime instead 2024-12-02 15:09:31 +01:00
parse_numbers.cpp scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
parse_script.cpp
parse_univalue.cpp fuzz: Limit parse_univalue input length 2024-07-19 15:39:02 +02:00
partially_downloaded_block.cpp fuzz: Add SetMockTime() to necessary targets 2025-01-06 15:43:04 +00:00
policy_estimator.cpp Merge bitcoin/bitcoin#29043: fuzz: make FuzzedDataProvider usage deterministic 2024-09-04 15:04:53 -04:00
policy_estimator_io.cpp fuzz: Remove FuzzedAutoFileProvider 2023-11-14 17:41:26 +01:00
poolresource.cpp refactor: Remove Span operator==, Use std::ranges::equal 2024-08-13 07:44:31 +02:00
pow.cpp Add FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION in PoW check 2024-09-02 15:43:33 +01:00
prevector.cpp Merge bitcoin/bitcoin#29043: fuzz: make FuzzedDataProvider usage deterministic 2024-09-04 15:04:53 -04:00
primitives_transaction.cpp Use ParamsWrapper for witness serialization 2023-11-14 08:45:30 +10:00
process_message.cpp Merge bitcoin/bitcoin#31486: fuzz: Abort when using global PRNG without re-seed 2024-12-17 12:55:38 -05:00
process_messages.cpp Merge bitcoin/bitcoin#31486: fuzz: Abort when using global PRNG without re-seed 2024-12-17 12:55:38 -05:00
protocol.cpp scripted-diff: get rid of remaining "command" terminology in protocol.{h,cpp} 2024-10-26 23:44:15 +02:00
psbt.cpp fuzz: Add missing SeedRandomStateForTest(SeedRand::ZEROS) 2024-12-13 14:22:25 +01:00
random.cpp random: drop ad-hoc Shuffle in favor of std::shuffle 2024-07-06 09:06:36 -04:00
rbf.cpp fuzz: Add missing SeedRandomStateForTest(SeedRand::ZEROS) 2024-12-13 14:22:25 +01:00
rolling_bloom_filter.cpp fuzz: Add missing SeedRandomStateForTest(SeedRand::ZEROS) 2024-12-13 14:22:25 +01:00
rpc.cpp fuzz: Add missing SeedRandomStateForTest(SeedRand::ZEROS) 2024-12-13 14:22:25 +01:00
script.cpp [test]: remove ExtractDestination false assertion for ANCHOR script 2024-08-09 11:18:45 +01:00
script_assets_test_minimizer.cpp util: Move util/string.h functions to util namespace 2024-05-16 10:16:08 -05:00
script_descriptor_cache.cpp scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
script_flags.cpp Fix IWYU for the script_flags fuzz target 2023-11-23 17:57:53 +01:00
script_format.cpp fuzz: make FuzzedDataProvider usage deterministic 2023-12-09 19:31:06 +01:00
script_interpreter.cpp fuzz: make FuzzedDataProvider usage deterministic 2023-12-09 19:31:06 +01:00
script_ops.cpp
script_parsing.cpp util: Move util/string.h functions to util namespace 2024-05-16 10:16:08 -05:00
script_sigcache.cpp fuzz: Add missing SeedRandomStateForTest(SeedRand::ZEROS) 2024-12-13 14:22:25 +01:00
script_sign.cpp Merge bitcoin/bitcoin#30561: refactor: move SignSignature helpers to test utils 2024-09-20 16:05:28 +01:00
scriptnum_ops.cpp
secp256k1_ec_seckey_import_export_der.cpp test: replace deprecated secp256k1 context flags usage 2024-08-21 00:41:56 +02:00
secp256k1_ecdsa_signature_parse_der_lax.cpp fuzz: Add missing SeedRandomStateForTest(SeedRand::ZEROS) 2024-12-13 14:22:25 +01:00
signature_checker.cpp Merge bitcoin/bitcoin#26691: Update secp256k1 subtree to libsecp256k1 version 0.2.0 2023-01-13 09:40:57 +00:00
signet.cpp Use ParamsWrapper for witness serialization 2023-11-14 08:45:30 +10:00
socks5.cpp fuzz: Add SetMockTime() to necessary targets 2025-01-06 15:43:04 +00:00
span.cpp refactor: Remove Span operator==, Use std::ranges::equal 2024-08-13 07:44:31 +02:00
string.cpp util: Catch translation string errors at compile time 2024-07-10 09:40:47 +02:00
strprintf.cpp refactor: Introduce struct to hold a runtime format string 2025-01-15 12:16:08 +01:00
system.cpp multiprocess: Add -ipcbind option to bitcoin-node 2024-09-06 09:08:10 -04:00
timeoffsets.cpp refactor: remove warnings globals 2024-06-13 11:20:49 +01:00
torcontrol.cpp scripted-diff: Use new FUZZ_TARGET macro everywhere 2023-07-13 20:37:14 +02:00
transaction.cpp fuzz: Add missing SeedRandomStateForTest(SeedRand::ZEROS) 2024-12-13 14:22:25 +01:00
tx_in.cpp Remove unused version.h include 2023-11-30 11:28:19 +01:00
tx_out.cpp Remove unused version.h include 2023-11-30 11:28:19 +01:00
tx_pool.cpp Merge bitcoin/bitcoin#31486: fuzz: Abort when using global PRNG without re-seed 2024-12-17 12:55:38 -05:00
txdownloadman.cpp Merge bitcoin/bitcoin#31397: p2p: track and use all potential peers for orphan resolution 2025-01-16 13:42:26 +00:00
txorphan.cpp [p2p] only attempt 1p1c when both txns provided by the same peer 2025-01-06 09:02:05 -05:00
txrequest.cpp scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
util.cpp util: Implement ParseISO8601DateTime based on C++20 2024-12-02 08:21:32 +01:00
util.h refactor: Reserve vectors in fuzz tests 2024-11-25 20:09:44 +01:00
utxo_snapshot.cpp fuzz: Add SetMockTime() to necessary targets 2025-01-06 15:43:04 +00:00
utxo_total_supply.cpp fuzz: Add SetMockTime() to necessary targets 2025-01-06 15:43:04 +00:00
validation_load_mempool.cpp fuzz: Add missing SeedRandomStateForTest(SeedRand::ZEROS) 2024-12-13 14:22:25 +01:00
vecdeque.cpp random: convert XoRoShiRo128PlusPlus into full RNG 2024-07-01 10:26:46 -04:00
versionbits.cpp scripted-diff: Use new FUZZ_TARGET macro everywhere 2023-07-13 20:37:14 +02:00