Skip to content

Commit

Permalink
fix more conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoni-Starkware committed Feb 6, 2025
1 parent 6abcbf1 commit ba27928
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
},
"builtin_gas_costs": {
"range_check": 70,
"range_check96": 56,
"keccak": 136189,
"pedersen": 4050,
"bitwise": 583,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ use rstest_reuse::apply;
use starknet_api::abi::abi_utils::selector_from_name;
use starknet_api::calldata;

use crate::blockifier_versioned_constants::BuiltinGasCosts;
use crate::context::{BlockContext, ChainInfo};
use crate::execution::entry_point::CallEntryPoint;
use crate::test_utils::contracts::FeatureContract;
use crate::test_utils::initial_test_state::test_state;
use crate::test_utils::test_templates::runnable_version;
use crate::test_utils::{trivial_external_entry_point_new, CairoVersion, RunnableCairo1, BALANCE};
use crate::versioned_constants::BuiltinGasCosts;

const TESTED_BUILTIN_GAS_COST: u64 = u64::pow(10, 7);

Expand Down
22 changes: 14 additions & 8 deletions crates/blockifier/src/state/contract_class_manager.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub const DEFAULT_COMPILATION_REQUEST_CHANNEL_SIZE: usize = 2000;

#[cfg(feature = "cairo_native")]
pub type ContractClassManager = crate::state::native_class_manager::NativeClassManager;
pub use crate::state::native_class_manager::NativeClassManager as ContractClassManager;

#[cfg(not(feature = "cairo_native"))]
pub mod trivial_class_manager {
Expand All @@ -13,32 +13,38 @@ pub mod trivial_class_manager {
use crate::execution::contract_class::RunnableCompiledClass;
use crate::state::global_cache::{CachedClass, RawClassCache};

pub type ContractClassManager = RawClassCache;
pub struct TrivialClassManager {
cache: RawClassCache,
}

// Trivial implementation of the class manager for Native-less projects.
impl ContractClassManager {
impl TrivialClassManager {
pub fn start(config: ContractClassManagerConfig) -> Self {
assert!(
!config.cairo_native_run_config.run_cairo_native,
"Cairo Native feature is off."
);
Self::new(config.contract_cache_size)
Self { cache: RawClassCache::new(config.contract_cache_size) }
}

pub fn get_runnable(&self, class_hash: &ClassHash) -> Option<RunnableCompiledClass> {
Some(self.get(class_hash)?.to_runnable())
Some(self.cache.get(class_hash)?.to_runnable())
}

pub fn set_and_compile(&self, class_hash: ClassHash, compiled_class: CachedClass) {
self.set(class_hash, compiled_class);
self.cache.set(class_hash, compiled_class);
}

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

#[cfg(any(feature = "testing", test))]
pub fn get_cache_size(&self) -> usize {
self.lock().cache_size()
self.cache.lock().cache_size()
}
}
}

#[cfg(not(feature = "cairo_native"))]
pub use trivial_class_manager::ContractClassManager;
pub use trivial_class_manager::TrivialClassManager as ContractClassManager;
1 change: 0 additions & 1 deletion crates/blockifier/src/state/global_cache.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::sync::Arc;

use starknet_api::class_cache::GlobalContractCache;
use starknet_api::core::ClassHash;
use starknet_api::state::SierraContractClass;

use crate::execution::contract_class::{CompiledClassV0, CompiledClassV1, RunnableCompiledClass};
Expand Down
6 changes: 1 addition & 5 deletions crates/papyrus_state_reader/src/papyrus_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@ use blockifier::state::contract_class_manager::ContractClassManager;
use blockifier::state::errors::{couple_casm_and_sierra, StateError};
use blockifier::state::global_cache::CachedClass;
use blockifier::state::state_api::{StateReader, StateResult};
<<<<<<< HEAD
use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass;
||||||| 91889fd5e
=======
use log;
>>>>>>> origin/main-v0.13.4
use papyrus_storage::compiled_class::CasmStorageReader;
use papyrus_storage::db::RO;
use papyrus_storage::state::StateStorageReader;
Expand Down Expand Up @@ -171,7 +167,7 @@ impl StateReader for PapyrusReader {
// Access the cache again in case the class was compiled.
Ok(self.contract_class_manager.get_runnable(&class_hash).unwrap_or_else(|| {
// Edge case that should not be happen if the cache size is big enough.
// TODO(Yoni) consider having an atomic set-and-get.
// TODO(Yoni): consider having an atomic set-and-get.
log::error!("Class is missing immediately after being cached.");
cached_class.to_runnable()
}))
Expand Down

0 comments on commit ba27928

Please sign in to comment.