mirror of
https://github.com/powdr-labs/powdr.git
synced 2026-04-20 03:03:25 -04:00
when run this command:
`cargo run pil test_data/asm/book/hello_world.asm --inputs 0 -o output
--field m31 --prove-with plonky3 -f`
it gets error:
```
thread 'main' panicked at
powdr/executor/src/witgen/global_constraints.rs:195:37:
attempt to subtract with overflow
```
The problem is in function
```
fn smallest_period_candidate<T: FieldElement>(fixed: &[T]) -> Option<u64> {
if fixed.first() != Some(&0.into()) {
return None;
}
(1..63).find(|bit| fixed.last() == Some(&((1u64 << bit) - 1).into()))
}
```
when using Mersenne31 field (prime: 2^31 -1) and the last element of
fixed is 0, it is equivalent to 2^31-1, then the function return bit=31
and bit=31 overflow at this line:
`let mask = T::Integer::from(((1 << bit) - 1) as u64);`
in function process_fixed_column, as 1 is by default to be i32
so I add the code below to handle the special case and make 1 to be 1u64
`if fixed.last() == Some(&0.into()) {
return None;
}`
---------
Co-authored-by: Georg Wiese <georgwiese@gmail.com>