[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
+13 -13
View File
@@ -5,32 +5,32 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
[dependencies]
app-crypto = { package = "sp-application-crypto", path = "../../primitives/application-crypto", default-features = false }
authorship = { package = "pallet-authorship", path = "../authorship", default-features = false }
sp-application-crypto = { path = "../../primitives/application-crypto", default-features = false }
pallet-authorship = { path = "../authorship", default-features = false }
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-std = { path = "../../primitives/std", default-features = false }
serde = { version = "1.0.101", optional = true }
session = { package = "pallet-session", path = "../session", default-features = false }
pallet-session = { path = "../session", default-features = false }
sp-io = { path = "../../primitives/io", 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 }
frame-support = { path = "../support", default-features = false }
frame-system = { path = "../system", default-features = false }
[features]
default = ["std", "session/historical"]
default = ["std", "pallet-session/historical"]
std = [
"app-crypto/std",
"authorship/std",
"sp-application-crypto/std",
"pallet-authorship/std",
"codec/std",
"primitives/std",
"sp-core/std",
"sp-std/std",
"serde",
"session/std",
"pallet-session/std",
"sp-io/std",
"sp-runtime/std",
"sp-staking/std",
"support/std",
"system/std",
"frame-support/std",
"frame-system/std",
]
+27 -27
View File
@@ -42,8 +42,8 @@
//! ## Usage
//!
//! ```
//! 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_im_online::{self as im_online};
//!
//! pub trait Trait: im_online::Trait {}
@@ -70,12 +70,12 @@
mod mock;
mod tests;
use app_crypto::RuntimeAppPublic;
use sp_application_crypto::RuntimeAppPublic;
use codec::{Encode, Decode};
use primitives::offchain::{OpaqueNetworkState, StorageKind};
use sp_core::offchain::{OpaqueNetworkState, StorageKind};
use sp_std::prelude::*;
use sp_std::convert::TryInto;
use session::historical::IdentificationTuple;
use pallet_session::historical::IdentificationTuple;
use sp_runtime::{
RuntimeDebug,
traits::{Convert, Member, Printable, Saturating}, Perbill,
@@ -88,16 +88,16 @@ use sp_staking::{
SessionIndex,
offence::{ReportOffence, Offence, Kind},
};
use support::{
use frame_support::{
decl_module, decl_event, decl_storage, print, Parameter, debug,
traits::Get,
};
use system::ensure_none;
use system::offchain::SubmitUnsignedTransaction;
use frame_system::{self as system, ensure_none};
use frame_system::offchain::SubmitUnsignedTransaction;
pub mod sr25519 {
mod app_sr25519 {
use app_crypto::{app_crypto, key_types::IM_ONLINE, sr25519};
use sp_application_crypto::{app_crypto, key_types::IM_ONLINE, sr25519};
app_crypto!(sr25519, IM_ONLINE);
}
@@ -114,7 +114,7 @@ pub mod sr25519 {
pub mod ed25519 {
mod app_ed25519 {
use app_crypto::{app_crypto, key_types::IM_ONLINE, ed25519};
use sp_application_crypto::{app_crypto, key_types::IM_ONLINE, ed25519};
app_crypto!(ed25519, IM_ONLINE);
}
@@ -177,12 +177,12 @@ pub struct Heartbeat<BlockNumber>
authority_index: AuthIndex,
}
pub trait Trait: system::Trait + session::historical::Trait {
pub trait Trait: frame_system::Trait + pallet_session::historical::Trait {
/// The identifier type for an authority.
type AuthorityId: Member + Parameter + RuntimeAppPublic + Default + Ord;
/// 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>;
/// A dispatchable call type.
type Call: From<Call<Self>>;
@@ -257,7 +257,7 @@ decl_module! {
) {
ensure_none(origin)?;
let current_session = <session::Module<T>>::current_index();
let current_session = <pallet_session::Module<T>>::current_index();
let exists = <ReceivedHeartbeats>::exists(
&current_session,
&heartbeat.authority_index
@@ -294,7 +294,7 @@ decl_module! {
/// Keep track of number of authored blocks per authority, uncles are counted as
/// well since they're a valid proof of onlineness.
impl<T: Trait + authorship::Trait> authorship::EventHandler<T::ValidatorId, T::BlockNumber> for Module<T> {
impl<T: Trait + pallet_authorship::Trait> pallet_authorship::EventHandler<T::ValidatorId, T::BlockNumber> for Module<T> {
fn note_author(author: T::ValidatorId) {
Self::note_authorship(author);
}
@@ -310,7 +310,7 @@ impl<T: Trait> Module<T> {
/// authored at least one block, during the current session. Otherwise
/// `false`.
pub fn is_online(authority_index: AuthIndex) -> bool {
let current_validators = <session::Module<T>>::validators();
let current_validators = <pallet_session::Module<T>>::validators();
if authority_index >= current_validators.len() as u32 {
return false;
@@ -322,7 +322,7 @@ impl<T: Trait> Module<T> {
}
fn is_online_aux(authority_index: AuthIndex, authority: &T::ValidatorId) -> bool {
let current_session = <session::Module<T>>::current_index();
let current_session = <pallet_session::Module<T>>::current_index();
<ReceivedHeartbeats>::exists(&current_session, &authority_index) ||
<AuthoredBlocks<T>>::get(
@@ -334,13 +334,13 @@ impl<T: Trait> Module<T> {
/// Returns `true` if a heartbeat has been received for the authority at `authority_index` in
/// the authorities series, during the current session. Otherwise `false`.
pub fn received_heartbeat_in_current_session(authority_index: AuthIndex) -> bool {
let current_session = <session::Module<T>>::current_index();
let current_session = <pallet_session::Module<T>>::current_index();
<ReceivedHeartbeats>::exists(&current_session, &authority_index)
}
/// Note that the given authority has authored a block in the current session.
fn note_authorship(author: T::ValidatorId) {
let current_session = <session::Module<T>>::current_index();
let current_session = <pallet_session::Module<T>>::current_index();
<AuthoredBlocks<T>>::mutate(
&current_session,
@@ -413,7 +413,7 @@ impl<T: Trait> Module<T> {
let heartbeat_data = Heartbeat {
block_number,
network_state,
session_index: <session::Module<T>>::current_index(),
session_index: <pallet_session::Module<T>>::current_index(),
authority_index,
};
@@ -513,7 +513,7 @@ impl<T: Trait> sp_runtime::BoundToRuntimeAppPublic for Module<T> {
type Public = T::AuthorityId;
}
impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
impl<T: Trait> pallet_session::OneSessionHandler<T::AccountId> for Module<T> {
type Key = T::AuthorityId;
fn on_genesis_session<'a, I: 'a>(validators: I)
@@ -529,7 +529,7 @@ impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
// Tell the offchain worker to start making the next session's heartbeats.
// Since we consider producing blocks as being online,
// the hearbeat is defered a bit to prevent spaming.
let block_number = <system::Module<T>>::block_number();
let block_number = <frame_system::Module<T>>::block_number();
let half_session = T::SessionDuration::get() / 2.into();
<GossipAt<T>>::put(block_number + half_session);
@@ -538,9 +538,9 @@ impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
}
fn on_before_session_ending() {
let session_index = <session::Module<T>>::current_index();
let session_index = <pallet_session::Module<T>>::current_index();
let keys = Keys::<T>::get();
let current_validators = <session::Module<T>>::validators();
let current_validators = <pallet_session::Module<T>>::validators();
let offenders = current_validators.into_iter().enumerate()
.filter(|(index, id)|
@@ -552,8 +552,8 @@ impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
// Remove all received heartbeats and number of authored blocks from the
// current session, they have already been processed and won't be needed
// anymore.
<ReceivedHeartbeats>::remove_prefix(&<session::Module<T>>::current_index());
<AuthoredBlocks<T>>::remove_prefix(&<session::Module<T>>::current_index());
<ReceivedHeartbeats>::remove_prefix(&<pallet_session::Module<T>>::current_index());
<AuthoredBlocks<T>>::remove_prefix(&<pallet_session::Module<T>>::current_index());
if offenders.is_empty() {
Self::deposit_event(RawEvent::AllGood);
@@ -572,7 +572,7 @@ impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
}
#[allow(deprecated)]
impl<T: Trait> support::unsigned::ValidateUnsigned for Module<T> {
impl<T: Trait> frame_support::unsigned::ValidateUnsigned for Module<T> {
type Call = Call<T>;
fn validate_unsigned(call: &Self::Call) -> TransactionValidity {
@@ -583,7 +583,7 @@ impl<T: Trait> support::unsigned::ValidateUnsigned for Module<T> {
}
// check if session index from heartbeat is recent
let current_session = <session::Module<T>>::current_index();
let current_session = <pallet_session::Module<T>>::current_index();
if heartbeat.session_index != current_session {
return InvalidTransaction::Stale.into();
}
+15 -15
View File
@@ -25,10 +25,10 @@ use sp_runtime::Perbill;
use sp_staking::{SessionIndex, offence::ReportOffence};
use sp_runtime::testing::{Header, UintAuthorityId, TestXt};
use sp_runtime::traits::{IdentityLookup, BlakeTwo256, ConvertInto};
use primitives::H256;
use support::{impl_outer_origin, impl_outer_dispatch, parameter_types, weights::Weight};
use {sp_io, system};
use sp_core::H256;
use frame_support::{impl_outer_origin, impl_outer_dispatch, parameter_types, weights::Weight};
use frame_system as system;
impl_outer_origin!{
pub enum Origin for Runtime {}
}
@@ -44,7 +44,7 @@ thread_local! {
}
pub struct TestOnSessionEnding;
impl session::OnSessionEnding<u64> for TestOnSessionEnding {
impl pallet_session::OnSessionEnding<u64> for TestOnSessionEnding {
fn on_session_ending(_ending_index: SessionIndex, _will_apply_at: SessionIndex)
-> Option<Vec<u64>>
{
@@ -52,7 +52,7 @@ impl session::OnSessionEnding<u64> for TestOnSessionEnding {
}
}
impl session::historical::OnSessionEnding<u64, u64> for TestOnSessionEnding {
impl pallet_session::historical::OnSessionEnding<u64, u64> for TestOnSessionEnding {
fn on_session_ending(_ending_index: SessionIndex, _will_apply_at: SessionIndex)
-> Option<(Vec<u64>, Vec<(u64, u64)>)>
{
@@ -69,7 +69,7 @@ impl session::historical::OnSessionEnding<u64, u64> for TestOnSessionEnding {
/// An extrinsic type used for tests.
pub type Extrinsic = TestXt<Call, ()>;
type SubmitTransaction = system::offchain::TransactionSubmitter<(), Call, Extrinsic>;
type SubmitTransaction = frame_system::offchain::TransactionSubmitter<(), Call, Extrinsic>;
type IdentificationTuple = (u64, u64);
type Offence = crate::UnresponsivenessOffence<IdentificationTuple>;
@@ -86,7 +86,7 @@ impl ReportOffence<u64, IdentificationTuple, Offence> for OffenceHandler {
}
pub fn new_test_ext() -> sp_io::TestExternalities {
let t = system::GenesisConfig::default().build_storage::<Runtime>().unwrap();
let t = frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap();
t.into()
}
@@ -101,7 +101,7 @@ parameter_types! {
pub const AvailableBlockRatio: Perbill = Perbill::one();
}
impl system::Trait for Runtime {
impl frame_system::Trait for Runtime {
type Origin = Origin;
type Index = u64;
type BlockNumber = u64;
@@ -128,9 +128,9 @@ parameter_types! {
pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(33);
}
impl session::Trait for Runtime {
type ShouldEndSession = session::PeriodicSessions<Period, Offset>;
type OnSessionEnding = session::historical::NoteHistoricalRoot<Runtime, TestOnSessionEnding>;
impl pallet_session::Trait for Runtime {
type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;
type OnSessionEnding = pallet_session::historical::NoteHistoricalRoot<Runtime, TestOnSessionEnding>;
type SessionHandler = (ImOnline, );
type ValidatorId = u64;
type ValidatorIdOf = ConvertInto;
@@ -140,7 +140,7 @@ impl session::Trait for Runtime {
type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
}
impl session::historical::Trait for Runtime {
impl pallet_session::historical::Trait for Runtime {
type FullIdentification = u64;
type FullIdentificationOf = ConvertInto;
}
@@ -149,7 +149,7 @@ parameter_types! {
pub const UncleGenerations: u32 = 5;
}
impl authorship::Trait for Runtime {
impl pallet_authorship::Trait for Runtime {
type FindAuthor = ();
type UncleGenerations = UncleGenerations;
type FilterUncle = ();
@@ -167,8 +167,8 @@ impl Trait for Runtime {
/// Im Online module.
pub type ImOnline = Module<Runtime>;
pub type System = system::Module<Runtime>;
pub type Session = session::Module<Runtime>;
pub type System = frame_system::Module<Runtime>;
pub type Session = pallet_session::Module<Runtime>;
pub fn advance_session() {
let now = System::block_number();
+7 -7
View File
@@ -20,13 +20,13 @@
use super::*;
use crate::mock::*;
use primitives::offchain::{
use sp_core::offchain::{
OpaquePeerId,
OffchainExt,
TransactionPoolExt,
testing::{TestOffchainExt, TestTransactionPoolExt},
};
use support::{dispatch, assert_noop};
use frame_support::{dispatch, assert_noop};
use sp_runtime::testing::UintAuthorityId;
#[test]
@@ -113,7 +113,7 @@ fn heartbeat(
id: UintAuthorityId,
) -> dispatch::Result {
#[allow(deprecated)]
use support::unsigned::ValidateUnsigned;
use frame_support::unsigned::ValidateUnsigned;
let heartbeat = Heartbeat {
block_number,
@@ -129,7 +129,7 @@ fn heartbeat(
#[allow(deprecated)] // Allow ValidateUnsigned
ImOnline::pre_dispatch(&crate::Call::heartbeat(heartbeat.clone(), signature.clone()))?;
ImOnline::heartbeat(
Origin::system(system::RawOrigin::None),
Origin::system(frame_system::RawOrigin::None),
heartbeat,
signature
)
@@ -262,7 +262,7 @@ fn should_cleanup_received_heartbeats_on_session_end() {
#[test]
fn should_mark_online_validator_when_block_is_authored() {
use authorship::EventHandler;
use pallet_authorship::EventHandler;
new_test_ext().execute_with(|| {
advance_session();
@@ -292,7 +292,7 @@ fn should_mark_online_validator_when_block_is_authored() {
#[test]
fn should_not_send_a_report_if_already_online() {
use authorship::EventHandler;
use pallet_authorship::EventHandler;
let mut ext = new_test_ext();
let (offchain, _state) = TestOffchainExt::new();
@@ -313,7 +313,7 @@ fn should_not_send_a_report_if_already_online() {
ImOnline::note_uncle(3, 0);
// when
UintAuthorityId::set_all_keys(vec![0]); // all authorities use session key 0
UintAuthorityId::set_all_keys(vec![0]); // all authorities use pallet_session key 0
ImOnline::offchain(4);
// then