Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ jobs:
- name: Document
run: python3 driver.py --doc
- name: Build, then Test
run: python3 driver.py --test
run: python3 driver.py --test --ci
20 changes: 15 additions & 5 deletions driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def build(features):
log_run_check(["./scripts/build_mpc_zokrates_test.zsh"])


def test(features, extra_args):
def test(features, ci: bool, extra_args):
"""
Run cargo tests and any test cases in the feature list

Expand All @@ -176,6 +176,9 @@ def test(features, extra_args):

extra_args: list of str
extra arguments to pass to cargo

ci: bool
whether to disable some tests b/c of CI limitations
"""

build(features)
Expand All @@ -197,7 +200,7 @@ def test(features, extra_args):
log_run_check(["./scripts/test_datalog.zsh"])

if "zok" in features and "smt" in features:
if "aby" in features:
if "aby" in features and not ci:
log_run_check(["python3", "./scripts/aby_tests/zokrates_test_aby.py"])
if "lp" in features:
log_run_check(["./scripts/test_zok_to_ilp.zsh"])
Expand All @@ -213,7 +216,7 @@ def test(features, extra_args):
log_run_check(["./scripts/test_zok_to_ilp_pf.zsh"])

if "c" in features:
if "aby" in features:
if "aby" in features and not ci:
log_run_check(["python3", "./scripts/aby_tests/c_test_aby.py"])
if "smt" in features:
log_run_check(["./scripts/test_c_smt.zsh"])
Expand Down Expand Up @@ -362,6 +365,11 @@ def format_sub_process_cmd(r: subprocess.CalledProcessError) -> str:
parser.add_argument(
"-l", "--lint", action="store_true", help="run `cargo clippy`"
)
parser.add_argument(
"--ci",
action="store_true",
help="customize commands for CI, where some things are hard to run",
)
parser.add_argument(
"--flamegraph", action="store_true", help="run `cargo flamegraph`"
)
Expand Down Expand Up @@ -402,7 +410,9 @@ def verify_single_action(args: argparse.Namespace):
actions = [
k
for k, v in vars(args).items()
if (type(v) is bool or k in ["features", "mode"]) and bool(v)
if (type(v) is bool or k in ["features", "mode"])
and bool(v)
and k not in ["ci"]
]
if len(actions) != 1:
parser.error(
Expand Down Expand Up @@ -443,7 +453,7 @@ def verify_extra_implies_flamegraph_or_test(args: argparse.Namespace):
build(features)

if args.test:
test(features, args.extra)
test(features, args.ci, args.extra)

if args.benchmark:
benchmark(features)
Expand Down
2 changes: 1 addition & 1 deletion src/front/c/ast_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub fn name_from_decl(decl: &Declarator) -> String {

pub fn compress_type(ts: Vec<Option<Ty>>) -> Option<Ty> {
if ts.len() == 1 {
return ts.first().unwrap().clone();
ts.first().unwrap().clone()
} else {
let mut signed: bool = true;
let mut _void: bool = false;
Expand Down
11 changes: 5 additions & 6 deletions src/front/c/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl CGen {

/// TODO: Refactor with s_type_ / d_type_
fn type_(&mut self, t: &TypeSpecifier) -> Option<Ty> {
return match t {
match t {
TypeSpecifier::Void => None,
TypeSpecifier::Int => Some(Ty::Int(true, 32)),
TypeSpecifier::Unsigned => Some(Ty::Int(false, 32)),
Expand Down Expand Up @@ -244,7 +244,7 @@ impl CGen {
}
}
_ => unimplemented!("Type {:#?} not implemented yet.", t),
};
}
}

fn get_inner_derived_type(&mut self, base_ty: &Ty, d: &DerivedDeclarator) -> Ty {
Expand Down Expand Up @@ -1134,12 +1134,11 @@ impl CGen {
}
};
}
Statement::Expression(expr) => match expr {
Some(e) => {
Statement::Expression(expr) => {
if let Some(e) = expr {
self.gen_expr(&e.node);
}
None => {}
},
}
Statement::For(for_stmt) => {
// TODO: Add enter_breakable
self.circ_enter_scope();
Expand Down
6 changes: 3 additions & 3 deletions src/front/datalog/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub struct Error<'ast> {
pub span: Option<Span<'ast>>,
}

impl<'ast> Display for Error<'ast> {
impl Display for Error<'_> {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
writeln!(f, "Error: {}", self.kind)?;
if let Some(s) = &self.span {
Expand All @@ -47,7 +47,7 @@ impl<'ast> Display for Error<'ast> {
}
}

impl<'ast> From<ErrorKind> for Error<'ast> {
impl From<ErrorKind> for Error<'_> {
fn from(error_kind: ErrorKind) -> Self {
Error {
kind: error_kind,
Expand All @@ -56,7 +56,7 @@ impl<'ast> From<ErrorKind> for Error<'ast> {
}
}

impl<'ast> From<crate::circify::CircError> for Error<'ast> {
impl From<crate::circify::CircError> for Error<'_> {
fn from(circ: crate::circify::CircError) -> Self {
Error {
kind: ErrorKind::Circify(circ),
Expand Down
2 changes: 1 addition & 1 deletion src/front/zsharp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ struct ZGen<'ast> {
#[derive(Debug, Clone, PartialEq, Hash, Eq)]
struct FnCallImplInput(bool, Vec<T>, Vec<(String, T)>, PathBuf, String);

impl<'ast> Drop for ZGen<'ast> {
impl Drop for ZGen<'_> {
fn drop(&mut self) {
use std::mem::take;

Expand Down
2 changes: 1 addition & 1 deletion src/front/zsharp/zvisit/zstmtwalker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ impl<'ast, 'ret> ZStatementWalker<'ast, 'ret> {
}
}

impl<'ast, 'ret> ZVisitorMut<'ast> for ZStatementWalker<'ast, 'ret> {
impl<'ast> ZVisitorMut<'ast> for ZStatementWalker<'ast, '_> {
fn visit_return_statement(&mut self, ret: &mut ast::ReturnStatement<'ast>) -> ZVisitorResult {
if self.rets.len() != ret.expressions.len() {
return Err(ZVisitorError(
Expand Down
2 changes: 1 addition & 1 deletion src/front/zsharp/zvisit/zstmtwalker/zexprtyper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl<'ast, 'ret, 'wlk> ZExpressionTyper<'ast, 'ret, 'wlk> {
}
}

impl<'ast, 'ret, 'wlk> ZVisitorMut<'ast> for ZExpressionTyper<'ast, 'ret, 'wlk> {
impl<'ast> ZVisitorMut<'ast> for ZExpressionTyper<'ast, '_, '_> {
fn visit_expression(&mut self, expr: &mut ast::Expression<'ast>) -> ZVisitorResult {
use ast::Expression::*;
if self.ty.is_some() {
Expand Down
4 changes: 2 additions & 2 deletions src/ir/opt/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn link_one(callee: &Computation, values: Vec<Term>) -> Term {
)
}

impl<'f> Linker<'f> {
impl Linker<'_> {
/// Ensure that a totally linked version of `name` is in the cache.
fn link_all(&mut self, name: &str) {
if !self.cache.contains_key(name) {
Expand All @@ -66,7 +66,7 @@ impl<'f> Linker<'f> {
/// Rewrites a term, inlining function calls along the way.
///
/// Assumes that the callees are already inlined. Panics otherwise.
impl<'f> RewritePass for Linker<'f> {
impl RewritePass for Linker<'_> {
fn visit<F: Fn() -> Vec<Term>>(
&mut self,
_computation: &mut Computation,
Expand Down
7 changes: 5 additions & 2 deletions src/ir/term/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,15 @@ impl rand::distributions::Distribution<BitVector> for UniformBitVector {

pub(crate) struct UniformFieldV<'a>(&'a FieldT);

impl<'a> rand::distributions::Distribution<FieldV> for UniformFieldV<'a> {
impl rand::distributions::Distribution<FieldV> for UniformFieldV<'_> {
fn sample<R: rand::Rng + ?Sized>(&self, rng: &mut R) -> FieldV {
self.0.random_v(rng)
}
}

pub(crate) struct UniformValue<'a>(pub &'a Sort);

impl<'a> rand::distributions::Distribution<Value> for UniformValue<'a> {
impl rand::distributions::Distribution<Value> for UniformValue<'_> {
fn sample<R: rand::Rng + ?Sized>(&self, rng: &mut R) -> Value {
match self.0 {
Sort::Bool => Value::Bool(rng.gen()),
Expand Down Expand Up @@ -314,6 +314,7 @@ impl rand::distributions::Distribution<Term> for FixedSizeDist {
}

#[cfg(test)]
/// Utilities for random testing.
pub mod test {
use super::*;

Expand All @@ -323,6 +324,7 @@ pub mod test {
use rand::SeedableRng;

#[derive(Clone, Debug)]
/// A random term with only Boolean descendents and values for its variables.
pub struct PureBool(pub Term, pub FxHashMap<String, Value>);

impl Arbitrary for PureBool {
Expand Down Expand Up @@ -353,6 +355,7 @@ pub mod test {
}

#[derive(Clone)]
/// A random term and values for its variables.
pub struct ArbitraryTerm(pub Term);

impl std::fmt::Debug for ArbitraryTerm {
Expand Down
8 changes: 4 additions & 4 deletions src/ir/term/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ impl<'a, 'b> IrFormatter<'a, 'b> {
}
}

impl<'a, 'b> Write for IrFormatter<'a, 'b> {
impl Write for IrFormatter<'_, '_> {
fn write_str(&mut self, s: &str) -> FmtResult {
self.writer.write_str(s)
}
Expand Down Expand Up @@ -509,7 +509,7 @@ impl DisplayIr for FieldV {
let omit_field = f.cfg.hide_field
|| f.default_field
.as_ref()
.map_or(false, |field| field == &self.ty());
.is_some_and(|field| field == &self.ty());
let mut i = self.i();
let mod_bits = self.modulus().significant_bits();
if i.significant_bits() + 1 >= mod_bits {
Expand Down Expand Up @@ -666,13 +666,13 @@ fn fmt_term_with_bindings(t: &Term, f: &mut IrFormatter) -> FmtResult {
Ok(())
}

impl<'a> Display for IrWrapper<'a, Term> {
impl Display for IrWrapper<'_, Term> {
fn fmt(&self, f: &mut Formatter) -> FmtResult {
write!(f, "{self:?}")
}
}

impl<'a> Debug for IrWrapper<'a, Term> {
impl Debug for IrWrapper<'_, Term> {
fn fmt(&self, f: &mut Formatter) -> FmtResult {
let cfg = IrCfg::from_circ_cfg();
let f = &mut IrFormatter::new(f, &cfg);
Expand Down
4 changes: 2 additions & 2 deletions src/ir/term/text/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ enum TokTree<'src> {

use TokTree::*;

impl<'src> Display for TokTree<'src> {
impl Display for TokTree<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
Leaf(_, l) => write!(f, "{}", from_utf8(l).unwrap()),
Expand All @@ -115,7 +115,7 @@ impl<'src> Display for TokTree<'src> {
}
}

impl<'src> Debug for TokTree<'src> {
impl Debug for TokTree<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
Leaf(_, l) => write!(f, "{}", from_utf8(l).unwrap()),
Expand Down
2 changes: 1 addition & 1 deletion src/target/r1cs/bellman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub(super) fn get_modulus<F: Field + PrimeField>() -> Integer {
/// bellman prover.
pub struct SynthInput<'a>(&'a ProverData, Option<&'a FxHashMap<String, Value>>);

impl<'a, F: PrimeField> Circuit<F> for SynthInput<'a> {
impl<F: PrimeField> Circuit<F> for SynthInput<'_> {
#[track_caller]
fn synthesize<CS>(self, cs: &mut CS) -> std::result::Result<(), SynthesisError>
where
Expand Down
1 change: 1 addition & 0 deletions src/target/r1cs/trans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,7 @@ pub fn to_r1cs(cs: &Computation, cfg: &CircCfg) -> R1cs {
}

#[cfg(test)]
/// Tests for this module.
pub mod test {
use super::*;

Expand Down
Loading