Skip to content

Commit

Permalink
Extend the memory based on the furthest memory access location.
Browse files Browse the repository at this point in the history
- Between source and destination, the memory is extended based on the
  furthest memory access location.
  • Loading branch information
fselmo committed Mar 9, 2024
1 parent 02dac4a commit 8174c7c
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions eth/vm/logic/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,9 @@ def msize(computation: ComputationAPI) -> None:
def mcopy(computation: ComputationAPI) -> None:
dst, src, length = computation.stack_pop_ints(3)

# Extend the memory to cover the entire range of the copy. This will make sure that
# the memory is allocated for the entire range and that the gas cost is correctly
# calculated.
computation.extend_memory(src, length)
computation.extend_memory(dst, length)
# extend the memory based on the maximum of the src and dst to ensure that
# we have enough space to copy the memory and to account for the gas cost
computation.extend_memory(max(src, dst), length)

word_count = ceil32(length) // 32
g_copy = constants.GAS_COPY * word_count
Expand Down

0 comments on commit 8174c7c

Please sign in to comment.