diff --git a/benches/end2end.rs b/benches/end2end.rs index 7d7821c857..23ed65d05c 100644 --- a/benches/end2end.rs +++ b/benches/end2end.rs @@ -303,7 +303,7 @@ fn prove_benchmark(c: &mut Criterion) { b.iter(|| { let result = prover - .prove(&pp, &frames, &mut store, lang_pallas_rc.clone()) + .prove(&pp, &frames, &store, lang_pallas_rc.clone()) .unwrap(); black_box(result); }) @@ -350,7 +350,7 @@ fn prove_compressed_benchmark(c: &mut Criterion) { b.iter(|| { let (proof, _, _, _) = prover - .prove(&pp, &frames, &mut store, lang_pallas_rc.clone()) + .prove(&pp, &frames, &store, lang_pallas_rc.clone()) .unwrap(); let compressed_result = proof.compress(&pp).unwrap(); @@ -394,7 +394,7 @@ fn verify_benchmark(c: &mut Criterion) { .get_evaluation_frames(ptr, empty_sym_env(&store), &mut store, limit, &lang_pallas) .unwrap(); let (proof, z0, zi, num_steps) = prover - .prove(&pp, &frames, &mut store, lang_pallas_rc.clone()) + .prove(&pp, &frames, &store, lang_pallas_rc.clone()) .unwrap(); b.iter_batched( @@ -446,7 +446,7 @@ fn verify_compressed_benchmark(c: &mut Criterion) { .get_evaluation_frames(ptr, empty_sym_env(&store), &mut store, limit, &lang_pallas) .unwrap(); let (proof, z0, zi, num_steps) = prover - .prove(&pp, &frames, &mut store, lang_pallas_rc.clone()) + .prove(&pp, &frames, &store, lang_pallas_rc.clone()) .unwrap(); let compressed_proof = proof.compress(&pp).unwrap(); diff --git a/benches/fibonacci.rs b/benches/fibonacci.rs index 060180b759..85b2dbc088 100644 --- a/benches/fibonacci.rs +++ b/benches/fibonacci.rs @@ -104,7 +104,7 @@ fn fibo_prove( b.iter_batched( || (frames, lang_rc.clone()), |(frames, lang_rc)| { - let result = prover.prove(&pp, frames, &mut store, lang_rc); + let result = prover.prove(&pp, frames, &store, lang_rc); let _ = black_box(result); }, BatchSize::LargeInput, diff --git a/clutch/src/lib.rs b/clutch/src/lib.rs index e1a1329b2d..37b5a31e9a 100644 --- a/clutch/src/lib.rs +++ b/clutch/src/lib.rs @@ -510,14 +510,14 @@ impl ClutchState> { println!(); Ok(None) } - fn proof_claim(&self, store: &mut Store, rest: Ptr) -> Result>> { + fn proof_claim(&self, store: &Store, rest: Ptr) -> Result>> { let proof = self.get_proof(store, rest)?; println!("{0:#?}", proof.claim); Ok(None) } - fn get_proof(&self, store: &mut Store, rest: Ptr) -> Result> { + fn get_proof(&self, store: &Store, rest: Ptr) -> Result> { let (proof_cid, _rest1) = store.car_cdr(&rest)?; let zptr_string = store .fetch_string(&proof_cid) @@ -579,7 +579,7 @@ impl ClutchState> { bail!("verification of new proof failed"); } } - fn verify(&mut self, store: &mut Store, rest: Ptr) -> Result>> { + fn verify(&mut self, store: &Store, rest: Ptr) -> Result>> { let (proof_cid, _) = store.car_cdr(&rest)?; let zptr_string = store diff --git a/fcomm/src/lib.rs b/fcomm/src/lib.rs index e61cf8d973..9b568c90ce 100644 --- a/fcomm/src/lib.rs +++ b/fcomm/src/lib.rs @@ -405,7 +405,7 @@ impl ReductionCount { impl Evaluation { fn new( - s: &mut Store, + s: &Store, input: IO, output: IO, iterations: Option, // This might be padded, so is not quite 'iterations' in the sense of number of actual reduction steps required @@ -491,7 +491,7 @@ impl PtrEvaluation { } impl Commitment { - pub fn from_comm(s: &mut Store, ptr: &Ptr) -> Result { + pub fn from_comm(s: &Store, ptr: &Ptr) -> Result { assert_eq!(ExprTag::Comm, ptr.tag); let digest = *s @@ -589,7 +589,7 @@ impl LurkPtr { } } - pub fn from_ptr(s: &mut Store, ptr: &Ptr) -> Self { + pub fn from_ptr(s: &Store, ptr: &Ptr) -> Self { let (z_store, z_ptr) = ZStore::new_with_expr(s, ptr); let z_ptr = z_ptr.unwrap(); Self::ZStorePtr(ZStorePtr { z_store, z_ptr }) @@ -599,7 +599,7 @@ impl LurkPtr { impl LurkCont { pub fn cont_ptr( &self, - s: &mut Store, + s: &Store, ) -> ContPtr { match self { Self::Outermost => s.get_cont_outermost(), diff --git a/src/circuit/gadgets/hashes.rs b/src/circuit/gadgets/hashes.rs index 6d3bdeb8b1..ebb638974f 100644 --- a/src/circuit/gadgets/hashes.rs +++ b/src/circuit/gadgets/hashes.rs @@ -173,7 +173,7 @@ impl<'a, F: LurkField> HashConst<'a, F> { #[allow(dead_code)] fn cache_hash_witness>( &self, - cs: &mut CS, + cs: &CS, preimage: Vec, hash_circuit_witness_cache: &mut HashCircuitWitnessCache, ) { @@ -364,7 +364,7 @@ impl<'a, F: LurkField> AllocatedContWitness<'a, F> { // Currently unused, but not necessarily useless. #[allow(dead_code)] fn make_hash_cache>( - cs: &mut CS, + cs: &CS, names_and_ptrs: &[(ContName, (Option>, Option>))], hash_constants: HashConst<'_, F>, ) -> Option> { diff --git a/src/cli/repl.rs b/src/cli/repl.rs index da20b286f6..71571c73d6 100644 --- a/src/cli/repl.rs +++ b/src/cli/repl.rs @@ -237,7 +237,7 @@ impl Repl { info!("Proving"); let (proof, public_inputs, public_outputs, num_steps) = - prover.prove(&pp, frames, &mut self.store, self.lang.clone())?; + prover.prove(&pp, frames, &self.store, self.lang.clone())?; info!("Compressing proof"); let proof = proof.compress(&pp)?; assert_eq!(self.rc * num_steps, pad(n_frames, self.rc)); diff --git a/src/field.rs b/src/field.rs index 0640583e01..f9f26a7bab 100644 --- a/src/field.rs +++ b/src/field.rs @@ -309,7 +309,7 @@ impl Hash for FWrap { impl PartialOrd for FWrap { fn partial_cmp(&self, other: &Self) -> Option { - (self.0.to_repr().as_ref()).partial_cmp(other.0.to_repr().as_ref()) + Some(self.cmp(other)) } } diff --git a/src/hash_witness.rs b/src/hash_witness.rs index 191953839a..65e705ecf3 100644 --- a/src/hash_witness.rs +++ b/src/hash_witness.rs @@ -296,28 +296,6 @@ impl ConsStub { } } - pub fn car_cdr_mut( - &mut self, - s: &mut Store, - cons: &Ptr, - ) -> Result<(Ptr, Ptr), store::Error> { - match self { - Self::Dummy => { - let (car, cdr) = Cons::get_car_cdr_mut(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: &mut Store, car: Ptr, cdr: Ptr) -> Ptr { match self { Self::Dummy => { @@ -572,10 +550,10 @@ impl ConsWitness { pub fn car_cdr_mut_named( &mut self, name: ConsName, - store: &mut Store, + store: &Store, cons: &Ptr, ) -> Result<(Ptr, Ptr), store::Error> { - self.get_assigned_slot(name).car_cdr_mut(store, cons) + self.get_assigned_slot(name).car_cdr(store, cons) } pub fn extend_named( @@ -610,17 +588,13 @@ impl Cons { fn get_car_cdr(s: &Store, cons: &Ptr) -> Result<(Ptr, Ptr), store::Error> { s.car_cdr(cons) } - - fn get_car_cdr_mut(s: &mut Store, cons: &Ptr) -> Result<(Ptr, Ptr), store::Error> { - s.car_cdr(cons) - } } impl ContWitness { pub fn fetch_named_cont( &mut self, name: ContName, - store: &mut Store, + store: &Store, cont: &ContPtr, ) -> Option> { self.get_assigned_slot(name).fetch_cont(store, cont) @@ -638,11 +612,7 @@ impl ContWitness { } impl ContStub { - pub fn fetch_cont( - &mut self, - store: &mut Store, - cont: &ContPtr, - ) -> Option> { + pub fn fetch_cont(&mut self, store: &Store, cont: &ContPtr) -> Option> { match self { Self::Dummy => { let continuation = store.fetch_cont(cont)?; diff --git a/src/proof/nova.rs b/src/proof/nova.rs index 4008836397..6aa43c6024 100644 --- a/src/proof/nova.rs +++ b/src/proof/nova.rs @@ -277,7 +277,7 @@ where &'a self, pp: &'a PublicParams<'_, F, C>, frames: &[Frame, Witness, C>], - store: &'a mut Store, + store: &'a Store, lang: Arc>, ) -> Result<(Proof<'_, F, C>, Vec, Vec, usize), ProofError> { let z0 = frames[0].input.to_vector(store)?; diff --git a/src/public_parameters/mem_cache.rs b/src/public_parameters/mem_cache.rs index 1b2a0de7d7..3c93794dff 100644 --- a/src/public_parameters/mem_cache.rs +++ b/src/public_parameters/mem_cache.rs @@ -126,7 +126,7 @@ impl PublicParamMemCache { // retrieve the per-Coproc public param table let entry = mem_cache.entry::>(); // deduce the map and populate it if needed - let param_entry = entry.or_insert_with(HashMap::new); + let param_entry = entry.or_default(); match param_entry.entry((rc, abomonated)) { Entry::Occupied(o) => Ok(o.into_mut()), Entry::Vacant(v) => { diff --git a/src/repl.rs b/src/repl.rs index e313bf5f88..95b7b44f9f 100644 --- a/src/repl.rs +++ b/src/repl.rs @@ -106,8 +106,6 @@ pub trait ReplTrait> { state: Rc>, file_path: P, ) -> Result<()> { - let file_path = file_path; - let input = read_to_string(file_path)?; eprintln!( "Read from {}: {}", @@ -324,7 +322,7 @@ pub fn run_repl, F: LurkField, T: ReplTrait, C: Coprocessor } impl> ReplState { - pub fn new(s: &mut Store, limit: usize, command: Option, lang: Lang) -> Self { + pub fn new(s: &Store, limit: usize, command: Option, lang: Lang) -> Self { Self { env: empty_sym_env(s), limit, diff --git a/src/z_data/z_ptr.rs b/src/z_data/z_ptr.rs index 00856c8eab..fa40144a58 100644 --- a/src/z_data/z_ptr.rs +++ b/src/z_data/z_ptr.rs @@ -54,24 +54,23 @@ impl Display for ZPtr { impl PartialOrd for ZPtr { fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for ZPtr { + fn cmp(&self, other: &Self) -> core::cmp::Ordering { ( self.0.to_field_bytes::().as_ref(), self.1.to_repr().as_ref(), ) - .partial_cmp(&( + .cmp(&( other.0.to_field_bytes::().as_ref(), other.1.to_repr().as_ref(), )) } } -impl Ord for ZPtr { - fn cmp(&self, other: &Self) -> core::cmp::Ordering { - self.partial_cmp(other) - .expect("ZPtr::cmp: partial_cmp domain invariant violation") - } -} - #[allow(clippy::derived_hash_with_manual_eq)] impl Hash for ZPtr { fn hash(&self, state: &mut H) {