-
Notifications
You must be signed in to change notification settings - Fork 1.6k
gossip: do not try to connect if we are not validators #2786
gossip: do not try to connect if we are not validators #2786
Conversation
To confirm - regular nodes not in the validator set will still connect to other nodes via discovery (in_peers)? Otherwise, we should add a few out_peers to ensure that the gossip graph reaches all full nodes interested in the validation protocol. |
We have only two places of issuing connection requests for the validation peerset, it's not happening via discovery:
Full nodes won't issue connection requests via availability distribution, since we try to find our validator index first. And after this PR is merge they won't issue it via gossip support either. Not sure whether we need to bump |
Actually I realized we don't need to issue requests in availability distribution anymore. |
// we want our gossip subset to always include reserved peers | ||
in_peers: super::MIN_GOSSIP_PEERS as u32 / 2, | ||
out_peers: 0, | ||
// we allow full nodes to connect to validators for gossip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be worthwhile to extend this comment to also note that block authors will also not be considered parachain validators in the case that the maximum number of validators participating in parachain validation is limited.
Although...due to https://github.com/paritytech/polkadot/blob/master/runtime/parachains/src/runtime_api_impl/v1.rs#L243 we currently include all of the next authority IDs (even beyond max_validators
) which are most likely the same as current-session.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's exactly the motivation for using authorities api instead of session_info
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mind adding some of that info to the comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, do we actually want to add all validators to the validation reserved peerset or just the ones participating in the parachain validation? If we add all, then we can set it to reserved only, no? @eskimor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ordian We had this discussion earlier today, and I believe the outcome was:
- Connect to parachain validators of the last N sessions
- Connect to all validators of the current session so block authors are included too.
Technically we don't need to include block authors as they should be reachable by in_peers
and out_peers
, but this ensures they're only one hop away.
We don't want to set it to reserved-only as full nodes should still have access to the information gossiped
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically we don't need to include block authors as they should be reachable by
in_peers
andout_peers
, but this ensures they're only one hop away.
We can not rely on that, peer sets can easily get filled either maliciously or by accident. We also don't punish inactive peers, so that's a really cheap attack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copying my DM from Element:
here's my understanding of what we want
- a non-degenerate graph of all validators with a clique of parachain validators, although the latter part is optional
- for disputes we want parachain validators of some previous sessions
We could make e.g. statement distribution and disputes use a separate peerset each and set reserved validation to only parachain validators.
But for now, using authorities is fine I think.
By using AuthorityDiscoveryApi::authorities we will set reserved peerset to a superset of that, but as you mentioned that's mostly two validator groups, also this will ensure we're potentially connected to validators in the next session in advance, which is nice
let validators = determine_relevant_validators(ctx, relay_parent, new_session).await?; | ||
tracing::debug!(target: LOG_TARGET, num = ?validators.len(), "Issuing a connection request"); | ||
let authorities = determine_relevant_authorities(client.clone(), relay_parent).await?; | ||
ensure_i_am_an_authority(keystore, &authorities).await?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, so block authors pass this check too. Seems fine to me
* gossip: do not issue a connection request if we are not a validator * guide updates * use all relevant authorities when issuing a request * use AuthorityDiscoveryApi instead * update comments to the status quo
See #2776 (comment).