diff --git a/cairo-vm-cli/src/main.rs b/cairo-vm-cli/src/main.rs index 295e4519a4..ba61037294 100644 --- a/cairo-vm-cli/src/main.rs +++ b/cairo-vm-cli/src/main.rs @@ -203,9 +203,29 @@ fn run(args: impl Iterator) -> Result<(), Error> { } if let Some(file_path) = args.air_private_input { + // Get absolute paths of trace_file & memory_file + let trace_path = args + .trace_file + .clone() + .unwrap() + .as_path() + .canonicalize() + .unwrap_or(args.trace_file.unwrap()) + .to_string_lossy() + .to_string(); + let memory_path = args + .memory_file + .clone() + .unwrap() + .as_path() + .canonicalize() + .unwrap_or(args.memory_file.unwrap()) + .to_string_lossy() + .to_string(); + let json = cairo_runner .get_air_private_input(&vm) - .to_serializable(args.trace_file.unwrap(), args.memory_file.unwrap()) + .to_serializable(trace_path, memory_path) .serialize_json() .map_err(PublicInputError::Serde)?; std::fs::write(file_path, json)?; diff --git a/vm/src/air_private_input.rs b/vm/src/air_private_input.rs index b9a9431841..696fe0162c 100644 --- a/vm/src/air_private_input.rs +++ b/vm/src/air_private_input.rs @@ -1,6 +1,3 @@ -#[cfg(feature = "std")] -use std::path::PathBuf; - use crate::{ stdlib::collections::HashMap, vm::runners::builtin_runner::{ @@ -13,11 +10,10 @@ use serde::{Deserialize, Serialize}; use crate::Felt252; // Serializable format, matches the file output of the python implementation -#[cfg(feature = "std")] #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] pub struct AirPrivateInputSerializable { - trace_path: PathBuf, - memory_path: PathBuf, + trace_path: String, + memory_path: String, pedersen: Vec, range_check: Vec, ecdsa: Vec, @@ -100,16 +96,15 @@ pub struct SignatureInput { pub w: Felt252, } -#[cfg(feature = "std")] impl AirPrivateInput { pub fn to_serializable( &self, - trace_file: PathBuf, - memory_file: PathBuf, + trace_path: String, + memory_path: String, ) -> AirPrivateInputSerializable { AirPrivateInputSerializable { - trace_path: trace_file.as_path().canonicalize().unwrap_or(trace_file), - memory_path: memory_file.as_path().canonicalize().unwrap_or(memory_file), + trace_path, + memory_path, pedersen: self.0.get(HASH_BUILTIN_NAME).cloned().unwrap_or_default(), range_check: self .0 @@ -137,7 +132,6 @@ impl AirPrivateInput { } } -#[cfg(feature = "std")] impl AirPrivateInputSerializable { pub fn serialize_json(&self) -> Result { serde_json::to_string_pretty(&self)