-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove dependency to common ConstraintSystem in the backend #290
Conversation
- Rewrite VerifyingKey and ProvingKey methods in terms of the ConstraintSystemBack so that the backend becomes independent of the Circuit trait (which belongs to the frontend) - Add `vk_read` and `pk_read` legacy functions in halo2_proofs for compatiblity. - Split the implementation of converting selectors to fixed columns into two parts: - One part just converts the ConstraintSystem, transforming the selectors into fixed columns (compressed and direct versions) - The other part transforms the assignments of selector columns into assignments of fixed columns based on the mappings calculated in part one.
02a32dd
to
0ec4b72
Compare
0ec4b72
to
3c9090d
Compare
…value, add safety check In selectors_to_fixed_compressed and selectors_to_fixed_direct add safety check via the ConstraintSystem.selectors_to_fixed status field such that the methods can only be called once. Calling them multiple times would lead to an invalid ConstraintSystem with unused duplicated fixed columns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a quick review, added some comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! LGTM! 🚀
I have just one comment.
I think that the remaining modules(helpers
, multicore
, plonk
) of halo2_common
can be moved to halo2_backend
. right? @ed255
Maybe, it could be better to move all of those in this PR. And remove halo2_common
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work!!!!!
I didn't check in detail but I had the impression that the remaining work regarding |
After the frontend-backend split, both the backend and frontend were using the same
ConstraintSystem
internally. This has the following implicationConstraintSystem
uses Expressions that can have selectors, but the backend shouldn't have any code related to selectorsThis PR does:
Expression
type inmiddleware
that can be easily customized for the backend and frontend needs. The point of this is to reuse some code. Then we have the following configurations:Circuit
trait; it would configure the circuit to extract its configuration, and from it read the keys. Now it receives aConstraintSystemBackend
(which is the output of the configuration, or also part of the output of circuit compilation).permutation::ArgumentV2
topermutation::ArgumentMid
ConstraintSystemV2Backend
toConstraintSystemMid
GateV2Backend
toGateMid
lookup::ArgumentV2
tolookup::ArgumentMid
shuffle::ArgumentV2
toshuffle::ArgumentMid
halo2_common
tohalo_frontend
(as they are no longer used inhalo_backend
):Circuit
trait:pk_read
andvk_read
inhalo2_proofs
ConstraintSystem
, transforming the selectors into fixed columns (compressed and direct versions)ConstraintSystem
that marks when the transformation of selectors to fixed has been done, so that it panics if the transformation is attempted a second time.Related issue: #266
NOTE: I'm not marking as breaking the changes that affect the frontend-backend split, only the changes that affect the legacy API, because we still haven't made any release with the frontend-backend split.
Blocked by #289