Commit graph

873 commits

Author SHA1 Message Date
Byron Hambly
54c9ee347d Merge 9635760ce8 into merged_master (Bitcoin PR bitcoin/bitcoin#22777) 2023-06-13 10:06:36 +00:00
Byron Hambly
70c69d94f6 Merge 9f7661c0c4 into merged_master (Bitcoin PR bitcoin/bitcoin#19499) 2023-06-12 13:11:30 +00:00
Byron Hambly
b0b2f3deff Merge f6013265b7 into merged_master (Bitcoin PR bitcoin/bitcoin#20295) 2023-06-06 09:10:04 +00:00
Byron Hambly
16ce576d1d Merge e457513eb1 into merged_master (Bitcoin PR bitcoin/bitcoin#23631) 2023-06-02 12:58:30 +00:00
James Dorfman
72a90148c8 Merge 8b1de78577 into merged_master (Bitcoin PR bitcoin/bitcoin#23413) 2023-06-01 18:51:42 +00:00
James Dorfman
5aadbb7a9d Merge 63c0d0e937 into merged_master (Bitcoin PR bitcoin/bitcoin#21327)
I commented out a few new lines at the bottom of test/functional/p2p_ibd_txrelay.py
It tests that nodes process certain transactions, after IBD. These new assertions
from upstream are failing, but it may be because our IBD / tx sharing logic is different.

We should revisit this.
2023-06-01 05:27:06 +00:00
Byron Hambly
8250bf53d2 Merge 606e306277 into merged_master (Bitcoin PR bitcoin/bitcoin#22981) 2023-05-26 13:47:21 +00:00
Byron Hambly
2da8f66309 Merge 38b2a0a3f9 into merged_master (Bitcoin PR bitcoin/bitcoin#23173) 2023-05-24 11:45:57 +00:00
James Dorfman
df8f97d63b Merge 1847ce2d49 into merged_master (Bitcoin PR bitcoin/bitcoin#23157) 2023-05-16 09:04:56 +00:00
Byron Hambly
7925c2a451 Merge 224e90d9fd into merged_master (Bitcoin PR bitcoin/bitcoin#23336) 2023-05-15 12:27:08 +00:00
Byron Hambly
06d3e29912 Merge 788909f3c7 into merged_master (Bitcoin PR bitcoin/bitcoin#23042) 2023-05-14 11:08:09 +00:00
Byron Hambly
8299bec8a2 Merge c001da306b into merged_master (Bitcoin PR bitcoin/bitcoin#23325) 2023-05-14 10:52:15 +00:00
Byron Hambly
c1a05187a3 Merge 8a083bc5b5 into merged_master (Bitcoin PR bitcoin/bitcoin#23218) 2023-05-14 09:58:38 +00:00
Byron Hambly
9b7c9154fe Merge c4fc899442 into merged_master (Bitcoin PR bitcoin/bitcoin#22950) 2023-05-09 12:21:13 +00:00
Byron Hambly
498907a233 Merge 816e15ee81 into merged_master (Bitcoin PR bitcoin/bitcoin#22951) 2023-05-09 11:50:39 +00:00
Byron Hambly
4d68eaa81b Merge 4e1de1fc59 into merged_master (Bitcoin PR bitcoin/bitcoin#22340) 2023-04-28 13:51:41 +00:00
Byron Hambly
eea9829aa6 Merge 825f4a64e6 into merged_master (Bitcoin PR bitcoin/bitcoin#22976) 2023-04-24 11:40:49 +00:00
Byron Hambly
965ac7c53b Merge 58e02395ba into merged_master (Bitcoin PR bitcoin/bitcoin#22955) 2023-04-21 11:43:16 +00:00
Byron Hambly
6d32af1662 Merge 33707a2a88 into merged_master (Bitcoin PR bitcoin/bitcoin#22782) 2023-04-11 08:18:04 +00:00
James Dorfman
cdbedba214 Merge dbcb5742c4 into merged_master (Bitcoin PR bitcoin/bitcoin#20541) 2023-04-11 01:40:34 +00:00
Byron Hambly
a797e5e55a Merge 4c87665707 into merged_master (Bitcoin PR bitcoin/bitcoin#22604) 2023-04-09 07:26:48 +00:00
James Dorfman
815f4d545d Merge dd981b5e84 into merged_master (Bitcoin PR bitcoin/bitcoin#22618) 2023-04-06 20:54:28 +00:00
Byron Hambly
b9ff9a6259 Merge 513e1071a1 into merged_master (Bitcoin PR bitcoin/bitcoin#22616) 2023-04-06 13:35:05 +00:00
Byron Hambly
5f259e46c1 Merge 5b2d8661c9 into merged_master (Bitcoin PR bitcoin/bitcoin#22577) 2023-04-06 13:24:41 +00:00
Byron Hambly
05f9a1a7c2 Merge 06788c6705 into merged_master (Bitcoin PR bitcoin/bitcoin#21528) 2023-04-04 11:04:30 +02:00
James Dorfman
c8526de70a Merge 67b9416540 into merged_master (Bitcoin PR bitcoin/bitcoin#21562) 2023-03-31 18:42:53 +00:00
Glenn Willen
4334fce793 Merge 61cefde7a7 into merged_master (Bitcoin PR bitcoin/bitcoin#22006) 2023-03-28 00:12:41 +00:00
Glenn Willen
ac88de9825 Merge f372623807 into merged_master (Bitcoin PR bitcoin/bitcoin#22495) 2023-03-27 23:56:34 +00:00
James Dorfman
17e6efe7fe Merge 5d83e7d714 into merged_master (Bitcoin PR bitcoin/bitcoin#21090)
We comment out a newly-added assert from the Bitcoin
side, because it's unclear how to replicate it
correctly in Elements.

Co-authored-by: Glenn Willen <gwillen@nerdnet.org>
2023-03-22 01:11:20 +00:00
Pablo Greco
e7fea1d50b Fix underflow when blocks are ahead of headers 2023-02-21 06:22:25 -03:00
Glenn Willen
e8475e7edd Fix stuck IBD when discarding unwanted headers from peers.
When receiving unwanted headers from a peer, first check whether we have
recent "best known block" state for that peer. If not, accept one batch
of headers to refresh it. Otherwise, we can become stuck in a state where
we need blocks, but we don't know which peers have those blocks available.
This especially happens during startup, when we don't have this information
for any peers until we start processing header messages.
2023-01-24 22:05:36 -08:00
Glenn Willen
8cad8cda44 Further fixes from code review 2023-01-04 16:33:35 -08:00
Glenn Willen
29345e9e12 pgreco's startup crash fix 2022-12-12 09:53:44 -08:00
Glenn Willen
fba37b74b4 Move enough-headers check up, rejecting excess headers when received. 2022-12-12 09:53:44 -08:00
Glenn Willen
394e59d38d Politely and safely refuse getheaders requests for headers we have trimmed. 2022-12-12 09:53:44 -08:00
Glenn Willen
7e6fe4a5ba Don't let header syncing get too far ahead of block syncing 2022-12-12 09:53:44 -08:00
Glenn Willen
5cfd3812fc Merge 24ab49d110 into merged_master (Elements PR ElementsProject/elements#1085) 2022-04-21 15:36:43 -07:00
Glenn Willen
dea074b88a Merge b707a6f00f into merged_master (Elements PR ElementsProject/elements#1069) 2022-04-20 20:51:37 -07:00
Pablo Greco
5f9696437f Remove block from in-flight list when a duplicate is received 2021-12-23 18:07:52 +00:00
MarcoFalke
9635760ce8
Merge bitcoin/bitcoin#22777: net processing: don't request tx relay on feeler connections
eaf6be0114 [net processing] Do not request transaction relay from feeler connections (John Newbery)
0220b834b1 [test] Add testing for outbound feeler connections (John Newbery)

Pull request description:

  Feelers are short-lived connections used to test the viability of peers. The bitcoind node will periodically open feeler connections to addresses in its addrman, wait for a `version` message from the peer, and then close the connection.

  Currently, we set `fRelay` to `1` in the `version` message for feeler connections, indicating that we want the peer to relay transactions to us. However, we close the connection immediately on receipt of the `version` message, and so never process any incoming transaction announcements. This PR changes that behaviour to instead set `fRelay` to `0` indicating that we do not wish to receive transaction announcements from the peer.

  This PR also extends the `addconnection` RPC to allow creating outbound feeler connections from the node to the test framework, and a test to verify that the node sets `fRelay` to `0` in the `version` message to feeler connections.

ACKs for top commit:
  naumenkogs:
    ACK eaf6be0114
  MarcoFalke:
    review ACK eaf6be0114 🏃

Tree-SHA512: 1c56837dbd0a396fe404a5e39f7459864d15f666664d6b35ad109628b13158e077e417e586bf48946a23bd5cbe63716cb4bf22cdf8781b74dfce6047b87b465a
2021-12-14 17:57:10 +01:00
MarcoFalke
9f7661c0c4
Merge bitcoin/bitcoin#19499: p2p: Make timeout mockable and type safe, speed up test
fadc0c80ae p2p: Make timeout mockable and type safe, speed up test (MarcoFalke)
fa6d5a238d scripted-diff: Rename m_last_send and m_last_recv (MarcoFalke)

Pull request description:

  Use type-safe time for better code readability/maintainability and mockable time for better testability. This speeds up the p2p_timeout test.

  This is also a bugfix for intermittent test issues like: https://cirrus-ci.com/task/4769904156999680?command=ci#L2836

  Fixes #20654

ACKs for top commit:
  laanwj:
    Code review ACK fadc0c80ae
  naumenkogs:
    ACK fadc0c80ae

Tree-SHA512: 28c6544c97f188c8a0fbc80411c74ab74ffd055885322c325aa3d1c404b29c3fd70a737e86083eecae58ef394db1cb56bc122d06cff63742aa89a8e868730c64
2021-12-10 10:02:12 +01:00
MarcoFalke
f6013265b7
Merge bitcoin/bitcoin#20295: rpc: getblockfrompeer
dce8c4c381 rpc: getblockfrompeer (Sjors Provoost)
b884ababc2 rpc: move Ensure* helpers to server_util.h (Sjors Provoost)

Pull request description:

  This adds an RPC method to fetch a block directly from a peer. This can used to fetch stale blocks with lower proof of work that are normally ignored by the node (`headers-only` in `getchaintips`).

  Usage:
  ```
  bitcoin-cli getblockfrompeer HASH peer_n
  ```

  Closes #20155

  Limitations:
  * you have to specify which peer to fetch the block from
  * the node must already have the header

ACKs for top commit:
  jnewbery:
    ACK dce8c4c381
  fjahr:
     re-ACK dce8c4c381

Tree-SHA512: 843ba2b7a308f640770d624d0aa3265fdc5c6ea48e8db32269b96a082b7420f7953d1d8d1ef2e6529392c7172dded9d15639fbc9c24e7bfa5cfb79e13a5498c8
2021-12-08 10:39:37 +01:00
fanquake
e457513eb1
Merge bitcoin/bitcoin#23631: p2p: Don't use timestamps from inbound peers for Adjusted Time
0c85dc30e6 p2p: Don't use timestamps from inbound peers (Martin Zumsande)

Pull request description:

  `GetAdjustedTime()` (used e.g. in validation and addrman) returns a time with an offset that is influenced by timestamps that our peers have sent us in their version message.

  Currently, timestamps from all peers are used for this.
  However, I think that it would make sense to ignore the timedata samples from inbound peers, making it much harder for others to influence the Adjusted Time in a targeted way.
  With the extra feeler connections (every 2 minutes on average) and extra block-relay-only connections (every 5 minutes on average) there are also now plenty of opportunities to gather a meaningful number of timedata samples from outbound peers.

  There are some measures in place to prevent abuse: the `-maxtimeadjustment` parameter with a default of 70 minutes, warnings in cases of large deviations, only using the first 200 samples ([explanation](383d350bd5/src/timedata.cpp (L57-L72))), but I think that only using samples from outbound connections in the first place would be an additional safety measure that would make sense.

  See also issue #4521 for further context and links: There have been several discussions in the past about replacing or abolishing the existing timedata system.

ACKs for top commit:
  jnewbery:
    Concept and code review ACK 0c85dc30e6
  naumenkogs:
    ACK 0c85dc30e6
  vasild:
    ACK 0c85dc30e6

Tree-SHA512: 2d6375305bcae034d68b58b7a07777b40ac430dfed554c88e681a048c527536691e1b7d08c0ef995247d356f8e81aa0a4b983bf2674faf6a416264e5f1af0a96
2021-12-07 17:36:53 +08:00
MarcoFalke
fadc0c80ae
p2p: Make timeout mockable and type safe, speed up test 2021-12-06 10:47:52 +01:00
MarcoFalke
8b1de78577
Merge bitcoin/bitcoin#23413: Replace MakeSpan helper with Span deduction guide
11daf6ceb1 More Span simplifications (Pieter Wuille)
568dd2f839 Replace MakeSpan helper with Span deduction guide (Pieter Wuille)

Pull request description:

  C++17 supports [user-defined deduction guides](https://en.cppreference.com/w/cpp/language/class_template_argument_deduction), allowing class constructors to be invoked without specifying class template arguments. Instead, the code can contain rules to infer the template arguments from the constructor argument types.

  This alleviates the need for the `MakeSpan` helper. Convert the existing MakeSpan rules into deduction rules for `Span` itself, and replace all invocations of `MakeSpan` with just `Span` ones.

ACKs for top commit:
  MarcoFalke:
    re-ACK 11daf6ceb1 Only change is removing a hunk in the tests 🌕

Tree-SHA512: 10f3e82e4338f39d9b7b407cd11aac7ebe1e9191b58e3d7f4e5e338a4636c0e126b4a1d912127c7446f57ba356c8d6544482e47f97901efea6a54fffbfd7895f
2021-12-03 10:44:37 +01:00
Sjors Provoost
dce8c4c381
rpc: getblockfrompeer
Co-authored-by: John Newbery <john@johnnewbery.com>
2021-12-02 13:16:18 +07:00
W. J. van der Laan
63c0d0e937
Merge bitcoin/bitcoin#21327: net_processing: ignore transactions while in IBD
6aed8b7e9b [test] tx processing before and after ibd (glozow)
b9e105b664 [net_processing] ignore all transactions during ibd (glozow)

Pull request description:

  This is basically a mini, IBD-only version of #21224

  Incoming transactions aren't really relevant until we're caught up. That's why we send a giant feefilter and don't send tx getdatas, but we also shouldn't process them if peers send them anyway. Simply ignore them.

ACKs for top commit:
  jnewbery:
    reACK 6aed8b7e9b
  laanwj:
    Code review ACK 6aed8b7e9b

Tree-SHA512: 8e1616bf355f9d0b180bdbc5461f24c757dc5d7bc7bf651470f3b0bffcca5d5e68287106255b5cede2d96b42bce448a0f8c0649de35a530c5e079f7c89c70a35
2021-11-30 19:09:15 +01:00
Pieter Wuille
568dd2f839 Replace MakeSpan helper with Span deduction guide 2021-11-29 17:58:53 -05:00
Martin Zumsande
0c85dc30e6 p2p: Don't use timestamps from inbound peers
This makes it harder for others to tamper with
our adjusted time.
2021-11-29 16:46:41 +01:00
Glenn Willen
cdfb4c9c6c Fix elements multiple-header-download issue.
This fixes an issue which causes Elements to download the blockchain headers
multiple times during initial block download.

In particular: each time we receive an INV P2P message with a new block
(about once a minute), we start downloading the headers, again, in parallel
with any existing download(s) in progress.

With this change, after we receive each batch of headers, we check whether
any of the headers in it were new to us. If not (they were all duplicates),
we stop there, and do not ask the peer for another batch. This reduces the
maximum amount of duplication to about 2x, which is not ideal, but a HUGE
improvement.
2021-11-17 09:06:38 -08:00