From 6b78b5a9783a85b1a1e1d0e49a47db9b57cb4b11 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 5 Dec 2025 12:51:09 +1100 Subject: [PATCH 1/6] Fix lint warnings about error size Just allow the lint to pass ignoring the large error return size. --- src/psbt/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/psbt/mod.rs b/src/psbt/mod.rs index 916f8d3c1..a0833ad2e 100644 --- a/src/psbt/mod.rs +++ b/src/psbt/mod.rs @@ -455,6 +455,7 @@ pub trait PsbtExt { /// /// - Returns a mutated psbt with all inputs `finalize_mut` could finalize /// - A vector of input errors, one of each of failed finalized input + #[allow(clippy::result_large_err)] fn finalize( self, secp: &secp256k1::Secp256k1, @@ -467,6 +468,7 @@ pub trait PsbtExt { ) -> Result<(), Vec>; /// Same as [PsbtExt::finalize], but allows for malleable satisfactions + #[allow(clippy::result_large_err)] fn finalize_mall( self, secp: &Secp256k1, From 1231487c29306616c575c7738a675359590e2fd5 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 5 Dec 2025 12:51:09 +1100 Subject: [PATCH 2/6] Fix benches Add import to fix the benchmarks. Just allow the lint to pass ignoring the large error return size. --- src/benchmarks.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/benchmarks.rs b/src/benchmarks.rs index f79b3509b..52823186c 100644 --- a/src/benchmarks.rs +++ b/src/benchmarks.rs @@ -305,7 +305,7 @@ mod compiler_benches { use crate::policy::compiler::CompilerError; use crate::policy::Concrete; use crate::prelude::*; - use crate::Error; + use crate::{Error, Miniscript}; type TapMsRes = Result, CompilerError>; type TapDesc = Result, Error>; From f614384a29ae0b6238010b125db93fd98ea59dd8 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 5 Dec 2025 13:12:09 +1100 Subject: [PATCH 3/6] integration: Remove redundant parenthesis clippy emits: warning: unnecessary parentheses around closure body As suggested remove the parentheses. --- bitcoind-tests/tests/test_desc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitcoind-tests/tests/test_desc.rs b/bitcoind-tests/tests/test_desc.rs index e09260097..f73906a40 100644 --- a/bitcoind-tests/tests/test_desc.rs +++ b/bitcoind-tests/tests/test_desc.rs @@ -315,7 +315,7 @@ fn find_sks_ms( .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 From 9b8ca2cb474277ac01c1e191586be756cb4694b2 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 5 Dec 2025 13:13:25 +1100 Subject: [PATCH 4/6] integration: Remove usage of deprecated function Use `to_keypair` as suggested by the linter. --- bitcoind-tests/tests/test_desc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitcoind-tests/tests/test_desc.rs b/bitcoind-tests/tests/test_desc.rs index f73906a40..15978175f 100644 --- a/bitcoind-tests/tests/test_desc.rs +++ b/bitcoind-tests/tests/test_desc.rs @@ -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 { From d10e267c2aacb8f76757db4ee38913d5127b037d Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Mon, 8 Dec 2025 12:12:06 +1100 Subject: [PATCH 5/6] Remove clippy.toml Its no longer needed for MSRV of 1.63. --- clippy.toml | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 clippy.toml diff --git a/clippy.toml b/clippy.toml deleted file mode 100644 index 2edc417d1..000000000 --- a/clippy.toml +++ /dev/null @@ -1,3 +0,0 @@ -msrv = "1.63.0" -# plan API returns Self as an error type for an large-ish enum -large-error-threshold = 256 From 9ba53146f0e56d86d26068aea4c1af78a7db8f24 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 5 Dec 2025 12:13:06 +1100 Subject: [PATCH 6/6] CI: Use new cargo rmbt tool Use Nicks mad new tool to run CI. To do this I copied what is in `rust-psbt`, guessed at what `bench` should be, and used the latest commit hash from `rust-bitcoin-maintainer-tools` repo. --- .github/actions/prepare/action.yml | 41 ++++++ .github/workflows/rust.yml | 202 +++++++---------------------- rbmt-version | 1 + rbmt.toml | 28 ++++ 4 files changed, 114 insertions(+), 158 deletions(-) create mode 100644 .github/actions/prepare/action.yml create mode 100644 rbmt-version create mode 100644 rbmt.toml diff --git a/.github/actions/prepare/action.yml b/.github/actions/prepare/action.yml new file mode 100644 index 000000000..603cd500c --- /dev/null +++ b/.github/actions/prepare/action.yml @@ -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 }} diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 2642dfc13..4dcb871b8 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -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 @@ -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 @@ -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 diff --git a/rbmt-version b/rbmt-version new file mode 100644 index 000000000..afd9fe545 --- /dev/null +++ b/rbmt-version @@ -0,0 +1 @@ +bcff6290c9e3f5b4d7e832acb5a8c6bf890fd1ce diff --git a/rbmt.toml b/rbmt.toml new file mode 100644 index 000000000..41622ae3f --- /dev/null +++ b/rbmt.toml @@ -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? +]