-
Notifications
You must be signed in to change notification settings - Fork 106
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 number of outbound peer connections #2944
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just added some minor questions/nit-picks.
8ec9c93
to
6188022
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@conradoplg here are some notes on testing.
You might need the task starvation fixes in 5d245cf to avoid test hangs.
(Commit name: Avoid cooperative async task starvation...)
And you might need the new Config
methods in 0b5f82e.
(Bias Zebra towards outbound connections.)
This comment has been minimized.
This comment has been minimized.
6188022
to
e51afcb
Compare
And turn connection limits into `Config` methods.
Includes: - `fastmod OUTBOUND_PEER_BIAS_FRACTION OUTBOUND_PEER_BIAS_DENOMINATOR zebra*` - clarify connection limit documentation
If we don't yield in these loops, they can run for a long time before tokio forces them to yield.
And use the multi-threaded runtime to avoid long hangs.
Adds yields after inbound successes and initial peer connections.
e51afcb
to
4315699
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good and suggestions from @jvff were applied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. The tests are very similar to the ones in #2961 (or maybe it should be the other way round 😅 ), so some review comments from there might also be useful here.
But we can merge as is and take a look at improving all of them later 👍
* 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>
Motivation
We want to limit Zebra's outbound peer connections to avoid whole-of-network denial of service attacks.
Solution
Implementation:
config.peerset_initial_target_size
Bug fixes:
Unit tests:
Runtime checks:
Local tests:
Closes #1850.
Review
@jvff is a good person to review this PR.
Reviewer Checklist