Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoni-Starkware committed Feb 6, 2025
1 parent 05f100e commit 6abcbf1
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 419 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,8 @@ use crate::transaction::objects::{
TransactionVersion::ONE,
false,
false;
<<<<<<< HEAD
"Native: Legacy contract. Execute execution mode: block info should be as usual. Transaction
V1."
||||||| 91889fd5e
"Native: Legacy contract. Execute execution mode: block info should be as usual. Transaction
V1."
=======
"Native: Legacy contract. Execute execution mode: block info should be as usual. Transaction V1."
>>>>>>> origin/main-v0.13.4
)
)]
#[cfg_attr(
Expand All @@ -115,15 +108,8 @@ use crate::transaction::objects::{
TransactionVersion::THREE,
false,
false;
<<<<<<< HEAD
"Native: Legacy contract. Execute execution mode: block info should be as usual. Transaction
V3."
||||||| 91889fd5e
"Native: Legacy contract. Execute execution mode: block info should be as usual. Transaction
V3."
=======
"Native: Legacy contract. Execute execution mode: block info should be as usual. Transaction V3."
>>>>>>> origin/main-v0.13.4
)
)]
#[cfg_attr(
Expand Down
106 changes: 0 additions & 106 deletions crates/blockifier/src/execution/syscalls/syscall_tests/out_of_gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,109 +57,3 @@ fn test_total_tx_limits_less_than_max_sierra_gas() {
<= MAX_POSSIBLE_SIERRA_GAS
);
}
<<<<<<< HEAD

// TODO(AvivG): move this test to Transaction executor

// #[cfg(feature = "cairo_native")]
// #[cfg(feature = "cairo_native")]
// use crate::context::ChainInfo;
// #[cfg(feature = "cairo_native")]
// use crate::test_utils::initial_test_state::test_state;
// #[cfg(feature = "cairo_native")]
// use crate::test_utils::BALANCE;
// #[rstest::rstest]
// #[case(MAX_POSSIBLE_SIERRA_GAS, MAX_POSSIBLE_SIERRA_GAS - 2681170910)]
// #[case(MAX_POSSIBLE_SIERRA_GAS / 10, 81886490)]
// #[case(MAX_POSSIBLE_SIERRA_GAS / 100, 8190940)]
// #[case(MAX_POSSIBLE_SIERRA_GAS / 1000, 822890)]
// #[case(MAX_POSSIBLE_SIERRA_GAS / 10000, 85440)]
// #[case(MAX_POSSIBLE_SIERRA_GAS / 100000, 12340)]
// #[case(MAX_POSSIBLE_SIERRA_GAS / 1000000, 0)]
// #[case(350, 0)]
// #[case(35, 0)]
// #[case(0, 0)]
// /// Tests that Native can handle deep recursion calls without overflowing the stack.
// /// Note that the recursive function must be complicated, since the compiler might transform
// /// simple recursions into loops. The tested function was manually tested with higher gas and
// /// reached stack overflow.
// ///
// /// Also, there is no need to test the VM here since it doesn't use the stack.
// fn test_stack_overflow(#[case] initial_gas: u64, #[case] gas_consumed: u64) {
// let test_contract =
// FeatureContract::TestContract(CairoVersion::Cairo1(RunnableCairo1::Native)); let mut state =
// test_state(&ChainInfo::create_for_testing(), BALANCE, &[(test_contract, 1)]);

// let depth = felt!(1000000_u128);
// let entry_point_call = CallEntryPoint {
// calldata: calldata![depth],
// entry_point_selector: selector_from_name("test_stack_overflow"),
// initial_gas,
// ..trivial_external_entry_point_new(test_contract)
// };
// let call_info = entry_point_call.execute_directly(&mut state).unwrap();
// assert_eq!(
// call_info.execution,
// CallExecution {
// // 'Out of gas'
// retdata: retdata![felt!["0x4f7574206f6620676173"]],
// gas_consumed,
// failed: true,
// ..Default::default()
// }
// );
// }
||||||| 91889fd5e

// TODO (AvivG) move this test to Transaction executor

// #[cfg(feature = "cairo_native")]
// #[cfg(feature = "cairo_native")]
// use crate::context::ChainInfo;
// #[cfg(feature = "cairo_native")]
// use crate::test_utils::initial_test_state::test_state;
// #[cfg(feature = "cairo_native")]
// use crate::test_utils::BALANCE;
// #[rstest::rstest]
// #[case(MAX_POSSIBLE_SIERRA_GAS, MAX_POSSIBLE_SIERRA_GAS - 2681170910)]
// #[case(MAX_POSSIBLE_SIERRA_GAS / 10, 81886490)]
// #[case(MAX_POSSIBLE_SIERRA_GAS / 100, 8190940)]
// #[case(MAX_POSSIBLE_SIERRA_GAS / 1000, 822890)]
// #[case(MAX_POSSIBLE_SIERRA_GAS / 10000, 85440)]
// #[case(MAX_POSSIBLE_SIERRA_GAS / 100000, 12340)]
// #[case(MAX_POSSIBLE_SIERRA_GAS / 1000000, 0)]
// #[case(350, 0)]
// #[case(35, 0)]
// #[case(0, 0)]
// /// Tests that Native can handle deep recursion calls without overflowing the stack.
// /// Note that the recursive function must be complicated, since the compiler might transform
// /// simple recursions into loops. The tested function was manually tested with higher gas and
// /// reached stack overflow.
// ///
// /// Also, there is no need to test the VM here since it doesn't use the stack.
// fn test_stack_overflow(#[case] initial_gas: u64, #[case] gas_consumed: u64) {
// let test_contract =
// FeatureContract::TestContract(CairoVersion::Cairo1(RunnableCairo1::Native)); let mut state =
// test_state(&ChainInfo::create_for_testing(), BALANCE, &[(test_contract, 1)]);

// let depth = felt!(1000000_u128);
// let entry_point_call = CallEntryPoint {
// calldata: calldata![depth],
// entry_point_selector: selector_from_name("test_stack_overflow"),
// initial_gas,
// ..trivial_external_entry_point_new(test_contract)
// };
// let call_info = entry_point_call.execute_directly(&mut state).unwrap();
// assert_eq!(
// call_info.execution,
// CallExecution {
// // 'Out of gas'
// retdata: retdata![felt!["0x4f7574206f6620676173"]],
// gas_consumed,
// failed: true,
// ..Default::default()
// }
// );
// }
=======
>>>>>>> origin/main-v0.13.4
136 changes: 0 additions & 136 deletions crates/blockifier/src/state/global_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,139 +48,3 @@ pub enum CachedCairoNative {
Compiled(NativeCompiledClassV1),
CompilationFailed(CompiledClassV1),
}

<<<<<<< HEAD
#[derive(Clone)]
pub struct ContractCaches {
pub casm_cache: GlobalContractCache<CachedCasm>,
#[cfg(feature = "cairo_native")]
pub native_cache: GlobalContractCache<CachedCairoNative>,
}

impl ContractCaches {
pub fn get_casm(&self, class_hash: &ClassHash) -> Option<CachedCasm> {
self.casm_cache.get(class_hash)
}

pub fn set_casm(&self, class_hash: ClassHash, compiled_class: CachedCasm) {
self.casm_cache.set(class_hash, compiled_class);
}

#[cfg(feature = "cairo_native")]
pub fn get_native(&self, class_hash: &ClassHash) -> Option<CachedCairoNative> {
self.native_cache.get(class_hash)
}

#[cfg(feature = "cairo_native")]
pub fn set_native(&self, class_hash: ClassHash, contract_executor: CachedCairoNative) {
self.native_cache.set(class_hash, contract_executor);
}

pub fn new(cache_size: usize) -> Self {
Self {
casm_cache: GlobalContractCache::new(cache_size),
#[cfg(feature = "cairo_native")]
native_cache: GlobalContractCache::new(cache_size),
}
}

pub fn clear(&mut self) {
self.casm_cache.clear();
#[cfg(feature = "cairo_native")]
self.native_cache.clear();
}
}
||||||| 91889fd5e
pub const GLOBAL_CONTRACT_CACHE_SIZE_FOR_TEST: usize = 600;

impl<T: Clone> GlobalContractCache<T> {
/// Locks the cache for atomic access. Although conceptually shared, writing to this cache is
/// only possible for one writer at a time.
pub fn lock(&self) -> LockedClassCache<'_, T> {
self.0.lock().expect("Global contract cache is poisoned.")
}

pub fn get(&self, class_hash: &ClassHash) -> Option<T> {
self.lock().cache_get(class_hash).cloned()
}

pub fn set(&self, class_hash: ClassHash, contract_class: T) {
self.lock().cache_set(class_hash, contract_class);
}

pub fn clear(&mut self) {
self.lock().cache_clear();
}

pub fn new(cache_size: usize) -> Self {
Self(Arc::new(Mutex::new(ContractLRUCache::<T>::with_size(cache_size))))
}
}

#[derive(Clone)]
pub struct ContractCaches {
pub casm_cache: GlobalContractCache<CachedCasm>,
#[cfg(feature = "cairo_native")]
pub native_cache: GlobalContractCache<CachedCairoNative>,
}

impl ContractCaches {
pub fn get_casm(&self, class_hash: &ClassHash) -> Option<CachedCasm> {
self.casm_cache.get(class_hash)
}

pub fn set_casm(&self, class_hash: ClassHash, compiled_class: CachedCasm) {
self.casm_cache.set(class_hash, compiled_class);
}

#[cfg(feature = "cairo_native")]
pub fn get_native(&self, class_hash: &ClassHash) -> Option<CachedCairoNative> {
self.native_cache.get(class_hash)
}

#[cfg(feature = "cairo_native")]
pub fn set_native(&self, class_hash: ClassHash, contract_executor: CachedCairoNative) {
self.native_cache.set(class_hash, contract_executor);
}

pub fn new(cache_size: usize) -> Self {
Self {
casm_cache: GlobalContractCache::new(cache_size),
#[cfg(feature = "cairo_native")]
native_cache: GlobalContractCache::new(cache_size),
}
}

pub fn clear(&mut self) {
self.casm_cache.clear();
#[cfg(feature = "cairo_native")]
self.native_cache.clear();
}
}
=======
pub const GLOBAL_CONTRACT_CACHE_SIZE_FOR_TEST: usize = 600;

impl<T: Clone> GlobalContractCache<T> {
/// Locks the cache for atomic access. Although conceptually shared, writing to this cache is
/// only possible for one writer at a time.
pub fn lock(&self) -> LockedClassCache<'_, T> {
self.0.lock().expect("Global contract cache is poisoned.")
}

pub fn get(&self, class_hash: &ClassHash) -> Option<T> {
self.lock().cache_get(class_hash).cloned()
}

pub fn set(&self, class_hash: ClassHash, contract_class: T) {
self.lock().cache_set(class_hash, contract_class);
}

pub fn clear(&mut self) {
self.lock().cache_clear();
}

pub fn new(cache_size: usize) -> Self {
Self(Arc::new(Mutex::new(ContractLRUCache::<T>::with_size(cache_size))))
}
}
>>>>>>> origin/main-v0.13.4
4 changes: 0 additions & 4 deletions crates/papyrus_state_reader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@ workspace = true

[dependencies]
blockifier.workspace = true
<<<<<<< HEAD
cairo-lang-starknet-classes.workspace = true
||||||| 91889fd5e
=======
log.workspace = true
>>>>>>> origin/main-v0.13.4
papyrus_storage.workspace = true
starknet-types-core.workspace = true
starknet_api.workspace = true
Expand Down
Loading

0 comments on commit 6abcbf1

Please sign in to comment.