Skip to content
1 change: 0 additions & 1 deletion cumulus/pallets/collator-selection/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use super::*;
#[allow(unused)]
use crate::Pallet as CollatorSelection;
use alloc::vec::Vec;
use codec::Decode;
use core::cmp;
use cumulus_pallet_session_benchmarking as session_benchmarking;
use frame_benchmarking::{account, v2::*, whitelisted_caller, BenchmarkError};
Expand Down
20 changes: 15 additions & 5 deletions cumulus/pallets/collator-selection/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fn invulnerable_limit_works() {
// only keys were registered in mock for 1 to 5
if ii > 5 {
Balances::make_free_balance_be(&ii, 100);
let key = MockSessionKeys { aura: UintAuthorityId(ii) };
let mut key = MockSessionKeys { aura: UintAuthorityId(ii) };
Session::set_keys(
RuntimeOrigin::signed(ii).into(),
key.clone(),
Expand Down Expand Up @@ -488,8 +488,13 @@ fn cannot_register_candidate_if_too_many() {
// candidates.
for i in 6..=23 {
Balances::make_free_balance_be(&i, 100);
let key = MockSessionKeys { aura: UintAuthorityId(i) };
Session::set_keys(RuntimeOrigin::signed(i).into(), key, Vec::new()).unwrap();
let mut key = MockSessionKeys { aura: UintAuthorityId(i) };
Session::set_keys(
RuntimeOrigin::signed(i).into(),
key.clone(),
key.create_ownership_proof(&i.encode()).unwrap().encode(),
)
.unwrap();
}

for c in 3..=22 {
Expand Down Expand Up @@ -771,8 +776,13 @@ fn take_candidate_slot_works() {
assert_eq!(CandidateList::<Test>::get().iter().count(), 3);

Balances::make_free_balance_be(&6, 100);
let key = MockSessionKeys { aura: UintAuthorityId(6) };
Session::set_keys(RuntimeOrigin::signed(6).into(), key, Vec::new()).unwrap();
let mut key = MockSessionKeys { aura: UintAuthorityId(6) };
Session::set_keys(
RuntimeOrigin::signed(6).into(),
key.clone(),
key.create_ownership_proof(&6u64.encode()).unwrap().encode(),
)
.unwrap();

assert_ok!(CollatorSelection::take_candidate_slot(
RuntimeOrigin::signed(6),
Expand Down
1 change: 0 additions & 1 deletion cumulus/pallets/session-benchmarking/src/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

use alloc::vec::Vec;

use codec::Decode;
use frame_benchmarking::v2::*;
use frame_system::RawOrigin;
use pallet_session::*;
Expand Down
2 changes: 1 addition & 1 deletion docs/sdk/packages/guides/first-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ impl_runtime_apis! {
}

impl apis::SessionKeys<Block> for Runtime {
fn generate_session_keys(_seed: Option<Vec<u8>>) -> Vec<u8> {
fn generate_session_keys(_owner: Vec<u8>, _seed: Option<Vec<u8>>) -> apis::OpaqueGeneratedSessionKeys {
Default::default()
}

Expand Down
5 changes: 2 additions & 3 deletions substrate/frame/revive/dev-node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ use polkadot_sdk::{
},
*,
};
use sp_session::OpaqueGeneratedSessionKeys;
use sp_weights::{ConstantMultiplier, IdentityFee};

pub use polkadot_sdk::{
Expand Down Expand Up @@ -403,8 +402,8 @@ pallet_revive::impl_runtime_apis_plus_revive!(
}

impl apis::SessionKeys<Block> for Runtime {
fn generate_session_keys(owner: Vec<u8>, seed: Option<Vec<u8>>) -> OpaqueGeneratedSessionKeys {
SessionKeys::generate(&owner, seed).into()
fn generate_session_keys(_owner: Vec<u8>, _seed: Option<Vec<u8>>) -> apis::OpaqueGeneratedSessionKeys {
Default::default()
}


Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/staking-async/runtimes/parachain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1460,8 +1460,8 @@ impl_runtime_apis! {
}

impl sp_session::SessionKeys<Block> for Runtime {
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
SessionKeys::generate(seed)
fn generate_session_keys(owner: Vec<u8>, seed: Option<Vec<u8>>) -> sp_session::OpaqueGeneratedSessionKeys {
SessionKeys::generate(&owner, seed).into()
}

fn decode_session_keys(
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/staking-async/runtimes/rc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2595,8 +2595,8 @@ sp_api::impl_runtime_apis! {
}

impl sp_session::SessionKeys<Block> for Runtime {
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
SessionKeys::generate(seed)
fn generate_session_keys(owner: Vec<u8>, seed: Option<Vec<u8>>) -> sp_session::OpaqueGeneratedSessionKeys {
SessionKeys::generate(&owner, seed).into()
}

fn decode_session_keys(
Expand Down
8 changes: 4 additions & 4 deletions substrate/primitives/runtime/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ impl sp_application_crypto::RuntimeAppPublic for UintAuthorityId {
traits::Verify::verify(signature, msg.as_ref(), &self.0)
}

fn generate_proof_of_possession(&mut self, _owner: &[u8]) -> Option<Self::Signature> {
None
fn generate_proof_of_possession(&mut self, owner: &[u8]) -> Option<Self::Signature> {
Some(TestSignature(self.0, owner.to_vec()))
}

fn verify_proof_of_possession(&self, _owner: &[u8], _pop: &Self::Signature) -> bool {
false
fn verify_proof_of_possession(&self, owner: &[u8], pop: &Self::Signature) -> bool {
traits::Verify::verify(pop, owner, &self.0)
}

fn to_raw_vec(&self) -> Vec<u8> {
Expand Down
2 changes: 1 addition & 1 deletion substrate/primitives/session/src/runtime_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub use sp_core::crypto::KeyTypeId;
use sp_runtime::traits::GeneratedSessionKeys;

/// Opaque [`GeneratedSessionKeys`](sp_runtime::traits::GeneratedSessionKeys).
#[derive(Debug, Decode, Encode, scale_info::TypeInfo)]
#[derive(Debug, Default, Decode, Encode, scale_info::TypeInfo)]
pub struct OpaqueGeneratedSessionKeys {
/// The public session keys.
pub keys: Vec<u8>,
Expand Down
4 changes: 2 additions & 2 deletions templates/minimal/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ impl_runtime_apis! {
}

impl apis::SessionKeys<Block> for Runtime {
fn generate_session_keys(_owner: Vec<u8>, _seed: Option<Vec<u8>>) -> OpaqueGeneratedSessionKeys {
OpaqueGeneratedSessionKeys { keys: Default::default(), proof: Default::default() }
fn generate_session_keys(_owner: Vec<u8>, _seed: Option<Vec<u8>>) -> apis::OpaqueGeneratedSessionKeys {
apis::OpaqueGeneratedSessionKeys { keys: Default::default(), proof: Default::default() }
}

fn decode_session_keys(
Expand Down
Loading