Skip to content

Commit

Permalink
Companion for #11981 (#5915)
Browse files Browse the repository at this point in the history
* Companion for #11981

* more renaming

* fmt

* fixes

* add generic type

* Companion for #11831

* fix

* revert changes

* Delete rename-outer-enum.diff

* revert

* Update run_benches_for_runtime.sh

* rename type Call & type Event

* passing tests

* fmt

* small fixes

* commit

* fix

* fmt

* commit

* error fixes

* fix

* small fix in test

* Update lib.rs

* Update lib.rs

* Update lib.rs

* Update lib.rs

* Update lib.rs

* Update lib.rs

* Update lib.rs

* remove RuntimeCall from pallet_grandpa

* last fix

* commit

* rename

* merge fix

* update lockfile for {"substrate"}

* cargo +nightly fmt

* fix

Co-authored-by: parity-processbot <>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
  • Loading branch information
Szegoo and shawntabrizi authored Sep 12, 2022
1 parent 97ac0fe commit 7b73b43
Show file tree
Hide file tree
Showing 37 changed files with 691 additions and 648 deletions.
18 changes: 9 additions & 9 deletions polkadot/runtime/common/src/assigned_slots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub mod pallet {
#[pallet::disable_frame_system_supertrait_check]
pub trait Config: configuration::Config + paras::Config + slots::Config {
/// The overarching event type.
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;

/// Origin for assigning slots.
type AssignSlotOrigin: EnsureOrigin<<Self as frame_system::Config>::Origin>;
Expand Down Expand Up @@ -579,10 +579,10 @@ mod tests {

impl<C> frame_system::offchain::SendTransactionTypes<C> for Test
where
Call: From<C>,
RuntimeCall: From<C>,
{
type Extrinsic = UncheckedExtrinsic;
type OverarchingCall = Call;
type OverarchingCall = RuntimeCall;
}

parameter_types! {
Expand All @@ -593,15 +593,15 @@ mod tests {
type BlockWeights = ();
type BlockLength = ();
type Origin = Origin;
type Call = Call;
type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = BlockNumber;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type DbWeight = ();
type Version = ();
Expand All @@ -621,7 +621,7 @@ mod tests {

impl pallet_balances::Config for Test {
type Balance = u64;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
Expand All @@ -640,7 +640,7 @@ mod tests {
}

impl parachains_paras::Config for Test {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = parachains_paras::TestWeightInfo;
type UnsignedPriority = ParasUnsignedPriority;
type NextSessionRotation = crate::mock::TestNextSessionRotation;
Expand All @@ -655,7 +655,7 @@ mod tests {
}

impl slots::Config for Test {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type Registrar = TestRegistrar<Test>;
type LeasePeriod = LeasePeriod;
Expand All @@ -673,7 +673,7 @@ mod tests {
}

impl assigned_slots::Config for Test {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type AssignSlotOrigin = EnsureRoot<Self::AccountId>;
type Leaser = Slots;
type PermanentSlotLeasePeriodLength = PermanentSlotLeasePeriodLength;
Expand Down
14 changes: 7 additions & 7 deletions polkadot/runtime/common/src/auctions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub mod pallet {
#[pallet::config]
pub trait Config: frame_system::Config {
/// The overarching event type.
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;

/// The type representing the leasing system.
type Leaser: Leaser<
Expand Down Expand Up @@ -710,15 +710,15 @@ mod tests {
type BlockLength = ();
type DbWeight = ();
type Origin = Origin;
type Call = Call;
type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = BlockNumber;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type Version = ();
type PalletInfo = PalletInfo;
Expand All @@ -739,7 +739,7 @@ mod tests {
impl pallet_balances::Config for Test {
type Balance = u64;
type DustRemoval = ();
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
Expand Down Expand Up @@ -867,7 +867,7 @@ mod tests {
}

impl Config for Test {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type Leaser = TestLeaser;
type Registrar = TestRegistrar<Self>;
type EndingPeriod = EndingPeriod;
Expand Down Expand Up @@ -1729,9 +1729,9 @@ mod benchmarking {

use frame_benchmarking::{account, benchmarks, whitelisted_caller};

fn assert_last_event<T: Config>(generic_event: <T as Config>::Event) {
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
let events = frame_system::Pallet::<T>::events();
let system_event: <T as frame_system::Config>::Event = generic_event.into();
let system_event: <T as frame_system::Config>::RuntimeEvent = generic_event.into();
// compare to the last event record
let frame_system::EventRecord { event, .. } = &events[events.len() - 1];
assert_eq!(event, &system_event);
Expand Down
28 changes: 14 additions & 14 deletions polkadot/runtime/common/src/claims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ pub mod pallet {
#[pallet::config]
pub trait Config: frame_system::Config {
/// The overarching event type.
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
type VestingSchedule: VestingSchedule<Self::AccountId, Moment = Self::BlockNumber>;
#[pallet::constant]
type Prefix: Get<&'static [u8]>;
Expand Down Expand Up @@ -597,11 +597,11 @@ impl<T: Config> Pallet<T> {
#[scale_info(skip_type_params(T))]
pub struct PrevalidateAttests<T: Config + Send + Sync>(sp_std::marker::PhantomData<T>)
where
<T as frame_system::Config>::Call: IsSubType<Call<T>>;
<T as frame_system::Config>::RuntimeCall: IsSubType<Call<T>>;

impl<T: Config + Send + Sync> Debug for PrevalidateAttests<T>
where
<T as frame_system::Config>::Call: IsSubType<Call<T>>,
<T as frame_system::Config>::RuntimeCall: IsSubType<Call<T>>,
{
#[cfg(feature = "std")]
fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
Expand All @@ -616,7 +616,7 @@ where

impl<T: Config + Send + Sync> PrevalidateAttests<T>
where
<T as frame_system::Config>::Call: IsSubType<Call<T>>,
<T as frame_system::Config>::RuntimeCall: IsSubType<Call<T>>,
{
/// Create new `SignedExtension` to check runtime version.
pub fn new() -> Self {
Expand All @@ -626,10 +626,10 @@ where

impl<T: Config + Send + Sync> SignedExtension for PrevalidateAttests<T>
where
<T as frame_system::Config>::Call: IsSubType<Call<T>>,
<T as frame_system::Config>::RuntimeCall: IsSubType<Call<T>>,
{
type AccountId = T::AccountId;
type Call = <T as frame_system::Config>::Call;
type Call = <T as frame_system::Config>::RuntimeCall;
type AdditionalSigned = ();
type Pre = ();
const IDENTIFIER: &'static str = "PrevalidateAttests";
Expand Down Expand Up @@ -752,15 +752,15 @@ mod tests {
type BlockLength = ();
type DbWeight = ();
type Origin = Origin;
type Call = Call;
type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<u64>;
type Header = Header;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type Version = ();
type PalletInfo = PalletInfo;
Expand All @@ -779,7 +779,7 @@ mod tests {

impl pallet_balances::Config for Test {
type Balance = u64;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
Expand All @@ -794,7 +794,7 @@ mod tests {
}

impl pallet_vesting::Config for Test {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type BlockNumberToBalance = Identity;
type MinVestedTransfer = MinVestedTransfer;
Expand All @@ -810,7 +810,7 @@ mod tests {
}

impl Config for Test {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type VestingSchedule = Vesting;
type Prefix = Prefix;
type MoveClaimOrigin = frame_system::EnsureSignedBy<Six, u64>;
Expand Down Expand Up @@ -1052,7 +1052,7 @@ mod tests {
fn valid_attest_transactions_are_free() {
new_test_ext().execute_with(|| {
let p = PrevalidateAttests::<Test>::new();
let c = Call::Claims(ClaimsCall::attest {
let c = RuntimeCall::Claims(ClaimsCall::attest {
statement: StatementKind::Saft.to_text().to_vec(),
});
let di = c.get_dispatch_info();
Expand All @@ -1066,13 +1066,13 @@ mod tests {
fn invalid_attest_transactions_are_recognized() {
new_test_ext().execute_with(|| {
let p = PrevalidateAttests::<Test>::new();
let c = Call::Claims(ClaimsCall::attest {
let c = RuntimeCall::Claims(ClaimsCall::attest {
statement: StatementKind::Regular.to_text().to_vec(),
});
let di = c.get_dispatch_info();
let r = p.validate(&42, &c, &di, 20);
assert!(r.is_err());
let c = Call::Claims(ClaimsCall::attest {
let c = RuntimeCall::Claims(ClaimsCall::attest {
statement: StatementKind::Saft.to_text().to_vec(),
});
let di = c.get_dispatch_info();
Expand Down
18 changes: 9 additions & 9 deletions polkadot/runtime/common/src/crowdloan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ pub mod pallet {

#[pallet::config]
pub trait Config: frame_system::Config {
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;

/// `PalletId` for the crowdloan pallet. An appropriate value could be `PalletId(*b"py/cfund")`
#[pallet::constant]
Expand Down Expand Up @@ -893,15 +893,15 @@ mod tests {
type BlockLength = ();
type DbWeight = ();
type Origin = Origin;
type Call = Call;
type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = BlockNumber;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type Version = ();
type PalletInfo = PalletInfo;
Expand All @@ -920,7 +920,7 @@ mod tests {

impl pallet_balances::Config for Test {
type Balance = u64;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
Expand Down Expand Up @@ -1072,7 +1072,7 @@ mod tests {
}

impl Config for Test {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type SubmissionDeposit = SubmissionDeposit;
type MinContribution = MinContribution;
type PalletId = CrowdloanPalletId;
Expand Down Expand Up @@ -1129,8 +1129,8 @@ mod tests {
}
}

fn last_event() -> Event {
System::events().pop().expect("Event expected").event
fn last_event() -> RuntimeEvent {
System::events().pop().expect("RuntimeEvent expected").event
}

#[test]
Expand Down Expand Up @@ -1906,9 +1906,9 @@ mod benchmarking {

use frame_benchmarking::{account, benchmarks, whitelisted_caller};

fn assert_last_event<T: Config>(generic_event: <T as Config>::Event) {
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
let events = frame_system::Pallet::<T>::events();
let system_event: <T as frame_system::Config>::Event = generic_event.into();
let system_event: <T as frame_system::Config>::RuntimeEvent = generic_event.into();
// compare to the last event record
let frame_system::EventRecord { event, .. } = &events[events.len() - 1];
assert_eq!(event, &system_event);
Expand Down
8 changes: 4 additions & 4 deletions polkadot/runtime/common/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ mod tests {
type Origin = Origin;
type Index = u64;
type BlockNumber = u64;
type Call = Call;
type RuntimeCall = RuntimeCall;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type BlockLength = BlockLength;
type BlockWeights = BlockWeights;
Expand All @@ -136,7 +136,7 @@ mod tests {

impl pallet_balances::Config for Test {
type Balance = u64;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ();
type AccountStore = System;
Expand All @@ -155,7 +155,7 @@ mod tests {
type Currency = pallet_balances::Pallet<Test>;
type ApproveOrigin = frame_system::EnsureRoot<AccountId>;
type RejectOrigin = frame_system::EnsureRoot<AccountId>;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type OnSlash = ();
type ProposalBond = ();
type ProposalBondMinimum = ();
Expand Down
Loading

0 comments on commit 7b73b43

Please sign in to comment.