alexvanin
7f3392680d
examples: Use "or" operator in transfer check of NEP5 token
...
CanTransfer function checks if "to" and "from" values are
correct script hashes. If one of these values is correct and one
incorrect, then function returns false positive result. It uses "and"
operator which requires both "to" and "from" script hashes to be
incorrect to fail transaction.
Instead transaction must fail if at least one argument is incorrect,
so it should be "or" operator.
2020-05-12 16:49:04 +03:00
Evgenii Stratonikov
89b5e92b83
compiler: add tests for function literal
...
Add test forgotten in #934 .
2020-05-12 16:23:09 +03:00
Evgenii Stratonikov
e21015233b
compiler: implement shadowing of global variables
...
Before introducing slots it was hard to change global variables
preserving changes across multiple function calls.
This commit implements such possibility.
Closes #638 .
2020-05-12 16:23:09 +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
a6271f6bf2
vm: reorder splice opcodes
2020-05-12 16:15:35 +03:00
Evgenii Stratonikov
2cec088f08
vm: add reference counter to slots
2020-05-12 16:15:14 +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
81cbf183af
vm: implement storage slots
2020-05-12 16:15:14 +03:00
Roman Khimov
8e916f5ab8
Merge pull request #934 from nspcc-dev/feature/pointer
...
Implement function pointers in the VM
2020-05-12 15:47:01 +03:00
Evgenii Stratonikov
75fb3af48f
compiler: add basic support for function literals
...
Implement basic support for function literals.
Nested function literals and variables from closure are not supported for now.
2020-05-12 12:56:52 +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
Roman Khimov
b83ee77698
Merge pull request #938 from nspcc-dev/fix/appcall
...
vm: remove APPCALL, TAILCALL
2020-05-08 13:11:02 +03:00
Evgenii Stratonikov
c0147c76ac
emit: remove tailCall argument from AppCall
...
There is no TAILCALL opcode in NEO3.
2020-05-07 14:59:01 +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
ec900c7ff7
core: implement System.Contract.Call interop
2020-05-07 14:39:06 +03:00
Evgenii Stratonikov
301c1b7601
native: save native contract state on deploy
2020-05-07 14:03:14 +03:00
Evgenii Stratonikov
f9f3192b48
vm: move RET and SYSCALL opcodes
2020-05-07 13:23:05 +03:00
Roman Khimov
326264abb2
Merge pull request #937 from nspcc-dev/fix/slice
...
compiler: support implicit type in function arguments
2020-05-07 11:36:47 +03:00
Evgenii Stratonikov
7ac15a7557
compiler: support implicit type in function arguments
...
Go supports declaring multiple arguments of the same type without
duplicating type name. Now we support this too.
2020-05-07 11:33:09 +03:00
Roman Khimov
d3f1ccd518
Merge pull request #936 from nspcc-dev/fix/voidcall
...
compiler: allow empty returns
2020-05-06 18:27:59 +03:00
Evgenii Stratonikov
b0a89e8a1a
compiler: support named returns
2020-05-06 18:22:52 +03:00
Evgenii Stratonikov
156a2eddc5
compiler: support using return
in some branches
...
When `return` is used in one codepath, but not the other,
we do not clean altstack properly. This commit fixes it.
2020-05-06 18:22:52 +03:00
Evgenii Stratonikov
770cff8b91
compiler: allow to use return
with no arguments
2020-05-06 18:22:52 +03:00
Roman Khimov
9afcd71be3
Merge pull request #932 from nspcc-dev/feature/abort
...
vm: implement ASSERT/ABORT opcodes
2020-05-06 16:32:18 +03:00
Evgenii Stratonikov
5ab4b9284b
core: remove unused function from tests
2020-05-06 16:00:16 +03:00
Evgenii Stratonikov
977c431bf1
vm: implement ASSERT/ABORT opcodes
...
Rename THROWIFNOT to ASSERT, add ABORT opcode.
ABORT cannot be caught, but the implementation should be postponed until
exception handling is implemented.
2020-05-06 15:54:19 +03:00
Roman Khimov
963a70d54a
Merge pull request #926 from nspcc-dev/feature/stack
...
Implement NEO3 VM stack opcodes
2020-05-06 14:51:04 +03:00
Roman Khimov
d5c471b087
Merge pull request #928 from nspcc-dev/fix-rpc-submitblock-test
...
Fix RPC submitblock test
2020-05-06 14:47:44 +03:00
Roman Khimov
7287c01bd0
rpc/server: rework submitblock empty test
...
The original intention here was to check for server reaction in presence of
validation errors (response.ErrValidationFailed) and it was very easy to make
validation fail for block without transactions in Neo 2. But in Neo 3
transactionless blocks are perfectly valid (see
29d321b5e1
) which broke this test even though we
didn't see it until websocket addition (which required
8cec6694ae
to make this test work initially).
So make a valid block and then spoil its verification script.
2020-05-06 14:20:35 +03:00
Roman Khimov
fd72f0635e
rpc/server: prevent test panicing in checkErrGetResult()
...
If we expect some resp.Error, then check for it explicitly.
2020-05-06 13:11:12 +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
525527f750
vm: reorder stack opcodes
...
Leave *ALTSTACK opcodes for now as they are needed in compiler while
slot opcodes are not yet here.
2020-05-06 13:02:14 +03:00
Evgenii Stratonikov
115919aaf7
vm: process OLDPUSH1 at the context level
...
The only usecase for this opcode is single-byte verification scripts.
2020-05-06 13:00:00 +03:00
Roman Khimov
b04c8623c5
Merge pull request #925 from nspcc-dev/rpc-over-websocket
...
RPC over websocket
2020-05-06 12:52:58 +03:00
Roman Khimov
ec6ade4c9b
Merge pull request #920 from nspcc-dev/neo3/transaction/cosigners
...
core: implement cosigners mechanism
2020-05-04 17:15:07 +03:00
Roman Khimov
3de48d7d90
rpc/client: add minimalistic websocket client
2020-05-04 16:54:35 +03:00
Roman Khimov
a458a17748
rpc/client: separate out http-related functionality
2020-05-04 16:54:35 +03:00
Roman Khimov
6d202ad4c5
rpc/client: drop Version from Options
...
It makes no sense at all, it's a JSON-RPC version.
2020-05-04 16:54:35 +03:00
Roman Khimov
19397ec4a8
rpc/client: fix some comments
2020-05-04 16:54:35 +03:00
Roman Khimov
20d477cbd8
client: remove Balancer getter/setter, make it an Option
...
Keep it internal to the client instance, it makes no sense exposing it to the
outside user.
2020-05-04 16:54:35 +03:00
Roman Khimov
315aabde56
client: make http.Client internal to the Client
...
Exposing it the outside users is strange, so incapsulate it completely.
Fix DialTimeout setting along the way, handle negative timeouts as invalid.
2020-05-04 16:54:35 +03:00
Roman Khimov
ec62edac68
rpc/server: add websockets support via '/ws' URL
2020-05-04 16:54:35 +03:00
Roman Khimov
8cec6694ae
rpc/server: fix test block encoding
...
The end result of the previous code wasn't even a valid JSON.
2020-05-04 16:54:35 +03:00
Roman Khimov
d275652b37
rpc/server: use httptest.Server for testing
...
Which allows to reuse it for websockets.
2020-05-04 16:54:35 +03:00
Roman Khimov
1b523be4b6
rpc: shuffle handleHttpRequest/handleRequest responsibilities
...
Make handleRequest reusable in other contexts like websockets.
2020-05-04 13:57:23 +03:00
Roman Khimov
236f3dabdd
rpc: change handlers to always return response.Error for errors
...
As it's expected by WriteErrorResponse() actually.
2020-05-04 13:57:15 +03:00
Roman Khimov
57de98e1a3
rpc/server: refactor handler methods a little
...
request.In is a natural request representation, one can always get
request.Params from it.
2020-05-04 13:57:08 +03:00