-
Notifications
You must be signed in to change notification settings - Fork 360
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
feat: add defer to the Compiler interface #483
Conversation
follow up on our discussion; my vote is to call it |
Makes sense. I also think it seems nicer. I'll also try to append all the deferred methods into the key-value storage to allow |
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.
lgtm, w/ PreCompileHook(..)
--> Defer(...)
Renamed, but the implementation still doesn't feel right. I'll try with the kvstore to see if it works better. But need to rebase on unmerged PR. |
This was used to create API for field emulation. But we removed the fake-API interface in favor of dedicated emulated field type.
a57d380
to
dbb40ea
Compare
It is done but rebased on top of #480 (kvstore PR, not yet merged). Imo looks a bit nicer and I think a bit more future-proof. |
See discussion in #472. This PR adds
PreCompileHook(cb func(API) error)
method to thefrontend.Compiler
. The intent of the method is to register all callback which should be called after theDefine
method of the circuit is called. These callbacks can be used by gadgets to safely defer any necessary closing tasks (e.g. range checking builds actual constraints, permutation networks build the permutations etc.) without requiring any interaction from the user.I don't like the implementation though, I think it is really fragile. However, the problem is that I do not want to make
frontend.Compile
interface any more complex than it barely should, and this also means that there isn't a method to get all the callbacks which thefrontend.Compile
method can use. That is why I have embedded calling the callback in every builder'sCompile
method. But this is really really ugly solution.A better way would definitely be to make list of all callback available to
frontend.Compile
without makingfrontend.Compiler
interface bigger. One option, for example, would be to use the key-value store with some internal key. For example the implementation for registering callback:and then in
frontend.Compile
: