@@ -270,15 +270,6 @@ impl JournaledState {
270
270
last_journal. push ( JournalEntry :: AccountCreated { address } ) ;
271
271
account. info . code = None ;
272
272
273
- // Set all storages to default value. They need to be present to act as accessed slots in access list.
274
- // it shouldn't be possible for them to have different values then zero as code is not existing for this account,
275
- // but because tests can change that assumption we are doing it.
276
- let empty = EvmStorageSlot :: default ( ) ;
277
- account
278
- . storage
279
- . iter_mut ( )
280
- . for_each ( |( _, slot) | * slot = empty. clone ( ) ) ;
281
-
282
273
// touch account. This is important as for pre SpuriousDragon account could be
283
274
// saved even empty.
284
275
Self :: touch_account ( last_journal, & address, account) ;
@@ -321,7 +312,7 @@ impl JournaledState {
321
312
) {
322
313
for entry in journal_entries. into_iter ( ) . rev ( ) {
323
314
match entry {
324
- JournalEntry :: AccountLoaded { address } => {
315
+ JournalEntry :: AccountWarmed { address } => {
325
316
state. get_mut ( & address) . unwrap ( ) . mark_cold ( ) ;
326
317
}
327
318
JournalEntry :: AccountTouched { address } => {
@@ -367,19 +358,33 @@ impl JournaledState {
367
358
JournalEntry :: AccountCreated { address } => {
368
359
let account = & mut state. get_mut ( & address) . unwrap ( ) ;
369
360
account. unmark_created ( ) ;
361
+ account
362
+ . storage
363
+ . values_mut ( )
364
+ . for_each ( |slot| slot. mark_cold ( ) ) ;
370
365
account. info . nonce = 0 ;
371
366
}
372
- JournalEntry :: StorageChange {
367
+ JournalEntry :: StorageWarmed { address, key } => {
368
+ state
369
+ . get_mut ( & address)
370
+ . unwrap ( )
371
+ . storage
372
+ . get_mut ( & key)
373
+ . unwrap ( )
374
+ . mark_cold ( ) ;
375
+ }
376
+ JournalEntry :: StorageChanged {
373
377
address,
374
378
key,
375
379
had_value,
376
380
} => {
377
- let storage = & mut state. get_mut ( & address) . unwrap ( ) . storage ;
378
- if let Some ( had_value) = had_value {
379
- storage. get_mut ( & key) . unwrap ( ) . present_value = had_value;
380
- } else {
381
- storage. get_mut ( & key) . unwrap ( ) . mark_cold ( ) ;
382
- }
381
+ state
382
+ . get_mut ( & address)
383
+ . unwrap ( )
384
+ . storage
385
+ . get_mut ( & key)
386
+ . unwrap ( )
387
+ . present_value = had_value;
383
388
}
384
389
JournalEntry :: TransientStorageChange {
385
390
address,
@@ -581,7 +586,7 @@ impl JournaledState {
581
586
self . journal
582
587
. last_mut ( )
583
588
. unwrap ( )
584
- . push ( JournalEntry :: AccountLoaded { address } ) ;
589
+ . push ( JournalEntry :: AccountWarmed { address } ) ;
585
590
}
586
591
587
592
Ok ( ( value, is_cold) )
@@ -674,11 +679,7 @@ impl JournaledState {
674
679
self . journal
675
680
. last_mut ( )
676
681
. unwrap ( )
677
- . push ( JournalEntry :: StorageChange {
678
- address,
679
- key,
680
- had_value : None ,
681
- } ) ;
682
+ . push ( JournalEntry :: StorageWarmed { address, key } ) ;
682
683
}
683
684
684
685
Ok ( ( value, is_cold) )
@@ -718,10 +719,10 @@ impl JournaledState {
718
719
self . journal
719
720
. last_mut ( )
720
721
. unwrap ( )
721
- . push ( JournalEntry :: StorageChange {
722
+ . push ( JournalEntry :: StorageChanged {
722
723
address,
723
724
key,
724
- had_value : Some ( present) ,
725
+ had_value : present,
725
726
} ) ;
726
727
// insert value into present state.
727
728
slot. present_value = new;
@@ -800,7 +801,7 @@ pub enum JournalEntry {
800
801
/// Used to mark account that is warm inside EVM in regards to EIP-2929 AccessList.
801
802
/// Action: We will add Account to state.
802
803
/// Revert: we will remove account from state.
803
- AccountLoaded { address : Address } ,
804
+ AccountWarmed { address : Address } ,
804
805
/// Mark account to be destroyed and journal balance to be reverted
805
806
/// Action: Mark account and transfer the balance
806
807
/// Revert: Unmark the account and transfer balance back
@@ -833,15 +834,18 @@ pub enum JournalEntry {
833
834
/// Actions: Mark account as created
834
835
/// Revert: Unmart account as created and reset nonce to zero.
835
836
AccountCreated { address : Address } ,
836
- /// It is used to track both storage change and warm load of storage slot. For warm load in regard
837
- /// to EIP-2929 AccessList had_value will be None
838
- /// Action: Storage change or warm load
839
- /// Revert: Revert to previous value or remove slot from storage
840
- StorageChange {
837
+ /// Entry used to track storage changes
838
+ /// Action: Storage change
839
+ /// Revert: Revert to previous value
840
+ StorageChanged {
841
841
address : Address ,
842
842
key : U256 ,
843
- had_value : Option < U256 > , //if none, storage slot was cold loaded from db and needs to be removed
843
+ had_value : U256 ,
844
844
} ,
845
+ /// Entry used to track storage warming introduced by EIP-2929.
846
+ /// Action: Storage warmed
847
+ /// Revert: Revert to cold state
848
+ StorageWarmed { address : Address , key : U256 } ,
845
849
/// It is used to track an EIP-1153 transient storage change.
846
850
/// Action: Transient storage changed.
847
851
/// Revert: Revert to previous value.
0 commit comments