From b9f28024908aaa36aea0c7c11086fa6b74b2bc3e Mon Sep 17 00:00:00 2001 From: meship-starkware Date: Wed, 25 Dec 2024 14:04:10 +0200 Subject: [PATCH] add print for debug --- crates/bin/starknet-native-compile/src/main.rs | 3 +++ .../src/state/contract_class_manager.rs | 1 + .../papyrus_state_reader/src/papyrus_state.rs | 5 ++++- .../src/command_line_compiler.rs | 17 ++++++++++++----- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/crates/bin/starknet-native-compile/src/main.rs b/crates/bin/starknet-native-compile/src/main.rs index 6e6990d421..e3c9ed0690 100644 --- a/crates/bin/starknet-native-compile/src/main.rs +++ b/crates/bin/starknet-native-compile/src/main.rs @@ -24,9 +24,11 @@ fn main() { let path = args.path; let output = args.output; + println!("AAAAAAAAAAAAAAAAAAA"); let (contract_class, sierra_program) = load_sierra_program_from_file(&path); // TODO(Avi, 01/12/2024): Test different optimization levels for best performance. + println!("BBBBBBBBBBBBBBBBBBBB"); let mut contract_executor = AotContractExecutor::new( &sierra_program, &contract_class.entry_points_by_type, @@ -36,6 +38,7 @@ fn main() { eprintln!("Error compiling Sierra program: {}", err); process::exit(1); }); + println!("CCCCCCCCCCCCCCCCCCCC"); contract_executor.save(output.clone()).unwrap_or_else(|err| { eprintln!("Error saving compiled program: {}", err); process::exit(1); diff --git a/crates/blockifier/src/state/contract_class_manager.rs b/crates/blockifier/src/state/contract_class_manager.rs index 4091450545..162208f419 100644 --- a/crates/blockifier/src/state/contract_class_manager.rs +++ b/crates/blockifier/src/state/contract_class_manager.rs @@ -211,6 +211,7 @@ fn process_compilation_request( .set_native(class_hash, CachedCairoNative::Compiled(native_compiled_class)); } Err(err) => { + println!("Error compiling contract class: {}", err); log::error!("Error compiling contract class: {}", err); contract_caches.set_native(class_hash, CachedCairoNative::CompilationFailed); } diff --git a/crates/papyrus_state_reader/src/papyrus_state.rs b/crates/papyrus_state_reader/src/papyrus_state.rs index 8cf7dffa05..a75228d9c0 100644 --- a/crates/papyrus_state_reader/src/papyrus_state.rs +++ b/crates/papyrus_state_reader/src/papyrus_state.rs @@ -145,7 +145,10 @@ impl PapyrusReader { CachedCairoNative::Compiled(compiled_native) => { RunnableCompiledClass::from(compiled_native) } - CachedCairoNative::CompilationFailed => casm, + CachedCairoNative::CompilationFailed => { + println!("Compilation failed for class hash: {}", class_hash); + casm + }, } } } diff --git a/crates/starknet_sierra_compile/src/command_line_compiler.rs b/crates/starknet_sierra_compile/src/command_line_compiler.rs index ce324b49f5..5ede859b15 100644 --- a/crates/starknet_sierra_compile/src/command_line_compiler.rs +++ b/crates/starknet_sierra_compile/src/command_line_compiler.rs @@ -64,16 +64,19 @@ impl SierraToNativeCompiler for CommandLineCompiler { contract_class: ContractClass, ) -> Result { let compiler_binary_path = &self.path_to_starknet_native_compile_binary; - - let output_file = NamedTempFile::new()?; - let output_file_path = output_file.path().to_str().ok_or( + // let output_dir = + // TempDir::new().expect("Failed to create temporary compilation output directory."); + // let output_file = output_dir.path().join("output.so"); + let output_file = PathBuf::from("/tmp/output-1343214.so"); + let output_file_path = output_file.to_str().ok_or( CompilationUtilError::UnexpectedError("Failed to get output file path".to_owned()), )?; let additional_args = [output_file_path]; + println!("11111111111111111111"); let _stdout = compile_with_args(compiler_binary_path, contract_class, &additional_args)?; - - Ok(AotContractExecutor::load(Path::new(&output_file_path))?) + let out = Ok(AotContractExecutor::load(Path::new(&output_file_path))?); + out } } @@ -83,6 +86,7 @@ fn compile_with_args( additional_args: &[&str], ) -> Result, CompilationUtilError> { // Create a temporary file to store the Sierra contract class. + println!("222222222"); let serialized_contract_class = serde_json::to_string(&contract_class)?; let mut temp_file = NamedTempFile::new()?; @@ -93,13 +97,16 @@ fn compile_with_args( // Set the parameters for the compile process. // TODO(Arni, Avi): Setup the ulimit for the process. + println!("333333333"); let mut command = Command::new(compiler_binary_path.as_os_str()); command.arg(temp_file_path).args(additional_args); // Run the compile process. let compile_output = command.output()?; + println!("444444444"); if !compile_output.status.success() { + println!("55555555"); let stderr_output = String::from_utf8(compile_output.stderr) .unwrap_or("Failed to get stderr output".into()); return Err(CompilationUtilError::CompilationError(stderr_output));