Commit Graph

3964 Commits

Author SHA1 Message Date
Tobin C. Harding 35687c84fc
CI: Fix Manage PR job
In #2635 we broke the Manage PR CI job but for some reason CI didn't run
on that PR so we merged the breakage.

Fix the script by setting default variables when they are not set. Done
with ChatGPT.
2024-03-28 09:08:08 +11: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
Andrew Poelstra ebcddfce19
Merge rust-bitcoin/rust-bitcoin#2634: Run fuzzer daily
6ab0110964 Run fuzzer daily (Tobin C. Harding)

Pull request description:

  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.

  Note also we only get 20 jobs, currently there are 18 fuzzing jobs. This means for this hour any other CI runs will only have access to 2 jobs (if i understand GitHub resource usage correctly).

  ### Open questions

  Docs: https://docs.github.com/en/actions/learn-github-actions/usage-limits-billing-and-administration

  > Concurrent jobs - The number of concurrent jobs you can run in your account depends on your GitHub plan,

  What is the definition of "account" - is that a user account, or a repository? Which account is running the cron job?

ACKs for top commit:
  apoelstra:
    ACK 6ab0110964 though if this proves too onerous we should try 30 or even 15 minutes

Tree-SHA512: d6d07d16b550fe27258c97cb4da305f0bec16d39788da3cf061e9db7ca4a039897dc1a91b394ccc03cd4cd5427d3da94dd7c0ec4e0a80410bd48d029d4112d4e
2024-03-27 17:46:15 +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 af6dc1db02
internals: Bump version to 0.3.0
In preparation for release add a changelog and bump the version number.
2024-03-27 09:44:30 +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 3520f550f0
Implement ArbitraryOrd for relative::LockTime
TL;DR As we do for `absolute::LockTime` and for the same reasons;
implement `ArbitraryOrd` for `relative::LockTime`.

locktimes do not have a semantic ordering if they differ (blocks, time)
so we do not derive `Ord` however it is useful for downstream to be able
to order structs that contain lock times. This is exactly what the
`ArbitraryOrd` trait is for.

Update the rustdocs in `relative` and mirror the docs changes in
`absolute`.

Fix: #2566
2024-03-26 10:36:50 +11:00
Andrew Poelstra 9df59639ce
Merge rust-bitcoin/rust-bitcoin#2621: Release tracking PR: `hashes v0.14.0`
0ca5a43ce5 hashes: Bump version to v0.14.0 (Tobin C. Harding)

Pull request description:

  In preparation for release add a changlelog entry and bump the version.

  Note the hashes 0.13.0 dependency stays in the dependency graph because of secp, we can update secp after releasing `hashes` then update the secp dependency in `rust-bitcoin` thereby removing the `hashes v0.13.0` dependency - phew.

  Note we are right to release this immediately, the two open PRs (#2337 and #2541) that touch `hashes` only add a clippy attribute so can safely be ignored.

ACKs for top commit:
  apoelstra:
    ACK 0ca5a43ce5
  sanket1729:
    ACK 0ca5a43ce5

Tree-SHA512: d1d26acb8fbf13f785b25add3f1dac05bb392b5bdbad16ead2bc5dd26f3d668824c4b653c373f88c3562a37e775146766680606cedd19db40e0f197b26ca86b8
2024-03-25 22:23:30 +00:00
Andrew Poelstra b593778314
Merge rust-bitcoin/rust-bitcoin#2595: Release tracking PR: `base58ck v0.1.0`
c16c1be946 base58: Add changelog (Tobin C. Harding)

Pull request description:

  In preparation for release add a minimal changelog to the `base58ck` crate.

  This crate is currently unreleased and has the version number correctly set to `v0.1.0` - as of today, the crate name `base58ck` is available on crates.io.

ACKs for top commit:
  sanket1729:
    utACK c16c1be946
  apoelstra:
    ACK c16c1be946 Let's do it!

Tree-SHA512: 8c66e7823dd058257c65e40e67f4386f045cd6292f11356f80bf5e95c0fa28d573b52c57f8ba1504893e236e8124916311fa0c2af1807fdb48e3123bb3d826fb
2024-03-25 22:11:29 +00:00
Andrew Poelstra 92d8f70544
Merge rust-bitcoin/rust-bitcoin#2610: Add a validation variant to `ParseError`
a7a99e06bb Add a validation variant to `ParseError` (Tobin C. Harding)
d5c52618a9 Move NetworkValidationError within file (Tobin C. Harding)

Pull request description:

  As requested, return `ParseError` from `Address<NetworkUnchecked>::require_network`.

  - Patch 1: Preparatory refactor
  - Patch 2: Add the variant.

  Replaces #2593.

  Close: #2507

ACKs for top commit:
  sanket1729:
    ACK a7a99e06bb.
  apoelstra:
    ACK a7a99e06bb

Tree-SHA512: 08b290e5f11a5d787918a5b851f98efbeff5bd20a2838e00564f03bb242af3640da663ddc42473419255fff6f64280eaf2595706504676b3228ac81212ea7cf2
2024-03-25 21:41:25 +00:00
Tobin C. Harding a7a99e06bb
Add a validation variant to `ParseError`
`require_network` is typically called as part of parsing, often in the
same line of code. Counter to our normal errors, it makes
`require_network` more ergonomic to use if we just return a `ParseError`
variant.

Close: #2507
2024-03-25 08:45:19 +11:00
Tobin C. Harding d5c52618a9
Move NetworkValidationError within file
Done in preparation for adding the `NetworkValidationError` as a variant
of `ParseError`.

Move the `NetworkValidationError` type to beneath `ParseError`.

Code move only, no other changes.
2024-03-25 06:54:12 +11:00
Tobin C. Harding c16c1be946
base58: Add changelog
In preparation for release add a minimal changelog to the `base58ck`
crate. This crate is currently unreleased and has the version number
correctly set to `v0.1.0` - as of today, the crate name `base58ck` is
available on crates.io.
2024-03-25 06:41:38 +11:00
Andrew Poelstra c211e7be78
Merge rust-bitcoin/rust-bitcoin#2626: Replace TBD with 0.32.0
fd040f5e38 Replace TBD with 0.32.0 (Tobin C. Harding)

Pull request description:

  We are gearing up for the 0.32.0 release; replace all instances of TBD with the version number of the upcoming release.

ACKs for top commit:
  sanket1729:
    ACK fd040f5e38
  apoelstra:
    ACK fd040f5e38

Tree-SHA512: fe73fd47a794557742f618b21434cd3cc18cde0e861216716723bfcc9135accf63590e1ea60bfeda066acec7312c8b9f1bf09e7454e7161ccaba5ebe60af66fd
2024-03-24 15:15:09 +00:00
Andrew Poelstra bfd5255ae8
Merge rust-bitcoin/rust-bitcoin#2481: Improve base58 crate
af49841433 Hide base58::Error internals (Tobin C. Harding)
4f68e79da0 bitcoin: Stop using base58 errors (Tobin C. Harding)
669d5e8fc6 base58: Add InvalidCharacterError for decoding (Tobin C. Harding)
ec8609393b base58: Add error module (Tobin C. Harding)
42fabbab03 base58: Run the formatter (Tobin C. Harding)

Pull request description:

  Improve the error code in the new `base58` crate.

ACKs for top commit:
  apoelstra:
    ACK af49841433
  sanket1729:
    ACK af49841433

Tree-SHA512: c05479f02a9a58c7c98fd5987e760288562372e16cceeeb655f0a5385b4a8605945a3b6f7fcf473a7132a40f8dc90d204bc5e9e64fd2cc0bdc37dbcabb4ddc5c
2024-03-24 14:20:29 +00:00
Andrew Poelstra 26248b28ac
Merge rust-bitcoin/rust-bitcoin#2625: Put back in deprecated dust_value
c17db32df3 Pub back in deprecated dust_value (Tobin C. Harding)

Pull request description:

  When we renamed `dust_value` to `minimal_non_dust` we forgot to keep the original and deprecated it, doing so assists with the upgrade path.

  Put back in deprecated `dust_value`, linking to the rename.

  Renamed in #2255, found while testing upgrade of downstream software.

ACKs for top commit:
  tcharding:
    > ACK [c17db32](c17db32df3) I _think_ this matches the behavior of the old version
  apoelstra:
    ACK c17db32df3 I *think* this matches the behavior of the old version
  sanket1729:
    ACK c17db32df3

Tree-SHA512: 28e1bd2e1a0fd13c78c70ad2667b72b3bf649c293201b79c86c00f09d0126389ebaeb430b8dd32aeeec3d60cbd8761ae949f5784a5ea7756b1b9ae77ec96ce61
2024-03-24 13:56:34 +00:00
Andrew Poelstra 1656e1a09a
Merge rust-bitcoin/rust-bitcoin#2619: Call is_witness_program from witness_version
dec05b63e9 Refactor witness_version and is_witness_program (Tobin C. Harding)
dac552b436 Add unit tests for shortest/longest witness program (Tobin C. Harding)

Pull request description:

  Refactor `witness_version` and `is_witness_program`.

  - Patch 2 adds a couple of preparatory unit tests.
  - Patch 2 does the refactor

  Fix: #2618

ACKs for top commit:
  apoelstra:
    ACK dec05b63e9
  sanket1729:
    ACK dec05b63e9

Tree-SHA512: 3db0a1d8175cbb2fd18f3254854d02db3ad7efa2620b12f08d9727ef6bb5854f0a015917e57023cd2196a36d13276e80536a0e96318c44a1173da4f6793ca370
2024-03-22 23:52:42 +00:00
Andrew Poelstra 3851441265
Merge rust-bitcoin/rust-bitcoin#2549: improve relative locktime API
04715e3e60 absolute: make is_* methods uniform with the ones from relative (Andrew Poelstra)
878b865f85 relative locktime: introduce is_* methods to check units (Andrew Poelstra)
c2f87c7ab3 relative locktime: add is_implied_by method for sequences (Andrew Poelstra)
319e102fed relative locktime: use From/TryFrom to convert between relative locktimes and Sequence (Andrew Poelstra)
0ed26915f6 relative locktime: add conversions to/from sequence (Andrew Poelstra)
5c8fb5c11b relative locktime: add consensus encode/decode functions (Andrew Poelstra)
ac968e02b6 relative locktime: constify a bunch of constructors (Andrew Poelstra)
f27e675e1e relative locktime: add "obvious" constructors (Andrew Poelstra)
f02b1dac5b relative locktime: copy comments and PartialOrd impl from absolute locktimes (Andrew Poelstra)
2ff5085e70 locktimes: run cargo fmt (Andrew Poelstra)

Pull request description:

  While implementing https://github.com/rust-bitcoin/rust-miniscript/pull/654 I ran into a number of limitations of the `relative::LockTime` API. This fixes these by

  * Copying a ton of functions from `absolute::LockTime` to `relative::LockTime`, adjusting comments and functionality accordingly.
  * Adding conversion functions to/from `Sequence` numbers, as well as a method to check whether a locktime is satisfied by a given sequence number.

  Fixes #2547
  Fixes #2545
  Fixes #2540

ACKs for top commit:
  tcharding:
    ACK 04715e3e60
  sanket1729:
    ACK 04715e3e60

Tree-SHA512: 70740eaa3a83dc1e7312b99e907ccdcef4eeb6191ae881d81712707ad6fb949c4e28183ab6f9258c6cde1ef8fdd5dc6476439e705a9e02a939b7832430a608d4
2024-03-22 21:32:59 +00:00
Tobin C. Harding 42d02fbd66
Merge Refactor and One ACK carve outs
The "One ACK carve-out" has 3 rules and then there is a separate
"Refactor carve-out" that covers things that are not only refactoring -
this makes it hard to reference the carve-outs in github because its a
bit confusing.

Merge the carve-outs into a single "one ACK carve-out" with multiple
rules. Use rule 0 for the original refactor carve-out stuff because it
makes the diff smaller and all good lists start with 0.

Also remove mention of the refactor carve-out from rule 3.
2024-03-23 07:20:49 +11:00
Tobin C. Harding ebf5b670d4
Update test script mention
In the One ACK carve out just say "test scripts" instead of `test.sh`
because we re-named the test scripts recently.
2024-03-23 07:12:06 +11:00
Tobin C. Harding fd040f5e38
Replace TBD with 0.32.0
We are gearing up for the 0.32.0 release; replace all instances of TBD
with the version number of the upcoming release.
2024-03-23 05:36:52 +11:00
Tobin C. Harding c17db32df3
Pub back in deprecated dust_value
When we renamed `dust_value` to `minimal_non_dust` we forgot to keep the
original and deprecated it, doing so assists with the upgrade path.

Pub back in deprecated `dust_value`, linking to the rename.
2024-03-23 05:32:15 +11:00
Andrew Poelstra 08ff359dc7
Merge rust-bitcoin/rust-bitcoin#2578: Document how to write commits
8bd0394b0a Document how to write commits (Tobin C. Harding)

Pull request description:

  Reviewers often find themselves linking to blog posts to encourage newer devs to improve their commit logs, we can save everyones time by putting the links in the contributing docs, then we can just point devs there.

ACKs for top commit:
  apoelstra:
    ACK 8bd0394b0a

Tree-SHA512: b2713c2882c3153152091bd2a72a473e151cf1e3e93288ae17b773c9f2944805a78c991437c9951d9fe5478c76a31d5c0f2ac0212bda6cbca531681a7b41f988
2024-03-22 14:18:07 +00:00
Andrew Poelstra 04715e3e60
absolute: make is_* methods uniform with the ones from relative 2024-03-21 22:10:17 +00:00
Andrew Poelstra 878b865f85
relative locktime: introduce is_* methods to check units
Copy these from absolute::LockTime. While we are at it, make the
functions in absolute::LockTime const.
2024-03-21 22:10:17 +00:00
Andrew Poelstra c2f87c7ab3
relative locktime: add is_implied_by method for sequences
This gives a way to determine whether a CSV will pass, given a sequence
number, in a type-safe way where you can't get the two things backward.
2024-03-21 22:10:17 +00:00
Andrew Poelstra 319e102fed
relative locktime: use From/TryFrom to convert between relative locktimes and Sequence 2024-03-21 22:10:17 +00:00
Andrew Poelstra 0ed26915f6
relative locktime: add conversions to/from sequence 2024-03-21 22:10:17 +00:00
Andrew Poelstra 5c8fb5c11b
relative locktime: add consensus encode/decode functions 2024-03-21 22:10:13 +00:00
Andrew Poelstra ac968e02b6
relative locktime: constify a bunch of constructors 2024-03-21 22:07:29 +00:00
Andrew Poelstra f27e675e1e
relative locktime: add "obvious" constructors
Adds constructors to allow directly creating locktimes from time or
block counts; adds a flooring constructor to Time to match the ceiling
one; adds an explicit constructor to Height since the From<u16> was not
very discoverable.
2024-03-21 22:07:25 +00:00
Andrew Poelstra f02b1dac5b
relative locktime: copy comments and PartialOrd impl from absolute locktimes 2024-03-21 22:07:25 +00:00
Andrew Poelstra 2ff5085e70
locktimes: run cargo fmt 2024-03-21 22:07:25 +00:00
Tobin C. Harding dec05b63e9
Refactor witness_version and is_witness_program
These two functions are related. We cannot, by definition, get the
witness version from a script that is not a witness program but
currently the code is not linking these two things.

Refactor by doing:

- Move the check of the witness program bip rules to `witness_version`
- Call `witness_version().is_some()` in the predicate

Improve the docs while we are at it to include the bip text in the
rustdoc. Note I didn't bother referencing the segwit bip number, this
bip text is pretty well known.
2024-03-22 07:07:07 +11:00
Tobin C. Harding dac552b436
Add unit tests for shortest/longest witness program
Add two unit tests that verify we can correctly determine if a
shortest allowed and longest allowed script is a witness program.

Done in preparation for patching the `witness_version` function.
2024-03-22 07:03:30 +11:00
Tobin C. Harding 0ca5a43ce5
hashes: Bump version to v0.14.0
In preparation for release add a changlelog entry and bump the version.

I'm not 100% sure that this release is API breaking, dependencies
definitely changed. The rest might be only additives but I didn't bother
looking exactly because I think its better to bump the minor version and
err on the side of caution.

Note the hashes 0.13.0 dependency stays in the dependency graph because
of secp, we can update secp after releasing `hashes` then update the
secp dependency in `rust-bitcoin` thereby removing the `hashes v0.13.0`
dependency - phew.
2024-03-22 06:04:40 +11:00
Andrew Poelstra 7c910d5612
Merge rust-bitcoin/rust-bitcoin#2622: fuzz: Use path in manifest instead of version
d38cb8af9e fuzz: Use path in manifest instead of version (Tobin C. Harding)

Pull request description:

  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.

ACKs for top commit:
  apoelstra:
    ACK d38cb8af9e neat, I did not know you could do this

Tree-SHA512: dd3d4526e6599c0752aef07393238b381b166d0d5b436a4babe967c6b282aa47079583b36ecea7a17279b1de135591950c07c9d6f2ba8e50d349bc62ca77f5c6
2024-03-21 14:55:12 +00: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 2b9568158b
Merge rust-bitcoin/rust-bitcoin#2617: Revert #2525 (filter CI)
50e772fe79 Revert "ci: introduce `classify-pr.sh` script which determines whether a PR should have CI run" (Andrew Poelstra)
ae381fcc01 Revert "ci: gate CI workflow on source being changed" (Andrew Poelstra)
495d7e8acd Revert "ci: gate fuzztesting on whether source code changed" (Andrew Poelstra)
ec3e4e8801 Revert "ci: gate coverage analysis on whether source code changed" (Andrew Poelstra)

Pull request description:

  This PR did not work on the "master" CI runs and I really don't care enough to figure it out (or even how to test it). Just revert it.

ACKs for top commit:
  tcharding:
    ACK 50e772fe79

Tree-SHA512: c56b77dab93e9917b2420f5b7f178bfa05500f8329852296102d72df33c5de87d45ee79f235a4ce30e629bc79b2b290a2fcb97d7808c406bfe07c9fe7e1cc997
2024-03-20 22:13:33 +00:00
Tobin C. Harding af49841433
Hide base58::Error internals
As is convention here in `rust-bitcoin`, hide the `base58::Error`
internals by adding struct error types.
2024-03-21 06:22:51 +11:00
Tobin C. Harding 4f68e79da0
bitcoin: Stop using base58 errors
We are currently using the `base58::Error` type to create errors in
`bitcoin`, these are bitcoin errors not `base58` errors.

Note that we add what looks like duplicate
`InvalidBase58PayloadLengthError` types but they are different because
of the expected length. This could have been a field but I elected not
to do so for two reasons:

1. We will need to do so anyways if we crate smash more
2. The `crypto::key` one can have one of two values 33 or 34.

With this applied we can remove the now unused error variants from
`base58::Error`.
2024-03-21 06:22:51 +11:00
Tobin C. Harding 669d5e8fc6
base58: Add InvalidCharacterError for decoding
The `base58::decode` function can only return a single error type, add a
`InvalidCharacterError` struct (leaf error) to use as the return type.
2024-03-21 06:22:51 +11:00
Tobin C. Harding ec8609393b
base58: Add error module
In preparation for improving the `base58` error types crate an `error`
module and move the single current error type there. Make the module
public and reexport the type.
2024-03-21 06:22:51 +11:00
Tobin C. Harding 42fabbab03
base58: Run the formatter 2024-03-21 06:22:49 +11:00
Andrew Poelstra 6ff850539a
Merge rust-bitcoin/rust-bitcoin#2503: base58: Re-name crate to base58ck
6b09857f55 base58: Re-name crate to base58ck (Tobin C. Harding)

Pull request description:

  The current name `base58check` is taken, as is `base58`. Use `base58ck` instead.

  Add a brief section to the readme about the crate naming.

ACKs for top commit:
  apoelstra:
    ACK 6b09857f55
  sanket1729:
    ACK 6b09857f55

Tree-SHA512: 86ee08105906a6f3403dc2602e827b0d46226798ecdedb420ad3ac4b657d6a00e25eabcdfbdb9f8e89bdc3a38e608189f1e073e65593f89a2ad853e8ff027f69
2024-03-20 18:56:22 +00:00
Andrew Poelstra 4d90e0b2c4
Merge rust-bitcoin/rust-bitcoin#2528: hash_types: add unit tests for display of all hash types in the library
b816c0bb01 hash_types: add unit tests for display of all hash types in the library (Andrew Poelstra)

Pull request description:

  This can be checked against the 0.29.x branch, and against the commit prior to #1659 (40c246743b^) and you will see that it is consistent EXCEPT:

  * In rust-bitcoin 0.29.x we did not have multiple sighash types, only `Sighash`; we now have `LegacySighash`, `SegwitV0Sighash`, and `TapSighash`.
  * In #1565 we deliberately changed the display direction of the sighashes, to match BIP 143.

  Fixes #2495.

ACKs for top commit:
  tcharding:
    That's a win. ACK b816c0bb01

Tree-SHA512: 5b44f40165699910ea9ba945657cd1f960cf00a0b4dfa44c513feb3b74cda33ed80d3551042c15b85d6e57c30a54242db202eefd9ec8c8b6e1498b5578e52800
2024-03-20 16:33:58 +00:00
Andrew Poelstra 50e772fe79
Revert "ci: introduce `classify-pr.sh` script which determines whether a PR should have CI run"
This reverts commit 9aca8a18c7.
2024-03-20 14:08:17 +00:00
Andrew Poelstra ae381fcc01
Revert "ci: gate CI workflow on source being changed"
This reverts commit 09f7fc3cff.
2024-03-20 14:08:16 +00:00
Andrew Poelstra 495d7e8acd
Revert "ci: gate fuzztesting on whether source code changed"
This reverts commit 2203c02347.
2024-03-20 14:08:15 +00:00
Andrew Poelstra ec3e4e8801
Revert "ci: gate coverage analysis on whether source code changed"
This reverts commit 32f9b1a231.
2024-03-20 14:08:14 +00:00