Commit graph

42661 commits

Author SHA1 Message Date
Ryan Ofsky
d043950ba2 multiprocess: Add serialization code for BlockValidationState
Co-authored-by: TheCharlatan <seb.kung@gmail.com>
2024-09-23 16:03:04 -04:00
Ryan Ofsky
33c2eee285 multiprocess: Add IPC wrapper for Mining interface 2024-09-23 16:03:04 -04:00
Russell Yanofsky
06882f8401 multiprocess: Add serialization code for vector<char> 2024-09-23 15:03:04 -05:00
Russell Yanofsky
095286f790 multiprocess: Add serialization code for CTransaction
Add support for passing CTransaction and CTransactionRef types to IPC
functions.

These types can't be passed currently because IPC serialization code currently
only supports deserializing types that have an Unserialize() method, which
CTransaction does not, because it is supposed to represent immutable
transactions. Work around this by adding a CustomReadField overload that will
call CTransaction's deserialize_type constructor.

These types also can't be passed currently because serializing transactions
requires TransactionSerParams to be set. Fix this by setting TX_WITH_WITNESS as
default serialization parameters for IPC code.
2024-09-23 15:03:04 -05:00
Ryan Ofsky
69dfeb1876 multiprocess: update common-types.h to use C++20 concepts
Idea came from review comment by ion-
https://github.com/bitcoin/bitcoin/pull/30510#discussion_r1757372497
2024-09-23 16:03:04 -04:00
Ryan Ofsky
206c6e78ee build: Make bitcoin_ipc_test depend on bitcoin_ipc
This change is needed to allow generated capnp code in src/ipc/capnp/ to be
used in unit tests for better test coverage in upcoming commits.
2024-09-23 16:03:04 -04:00
Ryan Ofsky
070e6a32d5 depends: Update libmultiprocess library for cmake headers target
This update brings in the following changes:

https://github.com/chaincodelabs/libmultiprocess/pull/107 example: Remove manual client adding
https://github.com/chaincodelabs/libmultiprocess/pull/108 doc: Add comments for socket descriptor handling when forking
https://github.com/chaincodelabs/libmultiprocess/pull/109 example: Add missing thread.join() call so example can exit cleanly
https://github.com/chaincodelabs/libmultiprocess/pull/110 cmake: add target_capnp_sources headers target
2024-09-23 16:03:04 -04:00
Ava Chow
90a5786bba
Merge bitcoin/bitcoin#30678: wallet: Write best block to disk before backup
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
f20fe33e94 test: Add basic balance coverage to wallet_assumeutxo.py (Fabian Jahr)
037b101e80 test: Add coverage for best block locator write in wallet_backup (Fabian Jahr)
31c0df0389 wallet: migration, write best locator before unloading wallet (furszy)
7e3dbe4180 wallet: Write best block to disk before backup (Fabian Jahr)

Pull request description:

  I discovered that we don't write the best block to disk when trying to explain the behavior described here: https://github.com/bitcoin/bitcoin/pull/30455#discussion_r1719951882

  In the context of that test, the behavior is confusing and I think it also shows that one of the already existing tests in `wallet_assumeutxo.py` doesn't actually test what it says. It only fails because the best block isn't written and actually, the height of the backup that is loaded is at the snapshot height during backup. So it really shouldn't fail since it's past the background sync blocks already.

  I'm not sure if this is super relevant in practice though so I am first looking for concept ACKs on the `BackupWallet` code change. Either way, I think this behavior should be documented better if it is left as is and the test should be changed.

ACKs for top commit:
  achow101:
    ACK f20fe33e94
  furszy:
    ACK f20fe33

Tree-SHA512: bb384a940df5c942fffe2eb06314ade4fc5d9b924012bfef3b1c456c4182a30825d1e137d8ae561d93d3a8a2f4d1c1ffe568132d20fa7d04844f1e289ab4a28b
2024-09-23 16:03:04 -04:00
Ava Chow
dabc74e86c
Merge bitcoin/bitcoin#30409: Introduce waitTipChanged() mining interface, replace RPCNotifyBlockChange, drop CRPCSignals & g_best_block
7942951e3f Remove unused g_best_block (Ryan Ofsky)
e3a560ca68 rpc: use waitTipChanged for longpoll (Ryan Ofsky)
460687a09c Remove unused CRPCSignals (Sjors Provoost)
dca923150e Replace RPCNotifyBlockChange with waitTipChanged() (Sjors Provoost)
2a40ee1121 rpc: check for negative timeout arg in waitfor* (Sjors Provoost)
de7c855b3a rpc: recommend -rpcclienttimeout=0 for waitfor* (Sjors Provoost)
77ec072925 rpc: fix waitfornewblock description (Sjors Provoost)
285fe9fb51 rpc: add test for waitforblock and waitfornewblock (Sjors Provoost)
b94b27cf05 Add waitTipChanged to Mining interface (Sjors Provoost)
7eccdaf160 node: Track last block that received a blockTip notification (Sjors Provoost)
ebb8215f23 Rename getTipHash() to getTip() and return BlockRef (Sjors Provoost)
89a8f74bbb refactor: rename BlockKey to BlockRef (Sjors Provoost)

Pull request description:

  This continues the work in #30200 so that a future Stratum v2 Template Provider (see #29432) can avoid accessing node internals. It needs to know when a new block arrives in order to push new templates to connected clients.

  `waitTipChanged()` uses a new kernel notification `notifications().m_tip_block_mutex`, which this PR also introduces (a previous version used `g_best_block`).

  In order to ensure the new method works as intended, the `waitfornewblock`, `waitforblock` and `waitforblockheight` RPC methods are refactored to use it. This allows removing `RPCNotifyBlockChange`.

  There's a commit to add (direct) tests for the methods that are about to be refactored:
  - `waitfornewblock` was already implicitly tested by `feature_shutdown.py`.
  - `waitforblockheight` by `feature_coinstatsindex.py` and `example_test.py`

  This PR renames `getTipHash()` to `getTip()` and returns a `BlockRef` (renamed from `BlockKey`) so that callers can use either the height or hash.

  The later commits make trivial improvements to the `waitfor*` RPC calls (not needed for this PR).

  The `waitTipChanged()` method could probably also be used for the longpoll functionality in `getblocktemplate`, but I'm a bit reluctant to touch that.

  `RPCServer::OnStarted` no longer does anything and `RPCServer::OnStopped` merely prints a log statement. They were added in #5711 as a refactor. This PR drops them entirely.

  Finally `g_best_block` is also dropped.

ACKs for top commit:
  achow101:
    ACK 7942951e3f
  ryanofsky:
    Code review ACK 7942951e3f. Just rebased since last review
  TheCharlatan:
    Re-ACK 7942951e3f

Tree-SHA512: a5559446b4000c95e07aad33284b7ee2e57aafd87e1ae778b3825d59689566d047a8047e47a10f76e6e341e7dc72fd265a65afbc0a9c011d17c4cafd55031837
2024-09-23 15:40:33 -04:00
Fabian Jahr
f20fe33e94
test: Add basic balance coverage to wallet_assumeutxo.py 2024-09-22 19:19:12 +02:00
Ava Chow
33adc7521c
Merge bitcoin/bitcoin#30765: refactor: Allow CScript's operator<< to accept spans, not just vectors
Some checks failed
CI / test each commit (push) Has been cancelled
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Has been cancelled
CI / Win64 native, VS 2022 (push) Has been cancelled
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Has been cancelled
5e190cd11f Replace CScript _hex_v_u8 appends with _hex (Lőrinc)
cac846c2fb Allow CScript's operator<< to accept spans, not just vectors (Lőrinc)
c78d8ff4cb prevector: avoid GCC bogus warnings in insert method (Lőrinc)

Pull request description:

  Split out of https://github.com/bitcoin/bitcoin/pull/30377#discussion_r1722326803.

  Replace `_hex_v_u8` for `CScript` appends to `_hex`, to skip vector conversion before serializing to the `prevector` in `CScript`.

  To enable both `unsigned char` and `std::byte` values, I've extracted the existing serialization to append the size & data in separate private methods to clarify that it does more than just a simple data insertion.

  There were also discussion on eliminating the operators here completely to obviate when we're serializing fixed-size collections as raw bytes, and when we're prefixing them with their size - should also be done in a separate PR.

ACKs for top commit:
  achow101:
    ACK 5e190cd11f
  ryanofsky:
    Code review ACK 5e190cd11f. Looks good!
  hodlinator:
    re-ACK 5e190cd11f

Tree-SHA512: 27a646629e017b2a05416d5eb964dda8b25b900d466221eff7bfa1339ded443e1c5c4cf8ff20cb3bba915a2603787a9fa6f6ec12bc0b9415d9eb07b57289192b
2024-09-20 15:16:53 -04:00
Ava Chow
0894748316
Merge bitcoin/bitcoin#30918: fuzz: Add check in p2p_headers_presync that chain work never exceeds minimum work
284bd17309 add check that chainwork doesn't exceed minimum work (marcofleon)
9aa5d1c3fc add clarification in comment (marcofleon)

Pull request description:

  A followup to https://github.com/bitcoin/bitcoin/pull/30661

  The added assertion just makes sure that the fuzz test is working as intended. If we're sure that the total work of the test chain is never more than minimum chain work, then we can be sure that the later assertion failure would actually mean that a bug in the headers presync logic was found.

  This PR also addresses:
  https://github.com/bitcoin/bitcoin/pull/30661#discussion_r1746614616
  https://github.com/bitcoin/bitcoin/pull/30661#discussion_r1764943665
  https://github.com/bitcoin/bitcoin/pull/30661#discussion_r1764961991

ACKs for top commit:
  instagibbs:
    reACK 284bd17309
  maflcko:
    review ACK 284bd17309
  achow101:
    ACK 284bd17309

Tree-SHA512: 76a9dffea4b6e13499c636d6ad26af06135319d25117c0eb40cf8dfcfdca6a4549c9b4d2ba835192ca355e0f8d476227aeabf8bdb68770def72a9fb521533fe5
2024-09-20 14:35:05 -04:00
Ava Chow
f57a6754ed
Merge bitcoin/bitcoin#30826: fuzz: reduce number of iterations in crypto_aeadchacha20poly1305 target
f482d0e366 fuzz: reduce number of iterations in `crypto_aeadchacha20poly1305` target (brunoerg)

Pull request description:

  By reducing the number of iterations we improve the performance of this target and may increase coverage.

  Running with `-runs=100000` from qa-assets I noticed a significant performance improvement and an increase on cov:
  master:
  ```
  #100000 DONE   cov: 567 ft: 4078 corp: 124/33Kb lim: 4096 exec/s: 793 rss: 499Mb
  ```

  PR:
  ```
  #100000 DONE   cov: 568 ft: 3833 corp: 113/15188b lim: 1746 exec/s: 1250 rss: 544Mb
  ```

ACKs for top commit:
  achow101:
    ACK f482d0e366
  marcofleon:
    Tested ACK f482d0e366. Saw the same slight increase in coverage. Executed 100,000 runs several times and total time went from 30-35 sec to 20-25 sec.
  stratospher:
    ACK f482d0e. saw similar coverage stats

Tree-SHA512: 1a96dbc22a0aed396b7f8cc9b13534b7f20a461f64f167c69c650529d535e360499f1a501abc1f957f7541ee1860b36a5580aa488a1edbfa0270c9ed83ef741d
2024-09-20 13:55:51 -04:00
Ava Chow
48c20dbd86
Merge bitcoin/bitcoin#30794: interpreter: use int32_t instead of int type for risczero compile
bc52cda1f3 fix use int32_t instead of int type for risczero compile with (-march=rv32i, -mabi=ilp32) (Simon)

Pull request description:

  When compile bitcoin by the toolchain(`riscv32-unknown-elf-g++`) from risc0 , the compiler argument is `-march=rv32i, -mabi=ilp32`, which will get the error which due to not serialize the value of type int .

  ```
  blockbody-guest:   cargo:warning=In file included from depend/bitcoin/src/hash.h:14,
  blockbody-guest:   cargo:warning=                 from depend/bitcoin/src/script/interpreter.h:9,
  blockbody-guest:   cargo:warning=                 from depend/bitcoin/src/script/interpreter.cpp:6:
  blockbody-guest:   cargo:warning=depend/bitcoin/src/serialize.h: In instantiation of 'void Serialize(Stream&, const T&) [with Stream = HashWriter; T = int]':
  blockbody-guest:   cargo:warning=depend/bitcoin/src/hash.h:144:20:   required from 'HashWriter& HashWriter::operator<<(const T&) [with T = int]'
  blockbody-guest:   cargo:warning=depend/bitcoin/src/script/interpreter.cpp:1613:12:   required from 'uint256 SignatureHash(const CScript&, const T&, unsigned int, int, const CAmount&, SigVersion, const PrecomputedTransactionData*) [with T = CTransaction; CAmount = long long int]'
  blockbody-guest:   cargo:warning=depend/bitcoin/src/script/interpreter.cpp:1664:36:   required from 'bool GenericTransactionSignatureChecker<T>::CheckECDSASignature(const std::vector<unsigned char>&, const std::vector<unsigned char>&, const CScript&, SigVersion) const [with T = CTransaction]'
  blockbody-guest:   cargo:warning=depend/bitcoin/src/script/interpreter.cpp:1785:16:   required from here
  blockbody-guest:   cargo:warning=depend/bitcoin/src/serialize.h:776:7: error: request for member 'Serialize' in 'a', which is of non-class type 'const int'
  blockbody-guest:   cargo:warning=  776 |     a.Serialize(os);
  ```

  --------------

  ### Reason

  "The toolchain from RISC Zero defines int and int32_t as different types, although they have the same width. This means that `src/compat/assumptions.h` compiles fine; however, the templated serialization code cannot accept values of type int. Fix the compilation on RISC Zero by serializing int32_t instead of int values.

  This patch will explicitly use the `int32_t` type instead of `int` to avoid errors when compiling with the risc0 toolchain. Additionally, this patch will not change any behavior on platforms where compilation was previously successful.

  Fixes #30747

ACKs for top commit:
  maflcko:
    review-only ACK bc52cda1f3
  achow101:
    ACK bc52cda1f3
  TheCharlatan:
    ACK bc52cda1f3

Tree-SHA512: ef880e7dfa1335bf2704ab17c0f506f17390b8259755674dfcd57131736492b2f4cfc36babda6902202b7c55a7513991e21f6634b0cd9b2b03baf4f1c0f8d78b
2024-09-20 13:42:50 -04:00
Ava Chow
4148e60909
Merge bitcoin/bitcoin#30679: fix: handle invalid -rpcbind port earlier
e6994efe08 fix: increase rpcbind check robustness (tdb3)
d38e3aed89 fix: handle invalid rpcbind port earlier (tdb3)
83b67f2e6d refactor: move host/port checking (tdb3)
73c243965a test: add tests for invalid rpcbind ports (tdb3)

Pull request description:

  Previously, when an invalid port was specified in `-rpcbind`, the `SplitHostPort()` return value in `HTTPBindAddresses()` was ignored and attempt would be made to bind to the default rpcbind port (with the host/port treated as a host).

  This rearranges port checking code in `AppInitMain()` to handle the invalid port before reaching `HTTPBindAddresses()`.  Also adds a check in `HTTPBindAddresses()` as a defensive measure for future changes.

  Adds then updates associated functional tests as well.

ACKs for top commit:
  achow101:
    ACK e6994efe08
  ryanofsky:
    Code review ACK e6994efe08
  zaidmstrr:
    Code review ACK [e6994ef](e6994efe08)

Tree-SHA512: bcc3e5ceef21963821cd16ce6ecb83d5c5657755882c05872a7cfe661a1492b1d631f54de22f41fdd173512d62dd15dc37e394fe1a7abe4de484b82cd2438b92
2024-09-20 13:34:24 -04:00
Ava Chow
a8a2628b7a
Merge bitcoin/bitcoin#30828: interfaces: #30697 follow ups
8466329127 chain: simplify `deleteRwSettings` code and improve it's doc (ismaelsadeeq)
f8d91f49c7 chain: dont check for null settings value in `overwriteRwSetting` (ismaelsadeeq)
df601993f2 chain: ensure `updateRwSetting` doesn't update to a null settings (ismaelsadeeq)
c8e2eeeffb chain: uniformly use `SettingsAction` enum in settings methods (ismaelsadeeq)
1e9e735670 chain: move new settings safely in `overwriteRwSetting` (ismaelsadeeq)
1c409004c8 test: remove wallet context from `write_wallet_settings_concurrently` (ismaelsadeeq)

Pull request description:

  This PR addresses the remaining review comments from #30697

  1. Disallowed overwriting settings values with a `null` value.
  2. Uniformly used the `SettingsAction` enum in all settings methods instead of a boolean parameter.
  3. Updated `overwriteRwSetting` to receive the `common::SettingsValue` parameter by value, enabling it to be moved safely.
  4. Removed wallet context from the `write_wallet_settings_concurrently` unit test, as it is not needed.

ACKs for top commit:
  achow101:
    ACK 8466329127
  ryanofsky:
    Code review ACK 8466329127. Looks good, thanks for taking suggestions and applying them to the right commits. Only changes since last review were documentation improvements and simplifying delete method.
  furszy:
    Code review ACK 8466329127

Tree-SHA512: baf2f59ed5aac4a4bda0c84fb6554a466a40d1f7b52b61dc2ff293d83ae60e82b925b7003237b633fecb65eba3a4c108e69166046895d1295809fbe0de67b052
2024-09-20 13:26:38 -04:00
Ava Chow
0d81b3dded
Merge bitcoin/bitcoin#30568: addrman: change internal id counting to int64_t
51f7668d31 addrman: change nid_type from int to int64_t (Martin Zumsande)
051ba3290e addrman, refactor: introduce user-defined type for internal nId (Martin Zumsande)

Pull request description:

  With `nIdCount` being incremented for each addr received, an attacker could cause an overflow in the past, see https://bitcoincore.org/en/2024/07/31/disclose-addrman-int-overflow/
  Even though that attack was made infeasible indirectly by addr rate-limiting (PR #22387), to be on the safe side and prevent any regressions change the `nId`s used internally to `int64_t`.
  This is being done by first introducing a user-defined type for `nId`s in the first commit, and then updating it to `int64_t` (thanks sipa for help with this!).

  Note that `nId` is only used internally, it is not part of the serialization, so `peers.dat` should not be affected by this.

  I assume that the only reason this was not done in the past is to not draw attention to this previously undisclosed issue.

ACKs for top commit:
  naumenkogs:
    ACK 51f7668d31
  stratospher:
    ACK 51f7668d31. I think it's a good change to make the nId space large(64 bits) so that the nId values are distinct.
  achow101:
    ACK 51f7668d31

Tree-SHA512: 68d4b8b0269a01a9544bedfa7c1348ffde00a288537e4c8bf2b88372ac7d96c4566a44dd6b06285f2fcf31b4f9336761e3bca7253fbc20db5e0d04e887156224
2024-09-20 12:55:22 -04:00
Ava Chow
c985a34b9c
Merge bitcoin/bitcoin#26990: cli: Improve error message on multiwallet cli-side commands
54227e681a rpc, cli: improve error message on multiwallet mode (pablomartin4btc)

Pull request description:

  Running a CLI command when multiple wallets are loaded and `-rpcwallet` is not specified, should return a clearer error.

  Currently in `master`:

  ```
  $ bitcoin-cli -regtest -generate 1
  error code: -19
  error message:
  Wallet file not specified (must request wallet RPC through /wallet/<filename> uri-path).
  Try adding "-rpcwallet=<filename>" option to bitcoin-cli command line.
  ```

  With this change:

  ```
  $ bitcoin-cli -regtest -generate 1
  error code: -19
  error message:
  Multiple wallets are loaded. Please select which wallet to use by requesting the RPC through the /wallet/<walletname> URI path. Or for the CLI, specify the "-rpcwallet=<walletname>" option before the command (run "bitcoin-cli -h" for help or "bitcoin-cli listwallets" to see which wallets are currently loaded).
  ```

ACKs for top commit:
  maflcko:
    review ACK 54227e681a
  achow101:
    ACK 54227e681a
  furszy:
    utACK 54227e681a
  mzumsande:
    Code Review ACK 54227e681a
  jonatack:
    ACK 54227e681a

Tree-SHA512: 51ff24f64858aa6be6adf6f20105c9f076ebea743780bf2a4399f7fe8b5239cbb1ea06d32b2ef5e850da2369abb0ef7a52c50c2b8f31f4ca90d3a486abc9b77e
2024-09-20 12:00:27 -04:00
Fabian Jahr
037b101e80
test: Add coverage for best block locator write in wallet_backup 2024-09-20 17:20:15 +02:00
furszy
31c0df0389
wallet: migration, write best locator before unloading wallet 2024-09-20 17:16:38 +02:00
Fabian Jahr
7e3dbe4180
wallet: Write best block to disk before backup
This ensures that the best block is included in the backup which leads to a more consistent behavior when loading the backup.
2024-09-20 17:16:35 +02:00
merge-script
79f20fa1b1
Merge bitcoin/bitcoin#30561: refactor: move SignSignature helpers to test utils
58499b00d0 refactor: move `SignSignature` helpers to test utils (Sebastian Falbesoner)

Pull request description:

  These helpers haven't been used in production code since segwit was merged more than eight years ago (see commit 605e8473, PR #8149), so it seems appropriate to move them to the test utils module. As suggested by instagibbs, see https://github.com/bitcoin/bitcoin/pull/30352#discussion_r1697515508.

ACKs for top commit:
  instagibbs:
     ACK 58499b00d0
  pablomartin4btc:
    ACK 58499b00d0

Tree-SHA512: a52d3b92b477246f2ceb57c3690d0229a492b65a15dae331faeae9d96e5907f7fe1176edc1530243e0f088586984fd7ba435a0a2d2f2531c04d076fdf3f4095f
2024-09-20 16:05:28 +01:00
marcofleon
284bd17309 add check that chainwork doesn't exceed minimum work 2024-09-20 15:00:19 +01:00
marcofleon
9aa5d1c3fc add clarification in comment 2024-09-20 15:00:19 +01:00
merge-script
197aa24955
Merge bitcoin/bitcoin#30856: build: drop obj/ subdirectory for generated build.h
7025942687 build: drop superfluous `HAVE_BUILD_INFO` define (Sebastian Falbesoner)
0dd662510c build: drop obj/ subdir for generated build.h, rename to bitcoin-build-info.h (Sebastian Falbesoner)

Pull request description:

  As indicated by the TODO, the obj subdirectory is not needed anymore now for the generated build.h header, since autotools are gone and we don't have in-source builds anymore (see #30454, #30664). In the second commit the superflous `HAVE_BUILD_INFO` macro is dropped, as suggested in https://github.com/bitcoin/bitcoin/pull/30856#pullrequestreview-2292424496.

ACKs for top commit:
  theuni:
    utACK 7025942687

Tree-SHA512: 0a3b2cbbcf638344ceb74e5ba5a0fe2b1718427b23a18c8890258db36ce7177006a146178ed88d9c5ae956a5426f3844e86c1f4cca7c40946359742bffda983b
2024-09-20 10:59:13 +01:00
Sebastian Falbesoner
7025942687 build: drop superfluous HAVE_BUILD_INFO define
bitcoin-build-info.h should always be generated before clientversion.cpp
is compiled due to the following explicit dependency in src/CMakeLists.txt:

add_dependencies(bitcoin_clientversion generate_build_info)

Hence there is no need to gate the inclusion of that header with an
extra define.
2024-09-19 17:59:16 +02:00
Sebastian Falbesoner
0dd662510c build: drop obj/ subdir for generated build.h, rename to bitcoin-build-info.h
Now that this file is not in a subfolder anymore, prefix it with
"bitcoin-" to avoid potential collisions. Also add "info" for a more
descriptive name.
2024-09-19 17:57:36 +02:00
merge-script
84cd6478c4
Merge bitcoin/bitcoin#30927: Follow-up after AutoFile position caching: remove unused code
Some checks failed
CI / test each commit (push) Has been cancelled
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Has been cancelled
CI / Win64 native, VS 2022 (push) Has been cancelled
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Has been cancelled
caac06f784 streams: reorder/document functions (Pieter Wuille)
67a3d59076 streams: remove unused code (Pieter Wuille)

Pull request description:

  This is a follow-up to #30884.

  Remove a number of dead code paths, and improve the code organization and documentation, in `AutoFile`.

ACKs for top commit:
  maflcko:
    re-ACK caac06f784
  theStack:
    Code-review ACK caac06f784
  l0rinc:
    ACK caac06f784
  tdb3:
    CR ACK caac06f784

Tree-SHA512: 297791f093e0142730f815c11dd3466b98f7e7edea86094a815dae989ef40d8056db10e0fed6e575d530903c18e80c08d36d3f1e6b828f2d955528f365b22008
2024-09-19 16:43:46 +01:00
Pieter Wuille
caac06f784 streams: reorder/document functions 2024-09-19 07:57:45 -04:00
Pieter Wuille
67a3d59076 streams: remove unused code 2024-09-19 07:33:02 -04:00
merge-script
2db926f49c
Merge bitcoin/bitcoin#30889: log: Use ConstevalFormatString
facbcd4cef log: Use ConstevalFormatString (MarcoFalke)
fae9b60c4f test: Use LogPrintStr to test m_log_sourcelocations (MarcoFalke)
fa39b1ca63 doc: move-only logging warning (MarcoFalke)

Pull request description:

  This changes all logging (including the wallet logging) to produce a
  `ConstevalFormatString` at compile time, so that the format string can be
  validated at compile-time.

  I tested with `clang` and found that the compiler will use less than 1% more of time and memory.

  When an error is found, the compile-time error depends on the compiler, but it may look similar to:

  ```
  src/util/string.h: In function ‘int main(int, char**)’:
  src/bitcoind.cpp:265:5:   in ‘constexpr’ expansion of ‘util::ConstevalFormatString<1>(((const char*)"Hi %s %s"))’
  src/util/string.h:38:98:   in ‘constexpr’ expansion of ‘util::ConstevalFormatString<1>::Detail_CheckNumFormatSpecifiers(std::basic_string_view<char>(((const char*)((util::ConstevalFormatString<1>*)this)->util::ConstevalFormatString<1>::fmt)))’
  src/util/string.h:78:34: error: expression ‘<throw-expression>’ is not a constant expression
     78 |         if (num_params != count) throw "Format specifier count must match the argument count!";
        |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ```

  This refactor does not change behavior of the compiled executables.

ACKs for top commit:
  hodlinator:
    re-ACK facbcd4cef
  l0rinc:
    ACK facbcd4cef
  ryanofsky:
    Code review ACK facbcd4cef
  pablomartin4btc:
    re-ACK facbcd4cef
  stickies-v:
    Approach ACK and code LGTM facbcd4cef modulo a `tinyformat::format_error` concern.

Tree-SHA512: 852f74d360897020f0d0f6e5064edc5e7f7dacc2bec1d5feff22c634a2fcd2eb535aa75be0b7191d9053728be6108484c737154b02d68ad3186a2e5544ba0db8
2024-09-19 12:17:14 +01:00
merge-script
9ba56884f6
Merge bitcoin/bitcoin#30869: ci: Print inner env, Make ccache config more flexible
fa99e4521b ci: Allow CCACHE_DIR bind mount (MarcoFalke)
fa252da0b9 ci: Remove hardcoded CCACHE_DIR in cirrus (MarcoFalke)
fa146904e1 ci: Bump default CCACHE_MAXSIZE to 500M (MarcoFalke)
aaaa7cf8ba cirrus: Drop CCACHE_NOHASHDIR (MarcoFalke)
fa7ca182a9 ci: Print inner env (MarcoFalke)

Pull request description:

  The outer env is printed when the `/tmp/env-$USER-$CONTAINER_NAME` is created. There is also a separate env printed when building the container image (usually with default values).

  To confirm that the inner container env is correctly derived from the outer env, and not from the default build env, print it a third time.

ACKs for top commit:
  l0rinc:
    utACK fa99e4521b
  willcl-ark:
    ACK fa99e4521b

Tree-SHA512: 59fd3262d551e09224866e31c14ca865461e81abbe00b83391fe3a9c7ada30fd2fd0272e4aa812df2712433ac7594d1a55cf674248b341359cec09c8d3f0c58b
2024-09-19 10:42:09 +01:00
merge-script
ab0b5706b2
Merge bitcoin/bitcoin#30875: doc: fixed inconsistencies in documentation between autotools to cmake change
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
a9964c0444 doc: Updating docs from autotools to cmake (kevkevinpal)

Pull request description:

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

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

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

Tree-SHA512: f7ed20b8ad61f028c0d242b9cc70650d8da63057d4a8f7da88f0117a8d3241c5fe8fcf19d56ec82088160b9fee9b175fe9f64e5a845260d3696dc7e94bfdd0bd
2024-09-18 18:44:02 +01:00
merge-script
fd08fded63
Merge bitcoin/bitcoin#30639: ci: Use clang-19 in msan tasks
ccccb67851 ci: Use clang-19 in msan tasks (MarcoFalke)

Pull request description:

  A new clang version generally comes with bugfixes, new sanitizer features, deprecations, as well as new features.

  Upgrade the memory sanitizer tasks to use the new version.

  (Ref https://github.com/bitcoin/bitcoin/pull/30634)

ACKs for top commit:
  fanquake:
    ACK ccccb67851 Tested both jobs on aarch64, and one on x86_64 with `mmap_rnd_bits`.

Tree-SHA512: a42bf2da7c08aa54c0c5ab3811ff51b98b80b276be135eed32395a55ae93a42d41d7cd32c307062dcca711a892958ea141168c2a06025560074f8c5d20190946
2024-09-18 18:40:05 +01:00
kevkevinpal
a9964c0444
doc: Updating docs from autotools to cmake
replaced --enable-debug with -DCMAKE_BUILD_TYPE=Debug in developer-notes
replaced --enable-multiprocess with -DWITH_MULTIPROCESS=ON
replaced --disable-zmq with -DWITH_ZMQ=OFF
2024-09-18 11:04:52 -04:00
merge-script
69409bc6e5
Merge bitcoin/bitcoin#30908: doc: remove Eclipser fuzzing documentation
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
735436df8c Remove outdated Eclipser fuzzing documentation (Jon Atack)

Pull request description:

  Remove the Eclipser fuzzing documentation from `doc/fuzzing.md`, as that repository (https://github.com/SoftSec-KAIST/Eclipser) hasn't been updated in several years, appears possibly unmaintained, and likely isn't being actively used for fuzzing Bitcoin Core.

  These docs were originally added in https://github.com/bitcoin/bitcoin/pull/22585.

ACKs for top commit:
  maflcko:
    review ACK 735436df8c
  brunoerg:
    ACK 735436df8c

Tree-SHA512: 7ccbf93c10add53e92edf67a622722935029add63f8fbb6e733b96e9d155faeb8d5d3678adb0e7f2ce8ccbdffd2a34c3dc93adbcf4e3ce0cdd03e20ad3e6bbd6
2024-09-18 10:17:28 +01:00
merge-script
6b97882ab5
Merge bitcoin/bitcoin#30915: ci: Use ninja to build in macOS native CI job
d01b85bfec ci: Use `ninja` to build in macOS native CI job (Hennadii Stepanov)

Pull request description:

  This PR addresses [this](https://github.com/bitcoin/bitcoin/pull/30911#issuecomment-2354922939) comment:
  > I wonder if one CI task should be using Ninja (and cmake >= 3.27), if it isn't too hard to implement. Otherwise this config will remain untested and errors may sneak in to the master branch, only being detected after merge.

ACKs for top commit:
  maflcko:
    review ACK d01b85bfec
  theuni:
    ACK d01b85bfec.
  jonatack:
    ACK d01b85bfec
  jarolrod:
    ACK d01b85bfec

Tree-SHA512: 5cbbc87f0e48512441a4f0cf10af2f6d73f24d3e8667b338b176fd1667fd5d7739349bcede3aeef973497ff67d33cb8f7d7f3681c3ede8e8b2f673b853d5bc63
2024-09-18 10:16:14 +01:00
tdb3
e6994efe08
fix: increase rpcbind check robustness
Adds invalid rpcbind port checking to
`HTTPBindAddresses()`. While movement of
`CheckHostPortOptions()` in the previous
commit handles rcpbind port errors, updating
`HTTPBindAddresses()` port checking adds
a defensive measure for potential future
changes.
2024-09-17 21:47:33 -04:00
tdb3
d38e3aed89
fix: handle invalid rpcbind port earlier
Previously, when an invalid port was specified
in `-rpcbind`, the `SplitHostPort()` return value
in `HTTPBindAddresses()` was ignored and attempt
would be made to bind to the default rpcbind port
(with the host/port treated as a host).

This rearranges port checking code in
`AppInitMain()` to handle the invalid
port before reaching `HTTPBindAddresses()`.

Also adjusts associated functional tests.
2024-09-17 21:47:29 -04:00
tdb3
83b67f2e6d
refactor: move host/port checking
Reduces the size of AppInitMain() by moving
checks to CheckHostPortOptions()

Co-Authored-By: Ryan Ofsky <ryan@ofsky.org>
2024-09-17 21:47:20 -04:00
tdb3
73c243965a
test: add tests for invalid rpcbind ports 2024-09-17 20:03:00 -04:00
pablomartin4btc
54227e681a rpc, cli: improve error message on multiwallet mode
The primary objective is to provide users with clearer
and more informative error messages when encountering
the RPC_WALLET_NOT_SPECIFIED error, which occurs when
multiple wallets are loadad.

This commit also rectifies the error message consistency
by bringing the error message in line with the definition
established in protocol.h ("error when there are multiple
wallets loaded").
2024-09-17 16:22:12 -03:00
Jon Atack
735436df8c Remove outdated Eclipser fuzzing documentation
[skip ci]
2024-09-17 11:32:46 -06:00
MarcoFalke
ccccb67851
ci: Use clang-19 in msan tasks 2024-09-17 19:04:12 +02:00
MarcoFalke
facbcd4cef
log: Use ConstevalFormatString
This changes all logging (including the wallet logging) to produce a
ConstevalFormatString at compile time, so that the format string can be
validated at compile-time.

Also, while touching the wallet logging, avoid a copy of the template
Params by using const Params&.
2024-09-17 18:21:23 +02:00
Hennadii Stepanov
d01b85bfec
ci: Use ninja to build in macOS native CI job 2024-09-17 15:43:48 +01:00
merge-script
6fc4692797
Merge bitcoin/bitcoin#29624: doc: update NeedsRedownload() and nStatus comment
Some checks are pending
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
af9f987893 doc: update NeedsRedownload() comment (Sjors Provoost)

Pull request description:

  Noticed two outdated comments while reviewing #29370.

  Since #21009 we no longer roll back the chain, when a user updates a pre-segwit node to a modern node. In this unlikely scenario we tell the user to `-reindex`.

  This PR updates a comment in `PopulateAndValidateSnapshot` to reflect that change. Ditto for the description of `nStatus` in `chain.h`.

ACKs for top commit:
  maflcko:
    re-ACK af9f987893
  fjahr:
    ACK af9f987893

Tree-SHA512: d590f1cff6823297764c863753ed5478b8933d503c43933902d50b449dfd852a02aeb318c072ad25d02e4c2583d7026cd176a10b0584292d6bbe381a063f5c45
2024-09-17 15:27:29 +01:00
merge-script
2a0949f097
Merge bitcoin/bitcoin#30888: build: optimize .h generation in GenerateHeaderFrom{Raw,Json}.cmake
2a581144f2 build: Minimize I/O operations in GenerateHeaderFromJson.cmake (Lőrinc)
aa003d1568 build: Minimize I/O operations in GenerateHeaderFromRaw.cmake (Lőrinc)

Pull request description:

  Follow up of the https://github.com/bitcoin/bitcoin/pull/30883 revert.

  Replaced multiple file writes with a single string template write.
  The raw content is first grouped into 8 byte chunks, followed by another regex replace which wraps them in `std::byte` or just the raw bytes, prefixed with `0x`.

  Tested the output with `diff -w` and they're the same - only whitespace differences because slightly different source formatting.

  ----

  Tested the `Raw` performance with:
  ```bash
  time cmake -DRAW_SOURCE_PATH=src/bench/data/block413567.raw -DHEADER_PATH=build/after/block413567.raw.h -DRAW_NAMESPACE=benchmark::data -P cmake/script/GenerateHeaderFromRaw.cmake
  ```

  Before:
  > 15.41s user 23.06s system 97% cpu 39.593 total

  After:
  > 0.77s user 0.06s system 97% cpu 0.849 total

  ----

  Tested the `Json` performance with:
  ```bash
  time cmake -DJSON_SOURCE_PATH=src/secp256k1/src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.json -DHEADER_PATH=build/after/ecdsa_secp256k1_sha256_bitcoin_test.json -P cmake/script/GenerateHeaderFromJson.cmake
  ````

  Before:
  > 3.57s user 6.01s system 94% cpu 10.136 total

  After:
  > 0.17s user 0.01s system 98% cpu 0.187 total

ACKs for top commit:
  maflcko:
    review ACK 2a581144f2 👒
  hebasto:
    ACK 2a581144f2.
  willcl-ark:
    tACK 2a581144f2

Tree-SHA512: 5e44f79d1c0dbb61d8b64f28d4c3c87a176981f72104b28800eef2037b0728076cbcf14ff07b05ff94d4e8800605586cfd5df00519db9027933c5943348c01d2
2024-09-17 15:27:00 +01:00
merge-script
bdbc90f29a
Merge bitcoin/bitcoin#30902: Remove Autotools packages from CI (and depends doc)
7a8a6a0667 doc: Fix comment in `contrib/devtools/check-deps.sh` script (Hennadii Stepanov)
712d105e09 depends, doc: Do not install Autotools packages (Hennadii Stepanov)
b786449e66 ci: Do not install Autotools packages (Hennadii Stepanov)

Pull request description:

  This PR is a follow-up to https://github.com/bitcoin/bitcoin/pull/30752 and addresses https://github.com/bitcoin/bitcoin/pull/30752#discussion_r1758594864.

ACKs for top commit:
  kevkevinpal:
    ACK [7a8a6a0](7a8a6a0667)

Tree-SHA512: ac701b34ebf1621be355a5b576032d30a342a5667eff47d858587ac3c60011d77bd469e524d69dae90a932f14269227886e3d170a63a2e855b29ef4fa5b9e5a4
2024-09-17 15:19:18 +01:00
merge-script
a95e742b69
Merge bitcoin/bitcoin#30913: ci: Use macos-14 GHA image (x86_64-apple-darwin22.6.0 -> arm64-apple-darwin23.6.0)
fab932b421 ci: Remove incorrectly hardcoded HOST in mac_native task (MarcoFalke)
fa8f35d786 ci: Use macos-14 GHA image (MarcoFalke)

Pull request description:

  There shouldn't be any downside, because XCode remains pinned to the same version.

  However, builds are expected to be a bit faster with M1, which seems nice.

ACKs for top commit:
  hebasto:
    ACK fab932b421.
  willcl-ark:
    ACK fab932b421

Tree-SHA512: 9719e05c67b8b5f3d59bd1a38eef00407b1ae5e123b18151c494b6d2dbf55bd2b0b5bb6c1a0469635c7b3bb5f23990d3bb2f339f56ce3955e8a1b97ac9f295d4
2024-09-17 15:11:35 +01:00