Skip to content

Commit

Permalink
logs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-camuto committed Sep 24, 2023
1 parent 57f216d commit e9fa613
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 3 deletions.
2 changes: 2 additions & 0 deletions halo2_proofs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ tracing = "0.1"
blake2b_simd = "1"
sha3 = "0.9.1"
rand_chacha = "0.3"
lazy_static = { version = "1", optional = true }

# Developer tooling dependencies
plotters = { version = "0.3.0", optional = true }
Expand All @@ -82,6 +83,7 @@ thread-safe-region = []
sanity-checks = []
batch = ["rand_core/getrandom"]
circuit-params = []
counter = ["lazy_static"]

[lib]
bench = false
Expand Down
19 changes: 19 additions & 0 deletions halo2_proofs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@
#![allow(unused_imports)]
#![allow(clippy::derive_partial_eq_without_eq)]

#[cfg(feature = "counter")]
#[macro_use]
extern crate lazy_static;

#[cfg(feature = "counter")]
use lazy_static::lazy_static;

#[cfg(feature = "counter")]
use std::sync::Mutex;

#[cfg(feature = "counter")]
use std::collections::BTreeMap;

#[cfg(feature = "counter")]
lazy_static! {
static ref FFT_COUNTER: Mutex<BTreeMap<usize, usize>> = Mutex::new(BTreeMap::new());
static ref MSM_COUNTER: Mutex<BTreeMap<usize, usize>> = Mutex::new(BTreeMap::new());
}

pub mod arithmetic;
pub mod circuit;
pub use halo2curves;
Expand Down
6 changes: 3 additions & 3 deletions halo2_proofs/src/plonk/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1784,19 +1784,19 @@ impl<F: Field> ConstraintSystem<F> {
})
.max()
.unwrap();
log::trace!("max_single_lookup_degree: {}", max_gate_degree);
log::debug!("max single lookup degree: {}", max_gate_degree);

let required_degree = std::cmp::max(max_gate_degree, max_single_lookup_degree);
let required_degree = (required_degree as u64 - 1).next_power_of_two() as usize;

log::trace!("required_degree: {}", required_degree);
log::trace!("required degree: {}", required_degree);

self.set_minimum_degree(required_degree + 1);

// safe to unwrap here
let minimum_degree = self.minimum_degree.unwrap();

log::trace!("minimum_degree: {}", minimum_degree);
log::trace!("minimum degree: {}", minimum_degree);

let mut lookups: Vec<_> = vec![];
for v in self.lookups_map.values() {
Expand Down
22 changes: 22 additions & 0 deletions halo2_proofs/src/plonk/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ pub fn create_proof<
where
Scheme::Scalar: WithSmallOrderMulGroup<3> + FromUniformBytes<64>,
{
#[cfg(feature = "counter")]
{
use crate::{FFT_COUNTER, MSM_COUNTER};
use std::collections::BTreeMap;

// reset counters at the beginning of the prove
*MSM_COUNTER.lock().unwrap() = BTreeMap::new();
*FFT_COUNTER.lock().unwrap() = BTreeMap::new();
}

for instance in instances.iter() {
if instance.len() != pk.vk.cs.num_instance_columns {
return Err(Error::InvalidInstances);
Expand Down Expand Up @@ -695,6 +705,18 @@ where
// We query the h(X) polynomial at x
.chain(vanishing.open(x));

#[cfg(feature = "counter")]
{
use crate::{FFT_COUNTER, MSM_COUNTER};
use std::collections::BTreeMap;
log::debug!("MSM_COUNTER: {:?}", MSM_COUNTER.lock().unwrap());
log::debug!("FFT_COUNTER: {:?}", *FFT_COUNTER.lock().unwrap());

// reset counters at the end of the proving
*MSM_COUNTER.lock().unwrap() = BTreeMap::new();
*FFT_COUNTER.lock().unwrap() = BTreeMap::new();
}

let prover = P::new(params);
prover
.create_proof(rng, transcript, instances)
Expand Down

0 comments on commit e9fa613

Please sign in to comment.