Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: improve linting and setup ci in opt mode #8

Merged
merged 3 commits into from
Oct 16, 2023
Merged
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
24 changes: 21 additions & 3 deletions .cargo/config
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,27 @@
# clippy doesn't currently allow for specifiying project-wide lints in a
# configuration file. This is a similar workaround to the ones presented here:
# <https://github.com/EmbarkStudios/rust-ecosystem/issues/59>
# TODO: add support for --all-features
xclippy = [
"clippy", "--all-targets", "--",
"clippy", "--workspace", "--all-targets", "--",
"-Wclippy::all",
"-Wclippy::match_same_arms",
"-Wclippy::cast_lossless",
"-Wclippy::dbg_macro",
"-Wclippy::disallowed_methods",
]
"-Wclippy::derive_partial_eq_without_eq",
"-Wclippy::enum_glob_use",
"-Wclippy::filter_map_next",
"-Wclippy::flat_map_option",
"-Wclippy::inefficient_to_string",
"-Wclippy::large_types_passed_by_value",
"-Wclippy::manual_assert",
"-Wclippy::manual_ok_or",
"-Wclippy::map_flatten",
"-Wclippy::map_unwrap_or",
"-Wclippy::needless_borrow",
"-Wclippy::checked_conversions",
"-Wclippy::trait_duplication_in_bounds",
"-Wrust_2018_idioms",
"-Wtrivial_numeric_casts",
"-Wunused_lifetimes",
]
19 changes: 19 additions & 0 deletions .github/workflows/licenses-audits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: cargo-deny

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

env:
CARGO_TERM_COLOR: always

jobs:
cargo-deny:
name: cargo-deny (advisories, licenses, bans, ...)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v1
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
- name: cargo test
# TODO: --all-features
run: |
cargo nextest run --release --profile ci
cargo nextest run --profile ci --cargo-profile dev-ci
- name: Doctests
run: |
cargo test --doc
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
target
Cargo.lock
Cargo.lock
.vscode
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@ repository = "https://github.com/lurk-lab/bellpepper-gadgets"
bellpepper-core = { version="0.2.0", default-features = false }
bellpepper = { version="0.2.0", default-features = false }
ff = "0.13.0"

[profile.dev-ci]
inherits = "dev"
# By compiling dependencies with optimizations, performing tests gets much faster.
opt-level = 3
lto = "thin"
incremental = false
codegen-units = 16
21 changes: 8 additions & 13 deletions crates/emulated/src/field_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,11 @@ where
where
CS: ConstraintSystem<F>,
{
if self.overflow + 2 > Self::max_overflow() {
panic!(
assert!(self.overflow + 2 <= Self::max_overflow(),
"Not enough bits in native field to accomodate a subtraction operation which is performed during reduce: {} > {}",
self.overflow + 2,
Self::max_overflow(),
);
}

self.enforce_width_conditional(&mut cs.namespace(|| "ensure bitwidths in input"))?;
if self.overflow == 0 {
Expand Down Expand Up @@ -528,13 +526,12 @@ where
}

fn mul_precondition(a: &Self, b: &Self) -> Result<usize, OverflowError> {
if 2 * P::bits_per_limb() > F::CAPACITY as usize {
panic!(
"Not enough bits in native field to accomodate a product of limbs: {} < {}",
F::CAPACITY,
2 * P::bits_per_limb(),
);
}
assert!(
2 * P::bits_per_limb() <= F::CAPACITY as usize,
"Not enough bits in native field to accomodate a product of limbs: {} < {}",
F::CAPACITY,
2 * P::bits_per_limb(),
);
let reduce_right = a.overflow < b.overflow;
let max_carry_bits = (a.len().min(b.len()) as f32).log2().ceil() as usize;
let next_overflow = P::bits_per_limb() + a.overflow + b.overflow + max_carry_bits;
Expand Down Expand Up @@ -793,9 +790,7 @@ where
}

let pseudo_mersenne_params = P::pseudo_mersenne_params().unwrap();
if P::num_limbs() * P::bits_per_limb() < pseudo_mersenne_params.e as usize {
panic!("The number of bits available is too small to accommodate the non-native field elements");
}
assert!(P::num_limbs() * P::bits_per_limb() >= pseudo_mersenne_params.e as usize, "The number of bits available is too small to accommodate the non-native field elements");

let mut acc = chunks[0].clone();

Expand Down
Loading
Loading