Skip to content
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

Open
wants to merge 42 commits into
base: main
Choose a base branch
from
Open

Add scarb prove #1900

wants to merge 42 commits into from

Conversation

DelevoXDG
Copy link
Contributor

@DelevoXDG DelevoXDG commented Jan 18, 2025

Closes #1815

@DelevoXDG DelevoXDG changed the base branch from maicektr/executable to main January 18, 2025 05:05
@DelevoXDG DelevoXDG changed the title Zdobnikau/stwo prove Add scarb prove Jan 18, 2025
Comment on lines +29 to +31
/// Execute the program before proving.
#[arg(long, conflicts_with_all = ["execution_id", "pub_input_file", "priv_input_file"])]
execute: bool,
Copy link
Contributor Author

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?

Copy link
Contributor Author

@DelevoXDG DelevoXDG Jan 21, 2025

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'.

Copy link
Member

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?).

Comment on lines +226 to +227
let output = cmd.output_and_stream(&printer)?;
extract_execution_id(&output)
Copy link
Contributor Author

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

Copy link
Member

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 🤔

Comment on lines +62 to +71
#[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>,
}
Copy link
Contributor Author

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.

Copy link
Member

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? 🙏

Comment on lines +48 to +65
#[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>,
}
Copy link
Contributor Author

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 🤔

Copy link
Member

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

@DelevoXDG DelevoXDG requested a review from THenry14 January 21, 2025 12:58
@DelevoXDG DelevoXDG marked this pull request as ready for review January 21, 2025 13:00
@DelevoXDG DelevoXDG requested a review from a team as a code owner January 21, 2025 13:00
-p scarb-ui \
-p test-for-each-example \
-p xtask
- run: cargo clippy --all-targets --all-features --workspace --exclude scarb-prove -- --no-deps
Copy link
Member

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"
Copy link
Member

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?

Comment on lines +29 to +31
/// Execute the program before proving.
#[arg(long, conflicts_with_all = ["execution_id", "pub_input_file", "priv_input_file"])]
execute: bool,
Copy link
Member

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?).

Comment on lines +61 to +63
/// Target for execution.
#[arg(long, requires = "execute")]
target: Option<String>,
Copy link
Member

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 ?

Comment on lines +53 to +59
/// 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>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not ProgramArguments instead?

Comment on lines +48 to +65
#[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>,
}
Copy link
Member

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

Comment on lines +62 to +71
#[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>,
}
Copy link
Member

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? 🙏

Comment on lines +226 to +227
let output = cmd.output_and_stream(&printer)?;
extract_execution_id(&output)
Copy link
Member

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 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate Stwo prover into Scarb
3 participants