Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Only take subset for assignment keys.
  • Loading branch information
eskimor committed Sep 8, 2021
commit 118b7465179d26fef31f07429ab50c12ccd317cc
7 changes: 5 additions & 2 deletions primitives/src/v1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -907,8 +907,11 @@ pub struct SessionInfo {
pub discovery_keys: Vec<AuthorityDiscoveryId>,
/// The assignment keys for validators.
///
/// NOTE: For assignment keys the same rule applies as for discovery keys. (First
/// `validators.len()` keys, will correspond to validators in `validators`.
/// NOTE: There might be more authorities in the current session, than validators participating
/// in parachain consensus. See
/// [max_validators](https://github.com/paritytech/polkadot/blob/a52dca2be7840b23c19c153cf7e110b1e3e475f8/runtime/parachains/src/configuration.rs#L148).
///
/// Therefore: assignment_keys.len() == validators.len() && validators.len() <= discovery_keys.len().
pub assignment_keys: Vec<AssignmentId>,
/// Validators in shuffled ordering - these are the validator groups as produced
/// by the `Scheduler` module for the session and are typically referred to by
Expand Down
13 changes: 9 additions & 4 deletions runtime/parachains/src/session_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

use crate::{
configuration, paras, scheduler, shared,
util::take_active_subset_and_inactive,
util::{take_active_subset, take_active_subset_and_inactive},
};
use frame_support::{pallet_prelude::*, traits::OneSessionHandler};
use primitives::v1::{AssignmentId, AuthorityDiscoveryId, SessionIndex, SessionInfo};
Expand Down Expand Up @@ -124,7 +124,7 @@ impl<T: Config> Pallet<T> {
let new_session_info = SessionInfo {
validators, // these are from the notification and are thus already correct.
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.

assignment_keys: take_active_subset_and_inactive(&active_set, &assignment_keys),
assignment_keys: take_active_subset(&active_set, &assignment_keys),
validator_groups,
n_cores,
zeroth_delay_tranche_width,
Expand Down Expand Up @@ -172,10 +172,15 @@ impl<T: pallet_session::Config + Config> OneSessionHandler<T::AccountId> for Pal
#[cfg(test)]
mod tests {
use super::*;
use crate::{configuration::HostConfiguration, initializer::SessionChangeNotification, mock::{
use crate::{
configuration::HostConfiguration,
initializer::SessionChangeNotification,
mock::{
new_test_ext, Configuration, MockGenesisConfig, Origin, ParasShared, SessionInfo,
System, Test,
}, util::take_active_subset};
},
util::take_active_subset,
};
use keyring::Sr25519Keyring;
use primitives::v1::{BlockNumber, ValidatorId, ValidatorIndex};

Expand Down