Commit graph

1499 commits

Author SHA1 Message Date
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