Commit graph

5723 commits

Author SHA1 Message Date
Roman Khimov
83f8ecf2e0
Merge pull request #2431 from nspcc-dev/rpc/historicall
rpc: support historic calls
2022-04-29 18:24:51 +03:00
Anna Shaleva
473955c2d6 core: use proper current block height/hash for interop API 2022-04-29 18:00:46 +03:00
Anna Shaleva
9cc41528ef core: avoid unnecessary NEO cached values copying 2022-04-29 16:10:04 +03:00
Anna Shaleva
335c1ee369 core: optimize access to NEO cache
Do not copy RW cache each block. Instead we should get RO cache and
change it only if there's a necessity.
2022-04-29 16:10:04 +03:00
Anna Shaleva
a6a0c1eb12 core: avoid lock copy in private DAO constructor
Fix the following linter warning:
```
pkg/core/dao/dao.go:101:7  govet  copylocks: assignment copies lock value to *d: github.com/nspcc-dev/neo-go/pkg/core/dao.Simple contains sync.RWMutex
```
2022-04-29 16:10:04 +03:00
Anna Shaleva
8d2d48f360 core: move native cache from MemCachedStore to DAO 2022-04-29 16:10:04 +03:00
Anna Shaleva
b77b412b04 core: refactor signature of (*NEO).dropCandidateIfZero
It never returns an error.
2022-04-29 16:10:04 +03:00
Anna Shaleva
c36448f27e core: don't reset NEO's registerPrice cache 2022-04-29 16:10:04 +03:00
Anna Shaleva
adec635f0e core: don't reset NEO's gasPerBlock cache 2022-04-29 16:10:04 +03:00
Anna Shaleva
35d160075d core: keep Policy cache always valid and up-to-date 2022-04-29 16:10:04 +03:00
Anna Shaleva
78b584053d core: keep Oracle cache always valid and up-to-date 2022-04-29 16:10:04 +03:00
Anna Shaleva
0f6bf33f86 core: keep Notary cache always valid and up-to-date 2022-04-29 16:10:04 +03:00
Anna Shaleva
27b0193da0 core: use native cache to check whether the same contract exists on deploy 2022-04-29 16:10:04 +03:00
Anna Shaleva
c0b490c7bf core: keep Management cache always valid and up-to-date 2022-04-29 16:10:04 +03:00
Anna Shaleva
11ab42d91c core: keep Designation cache always valid and up-to-date
Always use cache instead of DAO where possible. Update cache in-place
each time new designated node is chosen.
2022-04-29 16:10:04 +03:00
Anna Shaleva
c8bdd2ad1a core: remove Persist from NativeCache interface
Lower native cache should be assigned to the upper's value during persist.
2022-04-29 16:10:04 +03:00
Anna Shaleva
8ec8511d9d core: remove mutexes and atomic values from native cache
Native cache is always wrapped into independant layers, so concurrent
RW access is no-op.
2022-04-29 16:10:04 +03:00
Anna Shaleva
7b632c8ee8 core: refactor natives cache
1. Use layered natives cache. With layered cache the storeblock
process includes the following steps: create a wrapper over
current nativeCache, put changes into upper nativeCache layer,
persist (or discard) changes.
2. Split contract getters to read-only and read-and-change. Read-only
ones doesn't require the copy of an existing nativeCache item.
Read-and-change ones create a copy and after that change the copy.
2022-04-29 16:10:04 +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
812fa3f76a core: initialize NEO config cache in constructor
It isn't changed within the contract lifetime, thus initialisation can be
safely performed in constructor.
2022-04-29 16:10:04 +03:00
Anna Shaleva
e63d6aeff7 core: move natives cache initialisation to a separate method 2022-04-29 16:10:04 +03:00
Anna Shaleva
93fde3b4e6 core: fix typo in TestCreateBasicChain 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
Anna Shaleva
f8b5972f61 core: support Store interface over MPT 2022-04-29 16:10:04 +03:00
Anna Shaleva
0cf525d62e core: add ability to traverse backwards for Billet 2022-04-29 16:10:04 +03:00
Roman Khimov
3ae1647940
Merge pull request #2447 from nspcc-dev/gettransactionsigners
core: add GetTransactionSigners method to native Ledger
2022-04-29 11:58:38 +03:00
Anna Shaleva
1762fd9128 core: add test to check GetTransactionSigners interop API 2022-04-29 11:34:26 +03:00
Anna Shaleva
8ca8a825ef compiler: add compatibility test for GetTransactionSigners interop API 2022-04-29 11:34:22 +03:00
Anna Shaleva
18f8849713 examples: update neo-go dependency 2022-04-29 11:26:31 +03:00
Anna Shaleva
69b70c5e93 gomod: update interop dependency 2022-04-29 11:23:43 +03:00
Anna Shaleva
441a3eb34c interop: add API for getTransactionSigners Ledger's method 2022-04-29 11:22:21 +03:00
Anna Shaleva
47d52bd9c5 core: add getTransactionSigners method to native Ledger 2022-04-29 11:18:58 +03:00
Roman Khimov
e2ae572a9f
Merge pull request #2454 from nspcc-dev/fix-neo
core: remove voter reward per committee properly
2022-04-28 23:36:32 +03:00
Anna Shaleva
aaf7c423b4 core: remove voter reward per committee properly
(*Simple).Seek cuts search prefix, thus to remove voterRewardPerCommittee
we need to append it again to the height value. May affect dumps.
2022-04-28 17:15:18 +03:00
Roman Khimov
10acdbe40e
Merge pull request #2453 from nspcc-dev/check-policy-for-committee-members
Check policy for committee members
2022-04-28 12:58:07 +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
Roman Khimov
a8607e43b1 native: check candidates againt Policy blocked list
Follow neo-project/neo#2695 and neo-project/neo#2707.
2022-04-27 22:58:52 +03:00
Roman Khimov
bf3415e2bc emit: introduce CheckSig function
Which allows to create verification scripts without keys.PublicKey which is
convenient in some cases where we already have serialized key and don't want
to waste time decompressing it.
2022-04-27 22:57:10 +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
Roman Khimov
b8edf4ac73
Merge pull request #2450 from nspcc-dev/fix-ws
rpc: avoid panic during WSClient request after WS connection is closed
2022-04-27 17:02:45 +03:00
Anna Shaleva
c042c5bb63 Revert "rpc: adjust getversion RPC response"
This reverts commit 1c6afe402f.
2022-04-27 14:39:19 +03:00
Roman Khimov
9ad9700aef
Merge pull request #2452 from nspcc-dev/fix-rules
core: consider Rules witness scope as valid
2022-04-27 12:54:14 +03:00
Anna Shaleva
35d930951c core: consider Rules witness scope as valid 2022-04-27 12:48:33 +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
8983d25f7f
Merge pull request #2445 from nspcc-dev/rpc-when-sync
Add StartWhenSynchronized option for RPC server
2022-04-26 14:20:00 +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
53423b7c37 network: fix panic in blockqueue during shutdown
panic: send on closed channel

goroutine 116 [running]:
github.com/nspcc-dev/neo-go/pkg/network.(*blockQueue).putBlock(0xc00011b650, 0xc01e371200)
        github.com/nspcc-dev/neo-go/pkg/network/blockqueue.go:129 +0x185
github.com/nspcc-dev/neo-go/pkg/network.(*Server).handleBlockCmd(0xc0002d3c00, {0xf69b7f?, 0xc001520010?}, 0xc02eb44000?)
        github.com/nspcc-dev/neo-go/pkg/network/server.go:607 +0x6f
github.com/nspcc-dev/neo-go/pkg/network.(*Server).handleMessage(0xc0002d3c00, {0x121f4c8?, 0xc001528000?}, 0xc01e35cf80)
        github.com/nspcc-dev/neo-go/pkg/network/server.go:1160 +0x6c5
github.com/nspcc-dev/neo-go/pkg/network.(*TCPPeer).handleIncoming(0xc001528000)
        github.com/nspcc-dev/neo-go/pkg/network/tcp_peer.go:189 +0x98
created by github.com/nspcc-dev/neo-go/pkg/network.(*TCPPeer).handleConn
        github.com/nspcc-dev/neo-go/pkg/network/tcp_peer.go:164 +0xcf
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
f65c638be4
Merge pull request #2446 from nspcc-dev/fix-stateroot
core: fix broken stateroot storage
2022-04-23 00:35:28 +03:00