Evgenii Stratonikov
e903e40085
core: call from native contracts synchronously
...
Follow neo-project/neo#2130 .
2020-12-10 16:43:46 +03:00
Evgenii Stratonikov
b7e86fa6a3
manifest: add Safe
flag to method descriptor
...
`interop.Contex.AddMethod` sets `Safe` flag for native
contracts. This allows not to forget to change manifest
when changing call flags.
Also fixed invalid `Safe` flags for `Notary` and `Designate` contracts.
2020-12-08 13:27:43 +03:00
Evgenii Stratonikov
6e749f4977
core: add tests for crypto interops
...
Also move related test from `core/`.
2020-12-03 14:14:35 +03:00
Evgenii Stratonikov
b203c23515
core: cover enumerator/iterator interops
2020-12-02 15:54:03 +03:00
Evgenii Stratonikov
d136569ac8
core: move System.Binary.*
interops to binary/
package
...
Also extend test suite.
2020-12-02 15:54:03 +03:00
Evgenii Stratonikov
2eb256014e
core: move System.Runtime.*
interops to runtime/
package
...
Also extend test suite.
2020-12-02 15:54:03 +03:00
Roman Khimov
d93aa745bb
contract: avoid going to the DB for entry scripts
...
This optimizes out DB access for non-deployed contracts under the assumption
that deployed ones are always loaded via `LoadScriptWithHash` (and if they're
not --- it's a bug anyway with the new hashing model) which actually is a very
popular case (every entry script does that).
2020-11-27 21:47:08 +03:00
Roman Khimov
1cf1fe5d74
*: introduce stable contract hashes
...
Follow neo-project/neo#2044 .
2020-11-27 21:47:08 +03:00
Roman Khimov
b92ea2a48a
manifest/compiler: drop hashes from ABI and debug info
...
See neo-project/neo-devpack-dotnet#391 and neo-project/neo#2044 .
2020-11-26 18:30:49 +03:00
Anna Shaleva
0f68528095
core: add callback to VM context
2020-11-25 18:37:29 +03:00
Evgenii Stratonikov
c849176be7
manifest: include contract Name
2020-11-24 11:23:44 +03:00
Evgenii Stratonikov
e4bf531e3e
core: implement System.Binary.Atoi/Itoa
syscalls
...
They follow C# conversion rules, but differ from our `bigint` module
conversions:
1. String must be big-endian.
2. Sign extension is 4-bit in size (single hex character)
and not 8-byte.
2020-11-10 16:15:10 +03:00
Anna Shaleva
204d7f1c6a
core: refactor runtime.CheckWitness interop
...
Removed unreachable code, see
8fed383523
runtime.CheckHashedWitness can only be used for transaction
verification, the other two options from reference implementation (block
and consensus payload) have separate methods for verification.
2020-10-26 20:26:21 +03:00
Anna Shaleva
fe1f0a7245
core: introduce CheckReturnState constants
...
At the moment we should have 3 possible options to check return state
during vm context unloading:
* no check
* ensure the stack is empty
* ensure the stack is not empty
It is necessary to distinguish them because new _deploy method shouldn't
left anything on stack. Example: if we use _deploy method before some
ordinary contract method which returns one value. Without these changes
the contract invocation will fail due to 2 elements on stack left after
invocation (the first `null` element is from _deploy, the second element
is return-value from the ordinary contract method).
2020-10-13 19:14:44 +03:00
Anna Shaleva
6ce00fde82
vm, core: move invocation counter from InteropContext to VM
2020-10-08 11:33:26 +03:00
Anna Shaleva
45bfce60a5
core: remove error from runtime.GetInvocationCounter
...
close #1444
2020-10-08 11:32:00 +03:00
Evgenii Stratonikov
2d9ef9219a
core: call _deploy method during create/update
2020-10-06 18:03:25 +03:00
Roman Khimov
adcbb2287f
Merge pull request #1439 from nspcc-dev/core/verify_tx_witnesses_fix
...
core: take into account gasConsumed during tx witnesses verification
2020-09-29 18:11:39 +03:00
Anna Shaleva
ff6aa0fd45
core: allow empty callingScriptHash during CheckWitness
...
CallingScriptHash can be empty in the entry transaction script.
2020-09-29 17:43:39 +03:00
Roman Khimov
53c9690bdc
interop/runtime: allow calling script hash to pass CheckWitness
...
See neo-project/neo#1924 and neo-project/neo#1925 .
2020-09-29 09:56:19 +03:00
Evgenii Stratonikov
30526046e7
native: don't push void result in Call
...
This was done in https://github.com/neo-project/neo/pull/1693
for native calls. `OnPersist` script still uses `DROP` though
as value is pushed via `CheckReturn` logic for regular calls.
2020-09-25 16:32:10 +03:00
Evgenii Stratonikov
877b8ece63
core: move contractCall* to a separate package
2020-09-25 16:32:10 +03:00
Roman Khimov
53c014a0bb
crypto/consensus: sign hashes and cache them for consensus payloads
...
Avoid serializing payload again and again for various purposes. To sign it, we
only need a hash.
Some 2.4% gain in TPS could be achieved with this.
2020-09-09 20:46:31 +03:00
Evgenii Stratonikov
f6319f80e8
interop: allow to call CheckWitness without AllowStates
...
State access is needed only in specific circumstances.
2020-08-27 10:29:29 +03:00
Roman Khimov
9c72ea1d64
core/interop: add base58 encoding/decoding syscalls
...
Follow neo-project/neo#1833 .
2020-08-23 17:19:56 +03:00
Evgenii Stratonikov
a796f2b61d
names: implement FromID
...
Allow to convert interop id to it's name.
2020-08-14 14:22:45 +03:00
Evgenii Stratonikov
7854dcfd8f
core: replace interop names with named constants
2020-08-14 14:21:54 +03:00
Evgenii Stratonikov
f3650e20b0
vm: move InteropNameToID to a separate package
2020-08-14 13:54:11 +03:00
Roman Khimov
f5131491b7
Merge pull request #1271 from nspcc-dev/core/call_from_native
...
core: contractCall from native contracts
2020-08-07 21:24:50 +03:00
Anna Shaleva
c87e2262c3
core: remove ScriptHashGetter from interop context
...
We have VM inside the context, so don't need ScriptHashGetter anymore.
2020-08-07 20:31:20 +03:00
Anna Shaleva
995053f2eb
core: add VM into interop context
2020-08-07 16:15:24 +03:00
Roman Khimov
0e2784cd2c
always wrap errors when creating new ones with fmt.Errorf()
...
It doesn't really change anything in most of the cases, but it's a useful
habit anyway.
Fix #350 .
2020-08-07 12:21:52 +03:00
Roman Khimov
5ef08f60ae
remove github.com/pkg/errors from dependencies
...
It's not needed any more with Go 1.13 as we have wrapping/unwrapping in base
packages. All errors.Wrap calls are replaced with fmt.Errorf, some strings are
improved along the way.
2020-08-07 12:21:52 +03:00
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
9a992865b1
interop: add Secp2k to the list of crypto interops
...
Allow to use them during verification.
2020-07-29 13:43:33 +03:00
Evgenii Stratonikov
23a1430395
core: allow to restrict creating callbacks from syscalls
...
Specify DisallowCallback flag if syscall is not allowed to be used in a
callback.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-29 13:41:08 +03:00
Evgenii Stratonikov
99b0397a61
core: implement System.Callback.CreateFromSyscall
interop
...
Allow to create callbacks from syscalls.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-29 13:41:08 +03:00
Evgenii Stratonikov
c54b45e76d
core: implement System.Callback.CreateFromMethod
interop
...
Support creating callbacks from contract methods.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-29 13:41:08 +03:00
Evgenii Stratonikov
382a7f5b3e
core: implement System.Callback.*
interops
...
Support creating callbacks from pointers.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-29 13:41:08 +03:00
Evgenii Stratonikov
51ae12e4fd
*: move syscall handling out of VM
...
Remove interop-related structures from the `vm` package.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-29 13:41:08 +03:00
Anna Shaleva
4bf88ba6b0
core: decouple native contracts from interop service
...
Closes #1191 .
2020-07-29 10:33:18 +03:00
Evgenii Stratonikov
8931c9a794
core/interop: increase coverate for crypto interops
2020-07-25 12:16:56 +03:00
Anna Shaleva
8fde41001e
core, vm: remove allowed triggers from syscalls
...
Closes #1205 .
2020-07-23 20:44:39 +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
990ef5525c
core: adjust System.Runtime.GasLeft interop
...
Part of #1055 .
In test mode it should return -1.
2020-07-23 07:51:24 +03:00
Anna Shaleva
8fed383523
core: adjust System.Runtime.CheckWitness interop
...
Part of #1055 .
It should have `AllowStates` flag.
Also removed unreachable code: we can't have such situation when
script container is not a transaction in the scope of `CheckWitness`
method because:
1. Blocks have their own implementation of CheckWitness for
internal usage (it's (bc *Blockchain) verifyHeaderWitnesses method).
2. For the outside calls of System.Runtime.CheckWitness interop (e.g.
calls from smart-contract) script container is always a transaction.
2020-07-23 07:51:24 +03:00
Anna Shaleva
459ac34839
core: adjust System.Enumerator.Create interop
...
Part of #1201 .
It should be able to create enumerator from primitive byte-array-like
stack items too.
2020-07-23 07:51:24 +03:00
Anna Shaleva
b8d82b49ec
core: add Neo.Crypto.RIPEMD160 interop
...
Closes #1193 .
2020-07-22 16:58:32 +03:00
Evgenii Stratonikov
3d7fa9de93
*: make Notify interop accept event name
2020-07-20 13:33:32 +03:00