Commit graph

7608 commits

Author SHA1 Message Date
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
72ebcbec72 go.mod: update all external dependencies
Except for github.com/urfave/cli which breaks the CLI if upgraded to v1.22.14.
Refs. #3097.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-03-05 18:38:29 +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
Roman Khimov
49edf9e498
Merge pull request #3336 from nspcc-dev/go-upd
Add Go 1.22 support, drop Go 1.19 support
2024-03-05 15:40:02 +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
5485cf60da Dockerfile: switch to Go 1.22 based images
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-05 13:53:58 +03:00
Anna Shaleva
3f772c2711 workflows: use newer Go 1.22, drop Go 1.19
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-05 11:43:23 +03:00
Anna Shaleva
c660a6e8f3 workflows: remove cache argument from setup-go action
`actions/setup-go@v5` doesn't have `cache` argument.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-05 11:43:23 +03:00
Anna Shaleva
90db72abc9 workflows: upgrade runners
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-05 11:42:53 +03:00
Roman Khimov
8d67f17943
Merge pull request #3332 from nspcc-dev/fix-nep17-test
cli: fix race in TestNEP17Balance
2024-03-03 15:27:25 +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
685d095fa4 cli: fix race in TestNEP17Balance
`wallet1_solo.json` can't be used in this test because it contains
committee member that receives reward for accepted blocks. The race in
this test happens due to the  fact that it uses running blockchain and
checks expected GAS balance via call to blockchain's
GetUtilityTokenBalance API. This call is racy with the CLI command
executed prior to the call which causes the following test failure:
```
2023-04-06T08:44:08.6038406Z === NAME  TestNEP17Balance/all_accounts
2023-04-06T08:44:08.6038738Z     executor.go:240:
2023-04-06T08:44:08.6039454Z         	Error Trace:	/opt/github-runner/_work/neo-go/neo-go/cli/nep_test/executor.go:240
2023-04-06T08:44:08.6040628Z         	            				/opt/github-runner/_work/neo-go/neo-go/cli/nep_test/executor.go:236
2023-04-06T08:44:08.6041787Z         	            				/opt/github-runner/_work/neo-go/neo-go/cli/nep_test/nep17_test.go:73
2023-04-06T08:44:08.6042389Z         	Error:      	Expect "	Amount : 1" to match "^\s*Amount\s*:\s*1.5$"
2023-04-06T08:44:08.6042865Z         	Test:       	TestNEP17Balance/all_accounts
```

The fix is do not use committee accounts for balance checks. Let's use
side accounts and transfer funds to some of them before the test start.
Close #2960.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-01 19:19:02 +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
Roman Khimov
2404145133
Merge pull request #3331 from nspcc-dev/upd-go-ordered-json
go.mod: upgrade go-ordered-json
2024-02-29 13:36:32 +03:00
Anna Shaleva
e1e2b5304f go.mod: upgrade go-ordered-json
Fetch C# node compatibility fixes for the rest of corner cases. Ref.
https://github.com/nspcc-dev/go-ordered-json/pull/11.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-02-29 13:31:06 +03:00
Roman Khimov
9d7357c9fd
Merge pull request #3329 from nspcc-dev/support-rpc-maps 2024-02-28 16:26:29 +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
Anna Shaleva
6a560b9a95
Merge pull request #3330 from nspcc-dev/add-macos
Add ARM-based MacOS tests
2024-02-28 12:39:17 +03:00
Roman Khimov
630bd29b8d workflows: drop manual go mod downloads
It's done automatically since like forever, these steps are useless.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-02-28 12:09:15 +03:00
Roman Khimov
5fcae176b8 workflows: add MacOS 14 runner for tests
It's ARM-based, so it's a very nice combination.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-02-28 12:08:13 +03:00
Roman Khimov
cc38221d77
Merge pull request #3307 from nspcc-dev/test-register-peers
services: fix logging data race after shutdown
2024-02-27 17:09:08 +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
Roman Khimov
224808975b
Merge pull request #3328 from nspcc-dev/mod-upd
.github: use minimum required Go version from go.mod
2024-02-27 14:02:42 +03:00
Anna Shaleva
8ab08c6221 github: reorder actions/checkout and actions/setup-go steps
Otherwise setup-go action won't work with go-version-file. Ref.
https://github.com/actions/setup-go/issues/340.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-02-27 11:56:49 +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
Anna Shaleva
a81804e296 .github: use minimum required Go version from go.mod
For linter job only, port
e0ec4d24cb.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-02-27 11:39:51 +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
Anna Shaleva
be17924ef8
Merge pull request #3325 from stepanovdmitrii/fix/tcp_peer_deadlock
tcp_peer: Fix possible goroutine leak
2024-02-26 12:12:28 +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
Anna Shaleva
327e766cd9
Merge pull request #3321 from nspcc-dev/leveldb-windows
vm: fix exit in vm tests
2024-02-21 19:47:07 +03:00
Ekaterina Pavlova
b6a65e4d80 cli: fix exit in vm test
Add exit function at the end of the test to prevent
errors in t.Cleanup of the t.TempDir for levelDB instance.

Close #3154

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-02-21 13:22:38 +03:00
Anna Shaleva
00a1a8da56
Merge pull request #3320 from nspcc-dev/update-actions
workflows: update actions
2024-02-20 13:16:20 +03:00
Roman Khimov
07b2de73cd workflows: update actions
I'm tired of warnings for our workflow runs.

The only unupdated is Codecov, we can't switch to token-based uploads at the
moment (and it's required for new version).

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-02-19 22:14:24 +03:00
Roman Khimov
f94df6c013
Merge pull request #3318 from nspcc-dev/TestContractInitAndCompile 2024-02-19 21:49:22 +03:00
Ekaterina Pavlova
5128b84e1d *: update go.mod
According to https://go.dev/doc/modules/gomod-ref go version should be
placed before `require` section.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-02-19 19:12:21 +03:00
Ekaterina Pavlova
5d425a6e45 smartcontract: fix go version mismatch in TestContractInitAndCompile
Needs to updated dependencies inside the test for go1.18 and higher to
match with interop module.

Close #3152

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-02-19 19:08:36 +03:00
Anna Shaleva
71fb759c0d
Merge pull request #3313 from nspcc-dev/TestRun_WithNewVMContextAndBreakpoints
config: fix windows paths in VM tests
2024-02-15 11:07:04 +03:00
Ekaterina Pavlova
588e911ad6 config: fix TestRun_WithNewVMContextAndBreakpoints path for windows
Fix VM test for windows. We don't have notary enabled in unit testchains
 so it was removed.

Close #3309

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-02-14 13:22:07 +03:00
Roman Khimov
5fe4778b2e
Merge pull request #3306 from nspcc-dev/test-windows-path
config: fix TestGetConfigFromContext on Windows
2024-02-14 11:24:48 +03:00