Skip to content

Commit

Permalink
fix frozen
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancoGiachetta committed Nov 29, 2024
1 parent 15307a2 commit 049873c
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 51 deletions.
68 changes: 25 additions & 43 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ serde_with = "3.11.0"
serde = "1.0.197"
cairo-native = "0.2.4"
# Sequencer Dependencies
starknet_api = { git = "https://github.com/lambdaclass/sequencer.git", branch = "update-main-2" } # main
blockifier = { git = "https://github.com/lambdaclass/sequencer.git", branch = "update-main-2", features = ["cairo_native"] } # main
starknet_gateway = { git = "https://github.com/lambdaclass/sequencer.git", branch = "update-main-2" } # main
blockifier_reexecution = { git = "https://github.com/lambdaclass/sequencer.git", branch = "update-main-2" } # main
# starknet_api = { git = "https://github.com/lambdaclass/sequencer.git", branch = "update-main-2" } # main
# blockifier = { git = "https://github.com/lambdaclass/sequencer.git", branch = "update-main-2", features = ["cairo_native"] } # main
# starknet_gateway = { git = "https://github.com/lambdaclass/sequencer.git", branch = "update-main-2" } # main
# blockifier_reexecution = { git = "https://github.com/lambdaclass/sequencer.git", branch = "update-main-2" } # main

starknet_api = { path = "../sequencer/crates/starknet_api" } # main
blockifier = { path = "../sequencer/crates/blockifier", features = ["cairo_native"] } # main
starknet_gateway = { path = "../sequencer/crates/starknet_gateway" } # main
blockifier_reexecution = { path = "../sequencer/crates/blockifier_reexecution" } # main

# [patch.'https://github.com/lambdaclass/cairo_native']
# cairo-native = { git = "https://github.com/lambdaclass//cairo_native.git", rev = "76e83965d3bf1252eb6c68200a3accd5fd1ec004" }
5 changes: 5 additions & 0 deletions rpc-state-reader/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,14 @@ impl StateReader for RpcStateReader {
}

fn get_compiled_class(&self, class_hash: ClassHash) -> StateResult<RunnableCompiledClass> {
dbg!("ENTERED_GET_COMPILED_CLASS");
Ok(match self.get_contract_class(&class_hash)? {
SNContractClass::Legacy(compressed_legacy_cc) => {
dbg!("ENTERED_LEGACY");
compile_legacy_cc(compressed_legacy_cc)
}
SNContractClass::Sierra(flattened_sierra_cc) => {
dbg!("ENTERED_SIERRA");
compile_sierra_cc(flattened_sierra_cc, class_hash)
}
})
Expand Down Expand Up @@ -350,7 +353,9 @@ fn compile_sierra_cc(

RunnableCompiledClass::V1(casm_cc.try_into().unwrap())
} else {
dbg!("COMPILED_EXECUTOR");
let executor = utils::get_native_executor(&sierra_cc, class_hash);
dbg!("COMPILED_EXECUTOR_PASSED");
let casm = CasmContractClass::from_contract_class(sierra_cc, false, usize::MAX).unwrap();
let casm = CompiledClassV1::try_from(casm).unwrap();

Expand Down
9 changes: 5 additions & 4 deletions rpc-state-reader/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,10 @@ pub fn decode_reader(bytes: Vec<u8>) -> io::Result<String> {
pub fn get_native_executor(contract: &ContractClass, class_hash: ClassHash) -> AotContractExecutor {
let cache_lock = AOT_PROGRAM_CACHE.get_or_init(|| RwLock::new(HashMap::new()));

let executor = cache_lock.read().unwrap();
let executor = executor.get(&class_hash);
let executor = cache_lock.read().unwrap().get(&class_hash).map(Clone::clone);

match executor {
Some(executor) => executor.clone(),
Some(executor) => executor,
None => {
let mut cache = cache_lock.write().unwrap();
let path = PathBuf::from(format!(
Expand Down Expand Up @@ -122,7 +121,9 @@ pub fn get_native_executor(contract: &ContractClass, class_hash: ClassHash) -> A
executor
};

cache.insert(class_hash, executor).unwrap()
cache.insert(class_hash, executor.clone());

executor
}
}
}

0 comments on commit 049873c

Please sign in to comment.