Skip to content

Commit

Permalink
fix LEM's Func::num_constraints and syntax parsing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurpaulino committed Oct 21, 2023
1 parent 4f19d4b commit 24aeba6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 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
8 changes: 4 additions & 4 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 All @@ -891,7 +891,7 @@ pub mod tests {
#[test]
fn unit_parse_syntax_misc() {
let vec: Vec<u8> = vec![
0x6e, 0x2e, 0x50, 0x55, 0xdc, 0xf6, 0x14, 0x86, 0xb0, 0x3b, 0xb8, 0x0e, 0xd2, 0xb3,
0x3e, 0x2e, 0x50, 0x55, 0xdc, 0xf6, 0x14, 0x86, 0xb0, 0x3b, 0xb8, 0x0e, 0xd2, 0xb3,

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

View check run for this annotation

Codecov / codecov/patch

src/parser/syntax.rs#L894

Added line #L894 was not covered by tests
0xf1, 0xa3, 0x5c, 0x30, 0xe1, 0x22, 0xde, 0xfe, 0xba, 0xe8, 0x24, 0xfa, 0xe4, 0xed,
0x32, 0x40, 0x8e, 0x87,
]
Expand All @@ -908,7 +908,7 @@ pub mod tests {
));
assert!(test(
parse_syntax(state(), false, true),
"(0x6e2e5055dcf61486b03bb80ed2b3f1a35c30e122defebae824fae4ed32408e87)",
"(0x3e2e5055dcf61486b03bb80ed2b3f1a35c30e122defebae824fae4ed32408e87)",

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

View check run for this annotation

Codecov / codecov/patch

src/parser/syntax.rs#L911

Added line #L911 was not covered by tests
Some(list!([num!(Num::Scalar(f_from_le_bytes(&vec)))])),
));
assert!(test(
Expand Down

0 comments on commit 24aeba6

Please sign in to comment.