Commit graph

27032 commits

Author SHA1 Message Date
Ava Chow
5373aa30e2
Merge bitcoin/bitcoin#30788: test: fixing failing system_tests/run_command under some Locales
ae48a22a3d test: fixing failing system_tests/run_command under some Locales (Jadi)

Pull request description:

  the run_command test under system_tests fails if the locale is anything
  other than English ones because results such as "No such file or directory"
  will be different under Non-English locales.

  On the old version, a `ls nonexistingfile` was used to generate the error
  output which is not ideal. In the current version we are using a Python one-liner
  to generate a non 0 zero return value and "err" on stderr and check the
  expected value against this.

  fixes https://github.com/bitcoin/bitcoin/issues/30608

ACKs for top commit:
  maflcko:
    review ACK ae48a22a3d
  achow101:
    ACK ae48a22a3d
  hebasto:
    ACK ae48a22a3d, tested on Ubuntu 24.04 by switching locale.

Tree-SHA512: af7522ddcd786fa4a6832c8336ca89d8ff05f49ff963cbe1a96653b0edf29e0f950a032f23d742b16b3895e90cf5117b5f6a95464268dec67039df166d7d8639
2024-09-04 15:28:41 -04:00
Ava Chow
3210d87dfc
Merge bitcoin/bitcoin#29043: fuzz: make FuzzedDataProvider usage deterministic
01960c53c7 fuzz: make FuzzedDataProvider usage deterministic (Martin Leitner-Ankerl)

Pull request description:

  There exist many usages of `fuzzed_data_provider` where it is evaluated directly in the function call.
  Unfortunately, [the order of evaluation of function arguments is unspecified](https://en.cppreference.com/w/cpp/language/eval_order), and a simple example shows that it can differ e.g. between clang++ and g++: https://godbolt.org/z/jooMezWWY

  When the evaluation order is not consistent, the same fuzzing/random input will produce different output, which is bad for coverage/reproducibility. This PR fixes all these cases I have found where unspecified evaluation order could be a problem.

  Finding these has been manual work; I grepped the sourcecode for these patterns, and looked at each usage individually. So there is a chance I missed some.

  * `fuzzed_data_provider`
  * `.Consume`
  * `>Consume`
  * `.rand`

  I first discovered this in https://github.com/bitcoin/bitcoin/pull/29013#discussion_r1420236394. Note that there is a possibility that due to this fix the evaluation order is now different in many cases than when the fuzzing corpus has been created. If that is the case, the fuzzing corpus will have worse coverage than before.

  Update: In list-initialization the order of evaluation is well defined, so e.g. usages in `initializer_list` or constructors that use `{...}` is ok.

ACKs for top commit:
  achow101:
    ACK 01960c53c7
  vasild:
    ACK 01960c53c7
  ismaelsadeeq:
    ACK 01960c53c7

Tree-SHA512: e56d087f6f4bf79c90b972a5f0c6908d1784b3cfbb8130b6b450d5ca7d116c5a791df506b869a23bce930b2a6977558e1fb5115bb4e061969cc40f568077a1ad
2024-09-04 15:04:53 -04:00
Ava Chow
81276540d3
Merge bitcoin/bitcoin#30148: cli: restrict multiple exclusive argument usage in bitcoin-cli
c8e6771af0 test: restrict multiple CLI arguments (naiyoma)
8838c4f171 common/args.h: automate check for multiple cli commands (naiyoma)

Pull request description:

  This PR is a continuation of the validation suggested [here](https://github.com/bitcoin/bitcoin/pull/27815) to ensure that only one Request Handler can be specified at a time.

ACKs for top commit:
  stratospher:
    reACK c8e6771.
  achow101:
    ACK c8e6771af0
  tdb3:
    cr re ACK c8e6771af0

Tree-SHA512: f4fe036fee342a54f1a7ac702ac35c40bf3d420fde6ab16313a75327292d5ee5c8ece1be9f852a13fcf73da1148b143b37b4894e294052abdde6eefb2e8c6f3f
2024-09-04 14:47:38 -04:00
Ava Chow
cb65ac469a
Merge bitcoin/bitcoin#29605: net: Favor peers from addrman over fetching seednodes
6eeb188d40 test: adds seednode functional tests (Sergi Delgado Segura)
3270f0adad net: Favor peers from addrman over fetching seednodes (Sergi Delgado Segura)

Pull request description:

  This is a follow-up of #28016 motivated by https://github.com/bitcoin/bitcoin/pull/28016#pullrequestreview-1913140932 and https://github.com/bitcoin/bitcoin/pull/28016#issuecomment-1984448937.

  The current behavior of seednode fetching is pretty eager: we do it as the first step under `ThreadOpenNetworkConnections` even if some peers may be queryable from our addrman. This poses two potential issues:

  - First, if permanently set (e.g. running with seednode in a config file) we'd be signaling such seed every time we restart our node
  - Second, we will be giving the seed node way too much influence over our addrman, populating the latter with data from the former even when unnecessary

  This changes the behavior to only add seednodes to `m_addr_fetch` if our addrman is empty, or little by little after we've spent some time trying addresses from our addrman. Also, seednodes are added to `m_addr_fetch` in random order, to avoid signaling the same node in case more than one seed is added and we happen to try them over multiple restarts

ACKs for top commit:
  achow101:
    ACK 6eeb188d40
  cbergqvist:
    ACK 6eeb188d40
  itornaza:
    Tested ACK 6eeb188d40
  tdb3:
    ACK 6eeb188d40

Tree-SHA512: b04445412f22018852d6bef4d3f1e88425ee6ddb434f61dcffa9e0c41b8e31f8c56f83858d5c7686289c86dc4c9476c437df15ea61a47082e2bb2e073cc62f15
2024-09-04 13:15:08 -04:00
Ava Chow
b8d2f58e06
Merge bitcoin/bitcoin#30808: rpc: dumptxoutset height parameter follow-ups (29553)
a3108a7c56 rpc: Manage dumptxoutset rollback with RAII class (Fabian Jahr)
c5eaae3b89 doc: Add -rpcclienttimeout=0 to loadtxoutset examples (Fabian Jahr)
598b9bba5a rpc: Don't re-enable previously disabled network after dumptxoutset (Fabian Jahr)

Pull request description:

  First, this addresses two left-over comments in #29553:

  - When running `dumptxoutset` the network gets disabled in the beginning and then re-enabled at the end. The network would be re-enabled even if the user had already disabled the network themself before running `dumptxoutset`. The network is now not re-enabled anymore since that might not be what the user wants.
  - The `-rpcclienttimeout=0` option is added to `loadtxoutset` examples in documentation

  Additionally, pablomartin4btc notified me that he found his node stuck at the invalidated height after some late testing after #29553 was merged. We could not find the actual source of the issue since his logs got lost. However, it seems likely that some kind of disruption stopped the process before the node could roll forward again. We fixed this issue for network disablement with a RAII class previously and it seems logical that this can happen the same way for the rollback part so I suggest to also fix it the same way.

  An example to reproduce the issue described above as I think it happened: Remove the `!` in the following line in `PrepareUTXOSnapshot()` to simulate an issue occurring during `GetUTXOStats()`.

  ```
  if (!maybe_stats) {
  ```

  This leaves the node in the following state on master:

  ```
  $ build/src/bitcoin-cli -rpcclienttimeout=0 -named dumptxoutset utxo-859750.dat rollback=859750
  error code: -32603
  error message:
  Unable to read UTXO set
  $ build/src/bitcoin-cli getchaintips
  [
    {
      "height": 859762,
      "hash": "00000000000000000002ec7a0fcca3aeca5b35545b52eb925766670aacc704ad",
      "branchlen": 12,
      "status": "headers-only"
    },
    {
      "height": 859750,
      "hash": "0000000000000000000010897b6b88a18f9478050200d8d048013c58bfd6229e",
      "branchlen": 0,
      "status": "active"
    },
  ```

  (Note that the first tip is `headers-only` and not `invalid` only because I started `dumptxoutset` before my node had fully synced to the tip. pablomartin4btc saw it as `invalid`.)

ACKs for top commit:
  maflcko:
    re-ACK a3108a7c56 🐸
  achow101:
    ACK a3108a7c56
  pablomartin4btc:
    cr ACK a3108a7c56

Tree-SHA512: d2ab32f62de2253312e27d7d753ec0995da3fe7a22ffc3d6c7cfa3b68a4a144c59210aa82b7a704c2a29c3b2aad6ea74972e3e8bb979ee4b7082a20f4bfddc9c
2024-09-04 11:40:26 -04:00
stickies-v
f51b237723
refactor: rpc: use uint256::FromHex for ParseHashV
uint256S() is deprecated for being unsafe, and will be removed
in a future commit.
2024-09-04 16:39:55 +01:00
glozow
f66011e88f
Merge bitcoin/bitcoin#30784: test: add check that too large txs aren't put into orphanage
66d13c8702 test: add check that large txs aren't put into orphanage (Sebastian Falbesoner)
ed7d224666 test: add `BulkTransaction` helper to unit test transaction utils (Sebastian Falbesoner)

Pull request description:

  This PR adds test coverage for the following check in `TxOrphanage::AddTx`, where large orphan txs are ignored in order to avoid memory exhaustion attacks:
  5abb9b1af4/src/txorphanage.cpp (L22-L34)
  Note that this code-path isn't reachable under normal circumstances, as txs larger than `MAX_STANDARD_TX_WEIGHT` are already rejected earlier in the course of doing the mempool standardness checks (see `MemPoolAccept::PreChecks` -> `IsStandardTx` -> `reason = "tx-size";`), so this is only relevant if tx standardness rules are disabled via `-acceptnonstdtxns=1`. The ignore path is checked ~~by asserting the debug log, which is ugly, but as far as I know there is currently no way to access the orphanage entries from the outside~~ via unit test that checks the return value of `AddTx`. As an alternative to adding test coverage, one might consider removing this check altogether (or replacing it with an `Assume`), as it's redundant as explained above.

ACKs for top commit:
  maflcko:
    review ACK 66d13c8702
  glozow:
    ACK 66d13c8702
  tdb3:
    re-ACK 66d13c8702

Tree-SHA512: 88e8254ab5fca70c387a5992649ea6a704a65162999be972cc86bd74fc26c5f0f1e13e04856708d07ad5524cb77c0918e19663db92b3593e842469dfe04af6a1
2024-09-04 10:20:33 -04:00
Fabian Jahr
a3108a7c56
rpc: Manage dumptxoutset rollback with RAII class 2024-09-04 16:04:17 +02:00
Fabian Jahr
c5eaae3b89
doc: Add -rpcclienttimeout=0 to loadtxoutset examples 2024-09-04 15:49:04 +02:00
Fabian Jahr
598b9bba5a
rpc: Don't re-enable previously disabled network after dumptxoutset
Also fixes a typo in the RPC help text.
2024-09-04 15:49:03 +02:00
merge-script
ab317ad2ef
Merge bitcoin/bitcoin#30804: fuzz: Rename fuzz_seed_corpus to fuzz_corpora
8888beea8d scripted-diff: fuzz: Rename fuzz_seed_corpus to fuzz_corpora (MarcoFalke)

Pull request description:

  Now that cmake was a breaking change for all fuzz scripts, it seems fine to bundle it with another breaking change to rename the fuzz corpora directory, as discussed and approved in https://github.com/bitcoin-core/qa-assets/issues/200:

  * The word "seed" in the old name doesn't really apply. In reality it is a collection of fuzz input seeds, as well as fuzz inputs.
  * The rename will also allow in the future (when there is a need and desire) to provide a minimal set of possibly hand-crafted or otherwise non-fuzz-generated fuzz seed inputs to some fuzz targets (and possibly store them in a separate folder and validate that their format is still accurate and matches the fuzz target code).
  * Finally, "corpus" is renamed to corpora, to clarify that the folder holds the fuzz inputs for several fuzz targets.

ACKs for top commit:
  brunoerg:
    ACK 8888beea8d
  marcofleon:
    ACK 8888beea8d

Tree-SHA512: abc693ca5d946850f04b6349e2a98f8fbc2ba9991be5a025bc0f357e341cbe7510f2f5f0e47b997d07136736d818df361270f372b8fb70860995a0605ca81e4d
2024-09-04 14:04:27 +01:00
merge-script
4835bba2cb
Merge bitcoin/bitcoin#30802: doc: Clarify libbitcoin_consensus in design/libraries.md
fa78ed83be doc: Clarify libbitcoin_consensus in design/libraries.md (MarcoFalke)

Pull request description:

  Now that the shared library has been removed in commit 80f8b92f4f, update the documentation to drop the no-longer applicable prefix "Stable...".

ACKs for top commit:
  hebasto:
    ACK fa78ed83be.
  fanquake:
    ACK fa78ed83be

Tree-SHA512: d7b946d50f734c0474ff6155a655a2bb873f76e071bfeeca1dd42ea5fdd32bc1e45129826bb54e3f111265d19c2aba2d02cb77ad7663f9fc40c8c875e5fddda2
2024-09-04 10:13:56 +01:00
Jadi
ae48a22a3d test: fixing failing system_tests/run_command under some Locales
the run_command test under system_tests fails if the locale is anything
other than English ones because results such as "No such file or directory"
will be different under Non-English locales.

On the old version, a `ls nonexistingfile` was used to generate the error
output which is not ideal. In the current version we are using a Python one-liner
to generate a non 0 zero return value and "err" on stderr and check the
expected value against this.

fixes #30608
2024-09-04 09:30:05 +03:30
Ava Chow
94c307b3c0
Merge bitcoin/bitcoin#30675: http: set TCP_NODELAY when creating HTTP server
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
03d49d0f25 http: set TCP_NODELAY when creating HTTP server (Roman Zeyde)

Pull request description:

  Otherwise, the default HTTP server config may result in high latency, due to Nagle's algorithm (on the server) and delayed ACK (on the client):

  [1] https://www.extrahop.com/blog/tcp-nodelay-nagle-quickack-best-practices
  [2] https://eklitzke.org/the-caveats-of-tcp-nodelay

  Without the fix, fetching a small block takes ~40ms (when connection keep-alive is enabled):
  ```
  $ ab -k -c 1 -n 100 http://localhost:8332/rest/block/00000000000002b5898f7cdc80d9c84e9747bc6b9388cc989971d443f05713ee.bin

  Server Software:
  Server Hostname:        localhost
  Server Port:            8332

  Document Path:          /rest/block/00000000000002b5898f7cdc80d9c84e9747bc6b9388cc989971d443f05713ee.bin
  Document Length:        25086 bytes

  Concurrency Level:      1
  Time taken for tests:   4.075 seconds
  Complete requests:      100
  Failed requests:        0
  Keep-Alive requests:    100
  Total transferred:      2519200 bytes
  HTML transferred:       2508600 bytes
  Requests per second:    24.54 [#/sec] (mean)
  Time per request:       40.747 [ms] (mean)
  Time per request:       40.747 [ms] (mean, across all concurrent requests)
  Transfer rate:          603.76 [Kbytes/sec] received

  Connection Times (ms)
                min  mean[+/-sd] median   max
  Connect:        0    0   0.0      0       0
  Processing:     0   41   4.1     41      42
  Waiting:        0    0   0.1      0       1
  Total:          0   41   4.1     41      42

  Percentage of the requests served within a certain time (ms)
    50%     41
    66%     41
    75%     41
    80%     41
    90%     42
    95%     42
    98%     42
    99%     42
   100%     42 (longest request)
  ```

  With the fix, it takes ~0.2ms:
  ```
  $ ab -k -c 1 -n 1000 http://localhost:8332/rest/block/00000000000002b5898f7cdc80d9c84e9747bc6b9388cc989971d443f05713ee.bin

  Benchmarking localhost (be patient)
  Completed 100 requests
  Completed 200 requests
  Completed 300 requests
  Completed 400 requests
  Completed 500 requests
  Completed 600 requests
  Completed 700 requests
  Completed 800 requests
  Completed 900 requests
  Completed 1000 requests
  Finished 1000 requests

  Server Software:
  Server Hostname:        localhost
  Server Port:            8332

  Document Path:          /rest/block/00000000000002b5898f7cdc80d9c84e9747bc6b9388cc989971d443f05713ee.bin
  Document Length:        25086 bytes

  Concurrency Level:      1
  Time taken for tests:   0.194 seconds
  Complete requests:      1000
  Failed requests:        0
  Keep-Alive requests:    1000
  Total transferred:      25192000 bytes
  HTML transferred:       25086000 bytes
  Requests per second:    5147.05 [#/sec] (mean)
  Time per request:       0.194 [ms] (mean)
  Time per request:       0.194 [ms] (mean, across all concurrent requests)
  Transfer rate:          126625.50 [Kbytes/sec] received

  Connection Times (ms)
                min  mean[+/-sd] median   max
  Connect:        0    0   0.0      0       0
  Processing:     0    0   0.0      0       0
  Waiting:        0    0   0.0      0       0
  Total:          0    0   0.0      0       0

  Percentage of the requests served within a certain time (ms)
    50%      0
    66%      0
    75%      0
    80%      0
    90%      0
    95%      0
    98%      0
    99%      0
   100%      0 (longest request)
  ```

ACKs for top commit:
  achow101:
    ACK 03d49d0f25
  theStack:
    re-ACK 03d49d0f25
  tdb3:
    ACK 03d49d0f25

Tree-SHA512: bbf3d78b8521f569430850ec4315a75711303547df1a3de213a4ad34c9700105e374e0a649352fd05f8e4badb5b59debd3720e1c5d392c5113d7816648f7fcaa
2024-09-03 17:27:50 -04:00
Ava Chow
27e89bc2f5
Merge bitcoin/bitcoin#26619: log: expand BCLog::LogFlags (categories) to 64 bits
b31a0cd037 log: expand BCLog::LogFlags (categories) to 64 bits (Larry Ruane)

Pull request description:

  Increase the maximum number of logging categories from 32 to 64.

  We're currently using 29 of the 32 available logging categories (there are only 3 remaining). It would be good to increase the limit soon; the fourth PR to be merged that adds a new logging category will be blocked until something like this is done.

  This PR also adds a `TEST` category that uses the new range (`1ULL << 63`) in case there's a hidden assumption somewhere that the `BCLog::LogFlags` type is 32 bits. (Also added a test for this test category.) It also provides an example showing that the expression must be `1ULL << <shift>` for shift value 31 and beyond.

ACKs for top commit:
  achow101:
    ACK b31a0cd037
  vasild:
    ACK b31a0cd037
  ryanofsky:
    Code review ACK b31a0cd037, just dropping mask_bit constant since last review. I still think
  theStack:
    Code-review ACK b31a0cd037

Tree-SHA512: de422dbeb479848d370aed42d415f42461457ab0eda62b245dc7ff9f0e111626e7d4c0d62ff13082ec664d05fbb0db04c71eb4b6f22eb8f19198826a67c4035e
2024-09-03 16:33:49 -04:00
Sebastian Falbesoner
66d13c8702 test: add check that large txs aren't put into orphanage 2024-09-03 22:23:48 +02:00
Sebastian Falbesoner
ed7d224666 test: add BulkTransaction helper to unit test transaction utils
The padding method used matches the one used in MiniWallet,
`MiniWallet._bulk_tx`.
2024-09-03 22:20:01 +02:00
Ava Chow
d4b5553849
Merge bitcoin/bitcoin#30742: kernel: Use spans instead of vectors for passing block headers to validation functions
a2955f0979 validation: Use span for ImportBlocks paths (TheCharlatan)
20515ea3f5 validation: Use span for CalculateClaimedHeadersWork (TheCharlatan)
52575e96e7 validation: Use span for ProcessNewBlockHeaders (TheCharlatan)

Pull request description:

  Makes it friendlier for potential future users of the kernel library if they do not store the headers in a std::vector, but can guarantee contiguous memory.

  Take this opportunity to also change the argument of ImportBlocks previously taking a `std::vector` to a `std::span`.

ACKs for top commit:
  stickies-v:
    re-ACK a2955f0979 - no changes except further walking the ~file~ path of modernizing variable names.
  maflcko:
    ACK a2955f0979 🕑
  achow101:
    ACK a2955f0979
  danielabrozzoni:
    ACK a2955f0979

Tree-SHA512: 8b07f4ad26e270b65600d1968cd78847b85caca5bfbb83fd9860389f26656b1d9a40b85e0990339f50403d18cedcd2456990054f3b8b0bedce943e50222d2709
2024-09-03 15:40:40 -04:00
Ava Chow
fa5fc71199
Merge bitcoin/bitcoin#29553: assumeutxo: Add dumptxoutset height param, remove shell scripts
94b0adcc37 rpc, refactor: Prevent potential race conditions in dumptxoutset (Fabian Jahr)
e868a6e070 doc: Improve assumeutxo guide and add more docs/comments (Fabian Jahr)
b29c21fc92 assumeutxo: Remove devtools/utxo_snapshot.sh (Fabian Jahr)
20a1c77aa7 contrib: Remove test_utxo_snapshots.sh (Fabian Jahr)
8426850352 test: Test for dumptxoutset at specific height (Fabian Jahr)
993cafe7e4 RPC: Add type parameter to dumptxoutset (Fabian Jahr)
fccf4f91d2 RPC: Extract ReconsiderBlock helper (Fabian Jahr)
446ce51c21 RPC: Extract InvalidateBlock helper (Fabian Jahr)

Pull request description:

  This adds a height parameter to the `dumptxoutset` RPC. This internalizes the workflow that was previously done by scripts: roll back the chain to the height we actually want the snapshot from, create the snapshot, roll forward to the real tip again.

  The nice thing about internalizing this functionality is that we can write tests for the code and it gives us more options to make the functionality robust. The shell scripts we have so far will be more cumbersome to maintain in the long run, especially since we will only notice later when we have broken them. I think it's safe to remove these `test_utxo_snapshots.sh` as well when we have this option in `dumptxoutset` because we have also added some good additional functional test coverage for this functionality.

ACKs for top commit:
  Sjors:
    re-utACK 94b0adcc37
  achow101:
    ACK 94b0adcc37
  mzumsande:
    ACK 94b0adcc37
  pablomartin4btc:
    re-ACK 94b0adcc37

Tree-SHA512: a4c9af5f687d1ca7bfb579a36f363882823386b5fa80c05de531b05a2782b5da6ff5baf3ada4bca8f32f63975d86f1948175abed9affe51fc958472b5f838dab
2024-09-03 15:30:45 -04:00
MarcoFalke
8888beea8d
scripted-diff: fuzz: Rename fuzz_seed_corpus to fuzz_corpora
-BEGIN VERIFY SCRIPT-
 ren() { sed -i "s:\<$1\>:$2:g" $( git grep -l "$1" ) ; }
 ren fuzz_seed_corpus     fuzz_corpora
 ren FUZZ_SEED_CORPUS_DIR FUZZ_CORPORA_DIR
-END VERIFY SCRIPT-
2024-09-03 20:40:35 +02:00
MarcoFalke
fa78ed83be
doc: Clarify libbitcoin_consensus in design/libraries.md 2024-09-03 19:35:43 +02:00
MarcoFalke
fac973647d
test: Use string_view for json_tests
This avoids a static constructor of the global std::string, and rules
out possibly expensive and implicit copies of the string completely.
2024-09-03 16:06:20 +02:00
merge-script
9cb9651d92
Merge bitcoin/bitcoin#30778: build: Fix linking for fuzz target when building with MSan
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
787dfaf084 ci: Do not override `-g -O1` set in `MSAN_FLAGS` (Hennadii Stepanov)
26c460aa8b build: Fix linking for `fuzz` target when building with MSan (Hennadii Stepanov)

Pull request description:

  The first commit fixes https://github.com/bitcoin/bitcoin/issues/30760.

  The second commit:
  1. Preserves `-g -O1` set in `MSAN_FLAGS`. Since configuration-specific flags override general flags, these are set to empty strings. A similar approach is used in the OSS-Fuzz repository.
  2. Sets the "Debug" build configuration when depends are built with `DEBUG=1`, ensuring that `linux_debug_CPPFLAGS` from depends are passed to the main build system.

ACKs for top commit:
  maflcko:
    review-only ACK 787dfaf084
  fanquake:
    ACK 787dfaf084 - as a follow up it would be good to:

Tree-SHA512: c324390d1dbda30f82025d8482ddb0cfa0395f9ba225a2ddce05a123c65e0622a6a1d5f0fa03f09e21d62792431cf3da5c49e41a3ac7f7a958d0392a0430f29c
2024-09-03 12:15:28 +01:00
merge-script
4c526f575c
Merge bitcoin/bitcoin#30741: doc: update documentation and scripts related to build directories
6a68343ffb doc: Prepend 'build/' to binary paths under 'src/' in docs (Lőrinc)
91b3bc2b9c doc: Update documentation generation example in developer-notes.md (Lőrinc)

Pull request description:

  In [the other readmes](6ce50fd9d0/src/test/README.md (L19)) we've provided a default build directory instead, unified the `developer-notes.md` to specify it explicitly.

  In the next commit I've used this default to go over each reference to our binaries and changed their in-source references to the build directory.
  Some of these changes were in example outputs - I haven't validated that the outputs are still the same.
  I haven't modified the build folders in the devtools.

ACKs for top commit:
  maflcko:
    review ACK 6a68343ffb
  pablomartin4btc:
    ACK 6a68343ffb
  fanquake:
    ACK 6a68343ffb - we still need to followup with other scripts/devtools, and likely unify what we are doing in some way, but this is an improvement.

Tree-SHA512: 905d9c68cafe1e405e98d6aa089d7a36a34c9e03403df5c67ac2c9a98cfa54a0305b647cb92247dcb9f49e9b509a8ba88367392b95618c67059684c67b6c36fb
2024-09-03 10:31:00 +01:00
Hennadii Stepanov
26c460aa8b
build: Fix linking for fuzz target when building with MSan 2024-09-02 23:18:16 +01:00
Sebastian Falbesoner
7346b01092 qt, build: remove unneeded Q_IMPORT_PLUGIN macro calls
After the recent full removal of Autotools (PR #30664), these
macros are not needed anymore in the .cpp files according to the
TODO in qt's CMakeLists.txt. Tested building on OpenBSD 7.5, where
the XCB plugin was still imported according to the debug log.
2024-09-02 23:01:30 +02:00
marcofleon
a0eaa4749f Add FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION in PoW check
To avoid PoW being a blocker for fuzz tests,
`FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION` is used in fuzz builds to
bypass the actual PoW validation in `CheckProofOfWork`. It's
replaced with a check on the last byte of the hash, which allows the
fuzzer to quickly generate (in)valid blocks by checking a single bit,
rather than performing the full PoW computation.

If PoW is the target of a fuzz test, then it should call
`CheckProofOfWorkImpl`.
2024-09-02 15:43:33 +01:00
marcofleon
0c02d4b2bd net_processing: Make MAX_HEADERS_RESULTS a PeerManager option 2024-09-02 15:42:44 +01:00
merge-script
d4cc0c6845
Merge bitcoin/bitcoin#30750: scripted-diff: LogPrint -> LogDebug
fa09cb41f5 refactor: Remove unused LogPrint (MarcoFalke)
3333415890 scripted-diff: LogPrint -> LogDebug (MarcoFalke)

Pull request description:

  `LogPrint` has many issues:

  * It seems to indicate that something is being "printed", however config options such as `-printtoconsole` actually control what and where something is logged.
  * It does not mention the log severity (debug).
  * It is a deprecated alias for `LogDebug`, according to the dev notes.
  * It wastes review cycles, because reviewers sometimes point out that it is deprecated.
  * It makes the code inconsistent, when both are used, possibly even in lines right next to each other (like in `InitHTTPServer`)

  Fix all issues by removing the deprecated alias.

  I checked all conflicting pull requests and at the time of writing there are no conflicts, except in pull requests that are marked as draft, are yet unreviewed, or are blocked on feedback for other reasons. So I think it is fine to do now.

ACKs for top commit:
  stickies-v:
    ACK fa09cb41f5
  danielabrozzoni:
    utACK fa09cb41f5
  TheCharlatan:
    ACK fa09cb41f5

Tree-SHA512: 14270f4cfa3906025a0b994cbb5b2e3c8c2427c0beb19c717a505a2ccbfb1fd1ecf2fd03f6c52d22cde69a8d057e50d2207119fab2c2bc8228db3f10d4288d0f
2024-09-02 11:59:56 +01:00
merge-script
ef6f49ecaf
Merge bitcoin/bitcoin#30664: build: Remove Autotools-based build system
faa382ae76 ci, doc: Drop reference to `src/.bear-tidy-config` (Hennadii Stepanov)
d71ac76842 build: Remove Autotools-based build system (Hennadii Stepanov)
e268b48419 doc: Adjust `doc/design/libraries.md` (Hennadii Stepanov)
d209e4f156 doc: Drop mentions of `share/genbuild.sh` (Hennadii Stepanov)

Pull request description:

  This PR deletes the Autotools-based build system.

  The MSVC build system is deleted in https://github.com/bitcoin/bitcoin/pull/30731.

ACKs for top commit:
  maflcko:
    re-ACK faa382ae76 🍦
  TheCharlatan:
    ACK faa382ae76
  fanquake:
    ACK faa382ae76

Tree-SHA512: 53df977b5b199a1c38f7f61a042a62b24831c559ba65a461b4ac1c96a1a56e2dfd676df79f1358fd1cc1749ff27e7b548086157f337d4f596c1054cb3d2d5739
2024-09-02 11:39:56 +01:00
MarcoFalke
fa84f9decd
test: Pin and document TEST_DIR_PATH_ELEMENT 2024-09-02 09:28:52 +02:00
Fabian Jahr
94b0adcc37
rpc, refactor: Prevent potential race conditions in dumptxoutset
Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2024-09-01 21:07:23 +02:00
Fabian Jahr
e868a6e070
doc: Improve assumeutxo guide and add more docs/comments
Also fixes some outdated information in the remaining design doc.
2024-09-01 21:07:21 +02:00
Fabian Jahr
993cafe7e4
RPC: Add type parameter to dumptxoutset 2024-09-01 20:56:38 +02:00
Fabian Jahr
fccf4f91d2
RPC: Extract ReconsiderBlock helper 2024-09-01 20:56:38 +02:00
Fabian Jahr
446ce51c21
RPC: Extract InvalidateBlock helper 2024-09-01 20:56:37 +02:00
Ryan Ofsky
b52d547361
Merge bitcoin/bitcoin#30377: refactor: Replace ParseHex with consteval ""_hex literals
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
8756ccd712 scripted-diff: Replace ParseHex[<std::byte>]("str") -> "str"_hex[_u8] (Hodlinator)
9cb687351f refactor: Prepare for ParseHex -> ""_hex scripted-diff (Hodlinator)
50bc017040 refactor: Hand-replace some ParseHex -> ""_hex (Hodlinator)
5b74a849cf util: Add consteval ""_hex[_v][_u8] literals (l0rinc)
dc5f6f6812 test refactor: util_tests - parse_hex clean up (Hodlinator)
2b5e6eff36 refactor: Make XOnlyPubKey tolerate constexpr std::arrays (Hodlinator)
403d86f1cc refactor: vector -> span in CCrypter (Hodlinator)
bd0830bbd4 refactor: de-Hungarianize CCrypter (Hodlinator)
d99c816971 refactor: Improve CCrypter related lines (Hodlinator)
7e1d9a8468 refactor: Enforce lowercase hex digits for consteval uint256 (Hodlinator)

Pull request description:

  Motivation:
  * Validates and converts the hex string into bytes at compile time instead of at runtime like `ParseHex()`.
  * Eliminates runtime dependencies: https://github.com/bitcoin/bitcoin/pull/30377#issuecomment-2214432177, https://github.com/bitcoin/bitcoin/pull/30048#discussion_r1592108480
  * Has stricter requirements than `ParseHex()` (disallows whitespace and uppercase hex digits) and replaces it in a bunch of places.
  * Makes it possible to derive other compile time constants.
  * Minor: should shave off a few runtime CPU cycles.

  `""_hex` produces `std::array<std::byte>` as the momentum in the codebase is to use `std::byte` over `uint8_t`.

  Also makes `uint256` hex string constructor disallow uppercase hex digits. Discussed: https://github.com/bitcoin/bitcoin/pull/30560#discussion_r1701323070

  Surprisingly does not change the size of the Guix **bitcoind** binary (on x86_64-linux-gnu) by 1 single byte.

  Spawned already merged PRs: #30436, #30482, #30532, #30560.

ACKs for top commit:
  l0rinc:
    ACK 8756ccd712
  stickies-v:
    Rebase re-ACK 8756ccd712, no changes since a096215c9c71a2ec03e76f1fd0bcdda0727996e0
  ryanofsky:
    Code review ACK 8756ccd712, just rebasing since last review and taking advantage of CScript constructors in #29369, also tweaking a code comment

Tree-SHA512: 9b2011b7c37e0ef004c669f8601270a214b388916316458370f5902c79c2856790b1b2c7c123efa65decad04886ab5eff95644301e0d84358bb265cf1f8ec195
2024-08-31 10:18:00 -04:00
Hennadii Stepanov
d71ac76842
build: Remove Autotools-based build system 2024-08-30 21:31:39 +01:00
TheCharlatan
a2955f0979
validation: Use span for ImportBlocks paths
Makes it friendlier for potential future users of the kernel library if
they do not store the headers in a std::vector, but can guarantee
contiguous memory.
2024-08-30 12:39:46 +02:00
TheCharlatan
20515ea3f5
validation: Use span for CalculateClaimedHeadersWork
Makes it friendlier for potential future users of the kernel library if
they do not store the headers in a std::vector, but can guarantee
contiguous memory.
2024-08-30 10:17:26 +02:00
TheCharlatan
52575e96e7
validation: Use span for ProcessNewBlockHeaders
Makes it friendlier for potential future users of the kernel library if
they do not store the headers in a std::vector, but can guarantee
contiguous memory.
2024-08-30 10:17:09 +02:00
MarcoFalke
fa09cb41f5
refactor: Remove unused LogPrint 2024-08-29 15:58:27 +02:00
Lőrinc
6a68343ffb doc: Prepend 'build/' to binary paths under 'src/' in docs 2024-08-29 15:23:12 +02:00
MarcoFalke
3333415890
scripted-diff: LogPrint -> LogDebug
-BEGIN VERIFY SCRIPT-
 sed -i 's/\<LogPrint\>/LogDebug/g' $( git grep -l '\<LogPrint\>'  -- ./contrib/ ./src/ ./test/ ':(exclude)src/logging.h' )
-END VERIFY SCRIPT-
2024-08-29 13:49:57 +02:00
Hennadii Stepanov
d209e4f156
doc: Drop mentions of share/genbuild.sh 2024-08-29 12:38:37 +01:00
MarcoFalke
2222f7a874
test: Rename SeedRand::SEED to FIXED_SEED for clarity 2024-08-29 09:38:05 +02:00
Hodlinator
8756ccd712
scripted-diff: Replace ParseHex[<std::byte>]("str") -> "str"_hex[_u8]
Ideally all call sites should accept std::byte instead of uint8_t but those transformations are left to future PRs.

-BEGIN VERIFY SCRIPT-
sed -i --regexp-extended 's/\bParseHex\(("[^"]*")\)/\1_hex_u8/g' $(git grep -l ParseHex -- :src ':(exclude)src/test/util_tests.cpp')
sed -i --regexp-extended 's/\bParseHex<std::byte>\(("[^"]*")\)/\1_hex/g' $(git grep -l ParseHex -- :src ':(exclude)src/test/util_tests.cpp')
sed -i --regexp-extended 's/\bScriptFromHex\(("[^"]*")\)/ToScript(\1_hex)/g' src/test/script_tests.cpp
-END VERIFY SCRIPT-

Co-Authored-By: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
Co-Authored-By: Ryan Ofsky <ryan@ofsky.org>
2024-08-28 19:11:59 +02:00
Hodlinator
9cb687351f
refactor: Prepare for ParseHex -> ""_hex scripted-diff
- Adds using namespace.
- Extracts ToScript helper function from ScriptFromHex, to be used heavily in the next commit.
- Changes ScriptFromHex from using ParseHex to TryParseHex, now asserting the string is valid.
- Use even number of hex digits in comment (and apply replacement from next commit to only touch line once).
2024-08-28 19:11:59 +02:00
Hodlinator
50bc017040
refactor: Hand-replace some ParseHex -> ""_hex
The following scripted-diff commit will replace ParseHex("...") with "..."_hex_u8, but this replacement will not work in cases where vectors are needed instead of arrays, and is not ideal in cases where std::byte is accepted.

For example, it is currently necessary to use _hex_v_u8 when calling CScript operator<< because that operator does not currently support std::array or std::byte.

Conversely, it is incorrect to use _hex_v instead of _hex in net_processing.cpp for the MakeAndPushMessage argument, because if the argument is a std::vector it is considered variable-length and serialized with a size prefix, but if the argument is a std::array or Span is it considered fixed length and serialized without a prefix.

By the same logic, it is also safe to change the NUMS_H constant in pubkey.cpp from a std::vector to std::array because it is never serialized.
2024-08-28 19:11:59 +02:00
l0rinc
5b74a849cf
util: Add consteval ""_hex[_v][_u8] literals
""_hex is a compile-time user-defined literal returning std::array<std::byte>, equivalent of ParseHex.

Variants:
- ""_hex_v returns std::vector<std::byte>
- ""_hex_u8 returns std::array<uint8_t>
- ""_hex_v_u8 returns std::vector<uint8_t> - Directly serializable as a size-prefixed OP_PUSH CScript payload using operator<<.

Also extracts from_hex into shared util::ConstevalHexDigit function.

Co-Authored-By: hodlinator <172445034+hodlinator@users.noreply.github.com>
Co-Authored-By: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
Co-Authored-By: Ryan Ofsky <ryan@ofsky.org>
Co-Authored-By: stickies-v <stickies-v@protonmail.com>
2024-08-28 19:09:51 +02:00