Skip to content
Open
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
11 changes: 0 additions & 11 deletions .github/actions/checkout-maintainer-tools/action.yml

This file was deleted.

18 changes: 18 additions & 0 deletions .github/actions/setup-rbmt/action.yml
Original file line number Diff line number Diff line change
@@ -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
171 changes: 32 additions & 139 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -185,31 +79,30 @@ jobs:

Fuzz:
name: Check Fuzz
needs: Prepare
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- 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
echo "fuzzing $target"
cargo fuzz run --fuzz-dir fuzz "$target" -- -runs=1
done
15 changes: 13 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -47,6 +51,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??
Expand Down Expand Up @@ -75,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"
Expand Down Expand Up @@ -159,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"
Expand Down
3 changes: 1 addition & 2 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -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" ]
doc-valid-idents = [ "SimplicityHL" ]
1 change: 1 addition & 0 deletions codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ name = "simplicityhl-fuzz"
version = "0.0.0"
publish = false
edition = "2021"
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"] }
Expand Down
1 change: 0 additions & 1 deletion nightly-version

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 @@
1778ab50a2a0cb23fc23c20a47532a6eceb637e1
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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();
(
Expand Down
18 changes: 12 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,20 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

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(())
}
Loading