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

Make bootloader mode the default #18

Merged
merged 12 commits into from
May 23, 2024
16 changes: 13 additions & 3 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ impl FromStr for Bootloader {
#[command(args_conflicts_with_subcommands = true)]
#[command(flatten_help = true)]
pub struct ProveArgs {
#[clap(long = "with-bootloader", default_value_t = false)]
#[clap(long = "with-bootloader", default_value_t = true)]
pub with_bootloader: bool,

#[clap(long = "no-bootloader", conflicts_with = "with_bootloader")]
pub no_bootloader: Option<bool>,
whichqua marked this conversation as resolved.
Show resolved Hide resolved

#[clap(long = "bootloader-version")]
bootloader: Option<Bootloader>,

Expand All @@ -73,9 +76,16 @@ pub struct ProveArgs {
}

impl ProveArgs {
fn use_bootloader(&self) -> bool {
if let Some(no_bootloader) = self.no_bootloader {
return !no_bootloader;
}
self.with_bootloader
}
pub fn command(mut self) -> ProveCommand {
let mut cmd = Cli::command();
if !self.with_bootloader {
let use_bootloader = self.use_bootloader();
if !use_bootloader {
if self.config.fact_topologies_file.is_some() {
cmd.error(
ErrorKind::ArgumentConflict,
Expand All @@ -102,7 +112,7 @@ impl ProveArgs {
let layout = self.layout.unwrap_or(Layout::StarknetWithKeccak);
let verifier = self.verifier.unwrap_or(Verifier::Stone);

let executable = match self.with_bootloader {
let executable = match use_bootloader {
true => {
let bootloader = match self.bootloader {
Some(version) => version,
Expand Down
27 changes: 21 additions & 6 deletions tests/test_prove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::common::cli_in_path;
mod common;

fn invoke_cli(
with_bootloader: bool,
use_bootloader: bool,
executables: &[&Path],
verifier: Option<Verifier>,
prover_config: Option<&Path>,
Expand All @@ -21,8 +21,10 @@ fn invoke_cli(

command.arg("prove");

if with_bootloader {
if use_bootloader {
command.arg("--with-bootloader");
} else {
command.arg("--no-bootloader").arg("true");
}
for executable in executables {
command.arg(*executable);
Expand Down Expand Up @@ -70,6 +72,19 @@ fn assert_proof_eq(proof: Proof, expected_proof: Proof) {
assert_eq!(proof.proof_hex, expected_proof.proof_hex);
}

#[test]
fn assert_conflict_on_usage_of_with_and_no_bootloader() {
let mut command = std::process::Command::new("stone-prover-cli");
odesenfans marked this conversation as resolved.
Show resolved Hide resolved
command.arg("prove");
command.arg("--with-bootloader");
command.arg("--no-bootloader").arg("true");
let output = command.output().unwrap();
assert!(!output.status.success());
assert!(format!("{output:?}").contains(
"the argument '--with-bootloader' cannot be used with '--no-bootloader <NO_BOOTLOADER>'"
))
}

#[rstest]
fn execute_and_prove_program(
#[from(cli_in_path)] _path: (),
Expand Down Expand Up @@ -102,7 +117,7 @@ fn execute_and_prove_program(

let result = invoke_cli(
false,
&vec![program.as_path()],
&[program.as_path()],
odesenfans marked this conversation as resolved.
Show resolved Hide resolved
None,
prover_config,
prover_parameters,
Expand Down Expand Up @@ -138,7 +153,7 @@ fn execute_and_prove_program_l1_verifier(#[from(cli_in_path)] _path: ()) {

let result = invoke_cli(
false,
&vec![program.as_path()],
&[program.as_path()],
Some(Verifier::L1),
None,
None,
Expand Down Expand Up @@ -184,7 +199,7 @@ fn execute_and_prove_program_with_bootloader(#[from(cli_in_path)] _path: ()) {

let result = invoke_cli(
true,
&vec![program.as_path()],
&[program.as_path()],
None,
None,
None,
Expand Down Expand Up @@ -217,7 +232,7 @@ fn execute_and_prove_pie_with_bootloader(#[from(cli_in_path)] _path: ()) {

let result = invoke_cli(
true,
&vec![pie.as_path()],
&[pie.as_path()],
None,
None,
None,
Expand Down
Loading