Skip to content

Commit c9336b6

Browse files
committed
fix: source pointer mismatch, fixes execution phase
1 parent bcb60d0 commit c9336b6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

extensions/memcpy/circuit/src/iteration.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ where
499499
// source,
500500
// &mut record.var[0].read_aux[2].prev_timestamp,
501501
// );
502+
source = source.saturating_sub(12 * (shift != 0) as u32);
502503
if shift != 0 {
503504
if source >= 4 {
504505
record.var[0].data[3] = tracing_read(
@@ -576,7 +577,7 @@ where
576577
let mut dest_data = [0; 4];
577578
let mut source_data = [0; 4];
578579
let mut len_data = [0; 4];
579-
580+
source = source.saturating_add(12 * (shift != 0) as u32);
580581
tracing_write(
581582
state.memory,
582583
RV32_REGISTER_AS,
@@ -1005,6 +1006,8 @@ unsafe fn execute_e12_impl<F: PrimeField32, CTX: ExecutionCtxTrait>(
10051006
let mut source = u32::from_le_bytes(source).saturating_sub(12 * (shift != 0) as u32);
10061007
let mut len = u32::from_le_bytes(len);
10071008

1009+
let effective_len = len.saturating_sub(shift as u32); // n >= 16 + shift
1010+
let num_iters = (effective_len >> 4) as u32;
10081011
// Check address ranges are valid
10091012

10101013
/*
@@ -1034,9 +1037,7 @@ unsafe fn execute_e12_impl<F: PrimeField32, CTX: ExecutionCtxTrait>(
10341037
} else {
10351038
[0; 4] // unused when shift == 0
10361039
};
1037-
let effective_len = len.saturating_sub(shift as u32);
1038-
let num_iters = (effective_len >> 4) as u32; // number of 16-byte chunks we will process
1039-
//why is PC not being incremented correctly
1040+
10401041
eprintln!("num_iters: {:?}", num_iters);
10411042
eprintln!("source: {:?}, dest: {:?}, pc: {:?}", source, dest, *pc);
10421043
for _ in 0..num_iters {

0 commit comments

Comments
 (0)