[big refactor] Remove crate aliasing. (#4395)

* Rename: Phase 1.

* Unify codec.

* Fixing: Phase 2

* Fixing: Phase 3.

* Fixing: Phase 4.

* Fixing: Phase 5.

* Fixing: Phase 6.

* Fixing: Phase 7.

* Fixing: Phase 8. Tests

* Fixing: Phase 9. Tests!!!

* Fixing: Phase 10. Moar tests!

* Finally done!

* More fixes.

* Rename primitives:: to sp_core::

* Apply renames in finality-grandpa.

* Fix benches.

* Fix benches 2.

* Revert node-template.

* Fix frame-system in our modules.
This commit is contained in:
Tomasz Drwięga
2019-12-16 13:36:49 +01:00
committed by Gavin Wood
parent f14d98a439
commit 8778ca7dc8
485 changed files with 4023 additions and 4005 deletions
+43 -43
View File
@@ -138,8 +138,8 @@
//! ### Example: Rewarding a validator by id.
//!
//! ```
//! use support::{decl_module, dispatch};
//! use system::ensure_signed;
//! use frame_support::{decl_module, dispatch};
//! use frame_system::{self as system, ensure_signed};
//! use pallet_staking::{self as staking};
//!
//! pub trait Trait: staking::Trait {}
@@ -181,7 +181,7 @@
//! [`reward_by_indices`](./enum.Call.html#variant.reward_by_indices).
//!
//! [`Module`](./struct.Module.html) implements
//! [`authorship::EventHandler`](../pallet_authorship/trait.EventHandler.html) to add reward points
//! [`pallet_authorship::EventHandler`](../pallet_authorship/trait.EventHandler.html) to add reward points
//! to block producer and block producer of referenced uncles.
//!
//! The validator and its nominator split their reward as following:
@@ -257,7 +257,7 @@ pub mod inflation;
use sp_std::{prelude::*, result};
use codec::{HasCompact, Encode, Decode};
use support::{
use frame_support::{
decl_module, decl_event, decl_storage, ensure,
weights::SimpleDispatchInfo,
traits::{
@@ -265,7 +265,7 @@ use support::{
WithdrawReasons, OnUnbalanced, Imbalance, Get, Time
}
};
use session::{historical::OnSessionEnding, SelectInitialValidators};
use pallet_session::{historical::OnSessionEnding, SelectInitialValidators};
use sp_runtime::{
Perbill,
RuntimeDebug,
@@ -281,9 +281,9 @@ use sp_staking::{
};
#[cfg(feature = "std")]
use sp_runtime::{Serialize, Deserialize};
use system::{ensure_signed, ensure_root};
use frame_system::{self as system, ensure_signed, ensure_root};
use phragmen::{ExtendedBalance, PhragmenStakedAssignment};
use sp_phragmen::{ExtendedBalance, PhragmenStakedAssignment};
const DEFAULT_MINIMUM_VALIDATOR_COUNT: u32 = 4;
const MAX_NOMINATIONS: usize = 16;
@@ -521,17 +521,17 @@ pub struct UnappliedSlash<AccountId, Balance: HasCompact> {
}
pub type BalanceOf<T> =
<<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
<<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
type PositiveImbalanceOf<T> =
<<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::PositiveImbalance;
<<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::PositiveImbalance;
type NegativeImbalanceOf<T> =
<<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::NegativeImbalance;
<<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::NegativeImbalance;
type MomentOf<T> = <<T as Trait>::Time as Time>::Moment;
/// Means for interacting with a specialized version of the `session` trait.
///
/// This is needed because `Staking` sets the `ValidatorIdOf` of the `session::Trait`
pub trait SessionInterface<AccountId>: system::Trait {
/// This is needed because `Staking` sets the `ValidatorIdOf` of the `pallet_session::Trait`
pub trait SessionInterface<AccountId>: frame_system::Trait {
/// Disable a given validator by stash ID.
///
/// Returns `true` if new era should be forced at the end of this session.
@@ -544,31 +544,31 @@ pub trait SessionInterface<AccountId>: system::Trait {
fn prune_historical_up_to(up_to: SessionIndex);
}
impl<T: Trait> SessionInterface<<T as system::Trait>::AccountId> for T where
T: session::Trait<ValidatorId = <T as system::Trait>::AccountId>,
T: session::historical::Trait<
FullIdentification = Exposure<<T as system::Trait>::AccountId, BalanceOf<T>>,
impl<T: Trait> SessionInterface<<T as frame_system::Trait>::AccountId> for T where
T: pallet_session::Trait<ValidatorId = <T as frame_system::Trait>::AccountId>,
T: pallet_session::historical::Trait<
FullIdentification = Exposure<<T as frame_system::Trait>::AccountId, BalanceOf<T>>,
FullIdentificationOf = ExposureOf<T>,
>,
T::SessionHandler: session::SessionHandler<<T as system::Trait>::AccountId>,
T::OnSessionEnding: session::OnSessionEnding<<T as system::Trait>::AccountId>,
T::SelectInitialValidators: session::SelectInitialValidators<<T as system::Trait>::AccountId>,
T::ValidatorIdOf: Convert<<T as system::Trait>::AccountId, Option<<T as system::Trait>::AccountId>>
T::SessionHandler: pallet_session::SessionHandler<<T as frame_system::Trait>::AccountId>,
T::OnSessionEnding: pallet_session::OnSessionEnding<<T as frame_system::Trait>::AccountId>,
T::SelectInitialValidators: pallet_session::SelectInitialValidators<<T as frame_system::Trait>::AccountId>,
T::ValidatorIdOf: Convert<<T as frame_system::Trait>::AccountId, Option<<T as frame_system::Trait>::AccountId>>
{
fn disable_validator(validator: &<T as system::Trait>::AccountId) -> Result<bool, ()> {
<session::Module<T>>::disable(validator)
fn disable_validator(validator: &<T as frame_system::Trait>::AccountId) -> Result<bool, ()> {
<pallet_session::Module<T>>::disable(validator)
}
fn validators() -> Vec<<T as system::Trait>::AccountId> {
<session::Module<T>>::validators()
fn validators() -> Vec<<T as frame_system::Trait>::AccountId> {
<pallet_session::Module<T>>::validators()
}
fn prune_historical_up_to(up_to: SessionIndex) {
<session::historical::Module<T>>::prune_up_to(up_to);
<pallet_session::historical::Module<T>>::prune_up_to(up_to);
}
}
pub trait Trait: system::Trait {
pub trait Trait: frame_system::Trait {
/// The staking balance.
type Currency: LockableCurrency<Self::AccountId, Moment=Self::BlockNumber>;
@@ -586,7 +586,7 @@ pub trait Trait: system::Trait {
type RewardRemainder: OnUnbalanced<NegativeImbalanceOf<Self>>;
/// The overarching event type.
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
/// Handler for the unbalanced reduction when slashing a staker.
type Slash: OnUnbalanced<NegativeImbalanceOf<Self>>;
@@ -771,7 +771,7 @@ decl_storage! {
}
decl_event!(
pub enum Event<T> where Balance = BalanceOf<T>, <T as system::Trait>::AccountId {
pub enum Event<T> where Balance = BalanceOf<T>, <T as frame_system::Trait>::AccountId {
/// All validators have been rewarded by the first balance; the second is the remainder
/// from the maximum amount of reward.
Reward(Balance, Balance),
@@ -1423,7 +1423,7 @@ impl<T: Trait> Module<T> {
});
all_nominators.extend(nominator_votes);
let maybe_phragmen_result = phragmen::elect::<_, _, _, T::CurrencyToVote>(
let maybe_phragmen_result = sp_phragmen::elect::<_, _, _, T::CurrencyToVote>(
Self::validator_count() as usize,
Self::minimum_validator_count().max(1) as usize,
all_validators,
@@ -1442,7 +1442,7 @@ impl<T: Trait> Module<T> {
let to_balance = |e: ExtendedBalance|
<T::CurrencyToVote as Convert<ExtendedBalance, BalanceOf<T>>>::convert(e);
let mut supports = phragmen::build_support_map::<_, _, _, T::CurrencyToVote>(
let mut supports = sp_phragmen::build_support_map::<_, _, _, T::CurrencyToVote>(
&elected_stashes,
&assignments,
Self::slashable_balance_of,
@@ -1473,7 +1473,7 @@ impl<T: Trait> Module<T> {
let tolerance = 0_u128;
let iterations = 2_usize;
phragmen::equalize::<_, _, T::CurrencyToVote, _>(
sp_phragmen::equalize::<_, _, T::CurrencyToVote, _>(
staked_assignments,
&mut supports,
tolerance,
@@ -1600,7 +1600,7 @@ impl<T: Trait> Module<T> {
}
}
impl<T: Trait> session::OnSessionEnding<T::AccountId> for Module<T> {
impl<T: Trait> pallet_session::OnSessionEnding<T::AccountId> for Module<T> {
fn on_session_ending(_ending: SessionIndex, start_session: SessionIndex) -> Option<Vec<T::AccountId>> {
Self::ensure_storage_upgraded();
Self::new_session(start_session - 1).map(|(new, _old)| new)
@@ -1627,13 +1627,13 @@ impl<T: Trait> OnFreeBalanceZero<T::AccountId> for Module<T> {
/// * 20 points to the block producer for producing a (non-uncle) block in the relay chain,
/// * 2 points to the block producer for each reference to a previously unreferenced uncle, and
/// * 1 point to the producer of each referenced uncle block.
impl<T: Trait + authorship::Trait> authorship::EventHandler<T::AccountId, T::BlockNumber> for Module<T> {
impl<T: Trait + pallet_authorship::Trait> pallet_authorship::EventHandler<T::AccountId, T::BlockNumber> for Module<T> {
fn note_author(author: T::AccountId) {
Self::reward_by_ids(vec![(author, 20)]);
}
fn note_uncle(author: T::AccountId, _age: T::BlockNumber) {
Self::reward_by_ids(vec![
(<authorship::Module<T>>::author(), 2),
(<pallet_authorship::Module<T>>::author(), 2),
(author, 1)
])
}
@@ -1668,19 +1668,19 @@ impl<T: Trait> SelectInitialValidators<T::AccountId> for Module<T> {
}
/// This is intended to be used with `FilterHistoricalOffences`.
impl <T: Trait> OnOffenceHandler<T::AccountId, session::historical::IdentificationTuple<T>> for Module<T> where
T: session::Trait<ValidatorId = <T as system::Trait>::AccountId>,
T: session::historical::Trait<
FullIdentification = Exposure<<T as system::Trait>::AccountId, BalanceOf<T>>,
impl <T: Trait> OnOffenceHandler<T::AccountId, pallet_session::historical::IdentificationTuple<T>> for Module<T> where
T: pallet_session::Trait<ValidatorId = <T as frame_system::Trait>::AccountId>,
T: pallet_session::historical::Trait<
FullIdentification = Exposure<<T as frame_system::Trait>::AccountId, BalanceOf<T>>,
FullIdentificationOf = ExposureOf<T>,
>,
T::SessionHandler: session::SessionHandler<<T as system::Trait>::AccountId>,
T::OnSessionEnding: session::OnSessionEnding<<T as system::Trait>::AccountId>,
T::SelectInitialValidators: session::SelectInitialValidators<<T as system::Trait>::AccountId>,
T::ValidatorIdOf: Convert<<T as system::Trait>::AccountId, Option<<T as system::Trait>::AccountId>>
T::SessionHandler: pallet_session::SessionHandler<<T as frame_system::Trait>::AccountId>,
T::OnSessionEnding: pallet_session::OnSessionEnding<<T as frame_system::Trait>::AccountId>,
T::SelectInitialValidators: pallet_session::SelectInitialValidators<<T as frame_system::Trait>::AccountId>,
T::ValidatorIdOf: Convert<<T as frame_system::Trait>::AccountId, Option<<T as frame_system::Trait>::AccountId>>
{
fn on_offence(
offenders: &[OffenceDetails<T::AccountId, session::historical::IdentificationTuple<T>>],
offenders: &[OffenceDetails<T::AccountId, pallet_session::historical::IdentificationTuple<T>>],
slash_fraction: &[Perbill],
slash_session: SessionIndex,
) {