Storage

AccountStorageDB

class eth.db.storage.AccountStorageDB(db: AtomicDatabaseAPI, storage_root: Hash32, address: Address)
commit(checkpoint: JournalDBCheckpoint) None

Collapse changes into the given checkpoint.

delete() None

Delete the entire storage at the account.

discard(checkpoint: JournalDBCheckpoint) None

Discard the given checkpoint.

get(slot: int, from_journal: bool = True) int

Return the value at slot. Lookups take the journal into consideration unless from_journal is explicitly set to False.

get_accessed_slots() FrozenSet[int]

List all the slots that had been accessed since object creation.

get_changed_root() Hash32

Return the changed root hash. Raise ValidationError if the root has not changed.

lock_changes() None

Locks in changes to storage, typically just as a transaction starts.

This is used, for example, to look up the storage value from the start of the transaction, when calculating gas costs in EIP-2200: net gas metering.

make_storage_root() None

Force calculation of the storage root for this account

persist(db: DatabaseAPI) None

Persist all changes to the database.

record(checkpoint: JournalDBCheckpoint) None

Record changes into the given checkpoint.

set(slot: int, value: int) None

Write value into slot.

property has_changed_root: bool

Return True if the storage root has changed.

logger = <ExtendedDebugLogger eth.db.storage.AccountStorageDB (WARNING)>

StorageLookup

class eth.db.storage.StorageLookup(db: DatabaseAPI, storage_root: Hash32, address: Address)

This lookup converts lookups of storage slot integers into the appropriate trie lookup. Similarly, it persists changes to the appropriate trie at write time.

StorageLookup also tracks the state roots changed since the last persist.

commit_to(db: DatabaseAPI) None

Trying to commit changes when nothing has been written will raise a ValidationError

get_changed_root() Hash32
new_trie() int

Switch to an empty trie. Save the old trie, and pending writes, in case of a revert.

Returns:

index for reviving the previous trie

rollback_trie(trie_index: int) None

Revert back to the previous trie, using the index returned by a new_trie() call. The index returned by that call returns you to the trie in place before the call.

Parameters:

trie_index – index for reviving the previous trie

property has_changed_root: bool
logger = <ExtendedDebugLogger eth.db.storage.StorageLookup (WARNING)>