diff --git a/crates/native_blockifier/src/py_block_executor.rs b/crates/native_blockifier/src/py_block_executor.rs index 7bf28040a1a..83d190c0bb7 100644 --- a/crates/native_blockifier/src/py_block_executor.rs +++ b/crates/native_blockifier/src/py_block_executor.rs @@ -305,7 +305,7 @@ impl PyBlockExecutor { previous_block_id: Option, py_block_info: PyBlockInfo, py_state_diff: PyStateDiff, - declared_class_hash_to_class: HashMap, + declared_class_hash_to_class: HashMap, deprecated_declared_class_hash_to_class: HashMap, ) -> NativeBlockifierResult<()> { self.storage.append_block( diff --git a/crates/native_blockifier/src/py_block_executor_test.rs b/crates/native_blockifier/src/py_block_executor_test.rs index 0f5b59426dd..0b875c50098 100644 --- a/crates/native_blockifier/src/py_block_executor_test.rs +++ b/crates/native_blockifier/src/py_block_executor_test.rs @@ -7,6 +7,7 @@ use cached::Cached; use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use pretty_assertions::assert_eq; use starknet_api::class_hash; +use starknet_api::state::ContractClass; use starknet_types_core::felt::Felt; use crate::py_block_executor::{PyBlockExecutor, PyOsConfig}; @@ -19,6 +20,7 @@ use crate::test_utils::MockStorage; fn global_contract_cache_update() { // Initialize executor and set a contract class on the state. let casm = CasmContractClass { compiler_version: "0.1.0".to_string(), ..Default::default() }; + let sierra = ContractClass::default(); let contract_class = RunnableContractClass::V1(ContractClassV1::try_from(casm.clone()).unwrap()); let class_hash = class_hash!("0x1"); @@ -38,7 +40,10 @@ fn global_contract_cache_update() { PyStateDiff::default(), HashMap::from([( class_hash.into(), - (PyFelt::from(1_u8), serde_json::to_string(&casm).unwrap()), + ( + serde_json::to_string(&sierra).unwrap(), + (PyFelt::from(1_u8), serde_json::to_string(&casm).unwrap()), + ), )]), HashMap::default(), ) diff --git a/crates/native_blockifier/src/storage.rs b/crates/native_blockifier/src/storage.rs index 50b3a7efa5d..dfae73cb17f 100644 --- a/crates/native_blockifier/src/storage.rs +++ b/crates/native_blockifier/src/storage.rs @@ -116,7 +116,7 @@ impl Storage for PapyrusStorage { previous_block_id: Option, py_block_info: PyBlockInfo, py_state_diff: PyStateDiff, - declared_class_hash_to_class: HashMap, + declared_class_hash_to_class: HashMap, deprecated_declared_class_hash_to_class: HashMap, ) -> NativeBlockifierResult<()> { log::debug!( @@ -167,7 +167,9 @@ impl Storage for PapyrusStorage { let mut declared_classes = IndexMap::::new(); let mut undeclared_casm_contracts = Vec::<(ClassHash, CasmContractClass)>::new(); - for (class_hash, (compiled_class_hash, raw_class)) in declared_class_hash_to_class { + for (class_hash, (raw_sierra, (compiled_class_hash, raw_casm))) in + declared_class_hash_to_class + { let class_hash = ClassHash(class_hash.0); let class_undeclared = self .reader() @@ -177,12 +179,13 @@ impl Storage for PapyrusStorage { .is_none(); if class_undeclared { + let sierra_contract_class: ContractClass = serde_json::from_str(&raw_sierra)?; declared_classes.insert( class_hash, - (CompiledClassHash(compiled_class_hash.0), ContractClass::default()), + (CompiledClassHash(compiled_class_hash.0), sierra_contract_class), ); - let contract_class: CasmContractClass = serde_json::from_str(&raw_class)?; - undeclared_casm_contracts.push((class_hash, contract_class)); + let casm_contract_class: CasmContractClass = serde_json::from_str(&raw_casm)?; + undeclared_casm_contracts.push((class_hash, casm_contract_class)); } } @@ -295,7 +298,7 @@ pub trait Storage { previous_block_id: Option, py_block_info: PyBlockInfo, py_state_diff: PyStateDiff, - declared_class_hash_to_class: HashMap, + declared_class_hash_to_class: HashMap, deprecated_declared_class_hash_to_class: HashMap, ) -> NativeBlockifierResult<()>; diff --git a/crates/native_blockifier/src/test_utils.rs b/crates/native_blockifier/src/test_utils.rs index 13a2626ecc4..e2d8fa72211 100644 --- a/crates/native_blockifier/src/test_utils.rs +++ b/crates/native_blockifier/src/test_utils.rs @@ -33,7 +33,7 @@ impl Storage for MockStorage { _py_state_diff: crate::py_state_diff::PyStateDiff, _declared_class_hash_to_class: HashMap< crate::py_utils::PyFelt, - (crate::py_utils::PyFelt, String), + (String, (crate::py_utils::PyFelt, String)), >, _deprecated_declared_class_hash_to_class: HashMap, ) -> NativeBlockifierResult<()> {