Commit graph

5455 commits

Author SHA1 Message Date
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
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
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
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
Anna Shaleva
2c7430583c smartcontrct: take care of manifest permission descriptor wildcardness
Starting from b10af1ed31
(*WildPermissionDescs).Add method's call is not enough to construct a
proper restricted permission descriptor, because Wildcard field should
be set properly at the same time. Ref. #3523.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-08-05 16:05:59 +03:00
Anna Shaleva
c46dfee214
Merge pull request #3537 from nspcc-dev/fix-mempool-fees
Fix mempool fees
2024-08-05 15:59:11 +03:00
Roman Khimov
5d1d7b104e mempool: properly remove fees when removing tx during Add
Fixes #3488.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-05 15:36:14 +03:00
Roman Khimov
ee0d92c6d2 dbft: update to AMEV-enabled version
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-01 22:29:51 +03:00
Ekaterina Pavlova
ef20ba3701 netmode: add constant MainNetNeoFS and TestNetNeoFS
Extend netmode package with NeoFS chains IDs.

Close #3503

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-07-31 11:02:17 +08:00
Roman Khimov
a11e433754 mempool: move metrics out of removeInternal, simplify it
Metrics should be updated once per action, currently removeInternal is
used by Add and Remove, the first one updates them in the end anyway and
remove should do the same.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-07-30 17:43:14 +03:00
Roman Khimov
6334192a95 mempool: remove Feer from Remove()
It's not used and not needed for removal.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-07-30 17:37:18 +03:00
Pavel Karpy
9fadfef0d7 rpcclient/WS: do not deadlock on connection loss
`makeWsRequest` creates a channel for response and waits for it. If between
creating the channel and starting the reading `select` connection is lost
(`writerDone` channel is closed), nothing reads from the channel and a
deadlock appears. Looking at "done" channels when transferring RPC data
solves the issue. Closes #3530.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2024-07-29 17:39:11 +03:00
Roman Khimov
54fd70fc32
Merge pull request #3523 from nspcc-dev/fix-null-handling-in-manifest
Fix null handling in manifest
2024-07-29 13:11:20 +03:00
Roman Khimov
1a48f1ce43 block: add PrimaryIndex to the stack item of block
This is a bad one.

$ ./bin/neo-go contract testinvokefunction -r https://rpc10.n3.nspcc.ru:10331 0xda65b600f7124ce6c79950c1772a36403104f2be getBlock 5762000
{
  "state": "HALT",
  "gasconsumed": "202812",
  "script": "AtDrVwARwB8MCGdldEJsb2NrDBS+8gQxQDYqd8FQmcfmTBL3ALZl2kFifVtS",
  "stack": [
    {
      "type": "Array",
      "value": [
        {
          "type": "ByteString",
          "value": "vq5IPTPEDRhz0JA4cQKIa6/o97pnJt/HfVkDRknd1rg="
        },
        {
          "type": "Integer",
          "value": "0"
        },
        {
          "type": "ByteString",
          "value": "zFYF3LGaTKdbqVX99shaBUzTq9YjXb0jaPMjk2jdSP4="
        },
        {
          "type": "ByteString",
          "value": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
        },
        {
          "type": "Integer",
          "value": "1722060076994"
        },
        {
          "type": "Integer",
          "value": "5293295626238767595"
        },
        {
          "type": "Integer",
          "value": "5762000"
        },
        {
          "type": "ByteString",
          "value": "LIt05Fpxhl/kXMX3EAGIASyOSQs="
        },
        {
          "type": "Integer",
          "value": "0"
        }
      ]
    }
  ],
  "exception": null,
  "notifications": []
}

$ ./bin/neo-go contract testinvokefunction -r http://seed3.neo.org:10332 0xda65b600f7124ce6c79950c1772a36403104f2be getBlock 5762000
{
  "state": "HALT",
  "gasconsumed": "202812",
  "script": "AtDrVwARwB8MCGdldEJsb2NrDBS+8gQxQDYqd8FQmcfmTBL3ALZl2kFifVtS",
  "stack": [
    {
      "type": "Array",
      "value": [
        {
          "type": "ByteString",
          "value": "vq5IPTPEDRhz0JA4cQKIa6/o97pnJt/HfVkDRknd1rg="
        },
        {
          "type": "Integer",
          "value": "0"
        },
        {
          "type": "ByteString",
          "value": "zFYF3LGaTKdbqVX99shaBUzTq9YjXb0jaPMjk2jdSP4="
        },
        {
          "type": "ByteString",
          "value": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
        },
        {
          "type": "Integer",
          "value": "1722060076994"
        },
        {
          "type": "Integer",
          "value": "5293295626238767595"
        },
        {
          "type": "Integer",
          "value": "5762000"
        },
        {
          "type": "Integer",
          "value": "6"
        },
        {
          "type": "ByteString",
          "value": "LIt05Fpxhl/kXMX3EAGIASyOSQs="
        },
        {
          "type": "Integer",
          "value": "0"
        }
      ]
    }
  ],
  "exception": null,
  "notifications": []
}

9 fields vs 10, notice the primary index right after the block number.

Back when ac527650eb initially added Ledger I've
used https://github.com/neo-project/neo/pull/2215 as a reference and it was
correct (no primary index). But then https://github.com/neo-project/neo/pull/2296
came into the C# codebase and while it looked like a pure refactoring it
actually did add the primary index as well and this wasn't noticed. It wasn't
noticed even when 3a4e0caeb8 had touched some
nearby code. In short, we had a completely wrong implementation of this call
for more than three years. But looks like it's not a very popular one.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-07-27 12:35:19 +03:00
Roman Khimov
c6ed92a169
Merge pull request #3532 from nspcc-dev/fix/ws-client-subscription-panic
rpcclient/WS: fix data race on concurrent (un)subscription
2024-07-26 19:29:38 +03:00
Pavel Karpy
d6eaf6efc2 rpcclient/WS: fix data race on concurrent (un)subscription
Every client's (Un)Subscription call does two things: an RPC call and a
subscription map lock (two of maps currently). If we imagine that there is
one routine that tries to subscribe (A) and one routine that tries to
unsubscribe (B), the following sequence can happen:

0. Current number of subscriptions is X
1. B does an RPC and makes number of subscriptions X-1
2. A does an RPC and makes number of subscriptions X again
3. A holds subscription locks and rewrites client's subscription state
   (subscription with ID X now points to a different channel; channel that
   was registered by B is lost and is not related to any real subscription
   but is still included in the `receivers` map)
4. B holds subscription locks and drops subscription X (first, it is an
   error and we have just lost a subscription that we think was made
   successfully second, we have lost a channel in the `receivers` map, and
   no corresponding subscription points to it)
5. X subscription is received by the WS client (in practice it is a new
   block, 100ms, quite often to be sure this issue happens every hour), we
   range through the receivers, see no corresponding subscription, and
   panic.

Closes #3093.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2024-07-26 18:19:50 +03:00
Roman Khimov
f4b61b5a77 rpcsrv: set minimal default SessionExpirationTime to 5s, fix #3509
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-07-26 17:17:37 +03:00
Roman Khimov
b10af1ed31 manifest: make default trusts invalid
Refs. #3522. The core problem is the same as for groups/features: we can't
allow empty trusts when they're unmarshalled from JSON. But unlike others we
can't easily differentiate missing any value with other cases because the
default value for WildPermissionDescs is a valid thing. Adding an additional
field makes it invalid and we can build around it. Other options are
implementing custom UnmarshalJSON for Manifest (too much for this) or making
Trusts a pointer (an option, but can fail in too many ways).

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-07-26 15:18:25 +03:00
Roman Khimov
58ab24efdb manifest: don't accept manifests with invalid features
Refs. #3522.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-07-26 15:18:25 +03:00
Roman Khimov
e861aeec2e manifest: disallow null groups, fix #3522
IsValid() is used by both compiler and ContractManagement then.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-07-26 11:22:44 +03:00
Anna Shaleva
c207b9b194
Merge pull request #3514 from nspcc-dev/microoptimize-chaindump
chaindump: microoptimize memory management
2024-07-16 16:54:41 +03:00
Roman Khimov
f60d5ee1b3
Merge pull request #3500 from nspcc-dev/optimize-ext-computations 2024-07-16 15:32:07 +03:00
Roman Khimov
1aefd7d16a chaindump: microoptimize memory management
Reuse buffers.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-07-16 15:03:17 +03:00
Anna Shaleva
434f94800a rpcsrv: improve witness verification error
It's needed to give user a hint about what's wrong with the witness
during `calculatenetworkfee` RPC request processing.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-07-11 12:03:34 +03:00
Anna Shaleva
7304b2c7fb
Merge pull request #3505 from nspcc-dev/array-cp
*: Convert slices to arrays instead of `copy` where possible
2024-07-08 11:00:31 +03:00
Leonard Lyubich
c975d728e8 *: Convert slices to arrays instead of copy where possible
Became possible with Go 1.20.

Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
2024-07-05 20:36:22 +04:00
Anna Shaleva
ed9817d35b config: get back default node configuration values
This code was accidentally removed by
https://github.com/nspcc-dev/neo-go/pull/3477, it's important to have
these fields set by default.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-07-05 13:31:25 +03:00
Anna Shaleva
5566e354d4
Merge pull request #3501 from NeoGoBros/add-max-array-size-test
Add a missing `mptdata` test
2024-07-03 19:34:14 +03:00
Furetur
3456d92220 mptdata: add test for MaxArraySize
This commit adds a single test that covers the
previously uncovered branch in the mptdata
decoding algorithm.

Signed-off-by: Furetur <furetur@gmail.com>
2024-07-03 13:36:53 +03:00
Anna Shaleva
6f77195ce3
Merge pull request #3460 from NeoGoBros/add-onexec-hook
Implement OnExecHook VM API
2024-07-03 13:21:46 +03:00
Anna Shaleva
17de1bf7fe core: avoid extra call to GetNextBlockValidatorsInternal
It should be sufficient to retrieve next block validators once per
updateExtensibleWhitelist call and then reuse this value. `nextVals`
copy intentionally omitted since the only change that
smartcontract.CreateDefaultMultiSigRedeemScript performs over the
`nextVals` list is sorting.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-07-03 13:03:10 +03:00
Furetur
f5794e91a2 vm: implement OnExecHook
Refs #3415

This commit introduces a small new change
that implements the Hooks API and more
specifically the OnExecHook. This feature
can be used to implement test coverage
collection, tracing, breakpoints, and etc.

To be more specific, this commit:

1. adds a new `hooks` field to the `VM`
   (this field contains the OnExecHook
    function)

2. sets the default value of this hook
   to be a NOP function

3. adds the `VM.SetOnExecHook` method

Signed-off-by: Furetur <furetur@gmail.com>
2024-07-03 12:49:09 +03:00
Ekaterina Pavlova
a9abd84cc4 cli: add embedded node config
If `config-path` is not passed, default configs are used according to
the set network. In VM CLI the default privnet config with InMemory db
is used.

Close #3450
Close #3459

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-07-01 10:59:11 +03:00
Anna Shaleva
ce1edda3f2
Merge pull request #3481 from EdgeDLT/getPeerHeights
Extend getpeers RPC method to provide useragent and last known height
2024-06-28 11:07:09 +03:00
edgedlt
ba4ebbd107 rpcclient: fix getpeers test
Signed-off-by: edgedlt <edgedlt@protonmail.com>
2024-06-27 14:00:08 +01:00
edgedlt
aab2620548 neorpc: extend getpeers method
Signed-off-by: edgedlt <edgedlt@protonmail.com>
2024-06-27 10:41:59 +01:00
Anna Shaleva
d9d9d00775
Merge pull request #3492 from nspcc-dev/actor-signers
invoker: add Signers() API
2024-06-21 23:30:45 +03:00
Roman Khimov
cc3f528eb6 actor: add SignerAccounts() API
Allow to retrieve the list easily.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-06-21 18:45:15 +03:00
Roman Khimov
8336b1b518 invoker: add Signers() API
Signers are very important for notary checks and keeping/passing an additional
copy of them is very inconvenient. Exposing them from invoker makes them
available in actors too.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-06-21 18:45:15 +03:00
Roman Khimov
a327a82085 actor: add a new WaitSuccess API
Most of the time people are interested in successful executions. Unfortunately,
unwrap package can't help here because of a different result structure (some
interface abstract can help, but it's still mostly stack-oriented and sessions
can be a problem), so this additional interface is needed.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-06-21 18:39:02 +03:00
Anna Shaleva
8f70d05f85 docs: add a note about System.Runtime.GetNotifications refcounting
Add a note about System.Runtime.GetNotifications refcounting to Domovoi
hardfork. Ref. https://github.com/neo-project/neo/pull/3301 and
https://github.com/nspcc-dev/neo-go/pull/3485.

Although NeoGo doesn't have anything to be updated, there's a
behaviour difference between C# and Go nodes before Domovoi hardfork, it
deserves a comment.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-06-11 19:26:11 +03:00
Roman Khimov
21aaadc4b7
Merge pull request #3473 from nspcc-dev/fix-call-check 2024-06-11 19:21:44 +03:00
Anna Shaleva
a7aceca74a interop: use currently executing contract state for permissions check
It's not correct to use an updated contract state got from Management to
check for the allowed method call. We need to use manifest from the
currently executing context for that. It may be critical for cases when
executing contract is being updated firstly, and after that calls
another contract. So we need an old (executing) contract manifest for
this check.

This change likely does not affect the mainnet's state since it's hard
to meet the trigger criteria, but I'd put it under the hardfork anyway.

Ref. https://github.com/neo-project/neo/pull/3290.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-06-11 19:13:17 +03:00
Roman Khimov
02627e948f
Merge pull request #3485 from nspcc-dev/test-maxstacksize 2024-06-11 19:04:26 +03:00