Commit graph

931 commits

Author SHA1 Message Date
Ava Chow
53a5bd0790 Merge bitcoin/bitcoin#33296: net: check for empty header before calling FillBlock
8b6264768030db1840041abeeaeefd6c227a2644 test: send duplicate blocktxn message in p2p_compactblocks.py (Eugene Siegel)
5e585a0fc4fd68dd7b4982054b34deae2e7aeb89 net: check for empty header before calling FillBlock (Eugene Siegel)

Pull request description:

  This avoids an Assume crash if multiple blocktxn messages are received. The first call to `FillBlock` would make the header empty via `SetNull` and the call right before the second `FillBlock` would crash [here](689a321976/src/net_processing.cpp (L3333)) since `LookupBlockIndex` won't find anything. Fix that by checking for an empty header before the Assume.

ACKs for top commit:
  instagibbs:
    reACK https://github.com/bitcoin/bitcoin/pull/33296/commits/8b6264768030db1840041abeeaeefd6c227a2644
  fjahr:
    tACK 8b6264768030db1840041abeeaeefd6c227a2644
  achow101:
    ACK 8b6264768030db1840041abeeaeefd6c227a2644
  mzumsande:
    Code Review ACK 8b6264768030db1840041abeeaeefd6c227a2644

Tree-SHA512: d43a6f652161d4f7e6137f207a3e95259fc51509279d20347b1698c91179c39c8fcb75d2668b13a6b220f478a03578573208a415804be1d8843acb057fa1a73a
2025-11-25 12:58:39 +00:00
Pablo Greco
38cbe9282d Merge branch 'master' into elem-23.3.1-rc1 2025-07-14 16:35:03 -07:00
glozow
8db506f406 Merge bitcoin/bitcoin#30394: net: fix race condition in self-connect detection
16bd283b3a Reapply "test: p2p: check that connecting to ourself leads to disconnect" (Sebastian Falbesoner)
0dbcd4c148 net: prevent sending messages in `NetEventsInterface::InitializeNode` (Sebastian Falbesoner)
66673f1c13 net: fix race condition in self-connect detection (Sebastian Falbesoner)

Pull request description:

  This PR fixes a recently discovered race condition in the self-connect detection (see #30362 and #30368).

  Initiating an outbound network connection currently involves the following steps after the socket connection is established (see [`CConnman::OpenNetworkConnection`](bd5d1688b4/src/net.cpp (L2923-L2930)) method):
  1. set up node state
  2. queue VERSION message (both steps 1 and 2 happen in [`InitializeNode`](bd5d1688b4/src/net_processing.cpp (L1662-L1683)))
  3. add new node to vector `m_nodes`

  If we connect to ourself, it can happen that the sent VERSION message (step 2) is received and processed locally *before* the node object is added to the connection manager's `m_nodes` vector (step 3). In this case, the self-connect remains undiscovered, as the detection doesn't find the outbound peer in `m_nodes` yet (see `CConnman::CheckIncomingNonce`).

  Fix this by swapping the order of 2. and 3., by taking the `PushNodeVersion` call out of `InitializeNode` and doing that in the `SendMessages` method instead, which is only called for `CNode` instances in `m_nodes`.

  The temporarily reverted test introduced in #30362 is readded. Fixes #30368.

  Thanks go to vasild, mzumsande and dergoegge for suggestions on how to fix this (see https://github.com/bitcoin/bitcoin/issues/30368#issuecomment-2200625017 ff. and https://github.com/bitcoin/bitcoin/pull/30394#discussion_r1668290789).

ACKs for top commit:
  naiyoma:
    tested ACK [https://github.com/bitcoin/bitcoin/pull/30394/commits/16bd283b3ad05daa41259a062aee0fc05b463fa6](https://github.com/bitcoin/bitcoin/pull/30394/commits/16bd283b3ad05daa41259a062aee0fc05b463fa6),  built and tested locally,  test passes successfully.
  mzumsande:
    ACK 16bd283b3a
  tdb3:
    ACK 16bd283b3a
  glozow:
    ACK 16bd283b3a
  dergoegge:
    ACK 16bd283b3a

Tree-SHA512: 5b8aced6cda8deb38d4cd3fe4980b8af505d37ffa0925afaa734c5d81efe9d490dc48a42e1d0d45dd2961c0e1172a3d5b6582ae9a2d642f2592a17fbdc184445
2025-07-08 13:53:58 +01:00
Pablo Greco
54fa255b85 Merge branch 'master' into elem-23.3.0rc5 2025-03-04 08:53:38 -08:00
Pablo Greco
b92a3ceda2 TSAN: Avoid unlocked access to pindexBestHeader 2025-02-23 14:34:19 -08:00
James Dorfman
c5e8a2be77
Merge pull request #1337 from ElementsProject/master
elements-23.x: merge master to prep release
2024-06-14 11:14:47 -04:00
Pablo Greco
6367320f70 Restore NODE_NETWORK functionality with trim_headers 2024-05-21 05:34:30 +00:00
Byron Hambly
c85f0d4fda
discount: implement net processing 2024-05-14 19:03:36 +02:00
James Dorfman
730d9fdca0 Merge 2e9fc2e353 (Bitcoin PR bitcoin/bitcoin#27624) 2023-09-25 22:37:05 +00:00
James Dorfman
0b913592b2 Merge f20016d1ab into merged_master (Elements PR #1252) 2023-08-29 04:36:30 +00:00
Byron Hambly
d9e021486f
lint: fix codespell lint issues 2023-07-28 12:07:19 +02:00
Byron Hambly
6f90a02548 Merge 30308cc380 into merged_master (Bitcoin PR bitcoin/bitcoin#20196) 2023-07-03 11:17:52 +00:00
Byron Hambly
1dc6ad6ea9 Merge ba11eb354b into merged_master (Bitcoin PR bitcoin/bitcoin#23542) 2023-07-03 09:44:18 +00:00
Byron Hambly
063acc7793 Merge cf5bb048e8 into merged_master (Bitcoin PR bitcoin/bitcoin#22932) 2023-06-28 17:12:24 +00:00
Byron Hambly
9aa813fbc8 Merge 39d9bbe4ac into merged_master (Bitcoin PR bitcoin/bitcoin#23706) 2023-06-28 14:25:29 +00:00
Byron Hambly
97153c657b Merge 973c390298 into merged_master (Bitcoin PR bitcoin/bitcoin#24078) 2023-06-20 13:11:19 +00:00
Byron Hambly
5fd03f5cdb Merge 6d859cbd79 into merged_master (Bitcoin PR bitcoin/bitcoin#24021) 2023-06-20 12:55:58 +00:00
Byron Hambly
77e3aef46b Merge dbf81a73e3 into merged_master (Bitcoin PR bitcoin/bitcoin#24079) 2023-06-20 11:34:15 +00:00
Byron Hambly
7878ba47b9 Merge c561f2f06e into merged_master (Bitcoin PR bitcoin/bitcoin#23497) 2023-06-19 09:28:31 +00:00
Byron Hambly
9044eee63e Merge 06209574da into merged_master (Bitcoin PR bitcoin/bitcoin#23832) 2023-06-15 10:50:26 +00:00
Byron Hambly
334188e09d Merge 17fdbefd3f into merged_master (Bitcoin PR bitcoin/bitcoin#23970) 2023-06-15 09:43:05 +00:00
Byron Hambly
47626b5a64 Merge 623745ca74 into merged_master (Bitcoin PR bitcoin/bitcoin#23912) 2023-06-14 15:44:11 +00:00
Byron Hambly
bd0af938dc Merge 3ec8f9f123 into merged_master (Bitcoin PR bitcoin/bitcoin#23801) 2023-06-13 19:43:04 +00:00
Byron Hambly
a23bba068f Merge 14ba286556 into merged_master (Bitcoin PR bitcoin/bitcoin#23695) 2023-06-13 15:16:02 +00:00
Byron Hambly
413786c613 Merge 8c0bd871fc into merged_master (Bitcoin PR bitcoin/bitcoin#23785) 2023-06-13 14:30:53 +00:00
Byron Hambly
8edcc34130 Merge 60b5795133 into merged_master (Bitcoin PR bitcoin/bitcoin#23758) 2023-06-13 12:26:03 +00:00
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
Anthony Towns
06731d19bc
net_processing: Boost inv trickle rate
If transactions are being added to the mempool at a rate faster than 7tx/s
(INVENTORY_BROADCAST_PER_SECOND) then peers' inventory_to_send queue can
become relatively large. If this happens, increase the number of txids
we include in an INV message (normally capped at 35) by 5 for each 1000
txids in the queue.

This will tend to clear a temporary excess out reasonably quickly; an
excess of 4000 invs to send will be cleared down to 1000 in about 30
minutes, while an excess of 20000 invs would be cleared down to 1000 in
about 60 minutes.

Github-Pull: #27610
Rebased-From: 5b3406094f
2023-05-11 17:20:38 +01:00
Suhas Daftuar
ce8f812b0a
p2p: Avoid prematurely clearing download state for other peers
Github-Pull: #27608
Rebased-From: 52e52071e0
2023-05-11 10:21:18 +01: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