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

validator-discovery: don't remove multiaddr of requested PeerIds #4036

Merged
26 commits merged into from Oct 8, 2021

Conversation

ordian
Copy link
Member

@ordian ordian commented Oct 7, 2021

An alternative to #4034.

Should help with improving validation peerset connectivity on kusama (#3877).

companion to paritytech/substrate#9964.

@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 Oct 7, 2021
@ordian ordian requested review from tomaka and eskimor October 7, 2021 17:01
@tomaka
Copy link
Contributor

tomaka commented Oct 7, 2021

This would disconnect the peers before they are re-added.

@ordian ordian added the D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit. label Oct 7, 2021
@ordian
Copy link
Member Author

ordian commented Oct 7, 2021

Ok, I'll rework it to be a companion to paritytech/substrate#9964 and do what you suggested.

@ordian ordian changed the title validator-discovery: remove from peer set before inserting validator-discovery: don't remove multiaddr of requested multiaddr Oct 7, 2021
@ordian ordian changed the title validator-discovery: don't remove multiaddr of requested multiaddr validator-discovery: don't remove multiaddr of requested PeerIds Oct 7, 2021
@ordian ordian added B7-runtimenoteworthy and removed B0-silent Changes should not be mentioned in any release notes labels Oct 7, 2021
@ordian ordian added B0-silent Changes should not be mentioned in any release notes B1-releasenotes and removed B7-runtimenoteworthy B0-silent Changes should not be mentioned in any release notes labels Oct 7, 2021
node/network/bridge/src/validator_discovery.rs Outdated Show resolved Hide resolved
Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>

let addr_to_remove: Vec<PeerId> =
state.previously_requested.difference(&new_peer_ids).cloned().collect();
let multiaddr_to_add: HashSet<_> = newly_requested
Copy link
Member

@eskimor eskimor Oct 8, 2021

Choose a reason for hiding this comment

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

This looks a bit hacky and inefficient. Also we will fail to add new addresses of a peer this way.

I think the cleanest solution would be to use set_reserved_peers with the full set and afterwards call the now changed remove_from_peers_set function to get rid of any dead peers.

Copy link
Member Author

Choose a reason for hiding this comment

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

If you're thinking set_reserved_peers is more efficient, it's not: https://github.com/paritytech/substrate/blob/0e220090f61233db76bb2f705849e1773b62498c/client/network/src/service.rs#L1102-L1131.

Also we will fail to add new addresses of a peer this way.

See e0bc56a

Copy link
Member

Choose a reason for hiding this comment

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

honestly, we should revisit that API at some point. The usage is proving to be pretty awkward. It should either be more low-level or more high-level. This mid-level, where we do the same stuff at the calling and at the called side makes no sense.

Copy link
Member Author

Choose a reason for hiding this comment

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

e352c2d is using set_reserved_peers

@ordian ordian added A4-companion A PR that needs a companion PR to merge in parallel for one of its downstream dependencies. and removed A0-please_review Pull request needs code review. labels Oct 8, 2021
@ordian ordian requested a review from eskimor October 8, 2021 11:53
ordian and others added 2 commits October 8, 2021 17:30
* master:
  Substrate companion for #9966 (#4037)
  Bump spec_versions (#4041)
  Remove bridges from checks (#4040)
@ghost
Copy link

ghost commented Oct 8, 2021

Waiting for commit status.

@ghost ghost merged commit c0d681c into master Oct 8, 2021
@ghost ghost deleted the ao-fix-connectivity-2 branch October 8, 2021 16:12
emostov pushed a commit that referenced this pull request Nov 1, 2021
…4036)

* validator-discovery: remove from peer set before inserting

* bump spec versions

* rework into a companion

* fmt

* fix

* fix

* one more time

* one more try

* one more try

* Revert "one more try"

This reverts commit ab6568d.

* one more try

* one more try

* Revert "one more try"

This reverts commit 8d7369f.

* fix a warning

* fix another warn

* correct log

* fix compilation

* ffs

* less cloning

* Apply suggestions from code review

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>

* add comments and a small refactoring

* use set_reserved_peers

* cargo update -p sp-io

* rename added to num_peers

* update Substrate

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
Co-authored-by: parity-processbot <>
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A4-companion A PR that needs a companion PR to merge in parallel for one of its downstream dependencies. C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants