Skip to content

Commit 35334d2

Browse files
authored
NEP: Stack Isolation for NeoVM (#22)
1 parent d63dbec commit 35334d2

File tree

3 files changed

+60
-4
lines changed

3 files changed

+60
-4
lines changed

README.mediawiki

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ First review [[nep-1.mediawiki|NEP-1]]. Then clone the repository and add your N
3737
| Dynamic Contract Invocation
3838
| localhuman, unignorant
3939
| Standard
40-
| Final
40+
| [[nep-8.mediawiki|Replaced]]
4141
|-
4242
| [[nep-5.mediawiki|5]]
4343
| Token Standard
@@ -57,11 +57,11 @@ First review [[nep-1.mediawiki|NEP-1]]. Then clone the repository and add your N
5757
| Standard
5858
| Final
5959
|-
60-
| [https://github.com/neo-project/proposals/pull/22 8]
60+
| [[nep-8.mediawiki|8]]
6161
| Stack Isolation for NeoVM
6262
| Erik Zhang
6363
| Standard
64-
| Accepted
64+
| Final
6565
|-
6666
| [[nep-9.mediawiki|9]]
6767
| URI Scheme

nep-4.mediawiki

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
Title: Dynamic Contract Invocation
44
Author: localhuman, unignorant
55
Type: Standard
6-
Status: Final
6+
Status: Replaced
77
Created: 2017-11-06
8+
Superseded-By: 8
89
</pre>
910

1011
==Abstract==

nep-8.mediawiki

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<pre>
2+
NEP: 8
3+
Title: Stack Isolation for NeoVM
4+
Author: Erik Zhang <[email protected]>
5+
Type: Standard
6+
Status: Final
7+
Created: 2017-12-26
8+
Replaces: 4
9+
</pre>
10+
11+
==Abstract==
12+
13+
This NEP proposes that stack isolation of the NeoVM evaluation stack should be carried out to ensure the security of dynamic invocations and provide support for future new features.
14+
15+
==Motivation==
16+
17+
Now that [[nep-4.mediawiki|NEP-4 (dynamic invocation)]] has been implemented, but because the NeoVM evaluation stack is not isolated, a dynamically invoked contract may break the caller's stack at runtime, resulting in the contract not being executed as expected.
18+
19+
On the other hand, some features, such as exception handling, also require stack isolation to be implemented.
20+
21+
==Rationale==
22+
23+
We need a new set of instructions so that each invocation creates a separate evaluation stack and automatically copies the arguments of the function to the new stack. After the function has finished running, the return value is automatically copied to the caller's stack. In this way, the invoked contract will no longer affect the caller's behavior by modifying with the stack.
24+
25+
==Specification==
26+
27+
We add five new instructions for starting invocations with stack isolation: <code>CALL_I</code>, <code>CALL_E</code>, <code>CALL_ED</code>, <code>CALL_ET</code>, <code>CALL_EDT</code>.
28+
29+
===CALL_I===
30+
31+
The instruction <code>CALL_I</code> is very similar to the old instruction <code>CALL</code>. The difference is that <code>CALL_I</code> requires an operand behind the instruction for representing the number of parameters and return values to copy.
32+
33+
===CALL_E===
34+
35+
The instruction <code>CALL_E</code> is very similar to the old instruction <code>APPCALL</code> for static invocations. The difference is that <code>CALL_E</code> requires an operand behind the instruction for representing the number of parameters and return values to copy.
36+
37+
===CALL_ED===
38+
39+
The instruction <code>CALL_ED</code> is very similar to the old instruction <code>APPCALL</code> for dynamic invocations. The difference is that <code>CALL_ED</code> requires an operand behind the instruction for representing the number of parameters and return values to copy.
40+
41+
===CALL_ET===
42+
43+
The instruction <code>CALL_ET</code> is very similar to the instruction <code>CALL_E</code>. The difference is that <code>CALL_ET</code> will start a tail call.
44+
45+
===CALL_EDT===
46+
47+
The instruction <code>CALL_EDT</code> is very similar to the instruction <code>CALL_ED</code>. The difference is that <code>CALL_EDT</code> will start a tail call.
48+
49+
==Backwards Compatibility==
50+
51+
All old contracts can be executed correctly in the original instruction set, but no new contracts are proposed to continue using the old instructions. When a new contract requires dynamic invocation, the old instructions should be avoided.
52+
53+
==Implementation==
54+
55+
https://github.com/neo-project/neo-vm/pull/39

0 commit comments

Comments
 (0)