@@ -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 } ;
@@ -103,7 +103,7 @@ impl<S: StateReader> TransactionExecutor<S> {
103103 pub fn execute (
104104 & mut self ,
105105 tx : & Transaction ,
106- ) -> TransactionExecutorResult < TransactionExecutionInfo > {
106+ ) -> TransactionExecutorResult < TransactionExecutionOutput > {
107107 let mut transactional_state = TransactionalState :: create_transactional (
108108 self . block_state . as_mut ( ) . expect ( BLOCK_STATE_ACCESS_ERR ) ,
109109 ) ;
@@ -116,14 +116,15 @@ impl<S: StateReader> TransactionExecutor<S> {
116116 Ok ( tx_execution_info) => {
117117 let tx_state_changes_keys =
118118 transactional_state. get_actual_state_changes ( ) ?. state_maps . into_keys ( ) ;
119+ let state_diff = transactional_state. to_state_diff ( ) ?. state_maps ;
119120 self . bouncer . try_update (
120121 & transactional_state,
121122 & tx_state_changes_keys,
122123 & tx_execution_info. summarize ( & self . block_context . versioned_constants ) ,
123124 & tx_execution_info. receipt . resources ,
124125 ) ?;
125126 transactional_state. commit ( ) ;
126- Ok ( tx_execution_info)
127+ Ok ( ( tx_execution_info, state_diff ) )
127128 }
128129 Err ( error) => {
129130 transactional_state. abort ( ) ;
@@ -135,11 +136,13 @@ impl<S: StateReader> TransactionExecutor<S> {
135136 pub fn execute_txs_sequentially_inner (
136137 & mut self ,
137138 txs : & [ Transaction ] ,
138- ) -> Vec < TransactionExecutorResult < TransactionExecutionInfo > > {
139+ ) -> Vec < TransactionExecutorResult < ( TransactionExecutionInfo , StateMaps ) > > {
139140 let mut results = Vec :: new ( ) ;
140141 for tx in txs {
141142 match self . execute ( tx) {
142- Ok ( tx_execution_info) => results. push ( Ok ( tx_execution_info) ) ,
143+ Ok ( ( tx_execution_info, state_diff) ) => {
144+ results. push ( Ok ( ( tx_execution_info, state_diff) ) )
145+ }
143146 Err ( TransactionExecutorError :: BlockFull ) => break ,
144147 Err ( error) => results. push ( Err ( error) ) ,
145148 }
@@ -233,14 +236,18 @@ impl<S: StateReader + Send + Sync> TransactionExecutor<S> {
233236 txs : & [ Transaction ] ,
234237 ) -> Vec < TransactionExecutorResult < TransactionExecutionInfo > > {
235238 #[ cfg( not( feature = "cairo_native" ) ) ]
236- return self . execute_txs_sequentially_inner ( txs) ;
239+ return self
240+ . execute_txs_sequentially_inner ( txs)
241+ . into_iter ( )
242+ . map ( |result| result. map ( |( info, _) | info) )
243+ . collect ( ) ;
237244 #[ cfg( feature = "cairo_native" ) ]
238245 {
239246 // TODO meshi: find a way to access the contract class manager config from transaction
240247 // executor.
241248 let txs = txs. to_vec ( ) ;
242249 std:: thread:: scope ( |s| {
243- std:: thread:: Builder :: new ( )
250+ let execution_outputs = std:: thread:: Builder :: new ( )
244251 // when running Cairo natively, the real stack is used and could get overflowed
245252 // (unlike the VM where the stack is simulated in the heap as a memory segment).
246253 //
@@ -256,7 +263,9 @@ impl<S: StateReader + Send + Sync> TransactionExecutor<S> {
256263 . spawn_scoped ( s, || self . execute_txs_sequentially_inner ( & txs) )
257264 . expect ( "Failed to spawn thread" )
258265 . join ( )
259- . expect ( "Failed to join thread." )
266+ . expect ( "Failed to join thread." ) ;
267+
268+ execution_outputs. into_iter ( ) . map ( |result| result. map ( |( info, _) | info) ) . collect ( )
260269 } )
261270 }
262271 }
0 commit comments