Roman Khimov
ab3330564a
native: add hasMethod, fix #2588
...
Yet another state change.
2022-07-13 17:29:46 +03:00
Roman Khimov
125c2805d3
storage: reduce lock time in (*MemoryStore).Seek
...
It makes a copy of the resulting set, so the lock can be released
earlier. This helps a lot with iterators that keep Seek() unfinished for a
long time,
2022-07-11 16:15:14 +03:00
Roman Khimov
96c4e61063
storage: move Operation into package of its own
...
Don't use storage.* types in rpc/response/result.
2022-07-08 23:30:30 +03:00
Roman Khimov
8cd7b93208
limits: new package with storage limits
...
Packages like core/state or core/mpt shouldn't import whole core/storage just
to get some constant value, it's not a good dependency.
2022-07-08 23:30:30 +03:00
Roman Khimov
9987afea4c
storage: move DB configuration into a package on its own
...
Lightweight thing to import anywhere, pkg/config should not be dependent on
Level/Bolt/anything else.
2022-07-08 23:30:30 +03:00
Roman Khimov
fab8dfb9f8
vm: move State type into a package of its own
...
It's used a lot in other places that need it, but don't need whole VM at the
same time.
2022-07-08 18:34:52 +03:00
Anna Shaleva
cbd20eb959
rpc: implement iterator sessions
2022-07-08 17:05:18 +03:00
Roman Khimov
251c9bd89b
block: push PrevStateRoot data into stack item, fix #2551
...
And add compiler/interop support for this.
2022-07-07 15:10:29 +03:00
Roman Khimov
926b082d39
Merge pull request #2538 from nspcc-dev/restrict-out-of-bounds
...
core: check methods offsets while contract deploying
2022-07-04 12:54:32 +03:00
Anna Shaleva
7c48edaccb
core, rpc: fix height-related issue of historic call functionality
...
Specifying a certain stateroot R as `invoke*historic` RPC-call
parameter, we're willing to perform historic call based on the storage
state of root R. Thus, next block should be of the height h(R)+1. This
allows to use historic functionality for the current blockchain height.
2022-06-20 19:05:22 +03:00
Roman Khimov
5108d1c2c7
Merge pull request #2539 from nspcc-dev/rollback-methods-sorting
...
core: sort native methods in ASCII-compatible way
2022-06-14 22:09:23 +03:00
Roman Khimov
7b88aedb27
transaction: add fuzz-test, refs. #2374
2022-06-09 13:43:22 +03:00
Roman Khimov
1b7c8f262b
core: add some comment for TestDesignate_DesignateAsRole
...
Closes #1472 at last.
2022-06-08 23:11:14 +03:00
Roman Khimov
ef50518b83
core: move notary tests into the notary package
2022-06-08 23:07:28 +03:00
Roman Khimov
5d573895ad
core: move oracle tests into oracle service
2022-06-08 23:04:47 +03:00
Roman Khimov
017cd558cb
core: move statesync tests into the statesync package
2022-06-08 22:57:48 +03:00
Roman Khimov
ff75e67610
core: move stateroot tests into services/stateroot
...
They test both module and service which is a bit wrong, but separating these
tests will lead to some duplication, so it's OK for now to have them in the
higher-order package (service imports module).
2022-06-08 22:53:09 +03:00
Roman Khimov
167bb72424
core: move Policy contract tests to native
2022-06-08 22:44:25 +03:00
Roman Khimov
a1eccc16e6
core: move benchmarks into bench_test.go
...
They share some functions and they're benchmarks, so let's have them here.
2022-06-08 22:39:57 +03:00
Roman Khimov
2e2d886a2f
core: move Management contract test into native
2022-06-08 22:34:09 +03:00
Roman Khimov
8057c096c6
core: move native invocation tests into native
2022-06-08 22:26:24 +03:00
Roman Khimov
2086bca303
core: move storage-related interop code into the storage package
2022-06-08 22:26:24 +03:00
Roman Khimov
f0d7a1da2a
core: move contract-related tests to the contract package
2022-06-08 19:01:34 +03:00
Roman Khimov
e7e80fda64
core: move TestNativeGetMethod to the native package
2022-06-08 18:51:27 +03:00
Roman Khimov
2127cc4146
core: move Runtime tests to runtime package
2022-06-08 18:46:49 +03:00
Roman Khimov
0055b18a8a
core: export CreateGenesisBlock
...
Nothing bad with it being public.
2022-06-08 18:20:34 +03:00
Roman Khimov
d70caf1da1
core: move GetScriptContainer to runtime
...
It also brings ToStackItem to Block and Transaction, previously this was
avoided to separate block and transaction packages from VM. But turns out
`transaction` depends on `stackitem` already, so this makes little sense (but
can be shuffled in another way if needed).
Context.Container is still a hash.Hashable because we have a number of
occasions (header or MPT root verification) where there is no ToStackItem
implementation possible. Maybe they can go with `nil` Container, but I don't
want to have this risk for now.
2022-06-08 18:12:41 +03:00
Roman Khimov
cdb55740ea
core: move ContractCreate*Account tests into the contract pkg
...
No functional changes.
2022-06-08 16:56:06 +03:00
Roman Khimov
ff1545b7eb
core: move TestContractCall into the contract package
...
It belongs there and now it can be moved. No functional changes.
2022-06-08 16:53:01 +03:00
Roman Khimov
bb021d0778
native: unbind PutContractState from Management
...
It doesn't need Management's state, ID can't really change.
2022-06-08 16:41:28 +03:00
Roman Khimov
209b977e9a
core: move contract-related interop code into appropriate package
...
And move one of the tests with it.
2022-06-08 16:02:07 +03:00
Roman Khimov
10f94e6119
core: move chain dump test into its own package
2022-06-08 15:28:08 +03:00
Roman Khimov
c2b3ee3d8e
core: move basic chain creation into a package of its own
...
This allows to reuse it across different packages.
testchain can't be used because of circular dependencies.
Init() is not changed except for filepath.Join() use instead of direct string
appends which is a better approach anyway. rootpath is required because
current directory will change from package to package.
2022-06-08 15:25:27 +03:00
Roman Khimov
92c94f265c
interop/vm: make VM reusable and use on VM for all in-block execs
...
Avoid allocating again and again. Increases TPS by about 3%.
2022-06-07 10:05:47 +03:00
Roman Khimov
bdc6624c9d
interop: unify VM price getter setting
2022-06-06 22:00:16 +03:00
Roman Khimov
638b04b29a
interop: wrap contract.LoadToken in context.LoadToken
...
Creating a closure in runtime is a relatively costly thing, but it can easily
be avoided.
2022-06-06 21:53:03 +03:00
Anna Shaleva
a5b5f88fe2
core: doesn't allow to deploy contract with invalid method offset
...
This commit partially reverts 16bf7c1426
.
2022-06-06 12:18:16 +03:00
Anna Shaleva
bc85f00cc7
Partially revert "core: fix native NEO ABI"
...
This partially reverts commit ca127f1615
.
2022-06-06 12:08:52 +03:00
Roman Khimov
799394192b
state: create buffer/io writer once per TokenTransferLog
...
name old time/op new time/op delta
TokenTransferLog_Append-8 93.0µs ±170% 46.8µs ±152% ~ (p=0.053 n=10+9)
name old alloc/op new alloc/op delta
TokenTransferLog_Append-8 53.8kB ± 4% 38.6kB ±39% -28.26% (p=0.004 n=8+10)
name old allocs/op new allocs/op delta
TokenTransferLog_Append-8 384 ± 0% 128 ± 0% -66.67% (p=0.000 n=10+10)
2022-06-04 00:11:11 +03:00
Roman Khimov
1e5825c4af
core: don't allocate another int for notification handler
...
It'll be serialized anyway.
2022-06-03 23:39:46 +03:00
Anna Shaleva
d3b15a60a2
core: add test for ABI checks on deploy
...
Make sure it compatible with the reference implementation, see
736c346b9d/src/neo/SmartContract/Helper.cs (L83)
.
2022-06-03 11:37:50 +03:00
Anna Shaleva
16bf7c1426
core: adjust contract script check on deploy
...
Reference implementation doesn't panic if the method offset is out of
the contract script bounds, see:
736c346b9d/src/neo/SmartContract/Helper.cs (L82)
and
a65487fa56/src/Neo.VM/Script.cs (L146)
.
This commit fixes T5 statediff at block #125000 . Neo-go node FAULTed the
deploying transaction:
```
{
"version" : 0,
"sysfee" : "1000106065",
"validuntilblock" : 130758,
"script" : "DdMDeyJuYW1lIjoiTmVwMTdUb2tlbiIsImdyb3VwcyI6W10sImZlYXR1cmVzIjp7fSwic3VwcG9ydGVkc3RhbmRhcmRzIjpbIk5FUC0xNyJdLCJhYmkiOnsibWV0aG9kcyI6W3sibmFtZSI6InN5bWJvbCIsInBhcmFtZXRlcnMiOltdLCJyZXR1cm50eXBlIjoiU3RyaW5nIiwib2Zmc2V0IjoyMiwic2FmZSI6dHJ1ZX0seyJuYW1lIjoiZGVjaW1hbHMiLCJwYXJhbWV0ZXJzIjpbXSwicmV0dXJudHlwZSI6IkludGVnZXIiLCJvZmZzZXQiOjIyLCJzYWZlIjp0cnVlfSx7Im5hbWUiOiJ0b3RhbFN1cHBseSIsInBhcmFtZXRlcnMiOltdLCJyZXR1cm50eXBlIjoiSW50ZWdlciIsIm9mZnNldCI6MjIsInNhZmUiOnRydWV9LHsibmFtZSI6ImJhbGFuY2VPZiIsInBhcmFtZXRlcnMiOlt7Im5hbWUiOiJvd25lciIsInR5cGUiOiJIYXNoMTYwIn1dLCJyZXR1cm50eXBlIjoiSW50ZWdlciIsIm9mZnNldCI6MjIsInNhZmUiOnRydWV9LHsibmFtZSI6InRyYW5zZmVyIiwicGFyYW1ldGVycyI6W3sibmFtZSI6ImZyb20iLCJ0eXBlIjoiSGFzaDE2MCJ9LHsibmFtZSI6InRvIiwidHlwZSI6Ikhhc2gxNjAifSx7Im5hbWUiOiJhbW91bnQiLCJ0eXBlIjoiSW50ZWdlciJ9LHsibmFtZSI6ImRhdGEiLCJ0eXBlIjoiQW55In1dLCJyZXR1cm50eXBlIjoiQm9vbGVhbiIsIm9mZnNldCI6MjIsInNhZmUiOmZhbHNlfV0sImV2ZW50cyI6W3sibmFtZSI6IlRyYW5zZmVyIiwicGFyYW1ldGVycyI6W3sibmFtZSI6ImZyb20iLCJ0eXBlIjoiSGFzaDE2MCJ9LHsibmFtZSI6InRvIiwidHlwZSI6Ikhhc2gxNjAifSx7Im5hbWUiOiJhbW91bnQiLCJ0eXBlIjoiSW50ZWdlciJ9XX1dfSwicGVybWlzc2lvbnMiOlt7ImNvbnRyYWN0IjoiKiIsIm1ldGhvZHMiOiIqIn1dLCJ0cnVzdHMiOltdLCJleHRyYSI6eyJlbWFpbCI6ImRldmVsb3BlckBuZW8ub3JnIiwiYXV0aG9yIjoibGF6eW5vZGUiLCJkZXNjcmlwdGlvbiI6IkEgU2ltcGxlIE5lcC0xNyBDb250cmFjdCJ9fQyyTkVGM25lb21sAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABOaHR0cHM6Ly9naXRodWIuY29tL2xhenlub2RlL25lb21sL2Jsb2IvZGV2L2V4YW1wbGVzL2EuZnVuY3Rpb24uc2ltcGxlbmVwMTcueG1sAAAAABYMBU5lb01MQBhAAgDh9QVAATkFQBFAkA456BLAHwwGZGVwbG95DBT9o/pDRupTKiWPxJfdrdtkN8n9/0FifVtS",
"hash" : "0x40302bcf2021f63a1c24f6009e154c3200f73ad2fe1462d7d599145823dbfa7e",
"witnesses" : [
{
"verification" : "DCECExn08eznGBdguHbcwI+R2//EtVdDx4qf6CeizHqOJgBBVuezJw==",
"invocation" : "DEBtoq+T9NrammQjuYnifco7KHCTk2v+woEJqJCUMr9IscS7PaZaN3FNzSt11yUglIi3T0CJ17KwArBOBvJ8kwq2"
}
],
"attributes" : [],
"signers" : [
{
"scopes" : "None",
"account" : "0x13a192c56738900f9918d7f1ec07d9d8c278b804"
}
],
"size" : 1360,
"nonce" : 1829882407,
"sender" : "NLLvsqs7AyBNmQT6NThUxYWDFwV5b1evaK",
"netfee" : "234352"
}
```
Transaction script contains malformed contract manifest (all methods
offsets are set to be 22, while the contract script lenght is 22):
```
{
"name" : "Nep17Token",
"groups" : [],
"extra" : {
"description" : "A Simple Nep-17 Contract",
"email" : "developer@neo.org",
"author" : "lazynode"
},
"permissions" : [
{
"contract" : "*",
"methods" : "*"
}
],
"features" : {},
"supportedstandards" : [
"NEP-17"
],
"abi" : {
"events" : [
{
"parameters" : [
{
"name" : "from",
"type" : "Hash160"
},
{
"type" : "Hash160",
"name" : "to"
},
{
"name" : "amount",
"type" : "Integer"
}
],
"name" : "Transfer"
}
],
"methods" : [
{
"safe" : true,
"offset" : 22,
"name" : "symbol",
"returntype" : "String",
"parameters" : []
},
{
"returntype" : "Integer",
"parameters" : [],
"safe" : true,
"offset" : 22,
"name" : "decimals"
},
{
"parameters" : [],
"returntype" : "Integer",
"name" : "totalSupply",
"safe" : true,
"offset" : 22
},
{
"parameters" : [
{
"name" : "owner",
"type" : "Hash160"
}
],
"returntype" : "Integer",
"name" : "balanceOf",
"offset" : 22,
"safe" : true
},
{
"name" : "transfer",
"offset" : 22,
"safe" : false,
"parameters" : [
{
"type" : "Hash160",
"name" : "from"
},
{
"name" : "to",
"type" : "Hash160"
},
{
"name" : "amount",
"type" : "Integer"
},
{
"name" : "data",
"type" : "Any"
}
],
"returntype" : "Boolean"
}
]
},
"trusts" : []
}
```
2022-06-03 11:37:50 +03:00
Anna Shaleva
1472c271e6
core: fix native NEO's getCandidateVote
signature
...
This commit fixes T5 statediff at block #0 . Management's storage item
differs between neo-go and C# nodes, the reason in native NEO contract
state.
The parameter should have `pubKey` name, unlike the other `pubkey`
arguments in this contract.
2022-06-03 11:37:50 +03:00
Anna Shaleva
ca127f1615
core: fix native NEO ABI
...
This commit fixes T5 statediff at block #0 . The reason in Management's
storage state. The diff occurs because of inconsistent NEO methods
order. See
https://github.com/neo-project/neo/issues/2766#issue-1257870089 .
The current solution is to preserve C#'s order of methods to be
compatible with current testnet.
See also
https://docs.microsoft.com/ru-ru/dotnet/api/system.stringcomparer?view=net-6.0
and
https://stackoverflow.com/questions/28638714/easiest-method-to-orderby-a-string-using-stringcomparison-ordinal
for more details.
2022-06-03 11:37:41 +03:00
Roman Khimov
edb6ca8926
Merge pull request #2531 from nspcc-dev/perf
...
Minor performance improvements
2022-06-03 10:40:56 +03:00
Roman Khimov
400cbde32c
state: optimize allocations in (*NEP17Transfer).EncodeBinary
2022-06-02 15:38:39 +03:00
Roman Khimov
9a06995460
bigint: don't allocate in ToPreallocatedBytes
...
Turns out, it's almost always allocating because we're mostly dealing with
small integers while the buffer size is calculated in 8-byte chunks here, so
preallocated buffer is always insufficient.
name old time/op new time/op delta
ToPreallocatedBytes-8 28.5ns ± 7% 19.7ns ± 5% -30.72% (p=0.000 n=10+10)
name old alloc/op new alloc/op delta
ToPreallocatedBytes-8 16.0B ± 0% 0.0B -100.00% (p=0.000 n=10+10)
name old allocs/op new allocs/op delta
ToPreallocatedBytes-8 1.00 ± 0% 0.00 -100.00% (p=0.000 n=10+10)
Fix StorageItem reuse at the same time. We don't copy when getting values from
the storage, but we don when we're putting them, so buffer reuse could corrupt
old values.
2022-06-02 15:38:39 +03:00
Roman Khimov
c3d989ebda
stackitem: reusable serialization context
...
We serialize items a lot and this allows to avoid a number of allocations.
2022-06-02 15:38:39 +03:00
Anna Shaleva
3bec6657f5
core: adjust notary-related attributes encoding
2022-06-01 15:09:06 +03:00
Anna Shaleva
1b80215415
core: adjust types of NVB, Conflicts and NotaryAssisted attributes
2022-06-01 15:09:06 +03:00