Skip to content

Conversation

@ImplOfAnImpl
Copy link
Contributor

@ImplOfAnImpl ImplOfAnImpl commented Sep 14, 2023

This fixes #664 (note that as we've discussed earlier, the solution proposed in the issue itself is redundant; using a bounded channel for peer events should be enough).

P.S. I've based this PR on top of #1183 to simplify merging.

Base automatically changed from p2p_protocol_v2 to master September 15, 2023 08:55
@TheQuantumPhysicist
Copy link
Contributor

Please fix the minor issues I mentioned then we'll go ahead and merge.

@ImplOfAnImpl ImplOfAnImpl marked this pull request as draft September 15, 2023 11:15
@ImplOfAnImpl ImplOfAnImpl force-pushed the use_bounded_channels_for_peer_events branch from 9de5513 to b2e9122 Compare September 18, 2023 17:55
@ImplOfAnImpl ImplOfAnImpl marked this pull request as ready for review September 18, 2023 18:11
@iljakuklic
Copy link
Contributor

Just noticed that StreamMap stores the channels in a Vec and polls them in order defined by the order of elements in the vec. This may give some peers advantage over others. For example the first connection will be in the first position and, as far as I can see, will stay there until disconnected.

Do we want to address this? Is it possible to periodically shuffle the elements or something like that?

@ImplOfAnImpl
Copy link
Contributor Author

Just noticed that StreamMap stores the channels in a Vec and polls them in order defined by the order of elements in the vec. This may give some peers advantage over others. For example the first connection will be in the first position and, as far as I can see, will stay there until disconnected.

Do we want to address this? Is it possible to periodically shuffle the elements or something like that?

As far as I can see, StreamMap::poll_next_entry chooses starting index randomly, so this should not be a problem.

@iljakuklic
Copy link
Contributor

As far as I can see, StreamMap::poll_next_entry chooses starting index randomly, so this should not be a problem.

Ok, good. Thanks for finding out.

@ImplOfAnImpl ImplOfAnImpl merged commit b7f0b1d into master Sep 20, 2023
@ImplOfAnImpl ImplOfAnImpl deleted the use_bounded_channels_for_peer_events branch September 20, 2023 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unbounded channels and DoS attacks

5 participants