ethereum.dao_fork.vmethereum.tangerine_whistle.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

should_transfer_value

63
    should_transfer_value: bool

parent_evm

64
    parent_evm: Optional["Evm"]

Evm

The internal state of the virtual machine.

67
@dataclass
class Evm:

pc

71
    pc: Uint

stack

72
    stack: List[U256]

memory

73
    memory: bytearray

code

74
    code: Bytes

gas_left

75
    gas_left: Uint

env

76
    env: Environment

valid_jump_destinations

77
    valid_jump_destinations: Set[Uint]

logs

78
    logs: Tuple[Log, ...]

refund_counter

79
    refund_counter: int

running

80
    running: bool

message

81
    message: Message

output

82
    output: Bytes

accounts_to_delete

83
    accounts_to_delete: Set[Address]

error

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