Commit graph

105 commits

Author SHA1 Message Date
Brannon King
41472404c6 [lbry] enable segwit 2021-12-14 14:00:59 -08:00
Roy Lee
28a5e6fc65 [lbry] rename btcd to lbcd
Co-authored-by: Brannon King <countprimes@gmail.com>
2021-12-14 14:00:59 -08:00
Olaoluwa Osuntokun
e98a1a1b4c
peer+server: add new config option to optionally disable stall detection
In this commit, we add a new config options that allows one to start
`btcd` in an operating mode that disables the stall detection. This can
be useful in simnet/regtest integration tests settings where it's
important that `btcd` holds on to its possibly sole connection to the
only other node in the test harness.

A new config flag has been added to gate this behavior, which is off by
default.
2021-10-01 14:55:50 -07:00
Wilmer Paulino
fdb479f121
peer: allow external testing of peer.Peer
The previous use of allowSelfConns prevented this, as users aren't able
to invoke peer.TstAllowSelfConns themselves due to being part of a test
file, which aren't exported at the library level, leading to a
"disconnecting peer connected to self" error upon establishing a mock
connection between two peers. By including the option at the config
level instead (false by default, prevents connections to self) we enable
users of the peer library to properly test the behavior of the peer.Peer
struct externally.
2021-03-11 18:24:13 -08:00
Jake Sylvestre
d08785547a docs: update shields 2021-03-05 07:45:19 -05:00
Olaoluwa Osuntokun
7d69fb9ba6 peer: prevent last block height going backwards
This modifies the UpdateLastBlockHeight function to ensure the new
height is after the existing height before updating it in order to
prevent it from going backwards so it properly matches the intent of the
function which is to report the latest known block height for the peer.

Without this change, the value will properly start out at the latest
known block height reported by the peer during version negotiation,
however, it will be set to lower values when syncing from the peer due
to requesting old blocks and blindly updating the height.

It also adds a test to ensure proper functionality.

This is a backport of https://github.com/decred/dcrd/pull/1747
2020-08-31 09:47:41 -04:00
Javed Khan
875b51c9fb peer: knownInventory, sentNonces - use generic lru
While here, also rename and generalize limitMap and apply to
other maps which need to be bounded.
2020-07-08 16:44:04 -04:00
George Tankersley
8bbbe98be9 peer: fix small typo 2020-03-04 08:38:26 -05:00
Wilmer Paulino
5de9e5b6c2
peer: include verack as part of version handshake
It was possible for connections to bitcoind nodes to be closed from
their side if the OnVersion callback queued a message to send. This is
because bitcoind expects a verack message before attempting to process
any other messages. To address this, we ensure the verack is sent as
part of the handshake process, such that any queued messages happen
after the fact.
2019-08-20 16:25:21 -07:00
Olaoluwa Osuntokun
1c5c32a5e8
Merge pull request #1315 from halseth/msgcfilter-string
peer log: add MsgCFHeaders and MsgGetCFHeaders message summary
2018-10-12 17:43:50 -07:00
Johan T. Halseth
5e578f546f
peer log: add MsgCFHeaders and MsgGetCFHeaders string representation 2018-10-01 13:40:45 +02:00
Dave Collins
4d1e1db9ea
peer: Improve net address service adverts.
This modifies the peer code which deals with advertising service flags
via the net address fields of the version message as follows:

- For outgoing connections:
  - Set the local netaddress services to what the local peer supports
  - Set the remote netaddress services to 0 to indicate no services as
    they are still unknown
- For incoming connections:
  - Set the local netaddress services to what the local peer supports
  - Set the remote netaddress services to the what was advertised by the
    remote peer in its version message
2018-09-20 22:31:23 -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
Dave Collins
25dfda9bd3
peer: Add duplicate version message test.
This adds a test to ensure duplicate version messages are rejected.

Backported from Decred.
2018-09-20 22:18:36 -05:00
Conner Fromknecht
475eafdc70
peer/example_test: switch TrickleTimeout -> TrickleInterval 2018-08-23 22:55:21 -07:00
Conner Fromknecht
7b402cd63b
peer/peer_test: switch TrickleTimeout -> TrickleInterval 2018-08-23 22:55:21 -07:00
Conner Fromknecht
602bced5f5
peer/peer: switch TrickleTimeout -> TrickleInterval 2018-08-23 22:55:21 -07:00
Olaoluwa Osuntokun
9f436585d7
Merge pull request #1247 from davecgh/peer_minor_cleanup
peer: Minor function definition order cleanup.
2018-08-22 19:41:16 -07:00
Dave Collins
fd78330fd3
peer: Minor function definition order cleanup.
This rearranges some of the function definitions that pertain to initial
peer version negotiation and bringup so they are more consistent with
the preferred order used throughout the codebase.  In particular, the
functions are defined before they're first used and generally as close
as possible to the first use when they're defined in the same file.

There are no functional changes.

Backported from Decred.
2018-08-10 20:20:11 -05:00
Johan T. Halseth
ee0740a289
peer test: set TrickleTimeout for test configs 2018-07-24 13:11:02 +02:00
Johan T. Halseth
08619220b4
config/peer: make trickleTimeout configurable 2018-07-24 12:59:44 +02:00
Olaoluwa Osuntokun
088eec67ec
peer: ensure the version negotiation goroutine will always exit
In this commit, we patch a goroutine leak within the peer struct. This
goroutine leak can happen, if the remote side fails to actually finish
negotiation the protocol before our timeout ticker ticks. In this case,
the goroutine will be blocked on a send, as the channel is unfired. An
example trace from a btcd node I had on testnet showed:
```
3183 @ 0x42e78a 0x42e83e 0x40540b 0x4051a5 0x872f76 0x45bfc1
```

So, all instances of the goroutine failing to exit due to the remote
peer not finishing the p2p version negotiation handshake.

Our fix is simple: make the `negotiateErr' channel unbuffered. With this
simple change, we ensure that the goroutine will always exit even in the
case that the parent goroutine exists due to a timeout.  # Please enter
the commit message for your changes. Lines starting
2018-07-21 17:41:23 -07:00
Olaoluwa Osuntokun
5596b63846 multi: fix linter warnings 2018-05-23 16:46:15 -07:00
Jim Posen
0581e18840 wire: Define CFCheckpt message. 2018-05-23 16:46:15 -07:00
Jim Posen
336b18c584 wire: Define GetCFCheckpt message. 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
Alex
c7e7acc7fd multi: use hidden varint for cftypes count; make filter type enum, not uint8 2018-05-23 16:46:15 -07:00
Alex
2b7ebfd698 peer: add OnCFTypes and OnGetCFTypes callbacks 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
Olaoluwa Osuntokun
8aeb8c3ef2 peer: temporarily disable stall detection 2018-05-23 16:46:15 -07:00
Olaoluwa Osuntokun
9a30e95d83 peer: don't inv trickle new blocks 2018-05-23 16:46:15 -07:00
Olaoluwa Osuntokun
ac4bd31ba0 peer: disable peer stalling for get blocks messages 2018-05-23 16:46:15 -07:00
Alex
dabb8000fb Add Extended flag to cfilter and cfheaders messages 2018-05-23 16:46:15 -07:00
Alex
936caad9c2 Add last blockhash to cfheaders and blockhash to cfilter messages 2018-05-23 16:46:15 -07:00
Alex
29b5ece196 Changed getcfheaders/cfheaders messages to get multiple headers. 2018-05-23 16:46:15 -07:00
Alex
8ad7aa5d5d Rename CFilterHeader to CFHeader on P2P side; fix some bugs/tests 2018-05-23 16:46:15 -07:00
pedro martelletto
b8c3be740f Add CFilterHeader p2p counterparts 2018-05-23 16:46:15 -07:00
pedro martelletto
71c421db66 Differentiate between basic/extended filters in p2p/RPC 2018-05-23 16:46:15 -07:00
pedro martelletto
6e5f650be9 CBFilter -> CFilter, discussed with davec@ 2018-05-23 16:46:15 -07:00
pedro martelletto
e9298934b9 Add a stub GetCBFilter message.
Actual semantic and payload format yet to be defined.
2018-05-23 16:46:15 -07:00
Jim Posen
1b50c7300f peer: Test that witnessEnabled is set properly on peer connection. 2017-08-15 12:08:49 -07:00
Jim Posen
095bba1a25 peer: Move IsWitnessEnabled() from serverPeer to Peer.
serverPeer is a problematic struct because it is local to the main
package.
2017-08-15 11:34:17 -07:00
Jim Posen
bc36cf51c6 peer: Don't send unsupported reject to old peers. 2017-08-14 16:58:57 -05:00
Jim Posen
f4d376d7af peer: Improve address sampling in PushAddrMsg.
This changes fixes shuffling algorithm in PushAddrMsg to select a
uniformly random subset of the given addresses using Fisher-Yates.
2017-08-14 15:44:08 -05:00
Olaoluwa Osuntokun
7a1456aae5 BIP0144+peer: specify the wire encoding type when reading/writing messages
This commit modifies the base peer struct to ascertain when a peer is
able to understand the new witness encoding, and specify the peer’s
supported encoding explicitly before/after the version handshake.
2017-08-13 23:17:40 -05:00
Dave Collins
01cb59c67d
multi: Simplify code per gosimple linter.
This simplifies the code based on the recommendations of the gosimple
lint tool.
2017-07-01 02:25:10 -05:00
Josh Rickmar
a6965d493f all: Remove seelog logger.
The btclog package has been changed to defining its own logging
interface (rather than seelog's) and provides a default implementation
for callers to use.

There are two primary advantages to the new logger implementation.

First, all log messages are created before the call returns.  Compared
to seelog, this prevents data races when mutable variables are logged.

Second, the new logger does not implement any kind of artifical rate
limiting (what seelog refers to as "adaptive logging").  Log messages
are outputted as soon as possible and the application will appear to
perform much better when watching standard output.

Because log rotation is not a feature of the btclog logging
implementation, it is handled by the main package by importing a file
rotation package that provides an io.Reader interface for creating
output to a rotating file output.  The rotator has been configured
with the same defaults that btcd previously used in the seelog config
(10MB file limits with maximum of 3 rolls) but now compresses newly
created roll files.  Due to the high compressibility of log text, the
compressed files typically reduce to around 15-30% of the original
10MB file.
2017-06-19 16:46:50 -04:00