Account
AccountDB
- class eth.db.account.AccountDB(db: AtomicDatabaseAPI, state_root: Hash32 = b'V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!')
- account_exists(address: Address) bool
Return
True
if an account exists ataddress
, otherwiseFalse
.
- account_has_code_or_nonce(address: Address) bool
Return
True
if either code or a nonce exists ataddress
.
- get_code_hash(address: Address) Hash32
Return the hash of the code at
address
.
- get_storage(address: Address, slot: int, from_journal: bool = True) int
Return the value stored at
slot
for the givenaddress
. Take the journal into consideration unlessfrom_journal
is set toFalse
.
- is_address_warm(address: Address) bool
Was the account accessed during this transaction?
See EIP-2929
- is_storage_warm(address: Address, slot: int) bool
Was the storage slot accessed during this transaction?
See EIP-2929
- lock_changes() None
Locks in changes across all accounts’ storage databases.
This is typically used at the end of a transaction, to make sure that a revert doesn’t roll back through the previous transaction, and to be able to look up the “original” value of any account storage, where “original” is the beginning of a transaction (instead of the beginning of a block).
See
eth.abc.AccountStorageDatabaseAPI.lock_changes()
for what is called on each account’s storage database.
- make_state_root() Hash32
Generate the state root with all the current changes in AccountDB
Current changes include every pending change to storage, as well as all account changes. After generating all the required tries, the final account state root is returned.
This is an expensive operation, so should be called as little as possible. For example, pre-Byzantium, this is called after every transaction, because we need the state root in each receipt. Byzantium+, we only need state roots at the end of the block, so we only call it right before persistence.
- Returns:
the new state root
- mark_address_warm(address: Address) None
Mark the account as accessed during this transaction.
See EIP-2929
- mark_storage_warm(address: Address, slot: int) None
Mark the storage slot as accessed during this transaction.
See EIP-2929
- persist() MetaWitnessAPI
Send changes to underlying database, including the trie state so that it will forever be possible to read the trie from this checkpoint.
make_state_root()
must be explicitly called before this method. Otherwise persist will raise a ValidationError.
- record() JournalDBCheckpoint
Create and return a new checkpoint.
- set_storage(address: Address, slot: int, value: int) None
Write
value
intoslot
for the givenaddress
.
- logger = <ExtendedDebugLogger eth.db.account.AccountDB (WARNING)>
- property state_root: Hash32
Return the state root hash.