Improve connection between gate configuration and assignment #365
Labels
A-dev-tooling
Area: Developer tooling
A-rust-api
Area: Public crate API
M-verifier-compatibility
This is a backwards-incompatible change to the verifier
Currently, to use a custom gate (being a group of constraints), the circuit developer needs to do the following:
Layouter::assign_region
to create a region in which the gate can be used.x
.x
.Note that the "definition" of the gate is not propagated from configuration to synthesis; the circuit developer just has to "remember" that definition and assign cells appropriately. On the one hand, this makes it easy to detect unintended double-assignments to cells, as the developer can assign once to a cell used in multiple overlapping gates. On the other hand, it's still on the developer to prevent those double-assignments, and it's more likely that the developer will get the assignments wrong due to needing to manually position the gate's "Tetris piece".
My idea for improving this (which I thought I'd already written down somewhere, but oh well) is that gates should be defined as structs with generic parameters:
At configure time, each gate struct is constructed to contain "cell templates", which are then used to configure the gate with the constraint relations:
The gate structs (
foo
in the above example) are then stored in the circuit config.Each gate struct has assignment functions that can be called at synthesis time within a region, by providing the offset to assign the gate at, and the values that should be assigned:
The use of the same struct (template) for both the gate and its values, reduces the chance that developers miss any cell assignments. Reviewers would only need to look at
StandardPlonk::assign_addition
to understand that assignment, instead of in potentially-repeated untethered functions.The text was updated successfully, but these errors were encountered: