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

Limit the initial crawler demand for outbound peers, based on seed peer connections #2902

Closed
teor2345 opened this issue Oct 19, 2021 · 2 comments · Fixed by #2969
Closed
Assignees
Labels
A-network Area: Network protocol updates or fixes
Projects

Comments

@teor2345
Copy link
Contributor

teor2345 commented Oct 19, 2021

Motivation

When Zebra starts up, the crawler task tries to dial peerset_initial_target_size peers. This is in addition to the peerset_initial_target_size peers from the initial seed peer connection limit.

But we only want peerset_initial_target_size initial peers, not peerset_initial_target_size * 2 initial peers. In PR #2944, this extra demand gets dropped, but it's a small waste of CPU and RAM.

Suggested Design

Initialize the peer connection count demand_tx in peer_set::initialize based on the number of connections made in add_initial_peers.

Edge Cases

The initial peer limit counts connection attempts. But the connection limit is for open connections. So we have to count the right thing here.

We should make sure the calculation doesn't underflow and panic.

Related Work

These tickets might modify the same functions as this ticket:

@teor2345 teor2345 added C-bug Category: This is a bug A-rust Area: Updates to Rust code S-blocked Status: Blocked on other tasks S-needs-triage Status: A bug report needs triage P-Medium C-security Category: Security issues I-heavy Problems with excessive memory, disk, or CPU usage I-slow Problems with performance or responsiveness I-remote-node-overload Zebra can overload other nodes on the network A-network Area: Network protocol updates or fixes labels Oct 19, 2021
@teor2345 teor2345 added this to the 2021 Sprint 21 milestone Oct 19, 2021
@zfnd-bot zfnd-bot bot added this to To Do in 🦓 Oct 19, 2021
@teor2345 teor2345 removed I-slow Problems with performance or responsiveness I-heavy Problems with excessive memory, disk, or CPU usage C-bug Category: This is a bug A-rust Area: Updates to Rust code labels Oct 19, 2021
@teor2345 teor2345 changed the title Security: Limit the initial number of outbound connections from both seed and crawler Security: Limit the number of outbound connections from both seed and crawler peers Oct 19, 2021
@mpguerra
Copy link
Contributor

@teor2345 teor2345 changed the title Security: Limit the number of outbound connections from both seed and crawler peers Limit the initial crawler demand for outbound peers, based on seed peer connections Oct 25, 2021
@teor2345 teor2345 added P-Low and removed P-Medium C-security Category: Security issues I-remote-node-overload Zebra can overload other nodes on the network labels Oct 25, 2021
@teor2345
Copy link
Contributor Author

The implementation in PR #2944 covers the security issue here.

So this is now a much smaller cleanup ticket, rather than a security ticket.

@oxarbitrage oxarbitrage self-assigned this Oct 28, 2021
@mpguerra mpguerra removed the S-needs-triage Status: A bug report needs triage label Oct 29, 2021
🦓 automation moved this from To Do to Done Oct 29, 2021
@mpguerra mpguerra removed the S-blocked Status: Blocked on other tasks label Jan 24, 2022
mergify bot pushed a commit that referenced this issue May 23, 2023
* ZIPs were updated to remove ambiguity, this was tracked in #1267.

* #2105 was fixed by #3039 and #2379 was closed by #3069

* #2230 was a duplicate of #2231 which was closed by #2511

* #3235 was obsoleted by #2156 which was fixed by #3505

* #1850 was fixed by #2944, #1851 was fixed by #2961 and #2902 was fixed by #2969

* We migrated to Rust 2021 edition in Jan 2022 with #3332

* #1631 was closed as not needed

* #338 was fixed by #3040 and #1162 was fixed by #3067

* #2079 was fixed by #2445

* #4794 was fixed by #6122

* #1678 stopped being an issue

* #3151 was fixed by #3934

* #3204 was closed as not needed

* #1213 was fixed by #4586

* #1774 was closed as not needed

* #4633 was closed as not needed

* Clarify behaviour of difficulty spacing

Co-authored-by: teor <teor@riseup.net>

* Update comment to reflect implemented behaviour

Co-authored-by: teor <teor@riseup.net>

* Update comment to reflect implemented behaviour when retrying block downloads

Co-authored-by: teor <teor@riseup.net>

* Update `TODO` to remove closed issue and clarify when we might want to fix

Co-authored-by: teor <teor@riseup.net>

* Update `TODO` to remove closed issue and clarify what we might want to change in future

Co-authored-by: teor <teor@riseup.net>

* Clarify benefits of how we do block verification

Co-authored-by: teor <teor@riseup.net>

* Fix rustfmt errors

---------

Co-authored-by: teor <teor@riseup.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-network Area: Network protocol updates or fixes
Projects
No open projects
🦓
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants