Skip to content

Commit 87acf0d

Browse files
authored
Fix the build (#221)
Including: removing ABY's testing from the CI since the test infrastructure is pinned to specific a specific Ubuntu version.
1 parent 589ae00 commit 87acf0d

File tree

14 files changed

+43
-30
lines changed

14 files changed

+43
-30
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ jobs:
3737
- name: Document
3838
run: python3 driver.py --doc
3939
- name: Build, then Test
40-
run: python3 driver.py --test
40+
run: python3 driver.py --test --ci

driver.py

+15-5
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def build(features):
165165
log_run_check(["./scripts/build_mpc_zokrates_test.zsh"])
166166

167167

168-
def test(features, extra_args):
168+
def test(features, ci: bool, extra_args):
169169
"""
170170
Run cargo tests and any test cases in the feature list
171171
@@ -176,6 +176,9 @@ def test(features, extra_args):
176176
177177
extra_args: list of str
178178
extra arguments to pass to cargo
179+
180+
ci: bool
181+
whether to disable some tests b/c of CI limitations
179182
"""
180183

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

199202
if "zok" in features and "smt" in features:
200-
if "aby" in features:
203+
if "aby" in features and not ci:
201204
log_run_check(["python3", "./scripts/aby_tests/zokrates_test_aby.py"])
202205
if "lp" in features:
203206
log_run_check(["./scripts/test_zok_to_ilp.zsh"])
@@ -213,7 +216,7 @@ def test(features, extra_args):
213216
log_run_check(["./scripts/test_zok_to_ilp_pf.zsh"])
214217

215218
if "c" in features:
216-
if "aby" in features:
219+
if "aby" in features and not ci:
217220
log_run_check(["python3", "./scripts/aby_tests/c_test_aby.py"])
218221
if "smt" in features:
219222
log_run_check(["./scripts/test_c_smt.zsh"])
@@ -362,6 +365,11 @@ def format_sub_process_cmd(r: subprocess.CalledProcessError) -> str:
362365
parser.add_argument(
363366
"-l", "--lint", action="store_true", help="run `cargo clippy`"
364367
)
368+
parser.add_argument(
369+
"--ci",
370+
action="store_true",
371+
help="customize commands for CI, where some things are hard to run",
372+
)
365373
parser.add_argument(
366374
"--flamegraph", action="store_true", help="run `cargo flamegraph`"
367375
)
@@ -402,7 +410,9 @@ def verify_single_action(args: argparse.Namespace):
402410
actions = [
403411
k
404412
for k, v in vars(args).items()
405-
if (type(v) is bool or k in ["features", "mode"]) and bool(v)
413+
if (type(v) is bool or k in ["features", "mode"])
414+
and bool(v)
415+
and k not in ["ci"]
406416
]
407417
if len(actions) != 1:
408418
parser.error(
@@ -443,7 +453,7 @@ def verify_extra_implies_flamegraph_or_test(args: argparse.Namespace):
443453
build(features)
444454

445455
if args.test:
446-
test(features, args.extra)
456+
test(features, args.ci, args.extra)
447457

448458
if args.benchmark:
449459
benchmark(features)

src/front/c/ast_utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub fn name_from_decl(decl: &Declarator) -> String {
6161

6262
pub fn compress_type(ts: Vec<Option<Ty>>) -> Option<Ty> {
6363
if ts.len() == 1 {
64-
return ts.first().unwrap().clone();
64+
ts.first().unwrap().clone()
6565
} else {
6666
let mut signed: bool = true;
6767
let mut _void: bool = false;

src/front/c/mod.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl CGen {
183183

184184
/// TODO: Refactor with s_type_ / d_type_
185185
fn type_(&mut self, t: &TypeSpecifier) -> Option<Ty> {
186-
return match t {
186+
match t {
187187
TypeSpecifier::Void => None,
188188
TypeSpecifier::Int => Some(Ty::Int(true, 32)),
189189
TypeSpecifier::Unsigned => Some(Ty::Int(false, 32)),
@@ -244,7 +244,7 @@ impl CGen {
244244
}
245245
}
246246
_ => unimplemented!("Type {:#?} not implemented yet.", t),
247-
};
247+
}
248248
}
249249

250250
fn get_inner_derived_type(&mut self, base_ty: &Ty, d: &DerivedDeclarator) -> Ty {
@@ -1134,12 +1134,11 @@ impl CGen {
11341134
}
11351135
};
11361136
}
1137-
Statement::Expression(expr) => match expr {
1138-
Some(e) => {
1137+
Statement::Expression(expr) => {
1138+
if let Some(e) = expr {
11391139
self.gen_expr(&e.node);
11401140
}
1141-
None => {}
1142-
},
1141+
}
11431142
Statement::For(for_stmt) => {
11441143
// TODO: Add enter_breakable
11451144
self.circ_enter_scope();

src/front/datalog/error.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub struct Error<'ast> {
3434
pub span: Option<Span<'ast>>,
3535
}
3636

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

50-
impl<'ast> From<ErrorKind> for Error<'ast> {
50+
impl From<ErrorKind> for Error<'_> {
5151
fn from(error_kind: ErrorKind) -> Self {
5252
Error {
5353
kind: error_kind,
@@ -56,7 +56,7 @@ impl<'ast> From<ErrorKind> for Error<'ast> {
5656
}
5757
}
5858

59-
impl<'ast> From<crate::circify::CircError> for Error<'ast> {
59+
impl From<crate::circify::CircError> for Error<'_> {
6060
fn from(circ: crate::circify::CircError) -> Self {
6161
Error {
6262
kind: ErrorKind::Circify(circ),

src/front/zsharp/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ struct ZGen<'ast> {
133133
#[derive(Debug, Clone, PartialEq, Hash, Eq)]
134134
struct FnCallImplInput(bool, Vec<T>, Vec<(String, T)>, PathBuf, String);
135135

136-
impl<'ast> Drop for ZGen<'ast> {
136+
impl Drop for ZGen<'_> {
137137
fn drop(&mut self) {
138138
use std::mem::take;
139139

src/front/zsharp/zvisit/zstmtwalker/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ impl<'ast, 'ret> ZStatementWalker<'ast, 'ret> {
729729
}
730730
}
731731

732-
impl<'ast, 'ret> ZVisitorMut<'ast> for ZStatementWalker<'ast, 'ret> {
732+
impl<'ast> ZVisitorMut<'ast> for ZStatementWalker<'ast, '_> {
733733
fn visit_return_statement(&mut self, ret: &mut ast::ReturnStatement<'ast>) -> ZVisitorResult {
734734
if self.rets.len() != ret.expressions.len() {
735735
return Err(ZVisitorError(

src/front/zsharp/zvisit/zstmtwalker/zexprtyper.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl<'ast, 'ret, 'wlk> ZExpressionTyper<'ast, 'ret, 'wlk> {
5959
}
6060
}
6161

62-
impl<'ast, 'ret, 'wlk> ZVisitorMut<'ast> for ZExpressionTyper<'ast, 'ret, 'wlk> {
62+
impl<'ast> ZVisitorMut<'ast> for ZExpressionTyper<'ast, '_, '_> {
6363
fn visit_expression(&mut self, expr: &mut ast::Expression<'ast>) -> ZVisitorResult {
6464
use ast::Expression::*;
6565
if self.ty.is_some() {

src/ir/opt/link.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub fn link_one(callee: &Computation, values: Vec<Term>) -> Term {
4545
)
4646
}
4747

48-
impl<'f> Linker<'f> {
48+
impl Linker<'_> {
4949
/// Ensure that a totally linked version of `name` is in the cache.
5050
fn link_all(&mut self, name: &str) {
5151
if !self.cache.contains_key(name) {
@@ -66,7 +66,7 @@ impl<'f> Linker<'f> {
6666
/// Rewrites a term, inlining function calls along the way.
6767
///
6868
/// Assumes that the callees are already inlined. Panics otherwise.
69-
impl<'f> RewritePass for Linker<'f> {
69+
impl RewritePass for Linker<'_> {
7070
fn visit<F: Fn() -> Vec<Term>>(
7171
&mut self,
7272
_computation: &mut Computation,

src/ir/term/dist.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -267,15 +267,15 @@ impl rand::distributions::Distribution<BitVector> for UniformBitVector {
267267

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

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

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

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

316316
#[cfg(test)]
317+
/// Utilities for random testing.
317318
pub mod test {
318319
use super::*;
319320

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

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

328330
impl Arbitrary for PureBool {
@@ -353,6 +355,7 @@ pub mod test {
353355
}
354356

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

358361
impl std::fmt::Debug for ArbitraryTerm {

src/ir/term/fmt.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ impl<'a, 'b> IrFormatter<'a, 'b> {
281281
}
282282
}
283283

284-
impl<'a, 'b> Write for IrFormatter<'a, 'b> {
284+
impl Write for IrFormatter<'_, '_> {
285285
fn write_str(&mut self, s: &str) -> FmtResult {
286286
self.writer.write_str(s)
287287
}
@@ -509,7 +509,7 @@ impl DisplayIr for FieldV {
509509
let omit_field = f.cfg.hide_field
510510
|| f.default_field
511511
.as_ref()
512-
.map_or(false, |field| field == &self.ty());
512+
.is_some_and(|field| field == &self.ty());
513513
let mut i = self.i();
514514
let mod_bits = self.modulus().significant_bits();
515515
if i.significant_bits() + 1 >= mod_bits {
@@ -666,13 +666,13 @@ fn fmt_term_with_bindings(t: &Term, f: &mut IrFormatter) -> FmtResult {
666666
Ok(())
667667
}
668668

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

675-
impl<'a> Debug for IrWrapper<'a, Term> {
675+
impl Debug for IrWrapper<'_, Term> {
676676
fn fmt(&self, f: &mut Formatter) -> FmtResult {
677677
let cfg = IrCfg::from_circ_cfg();
678678
let f = &mut IrFormatter::new(f, &cfg);

src/ir/term/text/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ enum TokTree<'src> {
9494

9595
use TokTree::*;
9696

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

118-
impl<'src> Debug for TokTree<'src> {
118+
impl Debug for TokTree<'_> {
119119
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
120120
match self {
121121
Leaf(_, l) => write!(f, "{}", from_utf8(l).unwrap()),

src/target/r1cs/bellman.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub(super) fn get_modulus<F: Field + PrimeField>() -> Integer {
7272
/// bellman prover.
7373
pub struct SynthInput<'a>(&'a ProverData, Option<&'a FxHashMap<String, Value>>);
7474

75-
impl<'a, F: PrimeField> Circuit<F> for SynthInput<'a> {
75+
impl<F: PrimeField> Circuit<F> for SynthInput<'_> {
7676
#[track_caller]
7777
fn synthesize<CS>(self, cs: &mut CS) -> std::result::Result<(), SynthesisError>
7878
where

src/target/r1cs/trans.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,7 @@ pub fn to_r1cs(cs: &Computation, cfg: &CircCfg) -> R1cs {
11671167
}
11681168

11691169
#[cfg(test)]
1170+
/// Tests for this module.
11701171
pub mod test {
11711172
use super::*;
11721173

0 commit comments

Comments
 (0)