Commit graph

1642 commits

Author SHA1 Message Date
Roman Khimov
19c21452c9 interop/account: update and extend documentation 2020-05-26 19:51:20 +03:00
alexvanin
aca6f2f3ad rpc/client: handle client creation error in new wsclient
Client returns error if it can't parse endpoint string. WSClient
should check client error or there could be panic at `cl.cli = nil`
expression.
2020-05-26 11:36:47 +03:00
Roman Khimov
29e66925aa rpc/client: deduplicate block/header tests a bit
The same data is copied at least twice here. Also use this block for header
test making it a bit more convenient.
2020-05-26 11:36:47 +03:00
Roman Khimov
5432530df4 result: use witnesses field in result.Header JSON
Follow new Neo 3.0 standard for these outputs.
2020-05-26 11:36:47 +03:00
Roman Khimov
7633439845 rpc/block: rework the way Block is JSONized
Our block.Block was JSONized in a bit different fashion than result.Block in
its NextConsensus and Index fields. It's not good for notifications because
third-party clients would probably expect to see the same format. Also, using
completely different Block representation is probably making our client a bit
weaker as this representation is harder to use with other neo-go components.

So use the same approach we took for Transactions and wrap block.Block which is
to be serialized in proper way.

Fix `Script` JSONization along the way, 3.0 node wraps it within `witnesses`.
2020-05-26 11:36:47 +03:00
Roman Khimov
393ce1c230 rpc/server: add notification filters
And check state string correctness on unmarshaling.
2020-05-26 11:36:47 +03:00
Roman Khimov
2dc16c0694 transaction: add json.Unmarshaler to Attribute
It actually was missing and it might affect Transaction conversion to/from
JSON.
2020-05-26 11:36:47 +03:00
Roman Khimov
725b47ddef rpc/client: add support for notification filters
Differing a bit from #895 draft specification, we won't add `sender` or
`cosigner` to `transaction_executed`.
2020-05-26 11:36:47 +03:00
Roman Khimov
c4c080d240 rpc: add subscriber queue overflow check
Server-side test is added, but disabled because of its unreliability.
2020-05-26 11:36:47 +03:00
Roman Khimov
44ae9086b6 core: improve and fix locking in storeBlock
Getting batch, updating Prometheus metrics and pushing events doesn't require
any locking: batch is a local cache batch that no one outside cares about,
Prometheus metrics are not critical to be in perfect sync and events are
asynchronous anyway.

Native contracts also don't require any locks and they should be processed
before dumping storage changes.
2020-05-26 11:36:47 +03:00
Roman Khimov
bef14977a2 rpc/client: add notifications support for WSClient
It differs from #895 design in that we have Notifications channel always
exposed as WSClient field, probably it simplifies things a little.
2020-05-26 11:36:47 +03:00
Roman Khimov
fc22a46a4c rpc/server: add notification subscription
Note that the protocol differs a bit from #895 in its notifications format,
to avoid additional server-side processing we're omitting some metadata like:
 * block size and confirmations
 * transaction fees, confirmations, block hash and timestamp
 * application execution doesn't have ScriptHash populated

Some block fields may also differ in encoding compared to `getblock` results
(like nonce field).

I think these differences are unnoticieable for most use cases, so we can
leave them as is, but it can be changed in the future.
2020-05-26 11:36:47 +03:00
Roman Khimov
03ecab5eec smartcontract: add JSON marshal/unmarshal for InteropType
We actually have to do that in order to answer getapplicationlog requests for
transactions that leave some interop items on the stack. It follows the same
logic our binary serializer/deserializes does leaving the type and stripping
the value (whatever that is).
2020-05-25 00:27:39 +03:00
Roman Khimov
612500ed96 rpc/server: start and shutdown Server in tests
It will be important for proper subscription testing and it doesn't hurt even
though technically we've got two http servers listening after this change (one
is a regular Server's http.Server and one is httptest's Server). Reusing
rpc.Server would be nice, but it requires some changes to Start sequence to
start Listener with net.Listen and then communicate back its resulting
Addr. It's not very convenient especially given that no other code needs it,
so doing these changes just for a bit cleaner testing seems like and
overkill.

Update config appropriately. Update Start comment along the way.
2020-05-25 00:27:39 +03:00
Roman Khimov
b7d2b659b4 network: get blocks directly from the chain for rebroadcasting
Simplify network<->consensus relations, also broadcast blocks received by
other means like RPC.
2020-05-25 00:27:39 +03:00
Roman Khimov
462022bbdd consensus: remove OnNewBlock(), use Blockchain subscription
Get new blocks directly from the Blockchain. It may lead to some duplications
(as we'll also receive our own blocks), but at the same time it's more
correct, because technically we can also get blocks via other means besides
network server like RPC (submitblock call). And it simplifies network server
at the same time.
2020-05-25 00:27:39 +03:00
Roman Khimov
3ca71d5e8d core: add Blockchain event subscription mechanism
A deep internal part of #895. Blockchainer interface is also extended for
various uses of these methods.
2020-05-25 00:27:39 +03:00
Roman Khimov
ac40d357f0 core: improve documentation a little 2020-05-24 23:54:01 +03:00
Roman Khimov
f2033b5e54 wallet: check for t.GetSignedPart() result correctness
It can return nil easily and signing that is a big mistake.
2020-05-24 23:53:38 +03:00
Roman Khimov
c9b1d359d8 core: ensure we produce correct blocks for tests
Check for correct merkle root generation.
2020-05-24 23:52:54 +03:00
Roman Khimov
bd98940a54
Merge pull request #982 from nspcc-dev/neo3/protocol/getblockdata
protocol: implement getblockdata p2p command
2020-05-22 19:28:42 +03:00
Anna Shaleva
8142caaf8b protocol: implement getblockdata p2p command
closes #891
2020-05-22 19:16:49 +03:00
Roman Khimov
d12d198eed
Merge pull request #983 from nspcc-dev/neo3/protocol/getblocks
protocol: refactor getblocks payload
2020-05-22 17:46:54 +03:00
Anna Shaleva
2f6a3e9af5 protocol: refactor getblocks payload
closes #890
2020-05-22 17:33:59 +03:00
Evgenii Stratonikov
d26758dd31 vm/tests: restore NEO3 JSON tests
The only skipped RN are ROT.json (see #927) and MEMCPY.json (not a valid
JSON).
2020-05-22 14:17:15 +03:00
Evgenii Stratonikov
673e6c84d1 vm/tests: preserve order when decoding Map item.
When using Go's `map` for decoding, order can change from time to time,
while we may want to check it too. Use custom decoder for saving items
in order.
2020-05-22 14:17:15 +03:00
Evgenii Stratonikov
9dca2288ba vm: make LEFT fail if count is too big 2020-05-22 14:16:32 +03:00
Evgenii Stratonikov
22791272bf vm/tests: compare static slot contents in JSON tests
Make use of "staticFields" test field to compare vm static slots.
Also remove altStack because it is doesn't exist.
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
86c4f1abc5 vm: do not use State as a mask
In NEO2 state could be used as a mask, but now it contains only a single
value.
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
f4fa712440 vm: make PUSH0 emit Integer 2020-05-22 14:16:32 +03:00
Evgenii Stratonikov
820b050b18 vm/tests: make test interop push non-nil InteropItem 2020-05-22 14:16:32 +03:00
Evgenii Stratonikov
a44acd25bb vm/tests: restore JSON tests parsing
Make sure we support new test format. Tests itself will be restored
later.
2020-05-22 14:16:32 +03:00
Evgenii Stratonikov
61b1722745 opcode: swap ROT and OLDPUSH1
Because of how stringer generates String() method, the first of them
will be used as the result.
2020-05-22 14:16:32 +03:00
Evgenii Stratonikov
646c247b31 vm/tests: unmarshal Map keys properly in JSON tests 2020-05-22 14:16:31 +03:00
Evgenii Stratonikov
128a99dec2 vm/tests: unmarshal action in JSON tests properly 2020-05-22 13:36:11 +03:00
Evgenii Stratonikov
7ddb23abe3 vm/tests: unmarshal stack items in JSON tests properly
New item types were added in NEO3 and they can be capitalized or not.
2020-05-22 13:36:11 +03:00
Evgenii Stratonikov
e71cc04c70 vm/tests: unmarshal VM state in JSON tests properly 2020-05-22 13:36:11 +03:00
Evgenii Stratonikov
0c7b163280 vm/tests: unmarshal script in JSON tests properly
Script is no specified via stringified opcodes and their arguments.
2020-05-22 13:36:11 +03:00
Evgenii Stratonikov
1100f629df opcode: implement FromString() 2020-05-22 13:36:11 +03:00
Evgenii Stratonikov
e53055a560 opcode: use underscored names in String() 2020-05-22 13:36:11 +03:00
Evgenii Stratonikov
3917b4b4e4 vm: update stack size in SETITEM properly 2020-05-21 18:00:51 +03:00
Anna Shaleva
64a2fb63e1 protocol: move magic exchange to version payload
closes #889
2020-05-21 14:23:41 +03:00
Anna Shaleva
3bcc56bdcf protocol: switch to binary MessageCommand
closes #888
2020-05-21 13:57:49 +03:00
Evgenii Stratonikov
8cf7871c26 compiler: support nested slice element assignment 2020-05-21 08:30:32 +03:00
Evgenii Stratonikov
5b0e73ddf0 compiler: initialize struct fields explicitly
By default VM initializes every field of a new struct to a Boolean.
If field contains another struct, we need to initialize it to default
value explicitly. This commit sets default values for uninitialized
field.
2020-05-21 08:30:32 +03:00
Evgenii Stratonikov
051e3608ff compiler: support nested struct fielid assignment 2020-05-21 08:30:32 +03:00
Evgenii Stratonikov
1e40f9dac0 compiler: support nested struct reading 2020-05-21 08:30:31 +03:00
Anna Shaleva
9f2cb1726b core: add witness check to nep5 transfer method
We have to check, whether transaction's sender is authorised to transfer
nep5 assets.
2020-05-20 23:34:27 +03:00
Anna Shaleva
1afd630169 core: add senders' fees monitor to mempool
In order to simplify maintainance of overall current senders` fees
in the mempool we are to keep them in a separate map.
2020-05-20 23:34:25 +03:00
Anna Shaleva
c3e08afe34 util: fixed typo in method description 2020-05-20 23:26:51 +03:00
Anna Shaleva
7acf5b2841 core: add SystemFee and NetworkFee to transaction
closes #831
2020-05-20 23:26:48 +03:00
Anna Shaleva
fc3acdc80c core: add native contracts' hashes getters 2020-05-20 23:16:04 +03:00
Anna Shaleva
6b2f4efdd4 core: fix bug in nep5TokenNative.addTokens method
Sometimes we want to add negative amount (e.g. when burning tokens).
2020-05-20 23:16:04 +03:00
Anna Shaleva
c7a040ff81 core: fix bug with native contracts methods initialisation
`NewNEO()` and `NewGAS()` methods are trying to initialise
both `onPersist` and `incBalance` methods of NEO and GAS AFTER
nep5TokenNative is set to the VALUE of created nep5 token.
In this situation an attemmpt to call the corresponding native contracts
methods (e.g. transfer native GAS) leads to contract invocation failure,
as far as `nep5TokenNative.incBalance` method is nil.

Fixed this by initializing both `onPersist` and `incBalance` methods
before getting the value of nep5 contract.
2020-05-20 23:16:04 +03:00
Anna Shaleva
4ebac5a069 core: fix bug in nep5 notifications handling
Native contracts deployment creates `Transfer` notifications and adds
them into interop context. However, these notifications were not stored
for two reasons:
1. typo in `Transfer` (so these notifications were not recognised during
processing of the invocation tx in (*Blockchain).storeBlock(...) method)
2. these notifications have `from` adress setted to null, so conversion
to []byte fails. Same thing could happen with `to`.

Related C# issue: https://github.com/neo-project/neo/issues/1646

For now, made both `transfer` and `Transfer` valid.
2020-05-20 23:16:04 +03:00
Anna Shaleva
45b8bdb51c core: fix bug in consensus
We should set MerkleRoot in approving block irrespective to
transactions presented in the block.
2020-05-20 23:16:04 +03:00
Evgenii Stratonikov
22067d400d rpc: update testchain 2020-05-20 17:45:56 +03:00
Evgenii Stratonikov
1a4a0c154b compiler: support var-declaration of byte slices
Related #801.
2020-05-20 17:45:56 +03:00
Evgenii Stratonikov
3a4ed7dfe8 compiler: emit Buffer for byte slices
All byte slices are mutable so buffer is a right stack item.
2020-05-20 17:45:56 +03:00
Evgenii Stratonikov
b4f1142149 compiler: emit byte constants properly 2020-05-20 17:45:56 +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
ee9adcdc5c vm: check ByteArray size before converting to Integer 2020-05-20 17:45:56 +03:00
Evgenii Stratonikov
8f5f6fba07 vm: copy slice in (*ByteArrayItem).TryBytes() 2020-05-20 17:45:56 +03:00
Evgenii Stratonikov
1b105a9f1d compiler: allow using OP= with struct fields and slice elements
Do it in a generic way, there is no need in restricting to only
variables.
Port of #954.
2020-05-20 14:14:29 +03:00
Evgenii Stratonikov
fdb217ec81 compiler: process _ as a special variable
It is more convenient to drop values inside `emitStoreVar` because this
makes other code has less special cases.
2020-05-20 14:14:29 +03:00
Evgenii Stratonikov
3926456d86 compiler: add test for iterating over map with range 2020-05-20 14:14:29 +03:00
Evgenii Stratonikov
d0735257ce compiler: support range loops with value variables
Closes #958.
2020-05-20 14:14:29 +03:00
Evgenii Stratonikov
b126056f04 compiler: use iterators in range loops
It is simpler than having some counters on stack and will help us to
support maps in future.
2020-05-20 14:14:29 +03:00
Evgenii Stratonikov
34a4c15932 compiler: support byte slice declaration 2020-05-20 11:10:02 +03:00
Evgenii Stratonikov
582469028b compiler: emit default values in a generic way 2020-05-20 11:10:01 +03:00
Evgenii Stratonikov
2cc58c3c9e compiler: allow to declare multiple compound types in a var decl 2020-05-19 16:57:02 +03:00
Evgenii Stratonikov
b4bad11699 compiler: count the number of variables correctly 2020-05-19 16:47:43 +03:00
Evgenii Stratonikov
0629479560 compiler: support non-struct methods
There is no need to restrict ourselves just to structs.
2020-05-19 16:40:26 +03:00
Evgenii Stratonikov
87f6ba34db compiler: process index expresstions in a generic way
All type errors such as string index in slice will be catched during parse phase.
2020-05-19 16:40:26 +03:00
Evgenii Stratonikov
aeaa4a8210 compiler: process bool literals in a generic way 2020-05-19 16:40:26 +03:00
Evgenii Stratonikov
70d0ff869d compiler: refactor typeinfo functions 2020-05-19 16:40:26 +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
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
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
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
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
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
Anna Shaleva
5ece9922c1 vm: hide GetContextScriptHash() method
After adding ScriptHashGetter interface to vm, there's no need in
GetContextScriptHash() to be exported.
2020-05-04 11:53:31 +03:00
Anna Shaleva
73167999cc core: add cosigners field to transaction
closes #864
2020-05-04 11:53:31 +03:00
Anna Shaleva
9ecac14aee vm: fix bug in GetContextScriptHash()
v.Istack.Peek(n) can return nil pointer, so .Value() on this pointer
leads to panic here. Fixed by adding nil check.
2020-05-04 11:49:14 +03:00
Anna Shaleva
d1ec01c45e util: implement Serializable interface over Uint160 2020-05-04 11:49:14 +03:00
Anna Shaleva
08f5708edb core: remove Script attribute type 2020-05-04 11:49:14 +03:00
Anna Shaleva
2ec1d76320 compiler: add ability to generate .abi.json file
A part of integration with NEO Blockchain Toolkit (see #902). To be
able to deploy smart-contract compiled with neo-go compiler via NEO
Express, we have to generate additional .abi.json file. This file
contains the following information:
 - hash of the compiled contract
 - smart-contract metadata (title, description, version, author,
email, has-storage, has-dynamic-invoke, is-payable)
 - smart-contract entry point
 - functions
 - events

However, this .abi.json file is slightly different from the one,
described in manifest.go, so we have to add auxilaury stractures for
json marshalling. The .abi.json format used by NEO-Express is described
[here](https://github.com/neo-project/neo-devpack-dotnet/blob/master/src/Neo.Compiler.MSIL/FuncExport.cs#L66).
2020-05-04 08:37:39 +03:00
Anna Shaleva
ab7f2cb4fb compiler: fix bug with missing methods parameters
Method `methodInfoFromScope(...)` always returned an empty parameters
set, so we were missing this information in both .abi.json and
.debug.json files. Fixed now.
2020-05-04 08:37:39 +03:00
Anna Shaleva
861aca1547 rpc, smartcontract: move contract metadata to smartcontract package 2020-05-04 08:37:39 +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
a64a0f2681 vm: reorder arithmetic opcodes 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
Roman Khimov
c1aa96d614
Merge pull request #911 from nspcc-dev/feature/convert
vm: implement CONVERT opcode
2020-04-28 18:08:36 +03:00
Evgenii Stratonikov
4b064e18aa emit: converto to Boolean in Bool() 2020-04-28 17:36:58 +03:00
Evgenii Stratonikov
2fd63387c0 compiler: support CONVERT interops
When result is needed to have certain type, we should have ability
to convert it, with the help of CONVERT opcode.
2020-04-28 16:44:06 +03:00
Evgenii Stratonikov
bfcb1a409f compiler: extend possible returned values
All integer values (int32, uint64...) should be able to be returned.
2020-04-28 16:44:06 +03:00
Evgenii Stratonikov
7e98a2ffa0 vm: implements CONVERT opcode 2020-04-28 16:38:52 +03:00
Evgenii Stratonikov
be38798785 vm: move Bool method to the StackItem interface 2020-04-28 15:13:41 +03:00
Anna Shaleva
fa467ce628 core: add txes duplication check on block.DecodeBinary 2020-04-27 18:00:01 +03:00
Anna Shaleva
dbda721599 consensus.Block: removed unnecessary setters
As far as we have consensus context in NewBlockFromContext, we don't
need them anymore.
2020-04-27 17:59:56 +03:00
Anna Shaleva
6db4ca874d consensus: replace NewBlock() with NewBlockFromContext(ctx *Context)
We have to set ConsensusData.PrimaryIndex field of Block, so this value
can be retrieved from consensus context.
2020-04-27 17:58:25 +03:00
Anna Shaleva
29d321b5e1 *: drop miner transaction
1. Completely remove miner transaction

2. Change validation rule for block: block without transactions is
valid.
2020-04-27 17:57:37 +03:00