ethereum.forks.frontier.vm.memoryethereum.forks.homestead.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 | """ |
| 36 | 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) -> Bytes:
| 42 | """ |
|---|---|
| 43 | Read bytes from memory. |
| 44 | |
| 45 | Parameters |
| 46 | ---------- |
| 47 | memory : |
| 48 | Memory contents of the EVM. |
| 49 | start_position : |
| 50 | Starting pointer to the memory. |
| 51 | size : |
| 52 | Size of the data that needs to be read from `start_position`. |
| 53 | |
| 54 | Returns |
| 55 | ------- |
| 56 | data_bytes : |
| 57 | Data read from memory. |
| 58 | |
| 59 | """ |
| 60 | return Bytes(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:
| 64 | """ |
|---|---|
| 65 | Read bytes from a buffer. Padding with zeros if necessary. |
| 66 | |
| 67 | Parameters |
| 68 | ---------- |
| 69 | buffer : |
| 70 | Memory contents of the EVM. |
| 71 | start_position : |
| 72 | Starting pointer to the memory. |
| 73 | size : |
| 74 | Size of the data that needs to be read from `start_position`. |
| 75 | |
| 76 | Returns |
| 77 | ------- |
| 78 | data_bytes : |
| 79 | Data read from memory. |
| 80 | |
| 81 | """ |
| 82 | return right_pad_zero_bytes( |
| 83 | buffer[start_position : Uint(start_position) + Uint(size)], size |
| 84 | ) |