Skip to content

Commit

Permalink
Merge pull request #50 from scroll-tech/mockprover_fork
Browse files Browse the repository at this point in the history
fix/boundary handling of the fork() function
  • Loading branch information
kunxian-xia authored Jul 6, 2023
2 parents aab39d5 + b2f596a commit 103ce21
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 7 deletions.
18 changes: 15 additions & 3 deletions halo2_proofs/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,21 @@ impl<'a, F: Field + Group> Assignment<F> for MockProver<'a, F> {
for (i, sub_range) in ranges.iter().enumerate() {
if sub_range.start < range_start {
// TODO: use more precise error type
log::error!(
"subCS_{} sub_range.start: {} < range_start{}",
i,
sub_range.start,
range_start
);
return Err(Error::Synthesis);
}
if i == ranges.len() - 1 && sub_range.end >= self.rw_rows.end {
if i == ranges.len() - 1 && sub_range.end > self.rw_rows.end {
log::error!(
"subCS_{} sub_range.end: {} > self.rw_rows.end{}",
i,
sub_range.end,
self.rw_rows.end
);
return Err(Error::Synthesis);
}
range_start = sub_range.end;
Expand Down Expand Up @@ -888,11 +900,11 @@ impl<'a, F: FieldExt> MockProver<'a, F> {
}

pub fn advice_values(&self, column: Column<Advice>) -> &[CellValue<F>] {
&self.advice[column.index()]
self.advice[column.index()]
}

pub fn fixed_values(&self, column: Column<Fixed>) -> &[CellValue<F>] {
&self.fixed[column.index()]
self.fixed[column.index()]
}

/// Returns `Ok(())` if this `MockProver` is satisfied, or a list of errors indicating
Expand Down
4 changes: 2 additions & 2 deletions halo2_proofs/src/plonk/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,12 +568,12 @@ pub trait Assignment<F: Field>: Sized + Send {
AR: Into<String>;

/// Fork
fn fork(&mut self, ranges: &[Range<usize>]) -> Result<Vec<Self>, Error> {
fn fork(&mut self, _ranges: &[Range<usize>]) -> Result<Vec<Self>, Error> {
unimplemented!("fork is not implemented by default")
}

/// Merge
fn merge(&mut self, sub_cs: Vec<Self>) -> Result<(), Error> {
fn merge(&mut self, _sub_cs: Vec<Self>) -> Result<(), Error> {
unimplemented!("merge is not implemented by default")
}

Expand Down
16 changes: 15 additions & 1 deletion halo2_proofs/src/plonk/keygen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ impl<'a, F: Field> Assignment<F> for Assembly<'a, F> {
}

if !self.rw_rows.contains(&row) {
log::error!("enable_selector: {:?}, row: {}", selector, row);
return Err(Error::Synthesis);
}

Expand All @@ -100,9 +101,21 @@ impl<'a, F: Field> Assignment<F> for Assembly<'a, F> {
for (i, sub_range) in ranges.iter().enumerate() {
if sub_range.start < range_start {
// TODO: use more precise error type
log::error!(
"subCS_{} sub_range.start: {} < range_start{}",
i,
sub_range.start,
range_start
);
return Err(Error::Synthesis);
}
if i == ranges.len() - 1 && sub_range.end >= self.rw_rows.end {
if i == ranges.len() - 1 && sub_range.end > self.rw_rows.end {
log::error!(
"subCS_{} sub_range.end: {} > self.rw_rows.end{}",
i,
sub_range.end,
self.rw_rows.end
);
return Err(Error::Synthesis);
}
range_start = sub_range.end;
Expand Down Expand Up @@ -217,6 +230,7 @@ impl<'a, F: Field> Assignment<F> for Assembly<'a, F> {
}

if !self.rw_rows.contains(&row) {
log::error!("assign_fixed: {:?}, row: {}", column, row);
return Err(Error::Synthesis);
}

Expand Down
15 changes: 14 additions & 1 deletion halo2_proofs/src/plonk/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,21 @@ pub fn create_proof<
let mut range_start = self.rw_rows.start;
for (i, sub_range) in ranges.iter().enumerate() {
if sub_range.start < range_start {
log::error!(
"subCS_{} sub_range.start: {} < range_start{}",
i,
sub_range.start,
range_start
);
return Err(Error::Synthesis);
}
if i == ranges.len() - 1 && sub_range.end >= self.rw_rows.end {
if i == ranges.len() - 1 && sub_range.end > self.rw_rows.end {
log::error!(
"subCS_{} sub_range.end: {} > self.rw_rows.end{}",
i,
sub_range.end,
self.rw_rows.end
);
return Err(Error::Synthesis);
}
range_start = sub_range.end;
Expand Down Expand Up @@ -273,6 +285,7 @@ pub fn create_proof<
}

if !self.rw_rows.contains(&row) {
log::error!("assign_advice: {:?}, row: {}", column, row);
return Err(Error::Synthesis);
}

Expand Down

0 comments on commit 103ce21

Please sign in to comment.