Anna Shaleva
84b00d46aa
rpc: emit Null in case of Any
parameter with zero-len value
...
Otherwise it leads to the following error in the TestActor_CallWithNilParam:
```
=== RUN TestActor_CallWithNilParam
logger.go:130: 2023-04-03T15:58:27.672+0300 INFO initial gas supply is not set or wrong, setting default value {"InitialGASSupply": "52000000"}
logger.go:130: 2023-04-03T15:58:27.672+0300 INFO P2PNotaryRequestPayloadPool size is not set or wrong, setting default value {"P2PNotaryRequestPayloadPoolSize": 1000}
logger.go:130: 2023-04-03T15:58:27.672+0300 INFO MaxBlockSize is not set or wrong, setting default value {"MaxBlockSize": 262144}
logger.go:130: 2023-04-03T15:58:27.672+0300 INFO MaxBlockSystemFee is not set or wrong, setting default value {"MaxBlockSystemFee": 900000000000}
logger.go:130: 2023-04-03T15:58:27.672+0300 INFO MaxTransactionsPerBlock is not set or wrong, using default value {"MaxTransactionsPerBlock": 512}
logger.go:130: 2023-04-03T15:58:27.672+0300 INFO MaxValidUntilBlockIncrement is not set or wrong, using default value {"MaxValidUntilBlockIncrement": 5760}
logger.go:130: 2023-04-03T15:58:27.675+0300 INFO no storage version found! creating genesis block
logger.go:130: 2023-04-03T15:58:27.675+0300 INFO ExtensiblePoolSize is not set or wrong, using default value {"ExtensiblePoolSize": 20}
logger.go:130: 2023-04-03T15:58:27.675+0300 INFO SessionPoolSize is not set or wrong, setting default value {"SessionPoolSize": 20}
logger.go:130: 2023-04-03T15:58:27.675+0300 INFO MaxWebSocketClients is not set or wrong, setting default value {"MaxWebSocketClients": 64}
logger.go:130: 2023-04-03T15:58:27.675+0300 INFO starting rpc-server {"endpoint": "localhost:0"}
logger.go:130: 2023-04-03T15:58:27.677+0300 DEBUG done processing headers {"headerIndex": 1, "blockHeight": 0, "took": "436.313µs"}
logger.go:130: 2023-04-03T15:58:27.679+0300 DEBUG done processing headers {"headerIndex": 2, "blockHeight": 1, "took": "272.891µs"}
logger.go:130: 2023-04-03T15:58:27.680+0300 DEBUG done processing headers {"headerIndex": 3, "blockHeight": 2, "took": "276.949µs"}
logger.go:130: 2023-04-03T15:58:27.681+0300 DEBUG done processing headers {"headerIndex": 4, "blockHeight": 3, "took": "286.028µs"}
logger.go:130: 2023-04-03T15:58:27.681+0300 DEBUG done processing headers {"headerIndex": 5, "blockHeight": 4, "took": "268.673µs"}
logger.go:130: 2023-04-03T15:58:27.681+0300 INFO bad notification {"contract": "565cff9508ebc75aadd7fe59f38dac610ab6093c", "event": "Transfer", "error": "parameter 0 type mismatch: Hash160 vs ByteString"}
logger.go:130: 2023-04-03T15:58:27.682+0300 DEBUG done processing headers {"headerIndex": 6, "blockHeight": 5, "took": "380.988µs"}
logger.go:130: 2023-04-03T15:58:27.683+0300 DEBUG done processing headers {"headerIndex": 7, "blockHeight": 6, "took": "273.543µs"}
logger.go:130: 2023-04-03T15:58:27.683+0300 DEBUG done processing headers {"headerIndex": 8, "blockHeight": 7, "took": "275.163µs"}
logger.go:130: 2023-04-03T15:58:27.684+0300 DEBUG done processing headers {"headerIndex": 9, "blockHeight": 8, "took": "259.578µs"}
logger.go:130: 2023-04-03T15:58:27.685+0300 DEBUG done processing headers {"headerIndex": 10, "blockHeight": 9, "took": "266.882µs"}
logger.go:130: 2023-04-03T15:58:27.686+0300 DEBUG done processing headers {"headerIndex": 11, "blockHeight": 10, "took": "295.3µs"}
logger.go:130: 2023-04-03T15:58:27.687+0300 DEBUG done processing headers {"headerIndex": 12, "blockHeight": 11, "took": "295.568µs"}
logger.go:130: 2023-04-03T15:58:27.688+0300 DEBUG done processing headers {"headerIndex": 13, "blockHeight": 12, "took": "258.197µs"}
logger.go:130: 2023-04-03T15:58:27.689+0300 DEBUG done processing headers {"headerIndex": 14, "blockHeight": 13, "took": "261.602µs"}
logger.go:130: 2023-04-03T15:58:27.689+0300 DEBUG done processing headers {"headerIndex": 15, "blockHeight": 14, "took": "268.922µs"}
logger.go:130: 2023-04-03T15:58:27.690+0300 DEBUG done processing headers {"headerIndex": 16, "blockHeight": 15, "took": "276.176µs"}
logger.go:130: 2023-04-03T15:58:27.691+0300 DEBUG done processing headers {"headerIndex": 17, "blockHeight": 16, "took": "256.068µs"}
logger.go:130: 2023-04-03T15:58:27.692+0300 DEBUG done processing headers {"headerIndex": 18, "blockHeight": 17, "took": "262.303µs"}
logger.go:130: 2023-04-03T15:58:27.692+0300 DEBUG done processing headers {"headerIndex": 19, "blockHeight": 18, "took": "265.087µs"}
logger.go:130: 2023-04-03T15:58:27.693+0300 DEBUG done processing headers {"headerIndex": 20, "blockHeight": 19, "took": "260.758µs"}
logger.go:130: 2023-04-03T15:58:27.694+0300 DEBUG done processing headers {"headerIndex": 21, "blockHeight": 20, "took": "263.482µs"}
logger.go:130: 2023-04-03T15:58:27.694+0300 DEBUG done processing headers {"headerIndex": 22, "blockHeight": 21, "took": "327.812µs"}
logger.go:130: 2023-04-03T15:58:27.696+0300 DEBUG done processing headers {"headerIndex": 23, "blockHeight": 22, "took": "284.104µs"}
logger.go:130: 2023-04-03T15:58:27.697+0300 WARN contract invocation failed {"tx": "82279bfe9bada282ca0f8cb8e0bb124b921af36f00c69a518320322c6f4fef60", "block": 23, "error": "at instruction 0 (ABORT): ABORT"}
logger.go:130: 2023-04-03T15:58:27.697+0300 DEBUG processing rpc request {"method": "getversion", "params": "[]"}
logger.go:130: 2023-04-03T15:58:27.698+0300 DEBUG processing rpc request {"method": "invokefunction", "params": "[565cff9508ebc75aadd7fe59f38dac610ab6093c putValue ]"}
client_test.go:2562:
Error Trace: /home/anna/Documents/GitProjects/nspcc-dev/neo-go/pkg/services/rpcsrv/client_test.go:2562
Error: Should be true
Test: TestActor_CallWithNilParam
Messages: at instruction 6 (PACK): OPACK: invalid length
logger.go:130: 2023-04-03T15:58:27.699+0300 INFO shutting down RPC server {"endpoint": "127.0.0.1:46005"}
logger.go:130: 2023-04-03T15:58:27.700+0300 INFO persisted to disk {"blocks": 23, "keys": 1236, "headerHeight": 23, "blockHeight": 23, "took": "908.825µs"}
--- FAIL: TestActor_CallWithNilParam (0.03s)
FAIL
```
See also the ref. df534f6b0c/src/Neo/SmartContract/ContractParameter.cs (L141)
and the way how parameters are handled by ref. RPC server:
4b3a76e1b7/src/RpcServer/RpcServer.SmartContract.cs (L202)
and FromJSON implementation:
df534f6b0c/src/Neo/SmartContract/ContractParameter.cs (L70)
2023-06-29 11:51:40 +03:00
Roman Khimov
0d5613cfcb
Merge pull request #2938 from nspcc-dev/failing-actor-test
...
actor: don't close already closed channel, fix #2932
2023-03-17 11:46:31 +03:00
Roman Khimov
da7eafd4c7
Merge pull request #2937 from nspcc-dev/copy-wsclient-filters
...
Copy wsclient filters
2023-03-17 10:49:13 +03:00
Roman Khimov
e197f3faef
rpcclient: copy subscription params, fix #2890
...
Clients can change things and we better be safe here.
2023-03-17 10:33:30 +03:00
Roman Khimov
e84ea0207d
actor: don't close already closed channel, fix #2932
...
Waiter should close its channels, but WSClient can also do that and it can do
that in a drain loop as well.
2023-03-17 09:57:41 +03:00
Roman Khimov
1a4da8c462
neorpc: add Copy to filters for easy deep copying
2023-03-16 23:43:00 +03:00
Roman Khimov
74623e64bc
rpcclient: improve wsclient doc, fix #2895
2023-03-16 21:27:35 +03:00
Roman Khimov
44e84a5943
stateroot: fix spelling and enhance FindStates doc, fix #2925
2023-03-15 22:55:19 +03:00
Anna Shaleva
c7566c2a01
consensus: perform batched chain's block sync
...
If there are several blocks from chain, then initialize consensus only for the
latest one.
2023-03-15 17:45:56 +03:00
Anna Shaleva
0b352349eb
consensus: adjust TestService_NextConsensus after dBFT upgrade
2023-03-15 17:37:47 +03:00
Anna Shaleva
0cbef58b3c
consensus: enqueue newly created blocks
...
Do not add them directly to chain, it will be done by the block queue
manager. Close https://github.com/nspcc-dev/neo-go/issues/2923 . However,
this commit is not valid without
https://github.com/roman-khimov/dbft/pull/4 .
It's the neo-go's duty to initialize consensus after subsequent block
addition; the dBFT itself must wait for the neo-go to complete the block
addition and notify the dBFT, so that it can initialize at 0-th view to
collect the next block.
2023-03-15 17:37:47 +03:00
Anna Shaleva
04d0b45ceb
network: move blockqueue to a separate package
2023-03-15 17:37:47 +03:00
Anna Shaleva
91a77c25a2
network: refactor blockqueuer interface
...
Remove unused argument.
2023-03-15 17:37:47 +03:00
Anna Shaleva
e57e74692f
consensus: drain block notification channel after each message
...
Make blockchain lock less possible.
2023-03-15 17:37:47 +03:00
Anna Shaleva
ea46943815
services: use buffered channels for block subscription
...
Add a tiny buffer where possible to avoid Blockchain's blocking
on new block addition.
2023-03-15 17:37:47 +03:00
Anna Shaleva
5f6c01336c
*: add nolint comments to multiple errors wrapping
...
To be enabled after go 1.20 support is added.
2023-03-15 16:38:01 +03:00
Roman Khimov
4f708c037d
network: drain send queues on peer disconnection
...
Fix potential memory leak with a lot of connected clients that keep requesting
things from node and then disconnect.
2023-02-21 16:19:06 +03:00
Anna Shaleva
da757fa387
network: fix grammar typo in the error message
2023-02-20 11:08:07 +03:00
Roman Khimov
475d9de2d5
Merge pull request #2916 from nspcc-dev/not-so-local-client
...
Not so local RPC client
2023-02-20 10:38:30 +03:00
Roman Khimov
d54418bad0
Merge pull request #2920 from nspcc-dev/fix-seek-doc
...
core: adjust the documentation of SeekRange's Prefix field
2023-02-18 23:18:39 +03:00
Anna Shaleva
09186127da
core: adjust the documentation of SeekRange's Prefix field
...
It is used in different context (seeking through the storage or
through the contract storage), and sometimes empty prefix is not
supported.
2023-02-18 21:06:30 +03:00
Roman Khimov
b1e7f40226
rpcbinding: fix wrappers for Any type, fix #2898
2023-02-18 00:06:45 +03:00
Roman Khimov
bd4a9f3f22
rpcsrv: drop ws from subscriber
...
Subscribers can be local as well and no one uses this field anyway.
2023-02-16 23:49:58 +03:00
Roman Khimov
6f7fed344b
rpcclient: add Internal client for direct RPC server calls
...
It has a special `requestF` and a special initialization function, but other
than that it's an absolutely regular WSClient. Can be used to call, can be
used to subscribe. Fixes #2909 .
2023-02-16 23:49:58 +03:00
Roman Khimov
a55a01d456
rpcsrv: provide RegisterLocal for local clients
...
This allows to call RPC server more effectively in the same process (bypassing
TCP/HTTP). Refs. #2909 .
2023-02-16 23:49:58 +03:00
Roman Khimov
e496084bee
params: add FromAny function
...
Creating RPC server parameters from any data can be useful. Refs. #2909 .
2023-02-15 16:46:59 +03:00
Erik van den Brink
3bdb3a87b8
rpcclient: expose endpoint ( fixes #2912 )
2023-02-15 08:29:44 +01:00
Anna Shaleva
25ed5fcd60
vm: allow custom limit duing Map\Array\Struct deserialization
2023-02-08 10:58:55 +03:00
Anna Shaleva
15fa65d30f
vm: export stackitem's deserContext
2023-02-08 10:58:54 +03:00
Anna Shaleva
51a28fac8d
rpcclient: adjust new subscriptions API doc
...
Add a warning about consequences of unproper notifications reading.
Ref. https://github.com/morphbits/neofs-cdn-edge-manager/pull/88#discussion_r1088007680 .
2023-01-30 14:36:11 +03:00
Leonard Lyubich
d09158161e
services/rpcsrv: Strengthen Server
error channel's type
...
According to docs, `Server` uses provided error channel only to write
encountered error to it. In this case, there is no need to accept rw
channel to create `Server` instance. Strengthening the type to
write-only will allow the caller to ensure control of reading errors
from the provided channel.
The change is backward compatible since any `chan` is `chan<-`.
Signed-off-by: Leonard Lyubich <ctulhurider@gmail.com>
2023-01-23 10:33:46 +03:00
Leonard Lyubich
cbdc6ba469
rpcclient/actor: Document RPCActor.CalculateNetworkFee
method
...
`Actor.MakeUnsignedUncheckedRun` method imposes restriction to
`CalculateNetworkFee` method's implementations: `Hash` or `Size` methods
must not be called on the pointer to the given transaction.
Add docs to adjust described requirement.
Signed-off-by: Leonard Lyubich <ctulhurider@gmail.com>
2023-01-17 21:28:20 +03:00
Anna Shaleva
28927228f0
*: adjust subscription-related doc
...
Add a warning about received events modification where applicable.
2023-01-17 17:11:19 +03:00
Roman Khimov
40ef567527
Merge pull request #2872 from nspcc-dev/fix-missing-exception-in-applog
...
state: always marshal applog exception into JSON, fix #2869
2023-01-12 12:49:00 +07:00
Roman Khimov
babc44bfb3
Merge pull request #2871 from nspcc-dev/fix-shadowed-infinite-loop
...
Fix shadowed infinite loop
2023-01-12 12:48:39 +07:00
Roman Khimov
9a6fa84f70
Merge pull request #2867 from nspcc-dev/store-magic-in-db
...
core: store magic in the DB version, fix #2847
2023-01-11 20:42:00 +07:00
Roman Khimov
4e23695441
Merge pull request #2866 from nspcc-dev/findstates-ret-nothing
...
Fix findstates response difference
2023-01-11 20:41:10 +07:00
Roman Khimov
817f64f9fe
state: always marshal applog exception into JSON, fix #2869
...
Fortunately, this is backwards-compatible in any direction. See
98b5e2b353
also.
2023-01-11 16:36:41 +03:00
Roman Khimov
8305389852
compiler: don't panic, return error for strange range loops
...
See #2870 .
2023-01-11 16:21:40 +03:00
Roman Khimov
92acc71c80
compiler: create new locals for range loops when needed, fix #2855
2023-01-11 15:49:10 +03:00
Roman Khimov
1c4c783c3a
core: store magic in the DB version, fix #2847
2023-01-11 12:05:05 +03:00
Roman Khimov
e780037cb4
rpcsrv: use valid stateroot hash in failing tests
...
Just in case.
2023-01-11 11:23:47 +03:00
Roman Khimov
9718602ce3
rpcsrv: return empty set from findstates when there is no data
...
Fix #2863 .
2023-01-11 11:21:58 +03:00
Roman Khimov
584675ec23
state: optimize NEP17Transfer struct
...
We have both from and to here, so technically we can either drop the neg/neg
trick from the processTokenTransfer() or drop one field from the structure
(the other side is a part of the key). Drop the field since this can make the
DB a bit more compact. Change Amount to be a pointer along the way since
that's the "native" thing for big.Int, we've used non-pointer field
specifically to avoid Neg/Neg problems, but it looks like this is not
necessary.
This structure is only used by the RPC server and I doubt anyone uses it via
the *Blockchain.
2023-01-10 22:51:45 +03:00
Roman Khimov
dfd4f6978f
bigint: don't reallocate big.Int in ToBytes(), fix #2864
...
In some cases n.Add() can reuse the []Word buffer and n.Sub() reallocate it
away. If that happens, we're out of luck with 0.99.0+ versions (since
3945e81857
). I'm not sure why it does that, bit
width doesn't change in most of the cases and even if it does, we still have
enough of it in cap() to hold the old Abs() value (when we have a negative
value we in fact decreate its Abs() first and increase it back
afterwards). Still, that's what we have.
So when we have processTokenTransfer() doing Neg/Neg in-place its value is not
affected, but the original []Word bits that are reused by amount value are
(they're shared initially, Amount: *amount).
name old time/op new time/op delta
ToPreallocatedBytes-8 65.8ns ± 2% 45.6ns ± 2% -30.73% (p=0.008 n=5+5)
name old alloc/op new alloc/op delta
ToPreallocatedBytes-8 0.00B 0.00B ~ (all equal)
name old allocs/op new allocs/op delta
ToPreallocatedBytes-8 0.00 0.00 ~ (all equal)
2023-01-10 22:51:45 +03:00
Roman Khimov
4e6ce9c3e6
Merge pull request #2846 from nspcc-dev/fix-getblockbyindex-req
...
network: do not allow to request invalid block count
2022-12-29 04:04:01 +07:00
Anna Shaleva
9b364aa7ee
network: do not allow to request invalid block count
...
The problem is in peer disconnection due to invalid GetBlockByIndex
payload (the logs are from some patched neo-go version):
```
дек 15 16:02:39 glagoli neo-go[928530]: 2022-12-15T16:02:39.490Z INFO new peer connected {"addr": "10.78.69.115:50846", "peerCount": 3}
дек 15 16:02:39 glagoli neo-go[928530]: 2022-12-15T16:02:39.490Z WARN peer disconnected {"addr": "10.78.69.115:50846", "error": "invalid block count", "peerCount": 2}
дек 15 16:02:39 glagoli neo-go[928530]: 2022-12-15T16:02:39.490Z INFO started protocol {"addr": "10.78.69.115:50846", "userAgent": "/NEO-GO:1.0.0/", "startHeight": 0, "id": 1339571820}
дек 15 16:02:39 glagoli neo-go[928530]: 2022-12-15T16:02:39.491Z INFO new peer connected {"addr": "10.78.69.115:50856", "peerCount": 3}
дек 15 16:02:39 glagoli neo-go[928530]: 2022-12-15T16:02:39.492Z WARN peer disconnected {"addr": "10.78.69.115:50856", "error": "invalid block count", "peerCount": 2}
дек 15 16:02:39 glagoli neo-go[928530]: 2022-12-15T16:02:39.492Z INFO started protocol {"addr": "10.78.69.115:50856", "userAgent": "/NEO-GO:1.0.0/", "startHeight": 0, "id": 1339571820}
дек 15 16:02:39 glagoli neo-go[928530]: 2022-12-15T16:02:39.492Z INFO new peer connected {"addr": "10.78.69.115:50858", "peerCount": 3}
дек 15 16:02:39 glagoli neo-go[928530]: 2022-12-15T16:02:39.493Z INFO started protocol {"addr": "10.78.69.115:50858", "userAgent": "/NEO-GO:1.0.0/", "startHeight": 0, "id": 1339571820}
дек 15 16:02:39 glagoli neo-go[928530]: 2022-12-15T16:02:39.493Z WARN peer disconnected {"addr": "10.78.69.115:50858", "error": "invalid block count", "peerCount": 2}
дек 15 16:02:39 glagoli neo-go[928530]: 2022-12-15T16:02:39.494Z INFO new peer connected {"addr": "10.78.69.115:50874", "peerCount": 3}
дек 15 16:02:39 glagoli neo-go[928530]: 2022-12-15T16:02:39.494Z INFO started protocol {"addr": "10.78.69.115:50874", "userAgent": "/NEO-GO:1.0.0/", "startHeight": 0, "id": 1339571820}
дек 15 16:02:39 glagoli neo-go[928530]: 2022-12-15T16:02:39.494Z WARN peer disconnected {"addr": "10.78.69.115:50874", "error": "invalid block count", "peerCount": 2}
```
GetBlockByIndex payload can't be decoded, and the only possible cause
is zero (or <-1, but it's probably not the case) block count requested.
Error is improved as far.
2022-12-28 13:04:56 +03:00
Anna Shaleva
c0a453a53b
network: adjust requestBlocs logic
...
If the lastQueued block index is the same as the one we'd like to
request in payload, then we need to increment the payload's count.
2022-12-28 12:50:30 +03:00
Evgeniy Stratonikov
db977ce38d
vm: add fuzz test for ParseMultiSigContract
...
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-12-28 11:50:15 +03:00
Evgeniy Stratonikov
affe1ecb4f
encoding: add bigint fuzz test
...
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-12-28 11:50:13 +03:00