Skip to content

Conversation

brunoerg
Copy link
Contributor

@brunoerg brunoerg commented Feb 16, 2023

Revives #17167. It allows whitelisting manual connections. Fixes #9923

Since there are some PRs/issues around this topic, I'll list some motivations/comments for whitelisting outbound connections from them:

@DrahtBot
Copy link
Contributor

DrahtBot commented Feb 16, 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 sr-gi, pinheadmz, achow101
Concept NACK luke-jr
Concept ACK furszy, RandyMcMillan
Approach ACK jonatack
Stale ACK pablomartin4btc, naumenkogs, stratospher

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:

  • #29415 (Broadcast own transactions only via short-lived Tor or I2P connections by vasild)
  • #28834 (net: attempts to connect to all resolved addresses when connecting to a node by sr-gi)
  • #28710 (Remove the legacy wallet and BDB dependency by achow101)

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 P2P label Feb 16, 2023
@brunoerg
Copy link
Contributor Author

cc: @furszy @theStack

@naumenkogs
Copy link
Member

Concept ACK

Copy link
Contributor

@stratospher stratospher left a comment

Choose a reason for hiding this comment

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

concept ACK. whitelisting outgoing connections is a useful feature to have! went through the code and it looks good.

  • integration tests in p2p_permissions.py would be nice! (It’d be interesting to see the behaviour when different permissions are set in different connection directions.)
  • something i had trouble understanding was if we give a trusted peer special permissions, would it matter who initiated the connection?
  • micro nit: next time you rebase/update, maybe reword the 1st commit message to use NetPermissionFlags::Implicit instead of PF_ISIMPLICIT?

Copy link
Member

@furszy furszy left a comment

Choose a reason for hiding this comment

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

Concept ACK

Could also add a test framework option to whitelist peers. So we don't have to add -whitelist flag everywhere.

@brunoerg
Copy link
Contributor Author

Could also add a test framework option to whitelist peers. So we don't have to add -whitelist flag everywhere.

Sounds good! Gonna implement it!

@brunoerg brunoerg force-pushed the 2023-02-outgoing-whitelist branch 2 times, most recently from 67b32c5 to 6ed6fca Compare March 14, 2023 23:24
@brunoerg
Copy link
Contributor Author

brunoerg commented Mar 15, 2023

force-pushed: Added self.whitelist_peers in test_framework to avoid having to add -whitelist flag everywhere. Also, I changed the 1st commit message as suggested by @stratospher.

@brunoerg
Copy link
Contributor Author

Rebased

@glozow
Copy link
Member

glozow commented Apr 20, 2023

linking #9923
perhaps also relevant: #10594, #10051

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

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

ACK 19f3f3a with some suggestions

],
[]
]
self.whitelist_peers = True
Copy link
Member

Choose a reason for hiding this comment

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

19f3f3a This doesn't seem to be a pure refactoring here and in mempool_packages.py and p2p_segwit.py

@brunoerg
Copy link
Contributor Author

Copy link
Member

@sr-gi sr-gi 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 0a53361

@DrahtBot DrahtBot requested a review from pinheadmz February 28, 2024 20:11
Copy link
Member

@pinheadmz pinheadmz left a comment

Choose a reason for hiding this comment

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

ACK 0a53361

confirmed minimal diff since last ack

Show Signature
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

ACK 0a533613fb44207053796fd01a9f4b523a3153d4
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEE5hdzzW4BBA4vG9eM5+KYS2KJyToFAmXg8cMACgkQ5+KYS2KJ
yTqb9BAAlsYlKQ6Umtb5FVctkQebcoO7F4P0cHseOl97Xlkcr+slqDGDnYNs19ft
6Ct9HJkB/faLzOQ2gyGq3cOxMevkuQEWBxAKti54uoHY5X5Ye51W5ejJz3BLT+Sw
pDhwlpXo2hSz7GhgpUeb6mj0+rHyA3pMXNvFGjcrjHCX4AeJdWLZEcau0avZ+Luj
5cl0cDxNztu6xWCSAdoooEDyHcpXifYafPOkMV2L6qefh94rZuHuc7gmCnff5geB
lb5DZJQm6lJiLLQBHQ6UUw5hLx4Myfn0Vdb3h937amiwZ+2RsTEHTT1RoZ0lT1Q4
qi/ehtXq+iLcqAA2FzHaiTc1IgZzG3ylJQMGov5rQ2irIpYBKyzPBgZcSloS49oK
lbMB3a3onyABtmmyCQGLG/ituxp8n1/MawyANaQj+uJF7aJrVoylkNctm7J5gb5T
6YYeYVEV/Dav+OqeJj+LZr+4zxvYHndTgrE7MgTZsGMoam/A7jzjZdS3Y0nceCIZ
Lm2d57+nzar/36pp2zzfS6yTjdIgK1NxGEYDLDSBSXdWV3YVaCbGezMzghAc2Wb1
l5JHH+SFvXhOY5WaciuhOUWF7wq726WtaNUeUGldIGHqJB0QrkJOB1IUqpkbaCOU
d4g4ePAXMkxIeo+m9QXwARLX9iFHr4AkW+qsytQoS3OgMQIQpdQ=
=N5cR
-----END PGP SIGNATURE-----

pinheadmz's public key is on keybase

Copy link
Contributor

@stratospher stratospher left a comment

Choose a reason for hiding this comment

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

concept ACK! it's useful to be able to whitelist and give special permissions to manual peers which are essentially peers you trust.

I've gone through all the commits but not leaving a code review/approach ACK since I don't understand why we'd need different permissions for each connection direction. (related comments - #17167 (comment), #27114 (comment), #27114 (comment))

@@ -27,10 +27,11 @@
class MempoolPackagesTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 2
# whitelist peers to speed up tx relay / mempool sync
self.noban_tx_relay = True
Copy link
Contributor

Choose a reason for hiding this comment

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

c985eb8: isn't this a behaviour change in the functional test? now, the second node also has noban permission - previously it didn't. same situation happens in test/functional/p2p_segwit.py.

so maybe keep "-whitelist=noban@127.0.0.1" instead of self.noban_tx_relay = True in both these tests.

(haven't looked into how having noban permission for second node affects the functional test though.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I does not affect the behaviour of the tests since those tests does not test any misbehaviour. It is just to speed up tx relay.

@achow101
Copy link
Member

ACK 0a53361

@achow101 achow101 merged commit bef9917 into bitcoin:master Mar 12, 2024
kevkevinpal pushed a commit to kevkevinpal/bitcoin that referenced this pull request Mar 13, 2024
kevkevinpal pushed a commit to kevkevinpal/bitcoin that referenced this pull request Mar 13, 2024
sr-gi pushed a commit to sr-gi/bitcoin that referenced this pull request Mar 25, 2024
Retropex pushed a commit to Retropex/bitcoin that referenced this pull request Mar 28, 2024
Retropex pushed a commit to Retropex/bitcoin that referenced this pull request Mar 28, 2024
Retropex pushed a commit to Retropex/bitcoin that referenced this pull request Mar 28, 2024
Retropex pushed a commit to Retropex/bitcoin that referenced this pull request Mar 28, 2024
Retropex pushed a commit to Retropex/bitcoin that referenced this pull request Mar 28, 2024
Retropex pushed a commit to Retropex/bitcoin that referenced this pull request Mar 28, 2024
theStack added a commit to theStack/bitcoin that referenced this pull request Apr 6, 2024
Reverts commit ab4efad (PR bitcoin#26970).
This workaround is not needed anymore, as since bitcoin#27114 the test sets
the noban permission for both in- and outbound connections via the
`noban_tx_relay` setting, and we don't have to rely on these topology
hacks anymore. See commit c985eb8.
fanquake added a commit that referenced this pull request Apr 7, 2024
…oups.py

93fae5a test: remove immediate tx relay workaround in wallet_groups.py (Sebastian Falbesoner)

Pull request description:

  Reverts commit ab4efad (PR #26970). This workaround is not needed anymore, as since #27114 the test sets the noban permission for both in- and outbound connections via the `noban_tx_relay` setting, and we don't have to rely on this topology hack anymore. See commit c985eb8 (kudos to brunoerg!).

  Can be tested by executing `$ time ./test/functional/wallet_groups.py` both on master and PR and verifying that the execution time is roughly equal.

ACKs for top commit:
  maflcko:
    lgtm ACK 93fae5a
  brunoerg:
    utACK 93fae5a

Tree-SHA512: b949fd05b4308815ba02d0ee4d1318f642b930288dd03223f46db7db745177af1c070bc7058743ac27963c5ad90564089867cc12f31fee94812a16919c353bab
// By default, whitelist only applies to incoming connections
if (connection_direction == ConnectionDirection::None) {
connection_direction = ConnectionDirection::In;
} else if (flags == NetPermissionFlags::None) {
Copy link
Member

@sr-gi sr-gi Apr 10, 2024

Choose a reason for hiding this comment

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

Going over this PR again, shouldn't this have been a separate if statement instead of an if/else (or not a condition at all)?

Right now we are accepting expressions of the type @ip:port (which were already accepted before), but not expressions of the type in/out@ip:port.

The former will pass and default to ConnectionDirection::In + NetPermissionFlags::Implicit, while the latter will be rejected. That feels inconsistent

PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Oct 25, 2024
…llet_groups.py

93fae5a test: remove immediate tx relay workaround in wallet_groups.py (Sebastian Falbesoner)

Pull request description:

  Reverts commit ab4efad (PR bitcoin#26970). This workaround is not needed anymore, as since bitcoin#27114 the test sets the noban permission for both in- and outbound connections via the `noban_tx_relay` setting, and we don't have to rely on this topology hack anymore. See commit c985eb8 (kudos to brunoerg!).

  Can be tested by executing `$ time ./test/functional/wallet_groups.py` both on master and PR and verifying that the execution time is roughly equal.

ACKs for top commit:
  maflcko:
    lgtm ACK 93fae5a
  brunoerg:
    utACK 93fae5a

Tree-SHA512: b949fd05b4308815ba02d0ee4d1318f642b930288dd03223f46db7db745177af1c070bc7058743ac27963c5ad90564089867cc12f31fee94812a16919c353bab
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Nov 12, 2024
Summary:
> net: store `-whitelist{force}relay` values in `CConnman`

> net: Move NetPermissionFlags::Implicit verification to `AddWhitelistPermissionFlags`

> net_processing: Move extra service flag into InitializeNode

> Accept "in" and "out" flags to -whitelist to allow whitelisting manual connections

> test: add coverage for whitelisting manual connections

This is a partial backport of [[bitcoin/bitcoin#27114 | core#27114]]
bitcoin/bitcoin@2863d7d
bitcoin/bitcoin@9133fd6
bitcoin/bitcoin@8e06be3
bitcoin/bitcoin@66bc6e2
bitcoin/bitcoin@e6b8f19
bitcoin/bitcoin@0a53361

Depends on D17112
Note that CNode::m_permissionFlags was made public by core in [[bitcoin/bitcoin#20881 | core#20881]] which we are missing so it had to be made public in this diff.

Test Plan: `ninja all check-all`

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D17114
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Nov 12, 2024
Summary:
when `self.noban_tx_relay=True`, the following flag
`-whitelist=noban,in,out@127.0.0.1`is added to `extra_args`
to speed up tx relay/mempool sync.

Before (all functional tests):
```
ALL                                        | ✓ Passed  | 1465 s (accumulated)
Runtime: 163 s
```

After:
```
ALL                                        | ✓ Passed  | 1350 s (accumulated)
Runtime: 150 s

```

This makes test duration shorter and hopefully solves some rare timeouts in interface_rest.py

This concludes backport of [[bitcoin/bitcoin#27114 | core#27114]]
bitcoin/bitcoin@c985eb8

Bypasses [[bitcoin/bitcoin#26970 | core#26970]] and [[bitcoin/bitcoin#29822 | core#29822]]

Depends on D17114

Test Plan: `ninja check-functional`

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D17115
roqqit pushed a commit to doged-io/doged that referenced this pull request Nov 21, 2024
Summary:
> net: store `-whitelist{force}relay` values in `CConnman`

> net: Move NetPermissionFlags::Implicit verification to `AddWhitelistPermissionFlags`

> net_processing: Move extra service flag into InitializeNode

> Accept "in" and "out" flags to -whitelist to allow whitelisting manual connections

> test: add coverage for whitelisting manual connections

This is a partial backport of [[bitcoin/bitcoin#27114 | core#27114]]
bitcoin/bitcoin@2863d7d
bitcoin/bitcoin@9133fd6
bitcoin/bitcoin@8e06be3
bitcoin/bitcoin@66bc6e2
bitcoin/bitcoin@e6b8f19
bitcoin/bitcoin@0a53361

Depends on D17112
Note that CNode::m_permissionFlags was made public by core in [[bitcoin/bitcoin#20881 | core#20881]] which we are missing so it had to be made public in this diff.

Test Plan: `ninja all check-all`

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D17114
roqqit pushed a commit to doged-io/doged that referenced this pull request Nov 21, 2024
Summary:
when `self.noban_tx_relay=True`, the following flag
`-whitelist=noban,in,out@127.0.0.1`is added to `extra_args`
to speed up tx relay/mempool sync.

Before (all functional tests):
```
ALL                                        | ✓ Passed  | 1465 s (accumulated)
Runtime: 163 s
```

After:
```
ALL                                        | ✓ Passed  | 1350 s (accumulated)
Runtime: 150 s

```

This makes test duration shorter and hopefully solves some rare timeouts in interface_rest.py

This concludes backport of [[bitcoin/bitcoin#27114 | core#27114]]
bitcoin/bitcoin@c985eb8

Bypasses [[bitcoin/bitcoin#26970 | core#26970]] and [[bitcoin/bitcoin#29822 | core#29822]]

Depends on D17114

Test Plan: `ninja check-functional`

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D17115
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Feb 22, 2025
@bitcoin bitcoin locked and limited conversation to collaborators Apr 10, 2025
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.

Whitelisting outgoing connections