Commit graph

305 commits

Author SHA1 Message Date
Steven Roose
9e94ccbd0e server: Fix incorrect log message format 2020-03-05 17:00:45 -05:00
Olaoluwa Osuntokun
037489ef50
Merge pull request #1485 from wpaulino/syncmanager-done-peer-verack
server: remove peer from SyncManager on VerAckReceived
2019-11-08 18:21:37 -08:00
nsa
c2ca0a408e
server: add addressesMtx to fix race condition 2019-11-08 21:11:24 -05:00
Wilmer Paulino
bc21593480
server: remove peer from SyncManager on VerAckReceived
Peers are now added to the SyncManager if we receive their verack, but
we'd still attempt to remove them from the SyncManager if we didn't
receive it.
2019-10-29 19:38:38 -07:00
Wilmer Paulino
baeb789a7d
server: prevent adding peers if already disconnected
This addresses an issue where the server ends up tracking a peer that
has been disconnected due to it processing a peer's `done` message
before its `add` message.
2019-10-14 13:26:44 +02:00
Wilmer Paulino
769c4e152f
server: request addresses from new peers once they can process messages
This was previously done within the OnVersion listener, which should not
be a blocking operation. It turns out that requesting these messages
there can lead to blocking due to peers not being able to process
messages since their message queues have yet to start. Therefore, we'll
now request within handleAddPeerMsg, which should allow it to go
through.
2019-10-14 13:26:43 +02:00
Wilmer Paulino
a1a5bfa819
server: add new peers within OnVerAck instead of within OnVersion
This change is needed as part of requiring peers to also send a verack
message following their version message during protocol negotiation.
Peers were previously added to the SyncManager before their message
queues were started, causing the server to stall if a peer didn't
provide a timely verack response following their version. We now do this
within OnVerAck, which happens shortly before peer message queues are
started.
2019-10-14 13:26:42 +02:00
Wilmer Paulino
11b84f5cb5
server: signal SyncManager with new peer within AddPeer
This makes the logic a bit more unified as previously it was possible we
for us to report the new peer to the SyncManager, but for whatever
reason failed to track the peer in the server internally within AddPeer.
This change ensures this can no longer happen.
2019-10-14 13:26:16 +02:00
Wilmer Paulino
0d00cdf82c
server: request new peer after disconnection of non-persistent peers
Doing so ensures we reach our target number of outbound peers as soon as
possible. This is only necessary after calls to connmgr.Remove, as these
won't request a new peer connection.
2019-10-10 19:05:41 -04:00
Wilmer Paulino
45d66d46f9
server: standardize use of connmanager's Disconnect and Remove methods
The Disconnect method would still attempt to reconnect to the same
peer, which could cause us to reconnect to bad/unstable peers if we came
across them. Instead, we'll now use Remove whenever we intend to remove
a peer that is not persistent.
2019-10-10 19:05:37 -04:00
Wilmer Paulino
ab6f3089f6
server: mark address as connected within handleAddPeerMsg
We do this to ensure the address manager contains live addresses.
Previously, addresses with which we established connections with would
not be marked as connected because it would be done once we disconnect
peers. Given that we don't process all of the disconnect logic when
we're shutting down, addresses of stable and good peers would never be
marked as connected unless the connection was lost during operation.
2019-10-10 12:10:52 -04:00
Wilmer Paulino
06baabe5da
server: mark address attempted on attempt rather than upon connection
We should mark addresses as attempted when we attempt to connect to
them, not once we establish a connection with said address.
2019-10-10 12:03:47 -04:00
Wilmer Paulino
95d0a371d9
mempool: implement RBF signaling policy 2019-06-13 16:35:53 -07:00
Conner Fromknecht
39592eba78
btcd: pass user agent black and white lists to server 2019-04-16 21:31:08 -07:00
Conner Fromknecht
d3ecdc91a9
server: adds hybrid black/whitelist filtering to user agents 2019-04-15 17:46:08 -07:00
Dave Collins
8c981e4ef2
server: Use local addr var in version handler.
This modifies the OnVersion handler for server peers to use a local
variable for the remote address of the peer in order to avoid grabbing
the mutex multiple times.

There are no functional changes.

Backported from Decred.
2018-09-20 22:32:59 -05:00
Dave Collins
c8b9fab820
server: Only advertise local addr when current.
This changes the server peers OnVersion handler to only advertise the
server as a viable target for inbound connections when the server
believes it is close the best known tip.

Backported from Decred.
2018-09-20 22:32:41 -05:00
Dave Collins
d2c7892aa4
server: Use local inbound var in version handler.
This modifies the OnVersion handler for server peers to use a local
variable for the inbound status of the peer in order to avoid grabbing
the mutex multiple times.

While here, it also does some light cleanup.  There are no functional
changes.

Backported from Decred.
2018-09-20 22:32:16 -05:00
Dave Collins
4b20d4f86a
server: Update addrmgr services on outbound conns.
This adds code to update the address manager services for a known
address to the services advertised by peers when they are connected to
via an outbound connection.  It is only done for outbound connections to
help prevent malicious behavior from inbound connections.

Backported from Decred.
2018-09-20 22:31:50 -05:00
Dave Collins
9151ebc90b
server: Reject outbound conns to non-full nodes.
This modifies the server connection code to reject outbound peers that
do not offer full node services.
2018-09-20 22:30:46 -05:00
Dave Collins
7b103e2434
peer: Allow OnVersion callback to reject peer.
This modifies the OnVersion callback to allow a reject message to be
returned in which case the message will be sent to the peer and the peer
will be disconnected.

Backported from Decred.
2018-09-20 22:29:27 -05:00
Dave Collins
118f55233b
peer: Rework version negotiation.
This modifies the negotiation logic to ensure the callback has the
opportunity to see the message before the peer is disconnected and
improves the error handling when reading the remote version message.

It also has the side effect of ensuring the protocol version is
negotiated before sending reject messages with the exception of the
first message not being a version message since negotiation is not
possible in that case.

This is being changed because it is useful for the server to see the
message regardless in order to have the opportunity to things such as
update the address manager and reject peers that don't have desired
services.

Backported from Decred.
2018-09-20 22:26:36 -05:00
qshuai
badf5453e9 server: Fix struct name mismatch 2018-09-08 22:34:41 +08:00
Olaoluwa Osuntokun
222a6dac0d
server: fix panic bug when looking for cf checkpoint cache intersection w/ chain
In this commit, we fix a panic bug that can arise when we attempt to
process a cf checkpoint message from a remote peer. Before this commit,
if the size of the checkpoint cache was large than the number of
checkpoints requested by the peer, we would panic with an out of bounds
error. In order to prevent, this we'll now use the size of the requested
set of hashes as our bound to ensure that we don't panic.
2018-08-27 17:49:45 -07:00
Olaoluwa Osuntokun
c8e6363e22
server: modify locking in OnGetCFCheckpt to allow for read concurrency
In this commit, we modify the locking scheme when serving cf checkpoints
for peers to allow the server to serve multiple peers at the same time.
Before this commit, we would first grab the write lock, check to see for
expansion, then release the read lock. In this commit we reverse this
and instead will grab the read lock, and upgrade to the write lock if we
need to actually expand the size of the cache.
2018-08-27 17:46:41 -07:00
Conner Fromknecht
ae733e7291
server: switch TrickleTimeout -> TrickleInterval 2018-08-23 22:55:21 -07:00
Olaoluwa Osuntokun
bb912b6e03
Merge pull request #1222 from halseth/trickle-timeout
config/peer: make trickleTimeout configurable
2018-08-22 19:39:33 -07:00
Olaoluwa Osuntokun
f899737d7f
Merge pull request #1169 from stevenroose/filteradd
server: Fix bug disconnecting peer on filteradd
2018-08-09 17:06:19 -07:00
Conner Fromknecht
90c2094cbd
server: always reply with get headers
backport of https://github.com/decred/dcrd/pull/1295
2018-07-31 21:15:02 -07:00
Johan T. Halseth
08619220b4
config/peer: make trickleTimeout configurable 2018-07-24 12:59:44 +02:00
Olaoluwa Osuntokun
5e86c37411
server: fix bug in cf checkpoint serving
In this commit, we fix a bug in the way that we previously attempted to
server cfcheckpoints. In the prior version we would never actually
fetch the current length of the cache. As a result, after the first time
the checkpoints were fetched, we would always continually grow the
cache rather than using what's there if sufficient.

In this commit, we fix this behavior by always checking the length, then
either keeping the rite lock, or downgrading to a read lock if the size
was sufficient.
2018-07-16 16:31:11 -07:00
Olaoluwa Osuntokun
f7366fb51b
server: ensure we only fetch filters we know of 2018-07-14 12:20:20 -07:00
Steven Roose
fbe1bfa659 server: print full name of cf index in main log 2018-07-06 14:40:27 -05:00
Jim Posen
4d0e856ea1 server: Handler for getcfcheckpt messages. 2018-05-23 16:46:15 -07:00
Jim Posen
4c991c8783 wire: Populate cfheaders message with filter hashes instead of headers. 2018-05-23 16:46:15 -07:00
Jim Posen
175af18043 multi: Modify CFHeaders message to have a PrevFilterHeader field. 2018-05-23 16:46:15 -07:00
Jim Posen
7a53a05878 multi: Redefine GetCFHeaders to have StartHeight and StopHash. 2018-05-23 16:46:15 -07:00
Jim Posen
daac60675e multi: Redefine GetCFilters to have StartHeight and StopHash. 2018-05-23 16:46:15 -07:00
Jim Posen
621f347929 wire: Remove cftypes and getcftypes commands. 2018-05-23 16:46:15 -07:00
Olaoluwa Osuntokun
5291c455c2 server: properly set feeEstimator in newServer 2018-05-23 16:46:15 -07:00
Daniel Krawisz
47113d428c It is now possible to save and restore the state of the FeeEstimator
and the server searches the database for a previous state to load
when the program is turned on.
2018-05-23 16:46:15 -07:00
Daniel Krawisz
4fd446028f Enable estimatefee rpc command. 2018-05-23 16:46:15 -07:00
Daniel Krawisz
1333ad7f78 FeeEstimator added to server. Mempool alerts the fee estimator of
new txs that it observes. The block manager alerts the fee estimator
of new and orphaned blocks.

Check for invalid state and recreate FeeEstimator if necessary.
2018-05-23 16:46:15 -07:00
Olaoluwa Osuntokun
10432160d5 multi: rebase to upstream, update API's 2018-05-23 16:46:15 -07:00
Alex
e0a357abb5 server: add TODO for querying supported filter types 2018-05-23 16:46:15 -07:00
Alex
c7e7acc7fd multi: use hidden varint for cftypes count; make filter type enum, not uint8 2018-05-23 16:46:15 -07:00
Alex
5772bdde86 server: add OnGetCFTypes callback to serverPeer 2018-05-23 16:46:15 -07:00
Alex
621c73dad1 multi: change cfilter Extended bool to FilterType uint8
The cfilter BIP specifies that the filter type is a uint8. The
current code encodes it correctly on the wire, but everywhere else,
it's treated as a boolean (false for basic filter, true for
extended). This commit corrects that to account for possible
additional filter types in the future. All package changes are
done in one commit as they're all interdependent. The following
packages are updated:

* blockchain/indexers
* btcjson
* peer
* wire
* main (server.go and rpcserver.go)
2018-05-23 16:46:15 -07:00
Alex
c5c392c5c5 server: init rpcserver with cfindex 2018-05-23 16:46:15 -07:00
Alex
6589cffb19 server: change logging in OnGetCFilter to be less verbose 2018-05-23 16:46:15 -07:00