Commit graph

83 commits

Author SHA1 Message Date
Evgenii Stratonikov
5f5d0097e2 network: use TimePerBlock from config 2020-01-13 17:58:12 +03:00
Evgenii Stratonikov
aecdf470e7 cli,pkg: use zap.Logger 2020-01-10 11:14:27 +03:00
Roman Khimov
234d94d27e network: implement getblocks command
Fixes #577, tested with C# nodes connecting to neo-go privnet.
2019-12-25 19:46:57 +03:00
Roman Khimov
abc0ec33bd
Merge pull request #532 from nspcc-dev/fix/peer_count
Consensus fixes.
2019-12-02 18:08:36 +03:00
Evgenii Stratonikov
7c900edd2d network: count only handshaked peers as connected 2019-12-02 15:09:09 +03:00
Roman Khimov
1da76a8eb4 network: rework inventory handling, check for item presence
Don't ask peers about the items we already have.
2019-12-02 11:02:52 +03:00
Roman Khimov
b4d9935bda network: deduplicate a part of RelayTxn()
We already have relayInventory() for this.
2019-11-29 16:26:44 +03:00
Roman Khimov
293615ea5f network/consensus: add new block relaying
Tell everyone about our new shiny blocks.
2019-11-29 12:27:15 +03:00
Roman Khimov
4d286dcfeb network: check height before requesting headers
Only request headers from the other peer if his height is bigger than
ours. Otherwise we routinely ask 0-height newcomers for some random headers
that they know nothing about.
2019-11-29 11:48:17 +03:00
Roman Khimov
a730529b0c network: process incoming p2p transactions
It's the same relaying as for RPC, but we don't need to return any result for
it.
2019-11-29 11:09:54 +03:00
Roman Khimov
9f9cf4ae3f network: add getheaders message processing
This one is essential for the consensus nodes as otherwise they won't give out
the blocks they generate making their generation almost useless. It also makes
our networking part more complete.
2019-11-29 11:08:22 +03:00
Roman Khimov
734338ad70 network: move Version sending to the tcp transport
We have a race between reader and writer goroutines for the same connection
that leads to handshake failures when reader is faster to read the incoming
version (and try to reply to it) than writer is to write our own Version:

WARN[0000] peer disconnected                             addr="172.200.0.4:20334" peerCount=5 reason="invalid handshake: tried to send VersionAck, but didn't send Version yet

Fix it by moving Version sending before the reader loop starts.
2019-11-29 11:05:42 +03:00
Evgenii Stratonikov
b5fb43bac9 network: don't reconnect to peers with identical ID 2019-11-27 11:58:17 +03:00
Evgenii Stratonikov
fdd5276d3e network: plug in dBFT library 2019-11-27 10:57:22 +03:00
Evgeniy Kulikov
0a56d3ddbc
network: generate randomized server id
math/rand might generate same id's on one environment, so.. use crypto/rand for generation id's
2019-11-18 17:17:21 +03:00
Evgenii Stratonikov
085ca7b770 network: implement Consensus payloads 2019-11-13 17:27:25 +03:00
Vsevolod Brekelov
11ce73af28 server: add log-path and address configuration
- LogPath can be configured through config
- node,rpc and monitoring address can be configured thought command line
or config
2019-11-06 15:58:54 +03:00
Roman Khimov
7cf9a40468 network: fix MaxPeers, introduce AttemptConnPeers
Our node didn't respect the MaxPeers setting, fix it with a drop of random
connection when this limit is reached (to give a chance for newcomers to
communicate), but also introduce AttemptConnPeers setting to tune the number
of attempted connections.

This also raises the default MaxPeers for testnet/mainnet to 100, because
neo-go nodes love making friends.
2019-11-06 15:29:58 +03:00
Roman Khimov
31954bb20c network: disallow double connections to the same peer
Makes no sense and C# node does it too.
2019-11-06 15:29:58 +03:00
Roman Khimov
d5a7ad2c47 network: fix data race in server peers map access 2019-11-06 15:29:58 +03:00
Roman Khimov
e859e03240 network: split Peer's NetAddr into RemoteAddr and PeerAddr
As they are different things used for different purposes.
2019-11-06 15:26:24 +03:00
Roman Khimov
e9f8b25776 network: add default MinPeers
If there is nothing specified in the configuration, set it to some reasonable
value.
2019-11-01 13:39:47 +03:00
Roman Khimov
b12a68994d network: make minpeers configurable
Without it node in privnet tries to reconnect to four existing nodes
indefinitely for no good reason.
2019-10-31 15:10:00 +03:00
Vsevolod Brekelov
d374175170 monitoring: add prometheus monitoring
add init metrics service which uses prometheus;
add configuration for metrics service;
add monitoring metrics for blockchain,rpc,server;
2019-10-29 20:51:17 +03:00
Roman Khimov
9ff55ac02c network: move inventory semantic check into common code
As per @volekerb suggestion.
2019-10-24 13:12:02 +03:00
Roman Khimov
257ba1c2ad network: implement getdata message handling in server
To properly implement relaying we need to answer these requests from other
nodes.
2019-10-24 13:12:01 +03:00
Vsevolod Brekelov
8ee421db14 fix spelling and godoc comments 2019-10-22 17:56:03 +03:00
Roman Khimov
56459c6c63 network: remove port check from handleVersionCmd()
It's bogus and no other node implementation has anything like that. It fires
up for no good reason in the case when some other node connects to us and it
obviously doesn't use its listening port for it.
2019-10-17 11:19:24 +03:00
Roman Khimov
74590551c4 core: add some interops
This also changes Verify to VerifyTx and VerifyWitnesses, because there is a
need to pass a block for some interop functions.
2019-10-15 12:56:25 +03:00
Roman Khimov
9617a6f9e9 network: fix requestBlocks() for (headers == blocks + 1)
In the very specific case when the list of headers received is exactly one
block ahead of the chain of full blocks requestBlocks() failed to generate
request to get the next full block.
2019-09-27 15:42:35 +03:00
Roman Khimov
c531dc0bde network: add block queue
This one will replace blockCache in Blockchain itself as it can and should be
external from it. The idea is that we only feed successive blocks into the
Blockchain and it only stores valid proper Blockchain and nothing else.
2019-09-27 13:00:09 +03:00
Roman Khimov
b9ff4d929c network: add getaddr message handling
Respond with known good addresses.
2019-09-16 16:32:04 +03:00
Roman Khimov
b2530a4c93 network: be more specific on port mismatch error 2019-09-16 16:32:04 +03:00
Roman Khimov
773ccc2b92 network: allow discoverer to reuse addresses
...and don't try to connect to the nodes we're already connected to.

Before this change we had a problem of discoverer throwing away good valid
addresses just because they are already known which lead to pool draining over
time (as address reuse was basically forbidden and getaddr may not get enough
new nodes).
2019-09-16 16:32:04 +03:00
Roman Khimov
46dc141c6c network: enlarge address request queue
Queuing one message is not reliable enough, the peer that gets it can fail to
actually make a request, so make this queue a bit deeper to have a higher
chance of success.
2019-09-16 16:32:04 +03:00
Roman Khimov
d3bb8ddf8f network: handle errors and connection close more correctly
This makes writer side handle errors properly and fixes communication between
reader and writer goroutine to always correctly unregister the peer. This is
especially important for the case where error occurs before handshake
completes as in this case we don't even have goroutine in startProtocol()
running.
2019-09-16 16:32:04 +03:00
Roman Khimov
76c7cff67f network: make node strictly follow handshake procedure
Don't accept other messages before handshake is completed, check handshake
message sequence.
2019-09-16 16:32:04 +03:00
Roman Khimov
90e13debe4 network: implement getaddr sends and addr receival
Request new addresses if we're short on known addresses pool size.
2019-09-16 16:26:30 +03:00
Roman Khimov
be6c905e5d network: use and improve discovery mechanism for reconnections
This makes our node reconnect to other nodes if connection drops for some
reason. Fixes #390.
2019-09-16 16:26:30 +03:00
Roman Khimov
8d9bc83214 util: drop Endpoint structure, fix #321
I think it's useless, buggy and hides parsing errors for no good reason.
2019-09-09 17:54:38 +03:00
Roman Khimov
fabd11699a *: gofmt -s
Appy gofmt for all the source tree.
2019-09-09 12:02:24 +03:00
Roman Khimov
2fd782eee8 util: drop RandUint32()
I don't see anything useful in it, all the current users of it should just use
plain rand.Uint32() not limiting its output in any way.
2019-08-26 13:32:19 +03:00
dauTT
095653af23 Implement rpc server method: sendrawtransaction (#174)
* Added new config attributes: 'SecondsPerBlock','LowPriorityThreshold'

* Added new files:

* Added new method: CompareTo

* Fixed empty Slice case

* Added new methods: LessThan, GreaterThan, Equal, CompareTo

* Added new method: InputIntersection

* Added MaxTransactionSize, GroupOutputByAssetID

* Added ned method: ScriptHash

* Added new method: IsDoubleSpend

* Refactor blockchainer, Added Feer interface, Verify and GetMemPool method

* 1) Added MemPool
2) Added new methods to satisfy the blockchainer interface: IsLowPriority, Verify, GetMemPool

* Added new methods: RelayTxn, RelayDirectly

* Fixed tests

* Implemented RPC server method sendrawtransaction

* Refactor getrawtransaction, sendrawtransaction in separate methods

* Moved 'secondsPerBlock' to config file

* Implemented Kim suggestions:
1) Fixed data race issues
2) refactor Verify method
3) Get rid of unused InputIntersection  method due to refactoring Verify method
4) Fixed bug in https://github.com/CityOfZion/neo-go/pull/174#discussion_r264108135
5) minor simplications of the code

* Fixed minor issues related to

1) space
2) getter methods do not need pointer on the receiver
3) error message
4) refactoring  CompareTo method in uint256.go

* Fixed small issues

* Use sync.RWMutex instead of sync.Mutex

* Refined (R)Lock/(R)Unlock

* return error instead of bool in Verify methods
2019-03-20 12:30:05 +00:00
Evgeniy Kulikov
630919bf7d Fix typos and warnings for GoReport / GolangCiLinter (#132)
- typos
- gofmt -s
- govet warnings
- golangci-lint run
2019-02-09 16:53:58 +01:00
Evgeniy Kulikov
f000b76879 [FIX] Formatting and code-style (#118)
* [FIX] Formatting and code-style

- gofmt
- import resort
- prealloc slices
- simplify code

* fix vet
2019-01-25 12:20:35 +01:00
Anthony De Meulemeester
ab2568cc51
Fixed some networking issues (#68)
* Faster persist timer

* fixed networking issues.
2018-04-13 12:14:08 +02:00
Anthony De Meulemeester
b2021c126e
Tweaks for network and storage (#66)
* Made Encode/Decode message public.

* Added Redis storage driver and made some optimizations for the initialising the blockchain

* removed log lines in tcp_peer

* Added missing comments on exported methods.

* bumped version
2018-04-09 18:58:09 +02:00
Steven Jack
19a430b262 RCP server (#50)
* Adds basic RPC supporting files

* Adds interrupt handling and error chan

* Add getblock RPC method

* Update request structure

* Update names of nodes

* Allow bad addresses to be registered in discovery externally

* Small tidy up

* Few tweaks

* Check if error is close error in tcp transport

* Fix tests

* Fix priv port

* Small tweak to param name

* Comment fix

* Remove version from server

* Moves submitblock to TODO block

* Remove old field

* Bumps version and fix hex issues
2018-03-23 21:36:59 +01:00
Anthony De Meulemeester
a67728628e
Persist blockchain with leveldb on disk (#48)
* Created test_data folder with block json files for testing + create separate file for block base.

* Fixed bug in WriteVarUint + Trim logic + unit tests

* Refactored store and add more tests for it.

* restore headerList from chain file

* Fix tx decode bug + lots of housekeeping.

* Implemented Node restore state from chain file.

* Created standalone package for storage. Added couple more methods to Batch and Store interfaces.

* Block persisting + tests

* bumped version -> 0.31.0
2018-03-17 12:53:21 +01:00
Steven Jack
b41e14e0f0 Server configuration (#43)
* Adds struct for config settings

* Bumps version

* Move settings around

* Only push version tag up not whole branch as well

* Move config into own path and add test and main nets

* Update config for timeouts

* Convert to yaml
2018-03-15 21:45:37 +01:00