Split Params into base and developer-defined (#458)
I thought it would be nice to have a Predicate for the typed value so that the developer can work with predicates as values comfortably. Then I noticed that hashing a predicate required `Params` which would have been annoying for converting a `TypedValue::Predicate` to `RawValue` and this led to a small refactor over how `Params` work. We already had some fields in the `Params` struct that determine compatibility between encoded data. They can be seen as determining a kind of ABI compatibility. In general it's better if those parameters don't change so that different circuit configurations can still verify proofs from each other. So I decided to force those parameters to be constant in the code base and not allow the user of our library to change them. Many field element serialization/deserialization functions in our code depended on those parameters, and since now they are constant many functions get rid of the `Params` argument, which simplifies the code. This includes the serialization of a `Predicate` which was required to calculate its hash.
This commit is contained in:
parent
498e946612
commit
a7a30176a7
20 changed files with 376 additions and 468 deletions
|
|
@ -355,7 +355,7 @@ pub fn batch_predicates(
|
|||
}
|
||||
|
||||
// Plan batch assignments in declaration order
|
||||
let assignments = plan_batch_assignments(&predicates, params.max_custom_batch_size)?;
|
||||
let assignments = plan_batch_assignments(&predicates, Params::max_custom_batch_size())?;
|
||||
|
||||
// Build reference map: name -> (batch_idx, idx_in_batch)
|
||||
let reference_map: HashMap<String, (usize, usize)> = assignments
|
||||
|
|
@ -1039,18 +1039,18 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_mutual_recursion_exceeds_capacity_error() {
|
||||
// Two predicates that call each other (SCC size = 2) with max batch size 1
|
||||
// Two predicates that call each other (SCC size = 5) with max batch size 4
|
||||
// Should error because an SCC cannot be split across batches
|
||||
let input = r#"
|
||||
pred1(A) = AND(pred2(A))
|
||||
pred2(B) = AND(pred1(B))
|
||||
pred2(B) = AND(pred3(B))
|
||||
pred3(B) = AND(pred4(B))
|
||||
pred4(B) = AND(pred5(B))
|
||||
pred5(B) = AND(pred1(B))
|
||||
"#;
|
||||
|
||||
let (predicates, validated) = parse_and_validate(input);
|
||||
let params = Params {
|
||||
max_custom_batch_size: 1, // force SCC > capacity
|
||||
..Default::default()
|
||||
};
|
||||
let params = Params::default();
|
||||
|
||||
let result = batch_predicates(
|
||||
preds_to_split_results(predicates),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue