Commit graph

5062 commits

Author SHA1 Message Date
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