Account¶
AccountDB¶
-
class
eth.db.account.
AccountDB
(db: eth.abc.AtomicDatabaseAPI, state_root: NewType.<locals>.new_type = b'Vxe8x1fx17x1bxccUxa6xffx83Exe6x92xc0xf8n[Hxe0x1bx99lxadxc0x01b/xb5xe3cxb4!')¶ -
account_exists
(address: NewType.<locals>.new_type) → bool¶ Return
True
if an account exists ataddress
, otherwiseFalse
.
-
account_has_code_or_nonce
(address: NewType.<locals>.new_type) → bool¶ Return
True
if either code or a nonce exists ataddress
.
-
account_is_empty
(address: NewType.<locals>.new_type) → bool¶ Return
True
if an account exists ataddress
.
-
commit
(checkpoint: NewType.<locals>.new_type) → None¶ Collapse changes into
checkpoint
.
-
delete_account
(address: NewType.<locals>.new_type) → None¶ Delete the account at
address
.
-
delete_code
(address: NewType.<locals>.new_type) → None¶ Delete the code at
address
.
-
delete_storage
(address: NewType.<locals>.new_type) → None¶ Delete the storage at
address
.
-
discard
(checkpoint: NewType.<locals>.new_type) → None¶ Discard the given
checkpoint
.
-
get_balance
(address: NewType.<locals>.new_type) → int¶ Return the balance at
address
.
-
get_code
(address: NewType.<locals>.new_type) → bytes¶ Return the code at the given
address
.
-
get_code_hash
(address: NewType.<locals>.new_type) → NewType.<locals>.new_type¶ Return the hash of the code at
address
.
-
get_nonce
(address: NewType.<locals>.new_type) → int¶ Return the nonce for
address
.
-
get_storage
(address: NewType.<locals>.new_type, 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
.
-
has_root
(state_root: bytes) → bool¶ Return
True
if the state_root exists, otherwiseFalse
.
-
increment_nonce
(address: NewType.<locals>.new_type) → None¶ Increment the nonce for
address
.
-
is_address_warm
(address: NewType.<locals>.new_type) → bool¶ Was the account accessed during this transaction?
See EIP-2929
-
is_storage_warm
(address: NewType.<locals>.new_type, 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
() → NewType.<locals>.new_type¶ 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 persistance.
Returns: the new state root
-
mark_address_warm
(address: NewType.<locals>.new_type) → None¶ Mark the account as accessed during this transaction.
See EIP-2929
-
mark_storage_warm
(address: NewType.<locals>.new_type, slot: int) → None¶ Mark the storage slot as accessed during this transaction.
See EIP-2929
-
persist
() → eth.abc.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
() → NewType.<locals>.new_type¶ Create and return a new checkpoint.
-
set_balance
(address: NewType.<locals>.new_type, balance: int) → None¶ Set
balance
as the new balance foraddress
.
-
set_code
(address: NewType.<locals>.new_type, code: bytes) → None¶ Set
code
as the new code ataddress
.
-
set_nonce
(address: NewType.<locals>.new_type, nonce: int) → None¶ Set
nonce
as the new nonce foraddress
.
-
set_storage
(address: NewType.<locals>.new_type, slot: int, value: int) → None¶ Write
value
intoslot
for the givenaddress
.
-
touch_account
(address: NewType.<locals>.new_type) → None¶ Touch the account at
address
.
-
state_root
¶ Return the state root hash.
-