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-address: Add get group function. #217

Closed
wants to merge 3 commits into from

Conversation

kilpatty
Copy link
Contributor

@kilpatty kilpatty commented Jul 6, 2019

This commit adds the getGroup function to net addresses. It allows for
network addresses to be grouped into buckets, such that we can limit the
number of outgoing connections per group to a certain amount. This will
allow for increased connection diversity and reduced attack surface
area.

TODO:

@kilpatty kilpatty changed the title net-address: Add get group function. WIP: net-address: Add get group function. Jul 6, 2019
@codecov-io
Copy link

codecov-io commented Jul 6, 2019

Codecov Report

Merging #217 into master will increase coverage by 0.07%.
The diff coverage is 92.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #217      +/-   ##
==========================================
+ Coverage   52.99%   53.06%   +0.07%     
==========================================
  Files         129      129              
  Lines       35773    35829      +56     
  Branches     6032     6046      +14     
==========================================
+ Hits        18957    19013      +56     
  Misses      16816    16816
Impacted Files Coverage Δ
lib/net/netaddress.js 72.3% <100%> (+10.71%) ⬆️
lib/net/pool.js 24.23% <42.85%> (+0.05%) ⬆️
lib/covenants/rules.js 73.04% <0%> (-0.15%) ⬇️
lib/script/script.js 58% <0%> (+0.07%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cc1ef7a...10b3b2f. Read the comment docs.

@kilpatty kilpatty force-pushed the add-group-netaddress branch 2 times, most recently from 46b9b01 to ddf5844 Compare July 6, 2019 16:39
This commit adds the getGroup function to net addresses. It allows for
network addresses to be grouped into buckets, such that we can limit the
number of outgoing connections per group to a certain amount. This will
allow for increased connection diversity and reduced attack surface
area.
This commit checks the outbound peers to see which group their network
addresses lives in before connecting. By doing this, we prevent a node
from connecting to all outbound addresses in a very close network group
bunch. This helps prevent someone spinning up multiple nodes on a
similar network e.g. AWS, GCP and using those to fill other nodes'
outbounds.

This commit just adds 2 operations in both addOutbound and addLoader. It
first checks if the new address pull from hostlist belongs in the same
group as an already connected peer. If it does not, it precedes as
usual, and if the connection succeeds then it adds that new outbound
group to the list of groups currently connected to.
@kilpatty
Copy link
Contributor Author

kilpatty commented Jul 6, 2019

Note to self: It'd be great to get a test case ensuring that we aren't adding 2 peers from the same group to outbound. I think it would be a good fit for when someone ports over the bcoin net tests. See: #197

@kilpatty kilpatty changed the title WIP: net-address: Add get group function. net-address: Add get group function. Jul 6, 2019
@tynes
Copy link
Contributor

tynes commented Dec 13, 2019

Note to self: It'd be great to get a test case ensuring that we aren't adding 2 peers from the same group to outbound. I think it would be a good fit for when someone ports over the bcoin net tests. See: #197

#197 has been closed, it would be ideal to have an issue to track this. Is there any additional information you would like to be in the issue?

@kilpatty
Copy link
Contributor Author

@tynes I can open one here

@tynes
Copy link
Contributor

tynes commented Dec 13, 2019

Having this merged would be very helpful for the experimental testnet as we are noticing some strange connectivity problems between nodes on the network.

It depends on bcoin-org/binet pull requests here:
https://github.com/bcoin-org/binet/pulls

The plan is to review and merge it here:
https://github.com/Handshake-Protocol/binet/pulls
https://github.com/Handshake-Protocol/hsd/pull/1

startByte = 6;
bits = 4;
// for he.net, use /36 groups
} else if (
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this would read a lot better if it was a function

let startByte = 0;
let bits = 16;

// all local addresses belong to the same group
Copy link
Contributor

Choose a reason for hiding this comment

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

Style nit: generally start comments with a capital letter and end with a period

@kilpatty
Copy link
Contributor Author

kilpatty commented Mar 4, 2020

@chjj Want me to kill this now with the most recent changes?

@nodech nodech added breaking-minor Backwards compatible - Release version feature general - adding feature net/p2p part of the codebase takeover Stale PRs. labels Dec 10, 2021
@nodech nodech self-assigned this Feb 24, 2022
@nodech nodech mentioned this pull request Feb 24, 2022
@nodech
Copy link
Contributor

nodech commented Apr 7, 2022

Merged in 6213460 from #692.

@nodech nodech closed this Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-minor Backwards compatible - Release version feature general - adding feature net/p2p part of the codebase takeover Stale PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants