Commit graph

5429 commits

Author SHA1 Message Date
Ekaterina Pavlova
1237c719e3 smartcontract: fix DO NOT EDIT warning to autogenerated files
The text must appear as the first line of a properly formatted Go //
comment, and that comment must appear before but not be attached to the
package clause and before any /* */ comment.

Closes #3254

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2023-12-25 13:01:36 +03:00
Ekaterina Pavlova
5d514538cf rpc: add new header_of_added_block event subscription
New event is to notify the user about header's content by the moment
when block is stored (which happens after block's processing). This is
needed for proper Waiter work.

Closes #2751.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2023-12-22 15:14:01 +03:00
Roman Khimov
56d32a010e
Merge pull request #3256 from fyfyrchik/fix-signer
Allow complex contract signature schemes in `wallet.Account`
2023-12-21 22:50:57 +03:00
Anna Shaleva
47aefad7ea consensus: remove unnecessary call to ComputeNextBlockValidators
dBFT doesn't use validators got from this call to GetValidators callback,
because NeoGo doesn't properly set WithGetConsensusAddress, and thus
this call can be safely skipped. Instead, NeoGo fills NextConsensus field
by itself in NewBlockFromContext callback.

This commit technically doesn't perform any functional changes and doesn't
affect the problem described in #3253 in any way. This commit is just a
removal of the code that was never used by NeoGo library.

This commit is a direct consequence of https://github.com/nspcc-dev/dbft/issues/84.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-12-21 18:16:34 +03:00
Anna Shaleva
d7d850ac7d native: never set Neo's newEpoch* cache values to nil
We have cache update mechanism (Neo's cache votesChanged flag), it must
be used for current epoch and new epoch cached values update. And the
cached current/new epoch values themselves must always contain valid
information for the current/new epoch. These cached values must only be
changed once per epoch, never set them to nil.

This commit prevents CN node panic described in #3253 when dBFT tries
to retrieve new epoch validators with some votes modifications made
before at the same dBFT epoch.

Close #3253.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-12-21 17:56:07 +03:00
Evgenii Stratonikov
c8ff44560e neotest: reuse wallet.Account for contract signers
Refs #3245
Refs #3233

Signed-off-by: Evgenii Stratonikov <fyfyrchik@runbox.com>
2023-12-21 11:27:41 +03:00
Evgenii Stratonikov
962b161652 wallet: allow complex contract verification schemes, close #3015
This was recently added in neotest, but working with the real RPC is
still not enjoyable. This commit extends `wallet.Account` with
invocation script builder to aid network fee calculations and signing.

Signed-off-by: Evgenii Stratonikov <fyfyrchik@runbox.com>
2023-12-21 11:26:55 +03:00
Roman Khimov
3766206f44
Merge pull request #3255 from smallhive/3177-wallet-from-bytes
wallet: Add new wallet constructors
2023-12-14 18:45:44 +03:00
Evgeny Baydakov
2012c56031
wallet: Add new wallet constructors
Closes #3177

Signed-off-by: Evgeny Baydakov <e.bajdakov@gmail.com>
2023-12-12 08:33:30 +04:00
Anna Shaleva
d5dee8fc94 rpcclient: fix failing initialisation-based tests
Must be a part of #3257.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-12-11 12:41:56 +03:00
Ekaterina Pavlova
3fd48a743e rpc: add an ability to filter out NotaryRequestEvents
Add new filter NotaryRequestFilter, support for filtering
NotaryRequestEvents by mempoolevent.Type
(added or removed).

Closes #2425.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2023-12-09 11:37:25 +03:00
Anna Shaleva
21ccb1a02a rpcclient: check network initialisation for blocks subscriptions
StateRootInHeader depends on it, so we better immediately return error
if client is not initialised.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-12-08 21:57:40 +03:00
Dmitrii Stepanov
7b53a0c239 neotest: Add contract signer support
Signed-off-by: Dmitrii Stepanov <dima-stepan@yandex.ru>
2023-12-01 10:50:08 +03:00
Roman Khimov
6c0c2a6a98
Merge pull request #3246 from nspcc-dev/fix-doc
neotest: adjust Signer documentation
2023-12-01 10:23:46 +03:00
Roman Khimov
26f96fe7ee
Merge pull request #3243 from nspcc-dev/add-management-test
native: test immediate contract availability
2023-12-01 10:21:09 +03:00
Anna Shaleva
daa2b3b920 neotest: adjust Signer documentation
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-12-01 09:25:41 +03:00
Roman Khimov
b31d39836a native: test immediate contract availability
I had some reason to suspect something is wrong here (but it's all OK). Even
though this is kinda tested in TestDeployGetUpdateDestroyContract, it uses
internal APIs and with neotest we can ensure it work OK for a complete tx/block
environment. So, won't hurt having these tests as well.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-11-30 15:58:00 +03:00
Roman Khimov
34be76efb7
Merge pull request #3240 from nspcc-dev/fix-native-upd
core: remove UpdateHistory from NativeContract structure
2023-11-29 16:18:34 +03:00
Anna Shaleva
6fdda0f15d rpcclient: add doc link to notifications ordering guarantees
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-29 13:53:45 +03:00
Anna Shaleva
8e8936912d core: remove UpdateHistory from NativeContract structure
Although it doesn't raise an exception on our side, we still have this
unrelevant information in the resulting RPC call response structure.
This should be a part of https://github.com/nspcc-dev/neo-go/pull/3212.

Port https://github.com/neo-project/neo-modules/pull/851.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-29 09:25:04 +03:00
Anna Shaleva
42b84ad905 rpcclient: improve documentation
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-28 20:23:33 +03:00
Anna Shaleva
b637048122 vm: allow to emit any based on its type
No functional changes, just moved a part of emit.Array to a separate
exported method. It may be useful for contract-based witness invocation
scripts construction and not only. Ref.
https://github.com/nspcc-dev/neo-go/pull/3233#discussion_r1407786333.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-28 17:17:34 +03:00
Anna Shaleva
2eab743a5b compiler: add compatibility test for storage limits
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-28 10:51:03 +03:00
Anna Shaleva
b35f351f0b interop: add contract storage limits
Users of NeoGo interop package may have a demand to use these limits
for custom purposes, it would be nice to have them as constants.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-27 19:56:13 +03:00
Anna Shaleva
15b4e0a8cd services: adjust StateRoot service initialisation
Perform initialisation of StateRoot service with designated
StateValidator's node list in the service constructor. There's no need
to wait until the next role update event, and it may lead to inaccuraces
in service work on SIGHUP/server restart.

A part of #3228.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-24 15:25:51 +03:00
Anna Shaleva
11ec0db350 core, services: fix Designation-dependant service initialisation
Initialise services dependant on roles designation based on N+1
block so that Genesis roles extension work properly. There's not
much sence to fetch node roles information for the latest persisted
block because Designation contract itself makes designated nodes
responsible since the next subsequent block.

A part of #3228.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-24 15:25:51 +03:00
Anna Shaleva
5d1e0192f1
Merge pull request #3206 from nspcc-dev/relative_path_flag
cli: add --relative-path option
2023-11-24 08:16:16 +03:00
Roman Khimov
1f84756c21
Merge pull request #3222 from nspcc-dev/doc/contracts-storage-seek-call-improvement
doc/Mention prefix trimming in `Seek` operations where applicable
2023-11-23 23:03:20 +03:00
Roman Khimov
61d5b6eb0c
Merge pull request #3221 from nspcc-dev/json-limits
Anti-DOS RPC limitations
2023-11-23 23:02:50 +03:00
Ekaterina Pavlova
f457d50773 cli: add --relative-path option
To be able running the node from any working directory by simply
pointing the relative-path as prefix for relative parameters set in
config.

Closes #3179.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2023-11-23 21:41:50 +04:00
Anna Shaleva
d511f6e5a9 confi: add MaxRequestHeaderBytes RPC configuration option
A part of #3131, follow the notion of https://github.com/neo-project/neo-modules/pull/827,
but don't restrict request line size due to https://github.com/golang/go/issues/15494.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-23 20:17:49 +03:00
Anna Shaleva
802d8d24b9 config: add MaxRequestBodySize RPC configuration option
A part of #3131, follow the https://github.com/neo-project/neo-modules/pull/827.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-23 20:17:49 +03:00
Pavel Karpy
62b710868b *: mention prefix trimming in Seek operations where applicable
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2023-11-23 18:44:19 +03:00
Roman Khimov
341d978e5b compiler: walk over functions in reproducible order, fix #3219
It affects both Debug data and bindings, otherwise two unnamed structures can
get any of unnamed/unnamedx names depending on particular invocation.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-11-23 13:21:51 +03:00
Anna Shaleva
22c654b200 neorpc: restrict maximum subitems number in SignerWithWitness
Restrict the number of Rules, Contracts and Groups. A part of #3131.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-23 12:12:34 +03:00
Anna Shaleva
2f6ba1fded rpcsrv: define GetSignersWithWitnesses on a pointer
Nil receiver can be properly handled and all other `Param`'s mathods
are defined on a pointer.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-23 11:44:29 +03:00
Roman Khimov
25ef2c7f16
Merge pull request #3218 from nspcc-dev/serialization-limits
Introduce stackitem serialization limits
2023-11-22 21:28:25 +03:00
Anna Shaleva
910d53b27b core: do not check manifest size on deploy/update
Manifest will be a part of the state.Contract which will be checked on its
way to the storage. Tiny optimisation which allows not to serialize manifest
twice. Ref. https://github.com/nspcc-dev/neo-go/pull/3218#discussion_r1402374232.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-22 20:17:09 +03:00
Anna Shaleva
1d189fd90c Revert "native: ignore decoding errors during cache init"
This reverts commit 822722bd2e.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-22 19:39:03 +03:00
Anna Shaleva
6824bd9f40 smartcontract: require manifest serialization in (*Manifest).IsValid
Port the restrictive part of https://github.com/neo-project/neo/pull/2948.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-22 19:39:03 +03:00
Anna Shaleva
387c411da0 vm: add default limit to SI serialization context
Follow the notion of https://github.com/neo-project/neo/pull/2948.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-22 19:39:01 +03:00
Roman Khimov
00c6a811ab
Merge pull request #3215 from nspcc-dev/tiny-compiler-fixes
Tiny compiler fixes
2023-11-22 19:29:37 +03:00
Roman Khimov
4c9cd438f8 rpcbinding: sort named types to stabilize output
Same input -> same output, otherwise tests fail and @AnnaShaleva is annoyed.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-11-21 21:47:51 +03:00
Roman Khimov
eade327b9b compiler: check for pkg nilness, fix #3202
Unfortunately, when import cycle happens somewhere deep in the import chain we
dont't get an error from packages.Load(). But it leaves some imports
uninitialized, so at least we can check for them.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-11-21 21:47:51 +03:00
Roman Khimov
fced6a27ba compiler: iterate over autoguessed events in reproducible way
Otherwise it's undertermined which of two unnamed structures will get "Unnamed"
and "UnnamedX" which can break the test from time to time.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-11-21 18:43:40 +03:00
Roman Khimov
5370034955 compiler: deduplicate autoguessed event names, fix #3088
Make them stable wrt parameter order and use proper names in event structures
as well.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-11-21 18:35:26 +03:00
Roman Khimov
a5d041a1ac compiler: check range first, analyze funcs then
Type data is added while walking through function ins/outs even if we're to
throw this function away. But we don't need it, these types are not used, so
we can deal with the main part of #3071 by optimizing this out.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-11-21 17:52:17 +03:00
Roman Khimov
2ae44e074d docs: canceltransaction is not going to be supported
Refs. neo-project/neo-modules#837.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-11-21 16:11:58 +03:00
Roman Khimov
ff958706f4
Merge pull request #3212 from nspcc-dev/drop-history
Move NativeUpdateHistory logic uner hardforks
2023-11-21 15:46:16 +03:00
Roman Khimov
28ee1621b8
Merge pull request #3155 from nspcc-dev/apptr-pricing
*: introduce Policy attributes pricing
2023-11-21 15:44:40 +03:00
Anna Shaleva
58102a9a80 *: move NativeUpdateHistory logic under Hardforks management
Close #3196.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-21 14:05:28 +03:00
Anna Shaleva
64b5ba24e9 *: fix less then typos everywhere
My poor grammar...

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-21 13:47:59 +03:00
Anna Shaleva
3b11f98cd0 core: review usages of (*intero.Context).BlockHeight method
This method returns persisted block height and doesn't take into account
persisting block height. Some of the callers of this method relay on
the wrong assumption that BlockHeight() returns persisting block index.

Fix improper usages of this method and adjust tests. Ref.
61a066583e/src/Neo/SmartContract/ApplicationEngine.cs (L634).

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-21 13:46:13 +03:00
Anna Shaleva
474225d425 core, rpcsrv: apply generic attributes fee logic to NotaryServiceFeePerKey
Remove related methods from native Notary and add relevant code to native
Policy.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-21 13:42:56 +03:00
Anna Shaleva
82cb2e718d native: introduce attribute pricing
Port the https://github.com/neo-project/neo/pull/2916.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-21 13:42:56 +03:00
Roman Khimov
80fcf81102
Merge pull request #3209 from nspcc-dev/strict-cfg
Forbid unknown YAML node configuration fields
2023-11-21 13:20:57 +03:00
Anna Shaleva
59baecd39b wallet: provide more detailed errors on failed NewWalletFromFile
Close #3180.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-21 13:07:11 +03:00
Anna Shaleva
63de821ff4 config: forbid unknown YAML configuration fields
Close #3128 and fix one of the privnet configurations along the way.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-20 20:04:09 +03:00
Anna Shaleva
a4779de375 core: improve TestConfigNativeUpdateHistory subtests naming
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-20 20:03:28 +03:00
Anna Shaleva
0fef119f5f rpcsrv: update test data
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-20 19:41:45 +03:00
Anna Shaleva
406c9f8b92 core, interop: add strLen method for native StdLib contract
Close #3195.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-20 19:23:33 +03:00
Roman Khimov
f6cb698cd1 rpcsrv/params: limit tx signers/witnesses
Inspired by https://github.com/neo-project/neo-modules/pull/845.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-11-20 16:01:14 +03:00
Roman Khimov
7fb077e999
Merge pull request #3186 from nspcc-dev/reduce-max-nef-size
Restrict maximum serialized NEF file size
2023-11-20 15:19:40 +03:00
Anna Shaleva
90705e37e9 compiler: perform NEF size check on serialization
Retun an error if the serialized NEF size exceeds stackitem.MaxSize.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-20 15:14:05 +03:00
Anna Shaleva
e63a93b8a0 compiler: add tests for System.Runtime.CurrentSigners
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-20 14:49:07 +03:00
Anna Shaleva
2fba04490a core: add System.Runtime.CurrentSigners syscall
Port the https://github.com/neo-project/neo/pull/2827.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-20 14:46:27 +03:00
Anna Shaleva
90b01bcea6 core: move SignersToStackItem to transaction package
It will be reused from interops.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-20 14:46:27 +03:00
Anna Shaleva
14d98811a5 smartcontract: restrict maximum NEF file size on deserialisation
Port https://github.com/neo-project/neo/pull/2939.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-20 14:32:32 +03:00
Anna Shaleva
fdcc369d60 manifest: add compatibility test for Permissions and Trust serialization
We already have tests for Permission deserialisation, so port the first
part of https://github.com/neo-project/neo/pull/2948.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-18 13:32:28 +03:00
Roman Khimov
de2a445088
Merge pull request #3185 from nspcc-dev/fix-stackitem-limits
vm: reduce maximum stckitem size
2023-11-13 22:53:19 +03:00
Anna Shaleva
b0cdae4666 vm: reduce maximum stckitem size
To prevent possible DoS. Port the https://github.com/neo-project/neo-vm/pull/514,
close #3170.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-13 20:40:30 +03:00
Anna Shaleva
963a22e280 neorpc: adjust common error messages
According to the initial proposal and
https://github.com/neo-project/proposals/pull/156/files#diff-2b5f7c12a23f7dbe4cb46bbf4be6936882f8e0f0b3a4db9d8c58eb294b02e6ed.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-13 20:29:13 +03:00
Roman Khimov
7045d3bd63
Merge pull request #3192 from nspcc-dev/rpc-err
neorpc: ensure errors.Is and errors.As work properly with neorpc.Error
2023-11-08 09:34:05 +03:00
Anna Shaleva
fca7eb35a1 neorpc: ensure errors.Is and errors.As work properly with neorpc.Error
Close #3188.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-07 23:59:53 +03:00
Anna Shaleva
b4866bd69e native: prohibit NEP-17 roundtrip with zero balance
Close #3190.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-07 19:37:37 +03:00
Anna Shaleva
ba4c58780c native: optimize policy check for transaction's signers
Do not retrieve RO cache for each signer, make it ones per transaction
instead.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-03 10:29:47 +03:00
Anna Shaleva
de38163f89 core: log block height before MPT/natives cache initialization
We have this log on the network server side, but it would also be
useful in case of failed blockchain initialization.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-03 10:29:46 +03:00
Anna Shaleva
bbbc6805a8 native: fix NeoToken initialization process
Refactored native NeoToken cache scheme introduced in #3110 sometimes requires
validators list recalculation during native cache initialization process (when
initializing with the existing storage from the block that is preceded each N-th block).
To recalculate validators from candidates, native NeoToken needs an access to
cached native Policy blocked accounts. By the moment of native Neo initialization,
the cache of native Policy is not yet initialized, thus we need a direct DAO access
for Policy to handle blocked account check.

Close #3181.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-02 17:56:02 +03:00
Anna Shaleva
91c8aa21cc core: fix typo in comment
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-02 17:15:34 +03:00
Roman Khimov
dffd87c6c8
Merge pull request #3171 from nspcc-dev/fix-linter
Fix linter problems
2023-10-20 21:14:41 +03:00
Anna Shaleva
7a6b908cae neorpc: fix exported structure comment
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-20 19:31:23 +03:00
Roman Khimov
c3955f87d1
Merge pull request #3165 from nspcc-dev/fix-win-timeout
Improve timeout of RPC tests on Windows
2023-10-20 19:07:24 +03:00
Anna Shaleva
3544d65ecd rpcclient: disable linter for documentation example
Disable the following linter warning:
```
superfluous-else: if block ends with call to panic function, so drop this else and outdent its block (revive)
```

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-20 17:28:57 +03:00
Anna Shaleva
6e0af5ac90 network: fix linter warning
Fix the following linter warning:
```
dot-imports: should not use dot imports (revive)
```

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-20 17:23:35 +03:00
Anna Shaleva
39ce3a9d1d vm: fix linter warning
Fix the following linter warning:
```
indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) (revive)
```

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-20 17:22:21 +03:00
Anna Shaleva
c93658b1c1 Partially revert "*: use localhost address instead of 127.0.0.1, fix #2575"
This partially reverts commit c26a962b55 for testing
chains configurations.

Ref. #2975, although this commit doesn't close it. This commit is an attempt to
enforce IPv4 for our test clients to avoid problem described in the issue.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-20 17:17:37 +03:00
Anna Shaleva
8cc32a91b6 *: add GenesisTransaction extension to the protocol configuration
Provide a script that should be deployed in the genesis block.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-19 18:33:50 +03:00
Anna Shaleva
065bd3f0be *: introduce Genesis protocol configuration
This section contains genesis-related settings including genesis-related or natives-related
extensions. Currently it includes the set of node roles that may be designated
duing the native Designation contract initialisation.

Close #3156.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-19 18:30:20 +03:00
Anna Shaleva
1815bc8a32 *: update Stringers wrt fresh Stringer version
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-19 11:33:07 +03:00
Anna Shaleva
61a74ab331 native: introduce Stringer for noderoles types
And rename roles.go to role.go to match the role_string.go and the
existing naming pattern for enums.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-19 11:33:04 +03:00
Roman Khimov
04d778612e
Merge pull request #3167 from nspcc-dev/autogen-warn
smartcontract: add `DO NOT EDIT` warning to autogenerated files
2023-10-18 21:35:20 +03:00
Anna Shaleva
6476241b3a smartcontract: add DO NOT EDIT warning to autogenerated files
Close #3139.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-18 20:34:36 +03:00
Anna Shaleva
1841d818ec rpcclient: always provide start parameter for findstorage RPC
Close #3137.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-18 20:12:05 +03:00
Anna Shaleva
6a706d5c5a rpcbinding: fix formatting of binding template
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-18 18:15:33 +03:00
Anna Shaleva
c42486587d smartcontract: apply gofmt to the resulting bindings
Close #3133.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-18 18:14:52 +03:00
Roman Khimov
38f77c39d0
Merge pull request #3142 from Ayrtat/fix/wsclient_hang
rpcclient: fix wsclient hang on making request
2023-10-16 15:26:13 +03:00
Anna Shaleva
545dbbc668 go.mod: upgrade gnark to v0.9.0
Close #3079.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-16 15:06:30 +03:00
Ayrtat
ff19189937 rpcclient: fix #3135 wsclient hangs on making request
* Rename c.done channel to c.readerDone
* Introduce c.writerDone channel that is closed if the wsWriter's loop
  is done
* Make the error returned by makeWsRequests verbose

Signed-off-by: Ayrtat <amper.meter1775@gmail.com>
2023-10-16 13:01:12 +03:00
Roman Khimov
a9a848a306
Merge pull request #3160 from nspcc-dev/add-version-hf
rpcsrv: add hardforks to `getversion` response
2023-10-16 10:37:10 +03:00
Anna Shaleva
69a0104d05 rpcsrv: add hardforks to getversion response
Port https://github.com/neo-project/neo-modules/pull/823.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-16 10:33:21 +03:00
Anna Shaleva
3aa858a69f *: drop go 1.18 support in doc and build targets
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-12 17:59:42 +03:00
Anna Shaleva
241d5f593e *: use methods of binary.AppendByteOrder where applicable
We often use binary.PutUint*, but almost all these cases have preallocated
buffer of the size that matches exactly the desired one and use a single or
a couple of calls to PutUint*. Thus, I don't think that replacing
binary.PutUint* by AppendUint* will make things better for all these usages.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-12 17:59:42 +03:00
Anna Shaleva
dc3d1300dd *: replace go.uber.org/atomic with sync/atomic
Use sync/atomic everywhere and exclude go.uber.org/atomic from go.mod.
Close #2626.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-12 17:59:34 +03:00
Anna Shaleva
7ca4ce0f79 core: fix race in stateroot initialization error logging
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-12 13:37:31 +03:00
Anna Shaleva
995d774ff8 *: bump minimum required go version to 1.19
For all components.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-12 13:28:59 +03:00
Anna Shaleva
e6b4fbc999 rpcsrv: format code
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-12 13:28:59 +03:00
Anna Shaleva
32bfed4741 core: improve conflict records storage scheme
Implement the https://github.com/neo-project/neo/issues/2907#issuecomment-1722506014
and port a part of https://github.com/neo-project/neo/pull/2913.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-10 17:34:27 +03:00
Roman Khimov
2f747dd8d9
Merge pull request #3150 from nspcc-dev/drop-deprecated
Drop deprecated things
2023-10-10 14:29:47 +03:00
Roman Khimov
460362ab2e config: drop deprecated Protocol configurations
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-10-10 13:26:07 +03:00
Roman Khimov
9f7b19f886 config: drop implicit consensus config via UnlockWallet
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-10-10 13:26:07 +03:00
Roman Khimov
6865848ca7 config: drop deprecated P2P configuration
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-10-10 13:26:07 +03:00
Roman Khimov
de69560c7d config: drop deprecated address/port configurations
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-10-10 13:26:07 +03:00
Roman Khimov
a59afa8ea3 config: drop obsolete SecondsPerBlock protocol configuration
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-10-10 13:26:07 +03:00
Roman Khimov
eb995c8600 rpcclient: drop deprecated Notifications an Subscribe*
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-10-10 13:26:07 +03:00
Roman Khimov
413caac941 rpcclient: drop deprecated Client APIs
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-10-10 13:26:07 +03:00
Anna Shaleva
d9644204ee native: make newEpochNextValidators always contain non-empty value
If it's the end of epoch, then it contains the updated validators list recalculated
during the last block's PostPersist. If it's middle of the epoch, then it contains
previously calculated value (value for the previous completed epoch) that is equal
to the current nextValidators cache value.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-10 13:18:05 +03:00
Anna Shaleva
f78f915071 native: optimize NEO's committee/validators cache handling
Do not recalculate new committee/validators value in the start of every
subsequent epoch. Use values that was calculated in the PostPersist method
of the previously processed block in the end of the previous epoch.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-10 13:18:05 +03:00
Anna Shaleva
27dddb4d50 native: refactor argument of NEO's getCommitteeMembers function
No funcional changes, just refactoring. It doesn't need the whole cache,
only the set of committee keys with votes.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-10 13:18:05 +03:00
Anna Shaleva
794658b54c native: rename NEO's cached validators list to newEpochNextValidators
Adjust all comments, make the field name match its meaning.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-10 13:18:05 +03:00
Anna Shaleva
312534af7c native: don't recalculate validators every block
Recalculate them once per epoch. Consensus is aware of it and must
call CalculateNextValidators exactly when needed.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-10 13:18:05 +03:00
Anna Shaleva
07e1bc7cd7 core: rename (*Blockchain).GetValidators to ComputeNextBlockValidators
We have two similar blockchain APIs: GetNextBlockValidators and GetValidators.
It's hard to distinguish them, thus renaming it to match the meaning, so what
we have now is:

GetNextBlockValidators literally just returns the top of the committee that
was elected in the start of batch of CommitteeSize blocks batch. It doesn't
change its valie every block.

ComputeNextBlockValidators literally computes the list of validators based on
the most fresh committee members information got from the NeoToken's storage
and based on the latest register/unregister/vote events. The list returned by
this method may be updated every block.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-10 13:18:05 +03:00
Anna Shaleva
96449d803a native: rework native NEO next block validators cache
Blockchain passes his own pure unwrapped DAO to
(*Blockchain).ComputeNextBlockValidators which means that native
RW NEO cache structure stored inside this DAO can be modified by
anyone who uses exported ComputeNextBlockValidators Blockchain API,
and technically it's valid, and we should allow this, because it's
the only purpose of `validators` caching. However, at the same time
some RPC server is allowed to request a subsequent wrapped DAO for
some test invocation. It means that descendant wrapped DAO
eventually will request RW NEO cache and try to `Copy()`
the underlying's DAO cache which is in direct use of
ComputeNextBlockValidators. Here's the race:
ComputeNextBlockValidators called by Consensus service tries to
update cached `validators` value, and descendant wrapped DAO
created by the  RPC server tries to copy DAO's native cache and
read the cached `validators` value.

So the problem is that native cache not designated to handle
concurrent access between parent DAO layer and derived (wrapped)
DAO layer. I've carefully reviewed all the usages of native cache,
and turns out that the described situation is the only place where
parent DAO is used directly to modify its cache concurrently with
some descendant DAO that is trying to access the cache. All other
usages of native cache (not only NEO, but also all other native
contrcts) strictly rely on the hierarchical DAO structure and don't
try to perform these concurrent operations between DAO layers.
There's also persist operation, but it keeps cache RW lock taken,
so it doesn't have this problem as far. Thus, in this commit we rework
NEO's `validators` cache value so that it always contain the relevant
list for upper Blockchain's DAO and is updated every PostPersist (if
needed).

Note: we must be very careful extending our native cache in the
future, every usage of native cache must be checked against the
described problem.

Close #2989.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-10 13:18:05 +03:00
Roman Khimov
19c59c3a59
Merge pull request #3149 from nspcc-dev/fix-compiler-version-race
internal: avoid race access to config.Version by tests
2023-10-10 12:23:08 +03:00
Anna Shaleva
eeb439f548 internal: avoid race access to config.Version by tests
Network server constructor reads config.Version variable, and
testcli.DeployContract writes dummy config.Version which causes
race in tests. Avoid this race by moving config.Version initialisation
to a separate package and perform it inside test packages init().

Close #3011, close #3017.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-10 11:59:53 +03:00
Roman Khimov
cef70091f6
Merge pull request #3148 from fyfyrchik/fix-dump
storage: Use timeout for boltdb database opening
2023-10-09 12:40:07 +03:00
Evgenii Stratonikov
f1c6b9fe8f storage: Use timeout for boltdb database opening
To dump the DB, the service must be stopped.
If this is not the case `dump` command just hangs without any output,
which _may_ be unexpected from the ops POV.
Introduce a 1 second timeous, which is more than enough, given
that bbolt retries doing flock() every 50ms.

Signed-off-by: Evgenii Stratonikov <fyfyrchik@runbox.com>
2023-10-06 13:10:11 +03:00
Roman Khimov
b78bea17c0
Merge pull request #3147 from fyfyrchik/fix-big-uint64
compiler: Fix emitting big uint64 constants
2023-10-05 22:34:07 +03:00
Evgenii Stratonikov
96ee2e2b2d compiler: Fix emitting big uint64 constants
Currently we take int64 value from the Go parser and push it to the
stack. Using uint64 is not a common practice (usually we just use `int`),
but can be a problem while doing bit arithmetic and serializing numbers.

Signed-off-by: Evgenii Stratonikov <fyfyrchik@runbox.com>
2023-10-05 16:03:57 +03:00
Anna Shaleva
d27d2a8561 zkpbinding: fix example link
Should be a part of #3043.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-05 15:16:11 +03:00
Anna Shaleva
a2d28272ef native: fix error message on unexpected BLS12-381 curve point
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-05 13:46:05 +03:00
Anna Shaleva
e2abb5cb7c zkpbinding: update templates of go.sum and go.mod for Verifier contract
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-05 13:46:05 +03:00
Anna Shaleva
ca71bd51d3 zkpbinding: format formulae in Verifier template
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-05 13:46:05 +03:00
Anna Shaleva
b7e019e7ef native: ensure proper endianness is used for CryptoLib's field element multiplier
Field element multiplier must be provided in the LE form, confirmed by
cross-node invocation: https://github.com/nspcc-dev/neo-go/pull/3043#issuecomment-1733424840.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-05 13:46:05 +03:00
Anna Shaleva
8c46517522 zkpbinding: use proper field size for BLS12-381
It's not differ from BN254, but we'd better use the proper package.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-05 13:46:05 +03:00
Anna Shaleva
ff260a6a9b zkpbinding: allow to handle serialisation format of gnark >= v0.9.0
An upgrade from gnark v0.8.X to v0.9.0 changes serialization format of verifying/proving keys
and proofs. In neo-go zkpbinding package we have to support both at least for now, because
gnark@v0.9.0 requires minimum go 1.19.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-05 13:46:05 +03:00
Anna Shaleva
9e74fc5b47 zkp: add end-to-end Groth-16 proof generation/verification example
The example shows that the proover knows the solution of the cubic
equation: y = x^3 + x + 5. The example is constructed for BLS12-381
curve points using Groth-16 prooving algorithm. The example includes
everything that developer needs to start using ZKP on the NEO platform
with Go SDK:
1. The described cubic circuit implementation.
2. The off-chain proof generation with the help of gnark-crypto library.
3. Go verification contract generation and deployment with the help of
   NeoGo libraries.
4. The on-chain proof verification for various sets of input data.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-05 12:32:47 +03:00
Anna Shaleva
0a3260c22c examples: add compatibility example for Groth16 veification
Port the C# contract provided in the
https://github.com/neo-project/neo/issues/2647#issuecomment-1129849870 and
add an integration test for it. Part of the #3002.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-05 11:01:25 +03:00
Roman Khimov
49a44b0b9d rpcsrv: use stricter GAS limit for calculatenetworkfee
Valid transactions can't use more than MaxVerificationGAS for script execution
and this applies to the whole set of signers, so use this value by default
unless local instance configuration suggests something lower for generic
invocations.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-09-27 19:33:06 +03:00
Roman Khimov
fd2774ea91 rpcsrv: return core.ErrVerificationFailed from calculatenetworkfee
We can ignore core.ErrInvalidSignature (which means that the script has
executed, but returned false), but we shouldn't ignore other errors which
likely mean that the script is incorrect (or hits some resource limits).

Use neorpc.ErrInvalidSignature as a return to separate this case from
contract-based verification.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-09-27 19:30:23 +03:00
Anna Shaleva
2581146a01 smartcontract: fix wildcard trusts deserialization
If manifest trusts presented as Null stackitem, then they should be
treated as wildcard, not as restricted.

It's not the same problem as described and fixed in
https://github.com/neo-project/neo/pull/2901 and
https://github.com/neo-project/neo/pull/2892, although these
two PRs are related.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-09-25 11:53:47 +03:00
Roman Khimov
a0f9743515 oracle/neofs: avoid panic on failed neofs requests
2023-09-13T06:04:07.114Z        WARN        failed to perform oracle request        {"url": "neofs:BE2c15AbYnKdcsVh77LisCtjifoNEJUekANo1yhQ211X/FMDZvqUCqcduZa8HD6wJNsHWrJ6sqkgBveGuYuL38pvH", "error": "header: status: code = 3072 message = container not found"}
  panic: runtime error: invalid memory address or nil pointer dereference
  [signal SIGSEGV: segmentation violation code=0x1 addr=0x50 pc=0xde7c8f]
  goroutine 302 [running]:
  github.com/nspcc-dev/neofs-sdk-go/client.(*PayloadReader).close(0x0?, 0x0?)
          github.com/nspcc-dev/neofs-sdk-go@v1.0.0-rc.11/client/object_get.go:200 +0x2f
  github.com/nspcc-dev/neofs-sdk-go/client.(*PayloadReader).Close(0x0?)
          github.com/nspcc-dev/neofs-sdk-go@v1.0.0-rc.11/client/object_get.go:229 +0x1e
  github.com/nspcc-dev/neo-go/pkg/services/oracle/neofs.clientCloseWrapper.Close({{0x14b45f8?, 0x0?}, 0xc0010a1380?})
          github.com/nspcc-dev/neo-go/pkg/services/oracle/neofs/neofs.go:97 +0x3c
  github.com/nspcc-dev/neo-go/pkg/services/oracle.(*Oracle).processRequest(0xc000255800, 0xc001dfa210, {0xb2d?, 0xc001ad8000?})
          github.com/nspcc-dev/neo-go/pkg/services/oracle/request.go:168 +0xee7
  github.com/nspcc-dev/neo-go/pkg/services/oracle.(*Oracle).runRequestWorker(0xc000255800)
          github.com/nspcc-dev/neo-go/pkg/services/oracle/request.go:36 +0xe5
  created by github.com/nspcc-dev/neo-go/pkg/services/oracle.(*Oracle).start
          github.com/nspcc-dev/neo-go/pkg/services/oracle/oracle.go:216 +0xae

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-09-13 10:50:42 +03:00
Roman Khimov
0f57ad4a12 oracle/neofs: upgrade to SDK RC11
It requires explicit signers, and we have a problem with the old code:

  2023-09-12T18:42:00.063Z        WARN        failed to perform oracle request        {"url": "neofs:FMDZvqUCqcduZa8HD6wJNsHWrJ6sqkgBveGuYuL38pvH/5DCg4wUgWuWN3zsF4P4HdAzY2iKvXcrZ8QBLYGd1D1g2", "error": "failed to create client: incorrect signer: expected ECDSA_DETERMINISTIC_SHA256 scheme"}

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-09-13 10:50:42 +03:00
Roman Khimov
9bdf66a5e0 state: always deserialize LastGasPerVote
It can be non-zero even if VoteTo is NULL. Fixes state diff with 3.6.0:

  block 41660: value mismatch for key +////xTrvgat3qG/w8hQoD/I4MgUz6rygA==: QQQhAS8hA7yiAAAhAA== vs QQQhAS8hA7yiAAAhB+POSWfBCAE=

Related to #2844.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-09-05 23:44:14 +03:00
Roman Khimov
4c015b30d5 neotest: improve doc based on #3120
We don't want anyone to have the same problem.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-09-05 15:20:00 +03:00
Roman Khimov
7cedcb9197 neotest: fix NewSingleSigner description, fix #3118
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-09-05 12:36:49 +03:00
Roman Khimov
fff7e91709 dao: simplify NewSimple()
We no longer need P2PSigExtension flag here, conflicts attribute is a part
of the normal protocol.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-09-04 16:56:59 +03:00
Anna Shaleva
f3c1283ac6 *: move NVB and Conflicts attributes out of extensions
They're a part of the regular protocol now.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-09-04 16:39:44 +03:00
Tatiana Nesterenko
259cbc3356 vm: add address&swap endianness to opcode dump for hashes
If the parameter in the opcode dump is a 20-byte value, the converted values,
such as the address and the swapped endianness, have been added.

Signed-off-by: Tatiana Nesterenko <tatiana@nspcc.io>
2023-09-04 08:41:22 +01:00
Roman Khimov
5180305240
Merge pull request #3117 from nspcc-dev/3070-unwrap-nothing
Add `unwrap.Nothing` function
2023-09-04 08:49:14 +03:00
Tatiana Nesterenko
59f72429b4 dbconfig: fix DBConfiguration description
The list of three supported types (`Type`) in the `DBConfiguration` struct
has been added.

Signed-off-by: Tatiana Nesterenko <tatiana@nspcc.io>
2023-09-03 18:02:38 +01:00
Tatiana Nesterenko
acd821948f unwrap: add Nothing function
The `Nothing` function expects zero stack items and a successful invocation
(HALT state).

Signed-off-by: Tatiana Nesterenko <tatiana@nspcc.io>
2023-09-03 16:54:50 +01:00
Tatiana Nesterenko
d06f135792 rpcclient: support getrawnotarytransaction and getrawnotarypool RPC methods
GetRawNotaryTransaction returns a fallback or main transaction that was
previously added to the memory pool by P2PNotaryRequest. This function
invokes the RPC server's `getrawnotarytransaction` method.
GetRawNotaryPool returns hashes from all the verified transactions,
including both main and fallback transactions. This function invokes
the RPC server's `getrawnotarypool` method.

Also, these functions were added to doc.go.

Signed-off-by: Tatiana Nesterenko <tatiana@nspcc.io>
2023-08-31 18:51:43 +01:00
Tatiana Nesterenko
9e31e42bd9 rpcsrv: add getrawnotarypool, getrawnotarytransaction handlers
`getrawnotarytransaction` takes a transaction hash and attempts to find
the corresponding transaction in the notary requests mempool. It searches
through all the verified main and fallback transactions.
`getrawnotarypool` returns hashes of all the verified transactions,
including both main and fallback transactions.

Additionally add struct result.RawNotaryPool.

Close https://github.com/nspcc-dev/neo-go/issues/2951

Signed-off-by: Tatiana Nesterenko <tatiana@nspcc.io>
2023-08-31 18:51:43 +01:00
Tatiana Nesterenko
d285342d54 core: add function IterateVerifiedTransactions
IterateVerifiedTransactions iterates through verified transactions in
memory pool and invokes function cont. Where cont callback returns
whether we should continue with the traversal process.

Signed-off-by: Tatiana Nesterenko <tatiana@nspcc.io>
2023-08-31 18:51:43 +01:00
Roman Khimov
5463a91edc
Merge pull request #3111 from nspcc-dev/rpcsrv-drop-unused-iface
rpcsrv: drop unused method from the Ledger interface
2023-08-30 10:55:23 +03:00
Roman Khimov
4a648692a2 rpcsrv: drop unused method from the Ledger interface
Inspired by #3110.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-08-29 22:33:26 +03:00
Roman Khimov
ad24aad9c0
Merge pull request #3108 from nspcc-dev/create-fallback-copy
notary: avoid changing pooled fallback transaction witnesses
2023-08-29 16:16:24 +03:00
Anna Shaleva
c63289a564 notary: avoid changing pooled fallback transaction witnesses
Forbid Notary service to change the fallback's witnesses in any way.
Fix the problem described in review comment:
https://github.com/nspcc-dev/neo-go/pull/3098#discussion_r1308336339.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-29 16:06:40 +03:00
Anna Shaleva
b89078c42a rpcsrv: set MaxNEP11Tokens to default if not specified
Do not use RPC configuration constructor for this, some external services
may skip this part.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-29 13:26:10 +03:00
Anna Shaleva
f5b0489d74 rpcsrv: set MaxFindStorageResultItems to default if not specified
Do not use RPC configuration constructor for this, some external services
may skip this part.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-29 13:26:10 +03:00
Anna Shaleva
dd7c762ff9 rpcsrv: set MaxFindResultItems to default if not specified
Do not use RPC configuration constructor for this, some external services
may skip this part.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-29 13:26:10 +03:00
Anna Shaleva
aeb7ee1021 rpcsrv: improve error formatting
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-29 13:26:05 +03:00
Anna Shaleva
97a57de82d rpcsrv: set MaxIteratorResultItems to default if not specified
Do not use RPC configuration constructor for this, some external services
may skip this part.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-29 13:19:39 +03:00
Anna Shaleva
5d3938ae23 core: adjust hardfork enabling logic
Follow the logic described in https://github.com/neo-project/neo/pull/2886#issuecomment-1674745298
and port the https://github.com/neo-project/neo/pull/2886.

Close #3096.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-25 18:24:15 +03:00
Anna Shaleva
7b64b693bd rpcsrv: refactor findstoragehistoric handler to avoid DoS attack
Do not retrieve the whole set of storage items when trying to find
the ones from the specified start. Use DAO's Seek interface
implemented over MPT TrieStore to retrieve only the necessary items.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-24 17:15:59 +03:00
Anna Shaleva
1fb0c96e2c rpcsrv, rpcclient: support getstoragehistoric call
Make it similar to `findstoragehistoric`.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-24 17:15:59 +03:00
Anna Shaleva
617c628c24 rpcsrv, rpcclient: support findstorage and findstoragehistoric
Close #3095 and add the corresponding historic extension.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-24 17:15:58 +03:00
Anna Shaleva
124c3df2ff rpcsrv: rename testcases related to unsupported state
Testcase name should match the test purpose.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-22 19:54:07 +03:00
Roman Khimov
227b0c5480
Merge pull request #3041 from nspcc-dev/generic-decl
compiler: temporary disallow generics usages
2023-08-18 21:24:56 +03:00
Anna Shaleva
bb2a99d451 smartcontract: disallow Null and non-utf8 String
Follow the https://github.com/neo-project/neo/pull/2810#discussion_r1295900728.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-18 16:41:33 +03:00
Anna Shaleva
ed2c4b0319 core: improve error checks in TestNotify
Ensure that the error returned from runtime.Notify is exactly the error
that was expected.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-18 16:41:33 +03:00
Anna Shaleva
2872c1c668 core: move contract notifications check under HFBasilisk
Follow the https://github.com/neo-project/neo/pull/2884.
A part of the https://github.com/neo-project/neo/pull/2810.
Fix failing tests along the way (a lot of them have invalid notifications
format which differs from the one declared in manifest).

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-18 16:40:20 +03:00
Anna Shaleva
35c3b65c8a compiler: disallow generic type decl
Need to be reverted and properly handled within the scope of #2376.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-18 16:02:40 +03:00
Anna Shaleva
380de580a7 compiler: disallow generic function parameter types
Need to be reverted and properly handled within the scope of #2376.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-18 16:02:40 +03:00
Anna Shaleva
1b1b454ce4 compiler: disallow generic method receiver
Either non-pointer or pointer, both cases are disallowed to be generic.
Need to be reverted and properly handled within the scope of #2376.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-18 16:02:39 +03:00
Anna Shaleva
415d44792a compiler: properly retrieve name of generic functions
Fix panic described in #3040. Ref. #2376.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-18 16:00:54 +03:00
Anna Shaleva
87aaaf1a67 core: rename TestManagement_DeployUpdateHardfork
So that hardfork name was explicitly present in the test name. We'll
have a set of similar tests later.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-18 12:02:43 +03:00
Anna Shaleva
60795a899f smartcontract: improve invalid notification error text
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-18 12:02:43 +03:00
Roman Khimov
5c6a111d00
Merge pull request #3063 from tatiana-nspcc/rpcsrv-errors
RPC: add error codes and response errors
2023-08-16 17:38:18 +03:00
Tatiana Nesterenko
90f1b0fd17 core: change text in ErrInvalidVerificationContract
No functional changes, just a refactoring.
Change error text to be able to use this error from external packages.

Signed-off-by: Tatiana Nesterenko <tatiana@nspcc.io>
2023-08-16 14:16:14 +01:00
Tatiana Nesterenko
f3760c1a98 rpcsrv: return ErrUnknownSession and ErrUnknownIterator
Behaviour change.
`terminatesession` returns ErrUnknownSession in case of impossibility of finding session,
previously there was no-error response with `false` result.
`traverseIterator`returns ErrUnknownSession in case of impossibility of finding session,
previously there was no-error response with default result; `traverseIterator`returns ErrUnknownIterator,
there were no such errors before.
Accordingly to proposal:
https://github.com/neo-project/proposals/pull/156
Also adding description of `traverseIterator` in docs/rpc.md.

Signed-off-by: Tatiana Nesterenko <tatiana@nspcc.io>
2023-08-16 14:16:14 +01:00
Tatiana Nesterenko
f557959c24 rpcsrv: return error on invalid proof from verifyProof
This change makes code incompatible with C# node,
because currently no error is returned on invalid proof.
According to proposal:
https://github.com/neo-project/proposals/pull/156
Also adding `verifyProof` descpiption in docs/rpc.md.

Signed-off-by: Tatiana Nesterenko <tatiana@nspcc.io>
2023-08-16 14:00:24 +01:00
Tatiana Nesterenko
2598257628 core: rename ErrInvalidVerification and ErrInvalidInvocation
No functional changes, just a refactoring.
Use more specific and meaningful names to be able to use these errors from external packages.

Signed-off-by: Tatiana Nesterenko <tatiana@nspcc.io>
2023-08-16 14:00:24 +01:00
Tatiana Nesterenko
1e6372e6d9 rpcsrv: return error on unknown storage item from getstorage
Follow the reference implementation, the behaviour was changed in
237ef7d057.

Signed-off-by: Tatiana Nesterenko <tatiana@nspcc.io>
2023-08-16 14:00:24 +01:00
Tatiana Nesterenko
d3fe92de14 rpcsrv: remove default request HTTP codes from switch statement
No functional changes, just a refactoring.

Signed-off-by: Tatiana Nesterenko <tatiana@nspcc.io>
2023-08-16 14:00:24 +01:00
Tatiana Nesterenko
3b29720298 neorpc: add deprecated error codes for C#-compatibility
While our server no longer uses these codes (-100, -400) they still can come
from C# servers and while we consider them deprecated we better at least have
some definition of them until C# implements our proposal:
https://github.com/neo-project/proposals/pull/156
Also adding description of deprecated RPC error codes in ROADMAP.md.

Signed-off-by: Tatiana Nesterenko <tatiana@nspcc.io>
2023-08-16 13:59:39 +01:00
Tatiana Nesterenko
31ceb568cb neorpc: add error codes and response errors
According to proposal:
https://github.com/neo-project/proposals/pull/156

Close #2248

Signed-off-by: Tatiana Nesterenko <tatiana@nspcc.io>
2023-08-16 13:59:33 +01:00
Tatiana Nesterenko
3abddc78c0 core: split ErrAlreadyExists into ErrAlreadyExists and ErrAlreadyInPool
ErrAlreadyExists is in blockchain and ErrAlreadyInPool is in mempool.

Signed-off-by: Tatiana Nesterenko <tatiana@nspcc.io>
2023-08-16 12:36:56 +01:00
Anna Shaleva
d1fe64470d compiler: fix sequence point boundaries
Thanks to @fyrchik, see the
https://github.com/neo-project/neo-devpack-dotnet/pull/154/files#diff-ebf53d00d5ba1f1197fedd2b8111fe9a8f44fb96699ef1314d54d05d5ceeb3f3R27

See also the standard:
https://github.com/neo-project/proposals/blob/master/nep-19.mediawiki#method.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-11 20:16:02 +03:00
Anna Shaleva
16d1d1e5eb rpcbinding: check duplicating struct fields before binding generation
RPC binding config may be malformed or the source .go contract may contain
structures like this:
```
type Str struct {
    Field int
    field int
}
```
We need to recognise these cases and return error. otherwise the resulting
binding can't be compiled.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-11 17:48:54 +03:00
Anna Shaleva
b2f84c83b3 rpcbinding: reuse upperFirst helper where possible
No functional changes.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-11 15:32:00 +03:00
Anna Shaleva
1356721862 rpcbinding: export any unexported fields of structures/events
Perform private -> public transformation at the last step of RPC binding
generation so that it works not only with NeoGo contracts, but with any
other contracts.

Close #3083.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-11 15:31:08 +03:00
Anna Shaleva
624f193f94 vm: move JNumbers parsing precision under HFBasilisk
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-10 13:14:16 +03:00
Anna Shaleva
d90608ddbf vm: increase BigInt parsing precision
Follow the https://github.com/neo-project/neo/pull/2883.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-10 13:14:16 +03:00
Anna Shaleva
158d8e69a4 vm: update VM json tests path
It was changed way back in 5a11f4b4ca.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-10 12:54:07 +03:00
Anna Shaleva
5b12be2ac7 compiler: add test for util.AbortMsg and util.AssertMsg
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-10 12:54:07 +03:00
Anna Shaleva
11bb733f1a interop: support ABORTMSG, ASSERT, ASSERTMSG opcodes
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-10 12:41:30 +03:00
Anna Shaleva
e7f77e052f vm: add ABORTMSG and ASSERTMSG opcodes
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-10 12:41:30 +03:00
Roman Khimov
2493400525
Merge pull request #3085 from nspcc-dev/fix-oracle-instance 2023-08-10 12:02:26 +03:00
Anna Shaleva
c39153756a rpcsrv: carefully store Oracle service
And simplify atomic service value stored by RPC server. Oracle service can
either be an untyped nil or be the proper non-nil *oracle.Oracle.
Otherwise `submitoracleresponse` RPC handler doesn't work properly.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-10 10:12:01 +03:00
Anna Shaleva
50ee241377 core: move strict script check on deploy under HF condition
Follow the https://github.com/neo-project/neo/pull/2881.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-09 18:32:30 +03:00
Anna Shaleva
bd937bc500 Revert "core: remove contract script check on deploy/update"
This reverts commit 762a8da76a.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-09 18:30:47 +03:00
Anna Shaleva
50a77f3fae rpcclient: fix test after 0.101.4 merge
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-02 10:35:19 +03:00
Anna Shaleva
18c42f7993
Merge branch 'master' into rel-0.101.4
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-01 19:34:34 +03:00
Anna Shaleva
e2c6bbb6b1 rpcsrv: properly set content-type and CORS for all headers
Not only for successful ones. Close #3075.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-01 17:47:48 +03:00
Anna Shaleva
8d5a41de6e vm: allow parsing scientific JSON numbers
52-bit precision is not enough for our 256-bit VM, but this value
matches the reference implementation, see the
https://github.com/neo-project/neo/issues/2879.

MaxIntegerPrec will be increased (or even removed) as soon as the
ref. issue is resolved.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-01 17:46:56 +03:00
Anna Shaleva
6615cce81d rpcclient: adjust unwrapContract helper
There may be no such contract, then Null stackitem is expected on stack.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-01 17:46:12 +03:00
Anna Shaleva
c0abc61613 smartcontract: allow to pass nil as parameter to (*Invoker).Call
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-01 17:45:52 +03:00
Anna Shaleva
bf871760c6 core: do not use formatted error if not needed
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-01 17:44:48 +03:00
Anna Shaleva
96aa10bb80 neorpc: adjust the way SignerWithWitness is marshalled
Marshal account with `0x` prefix and add a test.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-01 17:44:43 +03:00
Anna Shaleva
8db997c58a neorpc: adjust SignerWithWitness scopes parsing
Ensure that Scopes can be properly parsed not only from the string
representation, but also from a single byte. transaction.Signer
is not affected (checked against the C# implementation), only
RPC-related signer scopes are allowed to be unmarshalled from byte.

Close #3059.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-01 17:44:37 +03:00
Anna Shaleva
e30e262e66 network: forbid Notary contract to be a sender of main transaction
This prevents the possible attack on notary request sender when
malicious partie is allowed to send notary request with main transaction
being someone else's fallback.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-01 17:44:24 +03:00
Anna Shaleva
d560395985 core: prevent direct access to Notary contract if not active
Otherwise it will cause panic, which isn't expected behaviour.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-01 17:30:11 +03:00
Anna Shaleva
2c984e2393 core: initialize natives cache wrt NativeActivations
If the contract was deployed then cache must be initialized after
in-memory data reset. If the contract isn't active yet, then no
cache will be initialized on deploy (i.e. on call to Initialize()
method by native Management).

Close #2984.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-01 17:30:05 +03:00
Anna Shaleva
d0718a680f core: add InitializeCache method to Contract interface
Make the contracts cache initialization unified. The order of cache
iniitialization is not important and Nottary contract is added to the
bc.contracts.Contracts wrt P2PSigExtensions setting, thus no functional
changes, just refactoring for future applications.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-01 17:30:01 +03:00
Anna Shaleva
97b93c6833 *: adjust Prometheus metrics initialisation on node start
Initialize Prometheus metrics on node start where appropriate and review
the usage of the following metrics:
```
anna@kiwi:~/Documents/GitProjects/nspcc-dev/neo-go$ find | grep prometheus.go
./pkg/network/prometheus.go
./pkg/core/stateroot/prometheus.go
./pkg/core/prometheus.go
./pkg/services/rpcsrv/prometheus.go
./pkg/services/metrics/prometheus.go
```

Close #2970.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-01 17:29:36 +03:00
Roman Khimov
288dee8871 rpcclient: close subscriber channels on wsReader exit
The reader is about to exit and it will close legacy c.Notifications, but it
will leave subscription channels at the same time. This is wrong since these
channels will no longer receive any new events, game over.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-08-01 17:29:14 +03:00
Roman Khimov
08b273266b rpcclient: correctly handle request channel closure
wsReader() closes c.done first and then goes over the list of
c.respChannels. Technically this means that any of the two can be taken in
this select.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-08-01 17:29:08 +03:00
Leonard Lyubich
465d3f43d2 services/rpcsrv: Wait for subscription process to complete when stopped
Previously RPC server shutdown procedure listened to the execution
channel and stopped at the first element that arrived in the queue. This
could lead to the following problems:
 * stopper could steal the execution result from subscriber
 * stopper didn't wait for other subscription actions to complete

Add dedicated channel to `Server` for subscription routine. Close the
channel on `handleSubEvents` return and wait for signal in `Shutdown`.

Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
2023-08-01 17:27:21 +03:00
Leonard Lyubich
f8227aa5f7 services/rpcsrv: Fix potential shutdown deadlock of RPC server
Previously RPC server could never be shut down completely due to
some start precondition failure (in particular, inability to serve HTTP
on any configured endpoint). The problem was caused by next facts:
 * start method ran subscription routine after HTTP init succeeded only
 * stop method blocked waiting for the subscription routine to return

Run `handleSubEvents` routine on fresh `Start` unconditionally. With
this change, `Shutdown` method won't produce deadlock since
`handleSubEvents` closes wait channel.

Refs #2896.

Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
2023-08-01 17:27:11 +03:00
Leonard Lyubich
758c455c7e services/rpcsrv: Test Server shutdown with failed precondition
There is an existing problem with RPC server shutdown freeze after start
failure due to some init actions (at least HTTP listen) described in
#2896.

Add dedicated unit test which checks that `Shutdown` returns within 5s
after `Start` method encounters internal problems.

Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
2023-08-01 17:27:03 +03:00
Anna Shaleva
c880873105 core: improve documentation to SetOracle/SetNotary
I've carefully checked the way how new service can be added to the
Blockchain instance or to be removed from it. Current implemention
of SetNotary and SetOracle methods doesn't contain dangerous code,
and native contracts have atomic values everywhere where service
is stored.

Current implementation of Notary, Oracle and StateRoot services'
reload/disabling/enabling on SIGUSR1 is safe and doesn't require
any adjustment.

This commit closes #2944, it's not a bug in the code, it's just
stale documentation.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-01 17:26:17 +03:00
Anna Shaleva
d5f964f181 config: do not allow negative validators count
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-01 17:22:39 +03:00
Anna Shaleva
6cd0f78649 config: do not allow zero numbers for validators/committee history
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-01 17:22:33 +03:00
Anna Shaleva
56b93d279e config: use uint32 for validators/committee members count
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-01 17:22:28 +03:00
Anna Shaleva
7028930bd6 network: do not use error channel to start network srv
It's obsolete thing, we have looger and it perfectly suits our needs.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-01 17:22:01 +03:00
Anna Shaleva
01a5816f04 rpcsrv: properly set content-type and CORS for all headers
Not only for successful ones. Close #3075.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-01 16:12:53 +03:00
Roman Khimov
03b9b4a4a1
Merge pull request #3073 from nspcc-dev/fix-sci-jnum
JSON scientific numbers kludge
2023-08-01 15:06:32 +03:00
Anna Shaleva
4be692193e vm: allow parsing scientific JSON numbers
52-bit precision is not enough for our 256-bit VM, but this value
matches the reference implementation, see the
https://github.com/neo-project/neo/issues/2879.

MaxIntegerPrec will be increased (or even removed) as soon as the
ref. issue is resolved.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-07-31 17:19:05 +03:00
Anna Shaleva
e57967b11c rpcclient: adjust unwrapContract helper
There may be no such contract, then Null stackitem is expected on stack.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-07-28 18:51:25 +03:00
Roman Khimov
081f9d3ac5
Merge pull request #3061 from nspcc-dev/check-onchain-conflicts
core: check the signers of on-chained conflicting transaction during new transaction verification
2023-07-21 22:36:21 +03:00
Anna Shaleva
ee4b8f883b core: check signers of on-chained conflict during new tx verification
During new transaction verification if there's an on-chain conflicting
transaction, we should check the signers of this conflicting transaction.
If the signers intersect with signers of the incoming transaction, then
the conflict is treated as valid and verification for new incoming
transaction should fail. Otherwise, the conflict is treated as the
malicious attack attempt and will not be taken into account;
verification for the new incoming transaction should continue.

This commint implements the scheme described at
https://github.com/neo-project/neo/pull/2818#issuecomment-1632972055,
thanks to @shargon for digging.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-07-21 17:27:47 +03:00
Anna Shaleva
0d17273476 core: fix formatted error on transaction verification
Witnesses are not yet created by the moment we return this error,
thus, it was always 0 as an actual number of witnesses in
ErrInvalidWitnessNum.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-07-21 13:50:20 +03:00
Anna Shaleva
0a2be89964 core: remove unused blockchain API
`(*Blockchain).HasTransaction` is one of the oldest methods in our
codebase, and currently it's completely unused. I also doubt that
this method works as expected because it returns `true` if transaction
in the mempool.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-07-21 13:37:02 +03:00
Anna Shaleva
c926d53869 smartcontract: allow to pass nil as parameter to (*Invoker).Call
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-07-21 13:19:25 +03:00
Roman Khimov
862c2e4ed3
Merge pull request #3060 from nspcc-dev/extend-rpc-signers
neorpc: adjust `SignerWithWitness` marshalling scheme
2023-07-20 17:27:23 +03:00
Anna Shaleva
966111f4a8 network: forbid Notary contract to be a sender of main transaction
This prevents the possible attack on notary request sender when
malicious partie is allowed to send notary request with main transaction
being someone else's fallback.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-07-20 10:56:48 +03:00
Anna Shaleva
8253025c90 core: do not use formatted error if not needed
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-07-20 10:33:50 +03:00
Anna Shaleva
165525b7e9 neorpc: adjust the way SignerWithWitness is marshalled
Marshal account with `0x` prefix and add a test.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-07-20 10:33:50 +03:00
Anna Shaleva
9f69522ff5 neorpc: adjust SignerWithWitness scopes parsing
Ensure that Scopes can be properly parsed not only from the string
representation, but also from a single byte. transaction.Signer
is not affected (checked against the C# implementation), only
RPC-related signer scopes are allowed to be unmarshalled from byte.

Close #3059.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-07-20 10:33:48 +03:00
Anna Shaleva
762a8da76a core: remove contract script check on deploy/update
This check is good and was present here since #1729, but it was
accidently removed from the reference implementation (see the
discussion in https://github.com/neo-project/neo/issues/2848). The
removal of this check from the C# node leaded to the T5 testnet state
diff since 1670095 heigh which causes inability to process new blocks
since 2272533 height (see #3049). This check was added back to the
C# node in https://github.com/neo-project/neo/pull/2849, but it is
planned to be the part of the upcoming 3.6.0 C# node release.

We need to keep our testnet healthy, thus, strict contract script
check will be temporary removed from the node code and is planned
to be added back to be a part of the next 3.6.0-compatible release.

Close #3049.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-07-08 11:49:31 +03:00
Anna Shaleva
6fa4bcdc1d core: remove contract script check on deploy/update
This check is good and was present here since #1729, but it was
accidently removed from the reference implementation (see the
discussion in https://github.com/neo-project/neo/issues/2848). The
removal of this check from the C# node leaded to the T5 testnet state
diff since 1670095 heigh which causes inability to process new blocks
since 2272533 height (see #3049). This check was added back to the
C# node in https://github.com/neo-project/neo/pull/2849, but it is
planned to be the part of the upcoming 3.6.0 C# node release.

We need to keep our testnet healthy, thus, strict contract script
check will be temporary removed from the node code and is planned
to be added back to be a part of the next 3.6.0-compatible release.

Close #3049.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-07-04 14:17:04 +03:00
Roman Khimov
70aed34d77 interop/contract: fix state rollbacks for nested contexts
Our wrapping optimization relied on the caller context having a TRY block,
but each context (including internal calls!) has an exception handling stack
of its own, which means that for an invocation stack of

    entry
    A.someMethodFromEntry()   # this one has a TRY
    A.internalMethodViaCALL() # this one doesn't
    B.someMethod()

we get `HasTryBlock() == false` for `A.internalMethodViaCALL()` context, which
leads to missing wrapper and missing rollbacks if B is to THROW. What this
patch does instead is it checks for any context within contract boundaries.

Fixes #3045.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-06-29 11:58:12 +03:00
Anna Shaleva
84b00d46aa rpc: emit Null in case of Any parameter with zero-len value
Otherwise it leads to the following error in the TestActor_CallWithNilParam:
```
=== RUN   TestActor_CallWithNilParam
    logger.go:130: 2023-04-03T15:58:27.672+0300	INFO	initial gas supply is not set or wrong, setting default value	{"InitialGASSupply": "52000000"}
    logger.go:130: 2023-04-03T15:58:27.672+0300	INFO	P2PNotaryRequestPayloadPool size is not set or wrong, setting default value	{"P2PNotaryRequestPayloadPoolSize": 1000}
    logger.go:130: 2023-04-03T15:58:27.672+0300	INFO	MaxBlockSize is not set or wrong, setting default value	{"MaxBlockSize": 262144}
    logger.go:130: 2023-04-03T15:58:27.672+0300	INFO	MaxBlockSystemFee is not set or wrong, setting default value	{"MaxBlockSystemFee": 900000000000}
    logger.go:130: 2023-04-03T15:58:27.672+0300	INFO	MaxTransactionsPerBlock is not set or wrong, using default value	{"MaxTransactionsPerBlock": 512}
    logger.go:130: 2023-04-03T15:58:27.672+0300	INFO	MaxValidUntilBlockIncrement is not set or wrong, using default value	{"MaxValidUntilBlockIncrement": 5760}
    logger.go:130: 2023-04-03T15:58:27.675+0300	INFO	no storage version found! creating genesis block
    logger.go:130: 2023-04-03T15:58:27.675+0300	INFO	ExtensiblePoolSize is not set or wrong, using default value	{"ExtensiblePoolSize": 20}
    logger.go:130: 2023-04-03T15:58:27.675+0300	INFO	SessionPoolSize is not set or wrong, setting default value	{"SessionPoolSize": 20}
    logger.go:130: 2023-04-03T15:58:27.675+0300	INFO	MaxWebSocketClients is not set or wrong, setting default value	{"MaxWebSocketClients": 64}
    logger.go:130: 2023-04-03T15:58:27.675+0300	INFO	starting rpc-server	{"endpoint": "localhost:0"}
    logger.go:130: 2023-04-03T15:58:27.677+0300	DEBUG	done processing headers	{"headerIndex": 1, "blockHeight": 0, "took": "436.313µs"}
    logger.go:130: 2023-04-03T15:58:27.679+0300	DEBUG	done processing headers	{"headerIndex": 2, "blockHeight": 1, "took": "272.891µs"}
    logger.go:130: 2023-04-03T15:58:27.680+0300	DEBUG	done processing headers	{"headerIndex": 3, "blockHeight": 2, "took": "276.949µs"}
    logger.go:130: 2023-04-03T15:58:27.681+0300	DEBUG	done processing headers	{"headerIndex": 4, "blockHeight": 3, "took": "286.028µs"}
    logger.go:130: 2023-04-03T15:58:27.681+0300	DEBUG	done processing headers	{"headerIndex": 5, "blockHeight": 4, "took": "268.673µs"}
    logger.go:130: 2023-04-03T15:58:27.681+0300	INFO	bad notification	{"contract": "565cff9508ebc75aadd7fe59f38dac610ab6093c", "event": "Transfer", "error": "parameter 0 type mismatch: Hash160 vs ByteString"}
    logger.go:130: 2023-04-03T15:58:27.682+0300	DEBUG	done processing headers	{"headerIndex": 6, "blockHeight": 5, "took": "380.988µs"}
    logger.go:130: 2023-04-03T15:58:27.683+0300	DEBUG	done processing headers	{"headerIndex": 7, "blockHeight": 6, "took": "273.543µs"}
    logger.go:130: 2023-04-03T15:58:27.683+0300	DEBUG	done processing headers	{"headerIndex": 8, "blockHeight": 7, "took": "275.163µs"}
    logger.go:130: 2023-04-03T15:58:27.684+0300	DEBUG	done processing headers	{"headerIndex": 9, "blockHeight": 8, "took": "259.578µs"}
    logger.go:130: 2023-04-03T15:58:27.685+0300	DEBUG	done processing headers	{"headerIndex": 10, "blockHeight": 9, "took": "266.882µs"}
    logger.go:130: 2023-04-03T15:58:27.686+0300	DEBUG	done processing headers	{"headerIndex": 11, "blockHeight": 10, "took": "295.3µs"}
    logger.go:130: 2023-04-03T15:58:27.687+0300	DEBUG	done processing headers	{"headerIndex": 12, "blockHeight": 11, "took": "295.568µs"}
    logger.go:130: 2023-04-03T15:58:27.688+0300	DEBUG	done processing headers	{"headerIndex": 13, "blockHeight": 12, "took": "258.197µs"}
    logger.go:130: 2023-04-03T15:58:27.689+0300	DEBUG	done processing headers	{"headerIndex": 14, "blockHeight": 13, "took": "261.602µs"}
    logger.go:130: 2023-04-03T15:58:27.689+0300	DEBUG	done processing headers	{"headerIndex": 15, "blockHeight": 14, "took": "268.922µs"}
    logger.go:130: 2023-04-03T15:58:27.690+0300	DEBUG	done processing headers	{"headerIndex": 16, "blockHeight": 15, "took": "276.176µs"}
    logger.go:130: 2023-04-03T15:58:27.691+0300	DEBUG	done processing headers	{"headerIndex": 17, "blockHeight": 16, "took": "256.068µs"}
    logger.go:130: 2023-04-03T15:58:27.692+0300	DEBUG	done processing headers	{"headerIndex": 18, "blockHeight": 17, "took": "262.303µs"}
    logger.go:130: 2023-04-03T15:58:27.692+0300	DEBUG	done processing headers	{"headerIndex": 19, "blockHeight": 18, "took": "265.087µs"}
    logger.go:130: 2023-04-03T15:58:27.693+0300	DEBUG	done processing headers	{"headerIndex": 20, "blockHeight": 19, "took": "260.758µs"}
    logger.go:130: 2023-04-03T15:58:27.694+0300	DEBUG	done processing headers	{"headerIndex": 21, "blockHeight": 20, "took": "263.482µs"}
    logger.go:130: 2023-04-03T15:58:27.694+0300	DEBUG	done processing headers	{"headerIndex": 22, "blockHeight": 21, "took": "327.812µs"}
    logger.go:130: 2023-04-03T15:58:27.696+0300	DEBUG	done processing headers	{"headerIndex": 23, "blockHeight": 22, "took": "284.104µs"}
    logger.go:130: 2023-04-03T15:58:27.697+0300	WARN	contract invocation failed	{"tx": "82279bfe9bada282ca0f8cb8e0bb124b921af36f00c69a518320322c6f4fef60", "block": 23, "error": "at instruction 0 (ABORT): ABORT"}
    logger.go:130: 2023-04-03T15:58:27.697+0300	DEBUG	processing rpc request	{"method": "getversion", "params": "[]"}
    logger.go:130: 2023-04-03T15:58:27.698+0300	DEBUG	processing rpc request	{"method": "invokefunction", "params": "[565cff9508ebc75aadd7fe59f38dac610ab6093c putValue  ]"}
    client_test.go:2562:
        	Error Trace:	/home/anna/Documents/GitProjects/nspcc-dev/neo-go/pkg/services/rpcsrv/client_test.go:2562
        	Error:      	Should be true
        	Test:       	TestActor_CallWithNilParam
        	Messages:   	at instruction 6 (PACK): OPACK: invalid length
    logger.go:130: 2023-04-03T15:58:27.699+0300	INFO	shutting down RPC server	{"endpoint": "127.0.0.1:46005"}
    logger.go:130: 2023-04-03T15:58:27.700+0300	INFO	persisted to disk	{"blocks": 23, "keys": 1236, "headerHeight": 23, "blockHeight": 23, "took": "908.825µs"}
--- FAIL: TestActor_CallWithNilParam (0.03s)

FAIL
```

See also the ref. df534f6b0c/src/Neo/SmartContract/ContractParameter.cs (L141)
and the way how parameters are handled by ref. RPC server:
4b3a76e1b7/src/RpcServer/RpcServer.SmartContract.cs (L202)
and FromJSON implementation:
df534f6b0c/src/Neo/SmartContract/ContractParameter.cs (L70)
2023-06-29 11:51:40 +03:00
Roman Khimov
20b19d4599 interop/contract: fix state rollbacks for nested contexts
Our wrapping optimization relied on the caller context having a TRY block,
but each context (including internal calls!) has an exception handling stack
of its own, which means that for an invocation stack of

    entry
    A.someMethodFromEntry()   # this one has a TRY
    A.internalMethodViaCALL() # this one doesn't
    B.someMethod()

we get `HasTryBlock() == false` for `A.internalMethodViaCALL()` context, which
leads to missing wrapper and missing rollbacks if B is to THROW. What this
patch does instead is it checks for any context within contract boundaries.

Fixes #3045.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-06-29 11:35:10 +03:00
Anna Shaleva
31e2076810 native: move BLS12-381-related operations to a separate file
No functional changes, just refactoring.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-06-15 18:58:27 +03:00
Anna Shaleva
ea13fbe94a core: improve errors logging for bls12381-related operations
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-06-15 15:01:10 +03:00
Anna Shaleva
71bcb8bade native: allow to use EQUAL opcode for BLS12-381 points comparison
That's the way how C# node handles equality checks for stackitem.Interop types
for these points. Ref. https://github.com/nspcc-dev/neo-go/issues/3002#issuecomment-1591220501.

Along the way, add GT case for CryptoLib's bls12381Equal method. It should be there since #2940.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-06-15 15:00:27 +03:00
Anna Shaleva
0d470edf21 oracle: make use of ReadCloser returned from NeoFS's getters
Close #3032.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-06-06 17:40:19 +03:00
Anna Shaleva
4b2fc32462 oracle: update NeoFS SDK to 1.0.0-rc.9
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-06-06 11:47:24 +03:00