State
BaseState
- class eth.vm.state.BaseState(db: AtomicDatabaseAPI, execution_context: ExecutionContextAPI, state_root: Hash32)
-
- account_is_empty(address: Address) bool
Return
Trueif the account ataddressis 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
transactionwith a gas price of0.
- classmethod get_account_db_class() Type[AccountDatabaseAPI]
Return the
AccountDatabaseAPIclass 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_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
slotforaddress.
- 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
TransactionContextAPIfor the giventransaction
- classmethod get_transaction_context_class() Type[TransactionContextAPI]
Return the
BaseTransactionContextclass 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
addressat slotslot.
- has_code_or_nonce(address: Address) bool
Return
Trueif 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.
- 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
ContextManagerthat 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
valueto the givenslotataddress.
- set_system_contracts() None
Set required contracts for the particular fork to the state. This method should be called once at
__init__(). This is not relevant until Cancun.
- set_transient_storage(address: Address, slot: int, value: bytes) None
Return the transient storage for
addressat slotslot.
- snapshot() Tuple[Hash32, JournalDBCheckpoint]
Perform a full snapshot of the current state.
Snapshots are a combination of the
state_rootat 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_feefrom the currentexecution_contextRaises a
NotImplementedErrorif called in an execution context prior to the London hard fork.
- property blob_base_fee: int
Return the current
blob_base_feefrom the currentexecution_contextRaises a
NotImplementedErrorif called in an execution context prior to the Cancun hard fork.
- property block_number: BlockNumber
Return the current
block_numberfrom the currentexecution_context
- property coinbase: Address
Return the current
coinbasefrom the currentexecution_context
- computation_class: Type[ComputationAPI] = None
- property difficulty: int
Return the current
difficultyfrom the currentexecution_context
- execution_context: ExecutionContextAPI
- property logger: ExtendedDebugLogger
Return the logger.
- property mix_hash: Hash32
Return the current
mix_hashfrom the currentexecution_context
- property timestamp: int
Return the current
timestampfrom the currentexecution_context
- transaction_context_class: Type[TransactionContextAPI] = None
- transaction_executor_class: Type[TransactionExecutorAPI] = None