Commit graph

23317 commits

Author SHA1 Message Date
Andrew Chow
3d70dd99f9 Move FillPSBT to be a member of CWallet 2020-03-09 11:16:17 -04:00
MarcoFalke
aaaa055ff7
fuzz: Add option to merge input dir to test runner 2020-03-09 11:13:57 -04:00
MarcoFalke
fa4fa88d76
doc: Remove --disable-ccache from docs 2020-03-09 11:13:48 -04:00
MarcoFalke
31b2ce70fb
Merge #18299: tests: Update FUZZERS_MISSING_CORPORA to enable regression fuzzing for all harnesses in master
bf06641819 tests: Reset FUZZERS_MISSING_CORPORA to enable regression fuzzing for more harnesses (practicalswift)

Pull request description:

  Update `FUZZERS_MISSING_CORPORA` to enable regression fuzzing for all harnesses in `master`.

  Note that this PR is expected to fail in Travis until https://github.com/bitcoin-core/qa-assets/pull/4 is merged :)

Top commit has no ACKs.

Tree-SHA512: 6b4d23726ca99c7ab9454087f0354e35d307e7e16b90741cdf7838265a07a631cf54d9533b4f1bf9a0fd900c5ed909756a35cab738284bf39b09ab1c2ed54368
2020-03-09 11:05:52 -04:00
practicalswift
bf06641819 tests: Reset FUZZERS_MISSING_CORPORA to enable regression fuzzing for more harnesses 2020-03-09 14:30:18 +00:00
fanquake
6ddf435493
Merge #18274: rpc/wallet: initialize nFeeRequired to avoid using garbage value on failure
a652ba6293 rpc/wallet: initialize nFeeRequired to avoid using garbage value on failure (Karl-Johan Alm)

Pull request description:

  Initialize the `nFeeRequired` variable to avoid using an uninitialized value for errors happening before it is set to 0.

  Note: this originally fixed `nFeeRet` in `wallet.cpp`.

ACKs for top commit:
  promag:
    ACK a652ba6293.
  Sjors:
    utACK a652ba6293
  practicalswift:
    ACK a652ba6293 -- patch looks correct
  meshcollider:
    utACK a652ba6293

Tree-SHA512: 0d12f1ffd0851ed5ce6d109d2c87f55e8b1d57da297e684feeabb57229200c4078f029c55ca5aa5712bd18e26dda3ce538443dfe68a7a6d504428068f81fded0
2020-03-09 19:17:51 +08:00
Karl-Johan Alm
a652ba6293
rpc/wallet: initialize nFeeRequired to avoid using garbage value on failure 2020-03-09 10:20:41 +09:00
Andrew Chow
a4af324d15 Use CWallet::SignTransaction in CreateTransaction and signrawtransactionwithwallet
Instead of duplicating signing code, just use the function we already
have.
2020-03-08 12:27:05 -04:00
Andrew Chow
f37de92744 Implement CWallet::SignTransaction using ScriptPubKeyMan::SignTransaction 2020-03-08 12:26:32 -04:00
Andrew Chow
d999dd588c Add SignTransaction function to ScriptPubKeyMan and LegacyScriptPubKeyMan 2020-03-08 12:26:32 -04:00
Andrew Chow
2c52b59d0a Refactor rawtransaction's SignTransaction into generic SignTransaction function 2020-03-08 12:26:27 -04:00
MarcoFalke
fab0e5ba7f
fuzz: Add assert(script == decompressed_script) 2020-03-07 16:55:34 -05:00
MarcoFalke
5e12a61044
Merge #17926: tests: Add key_io fuzzing harness. Fuzz additional functions in existing fuzzing harnesses.
52fed696d2 tests: Fuzz additional functions in the script fuzzing harness (practicalswift)
5fc10f3cb5 tests: Fuzz additional functions in the transaction fuzzing harness (practicalswift)
1d324ce922 tests: Fuzz additional functions in the integer fuzzing harness (practicalswift)
4fe4de6364 tests: Fuzz additional functions in the hex fuzzing harness (practicalswift)
c7ea12d098 tests: Add key_io fuzzing harness (practicalswift)

Pull request description:

  Add `key_io` fuzzing harness.

  Fuzz additional functions in the `hex` fuzzing harness.

  Fuzz additional functions in the `integer` fuzzing harness.

  Fuzz additional functions in the `script` fuzzing harness.

  Fuzz additional functions in the `transaction` fuzzing harness.

  **How to test this PR**

  ```
  $ make distclean
  $ ./autogen.sh
  $ CC=clang CXX=clang++ ./configure --enable-fuzz \
        --with-sanitizers=address,fuzzer,undefined
  $ make
  $ src/test/fuzz/key_io
  …
  ```

ACKs for top commit:
  MarcoFalke:
    ACK 52fed696d2 🛫

Tree-SHA512: a57ab66c18d260c2e39d987cab9fa576f7a5520dc1ea7fd607d64d8e005e16558312ddb4c9f4d4f3147dc6194d8ae0b0fb86ed5e58ba6aef5383ea726463df97
2020-03-07 11:19:52 -05:00
Hennadii Stepanov
ddc7e42d60
build: Set minimum Automake version to 1.13 2020-03-07 17:38:06 +02:00
Andrew Chow
09e25071f4 Cache parent xpub inside of BIP32PubkeyProvider
Optimize Expand by having BIP32PubkeyProvider also cache the parent
(or only) xpub within itself. Since Expand does not provide a read
cache, it is useful to internally cache this xpub to avoid re-deriving
the same xpub.
2020-03-07 10:13:47 -05:00
Andrew Chow
deb791c7ba Only cache xpubs that have a hardened last step
Also adds tests for this:
For ranged descriptors with unhardened derivation, we expect to
find parent keys in the cache but no child keys.

For descriptors containing an xpub but do not have unhardened derivation
(i.e. hardened derivation or single xpub with or without derivation),
we expect to find all of the keys in the cache, and the same
number of keys in the cache as in the SigningProvider.

For everything else (no xpub), nothing should be cached at all.
2020-03-07 10:13:47 -05:00
Andrew Chow
f76733eda5 Cache the immediate derivation parent xpub
If unhardened derivation is used, cache the immediate derivation
parent xpub and use it for unhardened derivation
2020-03-07 10:13:47 -05:00
Andrew Chow
58f54b686f Add DescriptorCache* read_cache and DescriptorCache* write_cache to Expand and GetPubKey
Have Expand, ExpandFromCache, and ExpandHelper take additional DescriptorCache
parameters. These are then passed into PubkeyProvider::GetPubKey which
also takes them as arguments.

Reading and writing to the cache is pushed down into GetPubKey. The old cache where
pubkeys are serialized to a vector is completely removed and instead xpubs are being
cached in DescriptorCache.
2020-03-07 10:13:47 -05:00
Andrew Chow
66c2cadc91 Rename BIP32PubkeyProvider.m_extkey to m_root_extkey
Renaming clarifies that m_extkey is actually the root
extkey that keys are derived from.
2020-03-07 10:13:47 -05:00
Andrew Chow
df55d44d0d Track the index of the key expression in PubkeyProvider 2020-03-07 10:13:47 -05:00
Andrew Chow
474ea3b927 Introduce DescriptorCache struct which caches xpubs 2020-03-07 10:13:43 -05:00
practicalswift
52fed696d2 tests: Fuzz additional functions in the script fuzzing harness 2020-03-07 14:35:49 +00:00
practicalswift
5fc10f3cb5 tests: Fuzz additional functions in the transaction fuzzing harness 2020-03-07 14:35:49 +00:00
MarcoFalke
fa70ccc6c4
scheduler: Use C++11 member initialization, add shutdown assert
"Initializing the members in the declaration makes it easy to spot
uninitialized ones".
https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#c-data-structures
2020-03-07 08:58:38 -05:00
practicalswift
1d324ce922 tests: Fuzz additional functions in the integer fuzzing harness 2020-03-07 13:40:19 +00:00
practicalswift
4fe4de6364 tests: Fuzz additional functions in the hex fuzzing harness 2020-03-07 13:39:25 +00:00
practicalswift
c7ea12d098 tests: Add key_io fuzzing harness 2020-03-07 13:39:25 +00:00
fanquake
ad345909b2
doc: remove Boost Chrono from install docs 2020-03-07 08:34:31 +08:00
fanquake
e21fa542b1
test: remove Boost Chrono installation from CI 2020-03-07 08:34:31 +08:00
fanquake
bd37f2bc26
build: remove Boost Chrono detection from build system 2020-03-07 08:34:31 +08:00
fanquake
1d0a87e712
build: remove chrono package from depends Boost 2020-03-07 08:34:30 +08:00
fanquake
3d28c886f0
Merge #18286: build: Add locale fuzzer to FUZZERS_MISSING_CORPORA (and unbreak Travis! :))
0d0bc3b5c1 build: Add locale fuzzer to FUZZERS_MISSING_CORPORA (practicalswift)

Pull request description:

  Add `locale` fuzzer to `FUZZERS_MISSING_CORPORA`.

  This is a follow-up to #18126 which broke Travis. Sorry about that :)

ACKs for top commit:
  fanquake:
    ACK 0d0bc3b5c1

Tree-SHA512: c0968dc798839f87c891d1dfccf5541883ac56b51a29f52244e78c221c9c087d2dea0a959612d907d53b29fca1f486b340227b17653227ecbf6ca5ab0e85b0d3
2020-03-07 08:04:53 +08:00
practicalswift
0d0bc3b5c1 build: Add locale fuzzer to FUZZERS_MISSING_CORPORA 2020-03-06 23:29:23 +00:00
fanquake
4d80274b99
Merge #18241: wallet/refactor: refer to CWallet immutably when possible
79facb11e9 wallet: use constant CWallets in rpcwallet.cpp (Karl-Johan Alm)
d9b0ebc1da wallet: make ReserveDestination pwallet ivar const (Karl-Johan Alm)
57c569e4d9 wallet: make BackupWallet() const (Karl-Johan Alm)
df3a818d2a wallet: make getters const (Karl-Johan Alm)
227b9dd2d6 wallet/spkm: make GetOldestKeyPoolTime() const (Karl-Johan Alm)
22d329ad0e wallet: use constant CWallets in rpcdump.cpp (Karl-Johan Alm)
7b3587b29d wallet/db: make IsDummy() const (Karl-Johan Alm)
d366795d18 wallet/db: make Backup() const (Karl-Johan Alm)
8cd0b86340 wallet: make CanGetAddresses() const (Karl-Johan Alm)
037fa770eb wallet: make KeypoolCountExternalKeys() const (Karl-Johan Alm)
ddc93557ad wallet: make CanGenerateKeys() const (Karl-Johan Alm)
dc2d0650fd make BlockUntilSyncedToCurrentChain() const (Karl-Johan Alm)

Pull request description:

  A lot of places refer to `CWallet*`'s as `CWallet * const`, which translates to *"an immutable pointer to a mutable `CWallet` instance"*; this is

  1. often not what the author meant, especially as a lot of these places do not at all modify the wallet object, and
  2. confusing, as it tends to suggest that this is a proper way to refer to a constant `CWallet` instance.

  This PR changes references to wallets to `const CWallet* const` whenever immutability is expected. This should result in no behavioral changes at all, and improved compile-time error checking.

  Note from irc:

  > <sipa> sounds good to me; this is the sort of change that as long as it compiles, the behavior shouldn't change
  > <sipa> though in general it may lead to introducing automatic copying of objects sometimes (e.g. trying to std::move a const object will work, but generally result in a copy rather than an efficient move)
  > <sipa> CWallet objects aren't copied or moved though

ACKs for top commit:
  laanwj:
    ACK 79facb11e9
  Empact:
    ACK 79facb11e9
  promag:
    ACK 79facb11e9.
  fjahr:
    ACK 79facb11e9

Tree-SHA512: 80a80c1a52f0f788d0ccb268b53bc0f46c796643a3c5a22b55bbbde4ffa6c7e347784e5e53b1e488a3b4e14399e31d5be9417ad5b6319c74a462609e9b1a98e8
2020-03-07 07:24:54 +08:00
MarcoFalke
fab7d14ea5
test: Check that wait_until returns if time point is in the past 2020-03-06 16:08:12 -05:00
Wladimir J. van der Laan
3516a31eaa
Merge #18234: refactor: Replace boost::mutex,condition_var,chrono with std equivalents in scheduler
70a6b529f3 lint-cppcheck: Remove -DHAVE_WORKING_BOOST_SLEEP_FOR (Anthony Towns)
294937b39d scheduler_tests: re-enable mockforward test (Anthony Towns)
cea19f6859 Drop unused reverselock.h (Anthony Towns)
d0ebd93270 scheduler: switch from boost to std (Anthony Towns)
b9c4260127 sync.h: add REVERSE_LOCK (Anthony Towns)
306f71b4eb scheduler: don't rely on boost interrupt on shutdown (Anthony Towns)

Pull request description:

  Replacing boost functionality with C++11 stuff.

  Motivated by #18227, but should stand alone. Changing from `boost::condition_var` to `std::condition_var` means `threadGroup.interrupt_all` isn't enough to interrupt `serviceQueue` anymore, so that means calling `stop()` before `join_all()` is needed. And the existing reverselock.h code doesn't work with sync.h's DebugLock code (because the reversed lock won't be removed from `g_lockstack` which then leads to incorrect potential deadlock warnings), so I've replaced that with a dedicated class and macro that's aware of our debug lock behaviour.

  Fixes #16027, Fixes #14200, Fixes #18227

ACKs for top commit:
  laanwj:
    ACK 70a6b529f3

Tree-SHA512: d1da13adeabcf9186d114e2dad9a4fdbe2e440f7afbccde0c13dfbaf464efcd850b69d3371c5bf8b179d7ceb9d81f4af3cc22960b90834e41eaaf6d52ef7d331
2020-03-06 20:51:56 +01:00
MarcoFalke
45cdcd47d9
Merge #18126: tests: Add fuzzing harness testing the locale independence of the strencodings.h functions
259e290db8 tests: Add fuzzing harness for locale independence testing (practicalswift)

Pull request description:

  Context: [C and C++ locale assumptions in bitcoind and bitcoin-qt](https://github.com/bitcoin/bitcoin/pull/18124)

  Add fuzzing harness for locale independence testing of functions in `strencodings.h` and `tinyformat.h`.

  Test this PR using:

  ```
  $ make distclean
  $ ./autogen.sh
  $ CC=clang CXX=clang++ ./configure --enable-fuzz \
        --with-sanitizers=address,fuzzer,undefined
  $ make
  $ src/test/fuzz/locale
  …
  ```

  The tested functions (`ParseInt32(…)`, `ParseInt64(…)`, `atoi(const std::string&)`, `atoi64(const std::string& str)`, `i64tostr(const char*)`, `itostr(…)`, `strprintf(…)`) all call locale dependent functions (such as `strtol(…)`, `strtoll(…)`, `atoi(const char*)`, etc.) but are assumed to do so in a way that the tested functions return same results regardless of the chosen C locale (`setlocale`).

  This fuzzer aims to test that those assumptions hold up also in practice now and over time.

Top commit has no ACKs.

Tree-SHA512: d108d2f85aa6f482839dafbc7579465ffd4bacf7bc52835ad0fbaa1c71aed9b3870c83447b3d453a03b9ce307e76a3cfdd350a0c77024ab094c93c7d62c8a527
2020-03-06 14:31:11 -05:00
Anthony Towns
70a6b529f3 lint-cppcheck: Remove -DHAVE_WORKING_BOOST_SLEEP_FOR 2020-03-07 04:20:41 +10:00
practicalswift
259e290db8 tests: Add fuzzing harness for locale independence testing 2020-03-06 13:29:21 +00:00
Anthony Towns
294937b39d scheduler_tests: re-enable mockforward test 2020-03-06 23:14:10 +10:00
Anthony Towns
cea19f6859 Drop unused reverselock.h 2020-03-06 23:14:10 +10:00
Anthony Towns
d0ebd93270 scheduler: switch from boost to std
Changes from boost::chrono to std::chrono, boost::condition_var to
std::condition_var, boost::mutex to sync.h Mutex, and reverselock.h to
sync.h REVERSE_LOCK. Also adds threadsafety annotations to CScheduler
members.
2020-03-06 23:14:08 +10:00
Anthony Towns
b9c4260127 sync.h: add REVERSE_LOCK 2020-03-06 23:13:31 +10:00
Anthony Towns
306f71b4eb scheduler: don't rely on boost interrupt on shutdown
Calling interrupt_all() will immediately stop the scheduler, so it's
safe to invoke stop() beforehand, and this removes the reliance on boost
to interrupt serviceQueue().
2020-03-06 23:13:31 +10:00
fanquake
97aadf98d0
Merge #16117: util: Replace boost sleep with std sleep
fae86c38bc util: Remove unused MilliSleep (MarcoFalke)
fa9af06d91 scripted-diff: Replace MilliSleep with UninterruptibleSleep (MarcoFalke)
fa4620be78 util: Add UnintrruptibleSleep (MarcoFalke)

Pull request description:

  We don't use the interruptible feature of boost's sleep anywhere, so replace it with the sleep in `std::thread`

ACKs for top commit:
  ajtowns:
    ACK fae86c38bc quick code review
  practicalswift:
    ACK fae86c38bc -- patch looks correct
  sipa:
    Concept and code review ACK fae86c38bc
  fanquake:
    ACK fae86c38bc - note that an instance of `DHAVE_WORKING_BOOST_SLEEP_FOR` was missed in the [linter](https://github.com/bitcoin/bitcoin/blob/master/test/lint/extended-lint-cppcheck.sh#L69), but that can be cleaned up later.

Tree-SHA512: 7c0f8eb197664b9f7d9fe6c472c77d384f11c797c913afc31de4b532e3b4fd9ea6dd174f92062ff9d1ec39b25e0900ca7c597435add87f0f2477d9557204848c
2020-03-06 15:41:00 +08:00
MarcoFalke
3f826598a4
Merge #17972: tests: Add fuzzing harness for CKey and key related functions
f4691b6c21 tests: Add fuzzing harness for CKey related functions (practicalswift)

Pull request description:

  Add fuzzing harness for `CKey` and key related functions.

  **How to test this PR**

  ```
  $ make distclean
  $ ./autogen.sh
  $ CC=clang CXX=clang++ ./configure --enable-fuzz \
        --with-sanitizers=address,fuzzer,undefined
  $ make
  $ src/test/fuzz/key
  …
  #4096   pulse  cov: 5736 ft: 6960 corp: 27/833b lim: 67 exec/s: 2048 rss: 122Mb
  #8192   pulse  cov: 5736 ft: 6960 corp: 27/833b lim: 103 exec/s: 2048 rss: 143Mb
  #13067  NEW    cov: 5736 ft: 6965 corp: 28/865b lim: 154 exec/s: 2177 rss: 166Mb L: 32/32 MS: 1 ChangeBit-
  #16384  pulse  cov: 5736 ft: 6965 corp: 28/865b lim: 182 exec/s: 2048 rss: 181Mb
  #32768  pulse  cov: 5736 ft: 6965 corp: 28/865b lim: 347 exec/s: 2184 rss: 258Mb
  …
  ```

Top commit has no ACKs.

Tree-SHA512: 5b17ffb70c31966d3eac06d2258c127ae671d28d6cdf4e6ac20b45cd59ad32f80952c9c749930b97d317c72d5f840a3b75d466fd28fb6c351424a72c3e41bcbc
2020-03-05 16:43:16 -05:00
practicalswift
f4691b6c21 tests: Add fuzzing harness for CKey related functions 2020-03-05 21:11:10 +00:00
MarcoFalke
a2b5aae9f3
Merge #17996: tests: Add fuzzing harness for serialization/deserialization of floating-points and integrals
9ff41f6419 tests: Add float to FUZZERS_MISSING_CORPORA (temporarily) (practicalswift)
8f6fb0a85a tests: Add serialization/deserialization fuzzing for integral types (practicalswift)
3c82b92d2e tests: Add fuzzing harness for functions taking floating-point types as input (practicalswift)
c2bd588860 Add missing includes (practicalswift)

Pull request description:

  Add simple fuzzing harness for functions with floating-point parameters (such as `ser_double_to_uint64(double)`, etc.).

  Add serialization/deserialization fuzzing for integral types.

  Add missing includes.

  To test this PR:

  ```
  $ make distclean
  $ ./autogen.sh
  $ CC=clang CXX=clang++ ./configure --enable-fuzz \
        --with-sanitizers=address,fuzzer,undefined
  $ make
  $ src/test/fuzz/float
  …
  ```

Top commit has no ACKs.

Tree-SHA512: 9b5a0c4838ad18d715c7398e557d2a6d0fcc03aa842f76d7a8ed716170a28f17f249eaede4256998aa3417afe2935e0ffdfaa883727d71ae2d2d18a41ced24b5
2020-03-05 15:41:30 -05:00
practicalswift
9ff41f6419 tests: Add float to FUZZERS_MISSING_CORPORA (temporarily) 2020-03-05 20:35:26 +00:00
practicalswift
8f6fb0a85a tests: Add serialization/deserialization fuzzing for integral types 2020-03-05 20:35:26 +00:00