Commit graph

4447 commits

Author SHA1 Message Date
Roman Khimov
299d55e539
Merge pull request #2558 from nspcc-dev/rpc/fix-signature-decoding
rpc: fix compatibility issues of `CreateFunctionInvocationScript`
2022-06-27 08:18:36 +03:00
Anna Shaleva
9488756437 rpc: extend error log message for failed RPC requests
Message is always non-empty; Data is allowed to be empty.
2022-06-24 12:44:10 +03:00
Anna Shaleva
a15e52ee3d rpc: adjust TestInvocationScriptCreationGood testcase
Although neo-go can handle both ByteArray and ByteString parameter
types, C# node can't, so let's use the common one for tests. Compat
test:
```
anna@kiwi:~/Documents/GitProjects/nspcc-dev/neo-go$ curl -d '{ "jsonrpc": "2.0", "id": 1, "method": "invokefunction", "params": ["50befd26fdf6e4d957c11e078b24ebce6291456f", "a", [{"type": "ByteString", "value": "AwEtR+diEK7HO+Oas9GG4KQP6Nhr+j1Pq/2le6E7iPlq"}] ]}' seed1.neo.org:10332 | json_pp
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1271    0  1070  100   201   2860    537 --:--:-- --:--:-- --:--:--  3398
{
   "jsonrpc" : "2.0",
   "id" : 1,
   "error" : {
      "message" : "Requested value 'ByteString' was not found.",
      "data" : "   at System.Enum.TryParseByName(RuntimeType enumType, ReadOnlySpan`1 value, Boolean ignoreCase, Boolean throwOnFailure, UInt64& result)\n   at System.Enum.TryParseUInt32Enum(RuntimeType enumType, ReadOnlySpan`1 value, UInt32 maxInclusive, Boolean ignoreCase, Boolean throwOnFailure, TypeCode type, UInt32& result)\n   at System.Enum.TryParse[TEnum](ReadOnlySpan`1 value, Boolean ignoreCase, Boolean throwOnFailure, TEnum& result)\n   at System.Enum.TryParse[TEnum](String value, Boolean ignoreCase, Boolean throwOnFailure, TEnum& result)\n   at Neo.SmartContract.ContractParameter.FromJson(JObject json)\n   at Neo.Plugins.RpcServer.<>c.<InvokeFunction>b__43_0(JObject p)\n   at System.Linq.Enumerable.SelectIListIterator`2.ToArray()\n   at Neo.Plugins.RpcServer.InvokeFunction(JArray _params)\n   at Neo.Plugins.RpcServer.ProcessRequestAsync(HttpContext context, JObject request)",
      "code" : -2147024809
   }
}
anna@kiwi:~/Documents/GitProjects/nspcc-dev/neo-go$ curl -d '{ "jsonrpc": "2.0", "id": 1, "method": "invokefunction", "params": ["50befd26fdf6e4d957c11e078b24ebce6291456f", "a", [{"type": "ByteArray", "value": "AwEtR+diEK7HO+Oas9GG4KQP6Nhr+j1Pq/2le6E7iPlq"}] ]}' seed1.neo.org:10332 | json_pp
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   507    0   307  100   200    161    105  0:00:01  0:00:01 --:--:--   266
{
   "result" : {
      "gasconsumed" : "104526",
      "notifications" : [],
      "stack" : [],
      "script" : "DCEDAS1H52IQrsc745qz0YbgpA/o2Gv6PU+r/aV7oTuI+WoRwB8MAWEMFG9FkWLO6ySLBx7BV9nk9v0m/b5QQWJ9W1I=",
      "state" : "FAULT",
      "exception" : "Called Contract Does Not Exist: 0x50befd26fdf6e4d957c11e078b24ebce6291456f"
   },
   "id" : 1,
   "jsonrpc" : "2.0"
}
```
2022-06-24 12:37:25 +03:00
Anna Shaleva
aa3a5fc492 rpc: adjust script creation with empty parameters list
Always use NEWARRAY0 where possible, see
26d04a642a/src/neo/VM/Helper.cs (L41).

Compatibility is tested:
```
anna@kiwi:~/Documents/GitProjects/nspcc-dev/neo-go$ curl -d '{ "jsonrpc": "2.0", "id": 1, "method": "invokefunction", "params": ["50befd26fdf6e4d957c11e078b24ebce6291456f", "a", [] ]}' seed1.neo.org:10332 | json_pp
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   370    0   248  100   122    127     62  0:00:01  0:00:01 --:--:--   190
{
   "result" : {
      "notifications" : [],
      "stack" : [],
      "script" : "wh8MAWEMFG9FkWLO6ySLBx7BV9nk9v0m/b5QQWJ9W1I=",
      "gasconsumed" : "98403",
      "state" : "FAULT",
      "exception" : "Called Contract Does Not Exist: 0x50befd26fdf6e4d957c11e078b24ebce6291456f"
   },
   "jsonrpc" : "2.0",
   "id" : 1
}
```
2022-06-24 12:37:22 +03:00
Anna Shaleva
171af36ead rpc: fix Signature parameter unmarshalling
It is based64 encoded and decoded, see
5108d1c2c7/pkg/smartcontract/parameter.go (L78)
and
26d04a642a/src/neo/SmartContract/ContractParameter.cs (L150)
and
26d04a642a/src/neo/SmartContract/ContractParameter.cs (L79).

Also, TestInvocationScriptCreationGood is extended and compatibility
is tested with the following C# node requests:
```
anna@kiwi:~/Documents/GitProjects/nspcc-dev/neo-go$ curl -d '{ "jsonrpc": "2.0", "id": 1, "method": "invokefunction", "params": ["50befd26fdf6e4d957c11e078b24ebce6291456f", "a", [{"type": "Signature", "value": "4edf5005771de04619235d5a4c7a9a11bb78e008541f1da7725f654c33380a3c87e2959a025da706d7255cb3a3fa07ebe9c6559d0d9e6213c68049168eb1056f"}]] }' seed1.neo.org:10332 | json_pp
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   665    0   381  100   284    197    147  0:00:01  0:00:01 --:--:--   344
{
   "jsonrpc" : "2.0",
   "id" : 1,
   "result" : {
      "notifications" : [],
      "stack" : [],
      "script" : "DGDh51/nTTnvvV17TjrX3bfl3lrhztr1rXVtvvx7TTznjV/V1rvvbl/rnhzfffzRrdzzt7b3n1rTbl1rvTp3vbnlxvdrd9rTt5t71zrnn13R317rbXdzrzTj3Xrx5vXTnp8RwB8MAWEMFG9FkWLO6ySLBx7BV9nk9v0m/b5QQWJ9W1I=",
      "exception" : "Called Contract Does Not Exist: 0x50befd26fdf6e4d957c11e078b24ebce6291456f",
      "state" : "FAULT",
      "gasconsumed" : "104526"
   }
}
anna@kiwi:~/Documents/GitProjects/nspcc-dev/neo-go$ curl -d '{ "jsonrpc": "2.0", "id": 1, "method": "invokefunction", "params": ["50befd26fdf6e4d957c11e078b24ebce6291456f", "a", [{"type": "Signature", "value": "Tt9QBXcd4EYZI11aTHqaEbt44AhUHx2ncl9lTDM4CjyH4pWaAl2nBtclXLOj+gfr6cZVnQ2eYhPGgEkWjrEFbw=="}]] }' seed1.neo.org:10332 | json_pp
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   591    0   347  100   244    794    558 --:--:-- --:--:-- --:--:--  1352
{
   "jsonrpc" : "2.0",
   "result" : {
      "state" : "FAULT",
      "exception" : "Called Contract Does Not Exist: 0x50befd26fdf6e4d957c11e078b24ebce6291456f",
      "gasconsumed" : "104526",
      "notifications" : [],
      "stack" : [],
      "script" : "DEBO31AFdx3gRhkjXVpMepoRu3jgCFQfHadyX2VMMzgKPIfilZoCXacG1yVcs6P6B+vpxlWdDZ5iE8aASRaOsQVvEcAfDAFhDBRvRZFizuskiwcewVfZ5Pb9Jv2+UEFifVtS"
   },
   "id" : 1
}
```
2022-06-22 16:05:14 +03:00
Anna Shaleva
464061c7c1 rpc: refactor TestInvocationScriptCreationGood
Convert expected script from hex to base64 in order to match
`invokefunction` RPC response script encoding. No functional
changes.
2022-06-22 16:05:14 +03:00
Anna Shaleva
7c48edaccb core, rpc: fix height-related issue of historic call functionality
Specifying a certain stateroot R as `invoke*historic` RPC-call
parameter, we're willing to perform historic call based on the storage
state of root R. Thus, next block should be of the height h(R)+1. This
allows to use historic functionality for the current blockchain height.
2022-06-20 19:05:22 +03:00
Roman Khimov
5108d1c2c7
Merge pull request #2539 from nspcc-dev/rollback-methods-sorting
core: sort native methods in ASCII-compatible way
2022-06-14 22:09:23 +03:00
Roman Khimov
6e475856aa
Merge pull request #2544 from nspcc-dev/rpc/remove-cause
rpc: remove Cause field from RPC error
2022-06-10 19:12:13 +03:00
Anna Shaleva
ea6ddbee5b rpc: get rid of erverError type
Retrieve error's HTTP code in a separate method.
2022-06-10 16:47:57 +03:00
Anna Shaleva
6434404081 rpc: extend the list of predefined RPC errors
Add a few the most common ones.
2022-06-10 16:47:42 +03:00
Anna Shaleva
ef9eca7cce rpc: unexport ServerError
It's internal server thing that is not for the outside users.
2022-06-10 16:38:41 +03:00
Anna Shaleva
0687924e87 rpc: split response.Error into server/client side 2022-06-10 16:35:51 +03:00
Anna Shaleva
5803923f68 rpc: remove Cause field from RPC error
We can use Data field for the same purposes.
2022-06-10 16:35:48 +03:00
Roman Khimov
7b88aedb27 transaction: add fuzz-test, refs. #2374 2022-06-09 13:43:22 +03:00
Roman Khimov
9919fd2cc9
Merge pull request #2548 from nspcc-dev/shuffle-tests
Shuffle tests and some other code
2022-06-09 12:28:03 +03:00
Evgeniy Stratonikov
0431e26659 wallet: export SavePretty method
Client code can make use of it, see nspcc-dev/neofs-node#1498.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-06-09 09:47:18 +03:00
Roman Khimov
1b7c8f262b core: add some comment for TestDesignate_DesignateAsRole
Closes #1472 at last.
2022-06-08 23:11:14 +03:00
Roman Khimov
ef50518b83 core: move notary tests into the notary package 2022-06-08 23:07:28 +03:00
Roman Khimov
5d573895ad core: move oracle tests into oracle service 2022-06-08 23:04:47 +03:00
Roman Khimov
017cd558cb core: move statesync tests into the statesync package 2022-06-08 22:57:48 +03:00
Roman Khimov
ff75e67610 core: move stateroot tests into services/stateroot
They test both module and service which is a bit wrong, but separating these
tests will lead to some duplication, so it's OK for now to have them in the
higher-order package (service imports module).
2022-06-08 22:53:09 +03:00
Roman Khimov
167bb72424 core: move Policy contract tests to native 2022-06-08 22:44:25 +03:00
Roman Khimov
a1eccc16e6 core: move benchmarks into bench_test.go
They share some functions and they're benchmarks, so let's have them here.
2022-06-08 22:39:57 +03:00
Roman Khimov
2e2d886a2f core: move Management contract test into native 2022-06-08 22:34:09 +03:00
Roman Khimov
8057c096c6 core: move native invocation tests into native 2022-06-08 22:26:24 +03:00
Roman Khimov
2086bca303 core: move storage-related interop code into the storage package 2022-06-08 22:26:24 +03:00
Roman Khimov
f0d7a1da2a core: move contract-related tests to the contract package 2022-06-08 19:01:34 +03:00
Roman Khimov
e7e80fda64 core: move TestNativeGetMethod to the native package 2022-06-08 18:51:27 +03:00
Roman Khimov
2127cc4146 core: move Runtime tests to runtime package 2022-06-08 18:46:49 +03:00
Roman Khimov
0055b18a8a core: export CreateGenesisBlock
Nothing bad with it being public.
2022-06-08 18:20:34 +03:00
Roman Khimov
d70caf1da1 core: move GetScriptContainer to runtime
It also brings ToStackItem to Block and Transaction, previously this was
avoided to separate block and transaction packages from VM. But turns out
`transaction` depends on `stackitem` already, so this makes little sense (but
can be shuffled in another way if needed).

Context.Container is still a hash.Hashable because we have a number of
occasions (header or MPT root verification) where there is no ToStackItem
implementation possible. Maybe they can go with `nil` Container, but I don't
want to have this risk for now.
2022-06-08 18:12:41 +03:00
Roman Khimov
cdb55740ea core: move ContractCreate*Account tests into the contract pkg
No functional changes.
2022-06-08 16:56:06 +03:00
Roman Khimov
ff1545b7eb core: move TestContractCall into the contract package
It belongs there and now it can be moved. No functional changes.
2022-06-08 16:53:01 +03:00
Roman Khimov
bb021d0778 native: unbind PutContractState from Management
It doesn't need Management's state, ID can't really change.
2022-06-08 16:41:28 +03:00
Roman Khimov
209b977e9a core: move contract-related interop code into appropriate package
And move one of the tests with it.
2022-06-08 16:02:07 +03:00
Roman Khimov
10f94e6119 core: move chain dump test into its own package 2022-06-08 15:28:08 +03:00
Roman Khimov
c2b3ee3d8e core: move basic chain creation into a package of its own
This allows to reuse it across different packages.

testchain can't be used because of circular dependencies.

Init() is not changed except for filepath.Join() use instead of direct string
appends which is a better approach anyway. rootpath is required because
current directory will change from package to package.
2022-06-08 15:25:27 +03:00
Roman Khimov
8673d2a79c
Merge pull request #2543 from nspcc-dev/perf-new
Minor allocation improvements
2022-06-07 11:04:59 +03:00
Roman Khimov
19ad31dc52 vm: optimize IsSignatureContract
We use it a lot in (*Blockchain).IsTxStillRelevant().

name                   old time/op    new time/op    delta
IsSignatureContract-8    19.1ns ± 5%     1.2ns ± 4%  -93.81%  (p=0.000 n=10+10)

name                   old alloc/op   new alloc/op   delta
IsSignatureContract-8     0.00B          0.00B          ~     (all equal)

name                   old allocs/op  new allocs/op  delta
IsSignatureContract-8      0.00           0.00          ~     (all equal)
2022-06-07 10:29:13 +03:00
Roman Khimov
92c94f265c interop/vm: make VM reusable and use on VM for all in-block execs
Avoid allocating again and again. Increases TPS by about 3%.
2022-06-07 10:05:47 +03:00
Roman Khimov
bdc6624c9d interop: unify VM price getter setting 2022-06-06 22:00:16 +03:00
Roman Khimov
638b04b29a interop: wrap contract.LoadToken in context.LoadToken
Creating a closure in runtime is a relatively costly thing, but it can easily
be avoided.
2022-06-06 21:53:03 +03:00
Anna Shaleva
7612ad1195 rpc: adjust test data 2022-06-06 13:02:29 +03:00
Anna Shaleva
7dcbfcbbdb rpc: improve WS connection closure error a bit
Ref.
https://github.com/nspcc-dev/neofs-node/pull/1480#issuecomment-1147256917.
2022-06-06 12:58:42 +03:00
Anna Shaleva
1005c1f7db vm: forbid jumping out of the script bounds 2022-06-06 12:18:19 +03:00
Anna Shaleva
a5b5f88fe2 core: doesn't allow to deploy contract with invalid method offset
This commit partially reverts 16bf7c1426.
2022-06-06 12:18:16 +03:00
Anna Shaleva
bc85f00cc7 Partially revert "core: fix native NEO ABI"
This partially reverts commit ca127f1615.
2022-06-06 12:08:52 +03:00
Roman Khimov
799394192b state: create buffer/io writer once per TokenTransferLog
name                       old time/op    new time/op    delta
TokenTransferLog_Append-8   93.0µs ±170%   46.8µs ±152%     ~     (p=0.053 n=10+9)

name                       old alloc/op   new alloc/op   delta
TokenTransferLog_Append-8    53.8kB ± 4%    38.6kB ±39%  -28.26%  (p=0.004 n=8+10)

name                       old allocs/op  new allocs/op  delta
TokenTransferLog_Append-8       384 ± 0%       128 ± 0%  -66.67%  (p=0.000 n=10+10)
2022-06-04 00:11:11 +03:00
Roman Khimov
1e5825c4af core: don't allocate another int for notification handler
It'll be serialized anyway.
2022-06-03 23:39:46 +03:00
Roman Khimov
7a2199c495
Merge pull request #2535 from nspcc-dev/drop-hf-prefix
config: s/HF_Aspidochelone/Aspidochelone/
2022-06-03 11:59:53 +03:00
Roman Khimov
b6829f36fd config: s/HF_Aspidochelone/Aspidochelone/
HF_ prefix makes zero sense to me. If it's "hardfork", then it's in the
"Hardforks" section already. If it's "hotfix", then it made some sense back
when it was HF_2712_FixSyscallFees, but now it's codenamed anyway. So we can
drop it and have a cleaner config.
2022-06-03 11:53:18 +03:00
Anna Shaleva
629567717f compiler: make TestNativeHelpersCompile test more verbose 2022-06-03 11:37:50 +03:00
Anna Shaleva
ca519492fc rpc: adjust test data 2022-06-03 11:37:50 +03:00
Anna Shaleva
d3b15a60a2 core: add test for ABI checks on deploy
Make sure it compatible with the reference implementation, see
736c346b9d/src/neo/SmartContract/Helper.cs (L83).
2022-06-03 11:37:50 +03:00
Anna Shaleva
16bf7c1426 core: adjust contract script check on deploy
Reference implementation doesn't panic if the method offset is out of
the contract script bounds, see:
736c346b9d/src/neo/SmartContract/Helper.cs (L82)
and
a65487fa56/src/Neo.VM/Script.cs (L146).

This commit fixes T5 statediff at block #125000. Neo-go node FAULTed the
deploying transaction:
```
         {
            "version" : 0,
            "sysfee" : "1000106065",
            "validuntilblock" : 130758,
            "script" : "DdMDeyJuYW1lIjoiTmVwMTdUb2tlbiIsImdyb3VwcyI6W10sImZlYXR1cmVzIjp7fSwic3VwcG9ydGVkc3RhbmRhcmRzIjpbIk5FUC0xNyJdLCJhYmkiOnsibWV0aG9kcyI6W3sibmFtZSI6InN5bWJvbCIsInBhcmFtZXRlcnMiOltdLCJyZXR1cm50eXBlIjoiU3RyaW5nIiwib2Zmc2V0IjoyMiwic2FmZSI6dHJ1ZX0seyJuYW1lIjoiZGVjaW1hbHMiLCJwYXJhbWV0ZXJzIjpbXSwicmV0dXJudHlwZSI6IkludGVnZXIiLCJvZmZzZXQiOjIyLCJzYWZlIjp0cnVlfSx7Im5hbWUiOiJ0b3RhbFN1cHBseSIsInBhcmFtZXRlcnMiOltdLCJyZXR1cm50eXBlIjoiSW50ZWdlciIsIm9mZnNldCI6MjIsInNhZmUiOnRydWV9LHsibmFtZSI6ImJhbGFuY2VPZiIsInBhcmFtZXRlcnMiOlt7Im5hbWUiOiJvd25lciIsInR5cGUiOiJIYXNoMTYwIn1dLCJyZXR1cm50eXBlIjoiSW50ZWdlciIsIm9mZnNldCI6MjIsInNhZmUiOnRydWV9LHsibmFtZSI6InRyYW5zZmVyIiwicGFyYW1ldGVycyI6W3sibmFtZSI6ImZyb20iLCJ0eXBlIjoiSGFzaDE2MCJ9LHsibmFtZSI6InRvIiwidHlwZSI6Ikhhc2gxNjAifSx7Im5hbWUiOiJhbW91bnQiLCJ0eXBlIjoiSW50ZWdlciJ9LHsibmFtZSI6ImRhdGEiLCJ0eXBlIjoiQW55In1dLCJyZXR1cm50eXBlIjoiQm9vbGVhbiIsIm9mZnNldCI6MjIsInNhZmUiOmZhbHNlfV0sImV2ZW50cyI6W3sibmFtZSI6IlRyYW5zZmVyIiwicGFyYW1ldGVycyI6W3sibmFtZSI6ImZyb20iLCJ0eXBlIjoiSGFzaDE2MCJ9LHsibmFtZSI6InRvIiwidHlwZSI6Ikhhc2gxNjAifSx7Im5hbWUiOiJhbW91bnQiLCJ0eXBlIjoiSW50ZWdlciJ9XX1dfSwicGVybWlzc2lvbnMiOlt7ImNvbnRyYWN0IjoiKiIsIm1ldGhvZHMiOiIqIn1dLCJ0cnVzdHMiOltdLCJleHRyYSI6eyJlbWFpbCI6ImRldmVsb3BlckBuZW8ub3JnIiwiYXV0aG9yIjoibGF6eW5vZGUiLCJkZXNjcmlwdGlvbiI6IkEgU2ltcGxlIE5lcC0xNyBDb250cmFjdCJ9fQyyTkVGM25lb21sAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABOaHR0cHM6Ly9naXRodWIuY29tL2xhenlub2RlL25lb21sL2Jsb2IvZGV2L2V4YW1wbGVzL2EuZnVuY3Rpb24uc2ltcGxlbmVwMTcueG1sAAAAABYMBU5lb01MQBhAAgDh9QVAATkFQBFAkA456BLAHwwGZGVwbG95DBT9o/pDRupTKiWPxJfdrdtkN8n9/0FifVtS",
            "hash" : "0x40302bcf2021f63a1c24f6009e154c3200f73ad2fe1462d7d599145823dbfa7e",
            "witnesses" : [
               {
                  "verification" : "DCECExn08eznGBdguHbcwI+R2//EtVdDx4qf6CeizHqOJgBBVuezJw==",
                  "invocation" : "DEBtoq+T9NrammQjuYnifco7KHCTk2v+woEJqJCUMr9IscS7PaZaN3FNzSt11yUglIi3T0CJ17KwArBOBvJ8kwq2"
               }
            ],
            "attributes" : [],
            "signers" : [
               {
                  "scopes" : "None",
                  "account" : "0x13a192c56738900f9918d7f1ec07d9d8c278b804"
               }
            ],
            "size" : 1360,
            "nonce" : 1829882407,
            "sender" : "NLLvsqs7AyBNmQT6NThUxYWDFwV5b1evaK",
            "netfee" : "234352"
         }
```
Transaction script contains malformed contract manifest (all methods
offsets are set to be 22, while the contract script lenght is 22):
```
{
   "name" : "Nep17Token",
   "groups" : [],
   "extra" : {
      "description" : "A Simple Nep-17 Contract",
      "email" : "developer@neo.org",
      "author" : "lazynode"
   },
   "permissions" : [
      {
         "contract" : "*",
         "methods" : "*"
      }
   ],
   "features" : {},
   "supportedstandards" : [
      "NEP-17"
   ],
   "abi" : {
      "events" : [
         {
            "parameters" : [
               {
                  "name" : "from",
                  "type" : "Hash160"
               },
               {
                  "type" : "Hash160",
                  "name" : "to"
               },
               {
                  "name" : "amount",
                  "type" : "Integer"
               }
            ],
            "name" : "Transfer"
         }
      ],
      "methods" : [
         {
            "safe" : true,
            "offset" : 22,
            "name" : "symbol",
            "returntype" : "String",
            "parameters" : []
         },
         {
            "returntype" : "Integer",
            "parameters" : [],
            "safe" : true,
            "offset" : 22,
            "name" : "decimals"
         },
         {
            "parameters" : [],
            "returntype" : "Integer",
            "name" : "totalSupply",
            "safe" : true,
            "offset" : 22
         },
         {
            "parameters" : [
               {
                  "name" : "owner",
                  "type" : "Hash160"
               }
            ],
            "returntype" : "Integer",
            "name" : "balanceOf",
            "offset" : 22,
            "safe" : true
         },
         {
            "name" : "transfer",
            "offset" : 22,
            "safe" : false,
            "parameters" : [
               {
                  "type" : "Hash160",
                  "name" : "from"
               },
               {
                  "name" : "to",
                  "type" : "Hash160"
               },
               {
                  "name" : "amount",
                  "type" : "Integer"
               },
               {
                  "name" : "data",
                  "type" : "Any"
               }
            ],
            "returntype" : "Boolean"
         }
      ]
   },
   "trusts" : []
}
```
2022-06-03 11:37:50 +03:00
Anna Shaleva
1472c271e6 core: fix native NEO's getCandidateVote signature
This commit fixes T5 statediff at block #0. Management's storage item
differs between neo-go and C# nodes, the reason in native NEO contract
state.

The parameter should have `pubKey` name, unlike the other `pubkey`
arguments in this contract.
2022-06-03 11:37:50 +03:00
Anna Shaleva
ca127f1615 core: fix native NEO ABI
This commit fixes T5 statediff at block #0. The reason in Management's
storage state. The diff occurs because of inconsistent NEO methods
order. See
https://github.com/neo-project/neo/issues/2766#issue-1257870089.

The current solution is to preserve C#'s order of methods to be
compatible with current testnet.

See also
https://docs.microsoft.com/ru-ru/dotnet/api/system.stringcomparer?view=net-6.0
and
https://stackoverflow.com/questions/28638714/easiest-method-to-orderby-a-string-using-stringcomparison-ordinal
for more details.
2022-06-03 11:37:41 +03:00
Roman Khimov
edb6ca8926
Merge pull request #2531 from nspcc-dev/perf
Minor performance improvements
2022-06-03 10:40:56 +03:00
Roman Khimov
400cbde32c state: optimize allocations in (*NEP17Transfer).EncodeBinary 2022-06-02 15:38:39 +03:00
Roman Khimov
54f75bb999 consensus: don't use WriteArray for PrepareRequests
It's convenient, but it's not efficient due to reflection use.
2022-06-02 15:38:39 +03:00
Roman Khimov
b0744c2b21 util: optimize MarshalJSON allocations
name                  old time/op    new time/op    delta
Uint256MarshalJSON-8     230ns ± 6%      83ns ±13%  -63.78%  (p=0.000 n=8+10)

name                  old alloc/op   new alloc/op   delta
Uint256MarshalJSON-8      320B ± 0%       80B ± 0%  -75.00%  (p=0.000 n=10+10)

name                  old allocs/op  new allocs/op  delta
Uint256MarshalJSON-8      5.00 ± 0%      1.00 ± 0%  -80.00%  (p=0.000 n=10+10)
2022-06-02 15:38:39 +03:00
Roman Khimov
9a06995460 bigint: don't allocate in ToPreallocatedBytes
Turns out, it's almost always allocating because we're mostly dealing with
small integers while the buffer size is calculated in 8-byte chunks here, so
preallocated buffer is always insufficient.

name                   old time/op    new time/op    delta
ToPreallocatedBytes-8    28.5ns ± 7%    19.7ns ± 5%   -30.72%  (p=0.000 n=10+10)

name                   old alloc/op   new alloc/op   delta
ToPreallocatedBytes-8     16.0B ± 0%      0.0B       -100.00%  (p=0.000 n=10+10)

name                   old allocs/op  new allocs/op  delta
ToPreallocatedBytes-8      1.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)

Fix StorageItem reuse at the same time. We don't copy when getting values from
the storage, but we don when we're putting them, so buffer reuse could corrupt
old values.
2022-06-02 15:38:39 +03:00
Roman Khimov
c3d989ebda stackitem: reusable serialization context
We serialize items a lot and this allows to avoid a number of allocations.
2022-06-02 15:38:39 +03:00
Anna Shaleva
3bec6657f5 core: adjust notary-related attributes encoding 2022-06-01 15:09:06 +03:00
Anna Shaleva
1b80215415 core: adjust types of NVB, Conflicts and NotaryAssisted attributes 2022-06-01 15:09:06 +03:00
Anna Shaleva
c4f3a92485 rpc: regenerate testchain 2022-06-01 15:09:02 +03:00
Anna Shaleva
d540f16e37 core: adjust noderoles package usages
Don't use interop roles package for internal tests.
2022-06-01 15:03:29 +03:00
Anna Shaleva
56d5839a72 core: log stateroot N20 hash inside TestCreateBasicChain 2022-06-01 15:03:29 +03:00
AnnaShaleva
4291efc8f0 services: fix typo in method description 2022-06-01 15:03:29 +03:00
AnnaShaleva
50157b31cd core: add maximum constraint to setNotaryServiceFeePerKey 2022-06-01 15:03:29 +03:00
AnnaShaleva
d7afb7bb2f core: adjust value of P2PNotary node role 2022-06-01 15:03:29 +03:00
AnnaShaleva
9008cc500c core: adjust Notary contract ID 2022-06-01 15:03:29 +03:00
Roman Khimov
3d4076ca36 vm: microoptimize new estack creation
Subslice won't reach element -1, but it can reuse the same buffer space more
effectively.
2022-05-31 18:53:05 +03:00
Roman Khimov
10110d4e70 bigint: correct MaxBytesLen
It can't be 33, positive signed int256 all fit into 32 bytes (no need for
leading zero), negative ones fit into 32 bytes as well.
2022-05-31 16:51:19 +03:00
Roman Khimov
3945e81857 bigint: don't allocate in ToPreallocatedBytes() for negative numbers
In-place modifications are somewhat dangerous, but yet another allocation is
quite costly.
2022-05-31 12:45:34 +03:00
Roman Khimov
3509523baf contract: tune isolation logic
Wrap when we have outer exception handler and the method is not
safe. Otherwise we wrap almost always, since non-readonly methods are very
common.
2022-05-31 11:44:12 +03:00
Roman Khimov
e1607e23c2
Merge pull request #2525 from nspcc-dev/immutable-items
vm: implement immutable stackitems
2022-05-31 10:36:56 +03:00
Anna Shaleva
42a051e55a core: DeepCopy notifiction event args inside System.Runtime.Notify 2022-05-31 08:07:53 +03:00
Anna Shaleva
7296f0c913 vm: support immutable compound types 2022-05-31 08:07:50 +03:00
Anna Shaleva
107f5e0793 vm: adjust refcount operations order
Perform add/set/remove operations with VM type firstly, and with
refcounter after that. It is needed to be able to extend add/set/remove
operations with extra checks.
2022-05-31 08:02:13 +03:00
Roman Khimov
270dfbe241
Merge pull request #2526 from nspcc-dev/rpc-err
rpc: do not allow empty error's Cause
2022-05-30 17:12:57 +03:00
Anna Shaleva
ebc3974545 rpc: do not allow empty error's Cause
Server logger is broken after #2496:
```
2022-05-30T10:35:06.096Z        ERROR   Error encountered with rpc request
```
2022-05-30 15:58:46 +03:00
Evgeniy Stratonikov
ec21c14ca9 gomod: upgrade yaml package from v2 to v3
Close #2085.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-05-30 15:26:17 +03:00
Roman Khimov
5e013311e6 native: emit vote/candidate events
Follow neo-project/neo#2754.
2022-05-28 18:44:20 +03:00
Roman Khimov
502cdd68ab
Merge pull request #2508 from nspcc-dev/snapshot-isolation
core, vm: implement snapshot isolation
2022-05-27 12:44:06 +03:00
Anna Shaleva
8055952bbc core: rename hardfork HF_2712_FixSyscallFees
Fantastic Beasts and Where to Find Them
2022-05-26 14:20:48 +03:00
Anna Shaleva
c4ad434f20 core: adjust System.Runtime.GetRandom
1. Make seed dependant on the GetRandom invocations counter.
2. Adjust syscall price.
2022-05-26 14:20:12 +03:00
Anna Shaleva
a79c80cb8d vm: wrap cross-contract exceptions 2022-05-26 11:44:26 +03:00
Anna Shaleva
a39b7cc3fd core, vm: move all isolation-related logic out of VM
Keep it inside the interop context.
2022-05-26 09:26:31 +03:00
Anna Shaleva
f79f62dab4 vm: use single function instead of committer/discarder 2022-05-26 09:26:31 +03:00
Anna Shaleva
08b68e9b82 vm, core: push Null return value only if no exception occurs
Close https://github.com/nspcc-dev/neo-go/issues/2509.
2022-05-26 09:26:31 +03:00
Anna Shaleva
ce226f6b76 vm: optimize context wrapping code
We can omit DAO wrapping for safe methods and for those methods that are not
wrapped into try-catch block. However, we still need to persist
notificationsCount changes for these methods to the parent context.
2022-05-26 09:26:31 +03:00
Anna Shaleva
0cd19f550e core, vm: implement snapshot isolation
Initial implementation without optimisations, but it should work.
2022-05-26 09:26:25 +03:00
Roman Khimov
c6666c52bc
Merge pull request #2515 from nspcc-dev/interop-marshalling
vm: stringify InteropInterface stackitem type as `InteropInterface`
2022-05-25 13:38:26 +03:00
Anna Shaleva
a3285eae04 vm: stringify InteropInterface stackitem type as InteropInterface 2022-05-25 13:20:21 +03:00
Anna Shaleva
98b5e2b353 rpc: always marshal FaultException 2022-05-25 10:48:58 +03:00
Roman Khimov
f77a775e61 core: raise System.Runtime.GetNotifications fee
Fix DoS, follow neo-project/neo#2748.
2022-05-24 17:45:23 +03:00
Roman Khimov
c9ab553e5b
Merge pull request #2510 from nspcc-dev/rpc/ws-errors
rpc: add ability to get WSClient connection closure error
2022-05-24 13:15:40 +03:00
Anna Shaleva
19646e0967 rpc: add ability to get WSClient connection closure error
Close #2421.
2022-05-24 11:29:19 +03:00
Anna Shaleva
d8f7d5d5b6 core: adjust Signer to stackitem conversion
Follow the https://github.com/neo-project/neo/pull/2708.
2022-05-23 14:01:42 +03:00
Anna Shaleva
b840674433 neotest: return failed tx hash
It still may be useful for debugging and tests.
2022-05-19 13:56:24 +03:00
Anna Shaleva
deb1f6d3d8 core: emit notification events in a separate method 2022-05-19 08:48:26 +03:00
Roman Khimov
73ef36e03e
Merge pull request #2507 from nspcc-dev/fix-ws-read
rpc: increase server-side WS read limit for websocket RPC message
2022-05-18 13:06:39 +03:00
Anna Shaleva
1a07d0f039 rpc: increase server-side WS read limit for websocket RPC message
Close #2505. Turns out that existing limit is too low to fit
`submitp2pnotaryrequest`.

Thanks to @alexvanin for discovering this.
2022-05-18 12:53:50 +03:00
Roman Khimov
34e7d3e53c
Merge pull request #2499 from nspcc-dev/fix-concurrent-seek
core: avoid concurrent map iteration and map write during SeekAsync over private MemCachedStore
2022-05-18 11:36:57 +03:00
Anna Shaleva
b66f666267 core: ensure memcached Seek operation is properly cancelled
PR #2495 is not enought, the problem is reproduced during dump restore
with the stacktrace attached down below.

The reason is that SeekAsync starts goroutine that performs Seek
operation over private MemCachedStore. The goroutine iterates over
MemCachedStore's map without holding the lock (it's OK, because it's
private), whereas the main thread continues invocation and
performs writes to the same map. To fix that ic.Exec() needs to
wait until all goroutines are properly exited.

```
2022-05-17T08:34:50.430+0300	INFO	persisted to disk	{"blocks": 632, "keys": 16546, "headerHeight": 54091, "blockHeight": 54091, "took": "57.904387ms"}
fatal error: concurrent map iteration and map write

goroutine 218853 [running]:
runtime.throw({0xf56a31, 0x614968})
	runtime/panic.go:1198 +0x71 fp=0xc0000ceae0 sp=0xc0000ceab0 pc=0x4357b1
runtime.mapiternext(0x0)
	runtime/map.go:858 +0x4eb fp=0xc0000ceb50 sp=0xc0000ceae0 pc=0x40f82b
runtime.mapiterinit(0xc0000cec18, 0xc00359ca40, 0x1a)
	runtime/map.go:848 +0x236 fp=0xc0000ceb70 sp=0xc0000ceb50 pc=0x40f2f6
github.com/nspcc-dev/neo-go/pkg/core/storage.(*MemCachedStore).prepareSeekMemSnapshot(0xc005315680, {{0xc00359ca40, 0x1a, 0x1a}, {0x0, 0x0, 0x0}, 0x0})
	github.com/nspcc-dev/neo-go/pkg/core/storage/memcached_store.go:209 +0x24a fp=0xc0000ced88 sp=0xc0000ceb70 pc=0x823fca
github.com/nspcc-dev/neo-go/pkg/core/storage.(*MemCachedStore).Seek(0xd94ac0, {{0xc00359ca40, 0x1a, 0x1a}, {0x0, 0x0, 0x0}, 0x0}, 0x20)
	github.com/nspcc-dev/neo-go/pkg/core/storage/memcached_store.go:156 +0x9b fp=0xc0000cee20 sp=0xc0000ced88 pc=0x82369b
github.com/nspcc-dev/neo-go/pkg/core/storage.performSeek({0x11c3330, 0xc002240dc0}, {0x11cb258, 0xc005315680}, {0x0, 0x0, 0x1}, {{0xc00359ca40, 0x1a, 0x1a}, ...}, ...)
	github.com/nspcc-dev/neo-go/pkg/core/storage/memcached_store.go:304 +0x4b7 fp=0xc0000cef00 sp=0xc0000cee20 pc=0x824a37
github.com/nspcc-dev/neo-go/pkg/core/storage.(*MemCachedStore).SeekAsync.func1()
	github.com/nspcc-dev/neo-go/pkg/core/storage/memcached_store.go:176 +0x16c fp=0xc0000cefe0 sp=0xc0000cef00 pc=0x823b8c
runtime.goexit()
	runtime/asm_amd64.s:1581 +0x1 fp=0xc0000cefe8 sp=0xc0000cefe0 pc=0x468a41
created by github.com/nspcc-dev/neo-go/pkg/core/storage.(*MemCachedStore).SeekAsync
	github.com/nspcc-dev/neo-go/pkg/core/storage/memcached_store.go:175 +0x1f6

goroutine 1 [runnable]:
github.com/nspcc-dev/neo-go/pkg/core/mpt.MapToMPTBatch.func1(0x4, 0x0)
	github.com/nspcc-dev/neo-go/pkg/core/mpt/batch.go:28 +0x95
sort.doPivot_func({0xc000457878, 0xc003305bc0}, 0x0, 0x1a)
	sort/zfuncversion.go:121 +0x46a
sort.quickSort_func({0xc000457878, 0xc003305bc0}, 0xc001014d20, 0x0, 0xc003304ff0)
	sort/zfuncversion.go:143 +0x85
sort.Slice({0xd94800, 0xc001014d20}, 0x1a)
	sort/slice.go:20 +0x9f
github.com/nspcc-dev/neo-go/pkg/core/mpt.MapToMPTBatch(0xc003304ff0)
	github.com/nspcc-dev/neo-go/pkg/core/mpt/batch.go:28 +0x2e7
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).storeBlock(0xc000400280, 0xc000f178c0, 0xc005a04370)
	github.com/nspcc-dev/neo-go/pkg/core/blockchain.go:1136 +0xfef
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).AddBlock(0xc000400280, 0xc000f178c0)
	github.com/nspcc-dev/neo-go/pkg/core/blockchain.go:893 +0x755
github.com/nspcc-dev/neo-go/pkg/core/chaindump.Restore({0x11c3528, 0xc000400280}, 0xc350, 0x0, 0x4c221, 0xc000458710)
	github.com/nspcc-dev/neo-go/pkg/core/chaindump/dump.go:73 +0x2ca
github.com/nspcc-dev/neo-go/cli/server.restoreDB(0xc000410000)
	github.com/nspcc-dev/neo-go/cli/server/server.go:381 +0xcfa
github.com/urfave/cli.HandleAction({0xdbbfa0, 0x10a1078}, 0x7)
	github.com/urfave/cli@v1.22.5/app.go:524 +0xa8
github.com/urfave/cli.Command.Run({{0xf32b10, 0x7}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0xf4a41d, 0x1c}, {0x0, ...}, ...}, ...)
	github.com/urfave/cli@v1.22.5/command.go:173 +0x652
github.com/urfave/cli.(*App).RunAsSubcommand(0xc0001f7880, 0xc0001adce0)
	github.com/urfave/cli@v1.22.5/app.go:405 +0x9ec
github.com/urfave/cli.Command.startApp({{0xf2e982, 0x2}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0xf41af9, 0x16}, {0x0, ...}, ...}, ...)
	github.com/urfave/cli@v1.22.5/command.go:372 +0x6e9
github.com/urfave/cli.Command.Run({{0xf2e982, 0x2}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0xf41af9, 0x16}, {0x0, ...}, ...}, ...)
	github.com/urfave/cli@v1.22.5/command.go:102 +0x808
github.com/urfave/cli.(*App).Run(0xc0001f76c0, {0xc00012e000, 0x8, 0x8})
	github.com/urfave/cli@v1.22.5/app.go:277 +0x705
main.main()
	./main.go:19 +0x33

goroutine 66 [select]:
github.com/syndtr/goleveldb/leveldb/util.(*BufferPool).drain(0xc00027e1c0)
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/util/buffer_pool.go:209 +0xcd
created by github.com/syndtr/goleveldb/leveldb/util.NewBufferPool
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/util/buffer_pool.go:240 +0x19b

goroutine 67 [select]:
github.com/syndtr/goleveldb/leveldb.(*session).refLoop(0xc0002441e0)
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/session_util.go:189 +0x5bb
created by github.com/syndtr/goleveldb/leveldb.newSession
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/session.go:93 +0x2de

goroutine 85 [select]:
github.com/syndtr/goleveldb/leveldb.(*DB).compactionError(0xc0001f7a40)
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/db_compaction.go:91 +0x15e
created by github.com/syndtr/goleveldb/leveldb.openDB
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/db.go:148 +0x4ef

goroutine 86 [select]:
github.com/syndtr/goleveldb/leveldb.(*DB).mpoolDrain(0xc0001f7a40)
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/db_state.go:101 +0xae
created by github.com/syndtr/goleveldb/leveldb.openDB
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/db.go:149 +0x531

goroutine 87 [runnable]:
github.com/syndtr/goleveldb/leveldb.(*compaction).shouldStopBefore(0xc001787440, {0xc001890720, 0x29, 0x30})
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/session_compaction.go:272 +0x10a
github.com/syndtr/goleveldb/leveldb.(*tableCompactionBuilder).run(0xc0001ca140, 0xc002039638)
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/db_compaction.go:461 +0x565
github.com/syndtr/goleveldb/leveldb.(*DB).compactionTransact(0xc0001f7a40, {0xf369f0, 0xb}, {0x11b9b60, 0xc0001ca140})
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/db_compaction.go:186 +0x22f
github.com/syndtr/goleveldb/leveldb.(*DB).tableCompaction(0xc0001f7a40, 0xc001787440, 0x0)
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/db_compaction.go:580 +0xa30
github.com/syndtr/goleveldb/leveldb.(*DB).tableAutoCompaction(0xc0001f7a40)
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/db_compaction.go:644 +0x39
github.com/syndtr/goleveldb/leveldb.(*DB).tCompaction(0xc0001f7a40)
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/db_compaction.go:863 +0x43b
created by github.com/syndtr/goleveldb/leveldb.openDB
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/db.go:155 +0x5a7

goroutine 88 [select]:
github.com/syndtr/goleveldb/leveldb.(*DB).mCompaction(0xc0001f7a40)
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/db_compaction.go:773 +0x119
created by github.com/syndtr/goleveldb/leveldb.openDB
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/db.go:156 +0x5e9

goroutine 78 [select]:
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).Run(0xc000400280)
	github.com/nspcc-dev/neo-go/pkg/core/blockchain.go:615 +0x185
created by github.com/nspcc-dev/neo-go/cli/server.initBCWithMetrics
	github.com/nspcc-dev/neo-go/cli/server/server.go:217 +0x23d

goroutine 79 [IO wait]:
internal/poll.runtime_pollWait(0x7ffb00b2aad8, 0x72)
	runtime/netpoll.go:229 +0x89
internal/poll.(*pollDesc).wait(0xc00012e180, 0x4, 0x0)
	internal/poll/fd_poll_runtime.go:84 +0x32
internal/poll.(*pollDesc).waitRead(...)
	internal/poll/fd_poll_runtime.go:89
internal/poll.(*FD).Accept(0xc00012e180)
	internal/poll/fd_unix.go:402 +0x22c
net.(*netFD).accept(0xc00012e180)
	net/fd_unix.go:173 +0x35
net.(*TCPListener).accept(0xc000280090)
	net/tcpsock_posix.go:140 +0x28
net.(*TCPListener).Accept(0xc000280090)
	net/tcpsock.go:262 +0x3d
net/http.(*Server).Serve(0xc00027e380, {0x11bd4a8, 0xc000280090})
	net/http/server.go:3001 +0x394
net/http.(*Server).ListenAndServe(0xc00027e380)
	net/http/server.go:2930 +0x7d
github.com/nspcc-dev/neo-go/pkg/network/metrics.(*Service).Start(0xc000097d10)
	github.com/nspcc-dev/neo-go/pkg/network/metrics/metrics.go:29 +0x115
created by github.com/nspcc-dev/neo-go/cli/server.initBCWithMetrics
	github.com/nspcc-dev/neo-go/cli/server/server.go:218 +0x285

goroutine 9 [syscall]:
os/signal.signal_recv()
	runtime/sigqueue.go:169 +0x98
os/signal.loop()
	os/signal/signal_unix.go:24 +0x19
created by os/signal.Notify.func1.1
	os/signal/signal.go:151 +0x2c

goroutine 8 [select]:
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).notificationDispatcher(0xc000400280)
	github.com/nspcc-dev/neo-go/pkg/core/blockchain.go:739 +0x2e7
created by github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).Run
	github.com/nspcc-dev/neo-go/pkg/core/blockchain.go:612 +0xe5

goroutine 10 [chan receive]:
github.com/nspcc-dev/neo-go/cli/server.newGraceContext.func1()
	github.com/nspcc-dev/neo-go/cli/server/server.go:117 +0x28
created by github.com/nspcc-dev/neo-go/cli/server.newGraceContext
	github.com/nspcc-dev/neo-go/cli/server/server.go:116 +0xde
```
2022-05-18 07:35:48 +03:00
Roman Khimov
1e22024808
Merge pull request #2502 from nspcc-dev/fix-initsslot-refs
Fix INITSSLOT refs
2022-05-17 16:53:50 +03:00
Roman Khimov
ae2395f55f vm: simplify (slot).Set code
Refcounter handles nil items just fine.
2022-05-17 16:26:22 +03:00
Roman Khimov
f2f66ad36e vm: clear static slot refs on exit, fix #2501 2022-05-17 16:26:22 +03:00
Roman Khimov
7bda933e32
Merge pull request #2496 from nspcc-dev/fix-2484
rpc: differentiate log level for RPC errors
2022-05-17 14:57:59 +03:00
Anna Shaleva
33a0207bbb rpc: differentiate log level for RPC errors
Close #2484. Also, do not overuse InternalServerError.
2022-05-17 14:43:07 +03:00
Roman Khimov
711112ae40
Merge pull request #2485 from nspcc-dev/fix-rpc
rpc: check transaction for validness before network fee calculation
2022-05-17 11:34:11 +03:00
Roman Khimov
0d93b353e6 vm: count initial Null slot variables as well
Match C# behavior. Thanks to @ixje for finding this.
2022-05-16 17:42:57 +03:00
Roman Khimov
18d627e7f7 vm: count map key in the refcounter as well
Thanks @ixje for spotting this.
2022-05-16 16:07:25 +03:00
Anna Shaleva
c5c5e4c208 core: do not panic if transaction with empty script is being serialized
See https://github.com/nspcc-dev/neo-go/pull/2485#discussion_r872695786.

Allows to avoid panic:
```
(18:28:29)[sergio@transient:morph-control-load]% downloads/neofs-adm morph -c configuration/config.yaml init --contracts downloads/neofs-contract-v0.15.1
Stage 1: transfer GAS to alphabet nodes.
Waiting for transactions to persist...
Stage 2: set notary and alphabet nodes in designate contract.
Stage 2: already performed.
Stage 3: deploy NNS contract.
NNS contract is already deployed.
Stage 4: deploy NeoFS contracts.
Alphabet contract #0 is already deployed.
Alphabet contract #1 is already deployed.
Alphabet contract #2 is already deployed.
Alphabet contract #3 is already deployed.
audit contract is already deployed.
balance contract is already deployed.
container contract is already deployed.
neofsid contract is already deployed.
netmap contract is already deployed.
proxy contract is already deployed.
reputation contract is already deployed.
subnet contract is already deployed.
Waiting for transactions to persist...
Stage 4.1: Transfer GAS to proxy contract.
Stage 5: register candidates.
Stage 6: transfer NEO to alphabet contracts.
Stage 7: set addresses in NNS.
NNS: Set alphabet0.neofs -> 2efeb27866fa774ec6bfb43babaadcc7b28f9bb7
NNS: Set alphabet1.neofs -> 5606bc6598a538ac59ded3caa842247b9b26097a
NNS: Set alphabet2.neofs -> 2a8308cfd2706ddd5f67adfdf3954c6836806b5d
NNS: Set alphabet3.neofs -> 718d0459e6787f0f13f1e1898bf2ce6bc4bb452d
NNS: Set audit.neofs -> 54d516b36c3380efa2b2f26bda300b6c6302b8e7
NNS: Set balance.neofs -> 72b3255944524cb822788a7542c9d06cba208c0c
NNS: Set container.neofs -> 20a20f4352a49f161eccb7d5a806fd46dcab81ea
NNS: Set neofsid.neofs -> 04a3a71535689b820093cefe7ae188ed7591ad27
NNS: Set netmap.neofs -> 9a34c97b2ba6bd986fd9140a9c3d59059fa430f4
NNS: Set proxy.neofs -> 4eba34ec016f8709a511b02765a1195e31a921ea
NNS: Set reputation.neofs -> 77b5b2cf596957cc05ca3d57503ef08d72792301
NNS: Set subnet.neofs -> b0abe16bc7f56b2e7e0694ae2b36207c6aaa8636
panic: error serializing *transaction.Transaction: transaction has no script

goroutine 1 [running]:
github.com/nspcc-dev/neo-go/pkg/io.GetVarSize({0xbf6240, 0xc0003634a0})
	github.com/nspcc-dev/neo-go@v0.98.2/pkg/io/size.go:68 +0x6fd
github.com/nspcc-dev/neo-go/pkg/rpc/client.(*Client).AddNetworkFee(0xc0004080c0, 0xc0003634a0, 0x0, {0xc00000e248, 0x1, 0x93})
	github.com/nspcc-dev/neo-go@v0.98.2/pkg/rpc/client/rpc.go:966 +0x6b
github.com/nspcc-dev/neo-go/pkg/rpc/client.(*Client).CreateTxFromScript(0x0, {0x0, 0x0, 0x0}, 0x1, 0x0, 0x0, {0xc0001c7990, 0x1, 0x1})
	github.com/nspcc-dev/neo-go@v0.98.2/pkg/rpc/client/nep17.go:128 +0x345
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph.(*initializeContext).sendCommitteeTx(0xc00014a370, {0x0, 0x0, 0x0}, 0xc0016bcf30, 0x2)
	github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph/initialize.go:336 +0x131
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph.(*initializeContext).updateNNSGroup(0xc0001c7c88, {0x13, 0xd3, 0x6b, 0x85, 0x3e, 0x86, 0xbe, 0x77, 0xb7, ...}, ...)
	github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph/initialize_nns.go:89 +0x134
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph.(*initializeContext).setNNS(0xc00014a370)
	github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph/initialize_nns.go:74 +0x8c5
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph.initializeSideChainCmd(0x12a00e0, {0xc22a22, 0x4, 0x4})
	github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph/initialize.go:94 +0x2bc
github.com/spf13/cobra.(*Command).execute(0x12a00e0, {0xc00013a6c0, 0x4, 0x4})
	github.com/spf13/cobra@v1.1.3/command.go:852 +0x60e
github.com/spf13/cobra.(*Command).ExecuteC(0x129c760)
	github.com/spf13/cobra@v1.1.3/command.go:960 +0x3ad
github.com/spf13/cobra.(*Command).Execute(...)
	github.com/spf13/cobra@v1.1.3/command.go:897
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules.Execute(...)
	github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/root.go:48
main.main()
	github.com/nspcc-dev/neofs-node/cmd/neofs-adm/main.go:10 +0x25
zsh: exit 2     downloads/neofs-adm morph -c configuration/config.yaml init --contracts
```
2022-05-16 15:19:17 +03:00
Anna Shaleva
d2dcdecca5 core: avoid concurrent map r/w during SeekAsync
Close #2493.
2022-05-16 12:25:15 +03:00
Roman Khimov
4b785d4ffb
Merge pull request #2491 from nspcc-dev/fix-2489
core: pop native call arguments after call invocation
2022-05-16 11:12:45 +03:00
Anna Shaleva
a0774a2194 core: pop native call arguments after call invocation
Close #2489.
2022-05-16 09:39:17 +03:00
Anna Shaleva
a033b212a3 rpc: bump getversion compat
Version 0.98.5 is officially released with the old behaviour. The same thing
as #2479.
2022-05-16 06:59:23 +03:00
Roman Khimov
058a7eff90 Merge PR #2488 from nspcc-dev/reorder-neo-gas-distribution 2022-05-13 19:36:34 +03:00
Roman Khimov
54d8a37f3b native: make it mergeable with master again 2022-05-13 18:51:27 +03:00
Roman Khimov
85fe111aea neo: mint GAS after NEO transfer processing
See neo-project/neo#2734.
2022-05-13 18:05:27 +03:00
Anna Shaleva
6020ca9ae8 crypto: adjust Checksum documentation 2022-05-13 13:20:40 +03:00
Anna Shaleva
e31f4ca331 interop: add interop API for MODMUL, MODPOW opcodes 2022-05-12 14:31:24 +03:00
Anna Shaleva
e66e82278c vm: upgrade submodule 2022-05-12 14:25:14 +03:00
Anna Shaleva
a94ccf9236 vm: add MODMUL and MODPOW opcodes
Close #2470.
2022-05-12 14:25:14 +03:00
Roman Khimov
7fd0eb14b5
Merge pull request #2469 from nspcc-dev/hardfork
core: add ability to create hard-forks
2022-05-12 14:05:48 +03:00
Roman Khimov
e7a0722849 rpc: bump getversion compat again
Version 0.98.4 is officially released with the old behaviour. The same thing
as #2472.
2022-05-12 10:37:56 +03:00
Roman Khimov
c6f8c33e66
Merge pull request #2478 from nspcc-dev/mainnet-fixes
Mainnet fixes
2022-05-12 10:04:53 +03:00
Roman Khimov
64baa309cb
Merge pull request #2475 from nspcc-dev/vm/fix-jump
vm: check instruction offset is valid before subsequent IP move
2022-05-12 10:04:04 +03:00
Roman Khimov
621db8c832 stackitem: allow to unJSONize big numbers (>int64), fix #2477
100000000000000000000 overflows int64 and NeoGo returns some garbage to
contracts instead of a proper number.
2022-05-11 21:03:10 +03:00
Roman Khimov
3d1a81df1f native: std.itoa uses lower-cased letters, fix #2476 2022-05-11 19:33:17 +03:00
Anna Shaleva
5505acf10e core: change Create[Standard, Multisig]Account prices
And make a hard-fork from this change.
2022-05-11 14:21:43 +03:00
Anna Shaleva
e70bf7d12e core: allow to create hard-fork 2022-05-11 14:21:38 +03:00
Anna Shaleva
3be37e8c5b vm: check instruction offset is valid before subsequent IP move
Reference implementation:
e167f03e25/src/neo-vm/ExecutionContext.cs (L77).

Turns out that exception-related code (try\finally handling) is the only
place where next instruction pointer bounds are not pre-checked before
assignment. This statement is true for both go and C# implementations.
However, C# code has duplicate check located inside the
InstructionPointer setter for all instructions except the
exception-related ones. Neo-go code doesn't perform this duplicate check.
Thus, C# VM FAULTs execution in case of invalid TRY/FINALLY offsets, and
neo-go VM does not.

This commit reverts a part of
https://github.com/nspcc-dev/neo-go/pull/2396. This bug is discovered
thanks to test added in https://github.com/neo-project/neo-vm/pull/453.
2022-05-11 14:04:02 +03:00
Anna Shaleva
d88ca102c6 services: forbid insecure Oracle request redirects 2022-05-11 09:45:44 +03:00
Roman Khimov
d1588115a2
Merge pull request #2473 from nspcc-dev/fix-gosimple-wrn
services: fix gosimple warning
2022-05-11 09:22:05 +03:00
Roman Khimov
483130fa7c
Merge pull request #2472 from nspcc-dev/shift-getversion-compat
rpc: move latest getversion compat to 0.98.3
2022-05-11 08:10:07 +03:00
Anna Shaleva
48ee33fd61 services: fix gosimple warning
Fix the following warning:
```
S1001: should use copy() instead of a loop (gosimple)
```
2022-05-11 07:39:27 +03:00
Roman Khimov
2b79a162ce
Merge pull request #2467 from nspcc-dev/limit-eq
vm: adjust comparable limit for ByteArray
2022-05-10 19:53:20 +03:00
Roman Khimov
bb0efed8b7 rpc: move latest getversion compat to 0.98.3
Version 0.98.3 is officially released with the old behavior.
2022-05-07 22:34:40 +03:00
Roman Khimov
711e21709f rpc/notary: make this branch mergeable with master 2022-05-07 18:38:50 +03:00
Anna Shaleva
8af043520d vm: adjust MaxByteArrayComparableSize value
https://github.com/neo-project/neo-vm/pull/454#discussion_r857533800.
2022-05-07 12:56:09 +03:00
Anna Shaleva
23b78b0be2 vm: limit ByteArray comparable length
Close #2460.
2022-05-07 12:56:04 +03:00
Roman Khimov
7dc0404306 transaction: fix maxSubitems handling in JSON scope unmarshaller
Notice that binary deserializer (readArrayOfConditions) does it correctly. Can
be checked with neo-project/neo#2720 case.
2022-05-07 12:05:34 +03:00
Roman Khimov
c410219cba transaction: fix Rules stringer, it's WitnessRules in C#
See neo-project/neo#2720.
2022-05-07 12:05:25 +03:00
Anna Shaleva
b1f74b549d rpc: avoid panic during request after WS connection is closed
Fix the following panic:
```
panic: assignment to entry in nil map

goroutine 131 [running]:
github.com/nspcc-dev/neo-go/pkg/rpc/client.(*WSClient).registerRespChannel(0xc00033c240, 0x0, 0xc00003e2a0)
        /home/denis/go/pkg/mod/github.com/nspcc-dev/neo-go@v0.98.2/pkg/rpc/client/wsclient.go:244 +0x96
github.com/nspcc-dev/neo-go/pkg/rpc/client.(*WSClient).makeWsRequest(0xc00033c240, 0xc002080000)
        /home/denis/go/pkg/mod/github.com/nspcc-dev/neo-go@v0.98.2/pkg/rpc/client/wsclient.go:264 +0x69
github.com/nspcc-dev/neo-go/pkg/rpc/client.(*Client).performRequest(0xc00033c240, {0xc9f173, 0xd}, {{0x13d09d0, 0x0, 0x0}}, {0xb44120, 0xc00147a000})
        /home/denis/go/pkg/mod/github.com/nspcc-dev/neo-go@v0.98.2/pkg/rpc/client/client.go:186 +0x15d
github.com/nspcc-dev/neo-go/pkg/rpc/client.(*Client).GetBlockCount(0xc001fb5440)
        /home/denis/go/pkg/mod/github.com/nspcc-dev/neo-go@v0.98.2/pkg/rpc/client/rpc.go:73 +0x69
...
```
2022-05-07 12:02:42 +03:00
Anna Shaleva
a7fe85a2d8 services: fix changing of main tx size of Notary request 2022-05-07 12:00:16 +03:00
Anna Shaleva
d68f57b9f9 rpc: avoid panic on double-call to *WSClient.Close()
Although it's the caller's duty to avoid WSClient re-closing, we
still can handle it.

Fixes the following neofs-node error:
```
panic: close of closed channel

goroutine 98 [running]:
github.com/nspcc-dev/neo-go/pkg/rpc/client.(*WSClient).Close(...)
        github.com/nspcc-dev/neo-go@v0.98.3-pre.0.20220321144433-3b639f518ebb/pkg/rpc/client/wsclient.go:120
github.com/nspcc-dev/neofs-node/pkg/morph/subscriber.(*subscriber).Close(0x13)
        github.com/nspcc-dev/neofs-node/pkg/morph/subscriber/subscriber.go:108 +0x29
github.com/nspcc-dev/neofs-node/pkg/morph/event.listener.Stop(...)
        github.com/nspcc-dev/neofs-node/pkg/morph/event/listener.go:573
created by github.com/nspcc-dev/neofs-node/pkg/innerring.(*Server).Stop
        github.com/nspcc-dev/neofs-node/pkg/innerring/innerring.go:285 +0x12f
```
2022-05-07 11:59:55 +03:00