State
BaseState
- class eth.vm.state.BaseState(db: AtomicDatabaseAPI, execution_context: ExecutionContextAPI, state_root: Hash32)
-
- account_is_empty(address: Address) bool
Return
True
if the account ataddress
is empty, otherwiseFalse
.
- clear_transient_storage() None
Clear the transient storage. Should be done at the start of every transaction
- commit(snapshot: Tuple[Hash32, JournalDBCheckpoint]) None
Commit the journal to the point where the snapshot was taken. This merges in any changes that were recorded since the snapshot.
- costless_execute_transaction(transaction: SignedTransactionAPI) ComputationAPI
Execute the given
transaction
with a gas price of0
.
- classmethod get_account_db_class() Type[AccountDatabaseAPI]
Return the
AccountDatabaseAPI
class that the state class uses.
- get_ancestor_hash(block_number: int) Hash32
Return the hash for the ancestor block with number
block_number
. Return the empty bytestringb''
if the block number is outside of the range of available block numbers (typically the last 255 blocks).
- get_code_hash(address: Address) Hash32
Return the hash of the code at
address
.
- get_computation(message: MessageAPI, transaction_context: TransactionContextAPI) ComputationAPI
Return a computation instance for the given message and transaction_context
- get_gas_price(transaction: SignedTransactionAPI) int
Return the gas price of the given transaction.
Factor in the current block’s base gas price, if appropriate. (See EIP-1559)
- get_storage(address: Address, slot: int, from_journal: bool = True) int
Return the storage at
slot
foraddress
.
- get_tip(transaction: SignedTransactionAPI) int
Return the gas price that gets allocated to the miner/validator.
Pre-EIP-1559 that would be the full transaction gas price. After, it would be the tip price (potentially reduced, if the base fee is so high that it surpasses the transaction’s maximum gas price after adding the tip).
- get_transaction_context(transaction: SignedTransactionAPI) TransactionContextAPI
Return the
TransactionContextAPI
for the giventransaction
- classmethod get_transaction_context_class() Type[TransactionContextAPI]
Return the
BaseTransactionContext
class that the state class uses.
- get_transaction_executor() TransactionExecutorAPI
Return the transaction executor.
- get_transient_storage(address: Address, slot: int) bytes
Return the transient storage for
address
at slotslot
.
- has_code_or_nonce(address: Address) bool
Return
True
if either a nonce or code exists at the givenaddress
.
- 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 all changes to state, 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_state_root() Hash32
Create and return the 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
- override_transaction_context(gas_price: int) Iterator[None]
Return a
ContextManager
that overwrites the current transaction context, applying the givengas_price
.
- persist() MetaWitnessAPI
Persist the current state to the database.
- revert(snapshot: Tuple[Hash32, JournalDBCheckpoint]) None
Revert the VM to the state at the snapshot
- set_storage(address: Address, slot: int, value: int) None
Write
value
to the givenslot
ataddress
.
- set_transient_storage(address: Address, slot: int, value: bytes) None
Return the transient storage for
address
at slotslot
.
- snapshot() Tuple[Hash32, JournalDBCheckpoint]
Perform a full snapshot of the current state.
Snapshots are a combination of the
state_root
at the time of the snapshot and the checkpoint from the journaled DB.
- account_db_class: Type[AccountDatabaseAPI] = None
- property base_fee: int
Return the current
base_fee
from the currentexecution_context
Raises a
NotImplementedError
if called in an execution context prior to the London hard fork.
- property blob_base_fee: int
Return the current
blob_base_fee
from the currentexecution_context
Raises a
NotImplementedError
if called in an execution context prior to the Cancun hard fork.
- property block_number: BlockNumber
Return the current
block_number
from the currentexecution_context
- property coinbase: Address
Return the current
coinbase
from the currentexecution_context
- computation_class: Type[ComputationAPI] = None
- property difficulty: int
Return the current
difficulty
from the currentexecution_context
- execution_context: ExecutionContextAPI
- property logger: ExtendedDebugLogger
Return the logger.
- property mix_hash: Hash32
Return the current
mix_hash
from the currentexecution_context
- property state_root: Hash32
Return the current
state_root
from the underlying database
- property timestamp: int
Return the current
timestamp
from the currentexecution_context
- transaction_context_class: Type[TransactionContextAPI] = None
- transaction_executor_class: Type[TransactionExecutorAPI] = None