Evgenii Stratonikov
0510d1e6c1
vmcli: return after error in break
2020-12-31 12:51:01 +03:00
Evgenii Stratonikov
5d6065c3ee
vmcli: set breakpoint before the instruction
...
Breakpoint should occur before actual instruction execution.
2020-12-31 12:50:52 +03:00
Roman Khimov
e3c360c477
vm: fix comment typo
2020-09-15 21:44:54 +03:00
Roman Khimov
35c60cd8f4
vm: fix elements counting for isolated calls
...
The map and the counter are VM-wide, not context-specific, that's the whole
point of them.
2020-07-18 07:27:08 +03:00
Roman Khimov
3d62db4f34
vm: clear altstack on CALL, fix #1158
...
neo-vm doesn't copy altstack on CALL, so it effectively is cleared. But we
need to copy things back on return if there are any.
2020-07-18 07:27:08 +03:00
Roman Khimov
c6894bfb3f
vm/cli: fix load commands help
2020-06-26 00:13:58 +03:00
Evgenii Stratonikov
b0d07c3031
vm: make Iterator interface public
...
There is nothing wrong with iterators being implemented in other parts
of code (e.g. Storage.Find). In this case type assertions can
prevent bugs at compile-time.
2020-05-27 11:40:46 +03:00
Roman Khimov
fb9b2ae982
Merge pull request #975 from nspcc-dev/clone-struct-in-setitem-2.x
...
vm: clone struct item on SETITEM, close #972
2020-05-21 18:02:06 +03:00
Roman Khimov
f8b41e486c
vm: clone struct item on SETITEM, close #972
...
It's the same as with APPEND and VALUES.
2020-05-21 17:56:26 +03:00
Evgenii Stratonikov
a8fa68914a
vm: allow to convert Map item to bool
2020-05-21 17:53:19 +03:00
Evgenii Stratonikov
cd8445aa59
vm: update stack size in SETITEM properly
2020-05-21 15:20:37 +03:00
Roman Khimov
1721360dd1
vm: limit types accepted for PICKITEM, fix #965
...
bafdb916a0
change was wrong (probably brought
from neo-vm 3.0 at the state at which it existed back then), neo-vm 2.x
doesn't allow PICKITEM for arbitrary types.
2020-05-21 12:16:38 +03:00
Roman Khimov
328c6d7ce5
vm/cli: fix step command
...
It was setting a (wrong) breakpoint and couldn't then break out of it.
2020-05-21 12:15:50 +03:00
Roman Khimov
318ca55982
vm/cli: add push command to push something to the estack
2020-05-21 12:15:24 +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
Roman Khimov
2d0ad30fcf
vm: rework Map with internal slice representation
...
Which makes iterating over map stable which is important for serialization and
and even fixes occasional test failures. We use the same ordering here as
NEO 3.0 uses, but it should also be fine for NEO 2.0 because it has no
defined order.
2020-04-01 19:33:53 +03:00
Roman Khimov
3dbe549a61
smartcontract: store MapType Parameter as a slice of KV pairs
...
Fixes #809 .
Basically, there are three alternative approaches to fixing it:
* allowing both []byte and string for ByteArrayType value
minimal invasion into existing code, but ugly as hell and will probably
backfire at some point
* storing string values in ByteArrayType
incurs quite a number of type conversions (and associated data copying),
though note that these values are not changed usually, so dynamic
properties of []byte are almost irrelevant here
* storing only []byte values in ByteArrayType
makes it impossible to use them as map keys which can be solved in several
ways:
- via an interface (Marshalable)
which is good, but makes testing and comparing values in general harder,
because of keys mismatch
- using serialized Parameter as a key (in a string)
which will need some additional marshaling/unmarshaling
- converting MapType from map to a slice of key-value pairs
not a bad idea as we don't use this map as a map really, the type
itself is all about input/output for real VM types and this approach is
also a bit closer to JSON representation of the Map
2020-04-01 19:21:00 +03:00
Anna Shaleva
a8fa9c9244
vm: add tests to stack_item.go
...
closes #199
2020-03-31 17:18:13 +03:00
Roman Khimov
0d482ceb7f
Merge pull request #808 from nspcc-dev/fix-map-serialization
...
vm: make map serialization more compatible with C#
2020-03-29 13:40:52 +03:00
Roman Khimov
665bf78d11
vm: make map serialization more compatible with C#
...
C# pushes value and key to the stack of non-serialized items, so key gets
serialized first followed by value. Fixes #806 .
Notice though that neither IDictionary in C#, nor map in Go have elements
ordered, so we can easily get a difference in KV pairs order and it would be
impossible to fix.
2020-03-28 17:25:42 +03:00
Evgenii Stratonikov
db2dccf7cb
emit: implement AppCallWithOperationAndArgs
...
It is nice to have a typical task of calling contract method
with specific arguments incapsulated inside some function.
2020-03-27 11:05:36 +03:00
Evgenii Stratonikov
4522eed1bb
vm: fix offset for CALLI opcode
...
It is different from other JMP* and +2 should be added to the parameter.
2020-03-26 13:09:55 +03:00
Evgenii Stratonikov
dc8fb13021
vm: make NewBigInteger accept int64
...
It is more correct upconvert to int64 if needed,
so precision is never lost.
2020-03-24 11:10:56 +03:00
Roman Khimov
5148b98f43
Merge pull request #773 from nspcc-dev/fix/bigint
...
vm: use truncated division for Integers
2020-03-23 18:01:21 +03:00
Evgenii Stratonikov
954e8cdcf1
vm: allow to push integer-like items to stack
...
Perform automatic conversion of non-standard integer types to
int64 if possible.
Closes #776 .
2020-03-18 12:58:31 +03:00
Evgenii Stratonikov
4b44190485
vm: use truncated division for Integers
...
When divisor is negative, the result is truncated towards
zero.
2020-03-17 15:45:56 +03:00
Roman Khimov
1b5dd53e07
Merge pull request #746 from nspcc-dev/fix/equal
...
vm: implement EQUAL opcode properly
Fixes #745 , #749 .
2020-03-12 11:46:51 +03:00
Evgenii Stratonikov
dfc59129c7
vm: implement EQUAL opcode properly
...
When comparing elements of different types, conversions
should be performed. This commit implement custom equality
predicate for each stack item type.
2020-03-11 17:19:10 +03:00
Evgenii Stratonikov
5da82e8cf0
vm: add TryBytes() to StackItem interface
...
Conversion should be done in a StackItem, not in an Element.
2020-03-11 16:33:46 +03:00
Roman Khimov
8318adac56
vm: add support for dynamic invocations in APPCALL
...
Fixes #740 .
2020-03-10 17:17:36 +03:00
Evgenii Stratonikov
8819d4f970
vm: implement ParseMultisigContract()
...
When creating witness for a multisig contract, it is
needed to extract the order of public keys from it.
2020-03-05 09:43:14 +03:00
Roman Khimov
e41d434a49
*: move all packages from CityOfZion to nspcc-dev
2020-03-03 17:21:42 +03:00
Roman Khimov
56e37ad6ba
vm: drop duplicating stackItem structure, build JSON from Parameters
...
smartcontract.Parameter has everything needed now.
2020-03-03 15:38:03 +03:00
Roman Khimov
9b4fd99fbc
vm: break circular references when recursing into ToContractParameters
...
Reference types can have circular pointers to each other, thus we need to
control recursion.
2020-03-03 15:38:03 +03:00
Evgenii Stratonikov
6541bd4d42
vm: use Boolean
in (*BoolItem).String()
2020-03-02 18:01:49 +03:00
Roman Khimov
252a9f2f31
Merge pull request #690 from nspcc-dev/feature/getapplicationlog
...
rpc: implement getapplicationlog RPC
2020-03-02 17:41:32 +03:00
Anna Shaleva
ff4384d7ff
rpc: implement getapplicationlog RPC
...
Closes #500
2020-03-02 17:25:27 +03:00
Evgenii Stratonikov
a3dacd3b74
tests: replace t.Fatal with require where possible
...
This makes tests less verbose and unifies the style
they are written in.
2020-03-02 17:22:27 +03:00
Evgenii Stratonikov
5e229d84d4
compiler: use uint16 for label numbers
...
As noted in #687 this will make compiler a bit more predictable.
2020-02-21 17:45:45 +03:00
Evgenii Stratonikov
3e84f2bdf8
compiler: rewrite jump targets properly
...
Old implementation could view 0x62 byte in
a script as a JMP instruction irregardless of whether it is
a real opcode or a part of a parameter of another instruction.
In this commit instructions are decoded together with parameters
during jump label rewriting.
2020-02-12 10:58:53 +03:00
Roman Khimov
268cad5c06
Merge pull request #548 from nspcc-dev/feature/multisig
...
vm: implement parallel algorithm for CHECKMULTISIG
2020-02-08 16:10:34 +03:00
Roman Khimov
9b9adb28c1
Merge pull request #642 from nspcc-dev/feature/emit
...
vm, compiler: move Emit* functions to a separate package
Closes #449 , #534 .
2020-02-08 15:56:48 +03:00
Roman Khimov
b805b1a71b
vm: make SerializeItem/DeserializeItem public APIs
...
They're useful as wrappers around EncodeBinaryStackItem/DecodeBinaryStackItem.
2020-02-07 15:34:59 +03:00
Roman Khimov
7e7ce7f19f
vm: rephrase serialization errors
...
Seeing some
blockQueue: failed adding block into the blockchain {"error": "failed to store notifications: not supported", "blockHeight": 713984, "nextIndex": 713985}
in logs is not very helpful.
2020-02-07 11:53:53 +03:00
Evgenii Stratonikov
a8dc704197
emit: add tests for Int
2020-02-06 18:45:37 +03:00
Evgenii Stratonikov
6fd3f0fa48
emit: add tests for Bytes
2020-02-06 18:45:37 +03:00
Evgenii Stratonikov
5e992d8cdd
emit: add tests for Syscall, Jmp
2020-02-06 18:45:37 +03:00