Commit graph

3497 commits

Author SHA1 Message Date
Roman Khimov
c8ba155d47 server: don't always Sprintf params for logger
Add Stringer to Params, if we're not printing Debug messages (which usually is
the case), it won't be called at all. Micro-optimization.
2020-10-08 16:37:28 +03:00
Roman Khimov
124ce9d247
Merge pull request #1455 from nspcc-dev/get_invocation_counter
core: remove error from runtime.GetInvocationCounter
2020-10-08 16:34:40 +03:00
Anna Shaleva
cbf89fbb19 vm: add Call method which increments invocation counter 2020-10-08 16:25:45 +03:00
Roman Khimov
8c2fd91c5c
Merge pull request #1462 from nspcc-dev/rpc/exceptions
rpc, core: add FaultException to AppExecResult and Invoke* results
2020-10-08 16:20:38 +03:00
Anna Shaleva
0f71088246 core: add FaultException to AppExecResult 2020-10-08 16:12:19 +03:00
Anna Shaleva
9a493dd2a0 rpc: add FaultException to result.Invoke
Close #1440
2020-10-08 16:12:14 +03:00
Roman Khimov
70e9e329cd
Merge pull request #1463 from nspcc-dev/core/blocked_accounts_cache
core: add cache to Policy blocked accounts
2020-10-08 14:35:19 +03:00
Evgenii Stratonikov
44abaa8ef3 smartcontract: implement GetDefaultHonestNodeCount
We may use this in other parts of code.
2020-10-08 13:48:14 +03:00
Evgenii Stratonikov
037cecf1ac native: move OracleRequest to state package
It is used by multiple modules outside native
and produces unneeded dependencies.
2020-10-08 13:48:14 +03:00
Anna Shaleva
9fe2b04db9 core: add cache to Policy blocked accounts
Close #1441
2020-10-08 13:47:21 +03:00
Roman Khimov
705d04eda6
Merge pull request #1469 from nspcc-dev/fix-protocol-limits
Fix protocol limits
2020-10-08 13:39:25 +03:00
Roman Khimov
a44cb99df6 payload: add a check for zero-length address list
Which is also present in C# code. Thanks, @AnnaShaleva.
2020-10-08 13:26:18 +03:00
Anna Shaleva
6ce00fde82 vm, core: move invocation counter from InteropContext to VM 2020-10-08 11:33:26 +03:00
Anna Shaleva
45bfce60a5 core: remove error from runtime.GetInvocationCounter
close #1444
2020-10-08 11:32:00 +03:00
Roman Khimov
7ddce97f11
Merge pull request #1461 from nspcc-dev/cli/multisig
cli: allow to send multisig deploy/invoke tx
2020-10-07 23:34:52 +03:00
Roman Khimov
5abec520c7 payload: limit the number of possible addresses 2020-10-07 23:29:20 +03:00
Roman Khimov
0120a8f239 stackitem: limit buffer/bytearray reads upon deserialization
This is not the way it's done in C#, but that's the most sensible approach to
me.
2020-10-07 23:08:20 +03:00
Roman Khimov
64e9775707 vm/stackitem: limit reads for bigint values
They can't exceed 33 bytes.
2020-10-07 23:07:10 +03:00
Roman Khimov
f45c032eff nef: limit the number of bytes to be read during decode 2020-10-07 18:30:44 +03:00
Roman Khimov
63c7469dfd manifest: limit its size when decoding 2020-10-07 18:29:19 +03:00
Roman Khimov
f318e573d4 payload: limit the user agent field in version payload
Protocol limit.
2020-10-07 18:27:24 +03:00
Roman Khimov
705941a800 transaction: add script length limit
As it is implemented in C# code.
2020-10-07 18:23:10 +03:00
Roman Khimov
d029f5c0d8 transaction: fix witness script length limits
See neo-project/neo#1958.
2020-10-07 18:05:23 +03:00
Roman Khimov
273b803f52
Merge pull request #1464 from nspcc-dev/vm/bigint
vm: handle very big int creation properly
2020-10-07 15:09:25 +03:00
Evgenii Stratonikov
96bca91e4b vm: handle very big int creation properly
Determine size as in reference implementation instead of
`big.Int.BitLen()`

Close #1437.
2020-10-07 11:50:42 +03:00
Evgenii Stratonikov
897c9198f8 cli: allow to send multisig deploy/invoke tx
It allows to invoke native contracts as committee
from CLI in privnet, e.g. to set new oracle nodes.

Also don't require `out` flag in `multisig sign`
if tx is to be pushed.
2020-10-07 11:48:06 +03:00
Roman Khimov
0dcf42ac24
Merge pull request #1467 from nspcc-dev/core/fixes
Some fixes for core, crypto
2020-10-07 10:17:23 +03:00
Evgenii Stratonikov
17922038dc native: add GetOracleInvokeScript() 2020-10-07 10:04:19 +03:00
Evgenii Stratonikov
d50a14359a cli/wallet: save tx only if --out was provided
Also don't print tx hash twice.
2020-10-07 10:04:19 +03:00
Evgenii Stratonikov
0a596e1df2 keys: don't panic if signature has invalid size 2020-10-07 10:04:19 +03:00
Evgenii Stratonikov
9733a6f394 core: move CalculateNetworkFee to a separate package 2020-10-07 10:04:19 +03:00
Roman Khimov
d6a1a22afa
Merge pull request #1452 from nspcc-dev/contract/deploy
Support `_deploy` method
2020-10-06 19:54:14 +03:00
Evgenii Stratonikov
945e9410e4 cli: add test for testinvokefunction
Check that contract can be properly deployed
and invoked.
2020-10-06 19:12:38 +03:00
Evgenii Stratonikov
c4a8770215 compiler: support _deploy method 2020-10-06 19:12:35 +03:00
Evgenii Stratonikov
6701e8cda0 compiler: allow to use local variables in init()
Because body of multiple `init()` functions constitute single
method in contract, we initialize slot with maximum amount of
locals encounterered in any of `init()` functions and clear them
before emitting body of each instance of `init()`.
2020-10-06 19:08:32 +03:00
Evgenii Stratonikov
2d9ef9219a core: call _deploy method during create/update 2020-10-06 18:03:25 +03:00
Evgenii Stratonikov
b71f9e296c core/tests: refactor contract creation a bit
Make it easier to add new methods.
2020-10-06 18:03:25 +03:00
Evgenii Stratonikov
b2a3a0851e emit: accept multiple opcodes in Opcode() 2020-10-06 18:03:25 +03:00
Roman Khimov
2de146125c
Merge pull request #1460 from nspcc-dev/contract/update
core: allow Null in `System.Contract.Update`
2020-10-06 16:54:21 +03:00
Evgenii Stratonikov
0b76f875c7 core: allow Null in System.Contract.Update
Null means absense of script or manifest, empty
byte-slice is an error.

Related #1459.
2020-10-06 10:34:45 +03:00
Roman Khimov
2ea29924c4
Merge pull request #1454 from nspcc-dev/core/policy_checks
core: add validation to policy methods
2020-10-05 19:09:59 +03:00
Anna Shaleva
6cff35c927 network: restrict flags size in MerkleBlockPayload 2020-10-05 18:08:37 +03:00
Anna Shaleva
560e470484 core: add validation to native Policy methods
close #1442
2020-10-05 18:08:37 +03:00
Anna Shaleva
e1e586f18b core: restrict the muximum number of contents per block 2020-10-05 18:08:33 +03:00
Anna Shaleva
d27775acc5 rpc: remove json names from result.Invoke struct
We use invokeAux to marshal result.Invoke to JSON.
2020-10-05 16:00:15 +03:00
Roman Khimov
0e82d4cbd1
Merge pull request #1458 from nspcc-dev/fix/storageput
core: calculate gas for `System.Storage.Put` correctly
2020-10-05 14:26:17 +03:00
Evgenii Stratonikov
833bbb1d35 core: calculate gas for System.Storage.Put correctly
If `Put` creates new key, its length should contribute
to a GAS cost of the syscall.
2020-10-05 13:03:44 +03:00
Anna Shaleva
c79d440c21 network: fix MerkleBlockPayload serialisation 2020-10-02 19:25:57 +03:00
Roman Khimov
8e146d19b3
Merge pull request #1447 from nspcc-dev/core/fix_neo_cache
core: fix cache for (NEO).nextValidators and (NEO).committee
2020-10-02 17:09:43 +03:00
Anna Shaleva
eccf639803 core: add InitializeCache method to NEO native contracts
There might be a case when cached contract values store nil (e.g.
after restoring chain from dump). We should always initialize cached
values irrespective to the (NEO).Initialize method.

This commit fixes a bug introduced in 83e94d3
when 4-nodes privnet is failing after restoring from dump:
```
$ docker logs neo_go_node_one
=> Try to restore blocks before running node
2020-09-30T11:55:49.122Z	INFO	no storage version found! creating genesis block
2020-09-30T11:55:49.124Z	INFO	service hasn't started since it's disabled	{"service": "Pprof"}
2020-09-30T11:55:49.124Z	INFO	service hasn't started since it's disabled	{"service": "Prometheus"}
2020-09-30T11:55:49.124Z	INFO	skipped genesis block	{"hash": "3792eaa22c196399a114666fd491c4b9ac52491d9abb1f633a8036a8ac81e4db"}
2020-09-30T11:55:49.141Z	INFO	shutting down service	{"service": "Pprof", "endpoint": ":30001"}
2020-09-30T11:55:49.141Z	INFO	shutting down service	{"service": "Prometheus", "endpoint": ":40001"}
2020-09-30T11:55:49.141Z	INFO	blockchain persist completed	{"persistedBlocks": 3, "persistedKeys": 146, "headerHeight": 3, "blockHeight": 3, "took": "324.27µs"}
2020-09-30T11:55:49.150Z	INFO	restoring blockchain	{"version": "0.1.0"}
2020-09-30T11:55:49.150Z	INFO	service hasn't started since it's disabled	{"service": "Prometheus"}
2020-09-30T11:55:49.151Z	INFO	service hasn't started since it's disabled	{"service": "Pprof"}
2020-09-30T11:55:49.443Z	INFO	starting rpc-server	{"endpoint": ":30333"}
2020-09-30T11:55:49.443Z	INFO	node started	{"blockHeight": 3, "headerHeight": 3}

    _   ____________        __________
   / | / / ____/ __ \      / ____/ __ \
  /  |/ / __/ / / / /_____/ / __/ / / /
 / /|  / /___/ /_/ /_____/ /_/ / /_/ /
/_/ |_/_____/\____/      \____/\____/

/NEO-GO:/

2020-09-30T11:55:49.444Z	INFO	new peer connected	{"addr": "172.23.0.5:39638", "peerCount": 1}
2020-09-30T11:55:49.444Z	INFO	new peer connected	{"addr": "172.23.0.5:20333", "peerCount": 2}
2020-09-30T11:55:49.444Z	WARN	peer disconnected	{"addr": "172.23.0.5:20333", "reason": "identical node id", "peerCount": 1}
2020-09-30T11:55:49.445Z	WARN	peer disconnected	{"addr": "172.23.0.5:39638", "reason": "identical node id", "peerCount": 0}
2020-09-30T11:55:49.445Z	INFO	new peer connected	{"addr": "172.23.0.3:20335", "peerCount": 1}
2020-09-30T11:55:49.445Z	INFO	new peer connected	{"addr": "172.23.0.2:20334", "peerCount": 2}
2020-09-30T11:55:49.445Z	INFO	started protocol	{"addr": "172.23.0.3:20335", "userAgent": "/NEO-GO:/", "startHeight": 3, "id": 1339919829}
2020-09-30T11:55:49.445Z	INFO	new peer connected	{"addr": "172.23.0.4:20336", "peerCount": 3}
2020-09-30T11:55:49.445Z	INFO	started protocol	{"addr": "172.23.0.4:20336", "userAgent": "/NEO-GO:/", "startHeight": 3, "id": 4036722359}
2020-09-30T11:55:49.445Z	INFO	node reached synchronized state, starting consensus
2020-09-30T11:55:49.445Z	INFO	started protocol	{"addr": "172.23.0.2:20334", "userAgent": "/NEO-GO:/", "startHeight": 3, "id": 1557367037}
panic: runtime error: integer divide by zero

goroutine 132 [running]:
github.com/nspcc-dev/dbft.(*Context).GetPrimaryIndex(...)
	github.com/nspcc-dev/dbft@v0.0.0-20200925163137-8f3b9ab3b720/context.go:83
github.com/nspcc-dev/dbft.(*Context).reset(0xc0000e0780, 0x0)
	github.com/nspcc-dev/dbft@v0.0.0-20200925163137-8f3b9ab3b720/context.go:208 +0x64b
github.com/nspcc-dev/dbft.(*DBFT).InitializeConsensus(0xc0000e0780, 0x964800)
	github.com/nspcc-dev/dbft@v0.0.0-20200925163137-8f3b9ab3b720/dbft.go:87 +0x51
github.com/nspcc-dev/dbft.(*DBFT).Start(0xc0000e0780)
	github.com/nspcc-dev/dbft@v0.0.0-20200925163137-8f3b9ab3b720/dbft.go:81 +0x4b
github.com/nspcc-dev/neo-go/pkg/consensus.(*service).Start(0xc0001a2160)
	github.com/nspcc-dev/neo-go/pkg/consensus/consensus.go:206 +0x56
github.com/nspcc-dev/neo-go/pkg/network.(*Server).tryStartConsensus(0xc0000ec500)
	github.com/nspcc-dev/neo-go/pkg/network/server.go:311 +0xda
github.com/nspcc-dev/neo-go/pkg/network.(*Server).handleMessage(0xc0000ec500, 0x104d800, 0xc000222090, 0xc0000a6f10, 0x0, 0x0)
	github.com/nspcc-dev/neo-go/pkg/network/server.go:781 +0xa7a
github.com/nspcc-dev/neo-go/pkg/network.(*TCPPeer).handleConn(0xc000222090)
	github.com/nspcc-dev/neo-go/pkg/network/tcp_peer.go:162 +0x2e7
created by github.com/nspcc-dev/neo-go/pkg/network.(*TCPTransport).Dial
	github.com/nspcc-dev/neo-go/pkg/network/tcp_transport.go:40 +0x1ac
```
2020-10-02 17:03:06 +03:00