Commit graph

37947 commits

Author SHA1 Message Date
fanquake
76240ce55d
Merge bitcoin/bitcoin#28011: test: Rename EncodeDecimal to serialization_fallback
fabd34873c test: Rename EncodeDecimal to serialization_fallback (MarcoFalke)

Pull request description:

  The new name better explains that the function handles fallbacks, without listing all in the function name.

ACKs for top commit:
  theStack:
    ACK fabd34873c

Tree-SHA512: a0405aab2bfb2fd10c61b51b4eb767053b25b0d914d2dac006dd3eaf360fbc6f3a444bc7b580ab8469ec492fe4358cfad5943adde4a7c8f783032ceef5cc5383
2023-06-30 12:12:40 +01:00
fanquake
ca8bfbd980
Merge bitcoin/bitcoin#28013: doc: Fix verify-binaries link in contrib README
ab8f673357 doc: Fix verify-binaries link in contrib README (TheCharlatan)

Pull request description:

ACKs for top commit:
  Zero-1729:
    crACK ab8f673357
  theStack:
    ACK ab8f673357

Tree-SHA512: 901d99b897d0b4b1af612e5650e84530252d96b5b49bc4f87c512af993abe32e6494e7248bb7ce3eb7c5ff7377a949980f143007446e3720450146367e346519
2023-06-30 11:57:08 +01:00
TheCharlatan
ab8f673357
doc: Fix verify-binaries link in contrib README 2023-06-30 12:12:24 +02:00
fanquake
2cd71d3a13
Merge bitcoin/bitcoin#27937: doc: i2p documentation updates
11900e5a8a doc: simplify the router options in doc/i2p.md (Jon Atack)
b505d59326 doc: clarify when and how to launch the SAM bridge in doc/i2p.md (Jon Atack)

Pull request description:

  1. Clarify when and how to launch the SAM application bridge to address user questions and https://github.com/bitcoin/bitcoin/issues/22759#issuecomment-1599449753. The bridge is not enabled by default in the Java I2P Router, and the relevant info is somewhat difficult to find in its documentation.

  2. Remove a duplicate sentence and link (the preceding paragraph begins with the same sentence and link).

  3. Simplify the router options:

      - the Java I2P router and i2pd are the two routers have been heavily tested with Bitcoin Core and are what node operators and node software packages are using

      - [i2p-zero](https://github.com/i2p-zero/i2p-zero) hasn't been updated since July 2021 and its last release was in December 2020

      - the other routers in the wikipedia page are niche and I haven't heard anyone report using them

ACKs for top commit:
  fanquake:
    ACK 11900e5a8a

Tree-SHA512: add5f40004feddc7829d658a5de30422f144ab8fa09ff1396d5d263ee86e39803595a2c50e2aa601d0df6da5eff4358c3f7f17e039dcd4952cb306596c6c0397
2023-06-30 10:08:31 +01:00
fanquake
47ab00666e
Merge bitcoin/bitcoin#27988: test: Use same timeout for all index sync
fa086248e5 test: Use same timeout for all index sync (MarcoFalke)

Pull request description:

  Seems odd to use different timeouts.

  Fix this by using the same timeout for all syncs.

  May also fix https://github.com/bitcoin/bitcoin/issues/27355 or at least make it less frequent?

ACKs for top commit:
  mzumsande:
    code review ACK fa086248e5

Tree-SHA512: a61619247c97f3a88dd19eb3f200adedd120e6da8c4e4f2cf83621545b8c289dbad77e16f13cf7973a090f7b2c3391cb0297f09b0cc95fe4f55de21ae247670f
2023-06-30 10:06:58 +01:00
fanquake
b5ebeb376d
Merge bitcoin/bitcoin#28002: refactor: remove in-code warning suppression
3210f224db refactor: remove in-code warning suppression (fanquake)

Pull request description:

  Should no-longer be needed post #27872. If it is, then suppress-external-warnings should be fixed.

ACKs for top commit:
  hebasto:
    ACK 3210f224db

Tree-SHA512: 2405250b7308779d576f13ce9144944abd5b2293499a0c0fe940398dae951cb871246a55c0e644a038ee238f9510b5845c3e39f9658d9f10225a076d8122f078
2023-06-30 09:45:42 +01:00
Andrew Chow
54ba330f79
Merge bitcoin/bitcoin#27863: net: do not break when addr is not from a distinct network group
5fa4055452 net: do not `break` when `addr` is not from a distinct network group (brunoerg)

Pull request description:

  When the address is from a network group we already caught,
  do a `continue` and try to find another address until conditions
  are met or we reach the limit (`nTries`).

ACKs for top commit:
  amitiuttarwar:
    utACK 5fa4055452
  achow101:
    ACK 5fa4055452
  mzumsande:
    utACK 5fa4055452

Tree-SHA512: 225bb6df450b46960db934983c583e862d1a17bacfc46d3657a0eb25a0204e106e8cd18de36764e210e0a92489ab4b5773437e4a641c9b455bde74ff8a041787
2023-06-29 19:42:47 -04:00
Andrew Chow
561915f35f
Merge bitcoin/bitcoin#27978: refactor: Drop unsafe AsBytePtr function
7c853619ee refactor: Drop unsafe AsBytePtr function (Ryan Ofsky)

Pull request description:

  Replace calls to `AsBytePtr` with calls to `AsBytes` or `reinterpret_cast`. `AsBytePtr` is just a wrapper around `reinterpret_cast`. It accepts any type of pointer as an argument and uses `reinterpret_cast` to cast the argument to a `std::byte` pointer.

  Despite taking any type of pointer as an argument, it is not useful to call `AsBytePtr` on most types of pointers, because byte representations of most types will be platform specific or undefined. Also, because it is named similarly to the `AsBytes` function, `AsBytePtr` looks safer than it actually is. Both `AsBytes` and `AsBytePtr` call reinterpret_cast internally and may be unsafe to use with certain types, but AsBytes at least has some type checking and can only be called on `Span` objects, while `AsBytePtr` can be called on any pointer argument.

  The change was motivated by discussion on #27973 and #27927 and is compatible with those PRs

ACKs for top commit:
  jonatack:
    re-ACK 7c853619ee
  sipa:
    utACK 7c853619ee
  achow101:
    ACK 7c853619ee

Tree-SHA512: 200d858b1d4d579f081a7f9a14d488a99713b4918b4564ac3dd5c18578d927dbd6426e62e02f49f04a3fa73ca02ff7109c495cb0b92bec43c27d9b74e2f95757
2023-06-29 17:29:40 -04:00
MarcoFalke
fabd34873c
test: Rename EncodeDecimal to serialization_fallback
The new name better explains that the function handles fallbacks,
without listing all in the function name.
2023-06-29 19:51:43 +02:00
fanquake
3210f224db
refactor: remove in-code warning suppression
Should no-longer be needed post #27872. If it is, then
suppress-external-warnings should be fixed.
2023-06-29 14:41:33 +01:00
fanquake
c6287faae4
Merge bitcoin/bitcoin#27996: ci: filter all subtrees from tidy output
62633b5046 ci: filter all subtrees from tidy output (fanquake)

Pull request description:

  We are currently dumping output for some. i.e:
  ```bash
  diff --git a/src/minisketch/src/fields/clmul_1byte.cpp b/src/minisketch/src/fields/clmul_1byte.cpp
  index 8826af9..7fd6f2a 100644
  --- a/src/minisketch/src/fields/clmul_1byte.cpp
  +++ b/src/minisketch/src/fields/clmul_1byte.cpp
  @@ -4,21 +4,16 @@
    * file LICENSE or http://www.opensource.org/licenses/mit-license.php.*
    **********************************************************************/

  -/* This file was substantially auto-generated by doc/gen_params.sage. */
  -#include "../fielddefines.h"
  -
  +class Sketch;
   #if defined(ENABLE_FIELD_BYTES_INT_1)
  ```

ACKs for top commit:
  hebasto:
    re-ACK 62633b5046

Tree-SHA512: fd0a17af6b37fc7641547dab329c2d14ec784941c4d100db1e80d232aff39e45ad9c588982810a2cfc54b4fe820bfe0d50638b53209fec6774fd556b9b0ae180
2023-06-29 13:35:47 +01:00
fanquake
3d51f7c9a8
Merge bitcoin/bitcoin#27932: test: Fuzz on macOS
fae7c50d20 test: Run fuzz tests on macOS (MarcoFalke)

Pull request description:

  Any reason not to?

ACKs for top commit:
  jamesob:
    Github ACK fae7c50d20
  dergoegge:
    utACK fae7c50d20

Tree-SHA512: e45122d73fafb17cea312258314b826cb0745e08daadd28465f687ec02d4c127d2f8cbe20179a9fff5712038850c02c968abb4838fa088b7555e28709317d3a3
2023-06-29 13:08:58 +01:00
fanquake
62633b5046
ci: filter all subtrees from tidy output
We are currently dumping output for some. i.e:
```bash
diff --git a/src/minisketch/src/fields/clmul_1byte.cpp b/src/minisketch/src/fields/clmul_1byte.cpp
index 8826af9..7fd6f2a 100644
--- a/src/minisketch/src/fields/clmul_1byte.cpp
+++ b/src/minisketch/src/fields/clmul_1byte.cpp
@@ -4,21 +4,16 @@
  * file LICENSE or http://www.opensource.org/licenses/mit-license.php.*
  **********************************************************************/

-/* This file was substantially auto-generated by doc/gen_params.sage. */
-#include "../fielddefines.h"
-
+class Sketch;
 #if defined(ENABLE_FIELD_BYTES_INT_1)
```
2023-06-29 11:59:31 +01:00
fanquake
d4018f0b6c
Merge bitcoin/bitcoin#27811: guix: Clean up manifest
a51d7abf1e guix: Specify symbols in modules explicitly (Hennadii Stepanov)
47d51fb048 guix: Drop unneeded modules (Hennadii Stepanov)
57fdedd0e9 guix: Unify fetch methods (Hennadii Stepanov)

Pull request description:

  This PR cleans up the `contrib/guix/manifest.scm` in the following way:
  - Unneeded for a successful build modules have be dropped.
  - Some modules have been enhanced with `#:select` clauses, which improves maintainability (see the commit message for details).

ACKs for top commit:
  TheCharlatan:
    ACK a51d7abf1e

Tree-SHA512: 380a36d03ec303ff8700893cfaad75ca09d84a77fd08d6c6a1679ac96409014b36f0698eb071e09af25ad36f1bc62aec0eec1092146d879251c6a8cce586169b
2023-06-29 10:43:33 +01:00
fanquake
e0cd7458e6
Merge bitcoin/bitcoin#27530: Remove now-unnecessary poll, fcntl includes from net(base).cpp
8d9b90a61e Remove now-unnecessary poll, fcntl includes from net(base).cpp (Ben Woosley)

Pull request description:

  As far as I can tell, the code calling for these includes was removed in:
  6e68ccbefe #24356
  82d360b5a8 #21387

ACKs for top commit:
  fanquake:
    ACK 8d9b90a61e

Tree-SHA512: e536d60f4cf204a10a5b461eca20c8329aa6b0fd3b27651ac9490ed42d3e22e31d652cd991ddc84c96e4758df15aefa7e7f84c710f2feb6d2e0fcfbda9ad4356
2023-06-29 10:32:48 +01:00
fanquake
e8543629ae
Merge bitcoin/bitcoin#27884: test: Use TestNode datadir_path or chain_path where possible
aaaa3aefbd test: Use TestNode *_path properties where possible (MarcoFalke)
dddd89962b test: Allow pathlib.Path as RPC argument via authproxy (MarcoFalke)
fa41614a0a scripted-diff: Use wallets_path and chain_path where possible (MarcoFalke)
fa493fadfb test: Use wallet_dir lambda in wallet_multiwallet test where possible (MarcoFalke)

Pull request description:

  It seems inconsistent, fragile and verbose to:

  * Call `get_datadir_path` to recreate the path that already exists as field in TestNode
  * Call `os.path.join` with the hardcoded chain name or `self.chain` to recreate the TestNode `chain_path` property
  * Sometimes even use the hardcoded node dir name (`"node0"`)

  Fix all issues by using the TestNode properties.

ACKs for top commit:
  willcl-ark:
    re-ACK aaaa3aefbd
  theStack:
    Code-review ACK aaaa3aefbd 🌊

Tree-SHA512: e4720278085beb8164e1fe6c1aa18f601558a9263494ce69a83764c1487007de63ebb51d1b1151862dc4d5b49ded6162a5c1553cd30ea1c28627d447db4d8e72
2023-06-29 09:51:53 +01:00
Ben Woosley
8d9b90a61e
Remove now-unnecessary poll, fcntl includes from net(base).cpp
As far as I can tell, the code calling for these includes was removed in:
6e68ccbefe #24356
82d360b5a8 #21387
2023-06-28 16:35:45 -05:00
Andrew Chow
626d346469
Merge bitcoin/bitcoin#26222: Introduce secp256k1 module with field and group classes to test framework
d4fb58ae8a test: EC: optimize scalar multiplication of G by using lookup table (Sebastian Falbesoner)
1830dd8820 test: add secp256k1 module with FE (field element) and GE (group element) classes (Pieter Wuille)

Pull request description:

  This PR rewrites a portion of `test_framework/key.py`, in a compatible way, by introducing classes that encapsulate field element and group element logic, in an attempt to be more readable and reusable.

  To maximize readability, the group element logic does not use Jacobian coordinates. Instead, group elements just store (affine) X and Y coordinates directly. To compensate for the performance loss this causes, field elements are represented as fractions. This undoes most, but not all, of the performance loss, and there is a few % slowdown (as measured in `feature_taproot.py`, which heavily uses this).

  The upside is that the implementation for group laws (point doubling, addition, subtraction, ...) is very close to the mathematical description of elliptic curves, and this extends to potential future extensions (e.g. ElligatorSwift as needed by #27479).

ACKs for top commit:
  achow101:
    ACK d4fb58ae8a
  theStack:
    re-ACK d4fb58ae8a
  stratospher:
    tested ACK d4fb58a. really liked how this PR makes the secp256k1 code in the tests more intuitive and easier to follow!

Tree-SHA512: 9e0d65d7de0d4fb35ad19a1c19da7f41e5e1db33631df898c6d18ea227258a8ba80c893dab862b0fa9b0fb2efd0406ad4a72229ee26d7d8d733dee1d56947f18
2023-06-28 16:27:55 -04:00
Ryan Ofsky
7c853619ee refactor: Drop unsafe AsBytePtr function
Replace calls to AsBytePtr with direct calls to AsBytes or reinterpret_cast.
AsBytePtr is just a wrapper around reinterpret_cast. It accepts any type of
pointer as an argument and uses reinterpret_cast to cast the argument to a
std::byte pointer.

Despite taking any type of pointer as an argument, it is not useful to call
AsBytePtr on most types of pointers, because byte representations of most types
will be implmentation-specific. Also, because it is named similarly to the
AsBytes function, AsBytePtr looks safer than it actually is. Both AsBytes and
AsBytePtr call reinterpret_cast internally and may be unsafe to use with
certain types, but AsBytes at least has some type checking and can only be
called on Span objects, while AsBytePtr can be called on any pointer argument.

Co-authored-by: Pieter Wuille <pieter@wuille.net>
2023-06-28 15:14:45 -04:00
Andrew Chow
7952a5934a
Merge bitcoin/bitcoin#27927: util: Allow std::byte and char Span serialization
fa38d86235 Use only Span{} constructor for byte-like types where possible (MarcoFalke)
fa257bc831 util: Allow std::byte and char Span serialization (MarcoFalke)

Pull request description:

  Seems odd to require developers to cast all byte-like spans passed to serialization to `unsigned char`-spans. Fix that by passing and accepting byte-like spans as-is. Finally, add tests and update the code to use just `Span` where possible.

ACKs for top commit:
  sipa:
    utACK fa38d86235
  achow101:
    ACK fa38d86235
  ryanofsky:
    Code review ACK fa38d86235. This looks great. The second commit really removes a lot of boilerplate and shows why the first commit is useful.

Tree-SHA512: 788592d9ff515c3ebe73d48f9ecbb8d239f5b985af86f09974e508cafb0ca6d73a959350295246b4dfb496149bc56330a0b5d659fc434ba6723dbaba0b7a49e5
2023-06-28 15:12:12 -04:00
fanquake
d6ee03507f
Merge bitcoin/bitcoin#27987: ci: remove duplicate bsdmainutils from CI configs
248a17addf ci: remove duplicate python3 from CI configs (fanquake)
b50767fdde ci: remove duplicate bsdmainutils from CI configs (fanquake)

Pull request description:

  `bsdmainutils` and `python3` are included in `CI_BASE_PACKAGES`.

ACKs for top commit:
  hebasto:
    ACK 248a17addf

Tree-SHA512: 1e5cddd8a37128690ef3110891549cb9a4c69c6bca558137c97031bc0e494e1053063923d3ccee8b1d9f05d3432765ee10f9ce872e88959b802ba64b6e2d300c
2023-06-28 13:25:14 +01:00
Hennadii Stepanov
a51d7abf1e
guix: Specify symbols in modules explicitly
This change improves the maintainability of the manifest:
(1) It allows to remove the module when the specified symbols are no
    longer used.
(2) It prevents accidental use of other symbols, such as `bash`
    instead of `bash-minimal`.
2023-06-28 12:36:26 +01:00
Hennadii Stepanov
47d51fb048
guix: Drop unneeded modules 2023-06-28 12:35:20 +01:00
Hennadii Stepanov
57fdedd0e9
guix: Unify fetch methods 2023-06-28 12:35:14 +01:00
fanquake
a15388c606
Merge bitcoin/bitcoin#27949: http: update libevent workaround to correct version
79d343a642 http: update libevent workaround to correct version (stickies-v)

Pull request description:

  The libevent bug described in 5ff8eb2637 was already patched in [release-2.1.9-beta](https://github.com/libevent/libevent/releases/tag/release-2.1.9-beta), with cherry-picked commits [5b40744d1581447f5b4496ee8d4807383e468e7a](5b40744d15) and [b25813800f97179b2355a7b4b3557e6a7f568df2](b25813800f).

  There should be no side-effects by re-applying the workaround on an already patched version of libevent (as is currently done in master for people running libevent between 2.1.9 and 2.1.12), but it is best to just set the correct version number to avoid confusion.

  This will prevent situations like e.g. in https://github.com/bitcoin/bitcoin/pull/27909#discussion_r1238858604, where a reverse workaround was incorrectly applied to the wrong version range.

ACKs for top commit:
  fanquake:
    ACK 79d343a642

Tree-SHA512: 56d2576411cf38e56d0976523fec951e032a48e35af293ed1ef3af820af940b26f779b9197baaed6d8b79bd1c7f7334646b9d73f80610d63cffbc955958ca8a0
2023-06-28 12:20:25 +01:00
MarcoFalke
fa086248e5
test: Use same timeout for all index sync 2023-06-28 12:45:36 +02:00
fanquake
ec822e88dd
Merge bitcoin/bitcoin#27813: guix: Update python-lief package to 0.13.2
529c92e837 guix: Update `python-lief` package to 0.13.2 (Hennadii Stepanov)

Pull request description:

  The Guix's `python-lief` package is going to move to using external deps, rather than the bundled ones (https://lists.gnu.org/archive/html/guix-patches/2023-05/msg01302.html). We want to continue using our own package indefinitely, to keep the build simpler, and allow for easier updating.

  Changes in `contrib/devtools/security-check.py` are caused by 6357c6370b.

  Also see: https://github.com/bitcoin/bitcoin/pull/27507.

ACKs for top commit:
  fanquake:
    ACK 529c92e837

Tree-SHA512: ad81111b090a39b380fe25bb27b54a339e78a158f462c7adda25d5ee55f0d654107b1486b29b9687ad0808e27b01e04f53a0e8ffc6600b79103d6bd0dfec64ef
2023-06-28 11:41:35 +01:00
fanquake
248a17addf
ci: remove duplicate python3 from CI configs 2023-06-28 11:10:51 +01:00
fanquake
b50767fdde
ci: remove duplicate bsdmainutils from CI configs 2023-06-28 10:07:51 +01:00
Ryan Ofsky
d9c7c2fd3e
Merge bitcoin/bitcoin#24914: wallet: Load database records in a particular order
3c83b1d884 doc: Add release note for wallet loading changes (Andrew Chow)
2636844f53 walletdb: Remove loading code where the database is iterated (Andrew Chow)
cd211b3b99 walletdb: refactor decryption key loading (Andrew Chow)
31c033e5ca walletdb: refactor defaultkey and wkey loading (Andrew Chow)
c978c6d39c walletdb: refactor active spkm loading (Andrew Chow)
6fabb7fc99 walletdb: refactor tx loading (Andrew Chow)
abcc13dd24 walletdb: refactor address book loading (Andrew Chow)
405b4d9147 walletdb: Refactor descriptor wallet records loading (Andrew Chow)
30ab11c497 walletdb: Refactor legacy wallet record loading into its own function (Andrew Chow)
9e077d9b42 salvage: Remove use of ReadKeyValue in salvage (Andrew Chow)
ad779e9ece walletdb: Refactor hd chain loading to its own function (Andrew Chow)
72c2a54ebb walletdb: Refactor encryption key loading to its own function (Andrew Chow)
3ccde4599b walletdb: Refactor crypted key loading to its own function (Andrew Chow)
7be10adff3 walletdb: Refactor key reading and loading to its own function (Andrew Chow)
52932c5adb walletdb: Refactor wallet flags loading (Andrew Chow)
01b35b55a1 walletdb: Refactor minversion loading (Andrew Chow)

Pull request description:

  Currently when we load a wallet, we just iterate through all of the records in the database and add them completely statelessly. However we have some records which do rely on other records being loaded before they are. To deal with this, we use `CWalletScanState` to hold things temporarily until all of the records have been read and then we load the stateful things.

  However this can be slow, and with some future improvements, can cause some pretty drastic slowdowns to retain this pattern. So this PR changes the way we load records by choosing to load the records in a particular order. This lets us do things such as loading a descriptor record, then finding and loading that descriptor's cache and key records. In the future, this will also let us use `IsMine` when loading transactions as then `IsMine` will actually be working as we now always load keys and descriptors before transactions.

  In order to get records of a specific type, this PR includes some refactors to how we do database cursors. Functionality is also added to retrieve a cursor that will give us records beginning with a specified prefix.

  Lastly, one thing that iterating the entire database let us do was to find unknown records. However even if unknown records were found, we would not do anything with this information except output a number in a log line. With this PR, we would no longer be aware of any unknown records. This does not change functionality as we don't do anything with unknown records, and having unknown records is not an error. Now we would just not be aware that unknown records even exist.

ACKs for top commit:
  MarcoFalke:
    re-ACK 3c83b1d884 🍤
  furszy:
    reACK 3c83b1d8
  ryanofsky:
    Code review ACK 3c83b1d884. Just Marco's suggested error handling fixes since last review

Tree-SHA512: 15fa56332fb2ce4371db468a0c674ee7a3a8889c8cee9f428d06a7d1385d17a9bf54bcb0ba885c87736841fe6a5c934594bcf4476a473616510ee47862ef30b4
2023-06-27 19:03:15 -04:00
Andrew Chow
caff95a023
Merge bitcoin/bitcoin#27896: Remove the syscall sandbox
32e2ffc393 Remove the syscall sandbox (fanquake)

Pull request description:

  After initially being merged in #20487, it's no-longer clear that an internal syscall sandboxing mechanism is something that Bitcoin Core should have/maintain, especially when compared to better maintained/supported alterantives, i.e [firejail](https://github.com/netblue30/firejail).

  There is more related discussion in #24771.

  Note that given where it's used, the sandbox also gets dragged into the kernel.

  If it's removed, this should not require any sort of deprecation, as this was only ever an opt-in, experimental feature.

  Closes #24771.

ACKs for top commit:
  davidgumberg:
     crACK 32e2ffc393
  achow101:
    ACK 32e2ffc393
  dergoegge:
    ACK 32e2ffc393

Tree-SHA512: 8cf71c5623bb642cb515531d4a2545d806e503b9d57bfc15a996597632b06103d60d985fd7f843a3c1da6528bc38d0298d6b8bcf0be6f851795a8040d71faf16
2023-06-27 18:19:21 -04:00
Andrew Chow
5cce4d293e
Merge bitcoin/bitcoin#27334: util: implement noexcept move assignment & move ctor for prevector
bfb9291a86 util: implement prevector's move ctor & move assignment (Martin Leitner-Ankerl)
fffc86f49f test: CScriptCheck is used a lot in std::vector, make sure that's efficient (Martin Leitner-Ankerl)
81f67977f5 util: prevector's move ctor and move assignment is `noexcept` (Martin Leitner-Ankerl)
d380d2877e bench: Add benchmark for prevector usage in std::vector (Martin Leitner-Ankerl)

Pull request description:

  `prevector`'s move assignment and move constructor were not `noexcept`, which makes it inefficient to use inside STL containers like `std::vector`. That's the case e.g. for `CScriptCheck`. This PR adds `noexcept`, and also implements the move assignment & ctor, which makes it quite a bit more efficient to use prevector in an std::vector.

  The PR also adds a benchmark which grows an `std::vector` by adding `prevector` objects to it.

  merge-base:
  |               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |         bra/op |   miss% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
  |            6,440.29 |          155,272.42 |    0.2% |       40,713.01 |       20,473.84 |  1.989 |       7,132.01 |    0.2% |      0.44 | `PrevectorFillVectorDirectNontrivial`
  |            3,213.19 |          311,217.35 |    0.7% |       35,373.01 |       10,214.07 |  3.463 |       6,945.00 |    0.2% |      0.43 | `PrevectorFillVectorDirectTrivial`
  |           34,749.70 |           28,777.23 |    0.1% |      364,396.05 |      110,521.94 |  3.297 |      78,568.37 |    0.1% |      0.43 | `PrevectorFillVectorIndirectNontrivial`
  |           32,535.05 |           30,736.09 |    0.4% |      353,823.31 |      103,464.53 |  3.420 |      79,871.80 |    0.2% |      0.40 | `PrevectorFillVectorIndirectTrivial`

  util: prevector's move ctor and move assignment is `noexcept`:
  |               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |         bra/op |   miss% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
  |            6,603.87 |          151,426.40 |    0.2% |       23,734.01 |       21,009.63 |  1.130 |       2,445.01 |    0.3% |      0.44 | `PrevectorFillVectorDirectNontrivial`
  |            1,980.93 |          504,813.15 |    0.1% |       13,784.00 |        6,304.32 |  2.186 |       2,258.00 |    0.3% |      0.44 | `PrevectorFillVectorDirectTrivial`
  |           19,110.54 |           52,327.15 |    0.1% |      139,816.41 |       51,987.72 |  2.689 |      28,512.18 |    0.1% |      0.43 | `PrevectorFillVectorIndirectNontrivial`
  |           12,334.37 |           81,074.27 |    0.7% |      125,655.12 |       39,253.58 |  3.201 |      27,854.46 |    0.2% |      0.44 | `PrevectorFillVectorIndirectTrivial`

  util: implement prevector's move ctor & move assignment
  |               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |         bra/op |   miss% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
  |            5,262.66 |          190,018.01 |    0.2% |       20,157.01 |       16,745.26 |  1.204 |       2,445.01 |    0.3% |      0.44 | `PrevectorFillVectorDirectNontrivial`
  |            1,687.07 |          592,744.35 |    0.2% |       12,742.00 |        5,368.02 |  2.374 |       2,258.00 |    0.3% |      0.44 | `PrevectorFillVectorDirectTrivial`
  |           17,930.80 |           55,769.95 |    0.1% |      136,237.69 |       47,903.31 |  2.844 |      28,512.02 |    0.2% |      0.42 | `PrevectorFillVectorIndirectNontrivial`
  |           11,893.75 |           84,077.78 |    0.2% |      126,182.02 |       37,852.91 |  3.333 |      28,152.01 |    0.1% |      0.44 | `PrevectorFillVectorIndirectTrivial`

  As can be seen, mostly thanks to just `noexcept` the benchmark becomes about 2 times faster because `std::vector` can now use move operations instead of having to fall back to copy everything

  I had a look at how this change affects the other benchmarks, and they are all pretty much the same, the only noticable difference is `CCheckQueueSpeedPrevectorJob` goes from 364.56ns down to 346.21ns.

ACKs for top commit:
  achow101:
    ACK bfb9291a86
  jonatack:
    > Tested Approach ACK [bfb9291](bfb9291a86), ~ACK modulo re-verifying the implementation of the last commit.
  john-moffett:
    Approach ACK bfb9291a86
  theStack:
    Tested and light code-review ACK bfb9291a86

Tree-SHA512: 242995d7cb2f8ebfa73177aa690a505f189d91edeb8cea3e34a41ca507c8cb17c65fe2a4e196fdafc5c6e89b2b2222627bfc9f5c316517de0857b7b5e9c58225
2023-06-27 15:42:51 -04:00
Jon Atack
11900e5a8a doc: simplify the router options in doc/i2p.md
- the Java I2P router and i2pd are the two routers have been heavily tested
  with Bitcoin Core and are what people and node software packages use

- i2p-zero (https://github.com/i2p-zero/i2p-zero) hasn't been updated since
  July 2021 and its last release was in December 2020

- the other routers in the wikipedia page are niche
2023-06-27 10:26:57 -06:00
Jon Atack
b505d59326 doc: clarify when and how to launch the SAM bridge in doc/i2p.md
The SAM application bridge is not enabled by default in the Java I2P Router,
and the relevant info is somewhat difficult to find in its documentation.

Also, remove a duplicate sentence; the preceding paragraph begins with the same.
2023-06-27 10:26:06 -06:00
Andrew Chow
3c83b1d884 doc: Add release note for wallet loading changes
Co-Authored-By: Ryan Ofsky <ryan@ofsky.org>
2023-06-27 11:08:06 -04:00
Andrew Chow
2636844f53 walletdb: Remove loading code where the database is iterated
Instead of iterating the database to load the wallet, we now load
particular kinds of records in an order that we want them to be loaded.
So it is no longer necessary to iterate the entire database to load the
wallet.
2023-06-27 11:08:05 -04:00
Andrew Chow
cd211b3b99 walletdb: refactor decryption key loading
Instead of loading decryption keys as we iterate the database, load them
explicitly.
2023-06-27 11:08:00 -04:00
Andrew Chow
31c033e5ca walletdb: refactor defaultkey and wkey loading
Instead of dealing with these records when iterating the entire
database, find and handle them explicitly.

Loading of OLD_KEY records is bumped up to a LOAD_FAIL error as we will
not be able to use these types of keys which can lead to users missing
funds.
2023-06-27 11:07:51 -04:00
Andrew Chow
c978c6d39c walletdb: refactor active spkm loading
Instead of loading active spkm records as we come across them when
iterating the database, load them explicitly.

Due to exception handling changes, deserialization errors are now
treated as critical.
2023-06-27 11:07:46 -04:00
Andrew Chow
6fabb7fc99 walletdb: refactor tx loading
Instead of loading tx records as we come across them when iterating the
database, load them explicitly.
2023-06-27 11:07:38 -04:00
Andrew Chow
abcc13dd24 walletdb: refactor address book loading
Instead of loading address book records as we come across them when
iterating the database, load them explicitly

Due to exception handling changes, deserialization errors are now
treated as critical.

The error message for noncritical errors has also been updated to
reflect that there's more data that could be missing than just address
book entries and tx data.
2023-06-27 11:04:18 -04:00
Andrew Chow
405b4d9147 walletdb: Refactor descriptor wallet records loading
Instead of loading descriptor wallet records as we come across them when
iterating the database, loading them explicitly.

Exception handling for these records changes to a per-record type basis,
rather than globally. This results in some records now failing with a
critical error rather than a non-critical one.
2023-06-27 11:04:18 -04:00
Andrew Chow
30ab11c497 walletdb: Refactor legacy wallet record loading into its own function
Instead of loading legacy wallet records as we come across them when
iterating the database, load them explicitly.

Exception handling for these records changes to a per-record type basis,
rather than globally. This results in some records now failing with a
critical error rather than a non-critical one.
2023-06-27 11:00:47 -04:00
fanquake
7ee41217b3
Merge bitcoin/bitcoin#27940: test: Add implicit-signed-integer-truncation:*/include/c++/ suppression
fae55f989e test: Add implicit-signed-integer-truncation:*/include/c++/ suppression (MarcoFalke)

Pull request description:

  Needed for aarch64. Steps to test on aarch64:

  ```
  lscpu | grep Arch
  FILE_ENV="./ci/test/00_setup_env_native_fuzz.sh" ./ci/test_run_all.sh
  ```

ACKs for top commit:
  fanquake:
    ACK fae55f989e  - reproduced the failure:

Tree-SHA512: b5058873118d285cc5d678a572cf4b890f8d68a24e1ac0987490f1b4123469a2b4456b08474f372e6aa49bb0d69e16f2c8277208b1cde3222a317f000beb5056
2023-06-27 15:52:33 +01:00
Sebastian Falbesoner
d4fb58ae8a test: EC: optimize scalar multiplication of G by using lookup table
On my machine, this speeds up the functional test feature_taproot.py by
a factor of >1.66x (runtime decrease from 1m16.587s to 45.334s).

Co-authored-by: Pieter Wuille <pieter@wuille.net>
2023-06-27 09:34:52 -04:00
Pieter Wuille
1830dd8820 test: add secp256k1 module with FE (field element) and GE (group element) classes
These are primarily designed for ease of understanding, not performance.
2023-06-27 09:34:48 -04:00
fanquake
b741a62a2f
Merge bitcoin/bitcoin#27929: Added static_assert to check that base_blob is using whole bytes.
5fc4939e17 Added static_assert to check that base_blob is using whole bytes. (Brotcrunsher)

Pull request description:

  Prior to this commit it was possible to create base_blobs with any arbitrary amount of bits, like base_blob<9>. One could assume that this would be a valid way to create a bit field that guarantees to have at least 9 bits. However, in such a case, base_blob would not behave as expected because the WIDTH is rounded down to the closest whole byte (simple integer division by 8). This commit makes sure that this oddity is detected and blocked by the compiler.

ACKs for top commit:
  MarcoFalke:
    lgtm ACK 5fc4939e17
  theStack:
    ACK 5fc4939e17
  stickies-v:
    ACK 5fc4939e17

Tree-SHA512: 6a06760f09d4a9e6f0b9338d4dddd4091f2ac59a843a443d9302959936d72c55f7cccd55a51ec3a5a799921f68be1b87968ef3c9c11d3389cbd369b5045bb50a
2023-06-27 12:54:20 +01:00
fanquake
35b01e8504
Merge bitcoin/bitcoin#27676: macOS: Bump minimum required runtime version and prepare for building with upstream LLVM
3df6070466 contrib: remove macOS lazy_bind check (fanquake)
9bc357e205 build: explicitly opt-in to new fixup_chains functionality for darwin (Cory Fields)
fb61bc0c02 depends: Bump MacOS minimum runtime requirement to 11.0 (Cory Fields)
c2cd47280c depends: bump darwin clang to 11.1 (Cory Fields)

Pull request description:

  This (I believe) resolves the last of the blockers for [switching us away from cctools and instead using out-of-the-box llvm and lld](https://github.com/bitcoin/bitcoin/pull/21778) for building Darwin binaries.

  For now, we continue building with a pre-packaged llvm and cctools, but after this PR the clang+lld combo should just work for anyone trying it. Additionally after this PR, the new runtime `fixup_chains` behavior will be in-use, as ld64 uses it as well.

  The commits may seem unrelated, so in detail:

  lld (llvm's linker) has been a work-in-progress for Darwin for years. Recently though, it has gained nearly all of the features we require. The last missing feature from ld64, `-Wl,-bind_at_load`, is not implemented in lld; as far as I can tell [lazy loading has conceptually been replaced by fixup chains](https://www.emergetools.com/blog/posts/iOS15LaunchTime).

  So that means we don't need ld64's `bind_at_load` as long as lld can handle `-Wl,-fixup_chains` (which it can). I've added it to our configure as a linker option mostly so that we can see it in the logs; it's default-on as long as the minimum version is >11.0.

  About that: the runtime functionality required for `-Wl,-fixup_chains` [requires macOS >=11.0](https://github.com/llvm/llvm-project/blob/release/16.x/lld/MachO/Driver.cpp#L1021). Hence the commit that bumps the minimum version. Our current min runtime of `10.15` has been unsupported since September 2022, so I don't expect this bump to be controversial.

  Lastly, with the minimum runtime version bumped to 11.0, our current version of pre-compiled clang we use for macOS is too old to understand `-mmacosx-version-min=11.0` because it expects `=10.x`. So I've made the smallest possible bump (from 10.0.1 to 11.1.0) to a version that understands. This bump is arbitrary and unfortunate, but likely to be short-lived as we may end up replacing it with llvm+lld for v26 anyway. I've held off on bumping the SDK as I think that makes sense to do as part of the lld switch instead.

ACKs for top commit:
  hebasto:
    ACK 3df6070466
  gruve-p:
    ACK 3df6070466
  fanquake:
    ACK 3df6070466
  TheCharlatan:
    ACK 3df6070466

Tree-SHA512: 0200ec4a3b88df33877ae82c15b5c04d745852550923f491a354b391cac65f88e4df116a40055c23a8cbcfcdfb9a376c6ae8fdd0e898e7b966bc213dcb5857cf
2023-06-27 09:57:21 +01:00
MarcoFalke
fa38d86235
Use only Span{} constructor for byte-like types where possible
This removes bloat that is not needed.
2023-06-27 10:13:37 +02:00
MarcoFalke
fa257bc831
util: Allow std::byte and char Span serialization 2023-06-27 10:13:29 +02:00