mirror of
https://github.com/status-im/EIPs.git
synced 2025-02-24 12:48:20 +00:00
EIP-2315: update jumpsub gascost and add back testcases (#2669)
This commit is contained in:
parent
2661ee5203
commit
57c863dc30
@ -80,7 +80,7 @@ Bytecode: `0x6004b300b2b7`
|
|||||||
| Pc | Op | Cost | Stack | RStack |
|
| Pc | Op | Cost | Stack | RStack |
|
||||||
|-------|-------------|------|-----------|-----------|
|
|-------|-------------|------|-----------|-----------|
|
||||||
| 0 | PUSH1 | 3 | [] | [] |
|
| 0 | PUSH1 | 3 | [] | [] |
|
||||||
| 2 | JUMPSUB | 5 | [4] | [] |
|
| 2 | JUMPSUB | 8 | [4] | [] |
|
||||||
| 5 | RETURNSUB | 2 | [] | [ 2] |
|
| 5 | RETURNSUB | 2 | [] | [ 2] |
|
||||||
| 3 | STOP | 0 | [] | [] |
|
| 3 | STOP | 0 | [] | [] |
|
||||||
|
|
||||||
@ -92,9 +92,9 @@ Bytecode: `0x6800000000000000000cb300b26011b3b7b2b7`
|
|||||||
| Pc | Op | Cost | Stack | RStack |
|
| Pc | Op | Cost | Stack | RStack |
|
||||||
|-------|-------------|------|-----------|-----------|
|
|-------|-------------|------|-----------|-----------|
|
||||||
| 0 | PUSH9 | 3 | [] | [] |
|
| 0 | PUSH9 | 3 | [] | [] |
|
||||||
| 10 | JUMPSUB | 5 | [12] | [] |
|
| 10 | JUMPSUB | 8 | [12] | [] |
|
||||||
| 13 | PUSH1 | 3 | [] | [10] |
|
| 13 | PUSH1 | 3 | [] | [10] |
|
||||||
| 15 | JUMPSUB | 5 | [17] | [10] |
|
| 15 | JUMPSUB | 8 | [17] | [10] |
|
||||||
| 18 | RETURNSUB | 2 | [] | [10,15] |
|
| 18 | RETURNSUB | 2 | [] | [10,15] |
|
||||||
| 16 | RETURNSUB | 2 | [] | [10] |
|
| 16 | RETURNSUB | 2 | [] | [10] |
|
||||||
| 11 | STOP | 0 | [] | [] |
|
| 11 | STOP | 0 | [] | [] |
|
||||||
@ -110,7 +110,7 @@ Bytecode: `0x6801000000000000000cb300b26011b3b7b2b7 `
|
|||||||
| Pc | Op | Cost | Stack | RStack |
|
| Pc | Op | Cost | Stack | RStack |
|
||||||
|-------|-------------|------|-----------|-----------|
|
|-------|-------------|------|-----------|-----------|
|
||||||
| 0 | PUSH9 | 3 | [] | [] |
|
| 0 | PUSH9 | 3 | [] | [] |
|
||||||
| 10 | JUMPSUB | 5 |[18446744073709551628] | [] |
|
| 10 | JUMPSUB | 8 |[18446744073709551628] | [] |
|
||||||
|
|
||||||
```
|
```
|
||||||
Error: at pc=10, op=JUMPSUB: evm: invalid jump destination
|
Error: at pc=10, op=JUMPSUB: evm: invalid jump destination
|
||||||
@ -143,12 +143,25 @@ Bytecode: `0x600556b2b75b6003b3`
|
|||||||
| 2 | JUMP | 8 | [5] | [] |
|
| 2 | JUMP | 8 | [5] | [] |
|
||||||
| 5 | JUMPDEST | 1 | [] | [] |
|
| 5 | JUMPDEST | 1 | [] | [] |
|
||||||
| 6 | PUSH1 | 3 | [] | [] |
|
| 6 | PUSH1 | 3 | [] | [] |
|
||||||
| 8 | JUMPSUB | 5 | [3] | [] |
|
| 8 | JUMPSUB | 8 | [3] | [] |
|
||||||
| 3 | BEGINSUB | 1 | [] | [ 8] |
|
|
||||||
| 4 | RETURNSUB | 2 | [] | [ 8] |
|
| 4 | RETURNSUB | 2 | [] | [ 8] |
|
||||||
| 9 | STOP | 0 | [] | [] |
|
| 9 | STOP | 0 | [] | [] |
|
||||||
|
|
||||||
Consumed gas: `26`
|
Consumed gas: `25`
|
||||||
|
|
||||||
|
### Error on "walk-into-subroutine"
|
||||||
|
|
||||||
|
In this example, the code 'walks' into a subroutine, which is not allowed, and causes an error
|
||||||
|
|
||||||
|
| Pc | Op | Cost | Stack | RStack |
|
||||||
|
|-------|-------------|------|-----------|-----------|
|
||||||
|
| 0 | BEGINSUB | 1 | [] | [] |
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
Error: at pc=0, op=BEGINSUB: invalid subroutine entry
|
||||||
|
```
|
||||||
|
**Note 5**: The content of the error message, (`invalid subroutine entry`) is implementation-specific.
|
||||||
|
|
||||||
## Implementations
|
## Implementations
|
||||||
|
|
||||||
@ -162,7 +175,7 @@ The changes for the current version are trivial.
|
|||||||
|
|
||||||
### Costs and Codes
|
### Costs and Codes
|
||||||
|
|
||||||
We suggest that the cost of `JUMPSUB` be _low_, and `RETURNSUB` be _verylow_.
|
We suggest that the cost of `BEGINSUB` be _base_, `JUMPSUB` be _mid_, and `RETURNSUB` be _verylow_.
|
||||||
Measurement will tell. We suggest the following opcodes:
|
Measurement will tell. We suggest the following opcodes:
|
||||||
|
|
||||||
```
|
```
|
||||||
@ -171,6 +184,8 @@ We suggest that the cost of `JUMPSUB` be _low_, and `RETURNSUB` be _verylow_.
|
|||||||
0xb7 RETURNSUB
|
0xb7 RETURNSUB
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Note 6**: Although specified at _base_, the cost of `BEGINSUB` does not matter in practice, since `BEGINSUB` never executes without error.
|
||||||
|
|
||||||
## Security Considerations
|
## Security Considerations
|
||||||
|
|
||||||
These changes do introduce new flow control instructions, so any software which does static/dynamic analysis of evm-code
|
These changes do introduce new flow control instructions, so any software which does static/dynamic analysis of evm-code
|
||||||
|
Loading…
x
Reference in New Issue
Block a user