Commit graph

5963 commits

Author SHA1 Message Date
Roman Khimov
ea69b72cd8
Merge pull request #2560 from nspcc-dev/rpc/extend-logging
rpc: extend error log message for failed RPC requests
2022-06-27 09:42:54 +03:00
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
Roman Khimov
2a24983727
Merge pull request #2556 from nspcc-dev/fix-historiccall
core, rpc: fix height-related issue of historic call functionality
2022-06-24 09:33:45 +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
e5f2cac3c1
Merge pull request #2553 from nspcc-dev/tx-fuzz
transaction: add fuzz-test, refs. #2374
2022-06-09 14:37:38 +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
Roman Khimov
2c9fb20442
Merge pull request #2549 from nspcc-dev/wallet-save-pretty
wallet: export `SavePretty` method
2022-06-09 11:29:21 +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
8bc99aa229
Merge pull request #2546 from nspcc-dev/update-dbft
go.mod: update dbft, pick up recovery message send fix
2022-06-07 16:53:33 +03:00
Roman Khimov
65c8aa7701 go.mod: update dbft, pick up recovery message send fix 2022-06-07 16:40:37 +03:00
Roman Khimov
3d1a80f612
Merge pull request #2541 from nspcc-dev/fim-make-bin
Makefile: alias `build` target as `neo-go`
2022-06-07 16:38:43 +03:00
Anna Shaleva
80a2eb6774 Makefile: add docker/neo-go make target 2022-06-07 15:52:49 +03:00
Anna Shaleva
62e7d964da Makefile: alias build target
Follow the
https://github.com/nspcc-dev/neo-go/pull/2537#issuecomment-1147468063.
2022-06-07 15:32:25 +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