Commit graph

25021 commits

Author SHA1 Message Date
MarcoFalke
ead6d686eb
Merge #18912: ci: Run fuzz testing test cases (bitcoin-core/qa-assets) under valgrind to catch memory errors
3f686d1a28 ci: Run fuzz testing test cases (bitcoin-core/qa-assets) under valgrind to catch memory errors (practicalswift)

Pull request description:

  Re-introduce the Travis valgrind fuzzing job which was removed by PR #18899. The removal seems to have been made by accident since the removed job does not appear to be the source of the problem the PR set out to fix.

  ---

  Run fuzz testing [test cases (bitcoin-core/qa-assets)](https://github.com/bitcoin-core/qa-assets) under `valgrind`.

  This would have caught `util: Avoid potential uninitialized read in FormatISO8601DateTime(int64_t) by checking gmtime_s/gmtime_r return value` (#18162) and similar cases.

  This fuzzing job was introduced in #18166.

Top commit has no ACKs.

Tree-SHA512: 6e2681eb0ade6af465c5ea91ac163a337465d2130ec9880ba57a36d9af7c25682734586a32977dc25972d4f78483f339d680ea48c0ae13cf1dfa52b617aae401
2020-06-25 08:58:11 -04:00
MarcoFalke
c9d1040d25
Merge #19237: wallet: Check size after unserializing a pubkey
37ae687f95 Add tests for CPubKey serialization/unserialization (Elichai Turkel)
9b8907fade Check size after Unserializing CPubKey (Elichai Turkel)

Pull request description:

  Found by practicalswift, closes #19235
  Currently all the public API(except the pointer-like API) in CPubKey that sets/constructs a pubkey goes through `CPubKey::Set` which checks if that the length and size match and if not invalidates the key.

  This adds the same check to `CPubKey::Unserialize`, sadly I don't see an easy way to just push this to the existing checks in `CPubKey::Set` but it's only a simple condition.

  The problem with not invalidating is that if you write a pubkey like: `{0x02,0x00}` it will think the actual length is 33(because of `size()`) and will access uninitialized memory if you call any of the functions on CPubKey.

ACKs for top commit:
  practicalswift:
    re-ACK 37ae687f95
  jonatack:
    Code review re-ACK 37ae687 per `git diff eab8ee3 37ae687` only change since last review at eab8ee3 is passing the `pubkey` param by reference to const instead of by value in `src/test/key_tests.cpp::CmpSerializationPubkey`
  MarcoFalke:
    ACK 37ae687f95

Tree-SHA512: 30173755555dfc76d6263fb6a59f41be36049ffae7b4e1b92b922d668f5e5e2331f7374d5fa10d5d59fc53020d2966156905ffcfa8b8129c1f6d0ca062174ff1
2020-06-25 08:07:36 -04:00
Ivan Metlushko
3a7e79478a test: retry when write to a socket fails on macOS
If the socket is tearing down macOS will return EPROTOTYPE instead of EPIPE.
Because python doesn't handle this internally we have to do a workaround and retry the request.
See https://bugs.python.org/issue33450
2020-06-25 17:26:20 +07:00
Hennadii Stepanov
1307686798
refactor: Use Mutex type for g_cs_recent_confirmed_transactions 2020-06-25 10:25:24 +03:00
Luke Dashjr
03e056edcd
depends: Patch libevent build to fix IPv6 -rpcbind on Windows
libevent uses getaddrinfo when available, and falls back to gethostbyname
Windows has both, but gethostbyname only supports IPv4
libevent fails to detect Windows's getaddrinfo due to not including the right headers
This patches libevent's configure script to check it correctly
2020-06-25 10:23:54 +08:00
Andrew Chow
84d295e513 tests: Check that segwit inputs in psbt have both UTXO types 2020-06-24 16:32:20 -04:00
Andrew Chow
4600479058 psbt: always put a non_witness_utxo and don't remove it
Offline signers will always need a non_witness_utxo so make sure it is
there.
2020-06-24 16:32:19 -04:00
Andrew Chow
5279d8bc07 psbt: Allow both non_witness_utxo and witness_utxo 2020-06-24 16:31:42 -04:00
Andrew Chow
72f6bec1da rpc: show both UTXOs in decodepsbt 2020-06-24 16:31:42 -04:00
MarcoFalke
67881de0e3
Merge #19272: net, test: invalid p2p messages and test framework improvements
56010f9256 test: hoist p2p values to test framework constants (Jon Atack)
75447f0893 test: improve msg sends and p2p disconnections in p2p_invalid_messages (Jon Atack)
57960192a5 test: refactor test_large_inv() into 3 tests with common method (Jon Atack)
e2b21d8a59 test: add p2p_invalid_messages logging (Jon Atack)
9fa494dc09 net: update misbehavior logging for oversized messages (Jon Atack)

Pull request description:

  ...seen while reviewing #19264, #19252, #19304 and #19107:

  in `net_processing.cpp`
  - make the debug logging for oversized message size misbehavior the same for `addr`, `getdata`, `headers` and `inv` messages

  in `p2p_invalid_messages`
  - add missing logging
  - improve assertions/message sends, move cleanup disconnections outside the assertion scopes
  - split a slowish 3-part test into 3 order-independent tests
  - add a few p2p constants to the test framework

ACKs for top commit:
  troygiorshev:
    reACK 56010f9256
  MarcoFalke:
    ACK 56010f9256 🎛

Tree-SHA512: db67b70278f8d4c318907e105af54b54eb3afd15500f9aa0c98034f6fd4bd1cf9ad1663037bd9b237ff4890f3059b37291a6498d8d6ae2cc38efb9f045f73310
2020-06-24 15:57:34 -04:00
MarcoFalke
532b134cb0
Merge #19373: refactor: Replace HexStr(o.begin(), o.end()) with HexStr(o)
bd93e32292 refactor: Replace HexStr(o.begin(), o.end()) with HexStr(o) (Wladimir J. van der Laan)

Pull request description:

  HexStr can be called with anything that bas `begin()` and `end()` functions, so clean up the redundant calls.

  (context: I tried to convert `HexStr` to use span, but this turns out to be somewhat more involved than I thought, because of the limitation to pre-c++17 Span lacking iterator-based constructor) . This commit is a first step which stands on its own though)

ACKs for top commit:
  jonatack:
    ACK bd93e32292
  troygiorshev:
    ACK bd93e32292
  MarcoFalke:
    review ACK bd93e32292 🔌

Tree-SHA512: 7e4c9d0259b8d23271d233095f1c51db1ee021e865361d74c05c10dd5129aa6d34a243323e2b4596d648e2d7b25c7ebdee37a3e4f99a27883cb4c3cd26432b08
2020-06-24 14:24:14 -04:00
Wladimir J. van der Laan
bd93e32292 refactor: Replace HexStr(o.begin(), o.end()) with HexStr(o)
HexStr can be called with anything that bas `begin()` and `end()` functions,
so clean up the redundant calls.
2020-06-24 18:41:45 +02:00
MarcoFalke
fa74a54fad
ci: Increase test timeout for sanitizer configs 2020-06-24 09:17:37 -04:00
Wladimir J. van der Laan
205b87d2f6
Merge #19357: doc: add release note for bitcoin-cli -generate
9886c7d98d doc: add release note for bitcoin-cli -generate (Jon Atack)

Pull request description:

  Adds a release note for #19133.

ACKs for top commit:
  laanwj:
    ACK 9886c7d98d

Tree-SHA512: 1354e5db0098447788c9ded6f2cd868fd6ea4a1443c99bec8026881b962c92b7257bfea45757769071605faeb989e9db48eaa2fbe9d273513aa2905ee479a8ec
2020-06-24 14:21:34 +02:00
MarcoFalke
dae1bd61b2
Merge bitcoin-core/gui#11: Remove needless headers from qt/walletview.cpp
4f9d9efb4e qt: Remove needless headers (Hennadii Stepanov)

Pull request description:

  No symbols from the removed headers are used in the `qt/walletview.cpp`.

  This is a small followup of https://github.com/bitcoin/bitcoin/pull/18027.

Top commit has no ACKs.

Tree-SHA512: 986ed5c8f3bac4c0053736ce84d738f8593d3dbf713109af3cb9b7051cd838f23152a39bb3c1e9694a993c4e7accf14e94e5beff5e7881155638cd44fbf7f46f
2020-06-24 08:18:25 -04:00
Hennadii Stepanov
4f9d9efb4e
qt: Remove needless headers 2020-06-24 14:10:01 +03:00
Karl-Johan Alm
25dac9fa65
doc: add release notes for explicit fee estimators and bumpfee change 2020-06-24 16:01:38 +09:00
Karl-Johan Alm
05227a3554
tests for bumpfee / estimate_modes
* invalid parameter tests for bumpfee
* add tests for no conf_target explicit estimate_modes
2020-06-24 16:01:38 +09:00
Karl-Johan Alm
3404c1b753
policy: optional FeeEstimateMode param to CFeeRate::ToString 2020-06-24 16:01:38 +09:00
Karl-Johan Alm
6fcf448430
rpc/wallet: add two explicit modes to estimate_mode 2020-06-24 16:01:37 +09:00
Karl-Johan Alm
b188d80c2d
MOVEONLY: Make FeeEstimateMode available to CFeeRate
Can verify move-only with:

    git log -p -n1 --color-moved

This commit is move-only and doesn't change code or affect behavior.
2020-06-24 15:52:06 +09:00
Karl-Johan Alm
5d1a411eb1
fees: add FeeModes doc helper function 2020-06-24 15:52:05 +09:00
Glenn Willen
8578c6fccd build: Fix search for brew-installed BDB 4 on OS X
On OS X, when searching Homebrew keg-only packages for BDB 4.8, if we find it,
use BDB_CPPFLAGS and BDB_LIBS instead of CFLAGS and LIBS for the result. This
is (1) more correct, and (2) necessary in order to give this location
priority over other directories in the include search path, which may include
system include directories with other versions of BDB.
2020-06-23 22:04:02 -07:00
Ivan Metlushko
8cf9d15b82 test: use pgrep for better compatibility
pidof is not available on BSD system, while pgrep is present on BSD, Linux and macOS
2020-06-24 09:29:50 +07:00
John Newbery
e8a2822119 [net] Don't try to take cs_inventory before deleting CNode
The TRY_LOCK(cs_inventory) in DisconnectNodes() is taken after the CNode
object has been removed from vNodes and when the CNode's nRefCount is
zero.

The only other places that cs_inventory can be taken are:

- In ProcessMessages() or SendMessages(), when the CNode's nRefCount
must be >0 (see ThreadMessageHandler(), where the refcount is
incremented before calling ProcessMessages() and SendMessages()).
- In a ForEachNode() lambda in PeerLogicValidation::UpdatedBlockTip().
ForEachNode() locks cs_vNodes and calls the function on the CNode
objects in vNodes.

Therefore, cs_inventory is never locked by another thread when the
TRY_LOCK(cs_inventory) is reached in DisconnectNodes(). Since the
only purpose of this TRY_LOCK is to ensure that the lock is not
taken by another thread, this always succeeds. Remove the check.
2020-06-23 08:46:05 -04:00
John Newbery
3556227ddd [net] Make cs_inventory a non-recursive mutex
cs_inventory is never taken recursively. Make it a non-recursive mutex.
2020-06-23 08:46:05 -04:00
John Newbery
344e831de5 [net processing] Remove PushBlockInventory and PushBlockHash
PushBlockInventory() and PushBlockHash() are functions that can
be replaced with single-line statements. This also eliminates
the single place that cs_inventory is taken recursively.
2020-06-23 08:46:05 -04:00
practicalswift
870f0cd2a0 build: Add MemorySanitizer (MSan) in Travis to detect use of uninitialized memory 2020-06-23 09:09:30 +00:00
fanquake
80fd474e40
Merge #19240: build: macOS toolchain simplification and bump
adf543d714 darwin: pass mlinker-version so that clang enables new features (Cory Fields)
2418f739f7 macos: Bump to xcode 11.3.1 and 10.15 SDK (Cory Fields)
5c2c835433 depends: bump MacOS toolchain (Cory Fields)
85b5e42088 contrib: macdeploy: Remove historical extraction notes (Carl Dong)
351beb5c9a contrib: macdeploy: Use apple-sdk-tools instead of xar+pbzx (Carl Dong)
fbcfcf6954 native_cctools: Don't use libc++ from pinned clang (Carl Dong)
3381e4a189 Adapt rest of tooling to new SDK naming scheme (Carl Dong)
b3394ab235 contrib: macdeploy: Correctly generate macOS SDK (Carl Dong)

Pull request description:

  This PR achieves 3 main things:
  1. It simplifies the macOS SDK generation by putting the logic inside a (semi-)portable python3 script `gen-sdk`
  2. It transitions us to using `libc++` headers extracted from the `Xcode.app`, which is more correct as those headers better match the `.tbd` library stubs we use from the `MacOSX.sdk` (located under the same `Xcode.app`). Previously, we used `libc++` headers copied from our downloaded, pinned clang (see `native_cctools.mk`).
  3. It bumps the macOS toolchain in a way that fulfills all of the following constraints:
      1. The new SDK should support compiling with C++17 (our current one doesn't)
      2. The new toolchain should not change our minimum supported macOS version (`-mmacosx-version-min`)
      3. The new toolchain should expect to use a version of `cctools` that is supported by https://github.com/tpoechtrager/cctools-port

  For the constraints in (3), you can reference [this chart](https://en.wikipedia.org/wiki/Xcode#Xcode_7.0_-_11.x_(since_Free_On-Device_Development)) to see that the newest toolchain we can use with our `cctools-port` is `11.3.1`, and the rest of the constraints were tested with local builds.

  #### But [the other Wikipedia chart](https://en.wikipedia.org/wiki/Xcode#Xcode_11.x_(since_SwiftUI_framework)) says that the "min macOS to run" for Xcode 11.3.1 is 10.14.4, doesn't that violate constraint (ii)?

  This confused me at first too, but the "min macOS to run" is for the Xcode.app App itself. The SDK still supports 10.12, as evident in a few plist files and as proven through local builds.

  #### Why bundle all of this together in a single PR?

  We need (1) and (2) together, because if we don't, manually adding the `libc++` headers and writing that out in a `README.md` is going to result in a lot of user error, so it's great to have these together to be more correct and also make it easier on the user at the same time.

  We need (3) together with everything else because bumping (or in the case of (1), renaming) the SDK requires some human coordination and may break some builds. And since it's not that complicated a change, it makes sense to do it together with the rest.

ACKs for top commit:
  theuni:
    ACK adf543d714.
  fanquake:
    ACK adf543d714 - I'll take a look at the linker issue.

Tree-SHA512: 3813b69ebfe9610bee14100f26296fb5438d9bf0dd184ea55e6c38f5ebd94f7c171d98b150fc9e52fde626533f347f7ec51a2b72b79859d946284f578c1084a3
2020-06-23 16:14:49 +08:00
Ben Woosley
57b0c0a93a
Drop CADDR_TIME_VERSION checks now that MIN_PEER_PROTO_VERSION is greater 2020-06-23 00:49:50 -07:00
Hennadii Stepanov
92bc268e4a
build: Detect missed pkg-config early 2020-06-23 09:02:11 +03:00
Hennadii Stepanov
1739eb23d8
build: Drop unused use_pkgconfig variable 2020-06-23 09:01:47 +03:00
Hennadii Stepanov
a661449a2e
build: Drop use_pkgconfig check for libmultiprocess check 2020-06-23 09:00:54 +03:00
Jon Atack
9886c7d98d
doc: add release note for bitcoin-cli -generate 2020-06-23 07:09:27 +02:00
Cory Fields
adf543d714
darwin: pass mlinker-version so that clang enables new features
Without this clang fails to add any newly-added linker features.

Removing this in ca5055a5aa was likely a
regression.

See https://github.com/bitcoin/bitcoin/pull/19240#issuecomment-647764049
for more discussion.
2020-06-22 17:00:45 -04:00
Hennadii Stepanov
d906aaa117
qt: Fix regression in TransactionTableModel
Since #17993 a crash is possible on exit.

Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
2020-06-22 23:43:22 +03:00
Andrew Chow
ca24edfbc1 walletdb: Handle cursor internally
Instead of returning a Dbc (BDB cursor object) and having the caller
deal with the cursor, make BerkeleyBatch handle the cursor internally.

This prepares BerkeleyBatch to work with other database systems as Dbc
objects are BDB specific.
2020-06-22 15:36:23 -04:00
Andrew Chow
3a9aba21a4 Split SetWalletFlags into Add/LoadWalletFlags
Remove memonly bool and follow typical Add and Load pattern used
everywhere else.
2020-06-22 14:59:09 -04:00
Duncan Dean
39d526bde4
test: Bump linter versions
Updates Python linters, spellchecking, and ShellCheck versions. The PR links are updated for
the dependency versions in test/README.md. ShellCheck SC2230 removed to align with with new
behaviour in v0.7.1.

Fixes #19346.
2020-06-22 20:15:53 +02:00
Jon Atack
6d35d0d18f
doc: add release note for -getinfo displaying multiwallet balances 2020-06-22 19:26:34 +02:00
Wladimir J. van der Laan
e3fa3c7d67
Merge #19305: doc: add C++17 release note for 0.21.0
f1d21ef1c3 doc: add C++17 release note for 0.21.0 (fanquake)

Pull request description:

  TLDR: Mention that the codebase is now compatible with C++17, and that the
  intention is to require C++17 starting with 0.22.0.

  Following some discussion with Cory/Carl, and in #16684, I think this is the next step in the C++17 migration.

  While #16684 mentions a gitian/Guix release with C++17, it's not yet clear how that would be done. Are we just going to pass `--enable-c++17` in gitian/Guix?. Are we changing our default in configure.ac?

  According to the [last comment](https://github.com/bitcoin/bitcoin/issues/16684#issuecomment-643778757) in #16684, we wouldn't be changing anything in depends:
  > No, everything (including depends) will stay at C++11.

  However I don't think we want to be mixing C++11 built dependencies, with a C++17 built bitcoind, if there is any potential for compatibility issues.

  Instead, I'd suggest we build the 0.21.0 release as C++11, and do a complete switch to C++17 for 0.22.0. Also, if we actually wanted to use C++17 in depends for 0.21.0, we couldn't without breaking C++11 compat (Qt). See below.

  Here is a potential timeline/TODOs for the migration:

  Potential Timeline
  * 17 / 6 / 2020 - Today
  * Some time prior to split-off:
      * Confirm that compiling with C++17 works.
      * Confirm that C++11 compatibility has not been broken.
  * 1 / 11 / 2020
      * [0.21.0 split off happens](https://github.com/bitcoin/bitcoin/issues/18947).
  * 2 / 11 / 2020
      * Merge an "incompatible with C++11" change into master.
      * Switch configure to use C++17 mode by default.
      * Update minimum compiler requirements. At least:
          * Clang 5: https://clang.llvm.org/cxx_status.html#cxx17
          * GCC 7: https://gcc.gnu.org/projects/cxx-status.html#cxx17
              * While GCC has some support from 5, it seems a more complete support landed in GCC 7.
              * https://gcc.gnu.org/gcc-7/changes.html#cxx
      * Switch depends packages to use C++17 where applicable.
      * Bump Qt from 5.9.x (no c++17 mode) to, likely, 5.15.x (LTS).
      * Drop support for macOS < 10.14.x
          * The c++ dylib shipped with macOS [doesn't support c++17, prior to macOS 10.14](https://github.com/bitcoin/bitcoin/issues/16684#issuecomment-643722538).
          * Building Qt 5.12 or 5.15 in C++17 mode will also require a minimum macOS deployment target of 10.14. https://codereview.qt-project.org/c/qt/qtbase/+/283832.
      * Begin merging PRs like #19183 and #19245.
          * I've left some comments in #19183 if the macOS runtime issue interests anyone.
  * 3 / 12 / 2020
      * 0.21.0 released.
      * Built as C++11.
      * Contains warning in release notes that compiling 0.22.0 will require C++17.
  * 3 / 6 / 2021
      * 0.22.0 released.
      * Full of C++17 code.

  One thing worth noting, is that we cannot bump our Qt to a newer LTS for 0.21.0, without breaking C++11 compatibility. Qt 5.12 is not compilable in C++11 mode, as the project has started using C++14 features throughout at least the macOS portions of it's codebase, and seemingly "forgotten" that the release is meant to be C++11 compatible.
  Upstream bug here: https://bugreports.qt.io/browse/QTBUG-77310.
  > Building Qt requires C+11, at a minimum, but in practice we use later features, usually under a feature define, or with a fallback of some kind. On platforms that support > C11, we've (apparently) not considered the fallback necessary, under the assumption C+14 is always available.

ACKs for top commit:
  MarcoFalke:
    ACK f1d21ef1c3 can't hurt to give an advance warning
  Sjors:
    ACK f1d21ef1c3
  laanwj:
    ACK f1d21ef1c3
  theStack:
    ACK f1d21ef1c3

Tree-SHA512: 706baceb07d9584783ba6e437cdf447531c20f586285b9797edc21f3adb1e9d386059d1c543c70eb298d0f8e555dafb6682a55d35c5836979fc12132e8ba06f5
2020-06-22 19:13:22 +02:00
Wladimir J. van der Laan
a6aac20019
Merge #19350: test: Refactor tests using restart_node
20b6e95944 test: refactor functional tests to use restart_node (Christopher Coverdale)

Pull request description:

  fixes #19345

  This PR replaces consecutive calls to `stop_node()` and `start_node()` with `restart_node()` where appropriate in the functional tests.

  The commit messages are repetitive but focused on each file changed with the intention of squashing if applicable.

ACKs for top commit:
  laanwj:
    ACK 20b6e95944

Tree-SHA512: 1cfa1fb8c5f01a7b00fe44e80dbef072147f21e3891098817acd4275b0c5d91dc1c787594209e117edd418f2fa3a7b2dfcbafdf87efc07f740040938d641f3a9
2020-06-22 18:27:28 +02:00
Wladimir J. van der Laan
f591a1a184
Merge #19351: test: add two edge case tests for CSubNet
ccef5d7bf0 test: add two edge case tests for CSubNet (Vasil Dimov)

Pull request description:

  This is chopped off from https://github.com/bitcoin/bitcoin/pull/19031. It is needed because later 19031 modifies the related code and the tests ensure that no surprising changes in behavior sneak in.

ACKs for top commit:
  practicalswift:
    ACK ccef5d7bf0 -- more test coverage is better than less test coverage :)
  laanwj:
    ACK ccef5d7bf0
  hebasto:
    ACK ccef5d7bf0, I have reviewed the code and it looks OK, I agree it can be merged.

Tree-SHA512: 6d386672b6598aeddd33dabe3512e816cf548d5c1af56c4c9e6f897d513b62ba4659cde73405811a0df286ffee3a3f084ab7caf8e3a2086fa9ddecd1bdcb3c67
2020-06-22 18:01:02 +02:00
Hennadii Stepanov
bbe9cf4fe4
test: Improve "potential deadlock detected" exception message 2020-06-22 18:24:29 +03:00
Hennadii Stepanov
35599344c8
Fix mistakenly swapped "previous" and "current" lock orders 2020-06-22 18:12:26 +03:00
Cory Fields
2418f739f7
macos: Bump to xcode 11.3.1 and 10.15 SDK
This gets us a newer SDK with c++17 support and retains 10.12
back-compat.

Co-authored-by: Carl Dong <contact@carldong.me>
2020-06-22 10:14:33 -04:00
Cory Fields
5c2c835433
depends: bump MacOS toolchain
clang   6.0.1  -> 8.0.0
cctools 921    -> 949.0.1
ld64    409.12 -> 530
2020-06-22 10:14:05 -04:00
Carl Dong
85b5e42088
contrib: macdeploy: Remove historical extraction notes 2020-06-22 10:14:03 -04:00
Carl Dong
351beb5c9a
contrib: macdeploy: Use apple-sdk-tools instead of xar+pbzx 2020-06-22 10:14:02 -04:00
Carl Dong
fbcfcf6954
native_cctools: Don't use libc++ from pinned clang
Now that we include the macOS SDK libc++ headers in our macOS SDK
tarball, we no longer need this hack to use the libc++ from our pinned
clang.
2020-06-22 10:14:01 -04:00