diff --git a/src/coprocessor/memoset/demo.rs b/src/coprocessor/memoset/demo.rs index 53f04fe84a..6b5c601819 100644 --- a/src/coprocessor/memoset/demo.rs +++ b/src/coprocessor/memoset/demo.rs @@ -29,7 +29,7 @@ impl Query for DemoQuery { type CQ = DemoCircuitQuery; // DemoQuery and Scope depend on each other. - fn eval(&self, s: &Store, scope: &mut Scope>) -> Ptr { + fn eval(&self, s: &Store, scope: &mut Scope>) -> Ptr { match self { Self::Factorial(n) => { let n_zptr = s.hash_ptr(n); @@ -51,7 +51,7 @@ impl Query for DemoQuery { fn recursive_eval( &self, - scope: &mut Scope>, + scope: &mut Scope>, s: &Store, subquery: Self, ) -> Ptr { @@ -102,7 +102,7 @@ impl CircuitQuery for DemoCircuitQuery { cs: &mut CS, g: &GlobalAllocator, store: &Store, - scope: &mut CircuitScope>, + scope: &mut CircuitScope>, acc: &AllocatedPtr, transcript: &CircuitTranscript, ) -> Result<(AllocatedPtr, AllocatedPtr, CircuitTranscript), SynthesisError> { @@ -238,7 +238,7 @@ mod test { #[test] fn test_factorial() { let s = Store::default(); - let mut scope: Scope, LogMemo> = Scope::default(); + let mut scope: Scope, LogMemo> = Scope::default(); let zero = s.num(F::ZERO); let one = s.num(F::ONE); let two = s.num(F::from_u64(2)); diff --git a/src/coprocessor/memoset/mod.rs b/src/coprocessor/memoset/mod.rs index 629a452cc7..3d52120498 100644 --- a/src/coprocessor/memoset/mod.rs +++ b/src/coprocessor/memoset/mod.rs @@ -47,7 +47,7 @@ use crate::tag::{ExprTag, Tag as XTag}; use crate::z_ptr::ZPtr; use multiset::MultiSet; -use query::{CircuitQuery, Query}; +pub use query::{CircuitQuery, Query}; mod demo; mod multiset; @@ -180,7 +180,7 @@ impl CircuitTranscript { /// A `Scope` tracks the queries made while evaluating, including the subqueries that result from evaluating other /// queries -- then makes use of the bookkeeping performed at evaluation time to synthesize proof of each query /// performed. -pub struct Scope { +pub struct Scope { memoset: M, /// k => v queries: HashMap, @@ -192,10 +192,9 @@ pub struct Scope { internal_insertions: Vec, /// unique keys all_insertions: Vec, - _p: PhantomData, } -impl Default for Scope> { +impl Default for Scope> { fn default() -> Self { Self { memoset: Default::default(), @@ -204,22 +203,20 @@ impl Default for Scope> { toplevel_insertions: Default::default(), internal_insertions: Default::default(), all_insertions: Default::default(), - _p: Default::default(), } } } -pub struct CircuitScope, M: MemoSet> { +pub struct CircuitScope { memoset: M, /// k -> v queries: HashMap, ZPtr>, /// k -> allocated v transcript: CircuitTranscript, acc: Option>, - _p: PhantomData, } -impl> Scope> { +impl> Scope> { pub fn query(&mut self, s: &Store, form: Ptr) -> Ptr { let (response, kv_ptr) = self.query_aux(s, form); @@ -357,12 +354,12 @@ impl> Scope> { } } -impl> CircuitScope> { - fn from_scope, Q: Query>( +impl CircuitScope> { + fn from_scope, Q: Query>( cs: &mut CS, g: &mut GlobalAllocator, s: &Store, - scope: &Scope>, + scope: &Scope>, ) -> Self { let queries = scope .queries @@ -374,7 +371,6 @@ impl> CircuitScope> { queries, transcript: CircuitTranscript::new(cs, g, s), acc: Default::default(), - _p: Default::default(), } } @@ -496,9 +492,9 @@ impl> CircuitScope> { Ok((value, new_acc, new_insertion_transcript)) } - fn synthesize_insert_toplevel_queries, Q: Query>( + fn synthesize_insert_toplevel_queries, Q: Query>( &mut self, - scope: &mut Scope>, + scope: &mut Scope>, cs: &mut CS, g: &mut GlobalAllocator, s: &Store, @@ -546,20 +542,20 @@ impl> CircuitScope> { Ok(()) } - fn synthesize_prove_all_queries, Q: Query>( + fn synthesize_prove_all_queries, Q: Query>( &mut self, - scope: &mut Scope>, + scope: &mut Scope>, cs: &mut CS, g: &mut GlobalAllocator, s: &Store, ) -> Result<(), SynthesisError> { for (i, kv) in scope.all_insertions.iter().enumerate() { - self.synthesize_prove_query(cs, g, s, i, kv)?; + self.synthesize_prove_query::<_, Q::CQ>(cs, g, s, i, kv)?; } Ok(()) } - fn synthesize_prove_query>( + fn synthesize_prove_query, CQ: CircuitQuery>( &mut self, cs: &mut CS, g: &mut GlobalAllocator, @@ -752,7 +748,7 @@ mod test { #[test] fn test_query() { let s = &Store::::default(); - let mut scope: Scope, LogMemo> = Scope::default(); + let mut scope: Scope, LogMemo> = Scope::default(); let state = State::init_lurk_state(); let fact_4 = s.read_with_default_state("(factorial 4)").unwrap(); @@ -803,7 +799,7 @@ mod test { assert!(cs.is_satisfied()); } { - let mut scope: Scope, LogMemo> = Scope::default(); + let mut scope: Scope, LogMemo> = Scope::default(); scope.query(s, fact_4); scope.query(s, fact_3); diff --git a/src/coprocessor/memoset/query.rs b/src/coprocessor/memoset/query.rs index c6b58e069e..617feebbb3 100644 --- a/src/coprocessor/memoset/query.rs +++ b/src/coprocessor/memoset/query.rs @@ -13,10 +13,10 @@ where { type CQ: CircuitQuery; - fn eval(&self, s: &Store, scope: &mut Scope>) -> Ptr; + fn eval(&self, s: &Store, scope: &mut Scope>) -> Ptr; fn recursive_eval( &self, - scope: &mut Scope>, + scope: &mut Scope>, s: &Store, subquery: Self, ) -> Ptr; @@ -39,7 +39,7 @@ where cs: &mut CS, g: &GlobalAllocator, store: &Store, - scope: &mut CircuitScope>, + scope: &mut CircuitScope>, acc: &AllocatedPtr, transcript: &CircuitTranscript, ) -> Result<(AllocatedPtr, AllocatedPtr, CircuitTranscript), SynthesisError>;