Skip to content

Commit

Permalink
SingleChipLayouter: panic if assign_region is called more than on…
Browse files Browse the repository at this point in the history
…ce (#20)

SingleChipLayouter: panic if `assign_region` is called more than once
  • Loading branch information
therealyingtong authored Nov 2, 2023
1 parent ed85bf4 commit 6c5f7d9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions halo2_proofs/src/circuit/floor_planner/single_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ pub struct SingleChipLayouter<'a, F: Field, CS: Assignment<F> + 'a> {
// Stores the starting row for each region.
// Edit: modify to just one region with RegionStart(0)
// regions: Vec<RegionStart>,
// `assign_region` must only be called once.
region_assigned: bool,
/// Stores the first empty row for each column.
columns: FxHashMap<RegionColumn, usize>,
/// Stores the table fixed columns.
Expand All @@ -67,6 +69,7 @@ impl<'a, F: Field, CS: Assignment<F>> SingleChipLayouter<'a, F, CS> {
cs,
constants,
// regions: vec![],
region_assigned: false,
columns: FxHashMap::default(),
table_columns: vec![],
_marker: PhantomData,
Expand All @@ -86,6 +89,10 @@ impl<'a, F: Field, CS: Assignment<F> + 'a + SyncDeps> Layouter<F>
N: Fn() -> NR,
NR: Into<String>,
{
assert!(
!self.region_assigned,
"Only a single region can be assigned per layouter."
);
/*
let region_index = self.regions.len();
Expand Down Expand Up @@ -148,6 +155,8 @@ impl<'a, F: Field, CS: Assignment<F> + 'a + SyncDeps> Layouter<F>
}
}

self.region_assigned = true;

Ok(result)
}

Expand Down

0 comments on commit 6c5f7d9

Please sign in to comment.