Skip to content

Commit

Permalink
fix(cairo_native): remove native FC folder
Browse files Browse the repository at this point in the history
  • Loading branch information
meship-starkware committed Dec 5, 2024
1 parent 7b28f4a commit a3dbc9f
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 10,675 deletions.

This file was deleted.

This file was deleted.

648 changes: 0 additions & 648 deletions crates/blockifier/feature_contracts/cairo_native/test_contract.cairo

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use crate::transaction::objects::{
#[cfg_attr(
feature = "cairo_native",
test_case(
FeatureContract::SierraExecutionInfoV1Contract,
FeatureContract::SierraExecutionInfoV1Contract(CairoVersion::Cairo1(RunnableCairoVersion::Native)),
ExecutionMode::Validate,
TransactionVersion::ONE,
false;
Expand All @@ -54,7 +54,7 @@ use crate::transaction::objects::{
#[cfg_attr(
feature = "cairo_native",
test_case(
FeatureContract::SierraExecutionInfoV1Contract,
FeatureContract::SierraExecutionInfoV1Contract(CairoVersion::Cairo1(RunnableCairoVersion::Native)),
ExecutionMode::Execute,
TransactionVersion::ONE,
false;
Expand Down Expand Up @@ -181,7 +181,9 @@ fn test_get_execution_info(
vec![]
}
#[cfg(feature = "cairo_native")]
FeatureContract::SierraExecutionInfoV1Contract => {
FeatureContract::SierraExecutionInfoV1Contract(CairoVersion::Cairo1(
RunnableCairoVersion::Native,
)) => {
vec![]
}
_ => {
Expand Down Expand Up @@ -212,7 +214,12 @@ fn test_get_execution_info(
let expected_resource_bounds: Vec<Felt> = match (test_contract, version) {
(FeatureContract::LegacyTestContract, _) => vec![],
#[cfg(feature = "cairo_native")]
(FeatureContract::SierraExecutionInfoV1Contract, _) => vec![],
(
FeatureContract::SierraExecutionInfoV1Contract(CairoVersion::Cairo1(
RunnableCairoVersion::Native,
)),
_,
) => vec![],
(_, version) if version == TransactionVersion::ONE => vec![
felt!(0_u16), // Length of resource bounds array.
],
Expand Down
11 changes: 0 additions & 11 deletions crates/blockifier/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,6 @@ impl CairoVersion {
panic!("Transaction version {:?} is not supported.", tx_version)
}
}

pub fn other(&self) -> Self {
match self {
Self::Cairo0 => CairoVersion::Cairo1(RunnableCairoVersion::Casm),
CairoVersion::Cairo1(RunnableCairoVersion::Casm) => Self::Cairo0,
#[cfg(feature = "cairo_native")]
CairoVersion::Cairo1(RunnableCairoVersion::Native) => {
panic!("There is no other version for native")
}
}
}
}

#[derive(Clone, Copy, PartialEq, Eq, Debug)]
Expand Down
13 changes: 2 additions & 11 deletions crates/blockifier/src/test_utils/cairo_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,8 @@ struct CargoToml {
}

pub enum CompilationArtifacts {
Cairo0 {
casm: Vec<u8>,
},
Cairo1 {
casm: Vec<u8>,
sierra: Vec<u8>,
},
#[cfg(feature = "cairo_native")]
Cairo1Native {
sierra: Vec<u8>,
},
Cairo0 { casm: Vec<u8> },
Cairo1 { casm: Vec<u8>, sierra: Vec<u8> },
}

#[cached]
Expand Down
99 changes: 54 additions & 45 deletions crates/blockifier/src/test_utils/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ use crate::execution::contract_class::RunnableCompiledClass;
use crate::execution::entry_point::CallEntryPoint;
#[cfg(feature = "cairo_native")]
use crate::execution::native::contract_class::NativeCompiledClassV1;
#[cfg(feature = "cairo_native")]
use crate::test_utils::cairo_compile::starknet_compile;
use crate::test_utils::cairo_compile::{cairo0_compile, cairo1_compile, CompilationArtifacts};
use crate::test_utils::struct_impls::LoadContractFromFile;
use crate::test_utils::{get_raw_contract_class, CairoVersion, RunnableCairoVersion};
Expand Down Expand Up @@ -109,7 +107,7 @@ pub enum FeatureContract {
TestContract(CairoVersion),
CairoStepsTestContract,
#[cfg(feature = "cairo_native")]
SierraExecutionInfoV1Contract,
SierraExecutionInfoV1Contract(CairoVersion),
}

impl FeatureContract {
Expand All @@ -126,26 +124,13 @@ impl FeatureContract {
CairoVersion::Cairo1(RunnableCairoVersion::Casm)
}
#[cfg(feature = "cairo_native")]
Self::SierraExecutionInfoV1Contract => {
CairoVersion::Cairo1(RunnableCairoVersion::Native)
Self::SierraExecutionInfoV1Contract(version) => {
assert_ne!(version, &CairoVersion::Cairo0);
*version
}
}
}

fn has_two_versions(&self) -> bool {
match self {
Self::AccountWithLongValidate(_)
| Self::AccountWithoutValidations(_)
| Self::Empty(_)
| Self::FaultyAccount(_)
| Self::TestContract(_)
| Self::ERC20(_) => true,
#[cfg(feature = "cairo_native")]
Self::SierraExecutionInfoV1Contract => false,
Self::SecurityTests | Self::LegacyTestContract | Self::CairoStepsTestContract => false,
}
}

pub fn set_cairo_version(&mut self, version: CairoVersion) {
match self {
Self::AccountWithLongValidate(v)
Expand All @@ -154,11 +139,11 @@ impl FeatureContract {
| Self::FaultyAccount(v)
| Self::TestContract(v)
| Self::ERC20(v) => *v = version,
Self::LegacyTestContract | Self::SecurityTests | Self::CairoStepsTestContract => {
panic!("{self:?} contract has no configurable version.")
}
#[cfg(feature = "cairo_native")]
Self::SierraExecutionInfoV1Contract => {
Self::SierraExecutionInfoV1Contract(_) => {
panic!("SierraExecutionInfoV1Contract has no configurable version.")
}
Self::SecurityTests | Self::CairoStepsTestContract | Self::LegacyTestContract => {
panic!("{self:?} contract has no configurable version.")
}
}
Expand Down Expand Up @@ -257,7 +242,7 @@ impl FeatureContract {
Self::TestContract(_) => TEST_CONTRACT_BASE,
Self::CairoStepsTestContract => CAIRO_STEPS_TEST_CONTRACT_BASE,
#[cfg(feature = "cairo_native")]
Self::SierraExecutionInfoV1Contract => SIERRA_EXECUTION_INFO_V1_CONTRACT_BASE,
Self::SierraExecutionInfoV1Contract(_) => SIERRA_EXECUTION_INFO_V1_CONTRACT_BASE,
}
}

Expand All @@ -272,7 +257,7 @@ impl FeatureContract {
Self::TestContract(_) => TEST_CONTRACT_NAME,
Self::CairoStepsTestContract => CAIRO_STEPS_TEST_CONTRACT_NAME,
#[cfg(feature = "cairo_native")]
Self::SierraExecutionInfoV1Contract => EXECUTION_INFO_V1_CONTRACT_NAME,
Self::SierraExecutionInfoV1Contract(_) => EXECUTION_INFO_V1_CONTRACT_NAME,
Self::ERC20(_) => unreachable!(),
}
}
Expand All @@ -298,7 +283,7 @@ impl FeatureContract {
CairoVersion::Cairo0 => "0",
CairoVersion::Cairo1(RunnableCairoVersion::Casm) => "1",
#[cfg(feature = "cairo_native")]
CairoVersion::Cairo1(RunnableCairoVersion::Native) => "_native",
CairoVersion::Cairo1(RunnableCairoVersion::Native) => "1",
},
self.get_non_erc20_base_name()
)
Expand Down Expand Up @@ -329,12 +314,12 @@ impl FeatureContract {
} else {
let cairo_version = self.cairo_version();
format!(
"feature_contracts/cairo{}/compiled/{}{}.json",
"feature_contracts/cairo{}/{}{}.json",
match cairo_version {
CairoVersion::Cairo0 => "0",
CairoVersion::Cairo1(RunnableCairoVersion::Casm) => "1",
CairoVersion::Cairo0 => "0/compiled",
CairoVersion::Cairo1(RunnableCairoVersion::Casm) => "1/compiled",
#[cfg(feature = "cairo_native")]
CairoVersion::Cairo1(RunnableCairoVersion::Native) => "_native",
CairoVersion::Cairo1(RunnableCairoVersion::Native) => "1/sierra",
},
self.get_non_erc20_base_name(),
match cairo_version {
Expand Down Expand Up @@ -366,7 +351,7 @@ impl FeatureContract {
| FeatureContract::LegacyTestContract
| FeatureContract::CairoStepsTestContract => None,
#[cfg(feature = "cairo_native")]
FeatureContract::SierraExecutionInfoV1Contract => None,
Self::SierraExecutionInfoV1Contract(_) => None,
FeatureContract::ERC20(_) => unreachable!(),
};
cairo0_compile(self.get_source_path(), extra_arg, false)
Expand All @@ -378,13 +363,7 @@ impl FeatureContract {
#[cfg(feature = "cairo_native")]
CairoVersion::Cairo1(RunnableCairoVersion::Native) => {
let (tag_override, cargo_nightly_arg) = self.fixed_tag_and_rust_toolchain();
let sierra_output = starknet_compile(
self.get_source_path(),
tag_override,
cargo_nightly_arg,
&mut vec![],
);
CompilationArtifacts::Cairo1Native { sierra: sierra_output }
cairo1_compile(self.get_source_path(), tag_override, cargo_nightly_arg)
}
}
}
Expand Down Expand Up @@ -445,14 +424,44 @@ impl FeatureContract {
pub fn all_contracts() -> impl Iterator<Item = Self> {
// EnumIter iterates over all variants with Default::default() as the cairo
// version.
Self::iter().flat_map(|contract| {
if contract.has_two_versions() {
let mut other_contract = contract;
other_contract.set_cairo_version(contract.cairo_version().other());
vec![contract, other_contract].into_iter()
} else {
vec![contract].into_iter()
Self::iter().flat_map(|contract| match contract {
Self::AccountWithLongValidate(_) => vec![
Self::AccountWithLongValidate(CairoVersion::Cairo0),
Self::AccountWithLongValidate(CairoVersion::Cairo1(RunnableCairoVersion::Casm)),
],
Self::AccountWithoutValidations(_) => vec![
Self::AccountWithoutValidations(CairoVersion::Cairo0),
Self::AccountWithoutValidations(CairoVersion::Cairo1(RunnableCairoVersion::Casm)),
],
Self::Empty(_) => {
vec![
Self::Empty(CairoVersion::Cairo0),
Self::Empty(CairoVersion::Cairo1(RunnableCairoVersion::Casm)),
]
}

Self::FaultyAccount(_) => vec![
Self::FaultyAccount(CairoVersion::Cairo0),
Self::FaultyAccount(CairoVersion::Cairo1(RunnableCairoVersion::Casm)),
],
Self::TestContract(_) => vec![
Self::TestContract(CairoVersion::Cairo0),
Self::TestContract(CairoVersion::Cairo1(RunnableCairoVersion::Casm)),
],
Self::ERC20(_) => {
vec![
Self::ERC20(CairoVersion::Cairo0),
Self::ERC20(CairoVersion::Cairo1(RunnableCairoVersion::Casm)),
]
}

Self::SecurityTests => vec![Self::SecurityTests],
Self::LegacyTestContract => vec![Self::LegacyTestContract],
Self::CairoStepsTestContract => vec![Self::CairoStepsTestContract],
#[cfg(feature = "cairo_native")]
Self::SierraExecutionInfoV1Contract(_) => vec![Self::SierraExecutionInfoV1Contract(
CairoVersion::Cairo1(RunnableCairoVersion::Casm),
)],
})
}

Expand Down
Loading

0 comments on commit a3dbc9f

Please sign in to comment.