Anna Shaleva
c8120a139d
core: add MaxKeyLength restrictions to MPT's operations
2021-10-06 16:37:23 +03:00
Evgeniy Stratonikov
cb5b075e7d
wallet: do not store file handle
...
Close immediately after read/write. This can be a bit slower but
we store everything in memory anyway and code size is smaller.
`wallet.Close()` method is now a no-op.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-10-06 15:29:52 +03:00
Evgeniy Stratonikov
4dd3a0d503
network: request headers in parallel, fix #2158
...
Do this similarly to how blocks are requested.
See also 4aa1a37
.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-10-06 15:25:54 +03:00
Evgeniy Stratonikov
0c01d89827
compiler: check that safe methods exist
...
If a method is missing from the manifest, it is most likely a typo
or regression after refactoring. There is no "turn-off" flag
for this error because we can do this precisely.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-10-06 15:18:58 +03:00
Evgeniy Stratonikov
7b6203d0d4
wallet: allow to open in read-only mode, fix #2182
...
If wallet was opened via `NewWalletFromFile`, open it as read-only first
and re-open for write if needed.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-10-05 16:25:50 +03:00
Roman Khimov
b4e24bef14
Merge pull request #2202 from nspcc-dev/validatorscount
...
rpc: add validatorscount to getversion response
2021-09-29 11:55:59 +03:00
Roman Khimov
0ddc7be74d
Merge pull request #2199 from nspcc-dev/conflicts-message
...
Reword some error messages
2021-09-28 10:17:46 +03:00
Roman Khimov
5a2b77238c
rpc: add validatorscount to getversion response
...
See neo-project/neo-modules#642 .
2021-09-28 10:10:26 +03:00
Evgeniy Stratonikov
45976a4111
rpc/response: beautify error message
...
If `Error.Cause` is nil, omit ugly `%s!<nil>`.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-09-28 09:57:42 +03:00
Evgeniy Stratonikov
e6aa9b76ee
mempool: reword ErrConflict
message, fix #2197
...
Make it more user-friendly.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-09-28 09:57:42 +03:00
fyrchik
cfeaeb0f07
Merge pull request #2194 from nspcc-dev/fix-config-types
...
config: fix duration parameter types
2021-09-27 10:20:15 +03:00
Roman Khimov
e34c47a0c6
Merge pull request #2192 from nspcc-dev/rpc/container_hash
...
subscriptions: add container hash to notification event
2021-09-25 22:33:16 +03:00
Evgeniy Stratonikov
7fa6c8dcf6
config: fix duration parameter types
...
These parameters denote seconds and are thus unitless integers, not
durations.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-09-25 13:13:51 +03:00
Anna Shaleva
5c97e0dcf2
rpc: move NotaryRequestEvent to the subscriptions pkg
...
It is used for subscriptions only, so move it to the subscriptions pkg.
2021-09-24 17:42:59 +03:00
Anna Shaleva
b3ea7504cb
subscriptions: add container hash to notification event
...
External users make use of it. Close #2190 .
2021-09-24 17:42:02 +03:00
Roman Khimov
63c939b9fa
Merge pull request #2191 from nspcc-dev/port-nef-source
...
nef: add Source field
2021-09-24 10:42:49 +03:00
Roman Khimov
42a9d3d7b8
nef: add Source field
...
Follow neo-project/neo#2605 .
2021-09-24 00:19:37 +03:00
Roman Khimov
0a52c32df3
Merge pull request #2179 from nspcc-dev/fix-param
...
Improve `wallet sign` command
2021-09-23 17:57:59 +03:00
Evgeniy Stratonikov
bf2ca35453
cli/wallet: allow to testinvoke transaction before signing
...
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-09-23 11:48:25 +03:00
Roman Khimov
e2a93f3e41
Merge pull request #2186 from nspcc-dev/voter-optimizations
...
NEO voter optimizations
2021-09-22 18:10:28 +03:00
Roman Khimov
c009356b73
core: simplify component flushing in storeBlock
...
Instead of flushing everything to `cache` and then to `bc.dao`, wrap `bc.dao`
directly for block/tx data and AERs and then flush to it. Block/transactions
are usually processed more quickly than other components, so they easily end
up in `cache` where they directly affect Seek performance for any executing
transaction.
Simple as it is this change improves voter NEO transfer benchmark with 1000
accounts by more than 25%, from ~18500 TPS to ~23500 TPS. It doesn't affect
much other cases.
2021-09-22 17:15:12 +03:00
Roman Khimov
b66bc33cf9
native: short-circuit successive GAS distributions
...
GAS can only be distributed once in a block for particular address, so it
makes little sense trying to calculate it again and again. This fixes
neo-bench for NEO voter, because without it we get ~2500 TPS for
single-address test and with it it jumps 13-fold to normal values like
~33500.
2021-09-22 17:13:55 +03:00
Roman Khimov
d915f085a7
Merge pull request #2180 from nspcc-dev/cli-show-fee
...
cli/wallet: show tx fee before relaying
2021-09-22 13:33:40 +03:00
Roman Khimov
6d5fb59f59
Merge pull request #2185 from nspcc-dev/remove-unused-interopnames
...
core: remove unused interopnames
2021-09-21 17:32:10 +03:00
Anna Shaleva
06d3c21e3f
core: remove unused interopnames
2021-09-21 16:43:09 +03:00
Roman Khimov
4743d5aacf
Merge pull request #2181 from nspcc-dev/states-diff_testnet_289026
...
core: fix NEO balance state handler
2021-09-21 15:39:37 +03:00
Roman Khimov
ca7be4c7fa
Merge pull request #2183 from nspcc-dev/examples/rename-migrate
...
examples: rename Migrate methods to Update
2021-09-21 12:49:36 +03:00
Evgeniy Stratonikov
2a78ec8003
cli/wallet: show tx fee before relaying
...
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-09-21 11:31:56 +03:00
Anna Shaleva
6594099846
examples: rename Migrate methods to Update
...
It's a remnant from N2, so this commit unifies style of all
update-related methods.
2021-09-20 21:56:06 +03:00
Anna Shaleva
c113d682bd
core: fix NEO balance state handler
...
We need to store NEO balance's LastUpdateHeight before GAS mint,
because mint can call onNEP17Payment and onNEP17Payment can call NEO
transfer which also calls GAS mint. Storing balance height allows to
avoid recursion.
2021-09-20 19:23:35 +03:00
Roman Khimov
56dd7b7364
Merge pull request #2177 from nspcc-dev/fix-lint
...
Replace golint with revive
2021-09-15 17:59:04 +03:00
Evgeniy Stratonikov
31eed060ad
.circleci: update golangci-lint to v1.42.1
...
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-09-15 17:44:41 +03:00
Roman Khimov
68af14100c
Merge pull request #2174 from nspcc-dev/states-diff_testnet_284177
...
smartcontract: escape non-ascii characters for manifest.Extra SI
2021-09-15 15:07:25 +03:00
Anna Shaleva
dfc0b25cfe
gomod: use nspcc-dev's fork of go-ordered-json
...
Escape non-ASCII characters while JSON encoding.
2021-09-15 15:01:01 +03:00
Roman Khimov
1480e29548
Merge pull request #2178 from nspcc-dev/fix-oracle-unsupported-code
...
transaction: fix ContentTypeNotSupported oracle code processing
2021-09-14 18:01:40 +03:00
Roman Khimov
24a3cce1ca
Merge pull request #2169 from nspcc-dev/states-diff_mainnet_131795
...
core: allow transfer 0 GAS/NEO with zero balance
2021-09-14 17:30:41 +03:00
Roman Khimov
8a440a4016
transaction: fix ContentTypeNotSupported oracle code processing
...
Fix testnet block 311487 block processing and synchronization errors:
2021-09-14T15:18:53.611+0300 WARN peer disconnected {"addr": "20.198.226.132:20333", "reason": "invalid oracle response code", "peerCount": 10}
Fix 8e9302f40b
.
2021-09-14 15:18:38 +03:00
Roman Khimov
dd0ea4d057
Merge pull request #2171 from nspcc-dev/fix-sc-json
...
Smartcontract parameter JSON marshaling fixes
2021-09-14 14:48:17 +03:00
Evgeniy Stratonikov
176b61e317
*: fix linter issues
...
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-09-14 14:39:39 +03:00
Evgeniy Stratonikov
e503b068b6
.golangci.yml: replace golint
with revive
...
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-09-14 14:39:23 +03:00
Evgeniy Stratonikov
918d7e65bf
smartcontract: unmarhal null
values properly
...
First we unmarshal `null` to `[]byte`, then we marshal it to the empty
string.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-09-14 13:28:01 +03:00
Roman Khimov
5209fe1e09
Merge pull request #2173 from nspcc-dev/fix-race
...
network: fix race in StateSync module tests
2021-09-14 11:57:21 +03:00
Roman Khimov
621478296c
Merge pull request #2161 from nspcc-dev/rpc-get-version
...
rpc: return protocol parameters in `getversion`, fix #2160
2021-09-13 19:10:43 +03:00
Anna Shaleva
6357af0bb0
network: fix race in TestHandleGetMPTData
...
Init server config before server start. Fixes the following data race:
```
WARNING: DATA RACE
Write at 0x00c00032ef20 by goroutine 26:
github.com/nspcc-dev/neo-go/pkg/network.TestHandleGetMPTData.func2()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server_test.go:755 +0x10a
testing.tRunner()
/usr/local/go/src/testing/testing.go:1193 +0x202
Previous read at 0x00c00032ef20 by goroutine 24:
github.com/nspcc-dev/neo-go/internal/fakechain.(*FakeChain).GetConfig()
/go/src/github.com/nspcc-dev/neo-go/internal/fakechain/fakechain.go:167 +0x6f
github.com/nspcc-dev/neo-go/pkg/network.(*Server).initStaleMemPools()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server.go:1433 +0x89
github.com/nspcc-dev/neo-go/pkg/network.(*Server).Start()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server.go:284 +0x288
github.com/nspcc-dev/neo-go/pkg/network.startWithChannel.func1()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server_test.go:91 +0x44
Goroutine 26 (running) created at:
testing.(*T).Run()
/usr/local/go/src/testing/testing.go:1238 +0x5d7
github.com/nspcc-dev/neo-go/pkg/network.TestHandleGetMPTData()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server_test.go:752 +0x8c
testing.tRunner()
/usr/local/go/src/testing/testing.go:1193 +0x202
Goroutine 24 (running) created at:
github.com/nspcc-dev/neo-go/pkg/network.startWithChannel()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server_test.go:90 +0x78
github.com/nspcc-dev/neo-go/pkg/network.startTestServer()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server_test.go:384 +0xbd
github.com/nspcc-dev/neo-go/pkg/network.TestHandleGetMPTData.func2()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server_test.go:753 +0x55
testing.tRunner()
/usr/local/go/src/testing/testing.go:1193 +0x202
```
2021-09-13 11:45:48 +03:00
Anna Shaleva
29ef076f4b
network: fix race in TestTryInitStateSync
...
Register peers properly. Fixes the following data race:
```
Read at 0x00c001184ac8 by goroutine 116:
github.com/nspcc-dev/neo-go/pkg/network.(*localPeer).EnqueueHPPacket()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/helper_test.go:127 +0x1f2
github.com/nspcc-dev/neo-go/pkg/network.(*localPeer).EnqueuePacket()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/helper_test.go:114 +0xac
github.com/nspcc-dev/neo-go/pkg/network.(*localPeer).EnqueueMessage()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/helper_test.go:111 +0xc1
github.com/nspcc-dev/neo-go/pkg/network.(*localPeer).SendPing()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/helper_test.go:159 +0x88
github.com/nspcc-dev/neo-go/pkg/network.(*Server).runProto()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server.go:446 +0x409
Previous write at 0x00c001184ac8 by goroutine 102:
github.com/nspcc-dev/neo-go/pkg/network.newLocalPeer()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/helper_test.go:83 +0x476
github.com/nspcc-dev/neo-go/pkg/network.TestTryInitStateSync.func3()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server_test.go:1064 +0x40f
testing.tRunner()
/usr/local/go/src/testing/testing.go:1123 +0x202
Goroutine 116 (running) created at:
github.com/nspcc-dev/neo-go/pkg/network.(*Server).run()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server.go:358 +0x69
github.com/nspcc-dev/neo-go/pkg/network.(*Server).Start()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server.go:292 +0x488
github.com/nspcc-dev/neo-go/pkg/network.startWithChannel.func1()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server_test.go:91 +0x44
Goroutine 102 (running) created at:
testing.(*T).Run()
/usr/local/go/src/testing/testing.go:1168 +0x5bb
github.com/nspcc-dev/neo-go/pkg/network.TestTryInitStateSync()
/go/src/github.com/nspcc-dev/neo-go/pkg/network/server_test.go:1056 +0xbb
testing.tRunner()
/usr/local/go/src/testing/testing.go:1123 +0x202
```
2021-09-13 11:45:48 +03:00
Roman Khimov
868835fb2a
Merge pull request #2172 from nspcc-dev/fix-go-fmt
...
*: gofmt -s
2021-09-10 22:01:24 +03:00
Evgeniy Stratonikov
8a3e05096b
*: gofmt -s
...
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-09-10 21:49:11 +03:00
Evgeniy Stratonikov
c465b18cb2
rpc: return protocol parameters in getversion
, fix #2160
...
`StateRootInHeader` is duplicated similarly to `Network`.
It will be removed in future as it is surely a protocol parameter.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-09-10 21:45:59 +03:00
Roman Khimov
63e00ac128
Merge pull request #2166 from nspcc-dev/fix-nns-compat
...
Fix NNS compatibility
2021-09-10 18:10:17 +03:00
Anna Shaleva
7fc57c9d58
core: allow transfer 0 GAS/NEO with zero balance
...
This commit fixes states diff at 131795 block of mainnet.
Transaction:
```
NEO-GO-VM > loadbase64 DAAQDBSPsxdYh6cITC3gUKI4oWmYxJs49gwUj7MXWIenCEwt4FCiOKFpmMSbOPYUwB8MCHRyYW5zZmVyDBT1Y+pAvCg9TQ4FxI6jBbPyoHNA70FifVtSOQwAEQwUj7MXWIenCEwt4FCiOKFpmMSbOPYMFL1Mb4Fqp6gHiEwzM6xSc8fLS+RpFMAfDAh0cmFuc2ZlcgwU9WPqQLwoPU0OBcSOowWz8qBzQO9BYn1bUjk=
READY: loaded 176 instructions
NEO-GO-VM 0 > ops
INDEX OPCODE PARAMETER
0 PUSHDATA1 ("") <<
2 PUSH0
3 PUSHDATA1 8fb3175887a7084c2de050a238a16998c49b38f6
25 PUSHDATA1 8fb3175887a7084c2de050a238a16998c49b38f6
47 PUSH4
48 PACK
49 PUSH15
50 PUSHDATA1 7472616e73666572 ("transfer")
60 PUSHDATA1 f563ea40bc283d4d0e05c48ea305b3f2a07340ef // NEO token
82 SYSCALL System.Contract.Call (627d5b52)
87 ASSERT
88 PUSHDATA1 ("")
90 PUSH1
91 PUSHDATA1 8fb3175887a7084c2de050a238a16998c49b38f6
113 PUSHDATA1 bd4c6f816aa7a807884c3333ac5273c7cb4be469
135 PUSH4
136 PACK
137 PUSH15
138 PUSHDATA1 7472616e73666572 ("transfer")
148 PUSHDATA1 f563ea40bc283d4d0e05c48ea305b3f2a07340ef // NEO token
170 SYSCALL System.Contract.Call (627d5b52)
175 ASSERT
```
Go's applog:
```
{
"id" : 1,
"result" : {
"txid" : "0x97d2ccb01467b22c73a2cb95f7af298f3a5bd8c849d7044371898b8efecdaabd",
"executions" : [
{
"exception" : "at instruction 87 (ASSERT): ASSERT failed",
"stack" : [],
"gasconsumed" : "4988995",
"notifications" : [],
"trigger" : "Application",
"vmstate" : "FAULT"
}
]
},
"jsonrpc" : "2.0"
}
```
C#'s applog:
```
{
"jsonrpc" : "2.0",
"result" : {
"executions" : [
{
"stack" : [],
"notifications" : [
{
"contract" : "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5",
"state" : {
"type" : "Array",
"value" : [
{
"type" : "ByteString",
"value" : "j7MXWIenCEwt4FCiOKFpmMSbOPY="
},
{
"type" : "ByteString",
"value" : "j7MXWIenCEwt4FCiOKFpmMSbOPY="
},
{
"value" : "0",
"type" : "Integer"
}
]
},
"eventname" : "Transfer"
},
{
"contract" : "0xd2a4cff31913016155e38e474a2c06d08be276cf",
"state" : {
"value" : [
{
"type" : "Any"
},
{
"type" : "ByteString",
"value" : "vUxvgWqnqAeITDMzrFJzx8tL5Gk="
},
{
"value" : "2490",
"type" : "Integer"
}
],
"type" : "Array"
},
"eventname" : "Transfer"
},
{
"contract" : "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5",
"state" : {
"value" : [
{
"value" : "vUxvgWqnqAeITDMzrFJzx8tL5Gk=",
"type" : "ByteString"
},
{
"value" : "j7MXWIenCEwt4FCiOKFpmMSbOPY=",
"type" : "ByteString"
},
{
"value" : "1",
"type" : "Integer"
}
],
"type" : "Array"
},
"eventname" : "Transfer"
}
],
"vmstate" : "HALT",
"gasconsumed" : "9977990",
"trigger" : "Application",
"exception" : null
}
],
"txid" : "0x97d2ccb01467b22c73a2cb95f7af298f3a5bd8c849d7044371898b8efecdaabd"
},
"id" : 1
}
```
2021-09-10 17:18:09 +03:00