diff --git a/crates/blockifier/src/blockifier/transaction_executor.rs b/crates/blockifier/src/blockifier/transaction_executor.rs index 1bf6b62c9a..204d139934 100644 --- a/crates/blockifier/src/blockifier/transaction_executor.rs +++ b/crates/blockifier/src/blockifier/transaction_executor.rs @@ -13,9 +13,9 @@ use crate::bouncer::{Bouncer, BouncerWeights}; #[cfg(feature = "concurrency")] use crate::concurrency::worker_logic::WorkerExecutor; use crate::context::BlockContext; -use crate::state::cached_state::{ - CachedState, CommitmentStateDiff, TransactionalState, VisitedPcs, -}; +#[cfg(feature = "concurrency")] +use crate::state::cached_state::VisitedPcs; +use crate::state::cached_state::{CachedState, CommitmentStateDiff, TransactionalState}; use crate::state::errors::StateError; use crate::state::state_api::StateReader; use crate::transaction::errors::TransactionExecutionError; diff --git a/crates/blockifier/src/lib.rs b/crates/blockifier/src/lib.rs index 686c46b983..e5e1450a58 100644 --- a/crates/blockifier/src/lib.rs +++ b/crates/blockifier/src/lib.rs @@ -2,12 +2,7 @@ // length to pointer type ([not necessarily true](https://github.com/rust-lang/rust/issues/65473), // but it is a reasonable assumption for now), this attribute protects against potential overflow // when converting usize to u128. -#![cfg(any( - target_pointer_width = "16", - target_pointer_width = "32", - target_pointer_width = "64", - target_pointer_width = "128" -))] +#![cfg(any(target_pointer_width = "16", target_pointer_width = "32", target_pointer_width = "64"))] #[cfg(feature = "jemalloc")] // Override default allocator. diff --git a/crates/blockifier/src/state/cached_state.rs b/crates/blockifier/src/state/cached_state.rs index e68ff1038c..0f030320f4 100644 --- a/crates/blockifier/src/state/cached_state.rs +++ b/crates/blockifier/src/state/cached_state.rs @@ -44,7 +44,11 @@ pub struct CachedState { // Using interior mutability to update caches during `State`'s immutable getters. pub(crate) cache: RefCell, pub(crate) class_hash_to_class: RefCell, - /// A map from class hash to the set of PC values that were visited in the class. + // A map from class hash the PC values that were visited in the class. + // + // If the feature `vector_of_visited_program_counters` is selected, `visited_pcs` contains the + // full vector of visited program counters for each class hash call. Otherwise, it contains + // the just the set of visited program counters. pub visited_pcs: VisitedPcs, } @@ -71,6 +75,7 @@ impl CachedState { Ok(self.to_state_diff()?.into()) } + /// Returns the set of visited program counters given a `class_hash`. pub fn get_set_visited_pcs(&self, class_hash: &ClassHash) -> HashSet { #[cfg(not(feature = "vector_of_visited_program_counters"))] fn from_set(class_hash: &ClassHash, visited_pcs: &VisitedPcs) -> HashSet { @@ -105,8 +110,28 @@ impl CachedState { } pub fn update_visited_pcs_cache(&mut self, visited_pcs: &VisitedPcs) { + #[cfg(not(feature = "vector_of_visited_program_counters"))] + fn from_set( + cached_state: &mut CachedState, + class_hash: &ClassHash, + visited_pcs: &Pcs, + ) { + cached_state.add_visited_pcs(*class_hash, visited_pcs); + } + + #[cfg(feature = "vector_of_visited_program_counters")] + fn from_set( + cached_state: &mut CachedState, + class_hash: &ClassHash, + visited_pcs: &Vec>, + ) { + for pcs in visited_pcs { + cached_state.add_visited_pcs(*class_hash, pcs); + } + } + for (class_hash, class_visited_pcs) in visited_pcs { - self.visited_pcs.entry(*class_hash).or_default().extend(class_visited_pcs.clone()); + from_set(self, class_hash, class_visited_pcs); } } diff --git a/crates/native_blockifier/src/lib.rs b/crates/native_blockifier/src/lib.rs index 1ae8dd5464..54950bfb0b 100644 --- a/crates/native_blockifier/src/lib.rs +++ b/crates/native_blockifier/src/lib.rs @@ -1,10 +1,5 @@ // The blockifier crate supports only these specific architectures. -#![cfg(any( - target_pointer_width = "16", - target_pointer_width = "32", - target_pointer_width = "64", - target_pointer_width = "128" -))] +#![cfg(any(target_pointer_width = "16", target_pointer_width = "32", target_pointer_width = "64"))] pub mod errors; pub mod py_block_executor;