@@ -13,7 +13,12 @@ use starknet_types_core::felt::Felt;
1313use strum:: IntoEnumIterator ;
1414use strum_macros:: EnumIter ;
1515
16- use crate :: cairo_compile:: { cairo0_compile, cairo1_compile, CompilationArtifacts } ;
16+ use crate :: cairo_compile:: {
17+ cairo0_compile,
18+ cairo1_compile,
19+ cairo1_compiler_version_for_feature_contracts,
20+ CompilationArtifacts ,
21+ } ;
1722use crate :: cairo_versions:: { CairoVersion , RunnableCairo1 } ;
1823
1924pub const CAIRO1_FEATURE_CONTRACTS_DIR : & str = "resources/feature_contracts/cairo1" ;
@@ -77,16 +82,12 @@ const ERC20_CAIRO1_CONTRACT_SOURCE_PATH: &str = "./resources/ERC20/ERC20_Cairo1/
7782const ERC20_SIERRA_CONTRACT_PATH : & str = "./resources/ERC20/ERC20_Cairo1/erc20.sierra.json" ;
7883const ERC20_CAIRO1_CONTRACT_PATH : & str = "./resources/ERC20/ERC20_Cairo1/erc20.casm.json" ;
7984
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" ;
85+ // The following contracts are compiled with a fixed version of the compiler.
86+ const LEGACY_CONTRACT_COMPILER_VERSION : & str = "2.1.0" ;
87+ const CAIRO_STEPS_TEST_CONTRACT_COMPILER_VERSION : & str = "2.7.0" ;
8488
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 > > ;
89+ pub type CairoVersionString = String ;
90+ pub type VersionToContractsMapping = HashMap < CairoVersionString , Vec < FeatureContract > > ;
9091
9192/// Enum representing all feature contracts.
9293/// The contracts that are implemented in both Cairo versions include a version field.
@@ -193,19 +194,12 @@ impl FeatureContract {
193194 }
194195
195196 /// 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 {
197+ /// specific (old) compiler version.
198+ pub fn fixed_version ( & self ) -> CairoVersionString {
199199 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 ) ,
200+ Self :: LegacyTestContract => LEGACY_CONTRACT_COMPILER_VERSION . into ( ) ,
201+ Self :: CairoStepsTestContract => CAIRO_STEPS_TEST_CONTRACT_COMPILER_VERSION . into ( ) ,
202+ _ => cairo1_compiler_version_for_feature_contracts ( ) ,
209203 }
210204 }
211205
@@ -338,10 +332,7 @@ impl FeatureContract {
338332 } ;
339333 cairo0_compile ( self . get_source_path ( ) , extra_arg, false )
340334 }
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- }
335+ CairoVersion :: Cairo1 ( _) => cairo1_compile ( self . get_source_path ( ) , self . fixed_version ( ) ) ,
345336 }
346337 }
347338
@@ -405,10 +396,10 @@ impl FeatureContract {
405396 Self :: all_contracts ( ) . filter ( |contract| !matches ! ( contract, Self :: ERC20 ( _) ) )
406397 }
407398
408- pub fn cairo1_feature_contracts_by_tag ( ) -> TagToContractsMapping {
399+ pub fn cairo1_feature_contracts_by_version ( ) -> VersionToContractsMapping {
409400 Self :: all_feature_contracts ( )
410401 . filter ( |contract| contract. cairo_version ( ) != CairoVersion :: Cairo0 )
411- . map ( |contract| ( contract. fixed_tag_and_rust_toolchain ( ) , contract) )
402+ . map ( |contract| ( contract. fixed_version ( ) , contract) )
412403 . into_group_map ( )
413404 }
414405}
0 commit comments