Skip to content

Commit

Permalink
Update EIP-5450: Add JUMPF simplification (ethereum#6101)
Browse files Browse the repository at this point in the history
* Update EIP-5450: Add JUMPF simplification change

* Apply stylistic suggestions and typo fixes from review

Co-authored-by: lightclient <[email protected]>

Co-authored-by: lightclient <[email protected]>
  • Loading branch information
gumb0 and lightclient authored Dec 8, 2022
1 parent 49c14e3 commit acd69bd
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions EIPS/eip-5450.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ Given new deploy-time guarantees, EVM implementation is not required anymore to

Stack overflow check, on the other hand, is still required at run-time, because function execution can start at arbitrary (i.e. known only at run-time) stack height at `CALLF` instruction of a caller (i.e. each execution can be in arbitrary inner call frame). Verification algorithm examines only stack height changes relative to starting stack height of the function.

#### JUMPF changes

In case a function pushed more items to the stack than is required as inputs by the jumped-to function, the previously defined `JUMPF` instruction behaviour was to remove the extra items:

> 3. If data stack has more than `caller_stack_height + type[code_section_index].inputs` items, discards the items between `caller_stack_height` and top `type[code_section_index].inputs`, so that there are exactly `caller_stack_height + type[code_section_index].items` items left.
Given the new deploy-time guarantee of no function underflowing its stack frame, `JUMPF` instruction can check only that there is enough items for input arguments of the callee on the stack, without making sure there is exactly `inputs` items and not more.

Therefore, the previously defined behavior of discarding extra items is removed, and only the check for enough inputs is done:

> 2. If data stack has less than `caller_stack_height + type[code_section_index].inputs` items, execution results in exceptional halt.
With this change `JUMPF` operation complexity does not depend on `ouputs` value and is constant-time, therefore the price of `JUMPF` is lowered to 3 gas.

## Rationale

### Stack overflow check only in CALLF
Expand Down

0 comments on commit acd69bd

Please sign in to comment.