From df83e8ed67222c1764bec939da6b4e2db5d94d82 Mon Sep 17 00:00:00 2001 From: Kamen Mladenov Date: Wed, 7 May 2025 11:55:04 +0300 Subject: feat(zkvms_guest_io): Add private and public input arguments This allows us to pass custom inputs on single-guest commands (nix run .#fibonacci). --- zkvms_guest_io/src/main.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'zkvms_guest_io/src') diff --git a/zkvms_guest_io/src/main.rs b/zkvms_guest_io/src/main.rs index a38ce99..a3f48ca 100644 --- a/zkvms_guest_io/src/main.rs +++ b/zkvms_guest_io/src/main.rs @@ -15,6 +15,12 @@ use sysinfo::System; #[derive(Parser, Debug)] #[command(about, long_about = None)] struct Cli { + /// Path to private input file (in TOML format) + private_input: Option, + + /// Path to public input file (in TOML format) + public_input: Option, + /// Ignored zkVMs. Values are substrings of names. #[arg(short, long, value_delimiter = ',', num_args = 1..)] ignore: Option>, @@ -36,12 +42,15 @@ static COMMAND_LOG_PATH: &str = "/tmp/output.log"; static METRICS_TEMP_OUTPUT_PATH: &str = "/tmp/current_metrics"; static PROOF_SIZE_FILE_PATH: &str = "/tmp/proof_size"; -fn run_command(zkvm_guest_command: &str, operation: &str) -> Result { +fn run_command(zkvm_guest_command: &str, operation: &str, private_input: &Option, public_input: &Option) -> Result { + let inputs = vec![private_input.clone(), public_input.clone()]; + let inputs = inputs.iter().flatten().collect::>(); Command::new("runexec") .args(["--no-container", "--output", COMMAND_LOG_PATH, "--"]) .args([zkvm_guest_command, operation]) .arg("--benchmark") .args(["--metrics-output", METRICS_TEMP_OUTPUT_PATH]) + .args(inputs) .stdout(Stdio::piped()) .output() } @@ -153,7 +162,7 @@ fn main() { for operation in ["execute", "prove", "verify"] { println!("== {operation} {zkvm} =="); - let output = run_command(zkvm_guest_command, operation); + let output = run_command(zkvm_guest_command, operation, &cli.private_input, &cli.public_input); // Couldn't run runexec if let Err(msg) = output { -- cgit v1.2.3