Skip to content

Commit

Permalink
refactor: simplify constraint construction
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-ferdinand committed May 21, 2024
1 parent 5ee06a2 commit c6b0f13
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions triton-vm/src/table/processor_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2490,7 +2490,7 @@ impl ExtProcessorTable {
.concat()
}

fn get_transition_constraints_for_instruction(
fn transition_constraints_for_instruction(
circuit_builder: &ConstraintCircuitBuilder<DualRowIndicator>,
instruction: Instruction,
) -> Vec<ConstraintCircuitMonad<DualRowIndicator>> {
Expand Down Expand Up @@ -3577,16 +3577,10 @@ impl ExtProcessorTable {
vec![clk_increases_by_1, is_padding_is_0_or_does_not_change];

// instruction-specific constraints
let all_transition_constraints_by_instruction = ALL_INSTRUCTIONS.map(|instruction| {
Self::get_transition_constraints_for_instruction(circuit_builder, instruction)
});
let all_instructions_and_their_transition_constraints = ALL_INSTRUCTIONS
.into_iter()
.zip_eq(all_transition_constraints_by_instruction)
.collect_vec()
.try_into()
.unwrap();

let transition_constraints_for_instruction =
|instr| Self::transition_constraints_for_instruction(circuit_builder, instr);
let all_instructions_and_their_transition_constraints =
ALL_INSTRUCTIONS.map(|instr| (instr, transition_constraints_for_instruction(instr)));
let deselected_transition_constraints =
Self::combine_instruction_constraints_with_deselectors(
circuit_builder,
Expand Down Expand Up @@ -3713,7 +3707,7 @@ pub(crate) mod tests {
) {
let instruction = debug_info.instruction;
let circuit_builder = ConstraintCircuitBuilder::new();
let transition_constraints = ExtProcessorTable::get_transition_constraints_for_instruction(
let transition_constraints = ExtProcessorTable::transition_constraints_for_instruction(
&circuit_builder,
instruction,
);
Expand Down Expand Up @@ -4355,7 +4349,7 @@ pub(crate) mod tests {
println!("|:----------------|-------:|--------:|:------------");
let circuit_builder = ConstraintCircuitBuilder::new();
for instruction in ALL_INSTRUCTIONS {
let constraints = ExtProcessorTable::get_transition_constraints_for_instruction(
let constraints = ExtProcessorTable::transition_constraints_for_instruction(
&circuit_builder,
instruction,
);
Expand Down

0 comments on commit c6b0f13

Please sign in to comment.