Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Split Peerset into reputation store & ProtocolControllers #13611

Merged
merged 106 commits into from
May 23, 2023

Conversation

dmitry-markin
Copy link
Contributor

@dmitry-markin dmitry-markin commented Mar 15, 2023

The connection logic (connect/drop/accept/reject) is extracted from Peerset into ProtocolController and PeerStore. Each ProtocolController instance is responsible for a specific notifications protocol, and should allow customization of connection logic by protocols in the future. PeerStore is responsible for connection candidates and peer reputations.

Resolves #13531.

@dmitry-markin dmitry-markin added the A3-in_progress Pull request is in progress. No review needed at this stage. label Mar 15, 2023
Copy link
Contributor

@altonen altonen left a comment

Choose a reason for hiding this comment

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

Did a first pass. There are some problems we need to address, especially regarding Peer. I hope we can get rid of it and just match on peer state and then perform the correct action.

client/peerset/src/protocol_controller.rs Outdated Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Outdated Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Outdated Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Outdated Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Outdated Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Outdated Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Outdated Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@altonen altonen left a comment

Choose a reason for hiding this comment

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

I think this is going in the right direction. Some of code duplication should be removed if possible

client/peerset/src/protocol_controller.rs Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Outdated Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Outdated Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Outdated Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Outdated Show resolved Hide resolved
Co-authored-by: Aaro Altonen <48052676+altonen@users.noreply.github.com>
@dmitry-markin dmitry-markin added B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. labels Mar 17, 2023
@dmitry-markin dmitry-markin requested a review from a team March 17, 2023 12:24
@dmitry-markin
Copy link
Contributor Author

@altonen I've reworked peer management using ideas from your prototype. Apart from a couple of places where I had to call self.peerset_handle.is_banned() instead of self.is_banned(), borrowing issues are gone. Implementation of alloc_slots() feels sub-optimal, but that's likely an inevitable consequence of separating peer reputation values and connection handling.

Copy link
Contributor

@altonen altonen left a comment

Choose a reason for hiding this comment

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

I think this is looking good already. alloc_slots() can be improved but could you write some tests to confirm this implementation works as expected?

client/peerset/src/protocol_controller.rs Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Outdated Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Outdated Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Outdated Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Outdated Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Outdated Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Outdated Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Outdated Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Outdated Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Outdated Show resolved Hide resolved
@dmitry-markin
Copy link
Contributor Author

dmitry-markin commented Mar 20, 2023

... could you write some tests to confirm this implementation works as expected?

Sure, that was my plan.

@dmitry-markin
Copy link
Contributor Author

dmitry-markin commented May 16, 2023

The PR is ready for review. Relaxing requirements on possible messages in Notifications a little more allowed to get rid of ACKing, preserving the eventual consistency of peer views in ProtocolController and Notifications.

@dmitry-markin
Copy link
Contributor Author

We definitely need a burn-in for this PR.

@altonen
Copy link
Contributor

altonen commented May 16, 2023

We definitely need a burn-in for this PR.

Versi burn-in would be nice

Copy link
Contributor

@altonen altonen left a comment

Choose a reason for hiding this comment

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

LGTM but let's merge it only after the burn-in is done

client/peerset/src/lib.rs Show resolved Hide resolved
client/peerset/src/lib.rs Outdated Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Show resolved Hide resolved
@altonen altonen requested a review from a team May 16, 2023 10:48
Copy link
Contributor

@melekes melekes left a comment

Choose a reason for hiding this comment

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

client/network/src/service/traits.rs Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Outdated Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Outdated Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Outdated Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Outdated Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Show resolved Hide resolved
client/peerset/src/protocol_controller.rs Show resolved Hide resolved
@dmitry-markin dmitry-markin requested a review from a team May 22, 2023 11:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D2-breaksapi
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Refactoring: prepare Peerset for moving connection establishment logic to protocol handlers
3 participants