Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(executor): disable global class cache #1595

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading