diff --git a/crates/vm/src/arch/testing/memory/mod.rs b/crates/vm/src/arch/testing/memory/mod.rs index 383352aa8..84d343a4b 100644 --- a/crates/vm/src/arch/testing/memory/mod.rs +++ b/crates/vm/src/arch/testing/memory/mod.rs @@ -99,10 +99,8 @@ where address_space: record.address_space, pointer: record.pointer, }; - row.data = match &record.prev_data { - Some(prev_data) => prev_data.clone().try_into().unwrap(), - None => record.data.clone().try_into().unwrap(), - }; + row.data + .copy_from_slice(record.prev_data.as_ref().unwrap_or(&record.data)); row.timestamp = Val::::from_canonical_u32(record.prev_timestamp); row.count = -Val::::ONE; @@ -111,7 +109,7 @@ where address_space: record.address_space, pointer: record.pointer, }; - row.data = record.data.clone().try_into().unwrap(); + row.data.copy_from_slice(&record.data); row.timestamp = Val::::from_canonical_u32(record.timestamp); row.count = Val::::ONE; } diff --git a/extensions/keccak256/circuit/src/trace.rs b/extensions/keccak256/circuit/src/trace.rs index c2302d0fe..2b50bb12a 100644 --- a/extensions/keccak256/circuit/src/trace.rs +++ b/extensions/keccak256/circuit/src/trace.rs @@ -163,16 +163,6 @@ where .zip(instruction_blocks.into_par_iter()) .for_each(|((rows, p3_keccak_mat), (instruction, diff, block))| { let height = rows.len() / trace_width; - let partial_read_data = if let Some(partial_read_idx) = block.partial_read_idx { - memory - .record_by_id(block.reads[partial_read_idx]) - .data - .clone() - .try_into() - .unwrap() - } else { - [Val::::ZERO; KECCAK_WORD_SIZE] - }; for (row, p3_keccak_row) in rows .chunks_exact_mut(trace_width) .zip(p3_keccak_mat.chunks_exact(NUM_KECCAK_PERM_COLS)) @@ -184,10 +174,13 @@ where row_mut.sponge.block_bytes = block.padded_bytes.map(Val::::from_canonical_u8); - row_mut - .mem_oc - .partial_block - .copy_from_slice(&partial_read_data[1..]); + if let Some(partial_read_idx) = block.partial_read_idx { + let partial_read = memory.record_by_id(block.reads[partial_read_idx]); + row_mut + .mem_oc + .partial_block + .copy_from_slice(&partial_read.data[1..]); + } for (i, is_padding) in row_mut.sponge.is_padding_byte.iter_mut().enumerate() { *is_padding = Val::::from_bool(i >= block.remaining_len); } diff --git a/extensions/rv32-adapters/src/eq_mod.rs b/extensions/rv32-adapters/src/eq_mod.rs index 0e7b6ac8f..a5b792747 100644 --- a/extensions/rv32-adapters/src/eq_mod.rs +++ b/extensions/rv32-adapters/src/eq_mod.rs @@ -399,7 +399,7 @@ impl< let rs = read_record.rs.map(|r| memory.record_by_id(r)); for (i, r) in rs.iter().enumerate() { row_slice.rs_ptr[i] = r.pointer; - row_slice.rs_val[i] = r.data.clone().try_into().unwrap(); + row_slice.rs_val[i].copy_from_slice(&r.data); aux_cols_factory.generate_read_aux(r, &mut row_slice.rs_read_aux[i]); for (j, x) in read_record.reads[i].iter().enumerate() { let read = memory.record_by_id(*x); diff --git a/extensions/rv32im/circuit/src/adapters/hintstore.rs b/extensions/rv32im/circuit/src/adapters/hintstore.rs index 0df8d630d..5838654cd 100644 --- a/extensions/rv32im/circuit/src/adapters/hintstore.rs +++ b/extensions/rv32im/circuit/src/adapters/hintstore.rs @@ -318,7 +318,7 @@ impl VmAdapterChip for Rv32HintStoreAdapterChip { let adapter_cols: &mut Rv32HintStoreAdapterCols<_> = row_slice.borrow_mut(); adapter_cols.from_state = write_record.from_state.map(F::from_canonical_u32); let rs1 = memory.record_by_id(read_record.rs1_record); - adapter_cols.rs1_data = rs1.data.clone().try_into().unwrap(); + adapter_cols.rs1_data.copy_from_slice(&rs1.data); aux_cols_factory.generate_read_aux(rs1, &mut adapter_cols.rs1_aux_cols); adapter_cols.rs1_ptr = read_record.rs1_ptr; adapter_cols.imm = read_record.imm; diff --git a/extensions/rv32im/circuit/src/adapters/loadstore.rs b/extensions/rv32im/circuit/src/adapters/loadstore.rs index 302d51bb0..6e46f1bfb 100644 --- a/extensions/rv32im/circuit/src/adapters/loadstore.rs +++ b/extensions/rv32im/circuit/src/adapters/loadstore.rs @@ -466,7 +466,7 @@ impl VmAdapterChip for Rv32LoadStoreAdapterChip { let adapter_cols: &mut Rv32LoadStoreAdapterCols<_> = row_slice.borrow_mut(); adapter_cols.from_state = write_record.from_state.map(F::from_canonical_u32); let rs1 = memory.record_by_id(read_record.rs1_record); - adapter_cols.rs1_data = rs1.data.clone().try_into().unwrap(); + adapter_cols.rs1_data.copy_from_slice(&rs1.data); aux_cols_factory.generate_read_aux(rs1, &mut adapter_cols.rs1_aux_cols); adapter_cols.rs1_ptr = read_record.rs1_ptr; adapter_cols.rd_rs2_ptr = write_record.rd_rs2_ptr; diff --git a/extensions/sha256/circuit/src/sha256_chip/trace.rs b/extensions/sha256/circuit/src/sha256_chip/trace.rs index fca1ac01c..11221b9fa 100644 --- a/extensions/sha256/circuit/src/sha256_chip/trace.rs +++ b/extensions/sha256/circuit/src/sha256_chip/trace.rs @@ -218,9 +218,9 @@ where cols.rd_ptr = dst_read.pointer; cols.rs1_ptr = src_read.pointer; cols.rs2_ptr = len_read.pointer; - cols.dst_ptr = dst_read.data.clone().try_into().unwrap(); - cols.src_ptr = src_read.data.clone().try_into().unwrap(); - cols.len_data = len_read.data.clone().try_into().unwrap(); + cols.dst_ptr.copy_from_slice(&dst_read.data); + cols.src_ptr.copy_from_slice(&src_read.data); + cols.len_data.copy_from_slice(&len_read.data); memory_aux_cols_factory .generate_read_aux(dst_read, &mut cols.register_reads_aux[0]); memory_aux_cols_factory