From 4747b002c432a1eea7920c69bb0eb7a84848f0db Mon Sep 17 00:00:00 2001 From: ohad nir Date: Fri, 10 Jan 2025 20:44:13 +0200 Subject: [PATCH] update the names of jump opcodes --- .../prover/src/cairo_air/debug_tools.rs | 28 +- .../prover/src/cairo_air/opcodes_air.rs | 291 ++++++++---------- .../components/generic_opcode/component.rs | 1 + .../src/components/generic_opcode/prover.rs | 117 ++----- .../component.rs | 1 + .../mod.rs | 0 .../prover.rs | 83 ++--- .../component.rs | 1 + .../mod.rs | 0 .../prover.rs | 96 +++--- .../component.rs | 1 + .../mod.rs | 0 .../prover.rs | 90 +++--- .../component.rs | 1 + .../mod.rs | 0 .../prover.rs | 64 ++-- .../crates/prover/src/components/mod.rs | 8 +- .../src/components/ret_opcode/component.rs | 1 + .../src/components/ret_opcode/prover.rs | 18 +- .../prover/src/input/state_transitions.rs | 55 +--- .../crates/prover/src/input/vm_import/mod.rs | 56 +--- 21 files changed, 395 insertions(+), 517 deletions(-) rename stwo_cairo_prover/crates/prover/src/components/{jump_opcode_is_rel_f_is_imm_f_is_double_deref_f => jump_opcode}/component.rs (98%) rename stwo_cairo_prover/crates/prover/src/components/{jump_opcode_is_rel_f_is_imm_f_is_double_deref_f => jump_opcode}/mod.rs (100%) rename stwo_cairo_prover/crates/prover/src/components/{jump_opcode_is_rel_f_is_imm_f_is_double_deref_f => jump_opcode}/prover.rs (87%) rename stwo_cairo_prover/crates/prover/src/components/{jump_opcode_is_rel_f_is_imm_f_is_double_deref_t => jump_opcode_double_deref}/component.rs (98%) rename stwo_cairo_prover/crates/prover/src/components/{jump_opcode_is_rel_f_is_imm_f_is_double_deref_t => jump_opcode_double_deref}/mod.rs (100%) rename stwo_cairo_prover/crates/prover/src/components/{jump_opcode_is_rel_f_is_imm_f_is_double_deref_t => jump_opcode_double_deref}/prover.rs (88%) rename stwo_cairo_prover/crates/prover/src/components/{jump_opcode_is_rel_t_is_imm_f_is_double_deref_f => jump_opcode_rel}/component.rs (99%) rename stwo_cairo_prover/crates/prover/src/components/{jump_opcode_is_rel_t_is_imm_f_is_double_deref_f => jump_opcode_rel}/mod.rs (100%) rename stwo_cairo_prover/crates/prover/src/components/{jump_opcode_is_rel_t_is_imm_f_is_double_deref_f => jump_opcode_rel}/prover.rs (87%) rename stwo_cairo_prover/crates/prover/src/components/{jump_opcode_is_rel_t_is_imm_t_is_double_deref_f => jump_opcode_rel_imm}/component.rs (98%) rename stwo_cairo_prover/crates/prover/src/components/{jump_opcode_is_rel_t_is_imm_t_is_double_deref_f => jump_opcode_rel_imm}/mod.rs (100%) rename stwo_cairo_prover/crates/prover/src/components/{jump_opcode_is_rel_t_is_imm_t_is_double_deref_f => jump_opcode_rel_imm}/prover.rs (89%) diff --git a/stwo_cairo_prover/crates/prover/src/cairo_air/debug_tools.rs b/stwo_cairo_prover/crates/prover/src/cairo_air/debug_tools.rs index 75540c9b..0166a703 100644 --- a/stwo_cairo_prover/crates/prover/src/cairo_air/debug_tools.rs +++ b/stwo_cairo_prover/crates/prover/src/cairo_air/debug_tools.rs @@ -22,13 +22,11 @@ use crate::components::{ assert_eq_opcode_is_double_deref_t_is_imm_f, call_opcode_is_rel_f_op_1_base_fp_f, call_opcode_is_rel_f_op_1_base_fp_t, call_opcode_is_rel_t_op_1_base_fp_f, generic_opcode, jnz_opcode_is_taken_f_dst_base_fp_f, jnz_opcode_is_taken_f_dst_base_fp_t, - jnz_opcode_is_taken_t_dst_base_fp_f, jnz_opcode_is_taken_t_dst_base_fp_t, - jump_opcode_is_rel_f_is_imm_f_is_double_deref_f, - jump_opcode_is_rel_f_is_imm_f_is_double_deref_t, - jump_opcode_is_rel_t_is_imm_f_is_double_deref_f, - jump_opcode_is_rel_t_is_imm_t_is_double_deref_f, memory_address_to_id, memory_id_to_big, - mul_opcode_is_small_f_is_imm_f, mul_opcode_is_small_f_is_imm_t, range_check_19, - range_check_4_3, range_check_7_2_5, range_check_9_9, ret_opcode, verify_instruction, + jnz_opcode_is_taken_t_dst_base_fp_f, jnz_opcode_is_taken_t_dst_base_fp_t, jump_opcode, + jump_opcode_double_deref, jump_opcode_rel, jump_opcode_rel_imm, memory_address_to_id, + memory_id_to_big, mul_opcode_is_small_f_is_imm_f, mul_opcode_is_small_f_is_imm_t, + range_check_19, range_check_4_3, range_check_7_2_5, range_check_9_9, ret_opcode, + verify_instruction, }; use crate::felt::split_f252; use crate::relations; @@ -344,11 +342,11 @@ where .entries(trace), ); } - for claim in claim.opcodes.jump_f_f_f.clone() { + for claim in claim.opcodes.jump.clone() { entries.extend( RelationTrackerComponent::new( tree_span_provider, - jump_opcode_is_rel_f_is_imm_f_is_double_deref_f::Eval { + jump_opcode::Eval { claim, memory_address_to_id_lookup_elements: relations::MemoryAddressToId::dummy(), memory_id_to_big_lookup_elements: relations::MemoryIdToBig::dummy(), @@ -360,11 +358,11 @@ where .entries(trace), ); } - for claim in claim.opcodes.jump_f_f_t.clone() { + for claim in claim.opcodes.jump_double_deref.clone() { entries.extend( RelationTrackerComponent::new( tree_span_provider, - jump_opcode_is_rel_f_is_imm_f_is_double_deref_t::Eval { + jump_opcode_double_deref::Eval { claim, memory_address_to_id_lookup_elements: relations::MemoryAddressToId::dummy(), memory_id_to_big_lookup_elements: relations::MemoryIdToBig::dummy(), @@ -376,11 +374,11 @@ where .entries(trace), ); } - for claim in claim.opcodes.jump_t_f_f.clone() { + for claim in claim.opcodes.jump_rel.clone() { entries.extend( RelationTrackerComponent::new( tree_span_provider, - jump_opcode_is_rel_t_is_imm_f_is_double_deref_f::Eval { + jump_opcode_rel::Eval { claim, memory_address_to_id_lookup_elements: relations::MemoryAddressToId::dummy(), memory_id_to_big_lookup_elements: relations::MemoryIdToBig::dummy(), @@ -392,11 +390,11 @@ where .entries(trace), ); } - for claim in claim.opcodes.jump_t_t_f.clone() { + for claim in claim.opcodes.jump_rel_imm.clone() { entries.extend( RelationTrackerComponent::new( tree_span_provider, - jump_opcode_is_rel_t_is_imm_t_is_double_deref_f::Eval { + jump_opcode_rel_imm::Eval { claim, memory_address_to_id_lookup_elements: relations::MemoryAddressToId::dummy(), memory_id_to_big_lookup_elements: relations::MemoryIdToBig::dummy(), diff --git a/stwo_cairo_prover/crates/prover/src/cairo_air/opcodes_air.rs b/stwo_cairo_prover/crates/prover/src/cairo_air/opcodes_air.rs index 531b5df7..31d040f8 100644 --- a/stwo_cairo_prover/crates/prover/src/cairo_air/opcodes_air.rs +++ b/stwo_cairo_prover/crates/prover/src/cairo_air/opcodes_air.rs @@ -20,13 +20,10 @@ use crate::components::{ assert_eq_opcode_is_double_deref_t_is_imm_f, call_opcode_is_rel_f_op_1_base_fp_f, call_opcode_is_rel_f_op_1_base_fp_t, call_opcode_is_rel_t_op_1_base_fp_f, generic_opcode, jnz_opcode_is_taken_f_dst_base_fp_f, jnz_opcode_is_taken_f_dst_base_fp_t, - jnz_opcode_is_taken_t_dst_base_fp_f, jnz_opcode_is_taken_t_dst_base_fp_t, - jump_opcode_is_rel_f_is_imm_f_is_double_deref_f, - jump_opcode_is_rel_f_is_imm_f_is_double_deref_t, - jump_opcode_is_rel_t_is_imm_f_is_double_deref_f, - jump_opcode_is_rel_t_is_imm_t_is_double_deref_f, memory_address_to_id, memory_id_to_big, - mul_opcode_is_small_f_is_imm_f, mul_opcode_is_small_f_is_imm_t, range_check_19, - range_check_9_9, ret_opcode, verify_instruction, + jnz_opcode_is_taken_t_dst_base_fp_f, jnz_opcode_is_taken_t_dst_base_fp_t, jump_opcode, + jump_opcode_double_deref, jump_opcode_rel, jump_opcode_rel_imm, memory_address_to_id, + memory_id_to_big, mul_opcode_is_small_f_is_imm_f, mul_opcode_is_small_f_is_imm_t, + range_check_19, range_check_9_9, ret_opcode, verify_instruction, }; use crate::input::state_transitions::StateTransitions; @@ -50,10 +47,10 @@ pub struct OpcodeClaim { pub jnz_f_t: Vec, pub jnz_t_f: Vec, pub jnz_t_t: Vec, - pub jump_f_f_f: Vec, - pub jump_f_f_t: Vec, - pub jump_t_f_f: Vec, - pub jump_t_t_f: Vec, + pub jump: Vec, + pub jump_double_deref: Vec, + pub jump_rel: Vec, + pub jump_rel_imm: Vec, pub mul_f_f: Vec, pub mul_f_t: Vec, pub ret: Vec, @@ -78,10 +75,12 @@ impl OpcodeClaim { self.jnz_f_t.iter().for_each(|c| c.mix_into(channel)); self.jnz_t_f.iter().for_each(|c| c.mix_into(channel)); self.jnz_t_t.iter().for_each(|c| c.mix_into(channel)); - self.jump_f_f_f.iter().for_each(|c| c.mix_into(channel)); - self.jump_f_f_t.iter().for_each(|c| c.mix_into(channel)); - self.jump_t_f_f.iter().for_each(|c| c.mix_into(channel)); - self.jump_t_t_f.iter().for_each(|c| c.mix_into(channel)); + self.jump.iter().for_each(|c| c.mix_into(channel)); + self.jump_double_deref + .iter() + .for_each(|c| c.mix_into(channel)); + self.jump_rel.iter().for_each(|c| c.mix_into(channel)); + self.jump_rel_imm.iter().for_each(|c| c.mix_into(channel)); self.mul_f_f.iter().for_each(|c| c.mix_into(channel)); self.mul_f_t.iter().for_each(|c| c.mix_into(channel)); self.ret.iter().for_each(|c| c.mix_into(channel)); @@ -107,10 +106,10 @@ impl OpcodeClaim { self.jnz_f_t.iter().map(|c| c.log_sizes()), self.jnz_t_f.iter().map(|c| c.log_sizes()), self.jnz_t_t.iter().map(|c| c.log_sizes()), - self.jump_f_f_f.iter().map(|c| c.log_sizes()), - self.jump_f_f_t.iter().map(|c| c.log_sizes()), - self.jump_t_f_f.iter().map(|c| c.log_sizes()), - self.jump_t_t_f.iter().map(|c| c.log_sizes()), + self.jump.iter().map(|c| c.log_sizes()), + self.jump_double_deref.iter().map(|c| c.log_sizes()), + self.jump_rel.iter().map(|c| c.log_sizes()), + self.jump_rel_imm.iter().map(|c| c.log_sizes()), self.mul_f_f.iter().map(|c| c.log_sizes()), self.mul_f_t.iter().map(|c| c.log_sizes()), self.ret.iter().map(|c| c.log_sizes()), @@ -137,10 +136,10 @@ pub struct OpcodesClaimGenerator { jnz_f_t: Vec, jnz_t_f: Vec, jnz_t_t: Vec, - jump_f_f_f: Vec, - jump_f_f_t: Vec, - jump_t_f_f: Vec, - jump_t_t_f: Vec, + jump: Vec, + jump_double_deref: Vec, + jump_rel: Vec, + jump_rel_imm: Vec, mul_f_f: Vec, mul_f_t: Vec, ret: Vec, @@ -166,10 +165,10 @@ impl OpcodesClaimGenerator { let mut jnz_f_t = vec![]; let mut jnz_t_f = vec![]; let mut jnz_t_t = vec![]; - let mut jump_f_f_f = vec![]; - let mut jump_f_f_t = vec![]; - let mut jump_t_f_f = vec![]; - let mut jump_t_t_f = vec![]; + let mut jump = vec![]; + let mut jump_double_deref = vec![]; + let mut jump_rel = vec![]; + let mut jump_rel_imm = vec![]; let mut mul_f_f = vec![]; let mut mul_f_t = vec![]; let mut ret = vec![]; @@ -363,57 +362,29 @@ impl OpcodesClaimGenerator { .jnz_opcode_is_taken_t_dst_base_fp_t, )); } - if !input - .casm_states_by_opcode - .jump_opcode_is_rel_f_is_imm_f_is_double_deref_f - .is_empty() - { - jump_f_f_f.push( - jump_opcode_is_rel_f_is_imm_f_is_double_deref_f::ClaimGenerator::new( - input - .casm_states_by_opcode - .jump_opcode_is_rel_f_is_imm_f_is_double_deref_f, - ), - ); + if !input.casm_states_by_opcode.jump_opcode.is_empty() { + jump.push(jump_opcode::ClaimGenerator::new( + input.casm_states_by_opcode.jump_opcode, + )); } if !input .casm_states_by_opcode - .jump_opcode_is_rel_f_is_imm_f_is_double_deref_t + .jump_opcode_double_deref .is_empty() { - jump_f_f_t.push( - jump_opcode_is_rel_f_is_imm_f_is_double_deref_t::ClaimGenerator::new( - input - .casm_states_by_opcode - .jump_opcode_is_rel_f_is_imm_f_is_double_deref_t, - ), - ); + jump_double_deref.push(jump_opcode_double_deref::ClaimGenerator::new( + input.casm_states_by_opcode.jump_opcode_double_deref, + )); } - if !input - .casm_states_by_opcode - .jump_opcode_is_rel_t_is_imm_f_is_double_deref_f - .is_empty() - { - jump_t_f_f.push( - jump_opcode_is_rel_t_is_imm_f_is_double_deref_f::ClaimGenerator::new( - input - .casm_states_by_opcode - .jump_opcode_is_rel_t_is_imm_f_is_double_deref_f, - ), - ); + if !input.casm_states_by_opcode.jump_opcode_rel.is_empty() { + jump_rel.push(jump_opcode_rel::ClaimGenerator::new( + input.casm_states_by_opcode.jump_opcode_rel, + )); } - if !input - .casm_states_by_opcode - .jump_opcode_is_rel_t_is_imm_t_is_double_deref_f - .is_empty() - { - jump_t_t_f.push( - jump_opcode_is_rel_t_is_imm_t_is_double_deref_f::ClaimGenerator::new( - input - .casm_states_by_opcode - .jump_opcode_is_rel_t_is_imm_t_is_double_deref_f, - ), - ); + if !input.casm_states_by_opcode.jump_opcode_rel_imm.is_empty() { + jump_rel_imm.push(jump_opcode_rel_imm::ClaimGenerator::new( + input.casm_states_by_opcode.jump_opcode_rel_imm, + )); } // Handle small mul in big mul component. Temporary until airs are written with Rc_3_6_6. // TODO(Ohad): mul small. @@ -459,10 +430,10 @@ impl OpcodesClaimGenerator { jnz_f_t, jnz_t_f, jnz_t_t, - jump_f_f_f, - jump_f_f_t, - jump_t_f_f, - jump_t_t_f, + jump, + jump_double_deref, + jump_rel, + jump_rel_imm, mul_f_f, mul_f_t, ret, @@ -699,8 +670,8 @@ impl OpcodesClaimGenerator { ) }) .unzip(); - let (jump_f_f_f_claims, jump_f_f_f_interaction_gens) = self - .jump_f_f_f + let (jump_claims, jump_interaction_gens) = self + .jump .into_iter() .map(|gen| { gen.write_trace( @@ -711,8 +682,8 @@ impl OpcodesClaimGenerator { ) }) .unzip(); - let (jump_f_f_t_claims, jump_f_f_t_interaction_gens) = self - .jump_f_f_t + let (jump_double_deref_claims, jump_double_deref_interaction_gens) = self + .jump_double_deref .into_iter() .map(|gen| { gen.write_trace( @@ -723,8 +694,8 @@ impl OpcodesClaimGenerator { ) }) .unzip(); - let (jump_t_f_f_claims, jump_t_f_f_interaction_gens) = self - .jump_t_f_f + let (jump_rel_claims, jump_rel_interaction_gens) = self + .jump_rel .into_iter() .map(|gen| { gen.write_trace( @@ -735,8 +706,8 @@ impl OpcodesClaimGenerator { ) }) .unzip(); - let (jump_t_t_f_claims, jump_t_t_f_interaction_gens) = self - .jump_t_t_f + let (jump_rel_imm_claims, jump_rel_imm_interaction_gens) = self + .jump_rel_imm .into_iter() .map(|gen| { gen.write_trace( @@ -805,10 +776,10 @@ impl OpcodesClaimGenerator { jnz_f_t: jnz_f_t_claims, jnz_t_f: jnz_t_f_claims, jnz_t_t: jnz_t_t_claims, - jump_f_f_f: jump_f_f_f_claims, - jump_f_f_t: jump_f_f_t_claims, - jump_t_f_f: jump_t_f_f_claims, - jump_t_t_f: jump_t_t_f_claims, + jump: jump_claims, + jump_double_deref: jump_double_deref_claims, + jump_rel: jump_rel_claims, + jump_rel_imm: jump_rel_imm_claims, mul_f_f: mul_f_f_claims, mul_f_t: mul_f_t_claims, ret: ret_claims, @@ -832,10 +803,10 @@ impl OpcodesClaimGenerator { jnz_f_t: jnz_f_t_interaction_gens, jnz_t_f: jnz_t_f_interaction_gens, jnz_t_t: jnz_t_t_interaction_gens, - jump_f_f_f: jump_f_f_f_interaction_gens, - jump_f_f_t: jump_f_f_t_interaction_gens, - jump_t_f_f: jump_t_f_f_interaction_gens, - jump_t_t_f: jump_t_t_f_interaction_gens, + jump: jump_interaction_gens, + jump_double_deref: jump_double_deref_interaction_gens, + jump_rel: jump_rel_interaction_gens, + jump_rel_imm: jump_rel_imm_interaction_gens, mul_f_f: mul_f_f_interaction_gens, mul_f_t: mul_f_t_interaction_gens, ret_interaction_gens, @@ -864,10 +835,10 @@ pub struct OpcodeInteractionClaim { jnz_f_t: Vec, jnz_t_f: Vec, jnz_t_t: Vec, - jump_f_f_f: Vec, - jump_f_f_t: Vec, - jump_t_f_f: Vec, - jump_t_t_f: Vec, + jump: Vec, + jump_double_deref: Vec, + jump_rel: Vec, + jump_rel_imm: Vec, mul_f_f: Vec, mul_f_t: Vec, ret: Vec, @@ -892,10 +863,12 @@ impl OpcodeInteractionClaim { self.jnz_f_t.iter().for_each(|c| c.mix_into(channel)); self.jnz_t_f.iter().for_each(|c| c.mix_into(channel)); self.jnz_t_t.iter().for_each(|c| c.mix_into(channel)); - self.jump_f_f_f.iter().for_each(|c| c.mix_into(channel)); - self.jump_f_f_t.iter().for_each(|c| c.mix_into(channel)); - self.jump_t_f_f.iter().for_each(|c| c.mix_into(channel)); - self.jump_t_t_f.iter().for_each(|c| c.mix_into(channel)); + self.jump.iter().for_each(|c| c.mix_into(channel)); + self.jump_double_deref + .iter() + .for_each(|c| c.mix_into(channel)); + self.jump_rel.iter().for_each(|c| c.mix_into(channel)); + self.jump_rel_imm.iter().for_each(|c| c.mix_into(channel)); self.mul_f_f.iter().for_each(|c| c.mix_into(channel)); self.mul_f_t.iter().for_each(|c| c.mix_into(channel)); self.ret.iter().for_each(|c| c.mix_into(channel)); @@ -1029,28 +1002,28 @@ impl OpcodeInteractionClaim { None => total_sum, }; } - for interaction_claim in &self.jump_f_f_f { + for interaction_claim in &self.jump { let (total_sum, claimed_sum) = interaction_claim.logup_sums; sum += match claimed_sum { Some((claimed_sum, ..)) => claimed_sum, None => total_sum, }; } - for interaction_claim in &self.jump_f_f_t { + for interaction_claim in &self.jump_double_deref { let (total_sum, claimed_sum) = interaction_claim.logup_sums; sum += match claimed_sum { Some((claimed_sum, ..)) => claimed_sum, None => total_sum, }; } - for interaction_claim in &self.jump_t_f_f { + for interaction_claim in &self.jump_rel { let (total_sum, claimed_sum) = interaction_claim.logup_sums; sum += match claimed_sum { Some((claimed_sum, ..)) => claimed_sum, None => total_sum, }; } - for interaction_claim in &self.jump_t_t_f { + for interaction_claim in &self.jump_rel_imm { let (total_sum, claimed_sum) = interaction_claim.logup_sums; sum += match claimed_sum { Some((claimed_sum, ..)) => claimed_sum, @@ -1101,10 +1074,10 @@ pub struct OpcodesInteractionClaimGenerator { jnz_f_t: Vec, jnz_t_f: Vec, jnz_t_t: Vec, - jump_f_f_f: Vec, - jump_f_f_t: Vec, - jump_t_f_f: Vec, - jump_t_t_f: Vec, + jump: Vec, + jump_double_deref: Vec, + jump_rel: Vec, + jump_rel_imm: Vec, mul_f_f: Vec, mul_f_t: Vec, ret_interaction_gens: Vec, @@ -1352,8 +1325,8 @@ impl OpcodesInteractionClaimGenerator { ) }) .collect(); - let jump_f_f_f_interaction_claims = self - .jump_f_f_f + let jump_interaction_claims = self + .jump .into_iter() .map(|gen| { gen.write_interaction_trace( @@ -1365,8 +1338,8 @@ impl OpcodesInteractionClaimGenerator { ) }) .collect(); - let jump_f_f_t_interaction_claims = self - .jump_f_f_t + let jump_double_deref_interaction_claims = self + .jump_double_deref .into_iter() .map(|gen| { gen.write_interaction_trace( @@ -1378,8 +1351,8 @@ impl OpcodesInteractionClaimGenerator { ) }) .collect(); - let jump_t_f_f_interaction_claims = self - .jump_t_f_f + let jump_rel_interaction_claims = self + .jump_rel .into_iter() .map(|gen| { gen.write_interaction_trace( @@ -1391,8 +1364,8 @@ impl OpcodesInteractionClaimGenerator { ) }) .collect(); - let jump_t_t_f_interaction_claims = self - .jump_t_t_f + let jump_rel_imm_interaction_claims = self + .jump_rel_imm .into_iter() .map(|gen| { gen.write_interaction_trace( @@ -1464,10 +1437,10 @@ impl OpcodesInteractionClaimGenerator { jnz_f_t: jnz_f_t_interaction_claims, jnz_t_f: jnz_t_f_interaction_claims, jnz_t_t: jnz_t_t_interaction_claims, - jump_f_f_f: jump_f_f_f_interaction_claims, - jump_f_f_t: jump_f_f_t_interaction_claims, - jump_t_f_f: jump_t_f_f_interaction_claims, - jump_t_t_f: jump_t_t_f_interaction_claims, + jump: jump_interaction_claims, + jump_double_deref: jump_double_deref_interaction_claims, + jump_rel: jump_rel_interaction_claims, + jump_rel_imm: jump_rel_imm_interaction_claims, mul_f_f: mul_f_f_interaction_claims, mul_f_t: mul_f_t_interaction_claims, ret: ret_interaction_claims, @@ -1494,10 +1467,10 @@ pub struct OpcodeComponents { jnz_f_t: Vec, jnz_t_f: Vec, jnz_t_t: Vec, - jump_f_f_f: Vec, - jump_f_f_t: Vec, - jump_t_f_f: Vec, - jump_t_t_f: Vec, + jump: Vec, + jump_double_deref: Vec, + jump_rel: Vec, + jump_rel_imm: Vec, mul_f_f: Vec, mul_f_t: Vec, ret: Vec, @@ -1939,14 +1912,14 @@ impl OpcodeComponents { ) }) .collect_vec(); - let jump_f_f_f_components = claim - .jump_f_f_f + let jump_components = claim + .jump .iter() - .zip(interaction_claim.jump_f_f_f.iter()) + .zip(interaction_claim.jump.iter()) .map(|(&claim, &interaction_claim)| { - jump_opcode_is_rel_f_is_imm_f_is_double_deref_f::Component::new( + jump_opcode::Component::new( tree_span_provider, - jump_opcode_is_rel_f_is_imm_f_is_double_deref_f::Eval { + jump_opcode::Eval { claim, memory_address_to_id_lookup_elements: interaction_elements .memory_address_to_id @@ -1963,14 +1936,14 @@ impl OpcodeComponents { ) }) .collect(); - let jump_f_f_t_components = claim - .jump_f_f_t + let jump_double_deref_components = claim + .jump_double_deref .iter() - .zip(interaction_claim.jump_f_f_t.iter()) + .zip(interaction_claim.jump_double_deref.iter()) .map(|(&claim, &interaction_claim)| { - jump_opcode_is_rel_f_is_imm_f_is_double_deref_t::Component::new( + jump_opcode_double_deref::Component::new( tree_span_provider, - jump_opcode_is_rel_f_is_imm_f_is_double_deref_t::Eval { + jump_opcode_double_deref::Eval { claim, memory_address_to_id_lookup_elements: interaction_elements .memory_address_to_id @@ -1987,14 +1960,14 @@ impl OpcodeComponents { ) }) .collect(); - let jump_t_f_f_components = claim - .jump_t_f_f + let jump_rel_components = claim + .jump_rel .iter() - .zip(interaction_claim.jump_t_f_f.iter()) + .zip(interaction_claim.jump_rel.iter()) .map(|(&claim, &interaction_claim)| { - jump_opcode_is_rel_t_is_imm_f_is_double_deref_f::Component::new( + jump_opcode_rel::Component::new( tree_span_provider, - jump_opcode_is_rel_t_is_imm_f_is_double_deref_f::Eval { + jump_opcode_rel::Eval { claim, memory_address_to_id_lookup_elements: interaction_elements .memory_address_to_id @@ -2011,14 +1984,14 @@ impl OpcodeComponents { ) }) .collect(); - let jump_t_t_f_components = claim - .jump_t_t_f + let jump_rel_imm_components = claim + .jump_rel_imm .iter() - .zip(interaction_claim.jump_t_t_f.iter()) + .zip(interaction_claim.jump_rel_imm.iter()) .map(|(&claim, &interaction_claim)| { - jump_opcode_is_rel_t_is_imm_t_is_double_deref_f::Component::new( + jump_opcode_rel_imm::Component::new( tree_span_provider, - jump_opcode_is_rel_t_is_imm_t_is_double_deref_f::Eval { + jump_opcode_rel_imm::Eval { claim, memory_address_to_id_lookup_elements: interaction_elements .memory_address_to_id @@ -2128,10 +2101,10 @@ impl OpcodeComponents { jnz_f_t: jnz_f_t_components, jnz_t_f: jnz_t_f_components, jnz_t_t: jnz_t_t_components, - jump_f_f_f: jump_f_f_f_components, - jump_f_f_t: jump_f_f_t_components, - jump_t_f_f: jump_t_f_f_components, - jump_t_t_f: jump_t_t_f_components, + jump: jump_components, + jump_double_deref: jump_double_deref_components, + jump_rel: jump_rel_components, + jump_rel_imm: jump_rel_imm_components, mul_f_f: mul_f_f_components, mul_f_t: mul_f_t_components, ret: ret_components, @@ -2231,22 +2204,22 @@ impl OpcodeComponents { .map(|component| component as &dyn ComponentProver), ); vec.extend( - self.jump_f_f_f + self.jump .iter() .map(|component| component as &dyn ComponentProver), ); vec.extend( - self.jump_f_f_t + self.jump_double_deref .iter() .map(|component| component as &dyn ComponentProver), ); vec.extend( - self.jump_t_f_f + self.jump_rel .iter() .map(|component| component as &dyn ComponentProver), ); vec.extend( - self.jump_t_t_f + self.jump_rel_imm .iter() .map(|component| component as &dyn ComponentProver), ); @@ -2307,14 +2280,14 @@ impl std::fmt::Display for OpcodeComponents { writeln!(f, "{}", display_components(&self.jnz_t_f))?; writeln!(f, "jnz_t_t:")?; writeln!(f, "{}", display_components(&self.jnz_t_t))?; - writeln!(f, "jump_f_f_f:")?; - writeln!(f, "{}", display_components(&self.jump_f_f_f))?; - writeln!(f, "jump_f_f_t:")?; - writeln!(f, "{}", display_components(&self.jump_f_f_t))?; - writeln!(f, "jump_t_f_f:")?; - writeln!(f, "{}", display_components(&self.jump_t_f_f))?; - writeln!(f, "jump_t_t_f:")?; - writeln!(f, "{}", display_components(&self.jump_t_t_f))?; + writeln!(f, "jump:")?; + writeln!(f, "{}", display_components(&self.jump))?; + writeln!(f, "jump_double_deref:")?; + writeln!(f, "{}", display_components(&self.jump_double_deref))?; + writeln!(f, "jump_rel:")?; + writeln!(f, "{}", display_components(&self.jump_rel))?; + writeln!(f, "jump_rel_imm:")?; + writeln!(f, "{}", display_components(&self.jump_rel_imm))?; writeln!(f, "mul_f_f:")?; writeln!(f, "{}", display_components(&self.mul_f_f))?; writeln!(f, "mul_f_t:")?; diff --git a/stwo_cairo_prover/crates/prover/src/components/generic_opcode/component.rs b/stwo_cairo_prover/crates/prover/src/components/generic_opcode/component.rs index 9b1f7394..678004ce 100644 --- a/stwo_cairo_prover/crates/prover/src/components/generic_opcode/component.rs +++ b/stwo_cairo_prover/crates/prover/src/components/generic_opcode/component.rs @@ -4,6 +4,7 @@ use num_traits::{One, Zero}; use serde::{Deserialize, Serialize}; use stwo_cairo_serialize::CairoSerialize; use stwo_prover::constraint_framework::logup::{LogupAtRow, LogupSums, LookupElements}; +use stwo_prover::constraint_framework::preprocessed_columns::PreprocessedColumn; use stwo_prover::constraint_framework::{ EvalAtRow, FrameworkComponent, FrameworkEval, RelationEntry, }; diff --git a/stwo_cairo_prover/crates/prover/src/components/generic_opcode/prover.rs b/stwo_cairo_prover/crates/prover/src/components/generic_opcode/prover.rs index b656eb19..6a1f122c 100644 --- a/stwo_cairo_prover/crates/prover/src/components/generic_opcode/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/generic_opcode/prover.rs @@ -7,27 +7,28 @@ use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; use prover_types::simd::*; -use rayon::iter::ParallelIterator; -use rayon::iter::{IndexedParallelIterator, IntoParallelRefIterator}; -use stwo_air_utils_derive::{Uninitialized, IterMut, ParIterMut}; +use rayon::iter::{ + IndexedParallelIterator, IntoParallelIterator, IntoParallelRefIterator, ParallelIterator, +}; use stwo_air_utils::trace::component_trace::ComponentTrace; +use stwo_air_utils_derive::{IterMut, ParIterMut, Uninitialized}; use stwo_prover::constraint_framework::logup::LogupTraceGenerator; +use stwo_prover::constraint_framework::preprocessed_columns::PreprocessedColumn; use stwo_prover::constraint_framework::Relation; use stwo_prover::core::air::Component; -use stwo_prover::core::backend::{Col, Column}; -use stwo_prover::core::backend::BackendForChannel; use stwo_prover::core::backend::simd::column::BaseColumn; use stwo_prover::core::backend::simd::conversion::Unpack; use stwo_prover::core::backend::simd::m31::{PackedM31, LOG_N_LANES, N_LANES}; use stwo_prover::core::backend::simd::qm31::PackedQM31; use stwo_prover::core::backend::simd::SimdBackend; +use stwo_prover::core::backend::{BackendForChannel, Col, Column}; use stwo_prover::core::channel::{Channel, MerkleChannel}; use stwo_prover::core::fields::m31::M31; +use stwo_prover::core::fields::FieldExpOps; use stwo_prover::core::pcs::TreeBuilder; -use stwo_prover::core::poly::BitReversedOrder; use stwo_prover::core::poly::circle::{CanonicCoset, CircleEvaluation}; +use stwo_prover::core::poly::BitReversedOrder; use stwo_prover::core::utils::bit_reverse_coset_to_circle_domain_order; - use super::component::{Claim, InteractionClaim}; use crate::components::pack_values; use crate::relations; @@ -42,8 +43,8 @@ pub struct ClaimGenerator { pub inputs: Vec, } impl ClaimGenerator { - pub fn new(inputs: Vec) -> Self { - Self { inputs } + pub fn new(inputs: Vec,) -> Self { + Self { inputs, } } pub fn write_trace( @@ -66,7 +67,7 @@ impl ClaimGenerator { let packed_inputs = pack_values(&self.inputs); let (trace, mut sub_components_inputs, lookup_data) = - write_trace_simd(packed_inputs, memory_address_to_id_state,memory_id_to_big_state,); + write_trace_simd(n_rows,packed_inputs,memory_address_to_id_state,memory_id_to_big_state,); if need_padding { sub_components_inputs.bit_reverse_coset_to_circle_domain_order(); @@ -87,7 +88,7 @@ impl ClaimGenerator { ( Claim { - n_rows + n_rows, }, InteractionClaimGenerator { n_rows, @@ -96,12 +97,7 @@ impl ClaimGenerator { ) } - pub fn add_inputs( - &mut self, - inputs: &[InputType], - ) { - self.inputs.extend(inputs); - } + pub fn add_inputs(&self, _inputs: &[InputType],) {unimplemented!("Implement manually");} } #[derive(SubComponentInputs,Uninitialized,IterMut, ParIterMut)] @@ -113,30 +109,30 @@ pub struct SubComponentInputs #[allow(clippy::double_parens)] #[allow(non_snake_case)] fn write_trace_simd( - inputs: Vec, - memory_address_to_id_state: &memory_address_to_id::ClaimGenerator,memory_id_to_big_state: &memory_id_to_big::ClaimGenerator, + n_rows: usize,inputs: Vec,memory_address_to_id_state: &memory_address_to_id::ClaimGenerator,memory_id_to_big_state: &memory_id_to_big::ClaimGenerator, ) -> (ComponentTrace, SubComponentInputs, LookupData) { - let log_n_packed_rows = inputs.len().ilog2(); - let log_size = log_n_packed_rows + LOG_N_LANES; - let (mut trace, mut lookup_data, mut sub_components_inputs) = unsafe { - ( - ComponentTrace::::uninitialized(log_size), - LookupData::uninitialized(log_n_packed_rows), - SubComponentInputs::uninitialized(log_size), - ) - }; + let log_n_packed_rows = inputs.len().ilog2(); + let log_size = log_n_packed_rows + LOG_N_LANES; + let (mut trace, mut lookup_data, mut sub_components_inputs) = unsafe { + ( + ComponentTrace::::uninitialized(log_size), + LookupData::uninitialized(log_n_packed_rows), + SubComponentInputs::uninitialized(log_size), + ) + }; let M31_0 = PackedM31::broadcast(M31::from(0));let M31_1 = PackedM31::broadcast(M31::from(1));let M31_131072 = PackedM31::broadcast(M31::from(131072));let M31_134217728 = PackedM31::broadcast(M31::from(134217728));let M31_136 = PackedM31::broadcast(M31::from(136));let M31_2 = PackedM31::broadcast(M31::from(2));let M31_256 = PackedM31::broadcast(M31::from(256));let M31_262144 = PackedM31::broadcast(M31::from(262144));let M31_32 = PackedM31::broadcast(M31::from(32));let M31_32768 = PackedM31::broadcast(M31::from(32768));let M31_4 = PackedM31::broadcast(M31::from(4));let M31_4194304 = PackedM31::broadcast(M31::from(4194304));let M31_511 = PackedM31::broadcast(M31::from(511));let M31_512 = PackedM31::broadcast(M31::from(512));let M31_64 = PackedM31::broadcast(M31::from(64));let M31_65536 = PackedM31::broadcast(M31::from(65536));let M31_8 = PackedM31::broadcast(M31::from(8));let UInt16_0 = PackedUInt16::broadcast(UInt16::from(0));let UInt16_1 = PackedUInt16::broadcast(UInt16::from(1));let UInt16_10 = PackedUInt16::broadcast(UInt16::from(10));let UInt16_11 = PackedUInt16::broadcast(UInt16::from(11));let UInt16_12 = PackedUInt16::broadcast(UInt16::from(12));let UInt16_127 = PackedUInt16::broadcast(UInt16::from(127));let UInt16_13 = PackedUInt16::broadcast(UInt16::from(13));let UInt16_14 = PackedUInt16::broadcast(UInt16::from(14));let UInt16_2 = PackedUInt16::broadcast(UInt16::from(2));let UInt16_3 = PackedUInt16::broadcast(UInt16::from(3));let UInt16_31 = PackedUInt16::broadcast(UInt16::from(31));let UInt16_4 = PackedUInt16::broadcast(UInt16::from(4));let UInt16_5 = PackedUInt16::broadcast(UInt16::from(5));let UInt16_6 = PackedUInt16::broadcast(UInt16::from(6));let UInt16_7 = PackedUInt16::broadcast(UInt16::from(7));let UInt16_8 = PackedUInt16::broadcast(UInt16::from(8));let UInt16_9 = PackedUInt16::broadcast(UInt16::from(9));let UInt32_262143 = PackedUInt32::broadcast(UInt32::from(262143));let UInt32_511 = PackedUInt32::broadcast(UInt32::from(511));let UInt32_65536 = PackedUInt32::broadcast(UInt32::from(65536));let UInt32_9 = PackedUInt32::broadcast(UInt32::from(9)); trace .par_iter_mut() - .zip(inputs.par_iter()) + .enumerate() + .zip(inputs.into_par_iter()) .zip(lookup_data.par_iter_mut()) .zip(sub_components_inputs.par_iter_mut().chunks(N_LANES)) .for_each( - |(((row, generic_opcode_input), lookup_data), mut sub_components_inputs)| { + |((((row_index, row), generic_opcode_input), lookup_data), mut sub_components_inputs)| { let input_tmp_57455_0 = generic_opcode_input; let input_pc_col0 = input_tmp_57455_0.pc; *row[0] = input_pc_col0; @@ -214,7 +210,6 @@ let opcode_ret_col19 = opcode_ret_tmp_57455_19.as_m31(); let opcode_assert_eq_tmp_57455_20 = ((((((((PackedUInt16::from_m31(memory_id_to_big_value_tmp_57455_2.get_m31(5))) >> (UInt16_3))) + (((PackedUInt16::from_m31(memory_id_to_big_value_tmp_57455_2.get_m31(6))) << (UInt16_6))))) >> (UInt16_14))) & (UInt16_1)); let opcode_assert_eq_col20 = opcode_assert_eq_tmp_57455_20.as_m31(); *row[20] = opcode_assert_eq_col20; - for (i, &input) in (input_pc_col0, [offset0_col3, offset1_col4, offset2_col5], [dst_base_fp_col6, op0_base_fp_col7, op1_imm_col8, op1_base_fp_col9, op1_base_ap_col10, res_add_col11, res_mul_col12, pc_update_jump_col13, pc_update_jump_rel_col14, pc_update_jnz_col15, ap_update_add_col16, ap_update_add_1_col17, opcode_call_col18, opcode_ret_col19, opcode_assert_eq_col20]).unpack().iter().enumerate() { *sub_components_inputs[i] .verify_instruction_inputs[0] = input; @@ -549,85 +544,71 @@ let add_res_limb_27_col135 = add_res_tmp_57455_32.get_m31(27); //Range Check Big Value. - for (i, &input) in [add_res_limb_0_col108, add_res_limb_1_col109].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[0] = input; } *lookup_data.range_check_9_9_0 = [add_res_limb_0_col108, add_res_limb_1_col109]; - for (i, &input) in [add_res_limb_2_col110, add_res_limb_3_col111].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[1] = input; } *lookup_data.range_check_9_9_1 = [add_res_limb_2_col110, add_res_limb_3_col111]; - for (i, &input) in [add_res_limb_4_col112, add_res_limb_5_col113].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[2] = input; } *lookup_data.range_check_9_9_2 = [add_res_limb_4_col112, add_res_limb_5_col113]; - for (i, &input) in [add_res_limb_6_col114, add_res_limb_7_col115].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[3] = input; } *lookup_data.range_check_9_9_3 = [add_res_limb_6_col114, add_res_limb_7_col115]; - for (i, &input) in [add_res_limb_8_col116, add_res_limb_9_col117].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[4] = input; } *lookup_data.range_check_9_9_4 = [add_res_limb_8_col116, add_res_limb_9_col117]; - for (i, &input) in [add_res_limb_10_col118, add_res_limb_11_col119].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[5] = input; } *lookup_data.range_check_9_9_5 = [add_res_limb_10_col118, add_res_limb_11_col119]; - for (i, &input) in [add_res_limb_12_col120, add_res_limb_13_col121].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[6] = input; } *lookup_data.range_check_9_9_6 = [add_res_limb_12_col120, add_res_limb_13_col121]; - for (i, &input) in [add_res_limb_14_col122, add_res_limb_15_col123].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[7] = input; } *lookup_data.range_check_9_9_7 = [add_res_limb_14_col122, add_res_limb_15_col123]; - for (i, &input) in [add_res_limb_16_col124, add_res_limb_17_col125].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[8] = input; } *lookup_data.range_check_9_9_8 = [add_res_limb_16_col124, add_res_limb_17_col125]; - for (i, &input) in [add_res_limb_18_col126, add_res_limb_19_col127].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[9] = input; } *lookup_data.range_check_9_9_9 = [add_res_limb_18_col126, add_res_limb_19_col127]; - for (i, &input) in [add_res_limb_20_col128, add_res_limb_21_col129].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[10] = input; } *lookup_data.range_check_9_9_10 = [add_res_limb_20_col128, add_res_limb_21_col129]; - for (i, &input) in [add_res_limb_22_col130, add_res_limb_23_col131].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[11] = input; } *lookup_data.range_check_9_9_11 = [add_res_limb_22_col130, add_res_limb_23_col131]; - for (i, &input) in [add_res_limb_24_col132, add_res_limb_25_col133].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[12] = input; } *lookup_data.range_check_9_9_12 = [add_res_limb_24_col132, add_res_limb_25_col133]; - for (i, &input) in [add_res_limb_26_col134, add_res_limb_27_col135].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[13] = input; @@ -717,85 +698,71 @@ let mul_res_limb_27_col164 = mul_res_tmp_57455_61.get_m31(27); //Range Check Big Value. - for (i, &input) in [mul_res_limb_0_col137, mul_res_limb_1_col138].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[14] = input; } *lookup_data.range_check_9_9_14 = [mul_res_limb_0_col137, mul_res_limb_1_col138]; - for (i, &input) in [mul_res_limb_2_col139, mul_res_limb_3_col140].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[15] = input; } *lookup_data.range_check_9_9_15 = [mul_res_limb_2_col139, mul_res_limb_3_col140]; - for (i, &input) in [mul_res_limb_4_col141, mul_res_limb_5_col142].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[16] = input; } *lookup_data.range_check_9_9_16 = [mul_res_limb_4_col141, mul_res_limb_5_col142]; - for (i, &input) in [mul_res_limb_6_col143, mul_res_limb_7_col144].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[17] = input; } *lookup_data.range_check_9_9_17 = [mul_res_limb_6_col143, mul_res_limb_7_col144]; - for (i, &input) in [mul_res_limb_8_col145, mul_res_limb_9_col146].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[18] = input; } *lookup_data.range_check_9_9_18 = [mul_res_limb_8_col145, mul_res_limb_9_col146]; - for (i, &input) in [mul_res_limb_10_col147, mul_res_limb_11_col148].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[19] = input; } *lookup_data.range_check_9_9_19 = [mul_res_limb_10_col147, mul_res_limb_11_col148]; - for (i, &input) in [mul_res_limb_12_col149, mul_res_limb_13_col150].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[20] = input; } *lookup_data.range_check_9_9_20 = [mul_res_limb_12_col149, mul_res_limb_13_col150]; - for (i, &input) in [mul_res_limb_14_col151, mul_res_limb_15_col152].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[21] = input; } *lookup_data.range_check_9_9_21 = [mul_res_limb_14_col151, mul_res_limb_15_col152]; - for (i, &input) in [mul_res_limb_16_col153, mul_res_limb_17_col154].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[22] = input; } *lookup_data.range_check_9_9_22 = [mul_res_limb_16_col153, mul_res_limb_17_col154]; - for (i, &input) in [mul_res_limb_18_col155, mul_res_limb_19_col156].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[23] = input; } *lookup_data.range_check_9_9_23 = [mul_res_limb_18_col155, mul_res_limb_19_col156]; - for (i, &input) in [mul_res_limb_20_col157, mul_res_limb_21_col158].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[24] = input; } *lookup_data.range_check_9_9_24 = [mul_res_limb_20_col157, mul_res_limb_21_col158]; - for (i, &input) in [mul_res_limb_22_col159, mul_res_limb_23_col160].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[25] = input; } *lookup_data.range_check_9_9_25 = [mul_res_limb_22_col159, mul_res_limb_23_col160]; - for (i, &input) in [mul_res_limb_24_col161, mul_res_limb_25_col162].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[26] = input; } *lookup_data.range_check_9_9_26 = [mul_res_limb_24_col161, mul_res_limb_25_col162]; - for (i, &input) in [mul_res_limb_26_col163, mul_res_limb_27_col164].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_9_9_inputs[27] = input; @@ -895,7 +862,6 @@ let conv_mod_tmp_57455_144 = ((((((M31_0) + (((M31_2) * (conv_tmp_57455_82))))) let k_mod_2_18_biased_tmp_57455_145 = ((((((PackedUInt32::from_m31(((conv_mod_tmp_57455_117) + (M31_134217728)))) + (((((PackedUInt32::from_m31(((conv_mod_tmp_57455_118) + (M31_134217728)))) & (UInt32_511))) << (UInt32_9))))) + (UInt32_65536))) & (UInt32_262143)); let k_col165 = ((k_mod_2_18_biased_tmp_57455_145.low().as_m31()) + (((((k_mod_2_18_biased_tmp_57455_145.high().as_m31()) - (M31_1))) * (M31_65536)))); *row[165] = k_col165; - for (i, &input) in [((k_col165) + (M31_262144))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[0] = input; @@ -903,7 +869,6 @@ for (i, &input) in [((k_col165) + (M31_262144))].unpack().iter().enumerate() { *lookup_data.range_check_19_0 = [((k_col165) + (M31_262144))]; let carry_0_col166 = ((((((conv_mod_tmp_57455_117) - (((M31_1) * (k_col165))))) + (M31_0))) * (M31_4194304)); *row[166] = carry_0_col166; - for (i, &input) in [((carry_0_col166) + (M31_131072))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[1] = input; @@ -911,7 +876,6 @@ for (i, &input) in [((carry_0_col166) + (M31_131072))].unpack().iter().enumerate *lookup_data.range_check_19_1 = [((carry_0_col166) + (M31_131072))]; let carry_1_col167 = ((((conv_mod_tmp_57455_118) + (carry_0_col166))) * (M31_4194304)); *row[167] = carry_1_col167; - for (i, &input) in [((carry_1_col167) + (M31_131072))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[2] = input; @@ -919,7 +883,6 @@ for (i, &input) in [((carry_1_col167) + (M31_131072))].unpack().iter().enumerate *lookup_data.range_check_19_2 = [((carry_1_col167) + (M31_131072))]; let carry_2_col168 = ((((conv_mod_tmp_57455_119) + (carry_1_col167))) * (M31_4194304)); *row[168] = carry_2_col168; - for (i, &input) in [((carry_2_col168) + (M31_131072))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[3] = input; @@ -927,7 +890,6 @@ for (i, &input) in [((carry_2_col168) + (M31_131072))].unpack().iter().enumerate *lookup_data.range_check_19_3 = [((carry_2_col168) + (M31_131072))]; let carry_3_col169 = ((((conv_mod_tmp_57455_120) + (carry_2_col168))) * (M31_4194304)); *row[169] = carry_3_col169; - for (i, &input) in [((carry_3_col169) + (M31_131072))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[4] = input; @@ -935,7 +897,6 @@ for (i, &input) in [((carry_3_col169) + (M31_131072))].unpack().iter().enumerate *lookup_data.range_check_19_4 = [((carry_3_col169) + (M31_131072))]; let carry_4_col170 = ((((conv_mod_tmp_57455_121) + (carry_3_col169))) * (M31_4194304)); *row[170] = carry_4_col170; - for (i, &input) in [((carry_4_col170) + (M31_131072))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[5] = input; @@ -943,7 +904,6 @@ for (i, &input) in [((carry_4_col170) + (M31_131072))].unpack().iter().enumerate *lookup_data.range_check_19_5 = [((carry_4_col170) + (M31_131072))]; let carry_5_col171 = ((((conv_mod_tmp_57455_122) + (carry_4_col170))) * (M31_4194304)); *row[171] = carry_5_col171; - for (i, &input) in [((carry_5_col171) + (M31_131072))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[6] = input; @@ -951,7 +911,6 @@ for (i, &input) in [((carry_5_col171) + (M31_131072))].unpack().iter().enumerate *lookup_data.range_check_19_6 = [((carry_5_col171) + (M31_131072))]; let carry_6_col172 = ((((conv_mod_tmp_57455_123) + (carry_5_col171))) * (M31_4194304)); *row[172] = carry_6_col172; - for (i, &input) in [((carry_6_col172) + (M31_131072))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[7] = input; @@ -959,7 +918,6 @@ for (i, &input) in [((carry_6_col172) + (M31_131072))].unpack().iter().enumerate *lookup_data.range_check_19_7 = [((carry_6_col172) + (M31_131072))]; let carry_7_col173 = ((((conv_mod_tmp_57455_124) + (carry_6_col172))) * (M31_4194304)); *row[173] = carry_7_col173; - for (i, &input) in [((carry_7_col173) + (M31_131072))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[8] = input; @@ -967,7 +925,6 @@ for (i, &input) in [((carry_7_col173) + (M31_131072))].unpack().iter().enumerate *lookup_data.range_check_19_8 = [((carry_7_col173) + (M31_131072))]; let carry_8_col174 = ((((conv_mod_tmp_57455_125) + (carry_7_col173))) * (M31_4194304)); *row[174] = carry_8_col174; - for (i, &input) in [((carry_8_col174) + (M31_131072))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[9] = input; @@ -975,7 +932,6 @@ for (i, &input) in [((carry_8_col174) + (M31_131072))].unpack().iter().enumerate *lookup_data.range_check_19_9 = [((carry_8_col174) + (M31_131072))]; let carry_9_col175 = ((((conv_mod_tmp_57455_126) + (carry_8_col174))) * (M31_4194304)); *row[175] = carry_9_col175; - for (i, &input) in [((carry_9_col175) + (M31_131072))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[10] = input; @@ -983,7 +939,6 @@ for (i, &input) in [((carry_9_col175) + (M31_131072))].unpack().iter().enumerate *lookup_data.range_check_19_10 = [((carry_9_col175) + (M31_131072))]; let carry_10_col176 = ((((conv_mod_tmp_57455_127) + (carry_9_col175))) * (M31_4194304)); *row[176] = carry_10_col176; - for (i, &input) in [((carry_10_col176) + (M31_131072))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[11] = input; @@ -991,7 +946,6 @@ for (i, &input) in [((carry_10_col176) + (M31_131072))].unpack().iter().enumerat *lookup_data.range_check_19_11 = [((carry_10_col176) + (M31_131072))]; let carry_11_col177 = ((((conv_mod_tmp_57455_128) + (carry_10_col176))) * (M31_4194304)); *row[177] = carry_11_col177; - for (i, &input) in [((carry_11_col177) + (M31_131072))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[12] = input; @@ -999,7 +953,6 @@ for (i, &input) in [((carry_11_col177) + (M31_131072))].unpack().iter().enumerat *lookup_data.range_check_19_12 = [((carry_11_col177) + (M31_131072))]; let carry_12_col178 = ((((conv_mod_tmp_57455_129) + (carry_11_col177))) * (M31_4194304)); *row[178] = carry_12_col178; - for (i, &input) in [((carry_12_col178) + (M31_131072))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[13] = input; @@ -1007,7 +960,6 @@ for (i, &input) in [((carry_12_col178) + (M31_131072))].unpack().iter().enumerat *lookup_data.range_check_19_13 = [((carry_12_col178) + (M31_131072))]; let carry_13_col179 = ((((conv_mod_tmp_57455_130) + (carry_12_col178))) * (M31_4194304)); *row[179] = carry_13_col179; - for (i, &input) in [((carry_13_col179) + (M31_131072))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[14] = input; @@ -1015,7 +967,6 @@ for (i, &input) in [((carry_13_col179) + (M31_131072))].unpack().iter().enumerat *lookup_data.range_check_19_14 = [((carry_13_col179) + (M31_131072))]; let carry_14_col180 = ((((conv_mod_tmp_57455_131) + (carry_13_col179))) * (M31_4194304)); *row[180] = carry_14_col180; - for (i, &input) in [((carry_14_col180) + (M31_131072))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[15] = input; @@ -1023,7 +974,6 @@ for (i, &input) in [((carry_14_col180) + (M31_131072))].unpack().iter().enumerat *lookup_data.range_check_19_15 = [((carry_14_col180) + (M31_131072))]; let carry_15_col181 = ((((conv_mod_tmp_57455_132) + (carry_14_col180))) * (M31_4194304)); *row[181] = carry_15_col181; - for (i, &input) in [((carry_15_col181) + (M31_131072))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[16] = input; @@ -1031,7 +981,6 @@ for (i, &input) in [((carry_15_col181) + (M31_131072))].unpack().iter().enumerat *lookup_data.range_check_19_16 = [((carry_15_col181) + (M31_131072))]; let carry_16_col182 = ((((conv_mod_tmp_57455_133) + (carry_15_col181))) * (M31_4194304)); *row[182] = carry_16_col182; - for (i, &input) in [((carry_16_col182) + (M31_131072))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[17] = input; @@ -1039,7 +988,6 @@ for (i, &input) in [((carry_16_col182) + (M31_131072))].unpack().iter().enumerat *lookup_data.range_check_19_17 = [((carry_16_col182) + (M31_131072))]; let carry_17_col183 = ((((conv_mod_tmp_57455_134) + (carry_16_col182))) * (M31_4194304)); *row[183] = carry_17_col183; - for (i, &input) in [((carry_17_col183) + (M31_131072))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[18] = input; @@ -1047,7 +995,6 @@ for (i, &input) in [((carry_17_col183) + (M31_131072))].unpack().iter().enumerat *lookup_data.range_check_19_18 = [((carry_17_col183) + (M31_131072))]; let carry_18_col184 = ((((conv_mod_tmp_57455_135) + (carry_17_col183))) * (M31_4194304)); *row[184] = carry_18_col184; - for (i, &input) in [((carry_18_col184) + (M31_131072))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[19] = input; @@ -1055,7 +1002,6 @@ for (i, &input) in [((carry_18_col184) + (M31_131072))].unpack().iter().enumerat *lookup_data.range_check_19_19 = [((carry_18_col184) + (M31_131072))]; let carry_19_col185 = ((((conv_mod_tmp_57455_136) + (carry_18_col184))) * (M31_4194304)); *row[185] = carry_19_col185; - for (i, &input) in [((carry_19_col185) + (M31_131072))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[20] = input; @@ -1063,7 +1009,6 @@ for (i, &input) in [((carry_19_col185) + (M31_131072))].unpack().iter().enumerat *lookup_data.range_check_19_20 = [((carry_19_col185) + (M31_131072))]; let carry_20_col186 = ((((conv_mod_tmp_57455_137) + (carry_19_col185))) * (M31_4194304)); *row[186] = carry_20_col186; - for (i, &input) in [((carry_20_col186) + (M31_131072))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[21] = input; @@ -1071,7 +1016,6 @@ for (i, &input) in [((carry_20_col186) + (M31_131072))].unpack().iter().enumerat *lookup_data.range_check_19_21 = [((carry_20_col186) + (M31_131072))]; let carry_21_col187 = ((((((conv_mod_tmp_57455_138) - (((M31_136) * (k_col165))))) + (carry_20_col186))) * (M31_4194304)); *row[187] = carry_21_col187; - for (i, &input) in [((carry_21_col187) + (M31_131072))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[22] = input; @@ -1079,7 +1023,6 @@ for (i, &input) in [((carry_21_col187) + (M31_131072))].unpack().iter().enumerat *lookup_data.range_check_19_22 = [((carry_21_col187) + (M31_131072))]; let carry_22_col188 = ((((conv_mod_tmp_57455_139) + (carry_21_col187))) * (M31_4194304)); *row[188] = carry_22_col188; - for (i, &input) in [((carry_22_col188) + (M31_131072))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[23] = input; @@ -1087,7 +1030,6 @@ for (i, &input) in [((carry_22_col188) + (M31_131072))].unpack().iter().enumerat *lookup_data.range_check_19_23 = [((carry_22_col188) + (M31_131072))]; let carry_23_col189 = ((((conv_mod_tmp_57455_140) + (carry_22_col188))) * (M31_4194304)); *row[189] = carry_23_col189; - for (i, &input) in [((carry_23_col189) + (M31_131072))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[24] = input; @@ -1095,7 +1037,6 @@ for (i, &input) in [((carry_23_col189) + (M31_131072))].unpack().iter().enumerat *lookup_data.range_check_19_24 = [((carry_23_col189) + (M31_131072))]; let carry_24_col190 = ((((conv_mod_tmp_57455_141) + (carry_23_col189))) * (M31_4194304)); *row[190] = carry_24_col190; - for (i, &input) in [((carry_24_col190) + (M31_131072))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[25] = input; @@ -1103,7 +1044,6 @@ for (i, &input) in [((carry_24_col190) + (M31_131072))].unpack().iter().enumerat *lookup_data.range_check_19_25 = [((carry_24_col190) + (M31_131072))]; let carry_25_col191 = ((((conv_mod_tmp_57455_142) + (carry_24_col190))) * (M31_4194304)); *row[191] = carry_25_col191; - for (i, &input) in [((carry_25_col191) + (M31_131072))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[26] = input; @@ -1111,7 +1051,6 @@ for (i, &input) in [((carry_25_col191) + (M31_131072))].unpack().iter().enumerat *lookup_data.range_check_19_26 = [((carry_25_col191) + (M31_131072))]; let carry_26_col192 = ((((conv_mod_tmp_57455_143) + (carry_25_col191))) * (M31_4194304)); *row[192] = carry_26_col192; - for (i, &input) in [((carry_26_col192) + (M31_131072))].unpack().iter().enumerate() { *sub_components_inputs[i] .range_check_19_inputs[27] = input; @@ -1213,10 +1152,10 @@ let mid_limbs_set_col222 = mid_limbs_set_tmp_57455_149.as_m31(); let diff_from_p_tmp_57455_150 = ((dst_limb_0_col22) - (M31_1)); let diff_from_p_tmp_57455_151 = ((dst_limb_21_col43) - (M31_136)); let diff_from_p_tmp_57455_152 = ((dst_limb_27_col49) - (M31_256)); -let dst_sum_squares_inv_col223 = ((M31_1) .div (((((((((((((((((((((((((((((((((((((((((((((((((((((((((M31_0) + (((diff_from_p_tmp_57455_150) * (diff_from_p_tmp_57455_150))))) + (dst_limb_1_col23))) + (dst_limb_2_col24))) + (dst_limb_3_col25))) + (dst_limb_4_col26))) + (dst_limb_5_col27))) + (dst_limb_6_col28))) + (dst_limb_7_col29))) + (dst_limb_8_col30))) + (dst_limb_9_col31))) + (dst_limb_10_col32))) + (dst_limb_11_col33))) + (dst_limb_12_col34))) + (dst_limb_13_col35))) + (dst_limb_14_col36))) + (dst_limb_15_col37))) + (dst_limb_16_col38))) + (dst_limb_17_col39))) + (dst_limb_18_col40))) + (dst_limb_19_col41))) + (dst_limb_20_col42))) + (((diff_from_p_tmp_57455_151) * (diff_from_p_tmp_57455_151))))) + (dst_limb_22_col44))) + (dst_limb_23_col45))) + (dst_limb_24_col46))) + (dst_limb_25_col47))) + (dst_limb_26_col48))) + (((diff_from_p_tmp_57455_152) * (diff_from_p_tmp_57455_152)))))); +let dst_sum_squares_inv_col223 = ((((((((((((((((((((((((((((((((((((((((((((((((((((((((M31_0) + (((diff_from_p_tmp_57455_150) * (diff_from_p_tmp_57455_150))))) + (dst_limb_1_col23))) + (dst_limb_2_col24))) + (dst_limb_3_col25))) + (dst_limb_4_col26))) + (dst_limb_5_col27))) + (dst_limb_6_col28))) + (dst_limb_7_col29))) + (dst_limb_8_col30))) + (dst_limb_9_col31))) + (dst_limb_10_col32))) + (dst_limb_11_col33))) + (dst_limb_12_col34))) + (dst_limb_13_col35))) + (dst_limb_14_col36))) + (dst_limb_15_col37))) + (dst_limb_16_col38))) + (dst_limb_17_col39))) + (dst_limb_18_col40))) + (dst_limb_19_col41))) + (dst_limb_20_col42))) + (((diff_from_p_tmp_57455_151) * (diff_from_p_tmp_57455_151))))) + (dst_limb_22_col44))) + (dst_limb_23_col45))) + (dst_limb_24_col46))) + (dst_limb_25_col47))) + (dst_limb_26_col48))) + (((diff_from_p_tmp_57455_152) * (diff_from_p_tmp_57455_152)))).inverse(); *row[223] = dst_sum_squares_inv_col223; let dst_is_zero_tmp_57455_153 = ((((((((((((((((((((((((((((((((((((((((((((((((((((((((M31_0) + (dst_limb_0_col22))) + (dst_limb_1_col23))) + (dst_limb_2_col24))) + (dst_limb_3_col25))) + (dst_limb_4_col26))) + (dst_limb_5_col27))) + (dst_limb_6_col28))) + (dst_limb_7_col29))) + (dst_limb_8_col30))) + (dst_limb_9_col31))) + (dst_limb_10_col32))) + (dst_limb_11_col33))) + (dst_limb_12_col34))) + (dst_limb_13_col35))) + (dst_limb_14_col36))) + (dst_limb_15_col37))) + (dst_limb_16_col38))) + (dst_limb_17_col39))) + (dst_limb_18_col40))) + (dst_limb_19_col41))) + (dst_limb_20_col42))) + (dst_limb_21_col43))) + (dst_limb_22_col44))) + (dst_limb_23_col45))) + (dst_limb_24_col46))) + (dst_limb_25_col47))) + (dst_limb_26_col48))) + (dst_limb_27_col49)).eq(M31_0); -let dst_sum_inv_col224 = ((M31_1) .div (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((M31_0) + (dst_limb_0_col22))) + (dst_limb_1_col23))) + (dst_limb_2_col24))) + (dst_limb_3_col25))) + (dst_limb_4_col26))) + (dst_limb_5_col27))) + (dst_limb_6_col28))) + (dst_limb_7_col29))) + (dst_limb_8_col30))) + (dst_limb_9_col31))) + (dst_limb_10_col32))) + (dst_limb_11_col33))) + (dst_limb_12_col34))) + (dst_limb_13_col35))) + (dst_limb_14_col36))) + (dst_limb_15_col37))) + (dst_limb_16_col38))) + (dst_limb_17_col39))) + (dst_limb_18_col40))) + (dst_limb_19_col41))) + (dst_limb_20_col42))) + (dst_limb_21_col43))) + (dst_limb_22_col44))) + (dst_limb_23_col45))) + (dst_limb_24_col46))) + (dst_limb_25_col47))) + (dst_limb_26_col48))) + (dst_limb_27_col49))) + (dst_is_zero_tmp_57455_153.as_m31())))); +let dst_sum_inv_col224 = ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((M31_0) + (dst_limb_0_col22))) + (dst_limb_1_col23))) + (dst_limb_2_col24))) + (dst_limb_3_col25))) + (dst_limb_4_col26))) + (dst_limb_5_col27))) + (dst_limb_6_col28))) + (dst_limb_7_col29))) + (dst_limb_8_col30))) + (dst_limb_9_col31))) + (dst_limb_10_col32))) + (dst_limb_11_col33))) + (dst_limb_12_col34))) + (dst_limb_13_col35))) + (dst_limb_14_col36))) + (dst_limb_15_col37))) + (dst_limb_16_col38))) + (dst_limb_17_col39))) + (dst_limb_18_col40))) + (dst_limb_19_col41))) + (dst_limb_20_col42))) + (dst_limb_21_col43))) + (dst_limb_22_col44))) + (dst_limb_23_col45))) + (dst_limb_24_col46))) + (dst_limb_25_col47))) + (dst_limb_26_col48))) + (dst_limb_27_col49))) + (dst_is_zero_tmp_57455_153.as_m31())).inverse(); *row[224] = dst_sum_inv_col224; let op1_as_rel_imm_cond_col225 = ((pc_update_jnz_col15) * (((((((((((((((((((((((((((((((((((((((((((((((((((((((((M31_0) + (dst_limb_0_col22))) + (dst_limb_1_col23))) + (dst_limb_2_col24))) + (dst_limb_3_col25))) + (dst_limb_4_col26))) + (dst_limb_5_col27))) + (dst_limb_6_col28))) + (dst_limb_7_col29))) + (dst_limb_8_col30))) + (dst_limb_9_col31))) + (dst_limb_10_col32))) + (dst_limb_11_col33))) + (dst_limb_12_col34))) + (dst_limb_13_col35))) + (dst_limb_14_col36))) + (dst_limb_15_col37))) + (dst_limb_16_col38))) + (dst_limb_17_col39))) + (dst_limb_18_col40))) + (dst_limb_19_col41))) + (dst_limb_20_col42))) + (dst_limb_21_col43))) + (dst_limb_22_col44))) + (dst_limb_23_col45))) + (dst_limb_24_col46))) + (dst_limb_25_col47))) + (dst_limb_26_col48))) + (dst_limb_27_col49)))); *row[225] = op1_as_rel_imm_cond_col225; diff --git a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_f_is_imm_f_is_double_deref_f/component.rs b/stwo_cairo_prover/crates/prover/src/components/jump_opcode/component.rs similarity index 98% rename from stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_f_is_imm_f_is_double_deref_f/component.rs rename to stwo_cairo_prover/crates/prover/src/components/jump_opcode/component.rs index f6f47d2a..541a322f 100644 --- a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_f_is_imm_f_is_double_deref_f/component.rs +++ b/stwo_cairo_prover/crates/prover/src/components/jump_opcode/component.rs @@ -4,6 +4,7 @@ use num_traits::{One, Zero}; use serde::{Deserialize, Serialize}; use stwo_cairo_serialize::CairoSerialize; use stwo_prover::constraint_framework::logup::{LogupAtRow, LogupSums, LookupElements}; +use stwo_prover::constraint_framework::preprocessed_columns::PreprocessedColumn; use stwo_prover::constraint_framework::{ EvalAtRow, FrameworkComponent, FrameworkEval, RelationEntry, }; diff --git a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_f_is_imm_f_is_double_deref_f/mod.rs b/stwo_cairo_prover/crates/prover/src/components/jump_opcode/mod.rs similarity index 100% rename from stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_f_is_imm_f_is_double_deref_f/mod.rs rename to stwo_cairo_prover/crates/prover/src/components/jump_opcode/mod.rs diff --git a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_f_is_imm_f_is_double_deref_f/prover.rs b/stwo_cairo_prover/crates/prover/src/components/jump_opcode/prover.rs similarity index 87% rename from stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_f_is_imm_f_is_double_deref_f/prover.rs rename to stwo_cairo_prover/crates/prover/src/components/jump_opcode/prover.rs index 49691077..0e48c33e 100644 --- a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_f_is_imm_f_is_double_deref_f/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/jump_opcode/prover.rs @@ -7,10 +7,13 @@ use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; use prover_types::simd::*; -use rayon::iter::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator}; +use rayon::iter::{ + IndexedParallelIterator, IntoParallelIterator, IntoParallelRefIterator, ParallelIterator, +}; use stwo_air_utils::trace::component_trace::ComponentTrace; use stwo_air_utils_derive::{IterMut, ParIterMut, Uninitialized}; use stwo_prover::constraint_framework::logup::LogupTraceGenerator; +use stwo_prover::constraint_framework::preprocessed_columns::PreprocessedColumn; use stwo_prover::constraint_framework::Relation; use stwo_prover::core::air::Component; use stwo_prover::core::backend::simd::column::BaseColumn; @@ -21,6 +24,7 @@ use stwo_prover::core::backend::simd::SimdBackend; use stwo_prover::core::backend::{BackendForChannel, Col, Column}; use stwo_prover::core::channel::{Channel, MerkleChannel}; use stwo_prover::core::fields::m31::M31; +use stwo_prover::core::fields::FieldExpOps; use stwo_prover::core::pcs::TreeBuilder; use stwo_prover::core::poly::circle::{CanonicCoset, CircleEvaluation}; use stwo_prover::core::poly::BitReversedOrder; @@ -65,6 +69,7 @@ impl ClaimGenerator { let packed_inputs = pack_values(&self.inputs); let (trace, mut sub_components_inputs, lookup_data) = write_trace_simd( + n_rows, packed_inputs, memory_address_to_id_state, memory_id_to_big_state, @@ -103,8 +108,8 @@ impl ClaimGenerator { ) } - pub fn add_inputs(&mut self, inputs: &[InputType]) { - self.inputs.extend(inputs); + pub fn add_inputs(&self, _inputs: &[InputType]) { + unimplemented!("Implement manually"); } } @@ -120,6 +125,7 @@ pub struct SubComponentInputs { #[allow(clippy::double_parens)] #[allow(non_snake_case)] fn write_trace_simd( + n_rows: usize, inputs: Vec, memory_address_to_id_state: &memory_address_to_id::ClaimGenerator, memory_id_to_big_state: &memory_id_to_big::ClaimGenerator, @@ -155,71 +161,68 @@ fn write_trace_simd( trace .par_iter_mut() - .zip(inputs.par_iter()) + .enumerate() + .zip(inputs.into_par_iter()) .zip(lookup_data.par_iter_mut()) .zip(sub_components_inputs.par_iter_mut().chunks(N_LANES)) .for_each( - |( - ((row, jump_opcode_is_rel_f_is_imm_f_is_double_deref_f_input), lookup_data), - mut sub_components_inputs, - )| { - let input_tmp_a5f5f_0 = jump_opcode_is_rel_f_is_imm_f_is_double_deref_f_input; - let input_pc_col0 = input_tmp_a5f5f_0.pc; + |((((row_index, row), jump_opcode_input), lookup_data), mut sub_components_inputs)| { + let input_tmp_39ce3_0 = jump_opcode_input; + let input_pc_col0 = input_tmp_39ce3_0.pc; *row[0] = input_pc_col0; - let input_ap_col1 = input_tmp_a5f5f_0.ap; + let input_ap_col1 = input_tmp_39ce3_0.ap; *row[1] = input_ap_col1; - let input_fp_col2 = input_tmp_a5f5f_0.fp; + let input_fp_col2 = input_tmp_39ce3_0.fp; *row[2] = input_fp_col2; // Decode Instruction. - let memory_address_to_id_value_tmp_a5f5f_1 = + let memory_address_to_id_value_tmp_39ce3_1 = memory_address_to_id_state.deduce_output(input_pc_col0); - let memory_id_to_big_value_tmp_a5f5f_2 = - memory_id_to_big_state.deduce_output(memory_address_to_id_value_tmp_a5f5f_1); - let offset2_tmp_a5f5f_3 = - ((((PackedUInt16::from_m31(memory_id_to_big_value_tmp_a5f5f_2.get_m31(3))) + let memory_id_to_big_value_tmp_39ce3_2 = + memory_id_to_big_state.deduce_output(memory_address_to_id_value_tmp_39ce3_1); + let offset2_tmp_39ce3_3 = + ((((PackedUInt16::from_m31(memory_id_to_big_value_tmp_39ce3_2.get_m31(3))) >> (UInt16_5)) + ((PackedUInt16::from_m31( - memory_id_to_big_value_tmp_a5f5f_2.get_m31(4), + memory_id_to_big_value_tmp_39ce3_2.get_m31(4), )) << (UInt16_4))) + (((PackedUInt16::from_m31( - memory_id_to_big_value_tmp_a5f5f_2.get_m31(5), + memory_id_to_big_value_tmp_39ce3_2.get_m31(5), )) & (UInt16_7)) << (UInt16_13))); - let offset2_col3 = offset2_tmp_a5f5f_3.as_m31(); + let offset2_col3 = offset2_tmp_39ce3_3.as_m31(); *row[3] = offset2_col3; - let op1_base_fp_tmp_a5f5f_4 = - (((((PackedUInt16::from_m31(memory_id_to_big_value_tmp_a5f5f_2.get_m31(5))) + let op1_base_fp_tmp_39ce3_4 = + (((((PackedUInt16::from_m31(memory_id_to_big_value_tmp_39ce3_2.get_m31(5))) >> (UInt16_3)) + ((PackedUInt16::from_m31( - memory_id_to_big_value_tmp_a5f5f_2.get_m31(6), + memory_id_to_big_value_tmp_39ce3_2.get_m31(6), )) << (UInt16_6))) >> (UInt16_3)) & (UInt16_1)); - let op1_base_fp_col4 = op1_base_fp_tmp_a5f5f_4.as_m31(); + let op1_base_fp_col4 = op1_base_fp_tmp_39ce3_4.as_m31(); *row[4] = op1_base_fp_col4; - let op1_base_ap_tmp_a5f5f_5 = - (((((PackedUInt16::from_m31(memory_id_to_big_value_tmp_a5f5f_2.get_m31(5))) + let op1_base_ap_tmp_39ce3_5 = + (((((PackedUInt16::from_m31(memory_id_to_big_value_tmp_39ce3_2.get_m31(5))) >> (UInt16_3)) + ((PackedUInt16::from_m31( - memory_id_to_big_value_tmp_a5f5f_2.get_m31(6), + memory_id_to_big_value_tmp_39ce3_2.get_m31(6), )) << (UInt16_6))) >> (UInt16_4)) & (UInt16_1)); - let op1_base_ap_col5 = op1_base_ap_tmp_a5f5f_5.as_m31(); + let op1_base_ap_col5 = op1_base_ap_tmp_39ce3_5.as_m31(); *row[5] = op1_base_ap_col5; - let ap_update_add_1_tmp_a5f5f_6 = - (((((PackedUInt16::from_m31(memory_id_to_big_value_tmp_a5f5f_2.get_m31(5))) + let ap_update_add_1_tmp_39ce3_6 = + (((((PackedUInt16::from_m31(memory_id_to_big_value_tmp_39ce3_2.get_m31(5))) >> (UInt16_3)) + ((PackedUInt16::from_m31( - memory_id_to_big_value_tmp_a5f5f_2.get_m31(6), + memory_id_to_big_value_tmp_39ce3_2.get_m31(6), )) << (UInt16_6))) >> (UInt16_11)) & (UInt16_1)); - let ap_update_add_1_col6 = ap_update_add_1_tmp_a5f5f_6.as_m31(); + let ap_update_add_1_col6 = ap_update_add_1_tmp_39ce3_6.as_m31(); *row[6] = ap_update_add_1_col6; - for (i, &input) in ( input_pc_col0, [M31_32767, M31_32767, offset2_col3], @@ -275,11 +278,11 @@ fn write_trace_simd( // Read Positive Num Bits 27. - let memory_address_to_id_value_tmp_a5f5f_7 = memory_address_to_id_state + let memory_address_to_id_value_tmp_39ce3_7 = memory_address_to_id_state .deduce_output(((mem1_base_col7) + ((offset2_col3) - (M31_32768)))); - let memory_id_to_big_value_tmp_a5f5f_8 = - memory_id_to_big_state.deduce_output(memory_address_to_id_value_tmp_a5f5f_7); - let next_pc_id_col8 = memory_address_to_id_value_tmp_a5f5f_7; + let memory_id_to_big_value_tmp_39ce3_8 = + memory_id_to_big_state.deduce_output(memory_address_to_id_value_tmp_39ce3_7); + let next_pc_id_col8 = memory_address_to_id_value_tmp_39ce3_7; *row[8] = next_pc_id_col8; for (i, &input) in ((mem1_base_col7) + ((offset2_col3) - (M31_32768))) .unpack() @@ -292,11 +295,11 @@ fn write_trace_simd( ((mem1_base_col7) + ((offset2_col3) - (M31_32768))), next_pc_id_col8, ]; - let next_pc_limb_0_col9 = memory_id_to_big_value_tmp_a5f5f_8.get_m31(0); + let next_pc_limb_0_col9 = memory_id_to_big_value_tmp_39ce3_8.get_m31(0); *row[9] = next_pc_limb_0_col9; - let next_pc_limb_1_col10 = memory_id_to_big_value_tmp_a5f5f_8.get_m31(1); + let next_pc_limb_1_col10 = memory_id_to_big_value_tmp_39ce3_8.get_m31(1); *row[10] = next_pc_limb_1_col10; - let next_pc_limb_2_col11 = memory_id_to_big_value_tmp_a5f5f_8.get_m31(2); + let next_pc_limb_2_col11 = memory_id_to_big_value_tmp_39ce3_8.get_m31(2); *row[11] = next_pc_limb_2_col11; for (i, &input) in next_pc_id_col8.unpack().iter().enumerate() { *sub_components_inputs[i].memory_id_to_big_inputs[0] = input; diff --git a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_f_is_imm_f_is_double_deref_t/component.rs b/stwo_cairo_prover/crates/prover/src/components/jump_opcode_double_deref/component.rs similarity index 98% rename from stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_f_is_imm_f_is_double_deref_t/component.rs rename to stwo_cairo_prover/crates/prover/src/components/jump_opcode_double_deref/component.rs index 8781eaf2..3ecbdd8a 100644 --- a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_f_is_imm_f_is_double_deref_t/component.rs +++ b/stwo_cairo_prover/crates/prover/src/components/jump_opcode_double_deref/component.rs @@ -4,6 +4,7 @@ use num_traits::{One, Zero}; use serde::{Deserialize, Serialize}; use stwo_cairo_serialize::CairoSerialize; use stwo_prover::constraint_framework::logup::{LogupAtRow, LogupSums, LookupElements}; +use stwo_prover::constraint_framework::preprocessed_columns::PreprocessedColumn; use stwo_prover::constraint_framework::{ EvalAtRow, FrameworkComponent, FrameworkEval, RelationEntry, }; diff --git a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_f_is_imm_f_is_double_deref_t/mod.rs b/stwo_cairo_prover/crates/prover/src/components/jump_opcode_double_deref/mod.rs similarity index 100% rename from stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_f_is_imm_f_is_double_deref_t/mod.rs rename to stwo_cairo_prover/crates/prover/src/components/jump_opcode_double_deref/mod.rs diff --git a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_f_is_imm_f_is_double_deref_t/prover.rs b/stwo_cairo_prover/crates/prover/src/components/jump_opcode_double_deref/prover.rs similarity index 88% rename from stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_f_is_imm_f_is_double_deref_t/prover.rs rename to stwo_cairo_prover/crates/prover/src/components/jump_opcode_double_deref/prover.rs index 1a606546..42177c4c 100644 --- a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_f_is_imm_f_is_double_deref_t/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/jump_opcode_double_deref/prover.rs @@ -7,10 +7,13 @@ use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; use prover_types::simd::*; -use rayon::iter::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator}; +use rayon::iter::{ + IndexedParallelIterator, IntoParallelIterator, IntoParallelRefIterator, ParallelIterator, +}; use stwo_air_utils::trace::component_trace::ComponentTrace; use stwo_air_utils_derive::{IterMut, ParIterMut, Uninitialized}; use stwo_prover::constraint_framework::logup::LogupTraceGenerator; +use stwo_prover::constraint_framework::preprocessed_columns::PreprocessedColumn; use stwo_prover::constraint_framework::Relation; use stwo_prover::core::air::Component; use stwo_prover::core::backend::simd::column::BaseColumn; @@ -21,6 +24,7 @@ use stwo_prover::core::backend::simd::SimdBackend; use stwo_prover::core::backend::{BackendForChannel, Col, Column}; use stwo_prover::core::channel::{Channel, MerkleChannel}; use stwo_prover::core::fields::m31::M31; +use stwo_prover::core::fields::FieldExpOps; use stwo_prover::core::pcs::TreeBuilder; use stwo_prover::core::poly::circle::{CanonicCoset, CircleEvaluation}; use stwo_prover::core::poly::BitReversedOrder; @@ -65,6 +69,7 @@ impl ClaimGenerator { let packed_inputs = pack_values(&self.inputs); let (trace, mut sub_components_inputs, lookup_data) = write_trace_simd( + n_rows, packed_inputs, memory_address_to_id_state, memory_id_to_big_state, @@ -103,8 +108,8 @@ impl ClaimGenerator { ) } - pub fn add_inputs(&mut self, inputs: &[InputType]) { - self.inputs.extend(inputs); + pub fn add_inputs(&self, _inputs: &[InputType]) { + unimplemented!("Implement manually"); } } @@ -120,6 +125,7 @@ pub struct SubComponentInputs { #[allow(clippy::double_parens)] #[allow(non_snake_case)] fn write_trace_simd( + n_rows: usize, inputs: Vec, memory_address_to_id_state: &memory_address_to_id::ClaimGenerator, memory_id_to_big_state: &memory_id_to_big::ClaimGenerator, @@ -157,73 +163,73 @@ fn write_trace_simd( trace .par_iter_mut() - .zip(inputs.par_iter()) + .enumerate() + .zip(inputs.into_par_iter()) .zip(lookup_data.par_iter_mut()) .zip(sub_components_inputs.par_iter_mut().chunks(N_LANES)) .for_each( |( - ((row, jump_opcode_is_rel_f_is_imm_f_is_double_deref_t_input), lookup_data), + (((row_index, row), jump_opcode_double_deref_input), lookup_data), mut sub_components_inputs, )| { - let input_tmp_36541_0 = jump_opcode_is_rel_f_is_imm_f_is_double_deref_t_input; - let input_pc_col0 = input_tmp_36541_0.pc; + let input_tmp_2757b_0 = jump_opcode_double_deref_input; + let input_pc_col0 = input_tmp_2757b_0.pc; *row[0] = input_pc_col0; - let input_ap_col1 = input_tmp_36541_0.ap; + let input_ap_col1 = input_tmp_2757b_0.ap; *row[1] = input_ap_col1; - let input_fp_col2 = input_tmp_36541_0.fp; + let input_fp_col2 = input_tmp_2757b_0.fp; *row[2] = input_fp_col2; // Decode Instruction. - let memory_address_to_id_value_tmp_36541_1 = + let memory_address_to_id_value_tmp_2757b_1 = memory_address_to_id_state.deduce_output(input_pc_col0); - let memory_id_to_big_value_tmp_36541_2 = - memory_id_to_big_state.deduce_output(memory_address_to_id_value_tmp_36541_1); - let offset1_tmp_36541_3 = - ((((PackedUInt16::from_m31(memory_id_to_big_value_tmp_36541_2.get_m31(1))) + let memory_id_to_big_value_tmp_2757b_2 = + memory_id_to_big_state.deduce_output(memory_address_to_id_value_tmp_2757b_1); + let offset1_tmp_2757b_3 = + ((((PackedUInt16::from_m31(memory_id_to_big_value_tmp_2757b_2.get_m31(1))) >> (UInt16_7)) + ((PackedUInt16::from_m31( - memory_id_to_big_value_tmp_36541_2.get_m31(2), + memory_id_to_big_value_tmp_2757b_2.get_m31(2), )) << (UInt16_2))) + (((PackedUInt16::from_m31( - memory_id_to_big_value_tmp_36541_2.get_m31(3), + memory_id_to_big_value_tmp_2757b_2.get_m31(3), )) & (UInt16_31)) << (UInt16_11))); - let offset1_col3 = offset1_tmp_36541_3.as_m31(); + let offset1_col3 = offset1_tmp_2757b_3.as_m31(); *row[3] = offset1_col3; - let offset2_tmp_36541_4 = - ((((PackedUInt16::from_m31(memory_id_to_big_value_tmp_36541_2.get_m31(3))) + let offset2_tmp_2757b_4 = + ((((PackedUInt16::from_m31(memory_id_to_big_value_tmp_2757b_2.get_m31(3))) >> (UInt16_5)) + ((PackedUInt16::from_m31( - memory_id_to_big_value_tmp_36541_2.get_m31(4), + memory_id_to_big_value_tmp_2757b_2.get_m31(4), )) << (UInt16_4))) + (((PackedUInt16::from_m31( - memory_id_to_big_value_tmp_36541_2.get_m31(5), + memory_id_to_big_value_tmp_2757b_2.get_m31(5), )) & (UInt16_7)) << (UInt16_13))); - let offset2_col4 = offset2_tmp_36541_4.as_m31(); + let offset2_col4 = offset2_tmp_2757b_4.as_m31(); *row[4] = offset2_col4; - let op0_base_fp_tmp_36541_5 = - (((((PackedUInt16::from_m31(memory_id_to_big_value_tmp_36541_2.get_m31(5))) + let op0_base_fp_tmp_2757b_5 = + (((((PackedUInt16::from_m31(memory_id_to_big_value_tmp_2757b_2.get_m31(5))) >> (UInt16_3)) + ((PackedUInt16::from_m31( - memory_id_to_big_value_tmp_36541_2.get_m31(6), + memory_id_to_big_value_tmp_2757b_2.get_m31(6), )) << (UInt16_6))) >> (UInt16_1)) & (UInt16_1)); - let op0_base_fp_col5 = op0_base_fp_tmp_36541_5.as_m31(); + let op0_base_fp_col5 = op0_base_fp_tmp_2757b_5.as_m31(); *row[5] = op0_base_fp_col5; - let ap_update_add_1_tmp_36541_6 = - (((((PackedUInt16::from_m31(memory_id_to_big_value_tmp_36541_2.get_m31(5))) + let ap_update_add_1_tmp_2757b_6 = + (((((PackedUInt16::from_m31(memory_id_to_big_value_tmp_2757b_2.get_m31(5))) >> (UInt16_3)) + ((PackedUInt16::from_m31( - memory_id_to_big_value_tmp_36541_2.get_m31(6), + memory_id_to_big_value_tmp_2757b_2.get_m31(6), )) << (UInt16_6))) >> (UInt16_11)) & (UInt16_1)); - let ap_update_add_1_col6 = ap_update_add_1_tmp_36541_6.as_m31(); + let ap_update_add_1_col6 = ap_update_add_1_tmp_2757b_6.as_m31(); *row[6] = ap_update_add_1_col6; - for (i, &input) in ( input_pc_col0, [M31_32767, offset1_col3, offset2_col4], @@ -279,11 +285,11 @@ fn write_trace_simd( // Read Positive Num Bits 27. - let memory_address_to_id_value_tmp_36541_7 = memory_address_to_id_state + let memory_address_to_id_value_tmp_2757b_7 = memory_address_to_id_state .deduce_output(((mem0_base_col7) + ((offset1_col3) - (M31_32768)))); - let memory_id_to_big_value_tmp_36541_8 = - memory_id_to_big_state.deduce_output(memory_address_to_id_value_tmp_36541_7); - let mem1_base_id_col8 = memory_address_to_id_value_tmp_36541_7; + let memory_id_to_big_value_tmp_2757b_8 = + memory_id_to_big_state.deduce_output(memory_address_to_id_value_tmp_2757b_7); + let mem1_base_id_col8 = memory_address_to_id_value_tmp_2757b_7; *row[8] = mem1_base_id_col8; for (i, &input) in ((mem0_base_col7) + ((offset1_col3) - (M31_32768))) .unpack() @@ -296,11 +302,11 @@ fn write_trace_simd( ((mem0_base_col7) + ((offset1_col3) - (M31_32768))), mem1_base_id_col8, ]; - let mem1_base_limb_0_col9 = memory_id_to_big_value_tmp_36541_8.get_m31(0); + let mem1_base_limb_0_col9 = memory_id_to_big_value_tmp_2757b_8.get_m31(0); *row[9] = mem1_base_limb_0_col9; - let mem1_base_limb_1_col10 = memory_id_to_big_value_tmp_36541_8.get_m31(1); + let mem1_base_limb_1_col10 = memory_id_to_big_value_tmp_2757b_8.get_m31(1); *row[10] = mem1_base_limb_1_col10; - let mem1_base_limb_2_col11 = memory_id_to_big_value_tmp_36541_8.get_m31(2); + let mem1_base_limb_2_col11 = memory_id_to_big_value_tmp_2757b_8.get_m31(2); *row[11] = mem1_base_limb_2_col11; for (i, &input) in mem1_base_id_col8.unpack().iter().enumerate() { *sub_components_inputs[i].memory_id_to_big_inputs[0] = input; @@ -339,15 +345,15 @@ fn write_trace_simd( // Read Positive Num Bits 27. - let memory_address_to_id_value_tmp_36541_9 = memory_address_to_id_state + let memory_address_to_id_value_tmp_2757b_9 = memory_address_to_id_state .deduce_output( ((((mem1_base_limb_0_col9) + ((mem1_base_limb_1_col10) * (M31_512))) + ((mem1_base_limb_2_col11) * (M31_262144))) + ((offset2_col4) - (M31_32768))), ); - let memory_id_to_big_value_tmp_36541_10 = - memory_id_to_big_state.deduce_output(memory_address_to_id_value_tmp_36541_9); - let next_pc_id_col12 = memory_address_to_id_value_tmp_36541_9; + let memory_id_to_big_value_tmp_2757b_10 = + memory_id_to_big_state.deduce_output(memory_address_to_id_value_tmp_2757b_9); + let next_pc_id_col12 = memory_address_to_id_value_tmp_2757b_9; *row[12] = next_pc_id_col12; for (i, &input) in ((((mem1_base_limb_0_col9) + ((mem1_base_limb_1_col10) * (M31_512))) @@ -365,11 +371,11 @@ fn write_trace_simd( + ((offset2_col4) - (M31_32768))), next_pc_id_col12, ]; - let next_pc_limb_0_col13 = memory_id_to_big_value_tmp_36541_10.get_m31(0); + let next_pc_limb_0_col13 = memory_id_to_big_value_tmp_2757b_10.get_m31(0); *row[13] = next_pc_limb_0_col13; - let next_pc_limb_1_col14 = memory_id_to_big_value_tmp_36541_10.get_m31(1); + let next_pc_limb_1_col14 = memory_id_to_big_value_tmp_2757b_10.get_m31(1); *row[14] = next_pc_limb_1_col14; - let next_pc_limb_2_col15 = memory_id_to_big_value_tmp_36541_10.get_m31(2); + let next_pc_limb_2_col15 = memory_id_to_big_value_tmp_2757b_10.get_m31(2); *row[15] = next_pc_limb_2_col15; for (i, &input) in next_pc_id_col12.unpack().iter().enumerate() { *sub_components_inputs[i].memory_id_to_big_inputs[1] = input; diff --git a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_t_is_imm_f_is_double_deref_f/component.rs b/stwo_cairo_prover/crates/prover/src/components/jump_opcode_rel/component.rs similarity index 99% rename from stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_t_is_imm_f_is_double_deref_f/component.rs rename to stwo_cairo_prover/crates/prover/src/components/jump_opcode_rel/component.rs index dcd7f224..143ba3dc 100644 --- a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_t_is_imm_f_is_double_deref_f/component.rs +++ b/stwo_cairo_prover/crates/prover/src/components/jump_opcode_rel/component.rs @@ -4,6 +4,7 @@ use num_traits::{One, Zero}; use serde::{Deserialize, Serialize}; use stwo_cairo_serialize::CairoSerialize; use stwo_prover::constraint_framework::logup::{LogupAtRow, LogupSums, LookupElements}; +use stwo_prover::constraint_framework::preprocessed_columns::PreprocessedColumn; use stwo_prover::constraint_framework::{ EvalAtRow, FrameworkComponent, FrameworkEval, RelationEntry, }; diff --git a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_t_is_imm_f_is_double_deref_f/mod.rs b/stwo_cairo_prover/crates/prover/src/components/jump_opcode_rel/mod.rs similarity index 100% rename from stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_t_is_imm_f_is_double_deref_f/mod.rs rename to stwo_cairo_prover/crates/prover/src/components/jump_opcode_rel/mod.rs diff --git a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_t_is_imm_f_is_double_deref_f/prover.rs b/stwo_cairo_prover/crates/prover/src/components/jump_opcode_rel/prover.rs similarity index 87% rename from stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_t_is_imm_f_is_double_deref_f/prover.rs rename to stwo_cairo_prover/crates/prover/src/components/jump_opcode_rel/prover.rs index 3acfcbb7..fac596ae 100644 --- a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_t_is_imm_f_is_double_deref_f/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/jump_opcode_rel/prover.rs @@ -7,10 +7,13 @@ use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; use prover_types::simd::*; -use rayon::iter::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator}; +use rayon::iter::{ + IndexedParallelIterator, IntoParallelIterator, IntoParallelRefIterator, ParallelIterator, +}; use stwo_air_utils::trace::component_trace::ComponentTrace; use stwo_air_utils_derive::{IterMut, ParIterMut, Uninitialized}; use stwo_prover::constraint_framework::logup::LogupTraceGenerator; +use stwo_prover::constraint_framework::preprocessed_columns::PreprocessedColumn; use stwo_prover::constraint_framework::Relation; use stwo_prover::core::air::Component; use stwo_prover::core::backend::simd::column::BaseColumn; @@ -21,6 +24,7 @@ use stwo_prover::core::backend::simd::SimdBackend; use stwo_prover::core::backend::{BackendForChannel, Col, Column}; use stwo_prover::core::channel::{Channel, MerkleChannel}; use stwo_prover::core::fields::m31::M31; +use stwo_prover::core::fields::FieldExpOps; use stwo_prover::core::pcs::TreeBuilder; use stwo_prover::core::poly::circle::{CanonicCoset, CircleEvaluation}; use stwo_prover::core::poly::BitReversedOrder; @@ -65,6 +69,7 @@ impl ClaimGenerator { let packed_inputs = pack_values(&self.inputs); let (trace, mut sub_components_inputs, lookup_data) = write_trace_simd( + n_rows, packed_inputs, memory_address_to_id_state, memory_id_to_big_state, @@ -103,8 +108,8 @@ impl ClaimGenerator { ) } - pub fn add_inputs(&mut self, inputs: &[InputType]) { - self.inputs.extend(inputs); + pub fn add_inputs(&self, _inputs: &[InputType]) { + unimplemented!("Implement manually"); } } @@ -120,6 +125,7 @@ pub struct SubComponentInputs { #[allow(clippy::double_parens)] #[allow(non_snake_case)] fn write_trace_simd( + n_rows: usize, inputs: Vec, memory_address_to_id_state: &memory_address_to_id::ClaimGenerator, memory_id_to_big_state: &memory_id_to_big::ClaimGenerator, @@ -159,71 +165,71 @@ fn write_trace_simd( trace .par_iter_mut() - .zip(inputs.par_iter()) + .enumerate() + .zip(inputs.into_par_iter()) .zip(lookup_data.par_iter_mut()) .zip(sub_components_inputs.par_iter_mut().chunks(N_LANES)) .for_each( |( - ((row, jump_opcode_is_rel_t_is_imm_f_is_double_deref_f_input), lookup_data), + (((row_index, row), jump_opcode_rel_input), lookup_data), mut sub_components_inputs, )| { - let input_tmp_1409c_0 = jump_opcode_is_rel_t_is_imm_f_is_double_deref_f_input; - let input_pc_col0 = input_tmp_1409c_0.pc; + let input_tmp_c32b8_0 = jump_opcode_rel_input; + let input_pc_col0 = input_tmp_c32b8_0.pc; *row[0] = input_pc_col0; - let input_ap_col1 = input_tmp_1409c_0.ap; + let input_ap_col1 = input_tmp_c32b8_0.ap; *row[1] = input_ap_col1; - let input_fp_col2 = input_tmp_1409c_0.fp; + let input_fp_col2 = input_tmp_c32b8_0.fp; *row[2] = input_fp_col2; // Decode Instruction. - let memory_address_to_id_value_tmp_1409c_1 = + let memory_address_to_id_value_tmp_c32b8_1 = memory_address_to_id_state.deduce_output(input_pc_col0); - let memory_id_to_big_value_tmp_1409c_2 = - memory_id_to_big_state.deduce_output(memory_address_to_id_value_tmp_1409c_1); - let offset2_tmp_1409c_3 = - ((((PackedUInt16::from_m31(memory_id_to_big_value_tmp_1409c_2.get_m31(3))) + let memory_id_to_big_value_tmp_c32b8_2 = + memory_id_to_big_state.deduce_output(memory_address_to_id_value_tmp_c32b8_1); + let offset2_tmp_c32b8_3 = + ((((PackedUInt16::from_m31(memory_id_to_big_value_tmp_c32b8_2.get_m31(3))) >> (UInt16_5)) + ((PackedUInt16::from_m31( - memory_id_to_big_value_tmp_1409c_2.get_m31(4), + memory_id_to_big_value_tmp_c32b8_2.get_m31(4), )) << (UInt16_4))) + (((PackedUInt16::from_m31( - memory_id_to_big_value_tmp_1409c_2.get_m31(5), + memory_id_to_big_value_tmp_c32b8_2.get_m31(5), )) & (UInt16_7)) << (UInt16_13))); - let offset2_col3 = offset2_tmp_1409c_3.as_m31(); + let offset2_col3 = offset2_tmp_c32b8_3.as_m31(); *row[3] = offset2_col3; - let op1_base_fp_tmp_1409c_4 = - (((((PackedUInt16::from_m31(memory_id_to_big_value_tmp_1409c_2.get_m31(5))) + let op1_base_fp_tmp_c32b8_4 = + (((((PackedUInt16::from_m31(memory_id_to_big_value_tmp_c32b8_2.get_m31(5))) >> (UInt16_3)) + ((PackedUInt16::from_m31( - memory_id_to_big_value_tmp_1409c_2.get_m31(6), + memory_id_to_big_value_tmp_c32b8_2.get_m31(6), )) << (UInt16_6))) >> (UInt16_3)) & (UInt16_1)); - let op1_base_fp_col4 = op1_base_fp_tmp_1409c_4.as_m31(); + let op1_base_fp_col4 = op1_base_fp_tmp_c32b8_4.as_m31(); *row[4] = op1_base_fp_col4; - let op1_base_ap_tmp_1409c_5 = - (((((PackedUInt16::from_m31(memory_id_to_big_value_tmp_1409c_2.get_m31(5))) + let op1_base_ap_tmp_c32b8_5 = + (((((PackedUInt16::from_m31(memory_id_to_big_value_tmp_c32b8_2.get_m31(5))) >> (UInt16_3)) + ((PackedUInt16::from_m31( - memory_id_to_big_value_tmp_1409c_2.get_m31(6), + memory_id_to_big_value_tmp_c32b8_2.get_m31(6), )) << (UInt16_6))) >> (UInt16_4)) & (UInt16_1)); - let op1_base_ap_col5 = op1_base_ap_tmp_1409c_5.as_m31(); + let op1_base_ap_col5 = op1_base_ap_tmp_c32b8_5.as_m31(); *row[5] = op1_base_ap_col5; - let ap_update_add_1_tmp_1409c_6 = - (((((PackedUInt16::from_m31(memory_id_to_big_value_tmp_1409c_2.get_m31(5))) + let ap_update_add_1_tmp_c32b8_6 = + (((((PackedUInt16::from_m31(memory_id_to_big_value_tmp_c32b8_2.get_m31(5))) >> (UInt16_3)) + ((PackedUInt16::from_m31( - memory_id_to_big_value_tmp_1409c_2.get_m31(6), + memory_id_to_big_value_tmp_c32b8_2.get_m31(6), )) << (UInt16_6))) >> (UInt16_11)) & (UInt16_1)); - let ap_update_add_1_col6 = ap_update_add_1_tmp_1409c_6.as_m31(); + let ap_update_add_1_col6 = ap_update_add_1_tmp_c32b8_6.as_m31(); *row[6] = ap_update_add_1_col6; - for (i, &input) in ( input_pc_col0, [M31_32767, M31_32767, offset2_col3], @@ -279,11 +285,11 @@ fn write_trace_simd( // Read Small. - let memory_address_to_id_value_tmp_1409c_7 = memory_address_to_id_state + let memory_address_to_id_value_tmp_c32b8_7 = memory_address_to_id_state .deduce_output(((mem1_base_col7) + ((offset2_col3) - (M31_32768)))); - let memory_id_to_big_value_tmp_1409c_8 = - memory_id_to_big_state.deduce_output(memory_address_to_id_value_tmp_1409c_7); - let next_pc_id_col8 = memory_address_to_id_value_tmp_1409c_7; + let memory_id_to_big_value_tmp_c32b8_8 = + memory_id_to_big_state.deduce_output(memory_address_to_id_value_tmp_c32b8_7); + let next_pc_id_col8 = memory_address_to_id_value_tmp_c32b8_7; *row[8] = next_pc_id_col8; for (i, &input) in ((mem1_base_col7) + ((offset2_col3) - (M31_32768))) .unpack() @@ -299,19 +305,19 @@ fn write_trace_simd( // Cond Decode Small Sign. - let msb_tmp_1409c_9 = memory_id_to_big_value_tmp_1409c_8.get_m31(27).eq(M31_256); - let msb_col9 = msb_tmp_1409c_9.as_m31(); + let msb_tmp_c32b8_9 = memory_id_to_big_value_tmp_c32b8_8.get_m31(27).eq(M31_256); + let msb_col9 = msb_tmp_c32b8_9.as_m31(); *row[9] = msb_col9; - let mid_limbs_set_tmp_1409c_10 = - memory_id_to_big_value_tmp_1409c_8.get_m31(20).eq(M31_511); - let mid_limbs_set_col10 = mid_limbs_set_tmp_1409c_10.as_m31(); + let mid_limbs_set_tmp_c32b8_10 = + memory_id_to_big_value_tmp_c32b8_8.get_m31(20).eq(M31_511); + let mid_limbs_set_col10 = mid_limbs_set_tmp_c32b8_10.as_m31(); *row[10] = mid_limbs_set_col10; - let next_pc_limb_0_col11 = memory_id_to_big_value_tmp_1409c_8.get_m31(0); + let next_pc_limb_0_col11 = memory_id_to_big_value_tmp_c32b8_8.get_m31(0); *row[11] = next_pc_limb_0_col11; - let next_pc_limb_1_col12 = memory_id_to_big_value_tmp_1409c_8.get_m31(1); + let next_pc_limb_1_col12 = memory_id_to_big_value_tmp_c32b8_8.get_m31(1); *row[12] = next_pc_limb_1_col12; - let next_pc_limb_2_col13 = memory_id_to_big_value_tmp_1409c_8.get_m31(2); + let next_pc_limb_2_col13 = memory_id_to_big_value_tmp_c32b8_8.get_m31(2); *row[13] = next_pc_limb_2_col13; for (i, &input) in next_pc_id_col8.unpack().iter().enumerate() { *sub_components_inputs[i].memory_id_to_big_inputs[0] = input; diff --git a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_t_is_imm_t_is_double_deref_f/component.rs b/stwo_cairo_prover/crates/prover/src/components/jump_opcode_rel_imm/component.rs similarity index 98% rename from stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_t_is_imm_t_is_double_deref_f/component.rs rename to stwo_cairo_prover/crates/prover/src/components/jump_opcode_rel_imm/component.rs index 09885f51..c230e8a5 100644 --- a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_t_is_imm_t_is_double_deref_f/component.rs +++ b/stwo_cairo_prover/crates/prover/src/components/jump_opcode_rel_imm/component.rs @@ -4,6 +4,7 @@ use num_traits::{One, Zero}; use serde::{Deserialize, Serialize}; use stwo_cairo_serialize::CairoSerialize; use stwo_prover::constraint_framework::logup::{LogupAtRow, LogupSums, LookupElements}; +use stwo_prover::constraint_framework::preprocessed_columns::PreprocessedColumn; use stwo_prover::constraint_framework::{ EvalAtRow, FrameworkComponent, FrameworkEval, RelationEntry, }; diff --git a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_t_is_imm_t_is_double_deref_f/mod.rs b/stwo_cairo_prover/crates/prover/src/components/jump_opcode_rel_imm/mod.rs similarity index 100% rename from stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_t_is_imm_t_is_double_deref_f/mod.rs rename to stwo_cairo_prover/crates/prover/src/components/jump_opcode_rel_imm/mod.rs diff --git a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_t_is_imm_t_is_double_deref_f/prover.rs b/stwo_cairo_prover/crates/prover/src/components/jump_opcode_rel_imm/prover.rs similarity index 89% rename from stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_t_is_imm_t_is_double_deref_f/prover.rs rename to stwo_cairo_prover/crates/prover/src/components/jump_opcode_rel_imm/prover.rs index f8f53b84..24746dce 100644 --- a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_t_is_imm_t_is_double_deref_f/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/jump_opcode_rel_imm/prover.rs @@ -7,10 +7,13 @@ use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; use prover_types::simd::*; -use rayon::iter::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator}; +use rayon::iter::{ + IndexedParallelIterator, IntoParallelIterator, IntoParallelRefIterator, ParallelIterator, +}; use stwo_air_utils::trace::component_trace::ComponentTrace; use stwo_air_utils_derive::{IterMut, ParIterMut, Uninitialized}; use stwo_prover::constraint_framework::logup::LogupTraceGenerator; +use stwo_prover::constraint_framework::preprocessed_columns::PreprocessedColumn; use stwo_prover::constraint_framework::Relation; use stwo_prover::core::air::Component; use stwo_prover::core::backend::simd::column::BaseColumn; @@ -21,6 +24,7 @@ use stwo_prover::core::backend::simd::SimdBackend; use stwo_prover::core::backend::{BackendForChannel, Col, Column}; use stwo_prover::core::channel::{Channel, MerkleChannel}; use stwo_prover::core::fields::m31::M31; +use stwo_prover::core::fields::FieldExpOps; use stwo_prover::core::pcs::TreeBuilder; use stwo_prover::core::poly::circle::{CanonicCoset, CircleEvaluation}; use stwo_prover::core::poly::BitReversedOrder; @@ -65,6 +69,7 @@ impl ClaimGenerator { let packed_inputs = pack_values(&self.inputs); let (trace, mut sub_components_inputs, lookup_data) = write_trace_simd( + n_rows, packed_inputs, memory_address_to_id_state, memory_id_to_big_state, @@ -103,8 +108,8 @@ impl ClaimGenerator { ) } - pub fn add_inputs(&mut self, inputs: &[InputType]) { - self.inputs.extend(inputs); + pub fn add_inputs(&self, _inputs: &[InputType]) { + unimplemented!("Implement manually"); } } @@ -120,6 +125,7 @@ pub struct SubComponentInputs { #[allow(clippy::double_parens)] #[allow(non_snake_case)] fn write_trace_simd( + n_rows: usize, inputs: Vec, memory_address_to_id_state: &memory_address_to_id::ClaimGenerator, memory_id_to_big_state: &memory_id_to_big::ClaimGenerator, @@ -155,39 +161,39 @@ fn write_trace_simd( trace .par_iter_mut() - .zip(inputs.par_iter()) + .enumerate() + .zip(inputs.into_par_iter()) .zip(lookup_data.par_iter_mut()) .zip(sub_components_inputs.par_iter_mut().chunks(N_LANES)) .for_each( |( - ((row, jump_opcode_is_rel_t_is_imm_t_is_double_deref_f_input), lookup_data), + (((row_index, row), jump_opcode_rel_imm_input), lookup_data), mut sub_components_inputs, )| { - let input_tmp_ad2c6_0 = jump_opcode_is_rel_t_is_imm_t_is_double_deref_f_input; - let input_pc_col0 = input_tmp_ad2c6_0.pc; + let input_tmp_ff4f6_0 = jump_opcode_rel_imm_input; + let input_pc_col0 = input_tmp_ff4f6_0.pc; *row[0] = input_pc_col0; - let input_ap_col1 = input_tmp_ad2c6_0.ap; + let input_ap_col1 = input_tmp_ff4f6_0.ap; *row[1] = input_ap_col1; - let input_fp_col2 = input_tmp_ad2c6_0.fp; + let input_fp_col2 = input_tmp_ff4f6_0.fp; *row[2] = input_fp_col2; // Decode Instruction. - let memory_address_to_id_value_tmp_ad2c6_1 = + let memory_address_to_id_value_tmp_ff4f6_1 = memory_address_to_id_state.deduce_output(input_pc_col0); - let memory_id_to_big_value_tmp_ad2c6_2 = - memory_id_to_big_state.deduce_output(memory_address_to_id_value_tmp_ad2c6_1); - let ap_update_add_1_tmp_ad2c6_3 = - (((((PackedUInt16::from_m31(memory_id_to_big_value_tmp_ad2c6_2.get_m31(5))) + let memory_id_to_big_value_tmp_ff4f6_2 = + memory_id_to_big_state.deduce_output(memory_address_to_id_value_tmp_ff4f6_1); + let ap_update_add_1_tmp_ff4f6_3 = + (((((PackedUInt16::from_m31(memory_id_to_big_value_tmp_ff4f6_2.get_m31(5))) >> (UInt16_3)) + ((PackedUInt16::from_m31( - memory_id_to_big_value_tmp_ad2c6_2.get_m31(6), + memory_id_to_big_value_tmp_ff4f6_2.get_m31(6), )) << (UInt16_6))) >> (UInt16_11)) & (UInt16_1)); - let ap_update_add_1_col3 = ap_update_add_1_tmp_ad2c6_3.as_m31(); + let ap_update_add_1_col3 = ap_update_add_1_tmp_ff4f6_3.as_m31(); *row[3] = ap_update_add_1_col3; - for (i, &input) in ( input_pc_col0, [M31_32767, M31_32767, M31_32769], @@ -239,11 +245,11 @@ fn write_trace_simd( // Read Small. - let memory_address_to_id_value_tmp_ad2c6_4 = + let memory_address_to_id_value_tmp_ff4f6_4 = memory_address_to_id_state.deduce_output(((input_pc_col0) + (M31_1))); - let memory_id_to_big_value_tmp_ad2c6_5 = - memory_id_to_big_state.deduce_output(memory_address_to_id_value_tmp_ad2c6_4); - let next_pc_id_col4 = memory_address_to_id_value_tmp_ad2c6_4; + let memory_id_to_big_value_tmp_ff4f6_5 = + memory_id_to_big_state.deduce_output(memory_address_to_id_value_tmp_ff4f6_4); + let next_pc_id_col4 = memory_address_to_id_value_tmp_ff4f6_4; *row[4] = next_pc_id_col4; for (i, &input) in ((input_pc_col0) + (M31_1)).unpack().iter().enumerate() { *sub_components_inputs[i].memory_address_to_id_inputs[0] = input; @@ -253,19 +259,19 @@ fn write_trace_simd( // Cond Decode Small Sign. - let msb_tmp_ad2c6_6 = memory_id_to_big_value_tmp_ad2c6_5.get_m31(27).eq(M31_256); - let msb_col5 = msb_tmp_ad2c6_6.as_m31(); + let msb_tmp_ff4f6_6 = memory_id_to_big_value_tmp_ff4f6_5.get_m31(27).eq(M31_256); + let msb_col5 = msb_tmp_ff4f6_6.as_m31(); *row[5] = msb_col5; - let mid_limbs_set_tmp_ad2c6_7 = - memory_id_to_big_value_tmp_ad2c6_5.get_m31(20).eq(M31_511); - let mid_limbs_set_col6 = mid_limbs_set_tmp_ad2c6_7.as_m31(); + let mid_limbs_set_tmp_ff4f6_7 = + memory_id_to_big_value_tmp_ff4f6_5.get_m31(20).eq(M31_511); + let mid_limbs_set_col6 = mid_limbs_set_tmp_ff4f6_7.as_m31(); *row[6] = mid_limbs_set_col6; - let next_pc_limb_0_col7 = memory_id_to_big_value_tmp_ad2c6_5.get_m31(0); + let next_pc_limb_0_col7 = memory_id_to_big_value_tmp_ff4f6_5.get_m31(0); *row[7] = next_pc_limb_0_col7; - let next_pc_limb_1_col8 = memory_id_to_big_value_tmp_ad2c6_5.get_m31(1); + let next_pc_limb_1_col8 = memory_id_to_big_value_tmp_ff4f6_5.get_m31(1); *row[8] = next_pc_limb_1_col8; - let next_pc_limb_2_col9 = memory_id_to_big_value_tmp_ad2c6_5.get_m31(2); + let next_pc_limb_2_col9 = memory_id_to_big_value_tmp_ff4f6_5.get_m31(2); *row[9] = next_pc_limb_2_col9; for (i, &input) in next_pc_id_col4.unpack().iter().enumerate() { *sub_components_inputs[i].memory_id_to_big_inputs[0] = input; diff --git a/stwo_cairo_prover/crates/prover/src/components/mod.rs b/stwo_cairo_prover/crates/prover/src/components/mod.rs index cbe55e4b..df2b3caf 100644 --- a/stwo_cairo_prover/crates/prover/src/components/mod.rs +++ b/stwo_cairo_prover/crates/prover/src/components/mod.rs @@ -24,10 +24,10 @@ pub mod jnz_opcode_is_taken_f_dst_base_fp_f; pub mod jnz_opcode_is_taken_f_dst_base_fp_t; pub mod jnz_opcode_is_taken_t_dst_base_fp_f; pub mod jnz_opcode_is_taken_t_dst_base_fp_t; -pub mod jump_opcode_is_rel_f_is_imm_f_is_double_deref_f; -pub mod jump_opcode_is_rel_f_is_imm_f_is_double_deref_t; -pub mod jump_opcode_is_rel_t_is_imm_f_is_double_deref_f; -pub mod jump_opcode_is_rel_t_is_imm_t_is_double_deref_f; +pub mod jump_opcode; +pub mod jump_opcode_double_deref; +pub mod jump_opcode_rel; +pub mod jump_opcode_rel_imm; pub mod memory; pub mod range_check_vector; pub mod ret_opcode; diff --git a/stwo_cairo_prover/crates/prover/src/components/ret_opcode/component.rs b/stwo_cairo_prover/crates/prover/src/components/ret_opcode/component.rs index 402da96b..10287ccb 100644 --- a/stwo_cairo_prover/crates/prover/src/components/ret_opcode/component.rs +++ b/stwo_cairo_prover/crates/prover/src/components/ret_opcode/component.rs @@ -4,6 +4,7 @@ use num_traits::{One, Zero}; use serde::{Deserialize, Serialize}; use stwo_cairo_serialize::CairoSerialize; use stwo_prover::constraint_framework::logup::{LogupAtRow, LogupSums, LookupElements}; +use stwo_prover::constraint_framework::preprocessed_columns::PreprocessedColumn; use stwo_prover::constraint_framework::{ EvalAtRow, FrameworkComponent, FrameworkEval, RelationEntry, }; diff --git a/stwo_cairo_prover/crates/prover/src/components/ret_opcode/prover.rs b/stwo_cairo_prover/crates/prover/src/components/ret_opcode/prover.rs index b7c24a00..45f0926a 100644 --- a/stwo_cairo_prover/crates/prover/src/components/ret_opcode/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/ret_opcode/prover.rs @@ -7,10 +7,13 @@ use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; use prover_types::simd::*; -use rayon::iter::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator}; +use rayon::iter::{ + IndexedParallelIterator, IntoParallelIterator, IntoParallelRefIterator, ParallelIterator, +}; use stwo_air_utils::trace::component_trace::ComponentTrace; use stwo_air_utils_derive::{IterMut, ParIterMut, Uninitialized}; use stwo_prover::constraint_framework::logup::LogupTraceGenerator; +use stwo_prover::constraint_framework::preprocessed_columns::PreprocessedColumn; use stwo_prover::constraint_framework::Relation; use stwo_prover::core::air::Component; use stwo_prover::core::backend::simd::column::BaseColumn; @@ -21,6 +24,7 @@ use stwo_prover::core::backend::simd::SimdBackend; use stwo_prover::core::backend::{BackendForChannel, Col, Column}; use stwo_prover::core::channel::{Channel, MerkleChannel}; use stwo_prover::core::fields::m31::M31; +use stwo_prover::core::fields::FieldExpOps; use stwo_prover::core::pcs::TreeBuilder; use stwo_prover::core::poly::circle::{CanonicCoset, CircleEvaluation}; use stwo_prover::core::poly::BitReversedOrder; @@ -65,6 +69,7 @@ impl ClaimGenerator { let packed_inputs = pack_values(&self.inputs); let (trace, mut sub_components_inputs, lookup_data) = write_trace_simd( + n_rows, packed_inputs, memory_address_to_id_state, memory_id_to_big_state, @@ -103,8 +108,8 @@ impl ClaimGenerator { ) } - pub fn add_inputs(&mut self, inputs: &[InputType]) { - self.inputs.extend(inputs); + pub fn add_inputs(&self, _inputs: &[InputType]) { + unimplemented!("Implement manually"); } } @@ -120,6 +125,7 @@ pub struct SubComponentInputs { #[allow(clippy::double_parens)] #[allow(non_snake_case)] fn write_trace_simd( + n_rows: usize, inputs: Vec, memory_address_to_id_state: &memory_address_to_id::ClaimGenerator, memory_id_to_big_state: &memory_id_to_big::ClaimGenerator, @@ -148,11 +154,12 @@ fn write_trace_simd( trace .par_iter_mut() - .zip(inputs.par_iter()) + .enumerate() + .zip(inputs.into_par_iter()) .zip(lookup_data.par_iter_mut()) .zip(sub_components_inputs.par_iter_mut().chunks(N_LANES)) .for_each( - |(((row, ret_opcode_input), lookup_data), mut sub_components_inputs)| { + |((((row_index, row), ret_opcode_input), lookup_data), mut sub_components_inputs)| { let input_tmp_e23a5_0 = ret_opcode_input; let input_pc_col0 = input_tmp_e23a5_0.pc; *row[0] = input_pc_col0; @@ -167,7 +174,6 @@ fn write_trace_simd( memory_address_to_id_state.deduce_output(input_pc_col0); let memory_id_to_big_value_tmp_e23a5_2 = memory_id_to_big_state.deduce_output(memory_address_to_id_value_tmp_e23a5_1); - for (i, &input) in ( input_pc_col0, [M31_32766, M31_32767, M31_32767], diff --git a/stwo_cairo_prover/crates/prover/src/input/state_transitions.rs b/stwo_cairo_prover/crates/prover/src/input/state_transitions.rs index d1590c0e..23e2376c 100644 --- a/stwo_cairo_prover/crates/prover/src/input/state_transitions.rs +++ b/stwo_cairo_prover/crates/prover/src/input/state_transitions.rs @@ -40,10 +40,10 @@ pub struct CasmStatesByOpcode { pub jnz_opcode_is_taken_f_dst_base_fp_f: Vec, pub jnz_opcode_is_taken_t_dst_base_fp_f: Vec, pub jnz_opcode_is_taken_f_dst_base_fp_t: Vec, - pub jump_opcode_is_rel_t_is_imm_t_is_double_deref_f: Vec, - pub jump_opcode_is_rel_t_is_imm_f_is_double_deref_f: Vec, - pub jump_opcode_is_rel_f_is_imm_f_is_double_deref_t: Vec, - pub jump_opcode_is_rel_f_is_imm_f_is_double_deref_f: Vec, + pub jump_opcode_rel_imm: Vec, + pub jump_opcode_rel: Vec, + pub jump_opcode_double_deref: Vec, + pub jump_opcode: Vec, pub mul_opcode_is_small_t_is_imm_t: Vec, pub mul_opcode_is_small_t_is_imm_f: Vec, pub mul_opcode_is_small_f_is_imm_f: Vec, @@ -123,22 +123,13 @@ impl CasmStatesByOpcode { "jnz_opcode_is_taken_f_dst_base_fp_t", self.jnz_opcode_is_taken_f_dst_base_fp_t.len(), ), + ("jump_opcode_rel_imm", self.jump_opcode_rel_imm.len()), + ("jump_opcode_rel", self.jump_opcode_rel.len()), ( - "jump_opcode_is_rel_t_is_imm_t_is_double_deref_f", - self.jump_opcode_is_rel_t_is_imm_t_is_double_deref_f.len(), - ), - ( - "jump_opcode_is_rel_t_is_imm_f_is_double_deref_f", - self.jump_opcode_is_rel_t_is_imm_f_is_double_deref_f.len(), - ), - ( - "jump_opcode_is_rel_f_is_imm_f_is_double_deref_t", - self.jump_opcode_is_rel_f_is_imm_f_is_double_deref_t.len(), - ), - ( - "jump_opcode_is_rel_f_is_imm_f_is_double_deref_f", - self.jump_opcode_is_rel_f_is_imm_f_is_double_deref_f.len(), + "jump_opcode_double_deref", + self.jump_opcode_double_deref.len(), ), + ("jump_opcode", self.jump_opcode.len()), ( "mul_opcode_is_small_t_is_imm_t", self.mul_opcode_is_small_t_is_imm_t.len(), @@ -335,9 +326,7 @@ impl StateTransitions { && offset1 == -1 && offset2 == 1 ); - self.casm_states_by_opcode - .jump_opcode_is_rel_t_is_imm_t_is_double_deref_f - .push(state); + self.casm_states_by_opcode.jump_opcode_rel_imm.push(state); } else if pc_update_jump_rel { // jump rel [ap/fp + offset2]. assert!( @@ -346,14 +335,12 @@ impl StateTransitions { && op0_base_fp && offset1 == -1 ); - self.casm_states_by_opcode - .jump_opcode_is_rel_t_is_imm_f_is_double_deref_f - .push(state); + self.casm_states_by_opcode.jump_opcode_rel.push(state); } else if !op_1_base_fp && !op_1_base_ap { // jump abs [[ap/fp + offset1] + offset2]. assert!(pc_update_jump); self.casm_states_by_opcode - .jump_opcode_is_rel_f_is_imm_f_is_double_deref_t + .jump_opcode_double_deref .push(state); } else { // jump abs [ap/fp + offset2]. @@ -363,9 +350,7 @@ impl StateTransitions { && pc_update_jump && offset1 == -1 ); - self.casm_states_by_opcode - .jump_opcode_is_rel_f_is_imm_f_is_double_deref_f - .push(state); + self.casm_states_by_opcode.jump_opcode.push(state); } } @@ -708,12 +693,7 @@ mod mappings_tests { let input = input_from_plain_casm(instructions, false); let casm_states_by_opcode = input.state_transitions.casm_states_by_opcode; - assert_eq!( - casm_states_by_opcode - .jump_opcode_is_rel_f_is_imm_f_is_double_deref_f - .len(), - 1 - ); + assert_eq!(casm_states_by_opcode.jump_opcode.len(), 1); assert_eq!( casm_states_by_opcode .call_opcode_is_rel_t_op_1_base_fp_f @@ -736,12 +716,7 @@ mod mappings_tests { let input = input_from_plain_casm(instructions, false); let casm_states_by_opcode = input.state_transitions.casm_states_by_opcode; - assert_eq!( - casm_states_by_opcode - .jump_opcode_is_rel_t_is_imm_t_is_double_deref_f - .len(), - 1 - ); + assert_eq!(casm_states_by_opcode.jump_opcode_rel_imm.len(), 1); } #[test] diff --git a/stwo_cairo_prover/crates/prover/src/input/vm_import/mod.rs b/stwo_cairo_prover/crates/prover/src/input/vm_import/mod.rs index f98842f3..d0a02c1e 100644 --- a/stwo_cairo_prover/crates/prover/src/input/vm_import/mod.rs +++ b/stwo_cairo_prover/crates/prover/src/input/vm_import/mod.rs @@ -224,30 +224,10 @@ pub mod tests { assert_eq!(components.jnz_opcode_is_taken_f_dst_base_fp_f.len(), 27032); assert_eq!(components.jnz_opcode_is_taken_t_dst_base_fp_f.len(), 51060); assert_eq!(components.jnz_opcode_is_taken_f_dst_base_fp_t.len(), 5100); - assert_eq!( - components - .jump_opcode_is_rel_t_is_imm_t_is_double_deref_f - .len(), - 31873865 - ); - assert_eq!( - components - .jump_opcode_is_rel_t_is_imm_f_is_double_deref_f - .len(), - 500 - ); - assert_eq!( - components - .jump_opcode_is_rel_f_is_imm_f_is_double_deref_t - .len(), - 32 - ); - assert_eq!( - components - .jump_opcode_is_rel_f_is_imm_f_is_double_deref_f - .len(), - 0 - ); + assert_eq!(components.jump_opcode_rel_imm.len(), 31873865); + assert_eq!(components.jump_opcode_rel.len(), 500); + assert_eq!(components.jump_opcode_double_deref.len(), 32); + assert_eq!(components.jump_opcode.len(), 0); assert_eq!(components.mul_opcode_is_small_t_is_imm_t.len(), 7234); assert_eq!(components.mul_opcode_is_small_t_is_imm_f.len(), 7203); assert_eq!(components.mul_opcode_is_small_f_is_imm_f.len(), 3943); @@ -308,30 +288,10 @@ pub mod tests { assert_eq!(components.jnz_opcode_is_taken_f_dst_base_fp_f.len(), 0); assert_eq!(components.jnz_opcode_is_taken_t_dst_base_fp_f.len(), 0); assert_eq!(components.jnz_opcode_is_taken_f_dst_base_fp_t.len(), 11); - assert_eq!( - components - .jump_opcode_is_rel_t_is_imm_t_is_double_deref_f - .len(), - 124626 - ); - assert_eq!( - components - .jump_opcode_is_rel_t_is_imm_f_is_double_deref_f - .len(), - 0 - ); - assert_eq!( - components - .jump_opcode_is_rel_f_is_imm_f_is_double_deref_t - .len(), - 0 - ); - assert_eq!( - components - .jump_opcode_is_rel_f_is_imm_f_is_double_deref_f - .len(), - 0 - ); + assert_eq!(components.jump_opcode_rel_imm.len(), 124626); + assert_eq!(components.jump_opcode_rel.len(), 0); + assert_eq!(components.jump_opcode_double_deref.len(), 0); + assert_eq!(components.jump_opcode.len(), 0); assert_eq!(components.mul_opcode_is_small_t_is_imm_t.len(), 0); assert_eq!(components.mul_opcode_is_small_t_is_imm_f.len(), 0); assert_eq!(components.mul_opcode_is_small_f_is_imm_f.len(), 0);