@@ -193,30 +193,35 @@ impl EvmExecutor<'_> {
193
193
let storage_root_before = acc_data. storage_root ;
194
194
// get storage tire
195
195
cycle_tracker_start ! ( "update storage_tire" ) ;
196
- let mut storage_tire = zktrie_state
196
+ let mut storage_trie = zktrie_state
197
197
. zk_db
198
198
. new_trie ( storage_root_before. as_fixed_bytes ( ) )
199
199
. expect ( "unable to get storage trie" ) ;
200
200
for ( key, value) in db_acc. storage . iter ( ) {
201
201
if !value. is_zero ( ) {
202
202
cycle_track ! (
203
- storage_tire
203
+ storage_trie
204
204
. update_store( & key. to_be_bytes:: <32 >( ) , & value. to_be_bytes( ) )
205
205
. expect( "failed to update storage" ) ,
206
206
"Zktrie::update_store"
207
207
) ;
208
208
} else {
209
209
cycle_track ! (
210
- storage_tire . delete( & key. to_be_bytes:: <32 >( ) ) ,
210
+ storage_trie . delete( & key. to_be_bytes:: <32 >( ) ) ,
211
211
"Zktrie::delete"
212
212
) ;
213
213
}
214
214
215
215
#[ cfg( feature = "debug-storage" ) ]
216
216
debug_recorder. record_storage ( * addr, * key, * value) ;
217
217
}
218
+
219
+ if storage_trie. is_trie_dirty ( ) {
220
+ storage_trie. prepare_root ( ) ;
221
+ }
222
+
218
223
cycle_tracker_end ! ( "update storage_tire" ) ;
219
- acc_data. storage_root = H256 :: from ( storage_tire . root ( ) ) ;
224
+ acc_data. storage_root = H256 :: from ( storage_trie . root ( ) ) ;
220
225
221
226
#[ cfg( feature = "debug-storage" ) ]
222
227
debug_recorder. record_storage_root ( * addr, acc_data. storage_root ) ;
@@ -256,6 +261,10 @@ impl EvmExecutor<'_> {
256
261
cycle_tracker_end ! ( "commit account {}" , addr) ;
257
262
}
258
263
264
+ if zktrie. is_trie_dirty ( ) {
265
+ zktrie. prepare_root ( ) ;
266
+ }
267
+
259
268
let root_after = zktrie. root ( ) ;
260
269
261
270
zktrie_state. switch_to ( root_after) ;
0 commit comments