@@ -9,6 +9,7 @@ use revm::{
99    primitives:: { AccountInfo ,  Env ,  B256 ,  KECCAK_EMPTY ,  POSEIDON_EMPTY } , 
1010} ; 
1111use  sbv_primitives:: { 
12+     alloy_primitives:: Bytes , 
1213    zk_trie:: { 
1314        db:: kv:: KVDatabase , 
1415        hash:: { key_hasher:: NoCacheHasher ,  poseidon:: Poseidon } , 
@@ -22,18 +23,23 @@ use std::fmt::Debug;
2223mod  builder; 
2324pub  use  builder:: EvmExecutorBuilder ; 
2425
25- /// Execute hooks 
26- pub  mod  hooks; 
27- 
2826/// EVM executor that handles the block. 
29- pub  struct  EvmExecutor < ' db ,  ' h ,   CodeDb ,  ZkDb >  { 
27+ pub  struct  EvmExecutor < ' db ,  CodeDb ,  ZkDb >  { 
3028    chain_id :  ChainId , 
3129    hardfork_config :  HardforkConfig , 
3230    db :  CacheDB < EvmDatabase < ' db ,  CodeDb ,  ZkDb > > , 
33-     hooks :  hooks:: ExecuteHooks < ' h ,  CodeDb ,  ZkDb > , 
3431} 
3532
36- impl < CodeDb :  KVDatabase ,  ZkDb :  KVDatabase  + ' static >  EvmExecutor < ' _ ,  ' _ ,  CodeDb ,  ZkDb >  { 
33+ /// Block execution result 
34+ #[ derive( Debug ,  Clone ) ]  
35+ pub  struct  BlockExecutionResult  { 
36+     /// Gas used in this block 
37+ pub  gas_used :  u64 , 
38+     /// RLP bytes of transactions 
39+ pub  tx_rlps :  Vec < Bytes > , 
40+ } 
41+ 
42+ impl < CodeDb :  KVDatabase ,  ZkDb :  KVDatabase  + ' static >  EvmExecutor < ' _ ,  CodeDb ,  ZkDb >  { 
3743    /// Get reference to the DB 
3844pub  fn  db ( & self )  -> & CacheDB < EvmDatabase < CodeDb ,  ZkDb > >  { 
3945        & self . db 
@@ -45,7 +51,10 @@ impl<CodeDb: KVDatabase, ZkDb: KVDatabase + 'static> EvmExecutor<'_, '_, CodeDb,
4551    } 
4652
4753    /// Handle a block. 
48- pub  fn  handle_block < T :  Block > ( & mut  self ,  l2_trace :  & T )  -> Result < u64 ,  VerificationError >  { 
54+ pub  fn  handle_block < T :  Block > ( 
55+         & mut  self , 
56+         l2_trace :  & T , 
57+     )  -> Result < BlockExecutionResult ,  VerificationError >  { 
4958        #[ allow( clippy:: let_and_return) ]  
5059        let  gas_used = measure_duration_millis ! ( 
5160            handle_block_duration_milliseconds, 
@@ -59,7 +68,10 @@ impl<CodeDb: KVDatabase, ZkDb: KVDatabase + 'static> EvmExecutor<'_, '_, CodeDb,
5968    } 
6069
6170    #[ inline( always) ]  
62-     fn  handle_block_inner < T :  Block > ( & mut  self ,  l2_trace :  & T )  -> Result < u64 ,  VerificationError >  { 
71+     fn  handle_block_inner < T :  Block > ( 
72+         & mut  self , 
73+         l2_trace :  & T , 
74+     )  -> Result < BlockExecutionResult ,  VerificationError >  { 
6375        let  spec_id = self . hardfork_config . get_spec_id ( l2_trace. number ( ) ) ; 
6476        dev_trace ! ( "use spec id {spec_id:?}" , ) ; 
6577        self . hardfork_config 
@@ -81,6 +93,7 @@ impl<CodeDb: KVDatabase, ZkDb: KVDatabase + 'static> EvmExecutor<'_, '_, CodeDb,
8193        } ; 
8294
8395        let  mut  gas_used = 0 ; 
96+         let  mut  tx_rlps = Vec :: with_capacity ( l2_trace. num_txs ( ) ) ; 
8497
8598        for  ( idx,  tx)  in  l2_trace. transactions ( ) . enumerate ( )  { 
8699            cycle_tracker_start ! ( "handle tx" ) ; 
@@ -129,7 +142,7 @@ impl<CodeDb: KVDatabase, ZkDb: KVDatabase + 'static> EvmExecutor<'_, '_, CodeDb,
129142            } 
130143            env. tx . scroll . is_l1_msg  = tx. is_l1_msg ( ) ; 
131144            let  rlp_bytes = tx. rlp ( ) ; 
132-             self . hooks . tx_rlp ( self ,   & rlp_bytes) ; 
145+             tx_rlps . push ( rlp_bytes. clone ( ) ) ; 
133146            env. tx . scroll . rlp_bytes  = Some ( rlp_bytes) ; 
134147
135148            dev_trace ! ( "{env:#?}" ) ; 
@@ -161,12 +174,11 @@ impl<CodeDb: KVDatabase, ZkDb: KVDatabase + 'static> EvmExecutor<'_, '_, CodeDb,
161174
162175                dev_trace ! ( "{result:#?}" ) ; 
163176            } 
164-             self . hooks . post_tx_execution ( self ,  idx) ; 
165177
166178            dev_debug ! ( "handle {idx}th tx done" ) ; 
167179            cycle_tracker_end ! ( "handle tx" ) ; 
168180        } 
169-         Ok ( gas_used) 
181+         Ok ( BlockExecutionResult   {   gas_used,  tx_rlps  } ) 
170182    } 
171183
172184    /// Commit pending changes in cache db to zktrie 
@@ -345,7 +357,7 @@ impl<CodeDb: KVDatabase, ZkDb: KVDatabase + 'static> EvmExecutor<'_, '_, CodeDb,
345357    } 
346358} 
347359
348- impl < CodeDb ,  ZkDb >  Debug  for  EvmExecutor < ' _ ,  ' _ ,   CodeDb ,  ZkDb >  { 
360+ impl < CodeDb ,  ZkDb >  Debug  for  EvmExecutor < ' _ ,  CodeDb ,  ZkDb >  { 
349361    fn  fmt ( & self ,  f :  & mut  std:: fmt:: Formatter < ' _ > )  -> std:: fmt:: Result  { 
350362        f. debug_struct ( "EvmExecutor" ) . field ( "db" ,  & self . db ) . finish ( ) 
351363    } 
0 commit comments