@@ -157,7 +157,7 @@ def __init__(self, db: AtomicDatabaseAPI, storage_root: Hash32, address: Address
157
157
158
158
.. code::
159
159
160
- db -> _storage_lookup -> _storage_cache -> _journal_storage
160
+ db -> _storage_lookup -> _storage_cache -> _locked_changes -> _journal_storage
161
161
162
162
db is the raw database, we can assume it hits disk when written to.
163
163
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
174
174
after a state root change. Otherwise, you will see data since the last
175
175
storage root was calculated.
176
176
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
+
177
181
Journaling batches writes at the _journal_storage layer, until persist is called.
178
182
It manages all the checkpointing and rollbacks that happen during EVM execution.
179
183
@@ -183,11 +187,12 @@ def __init__(self, db: AtomicDatabaseAPI, storage_root: Hash32, address: Address
183
187
self ._address = address
184
188
self ._storage_lookup = StorageLookup (db , storage_root , address )
185
189
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 )
187
192
188
193
def get (self , slot : int , from_journal : bool = True ) -> int :
189
194
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
191
196
try :
192
197
encoded_value = lookup_db [key ]
193
198
except MissingStorageTrieNode :
@@ -237,9 +242,13 @@ def commit(self, checkpoint: JournalDBCheckpoint) -> None:
237
242
# then flatten all changes, without persisting
238
243
self ._journal_storage .flatten ()
239
244
240
- def make_storage_root (self ) -> None :
245
+ def lock_changes (self ) -> None :
241
246
self ._journal_storage .persist ()
242
247
248
+ def make_storage_root (self ) -> None :
249
+ self .lock_changes ()
250
+ self ._locked_changes .commit (apply_deletes = True )
251
+
243
252
def _validate_flushed (self ) -> None :
244
253
"""
245
254
Will raise an exception if there are some changes made since the last persist.
0 commit comments