Commit Graph

115 Commits

Author SHA1 Message Date
yancy 4576f4ba69 Remove fuzz rust version
Fuzz is not compatible with the workspace MSRV.
2024-07-01 14:17:14 -05:00
Tobin C. Harding 31a2324bfd
Fix fuzz script
Currently the `fuzz.sh` script fails with "unbound variable" if called
without any arguments, this has gone undetected since we added `set
-euox pipefail` because in CI we always call it with an argument.

Use chatGPT to fix the bug.

Fix: #2924
2024-06-27 08:49:10 +10:00
Tobin C. Harding a42bcdc22e
Remove usage of blockdata from paths
the `blockdata` directory is code organisation thing, all the
types/modules are re-exported from other places. In preparation for, and
to make easier, the `primitives` crate smashing work - remove all
explicit usage of `blockdata`.

Note that the few instances remain as they seem required e.g.,

  `pub(in crate::blockdata::script)`

Refactor only, no logic changes.
2024-06-20 12:00:22 +10:00
Shing Him Ng e7f33a2a12 Update PushBytes::read_scriptint(x) to x.read_scriptint() 2024-06-16 17:11:33 -05:00
Tobin C. Harding 6b7d02e5ae
Add inherent functions to hashes
Currently we have a trait `Hash` that is required for `Hmac`, `Hkdf`,
and other use cases. However, it is unegonomic for users who just want
to do a simple hash to have to import the trait.

Add inherent functions to all hash types including those created with
the new wrapper type macros.

This patch introduces some duplicate code but we are trying to make
progress in the hashes API re-write. We can come back and de-dublicate
later.

Includes making `to_byte_array`,`from_byte_array`, `as_byte_array`, and
`all_zeros` const where easily possible.
2024-06-14 10:17:00 +10:00
Fmt Bot 8e9be3beed 2024-06-09 automated rustfmt nightly 2024-06-09 01:09:23 +00:00
Bruno Garcia 55cbae9c2f fuzz: add more coverage for `deserialize_psbt` 2024-06-06 13:49:32 -03:00
Andrew Poelstra 741589c5ad
Merge rust-bitcoin/rust-bitcoin#2828: fuzz: add more coverage for `deserialize_block`
ee30eaa81b fuzz: add more coverage for `deserialize_block` (Bruno Garcia)

Pull request description:

  This PR adds more coverage for the `deserialize_block` target. First, it serializes the block and compares with the data provided and then call some block functions to ensure they run without any issue.

ACKs for top commit:
  apoelstra:
    ACK ee30eaa81b Thanks!

Tree-SHA512: db6c7befa7b429267e9b28fb7910d2b9e8d462e22c791b544b1aa528c7ba4f8e1cd32e1276c67d3da1f97ce484e7ed19ec20b10d2030f2977fd8f855cf510ffe
2024-06-03 13:57:09 +00:00
Bruno Garcia ee30eaa81b fuzz: add more coverage for `deserialize_block` 2024-06-02 15:44:35 -03:00
Divyansh Gupta a336ec0dda refactor(script): move `read_scriptint` to `PushBytes` & create `read_int` function
* Moved read_scriptint method to Push_Bytes struct
 * Created Instruction::read_int method
fix #1547
2024-05-28 15:36:17 +05:30
Andrew Poelstra 830a6e1b0c
fuzz: delete CBOR test
We were using an outdated CBOR crate for MSRV reasons. But this old
crate is causing suprious test failures. So delete it. (Sadly, updating
the crate doesn't fix the issue, replacing it with ciborium breaks our
MSRV tests because it needs a more recent `half` dependency, and
replacing it with `minicbor` doesn't work because minicbor is not based
on serde. So we don't really have any options.)

In general, I am suspicious of this decode-then-reencode test. CBOR has
some ambiguity in integer encoding. Empirically it has seemed to
work for a long time, but this seems more like an indictment of our test
than a positive result.

Also, round-trip testing serde encoding of a byte vector is probably not
a great use of our fuzz resources. I don't believe we have ever had a
problem with this.

Fixes #2801
2024-05-24 14:32:19 +00:00
Andrew Poelstra 91eb50b2db
fuzz: add lint to generate-files.sh
In #2785 I modified fuzz/Cargo.toml without updating the Cargo.toml
generating script. Oops. Fix that.
2024-05-24 14:30:49 +00:00
Andrew Poelstra 5ad7c245e3
cargo: whitelist all cfgs used in this repo 2024-05-22 13:32:24 +00:00
Jose Storopoli 021bea89bb
ci: shellcheck checks 2024-05-11 18:08:53 +00:00
Tobin C. Harding c750be2352
fuzz: Update generate-files.sh
Recently we modified the fuzz job manually and forgot about the
`generate-files.sh` file.

Update the script to match the current CI job, running it now produces
the same file `cron-daily-fuzz.sh`.
2024-05-02 16:02:28 +10:00
Jose Storopoli b355740da4
chore: format and standardize all markdowns files
according to the github flavor
(https://github.github.com/gfm/)
2024-04-27 06:29:23 -03:00
Andrew Poelstra 133531fab7
Merge rust-bitcoin/rust-bitcoin#2635: Add set -euo pipefail
3fa3d37c21 Add set -euo pipefail (Tobin C. Harding)

Pull request description:

  Add `euo pipefail` to all non-trial shell scripts, note if `x` is already set we maintain it.

ACKs for top commit:
  sanket1729:
    utACK 3fa3d37c21
  apoelstra:
    ACK 3fa3d37c21

Tree-SHA512: 24c0da96bea44ea4f550847c8f73bbe1d9ccd1bfee1714ef8a0c23075e3a6d438b6006e351cce0df7a1cb0b9d1b50096270f65a62d0def05c84c9573ffefacba
2024-03-27 18:14:42 +00:00
Tobin C. Harding 3fa3d37c21
Add set -euo pipefail
Add `euo pipefail` to all non-trial shell scripts, note if `x` is
already set we maintain it.

Note we have a pipe in `run_task.sh` that relies on grep not finding
anything i.e., failing, so we cannot use pipefail there. Disable it and
re-enable it after the pipe.
2024-03-27 11:02:27 +11:00
Tobin C. Harding 6ab0110964
Run fuzzer daily
Waiting for the fuzzer slows down the dev feedback loop because it makes
CI slow. We still want fuzz coverage but not in a way that slows down
devs.

Instead of running the fuzzer on every PR just run it once a nightly.

As we do for other daily jobs, rename the yaml file to make explicit
what it does.

Open questions:

- This should run for 30 minutes but I can't work out why the current
  set up only runs for a shorter time than that?
- Is this less fuzzing i.e., is 30 minutes once a day better or worse that 1
  minute 30 times?
2024-03-27 04:35:23 +11:00
Tobin C. Harding d38cb8af9e
fuzz: Use path in manifest instead of version
Using `path` instead of `version` makes the `fuzz` crate easier to
maintain because we don't have to update the version number to do
releases.
2024-03-21 16:20:03 +11:00
Andrew Poelstra e386cbfadf
ci: delete *test.sh files
These are not run in CI since #2353 and are likely to go out of date. If
we want a script that users can run locally then we should create a new
script that wraps our current CI.
2024-02-28 20:45:56 +00:00
Tobin C. Harding 422d30117c
Use bash to run shell scripts
Use `bash` instead of `sh` to run shell scripts.

We would like to support Nix users who do not typically have any shell
other than `sh` at a known path, therefore use `/usr/bin/env bash`.
2024-02-02 05:55:51 +11:00
shuoer86 cc45cfe3fe
Fix typos 2024-01-05 23:10:52 +08:00
Tobin C. Harding 69e56a64ed
Add bitcoin-units crate
Add a new crate `bitcoin-units`, move the `amount` module over to it and
re-export all types from `bitcoin::amount` so this as not a breaking
change.
2023-12-11 08:52:31 +11:00
Tobin C. Harding 4d5415f835
Add rust-version to the workspace manifests
Add `rust-version = 1.56.1` to all crates in the workspace i.e.,
including `fuzz` but excluding the various test crates.
2023-11-23 06:20:04 +11:00
Tobin C. Harding a41e978855
Update to edition 2021
We just bumped the MSRV to Rust 1.56.1 which includes edition 2021.

Update all crates in this repo to use edition 2021 and build/lint
warnings.
2023-11-23 06:20:03 +11:00
Tobin C. Harding efedf862b0
bitcoin: Bump version number to v0.31.0
In preparation for release of v0.31.0 bump the version number.

The changelog is already up to date because we have done two RC
releases.
2023-10-28 08:32:30 +11:00
Tobin C. Harding 38960ab5a5
Bump version to 0.31.0-rc2
In preparation for doing the next RC release bump the version.
2023-10-18 13:52:49 +11:00
Tobin C. Harding 6731e85dc1
bitcoin: Bump version to 0.31.0-rc1
In preparation for the first rc release; bump the version number.
2023-10-13 08:34:46 +11:00
Andrew Poelstra 539f4ba64c
apoelstra run of generate-files.sh 2023-10-10 14:39:15 -03:00
Einherjar 20f3a05d2a
ci: replace fuzz toolchain
old: `actions-rs/toolchain`
new: `dtolnay/rust-toolchain`

fix

ci(fuzz): change runner to ubuntu-latest

ci: update run syntax in fuzz job

ci: update and run fuzz/generate-files.sh
2023-10-10 14:39:15 -03:00
Tobin C. Harding c34e3cc7cc
Re-write size/weight API
Recently we introduced a bug in the weight/size code, while
investigating I found that our `Transaction`/`Block` weight/size APIs
were in a total mess because:

- The docs were stale
- The concept of weight (weight units) and size (bytes) were mixed up

I audited all the API functions, read some bips (141, 144) and re-wrote
the API with the following goals:

- Use terminology from the bips
- Use abstractions that mirror the bips where possible
2023-09-25 08:25:49 +10:00
Tobin C. Harding d4e8f49fc3
Move p2p::constants::Network to crate root
The `Network` type is not a p2p construct, it is more general, used
throughout the codebase to define _which_ Bitcoin network we are
operating on.
2023-08-01 16:46:59 +10:00
Tobin C. Harding 1bac1fd518
Rename the network module to p2p
The `network` module deals with data types and logic related to
internetworking bitcoind nodes, this is commonly referred to as the p2p
layer.

Rename the `network` module to `p2p` and fix all the paths.
2023-08-01 16:36:12 +10:00
Tobin C. Harding 92749d29e4
Rename PartiallySignedTransaction to Psbt
Last release we added a type alias for `Psbt`, now lets just rename the
type and be done with it.

Includes re-export at the crate root because `bitcoin::Psbt` is clear
and obvious.
2023-07-15 08:32:29 +10:00
Andrew Poelstra a1aaf5f12c
ci: fix run syntax in fuzz job 2023-05-08 22:11:40 +00:00
Andrew Poelstra ab4a48c8ba
ci: use new fuzzing cfg flags when fuzzing bitcoin (but not hashes) 2023-05-01 21:33:11 +00:00
Andrew Poelstra 6649e15193
add README note explaining how to disable crypto for fuzzing 2023-05-01 21:32:09 +00:00
Andrew Poelstra 2860aae1a5
fuzz: don't fuzz hashes against RustCrypto
We should probably restore this in the future, but we need to rethink
how we fuzz hashes -- right now when cfg(fuzzing) is set, we break all
the hash functions in a way that won't match any other library.

We should probably make this breakage opt-in but this will require
buy-in from rust-lightning and maybe others.
2023-04-27 00:24:53 +00:00
Andrew Poelstra 6467728202
fuzz: disable tests unless 'cfg(fuzzing)' is passed; update README for reproducing failures 2023-04-27 00:24:53 +00:00
Andrew Poelstra 6e2ee5be66
fuzz: run 'cargo fmt' on all the fuzz targets 2023-04-27 00:24:53 +00:00
Andrew Poelstra 9cfc0fcd81
fuzz: add contrib/test.sh so we at least 'cargo test' it in CI 2023-04-27 00:24:53 +00:00
Andrew Poelstra 933ecb19e1
fuzz: fix warnings, clippy lints, 1.48.0 failures 2023-04-27 00:24:53 +00:00
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