Commit graph

242 commits

Author SHA1 Message Date
Evgenii Stratonikov
a88a8e13fc vm: compare Array by reference in EQUAL 2019-09-23 13:25:59 +03:00
Evgenii Stratonikov
99f1d761ca vm: clone Struct on APPEND 2019-09-23 13:25:59 +03:00
Evgenii Stratonikov
d2ccc3b017 vm: make REVERSE consume an item from stack 2019-09-16 15:50:51 +03:00
Evgenii Stratonikov
fd264cb06f vm: make REVERSE work with structs
Also add more tests.
Extend `Array` method of `Element` to work with `StructItem`.
2019-09-16 15:50:51 +03:00
Evgenii Stratonikov
f0426ac2d5 vm: do nothing if SHL/SHR by 0 2019-09-16 15:50:51 +03:00
Evgenii Stratonikov
9eca5ee317 vm: convert SIZE argument to bytearray 2019-09-16 15:50:51 +03:00
Evgenii Stratonikov
9780889239 vm: make NEWARRAY/NEWSTRUCT accept bytearray 2019-09-16 15:50:51 +03:00
Evgenii Stratonikov
66501f9ef9 vm: make REMOVE consume array from stack 2019-09-16 15:50:14 +03:00
Evgenii Stratonikov
71cfd14b92 vm: create an array of false items in NEWARRAY/NEWSTRUCT 2019-09-16 15:24:58 +03:00
Evgenii Stratonikov
bafdb916a0 vm: make PICKITEM accept bytearrays 2019-09-16 15:24:58 +03:00
Evgenii Stratonikov
1881adabb9 vm: fail if NIP has not enough arguments 2019-09-16 15:24:58 +03:00
Evgenii Stratonikov
6e4014547d vm: fail if DROP has no argument 2019-09-16 15:24:58 +03:00
Evgenii Stratonikov
729b7a0b24 vm: fail if ROT has not enough arguments 2019-09-16 15:24:58 +03:00
Evgenii Stratonikov
cf7fbb80ba vm: fail if EQUAL has not enough arguments 2019-09-16 15:24:58 +03:00
Evgenii Stratonikov
d257044298 vm: fail if XTUCK argument is 0 2019-09-16 15:24:58 +03:00
Evgenii Stratonikov
68c6c93980 vm: do not allow APPEND to operate on bytearray 2019-09-11 17:17:37 +03:00
Evgenii Stratonikov
723dcc6e25 vm: make APPEND push no value on stack 2019-09-11 17:17:34 +03:00
Roman Khimov
8311bda355 vm: harden LEFT and RIGHT implementations against negative indexes 2019-09-11 14:51:04 +03:00
Roman Khimov
17f3a21e27 vm: harden SUBSTR implementation against bad index/offset values
The upper index bound for slices is capacity, not length. Check for negative
values also. Fixes #387.
2019-09-11 14:37:41 +03:00
Roman Khimov
fc1075bf75 vm: protect PUSHDATA from short reads
Same thing done in a2a8981979 for PUSHBYTES,
failing to read the amount of bytes specified should lead to FAULT. Also
makes readUint16() and readUint32() panic as this is the behavior we want in
these cases. Add some tests along the way.
2019-09-11 12:35:37 +03:00
Evgenii Stratonikov
31f4c7486b vm: add tests for CAT 2019-09-10 17:33:42 +03:00
Evgenii Stratonikov
1289d0f7e9 vm: add tests for NOT 2019-09-10 17:29:10 +03:00
Evgenii Stratonikov
9b10b4c4d8 vm: add tests for SIGN 2019-09-10 15:08:42 +03:00
Evgenii
0b58ed4a22 vm: do not fault on LEFT with big index
Fixes #378.
2019-09-09 17:29:31 +03:00
Roman Khimov
a039ae6cdb
Merge pull request #374 from nspcc-dev/makefile-and-gofmt
Makefile convenience targets and gofmt
2019-09-09 15:05:12 +03:00
Roman Khimov
a2a8981979 vm: fix not failing PUSHBYTES* on short read
Add some tests also. Fixes #361.
2019-09-09 12:09:05 +03:00
Roman Khimov
fabd11699a *: gofmt -s
Appy gofmt for all the source tree.
2019-09-09 12:02:24 +03:00
Evgenii
bcc8234155 vm: implement Array <-> Struct conversion
Reference VM implementation supports convertation from
Struct to Array via NEWARRAY and vice versa.
https://github.com/neo-project/neo-vm/pull/91
2019-09-08 13:40:21 +03:00
Roman Khimov
aefe572df3 vm: implement UNPACK, REVERSE, REMOVE opcodes
Also expand makeStackItem() to accept slices of int for testing
convenience. Fixes #195.
2019-09-06 19:00:34 +03:00
Roman Khimov
5bd50c7bcd vm: add some tests for PACK instruction 2019-09-06 13:15:30 +03:00
Roman Khimov
b3ed3d24ee vm: implement CAT, SUBSTR, LEFT and RIGHT
String instruction set.
2019-09-06 12:41:27 +03:00
Roman Khimov
59de72f446 vm: implement INVERT instruction 2019-09-05 17:35:30 +03:00
Roman Khimov
b494e094c0 vm: add XDROP implementation 2019-09-05 17:35:30 +03:00
Roman Khimov
974f5db6bc vm: add a TUCK implementation with tests
Also fix stack's InsertAt for the edge case of inserting into a position that
currently is empty (the first good TUCK test illustrates this).
2019-09-05 17:35:30 +03:00
Roman Khimov
eb224aeebe vm: add some checks for OVER and PICK, add OVER tests
These actually behaved correctly because of deferred sigsegv recover, but I
think it would be nice to print something more meaningful for users.
2019-09-05 17:35:30 +03:00
Roman Khimov
85831e3e92 vm: fix XTUCK implementation, add tests
The code that we have actually implements XTUCK and not TUCK. And it's a bit
broken, so fix it and add some tests. The most interesting one (that required
to touch stack code) is the one when we have 1 element on the stack and are
trying to tell XTUCK to push 2 elements deep.
2019-09-05 17:34:25 +03:00
Roman Khimov
5f0f9e1638 vm: implement PICK instruction 2019-09-05 15:18:04 +03:00
Roman Khimov
b34a1b6c25 vm: harden tests against VM failures
Add a check for failed VM state, some of tests using logic values (like NZ
test) can succeed even with VM in FAULT state otherwise.
2019-09-05 15:09:08 +03:00
Roman Khimov
fcf9c1213b vm: implement the NZ opcode 2019-09-05 15:05:44 +03:00
Roman Khimov
33c512032f vm: switch from Opcode to Instruction
Which matches the changes done in neo-storm and also make this codebase closer
to the `dev` branch (that also uses Instruction).
2019-08-14 15:40:31 +03:00
Evgeniy Kulikov
f000b76879 [FIX] Formatting and code-style (#118)
* [FIX] Formatting and code-style

- gofmt
- import resort
- prealloc slices
- simplify code

* fix vet
2019-01-25 12:20:35 +01:00
Anthony De Meulemeester
4bd5b2812e
Optimisations and API changes for smart contracts (#67)
* support VM to pass method and arguments to a script.

* added support for type assertions in smartcontracts.

* added native vm support for print.

* moved VM API packages to vm -> API

* reverted the native Print opcode in favor of runtime.Log

* added support for registering custom interop hooks in the VM.

* Updated README

* Updated compiler with @OPTIMIZE tags

* Moved more tests to VM package.

* optimized and refactored compiler and vm API

* updated README with new smartcontract apis

* bumped version
2018-04-10 11:45:31 +02:00
Renamed from pkg/vm/opcode_test.go (Browse further)