Commit graph

98 commits

Author SHA1 Message Date
Evgenii Stratonikov
dbe81f9b80 smartcontract: move flags to a separate package 2021-01-14 17:52:09 +03:00
Evgeniy Stratonikov
0b26b46234 state: store NEF instead of script for contract
NEFs for native contracts are set statically, thus
field values are taken from the reference implementation.
2021-01-13 15:34:10 +03:00
Evgenii Stratonikov
1840c1c80d core: redefine opcode prices
Prices are defined in as a coefficients to `BaseExecFee` which
is defined by Policy contract (TBD later).
Native method prices are defined without need to multiply.
2020-12-16 13:55:39 +03:00
Evgenii Stratonikov
1ffa1f9ade native: fix contract hashes 2020-12-15 12:58:04 +03:00
Roman Khimov
1e9253f1f0 interop: rename Neo.Native.Call to System.Contract.CallNative 2020-12-14 15:24:13 +03:00
Roman Khimov
ab12eee346 native: move contract deployment to management contract
See neo-project/neo#2119.
2020-12-14 15:23:46 +03:00
Roman Khimov
ad3547783d native: drop Neo.Native.Deploy, move contract init to management contract
The contract is almost a stub at the moment, though it does deploy other
contracts.
2020-12-14 13:33:41 +03:00
Roman Khimov
090bee8624 native: change OnPersist/PostPersist handling
Every contract now has these and they're always invoked. See
neo-project/neo#1913 and neo-project/neo#2119.
2020-12-13 21:36:06 +03:00
Anna Shaleva
53e45d793b core: adjust call flags 2020-12-11 11:38:14 +03:00
Anna Shaleva
fadbae8997 core: rename call flags
Also new States flag is added and ReadOnly flag is adjusted.
2020-12-11 10:34:01 +03:00
Evgenii Stratonikov
e63191d31f core: hangle CallingScriptHash correctly
When using native contracts, script hash of second-to-top context
on invocation stack does not always correspond to a real calling
contract.
2020-12-10 16:52:36 +03:00
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