From 07e3e260612117304ad183f95d8d9a6a77f7e018 Mon Sep 17 00:00:00 2001 From: Shahar Samocha Date: Mon, 7 Oct 2024 20:59:22 +0300 Subject: [PATCH] Print component information --- .../src/constraint_framework/component.rs | 31 +++++++++++++++++++ crates/prover/src/examples/poseidon/mod.rs | 3 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/crates/prover/src/constraint_framework/component.rs b/crates/prover/src/constraint_framework/component.rs index c7d1e3669..c82ca4a76 100644 --- a/crates/prover/src/constraint_framework/component.rs +++ b/crates/prover/src/constraint_framework/component.rs @@ -1,4 +1,5 @@ use std::borrow::Cow; +use std::fmt::{self, Display, Formatter}; use std::iter::zip; use std::ops::Deref; @@ -264,3 +265,33 @@ impl Deref for FrameworkComponent { &self.eval } } + +impl Display for FrameworkComponent { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + let log_n_rows = self.log_size(); + let mut n_cols = vec![]; + self.trace_log_degree_bounds() + .0 + .iter() + .for_each(|interaction| { + n_cols.push(interaction.len()); + }); + writeln!(f, "n_rows 2^{}", log_n_rows)?; + writeln!(f, "n_constraints {}", self.n_constraints())?; + writeln!( + f, + "constraint_log_degree_bound {}", + self.max_constraint_log_degree_bound() + )?; + writeln!(f, "total felts: 2^{} * {}", log_n_rows, n_cols.iter().sum::())?; + for (j, n_cols) in n_cols.into_iter().enumerate() { + writeln!( + f, + "\t Interaction {}: n_cols {}", + j, + n_cols + )?; + } + Ok(()) + } +} diff --git a/crates/prover/src/examples/poseidon/mod.rs b/crates/prover/src/examples/poseidon/mod.rs index 0cbc3ebbd..80a6c6516 100644 --- a/crates/prover/src/examples/poseidon/mod.rs +++ b/crates/prover/src/examples/poseidon/mod.rs @@ -3,7 +3,7 @@ use std::ops::{Add, AddAssign, Mul, Sub}; use itertools::Itertools; -use tracing::{span, Level}; +use tracing::{info, span, Level}; use crate::constraint_framework::constant_columns::gen_is_first; use crate::constraint_framework::logup::{LogupAtRow, LogupTraceGenerator, LookupElements}; @@ -386,6 +386,7 @@ pub fn prove_poseidon( total_sum, }, ); + info!("Poseidon component info:\n{}", component); let proof = prove(&[&component], channel, commitment_scheme).unwrap(); (component, proof)