Skip to content

Commit

Permalink
Renamed feature from full_visited_pcs to
Browse files Browse the repository at this point in the history
`vector_of_visited_program_counters`.
  • Loading branch information
Eagle941 committed Aug 11, 2024
1 parent 5d79056 commit d6e2185
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion crates/blockifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ workspace = true

[features]
concurrency = []
full_visited_pcs = []
vector_of_visited_program_counters = []
jemalloc = ["dep:tikv-jemallocator"]
testing = ["rand", "rstest"]

Expand Down
4 changes: 1 addition & 3 deletions crates/blockifier/src/blockifier/transaction_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ 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,
};
use crate::state::cached_state::{CachedState, CommitmentStateDiff, TransactionalState};
use crate::state::errors::StateError;
use crate::state::state_api::StateReader;
use crate::transaction::errors::TransactionExecutionError;
Expand Down
4 changes: 2 additions & 2 deletions crates/blockifier/src/execution/entry_point_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ fn register_visited_pcs(
bytecode_length: usize,
) -> EntryPointExecutionResult<()> {
fn add_element(pcs: &mut Pcs, element: usize) {
#[cfg(not(feature = "full_visited_pcs"))]
#[cfg(not(feature = "vector_of_visited_program_counters"))]
pcs.insert(element);

#[cfg(feature = "full_visited_pcs")]
#[cfg(feature = "vector_of_visited_program_counters")]
pcs.push(element);
}
let mut class_visited_pcs = Pcs::new();
Expand Down
7 changes: 6 additions & 1 deletion crates/blockifier/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
// 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"))]
#![cfg(any(
target_pointer_width = "16",
target_pointer_width = "32",
target_pointer_width = "64",
target_pointer_width = "128"
))]

#[cfg(feature = "jemalloc")]
// Override default allocator.
Expand Down
16 changes: 8 additions & 8 deletions crates/blockifier/src/state/cached_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ mod test;

pub type ContractClassMapping = HashMap<ClassHash, ContractClass>;

#[cfg(not(feature = "full_visited_pcs"))]
#[cfg(not(feature = "vector_of_visited_program_counters"))]
pub type Pcs = HashSet<usize>;

#[cfg(feature = "full_visited_pcs")]
#[cfg(feature = "vector_of_visited_program_counters")]
pub type Pcs = Vec<usize>;

#[cfg(not(feature = "full_visited_pcs"))]
#[cfg(not(feature = "vector_of_visited_program_counters"))]
pub type VisitedPcs = HashMap<ClassHash, Pcs>;

#[cfg(feature = "full_visited_pcs")]
#[cfg(feature = "vector_of_visited_program_counters")]
pub type VisitedPcs = HashMap<ClassHash, Vec<Pcs>>;

/// Caches read and write requests.
Expand Down Expand Up @@ -72,12 +72,12 @@ impl<S: StateReader> CachedState<S> {
}

pub fn get_set_visited_pcs(&self, class_hash: &ClassHash) -> HashSet<usize> {
#[cfg(not(feature = "full_visited_pcs"))]
#[cfg(not(feature = "vector_of_visited_program_counters"))]
fn from_set(class_hash: &ClassHash, visited_pcs: &VisitedPcs) -> HashSet<usize> {
return visited_pcs.get(class_hash).unwrap().clone();
}

#[cfg(feature = "full_visited_pcs")]
#[cfg(feature = "vector_of_visited_program_counters")]
fn from_set(class_hash: &ClassHash, visited_pcs: &VisitedPcs) -> HashSet<usize> {
let class_visited_pcs = visited_pcs.get(class_hash).unwrap();
let mut visited_pcs_set: HashSet<usize> = HashSet::new();
Expand Down Expand Up @@ -307,12 +307,12 @@ impl<S: StateReader> State for CachedState<S> {
}

fn add_visited_pcs(&mut self, class_hash: ClassHash, pcs: &Pcs) {
#[cfg(not(feature = "full_visited_pcs"))]
#[cfg(not(feature = "vector_of_visited_program_counters"))]
fn from_set(visited_pcs: &mut VisitedPcs, class_hash: ClassHash, pcs: &Pcs) {
visited_pcs.entry(class_hash).or_default().extend(pcs);
}

#[cfg(feature = "full_visited_pcs")]
#[cfg(feature = "vector_of_visited_program_counters")]
fn from_set(visited_pcs: &mut VisitedPcs, class_hash: ClassHash, pcs: &Pcs) {
visited_pcs.entry(class_hash).or_default().push(pcs.to_vec());
}
Expand Down
7 changes: 6 additions & 1 deletion crates/native_blockifier/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
// The blockifier crate supports only these specific architectures.
#![cfg(any(target_pointer_width = "16", target_pointer_width = "32", target_pointer_width = "64"))]
#![cfg(any(
target_pointer_width = "16",
target_pointer_width = "32",
target_pointer_width = "64",
target_pointer_width = "128"
))]

pub mod errors;
pub mod py_block_executor;
Expand Down

0 comments on commit d6e2185

Please sign in to comment.