Commit graph

448 commits

Author SHA1 Message Date
Evgenii Stratonikov
db2dccf7cb emit: implement AppCallWithOperationAndArgs
It is nice to have a typical task of calling contract method
with specific arguments incapsulated inside some function.
2020-03-27 11:05:36 +03:00
Evgenii Stratonikov
fcc4877f43 go.mod: update boltdb to v1.3.4
Also import lib as declared in it's go.mod:
via `go.etcd.io/bbolt`.
2020-03-25 17:07:54 +03:00
Evgenii Stratonikov
c992d6c518 core: reuse buffer in (*cacheddao).Persist()
When serializing multiple accounts, cost of a buffer grow
can become significant. This commit tries to amortize it by
reusing the same buffer in a single `Persist()` call.
2020-03-25 13:13:54 +03:00
Evgenii Stratonikov
6ed2bd63b9 core: marshal AppExecResult.Stack as an array
Closes #782.
2020-03-23 16:27:47 +03:00
Roman Khimov
8400f0add2 mempool: gofmt -s 2020-03-17 16:47:51 +03:00
Roman Khimov
ec76a0bf15 mempool: disallow more than one issue tx at once
Technically they could conflict for available asset amount, but as they're
very rare (and even can be considered obsolete) we can simplify this check.
2020-03-17 11:40:01 +03:00
Roman Khimov
d5d0479671 core: verify results of issue transaction
It shouldn't try to issue more tokens than there is available.
2020-03-17 11:40:01 +03:00
Roman Khimov
10601cb375 core: add issuer hashes into the verification list for Issue TX
As it should be done.
2020-03-17 11:40:00 +03:00
Roman Khimov
dca637d2d0 core: add owner hash to verified list for Register TX
As it should be done.
2020-03-17 11:37:02 +03:00
Roman Khimov
77a799f7d0 core: add missing state tx verifications 2020-03-16 20:14:59 +03:00
Roman Khimov
6ede65610d core: add appropriate hashes to check for State TX
These checks are important for proper transaction verification.
2020-03-16 19:52:28 +03:00
Evgenii Stratonikov
b193e78def core: remove duplication from IsDoubleClaim/IsDoubleSpend 2020-03-16 14:11:19 +03:00
Evgenii Stratonikov
cdf025bf89 transaction: implement AddVerificationHash() method 2020-03-16 14:11:19 +03:00
Roman Khimov
e9429374aa
Merge pull request #756 from nspcc-dev/feature/unclaimed
core/state: do not unmarshal Unclaimed balances in account
2020-03-16 13:21:23 +03:00
Evgenii Stratonikov
e503d1001d core/state: do not unmarshal Unclaimed balances in account 2020-03-16 12:19:32 +03:00
Roman Khimov
e6e8761d35 core: fix contract's state migration and don't swallow errors
Fixes difference in state changes at mainnet's block 2442790 because contract
migration in b4eb2dc35226e6520ee4e09a56197dff91547b50a7f57edc82930fc18c75dffc
doesn't actually transfer the storage state, it only deletes the old one.

And add an error check just in case.
2020-03-16 11:52:09 +03:00
Roman Khimov
d9a83373ed
Merge pull request #748 from nspcc-dev/feature/splitnep5
core: store NEP5 balances separately from account
2020-03-12 18:31:25 +03:00
Evgenii Stratonikov
ac475940a0 core: cache NEP5Transfers in cached DAO 2020-03-12 17:16:11 +03:00
Evgenii Stratonikov
6fa2a998f4 core: cache NEP5Balances in cached DAO 2020-03-12 17:06:20 +03:00
Evgenii Stratonikov
32401a567e core: store NEP5Transfers in batches
This is an append-only log which is read only during some RPCs.
It is rather slow to get it from base every time we need to append to
it. This commit stores all NEP5Transfers in batches, so that
only a last batch needs to be unmarshaled during block processing.
2020-03-12 14:51:12 +03:00
Evgenii Stratonikov
3c6d9653b0 core/state: add Size() method to NEP5TransferLog 2020-03-12 12:58:30 +03:00
Evgenii Stratonikov
df2598c8dc core: store NEP5 balances separately
There is no need to take and unmarshal an account structure only
to get it's NEP5 balances.
2020-03-12 12:58:28 +03:00
Roman Khimov
bbd802681e cli: make gas parameter to deployment add gas to the base price
That's how it was intended to behave originally. One thing questionable here
is contract price (policy thing, basically) being moved to smartcontract
package, but it's probably fine for NEO 2.0 (as it won't change) and we'll
make something better for NEO 3.0.
2020-03-11 20:34:36 +03:00
Roman Khimov
5f1868af28
Merge pull request #743 from nspcc-dev/optimize-some-db-accesses
Optimize some db accesses
2020-03-11 17:33:36 +03:00
Roman Khimov
abd7855890
Merge pull request #742 from nspcc-dev/add-dynamic-appcall
vm: add support for dynamic invocations in APPCALL
2020-03-11 17:27:05 +03:00
Roman Khimov
8c902a7223 core: cache UnspentCoins in cachedDao
1.5M block import time (VerifyBlocks disabled) on AMD Ryzen 5 1600/16GB/HDD,
before:
real    159m16.551s
user    69m58.279s
sys     7m34.334s

after:
real    139m41.836s
user    67m12.477s
sys     6m19.420s

12% which is even a bit more than could be expected from inputs analysis (that
has around 10% cache hits for a block-wide cache), worth doing.
2020-03-11 12:40:02 +03:00
Roman Khimov
23464401bc core/state: merge spent and unspent coins state, use it to store more things
This change reduces pressure on DB by doing the following things:
 * not storing additional KV pair for SpentCoin
 * storing Output right in the UnspentCoin, thus eliminating the need to get a
   full transaction from DB

At the same time it makes UnspentCoin more fat and hot, but it should probably
worth it.

Also drop `GetUnspentCoinStateOrNew` as it shouldn't ever existed, UTXOs
can't come out of nowhere.

1.5M block import time (VerifyBlocks disabled) on AMD Ryzen 5 1600/16GB/HDD,
before:
real    302m9.895s
user    96m17.200s
sys     13m37.084s

after:
real    159m16.551s
user    69m58.279s
sys     7m34.334s

So it's almost two-fold which is a great improvement.
2020-03-11 12:40:02 +03:00
Roman Khimov
e1f194ea7b core: treat state.Coin as a bitfield
As it was intended to.
2020-03-11 12:22:57 +03:00
Roman Khimov
377fb382aa core: move (un)SpentCoin structs into the state package
As they're all about the state.
2020-03-11 12:22:52 +03:00
Roman Khimov
8318adac56 vm: add support for dynamic invocations in APPCALL
Fixes #740.
2020-03-10 17:17:36 +03:00
Evgenii Stratonikov
ebf867b11d state: add a test for NEP5Transfer size
It's size is used in NEP5TransferLog so we need to be
sure it reflects reality.
2020-03-10 13:02:14 +03:00
Roman Khimov
ee57b96566
Merge pull request #733 from nspcc-dev/fix-getreferences-interop-regression
Fix GetReferences interop regression
2020-03-10 10:27:36 +03:00
Roman Khimov
0e2bda4f21 core: drop txHash from SpentCoinState
It's a key for it, makes no sense storing it as data.
2020-03-09 16:58:21 +03:00
Roman Khimov
eb404ceae3 core: fix max contract description limit check
It differs from other parameters in C# code. Fixes #735.
2020-03-09 14:18:51 +03:00
Roman Khimov
4587121c7f core: fix error propagation in contract-related interops
Obvious bug that hides failed contract deployments.
2020-03-09 14:18:00 +03:00
Roman Khimov
4b83e9a5cd
Merge pull request #732 from nspcc-dev/feature/getvalidators
rpc: implement getvalidators
2020-03-07 21:43:38 +03:00
Anna Shaleva
456a2d55fd rpc: implement getvalidators
closes #714
2020-03-07 18:05:40 +03:00
Roman Khimov
baeaa3dbe6 core: optimize tx verification, only get references and results once
Getting references requires DB access and that is expensive.
2020-03-06 20:15:01 +03:00
Roman Khimov
fe4916f691 core: simplify GetTransactionResults() a bit
Make less movements.
2020-03-06 19:26:39 +03:00
Roman Khimov
ced5ddbb9e core: fix wrong references ordering in interop function
Broken by 9f7018503a. Almost the same problem as
in 01082a8988 (though it is deterministic now,
just not the way the contract expects).
2020-03-06 19:20:55 +03:00
Roman Khimov
0e8ff558d1
Merge pull request #727 from nspcc-dev/fix-wrong-endian-in-interop-hashes
core: fix wrong endian used in interop functions
2020-03-06 19:07:28 +03:00
Roman Khimov
f8eee778f4
Merge pull request #724 from nspcc-dev/feature/submitblock
rpc: implement submitblock
2020-03-06 12:08:45 +03:00
Anna Shaleva
a746d8e6e6 rpc: implement submitblock RPC
closes #344
2020-03-06 12:03:08 +03:00
Evgenii Stratonikov
40188c5400 core: get rid of unnecessary copies
There is no need to keep Balances and Unclaimed slices
sorted, we need only to remove a single element.
2020-03-05 20:42:20 +03:00
Anna Shaleva
d3063c26e1 core: add custom error to blockhain.go
Add InvalidBlockIndex error to AddBlock func
2020-03-05 20:30:19 +03:00
Roman Khimov
a9abd3d841 core: fix wrong endian used in interop functions
C# uses ToArray() or UintXXX(bytes) here which interprets hashes as they
should be interpreted (BE, although they always convert to LE when converting
to String just for the fun of it). It leads to state difference for us at
block 2025204 where even though we have the same value for the key, the key
itself differs, ours:

dd2b538e2a0c1db1ae5061c15be14f916bd1e678e512ffcda6d9499d8e7fe97ee71fd6b8004583d9afe09cc4dadbd5deb63d01e061009b7cffdaa674beae0f930ebe6085af900093e5fe56b34a5c220ccdcf6efc336fc5000000000000000000000000000000000010

theirs:

dd2b538e2a0c1db1ae5061c15be14f916bd1e67861e0013db6ded5dbdac49ce0afd9834500b8d61fe77ee97f8e9d49d9a6cdff12e5009b7cffdaa674beae0f930ebe6085af900093e5fe56b34a5c220ccdcf6efc336fc5000000000000000000000000000000000010

In this key there is a tx hash encoded
(e512ffcda6d9499d8e7fe97ee71fd6b84583d9afe09cc4dadbd5deb63d01e061 in LE used
by all the tools like neoscan).

I love Neo.
2020-03-05 19:44:09 +03:00
Evgenii Stratonikov
95a8fa234f rpc: implement getnep5transfers RPC 2020-03-05 18:22:40 +03:00
Evgenii Stratonikov
6d270c4550 core,rpc: add NEP5 contract to testdata
Also transfer tokens between accounts.
2020-03-05 18:22:40 +03:00
Evgenii Stratonikov
f92fd3c948 core: track NEP5 transfers 2020-03-05 18:22:40 +03:00
Evgenii Stratonikov
e8c4179a9c core: track NEP5 balances 2020-03-05 18:22:19 +03:00