Commit Graph

72 Commits

Author SHA1 Message Date
Andrew Poelstra fd88e48696
fuzz: remove AFL support
AFAICT we literally never used this; it was available only on the
bitcoin targets and not the honggfuzz ones; AFL has a broken dep
tree (or at least, requires some more MSRV pins that I did not care
to investigate).

Just remove it entirely.
2023-04-27 00:24:52 +00:00
Andrew Poelstra ab467cb091
fuzz: make hongfuzz fuzzing the default feature
This way you can run `cargo clippy --all` in the root, and `cargo hfuzz
run` without modification.
2023-04-27 00:24:52 +00:00
Andrew Poelstra 6f754df231
fuzz: add fuzzing README
also remove `set -e` from `fuzz-util.sh` because the README suggests
that users sometimes source this into their interactive shell.
2023-04-27 00:24:52 +00:00
Andrew Poelstra f093765efe
fix fuzz.sh and cycle.sh to use generated lists of targets 2023-04-27 00:24:52 +00:00
Andrew Poelstra 6534f22362
fuzz: auto-generate CI and Cargo.toml files 2023-04-27 00:24:52 +00:00
Andrew Poelstra 8021034d86
rename travis-fuzz.sh to fuzz.sh; partially patch CI 2023-04-27 00:24:52 +00:00
Andrew Poelstra 0be75f7edc
move hashes/fuzz into main fuzz/ directory 2023-04-27 00:24:52 +00:00
Andrew Poelstra 5a891dec2d
move bitcoin fuzz targets into bitcoin/ subdirectory 2023-04-27 00:24:52 +00:00
Andrew Poelstra e3111c748b
move bitcoin/fuzz into repo root; add to workspace
This allows testing the fuzztests and making sure that they compile and
tests pass, etc., just using `cargo test --all` in the root.
2023-04-27 00:24:48 +00:00
Tobin C. Harding b9643bf3e9 Import bitcoin_hashes crate into hashes
We would like to bring the `bitcoin_hashes` crate into the
`rust-bitcoin` repository.

Import `bitcoin_hashes` into `rust-bitocin/hashes`, doing so looses all
the commit history from the original crate but if we archive the
original repository then the history will be preserved. We maintain the
same version number obviously and in the changelog we note the change of
repository.

Commit hash that was tip of `bitcoin_hashes` at time of import:

 commit 54c16249e06cc6b7870c7fc07d90f489d82647c7

Includes making `embedded` and `fuzzing` per-crate i.e., move them into
`bitcoin` as hashes includes these also.

NOTE: Does _not_ enable fuzzing for `hashes` in CI.

Notes on CI:

Attempts to merge in the github actions from the hashes crate however reduces
coverage by not running hashes tests for beta toolchain. Some additional
work could be done to improve the CI to increase efficiency without
reducing coverage. Leaving for another day.
2022-11-08 08:58:09 +11:00
Tobin C. Harding b84e1d46c0 Move amount module out of util
Done as part of flattening the `util` module. Simply move the `amount`
module out of the `util` module and to the crate root. Justified by the
fact that the `Amount` type is more-or-less a "primitive" bitcoin type.
2022-10-21 10:16:49 +11:00
Tobin C. Harding facd8ba556 Move bip152 module to crate root
We are attempting to flatten the `util` module; move the `bip152` module
to the crate root out of `util`.

Currently `src/util/` is ignored by the formatter so this move causes
the `bip152` module to be formatted.
2022-10-19 06:40:33 +11:00
Andrew Poelstra 121db506fa
Merge rust-bitcoin/rust-bitcoin#1197: Add `Target` and `Work` types
02a2b43b2b Remove Default impl for Target and Work (Tobin C. Harding)
cb9893c4a9 Add Target and Difficulty types (Tobin C. Harding)

Pull request description:

  Ugh! 1600 lines of green and 1100 of red - my apologies.

  Currently we use the `Uint256` type for proof-of-work calculations. It was observed in #1181 that providing a public 256 bit integer type like this implies that it is a general  purpose integer type. We do not want to provide a general purpose integer type (see the 1000 arithmetic functions on stdlib integer types for why not :)

  Add two new opaque integer types `Target` and `Work`. These are the inverse of each other, both conceptually and mathematically.

  There is a lot of code in this PR, sorry about that. At a high level the PR does:

  - Add a `pow` module.
  - Put a modified version of  `Uint256` in `pow`, making it private.
  - Add two new wrapper types `Target` and `Work` that provide a very limited API specific to their use case. In particular there are methods on each to convert to the other.
  - Only implement methods that we use on each type.

  ### Note

  During development I got mixed up with the word "difficulty", I have discovered this has a very specific meaning in Bitcoin. Please see rustdocs on the `Target::difficulty` function for explanation of this term. For this reason we use the type `Work` defined as the inverse of target, and reserve "difficulty" for the Bitcoin concept.

ACKs for top commit:
  apoelstra:
    ACK 02a2b43b2b
  Kixunil:
    ACK 02a2b43b2b

Tree-SHA512: 4d701756a42b832f03b8d542f3a5278b4ca1d5983ffd7d4630577ebd4cc8f47029719f9018185e01fa459d8fb32426b5cb4d6b8d8b588ebbb7b65e4aeee94412
2022-10-17 18:24:11 +00:00
Riccardo Casatta 9eca3c58c5
Add script to launch fuzzing continuosly 2022-10-10 11:45:54 +02:00
Tobin C. Harding cb9893c4a9 Add Target and Difficulty types
Currently we use the `Uint256` type to represent two proof of work
integers, namely target and difficulty (work).

It would be nice to not have a public integer type that is not fully
implemented (i.e., does not implement arithmetic etc as do integer types
in stdlib). Instead of implementing all the stdlib functions we can
instead add two new wrapper types, since these are not general purpose
integers they do not need to implement anything we do not need to use.

- Add a `pow` module.
- Put a modified version of `Uint256` to `pow`.
- Add two new wrapper types `Target` and `Difficulty`.
- Only implement methods that we use on each type.

Note this patch does not remove the original `Uint256`, that will be
done as a separate patch.
2022-09-28 04:16:59 +10:00
Andrew Poelstra 433952d53a
Merge rust-bitcoin/rust-bitcoin#1279: Add fuzz test for PrefilledTransaction
b79c178ea8 Add fuzz test for PrefilledTransaction (Tobin Harding)

Pull request description:

  Add a simple deserialization fuzz test for `PrefilledTransaction`.

  Fixes: #460 (I think, I'm not sure if any of the other types need fuzzing?)

ACKs for top commit:
  apoelstra:
    ACK b79c178ea8
  Kixunil:
    ACK b79c178ea8

Tree-SHA512: 3e5cbda6b17c36f414bce05b562b5648d82433b185853e6c8aa33ec491b58e527626eb09caca2a988120329efd92dfd3aaad60ef99746d6ac41555160efeb9d6
2022-09-20 14:07:05 +00:00
Tobin Harding b79c178ea8 Add fuzz test for PrefilledTransaction
Add a simple deserialization fuzz test for `PrefilledTransaction`.
2022-09-16 13:02:24 +10:00
Tobin C. Harding 3f275f7f2b Remove code deprecated in v0.28.0
I believe we said we'd keep deprecated code around for two release
cycles so this code can  all be deleted now.
2022-09-15 13:29:02 +10:00
Tobin C. Harding 022730bd8d Add a workspace to the top level directory.
Create a directory `bitcoin` and move into it the following as is with
no code changes:

- src
- Cargo.toml
- contrib
- test_data
- examples

Then do:

- Add a workspace to the repository root directory.
- Add the newly created `bitcoin` crate to the workspace.
- Exclude `fuzz` and `embedded` crates from the workspace.
- Add a contrib/test.sh script that runs contrib/test.sh in each
  sub-crate
- Fix the bitcoin/contrib/test.sh script
2022-09-13 08:44:57 +10:00
Andrew Poelstra d25aba8ca0 fuzz: use travis-fuzz.sh in CI 2022-08-30 21:51:42 +00:00
Andrew Poelstra 0a32525862
fuzz: disable features in honggfuzz 2022-08-30 20:42:28 +00:00
Tobin C. Harding e1ae9d86bb Move the address module out of util
The identifier 'util' does not convey any information. We have a whole
bunch of modules inside the `util` module.

As part of work to reduce the amount of arbitrary things in the `util`
module move the `address` module to the crate root level.
2022-08-12 07:35:15 +10:00
eunoia_1729 89bd4b61a4
Modify from_script functions in address.rs to return result
Modify from_script functions to return result instead of option so that, in case of errors, there is more
information on what went wrong.

Resolves: #1022
2022-06-09 01:13:51 +05:30
Riccardo Casatta 106acdc3ac
Add fuzzing for Witness struct 2021-12-28 09:56:41 +01:00
Martin Habovstiak 0e1b99359c Added fuzz test for `Script::bytes_to_asm_fmt`
This adds fuzz target for `Script::bytes_to_asm_fmt` which could
panic due to overflow in the past. Fuzzing should decrease the risk of
other panics.
2021-09-30 15:06:18 +02:00
Matt Corallo 23ccc58d7b
Merge pull request #664 from RCasatta/fuzz_ci
Improve Fuzz CI
2021-09-29 23:47:08 +00:00
Andrew Poelstra 454379cdfa
Merge rust-bitcoin/rust-bitcoin#612: Fix `Uint256::increment` panics
5d71a9dd89 Correct input length check for uin128 fuzzer (Matt Corallo)
9c256cc88e Add a fuzz check for `Uint128::increment` (Matt Corallo)
a15f263c4e Move the `increment` fn into the uint macro to add it to Uint128 (Matt Corallo)
d52b88b525 Fix increment of Uint256 with carry (carolcapps)

Pull request description:

  This is #578 with review feedback addressed.

ACKs for top commit:
  apoelstra:
    ACK 5d71a9dd89
  sanket1729:
    ACK 5d71a9d

Tree-SHA512: 32e5ea6387943ecad8f190a0de336a545fda72b6ff7388d3479037a5f880434276a7d0607f5cf61710d45e984c01954f4e3199a60c542be48b397717afb3d406
2021-09-27 17:45:53 +00:00
Riccardo Casatta 200d5314bc
remove hfuzz input not used anymore 2021-09-24 11:51:40 +02:00
Martin Habovstiak a291fee23c Removed fuzztarget feature
It seems to be unused and when there's a need for it it's better to use
`--cfg fuzzing` as in `rust-secp256k1 ` and `bitcoin_hashes`.
2021-07-29 08:13:25 +02:00
Matt Corallo 5d71a9dd89 Correct input length check for uin128 fuzzer
In an earlier version of the uint128 fuzz target, there was a byte
which incidated the specific operation to test. However, that was
dropped for the much-more-effective approach of simply testing all
operations in each fuzz iteration.
2021-06-15 23:10:38 +00:00
Matt Corallo 9c256cc88e Add a fuzz check for `Uint128::increment` 2021-06-10 16:03:20 +00:00
Elichai Turkel efe1a55819
Use new inclusive range syntax 2020-10-08 17:08:51 +03:00
Andrew Poelstra c8633b5bce
Merge pull request #436 from LNP-BP/feat-u256u8
Big integers (Uint*) from byte slice array with `from_be_bytes`
2020-09-09 16:42:32 +00:00
Elichai Turkel a44ba2d878
Merge pull request #397 from stevenroose/script-iter
Improve the Instructions iterator for scripts
2020-09-09 19:06:05 +03:00
Dr Maxim Orlovsky 2fd353d5ab Big integers (Uint*) from byte slice array with `from_be_bytes` 2020-08-09 18:00:00 +02:00
Dr Maxim Orlovsky 19f88212af Fuzz tests for u128 modulo division 2020-07-21 14:54:56 +02:00
Matt Corallo 604f1aa56e Add fuzz target comparing native u128 to our Uint type 2020-04-30 19:22:49 -04:00
Steven Roose fea09a0a94
Improve the Instructions iterator for scripts
- Rename the `iter` method to `instructions`.
- Add `instructions_minimal` for minimal-enforced iteration.
- Iterator has `Result<Instruction, Error>` as items.
2020-04-11 23:52:26 +01:00
Kiminuo d8223bb73c Update travis-fuzz.sh to check that fuzz input file names are allowed on Windows systems 2019-12-08 16:42:43 +00:00
Kiminuo 1b617b8f54 Rename fuzz input file names to allow repo cloning on Windows [fixes #350] 2019-12-08 16:42:43 +00:00
Steven Roose 3c390ceb93
Add fuzzer for Address::from_script 2019-08-15 22:29:10 +01:00
Riccardo Casatta 7d6687451a use BTreeMap instead of HashMap to always serialize the same (#310)
* use BTreeMap instead of HashMap to always serialize the same

* fix rust 1.22 error

* psbt fuzz roundtrip

* psbt fuzz roundtrip on our ser
2019-08-09 17:03:12 +02:00
Andrew Poelstra abb9210c04 make `VarInt::len` and `Transaction::get_weight` return a usize 2019-07-11 17:14:05 +00:00
Steven Roose 30201f3924
Remove Decimal and replace strason with serde_json 2019-06-13 18:29:16 +01:00
Andrew Poelstra 5d7e6bb7a4
Merge pull request #272 from TheBlueMatt/2019-05-net-cleanups
Fix DoS in RawNetworkMessage Deserialization
2019-06-07 11:53:31 +00:00
Matt Corallo 0904935f19 Switch Travis fuzzing to 30 seconds per target from an iter count. 2019-06-07 07:11:21 -04:00
Andrew Poelstra a6c1eacd70
Merge pull request #270 from stevenroose/signed-amount
Add Amount and SignedAmount
2019-06-07 09:16:02 +00:00
Matt Corallo 1b2dc9d6b0 Rename deserialize_raw_network_message to make my afl scripts happy 2019-06-05 07:49:19 -04:00
Carl Dong 836fdce475 fuzz: Add fuzzer for RawNetworkMessage. 2019-06-05 07:49:19 -04:00
Steven Roose 7af134ce79
Add fuzz target for Amount parsing 2019-06-04 12:54:12 +01:00