Skip to content

Conversation

@mzumsande
Copy link
Contributor

bitcoind nodes send getaddr messages only to outbound nodes (and ignore getaddr received by outgoing connections).
The python p2p node should mirror this behavior by not sending a getaddr message when it is not the initiator of the connection.
This is currently causing several unnecessary messages being sent and then ignored (Ignoring "getaddr" from outbound-full-relay connection.) in tests like p2p_add_connections.py.

…cted to

Bitcoind nodes send getaddr msgs only to outbound nodes (and ignore those
received by outgoing connections). The python p2p node should mirror
this behavior by not sending a getaddr message when it is not the
initiator of the connection.
@DrahtBot
Copy link
Contributor

DrahtBot commented Oct 10, 2023

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK pablomartin4btc, pinheadmz, BrandonOdiwuor
Concept ACK brunoerg, sipa

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #24748 (test/BIP324: functional tests for v2 P2P encryption by stratospher)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@DrahtBot DrahtBot added the Tests label Oct 10, 2023
@brunoerg
Copy link
Contributor

Concept ACK

Copy link
Member

@pablomartin4btc pablomartin4btc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested ACK

Copy link
Contributor

@BrandonOdiwuor BrandonOdiwuor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 88c33c6

Copy link
Member

@pablomartin4btc pablomartin4btc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to add these 2 checks (explicitly) at some point (?):

  • verify that there are no getaddr messages sent to inbound nodes,
  • verify that filtering out getaddr messages when come from outbound nodes works (eg #5442)

@mzumsande
Copy link
Contributor Author

  • verify that there are no getaddr messages sent to inbound nodes

Good idea, I added to commit to add this check to p2p_addr_relay.py (it's basically just an added assert)

That is already verified in the "Check that we answer getaddr messages only from inbound peers" section of p2p_addr_relay.py

@pablomartin4btc
Copy link
Member

  • verify that there are no getaddr messages sent to inbound nodes

Good idea, I added to commit to add this check to p2p_addr_relay.py (it's basically just an added assert)

Great, thanks and I appreciate including me as a co-author of that change, many thanks.

That is already verified in the "Check that we answer getaddr messages only from inbound peers" section of p2p_addr_relay.py

Yeah, perhaps I'm wrong but what I meant is since we are not sending the getaddr anymore (eg to inbound peers) we are not really filtering them out (from outbound peers), so maybe we need to force this situation (assert_equal(full_outbound_peer.getaddr_received(), True)) to validate that we don't reply to them. Perhaps this is already happening at another level and I'm totally missing it, ignore me if that's the case.

@mzumsande
Copy link
Contributor Author

mzumsande commented Oct 13, 2023

Yeah, perhaps I'm wrong but what I meant is since we are not sending the getaddr anymore (eg to inbound peers) we are not really filtering them out (from outbound peers), so maybe we need to force this situation (assert_equal(full_outbound_peer.getaddr_received(), True)) to validate that we don't reply to them. Perhaps this is already happening at another level and I'm totally missing it, ignore me if that's the case.

Sorry, I don't follow, who is "we"?
After this PR, the python p2p doesn't send getaddr to bitcoind anymore automatically if bitcoind connects to it.
In the existing test that I referred to, we test whether getaddr are ignored or not by instead sending the msg manually from pyhton p2p here and then check here whether bitcoind responded or ignored it.

(assert_equal(full_outbound_peer.getaddr_received(), True))

That is the other direction (python p2p receives getaddr, bitcoind sends it or not) and is checked here.

@sipa
Copy link
Member

sipa commented Oct 13, 2023

Concept ACK

@pablomartin4btc
Copy link
Member

Sorry, I don't follow, who is "we"?

I meant with the changes made by this PR.

After this PR, the python p2p doesn't send getaddr to bitcoind anymore automatically if bitcoind connects to it. In the existing test that I referred to, we test whether getaddr are ignored or not by instead sending the msg manually from pyhton p2p here and then check here whether bitcoind responded or ignored it.

Perfect, thank you very much for the clarification, I missed that.

(assert_equal(full_outbound_peer.getaddr_received(), True))

That is the other direction (python p2p receives getaddr, bitcoind sends it or not) and is checked here.

Thanks again for the links, I got it now.

Copy link
Member

@pablomartin4btc pablomartin4btc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re ACK 9cfc1c9

@pinheadmz
Copy link
Member

concept ACK 9cfc1c9

Confirmed the in/outbound asymmetry for sending and responding to getaddr messages

I wonder if it'd be cleaner to initialize Class P2PConnection with property self.outbound = True and then you only have to switch it to False in TestNode.add_outbound_p2p_connection() (which is outbound from bitcoin core but the P2PConnection perspective is inbound)

@DrahtBot DrahtBot requested review from BrandonOdiwuor and removed request for BrandonOdiwuor October 18, 2023 19:04
Copy link
Contributor

@BrandonOdiwuor BrandonOdiwuor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re ACK 9cfc1c9

@fanquake fanquake merged commit eca2e43 into bitcoin:master Nov 1, 2023
kwvg added a commit to kwvg/dash that referenced this pull request Oct 16, 2024
PastaPastaPasta added a commit to dashpay/dash that referenced this pull request Oct 22, 2024
, bitcoin#28645, bitcoin#28632, bitcoin#28782, bitcoin#28822, bitcoin#29006, bitcoin#29212, merge bitcoin-core/gui#754, partial bitcoin#23443, bitcoin#26448 (BIP324 backports: part 3)

aa5311d merge bitcoin#29212: Fix -netinfo backward compat with getpeerinfo pre-v26 (Kittywhiskers Van Gogh)
1a293c7 merge bitcoin#29006: fix v2 transport intermittent test failure (Kittywhiskers Van Gogh)
d0804d4 merge bitcoin#28822: Add missing wait for version to be sent in add_outbound_p2p_connection (Kittywhiskers Van Gogh)
c0b3062 merge bitcoin#28782: Add missing sync on send_version in peer_connect (Kittywhiskers Van Gogh)
35253cd merge bitcoin#28632: make python p2p not send getaddr on incoming connections (Kittywhiskers Van Gogh)
6a4ca62 merge bitcoin#28645: fix `assert_debug_log` call-site bugs, add type checks (Kittywhiskers Van Gogh)
deaee14 merge bitcoin-core/gui#754: Add BIP324-specific labels to peer details (Kittywhiskers Van Gogh)
fffe6e7 merge bitcoin#27986: remove race in the user-agent reception check (Kittywhiskers Van Gogh)
1bf135b merge bitcoin#26553: Fix intermittent failure in rpc_net.py (Kittywhiskers Van Gogh)
5bf245b partial bitcoin#26448: fix intermittent failure in p2p_sendtxrcncl.py (Kittywhiskers Van Gogh)
b7c0030 partial bitcoin#23443: Erlay support signaling (Kittywhiskers Van Gogh)
c709df7 merge bitcoin#20524: Move MIN_VERSION_SUPPORTED to p2p.py (Kittywhiskers Van Gogh)

Pull request description:

  ## Additional Information

  * Dependent on #6324

  * Dependency for #6330

  ## How Has This Been Tested?

  * Changes to Qt client were validated by running the client

    <details>

    <summary>Screenshot</summary>

    ![Transport reporting in Qt](https://github.com/user-attachments/assets/0d551e19-f3a2-4ce7-83d6-5cb3d03b1765)

    </details>

  * Changes to `dash-cli` were validated by running it with different node versions

    **Against a node built on this PR**

    <details>

    <summary>Screenshot</summary>

    ![getinfo with node running the latest build](https://github.com/user-attachments/assets/8cda68cc-727a-4cf3-a4d8-dd6a33331d78)

    </details>

    **Against a node built running the last release**

    <details>

    <summary>Screenshot</summary>

    ![getinfo with node running the latest release](https://github.com/user-attachments/assets/0c6ff476-7cc9-4297-bae5-35d423aba480)

    </details>

  ## Breaking Changes

  None expected.

  ## Checklist:

  - [x] I have performed a self-review of my own code
  - [x] I have commented my code, particularly in hard-to-understand areas (note: N/A)
  - [x] I have added or updated relevant unit/integration/functional/e2e tests
  - [x] I have made corresponding changes to the documentation (note: N/A)
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  UdjinM6:
    ACK aa5311d
  PastaPastaPasta:
    utACK aa5311d

Tree-SHA512: 8cca324ac988a73c0590a4e9b318e81ce951ac55fb173cf507fa647cab01ab4981e6a06d4792376b4bfb44ff09d4811de05fadb9ba793dd00b4c7965b4b22654
@bitcoin bitcoin locked and limited conversation to collaborators Oct 31, 2024
@mzumsande mzumsande deleted the 202310_test_no_getaddr branch January 2, 2025 22:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants