Commit graph

861 commits

Author SHA1 Message Date
Anna Shaleva
a033b212a3 rpc: bump getversion compat
Version 0.98.5 is officially released with the old behaviour. The same thing
as #2479.
2022-05-16 06:59:23 +03:00
Roman Khimov
e7a0722849 rpc: bump getversion compat again
Version 0.98.4 is officially released with the old behaviour. The same thing
as #2472.
2022-05-12 10:37:56 +03:00
Roman Khimov
bb0efed8b7 rpc: move latest getversion compat to 0.98.3
Version 0.98.3 is officially released with the old behavior.
2022-05-07 22:34:40 +03:00
Roman Khimov
7a2c7fa0bf
Merge pull request #2468 from nspcc-dev/rpc/improve-init
rpc: improve RPC Client initialization
2022-05-06 15:04:48 +03:00
Anna Shaleva
1782e16be4 rpc: improve RPC Client initialization
Thanks to #2463.
2022-05-06 14:15:59 +03:00
Anna Shaleva
ce35e69460 rpc: update testdata
Fix failing historic test.
2022-05-06 13:46:17 +03:00
Roman Khimov
75d06d18c9
Merge pull request #2466 from nspcc-dev/rules-fixes
Rules scope fixes
2022-05-06 11:09:39 +03:00
Roman Khimov
7b1943a6e5 rpc/server: return original error for invoke* param errors 2022-05-06 10:07:34 +03:00
Roman Khimov
740488f7f3
Merge pull request #2442 from EliChin/feature/eng_review
English Check
2022-05-05 17:12:37 +03:00
Elizaveta Chichindaeva
28908aa3cf [#2442] English Check
Signed-off-by: Elizaveta Chichindaeva <elizaveta@nspcc.ru>
2022-05-04 19:48:27 +03:00
Roman Khimov
930c439900 rpc: signal JSON marshalling errors through exception
See neo-project/neo-modules#696. Unmarshaller is left unchanged to be
compatible.
2022-05-04 13:13:21 +03:00
Anna Shaleva
aa886f67ce core: use dao-binded cache for native contracts
All native cached values are binded to DAO, so that it's possible
to properly handle historic calls.
2022-04-29 16:10:04 +03:00
Anna Shaleva
63c26ca270 core, rpc: support [invokefunction, invokescript, invokecontractverify]historic 2022-04-29 16:10:04 +03:00
Roman Khimov
ef93fd8cde
Merge pull request #2448 from nspcc-dev/rpc/fix-initialgas
rpc: support InitialGasDistribution response from older Neo-Go nodes
2022-04-27 23:13:24 +03:00
Anna Shaleva
9862b40f2c rpc: support InitialGasDistribution response from old Neo-Go nodes
https://github.com/nspcc-dev/neo-go/pull/2435 breaks compatibility
between newer RPC clients and older RPC servers with the following
error:
```
failed to get network magic: json: cannot unmarshal string into Go struct field Protocol.protocol.initialgasdistribution of type int64
```

This behaviour is expected, but we can't allow this radical change.
Thus, the following solution is implemented:
1. RPC server responds with proper non-stringified
   InitialGasDistribution value. The value represents an integral
   of fixed8 multiplied by the decimals.
2. RPC client is able to distinguish older and newer responses. For
   older one the stringified value without decimals part is
   expected. For newer responses the int64 value with decimal part
   is expected.

The cludge will be present in the code for a while until nodes of
version <=0.98.3 become completely absolete.
2022-04-27 19:00:46 +03:00
Anna Shaleva
c042c5bb63 Revert "rpc: adjust getversion RPC response"
This reverts commit 1c6afe402f.
2022-04-27 14:39:19 +03:00
Anna Shaleva
65dbe85ec5 rpc: avoid panic during request after WS connection is closed
Fix the following panic:
```
panic: assignment to entry in nil map

goroutine 131 [running]:
github.com/nspcc-dev/neo-go/pkg/rpc/client.(*WSClient).registerRespChannel(0xc00033c240, 0x0, 0xc00003e2a0)
        /home/denis/go/pkg/mod/github.com/nspcc-dev/neo-go@v0.98.2/pkg/rpc/client/wsclient.go:244 +0x96
github.com/nspcc-dev/neo-go/pkg/rpc/client.(*WSClient).makeWsRequest(0xc00033c240, 0xc002080000)
        /home/denis/go/pkg/mod/github.com/nspcc-dev/neo-go@v0.98.2/pkg/rpc/client/wsclient.go:264 +0x69
github.com/nspcc-dev/neo-go/pkg/rpc/client.(*Client).performRequest(0xc00033c240, {0xc9f173, 0xd}, {{0x13d09d0, 0x0, 0x0}}, {0xb44120, 0xc00147a000})
        /home/denis/go/pkg/mod/github.com/nspcc-dev/neo-go@v0.98.2/pkg/rpc/client/client.go:186 +0x15d
github.com/nspcc-dev/neo-go/pkg/rpc/client.(*Client).GetBlockCount(0xc001fb5440)
        /home/denis/go/pkg/mod/github.com/nspcc-dev/neo-go@v0.98.2/pkg/rpc/client/rpc.go:73 +0x69
...
```
2022-04-27 10:53:29 +03:00
Roman Khimov
a2126b92e1 rpc/server: only log errors during Shutdown
Sending them down the errChan is not really helpful and it can lead to
deadlock. If an error happens during node shutdown, we're exiting anyway, if
it happens during service restart, the old server will be dead irrespective of
this error (if this affects new one in any way we'll know it soon).
2022-04-26 00:31:48 +03:00
Roman Khimov
887fe0634d rpc: add StartWhenSynchronized option, fix #2433 2022-04-26 00:31:48 +03:00
Roman Khimov
2593bb0535 network: extend Service with Name, use it to distinguish services 2022-04-26 00:31:48 +03:00
Roman Khimov
a10b1ad32d rpc/server: make Server conform network.Service interface
With Start() and Shutdown() taking no parameters and returning no values.
2022-04-22 10:49:06 +03:00
Roman Khimov
4eee2f930e rpc/server: make double-start a no-op 2022-04-22 10:33:52 +03:00
Erik van den Brink
9fe3a86540
fix typo's 2022-04-20 14:00:12 +02:00
Anna Shaleva
1c6afe402f rpc: adjust getversion RPC response
Reference implementation includes `initialgasdistribution` as integer
value with decimals.

C# response:
```
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "nonce": 1677922561,
        "protocol": {
            "addressversion": 53,
            "initialgasdistribution": 5200000000000000,
            "maxtraceableblocks": 2102400,
            "maxtransactionsperblock": 512,
            "maxvaliduntilblockincrement": 5760,
            "memorypoolmaxtransactions": 50000,
            "msperblock": 15000,
            "network": 860833102,
            "validatorscount": 7
        },
        "tcpport": 10333,
        "useragent": "/Neo:3.1.0/",
        "wsport": 10334
    }
}
```

Neo-Go response:
```
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "network": 860833102,
        "nonce": 2847278838,
        "protocol": {
            "addressversion": 53,
            "initialgasdistribution": "52000000",
            "maxtraceableblocks": 2102400,
            "maxtransactionsperblock": 512,
            "maxvaliduntilblockincrement": 5760,
            "memorypoolmaxtransactions": 50000,
            "msperblock": 15000,
            "network": 860833102,
            "validatorscount": 7
        },
        "tcpport": 10333,
        "useragent": "/NEO-GO:0.98.2/"
    }
}
```
2022-04-14 13:51:30 +03:00
Anna Shaleva
850f56b367 rpc: avoid panic on double-call to *WSClient.Close()
Although it's the caller's duty to avoid WSClient re-closing, we
still can handle it.

Fixes the following neofs-node error:
```
panic: close of closed channel

goroutine 98 [running]:
github.com/nspcc-dev/neo-go/pkg/rpc/client.(*WSClient).Close(...)
        github.com/nspcc-dev/neo-go@v0.98.3-pre.0.20220321144433-3b639f518ebb/pkg/rpc/client/wsclient.go:120
github.com/nspcc-dev/neofs-node/pkg/morph/subscriber.(*subscriber).Close(0x13)
        github.com/nspcc-dev/neofs-node/pkg/morph/subscriber/subscriber.go:108 +0x29
github.com/nspcc-dev/neofs-node/pkg/morph/event.listener.Stop(...)
        github.com/nspcc-dev/neofs-node/pkg/morph/event/listener.go:573
created by github.com/nspcc-dev/neofs-node/pkg/innerring.(*Server).Stop
        github.com/nspcc-dev/neofs-node/pkg/innerring/innerring.go:285 +0x12f
```
2022-04-05 16:31:51 +03:00
Roman Khimov
2d60d4021b
Merge pull request #2413 from nspcc-dev/smartcontract-big-numbers
smartcontract: allow to use `*big.Int` numbers for integers
2022-04-01 10:38:33 +03:00
Evgeniy Stratonikov
0b0d39f797 smartcontract: allow to use *big.Int numbers for integers
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-04-01 08:38:34 +03:00
Anna Shaleva
889a7ec378 rpc: regenerate basic chain and adjust RPC server tests 2022-03-30 11:32:30 +03:00
Anna Shaleva
4a74c117ee *: refactor TestCreateBasicChain and its dependencies
Close #2355
2022-03-30 11:32:26 +03:00
Roman Khimov
9d5b8d606a server: quote method in logs, fix CodeQL warnings
CWE-117:
  Log entries created from user input

  If unsanitized user input is written to a log entry, a malicious user may be able to forge new log entries.
2022-03-22 16:05:06 +03:00
Roman Khimov
0a338ea94b rpc/server: register ws calls in Prometheus
They were completely missing.
2022-03-21 23:18:00 +03:00
Anna Shaleva
2096ad6e81 *: remove io/ioutil uses
Close #1764.
2022-03-17 19:39:18 +03:00
AnnaShaleva
3d5b1d8d17 rpc: add Rules signer scope to request parameters 2022-03-03 12:18:19 +03:00
AnnaShaleva
49e228ddf8 rpc: fix Client's GetOraclePrice 2022-03-01 19:08:22 +03:00
AnnaShaleva
92282c70cb *: support customisable NotaryServiceFeePerKey value
* Add corresponding methods to Notary contract.
* Extend RPC Client API.
* Adjust tests.
2022-03-01 19:08:16 +03:00
Anna Shaleva
1f255e756f rpc: add a note to RPC clients about thread-safeness 2022-02-24 19:01:21 +03:00
Anna Shaleva
2896c0a83a rpc: add test for concurrent WSClient access and request IDs generation 2022-02-24 19:01:21 +03:00
AnnaShaleva
0d8723527c rpc: refactor WSClient initialisation
Fix the following linter warning:
```
pkg/rpc/client/wsclient.go:99:18  govet  copylocks: literal copies lock value from *cl: github.com/nspcc-dev/neo-go/pkg/rpc/client.Client contains sync.RWMutex
```
2022-02-24 19:01:21 +03:00
AnnaShaleva
8991ee91cd rpc: make RPC WSClient thread-safe
Add ability to use unique request IDs for RPC requests.
2022-02-24 19:01:12 +03:00
AnnaShaleva
5b2e88b916 rpc: protect supscriptions of RPC WSClient from concurrent access 2022-02-22 15:40:08 +03:00
Anna Shaleva
d77f188d10 rpc: update native contract hashes inside (c *Client) GetNativeContracts() 2022-02-22 15:39:42 +03:00
AnnaShaleva
408f6b050e rpc: make RPC Client thread-safe 2022-02-22 15:37:00 +03:00
AnnaShaleva
0092330fe1 rpc: carefully review places where Client.cache.initDone is used
1. Keep initDone check only for the places where cache is directly accessed.
   We don't need to check it in other places, otherwise we have a mess of
   duplicating checks.
2. Fix bug in code related to block deserialisation. There's no magic, so
   checking that initialisation is done is not enough for proper block
   deserialisation. We need to manually fill StateRootEnabled field.
3. Since transaction doesn't need network magic to compute its hash, we don't
   need to perform Client initialisation before transaction-related requests.
4. Check that cache is initialised before accessing network magic.
5. Refactor the way Policy contract hash is fetched for Client requests.
   We don't really need Client initialisation for that, it's OK to fetch Policy
   hash on-the-fly.
2022-02-22 12:52:14 +03:00
AnnaShaleva
7c1862a9ac rpc: move all RPC client's cached fields to a separate cache structure
No functional changes.
2022-02-21 18:16:49 +03:00
Roman Khimov
075fd05bfc
Merge pull request #2356 from nspcc-dev/rpc-big-numbers
Allow to use big integers in RPC
2022-02-11 13:24:35 +03:00
Evgeniy Stratonikov
037076f2ee rpc/request: return error from ExpandArrayIntoScript if any
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-02-11 12:48:55 +03:00
Evgeniy Stratonikov
0394a79ef8 rpc: support big integers as request parameters
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-02-11 12:48:54 +03:00
Anna Shaleva
e306a90554 rpc: add NEP11-D tests to server and client
Also refactor basic chain creation.
2022-02-09 11:57:16 +03:00
Anna Shaleva
47652643df rpc: accept NEP11 token IDs as []byte for client methods
Accepting IDs as string is encoding-ambiguous, so make it []byte instead.
2022-02-09 11:55:07 +03:00
Roman Khimov
1df447cd68
Merge pull request #2334 from nspcc-dev/extendable-validators
Extendable validators
2022-02-01 12:09:56 +03:00