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 at address, otherwise False.

account_has_code_or_nonce(address: Address) bool

Return True if either code or a nonce exists at address.

account_is_empty(address: Address) bool

Return True if an account exists at address.

commit(checkpoint: JournalDBCheckpoint) None

Collapse changes into checkpoint.

delete_account(address: Address) None

Delete the account at address.

delete_code(address: Address) None

Delete the code at address.

delete_storage(address: Address) None

Delete the storage at address.

discard(checkpoint: JournalDBCheckpoint) None

Discard the given checkpoint.

get_balance(address: Address) int

Return the balance at address.

get_code(address: Address) bytes

Return the code at the given address.

get_code_hash(address: Address) Hash32

Return the hash of the code at address.

get_nonce(address: Address) int

Return the nonce for address.

get_storage(address: Address, slot: int, from_journal: bool = True) int

Return the value stored at slot for the given address. Take the journal into consideration unless from_journal is set to False.

has_root(state_root: bytes) bool

Return True if the state_root exists, otherwise False.

increment_nonce(address: Address) None

Increment the nonce for address.

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_balance(address: Address, balance: int) None

Set balance as the new balance for address.

set_code(address: Address, code: bytes) None

Set code as the new code at address.

set_nonce(address: Address, nonce: int) None

Set nonce as the new nonce for address.

set_storage(address: Address, slot: int, value: int) None

Write value into slot for the given address.

touch_account(address: Address) None

Touch the account at address.

logger = <ExtendedDebugLogger eth.db.account.AccountDB (WARNING)>
property state_root: Hash32

Return the state root hash.