ethereum.frontier.vm
Ethereum Virtual Machine (EVM) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. contents:: Table of Contents :backlinks: none :local:
Introduction
The abstract computer which runs the code stored in an
.fork_types.Account
.
__all__
26 | __all__ = ("Environment", "Evm", "Message") |
---|
Environment
Items external to the virtual machine itself, provided by the environment.
29 | @dataclass |
---|
class Environment:
caller
35 | caller: Address |
---|
block_hashes
36 | block_hashes: List[Hash32] |
---|
origin
37 | origin: Address |
---|
coinbase
38 | coinbase: Address |
---|
number
39 | number: Uint |
---|
gas_limit
40 | gas_limit: Uint |
---|
gas_price
41 | gas_price: Uint |
---|
time
42 | time: U256 |
---|
difficulty
43 | difficulty: Uint |
---|
state
44 | state: State |
---|
traces
45 | traces: List[dict] |
---|
Message
Items that are used by contract creation or message call.
48 | @dataclass |
---|
class Message:
caller
54 | caller: Address |
---|
target
55 | target: Union[Bytes0, Address] |
---|
current_target
56 | current_target: Address |
---|
gas
57 | gas: Uint |
---|
value
58 | value: U256 |
---|
data
59 | data: Bytes |
---|
code_address
60 | code_address: Optional[Address] |
---|
code
61 | code: Bytes |
---|
depth
62 | depth: Uint |
---|
parent_evm
63 | parent_evm: Optional["Evm"] |
---|
Evm
The internal state of the virtual machine.
66 | @dataclass |
---|
class Evm:
pc
70 | pc: Uint |
---|
stack
71 | stack: List[U256] |
---|
memory
72 | memory: bytearray |
---|
code
73 | code: Bytes |
---|
gas_left
74 | gas_left: Uint |
---|
env
75 | env: Environment |
---|
valid_jump_destinations
76 | valid_jump_destinations: Set[Uint] |
---|
logs
77 | logs: Tuple[Log, ...] |
---|
refund_counter
78 | refund_counter: int |
---|
running
79 | running: bool |
---|
message
80 | message: Message |
---|
output
81 | output: Bytes |
---|
accounts_to_delete
82 | accounts_to_delete: Set[Address] |
---|
error
83 | error: Optional[Exception] |
---|
incorporate_child_on_success
Incorporate the state of a successful child_evm
into the parent evm
.
Parameters
evm :
The parent EVM
.
child_evm :
The child evm to incorporate.
def incorporate_child_on_success(evm: Evm, child_evm: Evm) -> None:
87 | """ |
---|---|
88 | Incorporate the state of a successful `child_evm` into the parent `evm`. |
89 |
|
90 | Parameters |
91 | ---------- |
92 | evm : |
93 | The parent `EVM`. |
94 | child_evm : |
95 | The child evm to incorporate. |
96 | """ |
97 | evm.gas_left += child_evm.gas_left |
98 | evm.logs += child_evm.logs |
99 | evm.refund_counter += child_evm.refund_counter |
100 | evm.accounts_to_delete.update(child_evm.accounts_to_delete) |
incorporate_child_on_error
Incorporate the state of an unsuccessful child_evm
into the parent evm
.
Parameters
evm :
The parent EVM
.
child_evm :
The child evm to incorporate.
def incorporate_child_on_error(evm: Evm, child_evm: Evm) -> None:
104 | """ |
---|---|
105 | Incorporate the state of an unsuccessful `child_evm` into the parent `evm`. |
106 |
|
107 | Parameters |
108 | ---------- |
109 | evm : |
110 | The parent `EVM`. |
111 | child_evm : |
112 | The child evm to incorporate. |
113 | """ |
114 | evm.gas_left += child_evm.gas_left |