Commit graph

23401 commits

Author SHA1 Message Date
MarcoFalke
5c9d408b2d
Merge #18300: fuzz: Add option to merge input dir to test runner
fa3fa27c45 fuzz: Remove option --export_coverage from test_runner (MarcoFalke)
aaaa055ff7 fuzz: Add option to merge input dir to test runner (MarcoFalke)
fa4fa88d76 doc: Remove --disable-ccache from docs (MarcoFalke)

Pull request description:

  This is mainly useful for myself to merge pull requests like https://github.com/bitcoin-core/qa-assets/pull/4

  I thought it wouldn't hurt to share the code.

  Also remove the `--disable-ccache` from the docs to speed up builds when developing fuzzers.

Top commit has no ACKs.

Tree-SHA512: 818d85a90db86a7f4e8b001cc88342e5b28b02029d2bd4174440b28a8c4cc29b5406bd6348f72ddf909bb3d0f9bf7b1011976f6480e4418c8b7da5ecccae93e8
2020-03-18 15:51:44 -04:00
MarcoFalke
e83a1de4c0
Merge #18155: tests: Add harness which fuzzes EvalScript and VerifyScript using a fuzzed signature checker
5e47b19e50 tests: Add harness which fuzzes EvalScript and VerifyScript using a fuzzed signature checker (practicalswift)

Pull request description:

  Add harness which fuzzes `EvalScript` and `VerifyScript` using a fuzzed signature checker.

  Test this PR using:

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

  Closes #17986.

Top commit has no ACKs.

Tree-SHA512: a9988f8fa7919fe470756ca3e4e75764a589f590769aab452c8f4c254cf41667793e52131d470a12629ec3681fa7fc20091f371b8f3e3eec105674c2769e7d7e
2020-03-18 15:48:27 -04:00
MarcoFalke
dbb067da38
Merge #18379: doc: Comment fix merkle.cpp
5b59a19731 Update merkle.cpp (4d55397500)

Pull request description:

  Change comment from `The reason is that if the number of hashes in the list at a given time
  is odd`, to ` The reason is that if the number of hashes in the list at a given level
         is odd` (to be a bit more precise: replacing `time` with `level`)

  <!--
  *** Please remove the following help text before submitting: ***

  Pull requests without a rationale and clear improvement may be closed
  immediately.
  -->

  <!--
  Please provide clear motivation for your patch and explain how it improves
  Bitcoin Core user experience or Bitcoin Core developer experience
  significantly:

  * Any test improvements or new tests that improve coverage are always welcome.
  * All other changes should have accompanying unit tests (see `src/test/`) or
    functional tests (see `test/`). Contributors should note which tests cover
    modified code. If no tests exist for a region of modified code, new tests
    should accompany the change.
  * Bug fixes are most welcome when they come with steps to reproduce or an
    explanation of the potential issue as well as reasoning for the way the bug
    was fixed.
  * Features are welcome, but might be rejected due to design or scope issues.
    If a feature is based on a lot of dependencies, contributors should first
    consider building the system outside of Bitcoin Core, if possible.
  * Refactoring changes are only accepted if they are required for a feature or
    bug fix or otherwise improve developer experience significantly. For example,
    most "code style" refactoring changes require a thorough explanation why they
    are useful, what downsides they have and why they *significantly* improve
    developer experience or avoid serious programming bugs. Note that code style
    is often a subjective matter. Unless they are explicitly mentioned to be
    preferred in the [developer notes](/doc/developer-notes.md), stylistic code
    changes are usually rejected.
  -->

  <!--
  Bitcoin Core has a thorough review process and even the most trivial change
  needs to pass a lot of eyes and requires non-zero or even substantial time
  effort to review. There is a huge lack of active reviewers on the project, so
  patches often sit for a long time.
  -->

ACKs for top commit:
  MarcoFalke:
    ACK 5b59a19731
  instagibbs:
    ACK 5b59a19731

Tree-SHA512: 30d29b9855b30de8b54033ca4884cfb5bf8ab9e52cf61da237abba0e15ebff947c65f8ba82175694bc60ee0d54f940a098cadcb0404d3c3bcf577006ab0561a5
2020-03-18 14:02:22 -04:00
4d55397500
5b59a19731
Update merkle.cpp
Change comment from `The reason is that if the number of hashes in the list at a given time
is odd`, to ` The reason is that if the number of hashes in the list at a given level
       is odd` (to be a bit more precise)
2020-03-18 10:34:53 -07:00
MarcoFalke
3a8d25064e
Merge #18371: test: use fs namespace in dbwrapper unicodepath test
6afaf2f680 test: use fs namespace in dbwrapper unicodepath test (fanquake)

Pull request description:

  Use our `fs` namespace rather than `boost::filesystem`. Test was added in #17641.

ACKs for top commit:
  sipsorcery:
    ACK 6afaf2f680.

Tree-SHA512: 5ee024a6d90183b6c344f6a94cfbcacb006973f1f6d98cc421c1c6ef08c09b590d31c78b70b86d855e825241ffea25989cfc40d1bdd53e38a75cda0718ac4489
2020-03-18 09:42:25 -04:00
Vasil Dimov
7d8e1dec3b
net: fix use-after-free in tests
In PeerLogicValidation::PeerLogicValidation() we would schedule a lambda
function to execute later, capturing the local variable
`consensusParams` by reference.

Presumably this was considered safe because `consensusParams` is a
reference itself to a global variable which is not supposed to change,
but it can in tests.

Fixes https://github.com/bitcoin/bitcoin/issues/18372
2020-03-18 13:03:26 +01:00
fanquake
6afaf2f680
test: use fs namespace in dbwrapper unicodepath test 2020-03-18 11:10:20 +08:00
emu
84a46a9b93
doc: mention MAKE=gmake workaround when building on a BSD
Fixes: #14404
2020-03-18 07:55:07 +08:00
MarcoFalke
ce87d5613a
Merge #18289: refactor: Make scheduler methods type safe
fa36f3a295 refactor: move DUMP_BANS_INTERVAL to banman.h (MarcoFalke)
fadafb83cf scheduler: Make schedule* methods type safe (MarcoFalke)
fa70ccc6c4 scheduler: Use C++11 member initialization, add shutdown assert (MarcoFalke)

Pull request description:

  Main benefit is that stuff like `15 * 60 * 1000` is replaced by `minutes{15}`

ACKs for top commit:
  vasild:
    ACK fa36f3a (code review, not tested)
  ajtowns:
    ACK fa36f3a295
  jonatack:
    ACK fa36f3a

Tree-SHA512: f35f1a1d643dfa676bd47474659f6492ed05cca04cdb556064b126f654a6a44a4b93fcaddcdcd41faf81b8f11439c11e5c7ab88685ba2eef12f7188843d17ad8
2020-03-17 16:34:53 -04:00
practicalswift
5e47b19e50 tests: Add harness which fuzzes EvalScript and VerifyScript using a fuzzed signature checker 2020-03-17 19:10:59 +00:00
MarcoFalke
39497d1f32
Merge #15283: log: Fix UB with bench on genesis block
ec30a79f1c Fix UB with bench on genesis block (Gregory Sanders)

Pull request description:

  During the loading of the genesis block, the bench print lines in ConnectTip divide by zero due to early return in ConnectBlock.

ACKs for top commit:
  practicalswift:
    ACK ec30a79f1c
  sipa:
    utACK ec30a79f1c
  promag:
    ACK ec30a79, `nBlocksTotal` is only used in logging.

Tree-SHA512: b3bdbb58d10d002a2293d7f99196b227ed9f4ca8c6cd08981e95cc964be47efed98b91fad276ee6da5cf7e6684610998ace7ce9bace172dd6c51c386d985b83c
2020-03-17 14:27:42 -04:00
MarcoFalke
ad04f0d8a5
Merge #17319: Tests: remove bignum module
3ed772d221 [tests] remove bignum.py (John Newbery)
f950ec2520 [tests] remove bn2bin() (John Newbery)
3b9b38579c [tests] remove bn_bytes() function (John Newbery)
a760aa14a9 [tests] remove mpi2vch() function (John Newbery)
9a60bef50d [tests] don't encode the integer size in bignum (John Newbery)
1dc68aee66 [tests] add function comments to bignum (John Newbery)
f31fc0e92e [tests] fix flake8 warnings in script.py and bignum.py (John Newbery)

Pull request description:

  Only one function is imported in script.py. Just move that function to script.py and remove the bignum.py module.

  Remove unused functionality and fix some flake8 warnings along the way.

Top commit has no ACKs.

Tree-SHA512: 015f543ab545b5d5451896e2751d9c19334d9155b03faacd2023781e89833a2440f7f28741e9a8ac49badd9cdc012cbb6e038cdcdebeefaf9cb9d461c0689157
2020-03-17 13:38:00 -04:00
MarcoFalke
d2d0a04a66
Merge #18353: tests: Add fuzzing harnesses for classes CBlockHeader, CFeeRate and various functions
44abf417eb tests: Add fuzzing harness for various functions taking std::string as input (practicalswift)
d69145acb7 tests: Add fuzzing harness for MultiplicationOverflow(...) (practicalswift)
7726f3bc46 tests: Add fuzzing harness for CFeeRate (practicalswift)
0579a27630 tests: Add fuzzing harness for CBlockHeader (practicalswift)
cb4eec13c0 tests: Add fuzzing harness for count_seconds(...) (practicalswift)

Pull request description:

  Add fuzzing harnesses for classes `CBlockHeader`, `CFeeRate` and various functions.

  To test this PR:

  ```
  $ make distclean
  $ ./autogen.sh
  $ CC=clang CXX=clang++ ./configure --enable-fuzz \
        --with-sanitizers=address,fuzzer,undefined
  $ make
  $ src/test/fuzz/block_header
  ^c (ctrl-c)
  $ src/test/fuzz/fee_rate
  ^c (ctrl-c)
  $ src/test/fuzz/integer
  ^c (ctrl-c)
  $ src/test/fuzz/multiplication_overflow
  ^c (ctrl-c)
  $ src/test/fuzz/string
  ^c (ctrl-c)
  ```

ACKs for top commit:
  MarcoFalke:
    ACK 44abf417eb 🏉

Tree-SHA512: 2b382a7bc8efdcc6dd8b79f1637f194ecdca3e522c6618ae6c4b0bf6f86d2e79b1bb1c7160522083600616d1ed509b2f577f3a512ea3a7825a0a3794578d9d90
2020-03-17 13:07:42 -04:00
Wladimir J. van der Laan
1d64dfe4fa
Merge #18364: random: remove getentropy() fallback for macOS < 10.12
f9f210d8de doc: fix GetTimeMicros() comment in random.cpp (fanquake)
a889711562 rand: remove getentropy() fallback for macOS < 10.12 (fanquake)

Pull request description:

  We [no longer support macOS < 10.12](https://github.com/bitcoin/bitcoin/pull/17550) (our binaries will not run), so remove the fallback for when `getentropy()` wasn't available. From the manpage:

  ```bash
  HISTORY
       The getentropy() function appeared in OSX 10.12
  ```

  Note that compiling on macOS you'll see a new unused function warning:
  ```bash
  random.cpp:256:13: warning: unused function 'GetDevURandom' [-Wunused-function]
  static void GetDevURandom(unsigned char *ent32)
              ^
  1 warning generated.
  ```

  This will likely be addressed as part of #17563.

ACKs for top commit:
  vasild:
    ACK f9f210d8 (code review, not tested)
  elichai:
    utACK f9f210d8de
  practicalswift:
    ACK f9f210d8de -- patch looks correct
  laanwj:
    ACK f9f210d8de
  hebasto:
    ACK f9f210d8de, tested on macOS 10.13.6: compiled

Tree-SHA512: 6bd2a721f23605a8bca0b7b51f42d628ebf92a18e74eb43194331ba745ee449223aff84119892781c40b188c70b75417447f4e390e3d9ac549292de2b1e8b308
2020-03-17 17:03:20 +01:00
MarcoFalke
8fc5f2bdf0
Merge #18366: tests: simplify next_block() function in feature_block
612a931d1a tests: simplify next_block() function in feature_block (John Newbery)

Pull request description:

  The solve parameter is unnecessary. Remove it and add comments.

ACKs for top commit:
  MarcoFalke:
    ACK 612a931d1a
  TheQuantumPhysicist:
    ACK 612a931

Looks good. Thanks for improving it 😄
  practicalswift:
    ACK 612a931d1a -- simpler is better and patch looks correct :)

Tree-SHA512: 25b4879842ea37a3f598be886f02ce4c2fb0b5a618d02b266dbd380f5cbfdd71a8bd35ddd9d6f2cf83920e37c02caf9955a841a02b17ba75ac63f88d32f8b60b
2020-03-17 10:23:58 -04:00
John Newbery
612a931d1a tests: simplify next_block() function in feature_block
The solve parameter is unnecessary. Remove it and add
comments.
2020-03-17 09:45:00 -04:00
fanquake
f9f210d8de
doc: fix GetTimeMicros() comment in random.cpp 2020-03-17 13:09:52 +08:00
fanquake
a889711562
rand: remove getentropy() fallback for macOS < 10.12 2020-03-17 13:00:31 +08:00
MarcoFalke
7060d2d97a
Merge #18350: test: Fix mining to an invalid target + ensure that a new block has the correct hash internally
7a6627ae87 Fix mining to an invalid target + ensure that a new block has the correct hash internally in Python tests (Samer Afach)

Pull request description:

  Test with block 47 in the `feature_block.py` creates a block with a hash higher than the target, which is supposed to fail. Now two issues exist there, and both have low probability of showing up:

  1. The creation is done with `while (hash < target)`, which is wrong, because hash = target is a valid mined value based on the code in the function `CheckProofOfWork()` that validates the mining target:
  ```
      if (UintToArith256(hash) > bnTarget)
          return false;
  ```
  2. As we know the hash stored in CBlock class in Python is stateful, unlike how it's in C++, where calling `CBlock::GetHash()` will actively calculate the hash and not cache it anywhere. With this, blocks that come out of the method `next_block` can have incorrect hash value when `solve=False`. This is because the `next_block` is mostly used with `solve=True`, and solving does call the function `rehash()` which calculates the hash of the block, but with `solve=False`, nothing calls that method. And since the work to be done in regtests is very low, the probably of this problem showing up is very low, but it practically happens (well, with much higher probability compared to issue No. 1 above).

  This PR fixes both these issues.

Top commit has no ACKs.

Tree-SHA512: f3b54d18f5073d6f1c26eab89bfec78620dda4ac1e4dde4f1d69543f1b85a7989d64c907e091db63f3f062408f5ed1e111018b842819ba1a5f8348c7b01ade96
2020-03-16 16:31:42 -04:00
Wladimir J. van der Laan
25424cf57e
Merge #18346: rpc: Document an RPCResult for all calls; Enforce at compile time
fac52253f8 rpc: Document an RPCResult for all calls; Enforce at compile time (MarcoFalke)
fadd99f610 rpc: Add missing newline in RPCResult description (MarcoFalke)

Pull request description:

  This documents the RPC Result (type and description, if applicable) everywhere it was missing. The patch can be reviewed with the `git diff` option `-W`/`--function-context`.

  Also, code won't compile without having an RPCResult documented.

ACKs for top commit:
  laanwj:
    Lightly tested ACK fac52253f8
  promag:
    Tested ACK fac52253f8, built and verified listunspent help output.

Tree-SHA512: af2c1af1432beb944993776026c320814bfaecaf202f47359f5758849096ca7051ec6560395a2cc6678dcc111e7c9cf4917d0f0b221bdcf3ed1642e14d0e5b3c
2020-03-16 18:04:08 +01:00
MarcoFalke
8662387309
Merge #17997: refactor: Remove mempool global from net
fa7fea3654 refactor: Remove mempool global from net (MarcoFalke)

Pull request description:

  To increase modularisation and simplify testing, remove the mempool global from net in favour of a mempool member.

  This is done in the same way it was done for the connection manager global.

ACKs for top commit:
  jnewbery:
    code review ACK fa7fea3654

Tree-SHA512: 0e3e1eefa8d6e46367bc6991d5f36c636b15ae4a3bda99b6fe6715db3240771c3d87943c6eb257d69f31929fa2f1d0973e14fc9d1353a27551dbe746eae36857
2020-03-16 11:05:45 -04:00
Wladimir J. van der Laan
a64e5bed6b
Merge #18344: doc: Fix nit in getblockchaininfo
fb15bfd99e Fix nit in getblockchaininfo (Steven Roose)

Pull request description:

  Noticed that the statistics are not always shown.

ACKs for top commit:
  laanwj:
    ACK fb15bfd99e
  promag:
    ACK fb15bfd99e.

Tree-SHA512: bccbfdff03107d14967f6530eec0bcada7ba8eb16c61b829119533a73f2ead742a0da6a473b7962b15e25cd685c8f155506ab16d4a95b20352d3fd1b4b0164a3
2020-03-16 13:19:35 +01:00
Wladimir J. van der Laan
9ed429c50a
Merge #18341: doc: Replace remaining literal BTC with CURRENCY_UNIT.
7df0cf719f Replace remaining literals BTC with CURRENCY_UNIT (Daniel Kraft)

Pull request description:

  This replaces one remaining instance of the literal `"BTC"` string with the `CURRENCY_UNIT` constant, as is done in most of the codebase already.

  After this change, no instance of literal `"BTC"` remains anywhere in the RPC help texts.

ACKs for top commit:
  MarcoFalke:
    ACK 7df0cf719f
  laanwj:
    ACK 7df0cf719f

Tree-SHA512: 7f7d52b366e084c93a7d6a3c45b1bbfc4f4f50bca6956594077e6d46295977c8cc18499232878869869c73a8ab9a1c41245029ae7425a87cec2ccb0cb52eea13
2020-03-16 13:14:10 +01:00
fanquake
69f4f2c433
Merge #18357: Fix missing header in sync.h
686c5456f2 Fix missing header in sync.h (João Barbosa)

Pull request description:

  `std::string` is referenced in `sync.h` but the relevant header is not explicitly included as required by current guideline. Furthermore on osx 10.14.6 with clang-900.0.31 the following error occurs:
  ```
  In file included from threadinterrupt.cpp:6:
  In file included from ./threadinterrupt.h:8:
  ./sync.h:206:21: error: implicit instantiation of undefined template 'std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >'
          std::string lockname;
  ```

ACKs for top commit:
  practicalswift:
    ACK 686c5456f2
  laanwj:
    ACK 686c5456f2

Tree-SHA512: 7c1acdfa5b0dd148d1114e14c9450d5907006e63e1a04e82ed8a1e29757925476e6f8ef6024b0c6d1bb596623115209ad580d5035be1e4785337bd01b738c9f2
2020-03-16 20:04:54 +08:00
Wladimir J. van der Laan
d31f92586a
Merge #18360: Bump transifex slug and update English translations for 0.20
2a1b85f3c5 tx: Bump transifex slug to 020x (Wladimir J. van der Laan)
82dd8860bb qt: Periodical translations update (Wladimir J. van der Laan)

Pull request description:

  Need to merge this so that translations for 0.20 can start.

Top commit has no ACKs.

Tree-SHA512: c78307eea3130b9bbc301f23790340e4c86a3f3877ab308bf67d9e1c9e977f7dda4b2cd83b96d9398b01dce616a6c962b98115123628bba35170eb0f301c4dd8
2020-03-16 11:29:26 +01:00
Wladimir J. van der Laan
2a1b85f3c5 tx: Bump transifex slug to 020x 2020-03-16 10:52:55 +01:00
Wladimir J. van der Laan
82dd8860bb qt: Periodical translations update 2020-03-16 10:51:11 +01:00
João Barbosa
686c5456f2 Fix missing header in sync.h 2020-03-15 22:43:39 +00:00
Hennadii Stepanov
e4d366788b
build: Drop needless EXTRA_DIST content
Some EXTRA_DIST content is needless since a git archive is used as the
source tarball.
2020-03-15 18:34:27 +02:00
practicalswift
44abf417eb tests: Add fuzzing harness for various functions taking std::string as input 2020-03-15 16:25:29 +00:00
practicalswift
d69145acb7 tests: Add fuzzing harness for MultiplicationOverflow(...) 2020-03-15 16:25:29 +00:00
practicalswift
7726f3bc46 tests: Add fuzzing harness for CFeeRate 2020-03-15 16:25:29 +00:00
practicalswift
0579a27630 tests: Add fuzzing harness for CBlockHeader 2020-03-15 15:19:50 +00:00
practicalswift
cb4eec13c0 tests: Add fuzzing harness for count_seconds(...) 2020-03-15 15:19:50 +00:00
MarcoFalke
d402c1e4d3
Merge #18345: test: Bump timeouts to avoid valgrind failures
fa19295250 test: Bump timeouts to avoid valgrind failures (MarcoFalke)

Pull request description:

  This should fix ci timeout issues such as:

  * https://travis-ci.org/github/bitcoin/bitcoin/jobs/661946972#L3109
  * https://travis-ci.org/github/bitcoin/bitcoin/jobs/662521570#L4922

ACKs for top commit:
  practicalswift:
    ACK fa19295250

Tree-SHA512: 150f804957575033a83fd47c68fd6adff2c11b110ec5803bd77f121256349805b595c39a3a5047738ec538d082ee38cebbcb6792c787ef22f56b8dd0d9618c1f
2020-03-15 10:14:40 -04:00
MarcoFalke
fa19295250
test: Bump timeouts to avoid valgrind failures 2020-03-14 22:15:52 -04:00
Wladimir J. van der Laan
67dfd18f44
Merge #16902: O(1) OP_IF/NOTIF/ELSE/ENDIF script implementation
e6e622e5a0 Implement O(1) OP_IF/NOTIF/ELSE/ENDIF logic (Pieter Wuille)
d0e8f4d5d8 [refactor] interpreter: define interface for vfExec (Anthony Towns)
89fb241c54 Benchmark script verification with 100 nested IFs (Pieter Wuille)

Pull request description:

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

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

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

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

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

Tree-SHA512: 1dcfac3411ff04773de461959298a177f951cb5f706caa2734073bcec62224d7cd103767cfeef85cd129813e70c14c74fa8f1e38e4da70ec38a0f615aab1f7f7
2020-03-14 21:03:45 +01:00
Ben Woosley
d056df033a
Replace std::to_string with locale-independent alternative 2020-03-14 12:23:01 -07:00
Samer Afach
7a6627ae87 Fix mining to an invalid target + ensure that a new block has the
correct hash internally in Python tests
2020-03-14 14:44:56 +01:00
Daniel Kraft
7df0cf719f Replace remaining literals BTC with CURRENCY_UNIT
This replaces one remaining instance of the literal "BTC" string with
the CURRENCY_UNIT constant, as is done in most of the codebase already.

The other remaining instance (which is just part of a log message and thus
not really user-visible) is just removed.

After this change, no instance of literal "BTC" remains anywhere in the
non-Qt and non-test codebase.
2020-03-14 09:24:21 +01:00
Wladimir J. van der Laan
7f8176a1eb
Merge #18204: descriptors: improve descriptor cache and cache xpubs
09e25071f4 Cache parent xpub inside of BIP32PubkeyProvider (Andrew Chow)
deb791c7ba Only cache xpubs that have a hardened last step (Andrew Chow)
f76733eda5 Cache the immediate derivation parent xpub (Andrew Chow)
58f54b686f Add DescriptorCache* read_cache and DescriptorCache* write_cache to Expand and GetPubKey (Andrew Chow)
66c2cadc91 Rename BIP32PubkeyProvider.m_extkey to m_root_extkey (Andrew Chow)
df55d44d0d Track the index of the key expression in PubkeyProvider (Andrew Chow)
474ea3b927 Introduce DescriptorCache struct which caches xpubs (Andrew Chow)

Pull request description:

  Improves the descriptor cache by changing it from a `std::vector<unsigned char>` to a newly introduced `DescriptorCache` class. Instead of serializing pubkeys and whatever else we would want to cache in a way that may not be backwards compatible, we instead create a `DescriptorCache` object and populate it. This object contains only an xpub cache. Since the only `PubkeyProvider` that used the cache is the `BIP32PubkeyProvider` we just have it store the xpubs instead of the pubkeys. This allows us to have both the parent xpub and the child xpubs in the same container. The map is keyed by `KeyOriginInfo`.

  Sine we are caching `CExtPubKey`s in `DescriptorCache`, `BIP32PubKeyProviders` can use the cached parent xpubs to derive the children if unhardened derivation is used in the last step. This also means that we can still derive the keys for a `BIP32PubkeyProvider` that has hardened derivation steps. When combined with descriptor wallets, this should allow us to be able to import a descriptor with an `xprv` and hardened steps and still be able to derive from it. In that sense, this is an alternative to #18163

  To test that this works, the tests have been updated to do an additional `Expand` at the `i + 1` position. This expansion is not cached. We then do an `ExpandFromCache` at `i + 1` and use the cache that was produced by the expansion at `i`. This way, we won't have the child xpubs for `i + 1` but we will have the parent xpubs. So this checks whether the parent xpubs are being stored and can be used to derive the child keys. Descriptors that have a hardened last step are skipped for this part of the test because that will always require private keys.

ACKs for top commit:
  instagibbs:
    code review re-re-ACK 09e25071f4
  Sjors:
    re-ACK 09e25071f4

Tree-SHA512: 95c8d0092274cdf115ce39f6d49dec767679abf3758d5b9e418afc308deca9dc6f67167980195bcc036cd9c09890bbbb39ec1dacffbfacdc03efd72a7e23b276
2020-03-13 22:45:09 +01:00
Wladimir J. van der Laan
e5cb0dffd5
Merge #18002: Abstract out script execution out of VerifyWitnessProgram()
c8e24ddce3 [REFACTOR] Abstract out script execution out of VerifyWitnessProgram() (Pieter Wuille)

Pull request description:

  This is a refactoring cherry-picked out of #17977. As it touches consensus code, I don't think this would ordinarily meet the bar for review cost vs benefit. However, it simplifies the changes for Taproot significantly, and if it's going to be necessitated by inclusion of that code, I may as well give it some additional attention by PRing it independently.

ACKs for top commit:
  fjahr:
    Re-ACK c8e24ddce3
  theStack:
    re-ACK c8e24ddce3
  Empact:
    Code Review Re-ACK c8e24ddce3
  ajtowns:
    ACK c8e24ddce3
  jnewbery:
    ACK c8e24ddce3
  jonatack:
    ACK c8e24dd

Tree-SHA512: 96c2aa5d2f9c7c802bcc008f5cde55b1dfedfaf42e34101331e6c0d594acdf6437661102dc939718f0877c20451336855dfbaa8aa8f57d9e722a7fa7329e3a46
2020-03-13 22:30:21 +01:00
MarcoFalke
fac52253f8
rpc: Document an RPCResult for all calls; Enforce at compile time 2020-03-13 15:36:15 -04:00
MarcoFalke
fadd99f610
rpc: Add missing newline in RPCResult description 2020-03-13 15:35:41 -04:00
Steven Roose
fb15bfd99e
Fix nit in getblockchaininfo 2020-03-13 14:18:24 +00:00
fanquake
3f9e6a3c1c
Merge #18316: util: HelpExampleRpc formatting
a33cffbeab util: HelpExampleRpc formatting fixup (Jon Atack)

Pull request description:

  Minor visual fixup of the HelpExampleRpc template; conforms to the JSON-RPC spec as per https://www.jsonrpc.org/specification#examples. (I'm... somewhat embarassed to open such a minor change, but this is what is shown in all the CLI/RPC help docs.)

ACKs for top commit:
  laanwj:
    ACK a33cffbeab

Tree-SHA512: 8f1dee080c224742fff60a33fec6f5fb1d59c9fa51f3f2a67bf2e1837dbfa25f12a69e34518936588940013b0e61f55378b4f1a571c47c3cb081ca5b245e1091
2020-03-13 10:23:19 +08:00
practicalswift
100213c5c2 util: Fail to parse space-only strings in ParseMoney(...) (instead of parsing as zero) 2020-03-12 14:15:10 +00:00
MarcoFalke
fa7fea3654
refactor: Remove mempool global from net
This refactor does two things:
* Pass mempool in to PeerLogicValidation
* Pass m_mempool around where needed
2020-03-12 09:23:56 -04:00
MarcoFalke
e2d36639ca
Merge #18228: test: Add missing syncwithvalidationinterfacequeue
faf6f156ff test: Add missing syncwithvalidationinterfacequeue (MarcoFalke)

Pull request description:

  The wallet rebroadcast functionality learns about new blocks via the validation interface queue. To avoid test failures such as https://ci.appveyor.com/project/DrahtBot/bitcoin/builds/31119387#L466 , we can sync with the queue before advancing the test.

ACKs for top commit:
  jonatack:
    ACK faf6f156 this makes sense; the fix was previously added to mempool_persist.py and wallet_zapwallettxes.py in #12217 and to wallet_balance.py in #16302. It is also used in src/test/validation_block_tests.cpp (processnewblock_signals_ordering) and src/bench/wallet_balance.cpp.

Tree-SHA512: d72fd4b597b669d8111007902b523e946712913cd6eea6f9a695b0f04ecbe2321d05019873af999a95b9e0aa0f5c140a17109b37503723e40c9eab24ec358eb7
2020-03-12 09:20:50 -04:00
MarcoFalke
2737197ff3
Merge #18213: test: Fix race in p2p_segwit
fa2cf85e6f test: Fix race in p2p_segwit (MarcoFalke)

Pull request description:

  Fixes #11696

Top commit has no ACKs.

Tree-SHA512: 09de07ea26236547586f5c373a0df2b68d84af5cfa8f40bd2ca9f951fc083c5f4b8a472a60668d99118bbd9f3942ec3d6a34f05944d47345acca41c95475bb27
2020-03-12 09:15:43 -04:00