Skip to content

Commit c5eccb8

Browse files
committed
heaptrack stone prover
1 parent 7f1304b commit c5eccb8

File tree

3 files changed

+43
-13
lines changed

3 files changed

+43
-13
lines changed

src/args.rs

+3
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ pub struct ProveArgs {
6060

6161
#[clap(long = "stone_version", default_value = "v6", value_enum)]
6262
pub stone_version: StoneVersion,
63+
64+
#[clap(long = "bench-memory")]
65+
pub bench_memory: Option<bool>,
6366
}
6467

6568
#[derive(Args, Debug)]

src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ fn main() -> anyhow::Result<()> {
2929
&run_cairo_result.air_public_input,
3030
&run_cairo_result.air_private_input,
3131
&tmp_dir,
32+
args.bench_memory.unwrap_or(false),
3233
)
3334
.map_err(|e| anyhow::anyhow!("Failed to run stone prover: {}", e))
3435
});

src/prover.rs

+39-13
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ pub fn run_stone_prover(
5252
air_public_input: &PathBuf,
5353
air_private_input: &PathBuf,
5454
tmp_dir: &tempfile::TempDir,
55+
bench_memory: bool,
5556
) -> Result<(), ProverError> {
5657
println!("Running prover...");
5758

@@ -65,6 +66,7 @@ pub fn run_stone_prover(
6566
air_public_input,
6667
air_private_input,
6768
tmp_dir,
69+
bench_memory,
6870
)?;
6971

7072
println!("Prover finished successfully");
@@ -101,6 +103,7 @@ pub fn run_stone_prover_bootloader(
101103
air_public_input,
102104
air_private_input,
103105
tmp_dir,
106+
false,
104107
)?;
105108

106109
println!("Prover finished successfully");
@@ -118,6 +121,7 @@ fn run_stone_prover_internal(
118121
air_public_input: &PathBuf,
119122
air_private_input: &PathBuf,
120123
tmp_dir: &tempfile::TempDir,
124+
bench_memory: bool,
121125
) -> Result<(), ProverError> {
122126
let tmp_prover_parameters_path = tmp_dir.path().join("prover_parameters.json");
123127

@@ -150,6 +154,7 @@ fn run_stone_prover_internal(
150154
output_file,
151155
true,
152156
stone_version,
157+
bench_memory,
153158
)?;
154159

155160
Ok(())
@@ -163,26 +168,47 @@ fn run_prover_from_command_line_with_annotations(
163168
output_file: &PathBuf,
164169
generate_annotations: bool,
165170
stone_version: &StoneVersion,
171+
bench_memory: bool,
166172
) -> Result<(), ProverError> {
167173
// TODO: Add better error handling
168174
let prover_run_path = match stone_version {
169175
StoneVersion::V5 => std::env::var("CPU_AIR_PROVER_V5").unwrap(),
170176
StoneVersion::V6 => std::env::var("CPU_AIR_PROVER_V6").unwrap(),
171177
};
172178

173-
let mut command = Command::new("heaptrack");
174-
command
175-
.arg(prover_run_path)
176-
.arg("--out-file")
177-
.arg(output_file)
178-
.arg("--public-input-file")
179-
.arg(public_input_file)
180-
.arg("--private-input-file")
181-
.arg(private_input_file)
182-
.arg("--prover-config-file")
183-
.arg(prover_config_file)
184-
.arg("--parameter-file")
185-
.arg(prover_parameter_file);
179+
let mut command;
180+
if bench_memory {
181+
command = Command::new("heaptrack");
182+
command
183+
.arg("-o")
184+
.arg("heaptrack-prover")
185+
.arg(prover_run_path)
186+
.arg("--out-file")
187+
.arg(output_file)
188+
.arg("--public-input-file")
189+
.arg(public_input_file)
190+
.arg("--private-input-file")
191+
.arg(private_input_file)
192+
.arg("--prover-config-file")
193+
.arg(prover_config_file)
194+
.arg("--parameter-file")
195+
.arg(prover_parameter_file);
196+
}
197+
else {
198+
command = Command::new(prover_run_path);
199+
command
200+
.arg("--out-file")
201+
.arg(output_file)
202+
.arg("--public-input-file")
203+
.arg(public_input_file)
204+
.arg("--private-input-file")
205+
.arg(private_input_file)
206+
.arg("--prover-config-file")
207+
.arg(prover_config_file)
208+
.arg("--parameter-file")
209+
.arg(prover_parameter_file);
210+
}
211+
186212
if generate_annotations {
187213
command.arg("--generate-annotations");
188214
}

0 commit comments

Comments
 (0)