Commit graph

78 commits

Author SHA1 Message Date
Evgenii Stratonikov
194da64975 core: deepcopy notification in System.Runtime.Notify
Make it impossible to change already emitted notifications via
`System.Runtime.GetNotifications`.
2020-08-05 11:19:41 +03:00
Anna Shaleva
90825efa16 core: move transaction's sender to cosigners
Closes #1184

Ported changes from https://github.com/neo-project/neo/pull/1752
2020-08-04 17:33:50 +03:00
Evgenii Stratonikov
3c99393bef core: simplify System.Contract.Call* parameter handling 2020-07-30 12:37:32 +03:00
Evgenii Stratonikov
f40aba4cd0 vm: convert items to UTF-8 strings
Add `stackitem.ToString` for seamless string conversion.
2020-07-30 12:37:31 +03:00
Evgenii Stratonikov
685d44dbc1 *: support _initialize method in contracts
Invoke `_initialize` method on every call if present.
In NEO3 there is no entrypoint and methods are invoked by offset,
thus `Main` function is no longer required.
We still have special `Main` method in tests to simplify them.
2020-07-27 13:00:35 +03:00
Evgenii Stratonikov
d2ddf7b7cb *: support invoking methods by offset
Allow to invoke methods by offset:
1. Every invoked contract must have manifest.
2. Check arguments count on invocation.
3. Change AppCall to a regular syscall.
4. Add test suite for `System.Contract.Call`.
2020-07-27 13:00:35 +03:00
Roman Khimov
d8a1c3de46
Merge pull request #1221 from nspcc-dev/neo3/interop/post-preview2_adjustment3
interop: post-preview2 adjustment, part 3
2020-07-23 20:35:53 +03:00
Anna Shaleva
120eff92f7 core: adjust System.Runtime.Notify interop
Part of #1198.

Notification name should be UTF8-encoded.
2020-07-23 07:55:12 +03:00
Anna Shaleva
2c41b7b254 core: adjust System.Runtime.Log interop
Part of #1055 and #1198.

It should check the message length and encoding.
2020-07-23 07:54:51 +03:00
Anna Shaleva
84bf87df52 core: adjust System.Storage.PutEx interop
Part of #1055.

Added System.Storage.PutEx to compiler. Added StorageFlag in order to
denote whether item is constant or not.
2020-07-22 16:58:23 +03:00
Anna Shaleva
47eadcdf2a core: adjust System.Storage.Put interop
Part of #1055.

Maximum storage key len has been changed. Also added maximum storage
value len restriction.
2020-07-22 11:05:10 +03:00
Anna Shaleva
b5185d5d1a core: refactor System.Storage.Get[ReadOnly]Context interops
Part of #1055.

Split methods, as they have a lot of common code. This also fixex nil
error of storageGetReadOnlyContext in case when contract does not have
storage.
2020-07-22 10:51:47 +03:00
Evgenii Stratonikov
3d7fa9de93 *: make Notify interop accept event name 2020-07-20 13:33:32 +03:00
Anna Shaleva
f31ce9289d core: add System.Contract.GetCallFlags interop
Part of #1055.

It returns calling flags of the current context.
2020-07-17 12:35:02 +03:00
Anna Shaleva
d2ec0fed3d core: adjust System.Blockchain.GetContract interop
Part of #1055.

It should put on stack an array instead of interop interface.
2020-07-17 09:28:52 +03:00
Anna Shaleva
1a5fb01e61 core: adjust System.Contract.IsStandard interop
Part of #1055.

It should check not only stored contracts, but also interop context
script container in case if it's a transaction.
2020-07-17 08:19:43 +03:00
Anna Shaleva
d2f452c240 core: adjust System.Contract.CallEx interop
Part of #1055
2020-07-17 08:19:43 +03:00
Anna Shaleva
74ffde8367 core: adjust System.Blockchain.GetTransactionFromBlock interop
To match C# implementation, we should pick all arguments from stack first.
2020-07-17 08:19:43 +03:00
Anna Shaleva
a3e306ff78 core: implement Secp256k1 Verify and CheckMultisig interops
Closes #918.
2020-07-14 16:21:34 +03:00
Anna Shaleva
c4f7b06974 core, compiler: return struct from GetScriptContainer interop
Closes #1173
2020-07-14 06:04:48 +03:00
Anna Shaleva
73b630db9b *: switch from fixed8 to int64
Follow C# implementation, we have to marshall JSON Fixed8 fields without
taking into account decimals.
2020-06-29 21:39:27 +03:00
Roman Khimov
d81d826bfc core: fix Storage.Get to return Null when there is no value
Match C# implementation and fix state inconsistency at block 249920 of
preview2 testnet. Make our Go Storage.Get return nil and adapt
examples/tests.
2020-06-24 10:43:58 +03:00
Roman Khimov
a2cd2264a8 core: fix HasStorage check in storageGetContext
It was returning nil which is wrong.
2020-06-20 00:04:28 +03:00
Anna Shaleva
f1cdcbc99c core: store smartcontract items by id
closes #1037
2020-06-19 20:48:45 +03:00
Evgenii Stratonikov
3762ebdd08 core: implement System.Runtime.GetInvocationCounter syscall 2020-06-17 11:24:11 +03:00
Evgenii Stratonikov
52a27e9be4 core: implement System.Contract.CreateStandardAccount syscall 2020-06-16 12:12:29 +03:00
Evgenii Stratonikov
5b4f38d717 core: implement System.Contract.IsStandard syscall 2020-06-16 12:12:27 +03:00
Evgenii Stratonikov
8f20a70969 core: calculate a price of System.Storage.Put correctly
It also depends on the item already stored by key.
2020-06-15 12:02:21 +03:00
Evgenii Stratonikov
971ab0646f core: specify allowed triggers for interops
Related #1026, #1027, #1028, #1031.
2020-06-11 13:16:07 +03:00
Evgenii Stratonikov
b12add5a78 smartcontract: rewrite trigger types for NEO3 2020-06-11 13:16:07 +03:00
Evgenii Stratonikov
0dd00a49f5 core: specify require call flags in interop description
Related #1026, #1027, #1028, #1031.
2020-06-11 13:16:07 +03:00
Evgenii Stratonikov
bda94c74c3 vm: check calling flags on syscall invocation 2020-06-11 13:16:07 +03:00
Evgenii Stratonikov
55ab7535be core: optimize contractCallEx
Provide script hash upon script load.
2020-06-11 13:06:10 +03:00
Evgenii Stratonikov
a86e1910e1 core: remove unused interops
Missed in #1040.
2020-06-11 10:51:19 +03:00
Evgenii Stratonikov
f8a11f61b6 core: update *.Contract.* interops
1. Remove GetScript, IsPayable, GetStorageContext.
2. Revert 82319538 related to GetStorageContext.
3. Rename Migrate to Update.
4. Move remaining to System.Contract.*.

Related #1031.
2020-06-11 10:50:35 +03:00
Evgenii Stratonikov
c69f8a2fa3 core: check for permission in System.Contract.Call(Ex) 2020-06-11 10:45:25 +03:00
Evgenii Stratonikov
5514b3f52f smartcontract,vm: remove DynamicInvoke feature
It doesn't exist in NEO3.
2020-06-11 10:45:25 +03:00
Evgenii Stratonikov
3d3fe9398e core: remove Neo.Header/Witness/Account.* interops
They are not present in NEO3.
2020-06-10 12:13:18 +03:00
Anna Shaleva
8b7abd36c9 core: remove Block.GetTransactions, Block.GetTransactionsCount interops
Updated System.Blockchain.GetBlock interop replaced the functionality of
the following interops:
	System.Block.GetTransactions
	System.Block.GetTransactionCount
	Neo.Block.GetTransactions
	Neo.Block.GetTransactionsCount
2020-06-09 23:24:11 +03:00
Anna Shaleva
7a2d37cf7e core: update System.Blockchain.GetBlock interop
closes #1025

Now we put on stack stackitem.Array instead of Interop, so we're able to
use all available block properties without extra interop getters.
Removed Neo.Blockchain.GetBlock interop as we don't need it anymore.
2020-06-09 23:24:04 +03:00
Anna Shaleva
e2187c0a96 core: remove Block.GetTransaction interops
Removed Neo.Block.GetTransaction and System.Block.GetTransaction
interops. These interops were replaced by new
System.Blockchain.GetTransactionFromBlock interop.
2020-06-09 22:54:21 +03:00
Anna Shaleva
d692de5ea4 core: add System.Blockchain.GetTransactionFromBlock interop 2020-06-09 22:54:16 +03:00
Anna Shaleva
1e63ae4b3f core: update System.Blockchain.GetTransactionHeight interop
Update System.Blockchain.GetTransactionHeight and removed
Neo.Blockchain.GetTransactionHeight interop as we don't need it.
2020-06-09 22:04:18 +03:00
Anna Shaleva
53655c5ac2 core: implement new System.Blockchain.GetTransaction interop
closes #1023

Now we put on stack stackitem.Array instead of Interop, so we don't
need old transaction-related interops anymore. Removed the following
interops:
	System.Transaction.GetHash
	Neo.Transaction.GetAttributes
	Neo.Transaction.GetHash
	Neo.Transaction.GetWitnesses
	Neo.Attribute.GetData
	Neo.Attribute.GetUsage

Also removed the following duplicated NEO interop:
	Neo.Blockchain.GetTransaction
2020-06-09 22:04:13 +03:00
Anna Shaleva
783f5ecb01 vm: move StackItem to a separate package
closes #912
2020-06-08 13:27:08 +03:00
Roman Khimov
8231953842 core: fix Neo.Contract.GetStorageContext security check
This syscall should only work for contracts created by current transaction and
that is what is supposed to be checked here. Do so by looking at the
differences between ic.dao and original lower DAO.
2020-05-26 19:58:49 +03:00
Evgenii Stratonikov
ec900c7ff7 core: implement System.Contract.Call interop 2020-05-07 14:39:06 +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
Evgenii Stratonikov
82b230f19f core: rename *block.Base.GetHashableData to GetSignedPart()
This allow to use `Block` as a Verifiable item.
When tx is provided, it is set as an interop's script container.
Otherwise, block is set.
2020-04-17 11:12:40 +03:00
Evgenii Stratonikov
9586af32f2 core: move runtime.CheckWitness interop to a separate package 2020-04-16 15:54:58 +03:00