diff --git a/pil2-components/lib/std/pil/std_connection.pil b/pil2-components/lib/std/pil/std_connection.pil index 9d735a56..bfa8dc5b 100644 --- a/pil2-components/lib/std/pil/std_connection.pil +++ b/pil2-components/lib/std/pil/std_connection.pil @@ -74,7 +74,7 @@ const int DEFAULT_CONNECTION_N = 0; * col witness a,b,c; * connection_init(opid, [a, b, c]); */ -function connection_init(const int opid, const expr cols[], int default_frame_size = DEFAULT_CONNECTION_N, const int bus_type = 0) { +function connection_init(const int opid, const expr cols[], int default_frame_size = DEFAULT_CONNECTION_N, const int bus_type = PIOP_BUS_DEFAULT) { if (default_frame_size == DEFAULT_CONNECTION_N) default_frame_size = N; if (default_frame_size < 1) { @@ -484,20 +484,6 @@ private function checkClosed() { } } -/** - * TODO - * - * @param {int} opid - The (unique) identifier of the connection - * @param {expr[]} cols - Array of columns to be connected - * @param {expr[]} conn - Fixed columns indicating the connection - * @example - * col witness a,b,c; - * col fixed S1,S2,S3; - * // Compute S1, S2, S3... - * connection(opid, [a, b, c], [S1, S2, S3]); - * connection(opid, [a, b, c], [S1, S2, S3], N/2); - */ - /** * Connects the columns `cols` with the fixed columns `CONN`. * @@ -510,7 +496,7 @@ private function checkClosed() { * col fixed S1,S2,S3; * connection(opid, [a, b, c], [S1, S2, S3]); */ -function connection(const int opid, const expr cols[], const expr CONN[], const int bus_type = 0) { +function connection(const int opid, const expr cols[], const expr CONN[], const int bus_type = PIOP_BUS_DEFAULT) { const int len = length(cols); if (len == 0) { error(`Connection #${opid} cannot be empty`); diff --git a/pil2-components/lib/std/rs/src/debug.rs b/pil2-components/lib/std/rs/src/debug.rs index 171eb430..673c1f17 100644 --- a/pil2-components/lib/std/rs/src/debug.rs +++ b/pil2-components/lib/std/rs/src/debug.rs @@ -7,6 +7,7 @@ use std::{ }; use p3_field::PrimeField; +use proofman_common::ProofCtx; use proofman_hints::{format_vec, HintFieldOutput}; pub type DebugData = Mutex>, BusValue>>>; // opid -> val -> BusValue @@ -81,6 +82,7 @@ pub fn update_debug_data( } pub fn print_debug_info( + pctx: &ProofCtx, name: &str, max_values_to_print: usize, print_to_file: bool, @@ -151,7 +153,7 @@ pub fn print_debug_info( } let shared_data = &data.shared_data; let grouped_data = &mut data.grouped_data; - print_diffs(val, max_values_to_print, shared_data, grouped_data, false, &mut output); + print_diffs(pctx, val, max_values_to_print, shared_data, grouped_data, false, &mut output); } if len_overassumed > 0 { @@ -176,7 +178,7 @@ pub fn print_debug_info( let shared_data = &data.shared_data; let grouped_data = &mut data.grouped_data; - print_diffs(val, max_values_to_print, shared_data, grouped_data, true, &mut output); + print_diffs(pctx, val, max_values_to_print, shared_data, grouped_data, true, &mut output); } if len_overproven > 0 { @@ -185,6 +187,7 @@ pub fn print_debug_info( } fn print_diffs( + pctx: &ProofCtx, val: &[HintFieldOutput], max_values_to_print: usize, shared_data: &SharedData, @@ -230,6 +233,9 @@ pub fn print_debug_info( // Print grouped rows for (airgroup_id, air_id, instance_id, mut rows) in organized_rows { + let airgroup_name = pctx.global_info.get_air_group_name(airgroup_id); + let air_name = pctx.global_info.get_air_name(airgroup_id, air_id); + rows.sort(); let rows_display = rows.iter().map(|x| x.to_string()).take(max_values_to_print).collect::>().join(","); @@ -237,8 +243,10 @@ pub fn print_debug_info( let truncated = rows.len() > max_values_to_print; writeln!( output, - "\t Airgroup: {:<3} | Air: {:<3} | Instance: {:<3} | Num: {:<9} | Rows: [{}{}]", + "\t Airgroup: {} ({}) | Air: {} ({}) | Instance ID: {} | Num: {} | Rows: [{}{}]", + airgroup_name, airgroup_id, + air_name, air_id, instance_id, rows.len(), diff --git a/pil2-components/lib/std/rs/src/std_prod.rs b/pil2-components/lib/std/rs/src/std_prod.rs index ccaf548d..5667847c 100644 --- a/pil2-components/lib/std/rs/src/std_prod.rs +++ b/pil2-components/lib/std/rs/src/std_prod.rs @@ -18,6 +18,7 @@ use crate::{ }; pub struct StdProd { + pctx: Arc>, mode: StdMode, stage_wc: Option>, debug_data: Option>, @@ -40,6 +41,7 @@ impl AirComponent for StdProd { // Initialize std_prod with the extracted data let mode = mode.expect("Mode must be provided"); let std_prod = Arc::new(Self { + pctx: wcm.get_pctx(), mode: mode.clone(), stage_wc: match std_prod_users_id.is_empty() { true => None, @@ -324,11 +326,12 @@ impl WitnessComponent for StdProd { fn end_proof(&self) { // Print debug info if in debug mode if self.mode.name == ModeName::Debug { + let pctx = &self.pctx; let name = Self::MY_NAME; let max_values_to_print = self.mode.n_vals; let print_to_file = self.mode.print_to_file; let debug_data = self.debug_data.as_ref().expect("Debug data missing"); - print_debug_info(name, max_values_to_print, print_to_file, debug_data); + print_debug_info(pctx, name, max_values_to_print, print_to_file, debug_data); } } } diff --git a/pil2-components/lib/std/rs/src/std_sum.rs b/pil2-components/lib/std/rs/src/std_sum.rs index 77b4ae8e..211edc81 100644 --- a/pil2-components/lib/std/rs/src/std_sum.rs +++ b/pil2-components/lib/std/rs/src/std_sum.rs @@ -20,6 +20,7 @@ use crate::{ }; pub struct StdSum { + pctx: Arc>, mode: StdMode, stage_wc: Option>, debug_data: Option>, @@ -42,6 +43,7 @@ impl AirComponent for StdSum { // Initialize std_sum with the extracted data let mode = mode.expect("Mode must be provided"); let std_sum = Arc::new(Self { + pctx: wcm.get_pctx(), mode: mode.clone(), stage_wc: match std_sum_users_id.is_empty() { true => None, @@ -366,11 +368,12 @@ impl WitnessComponent for StdSum { fn end_proof(&self) { // Print debug info if in debug mode if self.mode.name == ModeName::Debug { + let pctx = &self.pctx; let name = Self::MY_NAME; let max_values_to_print = self.mode.n_vals; let print_to_file = self.mode.print_to_file; let debug_data = self.debug_data.as_ref().expect("Debug data missing"); - print_debug_info(name, max_values_to_print, print_to_file, debug_data); + print_debug_info(pctx, name, max_values_to_print, print_to_file, debug_data); } } }