Commit Graph

26884 Commits

Author SHA1 Message Date
Vasil Dimov
db058efeb0
sync: use HasReason() in double lock tests
`HasReason()` is shorter than a lambda function.
2020-11-26 14:42:06 +01:00
Vasil Dimov
a21dc469cc
sync: const-qualify the argument of double_lock_detected()
It is not modified in the function, so should be `const`.
2020-11-26 14:42:00 +01:00
Vasil Dimov
6d3689fcf6
sync: print proper lock order location when double lock is detected
Before:
```
Assertion failed: detected double lock at src/sync.cpp:153, details in debug log.
```

After:
```
Assertion failed: detected double lock for 'm' in src/test/sync_tests.cpp:40 (in thread ''), details in debug log.
```
2020-11-26 14:41:53 +01:00
practicalswift
79bff8e48a Remove NODISCARD 2020-11-26 09:07:33 +00:00
practicalswift
4848e71107 scripted-diff: Use [[nodiscard]] (C++17) instead of NODISCARD
-BEGIN VERIFY SCRIPT-
sed -i "s/NODISCARD/[[nodiscard]]/g" $(git grep -l "NODISCARD" ":(exclude)src/bench/nanobench.h" ":(exclude)src/attributes.h")
-END VERIFY SCRIPT-
2020-11-26 09:05:59 +00:00
sanket1729
e416cfc92b Add MAX_STANDARD_SCRIPTSIG_SIZE to policy
Bitcoin core has a standardness rule for max satisfaction script sig size.
This PR adds to the policy header file so that it is documented along with
along policy rules. The initial reasoning that 1650 is an implicit
limit(would not reached assuming all other policy rules are being
followed) is outdated.

As we now know, bitcoin transactions can have spend conditions are more than
just signatures and there may exist p2sh transactions involving 100 byte
preimages that maybe non-standard because of this rule. Because this
rule is no longer implicit, we should explicitly document it in policy
header file
2020-11-25 14:04:39 -06:00
Hennadii Stepanov
ec4a46dd9c
build: Drop unneeded IOKit framework dependency 2020-11-25 18:25:52 +02:00
Hennadii Stepanov
65afe4cb69
build: Drop unneeded ApplicationServices framework dependency 2020-11-25 18:18:36 +02:00
Wladimir J. van der Laan
50091592dd
Merge #19337: sync: detect double lock from the same thread
95975dd08d sync: detect double lock from the same thread (Vasil Dimov)
4df6567e4c sync: make EnterCritical() & push_lock() type safe (Vasil Dimov)

Pull request description:

  Double lock of the same (non-recursive) mutex from the same thread would produce an undefined behavior. Detect this from `DEBUG_LOCKORDER` and react similarly to the deadlock detection.

  This came up during discussion in another, related PR: https://github.com/bitcoin/bitcoin/pull/19238#discussion_r442394521.

ACKs for top commit:
  laanwj:
    code review ACK 95975dd08d
  hebasto:
    re-ACK 95975dd08d

Tree-SHA512: 375c62db7819e348bfaecc3bd82a7907fcd8f5af24f7d637ac82f3f16789da9fc127dbd0e37158a08e0dcbba01a55c6635caf1d8e9e827cf5a3747f7690a498e
2020-11-25 17:02:20 +01:00
MarcoFalke
19b8071eae
Merge #20489: CI msvc: only build vcpkg dependencies for release (not debug) to reduce build times
fa18e7cbc5 This change to the appveyor CI config for msvc builds reverses a change introduced in #19960. It re-applies a setting to inform vcpkg to only build release vesions of the dependencies rather than the default of debug and release. (Aaron Clauson)

Pull request description:

  This change to the appveyor CI config for msvc builds reverses a change introduced in #19960. It re-applies a setting to inform vcpkg to only build release versions of the dependencies rather than the default of debug and release.

  It had been expected that the vcpkg manifest mechanism introduced in #19960 would do this automatically but it turns out not to be the case.

ACKs for top commit:
  MarcoFalke:
    ACK fa18e7cbc5 if green
  hebasto:
    ACK fa18e7cbc5, AppVeyor build takes 5 minutes less.

Tree-SHA512: 427e7e78190c20e0d85dad9b29beed2b6fa13f99c6bc72bcc1839dfb51237a7cc785ab707b4f851c527c1bb0d3e7ebad9e640969e19d29778584bbaeec75cecf
2020-11-25 16:31:43 +01:00
MarcoFalke
5c0aebfcd4
Merge #19387: span: update constructors to match c++20 draft spec and add lifetimebound attribute
e3e7446305 Add lifetimebound to attributes for general-purpose usage (Cory Fields)
1d58cc7cb0 span: add lifetimebound attribute (Cory Fields)
62733fee87 span: (almost) match std::span's constructor behavior (Cory Fields)

Pull request description:

  Replaces #19382 with a different approach. See [this comment](https://github.com/bitcoin/bitcoin/pull/19382#discussion_r446332852) for the reasoning behind the switch.

  --

  Description from #19382:

  See [here](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0936r0.pdf) for more detail on lifetimebound.

  This is implemented using preprocesor macros rather than configure checks in order to keep span.h self-contained.

  The ```[[clang::lifetimebound]]``` syntax was chosen over ```__attribute__((lifetimebound))``` because the former is more flexible and works to guard ```this``` as well as function parameters, and also because at least for now, it's available only in clang.

  There are currently no violations in our codebase, but this can easily be tested by inserting one like this somewhere and compiling with a modern clang:
  ```c++
  Span<const int> bad(std::vector<int>{1,2,3});
  ```

  The result:
  > warning: temporary whose address is used as value of local variable 'bad' will be destroyed at the end of the full-expression [-Wdangling]
      Span<const int> bad(std::vector<int>{1,2,3});
  ```

ACKs for top commit:
  sipa:
    ACK e3e7446305
  ajtowns:
    ACK e3e7446305 (drive by; only a quick skim of code and some basic sanity checks)
  MarcoFalke:
    review ACK e3e7446305 🔗
  jonatack:
    ACK e3e7446 change since last review is adding `[[clang::lifetimebound]]` as `LIFETIMEBOUND` to src/attributes.h as suggested in https://github.com/bitcoin/bitcoin/pull/19387#issuecomment-650752959.

Tree-SHA512: 05a3440ee595ef0e8d693a2820b360707695c016a68e15df47c20cd8d053646cc6c8cca8addd7db40e72b3fce208879a41c8102ba7ae9223e4366e5de1175211
2020-11-25 15:18:33 +01:00
Hennadii Stepanov
8963b2c71f
qt: Improve comments in WalletController::getOrCreateWallet() 2020-11-25 16:12:33 +02:00
Hennadii Stepanov
5fcfee68af
qt: Call setParent() in the parent's context
setParent(parent) calls sendEvent(parent, QChildEvent) that implies
running in the thread which created the parent object.
2020-11-25 16:12:32 +02:00
Hennadii Stepanov
5659e73493
qt: Add ObjectInvoke template function
This is a replacement of the QMetaObject::invokeMethod functor overload
which is available in Qt 5.10+.

Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
2020-11-25 16:12:23 +02:00
Dmitry Petukhov
89895773b7
Fix length of R check in test/key_tests.cpp:key_signature_tests
The code before the fix only checked the length of R value of the last
signature in the loop, and only for equality (but the length can be
less than 32)

The fixed code checks that length of the R value is less than or equal
to 32 on each iteration of the loop

The BOOST_CHECK(sig.size() <= 70) is merged with sig[3] <= 32 check,
and BOOST_CHECKs are moved outside the loop, for efficiency
2020-11-25 18:07:37 +05:00
Hennadii Stepanov
830ddf4139
Drop noop gcc version checks
Since #20413 the minimum required GCC version is 7.

Co-authored-by: practicalswift <practicalswift@users.noreply.github.com>
2020-11-25 14:38:33 +02:00
MarcoFalke
afdfd3c8c1
Merge #20403: wallet: upgradewallet fixes, improvements, test coverage
3eb6f8b2e6 wallet (not for backport): improve upgradewallet error messages (Jon Atack)
ca8cd893bb wallet: fix and improve upgradewallet error responses (Jon Atack)
99d56e3571 wallet: fix and improve upgradewallet result responses (Jon Atack)
2498b04ce8 Don't upgrade to HD split if it is already supported (Andrew Chow)
c46c18b788 wallet: refactor GetClosestWalletFeature() (Jon Atack)

Pull request description:

  This follows up on #18836 and #20282 to fix and improve the as-yet unreleased `upgradewallet` feature and also implement review follow-up in https://github.com/bitcoin/bitcoin/pull/18836#discussion_r519328607.

  This PR fixes 4 upgradewallet issues:

  - this bug: https://github.com/bitcoin/bitcoin/pull/20403#discussion_r526063920
  - it returns nothing in the absence of an RPC error, which isn't reassuring for users
  - it returns the same thing both in the case of a successful upgrade and when no upgrade took place
  - the error message object is currently dead code

  This PR fixes the above and provides:

  ...user feedback to not silently return without upgrading
  ```
  {
    "wallet_name": "disable private keys",
    "previous_version": 169900,
    "current_version": 169900,
    "result": "Already at latest version. Wallet version unchanged."
  }
  ```
  ...better feedback after successfully upgrading
  ```
  {
    "wallet_name": "watch-only",
    "previous_version": 159900,
    "current_version": 169900,
    "result": "Wallet upgraded successfully from version 159900 to version 169900."
  }
  ```
  ...helpful error responses
  ```
  {
    "wallet_name": "blank",
    "previous_version": 169900,
    "current_version": 169900,
    "error": "Cannot downgrade wallet from version 169900 to version 159900. Wallet version unchanged."
  }
  {
    "wallet_name": "blank",
    "previous_version": 130000,
    "current_version": 130000,
    "error": "Cannot upgrade a non HD split wallet from version 130000 to version 169899 without upgrading to support pre-split keypool. Please use version 169900 or no version specified."
  }
  ```
  updated help:
  ```
  upgradewallet ( version )

  Upgrade the wallet. Upgrades to the latest version if no version number is specified.
  New keys may be generated and a new wallet backup will need to be made.
  Arguments:
  1. version    (numeric, optional, default=169900) The version number to upgrade to. Default is the latest wallet version.

  Result:
  {                            (json object)
    "wallet_name" : "str",     (string) Name of wallet this operation was performed on
    "previous_version" : n,    (numeric) Version of wallet before this operation
    "current_version" : n,     (numeric) Version of wallet after this operation
    "result" : "str",          (string, optional) Description of result, if no error
    "error" : "str"            (string, optional) Error message (if there is one)
  }
  ```

ACKs for top commit:
  achow101:
    ACK  3eb6f8b
  MarcoFalke:
    review ACK 3eb6f8b2e6 🛡

Tree-SHA512: b767314069e26b5933b123acfea6aa40708507f504bdb22884da020a4ca1332af38a7072b061e36281533af9f4e236d94d3c129daf6fe5b55241127537038eed
2020-11-25 12:46:27 +01:00
Aaron Clauson
fa18e7cbc5
This change to the appveyor CI config for msvc builds reverses a change introduced in #19960. It re-applies a setting to inform vcpkg to only build release vesions of the dependencies rather than the default of debug and release.
It had been expected that the vcpkg manifest mechanism introduced in #19960 would do this automatically but it turns out not to be the case.
2020-11-25 11:07:10 +00:00
Wladimir J. van der Laan
1e9e4b68f3
Merge #20469: build: Avoid secp256k1.h include from system
e95aaefe25 build: Avoid secp256k1.h include from system (Niklas Gögge)

Pull request description:

  While building i ran into an error because i had a version of `secp256k1.h` under `/usr/local/include` that was incompatible with the secp256k1 code in the repository. This caused a problem because `$(BOOST_CPPFLAGS)` contained `-I/usr/local/include` and the include paths are searched by the compiler in order from left to right, so in the end `$(BITCOIN_INCLUDES)` contained `-I/usr/local/include` before `-I$(srcdir)/secp256k1/include` which caused the compiler to find  `secp256k1.h` under `/usr/local/include`.

  Looking at git blame i am wondering how this has not happened to anyone else in several years: cb89e18845/src/Makefile.am (L25)

  I am on macOS 10.15.

ACKs for top commit:
  laanwj:
    Code review ACK e95aaefe25
  hebasto:
    ACK e95aaefe25, tested on macOS 11 Big Sur by adding `#error` into `/usr/local/include/secp256k1.h`.

Tree-SHA512: 1f0b395725936c179ab60dee3582ec7b21e2f9c0f1895e160d84a487cf0db16d0c7aa47d05800e0aded31685b4362056cac9b9ecca1bb8c308a4c5a810e8dc1d
2020-11-25 09:48:47 +01:00
MarcoFalke
efd4cdb81f
Merge #20456: test: Fix intermittent issue in mempool_compatibility
fa05d19bd6 test: Fix intermittent issue in mempool_compatibility (MarcoFalke)

Pull request description:

  Fixes https://cirrus-ci.com/task/5141306890518528?command=ci#L6076

  The version is too old to understand getmempoolinfo()[loaded], so it is never called when starting (See https://cirrus-ci.com/task/5141306890518528?command=ci#L5541)

ACKs for top commit:
  achow101:
    ACK fa05d19bd6

Tree-SHA512: e912d5dff6236d2d4ac608f9f3b3e255cc2b611f36d79bfe4e2a940709833a947c682d7703327887e1753eab30b95eb2615d7e2c21ce4bca4f089e717cbb51c4
2020-11-25 08:19:59 +01:00
MarcoFalke
ca4a784942
Merge #20410: wallet: Do not treat default constructed types as None-type
fa69c2c784 wallet: Do not treat default constructed types as None-type (MarcoFalke)
fac4e136fa refactor: Change pointer to reference because it can not be null (MarcoFalke)

Pull request description:

  Equating `0==None` and `""==None` is confusing, unneeded and undocumented

ACKs for top commit:
  jonatack:
    ACK fa69c2c784
  achow101:
    ACK fa69c2c784
  Sjors:
    tACK fa69c2c784 modulo `unset`

Tree-SHA512: c4c8d0ad80c6697621d356a9545caf28ca2facc82bb2fa8e70eceb52372d25f0685237c73688c4b01da0e75d213c77c0d45011a8bdfe81ea783d85f045786dac
2020-11-25 08:02:19 +01:00
Jonas Schnelli
c23f6f84ef Add depends qt fix for ARM macs 2020-11-24 21:00:34 +01:00
Russell Yanofsky
629a9299b2 Move WalletImpl from interfaces/wallet.cpp to wallet/interfaces.cpp 2020-11-24 10:20:16 -05:00
Russell Yanofsky
2a26771d81 Move ChainImpl from interfaces/chain.cpp to node/interfaces.cpp
No changes to ChainImpl or any related classes (review with `git diff --color-moved=dimmed_zebra`)
2020-11-24 10:13:23 -05:00
Russell Yanofsky
12bd0fc9d7 Move NodeImpl from interfaces/node.cpp to node/interfaces.cpp 2020-11-24 10:13:23 -05:00
Jonas Schnelli
982e548a9a Don't set BDB flags when configuring without 2020-11-24 15:08:28 +01:00
fanquake
31c9987976
Merge #20447: depends: Patch qt_intersect_spans to avoid non-deterministic behavior in LLVM 8
8f7d1b39ef Fix QPainter non-determinism on macOS (Andrew Chow)

Pull request description:

  Aplies a patch to Qt that fixes the non-determinism by modifying Qt. The source of the non-determinism is how LLVM 8 optimizes qt_intersect_spans when compiling. The particular optimization that seems to be causing the problems is that a temp variable is being added for spans->y. For some reason, when it does this, it chooses different instructions to use when making that variable. We bypass this problem by patching qt_intersect_spans to always make and use this local variable.

  Potential alternative to #20436 and #20440

ACKs for top commit:
  hebasto:
    re-ACK 8f7d1b39ef ~for merging into the 0.21 branch, but [not into the master](https://github.com/bitcoin/bitcoin/pull/20454) branch.~
  fanquake:
    ACK 8f7d1b39ef

Tree-SHA512: b0d00a77643554021736524fb64611462ef2ec849a220543c12d99edb0f52f2e8128d2cc61fa82176b7e13b294574774a92d6b649badf8b7630c6d6a7e70ce10
2020-11-24 21:12:02 +08:00
MarcoFalke
9402159b9b
Merge #20472: test: Add testing of ParseInt/ParseUInt edge cases with leading +/-/0:s
05c1095388 test: Add testing of ParseInt/ParseUInt edge cases with leading +/-/0:s (practicalswift)

Pull request description:

  Add testing of `ParseInt`/`ParseUInt` edge cases with leading `+`/`-`/`0`:s.

  Context: While working on #20457 and #20452 I noticed some edge cases which our unit tests are currently not covering.

ACKs for top commit:
  MarcoFalke:
    review ACK 05c1095388
  laanwj:
    Code review ACK 05c1095388
  jonatack:
    ACK 05c1095388
  promag:
    Code review ACK 05c1095388.

Tree-SHA512: bdfb94d8fa0293512dbba89907cb6dd0f8b1418d878267dd6d49c8c397a0e5b9714441345565d41a6a909a1cda052ef7cccece822f355ff604fcf85f2dc8136f
2020-11-24 12:10:23 +01:00
MarcoFalke
3a32b62fa7
Merge #20462: RPC/Wallet: unloadwallet: Clarify docs/error when both the RPC request and wallet_name parameter specify a wallet
b1f59d55d9 RPC/Wallet: unloadwallet: Clarify docs/error when both the RPC endpoint and wallet_name parameter specify a wallet (Luke Dashjr)

Pull request description:

  Just documentation clarifications from #20448

ACKs for top commit:
  MarcoFalke:
    review ACK b1f59d55d9
  jonatack:
    re-ACK b1f59d55d9  per `git diff e8303a0 b1f59d5`

Tree-SHA512: ac068b0aa7ceed49496367fdd9425b59dbba18b56e89b26afc22a6c8ece51f0b92a169cacd55740b1cadab2b32f4f8e8700e609066ab7e59d3b53c7891da585e
2020-11-24 12:07:09 +01:00
MarcoFalke
6f9dac5ede
Merge #20473: doc: Document current boost dependency as 1.71.0
0918eb49d5 doc: Document current boost dependency as 1.71.0 (Wladimir J. van der Laan)

Pull request description:

  This was forgotten in #19764.

ACKs for top commit:
  practicalswift:
    ACK 0918eb49d5
  fanquake:
    ACK 0918eb49d5

Tree-SHA512: bd4a39b96b95adeb725767b283f4cf04d9f0d6ac352e7dc67f88cf575b00a24c6d3f4bf51fe362e0c89aeebb6c7e8e9add9f9f17e843121efd30f8edef6128bc
2020-11-24 12:04:22 +01:00
Wladimir J. van der Laan
0918eb49d5 doc: Document current boost dependency as 1.71.0
This was forgotten in #19764.
2020-11-24 10:36:07 +01:00
Wladimir J. van der Laan
7ebbee551d
Merge #19764: depends: Split boost into build/host packages + bump + cleanup
f190343c96 depends: boost: Specify cflags+compileflags (Carl Dong)
b2328b7989 depends: boost: Remove unnecessary _archiver_ (Carl Dong)
ab9e047cc2 depends: boost: Cleanup toolset selection (Carl Dong)
86002e7e90 depends: boost: Cleanup architecture/address-model (Carl Dong)
d7048fa73f depends: boost: Disable all compression (Carl Dong)
9cf2ee54d3 depends: boost: Split into non-/native packages (Carl Dong)
a57b498560 depends: boost: Bump to 1.71.0 (Carl Dong)
800655ff31 depends: boost: Refer to version in URL (Carl Dong)

Pull request description:

  This PR improves the robustness of our boost package in depends, most notably:
  1. Bumps boost from `1.70.0` to `1.71.0`, because `1.71.0`:
  	1. Removes the need to patch out the unused variable.
  		f8462a6d27/depends/packages/boost.mk (L36)
  		Upstream boost patched it out in d20b64cf37, which was first included in the `1.71.0` release
  	2. Comes packaged with a version of `b2` which allows us to override its `CXX` and `CXXFLAGS`. Previously, choosing a toolset while building `b2` such as `clang` or `gcc` would force `b2`'s build system to invoke the compiler as a bare, hardcoded `clang` or `gcc`. However, our `depends` build system often want to customize this behaviour, adding extra flags or invoking the compiler by an alternate name. So this is useful.
  		1. Commit where `CXX` was introduced: 374f96516a
  		2. Commit where `CXXFLAGS` was introduced: 5d49abc1f2
  2. The boost package is now split into `native_b2` and `boost`, better representing what actually happens.
  	- In our `depends` build system, we have a distinction between `native` packages and non-`native` packages. The output of `native` packages are meant to be used on the machine that's performing the build, and the output of non-`native` packages are meant to be used on/for the machine that will ultimately be running bitcoin. Previously, `boost` existed in `depends` as a non-`native` package, but that's partly inaccurate because the `./bootstrap.sh` invocation in its `$(package)_config_cmds` stage actually produced a binary called `b2`, which is run on the machine that's performing the build. This means that `b2` is a `native` package which is being built in an environment set up for the non-`native` package `boost`. This reveals a hidden unintended behavior in our `depends` build system: for linux->darwin cross builds, we use `gcc` for `native` packages, and `clang` for non-`native` packages. But `b2` was actually being built using `clang`, since it was being built in an environment set up for non-`native` packages.

  theuni you might be interested in taking a look

ACKs for top commit:
  laanwj:
    Concept and code review ACK f190343c96

Tree-SHA512: f8b728a34da4f0a9a985a819a5762f2fc2689ea24c7eba1d24d26dfbd4c59f202227c699b0a4069dab10b6329cf9f4c6dd95082685776ee43dd5f7b659acdef1
2020-11-24 10:33:08 +01:00
MarcoFalke
faa05854f8
util: Remove probably misleading TODO
The TODO has been added by me, but I don't remember how to solve it. The
current code works fine, so just remove the TODO.
2020-11-24 10:09:48 +01:00
MarcoFalke
fac5efe730
util: Add Assume() identity function 2020-11-24 09:47:29 +01:00
practicalswift
fa861569dc
util: Allow Assert(...) to be used in all contexts
Fixes the compile error when used inside operator[]:

./chain.h:404:23: error: C++11 only allows consecutive left square brackets when introducing an attribute
        return (*this)[Assert(pindex)->nHeight] == pindex;
                      ^
2020-11-24 09:46:49 +01:00
practicalswift
05c1095388 test: Add testing of ParseInt/ParseUInt edge cases with leading +/-/0:s 2020-11-24 08:36:48 +00:00
Luke Dashjr
89bdad5b25 RPC/Wallet: unloadwallet: Allow specifying wallet_name param matching RPC endpoint 2020-11-24 05:33:18 +00:00
Luke Dashjr
b1f59d55d9 RPC/Wallet: unloadwallet: Clarify docs/error when both the RPC endpoint and wallet_name parameter specify a wallet 2020-11-24 05:31:58 +00:00
fanquake
2f5dfe4a7f
depends: build qt in c++17 mode 2020-11-24 10:18:24 +08:00
fanquake
104e859c97
builds: don't pass -silent to qt when building in debug mode
This means we'll get build output like this when building with DEBUG=1:

g++ -c -pipe -ffunction-sections -O2 -fPIC -std=c++11 -fno-exceptions <lots more> ../../corelib/kernel/qcoreapplication.cpp

rather than just:

compiling ../../corelib/kernel/qcoreapplication.cpp
2020-11-24 10:18:21 +08:00
fanquake
e2c500636c
depends: build zeromq with -std=c++17 2020-11-24 10:18:06 +08:00
fanquake
2374f2fbef
depends: build Boost with -std=c++17 2020-11-24 10:17:35 +08:00
fanquake
2dde55702d
depends: build bdb with -std=c++17 2020-11-24 07:29:28 +08:00
Niklas Gögge
e95aaefe25 build: Avoid secp256k1.h include from system 2020-11-23 23:33:53 +01:00
João Barbosa
053b4fbad8 doc: Release note regarding -rpcauth validation 2020-11-23 21:02:54 +00:00
João Barbosa
46001323b1 rpc: Validate -rpcauth arguments 2020-11-23 21:02:54 +00:00
João Barbosa
d37c813a43 rpc: Refactor to process -rpcauth once 2020-11-23 21:02:54 +00:00
Carl Dong
f190343c96
depends: boost: Specify cflags+compileflags 2020-11-23 15:50:59 -05:00
Carl Dong
b2328b7989
depends: boost: Remove unnecessary _archiver_
We already have $(package)_ar, so just use that instead
2020-11-23 15:50:58 -05:00
Carl Dong
ab9e047cc2
depends: boost: Cleanup toolset selection 2020-11-23 15:50:57 -05:00