Commit Graph

884 Commits

Author SHA1 Message Date
Jack Grigg 5f8a61cb24 MockProver: Switch VerifyFailure::Cell to report offset within region
This is more useful for developers, as the absolute cell row may be
obfuscated by the layouter, whereas the offset within a row is controlled
by the developer.
2021-06-18 17:52:53 +01:00
Jack Grigg 181ade5e29 MockProver: Check cell assignment per-region instead of globally
Current layouters measure the shape of regions by looking at the cells
they assign. If a chip developer forgets to assign a cell in a region,
it is possible for active gates to "stick out" past the edge of a
measured region shape.

`MockProver` checks that all active gates have their cells assigned,
but this was previously checked globally. If a layouter happened to
position the buggy region such that the dangling gate overlapped an
assigned cell in in adjacent region, this check would pass.

In this commit, we extend the check to be per-region. We map enabled
selectors and assigned cells to a specific region, and then if a gate
is active within a region, we require that its cells be assigned within
that same region.

Closes zcash/halo2#297.
2021-06-18 17:51:44 +01:00
Jack Grigg 572d74e1a0 Add an Assigned::invert method 2021-06-12 19:36:37 +01:00
Jack Grigg 1d7060af8a Enable region assignments to defer inversions 2021-06-12 19:36:37 +01:00
Jack Grigg cbd198fc71 Batch invert cell assignments during keygen and proving 2021-06-12 19:34:13 +01:00
Jack Grigg d685c5c5e6 impl operators for Assigned
This enables chips to use this as an intermediate value while computing
witnesses.
2021-06-12 19:34:13 +01:00
Jack Grigg 251bc68c05 Introduce an Assigned struct into the Assignment trait APIs
Value closures can now return a `(numerator, denominator)` tuple, in
order to defer inversions until after assignment.
2021-06-12 19:34:13 +01:00
str4d 236115917d
Merge pull request #290 from zcash/v1-layouter
V1 layouter
2021-06-12 18:14:54 +01:00
str4d eae5049ba2
Merge pull request #291 from zcash/circuitlayout-builder
dev: CircuitLayout builder
2021-06-11 23:50:08 +01:00
ying tong d04b532368
Merge pull request #292 from zcash/expression-square
plonk::circuit.rs: Add Expression::square() method.
2021-06-12 06:49:36 +08:00
therealyingtong c907ca5410 plonk::circuit.rs: Add Expression::square() method.
Co-authored-by: Jack Grigg <jack@electriccoin.co>
2021-06-11 12:31:27 +08:00
Jack Grigg faac7b798b dev: Render Selectors in a darker shade of blue
The regions are now rendered uniformly the same colour, by removing the
background bleed-through (which was more complex now that the fixed
columns are rendered in two colours).
2021-06-10 00:06:20 +01:00
Jack Grigg 49e18b2647 dev: Render labels last (so they are always the top layer) 2021-06-10 00:05:49 +01:00
Jack Grigg 53c43e85b2 Fix clippy lints 2021-06-08 12:40:16 +01:00
Jack Grigg d4984ebf53 dev: Enable CircuitLayout labels to be hidden 2021-06-08 12:26:37 +01:00
Jack Grigg 52be437509 dev: Add CircuitLayout viewport controls 2021-06-08 12:26:37 +01:00
Jack Grigg 3e82c7b232 dev: Move halo2::dev::circuit_layout to halo2::dev::CircuitLayout::render
This makes it easier to add configuration to the renderer.
2021-06-08 12:13:18 +01:00
Jack Grigg 7cca91331b Implement improved strategy for the V1 layouter
This layouter improves on the single-pass strategy in two ways:

- Regions are layed out with a "first fit" strategy (using the algorithm
  described in https://github.com/zcash/halo2/issues/93) instead of a
  "last fit" strategy. This enables gaps in the circuit to be filled.

- Regions are sorted by their "advice area" (columns * rows), and are
  then layed out biggest-first. This takes advantage of the regularity
  of circuits, and that the advice columns have the most contention. It
  also leads to larger gaps between early layed-out regions that are more
  easily filled by subsequent smaller regions.
2021-06-08 11:35:41 +01:00
Jack Grigg a94d4a9c01 Implement V1 layouter
The V1 layouter is a dual-pass layouter, that has visibility into the
entire `Circuit::synthesize` step.

This first commit implements the same strategy as `SingleChipLayouter`,
behaving as if it were a single-pass layouter.
2021-06-07 15:13:41 +01:00
Jack Grigg b00a0df392 Move SingleChipLayouter into a submodule
It is a single-pass layouter, but we won't rename it for now.
2021-06-07 14:52:25 +01:00
str4d d8e4f24df4
Merge pull request #287 from zcash/remove-selector-rotations
Remove rotations from Selectors
2021-06-05 23:36:37 +01:00
str4d 879509491f
Merge pull request #286 from zcash/constraint-annotations
Enable annotating individual constraints within gates
2021-06-05 23:36:28 +01:00
str4d 53ac47fcec
Merge pull request #289 from zcash/ci-book-fix
CI: Build book with latest mdbook
2021-06-05 11:38:02 +01:00
str4d 1dff93a8ad
dev: Update documentation for constraint_name
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-06-04 23:12:55 +01:00
str4d 5bf9390d23
Merge pull request #285 from zcash/dev-gate-constraints
dev: MockProver fixes and improvements
2021-06-04 23:11:49 +01:00
Jack Grigg a388726ce9 CI: Build book with latest mdbook
`mdbook-katex` is installed from crates.io, and if it doesn't use the
same version of `mdbook` it can cause build issues.
2021-06-04 22:41:25 +01:00
Jack Grigg 0d8b3bab38 Remove rotations from Selectors
Enabling selectors to be used in gates at non-zero rotations leads to
confusing gates, and inhibits our ability to create visualizations of
circuits. In most cases, a gate can be rearranged so that the selectors
have no rotation; in cases where cross-gate selector optimisations are
required, these can still be implemented using fixed columns.
2021-06-04 16:18:51 +01:00
Jack Grigg 483c872cbe dev: Clarify gate name documentation 2021-06-04 15:18:52 +01:00
Jack Grigg 876587c818 Panic in ConstraintSystem::create_gate if it would contain no constraints
We use iterators to allow a gate to contain more than one constraint, but
it is a programming error for a gate to not contain any constraints.
2021-06-04 12:59:57 +01:00
Jack Grigg 6cf73391e8 Enable annotating individual constraints within gates
The closure passed to `ConstraintSystem::create_gate` can now return:

- Tuples of `(&'static str, Expression<F>)`
- Anything implementing `IntoIterator` (e.g. `Some(Expression<F>)`)
2021-06-04 03:49:21 +01:00
Jack Grigg ff2a500e9a dev: impl fmt::Display for VerifyFailure 2021-06-04 03:46:08 +01:00
Jack Grigg 47061ade3d dev: Report indices of unsatisfied constraints
Now that gates may contain multiple constraints, we need to inform
developers about which specific constraints are failing within gates.
2021-06-04 03:46:08 +01:00
Jack Grigg e01fb15018 dev: Fix bug in cell assignment checker
The simple example was broken because it uses an instance column in a
gate. MockProver now assumes all instance cells are assigned to, since
this happens outside the circuit and outside its purview.
2021-06-04 02:56:35 +01:00
str4d 32cdcfa66f
Merge pull request #284 from zcash/doc-batch-invert-zero
Document that batch inversion in arithmetic.rs leaves zero as zero
2021-06-04 01:15:50 +01:00
Daira Hopwood e426fddd5e
Update arithmetic.rs 2021-06-04 00:17:05 +01:00
ebfull 3ff44d31a8
Merge pull request #283 from zcash/pasta-curves-0.1
`pasta_curves 0.1`
2021-06-01 17:18:09 -06:00
Jack Grigg c86b24f496 pasta_curves 0.1 2021-06-02 00:03:50 +01:00
Jack Grigg 8b94e3ad64 Bump MSRV to 1.51.0 2021-06-02 00:03:06 +01:00
str4d 0448584333
Merge pull request #278 from zcash/144-proof-encoding
book: Document encoding of proofs
2021-06-01 17:26:47 +01:00
Jack Grigg 7379e96a70 book: Use M for number-of-circuit-instances in proof encoding 2021-06-01 17:26:00 +01:00
str4d 256055c656
Merge pull request #279 from zcash/derive-eq
plonk::circuit : Derive Eq for Permutation
2021-06-01 17:20:05 +01:00
therealyingtong 684efbd6c1 plonk::circuit : Derive Eq for Permutation 2021-06-01 17:19:06 +01:00
str4d aac310c763
Merge pull request #274 from zcash/dev-check-cells-for-active-gates
MockProver: Check that cells for active gates are assigned to
2021-06-01 17:15:12 +01:00
str4d ea3d59756b
Merge pull request #273 from zcash/multiple-polys-per-gate
Allow multiple polynomial constraints per gate
2021-06-01 17:14:53 +01:00
str4d 845bf724ff
Merge pull request #272 from zcash/configure-api-changes
`Circuit` API changes
2021-06-01 17:14:39 +01:00
Jack Grigg 9a7f331f1b book: Document k constant in proof encodings 2021-06-01 14:05:33 +01:00
Jack Grigg 4b362669e4 book: Document encoding of proofs
Closes zcash/halo2#144.
2021-05-28 02:21:58 +01:00
Jack Grigg 081e353681 book: Move implementation notes about proofs into a subsection 2021-05-28 01:13:20 +01:00
str4d e4072e78ce
Merge pull request #234 from zcash/book-point-addition
[book] Point addition and compression background
2021-05-27 22:37:06 +01:00
str4d 36cd8633e2
book: Adjustments to point addition and compression sections 2021-05-27 18:43:24 +01:00