From 720992b155f90db454138f89c2d49a5467ea44b9 Mon Sep 17 00:00:00 2001 From: "Andrew Poelstra (aider)" Date: Fri, 1 Aug 2025 14:50:12 +0000 Subject: [PATCH 1/4] clippy: fix new lifetime lint --- src/primitives/correction.rs | 2 +- src/primitives/decode.rs | 6 +++--- src/primitives/fieldvec.rs | 4 ++-- src/primitives/hrp.rs | 8 ++++---- src/primitives/iter.rs | 4 +++- src/primitives/polynomial.rs | 2 +- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/primitives/correction.rs b/src/primitives/correction.rs index a6ce93b9..29652388 100644 --- a/src/primitives/correction.rs +++ b/src/primitives/correction.rs @@ -175,7 +175,7 @@ impl Corrector { /// /// If the input string has sufficiently many errors, this unique closest correct /// string may not actually be the intended string. - pub fn bch_errors(&self) -> Option> { + pub fn bch_errors(&self) -> Option> { // 1. Compute all syndromes by evaluating the residue at each power of the generator. let syndromes: Polynomial<_> = Ck::ROOT_GENERATOR .powers_range(Ck::ROOT_EXPONENTS) diff --git a/src/primitives/decode.rs b/src/primitives/decode.rs index 7b0f321f..c35aabf6 100644 --- a/src/primitives/decode.rs +++ b/src/primitives/decode.rs @@ -444,7 +444,7 @@ impl<'s> CheckedHrpstring<'s> { /// /// Converts the ASCII bytes representing field elements to the respective field elements. #[inline] - pub fn fe32_iter(&self, _: u8) -> AsciiToFe32Iter { + pub fn fe32_iter(&self, _: u8) -> AsciiToFe32Iter<'_> { AsciiToFe32Iter { iter: self.ascii.iter().copied() } } @@ -453,7 +453,7 @@ impl<'s> CheckedHrpstring<'s> { /// Converts the ASCII bytes representing field elements to the respective field elements, then /// converts the stream of field elements to a stream of bytes. #[inline] - pub fn byte_iter(&self) -> ByteIter { + pub fn byte_iter(&self) -> ByteIter<'_> { ByteIter { iter: AsciiToFe32Iter { iter: self.ascii.iter().copied() }.fes_to_bytes() } } @@ -663,7 +663,7 @@ impl<'s> SegwitHrpstring<'s> { /// /// Use `self.witness_version()` to get the witness version. #[inline] - pub fn byte_iter(&self) -> ByteIter { + pub fn byte_iter(&self) -> ByteIter<'_> { ByteIter { iter: AsciiToFe32Iter { iter: self.ascii.iter().copied() }.fes_to_bytes() } } } diff --git a/src/primitives/fieldvec.rs b/src/primitives/fieldvec.rs index 73da10bf..ba16f222 100644 --- a/src/primitives/fieldvec.rs +++ b/src/primitives/fieldvec.rs @@ -129,7 +129,7 @@ impl FieldVec { /// # Panics /// /// Panics if [`Self::has_data`] is false. - pub fn iter(&self) -> slice::Iter { + pub fn iter(&self) -> slice::Iter<'_, F> { if self.len > NO_ALLOC_MAX_LENGTH { self.assert_has_data(); #[cfg(feature = "alloc")] @@ -143,7 +143,7 @@ impl FieldVec { /// # Panics /// /// Panics if [`Self::has_data`] is false. - pub fn iter_mut(&mut self) -> slice::IterMut { + pub fn iter_mut(&mut self) -> slice::IterMut<'_, F> { if self.len > NO_ALLOC_MAX_LENGTH { self.assert_has_data(); #[cfg(feature = "alloc")] diff --git a/src/primitives/hrp.rs b/src/primitives/hrp.rs index b14e3eda..0e40da74 100644 --- a/src/primitives/hrp.rs +++ b/src/primitives/hrp.rs @@ -237,24 +237,24 @@ impl Hrp { /// If an uppercase HRP was parsed during object construction then this iterator will yield /// uppercase ASCII `char`s. For lowercase bytes see [`Self::lowercase_byte_iter`] #[inline] - pub fn byte_iter(&self) -> ByteIter { ByteIter { iter: self.buf[..self.size].iter() } } + pub fn byte_iter(&self) -> ByteIter<'_> { ByteIter { iter: self.buf[..self.size].iter() } } /// Creates a character iterator over the ASCII characters of this HRP. /// /// If an uppercase HRP was parsed during object construction then this iterator will yield /// uppercase ASCII `char`s. For lowercase bytes see [`Self::lowercase_char_iter`]. #[inline] - pub fn char_iter(&self) -> CharIter { CharIter { iter: self.byte_iter() } } + pub fn char_iter(&self) -> CharIter<'_> { CharIter { iter: self.byte_iter() } } /// Creates a lowercase iterator over the byte values (ASCII characters) of this HRP. #[inline] - pub fn lowercase_byte_iter(&self) -> LowercaseByteIter { + pub fn lowercase_byte_iter(&self) -> LowercaseByteIter<'_> { LowercaseByteIter { iter: self.byte_iter() } } /// Creates a lowercase character iterator over the ASCII characters of this HRP. #[inline] - pub fn lowercase_char_iter(&self) -> LowercaseCharIter { + pub fn lowercase_char_iter(&self) -> LowercaseCharIter<'_> { LowercaseCharIter { iter: self.lowercase_byte_iter() } } diff --git a/src/primitives/iter.rs b/src/primitives/iter.rs index a5cf068f..b078f379 100644 --- a/src/primitives/iter.rs +++ b/src/primitives/iter.rs @@ -85,7 +85,9 @@ pub trait Fe32IterExt: Sized + Iterator { /// Adapts the Fe32 iterator to encode the field elements into a bech32 address. #[inline] - fn with_checksum(self, hrp: &Hrp) -> Encoder { Encoder::new(self, hrp) } + fn with_checksum(self, hrp: &Hrp) -> Encoder<'_, Self, Ck> { + Encoder::new(self, hrp) + } } impl Fe32IterExt for I where I: Iterator {} diff --git a/src/primitives/polynomial.rs b/src/primitives/polynomial.rs index c202838f..b2dedcbc 100644 --- a/src/primitives/polynomial.rs +++ b/src/primitives/polynomial.rs @@ -73,7 +73,7 @@ impl Polynomial { /// # Panics /// /// Panics if [`Self::has_data`] is false. - pub fn iter(&self) -> slice::Iter { + pub fn iter(&self) -> slice::Iter<'_, F> { self.assert_has_data(); self.coefficients().iter() } From 4c00b93bb47b4929d57934694c07909cf4a8ef4a Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Fri, 1 Aug 2025 15:04:40 +0000 Subject: [PATCH 2/4] introduce nightly-version file (copied from rust-bitcoin) and use it in CI --- .github/workflows/rust.yml | 24 +++++++++++++++++++++--- nightly-version | 1 + 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 nightly-version diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index e134297a..87c5dbfb 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -3,6 +3,17 @@ on: [push, pull_request] 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: name: Test - stable toolchain runs-on: ubuntu-latest @@ -38,6 +49,7 @@ jobs: Nightly: name: Test - nightly toolchain + needs: Prepare runs-on: ubuntu-latest strategy: fail-fast: false @@ -45,7 +57,9 @@ jobs: - name: Checkout Crate uses: actions/checkout@v3 - name: Checkout Toolchain - uses: dtolnay/rust-toolchain@nightly + uses: dtolnay/rust-toolchain@v1 + with: + toolchain: ${{ needs.Prepare.outputs.nightly_version }} - name: Running test script env: DO_DOCSRS: true @@ -70,6 +84,7 @@ jobs: EmbeddedWithAlloc: name: no_std with alloc + needs: Prepare runs-on: ubuntu-latest strategy: fail-fast: false @@ -79,9 +94,10 @@ jobs: - name: Set up QEMU run: sudo apt update && sudo apt install -y qemu-system-arm gcc-arm-none-eabi - name: Checkout Toolchain - uses: dtolnay/rust-toolchain@nightly + uses: dtolnay/rust-toolchain@v1 with: targets: thumbv7m-none-eabi + toolchain: ${{ needs.Prepare.outputs.nightly_version }} - name: Run env: RUSTFLAGS: "-C link-arg=-Tlink.x" @@ -90,6 +106,7 @@ jobs: EmbeddedNoAlloc: name: no_std no alloc + needs: Prepare runs-on: ubuntu-latest strategy: fail-fast: false @@ -99,9 +116,10 @@ jobs: - name: Set up QEMU run: sudo apt update && sudo apt install -y qemu-system-arm gcc-arm-none-eabi - name: Checkout Toolchain - uses: dtolnay/rust-toolchain@nightly + uses: dtolnay/rust-toolchain@v1 with: targets: thumbv7m-none-eabi + toolchain: ${{ needs.Prepare.outputs.nightly_version }} - name: Run env: RUSTFLAGS: "-C link-arg=-Tlink.x" diff --git a/nightly-version b/nightly-version new file mode 100644 index 00000000..98cd340e --- /dev/null +++ b/nightly-version @@ -0,0 +1 @@ +nightly-2025-07-11 From 62a9d535162dcf722bb1336e0d7da3a78c4deae2 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Fri, 1 Aug 2025 15:09:29 +0000 Subject: [PATCH 3/4] add weekly cronjob to update nightly-version --- .../workflows/cron-weekly-update-nightly.yml | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/cron-weekly-update-nightly.yml diff --git a/.github/workflows/cron-weekly-update-nightly.yml b/.github/workflows/cron-weekly-update-nightly.yml new file mode 100644 index 00000000..dda26ff1 --- /dev/null +++ b/.github/workflows/cron-weekly-update-nightly.yml @@ -0,0 +1,41 @@ +name: Update Nightly rustc +on: + schedule: + - cron: "5 0 * * 6" # Saturday at 00:05 + workflow_dispatch: # allows manual triggering +jobs: + format: + name: Update nightly rustc + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@nightly + - name: Update rust.yml to use latest nightly + 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 + - name: Create Pull Request + if: env.changes_made == 'true' + uses: peter-evans/create-pull-request@v7 + with: + token: ${{ secrets.APOELSTRA_RUST_BITCOIN_ORG_CREATE_PR }} + author: Update Nightly Rustc Bot + committer: Update Nightly Rustc Bot + title: Automated update to nightly-version (to nightly-${{ env.nightly_date }}) + 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 }} + branch: create-pull-request/weekly-nightly-update From 7a3f493e58fe28035b8a2d56a092a7359328e0f0 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Sat, 2 Aug 2025 14:31:15 +0000 Subject: [PATCH 4/4] ci: update checkout and cache to v4; runner to ubuntu-latest. It seems we were using all sorts of versions of these actions throughout our GA files. v2 is deprecated and I think has been removed entirely. Then our fuzz runner is set to ubuntu-20.04 which has also been removed. So update everything to latest. For Rust software there should never be any surprise breakage due to OS changes. But there has been "surprise breakage" many times due to removing old versions. --- .../workflows/cron-weekly-update-nightly.yml | 2 +- .github/workflows/fuzz.yml | 8 ++++---- .github/workflows/rust.yml | 18 +++++++++--------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/cron-weekly-update-nightly.yml b/.github/workflows/cron-weekly-update-nightly.yml index dda26ff1..fa97f766 100644 --- a/.github/workflows/cron-weekly-update-nightly.yml +++ b/.github/workflows/cron-weekly-update-nightly.yml @@ -6,7 +6,7 @@ on: jobs: format: name: Update nightly rustc - runs-on: ubuntu-24.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index 80681682..b3fa2b2a 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -6,7 +6,7 @@ jobs: fuzz: if: ${{ !github.event.act }} - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest strategy: fail-fast: false matrix: @@ -14,8 +14,8 @@ jobs: 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 + - uses: actions/checkout@v4 + - uses: actions/cache@v4 id: cache-fuzz with: path: | @@ -38,7 +38,7 @@ jobs: needs: fuzz runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 - name: Display structure of downloaded files run: ls -R diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 87c5dbfb..6cfda274 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -4,7 +4,7 @@ name: Continuous Integration jobs: Prepare: - runs-on: ubuntu-24.04 + runs-on: ubuntu-latest outputs: nightly_version: ${{ steps.read_toolchain.outputs.nightly_version }} steps: @@ -21,7 +21,7 @@ jobs: fail-fast: false steps: - name: Checkout Crate - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Checkout Toolchain # https://github.com/dtolnay/rust-toolchain uses: dtolnay/rust-toolchain@stable @@ -39,7 +39,7 @@ jobs: fail-fast: false steps: - name: Checkout Crate - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Checkout Toolchain uses: dtolnay/rust-toolchain@beta - name: Running test script @@ -55,7 +55,7 @@ jobs: fail-fast: false steps: - name: Checkout Crate - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Checkout Toolchain uses: dtolnay/rust-toolchain@v1 with: @@ -74,7 +74,7 @@ jobs: fail-fast: false steps: - name: Checkout Crate - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Checkout Toolchain uses: dtolnay/rust-toolchain@1.56.1 - name: Running test script @@ -90,7 +90,7 @@ jobs: fail-fast: false steps: - name: Checkout Crate - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up QEMU run: sudo apt update && sudo apt install -y qemu-system-arm gcc-arm-none-eabi - name: Checkout Toolchain @@ -112,7 +112,7 @@ jobs: fail-fast: false steps: - name: Checkout Crate - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up QEMU run: sudo apt update && sudo apt install -y qemu-system-arm gcc-arm-none-eabi - name: Checkout Toolchain @@ -131,7 +131,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Crate - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Checkout Toolchain uses: dtolnay/rust-toolchain@stable - name: Add architecture i386 @@ -149,7 +149,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Crate - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Checkout Toolchain uses: dtolnay/rust-toolchain@stable - name: Install target