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__

28
__all__ = ("Environment", "Evm", "Message")

Environment

Items external to the virtual machine itself, provided by the environment.

31
@dataclass
class Environment:

caller

37
    caller: Address

block_hashes

38
    block_hashes: List[Hash32]

origin

39
    origin: Address

coinbase

40
    coinbase: Address

number

41
    number: Uint

gas_limit

42
    gas_limit: Uint

gas_price

43
    gas_price: Uint

time

44
    time: U256

difficulty

45
    difficulty: Uint

state

46
    state: State

traces

47
    traces: List[dict]

Message

Items that are used by contract creation or message call.

50
@dataclass
class Message:

caller

56
    caller: Address

target

57
    target: Union[Bytes0, Address]

current_target

58
    current_target: Address

gas

59
    gas: Uint

value

60
    value: U256

data

61
    data: Bytes

code_address

62
    code_address: Optional[Address]

code

63
    code: Bytes

depth

64
    depth: Uint

parent_evm

65
    parent_evm: Optional["Evm"]

Evm

The internal state of the virtual machine.

68
@dataclass
class Evm:

pc

72
    pc: Uint

stack

73
    stack: List[U256]

memory

74
    memory: bytearray

code

75
    code: Bytes

gas_left

76
    gas_left: Uint

env

77
    env: Environment

valid_jump_destinations

78
    valid_jump_destinations: Set[Uint]

logs

79
    logs: Tuple[Log, ...]

refund_counter

80
    refund_counter: int

running

81
    running: bool

message

82
    message: Message

output

83
    output: Bytes

accounts_to_delete

84
    accounts_to_delete: Set[Address]

error

85
    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:
89
    """
90
    Incorporate the state of a successful `child_evm` into the parent `evm`.
91
92
    Parameters
93
    ----------
94
    evm :
95
        The parent `EVM`.
96
    child_evm :
97
        The child evm to incorporate.
98
    """
99
    evm.gas_left += child_evm.gas_left
100
    evm.logs += child_evm.logs
101
    evm.refund_counter += child_evm.refund_counter
102
    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:
106
    """
107
    Incorporate the state of an unsuccessful `child_evm` into the parent `evm`.
108
109
    Parameters
110
    ----------
111
    evm :
112
        The parent `EVM`.
113
    child_evm :
114
        The child evm to incorporate.
115
    """
116
    evm.gas_left += child_evm.gas_left