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

feat: broadcast size should not be capped for newly connected neighbors #3367

Merged
merged 4 commits into from Oct 12, 2022

Conversation

istae
Copy link
Member

@istae istae commented Oct 3, 2022

Checklist

  • I have read the coding guide.
  • My change requires a documentation update, and I have done it.
  • I have added tests to cover my changes.
  • I have filled out the description and linked the related issues.

Description

Kademlia randomly picks 4 peers from each bin to broadcast when a new connection is made. If the connected peer is a neighbor, however, the broadcast peer size should not be capped.

Open API Spec Version Changes (if applicable)

Motivation and Context (Optional)

Related Issue (Optional)

Screenshots (if appropriate):


This change is Reviewable

@istae istae requested review from a team, vladopajic and metacertain and removed request for a team October 3, 2022 09:39
@istae istae changed the title Broadcast neighbors feat: broadcast size should not be capped for newly connected neighbors Oct 3, 2022
@istae istae added the ready for review The PR is ready to be reviewed label Oct 3, 2022
Copy link
Contributor

@aloknerurkar aloknerurkar left a comment

Choose a reason for hiding this comment

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

I don't think this is a good idea. This will exponentially increase the no. of protocol messages in the network. Each neighbor on getting the new peer will again be broadcasting to all the neighborhood. This will lead to a lot of duplicate broadcasts.

In order to test this, we should simulate peers connecting/disconnecting in the load test cluster and observe how much this affects the protocol messages for hive.

@istae
Copy link
Member Author

istae commented Oct 3, 2022

I don't think this is a good idea. This will exponentially increase the no. of protocol messages in the network. Each neighbor on getting the new peer will again be broadcasting to all the neighborhood. This will lead to a lot of duplicate broadcasts.

In order to test this, we should simulate peers connecting/disconnecting in the load test cluster and observe how much this affects the protocol messages for hive.

We have an out/in rate limiter in hive so it's okay :) Hive relative to the other protocols has a very small footprint.

Plus neighborhoods are small so we should not limit the peer count when announcing them to the new neighbor.
We are talking like maybe +5 peers more announced with the change.

@aloknerurkar
Copy link
Contributor

We have an out/in rate limiter in hive so it's okay :) Hive relative to the other protocols has a very small footprint.

Plus neighborhoods are small so we should not limit the peer count when announcing them to the new neighbor. We are talking like maybe +5 peers more announced with the change.

We need to test and verify all the assumptions here. We can have bunch of other problems even if we rate-limit like blocklisting/libp2p stream related problems etc.

@istae
Copy link
Member Author

istae commented Oct 3, 2022

We have an out/in rate limiter in hive so it's okay :) Hive relative to the other protocols has a very small footprint.
Plus neighborhoods are small so we should not limit the peer count when announcing them to the new neighbor. We are talking like maybe +5 peers more announced with the change.

We need to test and verify all the assumptions here. We can have bunch of other problems even if we rate-limit like blocklisting/libp2p stream related problems etc.

I feel that we are blowing out the proportions of this change significantly....we literally have an out limiter that blocks us from sending more than 128 peers a minute.

I appreciate the cautious approach, but it's a bit crippling.

@aloknerurkar
Copy link
Contributor

I feel that we are blowing out the proportions of this change significantly....we literally have an out limiter that blocks us from sending more than 128 peers a minute.

I appreciate the cautious approach, but it's a bit crippling.

So I dont think this is that simple of a change. This change affects the no of protocol messages nodes will exchange. This is very significant according to me as this can break the network if something goes wrong.

Also, I dont see why we need this change. Kademlia build-up is not a problem, has never been. With the libp2p changes coming in, I would prefer if we are extra cautious. This is known to cause issues due to more streams etc which is what will happen.

@istae
Copy link
Member Author

istae commented Oct 4, 2022

For correctness sake, a newly connected neighbor should receive a full list of connected neighbors.

Copy link
Member

@metacertain metacertain left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +1650 to +1661
t.Parallel()

defer func(p int) {
*kademlia.SaturationPeers = p
}(*kademlia.SaturationPeers)
*kademlia.SaturationPeers = 4

defer func(p int) {
*kademlia.OverSaturationPeers = p
}(*kademlia.OverSaturationPeers)
*kademlia.OverSaturationPeers = 4

Copy link
Contributor

Choose a reason for hiding this comment

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

Test which modify global variables shouldn't be executed in parallel because race condition may occur in which case one test function (executed in parallel) my affect expected variable of another test function.

PR #3360 fixes hacky usage of global variables in kadeemlia (which makes possible for test to execute in parallel).

Copy link
Member Author

Choose a reason for hiding this comment

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

@vladopajic Let's merge this, then can you also take a look at this test since your PR takes care of the global variables.

@istae istae merged commit 02c2f25 into master Oct 12, 2022
@istae istae deleted the broadcast-neighbors branch October 12, 2022 09:31
@aloknerurkar aloknerurkar added this to the 1.10.0 milestone Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pull-request ready for review The PR is ready to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants