@@ -157,7 +157,7 @@ def __init__(self, db: AtomicDatabaseAPI, storage_root: Hash32, address: Address
157157
158158 .. code::
159159
160- db -> _storage_lookup -> _storage_cache -> _journal_storage
160+ db -> _storage_lookup -> _storage_cache -> _locked_changes -> _journal_storage
161161
162162 db is the raw database, we can assume it hits disk when written to.
163163 Keys are stored as node hashes and rlp-encoded node values.
@@ -174,6 +174,10 @@ def __init__(self, db: AtomicDatabaseAPI, storage_root: Hash32, address: Address
174174 after a state root change. Otherwise, you will see data since the last
175175 storage root was calculated.
176176
177+ _locked_changes is a batch database that includes only those values that are
178+ un-revertable in the EVM. Currently, that means changes that completed in a
179+ previous transaction.
180+
177181 Journaling batches writes at the _journal_storage layer, until persist is called.
178182 It manages all the checkpointing and rollbacks that happen during EVM execution.
179183
@@ -183,11 +187,12 @@ def __init__(self, db: AtomicDatabaseAPI, storage_root: Hash32, address: Address
183187 self ._address = address
184188 self ._storage_lookup = StorageLookup (db , storage_root , address )
185189 self ._storage_cache = CacheDB (self ._storage_lookup )
186- self ._journal_storage = JournalDB (self ._storage_cache )
190+ self ._locked_changes = BatchDB (self ._storage_cache )
191+ self ._journal_storage = JournalDB (self ._locked_changes )
187192
188193 def get (self , slot : int , from_journal : bool = True ) -> int :
189194 key = int_to_big_endian (slot )
190- lookup_db = self ._journal_storage if from_journal else self ._storage_cache
195+ lookup_db = self ._journal_storage if from_journal else self ._locked_changes
191196 try :
192197 encoded_value = lookup_db [key ]
193198 except MissingStorageTrieNode :
@@ -237,9 +242,13 @@ def commit(self, checkpoint: JournalDBCheckpoint) -> None:
237242 # then flatten all changes, without persisting
238243 self ._journal_storage .flatten ()
239244
240- def make_storage_root (self ) -> None :
245+ def lock_changes (self ) -> None :
241246 self ._journal_storage .persist ()
242247
248+ def make_storage_root (self ) -> None :
249+ self .lock_changes ()
250+ self ._locked_changes .commit (apply_deletes = True )
251+
243252 def _validate_flushed (self ) -> None :
244253 """
245254 Will raise an exception if there are some changes made since the last persist.
0 commit comments