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

Put all authorities of a session into SessionInfo. #3813

Merged
merged 9 commits into from
Sep 14, 2021

Conversation

eskimor
Copy link
Member

@eskimor eskimor commented Sep 8, 2021

Authorities are not limited to parachain consensus, thus we should have access to all authorities for a given session, even with max_validators set.

This change fixes dispute distribution, which needs to know the authorities of the current session, so it can make sure the block producer will see its votes.

I checked the code base, apart from dispute distribution no subsystems should be affected by this change.

Fixes: #3653

@eskimor eskimor 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. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit. labels Sep 8, 2021
primitives/src/v1/mod.rs Outdated Show resolved Hide resolved
@@ -120,7 +123,7 @@ impl<T: Config> Pallet<T> {
// create a new entry in `Sessions` with information about the current session
let new_session_info = SessionInfo {
validators, // these are from the notification and are thus already correct.
discovery_keys: take_active_subset(&active_set, &discovery_keys),
discovery_keys: take_active_subset_and_inactive(&active_set, &discovery_keys),
Copy link
Contributor

Choose a reason for hiding this comment

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

This only seems to alter the discovery keys

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that's on purpose. We do have more authorities than parachain validators, but only parachain validators will be approval checkers, thus limiting assignment keys seems to be desired.

@rphmeier
Copy link
Contributor

rphmeier commented Sep 8, 2021

Any implementer's guide changes needed?

@eskimor
Copy link
Member Author

eskimor commented Sep 9, 2021

Any implementer's guide changes needed?

Haven't found any places that would need adaption.

@ordian
Copy link
Member

ordian commented Sep 9, 2021

@eskimor
Copy link
Member Author

eskimor commented Sep 9, 2021

Yeah ok - the comments there can be updated as well. Will do!

Copy link
Member

@ordian ordian left a comment

Choose a reason for hiding this comment

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

LGTM.

We used to map AuthorityDiscoveryId to ValidatorId by index, but I can't find that code anymore. I think we only map the other way around now. But maybe there are some external tools (e.g. block explorers) that make some assumptions about their length. We should somehow communicate that.

@eskimor eskimor added B1-releasenotes and removed B0-silent Changes should not be mentioned in any release notes labels Sep 9, 2021
Copy link
Contributor

@drahnr drahnr left a comment

Choose a reason for hiding this comment

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

Few nits, LGTM

/// in parachain consensus. See
/// [`max_validators`](https://github.com/paritytech/polkadot/blob/a52dca2be7840b23c19c153cf7e110b1e3e475f8/runtime/parachains/src/configuration.rs#L148).
///
/// `SessionInfo::validators` will be limited to to `max_validators` when set.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// `SessionInfo::validators` will be limited to to `max_validators` when set.
/// `SessionInfo::validators` will be limited to `max_validators` when set.

let subset: Vec<_> = active_validators
/// Take an active subset of a set containing all validators.
///
/// First item in pair will be all items in set have indeces found in the `active` indices set (in
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// First item in pair will be all items in set have indeces found in the `active` indices set (in
/// First item in pair will be all items in set have indices found in the `active` indices set (in

Comment on lines +77 to +79
let (mut a, mut i) = split_active_subset(active, all);
a.append(&mut i);
a
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: iiuc is only done, to assure that the acitve validators occupy the indices 0..n, correct? Would be nice to state this in the comment and/or the fn-name

@eskimor eskimor merged commit 143a308 into master Sep 14, 2021
@eskimor eskimor deleted the rk-fix-wrong-authority-set branch September 14, 2021 11:58
eskimor added a commit that referenced this pull request Sep 14, 2021
eskimor added a commit that referenced this pull request Sep 14, 2021
ordian added a commit that referenced this pull request Sep 15, 2021
* master: (21 commits)
  Add build with docker info to README (#3843)
  improve approval tracing (#3846)
  UMP: Support Overweight messages (#3575)
  Companion for substrate#9115 (#3265)
  Better error messages. (#3835)
  Put all authorities of a session into `SessionInfo`. (#3813)
  Bump tracing from 0.1.26 to 0.1.27 (#3841)
  Companion for substrate#9711 (#3801)
  fix complaints in CI (#3838)
  dockerfiles: upgrade to ubuntu:20.04; some chore (#3828)
  make polkadot-runtime optional feature (#3820)
  Companion for #9648 (#3757)
  Substrate Companion #9737 (#3830)
  Add logging for worker spawn failures (#3827)
  Add Canvas (#3823)
  Allow staking miner to use different election algorithms (#3752)
  Do not expire HRMP open channel requests (#3543)
  Bump tokio from 1.10.1 to 1.11.0 (#3821)
  Add words to the dictionnary (#3819)
  Add vault secrets to puplish-rustdoc job (#3816)
  ...
eskimor added a commit that referenced this pull request Sep 16, 2021
ordian added a commit that referenced this pull request Sep 16, 2021
* master:
  Raised nits on #3813 (#3844)
  Don't try to connect to ourselves. (#3855)
  add dispute metrics, some chores (#3842)
  add type info derive to senderror (#3860)
  Companion for #8615: enrich metadata with type information (#3336)
  approval-voting: processed wakeups can also update approval state (#3848)
  Add build with docker info to README (#3843)
  improve approval tracing (#3846)
  UMP: Support Overweight messages (#3575)
  Companion for substrate#9115 (#3265)
  Better error messages. (#3835)
  Put all authorities of a session into `SessionInfo`. (#3813)
  Bump tracing from 0.1.26 to 0.1.27 (#3841)
  Companion for substrate#9711 (#3801)
  fix complaints in CI (#3838)
ordian added a commit that referenced this pull request Sep 17, 2021
* master:
  Raised nits on #3813 (#3844)
  Don't try to connect to ourselves. (#3855)
  add dispute metrics, some chores (#3842)
  add type info derive to senderror (#3860)
  Companion for #8615: enrich metadata with type information (#3336)
  approval-voting: processed wakeups can also update approval state (#3848)
  Add build with docker info to README (#3843)
  improve approval tracing (#3846)
  UMP: Support Overweight messages (#3575)
  Companion for substrate#9115 (#3265)
  Better error messages. (#3835)
  Put all authorities of a session into `SessionInfo`. (#3813)
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. 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.

Dispute distribution uses wrong authority set
4 participants