Commit graph

321 commits

Author SHA1 Message Date
practicalswift
f9b22e3bdb tests: Add fuzzing harness for CCoinsViewCache 2020-05-25 10:05:06 +00:00
Russell Yanofsky
691c817b34 Add util::Ref class as temporary alternative for c++17 std::any
This commit does not change behavior
2020-05-13 16:20:13 -04:00
Wladimir J. van der Laan
f763283b65
Merge #18512: Improve asmap checks and add sanity check
748977690e Add asmap_direct fuzzer that tests Interpreter directly (Pieter Wuille)
7cf97fda15 Make asmap Interpreter errors fatal and fuzz test it (Pieter Wuille)
c81aefc537 Add additional effiency checks to sanity checker (Pieter Wuille)
fffd8dca2d Add asmap sanity checker (Pieter Wuille)
5feefbe6e7 Improve asmap Interpret checks and document failures (Pieter Wuille)
2b3dbfa5a6 Deal with decoding failures explicitly in asmap Interpret (Pieter Wuille)
1479007a33 Introduce Instruction enum in asmap (Pieter Wuille)

Pull request description:

  This improves/documents the failure cases inside the asmap interpreter. None of the changes are bug fixes (they only change behavior for corrupted asmap files), but they may make things easier to follow.

  In a second step, a sanity checker is added that effectively executes every potential code path through the asmap file, checking the same failure cases as the interpreter, and more. It takes around 30 ms to run for me for a 1.2 MB asmap file.

  I've verified that this accepts asmap files constructed by https://github.com/sipa/asmap/blob/master/buildmap.py with a large dataset, and no longer accepts it with 1 bit changed in it.

ACKs for top commit:
  practicalswift:
    ACK 748977690e modulo feedback below.
  jonatack:
    ACK 748977690e code review, regular build/tests/ran bitcoin with -asmap, fuzz build/ran both fuzzers overnight.
  fjahr:
    ACK 748977690e

Tree-SHA512: d876df3859735795c857c83e7155ba6851ce839bdfa10c18ce2698022cc493ce024b5578c1828e2a94bcdf2552c2f46c392a251ed086691b41959e62a6970821
2020-05-06 14:59:28 +02:00
MarcoFalke
0a729b0e42
Merge #18783: tests: Add fuzzing harness for MessageSign, MessageVerify and other functions in util/message.h
38e49ded8b tests: Add fuzzing harness for MessageSign, MessageVerify and other functions in util/message.h (practicalswift)

Pull request description:

  Add fuzzing harness for `MessageSign`, `MessageVerify` and other functions in `util/message.h`.

  See [`doc/fuzzing.md`](https://github.com/bitcoin/bitcoin/blob/master/doc/fuzzing.md) for information on how to fuzz Bitcoin Core. Don't forget to contribute any coverage increasing inputs you find to the [Bitcoin Core fuzzing corpus repo](https://github.com/bitcoin-core/qa-assets).

  Happy fuzzing :)

ACKs for top commit:
  vasild:
    utACK 38e49ded8b

Tree-SHA512: 4f83718365d9c7e772a4ccecb31817bf17117efae2bfaf6e9618ff17908def0c8b97b5fa2504d51ab38b2e6f82c046178dd751495cc37ab4779c0b1ac1a4d211
2020-05-04 09:02:21 -04:00
practicalswift
13c1f6b24f tests: Add fuzzing harness for IsRBFOptIn(...) 2020-04-30 13:19:24 +00:00
practicalswift
3439c88a5d tests: Add fuzzing harness for CBlockPolicyEstimator 2020-04-30 13:19:24 +00:00
practicalswift
38e49ded8b tests: Add fuzzing harness for MessageSign, MessageVerify and other functions in util/message.h 2020-04-27 17:06:59 +00:00
practicalswift
32b6b386a5 tests: Sort fuzzing harnesses 2020-04-26 20:25:40 +00:00
practicalswift
103b6ecce0 tests: Add fuzzing coverage for TransactionErrorString(...) 2020-04-26 20:23:56 +00:00
practicalswift
a19598cf98 tests: Add fuzzing harness for functions in system.h (ArgsManager) 2020-04-26 20:23:56 +00:00
practicalswift
fd8e99da57 tests: Add fuzzing harness for functions in primitives/transaction.h 2020-04-24 12:16:03 +00:00
MarcoFalke
c4c3f110eb
Merge #18190: tests: Add fuzzing harness for Golomb-Rice coding (GolombRiceEncode/GolombRiceDecode)
69749fbe6a tests: Add fuzzing harness for Golomb-Rice coding (GolombRiceEncode/GolombRiceDecode) (practicalswift)

Pull request description:

  Add fuzzing harness for Golomb-Rice coding (`GolombRiceEncode`/`GolombRiceDecode`).

  Test this PR using:

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

Top commit has no ACKs.

Tree-SHA512: 1b26512301b8c22ab3b804d9b9e4baf933f26f8c05e462d583863badcec7e694548a34849a0d7c4ff7d58b19f6338b51819976ecf642bc4659b04ef71182d748
2020-04-20 15:32:41 -04:00
practicalswift
69749fbe6a tests: Add fuzzing harness for Golomb-Rice coding (GolombRiceEncode/GolombRiceDecode) 2020-04-20 14:57:48 +00:00
MarcoFalke
4702cadca9
Merge #17954: wallet: Remove calls to Chain::Lock methods
48973402d8 wallet: Avoid use of Chain::Lock in CWallet::GetKeyBirthTimes (Russell Yanofsky)
e958ff9ab5 wallet: Avoid use of Chain::Lock in CWallet::CreateTransaction (Russell Yanofsky)
c0d07dc4cb wallet: Avoid use of Chain::Lock in CWallet::ScanForWalletTransactions (Russell Yanofsky)
1be8ff280c wallet: Avoid use of Chain::Lock in rescanblockchain (Russell Yanofsky)
3cb85ac594 wallet refactor: Avoid use of Chain::Lock in CWallet::RescanFromTime (Russell Yanofsky)
f7ba881bc6 wallet: Avoid use of Chain::Lock in listsinceblock (Russell Yanofsky)
bc96a9bfc6 wallet: Avoid use of Chain::Lock in importmulti (Russell Yanofsky)
25a9fcf9e5 wallet: Avoid use of Chain::Lock in importwallet and dumpwallet (Russell Yanofsky)
c1694ce6bb wallet: Avoid use of Chain::Lock in importprunedfunds (Russell Yanofsky)
ade5f87971 wallet refactor: Avoid use of Chain::Lock in qt wallettests (Russell Yanofsky)
f6da44ccce wallet: Avoid use of Chain::Lock in tryGetTxStatus and tryGetBalances (Russell Yanofsky)
bf30cd4922 refactor: Add interfaces::FoundBlock class to selectively return block data (Russell Yanofsky)

Pull request description:

  This is a set of changes updating wallet code to make fewer calls to `Chain::Lock` methods, so the `Chain::Lock` class will be easier to remove in #16426 with fewer code changes and small changes to behavior.

ACKs for top commit:
  MarcoFalke:
    re-ACK 48973402d8, only change is fixing bug 📀
  fjahr:
    re-ACK 48973402d8, reviewed rebase and changes since last review, built and ran tests locally
  ariard:
    Coce Review ACK 4897340, only changes are one suggested by last review on more accurate variable naming, human-readable output, args comments in `findCommonAncestor`

Tree-SHA512: cfd2f559f976b6faaa032794c40c9659191d5597b013abcb6c7968d36b2abb2b14d4e596f8ed8b9a077e96522365261299a241a939b3111eaf729ba0c3ef519b
2020-04-14 07:18:12 -04:00
MarcoFalke
10358a381a
Merge #17737: Add ChainstateManager, remove BlockManager global
c9017ce3bc protect g_chainman with cs_main (James O'Beirne)
2b081c4568 test: add basic tests for ChainstateManager (James O'Beirne)
4ae29f5f0c use ChainstateManager to initialize chainstate (James O'Beirne)
5b690f0aae refactor: move RewindBlockIndex to CChainState (James O'Beirne)
89cdf4d569 validation: introduce unused ChainstateManager (James O'Beirne)
8e2ecfe249 validation: add CChainState.m_from_snapshot_blockhash (James O'Beirne)

Pull request description:

  This is part of the [assumeutxo project](https://github.com/bitcoin/bitcoin/projects/11):

  Parent PR: #15606
  Issue: #15605
  Specification: https://github.com/jamesob/assumeutxo-docs/tree/master/proposal

  ---

  This changeset introduces `ChainstateManager`, which is responsible for creating and managing access to multiple chainstates. Until we allow chainstate creation from UTXO snapshots (next assumeutxo PR?) it's basically unnecessary, but it is a prerequisite for background IBD support.

  Changes are also made to the initialization process to make use of `g_chainman` and thus clear the way for multiple chainstates being loaded on startup.

  One immediate benefit of this change is that we no longer have the `g_blockman` global, but instead have the ChainstateManager inject a reference of its shared BlockManager into any chainstate it creates.

  Another immediate benefit is that uses of `ChainActive()` and `ChainstateActive()` are now covered by lock annotations. Because use of `g_chainman` is annotated to require cs_main, these two functions subsequently follow.

  Because of whitespace changes, this diff looks bigger than it is. E.g., 4813167d98 is most easily reviewed with
  ```sh
  git show --color-moved=dimmed_zebra -w 4813167d98
  ```

ACKs for top commit:
  MarcoFalke:
    re-ACK c9017ce3bc 📙
  fjahr:
    Code Review Re-ACK c9017ce3bc
  ariard:
    Code Review ACK c9017ce
  ryanofsky:
    Code review ACK c9017ce3bc. No changes since last review other than a straight rebase

Tree-SHA512: 3f250d0dc95d4bfd70852ef1e39e081a4a9b71a4453f276e6d474c2ae06ad6ae6a32b4173084fe499e1e9af72dd9007f4a8a375c63ce9ac472ffeaada41ab508
2020-04-10 13:02:01 -04:00
MarcoFalke
405713d00f
Merge #18529: Add fuzzer version of randomized prevector test
b1d24d1d03 Reorder the test instructions by number (Pieter Wuille)
c2ccadc26a Merge and generalize case 3 and case 6 (Pieter Wuille)
402ad5aaca Only run sanity check once at the end (Pieter Wuille)
eda8309bfc Assert immediately rather than caching failure (Pieter Wuille)
55608455cb Make a fuzzer-based copy of the prevector randomized test (Pieter Wuille)

Pull request description:

  The current prevector test effectively randomly generates a number of operations to perform on a prevector and a normal vector, and checks consistency between the two.

  By converting this into a fuzzer the operations can be targetted rather than random.

ACKs for top commit:
  MarcoFalke:
    ACK b1d24d1d03 🍬

Tree-SHA512: 2b5c62abcd5fee94f42db03400531484d98c59e7f4308e0e683c61aabcd9ce42f85c5d058d2d5e7f8221124f71d2112b6a5f3c80e5d0fdae265a70647747e92f
2020-04-09 15:00:57 -04:00
Pieter Wuille
748977690e Add asmap_direct fuzzer that tests Interpreter directly 2020-04-08 16:26:06 -07:00
MarcoFalke
661bd5dea3
Merge #18363: tests: Add fuzzing harness for HTTPRequest, libevent's evhttp and related functions
cdfb8e7afa tests: Add fuzzing harness for HTTPRequest, libevent's evhttp and related functions (practicalswift)

Pull request description:

  Add fuzzing harness for `HTTPRequest`, `libevent`'s `evhttp` and related functions.

ACKs for top commit:
  laanwj:
    ACK cdfb8e7afa

Tree-SHA512: da481afed5eb3232d3f3d0583094e56050e6234223dfcb356d8567fe0616336eb1b78c5e6821325fc9767e385e5dfaf3c96f0d35ffdb67f18d74f9a9a9464e24
2020-04-09 02:45:37 +08:00
MarcoFalke
3410fe6887
Merge #18521: fuzz: Add process_messages harness
fa6a008434 fuzz: Add process_messages harness (MarcoFalke)

Pull request description:

ACKs for top commit:
  practicalswift:
    Tested ACK fa6a008434

Tree-SHA512: 2d8788308c7f45c97ca003378f58a9d51f51265958557a65e5e505b1666b4cb928f0d010622870175090a0ad25e2d10b41f26f4eef14b6ff334a024baa250f8c
2020-04-09 00:14:31 +08:00
MarcoFalke
bfef72d0fb
Merge #18565: tests: Add fuzzing harnesses for classes/functions in policy/fees.h, checkqueue.h and cuckoocache.h. Add fuzzing coverage.
283bd72156 tests: Add coverage of {,Incremental}DynamicUsage(const std::set<X, Y>& s) to existing fuzzer (practicalswift)
bf76000493 tests: Add fuzzing harness for classes/functions in cuckoocache.h (practicalswift)
57890b2555 tests: Add fuzzing harness for classes/functions in checkqueue.h (practicalswift)
2df5701e90 tests: Add coverage of GetVirtualTransactionSize(...) to existing fuzzer (practicalswift)
7b9a2dc864 tests: Add fuzzing harness for AdditionOverflow(...) (practicalswift)
44fb2a596b tests: Add fuzzing harness for FeeFilterRounder (practicalswift)

Pull request description:

  Includes:

  ```
  tests: Add fuzzing harness for FeeFilterRounder
  tests: Add fuzzing harness for classes/functions in checkqueue.h
  tests: Add fuzzing harness for classes/functions in cuckoocache.h
  tests: Add coverage of {,Incremental}DynamicUsage(const std::set<X, Y>& s) to existing fuzzer
  tests: Add coverage of GetVirtualTransactionSize(...) to existing fuzzer
  tests: Add fuzzing harness for AdditionOverflow(...)
  ```

  See [`doc/fuzzing.md`](https://github.com/bitcoin/bitcoin/blob/master/doc/fuzzing.md) for information on how to fuzz Bitcoin Core.

ACKs for top commit:
  MarcoFalke:
    ACK 283bd72156

Tree-SHA512: 2361edfb5c47741b22d9fb996836c5250c5a26bc5e956039ea6a0c55ba2d36c78f241d66f85bc02f5b85b9b83d5fde56a5c4702b9d1b7ac4a9a3ae391ca79eaa
2020-04-08 23:34:19 +08:00
practicalswift
bf76000493 tests: Add fuzzing harness for classes/functions in cuckoocache.h 2020-04-08 14:45:27 +00:00
practicalswift
57890b2555 tests: Add fuzzing harness for classes/functions in checkqueue.h 2020-04-08 14:45:27 +00:00
practicalswift
7b9a2dc864 tests: Add fuzzing harness for AdditionOverflow(...) 2020-04-08 14:45:27 +00:00
practicalswift
44fb2a596b tests: Add fuzzing harness for FeeFilterRounder 2020-04-08 14:45:27 +00:00
Russell Yanofsky
2276339a17 Add test for UnregisterAllValidationInterfaces bug
Bug in MainSignalsInstance::Clear could cause validation interface callbacks to
be deleted during execution if UnregisterAllValidationInterfaces was called
more than once.

Bug was introduced in https://github.com/bitcoin/bitcoin/pull/18524 and is
fixed by https://github.com/bitcoin/bitcoin/pull/18551
2020-04-07 12:54:41 -07:00
Pieter Wuille
55608455cb Make a fuzzer-based copy of the prevector randomized test 2020-04-06 14:25:25 -07:00
practicalswift
cdfb8e7afa tests: Add fuzzing harness for HTTPRequest, libevent's evhttp and related functions 2020-04-06 13:58:51 +00:00
fanquake
516ebe8a62
Merge #18514: test: remove rapidcheck integration and tests
9e071b0089 test: remove rapidcheck integration and tests (fanquake)

Pull request description:

  Whilst the property tests are interesting, ultimately [rapidcheck](https://github.com/emil-e/rapidcheck) integration in this repository has not gained much traction. We have a limited number of tests, and they are rarely (if ever) run. Have discussed this with Chris Stewart.

ACKs for top commit:
  practicalswift:
    ACK 9e071b0089

Tree-SHA512: d0c12af3163382eee8413da420c63e39265a7b700709a05d518445832d45e049aed9508e32524db5228fe3ac114609a00b7bb890be047c07032e44a5ef4611e9
2020-04-06 09:48:21 +08:00
MarcoFalke
fa6a008434
fuzz: Add process_messages harness 2020-04-05 10:46:24 +08:00
Harris
691e2a7af7
build: create test_fuzz library from src/test/fuzz/fuzz.cpp 2020-04-05 01:01:13 +02:00
MarcoFalke
4839560ee1
Merge #18407: tests: Add proof-of-work fuzzing harness
acf269e146 tests: Add proof-of-work fuzzing harness (practicalswift)

Pull request description:

  Add proof-of-work fuzzing harness.

Top commit has no ACKs.

Tree-SHA512: dcdfa211cf1ec3018b61f378bb0f95793bbbe5d00e2f4d17f9db2c7263fe8ce919760c56cae7122c62c82e05c90e7056eb1778871674bdb3c42869e5fe4c2b60
2020-04-05 04:41:07 +08:00
practicalswift
acf269e146 tests: Add proof-of-work fuzzing harness 2020-04-04 17:23:50 +00:00
fanquake
9e071b0089
test: remove rapidcheck integration and tests 2020-04-03 22:47:59 +08:00
Russell Yanofsky
bf30cd4922 refactor: Add interfaces::FoundBlock class to selectively return block data
FoundBlock class allows interfaces::Chain::findBlock to return more block
information without having lots of optional output parameters. FoundBlock class
is also used by other chain methods in upcoming commits.

There is mostly no change in behavior. Only exception is
CWallet::RescanFromTime now throwing NonFatalCheckError instead of
std::logic_error.
2020-03-31 08:36:02 -05:00
MarcoFalke
fa3cc0bfc4
test: Remove unsafe BOOST_TEST_MESSAGE 2020-03-30 15:18:42 -04:00
practicalswift
11a520f679 tests: Add fuzzing harness for functions/classes in random.h 2020-03-29 13:17:04 +00:00
practicalswift
f205cf7fef tests: Add fuzzing harness for functions/classes in span.h 2020-03-29 13:17:04 +00:00
practicalswift
9718f38f54 tests: Add fuzzing harness for functions/classes in merkleblock.h 2020-03-29 13:17:04 +00:00
practicalswift
a16ea051f9 tests: Add fuzzing harness for functions/classes in flatfile.h 2020-03-29 13:17:04 +00:00
practicalswift
7834c3b9ec tests: Add fuzzing harness for functions/classes in chain.h 2020-03-26 21:21:34 +00:00
practicalswift
d7930c4326 tests: Add fuzzing harness for functions/classes in protocol.h 2020-03-26 21:21:34 +00:00
practicalswift
102f3267e9 tests: Add fuzzing harness for classes/functions in blockfilter.h 2020-03-24 17:01:54 +00:00
practicalswift
4308aa67e3 tests: Add fuzzing harness for functions in net_permissions.h 2020-03-24 14:39:23 +00:00
practicalswift
43ff0d91f8 tests: Add fuzzing harness for functions in timedata.h 2020-03-24 14:39:23 +00:00
practicalswift
a8695db785 tests: Add fuzzing harness for functions in addrdb.h 2020-03-24 14:39:23 +00:00
practicalswift
5e47b19e50 tests: Add harness which fuzzes EvalScript and VerifyScript using a fuzzed signature checker 2020-03-17 19:10:59 +00:00
James O'Beirne
2b081c4568 test: add basic tests for ChainstateManager
Feedback incorporated from Russell Yanofsky.

Co-authored-by: MarcoFalke <falke.marco@gmail.com>
2020-03-17 14:03:40 -04: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