mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 01:21:01 +00:00
Migrate pallet-session to the new pallet macro (#9796)
* Migrate pallet-session to the new pallet macro Signed-off-by: koushiro <koushiro.cqx@gmail.com> * Remove old macros Signed-off-by: koushiro <koushiro.cqx@gmail.com> * Fix Signed-off-by: koushiro <koushiro.cqx@gmail.com>
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
//! These roots and proofs of inclusion can be generated at any time during the current session.
|
||||
//! Afterwards, the proofs can be fed to a consensus module when reporting misbehavior.
|
||||
|
||||
use super::{Module as SessionModule, SessionIndex};
|
||||
use super::{Pallet as SessionModule, SessionIndex};
|
||||
use codec::{Decode, Encode};
|
||||
use frame_support::{
|
||||
decl_module, decl_storage, print,
|
||||
@@ -114,11 +114,11 @@ impl<T: Config> ValidatorSet<T::AccountId> for Module<T> {
|
||||
type ValidatorIdOf = T::ValidatorIdOf;
|
||||
|
||||
fn session_index() -> sp_staking::SessionIndex {
|
||||
super::Module::<T>::current_index()
|
||||
super::Pallet::<T>::current_index()
|
||||
}
|
||||
|
||||
fn validators() -> Vec<Self::ValidatorId> {
|
||||
super::Module::<T>::validators()
|
||||
super::Pallet::<T>::validators()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,11 +366,13 @@ pub(crate) mod tests {
|
||||
use crate::mock::{
|
||||
force_new_session, set_next_validators, Session, System, Test, NEXT_VALIDATORS,
|
||||
};
|
||||
|
||||
use sp_runtime::{key_types::DUMMY, testing::UintAuthorityId};
|
||||
|
||||
use frame_support::{
|
||||
traits::{KeyOwnerProofSystem, OnInitialize},
|
||||
traits::{GenesisBuild, KeyOwnerProofSystem, OnInitialize},
|
||||
BasicExternalities,
|
||||
};
|
||||
use sp_runtime::{key_types::DUMMY, testing::UintAuthorityId};
|
||||
|
||||
type Historical = Module<Test>;
|
||||
|
||||
|
||||
@@ -30,15 +30,11 @@ use sp_runtime::{
|
||||
KeyTypeId,
|
||||
};
|
||||
use sp_session::MembershipProof;
|
||||
|
||||
use super::{
|
||||
super::{Pallet as SessionModule, SessionIndex},
|
||||
Config, IdentificationTuple, ProvingTrie,
|
||||
};
|
||||
|
||||
use super::shared;
|
||||
use sp_std::prelude::*;
|
||||
|
||||
use super::{shared, Config, IdentificationTuple, ProvingTrie};
|
||||
use crate::{Pallet as SessionModule, SessionIndex};
|
||||
|
||||
/// A set of validators, which was used for a fixed session index.
|
||||
struct ValidatorSet<T: Config> {
|
||||
validator_set: Vec<IdentificationTuple<T>>,
|
||||
@@ -142,23 +138,24 @@ pub fn keep_newest<T: Config>(n_to_keep: usize) {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{
|
||||
super::{onchain, Module},
|
||||
*,
|
||||
};
|
||||
use crate::mock::{
|
||||
force_new_session, set_next_validators, Session, System, Test, NEXT_VALIDATORS,
|
||||
use super::*;
|
||||
use crate::{
|
||||
historical::{onchain, Module},
|
||||
mock::{force_new_session, set_next_validators, Session, System, Test, NEXT_VALIDATORS},
|
||||
};
|
||||
|
||||
use codec::Encode;
|
||||
use frame_support::traits::{KeyOwnerProofSystem, OnInitialize};
|
||||
use sp_core::{
|
||||
crypto::key_types::DUMMY,
|
||||
offchain::{testing::TestOffchainExt, OffchainDbExt, OffchainWorkerExt, StorageKind},
|
||||
};
|
||||
|
||||
use frame_support::BasicExternalities;
|
||||
use sp_runtime::testing::UintAuthorityId;
|
||||
|
||||
use frame_support::{
|
||||
traits::{GenesisBuild, KeyOwnerProofSystem, OnInitialize},
|
||||
BasicExternalities,
|
||||
};
|
||||
|
||||
type Historical = Module<Test>;
|
||||
|
||||
pub fn new_test_ext() -> sp_io::TestExternalities {
|
||||
|
||||
@@ -19,15 +19,11 @@
|
||||
|
||||
use codec::Encode;
|
||||
use sp_runtime::traits::Convert;
|
||||
|
||||
use super::{
|
||||
super::{Config as SessionConfig, Pallet as SessionModule, SessionIndex},
|
||||
Config as HistoricalConfig,
|
||||
};
|
||||
|
||||
use super::shared;
|
||||
use sp_std::prelude::*;
|
||||
|
||||
use super::{shared, Config as HistoricalConfig};
|
||||
use crate::{Config as SessionConfig, Pallet as SessionModule, SessionIndex};
|
||||
|
||||
/// Store the validator-set associated to the `session_index` to the off-chain database.
|
||||
///
|
||||
/// Further processing is then done [`off-chain side`](super::offchain).
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
//! Shared logic between on-chain and off-chain components used for slashing using an off-chain
|
||||
//! worker.
|
||||
|
||||
use super::SessionIndex;
|
||||
use codec::Encode;
|
||||
use sp_staking::SessionIndex;
|
||||
use sp_std::prelude::*;
|
||||
|
||||
pub(super) const PREFIX: &[u8] = b"session_historical";
|
||||
|
||||
Reference in New Issue
Block a user