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
Evgenii Stratonikov
d25dddc780
rpc: refactor getDecimals
...
Use existing functions to invoke smartcontract's
method instead of constructing ad-hoc script.
2020-03-12 12:19:31 +03:00
Evgenii Stratonikov
05544a1510
rpc: return empty arrays instead of null in getnep5* RPCs
2020-03-12 12:19:30 +03:00
Roman Khimov
1b5dd53e07
Merge pull request #746 from nspcc-dev/fix/equal
...
vm: implement EQUAL opcode properly
Fixes #745 , #749 .
2020-03-12 11:46:51 +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
695c4dd6ae
Merge pull request #744 from nspcc-dev/feature/getunclaimed
...
rpc: implement getunclaimed
2020-03-11 19:18:36 +03:00
Anna Shaleva
c23a522d25
rpc: implement getunclaimed
...
closes #712
2020-03-11 18:33:15 +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
Evgenii Stratonikov
dfc59129c7
vm: implement EQUAL opcode properly
...
When comparing elements of different types, conversions
should be performed. This commit implement custom equality
predicate for each stack item type.
2020-03-11 17:19:10 +03:00
Evgenii Stratonikov
5da82e8cf0
vm: add TryBytes() to StackItem interface
...
Conversion should be done in a StackItem, not in an Element.
2020-03-11 16:33:46 +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
aab7dd515f
Merge pull request #728 from nspcc-dev/feature/nep5cli
...
cli: implement NEP5-related commands
2020-03-10 18:10:00 +03:00
Roman Khimov
b7fa8dd40f
Merge pull request #741 from nspcc-dev/fix/network
...
network: fix possible deadlock in DefaultDiscovery
2020-03-10 17:29:45 +03:00
Roman Khimov
19f55e7280
Merge pull request #731 from nspcc-dev/feature/cleanstack
...
compiler: clean up stack on branch statements
2020-03-10 17:28:27 +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
b7dee156e2
network: fix a deadlock in DefaultDiscovery
...
Why a deadlock can occur:
1. (*DefaultDiscovery).run() has a for loop over requestCh channel.
2. (*DefaultDiscovery).RequestRemote() send to this channel while
holding a mutex.
3. (*DefaultDiscovery).RegisterBadAddr() tries to take mutex for write.
4. Second select-case can't take mutex for read because of (3).
2020-03-10 15:40:23 +03:00
Evgenii Stratonikov
2a1402f25d
compiler: clean up stack on branch statements
...
When `return` or `break` statement is encountered inside
a for/range/switch statement, top stack items can be auxilliary.
They need to be cleaned up before returning from the function.
2020-03-10 15:26:00 +03:00
Evgenii Stratonikov
c2924795ad
cli: fix a bug in wallet claim
...
getclaimable RPC expects address as a 1-st argument.
2020-03-10 13:02:14 +03:00
Evgenii Stratonikov
97131683d8
cli: display info about imported NEP5 token
2020-03-10 13:02:14 +03:00
Evgenii Stratonikov
053b779be7
cli: implement NEP5 transfer
2020-03-10 13:02:14 +03:00
Evgenii Stratonikov
bcc03e2068
cli: implement NEP5 balance querying
2020-03-10 13:02:14 +03:00
Evgenii Stratonikov
519b27fe0e
cli: implement NEP5 token import
...
To work with NEP5 tokens, one need to save some info
e.g. token Name. This way we will not make additional
RPC just to get Decimals.
2020-03-10 13:02:14 +03:00
Evgenii Stratonikov
22e99a5b3e
rpc: implement (*Client).NEP5TokenInfo()
...
It can be useful to receive all NEP5 token info at once.
2020-03-10 13:02:14 +03:00
Evgenii Stratonikov
564a8e429d
wallet: allow to add token contracts to the wallet
2020-03-10 13:02:14 +03:00
Evgenii Stratonikov
d447064515
util: implement FixedN from string
...
When working with NEP5 contracts we frequently need
to parse fixed-point decimals with arbitrary precision.
2020-03-10 13:02:14 +03:00
Evgenii Stratonikov
cdeba6d417
rpc: implement (*Client).NEP5* methods
2020-03-10 13:02:14 +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
3f1e8f66b6
Merge pull request #739 from nspcc-dev/fix/gomod
...
*: go mod tidy
2020-03-10 13:01:17 +03:00
Evgenii Stratonikov
386ff07054
*: go mod tidy
2020-03-10 12:55:41 +03:00
Roman Khimov
15a5c7f3d6
Merge pull request #738 from nspcc-dev/feature/fallthrough
...
compiler: implement fallthrough in switch
2020-03-10 12:44:35 +03:00
Evgenii Stratonikov
91301df161
compiler: implement fallthrough in switch
...
Closes #628 .
2020-03-10 12:34:07 +03:00
Roman Khimov
726237726b
Merge pull request #737 from nspcc-dev/fix/emptyaddress
...
cli: do not allow default value for an empty address
2020-03-10 10:30:59 +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
cc8203fc59
Merge pull request #736 from nspcc-dev/fix-contract-description-limit
...
Fix contract description limit
2020-03-10 10:27:25 +03:00
Evgenii Stratonikov
8d73276393
cli: do not allow default value for an empty address
...
Right now a bizarre error message can occur if an address flag was not
set: `wallet contains no account for 'AFmseVrdL9f9oyCzZefL9tG6UbvhPbdYzM'`.
This bug is 10x worse if it occures in `transfer` --from flag.
2020-03-10 09:54:23 +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
1b7b9e74d1
Merge pull request #734 from nspcc-dev/fix/getblock-response
...
[rpc/server] fix getblock verbose response
2020-03-06 20:10:14 +03:00
Evgeniy Kulikov
b34ac22434
[rpc/server] fix getblock verbose response
...
- Nonce should not trim leading zeros
- NextConsensus should returns address (uint160 -> base58)
2020-03-06 19:53:11 +03:00
Roman Khimov
fe4916f691
core: simplify GetTransactionResults() a bit
...
Make less movements.
2020-03-06 19:26:39 +03:00