From 7d450f1dfb4ed18373012a488463da67ef6671cf Mon Sep 17 00:00:00 2001 From: AvivYossef-starkware Date: Wed, 30 Oct 2024 11:31:08 +0200 Subject: [PATCH 1/2] refactor(blockifier_reexecution): use custom macro for comparing state diff From 68a18f990ae5ec016eb33ef8afb50947b833f9c3 Mon Sep 17 00:00:00 2001 From: AvivYossef-starkware Date: Sun, 3 Nov 2024 11:58:14 +0200 Subject: [PATCH 2/2] fix(blockifier_reexecution): fix bug in get contract class --- .../src/state_reader/test_state_reader.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/crates/blockifier_reexecution/src/state_reader/test_state_reader.rs b/crates/blockifier_reexecution/src/state_reader/test_state_reader.rs index 252c4823ef..ec1e49461e 100644 --- a/crates/blockifier_reexecution/src/state_reader/test_state_reader.rs +++ b/crates/blockifier_reexecution/src/state_reader/test_state_reader.rs @@ -21,7 +21,7 @@ use starknet_api::state::StorageKey; use starknet_api::transaction::{Transaction, TransactionHash}; use starknet_core::types::ContractClass as StarknetContractClass; use starknet_gateway::config::RpcStateReaderConfig; -use starknet_gateway::errors::serde_err_to_state_err; +use starknet_gateway::errors::{serde_err_to_state_err, RPCStateReaderError}; use starknet_gateway::rpc_objects::{BlockHeader, GetBlockWithTxHashesParams, ResourcePrice}; use starknet_gateway::rpc_state_reader::RpcStateReader; use starknet_types_core::felt::Felt; @@ -357,10 +357,16 @@ impl ReexecutionStateReader for TestStateReader { "block_id": self.rpc_state_reader.block_id, "class_hash": class_hash.0.to_string(), }); - let contract_class: StarknetContractClass = serde_json::from_value( - self.rpc_state_reader.send_rpc_request("starknet_getClass", params.clone())?, - ) - .map_err(serde_err_to_state_err)?; + let raw_contract_class = + match self.rpc_state_reader.send_rpc_request("starknet_getClass", params.clone()) { + Err(RPCStateReaderError::ClassHashNotFound(_)) => { + return Err(StateError::UndeclaredClassHash(*class_hash)); + } + other_result => other_result, + }?; + + let contract_class: StarknetContractClass = + serde_json::from_value(raw_contract_class).map_err(serde_err_to_state_err)?; // Create a binding to avoid value being dropped. let mut dumper_binding = self.contract_class_mapping_dumper.lock().unwrap(); // If dumper exists, insert the contract class to the mapping.