Unalias Substrate Imports (#1530)

* cargo.toml updates

* session and system

* more

* more

* more

* more

* more

* fix

* compiles

* fix tests

* fix more tests

* fix mock

* fix deleted space

* Update validation/Cargo.toml

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update Cargo.lock

* update rococo

* remove unused warning

* update add benchmarks

* rename weight file

* forgot a file

* Update chain_spec.rs

* Revert "remove unused warning"

This reverts commit 4227cd0d1525286fb466dccb817564c9b37f8645.

* fix merge

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Shawn Tabrizi
2020-08-04 15:23:33 +02:00
committed by GitHub
parent c01aa8bae8
commit 73f09e5154
54 changed files with 1680 additions and 1690 deletions
+19 -19
View File
@@ -21,15 +21,15 @@ sp-session = { git = "https://github.com/paritytech/substrate", branch = "master
sp-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
authorship = { package = "pallet-authorship", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
balances = { package = "pallet-balances", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
session = { package = "pallet-session", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-authorship = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-session = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
staking = { package = "pallet-staking", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
system = { package = "frame-system", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
timestamp = { package = "pallet-timestamp", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
vesting = { package = "pallet-vesting", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
offences = { package = "pallet-offences", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-system = {git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-vesting = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-offences = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false }
@@ -42,11 +42,11 @@ rand_chacha = { version = "0.2.2", default-features = false }
hex-literal = "0.2.1"
keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate", branch = "master" }
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master" }
babe = { package = "pallet-babe", git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "master" }
randomness-collective-flip = { package = "pallet-randomness-collective-flip", git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-randomness-collective-flip = { git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-staking-reward-curve = { git = "https://github.com/paritytech/substrate", branch = "master" }
treasury = { package = "pallet-treasury", git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-treasury = { git = "https://github.com/paritytech/substrate", branch = "master" }
serde_json = "1.0.41"
libsecp256k1 = "0.3.2"
sp-version = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -69,20 +69,20 @@ std = [
"sp-std/std",
"sp-io/std",
"frame-support/std",
"authorship/std",
"balances/std",
"pallet-authorship/std",
"pallet-balances/std",
"sp-runtime/std",
"sp-session/std",
"sp-staking/std",
"session/std",
"staking/std",
"system/std",
"timestamp/std",
"vesting/std",
"pallet-session/std",
"pallet-staking/std",
"frame-system/std",
"pallet-timestamp/std",
"pallet-vesting/std",
]
runtime-benchmarks = [
"libsecp256k1/hmac",
"frame-benchmarking",
"frame-support/runtime-benchmarks",
"system/runtime-benchmarks",
"frame-system/runtime-benchmarks",
]
@@ -27,7 +27,7 @@ use frame_support::{
};
use sp_runtime::traits::One;
use codec::{Encode, Decode};
use system::ensure_root;
use frame_system::ensure_root;
/// All configuration of the runtime with respect to parachains and parathreads.
#[derive(Clone, Encode, Decode, PartialEq, Default)]
@@ -61,7 +61,7 @@ pub struct HostConfiguration<BlockNumber> {
pub scheduling_lookahead: u32,
}
pub trait Trait: system::Trait { }
pub trait Trait: frame_system::Trait { }
decl_storage! {
trait Store for Module<T: Trait> as Configuration {
@@ -78,7 +78,7 @@ decl_error! {
decl_module! {
/// The parachains configuration module.
pub struct Module<T: Trait> for enum Call where origin: <T as system::Trait>::Origin, system = system {
pub struct Module<T: Trait> for enum Call where origin: <T as frame_system::Trait>::Origin {
type Error = Error<T>;
/// Set the validation upgrade frequency.
@@ -227,7 +227,7 @@ impl<T: Trait> Module<T> {
GlobalValidationData {
max_code_size: config.max_code_size,
max_head_data_size: config.max_head_data_size,
block_number: <system::Module<T>>::block_number() - One::one(),
block_number: <frame_system::Module<T>>::block_number() - One::one(),
}
}
}
+8 -8
View File
@@ -87,9 +87,9 @@ impl<H, N> CandidatePendingAvailability<H, N> {
}
pub trait Trait:
system::Trait + paras::Trait + configuration::Trait
frame_system::Trait + paras::Trait + configuration::Trait
{
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
}
decl_storage! {
@@ -154,7 +154,7 @@ decl_error! {
}
decl_event! {
pub enum Event<T> where <T as system::Trait>::Hash {
pub enum Event<T> where <T as frame_system::Trait>::Hash {
/// A candidate was backed.
CandidateBacked(CandidateReceipt<Hash>, HeadData),
/// A candidate was included.
@@ -167,7 +167,7 @@ decl_event! {
decl_module! {
/// The parachain-candidate inclusion module.
pub struct Module<T: Trait>
for enum Call where origin: <T as system::Trait>::Origin, system = system
for enum Call where origin: <T as frame_system::Trait>::Origin
{
type Error = Error<T>;
@@ -230,7 +230,7 @@ impl<T: Trait> Module<T> {
let mut last_index = None;
let signing_context = SigningContext {
parent_hash: <system::Module<T>>::parent_hash(),
parent_hash: <frame_system::Module<T>>::parent_hash(),
session_index,
};
@@ -266,7 +266,7 @@ impl<T: Trait> Module<T> {
}
}
let now = <system::Module<T>>::block_number();
let now = <frame_system::Module<T>>::block_number();
for signed_bitfield in signed_bitfields {
for (bit_idx, _)
in signed_bitfield.payload().0.iter().enumerate().filter(|(_, is_av)| **is_av)
@@ -356,9 +356,9 @@ impl<T: Trait> Module<T> {
}
let validators = Validators::get();
let parent_hash = <system::Module<T>>::parent_hash();
let parent_hash = <frame_system::Module<T>>::parent_hash();
let config = <configuration::Module<T>>::config();
let now = <system::Module<T>>::block_number();
let now = <frame_system::Module<T>>::block_number();
let relay_parent_number = now - One::one();
// do all checks before writing storage.
@@ -31,7 +31,7 @@ use frame_support::{
weights::{DispatchClass, Weight},
traits::Get,
};
use system::ensure_none;
use frame_system::ensure_none;
use crate::{
inclusion,
scheduler::{self, FreedReason},
@@ -61,7 +61,7 @@ decl_error! {
decl_module! {
/// The inclusion inherent module.
pub struct Module<T: Trait> for enum Call where origin: <T as system::Trait>::Origin, system = system {
pub struct Module<T: Trait> for enum Call where origin: <T as frame_system::Trait>::Origin {
type Error = Error<T>;
fn on_initialize() -> Weight {
@@ -134,7 +134,7 @@ impl<T: Trait> ProvideInherent for Module<T> {
.map(|(signed_bitfields, backed_candidates): (SignedAvailabilityBitfields, Vec<BackedCandidate<T::Hash>>)| {
// Sanity check: session changes can invalidate an inherent, and we _really_ don't want that to happen.
// See github.com/paritytech/polkadot/issues/1327
if Self::inclusion(system::RawOrigin::None.into(), signed_bitfields.clone(), backed_candidates.clone()).is_ok() {
if Self::inclusion(frame_system::RawOrigin::None.into(), signed_bitfields.clone(), backed_candidates.clone()).is_ok() {
Call::inclusion(signed_bitfields, backed_candidates)
} else {
Call::inclusion(Vec::new().into(), Vec::new())
@@ -55,7 +55,7 @@ struct BufferedSessionChange<N> {
}
pub trait Trait:
system::Trait + configuration::Trait + paras::Trait + scheduler::Trait + inclusion::Trait
frame_system::Trait + configuration::Trait + paras::Trait + scheduler::Trait + inclusion::Trait
{
/// A randomness beacon.
type Randomness: Randomness<Self::Hash>;
@@ -89,7 +89,7 @@ decl_error! {
decl_module! {
/// The initializer module.
pub struct Module<T: Trait> for enum Call where origin: <T as system::Trait>::Origin, system = system {
pub struct Module<T: Trait> for enum Call where origin: <T as frame_system::Trait>::Origin {
type Error = Error<T>;
fn on_initialize(now: T::BlockNumber) -> Weight {
@@ -190,7 +190,7 @@ impl<T: Trait> Module<T> {
};
<BufferedSessionChanges<T>>::mutate(|v| v.push(BufferedSessionChange {
apply_at: <system::Module<T>>::block_number() + One::one(),
apply_at: <frame_system::Module<T>>::block_number() + One::one(),
validators,
queued,
session_index,
@@ -202,7 +202,7 @@ impl<T: Trait> sp_runtime::BoundToRuntimeAppPublic for Module<T> {
type Public = ValidatorId;
}
impl<T: session::Trait + Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
impl<T: pallet_session::Trait + Trait> pallet_session::OneSessionHandler<T::AccountId> for Module<T> {
type Key = ValidatorId;
fn on_genesis_session<'a, I: 'a>(_validators: I)
@@ -214,7 +214,7 @@ impl<T: session::Trait + Trait> session::OneSessionHandler<T::AccountId> for Mod
fn on_new_session<'a, I: 'a>(changed: bool, validators: I, queued: I)
where I: Iterator<Item=(&'a T::AccountId, Self::Key)>
{
let session_index = <session::Module<T>>::current_index();
let session_index = <pallet_session::Module<T>>::current_index();
<Module<T>>::on_new_session(changed, session_index, validators, Some(queued));
}
+6 -6
View File
@@ -36,7 +36,7 @@ use crate::inclusion;
pub struct Test;
impl_outer_origin! {
pub enum Origin for Test where system = system { }
pub enum Origin for Test { }
}
impl_outer_dispatch! {
@@ -47,7 +47,7 @@ impl_outer_dispatch! {
impl_outer_event! {
pub enum TestEvent for Test {
system<T>,
frame_system<T>,
inclusion<T>,
}
}
@@ -67,7 +67,7 @@ parameter_types! {
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
}
impl system::Trait for Test {
impl frame_system::Trait for Test {
type BaseCallFilter = ();
type Origin = Origin;
type Call = Call;
@@ -89,7 +89,7 @@ impl system::Trait for Test {
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type AccountData = balances::AccountData<u128>;
type AccountData = pallet_balances::AccountData<u128>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
@@ -109,7 +109,7 @@ impl crate::inclusion::Trait for Test {
type Event = TestEvent;
}
pub type System = system::Module<Test>;
pub type System = frame_system::Module<Test>;
/// Mocked initializer.
pub type Initializer = crate::initializer::Module<Test>;
@@ -137,7 +137,7 @@ pub fn new_test_ext(state: GenesisConfig) -> TestExternalities {
#[derive(Default)]
pub struct GenesisConfig {
pub system: system::GenesisConfig,
pub system: frame_system::GenesisConfig,
pub configuration: crate::configuration::GenesisConfig<Test>,
pub paras: crate::paras::GenesisConfig<Test>,
}
+6 -6
View File
@@ -41,7 +41,7 @@ use sp_core::RuntimeDebug;
#[cfg(feature = "std")]
use serde::{Serialize, Deserialize};
pub trait Trait: system::Trait + configuration::Trait { }
pub trait Trait: frame_system::Trait + configuration::Trait { }
// the two key times necessary to track for every code replacement.
#[derive(Default, Encode, Decode)]
@@ -241,7 +241,7 @@ decl_error! {
decl_module! {
/// The parachains configuration module.
pub struct Module<T: Trait> for enum Call where origin: <T as system::Trait>::Origin, system = system {
pub struct Module<T: Trait> for enum Call where origin: <T as frame_system::Trait>::Origin {
type Error = Error<T>;
}
}
@@ -257,7 +257,7 @@ impl<T: Trait> Module<T> {
/// Called by the initializer to note that a new session has started.
pub(crate) fn initializer_on_new_session(_notification: &SessionChangeNotification<T::BlockNumber>) {
let now = <system::Module<T>>::block_number();
let now = <frame_system::Module<T>>::block_number();
let mut parachains = Self::clean_up_outgoing(now);
Self::apply_incoming(&mut parachains);
<Self as Store>::Parachains::set(parachains);
@@ -477,7 +477,7 @@ impl<T: Trait> Module<T> {
CurrentCode::insert(&id, &new_code);
// `now` is only used for registering pruning as part of `fn note_past_code`
let now = <system::Module<T>>::block_number();
let now = <frame_system::Module<T>>::block_number();
let weight = Self::note_past_code(
id,
@@ -509,7 +509,7 @@ impl<T: Trait> Module<T> {
at: T::BlockNumber,
assume_intermediate: Option<T::BlockNumber>,
) -> Option<ValidationCode> {
let now = <system::Module<T>>::block_number();
let now = <frame_system::Module<T>>::block_number();
let config = <configuration::Module<T>>::config();
if assume_intermediate.as_ref().map_or(false, |i| &at <= i) {
@@ -553,7 +553,7 @@ impl<T: Trait> Module<T> {
/// Compute the local-validation data based on the head of the para. This assumes the
/// relay-parent is the parent of the current block.
pub(crate) fn local_validation_data(para_id: ParaId) -> Option<LocalValidationData<T::BlockNumber>> {
let relay_parent_number = <system::Module<T>>::block_number() - One::one();
let relay_parent_number = <frame_system::Module<T>>::block_number() - One::one();
let config = <configuration::Module<T>>::config();
let freq = config.validation_upgrade_frequency;
@@ -243,11 +243,11 @@ pub fn candidate_pending_availability<T: initializer::Trait>(para_id: ParaId)
pub fn candidate_events<T, F>(extract_event: F) -> Vec<CandidateEvent<T::Hash>>
where
T: initializer::Trait,
F: Fn(<T as system::Trait>::Event) -> Option<inclusion::Event<T>>,
F: Fn(<T as frame_system::Trait>::Event) -> Option<inclusion::Event<T>>,
{
use inclusion::Event as RawEvent;
<system::Module<T>>::events().into_iter()
<frame_system::Module<T>>::events().into_iter()
.filter_map(|record| extract_event(record.event))
.map(|event| match event {
RawEvent::<T>::CandidateBacked(c, h) => CandidateEvent::CandidateBacked(c, h),
+9 -9
View File
@@ -105,7 +105,7 @@ pub enum FreedReason {
TimedOut,
}
pub trait Trait: system::Trait + configuration::Trait + paras::Trait { }
pub trait Trait: frame_system::Trait + configuration::Trait + paras::Trait { }
decl_storage! {
trait Store for Module<T: Trait> as ParaScheduler {
@@ -147,7 +147,7 @@ decl_error! {
decl_module! {
/// The scheduler module.
pub struct Module<T: Trait> for enum Call where origin: <T as system::Trait>::Origin, system = system {
pub struct Module<T: Trait> for enum Call where origin: <T as frame_system::Trait>::Origin {
type Error = Error<T>;
}
}
@@ -195,7 +195,7 @@ impl<T: Trait> Module<T> {
let n_parachains = <paras::Module<T>>::parachains().len() as u32;
let n_cores = n_parachains + config.parathread_cores;
<SessionStartBlock<T>>::set(<system::Module<T>>::block_number());
<SessionStartBlock<T>>::set(<frame_system::Module<T>>::block_number());
AvailabilityCores::mutate(|cores| {
// clear all occupied cores.
for maybe_occupied in cores.iter_mut() {
@@ -355,7 +355,7 @@ impl<T: Trait> Module<T> {
let parachains = <paras::Module<T>>::parachains();
let mut scheduled = Scheduled::get();
let mut parathread_queue = ParathreadQueue::get();
let now = <system::Module<T>>::block_number();
let now = <frame_system::Module<T>>::block_number();
if ValidatorGroups::get().is_empty() { return }
@@ -548,7 +548,7 @@ impl<T: Trait> Module<T> {
/// https://github.com/rust-lang/rust/issues/73226
/// which prevents us from testing the code if using `impl Trait`.
pub(crate) fn availability_timeout_predicate() -> Option<Box<dyn Fn(CoreIndex, T::BlockNumber) -> bool>> {
let now = <system::Module<T>>::block_number();
let now = <frame_system::Module<T>>::block_number();
let config = <configuration::Module<T>>::config();
let session_start = <SessionStartBlock<T>>::get();
@@ -596,7 +596,7 @@ impl<T: Trait> Module<T> {
/// Returns a helper for determining group rotation.
pub(crate) fn group_rotation_info() -> GroupRotationInfo<T::BlockNumber> {
let session_start_block = Self::session_start_block();
let now = <system::Module<T>>::block_number();
let now = <frame_system::Module<T>>::block_number();
let group_rotation_frequency = <configuration::Module<T>>::config()
.group_rotation_frequency;
@@ -1539,8 +1539,8 @@ mod tests {
fn availability_predicate_no_rotation() {
let genesis_config = MockGenesisConfig {
configuration: crate::configuration::GenesisConfig {
config: HostConfiguration {
group_rotation_frequency: 0, // no rotation
config: HostConfiguration {
group_rotation_frequency: 0, // no rotation
..default_config()
},
..Default::default()
@@ -1571,7 +1571,7 @@ mod tests {
run_to_block(1, |number| match number {
1 => Some(SessionChangeNotification {
new_config: HostConfiguration{
// Note: the `group_rotation_frequency` config change
// Note: the `group_rotation_frequency` config change
// is not accounted for on session change
// group_rotation_frequency: 0,
..default_config()