Skip to content

Latest commit

 

History

History
39 lines (28 loc) · 1.36 KB

5E.mdx

File metadata and controls

39 lines (28 loc) · 1.36 KB
fork group
Cancun
Stack Memory Storage and Flow Operations

Index 1 is top of the stack.

Notes

Copying takes place as if an intermediate buffer was used, allowing the destination and source to overlap. If size > 0 and (src + size or dst + size) is beyond the current memory size, the memory is extended with respective gas cost applied.

Stack input

  1. destOffset: byte offset in the memory where the result will be copied.
  2. offset: byte offset in the memory from which to copy.
  3. size: byte size to copy.

Examples

* Input 1 *
1 0 *
2 32 *
3 32 *
Memory before
0000000000000000000000000000000000000000000000000000000000000000 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f
Memory after
000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f

Reproduce in playground.

Gas

static_gas = 3
dynamic_gas = 3 * words_copied + memory_expansion_cost