From af0ea25fc86aca58fe31172be72dd0f015a08f90 Mon Sep 17 00:00:00 2001 From: wborgeaud Date: Thu, 19 Aug 2021 15:59:05 +0200 Subject: [PATCH] more trials --- src/iop/generator.rs | 30 +++++++++++++++++++----------- src/plonk/prover.rs | 11 +++++++++-- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/iop/generator.rs b/src/iop/generator.rs index 71b9aa3a..90e0f7c4 100644 --- a/src/iop/generator.rs +++ b/src/iop/generator.rs @@ -1,3 +1,4 @@ +use std::collections::HashMap; use std::convert::{identity, TryInto}; use std::fmt::Debug; @@ -198,6 +199,11 @@ pub(crate) fn generate_partial_witness( } }); + let mut parents: HashMap> = HashMap::new(); + for i in 0..witness.0.len() { + parents.entry(witness.0[i].parent).or_default().push(i); + } + // Build a list of "pending" generators which are queued to be run. Initially, all generators // are queued. let mut pending_generator_indices: Vec<_> = (0..generators.len()).collect(); @@ -217,14 +223,20 @@ pub(crate) fn generate_partial_witness( } let finished = generators[generator_idx].run(&witness, &mut buffer); + // dbg!(&generators[generator_idx], &buffer); if finished { generator_is_expired[generator_idx] = true; } // Enqueue unfinished generators that were watching one of the newly populated targets. for &(watch, _) in &buffer.target_values { - for &watching_generator_idx in &generator_indices_by_watches[witness.1(watch)] { - next_pending_generator_indices.push(watching_generator_idx); + let parent = witness.0[witness.1(watch)].parent; + for &yo in &parents[&parent] { + for &watching_generator_idx in &generator_indices_by_watches[yo] { + if !generator_is_expired[watching_generator_idx] { + next_pending_generator_indices.push(watching_generator_idx); + } + } } } @@ -234,17 +246,12 @@ pub(crate) fn generate_partial_witness( pending_generator_indices = next_pending_generator_indices; } - for i in 0..degree { - for j in 0..num_wires { - if !witness.contains(Target::Wire(Wire { gate: i, input: j })) { - println!("{} {}", i, j); - } - } - } // for i in 0..generator_is_expired.len() { // if !generator_is_expired[i] { - // println!("{:?}", generators[i]); - // println!("{:?}", generators[i].watch_list()); + // println!("{}: {:?}", i, generators[i]); + // for a in generators[i].watch_list() { + // println!("{:?} {}", a, witness.contains(a)); + // } // } // } assert!( @@ -266,6 +273,7 @@ pub trait WitnessGenerator: 'static + Send + Sync + Debug { } /// Values generated by a generator invocation. +#[derive(Debug)] pub struct GeneratedValues { pub(crate) target_values: Vec<(Target, F)>, } diff --git a/src/plonk/prover.rs b/src/plonk/prover.rs index 431a3441..558ca290 100644 --- a/src/plonk/prover.rs +++ b/src/plonk/prover.rs @@ -35,8 +35,9 @@ pub(crate) fn prove, const D: usize>( let num_challenges = config.num_challenges; let quotient_degree = common_data.quotient_degree(); let degree = common_data.degree(); - println!("{}", prover_data.gate_instances[0].gate_ref.0.id()); - println!("{}", prover_data.gate_instances[1].gate_ref.0.id()); + // for i in 0..prover_data.gate_instances.len() { + // println!("{}: {}", i, prover_data.gate_instances[i].gate_ref.0.id()); + // } let nrw = config.num_routed_wires; let nw = config.num_wires; @@ -71,6 +72,12 @@ pub(crate) fn prove, const D: usize>( partial_witness[parent].value = Some(v); } }); + // let t = partial_witness[target_index(Target::Wire(Wire { + // gate: 14, + // input: 16, + // }))]; + // dbg!(t); + // dbg!(partial_witness[t.parent]); // let mut partial_witness = inputs; let mut partial_witness = Yo(partial_witness, Box::new(target_index)); timed!(