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:
Gavin Wood
2023-01-17 06:26:34 -03:00
committed by GitHub
parent aae4731d38
commit 3aae882437
73 changed files with 4328 additions and 1487 deletions
+108 -8
View File
@@ -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
)
);
});
}