mirror of
https://github.com/circify/circ.git
synced 2026-01-09 13:48:02 -05:00
Fix the build (#221)
Including: removing ABY's testing from the CI since the test infrastructure is pinned to specific a specific Ubuntu version.
This commit is contained in:
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -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
driver.py
20
driver.py
@@ -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
|
||||
|
||||
@@ -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)
|
||||
@@ -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"])
|
||||
@@ -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"])
|
||||
@@ -362,6 +365,11 @@ if __name__ == "__main__":
|
||||
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`"
|
||||
)
|
||||
@@ -402,7 +410,9 @@ if __name__ == "__main__":
|
||||
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(
|
||||
@@ -443,7 +453,7 @@ if __name__ == "__main__":
|
||||
build(features)
|
||||
|
||||
if args.test:
|
||||
test(features, args.extra)
|
||||
test(features, args.ci, args.extra)
|
||||
|
||||
if args.benchmark:
|
||||
benchmark(features)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)),
|
||||
@@ -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 {
|
||||
@@ -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();
|
||||
|
||||
@@ -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 {
|
||||
@@ -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,
|
||||
@@ -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),
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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) {
|
||||
@@ -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,
|
||||
|
||||
@@ -267,7 +267,7 @@ 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)
|
||||
}
|
||||
@@ -275,7 +275,7 @@ impl<'a> rand::distributions::Distribution<FieldV> for UniformFieldV<'a> {
|
||||
|
||||
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()),
|
||||
@@ -314,6 +314,7 @@ impl rand::distributions::Distribution<Term> for FixedSizeDist {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
/// Utilities for random testing.
|
||||
pub mod test {
|
||||
use super::*;
|
||||
|
||||
@@ -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 {
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
@@ -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 {
|
||||
@@ -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);
|
||||
|
||||
@@ -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()),
|
||||
@@ -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()),
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1167,6 +1167,7 @@ pub fn to_r1cs(cs: &Computation, cfg: &CircCfg) -> R1cs {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
/// Tests for this module.
|
||||
pub mod test {
|
||||
use super::*;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user