Closed sai-deng closed 1 month ago
I think we'd rather want to have a
warn
/error
msg about the CPU target length being too small, and set it toNUM_EXTRA_CYCLES_AFTER.next_power_of_two()
or simply abort early.
We need small CPU target length for empty segment tests, where we aim to use the minimal number of CPU cycles in the first segment.
I think we'd rather want to have a
warn
/error
msg about the CPU target length being too small, and set it toNUM_EXTRA_CYCLES_AFTER.next_power_of_two()
or simply abort early.We need small CPU target length for empty segment tests, where we aim to use the minimal number of CPU cycles in the first segment.
As mentioned, if you are happy with the current empty table proving test, where we use max_cpu_len_log
= 7 or 46 cycles + 82 (NUM_EXTRA_CYCLES_AFTER
), we can abort early here.
I'm a bit confused because max_cpu_len_log
is supposed to represent the full length of the CPU segment, including the final exc_stop
cycles (which takes NUM_CYCLES_AFTER
cycles). So why would we want to allow it to be less than that?
I'm a bit confused because
max_cpu_len_log
is supposed to represent the full length of the CPU segment, including the finalexc_stop
cycles (which takesNUM_CYCLES_AFTER
cycles). So why would we want to allow it to be less than that?
This change only affects the behavior when max_cpu_len_log is less than 7, where we cannot represent the full length of the CPU segment. I planed to modify it so that it specifies the maximum actual CPU cycles we want in the CPU table. It would help with the empty segment test, where we aim to use the minimal number of CPU cycles in the segment.
Anyways, I think we are good with 46 cycles + 82 (NUM_EXTRA_CYCLES_AFTER) in the first segment for empty table testing, so I have made the changes to abort early.
I think it'd be a tad cleaner to have it as a hard
assert!
in the Interpreter initialization (methodnew()
) which is used for both simulation and actual proving (mentioningassert!
because it's probably not worth changing the method signatures to return aResult
instead ofSelf
given that this failure case is a hard no-go anyway).
Done
Address the ‘attempt to subtract with overflow’ issue that occurs when
max_cpu_len_log
is set to a small value (less than 7).This PR will also help with the empty segment test, where we aim to use the minimal number of CPU cycles in the segment.