Commit graph

3623 commits

Author SHA1 Message Date
Roman Khimov
6902003044 rpc/server: add limit to get*transfers calls
Return only N transfers requested.
2020-09-21 18:03:59 +03:00
Evgenii Stratonikov
fc77f8b5b2 consensus: exit if wrong password is provided in configuration 2020-09-21 17:56:25 +03:00
Roman Khimov
0c264b1486 mpt: fix comment typo 2020-09-21 17:54:11 +03:00
Roman Khimov
f0f676eb1c
Merge pull request #1416 from nspcc-dev/rpc/getcommittee
core, rpc: add GetCommittee method
2020-09-21 17:29:16 +03:00
Anna Shaleva
770c8d774c core, rpc: add GetCommittee method
Closes #1414
2020-09-21 15:56:25 +03:00
Roman Khimov
dbfdfd8e9b
Merge pull request #1413 from nspcc-dev/core/block_aer_marshalling
core: do not marshal block hash in application log
2020-09-21 14:22:17 +03:00
Anna Shaleva
c6f099294b core: do not marshal block hash in application log
Closes #1388
2020-09-21 14:08:15 +03:00
Roman Khimov
a439941a71
Merge pull request #1407 from nspcc-dev/core/oracleattr
Implement OracleResponse transaction attribute
2020-09-21 12:55:10 +03:00
Roman Khimov
a9f5fe424d
Merge pull request #1411 from nspcc-dev/fix-panic-in-cli-tests
consensus: wait goroutine to finish on Shutdown
2020-09-21 09:45:24 +03:00
Roman Khimov
15b621f0f3 consensus: wait goroutine to finish on Shutdown
Fixes:
panic: assignment to entry in nil map

goroutine 227 [running]:
github.com/nspcc-dev/neo-go/pkg/core/storage.(*MemoryStore).put(...)
        /home/rik/dev/neo-go/pkg/core/storage/memory_store.go:53
github.com/nspcc-dev/neo-go/pkg/core/storage.(*MemoryStore).PutBatch(0xc00035f580, 0x110a680, 0xc000336750, 0x0, 0x0)
        /home/rik/dev/neo-go/pkg/core/storage/memory_store.go:93 +0x286
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).addHeaders(0xc0000a2340, 0xc0001be301, 0xc00036d428, 0x1, 0x1, 0x0, 0x0)
        /home/rik/dev/neo-go/pkg/core/blockchain.go:516 +0xd5a
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).AddBlock(0xc0000a2340, 0xc0000bc2c0, 0x0, 0x0)
        /home/rik/dev/neo-go/pkg/core/blockchain.go:407 +0x9ca
github.com/nspcc-dev/neo-go/pkg/consensus.(*service).processBlock(0xc000152160, 0x1122320, 0xc0000bc2c0)
        /home/rik/dev/neo-go/pkg/consensus/consensus.go:440 +0xbf
github.com/nspcc-dev/dbft.(*DBFT).checkCommit(0xc0000d3400)
        /home/rik/go/pkg/mod/github.com/nspcc-dev/dbft@v0.0.0-20200911152629-be965ee4d449/check.go:71 +0x918
github.com/nspcc-dev/dbft.(*DBFT).checkPrepare(0xc0000d3400)
        /home/rik/go/pkg/mod/github.com/nspcc-dev/dbft@v0.0.0-20200911152629-be965ee4d449/check.go:36 +0x465
github.com/nspcc-dev/dbft.(*DBFT).sendPrepareRequest(0xc0000d3400)
        /home/rik/go/pkg/mod/github.com/nspcc-dev/dbft@v0.0.0-20200911152629-be965ee4d449/send.go:42 +0x2f8
github.com/nspcc-dev/dbft.(*DBFT).start(0xc0000d3400)
        /home/rik/go/pkg/mod/github.com/nspcc-dev/dbft@v0.0.0-20200911152629-be965ee4d449/dbft.go:269 +0x26f
github.com/nspcc-dev/dbft.(*DBFT).Start(0xc0000d3400)
        /home/rik/go/pkg/mod/github.com/nspcc-dev/dbft@v0.0.0-20200911152629-be965ee4d449/dbft.go:82 +0x59
github.com/nspcc-dev/neo-go/pkg/consensus.(*service).Start(0xc000152160)
        /home/rik/dev/neo-go/pkg/consensus/consensus.go:191 +0x56
github.com/nspcc-dev/neo-go/pkg/network.(*Server).tryStartConsensus(0xc000235040)
        /home/rik/dev/neo-go/pkg/network/server.go:311 +0xda
github.com/nspcc-dev/neo-go/pkg/network.(*Server).Start(0xc000235040, 0xc0000faba0)
        /home/rik/dev/neo-go/pkg/network/server.go:173 +0x202
created by github.com/nspcc-dev/neo-go/cli.newTestChain
        /home/rik/dev/neo-go/cli/executor_test.go:77 +0x47d
FAIL    github.com/nspcc-dev/neo-go/cli 14.479s
2020-09-19 21:49:05 +03:00
Roman Khimov
1608fbff87
Merge pull request #1378 from nspcc-dev/tests/cli
Implement tests for CLI
2020-09-19 17:02:34 +03:00
Roman Khimov
bdee702f76
Merge pull request #1410 from nspcc-dev/fix-potential-consensus-stall
consensus: fix potential system deadlock
2020-09-18 12:42:52 +03:00
Evgenii Stratonikov
bff67c921a core: wrap dao in GetTestVM
MPT must not be shared to the test VM.
Fix DATA RACE between `Collapse()` and RPC calls.
2020-09-18 12:07:02 +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
914b12af44 network: fix datarace in TCPTransport 2020-09-18 12:07:02 +03:00
Evgenii Stratonikov
fd98a9194a cli: add tests for wallet dump 2020-09-18 12:07:02 +03:00
Evgenii Stratonikov
40a24bad64 cli: add tests for wallet import-deployed
Fix bugs with import, allow to sign tx with contract.
2020-09-18 12:07:02 +03:00
Evgenii Stratonikov
583ef546f9 cli: add tests for wallet claim
Fix a NEO contract hash used in tx.
2020-09-18 12:07:02 +03:00
Evgenii Stratonikov
dff2ac1387 cli: add test for candidate register/unregister/vote
Also fix a bug with tx signing.
2020-09-18 12:07:02 +03:00
Evgenii Stratonikov
6e5a637da9 cli: add tests for multisig sign
This test is also a good example of how to
create and sign multisig transaction from scratch.
2020-09-18 12:07:02 +03:00
Evgenii Stratonikov
9817da7c4e cli: add tests for nep5 import/remove
Also unify `remove` and `import` arguments.
2020-09-18 12:07:02 +03:00
Evgenii Stratonikov
075f353062 cli: add tests for nep5 multitransfer
Also fix a bug when token's hash was incorrectly processed.
2020-09-18 12:07:02 +03:00
Evgenii Stratonikov
59157724e3 cli: add tests for wallet remove 2020-09-18 12:07:02 +03:00
Evgenii Stratonikov
4c00b26fb8 cli: add tests for wallet import-multisig 2020-09-18 12:07:02 +03:00
Evgenii Stratonikov
0a5fe84589 cli: add tests for wallet export 2020-09-18 12:07:02 +03:00
Evgenii Stratonikov
5d7f177811 cli: add tests for wallet/account creation 2020-09-18 12:07:02 +03:00
Evgenii Stratonikov
d30c7db49a cli: add tests for NEP5 transfer 2020-09-18 12:07:02 +03:00
Evgenii Stratonikov
468f7ee650 cli: add tests for NEP5 balance querying 2020-09-18 12:07:02 +03:00
Evgenii Stratonikov
282b55494b consensus: allow to shutdown service 2020-09-18 12:07:01 +03:00
Evgenii Stratonikov
0dda247719 cli: move input handling to a separate package 2020-09-18 12:05:31 +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
911be78cc7 cli: use Writer from app instead of Stdout
It is useful in tests.
2020-09-18 12:05:31 +03:00
Roman Khimov
af6a6f5f30 consensus: fix potential system deadlock
There is a notification pushed into the channel when block is being added,
that notification is read by special goroutine that then forwards it to all
subscribers to that particular event. Consensus goroutine is one of that
subscribers, so for the system to properly function it has to read these
events, but at the same time it can generate new blocks inside, so in some
cases it can generate two blocks without ever reading from the subscription
channel and this will lead to a deadlock.

To avoid that we need to check subscription channel for events on every loop.
2020-09-18 10:21:47 +03:00
Roman Khimov
1dc93216ee
Merge pull request #1408 from nspcc-dev/header-hash-list
Header hash list optimization
2020-09-16 17:52:44 +03:00
Roman Khimov
61ad82160b core: remove named return variable from addHeaders() 2020-09-16 17:45:12 +03:00
Roman Khimov
6bffa811d4 core: remove (*block.Block) checks for topBlock
If it's non-nil, it has *block.Block inside. If it doesn't --- tell everyone
about it with a nice panic message.
2020-09-16 17:40:27 +03:00
Roman Khimov
33ea179f6e core: remove forward index check from addHeaders()
It can't ever happen. We're guaranteed to have a consistent chain of headers
(we're verifying them above, if we're not verifying --- it's not our fault)
that starts at HeaderHeight that was actual when we were asking for it
previously. HeaderHeight can only move forward, so if that happened that would
be filtered out by the condition below and the first one can't happen. Though
to be absolutely sure change the second check to only pass "+1" headers (which
is what we want).
2020-09-16 16:33:42 +03:00
Roman Khimov
7cbb660082 core: rework headerList
It's a contention point as all accesses to it are serialized and they compete
with persisting logic at the same time.
2020-09-16 16:30:40 +03:00
Evgenii Stratonikov
1625689316 transaction: implement OracleResponse attribute 2020-09-16 14:50:31 +03:00
Roman Khimov
5f22bdfecf
Merge pull request #1375 from nspcc-dev/compiler/types
Smartcontract types definition in interops
2020-09-16 14:43:50 +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
e414ad3d47
Merge pull request #1406 from nspcc-dev/rpc-fix-websocket-tests
rpc/server: fix "websocket: bad handshake" during testing
2020-09-16 14:27:12 +03:00
Evgenii Stratonikov
06b29e409c transaction: remove Attribute.Data field 2020-09-16 13:39:53 +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
2e876b5593 block: remove Base.Verify()
It's a no-op and there is nothing we can do about it, header contents could
only be checked against chain state, there is nothing to check for internal
consistency.
2020-09-16 12:50:13 +03:00
Roman Khimov
d2b37adf95
Merge pull request #1403 from nspcc-dev/merkle-memory-optimization
hash: introduce memory-optimized merkle root hash calculation routine
2020-09-16 12:48:33 +03:00
Roman Khimov
bfe3b3d05d
Merge pull request #1401 from nspcc-dev/compiler/subslice
Support removing elements from slice.
2020-09-15 18:42:08 +03:00
Roman Khimov
d52e79668b hash: introduce memory-optimized merkle root hash calculation routine
NewMerkleTree is a memory hog, we can do better than that:

BenchmarkMerkle/NewMerkleTree-8                       13          88434670 ns/op        20828207 B/op     300035 allocs/op
BenchmarkMerkle/CalcMerkleRoot-8                      15          69264150 ns/op               0 B/op          0 allocs/op
2020-09-15 18:38:15 +03:00
Evgenii Stratonikov
5ba22a02f4 docs: mention util and convert packages in compiler 2020-09-15 16:34:00 +03:00