Skip to content

Commit

Permalink
fix LEM's Func::num_constraints and syntax test unit_parse_num
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurpaulino committed Oct 21, 2023
1 parent 4f19d4b commit e74150d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/lem/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use crate::{
},
coprocessor::Coprocessor,
eval::lang::Lang,
field::{FWrap, LurkField},
field::{FWrap, LanguageField, LurkField},
tag::ExprTag::{Comm, Num, Sym},
};

Expand Down Expand Up @@ -1485,12 +1485,19 @@ impl Func {
}
}
let globals = &mut HashSet::default();
let bit_decomp_cost = match F::FIELD {
LanguageField::Pallas => 298,

Check warning on line 1489 in src/lem/circuit.rs

View check run for this annotation

Codecov / codecov/patch

src/lem/circuit.rs#L1488-L1489

Added lines #L1488 - L1489 were not covered by tests
LanguageField::Vesta => 301,
LanguageField::BLS12_381 => 388,
_ => todo!(),
};

Check warning on line 1494 in src/lem/circuit.rs

View check run for this annotation

Codecov / codecov/patch

src/lem/circuit.rs#L1493-L1494

Added lines #L1493 - L1494 were not covered by tests
// fixed cost for each slot
let slot_constraints = 289 * self.slot.hash4
+ 337 * self.slot.hash6
+ 388 * self.slot.hash8
+ 265 * self.slot.commitment
+ 388 * self.slot.bit_decomp;
+ bit_decomp_cost * self.slot.bit_decomp;

Check warning on line 1500 in src/lem/circuit.rs

View check run for this annotation

Codecov / codecov/patch

src/lem/circuit.rs#L1500

Added line #L1500 was not covered by tests
let num_constraints = recurse(&self.body, globals, store, false);
slot_constraints + num_constraints + globals.len()
}
Expand Down
4 changes: 2 additions & 2 deletions src/parser/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -867,15 +867,15 @@ pub mod tests {
));
assert!(test(
parse_num(),
"0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000000",
"0x40000000000000000000000000000000224698fc0994a8dd8c46eb2100000000",

Check warning on line 870 in src/parser/syntax.rs

View check run for this annotation

Codecov / codecov/patch

src/parser/syntax.rs#L870

Added line #L870 was not covered by tests
Some(Syntax::Num(
Pos::No,
Num::Scalar(<Scalar as ff::Field>::ZERO - Scalar::from(1u64))
)),
));
assert!(test(
parse_num(),
"0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001",
"0x40000000000000000000000000000000224698fc0994a8dd8c46eb2100000001",

Check warning on line 878 in src/parser/syntax.rs

View check run for this annotation

Codecov / codecov/patch

src/parser/syntax.rs#L878

Added line #L878 was not covered by tests
None,
));
assert!(test(parse_num(), "-0", Some(num!(0))));
Expand Down

0 comments on commit e74150d

Please sign in to comment.