Commit graph

7967 commits

Author SHA1 Message Date
Roman Khimov
a0553f740d statesync: simplify Pool management code
* use slices.BinarySearchFunc with its boolean status
* use slices.Insert/slices.Delete, tnis can be a little less efficient, but it
  frees the memory faster and this code is more I/O (networking) bound to care
  about 1-3%

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 12:29:44 +03:00
Roman Khimov
5431b31d84 core: fix extensible sender check
Looks like it was wrong since 9592f3e052 because
sort.Search can return an index that is not equal to the target.
slices.BinarySearchFunc can do that too, but it also return a very convenient
boolean status that can be used.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 12:29:44 +03:00
Roman Khimov
74acfe5288 network: rework insertion into sorting in tryInitStateSync
Overall this'd be less operations and less allocations.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 12:29:44 +03:00
Roman Khimov
49438798b5 manifest: deduplicate duplicate-checking code
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
db820cb0dc manifest: rework method duplicate check
Don't use an additional type, it's inconvenient and this method is not
performance-critical.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
7f1690a840 manifest: use slices.SortFunc, deduplicate PermissionDesc code
Simplify Less and Equals, fix Equals as well for PermissionWildcard (it was
reporting false erroneously).

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
e0cf47e6d0 consensus: don't do useless key sorting
They're already sorted out of smartcontract.CreateMultiSigRedeemScript().

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
32e3310205 smartcontract: improve CreateMultiSigRedeemScript documentation
It was always like that, but this important aspect was never documented.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
de665b5567 *: use slices.Sort() where appropriate
It's always faster for simple types.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
d40ccb3e57 util: add Compare to Uint160
It's useful for slices-based sorting/finding.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
dda3d8b284 mempool: add some comments on potential slices.* use
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
a30792dbb6 *: use slices.Index/slices.Contains where appropriate
This doesn't touch performance-sensitive parts, but simplifies a lot of code.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
9cce148d83 *: use maps.Equal/slices.Equal where appropriate
Testing for equality has never been easier.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
93ecd61079 stackitem: microoptimize memory management of Make()
Preallocate as much as needed.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
e8a86e617b transaction: microoptimize multiattribute check
We can't have more than 256 attribute types, so allocate and use 32 bytes
instead of a whole map.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
f15a163cdf rpcsrv: deduplicate RunForErrors code
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
d22bdd8369 rpcsrv: microoptimize result allocation
We know the size.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
aefd0da181 payload: deduplicate test code slightly
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-24 22:41:48 +03:00
Roman Khimov
35d5495d39 wallet: simplify signature handling
Don't use an additional buffer, drop one branch.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-24 22:41:48 +03:00
Roman Khimov
9e112fc024 *: use slices.Clone instead of make/copy
It's much easier this way.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-24 22:41:48 +03:00
Roman Khimov
7243754a0d *: drop open-coded slice reversing
Less code, same performance.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-24 22:41:48 +03:00
Roman Khimov
c7b623cc38 *: drop pkg/util/slice, use slices.Reverse
This also removes bigint.FromBytesUnsigned(), it's not used very often and
it's somewhat misleading in the bigint package (which is supposed to use a
very specific enconding).

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-24 22:41:48 +03:00
Roman Khimov
963e22ea95 *: replace slice.Clean() with clear()
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-24 22:41:48 +03:00
Roman Khimov
d9ee31fb52 *: use clear() to clear maps
Supposedly more efficient since we can avoid some memory management dances.

Memory pool agrees:

goos: linux
goarch: amd64
pkg: github.com/nspcc-dev/neo-go/pkg/core/mempool
cpu: AMD Ryzen 7 PRO 7840U w/ Radeon 780M Graphics
                       │  pool.old   │              pool.new               │
                       │   sec/op    │   sec/op     vs base                │
Pool/one,_incr_fee-16    12.44m ± 1%   12.51m ± 1%   +0.55% (p=0.029 n=10)
Pool/many,_same_fee-16   4.960m ± 2%   3.100m ± 1%  -37.50% (p=0.000 n=10)
Pool/many,_incr_fee-16   16.03m ± 2%   14.11m ± 1%  -12.00% (p=0.000 n=10)
Pool/one,_same_fee-16                  1.742m ± 1%
geomean                  9.964m        5.556m       -17.92%

                       │    pool.old     │                pool.new                │
                       │      B/op       │      B/op       vs base                │
Pool/one,_incr_fee-16     8.117Ki ± 120%   7.101Ki ± 128%  -12.52% (p=0.022 n=10)
Pool/many,_same_fee-16   3941.2Ki ±   0%   805.4Ki ±   0%  -79.56% (p=0.000 n=10)
Pool/many,_incr_fee-16   3936.2Ki ±   0%   829.8Ki ±   0%  -78.92% (p=0.000 n=10)
Pool/one,_same_fee-16                      12.98Ki ±  10%
geomean                   501.2Ki          88.59Ki         -66.47%

                       │   pool.old   │               pool.new               │
                       │  allocs/op   │  allocs/op    vs base                │
Pool/one,_incr_fee-16     28.00 ± 21%    24.00 ± 21%  -14.29% (p=0.002 n=10)
Pool/many,_same_fee-16   40.38k ±  0%   40.03k ±  0%   -0.86% (p=0.000 n=10)
Pool/many,_incr_fee-16   40.38k ±  0%   40.04k ±  0%   -0.85% (p=0.000 n=10)
Pool/one,_same_fee-16                    23.00 ±  4%
geomean                  3.574k          969.8         -5.55%

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-24 22:41:48 +03:00
Roman Khimov
c2a374541f mempool: add a simple benchmark
Can't believe we never had any in code.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-24 22:41:05 +03:00
Roman Khimov
1c1d77c9b8 *: make use of min/max where appropriate
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-23 22:11:29 +03:00
Roman Khimov
f21edef43b *: bump min Go to 1.21, use 1.23 by default
Fixes #3089.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-23 19:11:06 +03:00
Anna Shaleva
dc6c195637
Merge pull request #3462 from NeoGoBros/add-coverage-support
Add initial coverage support to neotest
2024-08-21 11:40:16 +03:00
Roman Khimov
dfd4566a04
Merge pull request #3556 from nspcc-dev/adjust-waiter
Make PollingBased waiter more flexible
2024-08-20 12:32:51 +03:00
Anna Shaleva
42555668da rpcclient: add Waiter.Config
Include Waiter.PollConfig into Waiter.Config and use extended Waiter
configuration where needed.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-08-20 10:13:20 +03:00
Anna Shaleva
92c6361be8 rpcclient: integrate customizable Waiter with Actor
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-08-20 10:13:20 +03:00
Anna Shaleva
afbb51e78c rpcsrv: add test for Waiter constructor
Ensure that WSClient-based Actor is able to create EventBased waiter.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-08-20 10:13:20 +03:00
Anna Shaleva
027d726b65 rpcclient: allow to tune PollingBased waiter
Some clients need more flexible awaiting options (e.g. for short-blocks
networks). The default behaviour is not changed, all exported APIs are
compatible. Ref. https://github.com/nspcc-dev/neofs-node/issues/2864.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-08-20 10:13:19 +03:00
Anna Shaleva
3e3991cef8 rpcclient: remove default PolingBased poll interval
pollTime is never 0 since MillisecondsPerBlock protocol configuration value
is present in `getversion` RPC response since 0.97.3 release. We don't have such
old RPC servers in the network anymore, thus this fallback code may be
safely removed.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-08-20 10:10:59 +03:00
Slava0135
d0c45477f5 neotest: implement coverage collection
Test coverage is automatically enabled when go test is running with coverage
enabled. It can be disabled for any Executor by using relevant methods.
Coverage is gathered by capturing VM OPs during test contract execution and
mapping them to the contract source code using the DebugInfo information.

Signed-off-by: Slava0135 <super.novalskiy_0135@inbox.ru>
2024-08-19 14:39:18 +03:00
Roman Khimov
7766168c19
Merge pull request #3557 from nspcc-dev/fix-lint
*: fix linter issues
2024-08-14 15:02:20 +03:00
Anna Shaleva
c06543cf50 *: fix linter issues
Linter is updated up to v1.60.1, the following issue is fixed:
```
predeclared  variable max has same name as predeclared identifier
```

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-08-14 12:36:15 +03:00
Roman Khimov
8ea0bc6e58
Merge pull request #3554 from nspcc-dev/add-echidna 2024-08-12 13:48:20 +03:00
Anna Shaleva
2c24cb342e core: introduce Echidna hardfork
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-08-12 11:10:26 +03:00
Anna Shaleva
79e78980c4
Merge pull request #3552 from nspcc-dev/fix-wsclient-limit
rpcsrv: fix failing TestWSClientsLimit
2024-08-09 16:44:27 +03:00
Anna Shaleva
b27e4f4309
Merge pull request #3540 from nspcc-dev/rpc-getversion
rpcsrv: add seedlist and standbycommittee to `getversion`
2024-08-09 15:18:12 +03:00
Anna Shaleva
9ba6db491e rpcsrv: fix failing TestWSClientsLimit
64 connections is too much for slow GA runners, we have to keep all of
them alive to avoid failures in the test, but it's impossible since
runners are too slow to iterate through all of them in time.

Close #3442.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-08-09 15:14:52 +03:00
Roman Khimov
f0266a9973
Merge pull request #3551 from nspcc-dev/neotest-fixes 2024-08-09 15:09:30 +03:00
Ekaterina Pavlova
9fb6d3266e rpcsrv: add seedlist and standbycommittee to getversion
Port neo-project/neo#3443.

Close #3538

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-08-09 12:53:31 +03:00
Anna Shaleva
72d1427109 neotest: calculate system fee for deployment transactions
1. Bind NewDeployTxBy to Executor to be able to use
   (*Executor).AddSystemFee.
2. Replace pre-defined constant deployment fee by calculated one.

This change is needed to be able to properly collect coverage for
_deploy method of a contract via neotest coverage. Ref.
https://github.com/nspcc-dev/neo-go/pull/3462#pullrequestreview-2229601870.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-08-09 11:55:22 +03:00
Anna Shaleva
5799397034 neotest: bind AddSystemFee and TestInvoke to Executor
These methods need Executor's context to properly process coverage, thus
these methods are not independent anymore. Ref.
https://github.com/nspcc-dev/neo-go/pull/3462#pullrequestreview-2219332436.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-08-09 11:49:31 +03:00
Roman Khimov
ffcbe6a10d
Merge pull request #3547 from nspcc-dev/docker-upd 2024-08-07 08:24:46 +03:00
Anna Shaleva
cbc2f73a0c *: migrate to Docker Compose V2
Docker Compose V1 is deprecated since June 2023, ref.
https://docs.docker.com/compose/migrate/ and
https://github.com/nspcc-dev/neo-bench/issues/166.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-08-06 15:51:17 +03:00
Anna Shaleva
7e8fda6b6d
Merge pull request #3541 from nspcc-dev/up-dbft
dbft: update to AMEV-enabled version
2024-08-06 15:44:56 +03:00
Roman Khimov
39e0d60221
Merge pull request #3544 from nspcc-dev/fix-permission-extension 2024-08-05 16:17:19 +03:00