mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 05:17:58 +00:00
XCM v3 Companion (#697)
* Fixes * Undiener * Undiener * Undiener * Lockfile * Changes for send returning hash * Include message ID as params to execute_xcm * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Companion fixes * Formatting * Fixes * Formatting * Bump * Bump * Fixes * Formatting * Make the price of UMP/XCMP message sending configurable * cargo fmt * Remove InvertLocation * Formatting * Use ConstantPrice from polkadot-runtime-common * Fix naming * cargo fmt * Fixes * Fixes * Fixes * Add CallDispatcher * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Remove unused import * Remove unused import * XCMv3 fixes (#1710) * Fixes XCMv3 related Fixes XCMv3 (removed query_holding) Fixes XCMv3 - should use _depositable_count? Fixes XCMv3 - removed TrustedReserve Fixes - missing weights for statemine/statemint/westmint [DO-NOT-CHERRY-PICK] tmp return query_holding to aviod conficts to master Fixes - missing functions for pallet_xcm_benchmarks::generic::Config Fixes for XCMv3 benchmarking Fix xcm - removed query_holding * ".git/.scripts/bench-bot.sh" xcm statemine assets pallet_xcm_benchmarks::generic * ".git/.scripts/bench-bot.sh" xcm statemint assets pallet_xcm_benchmarks::generic * ".git/.scripts/bench-bot.sh" xcm westmint assets pallet_xcm_benchmarks::generic * Fix imports * Avoid consuming XCM message for NotApplicable scenario (#1787) * Avoid consuming message for NotApplicable scenario * Avoid consuming message for NotApplicable scenario tests * Add 10 message processing limit to DMP queue * Add 10 message limit to XCMP queue * Always increment the message_processed count whenever a message is processed * Fix formatting * Set an upper limit to the overweight message DMP queue * Add upper limit to XCMP overweight message queue * Fix for missing weight for `fn unpaid_execution()` * Fix - usage of `messages_processed` * Fixes * Fixes * Fixes * cargo fmt * Fixes * Fixes * Fixes * Fixes * Remove unused import * Fixes for gav-xcm-v3 (#1835) * Fix for FungiblesAdapter - trait changes: Contains -> AssetChecking * Fix for missing weight for `fn unpaid_execution()` * Used NonLocalMint for all NonZeroIssuance * Fix * Fixes * Fixes * Fixes * Fixes * Fixes * Fix tests * Fixes * Add SafeCallFilter * Add missing config items * Add TODO * Use () as the PriceForParentDelivery * Fixes * Fixes * Fixes * Fixes * Update transact_origin to transact_origin_and_runtime_call * Add ReachableDest config item to XCM pallet * Update SafeCallFilter to allow remark_with_event in runtime benchmarks * cargo fmt * Update substrate * Fix worst_case_holding * Fix DMQ queue unit tests * Remove unused label * cargo fmt * Actually process incoming XCMs * Fixes * Fixes * Fixes * Fixes - return back Weightless * Added measured benchmarks for `pallet_xcm` (#1968) * Fix Fix Fix * Fix * Fixes for transact benchmark * Fixes add pallet_xcm to benchmarks * Revert remark_with_event * ".git/.scripts/bench-bot.sh" xcm statemine assets pallet_xcm_benchmarks::generic * Fixes * TMP * Fix for reserve_asset_deposited * ".git/.scripts/bench-bot.sh" pallet statemine assets pallet_xcm * Fix * ".git/.scripts/bench-bot.sh" pallet statemint assets pallet_xcm * Fix * ".git/.scripts/bench-bot.sh" pallet westmint assets pallet_xcm * Fix westmint * ".git/.scripts/bench-bot.sh" xcm statemine assets pallet_xcm_benchmarks::generic * Fix * ".git/.scripts/bench-bot.sh" xcm westmint assets pallet_xcm_benchmarks::generic * ".git/.scripts/bench-bot.sh" xcm statemint assets pallet_xcm_benchmarks::generic * ".git/.scripts/bench-bot.sh" pallet collectives-polkadot collectives pallet_xcm * Fix for collectives * ".git/.scripts/bench-bot.sh" pallet bridge-hub-kusama bridge-hubs pallet_xcm * ".git/.scripts/bench-bot.sh" pallet bridge-hub-rococo bridge-hubs pallet_xcm * Fixes for bridge-hubs * Fixes - return back Weightless * Fix - removed MigrateToTrackInactive for contracts-rococo Co-authored-by: command-bot <> * cargo fmt * Fix benchmarks * Bko gav xcm v3 (#1993) * Fix * ".git/.scripts/bench-bot.sh" xcm statemint assets pallet_xcm_benchmarks::fungible * ".git/.scripts/bench-bot.sh" xcm statemine assets pallet_xcm_benchmarks::fungible * ".git/.scripts/bench-bot.sh" xcm westmint assets pallet_xcm_benchmarks::fungible * ".git/.scripts/bench-bot.sh" xcm statemine assets pallet_xcm_benchmarks::generic * ".git/.scripts/bench-bot.sh" xcm statemint assets pallet_xcm_benchmarks::generic * ".git/.scripts/bench-bot.sh" xcm westmint assets pallet_xcm_benchmarks::generic * ".git/.scripts/bench-bot.sh" pallet statemine assets pallet_xcm * ".git/.scripts/bench-bot.sh" pallet westmint assets pallet_xcm * ".git/.scripts/bench-bot.sh" pallet statemint assets pallet_xcm * ".git/.scripts/bench-bot.sh" pallet collectives-polkadot collectives pallet_xcm * ".git/.scripts/bench-bot.sh" pallet bridge-hub-kusama bridge-hubs pallet_xcm * ".git/.scripts/bench-bot.sh" pallet bridge-hub-rococo bridge-hubs pallet_xcm Co-authored-by: command-bot <> * Change AllowUnpaidExecutionFrom to be explicit * xcm-v3 benchmarks, weights, fixes for bridge-hubs (#2035) * Dumy weights to get compile * Change UniversalLocation according to https://github.com/paritytech/polkadot/pull/4097 (Location Inversion Removed) * Fix bridge-hubs weights * ".git/.scripts/bench-bot.sh" pallet statemine assets pallet_xcm * ".git/.scripts/bench-bot.sh" pallet statemint assets pallet_xcm * ".git/.scripts/bench-bot.sh" pallet collectives-polkadot collectives pallet_xcm * ".git/.scripts/bench-bot.sh" pallet westmint assets pallet_xcm * ".git/.scripts/bench-bot.sh" xcm bridge-hub-kusama bridge-hubs pallet_xcm_benchmarks::generic * ".git/.scripts/bench-bot.sh" xcm bridge-hub-kusama bridge-hubs pallet_xcm_benchmarks::fungible * ".git/.scripts/bench-bot.sh" pallet bridge-hub-kusama bridge-hubs pallet_xcm * ".git/.scripts/bench-bot.sh" pallet bridge-hub-rococo bridge-hubs pallet_xcm * ".git/.scripts/bench-bot.sh" xcm bridge-hub-rococo bridge-hubs pallet_xcm_benchmarks::fungible * ".git/.scripts/bench-bot.sh" xcm bridge-hub-rococo bridge-hubs pallet_xcm_benchmarks::generic * Change NetworkId to Option<NetworkId> Co-authored-by: command-bot <> Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> * Add event for showing the hash of an UMP sent message (#1228) * Add UpwardMessageSent event in parachain-system * additional fixes * Message Id * Fix errors from merge * fmt * more fmt * Remove todo * more formatting * Fixes * Fixes * Fixes * Fixes * Allow explicit unpaid executions from the relay chains for system parachains (#2060) * Allow explicit unpaid executions from the relay chains for system parachains * Put origin-filtering barriers into WithComputedOrigin * Use ConstU32<8> * Small nits * formatting * cargo fmt * Allow receiving XCMs from any relay chain plurality * Fixes * update lockfile for {"polkadot", "substrate"} * Update polkadot * Add runtime-benchmarks feature Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> Co-authored-by: Branislav Kontur <bkontur@gmail.com> Co-authored-by: girazoki <gorka.irazoki@gmail.com> Co-authored-by: parity-processbot <>
This commit is contained in:
Generated
+273
-255
File diff suppressed because it is too large
Load Diff
@@ -33,13 +33,16 @@ pub use pallet::*;
|
||||
use scale_info::TypeInfo;
|
||||
use sp_runtime::RuntimeDebug;
|
||||
use sp_std::{convert::TryFrom, prelude::*};
|
||||
use xcm::{
|
||||
latest::{prelude::*, Weight as XcmWeight},
|
||||
VersionedXcm, MAX_XCM_DECODE_DEPTH,
|
||||
};
|
||||
use xcm::{latest::prelude::*, VersionedXcm, MAX_XCM_DECODE_DEPTH};
|
||||
|
||||
const DEFAULT_POV_SIZE: u64 = 64 * 1024; // 64 KB
|
||||
|
||||
// Maximum amount of messages to process per block. This is a temporary measure until we properly
|
||||
// account for proof size weights.
|
||||
const MAX_MESSAGES_PER_BLOCK: u8 = 10;
|
||||
// Maximum amount of messages that can exist in the overweight queue at any given time.
|
||||
const MAX_OVERWEIGHT_MESSAGES: u32 = 1000;
|
||||
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)]
|
||||
pub struct ConfigData {
|
||||
/// The maximum amount of weight any individual message may consume. Messages above this weight
|
||||
@@ -119,8 +122,13 @@ pub mod pallet {
|
||||
|
||||
/// The overweight messages.
|
||||
#[pallet::storage]
|
||||
pub(super) type Overweight<T> =
|
||||
StorageMap<_, Blake2_128Concat, OverweightIndex, (RelayBlockNumber, Vec<u8>), OptionQuery>;
|
||||
pub(super) type Overweight<T> = CountedStorageMap<
|
||||
_,
|
||||
Blake2_128Concat,
|
||||
OverweightIndex,
|
||||
(RelayBlockNumber, Vec<u8>),
|
||||
OptionQuery,
|
||||
>;
|
||||
|
||||
#[pallet::error]
|
||||
pub enum Error<T> {
|
||||
@@ -145,30 +153,18 @@ pub mod pallet {
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
/// Service a single overweight message.
|
||||
///
|
||||
/// - `origin`: Must pass `ExecuteOverweightOrigin`.
|
||||
/// - `index`: The index of the overweight message to service.
|
||||
/// - `weight_limit`: The amount of weight that message execution may take.
|
||||
///
|
||||
/// Errors:
|
||||
/// - `Unknown`: Message of `index` is unknown.
|
||||
/// - `OverLimit`: Message execution may use greater than `weight_limit`.
|
||||
///
|
||||
/// Events:
|
||||
/// - `OverweightServiced`: On success.
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight(Weight::from_ref_time(weight_limit.saturating_add(1_000_000)))]
|
||||
#[pallet::weight(weight_limit.saturating_add(Weight::from_ref_time(1_000_000)))]
|
||||
pub fn service_overweight(
|
||||
origin: OriginFor<T>,
|
||||
index: OverweightIndex,
|
||||
weight_limit: XcmWeight,
|
||||
weight_limit: Weight,
|
||||
) -> DispatchResultWithPostInfo {
|
||||
T::ExecuteOverweightOrigin::ensure_origin(origin)?;
|
||||
|
||||
let (sent_at, data) = Overweight::<T>::get(index).ok_or(Error::<T>::Unknown)?;
|
||||
let weight_used =
|
||||
Self::try_service_message(Weight::from_ref_time(weight_limit), sent_at, &data[..])
|
||||
.map_err(|_| Error::<T>::OverLimit)?;
|
||||
let weight_used = Self::try_service_message(weight_limit, sent_at, &data[..])
|
||||
.map_err(|_| Error::<T>::OverLimit)?;
|
||||
Overweight::<T>::remove(index);
|
||||
Self::deposit_event(Event::OverweightServiced { overweight_index: index, weight_used });
|
||||
Ok(Some(weight_used.saturating_add(Weight::from_ref_time(1_000_000))).into())
|
||||
@@ -201,16 +197,29 @@ pub mod pallet {
|
||||
///
|
||||
/// Returns the weight consumed by executing messages in the queue.
|
||||
fn service_queue(limit: Weight) -> Weight {
|
||||
PageIndex::<T>::mutate(|page_index| Self::do_service_queue(limit, page_index))
|
||||
let mut messages_processed = 0;
|
||||
PageIndex::<T>::mutate(|page_index| {
|
||||
Self::do_service_queue(limit, page_index, &mut messages_processed)
|
||||
})
|
||||
}
|
||||
|
||||
/// Exactly equivalent to `service_queue` but expects a mutable `page_index` to be passed
|
||||
/// in and any changes stored.
|
||||
fn do_service_queue(limit: Weight, page_index: &mut PageIndexData) -> Weight {
|
||||
fn do_service_queue(
|
||||
limit: Weight,
|
||||
page_index: &mut PageIndexData,
|
||||
messages_processed: &mut u8,
|
||||
) -> Weight {
|
||||
let mut used = Weight::zero();
|
||||
while page_index.begin_used < page_index.end_used {
|
||||
let page = Pages::<T>::take(page_index.begin_used);
|
||||
for (i, &(sent_at, ref data)) in page.iter().enumerate() {
|
||||
if *messages_processed >= MAX_MESSAGES_PER_BLOCK {
|
||||
// Exceeded block message limit - put the remaining messages back and bail
|
||||
Pages::<T>::insert(page_index.begin_used, &page[i..]);
|
||||
return used
|
||||
}
|
||||
*messages_processed += 1;
|
||||
match Self::try_service_message(limit.saturating_sub(used), sent_at, &data[..])
|
||||
{
|
||||
Ok(w) => used += w,
|
||||
@@ -257,12 +266,12 @@ pub mod pallet {
|
||||
Ok(Weight::zero())
|
||||
},
|
||||
Ok(Ok(x)) => {
|
||||
let outcome = T::XcmExecutor::execute_xcm(Parent, x, limit.ref_time());
|
||||
let outcome = T::XcmExecutor::execute_xcm(Parent, x, message_id, limit);
|
||||
match outcome {
|
||||
Outcome::Error(XcmError::WeightLimitReached(required)) =>
|
||||
Err((message_id, Weight::from_ref_time(required))),
|
||||
Err((message_id, required)),
|
||||
outcome => {
|
||||
let weight_used = Weight::from_ref_time(outcome.weight_used());
|
||||
let weight_used = outcome.weight_used();
|
||||
Self::deposit_event(Event::ExecutedDownward { message_id, outcome });
|
||||
Ok(weight_used)
|
||||
},
|
||||
@@ -280,11 +289,12 @@ pub mod pallet {
|
||||
iter: impl Iterator<Item = (RelayBlockNumber, Vec<u8>)>,
|
||||
limit: Weight,
|
||||
) -> Weight {
|
||||
let mut messages_processed = 0;
|
||||
let mut page_index = PageIndex::<T>::get();
|
||||
let config = Configuration::<T>::get();
|
||||
|
||||
// First try to use `max_weight` to service the current queue.
|
||||
let mut used = Self::do_service_queue(limit, &mut page_index);
|
||||
let mut used = Self::do_service_queue(limit, &mut page_index, &mut messages_processed);
|
||||
|
||||
// Then if the queue is empty, use the weight remaining to service the incoming messages
|
||||
// and once we run out of weight, place them in the queue.
|
||||
@@ -297,15 +307,21 @@ pub mod pallet {
|
||||
};
|
||||
|
||||
for (i, (sent_at, data)) in iter.enumerate() {
|
||||
if messages_processed >= MAX_MESSAGES_PER_BLOCK {
|
||||
break
|
||||
}
|
||||
if maybe_enqueue_page.is_none() {
|
||||
// We're not currently enqueuing - try to execute inline.
|
||||
let remaining_weight = limit.saturating_sub(used);
|
||||
messages_processed += 1;
|
||||
match Self::try_service_message(remaining_weight, sent_at, &data[..]) {
|
||||
Ok(consumed) => used += consumed,
|
||||
Err((message_id, required_weight)) =>
|
||||
// Too much weight required right now.
|
||||
{
|
||||
if required_weight.any_gt(config.max_individual) {
|
||||
let is_under_limit = Overweight::<T>::count() < MAX_OVERWEIGHT_MESSAGES;
|
||||
used.saturating_accrue(T::DbWeight::get().reads(1));
|
||||
if required_weight.any_gt(config.max_individual) && is_under_limit {
|
||||
// overweight - add to overweight queue and continue with
|
||||
// message execution.
|
||||
let overweight_index = page_index.overweight_count;
|
||||
@@ -367,7 +383,7 @@ mod tests {
|
||||
};
|
||||
use sp_version::RuntimeVersion;
|
||||
use std::cell::RefCell;
|
||||
use xcm::latest::{MultiLocation, OriginKind, Weight as XCMWeight};
|
||||
use xcm::latest::{MultiLocation, OriginKind};
|
||||
|
||||
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
|
||||
type Block = frame_system::mocking::MockBlock<Test>;
|
||||
@@ -442,28 +458,58 @@ mod tests {
|
||||
})
|
||||
}
|
||||
|
||||
pub enum Weightless {}
|
||||
impl PreparedMessage for Weightless {
|
||||
fn weight_of(&self) -> Weight {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
|
||||
pub struct MockExec;
|
||||
impl ExecuteXcm<RuntimeCall> for MockExec {
|
||||
type Prepared = Weightless;
|
||||
|
||||
fn prepare(_message: Xcm) -> Result<Self::Prepared, Xcm> {
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
fn execute(
|
||||
_origin: impl Into<MultiLocation>,
|
||||
_pre: Weightless,
|
||||
_hash: XcmHash,
|
||||
_weight_credit: Weight,
|
||||
) -> Outcome {
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
fn execute_xcm_in_credit(
|
||||
_origin: impl Into<MultiLocation>,
|
||||
message: Xcm,
|
||||
weight_limit: XCMWeight,
|
||||
_credit: XCMWeight,
|
||||
_hash: XcmHash,
|
||||
weight_limit: Weight,
|
||||
_weight_credit: Weight,
|
||||
) -> Outcome {
|
||||
let o = match (message.0.len(), &message.0.first()) {
|
||||
(1, Some(Transact { require_weight_at_most, .. })) => {
|
||||
if *require_weight_at_most <= weight_limit {
|
||||
if require_weight_at_most.all_lte(weight_limit) {
|
||||
Outcome::Complete(*require_weight_at_most)
|
||||
} else {
|
||||
Outcome::Error(XcmError::WeightLimitReached(*require_weight_at_most))
|
||||
}
|
||||
},
|
||||
// use 1000 to decide that it's not supported.
|
||||
_ => Outcome::Incomplete(1000.min(weight_limit), XcmError::Unimplemented),
|
||||
_ => Outcome::Incomplete(
|
||||
Weight::from_parts(1000, 1000).min(weight_limit),
|
||||
XcmError::Unimplemented,
|
||||
),
|
||||
};
|
||||
TRACE.with(|q| q.borrow_mut().push((message, o.clone())));
|
||||
o
|
||||
}
|
||||
|
||||
fn charge_fees(_location: impl Into<MultiLocation>, _fees: MultiAssets) -> XcmResult {
|
||||
Err(XcmError::Unimplemented)
|
||||
}
|
||||
}
|
||||
|
||||
impl Config for Test {
|
||||
@@ -498,20 +544,23 @@ mod tests {
|
||||
DmpQueue::handle_dmp_messages(iter, limit)
|
||||
}
|
||||
|
||||
fn msg(weight: XCMWeight) -> Xcm {
|
||||
fn msg(weight: u64) -> Xcm {
|
||||
Xcm(vec![Transact {
|
||||
origin_type: OriginKind::Native,
|
||||
require_weight_at_most: weight,
|
||||
origin_kind: OriginKind::Native,
|
||||
require_weight_at_most: Weight::from_parts(weight, weight),
|
||||
call: Vec::new().into(),
|
||||
}])
|
||||
}
|
||||
|
||||
fn msg_complete(weight: XCMWeight) -> (Xcm, Outcome) {
|
||||
(msg(weight), Outcome::Complete(weight))
|
||||
fn msg_complete(weight: u64) -> (Xcm, Outcome) {
|
||||
(msg(weight), Outcome::Complete(Weight::from_parts(weight, weight)))
|
||||
}
|
||||
|
||||
fn msg_limit_reached(weight: XCMWeight) -> (Xcm, Outcome) {
|
||||
(msg(weight), Outcome::Error(XcmError::WeightLimitReached(weight)))
|
||||
fn msg_limit_reached(weight: u64) -> (Xcm, Outcome) {
|
||||
(
|
||||
msg(weight),
|
||||
Outcome::Error(XcmError::WeightLimitReached(Weight::from_parts(weight, weight))),
|
||||
)
|
||||
}
|
||||
|
||||
fn pages_queued() -> PageCounter {
|
||||
@@ -531,7 +580,7 @@ mod tests {
|
||||
#[test]
|
||||
fn basic_setup_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let weight_used = handle_messages(&[], Weight::from_ref_time(1000));
|
||||
let weight_used = handle_messages(&[], Weight::from_parts(1000, 1000));
|
||||
assert_eq!(weight_used, Weight::zero());
|
||||
assert_eq!(take_trace(), Vec::new());
|
||||
assert!(queue_is_empty());
|
||||
@@ -542,8 +591,8 @@ mod tests {
|
||||
fn service_inline_complete_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let incoming = vec![msg(1000), msg(1001)];
|
||||
let weight_used = handle_messages(&incoming, Weight::from_ref_time(2500));
|
||||
assert_eq!(weight_used, Weight::from_ref_time(2001));
|
||||
let weight_used = handle_messages(&incoming, Weight::from_parts(2500, 2500));
|
||||
assert_eq!(weight_used, Weight::from_parts(2001, 2001));
|
||||
assert_eq!(take_trace(), vec![msg_complete(1000), msg_complete(1001)]);
|
||||
assert!(queue_is_empty());
|
||||
});
|
||||
@@ -554,8 +603,8 @@ mod tests {
|
||||
new_test_ext().execute_with(|| {
|
||||
let enqueued = vec![msg(1000), msg(1001), msg(1002)];
|
||||
enqueue(&enqueued);
|
||||
let weight_used = handle_messages(&[], Weight::from_ref_time(2500));
|
||||
assert_eq!(weight_used, Weight::from_ref_time(2001));
|
||||
let weight_used = handle_messages(&[], Weight::from_parts(2500, 2500));
|
||||
assert_eq!(weight_used, Weight::from_parts(2001, 2001));
|
||||
assert_eq!(
|
||||
take_trace(),
|
||||
vec![msg_complete(1000), msg_complete(1001), msg_limit_reached(1002),]
|
||||
@@ -567,7 +616,7 @@ mod tests {
|
||||
fn enqueue_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let incoming = vec![msg(1000), msg(1001), msg(1002)];
|
||||
let weight_used = handle_messages(&incoming, Weight::from_ref_time(999));
|
||||
let weight_used = handle_messages(&incoming, Weight::from_parts(999, 999));
|
||||
assert_eq!(weight_used, Weight::zero());
|
||||
assert_eq!(
|
||||
PageIndex::<Test>::get(),
|
||||
@@ -576,15 +625,15 @@ mod tests {
|
||||
assert_eq!(Pages::<Test>::get(0).len(), 3);
|
||||
assert_eq!(take_trace(), vec![msg_limit_reached(1000)]);
|
||||
|
||||
let weight_used = handle_messages(&[], Weight::from_ref_time(2500));
|
||||
assert_eq!(weight_used, Weight::from_ref_time(2001));
|
||||
let weight_used = handle_messages(&[], Weight::from_parts(2500, 2500));
|
||||
assert_eq!(weight_used, Weight::from_parts(2001, 2001));
|
||||
assert_eq!(
|
||||
take_trace(),
|
||||
vec![msg_complete(1000), msg_complete(1001), msg_limit_reached(1002),]
|
||||
);
|
||||
|
||||
let weight_used = handle_messages(&[], Weight::from_ref_time(2500));
|
||||
assert_eq!(weight_used, Weight::from_ref_time(1002));
|
||||
let weight_used = handle_messages(&[], Weight::from_parts(2500, 2500));
|
||||
assert_eq!(weight_used, Weight::from_parts(1002, 1002));
|
||||
assert_eq!(take_trace(), vec![msg_complete(1002),]);
|
||||
assert!(queue_is_empty());
|
||||
});
|
||||
@@ -594,14 +643,14 @@ mod tests {
|
||||
fn service_inline_then_enqueue_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let incoming = vec![msg(1000), msg(1001), msg(1002)];
|
||||
let weight_used = handle_messages(&incoming, Weight::from_ref_time(1500));
|
||||
assert_eq!(weight_used, Weight::from_ref_time(1000));
|
||||
let weight_used = handle_messages(&incoming, Weight::from_parts(1500, 1500));
|
||||
assert_eq!(weight_used, Weight::from_parts(1000, 1000));
|
||||
assert_eq!(pages_queued(), 1);
|
||||
assert_eq!(Pages::<Test>::get(0).len(), 2);
|
||||
assert_eq!(take_trace(), vec![msg_complete(1000), msg_limit_reached(1001),]);
|
||||
|
||||
let weight_used = handle_messages(&[], Weight::from_ref_time(2500));
|
||||
assert_eq!(weight_used, Weight::from_ref_time(2003));
|
||||
let weight_used = handle_messages(&[], Weight::from_parts(2500, 2500));
|
||||
assert_eq!(weight_used, Weight::from_parts(2003, 2003));
|
||||
assert_eq!(take_trace(), vec![msg_complete(1001), msg_complete(1002),]);
|
||||
assert!(queue_is_empty());
|
||||
});
|
||||
@@ -613,8 +662,8 @@ mod tests {
|
||||
let enqueued = vec![msg(1000), msg(1001)];
|
||||
let incoming = vec![msg(1002), msg(1003)];
|
||||
enqueue(&enqueued);
|
||||
let weight_used = handle_messages(&incoming, Weight::from_ref_time(5000));
|
||||
assert_eq!(weight_used, Weight::from_ref_time(4006));
|
||||
let weight_used = handle_messages(&incoming, Weight::from_parts(5000, 5000));
|
||||
assert_eq!(weight_used, Weight::from_parts(4006, 4006));
|
||||
assert_eq!(
|
||||
take_trace(),
|
||||
vec![
|
||||
@@ -634,19 +683,19 @@ mod tests {
|
||||
let enqueued = vec![msg(1000), msg(10001)];
|
||||
let incoming = vec![msg(1002), msg(1003)];
|
||||
enqueue(&enqueued);
|
||||
let weight_used = handle_messages(&incoming, Weight::from_ref_time(5000));
|
||||
assert_eq!(weight_used, Weight::from_ref_time(1000));
|
||||
let weight_used = handle_messages(&incoming, Weight::from_parts(5000, 5000));
|
||||
assert_eq!(weight_used, Weight::from_parts(1000, 1000));
|
||||
assert_eq!(take_trace(), vec![msg_complete(1000), msg_limit_reached(10001),]);
|
||||
assert_eq!(pages_queued(), 2);
|
||||
|
||||
// 5000 is not enough to process the 10001 blocker, so nothing happens.
|
||||
let weight_used = handle_messages(&[], Weight::from_ref_time(5000));
|
||||
let weight_used = handle_messages(&[], Weight::from_parts(5000, 5000));
|
||||
assert_eq!(weight_used, Weight::zero());
|
||||
assert_eq!(take_trace(), vec![msg_limit_reached(10001),]);
|
||||
|
||||
// 20000 is now enough to process everything.
|
||||
let weight_used = handle_messages(&[], Weight::from_ref_time(20000));
|
||||
assert_eq!(weight_used, Weight::from_ref_time(12006));
|
||||
let weight_used = handle_messages(&[], Weight::from_parts(20000, 20000));
|
||||
assert_eq!(weight_used, Weight::from_parts(12006, 12006));
|
||||
assert_eq!(
|
||||
take_trace(),
|
||||
vec![msg_complete(10001), msg_complete(1002), msg_complete(1003),]
|
||||
@@ -661,8 +710,8 @@ mod tests {
|
||||
let enqueued = vec![msg(1000), msg(1001)];
|
||||
let incoming = vec![msg(10002), msg(1003)];
|
||||
enqueue(&enqueued);
|
||||
let weight_used = handle_messages(&incoming, Weight::from_ref_time(5000));
|
||||
assert_eq!(weight_used, Weight::from_ref_time(2001));
|
||||
let weight_used = handle_messages(&incoming, Weight::from_parts(5000, 5000));
|
||||
assert_eq!(weight_used, Weight::from_parts(2001, 2001));
|
||||
assert_eq!(
|
||||
take_trace(),
|
||||
vec![msg_complete(1000), msg_complete(1001), msg_limit_reached(10002),]
|
||||
@@ -670,8 +719,8 @@ mod tests {
|
||||
assert_eq!(pages_queued(), 1);
|
||||
|
||||
// 20000 is now enough to process everything.
|
||||
let weight_used = handle_messages(&[], Weight::from_ref_time(20000));
|
||||
assert_eq!(weight_used, Weight::from_ref_time(11005));
|
||||
let weight_used = handle_messages(&[], Weight::from_parts(20000, 20000));
|
||||
assert_eq!(weight_used, Weight::from_parts(11005, 11005));
|
||||
assert_eq!(take_trace(), vec![msg_complete(10002), msg_complete(1003),]);
|
||||
assert!(queue_is_empty());
|
||||
});
|
||||
@@ -683,8 +732,8 @@ mod tests {
|
||||
let enqueued = vec![msg(1000), msg(1001)];
|
||||
let incoming = vec![msg(1002), msg(10003)];
|
||||
enqueue(&enqueued);
|
||||
let weight_used = handle_messages(&incoming, Weight::from_ref_time(5000));
|
||||
assert_eq!(weight_used, Weight::from_ref_time(3003));
|
||||
let weight_used = handle_messages(&incoming, Weight::from_parts(5000, 5000));
|
||||
assert_eq!(weight_used, Weight::from_parts(3003, 3003));
|
||||
assert_eq!(
|
||||
take_trace(),
|
||||
vec![
|
||||
@@ -697,8 +746,8 @@ mod tests {
|
||||
assert_eq!(pages_queued(), 1);
|
||||
|
||||
// 20000 is now enough to process everything.
|
||||
let weight_used = handle_messages(&[], Weight::from_ref_time(20000));
|
||||
assert_eq!(weight_used, Weight::from_ref_time(10003));
|
||||
let weight_used = handle_messages(&[], Weight::from_parts(20000, 20000));
|
||||
assert_eq!(weight_used, Weight::from_parts(10003, 10003));
|
||||
assert_eq!(take_trace(), vec![msg_complete(10003),]);
|
||||
assert!(queue_is_empty());
|
||||
});
|
||||
@@ -709,20 +758,20 @@ mod tests {
|
||||
new_test_ext().execute_with(|| {
|
||||
let enqueued = vec![msg(1000), msg(1001)];
|
||||
enqueue(&enqueued);
|
||||
let weight_used = handle_messages(&vec![msg(1002)], Weight::from_ref_time(1500));
|
||||
assert_eq!(weight_used, Weight::from_ref_time(1000));
|
||||
let weight_used = handle_messages(&vec![msg(1002)], Weight::from_parts(1500, 1500));
|
||||
assert_eq!(weight_used, Weight::from_parts(1000, 1000));
|
||||
assert_eq!(take_trace(), vec![msg_complete(1000), msg_limit_reached(1001),]);
|
||||
assert_eq!(pages_queued(), 2);
|
||||
assert_eq!(PageIndex::<Test>::get().begin_used, 0);
|
||||
|
||||
let weight_used = handle_messages(&vec![msg(1003)], Weight::from_ref_time(1500));
|
||||
assert_eq!(weight_used, Weight::from_ref_time(1001));
|
||||
let weight_used = handle_messages(&vec![msg(1003)], Weight::from_parts(1500, 1500));
|
||||
assert_eq!(weight_used, Weight::from_parts(1001, 1001));
|
||||
assert_eq!(take_trace(), vec![msg_complete(1001), msg_limit_reached(1002),]);
|
||||
assert_eq!(pages_queued(), 2);
|
||||
assert_eq!(PageIndex::<Test>::get().begin_used, 1);
|
||||
|
||||
let weight_used = handle_messages(&vec![msg(1004)], Weight::from_ref_time(1500));
|
||||
assert_eq!(weight_used, Weight::from_ref_time(1002));
|
||||
let weight_used = handle_messages(&vec![msg(1004)], Weight::from_parts(1500, 1500));
|
||||
assert_eq!(weight_used, Weight::from_parts(1002, 1002));
|
||||
assert_eq!(take_trace(), vec![msg_complete(1002), msg_limit_reached(1003),]);
|
||||
assert_eq!(pages_queued(), 2);
|
||||
assert_eq!(PageIndex::<Test>::get().begin_used, 2);
|
||||
@@ -733,11 +782,13 @@ mod tests {
|
||||
fn overweight_should_not_block_queue() {
|
||||
new_test_ext().execute_with(|| {
|
||||
// Set the overweight threshold to 9999.
|
||||
Configuration::<Test>::put(ConfigData { max_individual: Weight::from_ref_time(9999) });
|
||||
Configuration::<Test>::put(ConfigData {
|
||||
max_individual: Weight::from_parts(9999, 9999),
|
||||
});
|
||||
|
||||
let incoming = vec![msg(1000), msg(10001), msg(1002)];
|
||||
let weight_used = handle_messages(&incoming, Weight::from_ref_time(2500));
|
||||
assert_eq!(weight_used, Weight::from_ref_time(2002));
|
||||
let weight_used = handle_messages(&incoming, Weight::from_parts(2500, 2500));
|
||||
assert_eq!(weight_used, Weight::from_parts(2002, 2002));
|
||||
assert!(queue_is_empty());
|
||||
assert_eq!(
|
||||
take_trace(),
|
||||
@@ -752,40 +803,64 @@ mod tests {
|
||||
fn overweights_should_be_manually_executable() {
|
||||
new_test_ext().execute_with(|| {
|
||||
// Set the overweight threshold to 9999.
|
||||
Configuration::<Test>::put(ConfigData { max_individual: Weight::from_ref_time(9999) });
|
||||
Configuration::<Test>::put(ConfigData {
|
||||
max_individual: Weight::from_parts(9999, 9999),
|
||||
});
|
||||
|
||||
let incoming = vec![msg(10000)];
|
||||
let weight_used = handle_messages(&incoming, Weight::from_ref_time(2500));
|
||||
let weight_used = handle_messages(&incoming, Weight::from_parts(2500, 2500));
|
||||
assert_eq!(weight_used, Weight::zero());
|
||||
assert_eq!(take_trace(), vec![msg_limit_reached(10000)]);
|
||||
assert_eq!(overweights(), vec![0]);
|
||||
|
||||
assert_noop!(
|
||||
DmpQueue::service_overweight(RuntimeOrigin::signed(1), 0, 20000),
|
||||
DmpQueue::service_overweight(
|
||||
RuntimeOrigin::signed(1),
|
||||
0,
|
||||
Weight::from_parts(20000, 20000)
|
||||
),
|
||||
BadOrigin
|
||||
);
|
||||
assert_noop!(
|
||||
DmpQueue::service_overweight(RuntimeOrigin::root(), 1, 20000),
|
||||
DmpQueue::service_overweight(
|
||||
RuntimeOrigin::root(),
|
||||
1,
|
||||
Weight::from_parts(20000, 20000)
|
||||
),
|
||||
Error::<Test>::Unknown
|
||||
);
|
||||
assert_noop!(
|
||||
DmpQueue::service_overweight(RuntimeOrigin::root(), 0, 9999),
|
||||
DmpQueue::service_overweight(
|
||||
RuntimeOrigin::root(),
|
||||
0,
|
||||
Weight::from_parts(9999, 9999)
|
||||
),
|
||||
Error::<Test>::OverLimit
|
||||
);
|
||||
assert_eq!(take_trace(), vec![msg_limit_reached(10000)]);
|
||||
|
||||
let base_weight = super::Call::<Test>::service_overweight { index: 0, weight_limit: 0 }
|
||||
.get_dispatch_info()
|
||||
.weight;
|
||||
let base_weight =
|
||||
super::Call::<Test>::service_overweight { index: 0, weight_limit: Weight::zero() }
|
||||
.get_dispatch_info()
|
||||
.weight;
|
||||
use frame_support::dispatch::GetDispatchInfo;
|
||||
let info = DmpQueue::service_overweight(RuntimeOrigin::root(), 0, 20000).unwrap();
|
||||
let info = DmpQueue::service_overweight(
|
||||
RuntimeOrigin::root(),
|
||||
0,
|
||||
Weight::from_parts(20000, 20000),
|
||||
)
|
||||
.unwrap();
|
||||
let actual_weight = info.actual_weight.unwrap();
|
||||
assert_eq!(actual_weight, base_weight + Weight::from_ref_time(10000));
|
||||
assert_eq!(actual_weight, base_weight + Weight::from_parts(10000, 10000));
|
||||
assert_eq!(take_trace(), vec![msg_complete(10000)]);
|
||||
assert!(overweights().is_empty());
|
||||
|
||||
assert_noop!(
|
||||
DmpQueue::service_overweight(RuntimeOrigin::root(), 0, 20000),
|
||||
DmpQueue::service_overweight(
|
||||
RuntimeOrigin::root(),
|
||||
0,
|
||||
Weight::from_parts(20000, 20000)
|
||||
),
|
||||
Error::<Test>::Unknown
|
||||
);
|
||||
});
|
||||
@@ -798,8 +873,8 @@ mod tests {
|
||||
enqueue(&vec![msg(1002), msg(1003)]);
|
||||
enqueue(&vec![msg(1004), msg(1005)]);
|
||||
|
||||
let weight_used = DmpQueue::on_idle(1, Weight::from_ref_time(6000));
|
||||
assert_eq!(weight_used, Weight::from_ref_time(5010));
|
||||
let weight_used = DmpQueue::on_idle(1, Weight::from_parts(6000, 6000));
|
||||
assert_eq!(weight_used, Weight::from_parts(5010, 5010));
|
||||
assert_eq!(
|
||||
take_trace(),
|
||||
vec![
|
||||
|
||||
@@ -22,7 +22,6 @@ use frame_support::{
|
||||
traits::StorageVersion,
|
||||
weights::{constants::WEIGHT_REF_TIME_PER_MILLIS, Weight},
|
||||
};
|
||||
use xcm::latest::Weight as XcmWeight;
|
||||
|
||||
/// The current storage version.
|
||||
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
|
||||
@@ -33,8 +32,15 @@ pub fn migrate_to_latest<T: Config>() -> Weight {
|
||||
let mut weight = T::DbWeight::get().reads(1);
|
||||
|
||||
if StorageVersion::get::<Pallet<T>>() == 0 {
|
||||
weight += migrate_to_v1::<T>();
|
||||
weight.saturating_accrue(migrate_to_v1::<T>());
|
||||
StorageVersion::new(1).put::<Pallet<T>>();
|
||||
weight.saturating_accrue(T::DbWeight::get().writes(1));
|
||||
}
|
||||
|
||||
if StorageVersion::get::<Pallet<T>>() == 1 {
|
||||
weight.saturating_accrue(migrate_to_v2::<T>());
|
||||
StorageVersion::new(2).put::<Pallet<T>>();
|
||||
weight.saturating_accrue(T::DbWeight::get().writes(1));
|
||||
}
|
||||
|
||||
weight
|
||||
@@ -46,7 +52,7 @@ mod v0 {
|
||||
|
||||
#[derive(Decode, Encode, Debug)]
|
||||
pub struct ConfigData {
|
||||
pub max_individual: XcmWeight,
|
||||
pub max_individual: u64,
|
||||
}
|
||||
|
||||
impl Default for ConfigData {
|
||||
@@ -78,6 +84,16 @@ pub fn migrate_to_v1<T: Config>() -> Weight {
|
||||
T::DbWeight::get().reads_writes(1, 1)
|
||||
}
|
||||
|
||||
/// Migrates `Overweight` so that it initializes the storage map's counter.
|
||||
///
|
||||
/// NOTE: Only use this function if you know what you're doing. Default to using
|
||||
/// `migrate_to_latest`.
|
||||
pub fn migrate_to_v2<T: Config>() -> Weight {
|
||||
let overweight_messages = <Pallet<T> as Store>::Overweight::initialize_counter() as u64;
|
||||
|
||||
T::DbWeight::get().reads_writes(overweight_messages, 1)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@@ -28,6 +28,7 @@ sp-version = { git = "https://github.com/paritytech/substrate", default-features
|
||||
|
||||
# Polkadot
|
||||
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, features = [ "wasm-api" ], branch = "master" }
|
||||
xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||
|
||||
# Cumulus
|
||||
cumulus-pallet-parachain-system-proc-macro = { path = "proc-macro", default-features = false }
|
||||
@@ -67,6 +68,7 @@ std = [
|
||||
"sp-state-machine/std",
|
||||
"sp-std/std",
|
||||
"sp-trie/std",
|
||||
"xcm/std",
|
||||
]
|
||||
|
||||
runtime-benchmarks = [
|
||||
|
||||
@@ -53,6 +53,7 @@ use sp_runtime::{
|
||||
},
|
||||
};
|
||||
use sp_std::{cmp, collections::btree_map::BTreeMap, prelude::*};
|
||||
use xcm::latest::XcmHash;
|
||||
|
||||
mod migration;
|
||||
mod relay_state_snapshot;
|
||||
@@ -480,6 +481,8 @@ pub mod pallet {
|
||||
DownwardMessagesReceived { count: u32 },
|
||||
/// Downward messages were processed using the given weight.
|
||||
DownwardMessagesProcessed { weight_used: Weight, dmq_head: relay_chain::Hash },
|
||||
/// An upward message was sent to the relay chain.
|
||||
UpwardMessageSent { message_hash: Option<XcmHash> },
|
||||
}
|
||||
|
||||
#[pallet::error]
|
||||
@@ -743,7 +746,7 @@ impl<T: Config> GetChannelInfo for Pallet<T> {
|
||||
// None then it must be that this is an edge-case where a message is attempted to be
|
||||
// sent at the first block. It should be safe to assume that there are no channels
|
||||
// opened at all so early. At least, relying on this assumption seems to be a better
|
||||
// tradeoff, compared to introducing an error variant that the clients should be
|
||||
// trade-off, compared to introducing an error variant that the clients should be
|
||||
// prepared to handle.
|
||||
let index = match channels.binary_search_by_key(&id, |item| item.0) {
|
||||
Err(_) => return ChannelStatus::Closed,
|
||||
@@ -1004,7 +1007,7 @@ impl<T: Config> frame_system::SetCode<T> for ParachainSetCode<T> {
|
||||
}
|
||||
|
||||
impl<T: Config> Pallet<T> {
|
||||
pub fn send_upward_message(message: UpwardMessage) -> Result<u32, MessageSendError> {
|
||||
pub fn send_upward_message(message: UpwardMessage) -> Result<(u32, XcmHash), MessageSendError> {
|
||||
// Check if the message fits into the relay-chain constraints.
|
||||
//
|
||||
// Note, that we are using `host_configuration` here which may be from the previous
|
||||
@@ -1034,13 +1037,18 @@ impl<T: Config> Pallet<T> {
|
||||
// Thus fall through here.
|
||||
},
|
||||
};
|
||||
<PendingUpwardMessages<T>>::append(message);
|
||||
Ok(0)
|
||||
<PendingUpwardMessages<T>>::append(message.clone());
|
||||
|
||||
// The relay ump does not use using_encoded
|
||||
// We apply the same this to use the same hash
|
||||
let hash = sp_io::hashing::blake2_256(&message);
|
||||
Self::deposit_event(Event::UpwardMessageSent { message_hash: Some(hash) });
|
||||
Ok((0, hash))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> UpwardMessageSender for Pallet<T> {
|
||||
fn send_upward_message(message: UpwardMessage) -> Result<u32, MessageSendError> {
|
||||
fn send_upward_message(message: UpwardMessage) -> Result<(u32, XcmHash), MessageSendError> {
|
||||
Self::send_upward_message(message)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,13 +67,13 @@ pub mod pallet {
|
||||
pub enum Event<T: Config> {
|
||||
/// Downward message is invalid XCM.
|
||||
/// \[ id \]
|
||||
InvalidFormat([u8; 8]),
|
||||
InvalidFormat([u8; 32]),
|
||||
/// Downward message is unsupported version of XCM.
|
||||
/// \[ id \]
|
||||
UnsupportedVersion([u8; 8]),
|
||||
UnsupportedVersion([u8; 32]),
|
||||
/// Downward message executed with the given outcome.
|
||||
/// \[ id, outcome \]
|
||||
ExecutedDownward([u8; 8], Outcome),
|
||||
ExecutedDownward([u8; 32], Outcome),
|
||||
}
|
||||
|
||||
/// Origin for the parachains module.
|
||||
@@ -113,7 +113,7 @@ impl<T: Config> DmpMessageHandler for UnlimitedDmpExecution<T> {
|
||||
) -> Weight {
|
||||
let mut used = Weight::zero();
|
||||
for (_sent_at, data) in iter {
|
||||
let id = sp_io::hashing::twox_64(&data[..]);
|
||||
let id = sp_io::hashing::blake2_256(&data[..]);
|
||||
let msg = VersionedXcm::<T::RuntimeCall>::decode_all_with_depth_limit(
|
||||
MAX_XCM_DECODE_DEPTH,
|
||||
&mut data.as_slice(),
|
||||
@@ -123,8 +123,8 @@ impl<T: Config> DmpMessageHandler for UnlimitedDmpExecution<T> {
|
||||
Err(_) => Pallet::<T>::deposit_event(Event::InvalidFormat(id)),
|
||||
Ok(Err(())) => Pallet::<T>::deposit_event(Event::UnsupportedVersion(id)),
|
||||
Ok(Ok(x)) => {
|
||||
let outcome = T::XcmExecutor::execute_xcm(Parent, x, limit.ref_time());
|
||||
used += Weight::from_ref_time(outcome.weight_used());
|
||||
let outcome = T::XcmExecutor::execute_xcm(Parent, x, id, limit);
|
||||
used = used.saturating_add(outcome.weight_used());
|
||||
Pallet::<T>::deposit_event(Event::ExecutedDownward(id, outcome));
|
||||
},
|
||||
}
|
||||
@@ -146,7 +146,7 @@ impl<T: Config> DmpMessageHandler for LimitAndDropDmpExecution<T> {
|
||||
) -> Weight {
|
||||
let mut used = Weight::zero();
|
||||
for (_sent_at, data) in iter {
|
||||
let id = sp_io::hashing::twox_64(&data[..]);
|
||||
let id = sp_io::hashing::blake2_256(&data[..]);
|
||||
let msg = VersionedXcm::<T::RuntimeCall>::decode_all_with_depth_limit(
|
||||
MAX_XCM_DECODE_DEPTH,
|
||||
&mut data.as_slice(),
|
||||
@@ -157,8 +157,8 @@ impl<T: Config> DmpMessageHandler for LimitAndDropDmpExecution<T> {
|
||||
Ok(Err(())) => Pallet::<T>::deposit_event(Event::UnsupportedVersion(id)),
|
||||
Ok(Ok(x)) => {
|
||||
let weight_limit = limit.saturating_sub(used);
|
||||
let outcome = T::XcmExecutor::execute_xcm(Parent, x, weight_limit.ref_time());
|
||||
used += Weight::from_ref_time(outcome.weight_used());
|
||||
let outcome = T::XcmExecutor::execute_xcm(Parent, x, id, weight_limit);
|
||||
used = used.saturating_add(outcome.weight_used());
|
||||
Pallet::<T>::deposit_event(Event::ExecutedDownward(id, outcome));
|
||||
},
|
||||
}
|
||||
|
||||
@@ -13,10 +13,12 @@ scale-info = { version = "2.3.1", default-features = false, features = ["derive"
|
||||
# Substrate
|
||||
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
|
||||
# Polkadot
|
||||
polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||
xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||
xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||
|
||||
@@ -30,7 +32,6 @@ frame-benchmarking = { default-features = false, optional = true, git = "https:/
|
||||
|
||||
# Substrate
|
||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
# Polkadot
|
||||
@@ -48,6 +49,8 @@ std = [
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
"log/std",
|
||||
"polkadot-runtime-common/std",
|
||||
"sp-io/std",
|
||||
"sp-runtime/std",
|
||||
"sp-std/std",
|
||||
"xcm-executor/std",
|
||||
|
||||
@@ -22,7 +22,7 @@ use frame_system::RawOrigin;
|
||||
|
||||
benchmarks! {
|
||||
set_config_with_u32 {}: update_resume_threshold(RawOrigin::Root, 100)
|
||||
set_config_with_weight {}: update_weight_restrict_decay(RawOrigin::Root, 3_000_000)
|
||||
set_config_with_weight {}: update_weight_restrict_decay(RawOrigin::Root, Weight::from_ref_time(3_000_000))
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test);
|
||||
|
||||
@@ -44,20 +44,18 @@ use cumulus_primitives_core::{
|
||||
ParaId, XcmpMessageFormat, XcmpMessageHandler, XcmpMessageSource,
|
||||
};
|
||||
use frame_support::{
|
||||
traits::EnsureOrigin,
|
||||
traits::{EnsureOrigin, Get},
|
||||
weights::{constants::WEIGHT_REF_TIME_PER_MILLIS, Weight},
|
||||
};
|
||||
use polkadot_runtime_common::xcm_sender::ConstantPrice;
|
||||
use rand_chacha::{
|
||||
rand_core::{RngCore, SeedableRng},
|
||||
ChaChaRng,
|
||||
};
|
||||
use scale_info::TypeInfo;
|
||||
use sp_runtime::{traits::Hash, RuntimeDebug};
|
||||
use sp_runtime::RuntimeDebug;
|
||||
use sp_std::{convert::TryFrom, prelude::*};
|
||||
use xcm::{
|
||||
latest::{prelude::*, Weight as XcmWeight},
|
||||
VersionedXcm, WrapVersion, MAX_XCM_DECODE_DEPTH,
|
||||
};
|
||||
use xcm::{latest::prelude::*, VersionedXcm, WrapVersion, MAX_XCM_DECODE_DEPTH};
|
||||
use xcm_executor::traits::ConvertOrigin;
|
||||
|
||||
pub use pallet::*;
|
||||
@@ -68,6 +66,12 @@ pub type OverweightIndex = u64;
|
||||
const LOG_TARGET: &str = "xcmp_queue";
|
||||
const DEFAULT_POV_SIZE: u64 = 64 * 1024; // 64 KB
|
||||
|
||||
// Maximum amount of messages to process per block. This is a temporary measure until we properly
|
||||
// account for proof size weights.
|
||||
const MAX_MESSAGES_PER_BLOCK: u8 = 10;
|
||||
// Maximum amount of messages that can exist in the overweight queue at any given time.
|
||||
const MAX_OVERWEIGHT_MESSAGES: u32 = 1000;
|
||||
|
||||
#[frame_support::pallet]
|
||||
pub mod pallet {
|
||||
use super::*;
|
||||
@@ -103,6 +107,9 @@ pub mod pallet {
|
||||
/// superuser origin.
|
||||
type ControllerOriginConverter: ConvertOrigin<Self::RuntimeOrigin>;
|
||||
|
||||
/// The price for delivering an XCM to a sibling parachain destination.
|
||||
type PriceForSiblingDelivery: PriceForSiblingDelivery;
|
||||
|
||||
/// The weight information of this pallet.
|
||||
type WeightInfo: WeightInfo;
|
||||
}
|
||||
@@ -135,11 +142,11 @@ pub mod pallet {
|
||||
/// Events:
|
||||
/// - `OverweightServiced`: On success.
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight((Weight::from_ref_time(weight_limit.saturating_add(1_000_000)), DispatchClass::Operational,))]
|
||||
#[pallet::weight((weight_limit.saturating_add(Weight::from_ref_time(1_000_000)), DispatchClass::Operational))]
|
||||
pub fn service_overweight(
|
||||
origin: OriginFor<T>,
|
||||
index: OverweightIndex,
|
||||
weight_limit: XcmWeight,
|
||||
weight_limit: Weight,
|
||||
) -> DispatchResultWithPostInfo {
|
||||
T::ExecuteOverweightOrigin::ensure_origin(origin)?;
|
||||
|
||||
@@ -150,9 +157,8 @@ pub mod pallet {
|
||||
&mut data.as_slice(),
|
||||
)
|
||||
.map_err(|_| Error::<T>::BadXcm)?;
|
||||
let used =
|
||||
Self::handle_xcm_message(sender, sent_at, xcm, Weight::from_ref_time(weight_limit))
|
||||
.map_err(|_| Error::<T>::WeightOverLimit)?;
|
||||
let used = Self::handle_xcm_message(sender, sent_at, xcm, weight_limit)
|
||||
.map_err(|_| Error::<T>::WeightOverLimit)?;
|
||||
Overweight::<T>::remove(index);
|
||||
Self::deposit_event(Event::OverweightServiced { index, used });
|
||||
Ok(Some(used.saturating_add(Weight::from_ref_time(1_000_000))).into())
|
||||
@@ -234,9 +240,9 @@ pub mod pallet {
|
||||
/// - `new`: Desired value for `QueueConfigData.threshold_weight`
|
||||
#[pallet::call_index(6)]
|
||||
#[pallet::weight((T::WeightInfo::set_config_with_weight(), DispatchClass::Operational,))]
|
||||
pub fn update_threshold_weight(origin: OriginFor<T>, new: XcmWeight) -> DispatchResult {
|
||||
pub fn update_threshold_weight(origin: OriginFor<T>, new: Weight) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
QueueConfig::<T>::mutate(|data| data.threshold_weight = Weight::from_ref_time(new));
|
||||
QueueConfig::<T>::mutate(|data| data.threshold_weight = new);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -248,14 +254,9 @@ pub mod pallet {
|
||||
/// - `new`: Desired value for `QueueConfigData.weight_restrict_decay`.
|
||||
#[pallet::call_index(7)]
|
||||
#[pallet::weight((T::WeightInfo::set_config_with_weight(), DispatchClass::Operational,))]
|
||||
pub fn update_weight_restrict_decay(
|
||||
origin: OriginFor<T>,
|
||||
new: XcmWeight,
|
||||
) -> DispatchResult {
|
||||
pub fn update_weight_restrict_decay(origin: OriginFor<T>, new: Weight) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
QueueConfig::<T>::mutate(|data| {
|
||||
data.weight_restrict_decay = Weight::from_ref_time(new)
|
||||
});
|
||||
QueueConfig::<T>::mutate(|data| data.weight_restrict_decay = new);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -269,12 +270,10 @@ pub mod pallet {
|
||||
#[pallet::weight((T::WeightInfo::set_config_with_weight(), DispatchClass::Operational,))]
|
||||
pub fn update_xcmp_max_individual_weight(
|
||||
origin: OriginFor<T>,
|
||||
new: XcmWeight,
|
||||
new: Weight,
|
||||
) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
QueueConfig::<T>::mutate(|data| {
|
||||
data.xcmp_max_individual_weight = Weight::from_ref_time(new)
|
||||
});
|
||||
QueueConfig::<T>::mutate(|data| data.xcmp_max_individual_weight = new);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -284,17 +283,15 @@ pub mod pallet {
|
||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||
pub enum Event<T: Config> {
|
||||
/// Some XCM was executed ok.
|
||||
Success { message_hash: Option<T::Hash>, weight: Weight },
|
||||
Success { message_hash: Option<XcmHash>, weight: Weight },
|
||||
/// Some XCM failed.
|
||||
Fail { message_hash: Option<T::Hash>, error: XcmError, weight: Weight },
|
||||
Fail { message_hash: Option<XcmHash>, error: XcmError, weight: Weight },
|
||||
/// Bad XCM version used.
|
||||
BadVersion { message_hash: Option<T::Hash> },
|
||||
BadVersion { message_hash: Option<XcmHash> },
|
||||
/// Bad XCM format used.
|
||||
BadFormat { message_hash: Option<T::Hash> },
|
||||
/// An upward message was sent to the relay chain.
|
||||
UpwardMessageSent { message_hash: Option<T::Hash> },
|
||||
BadFormat { message_hash: Option<XcmHash> },
|
||||
/// An HRMP message was sent to a sibling parachain.
|
||||
XcmpMessageSent { message_hash: Option<T::Hash> },
|
||||
XcmpMessageSent { message_hash: Option<XcmHash> },
|
||||
/// An XCM exceeded the individual message weight budget.
|
||||
OverweightEnqueued {
|
||||
sender: ParaId,
|
||||
@@ -368,7 +365,7 @@ pub mod pallet {
|
||||
/// `service_overweight`.
|
||||
#[pallet::storage]
|
||||
pub(super) type Overweight<T: Config> =
|
||||
StorageMap<_, Twox64Concat, OverweightIndex, (ParaId, RelayBlockNumber, Vec<u8>)>;
|
||||
CountedStorageMap<_, Twox64Concat, OverweightIndex, (ParaId, RelayBlockNumber, Vec<u8>)>;
|
||||
|
||||
/// The number of overweight messages ever recorded in `Overweight`. Also doubles as the next
|
||||
/// available free overweight index.
|
||||
@@ -623,34 +620,23 @@ impl<T: Config> Pallet<T> {
|
||||
xcm: VersionedXcm<T::RuntimeCall>,
|
||||
max_weight: Weight,
|
||||
) -> Result<Weight, XcmError> {
|
||||
let hash = Encode::using_encoded(&xcm, T::Hashing::hash);
|
||||
let hash = xcm.using_encoded(sp_io::hashing::blake2_256);
|
||||
log::debug!("Processing XCMP-XCM: {:?}", &hash);
|
||||
let (result, event) = match Xcm::<T::RuntimeCall>::try_from(xcm) {
|
||||
Ok(xcm) => {
|
||||
let location = (1, Parachain(sender.into()));
|
||||
let location = (Parent, Parachain(sender.into()));
|
||||
|
||||
match T::XcmExecutor::execute_xcm(location, xcm, max_weight.ref_time()) {
|
||||
match T::XcmExecutor::execute_xcm(location, xcm, hash, max_weight) {
|
||||
Outcome::Error(e) => (
|
||||
Err(e),
|
||||
Event::Fail { message_hash: Some(hash), error: e, weight: Weight::zero() },
|
||||
),
|
||||
Outcome::Complete(w) => (
|
||||
Ok(Weight::from_ref_time(w)),
|
||||
Event::Success {
|
||||
message_hash: Some(hash),
|
||||
weight: Weight::from_ref_time(w),
|
||||
},
|
||||
),
|
||||
Outcome::Complete(w) =>
|
||||
(Ok(w), Event::Success { message_hash: Some(hash), weight: w }),
|
||||
// As far as the caller is concerned, this was dispatched without error, so
|
||||
// we just report the weight used.
|
||||
Outcome::Incomplete(w, e) => (
|
||||
Ok(Weight::from_ref_time(w)),
|
||||
Event::Fail {
|
||||
message_hash: Some(hash),
|
||||
error: e,
|
||||
weight: Weight::from_ref_time(w),
|
||||
},
|
||||
),
|
||||
Outcome::Incomplete(w, e) =>
|
||||
(Ok(w), Event::Fail { message_hash: Some(hash), error: e, weight: w }),
|
||||
}
|
||||
},
|
||||
Err(()) =>
|
||||
@@ -663,6 +649,7 @@ impl<T: Config> Pallet<T> {
|
||||
fn process_xcmp_message(
|
||||
sender: ParaId,
|
||||
(sent_at, format): (RelayBlockNumber, XcmpMessageFormat),
|
||||
messages_processed: &mut u8,
|
||||
max_weight: Weight,
|
||||
max_individual_weight: Weight,
|
||||
) -> (Weight, bool) {
|
||||
@@ -672,35 +659,45 @@ impl<T: Config> Pallet<T> {
|
||||
let mut weight_used = Weight::zero();
|
||||
match format {
|
||||
XcmpMessageFormat::ConcatenatedVersionedXcm => {
|
||||
while !remaining_fragments.is_empty() {
|
||||
while !remaining_fragments.is_empty() &&
|
||||
*messages_processed < MAX_MESSAGES_PER_BLOCK
|
||||
{
|
||||
last_remaining_fragments = remaining_fragments;
|
||||
if let Ok(xcm) = VersionedXcm::<T::RuntimeCall>::decode_with_depth_limit(
|
||||
MAX_XCM_DECODE_DEPTH,
|
||||
&mut remaining_fragments,
|
||||
) {
|
||||
let weight = max_weight - weight_used;
|
||||
*messages_processed += 1;
|
||||
match Self::handle_xcm_message(sender, sent_at, xcm, weight) {
|
||||
Ok(used) => weight_used = weight_used.saturating_add(used),
|
||||
Err(XcmError::WeightLimitReached(required))
|
||||
if required > max_individual_weight.ref_time() =>
|
||||
if required.any_gt(max_individual_weight) =>
|
||||
{
|
||||
// overweight - add to overweight queue and continue with message
|
||||
// execution consuming the message.
|
||||
let msg_len = last_remaining_fragments
|
||||
.len()
|
||||
.saturating_sub(remaining_fragments.len());
|
||||
let overweight_xcm = last_remaining_fragments[..msg_len].to_vec();
|
||||
let index = Self::stash_overweight(sender, sent_at, overweight_xcm);
|
||||
let e = Event::OverweightEnqueued {
|
||||
sender,
|
||||
sent_at,
|
||||
index,
|
||||
required: Weight::from_ref_time(required),
|
||||
};
|
||||
Self::deposit_event(e);
|
||||
let is_under_limit =
|
||||
Overweight::<T>::count() < MAX_OVERWEIGHT_MESSAGES;
|
||||
weight_used.saturating_accrue(T::DbWeight::get().reads(1));
|
||||
if is_under_limit {
|
||||
// overweight - add to overweight queue and continue with message
|
||||
// execution consuming the message.
|
||||
let msg_len = last_remaining_fragments
|
||||
.len()
|
||||
.saturating_sub(remaining_fragments.len());
|
||||
let overweight_xcm =
|
||||
last_remaining_fragments[..msg_len].to_vec();
|
||||
let index =
|
||||
Self::stash_overweight(sender, sent_at, overweight_xcm);
|
||||
let e = Event::OverweightEnqueued {
|
||||
sender,
|
||||
sent_at,
|
||||
index,
|
||||
required,
|
||||
};
|
||||
Self::deposit_event(e);
|
||||
}
|
||||
},
|
||||
Err(XcmError::WeightLimitReached(required))
|
||||
if required <= max_weight.ref_time() =>
|
||||
if required.all_lte(max_weight) =>
|
||||
{
|
||||
// That message didn't get processed this time because of being
|
||||
// too heavy. We leave it around for next time and bail.
|
||||
@@ -727,6 +724,7 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
if let Ok(blob) = <Vec<u8>>::decode(&mut remaining_fragments) {
|
||||
let weight = max_weight - weight_used;
|
||||
*messages_processed += 1;
|
||||
match Self::handle_blob_message(sender, sent_at, blob, weight) {
|
||||
Ok(used) => weight_used = weight_used.saturating_add(used),
|
||||
Err(true) => {
|
||||
@@ -804,6 +802,7 @@ impl<T: Config> Pallet<T> {
|
||||
/// further.
|
||||
fn service_xcmp_queue(max_weight: Weight) -> Weight {
|
||||
let suspended = QueueSuspended::<T>::get();
|
||||
let mut messages_processed = 0;
|
||||
|
||||
let mut status = <InboundXcmpStatus<T>>::get(); // <- sorted.
|
||||
if status.is_empty() {
|
||||
@@ -832,12 +831,13 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
let mut shuffle_index = 0;
|
||||
while shuffle_index < shuffled.len() &&
|
||||
max_weight.saturating_sub(weight_used).all_gte(threshold_weight)
|
||||
max_weight.saturating_sub(weight_used).all_gte(threshold_weight) &&
|
||||
messages_processed < MAX_MESSAGES_PER_BLOCK
|
||||
{
|
||||
let index = shuffled[shuffle_index];
|
||||
let sender = status[index].sender;
|
||||
let sender_origin = T::ControllerOriginConverter::convert_origin(
|
||||
(1, Parachain(sender.into())),
|
||||
(Parent, Parachain(sender.into())),
|
||||
OriginKind::Superuser,
|
||||
);
|
||||
let is_controller = sender_origin
|
||||
@@ -872,6 +872,7 @@ impl<T: Config> Pallet<T> {
|
||||
let (weight_processed, is_empty) = Self::process_xcmp_message(
|
||||
sender,
|
||||
status[index].message_metadata[0],
|
||||
&mut messages_processed,
|
||||
weight_remaining,
|
||||
xcmp_max_individual_weight,
|
||||
);
|
||||
@@ -1133,28 +1134,60 @@ impl<T: Config> XcmpMessageSource for Pallet<T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub trait PriceForSiblingDelivery {
|
||||
fn price_for_sibling_delivery(id: ParaId, message: &Xcm<()>) -> MultiAssets;
|
||||
}
|
||||
|
||||
impl PriceForSiblingDelivery for () {
|
||||
fn price_for_sibling_delivery(_: ParaId, _: &Xcm<()>) -> MultiAssets {
|
||||
MultiAssets::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Get<MultiAssets>> PriceForSiblingDelivery for ConstantPrice<T> {
|
||||
fn price_for_sibling_delivery(_: ParaId, _: &Xcm<()>) -> MultiAssets {
|
||||
T::get()
|
||||
}
|
||||
}
|
||||
|
||||
/// Xcm sender for sending to a sibling parachain.
|
||||
impl<T: Config> SendXcm for Pallet<T> {
|
||||
fn send_xcm(dest: impl Into<MultiLocation>, msg: Xcm<()>) -> Result<(), SendError> {
|
||||
let dest = dest.into();
|
||||
type Ticket = (ParaId, VersionedXcm<()>);
|
||||
|
||||
match &dest {
|
||||
fn validate(
|
||||
dest: &mut Option<MultiLocation>,
|
||||
msg: &mut Option<Xcm<()>>,
|
||||
) -> SendResult<(ParaId, VersionedXcm<()>)> {
|
||||
let d = dest.take().ok_or(SendError::MissingArgument)?;
|
||||
|
||||
match &d {
|
||||
// An HRMP message for a sibling parachain.
|
||||
MultiLocation { parents: 1, interior: X1(Parachain(id)) } => {
|
||||
let versioned_xcm = T::VersionWrapper::wrap_version(&dest, msg)
|
||||
let xcm = msg.take().ok_or(SendError::MissingArgument)?;
|
||||
let id = ParaId::from(*id);
|
||||
let price = T::PriceForSiblingDelivery::price_for_sibling_delivery(id, &xcm);
|
||||
let versioned_xcm = T::VersionWrapper::wrap_version(&d, xcm)
|
||||
.map_err(|()| SendError::DestinationUnsupported)?;
|
||||
let hash = T::Hashing::hash_of(&versioned_xcm);
|
||||
Self::send_fragment(
|
||||
(*id).into(),
|
||||
XcmpMessageFormat::ConcatenatedVersionedXcm,
|
||||
versioned_xcm,
|
||||
)
|
||||
.map_err(|e| SendError::Transport(<&'static str>::from(e)))?;
|
||||
Self::deposit_event(Event::XcmpMessageSent { message_hash: Some(hash) });
|
||||
Ok(())
|
||||
Ok(((id, versioned_xcm), price))
|
||||
},
|
||||
// Anything else is unhandled. This includes a message this is meant for us.
|
||||
_ => Err(SendError::CannotReachDestination(dest, msg)),
|
||||
_ => {
|
||||
// Anything else is unhandled. This includes a message that is not meant for us.
|
||||
// We need to make sure that dest/msg is not consumed here.
|
||||
*dest = Some(d);
|
||||
Err(SendError::NotApplicable)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn deliver((id, xcm): (ParaId, VersionedXcm<()>)) -> Result<XcmHash, SendError> {
|
||||
let hash = xcm.using_encoded(sp_io::hashing::blake2_256);
|
||||
|
||||
match Self::send_fragment(id, XcmpMessageFormat::ConcatenatedVersionedXcm, xcm) {
|
||||
Ok(_) => {
|
||||
Self::deposit_event(Event::XcmpMessageSent { message_hash: Some(hash) });
|
||||
Ok(hash)
|
||||
},
|
||||
Err(e) => Err(SendError::Transport(<&'static str>::from(e))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ use frame_support::{
|
||||
traits::StorageVersion,
|
||||
weights::{constants::WEIGHT_REF_TIME_PER_MILLIS, Weight},
|
||||
};
|
||||
use xcm::latest::Weight as XcmWeight;
|
||||
|
||||
/// The current storage version.
|
||||
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(2);
|
||||
@@ -33,8 +32,15 @@ pub fn migrate_to_latest<T: Config>() -> Weight {
|
||||
let mut weight = T::DbWeight::get().reads(1);
|
||||
|
||||
if StorageVersion::get::<Pallet<T>>() == 1 {
|
||||
weight += migrate_to_v2::<T>();
|
||||
weight.saturating_accrue(migrate_to_v2::<T>());
|
||||
StorageVersion::new(2).put::<Pallet<T>>();
|
||||
weight.saturating_accrue(T::DbWeight::get().writes(1));
|
||||
}
|
||||
|
||||
if StorageVersion::get::<Pallet<T>>() == 2 {
|
||||
weight.saturating_accrue(migrate_to_v3::<T>());
|
||||
StorageVersion::new(3).put::<Pallet<T>>();
|
||||
weight.saturating_accrue(T::DbWeight::get().writes(1));
|
||||
}
|
||||
|
||||
weight
|
||||
@@ -49,9 +55,9 @@ mod v1 {
|
||||
pub suspend_threshold: u32,
|
||||
pub drop_threshold: u32,
|
||||
pub resume_threshold: u32,
|
||||
pub threshold_weight: XcmWeight,
|
||||
pub weight_restrict_decay: XcmWeight,
|
||||
pub xcmp_max_individual_weight: XcmWeight,
|
||||
pub threshold_weight: u64,
|
||||
pub weight_restrict_decay: u64,
|
||||
pub xcmp_max_individual_weight: u64,
|
||||
}
|
||||
|
||||
impl Default for QueueConfigData {
|
||||
@@ -98,6 +104,12 @@ pub fn migrate_to_v2<T: Config>() -> Weight {
|
||||
T::DbWeight::get().reads_writes(1, 1)
|
||||
}
|
||||
|
||||
pub fn migrate_to_v3<T: Config>() -> Weight {
|
||||
let overweight_messages = <Pallet<T> as Store>::Overweight::initialize_counter() as u64;
|
||||
|
||||
T::DbWeight::get().reads_writes(overweight_messages, 1)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@@ -18,7 +18,10 @@ use crate as xcmp_queue;
|
||||
use core::marker::PhantomData;
|
||||
use cumulus_pallet_parachain_system::AnyRelayNumber;
|
||||
use cumulus_primitives_core::{IsSystem, ParaId};
|
||||
use frame_support::{parameter_types, traits::OriginTrait};
|
||||
use frame_support::{
|
||||
parameter_types,
|
||||
traits::{Everything, Nothing, OriginTrait},
|
||||
};
|
||||
use frame_system::EnsureRoot;
|
||||
use sp_core::H256;
|
||||
use sp_runtime::{
|
||||
@@ -26,9 +29,7 @@ use sp_runtime::{
|
||||
traits::{BlakeTwo256, IdentityLookup},
|
||||
};
|
||||
use xcm::prelude::*;
|
||||
use xcm_builder::{
|
||||
CurrencyAdapter, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset, ParentIsPreset,
|
||||
};
|
||||
use xcm_builder::{CurrencyAdapter, FixedWeightBounds, IsConcrete, NativeAsset, ParentIsPreset};
|
||||
use xcm_executor::traits::ConvertOrigin;
|
||||
|
||||
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
|
||||
@@ -58,7 +59,7 @@ parameter_types! {
|
||||
type AccountId = u64;
|
||||
|
||||
impl frame_system::Config for Test {
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
type BaseCallFilter = Everything;
|
||||
type BlockWeights = ();
|
||||
type BlockLength = ();
|
||||
type DbWeight = ();
|
||||
@@ -115,9 +116,10 @@ impl cumulus_pallet_parachain_system::Config for Test {
|
||||
|
||||
parameter_types! {
|
||||
pub const RelayChain: MultiLocation = MultiLocation::parent();
|
||||
pub Ancestry: MultiLocation = X1(Parachain(1u32.into())).into();
|
||||
pub UnitWeightCost: u64 = 1_000_000;
|
||||
pub UniversalLocation: InteriorMultiLocation = X1(Parachain(1u32.into())).into();
|
||||
pub UnitWeightCost: Weight = Weight::from_parts(1_000_000, 1024);
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
pub const MaxAssetsIntoHolding: u32 = 64;
|
||||
}
|
||||
|
||||
/// Means for transacting assets on this chain.
|
||||
@@ -145,7 +147,7 @@ impl xcm_executor::Config for XcmConfig {
|
||||
type OriginConverter = ();
|
||||
type IsReserve = NativeAsset;
|
||||
type IsTeleporter = NativeAsset;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type UniversalLocation = UniversalLocation;
|
||||
type Barrier = ();
|
||||
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
|
||||
type Trader = ();
|
||||
@@ -153,6 +155,15 @@ impl xcm_executor::Config for XcmConfig {
|
||||
type AssetTrap = ();
|
||||
type AssetClaims = ();
|
||||
type SubscriptionService = ();
|
||||
type PalletInstancesInfo = AllPalletsWithSystem;
|
||||
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
|
||||
type AssetLocker = ();
|
||||
type AssetExchanger = ();
|
||||
type FeeManager = ();
|
||||
type MessageExporter = ();
|
||||
type UniversalAliases = Nothing;
|
||||
type CallDispatcher = RuntimeCall;
|
||||
type SafeCallFilter = Everything;
|
||||
}
|
||||
|
||||
pub type XcmRouter = (
|
||||
@@ -193,6 +204,7 @@ impl Config for Test {
|
||||
type ControllerOrigin = EnsureRoot<AccountId>;
|
||||
type ControllerOriginConverter = SystemParachainAsSuperuser<RuntimeOrigin>;
|
||||
type WeightInfo = ();
|
||||
type PriceForSiblingDelivery = ();
|
||||
}
|
||||
|
||||
pub fn new_test_ext() -> sp_io::TestExternalities {
|
||||
|
||||
@@ -46,6 +46,7 @@ fn bad_message_is_handled() {
|
||||
XcmpQueue::process_xcmp_message(
|
||||
1000.into(),
|
||||
(1, format),
|
||||
&mut 0,
|
||||
Weight::from_ref_time(10_000_000_000),
|
||||
Weight::from_ref_time(10_000_000_000),
|
||||
);
|
||||
@@ -69,6 +70,7 @@ fn handle_blob_message() {
|
||||
XcmpQueue::process_xcmp_message(
|
||||
1000.into(),
|
||||
(1, format),
|
||||
&mut 0,
|
||||
Weight::from_ref_time(10_000_000_000),
|
||||
Weight::from_ref_time(10_000_000_000),
|
||||
);
|
||||
@@ -86,6 +88,7 @@ fn handle_invalid_data() {
|
||||
XcmpQueue::process_xcmp_message(
|
||||
1000.into(),
|
||||
(1, format),
|
||||
&mut 0,
|
||||
Weight::from_ref_time(10_000_000_000),
|
||||
Weight::from_ref_time(10_000_000_000),
|
||||
);
|
||||
@@ -96,7 +99,7 @@ fn handle_invalid_data() {
|
||||
fn service_overweight_unknown() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_noop!(
|
||||
XcmpQueue::service_overweight(RuntimeOrigin::root(), 0, 1000),
|
||||
XcmpQueue::service_overweight(RuntimeOrigin::root(), 0, Weight::from_parts(1000, 1000)),
|
||||
Error::<Test>::BadOverweightIndex,
|
||||
);
|
||||
});
|
||||
@@ -109,7 +112,7 @@ fn service_overweight_bad_xcm_format() {
|
||||
Overweight::<Test>::insert(0, (ParaId::from(1000), 0, bad_xcm));
|
||||
|
||||
assert_noop!(
|
||||
XcmpQueue::service_overweight(RuntimeOrigin::root(), 0, 1000),
|
||||
XcmpQueue::service_overweight(RuntimeOrigin::root(), 0, Weight::from_parts(1000, 1000)),
|
||||
Error::<Test>::BadXcm
|
||||
);
|
||||
});
|
||||
@@ -187,9 +190,15 @@ fn update_threshold_weight_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let data: QueueConfigData = <QueueConfig<Test>>::get();
|
||||
assert_eq!(data.threshold_weight, Weight::from_ref_time(100_000));
|
||||
assert_ok!(XcmpQueue::update_threshold_weight(RuntimeOrigin::root(), 10_000));
|
||||
assert_ok!(XcmpQueue::update_threshold_weight(
|
||||
RuntimeOrigin::root(),
|
||||
Weight::from_ref_time(10_000)
|
||||
));
|
||||
assert_noop!(
|
||||
XcmpQueue::update_threshold_weight(RuntimeOrigin::signed(5), 10_000_000),
|
||||
XcmpQueue::update_threshold_weight(
|
||||
RuntimeOrigin::signed(5),
|
||||
Weight::from_ref_time(10_000_000),
|
||||
),
|
||||
BadOrigin
|
||||
);
|
||||
let data: QueueConfigData = <QueueConfig<Test>>::get();
|
||||
@@ -203,9 +212,15 @@ fn update_weight_restrict_decay_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let data: QueueConfigData = <QueueConfig<Test>>::get();
|
||||
assert_eq!(data.weight_restrict_decay, Weight::from_ref_time(2));
|
||||
assert_ok!(XcmpQueue::update_weight_restrict_decay(RuntimeOrigin::root(), 5));
|
||||
assert_ok!(XcmpQueue::update_weight_restrict_decay(
|
||||
RuntimeOrigin::root(),
|
||||
Weight::from_ref_time(5)
|
||||
));
|
||||
assert_noop!(
|
||||
XcmpQueue::update_weight_restrict_decay(RuntimeOrigin::signed(6), 4),
|
||||
XcmpQueue::update_weight_restrict_decay(
|
||||
RuntimeOrigin::signed(6),
|
||||
Weight::from_ref_time(4),
|
||||
),
|
||||
BadOrigin
|
||||
);
|
||||
let data: QueueConfigData = <QueueConfig<Test>>::get();
|
||||
@@ -224,12 +239,12 @@ fn update_xcmp_max_individual_weight() {
|
||||
);
|
||||
assert_ok!(XcmpQueue::update_xcmp_max_individual_weight(
|
||||
RuntimeOrigin::root(),
|
||||
30u64 * WEIGHT_REF_TIME_PER_MILLIS
|
||||
Weight::from_ref_time(30u64 * WEIGHT_REF_TIME_PER_MILLIS)
|
||||
));
|
||||
assert_noop!(
|
||||
XcmpQueue::update_xcmp_max_individual_weight(
|
||||
RuntimeOrigin::signed(3),
|
||||
10u64 * WEIGHT_REF_TIME_PER_MILLIS
|
||||
Weight::from_ref_time(10u64 * WEIGHT_REF_TIME_PER_MILLIS)
|
||||
),
|
||||
BadOrigin
|
||||
);
|
||||
@@ -241,3 +256,88 @@ fn update_xcmp_max_individual_weight() {
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/// Validates [`validate`] for required Some(destination) and Some(message)
|
||||
struct OkFixedXcmHashWithAssertingRequiredInputsSender;
|
||||
impl OkFixedXcmHashWithAssertingRequiredInputsSender {
|
||||
const FIXED_XCM_HASH: [u8; 32] = [9; 32];
|
||||
|
||||
fn fixed_delivery_asset() -> MultiAssets {
|
||||
MultiAssets::new()
|
||||
}
|
||||
|
||||
fn expected_delivery_result() -> Result<(XcmHash, MultiAssets), SendError> {
|
||||
Ok((Self::FIXED_XCM_HASH, Self::fixed_delivery_asset()))
|
||||
}
|
||||
}
|
||||
impl SendXcm for OkFixedXcmHashWithAssertingRequiredInputsSender {
|
||||
type Ticket = ();
|
||||
|
||||
fn validate(
|
||||
destination: &mut Option<MultiLocation>,
|
||||
message: &mut Option<Xcm<()>>,
|
||||
) -> SendResult<Self::Ticket> {
|
||||
assert!(destination.is_some());
|
||||
assert!(message.is_some());
|
||||
Ok(((), OkFixedXcmHashWithAssertingRequiredInputsSender::fixed_delivery_asset()))
|
||||
}
|
||||
|
||||
fn deliver(_: Self::Ticket) -> Result<XcmHash, SendError> {
|
||||
Ok(Self::FIXED_XCM_HASH)
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn xcmp_queue_does_not_consume_dest_or_msg_on_not_applicable() {
|
||||
// dummy message
|
||||
let message = Xcm(vec![Trap(5)]);
|
||||
|
||||
// XcmpQueue - check dest is really not applicable
|
||||
let dest = (Parent, Parent, Parent);
|
||||
let mut dest_wrapper = Some(dest.clone().into());
|
||||
let mut msg_wrapper = Some(message.clone());
|
||||
assert_eq!(
|
||||
Err(SendError::NotApplicable),
|
||||
<XcmpQueue as SendXcm>::validate(&mut dest_wrapper, &mut msg_wrapper)
|
||||
);
|
||||
|
||||
// check wrapper were not consumed
|
||||
assert_eq!(Some(dest.clone().into()), dest_wrapper.take());
|
||||
assert_eq!(Some(message.clone()), msg_wrapper.take());
|
||||
|
||||
// another try with router chain with asserting sender
|
||||
assert_eq!(
|
||||
OkFixedXcmHashWithAssertingRequiredInputsSender::expected_delivery_result(),
|
||||
send_xcm::<(XcmpQueue, OkFixedXcmHashWithAssertingRequiredInputsSender)>(
|
||||
dest.into(),
|
||||
message
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn xcmp_queue_consumes_dest_and_msg_on_ok_validate() {
|
||||
// dummy message
|
||||
let message = Xcm(vec![Trap(5)]);
|
||||
|
||||
// XcmpQueue - check dest/msg is valid
|
||||
let dest = (Parent, X1(Parachain(5555)));
|
||||
let mut dest_wrapper = Some(dest.clone().into());
|
||||
let mut msg_wrapper = Some(message.clone());
|
||||
assert!(<XcmpQueue as SendXcm>::validate(&mut dest_wrapper, &mut msg_wrapper).is_ok());
|
||||
|
||||
// check wrapper were consumed
|
||||
assert_eq!(None, dest_wrapper.take());
|
||||
assert_eq!(None, msg_wrapper.take());
|
||||
|
||||
new_test_ext().execute_with(|| {
|
||||
// another try with router chain with asserting sender
|
||||
assert_eq!(
|
||||
Err(SendError::Transport("NoChannel")),
|
||||
send_xcm::<(XcmpQueue, OkFixedXcmHashWithAssertingRequiredInputsSender)>(
|
||||
dest.into(),
|
||||
message
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -387,6 +387,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
|
||||
type ControllerOrigin = EnsureRoot<AccountId>;
|
||||
type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
|
||||
type WeightInfo = ();
|
||||
type PriceForSiblingDelivery = ();
|
||||
}
|
||||
|
||||
impl cumulus_pallet_dmp_queue::Config for Runtime {
|
||||
|
||||
@@ -1,30 +1,31 @@
|
||||
use super::{
|
||||
AccountId, Balances, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall,
|
||||
RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
|
||||
AccountId, AllPalletsWithSystem, Balances, ParachainInfo, ParachainSystem, PolkadotXcm,
|
||||
Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
|
||||
};
|
||||
use core::marker::PhantomData;
|
||||
use frame_support::{
|
||||
log, match_types, parameter_types,
|
||||
traits::{Everything, Nothing},
|
||||
traits::{ConstU32, Everything, Nothing},
|
||||
weights::Weight,
|
||||
};
|
||||
use pallet_xcm::XcmPassthrough;
|
||||
use polkadot_parachain::primitives::Sibling;
|
||||
use polkadot_runtime_common::impls::ToAuthor;
|
||||
use xcm::latest::{prelude::*, Weight as XCMWeight};
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,
|
||||
EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset, ParentIsPreset,
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowTopLevelPaidExecutionFrom,
|
||||
CurrencyAdapter, EnsureXcmOrigin, FixedWeightBounds, IsConcrete, NativeAsset, ParentIsPreset,
|
||||
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||
UsingComponents,
|
||||
UsingComponents, WithComputedOrigin,
|
||||
};
|
||||
use xcm_executor::{traits::ShouldExecute, XcmExecutor};
|
||||
|
||||
parameter_types! {
|
||||
pub const RelayLocation: MultiLocation = MultiLocation::parent();
|
||||
pub const RelayNetwork: NetworkId = NetworkId::Any;
|
||||
pub const RelayNetwork: Option<NetworkId> = None;
|
||||
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
||||
pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
|
||||
pub UniversalLocation: InteriorMultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
|
||||
}
|
||||
|
||||
/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
|
||||
@@ -76,8 +77,9 @@ pub type XcmOriginToTransactDispatchOrigin = (
|
||||
|
||||
parameter_types! {
|
||||
// One XCM operation is 1_000_000_000 weight - almost certainly a conservative estimate.
|
||||
pub UnitWeightCost: u64 = 1_000_000_000;
|
||||
pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 64 * 1024);
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
pub const MaxAssetsIntoHolding: u32 = 64;
|
||||
}
|
||||
|
||||
match_types! {
|
||||
@@ -102,9 +104,9 @@ where
|
||||
{
|
||||
fn should_execute<RuntimeCall>(
|
||||
origin: &MultiLocation,
|
||||
message: &mut Xcm<RuntimeCall>,
|
||||
max_weight: XCMWeight,
|
||||
weight_credit: &mut XCMWeight,
|
||||
message: &mut [Instruction<RuntimeCall>],
|
||||
max_weight: Weight,
|
||||
weight_credit: &mut Weight,
|
||||
) -> Result<(), ()> {
|
||||
Deny::should_execute(origin, message, max_weight, weight_credit)?;
|
||||
Allow::should_execute(origin, message, max_weight, weight_credit)
|
||||
@@ -116,12 +118,11 @@ pub struct DenyReserveTransferToRelayChain;
|
||||
impl ShouldExecute for DenyReserveTransferToRelayChain {
|
||||
fn should_execute<RuntimeCall>(
|
||||
origin: &MultiLocation,
|
||||
|
||||
message: &mut Xcm<RuntimeCall>,
|
||||
_max_weight: XCMWeight,
|
||||
_weight_credit: &mut XCMWeight,
|
||||
message: &mut [Instruction<RuntimeCall>],
|
||||
_max_weight: Weight,
|
||||
_weight_credit: &mut Weight,
|
||||
) -> Result<(), ()> {
|
||||
if message.0.iter().any(|inst| {
|
||||
if message.iter().any(|inst| {
|
||||
matches!(
|
||||
inst,
|
||||
InitiateReserveWithdraw {
|
||||
@@ -140,7 +141,7 @@ impl ShouldExecute for DenyReserveTransferToRelayChain {
|
||||
// An unexpected reserve transfer has arrived from the Relay Chain. Generally, `IsReserve`
|
||||
// should not allow this, but we just log it here.
|
||||
if matches!(origin, MultiLocation { parents: 1, interior: Here }) &&
|
||||
message.0.iter().any(|inst| matches!(inst, ReserveAssetDeposited { .. }))
|
||||
message.iter().any(|inst| matches!(inst, ReserveAssetDeposited { .. }))
|
||||
{
|
||||
log::warn!(
|
||||
target: "xcm::barriers",
|
||||
@@ -156,9 +157,15 @@ pub type Barrier = DenyThenTry<
|
||||
DenyReserveTransferToRelayChain,
|
||||
(
|
||||
TakeWeightCredit,
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
AllowUnpaidExecutionFrom<ParentOrParentsExecutivePlurality>,
|
||||
// ^^^ Parent and its exec plurality get free execution
|
||||
WithComputedOrigin<
|
||||
(
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
AllowExplicitUnpaidExecutionFrom<ParentOrParentsExecutivePlurality>,
|
||||
// ^^^ Parent and its exec plurality get free execution
|
||||
),
|
||||
UniversalLocation,
|
||||
ConstU32<8>,
|
||||
>,
|
||||
),
|
||||
>;
|
||||
|
||||
@@ -171,7 +178,7 @@ impl xcm_executor::Config for XcmConfig {
|
||||
type OriginConverter = XcmOriginToTransactDispatchOrigin;
|
||||
type IsReserve = NativeAsset;
|
||||
type IsTeleporter = (); // Teleporting is disabled.
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type UniversalLocation = UniversalLocation;
|
||||
type Barrier = Barrier;
|
||||
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
|
||||
type Trader =
|
||||
@@ -180,6 +187,15 @@ impl xcm_executor::Config for XcmConfig {
|
||||
type AssetTrap = PolkadotXcm;
|
||||
type AssetClaims = PolkadotXcm;
|
||||
type SubscriptionService = PolkadotXcm;
|
||||
type PalletInstancesInfo = AllPalletsWithSystem;
|
||||
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
|
||||
type AssetLocker = ();
|
||||
type AssetExchanger = ();
|
||||
type FeeManager = ();
|
||||
type MessageExporter = ();
|
||||
type UniversalAliases = Nothing;
|
||||
type CallDispatcher = RuntimeCall;
|
||||
type SafeCallFilter = Everything;
|
||||
}
|
||||
|
||||
/// No local origins on this chain are allowed to dispatch XCM sends/executions.
|
||||
@@ -189,11 +205,16 @@ pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, R
|
||||
/// queues.
|
||||
pub type XcmRouter = (
|
||||
// Two routers - use UMP to communicate with the relay chain:
|
||||
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,
|
||||
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, (), ()>,
|
||||
// ..and XCMP to communicate with the sibling chains.
|
||||
XcmpQueue,
|
||||
);
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
parameter_types! {
|
||||
pub ReachableDest: Option<MultiLocation> = Some(Parent.into());
|
||||
}
|
||||
|
||||
impl pallet_xcm::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type SendXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
|
||||
@@ -206,13 +227,21 @@ impl pallet_xcm::Config for Runtime {
|
||||
type XcmTeleportFilter = Everything;
|
||||
type XcmReserveTransferFilter = Nothing;
|
||||
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type UniversalLocation = UniversalLocation;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
|
||||
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
|
||||
// ^ Override for AdvertisedXcmVersion default
|
||||
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
|
||||
type Currency = Balances;
|
||||
type CurrencyMatcher = ();
|
||||
type TrustedLockers = ();
|
||||
type SovereignAccountOf = LocationToAccountId;
|
||||
type MaxLockers = ConstU32<8>;
|
||||
type WeightInfo = pallet_xcm::TestWeightInfo;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type ReachableDest = ReachableDest;
|
||||
}
|
||||
|
||||
impl cumulus_pallet_xcm::Config for Runtime {
|
||||
|
||||
@@ -28,6 +28,7 @@ sp-std = { git = "https://github.com/paritytech/substrate", default-features = f
|
||||
# Polkadot
|
||||
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||
xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||
xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||
xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||
|
||||
# Cumulus
|
||||
|
||||
@@ -18,13 +18,12 @@
|
||||
|
||||
use frame_support::traits::{
|
||||
fungibles::{self, Balanced, CreditOf},
|
||||
Contains, Currency, Get, Imbalance, OnUnbalanced,
|
||||
Contains, ContainsPair, Currency, Get, Imbalance, OnUnbalanced,
|
||||
};
|
||||
use pallet_asset_tx_payment::HandleCredit;
|
||||
use sp_runtime::traits::Zero;
|
||||
use sp_std::marker::PhantomData;
|
||||
use xcm::latest::{AssetId, Fungibility::Fungible, MultiAsset, MultiLocation};
|
||||
use xcm_executor::traits::FilterAssetLocation;
|
||||
|
||||
/// Type alias to conveniently refer to the `Currency::NegativeImbalance` associated type.
|
||||
pub type NegativeImbalance<T> = <pallet_balances::Pallet<T> as Currency<
|
||||
@@ -97,8 +96,8 @@ where
|
||||
|
||||
/// Asset filter that allows all assets from a certain location.
|
||||
pub struct AssetsFrom<T>(PhantomData<T>);
|
||||
impl<T: Get<MultiLocation>> FilterAssetLocation for AssetsFrom<T> {
|
||||
fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool {
|
||||
impl<T: Get<MultiLocation>> ContainsPair<MultiAsset, MultiLocation> for AssetsFrom<T> {
|
||||
fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool {
|
||||
let loc = T::get();
|
||||
&loc == origin &&
|
||||
matches!(asset, MultiAsset { id: AssetId::Concrete(asset_loc), fun: Fungible(_a) }
|
||||
@@ -267,12 +266,9 @@ mod tests {
|
||||
.clone()
|
||||
.pushed_with_interior(GeneralIndex(42))
|
||||
.expect("multilocation will only have 2 junctions; qed");
|
||||
let asset = MultiAsset { id: Concrete(asset_location), fun: 1_000_000.into() };
|
||||
let asset = MultiAsset { id: Concrete(asset_location), fun: 1_000_000u128.into() };
|
||||
assert!(
|
||||
AssetsFrom::<SomeSiblingParachain>::filter_asset_location(
|
||||
&asset,
|
||||
&SomeSiblingParachain::get()
|
||||
),
|
||||
AssetsFrom::<SomeSiblingParachain>::contains(&asset, &SomeSiblingParachain::get()),
|
||||
"AssetsFrom should allow assets from any of its interior locations"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@ use crate::impls::AccountIdOf;
|
||||
use core::marker::PhantomData;
|
||||
use frame_support::{
|
||||
log,
|
||||
traits::{fungibles::Inspect, tokens::BalanceConversion},
|
||||
traits::{fungibles::Inspect, tokens::BalanceConversion, ContainsPair},
|
||||
weights::{Weight, WeightToFee, WeightToFeePolynomial},
|
||||
};
|
||||
use sp_runtime::traits::Get;
|
||||
use xcm::latest::{prelude::*, Weight as XCMWeight};
|
||||
use xcm_executor::traits::{FilterAssetLocation, ShouldExecute};
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_executor::traits::ShouldExecute;
|
||||
|
||||
//TODO: move DenyThenTry to polkadot's xcm module.
|
||||
/// Deny executing the XCM if it matches any of the Deny filter regardless of anything else.
|
||||
@@ -24,9 +24,9 @@ where
|
||||
{
|
||||
fn should_execute<RuntimeCall>(
|
||||
origin: &MultiLocation,
|
||||
message: &mut Xcm<RuntimeCall>,
|
||||
max_weight: XCMWeight,
|
||||
weight_credit: &mut XCMWeight,
|
||||
message: &mut [Instruction<RuntimeCall>],
|
||||
max_weight: Weight,
|
||||
weight_credit: &mut Weight,
|
||||
) -> Result<(), ()> {
|
||||
Deny::should_execute(origin, message, max_weight, weight_credit)?;
|
||||
Allow::should_execute(origin, message, max_weight, weight_credit)
|
||||
@@ -38,11 +38,11 @@ pub struct DenyReserveTransferToRelayChain;
|
||||
impl ShouldExecute for DenyReserveTransferToRelayChain {
|
||||
fn should_execute<RuntimeCall>(
|
||||
origin: &MultiLocation,
|
||||
message: &mut Xcm<RuntimeCall>,
|
||||
_max_weight: XCMWeight,
|
||||
_weight_credit: &mut XCMWeight,
|
||||
message: &mut [Instruction<RuntimeCall>],
|
||||
_max_weight: Weight,
|
||||
_weight_credit: &mut Weight,
|
||||
) -> Result<(), ()> {
|
||||
if message.0.iter().any(|inst| {
|
||||
if message.iter().any(|inst| {
|
||||
matches!(
|
||||
inst,
|
||||
InitiateReserveWithdraw {
|
||||
@@ -61,7 +61,7 @@ impl ShouldExecute for DenyReserveTransferToRelayChain {
|
||||
// An unexpected reserve transfer has arrived from the Relay Chain. Generally, `IsReserve`
|
||||
// should not allow this, but we just log it here.
|
||||
if matches!(origin, MultiLocation { parents: 1, interior: Here }) &&
|
||||
message.0.iter().any(|inst| matches!(inst, ReserveAssetDeposited { .. }))
|
||||
message.iter().any(|inst| matches!(inst, ReserveAssetDeposited { .. }))
|
||||
{
|
||||
log::warn!(
|
||||
target: "xcm::barriers",
|
||||
@@ -111,8 +111,10 @@ where
|
||||
|
||||
/// Accepts an asset if it is a native asset from a particular `MultiLocation`.
|
||||
pub struct ConcreteNativeAssetFrom<Location>(PhantomData<Location>);
|
||||
impl<Location: Get<MultiLocation>> FilterAssetLocation for ConcreteNativeAssetFrom<Location> {
|
||||
fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool {
|
||||
impl<Location: Get<MultiLocation>> ContainsPair<MultiAsset, MultiLocation>
|
||||
for ConcreteNativeAssetFrom<Location>
|
||||
{
|
||||
fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool {
|
||||
log::trace!(target: "xcm::filter_asset_location",
|
||||
"ConcreteNativeAsset asset: {:?}, origin: {:?}, location: {:?}",
|
||||
asset, origin, Location::get());
|
||||
|
||||
@@ -78,9 +78,9 @@ pub mod pallet {
|
||||
#[pallet::event]
|
||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||
pub enum Event<T: Config> {
|
||||
PingSent(ParaId, u32, Vec<u8>),
|
||||
PingSent(ParaId, u32, Vec<u8>, XcmHash, MultiAssets),
|
||||
Pinged(ParaId, u32, Vec<u8>),
|
||||
PongSent(ParaId, u32, Vec<u8>),
|
||||
PongSent(ParaId, u32, Vec<u8>, XcmHash, MultiAssets),
|
||||
Ponged(ParaId, u32, Vec<u8>, T::BlockNumber),
|
||||
ErrorSendingPing(SendError, ParaId, u32, Vec<u8>),
|
||||
ErrorSendingPong(SendError, ParaId, u32, Vec<u8>),
|
||||
@@ -103,11 +103,11 @@ pub mod pallet {
|
||||
*seq += 1;
|
||||
*seq
|
||||
});
|
||||
match T::XcmSender::send_xcm(
|
||||
(1, Junction::Parachain(para.into())),
|
||||
match send_xcm::<T::XcmSender>(
|
||||
(Parent, Junction::Parachain(para.into())).into(),
|
||||
Xcm(vec![Transact {
|
||||
origin_type: OriginKind::Native,
|
||||
require_weight_at_most: 1_000,
|
||||
origin_kind: OriginKind::Native,
|
||||
require_weight_at_most: Weight::from_parts(1_000, 1_000),
|
||||
call: <T as Config>::RuntimeCall::from(Call::<T>::ping {
|
||||
seq,
|
||||
payload: payload.clone().to_vec(),
|
||||
@@ -116,9 +116,15 @@ pub mod pallet {
|
||||
.into(),
|
||||
}]),
|
||||
) {
|
||||
Ok(()) => {
|
||||
Ok((hash, cost)) => {
|
||||
Pings::<T>::insert(seq, n);
|
||||
Self::deposit_event(Event::PingSent(para, seq, payload.to_vec()));
|
||||
Self::deposit_event(Event::PingSent(
|
||||
para,
|
||||
seq,
|
||||
payload.to_vec(),
|
||||
hash,
|
||||
cost,
|
||||
));
|
||||
},
|
||||
Err(e) => {
|
||||
Self::deposit_event(Event::ErrorSendingPing(
|
||||
@@ -198,11 +204,11 @@ pub mod pallet {
|
||||
let para = ensure_sibling_para(<T as Config>::RuntimeOrigin::from(origin))?;
|
||||
|
||||
Self::deposit_event(Event::Pinged(para, seq, payload.clone()));
|
||||
match T::XcmSender::send_xcm(
|
||||
(1, Junction::Parachain(para.into())),
|
||||
match send_xcm::<T::XcmSender>(
|
||||
(Parent, Junction::Parachain(para.into())).into(),
|
||||
Xcm(vec![Transact {
|
||||
origin_type: OriginKind::Native,
|
||||
require_weight_at_most: 1_000,
|
||||
origin_kind: OriginKind::Native,
|
||||
require_weight_at_most: Weight::from_parts(1_000, 1_000),
|
||||
call: <T as Config>::RuntimeCall::from(Call::<T>::pong {
|
||||
seq,
|
||||
payload: payload.clone(),
|
||||
@@ -211,7 +217,8 @@ pub mod pallet {
|
||||
.into(),
|
||||
}]),
|
||||
) {
|
||||
Ok(()) => Self::deposit_event(Event::PongSent(para, seq, payload)),
|
||||
Ok((hash, cost)) =>
|
||||
Self::deposit_event(Event::PongSent(para, seq, payload, hash, cost)),
|
||||
Err(e) => Self::deposit_event(Event::ErrorSendingPong(e, para, seq, payload)),
|
||||
}
|
||||
Ok(())
|
||||
|
||||
@@ -471,6 +471,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
|
||||
>;
|
||||
type ControllerOriginConverter = xcm_config::XcmOriginToTransactDispatchOrigin;
|
||||
type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
|
||||
type PriceForSiblingDelivery = ();
|
||||
}
|
||||
|
||||
impl cumulus_pallet_dmp_queue::Config for Runtime {
|
||||
@@ -684,6 +685,7 @@ mod benches {
|
||||
[pallet_collator_selection, CollatorSelection]
|
||||
[cumulus_pallet_xcmp_queue, XcmpQueue]
|
||||
// XCM
|
||||
[pallet_xcm, PolkadotXcm]
|
||||
// NOTE: Make sure you point to the individual modules below.
|
||||
[pallet_xcm_benchmarks::fungible, XcmBalances]
|
||||
[pallet_xcm_benchmarks::generic, XcmGeneric]
|
||||
@@ -870,7 +872,7 @@ impl_runtime_apis! {
|
||||
impl cumulus_pallet_session_benchmarking::Config for Runtime {}
|
||||
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_config::KsmLocation;
|
||||
use xcm_config::{KsmLocation, MaxAssetsIntoHolding};
|
||||
use pallet_xcm_benchmarks::asset_instance_from;
|
||||
|
||||
impl pallet_xcm_benchmarks::Config for Runtime {
|
||||
@@ -879,12 +881,12 @@ impl_runtime_apis! {
|
||||
fn valid_destination() -> Result<MultiLocation, BenchmarkError> {
|
||||
Ok(KsmLocation::get())
|
||||
}
|
||||
fn worst_case_holding() -> MultiAssets {
|
||||
fn worst_case_holding(depositable_count: u32) -> MultiAssets {
|
||||
// A mix of fungible, non-fungible, and concrete assets.
|
||||
const HOLDING_FUNGIBLES: u32 = 100;
|
||||
const HOLDING_NON_FUNGIBLES: u32 = 100;
|
||||
let holding_non_fungibles = MaxAssetsIntoHolding::get() / 2 - depositable_count;
|
||||
let holding_fungibles = holding_non_fungibles.saturating_sub(1);
|
||||
let fungibles_amount: u128 = 100;
|
||||
let mut assets = (0..HOLDING_FUNGIBLES)
|
||||
let mut assets = (0..holding_fungibles)
|
||||
.map(|i| {
|
||||
MultiAsset {
|
||||
id: Concrete(GeneralIndex(i as u128).into()),
|
||||
@@ -893,17 +895,17 @@ impl_runtime_apis! {
|
||||
.into()
|
||||
})
|
||||
.chain(core::iter::once(MultiAsset { id: Concrete(Here.into()), fun: Fungible(u128::MAX) }))
|
||||
.chain((0..HOLDING_NON_FUNGIBLES).map(|i| MultiAsset {
|
||||
.chain((0..holding_non_fungibles).map(|i| MultiAsset {
|
||||
id: Concrete(GeneralIndex(i as u128).into()),
|
||||
fun: NonFungible(asset_instance_from(i)),
|
||||
}))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
assets.push(MultiAsset{
|
||||
id: Concrete(KsmLocation::get()),
|
||||
fun: Fungible(1_000_000 * UNITS),
|
||||
});
|
||||
assets.into()
|
||||
assets.push(MultiAsset {
|
||||
id: Concrete(KsmLocation::get()),
|
||||
fun: Fungible(1_000_000 * UNITS),
|
||||
});
|
||||
assets.into()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -912,8 +914,7 @@ impl_runtime_apis! {
|
||||
KsmLocation::get(),
|
||||
MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(KsmLocation::get()) },
|
||||
));
|
||||
pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = None;
|
||||
pub const CheckedAccount: Option<AccountId> = None;
|
||||
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
|
||||
|
||||
}
|
||||
|
||||
@@ -922,7 +923,6 @@ impl_runtime_apis! {
|
||||
|
||||
type CheckedAccount = CheckedAccount;
|
||||
type TrustedTeleporter = TrustedTeleporter;
|
||||
type TrustedReserve = TrustedReserve;
|
||||
|
||||
fn get_multi_asset() -> MultiAsset {
|
||||
MultiAsset {
|
||||
@@ -939,8 +939,16 @@ impl_runtime_apis! {
|
||||
(0u64, Response::Version(Default::default()))
|
||||
}
|
||||
|
||||
fn transact_origin() -> Result<MultiLocation, BenchmarkError> {
|
||||
Ok(KsmLocation::get())
|
||||
fn worst_case_asset_exchange() -> Result<(MultiAssets, MultiAssets), BenchmarkError> {
|
||||
Err(BenchmarkError::Skip)
|
||||
}
|
||||
|
||||
fn universal_alias() -> Result<Junction, BenchmarkError> {
|
||||
Err(BenchmarkError::Skip)
|
||||
}
|
||||
|
||||
fn transact_origin_and_runtime_call() -> Result<(MultiLocation, RuntimeCall), BenchmarkError> {
|
||||
Ok((KsmLocation::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
|
||||
}
|
||||
|
||||
fn subscribe_origin() -> Result<MultiLocation, BenchmarkError> {
|
||||
@@ -953,6 +961,10 @@ impl_runtime_apis! {
|
||||
let ticket = MultiLocation { parents: 0, interior: Here };
|
||||
Ok((origin, ticket, assets))
|
||||
}
|
||||
|
||||
fn unlockable_asset() -> Result<(MultiLocation, MultiLocation, MultiAsset), BenchmarkError> {
|
||||
Err(BenchmarkError::Skip)
|
||||
}
|
||||
}
|
||||
|
||||
type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
|
||||
|
||||
@@ -11,6 +11,7 @@ pub mod pallet_session;
|
||||
pub mod pallet_timestamp;
|
||||
pub mod pallet_uniques;
|
||||
pub mod pallet_utility;
|
||||
pub mod pallet_xcm;
|
||||
pub mod paritydb_weights;
|
||||
pub mod rocksdb_weights;
|
||||
pub mod xcm;
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
// Copyright 2021 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Cumulus.
|
||||
|
||||
// Cumulus is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Cumulus is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Autogenerated weights for `pallet_xcm`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2022-12-22, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// /home/benchbot/cargo_target_dir/production/polkadot-parachain
|
||||
// benchmark
|
||||
// pallet
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --extrinsic=*
|
||||
// --execution=wasm
|
||||
// --wasm-execution=compiled
|
||||
// --heap-pages=4096
|
||||
// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json
|
||||
// --pallet=pallet_xcm
|
||||
// --chain=statemine-dev
|
||||
// --header=./file_header.txt
|
||||
// --output=./parachains/runtimes/assets/statemine/src/weights/
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use frame_support::{traits::Get, weights::Weight};
|
||||
use sp_std::marker::PhantomData;
|
||||
|
||||
/// Weight functions for `pallet_xcm`.
|
||||
pub struct WeightInfo<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
fn send() -> Weight {
|
||||
// Minimum execution time: 26_577 nanoseconds.
|
||||
Weight::from_ref_time(27_239_000)
|
||||
.saturating_add(T::DbWeight::get().reads(5))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
fn teleport_assets() -> Weight {
|
||||
// Minimum execution time: 32_703 nanoseconds.
|
||||
Weight::from_ref_time(33_200_000)
|
||||
.saturating_add(T::DbWeight::get().reads(1))
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
fn reserve_transfer_assets() -> Weight {
|
||||
// Minimum execution time: 25_142 nanoseconds.
|
||||
Weight::from_ref_time(25_808_000)
|
||||
.saturating_add(T::DbWeight::get().reads(1))
|
||||
}
|
||||
// Storage: Benchmark Override (r:0 w:0)
|
||||
fn execute() -> Weight {
|
||||
// Minimum execution time: 18_446_744_073_709_551 nanoseconds.
|
||||
Weight::from_ref_time(18_446_744_073_709_551_000)
|
||||
}
|
||||
// Storage: PolkadotXcm SupportedVersion (r:0 w:1)
|
||||
fn force_xcm_version() -> Weight {
|
||||
// Minimum execution time: 15_036 nanoseconds.
|
||||
Weight::from_ref_time(15_456_000)
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
}
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:0 w:1)
|
||||
fn force_default_xcm_version() -> Weight {
|
||||
// Minimum execution time: 4_404 nanoseconds.
|
||||
Weight::from_ref_time(4_598_000)
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifiers (r:1 w:1)
|
||||
// Storage: PolkadotXcm QueryCounter (r:1 w:1)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
// Storage: PolkadotXcm Queries (r:0 w:1)
|
||||
fn force_subscribe_version_notify() -> Weight {
|
||||
// Minimum execution time: 30_942 nanoseconds.
|
||||
Weight::from_ref_time(31_608_000)
|
||||
.saturating_add(T::DbWeight::get().reads(7))
|
||||
.saturating_add(T::DbWeight::get().writes(5))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifiers (r:1 w:1)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
// Storage: PolkadotXcm Queries (r:0 w:1)
|
||||
fn force_unsubscribe_version_notify() -> Weight {
|
||||
// Minimum execution time: 32_327 nanoseconds.
|
||||
Weight::from_ref_time(32_698_000)
|
||||
.saturating_add(T::DbWeight::get().reads(6))
|
||||
.saturating_add(T::DbWeight::get().writes(4))
|
||||
}
|
||||
// Storage: PolkadotXcm SupportedVersion (r:4 w:2)
|
||||
fn migrate_supported_version() -> Weight {
|
||||
// Minimum execution time: 13_522 nanoseconds.
|
||||
Weight::from_ref_time(13_862_000)
|
||||
.saturating_add(T::DbWeight::get().reads(4))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifiers (r:4 w:2)
|
||||
fn migrate_version_notifiers() -> Weight {
|
||||
// Minimum execution time: 13_621 nanoseconds.
|
||||
Weight::from_ref_time(14_028_000)
|
||||
.saturating_add(T::DbWeight::get().reads(4))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:5 w:0)
|
||||
fn already_notified_target() -> Weight {
|
||||
// Minimum execution time: 15_511 nanoseconds.
|
||||
Weight::from_ref_time(15_825_000)
|
||||
.saturating_add(T::DbWeight::get().reads(5))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:2 w:1)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
fn notify_current_targets() -> Weight {
|
||||
// Minimum execution time: 27_062 nanoseconds.
|
||||
Weight::from_ref_time(27_514_000)
|
||||
.saturating_add(T::DbWeight::get().reads(7))
|
||||
.saturating_add(T::DbWeight::get().writes(3))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:3 w:0)
|
||||
fn notify_target_migration_fail() -> Weight {
|
||||
// Minimum execution time: 7_062 nanoseconds.
|
||||
Weight::from_ref_time(7_325_000)
|
||||
.saturating_add(T::DbWeight::get().reads(3))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:4 w:2)
|
||||
fn migrate_version_notify_targets() -> Weight {
|
||||
// Minimum execution time: 14_362 nanoseconds.
|
||||
Weight::from_ref_time(14_724_000)
|
||||
.saturating_add(T::DbWeight::get().reads(4))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:4 w:2)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
fn migrate_and_notify_old_targets() -> Weight {
|
||||
// Minimum execution time: 32_435 nanoseconds.
|
||||
Weight::from_ref_time(33_042_000)
|
||||
.saturating_add(T::DbWeight::get().reads(9))
|
||||
.saturating_add(T::DbWeight::get().writes(4))
|
||||
}
|
||||
}
|
||||
@@ -21,168 +21,220 @@ use crate::Runtime;
|
||||
use frame_support::weights::Weight;
|
||||
use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight;
|
||||
use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
|
||||
use sp_std::{cmp, prelude::*};
|
||||
use xcm::{
|
||||
latest::{prelude::*, Weight as XCMWeight},
|
||||
DoubleEncoded,
|
||||
};
|
||||
use sp_std::prelude::*;
|
||||
use xcm::{latest::prelude::*, DoubleEncoded};
|
||||
|
||||
trait WeighMultiAssets {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> XCMWeight;
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight;
|
||||
}
|
||||
|
||||
const MAX_ASSETS: u32 = 100;
|
||||
|
||||
impl WeighMultiAssets for MultiAssetFilter {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> XCMWeight {
|
||||
let weight = match self {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
||||
match self {
|
||||
Self::Definite(assets) =>
|
||||
weight.saturating_mul(assets.inner().into_iter().count() as u64),
|
||||
Self::Wild(_) => weight.saturating_mul(MAX_ASSETS as u64),
|
||||
};
|
||||
weight.ref_time()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl WeighMultiAssets for MultiAssets {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> XCMWeight {
|
||||
weight.saturating_mul(self.inner().into_iter().count() as u64).ref_time()
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
||||
weight.saturating_mul(self.inner().into_iter().count() as u64)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct StatemineXcmWeight<Call>(core::marker::PhantomData<Call>);
|
||||
impl<Call> XcmWeightInfo<Call> for StatemineXcmWeight<Call> {
|
||||
fn withdraw_asset(assets: &MultiAssets) -> XCMWeight {
|
||||
fn withdraw_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::withdraw_asset())
|
||||
}
|
||||
// Currently there is no trusted reserve
|
||||
fn reserve_asset_deposited(_assets: &MultiAssets) -> XCMWeight {
|
||||
u64::MAX
|
||||
fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight {
|
||||
// TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974
|
||||
Weight::from_ref_time(1_000_000_000 as u64)
|
||||
}
|
||||
fn receive_teleported_asset(assets: &MultiAssets) -> XCMWeight {
|
||||
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::receive_teleported_asset())
|
||||
}
|
||||
fn query_response(_query_id: &u64, _response: &Response, _max_weight: &u64) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::query_response().ref_time()
|
||||
fn query_response(
|
||||
_query_id: &u64,
|
||||
_response: &Response,
|
||||
_max_weight: &Weight,
|
||||
_querier: &Option<MultiLocation>,
|
||||
) -> Weight {
|
||||
XcmGeneric::<Runtime>::query_response()
|
||||
}
|
||||
fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> XCMWeight {
|
||||
fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::transfer_asset())
|
||||
}
|
||||
fn transfer_reserve_asset(
|
||||
assets: &MultiAssets,
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> XCMWeight {
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::transfer_reserve_asset())
|
||||
}
|
||||
fn transact(
|
||||
_origin_type: &OriginKind,
|
||||
_require_weight_at_most: &u64,
|
||||
_require_weight_at_most: &Weight,
|
||||
_call: &DoubleEncoded<Call>,
|
||||
) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::transact().ref_time()
|
||||
) -> Weight {
|
||||
XcmGeneric::<Runtime>::transact()
|
||||
}
|
||||
fn hrmp_new_channel_open_request(
|
||||
_sender: &u32,
|
||||
_max_message_size: &u32,
|
||||
_max_capacity: &u32,
|
||||
) -> XCMWeight {
|
||||
) -> Weight {
|
||||
// XCM Executor does not currently support HRMP channel operations
|
||||
Weight::MAX.ref_time()
|
||||
Weight::MAX
|
||||
}
|
||||
fn hrmp_channel_accepted(_recipient: &u32) -> XCMWeight {
|
||||
fn hrmp_channel_accepted(_recipient: &u32) -> Weight {
|
||||
// XCM Executor does not currently support HRMP channel operations
|
||||
Weight::MAX.ref_time()
|
||||
Weight::MAX
|
||||
}
|
||||
fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> XCMWeight {
|
||||
fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> Weight {
|
||||
// XCM Executor does not currently support HRMP channel operations
|
||||
Weight::MAX.ref_time()
|
||||
Weight::MAX
|
||||
}
|
||||
fn clear_origin() -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::clear_origin().ref_time()
|
||||
fn clear_origin() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_origin()
|
||||
}
|
||||
fn descend_origin(_who: &InteriorMultiLocation) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::descend_origin().ref_time()
|
||||
fn descend_origin(_who: &InteriorMultiLocation) -> Weight {
|
||||
XcmGeneric::<Runtime>::descend_origin()
|
||||
}
|
||||
fn report_error(
|
||||
_query_id: &QueryId,
|
||||
_dest: &MultiLocation,
|
||||
_max_response_weight: &u64,
|
||||
) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::report_error().ref_time()
|
||||
fn report_error(_query_response_info: &QueryResponseInfo) -> Weight {
|
||||
XcmGeneric::<Runtime>::report_error()
|
||||
}
|
||||
|
||||
fn deposit_asset(
|
||||
assets: &MultiAssetFilter,
|
||||
_max_assets: &u32,
|
||||
_dest: &MultiLocation,
|
||||
) -> XCMWeight {
|
||||
fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight {
|
||||
// Hardcoded till the XCM pallet is fixed
|
||||
let hardcoded_weight = Weight::from_ref_time(1_000_000_000 as u64).ref_time();
|
||||
let hardcoded_weight = Weight::from_ref_time(1_000_000_000 as u64);
|
||||
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_asset());
|
||||
cmp::min(hardcoded_weight, weight)
|
||||
hardcoded_weight.min(weight)
|
||||
}
|
||||
fn deposit_reserve_asset(
|
||||
assets: &MultiAssetFilter,
|
||||
_max_assets: &u32,
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> XCMWeight {
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_reserve_asset())
|
||||
}
|
||||
fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets) -> XCMWeight {
|
||||
Weight::MAX.ref_time()
|
||||
fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn initiate_reserve_withdraw(
|
||||
assets: &MultiAssetFilter,
|
||||
_reserve: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> XCMWeight {
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::initiate_reserve_withdraw())
|
||||
}
|
||||
fn initiate_teleport(
|
||||
assets: &MultiAssetFilter,
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> XCMWeight {
|
||||
) -> Weight {
|
||||
// Hardcoded till the XCM pallet is fixed
|
||||
let hardcoded_weight = Weight::from_ref_time(200_000_000 as u64).ref_time();
|
||||
let hardcoded_weight = Weight::from_ref_time(200_000_000 as u64);
|
||||
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport());
|
||||
cmp::min(hardcoded_weight, weight)
|
||||
hardcoded_weight.min(weight)
|
||||
}
|
||||
fn query_holding(
|
||||
_query_id: &u64,
|
||||
_dest: &MultiLocation,
|
||||
_assets: &MultiAssetFilter,
|
||||
_max_response_weight: &u64,
|
||||
) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::query_holding().ref_time()
|
||||
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
|
||||
XcmGeneric::<Runtime>::report_holding()
|
||||
}
|
||||
fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::buy_execution().ref_time()
|
||||
fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> Weight {
|
||||
XcmGeneric::<Runtime>::buy_execution()
|
||||
}
|
||||
fn refund_surplus() -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::refund_surplus().ref_time()
|
||||
fn refund_surplus() -> Weight {
|
||||
XcmGeneric::<Runtime>::refund_surplus()
|
||||
}
|
||||
fn set_error_handler(_xcm: &Xcm<Call>) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::set_error_handler().ref_time()
|
||||
fn set_error_handler(_xcm: &Xcm<Call>) -> Weight {
|
||||
XcmGeneric::<Runtime>::set_error_handler()
|
||||
}
|
||||
fn set_appendix(_xcm: &Xcm<Call>) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::set_appendix().ref_time()
|
||||
fn set_appendix(_xcm: &Xcm<Call>) -> Weight {
|
||||
XcmGeneric::<Runtime>::set_appendix()
|
||||
}
|
||||
fn clear_error() -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::clear_error().ref_time()
|
||||
fn clear_error() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_error()
|
||||
}
|
||||
fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::claim_asset().ref_time()
|
||||
fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> Weight {
|
||||
XcmGeneric::<Runtime>::claim_asset()
|
||||
}
|
||||
fn trap(_code: &u64) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::trap().ref_time()
|
||||
fn trap(_code: &u64) -> Weight {
|
||||
XcmGeneric::<Runtime>::trap()
|
||||
}
|
||||
fn subscribe_version(_query_id: &QueryId, _max_response_weight: &u64) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::subscribe_version().ref_time()
|
||||
fn subscribe_version(_query_id: &QueryId, _max_response_weight: &Weight) -> Weight {
|
||||
XcmGeneric::<Runtime>::subscribe_version()
|
||||
}
|
||||
fn unsubscribe_version() -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::unsubscribe_version().ref_time()
|
||||
fn unsubscribe_version() -> Weight {
|
||||
XcmGeneric::<Runtime>::unsubscribe_version()
|
||||
}
|
||||
fn burn_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::burn_asset())
|
||||
}
|
||||
fn expect_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::expect_asset())
|
||||
}
|
||||
fn expect_origin(_origin: &Option<MultiLocation>) -> Weight {
|
||||
XcmGeneric::<Runtime>::expect_origin()
|
||||
}
|
||||
fn expect_error(_error: &Option<(u32, XcmError)>) -> Weight {
|
||||
XcmGeneric::<Runtime>::expect_error()
|
||||
}
|
||||
fn query_pallet(_module_name: &Vec<u8>, _response_info: &QueryResponseInfo) -> Weight {
|
||||
XcmGeneric::<Runtime>::query_pallet()
|
||||
}
|
||||
fn expect_pallet(
|
||||
_index: &u32,
|
||||
_name: &Vec<u8>,
|
||||
_module_name: &Vec<u8>,
|
||||
_crate_major: &u32,
|
||||
_min_crate_minor: &u32,
|
||||
) -> Weight {
|
||||
XcmGeneric::<Runtime>::expect_pallet()
|
||||
}
|
||||
fn report_transact_status(_response_info: &QueryResponseInfo) -> Weight {
|
||||
XcmGeneric::<Runtime>::report_transact_status()
|
||||
}
|
||||
fn clear_transact_status() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_transact_status()
|
||||
}
|
||||
fn universal_origin(_: &Junction) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn set_fees_mode(_: &bool) -> Weight {
|
||||
XcmGeneric::<Runtime>::set_fees_mode()
|
||||
}
|
||||
fn set_topic(_topic: &[u8; 32]) -> Weight {
|
||||
XcmGeneric::<Runtime>::set_topic()
|
||||
}
|
||||
fn clear_topic() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_topic()
|
||||
}
|
||||
fn alias_origin(_: &MultiLocation) -> Weight {
|
||||
// XCM Executor does not currently support alias origin operations
|
||||
Weight::MAX
|
||||
}
|
||||
fn unpaid_execution(_: &WeightLimit, _: &Option<MultiLocation>) -> Weight {
|
||||
XcmGeneric::<Runtime>::unpaid_execution()
|
||||
}
|
||||
}
|
||||
|
||||
+19
-18
@@ -18,25 +18,26 @@
|
||||
//! Autogenerated weights for `pallet_xcm_benchmarks::fungible`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2022-12-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! DATE: 2022-12-14, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// ./artifacts/polkadot-parachain
|
||||
// /home/benchbot/cargo_target_dir/production/polkadot-parachain
|
||||
// benchmark
|
||||
// pallet
|
||||
// --template=./templates/xcm-bench-template.hbs
|
||||
// --chain=statemine-dev
|
||||
// --execution=wasm
|
||||
// --wasm-execution=compiled
|
||||
// --pallet=pallet_xcm_benchmarks::fungible
|
||||
// --extrinsic=*
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --json
|
||||
// --extrinsic=*
|
||||
// --execution=wasm
|
||||
// --wasm-execution=compiled
|
||||
// --heap-pages=4096
|
||||
// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json
|
||||
// --pallet=pallet_xcm_benchmarks::fungible
|
||||
// --chain=statemine-dev
|
||||
// --header=./file_header.txt
|
||||
// --output=./parachains/runtimes/assets/statemine/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
|
||||
// --template=./templates/xcm-bench-template.hbs
|
||||
// --output=./parachains/runtimes/assets/statemine/src/weights/xcm/
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
@@ -50,13 +51,13 @@ pub struct WeightInfo<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: System Account (r:1 w:1)
|
||||
pub(crate) fn withdraw_asset() -> Weight {
|
||||
Weight::from_ref_time(32_154_000 as u64)
|
||||
Weight::from_ref_time(31_498_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
// Storage: System Account (r:2 w:2)
|
||||
pub(crate) fn transfer_asset() -> Weight {
|
||||
Weight::from_ref_time(37_328_000 as u64)
|
||||
Weight::from_ref_time(39_782_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
@@ -68,16 +69,16 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn transfer_reserve_asset() -> Weight {
|
||||
Weight::from_ref_time(53_253_000 as u64)
|
||||
Weight::from_ref_time(55_814_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(8 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(4 as u64))
|
||||
}
|
||||
pub(crate) fn receive_teleported_asset() -> Weight {
|
||||
Weight::from_ref_time(6_378_000 as u64)
|
||||
Weight::from_ref_time(7_366_000 as u64)
|
||||
}
|
||||
// Storage: System Account (r:1 w:1)
|
||||
pub(crate) fn deposit_asset() -> Weight {
|
||||
Weight::from_ref_time(33_783_000 as u64)
|
||||
Weight::from_ref_time(59_346_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
@@ -89,7 +90,7 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn deposit_reserve_asset() -> Weight {
|
||||
Weight::from_ref_time(51_293_000 as u64)
|
||||
Weight::from_ref_time(49_991_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(7 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as u64))
|
||||
}
|
||||
@@ -100,7 +101,7 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn initiate_teleport() -> Weight {
|
||||
Weight::from_ref_time(28_390_000 as u64)
|
||||
Weight::from_ref_time(26_751_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
|
||||
+83
-29
@@ -18,25 +18,26 @@
|
||||
//! Autogenerated weights for `pallet_xcm_benchmarks::generic`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2022-12-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! DATE: 2022-12-14, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// ./artifacts/polkadot-parachain
|
||||
// /home/benchbot/cargo_target_dir/production/polkadot-parachain
|
||||
// benchmark
|
||||
// pallet
|
||||
// --template=./templates/xcm-bench-template.hbs
|
||||
// --chain=statemine-dev
|
||||
// --execution=wasm
|
||||
// --wasm-execution=compiled
|
||||
// --pallet=pallet_xcm_benchmarks::generic
|
||||
// --extrinsic=*
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --json
|
||||
// --extrinsic=*
|
||||
// --execution=wasm
|
||||
// --wasm-execution=compiled
|
||||
// --heap-pages=4096
|
||||
// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json
|
||||
// --pallet=pallet_xcm_benchmarks::generic
|
||||
// --chain=statemine-dev
|
||||
// --header=./file_header.txt
|
||||
// --output=./parachains/runtimes/assets/statemine/src/weights/xcm/pallet_xcm_benchmarks_generic.rs
|
||||
// --template=./templates/xcm-bench-template.hbs
|
||||
// --output=./parachains/runtimes/assets/statemine/src/weights/xcm/
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
@@ -54,58 +55,59 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn query_holding() -> Weight {
|
||||
Weight::from_ref_time(892_211_000 as u64)
|
||||
pub(crate) fn report_holding() -> Weight {
|
||||
Weight::from_ref_time(337_149_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
pub(crate) fn buy_execution() -> Weight {
|
||||
Weight::from_ref_time(8_728_000 as u64)
|
||||
Weight::from_ref_time(7_033_000 as u64)
|
||||
}
|
||||
// Storage: PolkadotXcm Queries (r:1 w:0)
|
||||
pub(crate) fn query_response() -> Weight {
|
||||
Weight::from_ref_time(16_766_000 as u64)
|
||||
Weight::from_ref_time(17_915_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
}
|
||||
pub(crate) fn transact() -> Weight {
|
||||
Weight::from_ref_time(19_546_000 as u64)
|
||||
Weight::from_ref_time(20_973_000 as u64)
|
||||
}
|
||||
pub(crate) fn refund_surplus() -> Weight {
|
||||
Weight::from_ref_time(8_907_000 as u64)
|
||||
Weight::from_ref_time(7_210_000 as u64)
|
||||
}
|
||||
pub(crate) fn set_error_handler() -> Weight {
|
||||
Weight::from_ref_time(5_393_000 as u64)
|
||||
Weight::from_ref_time(5_940_000 as u64)
|
||||
}
|
||||
pub(crate) fn set_appendix() -> Weight {
|
||||
Weight::from_ref_time(5_453_000 as u64)
|
||||
Weight::from_ref_time(5_869_000 as u64)
|
||||
}
|
||||
pub(crate) fn clear_error() -> Weight {
|
||||
Weight::from_ref_time(5_417_000 as u64)
|
||||
Weight::from_ref_time(5_860_000 as u64)
|
||||
}
|
||||
pub(crate) fn descend_origin() -> Weight {
|
||||
Weight::from_ref_time(6_700_000 as u64)
|
||||
Weight::from_ref_time(6_556_000 as u64)
|
||||
}
|
||||
pub(crate) fn clear_origin() -> Weight {
|
||||
Weight::from_ref_time(5_365_000 as u64)
|
||||
Weight::from_ref_time(5_862_000 as u64)
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn report_error() -> Weight {
|
||||
Weight::from_ref_time(15_258_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(5 as u64))
|
||||
Weight::from_ref_time(21_918_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
// Storage: PolkadotXcm AssetTraps (r:1 w:1)
|
||||
pub(crate) fn claim_asset() -> Weight {
|
||||
Weight::from_ref_time(21_485_000 as u64)
|
||||
Weight::from_ref_time(22_211_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
pub(crate) fn trap() -> Weight {
|
||||
Weight::from_ref_time(5_334_000 as u64)
|
||||
Weight::from_ref_time(5_844_000 as u64)
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:1 w:1)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
@@ -114,13 +116,13 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn subscribe_version() -> Weight {
|
||||
Weight::from_ref_time(18_035_000 as u64)
|
||||
Weight::from_ref_time(28_788_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as u64))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:0 w:1)
|
||||
pub(crate) fn unsubscribe_version() -> Weight {
|
||||
Weight::from_ref_time(7_661_000 as u64)
|
||||
Weight::from_ref_time(8_975_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
@@ -130,8 +132,60 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn initiate_reserve_withdraw() -> Weight {
|
||||
Weight::from_ref_time(1_090_619_000 as u64)
|
||||
Weight::from_ref_time(417_939_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
pub(crate) fn burn_asset() -> Weight {
|
||||
Weight::from_ref_time(137_412_000 as u64)
|
||||
}
|
||||
pub(crate) fn expect_asset() -> Weight {
|
||||
Weight::from_ref_time(16_437_000 as u64)
|
||||
}
|
||||
pub(crate) fn expect_origin() -> Weight {
|
||||
Weight::from_ref_time(5_890_000 as u64)
|
||||
}
|
||||
pub(crate) fn expect_error() -> Weight {
|
||||
Weight::from_ref_time(5_859_000 as u64)
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn query_pallet() -> Weight {
|
||||
Weight::from_ref_time(25_004_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
pub(crate) fn expect_pallet() -> Weight {
|
||||
Weight::from_ref_time(7_708_000 as u64)
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn report_transact_status() -> Weight {
|
||||
Weight::from_ref_time(22_445_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
pub(crate) fn clear_transact_status() -> Weight {
|
||||
Weight::from_ref_time(5_822_000 as u64)
|
||||
}
|
||||
pub(crate) fn set_topic() -> Weight {
|
||||
Weight::from_ref_time(5_763_000 as u64)
|
||||
}
|
||||
pub(crate) fn clear_topic() -> Weight {
|
||||
Weight::from_ref_time(5_766_000 as u64)
|
||||
}
|
||||
pub(crate) fn set_fees_mode() -> Weight {
|
||||
Weight::from_ref_time(5_907_000 as u64)
|
||||
}
|
||||
pub(crate) fn unpaid_execution() -> Weight {
|
||||
Weight::from_ref_time(5_996_000 as u64)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,12 +14,13 @@
|
||||
// limitations under the License.
|
||||
|
||||
use super::{
|
||||
AccountId, AssetId, Assets, Authorship, Balance, Balances, ParachainInfo, ParachainSystem,
|
||||
PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
|
||||
AccountId, AllPalletsWithSystem, AssetId, Assets, Authorship, Balance, Balances, ParachainInfo,
|
||||
ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee,
|
||||
XcmpQueue,
|
||||
};
|
||||
use frame_support::{
|
||||
match_types, parameter_types,
|
||||
traits::{Everything, Nothing, PalletInfoAccess},
|
||||
traits::{ConstU32, Contains, Everything, Nothing, PalletInfoAccess},
|
||||
};
|
||||
use pallet_xcm::XcmPassthrough;
|
||||
use parachains_common::{
|
||||
@@ -32,22 +33,26 @@ use polkadot_parachain::primitives::Sibling;
|
||||
use sp_runtime::traits::ConvertInto;
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
||||
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, AsPrefixedGeneralIndex,
|
||||
ConvertedConcreteAssetId, CurrencyAdapter, EnsureXcmOrigin, FungiblesAdapter, IsConcrete,
|
||||
LocationInverter, NativeAsset, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
|
||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
||||
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
|
||||
WeightInfoBounds,
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AsPrefixedGeneralIndex,
|
||||
ConvertedConcreteId, CurrencyAdapter, EnsureXcmOrigin, FungiblesAdapter, IsConcrete, LocalMint,
|
||||
NativeAsset, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
|
||||
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
|
||||
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds,
|
||||
WithComputedOrigin,
|
||||
};
|
||||
use xcm_executor::{
|
||||
traits::{JustTry, WithOriginFilter},
|
||||
XcmExecutor,
|
||||
};
|
||||
use xcm_executor::{traits::JustTry, XcmExecutor};
|
||||
|
||||
parameter_types! {
|
||||
pub const KsmLocation: MultiLocation = MultiLocation::parent();
|
||||
pub const RelayNetwork: NetworkId = NetworkId::Kusama;
|
||||
pub const RelayNetwork: Option<NetworkId> = Some(NetworkId::Kusama);
|
||||
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
||||
pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
|
||||
pub const Local: MultiLocation = Here.into();
|
||||
pub UniversalLocation: InteriorMultiLocation =
|
||||
X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into()));
|
||||
pub const Local: MultiLocation = Here.into_location();
|
||||
pub AssetsPalletLocation: MultiLocation =
|
||||
PalletInstance(<Assets as PalletInfoAccess>::index() as u8).into();
|
||||
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
|
||||
@@ -84,7 +89,7 @@ pub type FungiblesTransactor = FungiblesAdapter<
|
||||
// Use this fungibles implementation:
|
||||
Assets,
|
||||
// Use this currency when it is a fungible asset matching the given location or name:
|
||||
ConvertedConcreteAssetId<
|
||||
ConvertedConcreteId<
|
||||
AssetId,
|
||||
Balance,
|
||||
AsPrefixedGeneralIndex<AssetsPalletLocation, AssetId, JustTry>,
|
||||
@@ -96,7 +101,7 @@ pub type FungiblesTransactor = FungiblesAdapter<
|
||||
AccountId,
|
||||
// We only want to allow teleports of known assets. We use non-zero issuance as an indication
|
||||
// that this asset is known.
|
||||
parachains_common::impls::NonZeroIssuance<AccountId, Assets>,
|
||||
LocalMint<parachains_common::impls::NonZeroIssuance<AccountId, Assets>>,
|
||||
// The account to use for tracking teleports.
|
||||
CheckingAccount,
|
||||
>;
|
||||
@@ -129,13 +134,14 @@ pub type XcmOriginToTransactDispatchOrigin = (
|
||||
|
||||
parameter_types! {
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
pub const MaxAssetsIntoHolding: u32 = 64;
|
||||
pub XcmAssetFeesReceiver: Option<AccountId> = Authorship::author();
|
||||
}
|
||||
|
||||
match_types! {
|
||||
pub type ParentOrParentsExecutivePlurality: impl Contains<MultiLocation> = {
|
||||
pub type ParentOrParentsPlurality: impl Contains<MultiLocation> = {
|
||||
MultiLocation { parents: 1, interior: Here } |
|
||||
MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Executive, .. }) }
|
||||
MultiLocation { parents: 1, interior: X1(Plurality { .. }) }
|
||||
};
|
||||
pub type ParentOrSiblings: impl Contains<MultiLocation> = {
|
||||
MultiLocation { parents: 1, interior: Here } |
|
||||
@@ -143,17 +149,122 @@ match_types! {
|
||||
};
|
||||
}
|
||||
|
||||
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
|
||||
/// account for proof size weights.
|
||||
///
|
||||
/// Calls that are allowed through this filter must:
|
||||
/// 1. Have a fixed weight;
|
||||
/// 2. Cannot lead to another call being made;
|
||||
/// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters.
|
||||
pub struct SafeCallFilter;
|
||||
impl Contains<RuntimeCall> for SafeCallFilter {
|
||||
fn contains(call: &RuntimeCall) -> bool {
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
{
|
||||
if matches!(call, RuntimeCall::System(frame_system::Call::remark_with_event { .. })) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
match call {
|
||||
RuntimeCall::System(
|
||||
frame_system::Call::set_heap_pages { .. } |
|
||||
frame_system::Call::set_code { .. } |
|
||||
frame_system::Call::set_code_without_checks { .. } |
|
||||
frame_system::Call::kill_prefix { .. },
|
||||
) |
|
||||
RuntimeCall::ParachainSystem(..) |
|
||||
RuntimeCall::Timestamp(..) |
|
||||
RuntimeCall::Balances(..) |
|
||||
RuntimeCall::CollatorSelection(
|
||||
pallet_collator_selection::Call::set_desired_candidates { .. } |
|
||||
pallet_collator_selection::Call::set_candidacy_bond { .. } |
|
||||
pallet_collator_selection::Call::register_as_candidate { .. } |
|
||||
pallet_collator_selection::Call::leave_intent { .. },
|
||||
) |
|
||||
RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
|
||||
RuntimeCall::XcmpQueue(..) |
|
||||
RuntimeCall::DmpQueue(..) |
|
||||
RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) |
|
||||
RuntimeCall::Assets(
|
||||
pallet_assets::Call::create { .. } |
|
||||
pallet_assets::Call::force_create { .. } |
|
||||
pallet_assets::Call::start_destroy { .. } |
|
||||
pallet_assets::Call::destroy_accounts { .. } |
|
||||
pallet_assets::Call::destroy_approvals { .. } |
|
||||
pallet_assets::Call::finish_destroy { .. } |
|
||||
pallet_assets::Call::mint { .. } |
|
||||
pallet_assets::Call::burn { .. } |
|
||||
pallet_assets::Call::transfer { .. } |
|
||||
pallet_assets::Call::transfer_keep_alive { .. } |
|
||||
pallet_assets::Call::force_transfer { .. } |
|
||||
pallet_assets::Call::freeze { .. } |
|
||||
pallet_assets::Call::thaw { .. } |
|
||||
pallet_assets::Call::freeze_asset { .. } |
|
||||
pallet_assets::Call::thaw_asset { .. } |
|
||||
pallet_assets::Call::transfer_ownership { .. } |
|
||||
pallet_assets::Call::set_team { .. } |
|
||||
pallet_assets::Call::clear_metadata { .. } |
|
||||
pallet_assets::Call::force_clear_metadata { .. } |
|
||||
pallet_assets::Call::force_asset_status { .. } |
|
||||
pallet_assets::Call::approve_transfer { .. } |
|
||||
pallet_assets::Call::cancel_approval { .. } |
|
||||
pallet_assets::Call::force_cancel_approval { .. } |
|
||||
pallet_assets::Call::transfer_approved { .. } |
|
||||
pallet_assets::Call::touch { .. } |
|
||||
pallet_assets::Call::refund { .. },
|
||||
) |
|
||||
RuntimeCall::Uniques(
|
||||
pallet_uniques::Call::create { .. } |
|
||||
pallet_uniques::Call::force_create { .. } |
|
||||
pallet_uniques::Call::destroy { .. } |
|
||||
pallet_uniques::Call::mint { .. } |
|
||||
pallet_uniques::Call::burn { .. } |
|
||||
pallet_uniques::Call::transfer { .. } |
|
||||
pallet_uniques::Call::freeze { .. } |
|
||||
pallet_uniques::Call::thaw { .. } |
|
||||
pallet_uniques::Call::freeze_collection { .. } |
|
||||
pallet_uniques::Call::thaw_collection { .. } |
|
||||
pallet_uniques::Call::transfer_ownership { .. } |
|
||||
pallet_uniques::Call::set_team { .. } |
|
||||
pallet_uniques::Call::approve_transfer { .. } |
|
||||
pallet_uniques::Call::cancel_approval { .. } |
|
||||
pallet_uniques::Call::force_item_status { .. } |
|
||||
pallet_uniques::Call::set_attribute { .. } |
|
||||
pallet_uniques::Call::clear_attribute { .. } |
|
||||
pallet_uniques::Call::set_metadata { .. } |
|
||||
pallet_uniques::Call::clear_metadata { .. } |
|
||||
pallet_uniques::Call::set_collection_metadata { .. } |
|
||||
pallet_uniques::Call::clear_collection_metadata { .. } |
|
||||
pallet_uniques::Call::set_accept_ownership { .. } |
|
||||
pallet_uniques::Call::set_collection_max_supply { .. } |
|
||||
pallet_uniques::Call::set_price { .. } |
|
||||
pallet_uniques::Call::buy_item { .. },
|
||||
) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub type Barrier = DenyThenTry<
|
||||
DenyReserveTransferToRelayChain,
|
||||
(
|
||||
TakeWeightCredit,
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
// Parent and its exec plurality get free execution
|
||||
AllowUnpaidExecutionFrom<ParentOrParentsExecutivePlurality>,
|
||||
// Expected responses are OK.
|
||||
AllowKnownQueryResponses<PolkadotXcm>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<ParentOrSiblings>,
|
||||
// Allow XCMs with some computed origins to pass through.
|
||||
WithComputedOrigin<
|
||||
(
|
||||
// If the message is one that immediately attemps to pay for execution, then allow it.
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
// Parent and its plurality (i.e. governance bodies) gets free execution.
|
||||
AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<ParentOrSiblings>,
|
||||
),
|
||||
UniversalLocation,
|
||||
ConstU32<8>,
|
||||
>,
|
||||
),
|
||||
>;
|
||||
|
||||
@@ -174,7 +285,7 @@ impl xcm_executor::Config for XcmConfig {
|
||||
// For KSM, users must use teleport where allowed (e.g. with the Relay Chain).
|
||||
type IsReserve = ();
|
||||
type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of KSM
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type UniversalLocation = UniversalLocation;
|
||||
type Barrier = Barrier;
|
||||
type Weigher = WeightInfoBounds<
|
||||
crate::weights::xcm::StatemineXcmWeight<RuntimeCall>,
|
||||
@@ -186,7 +297,7 @@ impl xcm_executor::Config for XcmConfig {
|
||||
cumulus_primitives_utility::TakeFirstAssetTrader<
|
||||
AccountId,
|
||||
AssetFeeAsExistentialDepositMultiplierFeeCharger,
|
||||
ConvertedConcreteAssetId<
|
||||
ConvertedConcreteId<
|
||||
AssetId,
|
||||
Balance,
|
||||
AsPrefixedGeneralIndex<AssetsPalletLocation, AssetId, JustTry>,
|
||||
@@ -204,6 +315,15 @@ impl xcm_executor::Config for XcmConfig {
|
||||
type AssetTrap = PolkadotXcm;
|
||||
type AssetClaims = PolkadotXcm;
|
||||
type SubscriptionService = PolkadotXcm;
|
||||
type PalletInstancesInfo = AllPalletsWithSystem;
|
||||
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
|
||||
type AssetLocker = ();
|
||||
type AssetExchanger = ();
|
||||
type FeeManager = ();
|
||||
type MessageExporter = ();
|
||||
type UniversalAliases = Nothing;
|
||||
type CallDispatcher = WithOriginFilter<SafeCallFilter>;
|
||||
type SafeCallFilter = SafeCallFilter;
|
||||
}
|
||||
|
||||
/// Converts a local signed origin into an XCM multilocation.
|
||||
@@ -214,11 +334,16 @@ pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, R
|
||||
/// queues.
|
||||
pub type XcmRouter = (
|
||||
// Two routers - use UMP to communicate with the relay chain:
|
||||
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm>,
|
||||
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>,
|
||||
// ..and XCMP to communicate with the sibling chains.
|
||||
XcmpQueue,
|
||||
);
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
parameter_types! {
|
||||
pub ReachableDest: Option<MultiLocation> = Some(Parent.into());
|
||||
}
|
||||
|
||||
impl pallet_xcm::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
// We want to disallow users sending (arbitrary) XCMs from this chain.
|
||||
@@ -237,11 +362,19 @@ impl pallet_xcm::Config for Runtime {
|
||||
MaxInstructions,
|
||||
>;
|
||||
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type UniversalLocation = UniversalLocation;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
|
||||
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
|
||||
type Currency = Balances;
|
||||
type CurrencyMatcher = ();
|
||||
type TrustedLockers = ();
|
||||
type SovereignAccountOf = LocationToAccountId;
|
||||
type MaxLockers = ConstU32<8>;
|
||||
type WeightInfo = crate::weights::pallet_xcm::WeightInfo<Runtime>;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type ReachableDest = ReachableDest;
|
||||
}
|
||||
|
||||
impl cumulus_pallet_xcm::Config for Runtime {
|
||||
|
||||
@@ -62,13 +62,13 @@ fn test_asset_xcm_trader() {
|
||||
RuntimeHelper::<Runtime>::run_to_block(2, Some(AccountId::from(ALICE)));
|
||||
|
||||
// We are going to buy 4e9 weight
|
||||
let bought = 4_000_000_000u64;
|
||||
let bought = Weight::from_ref_time(4_000_000_000u64);
|
||||
|
||||
// Lets calculate amount needed
|
||||
let asset_amount_needed =
|
||||
AssetFeeAsExistentialDepositMultiplierFeeCharger::charge_weight_in_fungibles(
|
||||
local_asset_id,
|
||||
Weight::from_ref_time(bought),
|
||||
bought,
|
||||
)
|
||||
.expect("failed to compute");
|
||||
|
||||
@@ -138,7 +138,7 @@ fn test_asset_xcm_trader_with_refund() {
|
||||
RuntimeHelper::<Runtime>::run_to_block(2, Some(AccountId::from(ALICE)));
|
||||
|
||||
// We are going to buy 4e9 weight
|
||||
let bought = 4_000_000_000u64;
|
||||
let bought = Weight::from_ref_time(4_000_000_000u64);
|
||||
|
||||
let asset_multilocation = MultiLocation::new(
|
||||
0,
|
||||
@@ -152,7 +152,7 @@ fn test_asset_xcm_trader_with_refund() {
|
||||
);
|
||||
|
||||
// lets calculate amount needed
|
||||
let amount_bought = WeightToFee::weight_to_fee(&Weight::from_ref_time(bought));
|
||||
let amount_bought = WeightToFee::weight_to_fee(&bought);
|
||||
|
||||
let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into();
|
||||
|
||||
@@ -166,8 +166,7 @@ fn test_asset_xcm_trader_with_refund() {
|
||||
let weight_used = bought / 2;
|
||||
|
||||
// Make sure refurnd works.
|
||||
let amount_refunded =
|
||||
WeightToFee::weight_to_fee(&Weight::from_ref_time(bought - weight_used));
|
||||
let amount_refunded = WeightToFee::weight_to_fee(&(bought - weight_used));
|
||||
|
||||
assert_eq!(
|
||||
trader.refund_weight(bought - weight_used),
|
||||
@@ -178,7 +177,7 @@ fn test_asset_xcm_trader_with_refund() {
|
||||
drop(trader);
|
||||
|
||||
// We only should have paid for half of the bought weight
|
||||
let fees_paid = WeightToFee::weight_to_fee(&Weight::from_ref_time(weight_used));
|
||||
let fees_paid = WeightToFee::weight_to_fee(&weight_used);
|
||||
|
||||
assert_eq!(
|
||||
Assets::balance(1, AccountId::from(ALICE)),
|
||||
@@ -217,7 +216,7 @@ fn test_asset_xcm_trader_refund_not_possible_since_amount_less_than_ed() {
|
||||
RuntimeHelper::<Runtime>::run_to_block(2, Some(AccountId::from(ALICE)));
|
||||
|
||||
// We are going to buy small amount
|
||||
let bought = 500_000_000u64;
|
||||
let bought = Weight::from_ref_time(500_000_000u64);
|
||||
|
||||
let asset_multilocation = MultiLocation::new(
|
||||
0,
|
||||
@@ -230,7 +229,7 @@ fn test_asset_xcm_trader_refund_not_possible_since_amount_less_than_ed() {
|
||||
),
|
||||
);
|
||||
|
||||
let amount_bought = WeightToFee::weight_to_fee(&Weight::from_ref_time(bought));
|
||||
let amount_bought = WeightToFee::weight_to_fee(&bought);
|
||||
|
||||
assert!(
|
||||
amount_bought < ExistentialDeposit::get(),
|
||||
@@ -277,7 +276,7 @@ fn test_that_buying_ed_refund_does_not_refund() {
|
||||
RuntimeHelper::<Runtime>::run_to_block(2, Some(AccountId::from(ALICE)));
|
||||
|
||||
// We are gonna buy ED
|
||||
let bought: u64 = ExistentialDeposit::get().try_into().unwrap();
|
||||
let bought = Weight::from_ref_time(ExistentialDeposit::get().try_into().unwrap());
|
||||
|
||||
let asset_multilocation = MultiLocation::new(
|
||||
0,
|
||||
@@ -290,7 +289,7 @@ fn test_that_buying_ed_refund_does_not_refund() {
|
||||
),
|
||||
);
|
||||
|
||||
let amount_bought = WeightToFee::weight_to_fee(&Weight::from_ref_time(bought));
|
||||
let amount_bought = WeightToFee::weight_to_fee(&bought);
|
||||
|
||||
assert!(
|
||||
amount_bought < ExistentialDeposit::get(),
|
||||
@@ -358,10 +357,10 @@ fn test_asset_xcm_trader_not_possible_for_non_sufficient_assets() {
|
||||
RuntimeHelper::<Runtime>::run_to_block(2, Some(AccountId::from(ALICE)));
|
||||
|
||||
// We are going to buy 4e9 weight
|
||||
let bought = 4_000_000_000u64;
|
||||
let bought = Weight::from_ref_time(4_000_000_000u64);
|
||||
|
||||
// lets calculate amount needed
|
||||
let asset_amount_needed = WeightToFee::weight_to_fee(&Weight::from_ref_time(bought));
|
||||
let asset_amount_needed = WeightToFee::weight_to_fee(&bought);
|
||||
|
||||
let asset_multilocation = MultiLocation::new(
|
||||
0,
|
||||
|
||||
@@ -468,6 +468,7 @@ impl parachain_info::Config for Runtime {}
|
||||
impl cumulus_pallet_aura_ext::Config for Runtime {}
|
||||
|
||||
impl cumulus_pallet_xcmp_queue::Config for Runtime {
|
||||
type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type XcmExecutor = XcmExecutor<XcmConfig>;
|
||||
type ChannelInfo = ParachainSystem;
|
||||
@@ -478,7 +479,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
|
||||
EnsureXcm<IsMajorityOfBody<DotLocation, ExecutiveBody>>,
|
||||
>;
|
||||
type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
|
||||
type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
|
||||
type PriceForSiblingDelivery = ();
|
||||
}
|
||||
|
||||
impl cumulus_pallet_dmp_queue::Config for Runtime {
|
||||
@@ -682,6 +683,7 @@ mod benches {
|
||||
[pallet_collator_selection, CollatorSelection]
|
||||
[cumulus_pallet_xcmp_queue, XcmpQueue]
|
||||
// XCM
|
||||
[pallet_xcm, PolkadotXcm]
|
||||
// NOTE: Make sure you point to the individual modules below.
|
||||
[pallet_xcm_benchmarks::fungible, XcmBalances]
|
||||
[pallet_xcm_benchmarks::generic, XcmGeneric]
|
||||
@@ -868,7 +870,7 @@ impl_runtime_apis! {
|
||||
impl cumulus_pallet_session_benchmarking::Config for Runtime {}
|
||||
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_config::DotLocation;
|
||||
use xcm_config::{DotLocation, MaxAssetsIntoHolding};
|
||||
use pallet_xcm_benchmarks::asset_instance_from;
|
||||
|
||||
impl pallet_xcm_benchmarks::Config for Runtime {
|
||||
@@ -877,12 +879,12 @@ impl_runtime_apis! {
|
||||
fn valid_destination() -> Result<MultiLocation, BenchmarkError> {
|
||||
Ok(DotLocation::get())
|
||||
}
|
||||
fn worst_case_holding() -> MultiAssets {
|
||||
fn worst_case_holding(depositable_count: u32) -> MultiAssets {
|
||||
// A mix of fungible, non-fungible, and concrete assets.
|
||||
const HOLDING_FUNGIBLES: u32 = 100;
|
||||
const HOLDING_NON_FUNGIBLES: u32 = 100;
|
||||
let holding_non_fungibles = MaxAssetsIntoHolding::get() / 2 - depositable_count;
|
||||
let holding_fungibles = holding_non_fungibles - 1;
|
||||
let fungibles_amount: u128 = 100;
|
||||
let mut assets = (0..HOLDING_FUNGIBLES)
|
||||
let mut assets = (0..holding_fungibles)
|
||||
.map(|i| {
|
||||
MultiAsset {
|
||||
id: Concrete(GeneralIndex(i as u128).into()),
|
||||
@@ -891,17 +893,17 @@ impl_runtime_apis! {
|
||||
.into()
|
||||
})
|
||||
.chain(core::iter::once(MultiAsset { id: Concrete(Here.into()), fun: Fungible(u128::MAX) }))
|
||||
.chain((0..HOLDING_NON_FUNGIBLES).map(|i| MultiAsset {
|
||||
.chain((0..holding_non_fungibles).map(|i| MultiAsset {
|
||||
id: Concrete(GeneralIndex(i as u128).into()),
|
||||
fun: NonFungible(asset_instance_from(i)),
|
||||
}))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
assets.push(MultiAsset{
|
||||
id: Concrete(DotLocation::get()),
|
||||
fun: Fungible(1_000_000 * UNITS),
|
||||
});
|
||||
assets.into()
|
||||
assets.push(MultiAsset {
|
||||
id: Concrete(DotLocation::get()),
|
||||
fun: Fungible(1_000_000 * UNITS),
|
||||
});
|
||||
assets.into()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -910,8 +912,7 @@ impl_runtime_apis! {
|
||||
DotLocation::get(),
|
||||
MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(DotLocation::get()) },
|
||||
));
|
||||
pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = None;
|
||||
pub const CheckedAccount: Option<AccountId> = None;
|
||||
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
|
||||
}
|
||||
|
||||
impl pallet_xcm_benchmarks::fungible::Config for Runtime {
|
||||
@@ -919,7 +920,6 @@ impl_runtime_apis! {
|
||||
|
||||
type CheckedAccount = CheckedAccount;
|
||||
type TrustedTeleporter = TrustedTeleporter;
|
||||
type TrustedReserve = TrustedReserve;
|
||||
|
||||
fn get_multi_asset() -> MultiAsset {
|
||||
MultiAsset {
|
||||
@@ -936,8 +936,16 @@ impl_runtime_apis! {
|
||||
(0u64, Response::Version(Default::default()))
|
||||
}
|
||||
|
||||
fn transact_origin() -> Result<MultiLocation, BenchmarkError> {
|
||||
Ok(DotLocation::get())
|
||||
fn worst_case_asset_exchange() -> Result<(MultiAssets, MultiAssets), BenchmarkError> {
|
||||
Err(BenchmarkError::Skip)
|
||||
}
|
||||
|
||||
fn universal_alias() -> Result<Junction, BenchmarkError> {
|
||||
Err(BenchmarkError::Skip)
|
||||
}
|
||||
|
||||
fn transact_origin_and_runtime_call() -> Result<(MultiLocation, RuntimeCall), BenchmarkError> {
|
||||
Ok((DotLocation::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
|
||||
}
|
||||
|
||||
fn subscribe_origin() -> Result<MultiLocation, BenchmarkError> {
|
||||
@@ -950,6 +958,10 @@ impl_runtime_apis! {
|
||||
let ticket = MultiLocation { parents: 0, interior: Here };
|
||||
Ok((origin, ticket, assets))
|
||||
}
|
||||
|
||||
fn unlockable_asset() -> Result<(MultiLocation, MultiLocation, MultiAsset), BenchmarkError> {
|
||||
Err(BenchmarkError::Skip)
|
||||
}
|
||||
}
|
||||
|
||||
type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
|
||||
|
||||
@@ -11,6 +11,7 @@ pub mod pallet_session;
|
||||
pub mod pallet_timestamp;
|
||||
pub mod pallet_uniques;
|
||||
pub mod pallet_utility;
|
||||
pub mod pallet_xcm;
|
||||
pub mod paritydb_weights;
|
||||
pub mod rocksdb_weights;
|
||||
pub mod xcm;
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
// Copyright 2021 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Cumulus.
|
||||
|
||||
// Cumulus is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Cumulus is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Autogenerated weights for `pallet_xcm`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2022-12-22, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// /home/benchbot/cargo_target_dir/production/polkadot-parachain
|
||||
// benchmark
|
||||
// pallet
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --extrinsic=*
|
||||
// --execution=wasm
|
||||
// --wasm-execution=compiled
|
||||
// --heap-pages=4096
|
||||
// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json
|
||||
// --pallet=pallet_xcm
|
||||
// --chain=statemint-dev
|
||||
// --header=./file_header.txt
|
||||
// --output=./parachains/runtimes/assets/statemint/src/weights/
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use frame_support::{traits::Get, weights::Weight};
|
||||
use sp_std::marker::PhantomData;
|
||||
|
||||
/// Weight functions for `pallet_xcm`.
|
||||
pub struct WeightInfo<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
fn send() -> Weight {
|
||||
// Minimum execution time: 27_694 nanoseconds.
|
||||
Weight::from_ref_time(28_545_000)
|
||||
.saturating_add(T::DbWeight::get().reads(5))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
fn teleport_assets() -> Weight {
|
||||
// Minimum execution time: 33_053 nanoseconds.
|
||||
Weight::from_ref_time(33_789_000)
|
||||
.saturating_add(T::DbWeight::get().reads(1))
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
fn reserve_transfer_assets() -> Weight {
|
||||
// Minimum execution time: 24_781 nanoseconds.
|
||||
Weight::from_ref_time(25_259_000)
|
||||
.saturating_add(T::DbWeight::get().reads(1))
|
||||
}
|
||||
// Storage: Benchmark Override (r:0 w:0)
|
||||
fn execute() -> Weight {
|
||||
// Minimum execution time: 18_446_744_073_709_551 nanoseconds.
|
||||
Weight::from_ref_time(18_446_744_073_709_551_000)
|
||||
}
|
||||
// Storage: PolkadotXcm SupportedVersion (r:0 w:1)
|
||||
fn force_xcm_version() -> Weight {
|
||||
// Minimum execution time: 15_439 nanoseconds.
|
||||
Weight::from_ref_time(15_750_000)
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
}
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:0 w:1)
|
||||
fn force_default_xcm_version() -> Weight {
|
||||
// Minimum execution time: 4_576 nanoseconds.
|
||||
Weight::from_ref_time(4_758_000)
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifiers (r:1 w:1)
|
||||
// Storage: PolkadotXcm QueryCounter (r:1 w:1)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
// Storage: PolkadotXcm Queries (r:0 w:1)
|
||||
fn force_subscribe_version_notify() -> Weight {
|
||||
// Minimum execution time: 31_540 nanoseconds.
|
||||
Weight::from_ref_time(32_380_000)
|
||||
.saturating_add(T::DbWeight::get().reads(7))
|
||||
.saturating_add(T::DbWeight::get().writes(5))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifiers (r:1 w:1)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
// Storage: PolkadotXcm Queries (r:0 w:1)
|
||||
fn force_unsubscribe_version_notify() -> Weight {
|
||||
// Minimum execution time: 32_627 nanoseconds.
|
||||
Weight::from_ref_time(32_934_000)
|
||||
.saturating_add(T::DbWeight::get().reads(6))
|
||||
.saturating_add(T::DbWeight::get().writes(4))
|
||||
}
|
||||
// Storage: PolkadotXcm SupportedVersion (r:4 w:2)
|
||||
fn migrate_supported_version() -> Weight {
|
||||
// Minimum execution time: 13_968 nanoseconds.
|
||||
Weight::from_ref_time(14_356_000)
|
||||
.saturating_add(T::DbWeight::get().reads(4))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifiers (r:4 w:2)
|
||||
fn migrate_version_notifiers() -> Weight {
|
||||
// Minimum execution time: 14_263 nanoseconds.
|
||||
Weight::from_ref_time(14_540_000)
|
||||
.saturating_add(T::DbWeight::get().reads(4))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:5 w:0)
|
||||
fn already_notified_target() -> Weight {
|
||||
// Minimum execution time: 15_825 nanoseconds.
|
||||
Weight::from_ref_time(16_101_000)
|
||||
.saturating_add(T::DbWeight::get().reads(5))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:2 w:1)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
fn notify_current_targets() -> Weight {
|
||||
// Minimum execution time: 27_436 nanoseconds.
|
||||
Weight::from_ref_time(28_083_000)
|
||||
.saturating_add(T::DbWeight::get().reads(7))
|
||||
.saturating_add(T::DbWeight::get().writes(3))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:3 w:0)
|
||||
fn notify_target_migration_fail() -> Weight {
|
||||
// Minimum execution time: 7_187 nanoseconds.
|
||||
Weight::from_ref_time(7_399_000)
|
||||
.saturating_add(T::DbWeight::get().reads(3))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:4 w:2)
|
||||
fn migrate_version_notify_targets() -> Weight {
|
||||
// Minimum execution time: 14_904 nanoseconds.
|
||||
Weight::from_ref_time(15_191_000)
|
||||
.saturating_add(T::DbWeight::get().reads(4))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:4 w:2)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
fn migrate_and_notify_old_targets() -> Weight {
|
||||
// Minimum execution time: 33_269 nanoseconds.
|
||||
Weight::from_ref_time(34_064_000)
|
||||
.saturating_add(T::DbWeight::get().reads(9))
|
||||
.saturating_add(T::DbWeight::get().writes(4))
|
||||
}
|
||||
}
|
||||
@@ -21,168 +21,220 @@ use crate::Runtime;
|
||||
use frame_support::weights::Weight;
|
||||
use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight;
|
||||
use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
|
||||
use sp_std::{cmp, prelude::*};
|
||||
use xcm::{
|
||||
latest::{prelude::*, Weight as XCMWeight},
|
||||
DoubleEncoded,
|
||||
};
|
||||
use sp_std::prelude::*;
|
||||
use xcm::{latest::prelude::*, DoubleEncoded};
|
||||
|
||||
trait WeighMultiAssets {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> XCMWeight;
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight;
|
||||
}
|
||||
|
||||
const MAX_ASSETS: u32 = 100;
|
||||
|
||||
impl WeighMultiAssets for MultiAssetFilter {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> XCMWeight {
|
||||
let weight = match self {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
||||
match self {
|
||||
Self::Definite(assets) =>
|
||||
weight.saturating_mul(assets.inner().into_iter().count() as u64),
|
||||
Self::Wild(_) => weight.saturating_mul(MAX_ASSETS as u64),
|
||||
};
|
||||
weight.ref_time()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl WeighMultiAssets for MultiAssets {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> XCMWeight {
|
||||
weight.saturating_mul(self.inner().into_iter().count() as u64).ref_time()
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
||||
weight.saturating_mul(self.inner().into_iter().count() as u64)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct StatemintXcmWeight<Call>(core::marker::PhantomData<Call>);
|
||||
impl<Call> XcmWeightInfo<Call> for StatemintXcmWeight<Call> {
|
||||
fn withdraw_asset(assets: &MultiAssets) -> XCMWeight {
|
||||
fn withdraw_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::withdraw_asset())
|
||||
}
|
||||
// Currently there is no trusted reserve
|
||||
fn reserve_asset_deposited(_assets: &MultiAssets) -> XCMWeight {
|
||||
u64::MAX
|
||||
fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight {
|
||||
// TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974
|
||||
Weight::from_ref_time(1_000_000_000 as u64)
|
||||
}
|
||||
fn receive_teleported_asset(assets: &MultiAssets) -> XCMWeight {
|
||||
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::receive_teleported_asset())
|
||||
}
|
||||
fn query_response(_query_id: &u64, _response: &Response, _max_weight: &u64) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::query_response().ref_time()
|
||||
fn query_response(
|
||||
_query_id: &u64,
|
||||
_response: &Response,
|
||||
_max_weight: &Weight,
|
||||
_querier: &Option<MultiLocation>,
|
||||
) -> Weight {
|
||||
XcmGeneric::<Runtime>::query_response()
|
||||
}
|
||||
fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> XCMWeight {
|
||||
fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::transfer_asset())
|
||||
}
|
||||
fn transfer_reserve_asset(
|
||||
assets: &MultiAssets,
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> XCMWeight {
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::transfer_reserve_asset())
|
||||
}
|
||||
fn transact(
|
||||
_origin_type: &OriginKind,
|
||||
_require_weight_at_most: &u64,
|
||||
_require_weight_at_most: &Weight,
|
||||
_call: &DoubleEncoded<Call>,
|
||||
) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::transact().ref_time()
|
||||
) -> Weight {
|
||||
XcmGeneric::<Runtime>::transact()
|
||||
}
|
||||
fn hrmp_new_channel_open_request(
|
||||
_sender: &u32,
|
||||
_max_message_size: &u32,
|
||||
_max_capacity: &u32,
|
||||
) -> XCMWeight {
|
||||
) -> Weight {
|
||||
// XCM Executor does not currently support HRMP channel operations
|
||||
Weight::MAX.ref_time()
|
||||
Weight::MAX
|
||||
}
|
||||
fn hrmp_channel_accepted(_recipient: &u32) -> XCMWeight {
|
||||
fn hrmp_channel_accepted(_recipient: &u32) -> Weight {
|
||||
// XCM Executor does not currently support HRMP channel operations
|
||||
Weight::MAX.ref_time()
|
||||
Weight::MAX
|
||||
}
|
||||
fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> XCMWeight {
|
||||
fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> Weight {
|
||||
// XCM Executor does not currently support HRMP channel operations
|
||||
Weight::MAX.ref_time()
|
||||
Weight::MAX
|
||||
}
|
||||
fn clear_origin() -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::clear_origin().ref_time()
|
||||
fn clear_origin() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_origin()
|
||||
}
|
||||
fn descend_origin(_who: &InteriorMultiLocation) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::descend_origin().ref_time()
|
||||
fn descend_origin(_who: &InteriorMultiLocation) -> Weight {
|
||||
XcmGeneric::<Runtime>::descend_origin()
|
||||
}
|
||||
fn report_error(
|
||||
_query_id: &QueryId,
|
||||
_dest: &MultiLocation,
|
||||
_max_response_weight: &u64,
|
||||
) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::report_error().ref_time()
|
||||
fn report_error(_query_response_info: &QueryResponseInfo) -> Weight {
|
||||
XcmGeneric::<Runtime>::report_error()
|
||||
}
|
||||
|
||||
fn deposit_asset(
|
||||
assets: &MultiAssetFilter,
|
||||
_max_assets: &u32,
|
||||
_dest: &MultiLocation,
|
||||
) -> XCMWeight {
|
||||
fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight {
|
||||
// Hardcoded till the XCM pallet is fixed
|
||||
let hardcoded_weight = Weight::from_ref_time(1_000_000_000 as u64).ref_time();
|
||||
let hardcoded_weight = Weight::from_ref_time(1_000_000_000 as u64);
|
||||
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_asset());
|
||||
cmp::min(hardcoded_weight, weight)
|
||||
hardcoded_weight.min(weight)
|
||||
}
|
||||
fn deposit_reserve_asset(
|
||||
assets: &MultiAssetFilter,
|
||||
_max_assets: &u32,
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> XCMWeight {
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_reserve_asset())
|
||||
}
|
||||
fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets) -> XCMWeight {
|
||||
Weight::MAX.ref_time()
|
||||
fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn initiate_reserve_withdraw(
|
||||
assets: &MultiAssetFilter,
|
||||
_reserve: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> XCMWeight {
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::initiate_reserve_withdraw())
|
||||
}
|
||||
fn initiate_teleport(
|
||||
assets: &MultiAssetFilter,
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> XCMWeight {
|
||||
) -> Weight {
|
||||
// Hardcoded till the XCM pallet is fixed
|
||||
let hardcoded_weight = Weight::from_ref_time(200_000_000 as u64).ref_time();
|
||||
let hardcoded_weight = Weight::from_ref_time(200_000_000 as u64);
|
||||
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport());
|
||||
cmp::min(hardcoded_weight, weight)
|
||||
hardcoded_weight.min(weight)
|
||||
}
|
||||
fn query_holding(
|
||||
_query_id: &u64,
|
||||
_dest: &MultiLocation,
|
||||
_assets: &MultiAssetFilter,
|
||||
_max_response_weight: &u64,
|
||||
) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::query_holding().ref_time()
|
||||
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
|
||||
XcmGeneric::<Runtime>::report_holding()
|
||||
}
|
||||
fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::buy_execution().ref_time()
|
||||
fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> Weight {
|
||||
XcmGeneric::<Runtime>::buy_execution()
|
||||
}
|
||||
fn refund_surplus() -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::refund_surplus().ref_time()
|
||||
fn refund_surplus() -> Weight {
|
||||
XcmGeneric::<Runtime>::refund_surplus()
|
||||
}
|
||||
fn set_error_handler(_xcm: &Xcm<Call>) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::set_error_handler().ref_time()
|
||||
fn set_error_handler(_xcm: &Xcm<Call>) -> Weight {
|
||||
XcmGeneric::<Runtime>::set_error_handler()
|
||||
}
|
||||
fn set_appendix(_xcm: &Xcm<Call>) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::set_appendix().ref_time()
|
||||
fn set_appendix(_xcm: &Xcm<Call>) -> Weight {
|
||||
XcmGeneric::<Runtime>::set_appendix()
|
||||
}
|
||||
fn clear_error() -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::clear_error().ref_time()
|
||||
fn clear_error() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_error()
|
||||
}
|
||||
fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::claim_asset().ref_time()
|
||||
fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> Weight {
|
||||
XcmGeneric::<Runtime>::claim_asset()
|
||||
}
|
||||
fn trap(_code: &u64) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::trap().ref_time()
|
||||
fn trap(_code: &u64) -> Weight {
|
||||
XcmGeneric::<Runtime>::trap()
|
||||
}
|
||||
fn subscribe_version(_query_id: &QueryId, _max_response_weight: &u64) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::subscribe_version().ref_time()
|
||||
fn subscribe_version(_query_id: &QueryId, _max_response_weight: &Weight) -> Weight {
|
||||
XcmGeneric::<Runtime>::subscribe_version()
|
||||
}
|
||||
fn unsubscribe_version() -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::unsubscribe_version().ref_time()
|
||||
fn unsubscribe_version() -> Weight {
|
||||
XcmGeneric::<Runtime>::unsubscribe_version()
|
||||
}
|
||||
fn burn_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::burn_asset())
|
||||
}
|
||||
fn expect_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::expect_asset())
|
||||
}
|
||||
fn expect_origin(_origin: &Option<MultiLocation>) -> Weight {
|
||||
XcmGeneric::<Runtime>::expect_origin()
|
||||
}
|
||||
fn expect_error(_error: &Option<(u32, XcmError)>) -> Weight {
|
||||
XcmGeneric::<Runtime>::expect_error()
|
||||
}
|
||||
fn query_pallet(_module_name: &Vec<u8>, _response_info: &QueryResponseInfo) -> Weight {
|
||||
XcmGeneric::<Runtime>::query_pallet()
|
||||
}
|
||||
fn expect_pallet(
|
||||
_index: &u32,
|
||||
_name: &Vec<u8>,
|
||||
_module_name: &Vec<u8>,
|
||||
_crate_major: &u32,
|
||||
_min_crate_minor: &u32,
|
||||
) -> Weight {
|
||||
XcmGeneric::<Runtime>::expect_pallet()
|
||||
}
|
||||
fn report_transact_status(_response_info: &QueryResponseInfo) -> Weight {
|
||||
XcmGeneric::<Runtime>::report_transact_status()
|
||||
}
|
||||
fn clear_transact_status() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_transact_status()
|
||||
}
|
||||
fn universal_origin(_: &Junction) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn set_fees_mode(_: &bool) -> Weight {
|
||||
XcmGeneric::<Runtime>::set_fees_mode()
|
||||
}
|
||||
fn set_topic(_topic: &[u8; 32]) -> Weight {
|
||||
XcmGeneric::<Runtime>::set_topic()
|
||||
}
|
||||
fn clear_topic() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_topic()
|
||||
}
|
||||
fn alias_origin(_: &MultiLocation) -> Weight {
|
||||
// XCM Executor does not currently support alias origin operations
|
||||
Weight::MAX
|
||||
}
|
||||
fn unpaid_execution(_: &WeightLimit, _: &Option<MultiLocation>) -> Weight {
|
||||
XcmGeneric::<Runtime>::unpaid_execution()
|
||||
}
|
||||
}
|
||||
|
||||
+19
-18
@@ -18,25 +18,26 @@
|
||||
//! Autogenerated weights for `pallet_xcm_benchmarks::fungible`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2022-12-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! DATE: 2022-12-14, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// ./artifacts/polkadot-parachain
|
||||
// /home/benchbot/cargo_target_dir/production/polkadot-parachain
|
||||
// benchmark
|
||||
// pallet
|
||||
// --template=./templates/xcm-bench-template.hbs
|
||||
// --chain=statemint-dev
|
||||
// --execution=wasm
|
||||
// --wasm-execution=compiled
|
||||
// --pallet=pallet_xcm_benchmarks::fungible
|
||||
// --extrinsic=*
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --json
|
||||
// --extrinsic=*
|
||||
// --execution=wasm
|
||||
// --wasm-execution=compiled
|
||||
// --heap-pages=4096
|
||||
// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json
|
||||
// --pallet=pallet_xcm_benchmarks::fungible
|
||||
// --chain=statemint-dev
|
||||
// --header=./file_header.txt
|
||||
// --output=./parachains/runtimes/assets/statemint/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
|
||||
// --template=./templates/xcm-bench-template.hbs
|
||||
// --output=./parachains/runtimes/assets/statemint/src/weights/xcm/
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
@@ -50,13 +51,13 @@ pub struct WeightInfo<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: System Account (r:1 w:1)
|
||||
pub(crate) fn withdraw_asset() -> Weight {
|
||||
Weight::from_ref_time(31_628_000 as u64)
|
||||
Weight::from_ref_time(30_093_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
// Storage: System Account (r:2 w:2)
|
||||
pub(crate) fn transfer_asset() -> Weight {
|
||||
Weight::from_ref_time(36_286_000 as u64)
|
||||
Weight::from_ref_time(38_287_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
@@ -68,16 +69,16 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn transfer_reserve_asset() -> Weight {
|
||||
Weight::from_ref_time(51_189_000 as u64)
|
||||
Weight::from_ref_time(55_153_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(8 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(4 as u64))
|
||||
}
|
||||
pub(crate) fn receive_teleported_asset() -> Weight {
|
||||
Weight::from_ref_time(6_157_000 as u64)
|
||||
Weight::from_ref_time(7_127_000 as u64)
|
||||
}
|
||||
// Storage: System Account (r:1 w:1)
|
||||
pub(crate) fn deposit_asset() -> Weight {
|
||||
Weight::from_ref_time(32_614_000 as u64)
|
||||
Weight::from_ref_time(31_534_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
@@ -89,7 +90,7 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn deposit_reserve_asset() -> Weight {
|
||||
Weight::from_ref_time(49_945_000 as u64)
|
||||
Weight::from_ref_time(50_137_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(7 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as u64))
|
||||
}
|
||||
@@ -100,7 +101,7 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn initiate_teleport() -> Weight {
|
||||
Weight::from_ref_time(26_905_000 as u64)
|
||||
Weight::from_ref_time(26_702_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
|
||||
+83
-29
@@ -18,25 +18,26 @@
|
||||
//! Autogenerated weights for `pallet_xcm_benchmarks::generic`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2022-12-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! DATE: 2022-12-14, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// ./artifacts/polkadot-parachain
|
||||
// /home/benchbot/cargo_target_dir/production/polkadot-parachain
|
||||
// benchmark
|
||||
// pallet
|
||||
// --template=./templates/xcm-bench-template.hbs
|
||||
// --chain=statemint-dev
|
||||
// --execution=wasm
|
||||
// --wasm-execution=compiled
|
||||
// --pallet=pallet_xcm_benchmarks::generic
|
||||
// --extrinsic=*
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --json
|
||||
// --extrinsic=*
|
||||
// --execution=wasm
|
||||
// --wasm-execution=compiled
|
||||
// --heap-pages=4096
|
||||
// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json
|
||||
// --pallet=pallet_xcm_benchmarks::generic
|
||||
// --chain=statemint-dev
|
||||
// --header=./file_header.txt
|
||||
// --output=./parachains/runtimes/assets/statemint/src/weights/xcm/pallet_xcm_benchmarks_generic.rs
|
||||
// --template=./templates/xcm-bench-template.hbs
|
||||
// --output=./parachains/runtimes/assets/statemint/src/weights/xcm/
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
@@ -54,58 +55,59 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn query_holding() -> Weight {
|
||||
Weight::from_ref_time(684_287_000 as u64)
|
||||
pub(crate) fn report_holding() -> Weight {
|
||||
Weight::from_ref_time(331_611_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
pub(crate) fn buy_execution() -> Weight {
|
||||
Weight::from_ref_time(8_580_000 as u64)
|
||||
Weight::from_ref_time(6_432_000 as u64)
|
||||
}
|
||||
// Storage: PolkadotXcm Queries (r:1 w:0)
|
||||
pub(crate) fn query_response() -> Weight {
|
||||
Weight::from_ref_time(16_082_000 as u64)
|
||||
Weight::from_ref_time(17_465_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
}
|
||||
pub(crate) fn transact() -> Weight {
|
||||
Weight::from_ref_time(19_394_000 as u64)
|
||||
Weight::from_ref_time(21_163_000 as u64)
|
||||
}
|
||||
pub(crate) fn refund_surplus() -> Weight {
|
||||
Weight::from_ref_time(8_833_000 as u64)
|
||||
Weight::from_ref_time(7_024_000 as u64)
|
||||
}
|
||||
pub(crate) fn set_error_handler() -> Weight {
|
||||
Weight::from_ref_time(5_128_000 as u64)
|
||||
Weight::from_ref_time(5_758_000 as u64)
|
||||
}
|
||||
pub(crate) fn set_appendix() -> Weight {
|
||||
Weight::from_ref_time(5_081_000 as u64)
|
||||
Weight::from_ref_time(5_832_000 as u64)
|
||||
}
|
||||
pub(crate) fn clear_error() -> Weight {
|
||||
Weight::from_ref_time(5_196_000 as u64)
|
||||
Weight::from_ref_time(5_763_000 as u64)
|
||||
}
|
||||
pub(crate) fn descend_origin() -> Weight {
|
||||
Weight::from_ref_time(6_199_000 as u64)
|
||||
Weight::from_ref_time(6_560_000 as u64)
|
||||
}
|
||||
pub(crate) fn clear_origin() -> Weight {
|
||||
Weight::from_ref_time(5_078_000 as u64)
|
||||
Weight::from_ref_time(5_765_000 as u64)
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn report_error() -> Weight {
|
||||
Weight::from_ref_time(14_742_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(5 as u64))
|
||||
Weight::from_ref_time(21_465_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
// Storage: PolkadotXcm AssetTraps (r:1 w:1)
|
||||
pub(crate) fn claim_asset() -> Weight {
|
||||
Weight::from_ref_time(20_490_000 as u64)
|
||||
Weight::from_ref_time(21_284_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
pub(crate) fn trap() -> Weight {
|
||||
Weight::from_ref_time(5_024_000 as u64)
|
||||
Weight::from_ref_time(5_723_000 as u64)
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:1 w:1)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
@@ -114,13 +116,13 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn subscribe_version() -> Weight {
|
||||
Weight::from_ref_time(17_473_000 as u64)
|
||||
Weight::from_ref_time(27_907_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as u64))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:0 w:1)
|
||||
pub(crate) fn unsubscribe_version() -> Weight {
|
||||
Weight::from_ref_time(7_230_000 as u64)
|
||||
Weight::from_ref_time(7_971_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
@@ -130,8 +132,60 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn initiate_reserve_withdraw() -> Weight {
|
||||
Weight::from_ref_time(897_033_000 as u64)
|
||||
Weight::from_ref_time(384_329_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
pub(crate) fn burn_asset() -> Weight {
|
||||
Weight::from_ref_time(127_341_000 as u64)
|
||||
}
|
||||
pub(crate) fn expect_asset() -> Weight {
|
||||
Weight::from_ref_time(15_151_000 as u64)
|
||||
}
|
||||
pub(crate) fn expect_origin() -> Weight {
|
||||
Weight::from_ref_time(5_828_000 as u64)
|
||||
}
|
||||
pub(crate) fn expect_error() -> Weight {
|
||||
Weight::from_ref_time(5_758_000 as u64)
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn query_pallet() -> Weight {
|
||||
Weight::from_ref_time(23_974_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
pub(crate) fn expect_pallet() -> Weight {
|
||||
Weight::from_ref_time(7_579_000 as u64)
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn report_transact_status() -> Weight {
|
||||
Weight::from_ref_time(21_711_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
pub(crate) fn clear_transact_status() -> Weight {
|
||||
Weight::from_ref_time(5_798_000 as u64)
|
||||
}
|
||||
pub(crate) fn set_topic() -> Weight {
|
||||
Weight::from_ref_time(5_876_000 as u64)
|
||||
}
|
||||
pub(crate) fn clear_topic() -> Weight {
|
||||
Weight::from_ref_time(5_690_000 as u64)
|
||||
}
|
||||
pub(crate) fn set_fees_mode() -> Weight {
|
||||
Weight::from_ref_time(5_668_000 as u64)
|
||||
}
|
||||
pub(crate) fn unpaid_execution() -> Weight {
|
||||
Weight::from_ref_time(6_005_000 as u64)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,12 +14,13 @@
|
||||
// limitations under the License.
|
||||
|
||||
use super::{
|
||||
AccountId, AssetId, Assets, Authorship, Balance, Balances, ParachainInfo, ParachainSystem,
|
||||
PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
|
||||
AccountId, AllPalletsWithSystem, AssetId, Assets, Authorship, Balance, Balances, ParachainInfo,
|
||||
ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee,
|
||||
XcmpQueue,
|
||||
};
|
||||
use frame_support::{
|
||||
match_types, parameter_types,
|
||||
traits::{Everything, Nothing, PalletInfoAccess},
|
||||
traits::{ConstU32, Contains, Everything, Nothing, PalletInfoAccess},
|
||||
};
|
||||
use pallet_xcm::XcmPassthrough;
|
||||
use parachains_common::{
|
||||
@@ -32,22 +33,26 @@ use polkadot_parachain::primitives::Sibling;
|
||||
use sp_runtime::traits::ConvertInto;
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
||||
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, AsPrefixedGeneralIndex,
|
||||
ConvertedConcreteAssetId, CurrencyAdapter, EnsureXcmOrigin, FungiblesAdapter, IsConcrete,
|
||||
LocationInverter, NativeAsset, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
|
||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
||||
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
|
||||
WeightInfoBounds,
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AsPrefixedGeneralIndex,
|
||||
ConvertedConcreteId, CurrencyAdapter, EnsureXcmOrigin, FungiblesAdapter, IsConcrete, LocalMint,
|
||||
NativeAsset, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
|
||||
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
|
||||
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds,
|
||||
WithComputedOrigin,
|
||||
};
|
||||
use xcm_executor::{
|
||||
traits::{JustTry, WithOriginFilter},
|
||||
XcmExecutor,
|
||||
};
|
||||
use xcm_executor::{traits::JustTry, XcmExecutor};
|
||||
|
||||
parameter_types! {
|
||||
pub const DotLocation: MultiLocation = MultiLocation::parent();
|
||||
pub const RelayNetwork: NetworkId = NetworkId::Polkadot;
|
||||
pub const RelayNetwork: Option<NetworkId> = Some(NetworkId::Polkadot);
|
||||
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
||||
pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
|
||||
pub const Local: MultiLocation = Here.into();
|
||||
pub UniversalLocation: InteriorMultiLocation =
|
||||
X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into()));
|
||||
pub const Local: MultiLocation = MultiLocation::here();
|
||||
pub AssetsPalletLocation: MultiLocation =
|
||||
PalletInstance(<Assets as PalletInfoAccess>::index() as u8).into();
|
||||
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
|
||||
@@ -84,7 +89,7 @@ pub type FungiblesTransactor = FungiblesAdapter<
|
||||
// Use this fungibles implementation:
|
||||
Assets,
|
||||
// Use this currency when it is a fungible asset matching the given location or name:
|
||||
ConvertedConcreteAssetId<
|
||||
ConvertedConcreteId<
|
||||
AssetId,
|
||||
Balance,
|
||||
AsPrefixedGeneralIndex<AssetsPalletLocation, AssetId, JustTry>,
|
||||
@@ -96,7 +101,7 @@ pub type FungiblesTransactor = FungiblesAdapter<
|
||||
AccountId,
|
||||
// We only want to allow teleports of known assets. We use non-zero issuance as an indication
|
||||
// that this asset is known.
|
||||
parachains_common::impls::NonZeroIssuance<AccountId, Assets>,
|
||||
LocalMint<parachains_common::impls::NonZeroIssuance<AccountId, Assets>>,
|
||||
// The account to use for tracking teleports.
|
||||
CheckingAccount,
|
||||
>;
|
||||
@@ -129,13 +134,14 @@ pub type XcmOriginToTransactDispatchOrigin = (
|
||||
|
||||
parameter_types! {
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
pub const MaxAssetsIntoHolding: u32 = 64;
|
||||
pub XcmAssetFeesReceiver: Option<AccountId> = Authorship::author();
|
||||
}
|
||||
|
||||
match_types! {
|
||||
pub type ParentOrParentsExecutivePlurality: impl Contains<MultiLocation> = {
|
||||
pub type ParentOrParentsPlurality: impl Contains<MultiLocation> = {
|
||||
MultiLocation { parents: 1, interior: Here } |
|
||||
MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Executive, .. }) }
|
||||
MultiLocation { parents: 1, interior: X1(Plurality { .. }) }
|
||||
};
|
||||
pub type ParentOrSiblings: impl Contains<MultiLocation> = {
|
||||
MultiLocation { parents: 1, interior: Here } |
|
||||
@@ -143,17 +149,122 @@ match_types! {
|
||||
};
|
||||
}
|
||||
|
||||
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
|
||||
/// account for proof size weights.
|
||||
///
|
||||
/// Calls that are allowed through this filter must:
|
||||
/// 1. Have a fixed weight;
|
||||
/// 2. Cannot lead to another call being made;
|
||||
/// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters.
|
||||
pub struct SafeCallFilter;
|
||||
impl Contains<RuntimeCall> for SafeCallFilter {
|
||||
fn contains(call: &RuntimeCall) -> bool {
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
{
|
||||
if matches!(call, RuntimeCall::System(frame_system::Call::remark_with_event { .. })) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
match call {
|
||||
RuntimeCall::System(
|
||||
frame_system::Call::set_heap_pages { .. } |
|
||||
frame_system::Call::set_code { .. } |
|
||||
frame_system::Call::set_code_without_checks { .. } |
|
||||
frame_system::Call::kill_prefix { .. },
|
||||
) |
|
||||
RuntimeCall::ParachainSystem(..) |
|
||||
RuntimeCall::Timestamp(..) |
|
||||
RuntimeCall::Balances(..) |
|
||||
RuntimeCall::CollatorSelection(
|
||||
pallet_collator_selection::Call::set_desired_candidates { .. } |
|
||||
pallet_collator_selection::Call::set_candidacy_bond { .. } |
|
||||
pallet_collator_selection::Call::register_as_candidate { .. } |
|
||||
pallet_collator_selection::Call::leave_intent { .. },
|
||||
) |
|
||||
RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
|
||||
RuntimeCall::XcmpQueue(..) |
|
||||
RuntimeCall::DmpQueue(..) |
|
||||
RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) |
|
||||
RuntimeCall::Assets(
|
||||
pallet_assets::Call::create { .. } |
|
||||
pallet_assets::Call::force_create { .. } |
|
||||
pallet_assets::Call::start_destroy { .. } |
|
||||
pallet_assets::Call::destroy_accounts { .. } |
|
||||
pallet_assets::Call::destroy_approvals { .. } |
|
||||
pallet_assets::Call::finish_destroy { .. } |
|
||||
pallet_assets::Call::mint { .. } |
|
||||
pallet_assets::Call::burn { .. } |
|
||||
pallet_assets::Call::transfer { .. } |
|
||||
pallet_assets::Call::transfer_keep_alive { .. } |
|
||||
pallet_assets::Call::force_transfer { .. } |
|
||||
pallet_assets::Call::freeze { .. } |
|
||||
pallet_assets::Call::thaw { .. } |
|
||||
pallet_assets::Call::freeze_asset { .. } |
|
||||
pallet_assets::Call::thaw_asset { .. } |
|
||||
pallet_assets::Call::transfer_ownership { .. } |
|
||||
pallet_assets::Call::set_team { .. } |
|
||||
pallet_assets::Call::clear_metadata { .. } |
|
||||
pallet_assets::Call::force_clear_metadata { .. } |
|
||||
pallet_assets::Call::force_asset_status { .. } |
|
||||
pallet_assets::Call::approve_transfer { .. } |
|
||||
pallet_assets::Call::cancel_approval { .. } |
|
||||
pallet_assets::Call::force_cancel_approval { .. } |
|
||||
pallet_assets::Call::transfer_approved { .. } |
|
||||
pallet_assets::Call::touch { .. } |
|
||||
pallet_assets::Call::refund { .. },
|
||||
) |
|
||||
RuntimeCall::Uniques(
|
||||
pallet_uniques::Call::create { .. } |
|
||||
pallet_uniques::Call::force_create { .. } |
|
||||
pallet_uniques::Call::destroy { .. } |
|
||||
pallet_uniques::Call::mint { .. } |
|
||||
pallet_uniques::Call::burn { .. } |
|
||||
pallet_uniques::Call::transfer { .. } |
|
||||
pallet_uniques::Call::freeze { .. } |
|
||||
pallet_uniques::Call::thaw { .. } |
|
||||
pallet_uniques::Call::freeze_collection { .. } |
|
||||
pallet_uniques::Call::thaw_collection { .. } |
|
||||
pallet_uniques::Call::transfer_ownership { .. } |
|
||||
pallet_uniques::Call::set_team { .. } |
|
||||
pallet_uniques::Call::approve_transfer { .. } |
|
||||
pallet_uniques::Call::cancel_approval { .. } |
|
||||
pallet_uniques::Call::force_item_status { .. } |
|
||||
pallet_uniques::Call::set_attribute { .. } |
|
||||
pallet_uniques::Call::clear_attribute { .. } |
|
||||
pallet_uniques::Call::set_metadata { .. } |
|
||||
pallet_uniques::Call::clear_metadata { .. } |
|
||||
pallet_uniques::Call::set_collection_metadata { .. } |
|
||||
pallet_uniques::Call::clear_collection_metadata { .. } |
|
||||
pallet_uniques::Call::set_accept_ownership { .. } |
|
||||
pallet_uniques::Call::set_collection_max_supply { .. } |
|
||||
pallet_uniques::Call::set_price { .. } |
|
||||
pallet_uniques::Call::buy_item { .. },
|
||||
) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub type Barrier = DenyThenTry<
|
||||
DenyReserveTransferToRelayChain,
|
||||
(
|
||||
TakeWeightCredit,
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
// Parent and its exec plurality get free execution
|
||||
AllowUnpaidExecutionFrom<ParentOrParentsExecutivePlurality>,
|
||||
// Expected responses are OK.
|
||||
AllowKnownQueryResponses<PolkadotXcm>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<ParentOrSiblings>,
|
||||
// Allow XCMs with some computed origins to pass through.
|
||||
WithComputedOrigin<
|
||||
(
|
||||
// If the message is one that immediately attemps to pay for execution, then allow it.
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
// Parent and its plurality (i.e. governance bodies) gets free execution.
|
||||
AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<ParentOrSiblings>,
|
||||
),
|
||||
UniversalLocation,
|
||||
ConstU32<8>,
|
||||
>,
|
||||
),
|
||||
>;
|
||||
|
||||
@@ -174,7 +285,7 @@ impl xcm_executor::Config for XcmConfig {
|
||||
// For DOT, users must use teleport where allowed (e.g. with the Relay Chain).
|
||||
type IsReserve = ();
|
||||
type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of DOT
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type UniversalLocation = UniversalLocation;
|
||||
type Barrier = Barrier;
|
||||
type Weigher = WeightInfoBounds<
|
||||
crate::weights::xcm::StatemintXcmWeight<RuntimeCall>,
|
||||
@@ -186,7 +297,7 @@ impl xcm_executor::Config for XcmConfig {
|
||||
cumulus_primitives_utility::TakeFirstAssetTrader<
|
||||
AccountId,
|
||||
AssetFeeAsExistentialDepositMultiplierFeeCharger,
|
||||
ConvertedConcreteAssetId<
|
||||
ConvertedConcreteId<
|
||||
AssetId,
|
||||
Balance,
|
||||
AsPrefixedGeneralIndex<AssetsPalletLocation, AssetId, JustTry>,
|
||||
@@ -204,6 +315,15 @@ impl xcm_executor::Config for XcmConfig {
|
||||
type AssetTrap = PolkadotXcm;
|
||||
type AssetClaims = PolkadotXcm;
|
||||
type SubscriptionService = PolkadotXcm;
|
||||
type PalletInstancesInfo = AllPalletsWithSystem;
|
||||
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
|
||||
type AssetLocker = ();
|
||||
type AssetExchanger = ();
|
||||
type FeeManager = ();
|
||||
type MessageExporter = ();
|
||||
type UniversalAliases = Nothing;
|
||||
type CallDispatcher = WithOriginFilter<SafeCallFilter>;
|
||||
type SafeCallFilter = SafeCallFilter;
|
||||
}
|
||||
|
||||
/// Converts a local signed origin into an XCM multilocation.
|
||||
@@ -214,11 +334,16 @@ pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, R
|
||||
/// queues.
|
||||
pub type XcmRouter = (
|
||||
// Two routers - use UMP to communicate with the relay chain:
|
||||
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm>,
|
||||
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>,
|
||||
// ..and XCMP to communicate with the sibling chains.
|
||||
XcmpQueue,
|
||||
);
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
parameter_types! {
|
||||
pub ReachableDest: Option<MultiLocation> = Some(Parent.into());
|
||||
}
|
||||
|
||||
impl pallet_xcm::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
// We want to disallow users sending (arbitrary) XCMs from this chain.
|
||||
@@ -236,11 +361,19 @@ impl pallet_xcm::Config for Runtime {
|
||||
RuntimeCall,
|
||||
MaxInstructions,
|
||||
>;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type UniversalLocation = UniversalLocation;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
|
||||
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
|
||||
type Currency = Balances;
|
||||
type CurrencyMatcher = ();
|
||||
type TrustedLockers = ();
|
||||
type SovereignAccountOf = LocationToAccountId;
|
||||
type MaxLockers = ConstU32<8>;
|
||||
type WeightInfo = crate::weights::pallet_xcm::WeightInfo<Runtime>;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type ReachableDest = ReachableDest;
|
||||
}
|
||||
|
||||
impl cumulus_pallet_xcm::Config for Runtime {
|
||||
|
||||
@@ -65,13 +65,13 @@ fn test_asset_xcm_trader() {
|
||||
// Because of the ED being higher in statemine
|
||||
// and not to complicate things, we use a little
|
||||
// bit more of weight
|
||||
let bought = 400_000_000_000u64;
|
||||
let bought = Weight::from_ref_time(400_000_000_000u64);
|
||||
|
||||
// Lets calculate amount needed
|
||||
let asset_amount_needed =
|
||||
AssetFeeAsExistentialDepositMultiplierFeeCharger::charge_weight_in_fungibles(
|
||||
local_asset_id,
|
||||
Weight::from_ref_time(bought),
|
||||
bought,
|
||||
)
|
||||
.expect("failed to compute");
|
||||
|
||||
@@ -144,7 +144,7 @@ fn test_asset_xcm_trader_with_refund() {
|
||||
// Because of the ED being higher in statemine
|
||||
// and not to complicate things, we use a little
|
||||
// bit more of weight
|
||||
let bought = 400_000_000_000u64;
|
||||
let bought = Weight::from_ref_time(400_000_000_000u64);
|
||||
|
||||
let asset_multilocation = MultiLocation::new(
|
||||
0,
|
||||
@@ -158,7 +158,7 @@ fn test_asset_xcm_trader_with_refund() {
|
||||
);
|
||||
|
||||
// lets calculate amount needed
|
||||
let amount_bought = WeightToFee::weight_to_fee(&Weight::from_ref_time(bought));
|
||||
let amount_bought = WeightToFee::weight_to_fee(&bought);
|
||||
|
||||
let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into();
|
||||
|
||||
@@ -172,8 +172,7 @@ fn test_asset_xcm_trader_with_refund() {
|
||||
let weight_used = bought / 2;
|
||||
|
||||
// Make sure refurnd works.
|
||||
let amount_refunded =
|
||||
WeightToFee::weight_to_fee(&Weight::from_ref_time(bought - weight_used));
|
||||
let amount_refunded = WeightToFee::weight_to_fee(&(bought - weight_used));
|
||||
|
||||
assert_eq!(
|
||||
trader.refund_weight(bought - weight_used),
|
||||
@@ -184,7 +183,7 @@ fn test_asset_xcm_trader_with_refund() {
|
||||
drop(trader);
|
||||
|
||||
// We only should have paid for half of the bought weight
|
||||
let fees_paid = WeightToFee::weight_to_fee(&Weight::from_ref_time(weight_used));
|
||||
let fees_paid = WeightToFee::weight_to_fee(&weight_used);
|
||||
|
||||
assert_eq!(
|
||||
Assets::balance(1, AccountId::from(ALICE)),
|
||||
@@ -226,7 +225,7 @@ fn test_asset_xcm_trader_refund_not_possible_since_amount_less_than_ed() {
|
||||
// Because of the ED being higher in statemine
|
||||
// and not to complicate things, we use a little
|
||||
// bit more of weight
|
||||
let bought = 50_000_000_000u64;
|
||||
let bought = Weight::from_ref_time(50_000_000_000u64);
|
||||
|
||||
let asset_multilocation = MultiLocation::new(
|
||||
0,
|
||||
@@ -239,7 +238,7 @@ fn test_asset_xcm_trader_refund_not_possible_since_amount_less_than_ed() {
|
||||
),
|
||||
);
|
||||
|
||||
let amount_bought = WeightToFee::weight_to_fee(&Weight::from_ref_time(bought));
|
||||
let amount_bought = WeightToFee::weight_to_fee(&bought);
|
||||
|
||||
assert!(
|
||||
amount_bought < ExistentialDeposit::get(),
|
||||
@@ -286,7 +285,7 @@ fn test_that_buying_ed_refund_does_not_refund() {
|
||||
RuntimeHelper::<Runtime>::run_to_block(2, Some(AccountId::from(ALICE)));
|
||||
|
||||
// We are gonna buy ED
|
||||
let bought: u64 = ExistentialDeposit::get().try_into().unwrap();
|
||||
let bought = Weight::from_ref_time(ExistentialDeposit::get().try_into().unwrap());
|
||||
|
||||
let asset_multilocation = MultiLocation::new(
|
||||
0,
|
||||
@@ -299,7 +298,7 @@ fn test_that_buying_ed_refund_does_not_refund() {
|
||||
),
|
||||
);
|
||||
|
||||
let amount_bought = WeightToFee::weight_to_fee(&Weight::from_ref_time(bought));
|
||||
let amount_bought = WeightToFee::weight_to_fee(&bought);
|
||||
|
||||
assert!(
|
||||
amount_bought < ExistentialDeposit::get(),
|
||||
@@ -370,10 +369,10 @@ fn test_asset_xcm_trader_not_possible_for_non_sufficient_assets() {
|
||||
// Because of the ED being higher in statemine
|
||||
// and not to complicate things, we use a little
|
||||
// bit more of weight
|
||||
let bought = 400_000_000_000u64;
|
||||
let bought = Weight::from_ref_time(400_000_000_000u64);
|
||||
|
||||
// lets calculate amount needed
|
||||
let asset_amount_needed = WeightToFee::weight_to_fee(&Weight::from_ref_time(bought));
|
||||
let asset_amount_needed = WeightToFee::weight_to_fee(&bought);
|
||||
|
||||
let asset_multilocation = MultiLocation::new(
|
||||
0,
|
||||
|
||||
@@ -460,6 +460,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
|
||||
type ControllerOrigin = EnsureRoot<AccountId>;
|
||||
type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
|
||||
type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
|
||||
type PriceForSiblingDelivery = ();
|
||||
}
|
||||
|
||||
impl cumulus_pallet_dmp_queue::Config for Runtime {
|
||||
@@ -694,6 +695,7 @@ mod benches {
|
||||
[pallet_collator_selection, CollatorSelection]
|
||||
[cumulus_pallet_xcmp_queue, XcmpQueue]
|
||||
// XCM
|
||||
[pallet_xcm, PolkadotXcm]
|
||||
// NOTE: Make sure you point to the individual modules below.
|
||||
[pallet_xcm_benchmarks::fungible, XcmBalances]
|
||||
[pallet_xcm_benchmarks::generic, XcmGeneric]
|
||||
@@ -879,7 +881,7 @@ impl_runtime_apis! {
|
||||
impl cumulus_pallet_session_benchmarking::Config for Runtime {}
|
||||
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_config::WestendLocation;
|
||||
use xcm_config::{MaxAssetsIntoHolding, WestendLocation};
|
||||
use pallet_xcm_benchmarks::asset_instance_from;
|
||||
|
||||
impl pallet_xcm_benchmarks::Config for Runtime {
|
||||
@@ -888,12 +890,12 @@ impl_runtime_apis! {
|
||||
fn valid_destination() -> Result<MultiLocation, BenchmarkError> {
|
||||
Ok(WestendLocation::get())
|
||||
}
|
||||
fn worst_case_holding() -> MultiAssets {
|
||||
fn worst_case_holding(depositable_count: u32) -> MultiAssets {
|
||||
// A mix of fungible, non-fungible, and concrete assets.
|
||||
const HOLDING_FUNGIBLES: u32 = 100;
|
||||
const HOLDING_NON_FUNGIBLES: u32 = 100;
|
||||
let holding_non_fungibles = MaxAssetsIntoHolding::get() / 2 - depositable_count;
|
||||
let holding_fungibles = holding_non_fungibles - 1;
|
||||
let fungibles_amount: u128 = 100;
|
||||
let mut assets = (0..HOLDING_FUNGIBLES)
|
||||
let mut assets = (0..holding_fungibles)
|
||||
.map(|i| {
|
||||
MultiAsset {
|
||||
id: Concrete(GeneralIndex(i as u128).into()),
|
||||
@@ -902,17 +904,17 @@ impl_runtime_apis! {
|
||||
.into()
|
||||
})
|
||||
.chain(core::iter::once(MultiAsset { id: Concrete(Here.into()), fun: Fungible(u128::MAX) }))
|
||||
.chain((0..HOLDING_NON_FUNGIBLES).map(|i| MultiAsset {
|
||||
.chain((0..holding_non_fungibles).map(|i| MultiAsset {
|
||||
id: Concrete(GeneralIndex(i as u128).into()),
|
||||
fun: NonFungible(asset_instance_from(i)),
|
||||
}))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
assets.push(MultiAsset{
|
||||
id: Concrete(WestendLocation::get()),
|
||||
fun: Fungible(1_000_000 * UNITS),
|
||||
});
|
||||
assets.into()
|
||||
assets.push(MultiAsset {
|
||||
id: Concrete(WestendLocation::get()),
|
||||
fun: Fungible(1_000_000 * UNITS),
|
||||
});
|
||||
assets.into()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -921,8 +923,7 @@ impl_runtime_apis! {
|
||||
WestendLocation::get(),
|
||||
MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(WestendLocation::get()) },
|
||||
));
|
||||
pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = None;
|
||||
pub const CheckedAccount: Option<AccountId> = None;
|
||||
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
|
||||
|
||||
}
|
||||
|
||||
@@ -931,7 +932,6 @@ impl_runtime_apis! {
|
||||
|
||||
type CheckedAccount = CheckedAccount;
|
||||
type TrustedTeleporter = TrustedTeleporter;
|
||||
type TrustedReserve = TrustedReserve;
|
||||
|
||||
fn get_multi_asset() -> MultiAsset {
|
||||
MultiAsset {
|
||||
@@ -948,8 +948,16 @@ impl_runtime_apis! {
|
||||
(0u64, Response::Version(Default::default()))
|
||||
}
|
||||
|
||||
fn transact_origin() -> Result<MultiLocation, BenchmarkError> {
|
||||
Ok(WestendLocation::get())
|
||||
fn worst_case_asset_exchange() -> Result<(MultiAssets, MultiAssets), BenchmarkError> {
|
||||
Err(BenchmarkError::Skip)
|
||||
}
|
||||
|
||||
fn universal_alias() -> Result<Junction, BenchmarkError> {
|
||||
Err(BenchmarkError::Skip)
|
||||
}
|
||||
|
||||
fn transact_origin_and_runtime_call() -> Result<(MultiLocation, RuntimeCall), BenchmarkError> {
|
||||
Ok((WestendLocation::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
|
||||
}
|
||||
|
||||
fn subscribe_origin() -> Result<MultiLocation, BenchmarkError> {
|
||||
@@ -962,6 +970,10 @@ impl_runtime_apis! {
|
||||
let ticket = MultiLocation { parents: 0, interior: Here };
|
||||
Ok((origin, ticket, assets))
|
||||
}
|
||||
|
||||
fn unlockable_asset() -> Result<(MultiLocation, MultiLocation, MultiAsset), BenchmarkError> {
|
||||
Err(BenchmarkError::Skip)
|
||||
}
|
||||
}
|
||||
|
||||
type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
|
||||
|
||||
@@ -12,6 +12,7 @@ pub mod pallet_session;
|
||||
pub mod pallet_timestamp;
|
||||
pub mod pallet_uniques;
|
||||
pub mod pallet_utility;
|
||||
pub mod pallet_xcm;
|
||||
pub mod paritydb_weights;
|
||||
pub mod rocksdb_weights;
|
||||
pub mod xcm;
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
// Copyright 2021 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Cumulus.
|
||||
|
||||
// Cumulus is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Cumulus is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Autogenerated weights for `pallet_xcm`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2022-12-22, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westmint-dev"), DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// /home/benchbot/cargo_target_dir/production/polkadot-parachain
|
||||
// benchmark
|
||||
// pallet
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --extrinsic=*
|
||||
// --execution=wasm
|
||||
// --wasm-execution=compiled
|
||||
// --heap-pages=4096
|
||||
// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json
|
||||
// --pallet=pallet_xcm
|
||||
// --chain=westmint-dev
|
||||
// --header=./file_header.txt
|
||||
// --output=./parachains/runtimes/assets/westmint/src/weights/
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use frame_support::{traits::Get, weights::Weight};
|
||||
use sp_std::marker::PhantomData;
|
||||
|
||||
/// Weight functions for `pallet_xcm`.
|
||||
pub struct WeightInfo<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
fn send() -> Weight {
|
||||
// Minimum execution time: 27_623 nanoseconds.
|
||||
Weight::from_ref_time(28_375_000)
|
||||
.saturating_add(T::DbWeight::get().reads(5))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
fn teleport_assets() -> Weight {
|
||||
// Minimum execution time: 33_363 nanoseconds.
|
||||
Weight::from_ref_time(33_942_000)
|
||||
.saturating_add(T::DbWeight::get().reads(1))
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
fn reserve_transfer_assets() -> Weight {
|
||||
// Minimum execution time: 25_113 nanoseconds.
|
||||
Weight::from_ref_time(25_549_000)
|
||||
.saturating_add(T::DbWeight::get().reads(1))
|
||||
}
|
||||
fn execute() -> Weight {
|
||||
// Minimum execution time: 15_464 nanoseconds.
|
||||
Weight::from_ref_time(15_772_000)
|
||||
}
|
||||
// Storage: PolkadotXcm SupportedVersion (r:0 w:1)
|
||||
fn force_xcm_version() -> Weight {
|
||||
// Minimum execution time: 15_375 nanoseconds.
|
||||
Weight::from_ref_time(15_631_000)
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
}
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:0 w:1)
|
||||
fn force_default_xcm_version() -> Weight {
|
||||
// Minimum execution time: 4_575 nanoseconds.
|
||||
Weight::from_ref_time(4_708_000)
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifiers (r:1 w:1)
|
||||
// Storage: PolkadotXcm QueryCounter (r:1 w:1)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
// Storage: PolkadotXcm Queries (r:0 w:1)
|
||||
fn force_subscribe_version_notify() -> Weight {
|
||||
// Minimum execution time: 31_521 nanoseconds.
|
||||
Weight::from_ref_time(32_350_000)
|
||||
.saturating_add(T::DbWeight::get().reads(7))
|
||||
.saturating_add(T::DbWeight::get().writes(5))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifiers (r:1 w:1)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
// Storage: PolkadotXcm Queries (r:0 w:1)
|
||||
fn force_unsubscribe_version_notify() -> Weight {
|
||||
// Minimum execution time: 32_589 nanoseconds.
|
||||
Weight::from_ref_time(33_282_000)
|
||||
.saturating_add(T::DbWeight::get().reads(6))
|
||||
.saturating_add(T::DbWeight::get().writes(4))
|
||||
}
|
||||
// Storage: PolkadotXcm SupportedVersion (r:4 w:2)
|
||||
fn migrate_supported_version() -> Weight {
|
||||
// Minimum execution time: 13_642 nanoseconds.
|
||||
Weight::from_ref_time(13_969_000)
|
||||
.saturating_add(T::DbWeight::get().reads(4))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifiers (r:4 w:2)
|
||||
fn migrate_version_notifiers() -> Weight {
|
||||
// Minimum execution time: 13_569 nanoseconds.
|
||||
Weight::from_ref_time(14_168_000)
|
||||
.saturating_add(T::DbWeight::get().reads(4))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:5 w:0)
|
||||
fn already_notified_target() -> Weight {
|
||||
// Minimum execution time: 15_406 nanoseconds.
|
||||
Weight::from_ref_time(15_731_000)
|
||||
.saturating_add(T::DbWeight::get().reads(5))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:2 w:1)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
fn notify_current_targets() -> Weight {
|
||||
// Minimum execution time: 27_357 nanoseconds.
|
||||
Weight::from_ref_time(27_804_000)
|
||||
.saturating_add(T::DbWeight::get().reads(7))
|
||||
.saturating_add(T::DbWeight::get().writes(3))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:3 w:0)
|
||||
fn notify_target_migration_fail() -> Weight {
|
||||
// Minimum execution time: 6_940 nanoseconds.
|
||||
Weight::from_ref_time(7_147_000)
|
||||
.saturating_add(T::DbWeight::get().reads(3))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:4 w:2)
|
||||
fn migrate_version_notify_targets() -> Weight {
|
||||
// Minimum execution time: 14_204 nanoseconds.
|
||||
Weight::from_ref_time(14_529_000)
|
||||
.saturating_add(T::DbWeight::get().reads(4))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:4 w:2)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
fn migrate_and_notify_old_targets() -> Weight {
|
||||
// Minimum execution time: 32_809 nanoseconds.
|
||||
Weight::from_ref_time(33_346_000)
|
||||
.saturating_add(T::DbWeight::get().reads(9))
|
||||
.saturating_add(T::DbWeight::get().writes(4))
|
||||
}
|
||||
}
|
||||
@@ -21,168 +21,220 @@ use crate::Runtime;
|
||||
use frame_support::weights::Weight;
|
||||
use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight;
|
||||
use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
|
||||
use sp_std::{cmp, prelude::*};
|
||||
use xcm::{
|
||||
latest::{prelude::*, Weight as XCMWeight},
|
||||
DoubleEncoded,
|
||||
};
|
||||
use sp_std::prelude::*;
|
||||
use xcm::{latest::prelude::*, DoubleEncoded};
|
||||
|
||||
trait WeighMultiAssets {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> XCMWeight;
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight;
|
||||
}
|
||||
|
||||
const MAX_ASSETS: u32 = 100;
|
||||
|
||||
impl WeighMultiAssets for MultiAssetFilter {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> XCMWeight {
|
||||
let weight = match self {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
||||
match self {
|
||||
Self::Definite(assets) =>
|
||||
weight.saturating_mul(assets.inner().into_iter().count() as u64),
|
||||
Self::Wild(_) => weight.saturating_mul(MAX_ASSETS as u64),
|
||||
};
|
||||
weight.ref_time()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl WeighMultiAssets for MultiAssets {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> XCMWeight {
|
||||
weight.saturating_mul(self.inner().into_iter().count() as u64).ref_time()
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
||||
weight.saturating_mul(self.inner().into_iter().count() as u64)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct WestmintXcmWeight<Call>(core::marker::PhantomData<Call>);
|
||||
impl<Call> XcmWeightInfo<Call> for WestmintXcmWeight<Call> {
|
||||
fn withdraw_asset(assets: &MultiAssets) -> XCMWeight {
|
||||
fn withdraw_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::withdraw_asset())
|
||||
}
|
||||
// Currently there is no trusted reserve
|
||||
fn reserve_asset_deposited(_assets: &MultiAssets) -> XCMWeight {
|
||||
u64::MAX
|
||||
fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight {
|
||||
// TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974
|
||||
Weight::from_ref_time(1_000_000_000 as u64)
|
||||
}
|
||||
fn receive_teleported_asset(assets: &MultiAssets) -> XCMWeight {
|
||||
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::receive_teleported_asset())
|
||||
}
|
||||
fn query_response(_query_id: &u64, _response: &Response, _max_weight: &u64) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::query_response().ref_time()
|
||||
fn query_response(
|
||||
_query_id: &u64,
|
||||
_response: &Response,
|
||||
_max_weight: &Weight,
|
||||
_querier: &Option<MultiLocation>,
|
||||
) -> Weight {
|
||||
XcmGeneric::<Runtime>::query_response()
|
||||
}
|
||||
fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> XCMWeight {
|
||||
fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::transfer_asset())
|
||||
}
|
||||
fn transfer_reserve_asset(
|
||||
assets: &MultiAssets,
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> XCMWeight {
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::transfer_reserve_asset())
|
||||
}
|
||||
fn transact(
|
||||
_origin_type: &OriginKind,
|
||||
_require_weight_at_most: &u64,
|
||||
_require_weight_at_most: &Weight,
|
||||
_call: &DoubleEncoded<Call>,
|
||||
) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::transact().ref_time()
|
||||
) -> Weight {
|
||||
XcmGeneric::<Runtime>::transact()
|
||||
}
|
||||
fn hrmp_new_channel_open_request(
|
||||
_sender: &u32,
|
||||
_max_message_size: &u32,
|
||||
_max_capacity: &u32,
|
||||
) -> XCMWeight {
|
||||
) -> Weight {
|
||||
// XCM Executor does not currently support HRMP channel operations
|
||||
Weight::MAX.ref_time()
|
||||
Weight::MAX
|
||||
}
|
||||
fn hrmp_channel_accepted(_recipient: &u32) -> XCMWeight {
|
||||
fn hrmp_channel_accepted(_recipient: &u32) -> Weight {
|
||||
// XCM Executor does not currently support HRMP channel operations
|
||||
Weight::MAX.ref_time()
|
||||
Weight::MAX
|
||||
}
|
||||
fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> XCMWeight {
|
||||
fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> Weight {
|
||||
// XCM Executor does not currently support HRMP channel operations
|
||||
Weight::MAX.ref_time()
|
||||
Weight::MAX
|
||||
}
|
||||
fn clear_origin() -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::clear_origin().ref_time()
|
||||
fn clear_origin() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_origin()
|
||||
}
|
||||
fn descend_origin(_who: &InteriorMultiLocation) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::descend_origin().ref_time()
|
||||
fn descend_origin(_who: &InteriorMultiLocation) -> Weight {
|
||||
XcmGeneric::<Runtime>::descend_origin()
|
||||
}
|
||||
fn report_error(
|
||||
_query_id: &QueryId,
|
||||
_dest: &MultiLocation,
|
||||
_max_response_weight: &u64,
|
||||
) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::report_error().ref_time()
|
||||
fn report_error(_query_response_info: &QueryResponseInfo) -> Weight {
|
||||
XcmGeneric::<Runtime>::report_error()
|
||||
}
|
||||
|
||||
fn deposit_asset(
|
||||
assets: &MultiAssetFilter,
|
||||
_max_assets: &u32,
|
||||
_dest: &MultiLocation,
|
||||
) -> XCMWeight {
|
||||
fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight {
|
||||
// Hardcoded till the XCM pallet is fixed
|
||||
let hardcoded_weight = Weight::from_ref_time(1_000_000_000 as u64).ref_time();
|
||||
let hardcoded_weight = Weight::from_ref_time(1_000_000_000 as u64);
|
||||
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_asset());
|
||||
cmp::min(hardcoded_weight, weight)
|
||||
hardcoded_weight.min(weight)
|
||||
}
|
||||
fn deposit_reserve_asset(
|
||||
assets: &MultiAssetFilter,
|
||||
_max_assets: &u32,
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> XCMWeight {
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_reserve_asset())
|
||||
}
|
||||
fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets) -> XCMWeight {
|
||||
Weight::MAX.ref_time()
|
||||
fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn initiate_reserve_withdraw(
|
||||
assets: &MultiAssetFilter,
|
||||
_reserve: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> XCMWeight {
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::initiate_reserve_withdraw())
|
||||
}
|
||||
fn initiate_teleport(
|
||||
assets: &MultiAssetFilter,
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> XCMWeight {
|
||||
) -> Weight {
|
||||
// Hardcoded till the XCM pallet is fixed
|
||||
let hardcoded_weight = Weight::from_ref_time(200_000_000 as u64).ref_time();
|
||||
let hardcoded_weight = Weight::from_ref_time(200_000_000 as u64);
|
||||
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport());
|
||||
cmp::min(hardcoded_weight, weight)
|
||||
hardcoded_weight.min(weight)
|
||||
}
|
||||
fn query_holding(
|
||||
_query_id: &u64,
|
||||
_dest: &MultiLocation,
|
||||
_assets: &MultiAssetFilter,
|
||||
_max_response_weight: &u64,
|
||||
) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::query_holding().ref_time()
|
||||
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
|
||||
XcmGeneric::<Runtime>::report_holding()
|
||||
}
|
||||
fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::buy_execution().ref_time()
|
||||
fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> Weight {
|
||||
XcmGeneric::<Runtime>::buy_execution()
|
||||
}
|
||||
fn refund_surplus() -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::refund_surplus().ref_time()
|
||||
fn refund_surplus() -> Weight {
|
||||
XcmGeneric::<Runtime>::refund_surplus()
|
||||
}
|
||||
fn set_error_handler(_xcm: &Xcm<Call>) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::set_error_handler().ref_time()
|
||||
fn set_error_handler(_xcm: &Xcm<Call>) -> Weight {
|
||||
XcmGeneric::<Runtime>::set_error_handler()
|
||||
}
|
||||
fn set_appendix(_xcm: &Xcm<Call>) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::set_appendix().ref_time()
|
||||
fn set_appendix(_xcm: &Xcm<Call>) -> Weight {
|
||||
XcmGeneric::<Runtime>::set_appendix()
|
||||
}
|
||||
fn clear_error() -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::clear_error().ref_time()
|
||||
fn clear_error() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_error()
|
||||
}
|
||||
fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::claim_asset().ref_time()
|
||||
fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> Weight {
|
||||
XcmGeneric::<Runtime>::claim_asset()
|
||||
}
|
||||
fn trap(_code: &u64) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::trap().ref_time()
|
||||
fn trap(_code: &u64) -> Weight {
|
||||
XcmGeneric::<Runtime>::trap()
|
||||
}
|
||||
fn subscribe_version(_query_id: &QueryId, _max_response_weight: &u64) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::subscribe_version().ref_time()
|
||||
fn subscribe_version(_query_id: &QueryId, _max_response_weight: &Weight) -> Weight {
|
||||
XcmGeneric::<Runtime>::subscribe_version()
|
||||
}
|
||||
fn unsubscribe_version() -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::unsubscribe_version().ref_time()
|
||||
fn unsubscribe_version() -> Weight {
|
||||
XcmGeneric::<Runtime>::unsubscribe_version()
|
||||
}
|
||||
fn burn_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::burn_asset())
|
||||
}
|
||||
fn expect_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::expect_asset())
|
||||
}
|
||||
fn expect_origin(_origin: &Option<MultiLocation>) -> Weight {
|
||||
XcmGeneric::<Runtime>::expect_origin()
|
||||
}
|
||||
fn expect_error(_error: &Option<(u32, XcmError)>) -> Weight {
|
||||
XcmGeneric::<Runtime>::expect_error()
|
||||
}
|
||||
fn query_pallet(_module_name: &Vec<u8>, _response_info: &QueryResponseInfo) -> Weight {
|
||||
XcmGeneric::<Runtime>::query_pallet()
|
||||
}
|
||||
fn expect_pallet(
|
||||
_index: &u32,
|
||||
_name: &Vec<u8>,
|
||||
_module_name: &Vec<u8>,
|
||||
_crate_major: &u32,
|
||||
_min_crate_minor: &u32,
|
||||
) -> Weight {
|
||||
XcmGeneric::<Runtime>::expect_pallet()
|
||||
}
|
||||
fn report_transact_status(_response_info: &QueryResponseInfo) -> Weight {
|
||||
XcmGeneric::<Runtime>::report_transact_status()
|
||||
}
|
||||
fn clear_transact_status() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_transact_status()
|
||||
}
|
||||
fn universal_origin(_: &Junction) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn set_fees_mode(_: &bool) -> Weight {
|
||||
XcmGeneric::<Runtime>::set_fees_mode()
|
||||
}
|
||||
fn set_topic(_topic: &[u8; 32]) -> Weight {
|
||||
XcmGeneric::<Runtime>::set_topic()
|
||||
}
|
||||
fn clear_topic() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_topic()
|
||||
}
|
||||
fn alias_origin(_: &MultiLocation) -> Weight {
|
||||
// XCM Executor does not currently support alias origin operations
|
||||
Weight::MAX
|
||||
}
|
||||
fn unpaid_execution(_: &WeightLimit, _: &Option<MultiLocation>) -> Weight {
|
||||
XcmGeneric::<Runtime>::unpaid_execution()
|
||||
}
|
||||
}
|
||||
|
||||
+19
-18
@@ -18,25 +18,26 @@
|
||||
//! Autogenerated weights for `pallet_xcm_benchmarks::fungible`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2022-12-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! DATE: 2022-12-14, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westmint-dev"), DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// ./artifacts/polkadot-parachain
|
||||
// /home/benchbot/cargo_target_dir/production/polkadot-parachain
|
||||
// benchmark
|
||||
// pallet
|
||||
// --template=./templates/xcm-bench-template.hbs
|
||||
// --chain=westmint-dev
|
||||
// --execution=wasm
|
||||
// --wasm-execution=compiled
|
||||
// --pallet=pallet_xcm_benchmarks::fungible
|
||||
// --extrinsic=*
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --json
|
||||
// --extrinsic=*
|
||||
// --execution=wasm
|
||||
// --wasm-execution=compiled
|
||||
// --heap-pages=4096
|
||||
// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json
|
||||
// --pallet=pallet_xcm_benchmarks::fungible
|
||||
// --chain=westmint-dev
|
||||
// --header=./file_header.txt
|
||||
// --output=./parachains/runtimes/assets/westmint/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
|
||||
// --template=./templates/xcm-bench-template.hbs
|
||||
// --output=./parachains/runtimes/assets/westmint/src/weights/xcm/
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
@@ -50,13 +51,13 @@ pub struct WeightInfo<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: System Account (r:1 w:1)
|
||||
pub(crate) fn withdraw_asset() -> Weight {
|
||||
Weight::from_ref_time(32_238_000 as u64)
|
||||
Weight::from_ref_time(30_986_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
// Storage: System Account (r:2 w:2)
|
||||
pub(crate) fn transfer_asset() -> Weight {
|
||||
Weight::from_ref_time(37_145_000 as u64)
|
||||
Weight::from_ref_time(39_149_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
@@ -68,16 +69,16 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn transfer_reserve_asset() -> Weight {
|
||||
Weight::from_ref_time(52_803_000 as u64)
|
||||
Weight::from_ref_time(56_235_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(8 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(4 as u64))
|
||||
}
|
||||
pub(crate) fn receive_teleported_asset() -> Weight {
|
||||
Weight::from_ref_time(6_248_000 as u64)
|
||||
Weight::from_ref_time(7_616_000 as u64)
|
||||
}
|
||||
// Storage: System Account (r:1 w:1)
|
||||
pub(crate) fn deposit_asset() -> Weight {
|
||||
Weight::from_ref_time(33_168_000 as u64)
|
||||
Weight::from_ref_time(34_864_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
@@ -89,7 +90,7 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn deposit_reserve_asset() -> Weight {
|
||||
Weight::from_ref_time(53_662_000 as u64)
|
||||
Weight::from_ref_time(55_915_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(7 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as u64))
|
||||
}
|
||||
@@ -100,7 +101,7 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn initiate_teleport() -> Weight {
|
||||
Weight::from_ref_time(29_189_000 as u64)
|
||||
Weight::from_ref_time(30_050_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
|
||||
+83
-29
@@ -18,25 +18,26 @@
|
||||
//! Autogenerated weights for `pallet_xcm_benchmarks::generic`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2022-12-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! DATE: 2022-12-14, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westmint-dev"), DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// ./artifacts/polkadot-parachain
|
||||
// /home/benchbot/cargo_target_dir/production/polkadot-parachain
|
||||
// benchmark
|
||||
// pallet
|
||||
// --template=./templates/xcm-bench-template.hbs
|
||||
// --chain=westmint-dev
|
||||
// --execution=wasm
|
||||
// --wasm-execution=compiled
|
||||
// --pallet=pallet_xcm_benchmarks::generic
|
||||
// --extrinsic=*
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --json
|
||||
// --extrinsic=*
|
||||
// --execution=wasm
|
||||
// --wasm-execution=compiled
|
||||
// --heap-pages=4096
|
||||
// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json
|
||||
// --pallet=pallet_xcm_benchmarks::generic
|
||||
// --chain=westmint-dev
|
||||
// --header=./file_header.txt
|
||||
// --output=./parachains/runtimes/assets/westmint/src/weights/xcm/pallet_xcm_benchmarks_generic.rs
|
||||
// --template=./templates/xcm-bench-template.hbs
|
||||
// --output=./parachains/runtimes/assets/westmint/src/weights/xcm/
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
@@ -54,58 +55,59 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn query_holding() -> Weight {
|
||||
Weight::from_ref_time(710_352_000 as u64)
|
||||
pub(crate) fn report_holding() -> Weight {
|
||||
Weight::from_ref_time(337_762_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
pub(crate) fn buy_execution() -> Weight {
|
||||
Weight::from_ref_time(8_924_000 as u64)
|
||||
Weight::from_ref_time(6_682_000 as u64)
|
||||
}
|
||||
// Storage: PolkadotXcm Queries (r:1 w:0)
|
||||
pub(crate) fn query_response() -> Weight {
|
||||
Weight::from_ref_time(17_278_000 as u64)
|
||||
Weight::from_ref_time(17_801_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
}
|
||||
pub(crate) fn transact() -> Weight {
|
||||
Weight::from_ref_time(20_214_000 as u64)
|
||||
Weight::from_ref_time(21_889_000 as u64)
|
||||
}
|
||||
pub(crate) fn refund_surplus() -> Weight {
|
||||
Weight::from_ref_time(9_218_000 as u64)
|
||||
Weight::from_ref_time(7_081_000 as u64)
|
||||
}
|
||||
pub(crate) fn set_error_handler() -> Weight {
|
||||
Weight::from_ref_time(5_175_000 as u64)
|
||||
Weight::from_ref_time(6_050_000 as u64)
|
||||
}
|
||||
pub(crate) fn set_appendix() -> Weight {
|
||||
Weight::from_ref_time(5_145_000 as u64)
|
||||
Weight::from_ref_time(5_982_000 as u64)
|
||||
}
|
||||
pub(crate) fn clear_error() -> Weight {
|
||||
Weight::from_ref_time(5_298_000 as u64)
|
||||
Weight::from_ref_time(5_948_000 as u64)
|
||||
}
|
||||
pub(crate) fn descend_origin() -> Weight {
|
||||
Weight::from_ref_time(6_134_000 as u64)
|
||||
Weight::from_ref_time(7_022_000 as u64)
|
||||
}
|
||||
pub(crate) fn clear_origin() -> Weight {
|
||||
Weight::from_ref_time(5_277_000 as u64)
|
||||
Weight::from_ref_time(6_019_000 as u64)
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn report_error() -> Weight {
|
||||
Weight::from_ref_time(15_270_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(5 as u64))
|
||||
Weight::from_ref_time(21_836_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
// Storage: PolkadotXcm AssetTraps (r:1 w:1)
|
||||
pub(crate) fn claim_asset() -> Weight {
|
||||
Weight::from_ref_time(21_147_000 as u64)
|
||||
Weight::from_ref_time(21_512_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
pub(crate) fn trap() -> Weight {
|
||||
Weight::from_ref_time(5_429_000 as u64)
|
||||
Weight::from_ref_time(5_971_000 as u64)
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:1 w:1)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
@@ -114,13 +116,13 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn subscribe_version() -> Weight {
|
||||
Weight::from_ref_time(18_098_000 as u64)
|
||||
Weight::from_ref_time(27_912_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as u64))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:0 w:1)
|
||||
pub(crate) fn unsubscribe_version() -> Weight {
|
||||
Weight::from_ref_time(7_527_000 as u64)
|
||||
Weight::from_ref_time(7_870_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
@@ -130,8 +132,60 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn initiate_reserve_withdraw() -> Weight {
|
||||
Weight::from_ref_time(927_560_000 as u64)
|
||||
Weight::from_ref_time(390_638_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
pub(crate) fn burn_asset() -> Weight {
|
||||
Weight::from_ref_time(128_254_000 as u64)
|
||||
}
|
||||
pub(crate) fn expect_asset() -> Weight {
|
||||
Weight::from_ref_time(15_386_000 as u64)
|
||||
}
|
||||
pub(crate) fn expect_origin() -> Weight {
|
||||
Weight::from_ref_time(6_071_000 as u64)
|
||||
}
|
||||
pub(crate) fn expect_error() -> Weight {
|
||||
Weight::from_ref_time(6_044_000 as u64)
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn query_pallet() -> Weight {
|
||||
Weight::from_ref_time(24_744_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
pub(crate) fn expect_pallet() -> Weight {
|
||||
Weight::from_ref_time(7_558_000 as u64)
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn report_transact_status() -> Weight {
|
||||
Weight::from_ref_time(22_068_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
pub(crate) fn clear_transact_status() -> Weight {
|
||||
Weight::from_ref_time(5_945_000 as u64)
|
||||
}
|
||||
pub(crate) fn set_topic() -> Weight {
|
||||
Weight::from_ref_time(5_863_000 as u64)
|
||||
}
|
||||
pub(crate) fn clear_topic() -> Weight {
|
||||
Weight::from_ref_time(5_807_000 as u64)
|
||||
}
|
||||
pub(crate) fn set_fees_mode() -> Weight {
|
||||
Weight::from_ref_time(5_825_000 as u64)
|
||||
}
|
||||
pub(crate) fn unpaid_execution() -> Weight {
|
||||
Weight::from_ref_time(5_920_000 as u64)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,12 +14,13 @@
|
||||
// limitations under the License.
|
||||
|
||||
use super::{
|
||||
AccountId, AssetId, Assets, Authorship, Balance, Balances, ParachainInfo, ParachainSystem,
|
||||
PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
|
||||
AccountId, AllPalletsWithSystem, AssetId, Assets, Authorship, Balance, Balances, ParachainInfo,
|
||||
ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee,
|
||||
XcmpQueue,
|
||||
};
|
||||
use frame_support::{
|
||||
match_types, parameter_types,
|
||||
traits::{Everything, PalletInfoAccess},
|
||||
traits::{ConstU32, Contains, Everything, Nothing, PalletInfoAccess},
|
||||
};
|
||||
use pallet_xcm::XcmPassthrough;
|
||||
use parachains_common::{
|
||||
@@ -32,23 +33,26 @@ use polkadot_parachain::primitives::Sibling;
|
||||
use sp_runtime::traits::ConvertInto;
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
||||
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, AsPrefixedGeneralIndex,
|
||||
ConvertedConcreteAssetId, CurrencyAdapter, EnsureXcmOrigin, FungiblesAdapter, IsConcrete,
|
||||
LocationInverter, NativeAsset, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
|
||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
||||
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
|
||||
WeightInfoBounds,
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AsPrefixedGeneralIndex,
|
||||
ConvertedConcreteId, CurrencyAdapter, EnsureXcmOrigin, FungiblesAdapter, IsConcrete, LocalMint,
|
||||
NativeAsset, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
|
||||
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
|
||||
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds,
|
||||
WithComputedOrigin,
|
||||
};
|
||||
use xcm_executor::{
|
||||
traits::{JustTry, WithOriginFilter},
|
||||
XcmExecutor,
|
||||
};
|
||||
use xcm_executor::{traits::JustTry, XcmExecutor};
|
||||
|
||||
parameter_types! {
|
||||
pub const WestendLocation: MultiLocation = MultiLocation::parent();
|
||||
pub RelayNetwork: NetworkId =
|
||||
NetworkId::Named(b"Westend".to_vec().try_into().expect("less than length limit; qed"));
|
||||
pub RelayNetwork: Option<NetworkId> = Some(NetworkId::Westend);
|
||||
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
||||
pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
|
||||
pub const Local: MultiLocation = Here.into();
|
||||
pub UniversalLocation: InteriorMultiLocation =
|
||||
X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into()));
|
||||
pub const Local: MultiLocation = Here.into_location();
|
||||
pub AssetsPalletLocation: MultiLocation =
|
||||
PalletInstance(<Assets as PalletInfoAccess>::index() as u8).into();
|
||||
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
|
||||
@@ -85,7 +89,7 @@ pub type FungiblesTransactor = FungiblesAdapter<
|
||||
// Use this fungibles implementation:
|
||||
Assets,
|
||||
// Use this currency when it is a fungible asset matching the given location or name:
|
||||
ConvertedConcreteAssetId<
|
||||
ConvertedConcreteId<
|
||||
AssetId,
|
||||
Balance,
|
||||
AsPrefixedGeneralIndex<AssetsPalletLocation, AssetId, JustTry>,
|
||||
@@ -97,7 +101,7 @@ pub type FungiblesTransactor = FungiblesAdapter<
|
||||
AccountId,
|
||||
// We only want to allow teleports of known assets. We use non-zero issuance as an indication
|
||||
// that this asset is known.
|
||||
parachains_common::impls::NonZeroIssuance<AccountId, Assets>,
|
||||
LocalMint<parachains_common::impls::NonZeroIssuance<AccountId, Assets>>,
|
||||
// The account to use for tracking teleports.
|
||||
CheckingAccount,
|
||||
>;
|
||||
@@ -130,6 +134,7 @@ pub type XcmOriginToTransactDispatchOrigin = (
|
||||
|
||||
parameter_types! {
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
pub const MaxAssetsIntoHolding: u32 = 64;
|
||||
pub XcmAssetFeesReceiver: Option<AccountId> = Authorship::author();
|
||||
}
|
||||
|
||||
@@ -139,18 +144,122 @@ match_types! {
|
||||
MultiLocation { parents: 1, interior: X1(Plurality { .. }) }
|
||||
};
|
||||
}
|
||||
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
|
||||
/// account for proof size weights.
|
||||
///
|
||||
/// Calls that are allowed through this filter must:
|
||||
/// 1. Have a fixed weight;
|
||||
/// 2. Cannot lead to another call being made;
|
||||
/// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters.
|
||||
pub struct SafeCallFilter;
|
||||
impl Contains<RuntimeCall> for SafeCallFilter {
|
||||
fn contains(call: &RuntimeCall) -> bool {
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
{
|
||||
if matches!(call, RuntimeCall::System(frame_system::Call::remark_with_event { .. })) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
match call {
|
||||
RuntimeCall::System(
|
||||
frame_system::Call::set_heap_pages { .. } |
|
||||
frame_system::Call::set_code { .. } |
|
||||
frame_system::Call::set_code_without_checks { .. } |
|
||||
frame_system::Call::kill_prefix { .. },
|
||||
) |
|
||||
RuntimeCall::ParachainSystem(..) |
|
||||
RuntimeCall::Timestamp(..) |
|
||||
RuntimeCall::Balances(..) |
|
||||
RuntimeCall::CollatorSelection(
|
||||
pallet_collator_selection::Call::set_desired_candidates { .. } |
|
||||
pallet_collator_selection::Call::set_candidacy_bond { .. } |
|
||||
pallet_collator_selection::Call::register_as_candidate { .. } |
|
||||
pallet_collator_selection::Call::leave_intent { .. },
|
||||
) |
|
||||
RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
|
||||
RuntimeCall::XcmpQueue(..) |
|
||||
RuntimeCall::DmpQueue(..) |
|
||||
RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) |
|
||||
RuntimeCall::Assets(
|
||||
pallet_assets::Call::create { .. } |
|
||||
pallet_assets::Call::force_create { .. } |
|
||||
pallet_assets::Call::start_destroy { .. } |
|
||||
pallet_assets::Call::destroy_accounts { .. } |
|
||||
pallet_assets::Call::destroy_approvals { .. } |
|
||||
pallet_assets::Call::finish_destroy { .. } |
|
||||
pallet_assets::Call::mint { .. } |
|
||||
pallet_assets::Call::burn { .. } |
|
||||
pallet_assets::Call::transfer { .. } |
|
||||
pallet_assets::Call::transfer_keep_alive { .. } |
|
||||
pallet_assets::Call::force_transfer { .. } |
|
||||
pallet_assets::Call::freeze { .. } |
|
||||
pallet_assets::Call::thaw { .. } |
|
||||
pallet_assets::Call::freeze_asset { .. } |
|
||||
pallet_assets::Call::thaw_asset { .. } |
|
||||
pallet_assets::Call::transfer_ownership { .. } |
|
||||
pallet_assets::Call::set_team { .. } |
|
||||
pallet_assets::Call::clear_metadata { .. } |
|
||||
pallet_assets::Call::force_clear_metadata { .. } |
|
||||
pallet_assets::Call::force_asset_status { .. } |
|
||||
pallet_assets::Call::approve_transfer { .. } |
|
||||
pallet_assets::Call::cancel_approval { .. } |
|
||||
pallet_assets::Call::force_cancel_approval { .. } |
|
||||
pallet_assets::Call::transfer_approved { .. } |
|
||||
pallet_assets::Call::touch { .. } |
|
||||
pallet_assets::Call::refund { .. },
|
||||
) |
|
||||
RuntimeCall::Uniques(
|
||||
pallet_uniques::Call::create { .. } |
|
||||
pallet_uniques::Call::force_create { .. } |
|
||||
pallet_uniques::Call::destroy { .. } |
|
||||
pallet_uniques::Call::mint { .. } |
|
||||
pallet_uniques::Call::burn { .. } |
|
||||
pallet_uniques::Call::transfer { .. } |
|
||||
pallet_uniques::Call::freeze { .. } |
|
||||
pallet_uniques::Call::thaw { .. } |
|
||||
pallet_uniques::Call::freeze_collection { .. } |
|
||||
pallet_uniques::Call::thaw_collection { .. } |
|
||||
pallet_uniques::Call::transfer_ownership { .. } |
|
||||
pallet_uniques::Call::set_team { .. } |
|
||||
pallet_uniques::Call::approve_transfer { .. } |
|
||||
pallet_uniques::Call::cancel_approval { .. } |
|
||||
pallet_uniques::Call::force_item_status { .. } |
|
||||
pallet_uniques::Call::set_attribute { .. } |
|
||||
pallet_uniques::Call::clear_attribute { .. } |
|
||||
pallet_uniques::Call::set_metadata { .. } |
|
||||
pallet_uniques::Call::clear_metadata { .. } |
|
||||
pallet_uniques::Call::set_collection_metadata { .. } |
|
||||
pallet_uniques::Call::clear_collection_metadata { .. } |
|
||||
pallet_uniques::Call::set_accept_ownership { .. } |
|
||||
pallet_uniques::Call::set_collection_max_supply { .. } |
|
||||
pallet_uniques::Call::set_price { .. } |
|
||||
pallet_uniques::Call::buy_item { .. },
|
||||
) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub type Barrier = DenyThenTry<
|
||||
DenyReserveTransferToRelayChain,
|
||||
(
|
||||
TakeWeightCredit,
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
// Parent and its plurality get free execution
|
||||
AllowUnpaidExecutionFrom<ParentOrParentsPlurality>,
|
||||
// Expected responses are OK.
|
||||
AllowKnownQueryResponses<PolkadotXcm>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<Everything>,
|
||||
// Allow XCMs with some computed origins to pass through.
|
||||
WithComputedOrigin<
|
||||
(
|
||||
// If the message is one that immediately attemps to pay for execution, then allow it.
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
// Parent or its plurality (i.e. governance bodies) gets free execution.
|
||||
AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<Everything>,
|
||||
),
|
||||
UniversalLocation,
|
||||
ConstU32<8>,
|
||||
>,
|
||||
),
|
||||
>;
|
||||
|
||||
@@ -171,7 +280,7 @@ impl xcm_executor::Config for XcmConfig {
|
||||
// For WND, users must use teleport where allowed (e.g. with the Relay Chain).
|
||||
type IsReserve = ();
|
||||
type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of WND
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type UniversalLocation = UniversalLocation;
|
||||
type Barrier = Barrier;
|
||||
type Weigher = WeightInfoBounds<
|
||||
crate::weights::xcm::WestmintXcmWeight<RuntimeCall>,
|
||||
@@ -183,7 +292,7 @@ impl xcm_executor::Config for XcmConfig {
|
||||
cumulus_primitives_utility::TakeFirstAssetTrader<
|
||||
AccountId,
|
||||
AssetFeeAsExistentialDepositMultiplierFeeCharger,
|
||||
ConvertedConcreteAssetId<
|
||||
ConvertedConcreteId<
|
||||
AssetId,
|
||||
Balance,
|
||||
AsPrefixedGeneralIndex<AssetsPalletLocation, AssetId, JustTry>,
|
||||
@@ -201,6 +310,15 @@ impl xcm_executor::Config for XcmConfig {
|
||||
type AssetTrap = PolkadotXcm;
|
||||
type AssetClaims = PolkadotXcm;
|
||||
type SubscriptionService = PolkadotXcm;
|
||||
type PalletInstancesInfo = AllPalletsWithSystem;
|
||||
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
|
||||
type AssetLocker = ();
|
||||
type AssetExchanger = ();
|
||||
type FeeManager = ();
|
||||
type MessageExporter = ();
|
||||
type UniversalAliases = Nothing;
|
||||
type CallDispatcher = WithOriginFilter<SafeCallFilter>;
|
||||
type SafeCallFilter = SafeCallFilter;
|
||||
}
|
||||
|
||||
/// Local origins on this chain are allowed to dispatch XCM sends/executions.
|
||||
@@ -210,11 +328,16 @@ pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, R
|
||||
/// queues.
|
||||
pub type XcmRouter = (
|
||||
// Two routers - use UMP to communicate with the relay chain:
|
||||
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm>,
|
||||
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>,
|
||||
// ..and XCMP to communicate with the sibling chains.
|
||||
XcmpQueue,
|
||||
);
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
parameter_types! {
|
||||
pub ReachableDest: Option<MultiLocation> = Some(Parent.into());
|
||||
}
|
||||
|
||||
impl pallet_xcm::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type SendXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
|
||||
@@ -229,11 +352,19 @@ impl pallet_xcm::Config for Runtime {
|
||||
RuntimeCall,
|
||||
MaxInstructions,
|
||||
>;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type UniversalLocation = UniversalLocation;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
|
||||
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
|
||||
type Currency = Balances;
|
||||
type CurrencyMatcher = ();
|
||||
type TrustedLockers = ();
|
||||
type SovereignAccountOf = LocationToAccountId;
|
||||
type MaxLockers = ConstU32<8>;
|
||||
type WeightInfo = crate::weights::pallet_xcm::WeightInfo<Runtime>;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type ReachableDest = ReachableDest;
|
||||
}
|
||||
|
||||
impl cumulus_pallet_xcm::Config for Runtime {
|
||||
|
||||
@@ -62,13 +62,13 @@ fn test_asset_xcm_trader() {
|
||||
RuntimeHelper::<Runtime>::run_to_block(2, Some(AccountId::from(ALICE)));
|
||||
|
||||
// We are going to buy 4e9 weight
|
||||
let bought = 4_000_000_000u64;
|
||||
let bought = Weight::from_ref_time(4_000_000_000u64);
|
||||
|
||||
// Lets calculate amount needed
|
||||
let asset_amount_needed =
|
||||
AssetFeeAsExistentialDepositMultiplierFeeCharger::charge_weight_in_fungibles(
|
||||
local_asset_id,
|
||||
Weight::from_ref_time(bought),
|
||||
bought,
|
||||
)
|
||||
.expect("failed to compute");
|
||||
|
||||
@@ -138,7 +138,7 @@ fn test_asset_xcm_trader_with_refund() {
|
||||
RuntimeHelper::<Runtime>::run_to_block(2, Some(AccountId::from(ALICE)));
|
||||
|
||||
// We are going to buy 4e9 weight
|
||||
let bought = 4_000_000_000u64;
|
||||
let bought = Weight::from_ref_time(4_000_000_000u64);
|
||||
let asset_multilocation = MultiLocation::new(
|
||||
0,
|
||||
X2(
|
||||
@@ -151,7 +151,7 @@ fn test_asset_xcm_trader_with_refund() {
|
||||
);
|
||||
|
||||
// lets calculate amount needed
|
||||
let amount_bought = WeightToFee::weight_to_fee(&Weight::from_ref_time(bought));
|
||||
let amount_bought = WeightToFee::weight_to_fee(&bought);
|
||||
|
||||
let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into();
|
||||
|
||||
@@ -165,8 +165,7 @@ fn test_asset_xcm_trader_with_refund() {
|
||||
let weight_used = bought / 2;
|
||||
|
||||
// Make sure refurnd works.
|
||||
let amount_refunded =
|
||||
WeightToFee::weight_to_fee(&Weight::from_ref_time(bought - weight_used));
|
||||
let amount_refunded = WeightToFee::weight_to_fee(&(bought - weight_used));
|
||||
|
||||
assert_eq!(
|
||||
trader.refund_weight(bought - weight_used),
|
||||
@@ -177,7 +176,7 @@ fn test_asset_xcm_trader_with_refund() {
|
||||
drop(trader);
|
||||
|
||||
// We only should have paid for half of the bought weight
|
||||
let fees_paid = WeightToFee::weight_to_fee(&Weight::from_ref_time(weight_used));
|
||||
let fees_paid = WeightToFee::weight_to_fee(&weight_used);
|
||||
|
||||
assert_eq!(
|
||||
Assets::balance(1, AccountId::from(ALICE)),
|
||||
@@ -216,7 +215,7 @@ fn test_asset_xcm_trader_refund_not_possible_since_amount_less_than_ed() {
|
||||
RuntimeHelper::<Runtime>::run_to_block(2, Some(AccountId::from(ALICE)));
|
||||
|
||||
// We are going to buy 5e9 weight
|
||||
let bought = 500_000_000u64;
|
||||
let bought = Weight::from_ref_time(500_000_000u64);
|
||||
|
||||
let asset_multilocation = MultiLocation::new(
|
||||
0,
|
||||
@@ -229,7 +228,7 @@ fn test_asset_xcm_trader_refund_not_possible_since_amount_less_than_ed() {
|
||||
),
|
||||
);
|
||||
|
||||
let amount_bought = WeightToFee::weight_to_fee(&Weight::from_ref_time(bought));
|
||||
let amount_bought = WeightToFee::weight_to_fee(&bought);
|
||||
|
||||
assert!(
|
||||
amount_bought < ExistentialDeposit::get(),
|
||||
@@ -275,7 +274,7 @@ fn test_that_buying_ed_refund_does_not_refund() {
|
||||
// Set Alice as block author, who will receive fees
|
||||
RuntimeHelper::<Runtime>::run_to_block(2, Some(AccountId::from(ALICE)));
|
||||
|
||||
let bought = 500_000_000u64;
|
||||
let bought = Weight::from_ref_time(500_000_000u64);
|
||||
|
||||
let asset_multilocation = MultiLocation::new(
|
||||
0,
|
||||
@@ -288,7 +287,7 @@ fn test_that_buying_ed_refund_does_not_refund() {
|
||||
),
|
||||
);
|
||||
|
||||
let amount_bought = WeightToFee::weight_to_fee(&Weight::from_ref_time(bought));
|
||||
let amount_bought = WeightToFee::weight_to_fee(&bought);
|
||||
|
||||
assert!(
|
||||
amount_bought < ExistentialDeposit::get(),
|
||||
@@ -356,10 +355,10 @@ fn test_asset_xcm_trader_not_possible_for_non_sufficient_assets() {
|
||||
RuntimeHelper::<Runtime>::run_to_block(2, Some(AccountId::from(ALICE)));
|
||||
|
||||
// We are going to buy 4e9 weight
|
||||
let bought = 4_000_000_000u64;
|
||||
let bought = Weight::from_ref_time(4_000_000_000u64);
|
||||
|
||||
// lets calculate amount needed
|
||||
let asset_amount_needed = WeightToFee::weight_to_fee(&Weight::from_ref_time(bought));
|
||||
let asset_amount_needed = WeightToFee::weight_to_fee(&bought);
|
||||
|
||||
let asset_multilocation = MultiLocation::new(
|
||||
0,
|
||||
|
||||
@@ -305,6 +305,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
|
||||
type ControllerOrigin = RootOrExecutiveSimpleMajority;
|
||||
type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
|
||||
type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
|
||||
type PriceForSiblingDelivery = ();
|
||||
}
|
||||
|
||||
impl cumulus_pallet_dmp_queue::Config for Runtime {
|
||||
@@ -440,6 +441,7 @@ mod benches {
|
||||
[pallet_collator_selection, CollatorSelection]
|
||||
[cumulus_pallet_xcmp_queue, XcmpQueue]
|
||||
// XCM
|
||||
[pallet_xcm, PolkadotXcm]
|
||||
// NOTE: Make sure you point to the individual modules below.
|
||||
[pallet_xcm_benchmarks::fungible, XcmBalances]
|
||||
[pallet_xcm_benchmarks::generic, XcmGeneric]
|
||||
@@ -616,7 +618,7 @@ impl_runtime_apis! {
|
||||
fn valid_destination() -> Result<MultiLocation, BenchmarkError> {
|
||||
Ok(KsmRelayLocation::get())
|
||||
}
|
||||
fn worst_case_holding() -> MultiAssets {
|
||||
fn worst_case_holding(_depositable_count: u32) -> MultiAssets {
|
||||
// just concrete assets according to relay chain.
|
||||
let assets: Vec<MultiAsset> = vec![
|
||||
MultiAsset {
|
||||
@@ -633,8 +635,7 @@ impl_runtime_apis! {
|
||||
KsmRelayLocation::get(),
|
||||
MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(KsmRelayLocation::get()) },
|
||||
));
|
||||
pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = None;
|
||||
pub const CheckedAccount: Option<AccountId> = None;
|
||||
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
|
||||
}
|
||||
|
||||
impl pallet_xcm_benchmarks::fungible::Config for Runtime {
|
||||
@@ -642,7 +643,6 @@ impl_runtime_apis! {
|
||||
|
||||
type CheckedAccount = CheckedAccount;
|
||||
type TrustedTeleporter = TrustedTeleporter;
|
||||
type TrustedReserve = TrustedReserve;
|
||||
|
||||
fn get_multi_asset() -> MultiAsset {
|
||||
MultiAsset {
|
||||
@@ -659,8 +659,16 @@ impl_runtime_apis! {
|
||||
(0u64, Response::Version(Default::default()))
|
||||
}
|
||||
|
||||
fn transact_origin() -> Result<MultiLocation, BenchmarkError> {
|
||||
Ok(KsmRelayLocation::get())
|
||||
fn worst_case_asset_exchange() -> Result<(MultiAssets, MultiAssets), BenchmarkError> {
|
||||
Err(BenchmarkError::Skip)
|
||||
}
|
||||
|
||||
fn universal_alias() -> Result<Junction, BenchmarkError> {
|
||||
Err(BenchmarkError::Skip)
|
||||
}
|
||||
|
||||
fn transact_origin_and_runtime_call() -> Result<(MultiLocation, RuntimeCall), BenchmarkError> {
|
||||
Ok((KsmRelayLocation::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
|
||||
}
|
||||
|
||||
fn subscribe_origin() -> Result<MultiLocation, BenchmarkError> {
|
||||
@@ -673,6 +681,10 @@ impl_runtime_apis! {
|
||||
let ticket = MultiLocation { parents: 0, interior: Here };
|
||||
Ok((origin, ticket, assets))
|
||||
}
|
||||
|
||||
fn unlockable_asset() -> Result<(MultiLocation, MultiLocation, MultiAsset), BenchmarkError> {
|
||||
Err(BenchmarkError::Skip)
|
||||
}
|
||||
}
|
||||
|
||||
type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
|
||||
|
||||
@@ -27,6 +27,7 @@ pub mod pallet_multisig;
|
||||
pub mod pallet_session;
|
||||
pub mod pallet_timestamp;
|
||||
pub mod pallet_utility;
|
||||
pub mod pallet_xcm;
|
||||
pub mod paritydb_weights;
|
||||
pub mod rocksdb_weights;
|
||||
pub mod xcm;
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
// Copyright 2021 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Cumulus.
|
||||
|
||||
// Cumulus is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Cumulus is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Autogenerated weights for `pallet_xcm`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2022-12-22, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-kusama-dev"), DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// /home/benchbot/cargo_target_dir/production/polkadot-parachain
|
||||
// benchmark
|
||||
// pallet
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --extrinsic=*
|
||||
// --execution=wasm
|
||||
// --wasm-execution=compiled
|
||||
// --heap-pages=4096
|
||||
// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json
|
||||
// --pallet=pallet_xcm
|
||||
// --chain=bridge-hub-kusama-dev
|
||||
// --header=./file_header.txt
|
||||
// --output=./parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use frame_support::{traits::Get, weights::Weight};
|
||||
use sp_std::marker::PhantomData;
|
||||
|
||||
/// Weight functions for `pallet_xcm`.
|
||||
pub struct WeightInfo<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
fn send() -> Weight {
|
||||
// Minimum execution time: 26_824 nanoseconds.
|
||||
Weight::from_ref_time(27_272_000)
|
||||
.saturating_add(T::DbWeight::get().reads(5))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
fn teleport_assets() -> Weight {
|
||||
// Minimum execution time: 32_322 nanoseconds.
|
||||
Weight::from_ref_time(32_760_000)
|
||||
.saturating_add(T::DbWeight::get().reads(1))
|
||||
}
|
||||
// Storage: Benchmark Override (r:0 w:0)
|
||||
fn reserve_transfer_assets() -> Weight {
|
||||
// Minimum execution time: 18_446_744_073_709_551 nanoseconds.
|
||||
Weight::from_ref_time(18_446_744_073_709_551_000)
|
||||
}
|
||||
// Storage: Benchmark Override (r:0 w:0)
|
||||
fn execute() -> Weight {
|
||||
// Minimum execution time: 18_446_744_073_709_551 nanoseconds.
|
||||
Weight::from_ref_time(18_446_744_073_709_551_000)
|
||||
}
|
||||
// Storage: PolkadotXcm SupportedVersion (r:0 w:1)
|
||||
fn force_xcm_version() -> Weight {
|
||||
// Minimum execution time: 14_919 nanoseconds.
|
||||
Weight::from_ref_time(15_388_000)
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
}
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:0 w:1)
|
||||
fn force_default_xcm_version() -> Weight {
|
||||
// Minimum execution time: 4_754 nanoseconds.
|
||||
Weight::from_ref_time(4_857_000)
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifiers (r:1 w:1)
|
||||
// Storage: PolkadotXcm QueryCounter (r:1 w:1)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
// Storage: PolkadotXcm Queries (r:0 w:1)
|
||||
fn force_subscribe_version_notify() -> Weight {
|
||||
// Minimum execution time: 31_107 nanoseconds.
|
||||
Weight::from_ref_time(31_928_000)
|
||||
.saturating_add(T::DbWeight::get().reads(7))
|
||||
.saturating_add(T::DbWeight::get().writes(5))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifiers (r:1 w:1)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
// Storage: PolkadotXcm Queries (r:0 w:1)
|
||||
fn force_unsubscribe_version_notify() -> Weight {
|
||||
// Minimum execution time: 31_745 nanoseconds.
|
||||
Weight::from_ref_time(32_243_000)
|
||||
.saturating_add(T::DbWeight::get().reads(6))
|
||||
.saturating_add(T::DbWeight::get().writes(4))
|
||||
}
|
||||
// Storage: PolkadotXcm SupportedVersion (r:4 w:2)
|
||||
fn migrate_supported_version() -> Weight {
|
||||
// Minimum execution time: 13_855 nanoseconds.
|
||||
Weight::from_ref_time(14_060_000)
|
||||
.saturating_add(T::DbWeight::get().reads(4))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifiers (r:4 w:2)
|
||||
fn migrate_version_notifiers() -> Weight {
|
||||
// Minimum execution time: 13_693 nanoseconds.
|
||||
Weight::from_ref_time(13_984_000)
|
||||
.saturating_add(T::DbWeight::get().reads(4))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:5 w:0)
|
||||
fn already_notified_target() -> Weight {
|
||||
// Minimum execution time: 15_148 nanoseconds.
|
||||
Weight::from_ref_time(15_399_000)
|
||||
.saturating_add(T::DbWeight::get().reads(5))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:2 w:1)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
fn notify_current_targets() -> Weight {
|
||||
// Minimum execution time: 26_582 nanoseconds.
|
||||
Weight::from_ref_time(27_284_000)
|
||||
.saturating_add(T::DbWeight::get().reads(7))
|
||||
.saturating_add(T::DbWeight::get().writes(3))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:3 w:0)
|
||||
fn notify_target_migration_fail() -> Weight {
|
||||
// Minimum execution time: 6_961 nanoseconds.
|
||||
Weight::from_ref_time(7_139_000)
|
||||
.saturating_add(T::DbWeight::get().reads(3))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:4 w:2)
|
||||
fn migrate_version_notify_targets() -> Weight {
|
||||
// Minimum execution time: 14_094 nanoseconds.
|
||||
Weight::from_ref_time(14_474_000)
|
||||
.saturating_add(T::DbWeight::get().reads(4))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:4 w:2)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
fn migrate_and_notify_old_targets() -> Weight {
|
||||
// Minimum execution time: 31_931 nanoseconds.
|
||||
Weight::from_ref_time(32_628_000)
|
||||
.saturating_add(T::DbWeight::get().reads(9))
|
||||
.saturating_add(T::DbWeight::get().writes(4))
|
||||
}
|
||||
}
|
||||
@@ -21,168 +21,220 @@ use crate::Runtime;
|
||||
use frame_support::weights::Weight;
|
||||
use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight;
|
||||
use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
|
||||
use sp_std::{cmp, prelude::*};
|
||||
use xcm::{
|
||||
latest::{prelude::*, Weight as XCMWeight},
|
||||
DoubleEncoded,
|
||||
};
|
||||
use sp_std::prelude::*;
|
||||
use xcm::{latest::prelude::*, DoubleEncoded};
|
||||
|
||||
trait WeighMultiAssets {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> XCMWeight;
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight;
|
||||
}
|
||||
|
||||
const MAX_ASSETS: u32 = 100;
|
||||
|
||||
impl WeighMultiAssets for MultiAssetFilter {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> XCMWeight {
|
||||
let weight = match self {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
||||
match self {
|
||||
Self::Definite(assets) =>
|
||||
weight.saturating_mul(assets.inner().into_iter().count() as u64),
|
||||
Self::Wild(_) => weight.saturating_mul(MAX_ASSETS as u64),
|
||||
};
|
||||
weight.ref_time()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl WeighMultiAssets for MultiAssets {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> XCMWeight {
|
||||
weight.saturating_mul(self.inner().into_iter().count() as u64).ref_time()
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
||||
weight.saturating_mul(self.inner().into_iter().count() as u64)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BridgeHubKusamaXcmWeight<Call>(core::marker::PhantomData<Call>);
|
||||
impl<Call> XcmWeightInfo<Call> for BridgeHubKusamaXcmWeight<Call> {
|
||||
fn withdraw_asset(assets: &MultiAssets) -> XCMWeight {
|
||||
fn withdraw_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::withdraw_asset())
|
||||
}
|
||||
// Currently there is no trusted reserve
|
||||
fn reserve_asset_deposited(_assets: &MultiAssets) -> XCMWeight {
|
||||
u64::MAX
|
||||
fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight {
|
||||
// TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974
|
||||
Weight::from_ref_time(1_000_000_000 as u64)
|
||||
}
|
||||
fn receive_teleported_asset(assets: &MultiAssets) -> XCMWeight {
|
||||
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::receive_teleported_asset())
|
||||
}
|
||||
fn query_response(_query_id: &u64, _response: &Response, _max_weight: &u64) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::query_response().ref_time()
|
||||
fn query_response(
|
||||
_query_id: &u64,
|
||||
_response: &Response,
|
||||
_max_weight: &Weight,
|
||||
_querier: &Option<MultiLocation>,
|
||||
) -> Weight {
|
||||
XcmGeneric::<Runtime>::query_response()
|
||||
}
|
||||
fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> XCMWeight {
|
||||
fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::transfer_asset())
|
||||
}
|
||||
fn transfer_reserve_asset(
|
||||
assets: &MultiAssets,
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> XCMWeight {
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::transfer_reserve_asset())
|
||||
}
|
||||
fn transact(
|
||||
_origin_type: &OriginKind,
|
||||
_require_weight_at_most: &u64,
|
||||
_require_weight_at_most: &Weight,
|
||||
_call: &DoubleEncoded<Call>,
|
||||
) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::transact().ref_time()
|
||||
) -> Weight {
|
||||
XcmGeneric::<Runtime>::transact()
|
||||
}
|
||||
fn hrmp_new_channel_open_request(
|
||||
_sender: &u32,
|
||||
_max_message_size: &u32,
|
||||
_max_capacity: &u32,
|
||||
) -> XCMWeight {
|
||||
) -> Weight {
|
||||
// XCM Executor does not currently support HRMP channel operations
|
||||
Weight::MAX.ref_time()
|
||||
Weight::MAX
|
||||
}
|
||||
fn hrmp_channel_accepted(_recipient: &u32) -> XCMWeight {
|
||||
fn hrmp_channel_accepted(_recipient: &u32) -> Weight {
|
||||
// XCM Executor does not currently support HRMP channel operations
|
||||
Weight::MAX.ref_time()
|
||||
Weight::MAX
|
||||
}
|
||||
fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> XCMWeight {
|
||||
fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> Weight {
|
||||
// XCM Executor does not currently support HRMP channel operations
|
||||
Weight::MAX.ref_time()
|
||||
Weight::MAX
|
||||
}
|
||||
fn clear_origin() -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::clear_origin().ref_time()
|
||||
fn clear_origin() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_origin()
|
||||
}
|
||||
fn descend_origin(_who: &InteriorMultiLocation) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::descend_origin().ref_time()
|
||||
fn descend_origin(_who: &InteriorMultiLocation) -> Weight {
|
||||
XcmGeneric::<Runtime>::descend_origin()
|
||||
}
|
||||
fn report_error(
|
||||
_query_id: &QueryId,
|
||||
_dest: &MultiLocation,
|
||||
_max_response_weight: &u64,
|
||||
) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::report_error().ref_time()
|
||||
fn report_error(_query_response_info: &QueryResponseInfo) -> Weight {
|
||||
XcmGeneric::<Runtime>::report_error()
|
||||
}
|
||||
|
||||
fn deposit_asset(
|
||||
assets: &MultiAssetFilter,
|
||||
_max_assets: &u32,
|
||||
_dest: &MultiLocation,
|
||||
) -> XCMWeight {
|
||||
fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight {
|
||||
// Hardcoded till the XCM pallet is fixed
|
||||
let hardcoded_weight = Weight::from_ref_time(1_000_000_000 as u64).ref_time();
|
||||
let hardcoded_weight = Weight::from_ref_time(1_000_000_000 as u64);
|
||||
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_asset());
|
||||
cmp::min(hardcoded_weight, weight)
|
||||
hardcoded_weight.min(weight)
|
||||
}
|
||||
fn deposit_reserve_asset(
|
||||
assets: &MultiAssetFilter,
|
||||
_max_assets: &u32,
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> XCMWeight {
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_reserve_asset())
|
||||
}
|
||||
fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets) -> XCMWeight {
|
||||
Weight::MAX.ref_time()
|
||||
fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn initiate_reserve_withdraw(
|
||||
assets: &MultiAssetFilter,
|
||||
_reserve: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> XCMWeight {
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::initiate_reserve_withdraw())
|
||||
}
|
||||
fn initiate_teleport(
|
||||
assets: &MultiAssetFilter,
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> XCMWeight {
|
||||
) -> Weight {
|
||||
// Hardcoded till the XCM pallet is fixed
|
||||
let hardcoded_weight = Weight::from_ref_time(200_000_000 as u64).ref_time();
|
||||
let hardcoded_weight = Weight::from_ref_time(200_000_000 as u64);
|
||||
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport());
|
||||
cmp::min(hardcoded_weight, weight)
|
||||
hardcoded_weight.min(weight)
|
||||
}
|
||||
fn query_holding(
|
||||
_query_id: &u64,
|
||||
_dest: &MultiLocation,
|
||||
_assets: &MultiAssetFilter,
|
||||
_max_response_weight: &u64,
|
||||
) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::query_holding().ref_time()
|
||||
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
|
||||
XcmGeneric::<Runtime>::report_holding()
|
||||
}
|
||||
fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::buy_execution().ref_time()
|
||||
fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> Weight {
|
||||
XcmGeneric::<Runtime>::buy_execution()
|
||||
}
|
||||
fn refund_surplus() -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::refund_surplus().ref_time()
|
||||
fn refund_surplus() -> Weight {
|
||||
XcmGeneric::<Runtime>::refund_surplus()
|
||||
}
|
||||
fn set_error_handler(_xcm: &Xcm<Call>) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::set_error_handler().ref_time()
|
||||
fn set_error_handler(_xcm: &Xcm<Call>) -> Weight {
|
||||
XcmGeneric::<Runtime>::set_error_handler()
|
||||
}
|
||||
fn set_appendix(_xcm: &Xcm<Call>) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::set_appendix().ref_time()
|
||||
fn set_appendix(_xcm: &Xcm<Call>) -> Weight {
|
||||
XcmGeneric::<Runtime>::set_appendix()
|
||||
}
|
||||
fn clear_error() -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::clear_error().ref_time()
|
||||
fn clear_error() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_error()
|
||||
}
|
||||
fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::claim_asset().ref_time()
|
||||
fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> Weight {
|
||||
XcmGeneric::<Runtime>::claim_asset()
|
||||
}
|
||||
fn trap(_code: &u64) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::trap().ref_time()
|
||||
fn trap(_code: &u64) -> Weight {
|
||||
XcmGeneric::<Runtime>::trap()
|
||||
}
|
||||
fn subscribe_version(_query_id: &QueryId, _max_response_weight: &u64) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::subscribe_version().ref_time()
|
||||
fn subscribe_version(_query_id: &QueryId, _max_response_weight: &Weight) -> Weight {
|
||||
XcmGeneric::<Runtime>::subscribe_version()
|
||||
}
|
||||
fn unsubscribe_version() -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::unsubscribe_version().ref_time()
|
||||
fn unsubscribe_version() -> Weight {
|
||||
XcmGeneric::<Runtime>::unsubscribe_version()
|
||||
}
|
||||
fn burn_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::burn_asset())
|
||||
}
|
||||
fn expect_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::expect_asset())
|
||||
}
|
||||
fn expect_origin(_origin: &Option<MultiLocation>) -> Weight {
|
||||
XcmGeneric::<Runtime>::expect_origin()
|
||||
}
|
||||
fn expect_error(_error: &Option<(u32, XcmError)>) -> Weight {
|
||||
XcmGeneric::<Runtime>::expect_error()
|
||||
}
|
||||
fn query_pallet(_module_name: &Vec<u8>, _response_info: &QueryResponseInfo) -> Weight {
|
||||
XcmGeneric::<Runtime>::query_pallet()
|
||||
}
|
||||
fn expect_pallet(
|
||||
_index: &u32,
|
||||
_name: &Vec<u8>,
|
||||
_module_name: &Vec<u8>,
|
||||
_crate_major: &u32,
|
||||
_min_crate_minor: &u32,
|
||||
) -> Weight {
|
||||
XcmGeneric::<Runtime>::expect_pallet()
|
||||
}
|
||||
fn report_transact_status(_response_info: &QueryResponseInfo) -> Weight {
|
||||
XcmGeneric::<Runtime>::report_transact_status()
|
||||
}
|
||||
fn clear_transact_status() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_transact_status()
|
||||
}
|
||||
fn universal_origin(_: &Junction) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn set_fees_mode(_: &bool) -> Weight {
|
||||
XcmGeneric::<Runtime>::set_fees_mode()
|
||||
}
|
||||
fn set_topic(_topic: &[u8; 32]) -> Weight {
|
||||
XcmGeneric::<Runtime>::set_topic()
|
||||
}
|
||||
fn clear_topic() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_topic()
|
||||
}
|
||||
fn alias_origin(_: &MultiLocation) -> Weight {
|
||||
// XCM Executor does not currently support alias origin operations
|
||||
Weight::MAX
|
||||
}
|
||||
fn unpaid_execution(_: &WeightLimit, _: &Option<MultiLocation>) -> Weight {
|
||||
XcmGeneric::<Runtime>::unpaid_execution()
|
||||
}
|
||||
}
|
||||
|
||||
+9
-9
@@ -18,8 +18,8 @@
|
||||
//! Autogenerated weights for `pallet_xcm_benchmarks::fungible`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2022-12-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! DATE: 2022-12-22, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-kusama-dev"), DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
@@ -50,13 +50,13 @@ pub struct WeightInfo<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: System Account (r:1 w:1)
|
||||
pub(crate) fn withdraw_asset() -> Weight {
|
||||
Weight::from_ref_time(26_021_000 as u64)
|
||||
Weight::from_ref_time(27_070_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
// Storage: System Account (r:2 w:2)
|
||||
pub(crate) fn transfer_asset() -> Weight {
|
||||
Weight::from_ref_time(35_776_000 as u64)
|
||||
Weight::from_ref_time(38_614_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
@@ -68,16 +68,16 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn transfer_reserve_asset() -> Weight {
|
||||
Weight::from_ref_time(52_799_000 as u64)
|
||||
Weight::from_ref_time(55_875_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(8 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(4 as u64))
|
||||
}
|
||||
pub(crate) fn receive_teleported_asset() -> Weight {
|
||||
Weight::from_ref_time(5_784_000 as u64)
|
||||
Weight::from_ref_time(7_121_000 as u64)
|
||||
}
|
||||
// Storage: System Account (r:1 w:1)
|
||||
pub(crate) fn deposit_asset() -> Weight {
|
||||
Weight::from_ref_time(28_148_000 as u64)
|
||||
Weight::from_ref_time(30_450_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
@@ -89,7 +89,7 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn deposit_reserve_asset() -> Weight {
|
||||
Weight::from_ref_time(45_600_000 as u64)
|
||||
Weight::from_ref_time(49_122_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(7 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as u64))
|
||||
}
|
||||
@@ -100,7 +100,7 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn initiate_teleport() -> Weight {
|
||||
Weight::from_ref_time(23_402_000 as u64)
|
||||
Weight::from_ref_time(25_016_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
|
||||
+73
-20
@@ -18,8 +18,8 @@
|
||||
//! Autogenerated weights for `pallet_xcm_benchmarks::generic`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2022-12-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! DATE: 2022-12-22, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-kusama-dev"), DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
@@ -54,58 +54,59 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn query_holding() -> Weight {
|
||||
Weight::from_ref_time(21_401_000 as u64)
|
||||
pub(crate) fn report_holding() -> Weight {
|
||||
Weight::from_ref_time(28_638_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
pub(crate) fn buy_execution() -> Weight {
|
||||
Weight::from_ref_time(5_320_000 as u64)
|
||||
Weight::from_ref_time(5_869_000 as u64)
|
||||
}
|
||||
// Storage: PolkadotXcm Queries (r:1 w:0)
|
||||
pub(crate) fn query_response() -> Weight {
|
||||
Weight::from_ref_time(16_749_000 as u64)
|
||||
Weight::from_ref_time(18_018_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
}
|
||||
pub(crate) fn transact() -> Weight {
|
||||
Weight::from_ref_time(19_670_000 as u64)
|
||||
Weight::from_ref_time(21_240_000 as u64)
|
||||
}
|
||||
pub(crate) fn refund_surplus() -> Weight {
|
||||
Weight::from_ref_time(5_373_000 as u64)
|
||||
Weight::from_ref_time(6_118_000 as u64)
|
||||
}
|
||||
pub(crate) fn set_error_handler() -> Weight {
|
||||
Weight::from_ref_time(5_100_000 as u64)
|
||||
Weight::from_ref_time(5_855_000 as u64)
|
||||
}
|
||||
pub(crate) fn set_appendix() -> Weight {
|
||||
Weight::from_ref_time(5_288_000 as u64)
|
||||
Weight::from_ref_time(5_901_000 as u64)
|
||||
}
|
||||
pub(crate) fn clear_error() -> Weight {
|
||||
Weight::from_ref_time(5_315_000 as u64)
|
||||
Weight::from_ref_time(5_762_000 as u64)
|
||||
}
|
||||
pub(crate) fn descend_origin() -> Weight {
|
||||
Weight::from_ref_time(6_432_000 as u64)
|
||||
Weight::from_ref_time(6_717_000 as u64)
|
||||
}
|
||||
pub(crate) fn clear_origin() -> Weight {
|
||||
Weight::from_ref_time(5_254_000 as u64)
|
||||
Weight::from_ref_time(5_924_000 as u64)
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn report_error() -> Weight {
|
||||
Weight::from_ref_time(15_047_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(5 as u64))
|
||||
Weight::from_ref_time(22_264_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
// Storage: PolkadotXcm AssetTraps (r:1 w:1)
|
||||
pub(crate) fn claim_asset() -> Weight {
|
||||
Weight::from_ref_time(21_288_000 as u64)
|
||||
Weight::from_ref_time(21_620_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
pub(crate) fn trap() -> Weight {
|
||||
Weight::from_ref_time(5_120_000 as u64)
|
||||
Weight::from_ref_time(5_795_000 as u64)
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:1 w:1)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
@@ -114,13 +115,13 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn subscribe_version() -> Weight {
|
||||
Weight::from_ref_time(17_992_000 as u64)
|
||||
Weight::from_ref_time(29_039_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as u64))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:0 w:1)
|
||||
pub(crate) fn unsubscribe_version() -> Weight {
|
||||
Weight::from_ref_time(7_321_000 as u64)
|
||||
Weight::from_ref_time(8_794_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
@@ -130,8 +131,60 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn initiate_reserve_withdraw() -> Weight {
|
||||
Weight::from_ref_time(22_846_000 as u64)
|
||||
Weight::from_ref_time(26_793_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
pub(crate) fn burn_asset() -> Weight {
|
||||
Weight::from_ref_time(7_912_000 as u64)
|
||||
}
|
||||
pub(crate) fn expect_asset() -> Weight {
|
||||
Weight::from_ref_time(6_981_000 as u64)
|
||||
}
|
||||
pub(crate) fn expect_origin() -> Weight {
|
||||
Weight::from_ref_time(6_880_000 as u64)
|
||||
}
|
||||
pub(crate) fn expect_error() -> Weight {
|
||||
Weight::from_ref_time(6_802_000 as u64)
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn query_pallet() -> Weight {
|
||||
Weight::from_ref_time(31_039_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
pub(crate) fn expect_pallet() -> Weight {
|
||||
Weight::from_ref_time(9_291_000 as u64)
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn report_transact_status() -> Weight {
|
||||
Weight::from_ref_time(28_012_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
pub(crate) fn clear_transact_status() -> Weight {
|
||||
Weight::from_ref_time(7_491_000 as u64)
|
||||
}
|
||||
pub(crate) fn set_topic() -> Weight {
|
||||
Weight::from_ref_time(7_373_000 as u64)
|
||||
}
|
||||
pub(crate) fn clear_topic() -> Weight {
|
||||
Weight::from_ref_time(7_490_000 as u64)
|
||||
}
|
||||
pub(crate) fn set_fees_mode() -> Weight {
|
||||
Weight::from_ref_time(11_585_000 as u64)
|
||||
}
|
||||
pub(crate) fn unpaid_execution() -> Weight {
|
||||
Weight::from_ref_time(7_582_000 as u64)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use super::{
|
||||
AccountId, Balances, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall,
|
||||
RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
|
||||
AccountId, AllPalletsWithSystem, Balances, ParachainInfo, ParachainSystem, PolkadotXcm,
|
||||
Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
|
||||
};
|
||||
use frame_support::{
|
||||
match_types, parameter_types,
|
||||
traits::{Everything, Nothing},
|
||||
traits::{ConstU32, Contains, Everything, Nothing},
|
||||
};
|
||||
use pallet_xcm::XcmPassthrough;
|
||||
use parachains_common::xcm_config::{
|
||||
@@ -30,21 +30,23 @@ use polkadot_parachain::primitives::Sibling;
|
||||
use polkadot_runtime_common::impls::ToAuthor;
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
||||
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin,
|
||||
IsConcrete, LocationInverter, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
|
||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
||||
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
|
||||
WeightInfoBounds,
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin,
|
||||
IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
|
||||
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
|
||||
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds,
|
||||
WithComputedOrigin,
|
||||
};
|
||||
use xcm_executor::XcmExecutor;
|
||||
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
|
||||
|
||||
parameter_types! {
|
||||
pub const KsmRelayLocation: MultiLocation = MultiLocation::parent();
|
||||
pub const RelayNetwork: NetworkId = NetworkId::Kusama;
|
||||
pub const RelayNetwork: Option<NetworkId> = Some(NetworkId::Kusama);
|
||||
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
||||
pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
|
||||
pub UniversalLocation: InteriorMultiLocation =
|
||||
X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into()));
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
pub const MaxAssetsIntoHolding: u32 = 64;
|
||||
}
|
||||
|
||||
/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
|
||||
@@ -108,20 +110,67 @@ match_types! {
|
||||
MultiLocation { parents: 1, interior: X1(_) }
|
||||
};
|
||||
}
|
||||
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
|
||||
/// account for proof size weights.
|
||||
///
|
||||
/// Calls that are allowed through this filter must:
|
||||
/// 1. Have a fixed weight;
|
||||
/// 2. Cannot lead to another call being made;
|
||||
/// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters.
|
||||
pub struct SafeCallFilter;
|
||||
impl Contains<RuntimeCall> for SafeCallFilter {
|
||||
fn contains(call: &RuntimeCall) -> bool {
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
{
|
||||
if matches!(call, RuntimeCall::System(frame_system::Call::remark_with_event { .. })) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
match call {
|
||||
RuntimeCall::System(
|
||||
frame_system::Call::set_heap_pages { .. } |
|
||||
frame_system::Call::set_code { .. } |
|
||||
frame_system::Call::set_code_without_checks { .. } |
|
||||
frame_system::Call::kill_prefix { .. },
|
||||
) |
|
||||
RuntimeCall::ParachainSystem(..) |
|
||||
RuntimeCall::Timestamp(..) |
|
||||
RuntimeCall::Balances(..) |
|
||||
RuntimeCall::CollatorSelection(
|
||||
pallet_collator_selection::Call::set_desired_candidates { .. } |
|
||||
pallet_collator_selection::Call::set_candidacy_bond { .. } |
|
||||
pallet_collator_selection::Call::register_as_candidate { .. } |
|
||||
pallet_collator_selection::Call::leave_intent { .. },
|
||||
) |
|
||||
RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
|
||||
RuntimeCall::XcmpQueue(..) |
|
||||
RuntimeCall::DmpQueue(..) |
|
||||
RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub type Barrier = DenyThenTry<
|
||||
DenyReserveTransferToRelayChain,
|
||||
(
|
||||
// Allow local users to buy weight credit.
|
||||
TakeWeightCredit,
|
||||
// Parent and its exec plurality get free execution.
|
||||
AllowUnpaidExecutionFrom<ParentOrParentsExecutivePlurality>,
|
||||
// Expected responses are OK.
|
||||
AllowKnownQueryResponses<PolkadotXcm>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<ParentOrSiblings>,
|
||||
// Allow anything to pay for execution.
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
WithComputedOrigin<
|
||||
(
|
||||
// Allow anything to pay for execution.
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
// Parent and its exec plurality get free execution.
|
||||
AllowExplicitUnpaidExecutionFrom<ParentOrParentsExecutivePlurality>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<ParentOrSiblings>,
|
||||
),
|
||||
UniversalLocation,
|
||||
ConstU32<8>,
|
||||
>,
|
||||
),
|
||||
>;
|
||||
|
||||
@@ -136,7 +185,7 @@ impl xcm_executor::Config for XcmConfig {
|
||||
type IsReserve = ();
|
||||
/// Only allow teleportation of KSM.
|
||||
type IsTeleporter = ConcreteNativeAssetFrom<KsmRelayLocation>;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type UniversalLocation = UniversalLocation;
|
||||
type Barrier = Barrier;
|
||||
type Weigher = WeightInfoBounds<
|
||||
crate::weights::xcm::BridgeHubKusamaXcmWeight<RuntimeCall>,
|
||||
@@ -149,6 +198,15 @@ impl xcm_executor::Config for XcmConfig {
|
||||
type AssetTrap = PolkadotXcm;
|
||||
type AssetClaims = PolkadotXcm;
|
||||
type SubscriptionService = PolkadotXcm;
|
||||
type PalletInstancesInfo = AllPalletsWithSystem;
|
||||
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
|
||||
type AssetLocker = ();
|
||||
type AssetExchanger = ();
|
||||
type FeeManager = ();
|
||||
type MessageExporter = ();
|
||||
type UniversalAliases = Nothing;
|
||||
type CallDispatcher = WithOriginFilter<SafeCallFilter>;
|
||||
type SafeCallFilter = SafeCallFilter;
|
||||
}
|
||||
|
||||
/// Converts a local signed origin into an XCM multilocation.
|
||||
@@ -159,11 +217,16 @@ pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, R
|
||||
/// queues.
|
||||
pub type XcmRouter = (
|
||||
// Two routers - use UMP to communicate with the relay chain:
|
||||
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm>,
|
||||
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>,
|
||||
// ..and XCMP to communicate with the sibling chains.
|
||||
XcmpQueue,
|
||||
);
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
parameter_types! {
|
||||
pub ReachableDest: Option<MultiLocation> = Some(Parent.into());
|
||||
}
|
||||
|
||||
impl pallet_xcm::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
// We want to disallow users sending (arbitrary) XCMs from this chain.
|
||||
@@ -181,11 +244,19 @@ impl pallet_xcm::Config for Runtime {
|
||||
RuntimeCall,
|
||||
MaxInstructions,
|
||||
>;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type UniversalLocation = UniversalLocation;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
|
||||
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
|
||||
type Currency = Balances;
|
||||
type CurrencyMatcher = ();
|
||||
type TrustedLockers = ();
|
||||
type SovereignAccountOf = LocationToAccountId;
|
||||
type MaxLockers = ConstU32<8>;
|
||||
type WeightInfo = crate::weights::pallet_xcm::WeightInfo<Runtime>;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type ReachableDest = ReachableDest;
|
||||
}
|
||||
|
||||
impl cumulus_pallet_xcm::Config for Runtime {
|
||||
|
||||
@@ -335,6 +335,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
|
||||
type ControllerOrigin = EnsureRoot<AccountId>;
|
||||
type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
|
||||
type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
|
||||
type PriceForSiblingDelivery = ();
|
||||
}
|
||||
|
||||
impl cumulus_pallet_dmp_queue::Config for Runtime {
|
||||
@@ -468,6 +469,7 @@ mod benches {
|
||||
[pallet_collator_selection, CollatorSelection]
|
||||
[cumulus_pallet_xcmp_queue, XcmpQueue]
|
||||
// XCM
|
||||
[pallet_xcm, PolkadotXcm]
|
||||
// NOTE: Make sure you point to the individual modules below.
|
||||
[pallet_xcm_benchmarks::fungible, XcmBalances]
|
||||
[pallet_xcm_benchmarks::generic, XcmGeneric]
|
||||
@@ -644,7 +646,7 @@ impl_runtime_apis! {
|
||||
fn valid_destination() -> Result<MultiLocation, BenchmarkError> {
|
||||
Ok(RelayLocation::get())
|
||||
}
|
||||
fn worst_case_holding() -> MultiAssets {
|
||||
fn worst_case_holding(_depositable_count: u32) -> MultiAssets {
|
||||
// just concrete assets according to relay chain.
|
||||
let assets: Vec<MultiAsset> = vec![
|
||||
MultiAsset {
|
||||
@@ -661,8 +663,7 @@ impl_runtime_apis! {
|
||||
RelayLocation::get(),
|
||||
MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(RelayLocation::get()) },
|
||||
));
|
||||
pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = None;
|
||||
pub const CheckedAccount: Option<AccountId> = None;
|
||||
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
|
||||
}
|
||||
|
||||
impl pallet_xcm_benchmarks::fungible::Config for Runtime {
|
||||
@@ -670,7 +671,6 @@ impl_runtime_apis! {
|
||||
|
||||
type CheckedAccount = CheckedAccount;
|
||||
type TrustedTeleporter = TrustedTeleporter;
|
||||
type TrustedReserve = TrustedReserve;
|
||||
|
||||
fn get_multi_asset() -> MultiAsset {
|
||||
MultiAsset {
|
||||
@@ -687,8 +687,16 @@ impl_runtime_apis! {
|
||||
(0u64, Response::Version(Default::default()))
|
||||
}
|
||||
|
||||
fn transact_origin() -> Result<MultiLocation, BenchmarkError> {
|
||||
Ok(RelayLocation::get())
|
||||
fn worst_case_asset_exchange() -> Result<(MultiAssets, MultiAssets), BenchmarkError> {
|
||||
Err(BenchmarkError::Skip)
|
||||
}
|
||||
|
||||
fn universal_alias() -> Result<Junction, BenchmarkError> {
|
||||
Err(BenchmarkError::Skip)
|
||||
}
|
||||
|
||||
fn transact_origin_and_runtime_call() -> Result<(MultiLocation, RuntimeCall), BenchmarkError> {
|
||||
Ok((RelayLocation::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
|
||||
}
|
||||
|
||||
fn subscribe_origin() -> Result<MultiLocation, BenchmarkError> {
|
||||
@@ -701,6 +709,10 @@ impl_runtime_apis! {
|
||||
let ticket = MultiLocation { parents: 0, interior: Here };
|
||||
Ok((origin, ticket, assets))
|
||||
}
|
||||
|
||||
fn unlockable_asset() -> Result<(MultiLocation, MultiLocation, MultiAsset), BenchmarkError> {
|
||||
Err(BenchmarkError::Skip)
|
||||
}
|
||||
}
|
||||
|
||||
type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
|
||||
|
||||
@@ -27,6 +27,7 @@ pub mod pallet_multisig;
|
||||
pub mod pallet_session;
|
||||
pub mod pallet_timestamp;
|
||||
pub mod pallet_utility;
|
||||
pub mod pallet_xcm;
|
||||
pub mod paritydb_weights;
|
||||
pub mod rocksdb_weights;
|
||||
pub mod xcm;
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
// Copyright 2021 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Cumulus.
|
||||
|
||||
// Cumulus is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Cumulus is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Autogenerated weights for `pallet_xcm`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2022-12-22, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// /home/benchbot/cargo_target_dir/production/polkadot-parachain
|
||||
// benchmark
|
||||
// pallet
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --extrinsic=*
|
||||
// --execution=wasm
|
||||
// --wasm-execution=compiled
|
||||
// --heap-pages=4096
|
||||
// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json
|
||||
// --pallet=pallet_xcm
|
||||
// --chain=bridge-hub-rococo-dev
|
||||
// --header=./file_header.txt
|
||||
// --output=./parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use frame_support::{traits::Get, weights::Weight};
|
||||
use sp_std::marker::PhantomData;
|
||||
|
||||
/// Weight functions for `pallet_xcm`.
|
||||
pub struct WeightInfo<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
fn send() -> Weight {
|
||||
// Minimum execution time: 27_797 nanoseconds.
|
||||
Weight::from_ref_time(28_356_000)
|
||||
.saturating_add(T::DbWeight::get().reads(5))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
fn teleport_assets() -> Weight {
|
||||
// Minimum execution time: 32_656 nanoseconds.
|
||||
Weight::from_ref_time(33_011_000)
|
||||
.saturating_add(T::DbWeight::get().reads(1))
|
||||
}
|
||||
// Storage: Benchmark Override (r:0 w:0)
|
||||
fn reserve_transfer_assets() -> Weight {
|
||||
// Minimum execution time: 18_446_744_073_709_551 nanoseconds.
|
||||
Weight::from_ref_time(18_446_744_073_709_551_000)
|
||||
}
|
||||
// Storage: Benchmark Override (r:0 w:0)
|
||||
fn execute() -> Weight {
|
||||
// Minimum execution time: 18_446_744_073_709_551 nanoseconds.
|
||||
Weight::from_ref_time(18_446_744_073_709_551_000)
|
||||
}
|
||||
// Storage: PolkadotXcm SupportedVersion (r:0 w:1)
|
||||
fn force_xcm_version() -> Weight {
|
||||
// Minimum execution time: 15_101 nanoseconds.
|
||||
Weight::from_ref_time(15_535_000)
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
}
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:0 w:1)
|
||||
fn force_default_xcm_version() -> Weight {
|
||||
// Minimum execution time: 4_700 nanoseconds.
|
||||
Weight::from_ref_time(4_896_000)
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifiers (r:1 w:1)
|
||||
// Storage: PolkadotXcm QueryCounter (r:1 w:1)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
// Storage: PolkadotXcm Queries (r:0 w:1)
|
||||
fn force_subscribe_version_notify() -> Weight {
|
||||
// Minimum execution time: 31_532 nanoseconds.
|
||||
Weight::from_ref_time(32_180_000)
|
||||
.saturating_add(T::DbWeight::get().reads(7))
|
||||
.saturating_add(T::DbWeight::get().writes(5))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifiers (r:1 w:1)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
// Storage: PolkadotXcm Queries (r:0 w:1)
|
||||
fn force_unsubscribe_version_notify() -> Weight {
|
||||
// Minimum execution time: 32_515 nanoseconds.
|
||||
Weight::from_ref_time(33_097_000)
|
||||
.saturating_add(T::DbWeight::get().reads(6))
|
||||
.saturating_add(T::DbWeight::get().writes(4))
|
||||
}
|
||||
// Storage: PolkadotXcm SupportedVersion (r:4 w:2)
|
||||
fn migrate_supported_version() -> Weight {
|
||||
// Minimum execution time: 13_811 nanoseconds.
|
||||
Weight::from_ref_time(14_149_000)
|
||||
.saturating_add(T::DbWeight::get().reads(4))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifiers (r:4 w:2)
|
||||
fn migrate_version_notifiers() -> Weight {
|
||||
// Minimum execution time: 13_708 nanoseconds.
|
||||
Weight::from_ref_time(14_067_000)
|
||||
.saturating_add(T::DbWeight::get().reads(4))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:5 w:0)
|
||||
fn already_notified_target() -> Weight {
|
||||
// Minimum execution time: 15_277 nanoseconds.
|
||||
Weight::from_ref_time(15_626_000)
|
||||
.saturating_add(T::DbWeight::get().reads(5))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:2 w:1)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
fn notify_current_targets() -> Weight {
|
||||
// Minimum execution time: 29_263 nanoseconds.
|
||||
Weight::from_ref_time(29_831_000)
|
||||
.saturating_add(T::DbWeight::get().reads(7))
|
||||
.saturating_add(T::DbWeight::get().writes(3))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:3 w:0)
|
||||
fn notify_target_migration_fail() -> Weight {
|
||||
// Minimum execution time: 7_787 nanoseconds.
|
||||
Weight::from_ref_time(7_858_000)
|
||||
.saturating_add(T::DbWeight::get().reads(3))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:4 w:2)
|
||||
fn migrate_version_notify_targets() -> Weight {
|
||||
// Minimum execution time: 15_252 nanoseconds.
|
||||
Weight::from_ref_time(15_558_000)
|
||||
.saturating_add(T::DbWeight::get().reads(4))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:4 w:2)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
fn migrate_and_notify_old_targets() -> Weight {
|
||||
// Minimum execution time: 35_105 nanoseconds.
|
||||
Weight::from_ref_time(35_719_000)
|
||||
.saturating_add(T::DbWeight::get().reads(9))
|
||||
.saturating_add(T::DbWeight::get().writes(4))
|
||||
}
|
||||
}
|
||||
@@ -21,168 +21,220 @@ use crate::Runtime;
|
||||
use frame_support::weights::Weight;
|
||||
use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight;
|
||||
use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
|
||||
use sp_std::{cmp, prelude::*};
|
||||
use xcm::{
|
||||
latest::{prelude::*, Weight as XCMWeight},
|
||||
DoubleEncoded,
|
||||
};
|
||||
use sp_std::prelude::*;
|
||||
use xcm::{latest::prelude::*, DoubleEncoded};
|
||||
|
||||
trait WeighMultiAssets {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> XCMWeight;
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight;
|
||||
}
|
||||
|
||||
const MAX_ASSETS: u32 = 100;
|
||||
|
||||
impl WeighMultiAssets for MultiAssetFilter {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> XCMWeight {
|
||||
let weight = match self {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
||||
match self {
|
||||
Self::Definite(assets) =>
|
||||
weight.saturating_mul(assets.inner().into_iter().count() as u64),
|
||||
Self::Wild(_) => weight.saturating_mul(MAX_ASSETS as u64),
|
||||
};
|
||||
weight.ref_time()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl WeighMultiAssets for MultiAssets {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> XCMWeight {
|
||||
weight.saturating_mul(self.inner().into_iter().count() as u64).ref_time()
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
||||
weight.saturating_mul(self.inner().into_iter().count() as u64)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BridgeHubRococoXcmWeight<Call>(core::marker::PhantomData<Call>);
|
||||
impl<Call> XcmWeightInfo<Call> for BridgeHubRococoXcmWeight<Call> {
|
||||
fn withdraw_asset(assets: &MultiAssets) -> XCMWeight {
|
||||
fn withdraw_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::withdraw_asset())
|
||||
}
|
||||
// Currently there is no trusted reserve
|
||||
fn reserve_asset_deposited(_assets: &MultiAssets) -> XCMWeight {
|
||||
u64::MAX
|
||||
fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight {
|
||||
// TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974
|
||||
Weight::from_ref_time(1_000_000_000 as u64)
|
||||
}
|
||||
fn receive_teleported_asset(assets: &MultiAssets) -> XCMWeight {
|
||||
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::receive_teleported_asset())
|
||||
}
|
||||
fn query_response(_query_id: &u64, _response: &Response, _max_weight: &u64) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::query_response().ref_time()
|
||||
fn query_response(
|
||||
_query_id: &u64,
|
||||
_response: &Response,
|
||||
_max_weight: &Weight,
|
||||
_querier: &Option<MultiLocation>,
|
||||
) -> Weight {
|
||||
XcmGeneric::<Runtime>::query_response()
|
||||
}
|
||||
fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> XCMWeight {
|
||||
fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::transfer_asset())
|
||||
}
|
||||
fn transfer_reserve_asset(
|
||||
assets: &MultiAssets,
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> XCMWeight {
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::transfer_reserve_asset())
|
||||
}
|
||||
fn transact(
|
||||
_origin_type: &OriginKind,
|
||||
_require_weight_at_most: &u64,
|
||||
_require_weight_at_most: &Weight,
|
||||
_call: &DoubleEncoded<Call>,
|
||||
) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::transact().ref_time()
|
||||
) -> Weight {
|
||||
XcmGeneric::<Runtime>::transact()
|
||||
}
|
||||
fn hrmp_new_channel_open_request(
|
||||
_sender: &u32,
|
||||
_max_message_size: &u32,
|
||||
_max_capacity: &u32,
|
||||
) -> XCMWeight {
|
||||
) -> Weight {
|
||||
// XCM Executor does not currently support HRMP channel operations
|
||||
Weight::MAX.ref_time()
|
||||
Weight::MAX
|
||||
}
|
||||
fn hrmp_channel_accepted(_recipient: &u32) -> XCMWeight {
|
||||
fn hrmp_channel_accepted(_recipient: &u32) -> Weight {
|
||||
// XCM Executor does not currently support HRMP channel operations
|
||||
Weight::MAX.ref_time()
|
||||
Weight::MAX
|
||||
}
|
||||
fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> XCMWeight {
|
||||
fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> Weight {
|
||||
// XCM Executor does not currently support HRMP channel operations
|
||||
Weight::MAX.ref_time()
|
||||
Weight::MAX
|
||||
}
|
||||
fn clear_origin() -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::clear_origin().ref_time()
|
||||
fn clear_origin() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_origin()
|
||||
}
|
||||
fn descend_origin(_who: &InteriorMultiLocation) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::descend_origin().ref_time()
|
||||
fn descend_origin(_who: &InteriorMultiLocation) -> Weight {
|
||||
XcmGeneric::<Runtime>::descend_origin()
|
||||
}
|
||||
fn report_error(
|
||||
_query_id: &QueryId,
|
||||
_dest: &MultiLocation,
|
||||
_max_response_weight: &u64,
|
||||
) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::report_error().ref_time()
|
||||
fn report_error(_query_response_info: &QueryResponseInfo) -> Weight {
|
||||
XcmGeneric::<Runtime>::report_error()
|
||||
}
|
||||
|
||||
fn deposit_asset(
|
||||
assets: &MultiAssetFilter,
|
||||
_max_assets: &u32,
|
||||
_dest: &MultiLocation,
|
||||
) -> XCMWeight {
|
||||
fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight {
|
||||
// Hardcoded till the XCM pallet is fixed
|
||||
let hardcoded_weight = Weight::from_ref_time(1_000_000_000 as u64).ref_time();
|
||||
let hardcoded_weight = Weight::from_ref_time(1_000_000_000 as u64);
|
||||
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_asset());
|
||||
cmp::min(hardcoded_weight, weight)
|
||||
hardcoded_weight.min(weight)
|
||||
}
|
||||
fn deposit_reserve_asset(
|
||||
assets: &MultiAssetFilter,
|
||||
_max_assets: &u32,
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> XCMWeight {
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_reserve_asset())
|
||||
}
|
||||
fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets) -> XCMWeight {
|
||||
Weight::MAX.ref_time()
|
||||
fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn initiate_reserve_withdraw(
|
||||
assets: &MultiAssetFilter,
|
||||
_reserve: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> XCMWeight {
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::initiate_reserve_withdraw())
|
||||
}
|
||||
fn initiate_teleport(
|
||||
assets: &MultiAssetFilter,
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> XCMWeight {
|
||||
) -> Weight {
|
||||
// Hardcoded till the XCM pallet is fixed
|
||||
let hardcoded_weight = Weight::from_ref_time(200_000_000 as u64).ref_time();
|
||||
let hardcoded_weight = Weight::from_ref_time(200_000_000 as u64);
|
||||
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport());
|
||||
cmp::min(hardcoded_weight, weight)
|
||||
hardcoded_weight.min(weight)
|
||||
}
|
||||
fn query_holding(
|
||||
_query_id: &u64,
|
||||
_dest: &MultiLocation,
|
||||
_assets: &MultiAssetFilter,
|
||||
_max_response_weight: &u64,
|
||||
) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::query_holding().ref_time()
|
||||
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
|
||||
XcmGeneric::<Runtime>::report_holding()
|
||||
}
|
||||
fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::buy_execution().ref_time()
|
||||
fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> Weight {
|
||||
XcmGeneric::<Runtime>::buy_execution()
|
||||
}
|
||||
fn refund_surplus() -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::refund_surplus().ref_time()
|
||||
fn refund_surplus() -> Weight {
|
||||
XcmGeneric::<Runtime>::refund_surplus()
|
||||
}
|
||||
fn set_error_handler(_xcm: &Xcm<Call>) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::set_error_handler().ref_time()
|
||||
fn set_error_handler(_xcm: &Xcm<Call>) -> Weight {
|
||||
XcmGeneric::<Runtime>::set_error_handler()
|
||||
}
|
||||
fn set_appendix(_xcm: &Xcm<Call>) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::set_appendix().ref_time()
|
||||
fn set_appendix(_xcm: &Xcm<Call>) -> Weight {
|
||||
XcmGeneric::<Runtime>::set_appendix()
|
||||
}
|
||||
fn clear_error() -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::clear_error().ref_time()
|
||||
fn clear_error() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_error()
|
||||
}
|
||||
fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::claim_asset().ref_time()
|
||||
fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> Weight {
|
||||
XcmGeneric::<Runtime>::claim_asset()
|
||||
}
|
||||
fn trap(_code: &u64) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::trap().ref_time()
|
||||
fn trap(_code: &u64) -> Weight {
|
||||
XcmGeneric::<Runtime>::trap()
|
||||
}
|
||||
fn subscribe_version(_query_id: &QueryId, _max_response_weight: &u64) -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::subscribe_version().ref_time()
|
||||
fn subscribe_version(_query_id: &QueryId, _max_response_weight: &Weight) -> Weight {
|
||||
XcmGeneric::<Runtime>::subscribe_version()
|
||||
}
|
||||
fn unsubscribe_version() -> XCMWeight {
|
||||
XcmGeneric::<Runtime>::unsubscribe_version().ref_time()
|
||||
fn unsubscribe_version() -> Weight {
|
||||
XcmGeneric::<Runtime>::unsubscribe_version()
|
||||
}
|
||||
fn burn_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::burn_asset())
|
||||
}
|
||||
fn expect_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::expect_asset())
|
||||
}
|
||||
fn expect_origin(_origin: &Option<MultiLocation>) -> Weight {
|
||||
XcmGeneric::<Runtime>::expect_origin()
|
||||
}
|
||||
fn expect_error(_error: &Option<(u32, XcmError)>) -> Weight {
|
||||
XcmGeneric::<Runtime>::expect_error()
|
||||
}
|
||||
fn query_pallet(_module_name: &Vec<u8>, _response_info: &QueryResponseInfo) -> Weight {
|
||||
XcmGeneric::<Runtime>::query_pallet()
|
||||
}
|
||||
fn expect_pallet(
|
||||
_index: &u32,
|
||||
_name: &Vec<u8>,
|
||||
_module_name: &Vec<u8>,
|
||||
_crate_major: &u32,
|
||||
_min_crate_minor: &u32,
|
||||
) -> Weight {
|
||||
XcmGeneric::<Runtime>::expect_pallet()
|
||||
}
|
||||
fn report_transact_status(_response_info: &QueryResponseInfo) -> Weight {
|
||||
XcmGeneric::<Runtime>::report_transact_status()
|
||||
}
|
||||
fn clear_transact_status() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_transact_status()
|
||||
}
|
||||
fn universal_origin(_: &Junction) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn set_fees_mode(_: &bool) -> Weight {
|
||||
XcmGeneric::<Runtime>::set_fees_mode()
|
||||
}
|
||||
fn set_topic(_topic: &[u8; 32]) -> Weight {
|
||||
XcmGeneric::<Runtime>::set_topic()
|
||||
}
|
||||
fn clear_topic() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_topic()
|
||||
}
|
||||
fn alias_origin(_: &MultiLocation) -> Weight {
|
||||
// XCM Executor does not currently support alias origin operations
|
||||
Weight::MAX
|
||||
}
|
||||
fn unpaid_execution(_: &WeightLimit, _: &Option<MultiLocation>) -> Weight {
|
||||
XcmGeneric::<Runtime>::unpaid_execution()
|
||||
}
|
||||
}
|
||||
|
||||
+9
-9
@@ -18,8 +18,8 @@
|
||||
//! Autogenerated weights for `pallet_xcm_benchmarks::fungible`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2022-12-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! DATE: 2022-12-22, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
@@ -50,13 +50,13 @@ pub struct WeightInfo<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: System Account (r:1 w:1)
|
||||
pub(crate) fn withdraw_asset() -> Weight {
|
||||
Weight::from_ref_time(27_085_000 as u64)
|
||||
Weight::from_ref_time(27_244_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
// Storage: System Account (r:2 w:2)
|
||||
pub(crate) fn transfer_asset() -> Weight {
|
||||
Weight::from_ref_time(37_130_000 as u64)
|
||||
Weight::from_ref_time(38_254_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
@@ -68,16 +68,16 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn transfer_reserve_asset() -> Weight {
|
||||
Weight::from_ref_time(54_004_000 as u64)
|
||||
Weight::from_ref_time(55_608_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(8 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(4 as u64))
|
||||
}
|
||||
pub(crate) fn receive_teleported_asset() -> Weight {
|
||||
Weight::from_ref_time(6_208_000 as u64)
|
||||
Weight::from_ref_time(7_053_000 as u64)
|
||||
}
|
||||
// Storage: System Account (r:1 w:1)
|
||||
pub(crate) fn deposit_asset() -> Weight {
|
||||
Weight::from_ref_time(29_191_000 as u64)
|
||||
Weight::from_ref_time(29_030_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
@@ -89,7 +89,7 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn deposit_reserve_asset() -> Weight {
|
||||
Weight::from_ref_time(48_966_000 as u64)
|
||||
Weight::from_ref_time(48_233_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(7 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as u64))
|
||||
}
|
||||
@@ -100,7 +100,7 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn initiate_teleport() -> Weight {
|
||||
Weight::from_ref_time(23_337_000 as u64)
|
||||
Weight::from_ref_time(24_691_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
|
||||
+73
-20
@@ -18,8 +18,8 @@
|
||||
//! Autogenerated weights for `pallet_xcm_benchmarks::generic`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2022-12-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! DATE: 2022-12-22, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
@@ -54,58 +54,59 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn query_holding() -> Weight {
|
||||
Weight::from_ref_time(23_077_000 as u64)
|
||||
pub(crate) fn report_holding() -> Weight {
|
||||
Weight::from_ref_time(27_691_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
pub(crate) fn buy_execution() -> Weight {
|
||||
Weight::from_ref_time(5_595_000 as u64)
|
||||
Weight::from_ref_time(5_927_000 as u64)
|
||||
}
|
||||
// Storage: PolkadotXcm Queries (r:1 w:0)
|
||||
pub(crate) fn query_response() -> Weight {
|
||||
Weight::from_ref_time(16_593_000 as u64)
|
||||
Weight::from_ref_time(17_594_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
}
|
||||
pub(crate) fn transact() -> Weight {
|
||||
Weight::from_ref_time(19_522_000 as u64)
|
||||
Weight::from_ref_time(20_743_000 as u64)
|
||||
}
|
||||
pub(crate) fn refund_surplus() -> Weight {
|
||||
Weight::from_ref_time(5_612_000 as u64)
|
||||
Weight::from_ref_time(5_960_000 as u64)
|
||||
}
|
||||
pub(crate) fn set_error_handler() -> Weight {
|
||||
Weight::from_ref_time(5_455_000 as u64)
|
||||
Weight::from_ref_time(5_857_000 as u64)
|
||||
}
|
||||
pub(crate) fn set_appendix() -> Weight {
|
||||
Weight::from_ref_time(5_404_000 as u64)
|
||||
Weight::from_ref_time(5_819_000 as u64)
|
||||
}
|
||||
pub(crate) fn clear_error() -> Weight {
|
||||
Weight::from_ref_time(5_402_000 as u64)
|
||||
Weight::from_ref_time(5_826_000 as u64)
|
||||
}
|
||||
pub(crate) fn descend_origin() -> Weight {
|
||||
Weight::from_ref_time(6_725_000 as u64)
|
||||
Weight::from_ref_time(6_641_000 as u64)
|
||||
}
|
||||
pub(crate) fn clear_origin() -> Weight {
|
||||
Weight::from_ref_time(5_417_000 as u64)
|
||||
Weight::from_ref_time(5_754_000 as u64)
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn report_error() -> Weight {
|
||||
Weight::from_ref_time(14_868_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(5 as u64))
|
||||
Weight::from_ref_time(21_742_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
// Storage: PolkadotXcm AssetTraps (r:1 w:1)
|
||||
pub(crate) fn claim_asset() -> Weight {
|
||||
Weight::from_ref_time(20_838_000 as u64)
|
||||
Weight::from_ref_time(20_833_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
pub(crate) fn trap() -> Weight {
|
||||
Weight::from_ref_time(5_354_000 as u64)
|
||||
Weight::from_ref_time(5_773_000 as u64)
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:1 w:1)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
@@ -114,13 +115,13 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn subscribe_version() -> Weight {
|
||||
Weight::from_ref_time(17_989_000 as u64)
|
||||
Weight::from_ref_time(28_365_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as u64))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:0 w:1)
|
||||
pub(crate) fn unsubscribe_version() -> Weight {
|
||||
Weight::from_ref_time(7_304_000 as u64)
|
||||
Weight::from_ref_time(7_961_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
@@ -130,8 +131,60 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn initiate_reserve_withdraw() -> Weight {
|
||||
Weight::from_ref_time(22_875_000 as u64)
|
||||
Weight::from_ref_time(24_970_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
pub(crate) fn burn_asset() -> Weight {
|
||||
Weight::from_ref_time(7_400_000 as u64)
|
||||
}
|
||||
pub(crate) fn expect_asset() -> Weight {
|
||||
Weight::from_ref_time(6_018_000 as u64)
|
||||
}
|
||||
pub(crate) fn expect_origin() -> Weight {
|
||||
Weight::from_ref_time(5_862_000 as u64)
|
||||
}
|
||||
pub(crate) fn expect_error() -> Weight {
|
||||
Weight::from_ref_time(5_857_000 as u64)
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn query_pallet() -> Weight {
|
||||
Weight::from_ref_time(24_420_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
pub(crate) fn expect_pallet() -> Weight {
|
||||
Weight::from_ref_time(7_212_000 as u64)
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
pub(crate) fn report_transact_status() -> Weight {
|
||||
Weight::from_ref_time(22_227_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
pub(crate) fn clear_transact_status() -> Weight {
|
||||
Weight::from_ref_time(5_890_000 as u64)
|
||||
}
|
||||
pub(crate) fn set_topic() -> Weight {
|
||||
Weight::from_ref_time(5_684_000 as u64)
|
||||
}
|
||||
pub(crate) fn clear_topic() -> Weight {
|
||||
Weight::from_ref_time(5_763_000 as u64)
|
||||
}
|
||||
pub(crate) fn set_fees_mode() -> Weight {
|
||||
Weight::from_ref_time(5_812_000 as u64)
|
||||
}
|
||||
pub(crate) fn unpaid_execution() -> Weight {
|
||||
Weight::from_ref_time(6_043_000 as u64)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use super::{
|
||||
AccountId, Balances, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall,
|
||||
RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
|
||||
AccountId, AllPalletsWithSystem, Balances, ParachainInfo, ParachainSystem, PolkadotXcm,
|
||||
Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
|
||||
};
|
||||
use frame_support::{
|
||||
match_types, parameter_types,
|
||||
traits::{Everything, Nothing},
|
||||
traits::{ConstU32, Contains, Everything, Nothing},
|
||||
};
|
||||
use pallet_xcm::XcmPassthrough;
|
||||
use parachains_common::xcm_config::{
|
||||
@@ -30,21 +30,23 @@ use polkadot_parachain::primitives::Sibling;
|
||||
use polkadot_runtime_common::impls::ToAuthor;
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
||||
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin,
|
||||
IsConcrete, LocationInverter, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
|
||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
||||
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
|
||||
WeightInfoBounds,
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin,
|
||||
IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
|
||||
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
|
||||
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds,
|
||||
WithComputedOrigin,
|
||||
};
|
||||
use xcm_executor::XcmExecutor;
|
||||
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
|
||||
|
||||
parameter_types! {
|
||||
pub const RelayLocation: MultiLocation = MultiLocation::parent();
|
||||
pub const RelayNetwork: NetworkId = NetworkId::Any;
|
||||
pub const RelayNetwork: Option<NetworkId> = Some(NetworkId::Rococo);
|
||||
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
||||
pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
|
||||
pub UniversalLocation: InteriorMultiLocation =
|
||||
X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into()));
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
pub const MaxAssetsIntoHolding: u32 = 64;
|
||||
}
|
||||
|
||||
/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
|
||||
@@ -108,19 +110,67 @@ match_types! {
|
||||
};
|
||||
}
|
||||
|
||||
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
|
||||
/// account for proof size weights.
|
||||
///
|
||||
/// Calls that are allowed through this filter must:
|
||||
/// 1. Have a fixed weight;
|
||||
/// 2. Cannot lead to another call being made;
|
||||
/// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters.
|
||||
pub struct SafeCallFilter;
|
||||
impl Contains<RuntimeCall> for SafeCallFilter {
|
||||
fn contains(call: &RuntimeCall) -> bool {
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
{
|
||||
if matches!(call, RuntimeCall::System(frame_system::Call::remark_with_event { .. })) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
match call {
|
||||
RuntimeCall::System(
|
||||
frame_system::Call::set_heap_pages { .. } |
|
||||
frame_system::Call::set_code { .. } |
|
||||
frame_system::Call::set_code_without_checks { .. } |
|
||||
frame_system::Call::kill_prefix { .. },
|
||||
) |
|
||||
RuntimeCall::ParachainSystem(..) |
|
||||
RuntimeCall::Timestamp(..) |
|
||||
RuntimeCall::Balances(..) |
|
||||
RuntimeCall::CollatorSelection(
|
||||
pallet_collator_selection::Call::set_desired_candidates { .. } |
|
||||
pallet_collator_selection::Call::set_candidacy_bond { .. } |
|
||||
pallet_collator_selection::Call::register_as_candidate { .. } |
|
||||
pallet_collator_selection::Call::leave_intent { .. },
|
||||
) |
|
||||
RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
|
||||
RuntimeCall::XcmpQueue(..) |
|
||||
RuntimeCall::DmpQueue(..) |
|
||||
RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub type Barrier = DenyThenTry<
|
||||
DenyReserveTransferToRelayChain,
|
||||
(
|
||||
// Allow local users to buy weight credit.
|
||||
TakeWeightCredit,
|
||||
// Parent and its exec plurality get free execution.
|
||||
AllowUnpaidExecutionFrom<ParentOrParentsExecutivePlurality>,
|
||||
// Expected responses are OK.
|
||||
AllowKnownQueryResponses<PolkadotXcm>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<ParentOrSiblings>,
|
||||
// Allow anything to pay for execution.
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
WithComputedOrigin<
|
||||
(
|
||||
// Allow anything to pay for execution.
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
// Parent and its exec plurality get free execution.
|
||||
AllowExplicitUnpaidExecutionFrom<ParentOrParentsExecutivePlurality>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<ParentOrSiblings>,
|
||||
),
|
||||
UniversalLocation,
|
||||
ConstU32<8>,
|
||||
>,
|
||||
),
|
||||
>;
|
||||
|
||||
@@ -135,7 +185,7 @@ impl xcm_executor::Config for XcmConfig {
|
||||
type IsReserve = ();
|
||||
/// Only allow teleportation of NativeToken of relay chain.
|
||||
type IsTeleporter = ConcreteNativeAssetFrom<RelayLocation>;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type UniversalLocation = UniversalLocation;
|
||||
type Barrier = Barrier;
|
||||
type Weigher = WeightInfoBounds<
|
||||
crate::weights::xcm::BridgeHubRococoXcmWeight<RuntimeCall>,
|
||||
@@ -148,6 +198,15 @@ impl xcm_executor::Config for XcmConfig {
|
||||
type AssetTrap = PolkadotXcm;
|
||||
type AssetClaims = PolkadotXcm;
|
||||
type SubscriptionService = PolkadotXcm;
|
||||
type PalletInstancesInfo = AllPalletsWithSystem;
|
||||
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
|
||||
type AssetLocker = ();
|
||||
type AssetExchanger = ();
|
||||
type FeeManager = ();
|
||||
type MessageExporter = ();
|
||||
type UniversalAliases = Nothing;
|
||||
type CallDispatcher = WithOriginFilter<SafeCallFilter>;
|
||||
type SafeCallFilter = SafeCallFilter;
|
||||
}
|
||||
|
||||
/// Converts a local signed origin into an XCM multilocation.
|
||||
@@ -158,11 +217,16 @@ pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, R
|
||||
/// queues.
|
||||
pub type XcmRouter = (
|
||||
// Two routers - use UMP to communicate with the relay chain:
|
||||
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm>,
|
||||
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>,
|
||||
// ..and XCMP to communicate with the sibling chains.
|
||||
XcmpQueue,
|
||||
);
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
parameter_types! {
|
||||
pub ReachableDest: Option<MultiLocation> = Some(Parent.into());
|
||||
}
|
||||
|
||||
impl pallet_xcm::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
// We want to disallow users sending (arbitrary) XCMs from this chain.
|
||||
@@ -180,11 +244,19 @@ impl pallet_xcm::Config for Runtime {
|
||||
RuntimeCall,
|
||||
MaxInstructions,
|
||||
>;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type UniversalLocation = UniversalLocation;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
|
||||
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
|
||||
type Currency = Balances;
|
||||
type CurrencyMatcher = ();
|
||||
type TrustedLockers = ();
|
||||
type SovereignAccountOf = LocationToAccountId;
|
||||
type MaxLockers = ConstU32<8>;
|
||||
type WeightInfo = crate::weights::pallet_xcm::WeightInfo<Runtime>;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type ReachableDest = ReachableDest;
|
||||
}
|
||||
|
||||
impl cumulus_pallet_xcm::Config for Runtime {
|
||||
|
||||
@@ -21,7 +21,7 @@ use frame_support::{
|
||||
};
|
||||
use pallet_alliance::{ProposalIndex, ProposalProvider};
|
||||
use sp_std::{marker::PhantomData, prelude::*};
|
||||
use xcm::latest::{Fungibility, Junction, NetworkId, Parent};
|
||||
use xcm::latest::{Fungibility, Junction, Parent};
|
||||
|
||||
type AccountIdOf<T> = <T as frame_system::Config>::AccountId;
|
||||
|
||||
@@ -65,8 +65,8 @@ where
|
||||
<T as frame_system::Config>::RuntimeOrigin::signed(temp_account.into()),
|
||||
Box::new(Parent.into()),
|
||||
Box::new(
|
||||
Junction::AccountId32 { network: NetworkId::Any, id: treasury_acc.into() }
|
||||
.into()
|
||||
Junction::AccountId32 { network: None, id: treasury_acc.into() }
|
||||
.into_location()
|
||||
.into(),
|
||||
),
|
||||
Box::new((Parent, imbalance).into()),
|
||||
|
||||
@@ -371,6 +371,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
|
||||
type ControllerOrigin = RootOrExecutiveSimpleMajority;
|
||||
type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
|
||||
type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
|
||||
type PriceForSiblingDelivery = ();
|
||||
}
|
||||
|
||||
impl cumulus_pallet_dmp_queue::Config for Runtime {
|
||||
@@ -586,6 +587,7 @@ mod benches {
|
||||
[cumulus_pallet_xcmp_queue, XcmpQueue]
|
||||
[pallet_alliance, Alliance]
|
||||
[pallet_collective, AllianceMotion]
|
||||
[pallet_xcm, PolkadotXcm]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ pub mod pallet_proxy;
|
||||
pub mod pallet_session;
|
||||
pub mod pallet_timestamp;
|
||||
pub mod pallet_utility;
|
||||
pub mod pallet_xcm;
|
||||
pub mod paritydb_weights;
|
||||
pub mod rocksdb_weights;
|
||||
|
||||
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
// Copyright 2021 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Cumulus.
|
||||
|
||||
// Cumulus is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Cumulus is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Autogenerated weights for `pallet_xcm`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2022-12-22, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("collectives-polkadot-dev"), DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// /home/benchbot/cargo_target_dir/production/polkadot-parachain
|
||||
// benchmark
|
||||
// pallet
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --extrinsic=*
|
||||
// --execution=wasm
|
||||
// --wasm-execution=compiled
|
||||
// --heap-pages=4096
|
||||
// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json
|
||||
// --pallet=pallet_xcm
|
||||
// --chain=collectives-polkadot-dev
|
||||
// --header=./file_header.txt
|
||||
// --output=./parachains/runtimes/collectives/collectives-polkadot/src/weights/
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use frame_support::{traits::Get, weights::Weight};
|
||||
use sp_std::marker::PhantomData;
|
||||
|
||||
/// Weight functions for `pallet_xcm`.
|
||||
pub struct WeightInfo<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
fn send() -> Weight {
|
||||
// Minimum execution time: 27_016 nanoseconds.
|
||||
Weight::from_ref_time(27_587_000)
|
||||
.saturating_add(T::DbWeight::get().reads(5))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
}
|
||||
// Storage: ParachainInfo ParachainId (r:1 w:0)
|
||||
fn teleport_assets() -> Weight {
|
||||
// Minimum execution time: 33_807 nanoseconds.
|
||||
Weight::from_ref_time(34_960_000)
|
||||
.saturating_add(T::DbWeight::get().reads(1))
|
||||
}
|
||||
// Storage: Benchmark Override (r:0 w:0)
|
||||
fn reserve_transfer_assets() -> Weight {
|
||||
// Minimum execution time: 18_446_744_073_709_551 nanoseconds.
|
||||
Weight::from_ref_time(18_446_744_073_709_551_000)
|
||||
}
|
||||
// Storage: Benchmark Override (r:0 w:0)
|
||||
fn execute() -> Weight {
|
||||
// Minimum execution time: 18_446_744_073_709_551 nanoseconds.
|
||||
Weight::from_ref_time(18_446_744_073_709_551_000)
|
||||
}
|
||||
// Storage: PolkadotXcm SupportedVersion (r:0 w:1)
|
||||
fn force_xcm_version() -> Weight {
|
||||
// Minimum execution time: 15_322 nanoseconds.
|
||||
Weight::from_ref_time(15_782_000)
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
}
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:0 w:1)
|
||||
fn force_default_xcm_version() -> Weight {
|
||||
// Minimum execution time: 4_390 nanoseconds.
|
||||
Weight::from_ref_time(4_564_000)
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifiers (r:1 w:1)
|
||||
// Storage: PolkadotXcm QueryCounter (r:1 w:1)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
// Storage: PolkadotXcm Queries (r:0 w:1)
|
||||
fn force_subscribe_version_notify() -> Weight {
|
||||
// Minimum execution time: 31_238 nanoseconds.
|
||||
Weight::from_ref_time(32_021_000)
|
||||
.saturating_add(T::DbWeight::get().reads(7))
|
||||
.saturating_add(T::DbWeight::get().writes(5))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifiers (r:1 w:1)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
// Storage: PolkadotXcm Queries (r:0 w:1)
|
||||
fn force_unsubscribe_version_notify() -> Weight {
|
||||
// Minimum execution time: 32_459 nanoseconds.
|
||||
Weight::from_ref_time(32_802_000)
|
||||
.saturating_add(T::DbWeight::get().reads(6))
|
||||
.saturating_add(T::DbWeight::get().writes(4))
|
||||
}
|
||||
// Storage: PolkadotXcm SupportedVersion (r:4 w:2)
|
||||
fn migrate_supported_version() -> Weight {
|
||||
// Minimum execution time: 13_433 nanoseconds.
|
||||
Weight::from_ref_time(13_890_000)
|
||||
.saturating_add(T::DbWeight::get().reads(4))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifiers (r:4 w:2)
|
||||
fn migrate_version_notifiers() -> Weight {
|
||||
// Minimum execution time: 13_798 nanoseconds.
|
||||
Weight::from_ref_time(14_104_000)
|
||||
.saturating_add(T::DbWeight::get().reads(4))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:5 w:0)
|
||||
fn already_notified_target() -> Weight {
|
||||
// Minimum execution time: 15_012 nanoseconds.
|
||||
Weight::from_ref_time(15_360_000)
|
||||
.saturating_add(T::DbWeight::get().reads(5))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:2 w:1)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
fn notify_current_targets() -> Weight {
|
||||
// Minimum execution time: 26_911 nanoseconds.
|
||||
Weight::from_ref_time(27_686_000)
|
||||
.saturating_add(T::DbWeight::get().reads(7))
|
||||
.saturating_add(T::DbWeight::get().writes(3))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:3 w:0)
|
||||
fn notify_target_migration_fail() -> Weight {
|
||||
// Minimum execution time: 7_067 nanoseconds.
|
||||
Weight::from_ref_time(7_207_000)
|
||||
.saturating_add(T::DbWeight::get().reads(3))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:4 w:2)
|
||||
fn migrate_version_notify_targets() -> Weight {
|
||||
// Minimum execution time: 13_882 nanoseconds.
|
||||
Weight::from_ref_time(14_067_000)
|
||||
.saturating_add(T::DbWeight::get().reads(4))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
}
|
||||
// Storage: PolkadotXcm VersionNotifyTargets (r:4 w:2)
|
||||
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
|
||||
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
|
||||
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
|
||||
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
|
||||
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
|
||||
fn migrate_and_notify_old_targets() -> Weight {
|
||||
// Minimum execution time: 32_227 nanoseconds.
|
||||
Weight::from_ref_time(33_068_000)
|
||||
.saturating_add(T::DbWeight::get().reads(9))
|
||||
.saturating_add(T::DbWeight::get().writes(4))
|
||||
}
|
||||
}
|
||||
@@ -14,12 +14,13 @@
|
||||
// limitations under the License.
|
||||
|
||||
use super::{
|
||||
AccountId, Balances, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall,
|
||||
RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
|
||||
AccountId, AllPalletsWithSystem, Balances, ParachainInfo, ParachainSystem, PolkadotXcm,
|
||||
Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
|
||||
};
|
||||
use frame_support::{
|
||||
match_types, parameter_types,
|
||||
traits::{Everything, Nothing},
|
||||
traits::{ConstU32, Contains, Everything, Nothing},
|
||||
weights::Weight,
|
||||
};
|
||||
use pallet_xcm::XcmPassthrough;
|
||||
use parachains_common::{
|
||||
@@ -29,21 +30,22 @@ use parachains_common::{
|
||||
use polkadot_parachain::primitives::Sibling;
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
||||
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin,
|
||||
FixedWeightBounds, IsConcrete, LocationInverter, ParentAsSuperuser, ParentIsPreset,
|
||||
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||
UsingComponents,
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin,
|
||||
FixedWeightBounds, IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
|
||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
||||
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
|
||||
WithComputedOrigin,
|
||||
};
|
||||
use xcm_executor::XcmExecutor;
|
||||
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
|
||||
|
||||
parameter_types! {
|
||||
pub const DotLocation: MultiLocation = MultiLocation::parent();
|
||||
pub const RelayNetwork: NetworkId = NetworkId::Polkadot;
|
||||
pub const RelayNetwork: Option<NetworkId> = Some(NetworkId::Polkadot);
|
||||
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
||||
pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
|
||||
pub const Local: MultiLocation = Here.into();
|
||||
pub UniversalLocation: InteriorMultiLocation =
|
||||
X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into()));
|
||||
pub const Local: MultiLocation = Here.into_location();
|
||||
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
|
||||
}
|
||||
|
||||
@@ -99,14 +101,15 @@ pub type XcmOriginToTransactDispatchOrigin = (
|
||||
|
||||
parameter_types! {
|
||||
// One XCM operation is 1_000_000_000 weight - almost certainly a conservative estimate.
|
||||
pub UnitWeightCost: u64 = 1_000_000_000;
|
||||
pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 64 * 1024);
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
pub const MaxAssetsIntoHolding: u32 = 64;
|
||||
}
|
||||
|
||||
match_types! {
|
||||
pub type ParentOrParentsExecutivePlurality: impl Contains<MultiLocation> = {
|
||||
pub type ParentOrParentsPlurality: impl Contains<MultiLocation> = {
|
||||
MultiLocation { parents: 1, interior: Here } |
|
||||
MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Executive, .. }) }
|
||||
MultiLocation { parents: 1, interior: X1(Plurality { .. }) }
|
||||
};
|
||||
pub type ParentOrSiblings: impl Contains<MultiLocation> = {
|
||||
MultiLocation { parents: 1, interior: Here } |
|
||||
@@ -114,19 +117,90 @@ match_types! {
|
||||
};
|
||||
}
|
||||
|
||||
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
|
||||
/// account for proof size weights.
|
||||
///
|
||||
/// Calls that are allowed through this filter must:
|
||||
/// 1. Have a fixed weight;
|
||||
/// 2. Cannot lead to another call being made;
|
||||
/// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters.
|
||||
pub struct SafeCallFilter;
|
||||
impl Contains<RuntimeCall> for SafeCallFilter {
|
||||
fn contains(call: &RuntimeCall) -> bool {
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
{
|
||||
if matches!(call, RuntimeCall::System(frame_system::Call::remark_with_event { .. })) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
match call {
|
||||
RuntimeCall::System(
|
||||
frame_system::Call::set_heap_pages { .. } |
|
||||
frame_system::Call::set_code { .. } |
|
||||
frame_system::Call::set_code_without_checks { .. } |
|
||||
frame_system::Call::kill_prefix { .. },
|
||||
) |
|
||||
RuntimeCall::ParachainSystem(..) |
|
||||
RuntimeCall::Timestamp(..) |
|
||||
RuntimeCall::Balances(..) |
|
||||
RuntimeCall::CollatorSelection(
|
||||
pallet_collator_selection::Call::set_desired_candidates { .. } |
|
||||
pallet_collator_selection::Call::set_candidacy_bond { .. } |
|
||||
pallet_collator_selection::Call::register_as_candidate { .. } |
|
||||
pallet_collator_selection::Call::leave_intent { .. },
|
||||
) |
|
||||
RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
|
||||
RuntimeCall::XcmpQueue(..) |
|
||||
RuntimeCall::DmpQueue(..) |
|
||||
RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) |
|
||||
RuntimeCall::Alliance(
|
||||
pallet_alliance::Call::vote { .. } |
|
||||
pallet_alliance::Call::close_old_weight { .. } |
|
||||
pallet_alliance::Call::disband { .. } |
|
||||
pallet_alliance::Call::set_rule { .. } |
|
||||
pallet_alliance::Call::announce { .. } |
|
||||
pallet_alliance::Call::remove_announcement { .. } |
|
||||
pallet_alliance::Call::join_alliance { .. } |
|
||||
pallet_alliance::Call::nominate_ally { .. } |
|
||||
pallet_alliance::Call::elevate_ally { .. } |
|
||||
pallet_alliance::Call::give_retirement_notice { .. } |
|
||||
pallet_alliance::Call::retire { .. } |
|
||||
pallet_alliance::Call::kick_member { .. } |
|
||||
pallet_alliance::Call::close { .. } |
|
||||
pallet_alliance::Call::abdicate_fellow_status { .. },
|
||||
) |
|
||||
RuntimeCall::AllianceMotion(
|
||||
pallet_collective::Call::vote { .. } |
|
||||
pallet_collective::Call::close_old_weight { .. } |
|
||||
pallet_collective::Call::disapprove_proposal { .. } |
|
||||
pallet_collective::Call::close { .. },
|
||||
) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub type Barrier = DenyThenTry<
|
||||
DenyReserveTransferToRelayChain,
|
||||
(
|
||||
// Allow local users to buy weight credit.
|
||||
TakeWeightCredit,
|
||||
// Parent and its exec plurality get free execution.
|
||||
AllowUnpaidExecutionFrom<ParentOrParentsExecutivePlurality>,
|
||||
// Expected responses are OK.
|
||||
AllowKnownQueryResponses<PolkadotXcm>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<ParentOrSiblings>,
|
||||
// Allow anything to pay for execution.
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
// Allow XCMs with some computed origins to pass through.
|
||||
WithComputedOrigin<
|
||||
(
|
||||
// If the message is one that immediately attemps to pay for execution, then allow it.
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
// Parent and its plurality (i.e. governance bodies) gets free execution.
|
||||
AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<ParentOrSiblings>,
|
||||
),
|
||||
UniversalLocation,
|
||||
ConstU32<8>,
|
||||
>,
|
||||
),
|
||||
>;
|
||||
|
||||
@@ -141,7 +215,7 @@ impl xcm_executor::Config for XcmConfig {
|
||||
type IsReserve = ();
|
||||
/// Only allow teleportation of DOT.
|
||||
type IsTeleporter = ConcreteNativeAssetFrom<DotLocation>;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type UniversalLocation = UniversalLocation;
|
||||
type Barrier = Barrier;
|
||||
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
|
||||
type Trader =
|
||||
@@ -150,6 +224,15 @@ impl xcm_executor::Config for XcmConfig {
|
||||
type AssetTrap = PolkadotXcm;
|
||||
type AssetClaims = PolkadotXcm;
|
||||
type SubscriptionService = PolkadotXcm;
|
||||
type PalletInstancesInfo = AllPalletsWithSystem;
|
||||
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
|
||||
type AssetLocker = ();
|
||||
type AssetExchanger = ();
|
||||
type FeeManager = ();
|
||||
type MessageExporter = ();
|
||||
type UniversalAliases = Nothing;
|
||||
type CallDispatcher = WithOriginFilter<SafeCallFilter>;
|
||||
type SafeCallFilter = SafeCallFilter;
|
||||
}
|
||||
|
||||
/// Converts a local signed origin into an XCM multilocation.
|
||||
@@ -160,11 +243,16 @@ pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, R
|
||||
/// queues.
|
||||
pub type XcmRouter = (
|
||||
// Two routers - use UMP to communicate with the relay chain:
|
||||
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm>,
|
||||
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>,
|
||||
// ..and XCMP to communicate with the sibling chains.
|
||||
XcmpQueue,
|
||||
);
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
parameter_types! {
|
||||
pub ReachableDest: Option<MultiLocation> = Some(Parent.into());
|
||||
}
|
||||
|
||||
impl pallet_xcm::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
// We want to disallow users sending (arbitrary) XCMs from this chain.
|
||||
@@ -178,11 +266,19 @@ impl pallet_xcm::Config for Runtime {
|
||||
type XcmTeleportFilter = Everything;
|
||||
type XcmReserveTransferFilter = Nothing; // This parachain is not meant as a reserve location.
|
||||
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type UniversalLocation = UniversalLocation;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
|
||||
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
|
||||
type Currency = Balances;
|
||||
type CurrencyMatcher = ();
|
||||
type TrustedLockers = ();
|
||||
type SovereignAccountOf = LocationToAccountId;
|
||||
type MaxLockers = ConstU32<8>;
|
||||
type WeightInfo = crate::weights::pallet_xcm::WeightInfo<Runtime>;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type ReachableDest = ReachableDest;
|
||||
}
|
||||
|
||||
impl cumulus_pallet_xcm::Config for Runtime {
|
||||
|
||||
@@ -382,6 +382,7 @@ mod benches {
|
||||
[pallet_timestamp, Timestamp]
|
||||
[pallet_collator_selection, CollatorSelection]
|
||||
[pallet_contracts, Contracts]
|
||||
[pallet_xcm, PolkadotXcm]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,12 +14,13 @@
|
||||
// limitations under the License.
|
||||
|
||||
use super::{
|
||||
AccountId, Balances, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall,
|
||||
RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
|
||||
AccountId, AllPalletsWithSystem, Balances, ParachainInfo, ParachainSystem, PolkadotXcm,
|
||||
Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
|
||||
};
|
||||
use frame_support::{
|
||||
match_types, parameter_types,
|
||||
traits::{EitherOfDiverse, Everything, Nothing},
|
||||
traits::{ConstU32, EitherOfDiverse, Everything, Nothing},
|
||||
weights::Weight,
|
||||
};
|
||||
use frame_system::EnsureRoot;
|
||||
use pallet_xcm::{EnsureXcm, IsMajorityOfBody, XcmPassthrough};
|
||||
@@ -27,22 +28,20 @@ use parachains_common::xcm_config::{DenyReserveTransferToRelayChain, DenyThenTry
|
||||
use polkadot_parachain::primitives::Sibling;
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
||||
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin,
|
||||
FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset, ParentAsSuperuser,
|
||||
ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin,
|
||||
FixedWeightBounds, IsConcrete, NativeAsset, ParentAsSuperuser, ParentIsPreset,
|
||||
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||
UsingComponents,
|
||||
UsingComponents, WithComputedOrigin,
|
||||
};
|
||||
use xcm_executor::XcmExecutor;
|
||||
|
||||
parameter_types! {
|
||||
pub const RelayLocation: MultiLocation = MultiLocation::parent();
|
||||
pub const RelayNetwork: NetworkId = NetworkId::Any;
|
||||
pub const RelayNetwork: Option<NetworkId> = None;
|
||||
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
||||
pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
|
||||
pub const Local: MultiLocation = Here.into();
|
||||
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
|
||||
pub UniversalLocation: InteriorMultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
|
||||
pub const ExecutiveBody: BodyId = BodyId::Executive;
|
||||
}
|
||||
|
||||
@@ -104,14 +103,14 @@ pub type XcmOriginToTransactDispatchOrigin = (
|
||||
|
||||
parameter_types! {
|
||||
// One XCM operation is 1_000_000_000 weight - almost certainly a conservative estimate.
|
||||
pub UnitWeightCost: u64 = 1_000_000_000;
|
||||
pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 64 * 1024);
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
}
|
||||
|
||||
match_types! {
|
||||
pub type ParentOrParentsExecutivePlurality: impl Contains<MultiLocation> = {
|
||||
pub type ParentOrParentsPlurality: impl Contains<MultiLocation> = {
|
||||
MultiLocation { parents: 1, interior: Here } |
|
||||
MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Executive, .. }) }
|
||||
MultiLocation { parents: 1, interior: X1(Plurality { .. }) }
|
||||
};
|
||||
pub type ParentOrSiblings: impl Contains<MultiLocation> = {
|
||||
MultiLocation { parents: 1, interior: Here } |
|
||||
@@ -123,13 +122,21 @@ pub type Barrier = DenyThenTry<
|
||||
DenyReserveTransferToRelayChain,
|
||||
(
|
||||
TakeWeightCredit,
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
// Parent and its exec plurality get free execution
|
||||
AllowUnpaidExecutionFrom<ParentOrParentsExecutivePlurality>,
|
||||
// Expected responses are OK.
|
||||
AllowKnownQueryResponses<PolkadotXcm>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<ParentOrSiblings>,
|
||||
// Allow XCMs with some computed origins to pass through.
|
||||
WithComputedOrigin<
|
||||
(
|
||||
// If the message is one that immediately attemps to pay for execution, then allow it.
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
// Parent and its plurality (i.e. governance bodies) gets free execution.
|
||||
AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<ParentOrSiblings>,
|
||||
),
|
||||
UniversalLocation,
|
||||
ConstU32<8>,
|
||||
>,
|
||||
),
|
||||
>;
|
||||
|
||||
@@ -141,7 +148,7 @@ impl xcm_executor::Config for XcmConfig {
|
||||
type OriginConverter = XcmOriginToTransactDispatchOrigin;
|
||||
type IsReserve = NativeAsset;
|
||||
type IsTeleporter = NativeAsset;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type UniversalLocation = UniversalLocation;
|
||||
type Barrier = Barrier;
|
||||
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
|
||||
type Trader = UsingComponents<WeightToFee, RelayLocation, AccountId, Balances, ()>;
|
||||
@@ -149,6 +156,15 @@ impl xcm_executor::Config for XcmConfig {
|
||||
type AssetTrap = PolkadotXcm;
|
||||
type AssetClaims = PolkadotXcm;
|
||||
type SubscriptionService = PolkadotXcm;
|
||||
type PalletInstancesInfo = AllPalletsWithSystem;
|
||||
type MaxAssetsIntoHolding = ConstU32<8>;
|
||||
type AssetLocker = ();
|
||||
type AssetExchanger = ();
|
||||
type FeeManager = ();
|
||||
type MessageExporter = ();
|
||||
type UniversalAliases = Nothing;
|
||||
type CallDispatcher = RuntimeCall;
|
||||
type SafeCallFilter = Everything;
|
||||
}
|
||||
|
||||
/// Converts a local signed origin into an XCM multilocation.
|
||||
@@ -159,11 +175,16 @@ pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, R
|
||||
/// queues.
|
||||
pub type XcmRouter = (
|
||||
// Two routers - use UMP to communicate with the relay chain:
|
||||
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm>,
|
||||
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>,
|
||||
// ..and XCMP to communicate with the sibling chains.
|
||||
XcmpQueue,
|
||||
);
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
parameter_types! {
|
||||
pub ReachableDest: Option<MultiLocation> = Some(Parent.into());
|
||||
}
|
||||
|
||||
impl pallet_xcm::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
// We want to disallow users sending (arbitrary) XCMs from this chain.
|
||||
@@ -177,11 +198,20 @@ impl pallet_xcm::Config for Runtime {
|
||||
type XcmTeleportFilter = Everything;
|
||||
type XcmReserveTransferFilter = Everything;
|
||||
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type UniversalLocation = UniversalLocation;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
|
||||
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
|
||||
type Currency = Balances;
|
||||
type CurrencyMatcher = ();
|
||||
type TrustedLockers = ();
|
||||
type SovereignAccountOf = LocationToAccountId;
|
||||
type MaxLockers = ConstU32<8>;
|
||||
// FIXME: Replace with benchmarked weight info
|
||||
type WeightInfo = pallet_xcm::TestWeightInfo;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type ReachableDest = ReachableDest;
|
||||
}
|
||||
|
||||
impl cumulus_pallet_xcm::Config for Runtime {
|
||||
@@ -201,6 +231,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
|
||||
>;
|
||||
type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
|
||||
type WeightInfo = cumulus_pallet_xcmp_queue::weights::SubstrateWeight<Runtime>;
|
||||
type PriceForSiblingDelivery = ();
|
||||
}
|
||||
|
||||
impl cumulus_pallet_dmp_queue::Config for Runtime {
|
||||
|
||||
@@ -13,18 +13,25 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use super::{AccountId, ParachainInfo, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin};
|
||||
use frame_support::{match_types, parameter_types};
|
||||
use super::{
|
||||
AccountId, AllPalletsWithSystem, ParachainInfo, Runtime, RuntimeCall, RuntimeEvent,
|
||||
RuntimeOrigin,
|
||||
};
|
||||
use frame_support::{
|
||||
match_types, parameter_types,
|
||||
traits::{Everything, Nothing},
|
||||
weights::Weight,
|
||||
};
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AllowUnpaidExecutionFrom, FixedWeightBounds, LocationInverter, ParentAsSuperuser,
|
||||
ParentIsPreset, SovereignSignedViaLocation,
|
||||
AllowExplicitUnpaidExecutionFrom, FixedWeightBounds, ParentAsSuperuser, ParentIsPreset,
|
||||
SovereignSignedViaLocation,
|
||||
};
|
||||
|
||||
parameter_types! {
|
||||
pub const RococoLocation: MultiLocation = MultiLocation::parent();
|
||||
pub const RococoNetwork: NetworkId = NetworkId::Polkadot;
|
||||
pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
|
||||
pub const RococoNetwork: Option<NetworkId> = Some(NetworkId::Rococo);
|
||||
pub UniversalLocation: InteriorMultiLocation = X1(Parachain(ParachainInfo::parachain_id().into()));
|
||||
}
|
||||
|
||||
/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,
|
||||
@@ -46,8 +53,9 @@ match_types! {
|
||||
|
||||
parameter_types! {
|
||||
// One XCM operation is 1_000_000_000 weight - almost certainly a conservative estimate.
|
||||
pub UnitWeightCost: u64 = 1_000_000_000;
|
||||
pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 64 * 1024);
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
pub const MaxAssetsIntoHolding: u32 = 64;
|
||||
}
|
||||
|
||||
pub struct XcmConfig;
|
||||
@@ -58,14 +66,23 @@ impl xcm_executor::Config for XcmConfig {
|
||||
type OriginConverter = XcmOriginToTransactDispatchOrigin;
|
||||
type IsReserve = (); // balances not supported
|
||||
type IsTeleporter = (); // balances not supported
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type Barrier = AllowUnpaidExecutionFrom<JustTheParent>;
|
||||
type UniversalLocation = UniversalLocation;
|
||||
type Barrier = AllowExplicitUnpaidExecutionFrom<JustTheParent>;
|
||||
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>; // balances not supported
|
||||
type Trader = (); // balances not supported
|
||||
type ResponseHandler = (); // Don't handle responses for now.
|
||||
type AssetTrap = (); // don't trap for now
|
||||
type AssetClaims = (); // don't claim for now
|
||||
type SubscriptionService = (); // don't handle subscriptions for now
|
||||
type PalletInstancesInfo = AllPalletsWithSystem;
|
||||
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
|
||||
type AssetLocker = ();
|
||||
type AssetExchanger = ();
|
||||
type FeeManager = ();
|
||||
type MessageExporter = ();
|
||||
type UniversalAliases = Nothing;
|
||||
type CallDispatcher = RuntimeCall;
|
||||
type SafeCallFilter = Everything;
|
||||
}
|
||||
|
||||
impl cumulus_pallet_xcm::Config for Runtime {
|
||||
|
||||
@@ -440,6 +440,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
|
||||
type ControllerOrigin = EnsureRoot<AccountId>;
|
||||
type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
|
||||
type WeightInfo = ();
|
||||
type PriceForSiblingDelivery = ();
|
||||
}
|
||||
|
||||
impl cumulus_pallet_dmp_queue::Config for Runtime {
|
||||
|
||||
@@ -22,17 +22,18 @@
|
||||
//! with statemine as the reserve. At present no derivative tokens are minted on receipt of a
|
||||
//! ReserveAssetTransferDeposited message but that will but the intension will be to support this soon.
|
||||
use super::{
|
||||
AccountId, AssetId as AssetIdPalletAssets, Assets, Balance, Balances, ParachainInfo,
|
||||
ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee,
|
||||
XcmpQueue,
|
||||
AccountId, AllPalletsWithSystem, AssetId as AssetIdPalletAssets, Assets, Balance, Balances,
|
||||
ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin,
|
||||
WeightToFee, XcmpQueue,
|
||||
};
|
||||
use core::marker::PhantomData;
|
||||
use frame_support::{
|
||||
match_types, parameter_types,
|
||||
traits::{
|
||||
fungibles::{self, Balanced, CreditOf},
|
||||
Contains, Everything, Get, Nothing,
|
||||
ConstU32, Contains, ContainsPair, Everything, Get, Nothing,
|
||||
},
|
||||
weights::Weight,
|
||||
};
|
||||
use pallet_asset_tx_payment::HandleCredit;
|
||||
use pallet_xcm::XcmPassthrough;
|
||||
@@ -42,24 +43,21 @@ use polkadot_runtime_common::impls::ToAuthor;
|
||||
use sp_runtime::traits::Zero;
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
||||
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, AsPrefixedGeneralIndex,
|
||||
ConvertedConcreteAssetId, CurrencyAdapter, EnsureXcmOrigin, FixedWeightBounds,
|
||||
FungiblesAdapter, IsConcrete, LocationInverter, NativeAsset, ParentIsPreset,
|
||||
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||
UsingComponents,
|
||||
};
|
||||
use xcm_executor::{
|
||||
traits::{FilterAssetLocation, JustTry},
|
||||
XcmExecutor,
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
||||
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AsPrefixedGeneralIndex,
|
||||
ConvertedConcreteId, CurrencyAdapter, EnsureXcmOrigin, FixedWeightBounds, FungiblesAdapter,
|
||||
IsConcrete, LocalMint, NativeAsset, ParentIsPreset, RelayChainAsNative,
|
||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
||||
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
|
||||
WithComputedOrigin,
|
||||
};
|
||||
use xcm_executor::{traits::JustTry, XcmExecutor};
|
||||
|
||||
parameter_types! {
|
||||
pub const RelayLocation: MultiLocation = MultiLocation::parent();
|
||||
pub const RelayNetwork: NetworkId = NetworkId::Any;
|
||||
pub const RelayNetwork: Option<NetworkId> = None;
|
||||
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
||||
pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
|
||||
pub UniversalLocation: InteriorMultiLocation = X1(Parachain(ParachainInfo::parachain_id().into()));
|
||||
}
|
||||
|
||||
/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
|
||||
@@ -93,7 +91,7 @@ pub type FungiblesTransactor = FungiblesAdapter<
|
||||
// Use this fungibles implementation:
|
||||
Assets,
|
||||
// Use this currency when it is a fungible asset matching the given location or name:
|
||||
ConvertedConcreteAssetId<
|
||||
ConvertedConcreteId<
|
||||
AssetIdPalletAssets,
|
||||
Balance,
|
||||
AsPrefixedGeneralIndex<CommonGoodAssetsPalletLocation, AssetIdPalletAssets, JustTry>,
|
||||
@@ -105,7 +103,7 @@ pub type FungiblesTransactor = FungiblesAdapter<
|
||||
AccountId,
|
||||
// We only want to allow teleports of known assets. We use non-zero issuance as an indication
|
||||
// that this asset is known.
|
||||
NonZeroIssuance<AccountId, Assets>,
|
||||
LocalMint<NonZeroIssuance<AccountId, Assets>>,
|
||||
// The account to use for tracking teleports.
|
||||
CheckingAccount,
|
||||
>;
|
||||
@@ -136,8 +134,9 @@ pub type XcmOriginToTransactDispatchOrigin = (
|
||||
|
||||
parameter_types! {
|
||||
// One XCM operation is 1_000_000_000 weight - almost certainly a conservative estimate.
|
||||
pub UnitWeightCost: u64 = 1_000_000_000;
|
||||
pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 64 * 1024);
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
pub const MaxAssetsIntoHolding: u32 = 64;
|
||||
}
|
||||
|
||||
match_types! {
|
||||
@@ -154,15 +153,24 @@ pub type Barrier = DenyThenTry<
|
||||
DenyReserveTransferToRelayChain,
|
||||
(
|
||||
TakeWeightCredit,
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
// Parent and its exec plurality get free execution
|
||||
AllowUnpaidExecutionFrom<ParentOrParentsExecutivePlurality>,
|
||||
// Assets Common Good parachain gets free execution
|
||||
AllowUnpaidExecutionFrom<CommonGoodAssetsParachain>,
|
||||
// Expected responses are OK.
|
||||
AllowKnownQueryResponses<PolkadotXcm>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<Everything>,
|
||||
// Allow XCMs with some computed origins to pass through.
|
||||
WithComputedOrigin<
|
||||
(
|
||||
// If the message is one that immediately attemps to pay for execution, then allow it.
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
// Common Good Assets parachain, parent and its exec plurality get free execution
|
||||
AllowExplicitUnpaidExecutionFrom<(
|
||||
CommonGoodAssetsParachain,
|
||||
ParentOrParentsExecutivePlurality,
|
||||
)>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<Everything>,
|
||||
),
|
||||
UniversalLocation,
|
||||
ConstU32<8>,
|
||||
>,
|
||||
),
|
||||
>;
|
||||
|
||||
@@ -171,8 +179,8 @@ pub type AccountIdOf<R> = <R as frame_system::Config>::AccountId;
|
||||
|
||||
/// Asset filter that allows all assets from a certain location.
|
||||
pub struct AssetsFrom<T>(PhantomData<T>);
|
||||
impl<T: Get<MultiLocation>> FilterAssetLocation for AssetsFrom<T> {
|
||||
fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool {
|
||||
impl<T: Get<MultiLocation>> ContainsPair<MultiAsset, MultiLocation> for AssetsFrom<T> {
|
||||
fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool {
|
||||
let loc = T::get();
|
||||
&loc == origin &&
|
||||
matches!(asset, MultiAsset { id: AssetId::Concrete(asset_loc), fun: Fungible(_a) }
|
||||
@@ -234,8 +242,8 @@ impl Reserve for MultiAsset {
|
||||
/// A `FilterAssetLocation` implementation. Filters multi native assets whose
|
||||
/// reserve is same with `origin`.
|
||||
pub struct MultiNativeAsset;
|
||||
impl FilterAssetLocation for MultiNativeAsset {
|
||||
fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool {
|
||||
impl ContainsPair<MultiAsset, MultiLocation> for MultiNativeAsset {
|
||||
fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool {
|
||||
if let Some(ref reserve) = asset.reserve() {
|
||||
if reserve == origin {
|
||||
return true
|
||||
@@ -265,7 +273,7 @@ impl xcm_executor::Config for XcmConfig {
|
||||
type OriginConverter = XcmOriginToTransactDispatchOrigin;
|
||||
type IsReserve = MultiNativeAsset; // TODO: maybe needed to be replaced by Reserves
|
||||
type IsTeleporter = NativeAsset;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type UniversalLocation = UniversalLocation;
|
||||
type Barrier = Barrier;
|
||||
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
|
||||
type Trader =
|
||||
@@ -274,6 +282,15 @@ impl xcm_executor::Config for XcmConfig {
|
||||
type AssetTrap = PolkadotXcm;
|
||||
type AssetClaims = PolkadotXcm;
|
||||
type SubscriptionService = PolkadotXcm;
|
||||
type PalletInstancesInfo = AllPalletsWithSystem;
|
||||
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
|
||||
type AssetLocker = ();
|
||||
type AssetExchanger = ();
|
||||
type FeeManager = ();
|
||||
type MessageExporter = ();
|
||||
type UniversalAliases = Nothing;
|
||||
type CallDispatcher = RuntimeCall;
|
||||
type SafeCallFilter = Everything;
|
||||
}
|
||||
|
||||
/// No local origins on this chain are allowed to dispatch XCM sends/executions.
|
||||
@@ -283,11 +300,16 @@ pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, R
|
||||
/// queues.
|
||||
pub type XcmRouter = (
|
||||
// Two routers - use UMP to communicate with the relay chain:
|
||||
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm>,
|
||||
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>,
|
||||
// ..and XCMP to communicate with the sibling chains.
|
||||
XcmpQueue,
|
||||
);
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
parameter_types! {
|
||||
pub ReachableDest: Option<MultiLocation> = Some(Parent.into());
|
||||
}
|
||||
|
||||
impl pallet_xcm::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type SendXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
|
||||
@@ -300,13 +322,21 @@ impl pallet_xcm::Config for Runtime {
|
||||
type XcmTeleportFilter = Everything;
|
||||
type XcmReserveTransferFilter = Everything;
|
||||
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type UniversalLocation = UniversalLocation;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
|
||||
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
|
||||
// ^ Override for AdvertisedXcmVersion default
|
||||
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
|
||||
type Currency = Balances;
|
||||
type CurrencyMatcher = ();
|
||||
type TrustedLockers = ();
|
||||
type SovereignAccountOf = LocationToAccountId;
|
||||
type MaxLockers = ConstU32<8>;
|
||||
type WeightInfo = pallet_xcm::TestWeightInfo;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type ReachableDest = ReachableDest;
|
||||
}
|
||||
|
||||
impl cumulus_pallet_xcm::Config for Runtime {
|
||||
|
||||
@@ -103,4 +103,5 @@ std = [
|
||||
runtime-benchmarks = [
|
||||
"frame-benchmarking/runtime-benchmarks",
|
||||
"pallet-assets/runtime-benchmarks",
|
||||
"pallet-xcm/runtime-benchmarks",
|
||||
]
|
||||
|
||||
@@ -43,7 +43,7 @@ pub use frame_support::{
|
||||
match_types, parameter_types,
|
||||
traits::{
|
||||
AsEnsureOriginWithArg, ConstU32, ConstU64, ConstU8, EitherOfDiverse, Everything, IsInVec,
|
||||
Randomness,
|
||||
Nothing, Randomness,
|
||||
},
|
||||
weights::{
|
||||
constants::{
|
||||
@@ -69,8 +69,8 @@ use parachains_common::{
|
||||
AccountId, AssetId, Signature,
|
||||
};
|
||||
use xcm_builder::{
|
||||
AllowKnownQueryResponses, AllowSubscriptionsFrom, AsPrefixedGeneralIndex,
|
||||
ConvertedConcreteAssetId, FungiblesAdapter,
|
||||
AllowKnownQueryResponses, AllowSubscriptionsFrom, AsPrefixedGeneralIndex, ConvertedConcreteId,
|
||||
FungiblesAdapter, LocalMint,
|
||||
};
|
||||
use xcm_executor::traits::JustTry;
|
||||
|
||||
@@ -79,13 +79,13 @@ use pallet_xcm::{EnsureXcm, IsMajorityOfBody, XcmPassthrough};
|
||||
use polkadot_parachain::primitives::Sibling;
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,
|
||||
EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset,
|
||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowTopLevelPaidExecutionFrom,
|
||||
CurrencyAdapter, EnsureXcmOrigin, FixedWeightBounds, IsConcrete, NativeAsset,
|
||||
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
|
||||
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
|
||||
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
|
||||
};
|
||||
use xcm_executor::{Config, XcmExecutor};
|
||||
use xcm_executor::XcmExecutor;
|
||||
|
||||
pub type SessionHandlers = ();
|
||||
|
||||
@@ -276,9 +276,9 @@ impl cumulus_pallet_aura_ext::Config for Runtime {}
|
||||
|
||||
parameter_types! {
|
||||
pub const RocLocation: MultiLocation = MultiLocation::parent();
|
||||
pub const RococoNetwork: NetworkId = NetworkId::Polkadot;
|
||||
pub const RococoNetwork: Option<NetworkId> = Some(NetworkId::Rococo);
|
||||
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
||||
pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
|
||||
pub UniversalLocation: InteriorMultiLocation = X1(Parachain(ParachainInfo::parachain_id().into()));
|
||||
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ pub type FungiblesTransactor = FungiblesAdapter<
|
||||
// Use this fungibles implementation:
|
||||
Assets,
|
||||
// Use this currency when it is a fungible asset matching the given location or name:
|
||||
ConvertedConcreteAssetId<
|
||||
ConvertedConcreteId<
|
||||
AssetId,
|
||||
u64,
|
||||
AsPrefixedGeneralIndex<StatemintAssetsPalletLocation, AssetId, JustTry>,
|
||||
@@ -325,7 +325,7 @@ pub type FungiblesTransactor = FungiblesAdapter<
|
||||
AccountId,
|
||||
// We only want to allow teleports of known assets. We use non-zero issuance as an indication
|
||||
// that this asset is known.
|
||||
NonZeroIssuance<AccountId, Assets>,
|
||||
LocalMint<NonZeroIssuance<AccountId, Assets>>,
|
||||
// The account to use for tracking teleports.
|
||||
CheckingAccount,
|
||||
>;
|
||||
@@ -358,7 +358,7 @@ pub type XcmOriginToTransactDispatchOrigin = (
|
||||
|
||||
parameter_types! {
|
||||
// One XCM operation is 1_000_000_000 weight - almost certainly a conservative estimate.
|
||||
pub UnitWeightCost: u64 = 1_000_000_000;
|
||||
pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 64 * 1024);
|
||||
// One ROC buys 1 second of weight.
|
||||
pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), ROC);
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
@@ -377,9 +377,9 @@ match_types! {
|
||||
pub type Barrier = (
|
||||
TakeWeightCredit,
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,
|
||||
AllowExplicitUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,
|
||||
// ^^^ Parent & its unit plurality gets free execution
|
||||
AllowUnpaidExecutionFrom<Statemint>,
|
||||
AllowExplicitUnpaidExecutionFrom<Statemint>,
|
||||
// Expected responses are OK.
|
||||
AllowKnownQueryResponses<PolkadotXcm>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
@@ -387,6 +387,7 @@ pub type Barrier = (
|
||||
);
|
||||
|
||||
parameter_types! {
|
||||
pub MaxAssetsIntoHolding: u32 = 64;
|
||||
pub StatemintLocation: MultiLocation = MultiLocation::new(1, X1(Parachain(1000)));
|
||||
// ALWAYS ensure that the index in PalletInstance stays up-to-date with
|
||||
// Statemint's Assets pallet index
|
||||
@@ -397,7 +398,7 @@ parameter_types! {
|
||||
pub type Reserves = (NativeAsset, AssetsFrom<StatemintLocation>);
|
||||
|
||||
pub struct XcmConfig;
|
||||
impl Config for XcmConfig {
|
||||
impl xcm_executor::Config for XcmConfig {
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type XcmSender = XcmRouter;
|
||||
// How to withdraw and deposit an asset.
|
||||
@@ -405,7 +406,7 @@ impl Config for XcmConfig {
|
||||
type OriginConverter = XcmOriginToTransactDispatchOrigin;
|
||||
type IsReserve = Reserves;
|
||||
type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of ROC
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type UniversalLocation = UniversalLocation;
|
||||
type Barrier = Barrier;
|
||||
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
|
||||
type Trader = UsingComponents<IdentityFee<Balance>, RocLocation, AccountId, Balances, ()>;
|
||||
@@ -413,6 +414,15 @@ impl Config for XcmConfig {
|
||||
type AssetTrap = PolkadotXcm;
|
||||
type AssetClaims = PolkadotXcm;
|
||||
type SubscriptionService = PolkadotXcm;
|
||||
type PalletInstancesInfo = AllPalletsWithSystem;
|
||||
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
|
||||
type AssetLocker = ();
|
||||
type AssetExchanger = ();
|
||||
type FeeManager = ();
|
||||
type MessageExporter = ();
|
||||
type UniversalAliases = Nothing;
|
||||
type CallDispatcher = RuntimeCall;
|
||||
type SafeCallFilter = Everything;
|
||||
}
|
||||
|
||||
/// Local origins on this chain are allowed to dispatch XCM sends/executions.
|
||||
@@ -422,11 +432,16 @@ pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, R
|
||||
/// queues.
|
||||
pub type XcmRouter = (
|
||||
// Two routers - use UMP to communicate with the relay chain:
|
||||
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,
|
||||
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, (), ()>,
|
||||
// ..and XCMP to communicate with the sibling chains.
|
||||
XcmpQueue,
|
||||
);
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
parameter_types! {
|
||||
pub ReachableDest: Option<MultiLocation> = Some(Parent.into());
|
||||
}
|
||||
|
||||
impl pallet_xcm::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type SendXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
|
||||
@@ -435,13 +450,21 @@ impl pallet_xcm::Config for Runtime {
|
||||
type XcmExecuteFilter = Everything;
|
||||
type XcmExecutor = XcmExecutor<XcmConfig>;
|
||||
type XcmTeleportFilter = Everything;
|
||||
type XcmReserveTransferFilter = frame_support::traits::Nothing;
|
||||
type XcmReserveTransferFilter = Nothing;
|
||||
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type UniversalLocation = UniversalLocation;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
|
||||
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
|
||||
type Currency = Balances;
|
||||
type CurrencyMatcher = ();
|
||||
type TrustedLockers = ();
|
||||
type SovereignAccountOf = LocationToAccountId;
|
||||
type MaxLockers = ConstU32<8>;
|
||||
type WeightInfo = pallet_xcm::TestWeightInfo;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type ReachableDest = ReachableDest;
|
||||
}
|
||||
|
||||
impl cumulus_pallet_xcm::Config for Runtime {
|
||||
@@ -458,6 +481,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
|
||||
type ControllerOrigin = EnsureRoot<AccountId>;
|
||||
type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
|
||||
type WeightInfo = cumulus_pallet_xcmp_queue::weights::SubstrateWeight<Runtime>;
|
||||
type PriceForSiblingDelivery = ();
|
||||
}
|
||||
|
||||
impl cumulus_pallet_dmp_queue::Config for Runtime {
|
||||
|
||||
@@ -17,6 +17,7 @@ sp-trie = { git = "https://github.com/paritytech/substrate", default-features =
|
||||
polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||
xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||
|
||||
[features]
|
||||
default = [ "std" ]
|
||||
|
||||
@@ -32,6 +32,8 @@ pub use polkadot_primitives::{
|
||||
AbridgedHostConfiguration, AbridgedHrmpChannel, PersistedValidationData,
|
||||
};
|
||||
|
||||
pub use xcm::latest::prelude::*;
|
||||
|
||||
/// A module that re-exports relevant relay chain definitions.
|
||||
pub mod relay_chain {
|
||||
pub use polkadot_core_primitives::*;
|
||||
@@ -94,10 +96,11 @@ pub trait GetChannelInfo {
|
||||
pub trait UpwardMessageSender {
|
||||
/// Send the given UMP message; return the expected number of blocks before the message will
|
||||
/// be dispatched or an error if the message cannot be sent.
|
||||
fn send_upward_message(msg: UpwardMessage) -> Result<u32, MessageSendError>;
|
||||
/// return the hash of the message sent
|
||||
fn send_upward_message(msg: UpwardMessage) -> Result<(u32, XcmHash), MessageSendError>;
|
||||
}
|
||||
impl UpwardMessageSender for () {
|
||||
fn send_upward_message(_msg: UpwardMessage) -> Result<u32, MessageSendError> {
|
||||
fn send_upward_message(_msg: UpwardMessage) -> Result<(u32, XcmHash), MessageSendError> {
|
||||
Err(MessageSendError::NoChannel)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,10 +10,12 @@ log = { version = "0.4.17", default-features = false }
|
||||
|
||||
# Substrate
|
||||
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
|
||||
# Polkadot
|
||||
polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||
xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||
xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||
xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||
@@ -29,6 +31,8 @@ std = [
|
||||
"frame-support/std",
|
||||
"sp-runtime/std",
|
||||
"sp-std/std",
|
||||
"sp-io/std",
|
||||
"polkadot-runtime-common/std",
|
||||
"cumulus-primitives-core/std",
|
||||
"xcm/std",
|
||||
"xcm-builder/std",
|
||||
|
||||
@@ -20,20 +20,37 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use codec::Encode;
|
||||
use cumulus_primitives_core::UpwardMessageSender;
|
||||
use cumulus_primitives_core::{MessageSendError, UpwardMessageSender};
|
||||
use frame_support::{
|
||||
traits::tokens::{fungibles, fungibles::Inspect},
|
||||
traits::{
|
||||
tokens::{fungibles, fungibles::Inspect},
|
||||
Get,
|
||||
},
|
||||
weights::Weight,
|
||||
};
|
||||
use polkadot_runtime_common::xcm_sender::ConstantPrice;
|
||||
use sp_runtime::{traits::Saturating, SaturatedConversion};
|
||||
|
||||
use sp_std::marker::PhantomData;
|
||||
use xcm::{
|
||||
latest::{prelude::*, Weight as XCMWeight},
|
||||
WrapVersion,
|
||||
};
|
||||
use sp_std::{marker::PhantomData, prelude::*};
|
||||
use xcm::{latest::prelude::*, WrapVersion};
|
||||
use xcm_builder::TakeRevenue;
|
||||
use xcm_executor::traits::{MatchesFungibles, TransactAsset, WeightTrader};
|
||||
|
||||
pub trait PriceForParentDelivery {
|
||||
fn price_for_parent_delivery(message: &Xcm<()>) -> MultiAssets;
|
||||
}
|
||||
|
||||
impl PriceForParentDelivery for () {
|
||||
fn price_for_parent_delivery(_: &Xcm<()>) -> MultiAssets {
|
||||
MultiAssets::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Get<MultiAssets>> PriceForParentDelivery for ConstantPrice<T> {
|
||||
fn price_for_parent_delivery(_: &Xcm<()>) -> MultiAssets {
|
||||
T::get()
|
||||
}
|
||||
}
|
||||
|
||||
/// Xcm router which recognises the `Parent` destination and handles it by sending the message into
|
||||
/// the given UMP `UpwardMessageSender` implementation. Thus this essentially adapts an
|
||||
/// `UpwardMessageSender` trait impl into a `SendXcm` trait impl.
|
||||
@@ -41,25 +58,46 @@ use xcm_executor::traits::{MatchesFungibles, TransactAsset, WeightTrader};
|
||||
/// NOTE: This is a pretty dumb "just send it" router; we will probably want to introduce queuing
|
||||
/// to UMP eventually and when we do, the pallet which implements the queuing will be responsible
|
||||
/// for the `SendXcm` implementation.
|
||||
pub struct ParentAsUmp<T, W>(PhantomData<(T, W)>);
|
||||
impl<T: UpwardMessageSender, W: WrapVersion> SendXcm for ParentAsUmp<T, W> {
|
||||
fn send_xcm(dest: impl Into<MultiLocation>, msg: Xcm<()>) -> Result<(), SendError> {
|
||||
let dest = dest.into();
|
||||
pub struct ParentAsUmp<T, W, P>(PhantomData<(T, W, P)>);
|
||||
impl<T, W, P> SendXcm for ParentAsUmp<T, W, P>
|
||||
where
|
||||
T: UpwardMessageSender,
|
||||
W: WrapVersion,
|
||||
P: PriceForParentDelivery,
|
||||
{
|
||||
type Ticket = Vec<u8>;
|
||||
|
||||
if dest.contains_parents_only(1) {
|
||||
fn validate(
|
||||
dest: &mut Option<MultiLocation>,
|
||||
msg: &mut Option<Xcm<()>>,
|
||||
) -> SendResult<Vec<u8>> {
|
||||
let d = dest.take().ok_or(SendError::MissingArgument)?;
|
||||
|
||||
if d.contains_parents_only(1) {
|
||||
// An upward message for the relay chain.
|
||||
let xcm = msg.take().ok_or(SendError::MissingArgument)?;
|
||||
let price = P::price_for_parent_delivery(&xcm);
|
||||
let versioned_xcm =
|
||||
W::wrap_version(&dest, msg).map_err(|()| SendError::DestinationUnsupported)?;
|
||||
W::wrap_version(&d, xcm).map_err(|()| SendError::DestinationUnsupported)?;
|
||||
let data = versioned_xcm.encode();
|
||||
|
||||
T::send_upward_message(data).map_err(|e| SendError::Transport(e.into()))?;
|
||||
|
||||
Ok(())
|
||||
Ok((data, price))
|
||||
} else {
|
||||
// Anything else is unhandled. This includes a message this is meant for us.
|
||||
Err(SendError::CannotReachDestination(dest, msg))
|
||||
// Anything else is unhandled. This includes a message that is not meant for us.
|
||||
// We need to make sure that dest/msg is not consumed here.
|
||||
*dest = Some(d);
|
||||
Err(SendError::NotApplicable)
|
||||
}
|
||||
}
|
||||
|
||||
fn deliver(data: Vec<u8>) -> Result<XcmHash, SendError> {
|
||||
let (_, hash) = T::send_upward_message(data).map_err(|e| match e {
|
||||
MessageSendError::TooBig => SendError::ExceedsMaxMessageSize,
|
||||
e => SendError::Transport(e.into()),
|
||||
})?;
|
||||
|
||||
Ok(hash)
|
||||
}
|
||||
}
|
||||
|
||||
/// Contains information to handle refund/payment for xcm-execution
|
||||
@@ -108,7 +146,7 @@ impl<
|
||||
// If everything goes well, we charge.
|
||||
fn buy_weight(
|
||||
&mut self,
|
||||
weight: XCMWeight,
|
||||
weight: Weight,
|
||||
payment: xcm_executor::Assets,
|
||||
) -> Result<xcm_executor::Assets, XcmError> {
|
||||
log::trace!(target: "xcm::weight", "TakeFirstAssetTrader::buy_weight weight: {:?}, payment: {:?}", weight, payment);
|
||||
@@ -118,8 +156,6 @@ impl<
|
||||
return Err(XcmError::NotWithdrawable)
|
||||
}
|
||||
|
||||
let weight = Weight::from_ref_time(weight);
|
||||
|
||||
// We take the very first multiasset from payment
|
||||
// (assets are sorted by fungibility/amount after this conversion)
|
||||
let multiassets: MultiAssets = payment.clone().into();
|
||||
@@ -161,15 +197,13 @@ impl<
|
||||
Ok(unused)
|
||||
}
|
||||
|
||||
fn refund_weight(&mut self, weight: XCMWeight) -> Option<MultiAsset> {
|
||||
fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {
|
||||
log::trace!(target: "xcm::weight", "TakeFirstAssetTrader::refund_weight weight: {:?}", weight);
|
||||
if let Some(AssetTraderRefunder {
|
||||
mut weight_outstanding,
|
||||
outstanding_concrete_asset: MultiAsset { id, fun },
|
||||
}) = self.0.clone()
|
||||
{
|
||||
let weight = Weight::from_ref_time(weight).min(weight_outstanding);
|
||||
|
||||
// Get the local asset id in which we can refund fees
|
||||
let (local_asset_id, outstanding_balance) =
|
||||
Matcher::matches_fungibles(&(id.clone(), fun).into()).ok()?;
|
||||
@@ -255,7 +289,10 @@ impl<
|
||||
if let Some(receiver) = ReceiverAccount::get() {
|
||||
let ok = FungiblesMutateAdapter::deposit_asset(
|
||||
&revenue,
|
||||
&(X1(AccountId32 { network: Any, id: receiver.into() }).into()),
|
||||
&(X1(AccountId32 { network: None, id: receiver.into() }).into()),
|
||||
// We aren't able to track the XCM that initiated the fee deposit, so we create a
|
||||
// fake message hash here
|
||||
&XcmContext::with_message_hash([0; 32]),
|
||||
)
|
||||
.is_ok();
|
||||
|
||||
@@ -273,3 +310,104 @@ pub trait ChargeWeightInFungibles<AccountId, Assets: fungibles::Inspect<AccountI
|
||||
weight: Weight,
|
||||
) -> Result<<Assets as Inspect<AccountId>>::Balance, XcmError>;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use cumulus_primitives_core::UpwardMessage;
|
||||
|
||||
/// Validates [`validate`] for required Some(destination) and Some(message)
|
||||
struct OkFixedXcmHashWithAssertingRequiredInputsSender;
|
||||
impl OkFixedXcmHashWithAssertingRequiredInputsSender {
|
||||
const FIXED_XCM_HASH: [u8; 32] = [9; 32];
|
||||
|
||||
fn fixed_delivery_asset() -> MultiAssets {
|
||||
MultiAssets::new()
|
||||
}
|
||||
|
||||
fn expected_delivery_result() -> Result<(XcmHash, MultiAssets), SendError> {
|
||||
Ok((Self::FIXED_XCM_HASH, Self::fixed_delivery_asset()))
|
||||
}
|
||||
}
|
||||
impl SendXcm for OkFixedXcmHashWithAssertingRequiredInputsSender {
|
||||
type Ticket = ();
|
||||
|
||||
fn validate(
|
||||
destination: &mut Option<MultiLocation>,
|
||||
message: &mut Option<Xcm<()>>,
|
||||
) -> SendResult<Self::Ticket> {
|
||||
assert!(destination.is_some());
|
||||
assert!(message.is_some());
|
||||
Ok(((), OkFixedXcmHashWithAssertingRequiredInputsSender::fixed_delivery_asset()))
|
||||
}
|
||||
|
||||
fn deliver(_: Self::Ticket) -> Result<XcmHash, SendError> {
|
||||
Ok(Self::FIXED_XCM_HASH)
|
||||
}
|
||||
}
|
||||
|
||||
/// Impl [`UpwardMessageSender`] that return `Other` error
|
||||
struct OtherErrorUpwardMessageSender;
|
||||
impl UpwardMessageSender for OtherErrorUpwardMessageSender {
|
||||
fn send_upward_message(_: UpwardMessage) -> Result<(u32, XcmHash), MessageSendError> {
|
||||
Err(MessageSendError::Other)
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parent_as_ump_does_not_consume_dest_or_msg_on_not_applicable() {
|
||||
// dummy message
|
||||
let message = Xcm(vec![Trap(5)]);
|
||||
|
||||
// ParentAsUmp - check dest is really not applicable
|
||||
let dest = (Parent, Parent, Parent);
|
||||
let mut dest_wrapper = Some(dest.clone().into());
|
||||
let mut msg_wrapper = Some(message.clone());
|
||||
assert_eq!(
|
||||
Err(SendError::NotApplicable),
|
||||
<ParentAsUmp<(), (), ()> as SendXcm>::validate(&mut dest_wrapper, &mut msg_wrapper)
|
||||
);
|
||||
|
||||
// check wrapper were not consumed
|
||||
assert_eq!(Some(dest.clone().into()), dest_wrapper.take());
|
||||
assert_eq!(Some(message.clone()), msg_wrapper.take());
|
||||
|
||||
// another try with router chain with asserting sender
|
||||
assert_eq!(
|
||||
OkFixedXcmHashWithAssertingRequiredInputsSender::expected_delivery_result(),
|
||||
send_xcm::<(ParentAsUmp<(), (), ()>, OkFixedXcmHashWithAssertingRequiredInputsSender)>(
|
||||
dest.into(),
|
||||
message
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parent_as_ump_consumes_dest_and_msg_on_ok_validate() {
|
||||
// dummy message
|
||||
let message = Xcm(vec![Trap(5)]);
|
||||
|
||||
// ParentAsUmp - check dest/msg is valid
|
||||
let dest = (Parent, Here);
|
||||
let mut dest_wrapper = Some(dest.clone().into());
|
||||
let mut msg_wrapper = Some(message.clone());
|
||||
assert!(<ParentAsUmp<(), (), ()> as SendXcm>::validate(
|
||||
&mut dest_wrapper,
|
||||
&mut msg_wrapper
|
||||
)
|
||||
.is_ok());
|
||||
|
||||
// check wrapper were consumed
|
||||
assert_eq!(None, dest_wrapper.take());
|
||||
assert_eq!(None, msg_wrapper.take());
|
||||
|
||||
// another try with router chain with asserting sender
|
||||
assert_eq!(
|
||||
Err(SendError::Transport("Other")),
|
||||
send_xcm::<(
|
||||
ParentAsUmp<OtherErrorUpwardMessageSender, (), ()>,
|
||||
OkFixedXcmHashWithAssertingRequiredInputsSender
|
||||
)>(dest.into(), message)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +82,9 @@ polkadot-test-service = { git = "https://github.com/paritytech/polkadot", branch
|
||||
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
[features]
|
||||
runtime-benchmarks = ["polkadot-test-service/runtime-benchmarks"]
|
||||
|
||||
[[bench]]
|
||||
name = "transaction_throughput"
|
||||
harness = false
|
||||
|
||||
Reference in New Issue
Block a user