Skip to content

Commit

Permalink
resolve merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
kunxian-xia committed Dec 27, 2023
1 parent b97c7f0 commit 1abe85f
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 27 deletions.
2 changes: 1 addition & 1 deletion halo2_proofs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ rand_core = { version = "0.6", default-features = false, features = ["getrandom"
getrandom = { version = "0.2", features = ["js"] }

[features]
default = ["batch", "gwc", "logup_skip_inv"]
default = ["batch", "gwc", "multicore", "parallel_syn", "logup_skip_inv"]
multicore = ["maybe-rayon/threads"]
dev-graph = ["plotters", "tabbycat"]
test-dev-graph = [
Expand Down
4 changes: 2 additions & 2 deletions halo2_proofs/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1615,7 +1615,7 @@ impl<'a, F: FromUniformBytes<64> + Ord> MockProver<'a, F> {
assert!(table.binary_search(input).is_err());

Some(VerifyFailure::Lookup {
name: lookup.name.clone(),
name: lookup.name.to_string(),
lookup_index,
location: FailureLocation::find_expressions(
&self.cs,
Expand Down Expand Up @@ -2083,7 +2083,7 @@ impl<'a, F: FromUniformBytes<64> + Ord> MockProver<'a, F> {
.filter_map(move |(input, input_row)| {
if table.binary_search(input).is_err() {
Some(VerifyFailure::Lookup {
name: lookup.name.clone(),
name: lookup.name.to_string(),
lookup_index,
location: FailureLocation::find_expressions(
&self.cs,
Expand Down
20 changes: 20 additions & 0 deletions halo2_proofs/src/dev/tfp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,14 @@ impl<'r, F: Field> RegionLayouter<F> for TracingRegion<'r, F> {
) {
}

fn query_advice(&self, column: Column<Advice>, offset: usize) -> Result<F, Error> {
self.0.query_advice(column, offset)
}

fn query_fixed(&self, column: Column<Fixed>, offset: usize) -> Result<F, Error> {
self.0.query_fixed(column, offset)
}

fn assign_advice<'v>(
&'v mut self,
annotation: &'v (dyn Fn() -> String + 'v),
Expand Down Expand Up @@ -365,6 +373,10 @@ impl<'r, F: Field> RegionLayouter<F> for TracingRegion<'r, F> {
debug!(target: "constrain_equal", left = ?left, right = ?right);
self.0.constrain_equal(left, right)
}

fn global_offset(&self, row_offset: usize) -> usize {
self.0.global_offset(row_offset)
}
}

/// A helper type that augments an [`Assignment`] with [`tracing`] spans and events.
Expand Down Expand Up @@ -425,6 +437,14 @@ impl<'cs, F: Field, CS: Assignment<F>> Assignment<F> for TracingAssignment<'cs,
self.cs.enable_selector(|| annotation, selector, row)
}

fn query_advice(&self, column: Column<Advice>, row: usize) -> Result<F, Error> {
self.cs.query_advice(column, row)
}

fn query_fixed(&self, column: Column<Fixed>, row: usize) -> Result<F, Error> {
self.cs.query_fixed(column, row)
}

fn query_instance(&self, column: Column<Instance>, row: usize) -> Result<Value<F>, Error> {
let _guard = debug_span!("positioned").entered();
debug!(target: "query_instance", column = ?column, row = row);
Expand Down
35 changes: 17 additions & 18 deletions halo2_proofs/src/plonk/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,7 @@ impl<F: Field> ConstraintSystem<F> {
pub fn lookup<S: AsRef<str>>(
&mut self,
// FIXME use name in debug messages
_name: &'static str,
_name: S,
table_map: impl FnOnce(&mut VirtualCells<'_, F>) -> Vec<(Expression<F>, TableColumn)>,
) {
let mut cells = VirtualCells::new(self);
Expand Down Expand Up @@ -1894,16 +1894,21 @@ impl<F: Field> ConstraintSystem<F> {
table_map: impl FnOnce(&mut VirtualCells<'_, F>) -> Vec<(Expression<F>, Expression<F>)>,
) {
let mut cells = VirtualCells::new(self);
let table_map = table_map(&mut cells)
.into_iter()
.map(|(mut input, mut table)| {
input.query_cells(&mut cells);
table.query_cells(&mut cells);
(input, table)
})
.collect();
self.lookups
.push(mv_lookup::Argument::new(name.as_ref(), table_map));
let table_map = table_map(&mut cells);

let (input_expressions, table_expressions): (Vec<_>, Vec<_>) =
table_map.into_iter().unzip();
let table_expressions_identifier = table_expressions
.iter()
.fold(String::new(), |string, expr| string + &expr.identifier());

self.lookups_map
.entry(table_expressions_identifier)
.and_modify(|table_tracker| table_tracker.inputs.push(input_expressions.clone()))
.or_insert(LookupTracker {
table: table_expressions,
inputs: vec![input_expressions],
});
}

/// Add a shuffle argument for some input expressions and table expressions.
Expand All @@ -1926,13 +1931,7 @@ impl<F: Field> ConstraintSystem<F> {
self.shuffles
.push(shuffle::Argument::new(name.as_ref(), shuffle_map));

self.lookups_map
.entry(table_expressions_identifier)
.and_modify(|table_tracker| table_tracker.inputs.push(input_expressions.clone()))
.or_insert(LookupTracker {
table: table_expressions,
inputs: vec![input_expressions],
});
index
}

fn query_fixed_index(&mut self, column: Column<Fixed>, at: Rotation) -> usize {
Expand Down
4 changes: 2 additions & 2 deletions halo2_proofs/src/plonk/evaluation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,15 +297,15 @@ impl<C: CurveAffine> Evaluator<C> {
let compressed_input_coset = evaluate_lc(&shuffle.input_expressions, &mut graph_input);
let _ = graph_input.add_calculation(Calculation::Add(
compressed_input_coset,
ValueSource::Gamma(),
ValueSource::Beta(),
));

let mut graph_shuffle = GraphEvaluator::default();
let compressed_shuffle_coset =
evaluate_lc(&shuffle.shuffle_expressions, &mut graph_shuffle);
let _ = graph_shuffle.add_calculation(Calculation::Add(
compressed_shuffle_coset,
ValueSource::Gamma(),
ValueSource::Beta(),
));

ev.shuffles.push(graph_input);
Expand Down
6 changes: 3 additions & 3 deletions halo2_proofs/src/plonk/mv_lookup/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ impl<C: CurveAffine> Evaluated<C> {
expression.evaluate(
&|scalar| scalar,
&|_| panic!("virtual selectors are removed during optimization"),
&|query| fixed_evals[query.index],
&|query| advice_evals[query.index],
&|query| instance_evals[query.index],
&|query| fixed_evals[query.index()],
&|query| advice_evals[query.index()],
&|query| instance_evals[query.index()],
&|challenge| challenges[challenge.index()],
&|a| -a,
&|a, b| a + &b,
Expand Down
1 change: 1 addition & 0 deletions halo2_proofs/src/plonk/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::collections::BTreeSet;
use std::ops::{Range, RangeTo};
use std::sync::Arc;
use std::{collections::HashMap, iter};
use crate::plonk::shuffle;

use super::{
circuit::{
Expand Down
2 changes: 1 addition & 1 deletion halo2_proofs/src/poly/ipa/multiopen/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl<'params, C: CurveAffine> Verifier<'params, IPACommitmentScheme<C>>
let (q_commitment, x_1_power) = &mut q_commitments[set_idx];
match new_commitment {
CommitmentReference::Commitment(c) => {
q_commitments[set_idx].append_term(C::Scalar::ONE, (*c).into());
q_commitment.append_term(C::Scalar::ONE, (*c).into());
}
CommitmentReference::MSM(msm) => {
let mut msm = msm.clone();
Expand Down

0 comments on commit 1abe85f

Please sign in to comment.