From d372ffd19d5c4f6da22518d3aed3c5f573b2dae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Garillot?= <4142+huitseeker@users.noreply.github.com> Date: Fri, 17 Nov 2023 08:00:27 -0500 Subject: [PATCH] Refactor more hash cache logic from Lurk Alpha (#901) * refactor: remove unused functions in circuit_frame * refactor: trim hash_witness * refactor : remove old reduction Cont witnesses * refactor: remove old witness * refactor: remove hash_witness --- src/circuit/circuit_frame.rs | 120 +----- src/circuit/gadgets/constraints.rs | 1 + src/circuit/gadgets/hashes.rs | 4 +- src/circuit/mod.rs | 3 +- src/error.rs | 3 - src/eval/mod.rs | 15 +- src/hash_witness.rs | 590 ----------------------------- src/lib.rs | 1 - 8 files changed, 11 insertions(+), 726 deletions(-) delete mode 100644 src/hash_witness.rs diff --git a/src/circuit/circuit_frame.rs b/src/circuit/circuit_frame.rs index 8556e387f9..3375fc2897 100644 --- a/src/circuit/circuit_frame.rs +++ b/src/circuit/circuit_frame.rs @@ -1,119 +1,6 @@ use bellpepper::util_cs::Comparable; -use bellpepper_core::{boolean::Boolean, num::AllocatedNum, ConstraintSystem, SynthesisError}; -use crate::{ - circuit::gadgets::{data::GlobalAllocations, pointer::AllocatedPtr}, - field::LurkField, -}; - -use super::gadgets::constraints::{self, alloc_equal, enforce_implication}; -use crate::circuit::circuit_frame::constraints::boolean_to_num; -use crate::lurk_sym_ptr; -use crate::store::Store; - -pub fn destructure_list>( - cs: &mut CS, - store: &Store, - g: &GlobalAllocations, - n: usize, - list: &AllocatedPtr, -) -> Result<(Vec>, AllocatedNum), SynthesisError> { - let mut elements = Vec::with_capacity(n); - - let actual_length = destructure_list_aux(cs, store, g, n, list, &mut elements, &g.false_num)?; - - Ok((elements, actual_length)) -} - -fn destructure_list_aux>( - cs: &mut CS, - store: &Store, - g: &GlobalAllocations, - n: usize, - list: &AllocatedPtr, - elements: &mut Vec>, - length_so_far: &AllocatedNum, -) -> Result, SynthesisError> { - let is_cons = alloc_equal(&mut cs.namespace(|| "is_cons"), list.tag(), &g.cons_tag)?; - let increment = boolean_to_num(&mut cs.namespace(|| "increment"), &is_cons)?; - - let new_length_so_far = - increment.add(&mut cs.namespace(|| "new_length_so_far"), length_so_far)?; - - if n == 0 { - return Ok(new_length_so_far.clone()); - }; - - let (element, tail) = car_cdr( - &mut cs.namespace(|| format!("element-{}", n)), - g, - list, - store, - &is_cons, - )?; - - elements.push(element); - - destructure_list_aux( - &mut cs.namespace(|| format!("tail-{}", n)), - store, - g, - n - 1, - &tail, - elements, - &new_length_so_far, - ) -} - -/// Returns allocated car and cdr of `maybe_cons` if `not_dummy`. If `maybe_cons` is not a cons and `not_dummy` is true, the circuit will not be satisfied. -pub(crate) fn car_cdr>( - mut cs: CS, - g: &GlobalAllocations, - maybe_cons: &AllocatedPtr, - store: &Store, - not_dummy: &Boolean, -) -> Result<(AllocatedPtr, AllocatedPtr), SynthesisError> { - let (car, cdr) = if let Some(ptr) = maybe_cons.ptr(store).as_ref() { - if not_dummy.get_value().expect("not_dummy is missing") { - store - .car_cdr(ptr) - .map_err(|_| SynthesisError::AssignmentMissing)? - } else { - let nil_ptr = lurk_sym_ptr!(store, nil); - (nil_ptr, nil_ptr) - } - } else { - let nil_ptr = lurk_sym_ptr!(store, nil); - (nil_ptr, nil_ptr) - }; - - let allocated_car = AllocatedPtr::alloc_ptr(&mut cs.namespace(|| "car"), store, || Ok(&car))?; - let allocated_cdr = AllocatedPtr::alloc_ptr(&mut cs.namespace(|| "cdr"), store, || Ok(&cdr))?; - - let constructed_cons = AllocatedPtr::construct_cons( - &mut cs.namespace(|| "cons"), - g, - store, - &allocated_car, - &allocated_cdr, - )?; - - let real_cons = alloc_equal( - &mut cs.namespace(|| "cons is real"), - maybe_cons.hash(), - constructed_cons.hash(), - )?; - - // If `maybe_cons` is not a cons, then it is dummy. No check is necessary. - // Otherwise, we must enforce equality of hashes. - enforce_implication( - &mut cs.namespace(|| "is cons implies real cons"), - not_dummy, - &real_cons, - ); - - Ok((allocated_car, allocated_cdr)) -} +use crate::field::LurkField; /// Prints out the full CS for debugging purposes #[allow(dead_code)] @@ -143,9 +30,12 @@ pub(crate) fn print_cs>(this: &C) -> String { #[cfg(test)] mod tests { use super::*; - use crate::circuit::circuit_frame::constraints::popcount_equal; use crate::circuit::gadgets::constraints::implies_pack; + use crate::circuit::gadgets::constraints::popcount_equal; + use bellpepper_core::boolean::Boolean; + use bellpepper_core::num::AllocatedNum; use bellpepper_core::test_cs::TestConstraintSystem; + use bellpepper_core::ConstraintSystem; use pasta_curves::pallas::Scalar as Fr; diff --git a/src/circuit/gadgets/constraints.rs b/src/circuit/gadgets/constraints.rs index 292439579a..98a01e12d4 100644 --- a/src/circuit/gadgets/constraints.rs +++ b/src/circuit/gadgets/constraints.rs @@ -649,6 +649,7 @@ pub(crate) fn enforce_selector_with_premise, F: PrimeField>( cs: CS, premise: &Boolean, diff --git a/src/circuit/gadgets/hashes.rs b/src/circuit/gadgets/hashes.rs index 99a818d6f0..f21f87d1fe 100644 --- a/src/circuit/gadgets/hashes.rs +++ b/src/circuit/gadgets/hashes.rs @@ -7,7 +7,9 @@ use neptune::circuit2_witness::poseidon_hash_allocated_witness; use crate::field::{FWrap, LurkField}; use crate::hash::HashConst; -use crate::hash_witness::{Digest, WitnessBlock}; + +pub(crate) type WitnessBlock = Vec; +pub(crate) type Digest = F; type HashCircuitWitnessCache = HashMap>, (Vec, F)>; diff --git a/src/circuit/mod.rs b/src/circuit/mod.rs index f29a4a77ed..95740e6db1 100644 --- a/src/circuit/mod.rs +++ b/src/circuit/mod.rs @@ -1,4 +1,3 @@ #[macro_use] pub mod gadgets; - -pub mod circuit_frame; +mod circuit_frame; diff --git a/src/error.rs b/src/error.rs index 68193ffd98..520f603c13 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,4 +1,3 @@ -use crate::hash_witness::ConsName; use crate::store; use bellpepper_core::SynthesisError; @@ -23,8 +22,6 @@ impl From for ProofError { #[derive(Error, Debug, Clone)] pub enum ReductionError { - #[error("car_cdr of named cons {0:?} requires a cons or nil.")] - CarCdrType(ConsName), #[error("Miscellaneous error: {0}")] Misc(String), #[error("Lookup error: {0}")] diff --git a/src/eval/mod.rs b/src/eval/mod.rs index e1100e7c8e..5cd04ced71 100644 --- a/src/eval/mod.rs +++ b/src/eval/mod.rs @@ -1,7 +1,6 @@ use crate::field::LurkField; -use crate::hash_witness::{ConsWitness, ContWitness}; use crate::lurk_sym_ptr; -use crate::ptr::{ContPtr, Ptr}; +use crate::ptr::Ptr; use crate::store::Store; use crate::z_ptr::ZExprPtr; @@ -33,18 +32,6 @@ pub struct Frame { pub _p: PhantomData, } -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub struct Witness { - pub(crate) prethunk_output_expr: Ptr, - pub(crate) prethunk_output_env: Ptr, - pub(crate) prethunk_output_cont: ContPtr, - - pub(crate) closure_to_extend: Option>, - pub(crate) apply_continuation_cont: Option>, - pub(crate) conses: ConsWitness, - pub(crate) conts: ContWitness, -} - #[inline] pub fn empty_sym_env(store: &Store) -> Ptr { lurk_sym_ptr!(store, nil) diff --git a/src/hash_witness.rs b/src/hash_witness.rs deleted file mode 100644 index 9a49935f70..0000000000 --- a/src/hash_witness.rs +++ /dev/null @@ -1,590 +0,0 @@ -use std::collections::HashMap; -use std::fmt::Debug; -use std::marker::PhantomData; - -use anyhow::{anyhow, Result}; -use once_cell::sync::OnceCell; - -use crate::cont::Continuation; -use crate::error::ReductionError; -use crate::field::{FWrap, LurkField}; -use crate::lurk_sym_ptr; -use crate::ptr::{ContPtr, Ptr}; -use crate::state::State; -use crate::store::{self, Store}; -use crate::tag::ExprTag; -use crate::z_ptr::{ZContPtr, ZExprPtr}; - -pub const MAX_CONSES_PER_REDUCTION: usize = 11; -pub const MAX_CONTS_PER_REDUCTION: usize = 2; - -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub enum Stub { - Dummy, - Blank, - Value(T), -} - -impl Stub { - fn is_dummy(&self) -> bool { - matches!(self, Self::Dummy) - } -} - -pub trait ContentAddressed -where - Self::ScalarPtrRepr: CAddr, -{ - type ScalarPtrRepr; - - fn preimage(&self, s: &Store) -> Result> { - self.to_scalar_ptr_repr(s) - .map(|x| x.preimage()) - .ok_or_else(|| anyhow!("failed to get preimage")) - } - fn to_scalar_ptr_repr(&self, s: &Store) -> Option; - fn to_dummy_scalar_ptr_repr() -> Option { - unimplemented!() - } -} - -pub trait CAddr { - fn preimage(&self) -> Preimage; -} - -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub struct Cons { - pub car: Ptr, - pub cdr: Ptr, - pub cons: Ptr, -} - -#[derive(Clone, Debug)] -pub struct ScalarCons { - pub car: ZExprPtr, - pub cdr: ZExprPtr, - pub cons: Option>, -} - -#[derive(Clone, Debug)] -pub struct ScalarCont { - pub components: [F; 8], - pub cont: Option>, -} - -impl, T: CAddr> ContentAddressed - for Stub -{ - type ScalarPtrRepr = T; - - fn to_scalar_ptr_repr(&self, s: &Store) -> Option { - match self { - Stub::Dummy => C::to_dummy_scalar_ptr_repr(), - Stub::Blank => None, - Stub::Value(v) => v.to_scalar_ptr_repr(s), - } - } -} - -impl ContentAddressed for Cons { - type ScalarPtrRepr = ScalarCons; - - fn preimage(&self, s: &Store) -> Result> { - let spr = self.to_scalar_ptr_repr(s).ok_or(anyhow!("missing"))?; - Ok(spr.preimage()) - } - - fn to_scalar_ptr_repr(&self, s: &Store) -> Option { - let car = s.hash_expr(&self.car)?; - let cdr = s.hash_expr(&self.cdr)?; - let cons = Some(s.hash_expr(&self.cons)?); - Some(ScalarCons { car, cdr, cons }) - } - - fn to_dummy_scalar_ptr_repr() -> Option { - let car = ZExprPtr::from_parts(ExprTag::Nil, F::ZERO); - let cdr = ZExprPtr::from_parts(ExprTag::Nil, F::ZERO); - let cons = None; - Some(ScalarCons { car, cdr, cons }) - } -} - -impl ContentAddressed for Cont { - type ScalarPtrRepr = ScalarCont; - - fn preimage(&self, s: &Store) -> Result> { - let spr = self.to_scalar_ptr_repr(s).ok_or(anyhow!("missing"))?; - Ok(spr.preimage()) - } - - fn to_scalar_ptr_repr(&self, s: &Store) -> Option { - let cont = s.hash_cont(&self.cont_ptr)?; - let components = s.get_hash_components_cont(&self.cont_ptr).unwrap(); - Some(ScalarCont { - cont: Some(cont), - components, - }) - } - - fn to_dummy_scalar_ptr_repr() -> Option { - let cont = None; - let components = [ - F::ZERO, - F::ZERO, - F::ZERO, - F::ZERO, - F::ZERO, - F::ZERO, - F::ZERO, - F::ZERO, - ]; - Some(ScalarCont { cont, components }) - } -} - -impl CAddr for ScalarCons { - fn preimage(&self) -> Preimage { - vec![ - self.car.tag_field(), - *self.car.value(), - self.cdr.tag_field(), - *self.cdr.value(), - ] - } -} - -impl CAddr for ScalarCont { - fn preimage(&self) -> Preimage { - self.components.to_vec() - } -} - -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub struct Cont { - pub cont_ptr: ContPtr, - pub continuation: Continuation, -} - -pub type ConsStub = Stub>; -pub type ContStub = Stub>; - -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Default)] -pub enum ConsName { - #[default] - NeverUsed, - Env, - EnvCar, - EnvCaar, - Expr, - ExprCdr, - ExprCadr, - ExprCaadr, - ExprCaaadr, - ExprCddr, - UnopConsLike, - FunBody, - NewRec, - NewRecCadr, - ExtendedRec, - UnevaledArgs, - UnevaledArgsCdr, - Begin, - EnvToUse, - InnerBody, - Lambda, - InnerLambda, - TheCons, - FunExpanded, - ExtendedClosureEnv, - Binding, - ClosedEnv, - ExpandedInner0, - ExpandedInner, - Expanded, -} - -pub trait HashName: Copy { - fn index(&self) -> usize; -} - -impl HashName for ConsName { - fn index(&self) -> usize { - #[allow(clippy::match_same_arms)] - match self { - Self::NeverUsed => MAX_CONSES_PER_REDUCTION + 1, - Self::Expr => 0, - Self::ExprCdr => 1, - Self::UnevaledArgsCdr => 1, - Self::ExprCadr => 2, - Self::ExprCddr => 3, - Self::UnopConsLike => 3, - Self::Lambda => 3, - Self::ExprCaadr => 4, - Self::Begin => 4, - Self::InnerBody => 4, - Self::ExtendedClosureEnv => 4, - Self::UnevaledArgs => 5, - Self::ExprCaaadr => 5, - Self::ExtendedRec => 5, - Self::EnvToUse => 5, - Self::Binding => 5, - Self::FunBody => 6, - Self::NewRecCadr => 6, - Self::NewRec => 7, - Self::ClosedEnv => 7, - Self::Env => 8, - Self::ExpandedInner0 => 8, - Self::FunExpanded => 9, - Self::Expanded => 9, - Self::EnvCar => 9, - Self::InnerLambda => 10, - Self::TheCons => 10, - Self::EnvCaar => 10, - Self::ExpandedInner => 10, - } - } -} - -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Default)] -pub enum ContName { - #[default] - NeverUsed, - ApplyContinuation, - LetLike, - NewerCont, - NewerCont2, - MakeThunk, - Lookup, -} - -impl HashName for ContName { - fn index(&self) -> usize { - #[allow(clippy::match_same_arms)] - match self { - Self::NeverUsed => MAX_CONTS_PER_REDUCTION + 1, - Self::ApplyContinuation => 0, - Self::Lookup => 0, - Self::NewerCont => 1, - Self::NewerCont2 => 1, - Self::LetLike => 1, - Self::MakeThunk => 1, - } - } -} - -impl ConsStub { - pub fn car_cdr( - &mut self, - s: &Store, - cons: &Ptr, - ) -> Result<(Ptr, Ptr), store::Error> { - match self { - Self::Dummy => { - let (car, cdr) = Cons::get_car_cdr(s, cons)?; - - *self = Self::Value(Cons { - car, - cdr, - cons: *cons, - }); - - Ok((car, cdr)) - } - Self::Blank => unreachable!("Blank ConsStub should be used only in blank circuits."), - Self::Value(h) => Ok(h.car_cdr(cons)), - } - } - - pub fn cons(&mut self, store: &Store, car: Ptr, cdr: Ptr) -> Ptr { - match self { - Self::Dummy => { - let cons = Cons::cons(store, car, cdr); - - *self = Self::Value(Cons { car, cdr, cons }); - - cons - } - Self::Blank => unreachable!("Blank ConsStub should be used only in blank circuits."), - Self::Value(_) => Cons::cons(store, car, cdr), - } - } - pub fn strcons(&mut self, store: &Store, car: Ptr, cdr: Ptr) -> Ptr { - match self { - Self::Dummy => { - let cons = Cons::strcons(store, car, cdr); - - *self = Self::Value(Cons { car, cdr, cons }); - - cons - } - Self::Blank => unreachable!("Blank ConsStub should be used only in blank circuits."), - Self::Value(_) => Cons::strcons(store, car, cdr), - } - } -} - -impl ContStub {} - -pub type Preimage = Vec; -pub type PreimageKey = Vec>; -pub type WitnessBlock = Vec; -pub type Digest = F; -pub type HashCircuitWitnessCache = HashMap, (WitnessBlock, Digest)>; -pub type HashCircuitWitnessBlocks = Vec<(WitnessBlock, Digest)>; - -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub struct HashWitness { - pub slots: [(Name, Stub); L], - _f: PhantomData, -} - -#[derive(Clone, Debug, PartialEq)] -pub struct CircuitHashWitness, const L: usize, F: LurkField> -{ - pub hash_witness: HashWitness, - pub names_and_ptrs: OnceCell)>>, - pub circuit_witness_blocks: OnceCell>, -} - -impl, const L: usize, F: LurkField> - From> for CircuitHashWitness -{ - fn from(hash_witness: HashWitness) -> Self { - Self { - hash_witness, - names_and_ptrs: OnceCell::new(), - circuit_witness_blocks: OnceCell::new(), - } - } -} - -pub type ConsWitness = HashWitness, MAX_CONSES_PER_REDUCTION, F>; -pub type ContWitness = HashWitness, MAX_CONTS_PER_REDUCTION, F>; - -pub type ConsCircuitWitness = CircuitHashWitness, MAX_CONSES_PER_REDUCTION, F>; -pub type ContCircuitWitness = CircuitHashWitness, MAX_CONTS_PER_REDUCTION, F>; - -impl HashWitness, MAX_CONSES_PER_REDUCTION, F> { - #[allow(dead_code)] - fn assert_specific_invariants(&self, store: &Store, state: &State) { - // Use the commented code below to search for (non-nil) duplicated conses, which could indicate that two - // different Cons are being used to reference the identical structural value. In that case, they could be - // coalesced, potentially leading to fewer slots being required. - // - // As of the initial optimization pass, Env and ExtendedClosureEnv appear to be duplicated in this way. However, - // it's not clear why that is, and coalescing them does not obviously lead to a potential savings, so we will - // leave them distinct for now. - - let mut digests = HashMap::new(); - - for (name, p) in self.slots.iter() { - if let Stub::Value(hash) = p { - if let Some(existing_name) = digests.insert(hash.cons, name) { - let nil = lurk_sym_ptr!(store, nil); - if !store.ptr_eq(&hash.cons, &nil).unwrap() { - use crate::writer::Write; - let cons = hash.cons.fmt_to_string(store, state); - tracing::debug!( - "{:?} {:?} {:?} {:?}", - hash.cons, - cons, - name, - existing_name - ); - panic!("duplicate"); - } - } - }; - } - } -} - -impl< - Name: HashName + Default + Copy + Eq + Debug, - T: Copy, - const MAX_T_PER_REDUCTION: usize, - F: LurkField, - > HashWitness -{ - pub fn new_from_stub(stub: Stub) -> Self { - Self { - slots: [(Name::default(), stub); MAX_T_PER_REDUCTION], - _f: Default::default(), - } - } - - pub fn new_dummy() -> Self { - Self::new_from_stub(Stub::Dummy) - } - - pub fn get_assigned_slot(&mut self, name: Name) -> &mut Stub { - let i = name.index(); - let (slot_name, p) = self.slots[i]; - if p.is_dummy() { - self.slots[i].0 = name; - return &mut self.slots[i].1; - } - if slot_name == name { - &mut self.slots[i].1 - } else { - panic!( - "double booked: found {:?} when getting {:?}", - &slot_name, &name - ); - } - } - - pub fn assert_invariants(&self, _store: &Store) { - // TODO: Figure out how to make this work. - // self.assert_specific_invariants(store); - assert!(self.stubs_used_count() <= MAX_T_PER_REDUCTION); - } - - fn all_stubs(&self) -> Vec> { - self.slots.iter().map(|x| x.1).collect() - } - - pub fn stubs_used_count(&self) -> usize { - self.all_stubs().iter().filter(|c| !c.is_dummy()).count() - } -} - -impl ConsWitness { - pub fn car_cdr_named( - &mut self, - name: ConsName, - store: &Store, - cons: &Ptr, - ) -> Result<(Ptr, Ptr), ReductionError> { - if !matches!(cons.tag, ExprTag::Cons | ExprTag::Nil) { - return Err(ReductionError::CarCdrType(name)); - }; - self.get_assigned_slot(name) - .car_cdr(store, cons) - .map_err(|e| e.into()) - } - - pub fn cons_named( - &mut self, - name: ConsName, - store: &Store, - car: Ptr, - cdr: Ptr, - ) -> Ptr { - self.get_assigned_slot(name).cons(store, car, cdr) - } - - pub fn strcons_named( - &mut self, - name: ConsName, - store: &Store, - car: Ptr, - cdr: Ptr, - ) -> Ptr { - self.get_assigned_slot(name).strcons(store, car, cdr) - } - - pub fn car_cdr_mut_named( - &mut self, - name: ConsName, - store: &Store, - cons: &Ptr, - ) -> Result<(Ptr, Ptr), store::Error> { - self.get_assigned_slot(name).car_cdr(store, cons) - } - - pub fn extend_named( - &mut self, - name: ConsName, - env: Ptr, - var: Ptr, - val: Ptr, - store: &Store, - ) -> Ptr { - let binding = self.cons_named(ConsName::Binding, store, var, val); - - self.cons_named(name, store, binding, env) - } -} - -impl Cons { - fn cons(store: &Store, car: Ptr, cdr: Ptr) -> Ptr { - store.cons(car, cdr) - } - - fn strcons(store: &Store, car: Ptr, cdr: Ptr) -> Ptr { - store.strcons(car, cdr) - } - - fn car_cdr(&self, cons: &Ptr) -> (Ptr, Ptr) { - assert_eq!(cons, &self.cons, "wrong cons found when destructuring"); - - (self.car, self.cdr) - } - - fn get_car_cdr(s: &Store, cons: &Ptr) -> Result<(Ptr, Ptr), store::Error> { - s.car_cdr(cons) - } -} - -impl ContWitness { - pub fn fetch_named_cont( - &mut self, - name: ContName, - store: &Store, - cont: &ContPtr, - ) -> Option> { - self.get_assigned_slot(name).fetch_cont(store, cont) - } - - pub fn intern_named_cont( - &mut self, - name: ContName, - store: &Store, - continuation: Continuation, - ) -> ContPtr { - self.get_assigned_slot(name) - .intern_cont(store, continuation) - } -} - -impl ContStub { - pub fn fetch_cont(&mut self, store: &Store, cont: &ContPtr) -> Option> { - match self { - Self::Dummy => { - let continuation = store.fetch_cont(cont)?; - // tracing::debug!("overwriting dummy {:?} {:?}", continuation, store.hash_cont(&cont)); - *self = Self::Value(Cont { - cont_ptr: *cont, - continuation, - }); - - Some(continuation) - } - Self::Blank => unreachable!("Blank ContStub should be used only in blank circuits."), - Self::Value(h) => Some(h.fetch_cont(cont)), - } - } - pub fn intern_cont(&mut self, store: &Store, continuation: Continuation) -> ContPtr { - match self { - Self::Dummy => { - let cont_ptr = continuation.intern_aux(store); - *self = Self::Value(Cont { - cont_ptr, - continuation, - }); - cont_ptr - } - Self::Blank => unreachable!("Blank ContStub should be used only in blank circuits."), - Self::Value(h) => h.cont_ptr, - } - } -} - -impl Cont { - fn fetch_cont(&mut self, cont: &ContPtr) -> Continuation { - assert_eq!(cont, &self.cont_ptr); - - self.continuation - } -} diff --git a/src/lib.rs b/src/lib.rs index 5583e456d1..ccdb11e27f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,7 +12,6 @@ pub mod eval; mod expr; pub mod field; mod hash; -pub mod hash_witness; pub mod lem; mod num; mod package;