mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 11:41:02 +00:00
XCM: Implement a blocking barrier (#7098)
* Move XCM matcher to xcm-builder * Use ProcessMessageError as the error type in MatchXcm and ShouldExecute * Implement a blocking barrier * Fixes * Add benchmarking for force_suspension * ".git/.scripts/commands/bench/bench.sh" runtime westend pallet_xcm * ".git/.scripts/commands/bench/bench.sh" runtime rococo pallet_xcm * ".git/.scripts/commands/bench/bench.sh" runtime kusama pallet_xcm * ".git/.scripts/commands/bench/bench.sh" runtime polkadot pallet_xcm * ".git/.scripts/commands/bench/bench.sh" runtime westend pallet_xcm * ".git/.scripts/commands/bench/bench.sh" runtime rococo pallet_xcm --------- Co-authored-by: command-bot <>
This commit is contained in:
@@ -13,25 +13,28 @@
|
|||||||
|
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
//! Autogenerated weights for `pallet_xcm`
|
//! Autogenerated weights for `pallet_xcm`
|
||||||
//!
|
//!
|
||||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||||
//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
//! DATE: 2023-04-19, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||||
//! WORST CASE MAP SIZE: `1000000`
|
//! WORST CASE MAP SIZE: `1000000`
|
||||||
//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024
|
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024
|
||||||
|
|
||||||
// Executed Command:
|
// Executed Command:
|
||||||
// ./target/production/polkadot
|
// target/production/polkadot
|
||||||
// benchmark
|
// benchmark
|
||||||
// pallet
|
// pallet
|
||||||
// --chain=kusama-dev
|
|
||||||
// --steps=50
|
// --steps=50
|
||||||
// --repeat=20
|
// --repeat=20
|
||||||
// --pallet=pallet_xcm
|
|
||||||
// --extrinsic=*
|
// --extrinsic=*
|
||||||
// --execution=wasm
|
// --execution=wasm
|
||||||
// --wasm-execution=compiled
|
// --wasm-execution=compiled
|
||||||
|
// --heap-pages=4096
|
||||||
|
// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/polkadot/.git/.artifacts/bench.json
|
||||||
|
// --pallet=pallet_xcm
|
||||||
|
// --chain=kusama-dev
|
||||||
// --header=./file_header.txt
|
// --header=./file_header.txt
|
||||||
// --output=./runtime/kusama/src/weights/
|
// --output=./runtime/kusama/src/weights/
|
||||||
|
|
||||||
@@ -40,7 +43,7 @@
|
|||||||
#![allow(unused_imports)]
|
#![allow(unused_imports)]
|
||||||
|
|
||||||
use frame_support::{traits::Get, weights::Weight};
|
use frame_support::{traits::Get, weights::Weight};
|
||||||
use sp_std::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
|
|
||||||
/// Weight functions for `pallet_xcm`.
|
/// Weight functions for `pallet_xcm`.
|
||||||
pub struct WeightInfo<T>(PhantomData<T>);
|
pub struct WeightInfo<T>(PhantomData<T>);
|
||||||
@@ -58,10 +61,10 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
fn send() -> Weight {
|
fn send() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `211`
|
// Measured: `211`
|
||||||
// Estimated: `14420`
|
// Estimated: `3676`
|
||||||
// Minimum execution time: 32_211_000 picoseconds.
|
// Minimum execution time: 32_058_000 picoseconds.
|
||||||
Weight::from_parts(32_864_000, 0)
|
Weight::from_parts(32_630_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 14420))
|
.saturating_add(Weight::from_parts(0, 3676))
|
||||||
.saturating_add(T::DbWeight::get().reads(5))
|
.saturating_add(T::DbWeight::get().reads(5))
|
||||||
.saturating_add(T::DbWeight::get().writes(3))
|
.saturating_add(T::DbWeight::get().writes(3))
|
||||||
}
|
}
|
||||||
@@ -69,24 +72,24 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `0`
|
// Measured: `0`
|
||||||
// Estimated: `0`
|
// Estimated: `0`
|
||||||
// Minimum execution time: 21_186_000 picoseconds.
|
// Minimum execution time: 21_569_000 picoseconds.
|
||||||
Weight::from_parts(21_501_000, 0)
|
Weight::from_parts(21_969_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 0))
|
.saturating_add(Weight::from_parts(0, 0))
|
||||||
}
|
}
|
||||||
fn reserve_transfer_assets() -> Weight {
|
fn reserve_transfer_assets() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `0`
|
// Measured: `0`
|
||||||
// Estimated: `0`
|
// Estimated: `0`
|
||||||
// Minimum execution time: 20_009_000 picoseconds.
|
// Minimum execution time: 20_667_000 picoseconds.
|
||||||
Weight::from_parts(20_431_000, 0)
|
Weight::from_parts(21_006_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 0))
|
.saturating_add(Weight::from_parts(0, 0))
|
||||||
}
|
}
|
||||||
fn execute() -> Weight {
|
fn execute() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `0`
|
// Measured: `0`
|
||||||
// Estimated: `0`
|
// Estimated: `0`
|
||||||
// Minimum execution time: 10_031_000 picoseconds.
|
// Minimum execution time: 9_993_000 picoseconds.
|
||||||
Weight::from_parts(10_350_000, 0)
|
Weight::from_parts(10_278_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 0))
|
.saturating_add(Weight::from_parts(0, 0))
|
||||||
}
|
}
|
||||||
/// Storage: XcmPallet SupportedVersion (r:0 w:1)
|
/// Storage: XcmPallet SupportedVersion (r:0 w:1)
|
||||||
@@ -95,8 +98,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `0`
|
// Measured: `0`
|
||||||
// Estimated: `0`
|
// Estimated: `0`
|
||||||
// Minimum execution time: 10_202_000 picoseconds.
|
// Minimum execution time: 10_234_000 picoseconds.
|
||||||
Weight::from_parts(10_401_000, 0)
|
Weight::from_parts(10_498_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 0))
|
.saturating_add(Weight::from_parts(0, 0))
|
||||||
.saturating_add(T::DbWeight::get().writes(1))
|
.saturating_add(T::DbWeight::get().writes(1))
|
||||||
}
|
}
|
||||||
@@ -106,8 +109,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `0`
|
// Measured: `0`
|
||||||
// Estimated: `0`
|
// Estimated: `0`
|
||||||
// Minimum execution time: 3_042_000 picoseconds.
|
// Minimum execution time: 3_272_000 picoseconds.
|
||||||
Weight::from_parts(3_161_000, 0)
|
Weight::from_parts(3_469_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 0))
|
.saturating_add(Weight::from_parts(0, 0))
|
||||||
.saturating_add(T::DbWeight::get().writes(1))
|
.saturating_add(T::DbWeight::get().writes(1))
|
||||||
}
|
}
|
||||||
@@ -130,10 +133,10 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
fn force_subscribe_version_notify() -> Weight {
|
fn force_subscribe_version_notify() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `211`
|
// Measured: `211`
|
||||||
// Estimated: `20003`
|
// Estimated: `3676`
|
||||||
// Minimum execution time: 37_152_000 picoseconds.
|
// Minimum execution time: 36_157_000 picoseconds.
|
||||||
Weight::from_parts(37_637_000, 0)
|
Weight::from_parts(36_777_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 20003))
|
.saturating_add(Weight::from_parts(0, 3676))
|
||||||
.saturating_add(T::DbWeight::get().reads(7))
|
.saturating_add(T::DbWeight::get().reads(7))
|
||||||
.saturating_add(T::DbWeight::get().writes(6))
|
.saturating_add(T::DbWeight::get().writes(6))
|
||||||
}
|
}
|
||||||
@@ -154,21 +157,32 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
fn force_unsubscribe_version_notify() -> Weight {
|
fn force_unsubscribe_version_notify() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `483`
|
// Measured: `483`
|
||||||
// Estimated: `20211`
|
// Estimated: `3948`
|
||||||
// Minimum execution time: 40_068_000 picoseconds.
|
// Minimum execution time: 39_613_000 picoseconds.
|
||||||
Weight::from_parts(40_408_000, 0)
|
Weight::from_parts(39_905_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 20211))
|
.saturating_add(Weight::from_parts(0, 3948))
|
||||||
.saturating_add(T::DbWeight::get().reads(6))
|
.saturating_add(T::DbWeight::get().reads(6))
|
||||||
.saturating_add(T::DbWeight::get().writes(5))
|
.saturating_add(T::DbWeight::get().writes(5))
|
||||||
}
|
}
|
||||||
|
/// Storage: XcmPallet XcmExecutionSuspended (r:0 w:1)
|
||||||
|
/// Proof Skipped: XcmPallet XcmExecutionSuspended (max_values: Some(1), max_size: None, mode: Measured)
|
||||||
|
fn force_suspension() -> Weight {
|
||||||
|
// Proof Size summary in bytes:
|
||||||
|
// Measured: `0`
|
||||||
|
// Estimated: `0`
|
||||||
|
// Minimum execution time: 3_296_000 picoseconds.
|
||||||
|
Weight::from_parts(3_485_000, 0)
|
||||||
|
.saturating_add(Weight::from_parts(0, 0))
|
||||||
|
.saturating_add(T::DbWeight::get().writes(1))
|
||||||
|
}
|
||||||
/// Storage: XcmPallet SupportedVersion (r:4 w:2)
|
/// Storage: XcmPallet SupportedVersion (r:4 w:2)
|
||||||
/// Proof Skipped: XcmPallet SupportedVersion (max_values: None, max_size: None, mode: Measured)
|
/// Proof Skipped: XcmPallet SupportedVersion (max_values: None, max_size: None, mode: Measured)
|
||||||
fn migrate_supported_version() -> Weight {
|
fn migrate_supported_version() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `229`
|
// Measured: `229`
|
||||||
// Estimated: `11119`
|
// Estimated: `11119`
|
||||||
// Minimum execution time: 16_679_000 picoseconds.
|
// Minimum execution time: 16_201_000 picoseconds.
|
||||||
Weight::from_parts(17_372_000, 0)
|
Weight::from_parts(16_681_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 11119))
|
.saturating_add(Weight::from_parts(0, 11119))
|
||||||
.saturating_add(T::DbWeight::get().reads(4))
|
.saturating_add(T::DbWeight::get().reads(4))
|
||||||
.saturating_add(T::DbWeight::get().writes(2))
|
.saturating_add(T::DbWeight::get().writes(2))
|
||||||
@@ -179,8 +193,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `233`
|
// Measured: `233`
|
||||||
// Estimated: `11123`
|
// Estimated: `11123`
|
||||||
// Minimum execution time: 17_113_000 picoseconds.
|
// Minimum execution time: 16_157_000 picoseconds.
|
||||||
Weight::from_parts(17_539_000, 0)
|
Weight::from_parts(16_674_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 11123))
|
.saturating_add(Weight::from_parts(0, 11123))
|
||||||
.saturating_add(T::DbWeight::get().reads(4))
|
.saturating_add(T::DbWeight::get().reads(4))
|
||||||
.saturating_add(T::DbWeight::get().writes(2))
|
.saturating_add(T::DbWeight::get().writes(2))
|
||||||
@@ -191,8 +205,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `243`
|
// Measured: `243`
|
||||||
// Estimated: `13608`
|
// Estimated: `13608`
|
||||||
// Minimum execution time: 17_831_000 picoseconds.
|
// Minimum execution time: 17_502_000 picoseconds.
|
||||||
Weight::from_parts(18_222_000, 0)
|
Weight::from_parts(18_000_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 13608))
|
.saturating_add(Weight::from_parts(0, 13608))
|
||||||
.saturating_add(T::DbWeight::get().reads(5))
|
.saturating_add(T::DbWeight::get().reads(5))
|
||||||
}
|
}
|
||||||
@@ -211,10 +225,10 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
fn notify_current_targets() -> Weight {
|
fn notify_current_targets() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `281`
|
// Measured: `281`
|
||||||
// Estimated: `20991`
|
// Estimated: `6221`
|
||||||
// Minimum execution time: 34_239_000 picoseconds.
|
// Minimum execution time: 33_198_000 picoseconds.
|
||||||
Weight::from_parts(34_714_000, 0)
|
Weight::from_parts(33_742_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 20991))
|
.saturating_add(Weight::from_parts(0, 6221))
|
||||||
.saturating_add(T::DbWeight::get().reads(7))
|
.saturating_add(T::DbWeight::get().reads(7))
|
||||||
.saturating_add(T::DbWeight::get().writes(4))
|
.saturating_add(T::DbWeight::get().writes(4))
|
||||||
}
|
}
|
||||||
@@ -224,8 +238,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `272`
|
// Measured: `272`
|
||||||
// Estimated: `8687`
|
// Estimated: `8687`
|
||||||
// Minimum execution time: 9_813_000 picoseconds.
|
// Minimum execution time: 8_989_000 picoseconds.
|
||||||
Weight::from_parts(10_050_000, 0)
|
Weight::from_parts(9_241_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 8687))
|
.saturating_add(Weight::from_parts(0, 8687))
|
||||||
.saturating_add(T::DbWeight::get().reads(3))
|
.saturating_add(T::DbWeight::get().reads(3))
|
||||||
}
|
}
|
||||||
@@ -235,8 +249,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `240`
|
// Measured: `240`
|
||||||
// Estimated: `11130`
|
// Estimated: `11130`
|
||||||
// Minimum execution time: 17_449_000 picoseconds.
|
// Minimum execution time: 16_709_000 picoseconds.
|
||||||
Weight::from_parts(17_898_000, 0)
|
Weight::from_parts(17_237_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 11130))
|
.saturating_add(Weight::from_parts(0, 11130))
|
||||||
.saturating_add(T::DbWeight::get().reads(4))
|
.saturating_add(T::DbWeight::get().reads(4))
|
||||||
.saturating_add(T::DbWeight::get().writes(2))
|
.saturating_add(T::DbWeight::get().writes(2))
|
||||||
@@ -256,10 +270,10 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
fn migrate_and_notify_old_targets() -> Weight {
|
fn migrate_and_notify_old_targets() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `285`
|
// Measured: `285`
|
||||||
// Estimated: `25965`
|
// Estimated: `11175`
|
||||||
// Minimum execution time: 41_651_000 picoseconds.
|
// Minimum execution time: 40_749_000 picoseconds.
|
||||||
Weight::from_parts(42_184_000, 0)
|
Weight::from_parts(41_154_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 25965))
|
.saturating_add(Weight::from_parts(0, 11175))
|
||||||
.saturating_add(T::DbWeight::get().reads(9))
|
.saturating_add(T::DbWeight::get().reads(9))
|
||||||
.saturating_add(T::DbWeight::get().writes(5))
|
.saturating_add(T::DbWeight::get().writes(5))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,25 +13,28 @@
|
|||||||
|
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
//! Autogenerated weights for `pallet_xcm`
|
//! Autogenerated weights for `pallet_xcm`
|
||||||
//!
|
//!
|
||||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||||
//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
//! DATE: 2023-04-19, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||||
//! WORST CASE MAP SIZE: `1000000`
|
//! WORST CASE MAP SIZE: `1000000`
|
||||||
//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024
|
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024
|
||||||
|
|
||||||
// Executed Command:
|
// Executed Command:
|
||||||
// ./target/production/polkadot
|
// target/production/polkadot
|
||||||
// benchmark
|
// benchmark
|
||||||
// pallet
|
// pallet
|
||||||
// --chain=polkadot-dev
|
|
||||||
// --steps=50
|
// --steps=50
|
||||||
// --repeat=20
|
// --repeat=20
|
||||||
// --pallet=pallet_xcm
|
|
||||||
// --extrinsic=*
|
// --extrinsic=*
|
||||||
// --execution=wasm
|
// --execution=wasm
|
||||||
// --wasm-execution=compiled
|
// --wasm-execution=compiled
|
||||||
|
// --heap-pages=4096
|
||||||
|
// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/polkadot/.git/.artifacts/bench.json
|
||||||
|
// --pallet=pallet_xcm
|
||||||
|
// --chain=polkadot-dev
|
||||||
// --header=./file_header.txt
|
// --header=./file_header.txt
|
||||||
// --output=./runtime/polkadot/src/weights/
|
// --output=./runtime/polkadot/src/weights/
|
||||||
|
|
||||||
@@ -40,7 +43,7 @@
|
|||||||
#![allow(unused_imports)]
|
#![allow(unused_imports)]
|
||||||
|
|
||||||
use frame_support::{traits::Get, weights::Weight};
|
use frame_support::{traits::Get, weights::Weight};
|
||||||
use sp_std::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
|
|
||||||
/// Weight functions for `pallet_xcm`.
|
/// Weight functions for `pallet_xcm`.
|
||||||
pub struct WeightInfo<T>(PhantomData<T>);
|
pub struct WeightInfo<T>(PhantomData<T>);
|
||||||
@@ -59,11 +62,11 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
/// Proof Skipped: Dmp DownwardMessageQueueHeads (max_values: None, max_size: None, mode: Measured)
|
/// Proof Skipped: Dmp DownwardMessageQueueHeads (max_values: None, max_size: None, mode: Measured)
|
||||||
fn send() -> Weight {
|
fn send() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `438`
|
// Measured: `514`
|
||||||
// Estimated: `17478`
|
// Estimated: `3979`
|
||||||
// Minimum execution time: 34_675_000 picoseconds.
|
// Minimum execution time: 36_060_000 picoseconds.
|
||||||
Weight::from_parts(35_527_000, 0)
|
Weight::from_parts(36_761_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 17478))
|
.saturating_add(Weight::from_parts(0, 3979))
|
||||||
.saturating_add(T::DbWeight::get().reads(6))
|
.saturating_add(T::DbWeight::get().reads(6))
|
||||||
.saturating_add(T::DbWeight::get().writes(3))
|
.saturating_add(T::DbWeight::get().writes(3))
|
||||||
}
|
}
|
||||||
@@ -71,16 +74,16 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `0`
|
// Measured: `0`
|
||||||
// Estimated: `0`
|
// Estimated: `0`
|
||||||
// Minimum execution time: 22_653_000 picoseconds.
|
// Minimum execution time: 23_222_000 picoseconds.
|
||||||
Weight::from_parts(23_050_000, 0)
|
Weight::from_parts(23_506_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 0))
|
.saturating_add(Weight::from_parts(0, 0))
|
||||||
}
|
}
|
||||||
fn reserve_transfer_assets() -> Weight {
|
fn reserve_transfer_assets() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `0`
|
// Measured: `0`
|
||||||
// Estimated: `0`
|
// Estimated: `0`
|
||||||
// Minimum execution time: 21_214_000 picoseconds.
|
// Minimum execution time: 21_932_000 picoseconds.
|
||||||
Weight::from_parts(21_604_000, 0)
|
Weight::from_parts(22_343_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 0))
|
.saturating_add(Weight::from_parts(0, 0))
|
||||||
}
|
}
|
||||||
/// Storage: Benchmark Override (r:0 w:0)
|
/// Storage: Benchmark Override (r:0 w:0)
|
||||||
@@ -99,8 +102,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `0`
|
// Measured: `0`
|
||||||
// Estimated: `0`
|
// Estimated: `0`
|
||||||
// Minimum execution time: 10_275_000 picoseconds.
|
// Minimum execution time: 10_103_000 picoseconds.
|
||||||
Weight::from_parts(10_563_000, 0)
|
Weight::from_parts(10_429_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 0))
|
.saturating_add(Weight::from_parts(0, 0))
|
||||||
.saturating_add(T::DbWeight::get().writes(1))
|
.saturating_add(T::DbWeight::get().writes(1))
|
||||||
}
|
}
|
||||||
@@ -110,8 +113,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `0`
|
// Measured: `0`
|
||||||
// Estimated: `0`
|
// Estimated: `0`
|
||||||
// Minimum execution time: 3_001_000 picoseconds.
|
// Minimum execution time: 3_244_000 picoseconds.
|
||||||
Weight::from_parts(3_085_000, 0)
|
Weight::from_parts(3_367_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 0))
|
.saturating_add(Weight::from_parts(0, 0))
|
||||||
.saturating_add(T::DbWeight::get().writes(1))
|
.saturating_add(T::DbWeight::get().writes(1))
|
||||||
}
|
}
|
||||||
@@ -135,11 +138,11 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
/// Proof Skipped: XcmPallet Queries (max_values: None, max_size: None, mode: Measured)
|
/// Proof Skipped: XcmPallet Queries (max_values: None, max_size: None, mode: Measured)
|
||||||
fn force_subscribe_version_notify() -> Weight {
|
fn force_subscribe_version_notify() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `438`
|
// Measured: `514`
|
||||||
// Estimated: `23742`
|
// Estimated: `3979`
|
||||||
// Minimum execution time: 39_910_000 picoseconds.
|
// Minimum execution time: 40_198_000 picoseconds.
|
||||||
Weight::from_parts(40_847_000, 0)
|
Weight::from_parts(40_837_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 23742))
|
.saturating_add(Weight::from_parts(0, 3979))
|
||||||
.saturating_add(T::DbWeight::get().reads(8))
|
.saturating_add(T::DbWeight::get().reads(8))
|
||||||
.saturating_add(T::DbWeight::get().writes(6))
|
.saturating_add(T::DbWeight::get().writes(6))
|
||||||
}
|
}
|
||||||
@@ -161,22 +164,33 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
/// Proof Skipped: XcmPallet Queries (max_values: None, max_size: None, mode: Measured)
|
/// Proof Skipped: XcmPallet Queries (max_values: None, max_size: None, mode: Measured)
|
||||||
fn force_unsubscribe_version_notify() -> Weight {
|
fn force_unsubscribe_version_notify() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `710`
|
// Measured: `786`
|
||||||
// Estimated: `23995`
|
// Estimated: `4251`
|
||||||
// Minimum execution time: 43_293_000 picoseconds.
|
// Minimum execution time: 42_735_000 picoseconds.
|
||||||
Weight::from_parts(43_774_000, 0)
|
Weight::from_parts(43_343_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 23995))
|
.saturating_add(Weight::from_parts(0, 4251))
|
||||||
.saturating_add(T::DbWeight::get().reads(7))
|
.saturating_add(T::DbWeight::get().reads(7))
|
||||||
.saturating_add(T::DbWeight::get().writes(5))
|
.saturating_add(T::DbWeight::get().writes(5))
|
||||||
}
|
}
|
||||||
|
/// Storage: XcmPallet XcmExecutionSuspended (r:0 w:1)
|
||||||
|
/// Proof Skipped: XcmPallet XcmExecutionSuspended (max_values: Some(1), max_size: None, mode: Measured)
|
||||||
|
fn force_suspension() -> Weight {
|
||||||
|
// Proof Size summary in bytes:
|
||||||
|
// Measured: `0`
|
||||||
|
// Estimated: `0`
|
||||||
|
// Minimum execution time: 3_333_000 picoseconds.
|
||||||
|
Weight::from_parts(3_513_000, 0)
|
||||||
|
.saturating_add(Weight::from_parts(0, 0))
|
||||||
|
.saturating_add(T::DbWeight::get().writes(1))
|
||||||
|
}
|
||||||
/// Storage: XcmPallet SupportedVersion (r:4 w:2)
|
/// Storage: XcmPallet SupportedVersion (r:4 w:2)
|
||||||
/// Proof Skipped: XcmPallet SupportedVersion (max_values: None, max_size: None, mode: Measured)
|
/// Proof Skipped: XcmPallet SupportedVersion (max_values: None, max_size: None, mode: Measured)
|
||||||
fn migrate_supported_version() -> Weight {
|
fn migrate_supported_version() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `229`
|
// Measured: `229`
|
||||||
// Estimated: `11119`
|
// Estimated: `11119`
|
||||||
// Minimum execution time: 17_985_000 picoseconds.
|
// Minimum execution time: 16_716_000 picoseconds.
|
||||||
Weight::from_parts(18_376_000, 0)
|
Weight::from_parts(17_399_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 11119))
|
.saturating_add(Weight::from_parts(0, 11119))
|
||||||
.saturating_add(T::DbWeight::get().reads(4))
|
.saturating_add(T::DbWeight::get().reads(4))
|
||||||
.saturating_add(T::DbWeight::get().writes(2))
|
.saturating_add(T::DbWeight::get().writes(2))
|
||||||
@@ -187,8 +201,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `233`
|
// Measured: `233`
|
||||||
// Estimated: `11123`
|
// Estimated: `11123`
|
||||||
// Minimum execution time: 18_007_000 picoseconds.
|
// Minimum execution time: 17_034_000 picoseconds.
|
||||||
Weight::from_parts(18_507_000, 0)
|
Weight::from_parts(17_743_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 11123))
|
.saturating_add(Weight::from_parts(0, 11123))
|
||||||
.saturating_add(T::DbWeight::get().reads(4))
|
.saturating_add(T::DbWeight::get().reads(4))
|
||||||
.saturating_add(T::DbWeight::get().writes(2))
|
.saturating_add(T::DbWeight::get().writes(2))
|
||||||
@@ -199,8 +213,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `243`
|
// Measured: `243`
|
||||||
// Estimated: `13608`
|
// Estimated: `13608`
|
||||||
// Minimum execution time: 18_954_000 picoseconds.
|
// Minimum execution time: 18_741_000 picoseconds.
|
||||||
Weight::from_parts(19_612_000, 0)
|
Weight::from_parts(19_096_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 13608))
|
.saturating_add(Weight::from_parts(0, 13608))
|
||||||
.saturating_add(T::DbWeight::get().reads(5))
|
.saturating_add(T::DbWeight::get().reads(5))
|
||||||
}
|
}
|
||||||
@@ -220,11 +234,11 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
/// Proof Skipped: Dmp DownwardMessageQueueHeads (max_values: None, max_size: None, mode: Measured)
|
/// Proof Skipped: Dmp DownwardMessageQueueHeads (max_values: None, max_size: None, mode: Measured)
|
||||||
fn notify_current_targets() -> Weight {
|
fn notify_current_targets() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `508`
|
// Measured: `584`
|
||||||
// Estimated: `24346`
|
// Estimated: `6524`
|
||||||
// Minimum execution time: 38_137_000 picoseconds.
|
// Minimum execution time: 37_105_000 picoseconds.
|
||||||
Weight::from_parts(38_547_000, 0)
|
Weight::from_parts(37_579_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 24346))
|
.saturating_add(Weight::from_parts(0, 6524))
|
||||||
.saturating_add(T::DbWeight::get().reads(8))
|
.saturating_add(T::DbWeight::get().reads(8))
|
||||||
.saturating_add(T::DbWeight::get().writes(4))
|
.saturating_add(T::DbWeight::get().writes(4))
|
||||||
}
|
}
|
||||||
@@ -234,8 +248,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `272`
|
// Measured: `272`
|
||||||
// Estimated: `8687`
|
// Estimated: `8687`
|
||||||
// Minimum execution time: 9_454_000 picoseconds.
|
// Minimum execution time: 9_111_000 picoseconds.
|
||||||
Weight::from_parts(9_729_000, 0)
|
Weight::from_parts(9_442_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 8687))
|
.saturating_add(Weight::from_parts(0, 8687))
|
||||||
.saturating_add(T::DbWeight::get().reads(3))
|
.saturating_add(T::DbWeight::get().reads(3))
|
||||||
}
|
}
|
||||||
@@ -245,8 +259,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `240`
|
// Measured: `240`
|
||||||
// Estimated: `11130`
|
// Estimated: `11130`
|
||||||
// Minimum execution time: 17_957_000 picoseconds.
|
// Minimum execution time: 17_846_000 picoseconds.
|
||||||
Weight::from_parts(18_748_000, 0)
|
Weight::from_parts(18_193_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 11130))
|
.saturating_add(Weight::from_parts(0, 11130))
|
||||||
.saturating_add(T::DbWeight::get().reads(4))
|
.saturating_add(T::DbWeight::get().reads(4))
|
||||||
.saturating_add(T::DbWeight::get().writes(2))
|
.saturating_add(T::DbWeight::get().writes(2))
|
||||||
@@ -267,11 +281,11 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
/// Proof Skipped: Dmp DownwardMessageQueueHeads (max_values: None, max_size: None, mode: Measured)
|
/// Proof Skipped: Dmp DownwardMessageQueueHeads (max_values: None, max_size: None, mode: Measured)
|
||||||
fn migrate_and_notify_old_targets() -> Weight {
|
fn migrate_and_notify_old_targets() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `512`
|
// Measured: `588`
|
||||||
// Estimated: `29324`
|
// Estimated: `11478`
|
||||||
// Minimum execution time: 44_805_000 picoseconds.
|
// Minimum execution time: 43_680_000 picoseconds.
|
||||||
Weight::from_parts(45_461_000, 0)
|
Weight::from_parts(44_528_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 29324))
|
.saturating_add(Weight::from_parts(0, 11478))
|
||||||
.saturating_add(T::DbWeight::get().reads(10))
|
.saturating_add(T::DbWeight::get().reads(10))
|
||||||
.saturating_add(T::DbWeight::get().writes(5))
|
.saturating_add(T::DbWeight::get().writes(5))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,25 +13,28 @@
|
|||||||
|
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
//! Autogenerated weights for `pallet_xcm`
|
//! Autogenerated weights for `pallet_xcm`
|
||||||
//!
|
//!
|
||||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||||
//! DATE: 2023-03-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
//! DATE: 2023-04-19, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||||
//! WORST CASE MAP SIZE: `1000000`
|
//! WORST CASE MAP SIZE: `1000000`
|
||||||
//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024
|
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024
|
||||||
|
|
||||||
// Executed Command:
|
// Executed Command:
|
||||||
// ./target/production/polkadot
|
// target/production/polkadot
|
||||||
// benchmark
|
// benchmark
|
||||||
// pallet
|
// pallet
|
||||||
// --chain=rococo-dev
|
|
||||||
// --steps=50
|
// --steps=50
|
||||||
// --repeat=20
|
// --repeat=20
|
||||||
// --pallet=pallet_xcm
|
|
||||||
// --extrinsic=*
|
// --extrinsic=*
|
||||||
// --execution=wasm
|
// --execution=wasm
|
||||||
// --wasm-execution=compiled
|
// --wasm-execution=compiled
|
||||||
|
// --heap-pages=4096
|
||||||
|
// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/polkadot/.git/.artifacts/bench.json
|
||||||
|
// --pallet=pallet_xcm
|
||||||
|
// --chain=rococo-dev
|
||||||
// --header=./file_header.txt
|
// --header=./file_header.txt
|
||||||
// --output=./runtime/rococo/src/weights/
|
// --output=./runtime/rococo/src/weights/
|
||||||
|
|
||||||
@@ -40,7 +43,7 @@
|
|||||||
#![allow(unused_imports)]
|
#![allow(unused_imports)]
|
||||||
|
|
||||||
use frame_support::{traits::Get, weights::Weight};
|
use frame_support::{traits::Get, weights::Weight};
|
||||||
use sp_std::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
|
|
||||||
/// Weight functions for `pallet_xcm`.
|
/// Weight functions for `pallet_xcm`.
|
||||||
pub struct WeightInfo<T>(PhantomData<T>);
|
pub struct WeightInfo<T>(PhantomData<T>);
|
||||||
@@ -59,11 +62,11 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
/// Proof Skipped: Dmp DownwardMessageQueueHeads (max_values: None, max_size: None, mode: Measured)
|
/// Proof Skipped: Dmp DownwardMessageQueueHeads (max_values: None, max_size: None, mode: Measured)
|
||||||
fn send() -> Weight {
|
fn send() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `580`
|
// Measured: `585`
|
||||||
// Estimated: `18330`
|
// Estimated: `4050`
|
||||||
// Minimum execution time: 36_658_000 picoseconds.
|
// Minimum execution time: 35_808_000 picoseconds.
|
||||||
Weight::from_parts(37_475_000, 0)
|
Weight::from_parts(36_542_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 18330))
|
.saturating_add(Weight::from_parts(0, 4050))
|
||||||
.saturating_add(T::DbWeight::get().reads(6))
|
.saturating_add(T::DbWeight::get().reads(6))
|
||||||
.saturating_add(T::DbWeight::get().writes(3))
|
.saturating_add(T::DbWeight::get().writes(3))
|
||||||
}
|
}
|
||||||
@@ -71,24 +74,24 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `0`
|
// Measured: `0`
|
||||||
// Estimated: `0`
|
// Estimated: `0`
|
||||||
// Minimum execution time: 23_580_000 picoseconds.
|
// Minimum execution time: 21_646_000 picoseconds.
|
||||||
Weight::from_parts(23_929_000, 0)
|
Weight::from_parts(21_965_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 0))
|
.saturating_add(Weight::from_parts(0, 0))
|
||||||
}
|
}
|
||||||
fn reserve_transfer_assets() -> Weight {
|
fn reserve_transfer_assets() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `0`
|
// Measured: `0`
|
||||||
// Estimated: `0`
|
// Estimated: `0`
|
||||||
// Minimum execution time: 22_900_000 picoseconds.
|
// Minimum execution time: 20_760_000 picoseconds.
|
||||||
Weight::from_parts(23_356_000, 0)
|
Weight::from_parts(21_030_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 0))
|
.saturating_add(Weight::from_parts(0, 0))
|
||||||
}
|
}
|
||||||
fn execute() -> Weight {
|
fn execute() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `0`
|
// Measured: `0`
|
||||||
// Estimated: `0`
|
// Estimated: `0`
|
||||||
// Minimum execution time: 10_655_000 picoseconds.
|
// Minimum execution time: 10_418_000 picoseconds.
|
||||||
Weight::from_parts(10_827_000, 0)
|
Weight::from_parts(10_625_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 0))
|
.saturating_add(Weight::from_parts(0, 0))
|
||||||
}
|
}
|
||||||
/// Storage: XcmPallet SupportedVersion (r:0 w:1)
|
/// Storage: XcmPallet SupportedVersion (r:0 w:1)
|
||||||
@@ -97,8 +100,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `0`
|
// Measured: `0`
|
||||||
// Estimated: `0`
|
// Estimated: `0`
|
||||||
// Minimum execution time: 10_442_000 picoseconds.
|
// Minimum execution time: 10_336_000 picoseconds.
|
||||||
Weight::from_parts(10_716_000, 0)
|
Weight::from_parts(10_725_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 0))
|
.saturating_add(Weight::from_parts(0, 0))
|
||||||
.saturating_add(T::DbWeight::get().writes(1))
|
.saturating_add(T::DbWeight::get().writes(1))
|
||||||
}
|
}
|
||||||
@@ -108,8 +111,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `0`
|
// Measured: `0`
|
||||||
// Estimated: `0`
|
// Estimated: `0`
|
||||||
// Minimum execution time: 3_056_000 picoseconds.
|
// Minimum execution time: 3_387_000 picoseconds.
|
||||||
Weight::from_parts(3_246_000, 0)
|
Weight::from_parts(3_515_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 0))
|
.saturating_add(Weight::from_parts(0, 0))
|
||||||
.saturating_add(T::DbWeight::get().writes(1))
|
.saturating_add(T::DbWeight::get().writes(1))
|
||||||
}
|
}
|
||||||
@@ -133,11 +136,11 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
/// Proof Skipped: XcmPallet Queries (max_values: None, max_size: None, mode: Measured)
|
/// Proof Skipped: XcmPallet Queries (max_values: None, max_size: None, mode: Measured)
|
||||||
fn force_subscribe_version_notify() -> Weight {
|
fn force_subscribe_version_notify() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `580`
|
// Measured: `585`
|
||||||
// Estimated: `25020`
|
// Estimated: `4050`
|
||||||
// Minimum execution time: 42_106_000 picoseconds.
|
// Minimum execution time: 40_120_000 picoseconds.
|
||||||
Weight::from_parts(42_782_000, 0)
|
Weight::from_parts(41_122_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 25020))
|
.saturating_add(Weight::from_parts(0, 4050))
|
||||||
.saturating_add(T::DbWeight::get().reads(8))
|
.saturating_add(T::DbWeight::get().reads(8))
|
||||||
.saturating_add(T::DbWeight::get().writes(6))
|
.saturating_add(T::DbWeight::get().writes(6))
|
||||||
}
|
}
|
||||||
@@ -159,22 +162,33 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
/// Proof Skipped: XcmPallet Queries (max_values: None, max_size: None, mode: Measured)
|
/// Proof Skipped: XcmPallet Queries (max_values: None, max_size: None, mode: Measured)
|
||||||
fn force_unsubscribe_version_notify() -> Weight {
|
fn force_unsubscribe_version_notify() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `852`
|
// Measured: `857`
|
||||||
// Estimated: `25131`
|
// Estimated: `4322`
|
||||||
// Minimum execution time: 45_010_000 picoseconds.
|
// Minimum execution time: 43_082_000 picoseconds.
|
||||||
Weight::from_parts(45_326_000, 0)
|
Weight::from_parts(44_150_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 25131))
|
.saturating_add(Weight::from_parts(0, 4322))
|
||||||
.saturating_add(T::DbWeight::get().reads(7))
|
.saturating_add(T::DbWeight::get().reads(7))
|
||||||
.saturating_add(T::DbWeight::get().writes(5))
|
.saturating_add(T::DbWeight::get().writes(5))
|
||||||
}
|
}
|
||||||
|
/// Storage: XcmPallet XcmExecutionSuspended (r:0 w:1)
|
||||||
|
/// Proof Skipped: XcmPallet XcmExecutionSuspended (max_values: Some(1), max_size: None, mode: Measured)
|
||||||
|
fn force_suspension() -> Weight {
|
||||||
|
// Proof Size summary in bytes:
|
||||||
|
// Measured: `0`
|
||||||
|
// Estimated: `0`
|
||||||
|
// Minimum execution time: 3_375_000 picoseconds.
|
||||||
|
Weight::from_parts(3_532_000, 0)
|
||||||
|
.saturating_add(Weight::from_parts(0, 0))
|
||||||
|
.saturating_add(T::DbWeight::get().writes(1))
|
||||||
|
}
|
||||||
/// Storage: XcmPallet SupportedVersion (r:4 w:2)
|
/// Storage: XcmPallet SupportedVersion (r:4 w:2)
|
||||||
/// Proof Skipped: XcmPallet SupportedVersion (max_values: None, max_size: None, mode: Measured)
|
/// Proof Skipped: XcmPallet SupportedVersion (max_values: None, max_size: None, mode: Measured)
|
||||||
fn migrate_supported_version() -> Weight {
|
fn migrate_supported_version() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `229`
|
// Measured: `229`
|
||||||
// Estimated: `11119`
|
// Estimated: `11119`
|
||||||
// Minimum execution time: 17_856_000 picoseconds.
|
// Minimum execution time: 17_470_000 picoseconds.
|
||||||
Weight::from_parts(18_388_000, 0)
|
Weight::from_parts(17_718_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 11119))
|
.saturating_add(Weight::from_parts(0, 11119))
|
||||||
.saturating_add(T::DbWeight::get().reads(4))
|
.saturating_add(T::DbWeight::get().reads(4))
|
||||||
.saturating_add(T::DbWeight::get().writes(2))
|
.saturating_add(T::DbWeight::get().writes(2))
|
||||||
@@ -185,8 +199,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `233`
|
// Measured: `233`
|
||||||
// Estimated: `11123`
|
// Estimated: `11123`
|
||||||
// Minimum execution time: 19_236_000 picoseconds.
|
// Minimum execution time: 17_235_000 picoseconds.
|
||||||
Weight::from_parts(20_053_000, 0)
|
Weight::from_parts(17_767_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 11123))
|
.saturating_add(Weight::from_parts(0, 11123))
|
||||||
.saturating_add(T::DbWeight::get().reads(4))
|
.saturating_add(T::DbWeight::get().reads(4))
|
||||||
.saturating_add(T::DbWeight::get().writes(2))
|
.saturating_add(T::DbWeight::get().writes(2))
|
||||||
@@ -197,8 +211,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `243`
|
// Measured: `243`
|
||||||
// Estimated: `13608`
|
// Estimated: `13608`
|
||||||
// Minimum execution time: 21_784_000 picoseconds.
|
// Minimum execution time: 17_793_000 picoseconds.
|
||||||
Weight::from_parts(22_509_000, 0)
|
Weight::from_parts(18_606_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 13608))
|
.saturating_add(Weight::from_parts(0, 13608))
|
||||||
.saturating_add(T::DbWeight::get().reads(5))
|
.saturating_add(T::DbWeight::get().reads(5))
|
||||||
}
|
}
|
||||||
@@ -218,11 +232,11 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
/// Proof Skipped: Dmp DownwardMessageQueueHeads (max_values: None, max_size: None, mode: Measured)
|
/// Proof Skipped: Dmp DownwardMessageQueueHeads (max_values: None, max_size: None, mode: Measured)
|
||||||
fn notify_current_targets() -> Weight {
|
fn notify_current_targets() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `650`
|
// Measured: `655`
|
||||||
// Estimated: `25340`
|
// Estimated: `6595`
|
||||||
// Minimum execution time: 44_384_000 picoseconds.
|
// Minimum execution time: 36_577_000 picoseconds.
|
||||||
Weight::from_parts(45_288_000, 0)
|
Weight::from_parts(37_312_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 25340))
|
.saturating_add(Weight::from_parts(0, 6595))
|
||||||
.saturating_add(T::DbWeight::get().reads(8))
|
.saturating_add(T::DbWeight::get().reads(8))
|
||||||
.saturating_add(T::DbWeight::get().writes(4))
|
.saturating_add(T::DbWeight::get().writes(4))
|
||||||
}
|
}
|
||||||
@@ -232,8 +246,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `272`
|
// Measured: `272`
|
||||||
// Estimated: `8687`
|
// Estimated: `8687`
|
||||||
// Minimum execution time: 10_704_000 picoseconds.
|
// Minimum execution time: 8_756_000 picoseconds.
|
||||||
Weight::from_parts(11_054_000, 0)
|
Weight::from_parts(9_029_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 8687))
|
.saturating_add(Weight::from_parts(0, 8687))
|
||||||
.saturating_add(T::DbWeight::get().reads(3))
|
.saturating_add(T::DbWeight::get().reads(3))
|
||||||
}
|
}
|
||||||
@@ -243,8 +257,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `240`
|
// Measured: `240`
|
||||||
// Estimated: `11130`
|
// Estimated: `11130`
|
||||||
// Minimum execution time: 21_567_000 picoseconds.
|
// Minimum execution time: 17_871_000 picoseconds.
|
||||||
Weight::from_parts(22_017_000, 0)
|
Weight::from_parts(18_325_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 11130))
|
.saturating_add(Weight::from_parts(0, 11130))
|
||||||
.saturating_add(T::DbWeight::get().reads(4))
|
.saturating_add(T::DbWeight::get().reads(4))
|
||||||
.saturating_add(T::DbWeight::get().writes(2))
|
.saturating_add(T::DbWeight::get().writes(2))
|
||||||
@@ -265,11 +279,11 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
/// Proof Skipped: Dmp DownwardMessageQueueHeads (max_values: None, max_size: None, mode: Measured)
|
/// Proof Skipped: Dmp DownwardMessageQueueHeads (max_values: None, max_size: None, mode: Measured)
|
||||||
fn migrate_and_notify_old_targets() -> Weight {
|
fn migrate_and_notify_old_targets() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `654`
|
// Measured: `659`
|
||||||
// Estimated: `30318`
|
// Estimated: `11549`
|
||||||
// Minimum execution time: 54_062_000 picoseconds.
|
// Minimum execution time: 43_569_000 picoseconds.
|
||||||
Weight::from_parts(54_891_000, 0)
|
Weight::from_parts(44_261_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 30318))
|
.saturating_add(Weight::from_parts(0, 11549))
|
||||||
.saturating_add(T::DbWeight::get().reads(10))
|
.saturating_add(T::DbWeight::get().reads(10))
|
||||||
.saturating_add(T::DbWeight::get().writes(5))
|
.saturating_add(T::DbWeight::get().writes(5))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,25 +13,28 @@
|
|||||||
|
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
//! Autogenerated weights for `pallet_xcm`
|
//! Autogenerated weights for `pallet_xcm`
|
||||||
//!
|
//!
|
||||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||||
//! DATE: 2023-03-15, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
//! DATE: 2023-04-19, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||||
//! WORST CASE MAP SIZE: `1000000`
|
//! WORST CASE MAP SIZE: `1000000`
|
||||||
//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024
|
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024
|
||||||
|
|
||||||
// Executed Command:
|
// Executed Command:
|
||||||
// ./target/production/polkadot
|
// target/production/polkadot
|
||||||
// benchmark
|
// benchmark
|
||||||
// pallet
|
// pallet
|
||||||
// --chain=westend-dev
|
|
||||||
// --steps=50
|
// --steps=50
|
||||||
// --repeat=20
|
// --repeat=20
|
||||||
// --pallet=pallet_xcm
|
|
||||||
// --extrinsic=*
|
// --extrinsic=*
|
||||||
// --execution=wasm
|
// --execution=wasm
|
||||||
// --wasm-execution=compiled
|
// --wasm-execution=compiled
|
||||||
|
// --heap-pages=4096
|
||||||
|
// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/polkadot/.git/.artifacts/bench.json
|
||||||
|
// --pallet=pallet_xcm
|
||||||
|
// --chain=westend-dev
|
||||||
// --header=./file_header.txt
|
// --header=./file_header.txt
|
||||||
// --output=./runtime/westend/src/weights/
|
// --output=./runtime/westend/src/weights/
|
||||||
|
|
||||||
@@ -40,7 +43,7 @@
|
|||||||
#![allow(unused_imports)]
|
#![allow(unused_imports)]
|
||||||
|
|
||||||
use frame_support::{traits::Get, weights::Weight};
|
use frame_support::{traits::Get, weights::Weight};
|
||||||
use sp_std::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
|
|
||||||
/// Weight functions for `pallet_xcm`.
|
/// Weight functions for `pallet_xcm`.
|
||||||
pub struct WeightInfo<T>(PhantomData<T>);
|
pub struct WeightInfo<T>(PhantomData<T>);
|
||||||
@@ -58,10 +61,10 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
fn send() -> Weight {
|
fn send() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `169`
|
// Measured: `169`
|
||||||
// Estimated: `14210`
|
// Estimated: `3634`
|
||||||
// Minimum execution time: 30_377_000 picoseconds.
|
// Minimum execution time: 30_115_000 picoseconds.
|
||||||
Weight::from_parts(30_906_000, 0)
|
Weight::from_parts(30_754_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 14210))
|
.saturating_add(Weight::from_parts(0, 3634))
|
||||||
.saturating_add(T::DbWeight::get().reads(5))
|
.saturating_add(T::DbWeight::get().reads(5))
|
||||||
.saturating_add(T::DbWeight::get().writes(3))
|
.saturating_add(T::DbWeight::get().writes(3))
|
||||||
}
|
}
|
||||||
@@ -69,16 +72,16 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `0`
|
// Measured: `0`
|
||||||
// Estimated: `0`
|
// Estimated: `0`
|
||||||
// Minimum execution time: 20_605_000 picoseconds.
|
// Minimum execution time: 21_511_000 picoseconds.
|
||||||
Weight::from_parts(20_951_000, 0)
|
Weight::from_parts(21_766_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 0))
|
.saturating_add(Weight::from_parts(0, 0))
|
||||||
}
|
}
|
||||||
fn reserve_transfer_assets() -> Weight {
|
fn reserve_transfer_assets() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `0`
|
// Measured: `0`
|
||||||
// Estimated: `0`
|
// Estimated: `0`
|
||||||
// Minimum execution time: 20_055_000 picoseconds.
|
// Minimum execution time: 20_678_000 picoseconds.
|
||||||
Weight::from_parts(20_427_000, 0)
|
Weight::from_parts(21_141_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 0))
|
.saturating_add(Weight::from_parts(0, 0))
|
||||||
}
|
}
|
||||||
/// Storage: Benchmark Override (r:0 w:0)
|
/// Storage: Benchmark Override (r:0 w:0)
|
||||||
@@ -97,8 +100,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `0`
|
// Measured: `0`
|
||||||
// Estimated: `0`
|
// Estimated: `0`
|
||||||
// Minimum execution time: 9_682_000 picoseconds.
|
// Minimum execution time: 10_345_000 picoseconds.
|
||||||
Weight::from_parts(10_137_000, 0)
|
Weight::from_parts(10_700_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 0))
|
.saturating_add(Weight::from_parts(0, 0))
|
||||||
.saturating_add(T::DbWeight::get().writes(1))
|
.saturating_add(T::DbWeight::get().writes(1))
|
||||||
}
|
}
|
||||||
@@ -108,8 +111,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `0`
|
// Measured: `0`
|
||||||
// Estimated: `0`
|
// Estimated: `0`
|
||||||
// Minimum execution time: 3_064_000 picoseconds.
|
// Minimum execution time: 3_317_000 picoseconds.
|
||||||
Weight::from_parts(3_201_000, 0)
|
Weight::from_parts(3_432_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 0))
|
.saturating_add(Weight::from_parts(0, 0))
|
||||||
.saturating_add(T::DbWeight::get().writes(1))
|
.saturating_add(T::DbWeight::get().writes(1))
|
||||||
}
|
}
|
||||||
@@ -132,10 +135,10 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
fn force_subscribe_version_notify() -> Weight {
|
fn force_subscribe_version_notify() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `169`
|
// Measured: `169`
|
||||||
// Estimated: `19667`
|
// Estimated: `3634`
|
||||||
// Minimum execution time: 35_049_000 picoseconds.
|
// Minimum execution time: 34_794_000 picoseconds.
|
||||||
Weight::from_parts(35_549_000, 0)
|
Weight::from_parts(35_424_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 19667))
|
.saturating_add(Weight::from_parts(0, 3634))
|
||||||
.saturating_add(T::DbWeight::get().reads(7))
|
.saturating_add(T::DbWeight::get().reads(7))
|
||||||
.saturating_add(T::DbWeight::get().writes(6))
|
.saturating_add(T::DbWeight::get().writes(6))
|
||||||
}
|
}
|
||||||
@@ -156,21 +159,32 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
fn force_unsubscribe_version_notify() -> Weight {
|
fn force_unsubscribe_version_notify() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `326`
|
// Measured: `326`
|
||||||
// Estimated: `19112`
|
// Estimated: `3791`
|
||||||
// Minimum execution time: 35_083_000 picoseconds.
|
// Minimum execution time: 35_678_000 picoseconds.
|
||||||
Weight::from_parts(35_580_000, 0)
|
Weight::from_parts(36_056_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 19112))
|
.saturating_add(Weight::from_parts(0, 3791))
|
||||||
.saturating_add(T::DbWeight::get().reads(6))
|
.saturating_add(T::DbWeight::get().reads(6))
|
||||||
.saturating_add(T::DbWeight::get().writes(5))
|
.saturating_add(T::DbWeight::get().writes(5))
|
||||||
}
|
}
|
||||||
|
/// Storage: XcmPallet XcmExecutionSuspended (r:0 w:1)
|
||||||
|
/// Proof Skipped: XcmPallet XcmExecutionSuspended (max_values: Some(1), max_size: None, mode: Measured)
|
||||||
|
fn force_suspension() -> Weight {
|
||||||
|
// Proof Size summary in bytes:
|
||||||
|
// Measured: `0`
|
||||||
|
// Estimated: `0`
|
||||||
|
// Minimum execution time: 3_271_000 picoseconds.
|
||||||
|
Weight::from_parts(3_404_000, 0)
|
||||||
|
.saturating_add(Weight::from_parts(0, 0))
|
||||||
|
.saturating_add(T::DbWeight::get().writes(1))
|
||||||
|
}
|
||||||
/// Storage: XcmPallet SupportedVersion (r:4 w:2)
|
/// Storage: XcmPallet SupportedVersion (r:4 w:2)
|
||||||
/// Proof Skipped: XcmPallet SupportedVersion (max_values: None, max_size: None, mode: Measured)
|
/// Proof Skipped: XcmPallet SupportedVersion (max_values: None, max_size: None, mode: Measured)
|
||||||
fn migrate_supported_version() -> Weight {
|
fn migrate_supported_version() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `229`
|
// Measured: `229`
|
||||||
// Estimated: `11119`
|
// Estimated: `11119`
|
||||||
// Minimum execution time: 16_113_000 picoseconds.
|
// Minimum execution time: 16_601_000 picoseconds.
|
||||||
Weight::from_parts(16_592_000, 0)
|
Weight::from_parts(16_888_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 11119))
|
.saturating_add(Weight::from_parts(0, 11119))
|
||||||
.saturating_add(T::DbWeight::get().reads(4))
|
.saturating_add(T::DbWeight::get().reads(4))
|
||||||
.saturating_add(T::DbWeight::get().writes(2))
|
.saturating_add(T::DbWeight::get().writes(2))
|
||||||
@@ -181,8 +195,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `233`
|
// Measured: `233`
|
||||||
// Estimated: `11123`
|
// Estimated: `11123`
|
||||||
// Minimum execution time: 18_071_000 picoseconds.
|
// Minimum execution time: 16_714_000 picoseconds.
|
||||||
Weight::from_parts(18_527_000, 0)
|
Weight::from_parts(17_048_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 11123))
|
.saturating_add(Weight::from_parts(0, 11123))
|
||||||
.saturating_add(T::DbWeight::get().reads(4))
|
.saturating_add(T::DbWeight::get().reads(4))
|
||||||
.saturating_add(T::DbWeight::get().writes(2))
|
.saturating_add(T::DbWeight::get().writes(2))
|
||||||
@@ -193,8 +207,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `243`
|
// Measured: `243`
|
||||||
// Estimated: `13608`
|
// Estimated: `13608`
|
||||||
// Minimum execution time: 18_498_000 picoseconds.
|
// Minimum execution time: 17_552_000 picoseconds.
|
||||||
Weight::from_parts(19_091_000, 0)
|
Weight::from_parts(17_860_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 13608))
|
.saturating_add(Weight::from_parts(0, 13608))
|
||||||
.saturating_add(T::DbWeight::get().reads(5))
|
.saturating_add(T::DbWeight::get().reads(5))
|
||||||
}
|
}
|
||||||
@@ -213,10 +227,10 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
fn notify_current_targets() -> Weight {
|
fn notify_current_targets() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `239`
|
// Measured: `239`
|
||||||
// Estimated: `20739`
|
// Estimated: `6179`
|
||||||
// Minimum execution time: 31_568_000 picoseconds.
|
// Minimum execution time: 31_655_000 picoseconds.
|
||||||
Weight::from_parts(32_163_000, 0)
|
Weight::from_parts(32_201_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 20739))
|
.saturating_add(Weight::from_parts(0, 6179))
|
||||||
.saturating_add(T::DbWeight::get().reads(7))
|
.saturating_add(T::DbWeight::get().reads(7))
|
||||||
.saturating_add(T::DbWeight::get().writes(4))
|
.saturating_add(T::DbWeight::get().writes(4))
|
||||||
}
|
}
|
||||||
@@ -226,8 +240,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `272`
|
// Measured: `272`
|
||||||
// Estimated: `8687`
|
// Estimated: `8687`
|
||||||
// Minimum execution time: 9_139_000 picoseconds.
|
// Minimum execution time: 8_969_000 picoseconds.
|
||||||
Weight::from_parts(9_619_000, 0)
|
Weight::from_parts(9_314_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 8687))
|
.saturating_add(Weight::from_parts(0, 8687))
|
||||||
.saturating_add(T::DbWeight::get().reads(3))
|
.saturating_add(T::DbWeight::get().reads(3))
|
||||||
}
|
}
|
||||||
@@ -237,8 +251,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `240`
|
// Measured: `240`
|
||||||
// Estimated: `11130`
|
// Estimated: `11130`
|
||||||
// Minimum execution time: 16_944_000 picoseconds.
|
// Minimum execution time: 17_142_000 picoseconds.
|
||||||
Weight::from_parts(17_505_000, 0)
|
Weight::from_parts(17_694_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 11130))
|
.saturating_add(Weight::from_parts(0, 11130))
|
||||||
.saturating_add(T::DbWeight::get().reads(4))
|
.saturating_add(T::DbWeight::get().reads(4))
|
||||||
.saturating_add(T::DbWeight::get().writes(2))
|
.saturating_add(T::DbWeight::get().writes(2))
|
||||||
@@ -258,10 +272,10 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
|
|||||||
fn migrate_and_notify_old_targets() -> Weight {
|
fn migrate_and_notify_old_targets() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `243`
|
// Measured: `243`
|
||||||
// Estimated: `25713`
|
// Estimated: `11133`
|
||||||
// Minimum execution time: 38_715_000 picoseconds.
|
// Minimum execution time: 38_257_000 picoseconds.
|
||||||
Weight::from_parts(39_473_000, 0)
|
Weight::from_parts(39_042_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 25713))
|
.saturating_add(Weight::from_parts(0, 11133))
|
||||||
.saturating_add(T::DbWeight::get().reads(9))
|
.saturating_add(T::DbWeight::get().reads(9))
|
||||||
.saturating_add(T::DbWeight::get().writes(5))
|
.saturating_add(T::DbWeight::get().writes(5))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,6 +115,8 @@ benchmarks! {
|
|||||||
let _ = Pallet::<T>::request_version_notify(loc);
|
let _ = Pallet::<T>::request_version_notify(loc);
|
||||||
}: _(RawOrigin::Root, Box::new(versioned_loc))
|
}: _(RawOrigin::Root, Box::new(versioned_loc))
|
||||||
|
|
||||||
|
force_suspension {}: _(RawOrigin::Root, true)
|
||||||
|
|
||||||
migrate_supported_version {
|
migrate_supported_version {
|
||||||
let old_version = XCM_VERSION - 1;
|
let old_version = XCM_VERSION - 1;
|
||||||
let loc = VersionedMultiLocation::from(MultiLocation::from(Parent));
|
let loc = VersionedMultiLocation::from(MultiLocation::from(Parent));
|
||||||
|
|||||||
@@ -52,7 +52,8 @@ use frame_system::pallet_prelude::*;
|
|||||||
pub use pallet::*;
|
pub use pallet::*;
|
||||||
use xcm_executor::{
|
use xcm_executor::{
|
||||||
traits::{
|
traits::{
|
||||||
ClaimAssets, DropAssets, MatchesFungible, OnResponse, VersionChangeNotifier, WeightBounds,
|
CheckSuspension, ClaimAssets, DropAssets, MatchesFungible, OnResponse,
|
||||||
|
VersionChangeNotifier, WeightBounds,
|
||||||
},
|
},
|
||||||
Assets,
|
Assets,
|
||||||
};
|
};
|
||||||
@@ -66,6 +67,7 @@ pub trait WeightInfo {
|
|||||||
fn force_default_xcm_version() -> Weight;
|
fn force_default_xcm_version() -> Weight;
|
||||||
fn force_subscribe_version_notify() -> Weight;
|
fn force_subscribe_version_notify() -> Weight;
|
||||||
fn force_unsubscribe_version_notify() -> Weight;
|
fn force_unsubscribe_version_notify() -> Weight;
|
||||||
|
fn force_suspension() -> Weight;
|
||||||
fn migrate_supported_version() -> Weight;
|
fn migrate_supported_version() -> Weight;
|
||||||
fn migrate_version_notifiers() -> Weight;
|
fn migrate_version_notifiers() -> Weight;
|
||||||
fn already_notified_target() -> Weight;
|
fn already_notified_target() -> Weight;
|
||||||
@@ -110,6 +112,10 @@ impl WeightInfo for TestWeightInfo {
|
|||||||
Weight::from_parts(100_000_000, 0)
|
Weight::from_parts(100_000_000, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn force_suspension() -> Weight {
|
||||||
|
Weight::from_parts(100_000_000, 0)
|
||||||
|
}
|
||||||
|
|
||||||
fn migrate_supported_version() -> Weight {
|
fn migrate_supported_version() -> Weight {
|
||||||
Weight::from_parts(100_000_000, 0)
|
Weight::from_parts(100_000_000, 0)
|
||||||
}
|
}
|
||||||
@@ -612,6 +618,10 @@ pub mod pallet {
|
|||||||
OptionQuery,
|
OptionQuery,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
|
/// Global suspension state of the XCM executor.
|
||||||
|
#[pallet::storage]
|
||||||
|
pub(super) type XcmExecutionSuspended<T: Config> = StorageValue<_, bool, ValueQuery>;
|
||||||
|
|
||||||
#[pallet::genesis_config]
|
#[pallet::genesis_config]
|
||||||
pub struct GenesisConfig {
|
pub struct GenesisConfig {
|
||||||
/// The default version to encode outgoing XCM messages with.
|
/// The default version to encode outgoing XCM messages with.
|
||||||
@@ -908,7 +918,7 @@ pub mod pallet {
|
|||||||
/// Extoll that a particular destination can be communicated with through a particular
|
/// Extoll that a particular destination can be communicated with through a particular
|
||||||
/// version of XCM.
|
/// version of XCM.
|
||||||
///
|
///
|
||||||
/// - `origin`: Must be Root.
|
/// - `origin`: Must be an origin specified by AdminOrigin.
|
||||||
/// - `location`: The destination that is being described.
|
/// - `location`: The destination that is being described.
|
||||||
/// - `xcm_version`: The latest version of XCM that `location` supports.
|
/// - `xcm_version`: The latest version of XCM that `location` supports.
|
||||||
#[pallet::call_index(4)]
|
#[pallet::call_index(4)]
|
||||||
@@ -932,7 +942,7 @@ pub mod pallet {
|
|||||||
/// Set a safe XCM version (the version that XCM should be encoded with if the most recent
|
/// Set a safe XCM version (the version that XCM should be encoded with if the most recent
|
||||||
/// version a destination can accept is unknown).
|
/// version a destination can accept is unknown).
|
||||||
///
|
///
|
||||||
/// - `origin`: Must be Root.
|
/// - `origin`: Must be an origin specified by AdminOrigin.
|
||||||
/// - `maybe_xcm_version`: The default XCM encoding version, or `None` to disable.
|
/// - `maybe_xcm_version`: The default XCM encoding version, or `None` to disable.
|
||||||
#[pallet::call_index(5)]
|
#[pallet::call_index(5)]
|
||||||
#[pallet::weight(T::WeightInfo::force_default_xcm_version())]
|
#[pallet::weight(T::WeightInfo::force_default_xcm_version())]
|
||||||
@@ -947,7 +957,7 @@ pub mod pallet {
|
|||||||
|
|
||||||
/// Ask a location to notify us regarding their XCM version and any changes to it.
|
/// Ask a location to notify us regarding their XCM version and any changes to it.
|
||||||
///
|
///
|
||||||
/// - `origin`: Must be Root.
|
/// - `origin`: Must be an origin specified by AdminOrigin.
|
||||||
/// - `location`: The location to which we should subscribe for XCM version notifications.
|
/// - `location`: The location to which we should subscribe for XCM version notifications.
|
||||||
#[pallet::call_index(6)]
|
#[pallet::call_index(6)]
|
||||||
#[pallet::weight(T::WeightInfo::force_subscribe_version_notify())]
|
#[pallet::weight(T::WeightInfo::force_subscribe_version_notify())]
|
||||||
@@ -970,7 +980,7 @@ pub mod pallet {
|
|||||||
/// Require that a particular destination should no longer notify us regarding any XCM
|
/// Require that a particular destination should no longer notify us regarding any XCM
|
||||||
/// version changes.
|
/// version changes.
|
||||||
///
|
///
|
||||||
/// - `origin`: Must be Root.
|
/// - `origin`: Must be an origin specified by AdminOrigin.
|
||||||
/// - `location`: The location to which we are currently subscribed for XCM version
|
/// - `location`: The location to which we are currently subscribed for XCM version
|
||||||
/// notifications which we no longer desire.
|
/// notifications which we no longer desire.
|
||||||
#[pallet::call_index(7)]
|
#[pallet::call_index(7)]
|
||||||
@@ -1092,6 +1102,18 @@ pub mod pallet {
|
|||||||
Some(weight_limit),
|
Some(weight_limit),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set or unset the global suspension state of the XCM executor.
|
||||||
|
///
|
||||||
|
/// - `origin`: Must be an origin specified by AdminOrigin.
|
||||||
|
/// - `suspended`: `true` to suspend, `false` to resume.
|
||||||
|
#[pallet::call_index(10)]
|
||||||
|
#[pallet::weight(T::WeightInfo::force_suspension())]
|
||||||
|
pub fn force_suspension(origin: OriginFor<T>, suspended: bool) -> DispatchResult {
|
||||||
|
T::AdminOrigin::ensure_origin(origin)?;
|
||||||
|
XcmExecutionSuspended::<T>::set(suspended);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2044,6 +2066,17 @@ impl<T: Config> OnResponse for Pallet<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: Config> CheckSuspension for Pallet<T> {
|
||||||
|
fn is_suspended<Call>(
|
||||||
|
_origin: &MultiLocation,
|
||||||
|
_instructions: &mut [Instruction<Call>],
|
||||||
|
_max_weight: Weight,
|
||||||
|
_weight_credit: &mut Weight,
|
||||||
|
) -> bool {
|
||||||
|
XcmExecutionSuspended::<T>::get()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Ensure that the origin `o` represents an XCM (`Transact`) origin.
|
/// Ensure that the origin `o` represents an XCM (`Transact`) origin.
|
||||||
///
|
///
|
||||||
/// Returns `Ok` with the location of the XCM sender or an `Err` otherwise.
|
/// Returns `Ok` with the location of the XCM sender or an `Err` otherwise.
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
use core::ops::ControlFlow;
|
|
||||||
use derivative::Derivative;
|
use derivative::Derivative;
|
||||||
use parity_scale_codec::{Decode, Encode, Error as CodecError, Input, MaxEncodedLen};
|
use parity_scale_codec::{Decode, Encode, Error as CodecError, Input, MaxEncodedLen};
|
||||||
use scale_info::TypeInfo;
|
use scale_info::TypeInfo;
|
||||||
@@ -51,89 +50,6 @@ pub const MAX_XCM_DECODE_DEPTH: u32 = 8;
|
|||||||
/// A version of XCM.
|
/// A version of XCM.
|
||||||
pub type Version = u32;
|
pub type Version = u32;
|
||||||
|
|
||||||
/// Creates an instruction matcher from an XCM. Since XCM versions differ, we need to make a trait
|
|
||||||
/// here to unify the interfaces among them.
|
|
||||||
pub trait CreateMatcher {
|
|
||||||
/// The concrete matcher type.
|
|
||||||
type Matcher;
|
|
||||||
|
|
||||||
/// Method that creates and returns the matcher type from `Self`.
|
|
||||||
fn matcher(self) -> Self::Matcher;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// API that allows to pattern-match against anything that is contained within an XCM.
|
|
||||||
///
|
|
||||||
/// The intended usage of the matcher API is to enable the ability to chain successive methods of
|
|
||||||
/// this trait together, along with the ? operator for the purpose of facilitating the writing,
|
|
||||||
/// maintenance and auditability of XCM barriers.
|
|
||||||
///
|
|
||||||
/// Example:
|
|
||||||
/// ```rust
|
|
||||||
/// use xcm::{
|
|
||||||
/// v3::{Instruction, Matcher},
|
|
||||||
/// CreateMatcher, MatchXcm,
|
|
||||||
/// };
|
|
||||||
///
|
|
||||||
/// let mut msg = [Instruction::<()>::ClearOrigin];
|
|
||||||
/// let res = msg
|
|
||||||
/// .matcher()
|
|
||||||
/// .assert_remaining_insts(1)?
|
|
||||||
/// .match_next_inst(|inst| match inst {
|
|
||||||
/// Instruction::<()>::ClearOrigin => Ok(()),
|
|
||||||
/// _ => Err(()),
|
|
||||||
/// });
|
|
||||||
/// assert!(res.is_ok());
|
|
||||||
///
|
|
||||||
/// Ok::<(), ()>(())
|
|
||||||
/// ```
|
|
||||||
pub trait MatchXcm {
|
|
||||||
/// The concrete instruction type. Necessary to specify as it changes between XCM versions.
|
|
||||||
type Inst;
|
|
||||||
/// The `MultiLocation` type. Necessary to specify as it changes between XCM versions.
|
|
||||||
type Loc;
|
|
||||||
/// The error type to throw when errors happen during matching.
|
|
||||||
type Error;
|
|
||||||
|
|
||||||
/// Returns success if the number of instructions that still have not been iterated over
|
|
||||||
/// equals `n`, otherwise returns an error.
|
|
||||||
fn assert_remaining_insts(self, n: usize) -> Result<Self, Self::Error>
|
|
||||||
where
|
|
||||||
Self: Sized;
|
|
||||||
|
|
||||||
/// Accepts a closure `f` that contains an argument signifying the next instruction to be
|
|
||||||
/// iterated over. The closure can then be used to check whether the instruction matches a
|
|
||||||
/// given condition, and can also be used to mutate the fields of an instruction.
|
|
||||||
///
|
|
||||||
/// The closure `f` returns success when the instruction passes the condition, otherwise it
|
|
||||||
/// returns an error, which will ultimately be returned by this function.
|
|
||||||
fn match_next_inst<F>(self, f: F) -> Result<Self, Self::Error>
|
|
||||||
where
|
|
||||||
Self: Sized,
|
|
||||||
F: FnMut(&mut Self::Inst) -> Result<(), Self::Error>;
|
|
||||||
|
|
||||||
/// Attempts to continuously iterate through the instructions while applying `f` to each of
|
|
||||||
/// them, until either the last instruction or `cond` returns false.
|
|
||||||
///
|
|
||||||
/// If `f` returns an error, then iteration halts and the function returns that error.
|
|
||||||
/// Otherwise, `f` returns a `ControlFlow` which signifies whether the iteration breaks or
|
|
||||||
/// continues.
|
|
||||||
fn match_next_inst_while<C, F>(self, cond: C, f: F) -> Result<Self, Self::Error>
|
|
||||||
where
|
|
||||||
Self: Sized,
|
|
||||||
C: Fn(&Self::Inst) -> bool,
|
|
||||||
F: FnMut(&mut Self::Inst) -> Result<ControlFlow<()>, Self::Error>;
|
|
||||||
|
|
||||||
/// Iterate instructions forward until `cond` returns false. When there are no more instructions
|
|
||||||
/// to be read, an error is returned.
|
|
||||||
fn skip_inst_while<C>(self, cond: C) -> Result<Self, Self::Error>
|
|
||||||
where
|
|
||||||
Self: Sized,
|
|
||||||
C: Fn(&Self::Inst) -> bool,
|
|
||||||
{
|
|
||||||
Self::match_next_inst_while(self, cond, |_| Ok(ControlFlow::Continue(())))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Eq, PartialEq, Debug)]
|
#[derive(Clone, Eq, PartialEq, Debug)]
|
||||||
pub enum Unsupported {}
|
pub enum Unsupported {}
|
||||||
impl Encode for Unsupported {}
|
impl Encode for Unsupported {}
|
||||||
|
|||||||
@@ -1,109 +0,0 @@
|
|||||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
|
||||||
// This file is part of Polkadot.
|
|
||||||
|
|
||||||
// Substrate 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.
|
|
||||||
|
|
||||||
// Substrate 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 Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
//! XCM matcher API, used primarily for writing barrier conditions.
|
|
||||||
|
|
||||||
use super::{Instruction, MultiLocation};
|
|
||||||
use crate::{CreateMatcher, MatchXcm};
|
|
||||||
use core::ops::ControlFlow;
|
|
||||||
|
|
||||||
impl<'a, Call> CreateMatcher for &'a mut [Instruction<Call>] {
|
|
||||||
type Matcher = Matcher<'a, Call>;
|
|
||||||
|
|
||||||
fn matcher(self) -> Self::Matcher {
|
|
||||||
let total_inst = self.len();
|
|
||||||
|
|
||||||
Matcher { xcm: self, current_idx: 0, total_inst }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Struct created from calling `fn matcher()` on a mutable slice of `Instruction`s.
|
|
||||||
///
|
|
||||||
/// Implements `MatchXcm` to allow an iterator-like API to match against each `Instruction`
|
|
||||||
/// contained within the slice, which facilitates the building of XCM barriers.
|
|
||||||
pub struct Matcher<'a, Call> {
|
|
||||||
pub(crate) xcm: &'a mut [Instruction<Call>],
|
|
||||||
pub(crate) current_idx: usize,
|
|
||||||
pub(crate) total_inst: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, Call> MatchXcm for Matcher<'a, Call> {
|
|
||||||
type Error = ();
|
|
||||||
type Inst = Instruction<Call>;
|
|
||||||
type Loc = MultiLocation;
|
|
||||||
|
|
||||||
fn assert_remaining_insts(self, n: usize) -> Result<Self, Self::Error>
|
|
||||||
where
|
|
||||||
Self: Sized,
|
|
||||||
{
|
|
||||||
if self.total_inst - self.current_idx != n {
|
|
||||||
return Err(())
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn match_next_inst<F>(mut self, mut f: F) -> Result<Self, Self::Error>
|
|
||||||
where
|
|
||||||
Self: Sized,
|
|
||||||
F: FnMut(&mut Self::Inst) -> Result<(), Self::Error>,
|
|
||||||
{
|
|
||||||
if self.current_idx < self.total_inst {
|
|
||||||
f(&mut self.xcm[self.current_idx])?;
|
|
||||||
self.current_idx += 1;
|
|
||||||
Ok(self)
|
|
||||||
} else {
|
|
||||||
Err(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn match_next_inst_while<C, F>(mut self, cond: C, mut f: F) -> Result<Self, Self::Error>
|
|
||||||
where
|
|
||||||
Self: Sized,
|
|
||||||
C: Fn(&Self::Inst) -> bool,
|
|
||||||
F: FnMut(&mut Self::Inst) -> Result<ControlFlow<()>, Self::Error>,
|
|
||||||
{
|
|
||||||
if self.current_idx >= self.total_inst {
|
|
||||||
return Err(())
|
|
||||||
}
|
|
||||||
|
|
||||||
while self.current_idx < self.total_inst && cond(&self.xcm[self.current_idx]) {
|
|
||||||
if let ControlFlow::Break(()) = f(&mut self.xcm[self.current_idx])? {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
self.current_idx += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(self)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
use crate::v3::prelude::*;
|
|
||||||
use alloc::{vec, vec::Vec};
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn match_next_inst_while_works() {
|
|
||||||
let mut xcm: Vec<Instruction<()>> = vec![ClearOrigin];
|
|
||||||
|
|
||||||
let _ = xcm
|
|
||||||
.matcher()
|
|
||||||
.match_next_inst_while(|_| true, |_| Ok(ControlFlow::Continue(())))
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -34,14 +34,12 @@ use scale_info::TypeInfo;
|
|||||||
|
|
||||||
mod junction;
|
mod junction;
|
||||||
pub(crate) mod junctions;
|
pub(crate) mod junctions;
|
||||||
mod matcher;
|
|
||||||
mod multiasset;
|
mod multiasset;
|
||||||
mod multilocation;
|
mod multilocation;
|
||||||
mod traits;
|
mod traits;
|
||||||
|
|
||||||
pub use junction::{BodyId, BodyPart, Junction, NetworkId};
|
pub use junction::{BodyId, BodyPart, Junction, NetworkId};
|
||||||
pub use junctions::Junctions;
|
pub use junctions::Junctions;
|
||||||
pub use matcher::Matcher;
|
|
||||||
pub use multiasset::{
|
pub use multiasset::{
|
||||||
AssetId, AssetInstance, Fungibility, MultiAsset, MultiAssetFilter, MultiAssets,
|
AssetId, AssetInstance, Fungibility, MultiAsset, MultiAssetFilter, MultiAssets,
|
||||||
WildFungibility, WildMultiAsset,
|
WildFungibility, WildMultiAsset,
|
||||||
|
|||||||
@@ -16,23 +16,21 @@
|
|||||||
|
|
||||||
//! Various implementations for `ShouldExecute`.
|
//! Various implementations for `ShouldExecute`.
|
||||||
|
|
||||||
|
use crate::{CreateMatcher, MatchXcm};
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
ensure,
|
ensure,
|
||||||
traits::{Contains, Get},
|
traits::{Contains, Get, ProcessMessageError},
|
||||||
};
|
};
|
||||||
use polkadot_parachain::primitives::IsSystem;
|
use polkadot_parachain::primitives::IsSystem;
|
||||||
use sp_std::{cell::Cell, marker::PhantomData, ops::ControlFlow, result::Result};
|
use sp_std::{cell::Cell, marker::PhantomData, ops::ControlFlow, result::Result};
|
||||||
use xcm::{
|
use xcm::latest::{
|
||||||
latest::{
|
|
||||||
Instruction::{self, *},
|
Instruction::{self, *},
|
||||||
InteriorMultiLocation, Junction, Junctions,
|
InteriorMultiLocation, Junction, Junctions,
|
||||||
Junctions::X1,
|
Junctions::X1,
|
||||||
MultiLocation, Weight,
|
MultiLocation, Weight,
|
||||||
WeightLimit::*,
|
WeightLimit::*,
|
||||||
},
|
|
||||||
CreateMatcher, MatchXcm,
|
|
||||||
};
|
};
|
||||||
use xcm_executor::traits::{OnResponse, ShouldExecute};
|
use xcm_executor::traits::{CheckSuspension, OnResponse, ShouldExecute};
|
||||||
|
|
||||||
/// Execution barrier that just takes `max_weight` from `weight_credit`.
|
/// Execution barrier that just takes `max_weight` from `weight_credit`.
|
||||||
///
|
///
|
||||||
@@ -46,13 +44,15 @@ impl ShouldExecute for TakeWeightCredit {
|
|||||||
_instructions: &mut [Instruction<RuntimeCall>],
|
_instructions: &mut [Instruction<RuntimeCall>],
|
||||||
max_weight: Weight,
|
max_weight: Weight,
|
||||||
weight_credit: &mut Weight,
|
weight_credit: &mut Weight,
|
||||||
) -> Result<(), ()> {
|
) -> Result<(), ProcessMessageError> {
|
||||||
log::trace!(
|
log::trace!(
|
||||||
target: "xcm::barriers",
|
target: "xcm::barriers",
|
||||||
"TakeWeightCredit origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}",
|
"TakeWeightCredit origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}",
|
||||||
_origin, _instructions, max_weight, weight_credit,
|
_origin, _instructions, max_weight, weight_credit,
|
||||||
);
|
);
|
||||||
*weight_credit = weight_credit.checked_sub(&max_weight).ok_or(())?;
|
*weight_credit = weight_credit
|
||||||
|
.checked_sub(&max_weight)
|
||||||
|
.ok_or(ProcessMessageError::Overweight(max_weight))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -69,14 +69,14 @@ impl<T: Contains<MultiLocation>> ShouldExecute for AllowTopLevelPaidExecutionFro
|
|||||||
instructions: &mut [Instruction<RuntimeCall>],
|
instructions: &mut [Instruction<RuntimeCall>],
|
||||||
max_weight: Weight,
|
max_weight: Weight,
|
||||||
_weight_credit: &mut Weight,
|
_weight_credit: &mut Weight,
|
||||||
) -> Result<(), ()> {
|
) -> Result<(), ProcessMessageError> {
|
||||||
log::trace!(
|
log::trace!(
|
||||||
target: "xcm::barriers",
|
target: "xcm::barriers",
|
||||||
"AllowTopLevelPaidExecutionFrom origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}",
|
"AllowTopLevelPaidExecutionFrom origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}",
|
||||||
origin, instructions, max_weight, _weight_credit,
|
origin, instructions, max_weight, _weight_credit,
|
||||||
);
|
);
|
||||||
|
|
||||||
ensure!(T::contains(origin), ());
|
ensure!(T::contains(origin), ProcessMessageError::Unsupported);
|
||||||
// We will read up to 5 instructions. This allows up to 3 `ClearOrigin` instructions. We
|
// We will read up to 5 instructions. This allows up to 3 `ClearOrigin` instructions. We
|
||||||
// allow for more than one since anything beyond the first is a no-op and it's conceivable
|
// allow for more than one since anything beyond the first is a no-op and it's conceivable
|
||||||
// that composition of operations might result in more than one being appended.
|
// that composition of operations might result in more than one being appended.
|
||||||
@@ -88,7 +88,7 @@ impl<T: Contains<MultiLocation>> ShouldExecute for AllowTopLevelPaidExecutionFro
|
|||||||
WithdrawAsset(..) |
|
WithdrawAsset(..) |
|
||||||
ReserveAssetDeposited(..) |
|
ReserveAssetDeposited(..) |
|
||||||
ClaimAsset { .. } => Ok(()),
|
ClaimAsset { .. } => Ok(()),
|
||||||
_ => Err(()),
|
_ => Err(ProcessMessageError::BadFormat),
|
||||||
})?
|
})?
|
||||||
.skip_inst_while(|inst| matches!(inst, ClearOrigin))?
|
.skip_inst_while(|inst| matches!(inst, ClearOrigin))?
|
||||||
.match_next_inst(|inst| match inst {
|
.match_next_inst(|inst| match inst {
|
||||||
@@ -102,7 +102,7 @@ impl<T: Contains<MultiLocation>> ShouldExecute for AllowTopLevelPaidExecutionFro
|
|||||||
*weight_limit = Limited(max_weight);
|
*weight_limit = Limited(max_weight);
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
_ => Err(()),
|
_ => Err(ProcessMessageError::Overweight(max_weight)),
|
||||||
})?;
|
})?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -167,7 +167,7 @@ impl<
|
|||||||
instructions: &mut [Instruction<Call>],
|
instructions: &mut [Instruction<Call>],
|
||||||
max_weight: Weight,
|
max_weight: Weight,
|
||||||
weight_credit: &mut Weight,
|
weight_credit: &mut Weight,
|
||||||
) -> Result<(), ()> {
|
) -> Result<(), ProcessMessageError> {
|
||||||
log::trace!(
|
log::trace!(
|
||||||
target: "xcm::barriers",
|
target: "xcm::barriers",
|
||||||
"WithComputedOrigin origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}",
|
"WithComputedOrigin origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}",
|
||||||
@@ -191,7 +191,9 @@ impl<
|
|||||||
actual_origin = X1(*new_global).relative_to(&LocalUniversal::get());
|
actual_origin = X1(*new_global).relative_to(&LocalUniversal::get());
|
||||||
},
|
},
|
||||||
DescendOrigin(j) => {
|
DescendOrigin(j) => {
|
||||||
let Ok(_) = actual_origin.append_with(*j) else { return Err(()) };
|
let Ok(_) = actual_origin.append_with(*j) else {
|
||||||
|
return Err(ProcessMessageError::Unsupported)
|
||||||
|
};
|
||||||
},
|
},
|
||||||
_ => return Ok(ControlFlow::Break(())),
|
_ => return Ok(ControlFlow::Break(())),
|
||||||
};
|
};
|
||||||
@@ -208,6 +210,28 @@ impl<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Barrier condition that allows for a `SuspensionChecker` that controls whether or not the XCM
|
||||||
|
/// executor will be suspended from executing the given XCM.
|
||||||
|
pub struct RespectSuspension<Inner, SuspensionChecker>(PhantomData<(Inner, SuspensionChecker)>);
|
||||||
|
impl<Inner, SuspensionChecker> ShouldExecute for RespectSuspension<Inner, SuspensionChecker>
|
||||||
|
where
|
||||||
|
Inner: ShouldExecute,
|
||||||
|
SuspensionChecker: CheckSuspension,
|
||||||
|
{
|
||||||
|
fn should_execute<Call>(
|
||||||
|
origin: &MultiLocation,
|
||||||
|
instructions: &mut [Instruction<Call>],
|
||||||
|
max_weight: Weight,
|
||||||
|
weight_credit: &mut Weight,
|
||||||
|
) -> Result<(), ProcessMessageError> {
|
||||||
|
if SuspensionChecker::is_suspended(origin, instructions, max_weight, weight_credit) {
|
||||||
|
Err(ProcessMessageError::Yield)
|
||||||
|
} else {
|
||||||
|
Inner::should_execute(origin, instructions, max_weight, weight_credit)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Allows execution from any origin that is contained in `T` (i.e. `T::Contains(origin)`).
|
/// Allows execution from any origin that is contained in `T` (i.e. `T::Contains(origin)`).
|
||||||
///
|
///
|
||||||
/// Use only for executions from completely trusted origins, from which no unpermissioned messages
|
/// Use only for executions from completely trusted origins, from which no unpermissioned messages
|
||||||
@@ -219,13 +243,13 @@ impl<T: Contains<MultiLocation>> ShouldExecute for AllowUnpaidExecutionFrom<T> {
|
|||||||
instructions: &mut [Instruction<RuntimeCall>],
|
instructions: &mut [Instruction<RuntimeCall>],
|
||||||
_max_weight: Weight,
|
_max_weight: Weight,
|
||||||
_weight_credit: &mut Weight,
|
_weight_credit: &mut Weight,
|
||||||
) -> Result<(), ()> {
|
) -> Result<(), ProcessMessageError> {
|
||||||
log::trace!(
|
log::trace!(
|
||||||
target: "xcm::barriers",
|
target: "xcm::barriers",
|
||||||
"AllowUnpaidExecutionFrom origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}",
|
"AllowUnpaidExecutionFrom origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}",
|
||||||
origin, instructions, _max_weight, _weight_credit,
|
origin, instructions, _max_weight, _weight_credit,
|
||||||
);
|
);
|
||||||
ensure!(T::contains(origin), ());
|
ensure!(T::contains(origin), ProcessMessageError::Unsupported);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -241,17 +265,17 @@ impl<T: Contains<MultiLocation>> ShouldExecute for AllowExplicitUnpaidExecutionF
|
|||||||
instructions: &mut [Instruction<Call>],
|
instructions: &mut [Instruction<Call>],
|
||||||
max_weight: Weight,
|
max_weight: Weight,
|
||||||
_weight_credit: &mut Weight,
|
_weight_credit: &mut Weight,
|
||||||
) -> Result<(), ()> {
|
) -> Result<(), ProcessMessageError> {
|
||||||
log::trace!(
|
log::trace!(
|
||||||
target: "xcm::barriers",
|
target: "xcm::barriers",
|
||||||
"AllowExplicitUnpaidExecutionFrom origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}",
|
"AllowExplicitUnpaidExecutionFrom origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}",
|
||||||
origin, instructions, max_weight, _weight_credit,
|
origin, instructions, max_weight, _weight_credit,
|
||||||
);
|
);
|
||||||
ensure!(T::contains(origin), ());
|
ensure!(T::contains(origin), ProcessMessageError::Unsupported);
|
||||||
instructions.matcher().match_next_inst(|inst| match inst {
|
instructions.matcher().match_next_inst(|inst| match inst {
|
||||||
UnpaidExecution { weight_limit: Limited(m), .. } if m.all_gte(max_weight) => Ok(()),
|
UnpaidExecution { weight_limit: Limited(m), .. } if m.all_gte(max_weight) => Ok(()),
|
||||||
UnpaidExecution { weight_limit: Unlimited, .. } => Ok(()),
|
UnpaidExecution { weight_limit: Unlimited, .. } => Ok(()),
|
||||||
_ => Err(()),
|
_ => Err(ProcessMessageError::Overweight(max_weight)),
|
||||||
})?;
|
})?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -277,7 +301,7 @@ impl<ResponseHandler: OnResponse> ShouldExecute for AllowKnownQueryResponses<Res
|
|||||||
instructions: &mut [Instruction<RuntimeCall>],
|
instructions: &mut [Instruction<RuntimeCall>],
|
||||||
_max_weight: Weight,
|
_max_weight: Weight,
|
||||||
_weight_credit: &mut Weight,
|
_weight_credit: &mut Weight,
|
||||||
) -> Result<(), ()> {
|
) -> Result<(), ProcessMessageError> {
|
||||||
log::trace!(
|
log::trace!(
|
||||||
target: "xcm::barriers",
|
target: "xcm::barriers",
|
||||||
"AllowKnownQueryResponses origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}",
|
"AllowKnownQueryResponses origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}",
|
||||||
@@ -290,7 +314,7 @@ impl<ResponseHandler: OnResponse> ShouldExecute for AllowKnownQueryResponses<Res
|
|||||||
QueryResponse { query_id, querier, .. }
|
QueryResponse { query_id, querier, .. }
|
||||||
if ResponseHandler::expecting_response(origin, *query_id, querier.as_ref()) =>
|
if ResponseHandler::expecting_response(origin, *query_id, querier.as_ref()) =>
|
||||||
Ok(()),
|
Ok(()),
|
||||||
_ => Err(()),
|
_ => Err(ProcessMessageError::BadFormat),
|
||||||
})?;
|
})?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -305,19 +329,19 @@ impl<T: Contains<MultiLocation>> ShouldExecute for AllowSubscriptionsFrom<T> {
|
|||||||
instructions: &mut [Instruction<RuntimeCall>],
|
instructions: &mut [Instruction<RuntimeCall>],
|
||||||
_max_weight: Weight,
|
_max_weight: Weight,
|
||||||
_weight_credit: &mut Weight,
|
_weight_credit: &mut Weight,
|
||||||
) -> Result<(), ()> {
|
) -> Result<(), ProcessMessageError> {
|
||||||
log::trace!(
|
log::trace!(
|
||||||
target: "xcm::barriers",
|
target: "xcm::barriers",
|
||||||
"AllowSubscriptionsFrom origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}",
|
"AllowSubscriptionsFrom origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}",
|
||||||
origin, instructions, _max_weight, _weight_credit,
|
origin, instructions, _max_weight, _weight_credit,
|
||||||
);
|
);
|
||||||
ensure!(T::contains(origin), ());
|
ensure!(T::contains(origin), ProcessMessageError::Unsupported);
|
||||||
instructions
|
instructions
|
||||||
.matcher()
|
.matcher()
|
||||||
.assert_remaining_insts(1)?
|
.assert_remaining_insts(1)?
|
||||||
.match_next_inst(|inst| match inst {
|
.match_next_inst(|inst| match inst {
|
||||||
SubscribeVersion { .. } | UnsubscribeVersion => Ok(()),
|
SubscribeVersion { .. } | UnsubscribeVersion => Ok(()),
|
||||||
_ => Err(()),
|
_ => Err(ProcessMessageError::BadFormat),
|
||||||
})?;
|
})?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ mod barriers;
|
|||||||
pub use barriers::{
|
pub use barriers::{
|
||||||
AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
||||||
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, IsChildSystemParachain,
|
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, IsChildSystemParachain,
|
||||||
TakeWeightCredit, WithComputedOrigin,
|
RespectSuspension, TakeWeightCredit, WithComputedOrigin,
|
||||||
};
|
};
|
||||||
|
|
||||||
mod currency_adapter;
|
mod currency_adapter;
|
||||||
@@ -76,6 +76,9 @@ pub use weight::{
|
|||||||
mod matches_token;
|
mod matches_token;
|
||||||
pub use matches_token::{IsAbstract, IsConcrete};
|
pub use matches_token::{IsAbstract, IsConcrete};
|
||||||
|
|
||||||
|
mod matcher;
|
||||||
|
pub use matcher::{CreateMatcher, MatchXcm, Matcher};
|
||||||
|
|
||||||
mod filter_asset_location;
|
mod filter_asset_location;
|
||||||
pub use filter_asset_location::{Case, NativeAsset};
|
pub use filter_asset_location::{Case, NativeAsset};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,191 @@
|
|||||||
|
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||||
|
// This file is part of Polkadot.
|
||||||
|
|
||||||
|
// Substrate 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.
|
||||||
|
|
||||||
|
// Substrate 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 Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! XCM matcher API, used primarily for writing barrier conditions.
|
||||||
|
|
||||||
|
use core::ops::ControlFlow;
|
||||||
|
use frame_support::traits::ProcessMessageError;
|
||||||
|
use xcm::latest::{Instruction, MultiLocation};
|
||||||
|
|
||||||
|
/// Creates an instruction matcher from an XCM. Since XCM versions differ, we need to make a trait
|
||||||
|
/// here to unify the interfaces among them.
|
||||||
|
pub trait CreateMatcher {
|
||||||
|
/// The concrete matcher type.
|
||||||
|
type Matcher;
|
||||||
|
|
||||||
|
/// Method that creates and returns the matcher type from `Self`.
|
||||||
|
fn matcher(self) -> Self::Matcher;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, Call> CreateMatcher for &'a mut [Instruction<Call>] {
|
||||||
|
type Matcher = Matcher<'a, Call>;
|
||||||
|
|
||||||
|
fn matcher(self) -> Self::Matcher {
|
||||||
|
let total_inst = self.len();
|
||||||
|
|
||||||
|
Matcher { xcm: self, current_idx: 0, total_inst }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// API that allows to pattern-match against anything that is contained within an XCM.
|
||||||
|
///
|
||||||
|
/// The intended usage of the matcher API is to enable the ability to chain successive methods of
|
||||||
|
/// this trait together, along with the ? operator for the purpose of facilitating the writing,
|
||||||
|
/// maintenance and auditability of XCM barriers.
|
||||||
|
///
|
||||||
|
/// Example:
|
||||||
|
/// ```rust
|
||||||
|
/// use frame_support::traits::ProcessMessageError;
|
||||||
|
/// use xcm::latest::Instruction;
|
||||||
|
/// use xcm_builder::{CreateMatcher, MatchXcm};
|
||||||
|
///
|
||||||
|
/// let mut msg = [Instruction::<()>::ClearOrigin];
|
||||||
|
/// let res = msg
|
||||||
|
/// .matcher()
|
||||||
|
/// .assert_remaining_insts(1)?
|
||||||
|
/// .match_next_inst(|inst| match inst {
|
||||||
|
/// Instruction::<()>::ClearOrigin => Ok(()),
|
||||||
|
/// _ => Err(ProcessMessageError::BadFormat),
|
||||||
|
/// });
|
||||||
|
/// assert!(res.is_ok());
|
||||||
|
///
|
||||||
|
/// Ok::<(), ProcessMessageError>(())
|
||||||
|
/// ```
|
||||||
|
pub trait MatchXcm {
|
||||||
|
/// The concrete instruction type. Necessary to specify as it changes between XCM versions.
|
||||||
|
type Inst;
|
||||||
|
/// The `MultiLocation` type. Necessary to specify as it changes between XCM versions.
|
||||||
|
type Loc;
|
||||||
|
/// The error type to throw when errors happen during matching.
|
||||||
|
type Error;
|
||||||
|
|
||||||
|
/// Returns success if the number of instructions that still have not been iterated over
|
||||||
|
/// equals `n`, otherwise returns an error.
|
||||||
|
fn assert_remaining_insts(self, n: usize) -> Result<Self, Self::Error>
|
||||||
|
where
|
||||||
|
Self: Sized;
|
||||||
|
|
||||||
|
/// Accepts a closure `f` that contains an argument signifying the next instruction to be
|
||||||
|
/// iterated over. The closure can then be used to check whether the instruction matches a
|
||||||
|
/// given condition, and can also be used to mutate the fields of an instruction.
|
||||||
|
///
|
||||||
|
/// The closure `f` returns success when the instruction passes the condition, otherwise it
|
||||||
|
/// returns an error, which will ultimately be returned by this function.
|
||||||
|
fn match_next_inst<F>(self, f: F) -> Result<Self, Self::Error>
|
||||||
|
where
|
||||||
|
Self: Sized,
|
||||||
|
F: FnMut(&mut Self::Inst) -> Result<(), Self::Error>;
|
||||||
|
|
||||||
|
/// Attempts to continuously iterate through the instructions while applying `f` to each of
|
||||||
|
/// them, until either the last instruction or `cond` returns false.
|
||||||
|
///
|
||||||
|
/// If `f` returns an error, then iteration halts and the function returns that error.
|
||||||
|
/// Otherwise, `f` returns a `ControlFlow` which signifies whether the iteration breaks or
|
||||||
|
/// continues.
|
||||||
|
fn match_next_inst_while<C, F>(self, cond: C, f: F) -> Result<Self, Self::Error>
|
||||||
|
where
|
||||||
|
Self: Sized,
|
||||||
|
C: Fn(&Self::Inst) -> bool,
|
||||||
|
F: FnMut(&mut Self::Inst) -> Result<ControlFlow<()>, Self::Error>;
|
||||||
|
|
||||||
|
/// Iterate instructions forward until `cond` returns false. When there are no more instructions
|
||||||
|
/// to be read, an error is returned.
|
||||||
|
fn skip_inst_while<C>(self, cond: C) -> Result<Self, Self::Error>
|
||||||
|
where
|
||||||
|
Self: Sized,
|
||||||
|
C: Fn(&Self::Inst) -> bool,
|
||||||
|
{
|
||||||
|
Self::match_next_inst_while(self, cond, |_| Ok(ControlFlow::Continue(())))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Struct created from calling `fn matcher()` on a mutable slice of `Instruction`s.
|
||||||
|
///
|
||||||
|
/// Implements `MatchXcm` to allow an iterator-like API to match against each `Instruction`
|
||||||
|
/// contained within the slice, which facilitates the building of XCM barriers.
|
||||||
|
pub struct Matcher<'a, Call> {
|
||||||
|
pub(crate) xcm: &'a mut [Instruction<Call>],
|
||||||
|
pub(crate) current_idx: usize,
|
||||||
|
pub(crate) total_inst: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, Call> MatchXcm for Matcher<'a, Call> {
|
||||||
|
type Error = ProcessMessageError;
|
||||||
|
type Inst = Instruction<Call>;
|
||||||
|
type Loc = MultiLocation;
|
||||||
|
|
||||||
|
fn assert_remaining_insts(self, n: usize) -> Result<Self, Self::Error>
|
||||||
|
where
|
||||||
|
Self: Sized,
|
||||||
|
{
|
||||||
|
if self.total_inst - self.current_idx != n {
|
||||||
|
return Err(ProcessMessageError::BadFormat)
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn match_next_inst<F>(mut self, mut f: F) -> Result<Self, Self::Error>
|
||||||
|
where
|
||||||
|
Self: Sized,
|
||||||
|
F: FnMut(&mut Self::Inst) -> Result<(), Self::Error>,
|
||||||
|
{
|
||||||
|
if self.current_idx < self.total_inst {
|
||||||
|
f(&mut self.xcm[self.current_idx])?;
|
||||||
|
self.current_idx += 1;
|
||||||
|
Ok(self)
|
||||||
|
} else {
|
||||||
|
Err(ProcessMessageError::BadFormat)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn match_next_inst_while<C, F>(mut self, cond: C, mut f: F) -> Result<Self, Self::Error>
|
||||||
|
where
|
||||||
|
Self: Sized,
|
||||||
|
C: Fn(&Self::Inst) -> bool,
|
||||||
|
F: FnMut(&mut Self::Inst) -> Result<ControlFlow<()>, Self::Error>,
|
||||||
|
{
|
||||||
|
if self.current_idx >= self.total_inst {
|
||||||
|
return Err(ProcessMessageError::BadFormat)
|
||||||
|
}
|
||||||
|
|
||||||
|
while self.current_idx < self.total_inst && cond(&self.xcm[self.current_idx]) {
|
||||||
|
if let ControlFlow::Break(()) = f(&mut self.xcm[self.current_idx])? {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
self.current_idx += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
use std::{vec, vec::Vec};
|
||||||
|
use xcm::latest::prelude::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn match_next_inst_while_works() {
|
||||||
|
let mut xcm: Vec<Instruction<()>> = vec![ClearOrigin];
|
||||||
|
|
||||||
|
let _ = xcm
|
||||||
|
.matcher()
|
||||||
|
.match_next_inst_while(|_| true, |_| Ok(ControlFlow::Continue(())))
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -36,7 +36,7 @@ fn take_weight_credit_barrier_should_work() {
|
|||||||
Weight::from_parts(10, 10),
|
Weight::from_parts(10, 10),
|
||||||
&mut weight_credit,
|
&mut weight_credit,
|
||||||
);
|
);
|
||||||
assert_eq!(r, Err(()));
|
assert_eq!(r, Err(ProcessMessageError::Overweight(Weight::from_parts(10, 10))));
|
||||||
assert_eq!(weight_credit, Weight::zero());
|
assert_eq!(weight_credit, Weight::zero());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ fn computed_origin_should_work() {
|
|||||||
Weight::from_parts(100, 100),
|
Weight::from_parts(100, 100),
|
||||||
&mut Weight::zero(),
|
&mut Weight::zero(),
|
||||||
);
|
);
|
||||||
assert_eq!(r, Err(()));
|
assert_eq!(r, Err(ProcessMessageError::Unsupported));
|
||||||
|
|
||||||
let r = WithComputedOrigin::<
|
let r = WithComputedOrigin::<
|
||||||
AllowTopLevelPaidExecutionFrom<IsInVec<AllowPaidFrom>>,
|
AllowTopLevelPaidExecutionFrom<IsInVec<AllowPaidFrom>>,
|
||||||
@@ -81,7 +81,7 @@ fn computed_origin_should_work() {
|
|||||||
Weight::from_parts(100, 100),
|
Weight::from_parts(100, 100),
|
||||||
&mut Weight::zero(),
|
&mut Weight::zero(),
|
||||||
);
|
);
|
||||||
assert_eq!(r, Err(()));
|
assert_eq!(r, Err(ProcessMessageError::Unsupported));
|
||||||
|
|
||||||
let r = WithComputedOrigin::<
|
let r = WithComputedOrigin::<
|
||||||
AllowTopLevelPaidExecutionFrom<IsInVec<AllowPaidFrom>>,
|
AllowTopLevelPaidExecutionFrom<IsInVec<AllowPaidFrom>>,
|
||||||
@@ -109,7 +109,7 @@ fn allow_unpaid_should_work() {
|
|||||||
Weight::from_parts(10, 10),
|
Weight::from_parts(10, 10),
|
||||||
&mut Weight::zero(),
|
&mut Weight::zero(),
|
||||||
);
|
);
|
||||||
assert_eq!(r, Err(()));
|
assert_eq!(r, Err(ProcessMessageError::Unsupported));
|
||||||
|
|
||||||
let r = AllowUnpaidExecutionFrom::<IsInVec<AllowUnpaidFrom>>::should_execute(
|
let r = AllowUnpaidExecutionFrom::<IsInVec<AllowUnpaidFrom>>::should_execute(
|
||||||
&Parent.into(),
|
&Parent.into(),
|
||||||
@@ -149,7 +149,7 @@ fn allow_explicit_unpaid_should_work() {
|
|||||||
Weight::from_parts(20, 20),
|
Weight::from_parts(20, 20),
|
||||||
&mut Weight::zero(),
|
&mut Weight::zero(),
|
||||||
);
|
);
|
||||||
assert_eq!(r, Err(()));
|
assert_eq!(r, Err(ProcessMessageError::Unsupported));
|
||||||
|
|
||||||
let r = AllowExplicitUnpaidExecutionFrom::<IsInVec<AllowExplicitUnpaidFrom>>::should_execute(
|
let r = AllowExplicitUnpaidExecutionFrom::<IsInVec<AllowExplicitUnpaidFrom>>::should_execute(
|
||||||
&Parent.into(),
|
&Parent.into(),
|
||||||
@@ -157,7 +157,7 @@ fn allow_explicit_unpaid_should_work() {
|
|||||||
Weight::from_parts(20, 20),
|
Weight::from_parts(20, 20),
|
||||||
&mut Weight::zero(),
|
&mut Weight::zero(),
|
||||||
);
|
);
|
||||||
assert_eq!(r, Err(()));
|
assert_eq!(r, Err(ProcessMessageError::Overweight(Weight::from_parts(20, 20))));
|
||||||
|
|
||||||
let r = AllowExplicitUnpaidExecutionFrom::<IsInVec<AllowExplicitUnpaidFrom>>::should_execute(
|
let r = AllowExplicitUnpaidExecutionFrom::<IsInVec<AllowExplicitUnpaidFrom>>::should_execute(
|
||||||
&Parent.into(),
|
&Parent.into(),
|
||||||
@@ -165,7 +165,7 @@ fn allow_explicit_unpaid_should_work() {
|
|||||||
Weight::from_parts(20, 20),
|
Weight::from_parts(20, 20),
|
||||||
&mut Weight::zero(),
|
&mut Weight::zero(),
|
||||||
);
|
);
|
||||||
assert_eq!(r, Err(()));
|
assert_eq!(r, Err(ProcessMessageError::Overweight(Weight::from_parts(20, 20))));
|
||||||
|
|
||||||
let r = AllowExplicitUnpaidExecutionFrom::<IsInVec<AllowExplicitUnpaidFrom>>::should_execute(
|
let r = AllowExplicitUnpaidExecutionFrom::<IsInVec<AllowExplicitUnpaidFrom>>::should_execute(
|
||||||
&Parent.into(),
|
&Parent.into(),
|
||||||
@@ -189,7 +189,7 @@ fn allow_explicit_unpaid_should_work() {
|
|||||||
Weight::from_parts(20, 20),
|
Weight::from_parts(20, 20),
|
||||||
&mut Weight::zero(),
|
&mut Weight::zero(),
|
||||||
);
|
);
|
||||||
assert_eq!(r, Err(()));
|
assert_eq!(r, Err(ProcessMessageError::Overweight(Weight::from_parts(20, 20))));
|
||||||
|
|
||||||
let r = AllowExplicitUnpaidExecutionFrom::<IsInVec<AllowExplicitUnpaidFrom>>::should_execute(
|
let r = AllowExplicitUnpaidExecutionFrom::<IsInVec<AllowExplicitUnpaidFrom>>::should_execute(
|
||||||
&Parent.into(),
|
&Parent.into(),
|
||||||
@@ -213,7 +213,7 @@ fn allow_paid_should_work() {
|
|||||||
Weight::from_parts(10, 10),
|
Weight::from_parts(10, 10),
|
||||||
&mut Weight::zero(),
|
&mut Weight::zero(),
|
||||||
);
|
);
|
||||||
assert_eq!(r, Err(()));
|
assert_eq!(r, Err(ProcessMessageError::Unsupported));
|
||||||
|
|
||||||
let fees = (Parent, 1).into();
|
let fees = (Parent, 1).into();
|
||||||
let mut underpaying_message = Xcm::<()>(vec![
|
let mut underpaying_message = Xcm::<()>(vec![
|
||||||
@@ -228,7 +228,7 @@ fn allow_paid_should_work() {
|
|||||||
Weight::from_parts(30, 30),
|
Weight::from_parts(30, 30),
|
||||||
&mut Weight::zero(),
|
&mut Weight::zero(),
|
||||||
);
|
);
|
||||||
assert_eq!(r, Err(()));
|
assert_eq!(r, Err(ProcessMessageError::Overweight(Weight::from_parts(30, 30))));
|
||||||
|
|
||||||
let fees = (Parent, 1).into();
|
let fees = (Parent, 1).into();
|
||||||
let mut paying_message = Xcm::<()>(vec![
|
let mut paying_message = Xcm::<()>(vec![
|
||||||
@@ -243,7 +243,7 @@ fn allow_paid_should_work() {
|
|||||||
Weight::from_parts(30, 30),
|
Weight::from_parts(30, 30),
|
||||||
&mut Weight::zero(),
|
&mut Weight::zero(),
|
||||||
);
|
);
|
||||||
assert_eq!(r, Err(()));
|
assert_eq!(r, Err(ProcessMessageError::Unsupported));
|
||||||
|
|
||||||
let r = AllowTopLevelPaidExecutionFrom::<IsInVec<AllowPaidFrom>>::should_execute(
|
let r = AllowTopLevelPaidExecutionFrom::<IsInVec<AllowPaidFrom>>::should_execute(
|
||||||
&Parent.into(),
|
&Parent.into(),
|
||||||
@@ -266,7 +266,7 @@ fn allow_paid_should_work() {
|
|||||||
Weight::from_parts(20, 20),
|
Weight::from_parts(20, 20),
|
||||||
&mut Weight::zero(),
|
&mut Weight::zero(),
|
||||||
);
|
);
|
||||||
assert_eq!(r, Err(()));
|
assert_eq!(r, Err(ProcessMessageError::Overweight(Weight::from_parts(20, 20))));
|
||||||
|
|
||||||
let r = AllowTopLevelPaidExecutionFrom::<IsInVec<AllowPaidFrom>>::should_execute(
|
let r = AllowTopLevelPaidExecutionFrom::<IsInVec<AllowPaidFrom>>::should_execute(
|
||||||
&Parent.into(),
|
&Parent.into(),
|
||||||
@@ -276,3 +276,30 @@ fn allow_paid_should_work() {
|
|||||||
);
|
);
|
||||||
assert_eq!(r, Ok(()))
|
assert_eq!(r, Ok(()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn suspension_should_work() {
|
||||||
|
TestSuspender::set_suspended(true);
|
||||||
|
AllowUnpaidFrom::set(vec![Parent.into()]);
|
||||||
|
|
||||||
|
let mut message =
|
||||||
|
Xcm::<()>(vec![TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }]);
|
||||||
|
let r = RespectSuspension::<AllowUnpaidExecutionFrom::<IsInVec<AllowUnpaidFrom>>, TestSuspender>::should_execute(
|
||||||
|
&Parent.into(),
|
||||||
|
message.inner_mut(),
|
||||||
|
Weight::from_parts(10, 10),
|
||||||
|
&mut Weight::zero(),
|
||||||
|
);
|
||||||
|
assert_eq!(r, Err(ProcessMessageError::Yield));
|
||||||
|
|
||||||
|
TestSuspender::set_suspended(false);
|
||||||
|
let mut message =
|
||||||
|
Xcm::<()>(vec![TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }]);
|
||||||
|
let r = RespectSuspension::<AllowUnpaidExecutionFrom::<IsInVec<AllowUnpaidFrom>>, TestSuspender>::should_execute(
|
||||||
|
&Parent.into(),
|
||||||
|
message.inner_mut(),
|
||||||
|
Weight::from_parts(10, 10),
|
||||||
|
&mut Weight::zero(),
|
||||||
|
);
|
||||||
|
assert_eq!(r, Ok(()));
|
||||||
|
}
|
||||||
|
|||||||
@@ -14,7 +14,10 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use crate::{barriers::AllowSubscriptionsFrom, test_utils::*};
|
use crate::{
|
||||||
|
barriers::{AllowSubscriptionsFrom, RespectSuspension},
|
||||||
|
test_utils::*,
|
||||||
|
};
|
||||||
pub use crate::{
|
pub use crate::{
|
||||||
AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowTopLevelPaidExecutionFrom,
|
AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowTopLevelPaidExecutionFrom,
|
||||||
AllowUnpaidExecutionFrom, FixedRateOfFungible, FixedWeightBounds, TakeWeightCredit,
|
AllowUnpaidExecutionFrom, FixedRateOfFungible, FixedWeightBounds, TakeWeightCredit,
|
||||||
@@ -32,7 +35,7 @@ pub use frame_support::{
|
|||||||
pub use parity_scale_codec::{Decode, Encode};
|
pub use parity_scale_codec::{Decode, Encode};
|
||||||
pub use sp_io::hashing::blake2_256;
|
pub use sp_io::hashing::blake2_256;
|
||||||
pub use sp_std::{
|
pub use sp_std::{
|
||||||
cell::RefCell,
|
cell::{Cell, RefCell},
|
||||||
collections::{btree_map::BTreeMap, btree_set::BTreeSet},
|
collections::{btree_map::BTreeMap, btree_set::BTreeSet},
|
||||||
fmt::Debug,
|
fmt::Debug,
|
||||||
marker::PhantomData,
|
marker::PhantomData,
|
||||||
@@ -40,8 +43,8 @@ pub use sp_std::{
|
|||||||
pub use xcm::latest::{prelude::*, Weight};
|
pub use xcm::latest::{prelude::*, Weight};
|
||||||
pub use xcm_executor::{
|
pub use xcm_executor::{
|
||||||
traits::{
|
traits::{
|
||||||
AssetExchange, AssetLock, ConvertOrigin, Enact, ExportXcm, FeeManager, FeeReason,
|
AssetExchange, AssetLock, CheckSuspension, ConvertOrigin, Enact, ExportXcm, FeeManager,
|
||||||
LockError, OnResponse, TransactAsset,
|
FeeReason, LockError, OnResponse, TransactAsset,
|
||||||
},
|
},
|
||||||
Assets, Config,
|
Assets, Config,
|
||||||
};
|
};
|
||||||
@@ -128,6 +131,7 @@ thread_local! {
|
|||||||
) -> Result<XcmHash, SendError>,
|
) -> Result<XcmHash, SendError>,
|
||||||
)>> = RefCell::new(None);
|
)>> = RefCell::new(None);
|
||||||
pub static SEND_PRICE: RefCell<MultiAssets> = RefCell::new(MultiAssets::new());
|
pub static SEND_PRICE: RefCell<MultiAssets> = RefCell::new(MultiAssets::new());
|
||||||
|
pub static SUSPENDED: Cell<bool> = Cell::new(false);
|
||||||
}
|
}
|
||||||
pub fn sent_xcm() -> Vec<(MultiLocation, opaque::Xcm, XcmHash)> {
|
pub fn sent_xcm() -> Vec<(MultiLocation, opaque::Xcm, XcmHash)> {
|
||||||
SENT_XCM.with(|q| (*q.borrow()).clone())
|
SENT_XCM.with(|q| (*q.borrow()).clone())
|
||||||
@@ -419,6 +423,24 @@ parameter_types! {
|
|||||||
pub static MaxInstructions: u32 = 100;
|
pub static MaxInstructions: u32 = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct TestSuspender;
|
||||||
|
impl CheckSuspension for TestSuspender {
|
||||||
|
fn is_suspended<Call>(
|
||||||
|
_origin: &MultiLocation,
|
||||||
|
_instructions: &mut [Instruction<Call>],
|
||||||
|
_max_weight: Weight,
|
||||||
|
_weight_credit: &mut Weight,
|
||||||
|
) -> bool {
|
||||||
|
SUSPENDED.with(|s| s.get())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TestSuspender {
|
||||||
|
pub fn set_suspended(suspended: bool) {
|
||||||
|
SUSPENDED.with(|s| s.set(suspended));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub type TestBarrier = (
|
pub type TestBarrier = (
|
||||||
TakeWeightCredit,
|
TakeWeightCredit,
|
||||||
AllowKnownQueryResponses<TestResponseHandler>,
|
AllowKnownQueryResponses<TestResponseHandler>,
|
||||||
@@ -629,7 +651,7 @@ impl Config for TestConfig {
|
|||||||
type IsReserve = TestIsReserve;
|
type IsReserve = TestIsReserve;
|
||||||
type IsTeleporter = TestIsTeleporter;
|
type IsTeleporter = TestIsTeleporter;
|
||||||
type UniversalLocation = ExecutorUniversalLocation;
|
type UniversalLocation = ExecutorUniversalLocation;
|
||||||
type Barrier = TestBarrier;
|
type Barrier = RespectSuspension<TestBarrier, TestSuspender>;
|
||||||
type Weigher = FixedWeightBounds<UnitWeightCost, TestCall, MaxInstructions>;
|
type Weigher = FixedWeightBounds<UnitWeightCost, TestCall, MaxInstructions>;
|
||||||
type Trader = FixedRateOfFungible<WeightPrice, ()>;
|
type Trader = FixedRateOfFungible<WeightPrice, ()>;
|
||||||
type ResponseHandler = TestResponseHandler;
|
type ResponseHandler = TestResponseHandler;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ use super::{test_utils::*, *};
|
|||||||
use core::convert::TryInto;
|
use core::convert::TryInto;
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
assert_err,
|
assert_err,
|
||||||
traits::{ConstU32, ContainsPair},
|
traits::{ConstU32, ContainsPair, ProcessMessageError},
|
||||||
weights::constants::{WEIGHT_PROOF_SIZE_PER_MB, WEIGHT_REF_TIME_PER_SECOND},
|
weights::constants::{WEIGHT_PROOF_SIZE_PER_MB, WEIGHT_REF_TIME_PER_SECOND},
|
||||||
};
|
};
|
||||||
use xcm_executor::{traits::prelude::*, Config, XcmExecutor};
|
use xcm_executor::{traits::prelude::*, Config, XcmExecutor};
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ use xcm_builder::{
|
|||||||
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom,
|
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom,
|
||||||
ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser,
|
ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser,
|
||||||
CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfFungible, FixedWeightBounds,
|
CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfFungible, FixedWeightBounds,
|
||||||
IsChildSystemParachain, IsConcrete, MintLocation, SignedAccountId32AsNative,
|
IsChildSystemParachain, IsConcrete, MintLocation, RespectSuspension, SignedAccountId32AsNative,
|
||||||
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ impl xcm_executor::Config for XcmConfig {
|
|||||||
type IsReserve = ();
|
type IsReserve = ();
|
||||||
type IsTeleporter = TrustedTeleporters;
|
type IsTeleporter = TrustedTeleporters;
|
||||||
type UniversalLocation = UniversalLocation;
|
type UniversalLocation = UniversalLocation;
|
||||||
type Barrier = Barrier;
|
type Barrier = RespectSuspension<Barrier, XcmPallet>;
|
||||||
type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>;
|
type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>;
|
||||||
type Trader = FixedRateOfFungible<KsmPerSecondPerByte, ()>;
|
type Trader = FixedRateOfFungible<KsmPerSecondPerByte, ()>;
|
||||||
type ResponseHandler = XcmPallet;
|
type ResponseHandler = XcmPallet;
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ pub use token_matching::{
|
|||||||
mod on_response;
|
mod on_response;
|
||||||
pub use on_response::{OnResponse, VersionChangeNotifier};
|
pub use on_response::{OnResponse, VersionChangeNotifier};
|
||||||
mod should_execute;
|
mod should_execute;
|
||||||
pub use should_execute::ShouldExecute;
|
pub use should_execute::{CheckSuspension, ShouldExecute};
|
||||||
mod transact_asset;
|
mod transact_asset;
|
||||||
pub use transact_asset::TransactAsset;
|
pub use transact_asset::TransactAsset;
|
||||||
mod weight;
|
mod weight;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
use frame_support::traits::ProcessMessageError;
|
||||||
use sp_std::result::Result;
|
use sp_std::result::Result;
|
||||||
use xcm::latest::{Instruction, MultiLocation, Weight};
|
use xcm::latest::{Instruction, MultiLocation, Weight};
|
||||||
|
|
||||||
@@ -35,7 +36,7 @@ pub trait ShouldExecute {
|
|||||||
instructions: &mut [Instruction<RuntimeCall>],
|
instructions: &mut [Instruction<RuntimeCall>],
|
||||||
max_weight: Weight,
|
max_weight: Weight,
|
||||||
weight_credit: &mut Weight,
|
weight_credit: &mut Weight,
|
||||||
) -> Result<(), ()>;
|
) -> Result<(), ProcessMessageError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[impl_trait_for_tuples::impl_for_tuples(30)]
|
#[impl_trait_for_tuples::impl_for_tuples(30)]
|
||||||
@@ -45,7 +46,7 @@ impl ShouldExecute for Tuple {
|
|||||||
instructions: &mut [Instruction<RuntimeCall>],
|
instructions: &mut [Instruction<RuntimeCall>],
|
||||||
max_weight: Weight,
|
max_weight: Weight,
|
||||||
weight_credit: &mut Weight,
|
weight_credit: &mut Weight,
|
||||||
) -> Result<(), ()> {
|
) -> Result<(), ProcessMessageError> {
|
||||||
for_tuples!( #(
|
for_tuples!( #(
|
||||||
match Tuple::should_execute(origin, instructions, max_weight, weight_credit) {
|
match Tuple::should_execute(origin, instructions, max_weight, weight_credit) {
|
||||||
Ok(()) => return Ok(()),
|
Ok(()) => return Ok(()),
|
||||||
@@ -60,6 +61,42 @@ impl ShouldExecute for Tuple {
|
|||||||
max_weight,
|
max_weight,
|
||||||
weight_credit,
|
weight_credit,
|
||||||
);
|
);
|
||||||
Err(())
|
Err(ProcessMessageError::Unsupported)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Trait to determine whether the execution engine is suspended from executing a given XCM.
|
||||||
|
///
|
||||||
|
/// The trait method is given the same parameters as `ShouldExecute::should_execute`, so that the
|
||||||
|
/// implementer will have all the context necessary to determine whether or not to suspend the
|
||||||
|
/// XCM executor.
|
||||||
|
///
|
||||||
|
/// Can be chained together in tuples to have multiple rounds of checks. If all of the tuple
|
||||||
|
/// elements returns false, then execution is not suspended. Otherwise, execution is suspended
|
||||||
|
/// if any of the tuple elements returns true.
|
||||||
|
pub trait CheckSuspension {
|
||||||
|
fn is_suspended<Call>(
|
||||||
|
origin: &MultiLocation,
|
||||||
|
instructions: &mut [Instruction<Call>],
|
||||||
|
max_weight: Weight,
|
||||||
|
weight_credit: &mut Weight,
|
||||||
|
) -> bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[impl_trait_for_tuples::impl_for_tuples(30)]
|
||||||
|
impl CheckSuspension for Tuple {
|
||||||
|
fn is_suspended<Call>(
|
||||||
|
origin: &MultiLocation,
|
||||||
|
instruction: &mut [Instruction<Call>],
|
||||||
|
max_weight: Weight,
|
||||||
|
weight_credit: &mut Weight,
|
||||||
|
) -> bool {
|
||||||
|
for_tuples!( #(
|
||||||
|
if Tuple::is_suspended(origin, instruction, max_weight, weight_credit) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
)* );
|
||||||
|
|
||||||
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user