diff --git a/crates/blockifier/src/blockifier/transaction_executor.rs b/crates/blockifier/src/blockifier/transaction_executor.rs index 63887ff9d28..af9d216e1bc 100644 --- a/crates/blockifier/src/blockifier/transaction_executor.rs +++ b/crates/blockifier/src/blockifier/transaction_executor.rs @@ -168,7 +168,12 @@ impl TransactionExecutor { log::debug!("Final block weights: {:?}.", self.bouncer.get_accumulated_weights()); Ok(( - self.block_state.as_mut().expect(BLOCK_STATE_ACCESS_ERR).to_state_diff()?.into(), + self.block_state + .as_mut() + .expect(BLOCK_STATE_ACCESS_ERR) + .to_state_diff()? + .state_maps + .into(), visited_segments, *self.bouncer.get_accumulated_weights(), )) diff --git a/crates/blockifier/src/concurrency/worker_logic.rs b/crates/blockifier/src/concurrency/worker_logic.rs index d24d33223d4..b66de3b3de2 100644 --- a/crates/blockifier/src/concurrency/worker_logic.rs +++ b/crates/blockifier/src/concurrency/worker_logic.rs @@ -139,7 +139,7 @@ impl<'a, S: StateReader> WorkerExecutor<'a, S> { let execution_output_inner = match execution_result { Ok(_) => { let tx_reads_writes = transactional_state.cache.take(); - let writes = tx_reads_writes.to_state_diff(); + let writes = tx_reads_writes.to_state_diff().state_maps; let contract_classes = transactional_state.class_hash_to_class.take(); let visited_pcs = transactional_state.visited_pcs; // The versioned state does not carry the visited PCs. diff --git a/crates/blockifier/src/state/cached_state.rs b/crates/blockifier/src/state/cached_state.rs index 52b8435eb5d..f0b903efca1 100644 --- a/crates/blockifier/src/state/cached_state.rs +++ b/crates/blockifier/src/state/cached_state.rs @@ -47,7 +47,7 @@ impl CachedState { /// Returns the state diff resulting from the performed writes, with respect to the parent /// state. - pub fn to_state_diff(&mut self) -> StateResult { + pub fn to_state_diff(&mut self) -> StateResult { self.update_initial_values_of_write_only_access()?; Ok(self.cache.borrow().to_state_diff()) } @@ -55,7 +55,7 @@ impl CachedState { // TODO(Yoni, 1/8/2024): remove this function. /// Returns the state changes made on this state. pub fn get_actual_state_changes(&mut self) -> StateResult { - Ok(StateChanges { state_maps: self.to_state_diff()? }) + self.to_state_diff() } pub fn update_cache( @@ -399,8 +399,9 @@ pub struct StateCache { impl StateCache { /// Returns the state diff resulting from the performed writes, with respect to the initial /// reads. Assumes (and enforces) all initial reads are cached. - pub fn to_state_diff(&self) -> StateMaps { - self.writes.diff(&self.initial_reads) + pub fn to_state_diff(&self) -> StateChanges { + let state_maps = self.writes.diff(&self.initial_reads); + StateChanges { state_maps } } fn declare_contract(&mut self, class_hash: ClassHash) { diff --git a/crates/blockifier/src/state/cached_state_test.rs b/crates/blockifier/src/state/cached_state_test.rs index 9d32af747b0..f260250115d 100644 --- a/crates/blockifier/src/state/cached_state_test.rs +++ b/crates/blockifier/src/state/cached_state_test.rs @@ -286,7 +286,7 @@ fn cached_state_state_diff_conversion() { address_to_nonce: IndexMap::from_iter([(contract_address2, nonce!(1_u64))]), }; - assert_eq!(expected_state_diff, state.to_state_diff().unwrap().into()); + assert_eq!(expected_state_diff, state.to_state_diff().unwrap().state_maps.into()); } fn create_state_changes_for_test( diff --git a/crates/papyrus_execution/src/execution_utils.rs b/crates/papyrus_execution/src/execution_utils.rs index afec631cb14..45e45d16b8d 100644 --- a/crates/papyrus_execution/src/execution_utils.rs +++ b/crates/papyrus_execution/src/execution_utils.rs @@ -123,7 +123,8 @@ pub fn induced_state_diff( transactional_state: &mut CachedState>>, deprecated_declared_class_hash: Option, ) -> ExecutionResult { - let blockifier_state_diff = CommitmentStateDiff::from(transactional_state.to_state_diff()?); + let blockifier_state_diff = + CommitmentStateDiff::from(transactional_state.to_state_diff()?.state_maps); // Determine which contracts were deployed and which were replaced by comparing their // previous class hash (default value suggests it didn't exist before). let mut deployed_contracts = IndexMap::new();