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

validator_discovery: less flexible, but simpler design #3052

Merged
merged 5 commits into from
May 19, 2021

Conversation

ordian
Copy link
Member

@ordian ordian commented May 18, 2021

This PR implement and alternative design for validator discovery mentioned in #3035 (comment). As a bonus, it makes #3035 simpler to implement.

Instead of doing reference counting, we assume that the request contains the full list of peers all subsystems are interested in (per PeerSet). This is less flexible, but much simpler and hence less prone to bugs like #3038.

@ordian ordian added 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. labels May 18, 2021
@ordian ordian requested a review from eskimor May 18, 2021 18:09
@ordian
Copy link
Member Author

ordian commented May 18, 2021

investigating why adder-collator test if failing

@ordian ordian marked this pull request as draft May 18, 2021 22:34
Copy link
Member

@eskimor eskimor left a comment

Choose a reason for hiding this comment

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

I liked the formerly modular subsystem independent approach, but as it was only half baked anyway (subsystems would not have received PeerConnected events if another subsystem had issued connection requests earlier) and we don't need that modularity right now anyway, I think it is a fine simplification.

node/network/bridge/src/validator_discovery.rs Outdated Show resolved Hide resolved
@ordian
Copy link
Member Author

ordian commented May 19, 2021

subsystems would not have received PeerConnected events if another subsystem had issued connection requests earlier)

Do you mean that subsystem A would issue a connection request before subsystem B even started? I don't think that was the case in practice, because A would have to wait for the first ActiveLeavesUpdate, by which time subsystem B should've started already. Also the PeerConnected event should be propagated to all interested subsystems from the bridge (dispatch_validation_event_to_all).

@eskimor
Copy link
Member

eskimor commented May 19, 2021

It is definitely not an issue in practice. Just conceptually, if one subsystem issues connection requests later than another one, it would miss out on PeerConnected events, if it ignored it before it issued the connection request - for example. Or imagine a task that is started for some block, to track some stuff for a while and it issues a connection request - it would miss out on PeerConnected events if the connection was established already.

Either way all of this no longer matters with this simplification as we now rely on a single source of connection requests.

@ordian
Copy link
Member Author

ordian commented May 19, 2021

#3055 explains the failing test 😅

* master:
  Actually connect to new validators at session boundary. (#3055)
  Register ReadRuntimeVersionExt (#3045)
  Bump version & spec version in prep for v0.9.2 (#3046)
  Remove host configuration set migration from Kusama & Westend (#3050)
@ordian ordian marked this pull request as ready for review May 19, 2021 12:26
Copy link
Contributor

@tomaka tomaka left a comment

Choose a reason for hiding this comment

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

validator_discovery.rs looks good to me

Note that sc-network also provides set_reserved_peers that does the same thing 😅
EDIT: the peerset contains the appropriate logic, but it's actually not exposed in the public API of sc-network

@eskimor
Copy link
Member

eskimor commented May 19, 2021

Note that sc-network also provides set_reserved_peers that does the same thing sweat_smile

LOL, ok I think we should use that then. At least in a follow up.

@ordian
Copy link
Member Author

ordian commented May 19, 2021

Note that sc-network also provides set_reserved_peers that does the same thing

yeah, I think it's not exposed on NetworkService, also most of the time the deltas will be empty, so I decided to keep it as is for now

@ordian ordian merged commit d1a2eff into master May 19, 2021
@ordian ordian deleted the ao-alternative-validator-discovery-design branch May 19, 2021 16:54
ordian added a commit that referenced this pull request May 19, 2021
* master:
  validator_discovery: less flexible, but simpler design (#3052)
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants