-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvyperProto.proto
237 lines (202 loc) · 4.19 KB
/
vyperProto.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
syntax = "proto3";
message Int {
uint32 n = 1;
bool sign = 2;
}
message Bool {
}
message Decimal {
}
message BytesM {
uint32 m = 1;
}
message String {
uint32 max_len = 1;
}
message Address{}
message ByteArray{
uint32 max_len = 1;
}
message VarRef {
oneof type {
Bool b = 2;
Decimal d = 3;
BytesM bM = 4;
String s = 5;
Address adr = 6;
ByteArray barr = 7;
}
Int i = 1;
uint32 varnum = 8;
}
message Literal {
oneof literal_oneof {
bool boolval = 2;
uint64 decimalval = 3; // TO-DO: make this as int64 to enable signed variables
bytes bMval = 4;
string strval = 5;
uint32 addval = 6;
uint32 barrval = 7;
}
uint64 intval = 1; // check if we can make it just int
}
message BinaryOp {
enum BOp {
ADD = 0;
SUB = 1;
MUL = 2;
DIV = 3;
MOD = 4;
EXP = 5;
AND = 6;
OR = 7;
EQ = 8;
INEQ = 9;
LESS = 10;
LESSEQ = 11;
GREATER = 12;
GREATEREQ = 13;
BIT_AND = 14;
BIT_OR = 15;
BIT_XOR = 16;
LEFT_SHIFT = 17;
RIGHT_SHIFT = 18;
}
BOp op = 1;
Expression left = 2;
Expression right = 3;
}
message UnaryOp {
enum UOp {
NOT = 0;
MINUS = 1;
BIT_NOT = 2;
BALANCE = 3;
CODEHASH = 4;
CODESIZE = 5;
IS_CONTRACT = 6;
CODE = 7;
}
UOp op = 1;
Expression expr = 2;
}
message Expression {
oneof expr_oneof {
Literal cons = 2;
BinaryOp binop = 3;
UnaryOp unop = 4;
// NullaryOp nop = 5;
CreateMinimalProxy cr_min_proxy = 5;
CreateFromBlueprint cr_bp = 6;
Sha256 sha = 7;
}
VarRef varref = 1;
}
message IfStmtCase {
Expression cond = 1;
Block if_body = 2;
}
message IfStmt {
repeated IfStmtCase cases = 1;
optional Block else_case = 2;
}
message ForStmtRanged {
int32 start = 1;
int32 stop = 2;
}
// imo should be expression, but there are restrictions
// ref_id for range(x, x + N)
message ForStmtVariable {
optional VarRef ref_id = 1;
int32 length = 2;
}
message ForStmt {
oneof for_oneof {
ForStmtVariable variable = 2;
}
ForStmtRanged ranged = 1;
Block body = 3;
}
message VarDecl {
oneof type {
Bool b = 2;
Decimal d = 3;
BytesM bM = 4;
String s = 5;
Address adr = 6;
ByteArray barr = 7;
}
Int i = 1;
Expression expr = 8;
}
message AssignmentStatement {
VarRef ref_id = 1;
Expression expr = 2;
}
// probably add builtins to expression too
message Statement {
oneof stmt_oneof {
VarDecl decl = 1;
ForStmt for_stmt = 3;
IfStmt if_stmt = 4;
Selfdestruct selfd = 7;
}
AssignmentStatement assignment = 2;
}
message Block {
repeated Statement statements = 1;
}
message Reentrancy {
string key = 1;
}
message FuncParam {
oneof type {
Bool b = 2;
Decimal d = 3;
BytesM bM = 4;
String s = 5;
Address adr = 6;
ByteArray barr = 7;
}
Int i = 1;
}
message Func {
enum Visibility {
EXTERNAL = 0;
INTERNAL = 1;
}
enum Mutability {
PURE = 0;
VIEW = 1;
NONPAYABLE = 2;
PAYABLE = 3;
}
Visibility vis = 1;
Mutability mut = 2;
optional Reentrancy ret = 3;
repeated FuncParam input_params = 4;
repeated FuncParam output_params = 5;
Block block = 6;
}
message Contract {
repeated VarDecl decls = 1;
repeated Func functions = 2;
}
message CreateMinimalProxy{
Expression target = 1;
optional Expression value = 2;
optional Expression salt = 3;
}
message CreateFromBlueprint{
Expression target = 1;
repeated Expression args = 2;
optional Expression value = 3;
optional Expression code_offset = 4;
optional Expression salt = 5;
}
message Selfdestruct{
Expression to = 1;
}
message Sha256{
Expression value = 1;
}