Skip to content

Commit

Permalink
Update EIP-6206: Clarify JUMPF specification
Browse files Browse the repository at this point in the history
Merged by EIP-Bot.
  • Loading branch information
gumb0 authored Jul 13, 2023
1 parent d1db66f commit 4c5b64a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions EIPS/eip-6206.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,19 @@ A new instruction, `JUMPF (0xb2)`, is introduced.
### Execution Semantics

1. `JUMPF` has one immediate argument, `code_section_index`, encoded as a 16-bit unsigned big-endian value.
2. If the operand stack size exceeds `1024 - type[code_section_index].max_stack_height` (i.e. if the called function may exceed the global stack height limit), execution results in an exceptional halt. This guarantees that the stack height after the call is within the limits.
3. `JUMPF` costs 5 gas.
4. `JUMPF` neither pops nor pushes anything to the operand stack.
2. If the operand stack size exceeds `1024 - type[code_section_index].max_stack_height` (i.e. if the called function may exceed the global stack height limit), execution results in an exceptional halt. This guarantees that the target function does not exceed global stack height limit.
3. `JUMPF` sets `current_section_index` to `code_section_index` and `PC` to `0`, but does not change the return stack. Execution continues in the target section.
4. `JUMPF` costs 5 gas.
5. `JUMPF` neither pops nor pushes anything to the operand stack.

### Code Validation

Let the definition of `type[i]` be inherited from [EIP-4750](./eip-4750.md) and define `stack_height` to be the height of the stack at a certain instruction during the instruction flow traversal if the operand stack at the start of the function were equal to `type[i].inputs`.

* The immediate argument of `JUMPF` MUST be less than the total number of code sections.
* For each `JUMPF` instruction `type[current_section_index].outputs` MUST be greater or equal `type[code_section_index].outputs`.
* The stack height at `JUMPF` MUST be equal to `type[current_section_index].outputs + type[code_section_index].inputs - type[code_section_index].outputs`. This means that `code_section_index` can output less stack elements than the original code section called by the top element on the return stack, if the `current_section_index` code section leaves the delta `type[current_section_index].outputs - type[code_section_index].outputs` element(s) on the stack.
* The stack height at `JUMPF` MUST be equal to `type[current_section_index].outputs + type[code_section_index].inputs - type[code_section_index].outputs`. This means that target section can output less stack elements than the original code section called by the top element on the return stack, if the current code section leaves the delta `type[current_section_index].outputs - type[code_section_index].outputs` element(s) on the stack.
* `JUMPF` is considered terminating instruction, i.e. does not have successor instructions in code validation and MAY be final instruction in the section.
* The code validation defined in [EIP-4200](./eip-4200.md) also fails if any `RJUMP*` offset points to one of the two bytes directly following a `JUMPF` instruction.

## Rationale
Expand Down

0 comments on commit 4c5b64a

Please sign in to comment.