Commit Graph

1003 Commits

Author SHA1 Message Date
Jack Grigg 57877f5f18 Fix clippy lints 2021-07-27 16:04:27 +01:00
Jack Grigg e855ac6adb Add `halo2::plonk::circuit::TableColumn` struct
This type is required by the `ConstraintSystem::lookup` API, and cannot
be converted into a `Column<Fixed>` via the public API, forcing chip
developers to use `Layouter::assign_table` API to load tables. This is
a safety feature, as lookup table rows need to be default-value-filled
by the layouter (or else the table would have an implicit default value
of all-zeroes which could introduce soundness bugs into circuits).
2021-07-27 15:52:42 +01:00
Jack Grigg 8d8e76dc82 dev: Minor fixes to `CircuitLayout`
- Default view height is now the circuit size.
- Cells are now always shaded on top of any drawn regions.
2021-07-27 02:25:46 +01:00
Jack Grigg 7cf58661d8 dev: Add used/usable row metadata to `CircuitLayout`
- Black line showing the total used rows.
- Red shading for the unusable rows of the circuit.
- Annotations for the number of used and usable rows.
2021-07-27 02:25:07 +01:00
Jack Grigg dac3bf31e4 dev: Add `CircuitCost::marginal_proof_size` API 2021-07-27 02:21:46 +01:00
Daira Hopwood b21ab75625 Use assign_table API in test.
Co-authored-by: Jack Grigg <jack@electriccoin.co>
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2021-07-27 01:41:56 +01:00
Daira Hopwood e3e39455be Table refactoring.
Co-authored-by: Jack Grigg <jack@electriccoin.co>
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2021-07-27 01:34:51 +01:00
Jack Grigg 334036b942 dev: Add `halo2::dev::CircuitGates` developer tool 2021-07-26 02:53:13 +01:00
Jack Grigg eb2b020d8c Migrate benches and examples to `impl Neg for Expression` 2021-07-26 01:59:06 +01:00
Jack Grigg 7355462a9f Add `Expression::Negated` enum case
We were previously representing this as `Expression::Scaled(poly, -1)`
which was less efficient.
2021-07-26 01:59:06 +01:00
Jack Grigg d6bd7bb393 tests: Migrate `plonk_api` test to use `impl Neg for Expression`
No change to the pinned verification key, because `Neg` is implemented
the same way `plonk_api` was manually performing it.
2021-07-26 01:59:05 +01:00
str4d 2e960317ae
Merge pull request #347 from zcash/selector-optimization
Selector optimization
2021-07-26 01:50:28 +01:00
ebfull 101d7c79f3
Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
2021-07-25 18:39:42 -06:00
Sean Bowe 88d34924eb
Account for changes from #350. 2021-07-24 17:17:49 -06:00
Sean Bowe b47889ec51
Merge branch 'main' into selector-optimization 2021-07-24 17:17:03 -06:00
Sean Bowe 77805d9e8e
fix minor typo 2021-07-24 17:10:59 -06:00
Sean Bowe 2a253b89b0
Refactor the selector optimization pass so it can be independently proptested. 2021-07-24 16:35:45 -06:00
Sean Bowe e02fc06f52
cargo fmt 2021-07-24 15:42:30 -06:00
Sean Bowe 634d14a016
Remove spurious code from review suggestion. 2021-07-24 10:43:50 -06:00
ebfull 754dd62c92
Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-07-24 10:27:50 -06:00
str4d 6d3a11511d
Merge pull request #350 from zcash/fix-simple-floor-planner-constants
Fix SimpleFloorPlanner's handling of global constants
2021-07-23 18:53:49 +01:00
Jack Grigg 92645b6ee9 Fix SimpleFloorPlanner's handling of global constants
The previous behaviour assumed that all regions were always assigned
in increasing start-row order. That assumption is broken in e.g. the
Merkle path tests, which position two Sinsemilla calls in parallel.
The layouter was working fine for current tests, but in an adjacent
PR that changed the Merkle path chip's behaviour, it started to
produce invalid circuits.

The new behaviour emulates the `floor_planner::V1` behaviour in an
(intentionally) inefficient way: constants are positioned immediately
after the regions they are assigned to, in the first constants column.
If that column is also used in regions, those regions will now be
positioned without overlapping any assigned global constants.

Co-authored-by: therealyingtong <yingtong@z.cash>
2021-07-23 16:39:37 +01:00
Sean Bowe 28439414f4
(attempt 1 at implementing daira's algorithm) 2021-07-23 08:14:15 -06:00
Sean Bowe e23d148b72
minor clippy fixes 2021-07-22 12:07:17 -06:00
Sean Bowe e3c6542e83
Fix circuit-layout example. 2021-07-22 12:04:41 -06:00
Sean Bowe 5af7a7abfa
Only accept fixed columns in lookup argument tables. 2021-07-22 10:28:52 -06:00
Sean Bowe 145d096dcd
Distinguish between simple and non-simple selectors, and allow the former in lookup arguments. 2021-07-22 10:07:20 -06:00
Sean Bowe 26982a6050
Update circuit graph tooling to account for selector optimization. 2021-07-22 10:06:48 -06:00
Sean Bowe 1254e4f245
Ensure that selectors are only used in simple ways.
You cannot add an expression containing a Selector to another expression.

You cannot multiply an expression containing a Selector by another expression
that also has a selector.
2021-07-21 14:43:31 -06:00
Sean Bowe f6895555bb
Update cost model logic to account for selector optimizations. 2021-07-21 13:51:48 -06:00
Sean Bowe 2cc60838a5
Use locally generated ConstraintSystem to avoid performing optimizations twice. 2021-07-21 13:34:56 -06:00
Sean Bowe 23d7d6532d
Properly substitute selectors in lookup expressions during optimization pass. 2021-07-21 13:12:05 -06:00
Sean Bowe 382cd5a7ea
Create actual selector columns only during an optimization pass. 2021-07-21 12:55:19 -06:00
Sean Bowe dfbd5e3332
Distinguish between selectors and all other columns in layouter using RegionColumn. 2021-07-21 10:19:35 -06:00
str4d 4283713ec7
Merge pull request #340 from zcash/339-dev-proof-cost
dev: Add CircuitCost tool with proof size measurement
2021-07-21 16:45:03 +01:00
str4d a2fb36b6ee
Merge pull request #344 from zcash/325-column-ordering
Change canonical column ordering to Instance < Advice < Fixed
2021-07-21 16:44:50 +01:00
str4d 2b1baaf693
Merge pull request #342 from zcash/335-assign-advice-from-constant
Add `Region::assign_advice_from_constant` API
2021-07-21 16:44:33 +01:00
Jack Grigg 4e6c857854 Add test cases exercising Error::NotEnoughColumnsForConstants 2021-07-21 16:44:14 +01:00
str4d 6420a25c8c
Typo fix
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-07-21 16:35:44 +01:00
Jack Grigg cb9366d656 Fix more clippy lints 2021-07-21 12:00:25 +01:00
Jack Grigg 62f088e2f2 Fix clippy lints 2021-07-21 09:31:27 +08:00
Jack Grigg 629c13eae8 Add `Region::constrain_constant` API
This is the non-assigning subset of `Region::assign_advice_from_constant`.
2021-07-21 09:31:27 +08:00
Jack Grigg 4c5a830e5c Use constants API in simple-example 2021-07-21 09:31:27 +08:00
Jack Grigg 7adf695293 Add constants support to `floor_planner::V1`
Co-authored-by: therealyingtong <yingtong@z.cash>
2021-07-21 09:31:27 +08:00
Jack Grigg 9e2cba917f Update SimpleFloorPlanner with constants support 2021-07-21 09:31:27 +08:00
Jack Grigg ed2295b077 Add trait methods and general APIs for defining circuit constants
During circuit configuration, fixed columns can be marked as suitable
for containing arbitrary constant values (i.e. the columns aren't
encumbered by constraints that preclude arbitrary values).

During synthesis, circuits can now request that the layouter assign
an advice cell within a region, to some specified constant value. It
is the layouter's responsibility to find space within the previously
marked fixed columns, in which to assign the constant.

This commit intentionally does not compile.
2021-07-21 09:31:27 +08:00
str4d c99347be4a
Minor style tweak to Column Ord impl
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-07-20 21:43:24 +01:00
str4d a805e2a35c Merge pull request #343 from zcash/metadata-patch
Introduce metadata::Column struct.
2021-07-20 20:55:37 +01:00
therealyingtong 958cc7ee4b Introduce metadata::Column struct. 2021-07-20 20:55:11 +01:00
Jack Grigg 4417b4e480 Change canonical column ordering to Instance < Advice < Fixed
Closes zcash/halo2#325.
2021-07-20 20:24:37 +01:00