diff --git a/.github/actions/checkout-maintainer-tools/action.yml b/.github/actions/checkout-maintainer-tools/action.yml deleted file mode 100644 index d675edf0..00000000 --- a/.github/actions/checkout-maintainer-tools/action.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: Checkout Maintainer Tools -description: Checks out the rust-bitcoin maintainer tools repo -runs: - using: "composite" - steps: - - name: Checkout maintainer tools - uses: actions/checkout@v4 - with: - repository: rust-bitcoin/rust-bitcoin-maintainer-tools - ref: f92b2766865ce5327eca5cf72f86ceaa6be58ca4 - path: maintainer-tools diff --git a/.github/workflows/cron-weekly-update-nightly.yml b/.github/workflows/cron-weekly-update-nightly.yml index 02ac888d..c85c80b1 100644 --- a/.github/workflows/cron-weekly-update-nightly.yml +++ b/.github/workflows/cron-weekly-update-nightly.yml @@ -1,41 +1,35 @@ name: Update Nightly rustc on: schedule: - - cron: "5 0 * * 1" # runs every Monday at 00:05 UTC + - cron: "5 0 * * 6" # Saturday at 00:05 workflow_dispatch: # allows manual triggering +permissions: {} jobs: format: name: Update nightly rustc - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 + permissions: + contents: write + id-token: write + pull-requests: write steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@nightly - - name: Update rust.yml to use latest nightly + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + persist-credentials: false + - name: Install cargo-rbmt + run: cargo install --git https://github.com/rust-bitcoin/rust-bitcoin-maintainer-tools.git --rev $(cat rbmt-version) cargo-rbmt + - name: Update nightly toolchain in Cargo.toml run: | - set -x - # Not every night has a nightly, so extract the date from whatever - # version of the compiler dtolnay/rust-toolchain gives us. - NIGHTLY_DATE=$(rustc +nightly --verbose --version | sed -ne 's/^commit-date: //p') - # Update the nightly version in the reference file. - echo "nightly-${NIGHTLY_DATE}" > nightly-version - echo "nightly_date=${NIGHTLY_DATE}" >> $GITHUB_ENV - # Some days there is no new nightly. In this case don't make an empty PR. - if ! git diff --exit-code > /dev/null; then - echo "Updated nightly. Opening PR." - echo "changes_made=true" >> $GITHUB_ENV - else - echo "Attempted to update nightly but the latest-nightly date did not change. Not opening any PR." - echo "changes_made=false" >> $GITHUB_ENV - fi + eval "$(cargo rbmt toolchains --update-nightly)" + echo "nightly_version=$RBMT_NIGHTLY" >> $GITHUB_ENV - name: Create Pull Request - if: env.changes_made == 'true' - uses: peter-evans/create-pull-request@v6 + uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8 with: token: ${{ secrets.APOELSTRA_CREATE_PR_TOKEN }} author: Update Nightly Rustc Bot committer: Update Nightly Rustc Bot - title: Automated daily update to rustc (to nightly-${{ env.nightly_date }}) + title: Automated daily update to rustc (to ${{ env.nightly_version }}) body: | - Automated update to Github CI workflow `rust.yml` by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action - commit-message: Automated update to Github CI to rustc nightly-${{ env.nightly_date }} + Automated update to Cargo.toml workspace metadata by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action + commit-message: Automated update to rustc ${{ env.nightly_version }} branch: create-pull-request/daily-nightly-update diff --git a/.github/workflows/cron-weekly-update-stable.yml b/.github/workflows/cron-weekly-update-stable.yml new file mode 100644 index 00000000..3ffd4e1d --- /dev/null +++ b/.github/workflows/cron-weekly-update-stable.yml @@ -0,0 +1,34 @@ +name: Update Stable rustc +on: + schedule: + - cron: "0 0 * * 5" # runs every Friday at 00:00 (generally rust releases on Thursday) + workflow_dispatch: # allows manual triggering +permissions: {} +jobs: + format: + name: Update stable rustc + runs-on: ubuntu-24.04 + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + persist-credentials: false + - name: Install cargo-rbmt + run: cargo install --git https://github.com/rust-bitcoin/rust-bitcoin-maintainer-tools.git --rev $(cat rbmt-version) cargo-rbmt + - name: Update stable toolchain in Cargo.toml + run: | + eval "$(cargo rbmt toolchains --update-stable)" + echo "stable_version=$RBMT_STABLE" >> $GITHUB_ENV + - name: Create Pull Request + uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8 + with: + token: ${{ secrets.APOELSTRA_CREATE_PR_TOKEN }} + author: Update Stable Rustc Bot + committer: Update Stable Rustc Bot + title: Automated weekly update to rustc stable (to ${{ env.stable_version }}) + body: | + Automated update to Cargo.toml workspace metadata by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action + commit-message: Automated update to rustc stable-${{ env.stable_version }} + branch: create-pull-request/weekly-stable-update diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index afe786f8..4dc44501 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,173 +1,120 @@ -on: # yamllint disable-line rule:truthy - pull_request: - push: - branches: - - master - - 'test-ci/**' +on: [push, pull_request] -name: Continuous integration +name: Continuous Integration -jobs: - Prepare: - runs-on: ubuntu-latest - outputs: - nightly_version: ${{ steps.read_toolchain.outputs.nightly_version }} - msrv_version: ${{ steps.read_msrv.outputs.msrv_version }} - steps: - - name: "Checkout repo" - uses: actions/checkout@v4 - - name: "Read nightly version" - id: read_toolchain - run: | - set -euo pipefail - version=$(cat nightly-version) - echo "nightly_version=$version" >> $GITHUB_OUTPUT - - name: Read MSRV from clippy.toml - id: read_msrv - run: | - set -euo pipefail - msrv=$(grep '^msrv *= *"' clippy.toml | sed -E 's/.*"([^"]+)".*/\1/') - echo "msrv_version=$msrv" >> "$GITHUB_OUTPUT" - - Stable: - name: Test - stable toolchain - runs-on: ubuntu-latest - strategy: - fail-fast: false - steps: - - name: "Checkout repo" - uses: actions/checkout@v4 - - name: "Checkout maintainer tools" - uses: ./.github/actions/checkout-maintainer-tools - - name: "Select toolchain" - uses: dtolnay/rust-toolchain@stable - - name: "Set dependencies" - run: cp Cargo-latest.lock Cargo.lock - - name: "Run test script" - run: ./maintainer-tools/ci/run_task.sh stable - - Nightly: - name: Test - nightly toolchain - needs: Prepare - runs-on: ubuntu-latest - strategy: - fail-fast: false - steps: - - name: "Checkout repo" - uses: actions/checkout@v4 - - name: "Checkout maintainer tools" - uses: ./.github/actions/checkout-maintainer-tools - - name: "Select toolchain" - uses: dtolnay/rust-toolchain@v1 - with: - toolchain: ${{ needs.Prepare.outputs.nightly_version }} - - name: "Set dependencies" - run: cp Cargo-latest.lock Cargo.lock - - name: "Run test script" - run: ./maintainer-tools/ci/run_task.sh nightly +permissions: + contents: read - MSRV: - name: Test - MSRV - needs: Prepare - runs-on: ubuntu-latest +jobs: + Test: # 6 jobs: 3 toolchains × 2 lock files. + name: Test - ${{ matrix.toolchain }} toolchain (${{ matrix.dep }}) + runs-on: ubuntu-24.04 strategy: fail-fast: false + matrix: + dep: [recent] + toolchain: [stable, nightly, msrv] steps: - - name: "Checkout repo" + - name: Checkout repo uses: actions/checkout@v4 - - name: "Checkout maintainer tools" - uses: ./.github/actions/checkout-maintainer-tools - - name: "Select toolchain" - uses: dtolnay/rust-toolchain@stable - with: - toolchain: ${{ needs.Prepare.outputs.msrv_version }} - - name: "Set dependencies" - run: cp Cargo-latest.lock Cargo.lock - - name: "Run test script" - run: ./maintainer-tools/ci/run_task.sh msrv + - uses: rust-bitcoin/rust-bitcoin-maintainer-tools/.github/actions/setup-rbmt@af3c2868415b17eedc808da6d0589e10b7482660 # v0.1.0 + - uses: Swatinem/rust-cache@v2 + - name: Run ${{ matrix.toolchain }} tests + run: | + export ELEMENTSD_EXE="$PWD/elementsd-tests/bin/elementsd" + if [ "${{ matrix.toolchain }}" = "msrv" ]; then + MSRV="$(cargo rbmt toolchains --msrv)" + cp "Cargo-${{ matrix.dep }}.lock" Cargo.lock + cargo +"$MSRV" test --locked + else + cargo rbmt --lock-file ${{ matrix.dep }} test --toolchain ${{ matrix.toolchain }} + fi Lint: name: Lint - nightly toolchain - needs: Prepare - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - dep: [recent] + runs-on: ubuntu-24.04 steps: - - name: "Checkout repo" + - name: Checkout Crate uses: actions/checkout@v4 - - name: "Checkout maintainer tools" - uses: ./.github/actions/checkout-maintainer-tools - - name: "Select toolchain" - uses: dtolnay/rust-toolchain@v1 - with: - toolchain: ${{ needs.Prepare.outputs.nightly_version }} - - name: Install clippy - run: rustup component add clippy - - name: "Set dependencies" - run: cp Cargo-latest.lock Cargo.lock - - name: "Run test script" - run: ./maintainer-tools/ci/run_task.sh lint + - uses: rust-bitcoin/rust-bitcoin-maintainer-tools/.github/actions/setup-rbmt@af3c2868415b17eedc808da6d0589e10b7482660 # v0.1.0 + - uses: Swatinem/rust-cache@v2 + - name: Run lints + run: cargo rbmt --lock-file recent lint Docs: name: Docs - stable toolchain - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - dep: [recent] + runs-on: ubuntu-24.04 steps: - - name: "Checkout repo" + - name: Checkout Crate uses: actions/checkout@v4 - - name: "Checkout maintainer tools" - uses: ./.github/actions/checkout-maintainer-tools - - name: "Select toolchain" - uses: dtolnay/rust-toolchain@stable - - name: "Set dependencies" - run: cp Cargo-latest.lock Cargo.lock - - name: "Run test script" - run: ./maintainer-tools/ci/run_task.sh docs + - uses: rust-bitcoin/rust-bitcoin-maintainer-tools/.github/actions/setup-rbmt@af3c2868415b17eedc808da6d0589e10b7482660 # v0.1.0 + - uses: Swatinem/rust-cache@v2 + - name: Run doc tests + run: cargo rbmt --lock-file recent docs Docsrs: name: Docs - nightly toolchain - needs: Prepare - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - dep: [recent] + runs-on: ubuntu-24.04 steps: - - name: "Checkout repo" + - name: Checkout Crate uses: actions/checkout@v4 - - name: "Checkout maintainer tools" - uses: ./.github/actions/checkout-maintainer-tools - - name: "Select toolchain" - uses: dtolnay/rust-toolchain@v1 - with: - toolchain: ${{ needs.Prepare.outputs.nightly_version }} - - name: "Set dependencies" - run: cp Cargo-latest.lock Cargo.lock - - name: "Run test script" - run: ./maintainer-tools/ci/run_task.sh docsrs + - uses: rust-bitcoin/rust-bitcoin-maintainer-tools/.github/actions/setup-rbmt@af3c2868415b17eedc808da6d0589e10b7482660 # v0.1.0 + - uses: Swatinem/rust-cache@v2 + - name: Run docsrs tests + run: cargo rbmt --lock-file recent docsrs -# Format: +# Format: # 1 job, run cargo fmt directly. # name: Format - nightly toolchain -# needs: Prepare -# runs-on: ubuntu-latest -# strategy: -# fail-fast: false +# runs-on: ubuntu-24.04 # steps: -# - name: "Checkout repo" +# - name: Checkout Crate # uses: actions/checkout@v4 -# - name: "Select toolchain" -# uses: dtolnay/rust-toolchain@v1 -# with: -# toolchain: ${{ needs.Prepare.outputs.nightly_version }} -# - name: "Install rustfmt" -# run: rustup component add rustfmt -# - name: "Check formatting" -# run: cargo fmt --all -- --check +# - uses: rust-bitcoin/rust-bitcoin-maintainer-tools/.github/actions/setup-rbmt@af3c2868415b17eedc808da6d0589e10b7482660 # v0.1.0 +# - name: Check formatting +# run: cargo rbmt --lock-file recent fmt --check + + Bench: + name: Bench - nightly toolchain + runs-on: ubuntu-24.04 + steps: + - name: Checkout Crate + uses: actions/checkout@v4 + - uses: rust-bitcoin/rust-bitcoin-maintainer-tools/.github/actions/setup-rbmt@af3c2868415b17eedc808da6d0589e10b7482660 # v0.1.0 + - uses: Swatinem/rust-cache@v2 + - name: Run benches + run: cargo rbmt --lock-file recent bench + + Arch32bit: + name: Test 32-bit version + runs-on: ubuntu-24.04 + steps: + - name: Checkout Crate + uses: actions/checkout@v4 + - name: Checkout Toolchain + uses: dtolnay/rust-toolchain@stable + - name: Add architecture i386 + run: sudo dpkg --add-architecture i386 + - name: Install i686 gcc + run: sudo apt-get update -y && sudo apt-get install -y gcc-multilib + - name: Install target + run: rustup target add i686-unknown-linux-gnu + - name: Run tests on i686 + run: cargo test --target i686-unknown-linux-gnu + + Cross: + name: Cross test + runs-on: ubuntu-24.04 + steps: + - name: Checkout Crate + uses: actions/checkout@v4 + - name: Checkout Toolchain + uses: dtolnay/rust-toolchain@stable + - name: Install target + run: rustup target add s390x-unknown-linux-gnu + - name: install cross + run: cargo install cross --locked + - name: run cross test + run: cross test --target s390x-unknown-linux-gnu Wasm: name: Check WASM diff --git a/Cargo-latest.lock b/Cargo-recent.lock similarity index 100% rename from Cargo-latest.lock rename to Cargo-recent.lock diff --git a/Cargo.toml b/Cargo.toml index e42baeec..79e82b68 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,11 @@ homepage = "https://github.com/ElementsProject/rust-elements/" repository = "https://github.com/ElementsProject/rust-elements/" documentation = "https://docs.rs/elements/" edition = "2018" +rust-version = "1.63.0" + +[workspace.metadata.rbmt.toolchains] +nightly = "nightly-2026-04-17" +stable = "1.95.0" [features] default = ["json-contract"] @@ -86,7 +91,7 @@ copy_iterator = "warn" default_trait_access = "warn" doc_link_with_quotes = "warn" doc_markdown = "warn" -empty_enum = "warn" +empty_enums = "warn" enum_glob_use = "warn" expl_impl_clone_on_copy = "warn" explicit_deref_methods = "warn" @@ -168,7 +173,7 @@ struct_field_names = "warn" too_many_lines = "allow" # FIXME 14 triggers for this lint; probably most should be fixed transmute_ptr_to_ptr = "warn" trivially_copy_pass_by_ref = "warn" -unchecked_duration_subtraction = "warn" +unchecked_time_subtraction = "warn" unicode_not_nfc = "warn" unnecessary_box_returns = "warn" unnecessary_join = "warn" @@ -184,3 +189,11 @@ used_underscore_items = "warn" verbose_bit_mask = "warn" wildcard_imports = "warn" zero_sized_map_values = "warn" + +[package.metadata.rbmt.lint] +allowed_duplicates = [ + "hex-conservative", +] + +[package.metadata.rbmt.prerelease] +enabled = true diff --git a/clippy.toml b/clippy.toml index c218f7c9..5f304987 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1,2 +1 @@ avoid-breaking-exported-api = true -msrv = "1.63.0" diff --git a/elementsd-tests/Cargo.toml b/elementsd-tests/Cargo.toml index 52fc8620..55df5d4e 100644 --- a/elementsd-tests/Cargo.toml +++ b/elementsd-tests/Cargo.toml @@ -3,6 +3,7 @@ name = "elementsd-tests" version = "0.1.0" authors = ["Andrew Poelstra "] edition = "2018" +rust-version = "1.63.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -12,3 +13,22 @@ elements = {path = "../", features = ["base64"]} elementsd = "0.11.0" rand = "0.8" +[package.metadata.rbmt.lint] +# FIXME the bulk of these are because elementsd/bitcoind is much older than rust-bitcoin. +allowed_duplicates = [ + "hex-conservative", + "base64", + "getrandom", + "wasi", + "windows-sys", + "windows-targets", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_aarch64_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_i686_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", + "windows_x86_64_gnu", +] diff --git a/nightly-version b/nightly-version deleted file mode 100644 index 2fb44768..00000000 --- a/nightly-version +++ /dev/null @@ -1 +0,0 @@ -nightly-2025-09-27 diff --git a/rbmt-version b/rbmt-version new file mode 100644 index 00000000..de57ca2d --- /dev/null +++ b/rbmt-version @@ -0,0 +1 @@ +6560b728ae6a81af9d92713b630ba26772fbd970 diff --git a/src/pset/mod.rs b/src/pset/mod.rs index 2f895831..230369b5 100644 --- a/src/pset/mod.rs +++ b/src/pset/mod.rs @@ -360,11 +360,11 @@ impl PartiallySignedTransaction { self.global.merge(other.global)?; - for (self_input, other_input) in self.inputs.iter_mut().zip(other.inputs.into_iter()) { + for (self_input, other_input) in self.inputs.iter_mut().zip(other.inputs) { self_input.merge(other_input)?; } - for (self_output, other_output) in self.outputs.iter_mut().zip(other.outputs.into_iter()) { + for (self_output, other_output) in self.outputs.iter_mut().zip(other.outputs) { self_output.merge(other_output)?; } diff --git a/src/pset/serialize.rs b/src/pset/serialize.rs index ed8af56c..cdd2e77d 100644 --- a/src/pset/serialize.rs +++ b/src/pset/serialize.rs @@ -186,10 +186,8 @@ impl Deserialize for KeySource { let mut d = &bytes[4..]; while !d.is_empty() { - match u32::consensus_decode(&mut d) { - Ok(index) => dpath.push(index.into()), - Err(e) => return Err(e), - } + let index = u32::consensus_decode(&mut d)?; + dpath.push(index.into()); } Ok((fprint, dpath.into())) diff --git a/src/transaction.rs b/src/transaction.rs index 327eb0df..cfb82c72 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -238,13 +238,13 @@ impl Sequence { /// Returns `true` if the sequence number encodes a block based relative lock-time. #[inline] pub fn is_height_locked(&self) -> bool { - self.is_relative_lock_time() & (self.0 & Sequence::LOCK_TYPE_MASK == 0) + self.is_relative_lock_time() && self.0 & Sequence::LOCK_TYPE_MASK == 0 } /// Returns `true` if the sequence number encodes a time interval based relative lock-time. #[inline] pub fn is_time_locked(&self) -> bool { - self.is_relative_lock_time() & (self.0 & Sequence::LOCK_TYPE_MASK > 0) + self.is_relative_lock_time() && self.0 & Sequence::LOCK_TYPE_MASK > 0 } /// Create a relative lock-time using block height.