Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Small nits for xcm-v3 (#6408)
Browse files Browse the repository at this point in the history
* Add possibility to skip benchmark for export_message

* ".git/.scripts/bench-bot.sh" xcm westend-dev pallet_xcm_benchmarks::generic

* Revert

* ".git/.scripts/bench-bot.sh" xcm westend-dev pallet_xcm_benchmarks::generic

* Add HaulBlobError to `fn haul_blob`

* ".git/.scripts/bench-bot.sh" xcm westend-dev pallet_xcm_benchmarks::generic

Co-authored-by: command-bot <>
  • Loading branch information
bkontur authored Dec 13, 2022
1 parent 3e9cc17 commit 4b9a8e8
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 46 deletions.
79 changes: 40 additions & 39 deletions runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,25 @@
//! Autogenerated weights for `pallet_xcm_benchmarks::generic`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2022-04-17, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2022-12-12, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024
// Executed Command:
// target/production/polkadot
// /home/benchbot/cargo_target_dir/production/polkadot
// benchmark
// pallet
// --chain=westend-dev
// --steps=50
// --repeat=20
// --pallet=pallet_xcm_benchmarks::generic
// --extrinsic=*
// --execution=wasm
// --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_benchmarks::generic
// --chain=westend-dev
// --header=./file_header.txt
// --template=./xcm/pallet-xcm-benchmarks/template.hbs
// --output=./runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs
// --output=./runtime/westend/src/weights/xcm/

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
Expand All @@ -49,135 +50,135 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Storage: XcmPallet SupportedVersion (r:1 w:0)
// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1)
// Storage: XcmPallet SafeXcmVersion (r:1 w:0)
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
pub(crate) fn report_holding() -> Weight {
Weight::from_ref_time(24_686_000 as u64)
Weight::from_ref_time(34_089_000 as u64)
.saturating_add(T::DbWeight::get().reads(5 as u64))
.saturating_add(T::DbWeight::get().writes(3 as u64))
}
pub(crate) fn buy_execution() -> Weight {
Weight::from_ref_time(3_620_000 as u64)
Weight::from_ref_time(5_751_000 as u64)
}
// Storage: XcmPallet Queries (r:1 w:0)
pub(crate) fn query_response() -> Weight {
Weight::from_ref_time(12_946_000 as u64)
Weight::from_ref_time(17_938_000 as u64)
.saturating_add(T::DbWeight::get().reads(1 as u64))
}
pub(crate) fn transact() -> Weight {
Weight::from_ref_time(13_206_000 as u64)
Weight::from_ref_time(20_699_000 as u64)
}
pub(crate) fn refund_surplus() -> Weight {
Weight::from_ref_time(3_879_000 as u64)
Weight::from_ref_time(6_077_000 as u64)
}
pub(crate) fn set_error_handler() -> Weight {
Weight::from_ref_time(3_659_000 as u64)
Weight::from_ref_time(5_747_000 as u64)
}
pub(crate) fn set_appendix() -> Weight {
Weight::from_ref_time(3_743_000 as u64)
Weight::from_ref_time(5_837_000 as u64)
}
pub(crate) fn clear_error() -> Weight {
Weight::from_ref_time(3_711_000 as u64)
Weight::from_ref_time(5_712_000 as u64)
}
pub(crate) fn descend_origin() -> Weight {
Weight::from_ref_time(4_618_000 as u64)
Weight::from_ref_time(6_471_000 as u64)
}
pub(crate) fn clear_origin() -> Weight {
Weight::from_ref_time(3_588_000 as u64)
Weight::from_ref_time(5_725_000 as u64)
}
// Storage: XcmPallet SupportedVersion (r:1 w:0)
// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1)
// Storage: XcmPallet SafeXcmVersion (r:1 w:0)
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
pub(crate) fn report_error() -> Weight {
Weight::from_ref_time(20_331_000 as u64)
Weight::from_ref_time(29_975_000 as u64)
.saturating_add(T::DbWeight::get().reads(5 as u64))
.saturating_add(T::DbWeight::get().writes(3 as u64))
}
// Storage: XcmPallet AssetTraps (r:1 w:1)
pub(crate) fn claim_asset() -> Weight {
Weight::from_ref_time(7_650_000 as u64)
Weight::from_ref_time(21_598_000 as u64)
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
pub(crate) fn trap() -> Weight {
Weight::from_ref_time(3_617_000 as u64)
Weight::from_ref_time(5_665_000 as u64)
}
// Storage: XcmPallet VersionNotifyTargets (r:1 w:1)
// Storage: XcmPallet SupportedVersion (r:1 w:0)
// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1)
// Storage: XcmPallet SafeXcmVersion (r:1 w:0)
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
pub(crate) fn subscribe_version() -> Weight {
Weight::from_ref_time(28_613_000 as u64)
Weight::from_ref_time(38_343_000 as u64)
.saturating_add(T::DbWeight::get().reads(6 as u64))
.saturating_add(T::DbWeight::get().writes(4 as u64))
}
// Storage: XcmPallet VersionNotifyTargets (r:0 w:1)
pub(crate) fn unsubscribe_version() -> Weight {
Weight::from_ref_time(5_443_000 as u64)
Weight::from_ref_time(8_353_000 as u64)
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: XcmPallet SupportedVersion (r:1 w:0)
// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1)
// Storage: XcmPallet SafeXcmVersion (r:1 w:0)
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
pub(crate) fn initiate_reserve_withdraw() -> Weight {
Weight::from_ref_time(24_401_000 as u64)
Weight::from_ref_time(33_100_000 as u64)
.saturating_add(T::DbWeight::get().reads(5 as u64))
.saturating_add(T::DbWeight::get().writes(3 as u64))
}
pub(crate) fn burn_asset() -> Weight {
Weight::from_ref_time(5_259_000 as u64)
Weight::from_ref_time(7_259_000 as u64)
}
pub(crate) fn expect_asset() -> Weight {
Weight::from_ref_time(3_745_000 as u64)
Weight::from_ref_time(5_848_000 as u64)
}
pub(crate) fn expect_origin() -> Weight {
Weight::from_ref_time(3_847_000 as u64)
Weight::from_ref_time(5_787_000 as u64)
}
pub(crate) fn expect_error() -> Weight {
Weight::from_ref_time(3_633_000 as u64)
Weight::from_ref_time(5_775_000 as u64)
}
// Storage: XcmPallet SupportedVersion (r:1 w:0)
// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1)
// Storage: XcmPallet SafeXcmVersion (r:1 w:0)
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
pub(crate) fn query_pallet() -> Weight {
Weight::from_ref_time(21_645_000 as u64)
Weight::from_ref_time(34_846_000 as u64)
.saturating_add(T::DbWeight::get().reads(5 as u64))
.saturating_add(T::DbWeight::get().writes(3 as u64))
}
pub(crate) fn expect_pallet() -> Weight {
Weight::from_ref_time(4_017_000 as u64)
Weight::from_ref_time(8_844_000 as u64)
}
// Storage: XcmPallet SupportedVersion (r:1 w:0)
// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1)
// Storage: XcmPallet SafeXcmVersion (r:1 w:0)
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
pub(crate) fn report_transact_status() -> Weight {
Weight::from_ref_time(20_465_000 as u64)
Weight::from_ref_time(50_256_000 as u64)
.saturating_add(T::DbWeight::get().reads(5 as u64))
.saturating_add(T::DbWeight::get().writes(3 as u64))
}
pub(crate) fn clear_transact_status() -> Weight {
Weight::from_ref_time(3_723_000 as u64)
Weight::from_ref_time(9_959_000 as u64)
}
pub(crate) fn set_topic() -> Weight {
Weight::from_ref_time(3_687_000 as u64)
Weight::from_ref_time(10_007_000 as u64)
}
pub(crate) fn clear_topic() -> Weight {
Weight::from_ref_time(3_654_000 as u64)
Weight::from_ref_time(8_289_000 as u64)
}
pub(crate) fn set_fees_mode() -> Weight {
Weight::from_ref_time(3_721_000 as u64)
Weight::from_ref_time(5_764_000 as u64)
}
pub(crate) fn unpaid_execution() -> Weight {
Weight::from_ref_time(3_111_000 as u64)
Weight::from_ref_time(5_924_000 as u64)
}
}
8 changes: 4 additions & 4 deletions xcm/pallet-xcm-benchmarks/src/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,24 @@ pub mod pallet {
/// The first element in the returned tuple represents the assets that are being exchanged
/// from, whereas the second element represents the assets that are being exchanged to.
///
/// If set to `None`, benchmarks which rely on an `exchange_asset` will be skipped.
/// If set to `Err`, benchmarks which rely on an `exchange_asset` will be skipped.
fn worst_case_asset_exchange() -> Result<(MultiAssets, MultiAssets), BenchmarkError>;

/// A `Junction` that is one of the `UniversalAliases` configured by the XCM executor.
///
/// If set to `None`, benchmarks which rely on a universal alias will be skipped.
/// If set to `Err`, benchmarks which rely on a universal alias will be skipped.
fn universal_alias() -> Result<Junction, BenchmarkError>;

/// The `MultiLocation` and `RuntimeCall` used for successful transaction XCMs.
///
/// If set to `None`, benchmarks which rely on a `transact_origin_and_runtime_call` will be
/// If set to `Err`, benchmarks which rely on a `transact_origin_and_runtime_call` will be
/// skipped.
fn transact_origin_and_runtime_call(
) -> Result<(MultiLocation, <Self as crate::generic::Config<I>>::RuntimeCall), BenchmarkError>;

/// A valid `MultiLocation` we can successfully subscribe to.
///
/// If set to `None`, benchmarks which rely on a `subscribe_origin` will be skipped.
/// If set to `Err`, benchmarks which rely on a `subscribe_origin` will be skipped.
fn subscribe_origin() -> Result<MultiLocation, BenchmarkError>;

/// Return an origin, ticket, and assets that can be trapped and claimed.
Expand Down
3 changes: 2 additions & 1 deletion xcm/xcm-builder/src/tests/bridging/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ impl<D: DispatchBlob> TestBridge<D> {
}
}
impl<D: DispatchBlob> HaulBlob for TestBridge<D> {
fn haul_blob(blob: Vec<u8>) {
fn haul_blob(blob: Vec<u8>) -> Result<(), HaulBlobError> {
BRIDGE_TRAFFIC.with(|t| t.borrow_mut().push(blob));
Ok(())
}
}

Expand Down
18 changes: 16 additions & 2 deletions xcm/xcm-builder/src/universal_exports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,21 @@ pub trait DispatchBlob {

pub trait HaulBlob {
/// Sends a blob over some point-to-point link. This will generally be implemented by a bridge.
fn haul_blob(blob: Vec<u8>);
fn haul_blob(blob: Vec<u8>) -> Result<(), HaulBlobError>;
}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum HaulBlobError {
/// Represents point-to-point link failure with a human-readable explanation of the specific issue is provided.
Transport(&'static str),
}

impl From<HaulBlobError> for SendError {
fn from(err: HaulBlobError) -> Self {
match err {
HaulBlobError::Transport(reason) => SendError::Transport(reason),
}
}
}

#[derive(Clone, Encode, Decode)]
Expand Down Expand Up @@ -334,7 +348,7 @@ impl<Bridge: HaulBlob, BridgedNetwork: Get<NetworkId>, Price: Get<MultiAssets>>
}

fn deliver((blob, hash): (Vec<u8>, XcmHash)) -> Result<XcmHash, SendError> {
Bridge::haul_blob(blob);
Bridge::haul_blob(blob)?;
Ok(hash)
}
}
Expand Down

0 comments on commit 4b9a8e8

Please sign in to comment.