Commit graph

5290 commits

Author SHA1 Message Date
Anna Shaleva
335550fb1e rpcsrv: generate randome nonce for RPC server test transactions
Avoid mempool conflicts in tests.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-18 18:03:58 +03:00
Ekaterina Pavlova
0e6fbadfd5 native: clear LastGasPerVote when voting for NULL
Port neo-project/neo#3173.

Close #3345

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-03-15 10:51:32 +03:00
Anna Shaleva
37d4012306 rpcsrv: properly close RPC clients in tests
This commit doesn't fix anything, but clients should be closed, it's
just a good practice.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-14 11:04:39 +03:00
Anna Shaleva
67d39177d8
Merge pull request #3350 from nspcc-dev/tune-rpc-tests
rpcsrv: close idle client connections in doRPCCallOverHTTP
2024-03-14 10:52:35 +03:00
Roman Khimov
86faf7b343 rpcsrv: close idle client connections in doRPCCallOverHTTP
Shouldn't affect things much, yet at the same time we no longer need any
connection after we're done with the request.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-03-13 12:58:15 +03:00
Ekaterina Pavlova
0016b6b630 rpc: add synchronisation for httptest.Server in tests
Add waiting for startSending to ensure that the client is ready before
the server starts sending messages.

Close #3005
Close #3312

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-03-13 11:41:43 +03:00
Ekaterina Pavlova
588d7c6418 rpcsrv: fix concurrent test TestClient_IteratorSessions
The default for `MaxConnsPerHost` is "no limit", so it'll use as many
connections as it can (potentially hitting MacOS/Windows limits
https://github.com/golang/go/issues/20960#issuecomment-447918270 ).

Close #3300

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-03-11 22:00:23 +03:00
Ekaterina Pavlova
ee39b5ca18 rpcsrv: add close of http server in tests
The HTTP server should be closed at the end of the test.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-03-06 01:17:59 +03:00
Ekaterina Pavlova
46f2da0fb1 rpcsrv: add close of blockchain and rpc server in tests
The logs race issue is a result of improper shutdown during testing.

Close #3217

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-03-06 01:17:59 +03:00
Anna Shaleva
a256eac619
Merge pull request #3337 from nspcc-dev/fix-notary-test
notary: fix "Condition never satisfied" in Notary test, fix #2422
2024-03-05 19:11:59 +03:00
Roman Khimov
b2936e602c notary: fix getCompletedTx error
It checks for any transaction given (like fb), not exactly the main one.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-03-05 19:01:03 +03:00
Roman Khimov
d65b1fd66d *: use v2 LRU, fix #3322
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-03-05 18:39:17 +03:00
Roman Khimov
d2a7162217 notary: fix "Condition never satisfied" in Notary test, fix #2422
The theory is:
 * we add a block
 * it triggers notary
 * which can process the fallback before we're to setFinalizeWithError
 * it'll fail and require an additional block to enter, but it's never added
 * FAIL

The solution is:
 * always add an additional block, but treat the first fb specially

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-03-05 18:09:25 +03:00
Anna Shaleva
8162e9033d *: replace slice.Copy with bytes.Clone
And refactor some code a bit, don't use bytes.Clone where type-specific
helpers may be used instead.

Close #2907.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-05 13:54:10 +03:00
Anna Shaleva
b030c331b0 core: copy SC storage iterator prefix while returning values
It's a bug since Prefix is shared between all iterator items and
appending is not enough. If prefix has enough capacity, then new slice
won't be created and the previous item's prefix will be changed.

This commit fixes the following test failure caused by moving from
bytes.Clone to slice.Copy:
```
 --- FAIL: TestComlileAndInvokeFunction/test_Storage.Find (0.02s)
        --- FAIL: TestComlileAndInvokeFunction/test_Storage.Find/keys_only (0.01s)
            contract_test.go:866:
                	Error Trace:	/home/anna/Documents/GitProjects/nspcc-dev/neo-go/cli/smartcontract/contract_test.go:866
                	Error:      	Not equal:
                	            	expected: []stackitem.Item{(*stackitem.ByteArray)(0xc000a1cdf8), (*stackitem.ByteArray)(0xc000a1ce10)}
                	            	actual  : []stackitem.Item{(*stackitem.ByteArray)(0xc000a1cdb0), (*stackitem.ByteArray)(0xc000a1cdc8)}

                	            	Diff:
                	            	--- Expected
                	            	+++ Actual
                	            	@@ -2,3 +2,3 @@
                	            	  (*stackitem.ByteArray)((len=8) {
                	            	-  00000000  66 69 6e 64 6b 65 79 31                           |findkey1|
                	            	+  00000000  66 69 6e 64 6b 65 79 32                           |findkey2|
                	            	  }),
                	Test:       	TestComlileAndInvokeFunction/test_Storage.Find/keys_only
        --- FAIL: TestComlileAndInvokeFunction/test_Storage.Find/both (0.01s)
            contract_test.go:881:
                	Error Trace:	/home/anna/Documents/GitProjects/nspcc-dev/neo-go/cli/smartcontract/contract_test.go:881
                	Error:      	Not equal:
                	            	expected: []stackitem.Item{(*stackitem.ByteArray)(0xc000515920), (*stackitem.ByteArray)(0xc000515938)}
                	            	actual  : []stackitem.Item{(*stackitem.ByteArray)(0xc000515848), (*stackitem.ByteArray)(0xc000515860)}

                	            	Diff:
                	            	--- Expected
                	            	+++ Actual
                	            	@@ -2,3 +2,3 @@
                	            	  (*stackitem.ByteArray)((len=8) {
                	            	-  00000000  66 69 6e 64 6b 65 79 31                           |findkey1|
                	            	+  00000000  66 69 6e 64 6b 65 79 32                           |findkey2|
                	            	  }),
                	Test:       	TestComlileAndInvokeFunction/test_Storage.Find/both
```

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-05 13:54:10 +03:00
Anna Shaleva
1560df6913 *: add nolint comment to deprecated math/rand usages
They are used in tests only.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-05 13:54:10 +03:00
Anna Shaleva
0c6627f13d *: use multierror wrapping where possible
Revert 5f6c01336c, remove all multierror
related nolint comments and use multierror wrapping instead.

Close #2906.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-05 13:54:10 +03:00
Anna Shaleva
13ff95a3d3 go.mod: upgrade minimum required Go version to 1.20
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-05 13:54:10 +03:00
Anna Shaleva
46a3ff3348 *: regenerate all wallets with adjusted parameters
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-01 19:19:03 +03:00
Anna Shaleva
9525bc7785 wallet: fix scrypt parameters in wallet regeneration tests
Default NEP2 scrypt parameters should be overriden where needed,
otherwise our regeneration tests won't generate proper wallets.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-01 19:19:03 +03:00
Anna Shaleva
1f4e1922ee cli: add new testing wallet
It contains several simple signature accounts that are not related to
network committee or validators. Needed for tests, existing
`testwallet.json` can't de reused since some tests need testing wallet
with a single account.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-02-29 23:48:10 +03:00
Anna Shaleva
132531fabe rpcsrv: support Map parameter in invokefunction RPC handler
We have smartcontract.ParameterPair structure that can be properly
marshalled and passed to RPC server as an element of smartcontract.Map
structure. However, RPC server can't unmarshal map values properly
without this change.

This change is compatible with C# node.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-02-28 15:54:33 +03:00
Ekaterina Pavlova
5cf0c75744 network: fix server shutdown by waiting for goroutines to finish
s.Shutdown() does not wait for all goroutines of the node server to
finish normally just because the server exits without dependent
goroutines awaiting. Which causes logs to attempt to write after the
test has ended. The consequence of this bug fix is that corresponding
tests are fixed.

Close #2973
Close #2974

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-02-27 15:10:51 +03:00
Ekaterina Pavlova
5bb7c6b715 services: update logs flush after services shutdown
Added sync logs for every service separately to provide the ability to
have a custom logger for each service. This commit makes the code follow
the zap usages rules: `Sync calls the underlying Core's Sync method,
flushing any buffered log entries. Applications should take care to
call Sync before exiting.`

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-02-27 15:10:51 +03:00
Ekaterina Pavlova
9b540770cd network: fix typo
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-02-27 15:10:51 +03:00
Ekaterina Pavlova
775c56e87e network: ensure server is started and shut down only once
Use started atomic.Bool field to ensure that the node server shutdown
procedure is executed only once. Prevent the following panic caused by
server double-shutdown in testing code:
```
--- FAIL: TestServerRegisterPeer (0
.06s)
 panic: closed twice
 goroutine 60 [running]:
 testing.tRunner.func1.2({0x104c40b20, 0x104d0ec90})
 	/opt/homebrew/opt/go/libexec/src/testing/testing.go:1545 +0x1c8
 testing.tRunner.func1()
 	/opt/homebrew/opt/go/libexec/src/testing/testing.go:1548 +0x360
 panic({0x104c40b20?, 0x104d0ec90?})
 	/opt/homebrew/opt/go/libexec/src/runtime/panic.go:914 +0x218
 github.com/nspcc-dev/neo-go/pkg/network.(*fakeTransp).Close
 (0x14000159e08?)
 	/Users/ekaterinapavlova/Workplace/neo-go/pkg/network
 	/discovery_test.go:83 +0x54
 github.com/nspcc-dev/neo-go/pkg/network.(*Server).Shutdown
 (0x14000343400)
 	/Users/ekaterinapavlova/Workplace/neo-go/pkg/network/server.go:299
 	 +0x104
 github.com/nspcc-dev/neo-go/pkg/network.startWithCleanup.func1()
 	/Users/ekaterinapavlova/Workplace/neo-go/pkg/network/server_test
 	.go:408 +0x20
 testing.(*common).Cleanup.func1()
 	/opt/homebrew/opt/go/libexec/src/testing/testing.go:1169 +0x110
 testing.(*common).runCleanup(0x1400032c340, 0x14000159d80?)
 	/opt/homebrew/opt/go/libexec/src/testing/testing.go:1347 +0xd8
 testing.tRunner.func2()
 	/opt/homebrew/opt/go/libexec/src/testing/testing.go:1589 +0x2c
 testing.tRunner(0x1400032c340, 0x104d0c5d0)
 	/opt/homebrew/opt/go/libexec/src/testing/testing.go:1601 +0x114
 created by testing.(*T).Run in goroutine 1
 	/opt/homebrew/opt/go/libexec/src/testing/testing.go:1648 +0x33c
```

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-02-27 15:10:51 +03:00
Ekaterina Pavlova
4715e523e0 services: move blockchain/mempool subscriptions to separate routine
Start of some services is bound to blockchain subscriptions, and thus,
can't be run before the blockchain notifications dispatcher.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-02-27 15:10:51 +03:00
Ekaterina Pavlova
f8dc5ec44f network: change server Start() behavior
Previously user should Start server in a separate goroutine. Now
separate goroutine is created inside the Start(). For normal server
operation, the caller should wait for Start to finish. Also, fixed
TestTryInitStateSync test which was exiting earlier than logs are
called.

Close #3112

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-02-27 15:10:51 +03:00
Anna Shaleva
e55809f198
Merge pull request #3327 from nspcc-dev/fix-rpcclient-doc
rpcclient: fix address used in doc
2024-02-27 11:43:42 +03:00
Roman Khimov
9d3258495f rpcclient: use better RPC endpoint for example
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-02-26 23:18:45 +03:00
Roman Khimov
e09fc00188 rpcclient: fix address used in doc
This one doesn't really work now, it's Legacy. Replace with something N3-ish.

Thanks @lock9 for reporting.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-02-26 22:18:32 +03:00
Dmitrii Stepanov
6147bf452a tcp_peer: Fix possible goroutine leak
Scenario:
1. Two messages were read from the connection `p.conn`
2. The first message has started to be processed
3. The second message was queued to be added to the channel `p.incoming`
4. Processing of the first message failed with an error
5. TCP peer is closed, but processing of the second message continues

Signed-off-by: Dmitrii Stepanov <dima-stepan@yandex.ru>
2024-02-25 22:38:18 +03:00
Roman Khimov
51ac153a7b
Merge pull request #3293 from nspcc-dev/import-multisig
cli: update import-multisig with making --wif optional
2024-01-27 11:26:47 +03:00
Ekaterina Pavlova
57aa05add3 wallet: make --wif optional in import-multisig command
We have a full list of public keys in the import-multisig command, so if
 we have a key in the wallet that corresponds to one of these keys
 (simple sig), just reuse it for the account automatically

Closes #3266

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-01-26 18:36:29 +03:00
Ekaterina Pavlova
000109bfd1 smartcontract: update nns wrapper
Added missing function from smart-contract manifest.

Close #2732

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-01-26 18:30:17 +03:00
Anna Shaleva
36b89215ab
Merge pull request #3299 from nspcc-dev/autogeneration-linter
smartcontract: fix generation of nns wrapper for follow Go naming
2024-01-26 12:50:35 +03:00
Anna Shaleva
161b83fd7f rpcclient: ensure nns.RecordType can be passed as a parameter to invoker
Implement smartcontract.Convertible for nns.RecordType.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-01-25 17:04:21 +03:00
Ekaterina Pavlova
9b7eff18c0 smartcontract: fix generation of nns wrapper for follow Go naming
Autogenerated RPC wrapper used underscores to differentiate between
methods/event overloads. Now it adds increasing suffices instead.

Close #3296

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-01-24 16:21:36 +03:00
Anna Shaleva
a22a7177e3 smartcontract: improve TestParameterFromValue
Run error cases in the same loop with test cases. No functional changes.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-01-23 16:09:58 +03:00
Anna Shaleva
b90c0ece87 smartcontract: introduce Convertible interface
Allow to pass Convertible to NewParameterFromValue. Close #3285.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-01-23 16:09:57 +03:00
Ekaterina Pavlova
5f745dff72 config: update validation with check committee
ProtocolConfiguration section must include stand by committee and the
number of validators or committee/validators history.

Close #3247

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-01-22 10:25:23 +03:00
Roman Khimov
d428cfc4f1
Merge pull request #3290 from nspcc-dev/ntr-log
services: improve notary service logging
2024-01-12 13:23:00 +03:00
Anna Shaleva
32fab1adf1
Merge pull request #3286 from nspcc-dev/quotes
Upgrade go-ordered-json version
2024-01-12 14:30:12 +05:00
Anna Shaleva
2c0c111fd5
Merge pull request #3287 from nspcc-dev/additional-networking-debugs
Additional networking debugs
2024-01-12 14:29:18 +05:00
Anna Shaleva
ef9f75547a services: improve notary service logging
Let the user know whether it's main or fallback transaction that failed
to be relayed to the network.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-01-12 12:25:11 +03:00
Roman Khimov
f9a82ae45f network: add debug for transactions as well
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-01-12 12:18:06 +03:00
Roman Khimov
db2e214f7e network: add debug for notary payloads
Can be handy if things go wrong.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-01-12 12:18:06 +03:00
Ekaterina Pavlova
baac738ec3 smartcontract: add test of extraToStackItem with double quotes
C# double quotes marshalling compatibility test.

Refs #3284

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-01-12 11:18:24 +03:00
Anna Shaleva
f5b1bd3978 waiter: adopt headers subscription for WS-based tx awaiting
Try to subscribe for headers firstly, and then if RPC server doesn't
have this ability, fallback to block subscriptions to manage transaction
awaiting.

Close #3260.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-12-29 16:00:56 +03:00
Anna Shaleva
7c9b1d05d2 rpcclient: refactor waiter package naming
Adjust names of all used structures, no need to duplicate `Waiter` everywhere,
we already in the `waiter` package. Also, adjust comments to Actor so that links
to Waiter are properly described in docs.

Ref. #3265.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-12-29 15:22:50 +03:00