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

Commit

Permalink
Merge remote-tracking branch 'origin/master' into lexnv/bump_sp_crate…
Browse files Browse the repository at this point in the history
…s_two
  • Loading branch information
parity-processbot committed May 31, 2023
2 parents 011caf5 + b7a42f7 commit 8a56115
Show file tree
Hide file tree
Showing 15 changed files with 411 additions and 168 deletions.
80 changes: 33 additions & 47 deletions runtime/kusama/src/weights/runtime_parachains_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,26 @@
//! Autogenerated weights for `runtime_parachains::configuration`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-04-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2023-05-30, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! 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("kusama-dev"), DB CACHE: 1024

// Executed Command:
// ./target/production/polkadot
// target/production/polkadot
// benchmark
// pallet
// --chain=kusama-dev
// --steps=50
// --repeat=20
// --pallet=runtime_parachains::configuration
// --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=runtime_parachains::configuration
// --chain=kusama-dev
// --header=./file_header.txt
// --output=./runtime/kusama/src/weights/runtime_parachains_configuration.rs
// --output=./runtime/kusama/src/weights/

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
Expand All @@ -55,11 +57,11 @@ impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for
/// Proof Skipped: ParasShared CurrentSessionIndex (max_values: Some(1), max_size: None, mode: Measured)
fn set_config_with_block_number() -> Weight {
// Proof Size summary in bytes:
// Measured: `90`
// Estimated: `1575`
// Minimum execution time: 9_482_000 picoseconds.
Weight::from_parts(9_845_000, 0)
.saturating_add(Weight::from_parts(0, 1575))
// Measured: `127`
// Estimated: `1612`
// Minimum execution time: 9_471_000 picoseconds.
Weight::from_parts(9_872_000, 0)
.saturating_add(Weight::from_parts(0, 1612))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
Expand All @@ -71,11 +73,11 @@ impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for
/// Proof Skipped: ParasShared CurrentSessionIndex (max_values: Some(1), max_size: None, mode: Measured)
fn set_config_with_u32() -> Weight {
// Proof Size summary in bytes:
// Measured: `90`
// Estimated: `1575`
// Minimum execution time: 9_689_000 picoseconds.
Weight::from_parts(9_960_000, 0)
.saturating_add(Weight::from_parts(0, 1575))
// Measured: `127`
// Estimated: `1612`
// Minimum execution time: 9_555_000 picoseconds.
Weight::from_parts(9_800_000, 0)
.saturating_add(Weight::from_parts(0, 1612))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
Expand All @@ -87,27 +89,11 @@ impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for
/// Proof Skipped: ParasShared CurrentSessionIndex (max_values: Some(1), max_size: None, mode: Measured)
fn set_config_with_option_u32() -> Weight {
// Proof Size summary in bytes:
// Measured: `90`
// Estimated: `1575`
// Minimum execution time: 9_523_000 picoseconds.
Weight::from_parts(9_736_000, 0)
.saturating_add(Weight::from_parts(0, 1575))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: Configuration PendingConfigs (r:1 w:1)
/// Proof Skipped: Configuration PendingConfigs (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Configuration BypassConsistencyCheck (r:1 w:0)
/// Proof Skipped: Configuration BypassConsistencyCheck (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: ParasShared CurrentSessionIndex (r:1 w:0)
/// Proof Skipped: ParasShared CurrentSessionIndex (max_values: Some(1), max_size: None, mode: Measured)
fn set_config_with_weight() -> Weight {
// Proof Size summary in bytes:
// Measured: `90`
// Estimated: `1575`
// Minimum execution time: 9_443_000 picoseconds.
Weight::from_parts(9_679_000, 0)
.saturating_add(Weight::from_parts(0, 1575))
// Measured: `127`
// Estimated: `1612`
// Minimum execution time: 9_623_000 picoseconds.
Weight::from_parts(9_832_000, 0)
.saturating_add(Weight::from_parts(0, 1612))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
Expand All @@ -129,11 +115,11 @@ impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for
/// Proof Skipped: ParasShared CurrentSessionIndex (max_values: Some(1), max_size: None, mode: Measured)
fn set_config_with_balance() -> Weight {
// Proof Size summary in bytes:
// Measured: `90`
// Estimated: `1575`
// Minimum execution time: 9_460_000 picoseconds.
Weight::from_parts(9_716_000, 0)
.saturating_add(Weight::from_parts(0, 1575))
// Measured: `127`
// Estimated: `1612`
// Minimum execution time: 9_482_000 picoseconds.
Weight::from_parts(9_797_000, 0)
.saturating_add(Weight::from_parts(0, 1612))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
Expand All @@ -145,11 +131,11 @@ impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for
/// Proof Skipped: ParasShared CurrentSessionIndex (max_values: Some(1), max_size: None, mode: Measured)
fn set_config_with_executor_params() -> Weight {
// Proof Size summary in bytes:
// Measured: `90`
// Estimated: `1575`
// Minimum execution time: 10_279_000 picoseconds.
Weight::from_parts(10_615_000, 0)
.saturating_add(Weight::from_parts(0, 1575))
// Measured: `127`
// Estimated: `1612`
// Minimum execution time: 10_753_000 picoseconds.
Weight::from_parts(11_009_000, 0)
.saturating_add(Weight::from_parts(0, 1612))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
Expand Down
4 changes: 0 additions & 4 deletions runtime/parachains/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,6 @@ pub trait WeightInfo {
fn set_config_with_block_number() -> Weight;
fn set_config_with_u32() -> Weight;
fn set_config_with_option_u32() -> Weight;
fn set_config_with_weight() -> Weight;
fn set_config_with_balance() -> Weight;
fn set_hrmp_open_request_ttl() -> Weight;
fn set_config_with_executor_params() -> Weight;
Expand All @@ -455,9 +454,6 @@ impl WeightInfo for TestWeightInfo {
fn set_config_with_option_u32() -> Weight {
Weight::MAX
}
fn set_config_with_weight() -> Weight {
Weight::MAX
}
fn set_config_with_balance() -> Weight {
Weight::MAX
}
Expand Down
19 changes: 1 addition & 18 deletions runtime/polkadot/src/weights/runtime_parachains_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,24 +101,7 @@ impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: Configuration PendingConfigs (r:1 w:1)
/// Proof Skipped: Configuration PendingConfigs (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Configuration ActiveConfig (r:1 w:0)
/// Proof Skipped: Configuration ActiveConfig (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Configuration BypassConsistencyCheck (r:1 w:0)
/// Proof Skipped: Configuration BypassConsistencyCheck (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: ParasShared CurrentSessionIndex (r:1 w:0)
/// Proof Skipped: ParasShared CurrentSessionIndex (max_values: Some(1), max_size: None, mode: Measured)
fn set_config_with_weight() -> Weight {
// Proof Size summary in bytes:
// Measured: `393`
// Estimated: `1878`
// Minimum execution time: 12_999_000 picoseconds.
Weight::from_parts(13_465_000, 0)
.saturating_add(Weight::from_parts(0, 1878))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(1))
}

/// Storage: Benchmark Override (r:0 w:0)
/// Proof Skipped: Benchmark Override (max_values: None, max_size: None, mode: Measured)
fn set_hrmp_open_request_ttl() -> Weight {
Expand Down
19 changes: 1 addition & 18 deletions runtime/rococo/src/weights/runtime_parachains_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,24 +101,7 @@ impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: Configuration PendingConfigs (r:1 w:1)
/// Proof Skipped: Configuration PendingConfigs (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Configuration ActiveConfig (r:1 w:0)
/// Proof Skipped: Configuration ActiveConfig (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Configuration BypassConsistencyCheck (r:1 w:0)
/// Proof Skipped: Configuration BypassConsistencyCheck (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: ParasShared CurrentSessionIndex (r:1 w:0)
/// Proof Skipped: ParasShared CurrentSessionIndex (max_values: Some(1), max_size: None, mode: Measured)
fn set_config_with_weight() -> Weight {
// Proof Size summary in bytes:
// Measured: `397`
// Estimated: `1882`
// Minimum execution time: 12_914_000 picoseconds.
Weight::from_parts(13_395_000, 0)
.saturating_add(Weight::from_parts(0, 1882))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(1))
}

/// Storage: Benchmark Override (r:0 w:0)
/// Proof Skipped: Benchmark Override (max_values: None, max_size: None, mode: Measured)
fn set_hrmp_open_request_ttl() -> Weight {
Expand Down
3 changes: 2 additions & 1 deletion runtime/test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ pub mod pallet_test_notifier {
use pallet_xcm::ensure_response;
use sp_runtime::DispatchResult;
use xcm::latest::prelude::*;
use xcm_executor::traits::QueryHandler as XcmQueryHandler;

#[pallet::pallet]
pub struct Pallet<T>(_);
Expand Down Expand Up @@ -581,7 +582,7 @@ pub mod pallet_test_notifier {
let id = who
.using_encoded(|mut d| <[u8; 32]>::decode(&mut d))
.map_err(|_| Error::<T>::BadAccountFormat)?;
let qid = pallet_xcm::Pallet::<T>::new_query(
let qid = <pallet_xcm::Pallet<T> as XcmQueryHandler>::new_query(
Junction::AccountId32 { network: None, id },
100u32.into(),
Here,
Expand Down
17 changes: 1 addition & 16 deletions runtime/westend/src/weights/runtime_parachains_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,7 @@ impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: Configuration PendingConfigs (r:1 w:1)
/// Proof Skipped: Configuration PendingConfigs (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Configuration BypassConsistencyCheck (r:1 w:0)
/// Proof Skipped: Configuration BypassConsistencyCheck (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: ParasShared CurrentSessionIndex (r:1 w:0)
/// Proof Skipped: ParasShared CurrentSessionIndex (max_values: Some(1), max_size: None, mode: Measured)
fn set_config_with_weight() -> Weight {
// Proof Size summary in bytes:
// Measured: `90`
// Estimated: `1575`
// Minimum execution time: 10_293_000 picoseconds.
Weight::from_parts(10_619_000, 0)
.saturating_add(Weight::from_parts(0, 1575))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}

/// Storage: Benchmark Override (r:0 w:0)
/// Proof Skipped: Benchmark Override (max_values: None, max_size: None, mode: Measured)
fn set_hrmp_open_request_ttl() -> Weight {
Expand Down
117 changes: 62 additions & 55 deletions xcm/pallet-xcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ use frame_system::pallet_prelude::*;
pub use pallet::*;
use xcm_executor::{
traits::{
CheckSuspension, ClaimAssets, DropAssets, MatchesFungible, OnResponse,
VersionChangeNotifier, WeightBounds,
CheckSuspension, ClaimAssets, DropAssets, MatchesFungible, OnResponse, QueryHandler,
QueryResponseStatus, VersionChangeNotifier, WeightBounds,
},
Assets,
};
Expand Down Expand Up @@ -1126,6 +1126,66 @@ pub mod pallet {
/// The maximum number of distinct assets allowed to be transferred in a single helper extrinsic.
const MAX_ASSETS_FOR_TRANSFER: usize = 2;

impl<T: Config> QueryHandler for Pallet<T> {
type QueryId = u64;
type BlockNumber = T::BlockNumber;
type Error = XcmError;
type UniversalLocation = T::UniversalLocation;

/// Attempt to create a new query ID and register it as a query that is yet to respond.
fn new_query(
responder: impl Into<MultiLocation>,
timeout: T::BlockNumber,
match_querier: impl Into<MultiLocation>,
) -> Self::QueryId {
Self::do_new_query(responder, None, timeout, match_querier).into()
}

/// To check the status of the query, use `fn query()` passing the resultant `QueryId`
/// value.
fn report_outcome(
message: &mut Xcm<()>,
responder: impl Into<MultiLocation>,
timeout: Self::BlockNumber,
) -> Result<Self::QueryId, Self::Error> {
let responder = responder.into();
let destination = Self::UniversalLocation::get()
.invert_target(&responder)
.map_err(|()| XcmError::LocationNotInvertible)?;
let query_id = Self::new_query(responder, timeout, Here);
let response_info = QueryResponseInfo { destination, query_id, max_weight: Weight::zero() };
let report_error = Xcm(vec![ReportError(response_info)]);
message.0.insert(0, SetAppendix(report_error));
Ok(query_id)
}

/// Removes response when ready and emits [Event::ResponseTaken] event.
fn take_response(query_id: Self::QueryId) -> QueryResponseStatus<Self::BlockNumber> {
match Queries::<T>::get(query_id) {
Some(QueryStatus::Ready { response, at }) => match response.try_into() {
Ok(response) => {
Queries::<T>::remove(query_id);
Self::deposit_event(Event::ResponseTaken { query_id });
QueryResponseStatus::Ready { response, at }
},
Err(_) => QueryResponseStatus::UnexpectedVersion,
},
Some(QueryStatus::Pending { timeout, .. }) => QueryResponseStatus::Pending { timeout },
Some(_) => QueryResponseStatus::UnexpectedVersion,
None => QueryResponseStatus::NotFound,
}
}

#[cfg(feature = "runtime-benchmarks")]
fn expect_response(id: Self::QueryId, response: Response) {
let response = response.into();
Queries::<T>::insert(
id,
QueryStatus::Ready { response, at: frame_system::Pallet::<T>::block_number() },
);
}
}

impl<T: Config> Pallet<T> {
fn do_reserve_transfer_assets(
origin: OriginFor<T>,
Expand Down Expand Up @@ -1497,36 +1557,6 @@ impl<T: Config> Pallet<T> {
})
}

/// Consume `message` and return another which is equivalent to it except that it reports
/// back the outcome.
///
/// - `message`: The message whose outcome should be reported.
/// - `responder`: The origin from which a response should be expected.
/// - `timeout`: The block number after which it is permissible for `notify` not to be
/// called even if a response is received.
///
/// `report_outcome` may return an error if the `responder` is not invertible.
///
/// It is assumed that the querier of the response will be `Here`.
///
/// To check the status of the query, use `fn query()` passing the resultant `QueryId`
/// value.
pub fn report_outcome(
message: &mut Xcm<()>,
responder: impl Into<MultiLocation>,
timeout: T::BlockNumber,
) -> Result<QueryId, XcmError> {
let responder = responder.into();
let destination = T::UniversalLocation::get()
.invert_target(&responder)
.map_err(|()| XcmError::LocationNotInvertible)?;
let query_id = Self::new_query(responder, timeout, Here);
let response_info = QueryResponseInfo { destination, query_id, max_weight: Weight::zero() };
let report_error = Xcm(vec![ReportError(response_info)]);
message.0.insert(0, SetAppendix(report_error));
Ok(query_id)
}

/// Consume `message` and return another which is equivalent to it except that it reports
/// back the outcome and dispatches `notify` on this chain.
///
Expand Down Expand Up @@ -1568,15 +1598,6 @@ impl<T: Config> Pallet<T> {
Ok(())
}

/// Attempt to create a new query ID and register it as a query that is yet to respond.
pub fn new_query(
responder: impl Into<MultiLocation>,
timeout: T::BlockNumber,
match_querier: impl Into<MultiLocation>,
) -> u64 {
Self::do_new_query(responder, None, timeout, match_querier)
}

/// Attempt to create a new query ID and register it as a query that is yet to respond, and
/// which will call a dispatchable when a response happens.
pub fn new_notify_query(
Expand All @@ -1591,20 +1612,6 @@ impl<T: Config> Pallet<T> {
Self::do_new_query(responder, Some(notify), timeout, match_querier)
}

/// Attempt to remove and return the response of query with ID `query_id`.
///
/// Returns `None` if the response is not (yet) available.
pub fn take_response(query_id: QueryId) -> Option<(Response, T::BlockNumber)> {
if let Some(QueryStatus::Ready { response, at }) = Queries::<T>::get(query_id) {
let response = response.try_into().ok()?;
Queries::<T>::remove(query_id);
Self::deposit_event(Event::ResponseTaken { query_id });
Some((response, at))
} else {
None
}
}

/// Note that a particular destination to whom we would like to send a message is unknown
/// and queue it for version discovery.
fn note_unknown_version(dest: &MultiLocation) {
Expand Down
Loading

0 comments on commit 8a56115

Please sign in to comment.