Skip to content

Commit

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

* rename

* Event to RuntimeEvent in imports

* missed rename

* undo

* revert

* rename type Call & Event

* commit

* ...

* fix

* fix errors

* fixes

* fmt

* fix imports

* final fix?

* fmt

* fix?

* fixes after merge

* small fix

* cargo update -p polkadot-runtime-common

* cargo +nightly fmt

* update lockfile for {"polkadot", "substrate"}

* fix

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: parity-processbot <>
  • Loading branch information
Szegoo and shawntabrizi committed Sep 12, 2022
1 parent a67a17b commit d3fb9de
Show file tree
Hide file tree
Showing 26 changed files with 489 additions and 425 deletions.
4 changes: 2 additions & 2 deletions cumulus/pallets/collator-selection/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ macro_rules! whitelist {
};
}

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 EventRecord { event, .. } = &events[events.len() - 1];
assert_eq!(event, &system_event);
Expand Down
2 changes: 1 addition & 1 deletion cumulus/pallets/collator-selection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ pub mod pallet {
#[pallet::config]
pub trait Config: frame_system::Config {
/// 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 currency mechanism.
type Currency: ReservableCurrency<Self::AccountId>;
Expand Down
10 changes: 5 additions & 5 deletions cumulus/pallets/collator-selection/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ impl system::Config for Test {
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<Self::AccountId>;
type Header = Header;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type Version = ();
type PalletInfo = PalletInfo;
Expand All @@ -88,7 +88,7 @@ parameter_types! {

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 @@ -171,7 +171,7 @@ parameter_types! {
}

impl pallet_session::Config for Test {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type ValidatorId = <Self as frame_system::Config>::AccountId;
// we don't have stash and controller, thus we don't need the convert as well.
type ValidatorIdOf = IdentityCollator;
Expand Down Expand Up @@ -207,7 +207,7 @@ impl ValidatorRegistration<u64> for IsRegistered {
}

impl Config for Test {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type UpdateOrigin = EnsureSignedBy<RootAccount, u64>;
type PotId = PotId;
Expand Down
31 changes: 16 additions & 15 deletions cumulus/parachain-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,11 @@ pub type SignedExtra = (
);

/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
pub type UncheckedExtrinsic =
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;

/// Extrinsic type that has already been checked.
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, RuntimeCall, SignedExtra>;

/// Executive: handles dispatch to the various modules.
pub type Executive = frame_executive::Executive<
Expand Down Expand Up @@ -258,7 +259,7 @@ impl frame_system::Config for Runtime {
/// The identifier used to distinguish between accounts.
type AccountId = AccountId;
/// The aggregated dispatch type that is available for extrinsics.
type Call = Call;
type RuntimeCall = RuntimeCall;
/// The lookup mechanism to get account ID from whatever is passed in dispatchers.
type Lookup = AccountIdLookup<AccountId, ()>;
/// The index type for storing how many extrinsics an account has signed.
Expand All @@ -272,7 +273,7 @@ impl frame_system::Config for Runtime {
/// The header type.
type Header = generic::Header<BlockNumber, BlakeTwo256>;
/// The ubiquitous event type.
type Event = Event;
type RuntimeEvent = RuntimeEvent;
/// The ubiquitous origin type.
type Origin = Origin;
/// Maximum number of block number to block hash mappings to keep (oldest pruned first).
Expand Down Expand Up @@ -338,7 +339,7 @@ impl pallet_balances::Config for Runtime {
/// The type for recording an account's balance.
type Balance = Balance;
/// The ubiquitous event type.
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
Expand All @@ -354,7 +355,7 @@ parameter_types! {
}

impl pallet_transaction_payment::Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;
type WeightToFee = WeightToFee;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
Expand All @@ -368,7 +369,7 @@ parameter_types! {
}

impl cumulus_pallet_parachain_system::Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type OnSystemEvent = ();
type SelfParaId = parachain_info::Pallet<Runtime>;
type OutboundXcmpMessageSource = XcmpQueue;
Expand All @@ -384,7 +385,7 @@ impl parachain_info::Config for Runtime {}
impl cumulus_pallet_aura_ext::Config for Runtime {}

impl cumulus_pallet_xcmp_queue::Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type XcmExecutor = XcmExecutor<XcmConfig>;
type ChannelInfo = ParachainSystem;
type VersionWrapper = ();
Expand All @@ -395,7 +396,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
}

impl cumulus_pallet_dmp_queue::Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type XcmExecutor = XcmExecutor<XcmConfig>;
type ExecuteOverweightOrigin = EnsureRoot<AccountId>;
}
Expand All @@ -407,7 +408,7 @@ parameter_types! {
}

impl pallet_session::Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type ValidatorId = <Self as frame_system::Config>::AccountId;
// we don't have stash and controller, thus we don't need the convert as well.
type ValidatorIdOf = pallet_collator_selection::IdentityCollator;
Expand Down Expand Up @@ -439,7 +440,7 @@ parameter_types! {
pub type CollatorSelectionUpdateOrigin = EnsureRoot<AccountId>;

impl pallet_collator_selection::Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type UpdateOrigin = CollatorSelectionUpdateOrigin;
type PotId = PotId;
Expand All @@ -456,7 +457,7 @@ impl pallet_collator_selection::Config for Runtime {

/// Configure the pallet template in pallets/template.
impl pallet_template::Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
}

// Create the runtime by composing the FRAME pallets that were previously configured.
Expand Down Expand Up @@ -613,17 +614,17 @@ impl_runtime_apis! {
}
}

impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block, Balance, Call>
impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block, Balance, RuntimeCall>
for Runtime
{
fn query_call_info(
call: Call,
call: RuntimeCall,
len: u32,
) -> pallet_transaction_payment::RuntimeDispatchInfo<Balance> {
TransactionPayment::query_call_info(call, len)
}
fn query_call_fee_details(
call: Call,
call: RuntimeCall,
len: u32,
) -> pallet_transaction_payment::FeeDetails<Balance> {
TransactionPayment::query_call_fee_details(call, len)
Expand Down
25 changes: 13 additions & 12 deletions cumulus/parachain-template/runtime/src/xcm_config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{
AccountId, Balances, Call, Event, Origin, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime,
WeightToFee, XcmpQueue,
AccountId, Balances, Origin, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall,
RuntimeEvent, WeightToFee, XcmpQueue,
};
use core::marker::PhantomData;
use frame_support::{
Expand Down Expand Up @@ -100,9 +100,9 @@ where
Deny: ShouldExecute,
Allow: ShouldExecute,
{
fn should_execute<Call>(
fn should_execute<RuntimeCall>(
origin: &MultiLocation,
message: &mut Xcm<Call>,
message: &mut Xcm<RuntimeCall>,
max_weight: XCMWeight,
weight_credit: &mut XCMWeight,
) -> Result<(), ()> {
Expand All @@ -114,9 +114,10 @@ where
// See issue #5233
pub struct DenyReserveTransferToRelayChain;
impl ShouldExecute for DenyReserveTransferToRelayChain {
fn should_execute<Call>(
fn should_execute<RuntimeCall>(
origin: &MultiLocation,
message: &mut Xcm<Call>,

message: &mut Xcm<RuntimeCall>,
_max_weight: XCMWeight,
_weight_credit: &mut XCMWeight,
) -> Result<(), ()> {
Expand Down Expand Up @@ -163,7 +164,7 @@ pub type Barrier = DenyThenTry<

pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
type Call = Call;
type RuntimeCall = RuntimeCall;
type XcmSender = XcmRouter;
// How to withdraw and deposit an asset.
type AssetTransactor = LocalAssetTransactor;
Expand All @@ -172,7 +173,7 @@ impl xcm_executor::Config for XcmConfig {
type IsTeleporter = (); // Teleporting is disabled.
type LocationInverter = LocationInverter<Ancestry>;
type Barrier = Barrier;
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
type Trader =
UsingComponents<WeightToFee, RelayLocation, AccountId, Balances, ToAuthor<Runtime>>;
type ResponseHandler = PolkadotXcm;
Expand All @@ -194,7 +195,7 @@ pub type XcmRouter = (
);

impl pallet_xcm::Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
type XcmRouter = XcmRouter;
type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
Expand All @@ -204,17 +205,17 @@ impl pallet_xcm::Config for Runtime {
type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Everything;
type XcmReserveTransferFilter = Nothing;
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin;
type Call = Call;
type RuntimeCall = RuntimeCall;

const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
// ^ Override for AdvertisedXcmVersion default
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
}

impl cumulus_pallet_xcm::Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type XcmExecutor = XcmExecutor<XcmConfig>;
}
12 changes: 6 additions & 6 deletions cumulus/parachains/common/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ where
R: pallet_balances::Config + pallet_collator_selection::Config,
AccountIdOf<R>:
From<polkadot_primitives::v2::AccountId> + Into<polkadot_primitives::v2::AccountId>,
<R as frame_system::Config>::Event: From<pallet_balances::Event<R>>,
<R as frame_system::Config>::RuntimeEvent: From<pallet_balances::Event<R>>,
{
fn on_nonzero_unbalanced(amount: NegativeImbalance<R>) {
let staking_pot = <pallet_collator_selection::Pallet<R>>::account_id();
Expand All @@ -57,7 +57,7 @@ where
R: pallet_balances::Config + pallet_collator_selection::Config,
AccountIdOf<R>:
From<polkadot_primitives::v2::AccountId> + Into<polkadot_primitives::v2::AccountId>,
<R as frame_system::Config>::Event: From<pallet_balances::Event<R>>,
<R as frame_system::Config>::RuntimeEvent: From<pallet_balances::Event<R>>,
{
fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance<R>>) {
if let Some(mut fees) = fees_then_tips.next() {
Expand Down Expand Up @@ -156,13 +156,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 = ();
Expand All @@ -180,7 +180,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 Down Expand Up @@ -215,7 +215,7 @@ mod tests {
}

impl pallet_collator_selection::Config for Test {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type UpdateOrigin = EnsureRoot<AccountId>;
type PotId = PotId;
Expand Down
8 changes: 4 additions & 4 deletions cumulus/parachains/common/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ where
Deny: ShouldExecute,
Allow: ShouldExecute,
{
fn should_execute<Call>(
fn should_execute<RuntimeCall>(
origin: &MultiLocation,
message: &mut Xcm<Call>,
message: &mut Xcm<RuntimeCall>,
max_weight: XCMWeight,
weight_credit: &mut XCMWeight,
) -> Result<(), ()> {
Expand All @@ -36,9 +36,9 @@ where
// See issue #5233
pub struct DenyReserveTransferToRelayChain;
impl ShouldExecute for DenyReserveTransferToRelayChain {
fn should_execute<Call>(
fn should_execute<RuntimeCall>(
origin: &MultiLocation,
message: &mut Xcm<Call>,
message: &mut Xcm<RuntimeCall>,
_max_weight: XCMWeight,
_weight_credit: &mut XCMWeight,
) -> Result<(), ()> {
Expand Down
8 changes: 4 additions & 4 deletions cumulus/parachains/pallets/ping/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ 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 Origin: From<<Self as SystemConfig>::Origin>
+ Into<Result<CumulusOrigin, <Self as Config>::Origin>>;

/// The overarching call type; we assume sibling chains use the same type.
type Call: From<Call<Self>> + Encode;
type RuntimeCall: From<Call<Self>> + Encode;

type XcmSender: SendXcm;
}
Expand Down Expand Up @@ -108,7 +108,7 @@ pub mod pallet {
Xcm(vec![Transact {
origin_type: OriginKind::Native,
require_weight_at_most: 1_000,
call: <T as Config>::Call::from(Call::<T>::ping {
call: <T as Config>::RuntimeCall::from(Call::<T>::ping {
seq,
payload: payload.clone().to_vec(),
})
Expand Down Expand Up @@ -198,7 +198,7 @@ pub mod pallet {
Xcm(vec![Transact {
origin_type: OriginKind::Native,
require_weight_at_most: 1_000,
call: <T as Config>::Call::from(Call::<T>::pong {
call: <T as Config>::RuntimeCall::from(Call::<T>::pong {
seq,
payload: payload.clone(),
})
Expand Down
Loading

0 comments on commit d3fb9de

Please sign in to comment.