@@ -2,6 +2,7 @@ use std::collections::HashMap;
22use std:: fs;
33use std:: path:: PathBuf ;
44
5+ use apollo_infra_utils:: cairo_compiler_version:: cairo1_compiler_version;
56use apollo_infra_utils:: compile_time_cargo_manifest_dir;
67use cairo_lang_starknet_classes:: contract_class:: ContractClass as CairoLangContractClass ;
78use itertools:: Itertools ;
@@ -77,16 +78,12 @@ const ERC20_CAIRO1_CONTRACT_SOURCE_PATH: &str = "./resources/ERC20/ERC20_Cairo1/
7778const ERC20_SIERRA_CONTRACT_PATH : & str = "./resources/ERC20/ERC20_Cairo1/erc20.sierra.json" ;
7879const ERC20_CAIRO1_CONTRACT_PATH : & str = "./resources/ERC20/ERC20_Cairo1/erc20.casm.json" ;
7980
80- // The following contracts are compiled with a fixed version of the compiler. This compiler version
81- // no longer compiles with stable rust, so the toolchain is also fixed.
82- const LEGACY_CONTRACT_COMPILER_TAG : & str = "v2.1.0" ;
83- const LEGACY_CONTRACT_RUST_TOOLCHAIN : & str = "2023-07-05" ;
81+ // The following contracts are compiled with a fixed version of the compiler.
82+ const LEGACY_CONTRACT_COMPILER_VERSION : & str = "2.1.0" ;
83+ const CAIRO_STEPS_TEST_CONTRACT_COMPILER_VERSION : & str = "2.7.0" ;
8484
85- const CAIRO_STEPS_TEST_CONTRACT_COMPILER_TAG : & str = "v2.7.0" ;
86- const CAIRO_STEPS_TEST_CONTRACT_RUST_TOOLCHAIN : & str = "2024-04-29" ;
87-
88- pub type TagAndToolchain = ( Option < String > , Option < String > ) ;
89- pub type TagToContractsMapping = HashMap < TagAndToolchain , Vec < FeatureContract > > ;
85+ pub type CairoVersionString = String ;
86+ pub type VersionToContractsMapping = HashMap < CairoVersionString , Vec < FeatureContract > > ;
9087
9188/// Enum representing all feature contracts.
9289/// The contracts that are implemented in both Cairo versions include a version field.
@@ -198,19 +195,12 @@ impl FeatureContract {
198195 }
199196
200197 /// Some contracts are designed to test behavior of code compiled with a
201- /// specific (old) compiler tag. To run the (old) compiler, older rust
202- /// version is required.
203- pub fn fixed_tag_and_rust_toolchain ( & self ) -> TagAndToolchain {
198+ /// specific (old) compiler version.
199+ pub fn fixed_version ( & self ) -> CairoVersionString {
204200 match self {
205- Self :: LegacyTestContract => (
206- Some ( LEGACY_CONTRACT_COMPILER_TAG . into ( ) ) ,
207- Some ( LEGACY_CONTRACT_RUST_TOOLCHAIN . into ( ) ) ,
208- ) ,
209- Self :: CairoStepsTestContract => (
210- Some ( CAIRO_STEPS_TEST_CONTRACT_COMPILER_TAG . into ( ) ) ,
211- Some ( CAIRO_STEPS_TEST_CONTRACT_RUST_TOOLCHAIN . into ( ) ) ,
212- ) ,
213- _ => ( None , None ) ,
201+ Self :: LegacyTestContract => LEGACY_CONTRACT_COMPILER_VERSION . into ( ) ,
202+ Self :: CairoStepsTestContract => CAIRO_STEPS_TEST_CONTRACT_COMPILER_VERSION . into ( ) ,
203+ _ => cairo1_compiler_version ( ) ,
214204 }
215205 }
216206
@@ -343,10 +333,7 @@ impl FeatureContract {
343333 } ;
344334 cairo0_compile ( self . get_source_path ( ) , extra_arg, false )
345335 }
346- CairoVersion :: Cairo1 ( _) => {
347- let ( tag_override, cargo_nightly_arg) = self . fixed_tag_and_rust_toolchain ( ) ;
348- cairo1_compile ( self . get_source_path ( ) , tag_override, cargo_nightly_arg)
349- }
336+ CairoVersion :: Cairo1 ( _) => cairo1_compile ( self . get_source_path ( ) , self . fixed_version ( ) ) ,
350337 }
351338 }
352339
@@ -410,10 +397,10 @@ impl FeatureContract {
410397 Self :: all_contracts ( ) . filter ( |contract| !matches ! ( contract, Self :: ERC20 ( _) ) )
411398 }
412399
413- pub fn cairo1_feature_contracts_by_tag ( ) -> TagToContractsMapping {
400+ pub fn cairo1_feature_contracts_by_version ( ) -> VersionToContractsMapping {
414401 Self :: all_feature_contracts ( )
415402 . filter ( |contract| contract. cairo_version ( ) != CairoVersion :: Cairo0 )
416- . map ( |contract| ( contract. fixed_tag_and_rust_toolchain ( ) , contract) )
403+ . map ( |contract| ( contract. fixed_version ( ) , contract) )
417404 . into_group_map ( )
418405 }
419406}
0 commit comments