diff --git a/stwo_cairo_prover/crates/adapted_prover/src/main.rs b/stwo_cairo_prover/crates/adapted_prover/src/main.rs index 55cdb1fa..7487fbfa 100644 --- a/stwo_cairo_prover/crates/adapted_prover/src/main.rs +++ b/stwo_cairo_prover/crates/adapted_prover/src/main.rs @@ -61,7 +61,7 @@ fn run(args: impl Iterator) -> Result(vm_output, args.debug_lookup, args.display_components)?; diff --git a/stwo_cairo_prover/crates/prover/src/components/memory/memory_address_to_id/prover.rs b/stwo_cairo_prover/crates/prover/src/components/memory/memory_address_to_id/prover.rs index 3f2fa664..7d6fa5c3 100644 --- a/stwo_cairo_prover/crates/prover/src/components/memory/memory_address_to_id/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/memory/memory_address_to_id/prover.rs @@ -30,9 +30,9 @@ pub struct ClaimGenerator { pub multiplicities: MultiplicityColumn, } impl ClaimGenerator { - pub fn new(mem: &Memory) -> Self { - let ids = (0..mem.address_to_id.len()) - .map(|addr| mem.get_raw_id(addr as u32)) + pub fn new(memory: &Memory) -> Self { + let ids = (0..memory.address_to_id.len()) + .map(|addr| memory.get_raw_id(addr as u32)) .collect_vec(); let multiplicities = MultiplicityColumn::new(ids.len()); diff --git a/stwo_cairo_prover/crates/prover/src/input/state_transitions.rs b/stwo_cairo_prover/crates/prover/src/input/state_transitions.rs index 5ccd51f6..c4b43d22 100644 --- a/stwo_cairo_prover/crates/prover/src/input/state_transitions.rs +++ b/stwo_cairo_prover/crates/prover/src/input/state_transitions.rs @@ -179,7 +179,7 @@ impl StateTransitions { /// Iterates over the casm states and splits them into the appropriate opcode components. pub fn from_iter( iter: impl Iterator, - mem: &mut MemoryBuilder, + memory: &mut MemoryBuilder, dev_mode: bool, ) -> Self { let mut res = Self::default(); @@ -189,7 +189,7 @@ impl StateTransitions { return res; }; res.initial_state = first.into(); - res.push_instr(mem, first.into(), dev_mode); + res.push_instr(memory, first.into(), dev_mode); while let Some(entry) = iter.next() { // TODO(Ohad): Check if the adapter outputs the final state. @@ -197,16 +197,16 @@ impl StateTransitions { res.final_state = entry.into(); break; }; - res.push_instr(mem, entry.into(), dev_mode); + res.push_instr(memory, entry.into(), dev_mode); } res } // TODO(Ohad): remove dev_mode after adding the rest of the instructions. /// Pushes the state transition at pc into the appropriate opcode component. - fn push_instr(&mut self, mem: &mut MemoryBuilder, state: CasmState, dev_mode: bool) { + fn push_instr(&mut self, memory: &mut MemoryBuilder, state: CasmState, dev_mode: bool) { let CasmState { ap, fp, pc } = state; - let instruction = mem.get_inst(pc.0); + let instruction = memory.get_inst(pc.0); let instruction = Instruction::decode(instruction); match instruction { @@ -409,7 +409,7 @@ impl StateTransitions { opcode_assert_eq: false, } => { let dst_addr = if dst_base_fp { fp } else { ap }; - let dst = mem.get(dst_addr.0.checked_add_signed(offset0 as i32).unwrap()); + let dst = memory.get(dst_addr.0.checked_add_signed(offset0 as i32).unwrap()); let taken = dst != MemoryValue::Small(0); if taken { if dst_base_fp { @@ -509,8 +509,8 @@ impl StateTransitions { if op_1_base_fp { fp } else { ap }, ); let (op0, op_1) = ( - mem.get(op0_addr.0.checked_add_signed(offset1 as i32).unwrap()), - mem.get(op_1_addr.0.checked_add_signed(offset2 as i32).unwrap()), + memory.get(op0_addr.0.checked_add_signed(offset1 as i32).unwrap()), + memory.get(op_1_addr.0.checked_add_signed(offset2 as i32).unwrap()), ); if op_1_imm { // [ap/fp + offset0] = [ap/fp + offset1] * Imm. @@ -576,9 +576,9 @@ impl StateTransitions { if op_1_base_fp { fp } else { ap }, ); let (dst, op0, op_1) = ( - mem.get(dst_addr.0.checked_add_signed(offset0 as i32).unwrap()), - mem.get(op0_addr.0.checked_add_signed(offset1 as i32).unwrap()), - mem.get(op_1_addr.0.checked_add_signed(offset2 as i32).unwrap()), + memory.get(dst_addr.0.checked_add_signed(offset0 as i32).unwrap()), + memory.get(op0_addr.0.checked_add_signed(offset1 as i32).unwrap()), + memory.get(op_1_addr.0.checked_add_signed(offset2 as i32).unwrap()), ); if op_1_imm { // [ap/fp + offset0] = [ap/fp + offset1] + Imm. diff --git a/stwo_cairo_prover/crates/prover/src/input/vm_import/mod.rs b/stwo_cairo_prover/crates/prover/src/input/vm_import/mod.rs index 4ce4bfab..727c1b2a 100644 --- a/stwo_cairo_prover/crates/prover/src/input/vm_import/mod.rs +++ b/stwo_cairo_prover/crates/prover/src/input/vm_import/mod.rs @@ -58,11 +58,11 @@ pub fn import_from_vm_output( let mut trace_file = std::io::BufReader::new(std::fs::File::open(trace_path)?); let mut memory_file = std::io::BufReader::new(std::fs::File::open(memory_path)?); - let mut memory = MemoryBuilder::from_iter(memory_config, MemEntryIter(&mut memory_file)); + let mut memory = MemoryBuilder::from_iter(memory_config, MemoryEntryIter(&mut memory_file)); let state_transitions = StateTransitions::from_iter(TraceIter(&mut trace_file), &mut memory, dev_mode); - let public_mem_addresses = public_input + let public_memory_addresses = public_input .public_memory .iter() .map(|entry| entry.address as u32) @@ -71,7 +71,7 @@ pub fn import_from_vm_output( Ok(CairoInput { state_transitions, memory: memory.build(), - public_memory_addresses: public_mem_addresses, + public_memory_addresses, range_check_builtin: MemorySegmentAddresses { begin_addr: public_input.memory_segments["range_check"].begin_addr as usize, stop_ptr: public_input.memory_segments["range_check"].stop_ptr as usize, @@ -121,8 +121,8 @@ pub struct MemoryEntry { pub value: [u32; 8], } -pub struct MemEntryIter<'a, R: Read>(pub &'a mut R); -impl Iterator for MemEntryIter<'_, R> { +pub struct MemoryEntryIter<'a, R: Read>(pub &'a mut R); +impl Iterator for MemoryEntryIter<'_, R> { type Item = MemoryEntry; fn next(&mut self) -> Option {