From 3ca52929b3a03a5fabf226e8cd0bb77b88b4ce08 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Thu, 16 Mar 2023 19:34:06 +0000 Subject: [PATCH 01/31] Move XCM query functionality to trait --- xcm/pallet-xcm/src/lib.rs | 93 +++++++++++++++++++++------------------ xcm/src/v3/mod.rs | 4 +- xcm/src/v3/traits.rs | 12 +++++ 3 files changed, 64 insertions(+), 45 deletions(-) diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index cd6fb6321a8e..c8dd4539d8ee 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -1098,6 +1098,55 @@ 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 XcmQueryHandler for Pallet { + type QueryId = u64; + type BlockNumber = T::BlockNumber; + + /// 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. + fn report_outcome( + mut message: Xcm<()>, + responder: impl Into, + timeout: Self::BlockNumber, + ) -> Result<(Xcm<()>, Self::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((message, query_id)) + } + + /// Attempt to remove and return the response of query with ID `query_id`. + /// + /// Returns `None` if the response is not (yet) available. + fn take_response(query_id: Self::QueryId) -> Option<(Response, T::BlockNumber)> { + if let Some(QueryStatus::Ready { response, at }) = Queries::::get(query_id) { + let response = response.try_into().ok()?; + Queries::::remove(query_id); + Self::deposit_event(Event::ResponseTaken(query_id)); + Some((response, at)) + } else { + None + } + } +} + impl Pallet { fn do_reserve_transfer_assets( origin: OriginFor, @@ -1448,36 +1497,6 @@ impl Pallet { }) } - /// 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, - timeout: T::BlockNumber, - ) -> Result { - 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. /// @@ -1542,20 +1561,6 @@ impl Pallet { 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::::get(query_id) { - let response = response.try_into().ok()?; - Queries::::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) { diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index ff94c1392fea..6769d95ebe3c 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -171,7 +171,9 @@ impl From> for Vec> { pub mod prelude { mod contents { pub use super::super::{ - send_xcm, validate_send, Ancestor, AncestorThen, + send_xcm, + traits::XcmQueryHandler, + validate_send, Ancestor, AncestorThen, AssetId::{self, *}, AssetInstance::{self, *}, BodyId, BodyPart, Error as XcmError, ExecuteXcm, diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index b752647b0819..77ddb8496048 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -539,3 +539,15 @@ pub fn send_xcm( let hash = T::deliver(ticket)?; Ok((hash, price)) } + +pub trait XcmQueryHandler { + type QueryId; + type BlockNumber; + + fn report_outcome( + message: Xcm<()>, + responder: impl Into, + timeout: Self::BlockNumber, + ) -> result::Result<(Xcm<()>, Self::QueryId), Error>; + fn take_response(id: Self::QueryId) -> Option<(Response, T::BlockNumber)>; +} From d136364afb9f7d0274e01e58ba5f72ea634d64d7 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Thu, 16 Mar 2023 19:53:19 +0000 Subject: [PATCH 02/31] Fix tests --- xcm/pallet-xcm/src/lib.rs | 8 ++++---- xcm/src/v3/traits.rs | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index c8dd4539d8ee..30ba8253a479 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -1117,10 +1117,10 @@ impl XcmQueryHandler for Pallet { /// To check the status of the query, use `fn query()` passing the resultant `QueryId` /// value. fn report_outcome( - mut message: Xcm<()>, + message: &mut Xcm<()>, responder: impl Into, timeout: Self::BlockNumber, - ) -> Result<(Xcm<()>, Self::QueryId), XcmError> { + ) -> Result { let responder = responder.into(); let destination = T::UniversalLocation::get() .invert_target(&responder) @@ -1129,13 +1129,13 @@ impl XcmQueryHandler for Pallet { 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((message, query_id)) + Ok(query_id) } /// Attempt to remove and return the response of query with ID `query_id`. /// /// Returns `None` if the response is not (yet) available. - fn take_response(query_id: Self::QueryId) -> Option<(Response, T::BlockNumber)> { + fn take_response(query_id: Self::QueryId) -> Option<(Response, Self::BlockNumber)> { if let Some(QueryStatus::Ready { response, at }) = Queries::::get(query_id) { let response = response.try_into().ok()?; Queries::::remove(query_id); diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index 77ddb8496048..f7bac0197c4e 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -545,9 +545,9 @@ pub trait XcmQueryHandler { type BlockNumber; fn report_outcome( - message: Xcm<()>, + message: &mut Xcm<()>, responder: impl Into, timeout: Self::BlockNumber, - ) -> result::Result<(Xcm<()>, Self::QueryId), Error>; - fn take_response(id: Self::QueryId) -> Option<(Response, T::BlockNumber)>; + ) -> result::Result; + fn take_response(id: Self::QueryId) -> Option<(Response, Self::BlockNumber)>; } From 2529affae8ed7e0625058dd9981cfa3ca533c516 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Tue, 21 Mar 2023 16:29:27 -0300 Subject: [PATCH 03/31] Add PayOverXcm implementation --- xcm/pallet-xcm/src/lib.rs | 23 ++++++++---- xcm/src/v3/mod.rs | 2 +- xcm/src/v3/traits.rs | 13 +++++-- xcm/xcm-builder/src/lib.rs | 3 ++ xcm/xcm-builder/src/pay.rs | 75 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 104 insertions(+), 12 deletions(-) create mode 100644 xcm/xcm-builder/src/pay.rs diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index 30ba8253a479..559b3de87d89 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -1135,14 +1135,21 @@ impl XcmQueryHandler for Pallet { /// Attempt to remove and return the response of query with ID `query_id`. /// /// Returns `None` if the response is not (yet) available. - fn take_response(query_id: Self::QueryId) -> Option<(Response, Self::BlockNumber)> { - if let Some(QueryStatus::Ready { response, at }) = Queries::::get(query_id) { - let response = response.try_into().ok()?; - Queries::::remove(query_id); - Self::deposit_event(Event::ResponseTaken(query_id)); - Some((response, at)) - } else { - None + fn take_response(query_id: Self::QueryId) -> QueryResponseStatus { + match Queries::::get(query_id) { + Some(QueryStatus::Ready { response, at }) => { + let response = response.try_into(); + match response { + Ok(response) => { + Queries::::remove(query_id); + Self::deposit_event(Event::ResponseTaken(query_id)); + QueryResponseStatus::Finished { response, at } + }, + Err(_) => QueryResponseStatus::NotFound, // Found unexpected version + } + }, + Some(QueryStatus::Pending { .. }) => QueryResponseStatus::Pending, + _ => QueryResponseStatus::NotFound, } } } diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index 6769d95ebe3c..80beb465b998 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -172,7 +172,7 @@ pub mod prelude { mod contents { pub use super::super::{ send_xcm, - traits::XcmQueryHandler, + traits::{QueryResponseStatus, XcmQueryHandler}, validate_send, Ancestor, AncestorThen, AssetId::{self, *}, AssetInstance::{self, *}, diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index f7bac0197c4e..03d06026d32c 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -18,7 +18,7 @@ use crate::v2::Error as OldError; use core::result; -use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; +use parity_scale_codec::{Decode, Encode, FullCodec, MaxEncodedLen}; use scale_info::TypeInfo; pub use sp_weights::Weight; @@ -540,8 +540,15 @@ pub fn send_xcm( Ok((hash, price)) } +pub enum QueryResponseStatus { + Finished { response: Response, at: BlockNumber }, + Pending, + NotFound, +} + +/// Represents the pub trait XcmQueryHandler { - type QueryId; + type QueryId: FullCodec + MaxEncodedLen + TypeInfo + Clone + Eq + PartialEq + Debug + Copy; type BlockNumber; fn report_outcome( @@ -549,5 +556,5 @@ pub trait XcmQueryHandler { responder: impl Into, timeout: Self::BlockNumber, ) -> result::Result; - fn take_response(id: Self::QueryId) -> Option<(Response, Self::BlockNumber)>; + fn take_response(id: Self::QueryId) -> QueryResponseStatus; } diff --git a/xcm/xcm-builder/src/lib.rs b/xcm/xcm-builder/src/lib.rs index 2508a43a3226..06f5655a313a 100644 --- a/xcm/xcm-builder/src/lib.rs +++ b/xcm/xcm-builder/src/lib.rs @@ -85,3 +85,6 @@ pub use universal_exports::{ HaulBlobError, HaulBlobExporter, NetworkExportTable, SovereignPaidRemoteExporter, UnpaidLocalExporter, UnpaidRemoteExporter, }; + +mod pay; +pub use pay::PayOverXcm; diff --git a/xcm/xcm-builder/src/pay.rs b/xcm/xcm-builder/src/pay.rs new file mode 100644 index 000000000000..b030fac6fc22 --- /dev/null +++ b/xcm/xcm-builder/src/pay.rs @@ -0,0 +1,75 @@ +// Copyright Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot 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. + +// Polkadot 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 . + +//! `PayOverXcm` struct for paying through XCM and getting the status back + +use frame_support::traits::{ + tokens::{Pay, PaymentStatus}, + Get, +}; +use sp_std::{marker::PhantomData, vec}; +use xcm::prelude::*; + +pub struct PayOverXcm( + PhantomData<(DestChain, Router, Querier, BlockNumber)>, +); +impl< + DestChain: Get, + Router: SendXcm, + Querier: XcmQueryHandler, + BlockNumber, + > Pay for PayOverXcm +{ + type Beneficiary = MultiLocation; + type AssetKind = xcm::v3::AssetId; + type Balance = u128; + type Id = Querier::QueryId; + type Timeout = Querier::BlockNumber; + type Error = XcmError; + + fn pay( + who: &Self::Beneficiary, + asset_kind: Self::AssetKind, + amount: Self::Balance, + timeout: Self::Timeout, + ) -> Result { + let mut message = Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + TransferAsset { + beneficiary: *who, + assets: vec![MultiAsset { id: asset_kind, fun: Fungibility::Fungible(amount) }] + .into(), + }, + ]); + let destination = DestChain::get(); + let id = Querier::report_outcome(&mut message, destination, timeout)?; + let (ticket, _multiassets) = Router::validate(&mut Some(destination), &mut Some(message))?; + Router::deliver(ticket)?; + Ok(id) + } + + fn check_payment(id: Self::Id) -> PaymentStatus { + match Querier::take_response(id) { + QueryResponseStatus::Finished { response, at: _ } => match response { + Response::ExecutionResult(Some(_)) => PaymentStatus::Failure, + Response::ExecutionResult(None) => PaymentStatus::Success, + _ => PaymentStatus::Unknown, + }, + QueryResponseStatus::Pending => PaymentStatus::InProgress, + QueryResponseStatus::NotFound => PaymentStatus::Unknown, + } + } +} From e6102f67a7ff089900ad99c715bfaf5061e70ae8 Mon Sep 17 00:00:00 2001 From: Anthony Alaribe Date: Wed, 22 Mar 2023 15:53:27 +0000 Subject: [PATCH 04/31] fix the PayOverXcm trait to compile --- xcm/pallet-xcm/src/lib.rs | 6 ++- xcm/src/v3/mod.rs | 4 +- xcm/src/v3/traits.rs | 21 +--------- xcm/xcm-builder/src/pay.rs | 21 +++++----- xcm/xcm-executor/src/traits/mod.rs | 2 +- xcm/xcm-executor/src/traits/on_response.rs | 47 ++++++++++++++++++++++ 6 files changed, 65 insertions(+), 36 deletions(-) diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index 559b3de87d89..df792df01c3a 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -52,7 +52,8 @@ use frame_system::pallet_prelude::*; pub use pallet::*; use xcm_executor::{ traits::{ - ClaimAssets, DropAssets, MatchesFungible, OnResponse, VersionChangeNotifier, WeightBounds, + ClaimAssets, DropAssets, MatchesFungible, OnResponse, QueryResponseStatus, + VersionChangeNotifier, WeightBounds, XcmQueryHandler, }, Assets, }; @@ -1101,6 +1102,7 @@ const MAX_ASSETS_FOR_TRANSFER: usize = 2; impl XcmQueryHandler for Pallet { type QueryId = u64; type BlockNumber = T::BlockNumber; + type Error = XcmError; /// Consume `message` and return another which is equivalent to it except that it reports /// back the outcome. @@ -1120,7 +1122,7 @@ impl XcmQueryHandler for Pallet { message: &mut Xcm<()>, responder: impl Into, timeout: Self::BlockNumber, - ) -> Result { + ) -> Result { let responder = responder.into(); let destination = T::UniversalLocation::get() .invert_target(&responder) diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index 80beb465b998..ff94c1392fea 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -171,9 +171,7 @@ impl From> for Vec> { pub mod prelude { mod contents { pub use super::super::{ - send_xcm, - traits::{QueryResponseStatus, XcmQueryHandler}, - validate_send, Ancestor, AncestorThen, + send_xcm, validate_send, Ancestor, AncestorThen, AssetId::{self, *}, AssetInstance::{self, *}, BodyId, BodyPart, Error as XcmError, ExecuteXcm, diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index 03d06026d32c..b752647b0819 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -18,7 +18,7 @@ use crate::v2::Error as OldError; use core::result; -use parity_scale_codec::{Decode, Encode, FullCodec, MaxEncodedLen}; +use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; pub use sp_weights::Weight; @@ -539,22 +539,3 @@ pub fn send_xcm( let hash = T::deliver(ticket)?; Ok((hash, price)) } - -pub enum QueryResponseStatus { - Finished { response: Response, at: BlockNumber }, - Pending, - NotFound, -} - -/// Represents the -pub trait XcmQueryHandler { - type QueryId: FullCodec + MaxEncodedLen + TypeInfo + Clone + Eq + PartialEq + Debug + Copy; - type BlockNumber; - - fn report_outcome( - message: &mut Xcm<()>, - responder: impl Into, - timeout: Self::BlockNumber, - ) -> result::Result; - fn take_response(id: Self::QueryId) -> QueryResponseStatus; -} diff --git a/xcm/xcm-builder/src/pay.rs b/xcm/xcm-builder/src/pay.rs index b030fac6fc22..7a39c2c09501 100644 --- a/xcm/xcm-builder/src/pay.rs +++ b/xcm/xcm-builder/src/pay.rs @@ -22,30 +22,29 @@ use frame_support::traits::{ }; use sp_std::{marker::PhantomData, vec}; use xcm::prelude::*; +use xcm_executor::traits::{QueryResponseStatus, XcmQueryHandler}; -pub struct PayOverXcm( - PhantomData<(DestChain, Router, Querier, BlockNumber)>, +pub struct PayOverXcm( + PhantomData<(DestChain, Router, Querier, BlockNumber, Timeout)>, ); impl< DestChain: Get, Router: SendXcm, Querier: XcmQueryHandler, BlockNumber, - > Pay for PayOverXcm + Timeout: Get, + > Pay for PayOverXcm { type Beneficiary = MultiLocation; type AssetKind = xcm::v3::AssetId; type Balance = u128; type Id = Querier::QueryId; - type Timeout = Querier::BlockNumber; - type Error = XcmError; fn pay( who: &Self::Beneficiary, asset_kind: Self::AssetKind, amount: Self::Balance, - timeout: Self::Timeout, - ) -> Result { + ) -> Result { let mut message = Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, TransferAsset { @@ -55,9 +54,11 @@ impl< }, ]); let destination = DestChain::get(); - let id = Querier::report_outcome(&mut message, destination, timeout)?; - let (ticket, _multiassets) = Router::validate(&mut Some(destination), &mut Some(message))?; - Router::deliver(ticket)?; + let id = + Querier::report_outcome(&mut message, destination, Timeout::get()).map_err(|_| ())?; + let (ticket, _multiassets) = + Router::validate(&mut Some(destination), &mut Some(message)).map_err(|_| ())?; + Router::deliver(ticket).map_err(|_| ())?; Ok(id) } diff --git a/xcm/xcm-executor/src/traits/mod.rs b/xcm/xcm-executor/src/traits/mod.rs index f78226a2135b..e8af18bfc35d 100644 --- a/xcm/xcm-executor/src/traits/mod.rs +++ b/xcm/xcm-executor/src/traits/mod.rs @@ -38,7 +38,7 @@ pub use token_matching::{ Error, MatchesFungible, MatchesFungibles, MatchesNonFungible, MatchesNonFungibles, }; mod on_response; -pub use on_response::{OnResponse, VersionChangeNotifier}; +pub use on_response::{OnResponse, QueryResponseStatus, VersionChangeNotifier, XcmQueryHandler}; mod should_execute; pub use should_execute::ShouldExecute; mod transact_asset; diff --git a/xcm/xcm-executor/src/traits/on_response.rs b/xcm/xcm-executor/src/traits/on_response.rs index dcb7d924d799..b358f5c9f118 100644 --- a/xcm/xcm-executor/src/traits/on_response.rs +++ b/xcm/xcm-executor/src/traits/on_response.rs @@ -14,6 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . +use crate::Xcm; +use core::result; +use frame_support::{dispatch::fmt::Debug, pallet_prelude::TypeInfo}; +use parity_scale_codec::{FullCodec, MaxEncodedLen}; use xcm::latest::{ Error as XcmError, MultiLocation, QueryId, Response, Result as XcmResult, Weight, XcmContext, }; @@ -94,3 +98,46 @@ impl VersionChangeNotifier for () { false } } + +// An indication of the state of an XCM command +// - `Finished` - Indicates that the command was executed, and includes the Success or Error response of the command. +// - `Pending` - Indicates being aware of the xCM command has not yet completed, or a response has +// not been returned yet +// - `NotFound` - Not XCM command with the given `QueryId` was found +pub enum QueryResponseStatus { + Finished { response: Response, at: BlockNumber }, + Pending, + NotFound, +} + +/// XcmQueryHandler provides a way execute XCM messages which we can track the execution status of. +pub trait XcmQueryHandler { + type QueryId: FullCodec + MaxEncodedLen + TypeInfo + Clone + Eq + PartialEq + Debug + Copy; + type BlockNumber; + type Error; + + /// 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. + fn report_outcome( + message: &mut Xcm<()>, + responder: impl Into, + timeout: Self::BlockNumber, + ) -> result::Result; + + /// Attempt to remove and return the response of query with ID `query_id`. + /// + /// Returns `None` if the response is not (yet) available. + fn take_response(id: Self::QueryId) -> QueryResponseStatus; +} From 20f9e1fdd4cbd682ccfa61c55b5224cd43832a52 Mon Sep 17 00:00:00 2001 From: Anthony Alaribe Date: Wed, 22 Mar 2023 16:02:20 +0000 Subject: [PATCH 05/31] moved doc comment out of trait implmeentation and to the trait --- xcm/pallet-xcm/src/lib.rs | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index df792df01c3a..c6a5d5ca91ed 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -1104,20 +1104,6 @@ impl XcmQueryHandler for Pallet { type BlockNumber = T::BlockNumber; type Error = XcmError; - /// 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. fn report_outcome( message: &mut Xcm<()>, responder: impl Into, @@ -1134,9 +1120,6 @@ impl XcmQueryHandler for Pallet { Ok(query_id) } - /// Attempt to remove and return the response of query with ID `query_id`. - /// - /// Returns `None` if the response is not (yet) available. fn take_response(query_id: Self::QueryId) -> QueryResponseStatus { match Queries::::get(query_id) { Some(QueryStatus::Ready { response, at }) => { From 1a31c92b2933cfdd30c856fa9dfab5c0c1667a84 Mon Sep 17 00:00:00 2001 From: Anthony Alaribe Date: Wed, 22 Mar 2023 16:16:12 +0000 Subject: [PATCH 06/31] PayOverXCM documentation --- xcm/xcm-builder/src/pay.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/xcm/xcm-builder/src/pay.rs b/xcm/xcm-builder/src/pay.rs index 7a39c2c09501..6a698c40978e 100644 --- a/xcm/xcm-builder/src/pay.rs +++ b/xcm/xcm-builder/src/pay.rs @@ -24,6 +24,13 @@ use sp_std::{marker::PhantomData, vec}; use xcm::prelude::*; use xcm_executor::traits::{QueryResponseStatus, XcmQueryHandler}; +// `PayOverXcm` is a type which implements the `frame_support_traits::tokens::Pay` trait, to allow +// for generic payments of a given `AssetKind` and `Balance` from an implied target, to a +// beneficiary via XCM, and relying on an XCM `TransferAsset` operation. +// +// `PayOverXcm::pay` is asynchronous, and returns a `QueryId` which can then be used via +// `check_payment` to check the status of the xcm transaction transaction. +// pub struct PayOverXcm( PhantomData<(DestChain, Router, Querier, BlockNumber, Timeout)>, ); @@ -56,7 +63,7 @@ impl< let destination = DestChain::get(); let id = Querier::report_outcome(&mut message, destination, Timeout::get()).map_err(|_| ())?; - let (ticket, _multiassets) = + let (ticket, _) = Router::validate(&mut Some(destination), &mut Some(message)).map_err(|_| ())?; Router::deliver(ticket).map_err(|_| ())?; Ok(id) From 4030f146bd2ae9581a29c03947f7200f2fac36e7 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Wed, 22 Mar 2023 13:47:38 -0300 Subject: [PATCH 07/31] Change documentation a bit --- xcm/pallet-xcm/src/lib.rs | 2 ++ xcm/xcm-executor/src/traits/on_response.rs | 21 +++++++++------------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index c6a5d5ca91ed..d74edcb3e15a 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -1104,6 +1104,8 @@ impl XcmQueryHandler for Pallet { type BlockNumber = T::BlockNumber; type Error = XcmError; + /// To check the status of the query, use `fn query()` passing the resultant `QueryId` + /// value. fn report_outcome( message: &mut Xcm<()>, responder: impl Into, diff --git a/xcm/xcm-executor/src/traits/on_response.rs b/xcm/xcm-executor/src/traits/on_response.rs index b358f5c9f118..12335a31a423 100644 --- a/xcm/xcm-executor/src/traits/on_response.rs +++ b/xcm/xcm-executor/src/traits/on_response.rs @@ -99,18 +99,17 @@ impl VersionChangeNotifier for () { } } -// An indication of the state of an XCM command -// - `Finished` - Indicates that the command was executed, and includes the Success or Error response of the command. -// - `Pending` - Indicates being aware of the xCM command has not yet completed, or a response has -// not been returned yet -// - `NotFound` - Not XCM command with the given `QueryId` was found +/// The possible state of an XCM query response: +/// - `Finished`: The response has arrived, and includes the inner Response and the block number it arrived at. +/// - `Pending`: The response has not yet arrived, the XCM might still be executing or the response might be in transit. +/// - `NotFound`: No response with the given `QueryId` was found, or the response was already queried and removed from local storage. pub enum QueryResponseStatus { Finished { response: Response, at: BlockNumber }, Pending, NotFound, } -/// XcmQueryHandler provides a way execute XCM messages which we can track the execution status of. +/// Provides methods to expect responses from XCMs and query their status. pub trait XcmQueryHandler { type QueryId: FullCodec + MaxEncodedLen + TypeInfo + Clone + Eq + PartialEq + Debug + Copy; type BlockNumber; @@ -121,15 +120,12 @@ pub trait XcmQueryHandler { /// /// - `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. + /// - `timeout`: The block number after which it is permissible to return `NotFound` from `take_response`. /// /// `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. + /// The response can be queried with `take_response`. fn report_outcome( message: &mut Xcm<()>, responder: impl Into, @@ -138,6 +134,7 @@ pub trait XcmQueryHandler { /// Attempt to remove and return the response of query with ID `query_id`. /// - /// Returns `None` if the response is not (yet) available. + /// Returns `Pending` if the response is not yet available. + /// Returns `NotFound` if the response is not available and won't ever be. fn take_response(id: Self::QueryId) -> QueryResponseStatus; } From 6d2a686eb4de1255a8d7017585d4894be919a9e1 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Wed, 22 Mar 2023 17:22:03 -0300 Subject: [PATCH 08/31] Added empty benchmark methods implementation and changed docs --- xcm/xcm-builder/src/pay.rs | 20 +++++++++++++------- xcm/xcm-executor/src/traits/on_response.rs | 8 ++++---- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/xcm/xcm-builder/src/pay.rs b/xcm/xcm-builder/src/pay.rs index 6a698c40978e..53b358036e91 100644 --- a/xcm/xcm-builder/src/pay.rs +++ b/xcm/xcm-builder/src/pay.rs @@ -24,13 +24,13 @@ use sp_std::{marker::PhantomData, vec}; use xcm::prelude::*; use xcm_executor::traits::{QueryResponseStatus, XcmQueryHandler}; -// `PayOverXcm` is a type which implements the `frame_support_traits::tokens::Pay` trait, to allow -// for generic payments of a given `AssetKind` and `Balance` from an implied target, to a -// beneficiary via XCM, and relying on an XCM `TransferAsset` operation. -// -// `PayOverXcm::pay` is asynchronous, and returns a `QueryId` which can then be used via -// `check_payment` to check the status of the xcm transaction transaction. -// +/// Implementation of the `frame_support_traits::tokens::Pay` trait, to allow +/// for generic payments of a given `AssetKind` and `Balance` from an implied origin, to a +/// beneficiary via XCM, relying on the XCM `TransferAsset` instruction. +/// +/// `PayOverXcm::pay` is asynchronous, and returns a `QueryId` which can then be used in +/// `check_payment` to check the status of the XCM transaction. +/// pub struct PayOverXcm( PhantomData<(DestChain, Router, Querier, BlockNumber, Timeout)>, ); @@ -80,4 +80,10 @@ impl< QueryResponseStatus::NotFound => PaymentStatus::Unknown, } } + + #[cfg(feature = "runtime-benchmarks")] + fn ensure_successful(_: &Self::Beneficiary, amount: Self::Balance) {} + + #[cfg(feature = "runtime-benchmarks")] + fn ensure_concluded(_: Self::Id) {} } diff --git a/xcm/xcm-executor/src/traits/on_response.rs b/xcm/xcm-executor/src/traits/on_response.rs index 12335a31a423..5316cd0ced87 100644 --- a/xcm/xcm-executor/src/traits/on_response.rs +++ b/xcm/xcm-executor/src/traits/on_response.rs @@ -99,13 +99,13 @@ impl VersionChangeNotifier for () { } } -/// The possible state of an XCM query response: -/// - `Finished`: The response has arrived, and includes the inner Response and the block number it arrived at. -/// - `Pending`: The response has not yet arrived, the XCM might still be executing or the response might be in transit. -/// - `NotFound`: No response with the given `QueryId` was found, or the response was already queried and removed from local storage. +/// The possible state of an XCM query response. pub enum QueryResponseStatus { + /// The response has arrived, and includes the inner Response and the block number it arrived at. Finished { response: Response, at: BlockNumber }, + /// The response has not yet arrived, the XCM might still be executing or the response might be in transit. Pending, + /// No response with the given `QueryId` was found, or the response was already queried and removed from local storage. NotFound, } From 1331aa56168b68379b6eae2c0ceac07ffd0ea955 Mon Sep 17 00:00:00 2001 From: Anthony Alaribe Date: Thu, 23 Mar 2023 16:46:11 +0000 Subject: [PATCH 09/31] update PayOverXCM to convert AccountIds to MultiLocations --- xcm/xcm-builder/src/pay.rs | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/xcm/xcm-builder/src/pay.rs b/xcm/xcm-builder/src/pay.rs index 53b358036e91..3c7ab09764fd 100644 --- a/xcm/xcm-builder/src/pay.rs +++ b/xcm/xcm-builder/src/pay.rs @@ -22,7 +22,7 @@ use frame_support::traits::{ }; use sp_std::{marker::PhantomData, vec}; use xcm::prelude::*; -use xcm_executor::traits::{QueryResponseStatus, XcmQueryHandler}; +use xcm_executor::traits::{Convert, QueryResponseStatus, XcmQueryHandler}; /// Implementation of the `frame_support_traits::tokens::Pay` trait, to allow /// for generic payments of a given `AssetKind` and `Balance` from an implied origin, to a @@ -31,18 +31,27 @@ use xcm_executor::traits::{QueryResponseStatus, XcmQueryHandler}; /// `PayOverXcm::pay` is asynchronous, and returns a `QueryId` which can then be used in /// `check_payment` to check the status of the XCM transaction. /// -pub struct PayOverXcm( - PhantomData<(DestChain, Router, Querier, BlockNumber, Timeout)>, -); +pub struct PayOverXcm< + DestChain, + Router, + Querier, + BlockNumber, + Timeout, + AccountId, + AccountIdConverter, +>(PhantomData<(DestChain, Router, Querier, BlockNumber, Timeout, AccountId, AccountIdConverter)>); impl< DestChain: Get, Router: SendXcm, Querier: XcmQueryHandler, BlockNumber, Timeout: Get, - > Pay for PayOverXcm + AccountId: Clone, + AccountIdConverter: Convert, + > Pay + for PayOverXcm { - type Beneficiary = MultiLocation; + type Beneficiary = AccountId; type AssetKind = xcm::v3::AssetId; type Balance = u128; type Id = Querier::QueryId; @@ -52,10 +61,11 @@ impl< asset_kind: Self::AssetKind, amount: Self::Balance, ) -> Result { + let beneficiary = AccountIdConverter::reverse(who.clone()).map_err(|_| ())?; let mut message = Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, TransferAsset { - beneficiary: *who, + beneficiary, assets: vec![MultiAsset { id: asset_kind, fun: Fungibility::Fungible(amount) }] .into(), }, From 117c169f0bc61307c9b07fb769b3c3dab1d800c0 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Fri, 24 Mar 2023 12:42:14 -0300 Subject: [PATCH 10/31] Implement benchmarking method --- xcm/pallet-xcm/src/lib.rs | 9 +++++++++ xcm/xcm-builder/src/pay.rs | 6 ++++-- xcm/xcm-executor/src/traits/on_response.rs | 4 ++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index d74edcb3e15a..df9b2237331b 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -1139,6 +1139,15 @@ impl XcmQueryHandler for Pallet { _ => QueryResponseStatus::NotFound, } } + + #[cfg(feature = "runtime-benchmarks")] + fn expect_response(id: Self::QueryId) { + let query_status = QueryStatus::Ready { + response: VersionedResponse::V3(Response::Null), + at: Self::BlockNumber::default(), + }; + Queries::::insert(id, query_status); + } } impl Pallet { diff --git a/xcm/xcm-builder/src/pay.rs b/xcm/xcm-builder/src/pay.rs index 3c7ab09764fd..72db905559e1 100644 --- a/xcm/xcm-builder/src/pay.rs +++ b/xcm/xcm-builder/src/pay.rs @@ -92,8 +92,10 @@ impl< } #[cfg(feature = "runtime-benchmarks")] - fn ensure_successful(_: &Self::Beneficiary, amount: Self::Balance) {} + fn ensure_successful(_: &Self::Beneficiary, _: Self::Balance) {} #[cfg(feature = "runtime-benchmarks")] - fn ensure_concluded(_: Self::Id) {} + fn ensure_concluded(id: Self::Id) { + Querier::expect_response(id); + } } diff --git a/xcm/xcm-executor/src/traits/on_response.rs b/xcm/xcm-executor/src/traits/on_response.rs index 5316cd0ced87..562c4adecf62 100644 --- a/xcm/xcm-executor/src/traits/on_response.rs +++ b/xcm/xcm-executor/src/traits/on_response.rs @@ -132,6 +132,10 @@ pub trait XcmQueryHandler { timeout: Self::BlockNumber, ) -> result::Result; + /// Makes sure to expect a response with the given id + /// Used for bencharks. + fn expect_response(id: Self::QueryId); + /// Attempt to remove and return the response of query with ID `query_id`. /// /// Returns `Pending` if the response is not yet available. From 94a30c88c2ea08583afb2b3722139e488cf91fba Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Fri, 24 Mar 2023 16:54:30 -0300 Subject: [PATCH 11/31] Change v3 to latest --- xcm/pallet-xcm/src/lib.rs | 1 - xcm/xcm-builder/src/pay.rs | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index df9b2237331b..ad5c9c240333 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -1140,7 +1140,6 @@ impl XcmQueryHandler for Pallet { } } - #[cfg(feature = "runtime-benchmarks")] fn expect_response(id: Self::QueryId) { let query_status = QueryStatus::Ready { response: VersionedResponse::V3(Response::Null), diff --git a/xcm/xcm-builder/src/pay.rs b/xcm/xcm-builder/src/pay.rs index 72db905559e1..88a4224aae4c 100644 --- a/xcm/xcm-builder/src/pay.rs +++ b/xcm/xcm-builder/src/pay.rs @@ -41,7 +41,7 @@ pub struct PayOverXcm< AccountIdConverter, >(PhantomData<(DestChain, Router, Querier, BlockNumber, Timeout, AccountId, AccountIdConverter)>); impl< - DestChain: Get, + DestChain: Get, Router: SendXcm, Querier: XcmQueryHandler, BlockNumber, @@ -52,7 +52,7 @@ impl< for PayOverXcm { type Beneficiary = AccountId; - type AssetKind = xcm::v3::AssetId; + type AssetKind = xcm::latest::AssetId; type Balance = u128; type Id = Querier::QueryId; From 6c0decefe3f7cd29ecbe53c3a30f438928f5eab9 Mon Sep 17 00:00:00 2001 From: Muharem Ismailov Date: Wed, 29 Mar 2023 16:55:41 +0200 Subject: [PATCH 12/31] Descend origin to an asset sender (#6970) * descend origin to an asset sender * sender as tuple of dest and sender --- xcm/xcm-builder/src/pay.rs | 47 ++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/xcm/xcm-builder/src/pay.rs b/xcm/xcm-builder/src/pay.rs index 88a4224aae4c..839bdd4324b3 100644 --- a/xcm/xcm-builder/src/pay.rs +++ b/xcm/xcm-builder/src/pay.rs @@ -22,7 +22,7 @@ use frame_support::traits::{ }; use sp_std::{marker::PhantomData, vec}; use xcm::prelude::*; -use xcm_executor::traits::{Convert, QueryResponseStatus, XcmQueryHandler}; +use xcm_executor::traits::{QueryResponseStatus, XcmQueryHandler}; /// Implementation of the `frame_support_traits::tokens::Pay` trait, to allow /// for generic payments of a given `AssetKind` and `Balance` from an implied origin, to a @@ -31,28 +31,20 @@ use xcm_executor::traits::{Convert, QueryResponseStatus, XcmQueryHandler}; /// `PayOverXcm::pay` is asynchronous, and returns a `QueryId` which can then be used in /// `check_payment` to check the status of the XCM transaction. /// -pub struct PayOverXcm< - DestChain, - Router, - Querier, - BlockNumber, - Timeout, - AccountId, - AccountIdConverter, ->(PhantomData<(DestChain, Router, Querier, BlockNumber, Timeout, AccountId, AccountIdConverter)>); +pub struct PayOverXcm( + PhantomData<(Sender, Router, Querier, Timeout, Beneficiary, AssetKind)>, +); impl< - DestChain: Get, + Sender: Get<(MultiLocation, InteriorMultiLocation)>, Router: SendXcm, Querier: XcmQueryHandler, - BlockNumber, Timeout: Get, - AccountId: Clone, - AccountIdConverter: Convert, - > Pay - for PayOverXcm + Beneficiary: Into + Clone, + AssetKind: Into, + > Pay for PayOverXcm { - type Beneficiary = AccountId; - type AssetKind = xcm::latest::AssetId; + type Beneficiary = Beneficiary; + type AssetKind = AssetKind; type Balance = u128; type Id = Querier::QueryId; @@ -61,20 +53,21 @@ impl< asset_kind: Self::AssetKind, amount: Self::Balance, ) -> Result { - let beneficiary = AccountIdConverter::reverse(who.clone()).map_err(|_| ())?; + let (dest, sender) = Sender::get(); let mut message = Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + DescendOrigin(sender), TransferAsset { - beneficiary, - assets: vec![MultiAsset { id: asset_kind, fun: Fungibility::Fungible(amount) }] - .into(), + beneficiary: who.clone().into(), + assets: vec![MultiAsset { + id: asset_kind.into(), + fun: Fungibility::Fungible(amount), + }] + .into(), }, ]); - let destination = DestChain::get(); - let id = - Querier::report_outcome(&mut message, destination, Timeout::get()).map_err(|_| ())?; - let (ticket, _) = - Router::validate(&mut Some(destination), &mut Some(message)).map_err(|_| ())?; + let id = Querier::report_outcome(&mut message, dest, Timeout::get()).map_err(|_| ())?; + let (ticket, _) = Router::validate(&mut Some(dest), &mut Some(message)).map_err(|_| ())?; Router::deliver(ticket).map_err(|_| ())?; Ok(id) } From ec24eba15d489efe396af376c9c4ccbd2e5d6e07 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Thu, 30 Mar 2023 20:30:36 -0300 Subject: [PATCH 13/31] Add more variants to the QueryResponseStatus enum --- xcm/pallet-xcm/src/lib.rs | 19 +++++++++++++++---- xcm/pallet-xcm/src/tests.rs | 15 ++++++++++++--- xcm/xcm-builder/src/pay.rs | 18 +++++++++++------- xcm/xcm-executor/src/traits/mod.rs | 4 +++- xcm/xcm-executor/src/traits/on_response.rs | 12 +++++++++++- 5 files changed, 52 insertions(+), 16 deletions(-) diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index ad5c9c240333..23164e579743 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -52,7 +52,7 @@ use frame_system::pallet_prelude::*; pub use pallet::*; use xcm_executor::{ traits::{ - ClaimAssets, DropAssets, MatchesFungible, OnResponse, QueryResponseStatus, + ClaimAssets, DropAssets, FinishedQuery, MatchesFungible, OnResponse, QueryResponseStatus, VersionChangeNotifier, WeightBounds, XcmQueryHandler, }, Assets, @@ -1130,13 +1130,24 @@ impl XcmQueryHandler for Pallet { Ok(response) => { Queries::::remove(query_id); Self::deposit_event(Event::ResponseTaken(query_id)); - QueryResponseStatus::Finished { response, at } + QueryResponseStatus::Finished(FinishedQuery::Response { response, at }) }, - Err(_) => QueryResponseStatus::NotFound, // Found unexpected version + Err(_) => QueryResponseStatus::UnexpectedVersion, + } + }, + Some(QueryStatus::VersionNotifier { origin, is_active }) => { + let origin = origin.try_into(); + match origin { + Ok(origin) => + QueryResponseStatus::Finished(FinishedQuery::VersionNotification { + origin, + is_active, + }), + Err(_) => QueryResponseStatus::UnexpectedVersion, } }, Some(QueryStatus::Pending { .. }) => QueryResponseStatus::Pending, - _ => QueryResponseStatus::NotFound, + None => QueryResponseStatus::NotFound, } } diff --git a/xcm/pallet-xcm/src/tests.rs b/xcm/pallet-xcm/src/tests.rs index ae359116e023..5d999c825cc5 100644 --- a/xcm/pallet-xcm/src/tests.rs +++ b/xcm/pallet-xcm/src/tests.rs @@ -27,7 +27,10 @@ use polkadot_parachain::primitives::Id as ParaId; use sp_runtime::traits::{AccountIdConversion, BlakeTwo256, Hash}; use xcm::{latest::QueryResponseInfo, prelude::*}; use xcm_builder::AllowKnownQueryResponses; -use xcm_executor::{traits::ShouldExecute, XcmExecutor}; +use xcm_executor::{ + traits::{FinishedQuery, QueryResponseStatus, ShouldExecute, XcmQueryHandler}, + XcmExecutor, +}; const ALICE: AccountId = AccountId::new([0u8; 32]); const BOB: AccountId = AccountId::new([1u8; 32]); @@ -163,7 +166,10 @@ fn report_outcome_works() { )) ); - let response = Some((Response::ExecutionResult(None), 1)); + let response = QueryResponseStatus::Finished(FinishedQuery::Response { + response: Response::ExecutionResult(None), + at: 1, + }); assert_eq!(XcmPallet::take_response(0), response); }); } @@ -263,7 +269,10 @@ fn custom_querier_works() { )) ); - let response = Some((Response::ExecutionResult(None), 1)); + let response = QueryResponseStatus::Finished(FinishedQuery::Response { + response: Response::ExecutionResult(None), + at: 1, + }); assert_eq!(XcmPallet::take_response(0), response); }); } diff --git a/xcm/xcm-builder/src/pay.rs b/xcm/xcm-builder/src/pay.rs index 839bdd4324b3..bbbf60e0500e 100644 --- a/xcm/xcm-builder/src/pay.rs +++ b/xcm/xcm-builder/src/pay.rs @@ -22,7 +22,7 @@ use frame_support::traits::{ }; use sp_std::{marker::PhantomData, vec}; use xcm::prelude::*; -use xcm_executor::traits::{QueryResponseStatus, XcmQueryHandler}; +use xcm_executor::traits::{FinishedQuery, QueryResponseStatus, XcmQueryHandler}; /// Implementation of the `frame_support_traits::tokens::Pay` trait, to allow /// for generic payments of a given `AssetKind` and `Balance` from an implied origin, to a @@ -74,13 +74,17 @@ impl< fn check_payment(id: Self::Id) -> PaymentStatus { match Querier::take_response(id) { - QueryResponseStatus::Finished { response, at: _ } => match response { - Response::ExecutionResult(Some(_)) => PaymentStatus::Failure, - Response::ExecutionResult(None) => PaymentStatus::Success, - _ => PaymentStatus::Unknown, - }, + QueryResponseStatus::Finished(FinishedQuery::Response { response, at: _ }) => + match response { + Response::ExecutionResult(Some(_)) => PaymentStatus::Failure, + Response::ExecutionResult(None) => PaymentStatus::Success, + _ => PaymentStatus::Unknown, + }, QueryResponseStatus::Pending => PaymentStatus::InProgress, - QueryResponseStatus::NotFound => PaymentStatus::Unknown, + QueryResponseStatus::NotFound | + QueryResponseStatus::UnexpectedVersion | + QueryResponseStatus::Finished(FinishedQuery::VersionNotification { .. }) => + PaymentStatus::Unknown, } } diff --git a/xcm/xcm-executor/src/traits/mod.rs b/xcm/xcm-executor/src/traits/mod.rs index e8af18bfc35d..63db3ecc0f0a 100644 --- a/xcm/xcm-executor/src/traits/mod.rs +++ b/xcm/xcm-executor/src/traits/mod.rs @@ -38,7 +38,9 @@ pub use token_matching::{ Error, MatchesFungible, MatchesFungibles, MatchesNonFungible, MatchesNonFungibles, }; mod on_response; -pub use on_response::{OnResponse, QueryResponseStatus, VersionChangeNotifier, XcmQueryHandler}; +pub use on_response::{ + FinishedQuery, OnResponse, QueryResponseStatus, VersionChangeNotifier, XcmQueryHandler, +}; mod should_execute; pub use should_execute::ShouldExecute; mod transact_asset; diff --git a/xcm/xcm-executor/src/traits/on_response.rs b/xcm/xcm-executor/src/traits/on_response.rs index 562c4adecf62..9e1911de9b55 100644 --- a/xcm/xcm-executor/src/traits/on_response.rs +++ b/xcm/xcm-executor/src/traits/on_response.rs @@ -99,14 +99,23 @@ impl VersionChangeNotifier for () { } } +#[derive(Debug, PartialEq, Eq)] +pub enum FinishedQuery { + Response { response: Response, at: BlockNumber }, + VersionNotification { origin: MultiLocation, is_active: bool }, +} + /// The possible state of an XCM query response. +#[derive(Debug, PartialEq, Eq)] pub enum QueryResponseStatus { /// The response has arrived, and includes the inner Response and the block number it arrived at. - Finished { response: Response, at: BlockNumber }, + Finished(FinishedQuery), /// The response has not yet arrived, the XCM might still be executing or the response might be in transit. Pending, /// No response with the given `QueryId` was found, or the response was already queried and removed from local storage. NotFound, + /// Got an unexpected XCM version. + UnexpectedVersion, } /// Provides methods to expect responses from XCMs and query their status. @@ -138,6 +147,7 @@ pub trait XcmQueryHandler { /// Attempt to remove and return the response of query with ID `query_id`. /// + /// Returns `Finished` if the response is available and includes inner response. /// Returns `Pending` if the response is not yet available. /// Returns `NotFound` if the response is not available and won't ever be. fn take_response(id: Self::QueryId) -> QueryResponseStatus; From 6aa7b203d9fda6a4bac9fe11d26303818fddca42 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Tue, 4 Apr 2023 17:12:20 -0300 Subject: [PATCH 14/31] Change Beneficiary to Into<[u8; 32]> --- xcm/xcm-builder/src/pay.rs | 41 ++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/xcm/xcm-builder/src/pay.rs b/xcm/xcm-builder/src/pay.rs index bbbf60e0500e..2880da80b55b 100644 --- a/xcm/xcm-builder/src/pay.rs +++ b/xcm/xcm-builder/src/pay.rs @@ -31,17 +31,35 @@ use xcm_executor::traits::{FinishedQuery, QueryResponseStatus, XcmQueryHandler}; /// `PayOverXcm::pay` is asynchronous, and returns a `QueryId` which can then be used in /// `check_payment` to check the status of the XCM transaction. /// -pub struct PayOverXcm( - PhantomData<(Sender, Router, Querier, Timeout, Beneficiary, AssetKind)>, +pub struct PayOverXcm< + DestinationChain, + SenderAccount, + Router, + Querier, + Timeout, + Beneficiary, + AssetKind, +>( + PhantomData<( + DestinationChain, + SenderAccount, + Router, + Querier, + Timeout, + Beneficiary, + AssetKind, + )>, ); impl< - Sender: Get<(MultiLocation, InteriorMultiLocation)>, + DestinationChain: Get, + SenderAccount: Get, Router: SendXcm, Querier: XcmQueryHandler, Timeout: Get, - Beneficiary: Into + Clone, + Beneficiary: Into<[u8; 32]> + Clone, AssetKind: Into, - > Pay for PayOverXcm + > Pay + for PayOverXcm { type Beneficiary = Beneficiary; type AssetKind = AssetKind; @@ -53,12 +71,13 @@ impl< asset_kind: Self::AssetKind, amount: Self::Balance, ) -> Result { - let (dest, sender) = Sender::get(); + let destination_chain = DestinationChain::get(); + let sender_account = SenderAccount::get(); let mut message = Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - DescendOrigin(sender), + DescendOrigin(sender_account), TransferAsset { - beneficiary: who.clone().into(), + beneficiary: AccountId32 { network: None, id: who.clone().into() }.into(), assets: vec![MultiAsset { id: asset_kind.into(), fun: Fungibility::Fungible(amount), @@ -66,8 +85,10 @@ impl< .into(), }, ]); - let id = Querier::report_outcome(&mut message, dest, Timeout::get()).map_err(|_| ())?; - let (ticket, _) = Router::validate(&mut Some(dest), &mut Some(message)).map_err(|_| ())?; + let id = Querier::report_outcome(&mut message, destination_chain, Timeout::get()) + .map_err(|_| ())?; + let (ticket, _) = + Router::validate(&mut Some(destination_chain), &mut Some(message)).map_err(|_| ())?; Router::deliver(ticket).map_err(|_| ())?; Ok(id) } From 41fe1d8167e09c15bec057f04a1e7912d6865be1 Mon Sep 17 00:00:00 2001 From: Anthony Alaribe Date: Thu, 20 Apr 2023 21:38:12 +0200 Subject: [PATCH 15/31] update PayOverXcm to return concrete errors and use AccountId as sender --- xcm/xcm-builder/src/pay.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/xcm/xcm-builder/src/pay.rs b/xcm/xcm-builder/src/pay.rs index 2880da80b55b..6c0151b5f619 100644 --- a/xcm/xcm-builder/src/pay.rs +++ b/xcm/xcm-builder/src/pay.rs @@ -20,6 +20,7 @@ use frame_support::traits::{ tokens::{Pay, PaymentStatus}, Get, }; +use primitives::AccountId; use sp_std::{marker::PhantomData, vec}; use xcm::prelude::*; use xcm_executor::traits::{FinishedQuery, QueryResponseStatus, XcmQueryHandler}; @@ -52,7 +53,7 @@ pub struct PayOverXcm< ); impl< DestinationChain: Get, - SenderAccount: Get, + SenderAccount: Get, Router: SendXcm, Querier: XcmQueryHandler, Timeout: Get, @@ -65,17 +66,20 @@ impl< type AssetKind = AssetKind; type Balance = u128; type Id = Querier::QueryId; + type Error = xcm::latest::Error; fn pay( who: &Self::Beneficiary, asset_kind: Self::AssetKind, amount: Self::Balance, - ) -> Result { + ) -> Result { let destination_chain = DestinationChain::get(); let sender_account = SenderAccount::get(); let mut message = Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - DescendOrigin(sender_account), + DescendOrigin( + Junction::AccountId32 { network: None, id: sender_account.into() }.into(), + ), TransferAsset { beneficiary: AccountId32 { network: None, id: who.clone().into() }.into(), assets: vec![MultiAsset { @@ -86,10 +90,9 @@ impl< }, ]); let id = Querier::report_outcome(&mut message, destination_chain, Timeout::get()) - .map_err(|_| ())?; - let (ticket, _) = - Router::validate(&mut Some(destination_chain), &mut Some(message)).map_err(|_| ())?; - Router::deliver(ticket).map_err(|_| ())?; + .map_err(|_| Self::Error::LocationNotInvertible)?; + let (ticket, _) = Router::validate(&mut Some(destination_chain), &mut Some(message))?; + Router::deliver(ticket)?; Ok(id) } From 13ceb402f5a1f92f4c93cea1504314c1ad32122f Mon Sep 17 00:00:00 2001 From: Anthony Alaribe Date: Fri, 21 Apr 2023 10:14:53 +0200 Subject: [PATCH 16/31] use polkadot-primitives for AccountId --- Cargo.lock | 1 + xcm/xcm-builder/Cargo.toml | 1 + xcm/xcm-builder/src/pay.rs | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 23abf35bbaba..2917328ca963 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14102,6 +14102,7 @@ dependencies = [ "pallet-xcm", "parity-scale-codec", "polkadot-parachain", + "polkadot-primitives", "polkadot-runtime-parachains", "primitive-types", "scale-info", diff --git a/xcm/xcm-builder/Cargo.toml b/xcm/xcm-builder/Cargo.toml index 62bc0a0bf878..f51354219414 100644 --- a/xcm/xcm-builder/Cargo.toml +++ b/xcm/xcm-builder/Cargo.toml @@ -22,6 +22,7 @@ log = { version = "0.4.17", default-features = false } # Polkadot dependencies polkadot-parachain = { path = "../../parachain", default-features = false } +polkadot-primitives = { path = "../../primitives"} [dev-dependencies] primitive-types = "0.12.1" diff --git a/xcm/xcm-builder/src/pay.rs b/xcm/xcm-builder/src/pay.rs index 6c0151b5f619..83da45caa006 100644 --- a/xcm/xcm-builder/src/pay.rs +++ b/xcm/xcm-builder/src/pay.rs @@ -20,7 +20,7 @@ use frame_support::traits::{ tokens::{Pay, PaymentStatus}, Get, }; -use primitives::AccountId; +use polkadot_primitives::AccountId; use sp_std::{marker::PhantomData, vec}; use xcm::prelude::*; use xcm_executor::traits::{FinishedQuery, QueryResponseStatus, XcmQueryHandler}; From 9df80ea18c38916706fcef986396e31074836aca Mon Sep 17 00:00:00 2001 From: Anthony Alaribe Date: Fri, 21 Apr 2023 15:55:00 +0200 Subject: [PATCH 17/31] fix dependency to use polkadot-core-primitives --- Cargo.lock | 2 +- xcm/xcm-builder/Cargo.toml | 2 +- xcm/xcm-builder/src/pay.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2917328ca963..05c2855374cd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14101,8 +14101,8 @@ dependencies = [ "pallet-transaction-payment", "pallet-xcm", "parity-scale-codec", + "polkadot-core-primitives", "polkadot-parachain", - "polkadot-primitives", "polkadot-runtime-parachains", "primitive-types", "scale-info", diff --git a/xcm/xcm-builder/Cargo.toml b/xcm/xcm-builder/Cargo.toml index f51354219414..4a2e4403cdc9 100644 --- a/xcm/xcm-builder/Cargo.toml +++ b/xcm/xcm-builder/Cargo.toml @@ -22,7 +22,7 @@ log = { version = "0.4.17", default-features = false } # Polkadot dependencies polkadot-parachain = { path = "../../parachain", default-features = false } -polkadot-primitives = { path = "../../primitives"} +polkadot-core-primitives = { path = "../../core-primitives", default-features = false } [dev-dependencies] primitive-types = "0.12.1" diff --git a/xcm/xcm-builder/src/pay.rs b/xcm/xcm-builder/src/pay.rs index 83da45caa006..b8d6291944a5 100644 --- a/xcm/xcm-builder/src/pay.rs +++ b/xcm/xcm-builder/src/pay.rs @@ -20,7 +20,7 @@ use frame_support::traits::{ tokens::{Pay, PaymentStatus}, Get, }; -use polkadot_primitives::AccountId; +use polkadot_core_primitives::AccountId; use sp_std::{marker::PhantomData, vec}; use xcm::prelude::*; use xcm_executor::traits::{FinishedQuery, QueryResponseStatus, XcmQueryHandler}; From 59b884cbffb535365a55b48f0251f8bec3c32d6c Mon Sep 17 00:00:00 2001 From: Anthony Alaribe Date: Tue, 25 Apr 2023 02:10:04 +0200 Subject: [PATCH 18/31] force Unpaid instruction to the top of the instructions list --- xcm/xcm-builder/src/pay.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xcm/xcm-builder/src/pay.rs b/xcm/xcm-builder/src/pay.rs index b8d6291944a5..f8ef797d2aa0 100644 --- a/xcm/xcm-builder/src/pay.rs +++ b/xcm/xcm-builder/src/pay.rs @@ -76,7 +76,6 @@ impl< let destination_chain = DestinationChain::get(); let sender_account = SenderAccount::get(); let mut message = Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, DescendOrigin( Junction::AccountId32 { network: None, id: sender_account.into() }.into(), ), @@ -91,6 +90,11 @@ impl< ]); let id = Querier::report_outcome(&mut message, destination_chain, Timeout::get()) .map_err(|_| Self::Error::LocationNotInvertible)?; + + message + .0 + .insert(0, UnpaidExecution { weight_limit: Unlimited, check_origin: None }); + let (ticket, _) = Router::validate(&mut Some(destination_chain), &mut Some(message))?; Router::deliver(ticket)?; Ok(id) From 31d3e1d15af0499ae1b424f4a94cd11ac56b6e0b Mon Sep 17 00:00:00 2001 From: Anthony Alaribe Date: Wed, 26 Apr 2023 15:37:31 +0200 Subject: [PATCH 19/31] modify report_outcome to accept interior argument --- xcm/pallet-xcm/src/lib.rs | 3 ++- xcm/xcm-builder/src/pay.rs | 10 +++++----- xcm/xcm-executor/src/traits/on_response.rs | 2 ++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index 23164e579743..b86593a1162d 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -1110,12 +1110,13 @@ impl XcmQueryHandler for Pallet { message: &mut Xcm<()>, responder: impl Into, timeout: Self::BlockNumber, + interior: impl Into, ) -> Result { 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 query_id = Self::new_query(responder, timeout, interior); 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)); diff --git a/xcm/xcm-builder/src/pay.rs b/xcm/xcm-builder/src/pay.rs index f8ef797d2aa0..c397884de7c2 100644 --- a/xcm/xcm-builder/src/pay.rs +++ b/xcm/xcm-builder/src/pay.rs @@ -75,10 +75,9 @@ impl< ) -> Result { let destination_chain = DestinationChain::get(); let sender_account = SenderAccount::get(); + let sender_origin = Junction::AccountId32 { network: None, id: sender_account.into() }; let mut message = Xcm(vec![ - DescendOrigin( - Junction::AccountId32 { network: None, id: sender_account.into() }.into(), - ), + DescendOrigin(sender_origin.into()), TransferAsset { beneficiary: AccountId32 { network: None, id: who.clone().into() }.into(), assets: vec![MultiAsset { @@ -88,8 +87,9 @@ impl< .into(), }, ]); - let id = Querier::report_outcome(&mut message, destination_chain, Timeout::get()) - .map_err(|_| Self::Error::LocationNotInvertible)?; + let id = + Querier::report_outcome(&mut message, destination_chain, Timeout::get(), sender_origin) + .map_err(|_| Self::Error::LocationNotInvertible)?; message .0 diff --git a/xcm/xcm-executor/src/traits/on_response.rs b/xcm/xcm-executor/src/traits/on_response.rs index 9e1911de9b55..d2d763e544f7 100644 --- a/xcm/xcm-executor/src/traits/on_response.rs +++ b/xcm/xcm-executor/src/traits/on_response.rs @@ -130,6 +130,7 @@ pub trait XcmQueryHandler { /// - `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 to return `NotFound` from `take_response`. + /// - `interior`: Indicates the computed location which is expected to report the outcome. /// /// `report_outcome` may return an error if the `responder` is not invertible. /// @@ -139,6 +140,7 @@ pub trait XcmQueryHandler { message: &mut Xcm<()>, responder: impl Into, timeout: Self::BlockNumber, + interior: impl Into, ) -> result::Result; /// Makes sure to expect a response with the given id From 918d62e56e925c6347b39bebcb4b7411f2557214 Mon Sep 17 00:00:00 2001 From: Anthony Alaribe Date: Fri, 28 Apr 2023 19:09:23 +0200 Subject: [PATCH 20/31] use new_query directly for building final xcm query, instead of report_outcome --- xcm/pallet-xcm/src/lib.rs | 24 +++++++++---------- xcm/xcm-builder/src/pay.rs | 26 ++++++++++++-------- xcm/xcm-executor/src/traits/on_response.rs | 28 ++++++++++++++++++---- 3 files changed, 51 insertions(+), 27 deletions(-) diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index b86593a1162d..5bc69892125f 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -1103,6 +1103,16 @@ impl XcmQueryHandler for Pallet { 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, + timeout: T::BlockNumber, + match_querier: impl Into, + ) -> 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. @@ -1110,13 +1120,12 @@ impl XcmQueryHandler for Pallet { message: &mut Xcm<()>, responder: impl Into, timeout: Self::BlockNumber, - interior: impl Into, ) -> Result { let responder = responder.into(); - let destination = T::UniversalLocation::get() + let destination = Self::UniversalLocation::get() .invert_target(&responder) .map_err(|()| XcmError::LocationNotInvertible)?; - let query_id = Self::new_query(responder, timeout, interior); + 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)); @@ -1552,15 +1561,6 @@ impl Pallet { 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, - timeout: T::BlockNumber, - match_querier: impl Into, - ) -> 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( diff --git a/xcm/xcm-builder/src/pay.rs b/xcm/xcm-builder/src/pay.rs index c397884de7c2..5365febaeb5c 100644 --- a/xcm/xcm-builder/src/pay.rs +++ b/xcm/xcm-builder/src/pay.rs @@ -22,7 +22,7 @@ use frame_support::traits::{ }; use polkadot_core_primitives::AccountId; use sp_std::{marker::PhantomData, vec}; -use xcm::prelude::*; +use xcm::{opaque::lts::Weight, prelude::*}; use xcm_executor::traits::{FinishedQuery, QueryResponseStatus, XcmQueryHandler}; /// Implementation of the `frame_support_traits::tokens::Pay` trait, to allow @@ -76,7 +76,20 @@ impl< let destination_chain = DestinationChain::get(); let sender_account = SenderAccount::get(); let sender_origin = Junction::AccountId32 { network: None, id: sender_account.into() }; - let mut message = Xcm(vec![ + + let destination = Querier::UniversalLocation::get() + .invert_target(&destination_chain) + .map_err(|()| Self::Error::LocationNotInvertible)?; + + let query_id = Querier::new_query(destination_chain, Timeout::get(), sender_origin); + + let message = Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + SetAppendix(Xcm(vec![ReportError(QueryResponseInfo { + destination, + query_id, + max_weight: Weight::zero(), + })])), DescendOrigin(sender_origin.into()), TransferAsset { beneficiary: AccountId32 { network: None, id: who.clone().into() }.into(), @@ -87,17 +100,10 @@ impl< .into(), }, ]); - let id = - Querier::report_outcome(&mut message, destination_chain, Timeout::get(), sender_origin) - .map_err(|_| Self::Error::LocationNotInvertible)?; - - message - .0 - .insert(0, UnpaidExecution { weight_limit: Unlimited, check_origin: None }); let (ticket, _) = Router::validate(&mut Some(destination_chain), &mut Some(message))?; Router::deliver(ticket)?; - Ok(id) + Ok(query_id.into()) } fn check_payment(id: Self::Id) -> PaymentStatus { diff --git a/xcm/xcm-executor/src/traits/on_response.rs b/xcm/xcm-executor/src/traits/on_response.rs index d2d763e544f7..a580d0961ce4 100644 --- a/xcm/xcm-executor/src/traits/on_response.rs +++ b/xcm/xcm-executor/src/traits/on_response.rs @@ -16,10 +16,14 @@ use crate::Xcm; use core::result; -use frame_support::{dispatch::fmt::Debug, pallet_prelude::TypeInfo}; +use frame_support::{ + dispatch::fmt::Debug, + pallet_prelude::{Get, TypeInfo}, +}; use parity_scale_codec::{FullCodec, MaxEncodedLen}; use xcm::latest::{ - Error as XcmError, MultiLocation, QueryId, Response, Result as XcmResult, Weight, XcmContext, + Error as XcmError, InteriorMultiLocation, MultiLocation, QueryId, Response, + Result as XcmResult, Weight, XcmContext, }; /// Define what needs to be done upon receiving a query response. @@ -120,9 +124,25 @@ pub enum QueryResponseStatus { /// Provides methods to expect responses from XCMs and query their status. pub trait XcmQueryHandler { - type QueryId: FullCodec + MaxEncodedLen + TypeInfo + Clone + Eq + PartialEq + Debug + Copy; + type QueryId: From + + FullCodec + + MaxEncodedLen + + TypeInfo + + Clone + + Eq + + PartialEq + + Debug + + Copy; type BlockNumber; type Error; + type UniversalLocation: Get; + + /// Attempt to create a new query ID and register it as a query that is yet to respond. + fn new_query( + responder: impl Into, + timeout: Self::BlockNumber, + match_querier: impl Into, + ) -> QueryId; /// Consume `message` and return another which is equivalent to it except that it reports /// back the outcome. @@ -130,7 +150,6 @@ pub trait XcmQueryHandler { /// - `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 to return `NotFound` from `take_response`. - /// - `interior`: Indicates the computed location which is expected to report the outcome. /// /// `report_outcome` may return an error if the `responder` is not invertible. /// @@ -140,7 +159,6 @@ pub trait XcmQueryHandler { message: &mut Xcm<()>, responder: impl Into, timeout: Self::BlockNumber, - interior: impl Into, ) -> result::Result; /// Makes sure to expect a response with the given id From 97d05d04578b6a5422edce79eb95a2e2de41ff0a Mon Sep 17 00:00:00 2001 From: Anthony Alaribe Date: Fri, 28 Apr 2023 21:17:30 +0200 Subject: [PATCH 21/31] fix usage of new_query to use the XcmQueryHandler --- runtime/test-runtime/src/lib.rs | 5 +++-- xcm/pallet-xcm/src/mock.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index fb114df2ee46..1b708ddb2897 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -549,6 +549,7 @@ pub mod pallet_test_notifier { use pallet_xcm::ensure_response; use sp_runtime::DispatchResult; use xcm::latest::prelude::*; + use xcm_executor::traits::XcmQueryHandler; #[pallet::pallet] pub struct Pallet(_); @@ -584,7 +585,7 @@ pub mod pallet_test_notifier { let id = who .using_encoded(|mut d| <[u8; 32]>::decode(&mut d)) .map_err(|_| Error::::BadAccountFormat)?; - let qid = pallet_xcm::Pallet::::new_query( + let qid = as XcmQueryHandler>::new_query( Junction::AccountId32 { network: None, id }, 100u32.into(), Here, @@ -602,7 +603,7 @@ pub mod pallet_test_notifier { .map_err(|_| Error::::BadAccountFormat)?; let call = Call::::notification_received { query_id: 0, response: Default::default() }; - let qid = pallet_xcm::Pallet::::new_notify_query( + let qid = as XcmQueryHandler>::new_notify_query( Junction::AccountId32 { network: None, id }, ::RuntimeCall::from(call), 100u32.into(), diff --git a/xcm/pallet-xcm/src/mock.rs b/xcm/pallet-xcm/src/mock.rs index 0faef76f9eac..d6f01f9e0fc8 100644 --- a/xcm/pallet-xcm/src/mock.rs +++ b/xcm/pallet-xcm/src/mock.rs @@ -85,7 +85,7 @@ pub mod pallet_test_notifier { let id = who .using_encoded(|mut d| <[u8; 32]>::decode(&mut d)) .map_err(|_| Error::::BadAccountFormat)?; - let qid = crate::Pallet::::new_query( + let qid = as XcmQueryHandler>::new_query( Junction::AccountId32 { network: None, id }, 100u32.into(), querier, From 2465cc4a952fd0c4c3fa46f0cd0123cf48de1fa0 Mon Sep 17 00:00:00 2001 From: Anthony Alaribe Date: Fri, 28 Apr 2023 21:21:21 +0200 Subject: [PATCH 22/31] fix usage of new_query to use the XcmQueryHandler --- runtime/test-runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 1b708ddb2897..6aa303bc491a 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -603,7 +603,7 @@ pub mod pallet_test_notifier { .map_err(|_| Error::::BadAccountFormat)?; let call = Call::::notification_received { query_id: 0, response: Default::default() }; - let qid = as XcmQueryHandler>::new_notify_query( + let qid = pallet_xcm::Pallet::new_notify_query( Junction::AccountId32 { network: None, id }, ::RuntimeCall::from(call), 100u32.into(), From a524d26621cc4497d1cbeb675ea1a4a44f9a350f Mon Sep 17 00:00:00 2001 From: Anthony Alaribe Date: Fri, 28 Apr 2023 21:28:07 +0200 Subject: [PATCH 23/31] tiny method calling fix --- runtime/test-runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 6aa303bc491a..bcb8335b4dce 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -603,7 +603,7 @@ pub mod pallet_test_notifier { .map_err(|_| Error::::BadAccountFormat)?; let call = Call::::notification_received { query_id: 0, response: Default::default() }; - let qid = pallet_xcm::Pallet::new_notify_query( + let qid = pallet_xcm::Pallet::::new_notify_query( Junction::AccountId32 { network: None, id }, ::RuntimeCall::from(call), 100u32.into(), From 8ae3a9908c7586868886386cc2180797f49c4523 Mon Sep 17 00:00:00 2001 From: Muharem Ismailov Date: Wed, 10 May 2023 12:43:28 +0200 Subject: [PATCH 24/31] xcm query handler (#7198) * drop redundant query status * rename ReportQueryStatus to OuterQueryStatus * revert rename of QueryResponseStatus * update mapping --- xcm/pallet-xcm/src/lib.rs | 47 ++++++++-------------- xcm/pallet-xcm/src/mock.rs | 3 +- xcm/pallet-xcm/src/tests.rs | 14 +++---- xcm/xcm-builder/src/pay.rs | 27 ++++++------- xcm/xcm-executor/src/traits/mod.rs | 4 +- xcm/xcm-executor/src/traits/on_response.rs | 24 ++++------- 6 files changed, 44 insertions(+), 75 deletions(-) diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index 33b8de26dad0..e686829ec30d 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -52,8 +52,8 @@ use frame_system::pallet_prelude::*; pub use pallet::*; use xcm_executor::{ traits::{ - CheckSuspension, ClaimAssets, DropAssets, FinishedQuery, MatchesFungible, OnResponse, QueryResponseStatus, - VersionChangeNotifier, WeightBounds, XcmQueryHandler, + CheckSuspension, ClaimAssets, DropAssets, MatchesFungible, OnResponse, QueryHandler, + QueryResponseStatus, VersionChangeNotifier, WeightBounds, }, Assets, }; @@ -1120,7 +1120,7 @@ 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 XcmQueryHandler for Pallet { +impl QueryHandler for Pallet { type QueryId = u64; type BlockNumber = T::BlockNumber; type Error = XcmError; @@ -1153,41 +1153,26 @@ impl XcmQueryHandler for Pallet { Ok(query_id) } + /// Removes response when ready and emits [Event::ResponseTaken] event. fn take_response(query_id: Self::QueryId) -> QueryResponseStatus { match Queries::::get(query_id) { - Some(QueryStatus::Ready { response, at }) => { - let response = response.try_into(); - match response { - Ok(response) => { - Queries::::remove(query_id); - Self::deposit_event(Event::ResponseTaken(query_id)); - QueryResponseStatus::Finished(FinishedQuery::Response { response, at }) - }, - Err(_) => QueryResponseStatus::UnexpectedVersion, - } - }, - Some(QueryStatus::VersionNotifier { origin, is_active }) => { - let origin = origin.try_into(); - match origin { - Ok(origin) => - QueryResponseStatus::Finished(FinishedQuery::VersionNotification { - origin, - is_active, - }), - Err(_) => QueryResponseStatus::UnexpectedVersion, - } + Some(QueryStatus::Ready { response, at }) => match response.try_into() { + Ok(response) => { + Queries::::remove(query_id); + Self::deposit_event(Event::ResponseTaken(query_id)); + QueryResponseStatus::Ready { response, at } + }, + Err(_) => QueryResponseStatus::UnexpectedVersion, }, - Some(QueryStatus::Pending { .. }) => QueryResponseStatus::Pending, + Some(QueryStatus::Pending { timeout, .. }) => QueryResponseStatus::Pending { timeout }, + Some(_) => QueryResponseStatus::UnexpectedVersion, None => QueryResponseStatus::NotFound, } } - fn expect_response(id: Self::QueryId) { - let query_status = QueryStatus::Ready { - response: VersionedResponse::V3(Response::Null), - at: Self::BlockNumber::default(), - }; - Queries::::insert(id, query_status); + #[cfg(feature = "runtime-benchmarks")] + fn expect_response(id: Self::QueryId, status: QueryStatus) { + Queries::::insert(id, status); } } diff --git a/xcm/pallet-xcm/src/mock.rs b/xcm/pallet-xcm/src/mock.rs index d6f01f9e0fc8..34630e06aa76 100644 --- a/xcm/pallet-xcm/src/mock.rs +++ b/xcm/pallet-xcm/src/mock.rs @@ -50,6 +50,7 @@ pub mod pallet_test_notifier { use frame_system::pallet_prelude::*; use sp_runtime::DispatchResult; use xcm::latest::prelude::*; + use xcm_executor::traits::QueryHandler; #[pallet::pallet] pub struct Pallet(_); @@ -85,7 +86,7 @@ pub mod pallet_test_notifier { let id = who .using_encoded(|mut d| <[u8; 32]>::decode(&mut d)) .map_err(|_| Error::::BadAccountFormat)?; - let qid = as XcmQueryHandler>::new_query( + let qid = as QueryHandler>::new_query( Junction::AccountId32 { network: None, id }, 100u32.into(), querier, diff --git a/xcm/pallet-xcm/src/tests.rs b/xcm/pallet-xcm/src/tests.rs index 5d999c825cc5..5cf08a9847e3 100644 --- a/xcm/pallet-xcm/src/tests.rs +++ b/xcm/pallet-xcm/src/tests.rs @@ -28,7 +28,7 @@ use sp_runtime::traits::{AccountIdConversion, BlakeTwo256, Hash}; use xcm::{latest::QueryResponseInfo, prelude::*}; use xcm_builder::AllowKnownQueryResponses; use xcm_executor::{ - traits::{FinishedQuery, QueryResponseStatus, ShouldExecute, XcmQueryHandler}, + traits::{QueryHandler, QueryResponseStatus, ShouldExecute}, XcmExecutor, }; @@ -166,10 +166,8 @@ fn report_outcome_works() { )) ); - let response = QueryResponseStatus::Finished(FinishedQuery::Response { - response: Response::ExecutionResult(None), - at: 1, - }); + let response = + QueryResponseStatus::Ready { response: Response::ExecutionResult(None), at: 1 }; assert_eq!(XcmPallet::take_response(0), response); }); } @@ -269,10 +267,8 @@ fn custom_querier_works() { )) ); - let response = QueryResponseStatus::Finished(FinishedQuery::Response { - response: Response::ExecutionResult(None), - at: 1, - }); + let response = + QueryResponseStatus::Ready { response: Response::ExecutionResult(None), at: 1 }; assert_eq!(XcmPallet::take_response(0), response); }); } diff --git a/xcm/xcm-builder/src/pay.rs b/xcm/xcm-builder/src/pay.rs index 5365febaeb5c..0456189b8cbf 100644 --- a/xcm/xcm-builder/src/pay.rs +++ b/xcm/xcm-builder/src/pay.rs @@ -23,7 +23,7 @@ use frame_support::traits::{ use polkadot_core_primitives::AccountId; use sp_std::{marker::PhantomData, vec}; use xcm::{opaque::lts::Weight, prelude::*}; -use xcm_executor::traits::{FinishedQuery, QueryResponseStatus, XcmQueryHandler}; +use xcm_executor::traits::{QueryHandler, QueryResponseStatus}; /// Implementation of the `frame_support_traits::tokens::Pay` trait, to allow /// for generic payments of a given `AssetKind` and `Balance` from an implied origin, to a @@ -55,7 +55,7 @@ impl< DestinationChain: Get, SenderAccount: Get, Router: SendXcm, - Querier: XcmQueryHandler, + Querier: QueryHandler, Timeout: Get, Beneficiary: Into<[u8; 32]> + Clone, AssetKind: Into, @@ -107,23 +107,22 @@ impl< } fn check_payment(id: Self::Id) -> PaymentStatus { + use QueryResponseStatus::*; match Querier::take_response(id) { - QueryResponseStatus::Finished(FinishedQuery::Response { response, at: _ }) => - match response { - Response::ExecutionResult(Some(_)) => PaymentStatus::Failure, - Response::ExecutionResult(None) => PaymentStatus::Success, - _ => PaymentStatus::Unknown, - }, - QueryResponseStatus::Pending => PaymentStatus::InProgress, - QueryResponseStatus::NotFound | - QueryResponseStatus::UnexpectedVersion | - QueryResponseStatus::Finished(FinishedQuery::VersionNotification { .. }) => - PaymentStatus::Unknown, + Ready { response, .. } => match response { + Response::ExecutionResult(None) => PaymentStatus::Success, + Response::ExecutionResult(Some(_)) => PaymentStatus::Failure, + _ => PaymentStatus::Unknown, + }, + Pending { .. } => PaymentStatus::InProgress, + NotFound | UnexpectedVersion => PaymentStatus::Unknown, } } #[cfg(feature = "runtime-benchmarks")] - fn ensure_successful(_: &Self::Beneficiary, _: Self::Balance) {} + fn ensure_successful(_: &Self::Beneficiary, _: Self::Balance) { + Querier::expect_response(id); + } #[cfg(feature = "runtime-benchmarks")] fn ensure_concluded(id: Self::Id) { diff --git a/xcm/xcm-executor/src/traits/mod.rs b/xcm/xcm-executor/src/traits/mod.rs index 524cbe205cfd..246803de88b2 100644 --- a/xcm/xcm-executor/src/traits/mod.rs +++ b/xcm/xcm-executor/src/traits/mod.rs @@ -38,9 +38,7 @@ pub use token_matching::{ Error, MatchesFungible, MatchesFungibles, MatchesNonFungible, MatchesNonFungibles, }; mod on_response; -pub use on_response::{ - FinishedQuery, OnResponse, QueryResponseStatus, VersionChangeNotifier, XcmQueryHandler, -}; +pub use on_response::{OnResponse, QueryHandler, QueryResponseStatus, VersionChangeNotifier}; mod should_execute; pub use should_execute::{CheckSuspension, ShouldExecute}; mod transact_asset; diff --git a/xcm/xcm-executor/src/traits/on_response.rs b/xcm/xcm-executor/src/traits/on_response.rs index a580d0961ce4..e78200ed3cb2 100644 --- a/xcm/xcm-executor/src/traits/on_response.rs +++ b/xcm/xcm-executor/src/traits/on_response.rs @@ -103,19 +103,13 @@ impl VersionChangeNotifier for () { } } -#[derive(Debug, PartialEq, Eq)] -pub enum FinishedQuery { - Response { response: Response, at: BlockNumber }, - VersionNotification { origin: MultiLocation, is_active: bool }, -} - /// The possible state of an XCM query response. #[derive(Debug, PartialEq, Eq)] pub enum QueryResponseStatus { /// The response has arrived, and includes the inner Response and the block number it arrived at. - Finished(FinishedQuery), + Ready { response: Response, at: BlockNumber }, /// The response has not yet arrived, the XCM might still be executing or the response might be in transit. - Pending, + Pending { timeout: BlockNumber }, /// No response with the given `QueryId` was found, or the response was already queried and removed from local storage. NotFound, /// Got an unexpected XCM version. @@ -123,7 +117,7 @@ pub enum QueryResponseStatus { } /// Provides methods to expect responses from XCMs and query their status. -pub trait XcmQueryHandler { +pub trait QueryHandler { type QueryId: From + FullCodec + MaxEncodedLen @@ -161,14 +155,10 @@ pub trait XcmQueryHandler { timeout: Self::BlockNumber, ) -> result::Result; - /// Makes sure to expect a response with the given id - /// Used for bencharks. - fn expect_response(id: Self::QueryId); - /// Attempt to remove and return the response of query with ID `query_id`. - /// - /// Returns `Finished` if the response is available and includes inner response. - /// Returns `Pending` if the response is not yet available. - /// Returns `NotFound` if the response is not available and won't ever be. fn take_response(id: Self::QueryId) -> QueryResponseStatus; + + /// Makes sure to expect a response with the given id. + #[cfg(feature = "runtime-benchmarks")] + fn expect_response(id: Self::QueryId); } From 3ee49cd4599f272a698308b6e879701184ec2ff5 Mon Sep 17 00:00:00 2001 From: Anthony Alaribe Date: Fri, 26 May 2023 12:04:40 +0200 Subject: [PATCH 25/31] Update xcm/xcm-builder/src/pay.rs Co-authored-by: Gavin Wood --- xcm/xcm-builder/src/pay.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcm/xcm-builder/src/pay.rs b/xcm/xcm-builder/src/pay.rs index 0456189b8cbf..6344cad3b5bb 100644 --- a/xcm/xcm-builder/src/pay.rs +++ b/xcm/xcm-builder/src/pay.rs @@ -25,7 +25,7 @@ use sp_std::{marker::PhantomData, vec}; use xcm::{opaque::lts::Weight, prelude::*}; use xcm_executor::traits::{QueryHandler, QueryResponseStatus}; -/// Implementation of the `frame_support_traits::tokens::Pay` trait, to allow +/// Implementation of the `frame_support::traits::tokens::Pay` trait, to allow /// for generic payments of a given `AssetKind` and `Balance` from an implied origin, to a /// beneficiary via XCM, relying on the XCM `TransferAsset` instruction. /// From 00cb2d2fa5c001cfcf7464ede2ff2a156a089513 Mon Sep 17 00:00:00 2001 From: Gav Date: Mon, 29 May 2023 13:16:26 +0100 Subject: [PATCH 26/31] Updates --- Cargo.lock | 1 - .../dispute-coordinator/src/initialized.rs | 101 +++++++++--------- node/network/approval-distribution/src/lib.rs | 10 +- xcm/xcm-builder/Cargo.toml | 1 - xcm/xcm-builder/src/lib.rs | 6 +- xcm/xcm-builder/src/location_conversion.rs | 14 ++- xcm/xcm-builder/src/pay.rs | 64 ++++++++--- 7 files changed, 118 insertions(+), 79 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fb111af39d06..77bfd8c99860 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14340,7 +14340,6 @@ dependencies = [ "pallet-transaction-payment", "pallet-xcm", "parity-scale-codec", - "polkadot-core-primitives", "polkadot-parachain", "polkadot-runtime-parachains", "primitive-types", diff --git a/node/core/dispute-coordinator/src/initialized.rs b/node/core/dispute-coordinator/src/initialized.rs index c0eb029f4d0f..6644bebc4776 100644 --- a/node/core/dispute-coordinator/src/initialized.rs +++ b/node/core/dispute-coordinator/src/initialized.rs @@ -214,62 +214,61 @@ impl Initialized { gum::trace!(target: LOG_TARGET, "Waiting for message"); let mut overlay_db = OverlayedBackend::new(backend); let default_confirm = Box::new(|| Ok(())); - let confirm_write = match MuxedMessage::receive(ctx, &mut self.participation_receiver) - .await? - { - MuxedMessage::Participation(msg) => { - gum::trace!(target: LOG_TARGET, "MuxedMessage::Participation"); - let ParticipationStatement { - session, - candidate_hash, - candidate_receipt, - outcome, - } = self.participation.get_participation_result(ctx, msg).await?; - if let Some(valid) = outcome.validity() { - gum::trace!( - target: LOG_TARGET, - ?session, - ?candidate_hash, - ?valid, - "Issuing local statement based on participation outcome." - ); - self.issue_local_statement( - ctx, - &mut overlay_db, + let confirm_write = + match MuxedMessage::receive(ctx, &mut self.participation_receiver).await? { + MuxedMessage::Participation(msg) => { + gum::trace!(target: LOG_TARGET, "MuxedMessage::Participation"); + let ParticipationStatement { + session, candidate_hash, candidate_receipt, - session, - valid, - clock.now(), - ) - .await?; - } else { - gum::warn!(target: LOG_TARGET, ?outcome, "Dispute participation failed"); - } - default_confirm - }, - MuxedMessage::Subsystem(msg) => match msg { - FromOrchestra::Signal(OverseerSignal::Conclude) => return Ok(()), - FromOrchestra::Signal(OverseerSignal::ActiveLeaves(update)) => { - gum::trace!(target: LOG_TARGET, "OverseerSignal::ActiveLeaves"); - self.process_active_leaves_update( - ctx, - &mut overlay_db, - update, - clock.now(), - ) - .await?; + outcome, + } = self.participation.get_participation_result(ctx, msg).await?; + if let Some(valid) = outcome.validity() { + gum::trace!( + target: LOG_TARGET, + ?session, + ?candidate_hash, + ?valid, + "Issuing local statement based on participation outcome." + ); + self.issue_local_statement( + ctx, + &mut overlay_db, + candidate_hash, + candidate_receipt, + session, + valid, + clock.now(), + ) + .await?; + } else { + gum::warn!(target: LOG_TARGET, ?outcome, "Dispute participation failed"); + } default_confirm }, - FromOrchestra::Signal(OverseerSignal::BlockFinalized(_, n)) => { - gum::trace!(target: LOG_TARGET, "OverseerSignal::BlockFinalized"); - self.scraper.process_finalized_block(&n); - default_confirm + MuxedMessage::Subsystem(msg) => match msg { + FromOrchestra::Signal(OverseerSignal::Conclude) => return Ok(()), + FromOrchestra::Signal(OverseerSignal::ActiveLeaves(update)) => { + gum::trace!(target: LOG_TARGET, "OverseerSignal::ActiveLeaves"); + self.process_active_leaves_update( + ctx, + &mut overlay_db, + update, + clock.now(), + ) + .await?; + default_confirm + }, + FromOrchestra::Signal(OverseerSignal::BlockFinalized(_, n)) => { + gum::trace!(target: LOG_TARGET, "OverseerSignal::BlockFinalized"); + self.scraper.process_finalized_block(&n); + default_confirm + }, + FromOrchestra::Communication { msg } => + self.handle_incoming(ctx, &mut overlay_db, msg, clock.now()).await?, }, - FromOrchestra::Communication { msg } => - self.handle_incoming(ctx, &mut overlay_db, msg, clock.now()).await?, - }, - }; + }; if !overlay_db.is_empty() { let ops = overlay_db.into_write_ops(); diff --git a/node/network/approval-distribution/src/lib.rs b/node/network/approval-distribution/src/lib.rs index c8ad21ad406e..82f62502e474 100644 --- a/node/network/approval-distribution/src/lib.rs +++ b/node/network/approval-distribution/src/lib.rs @@ -1270,11 +1270,11 @@ impl State { let candidate_entry = match block_entry.candidates.get(index as usize) { None => { gum::debug!( - target: LOG_TARGET, - ?hash, - ?index, - "`get_approval_signatures`: could not find candidate entry for given hash and index!" - ); + target: LOG_TARGET, + ?hash, + ?index, + "`get_approval_signatures`: could not find candidate entry for given hash and index!" + ); continue }, Some(e) => e, diff --git a/xcm/xcm-builder/Cargo.toml b/xcm/xcm-builder/Cargo.toml index 4a2e4403cdc9..62bc0a0bf878 100644 --- a/xcm/xcm-builder/Cargo.toml +++ b/xcm/xcm-builder/Cargo.toml @@ -22,7 +22,6 @@ log = { version = "0.4.17", default-features = false } # Polkadot dependencies polkadot-parachain = { path = "../../parachain", default-features = false } -polkadot-core-primitives = { path = "../../core-primitives", default-features = false } [dev-dependencies] primitive-types = "0.12.1" diff --git a/xcm/xcm-builder/src/lib.rs b/xcm/xcm-builder/src/lib.rs index 17c59a6f3059..7370b5b215c3 100644 --- a/xcm/xcm-builder/src/lib.rs +++ b/xcm/xcm-builder/src/lib.rs @@ -28,8 +28,8 @@ pub mod test_utils; mod location_conversion; pub use location_conversion::{ - Account32Hash, AccountId32Aliases, AccountKey20Aliases, ChildParachainConvertsVia, - ParentIsPreset, SiblingParachainConvertsVia, + Account32Hash, AccountId32Aliases, AccountKey20Aliases, AliasesIntoAccountId32, + ChildParachainConvertsVia, ParentIsPreset, SiblingParachainConvertsVia, }; mod origin_conversion; @@ -90,4 +90,4 @@ pub use universal_exports::{ }; mod pay; -pub use pay::PayOverXcm; +pub use pay::{PayAccountId32OverXcm, PayOverXcm}; diff --git a/xcm/xcm-builder/src/location_conversion.rs b/xcm/xcm-builder/src/location_conversion.rs index 4239dc17dbdc..49f124d26112 100644 --- a/xcm/xcm-builder/src/location_conversion.rs +++ b/xcm/xcm-builder/src/location_conversion.rs @@ -22,15 +22,15 @@ use sp_std::{borrow::Borrow, marker::PhantomData}; use xcm::latest::prelude::*; use xcm_executor::traits::Convert; -/// Prefix for generating alias account for accounts coming +/// Prefix for generating alias account for accounts coming /// from chains that use 32 byte long representations. pub const FOREIGN_CHAIN_PREFIX_PARA_32: [u8; 37] = *b"ForeignChainAliasAccountPrefix_Para32"; -/// Prefix for generating alias account for accounts coming +/// Prefix for generating alias account for accounts coming /// from chains that use 20 byte long representations. pub const FOREIGN_CHAIN_PREFIX_PARA_20: [u8; 37] = *b"ForeignChainAliasAccountPrefix_Para20"; -/// Prefix for generating alias account for accounts coming +/// Prefix for generating alias account for accounts coming /// from the relay chain using 32 byte long representations. pub const FOREIGN_CHAIN_PREFIX_RELAY: [u8; 36] = *b"ForeignChainAliasAccountPrefix_Relay"; @@ -230,6 +230,14 @@ impl>, AccountId: From<[u8; 32]> + Into<[u8; 32]> Ok(AccountId32 { id: who.into(), network: Network::get() }.into()) } } +pub struct AliasesIntoAccountId32(PhantomData<(Network, AccountId)>); +impl>, AccountId: Into<[u8; 32]> + Clone> + Convert for AliasesIntoAccountId32 +{ + fn convert(who: AccountId) -> Result { + Ok(AccountId32 { network: Network::get(), id: who.into() }.into()) + } +} pub struct AccountKey20Aliases(PhantomData<(Network, AccountId)>); impl>, AccountId: From<[u8; 20]> + Into<[u8; 20]> + Clone> diff --git a/xcm/xcm-builder/src/pay.rs b/xcm/xcm-builder/src/pay.rs index 6344cad3b5bb..5eda008ee031 100644 --- a/xcm/xcm-builder/src/pay.rs +++ b/xcm/xcm-builder/src/pay.rs @@ -14,53 +14,70 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -//! `PayOverXcm` struct for paying through XCM and getting the status back +//! `PayOverXcm` struct for paying through XCM and getting the status back. use frame_support::traits::{ tokens::{Pay, PaymentStatus}, Get, }; -use polkadot_core_primitives::AccountId; +use sp_runtime::traits::Convert; use sp_std::{marker::PhantomData, vec}; use xcm::{opaque::lts::Weight, prelude::*}; use xcm_executor::traits::{QueryHandler, QueryResponseStatus}; /// Implementation of the `frame_support::traits::tokens::Pay` trait, to allow -/// for generic payments of a given `AssetKind` and `Balance` from an implied origin, to a -/// beneficiary via XCM, relying on the XCM `TransferAsset` instruction. +/// for XCM payments of a given `Balance` of `AssetKind` existing on a `DestinationChain` under +/// ownership of some `Interior` location of the local chain to a particular `Beneficiary`. +/// +/// This relies on the XCM `TransferAsset` instruction. A trait `BeneficiaryToLocation` must be +/// provided in order to convert the `Beneficiary` value into a location usable by `TransferAsset`. /// /// `PayOverXcm::pay` is asynchronous, and returns a `QueryId` which can then be used in /// `check_payment` to check the status of the XCM transaction. /// +/// See also `PayAccountId32OverXcm` which is similar to this except that `BeneficiaryToLocation` +/// need not be supplied and `Beneficiary` must implement `Into<[u8; 32]>`. pub struct PayOverXcm< DestinationChain, - SenderAccount, + Interior, Router, Querier, Timeout, Beneficiary, AssetKind, + BeneficiaryToLocation, >( PhantomData<( DestinationChain, - SenderAccount, + Interior, Router, Querier, Timeout, Beneficiary, AssetKind, + BeneficiaryToLocation, )>, ); impl< DestinationChain: Get, - SenderAccount: Get, + Interior: Get, Router: SendXcm, Querier: QueryHandler, Timeout: Get, - Beneficiary: Into<[u8; 32]> + Clone, + Beneficiary: Clone, AssetKind: Into, + BeneficiaryToLocation: Convert, > Pay - for PayOverXcm + for PayOverXcm< + DestinationChain, + Interior, + Router, + Querier, + Timeout, + Beneficiary, + AssetKind, + BeneficiaryToLocation, + > { type Beneficiary = Beneficiary; type AssetKind = AssetKind; @@ -74,14 +91,12 @@ impl< amount: Self::Balance, ) -> Result { let destination_chain = DestinationChain::get(); - let sender_account = SenderAccount::get(); - let sender_origin = Junction::AccountId32 { network: None, id: sender_account.into() }; - let destination = Querier::UniversalLocation::get() .invert_target(&destination_chain) .map_err(|()| Self::Error::LocationNotInvertible)?; + let beneficiary = BeneficiaryToLocation::convert(who.clone()); - let query_id = Querier::new_query(destination_chain, Timeout::get(), sender_origin); + let query_id = Querier::new_query(destination_chain, Timeout::get(), Interior::get()); let message = Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, @@ -90,9 +105,9 @@ impl< query_id, max_weight: Weight::zero(), })])), - DescendOrigin(sender_origin.into()), + DescendOrigin(Interior::get()), TransferAsset { - beneficiary: AccountId32 { network: None, id: who.clone().into() }.into(), + beneficiary, assets: vec![MultiAsset { id: asset_kind.into(), fun: Fungibility::Fungible(amount), @@ -129,3 +144,22 @@ impl< Querier::expect_response(id); } } + +pub type PayAccountId32OverXcm< + DestinationChain, + Interior, + Router, + Querier, + Timeout, + Beneficiary, + AssetKind, +> = PayOverXcm< + DestinationChain, + Interior, + Router, + Querier, + Timeout, + Beneficiary, + AssetKind, + crate::AliasesIntoAccountId32<(), Beneficiary>, +>; From a42c9e3dc36625c2e6eabfd52df16a4a14838c7f Mon Sep 17 00:00:00 2001 From: Gav Date: Mon, 29 May 2023 13:59:19 +0100 Subject: [PATCH 27/31] Docs --- xcm/xcm-builder/src/pay.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/xcm/xcm-builder/src/pay.rs b/xcm/xcm-builder/src/pay.rs index 5eda008ee031..a4c35138d2fe 100644 --- a/xcm/xcm-builder/src/pay.rs +++ b/xcm/xcm-builder/src/pay.rs @@ -145,6 +145,20 @@ impl< } } +/// Specialization of the [PayOverXcm] trait to allow `[u8; 32]`-based `AccountId` values to be +/// paid on a remote chain. +/// +/// Implementation of the `frame_support::traits::tokens::Pay` trait, to allow +/// for XCM payments of a given `Balance` of `AssetKind` existing on a `DestinationChain` under +/// ownership of some `Interior` location of the local chain to a particular `Beneficiary`. +/// +/// This relies on the XCM `TransferAsset` instruction. `Beneficiary` must implement +/// `Into<[u8; 32]>` (as 32-byte `AccountId`s generally do), and the actual XCM beneficiary will be +/// the location consisting of a single `AccountId32` junction with an appropriate account and no +/// specific network. +/// +/// `PayOverXcm::pay` is asynchronous, and returns a `QueryId` which can then be used in +/// `check_payment` to check the status of the XCM transaction. pub type PayAccountId32OverXcm< DestinationChain, Interior, From 3b38fa103e813a1d9c97645b099732c7cc121063 Mon Sep 17 00:00:00 2001 From: Gav Date: Mon, 29 May 2023 17:11:40 +0100 Subject: [PATCH 28/31] Fix benchmarking stuff --- Cargo.lock | 368 ++++++++++----------- runtime/test-runtime/src/lib.rs | 2 +- xcm/pallet-xcm/src/lib.rs | 8 +- xcm/xcm-builder/Cargo.toml | 3 +- xcm/xcm-builder/src/pay.rs | 8 +- xcm/xcm-executor/src/traits/on_response.rs | 5 +- 6 files changed, 201 insertions(+), 193 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c06bf426f11b..092a42dcae47 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -523,7 +523,7 @@ dependencies = [ [[package]] name = "binary-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "hash-db", "log", @@ -2498,7 +2498,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "parity-scale-codec", ] @@ -2521,7 +2521,7 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-support", "frame-support-procedural", @@ -2546,7 +2546,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "Inflector", "array-bytes", @@ -2593,7 +2593,7 @@ dependencies = [ [[package]] name = "frame-election-provider-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2604,7 +2604,7 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-election-provider-solution-type", "frame-support", @@ -2621,7 +2621,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-support", "frame-system", @@ -2650,7 +2650,7 @@ dependencies = [ [[package]] name = "frame-remote-externalities" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "async-recursion", "futures", @@ -2671,7 +2671,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "bitflags", "environmental", @@ -2705,7 +2705,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "Inflector", "cfg-expr", @@ -2721,7 +2721,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -2733,7 +2733,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "proc-macro2", "quote", @@ -2743,7 +2743,7 @@ dependencies = [ [[package]] name = "frame-support-test" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-executive", @@ -2769,7 +2769,7 @@ dependencies = [ [[package]] name = "frame-support-test-pallet" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-support", "frame-system", @@ -2781,7 +2781,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "cfg-if", "frame-support", @@ -2800,7 +2800,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -2815,7 +2815,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "parity-scale-codec", "sp-api", @@ -2824,7 +2824,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-support", "parity-scale-codec", @@ -3006,7 +3006,7 @@ dependencies = [ [[package]] name = "generate-bags" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "chrono", "frame-election-provider-support", @@ -4905,7 +4905,7 @@ dependencies = [ [[package]] name = "mmr-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "futures", "log", @@ -4924,7 +4924,7 @@ dependencies = [ [[package]] name = "mmr-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "anyhow", "jsonrpsee", @@ -5507,7 +5507,7 @@ dependencies = [ [[package]] name = "pallet-assets" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -5522,7 +5522,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-support", "frame-system", @@ -5538,7 +5538,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-support", "frame-system", @@ -5552,7 +5552,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -5576,7 +5576,7 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5596,7 +5596,7 @@ dependencies = [ [[package]] name = "pallet-bags-list-remote-tests" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-election-provider-support", "frame-remote-externalities", @@ -5615,7 +5615,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -5630,7 +5630,7 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-support", "frame-system", @@ -5649,7 +5649,7 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "array-bytes", "binary-merkle-tree", @@ -5673,7 +5673,7 @@ dependencies = [ [[package]] name = "pallet-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -5691,7 +5691,7 @@ dependencies = [ [[package]] name = "pallet-child-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -5710,7 +5710,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -5727,7 +5727,7 @@ dependencies = [ [[package]] name = "pallet-conviction-voting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "assert_matches", "frame-benchmarking", @@ -5744,7 +5744,7 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -5762,7 +5762,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5785,7 +5785,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-support-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5798,7 +5798,7 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -5816,7 +5816,7 @@ dependencies = [ [[package]] name = "pallet-fast-unstake" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5834,7 +5834,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -5857,7 +5857,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "enumflags2", "frame-benchmarking", @@ -5873,7 +5873,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -5893,7 +5893,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -5910,7 +5910,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -5927,7 +5927,7 @@ dependencies = [ [[package]] name = "pallet-message-queue" version = "7.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -5946,7 +5946,7 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -5963,7 +5963,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -5979,7 +5979,7 @@ dependencies = [ [[package]] name = "pallet-nis" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -5995,7 +5995,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-support", "frame-system", @@ -6012,7 +6012,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-benchmarking" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6032,7 +6032,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-runtime-api" version = "1.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "pallet-nomination-pools", "parity-scale-codec", @@ -6043,7 +6043,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-support", "frame-system", @@ -6060,7 +6060,7 @@ dependencies = [ [[package]] name = "pallet-offences-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6084,7 +6084,7 @@ dependencies = [ [[package]] name = "pallet-preimage" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -6101,7 +6101,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -6116,7 +6116,7 @@ dependencies = [ [[package]] name = "pallet-ranked-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -6134,7 +6134,7 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -6149,7 +6149,7 @@ dependencies = [ [[package]] name = "pallet-referenda" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "assert_matches", "frame-benchmarking", @@ -6168,7 +6168,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -6185,7 +6185,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-support", "frame-system", @@ -6206,7 +6206,7 @@ dependencies = [ [[package]] name = "pallet-session-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -6222,7 +6222,7 @@ dependencies = [ [[package]] name = "pallet-society" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-support", "frame-system", @@ -6236,7 +6236,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6259,7 +6259,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -6270,7 +6270,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-fn" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "log", "sp-arithmetic", @@ -6279,7 +6279,7 @@ dependencies = [ [[package]] name = "pallet-staking-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "parity-scale-codec", "sp-api", @@ -6288,7 +6288,7 @@ dependencies = [ [[package]] name = "pallet-state-trie-migration" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -6305,7 +6305,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -6320,7 +6320,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -6338,7 +6338,7 @@ dependencies = [ [[package]] name = "pallet-tips" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -6357,7 +6357,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-support", "frame-system", @@ -6373,7 +6373,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", @@ -6389,7 +6389,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -6401,7 +6401,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -6418,7 +6418,7 @@ dependencies = [ [[package]] name = "pallet-uniques" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -6433,7 +6433,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -6449,7 +6449,7 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -6464,7 +6464,7 @@ dependencies = [ [[package]] name = "pallet-whitelist" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-benchmarking", "frame-support", @@ -9593,7 +9593,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "log", "sp-core", @@ -9604,7 +9604,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "async-trait", "futures", @@ -9633,7 +9633,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "futures", "futures-timer", @@ -9656,7 +9656,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -9671,7 +9671,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "memmap2", "sc-chain-spec-derive", @@ -9690,7 +9690,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -9701,7 +9701,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "array-bytes", "chrono", @@ -9741,7 +9741,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "fnv", "futures", @@ -9768,7 +9768,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "hash-db", "kvdb", @@ -9794,7 +9794,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "async-trait", "futures", @@ -9819,7 +9819,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "async-trait", "fork-tree", @@ -9855,7 +9855,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "futures", "jsonrpsee", @@ -9877,7 +9877,7 @@ dependencies = [ [[package]] name = "sc-consensus-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "array-bytes", "async-channel", @@ -9913,7 +9913,7 @@ dependencies = [ [[package]] name = "sc-consensus-beefy-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "futures", "jsonrpsee", @@ -9932,7 +9932,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "fork-tree", "parity-scale-codec", @@ -9945,7 +9945,7 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "ahash 0.8.2", "array-bytes", @@ -9985,7 +9985,7 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "finality-grandpa", "futures", @@ -10005,7 +10005,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "async-trait", "futures", @@ -10028,7 +10028,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "lru 0.10.0", "parity-scale-codec", @@ -10050,7 +10050,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "sc-allocator", "sp-maybe-compressed-blob", @@ -10062,7 +10062,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "anyhow", "cfg-if", @@ -10080,7 +10080,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "ansi_term", "futures", @@ -10096,7 +10096,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "array-bytes", "parking_lot 0.12.1", @@ -10110,7 +10110,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "array-bytes", "async-channel", @@ -10155,7 +10155,7 @@ dependencies = [ [[package]] name = "sc-network-bitswap" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "async-channel", "cid", @@ -10176,7 +10176,7 @@ dependencies = [ [[package]] name = "sc-network-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "array-bytes", "async-trait", @@ -10204,7 +10204,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "ahash 0.8.2", "futures", @@ -10223,7 +10223,7 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "array-bytes", "async-channel", @@ -10246,7 +10246,7 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "array-bytes", "async-channel", @@ -10281,7 +10281,7 @@ dependencies = [ [[package]] name = "sc-network-transactions" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "array-bytes", "futures", @@ -10300,7 +10300,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "array-bytes", "bytes", @@ -10331,7 +10331,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "futures", "libp2p-identity", @@ -10347,7 +10347,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -10356,7 +10356,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "futures", "jsonrpsee", @@ -10387,7 +10387,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -10406,7 +10406,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "http", "jsonrpsee", @@ -10421,7 +10421,7 @@ dependencies = [ [[package]] name = "sc-rpc-spec-v2" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "array-bytes", "futures", @@ -10447,7 +10447,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "async-trait", "directories", @@ -10513,7 +10513,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "log", "parity-scale-codec", @@ -10524,7 +10524,7 @@ dependencies = [ [[package]] name = "sc-storage-monitor" version = "0.1.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "clap 4.2.5", "fs4", @@ -10540,7 +10540,7 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -10559,7 +10559,7 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "6.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "futures", "libc", @@ -10578,7 +10578,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "chrono", "futures", @@ -10597,7 +10597,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "ansi_term", "atty", @@ -10628,7 +10628,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -10639,7 +10639,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "async-trait", "futures", @@ -10666,7 +10666,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "async-trait", "futures", @@ -10680,7 +10680,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "async-channel", "futures", @@ -11228,7 +11228,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "hash-db", "log", @@ -11248,7 +11248,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "Inflector", "blake2", @@ -11262,7 +11262,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "8.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "parity-scale-codec", "scale-info", @@ -11275,7 +11275,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "integer-sqrt", "num-traits", @@ -11289,7 +11289,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "parity-scale-codec", "scale-info", @@ -11302,7 +11302,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "parity-scale-codec", "sp-api", @@ -11314,7 +11314,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "futures", "log", @@ -11332,7 +11332,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "async-trait", "futures", @@ -11347,7 +11347,7 @@ dependencies = [ [[package]] name = "sp-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "async-trait", "parity-scale-codec", @@ -11365,7 +11365,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "async-trait", "parity-scale-codec", @@ -11386,7 +11386,7 @@ dependencies = [ [[package]] name = "sp-consensus-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "lazy_static", "parity-scale-codec", @@ -11405,7 +11405,7 @@ dependencies = [ [[package]] name = "sp-consensus-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "finality-grandpa", "log", @@ -11423,7 +11423,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "parity-scale-codec", "scale-info", @@ -11435,7 +11435,7 @@ dependencies = [ [[package]] name = "sp-core" version = "8.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "array-bytes", "bitflags", @@ -11479,7 +11479,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "blake2b_simd", "byteorder", @@ -11493,7 +11493,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "proc-macro2", "quote", @@ -11504,7 +11504,7 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "kvdb", "parking_lot 0.12.1", @@ -11513,7 +11513,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "proc-macro2", "quote", @@ -11523,7 +11523,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.14.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "environmental", "parity-scale-codec", @@ -11534,7 +11534,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -11549,7 +11549,7 @@ dependencies = [ [[package]] name = "sp-io" version = "8.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "bytes", "ed25519", @@ -11575,7 +11575,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "8.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "lazy_static", "sp-core", @@ -11586,7 +11586,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.14.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "futures", "parity-scale-codec", @@ -11600,7 +11600,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "thiserror", "zstd 0.12.3+zstd.1.5.2", @@ -11609,7 +11609,7 @@ dependencies = [ [[package]] name = "sp-metadata-ir" version = "0.1.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-metadata", "parity-scale-codec", @@ -11620,7 +11620,7 @@ dependencies = [ [[package]] name = "sp-mmr-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "ckb-merkle-mountain-range", "log", @@ -11638,7 +11638,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "parity-scale-codec", "scale-info", @@ -11652,7 +11652,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "sp-api", "sp-core", @@ -11662,7 +11662,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "backtrace", "lazy_static", @@ -11672,7 +11672,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "rustc-hash", "serde", @@ -11682,7 +11682,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "8.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "either", "hash256-std-hasher", @@ -11704,7 +11704,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "8.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -11722,7 +11722,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "Inflector", "proc-macro-crate", @@ -11734,7 +11734,7 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "parity-scale-codec", "scale-info", @@ -11748,7 +11748,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "parity-scale-codec", "scale-info", @@ -11761,7 +11761,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.14.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "hash-db", "log", @@ -11781,7 +11781,7 @@ dependencies = [ [[package]] name = "sp-statement-store" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "log", "parity-scale-codec", @@ -11799,12 +11799,12 @@ dependencies = [ [[package]] name = "sp-std" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" [[package]] name = "sp-storage" version = "8.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "impl-serde", "parity-scale-codec", @@ -11817,7 +11817,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "async-trait", "futures-timer", @@ -11832,7 +11832,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "parity-scale-codec", "sp-std", @@ -11844,7 +11844,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "sp-api", "sp-runtime", @@ -11853,7 +11853,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "async-trait", "log", @@ -11869,7 +11869,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "8.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "ahash 0.8.2", "hash-db", @@ -11892,7 +11892,7 @@ dependencies = [ [[package]] name = "sp-version" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "impl-serde", "parity-scale-codec", @@ -11909,7 +11909,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -11920,7 +11920,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "8.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -11933,7 +11933,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "parity-scale-codec", "scale-info", @@ -12174,7 +12174,7 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "platforms", ] @@ -12182,7 +12182,7 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "frame-system-rpc-runtime-api", "futures", @@ -12201,7 +12201,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "hyper", "log", @@ -12213,7 +12213,7 @@ dependencies = [ [[package]] name = "substrate-rpc-client" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "async-trait", "jsonrpsee", @@ -12226,7 +12226,7 @@ dependencies = [ [[package]] name = "substrate-state-trie-migration-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "jsonrpsee", "log", @@ -12245,7 +12245,7 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "array-bytes", "async-trait", @@ -12271,7 +12271,7 @@ dependencies = [ [[package]] name = "substrate-test-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "futures", "substrate-test-utils-derive", @@ -12281,7 +12281,7 @@ dependencies = [ [[package]] name = "substrate-test-utils-derive" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -12292,7 +12292,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "ansi_term", "build-helper", @@ -13137,7 +13137,7 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#2bc071f33da268ae218f2f376e7aa1dbf397ec76" +source = "git+https://github.com/paritytech/substrate?branch=master#628a74048fd07096c95dc3470c0dbbae26378416" dependencies = [ "async-trait", "clap 4.2.5", diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 227a4617ec7f..a361a2a6ec5c 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -546,7 +546,7 @@ pub mod pallet_test_notifier { use pallet_xcm::ensure_response; use sp_runtime::DispatchResult; use xcm::latest::prelude::*; - use xcm_executor::traits::XcmQueryHandler; + use xcm_executor::traits::QueryHandler as XcmQueryHandler; #[pallet::pallet] pub struct Pallet(_); diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index d65781d04e5f..61243c7d682b 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -1177,8 +1177,12 @@ impl QueryHandler for Pallet { } #[cfg(feature = "runtime-benchmarks")] - fn expect_response(id: Self::QueryId, status: QueryStatus) { - Queries::::insert(id, status); + fn expect_response(id: Self::QueryId, response: Response) { + let response = response.into(); + Queries::::insert( + id, + QueryStatus::Ready { response, at: frame_system::Pallet::::block_number() }, + ); } } diff --git a/xcm/xcm-builder/Cargo.toml b/xcm/xcm-builder/Cargo.toml index 6f4a4f9dde14..465d338fd0a7 100644 --- a/xcm/xcm-builder/Cargo.toml +++ b/xcm/xcm-builder/Cargo.toml @@ -36,7 +36,8 @@ polkadot-test-runtime = { path = "../../runtime/test-runtime" } default = ["std"] runtime-benchmarks = [ "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks" + "frame-system/runtime-benchmarks", + "xcm-executor/runtime-benchmarks", ] std = [ "log/std", diff --git a/xcm/xcm-builder/src/pay.rs b/xcm/xcm-builder/src/pay.rs index a4c35138d2fe..bf3db68e27a0 100644 --- a/xcm/xcm-builder/src/pay.rs +++ b/xcm/xcm-builder/src/pay.rs @@ -135,13 +135,15 @@ impl< } #[cfg(feature = "runtime-benchmarks")] - fn ensure_successful(_: &Self::Beneficiary, _: Self::Balance) { - Querier::expect_response(id); + fn ensure_successful(_: &Self::Beneficiary, _: Self::AssetKind, _: Self::Balance) { + // We cannot generally guarantee this will go through successfully since we don't have any + // control over the XCM transport layers. We just assume that the benchmark environment + // will be sending it somewhere sensible. } #[cfg(feature = "runtime-benchmarks")] fn ensure_concluded(id: Self::Id) { - Querier::expect_response(id); + Querier::expect_response(id, Response::ExecutionResult(None)); } } diff --git a/xcm/xcm-executor/src/traits/on_response.rs b/xcm/xcm-executor/src/traits/on_response.rs index e78200ed3cb2..34bb7eb9597d 100644 --- a/xcm/xcm-executor/src/traits/on_response.rs +++ b/xcm/xcm-executor/src/traits/on_response.rs @@ -21,6 +21,7 @@ use frame_support::{ pallet_prelude::{Get, TypeInfo}, }; use parity_scale_codec::{FullCodec, MaxEncodedLen}; +use sp_arithmetic::traits::Zero; use xcm::latest::{ Error as XcmError, InteriorMultiLocation, MultiLocation, QueryId, Response, Result as XcmResult, Weight, XcmContext, @@ -127,7 +128,7 @@ pub trait QueryHandler { + PartialEq + Debug + Copy; - type BlockNumber; + type BlockNumber: Zero; type Error; type UniversalLocation: Get; @@ -160,5 +161,5 @@ pub trait QueryHandler { /// Makes sure to expect a response with the given id. #[cfg(feature = "runtime-benchmarks")] - fn expect_response(id: Self::QueryId); + fn expect_response(id: Self::QueryId, response: Response); } From 3bedbab11228fbfd66b03fb6a45204e3e522d955 Mon Sep 17 00:00:00 2001 From: Gav Date: Tue, 30 May 2023 16:14:57 +0100 Subject: [PATCH 29/31] Destination can be determined based on asset_kind --- xcm/xcm-builder/src/pay.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xcm/xcm-builder/src/pay.rs b/xcm/xcm-builder/src/pay.rs index bf3db68e27a0..0d6acf1f559d 100644 --- a/xcm/xcm-builder/src/pay.rs +++ b/xcm/xcm-builder/src/pay.rs @@ -59,7 +59,7 @@ pub struct PayOverXcm< )>, ); impl< - DestinationChain: Get, + DestinationChain: for<'a> Convert<&'a AssetKind, MultiLocation>, Interior: Get, Router: SendXcm, Querier: QueryHandler, @@ -90,7 +90,7 @@ impl< asset_kind: Self::AssetKind, amount: Self::Balance, ) -> Result { - let destination_chain = DestinationChain::get(); + let destination_chain = DestinationChain::convert(&asset_kind); let destination = Querier::UniversalLocation::get() .invert_target(&destination_chain) .map_err(|()| Self::Error::LocationNotInvertible)?; @@ -179,3 +179,6 @@ pub type PayAccountId32OverXcm< AssetKind, crate::AliasesIntoAccountId32<(), Beneficiary>, >; + +#[test] +fn it_builds() {} From 9a28a2a4ca9b5ab9b4b3cd00824cf86e512add8c Mon Sep 17 00:00:00 2001 From: Gav Date: Tue, 30 May 2023 17:43:52 +0100 Subject: [PATCH 30/31] Tweaking API to minimise clones --- xcm/xcm-builder/src/lib.rs | 2 +- xcm/xcm-builder/src/location_conversion.rs | 12 ++++ xcm/xcm-builder/src/pay.rs | 80 +++++++++++++++------- 3 files changed, 67 insertions(+), 27 deletions(-) diff --git a/xcm/xcm-builder/src/lib.rs b/xcm/xcm-builder/src/lib.rs index df6d7c0f04d6..645a4ec616ed 100644 --- a/xcm/xcm-builder/src/lib.rs +++ b/xcm/xcm-builder/src/lib.rs @@ -98,4 +98,4 @@ pub use universal_exports::{ }; mod pay; -pub use pay::{PayAccountId32OverXcm, PayOverXcm}; +pub use pay::{PayAccountId32OnChainOverXcm, PayOverXcm}; diff --git a/xcm/xcm-builder/src/location_conversion.rs b/xcm/xcm-builder/src/location_conversion.rs index 84cc912e641c..bafec5da4a30 100644 --- a/xcm/xcm-builder/src/location_conversion.rs +++ b/xcm/xcm-builder/src/location_conversion.rs @@ -231,7 +231,19 @@ impl>, AccountId: From<[u8; 32]> + Into<[u8; 32]> Ok(AccountId32 { id: who.into(), network: Network::get() }.into()) } } + +/// Conversion implementation which converts from a `[u8; 32]`-based `AccountId` into a +/// `MultiLocation` consisting solely of a `AccountId32` junction with a fixed value for its +/// network (provided by `Network`) and the `AccountId`'s `[u8; 32]` datum for the `id`. pub struct AliasesIntoAccountId32(PhantomData<(Network, AccountId)>); +impl<'a, Network: Get>, AccountId: Clone + Into<[u8; 32]> + Clone> + Convert<&'a AccountId, MultiLocation> for AliasesIntoAccountId32 +{ + fn convert(who: &AccountId) -> Result { + Ok(AccountId32 { network: Network::get(), id: who.clone().into() }.into()) + } +} + impl>, AccountId: Into<[u8; 32]> + Clone> Convert for AliasesIntoAccountId32 { diff --git a/xcm/xcm-builder/src/pay.rs b/xcm/xcm-builder/src/pay.rs index 0d6acf1f559d..38a0d4479e4c 100644 --- a/xcm/xcm-builder/src/pay.rs +++ b/xcm/xcm-builder/src/pay.rs @@ -26,57 +26,60 @@ use xcm::{opaque::lts::Weight, prelude::*}; use xcm_executor::traits::{QueryHandler, QueryResponseStatus}; /// Implementation of the `frame_support::traits::tokens::Pay` trait, to allow -/// for XCM payments of a given `Balance` of `AssetKind` existing on a `DestinationChain` under -/// ownership of some `Interior` location of the local chain to a particular `Beneficiary`. +/// for XCM payments of a given `Balance` of some asset ID existing on some chain under +/// ownership of some `Interior` location of the local chain to a particular `Beneficiary`. The +/// `AssetKind` value can be converted into both the XCM `AssetId` (via and `Into` bound) and the +/// the destination chain's location, via the `AssetKindToDestination` type parameter. /// -/// This relies on the XCM `TransferAsset` instruction. A trait `BeneficiaryToLocation` must be -/// provided in order to convert the `Beneficiary` value into a location usable by `TransferAsset`. +/// This relies on the XCM `TransferAsset` instruction. A trait `BeneficiaryRefToLocation` must be +/// provided in order to convert the `Beneficiary` reference into a location usable by +/// `TransferAsset`. /// /// `PayOverXcm::pay` is asynchronous, and returns a `QueryId` which can then be used in /// `check_payment` to check the status of the XCM transaction. /// -/// See also `PayAccountId32OverXcm` which is similar to this except that `BeneficiaryToLocation` +/// See also `PayAccountId32OverXcm` which is similar to this except that `BeneficiaryRefToLocation` /// need not be supplied and `Beneficiary` must implement `Into<[u8; 32]>`. pub struct PayOverXcm< - DestinationChain, Interior, Router, Querier, Timeout, Beneficiary, AssetKind, - BeneficiaryToLocation, + AssetKindToLocatableAsset, + BeneficiaryRefToLocation, >( PhantomData<( - DestinationChain, Interior, Router, Querier, Timeout, Beneficiary, AssetKind, - BeneficiaryToLocation, + AssetKindToLocatableAsset, + BeneficiaryRefToLocation, )>, ); impl< - DestinationChain: for<'a> Convert<&'a AssetKind, MultiLocation>, Interior: Get, Router: SendXcm, Querier: QueryHandler, Timeout: Get, Beneficiary: Clone, AssetKind: Into, - BeneficiaryToLocation: Convert, + AssetKindToLocatableAsset: Convert, + BeneficiaryRefToLocation: for<'a> Convert<&'a Beneficiary, MultiLocation>, > Pay for PayOverXcm< - DestinationChain, Interior, Router, Querier, Timeout, Beneficiary, AssetKind, - BeneficiaryToLocation, + AssetKindToLocatableAsset, + BeneficiaryRefToLocation, > { type Beneficiary = Beneficiary; @@ -90,13 +93,14 @@ impl< asset_kind: Self::AssetKind, amount: Self::Balance, ) -> Result { - let destination_chain = DestinationChain::convert(&asset_kind); + let locatable = AssetKindToLocatableAsset::convert(asset_kind); + let LocatableAssetId { asset_id, location: asset_location } = locatable; let destination = Querier::UniversalLocation::get() - .invert_target(&destination_chain) + .invert_target(&asset_location) .map_err(|()| Self::Error::LocationNotInvertible)?; - let beneficiary = BeneficiaryToLocation::convert(who.clone()); + let beneficiary = BeneficiaryRefToLocation::convert(&who); - let query_id = Querier::new_query(destination_chain, Timeout::get(), Interior::get()); + let query_id = Querier::new_query(asset_location, Timeout::get(), Interior::get()); let message = Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, @@ -108,15 +112,12 @@ impl< DescendOrigin(Interior::get()), TransferAsset { beneficiary, - assets: vec![MultiAsset { - id: asset_kind.into(), - fun: Fungibility::Fungible(amount), - }] - .into(), + assets: vec![MultiAsset { id: asset_id, fun: Fungibility::Fungible(amount) }] + .into(), }, ]); - let (ticket, _) = Router::validate(&mut Some(destination_chain), &mut Some(message))?; + let (ticket, _) = Router::validate(&mut Some(asset_location), &mut Some(message))?; Router::deliver(ticket)?; Ok(query_id.into()) } @@ -147,10 +148,17 @@ impl< } } +pub struct ConvertToValue(sp_std::marker::PhantomData); +impl> Convert for ConvertToValue { + fn convert(_: X) -> Y { + T::get() + } +} + /// Specialization of the [PayOverXcm] trait to allow `[u8; 32]`-based `AccountId` values to be /// paid on a remote chain. /// -/// Implementation of the `frame_support::traits::tokens::Pay` trait, to allow +/// Implementation of the [frame_support::traits::tokens::Pay] trait, to allow /// for XCM payments of a given `Balance` of `AssetKind` existing on a `DestinationChain` under /// ownership of some `Interior` location of the local chain to a particular `Beneficiary`. /// @@ -161,7 +169,7 @@ impl< /// /// `PayOverXcm::pay` is asynchronous, and returns a `QueryId` which can then be used in /// `check_payment` to check the status of the XCM transaction. -pub type PayAccountId32OverXcm< +pub type PayAccountId32OnChainOverXcm< DestinationChain, Interior, Router, @@ -170,7 +178,6 @@ pub type PayAccountId32OverXcm< Beneficiary, AssetKind, > = PayOverXcm< - DestinationChain, Interior, Router, Querier, @@ -178,7 +185,28 @@ pub type PayAccountId32OverXcm< Beneficiary, AssetKind, crate::AliasesIntoAccountId32<(), Beneficiary>, + FixedLocation, >; +/// Simple struct which contains both an XCM `location` and `asset_id` to identift an asset which +/// exists on some chain. +pub struct LocatableAssetId { + /// The asset's ID. + pub asset_id: AssetId, + /// The (relative) location in which the asset ID is meaningful. + pub location: MultiLocation, +} + +/// Adapter `struct` which implements a conversion from any `AssetKind` into a [LocatableAsset] +/// value using a fixed `Location` for the `location` field. +pub struct FixedLocation(sp_std::marker::PhantomData); +impl, AssetKind: Into> Convert + for FixedLocation +{ + fn convert(value: AssetKind) -> LocatableAssetId { + LocatableAssetId { asset_id: value.into(), location: Location::get() } + } +} + #[test] fn it_builds() {} From 27a049976338789cb9b7a2e01e95780cec75bc6b Mon Sep 17 00:00:00 2001 From: Gav Date: Wed, 31 May 2023 10:27:10 +0100 Subject: [PATCH 31/31] Some repotting and docs --- xcm/xcm-builder/src/lib.rs | 2 +- xcm/xcm-builder/src/pay.rs | 13 +++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/xcm/xcm-builder/src/lib.rs b/xcm/xcm-builder/src/lib.rs index 645a4ec616ed..124e83d3c338 100644 --- a/xcm/xcm-builder/src/lib.rs +++ b/xcm/xcm-builder/src/lib.rs @@ -98,4 +98,4 @@ pub use universal_exports::{ }; mod pay; -pub use pay::{PayAccountId32OnChainOverXcm, PayOverXcm}; +pub use pay::{FixedLocation, LocatableAssetId, PayAccountId32OnChainOverXcm, PayOverXcm}; diff --git a/xcm/xcm-builder/src/pay.rs b/xcm/xcm-builder/src/pay.rs index 38a0d4479e4c..e8cd2b2bb287 100644 --- a/xcm/xcm-builder/src/pay.rs +++ b/xcm/xcm-builder/src/pay.rs @@ -26,10 +26,10 @@ use xcm::{opaque::lts::Weight, prelude::*}; use xcm_executor::traits::{QueryHandler, QueryResponseStatus}; /// Implementation of the `frame_support::traits::tokens::Pay` trait, to allow -/// for XCM payments of a given `Balance` of some asset ID existing on some chain under +/// for XCM-based payments of a given `Balance` of some asset ID existing on some chain under /// ownership of some `Interior` location of the local chain to a particular `Beneficiary`. The /// `AssetKind` value can be converted into both the XCM `AssetId` (via and `Into` bound) and the -/// the destination chain's location, via the `AssetKindToDestination` type parameter. +/// the destination chain's location, via the `AssetKindToLocatableAsset` type parameter. /// /// This relies on the XCM `TransferAsset` instruction. A trait `BeneficiaryRefToLocation` must be /// provided in order to convert the `Beneficiary` reference into a location usable by @@ -67,7 +67,7 @@ impl< Querier: QueryHandler, Timeout: Get, Beneficiary: Clone, - AssetKind: Into, + AssetKind, AssetKindToLocatableAsset: Convert, BeneficiaryRefToLocation: for<'a> Convert<&'a Beneficiary, MultiLocation>, > Pay @@ -148,13 +148,6 @@ impl< } } -pub struct ConvertToValue(sp_std::marker::PhantomData); -impl> Convert for ConvertToValue { - fn convert(_: X) -> Y { - T::get() - } -} - /// Specialization of the [PayOverXcm] trait to allow `[u8; 32]`-based `AccountId` values to be /// paid on a remote chain. ///