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:
parent
05c21ebe6a
commit
a37b96ab4f
8 changed files with 262 additions and 39 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use anyhow::{anyhow, Result};
|
||||
use std::fmt;
|
||||
|
||||
use crate::middleware::{self, NativePredicate, StatementArg, ToFields};
|
||||
use crate::middleware::{self, NativePredicate, Params, StatementArg, ToFields};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct Statement(pub NativePredicate, pub Vec<StatementArg>);
|
||||
|
|
@ -21,12 +21,13 @@ impl Statement {
|
|||
}
|
||||
|
||||
impl ToFields for Statement {
|
||||
fn to_fields(self) -> (Vec<middleware::F>, usize) {
|
||||
let (native_statement_f, native_statement_f_len) = self.0.to_fields();
|
||||
fn to_fields(&self, params: Params) -> (Vec<middleware::F>, usize) {
|
||||
let (native_statement_f, native_statement_f_len) = self.0.to_fields(params);
|
||||
let (vec_statementarg_f, vec_statementarg_f_len) = self
|
||||
.1
|
||||
.clone()
|
||||
.into_iter()
|
||||
.map(|statement_arg| statement_arg.to_fields())
|
||||
.map(|statement_arg| statement_arg.to_fields(params))
|
||||
.fold((Vec::new(), 0), |mut acc, (f, l)| {
|
||||
acc.0.extend(f);
|
||||
acc.1 += l;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue