@@ -11,7 +11,7 @@ use blockifier::execution::contract_class::{
1111use blockifier:: fee:: fee_utils:: get_fee_by_gas_vector;
1212use blockifier:: state:: cached_state:: { self , TransactionalState } ;
1313use blockifier:: state:: state_api:: { StateReader , UpdatableState } ;
14- use blockifier:: state:: stateful_compression:: { allocate_aliases_in_storage, compress } ;
14+ use blockifier:: state:: stateful_compression:: allocate_aliases_in_storage;
1515use blockifier:: transaction:: account_transaction:: {
1616 AccountTransaction , ExecutionFlags as BlockifierExecutionFlags ,
1717} ;
@@ -499,18 +499,32 @@ pub fn block_context_from_envs(
499499 BlockContext :: new ( block_info, chain_info, versioned_constants, BouncerConfig :: max ( ) )
500500}
501501
502- pub ( super ) fn state_update_from_cached_state ( state : & CachedState < ' _ > ) -> StateUpdatesWithClasses {
503- let alias_contract_address = contract_address ! ( ALIAS_CONTRACT_ADDRESS ) ;
504- allocate_aliases_in_storage ( & mut state. inner . lock ( ) . cached_state , alias_contract_address)
505- . unwrap ( ) ;
502+ pub ( super ) fn state_update_from_cached_state (
503+ state : & CachedState < ' _ > ,
504+ stateful_compression : bool ,
505+ ) -> StateUpdatesWithClasses {
506+ let state_diff = if stateful_compression {
507+ let mut state_lock = state. inner . lock ( ) ;
506508
507- let state_diff = state . inner . lock ( ) . cached_state . to_state_diff ( ) . unwrap ( ) . state_maps ;
508- let state_diff =
509- compress ( & state_diff , & state . inner . lock ( ) . cached_state , alias_contract_address ) ;
509+ let alias_contract_address = contract_address ! ( ALIAS_CONTRACT_ADDRESS ) ;
510+ allocate_aliases_in_storage ( & mut state_lock . cached_state , alias_contract_address )
511+ . expect ( "failed to allocated aliases" ) ;
510512
511- assert ! ( state_diff. is_ok( ) , "failed to compress state diff" ) ;
513+ #[ cfg( debug_assertions) ]
514+ {
515+ use blockifier:: state:: stateful_compression:: compress;
512516
513- let state_diff = state. inner . lock ( ) . cached_state . to_state_diff ( ) . unwrap ( ) . state_maps ;
517+ let state_diff = state_lock. cached_state . to_state_diff ( ) . unwrap ( ) . state_maps ;
518+ let compressed_state_diff =
519+ compress ( & state_diff, & state_lock. cached_state , alias_contract_address) ;
520+
521+ debug_assert ! ( compressed_state_diff. is_ok( ) , "failed to compress state diff" ) ;
522+ }
523+
524+ state_lock. cached_state . to_state_diff ( ) . unwrap ( ) . state_maps
525+ } else {
526+ state. inner . lock ( ) . cached_state . to_state_diff ( ) . unwrap ( ) . state_maps
527+ } ;
514528
515529 let mut declared_contract_classes: BTreeMap <
516530 katana_primitives:: class:: ClassHash ,
0 commit comments