BREAKING: Rename Call & Event (#11981)

* rename Event to RuntimeEvent

* rename Call

* rename in runtimes

* small fix

* rename Event

* small fix & rename RuntimeCall back to Call for now

* small fixes

* more renaming

* a bit more renaming

* fmt

* small fix

* commit

* prep for renaming associated types

* fix

* rename associated Event type

* rename to RuntimeEvent

* commit

* merge conflict fixes & fmt

* additional renaming

* fix.

* fix decl_event

* rename in tests

* remove warnings

* remove accidental rename

* .

* commit

* update .stderr

* fix in test

* update .stderr

* TRYBUILD=overwrite

* docs

* fmt

* small change in docs

* rename PalletEvent to Event

* rename Call to RuntimeCall

* renamed at wrong places :P

* rename Call

* rename

* rename associated type

* fix

* fix & fmt

* commit

* frame-support-test

* passing tests

* update docs

* rustdoc fix

* update .stderr

* wrong code in docs

* merge fix

* fix in error message

* update .stderr

* docs & error message

* .

* merge fix

* merge fix

* fmt

* fmt

* merge fix

* more fixing

* fmt

* remove unused

* fmt

* fix

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
Sergej Sakac
2022-09-13 00:03:31 +02:00
committed by GitHub
parent 472b5746e5
commit 6e8795afe6
228 changed files with 1791 additions and 1672 deletions
@@ -54,7 +54,7 @@ impl<T: Config + Send + Sync> CheckGenesis<T> {
impl<T: Config + Send + Sync> SignedExtension for CheckGenesis<T> {
type AccountId = T::AccountId;
type Call = <T as Config>::Call;
type Call = <T as Config>::RuntimeCall;
type AdditionalSigned = T::Hash;
type Pre = ();
const IDENTIFIER: &'static str = "CheckGenesis";
@@ -56,7 +56,7 @@ impl<T: Config + Send + Sync> sp_std::fmt::Debug for CheckMortality<T> {
impl<T: Config + Send + Sync> SignedExtension for CheckMortality<T> {
type AccountId = T::AccountId;
type Call = T::Call;
type Call = T::RuntimeCall;
type AdditionalSigned = T::Hash;
type Pre = ();
const IDENTIFIER: &'static str = "CheckMortality";
@@ -53,10 +53,10 @@ impl<T: Config + Send + Sync> CheckNonZeroSender<T> {
impl<T: Config + Send + Sync> SignedExtension for CheckNonZeroSender<T>
where
T::Call: Dispatchable<Info = DispatchInfo>,
T::RuntimeCall: Dispatchable<Info = DispatchInfo>,
{
type AccountId = T::AccountId;
type Call = T::Call;
type Call = T::RuntimeCall;
type AdditionalSigned = ();
type Pre = ();
const IDENTIFIER: &'static str = "CheckNonZeroSender";
@@ -60,10 +60,10 @@ impl<T: Config> sp_std::fmt::Debug for CheckNonce<T> {
impl<T: Config> SignedExtension for CheckNonce<T>
where
T::Call: Dispatchable<Info = DispatchInfo>,
T::RuntimeCall: Dispatchable<Info = DispatchInfo>,
{
type AccountId = T::AccountId;
type Call = T::Call;
type Call = T::RuntimeCall;
type AdditionalSigned = ();
type Pre = ();
const IDENTIFIER: &'static str = "CheckNonce";
@@ -54,7 +54,7 @@ impl<T: Config + Send + Sync> CheckSpecVersion<T> {
impl<T: Config + Send + Sync> SignedExtension for CheckSpecVersion<T> {
type AccountId = T::AccountId;
type Call = <T as Config>::Call;
type Call = <T as Config>::RuntimeCall;
type AdditionalSigned = u32;
type Pre = ();
const IDENTIFIER: &'static str = "CheckSpecVersion";
@@ -54,7 +54,7 @@ impl<T: Config + Send + Sync> CheckTxVersion<T> {
impl<T: Config + Send + Sync> SignedExtension for CheckTxVersion<T> {
type AccountId = T::AccountId;
type Call = <T as Config>::Call;
type Call = <T as Config>::RuntimeCall;
type AdditionalSigned = u32;
type Pre = ();
const IDENTIFIER: &'static str = "CheckTxVersion";
@@ -40,12 +40,12 @@ pub struct CheckWeight<T: Config + Send + Sync>(sp_std::marker::PhantomData<T>);
impl<T: Config + Send + Sync> CheckWeight<T>
where
T::Call: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
T::RuntimeCall: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
{
/// Checks if the current extrinsic does not exceed the maximum weight a single extrinsic
/// with given `DispatchClass` can have.
fn check_extrinsic_weight(
info: &DispatchInfoOf<T::Call>,
info: &DispatchInfoOf<T::RuntimeCall>,
) -> Result<(), TransactionValidityError> {
let max = T::BlockWeights::get().get(info.class).max_extrinsic;
match max {
@@ -59,18 +59,18 @@ where
///
/// Upon successes, it returns the new block weight as a `Result`.
fn check_block_weight(
info: &DispatchInfoOf<T::Call>,
info: &DispatchInfoOf<T::RuntimeCall>,
) -> Result<crate::ConsumedWeight, TransactionValidityError> {
let maximum_weight = T::BlockWeights::get();
let all_weight = Pallet::<T>::block_weight();
calculate_consumed_weight::<T::Call>(maximum_weight, all_weight, info)
calculate_consumed_weight::<T::RuntimeCall>(maximum_weight, all_weight, info)
}
/// Checks if the current extrinsic can fit into the block with respect to block length limits.
///
/// Upon successes, it returns the new block length as a `Result`.
fn check_block_length(
info: &DispatchInfoOf<T::Call>,
info: &DispatchInfoOf<T::RuntimeCall>,
len: usize,
) -> Result<u32, TransactionValidityError> {
let length_limit = T::BlockLength::get();
@@ -93,7 +93,7 @@ where
///
/// It checks and notes the new weight and length.
pub fn do_pre_dispatch(
info: &DispatchInfoOf<T::Call>,
info: &DispatchInfoOf<T::RuntimeCall>,
len: usize,
) -> Result<(), TransactionValidityError> {
let next_len = Self::check_block_length(info, len)?;
@@ -108,7 +108,7 @@ where
/// Do the validate checks. This can be applied to both signed and unsigned.
///
/// It only checks that the block weight and length limit will not exceed.
pub fn do_validate(info: &DispatchInfoOf<T::Call>, len: usize) -> TransactionValidity {
pub fn do_validate(info: &DispatchInfoOf<T::RuntimeCall>, len: usize) -> TransactionValidity {
// ignore the next length. If they return `Ok`, then it is below the limit.
let _ = Self::check_block_length(info, len)?;
// during validation we skip block limit check. Since the `validate_transaction`
@@ -170,10 +170,10 @@ where
impl<T: Config + Send + Sync> SignedExtension for CheckWeight<T>
where
T::Call: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
T::RuntimeCall: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
{
type AccountId = T::AccountId;
type Call = T::Call;
type Call = T::RuntimeCall;
type AdditionalSigned = ();
type Pre = ();
const IDENTIFIER: &'static str = "CheckWeight";
@@ -713,13 +713,13 @@ mod tests {
};
// when
assert_ok!(calculate_consumed_weight::<<Test as Config>::Call>(
assert_ok!(calculate_consumed_weight::<<Test as Config>::RuntimeCall>(
maximum_weight.clone(),
all_weight.clone(),
&mandatory1
));
assert_err!(
calculate_consumed_weight::<<Test as Config>::Call>(
calculate_consumed_weight::<<Test as Config>::RuntimeCall>(
maximum_weight,
all_weight,
&mandatory2
+13 -13
View File
@@ -205,7 +205,7 @@ pub mod pallet {
pub trait Config: 'static + Eq + Clone {
/// The basic call filter to use in Origin. All origins are built with this filter as base,
/// except Root.
type BaseCallFilter: Contains<Self::Call>;
type BaseCallFilter: Contains<Self::RuntimeCall>;
/// Block & extrinsics weights: base values and limits.
#[pallet::constant]
@@ -219,10 +219,10 @@ pub mod pallet {
type Origin: Into<Result<RawOrigin<Self::AccountId>, Self::Origin>>
+ From<RawOrigin<Self::AccountId>>
+ Clone
+ OriginTrait<Call = Self::Call>;
+ OriginTrait<Call = Self::RuntimeCall>;
/// The aggregated `Call` type.
type Call: Dispatchable + Debug;
/// The aggregated `RuntimeCall` type.
type RuntimeCall: Dispatchable + Debug;
/// Account index (aka nonce) type. This stores the number of previous transactions
/// associated with a sender account.
@@ -293,11 +293,11 @@ pub mod pallet {
type Header: Parameter + traits::Header<Number = Self::BlockNumber, Hash = Self::Hash>;
/// The aggregated event type of the runtime.
type Event: Parameter
type RuntimeEvent: Parameter
+ Member
+ From<Event<Self>>
+ Debug
+ IsType<<Self as frame_system::Config>::Event>;
+ IsType<<Self as frame_system::Config>::RuntimeEvent>;
/// Maximum number of block number to block hash mappings to keep (oldest pruned first).
#[pallet::constant]
@@ -608,7 +608,7 @@ pub mod pallet {
#[pallet::storage]
#[pallet::unbounded]
pub(super) type Events<T: Config> =
StorageValue<_, Vec<Box<EventRecord<T::Event, T::Hash>>>, ValueQuery>;
StorageValue<_, Vec<Box<EventRecord<T::RuntimeEvent, T::Hash>>>, ValueQuery>;
/// The number of events in the `Events<T>` list.
#[pallet::storage]
@@ -1216,7 +1216,7 @@ impl<T: Config> Pallet<T> {
}
/// Deposits an event into this block's event record.
pub fn deposit_event(event: impl Into<T::Event>) {
pub fn deposit_event(event: impl Into<T::RuntimeEvent>) {
Self::deposit_event_indexed(&[], event.into());
}
@@ -1225,7 +1225,7 @@ impl<T: Config> Pallet<T> {
///
/// This will update storage entries that correspond to the specified topics.
/// It is expected that light-clients could subscribe to this topics.
pub fn deposit_event_indexed(topics: &[T::Hash], event: T::Event) {
pub fn deposit_event_indexed(topics: &[T::Hash], event: T::RuntimeEvent) {
let block_number = Self::block_number();
// Don't populate events on genesis.
if block_number.is_zero() {
@@ -1415,7 +1415,7 @@ impl<T: Config> Pallet<T> {
/// impact on the PoV size of a block. Users should use alternative and well bounded storage
/// items for any behavior like this.
#[cfg(any(feature = "std", feature = "runtime-benchmarks", test))]
pub fn events() -> Vec<EventRecord<T::Event, T::Hash>> {
pub fn events() -> Vec<EventRecord<T::RuntimeEvent, T::Hash>> {
// Dereferencing the events here is fine since we are not in the
// memory-restricted runtime.
Self::read_events_no_consensus().into_iter().map(|e| *e).collect()
@@ -1425,7 +1425,7 @@ impl<T: Config> Pallet<T> {
///
/// Should only be called if you know what you are doing and outside of the runtime block
/// execution else it can have a large impact on the PoV size of a block.
pub fn read_events_no_consensus() -> Vec<Box<EventRecord<T::Event, T::Hash>>> {
pub fn read_events_no_consensus() -> Vec<Box<EventRecord<T::RuntimeEvent, T::Hash>>> {
Events::<T>::get()
}
@@ -1470,13 +1470,13 @@ impl<T: Config> Pallet<T> {
/// Assert the given `event` exists.
#[cfg(any(feature = "std", feature = "runtime-benchmarks", test))]
pub fn assert_has_event(event: T::Event) {
pub fn assert_has_event(event: T::RuntimeEvent) {
assert!(Self::events().iter().any(|record| record.event == event))
}
/// Assert the last event equal to the given `event`.
#[cfg(any(feature = "std", feature = "runtime-benchmarks", test))]
pub fn assert_last_event(event: T::Event) {
pub fn assert_last_event(event: T::RuntimeEvent) {
assert_eq!(Self::events().last().expect("events expected").event, event);
}
+4 -4
View File
@@ -94,7 +94,7 @@ impl Config for Test {
type BlockWeights = RuntimeBlockWeights;
type BlockLength = RuntimeBlockLength;
type Origin = Origin;
type Call = Call;
type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = u64;
type Hash = H256;
@@ -102,7 +102,7 @@ impl Config for Test {
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = ConstU64<10>;
type DbWeight = DbWeight;
type Version = Version;
@@ -119,8 +119,8 @@ impl Config for Test {
pub type SysEvent = frame_system::Event<Test>;
/// A simple call, which one doesn't matter.
pub const CALL: &<Test as Config>::Call =
&Call::System(frame_system::Call::set_heap_pages { pages: 0u64 });
pub const CALL: &<Test as Config>::RuntimeCall =
&RuntimeCall::System(frame_system::Call::set_heap_pages { pages: 0u64 });
/// Create new externalities for `System` module tests.
pub fn new_test_ext() -> sp_io::TestExternalities {
+1 -1
View File
@@ -22,7 +22,7 @@ use sp_runtime::generic;
/// An unchecked extrinsic type to be used in tests.
pub type MockUncheckedExtrinsic<T, Signature = (), Extra = ()> = generic::UncheckedExtrinsic<
<T as crate::Config>::AccountId,
<T as crate::Config>::Call,
<T as crate::Config>::RuntimeCall,
Signature,
Extra,
>;
+4 -4
View File
@@ -617,7 +617,7 @@ pub trait SignedPayload<T: SigningTypes>: Encode {
#[cfg(test)]
mod tests {
use super::*;
use crate::mock::{Call, Test as TestRuntime, CALL};
use crate::mock::{RuntimeCall, Test as TestRuntime, CALL};
use codec::Decode;
use sp_core::offchain::{testing, TransactionPoolExt};
use sp_runtime::testing::{TestSignature, TestXt, UintAuthorityId};
@@ -627,11 +627,11 @@ mod tests {
type Signature = TestSignature;
}
type Extrinsic = TestXt<Call, ()>;
type Extrinsic = TestXt<RuntimeCall, ()>;
impl SendTransactionTypes<Call> for TestRuntime {
impl SendTransactionTypes<RuntimeCall> for TestRuntime {
type Extrinsic = Extrinsic;
type OverarchingCall = Call;
type OverarchingCall = RuntimeCall;
}
#[derive(codec::Encode, codec::Decode)]