Commit graph

2332 commits

Author SHA1 Message Date
Evgenii Stratonikov
282b55494b consensus: allow to shutdown service 2020-09-18 12:07:01 +03:00
Evgenii Stratonikov
758a88a813 rpc: exit from Start after Listener is running
If port is dynamically allocated, `(*Server).Addr` will contain
0 port. This commit executes listener before exiting from `Start()`
and sets Addr to the actual address.
2020-09-18 12:05:31 +03:00
Evgenii Stratonikov
bcc11cbd74 compiler: support removing slice elements
Go-way of removing elements from slice is via `append` builtin.
There is a separate opcode for removing elements from
Arrays, which is cheaper and supported in this commit.
2020-09-15 16:33:43 +03:00
Evgenii Stratonikov
78948ef7af compiler: emit error for non-byte subslices
They are not supported for now, as VM has only
`SUBSTR` opcode for Buffers (`[]byte` in Go).
2020-09-15 16:21:44 +03:00
Roman Khimov
19c69618c5 transaction: cache tx size, don't serialize it over and over again 2020-09-11 18:55:19 +03:00
Roman Khimov
a6a1df4e0d consensus: update dbft, use new timer 2020-09-11 18:55:07 +03:00
Roman Khimov
83fc38ae3a mempool: don't create new big.Int in tryAddSendersFee() if possible
Do a little less allocations.
2020-09-10 15:35:19 +03:00
Roman Khimov
fc7ea6217d mempool: avoid reassigning utilityBalanceAndFees value
It's not needed, we're either creating a new one and assigning it 6 lines
above or we're changing already existing big.Int via a pointer, so no update
is needed.
2020-09-10 15:20:04 +03:00
Roman Khimov
7310e748e3 core: reuse mempool from AddBlock() for bc.isTxStillRelevant()
It's already there most of the time and creating another slice is just a waste
of time. Checking for presence with map is also a little faster.
2020-09-10 15:02:03 +03:00
Roman Khimov
26339c75dc vm/core: drop old key caching system
Obsoleted by f5f58a7e91.
2020-09-10 14:43:24 +03:00
Roman Khimov
120c4d4406 network: don't compress Inventory messages
They're not really compressable.
2020-09-09 20:46:31 +03:00
Roman Khimov
9c5ef8d234 dbft: rev up, pick performance improvements 2020-09-09 20:46:31 +03:00
Roman Khimov
b78bc7f097 network: fix tx requests, we can't ask more than 500 txes at once 2020-09-09 20:46:31 +03:00
Roman Khimov
fe1f1d19be mempool: store only pointer in the verifiedMap
It's only used for presence checks, there is no need for metadata here.
2020-09-09 20:46:31 +03:00
Roman Khimov
a2d9b89964 dao: reuse buffers when storing blocks, txes and aers
Reduce memory allocation pressure.
2020-09-09 20:46:31 +03:00
Roman Khimov
097b2b8e78 network: fail fast in iteratePeersWithSendMsg
This easily saves us some allocations for single node.
2020-09-09 20:46:31 +03:00
Roman Khimov
af17bbfeab rpc/server: encode answers more efficiently
We're at the point where even this code can clearly be seen in profiles. We
can save on some buffers (and CPU cycles) by encoding the answer once.

Another ~2% TPS for single node.
2020-09-09 20:46:31 +03:00
Roman Khimov
9187e2ab25 rpc/response: drop unused GetRawTx type 2020-09-09 20:46:31 +03:00
Roman Khimov
9591d64e53 mempool: don't sort items by hash
There is nothing requiring us to do so. It also is bad because it allows for
new transaction to replace some already existing one with the same fee
parameters just because it has "better" hash.

But the other thing is that for transactions with equal fees it's always
better for us to append them to the end of the list, instead of inserting them
in the middle, so this change allows to reduce slice item movements and gain
some 6-7% increase for single-node TPS.
2020-09-09 20:46:31 +03:00
Roman Khimov
5df726db68 mempool: replace timeStamp with blockStamp
Time is not really relevant for us here and we don't use this timestamp in any
way. Yet it occupies 24 bytes and we do two clock_gettime calls to get it.

Replace it with blockStamp which is going to be used in the future for
transaction retransmissions.

It allows to improve single-node TPS by another 3%.
2020-09-09 20:46:31 +03:00
Roman Khimov
bc31ab3d2c storage: add bloom filter to leveldb
We're constantly checking for transactions there and most of the time this
check is not successful (meaning that the transaction in question is
new). Bloom filter easily reduces the need to search over the DB in 99% of
these cases and gives some 13% increase in single-node TPS.
2020-09-09 20:46:31 +03:00
Roman Khimov
f5f58a7e91 keys: add simple LRU key cache for 1024 elements
The cost of Y calculation from X is comparable with signature check, so it
reduces witness check overhead by ~30% for cached keys and gives ~5% overall
boost in TPS.
2020-09-09 20:46:31 +03:00
Roman Khimov
0ea8c8ba67 mempool: drop a level of indirection
`item` is so small that it makes no sense bothering memory allocator with
every instance of it.
2020-09-09 20:46:31 +03:00
Roman Khimov
53c014a0bb crypto/consensus: sign hashes and cache them for consensus payloads
Avoid serializing payload again and again for various purposes. To sign it, we
only need a hash.

Some 2.4% gain in TPS could be achieved with this.
2020-09-09 20:46:31 +03:00
Roman Khimov
49e9c1aa0f
Merge pull request #1387 from nspcc-dev/rpc/notifications_state_serialisation
rpc: replace result.ApplicationLog with state.AppExecResult
2020-09-07 17:48:08 +03:00
Roman Khimov
cf322cd9f4
Merge pull request #1391 from nspcc-dev/compiler/const
Small compiler improvements
2020-09-07 17:46:41 +03:00
Anna Shaleva
27348973c3 rpc: fix JSON marshalling for Invoke result
We should return a quote string as JSON value in case of recursive
reference, otherwise json.Marshal returns an error.
2020-09-07 13:57:45 +03:00
Anna Shaleva
acacac1b24 rpc: use state.AppExecResult for ApplicationLog marshalling
Closes #1371
2020-09-07 13:38:32 +03:00
Anna Shaleva
34df5d5949 smartcontract: update trigger.Type stringer
We have to explicitly specify the type of `All` trigger type for proper
automatic generation of string representation.
2020-09-07 11:13:58 +03:00
Evgenii Stratonikov
7483e3b054 compiler: support delete() builtin 2020-09-06 15:49:41 +03:00
Evgenii Stratonikov
18369c489e compiler: do not allocate slotes for unused "_" vars 2020-09-06 15:27:46 +03:00
Evgenii Stratonikov
0b44a43043 compiler: do not allocate static slot for constants
Their value is known at compile time.
2020-09-06 15:20:17 +03:00
Evgenii Stratonikov
230700ee81 core: do not persist Policy contract
It has nothing to persist.
2020-09-05 10:54:47 +03:00
Roman Khimov
18204ec21a
Merge pull request #1383 from nspcc-dev/compiler/switchtag
compiler: fix a bug with type conversion in switch
2020-09-03 14:40:17 +03:00
Roman Khimov
cf15ca30f5
Merge pull request #1382 from nspcc-dev/compiler/manifest_methods_fix
compiler: do not convert methods to manifest methods
2020-09-03 14:39:51 +03:00
Anna Shaleva
70a58b6522 compiler: do not convert methods to manifest methods
Close #1381
2020-09-02 22:41:54 +03:00
Anna Shaleva
058da7c2bd compiler: getFuncNameFromDecl for methods on pointers
Declaration has *ast.StarExpr type in case of method on pointer.
2020-09-02 22:41:54 +03:00
Evgenii Stratonikov
98ca17aab8 network: restrict block queue size
Close #1374.
2020-09-02 17:04:49 +03:00
Evgenii Stratonikov
74dda0ac66 compiler: allow to use type conversion in range 2020-09-02 15:35:20 +03:00
Evgenii Stratonikov
3af7ce8c6b compiler: allow to use copy() return value 2020-09-02 15:29:59 +03:00
Evgenii Stratonikov
3d8c7af66c compiler: handle void call to recover()
Other builtins such as `len` and `make` can be ignored,
because not-assigning `make` result is catched by parser.
2020-09-02 15:20:43 +03:00
Evgenii Stratonikov
7d61a567d5 compiler: fix a bug with type conversion in switch
It was incorrectly parsed as void call.
2020-09-02 14:48:19 +03:00
Evgenii Stratonikov
1788cf02a1 core: fix VerifyTX test
HighPriority attribute was lost during intermediate code changes.
2020-08-27 18:40:37 +03:00
Evgenii Stratonikov
dce456f77f native: fix a bug in GetCommitteeMembers
Return standby committee instead of validators.
2020-08-27 18:40:37 +03:00
Evgenii Stratonikov
b0c051b817 internal: extend committee for unit tests
Committee should differ from the set of validators, to catch
possible bugs during testing.
2020-08-27 18:40:36 +03:00
Roman Khimov
3468f97836
Merge pull request #1343 from nspcc-dev/compiler/recover
Support `defer` statement
2020-08-27 17:33:12 +03:00
Roman Khimov
5d306297e9
Merge pull request #1367 from nspcc-dev/rpc/array_func_params
rpc: allow to use arrays in expandArrayIntoScript
2020-08-27 17:31:07 +03:00
Roman Khimov
9e0c13b69d
Merge pull request #1362 from nspcc-dev/feature/verification
Allow to use account with contracts on client
2020-08-27 17:30:29 +03:00
Anna Shaleva
5e8ce45a84 rpc: allow to use arrays in expandArrayIntoScript
Should be done together with #1363. Also removed
CreateInvocationScript function as we don't have `Invoke` RPC-call
anymore.
2020-08-27 16:38:45 +03:00
Roman Khimov
96f6ff9c8a
Merge pull request #1368 from nspcc-dev/fix/getapplog
rpc: support 0x form of Uint256 in requests
2020-08-27 13:35:38 +03:00