@@ -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 ) ;
@@ -116,14 +118,16 @@ impl<S: StateReader> TransactionExecutor<S> {
116118 Ok ( tx_execution_info) => {
117119 let tx_state_changes_keys =
118120 transactional_state. get_actual_state_changes ( ) ?. state_maps . into_keys ( ) ;
121+ let state_diff = transactional_state. to_state_diff ( ) ?. state_maps ;
119122 self . bouncer . try_update (
120123 & transactional_state,
121124 & tx_state_changes_keys,
122125 & tx_execution_info. summarize ( & self . block_context . versioned_constants ) ,
123126 & tx_execution_info. receipt . resources ,
124127 ) ?;
125128 transactional_state. commit ( ) ;
126- Ok ( tx_execution_info)
129+
130+ Ok ( ( tx_execution_info, state_diff) )
127131 }
128132 Err ( error) => {
129133 transactional_state. abort ( ) ;
@@ -132,14 +136,16 @@ impl<S: StateReader> TransactionExecutor<S> {
132136 }
133137 }
134138
135- pub fn execute_txs_sequentially_inner (
139+ fn execute_txs_sequentially_inner (
136140 & mut self ,
137141 txs : & [ Transaction ] ,
138- ) -> Vec < TransactionExecutorResult < TransactionExecutionInfo > > {
142+ ) -> Vec < TransactionExecutorResult < TransactionExecutionOutput > > {
139143 let mut results = Vec :: new ( ) ;
140144 for tx in txs {
141145 match self . execute ( tx) {
142- Ok ( tx_execution_info) => results. push ( Ok ( tx_execution_info) ) ,
146+ Ok ( ( tx_execution_info, state_diff) ) => {
147+ results. push ( Ok ( ( tx_execution_info, state_diff) ) )
148+ }
143149 Err ( TransactionExecutorError :: BlockFull ) => break ,
144150 Err ( error) => results. push ( Err ( error) ) ,
145151 }
@@ -196,6 +202,9 @@ impl<S: StateReader + Send + Sync> TransactionExecutor<S> {
196202 if !self . config . concurrency_config . enabled {
197203 log:: debug!( "Executing transactions sequentially." ) ;
198204 self . execute_txs_sequentially ( txs)
205+ . into_iter ( )
206+ . map ( |result| result. map ( |( info, _) | info) )
207+ . collect ( )
199208 } else {
200209 log:: debug!( "Executing transactions concurrently." ) ;
201210 let chunk_size = self . config . concurrency_config . chunk_size ;
@@ -228,10 +237,10 @@ impl<S: StateReader + Send + Sync> TransactionExecutor<S> {
228237 }
229238 }
230239
231- pub fn execute_txs_sequentially (
240+ fn execute_txs_sequentially (
232241 & mut self ,
233242 txs : & [ Transaction ] ,
234- ) -> Vec < TransactionExecutorResult < TransactionExecutionInfo > > {
243+ ) -> Vec < TransactionExecutorResult < TransactionExecutionOutput > > {
235244 #[ cfg( not( feature = "cairo_native" ) ) ]
236245 return self . execute_txs_sequentially_inner ( txs) ;
237246 #[ cfg( feature = "cairo_native" ) ]
@@ -261,7 +270,7 @@ impl<S: StateReader + Send + Sync> TransactionExecutor<S> {
261270 }
262271 }
263272
264- pub fn execute_chunk (
273+ fn execute_chunk (
265274 & mut self ,
266275 chunk : & [ Transaction ] ,
267276 ) -> Vec < TransactionExecutorResult < TransactionExecutionInfo > > {
0 commit comments