Commit graph

7898 commits

Author SHA1 Message Date
Roman Khimov
9ebf04400e go.mod: upgrade golang.org/x/tools to v0.24.0
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-09-04 10:49:58 +03:00
Roman Khimov
894e53e697 go.mod: upgrade golang.org/x/crypto to v0.26.0
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-09-04 10:49:58 +03:00
Roman Khimov
a8e73a632d go.mod: update go.etcd.io/bbolt to v1.3.11
Minor fixes and Go 1.22.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-09-04 10:49:58 +03:00
Roman Khimov
7da0c900ca go.mod: upgrade github.com/urfave/cli/v2 to v2.27.4
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-09-04 10:49:58 +03:00
Roman Khimov
702ab131e3 go.mod: upgrade github.com/prometheus/client_golang to v1.20.2
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-09-04 10:49:58 +03:00
Roman Khimov
50657ddf32 go.mod: update our internal dependencies
go-ordered-json and rfc6979, nothing has really changed there.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-09-04 10:49:58 +03:00
Roman Khimov
da4500d8f1 go.mod: upgrade github.com/holiman/uint256 to v1.3.1
Heavily optimized one.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-09-04 10:49:58 +03:00
Roman Khimov
fed47df11a go.mod: upgrade github.com/gorilla/websocket to v1.5.3
It's maintained now again! A lot of fixes went in, but it seems to be ok
in tests.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-09-04 10:49:58 +03:00
Roman Khimov
4249fddc36 go.mod: update github.com/decred/dcrd/dcrec/secp256k1/v4 to v4.3.0
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-09-04 10:49:58 +03:00
Roman Khimov
7c356163e2 go.mod: upgrade github.com/consensys/gnark-crypto to v0.13.0
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-09-04 10:49:58 +03:00
Roman Khimov
d47fe392fb
Merge pull request #3567 from nspcc-dev/go-1.22
Go 1.22
2024-09-02 22:32:40 +03:00
Roman Khimov
565f8cfb7a *: fix copyloopvar warnings
Go 1.22+ allows to drop these:

  The copy of the 'for' variable "i" can be deleted (Go 1.22+) (copyloopvar)

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-30 22:02:57 +03:00
Roman Khimov
74cf5cbeae vm: drop *vm.VM parameter of CheckMultisigPar()
It's unused. Maybe we can move it out of VM completely decoupling VM from
crypto.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-30 21:48:27 +03:00
Roman Khimov
1b83dc2476 *: improve for loop syntax
Mostly it's about Go 1.22+ syntax with ranging over integers, but it also
prefers ranging over slices where possible (it makes code a little better to
read).

Notice that we have a number of dangerous loops where slices are mutated
during loop execution, many of these can't be converted since we need proper
length evalutation at every iteration.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-30 21:45:18 +03:00
Roman Khimov
133cd1dcf8 rpcbinding: use slices.Delete* for element filtering
It's a bit easier this way, loops that change slices aren't fun.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-30 21:35:27 +03:00
Roman Khimov
0fec17d7c0 bqueue: simplify queue flush on Discard()
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-30 21:30:00 +03:00
Roman Khimov
8f45d57612 *: stop using math/rand
Mostly this switches to math/rand/v2, but sometimes randomness is not really needed.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-30 17:00:11 +03:00
Roman Khimov
a50723ff72 *: use cmp.Or where appropriate
It's slightly less efficient (all comparisons are always made), but for
strings/ints it's negligible performance difference, while the code looks a
tiny bit better.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-30 17:00:11 +03:00
Roman Khimov
357bc76882 *: use slices.Concat where appropriate
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-30 17:00:11 +03:00
Roman Khimov
d5b7fc54e7 manifest: deduplicate test logic a bit with slices.Concat
LIkely it's more readable this way.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-30 17:00:11 +03:00
Roman Khimov
dfcff64acb go.mod: update to Go 1.22+
This also changes workflows to test 1.22 and 1.23 only (refs. https://github.com/nspcc-dev/.github/issues/30).
Fixes #3310.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-30 17:00:11 +03:00
Anna Shaleva
ff979e7ad2
Merge pull request #3563 from nspcc-dev/go-1.21
Go 1.21
2024-08-30 16:24:11 +05:00
Roman Khimov
8bececb511 go.mod: update github.com/consensys/gnark to v0.10.0
Fixes a security issue, https://github.com/Consensys/gnark/issues/897

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 15:40:49 +03:00
Roman Khimov
c07604fbf3 notary: simplify key presence check with slices
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 12:51:12 +03:00
Roman Khimov
8925b42250 golangci.yml: replace outdated linter
level=warning msg="The linter 'exportloopref' is deprecated (since v1.60.2) due to: Since Go1.22 (loopvar) this linter is no longer relevant. Replaced by copyloopvar."

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 12:51:12 +03:00
Roman Khimov
6d4ebdcef3 *: return errors.ErrUnsupported where appropriate
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 12:51:12 +03:00
Roman Khimov
97506fb48d keys: rework nep-2/wif encoding without bytes.Buffer
It doesn't make any sense here and the length check was just a dead code.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 12:29:44 +03:00
Roman Khimov
9bc67f9da6 keys: mute elliptic.Marshal deprecation warning
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 12:29:44 +03:00
Roman Khimov
b4e4567c2b *: don't use CompareTo name for three-way comparison functions
"Compare" is almost a standard one now, although math/big uses Cmp for historic
reasons (keys.PublicKey does so too). This also fixes Fixed8 since int64 to int
conversion is lossy.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 12:29:44 +03:00
Roman Khimov
a1a7e3d708 *: use slices package for sorting and searching
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 12:29:44 +03:00
Roman Khimov
6581bd47fc interop: simplify code with slices.Insert
It's not performance-critical for sure.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 12:29:44 +03:00
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