Commit graph

4355 commits

Author SHA1 Message Date
Anna Shaleva
ce226f6b76 vm: optimize context wrapping code
We can omit DAO wrapping for safe methods and for those methods that are not
wrapped into try-catch block. However, we still need to persist
notificationsCount changes for these methods to the parent context.
2022-05-26 09:26:31 +03:00
Anna Shaleva
0cd19f550e core, vm: implement snapshot isolation
Initial implementation without optimisations, but it should work.
2022-05-26 09:26:25 +03:00
Roman Khimov
c6666c52bc
Merge pull request #2515 from nspcc-dev/interop-marshalling
vm: stringify InteropInterface stackitem type as `InteropInterface`
2022-05-25 13:38:26 +03:00
Anna Shaleva
a3285eae04 vm: stringify InteropInterface stackitem type as InteropInterface 2022-05-25 13:20:21 +03:00
Anna Shaleva
98b5e2b353 rpc: always marshal FaultException 2022-05-25 10:48:58 +03:00
Roman Khimov
f77a775e61 core: raise System.Runtime.GetNotifications fee
Fix DoS, follow neo-project/neo#2748.
2022-05-24 17:45:23 +03:00
Roman Khimov
c9ab553e5b
Merge pull request #2510 from nspcc-dev/rpc/ws-errors
rpc: add ability to get WSClient connection closure error
2022-05-24 13:15:40 +03:00
Anna Shaleva
19646e0967 rpc: add ability to get WSClient connection closure error
Close #2421.
2022-05-24 11:29:19 +03:00
Anna Shaleva
d8f7d5d5b6 core: adjust Signer to stackitem conversion
Follow the https://github.com/neo-project/neo/pull/2708.
2022-05-23 14:01:42 +03:00
Anna Shaleva
b840674433 neotest: return failed tx hash
It still may be useful for debugging and tests.
2022-05-19 13:56:24 +03:00
Anna Shaleva
deb1f6d3d8 core: emit notification events in a separate method 2022-05-19 08:48:26 +03:00
Roman Khimov
73ef36e03e
Merge pull request #2507 from nspcc-dev/fix-ws-read
rpc: increase server-side WS read limit for websocket RPC message
2022-05-18 13:06:39 +03:00
Anna Shaleva
1a07d0f039 rpc: increase server-side WS read limit for websocket RPC message
Close #2505. Turns out that existing limit is too low to fit
`submitp2pnotaryrequest`.

Thanks to @alexvanin for discovering this.
2022-05-18 12:53:50 +03:00
Roman Khimov
34e7d3e53c
Merge pull request #2499 from nspcc-dev/fix-concurrent-seek
core: avoid concurrent map iteration and map write during SeekAsync over private MemCachedStore
2022-05-18 11:36:57 +03:00
Anna Shaleva
b66f666267 core: ensure memcached Seek operation is properly cancelled
PR #2495 is not enought, the problem is reproduced during dump restore
with the stacktrace attached down below.

The reason is that SeekAsync starts goroutine that performs Seek
operation over private MemCachedStore. The goroutine iterates over
MemCachedStore's map without holding the lock (it's OK, because it's
private), whereas the main thread continues invocation and
performs writes to the same map. To fix that ic.Exec() needs to
wait until all goroutines are properly exited.

```
2022-05-17T08:34:50.430+0300	INFO	persisted to disk	{"blocks": 632, "keys": 16546, "headerHeight": 54091, "blockHeight": 54091, "took": "57.904387ms"}
fatal error: concurrent map iteration and map write

goroutine 218853 [running]:
runtime.throw({0xf56a31, 0x614968})
	runtime/panic.go:1198 +0x71 fp=0xc0000ceae0 sp=0xc0000ceab0 pc=0x4357b1
runtime.mapiternext(0x0)
	runtime/map.go:858 +0x4eb fp=0xc0000ceb50 sp=0xc0000ceae0 pc=0x40f82b
runtime.mapiterinit(0xc0000cec18, 0xc00359ca40, 0x1a)
	runtime/map.go:848 +0x236 fp=0xc0000ceb70 sp=0xc0000ceb50 pc=0x40f2f6
github.com/nspcc-dev/neo-go/pkg/core/storage.(*MemCachedStore).prepareSeekMemSnapshot(0xc005315680, {{0xc00359ca40, 0x1a, 0x1a}, {0x0, 0x0, 0x0}, 0x0})
	github.com/nspcc-dev/neo-go/pkg/core/storage/memcached_store.go:209 +0x24a fp=0xc0000ced88 sp=0xc0000ceb70 pc=0x823fca
github.com/nspcc-dev/neo-go/pkg/core/storage.(*MemCachedStore).Seek(0xd94ac0, {{0xc00359ca40, 0x1a, 0x1a}, {0x0, 0x0, 0x0}, 0x0}, 0x20)
	github.com/nspcc-dev/neo-go/pkg/core/storage/memcached_store.go:156 +0x9b fp=0xc0000cee20 sp=0xc0000ced88 pc=0x82369b
github.com/nspcc-dev/neo-go/pkg/core/storage.performSeek({0x11c3330, 0xc002240dc0}, {0x11cb258, 0xc005315680}, {0x0, 0x0, 0x1}, {{0xc00359ca40, 0x1a, 0x1a}, ...}, ...)
	github.com/nspcc-dev/neo-go/pkg/core/storage/memcached_store.go:304 +0x4b7 fp=0xc0000cef00 sp=0xc0000cee20 pc=0x824a37
github.com/nspcc-dev/neo-go/pkg/core/storage.(*MemCachedStore).SeekAsync.func1()
	github.com/nspcc-dev/neo-go/pkg/core/storage/memcached_store.go:176 +0x16c fp=0xc0000cefe0 sp=0xc0000cef00 pc=0x823b8c
runtime.goexit()
	runtime/asm_amd64.s:1581 +0x1 fp=0xc0000cefe8 sp=0xc0000cefe0 pc=0x468a41
created by github.com/nspcc-dev/neo-go/pkg/core/storage.(*MemCachedStore).SeekAsync
	github.com/nspcc-dev/neo-go/pkg/core/storage/memcached_store.go:175 +0x1f6

goroutine 1 [runnable]:
github.com/nspcc-dev/neo-go/pkg/core/mpt.MapToMPTBatch.func1(0x4, 0x0)
	github.com/nspcc-dev/neo-go/pkg/core/mpt/batch.go:28 +0x95
sort.doPivot_func({0xc000457878, 0xc003305bc0}, 0x0, 0x1a)
	sort/zfuncversion.go:121 +0x46a
sort.quickSort_func({0xc000457878, 0xc003305bc0}, 0xc001014d20, 0x0, 0xc003304ff0)
	sort/zfuncversion.go:143 +0x85
sort.Slice({0xd94800, 0xc001014d20}, 0x1a)
	sort/slice.go:20 +0x9f
github.com/nspcc-dev/neo-go/pkg/core/mpt.MapToMPTBatch(0xc003304ff0)
	github.com/nspcc-dev/neo-go/pkg/core/mpt/batch.go:28 +0x2e7
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).storeBlock(0xc000400280, 0xc000f178c0, 0xc005a04370)
	github.com/nspcc-dev/neo-go/pkg/core/blockchain.go:1136 +0xfef
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).AddBlock(0xc000400280, 0xc000f178c0)
	github.com/nspcc-dev/neo-go/pkg/core/blockchain.go:893 +0x755
github.com/nspcc-dev/neo-go/pkg/core/chaindump.Restore({0x11c3528, 0xc000400280}, 0xc350, 0x0, 0x4c221, 0xc000458710)
	github.com/nspcc-dev/neo-go/pkg/core/chaindump/dump.go:73 +0x2ca
github.com/nspcc-dev/neo-go/cli/server.restoreDB(0xc000410000)
	github.com/nspcc-dev/neo-go/cli/server/server.go:381 +0xcfa
github.com/urfave/cli.HandleAction({0xdbbfa0, 0x10a1078}, 0x7)
	github.com/urfave/cli@v1.22.5/app.go:524 +0xa8
github.com/urfave/cli.Command.Run({{0xf32b10, 0x7}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0xf4a41d, 0x1c}, {0x0, ...}, ...}, ...)
	github.com/urfave/cli@v1.22.5/command.go:173 +0x652
github.com/urfave/cli.(*App).RunAsSubcommand(0xc0001f7880, 0xc0001adce0)
	github.com/urfave/cli@v1.22.5/app.go:405 +0x9ec
github.com/urfave/cli.Command.startApp({{0xf2e982, 0x2}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0xf41af9, 0x16}, {0x0, ...}, ...}, ...)
	github.com/urfave/cli@v1.22.5/command.go:372 +0x6e9
github.com/urfave/cli.Command.Run({{0xf2e982, 0x2}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0xf41af9, 0x16}, {0x0, ...}, ...}, ...)
	github.com/urfave/cli@v1.22.5/command.go:102 +0x808
github.com/urfave/cli.(*App).Run(0xc0001f76c0, {0xc00012e000, 0x8, 0x8})
	github.com/urfave/cli@v1.22.5/app.go:277 +0x705
main.main()
	./main.go:19 +0x33

goroutine 66 [select]:
github.com/syndtr/goleveldb/leveldb/util.(*BufferPool).drain(0xc00027e1c0)
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/util/buffer_pool.go:209 +0xcd
created by github.com/syndtr/goleveldb/leveldb/util.NewBufferPool
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/util/buffer_pool.go:240 +0x19b

goroutine 67 [select]:
github.com/syndtr/goleveldb/leveldb.(*session).refLoop(0xc0002441e0)
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/session_util.go:189 +0x5bb
created by github.com/syndtr/goleveldb/leveldb.newSession
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/session.go:93 +0x2de

goroutine 85 [select]:
github.com/syndtr/goleveldb/leveldb.(*DB).compactionError(0xc0001f7a40)
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/db_compaction.go:91 +0x15e
created by github.com/syndtr/goleveldb/leveldb.openDB
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/db.go:148 +0x4ef

goroutine 86 [select]:
github.com/syndtr/goleveldb/leveldb.(*DB).mpoolDrain(0xc0001f7a40)
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/db_state.go:101 +0xae
created by github.com/syndtr/goleveldb/leveldb.openDB
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/db.go:149 +0x531

goroutine 87 [runnable]:
github.com/syndtr/goleveldb/leveldb.(*compaction).shouldStopBefore(0xc001787440, {0xc001890720, 0x29, 0x30})
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/session_compaction.go:272 +0x10a
github.com/syndtr/goleveldb/leveldb.(*tableCompactionBuilder).run(0xc0001ca140, 0xc002039638)
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/db_compaction.go:461 +0x565
github.com/syndtr/goleveldb/leveldb.(*DB).compactionTransact(0xc0001f7a40, {0xf369f0, 0xb}, {0x11b9b60, 0xc0001ca140})
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/db_compaction.go:186 +0x22f
github.com/syndtr/goleveldb/leveldb.(*DB).tableCompaction(0xc0001f7a40, 0xc001787440, 0x0)
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/db_compaction.go:580 +0xa30
github.com/syndtr/goleveldb/leveldb.(*DB).tableAutoCompaction(0xc0001f7a40)
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/db_compaction.go:644 +0x39
github.com/syndtr/goleveldb/leveldb.(*DB).tCompaction(0xc0001f7a40)
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/db_compaction.go:863 +0x43b
created by github.com/syndtr/goleveldb/leveldb.openDB
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/db.go:155 +0x5a7

goroutine 88 [select]:
github.com/syndtr/goleveldb/leveldb.(*DB).mCompaction(0xc0001f7a40)
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/db_compaction.go:773 +0x119
created by github.com/syndtr/goleveldb/leveldb.openDB
	github.com/syndtr/goleveldb@v1.0.1-0.20210305035536-64b5b1c73954/leveldb/db.go:156 +0x5e9

goroutine 78 [select]:
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).Run(0xc000400280)
	github.com/nspcc-dev/neo-go/pkg/core/blockchain.go:615 +0x185
created by github.com/nspcc-dev/neo-go/cli/server.initBCWithMetrics
	github.com/nspcc-dev/neo-go/cli/server/server.go:217 +0x23d

goroutine 79 [IO wait]:
internal/poll.runtime_pollWait(0x7ffb00b2aad8, 0x72)
	runtime/netpoll.go:229 +0x89
internal/poll.(*pollDesc).wait(0xc00012e180, 0x4, 0x0)
	internal/poll/fd_poll_runtime.go:84 +0x32
internal/poll.(*pollDesc).waitRead(...)
	internal/poll/fd_poll_runtime.go:89
internal/poll.(*FD).Accept(0xc00012e180)
	internal/poll/fd_unix.go:402 +0x22c
net.(*netFD).accept(0xc00012e180)
	net/fd_unix.go:173 +0x35
net.(*TCPListener).accept(0xc000280090)
	net/tcpsock_posix.go:140 +0x28
net.(*TCPListener).Accept(0xc000280090)
	net/tcpsock.go:262 +0x3d
net/http.(*Server).Serve(0xc00027e380, {0x11bd4a8, 0xc000280090})
	net/http/server.go:3001 +0x394
net/http.(*Server).ListenAndServe(0xc00027e380)
	net/http/server.go:2930 +0x7d
github.com/nspcc-dev/neo-go/pkg/network/metrics.(*Service).Start(0xc000097d10)
	github.com/nspcc-dev/neo-go/pkg/network/metrics/metrics.go:29 +0x115
created by github.com/nspcc-dev/neo-go/cli/server.initBCWithMetrics
	github.com/nspcc-dev/neo-go/cli/server/server.go:218 +0x285

goroutine 9 [syscall]:
os/signal.signal_recv()
	runtime/sigqueue.go:169 +0x98
os/signal.loop()
	os/signal/signal_unix.go:24 +0x19
created by os/signal.Notify.func1.1
	os/signal/signal.go:151 +0x2c

goroutine 8 [select]:
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).notificationDispatcher(0xc000400280)
	github.com/nspcc-dev/neo-go/pkg/core/blockchain.go:739 +0x2e7
created by github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).Run
	github.com/nspcc-dev/neo-go/pkg/core/blockchain.go:612 +0xe5

goroutine 10 [chan receive]:
github.com/nspcc-dev/neo-go/cli/server.newGraceContext.func1()
	github.com/nspcc-dev/neo-go/cli/server/server.go:117 +0x28
created by github.com/nspcc-dev/neo-go/cli/server.newGraceContext
	github.com/nspcc-dev/neo-go/cli/server/server.go:116 +0xde
```
2022-05-18 07:35:48 +03:00
Roman Khimov
1e22024808
Merge pull request #2502 from nspcc-dev/fix-initsslot-refs
Fix INITSSLOT refs
2022-05-17 16:53:50 +03:00
Roman Khimov
ae2395f55f vm: simplify (slot).Set code
Refcounter handles nil items just fine.
2022-05-17 16:26:22 +03:00
Roman Khimov
f2f66ad36e vm: clear static slot refs on exit, fix #2501 2022-05-17 16:26:22 +03:00
Roman Khimov
7bda933e32
Merge pull request #2496 from nspcc-dev/fix-2484
rpc: differentiate log level for RPC errors
2022-05-17 14:57:59 +03:00
Anna Shaleva
33a0207bbb rpc: differentiate log level for RPC errors
Close #2484. Also, do not overuse InternalServerError.
2022-05-17 14:43:07 +03:00
Roman Khimov
711112ae40
Merge pull request #2485 from nspcc-dev/fix-rpc
rpc: check transaction for validness before network fee calculation
2022-05-17 11:34:11 +03:00
Roman Khimov
0d93b353e6 vm: count initial Null slot variables as well
Match C# behavior. Thanks to @ixje for finding this.
2022-05-16 17:42:57 +03:00
Roman Khimov
18d627e7f7 vm: count map key in the refcounter as well
Thanks @ixje for spotting this.
2022-05-16 16:07:25 +03:00
Anna Shaleva
c5c5e4c208 core: do not panic if transaction with empty script is being serialized
See https://github.com/nspcc-dev/neo-go/pull/2485#discussion_r872695786.

Allows to avoid panic:
```
(18:28:29)[sergio@transient:morph-control-load]% downloads/neofs-adm morph -c configuration/config.yaml init --contracts downloads/neofs-contract-v0.15.1
Stage 1: transfer GAS to alphabet nodes.
Waiting for transactions to persist...
Stage 2: set notary and alphabet nodes in designate contract.
Stage 2: already performed.
Stage 3: deploy NNS contract.
NNS contract is already deployed.
Stage 4: deploy NeoFS contracts.
Alphabet contract #0 is already deployed.
Alphabet contract #1 is already deployed.
Alphabet contract #2 is already deployed.
Alphabet contract #3 is already deployed.
audit contract is already deployed.
balance contract is already deployed.
container contract is already deployed.
neofsid contract is already deployed.
netmap contract is already deployed.
proxy contract is already deployed.
reputation contract is already deployed.
subnet contract is already deployed.
Waiting for transactions to persist...
Stage 4.1: Transfer GAS to proxy contract.
Stage 5: register candidates.
Stage 6: transfer NEO to alphabet contracts.
Stage 7: set addresses in NNS.
NNS: Set alphabet0.neofs -> 2efeb27866fa774ec6bfb43babaadcc7b28f9bb7
NNS: Set alphabet1.neofs -> 5606bc6598a538ac59ded3caa842247b9b26097a
NNS: Set alphabet2.neofs -> 2a8308cfd2706ddd5f67adfdf3954c6836806b5d
NNS: Set alphabet3.neofs -> 718d0459e6787f0f13f1e1898bf2ce6bc4bb452d
NNS: Set audit.neofs -> 54d516b36c3380efa2b2f26bda300b6c6302b8e7
NNS: Set balance.neofs -> 72b3255944524cb822788a7542c9d06cba208c0c
NNS: Set container.neofs -> 20a20f4352a49f161eccb7d5a806fd46dcab81ea
NNS: Set neofsid.neofs -> 04a3a71535689b820093cefe7ae188ed7591ad27
NNS: Set netmap.neofs -> 9a34c97b2ba6bd986fd9140a9c3d59059fa430f4
NNS: Set proxy.neofs -> 4eba34ec016f8709a511b02765a1195e31a921ea
NNS: Set reputation.neofs -> 77b5b2cf596957cc05ca3d57503ef08d72792301
NNS: Set subnet.neofs -> b0abe16bc7f56b2e7e0694ae2b36207c6aaa8636
panic: error serializing *transaction.Transaction: transaction has no script

goroutine 1 [running]:
github.com/nspcc-dev/neo-go/pkg/io.GetVarSize({0xbf6240, 0xc0003634a0})
	github.com/nspcc-dev/neo-go@v0.98.2/pkg/io/size.go:68 +0x6fd
github.com/nspcc-dev/neo-go/pkg/rpc/client.(*Client).AddNetworkFee(0xc0004080c0, 0xc0003634a0, 0x0, {0xc00000e248, 0x1, 0x93})
	github.com/nspcc-dev/neo-go@v0.98.2/pkg/rpc/client/rpc.go:966 +0x6b
github.com/nspcc-dev/neo-go/pkg/rpc/client.(*Client).CreateTxFromScript(0x0, {0x0, 0x0, 0x0}, 0x1, 0x0, 0x0, {0xc0001c7990, 0x1, 0x1})
	github.com/nspcc-dev/neo-go@v0.98.2/pkg/rpc/client/nep17.go:128 +0x345
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph.(*initializeContext).sendCommitteeTx(0xc00014a370, {0x0, 0x0, 0x0}, 0xc0016bcf30, 0x2)
	github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph/initialize.go:336 +0x131
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph.(*initializeContext).updateNNSGroup(0xc0001c7c88, {0x13, 0xd3, 0x6b, 0x85, 0x3e, 0x86, 0xbe, 0x77, 0xb7, ...}, ...)
	github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph/initialize_nns.go:89 +0x134
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph.(*initializeContext).setNNS(0xc00014a370)
	github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph/initialize_nns.go:74 +0x8c5
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph.initializeSideChainCmd(0x12a00e0, {0xc22a22, 0x4, 0x4})
	github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph/initialize.go:94 +0x2bc
github.com/spf13/cobra.(*Command).execute(0x12a00e0, {0xc00013a6c0, 0x4, 0x4})
	github.com/spf13/cobra@v1.1.3/command.go:852 +0x60e
github.com/spf13/cobra.(*Command).ExecuteC(0x129c760)
	github.com/spf13/cobra@v1.1.3/command.go:960 +0x3ad
github.com/spf13/cobra.(*Command).Execute(...)
	github.com/spf13/cobra@v1.1.3/command.go:897
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules.Execute(...)
	github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/root.go:48
main.main()
	github.com/nspcc-dev/neofs-node/cmd/neofs-adm/main.go:10 +0x25
zsh: exit 2     downloads/neofs-adm morph -c configuration/config.yaml init --contracts
```
2022-05-16 15:19:17 +03:00
Anna Shaleva
d2dcdecca5 core: avoid concurrent map r/w during SeekAsync
Close #2493.
2022-05-16 12:25:15 +03:00
Roman Khimov
4b785d4ffb
Merge pull request #2491 from nspcc-dev/fix-2489
core: pop native call arguments after call invocation
2022-05-16 11:12:45 +03:00
Anna Shaleva
a0774a2194 core: pop native call arguments after call invocation
Close #2489.
2022-05-16 09:39:17 +03:00
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
058a7eff90 Merge PR #2488 from nspcc-dev/reorder-neo-gas-distribution 2022-05-13 19:36:34 +03:00
Roman Khimov
54d8a37f3b native: make it mergeable with master again 2022-05-13 18:51:27 +03:00
Roman Khimov
85fe111aea neo: mint GAS after NEO transfer processing
See neo-project/neo#2734.
2022-05-13 18:05:27 +03:00
Anna Shaleva
6020ca9ae8 crypto: adjust Checksum documentation 2022-05-13 13:20:40 +03:00
Anna Shaleva
e31f4ca331 interop: add interop API for MODMUL, MODPOW opcodes 2022-05-12 14:31:24 +03:00
Anna Shaleva
e66e82278c vm: upgrade submodule 2022-05-12 14:25:14 +03:00
Anna Shaleva
a94ccf9236 vm: add MODMUL and MODPOW opcodes
Close #2470.
2022-05-12 14:25:14 +03:00
Roman Khimov
7fd0eb14b5
Merge pull request #2469 from nspcc-dev/hardfork
core: add ability to create hard-forks
2022-05-12 14:05:48 +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
c6f8c33e66
Merge pull request #2478 from nspcc-dev/mainnet-fixes
Mainnet fixes
2022-05-12 10:04:53 +03:00
Roman Khimov
64baa309cb
Merge pull request #2475 from nspcc-dev/vm/fix-jump
vm: check instruction offset is valid before subsequent IP move
2022-05-12 10:04:04 +03:00
Roman Khimov
621db8c832 stackitem: allow to unJSONize big numbers (>int64), fix #2477
100000000000000000000 overflows int64 and NeoGo returns some garbage to
contracts instead of a proper number.
2022-05-11 21:03:10 +03:00
Roman Khimov
3d1a81df1f native: std.itoa uses lower-cased letters, fix #2476 2022-05-11 19:33:17 +03:00
Anna Shaleva
5505acf10e core: change Create[Standard, Multisig]Account prices
And make a hard-fork from this change.
2022-05-11 14:21:43 +03:00
Anna Shaleva
e70bf7d12e core: allow to create hard-fork 2022-05-11 14:21:38 +03:00
Anna Shaleva
3be37e8c5b vm: check instruction offset is valid before subsequent IP move
Reference implementation:
e167f03e25/src/neo-vm/ExecutionContext.cs (L77).

Turns out that exception-related code (try\finally handling) is the only
place where next instruction pointer bounds are not pre-checked before
assignment. This statement is true for both go and C# implementations.
However, C# code has duplicate check located inside the
InstructionPointer setter for all instructions except the
exception-related ones. Neo-go code doesn't perform this duplicate check.
Thus, C# VM FAULTs execution in case of invalid TRY/FINALLY offsets, and
neo-go VM does not.

This commit reverts a part of
https://github.com/nspcc-dev/neo-go/pull/2396. This bug is discovered
thanks to test added in https://github.com/neo-project/neo-vm/pull/453.
2022-05-11 14:04:02 +03:00
Anna Shaleva
d88ca102c6 services: forbid insecure Oracle request redirects 2022-05-11 09:45:44 +03:00
Roman Khimov
d1588115a2
Merge pull request #2473 from nspcc-dev/fix-gosimple-wrn
services: fix gosimple warning
2022-05-11 09:22:05 +03:00
Roman Khimov
483130fa7c
Merge pull request #2472 from nspcc-dev/shift-getversion-compat
rpc: move latest getversion compat to 0.98.3
2022-05-11 08:10:07 +03:00
Anna Shaleva
48ee33fd61 services: fix gosimple warning
Fix the following warning:
```
S1001: should use copy() instead of a loop (gosimple)
```
2022-05-11 07:39:27 +03:00
Roman Khimov
2b79a162ce
Merge pull request #2467 from nspcc-dev/limit-eq
vm: adjust comparable limit for ByteArray
2022-05-10 19:53:20 +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
711e21709f rpc/notary: make this branch mergeable with master 2022-05-07 18:38:50 +03:00
Anna Shaleva
8af043520d vm: adjust MaxByteArrayComparableSize value
https://github.com/neo-project/neo-vm/pull/454#discussion_r857533800.
2022-05-07 12:56:09 +03:00
Anna Shaleva
23b78b0be2 vm: limit ByteArray comparable length
Close #2460.
2022-05-07 12:56:04 +03:00
Roman Khimov
7dc0404306 transaction: fix maxSubitems handling in JSON scope unmarshaller
Notice that binary deserializer (readArrayOfConditions) does it correctly. Can
be checked with neo-project/neo#2720 case.
2022-05-07 12:05:34 +03:00
Roman Khimov
c410219cba transaction: fix Rules stringer, it's WitnessRules in C#
See neo-project/neo#2720.
2022-05-07 12:05:25 +03:00
Anna Shaleva
b1f74b549d 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-05-07 12:02:42 +03:00
Anna Shaleva
a7fe85a2d8 services: fix changing of main tx size of Notary request 2022-05-07 12:00:16 +03:00
Anna Shaleva
d68f57b9f9 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-05-07 11:59:55 +03:00
Evgeniy Stratonikov
92a2ec5848 network: check compressed payload size in decompress
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-05-07 11:57:48 +03:00
Anna Shaleva
11bfb55b81 core: consider Rules witness scope as valid 2022-05-07 10:50:11 +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
a427411a57 core: fix race during native cache persist
Fixes the following race:
```
2022-05-06T06:51:33.3980029Z WARNING: DATA RACE
2022-05-06T06:51:33.3980178Z Read at 0x00c0007e02a0 by goroutine 96:
2022-05-06T06:51:33.3980338Z   runtime.mapaccess2_fast32()
2022-05-06T06:51:33.3980863Z       /opt/hostedtoolcache/go/1.17.9/x64/src/runtime/map_fast32.go:52 +0x0
2022-05-06T06:51:33.3981249Z   github.com/nspcc-dev/neo-go/pkg/core/dao.(*Simple).getCache()
2022-05-06T06:51:33.3982707Z       /home/runner/work/neo-go/neo-go/pkg/core/dao/dao.go:905 +0x64
2022-05-06T06:51:33.3983443Z   github.com/nspcc-dev/neo-go/pkg/core/dao.(*Simple).GetROCache()
2022-05-06T06:51:33.3983900Z       /home/runner/work/neo-go/neo-go/pkg/core/dao/dao.go:889 +0xd4
2022-05-06T06:51:33.3984231Z   github.com/nspcc-dev/neo-go/pkg/core/dao.(*Simple).getCache()
2022-05-06T06:51:33.3984869Z       /home/runner/work/neo-go/neo-go/pkg/core/dao/dao.go:913 +0x196
2022-05-06T06:51:33.3985254Z   github.com/nspcc-dev/neo-go/pkg/core/dao.(*Simple).GetROCache()
2022-05-06T06:51:33.3985756Z       /home/runner/work/neo-go/neo-go/pkg/core/dao/dao.go:889 +0xd4
2022-05-06T06:51:33.3986167Z   github.com/nspcc-dev/neo-go/pkg/core/native.(*Policy).isBlockedInternal()
2022-05-06T06:51:33.3986824Z       /home/runner/work/neo-go/neo-go/pkg/core/native/policy.go:258 +0x6a
2022-05-06T06:51:33.3987264Z   github.com/nspcc-dev/neo-go/pkg/core/native.(*Policy).IsBlocked()
2022-05-06T06:51:33.3987743Z       /home/runner/work/neo-go/neo-go/pkg/core/native/policy.go:250 +0x2f7
2022-05-06T06:51:33.3988155Z   github.com/nspcc-dev/neo-go/pkg/core/native.(*NEO).getAllCandidatesCall.func1()
2022-05-06T06:51:33.3988645Z       /home/runner/work/neo-go/neo-go/pkg/core/native/native_neo.go:948 +0x109
2022-05-06T06:51:33.3989053Z   github.com/nspcc-dev/neo-go/pkg/core/native.(*NEO).getAllCandidatesCall.func2()
2022-05-06T06:51:33.3989550Z       /home/runner/work/neo-go/neo-go/pkg/core/native/native_neo.go:959 +0x137
2022-05-06T06:51:33.3989561Z
2022-05-06T06:51:33.3989735Z Previous write at 0x00c0007e02a0 by goroutine 40:
2022-05-06T06:51:33.3989891Z   runtime.mapassign_fast32()
2022-05-06T06:51:33.3990260Z       /opt/hostedtoolcache/go/1.17.9/x64/src/runtime/map_fast32.go:92 +0x0
2022-05-06T06:51:33.3990640Z   github.com/nspcc-dev/neo-go/pkg/core/dao.(*Simple).persistNativeCache()
2022-05-06T06:51:33.3991084Z       /home/runner/work/neo-go/neo-go/pkg/core/dao/dao.go:876 +0x12d
2022-05-06T06:51:33.3991411Z   github.com/nspcc-dev/neo-go/pkg/core/dao.(*Simple).Persist()
2022-05-06T06:51:33.3991852Z       /home/runner/work/neo-go/neo-go/pkg/core/dao/dao.go:850 +0x1d4
2022-05-06T06:51:33.3992186Z   github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).runPersist()
2022-05-06T06:51:33.3992650Z       /home/runner/work/neo-go/neo-go/pkg/core/blockchain.go:1285 +0x28a
2022-05-06T06:51:33.3992971Z   github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).storeBlock()
2022-05-06T06:51:33.3993845Z       /home/runner/work/neo-go/neo-go/pkg/core/blockchain.go:1143 +0x1b9c
2022-05-06T06:51:33.3994241Z   github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).AddBlock()
2022-05-06T06:51:33.3994707Z       /home/runner/work/neo-go/neo-go/pkg/core/blockchain.go:910 +0x791
2022-05-06T06:51:33.3995053Z   github.com/nspcc-dev/neo-go/pkg/neotest.(*Executor).AddNewBlock()
2022-05-06T06:51:33.3995492Z       /home/runner/work/neo-go/neo-go/pkg/neotest/basic.go:334 +0xa7
2022-05-06T06:51:33.3995842Z   github.com/nspcc-dev/neo-go/pkg/neotest.(*Executor).InvokeScript()
2022-05-06T06:51:33.3996288Z       /home/runner/work/neo-go/neo-go/pkg/neotest/basic.go:178 +0x169
2022-05-06T06:51:33.3996725Z   github.com/nspcc-dev/neo-go/pkg/core/native/native_test_test.TestNEO_GetCandidates.func2()
2022-05-06T06:51:33.3997253Z       /home/runner/work/neo-go/neo-go/pkg/core/native/native_test/neo_test.go:549 +0x4cb
2022-05-06T06:51:33.3997672Z   github.com/nspcc-dev/neo-go/pkg/core/native/native_test_test.TestNEO_GetCandidates()
2022-05-06T06:51:33.3998404Z       /home/runner/work/neo-go/neo-go/pkg/core/native/native_test/neo_test.go:574 +0x2103
2022-05-06T06:51:33.3998751Z   github.com/nspcc-dev/neo-go/pkg/neotest.(*Executor).AddNewBlock()
2022-05-06T06:51:33.3999193Z       /home/runner/work/neo-go/neo-go/pkg/neotest/basic.go:334 +0xa7
2022-05-06T06:51:33.3999541Z   github.com/nspcc-dev/neo-go/pkg/neotest.(*Executor).InvokeScript()
2022-05-06T06:51:33.3999988Z       /home/runner/work/neo-go/neo-go/pkg/neotest/basic.go:178 +0x169
2022-05-06T06:51:33.4000305Z   github.com/nspcc-dev/neo-go/pkg/neotest.AddSystemFee()
2022-05-06T06:51:33.4000733Z       /home/runner/work/neo-go/neo-go/pkg/neotest/basic.go:291 +0x85
2022-05-06T06:51:33.4001062Z   github.com/nspcc-dev/neo-go/pkg/neotest.(*Executor).SignTx()
2022-05-06T06:51:33.4001509Z       /home/runner/work/neo-go/neo-go/pkg/neotest/basic.go:111 +0x109
2022-05-06T06:51:33.4001885Z   github.com/nspcc-dev/neo-go/pkg/neotest.(*Executor).PrepareInvocation()
2022-05-06T06:51:33.4002435Z       /home/runner/work/neo-go/neo-go/pkg/neotest/basic.go:191 +0x1b2
2022-05-06T06:51:33.4002808Z   github.com/nspcc-dev/neo-go/pkg/neotest.(*Executor).InvokeScript()
2022-05-06T06:51:33.4003249Z       /home/runner/work/neo-go/neo-go/pkg/neotest/basic.go:177 +0xed
2022-05-06T06:51:33.4003685Z   github.com/nspcc-dev/neo-go/pkg/core/native/native_test_test.TestNEO_GetCandidates.func2()
2022-05-06T06:51:33.4004216Z       /home/runner/work/neo-go/neo-go/pkg/core/native/native_test/neo_test.go:549 +0x4cb
2022-05-06T06:51:33.4004634Z   github.com/nspcc-dev/neo-go/pkg/core/native/native_test_test.TestNEO_GetCandidates()
2022-05-06T06:51:33.4005165Z       /home/runner/work/neo-go/neo-go/pkg/core/native/native_test/neo_test.go:558 +0x1bbb
2022-05-06T06:51:33.4005298Z   testing.tRunner()
2022-05-06T06:51:33.4005674Z       /opt/hostedtoolcache/go/1.17.9/x64/src/testing/testing.go:1259 +0x22f
2022-05-06T06:51:33.4005916Z   testing.(*T).Run·dwrap·21()
2022-05-06T06:51:33.4006298Z       /opt/hostedtoolcache/go/1.17.9/x64/src/testing/testing.go:1306 +0x47
...
```
2022-05-06 13:46:17 +03:00
Anna Shaleva
ce35e69460 rpc: update testdata
Fix failing historic test.
2022-05-06 13:46:17 +03:00
Anna Shaleva
5123b88c36 core: extend native Neo interop API
Add GetAllCandidates and GetCandidateVote methods.
2022-05-06 13:43:12 +03:00
Anna Shaleva
5e2a81ad03 interop: fix the signature of Neo's GetCandidates interop API 2022-05-06 13:43:12 +03:00
Anna Shaleva
2a8ffd9318 core: refactor (*NEO).GetCandidates and add (*NEO).GetAllCandidates 2022-05-06 13:43:12 +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
acb1151d71 transaction: fix maxSubitems handling in JSON scope unmarshaller
Notice that binary deserializer (readArrayOfConditions) does it correctly. Can
be checked with neo-project/neo#2720 case.
2022-05-06 10:20:55 +03:00
Roman Khimov
bd352daab4 transaction: fix Rules stringer, it's WitnessRules in C#
See neo-project/neo#2720.
2022-05-06 10:08:09 +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
58bda8be78
Merge pull request #2461 from nspcc-dev/rpc-json-error-in-exception
rpc: signal JSON marshalling errors through exception
2022-05-04 17:22:05 +03:00
Anna Shaleva
ffdcdf4a95 core: restrict the maximum number of contract updates 2022-05-04 13:56:52 +03:00
Anna Shaleva
42e4021898 core: block destroyed contracts 2022-05-04 13:56:45 +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
Roman Khimov
7f8b259994
Merge pull request #2457 from nspcc-dev/t5-testnet
T5 testnet
2022-05-04 10:44:55 +03:00
Roman Khimov
3c0ee9c3a3 config: switch to T5 testnet
See neo-project/neo-node#852, neo-project/neo-node#859.
2022-05-04 10:22:27 +03:00
Roman Khimov
f9c7693677 oracle: limit the number of redirections to 2
Be compatible with neo-project/neo-modules#698.
2022-05-03 23:18:53 +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
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
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
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
Anna Shaleva
1890e7cdc1 core: upgrade storage version 2022-04-22 18:38:05 +03:00
Anna Shaleva
8be6823cb1 core: fix broken stateroot storage
Store stateroot by DataMPTAux prefix instead of storing it by index only.
2022-04-22 18:37:56 +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
Anna Shaleva
d942940a82 core: support System.Runtime.GetAddressVersion syscall 2022-04-21 19:26:16 +03:00
Erik van den Brink
9fe3a86540
fix typo's 2022-04-20 14:00:12 +02:00
Roman Khimov
f73510b926
Merge pull request #2432 from nspcc-dev/fix-fees
core: use proper BaseExecFee and StoragePrice for interop context
2022-04-14 15:10:22 +03: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
51a54fa248 core: return default BaseExecFee if blockchain height is 0
For (bc *Blockchain).GetBaseExecFee().
2022-04-08 14:28:30 +03:00
Anna Shaleva
d3672eb14a core: use BaseExecFee from InteropContext instead of Blockchain's one
The InteropContext's one contains all relevant fee changes applied in
the prevouse transactions of the current block.
2022-04-08 12:56:46 +03:00
Anna Shaleva
544f2c2cb2 core: use proper storage price within the whole interop context
We shouldn't use StoragePrice from Blockchain because its dao doesn't
contain the whole set of changes from previouse transactions in the
current block. Instead, we should use an updated storage price for
each transaction and retrieve the price from cached DAO.
2022-04-08 12:50:56 +03:00
Anna Shaleva
91a4bc5beb core: use proper DAO to get ExecFeeFactor
The usage of the Blockchain's one leads to the same ExecFeeFactor within
a single block. What we need is to update ExecFeeFactor after each
transaction invocation, thus, cached DAO should be used as it contains
all relevant changes.
2022-04-08 12:50:50 +03:00
Roman Khimov
6ff11baa1b
Merge pull request #2427 from nspcc-dev/add-hash-to-debug-info
Add hash to debug info and use absolute path
2022-04-06 16:11:47 +03:00
Roman Khimov
f5d5019b70 compiler: use absolute paths for debug data
It's not a perfect thing, but neo-debugger just doesn't work at all with
relative pathes. Notice that `saveSequencePoint` still used absolute ones
leading to invalid debug.json data, but fixing it there doesn't help,
neo-debugger can't load source code using relatives.
2022-04-06 15:46:54 +03:00
Roman Khimov
e390981747 compiler: add hash field to debug info
New debugger won't work without it.
2022-04-06 15:27:01 +03:00
Roman Khimov
017326dca4
Merge pull request #2417 from nspcc-dev/interop-update
*: natives update
2022-04-05 19:02:59 +03:00
Roman Khimov
bdcb527ead
Merge pull request #2420 from nspcc-dev/fix-ws
rpc: avoid panic on double-call to *WSClient.Close()
2022-04-05 16:41:51 +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
Anna Shaleva
5771bbb52a services: fix changing of main tx size of Notary request 2022-04-05 16:00:12 +03:00
Anna Shaleva
72ec354039 compiler: add test for murmur32 interop API 2022-04-05 10:51:12 +03:00
Anna Shaleva
16f952270c core: add murmur32 to CryptoLib native contract
Close #2415.
2022-04-05 10:46:52 +03:00
Anna Shaleva
0e8bf83dda compiler: add tests for GetTransactionVMState 2022-04-05 10:46:52 +03:00
Anna Shaleva
b431e47d2a core: add GetTransactionVMState to native Ledger contract
Close #2343.
2022-04-05 10:37:02 +03:00
Anna Shaleva
4254407a9b dao: add GetTxExecResult method 2022-04-05 10:36:50 +03:00
Anna Shaleva
18c5f638b9 dao: adjust usages of Internal DB inconsistency error 2022-04-04 19:16:58 +03:00
Anna Shaleva
2972569a0a vm: make byte representation of VMState compatible with C# 2022-04-04 13:52:29 +03:00