Commit graph

509 commits

Author SHA1 Message Date
Roman Khimov
1608fbff87
Merge pull request #1378 from nspcc-dev/tests/cli
Implement tests for CLI
2020-09-19 17:02:34 +03:00
Evgenii Stratonikov
e0f406fd3a rpc/client: add constant to ValidUntilBlock
There are 2 problems:
1. `getvalidators` RPC can return empty list.
2. `+1` in single node can be too resrictive.
Proper solution for (1) may require requesting
standby validators. Here we add constant
to fix occasional test failures.
2020-09-18 12:07:02 +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
Roman Khimov
6f3aff76a4
Merge pull request #1405 from nspcc-dev/rework-block-verifications
Rework block verifications a bit
2020-09-16 14:27:24 +03:00
Roman Khimov
93be4bbeee rpc/server: fix "websocket: bad handshake" during testing
I think it's caused by connection limits server-side, we never close
connection on the client.
2020-09-16 12:51:59 +03:00
Roman Khimov
ce09c82b25 block: remove Verify()
It's used in two places now:
 * Blockchain.AddBlock()
   This one does transaction duplication check of its own, doing it in
   Verify() is just a waste of time. Merkle tree root hash value check is
   still relevant though
 * Block.DecodeBinary()
   We're decoding blocks for the following purposes:
     - on restore from dump
       The block will be added to the chain via AddBlock() and that will do a
       full check of it (if configured to do so)
     - on retrieving the block from the DB (DAO)
       We trust the DB, if it's gone wild, this check won't really help
     - on receiving the block via P2P
       It's gonna be put into block queue and then end up in AddBlock() which
       will check it
     - on receiving the block via RPC (submitblock)
       It is to be passed into AddBlock()
     - on receiving the block via RPC in a client
       That's the only problematic case probably, but RPC client has to trust
       the server and it can check for the signature if it really
       cares. Or a separate in-client check might be added.

As we can see nothing really requires this verification to be done the way it
is now, AddBlock can just have a Merkle check and DecodeBinary can do fine
without it at all.
2020-09-16 12:50:13 +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
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
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
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
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
Evgenii Stratonikov
db4eecf4dc rpc: support 0x form of Uint256 in requests 2020-08-27 12:36:33 +03:00
Evgenii Stratonikov
9c7168e4e8 rpc/client: allow to use contract accounts in AddNetworkFee 2020-08-27 11:32:55 +03:00
Evgenii Stratonikov
72ca8b79c3 rpc/client: provide sender in CreateNEP5MultiTransferTx
Specify scope explicitly.
Fix #1354.
2020-08-25 09:21:06 +03:00
Roman Khimov
7fedb4f4ba testchain: move newBlock there from rpc/server
Allow its reuse by other components.
2020-08-20 18:50:36 +03:00
Roman Khimov
9257167af3
Merge pull request #1328 from nspcc-dev/tests/addnetworkfee
rpc/client: provide scripts in AddNetworkFee
2020-08-18 15:30:47 +03:00
Evgenii Stratonikov
6bdaefcfa4 rpc/client: use CreateTxFromScript where possible
There is substantial overlap between `CreateTxFromScript` and
`SignAndPushInvocationTx`. This commit refactors both of them
to reuse common code.
2020-08-18 11:24:48 +03:00
Evgenii Stratonikov
16b10ab918 rpc/client: drop (*Client).wif
It isn't used internally and has no value.
2020-08-18 11:24:48 +03:00
Evgenii Stratonikov
316666cc22 rpc/client: add tests for Ping 2020-08-18 11:24:48 +03:00
Evgenii Stratonikov
48f1502167 rpc/client: add tests for SignAndPushInvocationTx 2020-08-18 11:24:48 +03:00
Evgenii Stratonikov
2699508914 wallet: emit proper multisignature
In case when a signature needs to be added to multisig
we must first find corresponding signer, not append new witness.
2020-08-18 11:24:48 +03:00
Evgenii Stratonikov
8699a4c1a9 rpc/client: provide scripts in AddNetworkFee
To calculate network fee properly we must know type of every
signer (simple, multisig, contract). Providing scripts is the most
simple and flexible way to know this.
2020-08-18 11:24:48 +03:00
Roman Khimov
d0c29f52c9 core: verification script must return exactly one value
C# node is quite picky as it expects there to be exactly one value returned,
but our testchain actually adds 4 signatures for multisig cases instead of 3
which makes it technically incompatible with C# node.
2020-08-17 22:02:15 +03:00
Roman Khimov
92f37a5d36
Merge pull request #1324 from nspcc-dev/fix-goreportcard-issues
Fix goreportcard issues
2020-08-14 14:50:35 +03:00
Roman Khimov
40bcd4c0bc
Merge pull request #1231 from nspcc-dev/fix/printops
vm: pretty-print remaining opcodes
2020-08-14 14:43:29 +03:00
Evgenii Stratonikov
7854dcfd8f core: replace interop names with named constants 2020-08-14 14:21:54 +03:00
Roman Khimov
e7d13e6db2 *: fix misspellings found in Go Report Card 2020-08-14 12:16:24 +03:00
Roman Khimov
70cc8b89e8
Merge pull request #1323 from nspcc-dev/fix/clienttests
rpc: fix (*Client).BalanceOf
2020-08-14 11:54:36 +03:00
Evgenii Stratonikov
a8cda69bc3 rpc: fix (*Client).BalanceOf
Add missing argument and write tests.
2020-08-14 11:19:24 +03:00
Anna Shaleva
0834661cac rpc: marshal getapplicationlog stack as []stackitem.Item
Following https://github.com/neo-project/neo-modules/issues/318
2020-08-13 17:16:31 +03:00
Roman Khimov
b31e18096f rpc/client: remove obsolete retry from invokeSomething()
All preview3 nodes have proper support for scoped signers in parameters.
2020-08-11 21:21:38 +03:00
Roman Khimov
c16040aecc native: sort GetValidators result
As it's returned sorted now. Fixes state change mismatch for
NextValidators. It also partially reverts
2f8e7e4d33 and significantly changes the test
chain as the fees are no longer being sent to the same account.
2020-08-10 19:49:09 +03:00
Roman Khimov
fb97ea9458 native: don't register standby validators on initialization
C# doesn't do that since neo-project/neo#1762.
2020-08-10 17:51:46 +03:00
Roman Khimov
6e252fbaae rpc: answer with zero-length when there are no registered validators
There is a huge difference between
   "result" : [],
and
   "result" : null,
2020-08-10 17:50:19 +03:00
Evgenii Stratonikov
412fc53cdd rpc: provide timestamps in getnep5transfers
Set default value for the first timestamp to a week ago.
2020-08-07 18:42:34 +03:00
Evgenii Stratonikov
807338f97e core: do not store NEP5 transfer log in memory
Traversing transfer log instead of accumulating and returning it
is faster and takes less memory.
2020-08-07 18:21:06 +03:00
Roman Khimov
c3c88a57cd
Merge pull request #1281 from nspcc-dev/drop-go-1.12-and-fix-some-things
Drop go 1.12 and fix some things
2020-08-07 13:34:54 +03:00
Roman Khimov
0e2784cd2c always wrap errors when creating new ones with fmt.Errorf()
It doesn't really change anything in most of the cases, but it's a useful
habit anyway.

Fix #350.
2020-08-07 12:21:52 +03:00
Roman Khimov
205f52c563 core: use error wrapping to provide more details 2020-08-07 12:21:52 +03:00
Roman Khimov
5ef08f60ae remove github.com/pkg/errors from dependencies
It's not needed any more with Go 1.13 as we have wrapping/unwrapping in base
packages. All errors.Wrap calls are replaced with fmt.Errorf, some strings are
improved along the way.
2020-08-07 12:21:52 +03:00
Evgenii Stratonikov
05c24d9401 cli: support voting
Closes #1206.
2020-08-06 20:39:13 +03:00
Evgenii Stratonikov
9bc731b3b1 native: implement delegated voting
Close #867.
2020-08-06 20:39:13 +03:00
Roman Khimov
4bbe863904
Merge pull request #1266 from nspcc-dev/notifications/filter_by_name
rpc: filter subscriptions' notifications by name
2020-08-05 10:00:15 +03:00
Roman Khimov
ef53a45e7a
Merge pull request #1264 from nspcc-dev/smartcontract/manifest/supported_standards
smartcontract: add list of supported standards to manifest
2020-08-04 22:17:00 +03:00
Roman Khimov
49688de75c
Merge pull request #1260 from nspcc-dev/feature/sendmany
cli: allow to transfer multiple tokens in `multitransfer`
2020-08-04 19:35:03 +03:00
Anna Shaleva
90825efa16 core: move transaction's sender to cosigners
Closes #1184

Ported changes from https://github.com/neo-project/neo/pull/1752
2020-08-04 17:33:50 +03:00