mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-23 15:25:49 +00:00
Remove footgun around session keys/handlers (#3949)
* Remove footgun around session keys/handlers - `OpaqueKeys` now has an associated type `KeyTypeIdProviders`. This can be used in the runtime as input for `SessionHandler` from the session trait. - `impl_opaque_keys` now works with modules and extracts the `KeyTypeId` from the module directly. - Added some checks to the `session` storage initialization that checks that the `SessionHandler` and `Keys` use the same number of keys and that the order is equal. * Update core/sr-primitives/src/traits.rs
This commit is contained in:
@@ -107,6 +107,10 @@ impl<T: Trait> Module<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait> sr_primitives::BoundToRuntimeAppPublic for Module<T> {
|
||||
type Public = T::AuthorityId;
|
||||
}
|
||||
|
||||
impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
|
||||
type Key = T::AuthorityId;
|
||||
|
||||
@@ -139,7 +143,7 @@ mod tests {
|
||||
use runtime_io::TestExternalities;
|
||||
use sr_primitives::{
|
||||
testing::{Header, UintAuthorityId}, traits::{ConvertInto, IdentityLookup, OpaqueKeys},
|
||||
Perbill,
|
||||
Perbill, KeyTypeId,
|
||||
};
|
||||
use support::{impl_outer_origin, parameter_types};
|
||||
|
||||
@@ -218,6 +222,8 @@ mod tests {
|
||||
|
||||
pub struct TestSessionHandler;
|
||||
impl session::SessionHandler<AuthorityId> for TestSessionHandler {
|
||||
const KEY_TYPE_IDS: &'static [KeyTypeId] = &[key_types::DUMMY];
|
||||
|
||||
fn on_new_session<Ks: OpaqueKeys>(
|
||||
_changed: bool,
|
||||
_validators: &[(AuthorityId, Ks)],
|
||||
|
||||
Reference in New Issue
Block a user