From b7f318b28105fc92988a89aeeaec48a7acf4c58e Mon Sep 17 00:00:00 2001 From: Kyryl R Date: Wed, 13 May 2026 12:17:58 +0300 Subject: [PATCH 1/5] ci: pin cargo-rbmt inputs --- Cargo.toml | 7 +++++++ codegen/Cargo.toml | 1 + fuzz/Cargo.toml | 1 + rbmt-version | 1 + 4 files changed, 10 insertions(+) create mode 100644 rbmt-version diff --git a/Cargo.toml b/Cargo.toml index 6216826b..d1022d64 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,6 +47,13 @@ getrandom = { version = "0.2", features = ["js"] } members = ["codegen", "fuzz"] exclude = ["bitcoind-tests", "lsp"] +[workspace.metadata.rbmt.toolchains] +nightly = "nightly-2025-08-23" +stable = "1.95.0" + +[workspace.metadata.rbmt.tools] +cargo-fuzz = "0.13.1" + [lints.clippy] # Exclude lints we don't think are valuable. large_enum_variant = "allow" # docs say "measure before paying attention to this"; why is it on by default?? diff --git a/codegen/Cargo.toml b/codegen/Cargo.toml index c09eaeaa..a178bdce 100644 --- a/codegen/Cargo.toml +++ b/codegen/Cargo.toml @@ -2,6 +2,7 @@ name = "codegen" version = "0.1.0" edition = "2021" +rust-version = "1.79.0" description = "Generator of Rust code as interface between SimplicityHL and Rust." publish = false diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index da5a9941..d9d129c1 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -3,6 +3,7 @@ name = "simplicityhl-fuzz" version = "0.0.0" publish = false edition = "2021" +rust-version = "1.79.0" [package.metadata] cargo-fuzz = true diff --git a/rbmt-version b/rbmt-version new file mode 100644 index 00000000..f2f70fda --- /dev/null +++ b/rbmt-version @@ -0,0 +1 @@ +1778ab50a2a0cb23fc23c20a47532a6eceb637e1 From 80c15a2cebc4d5cbc2d2bc03a890e3b1960bc469 Mon Sep 17 00:00:00 2001 From: Kyryl R Date: Wed, 13 May 2026 12:18:40 +0300 Subject: [PATCH 2/5] lint: prepare manifests for cargo-rbmt lint --- Cargo.toml | 8 ++++++-- fuzz/Cargo.toml | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d1022d64..35820433 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,10 @@ edition = "2021" rust-version = "1.79.0" default-run = "simc" +[package.metadata.rbmt.lint] +# Existing transitive split: derive_arbitrary uses syn 1 while serde/wasm tooling uses syn 2. +allowed_duplicates = ["syn"] + [lib] name = "simplicityhl" path = "src/lib.rs" @@ -82,7 +86,7 @@ copy_iterator = "warn" default_trait_access = "warn" doc_link_with_quotes = "warn" doc_markdown = "warn" -empty_enums = "warn" +empty_enum = "warn" enum_glob_use = "allow" expl_impl_clone_on_copy = "warn" explicit_deref_methods = "warn" @@ -166,7 +170,7 @@ struct_field_names = "warn" too_many_lines = "allow" transmute_ptr_to_ptr = "warn" trivially_copy_pass_by_ref = "warn" -unchecked_time_subtraction = "warn" +unchecked_duration_subtraction = "warn" unicode_not_nfc = "warn" unnecessary_box_returns = "warn" unnecessary_join = "warn" diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index d9d129c1..afe8284a 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -8,6 +8,10 @@ rust-version = "1.79.0" [package.metadata] cargo-fuzz = true +[package.metadata.rbmt.lint] +# Existing transitive split: derive_arbitrary uses syn 1 while serde/wasm tooling uses syn 2. +allowed_duplicates = ["syn"] + [dependencies] libfuzzer-sys = "0.4" arbitrary = { version = "1", features = ["derive"] } From 02807e77e9f1f5d00470b0ff36abd6bad98cf8d9 Mon Sep 17 00:00:00 2001 From: Kyryl R Date: Wed, 13 May 2026 12:19:25 +0300 Subject: [PATCH 3/5] lint: satisfy cargo-rbmt no-default clippy --- clippy.toml | 3 +-- src/lib.rs | 2 ++ src/main.rs | 18 ++++++++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/clippy.toml b/clippy.toml index 50164b13..754251e0 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1,5 +1,4 @@ -msrv = "1.79.0" # We have an error type, `RichError`, of size 144. This is pushing it but probably fine. large-error-threshold = 145 -doc-valid-idents = [ "SimplicityHL" ] \ No newline at end of file +doc-valid-idents = [ "SimplicityHL" ] diff --git a/src/lib.rs b/src/lib.rs index 0f0d2e00..2b978cf1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -554,6 +554,7 @@ pub(crate) mod tests { } } + #[cfg(feature = "serde")] pub fn get_encoding(self) -> String { let program_bytes = self.program.commit().to_vec_without_witness(); Base64Display::new(&program_bytes, &STANDARD).to_string() @@ -615,6 +616,7 @@ pub(crate) mod tests { } } + #[cfg(feature = "serde")] pub fn get_encoding_with_witness(self) -> (String, String) { let (program_bytes, witness_bytes) = self.program.redeem().to_vec_with_witness(); ( diff --git a/src/main.rs b/src/main.rs index 8d6a15cc..9f89d73d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -236,14 +236,20 @@ fn main() -> Result<(), Box> { if output_json { #[cfg(not(feature = "serde"))] - return Err( - "Program was compiled without the 'serde' feature and cannot output JSON.".into(), - ); + { + return Err( + "Program was compiled without the 'serde' feature and cannot output JSON.".into(), + ); + } + #[cfg(feature = "serde")] - println!("{}", serde_json::to_string(&output)?); - } else { - println!("{}", output); + { + println!("{}", serde_json::to_string(&output)?); + return Ok(()); + } } + println!("{}", output); + Ok(()) } From 53a4f3f84bdc5b2b1a0081457beae74fd6e97adf Mon Sep 17 00:00:00 2001 From: Kyryl R Date: Wed, 13 May 2026 12:19:48 +0300 Subject: [PATCH 4/5] ci: install cargo-rbmt in GitHub Actions --- .github/actions/setup-rbmt/action.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/actions/setup-rbmt/action.yml diff --git a/.github/actions/setup-rbmt/action.yml b/.github/actions/setup-rbmt/action.yml new file mode 100644 index 00000000..f95f36b1 --- /dev/null +++ b/.github/actions/setup-rbmt/action.yml @@ -0,0 +1,18 @@ +name: Setup RBMT +description: Install cargo-rbmt and pinned Rust toolchains. + +runs: + using: "composite" + steps: + - name: Install cargo-rbmt + shell: bash + run: | + cargo install \ + --git https://github.com/rust-bitcoin/rust-bitcoin-maintainer-tools \ + --rev "$(cat "${GITHUB_WORKSPACE}/rbmt-version")" \ + cargo-rbmt \ + --locked + + - name: Install Rust toolchains + shell: bash + run: cargo rbmt toolchains From e3147ff7a10b7b8f28838f7665cc77f1a2322b2b Mon Sep 17 00:00:00 2001 From: Kyryl R Date: Wed, 13 May 2026 12:22:09 +0300 Subject: [PATCH 5/5] ci: run Rust workflow through cargo-rbmt --- .../checkout-maintainer-tools/action.yml | 11 -- .github/workflows/rust.yml | 171 ++++-------------- nightly-version | 1 - 3 files changed, 32 insertions(+), 151 deletions(-) delete mode 100644 .github/actions/checkout-maintainer-tools/action.yml delete mode 100644 nightly-version 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/rust.yml b/.github/workflows/rust.yml index 2d2c3694..0410387e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -8,41 +8,20 @@ on: # yamllint disable-line rule:truthy 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 + Test: + name: Test - ${{ matrix.toolchain }} toolchain runs-on: ubuntu-latest strategy: fail-fast: false + matrix: + toolchain: [stable, nightly, msrv] 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: "Run test script" - run: ./maintainer-tools/ci/run_task.sh stable + - name: "Setup cargo-rbmt" + uses: ./.github/actions/setup-rbmt + - name: "Run tests" + run: cargo rbmt --lock-file existing test --toolchain ${{ matrix.toolchain }} Windows: name: Test - Windows stable toolchain @@ -57,118 +36,33 @@ jobs: - name: "Run tests" run: cargo test - 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: "Run test script" - run: ./maintainer-tools/ci/run_task.sh nightly - - MSRV: - name: Test - MSRV - 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@stable - with: - toolchain: ${{ needs.Prepare.outputs.msrv_version }} - - name: "Run test script" - run: ./maintainer-tools/ci/run_task.sh msrv - - 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: ./.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: "Run test script" - run: ./maintainer-tools/ci/run_task.sh 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: ./.github/actions/checkout-maintainer-tools - - name: "Select toolchain" - uses: dtolnay/rust-toolchain@stable - - name: "Run test script" - run: ./maintainer-tools/ci/run_task.sh docs - - Docsrs: - name: Docs - nightly toolchain - needs: Prepare + Check: + name: Check - ${{ matrix.task }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: - dep: [recent] + task: [lint, docs, docsrs] 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: "Run test script" - run: ./maintainer-tools/ci/run_task.sh docsrs + - name: "Setup cargo-rbmt" + uses: ./.github/actions/setup-rbmt + - name: "Run ${{ matrix.task }}" + run: cargo rbmt --lock-file existing ${{ matrix.task }} Format: - name: Format - nightly toolchain - needs: Prepare + name: Format runs-on: ubuntu-latest strategy: fail-fast: false steps: - name: "Checkout repo" 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: "Setup cargo-rbmt" + uses: ./.github/actions/setup-rbmt - name: "Check formatting" - run: cargo fmt --all -- --check + run: cargo rbmt fmt --check Wasm: name: Check WASM @@ -185,7 +79,6 @@ jobs: Fuzz: name: Check Fuzz - needs: Prepare runs-on: ubuntu-latest strategy: fail-fast: false @@ -193,23 +86,23 @@ jobs: - name: "Checkout repo" uses: actions/checkout@v4 - - name: "Select nightly toolchain" - uses: dtolnay/rust-toolchain@v1 - with: - toolchain: ${{ needs.Prepare.outputs.nightly_version }} + - name: "Setup cargo-rbmt" + uses: ./.github/actions/setup-rbmt + + - name: "Install cargo-fuzz" + run: cargo rbmt tools cargo-fuzz - name: "Check fuzz crate" - run: | - cargo check --manifest-path=fuzz/Cargo.toml + run: cargo rbmt --lock-file existing run --toolchain nightly -- check --manifest-path fuzz/Cargo.toml - - name: "Install cargo-fuzz" - run: | - cargo install cargo-fuzz --locked + - name: "Run fuzz target unit tests" + run: cargo rbmt --lock-file existing run --toolchain nightly -- test --manifest-path fuzz/Cargo.toml --bins - - name: "Run cargo-fuzz" + - name: "Run cargo-fuzz smoke tests" run: | set -euo pipefail + export RUSTUP_TOOLCHAIN="$(cargo rbmt toolchains --nightly)" cargo fuzz list --fuzz-dir fuzz | while read -r target; do - echo "fuzzing $target" - cargo fuzz run --fuzz-dir fuzz "$target" -- -runs=1 - done \ No newline at end of file + echo "fuzzing $target" + cargo fuzz run --fuzz-dir fuzz "$target" -- -runs=1 + done diff --git a/nightly-version b/nightly-version deleted file mode 100644 index d361064a..00000000 --- a/nightly-version +++ /dev/null @@ -1 +0,0 @@ -nightly-2025-08-23