Companion for #11981 (#5915)

* 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>
This commit is contained in:
Sergej Sakac
2022-09-13 01:03:47 +02:00
committed by GitHub
parent db0fc60344
commit 8ea6076fe5
73 changed files with 1241 additions and 1151 deletions
+3 -3
View File
@@ -27,7 +27,7 @@ use xcm::latest::SendXcm;
/// The trait to parameterize the `XcmExecutor`.
pub trait Config {
/// The outer call dispatch type.
type Call: Parameter + Dispatchable<PostInfo = PostDispatchInfo> + GetDispatchInfo;
type RuntimeCall: Parameter + Dispatchable<PostInfo = PostDispatchInfo> + GetDispatchInfo;
/// How to send an onward XCM message.
type XcmSender: SendXcm;
@@ -36,7 +36,7 @@ pub trait Config {
type AssetTransactor: TransactAsset;
/// How to get a call origin from a `OriginKind` value.
type OriginConverter: ConvertOrigin<<Self::Call as Dispatchable>::Origin>;
type OriginConverter: ConvertOrigin<<Self::RuntimeCall as Dispatchable>::Origin>;
/// Combinations of (Location, Asset) pairs which we trust as reserves.
type IsReserve: FilterAssetLocation;
@@ -51,7 +51,7 @@ pub trait Config {
type Barrier: ShouldExecute;
/// The means of determining an XCM message's weight.
type Weigher: WeightBounds<Self::Call>;
type Weigher: WeightBounds<Self::RuntimeCall>;
/// The means of purchasing weight credit for XCM execution.
type Trader: WeightTrader;
+14 -11
View File
@@ -51,9 +51,9 @@ pub struct XcmExecutor<Config: config::Config> {
/// the weight of dynamically determined instructions such as `Transact`).
pub total_surplus: u64,
pub total_refunded: u64,
pub error_handler: Xcm<Config::Call>,
pub error_handler: Xcm<Config::RuntimeCall>,
pub error_handler_weight: u64,
pub appendix: Xcm<Config::Call>,
pub appendix: Xcm<Config::RuntimeCall>,
pub appendix_weight: u64,
_config: PhantomData<Config>,
}
@@ -61,10 +61,10 @@ pub struct XcmExecutor<Config: config::Config> {
/// The maximum recursion limit for `execute_xcm` and `execute_effects`.
pub const MAX_RECURSION_LIMIT: u32 = 8;
impl<Config: config::Config> ExecuteXcm<Config::Call> for XcmExecutor<Config> {
impl<Config: config::Config> ExecuteXcm<Config::RuntimeCall> for XcmExecutor<Config> {
fn execute_xcm_in_credit(
origin: impl Into<MultiLocation>,
mut message: Xcm<Config::Call>,
mut message: Xcm<Config::RuntimeCall>,
weight_limit: Weight,
mut weight_credit: Weight,
) -> Outcome {
@@ -180,7 +180,7 @@ impl<Config: config::Config> XcmExecutor<Config> {
/// Execute the XCM program fragment and report back the error and which instruction caused it,
/// or `Ok` if there was no error.
pub fn execute(&mut self, xcm: Xcm<Config::Call>) -> Result<(), ExecutorError> {
pub fn execute(&mut self, xcm: Xcm<Config::RuntimeCall>) -> Result<(), ExecutorError> {
log::trace!(
target: "xcm::execute",
"origin: {:?}, total_surplus/refunded: {:?}/{:?}, error_handler_weight: {:?}",
@@ -231,8 +231,8 @@ impl<Config: config::Config> XcmExecutor<Config> {
}
/// Remove the registered error handler and return it. Do not refund its weight.
fn take_error_handler(&mut self) -> Xcm<Config::Call> {
let mut r = Xcm::<Config::Call>(vec![]);
fn take_error_handler(&mut self) -> Xcm<Config::RuntimeCall> {
let mut r = Xcm::<Config::RuntimeCall>(vec![]);
sp_std::mem::swap(&mut self.error_handler, &mut r);
self.error_handler_weight = 0;
r
@@ -240,14 +240,14 @@ impl<Config: config::Config> XcmExecutor<Config> {
/// Drop the registered error handler and refund its weight.
fn drop_error_handler(&mut self) {
self.error_handler = Xcm::<Config::Call>(vec![]);
self.error_handler = Xcm::<Config::RuntimeCall>(vec![]);
self.total_surplus.saturating_accrue(self.error_handler_weight);
self.error_handler_weight = 0;
}
/// Remove the registered appendix and return it.
fn take_appendix(&mut self) -> Xcm<Config::Call> {
let mut r = Xcm::<Config::Call>(vec![]);
fn take_appendix(&mut self) -> Xcm<Config::RuntimeCall> {
let mut r = Xcm::<Config::RuntimeCall>(vec![]);
sp_std::mem::swap(&mut self.appendix, &mut r);
self.appendix_weight = 0;
r
@@ -265,7 +265,10 @@ impl<Config: config::Config> XcmExecutor<Config> {
}
/// Process a single XCM instruction, mutating the state of the XCM virtual machine.
fn process_instruction(&mut self, instr: Instruction<Config::Call>) -> Result<(), XcmError> {
fn process_instruction(
&mut self,
instr: Instruction<Config::RuntimeCall>,
) -> Result<(), XcmError> {
match instr {
WithdrawAsset(assets) => {
// Take `assets` from the origin account (on-chain) and place in holding.
@@ -30,9 +30,9 @@ pub trait ShouldExecute {
/// - `weight_credit`: The pre-established amount of weight that the system has determined this
/// message may utilize in its execution. Typically non-zero only because of prior fee
/// payment, but could in principle be due to other factors.
fn should_execute<Call>(
fn should_execute<RuntimeCall>(
origin: &MultiLocation,
message: &mut Xcm<Call>,
message: &mut Xcm<RuntimeCall>,
max_weight: Weight,
weight_credit: &mut Weight,
) -> Result<(), ()>;
@@ -40,9 +40,9 @@ pub trait ShouldExecute {
#[impl_trait_for_tuples::impl_for_tuples(30)]
impl ShouldExecute for Tuple {
fn should_execute<Call>(
fn should_execute<RuntimeCall>(
origin: &MultiLocation,
message: &mut Xcm<Call>,
message: &mut Xcm<RuntimeCall>,
max_weight: Weight,
weight_credit: &mut Weight,
) -> Result<(), ()> {
@@ -19,14 +19,14 @@ use sp_std::result::Result;
use xcm::latest::{prelude::*, Weight};
/// Determine the weight of an XCM message.
pub trait WeightBounds<Call> {
pub trait WeightBounds<RuntimeCall> {
/// Return the maximum amount of weight that an attempted execution of this message could
/// consume.
fn weight(message: &mut Xcm<Call>) -> Result<Weight, ()>;
fn weight(message: &mut Xcm<RuntimeCall>) -> Result<Weight, ()>;
/// Return the maximum amount of weight that an attempted execution of this instruction could
/// consume.
fn instr_weight(instruction: &Instruction<Call>) -> Result<Weight, ()>;
fn instr_weight(instruction: &Instruction<RuntimeCall>) -> Result<Weight, ()>;
}
/// A means of getting approximate weight consumption for a given destination message executor and a