Commit graph

160 commits

Author SHA1 Message Date
Vsevolod Brekelov
5b81110d16 cli: print logo via shell 2019-10-17 18:23:49 +03:00
Evgenii Stratonikov
6d7016c3b9 vm: restrict max size in SETITEM 2019-10-17 12:17:06 +03:00
Evgenii Stratonikov
6f1f9e56bb vm: restrict max size in PACK 2019-10-17 12:17:06 +03:00
Evgenii Stratonikov
2d56c66bde vm: restrict max size in APPEND 2019-10-17 12:17:01 +03:00
Evgenii Stratonikov
8abcaeee6f vm: restrict max size in NEWARRAY/NEWSTRUCT 2019-10-17 11:48:48 +03:00
Roman Khimov
4822c736bb
Merge pull request #418 from nspcc-dev/various-verification-fixes2
Transaction verification fixes, interops and block verification. Fixes #12.
2019-10-15 19:11:00 +03:00
Roman Khimov
d007cc00cc vm: add script check functions
These are required for future interops.
2019-10-15 12:56:25 +03:00
Roman Khimov
acb7ef7fbd vm: support uint8 and uint64 in makeStackItem()
Convenience to avoid casts, uint64 is also a bit special in that it can't be
converted to int64 without data loss.
2019-10-15 12:56:25 +03:00
Roman Khimov
782ca64d92 vm: accept uint16 in makeStackItem() 2019-10-15 12:56:25 +03:00
Vsevolod Brekelov
5109b2e3e7 vm: fix cli comment 2019-10-14 18:38:05 +03:00
Vsevolod Brekelov
591d5eafbe vm: add stepInto,stepOver,stepOut
Original C# vm debugger behavior
2019-10-14 18:37:11 +03:00
Roman Khimov
dca332f333 vm: use new Context.Next() to properly dump programs
Fix #295, deduplicate code and add `inspect` parameter to the vm command to
dump AVMs (`contract inspect` works with Go code).
2019-10-04 16:13:39 +03:00
Roman Khimov
53a3b18652 vm: completely separate instruction read and execution phases
Make Context.Next() return both opcode and instruction parameter if any. This
simplifies some code and needed to deal with #295.
2019-10-04 16:13:39 +03:00
Roman Khimov
1bf232ad50 vm: introduce TryBool() for Element and use it in VerifyWitnesses
Script can return non-bool results that can still be converted to bool
according to the usual VM rules. Unfortunately Bool() panics if this
conversion fails which is OK for things done in vm.execute(), but certainly
not for VerifyWitnesses(), thus there is a need for TryBool() that will just
return an error in this case.
2019-10-04 16:13:39 +03:00
Roman Khimov
8441b31b4b vm: accept uint32 in makeStackItem()
Interop services routinely push such things (block index, blockchain height)
onto the stack.
2019-10-04 16:13:39 +03:00
Roman Khimov
d62a367900 vm: add Value() method to Element
It gives access to the internal value's Value() which is essential for interop
functions that need to get something from InteropItems. And it also simplifies
some already existing code along the way.
2019-10-04 16:13:39 +03:00
Roman Khimov
0c963875af vm: check for fault flag first in Run()
Switch cases are evaluated sequentially and the fault case is top-priority to
handle.
2019-10-04 16:13:39 +03:00
Roman Khimov
705c7f106f vm: don't panic if there is no result in PopResult()
This function is intended to be ran outside of the execute's panic recovery
mechanism, so it shouldn't panic if there is no result.
2019-10-04 16:13:39 +03:00
Roman Khimov
a357d99624 vm: introduce MaxArraySize constant
This is both for #373 and for interop functions that have to check some
inputs.
2019-10-04 16:13:39 +03:00
Roman Khimov
cfa0c13322 vm: add InteropItem type for interop data
This is an opaque data item that is to be used by the interop functions.
2019-10-04 16:13:39 +03:00
Roman Khimov
da2156f955 vm: add batched RegisterInteropFuncs 2019-10-04 16:13:39 +03:00
Roman Khimov
26e3b6abbe vm: extend interops to contain price
The same way C# node does.
2019-10-04 16:13:39 +03:00
Roman Khimov
ceca9cdb67 core/vm: implement contract storage and script retrieval
Fixes script invocations via the APPCALL instruction. Adjust contract state
field types accordingly.
2019-10-04 16:13:39 +03:00
Roman Khimov
c3591d8897 vm: fix CHECKMULTISIG to comply with NEO VM implementation
Testing with testnet quickly revealed that our code has an issue when the key
count doesn't equal signature count, fix it and add some comments.
2019-10-01 13:41:26 +03:00
Evgenii Stratonikov
c7c4291774 vm: simplify APPEND implementation a bit 2019-09-25 17:53:36 +03:00
Evgenii Stratonikov
13d7770c68 vm: support Map in ARRAYSIZE
Also make logic the same as in reference implementation
and add tests.
2019-09-25 17:53:36 +03:00
Evgenii Stratonikov
c66f493017 vm: compare Map by reference in EQUAL 2019-09-25 17:53:36 +03:00
Evgenii Stratonikov
c0be2b2a99 vm: support Map in REMOVE 2019-09-25 17:53:36 +03:00
Evgenii Stratonikov
8b6bddca3c vm: support Map in PICKITEM and SETITEM 2019-09-25 17:53:36 +03:00
Evgenii Stratonikov
d7bb50c609 vm: implement VALUES opcode 2019-09-25 17:53:36 +03:00
Evgenii Stratonikov
2da64267b0 vm: implement KEYS opcode 2019-09-25 17:53:34 +03:00
Evgenii Stratonikov
0fb4bb05cf vm: implement HASKEY opcode 2019-09-25 12:08:41 +03:00
Evgenii Stratonikov
df18da0ac9 vm: implement NEWMAP opcode 2019-09-24 17:06:17 +03:00
Roman Khimov
ca9c9be71f vm: add CHECKSIG/VERIFY/CHECKMULTISIG implementations
Fix #269.
2019-09-24 13:01:54 +03:00
Roman Khimov
3bbeb2476e vm: introduce HasFailed() method and use it where appropriate
It's gonna be used by external modules.
2019-09-23 20:19:07 +03:00
Evgenii Stratonikov
3c53beca82 vm: restrict SHL/SHR arguments to -256..256
Also unify SHL/SHR implementation.
2019-09-23 15:13:10 +03:00
Evgenii Stratonikov
4a8be486f0 vm: do not pop items in OVER 2019-09-23 14:54:59 +03:00
Evgenii Stratonikov
7cd69ea8e2 vm: truncate length in SUBSTR
Also fail on first error, without changing the stack.
2019-09-23 14:54:59 +03:00
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
Roman Khimov
42df4c2f39 vm: update and move README, refs. #339 2019-09-18 12:10:12 +03:00
Roman Khimov
778d29f543 compiler: update and move README to the docs folder
Refs. #339.
2019-09-17 19:09:02 +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
09e197eaf3 vm: make PUSH0 create empty bytearray
Also make tests expect []byte{} instead of 0.
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