ethereum.byzantium.vm.memoryethereum.constantinople.vm.memory

Ethereum Virtual Machine (EVM) Memory ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. contents:: Table of Contents :backlinks: none :local:

Introduction

EVM memory operations.

memory_write

Writes to memory.

Parameters

memory : Memory contents of the EVM. start_position : Starting pointer to the memory. value : Data to write to memory.

def memory_write(memory: bytearray, ​​start_position: U256, ​​value: Bytes) -> None:
23
    """
24
    Writes to memory.
25
26
    Parameters
27
    ----------
28
    memory :
29
        Memory contents of the EVM.
30
    start_position :
31
        Starting pointer to the memory.
32
    value :
33
        Data to write to memory.
34
    """
35
    memory[start_position : int(start_position) + len(value)] = value

memory_read_bytes

Read bytes from memory.

Parameters

memory : Memory contents of the EVM. start_position : Starting pointer to the memory. size : Size of the data that needs to be read from start_position.

Returns

data_bytes : Data read from memory.

def memory_read_bytes(memory: bytearray, ​​start_position: U256, ​​size: U256) -> bytearray:
41
    """
42
    Read bytes from memory.
43
44
    Parameters
45
    ----------
46
    memory :
47
        Memory contents of the EVM.
48
    start_position :
49
        Starting pointer to the memory.
50
    size :
51
        Size of the data that needs to be read from `start_position`.
52
53
    Returns
54
    -------
55
    data_bytes :
56
        Data read from memory.
57
    """
58
    return memory[start_position : Uint(start_position) + Uint(size)]

buffer_read

Read bytes from a buffer. Padding with zeros if necessary.

Parameters

buffer : Memory contents of the EVM. start_position : Starting pointer to the memory. size : Size of the data that needs to be read from start_position.

Returns

data_bytes : Data read from memory.

def buffer_read(buffer: Bytes, ​​start_position: U256, ​​size: U256) -> Bytes:
62
    """
63
    Read bytes from a buffer. Padding with zeros if necessary.
64
65
    Parameters
66
    ----------
67
    buffer :
68
        Memory contents of the EVM.
69
    start_position :
70
        Starting pointer to the memory.
71
    size :
72
        Size of the data that needs to be read from `start_position`.
73
74
    Returns
75
    -------
76
    data_bytes :
77
        Data read from memory.
78
    """
79
    return right_pad_zero_bytes(
80
        buffer[start_position : Uint(start_position) + Uint(size)], size
81
    )