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__

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

Environment

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

32
@dataclass
class Environment:

caller

38
    caller: Address

block_hashes

39
    block_hashes: List[Hash32]

origin

40
    origin: Address

coinbase

41
    coinbase: Address

number

42
    number: Uint

gas_limit

43
    gas_limit: Uint

gas_price

44
    gas_price: Uint

time

45
    time: U256

difficulty

46
    difficulty: Uint

state

47
    state: State

traces

48
    traces: List[dict]

Message

Items that are used by contract creation or message call.

51
@dataclass
class Message:

caller

57
    caller: Address

target

58
    target: Union[Bytes0, Address]

current_target

59
    current_target: Address

gas

60
    gas: Uint

value

61
    value: U256

data

62
    data: Bytes

code_address

63
    code_address: Optional[Address]

code

64
    code: Bytes

depth

65
    depth: Uint

parent_evm

66
    parent_evm: Optional["Evm"]

Evm

The internal state of the virtual machine.

69
@dataclass
class Evm:

pc

73
    pc: Uint

stack

74
    stack: List[U256]

memory

75
    memory: bytearray

code

76
    code: Bytes

gas_left

77
    gas_left: Uint

env

78
    env: Environment

valid_jump_destinations

79
    valid_jump_destinations: Set[Uint]

logs

80
    logs: Tuple[Log, ...]

refund_counter

81
    refund_counter: int

running

82
    running: bool

message

83
    message: Message

output

84
    output: Bytes

accounts_to_delete

85
    accounts_to_delete: Set[Address]

error

86
    error: Optional[EthereumException]

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