Skip to content

Commit

Permalink
Merge #47: update to rust-elements 0.22.0 and rust-bitcoin 0.30.0
Browse files Browse the repository at this point in the history
a94fa54 pull `bitcoind-tests` into the main workspace (Andrew Poelstra)
fab34ba release 0.2.0 (Andrew Poelstra)
408cd3b fuzz: bring in new scripts and CI stuff from rust-bitcoin (Andrew Poelstra)
78191ea fuzz: clean up all fuzz targets, remove `honggfuzz` feature (Andrew Poelstra)
abdd5bb update coding conventions; remove #![deny] from lib.rs (Andrew Poelstra)
a7b49cc bench: move bench behind cfg flag rather than Cargo feature (Andrew Poelstra)
b39aa2a update MSRV from 1.41.1 to 1.48.0 (Andrew Poelstra)
e5d4593 cargo fmt (Andrew Poelstra)
9992bee more clippy lol: bitcoind-tests (Andrew Poelstra)
f7e96e5 clippy: final checks (with --all-features and --all-targets) (Andrew Poelstra)
7cd2e19 clippy: compiler fixes (Andrew Poelstra)
3ccc535 clippy: replace () error with custom error type (Andrew Poelstra)
8fdc5ba clippy fixes: round 1 (Andrew Poelstra)
b1da1c9 bitcoind-tests: update dependencies (Andrew Poelstra)
1a00d31 update bitcoin to 0.30.0, elements to 0.22.0, miniscript to 10.0 (Andrew Poelstra)

Pull request description:

  A fair bit easier than the rust-elements upgrade, but still not entirely trivial.

ACKs for top commit:
  sanket1729:
    code review ACK a94fa54

Tree-SHA512: 9454acbb219d21d992e813a8884b038012758d309d47ce2fd1f5fadb3f0b8155f4eb674f32d4e250e38f82ae8119f69f1da710373e6350d84d0c34cc064f4cb0
  • Loading branch information
sanket1729 committed Jun 22, 2023
2 parents 955f380 + a94fa54 commit bd479c6
Show file tree
Hide file tree
Showing 75 changed files with 1,229 additions and 1,102 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Automatically generated by fuzz/generate-files.sh
name: Fuzz

on:
push:
branches:
- master
- 'test-ci/**'
pull_request:

jobs:
fuzz:
if: ${{ !github.event.act }}
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
fuzz_target: [
roundtrip_miniscript_str,
roundtrip_miniscript_script,
parse_descriptor,
roundtrip_semantic,
parse_descriptor_secret,
roundtrip_descriptor,
roundtrip_concrete,
compile_descriptor,
]
steps:
- name: Install test dependencies
run: sudo apt-get update -y && sudo apt-get install -y binutils-dev libunwind8-dev libcurl4-openssl-dev libelf-dev libdw-dev cmake gcc libiberty-dev
- uses: actions/checkout@v2
- uses: actions/cache@v2
id: cache-fuzz
with:
path: |
~/.cargo/bin
fuzz/target
target
key: cache-${{ matrix.target }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.58
override: true
profile: minimal
- name: fuzz
run: |
if [[ "${{ matrix.fuzz_target }}" =~ ^bitcoin ]]; then
export RUSTFLAGS='--cfg=hashes_fuzz --cfg=secp256k1_fuzz'
fi
echo "Using RUSTFLAGS $RUSTFLAGS"
cd fuzz && ./fuzz.sh "${{ matrix.fuzz_target }}"
- run: echo "${{ matrix.fuzz_target }}" >executed_${{ matrix.fuzz_target }}
- uses: actions/upload-artifact@v2
with:
name: executed_${{ matrix.fuzz_target }}
path: executed_${{ matrix.fuzz_target }}

verify-execution:
if: ${{ !github.event.act }}
needs: fuzz
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
- name: Display structure of downloaded files
run: ls -R
- run: find executed_* -type f -exec cat {} + | sort > executed
- run: source ./fuzz/fuzz-util.sh && listTargetNames | sort | diff - executed
11 changes: 7 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
on: [push, pull_request]
on:
push:
branches:
- master
pull_request: {}

name: Continuous integration

jobs:
lint_fuzz_stable:
name: Lint + Fuzz
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout Crate
Expand All @@ -19,7 +23,6 @@ jobs:
override: true
- name: Running fuzzer
env:
DO_FUZZ: true
DO_LINT: true
run: ./contrib/test.sh

Expand Down Expand Up @@ -66,7 +69,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
rust: [stable, beta, nightly, 1.41.1]
rust: [stable, beta, nightly, 1.48.0]
steps:
- name: Checkout Crate
uses: actions/checkout@v2
Expand Down
121 changes: 2 additions & 119 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,121 +1,4 @@
# 9.0.0 - November 5, 2022
# 0.2.0 - June 15, 2023

- Fixed a bug dealing with dissatisfying pkh inside thresh
- Changed the signature of `Satisfier::lookup_raw_pkh_pk` API. Only custom implementations
of `Satisfier` need to be updated. The psbt APIs are unchanged.
- Fixed a bug related to display of `raw_pk_h`. These descriptors are experimental
and only usable by opting via `ExtParams` while parsing string.
# 8.0.0 - October 20, 2022

This release contains several significant API overhauls, as well as a bump
of our MSRV from 1.29 to 1.41. Users are encouraged to update their compiler
to 1.41 *before* updating to this version.

It includes more Taproot support, but users should be aware that Taproot
support for Miniscript is **not** standardized and is subject to change in
the future. See [this gist](https://gist.github.com/sipa/06c5c844df155d4e5044c2c8cac9c05e)
for our thinking regarding this at the time of release.

- Works with bitcoin crate 0.29
- Correctly [return an error when `SortedMulti` is constructed with too many keys](https://github.com/rust-bitcoin/rust-miniscript/pull/366/)
- Cleanly separate [`experimental/insane miniscripts`](https://github.com/rust-bitcoin/rust-miniscript/pull/461) from sane miniscripts.
- allow disabling the checksum with [`alternate Display`](https://github.com/rust-bitcoin/rust-miniscript/pull/478)
- Correct [`max_satisfaction_size` of `from_multi_a` fragment](https://github.com/rust-bitcoin/rust-miniscript/pull/346/)
- [Add `PsbtInputExt` trait with `update_with_descriptor` method](https://github.com/rust-bitcoin/rust-miniscript/pull/339/) and [`PsbtOutputExt` trait](https://github.com/rust-bitcoin/rust-miniscript/pull/465/)
- Rename [several descriptor types](https://github.com/rust-bitcoin/rust-miniscript/pull/376/) to reduce redundancy
- [**Bump MSRV to 1.41** and edition to 2018](https://github.com/rust-bitcoin/rust-miniscript/pull/365/)
- Rename [`as_public` to `to_public` on some descriptor key types](https://github.com/rust-bitcoin/rust-miniscript/pull/377/)
- Split fully derived `DescriptorPublicKey`s [into their own type](https://github.com/rust-bitcoin/rust-miniscript/pull/345/) [followup](https://github.com/rust-bitcoin/rust-miniscript/pull/448/)
- [Remove the `DescriptorTrait`](https://github.com/rust-bitcoin/rust-miniscript/pull/386/) in favor of the `Descriptor` enum
- Fix signature costing [to account for ECDSA vs Schnorr](https://github.com/rust-bitcoin/rust-miniscript/pull/340/)
- **Add a Taproot-enabled compiler** [v1](https://github.com/rust-bitcoin/rust-miniscript/pull/291/) [v2](https://github.com/rust-bitcoin/rust-miniscript/pull/342/) [v3](https://github.com/rust-bitcoin/rust-miniscript/pull/418/)
- Rename [`stackelem` to `stack_elem`](https://github.com/rust-bitcoin/rust-miniscript/pull/411/) in the interpreter
- Add [`no-std`](https://github.com/rust-bitcoin/rust-miniscript/pull/277)
- Reworked the [`TranslatePk`](https://github.com/rust-bitcoin/rust-miniscript/pull/426) APIs. Add a Translator trait to cleanly allow downstream users without dealing with APIs that accept function pointers. Also provides `translate_assoc_clone` and `translate_assoc_fail` macros for helping in writing code.
- Updated [`MiniscriptKey trait`](https://github.com/rust-bitcoin/rust-miniscript/pull/434),https://github.com/rust-bitcoin/rust-miniscript/pull/439 to accept associated types for Sha256, Hash256, Ripemd160 and
Hash160. This allows users to write abstract miniscripts hashes as "sha256(H)" instead of specifying the entire hash in the string.
that updates the psbt with descriptor bip32 paths.
- Re-name [`as_public`](https://github.com/rust-bitcoin/rust-miniscript/pull/377) APIs -> `to_public`
- Significantly improve the [timelock](https://github.com/rust-bitcoin/rust-miniscript/pull/414) code with new rust-bitcoin APIs.
- rust-miniscript minor implementation detail: `PkH` fragment now has `Pk` generic instead of `Pk::Hash`. This only concerns users
that operate with `MiniscriptKey = bitcoin::PublicKey` or users that use custom implementation of `MiniscriptKey`. Users that use
`DescriptorPublicKey` need not be concerned. See [PR](https://github.com/rust-bitcoin/rust-miniscript/pull/431) for details.
- To elaborate, "pkh(<20-byte-hex>)" is no longer parsed by the `MiniscriptKey = bitcoin::PublicKey`.
This is consistent with the descriptor spec as defined. Parsing from `bitcoin::Script` for pkh<20-byte-hex> is still supported, but the library would not analyze them. These raw descriptors are still in spec discussions. Rust-miniscript will support them once they are completely specified.

# 7.0.0 - April 20, 2022

- Support for `tr` descriptors with miniscript leaves and multi_a fragment
- Changes to MiniscriptKey and ToPublicKey traits for x-only keys support
- Add `PsbtExt` trait for psbt operations
- `Psbt::update_desc` adds information from a descriptor to a psbt. This figures
out the type of the descriptor and adds corresponding redeem script/witness script
and tap tree information
- Add `derived_descriptor` API to Descriptor so that users no longer need to use
`translate` APIs. See examples/`xpub_descriptor` for usage
- Update `DescriptorTrait`: `script_code` and `explicit_script` can now fail because
of taproot descriptors
- Add `PreTaprootDescriptor` and `PreTaprootDescriptorTrait` to support non-failing versions
of `script_code` and `explicit_script` for non taproot descriptors
- Overhaul the interpreter API to provide simpler APIs `iter(prevouts)` and `iter_assume_sig()`
so that it no longer takes a closure input.
- Add interpreter support for taproot transactions.
- Works with rust-bitcoin 0.28.0-rc.1
# 6.0.1 - Aug 5, 2021

- The `lift` method on a Miniscript node was fixed. It would previously mix up
the `X` and `Y` argument of an `andor` fragment.

# 6.0.0 - Jul 29, 2021

- bump `rust-bitcoin` to 0.27
- several bugfixes

# 5.0.0 - Jan 14, 2021

- Remove `PkCtx` from the API
- Move descriptors into their own types, with an enum containing all of them
- Move descriptor functionality into a trait
- Remove `FromStr` bound from `MiniscriptKey`and `MiniscriptKey::Hash`
- Various `DescriptorPublicKey` improvements
- Allow hardened paths in `DescriptorPublicKey`, remove direct `ToPublicKey` implementation
- Change `Option` to `Result` in all APIs
- bump `rust-bitcoin` to 0.26

# 4.0.0 - Nov 23, 2020

- Add support for parsing secret keys
- Add sortedmulti descriptor
- Added standardness and other sanity checks
- Cleaned up `Error` type and return values of most of the API
- Overhauled `satisfied_constraints` module into a new `Iterpreter` API

# 3.0.0 - Oct 13, 2020

- **Bump MSRV to 1.29**

# 2.0.0 - Oct 1, 2020

- Changes to the miniscript type system to detect an invalid
combination of heightlocks and timelocks
- Lift miniscripts can now fail. Earlier it always succeeded and gave
the resulting Semantic Policy
- Compiler will not compile policies that contain at least one
unspendable path
- Added support for Descriptor PublicKeys(xpub)
- Added a generic psbt finalizer and extractor
- Updated Satisfaction API for checking time/height before setting satisfaction
- Added a policy entailment API for more miniscript semantic analysis

# 1.0.0 - July 6, 2020

- Added the following aliases to miniscript for ease of operations
- Rename `pk` to `pk_k`
- Rename `thresh_m` to `multi`
- Add alias `pk(K)` = `c:pk_k(K)`
- Add alias `pkh(K)` = `c:pk_h(K)`
- Fixed Miniscript parser bugs when decoding Hashlocks
- Added scriptContext(`Legacy` and `Segwitv0`) to Miniscript.
- Miscellaneous fixes against DoS attacks for heavy nesting.
- Fixed Satisfier bug that caused flipping of arguments for `and_v` and `and_n` and `and_or`
- Still rapid iteration, very unstable.

18 changes: 10 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "elements-miniscript"
version = "0.1.0"
version = "0.2.0"
authors = ["Andrew Poelstra <apoelstra@wpsoftware.net>, Sanket Kanjalkar <sanket1729@gmail.com>"]
repository = "https://github.com/ElementsProject/elements-miniscript"
description = "Elements Miniscript: Miniscript, but for elements"
Expand All @@ -14,15 +14,14 @@ edition = "2018"
compiler = []
trace = []

unstable = []
serde = ["actual-serde", "bitcoin/serde", "elements/serde"]
rand = ["bitcoin/rand"]
base64 = ["bitcoin/base64"]

[dependencies]
bitcoin = "0.29.1"
elements = "0.21.0"
bitcoin-miniscript = { package = "miniscript", version = "9.0", git = "https://github.com/rust-bitcoin/rust-miniscript", rev = "1351c20a5ead4f308e18bce88cc01983c7d0e876" }
bitcoin = "0.30.0"
elements = "0.22.0"
bitcoin-miniscript = { package = "miniscript", version = "10.0" }

# Do NOT use this as a feature! Use the `serde` feature instead.
actual-serde = { package = "serde", version = "1.0", optional = true }
Expand All @@ -31,8 +30,8 @@ actual-serde = { package = "serde", version = "1.0", optional = true }
serde_json = "1.0"
actual-rand = { package = "rand", version = "0.8.4"}
serde_test = "1.0.147"
bitcoin = { version = "0.29.2", features = ["base64"] }
secp256k1 = {version = "0.24.0", features = ["rand-std"]}
bitcoin = { version = "0.30.0", features = ["base64"] }
secp256k1 = {version = "0.27.0", features = ["rand-std"]}
actual-base64 = { package = "base64", version = "0.13.0" }


Expand All @@ -58,4 +57,7 @@ required-features = ["compiler"]

[[example]]
name = "psbt_sign_finalize"
required-features = ["base64"]
required-features = ["base64"]

[workspace]
members = ["bitcoind-tests", "fuzz"]
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![Build](https://github.com/ElementsProject/elements-miniscript/workflows/Continuous%20integration/badge.svg)

**Minimum Supported Rust Version:** 1.41.1
**Minimum Supported Rust Version:** 1.48.0

*This crate uses "2018" edition

Expand Down Expand Up @@ -35,19 +35,19 @@ The cargo feature `std` is enabled by default. At least one of the features `std

Enabling the `no-std` feature does not disable `std`. To disable the `std` feature you must disable default features. The `no-std` feature only enables additional features required for this crate to be usable without `std`. Both can be enabled without conflict.

## Benchmarking

To run the benchmarks run `RUSTFLAGS=--cfg=miniscript_bench cargo +nightly bench --all-features`.

## Minimum Supported Rust Version (MSRV)
This library should always compile with any combination of features on **Rust 1.41.1**.
This library should always compile with any combination of features on **Rust 1.48.0**.


Some dependencies do not play nicely with our MSRV, if you are running the tests
you may need to pin as follows:

```
cargo update --package url --precise 2.2.2
cargo update --package form_urlencoded --precise 1.0.1
cargo update -p once_cell --precise 1.13.1
cargo update -p bzip2 --precise 0.4.2
cargo update -p which --precise 4.3.0
cargo update -p serde --precise 1.0.156
```

## Contributing
Expand Down
2 changes: 1 addition & 1 deletion bitcoind-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ edition = "2018"
elements-miniscript = {path = "../"}
elementsd = {version = "0.6.0"}
actual-rand = { package = "rand", version = "0.8.4"}
secp256k1 = {version = "0.24.0", features = ["rand-std"]}
secp256k1 = {version = "0.27.0", features = ["rand-std"]}
8 changes: 4 additions & 4 deletions bitcoind-tests/tests/setup/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pub extern crate elements_miniscript;
use std::str::FromStr;
use miniscript::elements;
use elements::encode::{deserialize, serialize_hex};
use elements::hashes::hex::FromHex;
use elements::hex::FromHex;
use elements::BlockHash;
pub use elements_miniscript as miniscript;
use elementsd::bitcoincore_rpc::jsonrpc::serde_json::{json, Value};
Expand All @@ -18,8 +18,8 @@ pub mod test_util;
pub fn setup(validate_pegin: bool) -> (ElementsD, Option<BitcoinD>, elements::BlockHash) {
// Lookup bitcoind binary path
let curr_dir = std::env::current_dir().unwrap();
let bitcoind_path = curr_dir.clone().join("bin/bitcoind");
let elementsd_path = curr_dir.clone().join("bin/elementsd");
let bitcoind_path = curr_dir.join("bin/bitcoind");
let elementsd_path = curr_dir.join("bin/elementsd");

std::env::set_var("BITCOIND_EXE", bitcoind_path);
std::env::set_var("ELEMENTSD_EXE", elementsd_path);
Expand All @@ -28,7 +28,7 @@ pub fn setup(validate_pegin: bool) -> (ElementsD, Option<BitcoinD>, elements::Bl
if validate_pegin {
let bitcoind_exe = bitcoind::exe_path().unwrap();
let bitcoind_conf = bitcoind::Conf::default();
bitcoind = Some(bitcoind::BitcoinD::with_conf(&bitcoind_exe, &bitcoind_conf).unwrap());
bitcoind = Some(bitcoind::BitcoinD::with_conf(bitcoind_exe, &bitcoind_conf).unwrap());
}

let mut conf = elementsd::Conf::new(bitcoind.as_ref());
Expand Down
Loading

0 comments on commit bd479c6

Please sign in to comment.