@@ -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.
@@ -193,19 +190,12 @@ impl FeatureContract {
193190 }
194191
195192 /// Some contracts are designed to test behavior of code compiled with a
196- /// specific (old) compiler tag. To run the (old) compiler, older rust
197- /// version is required.
198- pub fn fixed_tag_and_rust_toolchain ( & self ) -> TagAndToolchain {
193+ /// specific (old) compiler version.
194+ pub fn fixed_version ( & self ) -> CairoVersionString {
199195 match self {
200- Self :: LegacyTestContract => (
201- Some ( LEGACY_CONTRACT_COMPILER_TAG . into ( ) ) ,
202- Some ( LEGACY_CONTRACT_RUST_TOOLCHAIN . into ( ) ) ,
203- ) ,
204- Self :: CairoStepsTestContract => (
205- Some ( CAIRO_STEPS_TEST_CONTRACT_COMPILER_TAG . into ( ) ) ,
206- Some ( CAIRO_STEPS_TEST_CONTRACT_RUST_TOOLCHAIN . into ( ) ) ,
207- ) ,
208- _ => ( None , None ) ,
196+ Self :: LegacyTestContract => LEGACY_CONTRACT_COMPILER_VERSION . into ( ) ,
197+ Self :: CairoStepsTestContract => CAIRO_STEPS_TEST_CONTRACT_COMPILER_VERSION . into ( ) ,
198+ _ => cairo1_compiler_version ( ) ,
209199 }
210200 }
211201
@@ -338,10 +328,7 @@ impl FeatureContract {
338328 } ;
339329 cairo0_compile ( self . get_source_path ( ) , extra_arg, false )
340330 }
341- CairoVersion :: Cairo1 ( _) => {
342- let ( tag_override, cargo_nightly_arg) = self . fixed_tag_and_rust_toolchain ( ) ;
343- cairo1_compile ( self . get_source_path ( ) , tag_override, cargo_nightly_arg)
344- }
331+ CairoVersion :: Cairo1 ( _) => cairo1_compile ( self . get_source_path ( ) , self . fixed_version ( ) ) ,
345332 }
346333 }
347334
@@ -405,10 +392,10 @@ impl FeatureContract {
405392 Self :: all_contracts ( ) . filter ( |contract| !matches ! ( contract, Self :: ERC20 ( _) ) )
406393 }
407394
408- pub fn cairo1_feature_contracts_by_tag ( ) -> TagToContractsMapping {
395+ pub fn cairo1_feature_contracts_by_version ( ) -> VersionToContractsMapping {
409396 Self :: all_feature_contracts ( )
410397 . filter ( |contract| contract. cairo_version ( ) != CairoVersion :: Cairo0 )
411- . map ( |contract| ( contract. fixed_tag_and_rust_toolchain ( ) , contract) )
398+ . map ( |contract| ( contract. fixed_version ( ) , contract) )
412399 . into_group_map ( )
413400 }
414401}
0 commit comments