-
Notifications
You must be signed in to change notification settings - Fork 71
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 scarb prove
#1900
base: main
Are you sure you want to change the base?
Add scarb prove
#1900
Conversation
Add scarb execute extension
Change output path from `scarb-execute/package_N` to `scarb-execute/package/executionN`
- Add `UiPrinter` - Cannot use `Ui` directly due to circular dependency
/// Execute the program before proving. | ||
#[arg(long, conflicts_with_all = ["execution_id", "pub_input_file", "priv_input_file"])] | ||
execute: bool, |
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.
Do we want to have the execute
mode on by default?
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.
And if not, do we want to change the error message to default to --execute
or --execution
mode when no args are provided?
Currently, it's
error: the following required arguments were not provided:
--pub-input-file <PUB_INPUT_FILE>
--priv-input-file <PRIV_INPUT_FILE>
Usage: scarb-prove --verbosity <VERBOSITY> --pub-input-file <PUB_INPUT_FILE> --priv-input-file <PRIV_INPUT_FILE>
For more information, try '--help'.
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.
Was there any discussion about this topic?
My understanding is that you technically could want to just prove some previously executed code, but am not sure about implication of this (how do you make sure the code you're proving is THE code?).
let output = cmd.output_and_stream(&printer)?; | ||
extract_execution_id(&output) |
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.
I know this is not ideal, but the original approach discussed with use of env::set_var
seems problematic to me due to this function now being unsafe: rust-lang/rust#124636
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.
my concern is: how stable is that? can't we get it any other way? it seems to me that something like extracting execution id could be done better than parsing the scarb execute output 🤔
#[derive(Parser, Clone, Debug)] | ||
struct InputFileArgs { | ||
/// AIR public input path. | ||
#[arg(long, required_unless_present_any = ["execution_id", "execute"], conflicts_with_all = ["execution_id", "execute"])] | ||
pub_input_file: Option<Utf8PathBuf>, | ||
|
||
/// AIR private input path. | ||
#[arg(long, required_unless_present_any = ["execution_id", "execute"], conflicts_with_all = ["execution_id", "execute"])] | ||
priv_input_file: Option<Utf8PathBuf>, | ||
} |
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.
We initially discussed whether such approach should be available, but I still wonder if we should support package-agnostic files in Scarb, as it creates a lot of noise in a sense of args available for a given subcommand.
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.
any additional context on that? 🙏
#[derive(Parser, Clone, Debug)] | ||
struct ExecuteArgs { | ||
/// Do not build the package before execution. | ||
#[arg(long, requires = "execute")] | ||
no_build: bool, | ||
|
||
/// Arguments to pass to the program during execution. | ||
#[arg(long, requires = "execute")] | ||
arguments: Option<String>, | ||
|
||
/// Arguments to the executable function from a file. | ||
#[arg(long, conflicts_with = "arguments")] | ||
arguments_file: Option<String>, | ||
|
||
/// Target for execution. | ||
#[arg(long, requires = "execute")] | ||
target: Option<String>, | ||
} |
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.
--execute
flag was requested initially for convenience, but I wonder whether we should really have it, as we it forces us to populate scarb prove
with bunch of arguments related to scarb execute
(and one more is coming when stwo prover would support cairo-pie).
Maybe it's better to output a warning, similarly to how scarb execute
does it?
package has not been compiled, file does not exist: `{filename}`
help: run `scarb build` to compile the package
This way all tricky logic related to extracting scarb execute
output would be eliminated.
Maybe not necessarily something we want to address as a part of this PR, but something we should possibly discuss 🤔
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.
I'm not sure I follow, sorry. Can you give me an example of problematic things related to this?
I guess that if we want to --execute
we should probably allow to set all the possible arguments, right? and having an option to just --execute
seems cool enough, but again - maybe I'm just missing something
-p scarb-ui \ | ||
-p test-for-each-example \ | ||
-p xtask | ||
- run: cargo clippy --all-targets --all-features --workspace --exclude scarb-prove -- --no-deps |
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.
let's create an issue to remove all this workarounds after we're able to use rust stable for all packages and add a todo in here
@@ -137,7 +138,7 @@ tar = "0.4" | |||
target-triple = "0.1" | |||
tempfile = "3" | |||
test-case = "3" | |||
thiserror = "2" | |||
thiserror = "2.0.10" |
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.
any specific reason to pin that?
/// Execute the program before proving. | ||
#[arg(long, conflicts_with_all = ["execution_id", "pub_input_file", "priv_input_file"])] | ||
execute: bool, |
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.
Was there any discussion about this topic?
My understanding is that you technically could want to just prove some previously executed code, but am not sure about implication of this (how do you make sure the code you're proving is THE code?).
/// Target for execution. | ||
#[arg(long, requires = "execute")] | ||
target: Option<String>, |
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.
shouldn't this be ExecutionTarget
?
/// Arguments to pass to the program during execution. | ||
#[arg(long, requires = "execute")] | ||
arguments: Option<String>, | ||
|
||
/// Arguments to the executable function from a file. | ||
#[arg(long, conflicts_with = "arguments")] | ||
arguments_file: Option<String>, |
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.
Why not ProgramArguments
instead?
#[derive(Parser, Clone, Debug)] | ||
struct ExecuteArgs { | ||
/// Do not build the package before execution. | ||
#[arg(long, requires = "execute")] | ||
no_build: bool, | ||
|
||
/// Arguments to pass to the program during execution. | ||
#[arg(long, requires = "execute")] | ||
arguments: Option<String>, | ||
|
||
/// Arguments to the executable function from a file. | ||
#[arg(long, conflicts_with = "arguments")] | ||
arguments_file: Option<String>, | ||
|
||
/// Target for execution. | ||
#[arg(long, requires = "execute")] | ||
target: Option<String>, | ||
} |
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.
I'm not sure I follow, sorry. Can you give me an example of problematic things related to this?
I guess that if we want to --execute
we should probably allow to set all the possible arguments, right? and having an option to just --execute
seems cool enough, but again - maybe I'm just missing something
#[derive(Parser, Clone, Debug)] | ||
struct InputFileArgs { | ||
/// AIR public input path. | ||
#[arg(long, required_unless_present_any = ["execution_id", "execute"], conflicts_with_all = ["execution_id", "execute"])] | ||
pub_input_file: Option<Utf8PathBuf>, | ||
|
||
/// AIR private input path. | ||
#[arg(long, required_unless_present_any = ["execution_id", "execute"], conflicts_with_all = ["execution_id", "execute"])] | ||
priv_input_file: Option<Utf8PathBuf>, | ||
} |
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.
any additional context on that? 🙏
let output = cmd.output_and_stream(&printer)?; | ||
extract_execution_id(&output) |
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.
my concern is: how stable is that? can't we get it any other way? it seems to me that something like extracting execution id could be done better than parsing the scarb execute output 🤔
Closes #1815