Roman Khimov
760b39e324
consensus: close chain in tests
...
Avoid test failures like this one:
=== RUN TestService_OnPayload
==================
WARNING: DATA RACE
Read at 0x00c00015a843 by goroutine 112:
testing.(*common).logDepth()
/usr/local/go/src/testing/testing.go:665 +0xa1
testing.(*common).Logf()
/usr/local/go/src/testing/testing.go:658 +0x8f
testing.(*T).Logf()
<autogenerated>:1 +0x75
go.uber.org/zap/zaptest.testingWriter.Write()
/go/pkg/mod/go.uber.org/zap@v1.10.0/zaptest/logger.go:130 +0x11f
go.uber.org/zap/zaptest.(*testingWriter).Write()
<autogenerated>:1 +0xa9
go.uber.org/zap/zapcore.(*ioCore).Write()
/go/pkg/mod/go.uber.org/zap@v1.10.0/zapcore/core.go:90 +0x1c3
go.uber.org/zap/zapcore.(*CheckedEntry).Write()
/go/pkg/mod/go.uber.org/zap@v1.10.0/zapcore/entry.go:215 +0x1e7
go.uber.org/zap.(*Logger).Info()
/go/pkg/mod/go.uber.org/zap@v1.10.0/logger.go:187 +0x95
github.com/CityOfZion/neo-go/pkg/core.(*Blockchain).persist()
/go/src/github.com/CityOfZion/neo-go/pkg/core/blockchain.go:720 +0x6bb
github.com/CityOfZion/neo-go/pkg/core.(*Blockchain).Run.func2()
/go/src/github.com/CityOfZion/neo-go/pkg/core/blockchain.go:228 +0x53
Previous write at 0x00c00015a843 by goroutine 98:
testing.tRunner.func1()
/usr/local/go/src/testing/testing.go:900 +0x353
testing.tRunner()
/usr/local/go/src/testing/testing.go:913 +0x1bb
Goroutine 112 (running) created at:
github.com/CityOfZion/neo-go/pkg/core.(*Blockchain).Run()
/go/src/github.com/CityOfZion/neo-go/pkg/core/blockchain.go:227 +0x264
Goroutine 98 (finished) created at:
testing.(*T).Run()
/usr/local/go/src/testing/testing.go:960 +0x651
testing.runTests.func1()
/usr/local/go/src/testing/testing.go:1202 +0xa6
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
testing.runTests()
/usr/local/go/src/testing/testing.go:1200 +0x521
testing.(*M).Run()
/usr/local/go/src/testing/testing.go:1117 +0x2ff
main.main()
_testmain.go:162 +0x337
==================
--- FAIL: TestService_OnPayload (4.11s)
2020-01-20 19:40:52 +03:00
Roman Khimov
0ba6b2a754
network: introduce peer sending queues
...
Two queues for high-priority and ordinary messages. Fixes #590 . These queues
are deliberately made small to avoid buffer bloat problem, there is gonna be
another queueing layer above them to compensate for that. The queues are
designed to be synchronous in enqueueing, async capabilities are to be added
layer above later.
2020-01-20 17:23:26 +03:00
Roman Khimov
7f0882767c
network: remove useless Done() method from the peer
...
It's internal state of the peer that no one should care about.
2020-01-20 17:23:26 +03:00
Roman Khimov
f39d5d5a10
network: fix unregistration on peer Disconnect
...
It should always signal to the server, not duplicating this send and not
missing it like it happened in the Server.run().
2020-01-20 17:23:26 +03:00
Roman Khimov
907a236285
network: move per-peer goroutines into the TCPPeer
...
As they're directly tied to it.
2020-01-20 17:23:26 +03:00
Roman Khimov
32213b1454
Merge pull request #601 from nspcc-dev/refactoring/core
...
core: refactor out Block, BlockBase and Header, closes #597 .
2020-01-20 16:19:20 +03:00
Roman Khimov
f4aa088d04
Merge pull request #603 from nspcc-dev/feature/wallet
...
consensus: use wallets instead of WIF, closes #588 .
2020-01-20 16:16:10 +03:00
Roman Khimov
bb80ba9b9e
Merge pull request #456 from nspcc-dev/pingpong_430
...
add ping pong processing
2020-01-20 16:10:29 +03:00
Evgenii Stratonikov
f0083b94c5
vm: use new big.Int (de-)serialization routines
...
Also fix a test with CAT.
2020-01-17 17:37:50 +03:00
Evgenii Stratonikov
f26bdae2c5
vm: implement proper big.Int to []byte conversions
...
Big.Int Bytes()/SetBytes() methods are not symmetric.
Moreover we need to mimic C# node behavior:
- if a positive number has MSB set, 0x00 byte should be appended
to distinguish positive number from negatives
- negative numbers should serialize as two's-complement
2020-01-17 17:37:50 +03:00
Evgenii Stratonikov
55d98ab19a
consensus: update keys from wallet after every block
2020-01-17 17:30:45 +03:00
Evgenii Stratonikov
aaefcdecae
consensus: use wallet in service
2020-01-17 17:25:51 +03:00
Evgenii Stratonikov
36cfa5b1f4
wallet: add GetAccount() method to Wallet
...
It is useful to be able to get account specified by script hash.
2020-01-17 17:25:51 +03:00
Evgenii Stratonikov
a798e4e0fa
wallet: add ScriptHash() method to Contract
2020-01-17 17:25:51 +03:00
Evgenii Stratonikov
a871f75063
wallet: use a script instead a hash
...
NEO wallets (e.g. used in privnet setup) use hex-encoded
script inside the wallet, not a script hash.
2020-01-17 17:25:51 +03:00
Roman Khimov
46b82b4fb5
keys: don't return error from PrivateKey.Sign
...
As it can't ever happen.
2020-01-17 17:00:30 +03:00
Vsevolod Brekelov
4e6ed9021c
network: add ping pong processing
...
add pingInterval same as used in ref C# implementation with the same logic
add pingTimeout which is used to check whether pong received. If not -- drop the peer.
add pingLimit which is hardcoded to 4 in TCPPeer. It's limit for unsuccessful ping/pong calls (where pong wasn't received in pingTimeout interval)
2020-01-17 13:24:14 +03:00
Roman Khimov
e2fff3bb1d
keys: update to newer rfc6979 package
...
Fixes #592 .
2020-01-16 18:21:10 +03:00
Evgenii Stratonikov
28183b81d6
mempool: simplify names of exported types
...
With the move to a separate package, naming can be simplified:
MemPool -> Pool, PoolItem -> Item, PoolItems -> Items.
2020-01-16 10:16:24 +03:00
Evgenii Stratonikov
fed6fba9b6
core: refactor out MemPool
2020-01-16 10:16:24 +03:00
Evgenii Stratonikov
79bceb3e40
block: use require in tests
2020-01-16 10:16:24 +03:00
Evgenii Stratonikov
489b88afbb
block: rename BlockBase to Base
2020-01-16 10:16:24 +03:00
Evgenii Stratonikov
63c56cca5c
core: refactor out Block, BlockBase and Header structs
...
See #597 .
2020-01-16 10:16:24 +03:00
Roman Khimov
7d4d57351e
network: fix requestTx() behaviour for consensus service
...
It wasn't actually requesting transactions but rather sending an inventory
message telling everyone that we have them which is completely wrong and
easily leads to ChangeView that could be avoided.
2020-01-15 14:31:56 +03:00
Roman Khimov
0420d48e56
network: micro-optimize relayInventory
...
Do less allocations, we're sending the same message with the same payload.
2020-01-15 13:16:09 +03:00
Roman Khimov
9eb880a095
Merge pull request #568 from nspcc-dev/feature/compiler_clean_and_tests
...
compiler: clean and tests
2020-01-14 18:44:07 +03:00
Vsevolod Brekelov
7084925e4b
compiler: add test for compile and save
2020-01-14 17:33:04 +03:00
Evgenii Stratonikov
3d704a3a3a
consensus: try to use previous proposal after ChangeView
...
When system and network pressure is high it can be beneficial
to use transactions which and were already proposed.
The assumption is that they will be in other node's memory pool
with more probability.
2020-01-14 16:05:27 +03:00
Roman Khimov
7ba5267494
Merge pull request #596 from nspcc-dev/feature/single_node
...
network: allow single-node privnet setup. Closes #595 .
2020-01-14 13:17:04 +03:00
Evgenii Stratonikov
70b23076f8
network: allow single-node privnet setup
2020-01-13 18:01:20 +03:00
Evgenii Stratonikov
5f5d0097e2
network: use TimePerBlock from config
2020-01-13 17:58:12 +03:00
Roman Khimov
2192b6602a
network: fix logic and logging for sendVersion() errors
...
It doesn't make sense trying to read from a broken connection and the
disconnect is to be logger from the server on unregistration.
2020-01-13 17:33:29 +03:00
Roman Khimov
b5f234ddef
rpc: make rpc request logging at Debug level
...
Makes no sense polluting logs with Info. It also affects benchmarking.
2020-01-13 17:33:29 +03:00
Evgenii Stratonikov
f3921ea3bd
network: fix NPE in logging
2020-01-13 15:06:57 +03:00
Roman Khimov
565c1940e3
Merge pull request #587 from nspcc-dev/feature/zap
...
Closes #284 .
2020-01-10 14:50:09 +03:00
Evgenii Stratonikov
9dc5571327
core,rpc: close Blockchain in tests
...
If blockchain is not closed, logging in defer can occur
after test has finished, which will lead to a panic with
"Log in goroutine after Test* has completed".
2020-01-10 11:47:56 +03:00
Evgenii Stratonikov
dc65684708
consensus: replace SugaredLogger with Logger
...
SugaredLogger was used to make output look more similar to logrus.
This is no longer needed.
2020-01-10 11:14:29 +03:00
Evgenii Stratonikov
9b8b77c9ea
network: return error if header message is too big
...
Big messages can still be processed but only first
2000 headers will be used.
2020-01-10 11:14:29 +03:00
Evgenii Stratonikov
637c99eda7
core: simplify newInteropContext
2020-01-10 11:14:29 +03:00
Evgenii Stratonikov
45a4524054
rpc: remove EnableCORSWorkaround from Request
2020-01-10 11:14:29 +03:00
Evgenii Stratonikov
289cb1c1d9
rpc: use zap.Logger
2020-01-10 11:14:29 +03:00
Evgenii Stratonikov
aecdf470e7
cli,pkg: use zap.Logger
2020-01-10 11:14:27 +03:00
Roman Khimov
e96b4bc82e
wallet: fix TestNewAccount
...
It duplicated TestNewFromWif.
2020-01-09 18:40:30 +03:00
Roman Khimov
9bb68d7025
wallet: make DecryptAccount a method of Account
...
Otherwise it almost duplicates keys.NEP2Decrypt().
2020-01-09 18:40:30 +03:00
Roman Khimov
951ee383e9
keys: improve NEP2 testing
2020-01-09 18:06:03 +03:00
Roman Khimov
b5b05a969c
keys: make NEP2Decrypt return a PrivateKey rather than WIF
...
There is no point in encoding the output of this function in a WIF format,
most of the users actually want the real key and those who need a WIF can
easily get if from the key (and it's simpler than getting the key from the
WIF).
It also fixes a severe bug in NEP2Decrypt, base58 decoding errors were not
processed correctly.
2020-01-09 18:05:14 +03:00
Evgenii Stratonikov
9c79684516
storage: panic on error in boltdb.Seek
...
Error in Seek means something is terribly wrong (e.g. db was not opened) and
error drop is not the right thing to do, because caller
will continue working with the wrong view.
2020-01-09 15:17:35 +03:00
Evgenii Stratonikov
8d1f564411
consensus: add tests for getTx
2019-12-27 14:12:58 +03:00
Evgenii Stratonikov
d803dffca8
consensus: return nil interface from getTx
2019-12-27 13:54:11 +03:00
Roman Khimov
c306d2f07c
Merge pull request #581 from nspcc-dev/feat/storage_find
...
core: implement Neo.Storage.Find interop, closes #422 .
2019-12-26 15:46:46 +03:00