From ab2018fc4ab34dcfed5c2f2b4ec639b3c150f136 Mon Sep 17 00:00:00 2001 From: Pearson White Date: Thu, 19 Sep 2024 09:03:29 -0400 Subject: [PATCH] fixup: addressed review comments --- vm/rust/src/juno_state_reader.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/vm/rust/src/juno_state_reader.rs b/vm/rust/src/juno_state_reader.rs index 0f6ff4fead..f68516f630 100644 --- a/vm/rust/src/juno_state_reader.rs +++ b/vm/rust/src/juno_state_reader.rs @@ -7,10 +7,8 @@ use blockifier::{ state::state_api::{StateReader, StateResult}, }; use cached::{Cached, SizedCache}; +use cairo_native::executor::contract::ContractExecutor; use cairo_native::OptLevel; -use cairo_native:: - executor::contract::ContractExecutor -; use once_cell::sync::Lazy; use serde::Deserialize; use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce}; @@ -291,11 +289,11 @@ fn native_try_from_json_string( let sierra_contract_class: cairo_lang_starknet_classes::contract_class::ContractClass = serde_json::from_str(raw_contract_class)?; let sierra_program = sierra_contract_class.extract_sierra_program()?; - let executor = ContractExecutor::load(&library_output_path).unwrap_or({ + let executor = ContractExecutor::load(library_output_path).or_else(|_| { let executor = ContractExecutor::new(&sierra_program, OptLevel::Default)?; - executor.save(&library_output_path)?; - executor - }); + executor.save(library_output_path)?; + Ok::>(executor) + })?; let contract_executor = NativeContractClassV1::new(Arc::new(executor), sierra_contract_class)?; Ok(contract_executor) }