Build BDB utilities
To install the binaries we need to build with just `install` instead of `install_lib` and `install_include`, this will install everything.
Then the binaries will be moved to a folder in `zcutil` directory. We can just leave them in staging however the user might have a hard time to find them there.
Closes https://github.com/zcash/zcash/issues/4537
Add options and help to AFL scripts
Closes https://github.com/zcash/zcash/issues/4315
For reference here is how the help of each command is script:
**afl-get.sh**:
```
$ ./zcutil/afl/afl-get.sh --help
Obtains and builds a copy of AFL from source.
Usage:
./zcutil/afl/afl-get.sh --afl-install=AFL_INSTALL_DIR
OPTIONS:
-h, --help Print this help message
-i, --afl-install Directory where AFL is going to be installed
EXAMPLE:
./zcutil/afl/afl-get.sh -i /tmp/afl
$
```
**afl-build.sh**:
```
$ ./zcutil/afl/afl-build.sh --help
A wrapper around ./zcutil/build.sh for instrumenting the build with AFL.
You may obtain a copy of AFL using ./zcutil/afl/afl-get.sh.
Additional arguments are passed-through to build.sh.
Usage:
./zcutil/afl/afl-build.sh --afl-install=AFL_INSTALL_DIR --fuzz-case=FUZZ_CASE [ OPTIONS ... ] [ ARGUMENTS ... ]
OPTIONS:
-a, --harden Turn off AFL_HARDEN. Default: 1
-c, --configure-flags Pass this flags to ./configure. Default: --enable-tests=no --enable-fuzz-main
-f, --fuzz-case Options are: CheckBlock, DecodeHexTx, DeserializeAddrMan, DeserializeTx or ReadFeeEstimates
-h, --help Print this help message
-l, --afl-log Directory to save AFL logs. Default: /home/oxarbitrage/zcash/zcash4/zcash
-i, --afl-install Directory where AFL is installed
-z, --zcutil The zcutil directory. Default /home/oxarbitrage/zcash/zcash4/zcash/zcutil
ARGUMENTS:
By default we are passing to build.sh the following flags:
CC=/home/oxarbitrage/zcash/zcash4/zcash/zcutil/afl/zcash-wrapper-gcc
CXX=/home/oxarbitrage/zcash/zcash4/zcash/zcutil/afl/zcash-wrapper-g++
EXAMPLE:
./zcutil/afl/afl-build.sh -i /tmp/afl -f DecodeHexTx
$
```
**afl-run.sh**:
```
$ ./zcutil/afl/afl-run.sh --help
Start fuzzing a case in a previously zcashd built for AFL.
Additional arguments are passed-through to AFL.
Usage:
./zcutil/afl/afl-run.sh --afl-install=AFL_INSTALL_DIR --fuzz-case=FUZZ_CASE [ ARGUMENTS... ]
OPTIONS:
-f, --fuzz-case Options are: CheckBlock, DecodeHexTx, DeserializeAddrMan, DeserializeTx or ReadFeeEstimates
-h, --help Print this help message
-i, --afl-install Directory where AFL is installed
EXAMPLE:
./zcutil/afl/afl-run.sh -i /tmp/afl -f DecodeHexTx
$
```
**afl-getbuildrun.sh**:
```
$ ./zcutil/afl/afl-getbuildrun.sh --help
Builds AFL and an instrumented zcashd, then begins fuzzing.
This script must be run from within the top level directory of a zcash clone.
Additional arguments are passed-through to AFL.
Usage:
./zcutil/afl/afl-getbuildrun.sh --fuzz-case=FUZZ_CASE [ OPTIONS ... ] [ ARGUMENTS... ]
OPTIONS:
-f, --fuzz-case Options are: CheckBlock, DecodeHexTx, DeserializeAddrMan, DeserializeTx or ReadFeeEstimates
-h, --help Print this help message
-i, --afl-install Directory where AFL is installed. Default: /home/oxarbitrage/zcash/zcash4/zcash/afl-temp
EXAMPLE:
./zcutil/afl/afl-getbuildrun.sh -f DecodeHexTx
$
```
zcutil/fetch-params.sh unneeded --testnet arg should warn user
If fetch-params.sh user doesn't know that testnet and mainnet params are the same, and user specifies --testnet, it's confusing that the argument is ignored.
Add AFL in zcutil (with all-in-one script)
Supersedes #4156 and #4167.
Fuzzing targets and input sets are defined by the contents of directories in `./src/fuzzing/`. Inside the directory, there's a `fuzz.cpp` and `fuzz.h` with a `main()` function that will replace `zcashd`'s actual `main()` as well as an `input` subdirectory containing the inputs, one per file. To just run a fuzzer, you can, for example...
```
make clean # if you've previously build zcashd without AFL instrumentation
./zcutil/afl/afl-getbuildrun.sh DecodeHexTx
```
Alternatively you can...
```
./zcutil/afl/afl-get.sh /tmp/afl # (or wherever you want to build AFL)
./zcutil/afl/afl-build.sh /tmp/afl DecodeHexTx -j$(nproc)
./zcutil/afl/afl-run.sh /tmp/afl DecodeHexTx
```
Run `make clean` whenever you switch between a normal build and an AFL-instrumented build.