Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: Extract download permission from noban #19191

Merged
merged 1 commit into from Jul 9, 2020

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Jun 6, 2020

It should be possible to grant nodes in a local network (e.g. home, university, enterprise, ...) permission to download blocks even after the maxuploadtarget is hit.

Currently this is only possible by setting the noban permission, which has some adverse effects, especially if the peers can't be fully trusted.

Fix this by extracting a download permission from noban.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 7, 2020

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

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.

@naumenkogs
Copy link
Member

Concept ACK.

Copy link
Member

@Sjors Sjors 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. Some minor feedback on faeb4f4.

src/net_processing.cpp Outdated Show resolved Hide resolved
src/net_processing.cpp Show resolved Hide resolved
Copy link
Member

@luke-jr luke-jr left a comment

Choose a reason for hiding this comment

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

utACK

luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 12, 2020
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 12, 2020
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 15, 2020
@Sjors
Copy link
Member

Sjors commented Jun 15, 2020

utACK 111109a

@promag
Copy link
Member

promag commented Jul 5, 2020

ACK 111109a.

(👍 on the needs release note tag)

@naumenkogs
Copy link
Member

utACK 111109a

@sipa
Copy link
Member

sipa commented Jul 7, 2020

utACK 111109a, but needs rebase.

@jonatack
Copy link
Contributor

jonatack commented Jul 8, 2020

Concept ACK

@maflcko
Copy link
Member Author

maflcko commented Jul 9, 2020

Added release notes and addressed feedback by @jonatack

@jonatack
Copy link
Contributor

jonatack commented Jul 9, 2020

ACK fa0540c

@Sjors
Copy link
Member

Sjors commented Jul 9, 2020

re-utACK fa0540c

@fanquake fanquake requested review from naumenkogs and sipa July 9, 2020 14:09
@maflcko maflcko merged commit cc9d09e into bitcoin:master Jul 9, 2020
@maflcko maflcko deleted the 2006-netPerDow branch July 9, 2020 15:42
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Aug 15, 2020
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Mar 22, 2021
Summary:
```
It should be possible to grant nodes in a local network (e.g. home,
university, enterprise, ...) permission to download blocks even after
the maxuploadtarget is hit.

Currently this is only possible by setting the noban permission, which
has some adverse effects, especially if the peers can't be fully
trusted.

Fix this by extracting a download permission from noban.
```

Backport of [[bitcoin/bitcoin#19191 | core#19191]].

Depends on D9324 and D9325.

Test Plan:
  ninja all check-all

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Subscribers: majcosta

Differential Revision: https://reviews.bitcoinabc.org/D9326
laanwj added a commit that referenced this pull request May 11, 2021
…:Bind()

36fb036 p2p: allow NetPermissions::ClearFlag() only with PF_ISIMPLICIT (Jon Atack)
4e0d578 test: add net permissions noban/download unit test coverage (Jon Atack)
dde69f2 p2p, bugfix: use NetPermissions::HasFlag() in CConnman::Bind() (Jon Atack)

Pull request description:

  This is a bugfix follow-up to #16248 and #19191 that was noticed in #21506. Both v0.21 and master are affected.

  Since #19191, noban is a multi-flag that implies download, so the conditional in `CConnman::Bind()` using a bitwise AND on noban will return the same result for both the noban status and the download status. This means that download peers are incorrectly not being added to local addresses because they are mistakenly seen as noban peers.

  The second commit adds unit test coverage to illustrate and test the noban/download relationship and the `NetPermissions` operations involving them.

  The final commit adds documentation and disallows calling `NetPermissions::ClearFlag()` with any second param other than `NetPermissionFlags` "implicit" -- per current usage in the codebase -- because `ClearFlag()` should not be called with any second param that is a subflag of a multiflag, e.g. "relay" or "download," as that would leave the result in an invalid state corresponding to none of the existing NetPermissionFlags. Thanks to Vasil Dimov for noticing this.

ACKs for top commit:
  theStack:
    re-ACK 36fb036 ☕
  vasild:
    ACK 36fb036
  hebasto:
    ACK 36fb036, I have reviewed the code and it looks OK, I agree it can be merged.
  kallewoof:
    Code review ACK 36fb036

Tree-SHA512: 5fbc7ddbf31d06b35bf238f4d77ef311e6b6ef2e1bb9893f32f889c1a0f65774a3710dcb21d94317fe6166df9334a9f2d42630809e7fe8cbd797dd6f6fc49491
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request May 11, 2021
…onnman::Bind()

36fb036 p2p: allow NetPermissions::ClearFlag() only with PF_ISIMPLICIT (Jon Atack)
4e0d578 test: add net permissions noban/download unit test coverage (Jon Atack)
dde69f2 p2p, bugfix: use NetPermissions::HasFlag() in CConnman::Bind() (Jon Atack)

Pull request description:

  This is a bugfix follow-up to bitcoin#16248 and bitcoin#19191 that was noticed in bitcoin#21506. Both v0.21 and master are affected.

  Since bitcoin#19191, noban is a multi-flag that implies download, so the conditional in `CConnman::Bind()` using a bitwise AND on noban will return the same result for both the noban status and the download status. This means that download peers are incorrectly not being added to local addresses because they are mistakenly seen as noban peers.

  The second commit adds unit test coverage to illustrate and test the noban/download relationship and the `NetPermissions` operations involving them.

  The final commit adds documentation and disallows calling `NetPermissions::ClearFlag()` with any second param other than `NetPermissionFlags` "implicit" -- per current usage in the codebase -- because `ClearFlag()` should not be called with any second param that is a subflag of a multiflag, e.g. "relay" or "download," as that would leave the result in an invalid state corresponding to none of the existing NetPermissionFlags. Thanks to Vasil Dimov for noticing this.

ACKs for top commit:
  theStack:
    re-ACK 36fb036 ☕
  vasild:
    ACK 36fb036
  hebasto:
    ACK 36fb036, I have reviewed the code and it looks OK, I agree it can be merged.
  kallewoof:
    Code review ACK 36fb036

Tree-SHA512: 5fbc7ddbf31d06b35bf238f4d77ef311e6b6ef2e1bb9893f32f889c1a0f65774a3710dcb21d94317fe6166df9334a9f2d42630809e7fe8cbd797dd6f6fc49491
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
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.

None yet

9 participants