Skip to content

Commit

Permalink
Update EIP-7069: Padding oob behavior of RETURNDATA*
Browse files Browse the repository at this point in the history
Align with ipsilon/eof#90
  • Loading branch information
pdobacz committed Jun 3, 2024
1 parent 2173502 commit 37eebbb
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions EIPS/eip-7069.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ status: Draft
type: Standards Track
category: Core
created: 2023-05-05
requires: 150, 211, 214, 2929
requires: 150, 211, 214, 2929, 3540
---

## Abstract

Introduce three new call instructions, `EXTCALL`, `EXTDELEGATECALL` and `EXTSTATICCALL`, with simplified semantics. Introduce another instruction, `RETURNDATALOAD` for loading a word from return data into stack. The existing call instructions remain unchanged.
Introduce three new call instructions, `EXTCALL`, `EXTDELEGATECALL` and `EXTSTATICCALL`, with simplified semantics. Introduce another instruction, `RETURNDATALOAD` for loading a word from return data into stack. Modify the behavior of `RETURNDATACOPY` instruction executed within EOF formatted code (as defined by [EIP-3540](./eip-3540.md)). The existing `*CALL` instructions remain unchanged.

The new instructions do not allow specifying a gas limit, but rather rely on the "63/64th rule" ([EIP-150](./eip-150.md)) to limit gas. An important improvement is the rules around the "stipend" are simplified, and callers do not need to perform special calculation whether the value is sent or not.

Expand Down Expand Up @@ -86,8 +86,16 @@ Execution semantics of `RETURNDATALOAD`:

1. Charge `G_verylow` (3) gas
2. Pop 1 item from the stack, to be referred to as `offset`
3. If `offset + 32 > len(returndata buffer)`, halt with exceptional failure.
4. Push 1 item onto the stack, the 32-byte word read from the returndata buffer starting at `offset`.
3. Push 1 item onto the stack, the 32-byte word read from the returndata buffer starting at `offset`.
4. If `offset + 32 > len(returndata buffer)`, the result is zero-padded.

In case this EIP is included as part of the greater EOF upgrade, execution semantics of `RETURNDATACOPY` in EOF formatted code ([EIP-3540](./eip-3540.md)) is modified as follows:

1. Assume the 3 arguments popped from stack are `destOffset`, `offset` and `size`.
2. If `offset + size > len(returndata buffer)` **do not** halt with exceptional failure, but instead set the `offset + size - len(returndata buffer)` memory bytes after the copied ones to zero.
3. Gas charged for memory copying remains `3 * num_words(size)`, regardless of the number of bytes actually copied or set to zero.

Execution of `RETURNDATACOPY` which is not in EOF formatted code (i.e. is in legacy code) is not changed.

<!-- *TODO:* Clarify which side (caller/callee) is gas deducted from and where an error originates from. -->

Expand Down

0 comments on commit 37eebbb

Please sign in to comment.