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

Commit

Permalink
session_info: add dispute_period and random_seed
Browse files Browse the repository at this point in the history
  • Loading branch information
ordian committed Dec 16, 2021
1 parent 0b3ae56 commit 50333db
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions node/core/approval-voting/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,8 @@ pub(crate) mod tests {
no_show_slots: index as _,
needed_approvals: index as _,
active_validator_indices: Vec::new(),
dispute_period: 6,
random_seed: [0u8; 32],
}
}

Expand Down Expand Up @@ -1142,6 +1144,8 @@ pub(crate) mod tests {
n_delay_tranches: irrelevant,
no_show_slots: irrelevant,
active_validator_indices: Vec::new(),
dispute_period: 6,
random_seed: [0u8; 32],
};

let slot = Slot::from(10);
Expand Down
2 changes: 2 additions & 0 deletions node/core/approval-voting/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,8 @@ fn session_info(keys: &[Sr25519Keyring]) -> SessionInfo {
n_delay_tranches: 50,
no_show_slots: 2,
active_validator_indices: vec![],
dispute_period: 6,
random_seed: [0u8; 32],
}
}

Expand Down
2 changes: 2 additions & 0 deletions node/core/dispute-coordinator/src/real/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ impl TestState {
no_show_slots: 1,
needed_approvals: 10,
active_validator_indices: Vec::new(),
dispute_period: 6,
random_seed: [0u8; 32],
}
}

Expand Down
2 changes: 2 additions & 0 deletions node/core/runtime-api/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,8 @@ fn dummy_session_info() -> SessionInfo {
no_show_slots: 0u32,
needed_approvals: 1u32,
active_validator_indices: vec![],
dispute_period: 6,
random_seed: [0u8; 32],
}
}
#[test]
Expand Down
2 changes: 2 additions & 0 deletions node/network/availability-distribution/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ pub fn make_session_info() -> SessionInfo {
no_show_slots: 0,
needed_approvals: 0,
active_validator_indices: Vec::new(),
dispute_period: 6,
random_seed: [0u8; 32],
}
}

Expand Down
2 changes: 2 additions & 0 deletions node/network/availability-recovery/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ impl TestState {
no_show_slots: 0,
needed_approvals: 0,
active_validator_indices: vec![],
dispute_period: 6,
random_seed: [0u8; 32],
}))).unwrap();
}
);
Expand Down
2 changes: 2 additions & 0 deletions node/network/collator-protocol/src/collator_side/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ impl Default for TestState {
no_show_slots: 0,
needed_approvals: 0,
active_validator_indices: vec![],
dispute_period: 6,
random_seed: [0u8; 32],
},
group_rotation_info,
validator_peer_id,
Expand Down
4 changes: 4 additions & 0 deletions node/network/dispute-distribution/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ pub static ref MOCK_SESSION_INFO: SessionInfo =
no_show_slots: 0,
needed_approvals: 0,
active_validator_indices: vec![],
dispute_period: 6,
random_seed: [0u8; 32],
};

/// `SessionInfo` for the second session. (No more validators, but two more authorities.
Expand All @@ -107,6 +109,8 @@ pub static ref MOCK_NEXT_SESSION_INFO: SessionInfo =
no_show_slots: 0,
needed_approvals: 0,
active_validator_indices: vec![],
dispute_period: 6,
random_seed: [0u8; 32],
};
}

Expand Down
2 changes: 2 additions & 0 deletions node/network/statement-distribution/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1852,5 +1852,7 @@ fn make_session_info(validators: Vec<Pair>, groups: Vec<Vec<u32>>) -> SessionInf
no_show_slots: 0,
needed_approvals: 0,
active_validator_indices: Vec::new(),
dispute_period: 6,
random_seed: [0u8; 32],
}
}
2 changes: 2 additions & 0 deletions node/subsystem-util/src/rolling_session_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ mod tests {
no_show_slots: index as _,
needed_approvals: index as _,
active_validator_indices: Vec::new(),
dispute_period: 6,
random_seed: [0u8; 32],
}
}

Expand Down
6 changes: 6 additions & 0 deletions primitives/src/v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ pub struct SessionInfo {
/// All the validators actively participating in parachain consensus.
/// Indices are into the broader validator set.
pub active_validator_indices: Vec<ValidatorIndex>,
/// A secure random seed for the session, gathered from BABE.
pub random_seed: [u8; 32],
/// The amount of sessions to keep for disputes.
pub dispute_period: SessionIndex,

/****** Old fields ******/
/// Validators in canonical ordering.
Expand Down Expand Up @@ -87,6 +91,8 @@ impl From<v1SessionInfo> for SessionInfo {
SessionInfo {
// new fields
active_validator_indices: Vec::new(),
random_seed: [0u8; 32],
dispute_period: 6,
// old fields
validators: old.validators,
discovery_keys: old.discovery_keys,
Expand Down
3 changes: 3 additions & 0 deletions runtime/parachains/src/session_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ impl<T: Config> Pallet<T> {
let needed_approvals = config.needed_approvals;

let new_session_index = notification.session_index;
let random_seed = notification.random_seed;
let old_earliest_stored_session = EarliestStoredSession::<T>::get();
let new_earliest_stored_session = new_session_index.saturating_sub(dispute_period);
let new_earliest_stored_session =
Expand Down Expand Up @@ -144,6 +145,8 @@ impl<T: Config> Pallet<T> {
no_show_slots,
needed_approvals,
active_validator_indices: active_set,
random_seed,
dispute_period,
};
Sessions::<T>::insert(&new_session_index, &new_session_info);
}
Expand Down

0 comments on commit 50333db

Please sign in to comment.