Commit graph

163 commits

Author SHA1 Message Date
Evgenii Stratonikov
0472a0b0b1 core: move Neo.Runtime/Enumerator/Iterator.* interops to System.* 2020-06-10 12:13:35 +03:00
Anna Shaleva
7ca2807875 vm/encoding: move bigint from vm to encoding package 2020-06-08 13:27:13 +03:00
Anna Shaleva
783f5ecb01 vm: move StackItem to a separate package
closes #912
2020-06-08 13:27:08 +03:00
Evgenii Stratonikov
9dca2288ba vm: make LEFT fail if count is too big 2020-05-22 14:16:32 +03:00
Evgenii Stratonikov
16bf72f9cc vm/tests: do not load empty script
In case we load a zero-length script, VM should end in HALT state.
https://github.com/neo-project/neo-vm/blob/master/tests/neo-vm.Tests/Tests/Others/OtherCases.json#L22
2020-05-22 14:16:32 +03:00
Evgenii Stratonikov
063c29636b vm: fail if NEWSTRUCT/NEWARRAY argument is not an integer
NEO3 VM does not support creating new Array from a Struct.
For this purpose CONVERT opcode is used.
2020-05-22 14:16:32 +03:00
Evgenii Stratonikov
1a0290edc6 vm: copy slice when converting between Array<->Struct
Related #437. Becase in NEO3 NEWSTRUCT/NEWARRAY accept only an integer
change tests too.
2020-05-22 14:16:32 +03:00
Evgenii Stratonikov
781def735d vm: use Null item as a default value for Array/Struct elements 2020-05-22 14:16:32 +03:00
Evgenii Stratonikov
3917b4b4e4 vm: update stack size in SETITEM properly 2020-05-21 18:00:51 +03:00
Evgenii Stratonikov
98c508d361 vm: implement MEMCPY opcode
MEMCPY copies byte-slice to a destination buffer.
2020-05-20 17:45:56 +03:00
Evgenii Stratonikov
a5f6e0e53d vm: implement NEWBUFFER opcode 2020-05-20 17:45:56 +03:00
Evgenii Stratonikov
a3a3a77431 vm: make slice opcodes emit Buffer 2020-05-20 17:45:56 +03:00
Evgenii Stratonikov
c3f7832f3b vm: implement Buffer stack item
Buffer is a stack item type introduced in NEO3
which represents mutable byte-array.
2020-05-20 17:45:56 +03:00
Evgenii Stratonikov
0cb6dc47e4 vm: implement slot-related opcodes
1. Slot is a new mechanism for storing variables during execution
which is more convenient than alt.stack. This commit implements
support for slot opcodes in both vm and compiler.
2. Remove old alt.stack opcodes.
3. Do not process globals at the start of every function, but instead
load them single time at main.
2020-05-12 16:23:08 +03:00
Evgenii Stratonikov
af2abedd86 vm: implement reference counter
It is convenient to have all reference-counting logic
in a separate struct.
2020-05-12 16:15:14 +03:00
Evgenii Stratonikov
1d3fb3d6f5 vm: implement PUSHA/CALLA opcodes 2020-05-12 12:56:51 +03:00
Evgenii Stratonikov
7fcd537b09 vm: implement Pointer stack item
Pointer is a generic address type in VM.
It is used for calling lambda-expressions.
2020-05-12 12:55:31 +03:00
Evgenii Stratonikov
73c82584a3 vm,compiler: replace APPCALL with System.Contract.Call
Contract calls are performed via syscall System.Contract.Call
in NEO3. This implements this in compiler and removes APPCALL from the
VM.
2020-05-07 14:52:03 +03:00
Evgenii Stratonikov
dd20320615 vm: remove XSWAP/XTUCK opcodes
Regenerate RPC testchain as these were used in compiler.
2020-05-06 13:05:22 +03:00
Evgenii Stratonikov
d18199ce42 vm: implement REVERSE* opcodes
Use new opcodes in the compiler instead of XSWAP/ROLL.
2020-05-06 13:03:49 +03:00
Evgenii Stratonikov
c8a1188ee1 vm: implement CLEAR opcode 2020-05-06 13:02:57 +03:00
Evgenii Stratonikov
c8328981ec vm: refactor tests
Most of the tests follow the same logic:
push items on stack -> execute program -> check single result.
This commit reuses this function in most of the tests.
2020-04-30 19:29:52 +03:00
Evgenii Stratonikov
9081211f12 vm: implement NOTEQUAL opcode 2020-04-30 18:00:15 +03:00
Evgenii Stratonikov
70f0c656b0 vm: check Integer size on creation 2020-04-30 18:00:15 +03:00
Evgenii Stratonikov
519b31a704 vm: remove crypto-related opcodes
All cryptography has moved to interops in NEO3.
There is no SHA256 interop RN, but it is to appear later.
Closes #777.
2020-04-29 19:16:38 +03:00
Evgenii Stratonikov
7e98a2ffa0 vm: implements CONVERT opcode 2020-04-28 16:38:52 +03:00
Evgenii Stratonikov
7c3d7c0261 vm: implement NEWARRAYT opcode 2020-04-27 09:06:48 +03:00
Evgenii Stratonikov
d3b9aef8e2 vm: implement ISTYPE opcode
Also make StackItemType public and reorder it according to NEO3.
2020-04-27 09:01:26 +03:00
Evgenii Stratonikov
48a41bd737 vm: implement CLEARITEMS opcode 2020-04-27 09:01:26 +03:00
Evgenii Stratonikov
9fd04aefa5 vm: implement NEWARRAY0 and NEWSTRUCT0 opcodes 2020-04-24 13:49:10 +03:00
Evgenii Stratonikov
03761421f8 vm: reorder Array/Map opcodes
Also SIZE can be used for both Arrays/Maps and ByteArrays.
2020-04-24 13:48:44 +03:00
Evgenii Stratonikov
d6624a92ca vm: implement new JMP* and CALL* opcodes
In compiler JMP*_L opcodes are always used, as this requires less effort.
2020-04-24 10:16:41 +03:00
Evgenii Stratonikov
fba185cd99 vm: remove stack isolation opcodes
They are not present in NEO3 and will be creating additional difficulties
during future flow-control opcodes implementation.
2020-04-24 10:15:14 +03:00
Evgenii Stratonikov
008e6eb233 vm: implement new PUSH opcodes 2020-04-23 10:52:28 +03:00
Evgenii Stratonikov
1a54be279e vm: simplify SimpleCall test
It was taken from the compiler output, but there is
no need in using a lot of complex instructions.
2020-04-23 10:36:44 +03:00
Evgenii Stratonikov
cde4ccf01c vm: remove CHECKSIG/VERIFY/CHECKMULTISIG opcodes 2020-04-20 11:55:24 +03:00
Roman Khimov
91f8626c42 vm: disallow negative shifts for SHL/SHR
Follow neo-project/neo-vm#257 change for Neo 3.
2020-04-19 19:15:00 +03:00
Evgenii Stratonikov
ceff8736f2 vm: use ID-based syscalls
In NEO3 SYSCALL opcode has 4-byte ID parameter.
This commit removes support for string-based syscalls and
changes SYSCALL's parameter to be fixed 4-byte value.
2020-04-17 11:46:31 +03:00
Evgenii Stratonikov
bfbbef952a vm: move InteropNameToID to emit package 2020-04-17 11:46:31 +03:00
Evgenii Stratonikov
93d2a3e031 vm: serialize zero Integer to an empty ByteArray 2020-04-17 11:46:31 +03:00
Evgenii Stratonikov
5dba30a49d vm: update bool -> []byte conversion to NEO 3
This reverts commit 4c688355bc.
2020-04-17 11:46:31 +03:00
Evgenii Stratonikov
2fd26287c5 vm: update SUBSTR to NEO3 version
This reverts commit 9ebb793009.
2020-04-17 11:46:31 +03:00
Evgenii Stratonikov
3831aec53f vm: make NewBigInteger accept *big.Int
It creates big.Int internally anyway, so this is the most flexible way.
2020-04-16 15:54:58 +03:00
Evgenii Stratonikov
948729137f vm: remove HASH160/HASH256 opcodes 2020-04-13 13:47:39 +03:00
Roman Khimov
5a22651e36
Merge pull request #784 from nspcc-dev/neo3/null
vm: support NULL stack item
2020-04-10 10:38:17 +03:00
Anna Shaleva
9f0bc2aaf5 vm: add tests to CALL* instructions
closes #452
2020-04-09 11:20:39 +03:00
Anna Shaleva
495c1b0565 vm: add tests for missing bit and numeric operations
Added tests for:
  - bit operatoins: AND, OR, XOR
  - numeric operations: BOOLOR, MIN, MAX, WITHIN, NEGATE
2020-04-07 18:10:31 +03:00
Evgenii Stratonikov
96806262bf vm: handle negative arguments in SHL/SHR
Do it as in reference implementation: a >> -b == a << b.
2020-04-06 10:46:35 +03:00
Evgenii Stratonikov
0023c4f1f6 vm: use truncated division in MOD
Mimic C#'s `%` behavior.
Related 4b44190 (#773).
2020-04-06 09:30:48 +03:00
Evgenii Stratonikov
f7f48d0048 vm: implement ISNULL opcode 2020-04-02 14:15:17 +03:00