Serialize and hash custom predicates (#90)

* Print pods from SignedPodBuilder

* Add additional print to test printing SignedPodBuilder

* Mock-prove and print MainPod

* Implement ToFields for custom predicates and dependencies

* Test: print serialization of a recursive batch

* Rearrange serialization of CustomPredicate so args_len is always in the same position

* Serialize predicates with first entry nonzero to avoid collision with padding

* Off by one error in ethdos test BatchSelf(2)

* cargo fmt

* not a typo

* Typos, trying again
This commit is contained in:
tideofwords 2025-02-26 11:28:27 -08:00 committed by GitHub
parent 05c21ebe6a
commit a37b96ab4f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 262 additions and 39 deletions

View file

@ -171,13 +171,16 @@ fn resolve_wildcard(args: &[&str], priv_args: &[&str], v: &HashOrWildcardStr) ->
#[cfg(test)]
mod tests {
use super::*;
use crate::middleware::{CustomPredicateRef, PodType};
use crate::middleware::{CustomPredicateRef, Params, PodType};
#[test]
fn test_custom_pred() {
use NativePredicate as NP;
use StatementTmplBuilder as STB;
let params = Params::default();
params.print_serialized_sizes();
let mut builder = CustomPredicateBatchBuilder::new("eth_friend".into());
let _eth_friend = builder.predicate_and(
// arguments:
@ -239,7 +242,7 @@ mod tests {
builder.predicates.last().unwrap()
);
let eth_dos_distance = Predicate::BatchSelf(3);
let eth_dos_distance = Predicate::BatchSelf(2);
// next chunk builds:
let eth_dos_distance_ind = builder.predicate_and(
@ -311,5 +314,9 @@ mod tests {
"b.2. eth_dos_distance = {}",
builder.predicates.last().unwrap()
);
let eth_dos_batch_b = builder.finish();
let fields = eth_dos_batch_b.to_fields(params);
println!("Batch b, serialized: {:?}", fields);
}
}