Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/actions/prepare/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: 'Prepare Rust Environment'
description: 'Setup Rust toolchain and install RBMT'
inputs:
toolchain:
description: 'Rust toolchain to use (nightly reads from nightly-version file)'
required: false
default: 'stable'
components:
description: 'Rust components to install (e.g., clippy, rustfmt)'
required: false
default: ''
runs:
using: "composite"
steps:
- name: "Determine toolchain"
id: toolchain
shell: bash
run: |
if [ "${{ inputs.toolchain }}" = "nightly" ]; then
TOOLCHAIN="$(cat nightly-version)"
else
TOOLCHAIN="${{ inputs.toolchain }}"
fi
echo "version=$TOOLCHAIN" >> $GITHUB_OUTPUT


# `rbmt` requires at least Rust 1.74 but MSRV of this repo is currently 1.63
- name: "Setup stable toolchain for RBMT"
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable

- name: "Install RBMT"
shell: bash
run: cargo install --git https://github.com/rust-bitcoin/rust-bitcoin-maintainer-tools.git --rev "$(cat rbmt-version)" cargo-rbmt

- name: "Setup requested toolchain"
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ steps.toolchain.outputs.version }}
components: ${{ inputs.components }}
202 changes: 44 additions & 158 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,6 @@ on: # yamllint disable-line rule:truthy
name: Continuous integration

jobs:
Prepare:
runs-on: ubuntu-24.04
outputs:
nightly_version: ${{ steps.read_toolchain.outputs.nightly_version }}
steps:
- name: "Checkout repo"
uses: actions/checkout@v4
- name: "Read nightly version"
id: read_toolchain
run: echo "nightly_version=$(cat nightly-version)" >> $GITHUB_OUTPUT

Stable: # 2 jobs, one per lock file.
name: Test - stable toolchain
runs-on: ubuntu-latest
Expand All @@ -29,45 +18,27 @@ jobs:
dep: [minimal, recent]
steps:
- name: "Checkout repo"
uses: actions/checkout@v4
- name: "Checkout maintainer tools"
uses: actions/checkout@v4
uses: actions/checkout@v6
- uses: ./.github/actions/prepare
with:
repository: rust-bitcoin/rust-bitcoin-maintainer-tools
ref: c3324024ced9bb1eb854397686919c3ff7d97e1e
path: maintainer-tools
- name: "Select toolchain"
uses: dtolnay/rust-toolchain@stable
- name: "Set dependencies"
run: cp Cargo-${{ matrix.dep }}.lock Cargo.lock
- name: "Run test script"
run: ./maintainer-tools/ci/run_task.sh stable
toolchain: stable
- name: "Run tests"
run: cargo rbmt test stable --lock-file ${{ matrix.dep }}

Nightly: # 2 jobs, one per lock file.
name: Test - nightly toolchain
needs: Prepare
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
dep: [minimal, recent]
steps:
- name: "Checkout repo"
uses: actions/checkout@v4
- name: "Checkout maintainer tools"
uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: ./.github/actions/prepare
with:
repository: rust-bitcoin/rust-bitcoin-maintainer-tools
ref: c3324024ced9bb1eb854397686919c3ff7d97e1e
path: maintainer-tools
- name: "Select toolchain"
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
- name: "Set dependencies"
run: cp Cargo-${{ matrix.dep }}.lock Cargo.lock
- name: "Run test script"
run: ./maintainer-tools/ci/run_task.sh nightly
toolchain: nightly
- name: "Run tests"
run: cargo rbmt test nightly --lock-file ${{ matrix.dep }}

MSRV: # 2 jobs, one per lock file.
name: Test - 1.63.0 toolchain
Expand All @@ -77,183 +48,98 @@ jobs:
matrix:
dep: [minimal, recent]
steps:
- name: "Checkout repo"
uses: actions/checkout@v4
- name: "Checkout maintainer tools"
uses: actions/checkout@v4
with:
repository: rust-bitcoin/rust-bitcoin-maintainer-tools
ref: c3324024ced9bb1eb854397686919c3ff7d97e1e
path: maintainer-tools
- uses: actions/checkout@v6
- name: "Free disk space"
uses: endersonmenezes/free-disk-space@v3
with:
remove_android: true
remove_dotnet: true
remove_haskell: true
- name: "Select toolchain"
uses: dtolnay/rust-toolchain@stable
- uses: ./.github/actions/prepare
with:
toolchain: "1.63.0"
- name: "Set dependencies"
run: cp Cargo-${{ matrix.dep }}.lock Cargo.lock
- name: "Run test script"
run: ./maintainer-tools/ci/run_task.sh msrv
- name: "Run tests"
run: cargo rbmt test msrv --lock-file ${{ matrix.dep }}

Lint:
name: Lint - nightly toolchain
needs: Prepare
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
dep: [recent]
steps:
- name: "Checkout repo"
uses: actions/checkout@v4
- name: "Checkout maintainer tools"
uses: actions/checkout@v4
with:
repository: rust-bitcoin/rust-bitcoin-maintainer-tools
ref: c3324024ced9bb1eb854397686919c3ff7d97e1e
path: maintainer-tools
- name: "Select toolchain"
uses: dtolnay/rust-toolchain@v1
- uses: actions/checkout@v6
- uses: ./.github/actions/prepare
with:
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
- name: "Install clippy"
run: rustup component add clippy
- name: "Set dependencies"
run: cp Cargo-${{ matrix.dep }}.lock Cargo.lock
- name: "Run test script"
run: ./maintainer-tools/ci/run_task.sh lint
toolchain: nightly
components: clippy
- name: "Run lint"
run: cargo rbmt lint

Docs:
name: Docs - stable toolchain
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
dep: [recent]
steps:
- name: "Checkout repo"
uses: actions/checkout@v4
- name: "Checkout maintainer tools"
uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: ./.github/actions/prepare
with:
repository: rust-bitcoin/rust-bitcoin-maintainer-tools
ref: c3324024ced9bb1eb854397686919c3ff7d97e1e
path: maintainer-tools
- name: "Select toolchain"
uses: dtolnay/rust-toolchain@stable
- name: "Set dependencies"
run: cp Cargo-${{ matrix.dep }}.lock Cargo.lock
- name: "Run test script"
run: ./maintainer-tools/ci/run_task.sh docs
toolchain: stable
- name: "Build docs"
run: cargo rbmt docs

Docsrs:
name: Docs - nightly toolchain
needs: Prepare
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
dep: [recent]
steps:
- name: "Checkout repo"
uses: actions/checkout@v4
- name: "Checkout maintainer tools"
uses: actions/checkout@v4
with:
repository: rust-bitcoin/rust-bitcoin-maintainer-tools
ref: c3324024ced9bb1eb854397686919c3ff7d97e1e
path: maintainer-tools
- name: "Select toolchain"
uses: dtolnay/rust-toolchain@v1
- uses: actions/checkout@v6
- uses: ./.github/actions/prepare
with:
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
- name: "Set dependencies"
run: cp Cargo-${{ matrix.dep }}.lock Cargo.lock
- name: "Run test script"
run: ./maintainer-tools/ci/run_task.sh docsrs
toolchain: nightly
- name: "Build docs.rs docs"
run: cargo rbmt docsrs

Bench:
name: Bench - nightly toolchain
needs: Prepare
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
dep: [recent]
steps:
- name: "Checkout repo"
uses: actions/checkout@v4
- name: "Checkout maintainer tools"
uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: ./.github/actions/prepare
with:
repository: rust-bitcoin/rust-bitcoin-maintainer-tools
ref: c3324024ced9bb1eb854397686919c3ff7d97e1e
path: maintainer-tools
- name: "Select toolchain"
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
- name: "Set dependencies"
run: cp Cargo-${{ matrix.dep }}.lock Cargo.lock
- name: "Run test script"
run: ./maintainer-tools/ci/run_task.sh bench
toolchain: nightly
- name: "Run bench"
run: cargo rbmt bench

Format: # 1 job, run cargo fmt directly.
name: Format - nightly toolchain
needs: Prepare
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: "Checkout repo"
uses: actions/checkout@v4
- name: "Select toolchain"
uses: dtolnay/rust-toolchain@v1
- uses: actions/checkout@v6
- uses: ./.github/actions/prepare
with:
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
- name: "Install rustfmt"
run: rustup component add rustfmt
toolchain: nightly
components: rustfmt
- name: "Check formatting"
run: cargo fmt --all -- --check

Integration: # 1 job for each bitcoind version we support.
name: Integration tests - stable toolchain
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
feature:
[
"26_0",
"25_2",
"25_1",
"25_0",
"24_2",
"24_1",
"24_0_1",
"23_2",
"23_1",
"23_0",
"22_1",
"22_0",
"0_21_2",
"0_20_2",
"0_19_1",
"0_18_1",
"0_17_1",
]
steps:
- name: "Checkout repo"
uses: actions/checkout@v4
- name: "Select toolchain"
uses: dtolnay/rust-toolchain@stable
- uses: actions/checkout@v6
- uses: ./.github/actions/prepare
with:
toolchain: stable
- name: "Run integration tests"
run: cd bitcoind-tests && cargo test --features=${{ matrix.feature }}
run: cargo rbmt integration

Embedded:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions bitcoind-tests/tests/test_desc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ pub fn test_desc_satisfy(
let mut aux_rand = [0u8; 32];
rand::thread_rng().fill_bytes(&mut aux_rand);
let schnorr_sig =
secp.sign_schnorr_with_aux_rand(&msg, &internal_keypair.to_inner(), &aux_rand);
secp.sign_schnorr_with_aux_rand(&msg, &internal_keypair.to_keypair(), &aux_rand);
psbt.inputs[0].tap_key_sig =
Some(taproot::Signature { signature: schnorr_sig, sighash_type });
} else {
Expand Down Expand Up @@ -315,7 +315,7 @@ fn find_sks_ms<Ctx: ScriptContext>(
.iter_pk()
.filter_map(|pk| {
let i = pks.iter().position(|&x| x.to_public_key() == pk);
i.map(|idx| (sks[idx]))
i.map(|idx| sks[idx])
})
.collect();
sks
Expand Down
3 changes: 0 additions & 3 deletions clippy.toml

This file was deleted.

1 change: 1 addition & 0 deletions rbmt-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bcff6290c9e3f5b4d7e832acb5a8c6bf890fd1ce
28 changes: 28 additions & 0 deletions rbmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Configuration for rbmt (Rust Bitcoin Maintainer Tools)

[test]
# Examples to run with specific features enabled.
# Format: "example_name:feature1 feature2"
examples = [
"htlc:std compiler",
"parse:std",
"sign_multisig:std",
"verify_tx:std",
"xpub_descriptors:std",
"taproot:std compiler",
"psbt_sign_finalize:std base64",
"taptree_of_horror:std compiler",
]

# Features to test with the conventional `std` feature enabled.
# Tests each feature alone with std, all pairs, and all together.
features_with_std = ["compiler", "trace", "serde", "rand", "base64"]

# Features to test without the `std` feature.
# Tests each feature alone, all pairs, and all together.
features_without_std = ["compiler", "trace", "serde", "rand", "base64"]

[lint]
allowed_duplicates = [
"hex-conservative", # FIXME: Should we be allowing this?
]
2 changes: 1 addition & 1 deletion src/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
//! nightly compiler to run. See the README for exact instructions.
//!

use core::str::FromStr;

Check warning on line 10 in src/benchmarks.rs

View workflow job for this annotation

GitHub Actions / Bench - nightly toolchain

unused import: `core::str::FromStr`

use bitcoin::secp256k1::{Secp256k1, SecretKey};
use test::{black_box, Bencher};

Check warning on line 13 in src/benchmarks.rs

View workflow job for this annotation

GitHub Actions / Bench - nightly toolchain

unused imports: `Bencher` and `black_box`

use crate::descriptor::{SinglePub, SinglePubKey};
use crate::expression::Tree;

Check warning on line 16 in src/benchmarks.rs

View workflow job for this annotation

GitHub Actions / Bench - nightly toolchain

unused import: `crate::expression::Tree`
use crate::{Descriptor, DescriptorPublicKey};

type Desc = Descriptor<DescriptorPublicKey>;

Check warning on line 19 in src/benchmarks.rs

View workflow job for this annotation

GitHub Actions / Bench - nightly toolchain

type alias `Desc` is never used

fn keygen(n: u32) -> DescriptorPublicKey {

Check warning on line 21 in src/benchmarks.rs

View workflow job for this annotation

GitHub Actions / Bench - nightly toolchain

function `keygen` is never used
let secp = Secp256k1::new();

let mut sk = [0; 32];
Expand All @@ -35,7 +35,7 @@
///
/// This method is extremely slow relative to parsing or even re-serializing
/// and should never be called from inside a benchmark.
fn generate_balanced_tree_str<CombFn>(n_nodes: usize, mut combfn: CombFn) -> String

Check warning on line 38 in src/benchmarks.rs

View workflow job for this annotation

GitHub Actions / Bench - nightly toolchain

function `generate_balanced_tree_str` is never used
where
CombFn: FnMut(&str, &str) -> String,
{
Expand Down Expand Up @@ -73,7 +73,7 @@
///
/// This method is extremely slow relative to parsing or even re-serializing
/// and should never be called from inside a benchmark.
fn generate_deep_tree_str<CombFn>(n_nodes: usize, mut combfn: CombFn) -> String

Check warning on line 76 in src/benchmarks.rs

View workflow job for this annotation

GitHub Actions / Bench - nightly toolchain

function `generate_deep_tree_str` is never used
where
CombFn: FnMut(&str, &str) -> String,
{
Expand Down Expand Up @@ -299,15 +299,15 @@

#[cfg(feature = "compiler")]
mod compiler_benches {
use super::*;

Check warning on line 302 in src/benchmarks.rs

View workflow job for this annotation

GitHub Actions / Bench - nightly toolchain

unused import: `super::*`
use crate::descriptor::Descriptor;
use crate::miniscript::Tap;
use crate::policy::compiler::CompilerError;
use crate::policy::Concrete;

Check warning on line 306 in src/benchmarks.rs

View workflow job for this annotation

GitHub Actions / Bench - nightly toolchain

unused import: `crate::policy::Concrete`
use crate::prelude::*;
use crate::Error;
use crate::{Error, Miniscript};

type TapMsRes = Result<Miniscript<String, Tap>, CompilerError>;

Check warning on line 310 in src/benchmarks.rs

View workflow job for this annotation

GitHub Actions / Bench - nightly toolchain

type alias `TapMsRes` is never used
type TapDesc = Result<Descriptor<String>, Error>;

#[bench]
Expand Down
Loading
Loading