Skip to content

Commit

Permalink
Merge pull request #1595 from eqlabs/krisztian/disable-global-class-c…
Browse files Browse the repository at this point in the history
…ache

fix(executor): disable global class cache
  • Loading branch information
kkovaacs committed Nov 29, 2023
2 parents b7ec709 + 88736d0 commit 5641434
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions crates/executor/src/execution_state.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
use super::state_reader::PathfinderStateReader;
use crate::{state_reader::LruCachedReader, IntoStarkFelt};
use crate::IntoStarkFelt;
use anyhow::Context;
use blockifier::{
block_context::BlockContext,
state::{cached_state::CachedState, state_api::State},
state::{
cached_state::{CachedState, GlobalContractCache},
state_api::State,
},
};
use pathfinder_common::{BlockHeader, ChainId, StateUpdate};

Expand All @@ -18,10 +21,7 @@ pub struct ExecutionState<'tx> {
impl<'tx> ExecutionState<'tx> {
pub(super) fn starknet_state(
&mut self,
) -> anyhow::Result<(
CachedState<LruCachedReader<PathfinderStateReader<'_>>>,
BlockContext,
)> {
) -> anyhow::Result<(CachedState<PathfinderStateReader<'_>>, BlockContext)> {
let block_context = super::block_context::construct_block_context(self)?;

let block_number = if self.execute_on_parent_state {
Expand All @@ -35,7 +35,7 @@ impl<'tx> ExecutionState<'tx> {
block_number,
self.pending_state.is_some(),
);
let mut cached_state = LruCachedReader::new_cached_state(raw_reader)?;
let mut cached_state = CachedState::new(raw_reader, GlobalContractCache::default());

// Perform system contract updates if we are executing ontop of a parent block.
// Currently this is only the block hash from 10 blocks ago.
Expand Down
6 changes: 3 additions & 3 deletions crates/executor/src/state_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ where
R: StateReader,
{
/// Build a `CachedState` on top of an `LruCachedReader`, sharing the same underlying cache.
pub fn new_cached_state(inner_reader: R) -> anyhow::Result<CachedState<LruCachedReader<R>>> {
pub fn _new_cached_state(inner_reader: R) -> anyhow::Result<CachedState<LruCachedReader<R>>> {
// `CachedState` already has a [move_classes_to_global_cache](https://docs.rs/blockifier/0.3.0-rc0/blockifier/state/cached_state/struct.CachedState.html#method.move_classes_to_global_cache)
// method that we might want to use instead, but relying on it would make this cache much
// less self-contained as these calls would have to be made in various places.
// One of the reasons for this is that we can't wrap the `CachedReader` in another layer of
// the `State` trait as `blockifier` explicitly requires a `CachedReader` in the signature
// of some methods we use.
let reader = Self::new(inner_reader)?;
let reader = Self::_new(inner_reader)?;
let cache = reader.compiled_class_cache.clone();
Ok(CachedState::new(reader, cache))
}

fn new(inner_reader: R) -> anyhow::Result<Self> {
fn _new(inner_reader: R) -> anyhow::Result<Self> {
lazy_static::lazy_static!(
static ref CONTRACT_CACHE: GlobalContractCache = {
let inner = SizedCache::with_size(128);
Expand Down

0 comments on commit 5641434

Please sign in to comment.