diff --git a/crates/starknet_gateway/src/compilation.rs b/crates/starknet_gateway/src/compilation.rs index 647704c8cd..5e8a4db171 100644 --- a/crates/starknet_gateway/src/compilation.rs +++ b/crates/starknet_gateway/src/compilation.rs @@ -5,7 +5,6 @@ use cairo_lang_starknet_classes::contract_class::ContractClass as CairoLangContr use starknet_api::contract_class::{ClassInfo, ContractClass}; use starknet_api::rpc_transaction::RpcDeclareTransaction; use starknet_gateway_types::errors::GatewaySpecError; -use starknet_sierra_compile::cairo_lang_compiler::CairoLangSierraToCasmCompiler; use starknet_sierra_compile::command_line_compiler::CommandLineCompiler; use starknet_sierra_compile::config::SierraToCasmCompilationConfig; use starknet_sierra_compile::utils::into_contract_class_for_compilation; @@ -29,11 +28,6 @@ impl GatewayCompiler { Self { sierra_to_casm_compiler: Arc::new(CommandLineCompiler::new(config)) } } - // TODO(Arni): Cosider deleting `CairoLangSierraToCasmCompiler`. - pub fn new_cairo_lang_compiler(config: SierraToCasmCompilationConfig) -> Self { - Self { sierra_to_casm_compiler: Arc::new(CairoLangSierraToCasmCompiler { config }) } - } - /// Formats the contract class for compilation, compiles it, and returns the compiled contract /// class wrapped in a [`ClassInfo`]. /// Assumes the contract class is of a Sierra program which is compiled to Casm. diff --git a/crates/starknet_sierra_compile/src/cairo_lang_compiler.rs b/crates/starknet_sierra_compile/src/cairo_lang_compiler.rs deleted file mode 100644 index b78e1bbc78..0000000000 --- a/crates/starknet_sierra_compile/src/cairo_lang_compiler.rs +++ /dev/null @@ -1,48 +0,0 @@ -use std::panic; - -use cairo_lang_starknet_classes::allowed_libfuncs::ListSelector; -use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; -use cairo_lang_starknet_classes::contract_class::ContractClass; - -use crate::config::SierraToCasmCompilationConfig; -use crate::errors::CompilationUtilError; -use crate::SierraToCasmCompiler; - -/// A compiler that compiles Sierra programs to Casm. Uses the code from the -/// `cairo_lang_starknet_classes` crate. -#[derive(Clone)] -pub struct CairoLangSierraToCasmCompiler { - pub config: SierraToCasmCompilationConfig, -} - -impl SierraToCasmCompiler for CairoLangSierraToCasmCompiler { - fn compile( - &self, - contract_class: ContractClass, - ) -> Result { - let catch_unwind_result = panic::catch_unwind(|| self.compile_inner(contract_class)); - let casm_contract_class = catch_unwind_result.map_err(|error| { - CompilationUtilError::UnexpectedError(format!( - "Compilation Paniced: Error: {:?}", - error - )) - })??; - - Ok(casm_contract_class) - } -} - -impl CairoLangSierraToCasmCompiler { - fn compile_inner( - &self, - contract_class: ContractClass, - ) -> Result { - contract_class.validate_version_compatible(ListSelector::DefaultList)?; - - Ok(CasmContractClass::from_contract_class( - contract_class, - true, - self.config.max_bytecode_size, - )?) - } -} diff --git a/crates/starknet_sierra_compile/src/compile_test.rs b/crates/starknet_sierra_compile/src/compile_test.rs index a5be78fb23..642cd4e4b9 100644 --- a/crates/starknet_sierra_compile/src/compile_test.rs +++ b/crates/starknet_sierra_compile/src/compile_test.rs @@ -7,7 +7,6 @@ use infra_utils::path::resolve_project_relative_path; use mempool_test_utils::{FAULTY_ACCOUNT_CLASS_FILE, TEST_FILES_FOLDER}; use rstest::rstest; -use crate::cairo_lang_compiler::CairoLangSierraToCasmCompiler; use crate::command_line_compiler::CommandLineCompiler; use crate::config::SierraToCasmCompilationConfig; use crate::errors::CompilationUtilError; @@ -19,9 +18,6 @@ use crate::SierraToNativeCompiler; const SIERRA_TO_CASM_COMPILATION_CONFIG: SierraToCasmCompilationConfig = SierraToCasmCompilationConfig { max_bytecode_size: 81920 }; -fn cairo_lang_compiler() -> CairoLangSierraToCasmCompiler { - CairoLangSierraToCasmCompiler { config: SIERRA_TO_CASM_COMPILATION_CONFIG } -} fn command_line_compiler() -> CommandLineCompiler { CommandLineCompiler::new(SIERRA_TO_CASM_COMPILATION_CONFIG) } @@ -39,9 +35,7 @@ fn get_faulty_test_contract() -> ContractClass { contract_class } -// TODO: use the other compiler as well. #[rstest] -#[case::cairo_lang_compiler(cairo_lang_compiler())] #[case::command_line_compiler(command_line_compiler())] fn test_compile_sierra_to_casm(#[case] compiler: impl SierraToCasmCompiler) { let expected_casm_contract_length = 72304; @@ -55,7 +49,6 @@ fn test_compile_sierra_to_casm(#[case] compiler: impl SierraToCasmCompiler) { // TODO(Arni, 1/5/2024): Add a test for panic result test. #[rstest] -#[case::cairo_lang_compiler(cairo_lang_compiler())] #[case::command_line_compiler(command_line_compiler())] fn test_negative_flow_compile_sierra_to_casm(#[case] compiler: impl SierraToCasmCompiler) { let contract_class = get_faulty_test_contract(); diff --git a/crates/starknet_sierra_compile/src/lib.rs b/crates/starknet_sierra_compile/src/lib.rs index d8974bb05c..1e79589aa3 100644 --- a/crates/starknet_sierra_compile/src/lib.rs +++ b/crates/starknet_sierra_compile/src/lib.rs @@ -7,7 +7,6 @@ use cairo_native::executor::AotContractExecutor; use crate::errors::CompilationUtilError; pub mod build_utils; -pub mod cairo_lang_compiler; pub mod command_line_compiler; pub mod config; pub mod errors;