@@ -11,7 +11,7 @@ use crate::blockifier::config::TransactionExecutorConfig;
1111use crate :: bouncer:: { Bouncer , BouncerWeights } ;
1212use crate :: concurrency:: worker_logic:: WorkerExecutor ;
1313use crate :: context:: BlockContext ;
14- use crate :: state:: cached_state:: { CachedState , CommitmentStateDiff , TransactionalState } ;
14+ use crate :: state:: cached_state:: { CachedState , CommitmentStateDiff , StateMaps , TransactionalState } ;
1515use crate :: state:: errors:: StateError ;
1616use crate :: state:: state_api:: { StateReader , StateResult } ;
1717use crate :: state:: stateful_compression:: { allocate_aliases_in_storage, compress, CompressionError } ;
@@ -27,6 +27,8 @@ pub mod transaction_executor_test;
2727pub const BLOCK_STATE_ACCESS_ERR : & str = "Error: The block state should be `Some`." ;
2828pub const DEFAULT_STACK_SIZE : usize = 60 * 1024 * 1024 ;
2929
30+ pub type TransactionExecutionOutput = ( TransactionExecutionInfo , StateMaps ) ;
31+
3032#[ derive( Debug , Error ) ]
3133pub enum TransactionExecutorError {
3234 #[ error( "Transaction cannot be added to the current block, block capacity reached." ) ]
@@ -103,7 +105,7 @@ impl<S: StateReader> TransactionExecutor<S> {
103105 pub fn execute (
104106 & mut self ,
105107 tx : & Transaction ,
106- ) -> TransactionExecutorResult < TransactionExecutionInfo > {
108+ ) -> TransactionExecutorResult < TransactionExecutionOutput > {
107109 let mut transactional_state = TransactionalState :: create_transactional (
108110 self . block_state . as_mut ( ) . expect ( BLOCK_STATE_ACCESS_ERR ) ,
109111 ) ;
@@ -114,16 +116,17 @@ impl<S: StateReader> TransactionExecutor<S> {
114116 tx. execute_raw ( & mut transactional_state, & self . block_context , concurrency_mode) ;
115117 match tx_execution_result {
116118 Ok ( tx_execution_info) => {
117- let tx_state_changes_keys =
118- transactional_state . get_actual_state_changes ( ) ? . state_maps . into_keys ( ) ;
119+ let state_diff = transactional_state . to_state_diff ( ) ? . state_maps ;
120+ let tx_state_changes_keys = state_diff . keys ( ) ;
119121 self . bouncer . try_update (
120122 & transactional_state,
121123 & tx_state_changes_keys,
122124 & tx_execution_info. summarize ( & self . block_context . versioned_constants ) ,
123125 & tx_execution_info. receipt . resources ,
124126 ) ?;
125127 transactional_state. commit ( ) ;
126- Ok ( tx_execution_info)
128+
129+ Ok ( ( tx_execution_info, state_diff) )
127130 }
128131 Err ( error) => {
129132 transactional_state. abort ( ) ;
@@ -132,14 +135,16 @@ impl<S: StateReader> TransactionExecutor<S> {
132135 }
133136 }
134137
135- pub fn execute_txs_sequentially_inner (
138+ fn execute_txs_sequentially_inner (
136139 & mut self ,
137140 txs : & [ Transaction ] ,
138- ) -> Vec < TransactionExecutorResult < TransactionExecutionInfo > > {
141+ ) -> Vec < TransactionExecutorResult < TransactionExecutionOutput > > {
139142 let mut results = Vec :: new ( ) ;
140143 for tx in txs {
141144 match self . execute ( tx) {
142- Ok ( tx_execution_info) => results. push ( Ok ( tx_execution_info) ) ,
145+ Ok ( ( tx_execution_info, state_diff) ) => {
146+ results. push ( Ok ( ( tx_execution_info, state_diff) ) )
147+ }
143148 Err ( TransactionExecutorError :: BlockFull ) => break ,
144149 Err ( error) => results. push ( Err ( error) ) ,
145150 }
@@ -196,6 +201,9 @@ impl<S: StateReader + Send + Sync> TransactionExecutor<S> {
196201 if !self . config . concurrency_config . enabled {
197202 log:: debug!( "Executing transactions sequentially." ) ;
198203 self . execute_txs_sequentially ( txs)
204+ . into_iter ( )
205+ . map ( |res| res. map ( |( tx_execution_info, _state_diff) | tx_execution_info) )
206+ . collect ( )
199207 } else {
200208 log:: debug!( "Executing transactions concurrently." ) ;
201209 let chunk_size = self . config . concurrency_config . chunk_size ;
@@ -228,10 +236,10 @@ impl<S: StateReader + Send + Sync> TransactionExecutor<S> {
228236 }
229237 }
230238
231- pub fn execute_txs_sequentially (
239+ fn execute_txs_sequentially (
232240 & mut self ,
233241 txs : & [ Transaction ] ,
234- ) -> Vec < TransactionExecutorResult < TransactionExecutionInfo > > {
242+ ) -> Vec < TransactionExecutorResult < TransactionExecutionOutput > > {
235243 #[ cfg( not( feature = "cairo_native" ) ) ]
236244 return self . execute_txs_sequentially_inner ( txs) ;
237245 #[ cfg( feature = "cairo_native" ) ]
@@ -261,7 +269,7 @@ impl<S: StateReader + Send + Sync> TransactionExecutor<S> {
261269 }
262270 }
263271
264- pub fn execute_chunk (
272+ fn execute_chunk (
265273 & mut self ,
266274 chunk : & [ Transaction ] ,
267275 ) -> Vec < TransactionExecutorResult < TransactionExecutionInfo > > {
0 commit comments