Skip to content

Commit

Permalink
add print for debug
Browse files Browse the repository at this point in the history
  • Loading branch information
meship-starkware committed Dec 25, 2024
1 parent 13960a8 commit b9f2802
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
3 changes: 3 additions & 0 deletions crates/bin/starknet-native-compile/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions crates/blockifier/src/state/contract_class_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
5 changes: 4 additions & 1 deletion crates/papyrus_state_reader/src/papyrus_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
}
}
}
Expand Down
17 changes: 12 additions & 5 deletions crates/starknet_sierra_compile/src/command_line_compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,19 @@ impl SierraToNativeCompiler for CommandLineCompiler {
contract_class: ContractClass,
) -> Result<AotContractExecutor, CompilationUtilError> {
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
}
}

Expand All @@ -83,6 +86,7 @@ fn compile_with_args(
additional_args: &[&str],
) -> Result<Vec<u8>, 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()?;
Expand All @@ -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));
Expand Down

0 comments on commit b9f2802

Please sign in to comment.