Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EIP2315: update opcodes #2682

Merged
merged 1 commit into from
May 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions EIPS/eip-2315.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ These changes do not affect the semantics of existing EVM code.

This should jump into a subroutine, back out and stop.

Bytecode: `0x6004b300b2b7`
Bytecode: `0x60045e005c5d` (`PUSH1 0x04, JUMPSUB, STOP, BEGINSUB, RETURNSUB`)

| Pc | Op | Cost | Stack | RStack |
|-------|-------------|------|-----------|-----------|
Expand All @@ -90,7 +90,7 @@ Consumed gas: `18`

This should execute fine, going into one two depths of subroutines

Bytecode: `0x6800000000000000000cb300b26011b3b7b2b7`
Bytecode: `0x6800000000000000000c5e005c60115e5d5c5d` (`PUSH9 0x00000000000000000c, JUMPSUB, STOP, BEGINSUB, PUSH1 0x11, JUMPSUB, RETURNSUB, BEGINSUB, RETURNSUB`)

| Pc | Op | Cost | Stack | RStack |
|-------|-------------|------|-----------|-----------|
Expand All @@ -109,7 +109,7 @@ Consumed gas: `36`
This should fail, since the given location is outside of the code-range. The code is the same as previous example,
except that the pushed location is `0x01000000000000000c` instead of `0x0c`.

Bytecode: `0x6801000000000000000cb300b26011b3b7b2b7`
Bytecode: `0x6801000000000000000c5e005c60115e5d5c5d` (`PUSH9 0x01000000000000000c, JUMPSUB, STOP, BEGINSUB, PUSH1 0x11, JUMPSUB, RETURNSUB, BEGINSUB, RETURNSUB`)

| Pc | Op | Cost | Stack | RStack |
|-------|-------------|------|-----------|-----------|
Expand All @@ -124,7 +124,7 @@ Error: at pc=10, op=JUMPSUB: invalid jump destination

This should fail at first opcode, due to shallow `return_stack`

Bytecode: `0xb75858` (`RETURNSUB`, `PC`, `PC`)
Bytecode: `0x5d5858` (`RETURNSUB, PC, PC`)

| Pc | Op | Cost | Stack | RStack |
|-------|-------------|------|-----------|-----------|
Expand All @@ -138,7 +138,7 @@ Error: at pc=0, op=RETURNSUB: invalid retsub

In this example. the JUMPSUB is on the last byte of code. When the subroutine returns, it should hit the 'virtual stop' _after_ the bytecode, and not exit with error

Bytecode: `0x600556b2b75b6003b3`
Bytecode: `0x6005565c5d5b60035e` (`PUSH1 0x05, JUMP, BEGINSUB, RETURNSUB, JUMPDEST, PUSH1 0x03, JUMPSUB`)

| Pc | Op | Cost | Stack | RStack |
|-------|-------------|------|-----------|-----------|
Expand All @@ -156,7 +156,7 @@ Consumed gas: `30`

In this example, the code 'walks' into a subroutine, which is not allowed, and causes an error

Bytecode: `0xb2b700`
Bytecode: `0x5c5d00` (`BEGINSUB, RETURNSUB, STOP`)


| Pc | Op | Cost | Stack | RStack |
Expand Down Expand Up @@ -193,9 +193,9 @@ Benchmarking might be needed to tell if the costs are well-balanced.
We suggest the following opcodes:

```
0xb2 BEGINSUB
0xb3 JUMPSUB
0xb7 RETURNSUB
0x5c BEGINSUB
0x5d RETURNSUB
0x5e JUMPSUB
```

## Security Considerations
Expand Down