You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Various Valida functions might exhibit partiality; on some inputs, they might fail to terminate with a result of the output type. Instead of panicking or non-terminating, functions should return a result indicating an error. The public functions which are currently partial should be modified to return a Result type.
It is okay to use functions which may panic in unreachable code sections and in cases where it is impossible for the functions to get inputs which result in a panic. However, attainable conditions should never result in a panic.
The reason for this issue is that Valida is going to be used in services, and those services can't panic. They have to stay running even when errors occur.
The following code sections (as far as I know) may potentially result in partiality. Line numbers are relative to commit eddd2b031a13278bc4855dea802fbc045f1378d8.
There are three instances of panic!() , excluding macro code which is only executed at compile-time, and code which is only used for debugging:
In the quoted code for run in the implementation of the run_method macro in derive/src/lib.rs.
In the implementation of AirBuilder::is_transition_window for ConstraintFolder<’a, F, EF, M> in machine/src/__internal/folding_builder.rs.
In the implementation of MemoryChip::read, in memory/src/lib.rs.
There are no instances of .expect() in non-test code, except for some instances in macro code which runs exclusively at compile time. It is okay for code which runs exclusively at compile time to be partial, as long as it terminates.
There are 16 instances of .unwrap() in non-test-code, excluding macro code which runs exclusively at compile time:
In the implementation of main in basic/src/bin/valida.rs, on the call to load_program_rom.
In the implementation of main in basic/src/bin/valida.rs, on the call to std::io::stdin().read_to_end.
In the implementation of main in basic/src/bin/valida.rs, on the call to std::io::stdout().write_all.
In the implementation of check_constraints in machine/src/__internal/check_constraints.rs, on line 30.
In the implementation of check_constraints in machine/src/__internal/check_constraints.rs, on line 39.
In the implementation of check_constraints in machine/src/__internal/check_constraints.rs, on line 44.
In the implementation of check_cumulative_sums in machine/src/__internal/check_constraints.rs, on line 90.
In the implementation of generate_permutation_trace in machine/src/chip.rs, on line 40.
In the implementation of generate_permutation_trace in machine/src/chip.rs, on line 169.
In the implementation of generate_permutation_trace in machine/src/chip.rs, on line 189.
In the implementation of eval_permutation_constraints in machine/src/chip.rs, on line 268.
In the implementation of eval_permutation_constraints in machine/src/chip.rs, on line 270.
In the implementation of MemoryChip::insert_dummy_reads in memory/src/lib.rs, on line 257.
In the implementation of MemoryChip::insert_dummy_reads in memory/src/lib.rs, on line 258.
In the implementation of MemoryChip::insert_dummy_reads in memory/src/lib.rs, on line 259.
In the implementation of Instruction<M>::execute for WriteInstruction in output/src/lib.rs, on line 154.
There are 4 instances of assert_eq!() in non-test code which is run after compile time:
In the implementation of check_constraints in machine/src/__internal/check_constraints.rs.
In the implementation of check_cumulative_sums in machine/src/__internal/check_constraints.rs.
In the implementation of Instruction<M>::execute for WriteInstruction in output/src/lib.rs, on lines 162 and 163.
There is one instance of assert!() in non-test code which runs after compile time:
In the default implementation of read_word in the MachineWithProgramChip trait definition, in program/src/lib.rs.
The following files contain unsafe blocks, which should be assumed pending further review to potentially result in partiality:
alu_u32/src/add/columns.rs
alu_u32/src/add/mod.rs
alu_u32/src/bitwise/columns.rs
alu_u32/src/bitwise/mod.rs
alu_u32/src/div/columns.rs
alu_u32/src/lt/columns.rs
alu_u32/src/lt/mod.rs
alu_u32/src/mul/columns.rs
alu_u32/src/shift/columns.rs
alu_u32/src/shift/mod.rs
alu_u32/src/sub/columns.rs
alu_u32/src/sub/mod.rs
cpu/src/columns.rs
cpu/src/lib.rs
derive/src/lib.rs
memory/src/columns.rs
memory/src/lib.rs
native_field/src/columns.rs
native_field/src/lib.rs
output/src/columns.rs
output/src/lib.rs
program/src/columns.rs
range/src/columns.rs
range/src/lib.rs
The following arithmetic operations may result in division by zero and a panic:
In the implementation of Div::div for Word<u8>, in machine/src/core.rs, line 87.
In the implementation of MemoryChip::insert_dummy_reads in memory/src/lib.rs, line 222.
In the implementation of Instruction<M>::execute for Div32Instruction, in alu_u32/src/div/mod.rs, line 89.
The following unchecked array indexes may result in an out of bounds error and a panic:
In the implementation of generate_permutation_trace in machine/src/chip.rs, lines 120, 166, 179, 182, and 189.
In the implementation of generate_rlc_elements in machine/src/chip.rs, lines 285 and 300.
In the implementation of CpuChip::set_instruction_values in cpu/src/lib.rs, line 248.
In the implementation of CpuChip::pad_to_power_of_two in cpu/src/lib.rs, lines 328, 329, 330, 346, 347, 348, 351, 352, 355, 356, and 357.
The zk-VM run method is capable of non-terminating; see derive/src/lib.rs, lines 158-176. This is to be expected, because Valida is Turing complete. Perhaps, however, we should code in a maximum number of steps, in order to avoid partiality. We can even pass in the maximum number of steps as an input to the method.
The text was updated successfully, but these errors were encountered:
Various Valida functions might exhibit partiality; on some inputs, they might fail to terminate with a result of the output type. Instead of panicking or non-terminating, functions should return a result indicating an error. The public functions which are currently partial should be modified to return a
Result
type.It is okay to use functions which may panic in unreachable code sections and in cases where it is impossible for the functions to get inputs which result in a panic. However, attainable conditions should never result in a panic.
The reason for this issue is that Valida is going to be used in services, and those services can't panic. They have to stay running even when errors occur.
The following code sections (as far as I know) may potentially result in partiality. Line numbers are relative to commit
eddd2b031a13278bc4855dea802fbc045f1378d8
.There are three instances of
panic!()
, excluding macro code which is only executed at compile-time, and code which is only used for debugging:run
in the implementation of therun_method
macro inderive/src/lib.rs
.AirBuilder::is_transition_window
forConstraintFolder<’a, F, EF, M>
inmachine/src/__internal/folding_builder.rs
.MemoryChip::read
, inmemory/src/lib.rs
.There are no instances of
.expect()
in non-test code, except for some instances in macro code which runs exclusively at compile time. It is okay for code which runs exclusively at compile time to be partial, as long as it terminates.There are 16 instances of
.unwrap()
in non-test-code, excluding macro code which runs exclusively at compile time:main
inbasic/src/bin/valida.rs
, on the call toload_program_rom
.main
inbasic/src/bin/valida.rs
, on the call tostd::io::stdin().read_to_end
.main
inbasic/src/bin/valida.rs
, on the call tostd::io::stdout().write_all
.check_constraints
inmachine/src/__internal/check_constraints.rs
, on line 30.check_constraints
inmachine/src/__internal/check_constraints.rs
, on line 39.check_constraints
inmachine/src/__internal/check_constraints.rs
, on line 44.check_cumulative_sums
inmachine/src/__internal/check_constraints.rs
, on line 90.generate_permutation_trace
inmachine/src/chip.rs
, on line 40.generate_permutation_trace
inmachine/src/chip.rs
, on line 169.generate_permutation_trace
inmachine/src/chip.rs
, on line 189.eval_permutation_constraints
inmachine/src/chip.rs
, on line 268.eval_permutation_constraints
inmachine/src/chip.rs
, on line 270.MemoryChip::insert_dummy_reads
inmemory/src/lib.rs
, on line 257.MemoryChip::insert_dummy_reads
inmemory/src/lib.rs
, on line 258.MemoryChip::insert_dummy_reads
inmemory/src/lib.rs
, on line 259.Instruction<M>::execute
forWriteInstruction
inoutput/src/lib.rs
, on line 154.There are 4 instances of
assert_eq!()
in non-test code which is run after compile time:check_constraints
inmachine/src/__internal/check_constraints.rs
.check_cumulative_sums
inmachine/src/__internal/check_constraints.rs
.Instruction<M>::execute
forWriteInstruction
inoutput/src/lib.rs
, on lines 162 and 163.There is one instance of
assert!()
in non-test code which runs after compile time:read_word
in theMachineWithProgramChip
trait definition, inprogram/src/lib.rs
.The following files contain
unsafe
blocks, which should be assumed pending further review to potentially result in partiality:alu_u32/src/add/columns.rs
alu_u32/src/add/mod.rs
alu_u32/src/bitwise/columns.rs
alu_u32/src/bitwise/mod.rs
alu_u32/src/div/columns.rs
alu_u32/src/lt/columns.rs
alu_u32/src/lt/mod.rs
alu_u32/src/mul/columns.rs
alu_u32/src/shift/columns.rs
alu_u32/src/shift/mod.rs
alu_u32/src/sub/columns.rs
alu_u32/src/sub/mod.rs
cpu/src/columns.rs
cpu/src/lib.rs
derive/src/lib.rs
memory/src/columns.rs
memory/src/lib.rs
native_field/src/columns.rs
native_field/src/lib.rs
output/src/columns.rs
output/src/lib.rs
program/src/columns.rs
range/src/columns.rs
range/src/lib.rs
The following arithmetic operations may result in division by zero and a panic:
Div::div
forWord<u8>
, inmachine/src/core.rs
, line 87.MemoryChip::insert_dummy_reads
inmemory/src/lib.rs
, line 222.Instruction<M>::execute
forDiv32Instruction
, inalu_u32/src/div/mod.rs
, line 89.The following unchecked array indexes may result in an out of bounds error and a panic:
generate_permutation_trace
inmachine/src/chip.rs
, lines 120, 166, 179, 182, and 189.generate_rlc_elements
inmachine/src/chip.rs
, lines 285 and 300.CpuChip::set_instruction_values
incpu/src/lib.rs
, line 248.CpuChip::pad_to_power_of_two
incpu/src/lib.rs
, lines 328, 329, 330, 346, 347, 348, 351, 352, 355, 356, and 357.The zk-VM
run
method is capable of non-terminating; seederive/src/lib.rs
, lines 158-176. This is to be expected, because Valida is Turing complete. Perhaps, however, we should code in a maximum number of steps, in order to avoid partiality. We can even pass in the maximum number of steps as an input to the method.The text was updated successfully, but these errors were encountered: