Skip to content

Commit 8223b75

Browse files
holimanpizzarob
authored andcommitted
EIP2315: update opcodes (ethereum#2682)
1 parent 10acc97 commit 8223b75

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

EIPS/eip-2315.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ These changes do not affect the semantics of existing EVM code.
7474

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

77-
Bytecode: `0x6004b300b2b7`
77+
Bytecode: `0x60045e005c5d` (`PUSH1 0x04, JUMPSUB, STOP, BEGINSUB, RETURNSUB`)
7878

7979
| Pc | Op | Cost | Stack | RStack |
8080
|-------|-------------|------|-----------|-----------|
@@ -90,7 +90,7 @@ Consumed gas: `18`
9090

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

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

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

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

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

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

127-
Bytecode: `0xb75858` (`RETURNSUB`, `PC`, `PC`)
127+
Bytecode: `0x5d5858` (`RETURNSUB, PC, PC`)
128128

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

139139
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
140140

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

143143
| Pc | Op | Cost | Stack | RStack |
144144
|-------|-------------|------|-----------|-----------|
@@ -156,7 +156,7 @@ Consumed gas: `30`
156156

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

159-
Bytecode: `0xb2b700`
159+
Bytecode: `0x5c5d00` (`BEGINSUB, RETURNSUB, STOP`)
160160

161161

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

195195
```
196-
0xb2 BEGINSUB
197-
0xb3 JUMPSUB
198-
0xb7 RETURNSUB
196+
0x5c BEGINSUB
197+
0x5d RETURNSUB
198+
0x5e JUMPSUB
199199
```
200200

201201
## Security Considerations

0 commit comments

Comments
 (0)