[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
+10 -10
View File
@@ -7,15 +7,15 @@ edition = "2018"
[dependencies]
serde = { version = "1.0.101", optional = true, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
primitives = { package = "sp-core", path = "../../primitives/core", default-features = false }
sp-core = { path = "../../primitives/core", default-features = false }
sp-finality-grandpa = { path = "../../primitives/finality-grandpa", default-features = false }
sp-std = { path = "../../primitives/std", default-features = false }
sp-runtime = { path = "../../primitives/runtime", default-features = false }
sp-staking = { path = "../../primitives/staking", default-features = false }
support = { package = "frame-support", path = "../support", default-features = false }
system = { package = "frame-system", path = "../system", default-features = false }
session = { package = "pallet-session", path = "../session", default-features = false }
finality-tracker = { package = "pallet-finality-tracker", path = "../finality-tracker", default-features = false }
frame-support = { path = "../support", default-features = false }
frame-system = { path = "../system", default-features = false }
pallet-session = { path = "../session", default-features = false }
pallet-finality-tracker = { path = "../finality-tracker", default-features = false }
[dev-dependencies]
sp-io ={ path = "../../primitives/io" }
@@ -25,14 +25,14 @@ default = ["std"]
std = [
"serde",
"codec/std",
"primitives/std",
"sp-core/std",
"sp-finality-grandpa/std",
"sp-std/std",
"support/std",
"frame-support/std",
"sp-runtime/std",
"sp-staking/std",
"system/std",
"session/std",
"finality-tracker/std",
"frame-system/std",
"pallet-session/std",
"pallet-finality-tracker/std",
]
migrate-authorities = []
+13 -13
View File
@@ -32,7 +32,7 @@ pub use sp_finality_grandpa as fg_primitives;
use sp_std::prelude::*;
use codec::{self as codec, Encode, Decode, Error};
use support::{decl_event, decl_storage, decl_module, dispatch, storage};
use frame_support::{decl_event, decl_storage, decl_module, dispatch, storage};
use sp_runtime::{
generic::{DigestItem, OpaqueDigestItemId}, traits::Zero, Perbill,
};
@@ -44,14 +44,14 @@ use fg_primitives::{
GRANDPA_AUTHORITIES_KEY, GRANDPA_ENGINE_ID, ScheduledChange, ConsensusLog, SetId, RoundNumber,
};
pub use fg_primitives::{AuthorityId, AuthorityList, AuthorityWeight, VersionedAuthorityList};
use system::{ensure_signed, DigestOf};
use frame_system::{self as system, ensure_signed, DigestOf};
mod mock;
mod tests;
pub trait Trait: system::Trait {
pub trait Trait: frame_system::Trait {
/// The event type of this module.
type Event: From<Event> + Into<<Self as system::Trait>::Event>;
type Event: From<Event> + Into<<Self as frame_system::Trait>::Event>;
}
/// A stored pending change, old format.
@@ -266,7 +266,7 @@ impl<T: Trait> Module<T> {
/// Cannot be done when already paused.
pub fn schedule_pause(in_blocks: T::BlockNumber) -> dispatch::Result {
if let StoredState::Live = <State<T>>::get() {
let scheduled_at = <system::Module<T>>::block_number();
let scheduled_at = <frame_system::Module<T>>::block_number();
<State<T>>::put(StoredState::PendingPause {
delay: in_blocks,
scheduled_at,
@@ -282,7 +282,7 @@ impl<T: Trait> Module<T> {
/// Schedule a resume of GRANDPA after pausing.
pub fn schedule_resume(in_blocks: T::BlockNumber) -> dispatch::Result {
if let StoredState::Paused = <State<T>>::get() {
let scheduled_at = <system::Module<T>>::block_number();
let scheduled_at = <frame_system::Module<T>>::block_number();
<State<T>>::put(StoredState::PendingResume {
delay: in_blocks,
scheduled_at,
@@ -315,7 +315,7 @@ impl<T: Trait> Module<T> {
forced: Option<T::BlockNumber>,
) -> dispatch::Result {
if !<PendingChange<T>>::exists() {
let scheduled_at = <system::Module<T>>::block_number();
let scheduled_at = <frame_system::Module<T>>::block_number();
if let Some(_) = forced {
if Self::next_forced().map_or(false, |next| next > scheduled_at) {
@@ -343,7 +343,7 @@ impl<T: Trait> Module<T> {
/// Deposit one of this module's logs.
fn deposit_log(log: ConsensusLog<T::BlockNumber>) {
let log: DigestItem<T::Hash> = DigestItem::Consensus(GRANDPA_ENGINE_ID, log.encode());
<system::Module<T>>::deposit_log(log.into());
<frame_system::Module<T>>::deposit_log(log.into());
}
fn initialize_authorities(authorities: &AuthorityList) {
@@ -404,8 +404,8 @@ impl<T: Trait> sp_runtime::BoundToRuntimeAppPublic for Module<T> {
type Public = AuthorityId;
}
impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T>
where T: session::Trait
impl<T: Trait> pallet_session::OneSessionHandler<T::AccountId> for Module<T>
where T: pallet_session::Trait
{
type Key = AuthorityId;
@@ -438,7 +438,7 @@ impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T>
// if we didn't issue a change, we update the mapping to note that the current
// set corresponds to the latest equivalent session (i.e. now).
let session_index = <session::Module<T>>::current_index();
let session_index = <pallet_session::Module<T>>::current_index();
SetIdSession::insert(current_set_id, &session_index);
}
@@ -447,9 +447,9 @@ impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T>
}
}
impl<T: Trait> finality_tracker::OnFinalizationStalled<T::BlockNumber> for Module<T> {
impl<T: Trait> pallet_finality_tracker::OnFinalizationStalled<T::BlockNumber> for Module<T> {
fn on_stalled(further_wait: T::BlockNumber, median: T::BlockNumber) {
// when we record old authority sets, we can use `finality_tracker::median`
// when we record old authority sets, we can use `pallet_finality_tracker::median`
// to figure out _who_ failed. until then, we can't meaningfully guard
// against `next == last` the way that normal session changes do.
<Stalled<T>>::put((further_wait, median));
+7 -6
View File
@@ -20,14 +20,15 @@
use sp_runtime::{Perbill, DigestItem, traits::IdentityLookup, testing::{Header, UintAuthorityId}};
use sp_io;
use support::{impl_outer_origin, impl_outer_event, parameter_types, weights::Weight};
use primitives::H256;
use frame_support::{impl_outer_origin, impl_outer_event, parameter_types, weights::Weight};
use sp_core::H256;
use codec::{Encode, Decode};
use crate::{AuthorityId, AuthorityList, GenesisConfig, Trait, Module, ConsensusLog};
use sp_finality_grandpa::GRANDPA_ENGINE_ID;
use frame_system as system;
impl_outer_origin!{
pub enum Origin for Test {}
pub enum Origin for Test where system = frame_system {}
}
pub fn grandpa_log(log: ConsensusLog<u64>) -> DigestItem<H256> {
@@ -47,7 +48,7 @@ parameter_types! {
pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::one();
}
impl system::Trait for Test {
impl frame_system::Trait for Test {
type Origin = Origin;
type Index = u64;
type BlockNumber = u64;
@@ -82,12 +83,12 @@ pub fn to_authorities(vec: Vec<(u64, u64)>) -> AuthorityList {
}
pub fn new_test_ext(authorities: Vec<(u64, u64)>) -> sp_io::TestExternalities {
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
GenesisConfig {
authorities: to_authorities(authorities),
}.assimilate_storage::<Test>(&mut t).unwrap();
t.into()
}
pub type System = system::Module<Test>;
pub type System = frame_system::Module<Test>;
pub type Grandpa = Module<Test>;
+1 -1
View File
@@ -20,7 +20,7 @@
use sp_runtime::{testing::Digest, traits::{Header, OnFinalize}};
use crate::mock::*;
use system::{EventRecord, Phase};
use frame_system::{EventRecord, Phase};
use codec::{Decode, Encode};
use fg_primitives::ScheduledChange;
use super::*;