Coverage Summary for Class: OpCodes (org.ethereum.vm)
Class |
Class, %
|
Method, %
|
Line, %
|
OpCodes |
0%
(0/1)
|
0%
(0/1)
|
0%
(0/1)
|
1 /*
2 * This file is part of RskJ
3 * Copyright (C) 2017 RSK Labs Ltd.
4 * (derived from ethereumJ library, Copyright (c) 2016 <ether.camp>)
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20
21 package org.ethereum.vm;
22
23 /**
24 * Created by Sergio on 07/07/2016.
25 */
26 public class OpCodes {
27
28 private OpCodes() {
29
30 }
31
32 /**
33 * Halts execution (0x00)
34 */
35 static final byte OP_STOP =0x00;
36
37 /* Arithmetic Operations */
38
39 /**
40 * (0x01) Addition operation
41 */
42 static final byte OP_ADD =0x01 ;
43 /**
44 * (0x02) Multiplication operation
45 */
46 static final byte OP_MUL =0x02 ;
47 /**
48 * (0x03) Subtraction operations
49 */
50 static final byte OP_SUB =0x03 ;
51 /**
52 * (0x04) Integer division operation
53 */
54 static final byte OP_DIV =0x04 ;
55 /**
56 * (0x05) Signed integer division operation
57 */
58 static final byte OP_SDIV =0x05 ;
59 /**
60 * (0x06) Modulo remainder operation
61 */
62 static final byte OP_MOD =0x06 ;
63 /**
64 * (0x07) Signed modulo remainder operation
65 */
66 static final byte OP_SMOD =0x07 ;
67 /**
68 * (0x08) Addition combined with modulo
69 * remainder operation
70 */
71 static final byte OP_ADDMOD =0x08 ;
72 /**
73 * (0x09) Multiplication combined with modulo
74 * remainder operation
75 */
76 static final byte OP_MULMOD =0x09 ;
77 /**
78 * (0x0a) Exponential operation
79 */
80 static final byte OP_EXP =0x0a ;
81 /**
82 * (0x0b) end length of signed integer
83 */
84 static final byte OP_SIGNEXTEND =0x0b ;
85
86 /* Bitwise Logic & Comparison Operations */
87
88 /**
89 * (0x10) Less-than comparison
90 */
91 static final byte OP_LT =0X10 ;
92 /**
93 * (0x11) Greater-than comparison
94 */
95 static final byte OP_GT =0X11 ;
96 /**
97 * (0x12) Signed less-than comparison
98 */
99 static final byte OP_SLT =0X12 ;
100 /**
101 * (0x13) Signed greater-than comparison
102 */
103 static final byte OP_SGT =0X13 ;
104 /**
105 * (0x14) Equality comparison
106 */
107 static final byte OP_EQ =0X14 ;
108 /**
109 * (0x15) Negation operation
110 */
111 static final byte OP_ISZERO =0x15 ;
112 /**
113 * (0x16) Bitwise AND operation
114 */
115 static final byte OP_AND =0x16 ;
116 /**
117 * (0x17) Bitwise OR operation
118 */
119 static final byte OP_OR =0x17 ;
120 /**
121 * (0x18) Bitwise XOR operation
122 */
123 static final byte OP_XOR =0x18 ;
124 /**
125 * (0x19) Bitwise NOT operationr
126 */
127 static final byte OP_NOT =0x19 ;
128 /**
129 * (0x1a) Retrieve single byte from word
130 */
131 static final byte OP_BYTE =0x1a ;
132
133 /**
134 * (0x1b) Bitwise SHIFT LEFT operation
135 */
136 public static final byte OP_SHL =0x1b ;
137 /**
138 * (0x1c) Bitwise SHIFT RIGHT operation
139 */
140 public static final byte OP_SHR =0x1c ;
141 /**
142 * (0x1d) Bitwise ARITHMETIC SHIFT RIGHT operation
143 */
144 public static final byte OP_SAR =0x1d ;
145
146 /* Cryptographic Operations */
147
148 /**
149 * (0x20) Compute SHA3-256 hash
150 */
151 static final byte OP_SHA_3 =0x20 ;
152
153 /* Environmental Information */
154
155 /**
156 * (0x30) Get address of currently
157 * executing account
158 */
159 static final byte OP_ADDRESS =0x30 ;
160 /**
161 * (0x31) Get balance of the given account
162 */
163 static final byte OP_BALANCE =0x31 ;
164 /**
165 * (0x32) Get execution origination address
166 */
167 static final byte OP_ORIGIN =0x32 ;
168 /**
169 * (0x33) Get caller address
170 */
171 static final byte OP_CALLER =0x33 ;
172 /**
173 * (0x34) Get deposited value by the
174 * instruction/transaction responsible
175 * for this execution
176 */
177 static final byte OP_CALLVALUE =0x34 ;
178 /**
179 * (0x35) Get input data of current
180 * environment
181 */
182 static final byte OP_CALLDATALOAD =0x35 ;
183 /**
184 * (0x36) Get size of input data in current
185 * environment
186 */
187 static final byte OP_CALLDATASIZE =0x36 ;
188 /**
189 * (0x37) Copy input data in current
190 * environment to memory
191 */
192 static final byte OP_CALLDATACOPY =0x37 ;
193 /**
194 * (0x38) Get size of code running in
195 * current environment
196 */
197 static final byte OP_CODESIZE =0x38 ;
198 /**
199 * (0x39) Copy code running in current
200 * environment to memory
201 */
202 static final byte OP_CODECOPY =0x39 ; // [len code_start mem_start CODECOPY]
203 /**
204 * (0x3a) Get price of gas in current
205 * environment
206 */
207 static final byte OP_GASPRICE =0x3a ;
208 /**
209 * (0x3b) Get size of code running in
210 * current environment with given offset
211 */
212 static final byte OP_EXTCODESIZE =0x3b ;
213 /**
214 * (0x3c) Copy code running in current
215 * environment to memory with given offset
216 */
217 static final byte OP_EXTCODECOPY =0x3c;
218 /**
219 * (0x3d and 0x3e) A mechanism to allow
220 * returning arbitrary-length data.
221 * After a call, return data is kept inside
222 * a virtual buffer from which the caller
223 * can copy it (or parts thereof) into
224 * memory. At the next call, the buffer is
225 * overwritten.
226 */
227 static final byte OP_RETURNDATASIZE = 0x3d;
228 static final byte OP_RETURNDATACOPY = 0x3e;
229
230 /**
231 * (0x3f) Get hash of code running in current
232 * environment
233 */
234 public static final byte OP_EXTCODEHASH = 0x3f;
235
236 /* Block Information */
237
238 /**
239 * (0x40) Get hash of most recent
240 * complete block
241 */
242 static final byte OP_BLOCKHASH =0x40 ;
243 /**
244 * (0x41) Get the block’s coin address
245 */
246 static final byte OP_COINBASE =0x41 ;
247 /**
248 * (x042) Get the block’s timestamp
249 */
250 static final byte OP_TIMESTAMP =0x42 ;
251 /**
252 * (0x43) Get the block’s number
253 */
254 static final byte OP_NUMBER =0x43 ;
255 /**
256 * (0x44) Get the block’s difficulty
257 */
258 static final byte OP_DIFFICULTY =0x44 ;
259 /**
260 * (0x45) Get the block’s gas limit
261 */
262 static final byte OP_GASLIMIT =0x45 ;
263 /**
264 * (0x46) Get the chain id
265 */
266 public static final byte OP_CHAINID =0x46 ;
267 /**
268 * (0x45) Get the senders balance
269 */
270 public static final byte OP_SELFBALANCE = 0x47 ;
271
272 /* Memory Storage and F Operations */
273
274 /**
275 * (0x50) Remove item from stack
276 */
277 static final byte OP_POP =0x50 ;
278 /**
279 * (0x51) Load word from memory
280 */
281 static final byte OP_MLOAD =0x51 ;
282 /**
283 * (0x52) Save word to memory
284 */
285 static final byte OP_MSTORE =0x52 ;
286 /**
287 * (0x53) Save byte to memory
288 */
289 static final byte OP_MSTORE_8 =0x53 ;
290 /**
291 * (0x54) Load word from storage
292 */
293 static final byte OP_SLOAD =0x54 ;
294 /**
295 * (0x55) Save word to storage
296 */
297 static final byte OP_SSTORE =0x55 ;
298 /**
299 * (0x56) Alter the program counter
300 */
301 static final byte OP_JUMP =0x56 ;
302 /**
303 * (0x57) Conditionally alter the program
304 * counter
305 */
306 static final byte OP_JUMPI =0x57;
307 /**
308 * (0x58) Get the program counter
309 */
310 static final byte OP_PC =0x58 ;
311 /**
312 * (0x59) Get the size of active memory
313 */
314 static final byte OP_MSIZE =0x59 ;
315 /**
316 * (0x5a) Get the amount of available gas
317 */
318 static final byte OP_GAS =0x5a ;
319 /**
320 * (0x5b)
321 */
322 static final byte OP_JUMPDEST =0x5b ;
323
324 /* Push Operations */
325
326 /**
327 * (0x60) Place 1-byte item on stack
328 */
329 static final byte OP_PUSH_1 =0x60 ;
330 /**
331 * (0x61) Place 2-byte item on stack
332 */
333 static final byte OP_PUSH_2 =0x61 ;
334 /**
335 * (0x62) Place 3-byte item on stack
336 */
337 static final byte OP_PUSH_3 =0x62 ;
338 /**
339 * (0x63) Place 4-byte item on stack
340 */
341 static final byte OP_PUSH_4 =0x63 ;
342 /**
343 * (0x64) Place 5-byte item on stack
344 */
345 static final byte OP_PUSH_5 =0x64 ;
346 /**
347 * (0x65) Place 6-byte item on stack
348 */
349 static final byte OP_PUSH_6 =0x65 ;
350 /**
351 * (0x66) Place 7-byte item on stack
352 */
353 static final byte OP_PUSH_7 =0x66 ;
354 /**
355 * (0x67) Place 8-byte item on stack
356 */
357 static final byte OP_PUSH_8 =0x67 ;
358 /**
359 * (0x68) Place 9-byte item on stack
360 */
361 static final byte OP_PUSH_9 =0x68 ;
362 /**
363 * (0x69) Place 10-byte item on stack
364 */
365 static final byte OP_PUSH_10 =0x69 ;
366 /**
367 * (0x6a) Place 11-byte item on stack
368 */
369 static final byte OP_PUSH_11 =0x6a ;
370 /**
371 * (0x6b) Place 12-byte item on stack
372 */
373 static final byte OP_PUSH_12 =0x6b ;
374 /**
375 * (0x6c) Place 13-byte item on stack
376 */
377 static final byte OP_PUSH_13 =0x6c ;
378 /**
379 * (0x6d) Place 14-byte item on stack
380 */
381 static final byte OP_PUSH_14 =0x6d ;
382 /**
383 * (0x6e) Place 15-byte item on stack
384 */
385 static final byte OP_PUSH_15 =0x6e ;
386 /**
387 * (0x6f) Place 16-byte item on stack
388 */
389 static final byte OP_PUSH_16 =0x6f ;
390 /**
391 * (0x70) Place 17-byte item on stack
392 */
393 static final byte OP_PUSH_17 =0x70 ;
394 /**
395 * (0x71) Place 18-byte item on stack
396 */
397 static final byte OP_PUSH_18 =0x71 ;
398 /**
399 * (0x72) Place 19-byte item on stack
400 */
401 static final byte OP_PUSH_19 =0x72 ;
402 /**
403 * (0x73) Place 20-byte item on stack
404 */
405 static final byte OP_PUSH_20 =0x73 ;
406 /**
407 * (0x74) Place 21-byte item on stack
408 */
409 static final byte OP_PUSH_21 =0x74 ;
410 /**
411 * (0x75) Place 22-byte item on stack
412 */
413 static final byte OP_PUSH_22 =0x75 ;
414 /**
415 * (0x76) Place 23-byte item on stack
416 */
417 static final byte OP_PUSH_23 =0x76 ;
418 /**
419 * (0x77) Place 24-byte item on stack
420 */
421 static final byte OP_PUSH_24 =0x77 ;
422 /**
423 * (0x78) Place 25-byte item on stack
424 */
425 static final byte OP_PUSH_25 =0x78 ;
426 /**
427 * (0x79) Place 26-byte item on stack
428 */
429 static final byte OP_PUSH_26 =0x79 ;
430 /**
431 * (0x7a) Place 27-byte item on stack
432 */
433 static final byte OP_PUSH_27 =0x7a ;
434 /**
435 * (0x7b) Place 28-byte item on stack
436 */
437 static final byte OP_PUSH_28 =0x7b ;
438 /**
439 * (0x7c) Place 29-byte item on stack
440 */
441 static final byte OP_PUSH_29 =0x7c ;
442 /**
443 * (0x7d) Place 30-byte item on stack
444 */
445 static final byte OP_PUSH_30 =0x7d ;
446 /**
447 * (0x7e) Place 31-byte item on stack
448 */
449 static final byte OP_PUSH_31 =0x7e ;
450 /**
451 * (0x7f) Place 32-byte (full word)
452 * item on stack
453 */
454 static final byte OP_PUSH_32 =0x7f ;
455
456 /* Duplicate Nth item from the stack */
457
458 /**
459 * (0x80) Duplicate 1st item on stack
460 */
461 static final byte OP_DUP_1 =(byte)0x80 ;
462 /**
463 * (0x81) Duplicate 2nd item on stack
464 */
465 static final byte OP_DUP_2 =(byte)0x81 ;
466 /**
467 * (0x82) Duplicate 3rd item on stack
468 */
469 static final byte OP_DUP_3 =(byte)0x82 ;
470 /**
471 * (0x83) Duplicate 4th item on stack
472 */
473 static final byte OP_DUP_4 =(byte)0x83 ;
474 /**
475 * (0x84) Duplicate 5th item on stack
476 */
477 static final byte OP_DUP_5 =(byte)0x84 ;
478 /**
479 * (0x85) Duplicate 6th item on stack
480 */
481 static final byte OP_DUP_6 =(byte)0x85 ;
482 /**
483 * (0x86) Duplicate 7th item on stack
484 */
485 static final byte OP_DUP_7 =(byte)0x86 ;
486 /**
487 * (0x87) Duplicate 8th item on stack
488 */
489 static final byte OP_DUP_8 =(byte)0x87 ;
490 /**
491 * (0x88) Duplicate 9th item on stack
492 */
493 static final byte OP_DUP_9 =(byte)0x88 ;
494 /**
495 * (0x89) Duplicate 10th item on stack
496 */
497 static final byte OP_DUP_10 =(byte)0x89 ;
498 /**
499 * (0x8a) Duplicate 11th item on stack
500 */
501 static final byte OP_DUP_11 =(byte)0x8a ;
502 /**
503 * (0x8b) Duplicate 12th item on stack
504 */
505 static final byte OP_DUP_12 =(byte)0x8b ;
506 /**
507 * (0x8c) Duplicate 13th item on stack
508 */
509 static final byte OP_DUP_13 =(byte)0x8c ;
510 /**
511 * (0x8d) Duplicate 14th item on stack
512 */
513 static final byte OP_DUP_14 =(byte)0x8d ;
514 /**
515 * (0x8e) Duplicate 15th item on stack
516 */
517 static final byte OP_DUP_15 =(byte)0x8e ;
518 /**
519 * (0x8f) Duplicate 16th item on stack
520 */
521 static final byte OP_DUP_16 =(byte)0x8f ;
522
523 /* Swap the Nth item from the stack with the top */
524
525 /**
526 * (0x90) Exchange 2nd item from stack with the top
527 */
528 static final byte OP_SWAP_1 =(byte)0x90 ;
529 /**
530 * (0x91) Exchange 3rd item from stack with the top
531 */
532 static final byte OP_SWAP_2 =(byte)0x91 ;
533 /**
534 * (0x92) Exchange 4th item from stack with the top
535 */
536 static final byte OP_SWAP_3 =(byte)0x92 ;
537 /**
538 * (0x93) Exchange 5th item from stack with the top
539 */
540 static final byte OP_SWAP_4 =(byte)0x93 ;
541 /**
542 * (0x94) Exchange 6th item from stack with the top
543 */
544 static final byte OP_SWAP_5 =(byte)0x94 ;
545 /**
546 * (0x95) Exchange 7th item from stack with the top
547 */
548 static final byte OP_SWAP_6 =(byte)0x95 ;
549 /**
550 * (0x96) Exchange 8th item from stack with the top
551 */
552 static final byte OP_SWAP_7 =(byte)0x96 ;
553 /**
554 * (0x97) Exchange 9th item from stack with the top
555 */
556 static final byte OP_SWAP_8 =(byte)0x97 ;
557 /**
558 * (0x98) Exchange 10th item from stack with the top
559 */
560 static final byte OP_SWAP_9 =(byte)0x98 ;
561 /**
562 * (0x99) Exchange 11th item from stack with the top
563 */
564 static final byte OP_SWAP_10 =(byte)0x99;
565 /**
566 * (0x9a) Exchange 12th item from stack with the top
567 */
568 static final byte OP_SWAP_11 =(byte)0x9a ;
569 /**
570 * (0x9b) Exchange 13th item from stack with the top
571 */
572 static final byte OP_SWAP_12 =(byte)0x9b ;
573 /**
574 * (0x9c) Exchange 14th item from stack with the top
575 */
576 static final byte OP_SWAP_13 =(byte)0x9c ;
577 /**
578 * (0x9d) Exchange 15th item from stack with the top
579 */
580 static final byte OP_SWAP_14 =(byte)0x9d ;
581 /**
582 * (0x9e) Exchange 16th item from stack with the top
583 */
584 static final byte OP_SWAP_15 =(byte)0x9e ;
585 /**
586 * (0x9f) Exchange 17th item from stack with the top
587 */
588 static final byte OP_SWAP_16 =(byte)0x9f ;
589
590 /**
591 * (0xa[n]) log some data for some addres with 0..n tags [addr [tag0..tagn] data]
592 */
593 static final byte OP_LOG_0 =(byte)0xa0 ;
594 static final byte OP_LOG_1 =(byte)0xa1 ;
595 static final byte OP_LOG_2 =(byte)0xa2 ;
596 static final byte OP_LOG_3 =(byte)0xa3 ;
597 static final byte OP_LOG_4 =(byte)0xa4 ;
598
599 /* System operations */
600 static final byte OP_DUPN = (byte)0xa8;
601 static final byte OP_SWAPN = (byte)0xa9;
602 static final byte OP_TXINDEX = (byte)0xaa;
603
604 /**
605 * (0xf0) Create a new account with associated code
606 */
607 static final byte OP_CREATE =(byte)0xf0 ; // [in_size] [in_offs] [gas_val] CREATE
608 /**
609 * (cxf1) Message-call into an account
610 */
611 static final byte OP_CALL =(byte)0xf1 ; // [out_data_size] [out_data_start] [in_data_size] [in_data_start] [value] [to_addr]
612 // [gas] CALL
613 /**
614 * (0xf2) Calls self but grabbing the code from the
615 * TO argument instead of from one's own address
616 */
617 static final byte OP_CALLCODE =(byte)0xf2 ;
618 /**
619 * (0xf3) Halt execution returning output data
620 */
621 static final byte OP_RETURN =(byte)0xf3 ;
622
623 /**
624 * (0xf4) similar in idea to CALLCODE except that it propagates the sender and value
625 * from the parent scope to the child scope ie. the call created has the same sender
626 * and value as the original call.
627 * also the Value parameter is omitted for this opcode
628 */
629 static final byte OP_DELEGATECALL =(byte)0xf4 ;
630
631 /**
632 * (0xf5) Skinny CREATE2, same as CREATE but with deterministic address
633 */
634 public static final byte OP_CREATE2 =(byte)0xf5;
635
636 /**
637 * opcode that can be used to call another contract (or itself) while disallowing any
638 * modifications to the state during the call (and its subcalls, if present).
639 * Any opcode that attempts to perform such a modification (see below for details)
640 * will result in an exception instead of performing the modification.
641 */
642 static final byte OP_STATICCALL =(byte)0xfa ;
643
644
645 static final byte OP_HEADER =(byte)0xfc ;
646
647 /**
648 * (0xfd) The `REVERT` instruction will stop execution, roll back all state changes done so far
649 * and provide a pointer to a memory section, which can be interpreted as an error code or message.
650 * While doing so, it will not consume all the remaining gas.
651 */
652 static final byte OP_REVERT = (byte)0xfd;
653
654 /**
655 * (0xff) Halt execution and register account for
656 * later deletion
657 */
658 static final byte OP_SUICIDE =(byte)0xff;
659 }