Commit graph

25229 commits

Author SHA1 Message Date
MarcoFalke
fa5288cf5c
contrib: Fixup valgrind suppressions file 2020-08-05 16:43:30 +02:00
MarcoFalke
65e4ecabd5
Merge #19654: lint: Don't use TRAVIS_COMMIT_RANGE in commit message linter
72351784b3 lint: Remove travis env var from commit linter (Fabian Jahr)

Pull request description:

  #19439 was recently merged and seemed to work fine but I now noticed strange behavior when it was running in Travis, which I could not reproduce locally. It turns out `TRAVIS_COMMIT_RANGE` which is used in Travis to get the commits for the linter, uses all the commits that were in a push, which includes all rebase commits for example. This means that the linter can fail on a commit that the developer has never even seen before, which can be very confusing. See an example here which caused me to look into this: https://travis-ci.org/github/bitcoin/bitcoin/jobs/714296381 The commit that is reported as failing in my PR is not part of my PR.

  I think we rather want to use something like `git merge-base` to get the commit range by default and in Travis. I am leaving the env variable functionality in place with a different name but this is not a variable that can be expected to be present in the CI environments so the `merge-base` range should be used there by default.

ACKs for top commit:
  hebasto:
    ACK 72351784b3, I have reviewed the code and it looks OK, I agree it can be merged.

Tree-SHA512: afb27bb386855cb8d5cf84fd3a6c11ef1160b25af6175ed0aa146bf04b9a26eb77298df70df0a855f8c46f19f08b3f62c49872c12974fcfa5526a15ee05b3c10
2020-08-05 10:45:33 +02:00
MarcoFalke
0f16212c59
Merge #19340: Preserve the LockData initial state if "potential deadlock detected" exception thrown
63e9e40b73 test: Add LockStackEmpty() (Hennadii Stepanov)
42b2a95373 test: Repeat deadlock tests (Hennadii Stepanov)
1f96be25b0 Preserve initial state if push_lock() throws exception (Hennadii Stepanov)

Pull request description:

  On master (e3fa3c7d67) if the `push_lock()` throws the "potential deadlock detected" exception (via the `potential_deadlock_detected()` call), the `LockData` instance internal state differs from one when the `push_lock()` was called. This non-well behaviour makes (at least) testing brittle.

  This PR preserves the `LockData` instance initial state if `push_lock()` throws an exception, and improves the `sync_tests` unit test.

ACKs for top commit:
  MarcoFalke:
    re-ACK 63e9e40b73
  vasild:
    ACK 63e9e40

Tree-SHA512: 7679182154ce5f079b44b790faf76eb5f553328dea70a326ff6b600db70e2f9ae015a33a104ca070cb660318280cb79b6b42e37ea5166f26f9e627ba721fcdec
2020-08-04 17:00:15 +02:00
MarcoFalke
3c93623be2
Merge #19489: test: Fail wait_until early if connection is lost
faa9a74c9e test: Fail wait_until early if connection is lost (MarcoFalke)

Pull request description:

  Calling `minonode.wait_until` needs a connection to make progress (e.g. waiting for an inv), unless the mininode waits for the initial connection or for a disconnection. So for test development and failure debugging, fail early in all `wait_until`, unless opted out.

ACKs for top commit:
  jnewbery:
    Code review ACK faa9a74c9e.

Tree-SHA512: 4be850b96e23b87bc2ff42c028a5045d6f5cdbc9482ce6a6ba01cc5eb26710dab9e2ed547c363aac4bd5825151ee9996fb797261420b631bceeddbfa698d1dec
2020-08-04 11:21:13 +02:00
Fabian Jahr
72351784b3
lint: Remove travis env var from commit linter 2020-08-04 10:48:56 +02:00
fanquake
bb2a9f9c8c
Merge #19634: rpc: Document getwalletinfo's unlocked_until field as optional
f916847d2b rpc: Document getwalletinfo's unlocked_until field as optional (Justin Moon)

Pull request description:

  The `getwalletinfo` RPC command's `unlocked_until` field is [optional in the code](f916847d2b/src/wallet/rpcwallet.cpp (L2397)), but wasn't marked as optional in the docs.

ACKs for top commit:
  theStack:
    ACK f916847d2b
  achow101:
    ACK f916847d2b
  kristapsk:
    ACK f916847d2b

Tree-SHA512: 8d82f0992fdaf8160000acf4a6e7e7f9ff289a90a983be2e078cf754f4b03601637e5f405afa66bd55adef9b347fa5eac5cc1822033b2ac08c587609cf3dfe0f
2020-08-04 09:14:45 +08:00
Wladimir J. van der Laan
34eb236258
Merge #19326: Simplify hash.h interface using Spans
77c507358b Make Hash[160] consume range-like objects (Pieter Wuille)
02c4cc5c5d Make CHash256/CHash160 output to Span (Pieter Wuille)
0ef97b1b10 Make MurmurHash3 consume Spans (Pieter Wuille)
e549bf8a9a Make CHash256 and CHash160 consume Spans (Pieter Wuille)
2a2182c387 Make script/standard's BaseHash Span-convertible (Pieter Wuille)
e63dcc3a67 Add MakeUCharSpan, to help constructing Span<[const] unsigned char> (Pieter Wuille)
567825049f Make uint256 Span-convertible by adding ::data() (Pieter Wuille)
131a2f0337 scripted-diff: rename base_blob::data to m_data (Pieter Wuille)

Pull request description:

  This makes use of the implicit constructions and conversions to Span introduced in #18468 to simplify the hash.h interface:

  * All functions that take a pointer and a length are changed to take a Span instead.
  * The Hash() and Hash160() functions are changed to take in "range" objects instead of begin/end iterators.

ACKs for top commit:
  laanwj:
    re-ACK 77c507358b
  jonatack:
    Code review re-ACK 77c5073 per `git range-diff 14ceddd 49fc016 77c5073`

Tree-SHA512: 9ec929891b1ddcf30eb14b946ee1bf142eca1442b9de0067ad6a3c181e0c7ea0c99c0e291e7f6e7a18bd7bdf78fe94ee3d5de66e167401674caf91e026269771
2020-08-03 17:27:49 +02:00
Wladimir J. van der Laan
14ceddd290
Merge #18991: Cache responses to GETADDR to prevent topology leaks
3bd67ba5a4 Test addr response caching (Gleb Naumenko)
cf1569e074 Add addr permission flag enabling non-cached addr sharing (Gleb Naumenko)
acd6135b43 Cache responses to addr requests (Gleb Naumenko)
7cc0e8101f Remove useless 2500 limit on AddrMan queries (Gleb Naumenko)
ded742bc5b Move filtering banned addrs inside GetAddresses() (Gleb Naumenko)

Pull request description:

  This is a very simple code change with a big p2p privacy benefit.

  It’s currently trivial to scrape any reachable node’s AddrMan (a database of all nodes known to them along with the timestamps).
  We do have a limit of one GETADDR per connection, but a spy can disconnect and reconnect even from the same IP, and send GETADDR again and again.

  Since we respond with 1,000 random records at most, depending on the AddrMan size it takes probably up to 100 requests for an spy to make sure they scraped (almost) everything.
  I even have a script for that. It is totally doable within couple minutes.

  Then, with some extra protocol knowledge a spy can infer the direct peers of the victim, and other topological stuff.

  I suggest to cache responses to GETADDR on a daily basis, so that an attacker gets at most 1,000 records per day, and can’t track the changes in real time. I will be following up with more improvements to addr relay privacy, but this one alone is a very effective. And simple!

  I doubt any of the real software does *reconnect to get new addrs from a given peer*, so we shouldn’t be cutting anyone.
  I also believe it doesn’t have any negative implications on the overall topology quality. And the records being “outdated” for at most a day doesn’t break any honest assumptions either.

ACKs for top commit:
  jnewbery:
    reACK 3bd67ba5a4
  promag:
    Code review ACK 3bd67ba5a4.
  ariard:
    Code Review ACK 3bd67ba

Tree-SHA512: dfa5d03205c2424e40a3f8a41af9306227e1ca18beead3b3dda44aa2a082175bb1c6d929dbc7ea8e48e01aed0d50f0d54491caa1147471a2b72a46c3ca06b66f
2020-08-03 14:48:52 +02:00
Hennadii Stepanov
63e9e40b73
test: Add LockStackEmpty() 2020-08-02 16:42:39 +03:00
Hennadii Stepanov
42b2a95373
test: Repeat deadlock tests 2020-08-02 16:42:39 +03:00
Hennadii Stepanov
1f96be25b0
Preserve initial state if push_lock() throws exception 2020-08-02 16:42:33 +03:00
MarcoFalke
a78742830a
Merge #19639: doc: Remove Reference Links #19582
334de75885 scripted-diff: Remove Reference Links (Robert)

Pull request description:

  Removed all reference links.
  Found this issue from #19582.
  The decision to remove links instead of update them was made in #19584
  The author of that PR was slow to resolve his commit to use scripted diff so I made this PR instead.

ACKs for top commit:
  laanwj:
    ACK 334de75885
  MarcoFalke:
    ACK 334de75885

Tree-SHA512: a337116379912b27974867bd86ec7799a1d41d67b51771885467fbe1be003b415cb37ce8e521568bf3eae190ab2f6af0d6e29fd3ea25f2689b8fb31def8fec96
2020-08-02 12:42:36 +02:00
MarcoFalke
8443fb11ad
Merge #19637: doc: Add historical release notes for 0.20.1
05e2740d92 doc: Add historical release notes for 0.20.1 (Wladimir J. van der Laan)

Pull request description:

ACKs for top commit:
  MarcoFalke:
    ACK 05e2740d92

Tree-SHA512: 8f33403c51bcbaf97410642878bbc5ee4cbced2e079a61362a69c7eb9d682cf8d3d6ce16fe9aa99c2c89f21a57910032219312403b16d322d403b029f39c62ff
2020-08-02 09:50:22 +02:00
Robert
334de75885 scripted-diff: Remove Reference Links
-BEGIN VERIFY SCRIPT-
sed -i '/https:\/\/bitcoin.org\/en\/developer-reference/d' ./src/protocol.h
-END VERIFY SCRIPT-
2020-08-01 23:42:07 -04:00
Wladimir J. van der Laan
05e2740d92 doc: Add historical release notes for 0.20.1 2020-08-01 14:17:14 +02:00
Justin Moon
f916847d2b rpc: Document getwalletinfo's unlocked_until field as optional 2020-07-31 12:27:48 -05:00
fanquake
f7c73b03d9
Merge #19569: Enable fetching of orphan parents from wtxid peers
10b7a6d532 refactor: make txmempool interface use GenTxid (Pieter Wuille)
5c124e1740 refactor: make FindTxForGetData use GenTxid (Pieter Wuille)
a2bfac8935 refactor: use GenTxid in tx request functions (Pieter Wuille)
e65d115b72 test: request parents of orphan from wtxid relay peer (Anthony Towns)
900d7f6c07 p2p: enable fetching of orphans from wtxid peers (Pieter Wuille)
9efd86a908 refactor: add GenTxid (=txid or wtxid) type and use it for tx request logic (Pieter Wuille)
d362f19355 doc: list support for BIP 339 in doc/bips.md (Pieter Wuille)

Pull request description:

  This is based on https://github.com/bitcoin/bitcoin/pull/18044#discussion_r450687076.

  A new type `GenTxid` is added to protocol.h, which represents a tagged txid-or-wtxid. The tx request logic is updated to use these instead of uint256s, permitting per-announcement distinguishing of txid/wtxid (instead of assuming that everything we want to request from a wtxid peer is wtx). Then the restriction of orphan-parent requesting to non-wtxid peers is lifted.

  Also document BIP339 in doc/bips.md.

ACKs for top commit:
  jnewbery:
    Code review ACK 10b7a6d532
  jonatack:
    ACK 10b7a6d532
  ajtowns:
    ACK 10b7a6d532 -- code review. Using gtxid to replace the is_txid_or_wtxid flag for the mempool functions is nice.
  naumenkogs:
    utACK 10b7a6d

Tree-SHA512: d518d13ffd71f8d2b3c175dc905362a7259689e6022a97a0b4f14f1f9fdd87475cf5af70cb12338d1e5d31b52c12e4faaea436114056a2ae9669cb506240758b
2020-07-31 19:52:18 +08:00
MarcoFalke
a63a26f042
Merge #19585: rpc: RPCResult Type of MempoolEntryDescription should be OBJ.
ae4958be95 rpc: RPCResult Type of MempoolEntryDescription should be OBJ. If multiple entries are possible, wrapping Type should be OBJ_DYN. fixes #19579 (Chris L)

Pull request description:

  If multiple entries are possible, wrapping Type should be OBJ_DYN.

  fixes #19579

Top commit has no ACKs.

Tree-SHA512: 59cf9f6e9729a69a867e924d8306e0cd6b70a3d702fc5a4111345874bb1224ee51ac3f70cea61b25cfe6bde7f65cb02528d52acc20dda4eda692eddf34f217e8
2020-07-31 07:52:40 +02:00
fanquake
a4a279b4f3
Merge #19617: doc: Clang 8 or later is required with FORCE_USE_SYSTEM_CLANG
e60ef21b8a doc: Clang 8 or later is required with FORCE_USE_SYSTEM_CLANG (fanquake)

Pull request description:

  The usage of pragmas within the macOS SDK requires LLVM Clang 8. This is
  the same version as our prebuilt Clang, however the minimum is worth noting
  here as they may diverge and/or expert users might expect they could use an
  earlier version.

  If you compile depends using `FORCE_USE_SYSTEM_CLANG=1` and Clang 7 you'll see output like:
  ```bash
  In file included from kernel/qcore_mac_objc.mm:44:
  In file included from /bitcoin/depends/SDKs/Xcode-11.3.1-11C505-extracted-SDK-with-libcxx-headers/System/Library/Frameworks/AppKit.framework/Headers/NSText.h:9:
  In file included from /bitcoin/depends/SDKs/Xcode-11.3.1-11C505-extracted-SDK-with-libcxx-headers/System/Library/Frameworks/AppKit.framework/Headers/NSView.h:19:
  In file included from /bitcoin/depends/SDKs/Xcode-11.3.1-11C505-extracted-SDK-with-libcxx-headers/System/Library/Frameworks/AppKit.framework/Headers/NSResponder.h:10:
  /bitcoin/depends/SDKs/Xcode-11.3.1-11C505-extracted-SDK-with-libcxx-headers/System/Library/Frameworks/AppKit.framework/Headers/NSEvent.h:19:1: error:
        expected 'push' or 'pop' after '#pragma clang attribute'
  /bitcoin/depends/SDKs/Xcode-11.3.1-11C505-extracted-SDK-with-libcxx-headers/usr/include/os/availability.h:104:273: note: expanded from macro
        'API_UNAVAILABLE_BEGIN'
    ...__API_UNAVAILABLE_BEGIN5, __API_UNAVAILABLE_BEGIN4, __API_UNAVAILABLE_BEGIN3, __API_UNAVAILABLE_BEGIN2, __API_UNAVAILABLE_BEGIN1, 0)(__VA_A...
                                                                                                               ^
  fatal error: too many errors emitted, stopping now [-ferror-limit=]
  20 errors generated.
  ```

  I've got a [godbolt here](https://godbolt.org/z/j6r987) that contains a demo of the issue (based off the macOS SDK). It will compile with Clang 8 but not with Clang 7.

ACKs for top commit:
  laanwj:
    ACK e60ef21b8a

Tree-SHA512: affc082a4b28d9cd102a844e10f63f55f0f20a9f840e5d8037a41470ad1ea83edc3075ce262b1d618c59c9b75445e52ddd9ba9f84c5ac3da9ce20681473c47b1
2020-07-31 08:52:03 +08:00
Pieter Wuille
77c507358b Make Hash[160] consume range-like objects 2020-07-30 13:57:54 -07:00
Pieter Wuille
02c4cc5c5d Make CHash256/CHash160 output to Span 2020-07-30 13:57:54 -07:00
Pieter Wuille
0ef97b1b10 Make MurmurHash3 consume Spans 2020-07-30 13:57:54 -07:00
Pieter Wuille
e549bf8a9a Make CHash256 and CHash160 consume Spans 2020-07-30 13:57:53 -07:00
Pieter Wuille
2a2182c387 Make script/standard's BaseHash Span-convertible 2020-07-30 13:57:09 -07:00
Pieter Wuille
e63dcc3a67 Add MakeUCharSpan, to help constructing Span<[const] unsigned char>
Based on a suggestion by Russell Yanofsky.
2020-07-30 13:57:09 -07:00
Pieter Wuille
567825049f Make uint256 Span-convertible by adding ::data() 2020-07-30 13:57:09 -07:00
Pieter Wuille
131a2f0337 scripted-diff: rename base_blob::data to m_data
This is in preparation for exposing a ::data member function.

-BEGIN VERIFY SCRIPT-
sed -i "s/\([^.]\|other.\)data/\1m_data/g" src/uint256.h src/uint256.cpp
-END VERIFY SCRIPT-
2020-07-30 13:57:09 -07:00
Pieter Wuille
10b7a6d532 refactor: make txmempool interface use GenTxid 2020-07-30 13:45:03 -07:00
Pieter Wuille
5c124e1740 refactor: make FindTxForGetData use GenTxid 2020-07-30 13:45:02 -07:00
Pieter Wuille
a2bfac8935 refactor: use GenTxid in tx request functions 2020-07-30 13:45:02 -07:00
Anthony Towns
e65d115b72 test: request parents of orphan from wtxid relay peer 2020-07-30 13:45:02 -07:00
Pieter Wuille
900d7f6c07 p2p: enable fetching of orphans from wtxid peers
Based on a commit by Anthony Towns.
2020-07-30 13:45:02 -07:00
Pieter Wuille
9efd86a908 refactor: add GenTxid (=txid or wtxid) type and use it for tx request logic 2020-07-30 13:44:54 -07:00
Pieter Wuille
d362f19355 doc: list support for BIP 339 in doc/bips.md 2020-07-30 12:39:34 -07:00
MarcoFalke
edec7f7c25
Merge #19439: script: Linter to check commit message formatting
284a969cc0 Linter to check commit message formatting (Amir Ghorbanian)

Pull request description:

  Write linter to check that commit messages have a new line before the body or no body at all. fixes issue #19091.

ACKs for top commit:
  troygiorshev:
    ACK 284a969cc0 Reviewed, manually tested. Works great!
  fjahr:
    tested ACK 284a969cc0
  adamjonas:
    utACK 284a969cc0

Tree-SHA512: fa278f090780b54e4fa6e2967a62b4c1a4da55d112ec1ad6dd7e1181ac490c5c1af0165524b5781b463fdd6d0f79fd3d95b5160184e6eca432ccff1189f77390
2020-07-30 17:32:37 +02:00
MarcoFalke
ad2952d17a
Merge #19604: Pass mempool pointer to UnloadBlockIndex/GetCoinsCacheSizeState
fae8c28dae Pass mempool pointer to GetCoinsCacheSizeState (MarcoFalke)
fac674db20 Pass mempool pointer to UnloadBlockIndex (MarcoFalke)
faec851b6e test: Simplify cs_main locks (MarcoFalke)

Pull request description:

  Split out from #19556

  Instead of relying on the implicit mempool global, pass a mempool pointer (which can be `0`). This helps with testing, code clarity and unlocks the features described in #19556.

ACKs for top commit:
  jnewbery:
    code review ACK fae8c28dae
  fjahr:
    Code review ACK fae8c28dae
  darosior:
    Tested ACK fae8c28dae
  jamesob:
    ACK fae8c28dae ([`jamesob/ackr/19604.1.MarcoFalke.pass_mempool_pointer_to`](https://github.com/jamesob/bitcoin/tree/ackr/19604.1.MarcoFalke.pass_mempool_pointer_to))

Tree-SHA512: fa687518c8cda4a095bdbdfe56e01fae2fb16c13d51efbb1312cd6dc007611fc47f53f475602e4a843e3973c9410e6af5a81d6847bd2399f8262ca7205975728
2020-07-30 17:30:52 +02:00
MarcoFalke
62d137ac3b
Merge #19561: refactor: Pass ArgsManager into functions that register args
8ed9002cd1 refactor: use local argsmanager in CRegTestParams (Ivan Metlushko)
9b20f66828 scripted-diff: Replace gArgs with local argsman (Ivan Metlushko)
a316e9ce26 refactor: add unused ArgsManager to replace gArgs (Ivan Metlushko)

Pull request description:

  Rationale: reduce use of gArgs to decouple code and simplify future maintenance and easier unit testing.

  This PR is continuation of work started in  #18926 and #18662
  It covers only places that register args in ArgsManager with `AddArgs()` or `AddHiddenArgs()`.

  Closes #19511

ACKs for top commit:
  MarcoFalke:
    ACK 8ed9002cd1 👛

Tree-SHA512: 7e6ba8e8357a48833c71e9c3942a769acb3d93bdcc6748a8ef2b7c4461a2499419b60896abf1d8b6bf8e88ee2590284cdd5da64220243ac22375300bcb8fe3e8
2020-07-30 17:08:46 +02:00
MarcoFalke
37b765b962
Merge #19102: wallet: Introduce and use DummyDatabase instead of dummy BerkeleyDatabase
0fcff547d5 walletdb: Ensure that having no database handle is a failure (Andrew Chow)
da039d2a91 Remove BDB dummy databases (Andrew Chow)
0103d6434e Introduce DummyDatabase and use it in the tests (Andrew Chow)

Pull request description:

  In the unit tests, we use a dummy `WalletDatabase` which does nothing and always returns true. This is currently implemented by creating a `BerkeleyDatabase` in dummy mode. This PR instead adds a `DummyDatabase` class which does nothing and never fails for use in the tests. `CreateDummyWalletDatabase` is changed to return this `DummyDatabase` and `BerkeleyDatabase` is cleaned up to remove all of the checks for `IsDummy`.

  Based on `WalletDatabase` abstract class introduced in #19334

ACKs for top commit:
  instagibbs:
    utACK 0fcff547d5
  MarcoFalke:
    crACK 0fcff547d5 🚈

Tree-SHA512: 05fbf32e078753e9a55a05f4c080b6d365b909a2a3a8e571b7e64b59ebbe53da49394f70419cc793192ade79f312f5e0422ca7c261ba81bae5912671c5ff6402
2020-07-30 17:01:11 +02:00
Wladimir J. van der Laan
17de75b028
Merge #19590: p2p, refactor: add CInv transaction message helpers; use in net processing
c251d710a4 p2p, refactoring: use CInv helpers in net_processing.cpp (Jon Atack)
4254cd9f8f p2p: add CInv transaction message helper methods (Jon Atack)

Pull request description:

  Following the merge of wtxid relay in #18044, this is the first of three refactoring PRs (this one, #19610, and #19611) with no change in behavior, tightly scoped to ease review, to simplify the net processing code and improve encapsulation:

  - add `CInv` transaction message helper methods, defined in the class

  - use the new helpers in `net_processing.cpp` to simplify the code and improve encapsulation

  Test coverage is provided by the functional p2p tests, notably (from seeing which tests failed when breaking things to test coverage) `p2p_segwit`, `p2p_tx_download`, `p2p_feefilter`, and `p2p_permissions`.

ACKs for top commit:
  fjahr:
    Code review ACK c251d710a4
  laanwj:
    Code review ACK c251d710a4
  vasild:
    ACK c251d71
  theStack:
    Code-Review ACK c251d710a4
  hebasto:
    ACK c251d710a4, I have reviewed the code and it looks OK, I agree it can be merged.

Tree-SHA512: ead034b3c9e438909b4c5010c570d7930e69063c114290b051b7cebfd9bd5b19f573218bebe8a521256d32e830797f997adad3d85b4539c64ac5762b698e656d
2020-07-30 16:18:06 +02:00
Wladimir J. van der Laan
4ebe2f6e75
Merge #18011: Replace current benchmarking framework with nanobench
78c312c983 Replace current benchmarking framework with nanobench (Martin Ankerl)

Pull request description:

  Replace current benchmarking framework with nanobench

  This replaces the current benchmarking framework with nanobench [1], an
  MIT licensed single-header benchmarking library, of which I am the
  autor. This has in my opinion several advantages, especially on Linux:

  * fast: Running all benchmarks takes ~6 seconds instead of 4m13s on
    an Intel i7-8700 CPU @ 3.20GHz.

  * accurate: I ran e.g. the benchmark for SipHash_32b 10 times and
    calculate standard deviation / mean = coefficient of variation:

    * 0.57% CV for old benchmarking framework
    * 0.20% CV for nanobench

    So the benchmark results with nanobench seem to vary less than with
    the old framework.

  * It automatically determines runtime based on clock precision, no need
    to specify number of evaluations.

  * measure instructions, cycles, branches, instructions per cycle,
    branch misses (only Linux, when performance counters are available)

  * output in markdown table format.

  * Warn about unstable environment (frequency scaling, turbo, ...)

  * For better profiling, it is possible to set the environment variable
    NANOBENCH_ENDLESS to force endless running of a particular benchmark
    without the need to recompile. This makes it to e.g. run "perf top"
    and look at hotspots.

  Here is an example copy & pasted from the terminal output:

  |             ns/byte |              byte/s |    err% |        ins/byte |        cyc/byte |    IPC |       bra/byte |   miss% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
  |                2.52 |      396,529,415.94 |    0.6% |           25.42 |            8.02 |  3.169 |           0.06 |    0.0% |      0.03 | `bench/crypto_hash.cpp RIPEMD160`
  |                1.87 |      535,161,444.83 |    0.3% |           21.36 |            5.95 |  3.589 |           0.06 |    0.0% |      0.02 | `bench/crypto_hash.cpp SHA1`
  |                3.22 |      310,344,174.79 |    1.1% |           36.80 |           10.22 |  3.601 |           0.09 |    0.0% |      0.04 | `bench/crypto_hash.cpp SHA256`
  |                2.01 |      496,375,796.23 |    0.0% |           18.72 |            6.43 |  2.911 |           0.01 |    1.0% |      0.00 | `bench/crypto_hash.cpp SHA256D64_1024`
  |                7.23 |      138,263,519.35 |    0.1% |           82.66 |           23.11 |  3.577 |           1.63 |    0.1% |      0.00 | `bench/crypto_hash.cpp SHA256_32b`
  |                3.04 |      328,780,166.40 |    0.3% |           35.82 |            9.69 |  3.696 |           0.03 |    0.0% |      0.03 | `bench/crypto_hash.cpp SHA512`

  [1] https://github.com/martinus/nanobench

ACKs for top commit:
  laanwj:
    ACK 78c312c983

Tree-SHA512: 9e18770b18b6f95a7d0105a4a5497d31cf4eb5efe6574f4482f6f1b4c88d7e0946b9a4a1e9e8e6ecbf41a3f2d7571240677dcb45af29a6f0584e89b25f32e49e
2020-07-30 15:34:17 +02:00
Gleb Naumenko
3bd67ba5a4 Test addr response caching 2020-07-30 14:38:50 +03:00
Gleb Naumenko
cf1569e074 Add addr permission flag enabling non-cached addr sharing 2020-07-30 14:38:50 +03:00
Gleb Naumenko
acd6135b43 Cache responses to addr requests
Prevents a spy from scraping victim's AddrMan by
reconnecting and re-requesting addrs.
2020-07-30 14:38:48 +03:00
MarcoFalke
2a784723f0
Merge #19597: test: test decodepsbt fee calculation (count input value only once per UTXO)
82dee87933 test: test decodepsbt fee calculation (count input value only once per UTXO) (Sebastian Falbesoner)

Pull request description:

  Fixes #19523, adding a simple test to `rpc_psbt.py` that checks that the decodepsbt fee matches the one given by the wallet (`walletcreatefundedpsbt`). This is in particular important for PSBTs with segwit inputs that have both a witness- and a non-witness-UTXO type set.

  Example test run after reverting commit 75122780e2 ("Increment input value sum only once per UTXO in decodepsbt"):

  ```
  $ test/functional/rpc_psbt.py
  2020-07-26T11:31:44.862000Z TestFramework (INFO): Initializing test directory /tmp/bitcoin_func_test__sutcd4y
  20.00007580
  2020-07-26T11:31:47.073000Z TestFramework (ERROR): Assertion failed
  Traceback (most recent call last):
    File "/home/honeybadger/buidl/bitcoin_thestack/test/functional/test_framework/test_framework.py", line 118, in main
      self.run_test()
    File "test/functional/rpc_psbt.py", line 166, in run_test
      assert_equal(decoded['fee'], created_psbt['fee'])
    File "/home/honeybadger/buidl/bitcoin_thestack/test/functional/test_framework/util.py", line 49, in assert_equal
      raise AssertionError("not(%s)" % " == ".join(str(arg) for arg in (thing1, thing2) + args))
  AssertionError: not(20.00007580 == 0.00007580)
  2020-07-26T11:31:47.125000Z TestFramework (INFO): Stopping nodes
  ......
  ```

ACKs for top commit:
  achow101:
    ACK 82dee87933

Tree-SHA512: 296b8a701f851d482ef6200c6cbf0cf0257a79a828ac6dbc39b05d8c2d839c6fdb9d3f5a084015295cfa3eac7c11faa2f2d52e619c11627b04c75150eead8330
2020-07-30 09:46:16 +02:00
MarcoFalke
149eca433d
Merge #19599: test: clean message_count and last_message
2c6a02e024 Clean message_count and last_message (Troy Giorshev)

Pull request description:

  From #19580

  This PR changes comments to clarify the intended usage of `message_count` and `last_message`.  Additionally it changes the only usage of `message_count` to use `last_message` instead, bringing the code into alignment with the intended usage.

  Note: Now `message_count` is completely unused.  However, it is ready to be used (i.e. the supporting code works) and likely will be used in some test in the future.

ACKs for top commit:
  jnewbery:
    utACK 2c6a02e024

Tree-SHA512: 07c7684c9586de4f845e10d7aac36c1aab9fb56b409949c1c70d5ca705bc3971ca7d5943245a0472def4efd7b4e1c5dad2f713db5ead8fca08404daf4891e98b
2020-07-30 09:15:49 +02:00
Andrew Chow
0fcff547d5 walletdb: Ensure that having no database handle is a failure
Previously having no database handle could still be considered a success
when BerkeleyDatabase and BerkeleyBatch were used for dummy database
things. With dedicated DummyDatabase and DummyBatch classes now, these
should fail.
2020-07-29 12:30:24 -04:00
Andrew Chow
da039d2a91 Remove BDB dummy databases 2020-07-29 12:30:23 -04:00
Andrew Chow
0103d6434e Introduce DummyDatabase and use it in the tests 2020-07-29 12:28:30 -04:00
Wladimir J. van der Laan
8db23349fe
Merge #19335: wallet: Cleanup and separate BerkeleyDatabase and BerkeleyBatch
74507ce71e walletdb: Remove BerkeleyBatch friend class from BerkeleyDatabase (Andrew Chow)
00f0041351 No need to check for duplicate fileids in all dbenvs (Andrew Chow)
d86efab370 walletdb: Move Db->open to BerkeleyDatabase::Open (Andrew Chow)
4fe4b3bf1b walletdb: track database file use as m_refcount within BerkeleyDatabase (Andrew Chow)
65fb8807ac Combine BerkeleyEnvironment::Verify into BerkeleyDatabase::Verify (Andrew Chow)

Pull request description:

  `BerkeleyBatch` and `BerkeleyDatabase` are kind of messy. The goal of this is to clean up them up so that they are logically separated.

  `BerkeleyBatch` currently handles the creation of the `BerkeleyDatabase`'s `Db` handle. This is instead moved into `BerkeleyDatabase` and is called by `BerkeleyBatch`.

  Instead of having `BerkeleyEnvironment` track each database's usage, have `BerkeleyDatabase` track this usage itself with the `m_refcount` variable that is present in `WalletDatabase`.

  Lastly, instead of having each `BerkeleyEnvironment` store the fileids of the databases open in it, have a global `g_fileids` to track those fileids. We were already checking fileid uniqueness globally (by checking the fileids in every environment when opening a database) so it's cleaner to do this with a global variable.

  All of these changes allow us to make `BerkeleyBatch` and `BerkeleyDatabase` no longer be friend classes.

  The diff of this PR is currently the same as in ##18971

  Requires #19334

ACKs for top commit:
  laanwj:
    Code review ACK 74507ce71e
  ryanofsky:
    Code review ACK 74507ce71e. No changes since last review other than rebase

Tree-SHA512: 845d84ee1a470e2bf5d2e2e3d7738183d8ce43ddd06a0bbd57edecf5779b2f55d70728b1b57f5daab0f078650a8d60c3e19dc30b75b36e7aa952ce268399d5f6
2020-07-29 18:24:16 +02:00
Wladimir J. van der Laan
400f45ec9b
Merge #19525: build: add -Wl,-z,separate-code to hardening flags
65d0f1a533 devtools: Add security check for separate_code (Wladimir J. van der Laan)
2e9e6377f1 build: add -Wl,-z,separate-code to hardening flags (fanquake)

Pull request description:

  TLDR: We are generally explicit about the hardening related flags we use,
  rather than letting the distro / toolchain decide via their defaults. This PR
  adds `-z,separate-code` which has been enabled by default for Linux targets
   since binutils 2.31. Ubuntu Bionic (currently used for gitian) ships with
  binutils 2.30, so this will enable the option for those builds.

  This flag was added to binutils/ld in the 2.30 release,
  see commit c11c786f0b45617bb8807ab6a57220d5ff50e414:

  > The new "-z separate-code" option will generate separate code LOAD
  segment which must be in wholly disjoint pages from any other data.

  It was made the default for Linux/x86 targets in the 2.31 release, see commit
  f6aec96dce1ddbd8961a3aa8a2925db2021719bb:

  > This patch adds --enable-separate-code to ld configure to turn on
  -z separate-code by default and enables it by default for Linux/x86.
  This avoids mixing code pages with data to improve cache performance
  as well as security.

  > To reduce x86-64 executable and shared object sizes, the maximum page
  size is reduced from 2MB to 4KB when -z separate-code is turned on by
  default.  Note: -z max-page-size= can be used to set the maximum page
  size.

  > We compared SPEC CPU 2017 performance before and after this change on
  Skylake server.  There are no any significant performance changes.
  Everything is mostly below +/-1%.

  Support was also added to LLVMs lld: https://reviews.llvm.org/D64903, however
  there it remains off by default.

  There were concerns about an increase in binary size, however in our case, the
  difference would seem negligible, given we are shipping a
  multi-megabyte binary, which then downloads 100's of GBs of data.

  Also note that most recent versions of distros are shipping a new enough version
  of binutils that this is available and/or already on by default (assuming the distro
  has not turned it off, I haven't checked everywhere):

  CentOS 8: 2.30
  Debian Buster 2.31.1
  Fedora 29: 2.31.1
  FreeBSD: 2.33
  GNU Guix: 2.33 / 2.34
  Ubuntu 18.04: 2.30

  Related threads / discussion:
  https://bugzilla.redhat.com/show_bug.cgi?id=1623218

  The ELF header when building on Debian Buster (where it's already enabled by default in binutils):
  ```bash
  Program Header:
      PHDR off    0x0000000000000040 vaddr 0x0000000000000040 paddr 0x0000000000000040 align 2**3
           filesz 0x00000000000002a0 memsz 0x00000000000002a0 flags r--
    INTERP off    0x00000000000002e0 vaddr 0x00000000000002e0 paddr 0x00000000000002e0 align 2**0
           filesz 0x000000000000001c memsz 0x000000000000001c flags r--
      LOAD off    0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**12
           filesz 0x0000000000038f10 memsz 0x0000000000038f10 flags r--
      LOAD off    0x0000000000039000 vaddr 0x0000000000039000 paddr 0x0000000000039000 align 2**12
           filesz 0x00000000006b9389 memsz 0x00000000006b9389 flags r-x
      LOAD off    0x00000000006f3000 vaddr 0x00000000006f3000 paddr 0x00000000006f3000 align 2**12
           filesz 0x0000000000204847 memsz 0x0000000000204847 flags r--
      LOAD off    0x00000000008f7920 vaddr 0x00000000008f8920 paddr 0x00000000008f8920 align 2**12
           filesz 0x00000000000183e0 memsz 0x0000000000022fd0 flags rw-
   DYNAMIC off    0x000000000090adb0 vaddr 0x000000000090bdb0 paddr 0x000000000090bdb0 align 2**3
           filesz 0x0000000000000240 memsz 0x0000000000000240 flags rw-
  ```
   vs when opting out using `-Wl,-z,noseparate-code`:
  ```bash
  Program Header:
      PHDR off    0x0000000000000040 vaddr 0x0000000000000040 paddr 0x0000000000000040 align 2**3
           filesz 0x0000000000000230 memsz 0x0000000000000230 flags r--
    INTERP off    0x0000000000000270 vaddr 0x0000000000000270 paddr 0x0000000000000270 align 2**0
           filesz 0x000000000000001c memsz 0x000000000000001c flags r--
      LOAD off    0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**12
           filesz 0x00000000008f6a87 memsz 0x00000000008f6a87 flags r-x
      LOAD off    0x00000000008f7920 vaddr 0x00000000008f8920 paddr 0x00000000008f8920 align 2**12
           filesz 0x00000000000183e0 memsz 0x0000000000022fd0 flags rw-
   DYNAMIC off    0x000000000090adb0 vaddr 0x000000000090bdb0 paddr 0x000000000090bdb0 align 2**3
           filesz 0x0000000000000240 memsz 0x0000000000000240 flags rw-
  ```

ACKs for top commit:
  laanwj:
    ACK 65d0f1a533

Tree-SHA512: 6e40e434efea8a8e39f6cb244dfd16aaa5a9db5a2ea762a05d1727357b20e33b7e47c1a652ee88490c9d7952a4caa2f992396fb30346239300d37ae123e36d49
2020-07-29 16:52:51 +02:00