Commit Graph

77 Commits

Author SHA1 Message Date
Kittywhiskers Van Gogh
c6b9186e69
merge bitcoin#25325: Add pool based memory resource 2024-09-04 16:29:30 +00:00
Kittywhiskers Van Gogh
aa361b2717
merge bitcoin#24301: header-only Boost 2024-08-13 22:53:48 +07:00
Kittywhiskers Van Gogh
30ac41e068
merge bitcoin#22284: performance improvements to ProtectEvictionCandidatesByRatio() 2024-06-12 16:37:11 +00:00
Kittywhiskers Van Gogh
1b1924e3d5
merge bitcoin#28008: BIP324 ciphersuite 2024-03-05 21:43:21 +00:00
Kittywhiskers Van Gogh
78a9f1e55b merge bitcoin#27479: BIP324: ElligatorSwift integrations 2023-11-21 07:59:03 -06:00
fanquake
8ae94ada7c Merge #18397: build: Fix libevent linking for bench_bitcoin binary
cd04286825c6512b46bf59ab7b3dfffb0e36d65b build: Fix typo in EVENT_CFLAGS variable (Hennadii Stepanov)
f709ad0c907d87d03002455967cc30ae7d704d80 build: Fix libevent linking for bench_bitcoin binary (Hennadii Stepanov)

Pull request description:

  This change fixes `libevent` linking error for the `bench_bitcoin` binary.

  This PR is an alternative to #18377.
  Fix #18373.

  Also fixed a typo in `EVENT_CFLAGS` variable noted by **brakmic**.

ACKs for top commit:
  fanquake:
    ACK cd04286825c6512b46bf59ab7b3dfffb0e36d65b

Tree-SHA512: a62f7457e86b11d3a55d603ea5d83f3a413792e2f28a0c72300e54d12591bd6f0acc1d76a4bd4b591e0223bc6d530e7a4b9a8b939fe2fdbf2dddfda5b1b537be
2023-05-31 12:01:04 -05:00
Wladimir J. van der Laan
4f57959387 Merge #16902: O(1) OP_IF/NOTIF/ELSE/ENDIF script implementation
e6e622e5a0e22c2ac1b50b96af818e412d67ac54 Implement O(1) OP_IF/NOTIF/ELSE/ENDIF logic (Pieter Wuille)
d0e8f4d5d8ddaccb37f98b7989fb944081e41ab8 [refactor] interpreter: define interface for vfExec (Anthony Towns)
89fb241c54fc85befacfa3703d8e21bf3b8a76eb Benchmark script verification with 100 nested IFs (Pieter Wuille)

Pull request description:

  While investigating what mechanisms are possible to maximize the per-opcode verification cost of scripts, I noticed that the logic for determining whether a particular opcode is to be executed is O(n) in the nesting depth. This issue was also pointed out by Sergio Demian Lerner in https://bitslog.wordpress.com/2017/04/17/new-quadratic-delays-in-bitcoin-scripts/, and this PR implements a variant of the O(1) algorithm suggested there.

  This is not a problem currently, because even with a nesting depth of 100 (the maximum possible right now due to the 201 ops limit), the slowdown caused by this on my machine is around 70 ns per opcode (or 0.25 s per block) at worst, far lower than what is possible with other opcodes.

  This PR mostly serves as a proof of concept that it's possible to avoid it, which may be relevant in discussions around increasing the opcode limits in future script versions. Without it, the execution time of scripts can grow quadratically with the nesting depth, which very quickly becomes unreasonable.

  This improves upon #14245 by completely removing the `vfExec` vector.

ACKs for top commit:
  jnewbery:
    Code review ACK e6e622e5a0e22c2ac1b50b96af818e412d67ac54
  MarcoFalke:
    ACK e6e622e5a0e22c2ac1b50b96af818e412d67ac54 🐴
  fjahr:
    ACK e6e622e5a0e22c2ac1b50b96af818e412d67ac54
  ajtowns:
    ACK e6e622e5a0e22c2ac1b50b96af818e412d67ac54
  laanwj:
    concept and code review ACK e6e622e5a0e22c2ac1b50b96af818e412d67ac54
  jonatack:
    ACK e6e622e5a0e22c2ac1b50b96af818e412d67ac54 code review, build, benches, fuzzing

Tree-SHA512: 1dcfac3411ff04773de461959298a177f951cb5f706caa2734073bcec62224d7cd103767cfeef85cd129813e70c14c74fa8f1e38e4da70ec38a0f615aab1f7f7
2023-05-31 12:01:04 -05:00
MarcoFalke
5066e83d59 Merge #17593: test: move more utility functions into test utility library
78e283e656bf1643944ffdb76185f3468eb25895 [test] move wallet helper functions into test library (Martin Zumsande)
f613e5dfdafe708f63ebb5193c44e2bc770c6651 [test] move mining helper functions into test library (Martin Zumsande)
2cb4e8bdc7ef75ae8d95c246af1e8e1f9c7045bd [test] move string helper functions into test library (Martin Zumsande)

Pull request description:

  This disbands `test/util.h` and `test/util.cpp` and moves the content into the test utility library recently created in #17542, so that all test utility functions are in one place.

  The content of the original files are split into three modules:
  1) string helper functions go to `test/util/str`
  2) mining helper functions go to the newly created `test/util/mining`
  3) wallet helper functions go to the newly created `test/util/wallet`

ACKs for top commit:
  MarcoFalke:
    ACK 78e283e656bf1643944ffdb76185f3468eb25895 🔧

Tree-SHA512: f182a61e86e76c32bcb84e37f44904d3a4a9c5a321f7a8efdda5368a6623cb8b5a5384ec4f96e67f0357b0c22099f6e3ecd0ac4cb467e3fa3f3128f8d36edfb8
2023-04-25 23:14:25 +03:00
Wladimir J. van der Laan
906dd71de0 Merge #16267: bench: Benchmark blockToJSON
91509ffe247b0eacbf84214c7c9c3f8a0012f2eb bench: Benchmark blockToJSON (Kirill Fomichev)

Pull request description:

  Related:
  - "getblock performance issue on verbosity" https://github.com/bitcoin/bitcoin/issues/15925
  - "refactor: Avoid UniValue copy constructor" #15974

ACKs for top commit:
  laanwj:
    ACK 91509ffe247b0eacbf84214c7c9c3f8a0012f2eb

Tree-SHA512: e70b12cb31921c7527bde334f52f39776da698b6bbdb196079a8b68478c67585a5bd7bed7403f65166bd604f7ed60778c53dc064d743bb8368318a1283d1073e
2023-03-29 21:01:56 +03:00
MarcoFalke
10750000d5
Merge #18754: bench: add CAddrMan benchmarks
a9b957740e3490d87e5ce0b7f1b93ba43bb19764 bench: add CAddrMan benchmarks (Vasil Dimov)

Pull request description:

  The added benchmarks exercise the public methods Add(), GetAddr(),
  Select() and Good().

ACKs for top commit:
  naumenkogs:
    utACK a9b9577
  MarcoFalke:
    ACK a9b957740e3490d87e5ce0b7f1b93ba43bb19764

Tree-SHA512: af54b2fbd97db34faf4cc6c9bacb20d2c97d0aaddb9cf91b220bc2e09227b55345402ed17e34450745493e3a2b286c176c031cdeb477415570a757cee16b06a8
2023-03-03 23:07:17 +05:30
Kittywhiskers Van Gogh
f42288c984 partial bitcoin#19077: Add sqlite as an alternative wallet database and use it for new descriptor wallets 2023-02-07 10:53:33 -06:00
Kittywhiskers Van Gogh
305abe91f9
build/depends: commit dashpay/bls-signatures@66ee820f to source tree as vendored (#5077)
* Squashed 'src/dashbls/' content from commit 66ee820fbc

git-subtree-dir: src/dashbls
git-subtree-split: 66ee820fbc9e3b97370db8c164904af48327a124

* build: stop tracking build-system generated relic_conf.h.in

* build: add support for building bls-signatures from local subtree

* build: add exclusions to linting scripts and filters

* build: drop bls-signatures (bls-dash) from depends
2022-11-22 11:34:46 -06:00
Kittywhiskers Van Gogh
1e9733f195 merge bitcoin#19558: split pthread flags out of ldflags and dont use when building libconsensus 2022-08-23 21:33:33 +05:30
Kittywhiskers Van Gogh
887b4324d3 trivial: revert dashification of source and header filenames 2022-08-09 14:16:29 +05:30
MarcoFalke
26d6ace1c2 Merge #14212: build: Remove libssl from LDADD unless gui
cccc362d62 build: Remove libssl from LDADD unless gui (MarcoFalke)

Pull request description:

  libssl is only used by the gui, so no need to LDADD it to the other tools and binaries

  Follow up of the commit which removed rpcssl: 40b556d374

Tree-SHA512: 9dbdf4faf40699cea3a37349ac83dbcacdaa062f5338416ff4ba77924c47d9e148b27218165c5aa3584a1ef4899e0fa237ff571208aa0b98803761e802d1e5dc
2022-05-23 02:15:41 -04:00
Kittywhiskers Van Gogh
2314ba4c99 merge bitcoin#17265: Remove OpenSSL 2022-04-25 15:29:52 +05:30
Kittywhiskers Van Gogh
43152b2b35
merge #17165: Remove BIP70 support (#4023)
* compat: remove bswap_* check on macOS

This was originally added in #9366 to fix the gui build, as
Protobuf would also define these macros. Now that we're no-longer
using Protobuf, remove the additional check.

* build: skip building OpenSSL lib_ssl

* build: remove OpenSSL from Qt build

More info available from:
https://doc.qt.io/qt-5/ssl.html#enabling-and-disabling-ssl-support

* build: remove EVP_MD_CTX_new detection

This was added in #9475 to fix LibreSSL compatibility for
BIP70, so is no longer required.

* build: remove SSL lib detection

* gui: update BIP70 support message

* build: remove BIP70 entries from macOS Info.plist

* gui: remove payment request file handling from OpenURI dialog

* gui: remove BIP70 Support

* build: remove protobuf from depends and contrib
2022-04-25 12:01:47 +03:00
UdjinM6
ac654efa60
Merge pull request #4709 from PastaPastaPasta/develop-trivial-2022-02-26
backport: trivial backports Feb 26 2022
2022-03-08 02:54:23 +03:00
fanquake
1b057e0da6 Merge #18429: build: remove double LIBBITCOIN_SERVER from bench-Makefile
1f97b69ba27deb645bf5dd229d0cb97d2baf8f49 build: remove double LIBBITCOIN_SERVER from bench-Makefile (Harris)

Pull request description:

  This PR removes the redundant **LIBBITCOIN_SERVER** linking from bench's Makefile.
  This PR is similar to https://github.com/bitcoin/bitcoin/pull/17910

  Originally, this PR was part of https://github.com/bitcoin/bitcoin/pull/18377, which later got replaced by a better one https://github.com/bitcoin/bitcoin/pull/18397 written by **hebasto**.

ACKs for top commit:
  Empact:
    Code Review ACK 1f97b69ba2
  theStack:
    ACK 1f97b69ba2
  hebasto:
    ACK 1f97b69ba27deb645bf5dd229d0cb97d2baf8f49

Tree-SHA512: e43035262361d4458a7dcfc920445540f19301387814cde1be0539c936fc20da0dcbe49e5ea25385e6d36d9639515b7a4171228223da568d93427e9c32810945
2022-03-07 09:40:31 -06:00
PastaPastaPasta
47ad9ab146
Merge pull request #4706 from kittywhiskers/libnatpmp
merge bitcoin#18077...22397: Add NAT-PMP port forwarding support
2022-03-05 11:03:44 -06:00
Kittywhiskers Van Gogh
687c7d4a5d merge bitcoin#18077: Add NAT-PMP port forwarding support 2022-02-26 17:49:13 +05:30
Kittywhiskers Van Gogh
0b4eddc359 merge bitcoin#13204: Faster sigcache nonce 2022-02-26 10:47:54 +05:30
Kittywhiskers Van Gogh
01dc196162 merge bitcoin#17542: Create test utility library from src/test/util 2022-02-26 10:45:13 +05:30
Kittywhiskers Van Gogh
e36ee01f99 merge bitcoin#17384: Create new test library 2022-02-26 10:45:13 +05:30
Kittywhiskers Van Gogh
7b74a34aba merge bitcoin#17292: Add new mempool benchmarks for a complex pool 2022-02-26 10:45:13 +05:30
Kittywhiskers Van Gogh
61e2c6d228 merge bitcoin#17183: test/bench: dedup Build{Crediting,Spending}Transaction() 2022-02-26 10:45:13 +05:30
Kittywhiskers Van Gogh
e51c4c41c0 merge bitcoin#16299: Move generated data to a dedicated translation unit 2021-12-12 22:36:50 +05:30
Kittywhiskers Van Gogh
2c98320c1a merge bitcoin#15288: Remove wallet -> node global function calls 2021-11-14 15:32:37 +05:30
Kittywhiskers Van Gogh
046fcc2060 partial bitcoin#15779: wallet_balance benchmark 2021-10-25 21:28:37 +05:30
Kittywhiskers Van Gogh
ad203019f9 merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
Kittywhiskers Van Gogh
544823b272 merge bitcoin#15473: bench: Benchmark MempoolToJSON 2021-10-25 14:49:12 +05:30
Kittywhiskers Van Gogh
a72eb30bf3 merge bitcoin#14400: Add Benchmark to test input de-duplication worst case 2021-10-25 14:49:12 +05:30
Kittywhiskers Van Gogh
ea3dc3b679 merge bitcoin#13219: Add block assemble benchmark 2021-10-25 14:49:12 +05:30
PastaPastaPasta
ff22aa299a
Merge #14437: Refactor: Start to separate wallet from node 2021-10-20 12:29:45 -04:00
Kittywhiskers Van Gogh
fc8952aa19
build: add libgmp detection, make immer a package (#4311)
* build: detect the presence of libgmp before generating Makefile

* depends: add arximboldi/immer@v0.6.2 as a package and add detection

* depends: remove immer from source tree, build using package only

* Drop immer refs from tools

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2021-08-10 22:35:55 +03:00
Kittywhiskers Van Gogh
b5db3c3d65 merge #18011: Replace current benchmarking framework with nanobench 2021-07-05 18:28:55 +05:30
Wladimir J. van der Laan
c7c810772d
Merge #13586: refactor: add benchmarks to bech32::Encode/Decode
189cf35f3e6d2cc9ed08eb23dd0ea36be28b6c11 Add simple bech32 benchmarks (Karl-Johan Alm)

Pull request description:

  This PR adds benchmarks to `Encode()`/`Decode()`.

  The benchmark commit is duplicated in #13632.

Tree-SHA512: 102a193e4af58c9cb23c66d3dc7e174aa6328edab0ed74f92deb7804db5c3d0601807b3e25a5472b5c72d6113cde0dbc9976315644671a8f14ecf349967dbaaa
2021-06-28 18:03:21 -05:00
dustinface
122078b9ec
backport: bitcoin#10583 - [RPC] Split part of validateaddress into getaddressinfo (#3880)
* [rpc] split wallet and non-wallet parts of DescribeAddressVisitor

* [rpc] Move DescribeAddressVisitor to rpc/util

* Create getaddressinfo RPC and deprecate parts of validateaddress

Moves the parts of validateaddress which require the wallet into getaddressinfo
which is part of the wallet RPCs. Mark those parts of validateaddress which
require the wallet as deprecated.

Validateaddress will  call getaddressinfo
for the data that both share for right now.

Moves IsMine functions to libbitcoin_common and then links libbitcoin_wallet
before libbitcoin_common in order to prevent linker errors since IsMine is no
longer used in libbitcoin_server.

* scripted-diff: validateaddress to getaddressinfo in tests

Change all instances of validateaddress to getaddressinfo since it seems that
no test actually uses validateaddress for actually validating addresses.

-BEGIN VERIFY SCRIPT-
find ./test/functional -path '*py' -not -path ./test/functional/wallet_disable.py -not -path ./test/functional/rpc_deprecated.py -not -path ./test/functional/wallet_address_types.py -exec sed -i'' -e 's/validateaddress/getaddressinfo/g' {} \;
-END VERIFY SCRIPT-

* wallet: Add missing description of "hdchainid"

* Update src/wallet/rpcwallet.cpp

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>

Co-authored-by: John Newbery <john@johnnewbery.com>
Co-authored-by: Andrew Chow <achow101-github@achow101.com>
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-12-17 13:46:20 +01:00
MarcoFalke
40dc6c4f7b
Merge #13025: Dead code removal
1bf3f33b46 node: Removed unused wallet-related methods from the Node interface. (Thomas Snider)
b38200459f benchmark: Removed bench/perf.cpp (Thomas Snider)

Pull request description:

  Not sure if these should be separate PRs.

  First is removal of a platform abstraction for getting cycle counters where possible.  Since the benchmarking switch to counting number of iterations over a fixed window instead of counting cycles per iteration, these are unused.

  Second is removal of a few methods from the Node interface that seem vestigial from when the concepts of wallet/node were not as clearly separated.

Tree-SHA512: de1460a7d4473ca19db4e2ca845185c63c765d12462c2685044a1f27dedab266cd908bc52235a881a7ad98bc251a4abf4eae523e5f599c169e3511e489f19a0d
2020-11-17 14:32:37 -05:00
MarcoFalke
f77b58e89f Merge #13312: docs: Add a note about the source code filename naming convention
e56771365b Do not use uppercase characters in source code filenames (practicalswift)
419a1983ca docs: Add a note about the source code filename naming convention (practicalswift)

Pull request description:

  Add a note about the source code filename naming convention.

Tree-SHA512: 8d329bd9e19bcd26e74b0862fb0bc2369b46095dbd3e69d34859908632763abd7c3d00ccc44ee059772ad4bae4460c2bcc1c0e22fd9d8876d57e5fcd346cea4b
2020-07-07 11:17:45 -05:00
Wladimir J. van der Laan
17929071d4 Merge #12254: BIP 158: Compact Block Filters for Light Clients
254c85b68794ada713dbdae415db72adf5fcbaf3 bench: Benchmark GCS filter creation and matching. (Jim Posen)
f33b717a85363e067316c133a542559d2f4aaeca blockfilter: Optimization on compilers with int128 support. (Jim Posen)
97b64d67daf0336dfb64b132f3e4d6a4c1967da4 blockfilter: Unit test against BIP 158 test vectors. (Jim Posen)
a4afb9cadbaecb0676e6475ab8d32a52faecb47a blockfilter: Additional helper methods to compute hash and header. (Jim Posen)
cd09c7925b5af4104834971cfe072251e3ac2bda blockfilter: Serialization methods on BlockFilter. (Jim Posen)
c1855f6052aca806fdb51be01b30dfeee8b55f40 blockfilter: Construction of basic block filters. (Jim Posen)
53e7874e079f9ddfe8b176f11d46e6b59c7283d5 blockfilter: Simple test for GCSFilter construction and Match. (Jim Posen)
558c536e35a25594881693e6ff01d275c88d7af1 blockfilter: Implement GCSFilter Match methods. (Jim Posen)
cf70b550054eed36f194eaa13f4a9cb31e32df38 blockfilter: Implement GCSFilter constructors. (Jim Posen)
c454f0ac63c6028f54c7eb51683b3ccdb475b19b blockfilter: Declare GCSFilter class for BIP 158 impl. (Jim Posen)
9b622dc72279b027c59d6541cddff53800fc689b streams: Unit tests for BitStreamReader and BitStreamWriter. (Jim Posen)
fe943f99bf0a2bbb12e30bc4803c0337e3c95b93 streams: Implement BitStreamReader/Writer classes. (Jim Posen)
87f2d9ee43a9220076b1959d1ca65245d9591be9 streams: Unit test for VectorReader class. (Jim Posen)
947133dec92cd25ec2b3358c09b8614ba6fb40d4 streams: Create VectorReader stream interface for vectors. (Jim Posen)

Pull request description:

  This implements the compact block filter construction in [BIP 158](https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki). The code is not used anywhere in the Bitcoin Core code base yet. The next step towards [BIP 157](https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki) support would be to create an indexing module similar to `TxIndex` that constructs the basic and extended filters for each validated block.

  ### Filter Sizes

  [Here](https://gateway.ipfs.io/ipfs/QmRqaAAQZ5ZX5eqxP7J2R1MzFrc2WDdKSWJEKtQzyawqog) is a CSV of filter sizes for blocks in the main chain.

  As you can see below, the ratio of filter size to block size drops after the first ~150,000 blocks:

  ![filter_sizes](https://user-images.githubusercontent.com/881253/42900589-299772d4-8a7e-11e8-886d-0d4f3f4fbe44.png)

  The reason for the relatively large filter sizes is that Golomb-coded sets only achieve good compression with a sufficient number of elements. Empirically, the average element size with 100 elements is 14% larger than with 10,000 elements.

  The ratio of filter size to block size is computed without witness data for basic filters. Here is a summary table of filter size ratios *for blocks after height 150,000*:

  | Stat | Filter Type |
  |-------|--------------|
  | Weighted Size Ratio Mean | 0.0198 |
  | Size Ratio Mean | 0.0224 |
  | Size Ratio Std Deviation | 0.0202 |
  | Mean Element Size (bits) | 21.145 |
  | Approx Theoretical Min Element Size (bits) | 21.025 |

Tree-SHA512: 2d045fbfc3fc45490ecb9b08d2f7e4dbbe7cd8c1c939f06bbdb8e8aacfe4c495cdb67c820e52520baebbf8a8305a0efd8e59d3fa8e367574a4b830509a39223f
2020-06-13 14:08:18 -05:00
Wladimir J. van der Laan
a76bafb98c Merge #16046: util: Add type safe GetTime
fa013664ae23d0682a195b9bded85bc19c99536e util: Add type safe GetTime (MarcoFalke)

Pull request description:

  There are basically two ways to get the time in Bitcoin Core:
  * get the system time (via `GetSystemTimeInSeconds` or `GetTime{Millis,Micros}`)
  * get the mockable time (via `GetTime`)

  Both return the same type (a plain int). This can lead to (test-only) bugs such as 99464bc38e.

  Fix that by deprecating `GetTime` and adding a `GetTime<>` that returns the mockable time in a non-int type. The new util function is currently unused, but new code should it where possible.

ACKs for commit fa0136:
  promag:
    utACK fa013664.

Tree-SHA512: efab9c463f079fd8fd3030c479637c7b1e8be567a881234bd0f555c8f87e518e3b43ef2466128103db8fc40295aaf24e87ad76d91f338c631246fc703477e95c
2020-04-08 14:50:07 +02:00
Wladimir J. van der Laan
0160203306
Merge #11435: build: Make "make clean" remove all files created when running "make check"
f35d033 build: Make "make clean" remove all files created when running "make check" (practicalswift)

Pull request description:

  Make `make clean` remove all files created when running `make check`. More specifically: remove also `obj/build.h` and `bench/data/block413567.raw.h` as part of `make clean`.

  Before this patch:

  ```bash
  $ git clone https://github.com/bitcoin/bitcoin.git
  $ cd bitcoin/
  $ ./autogen.sh
  $ ./configure
  $ cp -r ../bitcoin ../bitcoin-before-make
  $ make check
  $ make clean
  $ cp -r ../bitcoin ../bitcoin-after-make-and-make-clean
  $ cd ..
  $ diff -rq bitcoin-before-make/ bitcoin-after-make-and-make-clean/ | grep -E "^Only in bitcoin-after-make-and-make-clean/" | grep -v dirstamp
  Only in bitcoin-after-make-and-make-clean/src/bench/data: block413567.raw.h
  Only in bitcoin-after-make-and-make-clean/src/obj: build.h
  $
  ```

  After this patch:

  ```bash
  $ git clone https://github.com/bitcoin/bitcoin.git
  $ cd bitcoin/
  $ ./autogen.sh
  $ ./configure
  $ cp -r ../bitcoin ../bitcoin-before-make
  $ make check
  $ make clean
  $ cp -r ../bitcoin ../bitcoin-after-make-and-make-clean
  $ cd ..
  $ diff -rq bitcoin-before-make/ bitcoin-after-make-and-make-clean/ | grep -E "^Only in bitcoin-after-make-and-make-clean/" | grep -v dirstamp
  $
  ```

Tree-SHA512: 953e8423485ffd415f0ade6abe0b4c407454f67c332140ef019d89db425bb4a831327b3f634b8d69b17325dcfc6e3ac72dc2ba1ce5462158eecc3c05645e93ba
2020-01-22 09:11:34 -06:00
UdjinM6
33a9f46c08
Merge pull request #3133 from codablock/pr_backport_sha256_stuff
Backport sha256 optimizations (sse41, avx2, shani)
2019-10-03 13:46:26 +03:00
Wladimir J. van der Laan
595826ad63 Merge #12549: Make prevector::resize() and other prevector operations much faster
5aad635 Use memset() to optimize prevector::resize() (Evan Klitzke)
e46be25 Reduce redundant code of prevector and speed it up (Akio Nakamura)
f0e7aa7 Add new prevector benchmarks. (Evan Klitzke)

Pull request description:

  This branch optimizes various `prevector` operations, especially resizing vectors. While profiling the `loadblk` thread I noticed that a lot of time was being spent in `prevector::resize()` which led to this work. I have some data here indicating that it takes up **37%** of the time in `ReadBlockFromDisk()`: https://monad.io/readblockfromdisk.svg

  This branch improves things significantly. For trivial types, the new results for the prevector benchmark are:

   * `PrevectorClearTrivial` which tests `prevector::clear()` becomes 24.6x faster
   * `PrevectorDestructorTrivial` which tests `prevector::~prevector()` becomes 20.5x faster
   * `PrevectorResizeTrivial` which tests `prevector::resize()` becomes 20.3x faster

  Note that in practice it looks like the prevector is only used to contain `unsigned char` types, which is a trivial type. The benchmarks are testing a bit of an extreme case, but the changes here are motivated by the profiling data for `ReadBlockFromDisk()` I linked to above.

  The pull request here consists of a series of three commits:
   * The first adds new benchmarks but does not change the prevector code.
   * The second is from @AkioNak , and merges some prevector optimizations he submitted in #11988
   * The third optimizes `prevector::resize()` to use `memset()` when the prevector contains trivially constructible types

Tree-SHA512: 28f7cbb91a19f9f43b6a5942781d7eb2e3197389186b666f086b69df12bee37773140f765426d715bfb8ebff79cb27a5f1206d0325b54b4aa65598b50fb18368
2019-10-02 15:25:27 +02:00
Wladimir J. van der Laan
adfd2e1a83 Merge #13408: crypto: cleanup sha256 build
f68049dd879c216d1e98b6635eec488f8e936ed4 crypto: cleanup sha256 build (Cory Fields)

Pull request description:

  Requested by @sipa in #13386.

  Rather than appending all possible cpu variants to all targets, create a convenience variable that encompasses all.

Tree-SHA512: 8e9ab2185515672b79bb7925afa4f3fbfe921bfcbe61456833d15457de4feba95290de17514344ce42ee81cc38b252476cd0c29432ac48c737c2225ed515a4bd
2019-10-01 23:20:06 +02:00
Wladimir J. van der Laan
5a23934df1 Merge #13191: Specialized double-SHA256 with 64 byte inputs with SSE4.1 and AVX2
4defdfab94504018f822dc34a313ad26cedc8255 [MOVEONLY] Move unused Merkle branch code to tests (Pieter Wuille)
4437d6e1f3107a20a8c7b66be8b4b972a82e3b28 8-way AVX2 implementation for double SHA256 on 64-byte inputs (Pieter Wuille)
230294bf5fdeba7213471cd0b795fb7aa36e5717 4-way SSE4.1 implementation for double SHA256 on 64-byte inputs (Pieter Wuille)
1f0e7ca09c9d7c5787c218156fa5096a1bdf2ea8 Use SHA256D64 in Merkle root computation (Pieter Wuille)
d0c96328833127284574bfef26f96aa2e4afc91a Specialized double sha256 for 64 byte inputs (Pieter Wuille)
57f34630fb6c3e218bd19535ac607008cb894173 Refactor SHA256 code (Pieter Wuille)
0df017889b4f61860092e1d54e271092cce55f62 Benchmark Merkle root computation (Pieter Wuille)

Pull request description:

  This introduces a framework for specialized double-SHA256 with 64 byte inputs. 4 different implementations are provided:
  * Generic C++ (reusing the normal SHA256 code)
  * Specialized C++ for 64-byte inputs, but no special instructions
  * 4-way using SSE4.1 intrinsics
  * 8-way using AVX2 intrinsics

  On my own system (AVX2 capable), I get these benchmarks for computing the Merkle root of 9001 leaves (supported lengths / special instructions / parallellism):
  * 7.2 ms with varsize/naive/1way (master, non-SSE4 hardware)
  * 5.8 ms with size64/naive/1way (this PR, non-SSE4 capable systems)
  * 4.8 ms with varsize/SSE4/1way (master, SSE4 hardware)
  * 2.9 ms with size64/SSE4/4way (this PR, SSE4 hardware)
  * 1.1 ms with size64/AVX2/8way (this PR, AVX2 hardware)

Tree-SHA512: efa32d48b32820d9ce788ead4eb583949265be8c2e5f538c94bc914e92d131a57f8c1ee26c6f998e81fb0e30675d4e2eddc3360bcf632676249036018cff343e
2019-10-01 23:20:06 +02:00
Wladimir J. van der Laan
0840ce3a92
Merge #15649: Add ChaCha20Poly1305@Bitcoin AEAD
bb326add9f38f2a8e5ce5ee29d98ce08038200d8 Add ChaCha20Poly1305@Bitcoin AEAD benchmark (Jonas Schnelli)
99aea045d688059caf89c0e485fa427bd28eddd8 Add ChaCha20Poly1305@Bitcoin tests (Jonas Schnelli)
af5d1b5f4a7b56628a76af21284c258d845894f0 Add ChaCha20Poly1305@Bitcoin AEAD implementation (Jonas Schnelli)

Pull request description:

  This adds a new AEAD (authenticated encryption with additional data) construct optimised for small messages (like used in Bitcoins p2p network).

  Includes: #15519, #15512 (please review those first).

  The construct is specified here.
  https://gist.github.com/jonasschnelli/c530ea8421b8d0e80c51486325587c52#ChaCha20Poly1305Bitcoin_Cipher_Suite

  This aims for being used in v2 peer-to-peer messages.

ACKs for top commit:
  laanwj:
    code review ACK bb326add9f38f2a8e5ce5ee29d98ce08038200d8

Tree-SHA512: 15bcb86c510fce7abb7a73536ff2ae89893b24646bf108c6cf18f064d672dbbbea8b1dd0868849fdac0c6854e498f1345d01dab56d1c92031afd728302234686

Add new line
2019-07-23 09:14:30 -05:00
Wladimir J. van der Laan
4493671b87
Merge #15519: Add Poly1305 implementation
e9d5e975612e828ec44f9247b4c5c08f0268d360 Poly1305: tolerate the intentional unsigned wraparound in poly1305.cpp (Jonas Schnelli)
b34bf302f26c7cede47cc20b3bdfb613c51ab67e Add Poly1305 bench (Jonas Schnelli)
03be7f48fad10aa8da3291c28a185ed750193c7b Add Poly1305 implementation (Jonas Schnelli)

Pull request description:

  This adds a currently unused Poly1305 implementation including test vectors from RFC7539.

  Required for BIP151 (and related to #15512).

Tree-SHA512: f8c1ad2f686b980a7498ca50c517e2348ac7b1fe550565156f6c2b20faf764978e4fa6b5b1c3777a16e7a12e2eca3fb57a59be9c788b00d4358ee80f2959edb1
2019-07-23 09:14:28 -05:00
Jonas Schnelli
21ace66291
Merge #15512: Add ChaCha20 encryption option (XOR)
2dfe27517 Add ChaCha20 bench (Jonas Schnelli)
2bc2b8b49 Add ChaCha20 encryption option (XOR) (Jonas Schnelli)

Pull request description:

  The current ChaCha20 implementation does not support message encryption (it can only output the keystream which is sufficient for the RNG).

  This PR adds the actual XORing of the `plaintext` with the `keystream` in order to return the desired `ciphertext`.

  Required for v2 message transport protocol.

ACKs for commit 2dfe27:
  jnewbery:
    Looks good. utACK 2dfe2751713c814aea53b5a7563eb74ad1baea00.
  jnewbery:
    utACK 2dfe2751713c814aea53b5a7563eb74ad1baea00
  sipa:
    utACK 2dfe2751713c814aea53b5a7563eb74ad1baea00
  ryanofsky:
    utACK 2dfe2751713c814aea53b5a7563eb74ad1baea00. Changes since last review are just renaming the Crypt method, adding comments, and simplifying the benchmark.

Tree-SHA512: 84bb234da2ca9fdc44bc29a786d9dd215520f81245270c1aef801ef66b6091b7793e2eb38ad6dbb084925245065c5dce9e5582f2d0fa220ab3e182d43412d5b5
2019-07-23 09:14:28 -05:00