Commit graph

26239 commits

Author SHA1 Message Date
Pieter Wuille
fd9a0060f0 Report and verify expirations 2020-10-12 12:14:53 -07:00
Pieter Wuille
86f50ed10f Delete limitedmap as it is unused now 2020-10-12 12:14:53 -07:00
Pieter Wuille
cc16fff3e4 Make txid delay penalty also apply to fetches of orphan's parents 2020-10-12 12:14:53 -07:00
Pieter Wuille
173a1d2d3f Expedite removal of tx requests that are no longer needed
Whenever a transaction is added to the mempool or orphan pool, both
its txid and wtxid are considered AlreadyHave, and thus will eventually
be removed from m_txrequest.

The same is true for hashes added to the reject filter, but note that sometimes
only the wtxid is added (in which case only the wtxid can be removed from
m_txrequest).
2020-10-12 12:14:53 -07:00
Pieter Wuille
de11b0a4ef Reduce MAX_PEER_TX_ANNOUNCEMENTS for non-PF_RELAY peers
Maintaining up to 100000 INVs per peer is excessive, as that is far more
than fits in a typical mempool.

Also disable the "overload" penalty for PF_RELAY peers.
2020-10-12 12:14:53 -07:00
Pieter Wuille
242d16477d Change transaction request logic to use txrequest
This removes most transaction request logic from net_processing, and
replaces it with calls to a global TxRequestTracker object.

The major changes are:

* Announcements from outbound (and whitelisted) peers are now always
  preferred over those from inbound peers. This used to be the case for the
  first request (by delaying the first request from inbound peers), and
  a bias afters. The 2s delay for requests from inbound peers still exists,
  but after that, if viable outbound peers remain for any given transaction,
  they will always be tried first.

* No more hard cap of 100 in flight transactions per peer, as there is less
  need for it (memory usage is linear in the number of announcements, but
  independent from the number in flight, and CPU usage isn't affected by it).
  Furthermore, if only one peer announces a transaction, and it has over 100
  in flight and requestable already, we still want to request it from them.
  The cap is replaced with an additional 2s delay (possibly combined with the
  existing 2s delays for inbound connections, and for txid peers when wtxid
  peers are available).

Includes functional tests written by Marco Falke and Antoine Riard.
2020-10-12 12:14:11 -07:00
Pieter Wuille
5b03121d60 Add txrequest fuzz tests
This adds a fuzz test that reimplements a naive reimplementation of
TxRequestTracker (with up to 16 fixed peers and 16 fixed txhashes),
and compares the real implementation against it.
2020-10-12 12:08:47 -07:00
Pieter Wuille
3c7fe0e5a0 Add txrequest unit tests
Add unit tests for TxRequestTracker. Several scenarios are tested,
randomly interleaved with eachother.

Includes a test by Antoine Riard (ariard).
2020-10-12 12:08:43 -07:00
Pieter Wuille
da3b8fde03 Add txrequest module
This adds a new module (unused for now) which defines TxRequestTracker, a data
structure that maintains all information about transaction requests, and coordinates
requests.
2020-10-12 11:01:16 -07:00
Wladimir J. van der Laan
f79a4a8952
Merge #19998: net: Add CNode::ConnectedThroughNetwork member function
3984b78cd7 test: Add tests for CNode::ConnectedThroughNetwork (Hennadii Stepanov)
49fba9c1aa net: Add CNode::ConnectedThroughNetwork member function (Hennadii Stepanov)
d4dde24034 net: Add CNode::m_inbound_onion data member (Hennadii Stepanov)

Pull request description:

  This PR:
  - adds `CNode::ConnectedThroughNetwork` member function
  - is based on #19991, and only last two commits belong to it
  - is required for https://github.com/bitcoin-core/gui/pull/86 and #20002

ACKs for top commit:
  jonatack:
    re-ACK 3984b78cd7 per `git diff 3989fcf 3984b78c`
  laanwj:
    Code review ACK 3984b78cd7

Tree-SHA512: 23a9c8bca8dca75113b5505fe443b294f2d42d03c98c7e34919da12d8396beb8d0ada3a58ae16e3da04b7044395f72cf9c216625afc078256cd6c897ac42bf3d
2020-10-12 18:40:45 +02:00
Vasil Dimov
ba8950ee01
build: optionally skip external warnings
Add an option to `./configure` to suppress compilation warnings from
external headers. The option is off by default (no change in behavior,
show warnings from external headers).

This option is useful if e.g. Boost or Qt is installed outside of
`/usr/include` (warnings from headers in `/usr/include` are already
suppressed by default) and those warnings stand in the way of compiling
Bitcoin Core with `-Werror[=...]` or they just clutter the build output
too much and make our own warnings hard to spot.
2020-10-12 18:18:24 +02:00
MarcoFalke
faad92fe1c
test: Remove unused nVersion=1 in p2p tests
After commit ddefb5c0b7 nVersion is no
longer used in p2p logic when sending messages. Only when receiving
messages, but in this test no messages are received.
2020-10-12 13:11:26 +02:00
Pieter Wuille
9eb590894f Add TaggedHash function (BIP 340)
This adds the TaggedHash function as defined by BIP340 to the hash module, which
is used in BIP340 and BIP341 to produce domain-separated hashes.
2020-10-12 02:06:32 -07:00
Pieter Wuille
450d2b2371 --- [TAPROOT] BIP340/341/342 consensus rules --- 2020-10-12 02:06:32 -07:00
Pieter Wuille
5d62e3a68b refactor: keep spent outputs in PrecomputedTransactionData
A BIP-341 signature message may commit to the scriptPubKeys and amounts
of all spent outputs (including other ones than the input being signed
for spends), so keep them available to signature hashing code.
2020-10-12 02:06:32 -07:00
Vasil Dimov
8e4d62280e
tests: don't export in6addr_loopback
Don't export `in6addr_loopback` because that upsets
`contrib/devtools/symbol-check.py`

Fixes https://github.com/bitcoin/bitcoin/issues/20127
2020-10-12 10:25:08 +02:00
fanquake
af22322dab
Merge #20119: BIP155 follow-ups
56f9dba015 Only relay IPv4, IPv6, Tor addresses (Pieter Wuille)
79f3d9b932 Mention BIP155 in doc/bips.md (Pieter Wuille)

Pull request description:

  This:
  * Documents BIP155 support in doc/bips.md
  * Restricts addrv2 relay to IPv4, IPv6, and Tor addresses. Relaying addresses in ranges that no network software has support for seems like a gratuitous spam vector.

ACKs for top commit:
  jonatack:
    ACK 56f9dba015
  naumenkogs:
    ACK 56f9dba
  hebasto:
    ACK 56f9dba015, verified both links.

Tree-SHA512: f0a2072b3d84a05cdbc7b961c18d7322a2e7260517f5306599ff52d8c728f9167de0a59a6d66cb95d84d69f3028680ce8bd05dab0db8c4f97938a287e5ce9631
2020-10-12 15:47:07 +08:00
Sebastian Falbesoner
5b77f8098d test: add p2p_lock acquires in p2p_leak_tx.py 2020-10-12 00:22:16 +02:00
Sebastian Falbesoner
cc8c6823b4 test: use MiniWallet for p2p_leak_tx.py
This test can now be run even with the Bitcoin Core wallet disabled.
2020-10-11 23:57:56 +02:00
Pieter Wuille
56f9dba015 Only relay IPv4, IPv6, Tor addresses 2020-10-11 11:29:11 -07:00
Pieter Wuille
79f3d9b932 Mention BIP155 in doc/bips.md 2020-10-11 11:29:07 -07:00
fanquake
0b2abaa666
Merge #19954: Complete the BIP155 implementation and upgrade to TORv3
dcf0cb4776 tor: make a TORv3 hidden service instead of TORv2 (Vasil Dimov)
353a3fdaad net: advertise support for ADDRv2 via new message (Vasil Dimov)
201a4596d9 net: CAddress & CAddrMan: (un)serialize as ADDRv2 (Vasil Dimov)
1d3ec2a1fd Support bypassing range check in ReadCompactSize (Pieter Wuille)

Pull request description:

  This PR contains the two remaining commits from #19031 to complete the [BIP155](https://github.com/bitcoin/bips/blob/master/bip-0155.mediawiki) implementation:

  `net: CAddress & CAddrMan: (un)serialize as ADDRv2`
  `net: advertise support for ADDRv2 via new message`

  plus one more commit:

  `tor: make a TORv3 hidden service instead of TORv2`

ACKs for top commit:
  jonatack:
    re-ACK dcf0cb4776 per `git diff 9b56a68 dcf0cb4` only change since last review is an update to the release notes which partially picked up the suggested text. Running a node on this branch and addnode-ing to 6 other Tor v3 nodes, I see "addrv2" and "sendaddrv2" messages in getpeerinfo in both the "bytesrecv_per_msg" and "bytessent_per_msg" JSON objects.
  sipa:
    ACK dcf0cb4776
  hebasto:
    re-ACK dcf0cb4776, the node works flawlessly in all of the modes: Tor-only, clearnet-only, mixed.
  laanwj:
    Edit: I have to retract this ACK for now, I'm having some problems with this PR on a FreeBSD node. It drops all outgoing connections with this dcf0cb4776 merged on master (12a1c3ad1a).
  ariard:
    Code Review ACK dcf0cb4

Tree-SHA512: 28d4d0d817b8664d2f4b18c0e0f31579b2f0f2d23310ed213f1f436a4242afea14dfbf99e07e15889bc5c5c71ad50056797e9307ff8a90e96704f588a6171308
2020-10-11 08:51:57 +08:00
Amiti Uttarwar
41dca087b7 [trivial] Extract connection type doc into file where it is used.
This slightly reduces the size of the binary.
2020-10-09 16:09:51 -07:00
Amiti Uttarwar
3069b56a45 [doc] Improve help for getpeerinfo connection_type field. 2020-10-09 16:08:02 -07:00
Hennadii Stepanov
c056064a4a
gui: Fix SplashScreen crash when run with -disablewallet 2020-10-09 21:14:47 +03:00
gzhao408
88197b0769 [doc] release notes for max fee checking 2020-10-09 08:58:47 -07:00
Vasil Dimov
dcf0cb4776
tor: make a TORv3 hidden service instead of TORv2
TORv2 is deprecated [1], thus whenever we create the hidden service
ourselves create a TORv3 one instead.

[1] https://blog.torproject.org/v2-deprecation-timeline
2020-10-09 16:42:50 +02:00
Vasil Dimov
353a3fdaad
net: advertise support for ADDRv2 via new message
Introduce a new message `sendaddrv2` to signal support for ADDRv2.
Send the new message immediately after sending the `VERACK` message.

Add support for receiving and parsing ADDRv2 messages.

Send ADDRv2 messages (instead of ADDR) to a peer if he has
advertised support for it.

Co-authored-by: Carl Dong <contact@carldong.me>
2020-10-09 16:42:50 +02:00
Vasil Dimov
201a4596d9
net: CAddress & CAddrMan: (un)serialize as ADDRv2
Change the serialization of `CAddrMan` to serialize its addresses
in ADDRv2/BIP155 format by default. Introduce a new `CAddrMan` format
version (3).

Add support for ADDRv2 format in `CAddress` (un)serialization.

Co-authored-by: Carl Dong <contact@carldong.me>
2020-10-09 16:42:49 +02:00
Hennadii Stepanov
a490d074b3
doc: Add anchors.dat to files.md 2020-10-09 14:30:09 +03:00
Hennadii Stepanov
0a85e5a7bc
p2p: Try to connect to anchors once 2020-10-09 14:29:05 +03:00
Hennadii Stepanov
5543c7ab28
p2p: Fix off-by-one error in fetching address loop
This is a move-only commit.
2020-10-09 14:29:05 +03:00
Hennadii Stepanov
4170b46544
p2p: Integrate DumpAnchors() and ReadAnchors() into CConnman 2020-10-09 14:29:05 +03:00
Hennadii Stepanov
bad16aff49
p2p: Add CConnman::GetCurrentBlockRelayOnlyConns() 2020-10-09 14:29:04 +03:00
Hennadii Stepanov
c29272a157
p2p: Add ReadAnchors() 2020-10-09 14:29:04 +03:00
Hennadii Stepanov
567008d2a0
p2p: Add DumpAnchors() 2020-10-09 14:28:58 +03:00
fanquake
12a1c3ad1a
Merge #20107: doc: Collect release-notes snippets
faa0847dec doc: Add release notes for #20101 (MarcoFalke)
99992e7832 doc: Collect release-notes snippets (MarcoFalke)

Pull request description:

  Also add a note for #20101

ACKs for top commit:
  fanquake:
    ACK faa0847dec - no need to bike-shed here as these will all get massaged to death in the wiki anyways.

Tree-SHA512: 63d3597e2bbd422ec182e76112110477d22e3afedb479114ddec958405bcdd63492df9477267aac65605612af49c0aff6246b1bc3d41dd606d6d61c30117c109
2020-10-09 18:08:14 +08:00
fanquake
6854dbdc88
Merge #20076: doc: Update and improve files.md
2dc79c4264 doc: Update and improve files.md (Hennadii Stepanov)

Pull request description:

  This PR adds to the `files.md`:
  - the `signet` subdirectory
  - the `ip_asn.map` file
  - some small improvements

ACKs for top commit:
  practicalswift:
    ACK 2dc79c4264
  MarcoFalke:
    ACK 2dc79c4264

Tree-SHA512: f645486a26293e91eda826dee46e5798af9a81be410d48d07c2714f416da19b85e7e75b1a638b0e03a3e6dc486a8bb65c4be811eb2ff51b66f5817aecf89416d
2020-10-09 18:02:38 +08:00
Pieter Wuille
1d3ec2a1fd
Support bypassing range check in ReadCompactSize
This is needed when we want to encode an arbitrary number as CompactSize
like node service flags, which is a bitmask and could be bigger than the
usual size of an object.
2020-10-09 10:32:19 +02:00
MarcoFalke
380705ef4f
Merge #20106: cirrus: Use kvm to avoid spurious CI failures in the default virtualization cluster
faf2999e25 cirrus: Use kvm to avoid spurious CI failures in the default virtualization cluster (MarcoFalke)

Pull request description:

  Try to fix #20093

ACKs for top commit:
  practicalswift:
    ACK faf2999e25
  hebasto:
    ACK faf2999e25, the related doc:

Tree-SHA512: 156aa2ce5a5dde11570f7f90f9d51be540a5469f090033ab6f337b2c46347741469e109f9566f4b7c424339483d61192b91102021f5db38823ce4cf4428e5671
2020-10-09 08:44:35 +02:00
gzhao408
c201d73df3 style and nits for fee-checking in BroadcastTransaction 2020-10-08 14:11:16 -07:00
Wladimir J. van der Laan
d9de00b3e0
Merge #20105: [net] Remove CombinerAll
1afcd41a90 [net] Remove CombinerAll (John Newbery)

Pull request description:

  This was introduced in 9519a9a4 for use with boost signals. Boost signals
  have not been used in net since 8ad663c1, so this code is unused.

ACKs for top commit:
  MarcoFalke:
    review ACK 1afcd41a90
  laanwj:
    code review ACK 1afcd41a90

Tree-SHA512: a4313142afb88bf12f15abc4e717b3b0d0b40d2d5db2638494af3181e1cd680d7b036087050fc0e0dfe606228849a2e20ae85135908a9ebe8ff2130f163920e1
2020-10-08 20:42:19 +02:00
MarcoFalke
faa0847dec
doc: Add release notes for #20101 2020-10-08 15:11:25 +02:00
MarcoFalke
392c6f4fb2
Merge #20101: rpc: change no wallet loaded message to be clearer
907f142fc7 rpc: change no wallet loaded message to be clearer (Andrew Chow)

Pull request description:

  Changes the no wallet is loaded rpc error message to be clearer that no wallet is loaded and how the user can load or create a wallet. Also changes the error code from METHOD_NOT_FOUND to RPC_WALLET_NOT_FOUND as that makes more sense.

ACKs for top commit:
  MarcoFalke:
    review ACK 907f142fc7
  kristapsk:
    ACK 907f142fc7. In addition to standard tests, just in case tested that this doesn't break anything with JoinMarket.
  meshcollider:
    utACK 907f142fc7

Tree-SHA512: 4b413e6ab5430ec75a79de9db6583f2f3f38ccdf71aa373d8386a56e64f07f92200c8107c8c82c92c7c431d739615977c208b771a24c5960fa8676789b5497a2
2020-10-08 15:07:23 +02:00
MarcoFalke
faf2999e25
cirrus: Use kvm to avoid spurious CI failures in the default virtualization cluster 2020-10-08 14:47:21 +02:00
John Newbery
1afcd41a90 [net] Remove CombinerAll
This was introduced in 9519a9a4 for use with boost signals. Boost signals
have not been used in net since 8ad663c1, so this code is unused
2020-10-08 12:28:38 +01:00
MarcoFalke
b337bd7bc0
Merge #20065: fuzz: Configure check for main function
fae7a1c188 fuzz: Configure check for main function (MarcoFalke)

Pull request description:

  Instead of the PP jungle, use a proper configure check

  Fixes https://github.com/google/honggfuzz/issues/336#issuecomment-702972138

ACKs for top commit:
  practicalswift:
    ACK fae7a1c188

Tree-SHA512: 2e55457d01f9ac598bb1e119d8b49dca55a28f88ec164cee6b5f071c29e9791f5a46cc8ee2b801b3a3faf906348da964ce32e7254da981c1104b9210a3508100
2020-10-08 13:17:45 +02:00
MarcoFalke
9dd4de2832
Merge #20027: Use mockable time everywhere in net_processing
b6834e312a Avoid 'timing mishap' warnings when mocking (Pieter Wuille)
ec3916f40a Use mockable time everywhere in net_processing (Pieter Wuille)

Pull request description:

  The fact that net_processing uses a mix of mockable tand non-mockable time functions made it hard to write functional tests for #19988.

  I'm opening this as a separate PR as I believe it's independently useful. In some ways this doesn't go quite as far as it could, as there are now several data structures that could be converted to `std::chrono` types as well now. I haven't done that here, but I'm happy to reconsider that.

ACKs for top commit:
  MarcoFalke:
    ACK b6834e312a 🌶
  jnewbery:
    utACK b6834e312a
  naumenkogs:
    utACK b6834e3

Tree-SHA512: 6528a167c57926ca12894e0c476826411baf5de2f7b01c2125b97e5f710e620f427bbb13f72bdfc3de59072e56a9c1447bce832f41c725e00e81fea019518f0e
2020-10-08 11:38:47 +02:00
Pieter Wuille
b6834e312a Avoid 'timing mishap' warnings when mocking 2020-10-08 01:04:29 -07:00
Pieter Wuille
ec3916f40a Use mockable time everywhere in net_processing 2020-10-08 01:04:29 -07:00