-
Notifications
You must be signed in to change notification settings - Fork 52
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
Add --disable-safety-check option #235
base: main
Are you sure you want to change the base?
Conversation
This option allows variables that are not constrained.
b3b89e0
to
b9fe3c6
Compare
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.
Cool, lgtm. @mimoo may want to have a pass.
ErrorKind::PrivateInputNotUsed, | ||
private_cell_var.span, | ||
))? | ||
if !disable_safety_check { |
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.
same as above
private_cell_var.span, | ||
); | ||
Err(err)?; | ||
if !disable_safety_check { |
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.
Maybe checking this flag at the root block is cleaner :)
if !written_vars.contains(&var) && !disable_safety_check {
@@ -71,6 +71,10 @@ pub struct CmdBuild { | |||
/// Run in server mode to help debug and understand the compiler passes. | |||
#[clap(long)] | |||
server_mode: bool, | |||
|
|||
/// Do not check that every variable is in a constraint | |||
#[arg(long = "disable-safety-check", global = true)] |
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.
Maybe adding a doc on why this is necessary in certain cases, and it should not be recommended by default.
This option allows variables that are not constrained.
Right now, it's a bit ugly how this parameter has to be passed. I will explain the workflow below, but I guess in the future, we can have a struct to capture parameters and pass them around so we can have access to user-defined configs.
We need to add some ifs for this particular feature when we validate that variables have been used. This is happening in the
finalize_circuit
function inside circuit_writer instead of in the type checking and semantic checks. To pass the parameter from the UI based on which we are going to return an error or not, we do the following:cli/cmd_build_and_check.rs
andcli/cmd_prove_and_verify.rs
disable_safety_check
) incompiler.rs::compile
functionCircuitWriter::generate_circuit
functionfinalize_circuit
function (In all backends)Furthermore, in the tests, we always set that option to false.